N64: Fixed the problem with the D3D8 wrapper crashing when exiting or rebooting the core. Made sure to free the libraries so rebooting works. Started to clean up the code.
This commit is contained in:
parent
aaeb645116
commit
88f5bd7088
|
@ -6,6 +6,12 @@ extern "C"
|
||||||
{
|
{
|
||||||
ThreadSafePointerSet IDirect3D8::m_List;
|
ThreadSafePointerSet IDirect3D8::m_List;
|
||||||
|
|
||||||
|
D3D8Wrapper::IDirect3D8::IDirect3D8(D3D8Base::IDirect3D8* real) : D3D8Wrapper::IDirect3DUnknown((IUnknown*) real)
|
||||||
|
{
|
||||||
|
m_pD3D = real;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tries to find the real object in the pointer set, or creates a new wrapped object
|
||||||
D3D8Wrapper::IDirect3D8* D3D8Wrapper::IDirect3D8::GetDirect3D(D3D8Base::IDirect3D8* pD3D)
|
D3D8Wrapper::IDirect3D8* D3D8Wrapper::IDirect3D8::GetDirect3D(D3D8Base::IDirect3D8* pD3D)
|
||||||
{
|
{
|
||||||
D3D8Wrapper::IDirect3D8* p = (D3D8Wrapper::IDirect3D8*) m_List.GetDataPtr(pD3D);
|
D3D8Wrapper::IDirect3D8* p = (D3D8Wrapper::IDirect3D8*) m_List.GetDataPtr(pD3D);
|
||||||
|
@ -20,10 +26,8 @@ extern "C"
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3D8::Release(THIS)
|
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3D8::Release(THIS)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_pUnk->Release();
|
m_pUnk->Release();
|
||||||
|
|
||||||
ULONG ulRef = --m_ulRef;
|
ULONG ulRef = --m_ulRef;
|
||||||
|
@ -37,16 +41,12 @@ extern "C"
|
||||||
return ulRef;
|
return ulRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D8Wrapper::IDirect3D8::IDirect3D8(D3D8Base::IDirect3D8* real) : D3D8Wrapper::IDirect3DUnknown((IUnknown*) real)
|
|
||||||
{
|
|
||||||
m_pD3D = real;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetAdapterDisplayMode(THIS_ UINT Adapter,D3D8Base::D3DDISPLAYMODE* pMode)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetAdapterDisplayMode(THIS_ UINT Adapter,D3D8Base::D3DDISPLAYMODE* pMode)
|
||||||
{
|
{
|
||||||
LOG("displaymode");
|
LOG("IDirect3D8::GetAdapterDisplayMode");
|
||||||
HRESULT hr = m_pD3D->GetAdapterDisplayMode(Adapter, pMode);
|
return m_pD3D->GetAdapterDisplayMode(Adapter, pMode);
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,129 +54,91 @@ extern "C"
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::RegisterSoftwareDevice(void* pInitializeFunction)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::RegisterSoftwareDevice(void* pInitializeFunction)
|
||||||
{
|
{
|
||||||
LOG("RegisterSoftwareDevice");
|
LOG("IDirect3D8::RegisterSoftwareDevice");
|
||||||
HRESULT hr = m_pD3D->RegisterSoftwareDevice(pInitializeFunction);
|
return m_pD3D->RegisterSoftwareDevice(pInitializeFunction);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterCount(THIS)
|
STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterCount(THIS)
|
||||||
{
|
{
|
||||||
LOG("GetAdapterCount");
|
LOG("IDirect3D8::GetAdapterCount");
|
||||||
return m_pD3D->GetAdapterCount();
|
return m_pD3D->GetAdapterCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3D8Base::D3DADAPTER_IDENTIFIER8* pIdentifier)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3D8Base::D3DADAPTER_IDENTIFIER8* pIdentifier)
|
||||||
{
|
{
|
||||||
LOG("GetAdapterIdentifier");
|
LOG("IDirect3D8::GetAdapterIdentifier");
|
||||||
HRESULT hr = m_pD3D->GetAdapterIdentifier(Adapter,Flags,pIdentifier);
|
return m_pD3D->GetAdapterIdentifier(Adapter,Flags,pIdentifier);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterModeCount(UINT Adapter)
|
STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterModeCount(UINT Adapter)
|
||||||
{
|
{
|
||||||
LOG("GetAdapterModeCount");
|
LOG("IDirect3D8::GetAdapterModeCount");
|
||||||
return m_pD3D->GetAdapterModeCount(Adapter);
|
return m_pD3D->GetAdapterModeCount(Adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::EnumAdapterModes(UINT Adapter,UINT Mode,D3D8Base::D3DDISPLAYMODE* pMode)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::EnumAdapterModes(UINT Adapter,UINT Mode,D3D8Base::D3DDISPLAYMODE* pMode)
|
||||||
{
|
{
|
||||||
LOG("EnumAdapterModes");
|
LOG("IDirect3D8::EnumAdapterModes");
|
||||||
HRESULT hr = m_pD3D->EnumAdapterModes(Adapter,Mode,pMode);
|
return m_pD3D->EnumAdapterModes(Adapter,Mode,pMode);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceType(UINT Adapter,D3D8Base::D3DDEVTYPE CheckType,D3D8Base::D3DFORMAT DisplayFormat,D3D8Base::D3DFORMAT BackBufferFormat,BOOL Windowed)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceType(UINT Adapter,D3D8Base::D3DDEVTYPE CheckType,D3D8Base::D3DFORMAT DisplayFormat,D3D8Base::D3DFORMAT BackBufferFormat,BOOL Windowed)
|
||||||
{
|
{
|
||||||
LOG("CheckDeviceType");
|
LOG("IDirect3D8::CheckDeviceType");
|
||||||
HRESULT hr = m_pD3D->CheckDeviceType(Adapter,CheckType,DisplayFormat,BackBufferFormat,Windowed);
|
return m_pD3D->CheckDeviceType(Adapter,CheckType,DisplayFormat,BackBufferFormat,Windowed);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceFormat(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,DWORD Usage,D3D8Base::D3DRESOURCETYPE RType,D3D8Base::D3DFORMAT CheckFormat)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceFormat(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,DWORD Usage,D3D8Base::D3DRESOURCETYPE RType,D3D8Base::D3DFORMAT CheckFormat)
|
||||||
{
|
{
|
||||||
LOG("CheckDeviceFormat");
|
LOG("IDirect3D8::CheckDeviceFormat");
|
||||||
HRESULT hr = m_pD3D->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat);
|
return m_pD3D->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceMultiSampleType(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT SurfaceFormat,BOOL Windowed,D3D8Base::D3DMULTISAMPLE_TYPE MultiSampleType)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceMultiSampleType(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT SurfaceFormat,BOOL Windowed,D3D8Base::D3DMULTISAMPLE_TYPE MultiSampleType)
|
||||||
{
|
{
|
||||||
LOG("CheckDeviceMultiSampleType");
|
LOG("IDirect3D8::CheckDeviceMultiSampleType");
|
||||||
HRESULT hr = m_pD3D->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType);
|
return m_pD3D->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDepthStencilMatch(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,D3D8Base::D3DFORMAT RenderTargetFormat,D3D8Base::D3DFORMAT DepthStencilFormat)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDepthStencilMatch(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,D3D8Base::D3DFORMAT RenderTargetFormat,D3D8Base::D3DFORMAT DepthStencilFormat)
|
||||||
{
|
{
|
||||||
LOG("CheckDepthStencilMatch");
|
LOG("IDirect3D8::CheckDepthStencilMatch");
|
||||||
HRESULT hr = m_pD3D->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat);
|
return m_pD3D->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetDeviceCaps(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DCAPS8* pCaps)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::GetDeviceCaps(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DCAPS8* pCaps)
|
||||||
{
|
{
|
||||||
LOG("GetDeviceCaps");
|
LOG("IDirect3D8::GetDeviceCaps");
|
||||||
HRESULT hr = m_pD3D->GetDeviceCaps(Adapter,DeviceType,pCaps);
|
return m_pD3D->GetDeviceCaps(Adapter,DeviceType,pCaps);
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(HMONITOR) D3D8Wrapper::IDirect3D8::GetAdapterMonitor(UINT Adapter)
|
STDMETHODIMP_(HMONITOR) D3D8Wrapper::IDirect3D8::GetAdapterMonitor(UINT Adapter)
|
||||||
{
|
{
|
||||||
LOG("GetAdapterMonitor");
|
LOG("IDirect3D8::GetAdapterMonitor");
|
||||||
return m_pD3D->GetAdapterMonitor(Adapter);
|
return m_pD3D->GetAdapterMonitor(Adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3D8::CreateDevice(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DDevice8** ppReturnedDeviceInterface)
|
STDMETHODIMP D3D8Wrapper::IDirect3D8::CreateDevice(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DDevice8** ppReturnedDeviceInterface)
|
||||||
{
|
{
|
||||||
LOG("createdevice");
|
LOG("IDirect3D8::CreateDevice");
|
||||||
LOG(pPresentationParameters);
|
D3D8Base::IDirect3DDevice8* base_device = NULL;
|
||||||
if (pPresentationParameters != NULL)
|
|
||||||
{
|
|
||||||
LOG(pPresentationParameters->BackBufferWidth);
|
|
||||||
LOG(pPresentationParameters->BackBufferHeight);
|
|
||||||
LOG(pPresentationParameters->BackBufferFormat);
|
|
||||||
LOG(pPresentationParameters->BackBufferCount);
|
|
||||||
LOG(pPresentationParameters->MultiSampleType);
|
|
||||||
LOG(pPresentationParameters->SwapEffect);
|
|
||||||
LOG(pPresentationParameters->hDeviceWindow);
|
|
||||||
LOG(pPresentationParameters->Windowed);
|
|
||||||
LOG(pPresentationParameters->EnableAutoDepthStencil);
|
|
||||||
LOG(pPresentationParameters->Flags);
|
|
||||||
LOG(pPresentationParameters->FullScreen_RefreshRateInHz);
|
|
||||||
LOG(pPresentationParameters->FullScreen_PresentationInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
D3D8Base::IDirect3DDevice8* fd = NULL;
|
HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,&base_device);
|
||||||
|
|
||||||
D3D8Base::IDirect3DDevice8** fdp = &fd;
|
// Wrap the real object
|
||||||
|
D3D8Wrapper::IDirect3DDevice8* f = D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(base_device);
|
||||||
|
|
||||||
LOG(fd);
|
last_device = f;
|
||||||
|
|
||||||
HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,fdp);//(D3D8Base::IDirect3DDevice8**)ppReturnedDeviceInterface);
|
// Return our wrapped object
|
||||||
LOG(fd);
|
*ppReturnedDeviceInterface = f;
|
||||||
LOG(hr);
|
|
||||||
|
|
||||||
|
|
||||||
D3D8Wrapper::IDirect3DDevice8* f = D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(fd);
|
|
||||||
|
|
||||||
*ppReturnedDeviceInterface = f;//(D3D8Wrapper::IDirect3DDevice8*)fd;
|
|
||||||
|
|
||||||
//hr = D3DERR_NOTAVAILABLE;
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ extern "C"
|
||||||
{
|
{
|
||||||
p = new D3D8Wrapper::IDirect3DDevice8(pDevice);
|
p = new D3D8Wrapper::IDirect3DDevice8(pDevice);
|
||||||
m_List.AddMember(pDevice, p);
|
m_List.AddMember(pDevice, p);
|
||||||
last_device = p;
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +250,7 @@ extern "C"
|
||||||
|
|
||||||
HRESULT hr = m_pDevice->CreateTexture(Width,Height,Levels,Usage,Format,Pool,&fd);//ppTexture);
|
HRESULT hr = m_pDevice->CreateTexture(Width,Height,Levels,Usage,Format,Pool,&fd);//ppTexture);
|
||||||
|
|
||||||
D3D8Wrapper::IDirect3DTexture8* f = new D3D8Wrapper::IDirect3DTexture8(fd);
|
D3D8Wrapper::IDirect3DTexture8* f = D3D8Wrapper::IDirect3DTexture8::GetTexture(fd);
|
||||||
|
|
||||||
*ppTexture = f;
|
*ppTexture = f;
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ extern "C"
|
||||||
{
|
{
|
||||||
D3D8Wrapper::IDirect3DResource8::IDirect3DResource8(D3D8Base::IDirect3DResource8* pResource) : IDirect3DUnknown((IUnknown*) pResource)
|
D3D8Wrapper::IDirect3DResource8::IDirect3DResource8(D3D8Base::IDirect3DResource8* pResource) : IDirect3DUnknown((IUnknown*) pResource)
|
||||||
{
|
{
|
||||||
LOG("IDirect3DResource8");
|
LOG("IDirect3DResource8 from base " << pResource << " made " << this);
|
||||||
m_pD3D = pResource;
|
m_pD3D = pResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D8Wrapper::IDirect3DResource8::IDirect3DResource8(D3D8Wrapper::IDirect3DResource8* pResource) : IDirect3DUnknown((IUnknown*) pResource)
|
D3D8Wrapper::IDirect3DResource8::IDirect3DResource8(D3D8Wrapper::IDirect3DResource8* pResource) : IDirect3DUnknown((IUnknown*) pResource)
|
||||||
{
|
{
|
||||||
LOG("IDirect3DResource8 -- 2");
|
LOG("IDirect3DResource8 from wrapped " << pResource << " made " << this);
|
||||||
m_pD3D = pResource->getReal();
|
m_pD3D = pResource->getReal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,16 +22,19 @@ extern "C"
|
||||||
if( p == NULL )
|
if( p == NULL )
|
||||||
{
|
{
|
||||||
p = new D3D8Wrapper::IDirect3DResource8(pSwapChain);
|
p = new D3D8Wrapper::IDirect3DResource8(pSwapChain);
|
||||||
|
LOG("IDirect3DResource8::GetResource " << pSwapChain << " created new " << p)
|
||||||
m_List.AddMember(pSwapChain, p);
|
m_List.AddMember(pSwapChain, p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->m_ulRef++;
|
p->m_ulRef++;
|
||||||
|
LOG("IDirect3DResource8::GetResource " << pSwapChain << " found existing " << p)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DResource8::Release(THIS)
|
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DResource8::Release(THIS)
|
||||||
{
|
{
|
||||||
|
LOG("IDirect3DResource8::Release " << this);
|
||||||
m_pUnk->Release();
|
m_pUnk->Release();
|
||||||
|
|
||||||
ULONG ulRef = --m_ulRef;
|
ULONG ulRef = --m_ulRef;
|
||||||
|
|
|
@ -4,12 +4,45 @@ extern "C"
|
||||||
{
|
{
|
||||||
namespace D3D8Wrapper
|
namespace D3D8Wrapper
|
||||||
{
|
{
|
||||||
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DTexture8::m_List;
|
||||||
|
|
||||||
D3D8Wrapper::IDirect3DTexture8::IDirect3DTexture8(D3D8Base::IDirect3DTexture8* pTexture) : IDirect3DBaseTexture8((D3D8Base::IDirect3DBaseTexture8*) pTexture)
|
D3D8Wrapper::IDirect3DTexture8::IDirect3DTexture8(D3D8Base::IDirect3DTexture8* pTexture) : IDirect3DBaseTexture8((D3D8Base::IDirect3DBaseTexture8*) pTexture)
|
||||||
{
|
{
|
||||||
LOG("IDirect3DBaseTexture8");
|
LOG("IDirect3DTexture8");
|
||||||
m_pD3D = pTexture;
|
m_pD3D = pTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D3D8Wrapper::IDirect3DTexture8* D3D8Wrapper::IDirect3DTexture8::GetTexture(D3D8Base::IDirect3DTexture8* pTexture)
|
||||||
|
{
|
||||||
|
D3D8Wrapper::IDirect3DTexture8* p = (D3D8Wrapper::IDirect3DTexture8*) m_List.GetDataPtr(pTexture);
|
||||||
|
if( p == NULL )
|
||||||
|
{
|
||||||
|
p = new D3D8Wrapper::IDirect3DTexture8(pTexture);
|
||||||
|
LOG("IDirect3DTexture8::GetTexture " << pTexture << " created new " << p)
|
||||||
|
m_List.AddMember(pTexture, p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->m_ulRef++;
|
||||||
|
LOG("IDirect3DTexture8::GetTexture " << pTexture << " found existing " << p)
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DTexture8::Release(THIS)
|
||||||
|
{
|
||||||
|
LOG("IDirect3DTexture8::Release " << this);
|
||||||
|
m_pUnk->Release();
|
||||||
|
|
||||||
|
ULONG ulRef = --m_ulRef;
|
||||||
|
if(ulRef == 0)
|
||||||
|
{
|
||||||
|
m_List.DeleteMember(GetResource());
|
||||||
|
delete this;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ulRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3D8Base::D3DSURFACE_DESC *pDesc) PURE;*/
|
/*STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3D8Base::D3DSURFACE_DESC *pDesc) PURE;*/
|
||||||
STDMETHODIMP D3D8Wrapper::IDirect3DTexture8::GetLevelDesc(UINT Level,D3D8Base::D3DSURFACE_DESC *pDesc)
|
STDMETHODIMP D3D8Wrapper::IDirect3DTexture8::GetLevelDesc(UINT Level,D3D8Base::D3DSURFACE_DESC *pDesc)
|
||||||
|
|
|
@ -6,7 +6,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
D3D8Wrapper::IDirect3DVolumeTexture8::IDirect3DVolumeTexture8(D3D8Base::IDirect3DVolumeTexture8* pTexture) : IDirect3DBaseTexture8((D3D8Base::IDirect3DBaseTexture8*) pTexture)
|
D3D8Wrapper::IDirect3DVolumeTexture8::IDirect3DVolumeTexture8(D3D8Base::IDirect3DVolumeTexture8* pTexture) : IDirect3DBaseTexture8((D3D8Base::IDirect3DBaseTexture8*) pTexture)
|
||||||
{
|
{
|
||||||
LOG("IDirect3DBaseTexture8");
|
LOG("IDirect3DVolumeTexture8");
|
||||||
m_pD3D = pTexture;
|
m_pD3D = pTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ HMODULE hD3D;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DDevice8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DDevice8::m_List;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DResource8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DResource8::m_List;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DBaseTexture8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DBaseTexture8::m_List;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DTexture8::m_List;
|
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DVolumeTexture8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DVolumeTexture8::m_List;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DCubeTexture8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DCubeTexture8::m_List;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DVertexBuffer8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DVertexBuffer8::m_List;
|
||||||
|
@ -16,9 +15,6 @@ ThreadSafePointerSet D3D8Wrapper::IDirect3DSurface8::m_List;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DVolume8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DVolume8::m_List;
|
||||||
ThreadSafePointerSet D3D8Wrapper::IDirect3DSwapChain8::m_List;
|
ThreadSafePointerSet D3D8Wrapper::IDirect3DSwapChain8::m_List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
namespace D3D8Wrapper
|
namespace D3D8Wrapper
|
||||||
|
@ -28,26 +24,31 @@ extern "C"
|
||||||
|
|
||||||
D3D8Wrapper::IDirect3D8* WINAPI Direct3DCreate8(UINT Version)
|
D3D8Wrapper::IDirect3D8* WINAPI Direct3DCreate8(UINT Version)
|
||||||
{
|
{
|
||||||
LOG("I'M IN UR VIDJA GAME");
|
// Get the real DLL path
|
||||||
|
// Might be unsafe
|
||||||
|
CHAR dll_path[1024];
|
||||||
|
GetSystemDirectory(dll_path,1024);
|
||||||
|
strcat(dll_path,"\\d3d8.dll");
|
||||||
|
|
||||||
hD3D = LoadLibrary("C:\\Windows\\SysWOW64\\d3d8.dll");
|
hD3D = LoadLibrary(dll_path);
|
||||||
|
|
||||||
D3D8Wrapper::D3DCREATE pCreate = (D3D8Wrapper::D3DCREATE)GetProcAddress(hD3D, "Direct3DCreate8");
|
D3D8Wrapper::D3DCREATE pCreate = (D3D8Wrapper::D3DCREATE)GetProcAddress(hD3D, "Direct3DCreate8");
|
||||||
|
|
||||||
// Contains our real object
|
// Use the real Direct3DCreate8 to make the base object
|
||||||
D3D8Base::IDirect3D8* pD3D = pCreate(D3D_SDK_VERSION);
|
D3D8Base::IDirect3D8* pD3D = pCreate(D3D_SDK_VERSION);
|
||||||
|
|
||||||
|
// Wrap the object
|
||||||
D3D8Wrapper::IDirect3D8* fD3D = D3D8Wrapper::IDirect3D8::GetDirect3D(pD3D);
|
D3D8Wrapper::IDirect3D8* fD3D = D3D8Wrapper::IDirect3D8::GetDirect3D(pD3D);
|
||||||
|
|
||||||
MessageBox(NULL, "", "HAX", MB_OK);
|
return fD3D;
|
||||||
return fD3D; //D3D8Base::Direct3DCreate8(Version);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
__declspec(dllexport) void __cdecl CloseDLL()
|
||||||
|
{
|
||||||
|
FreeLibrary(hD3D);
|
||||||
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void __cdecl SetRenderingCallback(void (*callback)(int))
|
__declspec(dllexport) void __cdecl SetRenderingCallback(void (*callback)(int))
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,19 +82,15 @@ extern "C"
|
||||||
D3D8Base::IDirect3D8* m_pD3D;
|
D3D8Base::IDirect3D8* m_pD3D;
|
||||||
static ThreadSafePointerSet m_List;
|
static ThreadSafePointerSet m_List;
|
||||||
public:
|
public:
|
||||||
STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj)
|
IDirect3D8(D3D8Base::IDirect3D8*);
|
||||||
{
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
inline D3D8Base::IDirect3D8* GetDirect3D8() { return m_pD3D; }
|
|
||||||
|
|
||||||
|
inline D3D8Base::IDirect3D8* GetDirect3D8() { return m_pD3D; }
|
||||||
static IDirect3D8* GetDirect3D(D3D8Base::IDirect3D8* pD3D);
|
static IDirect3D8* GetDirect3D(D3D8Base::IDirect3D8* pD3D);
|
||||||
|
|
||||||
IDirect3D8(D3D8Base::IDirect3D8*);
|
/*** IDirect3DUnknown methods ***/
|
||||||
STDMETHOD_(ULONG,Release)(THIS);
|
STDMETHOD_(ULONG,Release)(THIS);
|
||||||
|
|
||||||
/*** IDirect3D8 methods ***/
|
/*** IDirect3D8 methods ***/
|
||||||
|
|
||||||
STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction);
|
STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction);
|
||||||
STDMETHOD_(UINT, GetAdapterCount)(THIS);
|
STDMETHOD_(UINT, GetAdapterCount)(THIS);
|
||||||
STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3D8Base::D3DADAPTER_IDENTIFIER8* pIdentifier);
|
STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3D8Base::D3DADAPTER_IDENTIFIER8* pIdentifier);
|
||||||
|
@ -108,7 +104,6 @@ extern "C"
|
||||||
STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DCAPS8* pCaps);
|
STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DCAPS8* pCaps);
|
||||||
STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter);
|
STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter);
|
||||||
STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DDevice8** ppReturnedDeviceInterface);
|
STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DDevice8** ppReturnedDeviceInterface);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class IDirect3DDevice8 : public IDirect3DUnknown
|
class IDirect3DDevice8 : public IDirect3DUnknown
|
||||||
|
@ -317,8 +312,12 @@ extern "C"
|
||||||
static ThreadSafePointerSet m_List;
|
static ThreadSafePointerSet m_List;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
STDMETHOD_(ULONG,Release)(THIS);
|
||||||
|
|
||||||
IDirect3DTexture8(D3D8Base::IDirect3DTexture8*);
|
IDirect3DTexture8(D3D8Base::IDirect3DTexture8*);
|
||||||
|
|
||||||
|
static D3D8Wrapper::IDirect3DTexture8* GetTexture(D3D8Base::IDirect3DTexture8*);
|
||||||
|
|
||||||
//D3D8Base::IDirect3DTexture8* getReal2();
|
//D3D8Base::IDirect3DTexture8* getReal2();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,16 @@ static int l_PluginInit = 0;
|
||||||
HMODULE JaboDLL;
|
HMODULE JaboDLL;
|
||||||
HWND hWnd_jabo;
|
HWND hWnd_jabo;
|
||||||
|
|
||||||
|
HANDLE window_thread = NULL;
|
||||||
|
|
||||||
HMODULE D3D8Dll;
|
HMODULE D3D8Dll;
|
||||||
|
|
||||||
typedef void (*ptr_D3D8_SetRenderingCallback)(void (*callback)(int));
|
typedef void (*ptr_D3D8_SetRenderingCallback)(void (*callback)(int));
|
||||||
ptr_D3D8_SetRenderingCallback D3D8_SetRenderingCallback = NULL;
|
ptr_D3D8_SetRenderingCallback D3D8_SetRenderingCallback = NULL;
|
||||||
typedef void (*ptr_D3D8_ReadScreen)(void *dest, int *width, int *height);
|
typedef void (*ptr_D3D8_ReadScreen)(void *dest, int *width, int *height);
|
||||||
ptr_D3D8_ReadScreen D3D8_ReadScreen = NULL;
|
ptr_D3D8_ReadScreen D3D8_ReadScreen = NULL;
|
||||||
|
typedef void (*ptr_D3D8_CloseDLL)();
|
||||||
|
ptr_D3D8_CloseDLL D3D8_CloseDLL = NULL;
|
||||||
|
|
||||||
void setup_jabo_functions()
|
void setup_jabo_functions()
|
||||||
{
|
{
|
||||||
|
@ -80,6 +84,7 @@ void setup_jabo_functions()
|
||||||
{
|
{
|
||||||
D3D8_SetRenderingCallback = (ptr_D3D8_SetRenderingCallback)GetProcAddress(D3D8Dll,"SetRenderingCallback");
|
D3D8_SetRenderingCallback = (ptr_D3D8_SetRenderingCallback)GetProcAddress(D3D8Dll,"SetRenderingCallback");
|
||||||
D3D8_ReadScreen = (ptr_D3D8_ReadScreen)GetProcAddress(D3D8Dll,"ReadScreen");
|
D3D8_ReadScreen = (ptr_D3D8_ReadScreen)GetProcAddress(D3D8Dll,"ReadScreen");
|
||||||
|
D3D8_CloseDLL = (ptr_D3D8_CloseDLL)GetProcAddress(D3D8Dll,"CloseDLL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +152,11 @@ EXPORT m64p_error CALL PluginShutdown(void)
|
||||||
LOG("API WRAPPER:\t PluginShutdown")
|
LOG("API WRAPPER:\t PluginShutdown")
|
||||||
OldAPI::CloseDLL();
|
OldAPI::CloseDLL();
|
||||||
|
|
||||||
|
TerminateThread(window_thread,0);
|
||||||
|
D3D8_CloseDLL();
|
||||||
|
FreeLibrary(D3D8Dll);
|
||||||
|
FreeLibrary(JaboDLL);
|
||||||
|
|
||||||
if (!l_PluginInit)
|
if (!l_PluginInit)
|
||||||
return M64ERR_NOT_INIT;
|
return M64ERR_NOT_INIT;
|
||||||
|
|
||||||
|
@ -416,7 +426,7 @@ BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call,LPVOID lpReser
|
||||||
{
|
{
|
||||||
if(ul_reason_for_call==DLL_PROCESS_ATTACH) {
|
if(ul_reason_for_call==DLL_PROCESS_ATTACH) {
|
||||||
inj_hModule = hModule;
|
inj_hModule = hModule;
|
||||||
CreateThread(0, NULL, ThreadProc, (LPVOID)"Window Title", NULL, NULL);
|
window_thread = CreateThread(0, NULL, ThreadProc, (LPVOID)"Window Title", NULL, NULL);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue