Solved

question to tfai

Posted on 1998-02-27
5
250 Views
Last Modified: 2013-12-03
To get ordinal nos of functions in a dll
dumpbin \exports my.dll workes fine under NT, but not
win95 ? any thing that you know of for this ?

and the other problem is that, kernel32.dll functions
under win95 does not support ordinal calls, (ole32.dll
for example works for win95, and win NT all works.

the following gives correct result under NT,
but fails under win95.

      typedef BOOL (CALLBACK* LPFUNC) (OSVERSIONINFO*);
      HINSTANCE hDLL;
      LPFUNC  lpfunc1, lpfunc2;
      hDLL = LoadLibrary("Kernel32");
      if(hDLL != NULL)
      {

        DWORD GETVERSIONEX;
         lpfunc1 = (LPFUNC) GetProcAddress(hDLL, "GetVersionExA");
            if(lpfunc1)
            {
                  for(int i = 0; i < 1000; i++)
                  {
                        GETVERSIONEX = i;
                        lpfunc2 = (LPFUNC) GetProcAddress(hDLL, (char*) GETVERSIONEX);
                        if(lpfunc1 == lpfunc2)
                        {
                              CString mess;
                              mess.Format("ordinal is : %d",i);
                              MessageBox(mess,"result");
                              break;
                        }
                  }
                  FreeLibrary(hDLL);
            }
            else
            {
                  FreeLibrary(hDLL);
                  int error_no;
                  error_no = GetLastError();
                  CString mess;
                  mess.Format("error # %d",error_no);
                  MessageBox(mess,"lpfunc1");
            }
      }

in here I wanted to find the ordinal no for a specific
function, programatically. Is there a better way ? thanks
0
Comment
Question by:has
  • 3
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1411577
I'm evesdropping, but Dumpbin /exports works fine for me under Win95.  What problem are you having with it?
0
 
LVL 4

Accepted Solution

by:
tflai earned 50 total points
ID: 1411578
This is what I found in the book "Dirty Little Secrets About Windows 95" by Matt Pietrek.  (Excellent book!):
or web page:  ftp.uni-mannheim.de/info/OReilly/windows/win95.update/dirty.html

Anti-hacking code

In Unauthorized Windows 95, Andrew Schulman made extensive use of undocumented functions in KERNEL32.DLL. Although there obviously weren't header files for these functions, the functions appeared in the import library for KERNEL32.DLL. Calling these functions was as simple as providing a prototype and linking with KERNEL32.LIB.

In subsequent builds of Windows 95 after Andrew's book came out, these functions disappeared from the import library for KERNEL32.DLL. (Surprise! Surprise!) At the same time, these function names disappeared from the exported names of KERNEL32.DLL. These undocumented functions were still exported, however. The difference is that they were exported by ordinal only.

Now, normally this would have been only a small nuisance to work around. You should be able to simply call GetProcAddress and pass in the desired function ordinal as the function name (0 in the HIWORD, the ordinal in the LOWORD) and get back the address. In a normal, sane world, this would work. However, at some point during the beta, Microsoft added code to GetProcAddress to see if it's being called with the ordinal form of the function. If so, and if the HMODULE passed to GetProcAddress is that of KERNEL32.DLL, GetProcAddress fails the call. In the debugging version of KERNEL32.DLL, the code emits a trace diagnostic: "GetProcAddress: kernel32 by id not supported."
0
 
LVL 4

Expert Comment

by:tflai
ID: 1411579
Funny thing what Microsoft can do to make developers' life tougher  :-)
0
 

Author Comment

by:has
ID: 1411580
thank you so win95 has one more problem to work around.
nietod says no problem of dumpbin in win95, I tried on three
win95 systems, non can recocnize it, nt of course does the job ?
what is your opinion ? thanks a lot
0
 
LVL 4

Expert Comment

by:tflai
ID: 1411581
Strange?  DUMPBIN works fine on my machine.
Are you sure you're using MSDEV's DUMPBIN.EXE?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now