* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-/* $Id$
- *
+/*
* Entry Point for win32k.sys
*/
-#include <w32k.h>
+#include <win32k.h>
#include <include/napi.h>
#define NDEBUG
#include <debug.h>
+HANDLE hModuleWin;
+
PGDI_HANDLE_TABLE INTERNAL_CALL GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject);
BOOL INTERNAL_CALL GDI_CleanupForProcess (struct _EPROCESS *Process);
/* FIXME */
HSEMAPHORE hsemDriverMgmt = NULL;
+SHORT gusLanguageID;
+
extern ULONG_PTR Win32kSSDT[];
extern UCHAR Win32kSSPT[];
extern ULONG Win32kNumberOfSysCalls;
NTSTATUS
-STDCALL
+APIENTRY
Win32kProcessCallback(struct _EPROCESS *Process,
BOOLEAN Create)
{
- PW32PROCESS Win32Process;
+ PPROCESSINFO Win32Process;
DECLARE_RETURN(NTSTATUS);
DPRINT("Enter Win32kProcessCallback\n");
{
/* FIXME - lock the process */
Win32Process = ExAllocatePoolWithTag(NonPagedPool,
- sizeof(W32PROCESS),
- TAG('W', '3', '2', 'p'));
+ sizeof(PROCESSINFO),
+ 'p23W');
if (Win32Process == NULL) RETURN( STATUS_NO_MEMORY);
- RtlZeroMemory(Win32Process, sizeof(W32PROCESS));
+ RtlZeroMemory(Win32Process, sizeof(PROCESSINFO));
PsSetProcessWin32Process(Process, Win32Process);
/* FIXME - unlock the process */
InitializeListHead(&Win32Process->MenuListHead);
+ InitializeListHead(&Win32Process->GDIBrushAttrFreeList);
+ InitializeListHead(&Win32Process->GDIDcAttrFreeList);
+
InitializeListHead(&Win32Process->PrivateFontListHead);
ExInitializeFastMutex(&Win32Process->PrivateFontListLock);
Process->Peb->GdiDCAttributeList = GDI_BATCH_LIMIT;
}
+ Win32Process->peProcess = Process;
/* setup process flags */
- Win32Process->Flags = 0;
+ Win32Process->W32PF_flags = 0;
}
else
{
DPRINT("Destroying W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql());
IntCleanupMenus(Process, Win32Process);
IntCleanupCurIcons(Process, Win32Process);
- IntEngCleanupDriverObjs(Process, Win32Process);
CleanupMonitorImpl();
/* no process windows should exist at this point, or the function will assert! */
{
LogonProcess = NULL;
}
-
- if (Win32Process->ProcessInfo != NULL)
- {
- UserHeapFree(Win32Process->ProcessInfo);
- Win32Process->ProcessInfo = NULL;
- }
}
RETURN( STATUS_SUCCESS);
NTSTATUS
-STDCALL
+APIENTRY
Win32kThreadCallback(struct _ETHREAD *Thread,
PSW32THREADCALLOUTTYPE Type)
{
struct _EPROCESS *Process;
- PW32THREAD Win32Thread;
+ PTHREADINFO Win32Thread;
DECLARE_RETURN(NTSTATUS);
DPRINT("Enter Win32kThreadCallback\n");
{
/* FIXME - lock the process */
Win32Thread = ExAllocatePoolWithTag(NonPagedPool,
- sizeof(W32THREAD),
- TAG('W', '3', '2', 't'));
+ sizeof(THREADINFO),
+ 't23W');
if (Win32Thread == NULL) RETURN( STATUS_NO_MEMORY);
- RtlZeroMemory(Win32Thread, sizeof(W32THREAD));
+ RtlZeroMemory(Win32Thread, sizeof(THREADINFO));
PsSetThreadWin32Thread(Thread, Win32Thread);
/* FIXME - unlock the process */
if (Type == PsW32ThreadCalloutInitialize)
{
HWINSTA hWinSta = NULL;
+ PTEB pTeb;
HDESK hDesk = NULL;
NTSTATUS Status;
PUNICODE_STRING DesktopPath;
InitializeListHead(&Win32Thread->WindowListHead);
InitializeListHead(&Win32Thread->W32CallbackListHead);
+ InitializeListHead(&Win32Thread->PtiLink);
/*
* inherit the thread desktop and process window station (if not yet inherited) from the process startup
if (hDesk != NULL)
{
- PDESKTOP_OBJECT DesktopObject;
- Win32Thread->Desktop = NULL;
+ PDESKTOP DesktopObject;
+ Win32Thread->rpdesk = NULL;
Status = ObReferenceObjectByHandle(hDesk,
0,
ExDesktopObjectType,
}
}
}
- Win32Thread->IsExiting = FALSE;
+ Win32Thread->TIF_flags &= ~TIF_INCLEANUP;
co_IntDestroyCaret(Win32Thread);
+ Win32Thread->ppi = PsGetCurrentProcessWin32Process();
+ pTeb = NtCurrentTeb();
+ if (pTeb)
+ {
+ Win32Thread->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
+ Win32Thread->pClientInfo->pClientThreadInfo = NULL;
+ }
Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
- if (Win32Thread->ThreadInfo)
- Win32Thread->ThreadInfo->ClientThreadInfo.dwcPumpHook = 0;
+ Win32Thread->pEThread = Thread;
}
else
{
DPRINT("Destroying W32 thread TID:%d at IRQ level: %lu\n", Thread->Cid.UniqueThread, KeGetCurrentIrql());
- Win32Thread->IsExiting = TRUE;
+ Win32Thread->TIF_flags |= TIF_INCLEANUP;
+ DceFreeThreadDCE(Win32Thread);
HOOK_DestroyThreadHooks(Thread);
+ /* Cleanup timers */
+ DestroyTimersForThread(Win32Thread);
+ KeSetEvent(Win32Thread->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
UnregisterThreadHotKeys(Thread);
/* what if this co_ func crash in umode? what will clean us up then? */
co_DestroyThreadWindows(Thread);
IntSetThreadDesktop(NULL,
TRUE);
- if (Win32Thread->ThreadInfo != NULL)
- {
- UserHeapFree(Win32Thread->ThreadInfo);
- Win32Thread->ThreadInfo = NULL;
- }
-
PsSetThreadWin32Thread(Thread, NULL);
}
if (Process->Win32Process == NULL)
{
/* FIXME - lock the process */
- Process->Win32Process = ExAllocatePool(NonPagedPool, sizeof(W32PROCESS));
+ Process->Win32Process = ExAllocatePoolWithTag(NonPagedPool, sizeof(PROCESSINFO), USERTAG_PROCESSINFO);
if (Process->Win32Process == NULL)
return STATUS_NO_MEMORY;
- RtlZeroMemory(Process->Win32Process, sizeof(W32PROCESS));
+ RtlZeroMemory(Process->Win32Process, sizeof(PROCESSINFO));
/* FIXME - unlock the process */
Win32kProcessCallback(Process, TRUE);
if (Thread->Tcb.Win32Thread == NULL)
{
- Thread->Tcb.Win32Thread = ExAllocatePool (NonPagedPool, sizeof(W32THREAD));
+ Thread->Tcb.Win32Thread = ExAllocatePoolWithTag(NonPagedPool, sizeof(THREADINFO), USERTAG_THREADINFO);
if (Thread->Tcb.Win32Thread == NULL)
return STATUS_NO_MEMORY;
- RtlZeroMemory(Thread->Tcb.Win32Thread, sizeof(W32THREAD));
+ RtlZeroMemory(Thread->Tcb.Win32Thread, sizeof(THREADINFO));
Win32kThreadCallback(Thread, PsW32ThreadCalloutInitialize);
}
/*
* This definition doesn't work
*/
-NTSTATUS STDCALL
+NTSTATUS APIENTRY
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
return STATUS_UNSUCCESSFUL;
}
+ hModuleWin = MmPageEntireDriver(DriverEntry);
+ DPRINT("Win32k hInstance 0x%x!\n",hModuleWin);
/*
* Register Object Manager Callbacks
*/
if(!hsemDriverMgmt) hsemDriverMgmt = EngCreateSemaphore();
+ GdiHandleTable = GDIOBJ_iAllocHandleTable(&GdiTableSection);
+ if (GdiHandleTable == NULL)
+ {
+ DPRINT1("Failed to initialize the GDI handle table.\n");
+ return STATUS_UNSUCCESSFUL;
+ }
+
Status = InitUserImpl();
if (!NT_SUCCESS(Status))
{
return(Status);
}
- GdiHandleTable = GDIOBJ_iAllocHandleTable(&GdiTableSection);
- if (GdiHandleTable == NULL)
- {
- DPRINT1("Failed to initialize the GDI handle table.\n");
- return STATUS_UNSUCCESSFUL;
- }
-
Status = InitDcImpl();
if (!NT_SUCCESS(Status))
{
return STATUS_UNSUCCESSFUL;
}
+ InitXlateImpl();
+
/* Create stock objects, ie. precreated objects commonly
used by win32 applications */
CreateStockObjects();
CreateSysColorObjects();
+ gusLanguageID = IntGdiGetLanguageID();
+
return STATUS_SUCCESS;
}