简体   繁体   中英

Is it possible to patch kernel32.dll function by creating dll and placing it beside application?

I am reviewing old patch for the old software: http://cc.embarcadero.com/item/21475

The full description of the patch is as:

Patch for BDE 'Insufficient disk space' problem. (4Gb multiples Terms: No Special Terms Name: Reinaldo Yanez email: ryaayr@yahoo.com URL: None Summary: Patch for BDE 'Insufficient disk space'-error which can occur while using BDE when the disk free space is near to a multiple of 4Gb. Description: This unit is a patch for the famous 4Gb BDE Bug. It is build to fix the 'Insufficient disk space'-error which can occur while using BDE when the disk free space is near to a multiple of 4Gb. For more information please see BDE report# 7089 on Quality Central.

The reason for the error in BDE is aparently a bug in idapi32.dll while computing free disk space. Idapi32.dll is using the api function called GetDiskFreeSpaceA exported by kernel32.dll.

The solution is to 'patch' GetDiskFreeSpaceA in kernel32.dll for the current process, every call to this function is redirected to a new routine (NewGetDiskFreeSpaceA).

The source code of the patch is included. If you use another programming language (ie not Delphi), a precompiled DLL (FIX4GBug.dll) is also included. (If you can compile the included unit, then you do not need to distribute the DLL)

Product: Delphi (4-7) Fixes Contest: None Uploaded: 25-Feb-04 10:03:08 AM last updated 22-Mar-04 6:44:49 PM

I wonder: if MyApplication.exe or BDE idapi32.dll is calling kernel32.dll function GetDiskFreeSpaceA, then how it is possible to redirect call into kernerl32.dll/GetDiskFreeSpaceA to FIX4GBug.dll/GetDiskFreeSpaceA by simply placing FIX4GBug.dll beside MyApplication.exe or beside idapi32.dll?

Ie does simple placement of dll, which contains the same function (same name and same signature), besides application push this application to use function from the local dll instead of kernel32.dll which sits inside Windows system directory?

Does simple placement of dll, which contains the same function (same name and same signature), besides application push this application to use function from the local dll instead of kernel32.dll which sits inside Windows system directory?

No that does not suffice. There is no reason for your executable to load that DLL.

You would need to hook the GetDiskFreeSpaceA API function from within your process. The supplied source code will do that. Alternatively I suspect that the DLL that is supplied will also do that, if you load it into your process with a call to LoadLibrary .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM