rizin icon indicating copy to clipboard operation
rizin copied to clipboard

Add default enums to database

Open dmknght opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. There are many const values in default libs have readable names. During programming time, it's easy to understand. For example, I have this code:

#include <unistd.h>
#include <stdio.h>


int main() {
  printf("%d\n", access("/etc/passwd", W_OK));
  return 0;
}

Const values are int. So when Rizin disassembly the code, It looks harder to understand, requires users checking the documentation (or the header files of source code). image

psudo code

int32_t main (void) {
    eax = access ("/etc/passwd", 2);
    esi = eax;
    eax = 0;
    printf (0x00002010);
    eax = 0;
    return eax;
}

Describe the solution you'd like I think a dictionary of const of system libraries is really useful (for example: socket). It helps users reduce time to check non famous int value.

Describe alternatives you've considered

  • It could be really hard to check push or move int before function is called. So maybe use this method is decompiler plugins is easier than do it it show disassembly code.
  • In comment of disassembly, I can see mov esi, 2 ; int mode so likely Rizin is supporting some sort of checking here. So I guess it's possible to show values in here like move esi, 2 ; int mode (W_OK) or UNIX_ACCESS_WRITE or unistd.h W_OK

dmknght avatar Feb 20 '22 18:02 dmknght

Update: deroad sent the db of linux-functions on telegram https://github.com/rizinorg/rizin/blob/dev/librz/analysis/d/functions-linux.sdb.txt so i think it's possible to do this idea but it requires different db reader method.

dmknght avatar Feb 20 '22 19:02 dmknght

Update: There are some examples in MacOS db https://github.com/rizinorg/rizin/blob/dev/librz/analysis/d/types-macos.sdb.txt#L4

dmknght avatar Feb 21 '22 11:02 dmknght

This issue has been automatically marked as stale because it has not had recent activity. Considering a lot has probably changed since its creation, we kindly ask you to check again if the issue you reported is still relevant in the current version of rizin. If it is, update this issue with a comment, otherwise it will be automatically closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 31 '22 05:08 stale[bot]

Hi, I am Sainithin , currently undergraduate final year student , i am willing to work on this task as part of qualification task for gsoc 2023. I was wondering if you could possibly elaborate a bit more on what you just mentioned? I would greatly appreciate any additional information you could share with me, like what files should be modified .Thank you

Sainithin-bit avatar Mar 17 '23 16:03 Sainithin-bit

Hi, I am Sainithin , currently undergraduate final year student , i am willing to work on this task as part of qualification task for gsoc 2023. I was wondering if you could possibly elaborate a bit more on what you just mentioned? I would greatly appreciate any additional information you could share with me, like what files should be modified .Thank you

Hello! The idea is very simple: There are default values in libraries / syscalls and it'd be much easier if the framework shows the values in enum-like values instead of digital numbers. For example, here are some default consts of socket https://man7.org/linux/man-pages/man2/socket.2.html. You can check the values and write it to the db of rizin as same as the MacOS db as the comment above.

dmknght avatar Mar 18 '23 21:03 dmknght