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
12a9b6d4
Commit
12a9b6d4
authored
Feb 13, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add tests for initial process parameters layout.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a95d7f6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
5 deletions
+67
-5
env.c
dlls/ntdll/tests/env.c
+67
-5
No files found.
dlls/ntdll/tests/env.c
View file @
12a9b6d4
...
...
@@ -37,6 +37,8 @@ static NTSTATUS (WINAPI *pRtlCreateProcessParameters)(RTL_USER_PROCESS_PARAMETER
const
UNICODE_STRING
*
,
const
UNICODE_STRING
*
);
static
void
(
WINAPI
*
pRtlDestroyProcessParameters
)(
RTL_USER_PROCESS_PARAMETERS
*
);
static
void
*
initial_env
;
static
WCHAR
small_env
[]
=
{
'f'
,
'o'
,
'o'
,
'='
,
't'
,
'o'
,
't'
,
'o'
,
0
,
'f'
,
'o'
,
'='
,
't'
,
'i'
,
't'
,
'i'
,
0
,
'f'
,
'o'
,
'o'
,
'o'
,
'='
,
't'
,
'u'
,
't'
,
'u'
,
0
,
...
...
@@ -289,17 +291,21 @@ static WCHAR *get_params_string( RTL_USER_PROCESS_PARAMETERS *params, UNICODE_ST
static
UINT_PTR
check_string_
(
int
line
,
RTL_USER_PROCESS_PARAMETERS
*
params
,
UNICODE_STRING
*
str
,
const
UNICODE_STRING
*
expect
,
UINT_PTR
pos
)
{
ok_
(
__FILE__
,
line
)(
str
->
Length
==
expect
->
Length
,
"wrong length %u/%u
\n
"
,
str
->
Length
,
expect
->
Length
);
ok_
(
__FILE__
,
line
)(
str
->
MaximumLength
==
expect
->
MaximumLength
||
broken
(
str
->
MaximumLength
==
1
&&
expect
->
MaximumLength
==
2
),
/* winxp */
"wrong maxlength %u/%u
\n
"
,
str
->
MaximumLength
,
expect
->
MaximumLength
);
if
(
expect
)
{
ok_
(
__FILE__
,
line
)(
str
->
Length
==
expect
->
Length
,
"wrong length %u/%u
\n
"
,
str
->
Length
,
expect
->
Length
);
ok_
(
__FILE__
,
line
)(
str
->
MaximumLength
==
expect
->
MaximumLength
||
broken
(
str
->
MaximumLength
==
1
&&
expect
->
MaximumLength
==
2
),
/* winxp */
"wrong maxlength %u/%u
\n
"
,
str
->
MaximumLength
,
expect
->
MaximumLength
);
}
if
(
!
str
->
MaximumLength
)
{
ok_
(
__FILE__
,
line
)(
str
->
Buffer
==
NULL
,
"buffer not null %p
\n
"
,
str
->
Buffer
);
return
pos
;
}
ok_
(
__FILE__
,
line
)(
(
UINT_PTR
)
str
->
Buffer
==
((
pos
+
sizeof
(
void
*
)
-
1
)
&
~
(
sizeof
(
void
*
)
-
1
))
||
(
!
expect
&&
(
UINT_PTR
)
str
->
Buffer
==
pos
)
||
/* initial params are not aligned */
broken
(
(
UINT_PTR
)
str
->
Buffer
==
((
pos
+
3
)
&
~
3
)
),
"wrong buffer %lx/%lx
\n
"
,
(
UINT_PTR
)
str
->
Buffer
,
pos
);
if
(
str
->
Length
<
str
->
MaximumLength
)
...
...
@@ -453,12 +459,68 @@ static void test_process_params(void)
}
else
ok
(
broken
(
TRUE
),
"environment not inside block
\n
"
);
/* <= win2k3 */
pRtlDestroyProcessParameters
(
params
);
/* also test the actual parameters of the current process */
ok
(
cur_params
->
Flags
&
PROCESS_PARAMS_FLAG_NORMALIZED
,
"current params not normalized
\n
"
);
if
(
VirtualQuery
(
cur_params
,
&
info
,
sizeof
(
info
)
)
&&
info
.
AllocationBase
==
cur_params
)
{
ok
(
broken
(
TRUE
),
"not a heap block %p
\n
"
,
cur_params
);
/* winxp */
ok
(
cur_params
->
AllocationSize
==
info
.
RegionSize
,
"wrong AllocationSize %x/%lx
\n
"
,
cur_params
->
AllocationSize
,
info
.
RegionSize
);
}
else
{
size
=
HeapSize
(
GetProcessHeap
(),
0
,
cur_params
);
ok
(
size
!=
~
0UL
,
"not a heap block %p
\n
"
,
cur_params
);
ok
(
cur_params
->
AllocationSize
==
cur_params
->
Size
,
"wrong AllocationSize %x/%x
\n
"
,
cur_params
->
AllocationSize
,
cur_params
->
Size
);
ok
(
cur_params
->
Size
==
size
,
"wrong Size %x/%lx
\n
"
,
cur_params
->
Size
,
size
);
}
/* CurrentDirectory points outside the params, and DllPath may be null */
pos
=
(
UINT_PTR
)
cur_params
->
DllPath
.
Buffer
;
if
(
!
pos
)
pos
=
(
UINT_PTR
)
cur_params
->
ImagePathName
.
Buffer
;
pos
=
check_string
(
cur_params
,
&
cur_params
->
DllPath
,
NULL
,
pos
);
pos
=
check_string
(
cur_params
,
&
cur_params
->
ImagePathName
,
NULL
,
pos
);
pos
=
check_string
(
cur_params
,
&
cur_params
->
CommandLine
,
NULL
,
pos
);
pos
=
check_string
(
cur_params
,
&
cur_params
->
WindowTitle
,
NULL
,
pos
);
pos
=
check_string
(
cur_params
,
&
cur_params
->
Desktop
,
NULL
,
pos
);
pos
=
check_string
(
cur_params
,
&
cur_params
->
ShellInfo
,
NULL
,
pos
);
pos
=
check_string
(
cur_params
,
&
cur_params
->
RuntimeInfo
,
NULL
,
pos
);
/* environment may follow */
str
=
(
WCHAR
*
)
pos
;
if
(
pos
-
(
UINT_PTR
)
cur_params
<
cur_params
->
Size
)
{
while
(
*
str
)
str
+=
lstrlenW
(
str
)
+
1
;
str
++
;
}
ok
(
(
char
*
)
str
==
(
char
*
)
cur_params
+
cur_params
->
Size
,
"wrong end ptr %p/%p
\n
"
,
str
,
(
char
*
)
cur_params
+
cur_params
->
Size
);
/* initial environment is a separate block */
ok
(
(
char
*
)
initial_env
<
(
char
*
)
cur_params
||
(
char
*
)
initial_env
>=
(
char
*
)
cur_params
+
size
,
"initial environment inside block %p / %p
\n
"
,
cur_params
,
initial_env
);
if
(
VirtualQuery
(
initial_env
,
&
info
,
sizeof
(
info
)
)
&&
info
.
AllocationBase
==
initial_env
)
{
todo_wine
ok
(
broken
(
TRUE
),
"env not a heap block %p / %p
\n
"
,
cur_params
,
initial_env
);
/* winxp */
}
else
{
size
=
HeapSize
(
GetProcessHeap
(),
0
,
initial_env
);
ok
(
size
!=
~
0UL
,
"env is not a heap block %p / %p
\n
"
,
cur_params
,
initial_env
);
}
}
START_TEST
(
env
)
{
HMODULE
mod
=
GetModuleHandleA
(
"ntdll.dll"
);
initial_env
=
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
Environment
;
pRtlMultiByteToUnicodeN
=
(
void
*
)
GetProcAddress
(
mod
,
"RtlMultiByteToUnicodeN"
);
pRtlCreateEnvironment
=
(
void
*
)
GetProcAddress
(
mod
,
"RtlCreateEnvironment"
);
pRtlDestroyEnvironment
=
(
void
*
)
GetProcAddress
(
mod
,
"RtlDestroyEnvironment"
);
...
...
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