idareversing

how I can read the value of this variable?


I'm doing some reversing homework and I often encounter some code that looks like this when dealing with classes, here is the pseudo code.

int __thiscall sub_858F90(_DWORD *this, int a2)
{
  int result; // eax

  result = a2;
  this[0x657] = a2;
  return result;
}

I want to know I could read the value of "this[0x657]". I have the class instance pointer. I tried to look at instance + 0x657 offset but there wasn't the value I'm looking for which should be an integer corresponding to the id of the operation.


Solution

  • // Assuming you have a valid pointer to the instance
    YourClass* instancePointer = ...;
    
    // Access the member at offset 0x657
    int value = instancePointer->yourMemberName; // Replace "yourMemberName" with the actual member name
    

    In this code, replace YourClass with the actual name of the class or structure, and replace yourMemberName with the actual name of the member variable you are trying to access at offset 0x657.

    Keep in mind that the exact syntax may vary depending on the programming language and context in which this code is used. Also, the offset 0x657 might not be a standard way to access class members, so it's important to understand the structure of the class or object you're working with.