Note that there are some explanatory texts on larger screens.

plurals
  1. POProcess access rights seem to differ when run from the compiler and as a standalone exe
    primarykey
    data
    text
    <p>I am using WINAPI for a program that I am writing. The program has the ProcessId of another process and needs to get a handle of it (to be able to terminate it later, and also to periodically check if the process is alive and responding by using WaitForSingleObject). When I compile my program (in Embarcadero RAD Studio 2010 C++ Builder), it works well; the program seems to get the handle successfully and generally works as intended. However, if I launch it from the folder as a standalone exe, it seems to fail to get the handle properly. I checked it by comparing (Companion is a HANDLE and Companion_PID is a DWORD):</p> <pre><code>GetProcessId(Companion) </code></pre> <p>and</p> <pre><code>Companion_PID </code></pre> <p>Where, a few lines earlier, Companion is taken from Companion_PID in the following code:</p> <pre><code>Companion = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Companion_PID); </code></pre> <p>And the "GetProcessId(Companion)" results in 0 (which is a good sign that the OpenProcess failed to return a proper handle.</p> <p>I'm pretty surprised that this code works differently when run from the compiler and as a standalone exe; I'm assuming in the first case the security attributes are inherited from the compiler itself, but I'd like to hear a possibly better explanation for this behaviour from someone more experienced in WINAPI and security attributes in particular.</p> <p>Small update: yes, like I thought, OpenProcess results in error 0x5 = ERROR_ACCESS_DENIED.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload