Skip to content

Commit

Permalink
Mitigate error caused by Scoop Installation of Spotify (#4)
Browse files Browse the repository at this point in the history
* Fix invalid Offsets on the Scoop Version of Spotify

* Rewrote Scoop fix to make it more robust and look better in general

* use array of offsets instead

* let's just call it offsets

---------

Co-authored-by: LabyStudio <[email protected]>
  • Loading branch information
HerXayah and LabyStudio authored Sep 8, 2023
1 parent e6d2330 commit 322dd42
Showing 1 changed file with 12 additions and 4 deletions.
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

0 comments on commit 322dd42

Please sign in to comment.