converta código em c++

BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
  FILE *v3; // esi
  int v4; // edi
  int v5; // edx
  int v6; // ecx
  int v7; // eax
  int i; // eax
  FILE *v9; // eax
  _BYTE *v10; // edi
  int v11; // eax
  int j; // esi
  char v13; // dl
  int v14; // eax
  int v15; // esi
  int v16; // edx
  int v17; // ecx
  int v18; // edi
  unsigned __int8 v19; // al
  char Drive[4]; // [esp+8h] [ebp-654h] BYREF
  int v22; // [esp+Ch] [ebp-650h]
  int v23; // [esp+10h] [ebp-64Ch]
  int v24; // [esp+14h] [ebp-648h]
  int v25; // [esp+18h] [ebp-644h]
  void *Block; // [esp+1Ch] [ebp-640h]
  char Dir[256]; // [esp+20h] [ebp-63Ch] BYREF
  CHAR Filename[260]; // [esp+120h] [ebp-53Ch] BYREF
  CHAR FileName[260]; // [esp+224h] [ebp-438h] BYREF
  char v30[264]; // [esp+328h] [ebp-334h] BYREF
  char Destination[256]; // [esp+430h] [ebp-22Ch] BYREF
  char v32[260]; // [esp+530h] [ebp-12Ch] BYREF
  char Source[20]; // [esp+634h] [ebp-28h] BYREF
  int v34[3]; // [esp+648h] [ebp-14h]
  __int16 v35; // [esp+654h] [ebp-8h]

  if ( fdwReason && fdwReason != 2 && fdwReason != 3 )
  {
    GetModuleFileNameA(0, Filename, 0x104u);
    _splitpath_s(Filename, Drive, 3u, Dir, 0x100u, Destination, 0x100u, Source, 0x14u);
    strcat_s(Destination, 0x100u, Source);
    dword_100198F0 = malloc(0x104u);
    GetModuleFileNameA(hinstDLL, FileName, 0x104u);
    v3 = fopen(FileName, "rb");
    fseek(v3, 0, 2);
    v4 = ftell(v3);
    rewind(v3);
    Block = malloc(v4);
    fread(Block, v4, 1u, v3);
    v5 = -1;
    v6 = 0;
    v7 = 0;
    v34[0] = 5570638;
    v34[1] = 4325453;
    v34[2] = 5374021;
    v35 = 0;
    v25 = -1;
    if ( v4 > 0 )
    {
      while ( v6 <= 10 )
      {
        if ( *((unsigned __int8 *)Block + v7) == *((char *)v34 + v6) )
          ++v6;
        else
          v6 = 0;
        if ( ++v7 >= v4 )
        {
          v5 = v25;
          goto LABEL_12;
        }
      }
      v5 = v7 - v6 + 14;
    }
LABEL_12:
    v25 = (int)Block + v5;
    qmemcpy(v30, (char *)Block + v5, sizeof(v30));
    memcpy(dword_100198F0, &v30[4], 0x104u);
    qmemcpy(v32, (const void *)(v25 + 264), sizeof(v32));
    for ( i = 0; i < 260; ++i )
      v32[i] = ~v32[i];
    free(Block);
    v9 = fopen(v32, "rb");
    if ( !v9 )
    {
      MessageBoxA(
        0,
        "Couldn't locate the client executable.\r\nError code : 0x01.",
        "GRF Encryption - File not found",
        0);
      exit(1);
    }
    fclose(v9);
    v10 = dword_100198F0;
    v11 = *(unsigned __int8 *)dword_100198F0
        + ((*((unsigned __int8 *)dword_100198F0 + 1)
          + ((*((unsigned __int8 *)dword_100198F0 + 2) + (*((unsigned __int8 *)dword_100198F0 + 3) << 8)) << 8)) << 8);
    for ( j = 0; j < 256; ++j )
    {
      v13 = v11;
      v11 *= 47;
      byte_100198F8[j] = v10[j + 4] ^ v13;
    }
    ++dword_1001814C;
    v14 = 0;
    v15 = 0;
    v16 = 0;
    byte_100198F4 = 1;
    v25 = 0;
    v24 = 0;
    v17 = 0;
    v22 = 0;
    Block = 0;
    v23 = 0;
    do
    {
      v24 += (unsigned __int8)byte_100198F8[v14];
      v23 += (unsigned __int8)byte_100198F9[v14];
      Block = (char *)Block + (unsigned __int8)byte_100198FA[v14];
      v18 = (unsigned __int8)byte_100198FB[v14];
      v25 += v14;
      v22 += v18;
      v17 += v14 + 1;
      v16 += v14 + 2;
      v15 += v14 + 3;
      v14 += 4;
    }
    while ( v14 < 256 );
    if ( (void *)(v17 + v16 + v15 + v25) == (char *)Block + v22 + v23 + v24 )
    {
      v19 = 1;
    }
    else
    {
      memset(byte_100198F8, 0, 0x100u);
      v19 = 0;
    }
    dword_100199F8 = v19;
    if ( strcmp(Destination, v32) )
    {
      MessageBoxA(
        0,
        "The client executable is invalid. Encryption feature will be disabled.\r\nError code : 0x02.",
        "GRF Encryption - File not found",
        0);
      dword_100199F8 = 0;
    }
  }
  return 1;
}