Add a test for VM address space when accessing user data.

svn path=/trunk/; revision=30573
This commit is contained in:
James Tabor 2007-11-19 07:41:11 +00:00
parent effad19afc
commit daffd42203
2 changed files with 20 additions and 2 deletions

View file

@ -9,6 +9,7 @@
<library>kernel32</library>
<library>advapi32</library>
<library>win32ksys</library>
<library>pseh</library>
<directory name="include">
<pch>precomp.h</pch>

View file

@ -124,8 +124,25 @@ BOOL GdiGetHandleUserData(HGDIOBJ hGdiObj, PVOID *UserData)
HANDLE pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
if(pid == NULL || pid == CurrentProcessId)
{
*UserData = Entry->UserData;
return TRUE;
//
// Need to test if we have Read & Write access to the VM address space.
//
BOOL Result = TRUE;
if(Entry->UserData)
{
volatile CHAR *Current = (volatile CHAR*)Entry->UserData;
_SEH_TRY
{
*Current = *Current;
}
_SEH_HANDLE
{
Result = FALSE;
}
_SEH_END
}
if (Result) *UserData = Entry->UserData;
return Result;
}
}
SetLastError(ERROR_INVALID_PARAMETER);