Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 08:27

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

Advertisement



DLL Injection/hooking

Discussion on DLL Injection/hooking within the .NET Languages forum part of the Coders Den category.

Closed Thread
 
Old   #1
 
elite*gold: 1000
Join Date: Apr 2012
Posts: 1,003
Received Thanks: 208
DLL Injection/hooking

Hey EPVP Coder,

Ich bin dabei eine 32-bit C++ DLL in einen 32-bit Prozess auf einem 64-bit System zu injecten.
Die DLL enthält einen hook.

So nun zu meinem Problem. Ich kann die DLL zwar erfolgreich injecten (MessageBox erscheint), jedoch wird der hook nicht richtig durchgeführt. Olly zeigt die Veränderung der Funktion an !
Ich finde das sehr mysteriös, denn wenn ich einen in C++ geschriebenen Injector nehme, dann funktioniert das ganze und der hook greift.
Habe schon etliche C# Injectoren aus dem Internet getestet und keiner geht. Mein eigener auch nicht.

Habt ihr einen Rat?

Code:
public bool Inject()
    	{
        	UIntPtr bytesout;
        	IntPtr bytesout2;
        	Int32 LenWrite = dllFilePath.Length;
        	ASCIIEncoding enc = new ASCIIEncoding();

        	adjustDebugPriv(procID);

        	IntPtr hProcess = OpenProcess(ProcessAccess.AllAccess, false, procID);

        	if (hProcess == null)
            	return false;

        	IntPtr AllocMem = (IntPtr)VirtualAllocEx(hProcess, (IntPtr)null, (uint)LenWrite, 0x1000, 0x40);

        	if (AllocMem == null)
            	return false;

        	bool wpm = WriteProcessMemory(hProcess, AllocMem, enc.GetBytes(dllFilePath), (uint)LenWrite, out bytesout);

        	if (!wpm)
            	return false;

        	UIntPtr Injector = (UIntPtr)GetProcAddress(API.GetModuleHandle("kernel32.dll"), "LoadLibraryA");

        	if (Injector == null)
            	return false;

        	IntPtr hThread = (IntPtr)CreateRemoteThread(hProcess, (IntPtr)null, 0, Injector, AllocMem, 0, out bytesout2);

        	if (hThread == null)
            	return false;

        	uint Result = API.WaitForSingleObject(hThread,10 * 10000);

        	if (Result == 0x00000080L || Result == 0x00000102L || Result == 0xFFFFFFFF)
        	{
            	if (hThread != null)
                	API.CloseHandle(hThread);

            	return false;
        	}

        	Thread.Sleep(1000);
        	API.VirtualFreeEx(hProcess, AllocMem, 0, FreeType.Release);

        	if (hThread != null)
            	API.CloseHandle(hThread);

        	return true;
    	}
E: Hat sich erledigt. VS11 ist verbuggt. Hab den gleichen Code mal bei VS10 verwendet und es läuft reibungslos. Kann also geschlossen werden.
qkuh is offline  
Closed Thread


Similar Threads Similar Threads
C# Dll Injection/Hooking ? Take two.
08/16/2012 - CO2 Programming - 2 Replies
c&ped from ug. Second release from me and martin. Have fun. PS. Credits to Inf. for the inline export func& compiler.
[tutorial]Injection & Function Hooking
11/06/2010 - Tutorials - 5 Replies
First let me say this: This is not written by me, i found it posted on game deception a while ago and just rediscoverd it on my hd. Thought it might be interesting for some ppl here. Credits go to whoever originally wrote it. This contains a demo project for vc 2003 and a tutorial. You can find the tutorial in the readme folder!!!!!! oh, if you don't trust me, don't download it....
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...
DLL Hooking/Injection
03/20/2008 - General Coding - 4 Replies
Can anyone lead me to some GOOD tutorials for DLL Hooking/Injection... as the ones ive found on Google are absolutely shit. Thanks in advance. :bandit:



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


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.