Author: weiden
Date: Thu Nov 15 06:08:46 2007
New Revision: 30453
URL:
http://svn.reactos.org/svn/reactos?rev=30453&view=rev
Log:
Translate pointers in ValidateHandle to the user mode mapping
Modified:
trunk/reactos/dll/win32/user32/misc/dllmain.c
trunk/reactos/dll/win32/user32/misc/misc.c
Modified: trunk/reactos/dll/win32/user32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/dllm…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/dllmain.c (original)
+++ trunk/reactos/dll/win32/user32/misc/dllmain.c Thu Nov 15 06:08:46 2007
@@ -5,7 +5,10 @@
static ULONG User32TlsIndex;
HINSTANCE User32Instance;
PUSER_HANDLE_TABLE gHandleTable = NULL;
+PW32PROCESSINFO g_pi = NULL;
+PW32PROCESSINFO
+GetW32ProcessInfo(VOID);
PUSER32_THREAD_DATA
User32GetThreadData()
@@ -51,11 +54,10 @@
(PVOID)User32SetupDefaultCursors;
NtCurrentTeb()->ProcessEnvironmentBlock->KernelCallbackTable[USER32_CALLBACK_HOOKPROC]
=
(PVOID)User32CallHookProcFromKernel;
- {
- PW32THREADINFO ti = (PW32THREADINFO)NtCurrentTeb()->Win32ThreadInfo;
- PW32PROCESSINFO pi = ti->pi;
- gHandleTable = (PUSER_HANDLE_TABLE) pi->UserHandleTable;
- }
+
+ g_pi = GetW32ProcessInfo();
+ gHandleTable = SharedPtrToUser(g_pi->UserHandleTable);
+
/* Allocate an index for user32 thread local data. */
User32TlsIndex = TlsAlloc();
if (User32TlsIndex != TLS_OUT_OF_INDEXES)
Modified: trunk/reactos/dll/win32/user32/misc/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/misc…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/misc.c (original)
+++ trunk/reactos/dll/win32/user32/misc/misc.c Thu Nov 15 06:08:46 2007
@@ -333,6 +333,26 @@
return NULL;
}
+/*
+ * Decide whether an object is located on the desktop or shared heap
+ */
+static const BOOL g_ObjectHeapTypeShared[VALIDATE_TYPE_MONITOR + 1] =
+{
+ FALSE, /* VALIDATE_TYPE_FREE (not used) */
+ FALSE, /* VALIDATE_TYPE_WIN */
+ TRUE, /* VALIDATE_TYPE_MENU */
+ TRUE, /* VALIDATE_TYPE_CURSOR */
+ TRUE, /* VALIDATE_TYPE_MWPOS */
+ TRUE, /* VALIDATE_TYPE_HOOK */
+ FALSE, /* (not used) */
+ FALSE, /* VALIDATE_TYPE_CALLPROC */
+ FALSE, /* VALIDATE_TYPE_ACCEL */
+ FALSE, /* (not used) */
+ FALSE, /* (not used) */
+ FALSE, /* (not used) */
+ TRUE /* VALIDATE_TYPE_MONITOR */
+};
+
//
// Validate Handle and return the pointer to the object.
//
@@ -340,14 +360,22 @@
FASTCALL
ValidateHandle(HANDLE handle, UINT uType)
{
+ PVOID ret;
PW32CLIENTINFO ClientInfo = GetWin32ClientInfo();
+ ASSERT(uType <= VALIDATE_TYPE_MONITOR);
+ ASSERT(ClientInfo != NULL);
+
+ /* See if we have the handle cached still */
if (uType == VALIDATE_TYPE_WIN)
{
if (handle == ClientInfo->hWND) return ClientInfo->pvWND;
}
PUSER_HANDLE_ENTRY pEntry = GetUser32Handle(handle);
+
+ if (pEntry && uType == 0)
+ uType = pEntry->type;
// Must have an entry and must be the same type!
if ( (!pEntry) || (pEntry->type != uType) )
@@ -374,13 +402,28 @@
break;
default:
SetLastError(ERROR_INVALID_HANDLE);
+ break;
}
return NULL;
}
if (!(NtUserValidateHandleSecure(handle, FALSE))) return NULL;
- return pEntry->ptr;
-}
-
-
+ if (g_ObjectHeapTypeShared[uType])
+ ret = SharedPtrToUser(pEntry->ptr);
+ else
+ ret = DesktopPtrToUser(pEntry->ptr);
+
+ /* Update the cache */
+#if 0
+ /* FIXME: To enable this win32k needs to check this information when destroying
+ the window handle and clear it out of the ClientInfo structure! */
+ if (uType == VALIDATE_TYPE_WIN)
+ {
+ ClientInfo->hWND = handle;
+ ClientInfo->pvWND = ret;
+ }
+#endif
+
+ return ret;
+}