How do I convert this pseudocode to C++?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DrewDroid
    New Member
    • Feb 2014
    • 1

    How do I convert this pseudocode to C++?

    Can someone please help me convert some of this code to C++? It would be greatly appreciated.
    Code:
    int __cdecl sub_401000(int a1, int *a2)
    {
      int v2; // ebx@1
      int v3; // eax@1
      int v4; // eax@1
      int v5; // eax@2
      int result; // eax@2
      int v7; // [sp+10h] [bp-Ch]@1
      int v8; // [sp+14h] [bp-8h]@1
    
      v2 = a1;
      v8 = (int)"D:hhMessage.h";
      v7 = 156;
      v3 = sub_660A30((int)&a1, 0);
      v4 = sub_65FD30(0x14u, (int)&v7, *(_DWORD *)v3);
      if ( v4 )
      {
        v5 = sub_116EE20(*a2, v4);
        sub_4010E0(v2, v5);
        result = v2;
      }
      else
      {
        sub_4010E0(v2, 0);
        result = v2;
      }
      return result;
    }
    Code:
    int __thiscall sub_4011F0(void *this)
    {
      void *v1; // esi@1
      int result; // eax@1
    
      v1 = this;
      result = (int)((char *)this + 4);
      if ( !_InterlockedExchangeAdd((signed __int32 *)this + 1, 0xFFFFFFFFu) )
      {
        result = (*(int (__thiscall **)(_DWORD))(*(_DWORD *)this + 4))(this);
        if ( !_InterlockedExchangeAdd((signed __int32 *)v1 + 2, 0xFFFFFFFFu) )
          result = (*(int (__thiscall **)(_DWORD))(*(_DWORD *)v1 + 8))(v1);
      }
      return result;
    }
    ---------------------------------------------------------
    bool __stdcall sub_63DE40(int a1)
    {
      return a1 == (_DWORD)"Msg_Dig";
    }
    Code:
    int __userpurge sub_4284D0<eax>(int a1<eax>, int a2)
    {
      int result; // eax@1
      int v3; // ecx@2
      int v4; // ecx@3
      int v5; // esi@3
      char v6; // [sp+10h] [bp-8h]@1
      int v7; // [sp+14h] [bp-4h]@3
    
      result = sub_428B50((int)&v6, a1);
      if ( result != a2 )
      {
        v3 = *(_DWORD *)result;
        *(_DWORD *)result = *(_DWORD *)a2;
        *(_DWORD *)a2 = v3;
      }
      v4 = *(_DWORD *)(a2 + 4);
      *(_DWORD *)(a2 + 4) = *(_DWORD *)(result + 4);
      *(_DWORD *)(result + 4) = v4;
      v5 = v7;
      if ( v7 )
      {
        result = v7 + 4;
        if ( !_InterlockedExchangeAdd((signed __int32 *)(v7 + 4), 0xFFFFFFFFu) )
        {
          result = (*(int (__thiscall **)(int))(*(_DWORD *)v5 + 4))(v5);
          if ( !_InterlockedExchangeAdd((signed __int32 *)(v5 + 8), 0xFFFFFFFFu) )
            result = (*(int (__thiscall **)(int))(*(_DWORD *)v5 + 8))(v5);
        }
      }
      return result;
    }
    If some of this is too hard, then I understand. You don't have to convert it if you don't want to.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I can provide assistance in areas where you are stuck or I can provide advice on how to proceed in a given situation. However, I do not provide code, write specs, etc.

    In any case, this does not look like pseudo code so I am not sure exactly what it is you are asking.

    Comment

    Working...