update for ReactOS HEAD-2003091401
[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
26
27 /**
28  * RtlQueryRegistryValues:
29  * @RelativeTo: Basedir type constant of relative @Path; ignored by libcaptive.
30  * @Path: String path or handle to retrieve; ignored by libcaptive.
31  * @QueryTable: Table of entries to retrieve; ignored by libcaptive.
32  * %NULL value is forbidden.
33  * @Context: Userdata to pass to QueryRoutine() (of @QueryTable); ignored by libcaptive.
34  * @Environment: Environment variable to use for key expansion; optional; ignored by libcaptive.
35  *
36  * Retrieves specified key from the system registry database.
37  * libcaptive currently always returns %STATUS_OBJECT_NAME_NOT_FOUND
38  * except #ULONG value 1 for the key "\captive\filesystem\Parameters\WritingSupport"
39  * (for ext2fsd.sys V0.10A).
40  *
41  * Returns: %STATUS_OBJECT_NAME_NOT_FOUND or %STATUS_SUCCESS if some result returned.
42  */
43 NTSTATUS RtlQueryRegistryValues
44                 (IN ULONG RelativeTo,IN PCWSTR Path,IN PRTL_QUERY_REGISTRY_TABLE QueryTable,IN PVOID Context,IN PVOID Environment) 
45 {
46 const WCHAR *Path__captive_filesystem_Parameters_ucs2=
47                 captive_utf8_to_UnicodeString_alloca("\\captive\\filesystem\\Parameters")->Buffer;
48 const WCHAR *QueryTable_WritingSupport_Name_ucs2=
49                 captive_utf8_to_UnicodeString_alloca("WritingSupport")->Buffer;
50
51         g_return_val_if_fail(Path!=NULL,STATUS_INVALID_PARAMETER);
52         g_return_val_if_fail(QueryTable!=NULL,STATUS_INVALID_PARAMETER);
53         
54         if (RelativeTo==RTL_REGISTRY_ABSOLUTE
55                         && captive_ucs2_compare(Path,Path__captive_filesystem_Parameters_ucs2)
56                         && QueryTable[0].Name!=NULL
57                                         && captive_ucs2_compare(QueryTable[0].Name,QueryTable_WritingSupport_Name_ucs2)
58                         && QueryTable[0].Flags==(RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED)
59                         && QueryTable[0].EntryContext!=NULL
60                         && QueryTable[1].Name==NULL) {
61                 *(ULONG *)QueryTable[0].EntryContext=1; /* => 'EXT2_SUPPORT_WRITING' */
62                 return STATUS_SUCCESS;
63                 }
64
65         return STATUS_OBJECT_NAME_NOT_FOUND;
66 }