Jump to content
  • 0

Problem getting the right value (Byte, Word)


YeetMeister
 Share

Question

I'm Modifying a game and the value I'm trying to modify is split up into two Bytes, so generally I should modify the word, but I want to have an exact value like 10000

what I have found out is that 64 00 = 100 Currency. and the word for it is 25600

now I need an math equation to exactly find out what word value I should put so I can have 10000 Currency. any Help?

im not very good at math, but if someone could help me get this right I would very much appreciate that

Link to comment
Share on other sites

Recommended Posts

  • 0
4 hours ago, YeetMeister said:

what I have found out is that 64 00 = 100 Currency. and the word for it is 25600

Possibly that the bytes are simply reversed. 0x64 is 100. Try "00 01" to see the result. 256 to be expected.

Link to comment
Share on other sites

  • 0
1 hour ago, CmP said:

Possibly that the bytes are simply reversed. 0x64 is 100. Try "00 01" to see the result. 256 to be expected.

Yes it is, I already figured that out by editing the second byte value

[added 3 minutes later]
1 hour ago, CmP said:

Possibly that the bytes are simply reversed. 0x64 is 100. Try "00 01" to see the result. 256 to be expected.

But I also figured out with NoFear that Word is the way to Modify both values at the same time

 

But now the question is how to mathematically put the values so I can have the exact value I want as Money

Link to comment
Share on other sites

  • 0
1 hour ago, YeetMeister said:

But now the question is how to mathematically put the values so I can have the exact value I want as Money

Convert the value to hexadecimal and swap first byte with the second one.

Example for 10000:
1. 10000 is 0x2710.
2. "27 10" after swap is "10 27".

Link to comment
Share on other sites

  • 0
12 hours ago, CmP said:

Convert the value to hexadecimal and swap first byte with the second one.

Example for 10000:
1. 10000 is 0x2710.
2. "27 10" after swap is "10 27".

so what ive found out is, that not actually 2 values modify the money, its actually 4

when i add in value format the hex notation i see the hex string and in memory editor i can see the values that correspond to it

so i better not use word to modify the value, instead using dword

okay, never mind its not 4 values, but also the 10 27 isnt 10000

 

Edited by YeetMeister
Link to comment
Share on other sites

  • 0
12 hours ago, YeetMeister said:

but also the 10 27 isnt 10000

The values for bytes that I provided are hexadecimal. So with 10 I meant 0x10 (16) and with 27 I meant 0x27 (39). Try them.

Also from your video it seems that bytes do not need to be swapped so ignore that step.

Link to comment
Share on other sites

  • 0
8 hours ago, CmP said:

The values for bytes that I provided are hexadecimal. So with 10 I meant 0x10 (16) and with 27 I meant 0x27 (39). Try them.

Also from your video it seems that bytes do not need to be swapped so ignore that step.

You are an absolute madman, thank you.

Link to comment
Share on other sites

  • 0
8 hours ago, CmP said:

The values for bytes that I provided are hexadecimal. So with 10 I meant 0x10 (16) and with 27 I meant 0x27 (39). Try them.

Also from your video it seems that bytes do not need to be swapped so ignore that step.

My Biggest problem right now is that 65535/16 = 4095 = FFFh. But in GameGuardian its FFh since Bytes only work up to 255, if i /16 from the 65535 again the first value is right, but the second value is just Fh now, how do i fix this. After i read the Email that you commented i immediately went to work and tried several things.

 

The problem is i need a Function that defines how often a number needs to be Modified (/16) so the result ends up in 2 Bytes. I figure because 3000 money doesnt need to be devided 2 times.

3000 money = 187;11 = BBh;0Bh

But the current script i used to get there spits out BBh;Bh

 

If you know how please share ❤️ and thanks for your Previous help, this burnt my Braincells since im not that Good at math :3

Edited by YeetMeister
Link to comment
Share on other sites

  • 0
11 hours ago, YeetMeister said:

The problem is i need a Function that defines how often a number needs to be Modified (/16) so the result ends up in 2 Bytes.

More like you need to find out the values of first and seconds bytes that together correspond to the value you need. The following code may work for values in range [0;32767]: 

local value = 3000
local firstByte = value % 256
local secondByte = (value >> 8) % 256
local searchString = string.format("%d;%d::2", secondByte, firstByte)
print(searchString) -- 11;184::2
11 hours ago, YeetMeister said:

3000 money = 187;11 = BBh;0Bh

As you see, this is slightly incorrect. That would be correct for value 3003. Also you may want ordered group search like in my example in which case you need to search for bytes in the correct order. 

Link to comment
Share on other sites

  • 0
1 hour ago, CmP said:

More like you need to find out the values of first and seconds bytes that together correspond to the value you need. The following code may work for values in range [0;32767]: 


local value = 3000
local firstByte = value % 256
local secondByte = (value >> 8) % 256
local searchString = string.format("%d;%d::2", secondByte, firstByte)
print(searchString) -- 11;184::2

As you see, this is slightly incorrect. That would be correct for value 3003. Also you may want ordered group search like in my example in which case you need to search for bytes in the correct order. 

That is true, ive come up with that result aswell, but i cant just Bruteforce every value you know

This is honestly driving me insane, one possible thing is to modify the word value since its 2 byte values, but there is the same thing here again.

I've yet to be questioning a method that fully will work though.

I can send you the game and link to the Emulator if you want, so you can have a look yourself if you're interested 🙂

Im thankful though that you still trying to help me, and once the method has been found, i will give a huge shout-out because its so an annoying process

https://play.google.com/store/apps/details?id=com.fastemulator.gbcfree

 

PokemonGold(Extracted from Cartrige).gbc

Edited by YeetMeister
Added Link to Emulator and the Game
Link to comment
Share on other sites

  • 0
1 hour ago, CmP said:

you need to find out the values of first and seconds bytes that together correspond to the value you need

Can i calculate from those values then? Because the starting amount of Money is 3000

I will Edit this response once i found that out again, i had the values before but i didnt had in mind saving them unfortunately

But that wont be hard since 3003 has already been found, so i only meed to modify the second byte, is all i know atm

Link to comment
Share on other sites

  • 0
1 hour ago, YeetMeister said:

Can i calculate from those values then?

Yes, you have everything that is needed to find the value and to modify it to any other (in allowed range).

To search for 3000 try search string "11;184::2" with type "Byte". If there will be more than 2 results, you will need to do refine search by changing the value in the game and searching the new value the same way. For example, if the new value is 2500, you will need to use the following search string "9;196::2".

Link to comment
Share on other sites

  • 0
10 hours ago, CmP said:

Yes, you have everything that is needed to find the value and to modify it to any other (in allowed range).

To search for 3000 try search string "11;184::2" with type "Byte". If there will be more than 2 results, you will need to do refine search by changing the value in the game and searching the new value the same way. For example, if the new value is 2500, you will need to use the following search string "9;196::2".

3000 money = 11 -72 bytes, how would i be able to calculate other wished values from now on / how the ***** did you do it lmao

Link to comment
Share on other sites

  • 0
8 hours ago, YeetMeister said:

3000 money = 11 -72 bytes

Byte value of 0xB8 is -72 in decimal if you interpret it as signed byte and 184 if you interpret is as unsigned byte, so these are just different interpretations of the same value.

8 hours ago, YeetMeister said:

how would i be able to calculate other wished values from now on

Just convert them to hexadecimal and extract byte values from the result. I have no idea why it is so hard to understand.

Example: convert 12345 decimal value to bytes.
1. 12345 = 0x3039
2. Byte values are 0x30 and 0x39 (to be searched in this order) or 48 and 57 in decimal.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.