20-CreateDLL

Standard DLL syntax-> https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain
visual studio -> new project -> search for dll and select Pasted image 20240728113910.png

if you don't use dll one, and use empty project then make sure configuration type is set to DLL, - Solution explorer ctrl+alt+L
right click on RandomDLL and properties.
Pasted image 20240727221204.png

Pasted image 20240727221036.png

// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <windows.h>

BOOL WINAPI DllMain(
    HINSTANCE hModule,  // handle to DLL module
    DWORD Reason,     // reason for calling function
    LPVOID lpvReserved)  // reserved

{
    switch (Reason) {

    case DLL_PROCESS_ATTACH:
        MessageBoxW(NULL, L"HEY", L"hacker alert!", MB_ICONQUESTION | MB_OK);
        break;
    }

    return TRUE;
}

Build -> build solution.
rundll32.exe .\DllInjection.dll,DllMain
Pasted image 20240728114007.png