mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Always convert paths to full UNC paths. Refs #177
* This avoids ambiguity/possible change between a mapped network drive like Z:\ and the UNC path \\hostname\foo\bar\
This commit is contained in:
@@ -187,9 +187,9 @@ namespace renderdocui.Code
|
||||
RefreshAssociations();
|
||||
}
|
||||
|
||||
private static string GetVulkanJSONPath(bool wow6432)
|
||||
public static string GetVulkanJSONPath(bool wow6432)
|
||||
{
|
||||
string basepath = Path.GetDirectoryName(Application.ExecutablePath);
|
||||
string basepath = Win32PInvoke.GetUniversalName(Path.GetDirectoryName(Application.ExecutablePath));
|
||||
if (wow6432)
|
||||
basepath = Path.Combine(basepath, "x86");
|
||||
|
||||
|
||||
@@ -117,5 +117,40 @@ namespace renderdocui.Code
|
||||
|
||||
return new string(buffer);
|
||||
}
|
||||
|
||||
[DllImport("mpr.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern uint WNetGetUniversalNameW(string lpLocalPath, int dwInfoLevel, IntPtr lpBuffer, ref int lpBufferSize);
|
||||
private const int UNIVERSAL_NAME_INFO_LEVEL = 0x00000001;
|
||||
private const uint ERROR_MORE_DATA = 234;
|
||||
|
||||
public static string GetUniversalName(string localPath)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
IntPtr buf = (IntPtr)IntPtr.Size; // don't initialise to zero, as otherwise the call fails
|
||||
|
||||
uint ret = WNetGetUniversalNameW(localPath, UNIVERSAL_NAME_INFO_LEVEL, buf, ref size);
|
||||
|
||||
if (ret != ERROR_MORE_DATA)
|
||||
return localPath;
|
||||
|
||||
buf = Marshal.AllocHGlobal(size);
|
||||
|
||||
ret = WNetGetUniversalNameW(localPath, UNIVERSAL_NAME_INFO_LEVEL, buf, ref size);
|
||||
|
||||
string universalPath = localPath;
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
// buf points to a struct that contains just a string pointer, that points
|
||||
// immediately after it. So we need to advance by one IntPtr to get to the
|
||||
// actual string
|
||||
universalPath = Marshal.PtrToStringUni(IntPtr.Add(buf, IntPtr.Size));
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(buf);
|
||||
|
||||
return universalPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -904,7 +904,7 @@ namespace renderdocui.Windows.Dialogs
|
||||
|
||||
Helpers.CheckVulkanLayerRegistration(out hasOtherJSON, out thisRegistered, out otherJSONs);
|
||||
|
||||
string myJSON = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "renderdoc.json";
|
||||
string myJSON = Helpers.GetVulkanJSONPath(false);
|
||||
|
||||
string msg = "Vulkan capture happens through the API's layer mechanism. RenderDoc has detected that ";
|
||||
|
||||
@@ -938,7 +938,7 @@ namespace renderdocui.Windows.Dialogs
|
||||
{
|
||||
msg += "Register: " + myJSON + "\n";
|
||||
if (Environment.Is64BitProcess)
|
||||
msg += "Register: " + myJSON.Replace("renderdoc.json", @"x86\renderdoc.json") + "\n";
|
||||
msg += "Register: " + Helpers.GetVulkanJSONPath(true) + "\n";
|
||||
msg += "\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user