public static BigInteger CreateIoCompletionPort(BigInteger handle, BigInteger port, BigInteger key, int concurrency) { var res = _CreateIoCompletionPort((IntPtr)(long)handle, (IntPtr)(long)port, (UIntPtr)(ulong)key, (uint)concurrency); if (res == IntPtr.Zero) { throw PythonNT.GetLastWin32Error(); } return(res.ToInt64()); }
public static BigInteger CreateNamedPipe([NotNone] string name, int open_mode, int pipe_mode, int max_instances, int out_buffer_size, int in_buffer_size, int default_timeout, int security_attributes) { if (security_attributes != 0) { throw new NotImplementedException(); } var handle = CreateNamedPipePI(name, (uint)open_mode, (uint)pipe_mode, (uint)max_instances, (uint)out_buffer_size, (uint)in_buffer_size, (uint)default_timeout, IntPtr.Zero); if (handle == new IntPtr(-1)) { throw PythonNT.GetLastWin32Error(); } return((long)handle); }
public static BigInteger CreateFile([NotNone] string file_name, int desired_access, int share_mode, int security_attributes, int creation_disposition, int flags_and_attributes, BigInteger template_file) { if (security_attributes != 0) { throw new NotImplementedException(); } if (template_file != 0) { throw new NotImplementedException(); } var handle = CreateFile(file_name, desired_access, share_mode, IntPtr.Zero, creation_disposition, flags_and_attributes, IntPtr.Zero); if (handle == new IntPtr(-1)) { throw PythonNT.GetLastWin32Error(); } return((long)handle); }
public static PythonTuple CreatePipe(object?pipe_attrs, int size) { SECURITY_ATTRIBUTES pSecA = new SECURITY_ATTRIBUTES(); pSecA.nLength = Marshal.SizeOf(pSecA); if (pipe_attrs != null) { /* If pSec passed in from Python is not NULL * there needs to be some conversion done here...*/ throw new NotImplementedException(); } var result = CreatePipePI(out IntPtr hReadPipe, out IntPtr hWritePipe, ref pSecA, (uint)size); if (!result) { throw PythonNT.GetLastWin32Error(); } return(PythonTuple.MakeTuple((BigInteger)(long)hReadPipe, (BigInteger)(long)hWritePipe)); }
public static object?ConnectNamedPipe(BigInteger handle, bool overlapped = false) { if (overlapped) { throw new NotImplementedException(); } if (overlapped) { throw new NotImplementedException(); } else { var result = ConnectNamedPipe((IntPtr)(long)handle, IntPtr.Zero); if (!result) { throw PythonNT.GetLastWin32Error(); } return(null); } }
public static object RAND_pseudo_bytes(int num) => PythonTuple.MakeTuple(PythonNT.urandom(num), true);
public static int RAND_status() => 1; // always ready public static object RAND_bytes(int num) => PythonNT.urandom(num);
public static PythonTuple CreateProcess( CodeContext context, string?application_name, string?command_line, object?proc_attrs /*subprocess.py passes None*/, object?thread_attrs /*subprocess.py passes None*/, int?inherit_handles, uint?creation_flags, object?env_mapping, string?current_directory, object?startup_info /* subprocess.py passes STARTUPINFO*/) { PythonOps.TryGetBoundAttr(context, startup_info, "dwFlags", out object?dwFlags); //public Int32 dwFlags; PythonOps.TryGetBoundAttr(context, startup_info, "hStdInput", out object?hStdInput); //public IntPtr hStdInput; PythonOps.TryGetBoundAttr(context, startup_info, "hStdOutput", out object?hStdOutput); //public IntPtr hStdOutput; PythonOps.TryGetBoundAttr(context, startup_info, "hStdError", out object?hStdError); //public IntPtr hStdError; PythonOps.TryGetBoundAttr(context, startup_info, "wShowWindow", out object?wShowWindow); //Int16 wShowWindow; int dwFlagsInt32 = dwFlags != null?Converter.ConvertToInt32(dwFlags) : 0; IntPtr hStdInputIntPtr = hStdInput != null ? new IntPtr(Converter.ConvertToInt32(hStdInput)) : IntPtr.Zero; IntPtr hStdOutputIntPtr = hStdOutput != null ? new IntPtr(Converter.ConvertToInt32(hStdOutput)) : IntPtr.Zero; IntPtr hStdErrorIntPtr = hStdError != null ? new IntPtr(Converter.ConvertToInt32(hStdError)) : IntPtr.Zero; short wShowWindowInt16 = wShowWindow != null?Converter.ConvertToInt16(wShowWindow) : (short)0; STARTUPINFO startupInfo = new STARTUPINFO { dwFlags = dwFlagsInt32, hStdInput = hStdInputIntPtr, hStdOutput = hStdOutputIntPtr, hStdError = hStdErrorIntPtr, wShowWindow = wShowWindowInt16 }; // No special security SECURITY_ATTRIBUTES pSecSA = new SECURITY_ATTRIBUTES(); pSecSA.nLength = Marshal.SizeOf(pSecSA); SECURITY_ATTRIBUTES tSecSA = new SECURITY_ATTRIBUTES(); tSecSA.nLength = Marshal.SizeOf(tSecSA); if (proc_attrs != null) { /* If pSec paseed in from Python is not NULL * there needs to be some conversion done here...*/ } if (thread_attrs != null) { /* If tSec paseed in from Python is not NULL * there needs to be some conversion done here...*/ } // If needed convert lpEnvironment Dictionary to lpEnvironmentIntPtr string?lpEnvironment = EnvironmentToNative(context, env_mapping); bool result = CreateProcessPI( string.IsNullOrEmpty(application_name) ? null : application_name /*applicationNameHelper*//*processStartInfo.FileName*/, string.IsNullOrEmpty(command_line) ? null : command_line /*commandLineArgsHelper*//*processStartInfo.Arguments*/, ref pSecSA, ref tSecSA, inherit_handles.HasValue && inherit_handles.Value > 0, creation_flags ?? 0, lpEnvironment, current_directory, ref startupInfo, out PROCESS_INFORMATION lpProcessInformation); if (!result) { throw PythonNT.GetLastWin32Error(); } IntPtr hp = lpProcessInformation.hProcess; IntPtr ht = lpProcessInformation.hThread; int pid = lpProcessInformation.dwProcessId; int tid = lpProcessInformation.dwThreadId; return(PythonTuple.MakeTuple((BigInteger)(long)hp, (BigInteger)(long)ht, pid, tid));