DLL Injection

Posts 1–13 of 13 · Page 1 of 1
DLL Injection
Okay so, I've made a few hacks that should hypothetically work. But they wont work for shit, because WriteProcessMemory just will not work. Well I am pretty sure I have to inject it as a dll if I want to use WriteProcessMemory. Now, I have an injector, and I've done some tests with DLL's etc using MessageBox to show messages and shit. Well it sorta works, I can get messagebox's to show up and things like that. But when I try to use WriteProcessMemory, it just... Doesn't work. I try using MessageBox->GetLastError() to show if there was any errors, but it was blank, meaning everything worked fine. Here's the code I tested with:
Code:
#include "Windows.h"

HWND handle;
DWORD pid;
HANDLE hProcess;

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  reason,
                       LPVOID lpReserved
					 )
{
	switch (reason)
	{
	case DLL_PROCESS_ATTACH:
	handle=FindWindow(NULL,(LPCWSTR)"Garry's Mod");
	GetWindowThreadProcessId(handle,&pid);
	hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,pid);
	WriteProcessMemory(hProcess,(LPVOID)0x16CFA0C8,(LPCVOID)2,sizeof(2),NULL);
	MessageBox(handle,(LPCWSTR)GetLastError(),NULL,MB_OK);
	break;
	}
	return TRUE;
}
What am I doing wrong? What do I need to change? I remember reading some stuff about CreateThread and CreateRemoteThread, but I have no idea how to use them, anyone care to help? Specifically Hell_Demon just because I know you know what to do, and you never help me.

There is nothing wrong with the address.

~lilneo
[php]
#include <windows.h>

DWORD* Address = 0x16CFA0C8;

void InitHack(void)
{
*Address = 2;
}

bool __stdcall DllMain(HINSTANCE hInst,DWORD Reason,void* lpReserved)
{
if(Reason == DLL_PROCESS_ATTACH)
{
InitHack();
}
return true;
}
[/php]

Why use WriteProcessMemory when you have direct memory access?
What? o.o
You're saying I can just like... Use the address as a pointer?

... .\dllmain.cpp(3) : error C2440: 'initializing' : cannot convert from 'int' to 'DWORD *'
Quote Originally Posted by lilneo View Post
What? o.o
You're saying I can just like... Use the address as a pointer?
Pretty much.
Bump, incase you posted before my edit. I have an error setting it to a DWORD... :\ What the hell, I hate all this variable type crap.
I have a question, why do you inject a dll ? Memory Editing is extern.

Regards Inmate
Quote Originally Posted by inmate View Post
I have a question, why do you inject a dll ? Memory Editing is extern.

Regards Inmate
Because when I try to use WriteProcessMemory, it blocks me. So by injecting a dll I am apart of the process, and I have FULL access.

I did this:
Code:
DWORD addy = 0x02163640;
DWORD *Address = &addy;
but it still doesn't change.

Oh, okay, uhh trying now

omg I think it actually worked.


Thank you so much void.

~lilneo
My bad, I did it really quickly..

[php]
DWORD* Address = (DWORD*)0x16CFA0C8;
[/php]
Quote Originally Posted by inmate View Post
I have a question, why do you inject a dll ? Memory Editing is extern.

Regards Inmate
Err... Get Out ?

Quote Originally Posted by Void View Post
My bad, I did it really quickly..

[php]
DWORD* Address = (DWORD*)0x16CFA0C8;
[/php]
Ohh =(. You could have let him solve that by Himself =).
Quote Originally Posted by Melodia View Post
Err... Get Out ?

How do you mean this ?

WriteProcessMemory is extern, when the .dll is already injected you can use WriteMem but not WriteProcessMemory /yea
Quote Originally Posted by inmate View Post
How do you mean this ?

WriteProcessMemory is extern, when the .dll is already injected you can use WriteMem but not WriteProcessMemory /yea
WriteProcessMemory can be used from a dll too, it's just more work then what void showed
WriteProcessMemory is for external use(so from an .exe)
Yeah figured that out now :\
Posts 1–13 of 13 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us