• 如何自己写xuetr(一) 每次改变的驱动名和服务名


    首先要获取驱动模块的文件名字,根据每次文件名字的不同进行生成,名字可以从链表获得:

    typedef struct _LDR_DATA_TABLE_ENTRY {

    LIST_ENTRY InLoadOrderLinks;

    LIST_ENTRY InMemoryOrderLinks;

    LIST_ENTRY InInitializationOrderLinks;

    PVOID DllBase;

    PVOID EntryPoint;

    ULONG SizeOfImage;

    UNICODE_STRING FullDllName;

    UNICODE_STRING BaseDllName;

    }LDR_DATA_TABLE_ENTRY,*PLDR_DATA_TABLE_ENTRY;

    //上面这个结构体需要自己定义

    static PLDR_DATA_TABLE_ENTRY GetSysList(PDRIVER_OBJECT DriverObject)

    {

    PLDR_DATA_TABLE_ENTRY ldr = (PLDR_DATA_TABLE_ENTRY)DriverObject->DriverSection;

    return ldr;

    }

    PLDR_DATA_TABLE_ENTRY pSysList = NULL;

    pSysList = GetSysList(DriverObject);//从DriverEntry获取驱动链表的节点信息。

    // 拼字符串创建服务名字

    static NTSTATUS XCreateDriverName(IN PDRIVER_OBJECT DriverObject,UNICODE_STRING BaseDllName)

    {

    UNICODE_STRING DeviceName,Win32Device;

    PDEVICE_OBJECT DeviceObject = NULL;

    NTSTATUS status;

    P_USTR(&BaseDllName);

    WCHAR strDevice[256];

    RtlInitEmptyUnicodeString(&DeviceName,strDevice,sizeof(strDevice));

    RtlAppendUnicodeToString(&DeviceName,L"\Device\");

    RtlAppendUnicodeStringToString(&DeviceName,&BaseDllName);

    P_USTR(&DeviceName);

    WCHAR strDosDevices[256];

    RtlInitEmptyUnicodeString(&Win32Device,strDosDevices,sizeof(strDosDevices));

    RtlAppendUnicodeToString(&Win32Device,L"\DosDevices\");

    RtlAppendUnicodeStringToString(&Win32Device,&BaseDllName);

    P_USTR(&Win32Device);

    status = IoCreateDevice(DriverObject,

    0,

    &DeviceName,

    FILE_DEVICE_UNKNOWN,

    0,

    FALSE,

    &DeviceObject);

    if (!NT_SUCCESS(status))

    return status;

    if (!DeviceObject)

    return STATUS_UNEXPECTED_IO_ERROR;

    DeviceObject->Flags |= DO_DIRECT_IO;

    DeviceObject->AlignmentRequirement = FILE_WORD_ALIGNMENT;

    status = IoCreateSymbolicLink(&Win32Device, &DeviceName);

    DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

    return STATUS_SUCCESS;

    }

    更多请关注微信公众号:driverdevelop

  • 相关阅读:
    Oracle的hash分区
    Oracle的list分区
    range联合分区
    Oracle分区表range单分区
    彻底解决Oracle unable to create INITIAL extent for segment in tablespace xx
    Oracle表空间管理,数据迁移,
    plsqldevelop安装教程
    count(*)与count列谁快谁慢
    阿里云服务器Centos6.9安装oracle11g单实例数据库
    字符转换二进制码
  • 原文地址:https://www.cnblogs.com/xujinping/p/4822803.html
Copyright © 2020-2023  润新知