News:

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

Main Menu

Partially converted C to ASM prototypes.

Started by hutch--, September 26, 2016, 12:08:05 PM

Previous topic - Next topic

hutch--

This is a test piece converting C prototypes from Pelle's C to POASM prototype format that should work with the Watcom forks as well. The attached file is a partial conversion of Winuser.h to POASM format. I don't need them for ML64 but they may be useful for POASM and the others. You will need to download Pelles C for the C header files.

habran

I don't believe it would work with JWasm or HJWasm, however, even if it would this is only for x64, not typed as well, while WinInc works for both x86 and x64 and it is typed. Compare these two below.
Your include:
Quote
wvsprintfA PROTO :QWORD,:QWORD,:VARARG
wvsprintfW PROTO :QWORD,:QWORD,:VARARG
wsprintfA PROTO :QWORD,:QWORD, ...
wsprintfW PROTO :QWORD,:QWORD, ...

WinInc include:
Quote
@DefProto WINUSERAPI, wvsprintfA, stdcall, , <:LPSTR, :LPSTR, :va_list>, 12
@DefProto WINUSERAPI, wvsprintfW, stdcall, , <:LPWSTR, :LPWSTR, :va_list>, 12
ifdef UNICODE
wvsprintf   EQU   <wvsprintfW>
else
wvsprintf   EQU   <wvsprintfA>
endif
@DefProto WINUSERAPI, wsprintfA, c, , <:LPSTR, :LPSTR, :VARARG>
@DefProto WINUSERAPI, wsprintfW, c, , <:LPWSTR, :LPWSTR, :VARARG>
ifdef UNICODE
wsprintf   EQU   <wsprintfW>
else
wsprintf   EQU   <wsprintfA>
endif
Cod-Father

hutch--

The format is specifically x64, if I wanted to write 32 bit assembler, I already have ML.EXE and a very mature support system for it. It certainly will work when fully converted for POASM in 64 bit but if JWASM or HJWASM is no longer 32 bit MASM compatible in its prototype format, then it would be no use to them.

This is how you do the standard Microsoft format.

wvsprintfA PROTO :QWORD,:QWORD,:VARARG
wvsprintfW PROTO :QWORD,:QWORD,:VARARG
IFNDEF __UNICODE__
  wvsprintf equ <wvsprintfA>
ELSE
  wvsprintf equ <wvsprintfW>
ENDIF

hutch--

For anyone who wants to try and backtrack multiple levels of nested typedefs to get the C data types, the conversion is even simpler if you don't mind the lack of documentation on the actual data sizes for function parameters. It looks like this,

wvsprintfA PROTO LPSTR,LPCSTR,va_list
wvsprintfW PROTO LPWSTR,LPCWSTR,va_list
wsprintfA PROTO LPSTR,LPCSTR, ...
wsprintfW PROTO LPWSTR,LPCWSTR, ...
LoadKeyboardLayoutA PROTO LPCSTR,UINT
LoadKeyboardLayoutW PROTO LPCWSTR,UINT
ActivateKeyboardLayout PROTO HKL,UINT
ToUnicodeEx PROTO UINT,UINT,CONST BYTE*,LPWSTR,int,UINT,HKL
UnloadKeyboardLayout PROTO HKL
GetKeyboardLayoutNameA PROTO LPSTR
GetKeyboardLayoutNameW PROTO LPWSTR
GetKeyboardLayoutList PROTO int,HKL*
GetKeyboardLayout PROTO DWORD
GetMouseMovePointsEx PROTO UINT,LPMOUSEMOVEPOINT,LPMOUSEMOVEPOINT,int,DWORD
CreateDesktopA PROTO LPCSTR,LPCSTR,LPDEVMODEA,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES
CreateDesktopW PROTO LPCWSTR,LPCWSTR,LPDEVMODEW,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES
CreateDesktopExA PROTO LPCSTR,LPCSTR,LPDEVMODEA,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES,ULONG,PVOID
CreateDesktopExW PROTO LPCWSTR,LPCWSTR,LPDEVMODEW,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES,ULONG,PVOID
OpenDesktopA PROTO LPCSTR,DWORD,BOOL,ACCESS_MASK
OpenDesktopW PROTO LPCWSTR,DWORD,BOOL,ACCESS_MASK
OpenInputDesktop PROTO DWORD,BOOL,ACCESS_MASK
EnumDesktopsA PROTO HWINSTA,DESKTOPENUMPROCA,LPARAM
EnumDesktopsW PROTO HWINSTA,DESKTOPENUMPROCW,LPARAM
EnumDesktopWindows PROTO HDESK,WNDENUMPROC,LPARAM

The problem of course is you suffer exactly the same problem as C compilers, near extreme difficulty in getting the data sizes correct. If you really want C style typedef nesting and C data type specifications, use a real C compiler, CL.EXE from MS, GCC and a host of others, if you want to write in assembler without the strangulation of C strong typing, use a real assembler.  :biggrin: