Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8516d196
Commit
8516d196
authored
Apr 19, 2005
by
James Hawkins
Committed by
Alexandre Julliard
Apr 19, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set the backup/restore privilege.
parent
e41bd72a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
5 deletions
+46
-5
registry.c
dlls/advapi32/tests/registry.c
+46
-5
No files found.
dlls/advapi32/tests/registry.c
View file @
8516d196
...
...
@@ -362,7 +362,6 @@ static void test_reg_save_key()
DWORD
ret
;
ret
=
RegSaveKey
(
hkey_main
,
"saved_key"
,
NULL
);
if
(
ERROR_PRIVILEGE_NOT_HELD
==
ret
)
return
;
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
}
...
...
@@ -372,7 +371,6 @@ static void test_reg_load_key()
HKEY
hkHandle
;
ret
=
RegLoadKey
(
HKEY_LOCAL_MACHINE
,
"Test"
,
"saved_key"
);
if
(
ERROR_PRIVILEGE_NOT_HELD
==
ret
)
return
;
ok
(
ret
==
ERROR_SUCCESS
,
"expected ERROR_SUCCESS, got %ld
\n
"
,
ret
);
ret
=
RegOpenKey
(
HKEY_LOCAL_MACHINE
,
"Test"
,
&
hkHandle
);
...
...
@@ -391,6 +389,40 @@ static void test_reg_unload_key()
DeleteFile
(
"saved_key"
);
}
static
BOOL
set_privileges
(
LPCSTR
privilege
,
BOOL
set
)
{
TOKEN_PRIVILEGES
tp
;
HANDLE
hToken
;
LUID
luid
;
if
(
!
OpenProcessToken
(
GetCurrentProcess
(),
TOKEN_ADJUST_PRIVILEGES
,
&
hToken
))
return
FALSE
;
if
(
!
LookupPrivilegeValue
(
NULL
,
privilege
,
&
luid
))
{
CloseHandle
(
hToken
);
return
FALSE
;
}
tp
.
PrivilegeCount
=
1
;
tp
.
Privileges
[
0
].
Luid
=
luid
;
if
(
set
)
tp
.
Privileges
[
0
].
Attributes
=
SE_PRIVILEGE_ENABLED
;
else
tp
.
Privileges
[
0
].
Attributes
=
0
;
AdjustTokenPrivileges
(
hToken
,
FALSE
,
&
tp
,
sizeof
(
TOKEN_PRIVILEGES
),
NULL
,
NULL
);
if
(
GetLastError
()
!=
ERROR_SUCCESS
)
{
CloseHandle
(
hToken
);
return
FALSE
;
}
CloseHandle
(
hToken
);
return
TRUE
;
}
START_TEST
(
registry
)
{
setup_main_key
();
...
...
@@ -400,9 +432,18 @@ START_TEST(registry)
test_reg_open_key
();
test_reg_close_key
();
test_reg_delete_key
();
test_reg_save_key
();
test_reg_load_key
();
test_reg_unload_key
();
/* SaveKey/LoadKey require the SE_BACKUP_NAME privilege to be set */
if
(
set_privileges
(
SE_BACKUP_NAME
,
TRUE
)
&&
set_privileges
(
SE_RESTORE_NAME
,
TRUE
))
{
test_reg_save_key
();
test_reg_load_key
();
test_reg_unload_key
();
set_privileges
(
SE_BACKUP_NAME
,
FALSE
);
set_privileges
(
SE_RESTORE_NAME
,
FALSE
);
}
/* cleanup */
delete_key
(
hkey_main
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment