The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Sigmatador on January 30, 2005, 11:55:49 AM

Title: What is the correct syntax for
Post by: Sigmatador on January 30, 2005, 11:55:49 AM
mov eax, [fs:30h] or something like that ?

regards.
Title: Re: What is the correct syntax for
Post by: hutch-- on January 30, 2005, 12:25:38 PM
Maybe if you told us what you are trying to do, someone could help you. Segment "fs" is normally not used in win32 for application coding so it would appear you have some other use for it.
Title: Re: What is the correct syntax for
Post by: Sigmatador on January 30, 2005, 12:34:18 PM
i know what i'm doing  :green
however this code will give you the module base address of KERNEL32.DLL on every 32bits Windows version (stored in eax)

mov     edx, fs:[30h]
mov     eax, [edx+0ch]
mov     esi, [eax+01ch]
mov     edx, [esi]
mov     eax, [edx+8]

this code compil without pb using msvc and inline asm syntax (__asm {...})
I would like to write a whole prog in asm using this (not just some inline asm in a C code), so i have to find the correct masm syntax to write this ^^
Title: Re: What is the correct syntax for
Post by: Sigmatador on January 30, 2005, 12:38:09 PM
and yes i know

mov eax, fs
add eax, 30h
mov eax, [eax]

would work, but why use 3 instructions when a single one do the same job  :8)

and btw, i'm new to masm, so  i still need to figure out the masm syntax specificity
Title: Re: What is the correct syntax for
Post by: Jibz on January 30, 2005, 12:57:55 PM
Quote from: Sigmatador on January 30, 2005, 12:34:18 PM
i know what i'm doing :green
however this code will give you the module base address of KERNEL32.DLL on every 32bits Windows version (stored in eax)

Tried it on Win9x/ME? or do you not considder them to be 32-bit since you know what you're doing?
Title: Re: What is the correct syntax for
Post by: Sigmatador on January 30, 2005, 01:00:04 PM
oki found!

by default masm prevent from using fs segment

a simple

assume fs:nothing
mov eax, [fs:30h]

do the trick ^^

cu all
regards