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
Antwort Antwort
Kas Ob.

Registriert seit: 3. Sep 2023
457 Beiträge
 
#1

AW: In Asm-Prozedur eine Exception auslösen

  Alt 10. Nov 2023, 12:40
@Kas Obi:

I think, the stack is need under modern Microsoft Windows.
Because the first two 8 Bit = 16 Bit = 10h is for 64-Bit self-references the Functions, and Procedures.
So the first Argument/Parameter for the Function's/Procedure's begin at Bit 16.
I say to me:
Code:
first := 0 <-- self
second := 1 <-- first Parameter
...
I am not sure i do understand that %100, but Self will be used and added ONLY in Objects and Classes when the code is used in OOP style, not in orphan procedures/functions like all the mentioned p/f in this thread.

Example
Code:
function MyFunc(A: Integer; B: string): Integer;
begin

end;
 // Internally the compiler will make generate the code exactly as the following

procedure MyFuncAsProc(A: Integer; B: string; out Result: Integer);
begin

end;

------------------------

function MyClass.MyFunc(A: Integer; B: string): Integer;
begin

end;
 // Internally the compiler will make generate the code exactly as the following

procedure MyClass.MyFuncAsProc(const Self: TMyClass; A: Integer; B: string; out Result: Integer);
begin

end;
So using the satck is not for only referencing Self, in fact Self will always be in a register.( in edx on x86/x32, and in rcx on x64)

and that if i understand your comment right and we are talking about Self like This in other languages.
Kas
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.554 Beiträge
 
Delphi 12 Athens
 
#2

AW: In Asm-Prozedur eine Exception auslösen

  Alt 10. Nov 2023, 12:46
no, with is only for results greater a Register aka SizeOf(Pointer)
or for Results with managed types, such as string and interface.
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Benutzerbild von paule32.jk
paule32.jk

Registriert seit: 24. Sep 2022
Ort: Planet Erde
371 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: In Asm-Prozedur eine Exception auslösen

  Alt 10. Nov 2023, 19:41
@kas ob:

ehmm... with self, I mean not the Delphi keyword in Context of Classes/Records.
with self, I mean the internal working Design of Microsoft Windows.
Like himitsu said - it could be for "self" managed Code (COM+).

And I can bet, that Microsoft have a secret Layer'ed File with Numbers (I pointed: 2 ^64 = 18 Trillion GiBytes dataflow. So, each managed Type becomes a (GUID) Number, and as such, all the Component(s) are different and can directly accessed. Instead to use String like in Delphi, and C++ Builder Debug Symbols.
In older Window's, the DLL Functions could be called by Value, and Name.
Frag doch einfach
Alles was nicht programmiert werden kann, wird gelötet
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
10.055 Beiträge
 
Delphi 12 Athens
 
#4

AW: In Asm-Prozedur eine Exception auslösen

  Alt 10. Nov 2023, 22:01
I don't understand what you mean, but the stack layout is documented here:
https://learn.microsoft.com/en-us/cpp/build/stack-usage
Sebastian Jänicke
AppCentral
  Mit Zitat antworten Zitat
Benutzerbild von paule32.jk
paule32.jk

Registriert seit: 24. Sep 2022
Ort: Planet Erde
371 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: In Asm-Prozedur eine Exception auslösen

  Alt 10. Nov 2023, 22:11
hello @jaenicke:

I point to: PROLOG and EPILOG

You can not simply call Exception Functions or any Functions of any Classes without .Create a Instance.
This give MAVs.
Frag doch einfach
Alles was nicht programmiert werden kann, wird gelötet
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
457 Beiträge
 
#6

AW: In Asm-Prozedur eine Exception auslösen

  Alt 11. Nov 2023, 06:59
@kas ob:

ehmm... with self, I mean not the Delphi keyword in Context of Classes/Records.
with self, I mean the internal working Design of Microsoft Windows.
Like himitsu said - it could be for "self" managed Code (COM+).
I am lost here, i don't understand this point or how it is relevant to raising an exception.

Notice that, exception are raised by an interrupt instruction, meaning it have standard way to raise, this doesn't have anything to do the OS (Windows/Linux...) it is standard by hardware, were the OS Kernel should have installed its debugger to capture/receive these hardware generated interrupt.

That was one, and second is notice how Delphi raise the Exception, we create a class then we pass the class to specific procedure to raise it, we don't call any element of that class.
Code:
type
  TMyException = class(Exception)
  end;

var
  MyExcept: TMyException;
begin
  MyExcept.Create('Error Message');
  // we do
  raise MyExcept;
  // and there is no way to raise it from within like
  MyExcept.raise;
end.
If we could do MyExcept.Raise then we should pass the except as self here, but we do raise MyExcept, which take a parameter to the System._RaiseExcept which has hidden way (aka compiler magic) to fill the parameter with the exception class, meaning it is declared as such
Code:
procedure RaiseExcept(Obj: TObject);
The fact we pass the created exception as parameter is merely a coincidence.

And I can bet, that Microsoft have a secret Layer'ed File with Numbers (I pointed: 2 ^64 = 18 Trillion GiBytes dataflow. So, each managed Type becomes a (GUID) Number, and as such, all the Component(s) are different and can directly accessed. Instead to use String like in Delphi, and C++ Builder Debug Symbols.
In older Window's, the DLL Functions could be called by Value, and Name.
Also don't understand this, GUID for COM literally stored in specific Windows format standardized with specific VMT, so we have what we can call a class but it is a bunch of linked look-up tables each have its own GUID stored in central table for that created class, so no secret DB for them, just a service belongs to the OS have the control over the registration for these COM/DCOM, and fill the data in the registry, in readable way.
Also these strings in Delphi are the same in other languages (eg. C#..), in all cases these GUID strings will be translated into bytes from their hex values, into the specific structure to be read then looked up.
So if you use a hex editor/viewer on an application, you will not find any string like these GUID in an interface, but you will find the HEX values for them.
Kas
  Mit Zitat antworten Zitat
Benutzerbild von paule32.jk
paule32.jk

Registriert seit: 24. Sep 2022
Ort: Planet Erde
371 Beiträge
 
Delphi 11 Alexandria
 
#7

AW: In Asm-Prozedur eine Exception auslösen

  Alt 11. Nov 2023, 07:57
@kas ob

First, the only Standard Interrupt on Windows is INT 3. It will be handled as/for Debug reason. This Interrupt is addressed into the GDT, and IDT Table (that is an Operating System Issue). I don't want go into the depth with this, because it will cover more things, that you don't understand.

Again, you need to create a Instance of a Exception Class to "stack up" the Exception.
Each Exception (class) need then stack Prolog, and Epilog.
The Prolog is for clean "build stack", the Epilog is for clean "destroy stack". This is a very import memory thing, because each Exception "can" have Parameters like .Create(42); or .Create('foo'); or .Create('foo','fufu',42); or simply .Create;

Exception's will be "raise" with: raise EExceptionClass.Create; or EExceptionClass.Create(42); ...
Again, you can not do simply raise EExceptionClass.MyExcept; because raise point then into memory where "not" your code have access, and Windows will prompt you with MAV's.

Second, Microsoft Windows uses very often COM+ (Component Object Model) things.
That is based on the Terminal Server Services, and/or the Remote Access Services (RD Remote Desktop).
This services are for centralized the maintain flow of Enterprise/Corporation's firms Computerdesk.

To hold the traffic and latency of Applications for this Services on a low Level, Microsoft plays a little bit with it's own technologies.
As such, they transmit data in form of image data, and plain text (like numbers that describe, what Function is to call on the counter part of the connection. This is then from Server to Client, and Client to Server.

- You can take a look onto the RPC Protocol, and it's implementation (Tools).
- You will realize that many things are based on numbers

RPC is a very old Protocol from Unix Workstations, and Unix Servers back into the 1970th.
Frag doch einfach
Alles was nicht programmiert werden kann, wird gelötet
  Mit Zitat antworten Zitat
Antwort Antwort


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 14:32 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