这篇教程C++ ExAcquireFastMutex函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ExAcquireFastMutex函数的典型用法代码示例。如果您正苦于以下问题:C++ ExAcquireFastMutex函数的具体用法?C++ ExAcquireFastMutex怎么用?C++ ExAcquireFastMutex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ExAcquireFastMutex函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: bus_plugin_devNTSTATUS bus_plugin_dev(ioctl_usbvbus_plugin * plugin, PFDO_DEVICE_DATA fdodata, PFILE_OBJECT fo){ PDEVICE_OBJECT pdo; PPDO_DEVICE_DATA pdodata, old_pdodata; NTSTATUS status; ULONG len; PLIST_ENTRY entry; unsigned long i; PAGED_CODE (); Bus_KdPrint (fdodata, BUS_DBG_PNP_INFO, ("Exposing PDO/n" "======addr: %d/n" "======vendor:product: %04x:%04x/n", plugin->addr, plugin->vendor, plugin->product)); if(plugin->addr <= 0) return STATUS_INVALID_PARAMETER; ExAcquireFastMutex (&fdodata->Mutex); for (entry = fdodata->ListOfPDOs.Flink; entry != &fdodata->ListOfPDOs; entry = entry->Flink) { pdodata = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); if (plugin->addr == pdodata->SerialNo && pdodata->DevicePnPState != SurpriseRemovePending) { ExReleaseFastMutex (&fdodata->Mutex); return STATUS_INVALID_PARAMETER; } } ExReleaseFastMutex (&fdodata->Mutex); // Create the PDO // Bus_KdPrint(fdodata, BUS_DBG_PNP_NOISE, ("fdodata->NextLowerDriver = 0x%p/n", fdodata->NextLowerDriver)); // // PDO must have a name. You should let the system auto generate a // name by specifying FILE_AUTOGENERATED_DEVICE_NAME in the // DeviceCharacteristics parameter. Let us create a secure deviceobject, // in case the child gets installed as a raw device (RawDeviceOK), to prevent // an unpriviledged user accessing our device. This function is avaliable // in a static WDMSEC.LIB and can be used in Win2k, XP, and Server 2003 // Just make sure that the GUID specified here is not a setup class GUID. // If you specify a setup class guid, you must make sure that class is // installed before enumerating the PDO. // status = IoCreateDeviceSecure(fdodata->Self->DriverObject, sizeof (PDO_DEVICE_DATA), NULL, FILE_DEVICE_BUS_EXTENDER, FILE_AUTOGENERATED_DEVICE_NAME |FILE_DEVICE_SECURE_OPEN, FALSE, &SDDL_DEVOBJ_SYS_ALL_ADM_RWX_WORLD_RWX_RES_RWX, // allow normal users to access the devices (LPCGUID)&GUID_SD_BUSENUM_PDO, &pdo); if (!NT_SUCCESS (status)) { return status; } pdodata = (PPDO_DEVICE_DATA) pdo->DeviceExtension;#define HARDWARE_IDS_TPL L"USB//Vid_%04x&Pid_%04x&Rev_%04xZUSB//Vid_%04x&Pid_%04xZ" len = sizeof(HARDWARE_IDS_TPL); pdodata->HardwareIDs = ExAllocatePoolWithTag (NonPagedPool, len, BUSENUM_POOL_TAG); if (NULL == pdodata->HardwareIDs) { IoDeleteDevice(pdo); return STATUS_INSUFFICIENT_RESOURCES; } RtlStringCchPrintfW(pdodata->HardwareIDs, len/sizeof(wchar_t), HARDWARE_IDS_TPL, plugin->vendor, plugin->product, plugin->version, plugin->vendor, plugin->product); for(i=0;i<len/sizeof(wchar_t);i++){ if('Z'==pdodata->HardwareIDs[i]) pdodata->HardwareIDs[i]=0; }#define COMPATIBLE_IDS_TPL L"USB//Class_%02x&SubClass_%02x&Prot_%02xZUSB//Class_%02x&SubClass_%02xZUSB//Class_%02xZ"#define COMPATIBLE_COMPOSITE_IDS_TPL L"USB//Class_%02x&SubClass_%02x&Prot_%02xZUSB//Class_%02x&SubClass_%02xZUSB//Class_%02xZUSB//COMPOSITEZ" if(plugin->inum>1) len = sizeof(COMPATIBLE_COMPOSITE_IDS_TPL); else len = sizeof(COMPATIBLE_IDS_TPL); pdodata->compatible_ids = ExAllocatePoolWithTag (NonPagedPool, len, BUSENUM_POOL_TAG); if (NULL == pdodata->compatible_ids) {//.........这里部分代码省略.........
开发者ID:DevNullx64,项目名称:usbip-windows-mirror,代码行数:101,
示例2: DoPdoPnP// for pdoNTSTATUS DoPdoPnP(PDEVICE_OBJECT pDevice,PIRP pIrp){ NTSTATUS status = STATUS_SUCCESS; PPdoExt pPdoExt = static_cast<PPdoExt>(pDevice->DeviceExtension); PIO_STACK_LOCATION pIoStack = IoGetCurrentIrpStackLocation(pIrp); switch(pIoStack->MinorFunction) { case IRP_MN_START_DEVICE: // set power state pPdoExt->m_devPowerState = PowerDeviceD0; POWER_STATE state; state.DeviceState = PowerDeviceD0; PoSetPowerState(pDevice,DevicePowerState,state); // set pnp state directly case IRP_MN_STOP_DEVICE: case IRP_MN_QUERY_STOP_DEVICE: case IRP_MN_QUERY_REMOVE_DEVICE: SetNewPnpState(pPdoExt,pIoStack->MinorFunction); break; // check prev state case IRP_MN_CANCEL_REMOVE_DEVICE: if(pPdoExt->m_ulCurrentPnpState == IRP_MN_QUERY_REMOVE_DEVICE) { RestorePnpState(pPdoExt); } break; // the same case IRP_MN_CANCEL_STOP_DEVICE: if(pPdoExt->m_ulCurrentPnpState == IRP_MN_QUERY_STOP_DEVICE) { RestorePnpState(pPdoExt); } break; // remove case IRP_MN_REMOVE_DEVICE: { // delete only if we have reported the device physical removal if(pPdoExt->m_bReportMissing) { SetNewPnpState(pPdoExt,IRP_MN_REMOVE_DEVICE); PDEVICE_OBJECT pFdo = pPdoExt->m_pParentFdo; if(pFdo) { PFdoExt pFdoExt = static_cast<PFdoExt>(pFdo->DeviceExtension); // update fdo's pointer ExAcquireFastMutex(&pFdoExt->m_mutexEnumPdo); pFdoExt->m_pEnumPdo = NULL; ExReleaseFastMutex(&pFdoExt->m_mutexEnumPdo); } // delete device IoDeleteDevice(pDevice); } // if it's present if(pPdoExt->m_bPresent) { // set it as stopped SetNewPnpState(pPdoExt,IRP_MN_STOP_DEVICE); } } break; // query caps case IRP_MN_QUERY_CAPABILITIES: { PDEVICE_CAPABILITIES pCaps = pIoStack->Parameters.DeviceCapabilities.Capabilities; // version check if(pCaps->Version != 1 || pCaps->Size < sizeof(DEVICE_CAPABILITIES)) { status = STATUS_UNSUCCESSFUL; break; } IO_STATUS_BLOCK ioStatus; KEVENT pnpEvent; PDEVICE_OBJECT pTargetObject; PIO_STACK_LOCATION pIrpStack; PIRP pPnpIrp; DEVICE_CAPABILITIES parentCaps; RtlZeroMemory(&parentCaps,sizeof(DEVICE_CAPABILITIES)); parentCaps.Size = sizeof(DEVICE_CAPABILITIES); parentCaps.Version = 1; parentCaps.Address = -1; parentCaps.UINumber = -1; KeInitializeEvent(&pnpEvent,NotificationEvent,FALSE);//.........这里部分代码省略.........
开发者ID:maodapeng,项目名称:WDUtils,代码行数:101,
示例3: SecondaryRecoverySession//.........这里部分代码省略......... } else { continue; } KeInitializeEvent( &Secondary->ReadyEvent, NotificationEvent, FALSE ); KeInitializeEvent( &Secondary->RequestEvent, NotificationEvent, FALSE ); InitializeObjectAttributes(&objectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL); status = PsCreateSystemThread( &Secondary->ThreadHandle, THREAD_ALL_ACCESS, &objectAttributes, NULL, NULL, SecondaryThreadProc, Secondary ); if (!NT_SUCCESS(status)) { ASSERT( NDASNTFS_UNEXPECTED ); break; } status = ObReferenceObjectByHandle( Secondary->ThreadHandle, FILE_READ_DATA, NULL, KernelMode, &Secondary->ThreadObject, NULL ); if (!NT_SUCCESS(status)) { ASSERT( NDASNTFS_INSUFFICIENT_RESOURCES ); break; } timeOut.QuadPart = -NDASNTFS_TIME_OUT; status = KeWaitForSingleObject( &Secondary->ReadyEvent, Executive, KernelMode, FALSE, &timeOut ); if(status != STATUS_SUCCESS) { ASSERT( NDASNTFS_BUG ); break; } KeClearEvent( &Secondary->ReadyEvent ); InterlockedIncrement( &Secondary->SessionId ); ExAcquireFastMutex( &Secondary->FastMutex ); if (!FlagOn(Secondary->Thread.Flags, SECONDARY_THREAD_FLAG_START) || FlagOn(Secondary->Thread.Flags, SECONDARY_THREAD_FLAG_STOPED)) { ExReleaseFastMutex( &Secondary->FastMutex ); if(Secondary->Thread.SessionStatus == STATUS_DISK_CORRUPT_ERROR) { status = STATUS_SUCCESS; break; } timeOut.QuadPart = -NDASNTFS_TIME_OUT; status = KeWaitForSingleObject( Secondary->ThreadObject, Executive, KernelMode, FALSE, &timeOut ); if(status != STATUS_SUCCESS) { ASSERT( NDASNTFS_BUG ); return status; } DebugTrace( 0, Dbg, ("Secondary_Stop: thread stoped/n") ); ObDereferenceObject( Secondary->ThreadObject ); Secondary->ThreadHandle = 0; Secondary->ThreadObject = 0; RtlZeroMemory( &Secondary->Thread.Flags, sizeof(SECONDARY) - FIELD_OFFSET(SECONDARY, Thread.Flags) ); continue; } ExReleaseFastMutex( &Secondary->FastMutex ); status = STATUS_SUCCESS; DebugTrace( 0, Dbg2, ("SessionRecovery Success Secondary = %p/n", Secondary) ); break; }
开发者ID:JanD1943,项目名称:ndas4windows,代码行数:101,
示例4: SecondaryTryCloseVOIDSecondaryTryClose ( IN PSECONDARY Secondary ){ PIRP_CONTEXT irpContext; BOOLEAN secondaryResourceAcquired = FALSE; BOOLEAN acquiredVcb = FALSE; BOOLEAN wait; irpContext = FatAllocateIrpContext(); if (irpContext == NULL) { return; } DebugTrace2( 0, Dbg, ("Secondary_TryCloseFiles start/n") ); try { RtlZeroMemory( irpContext, sizeof(IRP_CONTEXT) ); SetFlag( irpContext->Flags, IRP_CONTEXT_FLAG_WAIT ); SetFlag( irpContext->NdasFatFlags, NDAS_FAT_IRP_CONTEXT_FLAG_SECONDARY_CONTEXT ); irpContext->Vcb = &Secondary->VolDo->Vcb; secondaryResourceAcquired = SecondaryAcquireResourceSharedLite( irpContext, &Secondary->VolDo->Resource, FALSE ); if (secondaryResourceAcquired == FALSE) { leave; } wait = BooleanFlagOn( irpContext->Flags, IRP_CONTEXT_FLAG_WAIT ); acquiredVcb = FatAcquireExclusiveVcb( irpContext, irpContext->Vcb ); if (acquiredVcb == FALSE) { leave; } FsRtlEnterFileSystem(); FatFspClose( &Secondary->VolDo->Vcb ); FsRtlExitFileSystem(); DebugTrace2( 0, Dbg, ("Secondary_TryCloseFiles FatFspClose, Secondary->VolDo->Vcb.SecondaryOpenCount = %d/n", Secondary->VolDo->Vcb.SecondaryOpenFileCount) ); SetFlag( irpContext->NdasFatFlags, NDAS_FAT_IRP_CONTEXT_FLAG_TRY_CLOSE_FILES ); Secondary_TryCloseFilExts( Secondary ); } finally { ClearFlag( irpContext->NdasFatFlags, NDAS_FAT_IRP_CONTEXT_FLAG_TRY_CLOSE_FILES ); if (acquiredVcb) { FatReleaseVcb( irpContext, irpContext->Vcb ); } DebugTrace2( 0, Dbg, ("Secondary_TryCloseFiles exit/n") ); ExAcquireFastMutex( &Secondary->FastMutex ); Secondary->TryCloseActive = FALSE; ExReleaseFastMutex( &Secondary->FastMutex ); if (secondaryResourceAcquired) SecondaryReleaseResourceLite( NULL, &Secondary->VolDo->Resource ); Secondary_Dereference(Secondary); FatFreeIrpContext(irpContext); } return;}
开发者ID:Nevermore2015,项目名称:ndas4windows,代码行数:80,
示例5: FatCommonPnp//.........这里部分代码省略......... FatCompleteRequest( IrpContext, Irp, Status ); return Status; }#if __NDAS_FAT__ if (OurDeviceObject->NetdiskEnableMode == NETDISK_SECONDARY) SetFlag( IrpContext->NdFatFlags, ND_FAT_IRP_CONTEXT_FLAG_SECONDARY_CONTEXT );#endif Vcb = &OurDeviceObject->Vcb; // // Case on the minor code. // #if __NDAS_FAT_SECONDARY__ if ( ((PVOLUME_DEVICE_OBJECT)IrpSp->DeviceObject)->Secondary && ( ((PVOLUME_DEVICE_OBJECT)IrpSp->DeviceObject)->NetdiskEnableMode == NETDISK_SECONDARY || ((PVOLUME_DEVICE_OBJECT)IrpSp->DeviceObject)->NetdiskEnableMode == NETDISK_SECONDARY2PRIMARY ) ) { PSECONDARY Secondary = ((PVOLUME_DEVICE_OBJECT)IrpSp->DeviceObject)->Secondary; Status = STATUS_SUCCESS; Secondary_Reference( Secondary ); switch ( IrpSp->MinorFunction ) { case IRP_MN_QUERY_REMOVE_DEVICE: { DebugTrace2( 0, Dbg, ("FatCommonPnp: IRP_MN_QUERY_REMOVE_DEVICE NetdiskEnableMode = %d/n", ((PVOLUME_DEVICE_OBJECT)IrpSp->DeviceObject)->NetdiskEnableMode) ); ExAcquireFastMutex( &Secondary->FastMutex ); if (!Secondary->TryCloseActive) { Secondary->TryCloseActive = TRUE; ExReleaseFastMutex( &Secondary->FastMutex ); Secondary_Reference( Secondary ); //FatDebugTraceLevel |= DEBUG_TRACE_CLOSE; SecondaryTryClose( IrpContext, Secondary ); //FatDebugTraceLevel &= ~DEBUG_TRACE_CLOSE; } else { ExReleaseFastMutex( &Secondary->FastMutex ); } if (Vcb->SecondaryOpenFileCount) { LARGE_INTEGER interval; // Wait all files closed interval.QuadPart = (1 * HZ); //delay 1 seconds KeDelayExecutionThread(KernelMode, FALSE, &interval); }#if 0 if (Vcb->SecondaryOpenFileCount) { LONG ccbCount; PLIST_ENTRY ccbListEntry; PVOID restartKey; PFCB fcb;
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:66,
示例6: Bus_InitializePdoVOIDBus_InitializePdo ( PDEVICE_OBJECT Pdo, PFDO_DEVICE_DATA FdoData ){ PPDO_DEVICE_DATA pdoData; int acpistate; DEVICE_POWER_STATE ntState; PAGED_CODE (); pdoData = (PPDO_DEVICE_DATA) Pdo->DeviceExtension; DPRINT("pdo 0x%p, extension 0x%p/n", Pdo, pdoData); if (pdoData->AcpiHandle) acpi_bus_get_power(pdoData->AcpiHandle, &acpistate); else acpistate = ACPI_STATE_D0; switch(acpistate) { case ACPI_STATE_D0: ntState = PowerDeviceD0; break; case ACPI_STATE_D1: ntState = PowerDeviceD1; break; case ACPI_STATE_D2: ntState = PowerDeviceD2; break; case ACPI_STATE_D3: ntState = PowerDeviceD3; break; default: DPRINT1("Unknown power state (%d) returned by acpi/n",acpistate); ntState = PowerDeviceUnspecified; break; } // // Initialize the rest // pdoData->Common.IsFDO = FALSE; pdoData->Common.Self = Pdo; pdoData->ParentFdo = FdoData->Common.Self; INITIALIZE_PNP_STATE(pdoData->Common); pdoData->Common.DevicePowerState = ntState; pdoData->Common.SystemPowerState = FdoData->Common.SystemPowerState; Pdo->Flags |= DO_POWER_PAGABLE; ExAcquireFastMutex (&FdoData->Mutex); InsertTailList(&FdoData->ListOfPDOs, &pdoData->Link); FdoData->NumPDOs++; ExReleaseFastMutex (&FdoData->Mutex); // This should be the last step in initialization. Pdo->Flags &= ~DO_DEVICE_INITIALIZING;}
开发者ID:Strongc,项目名称:reactos,代码行数:66,
示例7: Secondary_Create//.........这里部分代码省略......... ExInitializeFastMutex( &secondary->RecoveryCcbQMutex ); InitializeListHead( &secondary->DeletedFcbQueue ); KeQuerySystemTime( &secondary->TryCloseTime ); secondary->TryCloseWorkItem = IoAllocateWorkItem( (PDEVICE_OBJECT)VolDo ); KeInitializeEvent( &secondary->ReadyEvent, NotificationEvent, FALSE ); InitializeListHead( &secondary->RequestQueue ); KeInitializeSpinLock( &secondary->RequestQSpinLock ); KeInitializeEvent( &secondary->RequestEvent, NotificationEvent, FALSE ); InitializeListHead( &secondary->FcbQueue ); ExInitializeFastMutex( &secondary->FcbQMutex ); KeInitializeEvent( &secondary->RecoveryReadyEvent, NotificationEvent, FALSE ); InitializeObjectAttributes( &objectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL ); secondary->SessionId = 0; status = PsCreateSystemThread( &secondary->ThreadHandle, THREAD_ALL_ACCESS, &objectAttributes, NULL, NULL, SecondaryThreadProc, secondary ); if (!NT_SUCCESS(status)) { ASSERT( NDASFAT_UNEXPECTED ); Secondary_Close( secondary ); return NULL; } status = ObReferenceObjectByHandle( secondary->ThreadHandle, FILE_READ_DATA, NULL, KernelMode, &secondary->ThreadObject, NULL ); if (!NT_SUCCESS(status)) { ASSERT( NDASFAT_INSUFFICIENT_RESOURCES ); Secondary_Close( secondary ); return NULL; } secondary->SessionId ++; timeOut.QuadPart = -NDASFAT_TIME_OUT; status = KeWaitForSingleObject( &secondary->ReadyEvent, Executive, KernelMode, FALSE, &timeOut ); if (status != STATUS_SUCCESS) { NDAS_ASSERT( FALSE ); Secondary_Close( secondary ); return NULL; } KeClearEvent( &secondary->ReadyEvent ); ExAcquireFastMutex( &secondary->FastMutex ); if (!FlagOn(secondary->Thread.Flags, SECONDARY_THREAD_FLAG_START) || FlagOn(secondary->Thread.Flags, SECONDARY_THREAD_FLAG_STOPED)) { if (secondary->Thread.SessionStatus != STATUS_DISK_CORRUPT_ERROR && secondary->Thread.SessionStatus != STATUS_UNRECOGNIZED_VOLUME) { ExReleaseFastMutex( &secondary->FastMutex ); Secondary_Close( secondary ); return NULL; } } ASSERT( secondary->Thread.SessionContext.SessionSlotCount != 0 ); ClearFlag( secondary->Flags, SECONDARY_FLAG_INITIALIZING ); SetFlag( secondary->Flags, SECONDARY_FLAG_START ); ExReleaseFastMutex( &secondary->FastMutex ); DebugTrace2( 0, Dbg2, ("Secondary_Create: The client thread are ready secondary = %p/n", secondary) ); return secondary;}
开发者ID:Nevermore2015,项目名称:ndas4windows,代码行数:101,
示例8: Readonly_CloseVOIDReadonly_Close ( IN PREADONLY Readonly ){ NTSTATUS status; LARGE_INTEGER timeOut; PLIST_ENTRY readonlyRequestEntry; PREADONLY_REQUEST readonlyRequest; SPY_LOG_PRINT( LFS_DEBUG_READONLY_INFO, ("Readonly close Readonly = %p/n", Readonly) ); ExAcquireFastMutex( &Readonly->FastMutex ); ASSERT( !FlagOn(Readonly->Flags, READONLY_FLAG_RECONNECTING) ); if (FlagOn(Readonly->Flags, READONLY_FLAG_CLOSED)) { //ASSERT( FALSE ); ExReleaseFastMutex( &Readonly->FastMutex ); return; } SetFlag( Readonly->Flags, READONLY_FLAG_CLOSED ); ExReleaseFastMutex( &Readonly->FastMutex ); FsRtlNotifyUninitializeSync( &Readonly->NotifySync ); if (Readonly->ThreadHandle == NULL) { //ASSERT( FALSE ); Readonly_Dereference( Readonly ); return; } ASSERT( Readonly->ThreadObject != NULL ); SPY_LOG_PRINT( LFS_DEBUG_READONLY_TRACE, ("Readonly close READONLY_REQ_DISCONNECT Readonly = %p/n", Readonly) ); readonlyRequest = AllocReadonlyRequest( Readonly, 0, FALSE ); readonlyRequest->RequestType = READONLY_REQ_DISCONNECT; QueueingReadonlyRequest( Readonly, readonlyRequest ); readonlyRequest = AllocReadonlyRequest( Readonly, 0, FALSE ); readonlyRequest->RequestType = READONLY_REQ_DOWN; QueueingReadonlyRequest( Readonly, readonlyRequest ); SPY_LOG_PRINT( LFS_DEBUG_READONLY_TRACE, ("Readonly close READONLY_REQ_DISCONNECT end Readonly = %p/n", Readonly) ); timeOut.QuadPart = -LFS_TIME_OUT; status = KeWaitForSingleObject( Readonly->ThreadObject, Executive, KernelMode, FALSE, &timeOut ); if (status == STATUS_SUCCESS) { SPY_LOG_PRINT( LFS_DEBUG_READONLY_TRACE, ("Readonly_Close: thread stoped Readonly = %p/n", Readonly) ); ObDereferenceObject( Readonly->ThreadObject ); Readonly->ThreadHandle = NULL; Readonly->ThreadObject = NULL; } else { ASSERT( LFS_BUG ); return; } if (!IsListEmpty(&Readonly->FcbQueue)) NDAS_ASSERT( FALSE ); if (!IsListEmpty(&Readonly->CcbQueue)) NDAS_ASSERT( FALSE ); if (!IsListEmpty(&Readonly->RequestQueue)) NDAS_ASSERT( FALSE ); while (readonlyRequestEntry = ExInterlockedRemoveHeadList(&Readonly->RequestQueue, &Readonly->RequestQSpinLock)) { PREADONLY_REQUEST readonlyRequest2; InitializeListHead( readonlyRequestEntry ); readonlyRequest2 = CONTAINING_RECORD( readonlyRequestEntry, READONLY_REQUEST, ListEntry ); readonlyRequest2->ExecuteStatus = STATUS_IO_DEVICE_ERROR; if (readonlyRequest2->Synchronous == TRUE)//.........这里部分代码省略.........
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:101,
示例9: ReadonlyThreadProcVOIDReadonlyThreadProc ( IN PREADONLY Readonly ){ BOOLEAN readonlyThreadTerminate = FALSE; PLIST_ENTRY readonlyRequestEntry; SPY_LOG_PRINT( LFS_DEBUG_READONLY_TRACE, ("ReadonlyThreadProc: Start Readonly = %p/n", Readonly) ); Readonly_Reference( Readonly ); Readonly->Thread.Flags = READONLY_THREAD_FLAG_INITIALIZING; ExAcquireFastMutex( &Readonly->FastMutex ); SetFlag( Readonly->Thread.Flags, READONLY_THREAD_FLAG_START ); ClearFlag( Readonly->Thread.Flags, READONLY_THREAD_FLAG_INITIALIZING ); ExReleaseFastMutex( &Readonly->FastMutex ); KeSetEvent( &Readonly->ReadyEvent, IO_DISK_INCREMENT, FALSE ); readonlyThreadTerminate = FALSE; while (readonlyThreadTerminate == FALSE) { PKEVENT events[2]; LONG eventCount; NTSTATUS eventStatus; LARGE_INTEGER timeOut; ASSERT( KeGetCurrentIrql() == PASSIVE_LEVEL ); eventCount = 0; events[eventCount++] = &Readonly->RequestEvent; timeOut.QuadPart = -LFS_READONLY_THREAD_FLAG_TIME_OUT; eventStatus = KeWaitForMultipleObjects( eventCount, events, WaitAny, Executive, KernelMode, TRUE, &timeOut, NULL ); if (eventStatus == STATUS_TIMEOUT) { ReadonlyTryCloseCcb( Readonly ); ReadonlyDismountVolumeStart( Readonly ); continue; } ASSERT( KeGetCurrentIrql() == PASSIVE_LEVEL ); ASSERT( eventCount < THREAD_WAIT_OBJECTS ); if (!NT_SUCCESS( eventStatus ) || eventStatus >= eventCount) { ASSERT( LFS_UNEXPECTED ); SetFlag( Readonly->Thread.Flags, READONLY_THREAD_FLAG_ERROR ); readonlyThreadTerminate = TRUE; continue; } KeClearEvent( events[eventStatus] ); if (eventStatus == 0) { while (!FlagOn(Readonly->Thread.Flags, READONLY_THREAD_FLAG_STOPED) && (readonlyRequestEntry = ExInterlockedRemoveHeadList(&Readonly->RequestQueue, &Readonly->RequestQSpinLock))) { PREADONLY_REQUEST readonlyRequest; InitializeListHead( readonlyRequestEntry ); readonlyRequest = CONTAINING_RECORD( readonlyRequestEntry, READONLY_REQUEST, ListEntry ); if (!(readonlyRequest->RequestType == READONLY_REQ_DISCONNECT || readonlyRequest->RequestType == READONLY_REQ_DOWN || readonlyRequest->RequestType == READONLY_REQ_SEND_MESSAGE)) { ASSERT( FALSE ); ExAcquireFastMutex( &Readonly->FastMutex ); SetFlag( Readonly->Thread.Flags, READONLY_THREAD_FLAG_STOPED | READONLY_THREAD_FLAG_ERROR ); ExReleaseFastMutex( &Readonly->FastMutex ); ExInterlockedInsertHeadList( &Readonly->RequestQueue, &readonlyRequest->ListEntry, &Readonly->RequestQSpinLock ); readonlyThreadTerminate = TRUE; break; }//.........这里部分代码省略.........
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:101,
示例10: IsRegionExempted//// Checks to see if a supplied region is exempted from being allocated into//BOOLEAN IsRegionExempted( IN PVOID RegionBase, IN ULONG RegionSize, OUT PULONG EndDisplacement OPTIONAL){ PLIST_ENTRY Current; BOOLEAN Exempted = FALSE; // // Acquire the region exemption list mutex // ExAcquireFastMutex( &RegionExemptionListMutex); // // Enumerate through all of the region exemptions // for (Current = RegionExemptionList.Flink; (Current != &RegionExemptionList) && (!Exempted); Current = Current->Flink) { PREGION_EXEMPTION Exemption = (PREGION_EXEMPTION)Current; Exempted = ( (IsAddressInsideRange( RegionBase, Exemption->Base, Exemption->Size)) || (IsAddressInsideRange( Exemption->Base, RegionBase, RegionSize))) ? TRUE : FALSE; // // If this region is exempted and the caller requested a displacement // calculation, pass one back to them such that they can optimize their // search by knowing how much to add to their region base to get outside // of the exempted region. // if ((Exempted) && (EndDisplacement)) { // // The number of bytes that will have to be incremented by to get the // supplied region out of the area of the exempted region is calculated // by subtracting the end of the exempted region from the start of the // supplied region. // *EndDisplacement = (ULONG)((Exemption->Base + Exemption->Size) - (ULONG_PTR)RegionBase); // // Assert that the end of the exempted region is always greater than // the region base, which should always be true. // ASSERT((Exemption->Base + Exemption->Size) > (ULONG_PTR)RegionBase); } } // // Release the region exemption list mutex // ExReleaseFastMutex( &RegionExemptionListMutex); return Exempted;}
开发者ID:340211173,项目名称:hf-2011,代码行数:69,
示例11: ReadonlyPassThroughBOOLEANReadonlyPassThrough ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PFILESPY_DEVICE_EXTENSION DevExt, OUT PNTSTATUS NtStatus ){ NTSTATUS status = STATUS_SUCCESS; BOOLEAN result = FALSE; PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation( Irp ); PFILE_OBJECT fileObject = irpSp->FileObject; BOOLEAN fastMutexAcquired = FALSE; UNREFERENCED_PARAMETER( DeviceObject ); ASSERT( DevExt->LfsDeviceExt.ReferenceCount ); LfsDeviceExt_Reference( &DevExt->LfsDeviceExt ); PrintIrp( LFS_DEBUG_READONLY_NOISE, __FUNCTION__, &DevExt->LfsDeviceExt, Irp ); ASSERT( KeGetCurrentIrql() <= APC_LEVEL ); ExAcquireFastMutex( &DevExt->LfsDeviceExt.FastMutex ); fastMutexAcquired = TRUE; try { if (!FlagOn(DevExt->LfsDeviceExt.Flags, LFS_DEVICE_FLAG_MOUNTED)) { result = FALSE; leave; } ASSERT( DevExt->LfsDeviceExt.AttachedToDeviceObject == DevExt->NLExtHeader.AttachedToDeviceObject ); if (DevExt->LfsDeviceExt.AttachedToDeviceObject == NULL) { NDAS_ASSERT( FALSE ); result = FALSE; leave; } if (!(FlagOn(DevExt->LfsDeviceExt.Flags, LFS_DEVICE_FLAG_MOUNTED) && !FlagOn(DevExt->LfsDeviceExt.Flags, LFS_DEVICE_FLAG_DISMOUNTED))) { ASSERT( DevExt->LfsDeviceExt.Readonly == NULL || ReadonlyLookUpCcb(DevExt->LfsDeviceExt.Readonly, fileObject) == NULL ); result = FALSE; leave; } switch (irpSp->MajorFunction) { case IRP_MJ_PNP: break; default: ExReleaseFastMutex( &DevExt->LfsDeviceExt.FastMutex ); fastMutexAcquired = FALSE; if (DevExt->LfsDeviceExt.Readonly) { status = ReadonlyRedirectIrp( DevExt, Irp, &result ); } else { result = FALSE; } leave; } if (irpSp->MajorFunction == IRP_MJ_PNP) { PrintIrp( LFS_DEBUG_READONLY_NOISE, __FUNCTION__, &DevExt->LfsDeviceExt, Irp ); if (irpSp->MinorFunction == IRP_MN_SURPRISE_REMOVAL) { if (DevExt->LfsDeviceExt.NetdiskPartition == NULL) { NDAS_ASSERT( FALSE ); } else { SetFlag( DevExt->LfsDeviceExt.Flags, LFS_DEVICE_FLAG_SURPRISE_REMOVED ); ExReleaseFastMutex( &DevExt->LfsDeviceExt.FastMutex ); fastMutexAcquired = FALSE; NetdiskManager_SurpriseRemoval( GlobalLfs.NetdiskManager, DevExt->LfsDeviceExt.NetdiskPartition, DevExt->LfsDeviceExt.NetdiskEnabledMode ); } DevExt->LfsDeviceExt.NetdiskPartition = NULL; //.........这里部分代码省略.........
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:101,
示例12: Bus_FDO_PnP//.........这里部分代码省略......... // call the next driver. // // // First check to see whether you have received cancel-remove // without first receiving a query-remove. This could happen if // someone above us fails a query-remove and passes down the // subsequent cancel-remove. // if (RemovePending == DeviceData->DevicePnPState) { // // We did receive a query-remove, so restore. // RESTORE_PREVIOUS_PNP_STATE(DeviceData); } Irp->IoStatus.Status = STATUS_SUCCESS;// You must not fail the IRP. break; case IRP_MN_SURPRISE_REMOVAL: // // The device has been unexpectedly removed from the machine // and is no longer available for I/O. Bus_RemoveFdo clears // all the resources, frees the interface and de-registers // with WMI, but it doesn't delete the FDO. That's done // later in Remove device query. // SET_NEW_PNP_STATE(DeviceData, SurpriseRemovePending); Bus_RemoveFdo(DeviceData); ExAcquireFastMutex (&DeviceData->Mutex); listHead = &DeviceData->ListOfPDOs; for(entry = listHead->Flink,nextEntry = entry->Flink; entry != listHead; entry = nextEntry,nextEntry = entry->Flink) { pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); RemoveEntryList (&pdoData->Link); InitializeListHead (&pdoData->Link); pdoData->ParentFdo = NULL; pdoData->ReportedMissing = TRUE; } ExReleaseFastMutex (&DeviceData->Mutex); Irp->IoStatus.Status = STATUS_SUCCESS; // You must not fail the IRP. break; case IRP_MN_REMOVE_DEVICE: // // The Plug & Play system has dictated the removal of this device. // We have no choice but to detach and delete the device object. // // // Check the state flag to see whether you are surprise removed // if (DeviceData->DevicePnPState != SurpriseRemovePending) {
开发者ID:DevNullx64,项目名称:usbip-windows-mirror,代码行数:67,
示例13: Bus_EjectDeviceNTSTATUSBus_EjectDevice ( PBUSENUM_EJECT_HARDWARE Eject, PFDO_DEVICE_DATA FdoData )/*++Routine Description: The user application has told us to eject the device from the bus. In a real situation the driver gets notified by an interrupt when the user presses the Eject button on the device.Arguments: Eject - pointer to Eject hardware structure. FdoData - contains the list to iterate overReturns: STATUS_SUCCESS upon successful removal from the list STATUS_INVALID_PARAMETER if the removal was unsuccessful--*/{ PLIST_ENTRY entry; PPDO_DEVICE_DATA pdoData; BOOLEAN found = FALSE, ejectAll; PAGED_CODE (); ejectAll = (0 == Eject->SerialNo); ExAcquireFastMutex (&FdoData->Mutex); if (ejectAll) { Bus_KdPrint (FdoData, BUS_DBG_IOCTL_NOISE, ("Ejecting all the pdos!/n")); } else { Bus_KdPrint (FdoData, BUS_DBG_IOCTL_NOISE, ("Ejecting %d/n", Eject->SerialNo)); } if (FdoData->NumPDOs == 0) { // // Somebody in user space isn't playing nice!!! // Bus_KdPrint (FdoData, BUS_DBG_IOCTL_ERROR, ("No devices to eject!/n")); ExReleaseFastMutex (&FdoData->Mutex); return STATUS_NO_SUCH_DEVICE; } // // Scan the list to find matching PDOs // for (entry = FdoData->ListOfPDOs.Flink; entry != &FdoData->ListOfPDOs; entry = entry->Flink) { pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); Bus_KdPrint (FdoData, BUS_DBG_IOCTL_NOISE, ("found device %d/n", pdoData->SerialNo)); if (ejectAll || Eject->SerialNo == pdoData->SerialNo) { Bus_KdPrint (FdoData, BUS_DBG_IOCTL_INFO, ("Ejected %d/n", pdoData->SerialNo)); found = TRUE; IoRequestDeviceEject(pdoData->Self); if (!ejectAll) { break; } } } ExReleaseFastMutex (&FdoData->Mutex); if (found) { return STATUS_SUCCESS; } Bus_KdPrint (FdoData, BUS_DBG_IOCTL_ERROR, ("Device %d is not present/n", Eject->SerialNo)); return STATUS_INVALID_PARAMETER;}
开发者ID:DevNullx64,项目名称:usbip-windows-mirror,代码行数:84,
示例14: bus_unplug_devNTSTATUSbus_unplug_dev ( int addr, PFDO_DEVICE_DATA fdodata ){ PLIST_ENTRY entry; PPDO_DEVICE_DATA pdodata; int found=0, all; PAGED_CODE (); if(addr<0||addr>127) return STATUS_INVALID_PARAMETER; all = (0 == addr); ExAcquireFastMutex (&fdodata->Mutex); if (all) { Bus_KdPrint (fdodata, BUS_DBG_IOCTL_NOISE, ("Plugging out all the devices!/n")); } else { Bus_KdPrint (fdodata, BUS_DBG_IOCTL_NOISE, ("Plugging out %d/n", addr)); } if (fdodata->NumPDOs == 0) { // // We got a 2nd plugout...somebody in user space isn't playing nice!!! // Bus_KdPrint (fdodata, BUS_DBG_IOCTL_ERROR, ("BAD BAD BAD...2 removes!!! Send only one!/n")); ExReleaseFastMutex (&fdodata->Mutex); return STATUS_NO_SUCH_DEVICE; } for (entry = fdodata->ListOfPDOs.Flink; entry != &fdodata->ListOfPDOs; entry = entry->Flink) { pdodata = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); Bus_KdPrint (fdodata, BUS_DBG_IOCTL_NOISE, ("found device %d/n", pdodata->SerialNo)); if (all || addr == pdodata->SerialNo) { Bus_KdPrint (fdodata, BUS_DBG_IOCTL_INFO, ("Plugging out %d/n", pdodata->SerialNo)); pdodata->Present = FALSE; complete_pending_read_irp(pdodata); found = 1; if (!all) { break; } } } ExReleaseFastMutex (&fdodata->Mutex); if (found) { IoInvalidateDeviceRelations (fdodata->UnderlyingPDO, BusRelations); ExAcquireFastMutex (&fdodata->Mutex); for (entry = fdodata->ListOfPDOs.Flink; entry != &fdodata->ListOfPDOs; entry = entry->Flink) { pdodata = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); if( pdodata->Present ==FALSE){ complete_pending_irp(pdodata); SET_NEW_PNP_STATE(pdodata,PNP_DEVICE_REMOVED); IoInvalidateDeviceState(pdodata->Self); } } ExReleaseFastMutex (&fdodata->Mutex); Bus_KdPrint (fdodata, BUS_DBG_IOCTL_ERROR, ("Device %d plug out finished/n", addr)); return STATUS_SUCCESS; } return STATUS_INVALID_PARAMETER;}
开发者ID:DevNullx64,项目名称:usbip-windows-mirror,代码行数:87,
示例15: ExFreeToPagedLookasideListVOIDExFreeToPagedLookasideList( IN PPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry)/*++Routine Description: This function inserts (pushes) the specified entry into the specified paged lookaside list.Arguments: Lookaside - Supplies a pointer to a paged lookaside list structure. Entry - Supples a pointer to the entry that is inserted in the lookaside list.Return Value: None.--*/{ Lookaside->L.TotalFrees += 1;#if !defined(_PPC_) if (Isx86FeaturePresent(KF_CMPXCHG8B)) { if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { Lookaside->L.FreeMisses += 1; (Lookaside->L.Free)(Entry); } else { ExInterlockedPushEntrySList(&Lookaside->L.ListHead, (PSINGLE_LIST_ENTRY)Entry, NULL); } return; }#endif ExAcquireFastMutex(&Lookaside->Lock); if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { ExReleaseFastMutex(&Lookaside->Lock); Lookaside->L.FreeMisses += 1; (Lookaside->L.Free)(Entry); } else { PushEntryList(&Lookaside->L.ListHead.Next, (PSINGLE_LIST_ENTRY)Entry); Lookaside->L.ListHead.Depth += 1; ExReleaseFastMutex(&Lookaside->Lock); } return;}
开发者ID:BillTheBest,项目名称:WinNT4,代码行数:62,
示例16: Readonly_Create//.........这里部分代码省略......... readonly->TryCloseWorkItem = IoAllocateWorkItem( (PDEVICE_OBJECT)VolDo );#endif KeInitializeEvent( &readonly->ReadyEvent, NotificationEvent, FALSE ); InitializeListHead( &readonly->RequestQueue ); KeInitializeSpinLock( &readonly->RequestQSpinLock ); KeInitializeEvent( &readonly->RequestEvent, NotificationEvent, FALSE );#if 0 //////////////////////////////////////// InitializeListHead( &readonly->FcbQueue ); ExInitializeFastMutex( &readonly->FcbQMutex ); /////////////////////////////////////////#endif KeInitializeEvent( &readonly->DiskmountReadyEvent, NotificationEvent, FALSE ); InitializeListHead( &readonly->DirNotifyList ); FsRtlNotifyInitializeSync( &readonly->NotifySync ); InitializeObjectAttributes( &objectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL ); readonly->SessionId = 0; status = PsCreateSystemThread( &readonly->ThreadHandle, THREAD_ALL_ACCESS, &objectAttributes, NULL, NULL, ReadonlyThreadProc, readonly ); if (!NT_SUCCESS(status)) { ASSERT( LFS_UNEXPECTED ); Readonly_Close( readonly ); return NULL; } status = ObReferenceObjectByHandle( readonly->ThreadHandle, FILE_READ_DATA, NULL, KernelMode, &readonly->ThreadObject, NULL ); if (!NT_SUCCESS(status)) { NDAS_ASSERT( NDAS_ASSERT_INSUFFICIENT_RESOURCES ); Readonly_Close( readonly ); return NULL; } readonly->SessionId ++; timeOut.QuadPart = -LFS_TIME_OUT; status = KeWaitForSingleObject( &readonly->ReadyEvent, Executive, KernelMode, FALSE, &timeOut ); if (status != STATUS_SUCCESS) { NDAS_ASSERT( FALSE ); Readonly_Close( readonly ); return NULL; } KeClearEvent( &readonly->ReadyEvent ); ExAcquireFastMutex( &readonly->FastMutex ); if (!FlagOn(readonly->Thread.Flags, READONLY_THREAD_FLAG_START) || FlagOn(readonly->Thread.Flags, READONLY_THREAD_FLAG_STOPED)) { if (readonly->Thread.SessionStatus != STATUS_DISK_CORRUPT_ERROR && readonly->Thread.SessionStatus != STATUS_UNRECOGNIZED_VOLUME) { ExReleaseFastMutex( &readonly->FastMutex ); Readonly_Close( readonly ); return NULL; } } ExReleaseFastMutex( &readonly->FastMutex ); ClearFlag( readonly->Flags, READONLY_FLAG_INITIALIZING ); SetFlag( readonly->Flags, READONLY_FLAG_START ); SPY_LOG_PRINT( LFS_DEBUG_READONLY_TRACE, ("Readonly_Create: The client thread are ready readonly = %p/n", readonly) ); return readonly;}
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:101,
示例17: NdFatSecondaryCommonRead//.........这里部分代码省略......... = SecondaryAcquireResourceExclusiveLite( IrpContext, &volDo->Secondary->SessionResource, BooleanFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT) ); if (FlagOn(volDo->Secondary->Thread.Flags, SECONDARY_THREAD_FLAG_REMOTE_DISCONNECTED) ) { PrintIrp( Dbg2, "SECONDARY_THREAD_FLAG_REMOTE_DISCONNECTED", NULL, IrpContext->OriginatingIrp ); FatRaiseStatus( IrpContext, STATUS_CANT_WAIT ); } outputBuffer = FatMapUserBuffer( IrpContext, Irp ); totalReadLength = 0; do { ULONG outputBufferLength; if (fcb->UncleanCount == 0) { DebugTrace( 0, Dbg2, "NdFatSecondaryCommonRead: fileName = %wZ/n", &fileObject->FileName ); status = STATUS_FILE_CLOSED; break; } if (!FlagOn(ccb->NdFatFlags, ND_FAT_CLEANUP_COMPLETE)) { primaryFileHandle = ccb->PrimaryFileHandle; } else { PLIST_ENTRY ccbListEntry; ExAcquireFastMutex( &fcb->CcbQMutex ); for (primaryFileHandle = 0, ccbListEntry = fcb->CcbQueue.Flink; ccbListEntry != &fcb->CcbQueue; ccbListEntry = ccbListEntry->Flink) { if (!FlagOn(CONTAINING_RECORD(ccbListEntry, CCB, FcbListEntry)->NdFatFlags, ND_FAT_CLEANUP_COMPLETE)) { primaryFileHandle = CONTAINING_RECORD(ccbListEntry, CCB, FcbListEntry)->PrimaryFileHandle; break; } } ExReleaseFastMutex( &fcb->CcbQMutex ); } ASSERT( primaryFileHandle ); outputBufferLength = ((read.Length-totalReadLength) <= volDo->Secondary->Thread.SessionContext.SecondaryMaxDataSize) ? (read.Length-totalReadLength) : volDo->Secondary->Thread.SessionContext.SecondaryMaxDataSize; secondaryRequest = ALLOC_WINXP_SECONDARY_REQUEST( volDo->Secondary, IRP_MJ_READ, volDo->Secondary->Thread.SessionContext.SecondaryMaxDataSize ); if (secondaryRequest == NULL) { FatRaiseStatus( IrpContext, STATUS_INSUFFICIENT_RESOURCES ); } ndfsRequestHeader = &secondaryRequest->NdfsRequestHeader; INITIALIZE_NDFS_REQUEST_HEADER( ndfsRequestHeader, NDFS_COMMAND_EXECUTE, volDo->Secondary, IRP_MJ_READ, 0 );
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:66,
示例18: MmGetPhysicalMemoryRangesPPHYSICAL_MEMORY_RANGEMmGetPhysicalMemoryRanges ( VOID )/*++Routine Description: This routine returns the virtual address of a nonpaged pool block which contains the physical memory ranges in the system. The returned block contains physical address and page count pairs. The last entry contains zero for both. The caller must understand that this block can change at any point before or after this snapshot. It is the caller's responsibility to free this block.Arguments: None.Return Value: NULL on failure.Environment: Kernel mode. PASSIVE level. No locks held.--*/{ ULONG i; KIRQL OldIrql; PPHYSICAL_MEMORY_RANGE p; PPHYSICAL_MEMORY_RANGE PhysicalMemoryBlock; ASSERT (KeGetCurrentIrql() == PASSIVE_LEVEL); ExAcquireFastMutex (&MmDynamicMemoryMutex); i = sizeof(PHYSICAL_MEMORY_RANGE) * (MmPhysicalMemoryBlock->NumberOfRuns + 1); PhysicalMemoryBlock = ExAllocatePoolWithTag (NonPagedPool, i, 'hPmM'); if (PhysicalMemoryBlock == NULL) { ExReleaseFastMutex (&MmDynamicMemoryMutex); return NULL; } p = PhysicalMemoryBlock; LOCK_PFN (OldIrql); ASSERT (i == (sizeof(PHYSICAL_MEMORY_RANGE) * (MmPhysicalMemoryBlock->NumberOfRuns + 1))); for (i = 0; i < MmPhysicalMemoryBlock->NumberOfRuns; i += 1) { p->BaseAddress.QuadPart = (LONGLONG)MmPhysicalMemoryBlock->Run[i].BasePage * PAGE_SIZE; p->NumberOfBytes.QuadPart = (LONGLONG)MmPhysicalMemoryBlock->Run[i].PageCount * PAGE_SIZE; p += 1; } p->BaseAddress.QuadPart = 0; p->NumberOfBytes.QuadPart = 0; UNLOCK_PFN (OldIrql); ExReleaseFastMutex (&MmDynamicMemoryMutex); return PhysicalMemoryBlock;}
开发者ID:conioh,项目名称:os-design,代码行数:76,
示例19: Bus_FDO_PnPNTSTATUSBus_FDO_PnP ( PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpStack, PFDO_DEVICE_DATA DeviceData ){ NTSTATUS status; ULONG length, prevcount, numPdosPresent; PLIST_ENTRY entry; PPDO_DEVICE_DATA pdoData; PDEVICE_RELATIONS relations, oldRelations; PAGED_CODE (); switch (IrpStack->MinorFunction) { case IRP_MN_START_DEVICE: status = Bus_StartFdo (DeviceData, Irp); // // We must now complete the IRP, since we stopped it in the // completion routine with MORE_PROCESSING_REQUIRED. // Irp->IoStatus.Status = status; IoCompleteRequest (Irp, IO_NO_INCREMENT); return status; case IRP_MN_QUERY_STOP_DEVICE: // // The PnP manager is trying to stop the device // for resource rebalancing. // SET_NEW_PNP_STATE(DeviceData->Common, StopPending); Irp->IoStatus.Status = STATUS_SUCCESS; break; case IRP_MN_CANCEL_STOP_DEVICE: // // The PnP Manager sends this IRP, at some point after an // IRP_MN_QUERY_STOP_DEVICE, to inform the drivers for a // device that the device will not be stopped for // resource reconfiguration. // // // First check to see whether you have received cancel-stop // without first receiving a query-stop. This could happen if // someone above us fails a query-stop and passes down the subsequent // cancel-stop. // if (StopPending == DeviceData->Common.DevicePnPState) { // // We did receive a query-stop, so restore. // RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); ASSERT(DeviceData->Common.DevicePnPState == Started); } Irp->IoStatus.Status = STATUS_SUCCESS; // We must not fail the IRP. break; case IRP_MN_QUERY_DEVICE_RELATIONS: DPRINT("/tQueryDeviceRelation Type: %s/n", DbgDeviceRelationString(/ IrpStack->Parameters.QueryDeviceRelations.Type)); if (BusRelations != IrpStack->Parameters.QueryDeviceRelations.Type) { // // We don't support any other Device Relations // break; } ExAcquireFastMutex (&DeviceData->Mutex); oldRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information; if (oldRelations) { prevcount = oldRelations->Count; if (!DeviceData->NumPDOs) { // // There is a device relations struct already present and we have // nothing to add to it, so just call IoSkip and IoCall // ExReleaseFastMutex (&DeviceData->Mutex); break; } } else { prevcount = 0; }//.........这里部分代码省略.........
开发者ID:Strongc,项目名称:reactos,代码行数:101,
示例20: MmAddPhysicalMemory//.........这里部分代码省略......... return STATUS_NOT_SUPPORTED; } PfnDatabaseIsPhysical = TRUE; } else { PfnDatabaseIsPhysical = FALSE; } StartPage = (PFN_NUMBER)(StartAddress->QuadPart >> PAGE_SHIFT); NumberOfPages = (PFN_NUMBER)(NumberOfBytes->QuadPart >> PAGE_SHIFT); EndPage = StartPage + NumberOfPages; if (EndPage - 1 > MmHighestPossiblePhysicalPage) { // // Truncate the request into something that can be mapped by the PFN // database. // EndPage = MmHighestPossiblePhysicalPage + 1; NumberOfPages = EndPage - StartPage; } // // The range cannot wrap. // if (StartPage >= EndPage) { return STATUS_INVALID_PARAMETER_1; } ExAcquireFastMutex (&MmDynamicMemoryMutex); i = (sizeof(PHYSICAL_MEMORY_DESCRIPTOR) + (sizeof(PHYSICAL_MEMORY_RUN) * (MmPhysicalMemoryBlock->NumberOfRuns + 1))); NewPhysicalMemoryBlock = ExAllocatePoolWithTag (NonPagedPool, i, ' mM'); if (NewPhysicalMemoryBlock == NULL) { ExReleaseFastMutex (&MmDynamicMemoryMutex); return STATUS_INSUFFICIENT_RESOURCES; } // // The range cannot overlap any ranges that are already present. // start = 0; LOCK_PFN (OldIrql); do { count = MmPhysicalMemoryBlock->Run[start].PageCount; Page = MmPhysicalMemoryBlock->Run[start].BasePage; if (count != 0) { LastPage = Page + count; if ((StartPage < Page) && (EndPage > Page)) { UNLOCK_PFN (OldIrql);
开发者ID:conioh,项目名称:os-design,代码行数:67,
示例21: Secondary_CloseVOIDSecondary_Close ( IN PSECONDARY Secondary ){ NTSTATUS status; LARGE_INTEGER timeOut; PLIST_ENTRY secondaryRequestEntry; PSECONDARY_REQUEST secondaryRequest; DebugTrace2( 0, Dbg2, ("Secondary close Secondary = %p/n", Secondary) ); ExAcquireFastMutex( &Secondary->FastMutex ); if (FlagOn(Secondary->Flags, SECONDARY_FLAG_CLOSED)) { //ASSERT( FALSE ); ExReleaseFastMutex( &Secondary->FastMutex ); return; } SetFlag( Secondary->Flags, SECONDARY_FLAG_CLOSED ); ExReleaseFastMutex( &Secondary->FastMutex ); if (Secondary->ThreadHandle == NULL) { Secondary_Dereference( Secondary ); return; } ASSERT( Secondary->ThreadObject != NULL ); DebugTrace2( 0, Dbg, ("Secondary close SECONDARY_REQ_DISCONNECT Secondary = %p/n", Secondary) ); secondaryRequest = AllocSecondaryRequest( Secondary, 0, FALSE ); secondaryRequest->RequestType = SECONDARY_REQ_DISCONNECT; QueueingSecondaryRequest( Secondary, secondaryRequest ); secondaryRequest = AllocSecondaryRequest( Secondary, 0, FALSE ); secondaryRequest->RequestType = SECONDARY_REQ_DOWN; QueueingSecondaryRequest( Secondary, secondaryRequest ); DebugTrace2( 0, Dbg, ("Secondary close SECONDARY_REQ_DISCONNECT end Secondary = %p/n", Secondary) ); timeOut.QuadPart = -NDASFAT_TIME_OUT; status = KeWaitForSingleObject( Secondary->ThreadObject, Executive, KernelMode, FALSE, &timeOut ); if (status == STATUS_SUCCESS) { DebugTrace2( 0, Dbg, ("Secondary_Close: thread stoped Secondary = %p/n", Secondary)); ObDereferenceObject( Secondary->ThreadObject ); Secondary->ThreadHandle = NULL; Secondary->ThreadObject = NULL; } else { ASSERT( NDASFAT_BUG ); return; } ASSERT( Secondary->VolDo->Vcb.SecondaryOpenFileCount == 0 ); ASSERT( IsListEmpty(&Secondary->FcbQueue) ); ASSERT( IsListEmpty(&Secondary->RecoveryCcbQueue) ); ASSERT( IsListEmpty(&Secondary->RequestQueue) ); while (secondaryRequestEntry = ExInterlockedRemoveHeadList(&Secondary->RequestQueue, &Secondary->RequestQSpinLock)) { PSECONDARY_REQUEST secondaryRequest2; InitializeListHead( secondaryRequestEntry ); secondaryRequest2 = CONTAINING_RECORD( secondaryRequestEntry, SECONDARY_REQUEST, ListEntry ); secondaryRequest2->ExecuteStatus = STATUS_IO_DEVICE_ERROR; if (secondaryRequest2->Synchronous == TRUE) KeSetEvent( &secondaryRequest2->CompleteEvent, IO_DISK_INCREMENT, FALSE ); else DereferenceSecondaryRequest( secondaryRequest2 ); } Secondary_Dereference( Secondary );//.........这里部分代码省略.........
开发者ID:Nevermore2015,项目名称:ndas4windows,代码行数:101,
示例22: MmRemovePhysicalMemory//.........这里部分代码省略......... PfnDatabaseIsPhysical = TRUE; } else { PfnDatabaseIsPhysical = FALSE; } StartPage = (PFN_NUMBER)(StartAddress->QuadPart >> PAGE_SHIFT); NumberOfPages = (PFN_COUNT)(NumberOfBytes->QuadPart >> PAGE_SHIFT); EndPage = StartPage + NumberOfPages; if (EndPage - 1 > MmHighestPossiblePhysicalPage) { // // Truncate the request into something that can be mapped by the PFN // database. // EndPage = MmHighestPossiblePhysicalPage + 1; NumberOfPages = (PFN_COUNT)(EndPage - StartPage); } // // The range cannot wrap. // if (StartPage >= EndPage) { return STATUS_INVALID_PARAMETER_1; } StartPfn = MI_PFN_ELEMENT (StartPage); EndPfn = MI_PFN_ELEMENT (EndPage); ExAcquireFastMutex (&MmDynamicMemoryMutex);#if DBG MiDynmemData[0] += 1;#endif // // Decrease all commit limits to reflect the removed memory. // ExAcquireSpinLock (&MmChargeCommitmentLock, &OldIrql); ASSERT (MmTotalCommitLimit <= MmTotalCommitLimitMaximum); if ((NumberOfPages + 100 > MmTotalCommitLimit - MmTotalCommittedPages) || (MmTotalCommittedPages > MmTotalCommitLimit)) {#if DBG MiDynmemData[1] += 1;#endif ExReleaseSpinLock (&MmChargeCommitmentLock, OldIrql); ExReleaseFastMutex (&MmDynamicMemoryMutex); return STATUS_INSUFFICIENT_RESOURCES; } MmTotalCommitLimit -= NumberOfPages; MmTotalCommitLimitMaximum -= NumberOfPages; ExReleaseSpinLock (&MmChargeCommitmentLock, OldIrql); // // Check for outstanding promises that cannot be broken. //
开发者ID:conioh,项目名称:os-design,代码行数:67,
示例23: NdFatSecondaryCommonWrite3//.........这里部分代码省略......... } else { FatRaiseStatus( IrpContext, STATUS_CANT_WAIT ); } } inputBuffer = FatMapUserBuffer( IrpContext, Irp ); totalWriteLength = 0; do { ULONG inputBufferLength; _U8 *ndfsWinxpRequestData; _U64 primaryFileHandle; if (fcb->UncleanCount == 0) { DebugTrace( 0, Dbg2, "NdFatSecondaryCommonWrite2: fileName = %wZ/n", &fileObject->FileName ); totalWriteLength = write.Length; status = STATUS_FILE_CLOSED; break; } if (!FlagOn(ccb->NdFatFlags, ND_FAT_CLEANUP_COMPLETE)) { primaryFileHandle = ccb->PrimaryFileHandle; } else { PLIST_ENTRY ccbListEntry; ExAcquireFastMutex( &fcb->CcbQMutex ); for (primaryFileHandle = 0, ccbListEntry = fcb->CcbQueue.Flink; ccbListEntry != &fcb->CcbQueue; ccbListEntry = ccbListEntry->Flink) { if (!FlagOn(CONTAINING_RECORD(ccbListEntry, CCB, FcbListEntry)->NdFatFlags, ND_FAT_CLEANUP_COMPLETE)) { primaryFileHandle = CONTAINING_RECORD(ccbListEntry, CCB, FcbListEntry)->PrimaryFileHandle; break; } } ExReleaseFastMutex( &fcb->CcbQMutex ); } ASSERT( primaryFileHandle ); inputBufferLength = ((write.Length-totalWriteLength) <= volDo->Secondary->Thread.SessionContext.SecondaryMaxDataSize) ? (write.Length-totalWriteLength) : volDo->Secondary->Thread.SessionContext.SecondaryMaxDataSize; secondaryRequest = ALLOC_WINXP_SECONDARY_REQUEST( volDo->Secondary, IRP_MJ_WRITE, volDo->Secondary->Thread.SessionContext.PrimaryMaxDataSize ); if (secondaryRequest == NULL) { FatRaiseStatus( IrpContext, STATUS_INSUFFICIENT_RESOURCES ); } ndfsRequestHeader = &secondaryRequest->NdfsRequestHeader; INITIALIZE_NDFS_REQUEST_HEADER( ndfsRequestHeader, NDFS_COMMAND_EXECUTE, volDo->Secondary, IRP_MJ_WRITE, inputBufferLength );
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:66,
示例24: MiniSecondaryNtfsPassThrough//.........这里部分代码省略......... if (Secondary_LookUpFileExtension(Secondary, fileObject)) { SecondaryFileObjectClose( Secondary, fileObject ); } Data->IoStatus.Status = STATUS_SUCCESS; Data->IoStatus.Information = 0; } else if (iopb->MajorFunction == IRP_MJ_CLEANUP) { InterlockedDecrement( &((PLFS_FCB)iopb->TargetFileObject->FsContext)->UncleanCount ); SetFlag( fileObject->Flags, FO_CLEANUP_COMPLETE ); Data->IoStatus.Status = STATUS_SUCCESS; Data->IoStatus.Information = 0; } else { Data->IoStatus.Status = STATUS_DISK_CORRUPT_ERROR; Data->IoStatus.Information = 0; } Secondary_Dereference( Secondary ); return FLT_PREOP_COMPLETE; } while (1) { NDASFS_ASSERT( fastMutexSet == FALSE ); NDASFS_ASSERT( retry == FALSE ); ExAcquireFastMutex( &Secondary->FastMutex ); if (FlagOn(Secondary->Flags, SECONDARY_FLAG_CLOSED)) { SPY_LOG_PRINT( LFS_DEBUG_SECONDARY_ERROR, ("Secondary is already closed Secondary = %p/n", Secondary) ); ExReleaseFastMutex( &Secondary->FastMutex ); NDASFS_ASSERT( iopb->MajorFunction == IRP_MJ_CREATE ); if (iopb->MajorFunction == IRP_MJ_CLOSE) { if (Secondary_LookUpFileExtension(Secondary, fileObject)) { SecondaryFileObjectClose( Secondary, fileObject ); } Data->IoStatus.Status = STATUS_SUCCESS; Data->IoStatus.Information = 0; } else if (iopb->MajorFunction == IRP_MJ_CLEANUP) { InterlockedDecrement( &((PLFS_FCB)iopb->TargetFileObject->FsContext)->UncleanCount ); SetFlag( fileObject->Flags, FO_CLEANUP_COMPLETE ); Data->IoStatus.Status = STATUS_SUCCESS; Data->IoStatus.Information = 0; } else { Data->IoStatus.Status = STATUS_TOO_LATE; Data->IoStatus.Information = 0;
开发者ID:JanD1943,项目名称:ndas4windows,代码行数:67,
示例25: DoFdoPnP// fdo pnpNTSTATUS DoFdoPnP(PDEVICE_OBJECT pDevice,PIRP pIrp){ NTSTATUS status = STATUS_SUCCESS; PFdoExt pFdoExt = static_cast<PFdoExt>(pDevice->DeviceExtension); // nead call next driver BOOLEAN bCallNext = TRUE; PIO_STACK_LOCATION pIoStack = IoGetCurrentIrpStackLocation(pIrp); // inc io count IncIoCount(pFdoExt); // save minor code UCHAR uMinorCode = pIoStack->MinorFunction; switch(uMinorCode) { case IRP_MN_START_DEVICE: { // send down first status = SendIrpToLowerDeviceSyn(pFdoExt->m_pLowerDevice,pIrp); if(NT_SUCCESS(status)) { // set device power state pFdoExt->m_devPowerState = PowerDeviceD0; POWER_STATE state; state.DeviceState = PowerDeviceD0; PoSetPowerState(pDevice,DevicePowerState,state); // set device interface state status = IoSetDeviceInterfaceState(&pFdoExt->m_symbolicName,TRUE); // set device pnp state SetNewPnpState(pFdoExt,IRP_MN_START_DEVICE); } // complete the irp pIrp->IoStatus.Status = status; IoCompleteRequest(pIrp,IO_NO_INCREMENT); // do not call down the device stack bCallNext = FALSE; } break; // set pnp state directly case IRP_MN_QUERY_REMOVE_DEVICE: case IRP_MN_QUERY_STOP_DEVICE: SetNewPnpState(pFdoExt,uMinorCode); break; // check for current pnp state,and restore it case IRP_MN_CANCEL_REMOVE_DEVICE: if(pFdoExt->m_ulCurrentPnpState == IRP_MN_QUERY_REMOVE_DEVICE) RestorePnpState(pFdoExt); break; // the same case IRP_MN_CANCEL_STOP_DEVICE: if(pFdoExt->m_ulCurrentPnpState == IRP_MN_QUERY_STOP_DEVICE) RestorePnpState(pFdoExt); break; // remove case IRP_MN_REMOVE_DEVICE: { // normal remove if(pFdoExt->m_ulCurrentPnpState != IRP_MN_SURPRISE_REMOVAL) { // just stop device interface if(pFdoExt->m_symbolicName.Buffer) { // set device interface false IoSetDeviceInterfaceState(&pFdoExt->m_symbolicName,FALSE); RtlFreeUnicodeString(&pFdoExt->m_symbolicName); } } // update pnp state SetNewPnpState(pFdoExt,IRP_MN_REMOVE_DEVICE); // dec outstandingio by 2 DecIoCount(pFdoExt); DecIoCount(pFdoExt); // wait other irps finish KeWaitForSingleObject(&pFdoExt->m_evRemove,Executive,KernelMode,FALSE,NULL); // check pdo ExAcquireFastMutex(&pFdoExt->m_mutexEnumPdo); // if the pdo is present if(pFdoExt->m_pEnumPdo) {//.........这里部分代码省略.........
开发者ID:maodapeng,项目名称:WDUtils,代码行数:101,
示例26: File_UpdateEntireFileByFileObjectNTSTATUSFile_UpdateEntireFileByFileObject( __in PFLT_CALLBACK_DATA Data, __in PFLT_RELATED_OBJECTS FltObjects, __in PFILE_OBJECT FileObject, __in PSTREAM_CONTEXT pStreamCtx, __in PVOLUME_CONTEXT pVolCtx ){ NTSTATUS status = STATUS_SUCCESS ; PUCHAR Buffer = NULL ; LARGE_INTEGER ReadWriteOffset = {0} ; BOOLEAN EndOfFile = FALSE; ULONG uReadBytes = 0 ; ULONG uWriteBytes = 0 ; ULONG uAllocateBufferSize = 1024*64 ; ULONG uReadWriteLength = 0 ; ULONG uOffset = 0 ; LARGE_INTEGER FileSize = {0} ; PFILE_FLAG psFileFlag = NULL ; KIRQL OldIrql ; try{ //判断分配空间长度是否SectorSize对齐 if ((uAllocateBufferSize % pVolCtx->SectorSize) != 0) {//由于SectorSize目前为512bytes,故暂时先返回失败,以后可以对AllocateBufferSize进行调整 status = ERR_CORE_LENGTH_NOT_ALIGNED ; __leave ; } Buffer = FltAllocatePoolAlignedWithTag(FltObjects->Instance,PagedPool, uAllocateBufferSize, FILEFLAG_POOL_TAG); if (!Buffer) { status = STATUS_INSUFFICIENT_RESOURCES; __leave ; } //allocate local file flag buffer psFileFlag = (PFILE_FLAG)ExAllocatePoolWithTag(NonPagedPool, FILE_FLAG_LENGTH, FILEFLAG_POOL_TAG) ; if (NULL == psFileFlag) { status = STATUS_INSUFFICIENT_RESOURCES ; __leave ; } RtlCopyMemory(psFileFlag, g_psFileFlag, FILE_FLAG_LENGTH) ; //实际上这里应该是当前文件自身的flag //set current file size into file flag buffer File_GetFileSize(Data, FltObjects, &FileSize) ; psFileFlag->FileValidLength= FileSize.QuadPart ; //calculate padded file size if (FileSize.QuadPart % SECTOR_SIZE) {//file size is not multiply of sector size FileSize.QuadPart = FileSize.QuadPart + (SECTOR_SIZE - FileSize.QuadPart % SECTOR_SIZE) + FILE_FLAG_LENGTH ; } else {//file size is multiply of sector size FileSize.QuadPart += FILE_FLAG_LENGTH ; } RtlCopyMemory(psFileFlag->FileKeyHash, pStreamCtx->szKeyHash, HASH_SIZE) ; while (TRUE) { status = File_ReadWriteFile(IRP_MJ_READ, FltObjects->Instance, FileObject, &ReadWriteOffset, uAllocateBufferSize, Buffer, &uReadBytes, FLTFL_IO_OPERATION_NON_CACHED|FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET) ; if (!NT_SUCCESS(status)) break; if (0 == uReadBytes) break; if (KeGetCurrentIrql() > PASSIVE_LEVEL) ExAcquireSpinLock(&pVolCtx->FsCryptSpinLock, &OldIrql); else ExAcquireFastMutex(&pVolCtx->FsCtxTableMutex) ; ///if (data_crypt(pVolCtx->aes_ctr_ctx, Buffer, uOffset, uReadBytes)) ///{ /// if (KeGetCurrentIrql() > PASSIVE_LEVEL) /// ExReleaseSpinLock(&pVolCtx->FsCryptSpinLock, OldIrql) ; /// else /// ExReleaseFastMutex(&pVolCtx->FsCtxTableMutex) ; /// break ; ///} if (KeGetCurrentIrql() > PASSIVE_LEVEL) ExReleaseSpinLock(&pVolCtx->FsCryptSpinLock, OldIrql) ; else ExReleaseFastMutex(&pVolCtx->FsCtxTableMutex) ; if (uReadBytes < uAllocateBufferSize) EndOfFile = TRUE; status = File_ReadWriteFile(IRP_MJ_WRITE, //.........这里部分代码省略.........
开发者ID:yedushusheng,项目名称:FileEncryption,代码行数:101,
示例27: ExSwapinWorkerThreadsVOIDExSwapinWorkerThreads ( IN BOOLEAN AllowSwap )/*++Routine Description: Sets the kernel stacks of the delayed worker threads to be swappable or pins them into memory.Arguments: AllowSwap - Supplies TRUE if worker kernel stacks should be swappable, FALSE if not.Return Value: None.--*/{ PETHREAD Thread; PETHREAD CurrentThread; PEPROCESS Process; KAPC Apc; KEVENT SwapSetEvent; PAGED_CODE(); CurrentThread = PsGetCurrentThread(); KeInitializeEvent (&SwapSetEvent, NotificationEvent, FALSE); Process = PsInitialSystemProcess; // // Serialize callers. // ExAcquireFastMutex (&ExpWorkerSwapinMutex); // // Stop new threads from swapping. // ExpWorkersCanSwap = AllowSwap; // // Stop existing worker threads from swapping. // for (Thread = PsGetNextProcessThread (Process, NULL); Thread != NULL; Thread = PsGetNextProcessThread (Process, Thread)) { // // Skip threads that are not worker threads or worker threads that // were permanently marked noswap at creation time. // if (Thread->ExWorkerCanWaitUser == 0) { continue; } if (Thread == CurrentThread) { // // No need to use an APC on the current thread. // KeSetKernelStackSwapEnable (AllowSwap); } else { // // Queue an APC to the thread, and wait for it to fire: // KeInitializeApc (&Apc, &Thread->Tcb, InsertApcEnvironment, ExpSetSwappingKernelApc, NULL, NULL, KernelMode, &AllowSwap); if (KeInsertQueueApc (&Apc, &SwapSetEvent, NULL, 3)) { KeWaitForSingleObject (&SwapSetEvent, Executive, KernelMode, FALSE, NULL);//.........这里部分代码省略.........
开发者ID:BaoYu0721,项目名称:WRK-1.2,代码行数:101,
示例28: ExAllocateFromPagedLookasideListPVOIDExAllocateFromPagedLookasideList( IN PPAGED_LOOKASIDE_LIST Lookaside)/*++Routine Description: This function removes (pops) the first entry from the specified paged lookaside list.Arguments: Lookaside - Supplies a pointer to a paged lookaside list structure.Return Value: If an entry is removed from the specified lookaside list, then the address of the entry is returned as the function value. Otherwise, NULL is returned.--*/{ PVOID Entry; Lookaside->L.TotalAllocates += 1;#if !defined(_PPC_) if (Isx86FeaturePresent(KF_CMPXCHG8B)) { if ((Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, NULL)) == NULL) { Lookaside->L.AllocateMisses += 1; Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, Lookaside->L.Size, Lookaside->L.Tag); } return Entry; }#endif ExAcquireFastMutex(&Lookaside->Lock); Entry = PopEntryList(&Lookaside->L.ListHead.Next); if (Entry == NULL) { ExReleaseFastMutex(&Lookaside->Lock); Lookaside->L.AllocateMisses += 1; Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, Lookaside->L.Size, Lookaside->L.Tag); } else { Lookaside->L.ListHead.Depth -= 1; ExReleaseFastMutex(&Lookaside->Lock); } return Entry;}
开发者ID:BillTheBest,项目名称:WinNT4,代码行数:63,
示例29: VolDoThreadProcVOIDVolDoThreadProc ( IN PVOLUME_DEVICE_OBJECT VolDo ){ BOOLEAN volDoThreadTerminate = FALSE; DebugTrace( 0, Dbg2, ("VolDoThreadProc: Start VolDo = %p/n", VolDo) ); VolDo_Reference( VolDo ); VolDo->Thread.Flags = VOLDO_THREAD_FLAG_INITIALIZING; ExAcquireFastMutex( &VolDo->FastMutex ); ClearFlag( VolDo->Thread.Flags, VOLDO_THREAD_FLAG_INITIALIZING ); SetFlag( VolDo->Thread.Flags, VOLDO_THREAD_FLAG_START ); ExReleaseFastMutex( &VolDo->FastMutex ); KeSetEvent( &VolDo->ReadyEvent, IO_DISK_INCREMENT, FALSE ); volDoThreadTerminate = FALSE; while (volDoThreadTerminate == FALSE) { PKEVENT events[2]; LONG eventCount; NTSTATUS eventStatus; LARGE_INTEGER timeOut; ASSERT( KeGetCurrentIrql() == PASSIVE_LEVEL ); eventCount = 0; events[eventCount++] = &VolDo->RequestEvent; timeOut.QuadPart = -NDNTFS_VOLDO_THREAD_FLAG_TIME_OUT; eventStatus = KeWaitForMultipleObjects( eventCount, events, WaitAny, Executive, KernelMode, TRUE, &timeOut, NULL ); if (eventStatus == STATUS_TIMEOUT) { LARGE_INTEGER currentTime; KeQuerySystemTime( ¤tTime ); if (FlagOn(VolDo->NdasNtfsFlags, NDAS_NTFS_DEVICE_FLAG_SHUTDOWN) || !(FlagOn(VolDo->NdasNtfsFlags, NDAS_NTFS_DEVICE_FLAG_MOUNTED) /*&& !FlagOn(LfsDeviceExt->Flags, LFS_DEVICE_STOP)*/)) { continue; } if ((VolDo->NetdiskEnableMode == NETDISK_READ_ONLY && (VolDo->TryFlushOrPurgeTime.QuadPart > currentTime.QuadPart || (currentTime.QuadPart - VolDo->TryFlushOrPurgeTime.QuadPart) >= NDNTFS_TRY_PURGE_DURATION)) || (VolDo->ReceiveWriteCommand == TRUE && (VolDo->TryFlushOrPurgeTime.QuadPart > currentTime.QuadPart || (currentTime.QuadPart - VolDo->TryFlushOrPurgeTime.QuadPart) >= NDNTFS_TRY_FLUSH_DURATION))) { if (VolDo->NetdiskEnableMode != NETDISK_READ_ONLY && (currentTime.QuadPart - VolDo->CommandReceiveTime.QuadPart) <= NDNTFS_TRY_FLUSH_DURATION /*&& (currentTime.QuadPart - VolDo->TryFlushOrPurgeTime.QuadPart) <= (100*NDNTFS_TRY_FLUSH_OR_PURGE_DURATION)*/) { continue; } do { HANDLE eventHandle = NULL; HANDLE fileHandle = NULL; ACCESS_MASK desiredAccess; ULONG attributes; OBJECT_ATTRIBUTES objectAttributes; IO_STATUS_BLOCK ioStatusBlock; LARGE_INTEGER allocationSize; ULONG fileAttributes; ULONG shareAccess; ULONG createDisposition; ULONG createOptions; PVOID eaBuffer; ULONG eaLength; NTSTATUS createStatus; NTSTATUS fileSystemControlStatus; PIRP topLevelIrp; PRIMARY_REQUEST_INFO primaryRequestInfo; ASSERT( KeGetCurrentIrql() == PASSIVE_LEVEL );//.........这里部分代码省略.........
开发者ID:Nevermore2015,项目名称:ndas4windows,代码行数:101,
示例30: MmpPageOutPhysicalAddressNTSTATUSNTAPIMmpPageOutPhysicalAddress(PFN_NUMBER Page){ BOOLEAN ProcRef = FALSE, PageDirty; PFN_NUMBER SectionPage = 0; PMM_RMAP_ENTRY entry; PMM_SECTION_SEGMENT Segment = NULL; LARGE_INTEGER FileOffset; PMEMORY_AREA MemoryArea; PMMSUPPORT AddressSpace = NULL; BOOLEAN Dirty = FALSE; PVOID Address = NULL; PEPROCESS Process = NULL; NTSTATUS Status = STATUS_SUCCESS; MM_REQUIRED_RESOURCES Resources = { 0 }; DPRINTC("Page out %x (ref ct %x)/n", Page, MmGetReferenceCountPage(Page)); ExAcquireFastMutex(&MiGlobalPageOperation); if ((Segment = MmGetSectionAssociation(Page, &FileOffset))) { DPRINTC("Withdrawing page (%x) %p:%x/n", Page, Segment, FileOffset.LowPart); SectionPage = MmWithdrawSectionPage(Segment, &FileOffset, &Dirty); DPRINTC("SectionPage %x/n", SectionPage); if (SectionPage == MM_WAIT_ENTRY || SectionPage == 0) { DPRINT1("In progress page out %x/n", SectionPage); ExReleaseFastMutex(&MiGlobalPageOperation); return STATUS_UNSUCCESSFUL; } else { ASSERT(SectionPage == Page); } Resources.State = Dirty ? 1 : 0; } else { DPRINT("No segment association for %x/n", Page); } Dirty = MmIsDirtyPageRmap(Page); DPRINTC("Trying to unmap all instances of %x/n", Page); ExAcquireFastMutex(&RmapListLock); entry = MmGetRmapListHeadPage(Page); // Entry and Segment might be null here in the case that the page // is new and is in the process of being swapped in if (!entry && !Segment) { Status = STATUS_UNSUCCESSFUL; DPRINT1("Page %x is in transit/n", Page); ExReleaseFastMutex(&RmapListLock); goto bail; } while (entry != NULL && NT_SUCCESS(Status)) { Process = entry->Process; Address = entry->Address; DPRINTC("Process %p Address %p Page %x/n", Process, Address, Page); if (RMAP_IS_SEGMENT(Address)) { entry = entry->Next; continue; } if (Process && Address < MmSystemRangeStart) { /* Make sure we don't try to page out part of an exiting process */ if (PspIsProcessExiting(Process)) { DPRINT("bail/n"); ExReleaseFastMutex(&RmapListLock); goto bail; } ObReferenceObject(Process); ProcRef = TRUE; AddressSpace = &Process->Vm; } else { AddressSpace = MmGetKernelAddressSpace(); } ExReleaseFastMutex(&RmapListLock); RtlZeroMemory(&Resources, sizeof(Resources)); if ((((ULONG_PTR)Address) & 0xFFF) != 0) { KeBugCheck(MEMORY_MANAGEMENT);//.........这里部分代码省略.........
开发者ID:RPG-7,项目名称:reactos,代码行数:101,
注:本文中的ExAcquireFastMutex函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ExAcquireResourceExclusiveLite函数代码示例 C++ Event_init函数代码示例 |