GExperts Win64: Enabling the Explicit Filter Expert

The GExperts 64-bit build just got a little more capable. The Filter Explicit Properties expert, which prevents the IDE from writing ExplicitLeft, ExplicitTop, ExplicitWidth, and ExplicitHeight properties to .dfm files, now works in the 64-bit IDE.

Since Delphi 2006, the IDE has been adding these Explicit* properties to .dfm files. While they serve a purpose for the form designer’s layout system, they clutter diff views and cause unnecessary merge conflicts in version control. The ExplicitFilter expert solves this by hooking TControl.DefineProperties to suppress these properties when saving forms.

The original implementation used a manual function hooking technique that only worked on 32-bit:

  TXRedirCode = packed record
    Jump: Byte;      // $E9 = relative jump
    Offset: Integer; // 32-bit offset
  end;
  

This 5-byte relative jump instruction can only reach ±2GB from the hook location – fine for 32-bit address spaces, but unreliable in 64-bit where code and data can be spread across a much larger address range.

GExperts already includes the DDetours library, which handles the complexities of function hooking on both 32-bit and 64-bit platforms. The fix was straightforward – replace the manual hooking code with DDetours’ InterceptCreate and InterceptRemove functions:

  procedure InitControlExplicitFix;
  begin
    gblTrampolineDefineProperties := InterceptCreate(
      @TControlHack.DefineProperties,
      @TControlExplicitFix.DefineProperties);
  end;

  procedure FinalizeControlExplicitFix;
  begin
    if Assigned(gblTrampolineDefineProperties) then begin
      InterceptRemove(gblTrampolineDefineProperties);
      gblTrampolineDefineProperties := nil;
    end;
  end;
  

DDetours handles all the platform-specific details internally, using appropriate jump sequences for each architecture.

The Filter Exceptions expert remains disabled on Win64. It hooks into the IDE’s debugger BPL packages to intercept exception notifications, but the 64-bit IDE uses different package names (Win64DebugIde*.bpl instead of Win32DebugIde*.bpl). Enabling this expert will require identifying the correct exported function names in the 64-bit debugger packages.

There is no release with these changes yet. If you want to use this feature now, you can build your own DLL from the latest source at the SourceForge repository. For instructions, see Compiling GExperts.