亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sspnp.c

?? WINDDK開發代碼
?? C
?? 第 1 頁 / 共 5 頁
字號:

    //
    // need 2 decrements
    //

    SSDbgPrint(3, ("HandleRemoveDevice::"));
    requestCount = SSIoDecrement(deviceExtension);

    ASSERT(requestCount > 0);

    SSDbgPrint(3, ("HandleRemoveDevice::"));
    requestCount = SSIoDecrement(deviceExtension);

    KeWaitForSingleObject(&deviceExtension->RemoveEvent, 
                          Executive, 
                          KernelMode, 
                          FALSE, 
                          NULL);

    ReleaseMemory(DeviceObject);

    //
    // We need to send the remove down the stack before we detach,
    // but we don't need to wait for the completion of this operation
    // (and to register a completion routine).
    //

    Irp->IoStatus.Status = STATUS_SUCCESS;
    Irp->IoStatus.Information = 0;

    IoSkipCurrentIrpStackLocation(Irp);
    ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);
    
    //
    // Detach the FDO from the device stack
    //
    IoDetachDevice(deviceExtension->TopOfStackDeviceObject);
    IoDeleteDevice(DeviceObject);

    SSDbgPrint(3, ("HandleRemoveDevice - ends\n"));

    return ntStatus;
}

NTSTATUS
HandleQueryCapabilities(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++

Routine Description:

    This routine services Irp of minor type IRP_MN_QUERY_CAPABILITIES

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet sent by the pnp manager.

Return Value:

    NT status value  

--*/
{
    ULONG                i;
    KEVENT               event;
    NTSTATUS             ntStatus;
    PDEVICE_EXTENSION    deviceExtension;
    PDEVICE_CAPABILITIES pdc;
    PIO_STACK_LOCATION   irpStack;

    SSDbgPrint(3, ("HandleQueryCapabilities - begins\n"));

    //
    // initialize variables
    //

    irpStack = IoGetCurrentIrpStackLocation(Irp);
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    pdc = irpStack->Parameters.DeviceCapabilities.Capabilities;

    //
    // We will provide here an example of an IRP that is processed
    // both on its way down and on its way up: there might be no need for
    // a function driver process this Irp (the bus driver will do that).
    // The driver will wait for the lower drivers (the bus driver among 
    // them) to process this IRP, then it processes it again.
    //

    if(pdc->Version < 1 || pdc->Size < sizeof(DEVICE_CAPABILITIES)) {
        
        SSDbgPrint(1, ("HandleQueryCapabilities::request failed\n"));
        ntStatus = STATUS_UNSUCCESSFUL;
        return ntStatus;
    }

    //
    // Set some values in deviceCapabilities here...
    //
    //.............................................
    //
    //
    // Prepare to pass the IRP down
    //

    KeInitializeEvent(&event, NotificationEvent, FALSE);
        
    IoCopyCurrentIrpStackLocationToNext(Irp);
    IoSetCompletionRoutine(Irp, 
                           (PIO_COMPLETION_ROUTINE)IrpCompletionRoutine, 
                           (PVOID)&event, 
                           TRUE, 
                           TRUE, 
                           TRUE);
    ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

    if(ntStatus == STATUS_PENDING) {

        KeWaitForSingleObject(&event, 
                              Executive, 
                              KernelMode, 
                              FALSE, 
                              NULL);
        ntStatus = Irp->IoStatus.Status;
    }

    //
    // initialize PowerDownLevel to disabled
    //

    deviceExtension->PowerDownLevel = PowerDeviceUnspecified;

    //
    // Lower drivers have finished their operation, so now
    // we can finish ours. 
    //

    if(NT_SUCCESS(ntStatus)) {

        deviceExtension->DeviceCapabilities = *pdc;
       
        for(i = PowerSystemSleeping1; i <= PowerSystemSleeping3; i++) {

            if(deviceExtension->DeviceCapabilities.DeviceState[i] < 
                                                            PowerDeviceD3) {

                deviceExtension->PowerDownLevel = 
                    deviceExtension->DeviceCapabilities.DeviceState[i];
            }
        }

        //
        // since its safe to surprise-remove this device, we shall
        // set the SurpriseRemoveOK flag to supress any dialog to 
        // user.
        //

        pdc->SurpriseRemovalOK = 1;

    }

    if(deviceExtension->PowerDownLevel == PowerDeviceUnspecified ||
       deviceExtension->PowerDownLevel <= PowerDeviceD0) {
    
        deviceExtension->PowerDownLevel = PowerDeviceD2;
    }

    SSDbgPrint(3, ("HandleQueryCapabilities - ends\n"));

    return ntStatus;
}


VOID
DpcRoutine(
    IN PKDPC Dpc,
    IN PVOID DeferredContext,
    IN PVOID SystemArgument1,
    IN PVOID SystemArgument2
    )
/*++
 
Routine Description:

    DPC routine triggered by the timer to check the idle state
    of the device and submit an idle request for the device.

Arguments:

    DeferredContext - context for the dpc routine.
                      DeviceObject in our case.

Return Value:

    None

--*/
{
    NTSTATUS          ntStatus;
    PDEVICE_OBJECT    deviceObject;
    PDEVICE_EXTENSION deviceExtension;
    PIO_WORKITEM      item;

    deviceObject = (PDEVICE_OBJECT)DeferredContext;
    deviceExtension = (PDEVICE_EXTENSION)deviceObject->DeviceExtension;

    SSDbgPrint(3, ("DpcRoutine - begins\n"));

    //
    // Clear this event since a DPC has been fired!
    //
    KeClearEvent(&deviceExtension->NoDpcWorkItemPendingEvent);

    if(CanDeviceSuspend(deviceExtension)) {

        SSDbgPrint(3, ("Device is Idle\n"));

        item = IoAllocateWorkItem(deviceObject);

        if(item) {

            IoQueueWorkItem(item, 
                            IdleRequestWorkerRoutine,
                            DelayedWorkQueue, 
                            item);

            ntStatus = STATUS_PENDING;

        }
        else {
        
            SSDbgPrint(3, ("Cannot alloc memory for work item\n"));
            
            ntStatus = STATUS_INSUFFICIENT_RESOURCES;

            //
            // signal the NoDpcWorkItemPendingEvent.
            //
            KeSetEvent(&deviceExtension->NoDpcWorkItemPendingEvent,
                       IO_NO_INCREMENT,
                       FALSE);
        }
    }
    else {
        
        SSDbgPrint(3, ("Idle event not signaled\n"));

        //
        // signal the NoDpcWorkItemPendingEvent.
        //
        KeSetEvent(&deviceExtension->NoDpcWorkItemPendingEvent,
                   IO_NO_INCREMENT,
                   FALSE);
    }

    SSDbgPrint(3, ("DpcRoutine - ends\n"));
}    


VOID
IdleRequestWorkerRoutine(
    IN PDEVICE_OBJECT DeviceObject,
    IN PVOID          Context
    )
/*++
 
Routine Description:

    This is the work item fired from the DPC.
    This workitem checks the idle state of the device
    and submits an idle request.

Arguments:

    DeviceObject - pointer to device object
    Context - context for the work item.

Return Value:

    None

--*/
{
    PIRP                   irp;
    NTSTATUS               ntStatus;
    PDEVICE_EXTENSION      deviceExtension;
    PIO_WORKITEM           workItem;

    SSDbgPrint(3, ("IdleRequestWorkerRoutine - begins\n"));

    //
    // initialize variables
    //
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    workItem = (PIO_WORKITEM) Context;

    if(CanDeviceSuspend(deviceExtension)) {

        SSDbgPrint(3, ("Device is idle\n"));

        ntStatus = SubmitIdleRequestIrp(deviceExtension);

        if(!NT_SUCCESS(ntStatus)) {

            SSDbgPrint(1, ("SubmitIdleRequestIrp failed\n"));
        }
    }
    else {

        SSDbgPrint(3, ("Device is not idle\n"));
    }

    IoFreeWorkItem(workItem);

    //
    // signal the NoDpcWorkItemPendingEvent.
    //
    KeSetEvent(&deviceExtension->NoDpcWorkItemPendingEvent,
               IO_NO_INCREMENT,
               FALSE);

    SSDbgPrint(3, ("IdleRequestsWorkerRoutine - ends\n"));
}


VOID
ProcessQueuedRequests(
    IN OUT PDEVICE_EXTENSION DeviceExtension
    )
/*++
 
Routine Description:

    Remove and process the entries in the queue. If this routine is called
    when processing IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE
    or IRP_MN_START_DEVICE, the requests are passed to the next lower driver.
    If the routine is called when IRP_MN_REMOVE_DEVICE is received, the IRPs
    are complete with STATUS_DELETE_PENDING

Arguments:

    DeviceExtension - pointer to device extension

Return Value:

    None

--*/
{
    KIRQL       oldIrql;
    PIRP        nextIrp,
                cancelledIrp;
    PVOID       cancelRoutine;
    LIST_ENTRY  cancelledIrpList;
    PLIST_ENTRY listEntry;

    SSDbgPrint(3, ("ProcessQueuedRequests - begins\n"));

    //
    // initialize variables
    //

    cancelRoutine = NULL;
    InitializeListHead(&cancelledIrpList);

    //
    // 1.  dequeue the entries in the queue
    // 2.  reset the cancel routine
    // 3.  process them
    // 3a. if the device is active, send them down
    // 3b. else complete with STATUS_DELETE_PENDING
    //

    while(1) {

        KeAcquireSpinLock(&DeviceExtension->QueueLock, &oldIrql);

        if(IsListEmpty(&DeviceExtension->NewRequestsQueue)) {

            KeReleaseSpinLock(&DeviceExtension->QueueLock, oldIrql);
            break;
        }
    
        //
        // Remove a request from the queue
        //

        listEntry = RemoveHeadList(&DeviceExtension->NewRequestsQueue);
        nextIrp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry);

        //
        // set the cancel routine to NULL
        //

        cancelRoutine = IoSetCancelRoutine(nextIrp, NULL);

        //
        // check if its already cancelled
        //

        if(nextIrp->Cancel) {
            if(cancelRoutine) {

                //
                // the cancel routine for this IRP hasnt been called yet
                // so queue the IRP in the cancelledIrp list and complete
                // after releasing the lock
                //
                
                InsertTailList(&cancelledIrpList, listEntry);
            }
            else {

                //
                // the cancel routine has run
                // it must be waiting to hold the queue lock
                // so initialize the IRPs listEntry
                //

                InitializeListHead(listEntry);
            }

            KeReleaseSpinLock(&DeviceExtension->QueueLock, oldIrql);
        }
        else {

            KeReleaseSpinLock(&DeviceExtension->QueueLock, oldIrql);

            if(FailRequests == DeviceExtension->QueueState) {

                nextIrp->IoStatus.Information = 0;
                nextIrp->IoStatus.Status = STATUS_DELETE_PENDING;
                IoCompleteRequest(nextIrp, IO_NO_INCREMENT);
            }
            else {

                PIO_STACK_LOCATION irpStack;

                SSDbgPrint(3, ("ProcessQueuedRequests::"));
                SSIoIncrement(DeviceExtension);

                IoSkipCurrentIrpStackLocation(nextIrp);
                IoCallDriver(DeviceExtension->TopOfStackDeviceObject, nextIrp);
               
                SSDbgPrint(3, ("ProcessQueuedRequests::"));
                SSIoDecrement(DeviceExtension);
            }
        }
    } // while loop

    //
    // walk through the cancelledIrp list and cancel them
    //

    while(!IsListEmpty(&cancelledIrpList)) {

        PLIST_ENTRY listEntry = RemoveHeadList(&cancelledIrpList);
        
        cancelledIrp = CONTAINING_RECORD(listEntry, IRP, Tail.Overlay.ListEntry);

        cancelledIrp->IoStatus.Status = STATUS_CANCELLED;
        cancelledIrp->IoStatus.Information = 0;

        IoCompleteRequest(cancelledIrp, IO_NO_INCREMENT);
    }

    SSDbgPrint(3, ("ProcessQueuedRequests - ends\n"));

    return;
}


NTSTATUS
SS_DispatchClean(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++
 
Routine Description:

    Dispatch routine for IRP_MJ_CLEANUP

Arguments:

    DeviceObject - pointer to device object
    Irp - I/O request packet sent by the pnp manager

Return Value:

    NT status value

--*/
{
    PDEVICE_EXTENSION  deviceExtension;
    KIRQL              oldIrql;
    LIST_ENTRY         cleanupList;
    PLIST_ENTRY        thisEntry, 
                       nextEntry, 
                       listHead;
    PIRP               pendingIrp;
    PIO_STACK_LOCATION pendingIrpStack, 
                       irpStack;
    NTSTATUS           ntStatus;

    //
    // initialize variables
    //

    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    irpStack = IoGetCurrentIrpStackLocation(Irp);
    InitializeListHead(&cleanupList);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产黑色紧身裤美女| 欧美zozo另类异族| 久久精品999| 日韩伦理免费电影| 久久伊人蜜桃av一区二区| 99re亚洲国产精品| 黑人巨大精品欧美一区| 婷婷中文字幕综合| 亚洲欧美激情小说另类| 中日韩av电影| 久久一日本道色综合| 制服视频三区第一页精品| 91色乱码一区二区三区| 国产精一品亚洲二区在线视频| 亚洲尤物视频在线| 中文字幕一区二区三区视频| 国产日韩av一区| 欧美成人精精品一区二区频| 欧美午夜在线观看| 日本久久精品电影| caoporm超碰国产精品| 国产成人免费视频一区| 激情综合色综合久久| 免费人成精品欧美精品| 天堂va蜜桃一区二区三区漫画版| 亚洲九九爱视频| 成人免费在线观看入口| 中日韩免费视频中文字幕| 久久久精品tv| 国产亚洲欧美在线| 久久久久久久久久久久久夜| 日韩视频在线永久播放| 欧美日韩黄色一区二区| 在线观看亚洲成人| 欧洲一区在线电影| 欧美亚洲一区三区| 91久久精品网| 99精品国产热久久91蜜凸| 亚洲国产视频一区| 在线精品视频一区二区| 午夜精品爽啪视频| 亚洲午夜成aⅴ人片| 亚洲国产精品视频| 亚洲综合激情网| 亚洲va欧美va天堂v国产综合| 丝袜诱惑制服诱惑色一区在线观看| 亚洲国产成人tv| 天天av天天翘天天综合网| 日韩国产一区二| 毛片基地黄久久久久久天堂| 国产一区二区主播在线| 国产一区二区0| 成人免费毛片片v| 99精品久久免费看蜜臀剧情介绍| 99久久99久久综合| 欧美视频在线一区二区三区| 3751色影院一区二区三区| 久久综合久久综合久久| 中文在线一区二区| 亚洲第四色夜色| 九九在线精品视频| 不卡在线观看av| 欧美三级三级三级| 欧美v国产在线一区二区三区| 国产亚洲午夜高清国产拍精品 | 日韩精品一区二区在线观看| 久久综合视频网| 亚洲欧美激情插 | 国产欧美一区二区三区沐欲| 91黄色激情网站| 亚洲男帅同性gay1069| 男男gaygay亚洲| 国产精品一区在线观看乱码 | 99久久精品情趣| 成人午夜短视频| 国产很黄免费观看久久| 美日韩一区二区| 国产福利精品一区| 成人网男人的天堂| 欧美高清www午色夜在线视频| 精品国产一二三| 亚洲欧美日韩人成在线播放| 日韩福利视频导航| 成人久久久精品乱码一区二区三区| 欧洲精品视频在线观看| 精品剧情在线观看| 亚洲精品成人a在线观看| 开心九九激情九九欧美日韩精美视频电影| 国产剧情一区在线| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 精品美女在线观看| 樱桃视频在线观看一区| 国产综合一区二区| 欧美嫩在线观看| 国产精品女上位| 免费成人结看片| 色妞www精品视频| 国产亚洲1区2区3区| 日日骚欧美日韩| 99国产精品久| 精品国产免费人成电影在线观看四季 | 一区2区3区在线看| 国产91精品一区二区麻豆网站| 欧美区在线观看| 亚洲免费在线视频一区 二区| 国产在线精品一区二区不卡了| 欧美网站大全在线观看| 国产精品国产三级国产有无不卡| 麻豆成人免费电影| 欧美精品xxxxbbbb| 夜夜嗨av一区二区三区| eeuss鲁片一区二区三区在线观看| 日韩女优av电影| 日本一不卡视频| 欧美体内she精高潮| 亚洲人精品一区| 成人激情免费视频| 久久午夜色播影院免费高清| 蜜桃一区二区三区四区| 欧美日韩一区二区三区不卡| 亚洲老司机在线| 99re亚洲国产精品| 成人欧美一区二区三区小说 | 久久99精品久久久久久| 5858s免费视频成人| 亚洲国产精品精华液网站| 欧洲精品一区二区三区在线观看| 亚洲美女视频在线观看| av激情成人网| 中文字幕中文乱码欧美一区二区| 国产一区二区不卡在线 | 欧美成人video| 久久99蜜桃精品| 精品日韩在线一区| 久久精品国内一区二区三区| 日韩欧美你懂的| 欧美bbbbb| 精品少妇一区二区三区| 精品一区二区三区在线观看国产| 日韩欧美一区二区三区在线| 日韩国产欧美在线播放| 日韩精品一区二区三区视频在线观看| 日韩成人一级大片| 精品入口麻豆88视频| 国产一区二区在线视频| 国产欧美日韩另类视频免费观看| 成人av免费观看| 亚洲日本va午夜在线影院| 日本韩国欧美一区二区三区| 亚洲图片有声小说| 337p亚洲精品色噜噜狠狠| 蜜臀精品一区二区三区在线观看| 精品三级在线观看| 成人免费av资源| 亚洲午夜激情网页| 3751色影院一区二区三区| 国精产品一区一区三区mba视频 | 欧美成人video| 国产91露脸合集magnet| 亚洲乱码国产乱码精品精小说 | 精品对白一区国产伦| 国产酒店精品激情| 亚洲欧美二区三区| 91精品国产aⅴ一区二区| 国内精品嫩模私拍在线| 国产精品久久久久婷婷| 欧美午夜片在线看| 久久av资源网| 国产精品久久久久久久久免费桃花| 日本道在线观看一区二区| 奇米精品一区二区三区在线观看一| 久久你懂得1024| 欧美自拍偷拍午夜视频| 久久99精品久久只有精品| 国产精品电影院| 91精品国产欧美一区二区18| 国产成人欧美日韩在线电影| 亚洲午夜久久久久| 久久久国产综合精品女国产盗摄| 日本韩国欧美一区| 国产在线观看免费一区| 亚洲一区二区三区四区五区中文 | 国产成人啪免费观看软件| 一区二区三区四区蜜桃| 亚洲精品在线网站| 91久久久免费一区二区| 国产综合色产在线精品| 亚洲精品乱码久久久久| 欧美tickling网站挠脚心| 91蜜桃在线免费视频| 免费三级欧美电影| 亚洲精品免费播放| 久久品道一品道久久精品| 欧美日韩一区二区在线视频| av一区二区三区四区| 久久99精品久久久久婷婷| 亚洲成人你懂的| 亚洲男人的天堂网| 久久久久久久久久久久久久久99 | 精品国产麻豆免费人成网站|