Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
666c0a57
Commit
666c0a57
authored
Apr 06, 2009
by
Mikołaj Zalewski
Committed by
Alexandre Julliard
Apr 07, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
psapi: Implement GetProcessImageNameW.
parent
33a0062e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
20 deletions
+57
-20
psapi_main.c
dlls/psapi/psapi_main.c
+5
-2
psapi_main.c
dlls/psapi/tests/psapi_main.c
+52
-18
No files found.
dlls/psapi/psapi_main.c
View file @
666c0a57
...
...
@@ -507,8 +507,11 @@ DWORD WINAPI GetProcessImageFileNameA( HANDLE process, LPSTR file, DWORD size )
*/
DWORD
WINAPI
GetProcessImageFileNameW
(
HANDLE
process
,
LPWSTR
file
,
DWORD
size
)
{
FIXME
(
"(%p, %p, %d) stub
\n
"
,
process
,
file
,
size
);
return
0
;
BOOL
success
=
QueryFullProcessImageNameW
(
process
,
PROCESS_NAME_NATIVE
,
file
,
&
size
);
if
(
success
)
return
size
;
else
return
0
;
}
/***********************************************************************
...
...
dlls/psapi/tests/psapi_main.c
View file @
666c0a57
...
...
@@ -21,10 +21,17 @@
#include <stdarg.h>
#include <stdio.h>
#include "wine/test.h"
#include "windows.h"
#include "wine/test.h"
#include "psapi.h"
#define expect_eq_d(expected, actual) \
do { \
int value = (actual); \
ok((expected) == value, "Expected " #actual " to be %d (" #expected ") is %d\n", \
(expected), value); \
} while (0)
#define PSAPI_GET_PROC(func) \
p ## func = (void*)GetProcAddress(hpsapi, #func); \
if(!p ## func) { \
...
...
@@ -63,6 +70,7 @@ static DWORD (WINAPI *pGetModuleFileNameExA)(HANDLE, HMODULE, LPSTR, DWORD);
static
BOOL
(
WINAPI
*
pGetModuleInformation
)(
HANDLE
,
HMODULE
,
LPMODULEINFO
,
DWORD
);
static
DWORD
(
WINAPI
*
pGetMappedFileNameA
)(
HANDLE
,
LPVOID
,
LPSTR
,
DWORD
);
static
DWORD
(
WINAPI
*
pGetProcessImageFileNameA
)(
HANDLE
,
LPSTR
,
DWORD
);
static
DWORD
(
WINAPI
*
pGetProcessImageFileNameW
)(
HANDLE
,
LPWSTR
,
DWORD
);
static
BOOL
(
WINAPI
*
pGetProcessMemoryInfo
)(
HANDLE
,
PPROCESS_MEMORY_COUNTERS
,
DWORD
);
static
BOOL
(
WINAPI
*
pGetWsChanges
)(
HANDLE
,
PPSAPI_WS_WATCH_INFORMATION
,
DWORD
);
static
BOOL
(
WINAPI
*
pInitializeProcessForWsWatch
)(
HANDLE
);
...
...
@@ -84,6 +92,8 @@ static BOOL InitFunctionPtrs(HMODULE hpsapi)
/* GetProcessImageFileName is not exported on NT4 */
pGetProcessImageFileNameA
=
(
void
*
)
GetProcAddress
(
hpsapi
,
"GetProcessImageFileNameA"
);
pGetProcessImageFileNameW
=
(
void
*
)
GetProcAddress
(
hpsapi
,
"GetProcessImageFileNameW"
);
return
TRUE
;
}
...
...
@@ -166,6 +176,7 @@ static void test_GetProcessImageFileName(void)
{
HMODULE
hMod
=
GetModuleHandle
(
NULL
);
char
szImgPath
[
MAX_PATH
],
szMapPath
[
MAX_PATH
];
WCHAR
szImgPathW
[
MAX_PATH
];
DWORD
ret
;
if
(
pGetProcessImageFileNameA
==
NULL
)
...
...
@@ -175,26 +186,49 @@ static void test_GetProcessImageFileName(void)
SetLastError
(
0xdeadbeef
);
if
(
!
pGetProcessImageFileNameA
(
hpQI
,
szImgPath
,
sizeof
(
szImgPath
)))
{
if
(
GetLastError
()
==
ERROR_INVALID_FUNCTION
)
if
(
GetLastError
()
==
ERROR_INVALID_FUNCTION
)
{
win_skip
(
"GetProcessImageFileName not implemented
\n
"
);
else
if
(
GetLastError
()
==
0xdeadbeef
)
ok
(
0
,
"failed without error code
\n
"
);
return
;
}
if
(
GetLastError
()
==
0xdeadbeef
)
todo_wine
ok
(
0
,
"failed without error code
\n
"
);
else
ok
(
0
,
"failed with %d
\n
"
,
GetLastError
());
todo_wine
ok
(
0
,
"failed with %d
\n
"
,
GetLastError
());
}
return
;
todo_wine
w32_err
(
pGetProcessImageFileNameA
(
NULL
,
szImgPath
,
sizeof
(
szImgPath
)),
ERROR_INVALID_HANDLE
);
todo_wine
w32_err
(
pGetProcessImageFileNameA
(
hpSR
,
szImgPath
,
sizeof
(
szImgPath
)),
ERROR_ACCESS_DENIED
);
todo_wine
w32_err
(
pGetProcessImageFileNameA
(
hpQI
,
szImgPath
,
0
),
ERROR_INSUFFICIENT_BUFFER
);
todo_wine
if
(
w32_suc
(
ret
=
pGetProcessImageFileNameA
(
hpQI
,
szImgPath
,
sizeof
(
szImgPath
)))
&&
w32_suc
(
pGetMappedFileNameA
(
hpQV
,
hMod
,
szMapPath
,
sizeof
(
szMapPath
))))
{
/* Windows returns 2*strlen-1 */
ok
(
ret
>=
strlen
(
szImgPath
),
"szImgPath=
\"
%s
\"
ret=%d
\n
"
,
szImgPath
,
ret
);
ok
(
!
strcmp
(
szImgPath
,
szMapPath
),
"szImgPath=
\"
%s
\"
szMapPath=
\"
%s
\"\n
"
,
szImgPath
,
szMapPath
);
}
w32_err
(
pGetProcessImageFileNameA
(
NULL
,
szImgPath
,
sizeof
(
szImgPath
)),
ERROR_INVALID_HANDLE
);
w32_err
(
pGetProcessImageFileNameA
(
hpSR
,
szImgPath
,
sizeof
(
szImgPath
)),
ERROR_ACCESS_DENIED
);
w32_err
(
pGetProcessImageFileNameA
(
hpQI
,
szImgPath
,
0
),
ERROR_INSUFFICIENT_BUFFER
);
if
(
!
w32_suc
(
ret
=
pGetProcessImageFileNameA
(
hpQI
,
szImgPath
,
sizeof
(
szImgPath
)))
||
!
w32_suc
(
pGetMappedFileNameA
(
hpQV
,
hMod
,
szMapPath
,
sizeof
(
szMapPath
))))
return
;
/* Windows returns 2*strlen-1 */
ok
(
ret
>=
strlen
(
szImgPath
),
"szImgPath=
\"
%s
\"
ret=%d
\n
"
,
szImgPath
,
ret
);
ok
(
!
strcmp
(
szImgPath
,
szMapPath
),
"szImgPath=
\"
%s
\"
szMapPath=
\"
%s
\"\n
"
,
szImgPath
,
szMapPath
);
w32_err
(
pGetProcessImageFileNameW
(
NULL
,
szImgPathW
,
sizeof
(
szImgPathW
)),
ERROR_INVALID_HANDLE
);
/* no information about correct buffer size returned: */
w32_err
(
pGetProcessImageFileNameW
(
hpQI
,
szImgPathW
,
0
),
ERROR_INSUFFICIENT_BUFFER
);
w32_err
(
pGetProcessImageFileNameW
(
hpQI
,
NULL
,
0
),
ERROR_INSUFFICIENT_BUFFER
);
/* correct call */
memset
(
szImgPathW
,
0xff
,
sizeof
(
szImgPathW
));
ret
=
pGetProcessImageFileNameW
(
hpQI
,
szImgPathW
,
sizeof
(
szImgPathW
)
/
sizeof
(
WCHAR
));
ok
(
ret
>
0
,
"GetProcessImageFileNameW should have succeeded.
\n
"
);
ok
(
szImgPathW
[
0
]
==
'\\'
,
"GetProcessImageFileNameW should have returned an NT path.
\n
"
);
expect_eq_d
(
lstrlenW
(
szImgPathW
),
ret
);
/* boundary values of 'size' */
w32_err
(
pGetProcessImageFileNameW
(
hpQI
,
szImgPathW
,
ret
),
ERROR_INSUFFICIENT_BUFFER
);
memset
(
szImgPathW
,
0xff
,
sizeof
(
szImgPathW
));
ret
=
pGetProcessImageFileNameW
(
hpQI
,
szImgPathW
,
ret
+
1
);
ok
(
ret
>
0
,
"GetProcessImageFileNameW should have succeeded.
\n
"
);
ok
(
szImgPathW
[
0
]
==
'\\'
,
"GetProcessImageFileNameW should have returned an NT path.
\n
"
);
expect_eq_d
(
lstrlenW
(
szImgPathW
),
ret
);
}
static
void
test_GetModuleFileNameEx
(
void
)
...
...
@@ -309,7 +343,7 @@ START_TEST(psapi_main)
test_GetModuleInformation
();
test_GetProcessMemoryInfo
();
todo_wine
test_GetMappedFileName
();
t
odo_wine
t
est_GetProcessImageFileName
();
test_GetProcessImageFileName
();
test_GetModuleFileNameEx
();
test_GetModuleBaseName
();
test_ws_functions
();
...
...
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