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

Replace pythonic type for representing a pointer with _weakref.ref or something better named. #148

Closed
arizvisa opened this issue Nov 10, 2021 · 6 comments
Assignees

Comments

@arizvisa
Copy link
Owner

arizvisa commented Nov 10, 2021

The pythonic types component could be reworked a bit to clean up the atoms (or types) that are used. Instead of using type for a reference, or chr for a character we can allow for more types or use things that are more clear.

We currently have [chr, length] for an array of characters and essentially str is just an alias for that. However, we can use str with the form (str, widthtype, lengthtype) to specify a particular type of string.

As prior noted, we use type to note a reference (pointer) but it would be more clear if we dual-use the weakref type that you find in _weakref.ref. This could also be used like (_weakref.ref, 4) to specify a uint32_t-sized pointer. We'd also need to expose _weakref.ref by importing it into the global namespace so that users could access it as ref or reference when assigning their types.

It'd be nice to figure out a type that lets you specify an enum used for a particular type. This would be vastly different because the way we're specifying structures is by wrapping them with a python object. There's a list of builtin modules that can be scraped for relelvant types in the sys.builtin_module_names tuple.

@arizvisa arizvisa self-assigned this Nov 10, 2021
@arizvisa
Copy link
Owner Author

arizvisa commented Feb 2, 2022

Support for idaapi.tinfo_t should also be added to the pythonic types. This will be an ongoing thing as I think I'm the only person in the world that's using them at this level at the moment.

@arizvisa
Copy link
Owner Author

Issue #156 and PR #157 is semi-related to this. None of this is relevant, but I'm truly considering deprecating pythonic-types to exchange idaapi.tinfo_t with it...but that would fucking suck because tinfo_t is hardly even linked to IDA's database.

@arizvisa
Copy link
Owner Author

Commit 6b91323 adds the ability to destructively assign a tinfo_t to a member. I'm not sure how much farther I should go. Maybe I should add support for pythonic-types to the database.type namespace to allow assigning a type non-destructively to an address too.

@arizvisa
Copy link
Owner Author

arizvisa commented Aug 8, 2022

Commit e2d094f adds support for variable-length structures (specified as a tuple of the type and size), and also adds the various string types of different widths and length-prefixes (specified as a tuple of (chr, width, prefix)). This is sort of related to commit 3c2ee19 which enables support for arbitrary string-encodings.

@arizvisa arizvisa changed the title Adding more atoms to the "pythonic" types component and the replacing of type for representing a pointer with _weakref.ref or similar. Replace pythonic type for representing a pointer with _weakref.ref or something better named. Aug 8, 2022
@arizvisa
Copy link
Owner Author

arizvisa commented Aug 8, 2022

Maybe it'd be a better idea to use object for pointers? Just throwing this out there..

@arizvisa
Copy link
Owner Author

arizvisa commented Oct 31, 2022

I've settled on type. Adding support for tinfo_t to Pythonic types doesn't work universally without converting tinfo_t into a Pythonic type. This isn't easy to do since tinfo_t can be empty, unsized, etc. To still allow support for tinfo_t, however, in #158 you're able to assign it to any function that would take a Pythonic-type. This results in different semantics in that assigning a pythonic-type is more of a "suggestion", and assigning a tinfo_t will force IDA to apply it (thus destroying any types after it if the type's size has changed).

Nobody cares about this anyways, so this issue is being closed.

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

1 participant