ghidra_psx_ldr icon indicating copy to clipboard operation
ghidra_psx_ldr copied to clipboard

Some structures from symbols not being applied

Open MrSapps opened this issue 5 years ago • 21 comments
trafficstars

Ghidra/plugin output:

/* File: E:\DATA\MGS\MGS_REVERSING\SRC\JIMCTRL_KILL_8003853C.C */

void jimctrl_kill_8003853C(void *pJimCtrl)
{
  sub_80038004();
  dword_8009E280.m[2]._0_4_ = 0;
  sub_80024098();
  return;
}

Original code:

typedef struct
{
    int dword_8009E280;
    int dword_8009E284;
    int dword_8009E288;
    int dword_8009E28C;
} unk_8009E280;

unk_8009E280 dword_8009E280 = {0, 0, 0, 0};

void jimctrl_kill_8003853C(void *pJimCtrl)
{
    sub_80038004(pJimCtrl);
    dword_8009E280.dword_8009E28C = 0;
    sub_80024098();
}

Binary and symbol file attached for repro.

ghidra.zip

MrSapps avatar Jan 26 '20 14:01 MrSapps

Thanks, I'll check it.

lab313ru avatar Jan 26 '20 15:01 lab313ru

Fixed via d8c76ac4cc3c3e460c769aed7b1387268e6f89ba. Check the project's new release.

lab313ru avatar Jan 27 '20 21:01 lab313ru

May I ask you: how did you get this SYM file? How it was generated?

lab313ru avatar Jan 27 '20 21:01 lab313ru

by compiling this source https://github.com/FoxdieTeam/mgs_reversing

MrSapps avatar Jan 28 '20 15:01 MrSapps

Thanks. If you will find some other problems, feel free to create an issue with a bunch of mistakes related to mgs_reversing.

lab313ru avatar Jan 28 '20 15:01 lab313ru

There still seems to be something strange going on here, the output is now:

void FUN_8003853c(void)
{
  FUN_80038004();
  unk_8009E280.dword_8009E28C = 0;
  FUN_80024098();
  return;
}

However as you can see some function names are now missing and also the correct name of the var is missing (it should be dword_8009E280 not unk_8009E280).

There is maybe another existing issue where some function names do not get applied too:

ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_GetPrimInfo_80038D68
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_JimakuWrite_800494E8
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_GetRadioCode_800497C4
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_DrawBar_80038D74
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_SetLoad_800427E8
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_DrawBar2_80038DE0
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_AreaNameWrite_80049534
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_Text_XY_Flags_80038B34
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_RadioCall_80042730
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_InitRadioTable_80049644
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_ResetCall_80042814
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_Text_80038C38
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_set_chara_code_800471AC
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_Text_Init_80038b98
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_SetRadioCallbackProc_8004283C
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_ClearRadioTable_8004967C
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_Color_80038B4C
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_InitRadioMemory_8004E0EC
ghidra.util.exception.InvalidInputException: Symbol name matches possible default symbol name: MENU_JimakuClear_80049518

When checking say MENU_JimakuClear_80049518 its name is FUN_80049518 which is not correct in respect to the symbol file.

MrSapps avatar Jan 28 '20 17:01 MrSapps

FUN_8003853c - but I have jimctrl_kill_8003853 here.

lab313ru avatar Jan 28 '20 17:01 lab313ru

hmm let me try again...

MrSapps avatar Jan 28 '20 17:01 MrSapps

it always repros with this sym for me, might not be the same as the one I originally used in this bug

asm.zip

MrSapps avatar Jan 28 '20 18:01 MrSapps

You've modified your sym file, so...:

03c450: $800382ec 94 Def class EXT type FCN VOID size 0 name jimctrl_kill_8003853C

jimctrl_kill_8003853C has now 0x800382ec address

lab313ru avatar Jan 28 '20 18:01 lab313ru

damn by bad, I'll try again with the original

MrSapps avatar Jan 28 '20 18:01 MrSapps

As I understand your current situation: your sym file was modified, but you're still using the original executable.

lab313ru avatar Jan 28 '20 18:01 lab313ru

Yeah I rebuilt from a bad version of the code, sorry about wasting your time on that. However even with the original symbol file the global var name is still incorrect?


/* File: E:\DATA\MGS\MGS_REVERSING\SRC\JIMCTRL_KILL_8003853C.C */

void jimctrl_kill_8003853C(void *pJimCtrl)
{
  sub_80038004();
  unk_8009E280.dword_8009E28C = 0;
  sub_80024098();
  return;
}

Edit: Issue with the names not applying from the exception messages still seems to stand too.

MrSapps avatar Jan 28 '20 18:01 MrSapps

Yes, fixing it...

lab313ru avatar Jan 28 '20 18:01 lab313ru

I also noticed another possible regression, in function 80018384 the first argument is undefined but it should be DRAWENV pointer

MrSapps avatar Jan 28 '20 18:01 MrSapps

New fixes via: 7f76770509fd8c9d1e74326166ea2cf07c85d423. Check new release.

lab313ru avatar Jan 28 '20 20:01 lab313ru


/* File: E:\DATA\MGS\MGS_REVERSING\SRC\JIMCTRL_KILL_8003853C.C */

void jimctrl_kill_8003853C(void *pJimCtrl)
{
  sub_80038004();
  DAT_8009e28c = 0;
  sub_80024098();
  return;
}

Still looks like it isn't working?

MrSapps avatar Jan 28 '20 22:01 MrSapps

It's strange, but not all structures defined in SYM file: HzdMap, for example.

lab313ru avatar Jan 29 '20 10:01 lab313ru

Maybe you can add verbose loading option so its easier for noob user like me to understand what is wrong. Right now I can't know if the structure for DAT_8009e28c is in sym file or not.

MrSapps avatar Jan 29 '20 12:01 MrSapps

Any progress? I've created a fork so I can build this and the latest code has a null pointer exception. I've also been trying to hack in a menu item to re-apply symbols after creating the ghidra DB.

MrSapps avatar Feb 16 '20 15:02 MrSapps

Unfortunately, I've stucked for now in fixing SIM file reading. Requires more time than I thought.

вс, 16 февр. 2020 г. в 18:43, Paul [email protected]:

Any progress? I've created a fork so I can build this and the latest code has a null pointer exception. I've also been trying to hack in a menu item to re-apply symbols after creating the ghidra DB.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/lab313ru/ghidra_psx_ldr/issues/18?email_source=notifications&email_token=ABW3GPJQTANTF7X4ZRZNPT3RDFNIHA5CNFSM4KLXHNC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL4KMDA#issuecomment-586720780, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABW3GPPUQDKZRH5BL7FF2YTRDFNIHANCNFSM4KLXHNCQ .

lab313ru avatar Feb 17 '20 08:02 lab313ru