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

[pcustom] Describe struct with struct member #49

Closed
u0m3 opened this issue Aug 21, 2016 · 8 comments
Closed

[pcustom] Describe struct with struct member #49

u0m3 opened this issue Aug 21, 2016 · 8 comments

Comments

@u0m3
Copy link
Contributor

u0m3 commented Aug 21, 2016

How does one describe a struct that has another struct as a member (or is it even possible)?

struct fosphor_cl_features
{
#define FLG_CL_GL_SHARING   (1<<0)
#define FLG_CL_NVIDIA_SM11  (1<<1)
#define FLG_CL_OPENCL_11    (1<<2)
#define FLG_CL_LOCAL_ATOMIC_EXT (1<<3)

    cl_device_type type;
    char vendor[128];
    unsigned long local_mem;
    int flags;
    int wg_size;
    int wg_size_dim[2];
};

struct fosphor_cl_state
{
    cl_platform_id   pl_id;
    cl_device_id     dev_id;
    cl_context       ctx;
    cl_command_queue cq;

    /* Features */
    struct fosphor_cl_features feat;

    /* FFT */
    cl_mem      mem_fft_in;
    cl_mem      mem_fft_out;
    cl_mem      mem_fft_win;

    cl_program  prog_fft;
    cl_kernel   kern_fft;

    float       *fft_win;
    int     fft_win_updated;

    /* Display */
    cl_mem      mem_waterfall;
    cl_mem      mem_histogram;
    cl_mem      mem_spectrum;

    cl_program  prog_display;
    cl_kernel   kern_display;

    /* Histogram range */
    float       histo_scale;
    float       histo_offset;

    /* State */
    int     waterfall_pos;
    enum {
        CL_BOOTING = 0,
        CL_PENDING,
        CL_READY,
    } state;
};

( code taken from https://github.com/osmocom/gr-fosphor/blob/master/lib/fosphor/cl.c )

@hugsy
Copy link
Owner

hugsy commented Aug 23, 2016

That's not implemented yet, but it's on the TODO list.

@Grazfather
Copy link
Collaborator

Grazfather commented Nov 11, 2016

I played with this tonight. Shouldn't be too difficult.

We need a way to have structures reference eachother.

  1. The name shoudn't have to be Template
  2. We should allow more than one per file. Maybe they would be referenced by module? e.g. dt heap.main_arena, allowing something like heap.fast_bins to exist in the same module and obviously allow them to reference each other.
  3. Should we allow inter-module? This gets a bit tricky because the importing between would be weird. I hacked this in a test module by editing sys.path which is very bad style

Note that this only works for embedded structures not pointers to structures.

@hugsy
Copy link
Owner

hugsy commented Dec 12, 2016

@Grazfather : I totally missed your comment on this ... I needed this feature on a CTF this weekend, so I was about to get to it. Do you already have a patch ready for that?

@Grazfather
Copy link
Collaborator

Grazfather commented Dec 12, 2016

Mine is super ugly, but I can push it.

EDIT: https://github.com/Grazfather/gef/tree/embed

@hugsy
Copy link
Owner

hugsy commented Dec 12, 2016

I'll have a look but I've also started on my end 😄

@Grazfather
Copy link
Collaborator

For sure. It's easy enough to implement, I just wasn't sure a nice way to have the modules find each other (sys.path stuff) and how to make it look.

hugsy pushed a commit that referenced this issue Dec 12, 2016
- issue #49: by default, the name of the ctype structure created will be the
- filename (instead of Template(Structure))
@hugsy
Copy link
Owner

hugsy commented Dec 12, 2016

For now, I'm using pcustom.struct_path to "manually" load the desired module (with imp): for every .py file in the directory, I am importing all classes from the variable exportables. This approach allows to not touch the Python path, but also to select which class are to be visible.

@hugsy
Copy link
Owner

hugsy commented Dec 15, 2017

This was fixed long ago.

@hugsy hugsy closed this as completed Dec 15, 2017
SakiiR pushed a commit to SakiiR/gef that referenced this issue Jul 1, 2019
- issue hugsy#49: by default, the name of the ctype structure created will be the
- filename (instead of Template(Structure))
SakiiR pushed a commit to SakiiR/gef that referenced this issue Jul 1, 2019
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

3 participants