elitepvpers

elitepvpers (https://www.elitepvpers.com/forum/)
-   CO2 Programming (https://www.elitepvpers.com/forum/co2-programming/)
-   -   Reading Current Experience from Conquer Process (https://www.elitepvpers.com/forum/co2-programming/194862-reading-current-experience-conquer-process.html)

Origonal 12/21/2008 05:48

Reading Current Experience from Conquer Process
 
Hi, im trying to read the current character experience from the Conquer Process, i am reading from the address 0x5DB490, i found this using CE and am almost certain its the right address (if its not then please correct me). The problem is, when i find the address in CE i find the information i want (that is, the current character experience). But when i read in the data in C# i get a completly wrong value, for example, when i find the value in CE its 2470588, but when i find it in C# its 188. So it seems to me that CE is doing some calculation that im missing (perhaps creating a integer out of subsequent bytes?) Does anyone have a idea of what it is im missing? I tried reading off some subsequent bytes and got the following array:

{188,178,37,0,0,0,0,0,0,0,0,0,50,1}

Thanks in advance for any help.

tanelipe 12/21/2008 15:16

Mind showing the C# code that you're using to read the memory ? I could check it.

high6 12/21/2008 17:20

is 2470588 the correct value?

edit: whoops, just read it fully, yes it is XD.

You are probably using ReadProcessMemory wrong. It reads bytes and then from there you convert to an integer.

Here is a snippet from CoHealth

Code:

            #region ReadX
            static int ReadInt(int handle, int addr)
            {
                byte[] buf = new byte[4];
                ReadProcessMemory(handle, addr, buf, 4, 0);
                return BitConverter.ToInt32(buf, 0);
            }
            static int ReadShort(int handle, int addr)
            {
                byte[] buf = new byte[2];
                ReadProcessMemory(handle, addr, buf, 2, 0);
                return BitConverter.ToInt16(buf, 0);
            }
            static byte ReadByte(int handle, int addr)
            {
                byte[] buf = new byte[1];
                ReadProcessMemory(handle, addr, buf, 1, 0);
                return buf[0];
            }
            static byte[] ReadBytes(int handle, int addr, int size)
            {
                byte[] buf = new byte[size];
                ReadProcessMemory(handle, addr, buf, size, 0);
                return buf;
            }
            #endregion


Origonal 12/21/2008 18:57

thanks for the two replys guys.

to high6: thanks for those code snippits, that BitConverter class might just be what i was looking for, tho i havnt had to use it when getting character level.

to tanelipe: code as requested, once this is completed ill release the whole thing open source.

Code:

private unsafe void timer_Tick(object sender, EventArgs e)
        {
            if (curProcess != null)
            {
                pReader.ReadProcess = curProcess;
                pReader.OpenProcess();
                byte[] bytesLev = pReader.ReadProcessMemory((IntPtr)CHAR_LEVEL_ADDRESS, 1, out bytesReaded);
                lblLevel.Text = "Level: " + bytesLev[0];
                byte[] bytesExp = pReader.ReadProcessMemory((IntPtr)CHAR_EXPERIENCE_ADDRESS, 4, out bytesReaded);
                lblPercent.Text = "Percent: " + convert.ConvertToPc(bytesLev[0],BitConverter.ToInt32(bytesExp,0)) + "%";
                lblWater.Text = bytesExp[0].ToString();
                pReader.CloseHandle();
            }
        }

im using someone else's API for doing the auctuall work, i think i understand most of the concepts in it, you can obtain the classes by making a codeproject class and downloading the source files from [Only registered and activated users can see links. Click Here To Register...]. convert is a very simple custom class that has one public method to take the level and current experience and returns a % by using a hard coded look-up table, im sure the code for that is working well.

tanelipe 12/21/2008 19:07

Experience is ulong so it should be read as 8 bytes instead of 4. (Atleast it's like that on packets.) And when converting from the array you should use Convert.ToInt64 then also. Other than that I don't see whats wrong if the experience address is correct

Origonal 12/21/2008 20:00

Thanks :)
Ill test it out in about 10 hours and report back the result here.

edit: thanks for your help, im all finsihed now, i had one more hurdle to overcome after getting the exp figure correct, that is realising that i had forgotten to multiply curexp/reqexp by 100 :P


All times are GMT +2. The time now is 13:49.

Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.