Question about Guild Wars memory offsets

01/03/2011 18:03 Scottyous#1
Hello, I'm wondering how to find in the ram the offsets for the Local/Trade channel .

Is it possible ?
It can't be done using tsearch or cheat engine ?
01/03/2011 18:45 buFFy!#2
What do u exactly want? What should the Address contain and what should it's value indicate?
01/03/2011 18:56 Scottyous#3
The address should contain the content of the Local or Trade channel, the value is a text, like "Want to buy ectos"
01/03/2011 19:03 buFFy!#4
ChatLogHook.h
Code:
#ifndef _CHATLOGHOOK_H
#define _CHATLOGHOOK_H

#include <iostream>
#include <windows.h>

/*
00592E60 - 66 83 3a 00                - cmp word ptr [edx],00
00592E64 - 56                         - push esi
00592E65 - 57                         - push edi
00592E66 - 8b c1                      - mov eax,ecx
*/

const BYTE ChatLogHookCode[] = {
	0x66, 0x83, 0x3A, 0x00, 0x56, 0x57, 0x8B, 0xC1
};

bool CreateChatLogHook(void);

#endif /* _CHATLOGHOOK_H */
ChatLogHook.cpp
Code:
#include "ChatLogHook.h"

BYTE* ChatLogHook;
DWORD ptrChatMsg;
DWORD ChatLogRet;
wchar_t* ChatMessage;

__declspec(naked) void ChatHook(void){
	_asm{
		CMP WORD PTR [EDX], 0x00
		PUSH ESI
		MOV ptrChatMsg, ECX
	}

	ChatMessage = (wchar_t*)(ptrChatMsg);
	wprintf(L"%s\n", ChatMessage);

	_asm JMP ChatLogRet
}

bool CreateChatLogHook(void){
	BYTE* start = (BYTE*)0x00401000;
	BYTE* end = (BYTE*)0x00900000;
	
	while(start!=end){
		if(!memcmp(start, ChatLogHookCode, sizeof(ChatLogHookCode))){
			ChatLogHook = start;
			ChatLogRet = (DWORD)ChatLogHook + 0x5;
			break;
		}
		start++;
	}
	printf("ChatLogHook:%X; ChatLogRet:%X\n", (DWORD)ChatLogHook, ChatLogRet);

	DWORD OldProtect;
	if(VirtualProtect((void*)(ChatLogHook), 20, PAGE_EXECUTE_READWRITE, &OldProtect)){
		*(BYTE*)(ChatLogHook) = 0xE9;
		*(DWORD*)((DWORD)(ChatLogHook+1)) = ((DWORD)(ChatHook) - (DWORD)(ChatLogHook) - 5);
		VirtualProtect((void*)(ChatLogHook), 20, OldProtect, 0);
	}
	else{
		printf("error\n");
		return false;
	}	

	return true;
}
Crediz to wadim.
01/04/2011 16:51 Scottyous#5
Thank you very much