For the bit of background, I'm a robotic engineer. Robotics manufactures hide some parameters of their robots in order to avoid their competition. Now, I need these data to compute the dynamics model of the robot. I'm working on establishing an ideal "pathfinder" in term of energy consumption.
Basically, I have a .dat file gathering all the parameters I want, but I don't know "which one" is "which one".
I've copied the code from the robot and dissasembled it using Ida pro. Now, I have some pseudo code that I analyse.
FILE *__cdecl CDynamicData::loadRobcorFile(CDynamicData *this, char
*filename, unsigned __int16 a3)
{
int v3; // eax@4
const char *v4; // ebx@6
int v5; // eax@6
signed int v6; // edx@6
int v7; // eax@7
int v8; // eax@8
const char *v9; // ebx@11
int v10; // eax@11
signed int v11; // edx@11
int v12; // eax@12
int v13; // eax@13
signed int v14; // ebx@16
int v15; // eax@16
signed int v16; // edx@16
int v17; // eax@19
signed int v18; // edx@19
int v19; // eax@20
int v20; // eax@25
int i; // esi@28
float v22; // ST34_4@31
int v23; // eax@32
int v24; // edi@34
int v25; // esi@35
float v26; // ST34_4@38
FILE *result; // eax@41
int v28; // [sp+28h] [bp-400h]@27
int nbParam; // [sp+2Ch] [bp-3FCh]@27
int v30; // [sp+30h] [bp-3F8h]@34
char s; // [sp+40h] [bp-3E8h]@29
char src; // [sp+140h] [bp-2E8h]@4
char v33; // [sp+240h] [bp-1E8h]@30
int v34; // [sp+340h] [bp-E8h]@23
int v35; // [sp+3A0h] [bp-88h]@23
char v36; // [sp+3B8h] [bp-70h]@23
char v37; // [sp+3C0h] [bp-68h]@23
char v38; // [sp+3C8h] [bp-60h]@23
int v39; // [sp+3D4h] [bp-54h]@23
FILE *stream; // [sp+3ECh] [bp-3Ch]@1
void *v41; // [sp+3F0h] [bp-38h]@1
int v42; // [sp+3F4h] [bp-34h]@1
double v43; // [sp+3F8h] [bp-30h]@23
double value; // [sp+400h] [bp-28h]@29
int v45; // [sp+408h] [bp-20h]@4
int indice; // [sp+40Ch] [bp-1Ch]@27
int v47; // [sp+410h] [bp-18h]@25
int v48; // [sp+414h] [bp-14h]@32
stream = 0;
v42 = 256;
readIntValues((CFileParser *)&stream, "$DYN_DAT", "REAL $DYN_DAT[%d]", &src, 1, &v47);
v20 = operator new[](8 * v47, &std::nothrow);
*((_DWORD *)this + 3) = v20;
v28 = *((_DWORD *)this + 3);
nbParam = v47;
indice = 0;
if ( v47 > 0 )
{
i = 0;
do
{
CFileParser::getLine((CFileParser *)&stream, &s);
if ( sscanf(&s, "$DYN_DAT[%d]=%lf", &indice, &value) != 2 )
{ // Can't acquire data
snprintf(&v33, 0x100u, "%s konnte nicht gelesen werden", "$DYN_DAT[%d]=%lf");
extended_internalError(
}
v22 = value;
*(double *)(v28 + 8 * indice - 8) = v22;
++i;
}
while ( nbParam != i );
}
Basically, I don't understand the meaning of:
*((_DWORD *)this + 3) = v20;
and:
*(double *)(v28 + 8 * indice - 8) = v22;
Do you have any ideas ?
So far, I think it's a pointer of pointer, but I don't understand "the meaning" of it because it seems like v28 is a "local variable" with unaloccated space ?
Here is the "pseudo code" of the constructor of the object DynDat:
int __cdecl CDynamicData::CDynamicData(int a1)
{
int result; // eax@1
result = a1;
*(_BYTE *)a1 = 0;
*(_DWORD *)(a1 + 4) = 0;
*(_DWORD *)(a1 + 8) = 0;
*(_DWORD *)(a1 + 12) = 0;
return result;
}
Bonus question: Do you have any idea of the most efficient way to trace back the parsing and use of some values ?
Kind Regards,
*((_DWORD *)this + 3) = v20
,this
is a pointer, so it's actually adding3*4 = 12
to the pointer. By looking at the constructor, this means it is assigningv20
to the fourth field of that class.v28
is not unallocated space; it's being assigned asv28 = *((_DWORD *)this + 3);
, which was previously assigned tov20
, which was previously initialized withoperator new[](8 * v47, &std::nothrow);