Remove old code and add minor bug fixes

This commit is contained in:
_ 2020-11-27 03:01:24 -07:00
parent d0d699d35a
commit ee372660e4

View File

@ -8,17 +8,9 @@ keyToLE_v25 keyToLE_v25_hook = nullptr;
typedef int (__cdecl* keyToLE_v28)(unsigned int* dest, int* key, int bits, bool isEncoded);
keyToLE_v28 keyToLE_v28_hook = nullptr;
typedef int (__thiscall* authTokenOld_v45)(void* This, char* authToken, int a3, int a4, int a5, size_t tokenLength,
int a7, int a8, int a9, __int64 bearerStr, int a11, int a12, int a13, int a14, char a15, int a16, int int_40,
int a18, char a19, int a20);
authTokenOld_v45 authTokenOld_v45_hook = nullptr;
typedef int* (__thiscall* authToken_v45)(void* This, int* a2);
authToken_v45 authToken_v45_hook = nullptr;
typedef char* (__cdecl* hexToStr_v45)(char* dest, BYTE* src, size_t srcLength);
hexToStr_v45 hexToStr_v45_hook = nullptr;
typedef int* (__thiscall* openTrack_v45)(void* This, int a2, void* a3, int a4, __int64 position, char a6, void* a7);
openTrack_v45 openTrack_v45_hook = nullptr;
@ -29,11 +21,10 @@ log_v45 log_v45_hook;
typedef void (__thiscall* fileIdWriter_v45)(void* This, int* a2);
fileIdWriter_v45 fileIdWriter_v45_hook = nullptr;
//typedef int(__stdcall* signalEmitter_v45)(int a1, int a2);
typedef void (__thiscall* signalEmitter_v45)(void* This, int a1, int a2);
signalEmitter_v45 signalEmitter_v45_hook = nullptr;
std::string authToken;
std::string authToken = std::string();
std::string keyStr = std::string();
std::string trackUriStr = std::string();
@ -115,21 +106,6 @@ int __cdecl keyToLE_hook_v28(unsigned int* dest, int* key, int bits, bool isEnco
return keyToLE_v28_hook(dest, key, bits, isEncoded);
}
int __fastcall authTokenHookOld_hook_v45(void* This, void* _EDX, char* authToken, int a3, int a4, int a5,
size_t tokenLength, int a7, int a8, int a9, __int64 bearerStr, int a11, int a12, int a13, int a14, char a15,
int a16, int int_40, int a18, char a19, int a20)
{
if (tokenLength == 311)
{
//std::cout << "Auth token: " << authToken << std::endl << std::endl;
::authToken = std::string(authToken);
}
return authTokenOld_v45_hook(This, authToken, a3, a4, a5, tokenLength, a7, a8, a9, bearerStr, a11, a12, a13, a14,
a15, a16, int_40, a18, a19, a20);
}
int* __fastcall authToken_hook_v45(void* This, void* _EDX, int* a2)
{
char* authToken = (char*) *(DWORD*)((a2) + 2); // 8/4 = 2
@ -140,20 +116,6 @@ int* __fastcall authToken_hook_v45(void* This, void* _EDX, int* a2)
return authToken_v45_hook(This, a2);
}
char* __cdecl hexToStr_hook_v45(char* dest, BYTE* src, size_t srcLength)
{
//std::cout << "hexToStr hook" << std::endl;
if (srcLength == 20)
{
// Assume it is file id
//std::cout << "File id: " << Utils::HexString(src, srcLength) << std::endl << std::endl;
//std::cout << "file id!?" << std::endl;
}
return hexToStr_v45_hook(dest, src, srcLength);
}
int* __fastcall openTrack_hook_v45(void* This, void* _EDX, int a2, void* a3, int a4, __int64 position, char a6,
void* a7)
{
@ -176,7 +138,7 @@ int* __fastcall log_hook_v45(void* This, void* _EDX, int a2, int a3, void* a4, c
//std::cout << "logStr: " << logStr << std::endl;
if (logStr.length() >= 32 && logStr.compare(8, 9, "track_uri") == 0) // 19 + 13 = 32
if (logStr.length() > 32 && logStr.compare(8, 9, "track_uri") == 0) // 19 + 13 = 32
{
if (logStr.compare(19, 13, "spotify:track") == 0)
{
@ -258,6 +220,17 @@ char* GetKeyFuncAddrV27()
return (char*)0x01068F20;
}
/*
This will return addrOne if addrOneByte matches the BYTE at addrOne, or return addrTwo if not
*/
char* GetKeyFunc(char* addrOne, char* addrTwo, BYTE addrOneByte)
{
if (*(BYTE*)addrOne == addrOneByte)
return addrOne;
return addrTwo;
}
void Hooks::Init()
{
int spotifyVer = Utils::GetSpotifyVersion();
@ -294,15 +267,20 @@ void Hooks::Init()
keyToLE_v28_hook = (keyToLE_v28)Utils::TrampHook32((char*)0x010CF780, (char*)keyToLE_hook_v28, 6);
authToken_v45_hook = (authToken_v45)Utils::TrampHook32((char*)0x00BF75F0, (char*)authToken_hook_v45, 7);
//openTrack_v45_hook = (openTrack_v45)Utils::TrampHook32((char*)0x00CA5740, (char*)&openTrack_hook_v45, 5);
log_v45_hook = (log_v45)Utils::TrampHook32((char*)0x10F2370, (char*)&log_hook_v45, 5);
log_v45_hook = (log_v45)Utils::TrampHook32((char*)0x010F2370, (char*)&log_hook_v45, 5);
fileIdWriter_v45_hook = (fileIdWriter_v45)Utils::TrampHook32((char*)0x00CBB560, (char*)&fileIdWriter_hook_v45,
5);
signalEmitter_v45_hook = (signalEmitter_v45)Utils::TrampHook32((char*)0x00B095A0, (char*)signalEmitter_hook_v45,
5);
//hexToStr_v45_hook = (hexToStr_v45)Utils::TrampHook32((char*)0x010F81A0, (char*)hexToStr_hook_v45, 7);
break;
case 46:
keyToLE_v28_hook = (keyToLE_v28)Utils::TrampHook32((char*)0x010C2FB0, (char*)keyToLE_hook_v28, 6);
authToken_v45_hook = (authToken_v45)Utils::TrampHook32((char*)0x00BEC8E0, (char*)authToken_hook_v45, 7);
log_v45_hook = (log_v45)Utils::TrampHook32((char*)0x010E59E0, (char*)&log_hook_v45, 5);
fileIdWriter_v45_hook = (fileIdWriter_v45)Utils::TrampHook32((char*)0x00CB00D0, (char*)&fileIdWriter_hook_v45,
5);
signalEmitter_v45_hook = (signalEmitter_v45)Utils::TrampHook32((char*)0x00B02270, (char*)signalEmitter_hook_v45,
5);
break;
}
}