Commit 2f93be4b authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

advapi32/tests: Add another key unloading test with NtUnloadKey.

parent 70c77cdf
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <assert.h> #include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "wine/test.h" #include "wine/test.h"
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
...@@ -48,8 +50,10 @@ static LONG (WINAPI *pRegDeleteTreeA)(HKEY,const char *); ...@@ -48,8 +50,10 @@ static LONG (WINAPI *pRegDeleteTreeA)(HKEY,const char *);
static DWORD (WINAPI *pRegDeleteKeyExA)(HKEY,LPCSTR,REGSAM,DWORD); static DWORD (WINAPI *pRegDeleteKeyExA)(HKEY,LPCSTR,REGSAM,DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL); static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL);
static NTSTATUS (WINAPI * pNtDeleteKey)(HANDLE); static NTSTATUS (WINAPI * pNtDeleteKey)(HANDLE);
static NTSTATUS (WINAPI * pNtUnloadKey)(POBJECT_ATTRIBUTES);
static NTSTATUS (WINAPI * pRtlFormatCurrentUserKeyPath)(UNICODE_STRING*); static NTSTATUS (WINAPI * pRtlFormatCurrentUserKeyPath)(UNICODE_STRING*);
static NTSTATUS (WINAPI * pRtlFreeUnicodeString)(PUNICODE_STRING); static NTSTATUS (WINAPI * pRtlFreeUnicodeString)(PUNICODE_STRING);
static NTSTATUS (WINAPI * pRtlInitUnicodeString)(PUNICODE_STRING,PCWSTR);
static LONG (WINAPI *pRegDeleteKeyValueA)(HKEY,LPCSTR,LPCSTR); static LONG (WINAPI *pRegDeleteKeyValueA)(HKEY,LPCSTR,LPCSTR);
static LONG (WINAPI *pRegSetKeyValueW)(HKEY,LPCWSTR,LPCWSTR,DWORD,const void*,DWORD); static LONG (WINAPI *pRegSetKeyValueW)(HKEY,LPCWSTR,LPCWSTR,DWORD,const void*,DWORD);
static LONG (WINAPI *pRegLoadMUIStringA)(HKEY,LPCSTR,LPSTR,DWORD,LPDWORD,DWORD,LPCSTR); static LONG (WINAPI *pRegLoadMUIStringA)(HKEY,LPCSTR,LPSTR,DWORD,LPDWORD,DWORD,LPCSTR);
...@@ -90,7 +94,9 @@ static void InitFunctionPtrs(void) ...@@ -90,7 +94,9 @@ static void InitFunctionPtrs(void)
pIsWow64Process = (void *)GetProcAddress( hkernel32, "IsWow64Process" ); pIsWow64Process = (void *)GetProcAddress( hkernel32, "IsWow64Process" );
pRtlFormatCurrentUserKeyPath = (void *)GetProcAddress( hntdll, "RtlFormatCurrentUserKeyPath" ); pRtlFormatCurrentUserKeyPath = (void *)GetProcAddress( hntdll, "RtlFormatCurrentUserKeyPath" );
pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString"); pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
pNtDeleteKey = (void *)GetProcAddress( hntdll, "NtDeleteKey" ); pNtDeleteKey = (void *)GetProcAddress( hntdll, "NtDeleteKey" );
pNtUnloadKey = (void *)GetProcAddress( hntdll, "NtUnloadKey" );
} }
/* delete key and all its subkeys */ /* delete key and all its subkeys */
...@@ -1561,7 +1567,11 @@ static void test_reg_load_key(void) ...@@ -1561,7 +1567,11 @@ static void test_reg_load_key(void)
static void test_reg_unload_key(void) static void test_reg_unload_key(void)
{ {
UNICODE_STRING key_name;
OBJECT_ATTRIBUTES attr;
NTSTATUS status;
DWORD ret; DWORD ret;
HKEY key;
if (!set_privileges(SE_RESTORE_NAME, TRUE) || if (!set_privileges(SE_RESTORE_NAME, TRUE) ||
!set_privileges(SE_BACKUP_NAME, FALSE)) !set_privileges(SE_BACKUP_NAME, FALSE))
...@@ -1570,6 +1580,17 @@ static void test_reg_unload_key(void) ...@@ -1570,6 +1580,17 @@ static void test_reg_unload_key(void)
return; return;
} }
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Test", 0, KEY_READ, &key);
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
/* try to unload though the key handle is live */
pRtlInitUnicodeString(&key_name, L"\\REGISTRY\\Machine\\Test");
InitializeObjectAttributes(&attr, &key_name, OBJ_CASE_INSENSITIVE, NULL, NULL);
status = pNtUnloadKey(&attr);
ok(status == STATUS_CANNOT_DELETE, "expected STATUS_CANNOT_DELETE, got %08x\n", status);
RegCloseKey(key);
ret = RegUnLoadKeyA(HKEY_LOCAL_MACHINE, "Test"); ret = RegUnLoadKeyA(HKEY_LOCAL_MACHINE, "Test");
ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret); ok(ret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", ret);
......
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