4 * Copyright 1996 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <sys/types.h>
26 #define WIN32_NO_STATUS
33 #include "kernel_private.h"
37 __ASM_STDCALL_FUNC( __fastcall_BaseThreadInitThunk
, 12,
39 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
40 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
42 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
44 __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
45 "movl 8(%ebp),%ebx\n\t"
46 /* deliberately mis-align the stack by 8, Doom 3 needs this */
47 "pushl 4(%ebp)\n\t" /* Driller expects readable address at this offset */
51 "movl %eax,(%esp)\n\t"
52 "call " __ASM_STDCALL( "RtlExitUserThread", 4 ))
55 /***********************************************************************
56 * BaseThreadInitThunk (KERNEL32.@)
58 void __fastcall
BaseThreadInitThunk( DWORD unknown
, LPTHREAD_START_ROUTINE entry
, void *arg
)
60 RtlExitUserThread( entry( arg
) );
64 /***********************************************************************
65 * FreeLibraryAndExitThread (KERNEL32.@)
67 void WINAPI
FreeLibraryAndExitThread(HINSTANCE hLibModule
, DWORD dwExitCode
)
69 FreeLibrary(hLibModule
);
70 ExitThread(dwExitCode
);
74 /***********************************************************************
75 * Wow64SetThreadContext [KERNEL32.@]
77 BOOL WINAPI
Wow64SetThreadContext( HANDLE handle
, const WOW64_CONTEXT
*context
)
80 return set_ntstatus( NtSetContextThread( handle
, (const CONTEXT
*)context
));
81 #elif defined(__x86_64__)
82 return set_ntstatus( RtlWow64SetThreadContext( handle
, context
));
84 return set_ntstatus( STATUS_NOT_IMPLEMENTED
);
88 /***********************************************************************
89 * Wow64GetThreadContext [KERNEL32.@]
91 BOOL WINAPI
Wow64GetThreadContext( HANDLE handle
, WOW64_CONTEXT
*context
)
94 return set_ntstatus( NtGetContextThread( handle
, (CONTEXT
*)context
));
95 #elif defined(__x86_64__)
96 return set_ntstatus( RtlWow64GetThreadContext( handle
, context
));
98 return set_ntstatus( STATUS_NOT_IMPLEMENTED
);
103 /**********************************************************************
104 * SetThreadAffinityMask (KERNEL32.@)
106 DWORD_PTR WINAPI
SetThreadAffinityMask( HANDLE thread
, DWORD_PTR mask
)
108 THREAD_BASIC_INFORMATION tbi
;
110 if (!set_ntstatus( NtQueryInformationThread( thread
, ThreadBasicInformation
, &tbi
, sizeof(tbi
), NULL
)))
112 if (!set_ntstatus( NtSetInformationThread( thread
, ThreadAffinityMask
, &mask
, sizeof(mask
))))
114 return tbi
.AffinityMask
;
118 /***********************************************************************
119 * GetThreadSelectorEntry (KERNEL32.@)
121 BOOL WINAPI
GetThreadSelectorEntry( HANDLE thread
, DWORD sel
, LDT_ENTRY
*ldtent
)
123 THREAD_DESCRIPTOR_INFORMATION tdi
;
126 if (!set_ntstatus( NtQueryInformationThread( thread
, ThreadDescriptorTableEntry
,
127 &tdi
, sizeof(tdi
), NULL
)))
134 /***********************************************************************
135 * GetCurrentThread [KERNEL32.@] Gets pseudohandle for current thread
138 * Pseudohandle for the current thread
140 HANDLE WINAPI
KERNEL32_GetCurrentThread(void)
142 return (HANDLE
)~(ULONG_PTR
)1;
145 /***********************************************************************
146 * GetCurrentProcessId (KERNEL32.@)
148 * Get the current process identifier.
151 * current process identifier
153 DWORD WINAPI
KERNEL32_GetCurrentProcessId(void)
155 return HandleToULong(NtCurrentTeb()->ClientId
.UniqueProcess
);
158 /***********************************************************************
159 * GetCurrentThreadId (KERNEL32.@)
161 * Get the current thread identifier.
164 * current thread identifier
166 DWORD WINAPI
KERNEL32_GetCurrentThreadId(void)
168 return HandleToULong(NtCurrentTeb()->ClientId
.UniqueThread
);