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,099 total registered users.


Recently Created Topics
How to view IDA Pro'...
Nov/02
reverse MC9S12DG128
Oct/07
Looking for an advan...
Mar/21
Ultimate Hacking Cha...
Jun/21
CreateMutex
May/31
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15


Recent Forum Posts
Looking for an advan...
tthtlc
Looking for an advan...
tthtlc
Looking for an advan...
clightning
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo


Recent Blog Entries
nieo
Mar/22
Android Application Reversing

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...

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