Can I recompile the .PAS files used by the Delphi IDE?

后端 未结 7 853
既然无缘
既然无缘 2021-01-13 11:27

I am familiar with Jeff Atwood\'s article about how errors are always the programmer\'s fault, but I believe I have really and truly found a bug in a Delphi .pas file.

7条回答
  •  无人及你
    2021-01-13 12:12

    You can, but often you don't have to. Recompiling a VCL unit sometime means recompiling all the rest of the VCL units either because you've changed the interface of a unit or because the compiler gets confused and thinks you've changed the interface. Recompiling a VCL unit also rules out the possibility of using most run-time packages because you can't recompile Delphi's run-time packages.

    Instead of recompiling, you can use run-time patching. I've used the method in the TNT Unicode controls, but Madshi also provides a way to replace a function with your own implementation. If you copy the implementation of DBCommon.GetIndexForOrderBy into your own unit and make your fixes, you can use this command to patch the VCL version with your own:

    var
      Old_GetIndexForOrderBy: Pointer;
    
    HookCode(@DBCommon.GetIndexForOrderBy,
             @Fixed_GetIndexForOrderBy,
             Old_GetIndexForOrderBy,
             0);
    

    With the Tnt Unicode library, find the OverwriteProcedure routine in the TntSystem unit. It's not public, so you'll need to either declare it in the unit interface or copy it into your own unit. Then you can call it much like the Madshi code above:

    var
      Old_GetIndexForOrderBy_Data: TOverwrittenData;
    
    OverwriteProcedure(@DBCommon.GetIndexForOrderBy,
                       @Fixed_GetIndexForOrderBy,
                       @Old_GetIndexForOrderBy_Data);
    

提交回复
热议问题