?
Solved

question to tfai

Posted on 1998-02-27
5
Medium Priority
?
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

765 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