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
505be3a0
Commit
505be3a0
authored
Aug 24, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Implement SetThreadStackGuarantee().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f238e846
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
4 deletions
+73
-4
thread.c
dlls/kernel32/tests/thread.c
+58
-0
thread.c
dlls/kernelbase/thread.c
+13
-2
winternl.h
include/winternl.h
+2
-2
No files found.
dlls/kernel32/tests/thread.c
View file @
505be3a0
...
...
@@ -82,6 +82,7 @@ static HANDLE (WINAPI *pOpenThread)(DWORD,BOOL,DWORD);
static
BOOL
(
WINAPI
*
pQueueUserWorkItem
)(
LPTHREAD_START_ROUTINE
,
PVOID
,
ULONG
);
static
DWORD
(
WINAPI
*
pSetThreadIdealProcessor
)(
HANDLE
,
DWORD
);
static
BOOL
(
WINAPI
*
pSetThreadPriorityBoost
)(
HANDLE
,
BOOL
);
static
BOOL
(
WINAPI
*
pSetThreadStackGuarantee
)(
ULONG
*
);
static
BOOL
(
WINAPI
*
pRegisterWaitForSingleObject
)(
PHANDLE
,
HANDLE
,
WAITORTIMERCALLBACK
,
PVOID
,
ULONG
,
ULONG
);
static
BOOL
(
WINAPI
*
pUnregisterWait
)(
HANDLE
);
static
BOOL
(
WINAPI
*
pIsWow64Process
)(
HANDLE
,
PBOOL
);
...
...
@@ -1016,6 +1017,61 @@ static VOID test_GetCurrentThreadStackLimits(void)
ok
(
high
==
(
ULONG_PTR
)
NtCurrentTeb
()
->
Tib
.
StackBase
,
"expected %p, got %lx
\n
"
,
NtCurrentTeb
()
->
Tib
.
StackBase
,
high
);
}
static
void
test_SetThreadStackGuarantee
(
void
)
{
ULONG
size
;
BOOL
ret
;
if
(
!
pSetThreadStackGuarantee
)
{
win_skip
(
"SetThreadStackGuarantee not available.
\n
"
);
return
;
}
size
=
0
;
ret
=
pSetThreadStackGuarantee
(
&
size
);
ok
(
ret
,
"failed err %u
\n
"
,
GetLastError
()
);
ok
(
size
==
0
,
"wrong size %u
\n
"
,
size
);
ok
(
NtCurrentTeb
()
->
GuaranteedStackBytes
==
0
,
"wrong teb %u
\n
"
,
NtCurrentTeb
()
->
GuaranteedStackBytes
);
size
=
0xdeadbef
;
ret
=
pSetThreadStackGuarantee
(
&
size
);
ok
(
!
ret
,
"succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
||
GetLastError
()
==
ERROR_INVALID_ADDRESS
,
"wrong error %u
\n
"
,
GetLastError
());
ok
(
size
==
0
,
"wrong size %u
\n
"
,
size
);
ok
(
NtCurrentTeb
()
->
GuaranteedStackBytes
==
0
,
"wrong teb %u
\n
"
,
NtCurrentTeb
()
->
GuaranteedStackBytes
);
size
=
200
;
ret
=
pSetThreadStackGuarantee
(
&
size
);
ok
(
ret
,
"failed err %u
\n
"
,
GetLastError
()
);
ok
(
size
==
0
,
"wrong size %u
\n
"
,
size
);
ok
(
NtCurrentTeb
()
->
GuaranteedStackBytes
==
4096
*
sizeof
(
void
*
)
/
4
,
"wrong teb %u
\n
"
,
NtCurrentTeb
()
->
GuaranteedStackBytes
);
size
=
5000
;
ret
=
pSetThreadStackGuarantee
(
&
size
);
ok
(
ret
,
"failed err %u
\n
"
,
GetLastError
()
);
ok
(
size
==
4096
*
sizeof
(
void
*
)
/
4
,
"wrong size %u
\n
"
,
size
);
ok
(
NtCurrentTeb
()
->
GuaranteedStackBytes
==
8192
,
"wrong teb %u
\n
"
,
NtCurrentTeb
()
->
GuaranteedStackBytes
);
size
=
2000
;
ret
=
pSetThreadStackGuarantee
(
&
size
);
ok
(
ret
,
"failed err %u
\n
"
,
GetLastError
()
);
ok
(
size
==
8192
,
"wrong size %u
\n
"
,
size
);
ok
(
NtCurrentTeb
()
->
GuaranteedStackBytes
==
8192
,
"wrong teb %u
\n
"
,
NtCurrentTeb
()
->
GuaranteedStackBytes
);
size
=
10000
;
ret
=
pSetThreadStackGuarantee
(
&
size
);
ok
(
ret
,
"failed err %u
\n
"
,
GetLastError
()
);
ok
(
size
==
8192
,
"wrong size %u
\n
"
,
size
);
ok
(
NtCurrentTeb
()
->
GuaranteedStackBytes
==
12288
,
"wrong teb %u
\n
"
,
NtCurrentTeb
()
->
GuaranteedStackBytes
);
ret
=
pSetThreadStackGuarantee
(
&
size
);
ok
(
ret
,
"failed err %u
\n
"
,
GetLastError
()
);
ok
(
size
==
12288
,
"wrong size %u
\n
"
,
size
);
ok
(
NtCurrentTeb
()
->
GuaranteedStackBytes
==
12288
,
"wrong teb %u
\n
"
,
NtCurrentTeb
()
->
GuaranteedStackBytes
);
}
static
VOID
test_GetThreadExitCode
(
void
)
{
DWORD
exitCode
,
threadid
;
...
...
@@ -2029,6 +2085,7 @@ static void init_funcs(void)
X
(
QueueUserWorkItem
);
X
(
SetThreadIdealProcessor
);
X
(
SetThreadPriorityBoost
);
X
(
SetThreadStackGuarantee
);
X
(
RegisterWaitForSingleObject
);
X
(
UnregisterWait
);
X
(
IsWow64Process
);
...
...
@@ -2110,6 +2167,7 @@ START_TEST(thread)
test_CreateThread_stack
();
test_thread_priority
();
test_GetCurrentThreadStackLimits
();
test_SetThreadStackGuarantee
();
test_GetThreadTimes
();
test_thread_processor
();
test_GetThreadExitCode
();
...
...
dlls/kernelbase/thread.c
View file @
505be3a0
...
...
@@ -470,8 +470,19 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetThreadPriorityBoost( HANDLE thread, BOOL disabl
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
SetThreadStackGuarantee
(
ULONG
*
size
)
{
static
int
once
;
if
(
once
++
==
0
)
FIXME
(
"(%p): stub
\n
"
,
size
);
ULONG
prev_size
=
NtCurrentTeb
()
->
GuaranteedStackBytes
;
ULONG
new_size
=
(
*
size
+
4095
)
&
~
4095
;
/* at least 2 pages on 64-bit */
if
(
sizeof
(
void
*
)
>
sizeof
(
int
))
new_size
=
max
(
new_size
,
8192
);
*
size
=
prev_size
;
if
(
new_size
>=
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackBase
-
(
char
*
)
NtCurrentTeb
()
->
DeallocationStack
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
new_size
>
prev_size
)
NtCurrentTeb
()
->
GuaranteedStackBytes
=
(
new_size
+
4095
)
&
~
4095
;
return
TRUE
;
}
...
...
include/winternl.h
View file @
505be3a0
...
...
@@ -397,8 +397,8 @@ typedef struct _TEB
PVOID
WinSockData
;
/* f6c/1738 */
ULONG
GdiBatchCount
;
/* f70/1740 */
ULONG
Spare2
;
/* f74/1744 */
PVOID
Spare3
;
/* f78/1748 */
PVOID
Spare4
;
/* f7c/1750 */
ULONG
GuaranteedStackBytes
;
/* f78/1748 */
PVOID
ReservedForPerf
;
/* f7c/1750 */
PVOID
ReservedForOle
;
/* f80/1758 */
ULONG
WaitingOnLoaderLock
;
/* f84/1760 */
PVOID
Reserved5
[
3
];
/* f88/1768 */
...
...
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