1: #include "stdafx.h"
2: #include <fstream>
3:
4: BOOL APIENTRY DllMain( HMODULE hModule,
5: DWORD ul_reason_for_call,
6: LPVOID lpReserved
7: )
8: {
9: std::ofstream myfile;
10: switch (ul_reason_for_call)
11: {
12: case DLL_PROCESS_ATTACH:
13: myfile.open("c:\\misc\\dllInjectTest.txt");
14: myfile << "Bomb Diggity!\n";
15: myfile.close();
16: break;
17: case DLL_THREAD_ATTACH:
18: myfile.open("c:\\misc\\dllInjectTest.txt");
19: myfile << "Bomb Diggity!\n";
20: myfile.close();
21: case DLL_THREAD_DETACH:
22: case DLL_PROCESS_DETACH:
23: break;
24: }
25: return TRUE;
26: }
The DllMain function is what's executed when the DLL is loaded by a process or thread, or detached by the same.
No comments:
Post a Comment