source: trunk/src/NTDLL/nt.cpp@ 51

Last change on this file since 51 was 51, checked in by sandervl, 26 years ago

* empty log message *

File size: 22.1 KB
Line 
1
2/*
3 * NT basis DLL
4 *
5 * This file contains the Nt* API functions of NTDLL.DLL.
6 * In the original ntdll.dll they all seem to just call int 0x2e (down to the HAL)
7 *
8 * Copyright 1996-1998 Marcus Meissner
9 * Copyright 1999 Patrick Haller
10 */
11
12#include <stdlib.h>
13#include <string.h>
14#include <time.h>
15
16#include "ntdll.h"
17
18
19/* move to winbase.h */
20
21// @@@PH can't compile this WINE code
22//typedef VOID (CALLBACK *PTIMERAPCROUTINE)(LPVOID lpArgToCompletionRoutine,DWORD dwTimerLowValue,DWORD dwTimerHighValue);
23typedef PVOID PTIMERAPCROUTINE;
24
25
26/*
27 * Timer object
28 */
29
30/**************************************************************************
31 * NtCreateTimer [NTDLL.87]
32 */
33NTSTATUS WINAPI NtCreateTimer(PHANDLE TimerHandle,
34 ACCESS_MASK DesiredAccess,
35 POBJECT_ATTRIBUTES ObjectAttributes,
36 TIMER_TYPE TimerType)
37{
38 dprintf(("NTDLL: NtCreateTimer(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
39 TimerHandle,
40 DesiredAccess,
41 ObjectAttributes,
42 TimerType));
43
44 return 0;
45}
46
47
48/**************************************************************************
49 * NtSetTimer [NTDLL.221]
50 */
51NTSTATUS WINAPI NtSetTimer(HANDLE TimerHandle,
52 PLARGE_INTEGER DueTime,
53 PTIMERAPCROUTINE TimerApcRoutine,
54 PVOID TimerContext,
55 BOOLEAN WakeTimer,
56 ULONG Period,
57 PBOOLEAN PreviousState)
58{
59 dprintf(("NTDLL: NtSetTimer(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
60 TimerHandle,
61 DueTime,
62 TimerApcRoutine,
63 TimerContext,
64 WakeTimer,
65 Period,
66 PreviousState));
67
68 return 0;
69}
70
71
72/******************************************************************************
73 * NtQueryTimerResolution [NTDLL.129]
74 */
75NTSTATUS WINAPI NtQueryTimerResolution(DWORD x1,
76 DWORD x2,
77 DWORD x3)
78{
79 dprintf(("NTDLL: NtQueryTimerResolution(%08xh,%08xh,%08xh) not implemented.\n",
80 x1,
81 x2,
82 x3));
83
84 return 1;
85}
86
87
88/*
89 * Process object
90 */
91
92/******************************************************************************
93 * NtTerminateProcess [NTDLL.]
94 *
95 * Native applications must kill themselves when done
96 * FIXME: return value 0-success
97 */
98NTSTATUS WINAPI NtTerminateProcess(HANDLE ProcessHandle,
99 LONG ExitStatus)
100{
101 dprintf(("NTDLL: NtTerminateProcess(%08xh,%08xh)",
102 ProcessHandle,
103 ExitStatus));
104
105 /* win32 (0x7fffffff) to nt (-1) */
106 if ( NtCurrentProcess() == ProcessHandle )
107 ProcessHandle = GetCurrentProcess();
108
109 /* @@@PH return code looks suspicious ! */
110 return (! TerminateProcess( ProcessHandle, ExitStatus ));
111}
112
113
114/******************************************************************************
115* NtQueryInformationProcess [NTDLL.]
116*
117*/
118NTSTATUS WINAPI NtQueryInformationProcess(HANDLE ProcessHandle,
119 PROCESSINFOCLASS ProcessInformationClass,
120 PVOID ProcessInformation,
121 ULONG ProcessInformationLength,
122 PULONG ReturnLength)
123{
124 dprintf(("NTDLL: NtQueryInformationProcess(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
125 ProcessHandle,
126 ProcessInformationClass,
127 ProcessInformation,
128 ProcessInformationLength,
129 ReturnLength));
130
131 return 0;
132}
133
134/******************************************************************************
135 * NtSetInformationProcess [NTDLL.207]
136 */
137NTSTATUS WINAPI NtSetInformationProcess(HANDLE ProcessHandle,
138 PROCESSINFOCLASS ProcessInformationClass,
139 PVOID ProcessInformation,
140 ULONG ProcessInformationLength)
141{
142 dprintf(("NTDLL: NtSetInformationProcess(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
143 ProcessHandle,
144 ProcessInformationClass,
145 ProcessInformation,
146 ProcessInformationLength));
147
148 return 0;
149}
150
151
152/*
153 * Thread
154 */
155
156/******************************************************************************
157 * NtResumeThread [NTDLL]
158 */
159NTSTATUS WINAPI NtResumeThread(HANDLE ThreadHandle,
160 PULONG SuspendCount)
161{
162 dprintf(("NTDLL: NtResumeThread(%08xh,%08x) not implemented.\n",
163 ThreadHandle,
164 SuspendCount));
165
166 return 0;
167}
168
169
170/******************************************************************************
171 * NtTerminateThread [NTDLL]
172 */
173NTSTATUS WINAPI NtTerminateThread(HANDLE ThreadHandle,
174 NTSTATUS ExitStatus)
175{
176 dprintf(("NTDLL: NtTerminateThread(%08xh,%08xh) not correctly implemented.\n",
177 ThreadHandle,
178 ExitStatus));
179
180 if ( TerminateThread(ThreadHandle,ExitStatus) )
181 return 0;
182
183 return 0xc0000000; /* FIXME: lasterror->ntstatus */
184}
185
186
187/******************************************************************************
188* NtQueryInformationThread [NTDLL.]
189*
190*/
191NTSTATUS WINAPI NtQueryInformationThread(HANDLE ThreadHandle,
192 THREADINFOCLASS ThreadInformationClass,
193 PVOID ThreadInformation,
194 ULONG ThreadInformationLength,
195 PULONG ReturnLength)
196{
197 dprintf(("NTDLL: NtQueryInformationThread(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
198 ThreadHandle,
199 ThreadInformationClass,
200 ThreadInformation,
201 ThreadInformationLength,
202 ReturnLength));
203
204 return 0;
205}
206
207
208/******************************************************************************
209 * NtSetInformationThread [NTDLL]
210 */
211NTSTATUS WINAPI NtSetInformationThread(HANDLE ThreadHandle,
212 THREADINFOCLASS ThreadInformationClass,
213 PVOID ThreadInformation,
214 ULONG ThreadInformationLength)
215{
216 dprintf(("NTDLL: NtSetInformationThread(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
217 ThreadHandle,
218 ThreadInformationClass,
219 ThreadInformation,
220 ThreadInformationLength));
221
222 return 0;
223}
224
225
226/*
227 * Token
228 */
229
230/******************************************************************************
231 * NtDuplicateToken [NTDLL]
232 */
233NTSTATUS WINAPI NtDuplicateToken(HANDLE ExistingToken,
234 ACCESS_MASK DesiredAccess,
235 POBJECT_ATTRIBUTES ObjectAttributes,
236 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
237 TOKEN_TYPE TokenType,
238 PHANDLE NewToken)
239{
240 dprintf(("NTDLL: NtDuplicateToken(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
241 ExistingToken,
242 DesiredAccess,
243 ObjectAttributes,
244 ImpersonationLevel,
245 TokenType,
246 NewToken));
247
248 return 0;
249}
250
251/******************************************************************************
252 * NtOpenProcessToken [NTDLL]
253 */
254NTSTATUS WINAPI NtOpenProcessToken(HANDLE ProcessHandle,
255 DWORD DesiredAccess,
256 PHANDLE TokenHandle)
257{
258 dprintf(("NTDLL: NtOpenProcessToken(%08xh,%08xh,%08xh) not implemented.\n",
259 ProcessHandle,
260 DesiredAccess,
261 TokenHandle));
262
263 *TokenHandle = 0xcafe;
264 return 0;
265}
266
267
268/******************************************************************************
269 * NtOpenThreadToken [NTDLL]
270 */
271NTSTATUS WINAPI NtOpenThreadToken(HANDLE ThreadHandle,
272 DWORD DesiredAccess,
273 BOOLEAN OpenAsSelf,
274 PHANDLE TokenHandle)
275{
276 dprintf(("NTDLL: NtOpenThreadToken(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
277 ThreadHandle,
278 DesiredAccess,
279 OpenAsSelf,
280 TokenHandle));
281
282 *TokenHandle = 0xcafe;
283 return 0;
284}
285
286
287/******************************************************************************
288 * NtAdjustPrivilegesToken [NTDLL]
289 *
290 * FIXME: parameters unsafe
291 */
292NTSTATUS WINAPI NtAdjustPrivilegesToken(HANDLE TokenHandle,
293 BOOLEAN DisableAllPrivileges,
294 PTOKEN_PRIVILEGES NewState,
295 DWORD BufferLength,
296 PTOKEN_PRIVILEGES PreviousState,
297 PDWORD ReturnLength)
298{
299 dprintf(("NTDLL: NtAdjustPrivilegesToken(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
300 TokenHandle,
301 DisableAllPrivileges,
302 NewState,
303 BufferLength,
304 PreviousState,
305 ReturnLength));
306
307 return 0;
308}
309
310
311/******************************************************************************
312* NtQueryInformationToken [NTDLL.156]
313*
314*/
315NTSTATUS WINAPI NtQueryInformationToken(HANDLE Token,
316 DWORD TokenInformationClass,
317 LPVOID TokenInformation,
318 DWORD TokenInformationLength,
319 LPDWORD ReturnLength)
320{
321 dprintf(("NTDLL: NtQueryInformationToken(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
322 Token,
323 TokenInformationClass,
324 TokenInformation,
325 TokenInformationLength,
326 ReturnLength));
327
328 switch (TokenInformationClass)
329 {
330 case TokenGroups: /* 2 */
331 *ReturnLength = sizeof (TOKEN_GROUPS);
332#if 0
333 case TokenUser: /* 1 */
334 case TokenPrivileges:
335 case TokenOwner:
336 case TokenPrimaryGroup:
337 case TokenDefaultDacl:
338 case TokenSource:
339 case TokenType:
340 case TokenImpersonationLevel:
341 case TokenStatistics:
342#endif /* 0 */
343 }
344
345 return 0;
346}
347
348
349/*
350 * Section
351 */
352
353/******************************************************************************
354 * NtCreateSection [NTDLL]
355 */
356NTSTATUS WINAPI NtCreateSection(PHANDLE SectionHandle,
357 ACCESS_MASK DesiredAccess,
358 POBJECT_ATTRIBUTES ObjectAttributes,
359 PLARGE_INTEGER MaximumSize,
360 ULONG SectionPageProtection,
361 ULONG AllocationAttributes,
362 HANDLE FileHandle)
363{
364 dprintf(("NTDLL: NtCreateSection(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
365 SectionHandle,
366 DesiredAccess,
367 ObjectAttributes,
368 MaximumSize,
369 SectionPageProtection,
370 AllocationAttributes,
371 FileHandle));
372
373 return 0;
374}
375
376
377/******************************************************************************
378 * NtOpenSection [NTDLL]
379 */
380NTSTATUS WINAPI NtOpenSection(PHANDLE SectionHandle,
381 ACCESS_MASK DesiredAccess,
382 POBJECT_ATTRIBUTES ObjectAttributes)
383{
384 dprintf(("NTDLL: NtOpenSection(%08xh,%08xh,%08xh) not implemented.\n",
385 SectionHandle,
386 DesiredAccess,
387 ObjectAttributes));
388
389 return 0;
390}
391
392
393/******************************************************************************
394 * NtQuerySection [NTDLL]
395 */
396NTSTATUS WINAPI NtQuerySection(HANDLE SectionHandle,
397 PVOID SectionInformationClass,
398 PVOID SectionInformation,
399 ULONG Length,
400 PULONG ResultLength)
401{
402 dprintf(("NTDLL: NtQuerySection(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
403 SectionHandle,
404 SectionInformationClass,
405 SectionInformation,
406 Length,
407 ResultLength));
408
409 return 0;
410}
411
412
413/******************************************************************************
414 * NtMapViewOfSection [NTDLL]
415 * FUNCTION: Maps a view of a section into the virtual address space of a process
416 *
417 * ARGUMENTS:
418 * SectionHandle Handle of the section
419 * ProcessHandle Handle of the process
420 * BaseAddress Desired base address (or NULL) on entry
421 * Actual base address of the view on exit
422 * ZeroBits Number of high order address bits that must be zero
423 * CommitSize Size bytes of the initially committed section of the view
424 * SectionOffset Offset bytes from the beginning of the section to the beginning of the view
425 * ViewSize Desired length of map (or zero to map all) on entry
426 Actual length mapped on exit
427 * InheritDisposition Specified how the view is to be shared with
428 * child processes
429 * AllocateType Type of allocation for the pages
430 * Protect Protection for the committed region of the view
431 */
432NTSTATUS WINAPI NtMapViewOfSection(HANDLE SectionHandle,
433 HANDLE ProcessHandle,
434 PVOID* BaseAddress,
435 ULONG ZeroBits,
436 ULONG CommitSize,
437 PLARGE_INTEGER SectionOffset,
438 PULONG ViewSize,
439 SECTION_INHERIT InheritDisposition,
440 ULONG AllocationType,
441 ULONG Protect)
442{
443 dprintf(("NTDLL: NtMapViewOfSection(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
444 SectionHandle,
445 ProcessHandle,
446 BaseAddress,
447 ZeroBits,
448 CommitSize,
449 SectionOffset,
450 ViewSize,
451 InheritDisposition,
452 AllocationType,
453 Protect));
454
455 return 0;
456}
457
458
459/*
460 * ports
461 */
462
463/******************************************************************************
464 * NtCreatePort [NTDLL]
465 */
466NTSTATUS WINAPI NtCreatePort(DWORD x1,
467 DWORD x2,
468 DWORD x3,
469 DWORD x4,
470 DWORD x5)
471{
472 dprintf(("NTDLL: NtCreatePort(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
473 x1,
474 x2,
475 x3,
476 x4,
477 x5));
478
479 return 0;
480}
481
482
483/******************************************************************************
484 * NtConnectPort [NTDLL]
485 */
486NTSTATUS WINAPI NtConnectPort(DWORD x1,
487 PUNICODE_STRING uni,
488 DWORD x3,
489 DWORD x4,
490 DWORD x5,
491 DWORD x6,
492 DWORD x7,
493 DWORD x8)
494{
495 dprintf(("NTDLL: NtConnectPort(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
496 x1,
497 uni,
498 x3,
499 x4,
500 x5,
501 x6,
502 x7,
503 x8));
504
505 return 0;
506}
507
508
509/******************************************************************************
510 * NtListenPort [NTDLL]
511 */
512NTSTATUS WINAPI NtListenPort(DWORD x1,
513 DWORD x2)
514{
515 dprintf(("NTDLL: NtListenPort(%08xh,%08xh) not implemented.\n",
516 x1,
517 x2));
518
519 return 0;
520}
521
522
523/******************************************************************************
524 * NtAcceptConnectPort [NTDLL]
525 */
526NTSTATUS WINAPI NtAcceptConnectPort(DWORD x1,
527 DWORD x2,
528 DWORD x3,
529 DWORD x4,
530 DWORD x5,
531 DWORD x6)
532{
533 dprintf(("NTDLL: NtAcceptConnectPort(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
534 x1,
535 x2,
536 x3,
537 x4,
538 x5,
539 x6));
540
541 return 0;
542}
543
544
545/******************************************************************************
546 * NtCompleteConnectPort [NTDLL]
547 */
548NTSTATUS WINAPI NtCompleteConnectPort(DWORD x1)
549{
550 dprintf(("NTDLL: NtCompleteConnectPort(%08xh) not implemented.\n",
551 x1));
552
553 return 0;
554}
555
556
557/******************************************************************************
558 * NtRegisterThreadTerminatePort [NTDLL]
559 */
560NTSTATUS WINAPI NtRegisterThreadTerminatePort(DWORD x1)
561{
562 dprintf(("NTDLL: NtRegisterThreadTerminatePort(%08xh) not implemented.\n",
563 x1));
564
565 return 0;
566}
567
568
569/******************************************************************************
570 * NtRequestWaitReplyPort [NTDLL]
571 */
572NTSTATUS WINAPI NtRequestWaitReplyPort(DWORD x1,
573 DWORD x2,
574 DWORD x3)
575{
576 dprintf(("NTDLL: NtRequestWaitReplyPort(%08xh,%08xh,%08xh) not implemented.\n",
577 x1,
578 x2,
579 x3));
580
581 return 0;
582}
583
584
585/******************************************************************************
586 * NtReplyWaitReceivePort [NTDLL]
587 */
588NTSTATUS WINAPI NtReplyWaitReceivePort(DWORD x1,
589 DWORD x2,
590 DWORD x3,
591 DWORD x4)
592{
593 dprintf(("NTDLL: NtReplyWaitReceivePort(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
594 x1,
595 x2,
596 x3,
597 x4));
598
599 return 0;
600}
601
602
603/*
604 * Misc
605 */
606
607 /******************************************************************************
608 * NtSetIntervalProfile [NTDLL]
609 */
610NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,
611 DWORD x2)
612{
613 dprintf(("NTDLL: NtSetIntervalProfile(%08xh,%08xh) not implemented.\n",
614 x1,
615 x2));
616
617 return 0;
618}
619
620
621/******************************************************************************
622 * NtQueryPerformanceCounter [NTDLL]
623 */
624NTSTATUS WINAPI NtQueryPerformanceCounter(PLARGE_INTEGER Counter,
625 PLARGE_INTEGER Frequency)
626{
627 dprintf(("NTDLL: NtQueryPerformanceCounter(%08xh,%08xh) not implemented.\n",
628 Counter,
629 Frequency));
630
631 return 0;
632}
633
634
635/******************************************************************************
636 * NtCreateMailSlotFile [NTDLL]
637 */
638NTSTATUS WINAPI NtCreateMailslotFile(DWORD x1,
639 DWORD x2,
640 DWORD x3,
641 DWORD x4,
642 DWORD x5,
643 DWORD x6,
644 DWORD x7,
645 DWORD x8)
646{
647 dprintf(("NTDLL: NtCreateMailslotFile(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
648 x1,
649 x2,
650 x3,
651 x4,
652 x5,
653 x6,
654 x7,
655 x8));
656
657 return 0;
658}
659
660
661/******************************************************************************
662 * NtQuerySystemInformation [NTDLL.168]
663 *
664 * ARGUMENTS:
665 * SystemInformationClass Index to a certain information structure
666 * SystemTimeAdjustmentInformation SYSTEM_TIME_ADJUSTMENT
667 * SystemCacheInformation SYSTEM_CACHE_INFORMATION
668 * SystemConfigurationInformation CONFIGURATION_INFORMATION
669 * observed (class/len):
670 * 0x0/0x2c
671 * 0x12/0x18
672 * 0x2/0x138
673 * 0x8/0x600
674 * SystemInformation caller supplies storage for the information structure
675 * Length size of the structure
676 * ResultLength Data written
677 */
678NTSTATUS WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,
679 PVOID SystemInformation,
680 ULONG Length,
681 PULONG ResultLength)
682{
683 dprintf(("NTDLL: NtQuerySystemInformation(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
684 SystemInformationClass,
685 SystemInformation,
686 Length,
687 ResultLength));
688
689 ZeroMemory (SystemInformation, Length);
690 return 0;
691}
692
693
694/******************************************************************************
695 * NtCreatePagingFile [NTDLL]
696 */
697NTSTATUS WINAPI NtCreatePagingFile(PUNICODE_STRING PageFileName,
698 ULONG MinimumSize,
699 ULONG MaximumSize,
700 PULONG ActualSize)
701{
702 dprintf(("NTDLL: NtCreatePagingFile(%08xh, %08xh, %08xh, %08xh) not implemented.\n",
703 PageFileName,
704 MinimumSize,
705 MaximumSize,
706 ActualSize));
707
708 return 0;
709}
710
711
712/******************************************************************************
713 * NtDisplayString [NTDLL.95]
714 *
715 * writes a string to the nt-textmode screen eg. during startup
716 */
717NTSTATUS WINAPI NtDisplayString (PUNICODE_STRING string)
718{
719 dprintf(("NTDLL: NtDisplayString(%08xh\n",
720 string));
721
722 WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),
723 string->Buffer,
724 string->Length,
725 0,
726 0);
727
728 return 0;
729}
Note: See TracBrowser for help on using the repository browser.