[DllImport("ntdll.dll")]
public static extern int NtOpenSymbolicLinkObject(
out SafeFileHandle LinkHandle,
uint DesiredAccess,
ref OBJECT_ATTRIBUTES ObjectAttributes);
Do you know one? Please contribute it!
Please add some!
static string GetSymbolicLinkTarget(string name)
{
SafeFileHandle h;
var attr = new OBJECT_ATTRIBUTES(name, 0);
var st = Win32.NtOpenSymbolicLinkObject(
out h, 0x80000000/*GENERIC_READ*/, ref attr);
if (st < 0) return null;
int len;
var buf = new UNICODE_STRING(new string(' ', 512));
st = Win32.NtQuerySymbolicLinkObject(h, ref buf, out len);
h.Dispose();
if (st < 0) return null;
return buf.ToString();
}