试图理解反编译器抛出的伪代码
Trying to understand a pseudo code thrown by a decompiler
我是这个主题的新手,在查看反编译器抛出的伪代码时卡住了。
我知道了:
int __cdecl update_FILES(const char *a1, const char *a2, int a3)
{
int result; // eax
int v4; // esi
int v5; // eax
FILE *v6; // [esp+20h] [ebp-98h]
FILE *v7; // [esp+24h] [ebp-94h]
FILE *v8; // [esp+28h] [ebp-90h]
char Str1[9]; // [esp+38h] [ebp-80h] BYREF
char v10; // [esp+41h] [ebp-77h]
float v11; // [esp+44h] [ebp-74h]
char Destination[50]; // [esp+4Ah] [ebp-6Eh] BYREF
char Buffer[56]; // [esp+7Ch] [ebp-3Ch] BYREF
float v14; // [esp+B4h] [ebp-4h]
_BYTE v15[336]; // [esp+B8h] [ebp+0h] BYREF
crear_cola_res(v15);
v6 = fopen(a1, "r+b");
result = 1;
if ( v6 )
{
v7 = fopen(a2, "rt");
if ( v7 )
{
strcpy(Destination, a2);
strcpy(strrchr(Destination, 46), "_myFile.txt");
v8 = fopen(Destination, "wb");
if ( v8 )
{
fread(Buffer, 0x3Cu, 1u, v6);
v4 = read_movements(Str1, v7, a3);
LABEL_5:
if ( !feof(v6) )
{
while ( v4 )
{
v5 = strcmp(Str1, Buffer);
if ( v5 < 0 )
{
v4 = read_movements(Str1, v7, a3);
goto LABEL_5;
}
if ( !v5 )
{
do
{
if ( v10 == 68 )
{
v14 = v14 - v11;
}
else if ( v10 == 67 )
{
v14 = v14 + v11;
}
put_in_FIFO(v15, Str1, 16);
v4 = read_movements(Str1, v7, a3);
}
while ( v4 && !strcmp(Str1, Buffer) );
fseek(v6, -60, 1);
fwrite(Buffer, 0x3Cu, 1u, v6);
fseek(v6, 0, 1);
if ( v14 < 0.0 )
{
while ( remove_from_FIFO(v15, Str1, 16) )
fprintf(v8, "%s, %c, %.2f\n", Str1, v10, v11);
}
else
{
erase_FIFO(v15);
}
}
fread(Buffer, 0x3Cu, 1u, v6);
if ( feof(v6) )
break;
}
}
fclose(v6);
fclose(v7);
fclose(v8);
result = 0;
}
else
{
fclose(v6);
fclose(v7);
result = 3;
}
}
else
{
fclose(v6);
result = 2;
}
}
return result;
}
我想知道从上面显示的伪代码中获取纯 C 代码的最佳方法是什么。显示的代码对我来说意义不大
有什么办法吗?你会怎么做?
我有点困惑。
编辑:
抱歉,我是反编译过程的新手。
我原来的函数原型是这样的:
update_FILES("../File/accounts.dat","../Files/movements.txt", key);
为什么参数彼此不同?。我不明白
我还是不太确定你对什么感到困惑...
...但是这个伪代码可能会有所帮助:
来电者:
update_FILES("../File/accounts.dat","../Files/movements.txt", key);
P-代码:
int __cdecl update_FILES(const char *a1, const char *a2, int a3)
{
<<Declare some local variables (result, v4, v5, v6, ...)>>
v6 = fopen("../File/accounts.dat")
if (v6 <> 0) // If "fopen()" succeed...
v7 = fopen("../Files/movements.txt")
if (v7 <> 0)
Destination = a2
...
我是这个主题的新手,在查看反编译器抛出的伪代码时卡住了。
我知道了:
int __cdecl update_FILES(const char *a1, const char *a2, int a3)
{
int result; // eax
int v4; // esi
int v5; // eax
FILE *v6; // [esp+20h] [ebp-98h]
FILE *v7; // [esp+24h] [ebp-94h]
FILE *v8; // [esp+28h] [ebp-90h]
char Str1[9]; // [esp+38h] [ebp-80h] BYREF
char v10; // [esp+41h] [ebp-77h]
float v11; // [esp+44h] [ebp-74h]
char Destination[50]; // [esp+4Ah] [ebp-6Eh] BYREF
char Buffer[56]; // [esp+7Ch] [ebp-3Ch] BYREF
float v14; // [esp+B4h] [ebp-4h]
_BYTE v15[336]; // [esp+B8h] [ebp+0h] BYREF
crear_cola_res(v15);
v6 = fopen(a1, "r+b");
result = 1;
if ( v6 )
{
v7 = fopen(a2, "rt");
if ( v7 )
{
strcpy(Destination, a2);
strcpy(strrchr(Destination, 46), "_myFile.txt");
v8 = fopen(Destination, "wb");
if ( v8 )
{
fread(Buffer, 0x3Cu, 1u, v6);
v4 = read_movements(Str1, v7, a3);
LABEL_5:
if ( !feof(v6) )
{
while ( v4 )
{
v5 = strcmp(Str1, Buffer);
if ( v5 < 0 )
{
v4 = read_movements(Str1, v7, a3);
goto LABEL_5;
}
if ( !v5 )
{
do
{
if ( v10 == 68 )
{
v14 = v14 - v11;
}
else if ( v10 == 67 )
{
v14 = v14 + v11;
}
put_in_FIFO(v15, Str1, 16);
v4 = read_movements(Str1, v7, a3);
}
while ( v4 && !strcmp(Str1, Buffer) );
fseek(v6, -60, 1);
fwrite(Buffer, 0x3Cu, 1u, v6);
fseek(v6, 0, 1);
if ( v14 < 0.0 )
{
while ( remove_from_FIFO(v15, Str1, 16) )
fprintf(v8, "%s, %c, %.2f\n", Str1, v10, v11);
}
else
{
erase_FIFO(v15);
}
}
fread(Buffer, 0x3Cu, 1u, v6);
if ( feof(v6) )
break;
}
}
fclose(v6);
fclose(v7);
fclose(v8);
result = 0;
}
else
{
fclose(v6);
fclose(v7);
result = 3;
}
}
else
{
fclose(v6);
result = 2;
}
}
return result;
}
我想知道从上面显示的伪代码中获取纯 C 代码的最佳方法是什么。显示的代码对我来说意义不大
有什么办法吗?你会怎么做?
我有点困惑。
编辑:
抱歉,我是反编译过程的新手。
我原来的函数原型是这样的:
update_FILES("../File/accounts.dat","../Files/movements.txt", key);
为什么参数彼此不同?。我不明白
我还是不太确定你对什么感到困惑... ...但是这个伪代码可能会有所帮助:
来电者:
update_FILES("../File/accounts.dat","../Files/movements.txt", key);
P-代码:
int __cdecl update_FILES(const char *a1, const char *a2, int a3)
{
<<Declare some local variables (result, v4, v5, v6, ...)>>
v6 = fopen("../File/accounts.dat")
if (v6 <> 0) // If "fopen()" succeed...
v7 = fopen("../Files/movements.txt")
if (v7 <> 0)
Destination = a2
...