Created
January 21, 2019 15:56
-
-
Save TheWover/19f2151fc168c125c0889f833aa3f334 to your computer and use it in GitHub Desktop.
DLLMain example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dllmain.cpp : Defines the entry point for the DLL application. | |
#include "stdafx.h" | |
#include <string> | |
std::string test = "not Loaded"; | |
BOOL APIENTRY DllMain( HMODULE hModule, | |
DWORD ul_reason_for_call, | |
LPVOID lpReserved | |
) | |
{ | |
//test = "loaded"; //You also change on this location the value of a variable | |
char cmd[] = "cmd.exe"; | |
switch (ul_reason_for_call) | |
{ | |
case DLL_PROCESS_ATTACH: | |
//MessageBoxA(NULL, "test", "test", NULL); | |
WinExec(cmd, SW_SHOWNORMAL); | |
ExitProcess(0); | |
break; | |
case DLL_THREAD_ATTACH: | |
case DLL_THREAD_DETACH: | |
case DLL_PROCESS_DETACH: | |
break; | |
} | |
return TRUE; | |
} | |
extern "C" __declspec (dllexport) bool example() | |
{ | |
MessageBoxA(NULL, test.c_str(), "test", NULL); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
handy