Skip to content

Instantly share code, notes, and snippets.

@TheWover
Created January 21, 2019 15:56
Show Gist options
  • Save TheWover/19f2151fc168c125c0889f833aa3f334 to your computer and use it in GitHub Desktop.
Save TheWover/19f2151fc168c125c0889f833aa3f334 to your computer and use it in GitHub Desktop.
DLLMain example
// 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;
}
@CodeDiseaseDev
Copy link

handy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment