Stefan Leichter Stefan.Leichter@camline.com writes:
/******************************************************************
QueryFullProcessImageNameA (KERNEL32.@)- */
+BOOL WINAPI QueryFullProcessImageNameA(HANDLE hProcess, DWORD dwFlags, LPSTR lpExeName, PDWORD pdwSize) +{
- BOOL retval;
- DWORD pdwSizeW = *pdwSize;
- LPWSTR lpExeNameW = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, *pdwSize * sizeof(WCHAR));
- retval = QueryFullProcessImageNameW(hProcess, dwFlags, lpExeNameW, &pdwSizeW);
- if(retval) {
if(lpExeName)*pdwSize = FILE_name_WtoA(lpExeNameW, pdwSizeW, lpExeName, *pdwSize);else {/* this is a difference between the acsii and the unicode version (vista)* the unicode version crashes when the size is big enough to hold the result* ascii version throughs an error*/retval = FALSE;SetLastError(ERROR_INVALID_PARAMETER);}- }
I'd expect that error to be a side effect of WideCharToMultiByte, which is most likely what you want to use here. Also you have to handle buffer overflows correctly, with test cases.