Note that there are some explanatory texts on larger screens.

plurals
  1. POGetBinaryType() fails with a last error of ERROR_PARTIAL_COPY
    text
    copied!<p>EDIT:</p> <p>The <code>ERROR_PARTIAL_COPY</code> error was not caused by the call to <code>GetBinaryType()</code> but by an earlier call to <code>EnumProcessModules()</code>, that was attempting to acquire the full path of the executable for a process to pass to <code>GetBinaryType()</code>, that failed. There was exception chaining occurring which I missed and that set the error message of the exception to the same error message in the original post but retained the OS error code of <code>ERROR_PARTIAL_COPY</code>.</p> <hr> <p>This function is called from within a 32-bit Windows Service. I have searched the internet and stackoverflow and found no other instance where <code>GetBinaryType()</code> failed and <code>GetLastError()</code> returned <code>ERROR_PARTIAL_COPY</code>:</p> <blockquote> <p>Only part of a ReadProcessMemory or WriteProcessMemory request was completed.</p> </blockquote> <p>A possibility I considered was that <code>ERROR_PARTIAL_COPY</code> was being set by an earlier WINAPI call and <code>GetBinaryType()</code> does not <code>SetLastError()</code> correctly. I attempted to reproduce this by:</p> <ul> <li>executing it with the path of a file that does not exist</li> <li>executing it with the path of a non-executable file</li> <li>executing it with the path of a file that denies access</li> </ul> <p>with no success (I called <code>SetLastError(ERROR_PARTIAL_COPY);</code> prior to each of the attempts): each of these attempts produced the expected result.</p> <p>The code snippet is:</p> <pre><code>std::string full_exe_path = a_impl-&gt;exe_installation_dir + "\\" + a_impl-&gt;exe_name; DWORD bin_type; if (FALSE == GetBinaryType(full_exe_path.c_str(), &amp;bin_type)) { throw Base_exception( __LINE__, __FILE__, "Failed to get binary type for " + a_impl-&gt;exe_name); // Optional argument here that defaults to GetLastError() } </code></pre> <p>Does anyone know, or have any suggestions, as to the cause of this?</p> <p><em>Note: this is happening on a machine that I do not have access to (and works on over 99% of the machines on which the Windows Service is running)</em></p>
 

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