flat assembler
Message board for the users of flat assembler.

Index > Windows > Importing API functions by their ordinals. Is it safe?

Author
Thread Post new topic Reply to topic
Serke



Joined: 26 Aug 2006
Posts: 3
Location: Russia
Serke
I wonder, is it safe to import WinAPI functions by their ordinals? AFAIK Micro$oft don’t guarantee that this method will work in their future OS’es, but what about existing OS’es that belong to win32 family? Will ordinals for some functions exported by KERNEL32.DLL and USER32.DLL in Windows XP SP2 be the same ordinals exported by the same DLL’s in, let’s say, Windows 98?
Post 26 Aug 2006, 10:43
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
Probably, since the C lib's use ordinals (as far as I could tell.)
Post 26 Aug 2006, 16:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
UCM: can you give some examples?
Post 27 Aug 2006, 09:16
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
Well, I looked at the import section of an executable I had linked from an OBJ (from FASM), and there were no human-readable names there.
Post 27 Aug 2006, 13:41
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
wasn't it that you linked to LIBCDLL.DLL with ordinals? not to kernel32.dll etc? and LIBCDLL.DLL uses strings, not ordinals...
Post 27 Aug 2006, 13:57
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM
I did not link to the C library, only to the system DLL's (kernel32 and user32.)
Post 27 Aug 2006, 17:21
View user's profile Send private message Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
Garthower
Whether it is safe? Here there is only one way - most to check up Smile To take DLL from, say, WinXP and Win98, and to look ordinals on interesting you API. But anyway, if MicroSoft speaks, that such support will not be conducted, to mean so it and will be. So it is better to not experiment, that then it was not need to rewrite a code.
Post 28 Aug 2006, 10:05
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
peter



Joined: 09 May 2006
Posts: 63
peter
It's not safe. See http://blogs.msdn.com/oldnewthing/archive/2006/07/18/669668.aspx

Also read http://blogs.msdn.com/oldnewthing/archive/2006/07/28/681473.aspx about efficiency of ordinal-based imports. BTW, FASM does not set a look-up hint, while Microsoft's linker (in MASM or VC++) sets it.
Post 29 Aug 2006, 08:46
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
So there is no way to use FASM with ordinals ?
Post 29 Aug 2006, 14:12
View user's profile Send private message Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
Garthower
Quote:

So there is no way to use FASM with ordinals ?


No, the way is. Manual loading API by means of GetProcAddress.
Post 29 Aug 2006, 14:34
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Garthower wrote:
Quote:

So there is no way to use FASM with ordinals ?


No, the way is. Manual loading API by means of GetProcAddress.


...or using object module output, and link against import libraries with ordinals.

_________________
Image - carpe noctem
Post 29 Aug 2006, 14:37
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
shism2 wrote:
So there is no way to use FASM with ordinals ?

The "import" macro is capable of importing functions by ordinal (see Win32 headers docs). However the "export" macro currently doesn't allow you to set up the fixed ordinals in your own DLL.
Post 31 Aug 2006, 08:34
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.