private KernelResult ManageNamedPort(long nameAddress, int maxSessions, out int handle) { handle = 0; if (!KernelTransfer.UserToKernelString(_system, nameAddress, 12, out string name)) { return(KernelResult.UserCopyFailed); } if (maxSessions < 0 || name.Length > 11) { return(KernelResult.MaximumExceeded); } if (maxSessions == 0) { return(KClientPort.RemoveName(_system, name)); } KPort port = new KPort(_system); KProcess currentProcess = _system.Scheduler.GetCurrentProcess(); KernelResult result = currentProcess.HandleTable.GenerateHandle(port.ServerPort, out handle); if (result != KernelResult.Success) { return(result); } port.Initialize(maxSessions, false, 0); result = port.SetName(name); if (result != KernelResult.Success) { currentProcess.HandleTable.CloseHandle(handle); } return(result); }
private KernelResult ManageNamedPort(long NameAddress, int MaxSessions, out int Handle) { Handle = 0; if (!KernelTransfer.UserToKernelString(System, NameAddress, 12, out string Name)) { return(KernelResult.UserCopyFailed); } if (MaxSessions < 0 || Name.Length > 11) { return(KernelResult.MaximumExceeded); } if (MaxSessions == 0) { return(KClientPort.RemoveName(System, Name)); } KPort Port = new KPort(System); KProcess CurrentProcess = System.Scheduler.GetCurrentProcess(); KernelResult Result = CurrentProcess.HandleTable.GenerateHandle(Port.ServerPort, out Handle); if (Result != KernelResult.Success) { return(Result); } Port.Initialize(MaxSessions, false, 0); Result = Port.SetName(Name); if (Result != KernelResult.Success) { CurrentProcess.HandleTable.CloseHandle(Handle); } return(Result); }
private KernelResult CreatePort( int maxSessions, bool isLight, long nameAddress, out int serverPortHandle, out int clientPortHandle) { serverPortHandle = clientPortHandle = 0; if (maxSessions < 1) { return(KernelResult.MaximumExceeded); } KPort port = new KPort(_system); port.Initialize(maxSessions, isLight, nameAddress); KProcess currentProcess = _system.Scheduler.GetCurrentProcess(); KernelResult result = currentProcess.HandleTable.GenerateHandle(port.ClientPort, out clientPortHandle); if (result != KernelResult.Success) { return(result); } result = currentProcess.HandleTable.GenerateHandle(port.ServerPort, out serverPortHandle); if (result != KernelResult.Success) { currentProcess.HandleTable.CloseHandle(clientPortHandle); } return(result); }
private KernelResult CreatePort( int MaxSessions, bool IsLight, long NameAddress, out int ServerPortHandle, out int ClientPortHandle) { ServerPortHandle = ClientPortHandle = 0; if (MaxSessions < 1) { return(KernelResult.MaximumExceeded); } KPort Port = new KPort(System); Port.Initialize(MaxSessions, IsLight, NameAddress); KProcess CurrentProcess = System.Scheduler.GetCurrentProcess(); KernelResult Result = CurrentProcess.HandleTable.GenerateHandle(Port.ClientPort, out ClientPortHandle); if (Result != KernelResult.Success) { return(Result); } Result = CurrentProcess.HandleTable.GenerateHandle(Port.ServerPort, out ServerPortHandle); if (Result != KernelResult.Success) { CurrentProcess.HandleTable.CloseHandle(ClientPortHandle); } return(Result); }