27 lines
906 B
C++
27 lines
906 B
C++
// test.cpp → compile as test.dll (x64, Release)
|
|
#include <windows.h>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
|
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
|
|
{
|
|
if (reason == DLL_PROCESS_ATTACH) {
|
|
DisableThreadLibraryCalls(hModule);
|
|
|
|
// 1. MessageBox = instant visible proof
|
|
MessageBoxA(NULL, "DLL INJECTED & DLLMAIN RAN!", "SUCCESS", MB_ICONINFORMATION);
|
|
|
|
// 2. Drop a file so you can see it even if no GUI
|
|
std::ofstream out("C:\\Users\\MyWindowsUser\\AppData\\Local\\Temp\\AREYOUWORKING.txt");
|
|
out << "DLL loaded at " << GetTickCount64() << " into PID " << GetCurrentProcessId() << std::endl;
|
|
out.close();
|
|
|
|
// 3. Keep process alive (critical!)
|
|
CreateThread(NULL, 0, [](LPVOID) -> DWORD {
|
|
for (;;) Sleep(60000);
|
|
return 0;
|
|
}, nullptr, 0, nullptr);
|
|
}
|
|
return TRUE;
|
|
}
|