RtlQueryRegistryValues(): Debug dump parameters.
[captive.git] / src / libcaptive / cm / rtlfunc.c
1 /* $Id$
2  * reactos registry handling functions emulation of libcaptive
3  * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
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; exactly version 2 of June 1991 is required
8  * 
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.
13  * 
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
17  */
18
19
20 #include "config.h"
21
22 #include "reactos/ddk/kefuncs.h"        /* self */
23 #include <glib/gmessages.h>
24 #include "captive/unicode.h"
25 #include "captive/macros.h"
26
27
28 /**
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.
36  *
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).
41  *
42  * Returns: %STATUS_OBJECT_NAME_NOT_FOUND or %STATUS_SUCCESS if some result returned.
43  */
44 NTSTATUS RtlQueryRegistryValues
45                 (IN ULONG RelativeTo,IN PCWSTR Path,IN PRTL_QUERY_REGISTRY_TABLE QueryTable,IN PVOID Context,IN PVOID Environment) 
46 {
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 gchar *RelativeTo_table[]={
52                 "RTL_REGISTRY_ABSOLUTE",
53                 "RTL_REGISTRY_SERVICES",
54                 "RTL_REGISTRY_CONTROL",
55                 "RTL_REGISTRY_WINDOWS_NT",
56                 "RTL_REGISTRY_DEVICEMAP",
57                 "RTL_REGISTRY_USER",
58                 "RTL_REGISTRY_ENUM",
59                 };
60 UNICODE_STRING Path_UnicodeString;
61
62         g_return_val_if_fail(Path!=NULL,STATUS_INVALID_PARAMETER);
63         g_return_val_if_fail(QueryTable!=NULL,STATUS_INVALID_PARAMETER);
64
65         Path_UnicodeString.Length=captive_ucs2_strlen(Path)*sizeof(*Path_UnicodeString.Buffer);
66         Path_UnicodeString.MaximumLength=Path_UnicodeString.Length+sizeof(*Path_UnicodeString.Buffer);
67         Path_UnicodeString.Buffer=(/* de-const */ PWSTR)Path;
68         g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: RelativeTo=%s,Path=%s",G_STRLOC,
69                         (RelativeTo>=0 && RelativeTo<G_N_ELEMENTS(RelativeTo_table)
70                                         ? RelativeTo_table[RelativeTo] : captive_printf_alloca("%lu",(unsigned long)RelativeTo)),
71                                         captive_UnicodeString_to_utf8_alloca(&Path_UnicodeString));
72
73         if (RelativeTo==RTL_REGISTRY_ABSOLUTE
74                         && captive_ucs2_compare(Path,Path__captive_filesystem_Parameters_ucs2)
75                         && QueryTable[0].Name!=NULL
76                                         && captive_ucs2_compare(QueryTable[0].Name,QueryTable_WritingSupport_Name_ucs2)
77                         && QueryTable[0].Flags==(RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED)
78                         && QueryTable[0].EntryContext!=NULL
79                         && QueryTable[1].Name==NULL) {
80                 *(ULONG *)QueryTable[0].EntryContext=1; /* => 'EXT2_SUPPORT_WRITING' */
81                 return STATUS_SUCCESS;
82                 }
83
84         return STATUS_OBJECT_NAME_NOT_FOUND;
85 }