//Release the device handle counter. Must be called for every GetReaderHandle to prevent resource leak. public static void ReleaseReaderHandle(DPUruNet.Reader reader) { BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; FieldInfo field = reader.GetType().GetField("m_handle", flags); System.Runtime.InteropServices.SafeHandle privateHandle = (System.Runtime.InteropServices.SafeHandle)field.GetValue(reader); if (privateHandle != null && !privateHandle.IsInvalid && !privateHandle.IsClosed) { privateHandle.DangerousRelease(); //decrement the device handle counter so the reader can be freed } }
protected override void DoExecute(IScriptExecutionEnvironment environment) { try { using (ServiceController serviceController = new ServiceController(serviceName)) { // this should throw an exception if the service does not exist System.Runtime.InteropServices.SafeHandle serviceHandle = serviceController.ServiceHandle; environment.SetConfigSetting(configurationSetting, "true"); environment.LogMessage("Windows service '{0}' exists.", serviceName); } } catch (InvalidOperationException) { environment.SetConfigSetting(configurationSetting, "false"); environment.LogMessage( "Windows service '{0}' does not exist.", serviceName); } }
protected override void DoExecute(ITaskContext context) { try { using (ServiceController serviceController = new ServiceController(serviceName, machineName)) { // this should throw an exception if the service does not exist System.Runtime.InteropServices.SafeHandle serviceHandle = serviceController.ServiceHandle; context.Properties.Set(configurationSetting, "true"); context.WriteInfo("Windows service '{0}:{1}' exists.", machineName, serviceName); } } catch (InvalidOperationException e) { context.Properties.Set(configurationSetting, false); context.WriteInfo( "Windows service '{0}' does not exist.{1}", serviceName, e.Message); } }
//Must be called to get device handle to control the LEDs (this must be coupled with a ReleaseReaderHandle) public static IntPtr GetReaderHandle(DPUruNet.Reader reader) { //We must use reflection here to get the private device handle BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; FieldInfo field = reader.GetType().GetField("m_handle", flags); System.Runtime.InteropServices.SafeHandle privateHandle = (System.Runtime.InteropServices.SafeHandle)field.GetValue(reader); Boolean bSuccess = false; if (privateHandle != null) { privateHandle.DangerousAddRef(ref bSuccess); //increment the reference counter for the reader\device handle } if (bSuccess) { return(privateHandle.DangerousGetHandle()); //return the handle to the caller } else { return(IntPtr.Zero); } }
public static System.Threading.ThreadPoolBoundHandle BindHandle(System.Runtime.InteropServices.SafeHandle handle) { return(default(System.Threading.ThreadPoolBoundHandle)); }
public static System.Windows.Input.Cursor Create(System.Runtime.InteropServices.SafeHandle cursorHandle) { return(default(System.Windows.Input.Cursor)); }
public static bool BindHandle(System.Runtime.InteropServices.SafeHandle osHandle) { throw null; }
public SafeNCryptKeyHandle(System.IntPtr handle, System.Runtime.InteropServices.SafeHandle parentHandle) { }
/// <summary> /// Gets lockdown policy as applied to a file. /// </summary> /// <remarks>Always return SystemEnforcementMode.None in CSS (trusted)</remarks> public static SystemEnforcementMode GetLockdownPolicy(string path, System.Runtime.InteropServices.SafeHandle handle) { return(SystemEnforcementMode.None); }
public static bool BindHandle(System.Runtime.InteropServices.SafeHandle osHandle) { return(default(bool)); }
protected SafeNCryptHandle(IntPtr handle, System.Runtime.InteropServices.SafeHandle parentHandle) : base(false) { throw new NotImplementedException(); }
protected virtual new void Persist(System.Runtime.InteropServices.SafeHandle handle, AccessControlSections includeSections) { }
protected sealed override void Persist(System.Runtime.InteropServices.SafeHandle handle, AccessControlSections includeSections) { }
protected void Persist(System.Runtime.InteropServices.SafeHandle handle, AccessControlSections includeSections, Object exceptionContext) { }
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, System.Runtime.InteropServices.SafeHandle handle, AccessControlSections includeSections) : base(default(bool)) { Contract.Ensures(false); }
protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, System.Runtime.InteropServices.SafeHandle handle, AccessControlSections includeSections, System.Security.AccessControl.NativeObjectSecurity.ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext) : base(default(bool)) { Contract.Ensures(false); }
public static bool BindHandle(System.Runtime.InteropServices.SafeHandle osHandle) => throw new NotImplementedException();
[System.Runtime.InteropServices.DllImport("crypt32.dll")][System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.PreserveSig)] public static extern bool CryptUnprotectMemory(System.Runtime.InteropServices.SafeHandle pData, uint cbData, uint dwFlags);
public static System.Threading.ThreadPoolBoundHandle BindHandle(System.Runtime.InteropServices.SafeHandle handle) { throw new PlatformNotSupportedException(); }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public static void AssertSafeHandleIsValid(System.Runtime.InteropServices.SafeHandle safeHandle) { }
protected override void UpdateUnmanagedPropertyState(System.Runtime.InteropServices.SafeHandle unmanagedEffect) { }
protected static void InitializeBitmapEffect(System.Runtime.InteropServices.SafeHandle outerObject, System.Runtime.InteropServices.SafeHandle innerObject) { }
protected SafeNCryptHandle(System.IntPtr handle, System.Runtime.InteropServices.SafeHandle parentHandle) : base(default(System.IntPtr), default(bool)) { }
protected static void SetValue(System.Runtime.InteropServices.SafeHandle effect, string propertyName, Object value) { }
protected internal void Persist(System.Runtime.InteropServices.SafeHandle handle) { }
protected abstract void UpdateUnmanagedPropertyState(System.Runtime.InteropServices.SafeHandle unmanagedEffect);
public static System.Threading.ThreadPoolBoundHandle BindHandle(System.Runtime.InteropServices.SafeHandle handle) { throw null; }
public static System.IntPtr SafeHandleGetHandle(System.Runtime.InteropServices.SafeHandle safeHandle, bool addRef) { throw null; }