Jump to content
  • Advertisement
Sign in to follow this  
lordcorm

DLL Injection

This topic is 3706 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!