Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate error caused by Scoop Installation of Spotify #4

Merged
merged 4 commits into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public class SpotifyProcess extends WinProcess {

// Spotify track id
private static final String PREFIX_SPOTIFY_TRACK = "spotify:track:";
private static final long ADDRESS_OFFSET_TRACK_ID = 0x1499F0;
private static final long[] OFFSETS_TRACK_ID = {
0x1499F0, // Vanilla
0xFEFE8 // Scoop
};

private final long addressTrackId;
private final PlaybackAccessor playbackAccessor;
Expand Down Expand Up @@ -54,10 +57,15 @@ private long findTrackIdAddress() {

// Find address of track id (Located in the chrome_elf.dll module)
long chromeElfAddress = chromeElfModule.getBaseOfDll();
long addressTrackId = chromeElfAddress + ADDRESS_OFFSET_TRACK_ID;

if (addressTrackId == -1 || !this.isTrackIdValid(this.readTrackId(addressTrackId))) {
throw new IllegalStateException("Could not find track id in memory");
// Check all offsets for valid track id
long addressTrackId = -1;
for (long trackIdOffset : OFFSETS_TRACK_ID) {
addressTrackId = chromeElfAddress + trackIdOffset;
if (addressTrackId == -1 || !this.isTrackIdValid(this.readTrackId(addressTrackId))) {
throw new IllegalStateException("Could not find track id in memory");
}
break;
}

if (DEBUG) {
Expand Down
Loading