News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

h2inc+

Started by Biterider, March 29, 2024, 10:45:35 PM

Previous topic - Next topic

Biterider

Hi sinsi
Thank you for your thoughts. 
In the beginning I had the same ideas, but based on the experience I gained with this project, I realised that a translator has to work a bit differently. This is because you don't have a preprocessor that 'simply' inserts or discards part of the code. The translator has to go through all possible PP code paths and arrange the code in a way that a MASM-compatible assembler can understand. One of the challenges we have is that the HL directives such as if, else, endif cannot be placed as flexibly as in C.

Nevertheless, it might be interesting to explore your idea further. Unfortunately, I don't know of any open source C compiler code that could be modified for our purposes.

The results of the current h2incX engine are actually very good (you can have a look here https://github.com/ObjAsm/ObjAsm-C.2/tree/master/Code/Inc/Windows). I have been using it for a long time without any problems in 32 and 64 bit.

The reason for a reworked engine is the amount of work needed to make small corrections afterwards. These are exactly the cases I wanted to show with some examples in the previous post.


Regards, Biterider

sinsi

Just a thought out of left field, but have you seen the Magic Number DataBase?
Parsing the Windows headers for constants, maybe it could be extended?

Biterider

Hi Sinsi
I solved the record problem and some others, but at the same time I introduced some regressions.
Maybe this weekend I can post a very first beta. The application is designed to selectively output protos, constants, structures/unions, etc. using some CL-switches. 
The implementation of this selectivity dfeature is not fully implemented yet, as I'm concentrating on the rendering atm.

Regards, Biterider


Biterider

Hi
I'm finishing the core functionality and leaving the "extern" declarations for the end. In the current state, the application can render most of the header files but has problems with this code:
extern "C" {
typedef BOOL (CALLBACK * ImageAbort)(VOID *);
typedef ImageAbort DrawImageAbort;
typedef ImageAbort GetThumbnailImageAbort;
}

Can anyone fluent in C explain what these lines do and what the MASM equivalent would be?

Biterider

TimoVJL

first declare callback function and next two with predefined names of them.
May the source be with you

Biterider

Hi Timo
Thanks for the quick replay  :thumbsup:
I'm a bit confused about the "typedef".
As far as I understand it, the first line defines a typedef to a proto and the 2 following lines uses this type to define 2 extern C functions.
Do you know how to translate it to MASM?

Biterider

fearless

At a guess, maybe could be written in masm something like this:

ImageAbort_Callback_Proto  TYPEDEF PROTO C VoidPtrParam:DWORD
ImageAbort_Callback        TYPEDEF PTR ImageAbort_Callback_Proto

.DATA

DrawImageAbort              ImageAbort_Callback 0
GetThumbnailImageAbort      ImageAbort_Callback 0

The DrawImageAbort and GetThumbnailImageAbort values can be assigned at runtime, before they are used and then can be used in Invoke's like:

Invoke GetThumbnailImageAbort, Addr hImageAbort
But its just a guess based on the code

Biterider

Hi fearless
Thanks for your hints.
I came now to the following translation

ImageAbort_Proto typedef proto C :ptr
ImageAbort typedef ptr ImageAbort_Proto
DrawImageAbort typedef ImageAbort
GetThumbnailImageAbort typedef ImageAbort

in the same header file I can now use the following translation
GdipGetImageThumbnail_ proto WIN_STD_CALL_CONV :ptr GpImage, :UINT, :UINT, :ptr ptr GpImage, :GetThumbnailImageAbort, :ptr VOIDwhich works fine.

In my opinion, the extern directive in C for a typedef is not relevant for masm.

Biterider