kernelbase: Use exception handlers instead of IsBad* functions.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f88404bfb0
commit
a76518c186
|
@ -688,7 +688,20 @@ LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock( HLOCAL hmem )
|
|||
{
|
||||
void *ret = NULL;
|
||||
|
||||
if (is_pointer( hmem )) return IsBadReadPtr( hmem, 1 ) ? NULL : hmem;
|
||||
if (is_pointer( hmem ))
|
||||
{
|
||||
__TRY
|
||||
{
|
||||
volatile char *p = hmem;
|
||||
*p |= 0;
|
||||
}
|
||||
__EXCEPT_PAGE_FAULT
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
__ENDTRY
|
||||
return hmem;
|
||||
}
|
||||
|
||||
RtlLockHeap( GetProcessHeap() );
|
||||
__TRY
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "winternl.h"
|
||||
|
||||
#include "kernelbase.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wine/heap.h"
|
||||
|
||||
|
@ -5049,10 +5050,15 @@ HRESULT WINAPI HashData(const unsigned char *src, DWORD src_len, unsigned char *
|
|||
|
||||
HRESULT WINAPI UrlHashA(const char *url, unsigned char *dest, DWORD dest_len)
|
||||
{
|
||||
if (IsBadStringPtrA(url, -1) || IsBadWritePtr(dest, dest_len))
|
||||
__TRY
|
||||
{
|
||||
HashData((const BYTE *)url, (int)strlen(url), dest, dest_len);
|
||||
}
|
||||
__EXCEPT_PAGE_FAULT
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
|
||||
HashData((const BYTE *)url, (int)strlen(url), dest, dest_len);
|
||||
}
|
||||
__ENDTRY
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -5062,11 +5068,16 @@ HRESULT WINAPI UrlHashW(const WCHAR *url, unsigned char *dest, DWORD dest_len)
|
|||
|
||||
TRACE("%s, %p, %d\n", debugstr_w(url), dest, dest_len);
|
||||
|
||||
if (IsBadStringPtrW(url, -1) || IsBadWritePtr(dest, dest_len))
|
||||
__TRY
|
||||
{
|
||||
WideCharToMultiByte(CP_ACP, 0, url, -1, urlA, MAX_PATH, NULL, NULL);
|
||||
HashData((const BYTE *)urlA, (int)strlen(urlA), dest, dest_len);
|
||||
}
|
||||
__EXCEPT_PAGE_FAULT
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, url, -1, urlA, MAX_PATH, NULL, NULL);
|
||||
HashData((const BYTE *)urlA, (int)strlen(urlA), dest, dest_len);
|
||||
}
|
||||
__ENDTRY
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "kernelbase.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/heap.h"
|
||||
#include "wine/list.h"
|
||||
|
||||
|
@ -3432,8 +3433,16 @@ LONG WINAPI SHRegWriteUSValueW(HUSKEY hUSKey, const WCHAR *value, DWORD type, vo
|
|||
|
||||
TRACE("%p, %s, %d, %p, %d, %#x\n", hUSKey, debugstr_w(value), type, data, data_len, flags);
|
||||
|
||||
if (!hUSKey || IsBadWritePtr(hUSKey, sizeof(struct USKEY)) || !(flags & (SHREGSET_FORCE_HKCU|SHREGSET_FORCE_HKLM)))
|
||||
__TRY
|
||||
{
|
||||
dummy = hKey->HKCUkey || hKey->HKLMkey;
|
||||
}
|
||||
__EXCEPT_PAGE_FAULT
|
||||
{
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
__ENDTRY
|
||||
if (!(flags & (SHREGSET_FORCE_HKCU|SHREGSET_FORCE_HKLM))) return ERROR_INVALID_PARAMETER;
|
||||
|
||||
if (flags & (SHREGSET_FORCE_HKCU | SHREGSET_HKCU))
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "kernelbase.h"
|
||||
#include "wine/asm.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(sync);
|
||||
|
@ -336,14 +337,16 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventExW( SECURITY_ATTRIBUTES *sa, LPCWSTR
|
|||
/* one buggy program needs this
|
||||
* ("Van Dale Groot woordenboek der Nederlandse taal")
|
||||
*/
|
||||
if (sa && IsBadReadPtr(sa,sizeof(SECURITY_ATTRIBUTES)))
|
||||
__TRY
|
||||
{
|
||||
get_create_object_attributes( &attr, &nameW, sa, name );
|
||||
}
|
||||
__EXCEPT_PAGE_FAULT
|
||||
{
|
||||
ERR("Bad security attributes pointer %p\n",sa);
|
||||
SetLastError( ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
get_create_object_attributes( &attr, &nameW, sa, name );
|
||||
__ENDTRY
|
||||
|
||||
status = NtCreateEvent( &ret, access, &attr,
|
||||
(flags & CREATE_EVENT_MANUAL_RESET) ? NotificationEvent : SynchronizationEvent,
|
||||
|
|
Loading…
Reference in New Issue