News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

include files

Started by Pokerice, December 11, 2014, 02:04:58 AM

Previous topic - Next topic

Pokerice

Hi guys, so i am a little confused on the include files. I thought they were only needed for their prototypes if you want to use invoke.
But whatever functions I am using from the libraries (like kernel32.lib or user32.lib) will give me the "undefined symbol error" whenever the include files are omitted.
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc


;include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
.code
start:
call ExitProcess      ; I also tried ExitProcessW and ExitProcessA but still doesn't work
end start

Could someone explain this?

jj2007

Your code chokes in the assembly phase because ML/JWasm don't know the symbol.

ExitProcess PROTO :DWORD
push 0
call ExitProcess

There are no ANSI or UNICODE versions - no strings passed. And it works definitely better with kernel32.lib ;-)

dedndave

include files may have all sorts of things in them
true enough, that Hutch has arranged them so that constants, structures, etc are all in windows.inc (and winextra.inc)
most of the others contain only prototypes

that's not always the case for other library packages

Pokerice

So does that mean you must have a prototype for a function before you can use it because the tutorial I am following states that you don't have to include files if you don't plan to invoke. Also, how come if I declare my own using proc, I can call it without prototyping?

dedndave

it doesn't need a prototype to be CALL'ed
it does need one to be INVOKE'd

even so, externals need to be defined, in some way
so - if not by PROTO, then by EXTERN or EXTERNDEF
externals meaning library or dll functions
this is one thing that is different for your own PROC's

better to use a PROTO and INVOKE if it has parameters
the assembler insures that you have the correct number and size of parameters

notice that for
    INVOKE  ExitProcess,0
the assembler actually generates
    push    0
    call    ExitProcess

Pokerice

thank you all especially dedndave, I understand now :biggrin:
So it is kind of like the declarations needed in the header files in c++?

dedndave