zoukankan      html  css  js  c++  java
  • 程序分析2-vec-list-map-MFC

    vector :动态数组

    我们可以通过ecx查看对象的内存

    list: 双向循环链表

    map: 树

     

    第一个是指向自己指针。

    第二个是指向结构体

    第三个是元素个数

     

     

     

    // 数据结构.cpp : 定义控制台应用程序的入口点。 //
    #include "stdafx.h"
    #include <iostream>
    #include <vector> 
    #include <list> 
    #include <map> 
    using namespace std;
    struct MyVector {  
        struct MyVector* pSelf;
        int* pDataStart;   
        int* pDataEnd;   
        int* pBufEnd;
    };
    struct MyNode { 
        struct MyNode* pNext; 
        struct MyNode* pPrev;  
        int nData; };
    struct MyList
        {    
        struct MyList* pSelf; 
        struct MyNode* pRoot; 
        int nNodeCount;
    };
    void testVector() { 
        // 动态数组,数据存储在堆内存中  
        // 当元素发生改变之后,会动态增加内存。 
        vector<int> vecObj;
        vecObj.push_back(1); 
        vecObj.push_back(2); 
        vecObj.push_back(3);  
        vecObj.pop_back();   
        vecObj.push_back(4); 
        vecObj.push_back(5);  
        vecObj.push_back(6);   
        vecObj.push_back(7);   
        //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐    // 遍历vector     
        for (size_t i = 0; i < vecObj.size(); i++) 
        {        
            printf("vecObj[%d] = %d", i, vecObj[i]); 
        }
        //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐    // 遍历vector     
        vector<int>::iterator iter = vecObj.begin();  
        while (iter != vecObj.end())    
        {        
            int n = *iter;   
            printf("vecObj i = %d", n); 
            iter++;  // 有临时对象产生 
            //++iter;// 无临时对象   
        }
        
        //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐    // 定义结构,操作vector     
        
        MyVector* pVector = (MyVector*)&vecObj;
        
    int size = ((int)pVector‐>pDataEnd ‐ (int)pVector‐>pDataStart) / sizeof(int))
        for (size_t i = 0; i < size; i++) 
        {       
            //pVector‐>pDataStart[i] = 3; 
            int n = pVector‐>pDataStart[i];  
            printf("元素=%d
    ", n); 
                                       
        } 
                                                                   
    }
    void testList() {     // 双向循环链表, 节点     
        list<int> listObj;
        listObj.push_back(1);  
        listObj.push_back(2);  
        listObj.push_back(3);   
        listObj.pop_back();
        listObj.push_back(4);
        //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
        MyList* pList = (MyList*)&listObj;   
        int size = pList‐>nNodeCount;  
        MyNode* pNode = pList‐>pRoot;  
        while (pNode‐>pNext != pList‐>pRoot)  
        {        
            pNode = pNode‐>pNext;    
            int n = pNode‐>nData; 
            printf("元素=%d
    ", n); 
        }
    }
    struct MyMapNode { 
        struct MyMapNode* pLeft; 
        struct MyMapNode* pParent; 
        struct MyMapNode* pRight;  
        int unknown;    
        int nkey;
        int nValue;
    }; 
    struct MyMap {
        struct MyMap* pSelf; 
        struct MyMapNode* pRoot; 
        int nNodeCount; };
    
    void enumMapNode(MyMapNode* pNode, MyMapNode* pRoot) 
    {   
        if (pNode == pRoot) return;  
        //printf("key=%d, value=%d
    ", pNode‐>nkey, pNode‐>nValue);  
        enumMapNode(pNode‐>pLeft, pRoot);  
        printf("key=%d, value=%d
    ", pNode‐>nkey, pNode‐>nValue); 
        enumMapNode(pNode‐>pRight, pRoot);
    }
    void testMap() { 
        map<intint> mapObj; 
        typedef pair <intint> Int_Pair; 
        mapObj.insert(Int_Pair(10x11));   
        mapObj.insert(Int_Pair(20x22));   
        mapObj.insert(Int_Pair(30x33));  
        mapObj.insert(Int_Pair(40x44));  
        mapObj.insert(Int_Pair(50x55));  
        mapObj.insert(Int_Pair(60x66));
        MyMap* pMap = (MyMap*)&mapObj;   
        MyMapNode* pNode = pMap‐>pRoot‐>pParent;    
        enumMapNode(pNode, pMap‐>pRoot);
        //mapObj.erase(2);
        //mapObj.insert(Int_Pair(7, 0x77));     //mapObj.insert(Int_Pair(3, 0x55));
    }
    int main()
        {  
        testVector();  
        testList();   
        testMap();
        getchar(); 
        return 0; 
    }

    MFC程序

    CWinApp的派生类中的 InitInstance

    CDialog的OnInitDialog

    各种消息处理函数

     

    分析MFC程序,我们应该去寻找特征: 同一个版本的MFC程序,特征应该一样。 寻找InitInstance

    mov         eax,dword ptr [edx]   mov         esi,esp  
    mov         ecx,dword ptr [eax+58h]   mov         dword ptr [ebp‐24h],ecx   mov         edi,esp   mov         ecx,dword ptr [ebp‐24h] 

    寻找按钮点击的特征 2017

  • 相关阅读:
    Java continue break 制作简单聊天室程序,屏蔽不文明语言,显示每句话聊天时间 for(;;) SimpleDateFormat("yyyy-MM-dd hh:mm:ss") equalsIgnoreCase
    Java实现随机出题,10道10以内加减法计算
    Java发出声卡蜂鸣生的方法
    Java程序调用自动关机指令 1分钟内自动关机
    Java如何将十六进制数转换为十进制数的自编程序
    告诉你今年是哪个生肖年的java程序
    更新MySQL数据库( java.sql.SQLException: No value specified for parameter 1) 异常 解决方法
    把网上图片下载到本地的java工具类
    exp ORA-01455: converting column overflows integer datatype
    shell date 格式化
  • 原文地址:https://www.cnblogs.com/ltyandy/p/11256630.html
Copyright © 2011-2022 走看看