* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS hive maker
/*
* TODO:
- * - Implement RegDeleteKey()
+ * - Implement RegDeleteKeyW()
* - Implement RegEnumValue()
- * - Implement RegQueryValueExA()
+ * - Implement RegQueryValueExW()
*/
#include <stdlib.h>
#define REG_DATA_SIZE_MASK 0x7FFFFFFF
#define REG_DATA_IN_OFFSET 0x80000000
-static EREGISTRY_HIVE RootHive;
+static CMHIVE RootHive;
static MEMKEY RootKey;
-EREGISTRY_HIVE DefaultHive; /* \Registry\User\.DEFAULT */
-EREGISTRY_HIVE SamHive; /* \Registry\Machine\SAM */
-EREGISTRY_HIVE SecurityHive; /* \Registry\Machine\SECURITY */
-EREGISTRY_HIVE SoftwareHive; /* \Registry\Machine\SOFTWARE */
-EREGISTRY_HIVE SystemHive; /* \Registry\Machine\SYSTEM */
+CMHIVE DefaultHive; /* \Registry\User\.DEFAULT */
+CMHIVE SamHive; /* \Registry\Machine\SAM */
+CMHIVE SecurityHive; /* \Registry\Machine\SECURITY */
+CMHIVE SoftwareHive; /* \Registry\Machine\SOFTWARE */
+CMHIVE SystemHive; /* \Registry\Machine\SYSTEM */
static MEMKEY
CreateInMemoryStructure(
- IN PEREGISTRY_HIVE RegistryHive,
+ IN PCMHIVE RegistryHive,
IN HCELL_INDEX KeyCellOffset,
IN PCUNICODE_STRING KeyName)
{
Key->ValueCount = 0;
Key->NameSize = KeyName->Length;
+ /* FIXME: It's not enough to allocate this way, because later
+ this memory gets overwritten with bigger names */
Key->Name = malloc (Key->NameSize);
if (!Key->Name)
return NULL;
LocalKeyName = (PWSTR)KeyName;
for (;;)
{
- End = (PWSTR) xwcschr(LocalKeyName, '\\');
+ End = (PWSTR) utf16_wcschr(LocalKeyName, '\\');
if (End)
{
KeyString.Buffer = LocalKeyName;
RtlInitUnicodeString(&KeyString, LocalKeyName);
/* Redirect from 'CurrentControlSet' to 'ControlSet001' */
- if (!memcmp(LocalKeyName, L"CurrentControlSet", 34) &&
- ParentKey->NameSize == 12 &&
- !memcmp(ParentKey->Name, L"SYSTEM", 12))
+ if (!utf16_wcsncmp(LocalKeyName, L"CurrentControlSet", 17) &&
+ ParentKey->NameSize == 12 &&
+ !memcmp(ParentKey->Name, L"SYSTEM", 12))
RtlInitUnicodeString(&KeyString, L"ControlSet001");
/* Check subkey in memory structure */
}
LONG WINAPI
-RegDeleteKeyA(HKEY Key,
- LPCSTR Name)
+RegDeleteKeyW(
+ IN HKEY hKey,
+ IN LPCWSTR lpSubKey)
+{
+ DPRINT1("FIXME!\n");
+ return ERROR_SUCCESS;
+}
+
+LONG WINAPI
+RegDeleteKeyA(
+ IN HKEY hKey,
+ IN LPCSTR lpSubKey)
{
- if (Name != NULL && strchr(Name, '\\') != NULL)
- return(ERROR_INVALID_PARAMETER);
+ PWSTR lpSubKeyW = NULL;
+ LONG rc;
+
+ if (lpSubKey != NULL && strchr(lpSubKey, '\\') != NULL)
+ return ERROR_INVALID_PARAMETER;
+
+ if (lpSubKey)
+ {
+ lpSubKeyW = MultiByteToWideChar(lpSubKey);
+ if (!lpSubKeyW)
+ return ERROR_OUTOFMEMORY;
+ }
- DPRINT1("FIXME!\n");
+ rc = RegDeleteKeyW(hKey, lpSubKeyW);
- return(ERROR_SUCCESS);
+ if (lpSubKey)
+ free(lpSubKeyW);
+
+ return rc;
}
LONG WINAPI
if (cbData <= sizeof(HCELL_INDEX))
{
/* If data size <= sizeof(HCELL_INDEX) then store data in the data offset */
- DPRINT("ValueCell->DataLength %lu\n", ValueCell->DataLength);
+ DPRINT("ValueCell->DataLength %u\n", ValueCell->DataLength);
if (DataCell)
HvFreeCell(&Key->RegistryHive->Hive, ValueCell->Data);
* data block and allocate a new one. */
HCELL_INDEX NewOffset;
- DPRINT("ValueCell->DataLength %lu\n", ValueCell->DataLength);
+ DPRINT("ValueCell->DataLength %u\n", ValueCell->DataLength);
NewOffset = HvAllocateCell(&Key->RegistryHive->Hive, cbData, Stable, HCELL_NIL);
if (NewOffset == HCELL_NIL)
{
- DPRINT("HvAllocateCell() failed with status 0x%08lx\n", Status);
+ DPRINT("HvAllocateCell() failed with status 0x%08x\n", Status);
return ERROR_UNSUCCESSFUL;
}
HvMarkCellDirty(&Key->RegistryHive->Hive, Key->KeyCellOffset, FALSE);
- DPRINT("Return status 0x%08lx\n", Status);
+ DPRINT("Return status 0x%08x\n", Status);
return Status;
}
static BOOL
ConnectRegistry(
IN HKEY RootKey,
- IN PEREGISTRY_HIVE HiveToConnect,
+ IN PCMHIVE HiveToConnect,
IN LPCWSTR Path)
{
NTSTATUS Status;
Status = CmiInitializeTempHive(HiveToConnect);
if (!NT_SUCCESS(Status))
{
- DPRINT1("CmiInitializeTempHive() failed with status 0x%08lx\n", Status);
+ DPRINT1("CmiInitializeTempHive() failed with status 0x%08x\n", Status);
return FALSE;
}
return TRUE;
}
-static BOOL
-MyExportBinaryHive (PCHAR FileName,
- PEREGISTRY_HIVE RootHive)
-{
- FILE *File;
- BOOL ret;
-
- /* Create new hive file */
- File = fopen (FileName, "w+b");
- if (File == NULL)
- {
- printf(" Error creating/opening file\n");
- return FALSE;
- }
-
- fseek (File, 0, SEEK_SET);
-
- RootHive->HiveHandle = (HANDLE)File;
- ret = HvWriteHive(&RootHive->Hive);
- fclose (File);
- return ret;
-}
-
LIST_ENTRY CmiHiveListHead;
VOID
Status = CmiInitializeTempHive(&RootHive);
if (!NT_SUCCESS(Status))
{
- DPRINT1("CmiInitializeTempHive() failed with status 0x%08lx\n", Status);
+ DPRINT1("CmiInitializeTempHive() failed with status 0x%08x\n", Status);
return;
}