unsigned int __cdecl EncryptCode::DecryptCodeByXOR(EncryptCode *this, unsigned __int8 *dest, unsigned int *a3)
{
unsigned int result; // eax
unsigned int v4; // eax
unsigned __int8 v5; // bl
unsigned int v6; // edx
int v7; // ecx
unsigned int v8; // esi
result = *a3;
if ( dest
&& result >= 8
&& *dest == -86
&& dest[1] == -86
&& dest[2] == -86
&& dest[3] == -86
&& dest[4] == -86
&& dest[5] == -86 )
{
if ( dest[6] == -86 || !dest || result <= 4 )
return result;
}
else if ( !dest || result < 5 )
{
return result;
}
if ( !*dest && !dest[3] && dest[dest[1] + 4] == dest[2] )
{
v4 = result - 4;
*a3 = v4;
memcpy(dest, dest + 4, v4);
result = *a3;
if ( *a3 )
{
v5 = *((_BYTE *)this + 16);
v6 = result % v5;
v7 = *dest;
*dest ^= v6;
result = (unsigned int)a3;
if ( *a3 >= 2 )
{
v8 = 1;
do
{
v6 = (v7 + (unsigned int)(unsigned __int8)v6) % v5;
v5 = *((_BYTE *)this + 16);
v7 = dest[v8];
dest[v8++] = v7 ^ v6;
result = (unsigned int)a3;
}
while ( v8 < *a3 );
}
}
}
return result;
}
With defined headers (from IDA SDK):
#define __int8 char
typedef unsigned char uint8;
#define _BYTE uint8
Thing is, I never had experience with C so all I can do is "read" the code but not write it (most of the part is how to define EncryptCode
).
Also, using frida I dumped from memory the hex of EncryptCode *this
= 09 03 08 0c 0a 04 0d 0b
so can I use it as a constant?