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
80ba9f35
Commit
80ba9f35
authored
Oct 04, 2011
by
Francois Gouget
Committed by
Alexandre Julliard
Oct 04, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Test K32GetProcessImageFileNameA() and improve the…
kernel32/tests: Test K32GetProcessImageFileNameA() and improve the QueryFullProcessImageNameA() tests.
parent
1533965e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
6 deletions
+58
-6
process.c
dlls/kernel32/tests/process.c
+58
-6
No files found.
dlls/kernel32/tests/process.c
View file @
80ba9f35
...
@@ -62,6 +62,7 @@ static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD);
...
@@ -62,6 +62,7 @@ static LPVOID (WINAPI *pVirtualAllocEx)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD);
static
BOOL
(
WINAPI
*
pVirtualFreeEx
)(
HANDLE
,
LPVOID
,
SIZE_T
,
DWORD
);
static
BOOL
(
WINAPI
*
pVirtualFreeEx
)(
HANDLE
,
LPVOID
,
SIZE_T
,
DWORD
);
static
BOOL
(
WINAPI
*
pQueryFullProcessImageNameA
)(
HANDLE
hProcess
,
DWORD
dwFlags
,
LPSTR
lpExeName
,
PDWORD
lpdwSize
);
static
BOOL
(
WINAPI
*
pQueryFullProcessImageNameA
)(
HANDLE
hProcess
,
DWORD
dwFlags
,
LPSTR
lpExeName
,
PDWORD
lpdwSize
);
static
BOOL
(
WINAPI
*
pQueryFullProcessImageNameW
)(
HANDLE
hProcess
,
DWORD
dwFlags
,
LPWSTR
lpExeName
,
PDWORD
lpdwSize
);
static
BOOL
(
WINAPI
*
pQueryFullProcessImageNameW
)(
HANDLE
hProcess
,
DWORD
dwFlags
,
LPWSTR
lpExeName
,
PDWORD
lpdwSize
);
static
DWORD
(
WINAPI
*
pK32GetProcessImageFileNameA
)(
HANDLE
,
LPSTR
,
DWORD
);
/* ############################### */
/* ############################### */
static
char
base
[
MAX_PATH
];
static
char
base
[
MAX_PATH
];
...
@@ -204,6 +205,7 @@ static int init(void)
...
@@ -204,6 +205,7 @@ static int init(void)
pVirtualFreeEx
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"VirtualFreeEx"
);
pVirtualFreeEx
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"VirtualFreeEx"
);
pQueryFullProcessImageNameA
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"QueryFullProcessImageNameA"
);
pQueryFullProcessImageNameA
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"QueryFullProcessImageNameA"
);
pQueryFullProcessImageNameW
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"QueryFullProcessImageNameW"
);
pQueryFullProcessImageNameW
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"QueryFullProcessImageNameW"
);
pK32GetProcessImageFileNameA
=
(
void
*
)
GetProcAddress
(
hkernel32
,
"K32GetProcessImageFileNameA"
);
return
1
;
return
1
;
}
}
...
@@ -1638,21 +1640,70 @@ static void test_GetProcessVersion(void)
...
@@ -1638,21 +1640,70 @@ static void test_GetProcessVersion(void)
CloseHandle
(
pi
.
hThread
);
CloseHandle
(
pi
.
hThread
);
}
}
static
void
test_ProcessNameA
(
void
)
static
void
test_GetProcessImageFileNameA
(
void
)
{
DWORD
rc
;
CHAR
process
[
MAX_PATH
];
static
const
char
harddisk
[]
=
"
\\
Device
\\
HarddiskVolume"
;
if
(
!
pK32GetProcessImageFileNameA
)
{
win_skip
(
"K32GetProcessImageFileNameA is unavailable
\n
"
);
return
;
}
/* callers must guess the buffer size */
SetLastError
(
0xdeadbeef
);
rc
=
pK32GetProcessImageFileNameA
(
GetCurrentProcess
(),
NULL
,
0
);
ok
(
!
rc
&&
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"K32GetProcessImageFileNameA(no buffer): returned %u, le=%u
\n
"
,
rc
,
GetLastError
());
*
process
=
'\0'
;
rc
=
pK32GetProcessImageFileNameA
(
GetCurrentProcess
(),
process
,
sizeof
(
process
));
expect_eq_d
(
rc
,
lstrlenA
(
process
));
if
(
strncmp
(
process
,
harddisk
,
lstrlenA
(
harddisk
)))
{
todo_wine
win_skip
(
"%s is probably on a network share, skipping tests
\n
"
,
process
);
return
;
}
if
(
!
pQueryFullProcessImageNameA
)
win_skip
(
"QueryFullProcessImageNameA unavailable (added in Windows Vista)
\n
"
);
else
{
CHAR
image
[
MAX_PATH
];
DWORD
length
;
length
=
sizeof
(
image
);
expect_eq_d
(
TRUE
,
pQueryFullProcessImageNameA
(
GetCurrentProcess
(),
PROCESS_NAME_NATIVE
,
image
,
&
length
));
expect_eq_d
(
length
,
lstrlenA
(
image
));
ok
(
lstrcmpi
(
process
,
image
)
==
0
,
"expected '%s' to be equal to '%s'
\n
"
,
process
,
image
);
}
}
static
void
test_QueryFullProcessImageNameA
(
void
)
{
{
#define INIT_STR "Just some words"
#define INIT_STR "Just some words"
DWORD
length
,
size
;
DWORD
length
,
size
;
CHAR
buf
[
1024
];
CHAR
buf
[
MAX_PATH
],
module
[
MAX_PATH
];
if
(
!
pQueryFullProcessImageNameA
)
if
(
!
pQueryFullProcessImageNameA
)
{
{
win_skip
(
"QueryFullProcessImageNameA unavailable (added in Windows Vista)
\n
"
);
win_skip
(
"QueryFullProcessImageNameA unavailable (added in Windows Vista)
\n
"
);
return
;
return
;
}
}
*
module
=
'\0'
;
SetLastError
(
0
);
/* old Windows don't reset it on success */
size
=
GetModuleFileNameA
(
NULL
,
module
,
sizeof
(
module
));
ok
(
size
&&
GetLastError
()
!=
ERROR_INSUFFICIENT_BUFFER
,
"GetModuleFileName failed: %u le=%u
\n
"
,
size
,
GetLastError
());
/* get the buffer length without \0 terminator */
/* get the buffer length without \0 terminator */
length
=
1024
;
length
=
sizeof
(
buf
)
;
expect_eq_d
(
TRUE
,
pQueryFullProcessImageNameA
(
GetCurrentProcess
(),
0
,
buf
,
&
length
));
expect_eq_d
(
TRUE
,
pQueryFullProcessImageNameA
(
GetCurrentProcess
(),
0
,
buf
,
&
length
));
expect_eq_d
(
length
,
lstrlenA
(
buf
));
expect_eq_d
(
length
,
lstrlenA
(
buf
));
ok
((
buf
[
0
]
==
'\\'
&&
buf
[
1
]
==
'\\'
)
||
lstrcmpi
(
buf
,
module
)
==
0
,
"expected %s to match %s
\n
"
,
buf
,
module
);
/* when the buffer is too small
/* when the buffer is too small
* - function fail with error ERROR_INSUFFICIENT_BUFFER
* - function fail with error ERROR_INSUFFICIENT_BUFFER
...
@@ -1685,7 +1736,7 @@ static void test_ProcessNameA(void)
...
@@ -1685,7 +1736,7 @@ static void test_ProcessNameA(void)
expect_eq_d
(
ERROR_INVALID_PARAMETER
,
GetLastError
());
expect_eq_d
(
ERROR_INVALID_PARAMETER
,
GetLastError
());
}
}
static
void
test_
ProcessName
(
void
)
static
void
test_
QueryFullProcessImageNameW
(
void
)
{
{
HANDLE
hSelf
;
HANDLE
hSelf
;
WCHAR
module_name
[
1024
];
WCHAR
module_name
[
1024
];
...
@@ -1888,8 +1939,9 @@ START_TEST(process)
...
@@ -1888,8 +1939,9 @@ START_TEST(process)
test_ExitCode
();
test_ExitCode
();
test_OpenProcess
();
test_OpenProcess
();
test_GetProcessVersion
();
test_GetProcessVersion
();
test_ProcessNameA
();
test_GetProcessImageFileNameA
();
test_ProcessName
();
test_QueryFullProcessImageNameA
();
test_QueryFullProcessImageNameW
();
test_Handles
();
test_Handles
();
test_SystemInfo
();
test_SystemInfo
();
test_RegistryQuota
();
test_RegistryQuota
();
...
...
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