Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different results between Ghidra and RzGhidra #52

Open
WhattaSkilL opened this issue Nov 5, 2019 · 4 comments
Open

Different results between Ghidra and RzGhidra #52

WhattaSkilL opened this issue Nov 5, 2019 · 4 comments

Comments

@WhattaSkilL
Copy link

WhattaSkilL commented Nov 5, 2019

Hello guys!
I got truble when try to decompile my example programm/
When i use ghidra i got result:

void FUN_00401d90(void)

{
  HMODULE hModule;
  FARPROC pFVar1;
  undefined local_9;
  uint local_8;
  
  local_8 = DAT_00407008 ^ (uint)&stack0xfffffffc;
  hModule = LoadLibraryA("ntdll.dll");
  if (hModule != (HMODULE)0x0) {
    pFVar1 = GetProcAddress(hModule,"RtlAdjustPrivilege");
    (*pFVar1)(0x13,1,0,&local_9);
  }
  FUN_0040229b();
  return;
}

But when i use rz-ghidra that looks like:

void main(void)
{
    int32_t iVar1;
    code *pcVar2;
    char *arg_8h;
    int32_t var_18h;
    undefined4 var_14h;
    undefined4 var_10h;
    undefined4 lpProcName;
    undefined var_5h;
    int32_t var_4h;
    
    var_4h = uRam00407008 ^ (uint32_t)&stack0xfffffffc;
    arg_8h = "ntdll.dll";
    iVar1 = (*_sym.imp.KERNEL32.dll_LoadLibraryA)();
    if (iVar1 != 0) {
        pcVar2 = (code *)(*_sym.imp.KERNEL32.dll_GetProcAddress)(iVar1, "RtlAdjustPrivilege");
        (*pcVar2)(0x13, 1, 0, &var_5h);
    }
    fcn.0040229b((int32_t)arg_8h);
    return;
}

Source:

int main(){
    BOOLEAN bEnabled;
    HMODULE RtlAdjustPrivilegeHModule = LoadLibraryA("ntdll.dll");
    if (!RtlAdjustPrivilegeHModule)
    {
         return 0;
    }
    LPVOID lpFuncAddress = GetProcAddress(RtlAdjustPrivilegeHModule, "RtlAdjustPrivilege");
    pdef_RtlAdjustPrivilege NtCall = (pdef_RtlAdjustPrivilege)lpFuncAddress;
    NTSTATUS NtRet = NTCall(19, TRUE, FALSE, &bEnabled);
    return 0;
}

So main problem here is argument for "KERNEL32.dll_LoadLibraryA". I try use files from ghidra for sleighhome but no matter. Some one hit that problem?

@Anutrix
Copy link

Anutrix commented Jan 1, 2020

This is happening to me often.
An example test file.
pro.zip
Ghidra:
WhatsApp Image 2020-01-01 at 22 51 07
R2Ghidra-Dec:
Capture75
Capture77

@bazuchan
Copy link

Happens to me too. For example binary https://github.com/csivitu/CTF-Write-ups/blob/master/CSAW%20Quals%202020/Rev/not_malware/not_malware

in ghidra main have this:
dVar4 = pow(16.00000000,0.50000000);

but in r2ghidra it looks like this:
sym.imp.pow(0x4030000000000000);

in ghidra main have this:

  if (local_a8[11] != local_7d) {
                    /* WARNING: Subroutine does not return */
    exit(1);
  }
  if (local_a8[3] != local_88[3]) {
                    /* WARNING: Subroutine does not return */
    exit(1);
  }
  if (local_a8[7] != local_81) {
                    /* WARNING: Subroutine does not return */
    exit(1);
  }

in r2ghidra:

    if (var_95h != var_75h) {            
    // WARNING: Subroutine does not return
        sym.imp.exit(1);
    }
    if (var_a0h._3_1_ != var_80h._3_1_) {
    // WARNING: Subroutine does not return
        sym.imp.exit(1);
    }
    if (var_a0h._7_1_ != var_80h._7_1_) {
    // WARNING: Subroutine does not return
        sym.imp.exit(1);
    }

@XVilka
Copy link
Member

XVilka commented Dec 23, 2020

It would be amazing if you could help to convert this into the test here: /test.

@thestr4ng3r
Copy link
Member

Well right now, most of these differences are expected and consequences of rizin's type system. So not sure if tests make sense yet.

@XVilka XVilka changed the title different results from ghidra and r2ghidra-dec Different results between Ghidra and RzGhidra Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants