跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

提交记录
修改scripts/guest-os/windows-host-enrollment.ps1+13 −1看文件
@@ -19,6 +19,7 @@ public static class Native {
1919 [DllImport("kernel32.dll",SetLastError=true)] public static extern bool GetNamedPipeServerProcessId(SafePipeHandle pipe,out uint pid);
2020 [DllImport("kernel32.dll",SetLastError=true)] static extern bool GetProcessTimes(IntPtr process,out FileTime created,out FileTime exited,out FileTime kernel,out FileTime user);
2121 [DllImport("kernel32.dll",CharSet=CharSet.Unicode,ExactSpelling=true,SetLastError=true)] static extern bool QueryFullProcessImageNameW(IntPtr process,uint flags,StringBuilder image,ref uint size);
22新增: [DllImport("kernel32.dll",CharSet=CharSet.Unicode,ExactSpelling=true,SetLastError=true)] static extern uint GetLongPathNameW(string path,StringBuilder expanded,uint capacity);
2223 [DllImport("advapi32.dll",SetLastError=true)] static extern bool OpenProcessToken(IntPtr process,uint access,out IntPtr token);
2324 [DllImport("advapi32.dll",SetLastError=true)] static extern bool GetTokenInformation(IntPtr token,int kind,IntPtr data,uint bytes,out uint needed);
2425 [DllImport("ntdll.dll")] static extern int NtQueryInformationProcess(IntPtr process,int kind,out Basic basic,uint bytes,out uint needed);
@@ -30,6 +31,17 @@ public static class Native {
3031 var p=OpenProcess(0x1000,false,pid);if(p==IntPtr.Zero)throw new InvalidOperationException("enrollment_peer_invalid");
3132 try {var value=new StringBuilder(32768);uint n=(uint)value.Capacity;if(!QueryFullProcessImageNameW(p,0,value,ref n))throw new InvalidOperationException("enrollment_peer_invalid");return value.ToString();}finally{CloseHandle(p);}
3233 }
34新增: static string LongPath(string path) {
35新增: var expanded=new StringBuilder(32768);
36新增: uint n=GetLongPathNameW(path,expanded,(uint)expanded.Capacity);
37新增: if(n==0||n>=expanded.Capacity)throw new InvalidOperationException("enrollment_image_path_unavailable");
38新增: return expanded.ToString();
39新增: }
40新增: public static bool SameImagePath(string actual,string expected) {
41新增: if(string.Equals(actual,expected,StringComparison.OrdinalIgnoreCase))return true;
42新增: // The kernel may report an 8.3 path for a process started by a long path.
43新增: return string.Equals(LongPath(actual),LongPath(expected),StringComparison.OrdinalIgnoreCase);
44新增: }
3345 public static uint Parent(uint pid) {
3446 var p=OpenProcess(0x1000,false,pid);if(p==IntPtr.Zero)throw new InvalidOperationException("enrollment_peer_invalid");
3547 try {Basic value;uint n;if(NtQueryInformationProcess(p,0,out value,(uint)Marshal.SizeOf(typeof(Basic)),out n)!=0)throw new InvalidOperationException("enrollment_peer_invalid");return checked((uint)value.Parent.ToInt64());}finally{CloseHandle(p);}
@@ -49,7 +61,7 @@ function Assert-CageHostEnrollmentPeer($Context,$Stream) {
4961 [uint32]$serverPID=0
5062 if(![Cage.HostEnrollment.Native]::GetNamedPipeServerProcessId($Stream.SafePipeHandle,[ref]$serverPID) -or $serverPID -ne $Context.WorkerPID){throw 'The original host enrollment peer could not be verified.'}
5163 if([Cage.HostEnrollment.Native]::Started($serverPID) -ne [long]$Context.WorkerStarted -or
52删除: [Cage.HostEnrollment.Native]::Image($serverPID) -ine $Context.WorkerExe -or
64新增: ![Cage.HostEnrollment.Native]::SameImagePath([Cage.HostEnrollment.Native]::Image($serverPID),$Context.WorkerExe) -or
5365 [Cage.HostEnrollment.Native]::UserSID($serverPID) -cne $Context.HostSID -or
5466 [Cage.HostEnrollment.Native]::Parent($serverPID) -ne $Context.OwnerPID -or
5567 [Cage.HostEnrollment.Native]::Started([uint32]$Context.OwnerPID) -ne [long]$Context.OwnerStarted -or