Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 08:49

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

Advertisement



Hooked Funktion Parameter Auslesen

Discussion on Hooked Funktion Parameter Auslesen within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1




 
bloodx's Avatar
 
elite*gold: 55
Join Date: Mar 2006
Posts: 4,582
Received Thanks: 1,539
Hooked Funktion Parameter Auslesen

Hallo, ich hab mich seit längerer Zeit mal wieder etwas mit C++ beschäftigt und nen kleines Projekt gestartet.

Komme jetzt aber überhaupt nicht drauf wie ich aus dieser Funktion


Code:
.text:00461080                 push    ebp
.text:00461081                 mov     ebp, esp
.text:00461083                 sub     esp, 4E0h
.text:00461089                 mov     eax, dword_4D9830
.text:0046108E                 mov     [ebp+var_A4], eax
.text:00461094                 mov     [ebp+var_4D0], ecx
.text:0046109A                 cmp     dword_4E35B8, 1
.text:004610A1                 jnz     short loc_4610E7
.text:004610A3                 mov     eax, [ebp+var_4D0]
.text:004610A9                 cmp     dword ptr [eax+1C8h], 3

[COLOR="Red"]geht nocht weiter aber ist viel zu viel![/COLOR]

int __thiscall CommandHandler(int this, const char *a2)
was aber eig

Code:
int __stdcall CommandHandler(char *)
ist.

hab die Funktion Detoured

DetourFunction((PBYTE)(0x00461080/*Start der Funktion*/),(PBYTE)ServerMain::MyGmCommands);

alles schön und gut kann meine Eigenen Commands einschläusen nun Funktionieren aber die normalen Commands nicht mehr da ich die Funktion ja auf meine weiterleite...

Jemand ne bessere Lösung den char aus zu lesen? ._.
bloodx is offline  
Old 08/06/2012, 05:15   #2
 
Dr. Coxxy's Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 1,206
Received Thanks: 736
DetourFunction sollte eigtl ein trampolin allokieren wo die überschriebenen bytes und ein jump auf die adresse nach dem jump gespeichert sein sollte.
solltest die adresse vom trampolin als void* zurückgeliefert bekommen, kannst also:

Code:
typedef int(__thiscall* MyGmCommands_t)(char*);

MyGmCommands_t OrigGmCommands;

OrigGmCommands = (MyGmCommands_t) DetourFunction((PBYTE)(0x00461080/*Start der Funktion*/),(PBYTE)ServerMain::MyGmCommands);


// im hook
int ServerMain::MyGmCommands(char* blubb)
{
  printf("Command Logged: %s\n", blubb);
  return OrigGmCommands(blubb);
}
Dr. Coxxy is offline  
Thanks
1 User
Old 08/06/2012, 05:20   #3




 
bloodx's Avatar
 
elite*gold: 55
Join Date: Mar 2006
Posts: 4,582
Received Thanks: 1,539
So hatte ich es eben auch Probiert hatte leider nicht Funktioniert, habe aber jetzt eine Lösung gefunden

Code:
__asm
		{
				 push edx
                push ecx
                push ebx
                push eax

				mov     eax, [ebp+0x08]
				push    eax
				call    MyGmCommands
				
				 pop eax
                pop ebx
                pop ecx
                pop edx

				mov     eax, [ebp+0x08]
				push eax
				mov   ecx, [ebp-0x68]
				mov             edx,OriginalBack
				jmp             edx
		}
Ich leite einfach genau an der stelle wo mov eax, [ebp+0x08] ausgeführt wird auf meine Funktion weiter und dann wieder zurück ~.~ so verdammt einfach eig, aber erstmal wieder drauf kommen


Trotzdem danke an dich
bloodx is offline  
Old 08/06/2012, 11:31   #4
 
elite*gold: 0
Join Date: Mar 2012
Posts: 26
Received Thanks: 3
Und wie machst du das genau, würd mich interessieren?
ehauser is offline  
Old 08/06/2012, 17:52   #5




 
bloodx's Avatar
 
elite*gold: 55
Join Date: Mar 2006
Posts: 4,582
Received Thanks: 1,539
Code:
Tool->Intercept(INST_JMP,reinterpret_cast<void*>(0x00460BD9),reinterpret_cast<void*>(ServerMain::ReadCommandHandler),5);
Code:
DWORD OriginalCommandsBack = 0x00460BE0;
	int __declspec( naked ) ReadCommandHandler()
	{
		__asm{
				 push edx
                push ecx
                push ebx
                push eax
				mov     eax, [ebp+0x08]
				push    eax
				call    MyGmCommands	
				pop eax
                pop ebx
                pop ecx
                pop edx
				mov     eax, [ebp+0x08]
				push eax
				mov   ecx, [ebp-0x68]
				mov   edx,OriginalCommandsBack
				jmp   edx
		}
	}
bloodx is offline  
Reply


Similar Threads Similar Threads
Ollydbg - Parameter einer Funktion auslesen?
11/06/2011 - General Coding - 3 Replies
Hallo Leute! Ich versuche gerade, so nen kleinen Bot in C++ für Metin2 zu schreiben. Die Funktion, um einen Schlag auszuführen, heißt "SetAttackKeyState" und sieht in Olly so aus: CPU Disasm Address Hex dump Command Comments 00450D08 |. 50 PUSH EAX ; /Arg3 => OFFSET LOCAL.0 00450D09 |. 6A 00 PUSH 0 ; |Arg2 = 0
IE Funktion und quelltext auslesen
09/11/2011 - AutoIt - 2 Replies
WIe kann ich machen, dass wenn ich mit ienavigate auf eine seite navigiere und dann den quelltext auslesen will? MfG Ludder231
Funktion Adressen + Parameter
01/31/2011 - Kal Online - 28 Replies
Hi, ich fang mal mit nem Quote von meak1 an. Wozu dir Pattern da sind etc habe ich verstanden. Die Frage die sich mir stellt: Woher weis ich welche Parameter die Methode KChatLog_v erwartet? Bzw gibt es Tipps, wie ich nach den Pattern für bestimmte funktionen suche kann? Hoffe die Fragen kann man beantworten, so dass ich weiterkomme.
Auslesen der Parameter einer EXE
02/11/2009 - General Coding - 15 Replies
Hi! Hab mal ne Frage: Gibt es eine Möglichkeit die Parameter mit denen man eine EXE starten kann auszulesen? Beispiel: chkdsk /f Danke im Vorraus :)



All times are GMT +1. The time now is 08:49.


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.