Exemple #1
0
        //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);
     }
 }
Exemple #4
0
        //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)
 {
 }
Exemple #9
0
 /// <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);
 }
Exemple #10
0
 public static bool BindHandle(System.Runtime.InteropServices.SafeHandle osHandle)
 {
     return(default(bool));
 }
Exemple #11
0
 protected SafeNCryptHandle(IntPtr handle, System.Runtime.InteropServices.SafeHandle parentHandle)
     : base(false)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 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);
 }
Exemple #17
0
 public static bool BindHandle(System.Runtime.InteropServices.SafeHandle osHandle) => throw new NotImplementedException();
Exemple #18
0
 [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);
Exemple #19
0
 public static System.Threading.ThreadPoolBoundHandle BindHandle(System.Runtime.InteropServices.SafeHandle handle)
 {
     throw new PlatformNotSupportedException();
 }
Exemple #20
0
 [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)
 {
 }
Exemple #25
0
 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;
 }