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

  • Home
  • SEARCH
  • 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 6691797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:47:38+00:00 2026-05-26T05:47:38+00:00

I’m trying to open a process with my debugger using CreateProcess with the DEBUG_PROCESS

  • 0

I’m trying to open a process with my debugger using CreateProcess with the DEBUG_PROCESS and DEBUG_ONLY_THIS_PROCESS flags and the the process is opened, but then when I try to call SymInitialize with the handle I receive, it fails.

This is my code:

#include <windows.h> 
#include <stdio.h> 
#include <dbghelp.h> 
#pragma (lib, "dbghelp.lib"); 

bool EnablePrivilege(LPCTSTR lpszPrivilegeName, BOOL bEnable)  
{  
    HANDLE hToken;  
    TOKEN_PRIVILEGES    tp;  
    LUID luid;  
    bool ret;  

    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY | TOKEN_READ, &hToken))  
        return FALSE;  

    if (!LookupPrivilegeValue(NULL, lpszPrivilegeName, &luid))  
        return FALSE;  

    tp.PrivilegeCount           = 1;  
    tp.Privileges[0].Luid       = luid;  
    tp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;  

    ret = AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);  
    CloseHandle(hToken);  

    return ret;  
} 

void main() 
{ 
    EnablePrivilege(SE_DEBUG_NAME, TRUE); 

    STARTUPINFOA startInfo; 
    PROCESS_INFORMATION processInfo; 
    ZeroMemory( &startInfo, sizeof(startInfo) ); 
    startInfo.cb = sizeof(startInfo); 
    ZeroMemory( &processInfo, sizeof(processInfo) ); 
    DWORD creationFlags = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS | PROCESS_VM_READ | PROCESS_QUERY_INFORMATION; 
    const char* comLine = "Some process path and name"; 

//     Start the child process.  
    if( CreateProcessA( NULL,   // No module name (use command line) 
       (LPSTR)comLine, //argv[1],        // Command line 
        NULL,           // Process handle not inheritable 
        NULL,           // Thread handle not inheritable 
        FALSE,          // Set handle inheritance to FALSE 
        creationFlags,              // No creation flags 
        NULL,           // Use parent's environment block 
        NULL,           // Use parent's starting directory  
        &startInfo,            // Pointer to STARTUPINFO structure 
        &processInfo )           // Pointer to PROCESS_INFORMATION structure 
     == false )  
    { 
        printf("FAIL!"); 
return; 
    } 

    SetLastError(0); 
    bool ok = SymInitialize(processInfo.hProcess, NULL, true); 
    int err = GetLastError(); 

} 

If I call CreateProcess with no creation flags, symInitialize succeed.
What am I doing wrong?

  • 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-05-26T05:47:39+00:00Added an answer on May 26, 2026 at 5:47 am

    Your error is result of calling MAKE_HRESULT macro as

    MAKE_HRESULT(ERROR_SEVERITY_ERROR, FACILITY_NULL, ERROR_INVALID_DATA)
    

    So your error code is not trash. Documentaion doesn’t say what kind of data might be invalid in this context. I will try to see what exactly is causing the problem.

    EDIT:

    This code works for me

    #include <windows.h>
    #include <stdio.h>
    #include <dbghelp.h>
    #include <WinError.h>
    
    bool EnablePrivilege(LPCTSTR lpszPrivilegeName, BOOL bEnable)
    {
        HANDLE hToken;
        TOKEN_PRIVILEGES    tp;
        LUID luid;
        bool ret;
    
        if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY | TOKEN_READ, &hToken))
        return FALSE;
    
        if (!LookupPrivilegeValue(NULL, lpszPrivilegeName, &luid))
        return FALSE;
    
        tp.PrivilegeCount           = 1;
        tp.Privileges[0].Luid       = luid;
        tp.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
    
        ret = AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
        CloseHandle(hToken);
    
        return ret;
    }
    
    void main()
    {
        EnablePrivilege(SE_DEBUG_NAME, TRUE);
    
        STARTUPINFOA startInfo;
        PROCESS_INFORMATION processInfo;
        ZeroMemory( &startInfo, sizeof(startInfo) );
        startInfo.cb = sizeof(startInfo);
        ZeroMemory( &processInfo, sizeof(processInfo) );
        DWORD creationFlags = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS | PROCESS_VM_READ | PROCESS_QUERY_INFORMATION;
        const char* comLine = "C:\\Windows\\Notepad.exe";
    
    //     Start the child process.
        if( CreateProcessA( NULL,   // No module name (use command line)
           (LPSTR)comLine,// argv[1],        // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        creationFlags,              // No creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory
        &startInfo,            // Pointer to STARTUPINFO structure
        &processInfo )           // Pointer to PROCESS_INFORMATION structure
         == false )
        {
        printf("FAIL!");
    return;
        }
    
        SetLastError(0);
        bool ok = SymInitialize(processInfo.hProcess, NULL, true);
        HRESULT err = HRESULT_FROM_WIN32(GetLastError());
    }
    

    I don’t know why it doesn’t for you – I am running windows XP, it might be a difference. For me SymInitialize returns true, and GetLastError returns 0x800700cb, which means only that it didn’t found evirnment variable pointing it to directory with symbol files.

    This might be stupid question, but perhaps you are missing some debugging libraries in your system? Have you tried installing eg. Debugging Tools for
    Windows
    ? I would reccomend ‘Download Debugging Tools from the Windows SDK’ option – read the description. I guess every programming IDE around would install it for you or have you install it before debugging anything, but it’s always best to check.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am trying to loop through a bunch of documents I have to put

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.