获取dll中的跳转指令地址jmp esp

来源:互联网 发布:java集合有哪些 编辑:程序博客网 时间:2024/05/11 03:55

1、ntdll.dll和kernel32.dll文件属于Windows的系统文件,在Windows系统中扮演着重要角色。

ntdll.dll(NT Layer DLL)是Windows NT操作系统的重要模块,属于系统级别的文件。用于堆栈释放、进程管理。

kernel32.dll是Windows 9x/Me中非常重要的32位动态链接库文件,属于内核级文件。它控制着系统的内存管理、数据的输入输出操作和中断处理,当Windows启动时,kernel32.dll就驻留在内存中特定的写保护区域,使别的程序无法占用这个内存区域。

2、下面的程序获取jmp esp(0xFFE4)指令地址,可以在不同的dll文件中进行搜索,详细见下面代码

// getJmpEsp.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include<windows.h>
#include<iostream.h>

#include<tchar.h>

int getJmpEsp(TCHAR *ucDllName)
{
    HINSTANCE h;
    
    h = GetModuleHandle(ucDllName);
    if(h == NULL)
    {
        h = LoadLibrary(ucDllName);
        if(h == NULL)
        {
            cout<<"ERROR LOADING DLL:"<<ucDllName<<endl;
            return -1;
        }
    }
    BYTE* ptr=(BYTE*)h;
    bool done=false;
    for(int y=0;!done;y++)
    {
        try
        {
            if(ptr[y] == 0xFF && ptr[y+1] == 0xE4)
            {
                int pos=(int)ptr + y;
                cout<<"OPCODE found at 0x"<<hex<<pos<<endl;
            }
        }catch(...)
        {
            cout<<"END OF "<<ucDllName<<" MEMORY REACHED"<<endl;
            done=true;
        }
    }
    FreeLibrary(h);
    return 0;
}
int main()
{
    getJmpEsp("ntdll");
    getJmpEsp("kernel32");
    return 0;
    
}
原创粉丝点击