flat assembler
Message board for the users of flat assembler.

Index > Windows > Unrolling FASM code

Author
Thread Post new topic Reply to topic
casey



Joined: 18 Aug 2005
Posts: 35
casey
Hi all,

I am trying to unroll FASM code:


; invoke GetModuleHandle, NULL

push 0
call GetModuleHandle

Although it compiled ok it would not run,

SimpleWindow2.EXE - Application Error
(X) The instruction at "0x00403060" referenced
memory at "0xcaa97c70". The memory could not
be "written",

-> 00403060 sub dword ptr [ebp-355D8380h]


Looking for GetModuleHandle all I could find was,


; KERNEL32 API calls (ASCII)
import kernel32,\
...
GetModuleHandle,'GetModuleHandleA',\


; KERNEL32 API calls parameters' count
GetModuleHandle% = 1

in the fasm files.


--
John Casey

email: jgkjcasey at yahoo.com.au
Post 25 Sep 2005, 02:27
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
GetModuleHandle is an OFFSET to a variable containing the address to GetModuleHandle

you should enclose it in square brackets:

Code:
push 0
call [GetModuleHandle]    
Post 25 Sep 2005, 02:47
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
casey



Joined: 18 Aug 2005
Posts: 35
casey
Of course Embarassed that works.

Thank you comrade.

It is unclear why the import is needed when it doesn't
seem to be needed in RosAsm source or MASM source. I
know it has something to do with the PE part from the
FASM manual.

section '.idata' import data readable writeable
...
import KERNEL32, \
GetModuleHandle, \
'GetModuleHandleA', \

The TD source code from RosAsm that I actually used
to unroll the invoke statement, uses GetModuleHandleA.
The 'A' I understand to mean plain asc rather than
unicode (GetModuleHandleW).

Why doesn't call [GetModuleHandleA] work?

Undefined symbol error.

Do I lack an include and/or import directive for
the file with the required definition?

I notice that Java, which I am also learning, uses
the import directive.

-
John Casey
Post 25 Sep 2005, 04:29
View user's profile Send private message Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial
Because you defined GetModuleHandle as symbol name, not GetModuleHandleA. Thats why the second one is an undefined symbol Wink

If you include win32ax.inc, you can make life easier as all important WinAPI functions get imported automaticaly.
Post 25 Sep 2005, 07:04
View user's profile Send private message Reply with quote
casey



Joined: 18 Aug 2005
Posts: 35
casey
I included win32ax.inc and it still declares GetModuleHandleA
as an undefined symbol.

How do I define it?

All I can find in the KERNEL32.inc is the same thing written in
the section '.idata'
Post 25 Sep 2005, 08:52
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
Write:
Code:
label GetModuleHandleA at GetModuleHandle    
Post 25 Sep 2005, 10:00
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.