Commit 580ded65 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

- Implement NtLoadKey.

- Forward RegLoadKey to NtLoadKey.
parent 6de70abd
...@@ -1588,42 +1588,28 @@ DWORD WINAPI RegDeleteValueA( HKEY hkey, LPCSTR name ) ...@@ -1588,42 +1588,28 @@ DWORD WINAPI RegDeleteValueA( HKEY hkey, LPCSTR name )
*/ */
LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename ) LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
{ {
HANDLE file; OBJECT_ATTRIBUTES destkey, file;
DWORD ret, len, err = GetLastError(); UNICODE_STRING subkeyW, filenameW;
HKEY shkey;
if (!(hkey = get_special_root_hkey(hkey))) return ERROR_INVALID_HANDLE;
TRACE( "(%p,%s,%s)\n", hkey, debugstr_w(subkey), debugstr_w(filename) );
destkey.Length = sizeof(destkey);
if (!filename || !*filename) return ERROR_INVALID_PARAMETER; destkey.RootDirectory = hkey; /* root key: HKLM or HKU */
if (!subkey || !*subkey) return ERROR_INVALID_PARAMETER; destkey.ObjectName = &subkeyW; /* name of the key */
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE; destkey.Attributes = 0;
destkey.SecurityDescriptor = NULL;
len = strlenW( subkey ) * sizeof(WCHAR); destkey.SecurityQualityOfService = NULL;
if (len > MAX_PATH*sizeof(WCHAR)) return ERROR_INVALID_PARAMETER; RtlInitUnicodeString(&subkeyW, subkey);
if ((file = CreateFileW( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, file.Length = sizeof(file);
FILE_ATTRIBUTE_NORMAL, 0 )) == INVALID_HANDLE_VALUE) file.RootDirectory = NULL;
{ file.ObjectName = &filenameW; /* file containing the hive */
ret = GetLastError(); file.Attributes = OBJ_CASE_INSENSITIVE;
goto done; file.SecurityDescriptor = NULL;
} file.SecurityQualityOfService = NULL;
RtlDosPathNameToNtPathName_U(filename, &filenameW, NULL, NULL);
RegCreateKeyW(hkey,subkey,&shkey);
return RtlNtStatusToDosError( NtLoadKey(&destkey, &file) );
SERVER_START_REQ( load_registry )
{
req->hkey = shkey;
req->file = file;
wine_server_add_data( req, subkey, len );
ret = RtlNtStatusToDosError( wine_server_call(req) );
}
SERVER_END_REQ;
CloseHandle( file );
RegCloseKey(shkey);
done:
SetLastError( err ); /* restore the last error code */
return ret;
} }
...@@ -1634,43 +1620,20 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename ) ...@@ -1634,43 +1620,20 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
*/ */
LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename ) LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
{ {
WCHAR buffer[MAX_PATH]; UNICODE_STRING subkeyW, filenameW;
HANDLE file; STRING subkeyA, filenameA;
DWORD ret, len, err = GetLastError(); NTSTATUS status;
HKEY shkey;
TRACE( "(%p,%s,%s)\n", hkey, debugstr_a(subkey), debugstr_a(filename) );
if (!filename || !*filename) return ERROR_INVALID_PARAMETER;
if (!subkey || !*subkey) return ERROR_INVALID_PARAMETER;
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
if (!(len = MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey), buffer, MAX_PATH )))
return ERROR_INVALID_PARAMETER;
if ((file = CreateFileA( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, RtlInitAnsiString(&subkeyA, subkey);
FILE_ATTRIBUTE_NORMAL, 0 )) == INVALID_HANDLE_VALUE) RtlInitAnsiString(&filenameA, filename);
{
ret = GetLastError();
goto done;
}
RegCreateKeyA(hkey,subkey,&shkey); if ((status = RtlAnsiStringToUnicodeString(&subkeyW, &subkeyA, TRUE)))
return RtlNtStatusToDosError(status);
SERVER_START_REQ( load_registry ) if ((status = RtlAnsiStringToUnicodeString(&filenameW, &filenameA, TRUE)))
{ return RtlNtStatusToDosError(status);
req->hkey = shkey;
req->file = file;
wine_server_add_data( req, buffer, len * sizeof(WCHAR) );
ret = RtlNtStatusToDosError( wine_server_call(req) );
}
SERVER_END_REQ;
CloseHandle( file );
RegCloseKey(shkey);
done: return RegLoadKeyW(hkey, subkeyW.Buffer, filenameW.Buffer);
SetLastError( err ); /* restore the last error code */
return ret;
} }
......
...@@ -558,12 +558,30 @@ NTSTATUS WINAPI NtFlushKey(HKEY key) ...@@ -558,12 +558,30 @@ NTSTATUS WINAPI NtFlushKey(HKEY key)
* NtLoadKey [NTDLL.@] * NtLoadKey [NTDLL.@]
* ZwLoadKey [NTDLL.@] * ZwLoadKey [NTDLL.@]
*/ */
NTSTATUS WINAPI NtLoadKey( const OBJECT_ATTRIBUTES *attr, const OBJECT_ATTRIBUTES *file ) NTSTATUS WINAPI NtLoadKey( const OBJECT_ATTRIBUTES *attr, OBJECT_ATTRIBUTES *file )
{ {
FIXME("stub!\n"); NTSTATUS ret;
dump_ObjectAttributes(attr); HANDLE hive;
dump_ObjectAttributes(file); IO_STATUS_BLOCK io;
return STATUS_SUCCESS;
TRACE("(%p,%p)\n", attr, file);
ret = NtCreateFile(&hive, GENERIC_READ, file, &io, NULL, FILE_ATTRIBUTE_NORMAL, 0,
OPEN_EXISTING, 0, NULL, 0);
if (ret) return ret;
SERVER_START_REQ( load_registry )
{
req->hkey = attr->RootDirectory;
req->file = hive;
wine_server_add_data(req, attr->ObjectName->Buffer, attr->ObjectName->Length);
ret = wine_server_call( req );
}
SERVER_END_REQ;
NtClose(hive);
return ret;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -1449,7 +1449,7 @@ NTSTATUS WINAPI NtImpersonateAnonymousToken(HANDLE); ...@@ -1449,7 +1449,7 @@ NTSTATUS WINAPI NtImpersonateAnonymousToken(HANDLE);
NTSTATUS WINAPI NtImpersonateClientOfPort(HANDLE,PPORT_MESSAGE); NTSTATUS WINAPI NtImpersonateClientOfPort(HANDLE,PPORT_MESSAGE);
NTSTATUS WINAPI NtImpersonateThread(HANDLE,HANDLE,PSECURITY_QUALITY_OF_SERVICE); NTSTATUS WINAPI NtImpersonateThread(HANDLE,HANDLE,PSECURITY_QUALITY_OF_SERVICE);
NTSTATUS WINAPI NtLoadDriver(const UNICODE_STRING *); NTSTATUS WINAPI NtLoadDriver(const UNICODE_STRING *);
NTSTATUS WINAPI NtLoadKey(const OBJECT_ATTRIBUTES *,const OBJECT_ATTRIBUTES *); NTSTATUS WINAPI NtLoadKey(const OBJECT_ATTRIBUTES *,OBJECT_ATTRIBUTES *);
NTSTATUS WINAPI NtLockFile(HANDLE,HANDLE,PIO_APC_ROUTINE,void*,PIO_STATUS_BLOCK,PLARGE_INTEGER,PLARGE_INTEGER,ULONG*,BOOLEAN,BOOLEAN); NTSTATUS WINAPI NtLockFile(HANDLE,HANDLE,PIO_APC_ROUTINE,void*,PIO_STATUS_BLOCK,PLARGE_INTEGER,PLARGE_INTEGER,ULONG*,BOOLEAN,BOOLEAN);
NTSTATUS WINAPI NtLockVirtualMemory(HANDLE,PVOID*,ULONG*,ULONG); NTSTATUS WINAPI NtLockVirtualMemory(HANDLE,PVOID*,ULONG*,ULONG);
NTSTATUS WINAPI NtMapViewOfSection(HANDLE,HANDLE,PVOID*,ULONG,ULONG,const LARGE_INTEGER*,ULONG*,SECTION_INHERIT,ULONG,ULONG); NTSTATUS WINAPI NtMapViewOfSection(HANDLE,HANDLE,PVOID*,ULONG,ULONG,const LARGE_INTEGER*,ULONG*,SECTION_INHERIT,ULONG,ULONG);
......
...@@ -1834,13 +1834,18 @@ DECL_HANDLER(delete_key_value) ...@@ -1834,13 +1834,18 @@ DECL_HANDLER(delete_key_value)
/* load a registry branch from a file */ /* load a registry branch from a file */
DECL_HANDLER(load_registry) DECL_HANDLER(load_registry)
{ {
struct key *key; struct key *key, *parent;
if ((key = get_hkey_obj( req->hkey, KEY_SET_VALUE | KEY_CREATE_SUB_KEY ))) if ((parent = get_hkey_obj( req->hkey, KEY_SET_VALUE | KEY_CREATE_SUB_KEY )))
{ {
/* FIXME: use subkey name */ int dummy;
load_registry( key, req->file ); WCHAR *name = copy_path( get_req_data(), get_req_data_size(), !req->hkey );
release_object( key ); if (name && (key = create_key( parent, name, NULL, KEY_DIRTY, time(NULL), &dummy )))
{
load_registry( key, req->file );
release_object( key );
}
release_object( parent );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment