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

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

?? functions.c

?? This the second tutorial of the Writing Device Drivers series. There seems to be a lot of interest i
?? C
?? 第 1 頁 / 共 3 頁
字號:
/**********************************************************************
 * 
 *  Toby Opferman
 *
 *  Driver Example
 *
 *  This example is for educational purposes only.  I license this source
 *  out for use in learning how to write a device driver.
 *
 *     Driver Functionality
 **********************************************************************/

#define _X86_ 

#include <wdm.h>
#include "example.h"
#include <public.h>


/**********************************************************************
 * Internal Functions
 **********************************************************************/
BOOLEAN Example_IsStringTerminated(PCHAR pString, UINT uiLength, UINT *pdwStringLength);
NTSTATUS Example_HandleSampleIoctl_DirectInIo(PIRP Irp, PIO_STACK_LOCATION pIoStackIrp, UINT *pdwDataWritten);
NTSTATUS Example_HandleSampleIoctl_DirectOutIo(PIRP Irp, PIO_STACK_LOCATION pIoStackIrp, UINT *pdwDataWritten);
NTSTATUS Example_HandleSampleIoctl_BufferedIo(PIRP Irp, PIO_STACK_LOCATION pIoStackIrp, UINT *pdwDataWritten);
NTSTATUS Example_HandleSampleIoctl_NeitherIo(PIRP Irp, PIO_STACK_LOCATION pIoStackIrp, UINT *pdwDataWritten);

#pragma alloc_text(PAGE, Example_Create) 
#pragma alloc_text(PAGE, Example_Close) 
#pragma alloc_text(PAGE, Example_IoControl) 
#pragma alloc_text(PAGE, Example_ReadDirectIO)
#pragma alloc_text(PAGE, Example_ReadBufferedIO)
#pragma alloc_text(PAGE, Example_ReadNeither)
#pragma alloc_text(PAGE, Example_WriteDirectIO)
#pragma alloc_text(PAGE, Example_WriteBufferedIO)
#pragma alloc_text(PAGE, Example_WriteNeither)
#pragma alloc_text(PAGE, Example_UnSupportedFunction)
#pragma alloc_text(PAGE, Example_IsStringTerminated)
#pragma alloc_text(PAGE, Example_HandleSampleIoctl_DirectInIo)
#pragma alloc_text(PAGE, Example_HandleSampleIoctl_DirectOutIo)
#pragma alloc_text(PAGE, Example_HandleSampleIoctl_NeitherIo)
#pragma alloc_text(PAGE, Example_HandleSampleIoctl_DirectInIo)




/**********************************************************************
 * 
 *  Example_Create
 *
 *    This is called when an instance of this driver is created (CreateFile)
 *
 **********************************************************************/
NTSTATUS Example_Create(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
    NTSTATUS NtStatus = STATUS_SUCCESS;
    DbgPrint("Example_Create Called \r\n");

    return NtStatus;
}

/**********************************************************************
 * 
 *  Example_Close
 *
 *    This is called when an instance of this driver is closed (CloseHandle)
 *
 **********************************************************************/
NTSTATUS Example_Close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
    NTSTATUS NtStatus = STATUS_SUCCESS;
    DbgPrint("Example_Close Called \r\n");

    return NtStatus;
}



/**********************************************************************
 * 
 *  Example_IoControl
 *
 *    This is called when an IOCTL is issued on the device handle (DeviceIoControl)
 *
 **********************************************************************/
NTSTATUS Example_IoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
    NTSTATUS NtStatus = STATUS_NOT_SUPPORTED;
    PIO_STACK_LOCATION pIoStackIrp = NULL;
    UINT dwDataWritten = 0;

    DbgPrint("Example_IoControl Called \r\n");
    
    /*
     * Each time the IRP is passed down the driver stack a new stack location is added
     * specifying certain parameters for the IRP to the driver.
     */
    pIoStackIrp = IoGetCurrentIrpStackLocation(Irp);    

    if(pIoStackIrp) /* Should Never Be NULL! */
    {
        switch(pIoStackIrp->Parameters.DeviceIoControl.IoControlCode)
        {
            case IOCTL_EXAMPLE_SAMPLE_DIRECT_IN_IO:
                 NtStatus = Example_HandleSampleIoctl_DirectInIo(Irp, pIoStackIrp, &dwDataWritten);
                 break;

            case IOCTL_EXAMPLE_SAMPLE_DIRECT_OUT_IO:
                 NtStatus = Example_HandleSampleIoctl_DirectOutIo(Irp, pIoStackIrp, &dwDataWritten);
                 break;

            case IOCTL_EXAMPLE_SAMPLE_BUFFERED_IO:
                 NtStatus = Example_HandleSampleIoctl_BufferedIo(Irp, pIoStackIrp, &dwDataWritten);
                 break;

            case IOCTL_EXAMPLE_SAMPLE_NEITHER_IO:
                 NtStatus = Example_HandleSampleIoctl_NeitherIo(Irp, pIoStackIrp, &dwDataWritten);
                 break;
        }
    }

    /*
     * This does not always need to be completed in this manner.  The I/O Manager is friendly
     * and in the simple case (as this driver is implemented) the IRP will be completed
     * by IoCompleteRequest() and the Status will be set to the return value.
     *
     * What will not be set however is the "Information" field, it cannot be set to how many bytes
     * were read or written obviously because the I/O Manager does not know, only your device
     * driver does.
     *
     * There are cases where you will need to complete the IRP and set the status however
     * our simple driver does not require that.
     *
     * In the Write operation the "bytes written" is really only used as an informant to
     * the application.  The Read operation is a bit different.  For example, some types of buffering
     * it may not matter if you set the number of bytes read.  For example "Neither" you write
     * directly into the user mode buffer so the user mode gets the data even if you don't
     * tell it the amount.  However if you remember how buffered I/O works?  It makes a copy
     * in memory.  If the I/O manager doesn't know the size then it can't copy it back to the
     * user mode buffer.
     *  
     *
     * IO_NO_INCREMENT - What is this?  If an IRP request is taking a long time you may want to help
     * the scheduler to re-schedule the thread as soon as possible.  For example perhaps it issued
     * a network request and went to sleep.  Then on another thread the network request completes
     * You may want to use one of the pre-defined constants or your own to increment the priority of
     * that thread to be rescheduled being since it hasn't been scheduled in a while.
     *
     */

    Irp->IoStatus.Status = NtStatus;
    Irp->IoStatus.Information = dwDataWritten;

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    return NtStatus;

}






/**********************************************************************
 * 
 *  Example_WriteDirectIO
 *
 *    This is called when a write is issued on the device handle (WriteFile/WriteFileEx)
 *
 *    This version uses Direct I/O
 *
 **********************************************************************/
NTSTATUS Example_WriteDirectIO(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
    NTSTATUS NtStatus = STATUS_UNSUCCESSFUL;
    PIO_STACK_LOCATION pIoStackIrp = NULL;
    UINT dwDataWritten = 0;
    PCHAR pWriteDataBuffer;

    DbgPrint("Example_WriteDirectIO Called \r\n");
    
    /*
     * Each time the IRP is passed down the driver stack a new stack location is added
     * specifying certain parameters for the IRP to the driver.
     */
    pIoStackIrp = IoGetCurrentIrpStackLocation(Irp);
    
    if(pIoStackIrp && Irp->MdlAddress)
    {
        pWriteDataBuffer = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
    
        if(pWriteDataBuffer)
        {                             
            /*
             * We need to verify that the string is NULL terminated. Bad things can happen
             * if we access memory not valid while in the Kernel.
             */
           if(Example_IsStringTerminated(pWriteDataBuffer, pIoStackIrp->Parameters.Write.Length, &dwDataWritten))
           {
                DbgPrint(pWriteDataBuffer);
                NtStatus = STATUS_SUCCESS;
           }
        }
    }

    /*
     * This does not always need to be completed in this manner.  The I/O Manager is friendly
     * and in the simple case (as this driver is implemented) the IRP will be completed
     * by IoCompleteRequest() and the Status will be set to the return value.
     *
     * What will not be set however is the "Information" field, it cannot be set to how many bytes
     * were read or written obviously because the I/O Manager does not know, only your device
     * driver does.
     *
     * There are cases where you will need to complete the IRP and set the status however
     * our simple driver does not require that.
     *
     * In the Write operation the "bytes written" is really only used as an informant to
     * the application.  The Read operation is a bit different.  For example, some types of buffering
     * it may not matter if you set the number of bytes read.  For example "Neither" you write
     * directly into the user mode buffer so the user mode gets the data even if you don't
     * tell it the amount.  However if you remember how buffered I/O works?  It makes a copy
     * in memory.  If the I/O manager doesn't know the size then it can't copy it back to the
     * user mode buffer.
     *  
     *
     * IO_NO_INCREMENT - What is this?  If an IRP request is taking a long time you may want to help
     * the scheduler to re-schedule the thread as soon as possible.  For example perhaps it issued
     * a network request and went to sleep.  Then on another thread the network request completes
     * You may want to use one of the pre-defined constants or your own to increment the priority of
     * that thread to be rescheduled being since it hasn't been scheduled in a while.
     *
     */

    Irp->IoStatus.Status = NtStatus;
    Irp->IoStatus.Information = dwDataWritten;

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

    return NtStatus;
}

/**********************************************************************
 * 
 *  Example_WriteBufferedIO
 *
 *    This is called when a write is issued on the device handle (WriteFile/WriteFileEx)
 *
 *    This version uses Buffered I/O
 *
 **********************************************************************/
NTSTATUS Example_WriteBufferedIO(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
    NTSTATUS NtStatus = STATUS_UNSUCCESSFUL;
    PIO_STACK_LOCATION pIoStackIrp = NULL;
    UINT dwDataWritten = 0;
    PCHAR pWriteDataBuffer;

    DbgPrint("Example_WriteBufferedIO Called \r\n");
    
    /*
     * Each time the IRP is passed down the driver stack a new stack location is added
     * specifying certain parameters for the IRP to the driver.
     */
    pIoStackIrp = IoGetCurrentIrpStackLocation(Irp);
    
    if(pIoStackIrp)
    {
        pWriteDataBuffer = (PCHAR)Irp->AssociatedIrp.SystemBuffer;
    
        if(pWriteDataBuffer)
        {                             
            /*
             * We need to verify that the string is NULL terminated. Bad things can happen
             * if we access memory not valid while in the Kernel.
             */
           if(Example_IsStringTerminated(pWriteDataBuffer, pIoStackIrp->Parameters.Write.Length, &dwDataWritten))
           {
                DbgPrint(pWriteDataBuffer);
                NtStatus = STATUS_SUCCESS;
           }
        }
    }
    
    /*
     * This does not always need to be completed in this manner.  The I/O Manager is friendly
     * and in the simple case (as this driver is implemented) the IRP will be completed
     * by IoCompleteRequest() and the Status will be set to the return value.
     *
     * What will not be set however is the "Information" field, it cannot be set to how many bytes
     * were read or written obviously because the I/O Manager does not know, only your device
     * driver does.
     *
     * There are cases where you will need to complete the IRP and set the status however
     * our simple driver does not require that.
     *
     * In the Write operation the "bytes written" is really only used as an informant to
     * the application.  The Read operation is a bit different.  For example, some types of buffering
     * it may not matter if you set the number of bytes read.  For example "Neither" you write
     * directly into the user mode buffer so the user mode gets the data even if you don't
     * tell it the amount.  However if you remember how buffered I/O works?  It makes a copy
     * in memory.  If the I/O manager doesn't know the size then it can't copy it back to the
     * user mode buffer.
     *  
     *
     * IO_NO_INCREMENT - What is this?  If an IRP request is taking a long time you may want to help
     * the scheduler to re-schedule the thread as soon as possible.  For example perhaps it issued
     * a network request and went to sleep.  Then on another thread the network request completes
     * You may want to use one of the pre-defined constants or your own to increment the priority of
     * that thread to be rescheduled being since it hasn't been scheduled in a while.
     *
     */

    Irp->IoStatus.Status = NtStatus;
    Irp->IoStatus.Information = dwDataWritten;

    IoCompleteRequest(Irp, IO_NO_INCREMENT);


    return NtStatus;
}

/**********************************************************************
 * 
 *  Example_WriteNeither
 *
 *    This is called when a write is issued on the device handle (WriteFile/WriteFileEx)
 *
 *    This version uses Neither buffered or direct I/O.  User mode memory is
 *    read directly.
 *
 **********************************************************************/
NTSTATUS Example_WriteNeither(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
    NTSTATUS NtStatus = STATUS_UNSUCCESSFUL;
    PIO_STACK_LOCATION pIoStackIrp = NULL;
    PCHAR pWriteDataBuffer;
    UINT dwDataWritten = 0;
    DbgPrint("Example_WriteNeither Called \r\n");
    
    /*
     * Each time the IRP is passed down the driver stack a new stack location is added
     * specifying certain parameters for the IRP to the driver.
     */
    pIoStackIrp = IoGetCurrentIrpStackLocation(Irp);
    
    if(pIoStackIrp)
    {
        /*
         * We need this in an exception handler or else we could trap.
         */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲男同性视频| 激情五月激情综合网| 日本中文字幕不卡| 高清国产一区二区三区| 欧美美女一区二区三区| 国产精品视频你懂的| 日产国产欧美视频一区精品 | 日韩欧美你懂的| 亚洲欧美电影一区二区| 麻豆成人综合网| 欧美日韩高清影院| 亚洲女厕所小便bbb| 国产精品性做久久久久久| 欧美日韩高清在线| 亚洲一区二区视频在线观看| 国内精品嫩模私拍在线| 欧美一区二区三区在线观看| 一区二区三区在线不卡| 成人av午夜电影| 久久久99精品久久| 国内精品伊人久久久久av影院 | 日韩无一区二区| 亚洲1区2区3区4区| 欧美色精品在线视频| 亚洲视频你懂的| 99热99精品| 国产精品乱码一区二三区小蝌蚪| 久久激五月天综合精品| 欧美精品在线一区二区| 亚洲一区av在线| 在线观看免费一区| 一区二区三区美女视频| 色综合欧美在线视频区| 亚洲免费观看高清完整版在线观看 | 日韩欧美成人一区| 男女男精品视频网| 日韩欧美另类在线| 国内成+人亚洲+欧美+综合在线| 日韩丝袜情趣美女图片| 免费在线观看不卡| 精品少妇一区二区三区视频免付费| 日韩精品亚洲专区| 欧美成人国产一区二区| 国产伦理精品不卡| 国产精品久久影院| 欧美在线啊v一区| 五月激情综合婷婷| 91精品国产综合久久福利| 免费不卡在线视频| 日本一区二区三区四区在线视频| 高清免费成人av| 日韩一区有码在线| 欧美日韩色一区| 免费成人小视频| 日本一区二区三区在线不卡| 成人久久视频在线观看| 亚洲免费观看高清完整版在线观看熊| 欧洲亚洲国产日韩| 男人的天堂亚洲一区| 国产欧美精品一区| 97精品视频在线观看自产线路二| 尤物在线观看一区| 日韩欧美国产一二三区| 不卡视频一二三| 亚洲成人自拍偷拍| 精品99999| 一本大道av伊人久久综合| 免费一级片91| 亚洲欧美区自拍先锋| 51午夜精品国产| 大陆成人av片| 日本不卡的三区四区五区| 国产精品久久久久久户外露出| 色妞www精品视频| 精品制服美女丁香| 亚洲精品第一国产综合野| 欧美一区二区视频网站| 91网站最新网址| 黄网站免费久久| 亚洲一区二区三区中文字幕在线| 精品理论电影在线观看 | 国产精品第一页第二页第三页| 欧美无砖砖区免费| 国产盗摄视频一区二区三区| 亚洲图片欧美色图| 国产精品久久久久9999吃药| 欧美精品123区| 色综合久久久久综合| 国产精品一区二区黑丝| 午夜精品久久久久久久| 国产精品久久久久久一区二区三区| 欧美一区二区三区小说| 日本伦理一区二区| 成人sese在线| 国产精品123区| 免费成人在线视频观看| 亚洲国产一区二区三区| 亚洲欧美另类在线| 中文字幕在线一区二区三区| 2014亚洲片线观看视频免费| 91精品国产丝袜白色高跟鞋| 91福利在线播放| av一区二区不卡| 成人免费视频免费观看| 国产剧情在线观看一区二区| 美女尤物国产一区| 日韩高清国产一区在线| 亚洲va中文字幕| 一区二区三区四区不卡在线 | 国产成人综合亚洲91猫咪| 日本不卡的三区四区五区| 香蕉加勒比综合久久| 一区二区三区久久| 亚洲综合成人在线视频| 亚洲毛片av在线| 亚洲九九爱视频| 亚洲人精品午夜| 一区二区三区在线视频免费| 自拍偷拍国产亚洲| 亚洲精品免费看| 亚洲另类春色校园小说| 亚洲一区在线看| 亚洲成人第一页| 天堂一区二区在线| 青草av.久久免费一区| 久久精品理论片| 国产美女主播视频一区| 国产精品 日产精品 欧美精品| 国产.欧美.日韩| 91亚洲大成网污www| 欧美在线观看视频一区二区| 欧美日韩的一区二区| 欧美电影免费观看高清完整版| 欧美va亚洲va国产综合| 久久久99精品免费观看不卡| 国产精品青草久久| 洋洋av久久久久久久一区| 天天操天天综合网| 国产麻豆视频一区| 99国内精品久久| 欧美特级限制片免费在线观看| 欧美日韩精品系列| 久久一日本道色综合| 亚洲人一二三区| 五月激情丁香一区二区三区| 久久99九九99精品| 成人久久18免费网站麻豆| 欧美色网一区二区| 久久久青草青青国产亚洲免观| 国产精品久久久久久久久久免费看| 一区二区在线观看视频| 人禽交欧美网站| av不卡在线观看| 欧美一级日韩免费不卡| 中文字幕精品—区二区四季| 亚洲va国产天堂va久久en| 极品美女销魂一区二区三区免费| 成人动漫视频在线| 制服丝袜在线91| 一区在线观看视频| 精品午夜一区二区三区在线观看| 成人免费看片app下载| 91精品婷婷国产综合久久| 国产精品久久久久影院色老大| 亚洲va在线va天堂| 成人精品gif动图一区| 欧美精品欧美精品系列| 国产精品久久久久久久蜜臀 | 91精品视频网| 亚洲美女一区二区三区| 国产精品一区二区免费不卡 | 亚洲香肠在线观看| av激情综合网| 久久久久久久综合| 日韩高清国产一区在线| 色综合天天综合网天天狠天天| 日韩欧美激情一区| 亚洲第一会所有码转帖| 成人午夜在线视频| 精品国产一二三区| 天天免费综合色| 欧美日韩午夜在线视频| 亚洲另类在线视频| 99综合影院在线| 国产欧美日韩在线| 九色porny丨国产精品| 91精品国产综合久久精品图片| 国产精品护士白丝一区av| 国产精品自拍在线| 精品国产一区二区三区久久影院| 日韩精品一二三| 欧美一区二区美女| 青草国产精品久久久久久| 在线不卡中文字幕播放| 亚洲午夜电影在线| 欧美日韩亚洲综合一区二区三区| 一区二区三区91| 欧美日产在线观看| 日韩国产在线观看一区| 欧美高清激情brazzers|