程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> (轉)TComboBox patch for Delphi 7,tcomboboxdelphi

(轉)TComboBox patch for Delphi 7,tcomboboxdelphi

編輯:Delphi

(轉)TComboBox patch for Delphi 7,tcomboboxdelphi


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.

 

官方BUG解決地址:

http://cc.embarcadero.com/item/18872


delphi前台代碼編譯不過

什麼系統啊? 未必是代碼大的原因

1 可能是TComboBox導致的 下載一個TComboBox patch for Delphi 7,然 後把D7ComboBoxStringsGetPatch.pas加到你的項 目中
2 如果是win2000系統 win2k\system32下的UXTHEME.dll更名為UXTHEME.old 試試
 

Taisol GL826 cardreader patch for win7,是什

電腦讀卡器驅動
 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved