im trying to write a dll that kills the process that loads it. (seems stupid but i have my reasons)
#include <windows.h>
#include <stdio.h>
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
OutputDebugString("Hello From The Dll");
ExitProcess(-69);
break;
case DLL_PROCESS_DETACH:
ExitProcess(-69);
break;
case DLL_THREAD_ATTACH:
ExitProcess(-69);
break;
case DLL_THREAD_DETACH:
ExitProcess(-69);
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
the person that sent me the code also sent a compiled dll (that works) but
when i compile the code then load the dll it doesnt work
here is the program im using to load the dll
#include <cstdlib>
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[])
{
char* DllName = "TestDll.dll"; /* Name of the dll to be loaded */
/* Load the dll */
printf("trying to load %s \n", DllName);
HMODULE EmployeDll = LoadLibrary(DllName);
/* Give some output */
if(EmployeDll != 0)
{
printf("%s is loaded into memory \n\n", DllName);
//FreeLibrary(EmployeDll); /* Unload the dll from memory */
}
else
printf("error loading %s into memory \n\n", DllName);
/* And then say goodbye */
system("PAUSE");
return EXIT_SUCCESS;
}
any ideas why the code is not working ?