亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日韩区在线观看| 亚洲女厕所小便bbb| 国产精品国产三级国产a| 亚洲一区二区成人在线观看| 韩国精品在线观看| 一本久久综合亚洲鲁鲁五月天| 69成人精品免费视频| 中文字幕av一区二区三区高 | 久久婷婷久久一区二区三区| 亚洲三级久久久| 国产麻豆精品theporn| 8x8x8国产精品| 一区二区三区久久| 不卡的av网站| 欧美精品一区二区久久婷婷| 亚洲综合色噜噜狠狠| bt欧美亚洲午夜电影天堂| 日韩午夜中文字幕| 天天射综合影视| 色综合一区二区三区| 中文字幕一区二区不卡| 国产美女一区二区三区| 日韩欧美国产午夜精品| 日本亚洲电影天堂| 欧美精品久久99| 一二三区精品福利视频| a亚洲天堂av| 亚洲欧美日韩国产成人精品影院| 国产iv一区二区三区| 国产日产欧美精品一区二区三区| 久久电影网站中文字幕| 欧美成人猛片aaaaaaa| 丝袜诱惑亚洲看片| 欧美一区二区三区四区久久| 亚洲国产视频直播| 欧美日韩二区三区| 日韩精品成人一区二区三区 | 欧美mv和日韩mv的网站| 日韩av在线免费观看不卡| 欧美嫩在线观看| 日韩1区2区3区| 欧美一卡在线观看| 韩国v欧美v日本v亚洲v| 久久久精品综合| 成人综合婷婷国产精品久久蜜臀 | 日韩亚洲欧美高清| 久久成人18免费观看| 久久精品无码一区二区三区| 国产精品99久久久久久久女警 | 国产精品一区二区不卡| 国产亚洲女人久久久久毛片| 成人h精品动漫一区二区三区| 亚洲区小说区图片区qvod| 欧美日韩在线观看一区二区| 丝瓜av网站精品一区二区| 欧美一级一级性生活免费录像| 国内精品国产成人国产三级粉色 | 99久久伊人网影院| 国产精品国产a| 欧美日韩一区不卡| 狠狠色综合日日| 亚洲色图欧洲色图| 欧美二区乱c少妇| 国产一区二区伦理片| 亚洲视频你懂的| 欧美另类z0zxhd电影| 国产精选一区二区三区| 成人欧美一区二区三区1314| 7799精品视频| 成人av资源在线| 日日摸夜夜添夜夜添亚洲女人| 国产女人水真多18毛片18精品视频| 99国产精品久久| 男女性色大片免费观看一区二区 | 欧美一级夜夜爽| av成人免费在线观看| 亚洲超丰满肉感bbw| 久久久国产精华| 欧美精品久久久久久久多人混战| 国产盗摄女厕一区二区三区| 一区二区三区欧美视频| 久久精品视频一区二区三区| 欧美在线视频全部完| 国产精品自在欧美一区| 亚洲小少妇裸体bbw| 久久蜜桃香蕉精品一区二区三区| 欧美日韩一区精品| 99久久精品99国产精品 | 日韩欧美专区在线| 91香蕉视频黄| 国产精品69久久久久水密桃| 亚洲成av人片在线观看| 1024成人网| 久久久久久久免费视频了| 欧美性大战久久久久久久蜜臀 | 久久99久久99精品免视看婷婷| 亚洲欧洲日产国产综合网| 26uuu欧美日本| 欧美一区二区不卡视频| 欧美日韩在线三区| 色婷婷狠狠综合| 成人午夜电影网站| 国产麻豆精品95视频| 精品在线观看视频| 日本免费新一区视频| 亚洲国产精品一区二区久久| 亚洲精品国产第一综合99久久 | 色综合天天做天天爱| 国产精品一区专区| 国产一区二区三区久久久| 久久精品999| 麻豆成人av在线| 麻豆91免费观看| 美腿丝袜亚洲综合| 裸体健美xxxx欧美裸体表演| 日本欧美一区二区三区| 日本91福利区| 美女在线观看视频一区二区| 日本人妖一区二区| 日本不卡视频一二三区| 老色鬼精品视频在线观看播放| 琪琪一区二区三区| 免费不卡在线视频| 久久99这里只有精品| 精品无人码麻豆乱码1区2区 | 欧洲av一区二区嗯嗯嗯啊| 99r精品视频| 色老头久久综合| 欧美日韩亚洲国产综合| 欧美一级一区二区| 欧美成人国产一区二区| 久久久无码精品亚洲日韩按摩| 亚洲国产激情av| 最新高清无码专区| 午夜欧美电影在线观看| 精品在线一区二区三区| 国产精品亚洲综合一区在线观看| 大桥未久av一区二区三区中文| 91欧美一区二区| 欧美精品在线观看播放| 精品国产精品网麻豆系列| 欧美极品美女视频| 亚洲电影视频在线| 精品在线播放免费| 色美美综合视频| 日韩欧美专区在线| 中文字幕一区二区三区视频| 亚洲综合在线免费观看| 日本aⅴ精品一区二区三区| 国产成人精品影院| 欧洲另类一二三四区| 久久一区二区三区四区| 一区二区视频免费在线观看| 日av在线不卡| 99re免费视频精品全部| 日韩欧美亚洲一区二区| 亚洲精选视频在线| 男男视频亚洲欧美| 99re亚洲国产精品| 精品欧美黑人一区二区三区| 国产精品电影一区二区三区| 日韩va欧美va亚洲va久久| 成人av免费观看| 欧美一区二区视频在线观看2020 | 国产 欧美在线| 欧美伦理视频网站| 中文字幕一区二区三区视频| 日本中文字幕一区二区视频 | 老司机午夜精品99久久| 99久久国产综合精品麻豆| 日韩女优制服丝袜电影| 亚洲精品视频免费看| 国产精品一卡二卡| 欧美久久婷婷综合色| 亚洲欧美日韩人成在线播放| 经典一区二区三区| 欧美日韩精品一二三区| 国产精品丝袜一区| 裸体健美xxxx欧美裸体表演| 欧美日韩三级在线| 中文字幕视频一区| 国产91在线观看丝袜| 欧美精品一二三区| 亚洲欧美国产77777| 成人精品小蝌蚪| 久久久亚洲国产美女国产盗摄 | 高清日韩电视剧大全免费| 在线综合视频播放| 国产精品美女久久久久高潮| 激情欧美日韩一区二区| 91.成人天堂一区| 日韩极品在线观看| 欧美三级电影网| 亚洲电影中文字幕在线观看| 91浏览器打开| 亚洲特黄一级片| 色综合婷婷久久| 亚洲美女免费视频| 在线精品视频免费观看| 亚洲一区二区影院|