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;
170 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
171 ProcessHandle,ProcessInformationClass,
172 ProcessInformation,ProcessInformationLength,
184 /******************************************************************************
185 * NtSetInformationProcess [NTDLL.@]
186 * ZwSetInformationProcess [NTDLL.@]
188 NTSTATUS WINAPI NtSetInformationProcess(
189 IN HANDLE ProcessHandle,
190 IN PROCESSINFOCLASS ProcessInformationClass,
191 IN PVOID ProcessInformation,
192 IN ULONG ProcessInformationLength)
194 FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
195 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
203 /******************************************************************************
204 * NtQueryInformationThread [NTDLL.@]
205 * ZwQueryInformationThread [NTDLL.@]
208 NTSTATUS WINAPI NtQueryInformationThread(
209 IN HANDLE ThreadHandle,
210 IN THREADINFOCLASS ThreadInformationClass,
211 OUT PVOID ThreadInformation,
212 IN ULONG ThreadInformationLength,
213 OUT PULONG ReturnLength)
215 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
216 ThreadHandle, ThreadInformationClass, ThreadInformation,
217 ThreadInformationLength, ReturnLength);
221 /******************************************************************************
222 * NtSetInformationThread [NTDLL.@]
223 * ZwSetInformationThread [NTDLL.@]
225 NTSTATUS WINAPI NtSetInformationThread(
227 THREADINFOCLASS ThreadInformationClass,
228 PVOID ThreadInformation,
229 ULONG ThreadInformationLength)
231 FIXME("(%p,0x%08x,%p,0x%08lx),stub!\n",
232 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
240 /******************************************************************************
241 * NtDuplicateToken [NTDLL.@]
242 * ZwDuplicateToken [NTDLL.@]
244 NTSTATUS WINAPI NtDuplicateToken(
245 IN HANDLE ExistingToken,
246 IN ACCESS_MASK DesiredAccess,
247 IN POBJECT_ATTRIBUTES ObjectAttributes,
248 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
249 IN TOKEN_TYPE TokenType,
250 OUT PHANDLE NewToken)
252 FIXME("(%p,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
253 ExistingToken, DesiredAccess, ObjectAttributes,
254 ImpersonationLevel, TokenType, NewToken);
255 dump_ObjectAttributes(ObjectAttributes);
259 /******************************************************************************
260 * NtOpenProcessToken [NTDLL.@]
261 * ZwOpenProcessToken [NTDLL.@]
263 NTSTATUS WINAPI NtOpenProcessToken(
264 HANDLE ProcessHandle,
268 FIXME("(%p,0x%08lx,%p): stub\n",
269 ProcessHandle,DesiredAccess, TokenHandle);
270 *TokenHandle = (HANDLE)0xcafe;
274 /******************************************************************************
275 * NtOpenThreadToken [NTDLL.@]
276 * ZwOpenThreadToken [NTDLL.@]
278 NTSTATUS WINAPI NtOpenThreadToken(
284 FIXME("(%p,0x%08lx,0x%08x,%p): stub\n",
285 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
286 *TokenHandle = (HANDLE)0xcafe;
290 /******************************************************************************
291 * NtAdjustPrivilegesToken [NTDLL.@]
292 * ZwAdjustGroupsToken [NTDLL.@]
294 * FIXME: parameters unsafe
296 NTSTATUS WINAPI NtAdjustPrivilegesToken(
297 IN HANDLE TokenHandle,
298 IN BOOLEAN DisableAllPrivileges,
299 IN PTOKEN_PRIVILEGES NewState,
300 IN DWORD BufferLength,
301 OUT PTOKEN_PRIVILEGES PreviousState,
302 OUT PDWORD ReturnLength)
304 FIXME("(%p,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
305 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
309 /******************************************************************************
310 * NtQueryInformationToken [NTDLL.@]
311 * ZwQueryInformationToken [NTDLL.@]
314 * Buffer for TokenUser:
315 * 0x00 TOKEN_USER the PSID field points to the SID
319 NTSTATUS WINAPI NtQueryInformationToken(
321 DWORD tokeninfoclass,
323 DWORD tokeninfolength,
326 unsigned int len = 0;
328 FIXME("(%p,%ld,%p,%ld,%p): stub\n",
329 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
331 switch (tokeninfoclass)
334 len = sizeof(TOKEN_USER) + sizeof(SID);
337 len = sizeof(TOKEN_GROUPS);
339 case TokenPrivileges:
340 len = sizeof(TOKEN_PRIVILEGES);
343 len = sizeof(TOKEN_OWNER);
345 case TokenPrimaryGroup:
346 len = sizeof(TOKEN_PRIMARY_GROUP);
348 case TokenDefaultDacl:
349 len = sizeof(TOKEN_DEFAULT_DACL);
352 len = sizeof(TOKEN_SOURCE);
355 len = sizeof (TOKEN_TYPE);
358 case TokenImpersonationLevel:
359 case TokenStatistics:
363 /* FIXME: what if retlen == NULL ? */
366 if (tokeninfolength < len)
367 return STATUS_BUFFER_TOO_SMALL;
369 switch (tokeninfoclass)
374 TOKEN_USER * tuser = tokeninfo;
375 PSID sid = (PSID) (tuser + 1);
376 SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
377 RtlInitializeSid(sid, &localSidAuthority, 1);
378 *(RtlSubAuthoritySid(sid, 0)) = SECURITY_INTERACTIVE_RID;
379 tuser->User.Sid = sid;
385 TOKEN_GROUPS *tgroups = tokeninfo;
386 SID_IDENTIFIER_AUTHORITY sid = {SECURITY_NT_AUTHORITY};
388 /* we need to show admin privileges ! */
389 tgroups->GroupCount = 1;
390 RtlAllocateAndInitializeSid( &sid,
392 SECURITY_BUILTIN_DOMAIN_RID,
393 DOMAIN_ALIAS_RID_ADMINS,
395 &(tgroups->Groups->Sid));
398 case TokenPrivileges:
401 TOKEN_PRIVILEGES *tpriv = tokeninfo;
402 tpriv->PrivilegeCount = 1;
413 /******************************************************************************
414 * NtQuerySection [NTDLL.@]
416 NTSTATUS WINAPI NtQuerySection(
417 IN HANDLE SectionHandle,
418 IN PVOID SectionInformationClass,
419 OUT PVOID SectionInformation,
421 OUT PULONG ResultLength)
423 FIXME("(%p,%p,%p,0x%08lx,%p) stub!\n",
424 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
432 /******************************************************************************
433 * NtCreatePort [NTDLL.@]
434 * ZwCreatePort [NTDLL.@]
436 NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
437 DWORD MaxConnectInfoLength,DWORD MaxDataLength,DWORD unknown)
439 FIXME("(%p,%p,0x%08lx,0x%08lx,0x%08lx),stub!\n",PortHandle,ObjectAttributes,
440 MaxConnectInfoLength,MaxDataLength,unknown);
444 /******************************************************************************
445 * NtConnectPort [NTDLL.@]
446 * ZwConnectPort [NTDLL.@]
448 NTSTATUS WINAPI NtConnectPort(PHANDLE PortHandle,PUNICODE_STRING PortName,PVOID Unknown1,
449 PLPCSECTIONINFO sectionInfo,PLPCSECTIONMAPINFO mapInfo,PVOID Unknown2,
450 PVOID ConnectInfo,PDWORD pConnectInfoLength)
452 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p (%ld)),stub!\n",PortHandle,debugstr_w(PortName->Buffer),Unknown1,
453 sectionInfo,mapInfo,Unknown2,ConnectInfo,pConnectInfoLength,pConnectInfoLength?*pConnectInfoLength:-1);
454 if(ConnectInfo && pConnectInfoLength)
455 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
459 /******************************************************************************
460 * NtListenPort [NTDLL.@]
461 * ZwListenPort [NTDLL.@]
463 NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessage)
465 FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
469 /******************************************************************************
470 * NtAcceptConnectPort [NTDLL.@]
471 * ZwAcceptConnectPort [NTDLL.@]
473 NTSTATUS WINAPI NtAcceptConnectPort(PHANDLE PortHandle,DWORD Unknown,PLPCMESSAGE pLpcMessage,
474 DWORD acceptIt,DWORD Unknown2,PLPCSECTIONMAPINFO mapInfo)
476 FIXME("(%p,0x%08lx,%p,0x%08lx,0x%08lx,%p),stub!\n",PortHandle,Unknown,pLpcMessage,acceptIt,Unknown2,mapInfo);
480 /******************************************************************************
481 * NtCompleteConnectPort [NTDLL.@]
482 * ZwCompleteConnectPort [NTDLL.@]
484 NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
486 FIXME("(%p),stub!\n",PortHandle);
490 /******************************************************************************
491 * NtRegisterThreadTerminatePort [NTDLL.@]
492 * ZwRegisterThreadTerminatePort [NTDLL.@]
494 NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
496 FIXME("(%p),stub!\n",PortHandle);
500 /******************************************************************************
501 * NtRequestWaitReplyPort [NTDLL.@]
502 * ZwRequestWaitReplyPort [NTDLL.@]
504 NTSTATUS WINAPI NtRequestWaitReplyPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessageIn,PLPCMESSAGE pLpcMessageOut)
506 FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
509 TRACE("Message to send:\n");
510 TRACE("\tActualMessageLength = %d\n",pLpcMessageIn->ActualMessageLength);
511 TRACE("\tTotalMessageLength = %d\n",pLpcMessageIn->TotalMessageLength);
512 TRACE("\tMessageType = %ld\n",pLpcMessageIn->MessageType);
513 TRACE("\tClientProcessId = %ld\n",pLpcMessageIn->ClientProcessId);
514 TRACE("\tClientThreadId = %ld\n",pLpcMessageIn->ClientThreadId);
515 TRACE("\tMessageId = %ld\n",pLpcMessageIn->MessageId);
516 TRACE("\tSharedSectionSize = %ld\n",pLpcMessageIn->SharedSectionSize);
517 TRACE("\tMessageData = %s\n",debugstr_an(pLpcMessageIn->MessageData,pLpcMessageIn->ActualMessageLength));
522 /******************************************************************************
523 * NtReplyWaitReceivePort [NTDLL.@]
524 * ZwReplyWaitReceivePort [NTDLL.@]
526 NTSTATUS WINAPI NtReplyWaitReceivePort(HANDLE PortHandle,PDWORD Unknown,PLPCMESSAGE pLpcMessageOut,PLPCMESSAGE pLpcMessageIn)
528 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,Unknown,pLpcMessageOut,pLpcMessageIn);
536 /******************************************************************************
537 * NtSetIntervalProfile [NTDLL.@]
538 * ZwSetIntervalProfile [NTDLL.@]
540 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
541 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
545 /******************************************************************************
546 * NtQueryPerformanceCounter [NTDLL.@]
548 NTSTATUS WINAPI NtQueryPerformanceCounter(
549 IN PLARGE_INTEGER Counter,
550 IN PLARGE_INTEGER Frequency)
552 FIXME("(%p, 0%p) stub\n",
557 /******************************************************************************
558 * NtCreateMailslotFile [NTDLL.@]
559 * ZwCreateMailslotFile [NTDLL.@]
561 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
563 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);
567 /******************************************************************************
568 * NtQuerySystemInformation [NTDLL.@]
569 * ZwQuerySystemInformation [NTDLL.@]
572 * SystemInformationClass Index to a certain information structure
573 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
574 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
575 * SystemConfigurationInformation CONFIGURATION_INFORMATION
576 * observed (class/len):
582 * SystemInformation caller supplies storage for the information structure
583 * Length size of the structure
584 * ResultLength Data written
586 NTSTATUS WINAPI NtQuerySystemInformation(
587 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
588 OUT PVOID SystemInformation,
590 OUT PULONG ResultLength)
592 switch(SystemInformationClass)
595 /* Something to do with the size of the registry *
596 * Since we don't have a size limitation, fake it *
597 * This is almost certainly wrong. *
598 * This sets each of the three words in the struct to 32 MB, *
599 * which is enough to make the IE 5 installer happy. */
600 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
601 SystemInformationClass,SystemInformation,Length,ResultLength);
602 *(DWORD *)SystemInformation = 0x2000000;
603 *(((DWORD *)SystemInformation)+1) = 0x200000;
604 *(((DWORD *)SystemInformation)+2) = 0x200000;
608 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
609 SystemInformationClass,SystemInformation,Length,ResultLength);
610 ZeroMemory (SystemInformation, Length);
613 return STATUS_SUCCESS;
617 /******************************************************************************
618 * NtCreatePagingFile [NTDLL.@]
619 * ZwCreatePagingFile [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.@]
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 (NTDLL.@)
663 * FIXME: the server should do that
665 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
669 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.HighPart, luid.LowPart);
674 Luid->HighPart = luid.HighPart;
675 Luid->LowPart = luid.LowPart;
677 return STATUS_SUCCESS;
680 /******************************************************************************
681 * VerSetConditionMask (NTDLL.@)
683 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
684 BYTE dwConditionMask)
686 if(dwTypeBitMask == 0)
687 return dwlConditionMask;
688 dwConditionMask &= 0x07;
689 if(dwConditionMask == 0)
690 return dwlConditionMask;
692 if(dwTypeBitMask & VER_PRODUCT_TYPE)
693 dwlConditionMask |= dwConditionMask << 7*3;
694 else if (dwTypeBitMask & VER_SUITENAME)
695 dwlConditionMask |= dwConditionMask << 6*3;
696 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
697 dwlConditionMask |= dwConditionMask << 5*3;
698 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
699 dwlConditionMask |= dwConditionMask << 4*3;
700 else if (dwTypeBitMask & VER_PLATFORMID)
701 dwlConditionMask |= dwConditionMask << 3*3;
702 else if (dwTypeBitMask & VER_BUILDNUMBER)
703 dwlConditionMask |= dwConditionMask << 2*3;
704 else if (dwTypeBitMask & VER_MAJORVERSION)
705 dwlConditionMask |= dwConditionMask << 1*3;
706 else if (dwTypeBitMask & VER_MINORVERSION)
707 dwlConditionMask |= dwConditionMask << 0*3;
708 return dwlConditionMask;