Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm writing a program. Part of the program fetches a cryptic memory value from another program (which stores information on a value i'm looking for) and reverse engineers it. I need help figuring out a consistent sequence of commands that i can use to reverse engineer that memory value.

I've confidently determined that that memory value, $y$, is related to what i'm trying to solve for, $x$, by either $y = c_1 + 640a + 16x$ or $y = c_2 + 648b + 16x$.

I know that meaningful ranges for $a$, $b$, and $x$ are $[0, 5]$, $[0, 7]$, and $[0, 39]$ and have determined the values of $c_1$ and $c_2$ beforehand.

If I knew whether it was the first equation or second equation it would simply be a matter of subtracting the constant offset, taking the result module 640 or 648 respectively, and then dividing by 16 to obtain $x$.

But I'm not sure if I can carry out the above on the wrong equation and have an answer that I can toss out ($x$ not being in the range of 0 to 39) every time.

Is there a test i can carry out to determine which equation that memory value belongs to? Or a generic way to solve for $x$? Thanks in advance.

share|improve this question
since b may be 0, and x might be 0, and i believe that the equations must injectively produce $y$ values... it might be possible to assume that either $c_2 > c_1 + 640*5 + 16*39$ or vice versa. then it's trivial... checking this possibility –  cplusplus Mar 14 '12 at 20:42
What are these two equations? Do they contradict each others results? If you solve both and get meaningful values in both ($x<39$), what happens if you choose one randomly? Do you get another chance or does the segmentation fault or whatever prevent that? As far as Linear Algebra is concerned, it will not help you determine which equation to choose but can only help you solve consistent equations. As far as I know, there is no way of "choosing" the right equation without more insight in what those equations do and why a particular equation works in a particular case but doesn't in another. –  Inquest Mar 15 '12 at 5:35
@Nunoxic, you're indeed correct that only one gives a meaningful value at a time and since there's no trouble in failing all it took was a couple of if statements to get a result. At first I was terribly afraid that c1 and c2 might be similar enough to cause problems but that isn't the case. The constants point to two images in memory which contain a grid of sprites. The a, b, and x offsets determine what part of the sprite grid to use. –  cplusplus Mar 16 '12 at 0:37
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.