(resend, 2nd) kernel32: Implement QueryFullProcessImageNameA (2nd try)

Alexandre Julliard julliard at winehq.org
Thu Jun 4 05:49:58 CDT 2009


Stefan Leichter <Stefan.Leichter at 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.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list