detours

How to use the Detour library in C++ properly for a simple hook of a function with known memory adress?

▼魔方 西西 提交于 2019-12-11 12:49:05
问题 I am having trouble to get my first hook using detour to work. I am using Detour 3.0. My code compiles fine and I can inject the DLL using Winject , however, the function which I am suppose to hook doesnt seem to be hooked. I am trying to hook the function InsertDateTime in notepad . http://www.9injector.com/winject-injector/ I have found the adress of the InsertDateTime in hex notation using IDA Pro Free . Is there anything fundmatal misstakes in the code below or is the memory in the

C++ — Detours (Win32 API Hijacking) — Hijack Class Methods

橙三吉。 提交于 2019-12-10 18:01:48
问题 I had no problems hijacking function with Detours for a long time... When I tried to hijack class methods (in my case IHTMLDocument2::write from mshtml.dll) I encountered endless problems (mainly type mismatching). As I didn't find any relevant example on the net I began doubting this can be done. My question is: is it possible to hijack class methods with Detours? Can I have an example, please? If not, is it possible to hijack class methods in a simpler way with another hooking library?

C++ and FULLY dynamic functions

久未见 提交于 2019-12-10 13:34:29
问题 I have a problem with detours. Detours, as you all know, can only move among 5 bytes of space (i.e a 'jmp' call and a 4 byte address). Because of this it is impossible to have the 'hook' function in a class (a method), you cannot supply the 'this' pointer because there is simply not enough space (here's the problem more thoroughly explained). So I've been brainstorming all day for a solution, and now I want your thoughts on the subject so I don't begin a 3-5 day project without knowing if it

Preventing a DLL file from loading into my process via MS Detours

给你一囗甜甜゛ 提交于 2019-12-09 23:06:03
问题 I'd like to prevent a specific third-party DLL file from loading into my application's process at runtime. My initial attempt at this was using the MS Detours product. I have a 32-bit MFC application running on Windows 10 64-bit. I tested with the free MS Detours 3.0 version as a feasibility check. In my MFC application class constructor, I call Detours to intercept the "load library" APIs (LoadLibraryW, LoadLibraryExW, LoadLibraryA, and LoadLibraryExA). This lets me intercept library loading

MS Detours Express 3.0 is not hooking CreateFile win32 API function properly

懵懂的女人 提交于 2019-12-08 12:37:11
问题 I am trying to hook win32 API function "CreateFile" using MS Detours, but when I test it by opening a *.doc file using MS Word, The CreateFile call for DLLs and font files and directories loaded by MS Word are redirected to my detoured function but not for that *.doc file, but when I open a *.txt file using notepad the CreateFile call for that *.txt file comes to my detoured function. I am using following code for hooking CreateFile: static HANDLE (WINAPI *Real_CreateFile)(LPCWSTR lpFileName,

Detours Hook memcpy Not Working

假如想象 提交于 2019-12-08 12:13:18
问题 I have programmed hook for memcpy but it only calls on the end of the program. Not each time, when was function called. Also the adresses are different. This is the hook: #include <windows.h> #include<iostream> #include "detours\detours.h" #pragma comment( lib, "msvcrt.lib" ) #pragma comment( lib, "detours.lib" ) //#pragma comment( lib, "detoured.lib" ) //int (WINAPI *Real_Send)(SOCKET s, const char *buf, int len, int flags) = send; //int WINAPI Mine_Send(SOCKET s, const char* buf, int len,

Detouring and using a _thiscall as a hook (GCC calling convention)

丶灬走出姿态 提交于 2019-12-08 04:57:07
问题 I've recently been working on detouring functions (only in Linux) and so far I've had great success. I was developing my own detouring class until I found this. I modernized the code a bit and converted it to C++ (as a class of course). That code is just like any other detour implementation, it replaces the original function address with a JMP to my own specified 'hook' function. It also creates a 'trampoline' for the original function. Everything works flawlessly but I'd like to do one

My trampoline won't bounce (detouring, C++, GCC)

安稳与你 提交于 2019-12-08 02:47:27
问题 It feels like I'm abusing Stackoverflow with all my questions, but it's a Q&A forum after all :) Anyhow, I have been using detours for a while now, but I have yet to implement one of my own (I've used wrappers earlier). Since I want to have complete control over my code (who doesn't?) I have decided to implement a fully functional detour'er on my own, so I can understand every single byte of my code. The code (below) is as simple as possible, the problem though, is not. I have successfully

Several programs crash when unhooking with UnhookWindowsHookEx()

柔情痞子 提交于 2019-12-06 14:56:06
问题 I am doing a global hook to add my DLL to the hook chain: HHOOK handle = SetWindowsHookEx(WH_CALLWNDPROC, addr, dll, 0); Inside my DLL I am using Detours to intercept several WINAPI function calls. Everything works fine, except for WaitForSingleObject calls. Whenever I add WaitForSingleObject to the detoured functions, several programs crash when I unhook my DLL (Chrome, Skype, ...). Here is how the DLL looks: DWORD (WINAPI* Real_WaitForSingleObject)( HANDLE hHandle, DWORD dwMilliseconds) =

Having trouble with microsoft detours

此生再无相见时 提交于 2019-12-06 13:36:55
问题 I'm trying to do some basic hooking with microsoft detours and I can't get it to work. I've used essentially the code that was posted in this thread: How can I hook Windows functions in C/C++? but no dice. I updated the send/receive functions in the DLL code to simply log the data to a file, and I tried having the main program hook into the "internet checkers" program, but a log file never gets created, so it appears that the dll wasn't injected. I'm running Windows 7 64-bit, Visual Studio 10