Flag: Tornado! Hurricane!

 Forums >>  IDA Pro  >>  Question in IDA PRO and HEX-RAYS Decompiler

Topic created on: May 30, 2012 08:59 CDT by epi2000 .

Hi,

I'm sure the following code:


int __cdecl sort_balls()
{
  unsigned int v0; // ebx@1
  int v1; // edi@1
  int result; // eax@1
  unsigned int v3; // ebx@5
  int v4; // edx@5
  __int32 v5; // edx@17
  unsigned int v6; // eax@17
  int s[66]; // [sp+4h] [bp-108h]@1

  v0 = 0;
  memset(s, 0, 0xF4u);
  memset(s, 999, 0xF4u);
  v1 = 0;
  result = game_int;
  do
  {
    if ( !result )
    {
LABEL_17:
      v5 = random() % 60;
      v6 = 0;
      do
      {
        if ( v5 == s[v6] )
          goto LABEL_17;
        ++v6;
      }
      while ( v6 <= v0 );
      s[v0] = v5;
      result = game_int;
    }
    ++v0;
    *(_DWORD *)(v1 + 135362116) = 330;
    *(_DWORD *)(v1 + 135362120) = 12;
    *(_DWORD *)(v1 + 135362132) = 330;
    *(_DWORD *)(v1 + 135362136) = 12;
    *(_DWORD *)(v1 + 135362124) = 0;
    *(_DWORD *)(v1 + 135362128) = 0;
    v1 += 28;
  }
  while ( v0 <= 59 );
  *(_DWORD *)&ball[908] = 154;
  if ( !result )
  {
    v3 = 0;
    v4 = (int)ball;
    do
    {
      result = s[v3];
      if ( (unsigned int)result > 14 )
      {
        if ( (unsigned int)result > 29 )
        {
          if ( (unsigned int)result > 44 )
          {
            if ( (unsigned int)result > 59 )
              goto LABEL_9;
            result = *(_DWORD *)&cart[4 * result + 1264];
          }
          else
          {
            result = *(_DWORD *)&cart[4 * result + 844];
          }
        }
        else
        {
          result = *(_DWORD *)&cart[4 * result + 424];
        }
      }
      else
      {
        result = *(_DWORD *)&cart[4 * result + 4];
      }
      *(_DWORD *)v4 = result;
LABEL_9:
      ++v3;
      v4 += 28;
    }
    while ( v3 <= 0x3B );
  }
  return result;
}



I do not know what exactly "* (* _DWORD)" means. If a structure is and if it is how to improve this part of the code.

Thanks for the help, I'm starting this world. =)

  phn1x     May 30, 2012 10:27.11 CDT
http://msdn.microsoft.com/en-us/library/cc230318%28v=prot.10%29.aspx

  cod     May 31, 2012 03:45.30 CDT
it's a dereference to assign a value..

*(_DWORD *)v4 = result;

in assembly may be an istruction like:

mov edx, [esp+4] ; get v4
mov [edx], eax ; mov in v4 address a value

in c it's a simple instruction like this:

void func(int *a)
{
  int result = 0;
  *a = result;  // mov edx, [esp+8] ; get a pointer from stack
  // mov [edx], eax ; write result value into memory at address of pointer

}

Note: Registration is required to post to the forums.

There are 31,325 total registered users.


Recently Created Topics
Oct/23
Oct/23
Oct/23
Oct/23
Oct/23
Oct/23
Oct/23
Oct/23
Oct/23
Oct/23


Recent Forum Posts
Reverse Engineering ...
bytecod3r
Reverse Engineering ...
bytecod3r
Reverse Engineering ...
bytecod3r
Reverse Engineering ...
bytecod3r
Reverse Engineering ...
bytecod3r
let 'IDAPython' impo...
bytecod3r
Reverse Engineering ...
bytecod3r
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit