QuestionC++ Pointer Help

Posts 1–3 of 3 · Page 1 of 1
C++ Pointer Help
I am having a problem with reading from a pointer, i think im right in saying:

You read the pointer address, Add the offset to the result, then you have your address for reading.

But this doesnt seem to work for me (i may have code wrong).

This is my DLL Code... (DllMain.cpp)

Code:
#include "Dll.h"
#include <windows.h>

HWND hwnd;
HANDLE pHandle;
DWORD pid;
bool Hooked;
long paddy, faddy, result;

extern "C"
{
	bool OpenMem()
	{
		if(!Hooked){
			hwnd = FindWindowA(NULL,"<GAME>");
			if(hwnd != 0){
				GetWindowThreadProcessId(hwnd, &pid);
				if(pid != 0){
					pHandle = OpenProcess(PROCESS_ALL_ACCESS,false,pid);
					Hooked = true;
				}
			}
		}
		return Hooked;
	}

	long ReadPointerHP()
	{
		ReadProcessMemory(pHandle,(LPCVOID)0x00458C9C,(LPVOID)paddy,sizeof(paddy),NULL);
		faddy = paddy + 0x2FC;
		ReadProcessMemory(pHandle,(LPCVOID)faddy,&result,sizeof(result),NULL);
		return result;
	}
}
And my dll.h:
Code:
extern "C"
{
	__declspec(dllexport) bool OpenMem();
	__declspec(dllexport) long ReadPointerHP();
}
Can any body see what i am doing wrong? This code (used in VB) returns a really big number (30064771072) when it should be returning between 0 and 500.

This is my declaration in VB:
Code:
Declare Function OpenMem Lib "Funcs.dll" () As Integer
Declare Function ReadPointerHP Lib "Funcs.dll" () As Long
If there is anything else you need to see just drop a post and ill put it up.

Thanks in advance..
~Calster~
*BUMP*

Please can some1 help me here?

I think my problem is that OpenProcess is always returning 0 for some reason...

Thanks.

~Calster~
[SOLVED]

Thanks for all the help..... (Sarcasm)

For all who need the same solution you need to SetDebugPrivilege look it up on google.
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Talk with us