A Translator for SDK header files

Started by ToutEnMasm, August 08, 2006, 08:55:36 AM

Previous topic - Next topic

ToutEnMasm

Hello,
This version has been tested on all the SDK 7.1,winddk and directx header files .
The translator is at an end in his writing.The translated files can be used now without windows.inc.
just include translate.inc , before windows.sdk.
All Prototypes (API and interface) used the standard notation of masm .You have just to follow the SDK help files,usage is the same.

http://www.masm32.com/board/index.php?topic=6182.msg46002#msg46002

The translation need a very few changes to use what is translate.UNICODE is supported.
Are translated,constants,structures,enums,Interfaces ,prototypes and the most common GUID.A comment (;API) is added before the prototypes to find them quickly(all prototypes are not API).The readme file in the zip say you more.
The translation is in the same maners as windows.inc,a few number of typedef are used.
This grant you the more simple syntax as possible ,and none hard search .
For win64 compilers,see egales.txt  and reverse the _w64 and win64 order.
********************************************************************
This version have made the windows.sdk downloadable on my site
Problem at link solved,Some prototypes have the same name in interfaces and/or are duplicate.
This provide a "error LNK2001: unresolved external symbol"
The title INTERFACE_API_CONFLIT_NOM added in egales.txt is here to solve this
All is ready to translate the ddk or the directx sdk

********************************************************************
Before translate anything,have a look at the full set of SDK header files translated
http://www.masm32.com/board/index.php?topic=8542.msg62123#msg62123     
VC++ 2008 header's file translated ( CRT )
http://www.masm32.com/board/index.php?topic=11617.0
==============================================================               
Trying to reuse various c++ project code,you can find than
there prototypes are written in a decorated form without prompt.
The following tool made the needed corrections.
http://www.masm32.com/board/index.php?topic=17077.0
Some names of functions can be incompatibles with masm.
Best way to solve this,is to made a dynamic load of this functions.
You can used this tool to do it.
http://www.masm32.com/board/index.php?topic=17120.0

Searching in the sdkrc7:
Open sdkrc7\liste.txt
This file contain the names of functions,structures,interfaces,defined dword ... translated from the windows sdk.
You can search one of those names  (search edit box ).
When you have find it ,go UP in the text file and you find the name of his header file .h
Open the .sdk and you have all  the declarations needed.



[attachment deleted by admin]

raneti

Good job, thats what i tought of when i encountered the .inc files. :U
Let MS update them and let them be translated automatically for us.

ToutEnMasm

#2
Hello,
The missing piece of the translator,is achieve.
COM interfaces are all translate (except one)

using them
If you want to use NameInterface,all you have to do is:
1) create a data named ppvNameInterface,to put in the pointer on the interface.
2) Call the API that give you the pointer on it.
3) Use the macro NameInterface instead of invoke
   and use the functions of the interface as they were API
   sample:
   ISecurityInformation Release

All prototypes are translated as comethod(N) ?
                Why This: Push byte,don't exist.
                             Push word misalign the stack(n*Two push are needed)
   How it is possible ?

Pushing byte ,word qword and real8
   
   invoke push only DWORD in stack,even if it is a byte or a word
   following is a list samples on how invoke work.
   Best method is to push a byte in a dword,bits are filled with zeros
   Qword and real8 are cutted in two dword
   
   
   invoke Parametre,petit ;with ,petit BYTE ,Parametre PROTO :BYTE
            ------- listing ----------
   mov    al, petit
   push   eax         
   call   Parametre
   ;-----------------------------------------
   invoke Parametre,moyen   ;moyen word    Parametre PROTO :WORD
            ------- listing ----------
   sub    esp, 002h      ;word undefined
   push   moyen
   call   Parametre   
   ;------------------------------------------------
   invoke Parametre,moyen   ;moyen word    Parametre PROTO :DWORD
            ------- listing ----------
   push   000h         ;word NULL in stack
   push   moyen      ;
   call   Parametre   
   ;------------------------------------------------
   invoke Parametre,petit   ;petit byte    Parametre PROTO :DWORD
            ------- listing ----------   
        push   000h         ;word NULL in stack
   mov    al, petit      ;translate byte in word
   movzx  ax, al      
   push   ax         ;=DWORD in stack   or movzx eax,al follow by push eax
   call   Parametre      
   ;----------------------------------------------------------------

What append when the translator failed to find the size of a variable ?
   In this case,the translator add the name of the variable in the line
   He try is chance assuming it is a dword (95/100)
   Look at the named variable and if it is a qword or a real8
      add one to the comethod and delet the name


In the package you find header_COM_place.txt who give you the name of the headers containing
   Interfaces and how many they are (about 4000)
                                   
                                              ToutEnMasm

                   
                                           



Vortex

Salut ToutEnMasm,

Thanks for this new tool, I will try it :U

gabor

Hello ToutEnMasm!

(is this a french name? :) )
Since I am really interested in creating translaters, I would like to ask you how you coded it?
What was your concept? I don't want to have a look on your code, I'd just like to understand your idea behind it!

Thanks and Greets, Gábor

ToutEnMasm

Hello,
ToutEnMasm mean All In Masm

Concepts and methods couldn't be separated.
For concepts I follow what is currently in use .For constants,enums and structures I follow the windows.inc file.For Interfaces I don't follow the com lib of masm32 ,but I have pick up what is best in it.Comethod is the same but the Macro is modified  to make things more simples.
The real concept is to normalize the differents names that are needed (the easy call of com Interface is a sample of this) .Making that , you can ask the computer something he can do,the hard labor that is repeated and repeated.
At each time you find a piece of code that can be used an other time with littles modifieds, you gain something.
Methods are made with all that MASM can offer.Proc,library,Macros...I don't use many pointers,only lines numbers.Like that I can go read text in any order and return to the previous position without add too many bugs.

                                            ToutEnMasm



dancho

@ToutEnMasm,
thx for great tool... :clap:

hutch--

Yves,

I have been a bit slow because I have had a lot to do but I downloaded the tool and it does not seem to like my win2000 sp4. I get this error message when I start headinc.exe  ..

Quote
The procedure entry point AddVectoredExceptionhandler could not be located in the dynamic link library KERNEL32.dll

Any chance of tweaking it so it runs on win2000 ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm


Hello,
Sorry for the mistake.It is my debugging routine that was not uninstalled very well.
I could not make something without it.
I have corrected this thing in the new download.
                                           ToutEnMasm

ToutEnMasm

Hello,
Many changes has been made to have this:
100% of the structures of the sdk are translated
100% of the prototypes API are translated
added features of the menu files to view some useful files.

API prototype us the standard notation of masm to pass structures by values
see http://www.masm32.com/board/index.php?topic=6182.msg46002#msg46002

This version is near a goal,replace the old windows.inc by a windows.sdk.
A few work is needed to have it,use translate.inc before the translated headers.

azdps

Nice work on your translator ToutEnMasm. I have just tested it on windows include file devguid.h. Can you tell me why the translator translates the following from:

DEFINE_GUID( GUID_DEVCLASS_1394,                0x6bdd1fc1L, 0x810f, 0x11d0, 0xbe, 0xc7, 0x08, 0x00, 0x2b, 0xe2, 0x09, 0x2f );
DEFINE_GUID( GUID_DEVCLASS_1394DEBUG,           0x66f250d6L, 0x7801, 0x4a64, 0xb1, 0x39, 0xee, 0xa8, 0x0a, 0x45, 0x0b, 0x24 );

to:

sGUID_DEVCLASS_1394         TEXTEQU  <{06bdd1fc1h,0810fh,011d0h,{0beh,0c7h,008h,000h,02bh,0e2h,009h,02fh}}>
sGUID_DEVCLASS_1394DEBUG    TEXTEQU  <{066f250d6h,07801h,04a64h,{0b1h,039h,0eeh,0a8h,00ah,045h,00bh,024h}}>

For instance, why is GUID_DEVCLASS_1394 translated to sGUID_DEVCLASS_1394. Why is there a leading s in front?

ToutEnMasm

Hello,

It's because you have to use it as follow in your source code
Quote
.data
GUID_DEVCLASS_1394 GUID sGUID_DEVCLASS_1394

This work also with all the translated GUID

azdps

wouldn't it be better to have it defined without the s in front. personally i think it would be better if you did not tamper with the defined name. i think the coder should do that within his/her own code.

for example if the msdn says i need to use GUID_DEVCLASS_1394 i would like to know that all i have to do is put it in my code and name it how i want. such as DEVCLASS_1394 GUID GUID_DEVCLASS_1394. makes more sense to me. otherwise i would need to know how you defined it in the include file and work from there. personally i think it would be an extra step when coding.

ToutEnMasm


Masm as rules for writing code and
Quote
DEVCLASS_1394 GUID GUID_DEVCLASS_1394 ;couldn't work

azdps

for example in my current project i use:

GUID_DEVINTERFACE_DISK  TEXTEQU  <{053f56307h,0b6bfh,011d0h,{094h,0f2h,000h,0a0h,0c9h,01eh,0fbh,08bh}}>
DISK_GUID    GUID    GUID_DEVINTERFACE_DISK

I use DISK_GUID in a fuction and it works well.