Commit a76518c1 authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Use exception handlers instead of IsBad* functions.

parent f88404bf
...@@ -688,7 +688,20 @@ LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock( HLOCAL hmem ) ...@@ -688,7 +688,20 @@ LPVOID WINAPI DECLSPEC_HOTPATCH LocalLock( HLOCAL hmem )
{ {
void *ret = NULL; 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() ); RtlLockHeap( GetProcessHeap() );
__TRY __TRY
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "winternl.h" #include "winternl.h"
#include "kernelbase.h" #include "kernelbase.h"
#include "wine/exception.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h" #include "wine/heap.h"
...@@ -5049,10 +5050,15 @@ HRESULT WINAPI HashData(const unsigned char *src, DWORD src_len, unsigned char * ...@@ -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) 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; return E_INVALIDARG;
}
HashData((const BYTE *)url, (int)strlen(url), dest, dest_len); __ENDTRY
return S_OK; return S_OK;
} }
...@@ -5062,11 +5068,16 @@ HRESULT WINAPI UrlHashW(const WCHAR *url, unsigned char *dest, DWORD dest_len) ...@@ -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); 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; return E_INVALIDARG;
}
WideCharToMultiByte(CP_ACP, 0, url, -1, urlA, MAX_PATH, NULL, NULL); __ENDTRY
HashData((const BYTE *)urlA, (int)strlen(urlA), dest, dest_len);
return S_OK; return S_OK;
} }
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "kernelbase.h" #include "kernelbase.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/exception.h"
#include "wine/heap.h" #include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
...@@ -3432,8 +3433,16 @@ LONG WINAPI SHRegWriteUSValueW(HUSKEY hUSKey, const WCHAR *value, DWORD type, vo ...@@ -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); 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; return ERROR_INVALID_PARAMETER;
}
__ENDTRY
if (!(flags & (SHREGSET_FORCE_HKCU|SHREGSET_FORCE_HKLM))) return ERROR_INVALID_PARAMETER;
if (flags & (SHREGSET_FORCE_HKCU | SHREGSET_HKCU)) if (flags & (SHREGSET_FORCE_HKCU | SHREGSET_HKCU))
{ {
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "kernelbase.h" #include "kernelbase.h"
#include "wine/asm.h" #include "wine/asm.h"
#include "wine/exception.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(sync); WINE_DEFAULT_DEBUG_CHANNEL(sync);
...@@ -336,14 +337,16 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventExW( SECURITY_ATTRIBUTES *sa, LPCWSTR ...@@ -336,14 +337,16 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventExW( SECURITY_ATTRIBUTES *sa, LPCWSTR
/* one buggy program needs this /* one buggy program needs this
* ("Van Dale Groot woordenboek der Nederlandse taal") * ("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); SetLastError( ERROR_INVALID_PARAMETER);
return 0; return 0;
} }
__ENDTRY
get_create_object_attributes( &attr, &nameW, sa, name );
status = NtCreateEvent( &ret, access, &attr, status = NtCreateEvent( &ret, access, &attr,
(flags & CREATE_EVENT_MANUAL_RESET) ? NotificationEvent : SynchronizationEvent, (flags & CREATE_EVENT_MANUAL_RESET) ? NotificationEvent : SynchronizationEvent,
......
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