[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

question to tfai

Posted on 1998-02-27
5
Medium Priority
?
265 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

656 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