a27c8acae5312e4b4cd7b8a0c207e2b9ff982c76
[reactos.git] / reactos / subsys / system / autochk / autochk.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2002 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: apps/system/autochk/autochk.c
24 * PURPOSE: Filesystem checker
25 * PROGRAMMER: Eric Kohl
26 */
27
28 /* INCLUDES *****************************************************************/
29
30 #include <ntos.h>
31 #include <napi/shared_data.h>
32
33 /* FUNCTIONS ****************************************************************/
34
35 void
36 DisplayString(LPCWSTR lpwString)
37 {
38 UNICODE_STRING us;
39
40 RtlInitUnicodeString(&us, lpwString);
41 NtDisplayString(&us);
42 }
43
44
45 void
46 PrintString(char* fmt,...)
47 {
48 char buffer[512];
49 va_list ap;
50 UNICODE_STRING UnicodeString;
51 ANSI_STRING AnsiString;
52
53 va_start(ap, fmt);
54 vsprintf(buffer, fmt, ap);
55 va_end(ap);
56
57 RtlInitAnsiString(&AnsiString, buffer);
58 RtlAnsiStringToUnicodeString(&UnicodeString,
59 &AnsiString,
60 TRUE);
61 NtDisplayString(&UnicodeString);
62 RtlFreeUnicodeString(&UnicodeString);
63 }
64
65
66 /* Native image's entry point */
67
68 VOID STDCALL
69 NtProcessStartup(PPEB Peb)
70 {
71 PROCESS_DEVICEMAP_INFORMATION DeviceMap;
72 ULONG i;
73 NTSTATUS Status;
74
75 PrintString("Autochk 0.0.1\n");
76
77 Status = NtQueryInformationProcess(NtCurrentProcess(),
78 ProcessDeviceMap,
79 &DeviceMap.Query,
80 sizeof(DeviceMap.Query),
81 NULL);
82 if(NT_SUCCESS(Status))
83 {
84 for (i = 0; i < 26; i++)
85 {
86 if ((DeviceMap.Query.DriveMap & (1 << i)) &&
87 (DeviceMap.Query.DriveType[i] == DOSDEVICE_DRIVE_FIXED))
88 {
89 PrintString(" Checking drive %c:", 'A'+i);
90 PrintString(" OK\n");
91 }
92 }
93 PrintString("\n");
94 }
95
96 NtTerminateProcess(NtCurrentProcess(), 0);
97 }
98
99 /* EOF */