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
)
81 struct terminate_process_request
*req
= server_alloc_req( sizeof(*req
), 0 );
83 req
->exit_code
= exit_code
;
84 ret
= server_call_noerr( REQ_TERMINATE_PROCESS
);
85 self
= !ret
&& req
->self
;
88 if (self
) exit( exit_code
);
92 /******************************************************************************
93 * NtQueryInformationProcess [NTDLL.]
96 NTSTATUS WINAPI
NtQueryInformationProcess(
97 IN HANDLE ProcessHandle
,
98 IN PROCESSINFOCLASS ProcessInformationClass
,
99 OUT PVOID ProcessInformation
,
100 IN ULONG ProcessInformationLength
,
101 OUT PULONG ReturnLength
)
103 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
104 ProcessHandle
,ProcessInformationClass
,ProcessInformation
,ProcessInformationLength
,ReturnLength
106 /* "These are not the debuggers you are looking for." */
107 if (ProcessInformationClass
== ProcessDebugPort
)
108 /* set it to 0 aka "no debugger" to satisfy copy protections */
109 memset(ProcessInformation
,0,ProcessInformationLength
);
114 /******************************************************************************
115 * NtSetInformationProcess [NTDLL.207]
117 NTSTATUS WINAPI
NtSetInformationProcess(
118 IN HANDLE ProcessHandle
,
119 IN PROCESSINFOCLASS ProcessInformationClass
,
120 IN PVOID ProcessInformation
,
121 IN ULONG ProcessInformationLength
)
123 FIXME("(0x%08x,0x%08x,%p,0x%08lx) stub\n",
124 ProcessHandle
,ProcessInformationClass
,ProcessInformation
,ProcessInformationLength
);
132 /******************************************************************************
133 * NtResumeThread [NTDLL]
135 NTSTATUS WINAPI
NtResumeThread(
136 IN HANDLE ThreadHandle
,
137 IN PULONG SuspendCount
)
139 FIXME("(0x%08x,%p),stub!\n",
140 ThreadHandle
,SuspendCount
);
145 /******************************************************************************
146 * NtTerminateThread [NTDLL]
148 NTSTATUS WINAPI
NtTerminateThread( HANDLE handle
, LONG exit_code
)
155 struct terminate_thread_request
*req
= server_alloc_req( sizeof(*req
), 0 );
156 req
->handle
= handle
;
157 req
->exit_code
= exit_code
;
158 ret
= server_call_noerr( REQ_TERMINATE_THREAD
);
159 self
= !ret
&& req
->self
;
166 if (last
) exit( exit_code
);
167 else SYSDEPS_ExitThread( exit_code
);
173 /******************************************************************************
174 * NtQueryInformationThread [NTDLL.]
177 NTSTATUS WINAPI
NtQueryInformationThread(
178 IN HANDLE ThreadHandle
,
179 IN THREADINFOCLASS ThreadInformationClass
,
180 OUT PVOID ThreadInformation
,
181 IN ULONG ThreadInformationLength
,
182 OUT PULONG ReturnLength
)
184 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p),stub!\n",
185 ThreadHandle
, ThreadInformationClass
, ThreadInformation
,
186 ThreadInformationLength
, ReturnLength
);
190 /******************************************************************************
191 * NtSetInformationThread [NTDLL]
193 NTSTATUS WINAPI
NtSetInformationThread(
195 THREADINFOCLASS ThreadInformationClass
,
196 PVOID ThreadInformation
,
197 ULONG ThreadInformationLength
)
199 FIXME("(0x%08x,0x%08x,%p,0x%08lx),stub!\n",
200 ThreadHandle
, ThreadInformationClass
, ThreadInformation
, ThreadInformationLength
);
208 /******************************************************************************
209 * NtDuplicateToken [NTDLL]
211 NTSTATUS WINAPI
NtDuplicateToken(
212 IN HANDLE ExistingToken
,
213 IN ACCESS_MASK DesiredAccess
,
214 IN POBJECT_ATTRIBUTES ObjectAttributes
,
215 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
,
216 IN TOKEN_TYPE TokenType
,
217 OUT PHANDLE NewToken
)
219 FIXME("(0x%08x,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
220 ExistingToken
, DesiredAccess
, ObjectAttributes
,
221 ImpersonationLevel
, TokenType
, NewToken
);
222 dump_ObjectAttributes(ObjectAttributes
);
226 /******************************************************************************
227 * NtOpenProcessToken [NTDLL]
229 NTSTATUS WINAPI
NtOpenProcessToken(
230 HANDLE ProcessHandle
,
234 FIXME("(0x%08x,0x%08lx,%p): stub\n",
235 ProcessHandle
,DesiredAccess
, TokenHandle
);
236 *TokenHandle
= 0xcafe;
240 /******************************************************************************
241 * NtOpenThreadToken [NTDLL]
243 NTSTATUS WINAPI
NtOpenThreadToken(
249 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
250 ThreadHandle
,DesiredAccess
, OpenAsSelf
, TokenHandle
);
251 *TokenHandle
= 0xcafe;
255 /******************************************************************************
256 * NtAdjustPrivilegesToken [NTDLL]
258 * FIXME: parameters unsafe
260 NTSTATUS WINAPI
NtAdjustPrivilegesToken(
261 IN HANDLE TokenHandle
,
262 IN BOOLEAN DisableAllPrivileges
,
263 IN PTOKEN_PRIVILEGES NewState
,
264 IN DWORD BufferLength
,
265 OUT PTOKEN_PRIVILEGES PreviousState
,
266 OUT PDWORD ReturnLength
)
268 FIXME("(0x%08x,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
269 TokenHandle
, DisableAllPrivileges
, NewState
, BufferLength
, PreviousState
, ReturnLength
);
273 /******************************************************************************
274 * NtQueryInformationToken [NTDLL.156]
277 * Buffer for TokenUser:
278 * 0x00 TOKEN_USER the PSID field points to the SID
282 NTSTATUS WINAPI
NtQueryInformationToken(
284 DWORD tokeninfoclass
,
286 DWORD tokeninfolength
,
289 unsigned int len
= 0;
291 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
292 token
,tokeninfoclass
,tokeninfo
,tokeninfolength
,retlen
);
294 switch (tokeninfoclass
)
297 len
= sizeof(TOKEN_USER
) + sizeof(SID
);
300 len
= sizeof(TOKEN_GROUPS
);
302 case TokenPrivileges
:
303 len
= sizeof(TOKEN_PRIVILEGES
);
306 len
= sizeof(TOKEN_OWNER
);
308 case TokenPrimaryGroup
:
309 len
= sizeof(TOKEN_PRIMARY_GROUP
);
311 case TokenDefaultDacl
:
312 len
= sizeof(TOKEN_DEFAULT_DACL
);
315 len
= sizeof(TOKEN_SOURCE
);
318 len
= sizeof (TOKEN_TYPE
);
321 case TokenImpersonationLevel
:
322 case TokenStatistics
:
326 /* FIXME: what if retlen == NULL ? */
329 if (tokeninfolength
< len
)
330 return STATUS_BUFFER_TOO_SMALL
;
332 switch (tokeninfoclass
)
337 TOKEN_USER
* tuser
= tokeninfo
;
338 PSID sid
= (PSID
) (tuser
+ 1);
339 SID_IDENTIFIER_AUTHORITY localSidAuthority
= {SECURITY_NT_AUTHORITY
};
340 RtlInitializeSid(sid
, &localSidAuthority
, 1);
341 *(RtlSubAuthoritySid(sid
, 0)) = SECURITY_INTERACTIVE_RID
;
342 tuser
->User
.Sid
= sid
;
348 TOKEN_GROUPS
*tgroups
= tokeninfo
;
349 SID_IDENTIFIER_AUTHORITY sid
= {SECURITY_NT_AUTHORITY
};
351 /* we need to show admin privileges ! */
352 tgroups
->GroupCount
= 1;
353 RtlAllocateAndInitializeSid( &sid
,
355 SECURITY_BUILTIN_DOMAIN_RID
,
356 DOMAIN_ALIAS_RID_ADMINS
,
358 &(tgroups
->Groups
->Sid
));
361 case TokenPrivileges
:
364 TOKEN_PRIVILEGES
*tpriv
= tokeninfo
;
365 tpriv
->PrivilegeCount
= 1;
376 /******************************************************************************
377 * NtCreateSection [NTDLL]
379 NTSTATUS WINAPI
NtCreateSection(
380 OUT PHANDLE SectionHandle
,
381 IN ACCESS_MASK DesiredAccess
,
382 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
,
383 IN PLARGE_INTEGER MaximumSize OPTIONAL
,
384 IN ULONG SectionPageProtection OPTIONAL
,
385 IN ULONG AllocationAttributes
,
386 IN HANDLE FileHandle OPTIONAL
)
388 FIXME("(%p,0x%08lx,%p,%p,0x%08lx,0x%08lx,0x%08x) stub\n",
389 SectionHandle
,DesiredAccess
, ObjectAttributes
,
390 MaximumSize
,SectionPageProtection
,AllocationAttributes
,FileHandle
);
391 dump_ObjectAttributes(ObjectAttributes
);
395 /******************************************************************************
396 * NtOpenSection [NTDLL]
398 NTSTATUS WINAPI
NtOpenSection(
399 PHANDLE SectionHandle
,
400 ACCESS_MASK DesiredAccess
,
401 POBJECT_ATTRIBUTES ObjectAttributes
)
403 FIXME("(%p,0x%08lx,%p),stub!\n",
404 SectionHandle
,DesiredAccess
,ObjectAttributes
);
405 dump_ObjectAttributes(ObjectAttributes
);
409 /******************************************************************************
410 * NtQuerySection [NTDLL]
412 NTSTATUS WINAPI
NtQuerySection(
413 IN HANDLE SectionHandle
,
414 IN PVOID SectionInformationClass
,
415 OUT PVOID SectionInformation
,
417 OUT PULONG ResultLength
)
419 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
420 SectionHandle
,SectionInformationClass
,SectionInformation
,Length
,ResultLength
);
424 /******************************************************************************
425 * NtMapViewOfSection [NTDLL]
426 * FUNCTION: Maps a view of a section into the virtual address space of a process
429 * SectionHandle Handle of the section
430 * ProcessHandle Handle of the process
431 * BaseAddress Desired base address (or NULL) on entry
432 * Actual base address of the view on exit
433 * ZeroBits Number of high order address bits that must be zero
434 * CommitSize Size in bytes of the initially committed section of the view
435 * SectionOffset Offset in bytes from the beginning of the section to the beginning of the view
436 * ViewSize Desired length of map (or zero to map all) on entry
437 Actual length mapped on exit
438 * InheritDisposition Specified how the view is to be shared with
440 * AllocateType Type of allocation for the pages
441 * Protect Protection for the committed region of the view
443 NTSTATUS WINAPI
NtMapViewOfSection(
444 HANDLE SectionHandle
,
445 HANDLE ProcessHandle
,
449 PLARGE_INTEGER SectionOffset
,
451 SECTION_INHERIT InheritDisposition
,
452 ULONG AllocationType
,
455 FIXME("(0x%08x,0x%08x,%p,0x%08lx,0x%08lx,%p,%p,0x%08x,0x%08lx,0x%08lx) stub\n",
456 SectionHandle
,ProcessHandle
,BaseAddress
,ZeroBits
,CommitSize
,SectionOffset
,
457 ViewSize
,InheritDisposition
,AllocationType
,Protect
);
465 /******************************************************************************
466 * NtCreatePort [NTDLL]
468 NTSTATUS WINAPI
NtCreatePort(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
,DWORD x5
)
470 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1
,x2
,x3
,x4
,x5
);
474 /******************************************************************************
475 * NtConnectPort [NTDLL]
477 NTSTATUS WINAPI
NtConnectPort(DWORD x1
,PUNICODE_STRING uni
,DWORD x3
,DWORD x4
,DWORD x5
,DWORD x6
,DWORD x7
,DWORD x8
)
479 FIXME("(0x%08lx,%s,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",
480 x1
,debugstr_w(uni
->Buffer
),x3
,x4
,x5
,x6
,x7
,x8
);
484 /******************************************************************************
485 * NtListenPort [NTDLL]
487 NTSTATUS WINAPI
NtListenPort(DWORD x1
,DWORD x2
)
489 FIXME("(0x%08lx,0x%08lx),stub!\n",x1
,x2
);
493 /******************************************************************************
494 * NtAcceptConnectPort [NTDLL]
496 NTSTATUS WINAPI
NtAcceptConnectPort(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
,DWORD x5
,DWORD x6
)
498 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1
,x2
,x3
,x4
,x5
,x6
);
502 /******************************************************************************
503 * NtCompleteConnectPort [NTDLL]
505 NTSTATUS WINAPI
NtCompleteConnectPort(DWORD x1
)
507 FIXME("(0x%08lx),stub!\n",x1
);
511 /******************************************************************************
512 * NtRegisterThreadTerminatePort [NTDLL]
514 NTSTATUS WINAPI
NtRegisterThreadTerminatePort(DWORD x1
)
516 FIXME("(0x%08lx),stub!\n",x1
);
520 /******************************************************************************
521 * NtRequestWaitReplyPort [NTDLL]
523 NTSTATUS WINAPI
NtRequestWaitReplyPort(DWORD x1
,DWORD x2
,DWORD x3
)
525 FIXME("(0x%08lx,0x%08lx,0x%08lx),stub!\n",x1
,x2
,x3
);
529 /******************************************************************************
530 * NtReplyWaitReceivePort [NTDLL]
532 NTSTATUS WINAPI
NtReplyWaitReceivePort(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
)
534 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub!\n",x1
,x2
,x3
,x4
);
542 /******************************************************************************
543 * NtSetIntervalProfile [NTDLL]
545 NTSTATUS WINAPI
NtSetIntervalProfile(DWORD x1
,DWORD x2
) {
546 FIXME("(0x%08lx,0x%08lx),stub!\n",x1
,x2
);
550 /******************************************************************************
551 * NtQueryPerformanceCounter [NTDLL]
553 NTSTATUS WINAPI
NtQueryPerformanceCounter(
554 IN PLARGE_INTEGER Counter
,
555 IN PLARGE_INTEGER Frequency
)
557 FIXME("(%p, 0%p) stub\n",
562 /******************************************************************************
563 * NtCreateMailslotFile [NTDLL]
565 NTSTATUS WINAPI
NtCreateMailslotFile(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
,DWORD x5
,DWORD x6
,DWORD x7
,DWORD x8
)
567 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
);
571 /******************************************************************************
572 * NtQuerySystemInformation [NTDLL.168]
575 * SystemInformationClass Index to a certain information structure
576 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
577 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
578 * SystemConfigurationInformation CONFIGURATION_INFORMATION
579 * observed (class/len):
585 * SystemInformation caller supplies storage for the information structure
586 * Length size of the structure
587 * ResultLength Data written
589 NTSTATUS WINAPI
NtQuerySystemInformation(
590 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
591 OUT PVOID SystemInformation
,
593 OUT PULONG ResultLength
)
595 switch(SystemInformationClass
)
598 /* Something to do with the size of the registry *
599 * Since we don't have a size limitation, fake it *
600 * This is almost certainly wrong. *
601 * This sets each of the three words in the struct to 32 MB, *
602 * which is enough to make the IE 5 installer happy. */
603 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
604 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
605 *(DWORD
*)SystemInformation
= 0x2000000;
606 *(((DWORD
*)SystemInformation
)+1) = 0x200000;
607 *(((DWORD
*)SystemInformation
)+2) = 0x200000;
611 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
612 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
613 ZeroMemory (SystemInformation
, Length
);
616 return STATUS_SUCCESS
;
620 /******************************************************************************
621 * NtCreatePagingFile [NTDLL]
623 NTSTATUS WINAPI
NtCreatePagingFile(
624 IN PUNICODE_STRING PageFileName
,
627 OUT PULONG ActualSize
)
629 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
630 PageFileName
->Buffer
, debugstr_w(PageFileName
->Buffer
),MiniumSize
,MaxiumSize
,ActualSize
);
634 /******************************************************************************
635 * NtDisplayString [NTDLL.95]
637 * writes a string to the nt-textmode screen eg. during startup
639 NTSTATUS WINAPI
NtDisplayString ( PUNICODE_STRING string
)
644 if (!(ret
= RtlUnicodeStringToAnsiString( &stringA
, string
, TRUE
)))
646 MESSAGE( "%.*s", stringA
.Length
, stringA
.Buffer
);
647 RtlFreeAnsiString( &stringA
);
652 /******************************************************************************
653 * NtPowerInformation [NTDLL]
656 NTSTATUS WINAPI
NtPowerInformation(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
,DWORD x5
)
658 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1
,x2
,x3
,x4
,x5
);
662 /******************************************************************************
663 * NtAllocateLocallyUniqueId
665 * FIXME: the server should do that
667 NTSTATUS WINAPI
NtAllocateLocallyUniqueId(PLUID Luid
)
671 FIXME("%p (0x%08lx%08lx)\n", Luid
, luid
.DUMMYSTRUCTNAME
.HighPart
, luid
.DUMMYSTRUCTNAME
.LowPart
);
675 Luid
->QuadPart
= luid
.QuadPart
;
676 return STATUS_SUCCESS
;