News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

question about include files

Started by RaZiel, October 07, 2008, 05:00:21 PM

Previous topic - Next topic

RaZiel

hi :) I'm new to this forum, so I feel obliged to post my first noob questions. Let me state a few things first to ease the replying;

Not new to programming. Got my background from coding in Delphi for quite some years now. Started doing some inline asm coding to optimize my routines. Which spurred my interest in asm. So my next step is to compile dll files made in masm to add to my projects in delphi. Ok, over to the questions.

I looked at an asm file stating: "include \masm32\include\w2k\ntstatus.inc". Wanted to compile it. Fine, the file didn't exist. It was mentioned it was to be found in the Windows DDK. Installed it. All I found was header files.
Now, I'm used to .pas files in Delphi for definitions, declarations, constants, and other identifiers. All in one place. I know C++ headers are used for the same purpose, been translating them to Delphi in the past.
I saw both .h and .inc files in the DDK, and got confused. So I got an ocean with questions. Are there any differences between them?
How to port them to masm compatible .inc files, or are the C++ header files compatible in masm? If not, is there a tool that converts from C++ syntax to masm? There are just a couple of inc files in Delphi, never really looked into them.
Comparing .inc files belonging to the 3 different compilers didn't help me much. Is there a general purpose or definition of a .inc file?

While I'm at it, what are lib files, and how do they relate to inc files? I opened a few in the DDK and masm, and saw both starting with the same starting file identifier "!<arch>". So I guess they're compatible. Correct me if I'm wrong.
I saw there was a bldlibs.bat in the "masm32\include" folder. Why use both if libs are built out of inc files? Like why use both "include \masm32\include\w2k\ntoskrnl.inc" and "includelib \masm32\lib\w2k\ntoskrnl.lib".

Got a few more questions, but I think I'll stop here :P
ps. thanks for reading all this.

fearless

Quote from: RaZiel on October 07, 2008, 05:00:21 PM
Now, I'm used to .pas files in Delphi for definitions, declarations, constants, and other identifiers. All in one place. I know C++ headers are used for the same purpose, been translating them to Delphi in the past.
I saw both .h and .inc files in the DDK, and got confused. So I got an ocean with questions. Are there any differences between them?

As you correctly pointed out .h files are similar in practise to your .pas files and so the .inc files are similar for MASM in this context. They all contain function declarations, constants etc, but in their own syntax.

Quote from: RaZiel on October 07, 2008, 05:00:21 PM
How to port them to masm compatible .inc files, or are the C++ header files compatible in masm? If not, is there a tool that converts from C++ syntax to masm? There are just a couple of inc files in Delphi, never really looked into them.
Comparing .inc files belonging to the 3 different compilers didn't help me much. Is there a general purpose or definition of a .inc file?

MASM32 package comes with the include files and libraries for the Win32 api's, so no need to convert .h files. Although granted there are exceptions and times when one would want to convert a .h file to a .inc - take a look at h2inc which is included with the package.

Quote from: RaZiel on October 07, 2008, 05:00:21 PMWhile I'm at it, what are lib files, and how do they relate to inc files? I opened a few in the DDK and masm, and saw both starting with the same starting file identifier "!<arch>". So I guess they're compatible. Correct me if I'm wrong.
I saw there was a bldlibs.bat in the "masm32\include" folder. Why use both if libs are built out of inc files? Like why use both "include \masm32\include\w2k\ntoskrnl.inc" and "includelib \masm32\lib\w2k\ntoskrnl.lib".

The include files are as stated above, the libraries or .lib files contain the object code for the functions you call, or with the win32 api function libs (which is what the MASM32 package contains), the functions are placeholders for the calls to be forwarded to the dynamic link library that actually contains the working function and object code.

Hope that helps, im sure others can clarify the points further and probably better than i can ;-)
Ć’earless

RaZiel

It helped a lot. Thank you, fearless  :) Tried googling for answers, but no clear information came up. You saved me a lot of time.

Tried h2inc and the translator posted on this forum. Using inc2l didn't result in any easy solution. I'm just not familiar with this yet.
But I found a post with KmdKit which had what I needed.

I'm sure this has been answered before, but I'll give it a go since it's the same post. How can I figure out what physical memory address a process is located? Granted that I'm not even sure if a process has a certain range set for
it's variables and etc. or are they scattered at random addresses in memory?
Which indicates I'm not experienced in working with debuggers. Is there any debugger that someone could recommend? Or give me a hint on where to start? For example when I get a "The application failed to initialize properly (0xc0000005)" error, I have no clue where in the code it's caused.

Thanks again :)

jj2007

Olly is a good free debugger that integrates neatly with Masm32.

By the way, there are lots of libraries included in the Masm32 package. The snippet below is a complete Masm32 program... and \masm32\include\masm32rt.inc is definitely worth checking.

include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start