Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 12:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Detours 1.5 auf JMP

Discussion on Detours 1.5 auf JMP within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Mar 2010
Posts: 360
Received Thanks: 132
Detours 1.5 auf JMP

Ich habe eine Funktion A.
A hat als erste Anweisung einen JMP.
DetourFunction liefert keinerlei Probleme und mein Hook wird ordenungsgemäß ausgeführt.
DetourRemove liefert false. Ein Blick in den debugger bestätigt dieses Ergebnis. Der Hook wurde nicht entfernt.


Offensichtlich kommt DetourRemove mit dem Berechnen des neuen JMP Offsets nicht zurecht. Gibt es für diesen Fall eine spezielle Funktion die ich nutzen muss ?


PS: Eine Antwort eilt nicht. Ich habe das Problem bereits behoben, indem ich mir einen eigenen DetourHandler geschrieben habe. Aber es wäre trotzdem schön zu wissen, ob die nativen MS Detours 1.5 für diesen Fall eine Lösung bieten.
Daifoku is offline  
Old 10/02/2015, 23:52   #2
 
xAxTer's Avatar
 
elite*gold: 0
Join Date: Sep 2015
Posts: 18
Received Thanks: 1
It's so easy but it needs some background knowledge about C++ detors.

anyway, I made a full detor hooking for you:

Code:
// globals for hook and retn
DWORD dwHook = 0x00000000; //place your address here

BOOL WINAPI DllMain( HMODULE hMod, DWORD dwReason, LPVOID lpReserved )
{
	if( dwReason == DLL_PROCESS_ATTACH )
	{
		// hook it by a JMP on the dwHook offset
		PlaceJMP( (PBYTE)dwHook, (DWORD)TargetFunc, 0x4);
		MessageBox(0, "Hook placed successfully.", "Info", MB_OK);
	}
 
	return TRUE;
}


// Target Function to be Hooked
__declspec( naked ) void TargetFunc()
{
	__asm PUSH EBX;
	__asm PUSH EBP;
	__asm PUSH ESI;
	__asm MOV ESI, [EDI+0x0A7C]; // jumped
 
	__asm PUSHAD;
 
	Func();
 
	__asm POPAD;
	__asm JMP [dwRet];
}
 

void PlaceJMP(BYTE *pAddress, DWORD dwJumpTo, DWORD dwLen )
{
	DWORD dwOldProtect, dwBkup, dwRelAddr;
	
	VirtualProtect(pAddress, dwLen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
	dwRelAddr = (DWORD) (dwJumpTo - (DWORD) pAddress) - 5;
	*pAddress = 0xE9;
	
	*((DWORD *)(pAddress + 0x1)) = dwRelAddr;
	for(DWORD x = 0x5; x < dwLen; x++) *(pAddress + x) = 0x90;
	VirtualProtect(pAddress, dwLen, dwOldProtect, &dwBkup);
	
	return;
}
xAxTer is offline  
Old 10/03/2015, 00:10   #3
 
elite*gold: 0
Join Date: Mar 2010
Posts: 360
Received Thanks: 132
That was not the question ;-)

I made my own detours (which was really easy) but I wanted to know how to do it with MS Detours 1.5. There is no documentation about detours 1.5, 2.0, 3.0, ...

and this topic was about DetourRemove. Detouring worked fine but I couldn't remove the Detour because the trampoline was wrong.
Daifoku is offline  
Reply


Similar Threads Similar Threads
detours 3.0
02/11/2017 - Kal Hacks, Bots, Cheats & Exploits - 7 Replies
Idk if some1 is in use for these or if this can even be called release, but anyway: (you can make your virus scans if you are willing) cheers
Minecraft Bot mit Detours
12/28/2012 - C/C++ - 20 Replies
Hi, ich möchte gerne für das Spiel Minecraft einen Bot schreiben. Dazu möchte ich ja ein Dll injecten aber wie bekomme ich raus wie die Funktionen heißen also die Daten senden und Empfangen. Wer es nicht weiß Minecraft ist auf Java geschrieben. Ich ich muss ja wissen ob das eine WSAsend Funktion oder andere ist...wie bekomme ich das raus? Ich hab es mit IDA Pro getestet bin bekomme es aber nicht hin.
[Help]MS detours
04/19/2012 - CO2 Programming - 6 Replies
EDIT: my question actually lies in my 2nd post now.
c++ Python.h und detours.h
06/15/2011 - C/C++ - 4 Replies
hi ich benutze Microsoft visual c++ 2010 und wenn ich #include "windows.h" #include <Python.h> #include "detours.h" benutze wird nur windows.h gefunden
MS Detours 1.5
07/16/2010 - Kal Online - 10 Replies
hi, i'm having problem trying to compile my dll using ms detours 2.1 (not 1.5, sorry) detours.lib(detours.obj) : error LNK2001: unresolved external symbol "struct HINSTANCE__ * __stdcall Detoured(void)" (?Detoured@@YGPAUHINSTANCE__@@XZ) G:\KalOnline\d3dx9_29.dll : fatal error LNK1120: 1 unresolved externals could someone tell me how to solve it? could not google it.



All times are GMT +1. The time now is 12:37.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.