SetDbgZone failed with process id. RRS feed

  • General discussion

  • I am trying to set debug zone for some process and modules. SetDbgZone for module is working fine, but failed with process id the error code is 87, invalid parameter.

    hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);

        PROCESSENTRY32 p;
        p.dwSize = sizeof(PROCESSENTRY32);
        if (Process32First(hSnapShot,&p))


    if(SetDbgZone(p.th32ProcessID,0 , NULL, -1,&dbgzone))

    I get the process name correctly, but the call to SetDbgZone still failed.

    any one know what is the problem?

    Tuesday, June 4, 2013 8:18 AM

All replies

  • The fist argument of SetDbgZone is the process HANDLE, not the process ID (differently from when you deal with a module). Try with

    HANDLE hProcess = OpenProcess(0, FALSE, p.th32ProcessID);
    SetDbgZone(hprocess ,0 , NULL, -1,&dbgzone);

    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom Check my blog:

    Friday, June 7, 2013 8:34 AM
  • thanks, it still failed with same error 87.
    Tuesday, July 9, 2013 4:15 AM
  • Did you confirm that the process ID and the process handle are legitimate as returned by Process32First and OpenProcess?
    Tuesday, July 9, 2013 12:55 PM