diff --git a/SpotifyKeyDumperInjector/SpotifyKeyDumperInjector.cpp b/SpotifyKeyDumperInjector/SpotifyKeyDumperInjector.cpp index c252293..2f151ee 100644 --- a/SpotifyKeyDumperInjector/SpotifyKeyDumperInjector.cpp +++ b/SpotifyKeyDumperInjector/SpotifyKeyDumperInjector.cpp @@ -17,7 +17,7 @@ DWORD GetProcId(const wchar_t* procName) if (hSnap != INVALID_HANDLE_VALUE) { - PROCESSENTRY32 procEntry; + PROCESSENTRY32 procEntry = {}; procEntry.dwSize = sizeof(procEntry); if (Process32First(hSnap, &procEntry)) @@ -53,7 +53,6 @@ void StartSuspendedInjection() std::wstring procNameW = std::wstring(PROC_NAME); MessageBox(NULL, std::wstring(procNameW + std::wstring(L" has already been detected!\n\n" "Please launch this before ") + procNameW).c_str(), NULL, MB_OK | MB_ICONERROR); - return; } @@ -63,21 +62,22 @@ void StartSuspendedInjection() startupInfo.cb = sizeof(STARTUPINFOA); ZeroMemory(&procInfo, sizeof(procInfo)); - if (!CreateProcess(PROC_NAME, NULL, NULL, NULL, false, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &procInfo)) + if (!CreateProcessW(PROC_NAME, NULL, NULL, NULL, false, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &procInfo)) { - std::wcout << "Error: Could not start " << PROC_NAME << " (could not create process)" << std::endl; + std::wcout << "Error: Could not start " << PROC_NAME << " (could not create process): " << GetLastError() + << std::endl; return; } std::cout << "Injecting DLL..." << std::endl; - if (GetFileAttributes(PROC_NAME) == INVALID_FILE_ATTRIBUTES) + if (GetFileAttributesW(PROC_NAME) == INVALID_FILE_ATTRIBUTES) { std::wcout << "Error: DLL injection failed (could not find " << PROC_NAME << ")" << std::endl; return; } - if (GetFileAttributes(DLL_FILE_PATH) == INVALID_FILE_ATTRIBUTES) + if (GetFileAttributesW(DLL_FILE_PATH) == INVALID_FILE_ATTRIBUTES) { std::wcout << "Error: DLL injection failed (could not find " << DLL_FILE_PATH << ")" << std::endl; return; @@ -86,13 +86,13 @@ void StartSuspendedInjection() tmpPage = VirtualAllocEx(procInfo.hProcess, NULL, dllPathLen, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); if (tmpPage == NULL) { - std::wcout << "Error: DLL injection failed (could not allocate memory)" << std::endl; + std::wcout << "Error: DLL injection failed (could not allocate memory): " << GetLastError() << std::endl; return; } if (!WriteProcessMemory(procInfo.hProcess, tmpPage, (PVOID) DLL_FILE_PATH, dllPathLen, NULL)) { - std::wcout << "Error: DLL injection failed (could not write memory)" << std::endl; + std::wcout << "Error: DLL injection failed (could not write memory): " << GetLastError() << std::endl; return; } @@ -100,19 +100,20 @@ void StartSuspendedInjection() NULL); if (injectThread == NULL) { - std::wcout << "Error: DLL injection failed (could not load library)" << std::endl; + std::wcout << "Error: DLL injection failed (could not load library): " << GetLastError() << std::endl; return; } if (WaitForSingleObject(injectThread, UINT_MAX) == WAIT_FAILED) { - std::wcout << "Error: DLL injection failed (could not wait for thread to return)" << std::endl; + std::wcout << "Error: DLL injection failed (could not wait for thread to return): " << GetLastError() + << std::endl; return; } if (ResumeThread(procInfo.hThread) == -1) { - std::wcout << "Error: DLL injection failed (could not resume thread)" << std::endl; + std::wcout << "Error: DLL injection failed (could not resume thread): " << GetLastError() << std::endl; return; }