Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Hook führt zu System Exception (https://www.delphipraxis.net/160650-hook-fuehrt-zu-system-exception.html)

s.h.a.r.k 8. Jun 2011 17:41

AW: Hook führt zu System Exception
 
Ich habe noch eine kleine Optimierung, die eine Compiler-Warnung betrifft, die ich bisher leider übersehen hatte. Das Problem war, dass der Wert in der Zeile
Delphi-Quellcode:
PLongInt(Result)^ := $B952515A;
größer als der maximale LongInt-Wert von $7FFFFFFF ist und somit eine Warnung des Compilers ausgegeben wurde, völlig zurecht will ich meinen. Habe nun anstatt PLongInt nach PLongWord gecastet und schon war die Warnung weg. Hier der korrigierte Code:
Delphi-Quellcode:
function MakeProcInstance(const M: TMethod): Pointer;
begin
  GetMem(Result, 7 + 2 * SizeOf(Pointer));
  PByte(Result)^ := $B9;
  Inc(PByte(Result));
  PPointer(Result)^ := M.Data;
  Inc(PPointer(Result));
  PLongWord(Result)^ := $B952515A;
  Inc(PLongInt(Result));
  PPointer(Result)^ := M.Code;
  Inc(PPointer(Result));
  PByte(Result)^ := $FF;
  Inc(PByte(Result));
  PByte(Result)^ := $E1;
  Dec(PByte(Result), 6 + 2 * SizeOf(Pointer));
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:35 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz