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
25 #include <sys/types.h>
28 #define WIN32_NO_STATUS
34 #include "kernel_private.h"
37 /***********************************************************************
38 * FreeLibraryAndExitThread (KERNEL32.@)
40 void WINAPI
FreeLibraryAndExitThread(HINSTANCE hLibModule
, DWORD dwExitCode
)
42 FreeLibrary(hLibModule
);
43 ExitThread(dwExitCode
);
47 /***********************************************************************
48 * Wow64SetThreadContext [KERNEL32.@]
50 BOOL WINAPI
Wow64SetThreadContext( HANDLE handle
, const WOW64_CONTEXT
*context
)
53 NTSTATUS status
= NtSetContextThread( handle
, (const CONTEXT
*)context
);
54 #elif defined(__x86_64__)
55 NTSTATUS status
= RtlWow64SetThreadContext( handle
, context
);
57 NTSTATUS status
= STATUS_NOT_IMPLEMENTED
;
59 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
63 /***********************************************************************
64 * Wow64GetThreadContext [KERNEL32.@]
66 BOOL WINAPI
Wow64GetThreadContext( HANDLE handle
, WOW64_CONTEXT
*context
)
69 NTSTATUS status
= NtGetContextThread( handle
, (CONTEXT
*)context
);
70 #elif defined(__x86_64__)
71 NTSTATUS status
= RtlWow64GetThreadContext( handle
, context
);
73 NTSTATUS status
= STATUS_NOT_IMPLEMENTED
;
75 if (status
) SetLastError( RtlNtStatusToDosError(status
) );
80 /**********************************************************************
81 * SetThreadAffinityMask (KERNEL32.@)
83 DWORD_PTR WINAPI
SetThreadAffinityMask( HANDLE hThread
, DWORD_PTR dwThreadAffinityMask
)
86 THREAD_BASIC_INFORMATION tbi
;
88 status
= NtQueryInformationThread( hThread
, ThreadBasicInformation
,
89 &tbi
, sizeof(tbi
), NULL
);
92 SetLastError( RtlNtStatusToDosError(status
) );
95 status
= NtSetInformationThread( hThread
, ThreadAffinityMask
,
96 &dwThreadAffinityMask
,
97 sizeof(dwThreadAffinityMask
));
100 SetLastError( RtlNtStatusToDosError(status
) );
103 return tbi
.AffinityMask
;
107 /***********************************************************************
108 * GetThreadSelectorEntry (KERNEL32.@)
110 BOOL WINAPI
GetThreadSelectorEntry( HANDLE hthread
, DWORD sel
, LPLDT_ENTRY ldtent
)
112 THREAD_DESCRIPTOR_INFORMATION tdi
;
116 status
= NtQueryInformationThread( hthread
, ThreadDescriptorTableEntry
, &tdi
, sizeof(tdi
), NULL
);
119 SetLastError( RtlNtStatusToDosError(status
) );
127 /***********************************************************************
128 * GetCurrentThread [KERNEL32.@] Gets pseudohandle for current thread
131 * Pseudohandle for the current thread
133 HANDLE WINAPI
KERNEL32_GetCurrentThread(void)
135 return (HANDLE
)~(ULONG_PTR
)1;
138 /***********************************************************************
139 * GetCurrentProcessId (KERNEL32.@)
141 * Get the current process identifier.
144 * current process identifier
146 DWORD WINAPI
KERNEL32_GetCurrentProcessId(void)
148 return HandleToULong(NtCurrentTeb()->ClientId
.UniqueProcess
);
151 /***********************************************************************
152 * GetCurrentThreadId (KERNEL32.@)
154 * Get the current thread identifier.
157 * current thread identifier
159 DWORD WINAPI
KERNEL32_GetCurrentThreadId(void)
161 return HandleToULong(NtCurrentTeb()->ClientId
.UniqueThread
);