AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Windows 2022 Server, mit Delphi erstelltes exe hat Fehler
Thema durchsuchen
Ansicht
Themen-Optionen

Windows 2022 Server, mit Delphi erstelltes exe hat Fehler

Ein Thema von AndreasAutopoll · begonnen am 5. Sep 2024 · letzter Beitrag vom 9. Sep 2024
 
Kas Ob.

Registriert seit: 3. Sep 2023
404 Beiträge
 
#12

AW: Windows 2022 Server, mit Delphi erstelltes exe hat Fehler

  Alt 6. Sep 2024, 12:29
On my XE8, an empty VCL project does in fact call RegisterClass only once for TMenuItem, so OutputDebugString might be enough as the list might be short.

Here is a full hooking unit
Delphi-Quellcode:
unit lcHookRegisterClass;

interface

uses
  Classes, Windows, DDetours;

//procedure InstallHook;

type
  TRegisterClassProc = procedure(AClass: TPersistentClass);

var
  TrampolineRegisterClass: TRegisterClassProc;

implementation

procedure InterceptRegisterClass(AClass: TPersistentClass);
begin
  TrampolineRegisterClass(AClass); // call the original to register, we don't break the application

  // AClass.ClassName to log , file or OutputDebugString ...
  OutputDebugString(PChar(AClass.ClassName)); // OutputDebugString need Windows in uses clause
end;

procedure InstallHook;
begin
  // Classes.RegisterClass , we use full name and path to the proc if possible to prevent confusion as there is Windows API as RegisterClass
  if not Assigned(TrampolineRegisterClass) then
    TrampolineRegisterClass := InterceptCreate(@Classes.RegisterClass, @InterceptRegisterClass);
end;

initialization
  InstallHook;


finalization
  if Assigned(TrampolineRegisterClass) then
    InterceptRemove(@TrampolineRegisterClass);

end.
lcHookRegisterClass should be the first in in the uses clauses in the dpr file, or the second if there is Memory Manger unit is used, something like this
Delphi-Quellcode:
program Project10;

uses
  lcHookRegisterClass in 'lcHookRegisterClass.pas',
  Vcl.Forms,
  uMain in 'uMain.pas{Form10};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm10, Form10);
  Application.Run;
end.
Kas
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:36 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz