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 HAL)
7 * Copyright 1996-1998 Marcus Meissner
14 #include "debugtools.h"
17 #include "ntdll_misc.h"
19 DEFAULT_DEBUG_CHANNEL(ntdll);
25 /**************************************************************************
26 * NtCreateTimer [NTDLL.87]
28 NTSTATUS WINAPI NtCreateTimer(
29 OUT PHANDLE TimerHandle,
30 IN ACCESS_MASK DesiredAccess,
31 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
32 IN TIMER_TYPE TimerType)
34 FIXME("(%p,0x%08lx,%p,0x%08x) stub\n",
35 TimerHandle,DesiredAccess,ObjectAttributes, TimerType);
36 dump_ObjectAttributes(ObjectAttributes);
39 /**************************************************************************
40 * NtSetTimer [NTDLL.221]
42 NTSTATUS WINAPI NtSetTimer(
43 IN HANDLE TimerHandle,
44 IN PLARGE_INTEGER DueTime,
45 IN PTIMERAPCROUTINE TimerApcRoutine,
46 IN PVOID TimerContext,
48 IN ULONG Period OPTIONAL,
49 OUT PBOOLEAN PreviousState OPTIONAL)
51 FIXME("(0x%08x,%p,%p,%p,%08x,0x%08lx,%p) stub\n",
52 TimerHandle,DueTime,TimerApcRoutine,TimerContext,WakeTimer,Period,PreviousState);
56 /******************************************************************************
57 * NtQueryTimerResolution [NTDLL.129]
59 NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,DWORD x2,DWORD x3)
61 FIXME("(0x%08lx,0x%08lx,0x%08lx), stub!\n",x1,x2,x3);
69 /******************************************************************************
70 * NtTerminateProcess [NTDLL.]
72 * Native applications must kill themselves when done
73 * FIXME: return value 0-success
75 NTSTATUS WINAPI NtTerminateProcess(
79 TRACE("0x%08x 0x%08lx\n", ProcessHandle, ExitStatus );
81 /* win32 (0x7fffffff) to nt (-1) */
82 if ( NtCurrentProcess() == ProcessHandle )
83 ProcessHandle = GetCurrentProcess();
85 return (! TerminateProcess( ProcessHandle, ExitStatus ));
88 /******************************************************************************
89 * NtQueryInformationProcess [NTDLL.]
92 NTSTATUS WINAPI NtQueryInformationProcess(
93 IN HANDLE ProcessHandle,
94 IN PROCESSINFOCLASS ProcessInformationClass,
95 OUT PVOID ProcessInformation,
96 IN ULONG ProcessInformationLength,
97 OUT PULONG ReturnLength)
99 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
100 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength,ReturnLength);
104 /******************************************************************************
105 * NtSetInformationProcess [NTDLL.207]
107 NTSTATUS WINAPI NtSetInformationProcess(
108 IN HANDLE ProcessHandle,
109 IN PROCESSINFOCLASS ProcessInformationClass,
110 IN PVOID ProcessInformation,
111 IN ULONG ProcessInformationLength)
113 FIXME("(0x%08x,0x%08x,%p,0x%08lx) stub\n",
114 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
122 /******************************************************************************
123 * NtResumeThread [NTDLL]
125 NTSTATUS WINAPI NtResumeThread(
126 IN HANDLE ThreadHandle,
127 IN PULONG SuspendCount)
129 FIXME("(0x%08x,%p),stub!\n",
130 ThreadHandle,SuspendCount);
134 /******************************************************************************
135 * NtTerminateThread [NTDLL]
137 NTSTATUS WINAPI NtTerminateThread(
138 IN HANDLE ThreadHandle,
139 IN NTSTATUS ExitStatus)
141 if ( TerminateThread(ThreadHandle,ExitStatus) )
144 return 0xc0000000; /* FIXME: lasterror->ntstatus */
147 /******************************************************************************
148 * NtQueryInformationThread [NTDLL.]
151 NTSTATUS WINAPI NtQueryInformationThread(
152 IN HANDLE ThreadHandle,
153 IN THREADINFOCLASS ThreadInformationClass,
154 OUT PVOID ThreadInformation,
155 IN ULONG ThreadInformationLength,
156 OUT PULONG ReturnLength)
158 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
159 ThreadHandle, ThreadInformationClass, ThreadInformation,
160 ThreadInformationLength, ReturnLength);
164 /******************************************************************************
165 * NtSetInformationThread [NTDLL]
167 NTSTATUS WINAPI NtSetInformationThread(
169 THREADINFOCLASS ThreadInformationClass,
170 PVOID ThreadInformation,
171 ULONG ThreadInformationLength)
173 FIXME("(0x%08x,0x%08x,%p,0x%08lx),stub!\n",
174 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
182 /******************************************************************************
183 * NtDuplicateToken [NTDLL]
185 NTSTATUS WINAPI NtDuplicateToken(
186 IN HANDLE ExistingToken,
187 IN ACCESS_MASK DesiredAccess,
188 IN POBJECT_ATTRIBUTES ObjectAttributes,
189 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
190 IN TOKEN_TYPE TokenType,
191 OUT PHANDLE NewToken)
193 FIXME("(0x%08x,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
194 ExistingToken, DesiredAccess, ObjectAttributes,
195 ImpersonationLevel, TokenType, NewToken);
196 dump_ObjectAttributes(ObjectAttributes);
200 /******************************************************************************
201 * NtOpenProcessToken [NTDLL]
203 NTSTATUS WINAPI NtOpenProcessToken(
204 HANDLE ProcessHandle,
208 FIXME("(0x%08x,0x%08lx,%p): stub\n",
209 ProcessHandle,DesiredAccess, TokenHandle);
210 *TokenHandle = 0xcafe;
214 /******************************************************************************
215 * NtOpenThreadToken [NTDLL]
217 NTSTATUS WINAPI NtOpenThreadToken(
223 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
224 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
225 *TokenHandle = 0xcafe;
229 /******************************************************************************
230 * NtAdjustPrivilegesToken [NTDLL]
232 * FIXME: parameters unsafe
234 NTSTATUS WINAPI NtAdjustPrivilegesToken(
235 IN HANDLE TokenHandle,
236 IN BOOLEAN DisableAllPrivileges,
237 IN PTOKEN_PRIVILEGES NewState,
238 IN DWORD BufferLength,
239 OUT PTOKEN_PRIVILEGES PreviousState,
240 OUT PDWORD ReturnLength)
242 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
243 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
247 /******************************************************************************
248 * NtQueryInformationToken [NTDLL.156]
251 * Buffer for TokenUser:
252 * 0x00 TOKEN_USER the PSID field points to the SID
256 NTSTATUS WINAPI NtQueryInformationToken(
258 DWORD tokeninfoclass,
260 DWORD tokeninfolength,
263 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
264 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
266 switch (tokeninfoclass)
267 { case TokenGroups: /* 2 */
268 *retlen = sizeof (TOKEN_GROUPS);
270 case TokenUser: /* 1 */
272 int len = sizeof (TOKEN_USER)+ sizeof(SID);
274 if ( len <= tokeninfolength)
277 TOKEN_USER * tuser = tokeninfo;
278 PSID sid = (PSID) &((LPBYTE)tokeninfo)[sizeof(TOKEN_USER)];
279 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
280 RtlInitializeSid(sid, &localSidAuthority, 1);
281 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
282 tuser->User.Sid = sid;
286 case TokenPrivileges:
287 *retlen = sizeof (TOKEN_PRIVILEGES);
290 *retlen = sizeof (TOKEN_OWNER);
292 case TokenPrimaryGroup:
293 *retlen = sizeof (TOKEN_PRIMARY_GROUP);
295 case TokenDefaultDacl:
296 *retlen = sizeof (TOKEN_DEFAULT_DACL);
299 *retlen = sizeof (TOKEN_SOURCE);
302 *retlen = sizeof (TOKEN_TYPE);
305 case TokenImpersonationLevel:
306 case TokenStatistics:
317 /******************************************************************************
318 * NtCreateSection [NTDLL]
320 NTSTATUS WINAPI NtCreateSection(
321 OUT PHANDLE SectionHandle,
322 IN ACCESS_MASK DesiredAccess,
323 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
324 IN PLARGE_INTEGER MaximumSize OPTIONAL,
325 IN ULONG SectionPageProtection OPTIONAL,
326 IN ULONG AllocationAttributes,
327 IN HANDLE FileHandle OPTIONAL)
329 FIXME("(%p,0x%08lx,%p,%p,0x%08lx,0x%08lx,0x%08x) stub\n",
330 SectionHandle,DesiredAccess, ObjectAttributes,
331 MaximumSize,SectionPageProtection,AllocationAttributes,FileHandle);
332 dump_ObjectAttributes(ObjectAttributes);
336 /******************************************************************************
337 * NtOpenSection [NTDLL]
339 NTSTATUS WINAPI NtOpenSection(
340 PHANDLE SectionHandle,
341 ACCESS_MASK DesiredAccess,
342 POBJECT_ATTRIBUTES ObjectAttributes)
344 FIXME("(%p,0x%08lx,%p),stub!\n",
345 SectionHandle,DesiredAccess,ObjectAttributes);
346 dump_ObjectAttributes(ObjectAttributes);
350 /******************************************************************************
351 * NtQuerySection [NTDLL]
353 NTSTATUS WINAPI NtQuerySection(
354 IN HANDLE SectionHandle,
355 IN PVOID SectionInformationClass,
356 OUT PVOID SectionInformation,
358 OUT PULONG ResultLength)
360 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
361 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
365 /******************************************************************************
366 * NtMapViewOfSection [NTDLL]
367 * FUNCTION: Maps a view of a section into the virtual address space of a process
370 * SectionHandle Handle of the section
371 * ProcessHandle Handle of the process
372 * BaseAddress Desired base address (or NULL) on entry
373 * Actual base address of the view on exit
374 * ZeroBits Number of high order address bits that must be zero
375 * CommitSize Size in bytes of the initially committed section of the view
376 * SectionOffset Offset in bytes from the beginning of the section to the beginning of the view
377 * ViewSize Desired length of map (or zero to map all) on entry
378 Actual length mapped on exit
379 * InheritDisposition Specified how the view is to be shared with
381 * AllocateType Type of allocation for the pages
382 * Protect Protection for the committed region of the view
384 NTSTATUS WINAPI NtMapViewOfSection(
385 HANDLE SectionHandle,
386 HANDLE ProcessHandle,
390 PLARGE_INTEGER SectionOffset,
392 SECTION_INHERIT InheritDisposition,
393 ULONG AllocationType,
396 FIXME("(0x%08x,0x%08x,%p,0x%08lx,0x%08lx,%p,%p,0x%08x,0x%08lx,0x%08lx) stub\n",
397 SectionHandle,ProcessHandle,BaseAddress,ZeroBits,CommitSize,SectionOffset,
398 ViewSize,InheritDisposition,AllocationType,Protect);
406 /******************************************************************************
407 * NtCreatePort [NTDLL]
409 NTSTATUS WINAPI NtCreatePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
411 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5);
415 /******************************************************************************
416 * NtConnectPort [NTDLL]
418 NTSTATUS WINAPI NtConnectPort(DWORD x1,PUNICODE_STRING uni,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
420 FIXME("(0x%08lx,%s,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
421 x1,debugstr_w(uni->Buffer),x3,x4,x5,x6,x7,x8);
425 /******************************************************************************
426 * NtListenPort [NTDLL]
428 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
430 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
434 /******************************************************************************
435 * NtAcceptConnectPort [NTDLL]
437 NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6)
439 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4,x5,x6);
443 /******************************************************************************
444 * NtCompleteConnectPort [NTDLL]
446 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
448 FIXME("(0x%08lx),stub!\n",x1);
452 /******************************************************************************
453 * NtRegisterThreadTerminatePort [NTDLL]
455 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
457 FIXME("(0x%08lx),stub!\n",x1);
461 /******************************************************************************
462 * NtRequestWaitReplyPort [NTDLL]
464 NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1,DWORD x2,DWORD x3)
466 FIXME("(0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3);
470 /******************************************************************************
471 * NtReplyWaitReceivePort [NTDLL]
473 NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1,DWORD x2,DWORD x3,DWORD x4)
475 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1,x2,x3,x4);
483 /******************************************************************************
484 * NtSetIntervalProfile [NTDLL]
486 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
487 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
491 /******************************************************************************
492 * NtQueryPerformanceCounter [NTDLL]
494 NTSTATUS WINAPI NtQueryPerformanceCounter(
495 IN PLARGE_INTEGER Counter,
496 IN PLARGE_INTEGER Frequency)
498 FIXME("(%p, 0%p) stub\n",
503 /******************************************************************************
504 * NtCreateMailslotFile [NTDLL]
506 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
508 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);
512 /******************************************************************************
513 * NtQuerySystemInformation [NTDLL.168]
516 * SystemInformationClass Index to a certain information structure
517 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
518 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
519 * SystemConfigurationInformation CONFIGURATION_INFORMATION
520 * observed (class/len):
525 * SystemInformation caller supplies storage for the information structure
526 * Length size of the structure
527 * ResultLength Data written
529 NTSTATUS WINAPI NtQuerySystemInformation(
530 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
531 OUT PVOID SystemInformation,
533 OUT PULONG ResultLength)
535 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
536 SystemInformationClass,SystemInformation,Length,ResultLength);
537 ZeroMemory (SystemInformation, Length);
542 /******************************************************************************
543 * NtCreatePagingFile [NTDLL]
545 NTSTATUS WINAPI NtCreatePagingFile(
546 IN PUNICODE_STRING PageFileName,
549 OUT PULONG ActualSize)
551 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
552 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
556 /******************************************************************************
557 * NtDisplayString [NTDLL.95]
559 * writes a string to the nt-textmode screen eg. during startup
561 NTSTATUS WINAPI NtDisplayString (
562 PUNICODE_STRING string)
564 TRACE("%p(%s)\n",string->Buffer, debugstr_w(string->Buffer));
565 WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), string->Buffer, string->Length, 0, 0);
569 /******************************************************************************
570 * _alldiv [NTDLL.937]
574 long long WINAPI _alldiv(LARGE_INTEGER a, LARGE_INTEGER b)
576 #if SIZEOF_LONG_LONG==8
577 return (*(long long*)&a / *(long long*)&b);
583 /******************************************************************************
584 * _allmul [NTDLL.938]
588 long long WINAPI _allmul(LARGE_INTEGER a, LARGE_INTEGER b)
590 #if SIZEOF_LONG_LONG==8
591 return (*(long long*)&a * *(long long*)&b);
598 /******************************************************************************
599 * NtPowerInformation [NTDLL]
602 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
604 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
608 /******************************************************************************
609 * NtAllocateLocallyUniqueId
611 * FIXME: the server should do that
613 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
617 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.DUMMYSTRUCTNAME.HighPart, luid.DUMMYSTRUCTNAME.LowPart);
621 Luid->QuadPart = luid.QuadPart;
622 return STATUS_SUCCESS;