Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include "Detour.h"
- /* PBYTE pbMessageBoxA = reinterpret_cast <PBYTE> (
- GetProcAddress(GetModuleHandle("User32.dll"), "MessageBoxA"));
- PBYTE pbMessageBoxW = reinterpret_cast <PBYTE> (
- GetProcAddress(GetModuleHandle("User32.dll"), "MessageBoxW")); */
- typedef int (WINAPI* tpMessageBoxA)(HWND, LPCTSTR, LPCTSTR, UINT);
- typedef int (WINAPI* tpMessageBoxW)(HWND, LPCWSTR, LPCWSTR, UINT);
- tpMessageBoxA p_tpMessageBoxA = NULL;
- tpMessageBoxW p_tpMessageBoxW = NULL;
- int WINAPI hkMessageBoxA(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) {
- return p_tpMessageBoxA(hWnd, "Detoured;)", lpCaption, uType);
- }
- int WINAPI hkMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType) {
- return p_tpMessageBoxW(hWnd, L"Detoured;)", lpCaption, uType);
- }
- BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
- if (fdwReason == 1) {
- p_tpMessageBoxA =
- reinterpret_cast <tpMessageBoxA> (DetourFunction(
- reinterpret_cast <PBYTE> (MessageBoxA),
- reinterpret_cast <PBYTE> (hkMessageBoxA)));
- /* p_tpMessageBoxA =
- reinterpret_cast <tpMessageBoxA> (DetourFunction(pbMessageBoxA,
- reinterpret_cast <PBYTE> (hkMessageBoxA))); */
- p_tpMessageBoxW =
- reinterpret_cast <tpMessageBoxW> (DetourFunction(
- reinterpret_cast <PBYTE> (MessageBoxW),
- reinterpret_cast <PBYTE> (hkMessageBoxW)));
- /* p_tpMessageBoxW =
- reinterpret_cast <tpMessageBoxW> (DetourFunction(pbMessageBoxW,
- reinterpret_cast <PBYTE> (hkMessageBoxW))); */
- } return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement