4 * This file contains the Nt* API functions of NTDLL.DLL.
5 * In the original ntdll.dll they all seem to just call int 0x2e (down to the NTOSKRNL)
7 * Copyright 1996-1998 Marcus Meissner
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "wine/debug.h"
31 #include "ntdll_misc.h"
32 #include "wine/server.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
40 /**************************************************************************
41 * NtCreateTimer [NTDLL.@]
42 * ZwCreateTimer [NTDLL.@]
44 NTSTATUS WINAPI NtCreateTimer(
45 OUT PHANDLE TimerHandle,
46 IN ACCESS_MASK DesiredAccess,
47 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
48 IN TIMER_TYPE TimerType)
50 FIXME("(%p,0x%08lx,%p,0x%08x) stub\n",
51 TimerHandle,DesiredAccess,ObjectAttributes, TimerType);
52 dump_ObjectAttributes(ObjectAttributes);
55 /**************************************************************************
56 * NtSetTimer [NTDLL.@]
57 * ZwSetTimer [NTDLL.@]
59 NTSTATUS WINAPI NtSetTimer(
60 IN HANDLE TimerHandle,
61 IN PLARGE_INTEGER DueTime,
62 IN PTIMERAPCROUTINE TimerApcRoutine,
63 IN PVOID TimerContext,
65 IN ULONG Period OPTIONAL,
66 OUT PBOOLEAN PreviousState OPTIONAL)
68 FIXME("(0x%08x,%p,%p,%p,%08x,0x%08lx,%p) stub\n",
69 TimerHandle,DueTime,TimerApcRoutine,TimerContext,WakeTimer,Period,PreviousState);
73 /******************************************************************************
74 * NtQueryTimerResolution [NTDLL.@]
76 NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,DWORD x2,DWORD x3)
78 FIXME("(0x%08lx,0x%08lx,0x%08lx), stub!\n",x1,x2,x3);
86 /******************************************************************************
87 * NtTerminateProcess [NTDLL.@]
89 * Native applications must kill themselves when done
91 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
95 SERVER_START_REQ( terminate_process )
98 req->exit_code = exit_code;
99 ret = wine_server_call( req );
100 self = !ret && reply->self;
103 if (self) exit( exit_code );
107 /******************************************************************************
108 * NtQueryInformationProcess [NTDLL.@]
109 * ZwQueryInformationProcess [NTDLL.@]
112 NTSTATUS WINAPI NtQueryInformationProcess(
113 IN HANDLE ProcessHandle,
114 IN PROCESSINFOCLASS ProcessInformationClass,
115 OUT PVOID ProcessInformation,
116 IN ULONG ProcessInformationLength,
117 OUT PULONG ReturnLength)
119 NTSTATUS ret = STATUS_SUCCESS;
122 switch (ProcessInformationClass) {
123 case ProcessDebugPort:
124 /* "These are not the debuggers you are looking for." */
125 /* set it to 0 aka "no debugger" to satisfy copy protections */
126 if (ProcessInformationLength == 4)
128 memset(ProcessInformation,0,ProcessInformationLength);
132 ret = STATUS_INFO_LENGTH_MISMATCH;
135 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
136 ProcessHandle,ProcessInformationClass,
137 ProcessInformation,ProcessInformationLength,
149 /******************************************************************************
150 * NtSetInformationProcess [NTDLL.@]
151 * ZwSetInformationProcess [NTDLL.@]
153 NTSTATUS WINAPI NtSetInformationProcess(
154 IN HANDLE ProcessHandle,
155 IN PROCESSINFOCLASS ProcessInformationClass,
156 IN PVOID ProcessInformation,
157 IN ULONG ProcessInformationLength)
159 FIXME("(0x%08x,0x%08x,%p,0x%08lx) stub\n",
160 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
168 /******************************************************************************
169 * NtResumeThread [NTDLL.@]
170 * ZwResumeThread [NTDLL.@]
172 NTSTATUS WINAPI NtResumeThread(
173 IN HANDLE ThreadHandle,
174 IN PULONG SuspendCount)
176 FIXME("(0x%08x,%p),stub!\n",
177 ThreadHandle,SuspendCount);
182 /******************************************************************************
183 * NtTerminateThread [NTDLL.@]
184 * ZwTerminateThread [NTDLL.@]
186 NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
191 SERVER_START_REQ( terminate_thread )
193 req->handle = handle;
194 req->exit_code = exit_code;
195 ret = wine_server_call( req );
196 self = !ret && reply->self;
203 if (last) exit( exit_code );
204 else SYSDEPS_ExitThread( exit_code );
210 /******************************************************************************
211 * NtQueryInformationThread [NTDLL.@]
212 * ZwQueryInformationThread [NTDLL.@]
215 NTSTATUS WINAPI NtQueryInformationThread(
216 IN HANDLE ThreadHandle,
217 IN THREADINFOCLASS ThreadInformationClass,
218 OUT PVOID ThreadInformation,
219 IN ULONG ThreadInformationLength,
220 OUT PULONG ReturnLength)
222 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
223 ThreadHandle, ThreadInformationClass, ThreadInformation,
224 ThreadInformationLength, ReturnLength);
228 /******************************************************************************
229 * NtSetInformationThread [NTDLL.@]
230 * ZwSetInformationThread [NTDLL.@]
232 NTSTATUS WINAPI NtSetInformationThread(
234 THREADINFOCLASS ThreadInformationClass,
235 PVOID ThreadInformation,
236 ULONG ThreadInformationLength)
238 FIXME("(0x%08x,0x%08x,%p,0x%08lx),stub!\n",
239 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
247 /******************************************************************************
248 * NtDuplicateToken [NTDLL.@]
249 * ZwDuplicateToken [NTDLL.@]
251 NTSTATUS WINAPI NtDuplicateToken(
252 IN HANDLE ExistingToken,
253 IN ACCESS_MASK DesiredAccess,
254 IN POBJECT_ATTRIBUTES ObjectAttributes,
255 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
256 IN TOKEN_TYPE TokenType,
257 OUT PHANDLE NewToken)
259 FIXME("(0x%08x,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
260 ExistingToken, DesiredAccess, ObjectAttributes,
261 ImpersonationLevel, TokenType, NewToken);
262 dump_ObjectAttributes(ObjectAttributes);
266 /******************************************************************************
267 * NtOpenProcessToken [NTDLL.@]
268 * ZwOpenProcessToken [NTDLL.@]
270 NTSTATUS WINAPI NtOpenProcessToken(
271 HANDLE ProcessHandle,
275 FIXME("(0x%08x,0x%08lx,%p): stub\n",
276 ProcessHandle,DesiredAccess, TokenHandle);
277 *TokenHandle = (HANDLE)0xcafe;
281 /******************************************************************************
282 * NtOpenThreadToken [NTDLL.@]
283 * ZwOpenThreadToken [NTDLL.@]
285 NTSTATUS WINAPI NtOpenThreadToken(
291 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
292 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
293 *TokenHandle = (HANDLE)0xcafe;
297 /******************************************************************************
298 * NtAdjustPrivilegesToken [NTDLL.@]
299 * ZwAdjustGroupsToken [NTDLL.@]
301 * FIXME: parameters unsafe
303 NTSTATUS WINAPI NtAdjustPrivilegesToken(
304 IN HANDLE TokenHandle,
305 IN BOOLEAN DisableAllPrivileges,
306 IN PTOKEN_PRIVILEGES NewState,
307 IN DWORD BufferLength,
308 OUT PTOKEN_PRIVILEGES PreviousState,
309 OUT PDWORD ReturnLength)
311 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
312 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
316 /******************************************************************************
317 * NtQueryInformationToken [NTDLL.@]
318 * ZwQueryInformationToken [NTDLL.@]
321 * Buffer for TokenUser:
322 * 0x00 TOKEN_USER the PSID field points to the SID
326 NTSTATUS WINAPI NtQueryInformationToken(
328 DWORD tokeninfoclass,
330 DWORD tokeninfolength,
333 unsigned int len = 0;
335 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
336 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
338 switch (tokeninfoclass)
341 len = sizeof(TOKEN_USER) + sizeof(SID);
344 len = sizeof(TOKEN_GROUPS);
346 case TokenPrivileges:
347 len = sizeof(TOKEN_PRIVILEGES);
350 len = sizeof(TOKEN_OWNER);
352 case TokenPrimaryGroup:
353 len = sizeof(TOKEN_PRIMARY_GROUP);
355 case TokenDefaultDacl:
356 len = sizeof(TOKEN_DEFAULT_DACL);
359 len = sizeof(TOKEN_SOURCE);
362 len = sizeof (TOKEN_TYPE);
365 case TokenImpersonationLevel:
366 case TokenStatistics:
370 /* FIXME: what if retlen == NULL ? */
373 if (tokeninfolength < len)
374 return STATUS_BUFFER_TOO_SMALL;
376 switch (tokeninfoclass)
381 TOKEN_USER * tuser = tokeninfo;
382 PSID sid = (PSID) (tuser + 1);
383 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
384 RtlInitializeSid(sid, &localSidAuthority, 1);
385 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
386 tuser->User.Sid = sid;
392 TOKEN_GROUPS *tgroups = tokeninfo;
393 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
395 /* we need to show admin privileges ! */
396 tgroups->GroupCount = 1;
397 RtlAllocateAndInitializeSid( &sid,
399 SECURITY_BUILTIN_DOMAIN_RID,
400 DOMAIN_ALIAS_RID_ADMINS,
402 &(tgroups->Groups->Sid));
405 case TokenPrivileges:
408 TOKEN_PRIVILEGES *tpriv = tokeninfo;
409 tpriv->PrivilegeCount = 1;
420 /******************************************************************************
421 * NtQuerySection [NTDLL.@]
423 NTSTATUS WINAPI NtQuerySection(
424 IN HANDLE SectionHandle,
425 IN PVOID SectionInformationClass,
426 OUT PVOID SectionInformation,
428 OUT PULONG ResultLength)
430 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
431 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
439 /******************************************************************************
440 * NtCreatePort [NTDLL.@]
441 * ZwCreatePort [NTDLL.@]
443 NTSTATUS WINAPI NtCreatePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
445 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5);
449 /******************************************************************************
450 * NtConnectPort [NTDLL.@]
451 * ZwConnectPort [NTDLL.@]
453 NTSTATUS WINAPI NtConnectPort(DWORD x1,PUNICODE_STRING uni,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
455 FIXME("(0x%08lx,%s,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
456 x1,debugstr_w(uni->Buffer),x3,x4,x5,x6,x7,x8);
460 /******************************************************************************
461 * NtListenPort [NTDLL.@]
462 * ZwListenPort [NTDLL.@]
464 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
466 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
470 /******************************************************************************
471 * NtAcceptConnectPort [NTDLL.@]
472 * ZwAcceptConnectPort [NTDLL.@]
474 NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6)
476 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6);
480 /******************************************************************************
481 * NtCompleteConnectPort [NTDLL.@]
482 * ZwCompleteConnectPort [NTDLL.@]
484 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
486 FIXME("(0x%08lx),stub!\n",x1);
490 /******************************************************************************
491 * NtRegisterThreadTerminatePort [NTDLL.@]
492 * ZwRegisterThreadTerminatePort [NTDLL.@]
494 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
496 FIXME("(0x%08lx),stub!\n",x1);
500 /******************************************************************************
501 * NtRequestWaitReplyPort [NTDLL.@]
502 * ZwRequestWaitReplyPort [NTDLL.@]
504 NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1,DWORD x2,DWORD x3)
506 FIXME("(0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3);
510 /******************************************************************************
511 * NtReplyWaitReceivePort [NTDLL.@]
512 * ZwReplyWaitReceivePort [NTDLL.@]
514 NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4)
516 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
524 /******************************************************************************
525 * NtSetIntervalProfile [NTDLL.@]
526 * ZwSetIntervalProfile [NTDLL.@]
528 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
529 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
533 /******************************************************************************
534 * NtQueryPerformanceCounter [NTDLL.@]
536 NTSTATUS WINAPI NtQueryPerformanceCounter(
537 IN PLARGE_INTEGER Counter,
538 IN PLARGE_INTEGER Frequency)
540 FIXME("(%p, 0%p) stub\n",
545 /******************************************************************************
546 * NtCreateMailslotFile [NTDLL.@]
547 * ZwCreateMailslotFile [NTDLL.@]
549 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
551 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6,x7,x8);
555 /******************************************************************************
556 * NtQuerySystemInformation [NTDLL.@]
557 * ZwQuerySystemInformation [NTDLL.@]
560 * SystemInformationClass Index to a certain information structure
561 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
562 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
563 * SystemConfigurationInformation CONFIGURATION_INFORMATION
564 * observed (class/len):
570 * SystemInformation caller supplies storage for the information structure
571 * Length size of the structure
572 * ResultLength Data written
574 NTSTATUS WINAPI NtQuerySystemInformation(
575 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
576 OUT PVOID SystemInformation,
578 OUT PULONG ResultLength)
580 switch(SystemInformationClass)
583 /* Something to do with the size of the registry *
584 * Since we don't have a size limitation, fake it *
585 * This is almost certainly wrong. *
586 * This sets each of the three words in the struct to 32 MB, *
587 * which is enough to make the IE 5 installer happy. */
588 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
589 SystemInformationClass,SystemInformation,Length,ResultLength);
590 *(DWORD *)SystemInformation = 0x2000000;
591 *(((DWORD *)SystemInformation)+1) = 0x200000;
592 *(((DWORD *)SystemInformation)+2) = 0x200000;
596 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
597 SystemInformationClass,SystemInformation,Length,ResultLength);
598 ZeroMemory (SystemInformation, Length);
601 return STATUS_SUCCESS;
605 /******************************************************************************
606 * NtCreatePagingFile [NTDLL.@]
607 * ZwCreatePagingFile [NTDLL.@]
609 NTSTATUS WINAPI NtCreatePagingFile(
610 IN PUNICODE_STRING PageFileName,
613 OUT PULONG ActualSize)
615 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
616 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
620 /******************************************************************************
621 * NtDisplayString [NTDLL.@]
623 * writes a string to the nt-textmode screen eg. during startup
625 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
630 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
632 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
633 RtlFreeAnsiString( &stringA );
638 /******************************************************************************
639 * NtPowerInformation [NTDLL.@]
642 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
644 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
648 /******************************************************************************
649 * NtAllocateLocallyUniqueId (NTDLL.@)
651 * FIXME: the server should do that
653 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
657 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.HighPart, luid.LowPart);
662 Luid->HighPart = luid.HighPart;
663 Luid->LowPart = luid.LowPart;
665 return STATUS_SUCCESS;
668 /******************************************************************************
669 * VerSetConditionMask (NTDLL.@)
671 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
672 BYTE dwConditionMask)
674 if(dwTypeBitMask == 0)
675 return dwlConditionMask;
676 dwConditionMask &= 0x07;
677 if(dwConditionMask == 0)
678 return dwlConditionMask;
680 if(dwTypeBitMask & VER_PRODUCT_TYPE)
681 dwlConditionMask |= dwConditionMask << 7*3;
682 else if (dwTypeBitMask & VER_SUITENAME)
683 dwlConditionMask |= dwConditionMask << 6*3;
684 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
685 dwlConditionMask |= dwConditionMask << 5*3;
686 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
687 dwlConditionMask |= dwConditionMask << 4*3;
688 else if (dwTypeBitMask & VER_PLATFORMID)
689 dwlConditionMask |= dwConditionMask << 3*3;
690 else if (dwTypeBitMask & VER_BUILDNUMBER)
691 dwlConditionMask |= dwConditionMask << 2*3;
692 else if (dwTypeBitMask & VER_MAJORVERSION)
693 dwlConditionMask |= dwConditionMask << 1*3;
694 else if (dwTypeBitMask & VER_MINORVERSION)
695 dwlConditionMask |= dwConditionMask << 0*3;
696 return dwlConditionMask;