2004-04-09 20:03:21 +00:00
|
|
|
#undef __USE_W32API
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <debug.h>
|
2004-04-09 20:03:21 +00:00
|
|
|
#include <ddk/ntddk.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <user32/callback.h>
|
2003-07-20 03:45:31 +00:00
|
|
|
#include <user32/accel.h>
|
2002-09-17 23:46:23 +00:00
|
|
|
#include <window.h>
|
2003-07-26 15:48:47 +00:00
|
|
|
#include <menu.h>
|
2004-04-29 21:13:16 +00:00
|
|
|
#include <message.h>
|
2004-04-09 20:03:21 +00:00
|
|
|
#define _WIN32K_KAPI_H
|
2003-08-01 18:45:35 +00:00
|
|
|
#include <user32.h>
|
2003-08-08 02:57:54 +00:00
|
|
|
#include <strpool.h>
|
2004-04-09 21:22:18 +00:00
|
|
|
#include <roscfg.h>
|
2001-06-12 17:35:46 +00:00
|
|
|
|
|
|
|
#ifdef DBG
|
|
|
|
|
|
|
|
/* See debug.h for debug/trace constants */
|
|
|
|
DWORD DebugTraceLevel = MIN_TRACE;
|
|
|
|
|
|
|
|
#endif /* DBG */
|
|
|
|
|
2004-04-09 20:03:21 +00:00
|
|
|
extern CRITICAL_SECTION gcsMPH;
|
2003-08-01 18:45:35 +00:00
|
|
|
static ULONG User32TlsIndex;
|
2004-05-16 19:31:09 +00:00
|
|
|
HINSTANCE User32Instance;
|
2003-08-01 18:45:35 +00:00
|
|
|
|
2001-06-12 17:35:46 +00:00
|
|
|
/* To make the linker happy */
|
|
|
|
VOID STDCALL KeBugCheck (ULONG BugCheckCode) {}
|
|
|
|
|
|
|
|
HWINSTA ProcessWindowStation;
|
|
|
|
|
2003-08-01 18:45:35 +00:00
|
|
|
PUSER32_THREAD_DATA
|
|
|
|
User32GetThreadData()
|
|
|
|
{
|
|
|
|
return((PUSER32_THREAD_DATA)TlsGetValue(User32TlsIndex));
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
InitThread(VOID)
|
|
|
|
{
|
|
|
|
PUSER32_THREAD_DATA ThreadData;
|
|
|
|
|
|
|
|
ThreadData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(USER32_THREAD_DATA));
|
|
|
|
TlsSetValue(User32TlsIndex, ThreadData);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CleanupThread(VOID)
|
|
|
|
{
|
|
|
|
PUSER32_THREAD_DATA ThreadData;
|
|
|
|
|
|
|
|
ThreadData = (PUSER32_THREAD_DATA)TlsGetValue(User32TlsIndex);
|
|
|
|
HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY, ThreadData);
|
|
|
|
TlsSetValue(User32TlsIndex, 0);
|
|
|
|
}
|
|
|
|
|
2001-06-12 17:35:46 +00:00
|
|
|
DWORD
|
|
|
|
Init(VOID)
|
|
|
|
{
|
|
|
|
DWORD Status;
|
|
|
|
|
2002-01-27 01:11:24 +00:00
|
|
|
/* Set up the kernel callbacks. */
|
2004-04-09 20:03:21 +00:00
|
|
|
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_WINDOWPROC] =
|
2002-01-27 01:11:24 +00:00
|
|
|
(PVOID)User32CallWindowProcFromKernel;
|
2004-04-09 20:03:21 +00:00
|
|
|
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_SENDASYNCPROC] =
|
2002-05-06 22:20:32 +00:00
|
|
|
(PVOID)User32CallSendAsyncProcForKernel;
|
2004-04-09 20:03:21 +00:00
|
|
|
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_LOADSYSMENUTEMPLATE] =
|
2003-08-21 20:29:44 +00:00
|
|
|
(PVOID)User32LoadSysMenuTemplateForKernel;
|
2004-04-09 20:03:21 +00:00
|
|
|
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_LOADDEFAULTCURSORS] =
|
2003-08-29 00:24:42 +00:00
|
|
|
(PVOID)User32SetupDefaultCursors;
|
2004-04-09 20:03:21 +00:00
|
|
|
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_HOOKPROC] =
|
2003-12-12 14:22:37 +00:00
|
|
|
(PVOID)User32CallHookProcFromKernel;
|
2002-01-27 01:11:24 +00:00
|
|
|
|
2003-08-01 18:45:35 +00:00
|
|
|
/* Allocate an index for user32 thread local data. */
|
|
|
|
User32TlsIndex = TlsAlloc();
|
|
|
|
|
2003-07-26 15:48:47 +00:00
|
|
|
MenuInit();
|
2004-04-29 21:13:16 +00:00
|
|
|
MessageInit();
|
2003-08-18 09:59:29 +00:00
|
|
|
|
2004-04-09 20:03:21 +00:00
|
|
|
InitializeCriticalSection(&U32AccelCacheLock);
|
|
|
|
InitializeCriticalSection(&gcsMPH);
|
2002-09-17 23:46:23 +00:00
|
|
|
|
2002-08-26 13:06:03 +00:00
|
|
|
GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);
|
2001-06-12 17:35:46 +00:00
|
|
|
|
2002-08-26 13:06:03 +00:00
|
|
|
return(Status);
|
2001-06-12 17:35:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD
|
|
|
|
Cleanup(VOID)
|
|
|
|
{
|
|
|
|
DWORD Status;
|
|
|
|
|
2002-08-26 13:06:03 +00:00
|
|
|
GdiDllInitialize(NULL, DLL_PROCESS_DETACH, NULL);
|
2001-06-12 17:35:46 +00:00
|
|
|
|
2003-08-01 18:45:35 +00:00
|
|
|
TlsFree(User32TlsIndex);
|
|
|
|
|
2002-08-26 13:06:03 +00:00
|
|
|
return(Status);
|
2001-06-12 17:35:46 +00:00
|
|
|
}
|
2000-04-12 22:41:51 +00:00
|
|
|
|
2003-08-01 18:45:35 +00:00
|
|
|
|
|
|
|
|
2002-01-27 01:11:24 +00:00
|
|
|
INT STDCALL
|
2003-08-14 20:25:52 +00:00
|
|
|
DllMain(
|
|
|
|
PVOID hinstDll,
|
|
|
|
ULONG dwReason,
|
|
|
|
PVOID reserved
|
|
|
|
)
|
1999-05-08 07:09:31 +00:00
|
|
|
{
|
2002-01-27 01:11:24 +00:00
|
|
|
switch (dwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2004-05-16 19:31:09 +00:00
|
|
|
User32Instance = hinstDll;
|
2003-08-14 20:25:52 +00:00
|
|
|
hProcessHeap = RtlGetProcessHeap();
|
2001-06-12 17:35:46 +00:00
|
|
|
Init();
|
2004-04-09 20:03:21 +00:00
|
|
|
InitThread();
|
2002-01-27 01:11:24 +00:00
|
|
|
break;
|
|
|
|
case DLL_THREAD_ATTACH:
|
2003-08-01 18:45:35 +00:00
|
|
|
InitThread();
|
2002-01-27 01:11:24 +00:00
|
|
|
break;
|
|
|
|
case DLL_THREAD_DETACH:
|
2003-08-01 18:45:35 +00:00
|
|
|
CleanupThread();
|
2002-01-27 01:11:24 +00:00
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2003-08-22 07:51:32 +00:00
|
|
|
DeleteFrameBrushes();
|
2004-04-09 20:03:21 +00:00
|
|
|
CleanupThread();
|
2001-06-12 17:35:46 +00:00
|
|
|
Cleanup();
|
2002-01-27 01:11:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(1);
|
1999-05-08 07:09:31 +00:00
|
|
|
}
|