zoukankan      html  css  js  c++  java
  • 写程序取自己进程的AEP

    测试程序功能 

    打印出自己进程的程序入口点地址.

    结合OD载入程序,看到的入口点确实是0x004014f0, 说明程序入口点找到了

    测试程序

    [cpp] view plain copy
     
    1. /// @file exam_1_1.c  
    2.   
    3. #include <stdlib.h>  
    4. #include <stdio.h>  
    5.   
    6. void fnGetProgEntry();  
    7.   
    8. int main(int agrc, char** argv)  
    9. {  
    10.     fnGetProgEntry();  
    11.   
    12.     printf("END, press any key to quit ");  
    13.     getchar();  
    14.     return 0;  
    15. }  
    16.   
    17. void fnGetProgEntry()  
    18. {  
    19.     #define PE_SIGNTURE 0x4550 ///< "PE"  
    20.   
    21.     int* pFileAddressOfNewHeader = NULL;  
    22.     int* pCOFFFileHeader = NULL;  
    23.     int* pAEP = NULL;  
    24.     const int iAddrPeImgBase = 0x400000;  
    25.   
    26.     /// iOffsetX 为偏移  
    27.     /// iContent 为地址中的内容  
    28.     const int iOffsetFileAddressOfNewHeader = (16 * 4 - 4); ///< File address of new header 相对于DosHeader的偏移  
    29.     const int iOffsetAEPToFileAddressOfNewHeader = 0x28;  
    30.   
    31.     int iContentFileAddressOfNewHeader = 0;   
    32.     int iPeSignature = 0;  
    33.     int iOffsetAddressOfEntryPoint = 0; ///< 程序入口点偏移地址  
    34.       
    35.     do   
    36.     {  
    37.         pFileAddressOfNewHeader = (int*)(iAddrPeImgBase + iOffsetFileAddressOfNewHeader);  
    38.         iContentFileAddressOfNewHeader = *pFileAddressOfNewHeader; ///< iContentFileAddressOfNewHeader = 0xd0  
    39.   
    40.         pCOFFFileHeader = (int*)(iAddrPeImgBase + iContentFileAddressOfNewHeader);  
    41.         iPeSignature = *pCOFFFileHeader;  
    42.         if (PE_SIGNTURE != iPeSignature)  
    43.         {  
    44.             printf("error pe file ");  
    45.         }  
    46.   
    47.         pAEP = (int*)((int)pCOFFFileHeader + iOffsetAEPToFileAddressOfNewHeader);  
    48.         iOffsetAddressOfEntryPoint = iAddrPeImgBase + *pAEP;  
    49.         printf("my address entry point is 0x%x ", iOffsetAddressOfEntryPoint);  
    50.     } while (0);  
    51.   
    52.     printf("END, press any key to quit ");  
    53. }  

    运行结果

    http://blog.csdn.net/lostspeed/article/details/49506193

  • 相关阅读:
    Python--基本的对象类型(列表_可变的数据类型)
    Python--基本的对象类型(数字int和布尔值bool)
    Java项目目录结构
    linux- day1
    python学习笔记,视频day20-装饰器
    python学习笔记,视频day19-习题
    python学习笔记,视频day17、18-文件处理
    python学习笔记,视频day16 17-内置函数
    python学习笔记,视频day16-函数作用域,匿名函数,map,filter,reduce
    python学习笔记,视频day15-全局变量与局部变量、风湿理论、函数递归
  • 原文地址:https://www.cnblogs.com/findumars/p/5187279.html
Copyright © 2011-2022 走看看