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
7a383cf8
Commit
7a383cf8
authored
Jan 18, 2007
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Abuse RtlCreateUserThread to call the thread function for CreateThread directly.
parent
21d631e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
52 deletions
+45
-52
thread.c
dlls/kernel32/thread.c
+1
-48
thread.c
dlls/ntdll/thread.c
+44
-4
No files found.
dlls/kernel32/thread.c
View file @
7a383cf8
...
...
@@ -45,42 +45,6 @@
#include "kernel_private.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
thread
);
WINE_DECLARE_DEBUG_CHANNEL
(
relay
);
struct
new_thread_info
{
LPTHREAD_START_ROUTINE
func
;
void
*
arg
;
};
/***********************************************************************
* THREAD_Start
*
* Start execution of a newly created thread. Does not return.
*/
static
void
CALLBACK
THREAD_Start
(
void
*
ptr
)
{
struct
new_thread_info
*
info
=
ptr
;
LPTHREAD_START_ROUTINE
func
=
info
->
func
;
void
*
arg
=
info
->
arg
;
RtlFreeHeap
(
GetProcessHeap
(),
0
,
info
);
if
(
TRACE_ON
(
relay
))
DPRINTF
(
"%04x:Starting thread (entryproc=%p)
\n
"
,
GetCurrentThreadId
(),
func
);
__TRY
{
ExitThread
(
func
(
arg
)
);
}
__EXCEPT
(
UnhandledExceptionFilter
)
{
TerminateThread
(
GetCurrentThread
(),
GetExceptionCode
()
);
}
__ENDTRY
}
/***********************************************************************
...
...
@@ -120,22 +84,13 @@ HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE
CLIENT_ID
client_id
;
NTSTATUS
status
;
SIZE_T
stack_reserve
=
0
,
stack_commit
=
0
;
struct
new_thread_info
*
info
;
if
(
!
(
info
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
*
info
)
)))
{
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
return
0
;
}
info
->
func
=
start
;
info
->
arg
=
param
;
if
(
flags
&
STACK_SIZE_PARAM_IS_A_RESERVATION
)
stack_reserve
=
stack
;
else
stack_commit
=
stack
;
status
=
RtlCreateUserThread
(
hProcess
,
NULL
,
TRUE
,
NULL
,
stack_reserve
,
stack_commit
,
THREAD_Start
,
info
,
&
handle
,
&
client_id
);
(
PRTL_THREAD_START_ROUTINE
)
start
,
param
,
&
handle
,
&
client_id
);
if
(
status
==
STATUS_SUCCESS
)
{
if
(
id
)
*
id
=
(
DWORD
)
client_id
.
UniqueThread
;
...
...
@@ -147,7 +102,6 @@ HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE
if
(
NtResumeThread
(
handle
,
&
ret
))
{
NtClose
(
handle
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
info
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
handle
=
0
;
}
...
...
@@ -155,7 +109,6 @@ HANDLE WINAPI CreateRemoteThread( HANDLE hProcess, SECURITY_ATTRIBUTES *sa, SIZE
}
else
{
RtlFreeHeap
(
GetProcessHeap
(),
0
,
info
);
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
handle
=
0
;
}
...
...
dlls/ntdll/thread.c
View file @
7a383cf8
...
...
@@ -43,6 +43,7 @@
#include "wine/exception.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
thread
);
WINE_DECLARE_DEBUG_CHANNEL
(
relay
);
/* info passed to a starting thread */
struct
startup_info
...
...
@@ -349,6 +350,47 @@ static PUNHANDLED_EXCEPTION_FILTER get_unhandled_exception_filter(void)
}
/***********************************************************************
* call_thread_func
*
* Hack to make things compatible with the thread procedures used by kernel32.CreateThread.
*/
static
void
DECLSPEC_NORETURN
call_thread_func
(
PRTL_THREAD_START_ROUTINE
rtl_func
,
void
*
arg
)
{
LPTHREAD_START_ROUTINE
func
=
(
LPTHREAD_START_ROUTINE
)
rtl_func
;
DWORD
exit_code
;
BOOL
last
;
MODULE_DllThreadAttach
(
NULL
);
if
(
TRACE_ON
(
relay
))
DPRINTF
(
"%04x:Starting thread proc %p (arg=%p)
\n
"
,
GetCurrentThreadId
(),
func
,
arg
);
exit_code
=
func
(
arg
);
/* send the exit code to the server */
SERVER_START_REQ
(
terminate_thread
)
{
req
->
handle
=
GetCurrentThread
();
req
->
exit_code
=
exit_code
;
wine_server_call
(
req
);
last
=
reply
->
last
;
}
SERVER_END_REQ
;
if
(
last
)
{
LdrShutdownProcess
();
exit
(
exit_code
);
}
else
{
LdrShutdownThread
();
server_exit_thread
(
exit_code
);
}
}
/***********************************************************************
* start_thread
*
* Startup routine for a newly created thread.
...
...
@@ -397,7 +439,7 @@ static void start_thread( struct wine_pthread_thread_info *info )
{
__TRY
{
MODULE_DllThreadAttach
(
NULL
);
call_thread_func
(
func
,
arg
);
}
__EXCEPT
(
get_unhandled_exception_filter
())
{
...
...
@@ -406,9 +448,7 @@ static void start_thread( struct wine_pthread_thread_info *info )
__ENDTRY
}
else
MODULE_DllThreadAttach
(
NULL
);
func
(
arg
);
call_thread_func
(
func
,
arg
);
}
...
...
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