Create directories that don't contain a Makefile.
[wine/multimedia.git] / dlls / ntdll / nt.c
blobff18cef9b964fc0e0383e16d8fe4cdf5ab54a8c4
1 /*
2 * NT basis DLL
3 *
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
8 */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <time.h>
14 #include "debugtools.h"
16 #include "ntddk.h"
17 #include "ntdll_misc.h"
19 DEFAULT_DEBUG_CHANNEL(ntdll);
22 * Timer object
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);
37 return 0;
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,
47 IN BOOLEAN WakeTimer,
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);
53 return 0;
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);
62 return 1;
66 * Process object
69 /******************************************************************************
70 * NtTerminateProcess [NTDLL.]
72 * Native applications must kill themselves when done
73 * FIXME: return value 0-success
75 NTSTATUS WINAPI NtTerminateProcess(
76 HANDLE ProcessHandle,
77 LONG ExitStatus)
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);
101 return 0;
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);
115 return 0;
119 * Thread
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);
131 return 0;
134 /******************************************************************************
135 * NtTerminateThread [NTDLL]
137 NTSTATUS WINAPI NtTerminateThread(
138 IN HANDLE ThreadHandle,
139 IN NTSTATUS ExitStatus)
141 if ( TerminateThread(ThreadHandle,ExitStatus) )
142 return 0;
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);
161 return 0;
164 /******************************************************************************
165 * NtSetInformationThread [NTDLL]
167 NTSTATUS WINAPI NtSetInformationThread(
168 HANDLE ThreadHandle,
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);
175 return 0;
179 * Token
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);
197 return 0;
200 /******************************************************************************
201 * NtOpenProcessToken [NTDLL]
203 NTSTATUS WINAPI NtOpenProcessToken(
204 HANDLE ProcessHandle,
205 DWORD DesiredAccess,
206 HANDLE *TokenHandle)
208 FIXME("(0x%08x,0x%08lx,%p): stub\n",
209 ProcessHandle,DesiredAccess, TokenHandle);
210 *TokenHandle = 0xcafe;
211 return 0;
214 /******************************************************************************
215 * NtOpenThreadToken [NTDLL]
217 NTSTATUS WINAPI NtOpenThreadToken(
218 HANDLE ThreadHandle,
219 DWORD DesiredAccess,
220 BOOLEAN OpenAsSelf,
221 HANDLE *TokenHandle)
223 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
224 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
225 *TokenHandle = 0xcafe;
226 return 0;
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);
244 return 0;
247 /******************************************************************************
248 * NtQueryInformationToken [NTDLL.156]
250 * NOTES
251 * Buffer for TokenUser:
252 * 0x00 TOKEN_USER the PSID field points to the SID
253 * 0x08 SID
256 NTSTATUS WINAPI NtQueryInformationToken(
257 HANDLE token,
258 DWORD tokeninfoclass,
259 LPVOID tokeninfo,
260 DWORD tokeninfolength,
261 LPDWORD retlen )
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);
269 break;
270 case TokenUser: /* 1 */
272 int len = sizeof (TOKEN_USER)+ sizeof(SID);
273 *retlen = len;
274 if ( len <= tokeninfolength)
275 if( tokeninfo )
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;
285 break;
286 case TokenPrivileges:
287 *retlen = sizeof (TOKEN_PRIVILEGES);
288 break;
289 case TokenOwner:
290 *retlen = sizeof (TOKEN_OWNER);
291 break;
292 case TokenPrimaryGroup:
293 *retlen = sizeof (TOKEN_PRIMARY_GROUP);
294 break;
295 case TokenDefaultDacl:
296 *retlen = sizeof (TOKEN_DEFAULT_DACL);
297 break;
298 case TokenSource:
299 *retlen = sizeof (TOKEN_SOURCE);
300 break;
301 case TokenType:
302 *retlen = sizeof (TOKEN_TYPE);
303 break;
304 #if 0
305 case TokenImpersonationLevel:
306 case TokenStatistics:
307 #endif /* 0 */
310 return 0;
314 * Section
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);
333 return 0;
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);
347 return 0;
350 /******************************************************************************
351 * NtQuerySection [NTDLL]
353 NTSTATUS WINAPI NtQuerySection(
354 IN HANDLE SectionHandle,
355 IN PVOID SectionInformationClass,
356 OUT PVOID SectionInformation,
357 IN ULONG Length,
358 OUT PULONG ResultLength)
360 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
361 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
362 return 0;
365 /******************************************************************************
366 * NtMapViewOfSection [NTDLL]
367 * FUNCTION: Maps a view of a section into the virtual address space of a process
369 * ARGUMENTS:
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
380 * child processes
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,
387 PVOID* BaseAddress,
388 ULONG ZeroBits,
389 ULONG CommitSize,
390 PLARGE_INTEGER SectionOffset,
391 PULONG ViewSize,
392 SECTION_INHERIT InheritDisposition,
393 ULONG AllocationType,
394 ULONG Protect)
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);
399 return 0;
403 * ports
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);
412 return 0;
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);
422 return 0;
425 /******************************************************************************
426 * NtListenPort [NTDLL]
428 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
430 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
431 return 0;
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);
440 return 0;
443 /******************************************************************************
444 * NtCompleteConnectPort [NTDLL]
446 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
448 FIXME("(0x%08lx),stub!\n",x1);
449 return 0;
452 /******************************************************************************
453 * NtRegisterThreadTerminatePort [NTDLL]
455 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
457 FIXME("(0x%08lx),stub!\n",x1);
458 return 0;
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);
467 return 0;
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);
476 return 0;
480 * Misc
483 /******************************************************************************
484 * NtSetIntervalProfile [NTDLL]
486 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
487 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
488 return 0;
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",
499 Counter, Frequency);
500 return 0;
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);
509 return 0;
512 /******************************************************************************
513 * NtQuerySystemInformation [NTDLL.168]
515 * ARGUMENTS:
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):
521 * 0x0/0x2c
522 * 0x12/0x18
523 * 0x2/0x138
524 * 0x8/0x600
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,
532 IN ULONG Length,
533 OUT PULONG ResultLength)
535 FIXME("(0x%08x,%p,0x%08lx,%p) stub\n",
536 SystemInformationClass,SystemInformation,Length,ResultLength);
537 ZeroMemory (SystemInformation, Length);
538 return 0;
542 /******************************************************************************
543 * NtCreatePagingFile [NTDLL]
545 NTSTATUS WINAPI NtCreatePagingFile(
546 IN PUNICODE_STRING PageFileName,
547 IN ULONG MiniumSize,
548 IN ULONG MaxiumSize,
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);
553 return 0;
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);
566 return 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);
578 #else
579 FIXME("stub\n");
580 return 0;
581 #endif
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);
592 #else
593 FIXME("stub\n");
594 return 0;
595 #endif
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);
605 return 0;
608 /******************************************************************************
609 * NtAllocateLocallyUniqueId
611 * FIXME: the server should do that
613 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
615 static LUID luid;
617 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.DUMMYSTRUCTNAME.HighPart, luid.DUMMYSTRUCTNAME.LowPart);
619 luid.QuadPart++;
621 Luid->QuadPart = luid.QuadPart;
622 return STATUS_SUCCESS;