]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: win32 GetCurrentThread is a fake thread handle
authorJoe Groff <arcata@gmail.com>
Thu, 27 Oct 2011 00:19:23 +0000 (17:19 -0700)
committerJoe Groff <arcata@gmail.com>
Fri, 28 Oct 2011 04:18:21 +0000 (21:18 -0700)
Open a real thread handle with the necessary permissions to dispatch a handler from the the Ctrl-C handler thread.

vm/os-windows.hpp

index aca5eab9a8dc55dfb79bb32fb370899adc7c803a..ba820d32e9b7375a206513dec0f6faa42f5b1cf6 100755 (executable)
@@ -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