Possible bug

Ask for Help on Using the Language With Memory Hacking Software

Moderators: g3nuin3, SpeedWing, WhiteHat, mezzo

Possible bug

Postby Goutetsu » Sat Jul 22, 2006 12:19 pm

Ok, so I decided to try out the scripting language by making a small
"patcher/unpatcher" for one of my Oblivion cheats. I ran into what I
believe is a bug, but I could be wrong.

My code:
Code: Select all
void On_HK_0(DWORD dw1, DWORD dw2)
{
   extern BYTE values[5] = {"", 0x006519D9};

   BYTE vals[5];
   vals[0] = 1;
   vals[1] = 2;
   vals[2] = 3;
   vals[3] = 4;
   vals[4] = 5;
   
   Clear();
   int i = 0;
   PrintF("Test1 at 0x006519D9 %02X%02X%02X%02X%02X.", values[0], values[1], values[2], values[3], values[4]);
   PrintF("Test2 at 0x006519D9 %02X%02X%02X%02X%02X.", values[5-5], values[5-4], values[5-3], values[5-2], values[5-1]);
   PrintF("Test3 at 0x006519D9 %02X%02X%02X%02X%02X.", values[i+5-5], values[i+5-4], values[i+5-3], values[i+5-2], values[i+5-1]);
   PrintF("Test4 at 0x006519D9 %02X%02X%02X%02X%02X.", values[i], values[i+1], values[i+2], values[i+3], values[i+4]);
   PrintF("Test5 at %02X%02X%02X%02X%02X.", vals[0], vals[1], vals[2], vals[3], vals[4]);
   PrintF("Test6 at %02X%02X%02X%02X%02X.", vals[i], vals[i+1], vals[i+2], vals[i+3], vals[i+4]);
   
   for(i=0;i<5;i++)
      PrintF("values[%d] = %02X;", i, values[i]);
}


And my results:
Code: Select all
Test1 at 0x006519D9 1010101010.
Test2 at 0x006519D9 1010101010.
Test3 at 0x006519D9 7A1084DB0F.
Test4 at 0x006519D9 7A1084DB0F.
Test5 at 0102030405.
Test6 at 0102030405.
values[0] = 7A;
values[1] = 10;
values[2] = 84;
values[3] = DB;
values[4] = 0F;


As you can see in Test1 and Test 2, the second byte of the array is
repeated no matter the index. This seems to only happen when the
array is indexed without a variable in the expression.

I did not know if this was a bug or intentional, but I figured I would
post my findings.

PS.
Awesome work L. Spiro :D
Goutetsu
I Have A Question
 
Posts: 1
Joined: Tue Jul 18, 2006 1:12 am

Postby L. Spiro » Sat Jul 22, 2006 12:40 pm

It appears to be a bug.

I don’t have my computer handy at the moment, but thanks to your testing I already know exactly where to look to find this bug.


Constants in array expressions are simplified to go directly to the index being accessed, so as to save time.
Variables in array expressions are evaluated, loaded to a register, converted to an integer (this is why floats and doubles can be used as indices), multiplied by the array-type size, added to the array base address, and then accessed accordingly.
Seems like a lot, but it’s the same as x86 native.

So the method for array access with constants is different, and it seems slightly broken on extern, but I know where to look and you can expect it to be fixed in the next version.

Until then, you can access arrays via variables, as it appears to work fine that way.

Also note that “const” variables are exactly the same as literal variables; they always resolve to their numeric values as if the numeric value was used directly, so in this case, they would also cause problems.


L. Spiro
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Postby L. Spiro » Wed Jul 26, 2006 4:53 pm

Fixed in 3.0.0.8 Pro.


L. Spiro
User avatar
L. Spiro
L. Spiro
 
Posts: 3129
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan


Return to Help

Who is online

Users browsing this forum: No registered users and 0 guests