writing to pointer

Posts 18 of 8 · Page 1 of 1
writing to pointer
Ok, so I am using this to read from a pointer:

Code:
__inline ULONG_PTR ReadPointer(ULONG_PTR* ulBase, INT nOffset)
{
   if ( !IsBadReadPtr((VOID*)ulBase, sizeof(ULONG_PTR)) )
        if ( !IsBadReadPtr((VOID*)((*(ULONG_PTR*)ulBase)+nOffset), sizeof(ULONG_PTR)) )
            return *(ULONG_PTR*)((*(ULONG_PTR*)ulBase)+nOffset);
    return 0;
}
I just want to write to a pointer and I can't find any thread that explain about it? if anyone could at least point me to a thread that helps me?
I'm not quite sure I understand what you want to do. But I guess it would almost be the same as what you gave us there.

[php]
return *(ULONG_PTR*)((*(ULONG_PTR*)ulBase)+nOffset);
[/php]

I don't quite know how offsets work and such, but I understand what you did here. Dereference the base address, add the offset to that. Cast into a ULONG_PTR and dereference and return the contents.

If you want to write, I'm not 100% sure, but I think it may be similar to that.

[php]
*( ULONG_PTR* ) ( ( *(ULONG_PTR*)BaseAddress ) +offset ) = Somevalue;
[/php]

I've never tried anything like this, so if someone would please correct me if I've made some mistakes.
well this is how you read from it ( supposedly )

Code:
ReadPointer((ULONG_PTR*)ulBase, nOffset);
I'm going to try and give what you posted a go and see
Code:
unsigned long *addie = (unsigned long*)0x12345678;
unsigned char NopThree[3] = { 0x90, 0x90, 0x90 };

void PatchMem(LPVOID dwAddress, LPVOID bytes, DWORD dwSize)
{
	DWORD flOldProtect = 0;
	VirtualProtect((void*)dwAddress, dwSize, PAGE_EXECUTE_READWRITE, &flOldProtect);
	memcpy((void*) dwAddress, bytes, dwSize);
	VirtualProtect((void*)dwAddress, dwSize, flOldProtect, &flOldProtect);
}
PatchMem(addie,NopThree,3);
Quote Originally Posted by Hell_Demon View Post
Code:
unsigned long *addie = (unsigned long*)0x12345678;
unsigned char NopThree[3] = { 0x90, 0x90, 0x90 };

void PatchMem(LPVOID dwAddress, LPVOID bytes, DWORD dwSize)
{
	DWORD flOldProtect = 0;
	VirtualProtect((void*)dwAddress, dwSize, PAGE_EXECUTE_READWRITE, &flOldProtect);
	memcpy((void*) dwAddress, bytes, dwSize);
	VirtualProtect((void*)dwAddress, dwSize, flOldProtect, &flOldProtect);
}
PatchMem(addie,NopThree,3);
does this actually write to a pointer? i don't see where the offset is at??
Just cast it?
PatchMem((*(unsigned long*)0x12345678)+0x10, NopThree, 3);
lol when u guys free mind writing a tutorial on memory manipulation for a total choob like meh?? I'll be deeply thankful :P
Yeh I never got Multi-level pointers or VirtualProtect and stuff either. That would really help a lot. Because all I can do now is WPM & RPM for single addresses. Or point me to a good tutorial link o_O. If not google will be my friend.
Posts 18 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?