fix: redact tunnel keys, preserve cached login and correct HIP handling

This commit is contained in:
Kevin Yue committed 2026-11-18 18:08:01 +08:00
1 parent 65fce7bcf0
commit 9a43880c4d
18 files changed
+412 -196

No files matched your search

+51
View File
@@ -144,6 +144,56 @@ function Set-MachineState {
} finally { $registry.Dispose() }
}
# WScript.Shell creates the link but does not expose its shell property store.
function Set-ShortcutAppId([string]$Path, [string]$AppId) {
if (-not ('GPConnectShortcutProperties' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
public static class GPConnectShortcutProperties {
[StructLayout(LayoutKind.Sequential)]
struct PropertyKey { public Guid format; public uint id; }
[StructLayout(LayoutKind.Explicit, Size = 24)]
struct StringPropVariant {
[FieldOffset(0)] public ushort type;
[FieldOffset(8)] public IntPtr text;
}
[ComImport, Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IPropertyStore {
void GetCount(out uint count);
void GetAt(uint index, out PropertyKey key);
void GetValue(ref PropertyKey key, IntPtr value);
void SetValue(ref PropertyKey key, ref StringPropVariant value);
void Commit();
}
[DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
static extern void SHGetPropertyStoreFromParsingName(string path, IntPtr context, uint flags,
ref Guid iid, [MarshalAs(UnmanagedType.Interface)] out IPropertyStore store);
public static void SetAppId(string path, string appId) {
Guid iid = typeof(IPropertyStore).GUID;
IPropertyStore store;
SHGetPropertyStoreFromParsingName(path, IntPtr.Zero, 2 /* GPS_READWRITE */, ref iid, out store);
var key = new PropertyKey { format = new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), id = 5 };
var value = new StringPropVariant { type = 31 /* VT_LPWSTR */, text = Marshal.StringToCoTaskMemUni(appId) };
try {
store.SetValue(ref key, ref value);
store.Commit();
} finally {
Marshal.FreeCoTaskMem(value.text);
Marshal.ReleaseComObject(store);
}
}
}
'@
}
[GPConnectShortcutProperties]::SetAppId($Path, $AppId)
}
function Set-InstallationMetadata([string]$InstalledVersion) {
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut($shortcutPath)
@@ -152,6 +202,7 @@ function Set-InstallationMetadata([string]$InstalledVersion) {
$shortcut.Description = 'A GUI client for GlobalProtect VPN'
$shortcut.IconLocation = (Join-Path $destination 'gpgui.exe') + ',0'
$shortcut.Save()
Set-ShortcutAppId $shortcutPath 'com.yuezk.gpgui'
if (Test-Path -LiteralPath (Join-Path $destination 'uninstall.exe')) {
New-Item -Path $uninstallKey -Force | Out-Null
$values = @{