Fix for Windows XP compatibility
I neglected FreeLibrary and have multiple calls to LoadLibrary without freeing. This is fixed by moving it to the class member level and allocating and deallocating through the class constructor/destructor.
This commit is contained in:
parent
a972773b6a
commit
84c164ff66
|
@ -49,6 +49,12 @@ CScriptInstance::CScriptInstance(CDebuggerUI* debugger)
|
||||||
m_hIOCompletionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
|
m_hIOCompletionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
|
||||||
InitializeCriticalSection(&m_CriticalSection);
|
InitializeCriticalSection(&m_CriticalSection);
|
||||||
CacheInstance(this);
|
CacheInstance(this);
|
||||||
|
m_hKernel = LoadLibrary("Kernel32.dll");
|
||||||
|
m_CancelIoEx = NULL;
|
||||||
|
if (m_hKernel != NULL)
|
||||||
|
{
|
||||||
|
m_CancelIoEx = (Dynamic_CancelIoEx)GetProcAddress(m_hKernel, "CancelIoEx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptInstance::~CScriptInstance()
|
CScriptInstance::~CScriptInstance()
|
||||||
|
@ -59,6 +65,11 @@ CScriptInstance::~CScriptInstance()
|
||||||
|
|
||||||
TerminateThread(m_hThread, 0);
|
TerminateThread(m_hThread, 0);
|
||||||
CloseHandle(m_hThread);
|
CloseHandle(m_hThread);
|
||||||
|
m_CancelIoEx = NULL;
|
||||||
|
if (m_hKernel != NULL)
|
||||||
|
{
|
||||||
|
FreeLibrary(m_hKernel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptInstance::Start(char* path)
|
void CScriptInstance::Start(char* path)
|
||||||
|
@ -346,8 +357,6 @@ CScriptInstance::AddListener(HANDLE fd, IOEVENTTYPE evt, void* callback, void* d
|
||||||
|
|
||||||
void CScriptInstance::RemoveListenerByIndex(UINT index)
|
void CScriptInstance::RemoveListenerByIndex(UINT index)
|
||||||
{
|
{
|
||||||
typedef BOOL (__stdcall *Dynamic_CancelIoEx)(HANDLE, LPOVERLAPPED);
|
|
||||||
Dynamic_CancelIoEx _CancelIoEx;
|
|
||||||
IOLISTENER* lpListener = m_Listeners[index];
|
IOLISTENER* lpListener = m_Listeners[index];
|
||||||
|
|
||||||
if (lpListener->data != NULL)
|
if (lpListener->data != NULL)
|
||||||
|
@ -355,16 +364,18 @@ void CScriptInstance::RemoveListenerByIndex(UINT index)
|
||||||
free(lpListener->data);
|
free(lpListener->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
HMODULE hKernel = LoadLibrary("Kernel32.dll");
|
// Original call to CancelIoEx:
|
||||||
_CancelIoEx = (Dynamic_CancelIoEx)GetProcAddress(hKernel, "CancelIoEx");
|
|
||||||
|
|
||||||
//CancelIoEx(lpListener->fd, (LPOVERLAPPED)lpListener);
|
//CancelIoEx(lpListener->fd, (LPOVERLAPPED)lpListener);
|
||||||
if (_CancelIoEx != NULL)
|
if (m_CancelIoEx != NULL)
|
||||||
_CancelIoEx(lpListener->fd, (LPOVERLAPPED)lpListener);
|
{
|
||||||
|
m_CancelIoEx(lpListener->fd, (LPOVERLAPPED)lpListener);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
// This isn't a good replacement and the script aspects of the debugger shouldn't
|
// This isn't a good replacement and the script aspects of the debugger shouldn't
|
||||||
// be used in WindowsXP
|
// be used in WindowsXP
|
||||||
CancelIo(lpListener->fd);
|
CancelIo(lpListener->fd);
|
||||||
|
}
|
||||||
|
|
||||||
free(lpListener);
|
free(lpListener);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ class CScriptInstance
|
||||||
int fd;
|
int fd;
|
||||||
} FILE_FD;
|
} FILE_FD;
|
||||||
|
|
||||||
|
typedef BOOL(__stdcall *Dynamic_CancelIoEx)(HANDLE, LPOVERLAPPED);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CScriptInstance(CDebuggerUI* debugger);
|
CScriptInstance(CDebuggerUI* debugger);
|
||||||
|
@ -129,6 +130,10 @@ private:
|
||||||
|
|
||||||
const char* EvalFile(const char* jsPath);
|
const char* EvalFile(const char* jsPath);
|
||||||
|
|
||||||
|
// Handle to to dynamically load CancelIoEx for Windows XP compatibility
|
||||||
|
HMODULE m_hKernel;
|
||||||
|
Dynamic_CancelIoEx m_CancelIoEx;
|
||||||
|
|
||||||
// Lookup list of CScriptInstance instances for static js_* functions
|
// Lookup list of CScriptInstance instances for static js_* functions
|
||||||
static vector<CScriptInstance*> Cache;
|
static vector<CScriptInstance*> Cache;
|
||||||
static void CacheInstance(CScriptInstance* _this);
|
static void CacheInstance(CScriptInstance* _this);
|
||||||
|
|
Loading…
Reference in New Issue