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 * NtTerminateProcess [NTDLL.@]
78 * Native applications must kill themselves when done
80 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
84 SERVER_START_REQ( terminate_process )
87 req->exit_code = exit_code;
88 ret = wine_server_call( req );
89 self = !ret && reply->self;
92 if (self) exit( exit_code );
96 /******************************************************************************
97 * NtQueryInformationProcess [NTDLL.@]
98 * ZwQueryInformationProcess [NTDLL.@]
101 NTSTATUS WINAPI NtQueryInformationProcess(
102 IN HANDLE ProcessHandle,
103 IN PROCESSINFOCLASS ProcessInformationClass,
104 OUT PVOID ProcessInformation,
105 IN ULONG ProcessInformationLength,
106 OUT PULONG ReturnLength)
108 NTSTATUS ret = STATUS_SUCCESS;
111 switch (ProcessInformationClass) {
112 case ProcessDebugPort:
113 /* "These are not the debuggers you are looking for." */
114 /* set it to 0 aka "no debugger" to satisfy copy protections */
115 if (ProcessInformationLength == 4)
117 memset(ProcessInformation,0,ProcessInformationLength);
121 ret = STATUS_INFO_LENGTH_MISMATCH;
123 case ProcessWow64Information:
124 if (ProcessInformationLength == 4)
126 memset(ProcessInformation,0,ProcessInformationLength);
130 ret = STATUS_INFO_LENGTH_MISMATCH;
133 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
134 ProcessHandle,ProcessInformationClass,
135 ProcessInformation,ProcessInformationLength,
147 /******************************************************************************
148 * NtSetInformationProcess [NTDLL.@]
149 * ZwSetInformationProcess [NTDLL.@]
151 NTSTATUS WINAPI NtSetInformationProcess(
152 IN HANDLE ProcessHandle,
153 IN PROCESSINFOCLASS ProcessInformationClass,
154 IN PVOID ProcessInformation,
155 IN ULONG ProcessInformationLength)
157 FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
158 ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
166 /******************************************************************************
167 * NtQueryInformationThread [NTDLL.@]
168 * ZwQueryInformationThread [NTDLL.@]
171 NTSTATUS WINAPI NtQueryInformationThread(
172 IN HANDLE ThreadHandle,
173 IN THREADINFOCLASS ThreadInformationClass,
174 OUT PVOID ThreadInformation,
175 IN ULONG ThreadInformationLength,
176 OUT PULONG ReturnLength)
178 FIXME("(%p,0x%08x,%p,0x%08lx,%p),stub!\n",
179 ThreadHandle, ThreadInformationClass, ThreadInformation,
180 ThreadInformationLength, ReturnLength);
184 /******************************************************************************
185 * NtSetInformationThread [NTDLL.@]
186 * ZwSetInformationThread [NTDLL.@]
188 NTSTATUS WINAPI NtSetInformationThread(
190 THREADINFOCLASS ThreadInformationClass,
191 PVOID ThreadInformation,
192 ULONG ThreadInformationLength)
194 FIXME("(%p,0x%08x,%p,0x%08lx),stub!\n",
195 ThreadHandle, ThreadInformationClass, ThreadInformation, ThreadInformationLength);
203 /******************************************************************************
204 * NtDuplicateToken [NTDLL.@]
205 * ZwDuplicateToken [NTDLL.@]
207 NTSTATUS WINAPI NtDuplicateToken(
208 IN HANDLE ExistingToken,
209 IN ACCESS_MASK DesiredAccess,
210 IN POBJECT_ATTRIBUTES ObjectAttributes,
211 IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
212 IN TOKEN_TYPE TokenType,
213 OUT PHANDLE NewToken)
215 FIXME("(%p,0x%08lx,%p,0x%08x,0x%08x,%p),stub!\n",
216 ExistingToken, DesiredAccess, ObjectAttributes,
217 ImpersonationLevel, TokenType, NewToken);
218 dump_ObjectAttributes(ObjectAttributes);
222 /******************************************************************************
223 * NtOpenProcessToken [NTDLL.@]
224 * ZwOpenProcessToken [NTDLL.@]
226 NTSTATUS WINAPI NtOpenProcessToken(
227 HANDLE ProcessHandle,
231 FIXME("(%p,0x%08lx,%p): stub\n",
232 ProcessHandle,DesiredAccess, TokenHandle);
233 *TokenHandle = (HANDLE)0xcafe;
237 /******************************************************************************
238 * NtOpenThreadToken [NTDLL.@]
239 * ZwOpenThreadToken [NTDLL.@]
241 NTSTATUS WINAPI NtOpenThreadToken(
247 FIXME("(%p,0x%08lx,0x%08x,%p): stub\n",
248 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
249 *TokenHandle = (HANDLE)0xcafe;
253 /******************************************************************************
254 * NtAdjustPrivilegesToken [NTDLL.@]
255 * ZwAdjustGroupsToken [NTDLL.@]
257 * FIXME: parameters unsafe
259 NTSTATUS WINAPI NtAdjustPrivilegesToken(
260 IN HANDLE TokenHandle,
261 IN BOOLEAN DisableAllPrivileges,
262 IN PTOKEN_PRIVILEGES NewState,
263 IN DWORD BufferLength,
264 OUT PTOKEN_PRIVILEGES PreviousState,
265 OUT PDWORD ReturnLength)
267 FIXME("(%p,0x%08x,%p,0x%08lx,%p,%p),stub!\n",
268 TokenHandle, DisableAllPrivileges, NewState, BufferLength, PreviousState, ReturnLength);
272 /******************************************************************************
273 * NtQueryInformationToken [NTDLL.@]
274 * ZwQueryInformationToken [NTDLL.@]
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("(%p,%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 * NtQuerySection [NTDLL.@]
379 NTSTATUS WINAPI NtQuerySection(
380 IN HANDLE SectionHandle,
381 IN PVOID SectionInformationClass,
382 OUT PVOID SectionInformation,
384 OUT PULONG ResultLength)
386 FIXME("(%p,%p,%p,0x%08lx,%p) stub!\n",
387 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
395 /******************************************************************************
396 * NtCreatePort [NTDLL.@]
397 * ZwCreatePort [NTDLL.@]
399 NTSTATUS WINAPI NtCreatePort(PHANDLE PortHandle,POBJECT_ATTRIBUTES ObjectAttributes,
400 DWORD MaxConnectInfoLength,DWORD MaxDataLength,DWORD unknown)
402 FIXME("(%p,%p,0x%08lx,0x%08lx,0x%08lx),stub!\n",PortHandle,ObjectAttributes,
403 MaxConnectInfoLength,MaxDataLength,unknown);
407 /******************************************************************************
408 * NtConnectPort [NTDLL.@]
409 * ZwConnectPort [NTDLL.@]
411 NTSTATUS WINAPI NtConnectPort(PHANDLE PortHandle,PUNICODE_STRING PortName,PVOID Unknown1,
412 PLPCSECTIONINFO sectionInfo,PLPCSECTIONMAPINFO mapInfo,PVOID Unknown2,
413 PVOID ConnectInfo,PDWORD pConnectInfoLength)
415 FIXME("(%p,%s,%p,%p,%p,%p,%p,%p (%ld)),stub!\n",PortHandle,debugstr_w(PortName->Buffer),Unknown1,
416 sectionInfo,mapInfo,Unknown2,ConnectInfo,pConnectInfoLength,pConnectInfoLength?*pConnectInfoLength:-1);
417 if(ConnectInfo && pConnectInfoLength)
418 TRACE("\tMessage = %s\n",debugstr_an(ConnectInfo,*pConnectInfoLength));
422 /******************************************************************************
423 * NtListenPort [NTDLL.@]
424 * ZwListenPort [NTDLL.@]
426 NTSTATUS WINAPI NtListenPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessage)
428 FIXME("(%p,%p),stub!\n",PortHandle,pLpcMessage);
432 /******************************************************************************
433 * NtAcceptConnectPort [NTDLL.@]
434 * ZwAcceptConnectPort [NTDLL.@]
436 NTSTATUS WINAPI NtAcceptConnectPort(PHANDLE PortHandle,DWORD Unknown,PLPCMESSAGE pLpcMessage,
437 DWORD acceptIt,DWORD Unknown2,PLPCSECTIONMAPINFO mapInfo)
439 FIXME("(%p,0x%08lx,%p,0x%08lx,0x%08lx,%p),stub!\n",PortHandle,Unknown,pLpcMessage,acceptIt,Unknown2,mapInfo);
443 /******************************************************************************
444 * NtCompleteConnectPort [NTDLL.@]
445 * ZwCompleteConnectPort [NTDLL.@]
447 NTSTATUS WINAPI NtCompleteConnectPort(HANDLE PortHandle)
449 FIXME("(%p),stub!\n",PortHandle);
453 /******************************************************************************
454 * NtRegisterThreadTerminatePort [NTDLL.@]
455 * ZwRegisterThreadTerminatePort [NTDLL.@]
457 NTSTATUS WINAPI NtRegisterThreadTerminatePort(HANDLE PortHandle)
459 FIXME("(%p),stub!\n",PortHandle);
463 /******************************************************************************
464 * NtRequestWaitReplyPort [NTDLL.@]
465 * ZwRequestWaitReplyPort [NTDLL.@]
467 NTSTATUS WINAPI NtRequestWaitReplyPort(HANDLE PortHandle,PLPCMESSAGE pLpcMessageIn,PLPCMESSAGE pLpcMessageOut)
469 FIXME("(%p,%p,%p),stub!\n",PortHandle,pLpcMessageIn,pLpcMessageOut);
472 TRACE("Message to send:\n");
473 TRACE("\tActualMessageLength = %d\n",pLpcMessageIn->ActualMessageLength);
474 TRACE("\tTotalMessageLength = %d\n",pLpcMessageIn->TotalMessageLength);
475 TRACE("\tMessageType = %ld\n",pLpcMessageIn->MessageType);
476 TRACE("\tClientProcessId = %ld\n",pLpcMessageIn->ClientProcessId);
477 TRACE("\tClientThreadId = %ld\n",pLpcMessageIn->ClientThreadId);
478 TRACE("\tMessageId = %ld\n",pLpcMessageIn->MessageId);
479 TRACE("\tSharedSectionSize = %ld\n",pLpcMessageIn->SharedSectionSize);
480 TRACE("\tMessageData = %s\n",debugstr_an(pLpcMessageIn->MessageData,pLpcMessageIn->ActualMessageLength));
485 /******************************************************************************
486 * NtReplyWaitReceivePort [NTDLL.@]
487 * ZwReplyWaitReceivePort [NTDLL.@]
489 NTSTATUS WINAPI NtReplyWaitReceivePort(HANDLE PortHandle,PDWORD Unknown,PLPCMESSAGE pLpcMessageOut,PLPCMESSAGE pLpcMessageIn)
491 FIXME("(%p,%p,%p,%p),stub!\n",PortHandle,Unknown,pLpcMessageOut,pLpcMessageIn);
499 /******************************************************************************
500 * NtSetIntervalProfile [NTDLL.@]
501 * ZwSetIntervalProfile [NTDLL.@]
503 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
504 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
508 /******************************************************************************
509 * NtQueryPerformanceCounter [NTDLL.@]
511 NTSTATUS WINAPI NtQueryPerformanceCounter(
512 IN PLARGE_INTEGER Counter,
513 IN PLARGE_INTEGER Frequency)
515 FIXME("(%p, 0%p) stub\n",
520 /******************************************************************************
521 * NtCreateMailslotFile [NTDLL.@]
522 * ZwCreateMailslotFile [NTDLL.@]
524 NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5,DWORD x6,DWORD x7,DWORD x8)
526 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);
530 /******************************************************************************
531 * NtQuerySystemInformation [NTDLL.@]
532 * ZwQuerySystemInformation [NTDLL.@]
535 * SystemInformationClass Index to a certain information structure
536 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
537 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
538 * SystemConfigurationInformation CONFIGURATION_INFORMATION
539 * observed (class/len):
545 * SystemInformation caller supplies storage for the information structure
546 * Length size of the structure
547 * ResultLength Data written
549 NTSTATUS WINAPI NtQuerySystemInformation(
550 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
551 OUT PVOID SystemInformation,
553 OUT PULONG ResultLength)
555 switch(SystemInformationClass)
558 /* Something to do with the size of the registry *
559 * Since we don't have a size limitation, fake it *
560 * This is almost certainly wrong. *
561 * This sets each of the three words in the struct to 32 MB, *
562 * which is enough to make the IE 5 installer happy. */
563 FIXME("(0x%08x,%p,0x%08lx,%p) faking max registry size of 32 MB\n",
564 SystemInformationClass,SystemInformation,Length,ResultLength);
565 *(DWORD *)SystemInformation = 0x2000000;
566 *(((DWORD *)SystemInformation)+1) = 0x200000;
567 *(((DWORD *)SystemInformation)+2) = 0x200000;
571 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
572 SystemInformationClass,SystemInformation,Length,ResultLength);
573 ZeroMemory (SystemInformation, Length);
576 return STATUS_SUCCESS;
580 /******************************************************************************
581 * NtCreatePagingFile [NTDLL.@]
582 * ZwCreatePagingFile [NTDLL.@]
584 NTSTATUS WINAPI NtCreatePagingFile(
585 IN PUNICODE_STRING PageFileName,
588 OUT PULONG ActualSize)
590 FIXME("(%p(%s),0x%08lx,0x%08lx,%p),stub!\n",
591 PageFileName->Buffer, debugstr_w(PageFileName->Buffer),MiniumSize,MaxiumSize,ActualSize);
595 /******************************************************************************
596 * NtDisplayString [NTDLL.@]
598 * writes a string to the nt-textmode screen eg. during startup
600 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
605 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
607 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
608 RtlFreeAnsiString( &stringA );
613 /******************************************************************************
614 * NtPowerInformation [NTDLL.@]
617 NTSTATUS WINAPI NtPowerInformation(DWORD x1,DWORD x2,DWORD x3,DWORD x4,DWORD x5)
619 FIXME("(0x%08lx,0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",x1,x2,x3,x4,x5);
623 /******************************************************************************
624 * NtAllocateLocallyUniqueId (NTDLL.@)
626 * FIXME: the server should do that
628 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
632 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.HighPart, luid.LowPart);
637 Luid->HighPart = luid.HighPart;
638 Luid->LowPart = luid.LowPart;
640 return STATUS_SUCCESS;
643 /******************************************************************************
644 * VerSetConditionMask (NTDLL.@)
646 ULONGLONG WINAPI VerSetConditionMask( ULONGLONG dwlConditionMask, DWORD dwTypeBitMask,
647 BYTE dwConditionMask)
649 if(dwTypeBitMask == 0)
650 return dwlConditionMask;
651 dwConditionMask &= 0x07;
652 if(dwConditionMask == 0)
653 return dwlConditionMask;
655 if(dwTypeBitMask & VER_PRODUCT_TYPE)
656 dwlConditionMask |= dwConditionMask << 7*3;
657 else if (dwTypeBitMask & VER_SUITENAME)
658 dwlConditionMask |= dwConditionMask << 6*3;
659 else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
660 dwlConditionMask |= dwConditionMask << 5*3;
661 else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
662 dwlConditionMask |= dwConditionMask << 4*3;
663 else if (dwTypeBitMask & VER_PLATFORMID)
664 dwlConditionMask |= dwConditionMask << 3*3;
665 else if (dwTypeBitMask & VER_BUILDNUMBER)
666 dwlConditionMask |= dwConditionMask << 2*3;
667 else if (dwTypeBitMask & VER_MAJORVERSION)
668 dwlConditionMask |= dwConditionMask << 1*3;
669 else if (dwTypeBitMask & VER_MINORVERSION)
670 dwlConditionMask |= dwConditionMask << 0*3;
671 return dwlConditionMask;