void Test_EngDeleteSemaphore() { HSEMAPHORE hsem; PRTL_CRITICAL_SECTION lpcrit; /* test Create then delete */ hsem = EngCreateSemaphore(); ok(hsem != NULL, "EngCreateSemaphore failed\n"); if (!hsem) return; lpcrit = (PRTL_CRITICAL_SECTION)hsem; EngDeleteSemaphore(hsem); // ok(lpcrit->LockCount > 0); doesn't work on XP ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount); ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread); ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore); ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount); //ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n"); if (lpcrit->DebugInfo) { ok(lpcrit->DebugInfo->Type != 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type); ok(lpcrit->DebugInfo->CreatorBackTraceIndex != 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex); //ok(lpcrit->DebugInfo->EntryCount != 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount); //ok(lpcrit->DebugInfo->ContentionCount != 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount); } /* test EngAcquireSemaphore and release it, then delete it */ hsem = EngCreateSemaphore(); ok(hsem != NULL, "EngCreateSemaphore failed\n"); if (!hsem) return; lpcrit = (PRTL_CRITICAL_SECTION)hsem; EngAcquireSemaphore(hsem); EngReleaseSemaphore(hsem); EngDeleteSemaphore(hsem); //ok(lpcrit->LockCount > 0, "lpcrit->LockCount=%ld\n", lpcrit->LockCount); ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount); ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread); ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore); ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount); //ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n"); if (lpcrit->DebugInfo) { ok(lpcrit->DebugInfo->Type != 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type); ok(lpcrit->DebugInfo->CreatorBackTraceIndex != 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex); //ok(lpcrit->DebugInfo->EntryCount != 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount); //ok(lpcrit->DebugInfo->ContentionCount != 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount); } }
INIT_FUNCTION NTSTATUS NTAPI InitPDEVImpl() { ghsemPDEV = EngCreateSemaphore(); if (!ghsemPDEV) return STATUS_INSUFFICIENT_RESOURCES; return STATUS_SUCCESS; }
/*++ * @name DxEngLockShareSem * @implemented * * The function DxEngLockShareSem locks a struct of type ghsemShareDevLock that can be shared. * * @return * This function returns TRUE for success and FALSE for failure. * FALSE must mean the struct has already been locked. * * @remarks. * It is being used in various ntuser* functions and ntgdi* * ReactOS specific: It is not in use yet? *SystemResourcesList *--*/ BOOLEAN APIENTRY DxEngLockShareSem() { DPRINT1("ReactX Calling : DxEngLockShareSem\n"); if(!ghsemShareDevLock) ghsemShareDevLock = EngCreateSemaphore(); // Hax, should be in dllmain.c IntGdiAcquireSemaphore(ghsemShareDevLock); return TRUE; }
INIT_FUNCTION NTSTATUS NTAPI InitDeviceImpl(VOID) { ghsemGraphicsDeviceList = EngCreateSemaphore(); if (!ghsemGraphicsDeviceList) return STATUS_INSUFFICIENT_RESOURCES; return STATUS_SUCCESS; }
INIT_FUNCTION NTSTATUS NTAPI InitLDEVImpl(VOID) { ULONG cbSize; /* Initialize the loader lock */ ghsemLDEVList = EngCreateSemaphore(); if (!ghsemLDEVList) { ERR("Failed to create ghsemLDEVList\n"); return STATUS_INSUFFICIENT_RESOURCES; } /* Allocate a LDEVOBJ for win32k */ gpldevWin32k = ExAllocatePoolWithTag(PagedPool, sizeof(LDEVOBJ) + sizeof(SYSTEM_GDI_DRIVER_INFORMATION), GDITAG_LDEV); if (!gpldevWin32k) { return STATUS_NO_MEMORY; } /* Initialize the LDEVOBJ for win32k */ gpldevWin32k->pldevNext = NULL; gpldevWin32k->pldevPrev = NULL; gpldevWin32k->ldevtype = LDEV_DEVICE_DISPLAY; gpldevWin32k->cRefs = 1; gpldevWin32k->ulDriverVersion = GDI_ENGINE_VERSION; gpldevWin32k->pGdiDriverInfo = (PVOID)(gpldevWin32k + 1); RtlInitUnicodeString(&gpldevWin32k->pGdiDriverInfo->DriverName, L"\\SystemRoot\\System32\\win32k.sys"); gpldevWin32k->pGdiDriverInfo->ImageAddress = &__ImageBase; gpldevWin32k->pGdiDriverInfo->SectionPointer = NULL; gpldevWin32k->pGdiDriverInfo->EntryPoint = (PVOID)DriverEntry; gpldevWin32k->pGdiDriverInfo->ExportSectionPointer = RtlImageDirectoryEntryToData(&__ImageBase, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &cbSize); gpldevWin32k->pGdiDriverInfo->ImageLength = 0; // FIXME return STATUS_SUCCESS; }
NTSTATUS APIENTRY DxDdStartupDxGraphics (ULONG SizeEngDrv, PDRVENABLEDATA pDxEngDrv, ULONG SizeDxgDrv, PDRVENABLEDATA pDxgDrv, PULONG DirectDrawContext, PEPROCESS Proc ) { PDRVFN drv_func; UINT i; /* Test see if the data is vaild we got from win32k.sys */ if ((SizeEngDrv != sizeof(DRVENABLEDATA)) || (SizeDxgDrv != sizeof(DRVENABLEDATA))) { return STATUS_BUFFER_TOO_SMALL; } /* rest static value */ gpDummyPage = NULL; gcDummyPageRefCnt = 0; ghsemDummyPage = NULL; /* * Setup internal driver functions list we got from dxg driver functions list */ pDxgDrv->iDriverVersion = 0x80000; /* Note 12/1-2004 : DirectX 8 ? */ pDxgDrv->c = gcDxgFuncs; pDxgDrv->pdrvfn = gaDxgFuncs; /* check how many driver functions and fail if the value does not match */ if (pDxEngDrv->c != DXENG_INDEX_DxEngLoadImage + 1) { return STATUS_INTERNAL_ERROR; } /* * Check if all drv functions are sorted right * and if it really are exported */ for (i=1 ; i < DXENG_INDEX_DxEngLoadImage + 1; i++) { drv_func = &pDxEngDrv->pdrvfn[i]; if ((drv_func->iFunc != i) || (drv_func->pfn == NULL)) { return STATUS_INTERNAL_ERROR; } } gpEngFuncs = pDxEngDrv->pdrvfn; /* Note 12/1-2004 : Why is this set to 0x618 */ *DirectDrawContext = 0x618; if (DdHmgCreate()) { ghsemDummyPage = EngCreateSemaphore(); if (ghsemDummyPage) { gpepSession = Proc; return STATUS_SUCCESS; } } DdHmgDestroy(); if (ghsemDummyPage) { EngDeleteSemaphore(ghsemDummyPage); ghsemDummyPage = 0; } return STATUS_NO_MEMORY; }
static PPDEVOBJ EngpCreatePDEV( PUNICODE_STRING pustrDeviceName, PDEVMODEW pdm) { PGRAPHICS_DEVICE pGraphicsDevice; PPDEVOBJ ppdev; /* Try to find the GRAPHICS_DEVICE */ if (pustrDeviceName) { pGraphicsDevice = EngpFindGraphicsDevice(pustrDeviceName, 0, 0); if (!pGraphicsDevice) { DPRINT1("No GRAPHICS_DEVICE found for %ls!\n", pustrDeviceName ? pustrDeviceName->Buffer : 0); return NULL; } } else { pGraphicsDevice = gpPrimaryGraphicsDevice; } /* Allocate a new PDEVOBJ */ ppdev = PDEVOBJ_AllocPDEV(); if (!ppdev) { DPRINT1("failed to allocate a PDEV\n"); return NULL; } /* If no DEVMODEW is given, ... */ if (!pdm) { /* ... use the device's default one */ pdm = pGraphicsDevice->pDevModeList[pGraphicsDevice->iDefaultMode].pdm; DPRINT("Using iDefaultMode = %ld\n", pGraphicsDevice->iDefaultMode); } /* Try to get a diplay driver */ ppdev->pldev = EngLoadImageEx(pdm->dmDeviceName, LDEV_DEVICE_DISPLAY); if (!ppdev->pldev) { DPRINT1("Could not load display driver '%ls'\n", pGraphicsDevice->pDiplayDrivers); ExFreePoolWithTag(ppdev, GDITAG_PDEV); return NULL; } /* Copy the function table */ ppdev->pfn = ppdev->pldev->pfn; /* Set MovePointer function */ ppdev->pfnMovePointer = ppdev->pfn.MovePointer; if (!ppdev->pfnMovePointer) ppdev->pfnMovePointer = EngMovePointer; ppdev->pGraphicsDevice = pGraphicsDevice; ppdev->hsemDevLock = EngCreateSemaphore(); // Should we change the ative mode of pGraphicsDevice ? ppdev->pdmwDev = PDEVOBJ_pdmMatchDevMode(ppdev, pdm) ; /* FIXME! */ ppdev->flFlags = PDEV_DISPLAY; /* HACK: Don't use the pointer */ ppdev->Pointer.Exclude.right = -1; /* Call the driver to enable the PDEV */ if (!PDEVOBJ_bEnablePDEV(ppdev, pdm, NULL)) { DPRINT1("Failed to enable PDEV!\n"); ASSERT(FALSE); } /* FIXME: this must be done in a better way */ pGraphicsDevice->StateFlags |= DISPLAY_DEVICE_ATTACHED_TO_DESKTOP; /* Tell the driver that the PDEV is ready */ PDEVOBJ_vCompletePDEV(ppdev); /* Return the PDEV */ return ppdev; }