So habe wieder bissi weiter gesucht, und nun komme ich soweit, das mein Hook erfolgreich gesetzt wird - laut MessageBox
BlueHookLib.pas
Delphi-Quellcode:
library d3dxhook;
{ 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,
SysUtils,
BlueHookLib,
BlueFileLog,
Direct3D8,
d3dx8;
{$R *.res}
type
Direct3DCreate8 =
function( D3D_SDK_VERSION: cardinal ): IDirect3D8;
stdcall;
var
oldDirect3DCreate8 : Direct3DCreate8;
newDirect3DCreate8 : Direct3DCreate8;
pIDirect3D8 : IDirect3D8;
function callbackDirect3DCreate8( D3D_SDK_VERSION: cardinal ): IDirect3D8;
stdcall;
begin
Result := oldDirect3DCreate8(D3D_SDK_VERSION);
MessageBox(0, '
callbackDirect3DCreate8', '
Information', MB_ICONINFORMATION);
end;
procedure DllMain(dwReason: DWord);
var
gHook : CDeepHook;
gLog : CDeepLog;
begin
case dwReason
of
DLL_PROCESS_ATTACH:
begin
gHook := CDeepHook.Create(gLog);
oldDirect3DCreate8 := GetProcAddress(GetModuleHandle('
d3d8.dll'), '
Direct3DCreate8');
if not(gHook.HookJMP( @oldDirect3DCreate8, @callbackDirect3DCreate8, @newDirect3DCreate8))
then
MessageBox(0, '
Direct3DCreate8 hooking failed', '
Information', MB_ICONINFORMATION);
end;
end;
end;
begin
DllProc := @DllMain;
DllMain(DLL_PROCESS_ATTACH);
end.
Also ich bekomme eine Message: "Direct3DCreate8 hooked", jedoch keine "callbackDirect3DCreate8". Woran könnte das liegen?
Du derefernzierst p2 einmal und weißt die Adresse von i zu. Das heißt p2 (also der Zeiger auf einen Zeiger) zeigt auf den Zeiger p1 welchen du so auf i zeigen lässt.