5
votes
An ugly alternative to interface to object casting
Entropy Overload
– I was answering a question on Stack Overflow, but the user didn't have the latest version of Delphi. My answer included converting an interface to an object instance, which is made possible with the as cast on interfaces in recent Delphi versions. But there is another way of doing it, exploiting the regularity Delphi interface vtable implementations: {$apptype console} function Intf2Obj(x: IInterface): TObject; type TStub = array[0..3] of Byte; const // ADD [ESP+$04], imm8; [ESP+$04] in stdcall is Self argument, after return address add_esp_04_imm8: TStub = ($83, $44, $24, $04); // ...
Statistics
|
Visits by Source |
User Actions |




