unit d3d8hook;
interface
uses Windows, uallHook;
function HookDirect3D8 : boolean;
implementation
var
newSetRenderState8:
function(self: pointer; stateType, state: dword): dword;
stdcall;
newCreateDevice8 :
function(self, adapter, devType, wnd, flags, params, device: pointer) : dword;
stdcall;
newDirect3DCreate8 :
function(sdkVersion: dword) : dword;
stdcall;
function GetInterfaceMethod(
const intf; methodIndex: dword) : pointer;
begin
result := pointer(pointer(dword(pointer(intf)^) + methodIndex * 4)^);
end;
function SetRenderState8Callback(self: pointer; stateType, state: dword) : dword;
stdcall;
begin
end;
function CreateDevice8Callback(self, adapter, devType, wnd, flags, params, device: pointer) : dword;
stdcall;
begin
result := newCreateDevice8(self, adapter, devType, wnd, flags, params, device);
if result = 0
then
if @newSetRenderState8 =
nil then
HookCode(GetInterfaceMethod(device^, 50), @SetRenderState8Callback, @newSetRenderState8);
end;
function Direct3DCreate8Callback(sdkVersion: dword) : dword;
stdcall;
begin
result := newDirect3DCreate8(sdkVersion);
MessageBox(0, '
DEVICE CREATE 8', '
Hook', 0);
if result <> 0
then
if @newCreateDevice8 =
nil then
HookCode(GetInterfaceMethod(result, 15), @CreateDevice8Callback, @newCreateDevice8);
end;
function HookDirect3D8 : boolean;
begin
HookApiIAT('
d3d8.dll', '
Direct3DCreate8', @Direct3DCreate8Callback,@newDirect3DCreate8);
end;
end.