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); } }
NTSTATUS APIENTRY DxDdCleanupDxGraphics(VOID) { DdHmgDestroy(); if (ghsemDummyPage != 0 ) { if (gpDummyPage != 0 ) { ExFreePoolWithTag(gpDummyPage,0); gpDummyPage = NULL; gcDummyPageRefCnt = 0; } EngDeleteSemaphore(ghsemDummyPage); ghsemDummyPage = 0; } return 0; }
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; }