Page 1 of 1

MM2 getModuleAddress

Posted: Wed Sep 24, 2014 5:00 pm
by KillerTHC
I am trying to access a static address in the LOTRO client using process.read, however I am having trouble understanding how to get the base address of the client and then adding the address to it to get the correct address to read from.

CE says the static address is at lotroclient.exe+1561154
So I tried the following

Code: Select all

staticAddress = 0x1561154;
lotroBase = process.getModuleAddress(lotroProcId, "lotroclient.exe");
process.read(lotroProc, "ushort", lotroBase + staticAddress);
But the value I am getting is incorrect, I can see the address is still valid in CE.
How should I be accomplishing this task?

Re: MM2 getModuleAddress

Posted: Wed Sep 24, 2014 8:30 pm
by Administrator
How is it invalid, nil or is it giving the wrong address? What is getModuleAddress() returning? What happens if you print lotroBase + staticAddress?

Re: MM2 getModuleAddress

Posted: Thu Sep 25, 2014 6:38 am
by KillerTHC
Administrator wrote:How is it invalid, nil or is it giving the wrong address? What is getModuleAddress() returning? What happens if you print lotroBase + staticAddress?
After doing some debugging I found out getModuleAddress() is returning the correct address and when I add the static address I get the correct address as displayed by CE, however the value I get when reading the memory from that address is drastically different than the value CE displays. CE display a float ranging from -1 to 1, MM displays a number in the thousands. I am going to keep debugging, if you have any tips or guesses I will appreciate it too.

EDIT:
I found my mistake I was reading a ushort instead of a float, I was a bit confused because the online documentation isn't 100% clear about what the variable type can be in process.read() I understand this is because its still in development. Thank you for the help!

Re: MM2 getModuleAddress

Posted: Thu Sep 25, 2014 2:38 pm
by Administrator
Sorry, I might have to clear that up. Still, you want to keep the same type you do in Cheat Engine. So if the variable type is float in CE, read it as a float.

A "short" is a single byte from -127 to 127, and unsigned short is 0 to 255.

Here's a decent list to go by:
http://stackoverflow.com/questions/5895 ... t-long-etc
signed char: -127 to 127 (note, not -128 to 127; this accommodates 1's-complement platforms)
unsigned char: 0 to 255
"plain" char: -127 to 127 or 0 to 255 (depends on default char signedness)
signed short: -32767 to 32767
unsigned short: 0 to 65535
signed int: -32767 to 32767
unsigned int: 0 to 65535
signed long: -2147483647 to 2147483647
unsigned long: 0 to 4294967295
signed long long: -9223372036854775807 to 9223372036854775807
unsigned long long: 0 to 18446744073709551615

Re: MM2 getModuleAddress

Posted: Thu Sep 25, 2014 11:35 pm
by rock5
Some of those values you copied over look wrong.
Looks like the long values are what we call ints and the long long values are what we call long.

Re: MM2 getModuleAddress

Posted: Fri Sep 26, 2014 12:31 pm
by Administrator
Not wrong, it's just there's some information missing.
A long and int are the same thing (in C++). Usually. It depends on platform, though nowadays I think it would be hard to find one where they are different. Many years ago, an int could be 4 bytes on one platform and 2 on another. Now it is standardized as 4 bytes (ie. long).

Re: MM2 getModuleAddress

Posted: Fri Sep 26, 2014 10:20 pm
by rock5
Glad I quantified my answers with "what we call" then. :)