public static SNRESULT GetConnectStatus(int target, out ConnectStatus status, out string usage) { SNRESULT snresult = Is32Bit() ? GetConnectStatusX86(target, out uint num, out IntPtr ptr) : GetConnectStatusX64(target, out num, out ptr); status = (ConnectStatus)num; usage = Utf8ToString(ptr, uint.MaxValue); return(snresult); }
public static SNRESULT GetConnectionInfo(int target, out TCPIPConnectProperties connectProperties) { connectProperties = null; ScopedGlobalHeapPtr ptr = new ScopedGlobalHeapPtr(Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TCPIPConnectProperties)))); SNRESULT res = Is32Bit() ? GetConnectionInfoX86(target, ptr.Get()) : GetConnectionInfoX64(target, ptr.Get()); if (SUCCEEDED(res)) { connectProperties = new TCPIPConnectProperties(); Marshal.PtrToStructure(ptr.Get(), connectProperties); } return(res); }
public static SNRESULT GetTargetInfo(ref TargetInfo targetInfo) { TargetInfoPriv targetInfoPriv = new TargetInfoPriv { Flags = targetInfo.Flags, Target = targetInfo.Target }; SNRESULT res = Is32Bit() ? GetTargetInfoX86(ref targetInfoPriv) : GetTargetInfoX64(ref targetInfoPriv); if (!FAILED(res)) { targetInfo.Flags = targetInfoPriv.Flags; targetInfo.Target = targetInfoPriv.Target; targetInfo.Name = Utf8ToString(targetInfoPriv.Name, uint.MaxValue); targetInfo.Type = Utf8ToString(targetInfoPriv.Type, uint.MaxValue); targetInfo.Info = Utf8ToString(targetInfoPriv.Info, uint.MaxValue); targetInfo.HomeDir = Utf8ToString(targetInfoPriv.HomeDir, uint.MaxValue); targetInfo.FSDir = Utf8ToString(targetInfoPriv.FSDir, uint.MaxValue); targetInfo.Boot = targetInfoPriv.Boot; } return(res); }
public static SNRESULT GetProcessList(int target, out uint[] processIDs) { processIDs = null; uint count = 0; SNRESULT res = Is32Bit() ? GetProcessListX86(target, ref count, IntPtr.Zero) : GetProcessListX64(target, ref count, IntPtr.Zero); if (!FAILED(res)) { ScopedGlobalHeapPtr ptr = new ScopedGlobalHeapPtr(Marshal.AllocHGlobal((int)(4 * count))); res = Is32Bit() ? GetProcessListX86(target, ref count, ptr.Get()) : GetProcessListX64(target, ref count, ptr.Get()); if (FAILED(res)) { return(res); } IntPtr unmanagedBuf = ptr.Get(); processIDs = new uint[count]; for (uint i = 0; i < count; i++) { unmanagedBuf = ReadDataFromUnmanagedIncPtr <uint>(unmanagedBuf, ref processIDs[i]); } } return(res); }
public static bool SUCCEEDED(SNRESULT res) { return(res >= SNRESULT.SN_S_OK); }
public static bool FAILED(SNRESULT res) { return(!SUCCEEDED(res)); }