. But I dont understand the code makes perfect sense to me it should work but when I inject it to dll with my injector I made my self, ce or winject it doesnt write the text file. Im just doing the text file to check if the dll initialized.#include "main.h"
#define game "Diablo II"
HWND hWnd;
HANDLE HndThread;
int Thread() {
while(1) {
ofstream file;
file.open("test.txt");
file << "worked";
file.close();
Sleep(1);
}
}
BOOL APIENTRY DllMain(HMODULE hModule,DWORD reason,LPVOID lpReserved) {
if(reason == DLL_PROCESS_ATTACH) {
hWnd = FindWindow(NULL,game);
if(hWnd == NULL) {
return false;
} else {
HndThread = CreateThread(0,0,(LPTHREAD_START_ROUTINE)Thread,NULL,0,NULL);
}
}
return true;
}
BOOL WINAPI DllMain( HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved )
{
if( dwReason == DLL_PROCESS_ATTACH )
{
CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE)Thread, NULL, NULL, NULL);
}
return TRUE;
}