#include<Windows.h>
#include<tchar.h>
#include<Shlwapi.h>
#include"Header.h"
#include"DebugPriv.h"

#pragma	comment(lib, "Shlwapi")

int wmain(int argc, wchar_t *argv[])
{
	EnableDebugAbility();

	DWORD	pid = _wtoi(argv[1]);
	//DWORD pid = 6240;
	LONGLONG	addr;
	CHAR buffer[100];
	SIZE_T bytesRead;

	// Glad this exists!
	// Convert Hex string to 64 int
	//https://msdn.microsoft.com/en-us/library/windows/desktop/bb773450(v=vs.85).aspx

	StrToInt64Ex(argv[2], STIF_SUPPORT_HEX, &addr);

	_tprintf(_T("Reading/Writing to Address: 0x%I64x of PID= %d\n"), addr, pid);

	memset(buffer, 0x0, 100);

	if (!Toolhelp32ReadProcessMemory(pid, (LPCVOID)addr, buffer, 95, &bytesRead)) {

		ErrorDetails(_T("Toolhelp32ReadProcessMemory"), false);
	}
	else {
		// Managed to read :) 

		_tprintf(_T("Read: %hs\n"), buffer);

	}

	return 0;
}

