public static unsafe bool BindToService( ProcessHandle handle, SystemType impType, SystemType expType, char *contractChars, int contractLen, int startState, int index) { //convert contract to string if (contractLen == 0) { return(false); } Process process = HandleTable.GetHandle(handle.id) as Process; string contract = String.StringCTOR(contractChars, 0, contractLen); if (contract == null) { return(false); } return(Binder.BindToService(process, impType, expType, contract, startState, index)); }
public static unsafe int WaitAny(SyncHandle *handles, int handleCount, TimeSpan timeout) { WaitHandle[] waits = Thread.CurrentThread.GetSyncHandles(handleCount); for (int i = 0; i < handleCount; i++) { waits[i] = HandleTable.GetHandle(handles[i].id) as WaitHandle;; } int ret = WaitHandle.WaitAny(waits, handleCount, SchedulerTime.Now + timeout); Tracing.Log(Tracing.Debug, "SyncHandle.WaitAny(handles={0:x8}, count={1}, time=) = {2}", (UIntPtr)handles, (UIntPtr) unchecked ((uint)handleCount), (UIntPtr) unchecked ((uint)ret)); for (int i = 0; i < handleCount; i++) { waits[i] = null; } return(ret); }
public static ExternalProcessState GetState(ProcessHandle handle) { Process process = HandleTable.GetHandle(handle.id) as Process; switch (process.State) { case InternalProcessState.Unstarted: case InternalProcessState.Running: return(ExternalProcessState.Active); case InternalProcessState.Suspending: case InternalProcessState.SuspendingRecursive: case InternalProcessState.Suspended: return(ExternalProcessState.Suspended); case InternalProcessState.Stopping: case InternalProcessState.Stopped: return(ExternalProcessState.Stopped); default: // handle new missing case DebugStub.Break(); return(ExternalProcessState.Stopped); } }
internal bool IsSubtype(UIntPtr candidateHandle) { if (candidateHandle == UIntPtr.Zero) { DebugLine("RST.IsSubType {0:x8} of {1:x8} => false", __arglist(candidateHandle, handle)); return(false); } RuntimeSystemType candidate = HandleTable.GetHandle(candidateHandle) as RuntimeSystemType; if (candidate == null) { DebugLine("RST.IsSubType {0:x8} of {1:x8} => false", __arglist(candidateHandle, handle)); return(false); } RuntimeSystemType current = this; while (current != null) { if (current == candidate) { DebugLine("RST.IsSubType {0:x8} of {1:x8} => true", __arglist(candidateHandle, handle)); return(true); } current = current.parent; } DebugLine("RST.IsSubType {0:x8} of {1:x8} => false", __arglist(candidateHandle, handle)); return(false); }
public static unsafe ParameterCode SetStartupStringArrayArg( ProcessHandle handle, int index, char *args, int *argLengths, int argCount) { Process process = HandleTable.GetHandle(handle.id) as Process; // // Create a kernel String[] object populated with the argument // values passed in from userland. // String[] arguments = new String[argCount]; int offset = 0; for (int argument = 0; argument < argCount; argument++) { arguments[argument] = String.StringCTOR( args, offset, argLengths[argument]); offset += argLengths[argument]; } return((ParameterCode)process.SetStartupStringArrayArg(index, arguments)); }
/// Called from Binder which lives in a separate dll. public static SystemType Register(string name, long lowerHash, long upperHash, SystemType parent) { RuntimeSystemType parentrts = HandleTable.GetHandle(parent.id) as RuntimeSystemType; #if false DebugStub.WriteLine("SystemType.Register '{0}' hash0={1:x8} hash1={2:x8} Parent {3}", __arglist(name, lowerHash, upperHash, parent.TypeId)); Tracing.Log(Tracing.Debug, "Type '{0}' (parent={1:x8})", name, parent.id); Tracing.Log(Tracing.Debug, "hash0={0:x8} hash1={1:x8}", lowerHash.ToString(), upperHash.ToString()); #endif // false UIntPtr childHandle = parentrts.LookupChildHandle(name, lowerHash, upperHash); #if false Tracing.Log(Tracing.Debug, "result UIntPtr = {0:x8}", childHandle); #endif // false SystemType ret = new SystemType(childHandle); return(ret); }
public static void Start(ThreadHandle handle) { Thread thread = HandleTable.GetHandle(handle.id) as Thread; Tracing.Log(Tracing.Debug, "ThreadHandle.Start(id={0:x8})", handle.id); thread.Start(); }
public static PrincipalHandle GetPrincipalHandle(ProcessHandle handle) { Tracing.Log(Tracing.Debug, "ProcessHandle.GetPrincipalHandle(id={0:x8})", handle.id); Process process = HandleTable.GetHandle(handle.id) as Process; return(new PrincipalHandle(process.Principal.Val)); }
public static TimeSpan GetExecutionTime(ThreadHandle handle) { Thread thread = HandleTable.GetHandle(handle.id) as Thread; TimeSpan ts = thread.ExecutionTime; Tracing.Log(Tracing.Debug, "ThreadHandle.GetExecutionTime(id={0:x8}, out time=)", handle.id); return(ts); }
public static void SetAffinity(ThreadHandle handle, int affinity) { Tracing.Log(Tracing.Debug, "ThreadHandle.SetAffinity(id={0:x8}, affinity={1})", handle.id, (UIntPtr) unchecked (affinity)); Thread thread = HandleTable.GetHandle(handle.id) as Thread; thread.SetAffinity(affinity); }
public static bool WaitOneNoGC(SyncHandle handle) { WaitHandle waitHandle = HandleTable.GetHandle(handle.id) as WaitHandle; bool ret = waitHandle.WaitOne(SchedulerTime.MaxValue); Tracing.Log(Tracing.Debug, "SyncHandle.WaitOneNoGC(id={0:x8})", handle.id); return(ret); }
public static bool Join(ThreadHandle handle, TimeSpan timeout) { Thread thread = HandleTable.GetHandle(handle.id) as Thread; bool ret = thread.Join(timeout); Tracing.Log(Tracing.Debug, "ThreadHandle.Join(id={0:x8}, time=)", handle.id); return(ret); }
public static bool Join(ThreadHandle handle, SchedulerTime stop) { Thread thread = HandleTable.GetHandle(handle.id) as Thread; bool ret = thread.Join(stop); Tracing.Log(Tracing.Debug, "ThreadHandle.Join(id={0:x8}, stop=)", handle.id); return(ret); }
public static ThreadState GetThreadState(ThreadHandle handle) { Thread thread = HandleTable.GetHandle(handle.id) as Thread; ThreadState state = (ThreadState)thread.ThreadState; Tracing.Log(Tracing.Debug, "ThreadHandle.GetThreadState(id={0:x8}, out state={1})", handle.id, (UIntPtr) unchecked ((uint)state)); return(state); }
public static bool Join(ThreadHandle handle) { Thread thread = HandleTable.GetHandle(handle.id) as Thread; bool ret = true; thread.Join(); Tracing.Log(Tracing.Debug, "ThreadHandle.Join(id={0:x8})", handle.id); return(ret); }
public static int GetExitCode(ProcessHandle handle) { Tracing.Log(Tracing.Debug, "ProcessHandle.GetExitCode(id={0:x8})", handle.id); // // Convert the handle to a process; retrieve ExitCode. // Process process = HandleTable.GetHandle(handle.id) as Process; return(process.ExitCode); }
public static void Stop(ProcessHandle handle, int exitcode) { Tracing.Log(Tracing.Debug, "ProcessHandle.Stop(id={0:x8})", handle.id); // // Convert the handle to a process; call Stop method. // Process process = HandleTable.GetHandle(handle.id) as Process; process.Stop(exitcode); }
public static bool Resume(ProcessHandle handle, bool recursive) { Tracing.Log(Tracing.Debug, "ProcessHandle.Resume(id={0:x8})", handle.id); // // Convert the handle to a process; call Resume method. // Process process = HandleTable.GetHandle(handle.id) as Process; return(process.Resume(recursive)); }
public static void Join(ProcessHandle handle, out bool started) { Tracing.Log(Tracing.Debug, "ProcessHandle.Join(id={0:x8})", handle.id); // // Convert the handle to a process; call Join method. // Process process = HandleTable.GetHandle(handle.id) as Process; process.Join(out started); }
public static bool WaitOne(SyncHandle handle) { // // Convert the handle to a waitHandle; wait on the waitHandle. // WaitHandle waitHandle = HandleTable.GetHandle(handle.id) as WaitHandle; bool ret = waitHandle.WaitOne(SchedulerTime.MaxValue); Tracing.Log(Tracing.Debug, "SyncHandle.WaitOne(id={0:x8})", handle.id); return(ret); }
public static bool IsOwnedByCurrentThread(MutexHandle handle) { Tracing.Log(Tracing.Debug, "MutexHandle.IsOwnedByCurrentThread(id={0:x8})", handle.id); // // Convert the handle to a mutex; check the ownership of the mutex. // Mutex mutex = HandleTable.GetHandle(handle.id) as Mutex; return(mutex.IsOwnedByCurrentThread()); }
public static void Release(MutexHandle handle) { Tracing.Log(Tracing.Debug, "MutexHandle.Release(id={0:x8})", handle.id); // // Convert the handle to a mutex; release the mutex. // Mutex mutex = HandleTable.GetHandle(handle.id) as Mutex; mutex.ReleaseMutex(); }
public static bool Start(ProcessHandle handle) { Tracing.Log(Tracing.Debug, "ProcessHandle.Start(id={0:x8})", handle.id); // // Convert the handle to a process; call Start method. // Process process = HandleTable.GetHandle(handle.id) as Process; return(process.Start()); }
public static bool Set(ManualResetEventHandle handle) { // // Convert the handle to a manual-reset event; set the event. // ManualResetEvent mre = HandleTable.GetHandle(handle.id) as ManualResetEvent; bool ret = mre.Set(); Tracing.Log(Tracing.Debug, "ManualResetEventHandle.Set(id={0:x8})", handle.id); return(ret); }
bool Write32(PciPortHandle handle, int offset, uint value) { if (handle.id != UIntPtr.Zero) { PciPort p = HandleTable.GetHandle(handle.id) as PciPort; p.Write32(offset, value); return(true); } else { return(false); } }
public static bool Set(AutoResetEventHandle handle) { // // Convert the handle to an auto-reset event; set the event. // AutoResetEvent are = HandleTable.GetHandle(handle.id) as AutoResetEvent; bool ret = are.Set(); Tracing.Log(Tracing.Debug, "AutoResetEventHandle.Set(id={0:x8})", handle.id); return(ret); }
bool Read16Impl(PciPortHandle handle, int offset, ushort *value) { if (handle.id != UIntPtr.Zero) { PciPort p = HandleTable.GetHandle(handle.id) as PciPort; * value = p.Read16(offset); return(true); } else { *value = 0; return(false); } }
public static void Pulse(InterruptHandle handle) { if (handle.id == UIntPtr.Zero) { Tracing.Log(Tracing.Error, "InterruptHandle.Wait(id={0:x8}) on bad handle", handle.id); return; } IoIrq irq = HandleTable.GetHandle(handle.id) as IoIrq; irq.Pulse(); Tracing.Log(Tracing.Debug, "InterruptHandle.Pulse(id={0:x8})", handle.id); }
public static bool Join(ProcessHandle handle, SchedulerTime stop, out bool started) { Tracing.Log(Tracing.Debug, "ProcessHandle.Join(id={0:x8})", handle.id); // // Convert the handle to a process; call Join method. // Process process = HandleTable.GetHandle(handle.id) as Process; bool ret = process.Join(stop, out started); return(ret); }
public static unsafe bool SetStartupEndpoint(ProcessHandle handle, int index, SharedHeapService.Allocation *endpoint) { Tracing.Log(Tracing.Debug, "ProcessHandle.SetStartupEndpoint(id={0:x8}, ndx={1}, ep={2:x8})", handle.id, (UIntPtr)index, (UIntPtr)endpoint); // // Convert the handle to a process; set the endpoint. // SharedHeap.Allocation *ep = (SharedHeap.Allocation *)endpoint; Process process = HandleTable.GetHandle(handle.id) as Process; return(process.SetEndpoint(index, ref ep)); }