Exemple #1
0
 public static void AdjustPrivileges(this SafeHTOKEN hObj, SafeAllocatedMemoryHandle privileges)
 {
     if (privileges == null || privileges.IsInvalid)
     {
         return;
     }
     if (!AdjustTokenPrivileges(hObj, false, privileges))
     {
         throw new Win32Exception();
     }
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafeMoveableHGlobalHandle"/> class from a <see cref="SafeAllocatedMemoryHandle"/>
 /// instance, copying all the memory.
 /// </summary>
 /// <param name="source">The source memory block.</param>
 public SafeMoveableHGlobalHandle(SafeAllocatedMemoryHandle source) : base(source)
 {
 }
Exemple #3
0
 /// <summary>Initializes a new instance of the <see cref="AmsiStream"/> class.</summary>
 /// <param name="mem">The memory allocator used to create and extend the native memory.</param>
 /// <param name="writable">if set to <see langword="true"/>, the stream is read-write; if <see langword="false"/>, it is read-only.</param>
 public AmsiStream(SafeAllocatedMemoryHandle mem, bool writable) : this(mem.GetBytes(), writable)
 {
 }