Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:56:47+00:00 2026-06-01T12:56:47+00:00

I am trying to dump a process, say calc.exe When I run my program

  • 0

I am trying to dump a process, say calc.exe

When I run my program I get

Program received signal SIGSEGV, Segmentation fault.
0x0000000000401640 in MiniDumpWriteDump ()

Here is the code

#include <windows.h>
#include <dbghelp.h>

int main(){
    HANDLE hFile = CreateFileA(
        "calc.dmp",
        GENERIC_READ | GENERIC_WRITE,
        FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
        NULL,
        CREATE_ALWAYS,
        FILE_ATTRIBUTE_NORMAL,
        NULL
    );

    DWORD procID = 196;

    HANDLE hProc = OpenProcess(
        PROCESS_ALL_ACCESS,
        FALSE,
        procID
    );

    MiniDumpWriteDump(
        hProc,
        procID,
        hFile,
        MiniDumpWithFullMemory,
        NULL,
        NULL,
        NULL
    );

    CloseHandle(hFile);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:56:48+00:00Added an answer on June 1, 2026 at 12:56 pm

    You example works on 32 bit and 64 bit windows, but it has to be compiled with the same “bitness” (64 bit on 64 bit Windows, 32 bit on 32 bit Windows).

    I only added a window enumeration and a way to supply a procID as an argument. The functions that return values should be checked for errors.

    #include <windows.h>
    #include <dbghelp.h>
    #include <stdio.h>
    #define TRYTO(b,a) if (!(a)) { \
    fprintf(stderr,"Unable to " b "\n"); exit(1);}
    static BOOL CALLBACK FunkyCallback(HWND hWnd, LPARAM lParam ){
        char b[100]; RECT Rect;
        DWORD pid;
        if(!GetParent(hWnd)){
            GetWindowText(hWnd, b, 99); GetWindowRect(hWnd,&Rect);
            GetWindowThreadProcessId(hWnd, &pid);
            printf("%li: %s left:%li top:%li\n",pid,b,Rect.left,Rect.top);
        }
        return TRUE;
    }
    int main(int argc, char ** argv){
        HANDLE hFile;
        DWORD procID;
        HANDLE hProc;
        if (argc > 1){
            TRYTO("create file",(
                hFile = CreateFile(
                    "proc.dmp",
                    GENERIC_READ | GENERIC_WRITE,
                    FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
                    NULL,
                    CREATE_ALWAYS,
                    FILE_ATTRIBUTE_NORMAL,
                    NULL
                ))!=INVALID_HANDLE_VALUE);
            DWORD procID = atoi(argv[1]);
            TRYTO("open process",(
                hProc = OpenProcess(
                    PROCESS_ALL_ACCESS,
                    FALSE,
                    procID
                )));
            TRYTO("write dump",(
                MiniDumpWriteDump(
                    hProc,
                    procID,
                    hFile,
                    MiniDumpNormal,
                    NULL,
                    NULL,
                    NULL
                )));
            fprintf(stderr,"Successfully created proc.dmp.\n",argv[0]);
            CloseHandle(hFile);
        } else { 
            EnumChildWindows(GetDesktopWindow(),FunkyCallback, 0);
            fprintf(stderr,"Usage: %s procID\n",argv[0]);
        }
    }
    

    Compilation notes

    Tested on Linux with Mingw64.
    Fedora Linux has packages here. I copied the 64 bit dbghelp.dll from Windows Server 2008 Windows/system32 to the source folder. objdump -f can confirm whether the dll is 64 or 32 bit. The compile line was something like

    /usr/bin/x86_64-w64-mingw32-gcc dmp.c -L. -l dbghelp -o dmp.exe
    

    Links

    • Link to .DLL on Windows
    • Wine
    • Link to DLL with MingW
    • C FAQ system dependencies
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have taken a dump of W3wp.exe process and am trying to retrieve the
I'm trying to run some statistics over the Stack Overflow data dump, and for
I'm trying to debug a 32 bit process dump from a process that ran
I am getting some odd results when trying to run a process from a
Good day. I'm trying to get a thread dump (stack trace and state for
I've a dump file of a process I'm running (trying to find a memory
I'm trying to run a command-line program and piping in a file. The command
I am trying to get crash dump debugging working with 2010, but it keeps
I'm trying to make a dump of a MySQL table on the server and
I am trying to use my logger to dump variables to my logfile. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.