Fix log hook crash by checking string length, fix possible other crashes with downloading.

This commit is contained in:
_ 2020-11-22 21:43:55 -07:00
parent 1c62192cd8
commit e237640858
2 changed files with 11 additions and 4 deletions

View File

@ -176,7 +176,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.compare(8, 9, "track_uri") == 0)
if (logStr.length() >= 32 && logStr.compare(8, 9, "track_uri") == 0) // 19 + 13 = 32
{
if (logStr.compare(19, 13, "spotify:track") == 0)
{
@ -184,12 +184,13 @@ int* __fastcall log_hook_v45(void* This, void* _EDX, int a2, int a3, void* a4, c
trackUriStr = logStr.substr(19, std::string::npos);
newPosition = 0;
}
// TODO
//else if (logStr.compare(19, 11, "spotify:ad") == 0) // Possibly this works?
else
/*else
{
std::cout << "Skipping ad: " << logStr.substr(19, std::string::npos) << std::endl;
newPosition = 29000; // 29 seconds: duration of ad
}
}*/
}
}
}
@ -216,7 +217,7 @@ void __fastcall fileIdWriter_hook_v45(void* This, void* _EDX, int* a2)
}
int signalEmitterInitCount = 0;
const int signalEmitterRequired = 5;
const int signalEmitterRequired = 3;
void __fastcall signalEmitter_hook_v45(void* This, void* _EDX, int a1, int a2)
{
//std::cout << "signalEmitter!!!" << std::endl << std::endl;

View File

@ -140,6 +140,12 @@ void Utils::DownloadSong(std::string fileId, std::string trackUri, std::string k
{
std::cout << "Downloading song..." << std::endl;
if (fileId.empty() || trackUri.empty() || key.empty() || authToken.empty())
{
std::cout << "Could not download song: missing fileId, trackUri, key, or authToken!" << std::endl;
return;
}
/*std::cout << "fileId = " << fileId << std::endl;
std::cout << "trackUri = " << trackUri << std::endl;
std::cout << "key = " << key << std::endl;