The MASM Forum Archive 2004 to 2012

Project Support Forums => GoAsm Assembler and Tools => Topic started by: pro3carp3 on July 04, 2006, 04:26:47 AM

Title: accessing the api
Post by: pro3carp3 on July 04, 2006, 04:26:47 AM
I'm trying out GoAsm and am having difficulty calling the windows api.  I have the following so far:

;HELLOWIN

#include F:\goasm\includea\windows.inc
#include F:\goasm\includea\all_api.inc


CONST SECTION
align 4

sAppName db "HelloWin",0
sWndClassName db "HelloWinClass",0


DATA SECTION
align 4

;INITIALIZED DATA

;UNINITIALIZED DATA
hApp dd ?
psCmdLine dd ?


CODE SECTION

Start:

;Get instance handle
push NULL
call GetModuleHandleA
mov [hApp], eax

; ;Get command line
; call GetCommandLine
; mov [psCmdLine], eax



push 0
call ExitProcess


The above assembles without errors.

Here's my command file:

test.obj
;/debug coff
gdi32.dll
kernel32.dll
user32.dll


Here's the error I get when I enter: golink @test.cmd

The system could not make the output file <test.exe>

Any ideas where I'm going wrong?  Thanks.
Title: Re: accessing the api
Post by: pro3carp3 on July 04, 2006, 01:31:41 PM
Well, I got up this morning with fresh eyes and realized I still had GetModuleHandleA instead of GetModuleHandle.  My original problem, I believe, was in getting the proper include files.  I think I got it working so far.
Title: Re: accessing the api
Post by: 1rDirEctoALgran0 on July 04, 2006, 05:42:35 PM
I have found no error...
Of course you must assemble like this :
goasm test.asm
See "test.zip"

Regards

[attachment deleted by admin]
Title: Re: accessing the api
Post by: jorgon on July 04, 2006, 08:32:59 PM
Hi pro3carp3

If GoLink reports:-

QuoteThe system could not make the output file <test.exe>

then this is because when GoLink asked the system to make the output file test.exe, it could not do so.
The usual reason for this is that test.exe is still open.
Probably you ran an earlier (wrongly coded) version of test.exe which had not exited properly.
On XP you can check this by using Crtl-Alt-Del and looking at the task manager to see if test.exe is still running.
When you got up the next morning presumably you tried again after a reboot of the system.  This would have closed all open files.

There is no problem calling the API GetModuleHandleA if you want.  This is what it is called in kernel32.dll.  If you specify GetModuleHandle instead of GetModuleHandleA, however, you will need the include file, as you have done.  Alternatively you could add the line GetModuleHandle=GetModuleHandleA (although there seems little point in this).

GoAsm does not recognise "NULL" which of course is really 0.
It is, however, defined in the include file as 0.  So if you really want to use NULL instead of 0, you must use the include file as you have done.  Alternatively you can add the line NULL=0 (although there seems little point in this).
Title: Re: accessing the api
Post by: pro3carp3 on July 12, 2006, 12:11:08 PM
Jorgon,

Thank you.  Your comments are very helpful, and I believe your analysis is correct.