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
14 #include "debugtools.h"
17 #include "ntdll_misc.h"
18 #include "wine/server.h"
20 DEFAULT_DEBUG_CHANNEL(ntdll);
26 /**************************************************************************
27 * NtCreateTimer [NTDLL.@]
28 * ZwCreateTimer [NTDLL.@]
30 NTSTATUS WINAPI NtCreateTimer(
31 OUT PHANDLE TimerHandle,
32 IN ACCESS_MASK DesiredAccess,
33 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
34 IN TIMER_TYPE TimerType)
36 FIXME("(%p,0x%08lx,%p,0x%08x) stub\n",
37 TimerHandle,DesiredAccess,ObjectAttributes, TimerType);
38 dump_ObjectAttributes(ObjectAttributes);
41 /**************************************************************************
42 * NtSetTimer [NTDLL.@]
43 * ZwSetTimer [NTDLL.@]
45 NTSTATUS WINAPI NtSetTimer(
46 IN HANDLE TimerHandle,
47 IN PLARGE_INTEGER DueTime,
48 IN PTIMERAPCROUTINE TimerApcRoutine,
49 IN PVOID TimerContext,
51 IN ULONG Period OPTIONAL,
52 OUT PBOOLEAN PreviousState OPTIONAL)
54 FIXME("(0x%08x,%p,%p,%p,%08x,0x%08lx,%p) stub\n",
55 TimerHandle,DueTime,TimerApcRoutine,TimerContext,WakeTimer,Period,PreviousState);
59 /******************************************************************************
60 * NtQueryTimerResolution [NTDLL.@]
62 NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,DWORD x2,DWORD x3)
64 FIXME("(0x%08lx,0x%08lx,0x%08lx), stub!\n",x1,x2,x3);
72 /******************************************************************************
73 * NtTerminateProcess [NTDLL.@]
75 * Native applications must kill themselves when done
77 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
81 SERVER_START_REQ( terminate_process )
84 req->exit_code = exit_code;
85 ret = wine_server_call( req );
86 self = !ret && reply->self;
89 if (self) exit( exit_code );
93 /******************************************************************************
94 * NtQueryInformationProcess [NTDLL.@]
95 * ZwQueryInformationProcess [NTDLL.@]
98 NTSTATUS WINAPI NtQueryInformationProcess(
99 IN HANDLE ProcessHandle,
100 IN PROCESSINFOCLASS ProcessInformationClass,
101 OUT PVOID ProcessInformation,
102 IN ULONG ProcessInformationLength,
103 OUT PULONG ReturnLength)
105 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
106 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength,ReturnLength
108 /* "These are not the debuggers you are looking for." */
109 if (ProcessInformationClass == ProcessDebugPort)
110 /* set it to 0 aka "no debugger" to satisfy copy protections */
111 memset(ProcessInformation,0,ProcessInformationLength);
116 /******************************************************************************
117 * NtSetInformationProcess [NTDLL.@]
118 * ZwSetInformationProcess [NTDLL.@]
120 NTSTATUS WINAPI NtSetInformationProcess(
121 IN HANDLE ProcessHandle,
122 IN PROCESSINFOCLASS ProcessInformationClass,
123 IN PVOID ProcessInformation,
124 IN ULONG ProcessInformationLength)
126 FIXME("(0x%08x,0x%08x,%p,0x%08lx) stub\n",
127 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
135 /******************************************************************************
136 * NtResumeThread [NTDLL.@]
137 * ZwResumeThread [NTDLL.@]
139 NTSTATUS WINAPI NtResumeThread(
140 IN HANDLE ThreadHandle,
141 IN PULONG SuspendCount)
143 FIXME("(0x%08x,%p),stub!\n",
144 ThreadHandle,SuspendCount);
149 /******************************************************************************
150 * NtTerminateThread [NTDLL.@]
151 * ZwTerminateThread [NTDLL.@]
153 NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
158 SERVER_START_REQ( terminate_thread )
160 req->handle = handle;
161 req->exit_code = exit_code;
162 ret = wine_server_call( req );
163 self = !ret && reply->self;
170 if (last) exit( exit_code );
171 else SYSDEPS_ExitThread( exit_code );
177 /******************************************************************************
178 * NtQueryInformationThread [NTDLL.@]
179 * ZwQueryInformationThread [NTDLL.@]
182 NTSTATUS WINAPI NtQueryInformationThread(
183 IN HANDLE ThreadHandle,
184 IN THREADINFOCLASS ThreadInformationClass,
185 OUT PVOID ThreadInformation,
186 IN ULONG ThreadInformationLength,
187 OUT PULONG ReturnLength)
189 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
190 ThreadHandle, ThreadInformationClass, ThreadInformation,
191 ThreadInformationLength, ReturnLength);
195 /******************************************************************************
196 * NtSetInformationThread [NTDLL.@]
197 * ZwSetInformationThread [NTDLL.@]
199 NTSTATUS WINAPI NtSetInformationThread(
201 THREADINFOCLASS ThreadInformationClass,
202 PVOID ThreadInformation,
203 ULONG ThreadInformationLength)
205 FIXME("(0x%08x,0x%08x,%p,0x%08lx),stub!\n",
206 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
214 /******************************************************************************
215 * NtDuplicateToken [NTDLL.@]
216 * ZwDuplicateToken [NTDLL.@]
218 NTSTATUS WINAPI NtDuplicateToken(
219 IN HANDLE ExistingToken,
220 IN ACCESS_MASK DesiredAccess,
221 IN POBJECT_ATTRIBUTES ObjectAttributes,
222 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
223 IN TOKEN_TYPE TokenType,
224 OUT PHANDLE NewToken)
226 FIXME("(0x%08x,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
227 ExistingToken, DesiredAccess, ObjectAttributes,
228 ImpersonationLevel, TokenType, NewToken);
229 dump_ObjectAttributes(ObjectAttributes);
233 /******************************************************************************
234 * NtOpenProcessToken [NTDLL.@]
235 * ZwOpenProcessToken [NTDLL.@]
237 NTSTATUS WINAPI NtOpenProcessToken(
238 HANDLE ProcessHandle,
242 FIXME("(0x%08x,0x%08lx,%p): stub\n",
243 ProcessHandle,DesiredAccess, TokenHandle);
244 *TokenHandle = 0xcafe;
248 /******************************************************************************
249 * NtOpenThreadToken [NTDLL.@]
250 * ZwOpenThreadToken [NTDLL.@]
252 NTSTATUS WINAPI NtOpenThreadToken(
258 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
259 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
260 *TokenHandle = 0xcafe;
264 /******************************************************************************
265 * NtAdjustPrivilegesToken [NTDLL.@]
266 * ZwAdjustGroupsToken [NTDLL.@]
268 * FIXME: parameters unsafe
270 NTSTATUS WINAPI NtAdjustPrivilegesToken(
271 IN HANDLE TokenHandle,
272 IN BOOLEAN DisableAllPrivileges,
273 IN PTOKEN_PRIVILEGES NewState,
274 IN DWORD BufferLength,
275 OUT PTOKEN_PRIVILEGES PreviousState,
276 OUT PDWORD ReturnLength)
278 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
279 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
283 /******************************************************************************
284 * NtQueryInformationToken [NTDLL.@]
285 * ZwQueryInformationToken [NTDLL.@]
288 * Buffer for TokenUser:
289 * 0x00 TOKEN_USER the PSID field points to the SID
293 NTSTATUS WINAPI NtQueryInformationToken(
295 DWORD tokeninfoclass,
297 DWORD tokeninfolength,
300 unsigned int len = 0;
302 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
303 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
305 switch (tokeninfoclass)
308 len = sizeof(TOKEN_USER) + sizeof(SID);
311 len = sizeof(TOKEN_GROUPS);
313 case TokenPrivileges:
314 len = sizeof(TOKEN_PRIVILEGES);
317 len = sizeof(TOKEN_OWNER);
319 case TokenPrimaryGroup:
320 len = sizeof(TOKEN_PRIMARY_GROUP);
322 case TokenDefaultDacl:
323 len = sizeof(TOKEN_DEFAULT_DACL);
326 len = sizeof(TOKEN_SOURCE);
329 len = sizeof (TOKEN_TYPE);
332 case TokenImpersonationLevel:
333 case TokenStatistics:
337 /* FIXME: what if retlen == NULL ? */
340 if (tokeninfolength < len)
341 return STATUS_BUFFER_TOO_SMALL;
343 switch (tokeninfoclass)
348 TOKEN_USER * tuser = tokeninfo;
349 PSID sid = (PSID) (tuser + 1);
350 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
351 RtlInitializeSid(sid, &localSidAuthority, 1);
352 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
353 tuser->User.Sid = sid;
359 TOKEN_GROUPS *tgroups = tokeninfo;
360 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
362 /* we need to show admin privileges ! */
363 tgroups->GroupCount = 1;
364 RtlAllocateAndInitializeSid( &sid,
366 SECURITY_BUILTIN_DOMAIN_RID,
367 DOMAIN_ALIAS_RID_ADMINS,
369 &(tgroups->Groups->Sid));
372 case TokenPrivileges:
375 TOKEN_PRIVILEGES *tpriv = tokeninfo;
376 tpriv->PrivilegeCount = 1;
387 /******************************************************************************
388 * NtCreateSection [NTDLL.@]
389 * ZwCreateSection [NTDLL.@]
391 NTSTATUS WINAPI NtCreateSection(
392 OUT PHANDLE SectionHandle,
393 IN ACCESS_MASK DesiredAccess,
394 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
395 IN PLARGE_INTEGER MaximumSize OPTIONAL,
396 IN ULONG SectionPageProtection OPTIONAL,
397 IN ULONG AllocationAttributes,
398 IN HANDLE FileHandle OPTIONAL)
400 FIXME("(%p,0x%08lx,%p,%p,0x%08lx,0x%08lx,0x%08x) stub\n",
401 SectionHandle,DesiredAccess, ObjectAttributes,
402 MaximumSize,SectionPageProtection,AllocationAttributes,FileHandle);
403 dump_ObjectAttributes(ObjectAttributes);
407 /******************************************************************************
408 * NtOpenSection [NTDLL.@]
409 * ZwOpenSection [NTDLL.@]
411 NTSTATUS WINAPI NtOpenSection(
412 PHANDLE SectionHandle,
413 ACCESS_MASK DesiredAccess,
414 POBJECT_ATTRIBUTES ObjectAttributes)
416 FIXME("(%p,0x%08lx,%p),stub!\n",
417 SectionHandle,DesiredAccess,ObjectAttributes);
418 dump_ObjectAttributes(ObjectAttributes);
422 /******************************************************************************
423 * NtQuerySection [NTDLL.@]
425 NTSTATUS WINAPI NtQuerySection(
426 IN HANDLE SectionHandle,
427 IN PVOID SectionInformationClass,
428 OUT PVOID SectionInformation,
430 OUT PULONG ResultLength)
432 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
433 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
437 /******************************************************************************
438 * NtMapViewOfSection [NTDLL.@]
439 * ZwMapViewOfSection [NTDLL.@]
440 * FUNCTION: Maps a view of a section into the virtual address space of a process
443 * SectionHandle Handle of the section
444 * ProcessHandle Handle of the process
445 * BaseAddress Desired base address (or NULL) on entry
446 * Actual base address of the view on exit
447 * ZeroBits Number of high order address bits that must be zero
448 * CommitSize Size in bytes of the initially committed section of the view
449 * SectionOffset Offset in bytes from the beginning of the section to the beginning of the view
450 * ViewSize Desired length of map (or zero to map all) on entry
451 Actual length mapped on exit
452 * InheritDisposition Specified how the view is to be shared with
454 * AllocateType Type of allocation for the pages
455 * Protect Protection for the committed region of the view
457 NTSTATUS WINAPI NtMapViewOfSection(
458 HANDLE SectionHandle,
459 HANDLE ProcessHandle,
463 PLARGE_INTEGER SectionOffset,
465 SECTION_INHERIT InheritDisposition,
466 ULONG AllocationType,
469 FIXME("(0x%08x,0x%08x,%p,0x%08lx,0x%08lx,%p,%p,0x%08x,0x%08lx,0x%08lx) stub\n",
470 SectionHandle,ProcessHandle,BaseAddress,ZeroBits,CommitSize,SectionOffset,
471 ViewSize,InheritDisposition,AllocationType,Protect);
479 /******************************************************************************
480 * NtCreatePort [NTDLL.@]
481 * ZwCreatePort [NTDLL.@]
483 NTSTATUS WINAPI NtCreatePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
485 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5);
489 /******************************************************************************
490 * NtConnectPort [NTDLL.@]
491 * ZwConnectPort [NTDLL.@]
493 NTSTATUS WINAPI NtConnectPort(DWORD x1,PUNICODE_STRING uni,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
495 FIXME("(0x%08lx,%s,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
496 x1,debugstr_w(uni->Buffer),x3,x4,x5,x6,x7,x8);
500 /******************************************************************************
501 * NtListenPort [NTDLL.@]
502 * ZwListenPort [NTDLL.@]
504 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
506 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
510 /******************************************************************************
511 * NtAcceptConnectPort [NTDLL.@]
512 * ZwAcceptConnectPort [NTDLL.@]
514 NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6)
516 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6);
520 /******************************************************************************
521 * NtCompleteConnectPort [NTDLL.@]
522 * ZwCompleteConnectPort [NTDLL.@]
524 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
526 FIXME("(0x%08lx),stub!\n",x1);
530 /******************************************************************************
531 * NtRegisterThreadTerminatePort [NTDLL.@]
532 * ZwRegisterThreadTerminatePort [NTDLL.@]
534 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
536 FIXME("(0x%08lx),stub!\n",x1);
540 /******************************************************************************
541 * NtRequestWaitReplyPort [NTDLL.@]
542 * ZwRequestWaitReplyPort [NTDLL.@]
544 NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1,DWORD x2,DWORD x3)
546 FIXME("(0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3);
550 /******************************************************************************
551 * NtReplyWaitReceivePort [NTDLL.@]
552 * ZwReplyWaitReceivePort [NTDLL.@]
554 NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4)
556 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
564 /******************************************************************************
565 * NtSetIntervalProfile [NTDLL.@]
566 * ZwSetIntervalProfile [NTDLL.@]
568 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
569 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
573 /******************************************************************************
574 * NtQueryPerformanceCounter [NTDLL.@]
576 NTSTATUS WINAPI NtQueryPerformanceCounter(
577 IN PLARGE_INTEGER Counter,
578 IN PLARGE_INTEGER Frequency)
580 FIXME("(%p, 0%p) stub\n",
585 /******************************************************************************
586 * NtCreateMailslotFile [NTDLL.@]
587 * ZwCreateMailslotFile [NTDLL.@]
589 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
591 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);
595 /******************************************************************************
596 * NtQuerySystemInformation [NTDLL.@]
597 * ZwQuerySystemInformation [NTDLL.@]
600 * SystemInformationClass Index to a certain information structure
601 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
602 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
603 * SystemConfigurationInformation CONFIGURATION_INFORMATION
604 * observed (class/len):
610 * SystemInformation caller supplies storage for the information structure
611 * Length size of the structure
612 * ResultLength Data written
614 NTSTATUS WINAPI NtQuerySystemInformation(
615 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
616 OUT PVOID SystemInformation,
618 OUT PULONG ResultLength)
620 switch(SystemInformationClass)
623 /* Something to do with the size of the registry *
624 * Since we don't have a size limitation, fake it *
625 * This is almost certainly wrong. *
626 * This sets each of the three words in the struct to 32 MB, *
627 * which is enough to make the IE 5 installer happy. */
628 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
629 SystemInformationClass,SystemInformation,Length,ResultLength);
630 *(DWORD *)SystemInformation = 0x2000000;
631 *(((DWORD *)SystemInformation)+1) = 0x200000;
632 *(((DWORD *)SystemInformation)+2) = 0x200000;
636 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
637 SystemInformationClass,SystemInformation,Length,ResultLength);
638 ZeroMemory (SystemInformation, Length);
641 return STATUS_SUCCESS;
645 /******************************************************************************
646 * NtCreatePagingFile [NTDLL.@]
647 * ZwCreatePagingFile [NTDLL.@]
649 NTSTATUS WINAPI NtCreatePagingFile(
650 IN PUNICODE_STRING PageFileName,
653 OUT PULONG ActualSize)
655 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
656 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
660 /******************************************************************************
661 * NtDisplayString [NTDLL.@]
663 * writes a string to the nt-textmode screen eg. during startup
665 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
670 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
672 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
673 RtlFreeAnsiString( &stringA );
678 /******************************************************************************
679 * NtPowerInformation [NTDLL.@]
682 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
684 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
688 /******************************************************************************
689 * NtAllocateLocallyUniqueId (NTDLL.@)
691 * FIXME: the server should do that
693 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
697 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.HighPart, luid.LowPart);
702 Luid->HighPart = luid.HighPart;
703 Luid->LowPart = luid.LowPart;
705 return STATUS_SUCCESS;