2 * reactos registry handling functions emulation of libcaptive
3 * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
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; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "reactos/ddk/kefuncs.h" /* self */
23 #include <glib/gmessages.h>
24 #include "captive/unicode.h"
25 #include "captive/macros.h"
29 * RtlQueryRegistryValues:
30 * @RelativeTo: Basedir type constant of relative @Path; ignored by libcaptive.
31 * @Path: String path or handle to retrieve; ignored by libcaptive.
32 * @QueryTable: Table of entries to retrieve; ignored by libcaptive.
33 * %NULL value is forbidden.
34 * @Context: Userdata to pass to QueryRoutine() (of @QueryTable); ignored by libcaptive.
35 * @Environment: Environment variable to use for key expansion; optional; ignored by libcaptive.
37 * Retrieves specified key from the system registry database.
38 * libcaptive currently always returns %STATUS_OBJECT_NAME_NOT_FOUND
39 * except #ULONG value 1 for the key "\captive\filesystem\Parameters\WritingSupport"
40 * (for ext2fsd.sys V0.10A).
42 * Returns: %STATUS_OBJECT_NAME_NOT_FOUND or %STATUS_SUCCESS if some result returned.
44 NTSTATUS RtlQueryRegistryValues
45 (IN ULONG RelativeTo,IN PCWSTR Path,IN PRTL_QUERY_REGISTRY_TABLE QueryTable,IN PVOID Context,IN PVOID Environment)
47 const WCHAR *Path__captive_filesystem_Parameters_ucs2=
48 captive_utf8_to_UnicodeString_alloca("\\captive\\filesystem\\Parameters")->Buffer;
49 const WCHAR *QueryTable_WritingSupport_Name_ucs2=
50 captive_utf8_to_UnicodeString_alloca("WritingSupport")->Buffer;
51 const WCHAR *QueryTable_CSDVersion_Name_ucs2=
52 captive_utf8_to_UnicodeString_alloca("CSDVersion")->Buffer;
53 const gchar *RelativeTo_table[]={
54 "RTL_REGISTRY_ABSOLUTE",
55 "RTL_REGISTRY_SERVICES",
56 "RTL_REGISTRY_CONTROL",
57 "RTL_REGISTRY_WINDOWS_NT",
58 "RTL_REGISTRY_DEVICEMAP",
62 UNICODE_STRING Path_UnicodeString;
64 g_return_val_if_fail(Path!=NULL,STATUS_INVALID_PARAMETER);
65 g_return_val_if_fail(QueryTable!=NULL,STATUS_INVALID_PARAMETER);
67 Path_UnicodeString.Length=captive_ucs2_strlen(Path)*sizeof(*Path_UnicodeString.Buffer);
68 Path_UnicodeString.MaximumLength=Path_UnicodeString.Length+sizeof(*Path_UnicodeString.Buffer);
69 Path_UnicodeString.Buffer=(/* de-const */ PWSTR)Path;
70 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: RelativeTo=%s,Path=%s",G_STRLOC,
71 (RelativeTo>=0 && RelativeTo<G_N_ELEMENTS(RelativeTo_table)
72 ? RelativeTo_table[RelativeTo] : captive_printf_alloca("%lu",(unsigned long)RelativeTo)),
73 captive_UnicodeString_to_utf8_alloca(&Path_UnicodeString));
75 if (RelativeTo==RTL_REGISTRY_ABSOLUTE
76 && captive_ucs2_compare(Path,Path__captive_filesystem_Parameters_ucs2)
77 && QueryTable[0].Name!=NULL
78 && captive_ucs2_compare(QueryTable[0].Name,QueryTable_WritingSupport_Name_ucs2)
79 && QueryTable[0].Flags==(RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED)
80 && QueryTable[0].EntryContext!=NULL
81 && QueryTable[1].Name==NULL) {
82 *(ULONG *)QueryTable[0].EntryContext=1; /* => 'EXT2_SUPPORT_WRITING' */
83 return STATUS_SUCCESS;
86 if (RelativeTo==RTL_REGISTRY_WINDOWS_NT
88 && QueryTable[0].Name!=NULL
89 && captive_ucs2_compare(QueryTable[0].Name,QueryTable_CSDVersion_Name_ucs2)
90 && QueryTable[0].Flags==RTL_QUERY_REGISTRY_DIRECT
91 && QueryTable[0].EntryContext!=NULL
92 && QueryTable[1].Name==NULL) {
94 (UNICODE_STRING *)QueryTable->EntryContext, /* DestinationString */
95 captive_utf8_to_UnicodeString_alloca("Service Pack 1")); /* SourceString */
96 return STATUS_SUCCESS;
99 return STATUS_OBJECT_NAME_NOT_FOUND;