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
3103adb6
Commit
3103adb6
authored
Feb 20, 2024
by
Zebediah Figura
Committed by
Alexandre Julliard
Mar 08, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winetest: Elevate test processes on Wine.
parent
4860be47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
2 deletions
+26
-2
main.c
programs/winetest/main.c
+26
-2
No files found.
programs/winetest/main.c
View file @
3103adb6
...
@@ -687,6 +687,21 @@ extract_test (struct wine_test *test, const char *dir, LPSTR res_name)
...
@@ -687,6 +687,21 @@ extract_test (struct wine_test *test, const char *dir, LPSTR res_name)
CloseHandle
(
hfile
);
CloseHandle
(
hfile
);
}
}
static
HANDLE
get_admin_token
(
void
)
{
TOKEN_ELEVATION_TYPE
type
;
TOKEN_LINKED_TOKEN
linked
;
DWORD
size
;
if
(
!
GetTokenInformation
(
GetCurrentThreadEffectiveToken
(),
TokenElevationType
,
&
type
,
sizeof
(
type
),
&
size
)
||
type
==
TokenElevationTypeFull
)
return
NULL
;
if
(
!
GetTokenInformation
(
GetCurrentThreadEffectiveToken
(),
TokenLinkedToken
,
&
linked
,
sizeof
(
linked
),
&
size
))
return
NULL
;
return
linked
.
LinkedToken
;
}
static
DWORD
wait_process
(
HANDLE
process
,
DWORD
timeout
)
static
DWORD
wait_process
(
HANDLE
process
,
DWORD
timeout
)
{
{
DWORD
wait
,
diff
=
0
,
start
=
GetTickCount
();
DWORD
wait
,
diff
=
0
,
start
=
GetTickCount
();
...
@@ -722,6 +737,7 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic
...
@@ -722,6 +737,7 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic
PROCESS_INFORMATION
pi
;
PROCESS_INFORMATION
pi
;
DWORD
wait
,
status
,
flags
;
DWORD
wait
,
status
,
flags
;
UINT
old_errmode
;
UINT
old_errmode
;
HANDLE
token
=
NULL
;
GetStartupInfoA
(
&
si
);
GetStartupInfoA
(
&
si
);
si
.
dwFlags
=
STARTF_USESTDHANDLES
;
si
.
dwFlags
=
STARTF_USESTDHANDLES
;
...
@@ -737,8 +753,16 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic
...
@@ -737,8 +753,16 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, BOOL nocritic
else
else
flags
=
CREATE_DEFAULT_ERROR_MODE
;
flags
=
CREATE_DEFAULT_ERROR_MODE
;
if
(
!
CreateProcessA
(
NULL
,
cmd
,
NULL
,
NULL
,
TRUE
,
flags
,
/* Some tests cause a UAC prompt on Windows if the user is not elevated,
NULL
,
tempdir
,
&
si
,
&
pi
))
* so to allow them to run unattended the relevant test units need to skip
* the tests if so.
*
* However, we still want Wine to run as many tests as possible, so always
* elevate ourselves. On Wine elevation isn't interactive. */
if
(
running_under_wine
())
token
=
get_admin_token
();
if
(
!
CreateProcessAsUserA
(
token
,
NULL
,
cmd
,
NULL
,
NULL
,
TRUE
,
flags
,
NULL
,
tempdir
,
&
si
,
&
pi
))
{
{
if
(
nocritical
)
SetErrorMode
(
old_errmode
);
if
(
nocritical
)
SetErrorMode
(
old_errmode
);
if
(
pid
)
*
pid
=
0
;
if
(
pid
)
*
pid
=
0
;
...
...
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