News:

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

accessing the api

Started by pro3carp3, July 04, 2006, 04:26:47 AM

Previous topic - Next topic

pro3carp3

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.
LGC

pro3carp3

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.
LGC

1rDirEctoALgran0

I have found no error...
Of course you must assemble like this :
goasm test.asm
See "test.zip"

Regards

[attachment deleted by admin]

jorgon

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).
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

pro3carp3

Jorgon,

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