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
);
36 /* Structures used by NtConnectPort */
38 typedef struct LpcSectionInfo
44 DWORD ClientBaseAddress
;
45 DWORD ServerBaseAddress
;
46 } LPCSECTIONINFO
, *PLPCSECTIONINFO
;
48 typedef struct LpcSectionMapInfo
52 DWORD ServerBaseAddress
;
53 } LPCSECTIONMAPINFO
, *PLPCSECTIONMAPINFO
;
55 /* Structure used by NtAcceptConnectPort, NtReplyWaitReceivePort */
57 #define MAX_MESSAGE_DATA 328
59 typedef struct LpcMessage
61 WORD ActualMessageLength
;
62 WORD TotalMessageLength
;
64 DWORD ClientProcessId
;
67 DWORD SharedSectionSize
;
68 BYTE MessageData
[MAX_MESSAGE_DATA
];
69 } LPCMESSAGE
, *PLPCMESSAGE
;
75 /**************************************************************************
76 * NtCreateTimer [NTDLL.@]
77 * ZwCreateTimer [NTDLL.@]
79 NTSTATUS WINAPI
NtCreateTimer(
80 OUT PHANDLE TimerHandle
,
81 IN ACCESS_MASK DesiredAccess
,
82 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL
,
83 IN TIMER_TYPE TimerType
)
85 FIXME("(%p,0x%08lx,%p,0x%08x) stub\n",
86 TimerHandle
,DesiredAccess
,ObjectAttributes
, TimerType
);
87 dump_ObjectAttributes(ObjectAttributes
);
90 /**************************************************************************
91 * NtSetTimer [NTDLL.@]
92 * ZwSetTimer [NTDLL.@]
94 NTSTATUS WINAPI
NtSetTimer(
95 IN HANDLE TimerHandle
,
96 IN PLARGE_INTEGER DueTime
,
97 IN PTIMERAPCROUTINE TimerApcRoutine
,
98 IN PVOID TimerContext
,
100 IN ULONG Period OPTIONAL
,
101 OUT PBOOLEAN PreviousState OPTIONAL
)
103 FIXME("(%p,%p,%p,%p,%08x,0x%08lx,%p) stub\n",
104 TimerHandle
,DueTime
,TimerApcRoutine
,TimerContext
,WakeTimer
,Period
,PreviousState
);
108 /******************************************************************************
109 * NtQueryTimerResolution [NTDLL.@]
111 NTSTATUS WINAPI
NtQueryTimerResolution(DWORD x1
,DWORD x2
,DWORD x3
)
113 FIXME("(0x%08lx,0x%08lx,0x%08lx), stub!\n",x1
,x2
,x3
);
121 /******************************************************************************
122 * NtTerminateProcess [NTDLL.@]
124 * Native applications must kill themselves when done
126 NTSTATUS WINAPI
NtTerminateProcess( HANDLE handle
, LONG exit_code
)
130 SERVER_START_REQ( terminate_process
)
132 req
->handle
= handle
;
133 req
->exit_code
= exit_code
;
134 ret
= wine_server_call( req
);
135 self
= !ret
&& reply
->self
;
138 if (self
) exit( exit_code
);
142 /******************************************************************************
143 * NtQueryInformationProcess [NTDLL.@]
144 * ZwQueryInformationProcess [NTDLL.@]
147 NTSTATUS WINAPI
NtQueryInformationProcess(
148 IN HANDLE ProcessHandle
,
149 IN PROCESSINFOCLASS ProcessInformationClass
,
150 OUT PVOID ProcessInformation
,
151 IN ULONG ProcessInformationLength
,
152 OUT PULONG ReturnLength
)
154 NTSTATUS ret
= STATUS_SUCCESS
;
157 switch (ProcessInformationClass
) {
158 case ProcessDebugPort
:
159 /* "These are not the debuggers you are looking for." */
160 /* set it to 0 aka "no debugger" to satisfy copy protections */
161 if (ProcessInformationLength
== 4)
163 memset(ProcessInformation
,0,ProcessInformationLength
);
167 ret
= STATUS_INFO_LENGTH_MISMATCH
;
169 case ProcessWow64Information
:
170 if (ProcessInformationLength
== 4)
172 memset(ProcessInformation
,0,ProcessInformationLength
);
176 ret
= STATUS_INFO_LENGTH_MISMATCH
;
179 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
180 ProcessHandle
,ProcessInformationClass
,
181 ProcessInformation
,ProcessInformationLength
,
193 /******************************************************************************
194 * NtSetInformationProcess [NTDLL.@]
195 * ZwSetInformationProcess [NTDLL.@]
197 NTSTATUS WINAPI
NtSetInformationProcess(
198 IN HANDLE ProcessHandle
,
199 IN PROCESSINFOCLASS ProcessInformationClass
,
200 IN PVOID ProcessInformation
,
201 IN ULONG ProcessInformationLength
)
203 FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
204 ProcessHandle
,ProcessInformationClass
,ProcessInformation
,ProcessInformationLength
);
212 /******************************************************************************
213 * NtQueryInformationThread [NTDLL.@]
214 * ZwQueryInformationThread [NTDLL.@]
217 NTSTATUS WINAPI
NtQueryInformationThread(
218 IN HANDLE ThreadHandle
,
219 IN THREADINFOCLASS ThreadInformationClass
,
220 OUT PVOID ThreadInformation
,
221 IN ULONG ThreadInformationLength
,
222 OUT PULONG ReturnLength
)
224 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
225 ThreadHandle
, ThreadInformationClass
, ThreadInformation
,
226 ThreadInformationLength
, ReturnLength
);
230 /******************************************************************************
231 * NtSetInformationThread [NTDLL.@]
232 * ZwSetInformationThread [NTDLL.@]
234 NTSTATUS WINAPI
NtSetInformationThread(
236 THREADINFOCLASS ThreadInformationClass
,
237 PVOID ThreadInformation
,
238 ULONG ThreadInformationLength
)
240 FIXME("(%p,0x%08x,%p,0x%08lx),stub!\n",
241 ThreadHandle
, ThreadInformationClass
, ThreadInformation
, ThreadInformationLength
);
249 /******************************************************************************
250 * NtDuplicateToken [NTDLL.@]
251 * ZwDuplicateToken [NTDLL.@]
253 NTSTATUS WINAPI
NtDuplicateToken(
254 IN HANDLE ExistingToken
,
255 IN ACCESS_MASK DesiredAccess
,
256 IN POBJECT_ATTRIBUTES ObjectAttributes
,
257 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
,
258 IN TOKEN_TYPE TokenType
,
259 OUT PHANDLE NewToken
)
261 FIXME("(%p,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
262 ExistingToken
, DesiredAccess
, ObjectAttributes
,
263 ImpersonationLevel
, TokenType
, NewToken
);
264 dump_ObjectAttributes(ObjectAttributes
);
268 /******************************************************************************
269 * NtOpenProcessToken [NTDLL.@]
270 * ZwOpenProcessToken [NTDLL.@]
272 NTSTATUS WINAPI
NtOpenProcessToken(
273 HANDLE ProcessHandle
,
277 FIXME("(%p,0x%08lx,%p): stub\n",
278 ProcessHandle
,DesiredAccess
, TokenHandle
);
279 *TokenHandle
= (HANDLE
)0xcafe;
283 /******************************************************************************
284 * NtOpenThreadToken [NTDLL.@]
285 * ZwOpenThreadToken [NTDLL.@]
287 NTSTATUS WINAPI
NtOpenThreadToken(
293 FIXME("(%p,0x%08lx,0x%08x,%p): stub\n",
294 ThreadHandle
,DesiredAccess
, OpenAsSelf
, TokenHandle
);
295 *TokenHandle
= (HANDLE
)0xcafe;
299 /******************************************************************************
300 * NtAdjustPrivilegesToken [NTDLL.@]
301 * ZwAdjustGroupsToken [NTDLL.@]
303 * FIXME: parameters unsafe
305 NTSTATUS WINAPI
NtAdjustPrivilegesToken(
306 IN HANDLE TokenHandle
,
307 IN BOOLEAN DisableAllPrivileges
,
308 IN PTOKEN_PRIVILEGES NewState
,
309 IN DWORD BufferLength
,
310 OUT PTOKEN_PRIVILEGES PreviousState
,
311 OUT PDWORD ReturnLength
)
313 FIXME("(%p,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
314 TokenHandle
, DisableAllPrivileges
, NewState
, BufferLength
, PreviousState
, ReturnLength
);
318 /******************************************************************************
319 * NtQueryInformationToken [NTDLL.@]
320 * ZwQueryInformationToken [NTDLL.@]
323 * Buffer for TokenUser:
324 * 0x00 TOKEN_USER the PSID field points to the SID
328 NTSTATUS WINAPI
NtQueryInformationToken(
330 DWORD tokeninfoclass
,
332 DWORD tokeninfolength
,
335 unsigned int len
= 0;
337 FIXME("(%p,%ld,%p,%ld,%p): stub\n",
338 token
,tokeninfoclass
,tokeninfo
,tokeninfolength
,retlen
);
340 switch (tokeninfoclass
)
343 len
= sizeof(TOKEN_USER
) + sizeof(SID
);
346 len
= sizeof(TOKEN_GROUPS
);
348 case TokenPrivileges
:
349 len
= sizeof(TOKEN_PRIVILEGES
);
352 len
= sizeof(TOKEN_OWNER
);
354 case TokenPrimaryGroup
:
355 len
= sizeof(TOKEN_PRIMARY_GROUP
);
357 case TokenDefaultDacl
:
358 len
= sizeof(TOKEN_DEFAULT_DACL
);
361 len
= sizeof(TOKEN_SOURCE
);
364 len
= sizeof (TOKEN_TYPE
);
367 case TokenImpersonationLevel
:
368 case TokenStatistics
:
372 /* FIXME: what if retlen == NULL ? */
375 if (tokeninfolength
< len
)
376 return STATUS_BUFFER_TOO_SMALL
;
378 switch (tokeninfoclass
)
383 TOKEN_USER
* tuser
= tokeninfo
;
384 PSID sid
= (PSID
) (tuser
+ 1);
385 SID_IDENTIFIER_AUTHORITY localSidAuthority
= {SECURITY_NT_AUTHORITY
};
386 RtlInitializeSid(sid
, &localSidAuthority
, 1);
387 *(RtlSubAuthoritySid(sid
, 0)) = SECURITY_INTERACTIVE_RID
;
388 tuser
->User
.Sid
= sid
;
394 TOKEN_GROUPS
*tgroups
= tokeninfo
;
395 SID_IDENTIFIER_AUTHORITY sid
= {SECURITY_NT_AUTHORITY
};
397 /* we need to show admin privileges ! */
398 tgroups
->GroupCount
= 1;
399 RtlAllocateAndInitializeSid( &sid
,
401 SECURITY_BUILTIN_DOMAIN_RID
,
402 DOMAIN_ALIAS_RID_ADMINS
,
404 &(tgroups
->Groups
->Sid
));
407 case TokenPrivileges
:
410 TOKEN_PRIVILEGES
*tpriv
= tokeninfo
;
411 tpriv
->PrivilegeCount
= 1;
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("(%p,%p,%p,0x%08lx,%p) stub!\n",
433 SectionHandle
,SectionInformationClass
,SectionInformation
,Length
,ResultLength
);
441 /******************************************************************************
442 * NtCreatePort [NTDLL.@]
443 * ZwCreatePort [NTDLL.@]
445 NTSTATUS WINAPI
NtCreatePort(PHANDLE PortHandle
,POBJECT_ATTRIBUTES ObjectAttributes
,
446 DWORD MaxConnectInfoLength
,DWORD MaxDataLength
,DWORD unknown
)
448 FIXME("(%p,%p,0x%08lx,0x%08lx,0x%08lx),stub!\n",PortHandle
,ObjectAttributes
,
449 MaxConnectInfoLength
,MaxDataLength
,unknown
);
453 /******************************************************************************
454 * NtConnectPort [NTDLL.@]
455 * ZwConnectPort [NTDLL.@]
457 NTSTATUS WINAPI
NtConnectPort(PHANDLE PortHandle
,PUNICODE_STRING PortName
,PVOID Unknown1
,
458 PLPCSECTIONINFO sectionInfo
,PLPCSECTIONMAPINFO mapInfo
,PVOID Unknown2
,
459 PVOID ConnectInfo
,PDWORD pConnectInfoLength
)
461 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p (%ld)),stub!\n",PortHandle
,debugstr_w(PortName
->Buffer
),Unknown1
,
462 sectionInfo
,mapInfo
,Unknown2
,ConnectInfo
,pConnectInfoLength
,pConnectInfoLength
?*pConnectInfoLength
:-1);
463 if(ConnectInfo
&& pConnectInfoLength
)
464 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo
,*pConnectInfoLength
));
468 /******************************************************************************
469 * NtListenPort [NTDLL.@]
470 * ZwListenPort [NTDLL.@]
472 NTSTATUS WINAPI
NtListenPort(HANDLE PortHandle
,PLPCMESSAGE pLpcMessage
)
474 FIXME("(%p,%p),stub!\n",PortHandle
,pLpcMessage
);
478 /******************************************************************************
479 * NtAcceptConnectPort [NTDLL.@]
480 * ZwAcceptConnectPort [NTDLL.@]
482 NTSTATUS WINAPI
NtAcceptConnectPort(PHANDLE PortHandle
,DWORD Unknown
,PLPCMESSAGE pLpcMessage
,
483 DWORD acceptIt
,DWORD Unknown2
,PLPCSECTIONMAPINFO mapInfo
)
485 FIXME("(%p,0x%08lx,%p,0x%08lx,0x%08lx,%p),stub!\n",PortHandle
,Unknown
,pLpcMessage
,acceptIt
,Unknown2
,mapInfo
);
489 /******************************************************************************
490 * NtCompleteConnectPort [NTDLL.@]
491 * ZwCompleteConnectPort [NTDLL.@]
493 NTSTATUS WINAPI
NtCompleteConnectPort(HANDLE PortHandle
)
495 FIXME("(%p),stub!\n",PortHandle
);
499 /******************************************************************************
500 * NtRegisterThreadTerminatePort [NTDLL.@]
501 * ZwRegisterThreadTerminatePort [NTDLL.@]
503 NTSTATUS WINAPI
NtRegisterThreadTerminatePort(HANDLE PortHandle
)
505 FIXME("(%p),stub!\n",PortHandle
);
509 /******************************************************************************
510 * NtRequestWaitReplyPort [NTDLL.@]
511 * ZwRequestWaitReplyPort [NTDLL.@]
513 NTSTATUS WINAPI
NtRequestWaitReplyPort(HANDLE PortHandle
,PLPCMESSAGE pLpcMessageIn
,PLPCMESSAGE pLpcMessageOut
)
515 FIXME("(%p,%p,%p),stub!\n",PortHandle
,pLpcMessageIn
,pLpcMessageOut
);
518 TRACE("Message to send:\n");
519 TRACE("\tActualMessageLength = %d\n",pLpcMessageIn
->ActualMessageLength
);
520 TRACE("\tTotalMessageLength = %d\n",pLpcMessageIn
->TotalMessageLength
);
521 TRACE("\tMessageType = %ld\n",pLpcMessageIn
->MessageType
);
522 TRACE("\tClientProcessId = %ld\n",pLpcMessageIn
->ClientProcessId
);
523 TRACE("\tClientThreadId = %ld\n",pLpcMessageIn
->ClientThreadId
);
524 TRACE("\tMessageId = %ld\n",pLpcMessageIn
->MessageId
);
525 TRACE("\tSharedSectionSize = %ld\n",pLpcMessageIn
->SharedSectionSize
);
526 TRACE("\tMessageData = %s\n",debugstr_an(pLpcMessageIn
->MessageData
,pLpcMessageIn
->ActualMessageLength
));
531 /******************************************************************************
532 * NtReplyWaitReceivePort [NTDLL.@]
533 * ZwReplyWaitReceivePort [NTDLL.@]
535 NTSTATUS WINAPI
NtReplyWaitReceivePort(HANDLE PortHandle
,PDWORD Unknown
,PLPCMESSAGE pLpcMessageOut
,PLPCMESSAGE pLpcMessageIn
)
537 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle
,Unknown
,pLpcMessageOut
,pLpcMessageIn
);
545 /******************************************************************************
546 * NtSetIntervalProfile [NTDLL.@]
547 * ZwSetIntervalProfile [NTDLL.@]
549 NTSTATUS WINAPI
NtSetIntervalProfile(DWORD x1
,DWORD x2
) {
550 FIXME("(0x%08lx,0x%08lx),stub!\n",x1
,x2
);
554 /******************************************************************************
555 * NtQueryPerformanceCounter [NTDLL.@]
557 NTSTATUS WINAPI
NtQueryPerformanceCounter(
558 IN PLARGE_INTEGER Counter
,
559 IN PLARGE_INTEGER Frequency
)
561 FIXME("(%p, 0%p) stub\n",
566 /******************************************************************************
567 * NtCreateMailslotFile [NTDLL.@]
568 * ZwCreateMailslotFile [NTDLL.@]
570 NTSTATUS WINAPI
NtCreateMailslotFile(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
,DWORD x5
,DWORD x6
,DWORD x7
,DWORD x8
)
572 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
);
576 /******************************************************************************
577 * NtQuerySystemInformation [NTDLL.@]
578 * ZwQuerySystemInformation [NTDLL.@]
581 * SystemInformationClass Index to a certain information structure
582 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
583 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
584 * SystemConfigurationInformation CONFIGURATION_INFORMATION
585 * observed (class/len):
591 * SystemInformation caller supplies storage for the information structure
592 * Length size of the structure
593 * ResultLength Data written
595 NTSTATUS WINAPI
NtQuerySystemInformation(
596 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
597 OUT PVOID SystemInformation
,
599 OUT PULONG ResultLength
)
601 switch(SystemInformationClass
)
604 /* Something to do with the size of the registry *
605 * Since we don't have a size limitation, fake it *
606 * This is almost certainly wrong. *
607 * This sets each of the three words in the struct to 32 MB, *
608 * which is enough to make the IE 5 installer happy. */
609 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
610 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
611 *(DWORD
*)SystemInformation
= 0x2000000;
612 *(((DWORD
*)SystemInformation
)+1) = 0x200000;
613 *(((DWORD
*)SystemInformation
)+2) = 0x200000;
617 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
618 SystemInformationClass
,SystemInformation
,Length
,ResultLength
);
619 ZeroMemory (SystemInformation
, Length
);
622 return STATUS_SUCCESS
;
626 /******************************************************************************
627 * NtCreatePagingFile [NTDLL.@]
628 * ZwCreatePagingFile [NTDLL.@]
630 NTSTATUS WINAPI
NtCreatePagingFile(
631 IN PUNICODE_STRING PageFileName
,
634 OUT PULONG ActualSize
)
636 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
637 PageFileName
->Buffer
, debugstr_w(PageFileName
->Buffer
),MiniumSize
,MaxiumSize
,ActualSize
);
641 /******************************************************************************
642 * NtDisplayString [NTDLL.@]
644 * writes a string to the nt-textmode screen eg. during startup
646 NTSTATUS WINAPI
NtDisplayString ( PUNICODE_STRING string
)
651 if (!(ret
= RtlUnicodeStringToAnsiString( &stringA
, string
, TRUE
)))
653 MESSAGE( "%.*s", stringA
.Length
, stringA
.Buffer
);
654 RtlFreeAnsiString( &stringA
);
659 /******************************************************************************
660 * NtPowerInformation [NTDLL.@]
663 NTSTATUS WINAPI
NtPowerInformation(DWORD x1
,DWORD x2
,DWORD x3
,DWORD x4
,DWORD x5
)
665 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1
,x2
,x3
,x4
,x5
);
669 /******************************************************************************
670 * NtAllocateLocallyUniqueId (NTDLL.@)
672 * FIXME: the server should do that
674 NTSTATUS WINAPI
NtAllocateLocallyUniqueId(PLUID Luid
)
678 FIXME("%p (0x%08lx%08lx)\n", Luid
, luid
.HighPart
, luid
.LowPart
);
683 Luid
->HighPart
= luid
.HighPart
;
684 Luid
->LowPart
= luid
.LowPart
;
686 return STATUS_SUCCESS
;
689 /******************************************************************************
690 * VerSetConditionMask (NTDLL.@)
692 ULONGLONG WINAPI
VerSetConditionMask( ULONGLONG dwlConditionMask
, DWORD dwTypeBitMask
,
693 BYTE dwConditionMask
)
695 if(dwTypeBitMask
== 0)
696 return dwlConditionMask
;
697 dwConditionMask
&= 0x07;
698 if(dwConditionMask
== 0)
699 return dwlConditionMask
;
701 if(dwTypeBitMask
& VER_PRODUCT_TYPE
)
702 dwlConditionMask
|= dwConditionMask
<< 7*3;
703 else if (dwTypeBitMask
& VER_SUITENAME
)
704 dwlConditionMask
|= dwConditionMask
<< 6*3;
705 else if (dwTypeBitMask
& VER_SERVICEPACKMAJOR
)
706 dwlConditionMask
|= dwConditionMask
<< 5*3;
707 else if (dwTypeBitMask
& VER_SERVICEPACKMINOR
)
708 dwlConditionMask
|= dwConditionMask
<< 4*3;
709 else if (dwTypeBitMask
& VER_PLATFORMID
)
710 dwlConditionMask
|= dwConditionMask
<< 3*3;
711 else if (dwTypeBitMask
& VER_BUILDNUMBER
)
712 dwlConditionMask
|= dwConditionMask
<< 2*3;
713 else if (dwTypeBitMask
& VER_MAJORVERSION
)
714 dwlConditionMask
|= dwConditionMask
<< 1*3;
715 else if (dwTypeBitMask
& VER_MINORVERSION
)
716 dwlConditionMask
|= dwConditionMask
<< 0*3;
717 return dwlConditionMask
;