Please first learn the language instead of copy&pasting fom progamercity.net
First, if you want to use MessageBoxA to display that you injected successfully, then do this before hooking it.
And by the way, it's better to create a thread for hooking and unhooking to see the effect better.
maybe there are other soultions for detouring, without unhooking it everytime it gets into my function
You don't even need to unhook the original function and hook yours. Just hook it, but don't forget to unhook the function after closing the application
@XxharCs
You mean before ejecting the dll. When the application closes, it doesn't matter anyway, because well.. the application closes.
Cleanup is only needed if you want to keep the process working after ejecting the dll.
but then i am unable to call messagebox (the original function) in "mymessagebox" cause my call would land in my fake function again and again (endless loop).
look, you replace the the first bytes of messagebox with YOUR JMP to YOUR NEW function.
if you don't unhook it in YOUR function and CALL it again, logically it lands back to the REPLACED BYTES (the JMP TO YOUR FUNCTION) and then it jmps again to your function. it trys again to call MessageBoxA, but it gets again to your func.
or what you mean?
i could only copy the orig. func. to new allocated memory, so i can call it from there..
and M$-detours is $hit, cause it does not support x64(free version) :P
Ms Detours isnt ****, your hooking library obviously is, if it doesn't support a trampoline, because that's what solves your problem.
One does not simply unhook a hook that is currently executing (it's possible, but it has no point in most cases and it isn't thread-safe).
Ms Detours isnt ****, your hooking library obviously is, if it doesn't support a trampoline, because that's what solves your problem.
One does not simply unhook a hook that is currently executing (it's possible, but it has no point in most cases and it isn't thread-safe).
but then i am unable to call messagebox (the original function) in "mymessagebox" cause my call would land in my fake function again and again (endless loop).
If you would have a good Detour Function/Library you would have an pointer to the original function and you could just call it. Don't really understand want your detour code is returning there. ( Well i understand it, but i don't know why it is returning the start adress of the function.)
I got no idea why you exaclty want to Unhook the function, once the hooked function is called and then want to hook it again. Hook it one Time on load and Unhook it on unload but only if the process is not closing and the dll is being unloaded. MrSmith said the rest.
[Tutorial] Hooking API's using C# 08/17/2020 - Coding Tutorials - 6 Replies Hello epvp, today i'm going to teach you how to hook MessageBox using C# ;)
Requirements & information ]
.NET framework 4
Visual Studio 20XX
EasyHook
MessageBox function(Windows)
Hooking - Wikipedia, the free encyclopedia
Help with API Hooking 01/30/2014 - C/C++ - 3 Replies Hi epvp i tried hooking the api CreateProcessA to change the parameters of the process to be loaded. But something is wrong cause the process Crashes :(
Here is the code:
#include <windows.h>
void* detourFunc(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwback;
Hooking with D 02/20/2013 - CO2 Programming - 6 Replies Comes with a homemade DLL injector although there's probably others that will do the job just as good.
If anyone's interested here's the tools I use
D compiler: Downloads - D Programming Language
IDE: Download - MonoDevelop
Mono-D (D support for MonoDevelop): Mono-D
C++ D3D Hooking 08/24/2009 - C/C++ - 12 Replies Hallo zusammen,
ich stehe gerade vor folgendem Problem:
ich habe eine DLL und einen Loader gecoded, jedoch will ich anstelle des Loader einen Injecter haben, sprich: das spiel, in das injected werden soll, soll schon laufen. Natürlich hab ich das ganze schon probiert, jedoch werden die D3D-funktionen nicht wirklich gehookt, da die DLL auf ein Direct3DCreate9 wartet. Da diese Funktion aber wahrscheinlich direkt beim Starten des "Opfer-Spiels" ausgeführt wird, werden deswegen die anderen...