News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Convert MSDN structures to MASM format

Started by jj2007, February 17, 2014, 03:38:07 AM

Previous topic - Next topic

jj2007

As the title says, the attached proggie converts C/C++ structures to MASM format. It is meant to be added to the menu of qEditor. If it detects a C/C++ structure on the clipboard, the process is automatic, otherwise you have to paste the struct in the right pane and press Ctrl C.

Gunther

Jochen,

you've included the ASC file. Why not the ASM source?

Gunther
You have to know the facts before you can distort them.

jj2007

Just open it in Wordpad, copy all, paste in whatever plain text editor you are using.

Gunther

Jochen,

Quote from: jj2007 on February 17, 2014, 05:23:46 AM
Just open it in Wordpad, copy all, paste in whatever plain text editor you are using.

that works. Thank you.

Gunther
You have to know the facts before you can distort them.

jj2007

Version B attached on top of thread. It can handle MSDN OPENFILENAME to 99%.

If anybody knows a tricky structure on MSDN, please let me know.

dedndave

what do you mean by tricky?

INPUT_RECORD is a little tricky   :P
NONCLIENTMETRICS (i think that's the name) is a little problematic, too

jj2007

Quote from: dedndave on February 17, 2014, 11:55:12 AM
what do you mean by tricky?

INPUT_RECORD is a little tricky   :P
Looks OK:
INPUT_RECORD STRUCT
  KeyEvent     KEY_EVENT_RECORD <>
  MouseEvent   MOUSE_EVENT_RECORD <>
  WindowBufferSizeEvent   WINDOW_BUFFER_SIZE_RECORD <>
  MenuEvent    MENU_EVENT_RECORD <>
  FocusEvent   FOCUS_EVENT_RECORD <>
INPUT_RECORD ENDS


QuoteNONCLIENTMETRICS (i think that's the name) is a little problematic, too
Could be worse:
NONCLIENTMETRICS STRUCT
  cbSize       UINT ?
  iBorderWidth   dd ?
  iScrollWidth   dd ?
  iScrollHeight   dd ?
  iCaptionWidth   dd ?
  iCaptionHeight   dd ?
  lfCaptionFont   LOGFONT <>
  iSmCaptionWidth   dd ?
  iSmCaptionHeight   dd ?
  lfSmCaptionFont   LOGFONT <>
  iMenuWidth   dd ?
  iMenuHeight   dd ?
  lfMenuFont   LOGFONT <>
  lfStatusFont   LOGFONT <>
  lfMessageFont   LOGFONT <>
if (WINVER ge 00600h)
  iPaddedBorderWidth   dd ?
endif
NONCLIENTMETRICS ENDS

dedndave

NONCLIENTMETRICS is tricky because of alignment issues   :biggrin:

INPUT_RECORD is a little tricky because it has the most complex unions that i could think of - lol
typedef struct _INPUT_RECORD {
  WORD  EventType;
  union {
    KEY_EVENT_RECORD          KeyEvent;
    MOUSE_EVENT_RECORD        MouseEvent;
    WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
    MENU_EVENT_RECORD         MenuEvent;
    FOCUS_EVENT_RECORD        FocusEvent;
  } Event;
} INPUT_RECORD;

jj2007

Quote from: dedndave on February 17, 2014, 01:01:15 PM
INPUT_RECORD is a little tricky because it has the most complex unions that i could think of - lol

That translates to
INPUT_RECORD STRUCT
KeyEvent     KEY_EVENT_RECORD <>
MouseEvent   MOUSE_EVENT_RECORD <>
WindowBufferSizeEvent   WINDOW_BUFFER_SIZE_RECORD <>
MenuEvent    MENU_EVENT_RECORD <>
FocusEvent   FOCUS_EVENT_RECORD <>
INPUT_RECORD ENDS

i.e. you have to add the UNION yourself.

I've updated the app, see top of thread. It now handles this:

typedef struct {
int  argc;              /* Count of files to zip */
LPSTR lpszZipFN;        /* name of archive to create/update */
char **FNV;             /* array of file names to zip up */
} ZCL, _far *LPZCL;

... translates to ...

ZCL STRUCT
argc         dd ?   ; Count of files to zip
lpszZipFN    LPSTR ?   ; name of archive to create/update
FNV          LPSTR ?   ; array of file names to zip up
ZCL ENDS


Not sure if that is correct (it will probably work, LPSTR is DWORD); maybe the C/C++ gurus can explain what the correct type for char ** would be ;-)

ragdog

Hi Jochen

Nice little helper :t

QuoteNot sure if that is correct (it will probably work, LPSTR is DWORD); maybe the C/C++ gurus can explain what the correct type for char ** would be ;-)
http://petio.org/winasm/masm.html

But what good works to translate header to include is h2incx
http://www.japheth.de/h2incX.html

dedndave

Quotei.e. you have to add the UNION yourself.

not sure what you mean by that - lol

INPUT_RECORD STRUCT
  EventType             WORD ?
  two_byte_alignment    WORD ?
  UNION
    KeyEvent                KEY_EVENT_RECORD            <>
    MouseEvent              MOUSE_EVENT_RECORD          <>
    WindowBufferSizeEvent   WINDOW_BUFFER_SIZE_RECORD   <>
    MenuEvent               MENU_EVENT_RECORD           <>
    FocusEvent              FOCUS_EVENT_RECORD          <>
  ENDS
INPUT_RECORD ENDS

jj2007

Quote from: ragdog on February 17, 2014, 05:02:29 PM
QuoteNot sure if that is correct (it will probably work, LPSTR is DWORD); maybe the C/C++ gurus can explain what the correct type for char ** would be ;-)
http://petio.org/winasm/masm.html

There is no char * on that page, let alone char **...

QuoteBut what good works to translate header to include is h2incx
http://www.japheth.de/h2incX.html

Yes, I've tested that one in the meantime. Very sophisticated tool indeed, although a bit clumsy to use for the simple task of translating a structure (and the comments are badly formatted, too).

Quote from: dedndave on February 17, 2014, 05:48:23 PMINPUT_RECORD STRUCT
  EventType             WORD ?
  two_byte_alignment    WORD ?
  UNION

That looks like one of these wonderful bugs that are almost impossible to chase. Worth a separate thread imho :P

GoneFishing

Quote from: jj2007 on February 17, 2014, 01:11:25 PM
...
typedef struct {
int  argc;              /* Count of files to zip */
LPSTR lpszZipFN;        /* name of archive to create/update */
char **FNV;             /* array of file names to zip up */
} ZCL, _far *LPZCL;
...
Where is this structure defined? I didn't find it in Windows SDK includes.
EDIT:Well, I've found it.
It's from WIZDLL32 project

ragdog

I think  char ** is a dword

char **FNV; 

I have translate with h2incx here is the result

ZCL struct
argc DWORD ?
lpszZipFN LPSTR ?
FNV DWORD ?
ZCL ends

TWell

Here are some findings:
Quotetypedef struct tagOCPFIPARAMS {
    ULONG cbStructSize;
    HWND hWndOwner;
    int x;
    int y;
    LPCOLESTR lpszCaption;
    ULONG cObjects;
    LPUNKNOWN *lplpUnk;
    ULONG cPages;
    CLSID *lpPages;
    LCID lcid;
    DISPID dispidInitialProperty;
} OCPFIPARAMS, *LPOCPFIPARAMS;

QuoteOCPFIPARAMS STRUCT
cbStructSize   ULONG ?
hWndOwner    HWND ?
x            dd ?
y            dd ?
lpszCaption   LPCOLESTR <>
cObjects     ULONG ?
lplpUnk      LPSTR ?
cPages       ULONG ?
lpPages      LPSTR ?
lcid         LCID <>
dispidInitialProperty   DISPID <>
OCPFIPARAMS ENDS

Quotetypedef struct tagPICTDESC {
    UINT cbSizeofstruct;
    UINT picType;
    union {
        struct {
            HBITMAP hbitmap;
            HPALETTE hpal;
        } bmp;
        struct {
            HMETAFILE hmeta;
            int xExt;
            int yExt;
        } wmf;
        struct {
            HICON hicon;
        } icon;
        struct {
            HENHMETAFILE hemf;
        } emf;
    };
} PICTDESC, *LPPICTDESC;

QuotePICTDESC STRUCT
hemf         HENHMETAFILE <>
PICTDESC ENDS

Not in MSDN in this way
Quotetypedef struct _GUID {
    unsigned long Data1;
    unsigned short Data2;
    unsigned short Data3;
    unsigned char Data4[8];
} GUID;

QuoteGUID STRUCT
long         unsigned <>
short        unsigned <>
short        unsigned <>
char         unsigned <>
GUID ENDS