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

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

?? packet.c

?? <Visual C++ 網絡程序設計實例詳解>配套源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 1990-2000  Microsoft Corporation

Module Name:

    packet.c

Abstract:


Author:


Environment:

    Kernel mode only.

Notes:


Future:



Revision History:

  Fixed bugs and converted to NDIS 5.0. This driver handles 
  dynamic binding and unbinding to underlying NICs, receives
  pnp and power management callbacks, and implements 
  ReceivePacketHandler. 
                            - Eliyas Yakub June, 1999
  
--*/

#include "ntddk.h"
#include "ndis.h"
#include "ntddpack.h"
#include "packet.h"
#include "stdio.h"


NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT DriverObject,
    IN PUNICODE_STRING RegistryPath
    )

/*++

Routine Description:

    This routine initializes the Packet driver.

Arguments:

    DriverObject - Pointer to driver object created by system.

    RegistryPath - Pointer to the Unicode name of the registry path
        for this driver.

Return Value:

    NT Status code
    
--*/

{

    NDIS_PROTOCOL_CHARACTERISTICS   protocolChar;
    NTSTATUS                        status = STATUS_SUCCESS;
    NDIS_STRING                     protoName = NDIS_STRING_CONST("Packet");     
    UNICODE_STRING                  ntDeviceName;
    UNICODE_STRING                  win32DeviceName;
    BOOLEAN                         fSymbolicLink = FALSE;
    PDEVICE_OBJECT                  deviceObject;

    DebugPrint(("\n\nDriverEntry\n"));
    
    Globals.DriverObject = DriverObject;

    //
    // Save the RegistryPath.
    //

    Globals.RegistryPath.MaximumLength = RegistryPath->Length +
                                          sizeof(UNICODE_NULL);
    Globals.RegistryPath.Length = RegistryPath->Length;
    Globals.RegistryPath.Buffer = ExAllocatePool(
                                       PagedPool,
                                       Globals.RegistryPath.MaximumLength
                                       );    

    if (!Globals.RegistryPath.Buffer) {

        DebugPrint (("Couldn't allocate pool for registry path."));

        return STATUS_INSUFFICIENT_RESOURCES;
    }
    
    RtlCopyUnicodeString(&Globals.RegistryPath, RegistryPath);

    RtlInitUnicodeString(&ntDeviceName, NT_DEVICE_NAME);

    //
    // Create a control device object for this driver.
    // Application can send an IOCTL to this device to get 
    // bound adapter information.
    //

    status = IoCreateDevice (DriverObject,
                             0,
                             &ntDeviceName,
                             FILE_DEVICE_UNKNOWN,
                             0,
                             FALSE,
                             &deviceObject);

    
    if (!NT_SUCCESS (status)) {
        //
        // Either not enough memory to create a deviceobject or another
        // deviceobject with the same name exits. This could happen
        // if you install another instance of this device.
        //
        goto ERROR;
    }

    RtlInitUnicodeString(&win32DeviceName, DOS_DEVICE_NAME);

    status = IoCreateSymbolicLink( &win32DeviceName, &ntDeviceName );

    if (!NT_SUCCESS(status))    // If we couldn't create the link then
    {                           //  abort installation.
        goto ERROR;
    }

    fSymbolicLink = TRUE; // symboliclink is created
    
    deviceObject->Flags |= DO_BUFFERED_IO;
    Globals.ControlDeviceObject = deviceObject;

    InitializeListHead(&Globals.AdapterList);
    KeInitializeSpinLock(&Globals.GlobalLock);

    //
    // Initialize the protocol characterstic structure
    //
    
    NdisZeroMemory(&protocolChar,sizeof(NDIS_PROTOCOL_CHARACTERISTICS));

    protocolChar.MajorNdisVersion            = 5;
    protocolChar.MinorNdisVersion            = 0;
    protocolChar.Name                        = protoName;
    protocolChar.OpenAdapterCompleteHandler  = PacketOpenAdapterComplete;
    protocolChar.CloseAdapterCompleteHandler = PacketCloseAdapterComplete;
    protocolChar.SendCompleteHandler         = PacketSendComplete;
    protocolChar.TransferDataCompleteHandler = PacketTransferDataComplete;
    protocolChar.ResetCompleteHandler        = PacketResetComplete;
    protocolChar.RequestCompleteHandler      = PacketRequestComplete;
    protocolChar.ReceiveHandler              = PacketReceiveIndicate;
    protocolChar.ReceiveCompleteHandler      = PacketReceiveComplete;
    protocolChar.StatusHandler               = PacketStatus;
    protocolChar.StatusCompleteHandler       = PacketStatusComplete;
    protocolChar.BindAdapterHandler          = PacketBindAdapter;
    protocolChar.UnbindAdapterHandler        = PacketUnbindAdapter;
    protocolChar.UnloadHandler               = NULL;
    protocolChar.ReceivePacketHandler        = PacketReceivePacket;
    protocolChar.PnPEventHandler             = PacketPNPHandler;

    //
    // Register as a protocol driver
    //
    
    NdisRegisterProtocol(
        &status,
        &Globals.NdisProtocolHandle,
        &protocolChar,
        sizeof(NDIS_PROTOCOL_CHARACTERISTICS));

    if (status != NDIS_STATUS_SUCCESS) {
        DebugPrint(("Failed to register protocol with NDIS\n"));
        status = STATUS_UNSUCCESSFUL;
        goto ERROR;        
    }
    
    //
    // Now set only the dispatch points we would like to handle.
    //

    DriverObject->MajorFunction[IRP_MJ_CREATE] = PacketOpen;
    DriverObject->MajorFunction[IRP_MJ_CLOSE]  = PacketClose;
    DriverObject->MajorFunction[IRP_MJ_READ]   = PacketRead;
    DriverObject->MajorFunction[IRP_MJ_WRITE]  = PacketWrite;
    DriverObject->MajorFunction[IRP_MJ_CLEANUP]  = PacketCleanup;
    DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]  = PacketIoControl;
    DriverObject->DriverUnload = PacketUnload;
       
    return(STATUS_SUCCESS);

ERROR:
    if(deviceObject)
        IoDeleteDevice(deviceObject);
    if(fSymbolicLink)
        IoDeleteSymbolicLink(&win32DeviceName);
    if(Globals.RegistryPath.Buffer)        
        ExFreePool(Globals.RegistryPath.Buffer);

    return status;


}


VOID
PacketUnload(
    IN PDRIVER_OBJECT DriverObject
    )
/*++

Routine Description:

    Free all the allocated resources, etc.

Arguments:

    DriverObject - pointer to a driver object.

Return Value:

    VOID.

--*/
{

    NDIS_STATUS        status;
    UNICODE_STRING     win32DeviceName;

    DebugPrint(("Unload Enter\n"));

    //
    // First delete the Control deviceobject and the corresponding
    // symbolicLink
    //

    RtlInitUnicodeString(&win32DeviceName, DOS_DEVICE_NAME);
    IoDeleteSymbolicLink(&win32DeviceName);           
    if(Globals.ControlDeviceObject)
        IoDeleteDevice(Globals.ControlDeviceObject);
    //
    // Unbind from all the adapters. The system removes the driver code 
    // pages from the memory as soon as the unload returns. So you 
    // must wait for all the CloseAdapterCompleteHandler to finish 
    // before returning from the unload routine. You don't any callbacks
    // to trigger after the driver is unloaded.
    // 
    
    while(DriverObject->DeviceObject)
    {
        PacketUnbindAdapter(&status,
                    DriverObject->DeviceObject->DeviceExtension,
                    NULL);
    }

    if(Globals.RegistryPath.Buffer)
        ExFreePool(Globals.RegistryPath.Buffer);

    DebugPrint(("Deregister\n"));

    NdisDeregisterProtocol(
        &status,
        Globals.NdisProtocolHandle
        );
    DebugPrint(("Unload Exit\n"));

}




NTSTATUS
PacketIoControl(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP Irp
    )

/*++

Routine Description:

    This is the dispatch routine for Filter OID and Reset requests.

Arguments:

    DeviceObject - Pointer to the device object.

    Irp - Pointer to the request packet.

Return Value:

    Status is returned.

--*/

{

    POPEN_INSTANCE      open;
    PIO_STACK_LOCATION  irpSp;
    PINTERNAL_REQUEST   pRequest;
    ULONG               functionCode;
    NDIS_STATUS         status;
    ULONG               dataLength =0;

    DebugPrint(("IoControl\n"));
    
    irpSp = IoGetCurrentIrpStackLocation(Irp);

    functionCode=irpSp->Parameters.DeviceIoControl.IoControlCode;

    //
    // Check whether this request is to get bound adapter list.
    //
    if (functionCode == IOCTL_ENUM_ADAPTERS) {
        //
        // If the request is not made to the controlobject, fail
        // the request.
        //
        if(DeviceObject != Globals.ControlDeviceObject) {
            status = STATUS_INVALID_DEVICE_REQUEST;
        } else {
            status = PacketGetAdapterList(
                            Irp->AssociatedIrp.SystemBuffer, 
                            irpSp->Parameters.DeviceIoControl.OutputBufferLength,
                            &dataLength
                            );        
        }
        Irp->IoStatus.Status = status;
        Irp->IoStatus.Information = dataLength;
        IoCompleteRequest(Irp, IO_NO_INCREMENT);
        return status;
    }

    //
    // Increment the outstanding IRP count.
    //
    open =  DeviceObject->DeviceExtension;
    IoIncrement(open);

    //
    // Check to see whether you are still bound to the adapter
    //

    if(!open->Bound)
    {
        Irp->IoStatus.Status = status = STATUS_UNSUCCESSFUL;
        IoCompleteRequest(Irp, IO_NO_INCREMENT);
        IoDecrement(open);
        return status;
    }


    DebugPrint(("Function code is %08lx  buff size=%08lx  %08lx\n",
            functionCode,irpSp->Parameters.DeviceIoControl.InputBufferLength,
            irpSp->Parameters.DeviceIoControl.OutputBufferLength));

    //
    // Important: Since we have marked the IRP pending, we must return 
    // STATUS_PENDING even we happen to complete the IRP synchronously.
    // 
    
    IoMarkIrpPending(Irp);

    if (functionCode == IOCTL_PROTOCOL_RESET) {


        DebugPrint(("IoControl - Reset request\n"));

        //
        // Since NDIS doesn't have an interface to cancel a request
        // pending at miniport, we cannot set a cancel routine.
        // As a result if the application that made the request
        // terminates, we wait in the Cleanup routine for all pending
        // NDIS requests to complete.
        //
        
        ExInterlockedInsertTailList(
                &open->ResetIrpList,
                &Irp->Tail.Overlay.ListEntry,
                &open->ResetQueueLock);


        NdisReset(
            &status,
            open->AdapterHandle
            );


        if (status != NDIS_STATUS_PENDING) {

            DebugPrint(("IoControl - ResetComplete being called\n"));

            PacketResetComplete(
                open,
                status
                );

        }

    } else {
        //
        //  See if it is an Ndis request
        //
        PPACKET_OID_DATA    OidData=Irp->AssociatedIrp.SystemBuffer;

        pRequest = ExAllocatePool(NonPagedPool, sizeof(INTERNAL_REQUEST));

        if(NULL == pRequest)
        {
            Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
            IoCompleteRequest (Irp, IO_NO_INCREMENT);
            IoDecrement(open);
            return STATUS_PENDING;
        }         
        pRequest->Irp=Irp;

        if (((functionCode == IOCTL_PROTOCOL_SET_OID) 
                        || (functionCode == IOCTL_PROTOCOL_QUERY_OID))
            &&
            (irpSp->Parameters.DeviceIoControl.InputBufferLength 
                        == irpSp->Parameters.DeviceIoControl.OutputBufferLength)
            &&
            (irpSp->Parameters.DeviceIoControl.InputBufferLength 
                        >= sizeof(PACKET_OID_DATA))
            &&
            (irpSp->Parameters.DeviceIoControl.InputBufferLength 
                        >= sizeof(PACKET_OID_DATA)-1+OidData->Length)) {

            DebugPrint(("IoControl: Request: Oid=%08lx, Length=%08lx\n",
                            OidData->Oid,OidData->Length));

            //
            //  The buffer is valid
            //
            if (functionCode == IOCTL_PROTOCOL_SET_OID) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国欧美一区二区| 成人免费在线播放视频| 欧美一级专区免费大片| 久久久精品欧美丰满| 亚洲一区电影777| 在线观看网站黄不卡| 五月天一区二区三区| 懂色av一区二区三区免费观看| 国产精品久久久久久一区二区三区 | 国产美女一区二区三区| 亚洲精品国产一区二区三区四区在线| 制服丝袜亚洲播放| 99在线精品观看| 国精产品一区一区三区mba桃花| 一区二区三区中文字幕在线观看| 欧美成人a在线| 色婷婷精品久久二区二区蜜臂av| 国产成人在线视频免费播放| 欧美欧美午夜aⅴ在线观看| 国产69精品久久久久777| 日韩电影一二三区| 亚洲欧洲精品一区二区精品久久久| 日韩精品专区在线影院观看| 在线一区二区三区四区五区| 国产91精品一区二区麻豆网站| 日韩av电影天堂| 亚洲一二三四在线观看| 国产精品理伦片| 国产色爱av资源综合区| 日韩女同互慰一区二区| 亚洲欧洲日产国产综合网| 91麻豆.com| 欧美成人激情免费网| 在线播放日韩导航| 精品写真视频在线观看| 久久中文字幕电影| 国产一区二区三区免费播放| 国产精品国产三级国产三级人妇 | 在线观看亚洲精品视频| 国产一区二区福利| 欧美a一区二区| 日韩国产在线观看| 五月婷婷综合在线| 亚洲aaa精品| 亚洲国产你懂的| 亚洲精品视频免费看| 中文字幕一区二区在线观看| 国产精品免费aⅴ片在线观看| 国产午夜三级一区二区三| 久久在线免费观看| 久久久精品国产99久久精品芒果| 精品国产一区二区三区四区四| 日韩三级电影网址| 精品国产百合女同互慰| 久久久久久亚洲综合影院红桃| 2021国产精品久久精品| 国产亚洲综合av| 国产欧美日韩视频在线观看| 久久久久国产精品人| 日韩精品影音先锋| 中文字幕不卡的av| 欧美日韩精品一区二区三区四区 | 免费久久99精品国产| 欧美在线制服丝袜| 不卡的电影网站| 日韩成人一级片| 欧美成人福利视频| 色香蕉久久蜜桃| 国产精品99久久久久久有的能看| 亚洲一区二区精品视频| 国产精品久久久久aaaa| 5566中文字幕一区二区电影| 成人高清视频在线观看| 国产中文字幕精品| 亚洲成av人片一区二区三区| 中文字幕欧美三区| 日韩午夜电影在线观看| 色网站国产精品| 国产成人精品亚洲777人妖| 日韩电影在线观看电影| 日本色综合中文字幕| 精品久久国产97色综合| 在线播放日韩导航| 欧美日韩高清一区二区| 中文字幕日韩一区二区| 自拍偷拍亚洲综合| 亚洲天堂免费在线观看视频| 精品播放一区二区| 久久免费国产精品| 国产欧美一区二区三区在线老狼| 成人久久18免费网站麻豆 | 亚洲视频一二三| 亚洲欧美日韩小说| 国产在线视视频有精品| 夫妻av一区二区| 一本色道久久综合狠狠躁的推荐| 高清在线观看日韩| 日韩无一区二区| 色久优优欧美色久优优| 色又黄又爽网站www久久| 欧美日韩一区二区三区高清| 91精品国产欧美一区二区成人| 99re这里只有精品6| 制服丝袜亚洲网站| 国产精品欧美久久久久无广告 | 在线不卡欧美精品一区二区三区| 欧美一区二区久久久| 国产视频视频一区| 亚洲成人激情av| 成人性生交大片免费| 欧美在线一二三| 中文在线一区二区| 亚洲成人av一区二区三区| 国产乱妇无码大片在线观看| 欧洲日韩一区二区三区| 日韩欧美激情在线| 国产精品毛片大码女人| 免费欧美日韩国产三级电影| 日韩电影免费一区| 在线精品视频免费播放| 中文字幕的久久| 国产一区不卡视频| 精品久久人人做人人爱| 一区二区三区在线视频观看| 不卡欧美aaaaa| 国产精品久久久久毛片软件| 九九九精品视频| 久久久综合视频| 欧洲另类一二三四区| 一区二区三区四区高清精品免费观看| 亚洲风情在线资源站| 久久久久久久久久久99999| 在线观看国产精品网站| 麻豆精品一区二区av白丝在线| 中文字幕av资源一区| 日韩欧美一级片| 91精品婷婷国产综合久久| 欧美大片国产精品| 国产精品综合在线视频| 国产精品五月天| 一本到不卡免费一区二区| 亚洲欧美激情视频在线观看一区二区三区 | 2023国产精品| 成人性视频免费网站| 亚洲电影在线免费观看| 国产精品大尺度| 国产欧美日韩在线视频| 国产成人一区二区精品非洲| 性久久久久久久久久久久| 中文成人综合网| 97se亚洲国产综合在线| 99久久婷婷国产综合精品| 国产在线播放一区三区四| 美腿丝袜亚洲三区| 亚洲成人av在线电影| 国产三级欧美三级日产三级99| 欧美日韩在线播放三区| 色综合一区二区三区| 色婷婷精品大视频在线蜜桃视频| 亚洲午夜精品在线| 午夜久久久久久久久| 奇米色一区二区三区四区| 麻豆成人免费电影| 久久不见久久见免费视频1| 精品亚洲成a人在线观看| 美女一区二区在线观看| 久久蜜桃av一区精品变态类天堂 | 久久综合精品国产一区二区三区| 亚洲自拍偷拍欧美| 中文字幕 久热精品 视频在线| 国产精品 日产精品 欧美精品| 日韩专区在线视频| 一区在线观看免费| 国产午夜精品一区二区| 日韩欧美国产三级| 欧美一三区三区四区免费在线看| 日韩免费视频一区二区| 精品99999| 精品捆绑美女sm三区| 国产一区二区三区在线观看精品| 爽爽淫人综合网网站| 亚洲成人一二三| 蜜臀精品一区二区三区在线观看 | 国产欧美精品一区二区色综合朱莉 | a在线欧美一区| 99国内精品久久| 欧美性猛交xxxx乱大交退制版 | 久久精品99久久久| 国产精选一区二区三区| 亚洲一区二区三区自拍| 亚洲chinese男男1069| 日韩精品免费视频人成| 一区二区三区中文在线| 亚洲国产日韩在线一区模特 | 成人性色生活片| 日韩欧美成人一区二区| 亚洲精品国久久99热| 91丝袜美腿高跟国产极品老师 | 欧美成人一区二区三区| 日韩中文字幕1|