AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Directx, Text in fremder app anzeigen, dll
Thema durchsuchen
Ansicht
Themen-Optionen

Directx, Text in fremder app anzeigen, dll

Ein Thema von Darkpara · begonnen am 18. Nov 2007
Antwort Antwort
Darkpara

Registriert seit: 18. Sep 2006
1 Beiträge
 
#1

Directx, Text in fremder app anzeigen, dll

  Alt 18. Nov 2007, 15:12
Moin,

habe diese frage auch schon im Delphi-Forum gepostet nur konnte mir bisjetzt noch niemand helfen also dachte ich mir ich frag ma hier nach

ich versuche ein kleines programm zu schreiben mit dem ich mir fps oder später vl. auch ma was anderes im spiel anzeigen lassen kann.
vom prinzip gleich wie das teamspeak overlay oder fraps, die zeigen auch informationen in einem fullscreen spiel an.

hab bisel rumgelesen und bin auch hooks gestossen, mit welchen ich mich leider kaum auskenne.

so nun zur frage hier habe ich eine dll gefunden mit welcher es möglich sein soll texte in spielen auszugeben


Delphi-Quellcode:
   
library directdll;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }


uses
  Windows,
  madCodeHook;

{$R *.res}

var
  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;

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 : trect;
begin
  rect.top := y; rect.left := x;
  rect.bottom := y+1; rect.right := x+1;
  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
  result := presentnext(self,sourcerect,destrect,destwindowoverride,dirtyregion);
  showtext(100,100,'test',mycolor);
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.

nur krig ich hier viele fehler:
Delphi-Quellcode:
[Pascal Error] directdll.dpr(23): E2003 Undeclared identifier: 'id3dxfont'
[Pascal Error] directdll.dpr(24): E2003 Undeclared identifier: 'td3dcolor'
[Pascal Error] directdll.dpr(37): E2066 Missing operator or semicolon
[Pascal Error] directdll.dpr(37): E2010 Incompatible types: 'HDCand 'Pointer'
[Pascal Error] directdll.dpr(37): E2034 Too many actual parameters
[Pascal Error] directdll.dpr(45): E2003 Undeclared identifier: 'rect'
[Pascal Error] directdll.dpr(45): E2003 Undeclared identifier: 'y'
[Pascal Error] directdll.dpr(45): E2003 Undeclared identifier: 'x'
[Pascal Error] directdll.dpr(53): E2015 Operator not applicable to this operand type
[Pascal Error] directdll.dpr(55): E2003 Undeclared identifier: 'd3dxcreatefont'
[Pascal Error] directdll.dpr(55): E2003 Undeclared identifier: 'idirect3ddevice9'
[Pascal Error] directdll.dpr(67): E2003 Undeclared identifier: 'd3dcolor_rgba'
[Pascal Error] directdll.dpr(68): E2066 Missing operator or semicolon
wo genau muss ich den die variablen deklarieren in einer dll datei?
und die id3dxfont, td3color... ect, sollen mit nem header deklariert sein, wo krig ich so nen header her?

und nun die letzt frage, wenn ich die dll dann injecte wie use ich die funktionen dieser dll in meinem program?

danke schon mal im voraus..
  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 05:11 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz