diff --git a/SpotifyKeyDumper/Hooks.cpp b/SpotifyKeyDumper/Hooks.cpp index 8ad21ba..91c2ae3 100644 --- a/SpotifyKeyDumper/Hooks.cpp +++ b/SpotifyKeyDumper/Hooks.cpp @@ -39,13 +39,26 @@ isValidUrl_v25 isValidUrl_v25_hook = nullptr; std::string authToken = std::string(); std::string keyStr = std::string(); - std::string uriStr = std::string(); +std::string fileId = std::string(); + __int64 newPosition = 0; bool signalled = false; int destKeyPtr = 0; char* keyBuffer_v47; +std::string lastUri = std::string(); +void TryDownload() +{ + if (signalled && lastUri.compare(uriStr) != 0) + { + signalled = false; + lastUri = uriStr; + std::thread t2(Utils::DownloadSong, std::string(fileId), uriStr, keyStr, authToken); + t2.detach(); + } +} + int __cdecl keyToLE_hook_v25(unsigned int* dest, int* key, int bits) { if (bits == 128) @@ -115,6 +128,9 @@ int __cdecl keyToLE_hook_v28(unsigned int* dest, int* key, int bits, bool isEnco { std::cout << "Key: " << Utils::HexString(reinterpret_cast(&newKey[0]), 16) << std::endl << std::endl; keyStr = newKey; + + if (Utils::GetSpotifyVersion() >= 45) + TryDownload(); } } @@ -178,20 +194,17 @@ int* __fastcall log_hook_v45(void* This, void* _EDX, int a2, int a3, void* a4, c return log_v45_hook(This, a2, a3, a4, classStr, a6, logThing); } -std::string lastUri = std::string(); void __fastcall fileIdWriter_hook_v45(void* This, void* _EDX, int* a2) { // [[ebp+8]+28] char* fileId = (char*) *(DWORD*)(a2 + 16); // 0x40 / 4 = 16 + ::fileId = std::string(fileId); - if (signalled && lastUri.compare(uriStr) != 0) - { - //std::cout << "signalled = false" << std::endl; - signalled = false; - lastUri = uriStr; - std::thread t2(Utils::DownloadSong, std::string(fileId), uriStr, keyStr, authToken); - t2.detach(); - } + /*std::cout << "fileId = " << fileId << std::endl; + std::cout << "uriStr = " << uriStr<< std::endl;*/ + + if (uriStr.length() > 15 && uriStr.compare(0, 15, "spotify:episode") == 0) + TryDownload(); return fileIdWriter_v45_hook(This, a2); } @@ -230,6 +243,7 @@ void __cdecl KeyBufferToKeyStr() { keyStr = newKey; std::cout << "Key: " << Utils::HexString(reinterpret_cast(&newKey[0]), 16) << std::endl; + TryDownload(); } }