From 88f5bd7088a003ad56de3707de45aa072df4938a Mon Sep 17 00:00:00 2001 From: pjgat09 Date: Sun, 20 Jul 2014 02:38:57 +0000 Subject: [PATCH] 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. --- .../D3D8Interceptor/Direct3D8Functions.cpp | 110 ++++++------------ .../Direct3DDevice8Functions.cpp | 3 +- .../Direct3DResource8Functions.cpp | 7 +- .../Direct3DTexture8Functions.cpp | 35 +++++- .../Direct3DVolumeTexture8Functions.cpp | 2 +- .../D3D8Interceptor/d3d8Wrapper.cpp | 25 ++-- libmupen64plus/D3D8Interceptor/d3d8Wrapper.h | 19 ++- .../mupen64plus-video-jabo/main.cpp | 12 +- 8 files changed, 110 insertions(+), 103 deletions(-) diff --git a/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp b/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp index 088d02889f..0c1bd0048d 100644 --- a/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp +++ b/libmupen64plus/D3D8Interceptor/Direct3D8Functions.cpp @@ -6,6 +6,12 @@ extern "C" { 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* p = (D3D8Wrapper::IDirect3D8*) m_List.GetDataPtr(pD3D); @@ -20,10 +26,8 @@ extern "C" return p; } - STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3D8::Release(THIS) { - m_pUnk->Release(); ULONG ulRef = --m_ulRef; @@ -37,16 +41,12 @@ extern "C" 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) { - LOG("displaymode"); - HRESULT hr = m_pD3D->GetAdapterDisplayMode(Adapter, pMode); - return hr; + LOG("IDirect3D8::GetAdapterDisplayMode"); + return m_pD3D->GetAdapterDisplayMode(Adapter, pMode); } @@ -54,129 +54,91 @@ extern "C" STDMETHODIMP D3D8Wrapper::IDirect3D8::RegisterSoftwareDevice(void* pInitializeFunction) { - LOG("RegisterSoftwareDevice"); - HRESULT hr = m_pD3D->RegisterSoftwareDevice(pInitializeFunction); - - return hr; + LOG("IDirect3D8::RegisterSoftwareDevice"); + return m_pD3D->RegisterSoftwareDevice(pInitializeFunction); } STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterCount(THIS) { - LOG("GetAdapterCount"); + LOG("IDirect3D8::GetAdapterCount"); return m_pD3D->GetAdapterCount(); } STDMETHODIMP D3D8Wrapper::IDirect3D8::GetAdapterIdentifier(UINT Adapter,DWORD Flags,D3D8Base::D3DADAPTER_IDENTIFIER8* pIdentifier) { - LOG("GetAdapterIdentifier"); - HRESULT hr = m_pD3D->GetAdapterIdentifier(Adapter,Flags,pIdentifier); - - return hr; + LOG("IDirect3D8::GetAdapterIdentifier"); + return m_pD3D->GetAdapterIdentifier(Adapter,Flags,pIdentifier); } STDMETHODIMP_(UINT) D3D8Wrapper::IDirect3D8::GetAdapterModeCount(UINT Adapter) { - LOG("GetAdapterModeCount"); + LOG("IDirect3D8::GetAdapterModeCount"); return m_pD3D->GetAdapterModeCount(Adapter); } STDMETHODIMP D3D8Wrapper::IDirect3D8::EnumAdapterModes(UINT Adapter,UINT Mode,D3D8Base::D3DDISPLAYMODE* pMode) { - LOG("EnumAdapterModes"); - HRESULT hr = m_pD3D->EnumAdapterModes(Adapter,Mode,pMode); - - return hr; + LOG("IDirect3D8::EnumAdapterModes"); + return m_pD3D->EnumAdapterModes(Adapter,Mode,pMode); } STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceType(UINT Adapter,D3D8Base::D3DDEVTYPE CheckType,D3D8Base::D3DFORMAT DisplayFormat,D3D8Base::D3DFORMAT BackBufferFormat,BOOL Windowed) { - LOG("CheckDeviceType"); - HRESULT hr = m_pD3D->CheckDeviceType(Adapter,CheckType,DisplayFormat,BackBufferFormat,Windowed); - - return hr; + LOG("IDirect3D8::CheckDeviceType"); + return m_pD3D->CheckDeviceType(Adapter,CheckType,DisplayFormat,BackBufferFormat,Windowed); } STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceFormat(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,DWORD Usage,D3D8Base::D3DRESOURCETYPE RType,D3D8Base::D3DFORMAT CheckFormat) { - LOG("CheckDeviceFormat"); - HRESULT hr = m_pD3D->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat); - - return hr; + LOG("IDirect3D8::CheckDeviceFormat"); + return m_pD3D->CheckDeviceFormat(Adapter,DeviceType,AdapterFormat,Usage,RType,CheckFormat); } STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDeviceMultiSampleType(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT SurfaceFormat,BOOL Windowed,D3D8Base::D3DMULTISAMPLE_TYPE MultiSampleType) { - LOG("CheckDeviceMultiSampleType"); - HRESULT hr = m_pD3D->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType); - - return hr; + LOG("IDirect3D8::CheckDeviceMultiSampleType"); + return m_pD3D->CheckDeviceMultiSampleType(Adapter,DeviceType,SurfaceFormat,Windowed,MultiSampleType); } STDMETHODIMP D3D8Wrapper::IDirect3D8::CheckDepthStencilMatch(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DFORMAT AdapterFormat,D3D8Base::D3DFORMAT RenderTargetFormat,D3D8Base::D3DFORMAT DepthStencilFormat) { - LOG("CheckDepthStencilMatch"); - HRESULT hr = m_pD3D->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat); - - return hr; + LOG("IDirect3D8::CheckDepthStencilMatch"); + return m_pD3D->CheckDepthStencilMatch(Adapter,DeviceType,AdapterFormat,RenderTargetFormat,DepthStencilFormat); } STDMETHODIMP D3D8Wrapper::IDirect3D8::GetDeviceCaps(UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,D3D8Base::D3DCAPS8* pCaps) { - LOG("GetDeviceCaps"); - HRESULT hr = m_pD3D->GetDeviceCaps(Adapter,DeviceType,pCaps); - - return hr; + LOG("IDirect3D8::GetDeviceCaps"); + return m_pD3D->GetDeviceCaps(Adapter,DeviceType,pCaps); } STDMETHODIMP_(HMONITOR) D3D8Wrapper::IDirect3D8::GetAdapterMonitor(UINT Adapter) { - LOG("GetAdapterMonitor"); + LOG("IDirect3D8::GetAdapterMonitor"); 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) { - LOG("createdevice"); - LOG(pPresentationParameters); - 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; + LOG("IDirect3D8::CreateDevice"); + D3D8Base::IDirect3DDevice8* base_device = NULL; - D3D8Base::IDirect3DDevice8** fdp = &fd; + HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,&base_device); - LOG(fd); + // Wrap the real object + D3D8Wrapper::IDirect3DDevice8* f = D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(base_device); - HRESULT hr = m_pD3D->CreateDevice(Adapter,DeviceType,hFocusWindow,BehaviorFlags,pPresentationParameters,fdp);//(D3D8Base::IDirect3DDevice8**)ppReturnedDeviceInterface); - LOG(fd); - LOG(hr); + last_device = f; - - D3D8Wrapper::IDirect3DDevice8* f = D3D8Wrapper::IDirect3DDevice8::GetDirect3DDevice(fd); - - *ppReturnedDeviceInterface = f;//(D3D8Wrapper::IDirect3DDevice8*)fd; - - //hr = D3DERR_NOTAVAILABLE; + // Return our wrapped object + *ppReturnedDeviceInterface = f; return hr; } diff --git a/libmupen64plus/D3D8Interceptor/Direct3DDevice8Functions.cpp b/libmupen64plus/D3D8Interceptor/Direct3DDevice8Functions.cpp index 7a05fcd636..6e93fc370f 100644 --- a/libmupen64plus/D3D8Interceptor/Direct3DDevice8Functions.cpp +++ b/libmupen64plus/D3D8Interceptor/Direct3DDevice8Functions.cpp @@ -20,7 +20,6 @@ extern "C" { p = new D3D8Wrapper::IDirect3DDevice8(pDevice); m_List.AddMember(pDevice, p); - last_device = p; return p; } @@ -251,7 +250,7 @@ extern "C" 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; diff --git a/libmupen64plus/D3D8Interceptor/Direct3DResource8Functions.cpp b/libmupen64plus/D3D8Interceptor/Direct3DResource8Functions.cpp index b74f764db4..1f23eb7b46 100644 --- a/libmupen64plus/D3D8Interceptor/Direct3DResource8Functions.cpp +++ b/libmupen64plus/D3D8Interceptor/Direct3DResource8Functions.cpp @@ -6,13 +6,13 @@ extern "C" { D3D8Wrapper::IDirect3DResource8::IDirect3DResource8(D3D8Base::IDirect3DResource8* pResource) : IDirect3DUnknown((IUnknown*) pResource) { - LOG("IDirect3DResource8"); + LOG("IDirect3DResource8 from base " << pResource << " made " << this); m_pD3D = pResource; } D3D8Wrapper::IDirect3DResource8::IDirect3DResource8(D3D8Wrapper::IDirect3DResource8* pResource) : IDirect3DUnknown((IUnknown*) pResource) { - LOG("IDirect3DResource8 -- 2"); + LOG("IDirect3DResource8 from wrapped " << pResource << " made " << this); m_pD3D = pResource->getReal(); } @@ -22,16 +22,19 @@ extern "C" if( p == NULL ) { p = new D3D8Wrapper::IDirect3DResource8(pSwapChain); + LOG("IDirect3DResource8::GetResource " << pSwapChain << " created new " << p) m_List.AddMember(pSwapChain, p); return p; } p->m_ulRef++; + LOG("IDirect3DResource8::GetResource " << pSwapChain << " found existing " << p) return p; } STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DResource8::Release(THIS) { + LOG("IDirect3DResource8::Release " << this); m_pUnk->Release(); ULONG ulRef = --m_ulRef; diff --git a/libmupen64plus/D3D8Interceptor/Direct3DTexture8Functions.cpp b/libmupen64plus/D3D8Interceptor/Direct3DTexture8Functions.cpp index 14028cb88f..46bbb72bce 100644 --- a/libmupen64plus/D3D8Interceptor/Direct3DTexture8Functions.cpp +++ b/libmupen64plus/D3D8Interceptor/Direct3DTexture8Functions.cpp @@ -4,12 +4,45 @@ extern "C" { namespace D3D8Wrapper { + ThreadSafePointerSet D3D8Wrapper::IDirect3DTexture8::m_List; + D3D8Wrapper::IDirect3DTexture8::IDirect3DTexture8(D3D8Base::IDirect3DTexture8* pTexture) : IDirect3DBaseTexture8((D3D8Base::IDirect3DBaseTexture8*) pTexture) { - LOG("IDirect3DBaseTexture8"); + LOG("IDirect3DTexture8"); 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;*/ STDMETHODIMP D3D8Wrapper::IDirect3DTexture8::GetLevelDesc(UINT Level,D3D8Base::D3DSURFACE_DESC *pDesc) diff --git a/libmupen64plus/D3D8Interceptor/Direct3DVolumeTexture8Functions.cpp b/libmupen64plus/D3D8Interceptor/Direct3DVolumeTexture8Functions.cpp index dca86ec49a..6caf05951b 100644 --- a/libmupen64plus/D3D8Interceptor/Direct3DVolumeTexture8Functions.cpp +++ b/libmupen64plus/D3D8Interceptor/Direct3DVolumeTexture8Functions.cpp @@ -6,7 +6,7 @@ extern "C" { D3D8Wrapper::IDirect3DVolumeTexture8::IDirect3DVolumeTexture8(D3D8Base::IDirect3DVolumeTexture8* pTexture) : IDirect3DBaseTexture8((D3D8Base::IDirect3DBaseTexture8*) pTexture) { - LOG("IDirect3DBaseTexture8"); + LOG("IDirect3DVolumeTexture8"); m_pD3D = pTexture; } diff --git a/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp b/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp index 423fddc419..4c71b7232b 100644 --- a/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp +++ b/libmupen64plus/D3D8Interceptor/d3d8Wrapper.cpp @@ -7,7 +7,6 @@ HMODULE hD3D; ThreadSafePointerSet D3D8Wrapper::IDirect3DDevice8::m_List; ThreadSafePointerSet D3D8Wrapper::IDirect3DResource8::m_List; ThreadSafePointerSet D3D8Wrapper::IDirect3DBaseTexture8::m_List; -ThreadSafePointerSet D3D8Wrapper::IDirect3DTexture8::m_List; ThreadSafePointerSet D3D8Wrapper::IDirect3DVolumeTexture8::m_List; ThreadSafePointerSet D3D8Wrapper::IDirect3DCubeTexture8::m_List; ThreadSafePointerSet D3D8Wrapper::IDirect3DVertexBuffer8::m_List; @@ -16,9 +15,6 @@ ThreadSafePointerSet D3D8Wrapper::IDirect3DSurface8::m_List; ThreadSafePointerSet D3D8Wrapper::IDirect3DVolume8::m_List; ThreadSafePointerSet D3D8Wrapper::IDirect3DSwapChain8::m_List; - - - extern "C" { namespace D3D8Wrapper @@ -28,26 +24,31 @@ extern "C" 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"); - // Contains our real object + // Use the real Direct3DCreate8 to make the base object D3D8Base::IDirect3D8* pD3D = pCreate(D3D_SDK_VERSION); + // Wrap the object D3D8Wrapper::IDirect3D8* fD3D = D3D8Wrapper::IDirect3D8::GetDirect3D(pD3D); - MessageBox(NULL, "", "HAX", MB_OK); - return fD3D; //D3D8Base::Direct3DCreate8(Version); + return fD3D; } } - - - + __declspec(dllexport) void __cdecl CloseDLL() + { + FreeLibrary(hD3D); + } __declspec(dllexport) void __cdecl SetRenderingCallback(void (*callback)(int)) { diff --git a/libmupen64plus/D3D8Interceptor/d3d8Wrapper.h b/libmupen64plus/D3D8Interceptor/d3d8Wrapper.h index 7de65fbb24..7afb7c8e11 100644 --- a/libmupen64plus/D3D8Interceptor/d3d8Wrapper.h +++ b/libmupen64plus/D3D8Interceptor/d3d8Wrapper.h @@ -82,19 +82,15 @@ extern "C" D3D8Base::IDirect3D8* m_pD3D; static ThreadSafePointerSet m_List; public: - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) - { - return E_FAIL; - } - inline D3D8Base::IDirect3D8* GetDirect3D8() { return m_pD3D; } - - static IDirect3D8* GetDirect3D(D3D8Base::IDirect3D8* pD3D); - IDirect3D8(D3D8Base::IDirect3D8*); + + inline D3D8Base::IDirect3D8* GetDirect3D8() { return m_pD3D; } + static IDirect3D8* GetDirect3D(D3D8Base::IDirect3D8* pD3D); + + /*** IDirect3DUnknown methods ***/ STDMETHOD_(ULONG,Release)(THIS); /*** IDirect3D8 methods ***/ - STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction); STDMETHOD_(UINT, GetAdapterCount)(THIS); 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_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter); STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3D8Base::D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3D8Base::D3DPRESENT_PARAMETERS* pPresentationParameters,D3D8Wrapper::IDirect3DDevice8** ppReturnedDeviceInterface); - }; class IDirect3DDevice8 : public IDirect3DUnknown @@ -317,8 +312,12 @@ extern "C" static ThreadSafePointerSet m_List; public: + STDMETHOD_(ULONG,Release)(THIS); + IDirect3DTexture8(D3D8Base::IDirect3DTexture8*); + static D3D8Wrapper::IDirect3DTexture8* GetTexture(D3D8Base::IDirect3DTexture8*); + //D3D8Base::IDirect3DTexture8* getReal2(); diff --git a/libmupen64plus/mupen64plus-video-jabo/main.cpp b/libmupen64plus/mupen64plus-video-jabo/main.cpp index 52c8cbcfff..72f627b5df 100644 --- a/libmupen64plus/mupen64plus-video-jabo/main.cpp +++ b/libmupen64plus/mupen64plus-video-jabo/main.cpp @@ -45,12 +45,16 @@ static int l_PluginInit = 0; HMODULE JaboDLL; HWND hWnd_jabo; +HANDLE window_thread = NULL; + HMODULE D3D8Dll; typedef void (*ptr_D3D8_SetRenderingCallback)(void (*callback)(int)); ptr_D3D8_SetRenderingCallback D3D8_SetRenderingCallback = NULL; typedef void (*ptr_D3D8_ReadScreen)(void *dest, int *width, int *height); ptr_D3D8_ReadScreen D3D8_ReadScreen = NULL; +typedef void (*ptr_D3D8_CloseDLL)(); +ptr_D3D8_CloseDLL D3D8_CloseDLL = NULL; void setup_jabo_functions() { @@ -80,6 +84,7 @@ void setup_jabo_functions() { D3D8_SetRenderingCallback = (ptr_D3D8_SetRenderingCallback)GetProcAddress(D3D8Dll,"SetRenderingCallback"); 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") OldAPI::CloseDLL(); + TerminateThread(window_thread,0); + D3D8_CloseDLL(); + FreeLibrary(D3D8Dll); + FreeLibrary(JaboDLL); + if (!l_PluginInit) 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) { 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; }