C++ MiniDumpWriteDump failed

2

I am trying to create a simple C++ console app which dump the memory space of a given process (e.g. calc.exe) So I use MiniDumpWriteDump function

Here is the code :

DWORD procID = 1150;
char* procName = "calc.exe";

    // opens the dump file
    HANDLE hFile = CreateFile( "calc.dmp", GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); 
    if(hFile)
    {
        // opens the process
        HANDLE hProcToDump = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE,  procID);
        if(hProcToDump)
        {
            // dumps via the API
            BOOL rv = MiniDumpWriteDump(hProcToDump, GetProcessId(hProcToDump), hFile, MiniDumpNormal, NULL, NULL, NULL);
            HRESULT hr = GetLastError();

            if( !rv )
                printf("MiniDumpWriteDump failed.");
            else
                printf("Minidump OK!");

            CloseHandle( hFile );
            CloseHandle( hProcToDump );
        }
}

But I get the error : GetLastError() = hresult 0x8007012b Only part of a ReadProcessMemory or WriteProcessMemory request was completed

Why ? Note : I am admin on Win 7 x64.

Thank you for your help.

c++
dump
asked on Stack Overflow Jun 12, 2015 by Jeremy

1 Answer

0

Try this, which is similar to your example. Usage of MiniDumpWriteDump.

answered on Stack Overflow Jun 12, 2015 by Amaresh Narayanan

User contributions licensed under CC BY-SA 3.0