Added preferences to dinput drivers (so we can have two joystick
[wine/hacks.git] / dlls / ntdll / nt.c
blob5db057c6ea286d5c4a62924b3dc1d69c94a81135
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"
18 #include "server.h"
20 DEFAULT_DEBUG_CHANNEL(ntdll);
23 * Timer object
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);
38 return 0;
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,
48 IN BOOLEAN WakeTimer,
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);
54 return 0;
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);
63 return 1;
67 * Process object
70 /******************************************************************************
71 * NtTerminateProcess [NTDLL.]
73 * Native applications must kill themselves when done
75 NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
77 NTSTATUS ret;
78 BOOL self;
79 SERVER_START_REQ
81 struct terminate_process_request *req = server_alloc_req( sizeof(*req), 0 );
82 req->handle = handle;
83 req->exit_code = exit_code;
84 ret = server_call_noerr( REQ_TERMINATE_PROCESS );
85 self = !ret && req->self;
87 SERVER_END_REQ;
88 if (self) exit( exit_code );
89 return ret;
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);
111 return 0;
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);
125 return 0;
129 * Thread
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);
141 return 0;
145 /******************************************************************************
146 * NtTerminateThread [NTDLL]
148 NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
150 NTSTATUS ret;
151 BOOL self, last;
153 SERVER_START_REQ
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;
160 last = req->last;
162 SERVER_END_REQ;
164 if (self)
166 if (last) exit( exit_code );
167 else SYSDEPS_ExitThread( exit_code );
169 return ret;
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);
187 return 0;
190 /******************************************************************************
191 * NtSetInformationThread [NTDLL]
193 NTSTATUS WINAPI NtSetInformationThread(
194 HANDLE ThreadHandle,
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);
201 return 0;
205 * Token
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);
223 return 0;
226 /******************************************************************************
227 * NtOpenProcessToken [NTDLL]
229 NTSTATUS WINAPI NtOpenProcessToken(
230 HANDLE ProcessHandle,
231 DWORD DesiredAccess,
232 HANDLE *TokenHandle)
234 FIXME("(0x%08x,0x%08lx,%p): stub\n",
235 ProcessHandle,DesiredAccess, TokenHandle);
236 *TokenHandle = 0xcafe;
237 return 0;
240 /******************************************************************************
241 * NtOpenThreadToken [NTDLL]
243 NTSTATUS WINAPI NtOpenThreadToken(
244 HANDLE ThreadHandle,
245 DWORD DesiredAccess,
246 BOOLEAN OpenAsSelf,
247 HANDLE *TokenHandle)
249 FIXME("(0x%08x,0x%08lx,0x%08x,%p): stub\n",
250 ThreadHandle,DesiredAccess, OpenAsSelf, TokenHandle);
251 *TokenHandle = 0xcafe;
252 return 0;
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);
270 return 0;
273 /******************************************************************************
274 * NtQueryInformationToken [NTDLL.156]
276 * NOTES
277 * Buffer for TokenUser:
278 * 0x00 TOKEN_USER the PSID field points to the SID
279 * 0x08 SID
282 NTSTATUS WINAPI NtQueryInformationToken(
283 HANDLE token,
284 DWORD tokeninfoclass,
285 LPVOID tokeninfo,
286 DWORD tokeninfolength,
287 LPDWORD retlen )
289 unsigned int len = 0;
291 FIXME("(%08x,%ld,%p,%ld,%p): stub\n",
292 token,tokeninfoclass,tokeninfo,tokeninfolength,retlen);
294 switch (tokeninfoclass)
296 case TokenUser:
297 len = sizeof(TOKEN_USER) + sizeof(SID);
298 break;
299 case TokenGroups:
300 len = sizeof(TOKEN_GROUPS);
301 break;
302 case TokenPrivileges:
303 len = sizeof(TOKEN_PRIVILEGES);
304 break;
305 case TokenOwner:
306 len = sizeof(TOKEN_OWNER);
307 break;
308 case TokenPrimaryGroup:
309 len = sizeof(TOKEN_PRIMARY_GROUP);
310 break;
311 case TokenDefaultDacl:
312 len = sizeof(TOKEN_DEFAULT_DACL);
313 break;
314 case TokenSource:
315 len = sizeof(TOKEN_SOURCE);
316 break;
317 case TokenType:
318 len = sizeof (TOKEN_TYPE);
319 break;
320 #if 0
321 case TokenImpersonationLevel:
322 case TokenStatistics:
323 #endif /* 0 */
326 /* FIXME: what if retlen == NULL ? */
327 *retlen = len;
329 if (tokeninfolength < len)
330 return STATUS_BUFFER_TOO_SMALL;
332 switch (tokeninfoclass)
334 case TokenUser:
335 if( tokeninfo )
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;
344 break;
345 case TokenGroups:
346 if (tokeninfo)
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,
357 0, 0, 0, 0, 0, 0,
358 &(tgroups->Groups->Sid));
360 break;
361 case TokenPrivileges:
362 if (tokeninfo)
364 TOKEN_PRIVILEGES *tpriv = tokeninfo;
365 tpriv->PrivilegeCount = 1;
367 break;
369 return 0;
373 * Section
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);
392 return 0;
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);
406 return 0;
409 /******************************************************************************
410 * NtQuerySection [NTDLL]
412 NTSTATUS WINAPI NtQuerySection(
413 IN HANDLE SectionHandle,
414 IN PVOID SectionInformationClass,
415 OUT PVOID SectionInformation,
416 IN ULONG Length,
417 OUT PULONG ResultLength)
419 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
420 SectionHandle,SectionInformationClass,SectionInformation,Length,ResultLength);
421 return 0;
424 /******************************************************************************
425 * NtMapViewOfSection [NTDLL]
426 * FUNCTION: Maps a view of a section into the virtual address space of a process
428 * ARGUMENTS:
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
439 * child processes
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,
446 PVOID* BaseAddress,
447 ULONG ZeroBits,
448 ULONG CommitSize,
449 PLARGE_INTEGER SectionOffset,
450 PULONG ViewSize,
451 SECTION_INHERIT InheritDisposition,
452 ULONG AllocationType,
453 ULONG Protect)
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);
458 return 0;
462 * ports
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);
471 return 0;
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);
481 return 0;
484 /******************************************************************************
485 * NtListenPort [NTDLL]
487 NTSTATUS WINAPI NtListenPort(DWORD x1,DWORD x2)
489 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
490 return 0;
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);
499 return 0;
502 /******************************************************************************
503 * NtCompleteConnectPort [NTDLL]
505 NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
507 FIXME("(0x%08lx),stub!\n",x1);
508 return 0;
511 /******************************************************************************
512 * NtRegisterThreadTerminatePort [NTDLL]
514 NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
516 FIXME("(0x%08lx),stub!\n",x1);
517 return 0;
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);
526 return 0;
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);
535 return 0;
539 * Misc
542 /******************************************************************************
543 * NtSetIntervalProfile [NTDLL]
545 NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
546 FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
547 return 0;
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",
558 Counter, Frequency);
559 return 0;
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);
568 return 0;
571 /******************************************************************************
572 * NtQuerySystemInformation [NTDLL.168]
574 * ARGUMENTS:
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):
580 * 0x0/0x2c
581 * 0x12/0x18
582 * 0x2/0x138
583 * 0x8/0x600
584 * 0x25/0xc
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,
592 IN ULONG Length,
593 OUT PULONG ResultLength)
595 switch(SystemInformationClass)
597 case 0x25:
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;
608 break;
610 default:
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,
625 IN ULONG MiniumSize,
626 IN ULONG MaxiumSize,
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);
631 return 0;
634 /******************************************************************************
635 * NtDisplayString [NTDLL.95]
637 * writes a string to the nt-textmode screen eg. during startup
639 NTSTATUS WINAPI NtDisplayString ( PUNICODE_STRING string )
641 STRING stringA;
642 NTSTATUS ret;
644 if (!(ret = RtlUnicodeStringToAnsiString( &stringA, string, TRUE )))
646 MESSAGE( "%.*s", stringA.Length, stringA.Buffer );
647 RtlFreeAnsiString( &stringA );
649 return ret;
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);
659 return 0;
662 /******************************************************************************
663 * NtAllocateLocallyUniqueId
665 * FIXME: the server should do that
667 NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID Luid)
669 static LUID luid;
671 FIXME("%p (0x%08lx%08lx)\n", Luid, luid.DUMMYSTRUCTNAME.HighPart, luid.DUMMYSTRUCTNAME.LowPart);
673 luid.QuadPart++;
675 Luid->QuadPart = luid.QuadPart;
676 return STATUS_SUCCESS;