In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
ComBoBox control, if there is item is empty, then report ntdll.dll solution
After searching online, I finally found a solution and downloaded a pas file
After adding this pas file to project, there is no error reported. It is really good.
---------------------------------
Copy the following code and save it to D7ComboBoxStringsGetPatch.pas
------------------------------------------
unit D7ComboBoxStringsGetPatch;
// The patch fixes TCustomComboBoxStrings.Get method for empty string item in Delphi 7.
interface
{$IF RTLVersion 15.0}
'This patch is intended for Delphi 7 only';
{$IFEND}
implementation
uses
Windows, SysUtils, StdCtrls;
resourcestring
RsPatchingFailed = 'TCustomComboBoxStrings.Get patching failed. ';
type
TPatchResult = (prNotNeeded, prOk, prError);
function PatchCode(RoutineStartAddr: Pointer; PatchOffset: Cardinal; OriginalCode: Pointer;
OriginalCodeLen: Cardinal; PatchedCode: Pointer; PatchedCodeLen: Cardinal): TPatchResult;
const
JmpOpCode = $25FF;
type
PPackageThunk = ^TPackageThunk;
TPackageThunk = packed record
JmpInstruction: Word;
JmpAddress: PPointer;
end;
var
CodeStart: Pointer;
BytesWritten: DWORD;
begin
if FindClassHInstance(System.TObject) HInstance then
with PPackageThunk(RoutineStartAddr)^ do
if JmpInstruction = JmpOpCode then
RoutineStartAddr := JmpAddress^
else
begin
Result := prError;
Exit;
end;
CodeStart := Pointer(LongWord(RoutineStartAddr) + PatchOffset);
if CompareMem(CodeStart, OriginalCode, OriginalCodeLen) then
begin
if WriteProcessMemory(GetCurrentProcess, CodeStart, PatchedCode, PatchedCodeLen, BytesWritten) and
(BytesWritten = PatchedCodeLen) then
begin
FlushInstructionCache(GetCurrentProcess, CodeStart, PatchedCodeLen);
Result := prOk;
end
else
Result := prError;
end
else
Result := prNotNeeded;
end;
type
TCustomComboBoxStringsHack = class(TCustomComboBoxStrings);
function AddrOfTCustomComboBoxStringsGet: Pointer;
begin
Result := @TCustomComboBoxStringsHack.Get;
end;
procedure PatchTCustomComboBoxStringsGet;
const
OriginalCode: Cardinal = $74FFF883; // CMP EAX, -1 | JZ +$26
PatchedCode: Cardinal = $7E00F883; // CMP EAX, 0 | JLE +$26
PatchOffset = $1F;
// for DEBUG DCU by Pavel Rogulin
OriginalCodeD: Cardinal = $FFF07D83;
PatchedCodeD: Cardinal = $00F07D83;
PatchOffsetD = $2E;
var
PatchResult: TPatchResult;
begin
PatchResult := PatchCode(AddrOfTCustomComboBoxStringsGet, PatchOffset, @OriginalCode, SizeOf(OriginalCode),
@PatchedCode, SizeOf(PatchedCode));
if PatchResult = prNotNeeded then
PatchResult := PatchCode(AddrOfTCustomComboBoxStringsGet, PatchOffsetD, @OriginalCodeD, SizeOf(OriginalCodeD),
@PatchedCodeD, SizeOf(PatchedCodeD));
case PatchResult of
prError:
begin
if IsConsole then
WriteLn(ErrOutput, RsPatchingFailed)
else
MessageBox(0, PChar(RsPatchingFailed), nil, MB_OK or MB_ICONSTOP or MB_TASKMODAL);
RunError(1);
end;
end;
end;
initialization
PatchTCustomComboBoxStringsGet;
end.
Address of this article: http://www.xszlo.com/article/2012-11-10/7497.html, please keep this address for forwarding, thank you
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.