[fpc-pascal]WoW

Full_Name memsom at post.interalpha.co.uk
Mon Aug 20 16:03:57 CEST 2001


Quoting "Michael A. Hess" <mhess at miraclec.com>:


> Please. please. please have him help with the Lazarus project if he
> wants to work on something like that. Currently the core developers for
> Lazarus have been very busy so Lazarus develoment has slowed to a
> crawl.
> We are in major need of additional help. Any help.  :-)

I'll put it forward to him, but as he's the R&D guy for the entire company, I 
don't know whether it will still interest him. This was a conversation we had 
about two weeks ago ;-) He was writing a OO persistant DBMS layer for Delphi 
Classes for about 6 months. He seems to have dropped that now. He also has a 
nasty habbit of doing things like writing assembler directly into memory at 
runtime, and then executing it.. he wrote a piece of code that dynamically 
allocated/dispatched methods to an instance of an object from an interface 
(that wasn't part of the class) at runtime using this method. It was clever, 
but no one could really see a reason to use it...

 ITest = interface
    ['{77D52DDB-3EC3-4723-8919-00DFB6BF6418}']
    procedure DoSomething; stdcall;
    procedure DoSomethingElse; stdcall;
    procedure Another(test: integer); stdcall;
  end;

  TForm1 = class(TForm)
   {...}
  private
    { Private declarations }
    FIntFPtr         : Pointer;
    FTablePtr        : Pointer;
    FInvokationTable : PInvokationEntryArray;
    function GetITestToSelfOffset : Integer;
  public
    { Public declarations }
    procedure DoSomething; stdcall;
    procedure DoSomethingElse; stdcall;
    procedure Another(test: integer); stdcall;
  end;

  function CreateInvokationTable(Methods : array of pointer; Offset : 
Integer) : PInvokationEntryArray;

procedure FreeInvokationTable(InvokationEntries : PInvokationEntryArray);

function CreateInterfaceVTable(Size : Integer;
  InvokationEntries : PInvokationEntryArray) : Pointer;

procedure FreeInterfaceVTable(VTable : Pointer);


...I won't give you the guts of the code, because my company owns it, but you 
could then do the following...


procedure TForm1.FormCreate(Sender: TObject);
begin
  //  Create Invokation Table
  FInvokationTable := CreateInvokationTable([@TForm1.QueryInterface,
    @TForm1._AddRef, @TForm1._Release, @TForm1.DoSomething,
    @TForm1.DoSomethingElse, @TForm1.Another], GetITestToSelfOffset);
  //  Initialize VTable Pointer
  FTablePtr := CreateInterfaceVTable(6, FInvokationTable);
  //  Initialize Interface Pointer, Interface Is A Pointer To A Pointer To 
VTable
  FIntFPtr  := @FTablePtr;
end;

...and then do the following...

procedure TForm1.btnDoSomethingClick(Sender: TObject);
begin
  //  Invoke Method
  ITest(FIntFPtr).DoSomething;
end;

...Which should be impossible in the normal run of things.

Lazarus currently uses GTK+ doesn't it? That in itself probably will put him 
off. How is the Win32 API binding coming along?

Matt

--

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s+++:+ a- C++ UL+ P L++ E---- W- N+ o+ K- w 
O- M V PS PE-- Y PGP- t- 5-- X- R- tv+ b+ DI++ D+ 
G e++ h--- r+++ y+++ 
------END GEEK CODE BLOCK------




More information about the fpc-pascal mailing list