Thema: Delphi nochmal Overlay

Einzelnen Beitrag anzeigen

MasterTobi

Registriert seit: 29. Apr 2007
212 Beiträge
 
#2

Re: nochmal Overlay

  Alt 22. Jul 2009, 22:59
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,direct3d9,dxtypes,directdraw,d3dx9,madcodehook;

type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  direct3dcreate9next : function (sdkversion : dword ) : dword; stdcall = nil;
  createdevice9next : function (self, adapter, devtype, wnd, flags, params, device: pointer) : dword; stdcall = nil;
  presentnext : function (self: pointer; const sourcerect, destrect : prect; const destwindowoverride : hwnd; dirtyregion : prgndata) : hresult; stdcall = nil;
  font : id3dxfont;
  mycolor : td3dcolor;

implementation

{$R *.dfm}
function getinterfacemethod(const intf; methodindex: dword) : pointer;
begin
  result := pointer(pointer(dword(pointer(intf)^) + methodindex * 4)^);
end;



procedure showtext(x,y: integer; s: string; col: td3dcolor);
var
  rect : Prect;
begin
  rect.top := y+100; rect.left := x+100;
  rect.bottom := y+100; rect.right := x+100;
  if @font <> nil then
    font.drawtexta(nil,pchar(s),length(s),rect,dt_noclip,mycolor);
end;

function presentcallback(self : pointer; const sourcerect, destrect : prect; const destwindowoverride : hwnd; dirtyregion : prgndata) : hresult; stdcall;
var
  test : hwnd;
begin
showtext(100,100,'test',mycolor);
result := presentnext(self,sourcerect,destrect,destwindowoverride,dirtyregion);

end;


function createdevice9callback(self, adapter, devtype, wnd, flags, params, device: pointer) : dword; stdcall;
begin
  font := nil;
  result := createdevice9next(self, adapter, devtype, wnd, flags, params, device);
  if font = nil then
  begin
    d3dxcreatefont(idirect3ddevice9(device^),
                   20,
                   20,
                   0,
                   1,
                   false,
                   ansi_charset,
                   out_default_precis,
                   default_quality,
                   default_pitch,
                   'Arial',
                   font);
    mycolor := d3dcolor_rgba(255,0,0,255);
    font.preloadcharacters(0,255);
  end;
  if result = 0 then begin
    if @presentnext = nil then
    begin
      hookcode(getinterfacemethod(device^, 17), @presentcallback, @presentnext)
    end else
      renewhook(@presentnext);
  end;
end;



function direct3dcreate9callback(sdkversion: dword) : dword; stdcall;
begin
  font := nil;
  result := direct3dcreate9next(sdkversion);
  if result <> 0 then
    if @createdevice9next = nil then
      hookcode(getinterfacemethod(result, 16), @createdevice9callback, @createdevice9next)
    else
      renewhook(@createdevice9next);
end;

function hookdirect3d9 : boolean;
begin
  result := hookapi('d3d9.dll', 'Direct3DCreate9', @direct3dcreate9callback, @direct3dcreate9next);
end;

begin
  hookdirect3d9;
  end.



den code kennt ihr ja alle nur wieso funktioniert das nicht?

quelle http://www.delphidev.de/forum/viewtopic.php?id=497&p=2 sagt es funktioniert ich seh bloß nix weiß einer warum ?
MFG
Tobi
  Mit Zitat antworten Zitat