I just started ASM but I have already started to catch on very easily. For the past 3 days I've been stuck on the MessageBox/MessageBoxA function. I cannot get a MessageBox no matter how hard I try. When using the code below, I receive this error at assembly, "error a2006: undefined symbol : MessageBox" & "error a2006: undefined symbol : ExitProcess." Someone told me it was because the WINAPI.inc include is for 16-bit systems only.
Here's what I have:
Here's what I have:
.586
.MODEL FLAT, STDCALL
OPTION а а а CASEMAP : NONE ; case sensitive
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
INCLUDE WINAPI.inc
INCLUDELIB а а KERNEL32.lib
INCLUDELIB а а USER32.lib
INCLUDELIB GDI32.lib
INCLUDELIB MSVCRT.lib
;MSVCRT functions
_ftol а а а PROTO C: VARARG
_CIpow а а аPROTO C: VARARG ; X^Y
_itoa а а а PROTO C: VARARG
time а а а аPROTO C: VARARG
malloc а а аPROTO C: VARARG
difftime а аPROTO C: VARARG
free а а а аPROTO C: VARARG
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.DATA?
buffer DB 0ffh DUP (?)
angle_buff DB 0ffh DUP (?)
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.DATA
INCLUDE Data1.asm
INCLUDE Data2.asm
wc а= 1
th а= 0
showmore db 0 ;Show extra information? 1 = Yes, 0 = No
server db wc
key а а db 0ffh
angle а dd 0
angle2 а dd 0
power dd 0
angle_str а а db "w.p.: %.2i",0
angle_str2 а db "w.с.: %.3i",0
power_str а db "p: %.3i",0
MsgCap а а аdb "Test Caption",0
MsgTxt а а аdb "Testing... 1, 2, 3...",0
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.CODE
аStart:
invoke MessageBox, NULL, addr MsgTxt, addr MsgCap, MB_OK
invoke ExitProcess, NULL
а
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
END Start
Open win32.hlp find MessageBox and click on the button named "Quick Info" this will show you in which DLL the MessageBox function resides - which then you need to include.
Download hutch's masm32 and use his windows.inc and you would not encounter such problems.
Does WINAPI.inc include the declaration any API function? It seems to me it's like hutch's windows.inc, only contains constants and structure definitions. Try including kernel32.inc and user32.inc from the masm32 package. :)
Does WINAPI.inc include the declaration any API function? It seems to me it's like hutch's windows.inc, only contains constants and structure definitions. Try including kernel32.inc and user32.inc from the masm32 package. :)
I just looked at the 2 files (WINAPI.inc & WINDOWS.inc) and there are some functions in WINAPI.inc that are required for the program to run that aren't in WINDOWS.inc but when I try to include both of them I receive this error:
Assembling: C:\program.asm...
C:\Documents and Settings\Administrator\Desktop\SU1.0\Source\WINDOWS.inc(73) : error A2111: conflicting parameter definition
C:\Documents and Settings\Administrator\Desktop\SU1.0\Source\WINDOWS.inc(7916) : error A2008: syntax error : offset
C:\Documents and Settings\Administrator\Desktop\SU1.0\Source\program.asm(32) : error A2008: syntax error : in directive
C:\Documents and Settings\Administrator\Desktop\SU1.0\Source\program.asm(99) : error A2006: undefined symbol : MessageBox
C:\Documents and Settings\Administrator\Desktop\SU1.0\Source\program.asm(100) : error A2006: undefined symbol : ExitProcess
C:\Documents and Settings\Administrator\Desktop\SU1.0\Source\program.asm(108) : error A2006: undefined symbol : ExitProcess
I think you have to include either windows.inc or winapi.inc.
The windows.inc file is part of the masm32 package, and only has constants and structures. To declare functions you must use additional include files, also part of the package, one for each dll: user32.inc, kernel32.inc, etc.
I don't know where does winapi.inc come from, or what it contains, so I can't help you use it. :(
The windows.inc file is part of the masm32 package, and only has constants and structures. To declare functions you must use additional include files, also part of the package, one for each dll: user32.inc, kernel32.inc, etc.
I don't know where does winapi.inc come from, or what it contains, so I can't help you use it. :(
Nevermind I FINALLY figured it out, wow.
Here's what I did:
Here's what I did:
.586
.MODEL FLAT, STDCALL
OPTION CASEMAP : NONE ; case sensitive
MessageBoxA PROTO :DWORD, :DWORD, :DWORD, :DWORD
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
INCLUDE WINAPI.inc
INCLUDELIB KERNEL32.lib
INCLUDELIB USER32.lib
INCLUDELIB GDI32.lib
INCLUDELIB MSVCRT.lib
;MSVCRT functions
_ftol PROTO C: VARARG
_CIpow PROTO C: VARARG ; X^Y
_itoa PROTO C: VARARG
time PROTO C: VARARG
malloc PROTO C: VARARG
difftime PROTO C: VARARG
free PROTO C: VARARG
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.DATA?
buffer DB 0ffh DUP (?)
angle_buff DB 0ffh DUP (?)
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.const
NULL equ 0
MB_OK equ 0
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.DATA
.Data
MsgBoxCaption db "Caption",0
MsgBoxText db "Test",0
INCLUDE Data1.asm
INCLUDE Data2.asm
wc = 1
th = 0
showmore db 0 ;Show extra information? 1 = Yes, 0 = No
server db wc
key db 0ffh
angle dd 0
angle2 dd 0
power dd 0
angle_str db "wp: %.2i",0
angle_str2 db "wс: %.3i",0
power_str db "pr: %.3i",0
MsgCap db "Test Caption",0
MsgTxt db "Testing... 1, 2, 3...",0
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.CODE
Start:
INVOKE MessageBoxA, NULL, ADDR MsgBoxText, ADDR MsgBoxCaption, MB_OK
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
END Start
Now you can do the same for ExitProcess:
Still I'd recommend you to use hutch's include files, so you don't have to do the same for each and every API you want to call... :shock:
.586
.MODEL FLAT, STDCALL
OPTION CASEMAP : NONE ; case sensitive
MessageBoxA PROTO :DWORD, :DWORD, :DWORD, :DWORD
ExitProcess PROTO :DWORD
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
INCLUDE WINAPI.inc
INCLUDELIB KERNEL32.lib
INCLUDELIB USER32.lib
INCLUDELIB GDI32.lib
INCLUDELIB MSVCRT.lib
;MSVCRT functions
_ftol PROTO C: VARARG
_CIpow PROTO C: VARARG ; X^Y
_itoa PROTO C: VARARG
time PROTO C: VARARG
malloc PROTO C: VARARG
difftime PROTO C: VARARG
free PROTO C: VARARG
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.DATA?
buffer DB 0ffh DUP (?)
angle_buff DB 0ffh DUP (?)
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.const
NULL equ 0
MB_OK equ 0
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.DATA
.Data
MsgBoxCaption db "Caption",0
MsgBoxText db "Test",0
INCLUDE Data1.asm
INCLUDE Data2.asm
wc = 1
th = 0
showmore db 0 ;Show extra information? 1 = Yes, 0 = No
server db wc
key db 0ffh
angle dd 0
angle2 dd 0
power dd 0
angle_str db "wp: %.2i",0
angle_str2 db "wс: %.3i",0
power_str db "pr: %.3i",0
MsgCap db "Test Caption",0
MsgTxt db "Testing... 1, 2, 3...",0
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
.CODE
Start:
INVOKE MessageBoxA, NULL, ADDR MsgBoxText, ADDR MsgBoxCaption, MB_OK
INVOKE ExitProcess, 0
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
END Start
Still I'd recommend you to use hutch's include files, so you don't have to do the same for each and every API you want to call... :shock:
I have to agree with QvasiModo 8)
What the,........sigh