Getting free resource under Windows 95

How to call 16-bit dll API from 32-bit application.

Windows 95 secret finally revealed.

One of the most frequently asked question about Windows95 is "How does Windows Explorer get the amount of system resources available?"

The Microsoft documentation states that the GetFreeSystemResources function is discontinued for Win32. Win32 documentation also says that system resources are virtually unlimited now. However Windows Explorer Help About dialog shows that it is not correct (at least for Windows95). I haven't tested this on Windows98 as of yet and and I believe that the documentation is correct with regards to WindowsNT. However, for Windows95, they documentation is definitely in error.

The 16-bit module USER.EXE still exists in Windows95 and 16-bit applications can get retrieve the desired resource information using the 16-bit GetFreeSystemResources function. So, the question is, Why can't Explorer (or any 32-bit application) also make this call?

The code snippet below demonstrates how to invoke a function exported from a 16-bit DLL from a 32-bit application. Please note that the GetK32ProcAddress function was provided courtesy of Andrew Schulman's "Unauthorized Windows 95 Update". For the more curious among you, here are the links to the header and implentation files for that function.

(Since k32exp.c is included as a separate module, I'm guessing that it is protected by copyright.)

WORD GetFreeSystemResources(WORD type)
 //Decarations  "c" style
 typedef HINSTANCE (WINAPI* LOADLIB16)(char*);
 LOADLIB16 pLoadLib16;
 GETPROC16 pGetProc16;
 FREELIB16 pFreeLib16;
 DWORD pGetRes;
 WORD user_fsr;
 WORD _type;
 HMODULE hKernel;

 //Usuall Windows API calls
 hKernel = GetModuleHandle("KERNEL32");
 QT_Thunk = GetProcAddress(hKernel, "QT_Thunk");

 //Andrew Schulman's 
 pLoadLib16 = (LOADLIB16) GetK32ProcAddress(LOADLIBRARY16_ORD);
 pGetProc16 = (GETPROC16) GetK32ProcAddress(GETPROCADDRESS16_ORD);
 pFreeLib16 = (FREELIB16) GetK32ProcAddress(FREELIBRARY16_ORD);

 //Usuall for "c"-style calls - by pointer to function 
 hInst = (*pLoadLib16)("user");
 pGetRes = (*pGetProc16)(hInst,"GetFreeSystemResources");

 //How to call 16-bit dll API from 32-bit .exe using QT_Thunk function
 _type = type;
 if (pGetRes)
  push    _type
  mov     edx, [pGetRes] 
  call    QT_Thunk 
  mov     [user_fsr], ax
 return user_fsr;
The demo project included in this article is a console application that retrieves the free system resources for Windows 95. Simply build it and run it from the command line.

How do you know that the Windows95 Explorer uses the 16-bit USER.EXE to get free system resources? Just ask your buddy hacker to make GetFreeSystemResources in USER.EXE return zero and examine what Windows Explorer shows for free resources!. In my USER.EXE version 4.00.950, GetFreeSystemResources starts at the 0x444FF byte offset.

Download demo project - 5 in KB KB

Date Last Updated: February 8, 1999


  • free disk space from Windows NT machine.

    Posted by Legacy on 01/17/2001 12:00am

    Originally posted by: Arun Jose

    How t get the free available disk space in Windows NT machine???

  • Direct thunk problems

    Posted by Legacy on 09/27/1999 12:00am

    Originally posted by: PetrP

    I had to add extern "C" to k32exp.h to link it to my 32-bit application. Finaly this code is very helpful for all thunks programmers.

    I try to call my own 16-bit dll with no problems when passing constants through direct thunk, but I have problems with pointers now. I load procedure by LoadLib16() and GetProcAdress16(), then I allocate memory by GlobalAlloc16(), move data by MoveMemory(), call QT_Thunk passing pointer, then I free memory by GlobalFree16(). All is working until this. I try to free called procedure and library by FreeLib16() and error occures.

    When using another procedure from this same library without pointers everithing goes OK.

    What I'm doing wrong... Please HELP ME !

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Thanks to the Internet of Things (IoT), physical assets are turning into participants in real-time global digital markets. The countless types of assets around us will become as easily indexed, searched and traded as any online commodity. While some industries will be tougher to transform than others – those with physical limitations, such as manufacturing, will be harder to digitize – untold economic opportunities exist for growth and advancement. Our research shows this will create a new "Economy …

  • On-demand Event Event Date: September 23, 2015 The cloud is not just about a runtime platform for your projects – now, you can do your development in the cloud, too. Check out this webcast to learn how the cloud improves your development experience and team collaboration. Join Dana Singleterry, Principal Product Manager for Oracle Dev Tools, as he discusses how to simplify every aspect of the development lifecycle, including requirements gathering, version management, code reviews, build automation, and …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date