Skip to content

Commit 322dd42

Browse files
HerXayahLabyStudio
andauthored
Mitigate error caused by Scoop Installation of Spotify (#4)
* 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]>
1 parent e6d2330 commit 322dd42

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main/java/de/labystudio/spotifyapi/platform/windows/api/spotify/SpotifyProcess.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ public class SpotifyProcess extends WinProcess {
1717

1818
// Spotify track id
1919
private static final String PREFIX_SPOTIFY_TRACK = "spotify:track:";
20-
private static final long ADDRESS_OFFSET_TRACK_ID = 0x1499F0;
20+
private static final long[] OFFSETS_TRACK_ID = {
21+
0x1499F0, // Vanilla
22+
0xFEFE8 // Scoop
23+
};
2124

2225
private final long addressTrackId;
2326
private final PlaybackAccessor playbackAccessor;
@@ -54,10 +57,15 @@ private long findTrackIdAddress() {
5457

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

59-
if (addressTrackId == -1 || !this.isTrackIdValid(this.readTrackId(addressTrackId))) {
60-
throw new IllegalStateException("Could not find track id in memory");
61+
// Check all offsets for valid track id
62+
long addressTrackId = -1;
63+
for (long trackIdOffset : OFFSETS_TRACK_ID) {
64+
addressTrackId = chromeElfAddress + trackIdOffset;
65+
if (addressTrackId == -1 || !this.isTrackIdValid(this.readTrackId(addressTrackId))) {
66+
throw new IllegalStateException("Could not find track id in memory");
67+
}
68+
break;
6169
}
6270

6371
if (DEBUG) {

0 commit comments

Comments
 (0)