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

Design ctypes equivalent for syscall implementation #2

Closed
mrexodia opened this issue Nov 30, 2021 · 1 comment · Fixed by #61
Closed

Design ctypes equivalent for syscall implementation #2

mrexodia opened this issue Nov 30, 2021 · 1 comment · Fixed by #61
Labels
feature New feature or request

Comments

@mrexodia
Copy link
Owner

Currently the type system for syscalls is very rough and you need to do a lot of manual work. A type system similar to ctypes needs to be implemented where you can set struct members, work with enums etc.

Once the type system is complete a pdb/header parser can be implemented to support all the native types.

@mrexodia mrexodia added the feature New feature or request label Dec 15, 2021
@mrexodia mrexodia added this to the v0.1.0 milestone Dec 15, 2021
@mrexodia
Copy link
Owner Author

Probably it's enough to use a wrapper around ctypes:

def MEMORY_BASIC_INFORMATION(arch: Architecture):
    class MEMORY_BASIC_INFORMATION(ctypes.Structure):
        _alignment_ = arch.alignment()
        _fields_ = [
            ("BaseAddress", arch.ptr_type()),
            ("AllocationBase", arch.ptr_type()),
            ("AllocationProtect", ctypes.c_uint32),
            ("PartitionId", ctypes.c_uint16),
            ("RegionSize", arch.ptr_type()),
            ("State", ctypes.c_uint32),
            ("Protect", ctypes.c_uint32),
            ("Type", ctypes.c_uint32),
        ]
    return MEMORY_BASIC_INFORMATION()

The only thing left is to allow you to do:

            ("MbiPtr", arch.ptr_type(MEMORY_BASIC_INFORMATION)),

This might be possible by inheriting from ctypes and making it deserialize to a P(MEMORY_BASIC_INFORMATION), but this needs some more research.

@mrexodia mrexodia removed this from the v0.1.0 milestone Oct 11, 2022
@mrexodia mrexodia changed the title Implement ctypes equivalent for syscall implementation Design ctypes equivalent for syscall implementation Oct 11, 2022
This was referenced Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant