speakeasy icon indicating copy to clipboard operation
speakeasy copied to clipboard

consider integration with fox-it/dissect.cstruct for structure declarations

Open williballenthin opened this issue 3 years ago • 2 comments

https://github.com/fox-it/dissect.cstruct is a project the implements a parser for a subset of C for structure declaration (and parsing). it looks pretty natural to use. i wonder if we could use dissect.cstruct as a speakeasy.struct frontend so that its even easier to import structures from MSDN, etc.

williballenthin avatar Oct 07 '20 18:10 williballenthin

speakeasy.struct.Struct.from_c("""
  struct some_struct {
      uint8   field_1;
      char    field_2[SOME_CONSTANT];
      char    field_3[field_1 & 1 * 5];  // Some random expression to calculate array length
      Example field_4[2];
  };
""")

uses dissect.cstruct to parse the string and then translate and return a speakeasy.struct

williballenthin avatar Oct 07 '20 18:10 williballenthin

Very cool, it looks like we could also easily dynamically set the pointer size.

drewvis avatar Oct 07 '20 18:10 drewvis