Author Topic: A translator for sdk header files (64 and 32 bits translate)  (Read 27907 times)

LiaoMi

  • Member
  • ****
  • Posts: 891
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #60 on: July 11, 2021, 09:40:02 PM »
Hi TouEnMasm,

thanks, updated successfully, testing is in progress  :thup:

LiaoMi

  • Member
  • ****
  • Posts: 891
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #61 on: July 13, 2021, 09:01:27 PM »
Hi TouEnMasm,

in the previous version, the "Security" example was compiled without problems, in this version an error "Error A2080: Block nesting error: if-else" occurs.
Code: [Select]
Translated Windows SDK 10.0.19041.0 32 bits
ZUT
HIMAGELIST defined
security.asm : Error A2080: Block nesting error: if-else
security.asm: 261 lines, 1 passes, 1255 ms, 0 warnings, 1 errors

Code: [Select]
        include translate32.inc
        include windows.inc
        include WinUser.inc
        include ShlObj.inc
        include WinBase.inc
        include stdio.inc
        include sysinfoapi.inc
        include timezoneapi.inc
       
        includelib ntdll.lib
        includelib ntdllp.lib
       
        includelib kernel32.Lib
        includelib User32.Lib
        includelib ntoskrnl.lib
        includelib Advapi32.lib
       
        includelib ucrt.lib
include stdio.inc
include conio.inc

include accCtrl.inc
include aclapi.inc
includelib crt10_32.lib

_getch
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getch-getwch?view=msvc-160
Syntax C
int _getch( void );
wint_t _getwch( void );

Is this the correct conversion?
_getch PROTO cproto void:DWORD

it was like
_getch PROTO

No prototypes are added here from
include stdio.inc

security.asm(228) : Error A2160: INVOKE requires prototype for procedure <- printf in stdio.inc
Code: [Select]
Translated Windows SDK 10.0.19041.0 32 bits
ZUT
HIMAGELIST defined
security.asm(228) : Error A2160: INVOKE requires prototype for procedure
security.asm(256) : Error A2147: Too few arguments to INVOKE: _getch
security.asm : Error A2080: Block nesting error: if-else
security.asm: 261 lines, 1 passes, 843 ms, 0 warnings, 3 errors

I have already written above, I added the prototypes by hand, therefore the error is not visible there.
printf PROTO cproto _Format:XMASM, :VARARG
_getch PROTO cproto void:DWORD

TouEnMasm

  • Member
  • *****
  • Posts: 1733
    • EditMasm
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #62 on: July 14, 2021, 03:24:16 AM »
It's the new method in use who have re-make the problem.
the void:DWORD must be replace by nothing
I have modified headinc in the translatrorUS download.
Fa is a musical note to play with CL

TouEnMasm

  • Member
  • *****
  • Posts: 1733
    • EditMasm
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #63 on: July 16, 2021, 03:26:45 AM »
corrected also the sdkrc100_KIT_10.0.19041.0.7z
http://luce.yves.pagesperso-orange.fr/sdkrc100_KIT_10.0.19041.0.7z
Fa is a musical note to play with CL

LiaoMi

  • Member
  • ****
  • Posts: 891
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #64 on: July 18, 2021, 04:28:27 AM »
Hi TouEnMasm,

to carry out quality control I used the program - Compare It! 4.2 Unicode - https://www.grigsoft.com/files.htm, Portable - https://www.grigsoft.com/wincmp4u.zip

Here is a ready-made comparison of the old version and the new one - https://gofile.io/d/6ZzwUh

What is CPROTO? What does co-writing mean? - YourProc PROTO CPROTO

YourProc PROTO C arg1:DWORD,arg2:DWORD,extra_args:VARARG
YourProc PROTO CPROTO arg1:DWORD,arg2:DWORD,extra_args:VARARG

   ····_vcscanf_l PROTO·cproto _Format:XMASM ,_Locale:XMASM ,_ArgList:XMASM   43   _vcscanf_l PROTO _Format:XMASM ,_Locale:XMASM ,_ArgList:XMASM
44   ····_vcscanf PROTO·cproto _Format:XMASM ,_ArgList:XMASM   44   _vcscanf PROTO _Format:XMASM ,_ArgList:XMASM
45   ····_vcscanf_s_l PROTO·cproto _Format:XMASM ,_Locale:XMASM ,_ArgList:XMASM   45   _vcscanf_s_l PROTO _Format:XMASM ,_Locale:XMASM ,_ArgList:XMASM
46   ····_vcscanf_s PROTO·cproto _Format:XMASM ,_ArgList:XMASM   46   _vcscanf_s PROTO _Format:XMASM ,_ArgList:XMASM

TouEnMasm

  • Member
  • *****
  • Posts: 1733
    • EditMasm
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #65 on: July 18, 2021, 05:01:54 PM »
Cproto is defined in the translate(XX).inc
in 32 ,   cproto equ <C> ,   stdproto equ <stdcall>       
in 64    ,    cproto equ <fastcall> , stdproto equ <fastcall>

The use of the constant cproto allow to change the type of call  of  the proto
in the crt ,all pprototypes are c prototypes with a variant in the name.
The various names for a same call don't help the translation.
It's for that i have added a DEFINE_PROTO section in egales.txt to allow the user to modify the type all call.
It is those two lines:
cproto,__cdecl,__CRTDECL,U_EXPORT2,LDAPAPI,STDMAPIINITCALLTYPE,MI_MAIN_CALL,WINAPIV,RPC_VAR_ENTRY
stdproto,__stdcall,CALLBACK,WINAPI,APIPRIVATE,PASCAL, __RPC_API,__RPC_USER,__RPC_STUB,RPC_ENTRY
When an another is found there is just to add this one in one of the two lines and the translate is modify.
 


Fa is a musical note to play with CL

LiaoMi

  • Member
  • ****
  • Posts: 891
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #66 on: July 18, 2021, 10:30:55 PM »
Hi TouEnMasm,

 thanks for the clarification :thup:

A couple more questions, there is an example:
Code: [Select]
typedef long  Test_LONG64a;
typedef unsigned long  Test_LONG64b;
typedef long long int  Test_LONG64c;
typedef unsigned long long int  Test_LONG64d;
typedef __int64  Test_LONG64e;
typedef unsigned __int64  Test_LONG64f;

                                                         
#if Test_SIZEOF_LONG == ( 64 / Test_CHAR_BIT )

#define Test_LONG64
#define Test_INT64   long
#define Test_UINT64  unsigned long

#elif !defined( __STDC__ ) || defined( Test_CONFIG_OPTION_FORCE_INT64 )

#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L

#define Test_LONG64
#define Test_INT64   long long int
#define Test_UINT64  unsigned long long int


#elif defined( _MSC_VER ) && _MSC_VER >= 900

#define Test_LONG64
#define Test_INT64   __int64
#define Test_UINT64  unsigned __int64

#elif defined( __BORLANDC__ )

#define Test_LONG64
#define Test_INT64   __int64
#define Test_UINT64  unsigned __int64

#elif defined( __WATCOMC__ )

#elif defined( __MWERKS__ )

#define Test_LONG64
#define Test_INT64   long long int
#define Test_UINT64  unsigned long long int

#elif defined( __GNUC__ )

#define Test_LONG64
#define Test_INT64   long long int
#define Test_UINT64  unsigned long long int

#endif

#endif

#ifdef Test_LONG64
  typedef Test_INT64   Test_Int64;
  typedef Test_UINT64  Test_UInt64;
#endif

translated as

Code: [Select]
Test_LONG64a TYPEDEF DWORD

Test_LONG64b TYPEDEF DWORD

Test_LONG64c TYPEDEF DWORD

Test_LONG64d TYPEDEF DWORD

Test_LONG64e TYPEDEF QWORD

Test_LONG64f TYPEDEF QWORD

IF  Test_SIZEOF_LONG EQ (64 / Test_CHAR_BIT)
Test_LONG64 equ
Test_INT64 equ < long>
Test_UINT64 equ < unsigned long>
ELSEIF  NOTDEFINED( __STDC__ ) OR DEFINED( Test_CONFIG_OPTION_FORCE_INT64 )
IF DEFINED( __STDC_VERSION__ ) AND  __STDC_VERSION__ GE 199901
Test_LONG64 equ
Test_INT64 equ < long long int>
Test_UINT64 equ < unsigned long long int>
ELSEIF DEFINED( _MSC_VER ) AND  _MSC_VER GE 900
Test_LONG64 equ
Test_INT64 equ < __int64>
Test_UINT64 equ < unsigned __int64>
ELSEIF DEFINED( __BORLANDC__ )
Test_LONG64 equ
Test_INT64 equ < __int64>
Test_UINT64 equ < unsigned __int64>
ELSEIF DEFINED( __WATCOMC__ )
ELSEIF DEFINED( __MWERKS__ )
Test_LONG64 equ
Test_INT64 equ < long long int>
Test_UINT64 equ < unsigned long long int>
ELSEIF DEFINED( __GNUC__ )
Test_LONG64 equ
Test_INT64 equ < long long int>
Test_UINT64 equ < unsigned long long int>
ENDIF
ENDIF
IFDEF Test_LONG64
Test_Int64 TYPEDEF Test_INT64

Test_UInt64 TYPEDEF Test_UINT64

ENDIF

long long int and unsigned long long int have wrong values - DWORD
typedef long long int  Test_LONG64c;
typedef unsigned long long int  Test_LONG64d;

long long   8   none (but equivalent to __int64)   -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
unsigned long long   8   none (but equivalent to unsigned __int64)   0 to 18,446,744,073,709,551,615

Specifier(s)         Type
-------------    -------------
long long int    long long int
long long        long long int
long int         long int
long             long int

Next flaw (see further examples above  :arrow_up:)

Code: [Select]
#define Test_INT64
#define Test_INT64   long
#define Test_UINT64  unsigned long

translated as

Code: [Select]
Test_LONG64 equ
Test_INT64 equ < long>
Test_UINT64 equ < unsigned long>

but it should be

Code: [Select]
Test_LONG64 equ 1; TRUE
Test_INT64 equ DWORD
Test_UINT64 equ   DWORD

or

Code: [Select]
Test_LONG64 equ
Test_INT64 equ < long long int>
Test_UINT64 equ < unsigned long long int>

but it should be

Code: [Select]
Test_LONG64 equ 1
Test_INT64 equ QWORD
Test_UINT64 equ QWORD

it does not take into account the definition of a variable via #define  :tongue:

TouEnMasm

  • Member
  • *****
  • Posts: 1733
    • EditMasm
Re: A translator for sdk header files (64 and 32 bits translate)
« Reply #67 on: July 19, 2021, 12:10:54 AM »
The translator as been made for the windows sdk header (not too many old ) and i see that those you show aren't.
__BORLANDC__ isn't one of those and there is syntax in the header you show who aren't Visual C,C++ header.
The translator couldn't translate any c headers,only those of  the visual c,c++ microsoft.
He couldn't be use also on the header of the project without corrections,they don't follow the same rules.
He could be use only on the sdk header.
After you can also made a census on the triple words used as variable, I will get it and made a correction.
They are very few for evident reasons (headinc know the long long and the double long used in the sdk).
Can you tell me what is a int char double ? (he can exist somewhere !).
A unique chance to translate that is to put it in a c code.

The SDK more often use typedef to define variables not define.




Fa is a musical note to play with CL