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
31d522ea
Commit
31d522ea
authored
Sep 27, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Use set_ntstatus() in more places.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0bfee2c6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
135 deletions
+43
-135
loader.c
dlls/kernelbase/loader.c
+8
-22
main.c
dlls/kernelbase/main.c
+2
-12
memory.c
dlls/kernelbase/memory.c
+3
-6
sync.c
dlls/kernelbase/sync.c
+12
-66
thread.c
dlls/kernelbase/thread.c
+18
-29
No files found.
dlls/kernelbase/loader.c
View file @
31d522ea
...
...
@@ -573,7 +573,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExA( HMODULE module, ENUMRESTYPEP
BOOL
ret
=
FALSE
;
LPSTR
type
=
NULL
;
DWORD
len
=
0
,
newlen
;
NTSTATUS
status
;
const
IMAGE_RESOURCE_DIRECTORY
*
resdir
;
const
IMAGE_RESOURCE_DIRECTORY_ENTRY
*
et
;
const
IMAGE_RESOURCE_DIR_STRING_U
*
str
;
...
...
@@ -588,11 +587,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExA( HMODULE module, ENUMRESTYPEP
if
(
!
module
)
module
=
GetModuleHandleW
(
0
);
if
((
status
=
LdrFindResourceDirectory_U
(
module
,
NULL
,
0
,
&
resdir
))
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
FALSE
;
}
if
(
!
set_ntstatus
(
LdrFindResourceDirectory_U
(
module
,
NULL
,
0
,
&
resdir
)))
return
FALSE
;
et
=
(
const
IMAGE_RESOURCE_DIRECTORY_ENTRY
*
)(
resdir
+
1
);
for
(
i
=
0
;
i
<
resdir
->
NumberOfNamedEntries
+
resdir
->
NumberOfIdEntries
;
i
++
)
{
...
...
@@ -630,7 +626,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExW( HMODULE module, ENUMRESTYPEP
int
i
,
len
=
0
;
BOOL
ret
=
FALSE
;
LPWSTR
type
=
NULL
;
NTSTATUS
status
;
const
IMAGE_RESOURCE_DIRECTORY
*
resdir
;
const
IMAGE_RESOURCE_DIRECTORY_ENTRY
*
et
;
const
IMAGE_RESOURCE_DIR_STRING_U
*
str
;
...
...
@@ -642,11 +637,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumResourceTypesExW( HMODULE module, ENUMRESTYPEP
if
(
!
module
)
module
=
GetModuleHandleW
(
0
);
if
((
status
=
LdrFindResourceDirectory_U
(
module
,
NULL
,
0
,
&
resdir
))
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
FALSE
;
}
if
(
!
set_ntstatus
(
LdrFindResourceDirectory_U
(
module
,
NULL
,
0
,
&
resdir
)))
return
FALSE
;
et
=
(
const
IMAGE_RESOURCE_DIRECTORY_ENTRY
*
)(
resdir
+
1
);
for
(
i
=
0
;
i
<
resdir
->
NumberOfNamedEntries
+
resdir
->
NumberOfIdEntries
;
i
++
)
{
...
...
@@ -735,15 +727,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeResource( HGLOBAL handle )
*/
HGLOBAL
WINAPI
DECLSPEC_HOTPATCH
LoadResource
(
HINSTANCE
module
,
HRSRC
rsrc
)
{
NTSTATUS
status
;
void
*
ret
=
NULL
;
void
*
ret
;
TRACE
(
"%p %p
\n
"
,
module
,
rsrc
);
if
(
!
rsrc
)
return
0
;
if
(
!
module
)
module
=
GetModuleHandleW
(
0
);
status
=
LdrAccessResource
(
module
,
(
IMAGE_RESOURCE_DATA_ENTRY
*
)
rsrc
,
&
ret
,
NULL
);
if
(
status
!=
STATUS_SUCCESS
)
SetLastError
(
RtlNtStatusToDosError
(
status
)
)
;
if
(
!
set_ntstatus
(
LdrAccessResource
(
module
,
(
IMAGE_RESOURCE_DATA_ENTRY
*
)
rsrc
,
&
ret
,
NULL
)))
return
0
;
return
ret
;
}
...
...
@@ -795,16 +786,11 @@ void WINAPI DECLSPEC_HOTPATCH AddRefActCtx( HANDLE context )
*/
HANDLE
WINAPI
DECLSPEC_HOTPATCH
CreateActCtxW
(
PCACTCTXW
ctx
)
{
NTSTATUS
status
;
HANDLE
context
;
TRACE
(
"%p %08x
\n
"
,
ctx
,
ctx
?
ctx
->
dwFlags
:
0
);
if
((
status
=
RtlCreateActivationContext
(
&
context
,
ctx
)))
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
INVALID_HANDLE_VALUE
;
}
if
(
!
set_ntstatus
(
RtlCreateActivationContext
(
&
context
,
ctx
)))
return
INVALID_HANDLE_VALUE
;
return
context
;
}
...
...
dlls/kernelbase/main.c
View file @
31d522ea
...
...
@@ -202,23 +202,13 @@ BOOL WINAPI QuirkIsEnabled3(void *unk1, void *unk2)
BOOL
WINAPI
WaitOnAddress
(
volatile
void
*
addr
,
void
*
cmp
,
SIZE_T
size
,
DWORD
timeout
)
{
LARGE_INTEGER
to
;
NTSTATUS
status
;
if
(
timeout
!=
INFINITE
)
{
to
.
QuadPart
=
-
(
LONGLONG
)
timeout
*
10000
;
status
=
RtlWaitOnAddress
((
const
void
*
)
addr
,
cmp
,
size
,
&
to
);
return
set_ntstatus
(
RtlWaitOnAddress
(
(
const
void
*
)
addr
,
cmp
,
size
,
&
to
)
);
}
else
status
=
RtlWaitOnAddress
((
const
void
*
)
addr
,
cmp
,
size
,
NULL
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
FALSE
;
}
return
TRUE
;
return
set_ntstatus
(
RtlWaitOnAddress
(
(
const
void
*
)
addr
,
cmp
,
size
,
NULL
));
}
HRESULT
WINAPI
QISearch
(
void
*
base
,
const
QITAB
*
table
,
REFIID
riid
,
void
**
obj
)
...
...
dlls/kernelbase/memory.c
View file @
31d522ea
...
...
@@ -51,12 +51,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(heap);
BOOL
WINAPI
DECLSPEC_HOTPATCH
FlushViewOfFile
(
const
void
*
base
,
SIZE_T
size
)
{
NTSTATUS
status
=
NtFlushVirtualMemory
(
GetCurrentProcess
(),
&
base
,
&
size
,
0
);
if
(
status
)
{
if
(
status
==
STATUS_NOT_MAPPED_DATA
)
status
=
STATUS_SUCCESS
;
else
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
}
return
!
status
;
if
(
status
==
STATUS_NOT_MAPPED_DATA
)
status
=
STATUS_SUCCESS
;
return
set_ntstatus
(
status
);
}
...
...
dlls/kernelbase/sync.c
View file @
31d522ea
...
...
@@ -148,18 +148,12 @@ static HANDLE normalize_handle_if_console( HANDLE handle )
HANDLE
WINAPI
DECLSPEC_HOTPATCH
RegisterWaitForSingleObjectEx
(
HANDLE
handle
,
WAITORTIMERCALLBACK
callback
,
PVOID
context
,
ULONG
timeout
,
ULONG
flags
)
{
NTSTATUS
status
;
HANDLE
ret
;
TRACE
(
"%p %p %p %d %d
\n
"
,
handle
,
callback
,
context
,
timeout
,
flags
);
handle
=
normalize_handle_if_console
(
handle
);
status
=
RtlRegisterWait
(
&
ret
,
handle
,
callback
,
context
,
timeout
,
flags
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
NULL
;
}
if
(
!
set_ntstatus
(
RtlRegisterWait
(
&
ret
,
handle
,
callback
,
context
,
timeout
,
flags
)))
return
NULL
;
return
ret
;
}
...
...
@@ -388,18 +382,12 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW( DWORD access, BOOL inherit, LPCWSTR
HANDLE
ret
;
UNICODE_STRING
nameW
;
OBJECT_ATTRIBUTES
attr
;
NTSTATUS
status
;
if
(
!
is_version_nt
())
access
=
EVENT_ALL_ACCESS
;
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenEvent
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
0
;
}
if
(
!
set_ntstatus
(
NtOpenEvent
(
&
ret
,
access
,
&
attr
)))
return
0
;
return
ret
;
}
...
...
@@ -505,18 +493,12 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexW( DWORD access, BOOL inherit, LPCWSTR
HANDLE
ret
;
UNICODE_STRING
nameW
;
OBJECT_ATTRIBUTES
attr
;
NTSTATUS
status
;
if
(
!
is_version_nt
())
access
=
MUTEX_ALL_ACCESS
;
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenMutant
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
0
;
}
if
(
!
set_ntstatus
(
NtOpenMutant
(
&
ret
,
access
,
&
attr
)))
return
0
;
return
ret
;
}
...
...
@@ -575,18 +557,12 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreW( DWORD access, BOOL inherit, LPCW
HANDLE
ret
;
UNICODE_STRING
nameW
;
OBJECT_ATTRIBUTES
attr
;
NTSTATUS
status
;
if
(
!
is_version_nt
())
access
=
SEMAPHORE_ALL_ACCESS
;
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenSemaphore
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
0
;
}
if
(
!
set_ntstatus
(
NtOpenSemaphore
(
&
ret
,
access
,
&
attr
)))
return
0
;
return
ret
;
}
...
...
@@ -646,18 +622,12 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenWaitableTimerW( DWORD access, BOOL inherit,
HANDLE
handle
;
UNICODE_STRING
nameW
;
OBJECT_ATTRIBUTES
attr
;
NTSTATUS
status
;
if
(
!
is_version_nt
())
access
=
TIMER_ALL_ACCESS
;
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
status
=
NtOpenTimer
(
&
handle
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
0
;
}
if
(
!
set_ntstatus
(
NtOpenTimer
(
&
handle
,
access
,
&
attr
)))
return
0
;
return
handle
;
}
...
...
@@ -709,13 +679,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH CancelWaitableTimer( HANDLE handle )
HANDLE
WINAPI
DECLSPEC_HOTPATCH
CreateTimerQueue
(
void
)
{
HANDLE
q
;
NTSTATUS
status
=
RtlCreateTimerQueue
(
&
q
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
));
return
NULL
;
}
if
(
!
set_ntstatus
(
RtlCreateTimerQueue
(
&
q
)))
return
NULL
;
return
q
;
}
...
...
@@ -864,7 +829,6 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenFileMappingW( DWORD access, BOOL inherit, LP
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
HANDLE
ret
;
NTSTATUS
status
;
if
(
!
get_open_object_attributes
(
&
attr
,
&
nameW
,
inherit
,
name
))
return
0
;
...
...
@@ -876,12 +840,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenFileMappingW( DWORD access, BOOL inherit, LP
if
(
!
NtOpenSection
(
&
ret
,
access
|
SECTION_MAP_READ
|
SECTION_MAP_WRITE
,
&
attr
))
return
ret
;
}
status
=
NtOpenSection
(
&
ret
,
access
,
&
attr
);
if
(
status
!=
STATUS_SUCCESS
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
0
;
}
if
(
!
set_ntstatus
(
NtOpenSection
(
&
ret
,
access
,
&
attr
)))
return
0
;
return
ret
;
}
...
...
@@ -929,18 +888,14 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateIoCompletionPort( HANDLE handle, HANDLE po
{
FILE_COMPLETION_INFORMATION
info
;
IO_STATUS_BLOCK
iosb
;
NTSTATUS
status
;
HANDLE
ret
=
port
;
TRACE
(
"(%p, %p, %08lx, %08x)
\n
"
,
handle
,
port
,
key
,
threads
);
if
(
!
port
)
{
if
((
status
=
NtCreateIoCompletion
(
&
ret
,
IO_COMPLETION_ALL_ACCESS
,
NULL
,
threads
)))
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
if
(
!
set_ntstatus
(
NtCreateIoCompletion
(
&
ret
,
IO_COMPLETION_ALL_ACCESS
,
NULL
,
threads
)))
return
0
;
}
}
else
if
(
handle
==
INVALID_HANDLE_VALUE
)
{
...
...
@@ -952,10 +907,9 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateIoCompletionPort( HANDLE handle, HANDLE po
{
info
.
CompletionPort
=
ret
;
info
.
CompletionKey
=
key
;
if
(
(
status
=
NtSetInformationFile
(
handle
,
&
iosb
,
&
info
,
sizeof
(
info
),
FileCompletionInformation
)))
if
(
!
set_ntstatus
(
NtSetInformationFile
(
handle
,
&
iosb
,
&
info
,
sizeof
(
info
),
FileCompletionInformation
)))
{
if
(
!
port
)
CloseHandle
(
ret
);
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
0
;
}
}
...
...
@@ -1163,11 +1117,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateNamedPipeW( LPCWSTR name, DWORD open_mode,
FILE_OVERWRITE_IF
,
options
,
pipe_type
,
read_mode
,
non_block
,
instances
,
in_buff
,
out_buff
,
&
time
);
RtlFreeUnicodeString
(
&
nt_name
);
if
(
status
)
{
handle
=
INVALID_HANDLE_VALUE
;
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
}
if
(
!
set_ntstatus
(
status
))
return
INVALID_HANDLE_VALUE
;
return
handle
;
}
...
...
@@ -1243,14 +1193,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetNamedPipeInfo( HANDLE pipe, LPDWORD flags, LPDW
{
FILE_PIPE_LOCAL_INFORMATION
info
;
IO_STATUS_BLOCK
iosb
;
NTSTATUS
status
;
status
=
NtQueryInformationFile
(
pipe
,
&
iosb
,
&
info
,
sizeof
(
info
),
FilePipeLocalInformation
);
if
(
status
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
if
(
!
set_ntstatus
(
NtQueryInformationFile
(
pipe
,
&
iosb
,
&
info
,
sizeof
(
info
),
FilePipeLocalInformation
)))
return
FALSE
;
}
if
(
flags
)
{
*
flags
=
(
info
.
NamedPipeEnd
&
FILE_PIPE_SERVER_END
)
?
PIPE_SERVER_END
:
PIPE_CLIENT_END
;
...
...
dlls/kernelbase/thread.c
View file @
31d522ea
...
...
@@ -74,7 +74,6 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateRemoteThreadEx( HANDLE process, SECURITY_A
{
HANDLE
handle
;
CLIENT_ID
client_id
;
NTSTATUS
status
;
SIZE_T
stack_reserve
=
0
,
stack_commit
=
0
;
if
(
attributes
)
FIXME
(
"thread attributes ignored
\n
"
);
...
...
@@ -82,30 +81,24 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateRemoteThreadEx( HANDLE process, SECURITY_A
if
(
flags
&
STACK_SIZE_PARAM_IS_A_RESERVATION
)
stack_reserve
=
stack
;
else
stack_commit
=
stack
;
status
=
RtlCreateUserThread
(
process
,
sa
?
sa
->
lpSecurityDescriptor
:
NULL
,
TRUE
,
NULL
,
stack_reserve
,
stack_commit
,
(
PRTL_THREAD_START_ROUTINE
)
start
,
param
,
&
handle
,
&
client_id
);
if
(
status
==
STATUS_SUCCESS
)
if
(
!
set_ntstatus
(
RtlCreateUserThread
(
process
,
sa
?
sa
->
lpSecurityDescriptor
:
NULL
,
TRUE
,
NULL
,
stack_reserve
,
stack_commit
,
(
PRTL_THREAD_START_ROUTINE
)
start
,
param
,
&
handle
,
&
client_id
)))
return
0
;
if
(
id
)
*
id
=
HandleToULong
(
client_id
.
UniqueThread
);
if
(
sa
&&
sa
->
nLength
>=
sizeof
(
*
sa
)
&&
sa
->
bInheritHandle
)
SetHandleInformation
(
handle
,
HANDLE_FLAG_INHERIT
,
HANDLE_FLAG_INHERIT
);
if
(
!
(
flags
&
CREATE_SUSPENDED
))
{
if
(
id
)
*
id
=
HandleToULong
(
client_id
.
UniqueThread
);
if
(
sa
&&
sa
->
nLength
>=
sizeof
(
*
sa
)
&&
sa
->
bInheritHandle
)
SetHandleInformation
(
handle
,
HANDLE_FLAG_INHERIT
,
HANDLE_FLAG_INHERIT
);
if
(
!
(
flags
&
CREATE_SUSPENDED
))
ULONG
ret
;
if
(
NtResumeThread
(
handle
,
&
ret
))
{
ULONG
ret
;
if
(
NtResumeThread
(
handle
,
&
ret
))
{
NtClose
(
handle
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
handle
=
0
;
}
NtClose
(
handle
);
SetLastError
(
ERROR_NOT_ENOUGH_MEMORY
);
handle
=
0
;
}
}
else
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
handle
=
0
;
}
return
handle
;
}
...
...
@@ -292,12 +285,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetThreadTimes( HANDLE thread, LPFILETIME creation
LPFILETIME
kerneltime
,
LPFILETIME
usertime
)
{
KERNEL_USER_TIMES
times
;
NTSTATUS
status
=
NtQueryInformationThread
(
thread
,
ThreadTimes
,
&
times
,
sizeof
(
times
),
NULL
);
if
(
status
)
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
if
(
!
set_ntstatus
(
NtQueryInformationThread
(
thread
,
ThreadTimes
,
&
times
,
sizeof
(
times
),
NULL
)))
return
FALSE
;
}
if
(
creationtime
)
{
creationtime
->
dwLowDateTime
=
times
.
CreateTime
.
u
.
LowPart
;
...
...
@@ -857,7 +848,6 @@ LPVOID WINAPI DECLSPEC_HOTPATCH CreateFiberEx( SIZE_T stack_commit, SIZE_T stack
{
struct
fiber_data
*
fiber
;
INITIAL_TEB
stack
;
NTSTATUS
status
;
if
(
!
(
fiber
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
*
fiber
)
)))
{
...
...
@@ -865,9 +855,8 @@ LPVOID WINAPI DECLSPEC_HOTPATCH CreateFiberEx( SIZE_T stack_commit, SIZE_T stack
return
NULL
;
}
if
(
(
status
=
RtlCreateUserStack
(
stack_commit
,
stack_reserve
,
0
,
1
,
1
,
&
stack
)))
if
(
!
set_ntstatus
(
RtlCreateUserStack
(
stack_commit
,
stack_reserve
,
0
,
1
,
1
,
&
stack
)))
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
HeapFree
(
GetProcessHeap
(),
0
,
fiber
);
return
NULL
;
}
...
...
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