On 2016-06-29 02:38, hbelusca(a)svn.reactos.org wrote:
  +    if (!CharCount && (Result ==
ERROR_INSUFFICIENT_BUFFER))
 +    {
 +        /* Reallocate the buffer with double size */
 +        dwSize *= 2;
 +        tmp = (PWSTR)HeapReAlloc(GetProcessHeap(), 0, lpTargetPath, dwSize *
sizeof(WCHAR)); 
Oops, this fixes my previous concern, thanks.
The casts are still weird though.
  +        if (!tmp)
 +        {
 +            /* Memory problem, bail out */
 +            CharCount = 0;
 +            Result = ERROR_NOT_ENOUGH_MEMORY;
 +        }
 +        else
 +        {
 +            /* Retry again */
 +            lpTargetPath = tmp;
 +            goto Retry;
 +        }
 +    }
 +
 +    if (CharCount)
 +    {
 +        if ( wcsncmp(lpTargetPath, L"\\??\\", 4) == 0 &&
 +             ( (lpTargetPath[4] >= L'A' && lpTargetPath[4] <=
L'Z') ||
 +               (lpTargetPath[4] >= L'a' && lpTargetPath[4] <=
L'z') ) )
 +        {
 +            /* The drive exists and is SUBSTed */
 +            Result = ERROR_IS_SUBSTED;
 +        }
 +#if 0
 +        else
 +        {
 +            /* The drive exists but is not SUBSTed */
 +            Result = ERROR_INVALID_DRIVE;
 +        }
 +#endif
 +    }
 +
 +    if (!TargetPath)
 +    {
 +        /* Free the local buffer */
 +        HeapFree(GetProcessHeap(), 0, lpTargetPath);
 +    }
 +    else
 +    {
 +        /* Update the user-given pointers */
 +        *TargetPath = lpTargetPath;
 +        *Size = dwSize; 
If the HeapReAlloc above fails you might still get into this code path
which is not advisable. It should probably always take the if-branch in
that case.
  +    }
 +
 +    return Result; 
Thanks.
-Thomas