![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include
#include
CApiHook hookDx8;
NewD3Device8 * lpDevice = 0 ;
CGame game;
LRESULT CALLBACK FilterWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
IDirect3D8 * WINAPI Direct3DCreate8_Mine(UINT SDKVersion);
void OnDllLoad( void )
{
game.Init ();
game.ClientSocketInit();
game.HookOpenResFunc ( 0 );
hookDx8.HookApi ( " d3d8.dll " , " Direct3DCreate8 " ,Direct3DCreate8_Mine);
}
IDirect3D8 * WINAPI Direct3DCreate8_Mine(UINT SDKVersion)
{
static int nTimes = 0 ;
IDirect3D8 * d3d8temp = NULL;
IDirect3D8 * (WINAPI * Direct3DCreate8Ptr)(UINT SDKVersion) = NULL;
hookDx8.GetOrgAddr ( & Direct3DCreate8Ptr);
d3d8temp = Direct3DCreate8Ptr (SDKVersion);
while (( ++ nTimes) > 1 )
{
if (nTimes == 2 )
{
TCHAR szGamePath[ 256 ] = { 0 };
GetGamePath (szGamePath, sizeof (szGamePath));
TCHAR szSettingFile[ 256 ] = { 0 };
wsprintf(szSettingFile,TEXT( " %s\\userdata\\systemsettings.ini " ),szGamePath);
if (::GetPrivateProfileInt (TEXT( " Video " ),TEXT( " FullScreen " ), 0 ,szSettingFile)) break ;
}
NewIDirect3D8 * d3d8 = new NewIDirect3D8(d3d8temp);
d3d8temp = (IDirect3D8 * )d3d8;
hookDx8.UnHook ();
break ;
}
return d3d8temp;
}
HRESULT NewIDirect3D8::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,
DWORD BehaviorFlags,D3DPRESENT_PARAMETERS * pPresentationParameters,
IDirect3DDevice8 ** ppReturnedDeviceInterface)
{
HRESULT hr = 0 ;
hGameWnd = hFocusWindow;
game.hGWnd = hFocusWindow;
lpD3D -> CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters, & lpD3DD8bak);
lpDevice = new NewD3Device8(lpD3DD8bak);
/// //Init Data /
if (game.OrgWndProc == 0 )
{
game.OrgWndProc = ::GetWindowLong (game.hGWnd ,GWL_WNDPROC );
if (game.OrgWndProc)
{
::SetWindowLong (game.hGWnd ,GWL_WNDPROC ,(LONG) & FilterWndProc);
}
game.HookOpenResFunc ( 1 );
}
///
* ppReturnedDeviceInterface = (IDirect3DDevice8 * )lpDevice ; // 替换
return hr;
}
LRESULT CALLBACK FilterWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (game.CEGUIWndProc (hWnd,message,wParam,lParam))
return ::CallWindowProc ((WNDPROC)game.OrgWndProc,hWnd,message,wParam,lParam);
else
return 1 ;
}
HRESULT NewD3Device8::EndScene( void )
{
game.MyGuiRender ();
return dxDevice -> EndScene();
}
#include
CApiHook hookDx8;
NewD3Device8 * lpDevice = 0 ;
CGame game;
LRESULT CALLBACK FilterWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
IDirect3D8 * WINAPI Direct3DCreate8_Mine(UINT SDKVersion);
void OnDllLoad( void )
{
game.Init ();
game.ClientSocketInit();
game.HookOpenResFunc ( 0 );
hookDx8.HookApi ( " d3d8.dll " , " Direct3DCreate8 " ,Direct3DCreate8_Mine);
}
IDirect3D8 * WINAPI Direct3DCreate8_Mine(UINT SDKVersion)
{
static int nTimes = 0 ;
IDirect3D8 * d3d8temp = NULL;
IDirect3D8 * (WINAPI * Direct3DCreate8Ptr)(UINT SDKVersion) = NULL;
hookDx8.GetOrgAddr ( & Direct3DCreate8Ptr);
d3d8temp = Direct3DCreate8Ptr (SDKVersion);
while (( ++ nTimes) > 1 )
{
if (nTimes == 2 )
{
TCHAR szGamePath[ 256 ] = { 0 };
GetGamePath (szGamePath, sizeof (szGamePath));
TCHAR szSettingFile[ 256 ] = { 0 };
wsprintf(szSettingFile,TEXT( " %s\\userdata\\systemsettings.ini " ),szGamePath);
if (::GetPrivateProfileInt (TEXT( " Video " ),TEXT( " FullScreen " ), 0 ,szSettingFile)) break ;
}
NewIDirect3D8 * d3d8 = new NewIDirect3D8(d3d8temp);
d3d8temp = (IDirect3D8 * )d3d8;
hookDx8.UnHook ();
break ;
}
return d3d8temp;
}
HRESULT NewIDirect3D8::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,
DWORD BehaviorFlags,D3DPRESENT_PARAMETERS * pPresentationParameters,
IDirect3DDevice8 ** ppReturnedDeviceInterface)
{
HRESULT hr = 0 ;
hGameWnd = hFocusWindow;
game.hGWnd = hFocusWindow;
lpD3D -> CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters, & lpD3DD8bak);
lpDevice = new NewD3Device8(lpD3DD8bak);
/// //Init Data /
if (game.OrgWndProc == 0 )
{
game.OrgWndProc = ::GetWindowLong (game.hGWnd ,GWL_WNDPROC );
if (game.OrgWndProc)
{
::SetWindowLong (game.hGWnd ,GWL_WNDPROC ,(LONG) & FilterWndProc);
}
game.HookOpenResFunc ( 1 );
}
///
* ppReturnedDeviceInterface = (IDirect3DDevice8 * )lpDevice ; // 替换
return hr;
}
LRESULT CALLBACK FilterWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (game.CEGUIWndProc (hWnd,message,wParam,lParam))
return ::CallWindowProc ((WNDPROC)game.OrgWndProc,hWnd,message,wParam,lParam);
else
return 1 ;
}
HRESULT NewD3Device8::EndScene( void )
{
game.MyGuiRender ();
return dxDevice -> EndScene();
}