Results 1 to 14 of 14

Thread: API declaration using #1 function names

  1. #1

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    API declaration using #1 function names

    Does anybody in here know how to find out the API function names that correspond to the "#1" style of the same function names?

    I read that it's actually quicker to use the enumerated function name, but I can't seem to find a list of the corresponding function names.

    I've been matching some API's by trial an error, but there must be some documentation on this, that will save me a whole lot of time.

    Thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: API declaration using #1 function names

    "#1" style? There is the EntryPoint function name and alias and wide and ansi. Those are all I have heard of.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: API declaration using #1 function names

    "#1" style? There is the EntryPoint function name and alias and wide and ansi. Those are all I have heard of.
    I'm gonna call it enumerated alias style, because it had no name where i read it.(Dan Appleman's guide to the aPI). He mentions a performance increase.
    I've tested it, and sure enough it works. I assume that the numbers run in linear order from 1 to about 900+.

    When you use the Alias you put: Alias "#162".
    But you have to know what the 162 nd function name is, in order to know what params to use.

    I was doing a brute search with user32, and placing objects in the params with Nothing as the param. For example:
    Code:
    Public Declare Function Function1 Lib "user32" Alias "#1"  (ByVal p1 As Object, ByVal p2 As Object, ByVal p3 As Object, ByVal p4 As Object, ByVal p5 As Object) As Int32
    This returns a value, but I have no idea what function I'm calling.
    So i dont recommend everyone try this, as it could cause unintended results.

  4. #4

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: API declaration using #1 function names

    Okay i found something.
    It looks like they are called ordinal (#x).

    Here is an interesting link explaining why they are not commonly known.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: API declaration using #1 function names

    Oh interesting but that list would seem ungodly to create as there are something like 13K+ APIs up to and including Vista.

    Hmm, seems that maybe its in the Hint column of Depends when you open one of the windows core dlls like user32.dll. Could be close but you may want to take a look at it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: API declaration using #1 function names

    Okay Ive opened the user32.dll with notepad and found an alphabetic list of function names. Some of which seem to be completely unique, and undocumented! Is this what you meant?
    It maybe that these are listed in order of their ordinal representations.
    I'll have to do some testing to see if they match up with the alphabetic order.

    Thanks for pointing me towards the right direction.
    I should of thought of that to begin with.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: API declaration using #1 function names

    Well instead of using notepad, use the utility Dependancy Walker (Depends.exe) to open the user32.dll. It will show the heirarchy of API calls and the "Hint" column which has the numbers in it. I think the hint is referring to what you are looking for.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: API declaration using #1 function names

    I just tried AttatchThreadInput, declared as the ordinal #12, and it works perfect!

    Now the interesting part is to find out what the parameters are for those functions that I've never seen anywhere.

    Okay thanks for the depends.exe tip.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: API declaration using #1 function names

    Ok, after looking a bit more I think it goes like this...

    For each Windows dll it will contain its own set of ordinal number "Hint"s. So #13 in user32.dll is AttachThreadInput but in NTDLL.dll its AlpcAdjustCompletionListConcurrencyCount.

    Something to watch out for as I guess ordinal lists for each windows component dll will be necessary.

    Can you find the arguments for the functions on MSDN? I would look there first.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: API declaration using #1 function names

    Bah! Just realized we are looking at the ordinal numbers. The Hints are different numbers.

    Hints
    #12 - AttachThreadInput - User32.dll
    #12 - AlpcMaxAllowedMessageLength - NTDLL.dll

    Ordinals
    #13 - AttachThreadInput - User32.dll
    #22 - AlpcMaxAllowedMessageLength - NTDLL.dll
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: API declaration using #1 function names

    Yeah I realized that the numbers run for each dll.

    Some of those functions don't seem to come up on msdn.
    For example AllowForegroundActivation.

  12. #12

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: API declaration using #1 function names

    I found a couple links.

    Here is a link that has a simplified list of the user32 and kernel32
    User32
    Kernel32

    This link has the AllowForegroundActivation function, and it's param.
    http://www.reactos.biz/generated/dox...2stubs_8c.html

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: API declaration using #1 function names

    Ordinals are very slightly faster to compile because the function table lookup in the linking stage is avoided. This doesn't affect compiled performance.

    Since compilation speed is very rarely ever an issue, I recommend avoiding the use of ordinals simply for readability's sake.

    If you want to increase the speed of calling a native API function, investigate using a type library (.tlb) instead. This is the most efficient method.

  14. #14
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: API declaration using #1 function names

    A link for NTDLL.DLL NTinternals which I've found very useful. And of course Windows Internals if you want the book.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width