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
03e4ea17
Commit
03e4ea17
authored
Mar 18, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make GetModuleFileNameA call GetModuleFileNameW. Small cleanups.
parent
c85f61b1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
42 deletions
+23
-42
module.c
loader/module.c
+23
-42
No files found.
loader/module.c
View file @
03e4ea17
...
...
@@ -50,6 +50,14 @@ WINE_MODREF *MODULE_modref_list = NULL;
WINE_MODREF
*
exe_modref
;
int
process_detaching
=
0
;
/* set on process detach to avoid deadlocks with thread detach */
inline
static
HMODULE
get_exe_module
(
void
)
{
HMODULE
mod
;
/* FIXME: should look into PEB */
LdrGetDllHandle
(
0
,
0
,
NULL
,
&
mod
);
return
mod
;
}
/***********************************************************************
* wait_input_idle
*
...
...
@@ -922,46 +930,24 @@ DWORD WINAPI GetModuleFileNameA(
LPSTR
lpFileName
,
/* [out] filenamebuffer */
DWORD
size
)
/* [in] size of filenamebuffer */
{
DWORD
len
=
0
;
lpFileName
[
0
]
=
0
;
RtlEnterCriticalSection
(
&
loader_section
);
if
(
!
hModule
&&
!
(
NtCurrentTeb
()
->
tibflags
&
TEBF_WIN32
))
{
/* 16-bit task - get current NE module name */
NE_MODULE
*
pModule
=
NE_GetPtr
(
GetCurrentTask
()
);
if
(
pModule
)
len
=
GetLongPathNameA
(
NE_MODULE_NAME
(
pModule
),
lpFileName
,
size
);
}
else
if
(
hModule
||
LdrGetDllHandle
(
0
,
0
,
NULL
,
&
hModule
)
==
STATUS_SUCCESS
)
{
LDR_MODULE
*
pldr
;
NTSTATUS
nts
;
LPWSTR
filenameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
)
);
nts
=
LdrFindEntryForAddress
(
hModule
,
&
pldr
);
if
(
nts
==
STATUS_SUCCESS
)
if
(
!
filenameW
)
{
WideCharToMultiByte
(
CP_ACP
,
0
,
pldr
->
FullDllName
.
Buffer
,
pldr
->
FullDllName
.
Length
,
lpFileName
,
size
,
NULL
,
NULL
);
len
=
min
(
size
,
pldr
->
FullDllName
.
Length
/
sizeof
(
WCHAR
));
}
else
SetLastError
(
RtlNtStatusToDosError
(
nts
)
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
0
;
}
RtlLeaveCriticalSection
(
&
loader_section
);
TRACE
(
"%s
\n
"
,
debugstr_an
(
lpFileName
,
len
)
);
return
len
;
GetModuleFileNameW
(
hModule
,
filenameW
,
size
);
WideCharToMultiByte
(
CP_ACP
,
0
,
filenameW
,
-
1
,
lpFileName
,
size
,
NULL
,
NULL
);
HeapFree
(
GetProcessHeap
(),
0
,
filenameW
);
return
strlen
(
lpFileName
)
;
}
/***********************************************************************
* GetModuleFileNameW (KERNEL32.@)
*/
DWORD
WINAPI
GetModuleFileNameW
(
HMODULE
hModule
,
LPWSTR
lpFileName
,
DWORD
size
)
{
DWORD
len
=
0
;
lpFileName
[
0
]
=
0
;
RtlEnterCriticalSection
(
&
loader_section
);
...
...
@@ -973,30 +959,25 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size
{
WCHAR
path
[
MAX_PATH
];
MultiByteToWideChar
(
CP_ACP
,
0
,
NE_MODULE_NAME
(
pModule
),
-
1
,
path
,
MAX_PATH
);
len
=
GetLongPathNameW
(
path
,
lpFileName
,
size
);
MultiByteToWideChar
(
CP_ACP
,
0
,
NE_MODULE_NAME
(
pModule
),
-
1
,
path
,
MAX_PATH
);
GetLongPathNameW
(
path
,
lpFileName
,
size
);
}
}
else
if
(
hModule
||
LdrGetDllHandle
(
0
,
0
,
NULL
,
&
hModule
)
==
STATUS_SUCCESS
)
else
{
LDR_MODULE
*
pldr
;
NTSTATUS
nts
;
if
(
!
hModule
)
hModule
=
get_exe_module
();
nts
=
LdrFindEntryForAddress
(
hModule
,
&
pldr
);
if
(
nts
==
STATUS_SUCCESS
)
{
len
=
min
(
size
,
pldr
->
FullDllName
.
Length
/
sizeof
(
WCHAR
));
strncpyW
(
lpFileName
,
pldr
->
FullDllName
.
Buffer
,
len
);
if
(
len
<
size
)
lpFileName
[
len
]
=
0
;
}
if
(
nts
==
STATUS_SUCCESS
)
lstrcpynW
(
lpFileName
,
pldr
->
FullDllName
.
Buffer
,
size
);
else
SetLastError
(
RtlNtStatusToDosError
(
nts
)
);
}
RtlLeaveCriticalSection
(
&
loader_section
);
TRACE
(
"%s
\n
"
,
debugstr_w
n
(
lpFileName
,
len
)
);
return
len
;
TRACE
(
"%s
\n
"
,
debugstr_w
(
lpFileName
)
);
return
strlenW
(
lpFileName
)
;
}
/******************************************************************
...
...
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