Go to visual studio and start a windows console application. And create a simple message box inside Main,
your code will look like the following:
#include <Windows.h>
int main()
{
DWORD dwMessageBoxA = (DWORD)MessageBoxA;
char *lpText = "Test";
char *lpCaption = "Hello World!";
_asm push 0 //hWnd
_asm push lpText //lpText
_asm push lpCaption //lpCaption
_asm push 0 //uType 0 = MB_OK
_asm call dwMessageBoxA //Our Call
_asm add esp,0xC //0xC = return
}
GHL.h
class GHL
{
//Api
void dwMessageBox(HWND hWnd,LPCSTR lpText,LPCSTR lpCaption,UINT uType);
void ExitUserProcess();
void DestroyWindow();
};
extern GHL *GameHook;
GHL.cpp
void GHL::dwMessageBox(HWND hWnd,LPCSTR lpText,LPCSTR lpCaption,UINT uType)
{
HMODULE USER32 = LoadLibraryA("user32.dll");
DWORD dwMessageBoxA = (DWORD) GetProcAddress(USER32,"MessageBoxA");
_asm push hWnd //hwnd
_asm push lpText //lpText
_asm push lpCaption //lpCaption
_asm push uType //uType
_asm call dwMessageBoxA //Call
_asm add esp, 0xC //Ret
}
void GHL::ExitUserProcess()
{
HMODULE NTDLL = LoadLibraryA("ntdll.dll");
DWORD dwExitProcess = (DWORD) GetProcAddress(NTDLL,"NtTerminateProcess");
_asm push 0 //ExitCode
_asm call dwExitProcess //Call
_asm add esp, 0xC //Ret
}
void GHL::DestroyWindow()
{
HMODULE KERNAL32 = LoadLibraryA("Kernel32.dll");
DWORD dwDestroyWindow = (DWORD) GetProcAddress(KERNAL32,"DestroyWindow");
HANDLE Cod4 = FindWindowA("Call of Duty 4","Call of Duty 4");
_asm push Cod4 //hWnd
_asm call dwDestroyWindow //Call
_asm add esp, 0xC //Ret
}
You can use Theses like:
in dllMain.cpp
GHL *GameHook;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved )
{
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls(hinstDLL);
main_hinstDLL = hinstDLL;
LOG.Log("CREDIT","SALT3R <333");
GameHook->dwMessageBox(0,"Test","Test",MB_OK);
return true;
break;
}
case DLL_PROCESS_DETACH:
{
LOG.Log("CREDIT","SALT3R <333");
break;
}
}
return TRUE;
}
Usage: Same as the default MessageBoxA...
P.S. It's written inline for education & getting used to using inline
by Salt3r