none
COMO SALVAR UM TIPO DE DADOS EM UM TXT RRS feed

  • Pergunta

  • Como faço para salvar dados value dados da memoria em um arquivo de texto?

    Tenho que alocar?

    #include <iostream>

    #include <iomanip>
    #include <windows.h>
    #include <tlhelp32.h>
    #include <shlwapi.h>
    #include <shlobj.h>


    #define ReadLimit 100*4096 //6 zeroes - for ReadProcessMemory 
    #define StaticCacheSize 2*40000


    char *pCacheMap;


    using namespace std;


    int main()
    {
        DWORD address = 0x02C076C8;
    char* value = new char[79];


    FILE *arquivo;

    HANDLE hProcess,hProcesses;
    MEMORY_BASIC_INFORMATION MBI;
    BYTE *Buf;
    DWORD ReadAddr,QueryAddr,BytesRead,BufSize;
    BOOL bRet,pBool;
    SECURITY_ATTRIBUTES sa;



        //pGlobalBuf = VirtualAlloc(NULL,ReadLimit+4096,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE);

        HANDLE phandle = OpenProcess(PROCESS_VM_READ|PROCESS_QUERY_INFORMATION, 0, 21156);



        if(!phandle)
        {
    cout << "Programa não está em execução!";
    cin.get();
        }

    QueryAddr = 0;
    while(1) { //Enumerate process memory regions

        //Sleep(1);
    // _memset(&MBI,0x00,sizeof(MBI));
    VirtualQueryEx(phandle,(LPVOID)QueryAddr,&MBI,sizeof(MBI));  //if its bigger than 1 0 000 000 bytes, read only that amount

    if(MBI.BaseAddress==0 && QueryAddr!=0) { break; } //memory regions finished

    QueryAddr += (DWORD) MBI.RegionSize;

    if(MBI.Protect&PAGE_NOACCESS || MBI.Protect&PAGE_GUARD /*|| MBI.Protect&PAGE_EXECUTE || MBI.Protect&PAGE_EXECUTE_READ || MBI.State&MEM_FREE*/) { continue; }

    ReadAddr = 0;
    while(MBI.RegionSize>0) {

    if(ReadAddr!=0) {
    ReadAddr+=ReadLimit;
    } else { 
    ReadAddr = (DWORD) MBI.BaseAddress;
    }

    if(MBI.RegionSize>ReadLimit) {

    BufSize = ReadLimit;
    MBI.RegionSize -= ReadLimit;

    } else {

    BufSize = MBI.RegionSize;
    MBI.RegionSize = 0;
    }

    BytesRead = 0;



    ReadProcessMemory(phandle,(LPVOID)ReadAddr,&value[0],79,&BytesRead); 


    cout << value << endl;
    //Sleep(5000);


    }



    CloseHandle(phandle);

        return 0;
    }

     
    domingo, 8 de maio de 2016 22:33