When porting the C header file, the Assembly always finds that the db dw dd DQ type is hard and unreadable, And the Win32 and win64 structures need to be maintained in two copies. So I wrote a FASM typedef macro (the same as C), which can be used in struct definition, data definition, and local variable definition of the function.
; --- ===--- FASM typedef macro by G-spider @ 2013; --- ===--- macro @ typedef base, [type] {forward struc type [v] \{\ common match any, V \\{. base v \\} match, V \\{. base? \\}\} Macro type [v] \{\ common match any, V \\{ base v \\} match, V \\{ base? \\}\} Virtual at 0 base? Sizeof. # type = $ end virtual} macro typedef [statement] {common match GS @ base GS @ type, statement \ {macro @ typedef GS @ base, GS @ Type \} For example:; declare typedef dd sdwordtypedef sdword DWORD, int32, longtypedef dB char, byte_win64 equ falsematch = true, _ win64 {typedef pvoid} match = false, _ win64 {typedef dd pvoid} typedef pvoid handle, pstr, pwstr ;....................; structure Definition struc point X, Y {. :. X sdword X. Y int 32 Y. size = $-.} struct size CX long? Cy long? Ends ;....................; data Definition M1 sdword 12, 13, 14, sizeof. dwordm2 int32 12, 13, 14, sizeof. int32my point 7, my. sizeint 32m3 int32 ;....................; function Local data definition proc windowproc uses ebx esi edi, hwnd, wmsg, wparam, lparam local HDC: handle local mysize: Size
Note:
Version 1.70 (Apr 17,201 2 ):
[+] Macroinstruction argument now can have default value, defined with "="
Symbol followed by value after the argument name in definition.
Therefore, for analyticdb 1.7 and later versions, it can be abbreviated:
Macro typedef [Statement *] {common match GS @ base GS @ type, statement \ {IRP type, GS @ Type \\{ struc type [V =?] \\{\\\ Common. Gs @ base v \\\} macro type [V =?] \\{\\\ Common GS @ base v \\\} virtual at 0 Gs @ base? Sizeof. \\# type = $ end virtual \\}\}}