/* IntAttachMonitor * * Creates a new MONITOR and appends it to the list of monitors. * * Arguments * * pGdiDevice Pointer to the PDEVOBJ onto which the monitor was attached * DisplayNumber Display Number (starting with 0) * * Return value * Returns a NTSTATUS */ NTSTATUS IntAttachMonitor(IN PDEVOBJ *pGdiDevice, IN ULONG DisplayNumber) { PMONITOR Monitor; WCHAR Buffer[CCHDEVICENAME]; TRACE("Attaching monitor...\n"); /* create new monitor object */ Monitor = IntCreateMonitorObject(); if (Monitor == NULL) { TRACE("Couldnt create monitor object\n"); return STATUS_INSUFFICIENT_RESOURCES; } _snwprintf(Buffer, CCHDEVICENAME, L"\\\\.\\DISPLAY%d", DisplayNumber + 1); if (!RtlCreateUnicodeString(&Monitor->DeviceName, Buffer)) { TRACE("Couldn't duplicate monitor name!\n"); UserDereferenceObject(Monitor); UserDeleteObject(UserHMGetHandle(Monitor), otMonitor); return STATUS_INSUFFICIENT_RESOURCES; } Monitor->GdiDevice = pGdiDevice; Monitor->cWndStack = 0; if (gMonitorList == NULL) { TRACE("Primary monitor is beeing attached\n"); Monitor->IsPrimary = TRUE; gMonitorList = Monitor; } else { PMONITOR p; TRACE("Additional monitor is beeing attached\n"); for (p = gMonitorList; p->Next != NULL; p = p->Next) { p->Next = Monitor; } Monitor->Prev = p; } IntUpdateMonitorSize(pGdiDevice); return STATUS_SUCCESS; }
/* UserAttachMonitor * * Creates a new MONITOR and appends it to the list of monitors. * * Arguments * * pGdiDevice Pointer to the PDEVOBJ onto which the monitor was attached * DisplayNumber Display Number (starting with 0) * * Return value * Returns a NTSTATUS */ NTSTATUS NTAPI UserAttachMonitor(IN HDEV hDev) { PMONITOR pMonitor; TRACE("Attaching monitor...\n"); /* Create new monitor object */ pMonitor = IntCreateMonitorObject(); if (pMonitor == NULL) { TRACE("Couldnt create monitor object\n"); return STATUS_INSUFFICIENT_RESOURCES; } pMonitor->hDev = hDev; pMonitor->cWndStack = 0; if (gMonitorList == NULL) { TRACE("Primary monitor is beeing attached\n"); pMonitor->IsPrimary = TRUE; gMonitorList = pMonitor; } else { PMONITOR pmonLast = gMonitorList; TRACE("Additional monitor is beeing attached\n"); while (pmonLast->pMonitorNext != NULL) pmonLast = pmonLast->pMonitorNext; pmonLast->pMonitorNext = pMonitor; } UserUpdateMonitorSize(hDev); return STATUS_SUCCESS; }