New download triggering

This commit is contained in:
_ 2020-11-30 18:35:18 -07:00
parent 2ebf25b1b0
commit b250b2fb40

View File

@ -39,13 +39,26 @@ isValidUrl_v25 isValidUrl_v25_hook = nullptr;
std::string authToken = std::string(); std::string authToken = std::string();
std::string keyStr = std::string(); std::string keyStr = std::string();
std::string uriStr = std::string(); std::string uriStr = std::string();
std::string fileId = std::string();
__int64 newPosition = 0; __int64 newPosition = 0;
bool signalled = false; bool signalled = false;
int destKeyPtr = 0; int destKeyPtr = 0;
char* keyBuffer_v47; 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) int __cdecl keyToLE_hook_v25(unsigned int* dest, int* key, int bits)
{ {
if (bits == 128) 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<BYTE*>(&newKey[0]), 16) << std::endl << std::endl; std::cout << "Key: " << Utils::HexString(reinterpret_cast<BYTE*>(&newKey[0]), 16) << std::endl << std::endl;
keyStr = newKey; 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); 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) void __fastcall fileIdWriter_hook_v45(void* This, void* _EDX, int* a2)
{ {
// [[ebp+8]+28] // [[ebp+8]+28]
char* fileId = (char*) *(DWORD*)(a2 + 16); // 0x40 / 4 = 16 char* fileId = (char*) *(DWORD*)(a2 + 16); // 0x40 / 4 = 16
::fileId = std::string(fileId);
if (signalled && lastUri.compare(uriStr) != 0) /*std::cout << "fileId = " << fileId << std::endl;
{ std::cout << "uriStr = " << uriStr<< std::endl;*/
//std::cout << "signalled = false" << std::endl;
signalled = false; if (uriStr.length() > 15 && uriStr.compare(0, 15, "spotify:episode") == 0)
lastUri = uriStr; TryDownload();
std::thread t2(Utils::DownloadSong, std::string(fileId), uriStr, keyStr, authToken);
t2.detach();
}
return fileIdWriter_v45_hook(This, a2); return fileIdWriter_v45_hook(This, a2);
} }
@ -230,6 +243,7 @@ void __cdecl KeyBufferToKeyStr()
{ {
keyStr = newKey; keyStr = newKey;
std::cout << "Key: " << Utils::HexString(reinterpret_cast<BYTE*>(&newKey[0]), 16) << std::endl; std::cout << "Key: " << Utils::HexString(reinterpret_cast<BYTE*>(&newKey[0]), 16) << std::endl;
TryDownload();
} }
} }