Commit e076fff5 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Use set_ntstatus() in more places.

parent 61338905
......@@ -1252,12 +1252,7 @@ BOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput, LPCVOID lpBuffer, DWORD nNumber
FIXME("Conversion not supported yet\n");
}
HeapFree(GetProcessHeap(), 0, ptr);
if (status != STATUS_SUCCESS)
{
SetLastError(RtlNtStatusToDosError(status));
return FALSE;
}
return TRUE;
return set_ntstatus( status );
}
if (!GetConsoleMode(hConsoleOutput, &mode) || !GetConsoleScreenBufferInfo(hConsoleOutput, &csbi))
......
......@@ -150,13 +150,7 @@ void WINAPI DECLSPEC_HOTPATCH OutputDebugStringA( LPCSTR str )
*/
BOOL WINAPI DebugBreakProcess(HANDLE process)
{
NTSTATUS status;
TRACE("(%p)\n", process);
status = DbgUiIssueRemoteBreakin(process);
if (status) SetLastError(RtlNtStatusToDosError(status));
return !status;
return set_ntstatus( DbgUiIssueRemoteBreakin( process ));
}
......
......@@ -336,13 +336,10 @@ BOOL WINAPI SetFileCompletionNotificationModes( HANDLE file, UCHAR flags )
{
FILE_IO_COMPLETION_NOTIFICATION_INFORMATION info;
IO_STATUS_BLOCK io;
NTSTATUS status;
info.Flags = flags;
status = NtSetInformationFile( file, &io, &info, sizeof(info), FileIoCompletionNotificationInformation );
if (status == STATUS_SUCCESS) return TRUE;
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
return set_ntstatus( NtSetInformationFile( file, &io, &info, sizeof(info),
FileIoCompletionNotificationInformation ));
}
......@@ -534,8 +531,7 @@ BOOL WINAPI DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode,
lpvOutBuffer, cbOutBuffer);
if (lpcbBytesReturned) *lpcbBytesReturned = iosb.Information;
}
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
return set_ntstatus( status );
}
......
......@@ -26,6 +26,7 @@
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "kernel_private.h"
#include "wine/debug.h"
#include "wine/heap.h"
......@@ -173,9 +174,8 @@ HANDLE WINAPI PowerCreateRequest(REASON_CONTEXT *context)
status = NtCreatePowerRequest( &handle, &nt_context );
if (nt_context.Flags & POWER_REQUEST_CONTEXT_DETAILED_STRING)
heap_free( nt_context.u.s.ReasonStrings );
if (status)
SetLastError( RtlNtStatusToDosError(status) );
return status == STATUS_SUCCESS ? handle : INVALID_HANDLE_VALUE;
if (!set_ntstatus( status )) return INVALID_HANDLE_VALUE;
return handle;
}
/***********************************************************************
......@@ -183,10 +183,7 @@ HANDLE WINAPI PowerCreateRequest(REASON_CONTEXT *context)
*/
BOOL WINAPI PowerSetRequest(HANDLE request, POWER_REQUEST_TYPE type)
{
NTSTATUS status = NtSetPowerRequest( request, type );
if (status)
SetLastError( RtlNtStatusToDosError(status) );
return status == STATUS_SUCCESS;
return set_ntstatus( NtSetPowerRequest( request, type ));
}
/***********************************************************************
......@@ -194,8 +191,5 @@ BOOL WINAPI PowerSetRequest(HANDLE request, POWER_REQUEST_TYPE type)
*/
BOOL WINAPI PowerClearRequest(HANDLE request, POWER_REQUEST_TYPE type)
{
NTSTATUS status = NtClearPowerRequest( request, type );
if (status)
SetLastError( RtlNtStatusToDosError(status) );
return status == STATUS_SUCCESS;
return set_ntstatus( NtClearPowerRequest( request, type ));
}
......@@ -103,41 +103,21 @@ static HANDLE normalize_handle_if_console(HANDLE handle)
/***********************************************************************
* RegisterWaitForSingleObject (KERNEL32.@)
*/
BOOL WINAPI RegisterWaitForSingleObject(PHANDLE phNewWaitObject, HANDLE hObject,
WAITORTIMERCALLBACK Callback, PVOID Context,
ULONG dwMilliseconds, ULONG dwFlags)
BOOL WINAPI RegisterWaitForSingleObject( HANDLE *wait, HANDLE object, WAITORTIMERCALLBACK callback,
void *context, ULONG timeout, ULONG flags )
{
NTSTATUS status;
TRACE("%p %p %p %p %d %d\n",
phNewWaitObject,hObject,Callback,Context,dwMilliseconds,dwFlags);
TRACE( "%p %p %p %p %d %d\n", wait, object, callback, context, timeout, flags );
hObject = normalize_handle_if_console(hObject);
status = RtlRegisterWait( phNewWaitObject, hObject, Callback, Context, dwMilliseconds, dwFlags );
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
return TRUE;
object = normalize_handle_if_console( object );
return set_ntstatus( RtlRegisterWait( wait, object, callback, context, timeout, flags ));
}
/***********************************************************************
* UnregisterWait (KERNEL32.@)
*/
BOOL WINAPI UnregisterWait( HANDLE WaitHandle )
BOOL WINAPI UnregisterWait( HANDLE handle )
{
NTSTATUS status;
TRACE("%p\n",WaitHandle);
status = RtlDeregisterWait( WaitHandle );
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
return TRUE;
return set_ntstatus( RtlDeregisterWait( handle ));
}
/***********************************************************************
......@@ -310,16 +290,10 @@ HANDLE WINAPI OpenJobObjectW( DWORD access, BOOL inherit, LPCWSTR name )
HANDLE ret;
UNICODE_STRING nameW;
OBJECT_ATTRIBUTES attr;
NTSTATUS status;
if (!get_open_object_attributes( &attr, &nameW, inherit, name )) return 0;
status = NtOpenJobObject( &ret, access, &attr );
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
if (!set_ntstatus( NtOpenJobObject( &ret, access, &attr ))) return 0;
return ret;
}
......@@ -345,9 +319,7 @@ HANDLE WINAPI OpenJobObjectA( DWORD access, BOOL inherit, LPCSTR name )
*/
BOOL WINAPI TerminateJobObject( HANDLE job, UINT exit_code )
{
NTSTATUS status = NtTerminateJobObject( job, exit_code );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
return set_ntstatus( NtTerminateJobObject( job, exit_code ));
}
/******************************************************************************
......@@ -356,9 +328,7 @@ BOOL WINAPI TerminateJobObject( HANDLE job, UINT exit_code )
BOOL WINAPI QueryInformationJobObject( HANDLE job, JOBOBJECTINFOCLASS class, LPVOID info,
DWORD len, DWORD *ret_len )
{
NTSTATUS status = NtQueryInformationJobObject( job, class, info, len, ret_len );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
return set_ntstatus( NtQueryInformationJobObject( job, class, info, len, ret_len ));
}
/******************************************************************************
......@@ -366,9 +336,7 @@ BOOL WINAPI QueryInformationJobObject( HANDLE job, JOBOBJECTINFOCLASS class, LPV
*/
BOOL WINAPI SetInformationJobObject( HANDLE job, JOBOBJECTINFOCLASS class, LPVOID info, DWORD len )
{
NTSTATUS status = NtSetInformationJobObject( job, class, info, len );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
return set_ntstatus( NtSetInformationJobObject( job, class, info, len ));
}
/******************************************************************************
......@@ -376,9 +344,7 @@ BOOL WINAPI SetInformationJobObject( HANDLE job, JOBOBJECTINFOCLASS class, LPVOI
*/
BOOL WINAPI AssignProcessToJobObject( HANDLE job, HANDLE process )
{
NTSTATUS status = NtAssignProcessToJobObject( job, process );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
return set_ntstatus( NtAssignProcessToJobObject( job, process ));
}
......@@ -545,18 +511,10 @@ BOOL WINAPI WaitNamedPipeA (LPCSTR name, DWORD nTimeOut)
BOOL WINAPI GetNamedPipeClientProcessId( HANDLE pipe, ULONG *id )
{
IO_STATUS_BLOCK iosb;
NTSTATUS status;
TRACE( "%p %p\n", pipe, id );
status = NtFsControlFile( pipe, NULL, NULL, NULL, &iosb, FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE,
(void *)"ClientProcessId", sizeof("ClientProcessId"), id, sizeof(*id) );
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
return TRUE;
return set_ntstatus( NtFsControlFile( pipe, NULL, NULL, NULL, &iosb,
FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ClientProcessId",
sizeof("ClientProcessId"), id, sizeof(*id) ));
}
/***********************************************************************
......@@ -565,18 +523,10 @@ BOOL WINAPI GetNamedPipeClientProcessId( HANDLE pipe, ULONG *id )
BOOL WINAPI GetNamedPipeServerProcessId( HANDLE pipe, ULONG *id )
{
IO_STATUS_BLOCK iosb;
NTSTATUS status;
TRACE( "%p, %p\n", pipe, id );
status = NtFsControlFile( pipe, NULL, NULL, NULL, &iosb, FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE,
(void *)"ServerProcessId", sizeof("ServerProcessId"), id, sizeof(*id) );
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
return TRUE;
return set_ntstatus( NtFsControlFile( pipe, NULL, NULL, NULL, &iosb,
FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ServerProcessId",
sizeof("ServerProcessId"), id, sizeof(*id) ));
}
/***********************************************************************
......@@ -712,7 +662,6 @@ HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
UNICODE_STRING nameW;
LARGE_INTEGER timeout;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
TRACE("%s %d %d %p\n", debugstr_w(lpName),
nMaxMessageSize, lReadTimeout, sa);
......@@ -742,13 +691,9 @@ HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
else
timeout.QuadPart = ((LONGLONG)0x7fffffff << 32) | 0xffffffff;
status = NtCreateMailslotFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr,
&iosb, 0, 0, nMaxMessageSize, &timeout );
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
if (!set_ntstatus( NtCreateMailslotFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr,
&iosb, 0, 0, nMaxMessageSize, &timeout )))
handle = INVALID_HANDLE_VALUE;
}
RtlFreeUnicodeString( &nameW );
return handle;
......@@ -777,19 +722,13 @@ BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
{
FILE_MAILSLOT_QUERY_INFORMATION info;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
TRACE("%p %p %p %p %p\n",hMailslot, lpMaxMessageSize,
lpNextSize, lpMessageCount, lpReadTimeout);
status = NtQueryInformationFile( hMailslot, &iosb, &info, sizeof info,
FileMailslotQueryInformation );
if( status != STATUS_SUCCESS )
{
SetLastError( RtlNtStatusToDosError(status) );
if (!set_ntstatus( NtQueryInformationFile( hMailslot, &iosb, &info, sizeof info,
FileMailslotQueryInformation )))
return FALSE;
}
if( lpMaxMessageSize )
*lpMaxMessageSize = info.MaximumMessageSize;
......@@ -825,7 +764,6 @@ BOOL WINAPI SetMailslotInfo( HANDLE hMailslot, DWORD dwReadTimeout)
{
FILE_MAILSLOT_SET_INFORMATION info;
IO_STATUS_BLOCK iosb;
NTSTATUS status;
TRACE("%p %d\n", hMailslot, dwReadTimeout);
......@@ -833,30 +771,17 @@ BOOL WINAPI SetMailslotInfo( HANDLE hMailslot, DWORD dwReadTimeout)
info.ReadTimeout.QuadPart = (ULONGLONG)dwReadTimeout * -10000;
else
info.ReadTimeout.QuadPart = ((LONGLONG)0x7fffffff << 32) | 0xffffffff;
status = NtSetInformationFile( hMailslot, &iosb, &info, sizeof info,
FileMailslotSetInformation );
if( status != STATUS_SUCCESS )
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
return TRUE;
return set_ntstatus( NtSetInformationFile( hMailslot, &iosb, &info, sizeof info,
FileMailslotSetInformation ));
}
/******************************************************************************
* BindIoCompletionCallback (KERNEL32.@)
*/
BOOL WINAPI BindIoCompletionCallback( HANDLE FileHandle, LPOVERLAPPED_COMPLETION_ROUTINE Function, ULONG Flags)
BOOL WINAPI BindIoCompletionCallback( HANDLE handle, LPOVERLAPPED_COMPLETION_ROUTINE func, ULONG flags )
{
NTSTATUS status;
TRACE("(%p, %p, %d)\n", FileHandle, Function, Flags);
status = RtlSetIoCompletionCallback( FileHandle, (PRTL_OVERLAPPED_COMPLETION_ROUTINE)Function, Flags );
if (status == STATUS_SUCCESS) return TRUE;
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
return set_ntstatus( RtlSetIoCompletionCallback( handle, (PRTL_OVERLAPPED_COMPLETION_ROUTINE)func, flags ));
}
......
......@@ -50,14 +50,12 @@ void WINAPI FreeLibraryAndExitThread(HINSTANCE hLibModule, DWORD dwExitCode)
BOOL WINAPI Wow64SetThreadContext( HANDLE handle, const WOW64_CONTEXT *context)
{
#ifdef __i386__
NTSTATUS status = NtSetContextThread( handle, (const CONTEXT *)context );
return set_ntstatus( NtSetContextThread( handle, (const CONTEXT *)context ));
#elif defined(__x86_64__)
NTSTATUS status = RtlWow64SetThreadContext( handle, context );
return set_ntstatus( RtlWow64SetThreadContext( handle, context ));
#else
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
return set_ntstatus( STATUS_NOT_IMPLEMENTED );
#endif
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
/***********************************************************************
......@@ -66,40 +64,26 @@ BOOL WINAPI Wow64SetThreadContext( HANDLE handle, const WOW64_CONTEXT *context)
BOOL WINAPI Wow64GetThreadContext( HANDLE handle, WOW64_CONTEXT *context)
{
#ifdef __i386__
NTSTATUS status = NtGetContextThread( handle, (CONTEXT *)context );
return set_ntstatus( NtGetContextThread( handle, (CONTEXT *)context ));
#elif defined(__x86_64__)
NTSTATUS status = RtlWow64GetThreadContext( handle, context );
return set_ntstatus( RtlWow64GetThreadContext( handle, context ));
#else
NTSTATUS status = STATUS_NOT_IMPLEMENTED;
return set_ntstatus( STATUS_NOT_IMPLEMENTED );
#endif
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
/**********************************************************************
* SetThreadAffinityMask (KERNEL32.@)
*/
DWORD_PTR WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD_PTR dwThreadAffinityMask )
DWORD_PTR WINAPI SetThreadAffinityMask( HANDLE thread, DWORD_PTR mask )
{
NTSTATUS status;
THREAD_BASIC_INFORMATION tbi;
status = NtQueryInformationThread( hThread, ThreadBasicInformation,
&tbi, sizeof(tbi), NULL );
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
THREAD_BASIC_INFORMATION tbi;
if (!set_ntstatus( NtQueryInformationThread( thread, ThreadBasicInformation, &tbi, sizeof(tbi), NULL )))
return 0;
}
status = NtSetInformationThread( hThread, ThreadAffinityMask,
&dwThreadAffinityMask,
sizeof(dwThreadAffinityMask));
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
if (!set_ntstatus( NtSetInformationThread( thread, ThreadAffinityMask, &mask, sizeof(mask))))
return 0;
}
return tbi.AffinityMask;
}
......@@ -107,18 +91,14 @@ DWORD_PTR WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD_PTR dwThreadAffini
/***********************************************************************
* GetThreadSelectorEntry (KERNEL32.@)
*/
BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldtent )
BOOL WINAPI GetThreadSelectorEntry( HANDLE thread, DWORD sel, LDT_ENTRY *ldtent )
{
THREAD_DESCRIPTOR_INFORMATION tdi;
NTSTATUS status;
tdi.Selector = sel;
status = NtQueryInformationThread( hthread, ThreadDescriptorTableEntry, &tdi, sizeof(tdi), NULL);
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
if (!set_ntstatus( NtQueryInformationThread( thread, ThreadDescriptorTableEntry,
&tdi, sizeof(tdi), NULL )))
return FALSE;
}
*ldtent = tdi.Entry;
return TRUE;
}
......
......@@ -38,6 +38,7 @@
#include "winnls.h"
#include "winternl.h"
#include "kernel_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(toolhelp);
......@@ -78,7 +79,6 @@ static BOOL fetch_module( DWORD process, DWORD flags, LDR_DATA_TABLE_ENTRY **ldr
HANDLE hProcess;
PROCESS_BASIC_INFORMATION pbi;
PPEB_LDR_DATA pLdrData;
NTSTATUS status;
PLIST_ENTRY head, curr;
BOOL ret = FALSE;
......@@ -94,9 +94,8 @@ static BOOL fetch_module( DWORD process, DWORD flags, LDR_DATA_TABLE_ENTRY **ldr
else
hProcess = GetCurrentProcess();
status = NtQueryInformationProcess( hProcess, ProcessBasicInformation,
&pbi, sizeof(pbi), NULL );
if (!status)
if (set_ntstatus( NtQueryInformationProcess( hProcess, ProcessBasicInformation,
&pbi, sizeof(pbi), NULL )))
{
if (ReadProcessMemory( hProcess, &pbi.PebBaseAddress->LdrData,
&pLdrData, sizeof(pLdrData), NULL ) &&
......@@ -133,7 +132,6 @@ static BOOL fetch_module( DWORD process, DWORD flags, LDR_DATA_TABLE_ENTRY **ldr
ret = TRUE;
}
}
else SetLastError( RtlNtStatusToDosError( status ) );
if (process) CloseHandle( hProcess );
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment