Solved

question to tfai

Posted on 1998-02-27
5
257 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to DocumentFormat 8 127
What is MicroStrategy.NET? 2 84
Why is "packages element is not declared"? 2 468
How Do I Widen a Column in a SharePoint 2013 List 2 36
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…

730 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