首页
社区
课程
招聘
[原创]win10 内核中遍历内核模块
发表于: 2023-11-20 22:38 6261

[原创]win10 内核中遍历内核模块

2023-11-20 22:38
6261

//新人贴,只供自己学习 学习过了的就不要浪费时间

#include <ntifs.h>
LONGLONG mGetModuleBaseByName(PDRIVER_OBJECT pDriver, UNICODE_STRING moduleName)
{
    UNREFERENCED_PARAMETER(moduleName);
    PLDR_DATA_TABLE_ENTRY pLdr = NULL;
    PLIST_ENTRY pListEntry = NULL;
    PLIST_ENTRY pCurrentListEntry = NULL;
 
    PLDR_DATA_TABLE_ENTRY pCurrentModule = NULL;
    pLdr = (PLDR_DATA_TABLE_ENTRY)pDriver->DriverSection;
    pListEntry = pLdr->InLoadOrderLinks.Flink;
    pCurrentListEntry = pListEntry->Flink;
 
    while (pCurrentListEntry != pListEntry)
    {
        //获取PLDR_DATA_TABLE_ENTRY结构
        pCurrentModule = CONTAINING_RECORD(pCurrentListEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
        if (pCurrentModule->BaseDllName.Buffer != nullptr)
        {
 
            DbgPrintEx(0, 77, "ModuleName:%wZ", pCurrentModule->BaseDllName);
         
            //比较模块名
            if (RtlCompareUnicodeString(&pCurrentModule->BaseDllName, &moduleName, true) == 0)
            {
                return (LONGLONG)pCurrentModule->DllBase;
            }
 
        }
        pCurrentListEntry = pCurrentListEntry->Flink;
    }
    return 0;
}
 
void UnDriverLoad(DRIVER_OBJECT* pDriver)
{
    UNREFERENCED_PARAMETER(pDriver);
}
 
extern "C" NTSTATUS DriverEntry(DRIVER_OBJECT * pDriver, UNICODE_STRING * pRegistryPath)
{
    UNREFERENCED_PARAMETER(pRegistryPath);
    pDriver->DriverUnload = UnDriverLoad;   
    UNICODE_STRING mName= RTL_CONSTANT_STRING(L"");
    mGetModuleBaseByName(pDriver, mName);
    return STATUS_SUCCESS;
}
#include <ntifs.h>
LONGLONG mGetModuleBaseByName(PDRIVER_OBJECT pDriver, UNICODE_STRING moduleName)
{
    UNREFERENCED_PARAMETER(moduleName);
    PLDR_DATA_TABLE_ENTRY pLdr = NULL;
    PLIST_ENTRY pListEntry = NULL;
    PLIST_ENTRY pCurrentListEntry = NULL;
 
    PLDR_DATA_TABLE_ENTRY pCurrentModule = NULL;
    pLdr = (PLDR_DATA_TABLE_ENTRY)pDriver->DriverSection;
    pListEntry = pLdr->InLoadOrderLinks.Flink;
    pCurrentListEntry = pListEntry->Flink;
 
    while (pCurrentListEntry != pListEntry)
    {
        //获取PLDR_DATA_TABLE_ENTRY结构
        pCurrentModule = CONTAINING_RECORD(pCurrentListEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
        if (pCurrentModule->BaseDllName.Buffer != nullptr)
        {
 
            DbgPrintEx(0, 77, "ModuleName:%wZ", pCurrentModule->BaseDllName);
         
            //比较模块名

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

最后于 2023-11-20 22:45 被foxkinglxq编辑 ,原因:
收藏
免费 1
支持
分享
最新回复 (1)
雪    币: 3059
活跃值: (30876)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
感谢分享
2023-11-21 09:33
1
游客
登录 | 注册 方可回帖
返回
//