Skip to content

Instantly share code, notes, and snippets.

@filipesam
Forked from reigningshells/Cplapplet.cpp
Created January 29, 2023 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filipesam/e8dde44eaf994a6e3bc73944d567316f to your computer and use it in GitHub Desktop.
Save filipesam/e8dde44eaf994a6e3bc73944d567316f to your computer and use it in GitHub Desktop.
DllMain template to execute code in a .cpl file which is just a renamed DLL that exports a function CplApplet
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <Windows.h>
extern "C" __declspec(dllexport) LONG CplApplet()
{
MessageBoxA(NULL, "Replace this message box with something more interesting...", "Control Panel", 0);
return 1;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
CplApplet();
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment