From 9541bf14f5e64b4c79cc6efa0930c6bafaecf84a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 26 Oct 2011 17:19:23 -0700 Subject: [PATCH] vm: win32 GetCurrentThread is a fake thread handle Open a real thread handle with the necessary permissions to dispatch a handler from the the Ctrl-C handler thread. --- vm/os-windows.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vm/os-windows.hpp b/vm/os-windows.hpp index aca5eab9a8..ba820d32e9 100755 --- a/vm/os-windows.hpp +++ b/vm/os-windows.hpp @@ -73,7 +73,18 @@ long getpagesize(); void move_file(const vm_char *path1, const vm_char *path2); VM_C_API LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch); THREADHANDLE start_thread(void *(*start_routine)(void *),void *args); -inline static THREADHANDLE thread_id() { return GetCurrentThread(); } + +inline static THREADHANDLE thread_id() +{ + DWORD id = GetCurrentThreadId(); + HANDLE threadHandle = OpenThread( + THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME, + FALSE, + id + ); + assert(threadHandle != NULL); + return threadHandle; +} #define CODE_TO_FUNCTION_POINTER(code) (void)0 #define CODE_TO_FUNCTION_POINTER_CALLBACK(vm, code) (void)0