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
6113c468
Commit
6113c468
authored
Oct 01, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Use RtlGetSearchPath() in SearchPathW() implementation.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5f938bb5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
87 deletions
+6
-87
path.c
dlls/kernel32/path.c
+6
-87
No files found.
dlls/kernel32/path.c
View file @
6113c468
...
...
@@ -43,8 +43,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(file);
#define MAX_PATHNAME_LEN 1024
static
int
path_safe_mode
=
-
1
;
/* path mode set by SetSearchPathMode */
/* check if a file name is for an executable file (.exe or .com) */
static
inline
BOOL
is_executable
(
const
WCHAR
*
name
)
{
...
...
@@ -257,51 +255,6 @@ DWORD WINAPI GetShortPathNameA( LPCSTR longpath, LPSTR shortpath, DWORD shortlen
}
/***********************************************************************
* get_path_safe_mode
*/
static
BOOL
get_path_safe_mode
(
void
)
{
static
const
WCHAR
keyW
[]
=
{
'\\'
,
'R'
,
'e'
,
'g'
,
'i'
,
's'
,
't'
,
'r'
,
'y'
,
'\\'
,
'M'
,
'a'
,
'c'
,
'h'
,
'i'
,
'n'
,
'e'
,
'\\'
,
'S'
,
'y'
,
's'
,
't'
,
'e'
,
'm'
,
'\\'
,
'C'
,
'u'
,
'r'
,
'r'
,
'e'
,
'n'
,
't'
,
'C'
,
'o'
,
'n'
,
't'
,
'r'
,
'o'
,
'l'
,
'S'
,
'e'
,
't'
,
'\\'
,
'C'
,
'o'
,
'n'
,
't'
,
'r'
,
'o'
,
'l'
,
'\\'
,
'S'
,
'e'
,
's'
,
's'
,
'i'
,
'o'
,
'n'
,
' '
,
'M'
,
'a'
,
'n'
,
'a'
,
'g'
,
'e'
,
'r'
,
0
};
static
const
WCHAR
valueW
[]
=
{
'S'
,
'a'
,
'f'
,
'e'
,
'P'
,
'r'
,
'o'
,
'c'
,
'e'
,
's'
,
's'
,
'S'
,
'e'
,
'a'
,
'r'
,
'c'
,
'h'
,
'M'
,
'o'
,
'd'
,
'e'
,
0
};
if
(
path_safe_mode
==
-
1
)
{
char
buffer
[
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
[
sizeof
(
DWORD
)])];
KEY_VALUE_PARTIAL_INFORMATION
*
info
=
(
KEY_VALUE_PARTIAL_INFORMATION
*
)
buffer
;
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
HANDLE
hkey
;
DWORD
size
=
sizeof
(
buffer
);
BOOL
mode
=
FALSE
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
ObjectName
=
&
nameW
;
attr
.
Attributes
=
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
RtlInitUnicodeString
(
&
nameW
,
keyW
);
if
(
!
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
))
{
RtlInitUnicodeString
(
&
nameW
,
valueW
);
if
(
!
NtQueryValueKey
(
hkey
,
&
nameW
,
KeyValuePartialInformation
,
buffer
,
size
,
&
size
)
&&
info
->
Type
==
REG_DWORD
&&
info
->
DataLength
==
sizeof
(
DWORD
))
mode
=
!!*
(
DWORD
*
)
info
->
Data
;
NtClose
(
hkey
);
}
InterlockedCompareExchange
(
&
path_safe_mode
,
mode
,
-
1
);
}
return
path_safe_mode
!=
0
;
}
/***********************************************************************
* contains_pathW
*
* Check if the file name contains a path; helper for SearchPathW.
...
...
@@ -536,23 +489,14 @@ DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen,
ret
=
req_len
+
1
;
HeapFree
(
GetProcessHeap
(),
0
,
dll_path
);
HeapFree
(
GetProcessHeap
(),
0
,
search
);
}
else
else
if
(
!
RtlGetSearchPath
(
&
dll_path
))
{
if
((
dll_path
=
MODULE_get_dll_load_path
(
NULL
,
get_path_safe_mode
()
)))
{
ret
=
RtlDosSearchPath_U
(
dll_path
,
name
,
NULL
,
buflen
*
sizeof
(
WCHAR
),
buffer
,
lastpart
)
/
sizeof
(
WCHAR
);
HeapFree
(
GetProcessHeap
(),
0
,
dll_path
);
HeapFree
(
GetProcessHeap
(),
0
,
search
);
}
else
{
SetLastError
(
ERROR_OUTOFMEMORY
);
return
0
;
}
ret
=
RtlDosSearchPath_U
(
dll_path
,
name
,
NULL
,
buflen
*
sizeof
(
WCHAR
),
buffer
,
lastpart
)
/
sizeof
(
WCHAR
);
RtlReleasePath
(
dll_path
);
}
HeapFree
(
GetProcessHeap
(),
0
,
search
);
}
if
(
!
ret
)
SetLastError
(
ERROR_FILE_NOT_FOUND
);
...
...
@@ -1393,30 +1337,5 @@ BOOL WINAPI CheckNameLegalDOS8Dot3W(const WCHAR *name, char *oemname, DWORD oemn
*/
BOOL
WINAPI
SetSearchPathMode
(
DWORD
flags
)
{
int
val
;
switch
(
flags
)
{
case
BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
:
val
=
1
;
break
;
case
BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE
:
val
=
0
;
break
;
case
BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
|
BASE_SEARCH_PATH_PERMANENT
:
InterlockedExchange
(
&
path_safe_mode
,
2
);
return
TRUE
;
default:
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
for
(;;)
{
int
prev
=
path_safe_mode
;
if
(
prev
==
2
)
break
;
/* permanently set */
if
(
InterlockedCompareExchange
(
&
path_safe_mode
,
val
,
prev
)
==
prev
)
return
TRUE
;
}
SetLastError
(
ERROR_ACCESS_DENIED
);
return
FALSE
;
return
set_ntstatus
(
RtlSetSearchPathMode
(
flags
));
}
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