Sign in to follow this  

DLL Injection

This topic is 3492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, im making a program that will inject a DLL into another program, by making a remote thread, and attaching the function from the DLL to the thread. But, when i inject, the program im trying it on (mIRC), crashes. My guesses are: 1) Im loading the library (DLL) in my memory space, and referencing to my memory space, which would crash it, but, i thought DLL where all in shared memory space. 2) mIRC counts it own thread numbers for injection, and crashes itself (very unlikely) Here is my source for injection, i already have a valid handle to the program:
			 // Validate we have the Handle.
			 if(!SWGHandle)
			 {
				 MessageBox::Show("For some reason the hook was lost, please re-attach.","Error!", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
			 }

			 // Load the DLL into memory space
			 HMODULE DLL = LoadLibrary("../EnableConsole/EnableConsole.dll");
			 if(!DLL)
			 {
				 MessageBox::Show("Failed to load DLL! Please check that it exists.", "Error!", MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
				 return;
			 }

			 void* DLLFunctionAddress = GetProcAddress(DLL, "InjectionThread");
			 CreateRemoteThread(SWGHandle, NULL, NULL, (LPTHREAD_START_ROUTINE)DLLFunctionAddress, NULL, NULL, NULL); 

and here is my very simple DLL:
#include <windows.h>

extern "C" __declspec(dllexport) void InjectionThread()
{
	AllocConsole();
}

Share this post


Link to post
Share on other sites

This topic is 3492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this