-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add Support for Struct Imports #36
Comments
I've done this a few times manually and had some issues, for example with structs that aren't used anywhere in the code not being imported, or stuff not being loaded correctly if |
@k4lizen to clarify, you exported the struct from IDA, then put it in a C file and compiled it. Then you used the Good to know. I see this as the easiest path forward. However, there still exists the other path of crafting a DWARF (related to #54) with the struct information directly encoded in that. I'm not a huge fan of DWARF, but it could work more smoothly in more tools if done this way. |
I've just recently tried experimenting with importing symbols and structures into gdb so what I'm doing may very well not be the easiest way forward.
I "exported" it by copy pasting it from IDA to a C file but yes. The file looks like this for example: #include <stdint.h>
struct Mine // sizeof=0x18
{
char label[5];
// padding byte
// padding byte
// padding byte
char *content;
uint64_t size;
};
struct Mine p; // need it to be used somewhere Compiled with something like You might not have this issue though, or it might not be as relevant since there most likely will be variables in the program which use these structures. It's quite hacky. It seems to work for this person without specifying |
For now, we will only support IDA since we have a clear-cut way to both get every struct and also know when they have been updated. This may also be possible in Binja, but out of question for future Ghidra support... that one will have to wait.
IDA Changes
In IDA we need to utilize finding all ordinal numbers, which represents each custom struct in IDA. After that, we can use
idc.print_decls("1", 0)
for each number to get a nice C representation of the struct. Now that we have a string that has the C-definition of the struct we need to do things in the core.The changes all take place in the server. It's possible this may change the old API.
Client Changes
Assuming we now have a series of structs that are represented in C, we actually need to compile them into an object file and then add them with the classic
add-symbol-file
we use on the backend for other things. The trick though is adding this symbol file before we add the big one with all the global symbols here:decomp2dbg/decomp2dbg/clients/gdb/symbol_mapper.py
Line 243 in 5798361
Since both symbol files will be loaded into the same place, there will be an overlapping
main
function. We either need to bake structs directly into the first file we create, or we need to make a new way to addnative-struct
through the symbol mapper.The text was updated successfully, but these errors were encountered: