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"
20 DEFAULT_DEBUG_CHANNEL(ntdll);
26 /**************************************************************************
27 * NtCreateTimer [NTDLL.87]
29 NTSTATUS WINAPI NtCreateTimer(
30 OUT PHANDLE TimerHandle,
31 IN ACCESS_MASK DesiredAccess,
32 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
33 IN TIMER_TYPE TimerType)
35 FIXME("(%p,0x%08lx,%p,0x%08x) stub\n",
36 TimerHandle,DesiredAccess,ObjectAttributes, TimerType);
37 dump_ObjectAttributes(ObjectAttributes);
40 /**************************************************************************
41 * NtSetTimer [NTDLL.221]
43 NTSTATUS WINAPI NtSetTimer(
44 IN HANDLE TimerHandle,
45 IN PLARGE_INTEGER DueTime,
46 IN PTIMERAPCROUTINE TimerApcRoutine,
47 IN PVOID TimerContext,
49 IN ULONG Period OPTIONAL,
50 OUT PBOOLEAN PreviousState OPTIONAL)
52 FIXME("(0x%08x,%p,%p,%p,%08x,0x%08lx,%p) stub\n",
53 TimerHandle,DueTime,TimerApcRoutine,TimerContext,WakeTimer,Period,PreviousState);
57 /******************************************************************************
58 * NtQueryTimerResolution [NTDLL.129]
60 NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,DWORD x2,DWORD x3)
62 FIXME("(0x%08lx,0x%08lx,0x%08lx), stub!\n",x1,x2,x3);
70 /******************************************************************************
71 * NtTerminateProcess [NTDLL.]
73 * Native applications must kill themselves when done
75 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
79 SERVER_START_REQ( terminate_process )
82 req->exit_code = exit_code;
84 self = !ret && req->self;
87 if (self) exit( exit_code );
91 /******************************************************************************
92 * NtQueryInformationProcess [NTDLL.]
95 NTSTATUS WINAPI NtQueryInformationProcess(
96 IN HANDLE ProcessHandle,
97 IN PROCESSINFOCLASS ProcessInformationClass,
98 OUT PVOID ProcessInformation,
99 IN ULONG ProcessInformationLength,
100 OUT PULONG ReturnLength)
102 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
103 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength,ReturnLength
105 /* "These are not the debuggers you are looking for." */
106 if (ProcessInformationClass == ProcessDebugPort)
107 /* set it to 0 aka "no debugger" to satisfy copy protections */
108 memset(ProcessInformation,0,ProcessInformationLength);
113 /******************************************************************************
114 * NtSetInformationProcess [NTDLL.207]
116 NTSTATUS WINAPI NtSetInformationProcess(
117 IN HANDLE ProcessHandle,
118 IN PROCESSINFOCLASS ProcessInformationClass,
119 IN PVOID ProcessInformation,
120 IN ULONG ProcessInformationLength)
122 FIXME("(0x%08x,0x%08x,%p,0x%08lx) stub\n",
123 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
131 /******************************************************************************
132 * NtResumeThread [NTDLL]
134 NTSTATUS WINAPI NtResumeThread(
135 IN HANDLE ThreadHandle,
136 IN PULONG SuspendCount)
138 FIXME("(0x%08x,%p),stub!\n",
139 ThreadHandle,SuspendCount);
144 /******************************************************************************
145 * NtTerminateThread [NTDLL]
147 NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
152 SERVER_START_REQ( terminate_thread )
154 req->handle = handle;
155 req->exit_code = exit_code;
157 self = !ret && req->self;
164 if (last) exit( exit_code );
165 else SYSDEPS_ExitThread( exit_code );
171 /******************************************************************************
172 * NtQueryInformationThread [NTDLL.]
175 NTSTATUS WINAPI NtQueryInformationThread(
176 IN HANDLE ThreadHandle,
177 IN THREADINFOCLASS ThreadInformationClass,
178 OUT PVOID ThreadInformation,
179 IN ULONG ThreadInformationLength,
180 OUT PULONG ReturnLength)
182 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
183 ThreadHandle, ThreadInformationClass, ThreadInformation,
184 ThreadInformationLength, ReturnLength);
188 /******************************************************************************
189 * NtSetInformationThread [NTDLL]
191 NTSTATUS WINAPI NtSetInformationThread(
193 THREADINFOCLASS ThreadInformationClass,
194 PVOID ThreadInformation,
195 ULONG ThreadInformationLength)
197 FIXME("(0x%08x,0x%08x,%p,0x%08lx),stub!\n",
198 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
206 /******************************************************************************
207 * NtDuplicateToken [NTDLL]
209 NTSTATUS WINAPI NtDuplicateToken(
210 IN HANDLE ExistingToken,
211 IN ACCESS_MASK DesiredAccess,
212 IN POBJECT_ATTRIBUTES ObjectAttributes,
213 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
214 IN TOKEN_TYPE TokenType,
215 OUT PHANDLE NewToken)
217 FIXME("(0x%08x,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
218 ExistingToken, DesiredAccess, ObjectAttributes,
219 ImpersonationLevel, TokenType, NewToken);
220 dump_ObjectAttributes(ObjectAttributes);
224 /******************************************************************************
225 * NtOpenProcessToken [NTDLL]
227 NTSTATUS WINAPI NtOpenProcessToken(
228 HANDLE ProcessHandle,
232 FIXME("(0x%08x,0x%08lx,%p): stub\n",
233 ProcessHandle,DesiredAccess, TokenHandle);
234 *TokenHandle = 0xcafe;
238 /******************************************************************************
239 * NtOpenThreadToken [NTDLL]
241 NTSTATUS WINAPI NtOpenThreadToken(
247 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
248 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
249 *TokenHandle = 0xcafe;
253 /******************************************************************************
254 * NtAdjustPrivilegesToken [NTDLL]
256 * FIXME: parameters unsafe
258 NTSTATUS WINAPI NtAdjustPrivilegesToken(
259 IN HANDLE TokenHandle,
260 IN BOOLEAN DisableAllPrivileges,
261 IN PTOKEN_PRIVILEGES NewState,
262 IN DWORD BufferLength,
263 OUT PTOKEN_PRIVILEGES PreviousState,
264 OUT PDWORD ReturnLength)
266 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
267 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
271 /******************************************************************************
272 * NtQueryInformationToken [NTDLL.156]
275 * Buffer for TokenUser:
276 * 0x00 TOKEN_USER the PSID field points to the SID
280 NTSTATUS WINAPI NtQueryInformationToken(
282 DWORD tokeninfoclass,
284 DWORD tokeninfolength,
287 unsigned int len = 0;
289 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
290 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
292 switch (tokeninfoclass)
295 len = sizeof(TOKEN_USER) + sizeof(SID);
298 len = sizeof(TOKEN_GROUPS);
300 case TokenPrivileges:
301 len = sizeof(TOKEN_PRIVILEGES);
304 len = sizeof(TOKEN_OWNER);
306 case TokenPrimaryGroup:
307 len = sizeof(TOKEN_PRIMARY_GROUP);
309 case TokenDefaultDacl:
310 len = sizeof(TOKEN_DEFAULT_DACL);
313 len = sizeof(TOKEN_SOURCE);
316 len = sizeof (TOKEN_TYPE);
319 case TokenImpersonationLevel:
320 case TokenStatistics:
324 /* FIXME: what if retlen == NULL ? */
327 if (tokeninfolength < len)
328 return STATUS_BUFFER_TOO_SMALL;
330 switch (tokeninfoclass)
335 TOKEN_USER * tuser = tokeninfo;
336 PSID sid = (PSID) (tuser + 1);
337 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
338 RtlInitializeSid(sid, &localSidAuthority, 1);
339 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
340 tuser->User.Sid = sid;
346 TOKEN_GROUPS *tgroups = tokeninfo;
347 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
349 /* we need to show admin privileges ! */
350 tgroups->GroupCount = 1;
351 RtlAllocateAndInitializeSid( &sid,
353 SECURITY_BUILTIN_DOMAIN_RID,
354 DOMAIN_ALIAS_RID_ADMINS,
356 &(tgroups->Groups->Sid));
359 case TokenPrivileges:
362 TOKEN_PRIVILEGES *tpriv = tokeninfo;
363 tpriv->PrivilegeCount = 1;
374 /******************************************************************************
375 * NtCreateSection [NTDLL]
377 NTSTATUS WINAPI NtCreateSection(
378 OUT PHANDLE SectionHandle,
379 IN ACCESS_MASK DesiredAccess,
380 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
381 IN PLARGE_INTEGER MaximumSize OPTIONAL,
382 IN ULONG SectionPageProtection OPTIONAL,
383 IN ULONG AllocationAttributes,
384 IN HANDLE FileHandle OPTIONAL)
386 FIXME("(%p,0x%08lx,%p,%p,0x%08lx,0x%08lx,0x%08x) stub\n",
387 SectionHandle,DesiredAccess, ObjectAttributes,
388 MaximumSize,SectionPageProtection,AllocationAttributes,FileHandle);
389 dump_ObjectAttributes(ObjectAttributes);
393 /******************************************************************************
394 * NtOpenSection [NTDLL]
396 NTSTATUS WINAPI NtOpenSection(
397 PHANDLE SectionHandle,
398 ACCESS_MASK DesiredAccess,
399 POBJECT_ATTRIBUTES ObjectAttributes)
401 FIXME("(%p,0x%08lx,%p),stub!\n",
402 SectionHandle,DesiredAccess,ObjectAttributes);
403 dump_ObjectAttributes(ObjectAttributes);
407 /******************************************************************************
408 * NtQuerySection [NTDLL]
410 NTSTATUS WINAPI NtQuerySection(
411 IN HANDLE SectionHandle,
412 IN PVOID SectionInformationClass,
413 OUT PVOID SectionInformation,
415 OUT PULONG ResultLength)
417 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
418 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
422 /******************************************************************************
423 * NtMapViewOfSection [NTDLL]
424 * FUNCTION: Maps a view of a section into the virtual address space of a process
427 * SectionHandle Handle of the section
428 * ProcessHandle Handle of the process
429 * BaseAddress Desired base address (or NULL) on entry
430 * Actual base address of the view on exit
431 * ZeroBits Number of high order address bits that must be zero
432 * CommitSize Size in bytes of the initially committed section of the view
433 * SectionOffset Offset in bytes from the beginning of the section to the beginning of the view
434 * ViewSize Desired length of map (or zero to map all) on entry
435 Actual length mapped on exit
436 * InheritDisposition Specified how the view is to be shared with
438 * AllocateType Type of allocation for the pages
439 * Protect Protection for the committed region of the view
441 NTSTATUS WINAPI NtMapViewOfSection(
442 HANDLE SectionHandle,
443 HANDLE ProcessHandle,
447 PLARGE_INTEGER SectionOffset,
449 SECTION_INHERIT InheritDisposition,
450 ULONG AllocationType,
453 FIXME("(0x%08x,0x%08x,%p,0x%08lx,0x%08lx,%p,%p,0x%08x,0x%08lx,0x%08lx) stub\n",
454 SectionHandle,ProcessHandle,BaseAddress,ZeroBits,CommitSize,SectionOffset,
455 ViewSize,InheritDisposition,AllocationType,Protect);
463 /******************************************************************************
464 * NtCreatePort [NTDLL]
466 NTSTATUS WINAPI NtCreatePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
468 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5);
472 /******************************************************************************
473 * NtConnectPort [NTDLL]
475 NTSTATUS WINAPI NtConnectPort(DWORD x1,PUNICODE_STRING uni,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
477 FIXME("(0x%08lx,%s,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
478 x1,debugstr_w(uni->Buffer),x3,x4,x5,x6,x7,x8);
482 /******************************************************************************
483 * NtListenPort [NTDLL]
485 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
487 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
491 /******************************************************************************
492 * NtAcceptConnectPort [NTDLL]
494 NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6)
496 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6);
500 /******************************************************************************
501 * NtCompleteConnectPort [NTDLL]
503 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
505 FIXME("(0x%08lx),stub!\n",x1);
509 /******************************************************************************
510 * NtRegisterThreadTerminatePort [NTDLL]
512 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
514 FIXME("(0x%08lx),stub!\n",x1);
518 /******************************************************************************
519 * NtRequestWaitReplyPort [NTDLL]
521 NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1,DWORD x2,DWORD x3)
523 FIXME("(0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3);
527 /******************************************************************************
528 * NtReplyWaitReceivePort [NTDLL]
530 NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4)
532 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
540 /******************************************************************************
541 * NtSetIntervalProfile [NTDLL]
543 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
544 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
548 /******************************************************************************
549 * NtQueryPerformanceCounter [NTDLL]
551 NTSTATUS WINAPI NtQueryPerformanceCounter(
552 IN PLARGE_INTEGER Counter,
553 IN PLARGE_INTEGER Frequency)
555 FIXME("(%p, 0%p) stub\n",
560 /******************************************************************************
561 * NtCreateMailslotFile [NTDLL]
563 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
565 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);
569 /******************************************************************************
570 * NtQuerySystemInformation [NTDLL.168]
573 * SystemInformationClass Index to a certain information structure
574 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
575 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
576 * SystemConfigurationInformation CONFIGURATION_INFORMATION
577 * observed (class/len):
583 * SystemInformation caller supplies storage for the information structure
584 * Length size of the structure
585 * ResultLength Data written
587 NTSTATUS WINAPI NtQuerySystemInformation(
588 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
589 OUT PVOID SystemInformation,
591 OUT PULONG ResultLength)
593 switch(SystemInformationClass)
596 /* Something to do with the size of the registry *
597 * Since we don't have a size limitation, fake it *
598 * This is almost certainly wrong. *
599 * This sets each of the three words in the struct to 32 MB, *
600 * which is enough to make the IE 5 installer happy. */
601 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
602 SystemInformationClass,SystemInformation,Length,ResultLength);
603 *(DWORD *)SystemInformation = 0x2000000;
604 *(((DWORD *)SystemInformation)+1) = 0x200000;
605 *(((DWORD *)SystemInformation)+2) = 0x200000;
609 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
610 SystemInformationClass,SystemInformation,Length,ResultLength);
611 ZeroMemory (SystemInformation, Length);
614 return STATUS_SUCCESS;
618 /******************************************************************************
619 * NtCreatePagingFile [NTDLL]
621 NTSTATUS WINAPI NtCreatePagingFile(
622 IN PUNICODE_STRING PageFileName,
625 OUT PULONG ActualSize)
627 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
628 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
632 /******************************************************************************
633 * NtDisplayString [NTDLL.95]
635 * writes a string to the nt-textmode screen eg. during startup
637 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
642 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
644 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
645 RtlFreeAnsiString( &stringA );
650 /******************************************************************************
651 * NtPowerInformation [NTDLL]
654 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
656 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
660 /******************************************************************************
661 * NtAllocateLocallyUniqueId
663 * FIXME: the server should do that
665 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
669 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.DUMMYSTRUCTNAME.HighPart, luid.DUMMYSTRUCTNAME.LowPart);
673 Luid->QuadPart = luid.QuadPart;
674 return STATUS_SUCCESS;