PVOID WINAPI InternalInitAtomTable(VOID) { /* Create or return the local table */ if (!BaseLocalAtomTable) RtlCreateAtomTable(0, &BaseLocalAtomTable); return BaseLocalAtomTable; }
/* * @implemented */ BOOL WINAPI InitAtomTable(DWORD nSize) { /* Normalize size */ if (nSize < 4 || nSize > 511) nSize = 37; DPRINT("Here\n"); return NT_SUCCESS(RtlCreateAtomTable(nSize, &BaseLocalAtomTable)); }
/****************************************************************** * get_local_table * * Returns the local atom table for this process (and create it if doesn't * exist yet) */ static RTL_ATOM_TABLE get_local_table(DWORD entries) { static RTL_ATOM_TABLE local_table; if (!local_table) { NTSTATUS status; RTL_ATOM_TABLE table = NULL; if ((status = RtlCreateAtomTable( entries, &table ))) SetLastError( RtlNtStatusToDosError( status ) ); else if (InterlockedCompareExchangePointer((void*)&local_table, table, NULL) != NULL) RtlDestroyAtomTable( table ); } return local_table; }
/*++ * @name ExpGetGlobalAtomTable * * Gets pointer to a global atom table, creates it if not already created * * @return Pointer to the RTL_ATOM_TABLE, or NULL if it's impossible * to create atom table * * @remarks Internal function * *--*/ PRTL_ATOM_TABLE NTAPI ExpGetGlobalAtomTable(VOID) { NTSTATUS Status; /* Return it if we have one */ if (GlobalAtomTable) return GlobalAtomTable; /* Create it */ Status = RtlCreateAtomTable(37, &GlobalAtomTable); /* If we couldn't create it, return NULL */ if (!NT_SUCCESS(Status)) return NULL; /* Return the newly created one */ return GlobalAtomTable; }
HWINSTA APIENTRY NtUserCreateWindowStation( POBJECT_ATTRIBUTES ObjectAttributes, ACCESS_MASK dwDesiredAccess, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4, DWORD Unknown5, DWORD Unknown6) { UNICODE_STRING WindowStationName; PWINSTATION_OBJECT WindowStationObject; HWINSTA WindowStation; NTSTATUS Status; TRACE("NtUserCreateWindowStation called\n"); Status = ObOpenObjectByName(ObjectAttributes, ExWindowStationObjectType, UserMode, NULL, dwDesiredAccess, NULL, (PVOID*)&WindowStation); if (NT_SUCCESS(Status)) { TRACE("NtUserCreateWindowStation opened window station %wZ\n", ObjectAttributes->ObjectName); return (HWINSTA)WindowStation; } /* * No existing window station found, try to create new one */ /* Capture window station name */ _SEH2_TRY { ProbeForRead( ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 1); Status = IntSafeCopyUnicodeStringTerminateNULL(&WindowStationName, ObjectAttributes->ObjectName); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status =_SEH2_GetExceptionCode(); } _SEH2_END if (! NT_SUCCESS(Status)) { ERR("Failed reading capturing window station name\n"); SetLastNtError(Status); return NULL; } /* Create the window station object */ Status = ObCreateObject(UserMode, ExWindowStationObjectType, ObjectAttributes, UserMode, NULL, sizeof(WINSTATION_OBJECT), 0, 0, (PVOID*)&WindowStationObject); if (!NT_SUCCESS(Status)) { ERR("ObCreateObject failed with %lx for window station %wZ\n", Status, &WindowStationName); ExFreePoolWithTag(WindowStationName.Buffer, TAG_STRING); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; } /* Initialize the window station */ RtlZeroMemory(WindowStationObject, sizeof(WINSTATION_OBJECT)); InitializeListHead(&WindowStationObject->DesktopListHead); WindowStationObject->Name = WindowStationName; WindowStationObject->dwSessionId = NtCurrentPeb()->SessionId; Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable); if (!NT_SUCCESS(Status)) { ERR("RtlCreateAtomTable failed with %lx for window station %wZ\n", Status, &WindowStationName); ObDereferenceObject(WindowStationObject); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; } Status = ObInsertObject((PVOID)WindowStationObject, NULL, dwDesiredAccess, 0, NULL, (PVOID*)&WindowStation); if (!NT_SUCCESS(Status)) { ERR("ObInsertObject failed with %lx for window station\n", Status); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; } if (InputWindowStation == NULL) { ERR("Initializing input window station\n"); InputWindowStation = WindowStationObject; WindowStationObject->Flags &= ~WSS_NOIO; InitCursorImpl(); } else { WindowStationObject->Flags |= WSS_NOIO; } TRACE("NtUserCreateWindowStation created object %p with name %wZ handle %p\n", WindowStation, &WindowStationObject->Name, WindowStation); return WindowStation; }