Structures ..
C-Like Structures
Some bad Assemblers have a 'STRUCT' KeyWord performing hidden Declarations and Substitutions. This feature is particularly bad and incompatible with assembly. It has only inconvenience and no advantages. When one writes, with these Assemblers, something like:
POINT STRUCT
x DWORD ?
y DWORD ?
POINT ENDS
; ...
LOCAL Ps :POINT
; ...
mov eax, Ps.x
MyPoint <POINT>
mov ebx MyPoint.y
What is effectively done by the Assembler would be expressed, in RosAsm syntax, by something like this:
[X = 0 Y = 4]
Local @Point 8
mov eax D@Point+X
[MyPoint: D$ ? #2]
mov ebx D$MyPoint+Y
This is to say that this 'STRUCT' KeyWord performs a hidden Declaration of 'Displacement Equates', and that the '.x' formulation is unfolded as an added Displacement from the given Base.
This feature is very bad because the real symbols appear nowhere in your Source. No Search or Debug feature can point out, in your Sources, Declarations that do not exist. For Win32 Structures, compared to the way RosAsm gives you all of this by the [Struct] Dialog, there is no advantage. For your own private Structures, there is no advantage either as you have, in all cases, to declare these Structures by yourself, by hand.
As long as C-Like Structures Declarations are nothing but hidden Equates sets Declarations, there is no reason, in Assembler for not declaring them for what they are, instead of writing risky, unreadable and difficult to debug Code. Several users, with a previous experience with bad Assemblers, have asked me for having this 'Missing Feature' available. My answer has always been 'no' and will always be 'no', even at the cost of having users leaving and giving up on RosAsm. ( This has already happened several times ).
The [Struct] Dialog
The [Struct] menu item opens a Dialog for helping at Win32 Structures programming. You will retreive, in the ClipBoard, the selected Structure. The four top-Right Radio-Buttons define the way the items names are formatted.
The three downward left CheckButtons provide 3 different forms for the Structures: The common one (Data), another one written in Equates format (useful to point to Tables given in return by Win Notify messages-), and a last one, useful when you wish to declare a Structure (and the pointers to the data you wish to access) on the Stack (Example:
Structure @PAINTSTRUCT 64 , @hdc 0, ......
In that last case, avoid keeping all the symbols you don't use, to save RosAsm compiling task running for nop on Equates job.
And do never forget that, when writing such stack reservations by hand (for example because of a missing Structure in the integrated List), you *have* to align the Structures whole size on dWord Boundary. The Stack MUST remain aligned. Several Win Structures sizes are not aligned. The Structure given to you by the [Struc] Dialog are always properly size aligned.
The [Data to Equates] Dialog
One another Dialog is available in the [Tools] PopUp Menu. As, for you, writing the Structures under Data form is easier than calculating the relative displacements of each Member in a Structure (this may be a real pain with big and complex Sets), the purpose of this Dialog is to make this translation easy. The Left Edit Control receives you Data version input, and the right Edit Control gives you the Structure Equates translation.
When using this feature, it is a good idea to keep the Data version in your Source (in a Multi-Lines Comment -;;-), in order to not re-enter all of your Data each time you have to modify them.
Missing Structures
The available Structures in Structures.str Data File are only the basic ones of Win32. This simple set of Data is, in fact, a demential amount of work, done by a lot of programmers. So, I first thought of writing a set of tools to try to directly translate *.inc C Files into Asm syntax. Despite my efforts, I have been unable to implement this work for several reasons:
The first one is, of course that building these tools is a huge work, due to the weird and irregular syntaxes of all C files that might be found here and there. The fact that nobody ever did these translations tools, is not only because of the lack of volunteers. The method to try to understand what is a C Structure Declaration is yet to be found...
The second one is that, really coming over with it, would require learning C. I first wanted to do it, but as, on one hand, I hate C over all, and as, on the other hand, it is more and more evident to me that I cannot do everything by myself, I leave it open for others to implement.
Until ReactOS is available for public use, we will not have enough volunteers to do the job.
Until ReactOS is available for public use, we will not know with which C syntax we have to deal with, and as with one single C, the translation tools are almost impossible to write, with various C's it becomes absolutely impossible.
Note: I write 'tools', and not 'tool' because, after many weeks wasted at this, it now seems to me impossible to translate in one single pass, without any hand work between the various jobs' routines.
Waiting for better times, this is to say for the oncoming of a Asm volunteer programmer who will perfectly understand C and who will want to write the translation tools, if you are in need of alien Structures, the 'simpler' (!!!) way... is to do it by hand. As the amount of work to be done is widely out of human scale, if you perform such translations, think of forwarding them back to me (even if very partial) so that I can prepare future public releases of these Data under Asm form Files.
A partial translation for DirectX is available inside the Dx Demo available at my page.
~~~~~~~