AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein In Asm-Prozedur eine Exception auslösen
Thema durchsuchen
Ansicht
Themen-Optionen

In Asm-Prozedur eine Exception auslösen

Ein Thema von Amateurprofi · begonnen am 2. Nov 2023 · letzter Beitrag vom 11. Nov 2023
 
Kas Ob.

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

AW: In Asm-Prozedur eine Exception auslösen

  Alt 4. Nov 2023, 08:29
@Kas Ob.
Thanks for your detailed comments in #8.
Unfortunately not was I am looking for, because I dont want to call procedures outside of my Asm-Procedure (except system-routines).

What I am currently using is the following:

Delphi-Quellcode:
PROCEDURE RaiseException(const S:String);
begin
   raise Exception.Create(S);
end;
Delphi-Quellcode:
PROCEDURE Test;
const S:String='My Message';
asm
   {$IFDEF CPUX86}
   mov eax,S
   {$ELSE}
   mov rcx,S
   {$ENDIF}
   jmp RaiseException
end;
Thank you for clarifying and sorry if i wasn't clear enough.
Delphi assembler has very limited capability, eg. that is why you have to declare constant strings to be used with the assembler with typed strings.

My function above "ExceptionAsm32" is the closest thing you can do with assembly to create and raise exception without writing very complex and unreliable assembly code for Delphi assembler, because it is inconsistent not allow you to get or access specific types, VMT, offsets..etc

beantwortet, also:
Code:
  mov  eax,????
That i had answered , if you don't need to declare your own (or will not multiple ) then replace TMyException with the default Exception.
Code:
const
  pMyExClass: ExceptClass = (TMyException);
  ..
asm
  ..
  mov   eax, pMyExClass; // <-----
That way you can use multiple exception from asm block, only i use create because there is no way or at least no way i know to access the default constructor with compiler help, your assembly can't have the default constructor index to call Create directly for specific class.

ps: about this
Delphi-Quellcode:
PROCEDURE Test;
const S:String='My Message';
asm
   {$IFDEF CPUX86}
   mov eax,S
   {$ELSE}
   mov rcx,S
   {$ENDIF}
   jmp RaiseException
end;
I am against using jmp to raise exception, this will prevent one push on the stack which might leads to whole different story and confusion, just use call, the more code addresses on the stack the safer for OS to rewind correctly, see, when the system will unwind it might not see your that Test procedure at all and will report the caller to Test as the exception raiser.
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 20:26 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