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
a5d45e9a
Commit
a5d45e9a
authored
Oct 03, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Move exe path functions to ntdll.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
619bd16e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
5 deletions
+116
-5
process.c
dlls/kernel32/process.c
+14
-5
path.c
dlls/kernel32/tests/path.c
+75
-0
loader.c
dlls/ntdll/loader.c
+25
-0
ntdll.spec
dlls/ntdll/ntdll.spec
+1
-0
winternl.h
include/winternl.h
+1
-0
No files found.
dlls/kernel32/process.c
View file @
a5d45e9a
...
...
@@ -438,11 +438,18 @@ static HANDLE open_exe_file( const WCHAR *name, BOOL *is_64bit )
*/
static
BOOL
find_exe_file
(
const
WCHAR
*
name
,
WCHAR
*
buffer
,
int
buflen
,
HANDLE
*
handle
)
{
TRACE
(
"looking for %s
\n
"
,
debugstr_w
(
name
)
);
WCHAR
*
load_path
;
BOOL
ret
;
if
(
!
set_ntstatus
(
RtlGetExePath
(
name
,
&
load_path
)))
return
FALSE
;
TRACE
(
"looking for %s in %s
\n
"
,
debugstr_w
(
name
),
debugstr_w
(
load_path
)
);
if
(
!
SearchPathW
(
NULL
,
name
,
exeW
,
buflen
,
buffer
,
NULL
)
&&
/* no builtin found, try native without extension in case it is a Unix app */
!
SearchPathW
(
NULL
,
name
,
NULL
,
buflen
,
buffer
,
NULL
))
return
FALSE
;
ret
=
(
SearchPathW
(
load_path
,
name
,
exeW
,
buflen
,
buffer
,
NULL
)
||
/* no builtin found, try native without extension in case it is a Unix app */
SearchPathW
(
load_path
,
name
,
NULL
,
buflen
,
buffer
,
NULL
));
RtlReleasePath
(
load_path
);
if
(
!
ret
)
return
FALSE
;
TRACE
(
"Trying native exe %s
\n
"
,
debugstr_w
(
buffer
)
);
*
handle
=
CreateFileW
(
buffer
,
GENERIC_READ
,
FILE_SHARE_READ
|
FILE_SHARE_DELETE
,
...
...
@@ -1412,12 +1419,14 @@ void * CDECL __wine_kernel_init(void)
{
BOOL
is_64bit
;
if
(
!
SearchPathW
(
NULL
,
__wine_main_wargv
[
0
],
exeW
,
MAX_PATH
,
main_exe_name
,
NULL
)
&&
RtlGetExePath
(
__wine_main_wargv
[
0
],
&
load_path
);
if
(
!
SearchPathW
(
load_path
,
__wine_main_wargv
[
0
],
exeW
,
MAX_PATH
,
main_exe_name
,
NULL
)
&&
!
get_builtin_path
(
__wine_main_wargv
[
0
],
exeW
,
main_exe_name
,
MAX_PATH
,
&
is_64bit
))
{
MESSAGE
(
"wine: cannot find '%s'
\n
"
,
__wine_main_argv
[
0
]
);
ExitProcess
(
GetLastError
()
);
}
RtlReleasePath
(
load_path
);
update_library_argv0
(
main_exe_name
);
if
(
!
build_command_line
(
__wine_main_wargv
))
goto
error
;
start_wineboot
(
boot_events
);
...
...
dlls/kernel32/tests/path.c
View file @
a5d45e9a
...
...
@@ -78,6 +78,7 @@ static BOOL (WINAPI *pRemoveDllDirectory)(DLL_DIRECTORY_COOKIE);
static
BOOL
(
WINAPI
*
pSetSearchPathMode
)(
DWORD
);
static
BOOL
(
WINAPI
*
pSetDllDirectoryW
)(
LPCWSTR
);
static
BOOL
(
WINAPI
*
pSetDefaultDllDirectories
)(
DWORD
);
static
NTSTATUS
(
WINAPI
*
pRtlGetExePath
)(
LPCWSTR
,
LPWSTR
*
);
static
NTSTATUS
(
WINAPI
*
pRtlGetSearchPath
)(
LPWSTR
*
);
static
void
(
WINAPI
*
pRtlReleasePath
)(
LPWSTR
);
static
NTSTATUS
(
WINAPI
*
pLdrGetDllPath
)(
LPCWSTR
,
ULONG
,
LPWSTR
*
,
LPWSTR
*
);
...
...
@@ -2218,6 +2219,7 @@ static void init_pointers(void)
MAKEFUNC
(
CheckNameLegalDOS8Dot3A
);
mod
=
GetModuleHandleA
(
"ntdll.dll"
);
MAKEFUNC
(
LdrGetDllPath
);
MAKEFUNC
(
RtlGetExePath
);
MAKEFUNC
(
RtlGetSearchPath
);
MAKEFUNC
(
RtlReleasePath
);
#undef MAKEFUNC
...
...
@@ -2570,6 +2572,78 @@ static void test_RtlGetSearchPath(void)
SetEnvironmentVariableW
(
pathW
,
old_path
);
}
static
void
test_RtlGetExePath
(
void
)
{
static
const
WCHAR
fooW
[]
=
{
'\\'
,
'f'
,
'o'
,
'o'
,
0
};
static
const
WCHAR
emptyW
[
1
];
NTSTATUS
ret
;
WCHAR
*
path
;
WCHAR
buffer
[
2048
],
old_path
[
2048
],
dlldir
[
4
];
if
(
!
pRtlGetExePath
)
{
win_skip
(
"RtlGetExePath isn't available
\n
"
);
return
;
}
GetEnvironmentVariableW
(
pathW
,
old_path
,
ARRAY_SIZE
(
old_path
)
);
GetWindowsDirectoryW
(
buffer
,
ARRAY_SIZE
(
buffer
)
);
lstrcpynW
(
dlldir
,
buffer
,
ARRAY_SIZE
(
dlldir
)
);
SetEnvironmentVariableA
(
"NoDefaultCurrentDirectoryInExePath"
,
NULL
);
build_search_path
(
buffer
,
ARRAY_SIZE
(
buffer
),
NULL
,
FALSE
);
path
=
(
WCHAR
*
)
0xdeadbeef
;
ret
=
pRtlGetExePath
(
fooW
,
&
path
);
ok
(
!
ret
,
"RtlGetExePath failed %x
\n
"
,
ret
);
ok
(
path_equal
(
path
,
buffer
),
"got %s expected %s
\n
"
,
wine_dbgstr_w
(
path
),
wine_dbgstr_w
(
buffer
));
pRtlReleasePath
(
path
);
build_search_path
(
buffer
,
ARRAY_SIZE
(
buffer
),
NULL
,
FALSE
);
path
=
(
WCHAR
*
)
0xdeadbeef
;
ret
=
pRtlGetExePath
(
fooW
+
1
,
&
path
);
ok
(
!
ret
,
"RtlGetExePath failed %x
\n
"
,
ret
);
ok
(
path_equal
(
path
,
buffer
),
"got %s expected %s
\n
"
,
wine_dbgstr_w
(
path
),
wine_dbgstr_w
(
buffer
));
pRtlReleasePath
(
path
);
SetEnvironmentVariableA
(
"NoDefaultCurrentDirectoryInExePath"
,
"yes"
);
build_search_path
(
buffer
,
ARRAY_SIZE
(
buffer
),
NULL
,
FALSE
);
path
=
(
WCHAR
*
)
0xdeadbeef
;
ret
=
pRtlGetExePath
(
fooW
,
&
path
);
ok
(
!
ret
,
"RtlGetExePath failed %x
\n
"
,
ret
);
ok
(
path_equal
(
path
,
buffer
),
"got %s expected %s
\n
"
,
wine_dbgstr_w
(
path
),
wine_dbgstr_w
(
buffer
));
pRtlReleasePath
(
path
);
build_search_path
(
buffer
,
ARRAY_SIZE
(
buffer
),
emptyW
,
TRUE
);
path
=
(
WCHAR
*
)
0xdeadbeef
;
ret
=
pRtlGetExePath
(
fooW
+
1
,
&
path
);
ok
(
!
ret
,
"RtlGetExePath failed %x
\n
"
,
ret
);
ok
(
path_equal
(
path
,
buffer
),
"got %s expected %s
\n
"
,
wine_dbgstr_w
(
path
),
wine_dbgstr_w
(
buffer
));
pRtlReleasePath
(
path
);
SetEnvironmentVariableA
(
"PATH"
,
"foo"
);
build_search_path
(
buffer
,
ARRAY_SIZE
(
buffer
),
NULL
,
FALSE
);
path
=
(
WCHAR
*
)
0xdeadbeef
;
ret
=
pRtlGetExePath
(
fooW
,
&
path
);
ok
(
!
ret
,
"RtlGetExePath failed %x
\n
"
,
ret
);
ok
(
path_equal
(
path
,
buffer
),
"got %s expected %s
\n
"
,
wine_dbgstr_w
(
path
),
wine_dbgstr_w
(
buffer
));
pRtlReleasePath
(
path
);
if
(
pSetDllDirectoryW
)
{
ok
(
pSetDllDirectoryW
(
dlldir
),
"SetDllDirectoryW failed
\n
"
);
build_search_path
(
buffer
,
ARRAY_SIZE
(
buffer
),
NULL
,
FALSE
);
path
=
(
WCHAR
*
)
0xdeadbeef
;
ret
=
pRtlGetExePath
(
fooW
,
&
path
);
ok
(
!
ret
,
"RtlGetExePath failed %x
\n
"
,
ret
);
ok
(
path_equal
(
path
,
buffer
),
"got %s expected %s
\n
"
,
wine_dbgstr_w
(
path
),
wine_dbgstr_w
(
buffer
));
pRtlReleasePath
(
path
);
pSetDllDirectoryW
(
NULL
);
}
SetEnvironmentVariableW
(
pathW
,
old_path
);
}
static
void
test_LdrGetDllPath
(
void
)
{
static
const
WCHAR
fooW
[]
=
{
'f'
,
'o'
,
'o'
,
0
};
...
...
@@ -2705,5 +2779,6 @@ START_TEST(path)
test_CheckNameLegalDOS8Dot3
();
test_SetSearchPathMode
();
test_RtlGetSearchPath
();
test_RtlGetExePath
();
test_LdrGetDllPath
();
}
dlls/ntdll/loader.c
View file @
a5d45e9a
...
...
@@ -4133,6 +4133,31 @@ NTSTATUS WINAPI RtlSetSearchPathMode( ULONG flags )
/******************************************************************
* RtlGetExePath (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlGetExePath
(
PCWSTR
name
,
PWSTR
*
path
)
{
static
const
WCHAR
emptyW
[
1
];
const
WCHAR
*
dlldir
=
dotW
;
const
WCHAR
*
module
=
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
ImagePathName
.
Buffer
;
/* same check as NeedCurrentDirectoryForExePathW */
if
(
!
strchrW
(
name
,
'\\'
))
{
static
const
WCHAR
env_name
[]
=
{
'N'
,
'o'
,
'D'
,
'e'
,
'f'
,
'a'
,
'u'
,
'l'
,
't'
,
'C'
,
'u'
,
'r'
,
'r'
,
'e'
,
'n'
,
't'
,
'D'
,
'i'
,
'r'
,
'e'
,
'c'
,
't'
,
'o'
,
'r'
,
'y'
,
'I'
,
'n'
,
'E'
,
'x'
,
'e'
,
'P'
,
'a'
,
't'
,
'h'
,
0
};
UNICODE_STRING
name
,
value
=
{
0
};
RtlInitUnicodeString
(
&
name
,
env_name
);
if
(
RtlQueryEnvironmentVariable_U
(
NULL
,
&
name
,
&
value
)
!=
STATUS_VARIABLE_NOT_FOUND
)
dlldir
=
emptyW
;
}
return
get_dll_load_path
(
module
,
dlldir
,
FALSE
,
path
);
}
/******************************************************************
* RtlGetSearchPath (NTDLL.@)
*/
NTSTATUS
WINAPI
RtlGetSearchPath
(
PWSTR
*
path
)
...
...
dlls/ntdll/ntdll.spec
View file @
a5d45e9a
...
...
@@ -687,6 +687,7 @@
@ stdcall RtlGetDaclSecurityDescriptor(ptr ptr ptr ptr)
@ stub RtlGetElementGenericTable
# @ stub RtlGetElementGenericTableAvl
@ stdcall RtlGetExePath(wstr ptr)
# @ stub RtlGetFirstRange
@ stdcall RtlGetFrame()
@ stdcall RtlGetFullPathName_U(wstr long ptr ptr)
...
...
include/winternl.h
View file @
a5d45e9a
...
...
@@ -2724,6 +2724,7 @@ NTSYSAPI NTSTATUS WINAPI RtlGetControlSecurityDescriptor(PSECURITY_DESCRIPTOR,
NTSYSAPI
ULONG
WINAPI
RtlGetCurrentDirectory_U
(
ULONG
,
LPWSTR
);
NTSYSAPI
PEB
*
WINAPI
RtlGetCurrentPeb
(
void
);
NTSYSAPI
NTSTATUS
WINAPI
RtlGetDaclSecurityDescriptor
(
PSECURITY_DESCRIPTOR
,
PBOOLEAN
,
PACL
*
,
PBOOLEAN
);
NTSYSAPI
NTSTATUS
WINAPI
RtlGetExePath
(
PCWSTR
,
PWSTR
*
);
NTSYSAPI
TEB_ACTIVE_FRAME
*
WINAPI
RtlGetFrame
(
void
);
NTSYSAPI
ULONG
WINAPI
RtlGetFullPathName_U
(
PCWSTR
,
ULONG
,
PWSTR
,
PWSTR
*
);
NTSYSAPI
NTSTATUS
WINAPI
RtlGetGroupSecurityDescriptor
(
PSECURITY_DESCRIPTOR
,
PSID
*
,
PBOOLEAN
);
...
...
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