Einzelnen Beitrag anzeigen

Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#16

Re: D3D9 Hook bzw. als "proxy.dll"

  Alt 27. Okt 2009, 21:17
I think this is a Delphi bug, I remember it because I had a problem with some other winapi call that returned an interface.
I quickly tested this (I used IUnknown because I don't have DirectX):

Delphi-Quellcode:
function Direct3DCreate9(SDKVersion: Cardinal): IUnknown; stdcall; external 'd3d9.dll';

procedure TForm2.Button1Click(Sender: TObject);
var
  Unknown: IUnknown;
begin
  Unknown := Direct3DCreate9(32);
end;
When I look in the CPU window we can see the problem:
Delphi-Quellcode:
Unit2.pas.31: Unknown := Direct3DCreate9(32);
004A3B0F 6A20 push $20
004A3B11 8D45F8 lea eax,[ebp-$08]
004A3B14 50 push eax
004A3B15 E8CEFFFFFF call Direct3DCreate9
For some reason Delphi put's the result (which is in eax when using stdcall) on stack (push eax).

If I declare like this it looks ok:
Delphi-Quellcode:
function Direct3DCreate9(SDKVersion: Cardinal): Pointer; stdcall; external 'd3d9.dll';

procedure TForm2.Button1Click(Sender: TObject);
var
  Unknown: IUnknown;
begin
  Pointer(Unknown) := Direct3DCreate9(32);
end;
The CPU window shows:
Delphi-Quellcode:
Unit2.pas.31: Pointer(Unknown) := Direct3DCreate9(32);
004A3B0F 6A20 push $20
004A3B11 E8D2FFFFFF call Direct3DCreate9
004A3B16 8945F8 mov [ebp-$08],eax
See my blog blog
See our Jedi blog
  Mit Zitat antworten Zitat