detours

Is there any way to override the drag/drop or copy/paste behavior of an existing app in Windows?

I would like to extend some existing applications' drag and drop behavior, and I'm wondering if there is any way to hack on drag and drop support or changes to drag and drop behavior by monitoring the app's message loop and injecting my own messages. It would also work to monitor for when a paste operation is executed, basically to crea...

C++ - Detours WinSock Hooking

What I am trying to do is use the Detours library to hook into an applications WinSock2 send() and recv() functions (a packet logger). While it does work for the send() function, it does not, however, work for the recv() function. Here is my relevant code: #include <cstdio> #include <ctime> #include <fstream> #include <iomanip> #inclu...

Where inside injected DLL to loop?

Hey guys, So I've got an application that starts another application with my DLL injected (with Detours). The entry point is DllMain. I can't do much from DllMain, and certainly cannot loop. So how do I call my DLL monitor functions every x seconds? I read you cannot create a thread from DllMain (at least until it returns) and its true ...

What is the recommended way to hook Win32 APIs for a commmercial application?

What is your recommendation for an API hooking library or code to be used in a commercial application? I have looked at Microsoft Detours which seems to be very good, but definitely is out of budget for the profit I am expecting out of my application. Is there any library that offers compatibility across WinXP and Vista (and Windows 7...

Cannot get ::WideCharToMultiByte to work

Dears, I've got a DLL for injection. This is injected via CBT-hook. Now, when the desired process is encountered via CBT, I've detoured WinAPI's ExtTextOutW with my own. The specification of ExtTextOutW is: BOOL ExtTextOutW(HDC hdc, INT x, INT y, UINT fl...

Detouring DrawText

I've downloaded and compiled the Microsoft detouring library. Inside my project I've included the header file and added the .lib file as a dependency. Everything compiles without errors. Now I've been trying to detour DrawText, but for some reason that detoured function doesn't get called at all. Similiarly I tried detouring the Sleep fu...

C++ - Pointer to a class method

I have to set up a pointer to a library function (IHTMLDocument2::write) which is a method of the class IHTMLDocument2. (for the curious: i have to hook that function with Detours) I can't do this directly, because of type mismatch, neither can I use a cast (reinterpret_cast<> which is the "right one" afaik doesn't work) Here's what I ...

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

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 hijac...

Any other way to redirect a connection to custom ip/port?

Hi, I need to redirect a connection from a game to my custom ip/port. I know that it can be done via detours, or modifying the host file, just wondering if there is any other way? ...

Detour to get a Global Pointer?

Hey guys, I need to get the protocol version of an application, and I don't know too much about the inner workings of detouring. I usually use a detour class written by a friend of mine (Not windows detour, as this works on win/linux) but im wondering if anyone can give me some insight on how to retrieve the value of a global pointer? I...

Is it possible to override a Java implementation of the Random class?

Using Windows Detours in C++, I've seen that it is possible to trampoline function calls so that you may intercept windows base functionality and return custom resultsets, without modifying the original function call. I was wondering if there is any way to override a Java Randomization call so that I may implement my own result set. ...

Intercept ActiveX/COM methods

Hello. There is a VB6 application with VSFlexGrid control in it. On My WinXP machine OCX is here: c:\WINDOWS\system32\Vsflex7L.ocx I assume application calls AddItem method of this OCX to add new items to the grid. And I want to intercept this call and obtain data passed to AddItem method. The question is - what is the best way to do ...

Tracking HDC from injected process

Hi, I'm facing quite a dilemma. I've injected my DLL into other process as well as hooked few WinAPI calls from there, ExtTextOutW@GDI32, DrawTextExW@GDI32 and AlphaBlend@Msimg32 to be specific. Now, the problem is that when the other application writes something with those two GDI32 functions, i don't know the exact location where it c...

c++ d3d hooking - COM vtable

Trying to make a Fraps type program. See comment for where it fails. #include "precompiled.h" typedef IDirect3D9* (STDMETHODCALLTYPE* Direct3DCreate9_t)(UINT SDKVersion); Direct3DCreate9_t RealDirect3DCreate9 = NULL; typedef HRESULT (STDMETHODCALLTYPE* CreateDevice_t)(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD B...

What does DetourAttach(&(PVOID &)BindKeyT, BindKeyD); mean? Attaching a detour to a memory address...

Hello everyone! This is just a simple question. I've been reading the source of something which attaches to a memory address of a subroutine using DetourAttach(&(PVOID &)BindKeyT, BindKeyD); where BindKeyT is the address to a subroutine in memory. I'm curious, what exactly does (&(PVOID &) mean in english? I understand that PVOID is a v...

Need to call original function from detoured function

I'm using Detours to hook into an executable's message function, but I need to run my own code and then call the original code. From what I've seen in the Detours docs, it definitely sounds like that should happen automatically. The original function prints a message to the screen, but as soon as I attach a detour it starts running my co...

Microsoft Detours - DetourUpdateThread?

Hi, I have a few quick questions about the Microsoft Detours Library. I have used it before (successfully), but I just had a thought about this function: LONG DetourUpdateThread(HANDLE hThread); I read elsewhere that this function will actually suspend the thread until the transaction completes. This seems odd since most sample code c...

C/C++ Detours Library - where to find?

Hi! I came to a piece of code that includes "HookEngine/CDetours.hpp", search for a bit of info and came ot that is Microsoft Project, but i cant find what i'm looking for. I downloaded the Express Edition but this ediotion doesn't contain the HookEngine. ...

Dev-C++ and Detours compiling error

Hello. As title says I'm trying to compile with Dev-C++ a simple DLL using Detours, but I get this error: syntax error before token '&' on this lines: DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox) DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox) The complete code is #include <windows.h> #include <detours.h> #pr...

Can I redirect .NET method calls to a new method at runtime?

Suppose I have the following .NET classes: public class C { public void M() { .... } } and public class D { public void N() { .... } } These 2 classes reside in different namespaces, in different assemblies. Is there a way to cause all call to C.M() to 'redirect' automatically to D.N()? So,...