diff --git a/1.x/trunk/ProcessHacker.Common/BaseConverter.cs b/1.x/trunk/ProcessHacker.Common/BaseConverter.cs index 9d5dd91a9..6f3708cba 100644 --- a/1.x/trunk/ProcessHacker.Common/BaseConverter.cs +++ b/1.x/trunk/ProcessHacker.Common/BaseConverter.cs @@ -30,7 +30,7 @@ namespace ProcessHacker.Common /// public static class BaseConverter { - private static readonly int[] _reverseChars = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + private static int[] _reverseChars = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 52, 53, 54, 55, 56, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -74,7 +74,7 @@ public static decimal ToNumber(string number, int b) if (b > 70) return 0; - if (string.IsNullOrEmpty(number)) + if (number == "") return 0; bool negative = number[0] == '-'; @@ -95,8 +95,8 @@ public static decimal ToNumber(string number, int b) if (negative) return -result; - - return result; + else + return result; } /// @@ -118,11 +118,11 @@ public static decimal ToNumberParse(string number) /// public static decimal ToNumberParse(string number, bool allowNonStandardExts) { - if (string.IsNullOrEmpty(number)) + if (number == "") return 0; bool negative = number[0] == '-'; - decimal result; + decimal result = 0; if (negative) number = number.Substring(1); @@ -169,8 +169,8 @@ public static decimal ToNumberParse(string number, bool allowNonStandardExts) if (negative) return -result; - - return result; + else + return result; } } } diff --git a/1.x/trunk/ProcessHacker.Common/ByteStreamReader.cs b/1.x/trunk/ProcessHacker.Common/ByteStreamReader.cs index d838b59ae..37026970a 100644 --- a/1.x/trunk/ProcessHacker.Common/ByteStreamReader.cs +++ b/1.x/trunk/ProcessHacker.Common/ByteStreamReader.cs @@ -21,13 +21,15 @@ */ using System; +using System.Collections.Generic; using System.IO; +using System.Text; namespace ProcessHacker.Common { public sealed class ByteStreamReader : Stream { - private readonly byte[] _data; + private byte[] _data; private long _position; public ByteStreamReader(byte[] data) diff --git a/1.x/trunk/ProcessHacker.Common/DeltaManager.cs b/1.x/trunk/ProcessHacker.Common/DeltaManager.cs index 0545e781b..c5d38f54a 100644 --- a/1.x/trunk/ProcessHacker.Common/DeltaManager.cs +++ b/1.x/trunk/ProcessHacker.Common/DeltaManager.cs @@ -20,6 +20,8 @@ * along with Process Hacker. If not, see . */ +using System.Collections.Generic; + namespace ProcessHacker.Common { /// @@ -36,10 +38,10 @@ public interface ISubtractor public static class Subtractor { - private static readonly Int64Subtractor _int64Subtractor = new Int64Subtractor(); - private static readonly Int32Subtractor _int32Subtractor = new Int32Subtractor(); - private static readonly DoubleSubtractor _doubleSubtractor = new DoubleSubtractor(); - private static readonly FloatSubtractor _floatSubtractor = new FloatSubtractor(); + private static Int64Subtractor _int64Subtractor = new Int64Subtractor(); + private static Int32Subtractor _int32Subtractor = new Int32Subtractor(); + private static DoubleSubtractor _doubleSubtractor = new DoubleSubtractor(); + private static FloatSubtractor _floatSubtractor = new FloatSubtractor(); public static Int64Subtractor Int64Subtractor { @@ -115,7 +117,7 @@ public interface IDeltaValue public struct DeltaValue : IDeltaValue { - private readonly ISubtractor _subtractor; + private ISubtractor _subtractor; private T _value; private T _delta; diff --git a/1.x/trunk/ProcessHacker.Common/EnumComparer.cs b/1.x/trunk/ProcessHacker.Common/EnumComparer.cs index 54fd689c8..ed0aa58a5 100644 --- a/1.x/trunk/ProcessHacker.Common/EnumComparer.cs +++ b/1.x/trunk/ProcessHacker.Common/EnumComparer.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; +using System.Text; using System.Reflection.Emit; namespace ProcessHacker.Common @@ -14,6 +15,7 @@ public sealed class EnumComparer : IEqualityComparer where TEnum : struct, IComparable, IConvertible, IFormattable { public static readonly EnumComparer Instance; + private static readonly Func _equals; private static readonly Func _getHashCode; @@ -51,11 +53,12 @@ private static void AssertTypeIsEnum() private static void AssertUnderlyingTypeIsSupported() { var underlyingType = Enum.GetUnderlyingType(typeof(TEnum)); - ICollection supportedTypes = new[] - { - typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), - typeof(int), typeof(uint), typeof(long), typeof(ulong) - }; + ICollection supportedTypes = + new[] + { + typeof (byte), typeof (sbyte), typeof (short), typeof (ushort), + typeof (int), typeof (uint), typeof (long), typeof (ulong) + }; if (supportedTypes.Contains(underlyingType)) return; @@ -75,19 +78,18 @@ private static void AssertUnderlyingTypeIsSupported() /// The generated method. private static Func generateEquals() { - var method = new DynamicMethod(typeof(TEnum).Name + "_Equals", typeof(bool), new[] - { - typeof(TEnum), typeof(TEnum) - }, typeof(TEnum), true); - + var method = new DynamicMethod(typeof(TEnum).Name + "_Equals", + typeof(bool), + new[] { typeof(TEnum), typeof(TEnum) }, + typeof(TEnum), true); var generator = method.GetILGenerator(); // Writing body generator.Emit(OpCodes.Ldarg_0); // load x to stack generator.Emit(OpCodes.Ldarg_1); // load y to stack generator.Emit(OpCodes.Ceq); // x == y generator.Emit(OpCodes.Ret); // return result - - return (Func)method.CreateDelegate(typeof(Func)); + return (Func)method.CreateDelegate + (typeof(Func)); } /// @@ -102,11 +104,10 @@ private static Func generateEquals() /// The generated method. private static Func generateGetHashCode() { - var method = new DynamicMethod(typeof(TEnum).Name + "_GetHashCode", typeof(int), new[] - { - typeof(TEnum) - }, typeof(TEnum), true); - + var method = new DynamicMethod(typeof(TEnum).Name + "_GetHashCode", + typeof(int), + new[] { typeof(TEnum) }, + typeof(TEnum), true); var generator = method.GetILGenerator(); var underlyingType = Enum.GetUnderlyingType(typeof(TEnum)); var getHashCodeMethod = underlyingType.GetMethod("GetHashCode"); @@ -117,7 +118,6 @@ private static Func generateGetHashCode() generator.Emit(OpCodes.Ldloca_S, castValue); // load *castValue to stack generator.Emit(OpCodes.Call, getHashCodeMethod); // castValue.GetHashCode() generator.Emit(OpCodes.Ret); // return result - return (Func)method.CreateDelegate(typeof(Func)); } } diff --git a/1.x/trunk/ProcessHacker.Common/FreeList.cs b/1.x/trunk/ProcessHacker.Common/FreeList.cs index 47d79f470..a1b38c686 100644 --- a/1.x/trunk/ProcessHacker.Common/FreeList.cs +++ b/1.x/trunk/ProcessHacker.Common/FreeList.cs @@ -20,6 +20,7 @@ * along with Process Hacker. If not, see . */ +using System; using System.Threading; namespace ProcessHacker.Common @@ -27,10 +28,11 @@ namespace ProcessHacker.Common /// /// Manages a list of free objects that can be re-used. /// - public class FreeList where T : IResettable, new() + public class FreeList + where T : IResettable, new() { - private readonly T[] _list; - private int _freeIndex; + private T[] _list; + private int _freeIndex = 0; public FreeList(int maximumCount) { diff --git a/1.x/trunk/ProcessHacker.Common/IResettable.cs b/1.x/trunk/ProcessHacker.Common/IResettable.cs index 85ceb09ef..2fa07049c 100644 --- a/1.x/trunk/ProcessHacker.Common/IResettable.cs +++ b/1.x/trunk/ProcessHacker.Common/IResettable.cs @@ -1,4 +1,8 @@ -namespace ProcessHacker.Common +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.Common { public interface IResettable { diff --git a/1.x/trunk/ProcessHacker.Common/IdGenerator.cs b/1.x/trunk/ProcessHacker.Common/IdGenerator.cs index bb3284725..cae77136d 100644 --- a/1.x/trunk/ProcessHacker.Common/IdGenerator.cs +++ b/1.x/trunk/ProcessHacker.Common/IdGenerator.cs @@ -30,9 +30,9 @@ namespace ProcessHacker.Common /// public class IdGenerator { - private readonly int _step = 1; - private bool _sort; - private readonly List _ids = new List(); + private int _step = 1; + private bool _sort = false; + private List _ids = new List(); private int _id; /// @@ -88,9 +88,11 @@ public int Pop() return id; } - - id = this._id; - this._id += this._step; + else + { + id = _id; + _id += _step; + } } return id; diff --git a/1.x/trunk/ProcessHacker.Common/LibC.cs b/1.x/trunk/ProcessHacker.Common/LibC.cs index 5240ecc17..f75ce1675 100644 --- a/1.x/trunk/ProcessHacker.Common/LibC.cs +++ b/1.x/trunk/ProcessHacker.Common/LibC.cs @@ -1,4 +1,8 @@ -namespace ProcessHacker.Common +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.Common { public static class LibC { diff --git a/1.x/trunk/ProcessHacker.Common/LinkedList.cs b/1.x/trunk/ProcessHacker.Common/LinkedList.cs index 340de4508..cb7f667f9 100644 --- a/1.x/trunk/ProcessHacker.Common/LinkedList.cs +++ b/1.x/trunk/ProcessHacker.Common/LinkedList.cs @@ -1,4 +1,6 @@ -namespace ProcessHacker.Common +using System; + +namespace ProcessHacker.Common { public class LinkedListEntry { diff --git a/1.x/trunk/ProcessHacker.Common/Logging.cs b/1.x/trunk/ProcessHacker.Common/Logging.cs index 9778d8998..e2c973f84 100644 --- a/1.x/trunk/ProcessHacker.Common/Logging.cs +++ b/1.x/trunk/ProcessHacker.Common/Logging.cs @@ -22,6 +22,7 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; namespace ProcessHacker.Common { @@ -29,7 +30,7 @@ namespace ProcessHacker.Common public static class Logging { - public enum Importance + public enum Importance : int { Information = 0, Warning, @@ -39,18 +40,26 @@ public enum Importance public static event LoggingDelegate Logged; + [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] + private static extern void OutputDebugString(string OutputString); + + private static object _logLock = new object(); + [Conditional("DEBUG")] public static void Log(Importance importance, string message) { - string debugMessage = - DateTime.Now.ToString("hh:mm:ss:fff:") + - " ProcessHacker (T" + System.Threading.Thread.CurrentThread.ManagedThreadId + - "): (" + importance.ToString() + ") " + message + "\r\n\r\n" + Environment.StackTrace; + lock (_logLock) + { + string debugMessage = + DateTime.Now.ToString("hh:mm:ss:fff:") + + " ProcessHacker (T" + System.Threading.Thread.CurrentThread.ManagedThreadId + + "): (" + importance.ToString() + ") " + message + "\r\n\r\n" + Environment.StackTrace; - Debugger.Log(0, "DEBUG", debugMessage); + OutputDebugString(debugMessage); - if (Logged != null) - Logged(debugMessage); + if (Logged != null) + Logged(debugMessage); + } } [Conditional("DEBUG")] @@ -59,7 +68,7 @@ public static void Log(Exception ex) string message = ex.Message; if (ex.InnerException != null) - message += "\r\nInner exception:\r\n" + ex.InnerException; + message += "\r\nInner exception:\r\n" + ex.InnerException.ToString(); if (ex.StackTrace != null) message += "\r\n" + ex.StackTrace; diff --git a/1.x/trunk/ProcessHacker.Common/Messaging/Message.cs b/1.x/trunk/ProcessHacker.Common/Messaging/Message.cs index 8e77a91af..99616e719 100644 --- a/1.x/trunk/ProcessHacker.Common/Messaging/Message.cs +++ b/1.x/trunk/ProcessHacker.Common/Messaging/Message.cs @@ -1,15 +1,23 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Common.Messaging { public class Message { - public object Tag { get; set; } + private object _tag; + + public object Tag + { + get { return _tag; } + set { _tag = value; } + } } public class ActionMessage : Message { - private readonly Action _action; + private Action _action; public ActionMessage(Action action) { diff --git a/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueue.cs b/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueue.cs index 86f82763d..9ef8adb34 100644 --- a/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueue.cs +++ b/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueue.cs @@ -1,17 +1,18 @@ using System; using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Common.Messaging { public class MessageQueue { - private readonly Queue _queue = new Queue(); - private readonly List _listeners = new List(); + private Queue _queue = new Queue(); + private List _listeners = new List(); public MessageQueue() { // Action message listener. - this.AddListener(new MessageQueueListener(action => action.Action())); + this.AddListener(new MessageQueueListener((action) => action.Action())); } public void AddListener(MessageQueueListener listener) diff --git a/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueueListener.cs b/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueueListener.cs index 0b22b8733..b63b72ee0 100644 --- a/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueueListener.cs +++ b/1.x/trunk/ProcessHacker.Common/Messaging/MessageQueueListener.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Common.Messaging { @@ -6,8 +8,8 @@ namespace ProcessHacker.Common.Messaging public class MessageQueueListener { - private readonly MessageReceivedDelegate _callback; - private readonly Type _type; + private MessageReceivedDelegate _callback; + private Type _type; public MessageQueueListener(MessageReceivedDelegate callback, Type type) { @@ -26,12 +28,13 @@ public Type Type } } - public class MessageQueueListener : MessageQueueListener where T : Message + public class MessageQueueListener : MessageQueueListener + where T : Message { public delegate void MessageReceivedDelegate(T message); public MessageQueueListener(MessageReceivedDelegate callback) - : base(message => callback((T)message), typeof(T)) + : base((message) => callback((T)message), typeof(T)) { } } } diff --git a/1.x/trunk/ProcessHacker.Common/Objects/BaseObject.cs b/1.x/trunk/ProcessHacker.Common/Objects/BaseObject.cs index 6244dc021..2da6d5e3f 100644 --- a/1.x/trunk/ProcessHacker.Common/Objects/BaseObject.cs +++ b/1.x/trunk/ProcessHacker.Common/Objects/BaseObject.cs @@ -21,7 +21,7 @@ */ /* If enabled, the object system will keep statistics. */ -//#define ENABLE_STATISTICS +#define ENABLE_STATISTICS /* If enabled, the finalizers on objects can be enabled and disabled. * If disabled, the finalizers on objects can only be disabled. @@ -61,23 +61,23 @@ namespace ProcessHacker.Common.Objects /// the object will be freed. /// /// - public abstract class BaseObject : IRefCounted + public abstract class BaseObject : IDisposable, IRefCounted { - private const long ObjectOwned = 0x1; - private const long ObjectOwnedByGc = 0x2; - private const long ObjectDisposed = 0x4; - private const long ObjectRefCountShift = 3; - private const long ObjectRefCountMask = 0x1fffffff; - private const long ObjectRefCountIncrement = 0x8; - - private static long _createdCount; - private static long _freedCount; - private static long _disposedCount; - private static long _finalizedCount; - private static long _referencedCount; - private static long _dereferencedCount; - -#if DEBUG_ENABLE_LIVE_LIST + private const int ObjectOwned = 0x1; + private const int ObjectOwnedByGc = 0x2; + private const int ObjectDisposed = 0x4; + private const int ObjectRefCountShift = 3; + private const int ObjectRefCountMask = 0x1fffffff; + private const int ObjectRefCountIncrement = 0x8; + + private static int _createdCount = 0; + private static int _freedCount = 0; + private static int _disposedCount = 0; + private static int _finalizedCount = 0; + private static int _referencedCount = 0; + private static int _dereferencedCount = 0; + +#if DEBUG && DEBUG_ENABLE_LIVE_LIST private static System.Collections.Generic.List> _liveList = new System.Collections.Generic.List>(); #endif @@ -85,29 +85,29 @@ public abstract class BaseObject : IRefCounted /// /// Gets the number of disposable, owned objects that have been created. /// - public static long CreatedCount { get { return _createdCount; } } + public static int CreatedCount { get { return _createdCount; } } /// /// Gets the number of disposable objects that have been freed. /// - public static long FreedCount { get { return _freedCount; } } + public static int FreedCount { get { return _freedCount; } } /// /// Gets the number of disposable objects that have been Disposed with managed = true. /// - public static long DisposedCount { get { return _disposedCount; } } + public static int DisposedCount { get { return _disposedCount; } } /// /// Gets the number of disposable objects that have been Disposed with managed = false. /// - public static long FinalizedCount { get { return _finalizedCount; } } + public static int FinalizedCount { get { return _finalizedCount; } } /// /// Gets the number of times disposable objects have been referenced. /// - public static long ReferencedCount { get { return _referencedCount; } } + public static int ReferencedCount { get { return _referencedCount; } } /// /// Gets the number of times disposable objects have been dereferenced. /// - public static long DereferencedCount { get { return _dereferencedCount; } } + public static int DereferencedCount { get { return _dereferencedCount; } } -#if DEBUG_ENABLE_LIVE_LIST +#if DEBUG && DEBUG_ENABLE_LIVE_LIST public static void CleanLiveList() { var list = new System.Collections.Generic.List>(); @@ -122,17 +122,16 @@ public static void CleanLiveList() } #endif - public static T SwapRef(ref T reference, T newObj) where T : class, IRefCounted + public static T SwapRef(ref T reference, T newObj) + where T : class, IRefCounted { T oldObj; // Swap the reference. - oldObj = Interlocked.Exchange(ref reference, newObj); - + oldObj = Interlocked.Exchange(ref reference, newObj); // Reference the new object. if (newObj != null) newObj.Reference(); - // Dereference the old object. if (oldObj != null) oldObj.Dereference(); @@ -140,27 +139,27 @@ public static T SwapRef(ref T reference, T newObj) where T : class, IRefCount return oldObj; } -#if DEBUG_ENABLE_LIVE_LIST +#if DEBUG /// /// A stack trace collected when the object is created. /// private string _creationStackTrace; #endif /// - /// An UInt32 containing various fields. + /// An Int32 containing various fields. /// - private long _value; + private int _value; #if EXTENDED_FINALIZER /// /// Whether the finalizer will run. /// - private uint _finalizerRegistered = 1; + private int _finalizerRegistered = 1; #endif /// /// Initializes a disposable object. /// - protected BaseObject() + public BaseObject() : this(true) { } @@ -168,7 +167,7 @@ protected BaseObject() /// Initializes a disposable object. /// /// Whether the resource is owned. - protected BaseObject(bool owned) + public BaseObject(bool owned) { _value = ObjectOwned + ObjectOwnedByGc + ObjectRefCountIncrement; @@ -188,9 +187,11 @@ protected BaseObject(bool owned) Interlocked.Increment(ref _createdCount); #endif -#if DEBUG_ENABLE_LIVE_LIST +#if DEBUG _creationStackTrace = Environment.StackTrace; +#if DEBUG_ENABLE_LIVE_LIST _liveList.Add(new WeakReference(this)); +#endif #endif } @@ -223,8 +224,8 @@ public void Dispose() /// /// Whether to dispose managed resources. public void Dispose(bool managed) - { - long value = 0; + { + int value; if ((_value & ObjectOwned) == 0) return; @@ -315,9 +316,9 @@ public bool OwnedByGc /// This information is for debugging purposes ONLY. DO NOT /// base memory management logic upon this value. /// - public long ReferenceCount + public int ReferenceCount { - get { return (_value >> (int)ObjectRefCountShift) & ObjectRefCountMask; } + get { return (_value >> ObjectRefCountShift) & ObjectRefCountMask; } } #if EXTENDED_FINALIZER @@ -326,7 +327,7 @@ public long ReferenceCount /// private void DisableFinalizer() { - long oldFinalizerRegistered; + int oldFinalizerRegistered; oldFinalizerRegistered = Interlocked.CompareExchange(ref _finalizerRegistered, 0, 1); @@ -342,7 +343,7 @@ private void DisableFinalizer() /// protected void DisableOwnership(bool dispose) { - long value = 0; + int value; if (dispose) this.Dispose(); @@ -383,7 +384,7 @@ protected void DisableOwnership(bool dispose) /// Dereference(false). /// /// - public long Dereference() + public int Dereference() { return this.Dereference(true); } @@ -397,7 +398,7 @@ public long Dereference() /// If you are calling this method from a finalizer, set /// to false. /// - public long Dereference(bool managed) + public int Dereference(bool managed) { return this.Dereference(1, managed); } @@ -407,7 +408,7 @@ public long Dereference(bool managed) /// /// The number of times to dereference the object. /// The new reference count. - public long Dereference(long count) + public int Dereference(int count) { return this.Dereference(count, true); } @@ -418,10 +419,10 @@ public long Dereference(long count) /// The number of times to dereference the object. /// Whether to dispose managed resources. /// The new reference count. - public long Dereference(long count, bool managed) + public int Dereference(int count, bool managed) { - long value = 0; - long newRefCount = 0; + int value; + int newRefCount; // Initial parameter validation. if (count == 0) @@ -439,7 +440,7 @@ public long Dereference(long count, bool managed) // Decrease the reference count. value = Interlocked.Add(ref _value, -ObjectRefCountIncrement * count); - newRefCount = (value >> (int)ObjectRefCountShift) & ObjectRefCountMask; + newRefCount = (value >> ObjectRefCountShift) & ObjectRefCountMask; // Should not ever happen. if (newRefCount < 0) @@ -485,7 +486,7 @@ public void DereferenceDelayed() /// private void EnableFinalizer() { - long oldFinalizerRegistered; + int oldFinalizerRegistered; oldFinalizerRegistered = Interlocked.CompareExchange(ref _finalizerRegistered, 1, 0); @@ -506,7 +507,7 @@ private void EnableFinalizer() /// object) to match each call to Reference. Do not call Dispose. /// /// - public long Reference() + public int Reference() { return this.Reference(1); } @@ -516,9 +517,9 @@ public long Reference() /// /// The number of times to reference the object. /// The new reference count. - public long Reference(long count) + public int Reference(int count) { - long value; + int value; // Don't do anything if the object isn't owned. if ((_value & ObjectOwned) == 0) @@ -535,7 +536,7 @@ public long Reference(long count) value = Interlocked.Add(ref _value, ObjectRefCountIncrement * count); - return (value >> (int)ObjectRefCountShift) & ObjectRefCountMask; + return (value >> ObjectRefCountShift) & ObjectRefCountMask; } } } diff --git a/1.x/trunk/ProcessHacker.Common/Objects/DelayedReleasePool.cs b/1.x/trunk/ProcessHacker.Common/Objects/DelayedReleasePool.cs index a6c57893f..b240d38c9 100644 --- a/1.x/trunk/ProcessHacker.Common/Objects/DelayedReleasePool.cs +++ b/1.x/trunk/ProcessHacker.Common/Objects/DelayedReleasePool.cs @@ -56,8 +56,8 @@ private enum DelayedReleaseFlags /// private struct DelayedReleaseObject { - private readonly DelayedReleaseFlags _flags; - private readonly BaseObject _object; + private DelayedReleaseFlags _flags; + private BaseObject _object; public DelayedReleaseObject(DelayedReleaseFlags flags, BaseObject obj) { @@ -86,7 +86,14 @@ public BaseObject Object /// public static DelayedReleasePool CurrentPool { - get { return _currentPool ?? (_currentPool = new DelayedReleasePool()); } + get + { + if (_currentPool == null) + _currentPool = new DelayedReleasePool(); + + return _currentPool; + } + private set { _currentPool = value; } } /// @@ -97,7 +104,10 @@ private static Stack PoolStack get { // No locking needed because the stack is thread-local. - return _poolStack ?? (_poolStack = new Stack()); + if (_poolStack == null) + _poolStack = new Stack(); + + return _poolStack; } } @@ -107,9 +117,6 @@ private static Stack PoolStack /// The current delayed release pool. private static void PopPool(DelayedReleasePool pool) { - if (pool == null) - throw new ArgumentNullException("pool"); - if (_currentPool != pool) throw new OutOfOrderException( "Attempted to pop a pool when it wasn't on top of the stack. " + @@ -129,8 +136,8 @@ private static void PushPool(DelayedReleasePool pool) _currentPool = pool; } - private readonly int _creatorThreadId; - private readonly List _objects = new List(); + private int _creatorThreadId; + private List _objects = new List(); /// /// Creates a delayed release pool and sets it as the currently active pool. @@ -188,12 +195,11 @@ public void Drain() /// Whether to release managed resources. public void Drain(bool managed) { - foreach (DelayedReleaseObject obj in _objects) + foreach (var obj in _objects) { - if (obj.Flags.HasFlag(DelayedReleaseFlags.Dispose)) + if ((obj.Flags & DelayedReleaseFlags.Dispose) == DelayedReleaseFlags.Dispose) obj.Object.Dispose(); - - if (obj.Flags.HasFlag(DelayedReleaseFlags.Dereference)) + if ((obj.Flags & DelayedReleaseFlags.Dereference) == DelayedReleaseFlags.Dereference) obj.Object.Dereference(managed); } diff --git a/1.x/trunk/ProcessHacker.Common/Objects/HandleTable.cs b/1.x/trunk/ProcessHacker.Common/Objects/HandleTable.cs index f35264d16..938c7902d 100644 --- a/1.x/trunk/ProcessHacker.Common/Objects/HandleTable.cs +++ b/1.x/trunk/ProcessHacker.Common/Objects/HandleTable.cs @@ -27,8 +27,20 @@ namespace ProcessHacker.Common.Objects { public class HandleTableEntry { - public int Handle { get; internal set; } - public IRefCounted Object { get; internal set; } + private int _handle; + private IRefCounted _object; + + public int Handle + { + get { return _handle; } + internal set { _handle = value; } + } + + public IRefCounted Object + { + get { return _object; } + internal set { _object = value; } + } } /// @@ -52,9 +64,9 @@ public class HandleTable : BaseObject /// Return true to stop enumerating; otherwise return false. public delegate bool EnumerateHandleTableDelegate(int handle, TEntry entry); - private readonly IdGenerator _handleGenerator = new IdGenerator(4, 4); - private readonly FastResourceLock _lock = new FastResourceLock(); - private readonly Dictionary _handles = new Dictionary(); + private IdGenerator _handleGenerator = new IdGenerator(4, 4); + private FastResourceLock _lock = new FastResourceLock(); + private Dictionary _handles = new Dictionary(); protected override void DisposeObject(bool disposing) { @@ -306,7 +318,8 @@ public T ReferenceByHandle(int handle) /// An object. This object has been referenced and must be /// dereferenced once it is no longer needed. /// - public T ReferenceByHandle(int handle, out TEntry entry) where T : class, IRefCounted + public T ReferenceByHandle(int handle, out TEntry entry) + where T : class, IRefCounted { IRefCounted obj = this.ReferenceByHandle(handle, out entry); @@ -318,10 +331,12 @@ public T ReferenceByHandle(int handle, out TEntry entry) where T : class, IRe { return (T)obj; } - - // Wrong type. Dereference and return. - obj.Dereference(); - return null; + else + { + // Wrong type. Dereference and return. + obj.Dereference(); + return null; + } } } } diff --git a/1.x/trunk/ProcessHacker.Common/Objects/IRefCounted.cs b/1.x/trunk/ProcessHacker.Common/Objects/IRefCounted.cs index e7f10cf67..cbb37b004 100644 --- a/1.x/trunk/ProcessHacker.Common/Objects/IRefCounted.cs +++ b/1.x/trunk/ProcessHacker.Common/Objects/IRefCounted.cs @@ -8,21 +8,21 @@ public interface IRefCounted : IDisposable /// Decrements the reference count of the object. /// /// The new reference count. - long Dereference(); + int Dereference(); /// /// Decrements the reference count of the object. /// /// Whether to dispose managed resources. /// The new reference count. - long Dereference(bool managed); + int Dereference(bool managed); /// /// Decreases the reference count of the object. /// /// The number of times to dereference the object. /// The new reference count. - long Dereference(long count); + int Dereference(int count); /// /// Decreases the reference count of the object. @@ -30,7 +30,7 @@ public interface IRefCounted : IDisposable /// The number of times to dereference the object. /// Whether to dispose managed resources. /// The new reference count. - long Dereference(long count, bool managed); + int Dereference(int count, bool managed); /// /// Ensures that the reference counting system has exclusive control @@ -43,13 +43,13 @@ public interface IRefCounted : IDisposable /// Increments the reference count of the object. /// /// The new reference count. - long Reference(); + int Reference(); /// /// Increases the reference count of the object. /// /// The number of times to reference the object. /// The new reference count. - long Reference(long count); + int Reference(int count); } } diff --git a/1.x/trunk/ProcessHacker.Common/Objects/SecuredHandleTable.cs b/1.x/trunk/ProcessHacker.Common/Objects/SecuredHandleTable.cs index 9bce52099..77dd24b2c 100644 --- a/1.x/trunk/ProcessHacker.Common/Objects/SecuredHandleTable.cs +++ b/1.x/trunk/ProcessHacker.Common/Objects/SecuredHandleTable.cs @@ -27,30 +27,33 @@ namespace ProcessHacker.Common.Objects public class SecuredHandleTableEntry : HandleTableEntry { private long _grantedAccess; + public long GrantedAccess { get { return _grantedAccess; } set { _grantedAccess = value; } } - public bool AreAllAccessesGranted(TAccess access) where TAccess : struct + public bool AreAllAccessesGranted(TAccess access) + where TAccess : struct { long accessLong = Convert.ToInt64(access); if ((_grantedAccess & accessLong) == accessLong) return true; - - return false; + else + return false; } - public bool AreAnyAccessesGranted(TAccess access) where TAccess : struct + public bool AreAnyAccessesGranted(TAccess access) + where TAccess : struct { long accessLong = Convert.ToInt64(access); if ((_grantedAccess & accessLong) != 0) return true; - - return false; + else + return false; } } @@ -74,12 +77,12 @@ public class SecuredHandleTable : HandleTable /// The object to reference. /// The granted access to the object. /// The new handle. - public int Allocate(IRefCounted obj, TAccess grantedAccess) where TAccess : struct + public int Allocate(IRefCounted obj, TAccess grantedAccess) + where TAccess : struct { - TEntry entry = new TEntry - { - GrantedAccess = Convert.ToInt64(grantedAccess) - }; + TEntry entry = new TEntry(); + + entry.GrantedAccess = Convert.ToInt64(grantedAccess); return base.Allocate(obj, entry); } @@ -94,9 +97,10 @@ public int Allocate(IRefCounted obj, TAccess grantedAccess) where TAcce /// An object. This object has been referenced and must be /// dereferenced once it is no longer needed. /// - public IRefCounted ReferenceByHandle(int handle, TAccess access) where TAccess : struct + public IRefCounted ReferenceByHandle(int handle, TAccess access) + where TAccess : struct { - return this.ReferenceByHandle(handle, access, false); + return this.ReferenceByHandle(handle, access, false); } /// @@ -112,30 +116,34 @@ public IRefCounted ReferenceByHandle(int handle, TAccess access) where /// An object. This object has been referenced and must be /// dereferenced once it is no longer needed. /// - public IRefCounted ReferenceByHandle(int handle, TAccess access, bool throwOnAccessDenied) where TAccess : struct + public IRefCounted ReferenceByHandle(int handle, TAccess access, bool throwOnAccessDenied) + where TAccess : struct { TEntry entry; + IRefCounted obj; // Reference the object. - IRefCounted obj = this.ReferenceByHandle(handle, out entry); + obj = this.ReferenceByHandle(handle, out entry); if (obj == null) return null; // Check the access. - if (entry.AreAllAccessesGranted(access)) + if (entry.AreAllAccessesGranted(access)) { // OK, return the object. return obj; } - - // Access denied. Dereference the object and return. - obj.Dereference(); - - if (throwOnAccessDenied) - throw new UnauthorizedAccessException("Access denied."); - - return null; + else + { + // Access denied. Dereference the object and return. + obj.Dereference(); + + if (throwOnAccessDenied) + throw new UnauthorizedAccessException("Access denied."); + else + return null; + } } /// @@ -149,7 +157,9 @@ public IRefCounted ReferenceByHandle(int handle, TAccess access, bool t /// An object. This object has been referenced and must be /// dereferenced once it is no longer needed. /// - public T ReferenceByHandle(int handle, TAccess access) where T : class, IRefCounted where TAccess : struct + public T ReferenceByHandle(int handle, TAccess access) + where T : class, IRefCounted + where TAccess : struct { return this.ReferenceByHandle(handle, access, false); } @@ -168,9 +178,11 @@ public T ReferenceByHandle(int handle, TAccess access) where T : cla /// An object. This object has been referenced and must be /// dereferenced once it is no longer needed. /// - public T ReferenceByHandle(int handle, TAccess access, bool throwOnAccessDenied) where T : class, IRefCounted where TAccess : struct + public T ReferenceByHandle(int handle, TAccess access, bool throwOnAccessDenied) + where T : class, IRefCounted + where TAccess : struct { - IRefCounted obj = this.ReferenceByHandle(handle, access, throwOnAccessDenied); + IRefCounted obj = this.ReferenceByHandle(handle, access, throwOnAccessDenied); if (obj == null) return null; @@ -178,12 +190,13 @@ public T ReferenceByHandle(int handle, TAccess access, bool throwOnA // Check the type. if (obj is T) { - return obj as T; + return (T)obj; + } + else + { + obj.Dereference(); + return null; } - - obj.Dereference(); - - return null; } } } diff --git a/1.x/trunk/ProcessHacker.Common/ProcessHacker.Common.csproj b/1.x/trunk/ProcessHacker.Common/ProcessHacker.Common.csproj index d3c136c66..704e9fd35 100644 --- a/1.x/trunk/ProcessHacker.Common/ProcessHacker.Common.csproj +++ b/1.x/trunk/ProcessHacker.Common/ProcessHacker.Common.csproj @@ -10,7 +10,7 @@ Properties ProcessHacker.Common ProcessHacker.Common - v4.5 + v4.0 512 @@ -48,7 +48,6 @@ true AnyCPU AllRules.ruleset - false pdbonly @@ -62,7 +61,6 @@ true AnyCPU AllRules.ruleset - false @@ -117,6 +115,7 @@ + diff --git a/1.x/trunk/ProcessHacker.Common/Properties/AssemblyInfo.cs b/1.x/trunk/ProcessHacker.Common/Properties/AssemblyInfo.cs index 44018ff4a..f99cfef91 100644 --- a/1.x/trunk/ProcessHacker.Common/Properties/AssemblyInfo.cs +++ b/1.x/trunk/ProcessHacker.Common/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/1.x/trunk/ProcessHacker.Common/Settings/SettingDefaultAttribute.cs b/1.x/trunk/ProcessHacker.Common/Settings/SettingDefaultAttribute.cs index b840335dc..567b0a46a 100644 --- a/1.x/trunk/ProcessHacker.Common/Settings/SettingDefaultAttribute.cs +++ b/1.x/trunk/ProcessHacker.Common/Settings/SettingDefaultAttribute.cs @@ -30,7 +30,7 @@ namespace ProcessHacker.Common.Settings [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public class SettingDefaultAttribute : Attribute { - private readonly string _value; + private string _value; /// /// Initializes a new instance of the SettingDefaultAttribute class. diff --git a/1.x/trunk/ProcessHacker.Common/Settings/SettingsBase.cs b/1.x/trunk/ProcessHacker.Common/Settings/SettingsBase.cs index 2c2c75cbf..a4e926b5f 100644 --- a/1.x/trunk/ProcessHacker.Common/Settings/SettingsBase.cs +++ b/1.x/trunk/ProcessHacker.Common/Settings/SettingsBase.cs @@ -32,17 +32,17 @@ namespace ProcessHacker.Common.Settings /// public abstract class SettingsBase { - private readonly ISettingsStore _store; - private readonly Dictionary _settings = new Dictionary(); - private readonly Dictionary _modifiedSettings = new Dictionary(); - private readonly Dictionary _defaultsCache = new Dictionary(); - private readonly Dictionary _typeCache = new Dictionary(); + private ISettingsStore _store; + private Dictionary _settings = new Dictionary(); + private Dictionary _modifiedSettings = new Dictionary(); + private Dictionary _defaultsCache = new Dictionary(); + private Dictionary _typeCache = new Dictionary(); /// /// Creates a settings class with the specified storage provider. /// /// The storage provider. - protected SettingsBase(ISettingsStore store) + public SettingsBase(ISettingsStore store) { _store = store; } @@ -76,15 +76,14 @@ protected virtual object ConvertFromString(string value, Type valueType) { if (valueType.IsPrimitive) return Convert.ChangeType(value, valueType); - - if (valueType == typeof(string)) + else if (valueType == typeof(string)) return value; - TypeConverter converter = TypeDescriptor.GetConverter(valueType); + var converter = TypeDescriptor.GetConverter(valueType); // Since all types can convert to System.String, we also need to make sure they can // convert from System.String. - if (converter != null && (converter.CanConvertFrom(typeof(string)) && converter.CanConvertTo(typeof(string)))) + if (converter.CanConvertFrom(typeof(string)) && converter.CanConvertTo(typeof(string))) return converter.ConvertFromInvariantString(value); throw new InvalidOperationException("The setting '" + value + "' has an unsupported type."); @@ -100,15 +99,14 @@ protected virtual string ConvertToString(object value, Type valueType) { if (valueType.IsPrimitive) return (string)Convert.ChangeType(value, typeof(string)); - - if (valueType == typeof(string)) + else if (valueType == typeof(string)) return (string)value; - TypeConverter converter = TypeDescriptor.GetConverter(valueType); + var converter = TypeDescriptor.GetConverter(valueType); // Since all types can convert to System.String, we also need to make sure they can // convert from System.String. - if (converter != null && (converter.CanConvertFrom(typeof(string)) && converter.CanConvertTo(typeof(string)))) + if (converter.CanConvertFrom(typeof(string)) && converter.CanConvertTo(typeof(string))) return converter.ConvertToInvariantString(value); throw new InvalidOperationException("The setting '" + value + "' has an unsupported type."); @@ -125,15 +123,12 @@ private string GetSettingDefault(string name) { if (!_defaultsCache.ContainsKey(name)) { - PropertyInfo property = this.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public); - object[] attributes = property.GetCustomAttributes(typeof(SettingDefaultAttribute), true); + var property = this.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public); + var attributes = property.GetCustomAttributes(typeof(SettingDefaultAttribute), true); if (attributes.Length == 1) { - SettingDefaultAttribute settingDefaultAttribute = attributes[0] as SettingDefaultAttribute; - - if (settingDefaultAttribute != null) - this._defaultsCache.Add(name, settingDefaultAttribute.Value); + _defaultsCache.Add(name, (attributes[0] as SettingDefaultAttribute).Value); } else { @@ -173,6 +168,8 @@ private Type GetSettingType(string name) private object GetValue(string name) { object value; + string settingValue; + Type settingType; lock (_modifiedSettings) { @@ -186,14 +183,14 @@ private object GetValue(string name) return _settings[name]; } - string settingValue = this._store.GetValue(name); + settingValue = _store.GetValue(name); - if (string.IsNullOrEmpty(settingValue)) + if (settingValue == null) settingValue = this.GetSettingDefault(name); - if (string.IsNullOrEmpty(settingValue)) - settingValue = string.Empty; + if (settingValue == null) + settingValue = ""; - Type settingType = this.GetSettingType(name); + settingType = this.GetSettingType(name); try { @@ -253,7 +250,7 @@ public void Save() { lock (_modifiedSettings) { - foreach (KeyValuePair pair in _modifiedSettings) + foreach (var pair in _modifiedSettings) { _store.SetValue(pair.Key, this.ConvertToString(pair.Value, this.GetSettingType(pair.Key))); } diff --git a/1.x/trunk/ProcessHacker.Common/Settings/VolatileSettingsStore.cs b/1.x/trunk/ProcessHacker.Common/Settings/VolatileSettingsStore.cs index 0dda0ce3b..5ffb44f5e 100644 --- a/1.x/trunk/ProcessHacker.Common/Settings/VolatileSettingsStore.cs +++ b/1.x/trunk/ProcessHacker.Common/Settings/VolatileSettingsStore.cs @@ -1,4 +1,8 @@ -namespace ProcessHacker.Common.Settings +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.Common.Settings { public sealed class VolatileSettingsStore : ISettingsStore { diff --git a/1.x/trunk/ProcessHacker.Common/Settings/XmlFileSettingsStore.cs b/1.x/trunk/ProcessHacker.Common/Settings/XmlFileSettingsStore.cs index 54a98c8db..23795c3a6 100644 --- a/1.x/trunk/ProcessHacker.Common/Settings/XmlFileSettingsStore.cs +++ b/1.x/trunk/ProcessHacker.Common/Settings/XmlFileSettingsStore.cs @@ -20,7 +20,10 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; using System.IO; +using System.Text; using System.Xml; namespace ProcessHacker.Common.Settings @@ -34,8 +37,8 @@ public sealed class XmlFileSettingsStore : ISettingsStore private const string _settingElementName = "setting"; private const string _nameAttributeName = "name"; - private readonly string _fileName; - private readonly object _docLock = new object(); + private string _fileName; + private object _docLock = new object(); private XmlDocument _doc; private XmlNode _rootNode; @@ -80,10 +83,7 @@ public string GetValue(string name) { lock (_docLock) { - XmlNodeList nodes = _rootNode.SelectNodes(_settingElementName + "[@" + _nameAttributeName + "='" + name + "']"); - - if (nodes == null) - return null; + var nodes = _rootNode.SelectNodes(_settingElementName + "[@" + _nameAttributeName + "='" + name + "']"); if (nodes.Count == 0) return null; @@ -146,16 +146,16 @@ public void SetValue(string name, string value) { lock (_docLock) { - XmlNodeList nodes = _rootNode.SelectNodes(_settingElementName + "[@" + _nameAttributeName + "='" + name + "']"); + var nodes = _rootNode.SelectNodes(_settingElementName + "[@" + _nameAttributeName + "='" + name + "']"); - if (nodes != null && nodes.Count != 0) + if (nodes.Count != 0) { nodes[0].InnerText = value; } else { - XmlElement settingElement = _doc.CreateElement(_settingElementName); - XmlAttribute nameAttribute = _doc.CreateAttribute(_nameAttributeName); + var settingElement = _doc.CreateElement(_settingElementName); + var nameAttribute = _doc.CreateAttribute(_nameAttributeName); nameAttribute.Value = name; settingElement.Attributes.Append(nameAttribute); diff --git a/1.x/trunk/ProcessHacker.Common/String255.cs b/1.x/trunk/ProcessHacker.Common/String255.cs index b84fb6223..a62f20fb6 100644 --- a/1.x/trunk/ProcessHacker.Common/String255.cs +++ b/1.x/trunk/ProcessHacker.Common/String255.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Common { @@ -108,8 +110,8 @@ public void Append(string str) fixed (char* buffer = this.Buffer) { - foreach (char t in str) - buffer[this.Length++] = t; + for (int i = 0; i < str.Length; i++) + buffer[this.Length++] = str[i]; buffer[this.Length] = '\0'; } @@ -119,11 +121,14 @@ public int CompareTo(String255 str) { fixed (char* buffer = this.Buffer) { - int result = LibC.WMemCmp(buffer, str.Buffer, this.Length < str.Length ? this.Length : str.Length); + int result; + + result = LibC.WMemCmp(buffer, str.Buffer, this.Length < str.Length ? this.Length : str.Length); if (result == 0) return this.Length - str.Length; - return result; + else + return result; } } @@ -140,9 +145,10 @@ public override bool Equals(object other) { if (other is String255) return this.Equals((String255)other); - if (other is string) + else if (other is string) return this.Equals((string)other); - return false; + else + return false; } public bool Equals(String255 other) @@ -189,8 +195,8 @@ public int IndexOf(char c) if (ptr != null) return (int)(ptr - buffer); - - return -1; + else + return -1; } } @@ -198,9 +204,12 @@ public override int GetHashCode() { int hashCode = 0x15051505; - for (int i = 0; i < this.Length; i += 4) + fixed (char* buffer = this.Buffer) { - hashCode += hashCode ^ (hashCode << ((i % 4) * 8)); + for (int i = 0; i < this.Length; i += 4) + { + hashCode += hashCode ^ (hashCode << ((i % 4) * 8)); + } } return hashCode; diff --git a/1.x/trunk/ProcessHacker.Common/Threading/ActionSync.cs b/1.x/trunk/ProcessHacker.Common/Threading/ActionSync.cs index d0d7c018c..8c59a7599 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/ActionSync.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/ActionSync.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using System.Threading; namespace ProcessHacker.Common.Threading @@ -32,8 +34,8 @@ namespace ProcessHacker.Common.Threading public struct ActionSync { private int _value; - private readonly int _target; - private readonly Action _action; + private int _target; + private Action _action; /// /// Initializes an action-sync structure. diff --git a/1.x/trunk/ProcessHacker.Common/Threading/FairResourceLock.cs b/1.x/trunk/ProcessHacker.Common/Threading/FairResourceLock.cs index 7588a423d..75fb1ff37 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/FairResourceLock.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/FairResourceLock.cs @@ -21,11 +21,8 @@ */ #define DEFER_EVENT_CREATION - -#if DEBUG -#define ENABLE_STATISTICS -#define RIGOROUS_CHECKS -#endif +//#define ENABLE_STATISTICS +//#define RIGOROUS_CHECKS using System; using System.Runtime.InteropServices; @@ -124,18 +121,13 @@ public struct Statistics public int PeakShrdWtrsCount; } - private struct WaitBlock + private unsafe struct WaitBlock { - public static readonly int SizeOf; + public static readonly int Size = Marshal.SizeOf(typeof(WaitBlock)); public WaitBlock* Flink; public WaitBlock* Blink; public int Flags; - - static WaitBlock() - { - SizeOf = Marshal.SizeOf(typeof(WaitBlock)); - } } private enum ListPosition @@ -214,20 +206,20 @@ private static bool RemoveEntryList(WaitBlock* entry) private WaitBlock* _firstSharedWaiter; #if ENABLE_STATISTICS - private int _exclusiveWaitersCount; - private int _sharedWaitersCount; - - private int _acqExclCount; - private int _acqShrdCount; - private int _acqExclContCount; - private int _acqShrdContCount; - private int _acqExclBlkCount; - private int _acqShrdBlkCount; - private int _acqExclSlpCount; - private int _acqShrdSlpCount; - private int _insWaitBlkRetryCount; - private int _peakExclWtrsCount; - private int _peakShrdWtrsCount; + private int _exclusiveWaitersCount = 0; + private int _sharedWaitersCount = 0; + + private int _acqExclCount = 0; + private int _acqShrdCount = 0; + private int _acqExclContCount = 0; + private int _acqShrdContCount = 0; + private int _acqExclBlkCount = 0; + private int _acqShrdBlkCount = 0; + private int _acqExclSlpCount = 0; + private int _acqShrdSlpCount = 0; + private int _insWaitBlkRetryCount = 0; + private int _peakExclWtrsCount = 0; + private int _peakShrdWtrsCount = 0; #endif /// @@ -249,7 +241,7 @@ public FairResourceLock(int spinCount) _lock = new SpinLock(); _spinCount = Environment.ProcessorCount != 1 ? spinCount : 0; - _waitersListHead = (WaitBlock*)Marshal.AllocHGlobal(WaitBlock.SizeOf); + _waitersListHead = (WaitBlock*)Marshal.AllocHGlobal(WaitBlock.Size); _waitersListHead->Flink = _waitersListHead; _waitersListHead->Blink = _waitersListHead; _waitersListHead->Flags = 0; @@ -726,7 +718,7 @@ private IntPtr CreateWakeEvent() public Statistics GetStatistics() { #if ENABLE_STATISTICS - return new Statistics + return new Statistics() { AcqExcl = _acqExclCount, AcqShrd = _acqShrdCount, @@ -1134,7 +1126,7 @@ private void WakeExclusive() private void WakeShared() { WaitBlock wakeList = new WaitBlock(); - WaitBlock* wb; + WaitBlock* wb = null; wakeList.Flink = &wakeList; wakeList.Blink = &wakeList; diff --git a/1.x/trunk/ProcessHacker.Common/Threading/FastLock.cs b/1.x/trunk/ProcessHacker.Common/Threading/FastLock.cs index efc735b7f..4c51e3369 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/FastLock.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/FastLock.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Threading; namespace ProcessHacker.Common.Threading @@ -41,10 +43,13 @@ public void Acquire() } // Slow path 2 - wait on the event. + + IntPtr newEvent; + // Note: see FastEvent.cs for a more detailed explanation of this // technique. - IntPtr newEvent = Interlocked.CompareExchange(ref this._event, IntPtr.Zero, IntPtr.Zero); + newEvent = Interlocked.CompareExchange(ref _event, IntPtr.Zero, IntPtr.Zero); if (newEvent == IntPtr.Zero) { diff --git a/1.x/trunk/ProcessHacker.Common/Threading/FastMutex.cs b/1.x/trunk/ProcessHacker.Common/Threading/FastMutex.cs index 008cc5c5a..5a83cc3c3 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/FastMutex.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/FastMutex.cs @@ -16,7 +16,7 @@ public sealed class FastMutex public struct FastMutexContext : IDisposable { private bool _disposed; - private readonly FastMutex _fastMutex; + private FastMutex _fastMutex; internal FastMutexContext(FastMutex fastMutex) { @@ -37,7 +37,7 @@ public void Dispose() } } - private readonly object _lock = new object(); + private object _lock = new object(); /// /// Acquires the mutex and prevents others from acquiring it. diff --git a/1.x/trunk/ProcessHacker.Common/Threading/FastResourceLock.cs b/1.x/trunk/ProcessHacker.Common/Threading/FastResourceLock.cs index 3f78ebb86..cdac07d57 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/FastResourceLock.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/FastResourceLock.cs @@ -21,11 +21,8 @@ */ #define DEFER_EVENT_CREATION - -#if DEBUG -#define ENABLE_STATISTICS -#define RIGOROUS_CHECKS -#endif +//#define ENABLE_STATISTICS +//#define RIGOROUS_CHECKS using System; using System.Threading; @@ -201,24 +198,21 @@ public struct Statistics private IntPtr _exclusiveWakeEvent; #if ENABLE_STATISTICS - private int _acqExclCount; - private int _acqShrdCount; - private int _acqExclContCount; - private int _acqShrdContCount; - private int _acqExclSlpCount; - private int _acqShrdSlpCount; - private int _peakExclWtrsCount; - private int _peakShrdWtrsCount; + private int _acqExclCount = 0; + private int _acqShrdCount = 0; + private int _acqExclContCount = 0; + private int _acqShrdContCount = 0; + private int _acqExclSlpCount = 0; + private int _acqShrdSlpCount = 0; + private int _peakExclWtrsCount = 0; + private int _peakShrdWtrsCount = 0; #endif /// /// Creates a FastResourceLock. /// public FastResourceLock() - { -#if ENABLE_STATISTICS - this._acqExclContCount = 0; -#endif + { _value = 0; #if !DEFER_EVENT_CREATION @@ -353,8 +347,8 @@ public void AcquireExclusive() Interlocked2.Set( ref _peakExclWtrsCount, - p => p < exclWtrsCount, - p => exclWtrsCount + (p) => p < exclWtrsCount, + (p) => exclWtrsCount ); #endif @@ -463,8 +457,8 @@ public void AcquireShared() Interlocked2.Set( ref _peakShrdWtrsCount, - p => p < shrdWtrsCount, - p => shrdWtrsCount + (p) => p < shrdWtrsCount, + (p) => shrdWtrsCount ); #endif @@ -534,10 +528,12 @@ public void ConvertExclusiveToShared() /// A reference to the event handle. private void EnsureEventCreated(ref IntPtr handle) { + IntPtr eventHandle; + if (Thread.VolatileRead(ref handle) != IntPtr.Zero) return; - IntPtr eventHandle = NativeMethods.CreateSemaphore(IntPtr.Zero, 0, int.MaxValue, null); + eventHandle = NativeMethods.CreateSemaphore(IntPtr.Zero, 0, int.MaxValue, null); if (Interlocked.CompareExchange(ref handle, eventHandle, IntPtr.Zero) != IntPtr.Zero) NativeMethods.CloseHandle(eventHandle); @@ -551,7 +547,7 @@ private void EnsureEventCreated(ref IntPtr handle) public Statistics GetStatistics() { #if ENABLE_STATISTICS - return new Statistics + return new Statistics() { AcqExcl = _acqExclCount, AcqShrd = _acqShrdCount, @@ -601,7 +597,9 @@ public void ReleaseExclusive() // Case 2: if we have shared waiters, release all of them. else { - int sharedWaiters = (value >> LockSharedWaitersShift) & LockSharedWaitersMask; + int sharedWaiters; + + sharedWaiters = (value >> LockSharedWaitersShift) & LockSharedWaitersMask; if (Interlocked.CompareExchange( ref _value, @@ -824,17 +822,18 @@ public bool TryAcquireShared() value ) == value; } - - if (((value >> LockSharedOwnersShift) & LockSharedOwnersMask) != 0) + else if (((value >> LockSharedOwnersShift) & LockSharedOwnersMask) != 0) { return Interlocked.CompareExchange( - ref this._value, + ref _value, value + LockSharedOwnersIncrement, value ) == value; } - - return false; + else + { + return false; + } } /// diff --git a/1.x/trunk/ProcessHacker.Common/Threading/FastStack.cs b/1.x/trunk/ProcessHacker.Common/Threading/FastStack.cs index 111ab2593..42fd55a71 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/FastStack.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/FastStack.cs @@ -13,13 +13,8 @@ private class FastStackNode public FastStackNode Next; } - private readonly int _count; - private FastStackNode _bottom; - - public FastStack(int count) - { - _count = count; - } + private int _count = 0; + private FastStackNode _bottom = null; public int Count { @@ -53,7 +48,7 @@ public T Pop() throw new InvalidOperationException("The stack is empty."); // Try to replace the pointer. - if (Interlocked.CompareExchange( + if (Interlocked.CompareExchange>( ref _bottom, bottom.Next, bottom @@ -68,11 +63,10 @@ public T Pop() public void Push(T value) { FastStackNode bottom; + FastStackNode entry; - FastStackNode entry = new FastStackNode - { - Value = value - }; + entry = new FastStackNode(); + entry.Value = value; // Atomically replace the bottom of the stack. while (true) @@ -81,7 +75,7 @@ public void Push(T value) entry.Next = bottom; // Try to replace the pointer. - if (Interlocked.CompareExchange( + if (Interlocked.CompareExchange>( ref _bottom, entry, bottom diff --git a/1.x/trunk/ProcessHacker.Common/Threading/IResourceLock.cs b/1.x/trunk/ProcessHacker.Common/Threading/IResourceLock.cs index 58bcbdbb1..4d1baaf93 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/IResourceLock.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/IResourceLock.cs @@ -1,4 +1,8 @@ -namespace ProcessHacker.Common.Threading +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.Common.Threading { public interface IResourceLock { diff --git a/1.x/trunk/ProcessHacker.Common/Threading/Interlocked2.cs b/1.x/trunk/ProcessHacker.Common/Threading/Interlocked2.cs index e46da6230..351838a42 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/Interlocked2.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/Interlocked2.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Threading; namespace ProcessHacker.Common.Threading diff --git a/1.x/trunk/ProcessHacker.Common/Threading/NativeMethods.cs b/1.x/trunk/ProcessHacker.Common/Threading/NativeMethods.cs index 589f412f5..4697175da 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/NativeMethods.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/NativeMethods.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; using System.Security; +using System.Text; namespace ProcessHacker.Common.Threading { diff --git a/1.x/trunk/ProcessHacker.Common/Threading/RundownProtection.cs b/1.x/trunk/ProcessHacker.Common/Threading/RundownProtection.cs index c5c1367d2..7752ee58f 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/RundownProtection.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/RundownProtection.cs @@ -20,6 +20,7 @@ * along with Process Hacker. If not, see . */ +using System; using System.Threading; namespace ProcessHacker.Common.Threading @@ -129,7 +130,9 @@ public void Release() // Has the rundown already started? if ((value & RundownActive) != 0) { - int newValue = Interlocked.Add(ref this._value, -RundownCountIncrement); + int newValue; + + newValue = Interlocked.Add(ref _value, -RundownCountIncrement); // Are we the last out? Set the event if that's the case. if (newValue == RundownActive) @@ -139,13 +142,15 @@ public void Release() return; } - - if (Interlocked.CompareExchange( - ref this._value, - value - RundownCountIncrement, - value - ) == value) - return; + else + { + if (Interlocked.CompareExchange( + ref _value, + value - RundownCountIncrement, + value + ) == value) + return; + } } } @@ -164,7 +169,9 @@ public void Release(int count) // Has the rundown already started? if ((value & RundownActive) != 0) { - int newValue = Interlocked.Add(ref this._value, -RundownCountIncrement * count); + int newValue; + + newValue = Interlocked.Add(ref _value, -RundownCountIncrement * count); // Are we the last out? Set the event if that's the case. if (newValue == RundownActive) @@ -174,13 +181,15 @@ public void Release(int count) return; } - - if (Interlocked.CompareExchange( - ref this._value, - value - RundownCountIncrement * count, - value - ) == value) - return; + else + { + if (Interlocked.CompareExchange( + ref _value, + value - RundownCountIncrement * count, + value + ) == value) + return; + } } } @@ -201,10 +210,12 @@ public void Wait() /// Whether all references were released. public bool Wait(int millisecondsTimeout) { + int value; + // Fast path. Just in case there are no users, we can go ahead // and set the active flag and exit. Or if someone has already // initiated the rundown, exit as well. - int value = Interlocked.CompareExchange(ref this._value, RundownActive, 0); + value = Interlocked.CompareExchange(ref _value, RundownActive, 0); if (value == 0 || value == RundownActive) return true; @@ -222,8 +233,8 @@ public bool Wait(int millisecondsTimeout) // Wait for the event, but only if we had users. if ((value & ~RundownActive) != 0) return _wakeEvent.Wait(millisecondsTimeout); - - return true; + else + return true; } } } diff --git a/1.x/trunk/ProcessHacker.Common/Threading/SemaphorePair.cs b/1.x/trunk/ProcessHacker.Common/Threading/SemaphorePair.cs index dd180d8ae..25013a681 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/SemaphorePair.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/SemaphorePair.cs @@ -5,9 +5,9 @@ namespace ProcessHacker.Common.Threading { public class SemaphorePair : IDisposable { - private readonly int _count; - private readonly Semaphore _readSemaphore; - private readonly Semaphore _writeSemaphore; + private int _count; + private Semaphore _readSemaphore; + private Semaphore _writeSemaphore; public SemaphorePair(int count) { diff --git a/1.x/trunk/ProcessHacker.Common/Threading/ThreadTask.cs b/1.x/trunk/ProcessHacker.Common/Threading/ThreadTask.cs index 2a15c7011..26ce7310f 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/ThreadTask.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/ThreadTask.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Threading; namespace ProcessHacker.Common.Threading @@ -11,11 +13,11 @@ public sealed class ThreadTask public event ThreadTaskCompletedDelegate Completed; public event ThreadTaskRunTaskDelegate RunTask; - private Thread _thread; + private Thread _thread = null; private object _result; private Exception _exception; - private bool _cancelled; - private bool _running; + private bool _cancelled = false; + private bool _running = false; public bool Cancelled { @@ -55,10 +57,8 @@ public void Start(object param) _cancelled = false; _running = true; - _thread = new Thread(this.ThreadStart) - { - IsBackground = true - }; + _thread = new Thread(this.ThreadStart); + _thread.IsBackground = true; _thread.Start(param); } diff --git a/1.x/trunk/ProcessHacker.Common/Threading/WaitableQueue.cs b/1.x/trunk/ProcessHacker.Common/Threading/WaitableQueue.cs index 4d6f2db27..fef78eb7e 100644 --- a/1.x/trunk/ProcessHacker.Common/Threading/WaitableQueue.cs +++ b/1.x/trunk/ProcessHacker.Common/Threading/WaitableQueue.cs @@ -1,12 +1,15 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Text; +using System.Threading; namespace ProcessHacker.Common.Threading { - public class WaitableQueue : IEnumerable + public class WaitableQueue : IEnumerable, IEnumerable { - private readonly Queue _queue = new Queue(); - private readonly SemaphorePair _pair; + private Queue _queue = new Queue(); + private SemaphorePair _pair; public WaitableQueue() : this(int.MaxValue) @@ -47,8 +50,10 @@ public T Dequeue() public bool Dequeue(int timeout, out T item) { + bool waitResult = true; + // Wait for an item to dequeue. - bool waitResult = _pair.WaitRead(timeout); + waitResult = _pair.WaitRead(timeout); // Dequeue an item if we waited successfully, // otherwise pass the default value back. diff --git a/1.x/trunk/ProcessHacker.Common/Tokenizer.cs b/1.x/trunk/ProcessHacker.Common/Tokenizer.cs index 425ab979b..c21ef4a28 100644 --- a/1.x/trunk/ProcessHacker.Common/Tokenizer.cs +++ b/1.x/trunk/ProcessHacker.Common/Tokenizer.cs @@ -5,8 +5,8 @@ namespace ProcessHacker.Common { public class Tokenizer { - private readonly string _text; - private int _i; + private string _text; + private int _i = 0; public Tokenizer(string text) { @@ -90,7 +90,7 @@ public string EatQuotedString() _i++; } else - return string.Empty; + return ""; while (_i < _text.Length) { @@ -102,29 +102,20 @@ public string EatQuotedString() } else if (inEscape) { - switch (this._text[this._i]) - { - case '\\': - sb.Append('\\'); - break; - case '"': - sb.Append('"'); - break; - case '\'': - sb.Append('\''); - break; - case 'r': - sb.Append('\r'); - break; - case 'n': - sb.Append('\n'); - break; - case 't': - sb.Append('\t'); - break; - default: - throw new Exception("Unrecognized escape sequence '\\" + this._text[this._i] + "'"); - } + if (_text[_i] == '\\') + sb.Append('\\'); + else if (_text[_i] == '"') + sb.Append('"'); + else if (_text[_i] == '\'') + sb.Append('\''); + else if (_text[_i] == 'r') + sb.Append('\r'); + else if (_text[_i] == 'n') + sb.Append('\n'); + else if (_text[_i] == 't') + sb.Append('\t'); + else + throw new Exception("Unrecognized escape sequence '\\" + _text[_i] + "'"); _i++; inEscape = false; diff --git a/1.x/trunk/ProcessHacker.Common/Ui/ColumnHeaderExtensions.cs b/1.x/trunk/ProcessHacker.Common/Ui/ColumnHeaderExtensions.cs index c7e812784..cef6c409d 100644 --- a/1.x/trunk/ProcessHacker.Common/Ui/ColumnHeaderExtensions.cs +++ b/1.x/trunk/ProcessHacker.Common/Ui/ColumnHeaderExtensions.cs @@ -10,7 +10,7 @@ namespace ProcessHacker.Common.Ui public static class ColumnHeaderExtensions { [StructLayout(LayoutKind.Sequential)] - public struct LVCOLUMN + private struct LVCOLUMN { public Int32 mask; public Int32 cx; @@ -45,13 +45,11 @@ public static void SetSortIcon(this ColumnHeader column, SortOrder order) for (int i = 0; i <= listView.Columns.Count - 1; i++) { IntPtr ColumnPtr = new IntPtr(i); - LVCOLUMN lvColumn = new LVCOLUMN - { - mask = HDI_FORMAT - }; + LVCOLUMN lvColumn = new LVCOLUMN(); + lvColumn.mask = HDI_FORMAT; SendMessage(columnHeader, HDM_GETITEM, ColumnPtr, ref lvColumn); - if (order != SortOrder.None && i == column.Index) + if (!(order == SortOrder.None) && i == column.Index) { switch (order) { diff --git a/1.x/trunk/ProcessHacker.Common/Ui/SortedListViewComparer.cs b/1.x/trunk/ProcessHacker.Common/Ui/SortedListViewComparer.cs index 9aadbdff8..588d1298c 100644 --- a/1.x/trunk/ProcessHacker.Common/Ui/SortedListViewComparer.cs +++ b/1.x/trunk/ProcessHacker.Common/Ui/SortedListViewComparer.cs @@ -43,19 +43,26 @@ public class SortedListViewComparer : IComparer { private class DefaultComparer : ISortedListViewComparer { + private SortedListViewComparer _sortedListComparer; + + public DefaultComparer(SortedListViewComparer sortedListComparer) + { + _sortedListComparer = sortedListComparer; + } + public int Compare(ListViewItem x, ListViewItem y, int column) { string sx, sy; long ix, iy; IComparable cx, cy; - sx = x.SubItems[column].Text.Replace(",", string.Empty); - sy = y.SubItems[column].Text.Replace(",", string.Empty); + sx = x.SubItems[column].Text.Replace(",", ""); + sy = y.SubItems[column].Text.Replace(",", ""); - if (!long.TryParse(sx.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? sx.Substring(2) : sx, + if (!long.TryParse(sx.StartsWith("0x") ? sx.Substring(2) : sx, sx.StartsWith("0x") ? NumberStyles.AllowHexSpecifier : 0, null, out ix) || - !long.TryParse(sy.StartsWith("0x", StringComparison.OrdinalIgnoreCase) ? sy.Substring(2) : sy, + !long.TryParse(sy.StartsWith("0x") ? sy.Substring(2) : sy, sy.StartsWith("0x") ? NumberStyles.AllowHexSpecifier : 0, null, out iy)) { @@ -72,17 +79,17 @@ public int Compare(ListViewItem x, ListViewItem y, int column) } } - private readonly ListView _list; - private bool _virtualMode; + private ListView _list; + private bool _virtualMode = false; private RetrieveVirtualItemEventHandler _retrieveVirtualItem; - private bool _triState; + private bool _triState = false; private ISortedListViewComparer _comparer; private ISortedListViewComparer _triStateComparer; private int _sortColumn; private SortOrder _sortOrder; - private readonly Dictionary> _customSorters = + private Dictionary> _customSorters = new Dictionary>(); - private readonly List _columnSortOrder = new List(); + private List _columnSortOrder = new List(); /// /// Creates a new sorted list manager. @@ -91,10 +98,10 @@ public int Compare(ListViewItem x, ListViewItem y, int column) public SortedListViewComparer(ListView list) { _list = list; - _list.ColumnClick += this.list_ColumnClick; + _list.ColumnClick += new ColumnClickEventHandler(list_ColumnClick); _sortColumn = 0; _sortOrder = SortOrder.Ascending; - _comparer = new DefaultComparer(); + _comparer = new DefaultComparer(this); this.SetSortIcon(); } @@ -135,7 +142,7 @@ public ISortedListViewComparer Comparer set { if (value == null) - _comparer = new DefaultComparer(); + _comparer = new DefaultComparer(this); else _comparer = value; } @@ -229,20 +236,31 @@ private void SetSortIcon() // Avoid forcing handle creation before all other initialization // has finished. This is done by handling the Layout event and // performing the icon setting there. - _list.DoDelayed(control => _list.Columns[_sortColumn].SetSortIcon(_sortOrder)); + _list.DoDelayed((control) => _list.Columns[_sortColumn].SetSortIcon(_sortOrder)); } - private int ModifySort(int result, SortOrder order) + private ListViewItem GetItem(int index) { - switch (order) + if (_virtualMode) { - case SortOrder.Ascending: - return result; - case SortOrder.Descending: - return -result; - default: - return result; + var args = new RetrieveVirtualItemEventArgs(index); + _retrieveVirtualItem(this, args); + return args.Item; } + else + { + return _list.Items[index]; + } + } + + private int ModifySort(int result, SortOrder order) + { + if (order == SortOrder.Ascending) + return result; + else if (order == SortOrder.Descending) + return -result; + else + return result; } private int Compare(ListViewItem x, ListViewItem y, int column) diff --git a/1.x/trunk/ProcessHacker.Common/Utils.cs b/1.x/trunk/ProcessHacker.Common/Utils.cs index 718ebe4e7..b1f296a63 100644 --- a/1.x/trunk/ProcessHacker.Common/Utils.cs +++ b/1.x/trunk/ProcessHacker.Common/Utils.cs @@ -25,6 +25,7 @@ using System.Drawing; using System.IO; using System.Reflection; +using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; @@ -70,6 +71,8 @@ public enum Endianness /// public static int UnitSpecifier = 4; + private static PropertyInfo _doubleBufferedProperty; + /// /// Aligns a number to the specified power-of-two alignment value. /// @@ -130,7 +133,7 @@ public static T[] Concat(params T[][] ap) /// True if the array contains the value, otherwise false. public static bool Contains(this T[] array, T value) { - return Array.IndexOf(array, value) != -1; + return Array.IndexOf(array, value) != -1; } /// @@ -195,8 +198,8 @@ public static string CreateEllipsis(string s, int len) { if (s.Length <= len) return s; - - return s.Substring(0, len - 4) + " ..."; + else + return s.Substring(0, len - 4) + " ..."; } /// @@ -215,11 +218,24 @@ public static string CreateRandomString(int length) return sb.ToString(); } + /// + /// Clears and cleans up resources held by the menu items. + /// + public static void DisposeAndClear(this Menu.MenuItemCollection items) + { + //foreach (MenuItem item in items) + //{ + // item.Dispose(); + //} + + items.Clear(); + } + /// /// Disables the menu items contained in the specified menu. /// /// The menu. - public static void DisableAllMenuItems(MenuItem menu) + public static void DisableAllMenuItems(Menu menu) { foreach (MenuItem item in menu.MenuItems) item.Enabled = false; @@ -228,7 +244,7 @@ public static void DisableAllMenuItems(MenuItem menu) /// /// Disables all menu items. /// - public static void DisableAll(this MenuItem menu) + public static void DisableAll(this Menu menu) { DisableAllMenuItems(menu); } @@ -521,7 +537,7 @@ public static string FormatRelativeDateTime(DateTime time) double months = span.TotalDays * 12 / 365; double years = months / 12; double centuries = years / 100; - string str; + string str = ""; // Start from the most general time unit and see if they can be used // without any fractional component. @@ -577,7 +593,7 @@ public static string FormatRelativeDateTime(DateTime time) str = "a very short time"; // Turn 1 into "a", e.g. 1 minute -> a minute - if (str.StartsWith("1 ", StringComparison.OrdinalIgnoreCase)) + if (str.StartsWith("1 ")) { // Special vowel case: a hour -> an hour if (str[2] != 'h') @@ -605,7 +621,7 @@ public static string FormatSize(int size) public static string FormatSize(uint size) { int i = 0; - double s = size; + double s = (double)size; while (s > 1024 && i < SizeUnitNames.Length && i < UnitSpecifier) { @@ -644,7 +660,7 @@ public static string FormatSize(long size) public static string FormatSize(ulong size) { int i = 0; - double s = size; + double s = (double)size; while (s > 1024 && i < SizeUnitNames.Length && i < UnitSpecifier) { @@ -708,7 +724,7 @@ public static DateTime GetAssemblyBuildDate(Assembly assembly, bool forceFileDat // The last write time of the assembly, or DateTime.MaxValue if an exception occurred. public static DateTime GetAssemblyLastWriteTime(Assembly assembly) { - if (string.IsNullOrEmpty(assembly.Location)) + if (assembly.Location == null || assembly.Location == "") return DateTime.MaxValue; try @@ -824,10 +840,10 @@ public static int GetPrime(int minimum) if (minimum < 0) throw new ArgumentOutOfRangeException("minimum"); - foreach (int t in Primes) + for (int i = 0; i < Primes.Length; i++) { - if (t >= minimum) - return t; + if (Primes[i] >= minimum) + return Primes[i]; } for (int i = minimum | 1; i < int.MaxValue; i += 2) @@ -936,8 +952,8 @@ public static char MakePrintable(char c) { if (c >= ' ' && c <= '~') return c; - - return '.'; + else + return '.'; } /// @@ -949,8 +965,8 @@ public static string MakePrintable(string s) { StringBuilder sb = new StringBuilder(); - foreach (char t in s) - sb.Append(MakePrintable(t)); + for (int i = 0; i < s.Length; i++) + sb.Append(MakePrintable(s[i])); return sb.ToString(); } @@ -1043,7 +1059,7 @@ public static Dictionary ParseCommandLine(string[] args) foreach (string s in args) { - if (s.StartsWith("-", StringComparison.OrdinalIgnoreCase)) + if (s.StartsWith("-")) { if (dict.ContainsKey(s)) throw new ArgumentException("Option already specified."); @@ -1108,7 +1124,7 @@ public static string ReadString(Stream s, int length) if (s.Read(buffer, 0, length) == 0) throw new EndOfStreamException(); - return Encoding.ASCII.GetString(buffer); + return System.Text.Encoding.ASCII.GetString(buffer); } public static uint ReadUInt32(Stream s, Endianness type) @@ -1145,7 +1161,7 @@ public static string ReadUnicodeString(Stream s) if (b == 0 && b2 == 0) break; - str.Append(Encoding.Unicode.GetChars(new[] { (byte)b, (byte)b2 })); + str.Append(Encoding.Unicode.GetChars(new byte[] { (byte)b, (byte)b2 })); } return str.ToString(); @@ -1174,7 +1190,7 @@ public static string ReadUnicodeString(Stream s, int length) if (b2 == -1) break; - str.Append(Encoding.Unicode.GetChars(new[] { (byte)b, (byte)b2 })); + str.Append(Encoding.Unicode.GetChars(new byte[] { (byte)b, (byte)b2 })); i += 2; } @@ -1298,6 +1314,35 @@ public static void SelectAll(this ListView items) } } + /// + /// Enables or disables double buffering for a control. + /// + /// The control. + /// The type of the control. + /// The new setting. + public static void SetDoubleBuffered(this Control c, Type t, bool value) + { + PropertyInfo doubleBufferedProperty = _doubleBufferedProperty; + + if (doubleBufferedProperty == null) + { + _doubleBufferedProperty = doubleBufferedProperty = t.GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance); + } + + doubleBufferedProperty.SetValue(c, value, null); + } + + /// + /// Enables or disables double buffering for a control. + /// + /// The control to set the property on. + /// The new value. + public static void SetDoubleBuffered(this Control c, bool value) + { + c.SetDoubleBuffered(c.GetType(), value); + } + /// /// Shows a file in Windows Explorer. /// @@ -1310,13 +1355,23 @@ public static void ShowFileInExplorer(string fileName) /// /// Calculates the size of a structure. /// + /// The structure type. + /// The size of the structure. + public static int SizeOf() + { + return System.Runtime.InteropServices.Marshal.SizeOf(typeof(T)); + } + + /// + /// Calculates the size of a structure. + /// + /// The structure type. /// A power-of-two whole-structure alignment to apply. - /// /// The size of the structure. - public static int SizeOf(int alignment, int size) + public static int SizeOf(int alignment) { // HACK: This is wrong, but it works. - return size + alignment; + return SizeOf() + alignment; } /// @@ -1381,14 +1436,17 @@ public static int ToInt32(this byte[] data) public static int ToInt32(this byte[] data, Endianness type) { - switch (type) + if (type == Endianness.Little) { - case Endianness.Little: - return (data[0]) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); - case Endianness.Big: - return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3]); - default: - throw new ArgumentException(); + return (data[0]) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + } + else if (type == Endianness.Big) + { + return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | (data[3]); + } + else + { + throw new ArgumentException(); } } @@ -1399,16 +1457,19 @@ public static long ToInt64(this byte[] data) public static long ToInt64(this byte[] data, Endianness type) { - switch (type) + if (type == Endianness.Little) + { + return (data[0]) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24) | + (data[4] << 32) | (data[5] << 40) | (data[6] << 48) | (data[7] << 56); + } + else if (type == Endianness.Big) { - case Endianness.Little: - return (data[0]) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24) | - (data[4] << 32) | (data[5] << 40) | (data[6] << 48) | (data[7] << 56); - case Endianness.Big: - return (data[0] << 56) | (data[1] << 48) | (data[2] << 40) | (data[3] << 32) | - (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | (data[7]); - default: - throw new ArgumentException(); + return (data[0] << 56) | (data[1] << 48) | (data[2] << 40) | (data[3] << 32) | + (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | (data[7]); + } + else + { + throw new ArgumentException(); } } @@ -1417,15 +1478,12 @@ public static IntPtr ToIntPtr(this byte[] data) if (IntPtr.Size != data.Length) throw new ArgumentException("data"); - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(data.ToInt32(Endianness.Little)); - case sizeof(long): - return new IntPtr(data.ToInt64(Endianness.Little)); - default: - throw new ArgumentException("data"); - } + if (IntPtr.Size == sizeof(int)) + return new IntPtr(data.ToInt32(Endianness.Little)); + else if (IntPtr.Size == sizeof(long)) + return new IntPtr(data.ToInt64(Endianness.Little)); + else + throw new ArgumentException("data"); } public static ushort ToUInt16(this byte[] data, Endianness type) @@ -1435,14 +1493,17 @@ public static ushort ToUInt16(this byte[] data, Endianness type) public static ushort ToUInt16(this byte[] data, int offset, Endianness type) { - switch (type) + if (type == Endianness.Little) + { + return (ushort)(data[offset] | (data[offset + 1] << 8)); + } + else if (type == Endianness.Big) { - case Endianness.Little: - return (ushort)(data[offset] | (data[offset + 1] << 8)); - case Endianness.Big: - return (ushort)((data[offset] << 8) | data[offset + 1]); - default: - throw new ArgumentException(); + return (ushort)((data[offset] << 8) | data[offset + 1]); + } + else + { + throw new ArgumentException(); } } @@ -1453,16 +1514,19 @@ public static uint ToUInt32(this byte[] data, Endianness type) public static uint ToUInt32(this byte[] data, int offset, Endianness type) { - switch (type) + if (type == Endianness.Little) + { + return (uint)(data[offset]) | (uint)(data[offset + 1] << 8) | + (uint)(data[offset + 2] << 16) | (uint)(data[offset + 3] << 24); + } + else if (type == Endianness.Big) { - case Endianness.Little: - return (uint)(data[offset]) | (uint)(data[offset + 1] << 8) | - (uint)(data[offset + 2] << 16) | (uint)(data[offset + 3] << 24); - case Endianness.Big: - return (uint)(data[offset] << 24) | (uint)(data[offset + 1] << 16) | - (uint)(data[offset + 2] << 8) | (uint)(data[offset + 3]); - default: - throw new ArgumentException(); + return (uint)(data[offset] << 24) | (uint)(data[offset + 1] << 16) | + (uint)(data[offset + 2] << 8) | (uint)(data[offset + 3]); + } + else + { + throw new ArgumentException(); } } @@ -1485,7 +1549,7 @@ public static void ValidateBuffer(byte[] buffer, int offset, int length, bool ca if (buffer != null) { if (buffer.Length - offset < length) - throw new ArgumentOutOfRangeException("buffer", "The buffer is too small for the specified offset and length."); + throw new ArgumentOutOfRangeException("The buffer is too small for the specified offset and length."); } else { @@ -1494,7 +1558,7 @@ public static void ValidateBuffer(byte[] buffer, int offset, int length, bool ca // We don't have a buffer, so make sure the offset and length are zero. if (offset != 0 || length != 0) - throw new ArgumentOutOfRangeException("offset", "The offset and length must be zero for a null buffer."); + throw new ArgumentOutOfRangeException("The offset and length must be zero for a null buffer."); } } } diff --git a/1.x/trunk/ProcessHacker.Common/WeakReference.cs b/1.x/trunk/ProcessHacker.Common/WeakReference.cs new file mode 100644 index 000000000..a7d0bece0 --- /dev/null +++ b/1.x/trunk/ProcessHacker.Common/WeakReference.cs @@ -0,0 +1,39 @@ +using System; + +namespace ProcessHacker.Common +{ + public class WeakReference + where T : class + { + public static implicit operator T(WeakReference reference) + { + return reference.Target; + } + + private WeakReference _weakReference; + + public WeakReference(T obj) + : this(obj, false) + { } + + public WeakReference(T obj, bool trackResurrection) + { + _weakReference = new WeakReference(obj, trackResurrection); + } + + public bool Alive + { + get { return _weakReference.IsAlive; } + } + + public bool TrackResurrection + { + get { return _weakReference.TrackResurrection; } + } + + public T Target + { + get { return _weakReference.Target as T; } + } + } +} diff --git a/1.x/trunk/ProcessHacker.Common/WorkQueue.cs b/1.x/trunk/ProcessHacker.Common/WorkQueue.cs index 4d2f93b76..b37f82208 100644 --- a/1.x/trunk/ProcessHacker.Common/WorkQueue.cs +++ b/1.x/trunk/ProcessHacker.Common/WorkQueue.cs @@ -37,10 +37,10 @@ public sealed class WorkQueue /// public sealed class WorkItem { - private readonly WorkQueue _owner; - private readonly string _tag; - private readonly Delegate _work; - private readonly object[] _args; + private WorkQueue _owner; + private string _tag; + private Delegate _work; + private object[] _args; private bool _enabled = true; private FastEvent _completedEvent = new FastEvent(false); private object _result; @@ -175,7 +175,7 @@ public bool WaitOne(int timeout) } } - private static readonly WorkQueue _globalWorkQueue = new WorkQueue(); + private static WorkQueue _globalWorkQueue = new WorkQueue(); /// /// Gets the global work queue instance. @@ -228,7 +228,7 @@ public static WorkItem GlobalQueueWorkItemTag(Delegate work, string tag, params /// /// The work queue. This object is used as a lock. /// - private readonly Queue _workQueue = new Queue(); + private Queue _workQueue = new Queue(); /// /// The maximum number of worker threads. If there are less worker threads /// than this limit, they will be created as necessary. If there are more @@ -241,15 +241,15 @@ public static WorkItem GlobalQueueWorkItemTag(Delegate work, string tag, params /// as necessary and the number of worker threads will never drop below /// this number. /// - private int _minWorkerThreads; + private int _minWorkerThreads = 0; /// /// The pool of worker threads. This object is used as a lock. /// - private readonly Dictionary _workerThreads = new Dictionary(); + private Dictionary _workerThreads = new Dictionary(); /// /// The number of worker threads which are currently running work. /// - private int _busyCount; + private int _busyCount = 0; /// /// A worker will block on the work-arrived event for this amount of time /// before terminating. @@ -258,7 +258,13 @@ public static WorkItem GlobalQueueWorkItemTag(Delegate work, string tag, params /// /// If true, prevents new work items from being queued. /// - private volatile bool _isJoining; + private volatile bool _isJoining = false; + + /// + /// Creates a new work queue. + /// + public WorkQueue() + { } /// /// Gets the number of worker threads that are currently busy. @@ -336,11 +342,9 @@ public void CreateMinimumWorkerThreads() /// private void CreateWorkerThread() { - Thread workThread = new Thread(this.WorkerThreadStart, Utils.SixteenthStackSize) - { - IsBackground = true, - Priority = ThreadPriority.Lowest - }; + Thread workThread = new Thread(this.WorkerThreadStart, Utils.SixteenthStackSize); + workThread.IsBackground = true; + workThread.Priority = ThreadPriority.Lowest; workThread.SetApartmentState(ApartmentState.STA); _workerThreads.Add(workThread.ManagedThreadId, workThread); workThread.Start(); @@ -374,7 +378,7 @@ public void JoinAll() // Check for work items. while (_workQueue.Count > 0) { - WorkItem workItem; + WorkItem workItem = null; // Lock and re-check. lock (_workQueue) @@ -407,8 +411,11 @@ public bool RemoveQueuedWorkItem(WorkItem workItem) workItem.Enabled = false; return true; } - // The work item is no longer in the queue. - return false; + else + { + // The work item is no longer in the queue. + return false; + } } } @@ -528,7 +535,7 @@ private void WorkerThreadStart() // Check for work. if (_workQueue.Count > 0) { - WorkItem workItem; + WorkItem workItem = null; // There is work, but we must lock and re-check. lock (_workQueue) @@ -546,7 +553,7 @@ private void WorkerThreadStart() else { // No work available. Wait for work. - bool workArrived; + bool workArrived = false; lock (_workQueue) workArrived = Monitor.Wait(_workQueue, _noWorkTimeout); @@ -556,14 +563,17 @@ private void WorkerThreadStart() // Work arrived. Go back so we can perform it. continue; } - // No work arrived during the timeout period. Delete the thread. - lock (this._workerThreads) + else { - // Check the minimum. - if (this._workerThreads.Count > this._minWorkerThreads) + // No work arrived during the timeout period. Delete the thread. + lock (_workerThreads) { - this.DestroyWorkerThread(); - return; + // Check the minimum. + if (_workerThreads.Count > _minWorkerThreads) + { + this.DestroyWorkerThread(); + return; + } } } } diff --git a/1.x/trunk/ProcessHacker.Common/app.config b/1.x/trunk/ProcessHacker.Common/app.config index b4ca687d2..89dc7d426 100644 --- a/1.x/trunk/ProcessHacker.Common/app.config +++ b/1.x/trunk/ProcessHacker.Common/app.config @@ -1,3 +1,3 @@ - + diff --git a/1.x/trunk/ProcessHacker.Native/Api/Enums.cs b/1.x/trunk/ProcessHacker.Native/Api/Enums.cs index 2cdd47e6e..825d1dbc6 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/Enums.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/Enums.cs @@ -179,7 +179,7 @@ public enum FileCreationDispositionWin32 : uint TruncateExisting = 5 } - public enum GdiBlendMode + public enum GdiBlendMode : int { Black = 1, NotMergePen, @@ -200,7 +200,7 @@ public enum GdiBlendMode Last } - public enum GdiPenStyle + public enum GdiPenStyle : int { Solid = 0, Dash, @@ -213,7 +213,7 @@ public enum GdiPenStyle Alternate } - public enum GdiStockObject + public enum GdiStockObject : int { WhiteBrush = 0, LightGrayBrush, @@ -236,7 +236,7 @@ public enum GdiStockObject DcPen } - public enum GetWindowLongOffset + public enum GetWindowLongOffset : int { WndProc = -4, HInstance = -6, @@ -248,14 +248,14 @@ public enum GetWindowLongOffset } [Flags] - public enum HeapEntry32Flags + public enum HeapEntry32Flags : int { Fixed = 0x00000001, Free = 0x00000002, Moveable = 0x00000004 } - public enum LoadImageType + public enum LoadImageType : int { Bitmap = 0, Icon = 1, @@ -308,14 +308,14 @@ public enum MemoryState : uint LargePages = 0x20000000 } - public enum MemoryType + public enum MemoryType : int { Image = 0x1000000, Mapped = 0x40000, Private = 0x20000 } - public enum MibTcpState + public enum MibTcpState : int { Closed = 1, Listening = 2, @@ -331,7 +331,6 @@ public enum MibTcpState DeleteTcb = 12 } - [Flags] public enum MinidumpType : uint { Normal = 0x00000000, @@ -457,41 +456,6 @@ public enum ProcessPriorityClassWin32 : int AboveNormal = 0x8000 } - [Flags] - public enum PropSheetPageFlags - { - Default = 0x0, - DlgIndirect = 0x1, - UseHIcon = 0x2, - UseIconID = 0x4, - UseTitle = 0x8, - RtlReading = 0x10, - - HasHelp = 0x20, - UseRefParent = 0x40, - UseCallback = 0x80, - Premature = 0x400, - - HideHeader = 0x800, - UseHeaderTitle = 0x1000, - UseHeaderSubTitle = 0x2000, - UseFusionContext = 0x4000 - } - - public enum PropSheetPageCallbackMessage - { - AddRef = 0, - Release = 1, - Create = 2 - } - - public enum PropSheetNotification : uint - { - First = ~200u + 1, // -200 - SetActive = First - 0, - KillActive = First - 1 - } - [Flags] public enum RedrawWindowFlags { diff --git a/1.x/trunk/ProcessHacker.Native/Api/Extensions.cs b/1.x/trunk/ProcessHacker.Native/Api/Extensions.cs index cbbe8f5d9..b7a636607 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/Extensions.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/Extensions.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; @@ -29,7 +30,7 @@ namespace ProcessHacker.Native { public static class NativeExtensions { - private static bool NphNotAvailable; + private static bool NphNotAvailable = false; public static ObjectBasicInformation GetBasicInfo(this SystemHandleEntry thisHandle) { @@ -41,34 +42,39 @@ public static ObjectBasicInformation GetBasicInfo(this SystemHandleEntry thisHan public static ObjectBasicInformation GetBasicInfo(this SystemHandleEntry thisHandle, ProcessHandle process) { + NtStatus status = NtStatus.Success; IntPtr handle = new IntPtr(thisHandle.Handle); IntPtr objectHandleI; GenericHandle objectHandle = null; int retLength; + int baseAddress; - Win32.NtDuplicateObject( - process, - handle, - ProcessHandle.Current, - out objectHandleI, - 0, - 0, - 0 - ).ThrowIf(); - - try + if (KProcessHacker.Instance == null) { + if ((status = Win32.NtDuplicateObject( + process, handle, ProcessHandle.Current, out objectHandleI, 0, 0, 0)) >= NtStatus.Error) + Win32.Throw(); + objectHandle = new GenericHandle(objectHandleI); + } - using (MemoryAlloc data = new MemoryAlloc(ObjectBasicInformation.SizeOf)) + try + { + using (var data = new MemoryAlloc(Marshal.SizeOf(typeof(ObjectBasicInformation)))) { - Win32.NtQueryObject( - objectHandle, - ObjectInformationClass.ObjectBasicInformation, - data, - data.Size, - out retLength - ).ThrowIf(); + if (KProcessHacker.Instance != null) + { + KProcessHacker.Instance.ZwQueryObject(process, handle, ObjectInformationClass.ObjectBasicInformation, + data, data.Size, out retLength, out baseAddress); + } + else + { + status = Win32.NtQueryObject(objectHandle, ObjectInformationClass.ObjectBasicInformation, + data, data.Size, out retLength); + } + + if (status >= NtStatus.Error) + Win32.Throw(status); return data.ReadStruct(); } @@ -91,49 +97,62 @@ public static string GetName(this ClientId clientId, bool includeThread) if (includeThread) { - if (!string.IsNullOrEmpty(processName)) - return processName + " (" + clientId.ProcessId.ToString() + "): " + clientId.ThreadId.ToString(); - - return "Non-existent process (" + clientId.ProcessId.ToString() + "): " + clientId.ThreadId.ToString(); + if (processName != null) + return processName + " (" + clientId.ProcessId.ToString() + "): " + + clientId.ThreadId.ToString(); + else + return "Non-existent process (" + clientId.ProcessId.ToString() + "): " + + clientId.ThreadId.ToString(); + } + else + { + if (processName != null) + return processName + " (" + clientId.ProcessId.ToString() + ")"; + else + return "Non-existent process (" + clientId.ProcessId.ToString() + ")"; } - - if (!string.IsNullOrEmpty(processName)) - return processName + " (" + clientId.ProcessId.ToString() + ")"; - - return "Non-existent process (" + clientId.ProcessId.ToString() + ")"; } private static string GetObjectNameNt(ProcessHandle process, IntPtr handle, GenericHandle dupHandle) { int retLength; + int baseAddress = 0; - Win32.NtQueryObject( - dupHandle, - ObjectInformationClass.ObjectNameInformation, - IntPtr.Zero, - 0, - out retLength - ); + if (KProcessHacker.Instance != null) + { + KProcessHacker.Instance.ZwQueryObject(process, handle, ObjectInformationClass.ObjectNameInformation, + IntPtr.Zero, 0, out retLength, out baseAddress); + } + else + { + Win32.NtQueryObject(dupHandle, ObjectInformationClass.ObjectNameInformation, + IntPtr.Zero, 0, out retLength); + } if (retLength > 0) { using (MemoryAlloc oniMem = new MemoryAlloc(retLength)) { - Win32.NtQueryObject( - dupHandle, - ObjectInformationClass.ObjectNameInformation, - oniMem, - oniMem.Size, - out retLength - ).ThrowIf(); + if (KProcessHacker.Instance != null) + { + if (KProcessHacker.Instance.ZwQueryObject(process, handle, ObjectInformationClass.ObjectNameInformation, + oniMem, oniMem.Size, out retLength, out baseAddress) >= NtStatus.Error) + throw new Exception("ZwQueryObject failed."); + } + else + { + if (Win32.NtQueryObject(dupHandle, ObjectInformationClass.ObjectNameInformation, + oniMem, oniMem.Size, out retLength) >= NtStatus.Error) + throw new Exception("NtQueryObject failed."); + } - ObjectNameInformation oni = oniMem.ReadStruct(); - UnicodeString str = oni.Name; + var oni = oniMem.ReadStruct(); + var str = oni.Name; - //if (KProcessHacker.Instance != null) - //str.Buffer = str.Buffer.Increment(oniMem.Memory.Decrement(baseAddress)); + if (KProcessHacker.Instance != null) + str.Buffer = str.Buffer.Increment(oniMem.Memory.Decrement(baseAddress)); - return str.Text; + return str.Read(); } } @@ -147,7 +166,8 @@ public static ObjectInformation GetHandleInfo(this SystemHandleEntry thisHandle) public static ObjectInformation GetHandleInfo(this SystemHandleEntry thisHandle, bool getName) { - using (ProcessHandle process = new ProcessHandle(thisHandle.ProcessId, ProcessAccess.DupHandle)) + using (ProcessHandle process = new ProcessHandle(thisHandle.ProcessId, + KProcessHacker.Instance != null ? OSVersion.MinProcessQueryInfoAccess : ProcessAccess.DupHandle)) { return thisHandle.GetHandleInfo(process, getName); } @@ -162,24 +182,20 @@ public static ObjectInformation GetHandleInfo(this SystemHandleEntry thisHandle, { IntPtr handle = new IntPtr(thisHandle.Handle); IntPtr objectHandleI; - int retLength; + int retLength = 0; GenericHandle objectHandle = null; if (thisHandle.Handle == 0 || thisHandle.Handle == -1 || thisHandle.Handle == -2) throw new WindowsException(NtStatus.InvalidHandle); // Duplicate the handle if we're not using KPH - //if (KProcessHacker.Instance == null) + if (KProcessHacker.Instance == null) { - Win32.NtDuplicateObject( - process, - handle, - ProcessHandle.Current, - out objectHandleI, - 0, - 0, - 0 - ).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtDuplicateObject( + process, handle, ProcessHandle.Current, out objectHandleI, 0, 0, 0)) >= NtStatus.Error) + Win32.Throw(status); objectHandle = new GenericHandle(objectHandleI); } @@ -202,35 +218,45 @@ public static ObjectInformation GetHandleInfo(this SystemHandleEntry thisHandle, Windows.ObjectTypesLock.ReleaseShared(); } - if (string.IsNullOrEmpty(info.TypeName)) + if (info.TypeName == null) { - Win32.NtQueryObject( - objectHandle, - ObjectInformationClass.ObjectTypeInformation, - IntPtr.Zero, - 0, - out retLength - ); + int baseAddress = 0; + + if (KProcessHacker.Instance != null) + { + KProcessHacker.Instance.ZwQueryObject(process, handle, ObjectInformationClass.ObjectTypeInformation, + IntPtr.Zero, 0, out retLength, out baseAddress); + } + else + { + Win32.NtQueryObject(objectHandle, ObjectInformationClass.ObjectTypeInformation, + IntPtr.Zero, 0, out retLength); + } if (retLength > 0) { using (MemoryAlloc otiMem = new MemoryAlloc(retLength)) { - Win32.NtQueryObject( - objectHandle, - ObjectInformationClass.ObjectTypeInformation, - otiMem, - otiMem.Size, - out retLength - ).ThrowIf(); + if (KProcessHacker.Instance != null) + { + if (KProcessHacker.Instance.ZwQueryObject(process, handle, ObjectInformationClass.ObjectTypeInformation, + otiMem, otiMem.Size, out retLength, out baseAddress) >= NtStatus.Error) + throw new Exception("ZwQueryObject failed."); + } + else + { + if (Win32.NtQueryObject(objectHandle, ObjectInformationClass.ObjectTypeInformation, + otiMem, otiMem.Size, out retLength) >= NtStatus.Error) + throw new Exception("NtQueryObject failed."); + } - ObjectTypeInformation oti = otiMem.ReadStruct(); - UnicodeString str = oti.Name; + var oti = otiMem.ReadStruct(); + var str = oti.Name; - //if (KProcessHacker.Instance != null) - //str.Buffer = str.Buffer.Increment(otiMem.Memory.Decrement(baseAddress)); + if (KProcessHacker.Instance != null) + str.Buffer = str.Buffer.Increment(otiMem.Memory.Decrement(baseAddress)); - info.TypeName = str.Text; + info.TypeName = str.Read(); Windows.ObjectTypesLock.AcquireExclusive(); @@ -252,14 +278,14 @@ out retLength // Get the object's name. If the object is a file we must take special // precautions so that we don't hang. - if (string.Equals(info.TypeName, "File", StringComparison.OrdinalIgnoreCase)) + if (info.TypeName == "File") { - //if (KProcessHacker.Instance != null) - //{ - // // Use KProcessHacker for files to avoid hangs. - // info.OrigName = KProcessHacker.Instance.GetHandleObjectName(process, handle); - //} - //else + if (KProcessHacker.Instance != null) + { + // Use KProcessHacker for files to avoid hangs. + info.OrigName = KProcessHacker.Instance.GetHandleObjectName(process, handle); + } + else { // 0: No hack, query the thing normally. // 1: No hack, use NProcessHacker. @@ -289,16 +315,13 @@ out retLength // Use NProcessHacker. using (MemoryAlloc oniMem = new MemoryAlloc(0x4000)) { - NProcessHacker.PhQueryNameFileObject( - objectHandle, - oniMem, - oniMem.Size, - out retLength - ).ThrowIf(); + if (NProcessHacker.PhQueryNameFileObject( + objectHandle, oniMem, oniMem.Size, out retLength) >= NtStatus.Error) + throw new Exception("PhQueryNameFileObject failed."); var oni = oniMem.ReadStruct(); - info.OrigName = oni.Name.Text; + info.OrigName = oni.Name.Read(); } } catch (DllNotFoundException) @@ -316,7 +339,7 @@ out retLength { // KProcessHacker and NProcessHacker not available. Fall back to using hack // (i.e. not querying the name at all if the access is 0x0012019f). - if (thisHandle.GrantedAccess != 0x0012019f) + if ((int)thisHandle.GrantedAccess != 0x0012019f) info.OrigName = GetObjectNameNt(process, handle, objectHandle); } } @@ -341,20 +364,33 @@ out retLength case "Key": info.BestName = NativeUtils.FormatNativeKeyName(info.OrigName); + break; case "Process": { int processId; - using (NativeHandle processHandle = new NativeHandle(process, handle, OSVersion.MinProcessQueryInfoAccess)) + if (KProcessHacker.Instance != null) { - if ((processId = Win32.GetProcessId(processHandle)) == 0) - Win32.Throw(); + processId = KProcessHacker.Instance.KphGetProcessId(process, handle); + + if (processId == 0) + throw new Exception("Invalid PID"); + } + else + { + using (var processHandle = + new NativeHandle(process, handle, OSVersion.MinProcessQueryInfoAccess)) + { + if ((processId = Win32.GetProcessId(processHandle)) == 0) + Win32.Throw(); + } } info.BestName = (new ClientId(processId, 0)).GetName(false); } + break; case "Thread": @@ -362,82 +398,106 @@ out retLength int processId; int threadId; - using (var threadHandle = new NativeHandle(process, handle, OSVersion.MinThreadQueryInfoAccess)) + if (KProcessHacker.Instance != null) { - var basicInfo = ThreadHandle.FromHandle(threadHandle).GetBasicInformation(); + threadId = KProcessHacker.Instance.KphGetThreadId(process, handle, out processId); - threadId = basicInfo.ClientId.ThreadId; - processId = basicInfo.ClientId.ProcessId; + if (threadId == 0 || processId == 0) + throw new Exception("Invalid TID or PID"); + } + else + { + using (var threadHandle = + new NativeHandle(process, handle, OSVersion.MinThreadQueryInfoAccess)) + { + var basicInfo = ThreadHandle.FromHandle(threadHandle).GetBasicInformation(); + + threadId = basicInfo.ClientId.ThreadId; + processId = basicInfo.ClientId.ProcessId; + } } info.BestName = (new ClientId(processId, threadId)).GetName(true); } + break; case "TmEn": { - using (NativeHandle enHandleDup = new NativeHandle(process, handle, EnlistmentAccess.QueryInformation)) - using (EnlistmentHandle enHandle = EnlistmentHandle.FromHandle(enHandleDup)) + using (var enHandleDup = + new NativeHandle(process, handle, EnlistmentAccess.QueryInformation)) { - info.BestName = enHandle.BasicInformation.EnlistmentId.ToString("B"); + var enHandle = EnlistmentHandle.FromHandle(enHandleDup); + + info.BestName = enHandle.GetBasicInformation().EnlistmentId.ToString("B"); } } break; case "TmRm": { - using (var rmHandleDup = new NativeHandle(process, handle, ResourceManagerAccess.QueryInformation)) + using (var rmHandleDup = + new NativeHandle(process, handle, ResourceManagerAccess.QueryInformation)) { var rmHandle = ResourceManagerHandle.FromHandle(rmHandleDup); - info.BestName = rmHandle.Description; + info.BestName = rmHandle.GetDescription(); if (string.IsNullOrEmpty(info.BestName)) - info.BestName = rmHandle.Guid.ToString("B"); + info.BestName = rmHandle.GetGuid().ToString("B"); } } break; case "TmTm": { - using (NativeHandle tmHandleDup = new NativeHandle(process, handle, TmAccess.QueryInformation)) - using (TmHandle tmHandle = TmHandle.FromHandle(tmHandleDup)) + using (var tmHandleDup = + new NativeHandle(process, handle, TmAccess.QueryInformation)) { - info.BestName = FileUtils.GetFileName(FileUtils.GetFileName(tmHandle.LogFileName)); + var tmHandle = TmHandle.FromHandle(tmHandleDup); + + info.BestName = FileUtils.GetFileName(FileUtils.GetFileName(tmHandle.GetLogFileName())); if (string.IsNullOrEmpty(info.BestName)) - info.BestName = tmHandle.BasicInformation.TmIdentity.ToString("B"); + info.BestName = tmHandle.GetBasicInformation().TmIdentity.ToString("B"); } } break; case "TmTx": { - using (var transactionHandleDup = new NativeHandle(process, handle, TransactionAccess.QueryInformation)) + using (var transactionHandleDup = + new NativeHandle(process, handle, TransactionAccess.QueryInformation)) { - TransactionHandle transactionHandle = TransactionHandle.FromHandle(transactionHandleDup); + var transactionHandle = TransactionHandle.FromHandle(transactionHandleDup); - info.BestName = transactionHandle.Description; + info.BestName = transactionHandle.GetDescription(); if (string.IsNullOrEmpty(info.BestName)) - info.BestName = transactionHandle.BasicInformation.TransactionId.ToString("B"); + info.BestName = transactionHandle.GetBasicInformation().TransactionId.ToString("B"); } } break; case "Token": { - using (var tokenHandleDup = new NativeHandle(process, handle, TokenAccess.Query)) - using (TokenHandle tokenHandle = TokenHandle.FromHandle(tokenHandleDup)) - using (tokenHandle.User) + using (var tokenHandleDup = + new NativeHandle(process, handle, TokenAccess.Query)) { - info.BestName = tokenHandle.User.GetFullName(true) + ": 0x" + tokenHandle.Statistics.AuthenticationId; + var tokenHandle = TokenHandle.FromHandle(tokenHandleDup); + var sid = tokenHandle.GetUser(); + + using (sid) + info.BestName = sid.GetFullName(true) + ": 0x" + + tokenHandle.GetStatistics().AuthenticationId.ToString(); } } + break; default: - if (!string.IsNullOrEmpty(info.OrigName)) + if (info.OrigName != null && + info.OrigName != "") { info.BestName = info.OrigName; } @@ -451,7 +511,7 @@ out retLength } catch { - if (!string.IsNullOrEmpty(info.OrigName)) + if (info.OrigName != null && info.OrigName != "") { info.BestName = info.OrigName; } diff --git a/1.x/trunk/ProcessHacker.Native/Api/Functions.cs b/1.x/trunk/ProcessHacker.Native/Api/Functions.cs index 5fc47f803..51647ecdb 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/Functions.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/Functions.cs @@ -35,6 +35,7 @@ using System.Text; using System.Threading; using System.Windows.Forms; +using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; namespace ProcessHacker.Native.Api @@ -441,7 +442,7 @@ public static extern IntPtr ImageNtHeader( [In] IntPtr ImageBase ); - [DllImport("imagehlp.dll", SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true, CharSet = CharSet.Ansi)] + [DllImport("imagehlp.dll", SetLastError = true, CharSet = CharSet.Ansi)] public static extern bool MapAndLoad( [In] string ImageName, [In] [Optional] string DllPath, @@ -2590,8 +2591,8 @@ [In] UipiFilterFlag flag public static extern IntPtr SendMessage( [In] IntPtr hWnd, [In] WindowMessage msg, - [In] IntPtr w, - [In] IntPtr l + [In] int w, + [In] int l ); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] diff --git a/1.x/trunk/ProcessHacker.Native/Api/HResult.cs b/1.x/trunk/ProcessHacker.Native/Api/HResult.cs index a15542d46..b91d0cb78 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/HResult.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/HResult.cs @@ -21,6 +21,7 @@ * along with Process Hacker. If not, see . */ +using System; using System.Runtime.InteropServices; namespace ProcessHacker.Native.Api diff --git a/1.x/trunk/ProcessHacker.Native/Api/ISecurityInformation.cs b/1.x/trunk/ProcessHacker.Native/Api/ISecurityInformation.cs index 80186163b..4938bca58 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/ISecurityInformation.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/ISecurityInformation.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using System.Runtime.InteropServices; namespace ProcessHacker.Native.Api diff --git a/1.x/trunk/ProcessHacker.Native/Api/LsaFunctions.cs b/1.x/trunk/ProcessHacker.Native/Api/LsaFunctions.cs index 0e57c8493..a6a69f412 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/LsaFunctions.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/LsaFunctions.cs @@ -21,7 +21,9 @@ */ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Text; using ProcessHacker.Native.Security; namespace ProcessHacker.Native.Api diff --git a/1.x/trunk/ProcessHacker.Native/Api/LsaStructs.cs b/1.x/trunk/ProcessHacker.Native/Api/LsaStructs.cs index 2b082ff77..b5fe9b79d 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/LsaStructs.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/LsaStructs.cs @@ -21,7 +21,9 @@ */ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Text; namespace ProcessHacker.Native.Api { @@ -60,13 +62,6 @@ public struct LsaTranslatedSid2 [StructLayout(LayoutKind.Sequential)] public struct LsaTrustInformation { - public static readonly int SizeOf; - - static LsaTrustInformation() - { - SizeOf = Marshal.SizeOf(typeof(LsaTrustInformation)); - } - public UnicodeString Name; public IntPtr Sid; // Sid* } @@ -74,13 +69,6 @@ static LsaTrustInformation() [StructLayout(LayoutKind.Sequential)] public struct Msv1_0_InteractiveLogon { - public static readonly int SizeOf; - - static Msv1_0_InteractiveLogon() - { - SizeOf = Marshal.SizeOf(typeof(Msv1_0_InteractiveLogon)); - } - public Msv1_0_LogonSubmitType MessageType; public UnicodeString LogonDomainName; public UnicodeString UserName; @@ -111,13 +99,6 @@ public struct Msv1_0_InteractiveProfile [StructLayout(LayoutKind.Sequential)] public struct PolicyPrivilegeDefinition { - public static readonly int SizeOf; - - static PolicyPrivilegeDefinition() - { - SizeOf = Marshal.SizeOf(typeof(PolicyPrivilegeDefinition)); - } - public UnicodeString Name; public Luid LocalValue; } diff --git a/1.x/trunk/ProcessHacker.Native/Api/NativeDefinitions.cs b/1.x/trunk/ProcessHacker.Native/Api/NativeDefinitions.cs index fe065c3a1..f72d1a20b 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/NativeDefinitions.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/NativeDefinitions.cs @@ -84,9 +84,9 @@ public static partial class Win32 public const string TransactionManagerPath = @"\TransactionManager"; public static readonly IntPtr KnownAceSidStartOffset = Marshal.OffsetOf(typeof(KnownAceStruct), "SidStart"); - public static readonly int SecurityDescriptorMinLength = SecurityDescriptorStruct.SizeOf; + public static readonly int SecurityDescriptorMinLength = Marshal.SizeOf(typeof(SecurityDescriptorStruct)); public static readonly int SecurityMaxSidSize = - SidStruct.SizeOf - sizeof(int) + (SidMaxSubAuthorities * sizeof(int)); + Marshal.SizeOf(typeof(SidStruct)) - sizeof(int) + (SidMaxSubAuthorities * sizeof(int)); public static readonly IntPtr UserSharedData = new IntPtr(0x7ffe0000); public static int CsrMakeApiNumber(int dllIndex, int apiIndex) diff --git a/1.x/trunk/ProcessHacker.Native/Api/NativeEnums.cs b/1.x/trunk/ProcessHacker.Native/Api/NativeEnums.cs index 18b08cf76..15d0f6e64 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/NativeEnums.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/NativeEnums.cs @@ -210,7 +210,6 @@ public enum DebugObjectInformationClass : int MaxDebugObjectInfoClass } - [Flags] public enum DeviceControlAccess : int { Any = 0, @@ -425,7 +424,7 @@ public enum FileCreationDisposition : int OverwriteIf = 0x5 } - public enum FileInformationClass + public enum FileInformationClass : int { FileDirectoryInformation = 1, // dir FileFullDirectoryInformation, // dir diff --git a/1.x/trunk/ProcessHacker.Native/Api/NativeFunctions.cs b/1.x/trunk/ProcessHacker.Native/Api/NativeFunctions.cs index 02d8913f2..c571bcdf7 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/NativeFunctions.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/NativeFunctions.cs @@ -1507,15 +1507,6 @@ public static extern NtStatus NtQueryInformationToken( [Out] [Optional] out int ReturnLength ); - [DllImport("ntdll.dll")] - public static unsafe extern NtStatus NtQueryInformationToken( - [In] IntPtr TokenHandle, - [In] TokenInformationClass TokenInformationClass, - void* TokenInformation, - [In] int TokenInformationLength, - [Optional] void* ReturnLength - ); - [DllImport("ntdll.dll")] public static extern NtStatus NtQueryInformationToken( [In] IntPtr TokenHandle, @@ -1676,14 +1667,6 @@ public static extern NtStatus NtQuerySymbolicLinkObject( [Out] [Optional] out int ReturnLength ); - [DllImport("ntdll.dll")] - public static unsafe extern NtStatus NtQuerySystemInformation( - [In] SystemInformationClass SystemInformationClass, - void* SystemInformation, - [In] int SystemInformationLength, - int* ReturnLength - ); - [DllImport("ntdll.dll")] public static extern NtStatus NtQuerySystemInformation( [In] SystemInformationClass SystemInformationClass, @@ -2520,7 +2503,7 @@ [In] [Optional] ref long Timeout [DllImport("ntdll.dll", CharSet = CharSet.Unicode)] public static extern NtStatus LdrGetDllHandle( [In] [Optional] string DllPath, - [In] [Optional] int DllCharacteristics, + [In] [Optional] ref int DllCharacteristics, [In] ref UnicodeString DllName, [Out] out IntPtr DllHandle ); @@ -2528,7 +2511,7 @@ [Out] out IntPtr DllHandle [DllImport("ntdll.dll")] public static extern NtStatus LdrGetProcedureAddress( [In] IntPtr DllHandle, - [In] [Optional] IntPtr ProcedureName, + [In] [Optional] ref AnsiString ProcedureName, [In] [Optional] int ProcedureNumber, [Out] out IntPtr ProcedureAddress ); @@ -2536,7 +2519,7 @@ [Out] out IntPtr ProcedureAddress [DllImport("ntdll.dll", CharSet = CharSet.Unicode)] public static extern NtStatus LdrLoadDll( [In] [Optional] string DllPath, - [In] [Optional] int DllCharacteristics, + [In] [Optional] ref int DllCharacteristics, [In] ref UnicodeString DllName, [Out] out IntPtr DllHandle ); @@ -3311,14 +3294,6 @@ public static extern void RtlMoveMemory( [In] IntPtr Length ); - - [DllImport("ntdll.dll")] - public static extern unsafe void RtlMoveMemory( - void* Destination, - void* Source, - [In] IntPtr Length - ); - [DllImport("ntdll.dll")] public static extern void RtlZeroMemory( [In] IntPtr Destination, diff --git a/1.x/trunk/ProcessHacker.Native/Api/NativeStructs.cs b/1.x/trunk/ProcessHacker.Native/Api/NativeStructs.cs index b8a053771..243f8848f 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/NativeStructs.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/NativeStructs.cs @@ -99,13 +99,6 @@ public struct AclRevisionInformation [StructLayout(LayoutKind.Sequential)] public struct AclSizeInformation { - public static readonly int SizeOf; - - static AclSizeInformation() - { - SizeOf = Marshal.SizeOf(typeof(AclSizeInformation)); - } - public int AceCount; public int AclBytesInUse; public int AclBytesFree; @@ -126,10 +119,11 @@ public struct AnsiString : IDisposable { public AnsiString(string str) { - using (UnicodeString unicodeStr = new UnicodeString(str)) - { - this = unicodeStr.ToAnsiString(); - } + UnicodeString unicodeStr; + + unicodeStr = new UnicodeString(str); + this = unicodeStr.ToAnsiString(); + unicodeStr.Dispose(); } public ushort Length; @@ -147,9 +141,11 @@ public void Dispose() public UnicodeString ToUnicodeString() { + NtStatus status; UnicodeString unicodeStr = new UnicodeString(); - Win32.RtlAnsiStringToUnicodeString(ref unicodeStr, ref this, true).ThrowIf(); + if ((status = Win32.RtlAnsiStringToUnicodeString(ref unicodeStr, ref this, true)) >= NtStatus.Error) + Win32.Throw(status); return unicodeStr; } @@ -158,13 +154,6 @@ public UnicodeString ToUnicodeString() [StructLayout(LayoutKind.Sequential)] public struct BaseCreateProcessMsg { - public static readonly int SizeOf; - - static BaseCreateProcessMsg() - { - SizeOf = Marshal.SizeOf(typeof(BaseCreateProcessMsg)); - } - public IntPtr ProcessHandle; public IntPtr ThreadHandle; public ClientId ClientId; @@ -184,8 +173,6 @@ public struct BaseCreateThreadMsg [StructLayout(LayoutKind.Sequential)] public struct ClientId { - public static readonly int SizeOf = Marshal.SizeOf(typeof(ClientId)); - public ClientId(int processId, int threadId) { this.UniqueProcess = new IntPtr(processId); @@ -195,15 +182,8 @@ public ClientId(int processId, int threadId) public IntPtr UniqueProcess; public IntPtr UniqueThread; - public int ProcessId - { - get { return this.UniqueProcess.ToInt32(); } - } - - public int ThreadId - { - get { return this.UniqueThread.ToInt32(); } - } + public int ProcessId { get { return this.UniqueProcess.ToInt32(); } } + public int ThreadId { get { return this.UniqueThread.ToInt32(); } } } [StructLayout(LayoutKind.Sequential)] @@ -262,13 +242,6 @@ public struct Context [StructLayout(LayoutKind.Sequential)] public struct ContextAmd64 { - public static readonly int SizeOf; - - static ContextAmd64() - { - SizeOf = Marshal.SizeOf(typeof(ContextAmd64)); - } - public long P1Home; public long P2Home; public long P3Home; @@ -454,13 +427,6 @@ public struct DbgUiWaitStateChange [StructLayout(LayoutKind.Sequential)] public struct EnlistmentBasicInformation { - public static readonly int SizeOf; - - static EnlistmentBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(EnlistmentBasicInformation)); - } - public Guid EnlistmentId; public Guid TransactionId; public Guid ResourceManagerId; @@ -469,13 +435,6 @@ static EnlistmentBasicInformation() [StructLayout(LayoutKind.Sequential)] public struct EventBasicInformation { - public static readonly int SizeOf; - - static EventBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(EventBasicInformation)); - } - public EventType EventType; public int EventState; } @@ -521,13 +480,6 @@ public struct FileAllInformation [StructLayout(LayoutKind.Sequential)] public struct FileBasicInformation { - public static readonly int SizeOf; - - static FileBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileBasicInformation)); - } - public long CreationTime; public long LastAccessTime; public long LastWriteTime; @@ -538,13 +490,6 @@ static FileBasicInformation() [StructLayout(LayoutKind.Sequential)] public struct FileCompletionInformation { - public static readonly int SizeOf; - - static FileCompletionInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileCompletionInformation)); - } - public IntPtr Port; public IntPtr Key; } @@ -552,14 +497,8 @@ static FileCompletionInformation() [StructLayout(LayoutKind.Sequential)] public struct FileDirectoryInformation { - public static readonly int SizeOf; - public static readonly int FileNameOffset; - - static FileDirectoryInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileDirectoryInformation)); - FileNameOffset = Marshal.OffsetOf(typeof(FileDirectoryInformation), "FileName").ToInt32(); - } + public static int FileNameOffset = + Marshal.OffsetOf(typeof(FileDirectoryInformation), "FileName").ToInt32(); public int NextEntryOffset; public int FileIndex; @@ -578,13 +517,6 @@ static FileDirectoryInformation() [StructLayout(LayoutKind.Sequential)] public struct FileDispositionInformation { - public static readonly int SizeOf; - - static FileDispositionInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileDispositionInformation)); - } - [MarshalAs(UnmanagedType.I1)] public bool DeleteFile; } @@ -598,28 +530,12 @@ public struct FileEaInformation [StructLayout(LayoutKind.Sequential)] public struct FileEndOfFileInformation { - public static readonly int SizeOf; - - static FileEndOfFileInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileEndOfFileInformation)); - } - public long EndOfFile; } [StructLayout(LayoutKind.Sequential)] public struct FileFsAttributeInformation { - public static readonly int SizeOf; - public static readonly int FileSystemNameOffset; - - static FileFsAttributeInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileFsAttributeInformation)); - FileSystemNameOffset = Marshal.OffsetOf(typeof(FileFsAttributeInformation), "FileSystemName").ToInt32(); - } - public int FileSystemAttributes; public int MaximumComponentNameLength; public int FileSystemNameLength; @@ -638,22 +554,11 @@ public struct FileFsLabelInformation [StructLayout(LayoutKind.Sequential)] public struct FileFsVolumeInformation { - public static readonly int SizeOf; - public static readonly int VolumeLabelOffset; - - static FileFsVolumeInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileFsVolumeInformation)); - VolumeLabelOffset = Marshal.OffsetOf(typeof(FileFsVolumeInformation), "VolumeLabel").ToInt32(); - } - public long VolumeCreationTime; public int VolumeSerialNumber; public int VolumeLabelLength; - [MarshalAs(UnmanagedType.I1)] public bool SupportsObjects; - public short VolumeLabel; // Volume label string follows (WCHAR). } @@ -689,14 +594,8 @@ public struct FileModeInformation [StructLayout(LayoutKind.Sequential)] public struct FileNameInformation { - public static readonly int SizeOf; - public static int FileNameOffset; - - static FileNameInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileNameInformation)); - FileNameOffset = Marshal.OffsetOf(typeof(FileNameInformation), "FileName").ToInt32(); - } + public static int FileNameOffset = + Marshal.OffsetOf(typeof(FileNameInformation), "FileName").ToInt32(); public int FileNameLength; public short FileName; @@ -729,13 +628,6 @@ public struct FileNotifyInformation [StructLayout(LayoutKind.Sequential)] public struct FilePipeInformation { - public static readonly int SizeOf; - - static FilePipeInformation() - { - SizeOf = Marshal.SizeOf(typeof(FilePipeInformation)); - } - public PipeType ReadMode; public PipeCompletionMode CompletionMode; } @@ -743,13 +635,6 @@ static FilePipeInformation() [StructLayout(LayoutKind.Sequential)] public struct FilePipeLocalInformation { - public static readonly int SizeOf; - - static FilePipeLocalInformation() - { - SizeOf = Marshal.SizeOf(typeof(FilePipeLocalInformation)); - } - public PipeType NamedPipeType; public PipeConfiguration NamedPipeConfiguration; public int MaximumInstances; @@ -791,33 +676,17 @@ public struct FilePipeWaitForBuffer [StructLayout(LayoutKind.Sequential)] public struct FilePositionInformation { - public static readonly int SizeOf; - - static FilePositionInformation() - { - SizeOf = Marshal.SizeOf(typeof(FilePositionInformation)); - } - public long CurrentByteOffset; } [StructLayout(LayoutKind.Sequential)] public struct FileStandardInformation { - public static readonly int SizeOf; - - static FileStandardInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileStandardInformation)); - } - public long AllocationSize; public long EndOfFile; public int NumberOfLinks; - [MarshalAs(UnmanagedType.I1)] public bool DeletePending; - [MarshalAs(UnmanagedType.I1)] public bool Directory; } @@ -825,14 +694,8 @@ static FileStandardInformation() [StructLayout(LayoutKind.Sequential)] public struct FileStreamInformation { - public static readonly int SizeOf; - public static int StreamNameOffset; - - static FileStreamInformation() - { - SizeOf = Marshal.SizeOf(typeof(FileStreamInformation)); - StreamNameOffset = Marshal.OffsetOf(typeof(FileStreamInformation), "StreamName").ToInt32(); - } + public static int StreamNameOffset = + Marshal.OffsetOf(typeof(FileStreamInformation), "StreamName").ToInt32(); public int NextEntryOffset; public int StreamNameLength; @@ -1155,13 +1018,6 @@ public struct IoCompletionBasicInformation [StructLayout(LayoutKind.Sequential)] public struct IoCounters { - public static readonly int SizeOf; - - static IoCounters() - { - SizeOf = Marshal.SizeOf(typeof(IoCounters)); - } - public ulong ReadOperationCount; public ulong WriteOperationCount; public ulong OtherOperationCount; @@ -1173,13 +1029,6 @@ static IoCounters() [StructLayout(LayoutKind.Sequential)] public struct IoStatusBlock { - public static readonly int SizeOf; - - static IoStatusBlock() - { - SizeOf = Marshal.SizeOf(typeof(IoStatusBlock)); - } - public IoStatusBlock(NtStatus status) : this(status, IntPtr.Zero) { } @@ -1222,8 +1071,6 @@ public unsafe NtStatus Status [StructLayout(LayoutKind.Sequential)] public struct JobObjectBasicAccountingInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(JobObjectBasicAccountingInformation)); - public long TotalUserTime; public long TotalKernelTime; public long ThisPeriodTotalUserTime; @@ -1237,8 +1084,6 @@ public struct JobObjectBasicAccountingInformation [StructLayout(LayoutKind.Sequential)] public struct JobObjectBasicAndIoAccountingInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(JobObjectBasicAndIoAccountingInformation)); - public JobObjectBasicAccountingInformation BasicInfo; public IoCounters IoInfo; } @@ -1246,8 +1091,6 @@ public struct JobObjectBasicAndIoAccountingInformation [StructLayout(LayoutKind.Sequential)] public struct JobObjectBasicLimitInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(JobObjectBasicLimitInformation)); - public long PerProcessUserTimeLimit; public long PerJobUserTimeLimit; public JobObjectLimitFlags LimitFlags; @@ -1276,13 +1119,6 @@ public struct JobObjectEndOfJobTimeInformation [StructLayout(LayoutKind.Sequential)] public struct JobObjectExtendedLimitInformation { - public static readonly int SizeOf; - - static JobObjectExtendedLimitInformation() - { - SizeOf = Marshal.SizeOf(typeof(JobObjectExtendedLimitInformation)); - } - public JobObjectBasicLimitInformation BasicLimitInformation; public IoCounters IoInfo; public int ProcessMemoryLimit; @@ -1423,13 +1259,6 @@ public struct KeyWriteTimeInformation [StructLayout(LayoutKind.Sequential)] public struct KnownAceStruct { - public static readonly int SizeOf; - - static KnownAceStruct() - { - SizeOf = Marshal.SizeOf(typeof(KnownAceStruct)); - } - public AceHeader Header; public int Mask; public int SidStart; @@ -1551,14 +1380,8 @@ public LargeInteger(long quadPart) [StructLayout(LayoutKind.Sequential)] public struct LdrDataTableEntry { - public static readonly int SizeOf; - public static readonly int LoadCountOffset; - - static LdrDataTableEntry() - { - SizeOf = Marshal.SizeOf(typeof(LdrDataTableEntry)); - LoadCountOffset = Marshal.OffsetOf(typeof(LdrDataTableEntry), "LoadCount").ToInt32(); - } + public static readonly int LoadCountOffset = + Marshal.OffsetOf(typeof(LdrDataTableEntry), "LoadCount").ToInt32(); public ListEntry InLoadOrderLinks; public ListEntry InMemoryOrderLinks; @@ -1591,22 +1414,12 @@ public struct ListEntry [StructLayout(LayoutKind.Explicit, Pack = 4)] public struct Luid : IEquatable, IEquatable { - public static readonly int SizeOf; - public static readonly Luid Empty; + public static readonly Luid Empty = new Luid(); public static readonly Luid System = new Luid(0x3e7, 0); public static readonly Luid AnonymousLogon = new Luid(0x3e6, 0); public static readonly Luid LocalService = new Luid(0x3e5, 0); public static readonly Luid NetworkService = new Luid(0x3e4, 0); - static Luid() - { - SizeOf = Marshal.SizeOf(typeof(Luid)); - System = new Luid(0x3e7, 0); - AnonymousLogon = new Luid(0x3e6, 0); - LocalService = new Luid(0x3e5, 0); - NetworkService = new Luid(0x3e4, 0); - } - /// /// Creates a LUID from a single 64-bit value. /// @@ -1653,9 +1466,11 @@ public Luid(uint lowPart, int highPart) /// A new LUID. public static Luid Allocate() { + NtStatus status; Luid luid; - Win32.NtAllocateLocallyUniqueId(out luid).ThrowIf(); + if ((status = Win32.NtAllocateLocallyUniqueId(out luid)) >= NtStatus.Error) + Win32.Throw(status); return luid; } @@ -1712,18 +1527,9 @@ public struct MessageResourceEntry [StructLayout(LayoutKind.Sequential)] public struct MutantBasicInformation { - public static readonly int SizeOf; - - static MutantBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(MutantBasicInformation)); - } - public int CurrentCount; - [MarshalAs(UnmanagedType.U1)] public bool OwnedByCaller; - [MarshalAs(UnmanagedType.U1)] public bool AbandonedState; } @@ -1731,13 +1537,6 @@ static MutantBasicInformation() [StructLayout(LayoutKind.Sequential)] public struct MutantOwnerInformation { - public static readonly int SizeOf; - - static MutantOwnerInformation() - { - SizeOf = Marshal.SizeOf(typeof(MutantOwnerInformation)); - } - public ClientId ClientId; } @@ -1756,8 +1555,6 @@ public struct NtTib [StructLayout(LayoutKind.Sequential)] public struct ObjectAttributes : IDisposable { - public static readonly int SizeOf = Marshal.SizeOf(typeof(ObjectAttributes)); - public ObjectAttributes( string objectName, ObjectFlags attributes, @@ -1773,17 +1570,17 @@ public ObjectAttributes( SecurityQualityOfService? securityQos ) { - this.Length = SizeOf; + this.Length = Marshal.SizeOf(typeof(ObjectAttributes)); this.RootDirectory = IntPtr.Zero; this.ObjectName = IntPtr.Zero; - this.PtrSecurityDescriptor = IntPtr.Zero; - this.PtrSecurityQualityOfService = IntPtr.Zero; + this.SecurityDescriptor = IntPtr.Zero; + this.SecurityQualityOfService = IntPtr.Zero; // Object name - if (!string.IsNullOrEmpty(objectName)) + if (objectName != null) { UnicodeString unicodeString = new UnicodeString(objectName); - IntPtr unicodeStringMemory = MemoryAlloc.PrivateHeap.Allocate(UnicodeString.SizeOf); + IntPtr unicodeStringMemory = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(UnicodeString))); Marshal.StructureToPtr(unicodeString, unicodeStringMemory, false); this.ObjectName = unicodeStringMemory; @@ -1797,13 +1594,13 @@ public ObjectAttributes( this.RootDirectory = rootDirectory; // Security descriptor - this.PtrSecurityDescriptor = securityDescriptor ?? IntPtr.Zero; + this.SecurityDescriptor = securityDescriptor ?? IntPtr.Zero; // Security QOS if (securityQos.HasValue) { - this.PtrSecurityQualityOfService = MemoryAlloc.PrivateHeap.Allocate(SecurityQualityOfService.SizeOf); - Marshal.StructureToPtr(securityQos.Value, this.PtrSecurityQualityOfService, false); + this.SecurityQualityOfService = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SecurityQualityOfService))); + Marshal.StructureToPtr(securityQos.Value, this.SecurityQualityOfService, false); } } @@ -1811,23 +1608,28 @@ public ObjectAttributes( public IntPtr RootDirectory; public IntPtr ObjectName; public ObjectFlags Attributes; - public IntPtr PtrSecurityDescriptor; - public IntPtr PtrSecurityQualityOfService; + public IntPtr SecurityDescriptor; + public IntPtr SecurityQualityOfService; public void Dispose() { // Object name if (this.ObjectName != IntPtr.Zero) { - MemoryAlloc.PrivateHeap.Free(this.ObjectName); + UnicodeString unicodeString = + (UnicodeString)Marshal.PtrToStructure(this.ObjectName, typeof(UnicodeString)); + + unicodeString.Dispose(); + Marshal.FreeHGlobal(this.ObjectName); + this.ObjectName = IntPtr.Zero; } // Security QOS - if (this.PtrSecurityQualityOfService != IntPtr.Zero) + if (this.SecurityQualityOfService != null) { - MemoryAlloc.PrivateHeap.Free(this.PtrSecurityQualityOfService); - this.PtrSecurityQualityOfService = IntPtr.Zero; + Marshal.FreeHGlobal(this.SecurityQualityOfService); + this.SecurityQualityOfService = IntPtr.Zero; } } } @@ -1835,13 +1637,6 @@ public void Dispose() [StructLayout(LayoutKind.Sequential)] public struct ObjectBasicInformation { - public static readonly int SizeOf; - - static ObjectBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(ObjectBasicInformation)); - } - public uint Attributes; public int GrantedAccess; public uint HandleCount; @@ -1856,30 +1651,15 @@ static ObjectBasicInformation() public uint TypeInformationLength; public uint SecurityDescriptorLength; public ulong CreateTime; - } [StructLayout(LayoutKind.Sequential)] public struct ObjectDirectoryInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(ObjectDirectoryInformation)); - public UnicodeString Name; public UnicodeString TypeName; } - [StructLayout(LayoutKind.Sequential)] - public struct ObjectHandleFlagInformation - { - public static readonly int SizeOf = Marshal.SizeOf(typeof(ObjectHandleFlagInformation)); - - [MarshalAs(UnmanagedType.Bool)] - public bool Inherit; - - [MarshalAs(UnmanagedType.Bool)] - public bool ProtectFromClose; - } - [StructLayout(LayoutKind.Sequential)] public struct ObjectNameInformation { @@ -2017,13 +1797,6 @@ public struct Peb [StructLayout(LayoutKind.Sequential)] public struct PebLdrData { - public static readonly int SizeOf; - - static PebLdrData() - { - SizeOf = Marshal.SizeOf(typeof(PebLdrData)); - } - public int Length; [MarshalAs(UnmanagedType.I1)] public bool Initialized; @@ -2050,13 +1823,6 @@ public struct PooledUsageAndLimits [StructLayout(LayoutKind.Sequential)] public struct PortMessageStruct { - public static readonly int SizeOf; - - static PortMessageStruct() - { - SizeOf = Marshal.SizeOf(typeof(PortMessageStruct)); - } - public short DataLength; public short TotalLength; public PortMessageType Type; @@ -2080,7 +1846,7 @@ public struct PortView [StructLayout(LayoutKind.Sequential)] public struct PrivilegeSetStruct { - public static readonly int PrivilegesOffset = + public static int PrivilegesOffset = Marshal.OffsetOf(typeof(PrivilegeSetStruct), "Privileges").ToInt32(); public int Count; @@ -2091,8 +1857,6 @@ public struct PrivilegeSetStruct [StructLayout(LayoutKind.Sequential)] public struct ProcessBasicInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(ProcessBasicInformation)); - public NtStatus ExitStatus; public IntPtr PebBaseAddress; public IntPtr AffinityMask; @@ -2111,8 +1875,6 @@ public struct ProcessForegroundBackground [StructLayout(LayoutKind.Sequential)] public struct ProcessHandleTracingEnable { - public static readonly int SizeOf = Marshal.SizeOf(typeof(ProcessHandleTracingEnable)); - public int Flags; // No flags. Set to 0. } @@ -2126,13 +1888,6 @@ public struct ProcessHandleTracingEnableEx [StructLayout(LayoutKind.Sequential)] public struct ProcessHandleTracingEntry { - public static readonly int SizeOf; - - static ProcessHandleTracingEntry() - { - SizeOf = Marshal.SizeOf(typeof(ProcessHandleTracingEntry)); - } - public IntPtr Handle; public ClientId ClientId; public HandleTraceType Type; @@ -2156,16 +1911,9 @@ public struct ProcessHandleTracingQuery [StructLayout(LayoutKind.Sequential)] public struct ProcessPriorityClassStruct { - public static readonly int SizeOf; - //the type char is set by the CLR runtime to marshal as Ansi (single byte) for some insane reason... public char Foreground; public char PriorityClass; - - static ProcessPriorityClassStruct() - { - SizeOf = Marshal.SizeOf(typeof(ProcessPriorityClassStruct)); - } } [StructLayout(LayoutKind.Sequential)] @@ -2267,13 +2015,6 @@ public struct RtlHandleTable [StructLayout(LayoutKind.Sequential)] public struct RtlHeapInformation { - public static readonly int SizeOf; - - static RtlHeapInformation() - { - SizeOf = Marshal.SizeOf(typeof(RtlHeapInformation)); - } - public IntPtr BaseAddress; public int Flags; public ushort EntryOverhead; @@ -2327,13 +2068,6 @@ public struct RtlProcessHeaps [StructLayout(LayoutKind.Sequential)] public struct RtlProcessLockInformation { - public static readonly int SizeOf; - - static RtlProcessLockInformation() - { - SizeOf = Marshal.SizeOf(typeof(RtlProcessLockInformation)); - } - public IntPtr Address; public RtlLockType Type; public ushort CreatorBackTraceInformation; @@ -2362,13 +2096,6 @@ public struct RtlProcessLocks [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct RtlProcessModuleInformation { - public static readonly int SizeOf; - - static RtlProcessModuleInformation() - { - SizeOf = Marshal.SizeOf(typeof(RtlProcessModuleInformation)); - } - public IntPtr Section; // empty public IntPtr MappedBase; public IntPtr ImageBase; @@ -2406,32 +2133,26 @@ public struct RtlUserProcessInformation [StructLayout(LayoutKind.Sequential)] public struct RtlUserProcessParameters { - public static readonly int SizeOf; - public static readonly int CurrentDirectoryOffset; - public static readonly int DllPathOffset; - public static readonly int ImagePathNameOffset; - public static readonly int CommandLineOffset; - public static readonly int EnvironmentOffset; - public static readonly int WindowTitleOffset; - public static readonly int DesktopInfoOffset; - public static readonly int ShellInfoOffset; - public static readonly int RuntimeDataOffset; - public static readonly int CurrentDirectoriesOffset; - - static RtlUserProcessParameters() - { - SizeOf = Marshal.SizeOf(typeof(RtlUserProcessParameters)); - CurrentDirectoryOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "CurrentDirectory").ToInt32(); - DllPathOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "DllPath").ToInt32(); - ImagePathNameOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "ImagePathName").ToInt32(); - CommandLineOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "CommandLine").ToInt32(); - EnvironmentOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "Environment").ToInt32(); - WindowTitleOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "WindowTitle").ToInt32(); - DesktopInfoOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "DesktopInfo").ToInt32(); - ShellInfoOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "ShellInfo").ToInt32(); - RuntimeDataOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "RuntimeData").ToInt32(); - CurrentDirectoriesOffset = Marshal.OffsetOf(typeof(RtlUserProcessParameters), "CurrentDirectories").ToInt32(); - } + public static readonly int CurrentDirectoryOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "CurrentDirectory").ToInt32(); + public static readonly int DllPathOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "DllPath").ToInt32(); + public static readonly int ImagePathNameOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "ImagePathName").ToInt32(); + public static readonly int CommandLineOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "CommandLine").ToInt32(); + public static readonly int EnvironmentOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "Environment").ToInt32(); + public static readonly int WindowTitleOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "WindowTitle").ToInt32(); + public static readonly int DesktopInfoOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "DesktopInfo").ToInt32(); + public static readonly int ShellInfoOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "ShellInfo").ToInt32(); + public static readonly int RuntimeDataOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "RuntimeData").ToInt32(); + public static readonly int CurrentDirectoriesOffset = + Marshal.OffsetOf(typeof(RtlUserProcessParameters), "CurrentDirectories").ToInt32(); public struct CurDir { @@ -2488,23 +2209,14 @@ public struct RtlDriveLetterCurDir [StructLayout(LayoutKind.Sequential)] public struct SectionBasicInformation { - public static readonly int SizeOf; - public int Unknown; public SectionAttributes SectionAttributes; public long SectionSize; - - static SectionBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(SectionBasicInformation)); - } } [StructLayout(LayoutKind.Sequential)] public struct SectionImageInformation { - public static readonly int SizeOf; - public IntPtr TransferAddress; public int StackZeroBits; public IntPtr StackReserved; @@ -2523,18 +2235,11 @@ public struct SectionImageInformation public int LoaderFlags; public int ImageFileSize; public int Reserved; - - static SectionImageInformation() - { - SizeOf = Marshal.SizeOf(typeof(SectionImageInformation)); - } } [StructLayout(LayoutKind.Sequential)] public struct SecurityDescriptorStruct { - public static readonly int SizeOf = Marshal.SizeOf(typeof(SecurityDescriptorStruct)); - public byte Revision; public byte Sbz1; public SecurityDescriptorControlFlags Control; @@ -2559,15 +2264,13 @@ public struct SecurityDescriptorRelativeStruct [StructLayout(LayoutKind.Sequential)] public struct SecurityQualityOfService { - public static readonly int SizeOf = Marshal.SizeOf(typeof(SecurityQualityOfService)); - public SecurityQualityOfService( SecurityImpersonationLevel impersonationLevel, bool dynamicTracking, bool effectiveOnly ) { - this.Length = SizeOf; + this.Length = Marshal.SizeOf(typeof(SecurityQualityOfService)); this.ImpersonationLevel = impersonationLevel; this.ContextTrackingMode = dynamicTracking; this.EffectiveOnly = effectiveOnly; @@ -2584,27 +2287,13 @@ bool effectiveOnly [StructLayout(LayoutKind.Sequential)] public struct SemaphoreBasicInformation { - public static readonly int SizeOf; - public int CurrentCount; public int MaximumCount; - - static SemaphoreBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(SemaphoreBasicInformation)); - } } [StructLayout(LayoutKind.Sequential)] public struct SidStruct { - public static readonly int SizeOf; - - static SidStruct() - { - SizeOf = Marshal.SizeOf(typeof(SidStruct)); - } - public byte Revision; public byte SubAuthorityCount; public SidIdentifierAuthority IdentifierAuthority; @@ -2615,13 +2304,6 @@ static SidStruct() [StructLayout(LayoutKind.Sequential)] public struct SidAndAttributes { - public static readonly int SizeOf; - - static SidAndAttributes() - { - SizeOf = Marshal.SizeOf(typeof(SidAndAttributes)); - } - public IntPtr Sid; // ptr to a SID object public SidAttributes Attributes; @@ -2656,8 +2338,6 @@ public struct SystemAuditAceStruct [StructLayout(LayoutKind.Sequential)] public struct SystemBasicInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(SystemBasicInformation)); - public int Reserved; public int TimerResolution; public int PageSize; @@ -2674,8 +2354,6 @@ public struct SystemBasicInformation [StructLayout(LayoutKind.Sequential)] public struct SystemCacheInformation { - public static readonly int SizeOf; - /// /// The size of the system working set, in bytes. /// @@ -2696,11 +2374,6 @@ public struct SystemCacheInformation public IntPtr TransitionSharedPagesPeak; public int TransitionRePurposeCount; public int Flags; - - static SystemCacheInformation() - { - SizeOf = Marshal.SizeOf(typeof(SystemCacheInformation)); - } } [StructLayout(LayoutKind.Sequential)] @@ -2730,21 +2403,13 @@ public struct SystemHandleEntry [StructLayout(LayoutKind.Sequential)] public struct SystemHandleInformation { - public static readonly int HandlesOffset = Marshal.OffsetOf(typeof(SystemHandleInformation), "Handles").ToInt32(); + public static readonly int HandlesOffset = + Marshal.OffsetOf(typeof(SystemHandleInformation), "Handles").ToInt32(); public int NumberOfHandles; public SystemHandleEntry Handles; } - [StructLayout(LayoutKind.Sequential)] - public struct SystemProcessImageNameInformation - { - public static readonly int SizeOf = Marshal.SizeOf(typeof(SystemProcessImageNameInformation)); - - public int ProcessId; - public UnicodeString ImageName; - } - [StructLayout(LayoutKind.Sequential)] public struct SystemLoadAndCallImage { @@ -2785,13 +2450,6 @@ public struct SystemObjectTypeInformation [StructLayout(LayoutKind.Sequential)] public struct SystemPagefileInformation { - public static readonly int SizeOf; - - static SystemPagefileInformation() - { - SizeOf = Marshal.SizeOf(typeof(SystemPagefileInformation)); - } - public int NextEntryOffset; public int TotalSize; public int TotalInUse; @@ -2802,12 +2460,7 @@ static SystemPagefileInformation() [StructLayout(LayoutKind.Sequential)] public struct SystemPerformanceInformation { - public static readonly int SizeOf; - - static SystemPerformanceInformation() - { - SizeOf = Marshal.SizeOf(typeof(SystemPerformanceInformation)); - } + public static readonly int Size = Marshal.SizeOf(typeof(SystemPerformanceInformation)); /// /// The total idle time of all processors in units of 100-nanoseconds. @@ -2828,196 +2481,194 @@ static SystemPerformanceInformation() /// /// Number of calls to NtReadFile. /// - public uint IoReadOperationCount; + public int IoReadOperationCount; /// /// Number of calls to NtWriteFile. /// - public uint IoWriteOperationCount; + public int IoWriteOperationCount; /// /// Number of calls to other I/O functions. /// - public uint IoOtherOperationCount; + public int IoOtherOperationCount; /// /// The number of pages of physical memory available. /// - public uint AvailablePages; + public int AvailablePages; /// /// The number of pages of committed virtual memory. /// - public uint CommittedPages; + public int CommittedPages; /// /// The number of pages of virtual memory that could be committed /// without extending the system's pagefiles. /// - public uint CommitLimit; + public int CommitLimit; /// /// The peak number of pages of committed virtual memory. /// - public uint PeakCommitment; + public int PeakCommitment; /// /// The total number of soft and hard page faults. /// - public uint PageFaultCount; + public int PageFaultCount; /// /// The number of copy-on-write page faults. /// - public uint CopyOnWriteCount; + public int CopyOnWriteCount; /// /// The number of soft page faults. /// - public uint TransitionCount; + public int TransitionCount; /// /// Something that the Native API reference book doesn't have. /// - public uint CacheTransitionCount; + public int CacheTransitionCount; /// /// The number of demand zero faults. /// - public uint DemandZeroCount; + public int DemandZeroCount; /// /// The number of pages read from disk to resolve page faults. /// - public uint PageReadCount; + public int PageReadCount; /// /// The number of read operations initiated to resolve page faults. /// - public uint PageReadIoCount; - public uint CacheReadCount; - public uint CacheIoCount; + public int PageReadIoCount; + public int CacheReadCount; + public int CacheIoCount; /// /// The number of pages written to the system's pagefiles. /// - public uint DirtyPagesWriteCount; + public int DirtyPagesWriteCount; /// /// The number of write operations performed on the system's pagefiles. /// - public uint DirtyWriteIoCount; + public int DirtyWriteIoCount; /// /// The number of pages written to mapped files. /// - public uint MappedPagesWriteCount; + public int MappedPagesWriteCount; /// /// The number of write operations performed on mapped files. /// - public uint MappedWriteIoCount; + public int MappedWriteIoCount; /// /// The number of pages used by the paged pool. /// - public uint PagedPoolPages; + public int PagedPoolPages; /// /// The number of pages used by the non-paged pool. /// - public uint NonPagedPoolPages; + public int NonPagedPoolPages; /// /// The number of allocations made from the paged pool. /// - public uint PagedPoolAllocs; + public int PagedPoolAllocs; /// /// The number of allocations returned to the paged pool. /// - public uint PagedPoolFrees; + public int PagedPoolFrees; /// /// The number of allocations made from the non-paged pool. /// - public uint NonPagedPoolAllocs; + public int NonPagedPoolAllocs; /// /// The number of allocations returned to the non-paged pool. /// - public uint NonPagedPoolFrees; + public int NonPagedPoolFrees; /// /// The number of available System Page Table Entries. /// - public uint FreeSystemPtes; + public int FreeSystemPtes; /// /// The number of pages of pageable OS code and data in physical /// memory. /// - public uint ResidentSystemCodePage; + public int ResidentSystemCodePage; /// /// The number of pages of pageable driver code and data. /// - public uint TotalSystemDriverPages; + public int TotalSystemDriverPages; /// /// The number of pages of OS driver code and data. /// - public uint TotalSystemCodePages; + public int TotalSystemCodePages; /// /// The number of times an allocation could be statisfied by one of the /// small non-paged lookaside lists. /// - public uint NonPagedPoolLookasideHits; + public int NonPagedPoolLookasideHits; /// /// The number of times an allocation could be statisfied by one of the /// small paged lookaside lists. /// - public uint PagedPoolLookasideHits; + public int PagedPoolLookasideHits; /// /// The number of pages available for use by the paged pool. /// - public uint AvailablePagedPoolPages; + public int AvailablePagedPoolPages; /// /// The number of pages of the system cache in physical memory. /// - public uint ResidentSystemCachePage; + public int ResidentSystemCachePage; /// /// The number of pages of the paged pool in physical memory. /// - public uint ResidentPagedPoolPage; + public int ResidentPagedPoolPage; /// /// The number of pages of pageable driver code and data in physical memory. /// - public uint ResidentSystemDriverPage; + public int ResidentSystemDriverPage; /// /// The number of asynchronous fast read operations. /// - public uint CcFastReadNoWait; + public int CcFastReadNoWait; /// /// The number of synchronous fast read operations. /// - public uint CcFastReadWait; + public int CcFastReadWait; /// /// The number of fast read operations not possible because of resource /// conflicts. /// - public uint CcFastReadResourceMiss; - public uint CcFastReadNotPossible; - public uint CcFastMdlReadNoWait; - public uint CcFastMdlReadWait; - public uint CcFastMdlReadResourceMiss; - public uint CcFastMdlReadNotPossible; - public uint CcMapDataNoWait; - public uint CcMapDataWait; - public uint CcMapDataNoWaitMiss; - public uint CcMapDataWaitMiss; - public uint CcPinMappedDataCount; - public uint CcPinReadNoWait; - public uint CcPinReadWait; - public uint CcPinReadNoWaitMiss; - public uint CcPinReadWaitMiss; - public uint CcCopyReadNoWait; - public uint CcCopyReadWait; - public uint CcCopyReadNoWaitMiss; - public uint CcCopyReadWaitMiss; - public uint CcMdlReadNoWait; - public uint CcMdlReadWait; - public uint CcMdlReadNoWaitMiss; - public uint CcMdlReadWaitMiss; - public uint CcReadAheadIos; - public uint CcLazyWriteIos; - public uint CcLazyWritePages; - public uint CcDataFlushes; - public uint CcDataPages; - public uint ContextSwitches; - public uint FirstLevelTbFills; - public uint SecondLevelTbFills; - public uint SystemCalls; + public int CcFastReadResourceMiss; + public int CcFastReadNotPossible; + public int CcFastMdlReadNoWait; + public int CcFastMdlReadWait; + public int CcFastMdlReadResourceMiss; + public int CcFastMdlReadNotPossible; + public int CcMapDataNoWait; + public int CcMapDataWait; + public int CcMapDataNoWaitMiss; + public int CcMapDataWaitMiss; + public int CcPinMappedDataCount; + public int CcPinReadNoWait; + public int CcPinReadWait; + public int CcPinReadNoWaitMiss; + public int CcPinReadWaitMiss; + public int CcCopyReadNoWait; + public int CcCopyReadWait; + public int CcCopyReadNoWaitMiss; + public int CcCopyReadWaitMiss; + public int CcMdlReadNoWait; + public int CcMdlReadWait; + public int CcMdlReadNoWaitMiss; + public int CcMdlReadWaitMiss; + public int CcReadAheadIos; + public int CcLazyWriteIos; + public int CcLazyWritePages; + public int CcDataFlushes; + public int CcDataPages; + public int ContextSwitches; + public int FirstLevelTbFills; + public int SecondLevelTbFills; + public int SystemCalls; } [StructLayout(LayoutKind.Sequential)] public struct SystemProcessInformation { - public static readonly int SizeOf; - public int NextEntryOffset; public int NumberOfThreads; public long SpareLi1; @@ -3047,23 +2698,11 @@ public int InheritedFromProcessId get { return _inheritedFromProcessId.ToInt32(); } set { _inheritedFromProcessId = value.ToIntPtr(); } } - - static SystemProcessInformation() - { - SizeOf = Marshal.SizeOf(typeof(SystemProcessInformation)); - } } [StructLayout(LayoutKind.Sequential)] public struct SystemProcessorPerformanceInformation { - public static readonly int SizeOf; - - static SystemProcessorPerformanceInformation() - { - SizeOf = Marshal.SizeOf(typeof(SystemProcessorPerformanceInformation)); - } - public long IdleTime; public long KernelTime; public long UserTime; @@ -3083,13 +2722,6 @@ public struct SystemSessionProcessInformation [StructLayout(LayoutKind.Sequential)] public struct SystemThreadInformation { - public static readonly int SizeOf; - - static SystemThreadInformation() - { - SizeOf = Marshal.SizeOf(typeof(SystemThreadInformation)); - } - public long KernelTime; public long UserTime; public long CreateTime; @@ -3106,8 +2738,6 @@ static SystemThreadInformation() [StructLayout(LayoutKind.Sequential)] public struct SystemTimeOfDayInformation { - public static readonly int SizeOf; - public long BootTime; public long CurrentTime; public long TimeZoneBias; @@ -3115,11 +2745,6 @@ public struct SystemTimeOfDayInformation public int Reserved; public long BootTimeBias; public long SleepTimeBias; - - static SystemTimeOfDayInformation() - { - SizeOf = Marshal.SizeOf(typeof(SystemTimeOfDayInformation)); - } } [StructLayout(LayoutKind.Sequential)] @@ -3146,8 +2771,6 @@ public unsafe struct Teb [StructLayout(LayoutKind.Sequential)] public struct ThreadBasicInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(ThreadBasicInformation)); - public NtStatus ExitStatus; public IntPtr TebBaseAddress; public ClientId ClientId; @@ -3159,13 +2782,6 @@ public struct ThreadBasicInformation [StructLayout(LayoutKind.Sequential)] public struct TimerBasicInformation { - public static readonly int SizeOf; - - static TimerBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(TimerBasicInformation)); - } - public LargeInteger RemainingTime; [MarshalAs(UnmanagedType.I1)] public bool TimerState; @@ -3174,13 +2790,6 @@ static TimerBasicInformation() [StructLayout(LayoutKind.Sequential)] public struct TmBasicInformation { - public static readonly int SizeOf; - - static TmBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(TmBasicInformation)); - } - public Guid TmIdentity; public long VirtualClock; } @@ -3188,13 +2797,6 @@ static TmBasicInformation() [StructLayout(LayoutKind.Sequential)] public struct TmLogInformation { - public static readonly int SizeOf; - - static TmLogInformation() - { - SizeOf = Marshal.SizeOf(typeof(TmLogInformation)); - } - public Guid LogIdentity; } @@ -3218,13 +2820,6 @@ public struct TmLogPathInformation [StructLayout(LayoutKind.Sequential)] public struct TmRecoveryInformation { - public static readonly int SizeOf; - - static TmRecoveryInformation() - { - SizeOf = Marshal.SizeOf(typeof(TmRecoveryInformation)); - } - public long LastRecoveredLsn; } @@ -3242,14 +2837,8 @@ public TokenDefaultDacl(Acl defaultDacl) [StructLayout(LayoutKind.Sequential)] public struct TokenGroups { - public static readonly int SizeOf; - public static readonly int GroupsOffset; - - static TokenGroups() - { - SizeOf = Marshal.SizeOf(typeof(TokenGroups)); - GroupsOffset = Marshal.OffsetOf(typeof(TokenGroups), "Groups").ToInt32(); - } + public static readonly int GroupsOffset = + Marshal.OffsetOf(typeof(TokenGroups), "Groups").ToInt32(); public TokenGroups(Sid[] sids) { @@ -3305,8 +2894,6 @@ public TokenPrivileges(PrivilegeSet privileges) [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct TokenSource { - public static readonly int SizeOf; - public TokenSource(string sourceName, Luid sourceIdentifier) { if (sourceName.Length > 8) @@ -3320,18 +2907,11 @@ public TokenSource(string sourceName, Luid sourceIdentifier) public string SourceName; public Luid SourceIdentifier; - - static TokenSource() - { - SizeOf = Marshal.SizeOf(typeof(TokenSource)); - } } [StructLayout(LayoutKind.Sequential)] public struct TokenStatistics { - public static readonly int SizeOf; - public Luid TokenId; public Luid AuthenticationId; public long ExpirationTime; @@ -3342,11 +2922,6 @@ public struct TokenStatistics public int GroupCount; public int PrivilegeCount; public Luid ModifiedId; - - static TokenStatistics() - { - SizeOf = Marshal.SizeOf(typeof(TokenStatistics)); - } } [StructLayout(LayoutKind.Sequential)] @@ -3363,13 +2938,6 @@ public TokenUser(Sid user) [StructLayout(LayoutKind.Sequential)] public struct TransactionBasicInformation { - public static readonly int SizeOf; - - static TransactionBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(TransactionBasicInformation)); - } - public Guid TransactionId; public TransactionState State; public TransactionOutcome Outcome; @@ -3425,11 +2993,9 @@ public struct TransactionPropertiesInformation [StructLayout(LayoutKind.Sequential)] public struct UnicodeString : IComparable, IEquatable, IDisposable { - public static readonly int SizeOf = Marshal.SizeOf(typeof(UnicodeString)); - public UnicodeString(string str) { - if (!string.IsNullOrEmpty(str)) + if (str != null) { UnicodeString newString; @@ -3474,13 +3040,14 @@ public void Dispose() /// public UnicodeString Duplicate() { + NtStatus status; UnicodeString newString; - Win32.RtlDuplicateUnicodeString( - RtlDuplicateUnicodeStringFlags.AllocateNullString | RtlDuplicateUnicodeStringFlags.NullTerminate, - ref this, - out newString - ).ThrowIf(); + if ((status = Win32.RtlDuplicateUnicodeString( + RtlDuplicateUnicodeStringFlags.AllocateNullString | + RtlDuplicateUnicodeStringFlags.NullTerminate, + ref this, out newString)) >= NtStatus.Error) + Win32.Throw(status); return newString; } @@ -3502,14 +3069,12 @@ public override int GetHashCode() public int Hash(HashStringAlgorithm algorithm, bool caseInsensitive) { + NtStatus status; int hash; - Win32.RtlHashUnicodeString( - ref this, - caseInsensitive, - algorithm, - out hash - ).ThrowIf(); + if ((status = Win32.RtlHashUnicodeString(ref this, + caseInsensitive, algorithm, out hash)) >= NtStatus.Error) + Win32.Throw(status); return hash; } @@ -3524,21 +3089,18 @@ public int Hash() return this.Hash(HashStringAlgorithm.Default); } - public string Text + public string Read() { - get - { - if (this.Length == 0) - return string.Empty; + if (this.Length == 0) + return ""; - return Marshal.PtrToStringUni(this.Buffer, this.Length / 2); - } + return Marshal.PtrToStringUni(this.Buffer, this.Length / 2); } public string Read(ProcessHandle processHandle) { if (this.Length == 0) - return string.Empty; + return ""; byte[] strData = processHandle.ReadMemory(this.Buffer, this.Length); GCHandle strDataHandle = GCHandle.Alloc(strData, GCHandleType.Pinned); @@ -3565,23 +3127,27 @@ public bool StartsWith(UnicodeString unicodeString) public AnsiString ToAnsiString() { + NtStatus status; AnsiString ansiStr = new AnsiString(); - Win32.RtlUnicodeStringToAnsiString(ref ansiStr, ref this, true).ThrowIf(); + if ((status = Win32.RtlUnicodeStringToAnsiString(ref ansiStr, ref this, true)) >= NtStatus.Error) + Win32.Throw(status); return ansiStr; } public override string ToString() { - return this.Text; + return this.Read(); } public AnsiString ToUpperAnsiString() { + NtStatus status; AnsiString ansiStr = new AnsiString(); - Win32.RtlUpcaseUnicodeStringToAnsiString(ref ansiStr, ref this, true).ThrowIf(); + if ((status = Win32.RtlUpcaseUnicodeStringToAnsiString(ref ansiStr, ref this, true)) >= NtStatus.Error) + Win32.Throw(status); return ansiStr; } @@ -3590,8 +3156,6 @@ public AnsiString ToUpperAnsiString() [StructLayout(LayoutKind.Sequential)] public struct VmCounters { - public static readonly int SizeOf; - public IntPtr PeakVirtualSize; public IntPtr VirtualSize; public int PageFaultCount; @@ -3603,18 +3167,11 @@ public struct VmCounters public IntPtr QuotaNonPagedPoolUsage; public IntPtr PagefileUsage; public IntPtr PeakPagefileUsage; - - static VmCounters() - { - SizeOf = Marshal.SizeOf(typeof(VmCounters)); - } } [StructLayout(LayoutKind.Sequential)] public struct VmCountersEx { - public static readonly int SizeOf = Marshal.SizeOf(typeof(VmCountersEx)); - public IntPtr PeakVirtualSize; public IntPtr VirtualSize; public int PageFaultCount; @@ -3632,8 +3189,6 @@ public struct VmCountersEx [StructLayout(LayoutKind.Sequential)] public struct VmCountersEx64 { - public static readonly int SizeOf = Marshal.SizeOf(typeof(VmCountersEx64)); - public VmCountersEx64(VmCountersEx vm) { this.PeakVirtualSize = vm.PeakVirtualSize.ToInt64(); @@ -3665,7 +3220,7 @@ public VmCountersEx64(VmCountersEx vm) public VmCountersEx ToVmCountersEx() { - return new VmCountersEx + return new VmCountersEx() { PeakVirtualSize = this.PeakVirtualSize.ToIntPtr(), VirtualSize = this.VirtualSize.ToIntPtr(), diff --git a/1.x/trunk/ProcessHacker.Native/Api/NtStatus.cs b/1.x/trunk/ProcessHacker.Native/Api/NtStatus.cs index 04999f842..71822955d 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/NtStatus.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/NtStatus.cs @@ -20,7 +20,6 @@ * along with Process Hacker. If not, see . */ -using System; namespace ProcessHacker.Native.Api { /// @@ -390,7 +389,7 @@ public static string GetMessage(this NtStatus status) { // Fix those messages which are formatted like: // {Asdf}\r\nAsdf asdf asdf... - if (message.StartsWith("{", StringComparison.OrdinalIgnoreCase)) + if (message.StartsWith("{")) { string[] split = message.Split('\n'); diff --git a/1.x/trunk/ProcessHacker.Native/Api/SamDefinitions.cs b/1.x/trunk/ProcessHacker.Native/Api/SamDefinitions.cs index 8f5be7a46..a60892232 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/SamDefinitions.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/SamDefinitions.cs @@ -1,4 +1,8 @@ -namespace ProcessHacker.Native.Api +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.Native.Api { public static partial class Win32 { diff --git a/1.x/trunk/ProcessHacker.Native/Api/SamFunctions.cs b/1.x/trunk/ProcessHacker.Native/Api/SamFunctions.cs index ff866d897..569560248 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/SamFunctions.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/SamFunctions.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; using ProcessHacker.Native.Security; diff --git a/1.x/trunk/ProcessHacker.Native/Api/SamStructs.cs b/1.x/trunk/ProcessHacker.Native/Api/SamStructs.cs index 88a61be2d..feb291d87 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/SamStructs.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/SamStructs.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; namespace ProcessHacker.Native.Api @@ -123,13 +124,6 @@ public struct SamByteArray32K [StructLayout(LayoutKind.Sequential)] public struct SamRidEnumeration { - public static readonly int SizeOf; - - static SamRidEnumeration() - { - SizeOf = Marshal.SizeOf(typeof(SamRidEnumeration)); - } - public int RelativeId; public UnicodeString Name; } @@ -137,13 +131,6 @@ static SamRidEnumeration() [StructLayout(LayoutKind.Sequential)] public struct SamSidEnumeration { - public static readonly int SizeOf; - - static SamSidEnumeration() - { - SizeOf = Marshal.SizeOf(typeof(SamSidEnumeration)); - } - public IntPtr Sid; // Sid* public UnicodeString Name; } diff --git a/1.x/trunk/ProcessHacker.Native/Api/Structs.cs b/1.x/trunk/ProcessHacker.Native/Api/Structs.cs index d13a2d40f..4deaccf49 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/Structs.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/Structs.cs @@ -31,6 +31,7 @@ using System; using System.Drawing; using System.Runtime.InteropServices; +using ProcessHacker.Native.Objects; namespace ProcessHacker.Native.Api { @@ -91,13 +92,6 @@ public struct CMsgSignerInfo [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct CredUiInfo { - public static readonly int SizeOf; - - static CredUiInfo() - { - SizeOf = Marshal.SizeOf(typeof(CredUiInfo)); - } - public int Size; public IntPtr Parent; public string MessageText; @@ -161,25 +155,6 @@ public struct CryptProviderSgnr public IntPtr ChainContext; } - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct DlgTemplate - { - public static readonly int SizeOf; - - public int style; - public int dwExtendedStyle; - public short cdit; - public short x; - public short y; - public short cx; - public short cy; - - static DlgTemplate() - { - SizeOf = Marshal.SizeOf(typeof(DlgTemplate)); - } - } - [StructLayout(LayoutKind.Sequential)] public struct EnumServiceStatus { @@ -196,13 +171,6 @@ public struct EnumServiceStatus [StructLayout(LayoutKind.Sequential)] public struct EnumServiceStatusProcess { - public static readonly int SizeOf; - - static EnumServiceStatusProcess() - { - SizeOf = Marshal.SizeOf(typeof(EnumServiceStatusProcess)); - } - [MarshalAs(UnmanagedType.LPTStr)] public string ServiceName; @@ -235,13 +203,6 @@ public struct FpoData [StructLayout(LayoutKind.Sequential)] public struct HeapEntry32 { - public static readonly int SizeOf; - - static HeapEntry32() - { - SizeOf = Marshal.SizeOf(typeof(HeapEntry32)); - } - public int dwSize; public IntPtr hHandle; public IntPtr dwAddress; @@ -256,13 +217,6 @@ static HeapEntry32() [StructLayout(LayoutKind.Sequential)] public struct HeapList32 { - public static readonly int SizeOf; - - static HeapList32() - { - SizeOf = Marshal.SizeOf(typeof(HeapList32)); - } - public int dwSize; public int th32ProcessID; public IntPtr th32HeapID; @@ -335,13 +289,6 @@ public struct LoadedImage [StructLayout(LayoutKind.Sequential)] public struct LuidAndAttributes { - public static readonly int SizeOf; - - static LuidAndAttributes() - { - SizeOf = Marshal.SizeOf(typeof(LuidAndAttributes)); - } - public Luid Luid; public SePrivilegeAttributes Attributes; } @@ -349,8 +296,6 @@ static LuidAndAttributes() [StructLayout(LayoutKind.Sequential)] public struct MemoryBasicInformation { - public static readonly int SizeOf; - public IntPtr BaseAddress; public IntPtr AllocationBase; public MemoryProtection AllocationProtect; @@ -358,11 +303,6 @@ public struct MemoryBasicInformation public MemoryState State; public MemoryProtection Protect; public MemoryType Type; - - static MemoryBasicInformation() - { - SizeOf = Marshal.SizeOf(typeof(MemoryBasicInformation)); - } } [StructLayout(LayoutKind.Sequential, Pack = 16)] @@ -371,12 +311,12 @@ public struct MemoryBasicInformation64 public IntPtr BaseAddress; public IntPtr AllocationBase; public MemoryProtection AllocationProtect; - public int _alignment1; + private int _alignment1; public ulong RegionSize; public MemoryState State; public MemoryProtection Protect; public MemoryType Type; - public int _alignment2; + private int _alignment2; } [StructLayout(LayoutKind.Sequential)] @@ -418,13 +358,6 @@ public struct MibTcp6Row2 [StructLayout(LayoutKind.Sequential)] public struct MibTcpRowOwnerPid { - public static readonly int SizeOf; - - static MibTcpRowOwnerPid() - { - SizeOf = Marshal.SizeOf(typeof(MibTcpRowOwnerPid)); - } - public MibTcpState State; public uint LocalAddress; public int LocalPort; @@ -435,14 +368,7 @@ static MibTcpRowOwnerPid() [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MibTcp6RowOwnerPid - { - public static readonly int SizeOf; - - static MibTcp6RowOwnerPid() - { - SizeOf = Marshal.SizeOf(typeof(MibTcp6RowOwnerPid)); - } - + { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] LocalAddress; public uint LocalScopeId; @@ -534,14 +460,7 @@ public struct MibUdp6Table [StructLayout(LayoutKind.Sequential)] public struct MibUdpRowOwnerPid - { - public static readonly int SizeOf; - - static MibUdpRowOwnerPid() - { - SizeOf = Marshal.SizeOf(typeof(MibUdpRowOwnerPid)); - } - + { public uint LocalAddress; public int LocalPort; public int OwningProcessId; @@ -550,13 +469,6 @@ static MibUdpRowOwnerPid() [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MibUdp6RowOwnerPid { - public static readonly int SizeOf; - - static MibUdp6RowOwnerPid() - { - SizeOf = Marshal.SizeOf(typeof(MibUdp6RowOwnerPid)); - } - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] LocalAddress; public uint LocalScopeId; @@ -626,13 +538,6 @@ public struct ModuleEntry32 [StructLayout(LayoutKind.Sequential)] public struct ModuleInfo { - public static readonly int SizeOf; - - static ModuleInfo() - { - SizeOf = Marshal.SizeOf(typeof(ModuleInfo)); - } - public IntPtr BaseOfDll; public int SizeOfImage; public IntPtr EntryPoint; @@ -647,84 +552,23 @@ public struct MonitorInformation public uint Flags; } - /// - /// Contains performance information. - /// - /// http://msdn.microsoft.com/en-us/library/ms684824.aspx [StructLayout(LayoutKind.Sequential)] public struct PerformanceInformation { - public static readonly int SizeOf = Marshal.SizeOf(typeof(PerformanceInformation)); - - /// - /// The size of this structure, in bytes. - /// - public int cbSize; - - /// - /// The number of pages currently committed by the system. Note that committing pages (using VirtualAlloc with MEM_COMMIT) changes this value immediately; however, the physical memory is not charged until the pages are accessed. - /// + public int Size; public IntPtr CommitTotal; - - /// - /// The current maximum number of pages that can be committed by the system without extending the paging file(s). This number can change if memory is added or deleted, or if pagefiles have grown, shrunk, or been added. If the paging file can be extended, this is a soft limit. - /// public IntPtr CommitLimit; - - /// - /// The maximum number of pages that were simultaneously in the committed state since the last system reboot. - /// public IntPtr CommitPeak; - - /// - /// The amount of actual physical memory, in pages. - /// public IntPtr PhysicalTotal; - - /// - /// The amount of physical memory currently available, in pages. This is the amount of physical memory that can be immediately reused without having to write its contents to disk first. It is the sum of the size of the standby, free, and zero lists. - /// public IntPtr PhysicalAvailable; - - /// - /// The amount of system cache memory, in pages. This is the size of the standby list plus the system working set. - /// public IntPtr SystemCache; - - /// - /// The sum of the memory currently in the paged and nonpaged kernel pools, in pages. - /// public IntPtr KernelTotal; - - /// - /// The memory currently in the paged kernel pool, in pages. - /// public IntPtr KernelPaged; - - /// - /// The memory currently in the nonpaged kernel pool, in pages. - /// public IntPtr KernelNonPaged; - - /// - /// The size of a page, in bytes. - /// public IntPtr PageSize; - - /// - /// The current number of open handles. - /// - public uint HandlesCount; - - /// - /// The current number of processes. - /// - public uint ProcessCount; - - /// - /// The current number of threads. - /// - public uint ThreadCount; + public int HandlesCount; + public int ProcessCount; + public int ThreadCount; } [StructLayout(LayoutKind.Sequential)] @@ -753,32 +597,6 @@ public struct ProcessInformation public int ThreadId; } - [StructLayout(LayoutKind.Sequential)] - public struct PropSheetPageW - { - public static readonly int SizeOf; - - static PropSheetPageW() - { - SizeOf = Marshal.SizeOf(typeof(PropSheetPageW)); - } - - public int dwSize; - public PropSheetPageFlags dwFlags; - public IntPtr hInstance; - - public IntPtr pResource; // pszTemplate - public IntPtr hIcon; - public IntPtr pszTitle; - public IntPtr pfnDlgProc; - public IntPtr lParam; - public IntPtr pfnCallback; - public IntPtr pcRefParent; - public IntPtr pszHeaderTitle; - public IntPtr pszHeaderSubTitle; - public IntPtr hActCtx; - } - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct ProfileInformation { @@ -847,13 +665,6 @@ public struct ScAction [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SecPkgInfo { - public static readonly int SizeOf; - - static SecPkgInfo() - { - SizeOf = Marshal.SizeOf(typeof(SecPkgInfo)); - } - public int Capabilities; public ushort Version; public ushort RpcId; @@ -884,13 +695,6 @@ public struct ServiceStatus [StructLayout(LayoutKind.Sequential)] public struct ServiceStatusProcess { - public static readonly int SizeOf; - - static ServiceStatusProcess() - { - SizeOf = Marshal.SizeOf(typeof(ServiceStatusProcess)); - } - public ServiceType ServiceType; public ServiceState CurrentState; public ServiceAccept ControlsAccepted; @@ -905,13 +709,6 @@ static ServiceStatusProcess() [StructLayout(LayoutKind.Sequential)] public struct ShellExecuteInfo { - public static readonly int SizeOf; - - static ShellExecuteInfo() - { - SizeOf = Marshal.SizeOf(typeof(ShellExecuteInfo)); - } - public int cbSize; public uint fMask; public IntPtr hWnd; @@ -933,13 +730,6 @@ static ShellExecuteInfo() [StructLayout(LayoutKind.Sequential)] public struct ShFileInfo { - public static readonly int SizeOf; - - static ShFileInfo() - { - SizeOf = Marshal.SizeOf(typeof(ShFileInfo)); - } - public IntPtr hIcon; public IntPtr iIcon; public uint dwAttributes; @@ -952,13 +742,6 @@ static ShFileInfo() [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct SiAccess { - public static readonly int SizeOf; - - static SiAccess() - { - SizeOf = Marshal.SizeOf(typeof(SiAccess)); - } - public IntPtr Guid; public int Mask; public IntPtr Name; // string @@ -1010,13 +793,6 @@ public struct StackFrame64 [StructLayout(LayoutKind.Sequential)] public struct StartupInfo { - public static readonly int SizeOf; - - static StartupInfo() - { - SizeOf = Marshal.SizeOf(typeof(StartupInfo)); - } - public int Size; [MarshalAs(UnmanagedType.LPWStr)] public string Reserved; @@ -1043,8 +819,7 @@ static StartupInfo() [StructLayout(LayoutKind.Sequential)] public struct SymbolInfo { - public static readonly int SizeOf; - public static readonly int NameOffset; + public static readonly int NameOffset = Marshal.OffsetOf(typeof(SymbolInfo), "Name").ToInt32(); public int SizeOfStruct; public int TypeIndex; @@ -1061,12 +836,6 @@ public struct SymbolInfo public int NameLen; public int MaxNameLen; public byte Name; - - static SymbolInfo() - { - SizeOf = Marshal.SizeOf(typeof(SymbolInfo)); - NameOffset = Marshal.OffsetOf(typeof(SymbolInfo), "Name").ToInt32(); - } } [StructLayout(LayoutKind.Sequential)] @@ -1090,8 +859,8 @@ public struct WindowClass public int Styles; [MarshalAs(UnmanagedType.FunctionPtr)] public WndProcDelegate WindowsProc; - public int ExtraClassData; - public int ExtraWindowData; + private int ExtraClassData; + private int ExtraWindowData; public IntPtr InstanceHandle; public IntPtr IconHandle; public IntPtr CursorHandle; @@ -1105,13 +874,6 @@ public struct WindowClass [StructLayout(LayoutKind.Sequential)] public struct WindowPlacement { - public static readonly int SizeOf; - - static WindowPlacement() - { - SizeOf = Marshal.SizeOf(typeof(WindowPlacement)); - } - public int Length; public WindowPlacementFlags Flags; public ShowWindowType ShowState; @@ -1123,13 +885,6 @@ static WindowPlacement() [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WintrustCatalogInfo { - public static readonly int SizeOf; - - static WintrustCatalogInfo() - { - SizeOf = Marshal.SizeOf(typeof(WintrustCatalogInfo)); - } - public int Size; public int CatalogVersion; public string CatalogFilePath; @@ -1144,13 +899,6 @@ static WintrustCatalogInfo() [StructLayout(LayoutKind.Sequential)] public struct WintrustData { - public static readonly int SizeOf; - - static WintrustData() - { - SizeOf = Marshal.SizeOf(typeof(WintrustData)); - } - public int Size; public IntPtr PolicyCallbackData; public IntPtr SIPClientData; @@ -1168,13 +916,6 @@ static WintrustData() [StructLayout(LayoutKind.Sequential)] public struct WintrustFileInfo { - public static readonly int SizeOf; - - static WintrustFileInfo() - { - SizeOf = Marshal.SizeOf(typeof(WintrustFileInfo)); - } - public int Size; public IntPtr FilePath; public IntPtr FileHandle; @@ -1200,13 +941,6 @@ public struct WtsClientDisplay [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WtsProcessInfo { - public static readonly int SizeOf; - - static WtsProcessInfo() - { - SizeOf = Marshal.SizeOf(typeof(WtsProcessInfo)); - } - public int SessionId; public int ProcessId; public IntPtr ProcessName; @@ -1216,13 +950,6 @@ static WtsProcessInfo() [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WtsSessionInfo { - public static readonly int SizeOf; - - static WtsSessionInfo() - { - SizeOf = Marshal.SizeOf(typeof(WtsSessionInfo)); - } - public int SessionID; public string WinStationName; public WtsConnectStateClass State; diff --git a/1.x/trunk/ProcessHacker.Native/Api/Win32.cs b/1.x/trunk/ProcessHacker.Native/Api/Win32.cs index 537ca5121..2cb1d0393 100644 --- a/1.x/trunk/ProcessHacker.Native/Api/Win32.cs +++ b/1.x/trunk/ProcessHacker.Native/Api/Win32.cs @@ -39,20 +39,18 @@ namespace ProcessHacker.Native.Api public delegate IntPtr WndProcDelegate(IntPtr hWnd, WindowMessage msg, IntPtr wParam, IntPtr lParam); public delegate bool SymEnumSymbolsProc(IntPtr SymInfo, int SymbolSize, int UserContext); - public delegate bool ReadProcessMemoryProc64(IntPtr ProcessHandle, ulong BaseAddress, IntPtr Buffer, int Size, out int BytesRead); + public unsafe delegate bool ReadProcessMemoryProc64(IntPtr ProcessHandle, ulong BaseAddress, IntPtr Buffer, + int Size, out int BytesRead); public delegate IntPtr FunctionTableAccessProc64(IntPtr ProcessHandle, ulong AddrBase); public delegate ulong GetModuleBaseProc64(IntPtr ProcessHandle, ulong Address); - public delegate int PropSheetPageCallback(IntPtr hwnd, PropSheetPageCallbackMessage uMsg, IntPtr ppsp); - public delegate bool DialogProc(IntPtr hwndDlg, WindowMessage uMsg, IntPtr wParam, IntPtr lParam); - /// /// Provides interfacing to the Win32 and Native APIs. /// [SuppressUnmanagedCodeSecurity] public static partial class Win32 { - private static readonly FastMutex _dbgHelpLock = new FastMutex(); + private static FastMutex _dbgHelpLock = new FastMutex(); /// /// A mutex which controls access to the dbghelp.dll functions. @@ -95,12 +93,7 @@ public static string GetLastErrorMessage() /// public static void Throw() { - Win32Error last = GetLastErrorCode(); - - if (last != Win32Error.Success) - { - Throw(last); - } + Throw(GetLastErrorCode()); } public static void Throw(NtStatus status) @@ -122,7 +115,7 @@ public static void Throw(Win32Error error) #region Handles - public static void DuplicateObject( + public unsafe static void DuplicateObject( IntPtr sourceProcessHandle, IntPtr sourceHandle, int desiredAccess, @@ -143,7 +136,7 @@ DuplicateOptions options ); } - public static void DuplicateObject( + public unsafe static void DuplicateObject( IntPtr sourceProcessHandle, IntPtr sourceHandle, IntPtr targetProcessHandle, @@ -153,15 +146,34 @@ public static void DuplicateObject( DuplicateOptions options ) { - NtDuplicateObject( - sourceProcessHandle, - sourceHandle, - targetProcessHandle, - out targetHandle, - desiredAccess, - handleAttributes, - options - ).ThrowIf(); + if (KProcessHacker.Instance != null) + { + int target; + + KProcessHacker.Instance.KphDuplicateObject( + sourceProcessHandle.ToInt32(), + sourceHandle.ToInt32(), + targetProcessHandle.ToInt32(), + out target, + desiredAccess, + handleAttributes, + options); + targetHandle = new IntPtr(target); + } + else + { + NtStatus status; + + if ((status = NtDuplicateObject( + sourceProcessHandle, + sourceHandle, + targetProcessHandle, + out targetHandle, + desiredAccess, + handleAttributes, + options)) >= NtStatus.Error) + Throw(status); + } } #endregion @@ -181,7 +193,7 @@ public static int GetProcessSessionId(int ProcessId) { using (ProcessHandle phandle = new ProcessHandle(ProcessId, OSVersion.MinProcessQueryInfoAccess)) { - return phandle.GetToken(TokenAccess.Query).SessionId; + return phandle.GetToken(TokenAccess.Query).GetSessionId(); } } @@ -190,43 +202,6 @@ public static int GetProcessSessionId(int ProcessId) #endregion - #region Property Sheets - - [DllImport("comctl32.dll")] - public static extern IntPtr CreatePropertySheetPageW( - ref PropSheetPageW lppsp - ); - - [DllImport("user32.dll")] - public static extern bool MapDialogRect( - IntPtr hDlg, - ref Rect lpRect - ); - - [DllImport("user32.dll")] - public static extern IntPtr SetParent( - IntPtr hWndChild, - IntPtr hWndNewParent - ); - - [DllImport("user32.dll")] - public static extern IntPtr SendMessage( - IntPtr hWnd, - int Msg, - IntPtr wParam, - IntPtr lParam - ); - - [StructLayout(LayoutKind.Sequential)] - public struct NmHdr - { - public IntPtr hwndFrom; - public IntPtr idFrom; - public uint code; - } - - #endregion - #region TCP public static MibTcpStats GetTcpStats() @@ -253,7 +228,7 @@ public static MibTcpTableOwnerPid GetTcpTable() table.Table = new MibTcpRowOwnerPid[count]; for (int i = 0; i < count; i++) - table.Table[i] = mem.ReadStruct(sizeof(int), MibTcpRowOwnerPid.SizeOf, i); + table.Table[i] = mem.ReadStruct(sizeof(int), i); } return table; @@ -274,11 +249,13 @@ public unsafe static WtsEnumProcessesFastData TSEnumProcessesFast() { IntPtr processes; int count; + int[] pids; + IntPtr[] sids; WTSEnumerateProcesses(IntPtr.Zero, 0, 1, out processes, out count); - int[] pids = new int[count]; - IntPtr[] sids = new IntPtr[count]; + pids = new int[count]; + sids = new IntPtr[count]; WtsMemoryAlloc data = new WtsMemoryAlloc(processes); WtsProcessInfo* dataP = (WtsProcessInfo*)data.Memory; @@ -289,12 +266,7 @@ public unsafe static WtsEnumProcessesFastData TSEnumProcessesFast() sids[i] = dataP[i].Sid; } - return new WtsEnumProcessesFastData - { - PIDs = pids, - SIDs = sids, - Memory = data - }; + return new WtsEnumProcessesFastData() { PIDs = pids, SIDs = sids, Memory = data }; } #endregion @@ -325,7 +297,7 @@ public static MibUdpTableOwnerPid GetUdpTable() table.Table = new MibUdpRowOwnerPid[count]; for (int i = 0; i < count; i++) - table.Table[i] = mem.ReadStruct(sizeof(int), MibTcpRowOwnerPid.SizeOf, i); + table.Table[i] = mem.ReadStruct(sizeof(int), i); } return table; @@ -358,7 +330,7 @@ public unsafe static string[] GetMultiString(IntPtr ptr) string str = currentString.ToString(); - if (string.IsNullOrEmpty(str)) + if (str == "") { break; } diff --git a/1.x/trunk/ProcessHacker.Native/Cryptography.cs b/1.x/trunk/ProcessHacker.Native/Cryptography.cs index 857f409e9..10d1aba91 100644 --- a/1.x/trunk/ProcessHacker.Native/Cryptography.cs +++ b/1.x/trunk/ProcessHacker.Native/Cryptography.cs @@ -56,7 +56,7 @@ public static class Cryptography new Guid("{fc451c16-ac75-11d1-b4b8-00c04fb66ea0}"); public static readonly Guid WintrustActionGenericVerifyV2 = new Guid("{00aac56b-cd44-11d0-8cc2-00c04fc295ee}"); - public static readonly Guid WintrustActionTrustProviderTest = + public static readonly System.Guid WintrustActionTrustProviderTest = new Guid("{573e31f8-ddba-11d0-8ccb-00c04fc295ee}"); private static string GetX500Value(string subject, string keyName) @@ -106,12 +106,14 @@ private static string GetSignerNameFromStateData(IntPtr stateData) // Well, here's a shitload of indirection for you... // 1. State data -> Provider data + IntPtr provData = Win32.WTHelperProvDataFromStateData(stateData); if (provData == IntPtr.Zero) return null; // 2. Provider data -> Provider signer + IntPtr signerInfo = Win32.WTHelperGetProvSignerFromChain(provData, 0, false, 0); if (signerInfo == IntPtr.Zero) @@ -125,22 +127,25 @@ private static string GetSignerNameFromStateData(IntPtr stateData) return null; // 3. Provider signer -> Provider cert + CryptProviderCert cert = (CryptProviderCert)Marshal.PtrToStructure(sngr.CertChain, typeof(CryptProviderCert)); if (cert.Cert == IntPtr.Zero) return null; // 4. Provider cert -> Cert context + CertContext context = (CertContext)Marshal.PtrToStructure(cert.Cert, typeof(CertContext)); if (context.CertInfo != IntPtr.Zero) { // 5. Cert context -> Cert info + CertInfo certInfo = (CertInfo)Marshal.PtrToStructure(context.CertInfo, typeof(CertInfo)); unsafe { - using (MemoryAlloc buffer = new MemoryAlloc(0x200)) + using (var buffer = new MemoryAlloc(0x200)) { int length; @@ -168,12 +173,13 @@ private static string GetSignerNameFromStateData(IntPtr stateData) } string name = buffer.ReadUnicodeString(0); + string value; // 7. Subject X.500 string -> CN or OU value - string value = GetX500Value(name, "CN"); + value = GetX500Value(name, "CN"); - if (string.IsNullOrEmpty(value)) + if (value == null) value = GetX500Value(name, "OU"); return value; @@ -186,23 +192,20 @@ private static string GetSignerNameFromStateData(IntPtr stateData) public static VerifyResult StatusToVerifyResult(uint status) { - switch (status) - { - case 0: - return VerifyResult.Trusted; - case 0x800b0100: - return VerifyResult.NoSignature; - case 0x800b0101: - return VerifyResult.Expired; - case 0x800b010c: - return VerifyResult.Revoked; - case 0x800b0111: - return VerifyResult.Distrust; - case 0x80092026: - return VerifyResult.SecuritySettings; - default: - return VerifyResult.SecuritySettings; - } + if (status == 0) + return VerifyResult.Trusted; + else if (status == 0x800b0100) + return VerifyResult.NoSignature; + else if (status == 0x800b0101) + return VerifyResult.Expired; + else if (status == 0x800b010c) + return VerifyResult.Revoked; + else if (status == 0x800b0111) + return VerifyResult.Distrust; + else if (status == 0x80092026) + return VerifyResult.SecuritySettings; + else + return VerifyResult.SecuritySettings; } public static VerifyResult VerifyFile(string fileName) @@ -214,7 +217,7 @@ public static VerifyResult VerifyFile(string fileName) public static VerifyResult VerifyFile(string fileName, out string signerName) { - VerifyResult result; + VerifyResult result = VerifyResult.NoSignature; using (MemoryAlloc strMem = new MemoryAlloc(fileName.Length * 2 + 2)) { @@ -223,25 +226,24 @@ public static VerifyResult VerifyFile(string fileName, out string signerName) strMem.WriteUnicodeString(0, fileName); strMem.WriteInt16(fileName.Length * 2, 0); - fileInfo.Size = WintrustFileInfo.SizeOf; + fileInfo.Size = Marshal.SizeOf(fileInfo); fileInfo.FilePath = strMem; - WintrustData trustData = new WintrustData - { - Size = WintrustData.SizeOf, - UIChoice = 2, // WTD_UI_NONE - UnionChoice = 1, // WTD_CHOICE_FILE - RevocationChecks = WtdRevocationChecks.None, - ProvFlags = WtdProvFlags.Safer, - StateAction = WtdStateAction.Verify - }; + WintrustData trustData = new WintrustData(); + + trustData.Size = Marshal.SizeOf(typeof(WintrustData)); + trustData.UIChoice = 2; // WTD_UI_NONE + trustData.UnionChoice = 1; // WTD_CHOICE_FILE + trustData.RevocationChecks = WtdRevocationChecks.None; + trustData.ProvFlags = WtdProvFlags.Safer; + trustData.StateAction = WtdStateAction.Verify; if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) trustData.ProvFlags |= WtdProvFlags.CacheOnlyUrlRetrieval; using (MemoryAlloc mem = new MemoryAlloc(fileInfo.Size)) { - mem.WriteStruct(fileInfo); + mem.WriteStruct(fileInfo); trustData.UnionData = mem; uint winTrustResult = Win32.WinVerifyTrust(IntPtr.Zero, WintrustActionGenericVerifyV2, ref trustData); @@ -268,7 +270,8 @@ public static VerifyResult VerifyFile(string fileName, out string signerName) signerName = null; - using (FileHandle sourceFile = FileHandle.CreateWin32(fileName, FileAccess.GenericRead, FileShareMode.Read, FileCreationDispositionWin32.OpenExisting)) + using (FileHandle sourceFile = FileHandle.CreateWin32(fileName, FileAccess.GenericRead, FileShareMode.Read, + FileCreationDispositionWin32.OpenExisting)) { byte[] hash = new byte[256]; int hashLength = 256; @@ -308,29 +311,27 @@ public static VerifyResult VerifyFile(string fileName, out string signerName) return VerifyResult.NoSignature; } - WintrustCatalogInfo wci = new WintrustCatalogInfo - { - Size = WintrustCatalogInfo.SizeOf, - CatalogFilePath = ci.CatalogFile, - MemberFilePath = fileName, - MemberTag = memberTag.ToString() - }; + WintrustCatalogInfo wci = new WintrustCatalogInfo(); - WintrustData trustData = new WintrustData - { - Size = WintrustData.SizeOf, - UIChoice = 1, - UnionChoice = 2, - RevocationChecks = WtdRevocationChecks.None, - StateAction = WtdStateAction.Verify - }; + wci.Size = Marshal.SizeOf(wci); + wci.CatalogFilePath = ci.CatalogFile; + wci.MemberFilePath = fileName; + wci.MemberTag = memberTag.ToString(); + + WintrustData trustData = new WintrustData(); + + trustData.Size = Marshal.SizeOf(typeof(WintrustData)); + trustData.UIChoice = 1; + trustData.UnionChoice = 2; + trustData.RevocationChecks = WtdRevocationChecks.None; + trustData.StateAction = WtdStateAction.Verify; if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) trustData.ProvFlags = WtdProvFlags.CacheOnlyUrlRetrieval; using (MemoryAlloc mem = new MemoryAlloc(wci.Size)) { - mem.WriteStruct(wci); + mem.WriteStruct(wci); try { diff --git a/1.x/trunk/ProcessHacker.Native/Debugging/DebugBuffer.cs b/1.x/trunk/ProcessHacker.Native/Debugging/DebugBuffer.cs index 1a89a5ea3..72213a4c4 100644 --- a/1.x/trunk/ProcessHacker.Native/Debugging/DebugBuffer.cs +++ b/1.x/trunk/ProcessHacker.Native/Debugging/DebugBuffer.cs @@ -37,7 +37,7 @@ namespace ProcessHacker.Native.Debugging /// public sealed class DebugBuffer : BaseObject { - private readonly IntPtr _buffer; + private IntPtr _buffer; /// /// Creates a new debug buffer. @@ -64,7 +64,7 @@ protected override void DisposeObject(bool disposing) /// The callback for the enumeration. public void EnumHeaps(DebugEnumHeapsDelegate callback) { - RtlDebugInformation debugInfo = this.GetDebugInformation(); + var debugInfo = this.GetDebugInformation(); if (debugInfo.Heaps == IntPtr.Zero) throw new InvalidOperationException("Heap information does not exist."); @@ -74,7 +74,7 @@ public void EnumHeaps(DebugEnumHeapsDelegate callback) for (int i = 0; i < heaps.NumberOfHeaps; i++) { - RtlHeapInformation heap = heapInfo.ReadStruct(RtlProcessHeaps.HeapsOffset, RtlHeapInformation.SizeOf, i); + var heap = heapInfo.ReadStruct(RtlProcessHeaps.HeapsOffset, i); if (!callback(new HeapInformation(heap))) break; @@ -97,7 +97,7 @@ public void EnumLocks(DebugEnumLocksDelegate callback) for (int i = 0; i < locks.NumberOfLocks; i++) { - var lock_ = locksInfo.ReadStruct(sizeof(int), RtlProcessLockInformation.SizeOf, i); + var lock_ = locksInfo.ReadStruct(sizeof(int), i); if (!callback(new LockInformation(lock_))) break; @@ -110,17 +110,17 @@ public void EnumLocks(DebugEnumLocksDelegate callback) /// The callback for the enumeration. public void EnumModules(DebugEnumModulesDelegate callback) { - RtlDebugInformation debugInfo = this.GetDebugInformation(); + var debugInfo = this.GetDebugInformation(); if (debugInfo.Modules == IntPtr.Zero) throw new InvalidOperationException("Module information does not exist."); MemoryRegion modulesInfo = new MemoryRegion(debugInfo.Modules); - RtlProcessModules modules = modulesInfo.ReadStruct(); + var modules = modulesInfo.ReadStruct(); for (int i = 0; i < modules.NumberOfModules; i++) { - var module = modulesInfo.ReadStruct(RtlProcessModules.ModulesOffset, RtlProcessModuleInformation.SizeOf, i); + var module = modulesInfo.ReadStruct(RtlProcessModules.ModulesOffset, i); if (!callback(new ModuleInformation(module))) break; @@ -146,7 +146,7 @@ public HeapInformation[] GetHeaps() { List heaps = new List(); - this.EnumHeaps(heap => + this.EnumHeaps((heap) => { heaps.Add(heap); return true; @@ -163,7 +163,7 @@ public LockInformation[] GetLocks() { List locks = new List(); - this.EnumLocks(lock_ => + this.EnumLocks((lock_) => { locks.Add(lock_); return true; @@ -180,7 +180,7 @@ public ModuleInformation[] GetModules() { List modules = new List(); - this.EnumModules(module => + this.EnumModules((module) => { modules.Add(module); return true; @@ -195,7 +195,7 @@ public ModuleInformation[] GetModules() /// The information to query. public void Query(RtlQueryProcessDebugFlags flags) { - this.Query(ProcessHandle.CurrentId, flags); + this.Query(ProcessHandle.GetCurrentId(), flags); } /// @@ -205,11 +205,14 @@ public void Query(RtlQueryProcessDebugFlags flags) /// The information to query. public void Query(int pid, RtlQueryProcessDebugFlags flags) { - Win32.RtlQueryProcessDebugInformation( + NtStatus status; + + if ((status = Win32.RtlQueryProcessDebugInformation( pid.ToIntPtr(), flags, _buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -217,7 +220,10 @@ public void Query(int pid, RtlQueryProcessDebugFlags flags) /// public void QueryBackTraces() { - Win32.RtlQueryProcessBackTraceInformation(_buffer).ThrowIf(); + NtStatus status; + + if ((status = Win32.RtlQueryProcessBackTraceInformation(_buffer)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -225,7 +231,10 @@ public void QueryBackTraces() /// public void QueryHeaps() { - Win32.RtlQueryProcessHeapInformation(_buffer).ThrowIf(); + NtStatus status; + + if ((status = Win32.RtlQueryProcessHeapInformation(_buffer)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -233,7 +242,10 @@ public void QueryHeaps() /// public void QueryLocks() { - Win32.RtlQueryProcessLockInformation(_buffer).ThrowIf(); + NtStatus status; + + if ((status = Win32.RtlQueryProcessLockInformation(_buffer)) >= NtStatus.Error) + Win32.Throw(status); } //public void QueryModules() @@ -243,11 +255,14 @@ public void QueryLocks() //public void QueryModules(ProcessHandle processHandle, RtlQueryProcessDebugFlags flags) //{ - // Win32.RtlQueryProcessModuleInformation( + // NtStatus status; + + // if ((status = Win32.RtlQueryProcessModuleInformation( // processHandle ?? IntPtr.Zero, // flags, // _buffer - // ).ThrowIf(); + // )) >= NtStatus.Error) + // Win32.ThrowLastError(status); //} } } diff --git a/1.x/trunk/ProcessHacker.Native/FileUtils.cs b/1.x/trunk/ProcessHacker.Native/FileUtils.cs index cc4097790..401f77ec6 100644 --- a/1.x/trunk/ProcessHacker.Native/FileUtils.cs +++ b/1.x/trunk/ProcessHacker.Native/FileUtils.cs @@ -23,6 +23,8 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; @@ -42,18 +44,20 @@ static FileUtils() /// /// Used to resolve device prefixes (\Device\Harddisk1) into DOS drive names. /// - private static Dictionary _fileNamePrefixes; + private static Dictionary _fileNamePrefixes = new Dictionary(); public static string FindFile(string basePath, string fileName) { - if (!string.IsNullOrEmpty(basePath)) + string path; + + if (basePath != null) { // Search the base path first. if (System.IO.File.Exists(basePath + "\\" + fileName)) return System.IO.Path.Combine(basePath, fileName); } - string path = Environment.GetEnvironmentVariable("Path"); + path = Environment.GetEnvironmentVariable("Path"); string[] directories = path.Split(';'); @@ -68,11 +72,12 @@ public static string FindFile(string basePath, string fileName) public static string FindFileWin32(string fileName) { - using (MemoryAlloc data = new MemoryAlloc(0x400)) + using (var data = new MemoryAlloc(0x400)) { + int retLength; IntPtr filePart; - int retLength = Win32.SearchPath(null, fileName, null, data.Size / 2, data, out filePart); + retLength = Win32.SearchPath(null, fileName, null, data.Size / 2, data, out filePart); if (retLength * 2 > data.Size) { @@ -94,26 +99,24 @@ public static Icon GetFileIcon(string fileName) public static Icon GetFileIcon(string fileName, bool large) { + ShFileInfo shinfo = new ShFileInfo(); + if (string.IsNullOrEmpty(fileName)) throw new Exception("File name cannot be empty."); try { - ShFileInfo shinfo; - - if (Win32.SHGetFileInfo( - fileName, - 0, - out shinfo, - (uint)ShFileInfo.SizeOf, + if (Win32.SHGetFileInfo(fileName, 0, out shinfo, + (uint)Marshal.SizeOf(shinfo), Win32.ShgFiIcon | - (large ? Win32.ShgFiLargeIcon : Win32.ShgFiSmallIcon) - ) == 0) + (large ? Win32.ShgFiLargeIcon : Win32.ShgFiSmallIcon)) == 0) { return null; } - - return Icon.FromHandle(shinfo.hIcon); + else + { + return Icon.FromHandle(shinfo.hIcon); + } } catch { @@ -121,43 +124,6 @@ public static Icon GetFileIcon(string fileName, bool large) } } - public static unsafe string GetVistaFileName(int pid) - { - using (MemoryAlloc buffer = new MemoryAlloc(0x100)) - { - SystemProcessImageNameInformation info; - - info.ProcessId = pid; - info.ImageName.Length = 0; - info.ImageName.MaximumLength = 0x100; - info.ImageName.Buffer = buffer; - - NtStatus status = Win32.NtQuerySystemInformation( - SystemInformationClass.SystemProcessImageName, - &info, - SystemProcessImageNameInformation.SizeOf, - null - ); - - if (status == NtStatus.InfoLengthMismatch) - { - // Our buffer was too small. The required buffer length is stored in MaximumLength. - buffer.ResizeNew(info.ImageName.MaximumLength); - - status = Win32.NtQuerySystemInformation( - SystemInformationClass.SystemProcessImageName, - &info, - SystemProcessImageNameInformation.SizeOf, - null - ); - } - - status.ThrowIf(); - - return GetFileName(info.ImageName.Text); - } - } - public static string GetFileName(string fileName) { return GetFileName(fileName, false); @@ -180,23 +146,25 @@ public static string GetFileName(string fileName, bool canonicalize) alreadyCanonicalized = true; } // If the path starts with "\??\", we can remove it and we will have the path. - else if (fileName.StartsWith("\\??\\", StringComparison.OrdinalIgnoreCase)) + else if (fileName.StartsWith("\\??\\")) { fileName = fileName.Substring(4); } // If the path still starts with a backslash, we probably need to // resolve any native object name to a DOS drive letter. - if (fileName.StartsWith("\\", StringComparison.OrdinalIgnoreCase)) + if (fileName.StartsWith("\\")) { - foreach (KeyValuePair pair in _fileNamePrefixes) + var prefixes = _fileNamePrefixes; + + foreach (var pair in prefixes) { - if (fileName.StartsWith(pair.Key + "\\", StringComparison.OrdinalIgnoreCase)) + if (fileName.StartsWith(pair.Key + "\\")) { fileName = pair.Value + "\\" + fileName.Substring(pair.Key.Length + 1); break; } - if (fileName == pair.Key) + else if (fileName == pair.Key) { fileName = pair.Value; break; @@ -217,44 +185,42 @@ public static string GetPathForDosDrive(char driveLetter) if (driveLetter < 'A' || driveLetter > 'Z') throw new ArgumentException("The drive letter must be between A to Z (inclusive)."); - using (SymbolicLinkHandle shandle = new SymbolicLinkHandle(@"\??\" + driveLetter + ":", SymbolicLinkAccess.Query)) + using (var shandle = new SymbolicLinkHandle(@"\??\" + driveLetter + ":", SymbolicLinkAccess.Query)) { - return shandle.Target; + return shandle.GetTarget(); } } public static void RefreshFileNamePrefixes() { - if (_fileNamePrefixes == null) - { - // Just create a new dictionary to avoid having to lock the existing one. - _fileNamePrefixes = new Dictionary(); + // Just create a new dictionary to avoid having to lock the existing one. + var newPrefixes = new Dictionary(); - for (char c = 'A'; c <= 'Z'; c++) + for (char c = 'A'; c <= 'Z'; c++) + { + using (var data = new MemoryAlloc(1024)) { - using (MemoryAlloc data = new MemoryAlloc(1024)) - { - int length; + int length; - if ((length = Win32.QueryDosDevice(c.ToString() + ":", data, data.Size/2)) > 2) - { - _fileNamePrefixes.Add(data.ReadUnicodeString(0, length - 2), c.ToString() + ":"); - } + if ((length = Win32.QueryDosDevice(c.ToString() + ":", data, data.Size / 2)) > 2) + { + newPrefixes.Add(data.ReadUnicodeString(0, length - 2), c.ToString() + ":"); } } } + + _fileNamePrefixes = newPrefixes; } public static void ShowProperties(string fileName) { - ShellExecuteInfo info = new ShellExecuteInfo - { - cbSize = ShellExecuteInfo.SizeOf, - lpFile = fileName, - nShow = ShowWindowType.Show, - fMask = Win32.SeeMaskInvokeIdList, - lpVerb = "properties" - }; + var info = new ShellExecuteInfo(); + + info.cbSize = Marshal.SizeOf(info); + info.lpFile = fileName; + info.nShow = ShowWindowType.Show; + info.fMask = Win32.SeeMaskInvokeIdList; + info.lpVerb = "properties"; Win32.ShellExecuteEx(ref info); } diff --git a/1.x/trunk/ProcessHacker.Native/ILoadedModule.cs b/1.x/trunk/ProcessHacker.Native/ILoadedModule.cs index 3af0dd656..5dd450ca2 100644 --- a/1.x/trunk/ProcessHacker.Native/ILoadedModule.cs +++ b/1.x/trunk/ProcessHacker.Native/ILoadedModule.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; namespace ProcessHacker.Native diff --git a/1.x/trunk/ProcessHacker.Native/Image/ImageExports.cs b/1.x/trunk/ProcessHacker.Native/Image/ImageExports.cs index 881867446..8cb4349f0 100644 --- a/1.x/trunk/ProcessHacker.Native/Image/ImageExports.cs +++ b/1.x/trunk/ProcessHacker.Native/Image/ImageExports.cs @@ -21,7 +21,11 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; +using ProcessHacker.Native.Objects; +using ProcessHacker.Native.Security; namespace ProcessHacker.Native.Image { @@ -29,12 +33,12 @@ public unsafe sealed class ImageExports { public delegate bool EnumEntriesDelegate(ImageExportEntry entry); - private readonly MappedImage _mappedImage; - private readonly ImageDataDirectory* _dataDirectory; - private readonly ImageExportDirectory* _exportDirectory; - private readonly int* _addressTable; - private readonly int* _namePointerTable; - private readonly short* _ordinalTable; + private MappedImage _mappedImage; + private ImageDataDirectory* _dataDirectory; + private ImageExportDirectory* _exportDirectory; + private int* _addressTable; + private int* _namePointerTable; + private short* _ordinalTable; internal ImageExports(MappedImage mappedImage) { @@ -56,8 +60,8 @@ public int Count { if (_exportDirectory != null) return _exportDirectory->NumberOfFunctions; - - return 0; + else + return 0; } } @@ -68,10 +72,9 @@ public ImageExportEntry GetEntry(int index) if (index >= _exportDirectory->NumberOfFunctions) return ImageExportEntry.Empty; - ImageExportEntry entry = new ImageExportEntry - { - Ordinal = (short)(this._ordinalTable[index] + this._exportDirectory->Base) - }; + ImageExportEntry entry = new ImageExportEntry(); + + entry.Ordinal = (short)(_ordinalTable[index] + _exportDirectory->Base); if (index < _exportDirectory->NumberOfNames) entry.Name = new string((sbyte*)_mappedImage.RvaToVa(_namePointerTable[index])); @@ -84,7 +87,9 @@ public ImageExportFunction GetFunction(string name) if (_exportDirectory == null || _namePointerTable == null || _ordinalTable == null) return ImageExportFunction.Empty; - int index = this.LookupName(name); + int index; + + index = this.LookupName(name); if (index == -1) return ImageExportFunction.Empty; @@ -107,17 +112,13 @@ public ImageExportFunction GetFunction(short ordinal) ) { // This is a forwarder RVA. - return new ImageExportFunction - { - ForwardedName = new string((sbyte*)_mappedImage.RvaToVa(rva)) - }; + return new ImageExportFunction() { ForwardedName = new string((sbyte*)_mappedImage.RvaToVa(rva)) }; + } + else + { + // This is a function RVA. + return new ImageExportFunction() { Function = (IntPtr)_mappedImage.RvaToVa(rva) }; } - - // This is a function RVA. - return new ImageExportFunction - { - Function = (IntPtr)this._mappedImage.RvaToVa(rva) - }; } private int LookupName(string name) @@ -154,7 +155,7 @@ private int LookupName(string name) public struct ImageExportEntry { - public static readonly ImageExportEntry Empty; + public static readonly ImageExportEntry Empty = new ImageExportEntry(); public string Name; public short Ordinal; @@ -162,7 +163,7 @@ public struct ImageExportEntry public struct ImageExportFunction { - public static readonly ImageExportFunction Empty; + public static readonly ImageExportFunction Empty = new ImageExportFunction(); public IntPtr Function; public string ForwardedName; diff --git a/1.x/trunk/ProcessHacker.Native/Image/ImageImports.cs b/1.x/trunk/ProcessHacker.Native/Image/ImageImports.cs index c8c8e7c80..db466a7fb 100644 --- a/1.x/trunk/ProcessHacker.Native/Image/ImageImports.cs +++ b/1.x/trunk/ProcessHacker.Native/Image/ImageImports.cs @@ -28,10 +28,10 @@ public unsafe sealed class ImageImports { public delegate bool EnumEntriesDelegate(ImageExportEntry entry); - private readonly MappedImage _mappedImage; - private readonly int _count; - private readonly ImageImportDescriptor* _descriptorTable; - private readonly ImageImportDll[] _dlls; + private MappedImage _mappedImage; + private int _count; + private ImageImportDescriptor* _descriptorTable; + private ImageImportDll[] _dlls; internal ImageImports(MappedImage mappedImage) { @@ -82,11 +82,11 @@ public ImageImportDll GetDll(int index) public unsafe sealed class ImageImportDll { - private readonly MappedImage _mappedImage; - private readonly ImageImportDescriptor* _descriptor; + private MappedImage _mappedImage; + private ImageImportDescriptor* _descriptor; private string _name; - private readonly void* _lookupTable; - private readonly int _count; + private void* _lookupTable; + private int _count; internal ImageImportDll(MappedImage mappedImage, ImageImportDescriptor* descriptor) { @@ -144,50 +144,45 @@ public ImageImportEntry GetEntry(int index) if (index >= _count) return ImageImportEntry.Empty; - switch (this._mappedImage.Magic) + if (_mappedImage.Magic == Win32.Pe32Magic) { - case Win32.Pe32Magic: + int entry = ((int*)_lookupTable)[index]; + + // Is this entry using an ordinal? + if ((entry & 0x80000000) != 0) + { + return new ImageImportEntry() { Ordinal = (short)(entry & 0xffff) }; + } + else + { + ImageImportByName* nameEntry = (ImageImportByName*)_mappedImage.RvaToVa(entry); + + return new ImageImportEntry() { - int entry = ((int*)this._lookupTable)[index]; - - // Is this entry using an ordinal? - if ((entry & 0x80000000) != 0) - { - return new ImageImportEntry - { - Ordinal = (short)(entry & 0xffff) - }; - } - - ImageImportByName* nameEntry = (ImageImportByName*)this._mappedImage.RvaToVa(entry); - - return new ImageImportEntry - { - NameHint = nameEntry->Hint, - Name = new string((sbyte*)&nameEntry->Name) - }; - } - case Win32.Pe32PlusMagic: + NameHint = nameEntry->Hint, + Name = new string((sbyte*)&nameEntry->Name) + }; + } + } + else if (_mappedImage.Magic == Win32.Pe32PlusMagic) + { + long entry = ((long*)_lookupTable)[index]; + + // Is this entry using an ordinal? + if (((ulong)entry & 0x8000000000000000) != 0) + { + return new ImageImportEntry() { Ordinal = (short)(entry & 0xffff) }; + } + else + { + ImageImportByName* nameEntry = (ImageImportByName*)_mappedImage.RvaToVa((int)(entry & 0xffffffff)); + + return new ImageImportEntry() { - long entry = ((long*)this._lookupTable)[index]; - - // Is this entry using an ordinal? - if (((ulong)entry & 0x8000000000000000) != 0) - { - return new ImageImportEntry - { - Ordinal = (short)(entry & 0xffff) - }; - } - - ImageImportByName* nameEntry = (ImageImportByName*)this._mappedImage.RvaToVa((int)(entry & 0xffffffff)); - - return new ImageImportEntry - { - NameHint = nameEntry->Hint, - Name = new string((sbyte*)&nameEntry->Name) - }; - } + NameHint = nameEntry->Hint, + Name = new string((sbyte*)&nameEntry->Name) + }; + } } return ImageImportEntry.Empty; diff --git a/1.x/trunk/ProcessHacker.Native/Image/MappedImage.cs b/1.x/trunk/ProcessHacker.Native/Image/MappedImage.cs index b49cf4c63..e86324798 100644 --- a/1.x/trunk/ProcessHacker.Native/Image/MappedImage.cs +++ b/1.x/trunk/ProcessHacker.Native/Image/MappedImage.cs @@ -157,41 +157,52 @@ public int GetChecksum(out int oldChecksum) public ImageDataDirectory* GetDataEntry(ImageDataEntry entry) { - switch (this._magic) + if (_magic == Win32.Pe32Magic) { - case Win32.Pe32Magic: - if ((int)entry >= this._ntHeaders->OptionalHeader.NumberOfRvaAndSizes) - return null; - return &(&this._ntHeaders->OptionalHeader.DataDirectory)[(int)entry]; - case Win32.Pe32PlusMagic: - if ((int)entry >= this.GetOptionalHeader64()->NumberOfRvaAndSizes) - return null; - return &(&this.GetOptionalHeader64()->DataDirectory)[(int)entry]; - default: + if ((int)entry >= _ntHeaders->OptionalHeader.NumberOfRvaAndSizes) return null; + + return &(&_ntHeaders->OptionalHeader.DataDirectory)[(int)entry]; + } + else if (_magic == Win32.Pe32PlusMagic) + { + if ((int)entry >= this.GetOptionalHeader64()->NumberOfRvaAndSizes) + return null; + + return &(&this.GetOptionalHeader64()->DataDirectory)[(int)entry]; + } + else + { + return null; } } public ImageExportDirectory* GetExportDirectory() { - ImageDataDirectory* dataEntry = this.GetDataEntry(ImageDataEntry.Export); + ImageDataDirectory* dataEntry; + + dataEntry = this.GetDataEntry(ImageDataEntry.Export); return (ImageExportDirectory*)this.RvaToVa(dataEntry->VirtualAddress); } public ImageImportDescriptor* GetImportDirectory() { - ImageDataDirectory* dataEntry = this.GetDataEntry(ImageDataEntry.Import); + ImageDataDirectory* dataEntry; + + dataEntry = this.GetDataEntry(ImageDataEntry.Import); return (ImageImportDescriptor*)this.RvaToVa(dataEntry->VirtualAddress); } private void* GetLoadConfig(short magic) { + ImageDataDirectory* dataEntry; + if (_magic != magic) return null; - ImageDataDirectory* dataEntry = this.GetDataEntry(ImageDataEntry.LoadConfig); + dataEntry = this.GetDataEntry(ImageDataEntry.LoadConfig); if (dataEntry == null) return null; @@ -211,14 +222,17 @@ public int GetChecksum(out int oldChecksum) private ImageNtHeaders* GetNtHeaders() { - int offset = *((int*)((byte*)this._memory + 0x3c)); + int offset; + ImageNtHeaders* ntHeaders; + + offset = *((int*)((byte*)_memory + 0x3c)); if (offset == 0) throw new Exception("Invalid NT headers offset."); if (offset >= 0x10000000 || offset >= _size) throw new Exception("The NT headers offset is too large."); - ImageNtHeaders* ntHeaders = (ImageNtHeaders*)((byte*)this._memory + offset); + ntHeaders = (ImageNtHeaders*)((byte*)_memory + offset); return ntHeaders; } @@ -271,7 +285,7 @@ private void MapAndLoad(FileHandle fileHandle, bool readOnly) readOnly ? MemoryProtection.ExecuteRead : MemoryProtection.ExecuteReadWrite )) { - _size = (int)fileHandle.FileSize; + _size = (int)fileHandle.GetSize(); _view = section.MapView(_size); this.Load(_view); @@ -299,7 +313,9 @@ private void MapAndLoad(FileHandle fileHandle, bool readOnly) public void* RvaToVa(int rva) { - ImageSectionHeader* section = this.RvaToSection(rva); + ImageSectionHeader* section; + + section = this.RvaToSection(rva); if (section == null) return null; diff --git a/1.x/trunk/ProcessHacker.Native/ImpersonationContext.cs b/1.x/trunk/ProcessHacker.Native/ImpersonationContext.cs index f35c10a0b..cfba70324 100644 --- a/1.x/trunk/ProcessHacker.Native/ImpersonationContext.cs +++ b/1.x/trunk/ProcessHacker.Native/ImpersonationContext.cs @@ -6,7 +6,7 @@ namespace ProcessHacker.Native { public class ImpersonationContext : IDisposable { - private bool _disposed; + private bool _disposed = false; public ImpersonationContext(TokenHandle token) { @@ -16,11 +16,11 @@ public ImpersonationContext(TokenHandle token) public void Dispose() { - if (_disposed) - return; - - Win32.RevertToSelf(); - this._disposed = true; + if (!_disposed) + { + Win32.RevertToSelf(); + _disposed = true; + } } } } diff --git a/1.x/trunk/ProcessHacker.Native/IntPtrExtensions.cs b/1.x/trunk/ProcessHacker.Native/IntPtrExtensions.cs index 192721828..664fa81f3 100644 --- a/1.x/trunk/ProcessHacker.Native/IntPtrExtensions.cs +++ b/1.x/trunk/ProcessHacker.Native/IntPtrExtensions.cs @@ -22,6 +22,7 @@ */ using System; +using System.Runtime.InteropServices; namespace ProcessHacker.Native { @@ -34,34 +35,26 @@ public static IntPtr Align(this IntPtr ptr, int alignment) public static IntPtr And(this IntPtr ptr, int value) { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(ptr.ToInt32() & value); - default: - return new IntPtr(ptr.ToInt64() & value); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(ptr.ToInt32() & value); + else + return new IntPtr(ptr.ToInt64() & value); } public static IntPtr And(this IntPtr ptr, IntPtr value) { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(ptr.ToInt32() & value.ToInt32()); - default: - return new IntPtr(ptr.ToInt64() & value.ToInt64()); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(ptr.ToInt32() & value.ToInt32()); + else + return new IntPtr(ptr.ToInt64() & value.ToInt64()); } public static int CompareTo(this IntPtr ptr, IntPtr ptr2) { if (ptr.ToUInt64() > ptr2.ToUInt64()) return 1; - if (ptr.ToUInt64() < ptr2.ToUInt64()) return -1; - return 0; } @@ -74,22 +67,17 @@ public static int CompareTo(this IntPtr ptr, uint ptr2) { if (ptr.ToUInt64() > ptr2) return 1; - if (ptr.ToUInt64() < ptr2) return -1; - return 0; } public static IntPtr Decrement(this IntPtr ptr, IntPtr ptr2) { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(ptr.ToInt32() - ptr2.ToInt32()); - default: - return new IntPtr(ptr.ToInt64() - ptr2.ToInt64()); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(ptr.ToInt32() - ptr2.ToInt32()); + else + return new IntPtr(ptr.ToInt64() - ptr2.ToInt64()); } public static IntPtr Decrement(this IntPtr ptr, int value) @@ -102,6 +90,13 @@ public static IntPtr Decrement(this IntPtr ptr, long value) return Increment(ptr, -value); } + public static T ElementAt(this IntPtr ptr, int index) + { + var offset = Marshal.SizeOf(typeof(T)) * index; + var offsetPtr = ptr.Increment(offset); + return (T)Marshal.PtrToStructure(offsetPtr, typeof(T)); + } + public static bool Equals(this IntPtr ptr, IntPtr ptr2) { return ptr == ptr2; @@ -131,13 +126,10 @@ public static IntPtr Increment(this IntPtr ptr, int value) { unchecked { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(ptr.ToInt32() + value); - default: - return new IntPtr(ptr.ToInt64() + value); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(ptr.ToInt32() + value); + else + return new IntPtr(ptr.ToInt64() + value); } } @@ -145,13 +137,10 @@ public static IntPtr Increment(this IntPtr ptr, long value) { unchecked { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr((int)(ptr.ToInt32() + value)); - default: - return new IntPtr(ptr.ToInt64() + value); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr((int)(ptr.ToInt32() + value)); + else + return new IntPtr(ptr.ToInt64() + value); } } @@ -159,16 +148,18 @@ public static IntPtr Increment(this IntPtr ptr, IntPtr ptr2) { unchecked { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(ptr.ToInt32() + ptr2.ToInt32()); - default: - return new IntPtr(ptr.ToInt64() + ptr2.ToInt64()); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(ptr.ToInt32() + ptr2.ToInt32()); + else + return new IntPtr(ptr.ToInt64() + ptr2.ToInt64()); } } + public static IntPtr Increment(this IntPtr ptr) + { + return ptr.Increment(Marshal.SizeOf(typeof(T))); + } + public static bool IsGreaterThanOrEqualTo(this IntPtr ptr, IntPtr ptr2) { return ptr.CompareTo(ptr2) >= 0; @@ -181,40 +172,40 @@ public static bool IsLessThanOrEqualTo(this IntPtr ptr, IntPtr ptr2) public static IntPtr Not(this IntPtr ptr) { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(~ptr.ToInt32()); - default: - return new IntPtr(~ptr.ToInt64()); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(~ptr.ToInt32()); + else + return new IntPtr(~ptr.ToInt64()); } public static IntPtr Or(this IntPtr ptr, IntPtr value) { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(ptr.ToInt32() | value.ToInt32()); - default: - return new IntPtr(ptr.ToInt64() | value.ToInt64()); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(ptr.ToInt32() | value.ToInt32()); + else + return new IntPtr(ptr.ToInt64() | value.ToInt64()); } - public unsafe static uint ToUInt32(this IntPtr ptr) + public static uint ToUInt32(this IntPtr ptr) { // Avoid sign-extending the pointer - we want it zero-extended. - void* voidPtr = (void*)ptr; + unsafe + { + void* voidPtr = (void*)ptr; - return (uint)voidPtr; + return (uint)voidPtr; + } } - public unsafe static ulong ToUInt64(this IntPtr ptr) + public static ulong ToUInt64(this IntPtr ptr) { // Avoid sign-extending the pointer - we want it zero-extended. - void* voidPtr = (void*)ptr; + unsafe + { + void* voidPtr = (void*)ptr; - return (ulong)voidPtr; + return (ulong)voidPtr; + } } public static IntPtr ToIntPtr(this int value) @@ -251,13 +242,10 @@ public static IntPtr ToIntPtr(this ulong value) public static IntPtr Xor(this IntPtr ptr, IntPtr value) { - switch (IntPtr.Size) - { - case sizeof(int): - return new IntPtr(ptr.ToInt32() ^ value.ToInt32()); - default: - return new IntPtr(ptr.ToInt64() ^ value.ToInt64()); - } + if (IntPtr.Size == sizeof(Int32)) + return new IntPtr(ptr.ToInt32() ^ value.ToInt32()); + else + return new IntPtr(ptr.ToInt64() ^ value.ToInt64()); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Io/BeepDevice.cs b/1.x/trunk/ProcessHacker.Native/Io/BeepDevice.cs index 355b95db6..68ab2c533 100644 --- a/1.x/trunk/ProcessHacker.Native/Io/BeepDevice.cs +++ b/1.x/trunk/ProcessHacker.Native/Io/BeepDevice.cs @@ -13,15 +13,8 @@ public static class BeepDevice [StructLayout(LayoutKind.Sequential)] public struct BeepSetParameters { - public static readonly int SizeOf; - public int Frequency; public int Duration; - - static BeepSetParameters() - { - SizeOf = Marshal.SizeOf(typeof(BeepSetParameters)); - } } public const int BeepFrequencyMinimum = 0x25; @@ -29,15 +22,18 @@ static BeepSetParameters() public static readonly int IoCtlSet = Win32.CtlCode(DeviceType.Beep, 0, DeviceControlMethod.Buffered, DeviceControlAccess.Any); - public static unsafe void Beep(int frequency, int duration) + public static void Beep(int frequency, int duration) { - BeepSetParameters p; + unsafe + { + BeepSetParameters p; - p.Frequency = frequency; - p.Duration = duration; + p.Frequency = frequency; + p.Duration = duration; - using (var fhandle = OpenBeepDevice(FileAccess.GenericRead)) - fhandle.IoControl(IoCtlSet, &p, BeepSetParameters.SizeOf, null, 0); + using (var fhandle = OpenBeepDevice(FileAccess.GenericRead)) + fhandle.IoControl(IoCtlSet, &p, Marshal.SizeOf(typeof(BeepSetParameters)), null, 0); + } } private static FileHandle OpenBeepDevice(FileAccess access) diff --git a/1.x/trunk/ProcessHacker.Native/Io/DiskDevice.cs b/1.x/trunk/ProcessHacker.Native/Io/DiskDevice.cs index 845d17b88..8894a1925 100644 --- a/1.x/trunk/ProcessHacker.Native/Io/DiskDevice.cs +++ b/1.x/trunk/ProcessHacker.Native/Io/DiskDevice.cs @@ -1,5 +1,8 @@ -using System.Runtime.InteropServices; - +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using ProcessHacker.Native; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; @@ -8,7 +11,7 @@ namespace ProcessHacker.Native.Io { public static class DiskDevice { - public enum DiskCacheState + public enum DiskCacheState : int { Normal, WriteThroughNotSupported, @@ -19,17 +22,10 @@ public enum DiskCacheState [StructLayout(LayoutKind.Sequential)] public struct DiskCacheSetting { - public static readonly int SizeOf; - public int Version; public DiskCacheState State; [MarshalAs(UnmanagedType.I1)] public bool IsPowerProtected; - - static DiskCacheSetting() - { - SizeOf = Marshal.SizeOf(typeof(DiskCacheSetting)); - } } [StructLayout(LayoutKind.Sequential)] @@ -71,21 +67,24 @@ public static DiskCacheState GetCacheSetting(string fileName, out bool isPowerPr return GetCacheSetting(fhandle, out isPowerProtected); } - public static unsafe DiskCacheState GetCacheSetting(FileHandle fileHandle, out bool isPowerProtected) + public static DiskCacheState GetCacheSetting(FileHandle fileHandle, out bool isPowerProtected) { - DiskCacheSetting diskCacheSetting; + unsafe + { + DiskCacheSetting diskCacheSetting; - fileHandle.IoControl( - IoCtlGetCacheSetting, - null, - 0, - &diskCacheSetting, - DiskCacheSetting.SizeOf - ); + fileHandle.IoControl( + IoCtlGetCacheSetting, + null, + 0, + &diskCacheSetting, + Marshal.SizeOf(typeof(DiskCacheSetting)) + ); - isPowerProtected = diskCacheSetting.IsPowerProtected; + isPowerProtected = diskCacheSetting.IsPowerProtected; - return diskCacheSetting.State; + return diskCacheSetting.State; + } } public static void SetCacheSetting(string fileName, DiskCacheState state, bool isPowerProtected) @@ -94,21 +93,24 @@ public static void SetCacheSetting(string fileName, DiskCacheState state, bool i SetCacheSetting(fhandle, state, isPowerProtected); } - public static unsafe void SetCacheSetting(FileHandle fileHandle, DiskCacheState state, bool isPowerProtected) + public static void SetCacheSetting(FileHandle fileHandle, DiskCacheState state, bool isPowerProtected) { - DiskCacheSetting diskCacheSetting; - - diskCacheSetting.Version = DiskCacheSetting.SizeOf; - diskCacheSetting.State = state; - diskCacheSetting.IsPowerProtected = isPowerProtected; - - fileHandle.IoControl( - IoCtlSetCacheSetting, - &diskCacheSetting, - DiskCacheSetting.SizeOf, - null, - 0 - ); + unsafe + { + DiskCacheSetting diskCacheSetting; + + diskCacheSetting.Version = Marshal.SizeOf(typeof(DiskCacheSetting)); + diskCacheSetting.State = state; + diskCacheSetting.IsPowerProtected = isPowerProtected; + + fileHandle.IoControl( + IoCtlSetCacheSetting, + &diskCacheSetting, + Marshal.SizeOf(typeof(DiskCacheSetting)), + null, + 0 + ); + } } } } diff --git a/1.x/trunk/ProcessHacker.Native/Io/MountManager.cs b/1.x/trunk/ProcessHacker.Native/Io/MountManager.cs index 4091332cc..cd9e2eee0 100644 --- a/1.x/trunk/ProcessHacker.Native/Io/MountManager.cs +++ b/1.x/trunk/ProcessHacker.Native/Io/MountManager.cs @@ -21,7 +21,10 @@ */ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Text; +using ProcessHacker.Native; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; @@ -44,12 +47,7 @@ public struct MountMgrCreatePointInput [StructLayout(LayoutKind.Sequential)] public struct MountMgrMountPoint { - public static readonly int SizeOf; - - static MountMgrMountPoint() - { - SizeOf = Marshal.SizeOf(typeof(MountMgrMountPoint)); - } + public static readonly int Size = Marshal.SizeOf(typeof(MountMgrMountPoint)); public int SymbolicLinkNameOffset; public ushort SymbolicLinkNameLength; @@ -96,17 +94,12 @@ public struct MountMgrDriveLetterInformation [StructLayout(LayoutKind.Sequential)] public struct MountMgrVolumeMountPoint { - public static readonly int SizeOf; + public static readonly int Size = Marshal.SizeOf(typeof(MountMgrVolumeMountPoint)); public ushort SourceVolumeNameOffset; public ushort SourceVolumeNameLength; public ushort TargetVolumeNameOffset; public ushort TargetVolumeNameLength; - - static MountMgrVolumeMountPoint() - { - SizeOf = Marshal.SizeOf(typeof(MountMgrVolumeMountPoint)); - } } // Input, output for IoCtlChangeNotify @@ -172,16 +165,14 @@ public struct MountDevName private static void DeleteSymbolicLink(string path) { - using (MemoryAlloc data = new MemoryAlloc(MountMgrMountPoint.SizeOf + path.Length * 2)) - using (MemoryAlloc outData = new MemoryAlloc(1600)) + using (var data = new MemoryAlloc(MountMgrMountPoint.Size + path.Length * 2)) + using (var outData = new MemoryAlloc(1600)) { - MountMgrMountPoint mountPoint = new MountMgrMountPoint - { - SymbolicLinkNameLength = (ushort)(path.Length*2), - SymbolicLinkNameOffset = MountMgrMountPoint.SizeOf - }; + MountMgrMountPoint mountPoint = new MountMgrMountPoint(); - data.WriteStruct(mountPoint); + mountPoint.SymbolicLinkNameLength = (ushort)(path.Length * 2); + mountPoint.SymbolicLinkNameOffset = MountMgrMountPoint.Size; + data.WriteStruct(mountPoint); data.WriteUnicodeString(mountPoint.SymbolicLinkNameOffset, path); using (var fhandle = OpenMountManager(FileAccess.GenericRead | FileAccess.GenericWrite)) @@ -201,7 +192,7 @@ private static void DeleteSymbolicLink(string path) /// The device name associated with the DOS drive. public static string GetDeviceName(string fileName) { - using (FileHandle fhandle = new FileHandle( + using (var fhandle = new FileHandle( fileName, FileShareMode.ReadWrite, FileCreateOptions.SynchronousIoNonAlert, @@ -212,7 +203,7 @@ public static string GetDeviceName(string fileName) public static string GetDeviceName(FileHandle fhandle) { - using (MemoryAlloc data = new MemoryAlloc(600)) + using (var data = new MemoryAlloc(600)) { fhandle.IoControl(IoCtlQueryDeviceName, IntPtr.Zero, 0, data, data.Size); @@ -224,7 +215,7 @@ public static string GetDeviceName(FileHandle fhandle) private static string GetReparsePointTarget(FileHandle fhandle) { - using (MemoryAlloc data = new MemoryAlloc(FileSystem.MaximumReparseDataBufferSize)) + using (var data = new MemoryAlloc(FileSystem.MaximumReparseDataBufferSize)) { fhandle.IoControl(FileSystem.FsCtlGetReparsePoint, IntPtr.Zero, 0, data, data.Size); @@ -299,15 +290,13 @@ public static string GetVolumeName(char driveLetter) public static string GetVolumeName(string deviceName) { - using (MemoryAlloc data = new MemoryAlloc(MountMgrMountPoint.SizeOf + deviceName.Length * 2)) + using (var data = new MemoryAlloc(MountMgrMountPoint.Size + deviceName.Length * 2)) { - MountMgrMountPoint mountPoint = new MountMgrMountPoint - { - DeviceNameLength = (ushort)(deviceName.Length*2), - DeviceNameOffset = MountMgrMountPoint.SizeOf - }; + MountMgrMountPoint mountPoint = new MountMgrMountPoint(); - data.WriteStruct(mountPoint); + mountPoint.DeviceNameLength = (ushort)(deviceName.Length * 2); + mountPoint.DeviceNameOffset = MountMgrMountPoint.Size; + data.WriteStruct(mountPoint); data.WriteUnicodeString(mountPoint.DeviceNameOffset, deviceName); using (var fhandle = OpenMountManager((FileAccess)StandardRights.Synchronize)) @@ -315,7 +304,7 @@ public static string GetVolumeName(string deviceName) NtStatus status; int retLength; - using (MemoryAlloc outData = new MemoryAlloc(0x100)) + using (var outData = new MemoryAlloc(0x100)) { while (true) { @@ -339,7 +328,8 @@ out retLength } } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); MountMgrMountPoints mountPoints = outData.ReadStruct(); @@ -349,11 +339,11 @@ out retLength { MountMgrMountPoint mp = outData.ReadStruct( MountMgrMountPoints.MountPointsOffset, - MountMgrMountPoint.SizeOf, i ); + string symLinkName; - string symLinkName = Marshal.PtrToStringUni( + symLinkName = Marshal.PtrToStringUni( outData.Memory.Increment(mp.SymbolicLinkNameOffset), mp.SymbolicLinkNameLength / 2 ); @@ -372,20 +362,20 @@ public static bool IsDriveLetterPath(string path) { if ( path.Length == 14 && - path.StartsWith(@"\DosDevices\", StringComparison.OrdinalIgnoreCase) && + path.StartsWith(@"\DosDevices\") && path[12] >= 'A' && path[12] <= 'Z' && path[13] == ':' ) return true; - - return false; + else + return false; } public static bool IsVolumePath(string path) { if ( (path.Length == 48 || (path.Length == 49 && path[48] == '\\')) && - (path.StartsWith(@"\??\Volume", StringComparison.OrdinalIgnoreCase) || path.StartsWith(@"\\?\Volume", StringComparison.OrdinalIgnoreCase)) && + (path.StartsWith(@"\??\Volume") || path.StartsWith(@"\\?\Volume")) && path[10] == '{' && path[19] == '-' && path[24] == '-' && @@ -394,32 +384,31 @@ public static bool IsVolumePath(string path) path[47] == '}' ) return true; - - return false; + else + return false; } private static void Notify(bool created, string sourceVolumeName, string targetVolumeName) { - using (MemoryAlloc data = new MemoryAlloc( - MountMgrVolumeMountPoint.SizeOf + + using (var data = new MemoryAlloc( + MountMgrVolumeMountPoint.Size + sourceVolumeName.Length * 2 + targetVolumeName.Length * 2 )) { - MountMgrVolumeMountPoint mountPoint = new MountMgrVolumeMountPoint - { - SourceVolumeNameLength = (ushort)(sourceVolumeName.Length * 2), - SourceVolumeNameOffset = (ushort)MountMgrVolumeMountPoint.SizeOf, - TargetVolumeNameLength = (ushort)(targetVolumeName.Length * 2) - }; + MountMgrVolumeMountPoint mountPoint = new MountMgrVolumeMountPoint(); - mountPoint.TargetVolumeNameOffset = (ushort)(mountPoint.SourceVolumeNameOffset + mountPoint.SourceVolumeNameLength); + mountPoint.SourceVolumeNameLength = (ushort)(sourceVolumeName.Length * 2); + mountPoint.SourceVolumeNameOffset = (ushort)MountMgrVolumeMountPoint.Size; + mountPoint.TargetVolumeNameLength = (ushort)(targetVolumeName.Length * 2); + mountPoint.TargetVolumeNameOffset = + (ushort)(mountPoint.SourceVolumeNameOffset + mountPoint.SourceVolumeNameLength); - data.WriteStruct(mountPoint); + data.WriteStruct(mountPoint); data.WriteUnicodeString(mountPoint.SourceVolumeNameOffset, sourceVolumeName); data.WriteUnicodeString(mountPoint.TargetVolumeNameOffset, targetVolumeName); - using (FileHandle fhandle = OpenMountManager(FileAccess.GenericRead | FileAccess.GenericWrite)) + using (var fhandle = OpenMountManager(FileAccess.GenericRead | FileAccess.GenericWrite)) { fhandle.IoControl( created ? IoCtlVolumeMountPointCreated : IoCtlVolumeMountPointDeleted, diff --git a/1.x/trunk/ProcessHacker.Native/Io/StorageDevice.cs b/1.x/trunk/ProcessHacker.Native/Io/StorageDevice.cs index 8184df4db..532831101 100644 --- a/1.x/trunk/ProcessHacker.Native/Io/StorageDevice.cs +++ b/1.x/trunk/ProcessHacker.Native/Io/StorageDevice.cs @@ -23,8 +23,6 @@ public struct StoragePreventMediaRemoval [StructLayout(LayoutKind.Sequential)] public struct StorageHotplugInfo { - public static readonly int SizeOf; - public int Size; [MarshalAs(UnmanagedType.I1)] public bool MediaRemovable; @@ -34,11 +32,6 @@ public struct StorageHotplugInfo public bool DeviceHotplug; [MarshalAs(UnmanagedType.I1)] public bool WriteCacheEnableOverride; - - static StorageHotplugInfo() - { - SizeOf = Marshal.SizeOf(typeof(StorageHotplugInfo)); - } } public static readonly int IoCtlMediaRemoval = Win32.CtlCode(DeviceType.MassStorage, 0x0201, DeviceControlMethod.Buffered, DeviceControlAccess.Read); @@ -68,13 +61,16 @@ public static StorageHotplugInfo GetHotplugInfo(string fileName) return GetHotplugInfo(fhandle); } - public static unsafe StorageHotplugInfo GetHotplugInfo(FileHandle fileHandle) + public static StorageHotplugInfo GetHotplugInfo(FileHandle fileHandle) { - StorageHotplugInfo hotplugInfo; + unsafe + { + StorageHotplugInfo hotplugInfo; - fileHandle.IoControl(IoCtlGetHotplugInfo, null, 0, &hotplugInfo, StorageHotplugInfo.SizeOf); + fileHandle.IoControl(IoCtlGetHotplugInfo, null, 0, &hotplugInfo, Marshal.SizeOf(typeof(StorageHotplugInfo))); - return hotplugInfo; + return hotplugInfo; + } } public static FileHandle OpenStorageDevice(string fileName, FileAccess access) diff --git a/1.x/trunk/ProcessHacker.Native/Ipc/IpcCircularBuffer.cs b/1.x/trunk/ProcessHacker.Native/Ipc/IpcCircularBuffer.cs index dc560f6e8..d8f935285 100644 --- a/1.x/trunk/ProcessHacker.Native/Ipc/IpcCircularBuffer.cs +++ b/1.x/trunk/ProcessHacker.Native/Ipc/IpcCircularBuffer.cs @@ -28,18 +28,11 @@ namespace ProcessHacker.Native.Ipc { - public unsafe class IpcCircularBuffer : IDisposable + public unsafe class IpcCircularBuffer { [StructLayout(LayoutKind.Sequential)] - public struct BufferHeader + private struct BufferHeader { - public static readonly int SizeOf; - - static BufferHeader() - { - SizeOf = Marshal.SizeOf(typeof(BufferHeader)); - } - public int BlockSize; public int NumberOfBlocks; @@ -57,21 +50,22 @@ public static IpcCircularBuffer Create(string name, int blockSize, int numberOfB Random r = new Random(); long readSemaphoreId = ((long)r.Next() << 32) + r.Next(); long writeSemaphoreId = ((long)r.Next() << 32) + r.Next(); + Section section; - Section section = new Section(name, blockSize * numberOfBlocks, MemoryProtection.ReadWrite); + section = new Section(name, blockSize * numberOfBlocks, MemoryProtection.ReadWrite); - using (SectionView view = section.MapView(BufferHeader.SizeOf)) + using (var view = section.MapView(Marshal.SizeOf(typeof(BufferHeader)))) { - BufferHeader header = new BufferHeader - { - BlockSize = blockSize, - NumberOfBlocks = numberOfBlocks, - ReadSemaphoreId = readSemaphoreId, - WriteSemaphoreId = writeSemaphoreId, - ReadPosition = 0, WritePosition = 0 - }; - - view.WriteStruct(header); + BufferHeader header = new BufferHeader(); + + header.BlockSize = blockSize; + header.NumberOfBlocks = numberOfBlocks; + header.ReadSemaphoreId = readSemaphoreId; + header.WriteSemaphoreId = writeSemaphoreId; + header.ReadPosition = 0; + header.WritePosition = 0; + + view.WriteStruct(header); } return new IpcCircularBuffer( @@ -87,13 +81,13 @@ public static IpcCircularBuffer Open(string name) return new IpcCircularBuffer(new Section(name, SectionAccess.All), name, null, null); } - private readonly Section _section; - private readonly SectionView _sectionView; - private readonly Semaphore _readSemaphore; - private readonly Semaphore _writeSemaphore; + private Section _section; + private SectionView _sectionView; + private Semaphore _readSemaphore; + private Semaphore _writeSemaphore; - private readonly BufferHeader* _header; - private readonly void* _data; + private BufferHeader* _header; + private void* _data; private IpcCircularBuffer(Section section, string sectionName, Semaphore readSemaphore, Semaphore writeSemaphore) { @@ -101,7 +95,7 @@ private IpcCircularBuffer(Section section, string sectionName, Semaphore readSem _section = section; - _sectionView = section.MapView(BufferHeader.SizeOf); + _sectionView = section.MapView(Marshal.SizeOf(typeof(BufferHeader))); header = _sectionView.ReadStruct(); _sectionView.Dispose(); @@ -121,17 +115,16 @@ private IpcCircularBuffer(Section section, string sectionName, Semaphore readSem _data = &_header->Data; } - public T Read() where T : struct + public T Read() + where T : struct { - using (MemoryAlloc data = this.Read()) - { + using (var data = this.Read()) return data.ReadStruct(); - } } public MemoryAlloc Read() { - MemoryAlloc data = new MemoryAlloc(_header->BlockSize); + var data = new MemoryAlloc(_header->BlockSize); this.Read(data); @@ -175,12 +168,13 @@ public void Read(void* buffer) _writeSemaphore.Release(); } - public void Write(int size, T s) where T : struct + public void Write(T s) + where T : struct { - using (MemoryAlloc data = new MemoryAlloc(size)) + using (var data = new MemoryAlloc(Marshal.SizeOf(typeof(T)))) { - data.WriteStruct(s); - this.Write(data); + data.WriteStruct(s); + this.Write((MemoryRegion)data); } } @@ -225,14 +219,5 @@ public void Write(void* buffer) // Release the read semaphore to allow a reader to read one more block. _readSemaphore.Release(); } - - public void Dispose() - { - if (_readSemaphore != null) - _readSemaphore.Dispose(); - - if (_writeSemaphore != null) - _writeSemaphore.Dispose(); - } } } diff --git a/1.x/trunk/ProcessHacker.Native/KProcessHacker.cs b/1.x/trunk/ProcessHacker.Native/KProcessHacker.cs index 4c31da159..2d3d6b06c 100644 --- a/1.x/trunk/ProcessHacker.Native/KProcessHacker.cs +++ b/1.x/trunk/ProcessHacker.Native/KProcessHacker.cs @@ -2,7 +2,7 @@ * Process Hacker - * KProcessHacker interfacing code * - * Copyright (C) 2009-2011 wj32 + * Copyright (C) 2009 wj32 * * This file is part of Process Hacker. * @@ -23,96 +23,134 @@ // The private field 'field' is assigned but its value is never used #pragma warning disable 0414 +using System; using System.Runtime.InteropServices; +using System.Text; using System.Windows.Forms; -using ProcessHacker.Native; +using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; +using ProcessHacker.Native.SsLogging; -namespace System +namespace ProcessHacker.Native { /// /// Provides an interface to KProcessHacker. /// - public sealed unsafe class KProcessHacker2 : IDisposable + public sealed unsafe class KProcessHacker { - public static KProcessHacker2 Instance; + private static KProcessHacker _instance; - public bool KphIsConnected + public static KProcessHacker Instance { - get { return _fileHandle != null; } + get { return _instance; } + set { _instance = value; } } - public static int KphCtlCode(int x) + /// + /// A control code used by KProcessHacker to represent a specific function. + /// + private enum Control : uint { - return Win32.CtlCode((DeviceType)KphDeviceType, 0x800 + x, DeviceControlMethod.Neither, DeviceControlAccess.Any); + ClientCloseHandle = 0, + SsQueryClientEntry, + Reserved1, + KphOpenProcess, + KphOpenThread, + KphOpenProcessToken, + GetProcessProtected, + SetProcessProtected, + KphTerminateProcess, + KphSuspendProcess, + KphResumeProcess, + KphReadVirtualMemory, + KphWriteVirtualMemory, + SetProcessToken, + GetThreadStartAddress, + SetHandleAttributes, + GetHandleObjectName, + KphOpenProcessJob, + KphGetContextThread, + KphSetContextThread, + KphGetThreadWin32Thread, + KphDuplicateObject, + ZwQueryObject, + KphGetProcessId, + KphGetThreadId, + KphTerminateThread, + GetFeatures, + KphSetHandleGrantedAccess, + KphAssignImpersonationToken, + ProtectAdd, + ProtectRemove, + ProtectQuery, + KphUnsafeReadVirtualMemory, + SetExecuteOptions, + KphQueryProcessHandles, + KphOpenThreadProcess, + KphCaptureStackBackTraceThread, + KphDangerousTerminateThread, + KphOpenType, + KphOpenDriver, + KphQueryInformationDriver, + KphOpenDirectoryObject, + SsRef, + SsUnref, + SsCreateClientEntry, + SsCreateRuleSetEntry, + SsRemoveRule, + SsAddProcessIdRule, + SsAddThreadIdRule, + SsAddPreviousModeRule, + SsAddNumberRule, + SsEnableClientEntry, + KphOpenNamedObject, + KphQueryInformationProcess, + KphQueryInformationThread, + KphSetInformationProcess, + KphSetInformationThread, } - public const int KphDeviceType = 0x9999; - - // General - public static readonly int IoCtlGetFeatures = KphCtlCode(0); - - // Processes - public static readonly int IoCtlOpenProcess = KphCtlCode(50); - public static readonly int IoCtlOpenProcessToken = KphCtlCode(51); - public static readonly int IoCtlOpenProcessJob = KphCtlCode(52); - public static readonly int IoCtlSuspendProcess = KphCtlCode(53); - public static readonly int IoCtlResumeProcess = KphCtlCode(54); - public static readonly int IoCtlTerminateProcess = KphCtlCode(55); - public static readonly int IoCtlReadVirtualMemory = KphCtlCode(56); - public static readonly int IoCtlWriteVirtualMemory = KphCtlCode(57); - public static readonly int IoCtlReadVirtualMemoryUnsafe = KphCtlCode(58); - public static readonly int IoCtlQueryInformationProcess = KphCtlCode(59); - public static readonly int IoCtlSetInformationProcess = KphCtlCode(60); - - // Threads - public static readonly int IoCtlOpenThread = KphCtlCode(100); - public static readonly int IoCtlOpenThreadProcess = KphCtlCode(101); - public static readonly int IoCtlTerminateThread = KphCtlCode(102); - public static readonly int IoCtlTerminateThreadUnsafe = KphCtlCode(103); - public static readonly int IoCtlGetContextThread = KphCtlCode(104); - public static readonly int IoCtlSetContextThread = KphCtlCode(105); - public static readonly int IoCtlCaptureStackBackTraceThread = KphCtlCode(106); - public static readonly int IoCtlQueryInformationThread = KphCtlCode(107); - public static readonly int IoCtlSetInformationThread = KphCtlCode(108); - - // Handles - public static readonly int IoCtlEnumerateProcessHandles = KphCtlCode(150); - public static readonly int IoCtlQueryInformationObject = KphCtlCode(151); - public static readonly int IoCtlSetInformationObject = KphCtlCode(152); - public static readonly int IoCtlDuplicateObject = KphCtlCode(153); - - // Misc. - public static readonly int IoCtlOpenDriver = KphCtlCode(200); - public static readonly int IoCtlQueryInformationDriver = KphCtlCode(201); - [Flags] - public enum KphFeatures + public enum KphFeatures : int { - None = 0 // none so far + PsTerminateProcess = 0x1, + PspTerminateThreadByPointer = 0x2 } - private readonly string _deviceName; + private string _deviceName; private FileHandle _fileHandle; - private readonly KphFeatures _features; + private uint _baseControlNumber; + private KphFeatures _features; + + /// + /// Creates a connection to KProcessHacker. + /// + public KProcessHacker() + : this("KProcessHacker") + { } /// /// Creates a connection to KProcessHacker. /// - public KProcessHacker2() - : this("KProcessHacker2") + /// The name of the KProcessHacker service and device. + public KProcessHacker(string deviceName) + : this(deviceName, Application.StartupPath + "\\kprocesshacker.sys") { } /// /// Creates a connection to KProcessHacker. /// /// The name of the KProcessHacker service and device. - public KProcessHacker2(string deviceName) + /// The file name of the KProcessHacker driver. + public KProcessHacker(string deviceName, string fileName) { _deviceName = deviceName; + if (OSVersion.Architecture != OSArch.I386) + throw new NotSupportedException("KProcessHacker does not support 64-bit Windows."); + try { _fileHandle = new FileHandle( @@ -129,7 +167,53 @@ public KProcessHacker2(string deviceName) ex.Status == NtStatus.ObjectNameNotFound ) { - LoadService(); + // Attempt to load the driver, then try again. + ServiceHandle shandle; + bool created = false; + + try + { + using (shandle = new ServiceHandle("KProcessHacker", ServiceAccess.Start)) + { + shandle.Start(); + } + } + catch + { + using (var scm = new ServiceManagerHandle(ScManagerAccess.CreateService)) + { + shandle = scm.CreateService( + deviceName, + deviceName, + ServiceType.KernelDriver, + fileName + ); + shandle.Start(); + created = true; + } + } + + try + { + _fileHandle = new FileHandle( + @"\Device\" + deviceName, + 0, + FileAccess.GenericRead | FileAccess.GenericWrite + ); + } + finally + { + if (shandle != null) + { + if (created) + { + // The SCM will delete the service when it is stopped. + shandle.Delete(); + } + + shandle.Dispose(); + } + } } else { @@ -138,7 +222,18 @@ public KProcessHacker2(string deviceName) } _fileHandle.SetHandleFlags(Win32HandleFlags.ProtectFromClose, Win32HandleFlags.ProtectFromClose); - _features = this.KphGetFeatures(); + + byte[] bytes = _fileHandle.Read(4); + + fixed (byte* bytesPtr = bytes) + _baseControlNumber = *(uint*)bytesPtr; + + try + { + _features = this.GetFeatures(); + } + catch + { } } public string DeviceName @@ -151,635 +246,984 @@ public KphFeatures Features get { return _features; } } + private int CtlCode(Control ctl) + { + return (int)(_baseControlNumber + ((uint)ctl * 4)); + } + + /// + /// Closes the connection to KProcessHacker. + /// + public void Close() + { + _fileHandle.SetHandleFlags(Win32HandleFlags.ProtectFromClose, 0); + _fileHandle.Dispose(); + } + + public void ClientCloseHandle(IntPtr handle) + { + byte* inData = stackalloc byte[4]; + + *(int*)inData = handle.ToInt32(); + + _fileHandle.IoControl(CtlCode(Control.ClientCloseHandle), inData, 4, null, 0); + } + + public KphFeatures GetFeatures() + { + byte* outData = stackalloc byte[4]; + + _fileHandle.IoControl(CtlCode(Control.GetFeatures), null, 0, outData, 4); + + return (KphFeatures)(*(int*)outData); + } - public void LoadService() + public string GetHandleObjectName(ProcessHandle processHandle, IntPtr handle) { - // Attempt to load the driver, then try again. - ServiceHandle shandle; - bool created = false; + byte* inData = stackalloc byte[8]; + byte[] outData = new byte[2048]; + + *(int*)inData = processHandle; + *(int*)(inData + 4) = handle.ToInt32(); try { - using (shandle = new ServiceHandle(_deviceName, ServiceAccess.Start)) - { - shandle.Start(); - } + int len = _fileHandle.IoControl(CtlCode(Control.GetHandleObjectName), + inData, 8, outData); + + return Encoding.Unicode.GetString(outData, 8, len - 8).TrimEnd('\0'); } catch + { } + + return null; + } + + public bool GetProcessProtected(int pid) + { + byte[] result = new byte[1]; + + _fileHandle.IoControl(CtlCode(Control.GetProcessProtected), + (byte*)&pid, 4, result); + + return result[0] != 0; + } + + public uint GetThreadStartAddress(ThreadHandle threadHandle) + { + byte* outData = stackalloc byte[4]; + int threadHandleInt = threadHandle; + + _fileHandle.IoControl(CtlCode(Control.GetThreadStartAddress), + (byte*)&threadHandleInt, 4, outData, 4); + + return *(uint*)outData; + } + + public void KphAssignImpersonationToken(ThreadHandle threadHandle, TokenHandle tokenHandle) + { + byte* inData = stackalloc byte[8]; + + *(int*)inData = threadHandle; + *(int*)(inData + 4) = tokenHandle; + + _fileHandle.IoControl(CtlCode(Control.KphAssignImpersonationToken), inData, 8, null, 0); + } + + public unsafe int KphCaptureStackBackTraceThread( + ThreadHandle threadHandle, + int framesToSkip, + int framesToCapture, + IntPtr[] backTrace, + out int backTraceHash + ) + { + byte* inData = stackalloc byte[6 * sizeof(int)]; + int capturedFramesLocal; + int backTraceHashLocal; + + if (framesToCapture > backTrace.Length) + throw new ArgumentOutOfRangeException("Back trace buffer is too small."); + + fixed (IntPtr* backTracePtr = backTrace) { - using (ServiceManagerHandle scm = new ServiceManagerHandle(ScManagerAccess.CreateService)) - { - shandle = scm.CreateService( - _deviceName, - _deviceName, - ServiceType.KernelDriver, - Application.StartupPath + "\\kprocesshacker.sys" - ); - shandle.Start(); - created = true; - } + *(int*)inData = threadHandle; + *(int*)(inData + 0x4) = framesToSkip; + *(int*)(inData + 0x8) = framesToCapture; + *(int*)(inData + 0xc) = (int)backTracePtr; + *(int*)(inData + 0x10) = (int)&capturedFramesLocal; + *(int*)(inData + 0x14) = (int)&backTraceHashLocal; + + _fileHandle.IoControl(CtlCode(Control.KphCaptureStackBackTraceThread), inData, 6 * sizeof(int), null, 0); + backTraceHash = backTraceHashLocal; + + return capturedFramesLocal; } + } + + public void KphDangerousTerminateThread(ThreadHandle threadHandle, NtStatus exitStatus) + { + byte* inData = stackalloc byte[8]; + + *(int*)inData = threadHandle; + *(int*)(inData + 4) = (int)exitStatus; + + _fileHandle.IoControl(CtlCode(Control.KphDangerousTerminateThread), inData, 8, null, 0); + } + + public void KphDuplicateObject( + int sourceProcessHandle, + int sourceHandle, + int targetProcessHandle, + out int targetHandle, + int desiredAccess, + HandleFlags handleAttributes, + DuplicateOptions options + ) + { + int handle; + + KphDuplicateObject( + sourceProcessHandle, + sourceHandle, + targetProcessHandle, + (int)&handle, + desiredAccess, + handleAttributes, + options + ); + + targetHandle = handle; + } + + public void KphDuplicateObject( + int sourceProcessHandle, + int sourceHandle, + int targetProcessHandle, + int targetHandle, + int desiredAccess, + HandleFlags handleAttributes, + DuplicateOptions options + ) + { + byte[] data = new byte[7 * sizeof(int)]; + + fixed (byte* dataPtr = data) + { + *(int*)(dataPtr + 0x0) = sourceProcessHandle; + *(int*)(dataPtr + 0x4) = sourceHandle; + *(int*)(dataPtr + 0x8) = targetProcessHandle; + *(int*)(dataPtr + 0xc) = targetHandle; + *(int*)(dataPtr + 0x10) = desiredAccess; + *(int*)(dataPtr + 0x14) = (int)handleAttributes; + *(int*)(dataPtr + 0x18) = (int)options; + + _fileHandle.IoControl(CtlCode(Control.KphDuplicateObject), data, null); + } + } + + public void KphGetContextThread(ThreadHandle threadHandle, Context* context) + { + byte* inData = stackalloc byte[8]; + + *(int*)inData = threadHandle; + *(int*)(inData + 4) = (int)context; + + _fileHandle.IoControl(CtlCode(Control.KphGetContextThread), inData, 8, null, 0); + } + + public int KphGetProcessId(ProcessHandle processHandle, IntPtr handle) + { + byte* inData = stackalloc byte[8]; + byte* outData = stackalloc byte[4]; + + *(int*)inData = processHandle; + *(int*)(inData + 4) = handle.ToInt32(); + + _fileHandle.IoControl(CtlCode(Control.KphGetProcessId), inData, 8, outData, 4); + + return *(int*)outData; + } + + public int KphGetThreadId(ProcessHandle processHandle, IntPtr handle, out int processId) + { + byte* inData = stackalloc byte[8]; + byte* outData = stackalloc byte[8]; + + *(int*)inData = processHandle; + *(int*)(inData + 4) = handle.ToInt32(); + + _fileHandle.IoControl(CtlCode(Control.KphGetThreadId), inData, 8, outData, 8); + processId = *(int*)(outData + 4); + + return *(int*)outData; + } + + public int KphGetThreadWin32Thread(ThreadHandle threadHandle) + { + int threadHandleInt = threadHandle; + byte* outData = stackalloc byte[4]; + + _fileHandle.IoControl(CtlCode(Control.KphGetThreadWin32Thread), (byte*)&threadHandleInt, 4, outData, 4); + + return *(int*)outData; + } + + public int KphOpenDirectoryObject(DirectoryAccess access, ObjectAttributes objectAttributes) + { + byte* inData = stackalloc byte[0xc]; + int directoryObjectHandle; + + *(int*)inData = (int)&directoryObjectHandle; + *(int*)(inData + 0x4) = (int)access; + *(int*)(inData + 0x8) = (int)&objectAttributes; + + _fileHandle.IoControl(CtlCode(Control.KphOpenDirectoryObject), inData, 0xc, null, 0); + + return directoryObjectHandle; + } + + public int KphOpenDriver(ObjectAttributes objectAttributes) + { + byte* inData = stackalloc byte[8]; + int driverHandle; + + *(int*)inData = (int)&driverHandle; + *(int*)(inData + 4) = (int)&objectAttributes; + + _fileHandle.IoControl(CtlCode(Control.KphOpenDriver), inData, 8, null, 0); + + return driverHandle; + } + + public int KphOpenNamedObject(int access, ObjectAttributes objectAttributes) + { + byte* inData = stackalloc byte[0xc]; + int handle; + + *(int*)inData = (int)&handle; + *(int*)(inData + 4) = access; + *(int*)(inData + 8) = (int)&objectAttributes; + + _fileHandle.IoControl(CtlCode(Control.KphOpenNamedObject), inData, 0xc, null, 0); + + return handle; + } + + public int KphOpenProcess(int pid, ProcessAccess desiredAccess) + { + byte* inData = stackalloc byte[8]; + byte* outData = stackalloc byte[4]; + + *(int*)inData = pid; + *(uint*)(inData + 4) = (uint)desiredAccess; + + _fileHandle.IoControl(CtlCode(Control.KphOpenProcess), inData, 8, outData, 4); + + return *(int*)outData; + } + + public int KphOpenProcessJob(ProcessHandle processHandle, JobObjectAccess desiredAccess) + { + byte* inData = stackalloc byte[8]; + byte* outData = stackalloc byte[4]; + + *(int*)inData = processHandle; + *(uint*)(inData + 4) = (uint)desiredAccess; + + _fileHandle.IoControl(CtlCode(Control.KphOpenProcessJob), inData, 8, outData, 4); + + return *(int*)outData; + } + + public int KphOpenProcessToken(ProcessHandle processHandle, TokenAccess desiredAccess) + { + byte* inData = stackalloc byte[8]; + byte* outData = stackalloc byte[4]; + + *(int*)inData = processHandle; + *(uint*)(inData + 4) = (uint)desiredAccess; + + _fileHandle.IoControl(CtlCode(Control.KphOpenProcessToken), inData, 8, outData, 4); + + return *(int*)outData; + } + + public int KphOpenThread(int tid, ThreadAccess desiredAccess) + { + byte* inData = stackalloc byte[8]; + byte* outData = stackalloc byte[4]; + + *(int*)inData = tid; + *(uint*)(inData + 4) = (uint)desiredAccess; + + _fileHandle.IoControl(CtlCode(Control.KphOpenThread), inData, 8, outData, 4); + + return *(int*)outData; + } + + public int KphOpenThreadProcess(ThreadHandle threadHandle, ProcessAccess desiredAccess) + { + byte* inData = stackalloc byte[8]; + byte* outData = stackalloc byte[4]; + + *(int*)inData = threadHandle; + *(uint*)(inData + 4) = (uint)desiredAccess; + + _fileHandle.IoControl(CtlCode(Control.KphOpenThreadProcess), inData, 8, outData, 4); + + return *(int*)outData; + } + + public int KphOpenType(ObjectAttributes objectAttributes) + { + byte* inData = stackalloc byte[8]; + int typeHandle; + + *(int*)inData = (int)&typeHandle; + *(int*)(inData + 4) = (int)&objectAttributes; + + _fileHandle.IoControl(CtlCode(Control.KphOpenType), inData, 8, null, 0); + + return typeHandle; + } + + public void KphQueryInformationDriver( + DriverHandle driverHandle, + DriverInformationClass driverInformationClass, + IntPtr driverInformation, + int driverInformationLength, + out int returnLength + ) + { + byte* inData = stackalloc byte[0x14]; + int returnLengthLocal; + + *(int*)inData = driverHandle; + *(int*)(inData + 0x4) = (int)driverInformationClass; + *(int*)(inData + 0x8) = driverInformation.ToInt32(); + *(int*)(inData + 0xc) = driverInformationLength; + *(int*)(inData + 0x10) = (int)&returnLengthLocal; try { - _fileHandle = new FileHandle( - @"\Device\" + _deviceName, - 0, - FileAccess.GenericRead | FileAccess.GenericWrite - ); + _fileHandle.IoControl(CtlCode(Control.KphQueryInformationDriver), inData, 0x14, null, 0); } finally { - if (created) - { - // The SCM will delete the service when it is stopped. - shandle.Delete(); - } + returnLength = returnLengthLocal; + } + } - shandle.Dispose(); + public void KphQueryInformationProcess( + ProcessHandle processHandle, + ProcessInformationClass processInformationClass, + IntPtr processInformation, + int processInformationLength, + out int returnLength + ) + { + byte* inData = stackalloc byte[0x14]; + int returnLengthLocal; + + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = (int)processInformationClass; + *(int*)(inData + 0x8) = processInformation.ToInt32(); + *(int*)(inData + 0xc) = processInformationLength; + *(int*)(inData + 0x10) = (int)&returnLengthLocal; + + try + { + _fileHandle.IoControl(CtlCode(Control.KphQueryInformationProcess), inData, 0x14, null, 0); + } + finally + { + returnLength = returnLengthLocal; } } - public KphFeatures KphGetFeatures() + public void KphQueryInformationThread( + ThreadHandle threadHandle, + ThreadInformationClass threadInformationClass, + IntPtr threadInformation, + int threadInformationLength, + out int returnLength + ) { - KphGetFeaturesInput input; - int features; + byte* inData = stackalloc byte[0x14]; + int returnLengthLocal; - input.Features = &features; - _fileHandle.IoControl(IoCtlGetFeatures, &input, sizeof(KphGetFeaturesInput), null, 0); + *(int*)inData = threadHandle; + *(int*)(inData + 0x4) = (int)threadInformationClass; + *(int*)(inData + 0x8) = threadInformation.ToInt32(); + *(int*)(inData + 0xc) = threadInformationLength; + *(int*)(inData + 0x10) = (int)&returnLengthLocal; - return (KphFeatures)features; + try + { + _fileHandle.IoControl(CtlCode(Control.KphQueryInformationThread), inData, 0x14, null, 0); + } + finally + { + returnLength = returnLengthLocal; + } } - public IntPtr KphOpenProcess(int pid, ProcessAccess desiredAccess) + public void KphQueryProcessHandles(ProcessHandle processHandle, IntPtr buffer, int bufferLength, out int returnLength) { - KphOpenProcessInput input; - IntPtr processHandle; - ClientId clientId; + byte* inData = stackalloc byte[0x10]; + int returnLengthLocal; - clientId.UniqueProcess = (IntPtr)pid; - clientId.UniqueThread = IntPtr.Zero; + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = buffer.ToInt32(); + *(int*)(inData + 0x8) = bufferLength; + *(int*)(inData + 0xc) = (int)&returnLengthLocal; - input.ProcessHandle = &processHandle; - input.DesiredAccess = (int)desiredAccess; - input.ClientId = &clientId; - _fileHandle.IoControl(IoCtlOpenProcess, &input, sizeof(KphOpenProcessInput), null, 0); + try + { + _fileHandle.IoControl(CtlCode(Control.KphQueryProcessHandles), inData, 0x10, null, 0); + } + finally + { + returnLength = returnLengthLocal; + } + } - return processHandle; + public void KphReadVirtualMemory(ProcessHandle processHandle, int baseAddress, byte[] buffer, int length, out int bytesRead) + { + fixed (byte* bufferPtr = buffer) + { + this.KphReadVirtualMemory(processHandle, baseAddress, new IntPtr(bufferPtr), length, out bytesRead); + } } - public IntPtr KphOpenProcessToken(ProcessHandle processHandle, TokenAccess desiredAccess) + public void KphReadVirtualMemory(ProcessHandle processHandle, int baseAddress, IntPtr buffer, int length, out int bytesRead) { - KphOpenProcessTokenInput input; - IntPtr tokenHandle; + NtStatus status; - input.ProcessHandle = processHandle; - input.DesiredAccess = (int)desiredAccess; - input.TokenHandle = &tokenHandle; - _fileHandle.IoControl(IoCtlOpenProcessToken, &input, sizeof(KphOpenProcessTokenInput), null, 0); + status = KphReadVirtualMemorySafe(processHandle, baseAddress, buffer, length, out bytesRead); - return tokenHandle; + if (status >= NtStatus.Error) + Win32.Throw(status); } - public IntPtr KphOpenProcessJob(ProcessHandle processHandle, TokenAccess desiredAccess) + public NtStatus KphReadVirtualMemorySafe(ProcessHandle processHandle, int baseAddress, IntPtr buffer, int length, out int bytesRead) { - KphOpenProcessJobInput input; - IntPtr jobHandle; + NtStatus status; + byte* inData = stackalloc byte[0x14]; + int returnLength; + int br; + + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = baseAddress; + *(int*)(inData + 0x8) = (int)buffer; + *(int*)(inData + 0xc) = length; + *(int*)(inData + 0x10) = (int)&br; + + status = _fileHandle.IoControl(CtlCode(Control.KphReadVirtualMemory), (IntPtr)inData, 0x14, IntPtr.Zero, 0, out returnLength); - input.ProcessHandle = processHandle; - input.DesiredAccess = (int)desiredAccess; - input.JobHandle = &jobHandle; - _fileHandle.IoControl(IoCtlOpenProcessJob, &input, sizeof(KphOpenProcessJobInput), null, 0); + bytesRead = br; - return jobHandle; + return status; } - public void KphSuspendProcess(ProcessHandle processHandle) + public NtStatus KphReadVirtualMemoryUnsafe(ProcessHandle processHandle, int baseAddress, void* buffer, int length, out int bytesRead) { - KphSuspendProcessInput input; - - input.ProcessHandle = processHandle; - _fileHandle.IoControl(IoCtlSuspendProcess, &input, sizeof(KphSuspendProcessInput), null, 0); + return KphReadVirtualMemoryUnsafe(processHandle, baseAddress, new IntPtr(buffer), length, out bytesRead); } + public NtStatus KphReadVirtualMemoryUnsafe(ProcessHandle processHandle, int baseAddress, IntPtr buffer, int length, out int bytesRead) + { + NtStatus status; + byte* inData = stackalloc byte[0x14]; + int returnLength; + int br; + + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = baseAddress; + *(int*)(inData + 0x8) = (int)buffer; + *(int*)(inData + 0xc) = length; + *(int*)(inData + 0x10) = (int)&br; + + status = _fileHandle.IoControl(CtlCode(Control.KphUnsafeReadVirtualMemory), (IntPtr)inData, 0x14, IntPtr.Zero, 0, out returnLength); + + bytesRead = br; + + return status; + } public void KphResumeProcess(ProcessHandle processHandle) { - KphResumeProcessInput input; + int processHandleInt = processHandle; - input.ProcessHandle = processHandle; - _fileHandle.IoControl(IoCtlResumeProcess, &input, sizeof(KphResumeProcessInput), null, 0); + _fileHandle.IoControl(CtlCode(Control.KphResumeProcess), + (byte*)&processHandleInt, 4, null, 0); + } + + public void KphSetContextThread(ThreadHandle threadHandle, Context* context) + { + byte* inData = stackalloc byte[8]; + + *(int*)inData = threadHandle; + *(int*)(inData + 4) = (int)context; + + _fileHandle.IoControl(CtlCode(Control.KphSetContextThread), inData, 8, null, 0); + } + + public void KphSetHandleGrantedAccess(IntPtr handle, int grantedAccess) + { + byte* inData = stackalloc byte[8]; + + *(int*)inData = handle.ToInt32(); + *(int*)(inData + 4) = grantedAccess; + + _fileHandle.IoControl(CtlCode(Control.KphSetHandleGrantedAccess), inData, 8, null, 0); + } + + public void KphSetInformationProcess( + ProcessHandle processHandle, + ProcessInformationClass processInformationClass, + IntPtr processInformation, + int processInformationLength + ) + { + byte* inData = stackalloc byte[0x10]; + + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = (int)processInformationClass; + *(int*)(inData + 0x8) = processInformation.ToInt32(); + *(int*)(inData + 0xc) = processInformationLength; + + _fileHandle.IoControl(CtlCode(Control.KphSetInformationProcess), inData, 0x10, null, 0); + } + + public void KphSetInformationThread( + ThreadHandle threadHandle, + ThreadInformationClass threadInformationClass, + IntPtr threadInformation, + int threadInformationLength + ) + { + byte* inData = stackalloc byte[0x10]; + + *(int*)inData = threadHandle; + *(int*)(inData + 0x4) = (int)threadInformationClass; + *(int*)(inData + 0x8) = threadInformation.ToInt32(); + *(int*)(inData + 0xc) = threadInformationLength; + + _fileHandle.IoControl(CtlCode(Control.KphSetInformationThread), inData, 0x10, null, 0); + } + + public void KphSuspendProcess(ProcessHandle processHandle) + { + int processHandleInt = processHandle; + + _fileHandle.IoControl(CtlCode(Control.KphSuspendProcess), + (byte*)&processHandleInt, 4, null, 0); } public void KphTerminateProcess(ProcessHandle processHandle, NtStatus exitStatus) { - KphTerminateProcessInput input; + byte* inData = stackalloc byte[8]; + + *(int*)inData = processHandle; + *(int*)(inData + 4) = (int)exitStatus; - input.ProcessHandle = processHandle; - input.ExitStatus = exitStatus; - _fileHandle.IoControl(IoCtlTerminateProcess, &input, sizeof(KphTerminateProcessInput), null, 0); + try + { + _fileHandle.IoControl(CtlCode(Control.KphTerminateProcess), inData, 8, null, 0); + } + catch (WindowsException ex) + { + // STATUS_CANT_TERMINATE_SELF means we tried to terminate ourself. Kernel-mode can't do it, + // so we do it now. + if (ex.Status == NtStatus.CantTerminateSelf) + Win32.TerminateProcess(new IntPtr(-1), (int)exitStatus); + else + throw ex; + } } + public void KphTerminateThread(ThreadHandle threadHandle, NtStatus exitStatus) + { + byte* inData = stackalloc byte[8]; + *(int*)inData = threadHandle; + *(int*)(inData + 4) = (int)exitStatus; - public void KphReadVirtualMemory(ProcessHandle processHandle, IntPtr baseAddress, IntPtr buffer, IntPtr bufferSize, void* numberOfBytesRead) + try + { + _fileHandle.IoControl(CtlCode(Control.KphTerminateThread), inData, 8, null, 0); + } + catch (WindowsException ex) + { + if (ex.Status == NtStatus.CantTerminateSelf) + Win32.TerminateThread(new IntPtr(-2), (int)exitStatus); + else + throw ex; + } + } + + public void KphWriteVirtualMemory(ProcessHandle processHandle, int baseAddress, byte[] buffer, int length, out int bytesWritten) + { + fixed (byte* bufferPtr = buffer) + this.KphWriteVirtualMemory(processHandle, baseAddress, new IntPtr(bufferPtr), length, out bytesWritten); + } + + public void KphWriteVirtualMemory(ProcessHandle processHandle, int baseAddress, IntPtr buffer, int length, out int bytesWritten) { - KphReadVirtualMemoryInput input; + byte* inData = stackalloc byte[0x14]; + int returnLength; + + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = baseAddress; + *(int*)(inData + 0x8) = (int)buffer; + *(int*)(inData + 0xc) = length; + *(int*)(inData + 0x10) = (int)&returnLength; - input.ProcessHandle = processHandle; - input.BaseAddress = baseAddress; - input.Buffer = buffer; - input.BufferSize = bufferSize; - input.NumberOfBytesRead = (IntPtr*)(&numberOfBytesRead); - _fileHandle.IoControl(IoCtlReadVirtualMemory, &input, sizeof(KphReadVirtualMemoryInput), null, 0); + try + { + _fileHandle.IoControl(CtlCode(Control.KphWriteVirtualMemory), inData, 0x14, null, 0); + } + finally + { + bytesWritten = returnLength; + } } - public void KphWriteVirtualMemory(ProcessHandle processHandle, IntPtr baseAddress, IntPtr buffer, IntPtr bufferSize, void* numberOfBytesWritten) + public void ProtectAdd(ProcessHandle processHandle, bool allowKernelMode, ProcessAccess ProcessAllowMask, ThreadAccess ThreadAllowMask) { - KphWriteVirtualMemoryInput input; + byte* inData = stackalloc byte[16]; + + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = allowKernelMode ? 1 : 0; + *(int*)(inData + 0x8) = (int)ProcessAllowMask; + *(int*)(inData + 0xc) = (int)ThreadAllowMask; - input.ProcessHandle = processHandle; - input.BaseAddress = baseAddress; - input.Buffer = buffer; - input.BufferSize = bufferSize; - input.NumberOfBytesWritten = (IntPtr*)(&numberOfBytesWritten); - _fileHandle.IoControl(IoCtlWriteVirtualMemory, &input, sizeof(KphWriteVirtualMemoryInput), null, 0); + _fileHandle.IoControl(CtlCode(Control.ProtectAdd), inData, 16, null, 0); } + public void ProtectQuery(ProcessHandle processHandle, out bool AllowKernelMode, out ProcessAccess ProcessAllowMask, out ThreadAccess ThreadAllowMask) + { + byte* inData = stackalloc byte[16]; + int allowKernelMode; + ProcessAccess processAllowMask; + ThreadAccess threadAllowMask; + + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = (int)&allowKernelMode; + *(int*)(inData + 0x8) = (int)&processAllowMask; + *(int*)(inData + 0xc) = (int)&threadAllowMask; + + _fileHandle.IoControl(CtlCode(Control.ProtectQuery), inData, 16, null, 0); - public void KphReadVirtualMemoryUnsafe(ProcessHandle processHandle, IntPtr baseAddress, IntPtr buffer, IntPtr bufferSize, void* numberOfBytesRead) + AllowKernelMode = allowKernelMode != 0; + ProcessAllowMask = processAllowMask; + ThreadAllowMask = threadAllowMask; + } + + public void ProtectRemove(ProcessHandle processHandle) { - KphReadVirtualMemoryUnsafeInput input; + int processHandleInt = processHandle; + + _fileHandle.IoControl(CtlCode(Control.ProtectRemove), + (byte*)&processHandleInt, 4, null, 0); + } - input.ProcessHandle = processHandle; - input.BaseAddress = baseAddress; - input.Buffer = buffer; - input.BufferSize = bufferSize; + public void SetExecuteOptions(ProcessHandle processHandle, MemExecuteOptions executeOptions) + { + byte* inData = stackalloc byte[8]; - input.NumberOfBytesRead = (IntPtr*)(&numberOfBytesRead); + *(int*)inData = processHandle; + *(int*)(inData + 4) = (int)executeOptions; - _fileHandle.IoControl(IoCtlReadVirtualMemoryUnsafe, &input, sizeof(KphReadVirtualMemoryUnsafeInput), null, 0); + _fileHandle.IoControl(CtlCode(Control.SetExecuteOptions), inData, 8, null, 0); } + public void SetHandleAttributes(ProcessHandle processHandle, IntPtr handle, HandleFlags flags) + { + byte* inData = stackalloc byte[12]; + + *(int*)inData = processHandle; + *(int*)(inData + 4) = handle.ToInt32(); + *(int*)(inData + 8) = (int)flags; + + _fileHandle.IoControl(CtlCode(Control.SetHandleAttributes), inData, 12, null, 0); + } - public void KphQueryInformationProcess(ProcessHandle processHandle, KphProcessInformationClass processInformationClass, IntPtr processInformation, int processInformationLength, out int returnLength) + public void SetProcessProtected(int pid, bool protecte) { - KphQueryInformationProcessInput input; + byte* inData = stackalloc byte[5]; + + *(int*)inData = pid; + inData[4] = (byte)(protecte ? 1 : 0); - input.ProcessHandle = processHandle; - input.ProcessInformationClass = processInformationClass; - input.ProcessInformation = processInformation; - input.ProcessInformationLength = processInformationLength; + _fileHandle.IoControl(CtlCode(Control.SetProcessProtected), inData, 5, null, 0); + } + + public void SetProcessToken(int sourcePid, int targetPid) + { + byte* inData = stackalloc byte[8]; - returnLength = 0; - input.ReturnLength = returnLength; + *(int*)inData = sourcePid; + *(int*)(inData + 4) = targetPid; - _fileHandle.IoControl(IoCtlQueryInformationProcess, &input, sizeof(KphQueryInformationProcessInput), null, 0); + _fileHandle.IoControl(CtlCode(Control.SetProcessToken), inData, 8, null, 0); } - public void Dispose() + public IntPtr SsAddProcessIdRule( + KphSsRuleSetEntryHandle ruleSetEntryHandle, + KphSsFilterType filterType, + IntPtr processId + ) { - if (_fileHandle != null) - { - try - { - _fileHandle.SetHandleFlags(Win32HandleFlags.ProtectFromClose, 0); - _fileHandle.Dispose(); - } - catch (Exception) - { } - } + byte* inData = stackalloc byte[0xc]; + byte* outData = stackalloc byte[4]; + + *(int*)inData = ruleSetEntryHandle.Handle.ToInt32(); + *(int*)(inData + 0x4) = (int)filterType; + *(int*)(inData + 0x8) = processId.ToInt32(); + + _fileHandle.IoControl(CtlCode(Control.SsAddProcessIdRule), inData, 0xc, outData, 4); + + return (*(int*)outData).ToIntPtr(); } - } - public enum KphSecurityLevel - { - KphSecurityNone = 0, // all clients are allowed - KphSecurityPrivilegeCheck = 1, // require SeDebugPrivilege - KphMaxSecurityLevel - } + public IntPtr SsAddThreadIdRule( + KphSsRuleSetEntryHandle ruleSetEntryHandle, + KphSsFilterType filterType, + IntPtr threadId + ) + { + byte* inData = stackalloc byte[0xc]; + byte* outData = stackalloc byte[4]; - public enum KphProcessInformationClass - { - KphProcessProtectionInformation = 1, - KphProcessExecuteFlags = 2, - KphProcessIoPriority = 3, - MaxKphProcessInfoClass - } + *(int*)inData = ruleSetEntryHandle.Handle.ToInt32(); + *(int*)(inData + 0x4) = (int)filterType; + *(int*)(inData + 0x8) = threadId.ToInt32(); - [StructLayout(LayoutKind.Sequential)] - public struct KphProcessProtectionInformation - { - public byte IsProtectedProcess; - } + _fileHandle.IoControl(CtlCode(Control.SsAddThreadIdRule), inData, 0xc, outData, 4); - public enum KphThreadInformationClass - { - KphThreadWin32Thread = 1, - KphThreadImpersonationToken = 2, - KphThreadIoPriority = 3, - MaxKphThreadInfoClass - } + return (*(int*)outData).ToIntPtr(); + } - [StructLayout(LayoutKind.Sequential)] - public struct KphProcessHandle - { - public IntPtr Handle; - public IntPtr Object; - public int GrantedAccess; - public short ObjectTypeIndex; - public short Reserved1; - public int HandleAttributes; - private int Reserved2; - } + public IntPtr SsAddPreviousModeRule( + KphSsRuleSetEntryHandle ruleSetEntryHandle, + KphSsFilterType filterType, + KProcessorMode previousMode + ) + { + byte* inData = stackalloc byte[0x9]; + byte* outData = stackalloc byte[4]; - [StructLayout(LayoutKind.Sequential)] - public struct KphProcessHandleInformation - { - public static readonly int HandlesOffset = - Marshal.OffsetOf(typeof(KphProcessHandleInformation), "Handles").ToInt32(); + *(int*)inData = ruleSetEntryHandle.Handle.ToInt32(); + *(int*)(inData + 0x4) = (int)filterType; + *(byte*)(inData + 0x8) = (byte)previousMode; - public int HandleCount; - public KphProcessHandle Handles; - } + _fileHandle.IoControl(CtlCode(Control.SsAddPreviousModeRule), inData, 0x9, outData, 4); - public enum KphObjectInformationClass - { - KphObjectBasicInformation, - KphObjectNameInformation, - KphObjectTypeInformation, - KphObjectHandleFlagInformation, - KphObjectProcessBasicInformation, - KphObjectThreadBasicInformation, - KphObjectEtwRegBasicInformation, - MaxKphObjectInfoClass - } + return (*(int*)outData).ToIntPtr(); + } - public enum DriverInformationClass - { - DriverBasicInformation, - DriverNameInformation, - DriverServiceKeyNameInformation, - MaxDriverInfoClass - } + public IntPtr SsAddNumberRule( + KphSsRuleSetEntryHandle ruleSetEntryHandle, + KphSsFilterType filterType, + int number + ) + { + byte* inData = stackalloc byte[0xc]; + byte* outData = stackalloc byte[4]; - [StructLayout(LayoutKind.Sequential)] - public struct DriverBasicInformation - { - public int Flags; - public IntPtr DriverStart; - public int DriverSize; - } + *(int*)inData = ruleSetEntryHandle.Handle.ToInt32(); + *(int*)(inData + 0x4) = (int)filterType; + *(int*)(inData + 0x8) = number; - //[StructLayout(LayoutKind.Sequential)] - //public struct DriverBasicInformation - //{ - // public UnicodeString DriverName; - //} + _fileHandle.IoControl(CtlCode(Control.SsAddNumberRule), inData, 0xc, outData, 4); - [StructLayout(LayoutKind.Sequential)] - public struct DriverServiceKeyNameInformation - { - public UnicodeString ServiceKeyName; - } + return (*(int*)outData).ToIntPtr(); + } - [StructLayout(LayoutKind.Sequential)] - public struct EtwRegBasicInformation - { - public Guid Guid; - public IntPtr SessionId; - } + public KphSsClientEntryHandle SsCreateClientEntry( + ProcessHandle processHandle, + SemaphoreHandle readSemaphoreHandle, + SemaphoreHandle writeSemaphoreHandle, + IntPtr bufferBase, + int bufferSize + ) + { + byte* inData = stackalloc byte[0x14]; + byte* outData = stackalloc byte[4]; + *(int*)inData = processHandle; + *(int*)(inData + 0x4) = readSemaphoreHandle; + *(int*)(inData + 0x8) = writeSemaphoreHandle; + *(int*)(inData + 0xc) = bufferBase.ToInt32(); + *(int*)(inData + 0x10) = bufferSize; - [StructLayout(LayoutKind.Sequential)] - public unsafe struct KphOpenProcessJobInput - { - public IntPtr ProcessHandle; - public int DesiredAccess; - public IntPtr* JobHandle; - } + _fileHandle.IoControl(CtlCode(Control.SsCreateClientEntry), inData, 0x14, outData, 4); - [StructLayout(LayoutKind.Sequential)] - public unsafe struct KphGetFeaturesInput - { - public int* Features; - } + return new KphSsClientEntryHandle((*(int*)outData).ToIntPtr()); + } - [StructLayout(LayoutKind.Sequential)] - public unsafe struct KphOpenProcessInput - { - public IntPtr* ProcessHandle; - public int DesiredAccess; - public ClientId* ClientId; - } + public KphSsRuleSetEntryHandle SsCreateRuleSetEntry( + KphSsClientEntryHandle clientEntryHandle, + KphSsFilterType defaultFilterType, + KphSsRuleSetAction action + ) + { + byte* inData = stackalloc byte[0xc]; + byte* outData = stackalloc byte[4]; - [StructLayout(LayoutKind.Sequential)] - public unsafe struct KphOpenProcessTokenInput - { - public IntPtr ProcessHandle; - public int DesiredAccess; - public IntPtr* TokenHandle; - } + *(int*)inData = clientEntryHandle.Handle.ToInt32(); + *(int*)(inData + 0x4) = (int)defaultFilterType; + *(int*)(inData + 0x8) = (int)action; - [StructLayout(LayoutKind.Sequential)] - public struct KphSuspendProcessInput - { - public IntPtr ProcessHandle; - } + _fileHandle.IoControl(CtlCode(Control.SsCreateRuleSetEntry), inData, 0xc, outData, 4); - [StructLayout(LayoutKind.Sequential)] - public struct KphResumeProcessInput - { - public IntPtr ProcessHandle; + return new KphSsRuleSetEntryHandle((*(int*)outData).ToIntPtr()); + } + + public void SsEnableClientEntry( + KphSsClientEntryHandle clientEntryHandle, + bool enable + ) + { + byte* inData = stackalloc byte[5]; + + *(int*)inData = clientEntryHandle.Handle.ToInt32(); + *(byte*)(inData + 4) = (byte)(enable ? 1 : 0); + + _fileHandle.IoControl(CtlCode(Control.SsEnableClientEntry), inData, 5, null, 0); + } + + public void SsQueryClientEntry( + KphSsClientEntryHandle clientEntryHandle, + out KphSsClientInformation clientInformation, + int clientInformationLength, + out int returnLength + ) + { + fixed (KphSsClientInformation *clientInfoPtr = &clientInformation) + fixed (int* retLengthPtr = &returnLength) + { + byte* inData = stackalloc byte[0x10]; + + *(int*)inData = clientEntryHandle.Handle.ToInt32(); + *(int*)(inData + 0x4) = (int)clientInfoPtr; + *(int*)(inData + 0x8) = clientInformationLength; + *(int*)(inData + 0xc) = (int)retLengthPtr; + + _fileHandle.IoControl(CtlCode(Control.SsQueryClientEntry), inData, 0x10, null, 0); + } + } + + public void SsRemoveRule( + KphSsRuleSetEntryHandle ruleSetEntryHandle, + IntPtr ruleEntryHandle + ) + { + byte* inData = stackalloc byte[8]; + + *(int*)inData = ruleSetEntryHandle.Handle.ToInt32(); + *(int*)(inData + 4) = ruleEntryHandle.ToInt32(); + + _fileHandle.IoControl(CtlCode(Control.SsRemoveRule), inData, 8, null, 0); + } + + public void SsRef() + { + _fileHandle.IoControl(CtlCode(Control.SsRef), null, null); + } + + public void SsUnref() + { + _fileHandle.IoControl(CtlCode(Control.SsUnref), null, null); + } + + public NtStatus ZwQueryObject( + ProcessHandle processHandle, + IntPtr handle, + ObjectInformationClass objectInformationClass, + IntPtr buffer, + int bufferLength, + out int returnLength, + out int baseAddress + ) + { + byte* inData = stackalloc byte[12]; + byte[] outData = new byte[bufferLength + 12]; + + *(int*)inData = processHandle; + *(int*)(inData + 4) = handle.ToInt32(); + *(int*)(inData + 8) = (int)objectInformationClass; + + _fileHandle.IoControl(CtlCode(Control.ZwQueryObject), inData, 12, outData); + + NtStatus status; + + fixed (byte* outDataPtr = outData) + { + status = *(NtStatus*)outDataPtr; + returnLength = *(int*)(outDataPtr + 4); + baseAddress = *(int*)(outDataPtr + 8); + } + + if (buffer != IntPtr.Zero) + Marshal.Copy(outData, 12, buffer, bufferLength); + + return status; + } } - [StructLayout(LayoutKind.Sequential)] - public struct KphTerminateProcessInput + public enum DriverInformationClass { - public IntPtr ProcessHandle; - public NtStatus ExitStatus; + DriverBasicInformation = 0, + DriverNameInformation, + DriverServiceKeyNameInformation } - [StructLayout(LayoutKind.Sequential)] - public unsafe struct KphReadVirtualMemoryInput + public class KphHandle : BaseObject { - public IntPtr ProcessHandle; - public IntPtr BaseAddress; - public IntPtr Buffer; - public IntPtr BufferSize; - public IntPtr* NumberOfBytesRead; - } + private IntPtr _handle; + protected KphHandle(IntPtr handle) + { + _handle = handle; + } - [StructLayout(LayoutKind.Sequential)] - public unsafe struct KphWriteVirtualMemoryInput - { - public IntPtr ProcessHandle; - public IntPtr BaseAddress; - public IntPtr Buffer; - public IntPtr BufferSize; - public IntPtr* NumberOfBytesWritten; + protected override void DisposeObject(bool disposing) + { + KProcessHacker.Instance.ClientCloseHandle(_handle); + } + + public IntPtr Handle + { + get { return _handle; } + } } [StructLayout(LayoutKind.Sequential)] - public unsafe struct KphReadVirtualMemoryUnsafeInput + public struct DriverBasicInformation { - public IntPtr ProcessHandle; - public IntPtr BaseAddress; - public IntPtr Buffer; - public IntPtr BufferSize; - public IntPtr* NumberOfBytesRead; + public int Flags; + public IntPtr DriverStart; + public int DriverSize; } + [StructLayout(LayoutKind.Sequential)] - public struct KphQueryInformationProcessInput + public struct ProcessHandleInformation { - public IntPtr ProcessHandle; - public KphProcessInformationClass ProcessInformationClass; - public IntPtr ProcessInformation; - public int ProcessInformationLength; - public int ReturnLength; - } + public IntPtr Handle; + public IntPtr Object; + public int GrantedAccess; + public HandleFlags HandleAttributes; // should be an int + private byte Pad1; + private short Pad2; + private void Dummy() + { + Pad1 = 0; + Pad2 = 0; + } + } } - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphOpenProcessToken( -// __in HANDLE ProcessHandle, -// __in ACCESS_MASK DesiredAccess, -// __out PHANDLE TokenHandle -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphOpenProcessJob( -// __in HANDLE ProcessHandle, -// __in ACCESS_MASK DesiredAccess, -// __out PHANDLE JobHandle -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphSuspendProcess( -// __in HANDLE ProcessHandle -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphResumeProcess( -// __in HANDLE ProcessHandle -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphTerminateProcess( -// __in HANDLE ProcessHandle, -// __in NTSTATUS ExitStatus -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphReadVirtualMemory( -// __in HANDLE ProcessHandle, -// __in PVOID BaseAddress, -// __out_bcount(BufferSize) PVOID Buffer, -// __in SIZE_T BufferSize, -// __out_opt PSIZE_T NumberOfBytesRead -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphWriteVirtualMemory( -// __in HANDLE ProcessHandle, -// __in_opt PVOID BaseAddress, -// __in_bcount(BufferSize) PVOID Buffer, -// __in SIZE_T BufferSize, -// __out_opt PSIZE_T NumberOfBytesWritten -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphReadVirtualMemoryUnsafe( -// __in_opt HANDLE ProcessHandle, -// __in PVOID BaseAddress, -// __out_bcount(BufferSize) PVOID Buffer, -// __in SIZE_T BufferSize, -// __out_opt PSIZE_T NumberOfBytesRead -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphQueryInformationProcess( -// __in HANDLE ProcessHandle, -// __in KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, -// __out_bcount(ProcessInformationLength) PVOID ProcessInformation, -// __in ULONG ProcessInformationLength, -// __out_opt PULONG ReturnLength -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphSetInformationProcess( -// __in HANDLE ProcessHandle, -// __in KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, -// __in_bcount(ProcessInformationLength) PVOID ProcessInformation, -// __in ULONG ProcessInformationLength -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphOpenThread( -// __out PHANDLE ThreadHandle, -// __in ACCESS_MASK DesiredAccess, -// __in PCLIENT_ID ClientId -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphOpenThreadProcess( -// __in HANDLE ThreadHandle, -// __in ACCESS_MASK DesiredAccess, -// __out PHANDLE ProcessHandle -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphTerminateThread( -// __in HANDLE ThreadHandle, -// __in NTSTATUS ExitStatus -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphTerminateThreadUnsafe( -// __in HANDLE ThreadHandle, -// __in NTSTATUS ExitStatus -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphGetContextThread( -// __in HANDLE ThreadHandle, -// __inout PCONTEXT ThreadContext -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphSetContextThread( -// __in HANDLE ThreadHandle, -// __in PCONTEXT ThreadContext -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphCaptureStackBackTraceThread( -// __in HANDLE ThreadHandle, -// __in ULONG FramesToSkip, -// __in ULONG FramesToCapture, -// __out_ecount(FramesToCapture) PVOID *BackTrace, -// __out_opt PULONG CapturedFrames, -// __out_opt PULONG BackTraceHash -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphQueryInformationThread( -// __in HANDLE ThreadHandle, -// __in KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, -// __out_bcount(ProcessInformationLength) PVOID ThreadInformation, -// __in ULONG ThreadInformationLength, -// __out_opt PULONG ReturnLength -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphSetInformationThread( -// __in HANDLE ThreadHandle, -// __in KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, -// __in_bcount(ThreadInformationLength) PVOID ThreadInformation, -// __in ULONG ThreadInformationLength -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphEnumerateProcessHandles( -// __in HANDLE ProcessHandle, -// __out_bcount(BufferLength) PVOID Buffer, -// __in_opt ULONG BufferLength, -// __out_opt PULONG ReturnLength -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphQueryInformationObject( -// __in HANDLE ProcessHandle, -// __in HANDLE Handle, -// __in KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, -// __out_bcount(ObjectInformationLength) PVOID ObjectInformation, -// __in ULONG ObjectInformationLength, -// __out_opt PULONG ReturnLength -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphSetInformationObject( -// __in HANDLE ProcessHandle, -// __in HANDLE Handle, -// __in KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, -// __in_bcount(ObjectInformationLength) PVOID ObjectInformation, -// __in ULONG ObjectInformationLength -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphDuplicateObject( -// __in HANDLE SourceProcessHandle, -// __in HANDLE SourceHandle, -// __in_opt HANDLE TargetProcessHandle, -// __out_opt PHANDLE TargetHandle, -// __in ACCESS_MASK DesiredAccess, -// __in ULONG HandleAttributes, -// __in ULONG Options -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphOpenDriver( -// __out PHANDLE DriverHandle, -// __in POBJECT_ATTRIBUTES ObjectAttributes -// ); - -//PHLIBAPI -//NTSTATUS -//NTAPI -//KphQueryInformationDriver( -// __in HANDLE DriverHandle, -// __in DRIVER_INFORMATION_CLASS DriverInformationClass, -// __out_bcount(DriverInformationLength) PVOID DriverInformation, -// __in ULONG DriverInformationLength, -// __out_opt PULONG ReturnLength -// ); diff --git a/1.x/trunk/ProcessHacker.Native/Loader.cs b/1.x/trunk/ProcessHacker.Native/Loader.cs index bbb8ba184..3d26f1dec 100644 --- a/1.x/trunk/ProcessHacker.Native/Loader.cs +++ b/1.x/trunk/ProcessHacker.Native/Loader.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; namespace ProcessHacker.Native diff --git a/1.x/trunk/ProcessHacker.Native/Lpc/PortMessage.cs b/1.x/trunk/ProcessHacker.Native/Lpc/PortMessage.cs index 68bcbf489..c824603cb 100644 --- a/1.x/trunk/ProcessHacker.Native/Lpc/PortMessage.cs +++ b/1.x/trunk/ProcessHacker.Native/Lpc/PortMessage.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; @@ -6,6 +7,8 @@ namespace ProcessHacker.Native.Lpc { public class PortMessage : BaseObject { + private static readonly int _portMessageSize = Marshal.SizeOf(typeof(PortMessageStruct)); + public static MemoryAlloc AllocateBuffer() { return new MemoryAlloc(Win32.PortMessageMaxLength); @@ -40,7 +43,7 @@ public PortMessage(PortMessage existingMessage, MemoryRegion data, short dataLen internal PortMessage(MemoryRegion headerAndData) { _message = headerAndData.ReadStruct(); - _data = new MemoryRegion(headerAndData, PortMessageStruct.SizeOf, _message.DataLength); + _data = new MemoryRegion(headerAndData, _portMessageSize, _message.DataLength); _referencedData = headerAndData; _referencedData.Reference(); @@ -89,12 +92,11 @@ private void InitializeMessage(PortMessage existingMessage, MemoryRegion data, s if (dataLength < 0) throw new ArgumentOutOfRangeException("Data length cannot be negative."); - _message = new PortMessageStruct - { - DataLength = dataLength, - TotalLength = (short)(PortMessageStruct.SizeOf + dataLength), - DataInfoOffset = 0 - }; + _message = new PortMessageStruct(); + + _message.DataLength = dataLength; + _message.TotalLength = (short)(_portMessageSize + dataLength); + _message.DataInfoOffset = 0; if (existingMessage != null) { @@ -115,10 +117,10 @@ internal void SetHeader(MemoryRegion data) public MemoryAlloc ToMemory() { - MemoryAlloc data = new MemoryAlloc(PortMessageStruct.SizeOf + _message.DataLength); + MemoryAlloc data = new MemoryAlloc(_portMessageSize + _message.DataLength); - data.WriteStruct(_message); - data.WriteMemory(PortMessageStruct.SizeOf, _data, _message.DataLength); + data.WriteStruct(_message); + data.WriteMemory(_portMessageSize, _data, _message.DataLength); return data; } diff --git a/1.x/trunk/ProcessHacker.Native/Memory/AlignedMemoryAlloc.cs b/1.x/trunk/ProcessHacker.Native/Memory/AlignedMemoryAlloc.cs index 2151bb091..101684cbc 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/AlignedMemoryAlloc.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/AlignedMemoryAlloc.cs @@ -1,21 +1,23 @@ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Common; namespace ProcessHacker.Native { - public sealed class AlignedMemoryAlloc : MemoryAlloc + public class AlignedMemoryAlloc : MemoryAlloc { - private readonly IntPtr _realMemory; + private IntPtr _realMemory; public AlignedMemoryAlloc(int size, int alignment) { // Make sure the alignment is positive and a power of two. - if (alignment <= 0 || alignment.CountBits() != 1) + if (alignment <= 0 || Utils.CountBits(alignment) != 1) throw new ArgumentOutOfRangeException("alignment"); // Since we are going to align our pointer, we need to account for // any padding at the beginning. - _realMemory = PrivateHeap.Allocate(size + alignment - 1); + _realMemory = MemoryAlloc.PrivateHeap.Allocate(0, size + alignment - 1); // aligned memory = (memory + alignment - 1) & ~(alignment - 1) this.Memory = _realMemory.Align(alignment); @@ -24,7 +26,7 @@ public AlignedMemoryAlloc(int size, int alignment) protected override void Free() { - PrivateHeap.Free(_realMemory); + MemoryAlloc.PrivateHeap.Free(0, _realMemory); } public override void Resize(int newSize) diff --git a/1.x/trunk/ProcessHacker.Native/Memory/Heap.cs b/1.x/trunk/ProcessHacker.Native/Memory/Heap.cs index 21ef5c251..7696c7215 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/Heap.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/Heap.cs @@ -60,13 +60,11 @@ public static Heap[] GetHeaps() return heaps; } - private readonly IntPtr _heap; - private readonly HeapFlags _flags; + private IntPtr _heap; private Heap(IntPtr heap) { _heap = heap; - _flags = 0; } public Heap(HeapFlags flags) @@ -86,8 +84,6 @@ public Heap(HeapFlags flags, int reserveSize, int commitSize) if (_heap == IntPtr.Zero) throw new OutOfMemoryException(); - - _flags = flags; } public IntPtr Address @@ -95,9 +91,9 @@ public IntPtr Address get { return _heap; } } - public IntPtr Allocate(int size) + public IntPtr Allocate(HeapFlags flags, int size) { - IntPtr memory = Win32.RtlAllocateHeap(_heap, _flags, size.ToIntPtr()); + IntPtr memory = Win32.RtlAllocateHeap(_heap, flags, size.ToIntPtr()); if (memory == IntPtr.Zero) throw new OutOfMemoryException(); @@ -105,9 +101,9 @@ public IntPtr Allocate(int size) return memory; } - public int Compact() + public int Compact(HeapFlags flags) { - return Win32.RtlCompactHeap(_heap, _flags).ToInt32(); + return Win32.RtlCompactHeap(_heap, flags).ToInt32(); } public void Destroy() @@ -115,19 +111,19 @@ public void Destroy() Win32.RtlDestroyHeap(_heap); } - public void Free(IntPtr memory) + public void Free(HeapFlags flags, IntPtr memory) { - Win32.RtlFreeHeap(_heap, _flags, memory); + Win32.RtlFreeHeap(_heap, flags, memory); } - public int GetBlockSize(IntPtr memory) + public int GetBlockSize(HeapFlags flags, IntPtr memory) { - return Win32.RtlSizeHeap(_heap, _flags, memory).ToInt32(); + return Win32.RtlSizeHeap(_heap, flags, memory).ToInt32(); } - public IntPtr Reallocate(IntPtr memory, int size) + public IntPtr Reallocate(HeapFlags flags, IntPtr memory, int size) { - IntPtr newMemory = Win32.RtlReAllocateHeap(_heap, _flags, memory, size.ToIntPtr()); + IntPtr newMemory = Win32.RtlReAllocateHeap(_heap, flags, memory, size.ToIntPtr()); if (newMemory == IntPtr.Zero) throw new OutOfMemoryException(); diff --git a/1.x/trunk/ProcessHacker.Native/Memory/LsaMemoryAlloc.cs b/1.x/trunk/ProcessHacker.Native/Memory/LsaMemoryAlloc.cs index ce3a3fcd2..b9503fab7 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/LsaMemoryAlloc.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/LsaMemoryAlloc.cs @@ -31,7 +31,7 @@ namespace ProcessHacker.Native /// public sealed class LsaMemoryAlloc : MemoryAlloc { - private readonly bool _secur32; + private bool _secur32; public LsaMemoryAlloc(IntPtr memory) : this(memory, false) diff --git a/1.x/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs b/1.x/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs index 05caa373f..0bd646fec 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs @@ -20,11 +20,13 @@ * along with Process Hacker. If not, see . */ -#if DEBUG #define ENABLE_STATISTICS -#endif using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; namespace ProcessHacker.Native @@ -34,13 +36,13 @@ namespace ProcessHacker.Native /// public class MemoryAlloc : MemoryRegion { - private static int _allocatedCount; - private static int _freedCount; - private static int _reallocatedCount; + private static int _allocatedCount = 0; + private static int _freedCount = 0; + private static int _reallocatedCount = 0; // A private heap just for the client. private static Heap _privateHeap = new Heap(HeapFlags.Class1 | HeapFlags.Growable); - //private static Heap _processHeap = Heap.GetDefault(); + private static Heap _processHeap = Heap.GetDefault(); public static int AllocatedCount { @@ -67,6 +69,7 @@ public static int ReallocatedCount /// You must set the pointer using the Memory property. /// protected MemoryAlloc() + : base() { } public MemoryAlloc(IntPtr memory) @@ -96,25 +99,21 @@ public MemoryAlloc(int size) /// Any flags to use. public MemoryAlloc(int size, HeapFlags flags) { - this.Memory = _privateHeap.Allocate(size); + this.Memory = _privateHeap.Allocate(flags, size); this.Size = size; #if ENABLE_STATISTICS System.Threading.Interlocked.Increment(ref _allocatedCount); #endif - if (this.Size > 0) - GC.AddMemoryPressure(this.Size); } protected override void Free() { - _privateHeap.Free(this); + _privateHeap.Free(0, this); #if ENABLE_STATISTICS System.Threading.Interlocked.Increment(ref _freedCount); #endif - if (this.Size > 0) - GC.RemoveMemoryPressure(this.Size); } /// @@ -123,17 +122,12 @@ protected override void Free() /// The new size of the allocation. public virtual void Resize(int newSize) { - if (newSize > 0) - GC.RemoveMemoryPressure(this.Size); - - this.Memory = _privateHeap.Reallocate(this.Memory, newSize); + this.Memory = _privateHeap.Reallocate(0, this.Memory, newSize); this.Size = newSize; #if ENABLE_STATISTICS System.Threading.Interlocked.Increment(ref _reallocatedCount); #endif - if (this.Size > 0) - GC.AddMemoryPressure(this.Size); } /// @@ -143,16 +137,9 @@ public virtual void Resize(int newSize) /// The new size of the allocation. public virtual void ResizeNew(int newSize) { - if (newSize > 0) - GC.RemoveMemoryPressure(this.Size); - - _privateHeap.Free(this.Memory); - - this.Memory = _privateHeap.Allocate(newSize); + _privateHeap.Free(0, this.Memory); + this.Memory = _privateHeap.Allocate(0, newSize); this.Size = newSize; - - if (this.Size > 0) - GC.AddMemoryPressure(this.Size); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegion.cs b/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegion.cs index c04ca3efc..cd1d7b596 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegion.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegion.cs @@ -20,15 +20,68 @@ * along with Process Hacker. If not, see . */ +#define SIZE_CACHE_USE_RESOURCE_LOCK + using System; +using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Text; using ProcessHacker.Common.Objects; -using ProcessHacker.Native.Api; +using ProcessHacker.Common.Threading; namespace ProcessHacker.Native { public class MemoryRegion : BaseObject { + private static Dictionary _sizeCache = new Dictionary(); +#if SIZE_CACHE_USE_RESOURCE_LOCK + private static FastResourceLock _sizeCacheLock = new FastResourceLock(); +#endif + + private static int GetStructSize(Type structType) + { + int size; + +#if SIZE_CACHE_USE_RESOURCE_LOCK + _sizeCacheLock.AcquireShared(); + + if (_sizeCache.ContainsKey(structType)) + { + size = _sizeCache[structType]; + _sizeCacheLock.ReleaseShared(); + } + else + { + _sizeCacheLock.ReleaseShared(); + + size = Marshal.SizeOf(structType); + _sizeCacheLock.AcquireExclusive(); + + try + { + if (!_sizeCache.ContainsKey(structType)) + _sizeCache.Add(structType, size); + } + finally + { + _sizeCacheLock.ReleaseExclusive(); + } + } + + return size; +#else + lock (_sizeCache) + { + if (_sizeCache.ContainsKey(structType)) + size = _sizeCache[structType]; + else + _sizeCache.Add(structType, size = Marshal.SizeOf(structType)); + + return size; + } +#endif + } + public static T ReadStruct(IntPtr ptr) { return (T)Marshal.PtrToStructure(ptr, typeof(T)); @@ -44,7 +97,7 @@ public static implicit operator IntPtr(MemoryRegion memory) return memory.Memory.ToPointer(); } - private readonly MemoryRegion _parent; + private MemoryRegion _parent; private IntPtr _memory; private int _size; @@ -121,15 +174,15 @@ public virtual int Size public void DestroyStruct() { - Marshal.DestroyStructure(_memory, typeof(T)); + this.DestroyStruct(0); } - public void DestroyStruct(int index, int size) + public void DestroyStruct(int index) { - this.DestroyStruct(0, index, size); + this.DestroyStruct(0, index); } - public void DestroyStruct(int offset, int index, int size) + public void DestroyStruct(int offset, int index) { if (index == 0) { @@ -138,7 +191,7 @@ public void DestroyStruct(int offset, int index, int size) else { Marshal.DestroyStructure( - _memory.Increment(offset + size * index), + _memory.Increment(offset + GetStructSize(typeof(T)) * index), typeof(T) ); } @@ -146,7 +199,7 @@ public void DestroyStruct(int offset, int index, int size) public void Fill(int offset, int length, byte value) { - Win32.RtlFillMemory( + ProcessHacker.Native.Api.Win32.RtlFillMemory( _memory.Increment(offset), length.ToIntPtr(), value @@ -213,9 +266,12 @@ public int ReadInt32(int offset) /// The offset at which to begin reading. /// The index at which to begin reading, after the offset is added. /// The integer. - public unsafe int ReadInt32(int offset, int index) + public int ReadInt32(int offset, int index) { - return ((int*)((byte*)this._memory + offset))[index]; + unsafe + { + return ((int*)((byte*)_memory + offset))[index]; + } } public int[] ReadInt32Array(int offset, int count) @@ -232,14 +288,17 @@ public IntPtr ReadIntPtr(int offset) return this.ReadIntPtr(offset, 0); } - public unsafe IntPtr ReadIntPtr(int offset, int index) + public IntPtr ReadIntPtr(int offset, int index) { - return ((IntPtr*)((byte*)this._memory + offset))[index]; + unsafe + { + return ((IntPtr*)((byte*)_memory + offset))[index]; + } } public void ReadMemory(IntPtr buffer, int destOffset, int srcOffset, int length) { - Win32.RtlMoveMemory( + ProcessHacker.Native.Api.Win32.RtlMoveMemory( buffer.Increment(destOffset), _memory.Increment(srcOffset), length.ToIntPtr() @@ -262,14 +321,36 @@ public uint ReadUInt32(int offset) /// The offset at which to begin reading. /// The index at which to begin reading, after the offset is added. /// The integer. - public unsafe uint ReadUInt32(int offset, int index) + public uint ReadUInt32(int offset, int index) { - return ((uint*)((byte*)this._memory + offset))[index]; + unsafe + { + return ((uint*)((byte*)_memory + offset))[index]; + } } - public T ReadStruct() where T : struct + /// + /// Creates a struct from the memory allocation. + /// + /// The type of the struct. + /// The new struct. + public T ReadStruct() + where T : struct { - return (T)Marshal.PtrToStructure(_memory, typeof(T)); + return this.ReadStruct(0); + } + + /// + /// Creates a struct from the memory allocation. + /// + /// The type of the struct. + /// The index at which to begin reading to the struct. This is multiplied by + /// the size of the struct. + /// The new struct. + public T ReadStruct(int index) + where T : struct + { + return this.ReadStruct(0, index); } /// @@ -277,18 +358,23 @@ public T ReadStruct() where T : struct /// /// The type of the struct. /// The offset to add before reading. - /// /// The index at which to begin reading to the struct. This is multiplied by /// the size of the struct. /// The new struct. - public T ReadStruct(int offset, int size, int index) where T : struct + public T ReadStruct(int offset, int index) + where T : struct { if (index == 0) { return (T)Marshal.PtrToStructure(_memory.Increment(offset), typeof(T)); } - - return (T)Marshal.PtrToStructure(this._memory.Increment(offset + size * index), typeof(T)); + else + { + return (T)Marshal.PtrToStructure( + _memory.Increment(offset + GetStructSize(typeof(T)) * index), + typeof(T) + ); + } } public string ReadUnicodeString(int offset) @@ -306,9 +392,12 @@ public string ReadUnicodeString(int offset, int length) /// /// The offset at which to write. /// The value of the byte. - public unsafe void WriteByte(int offset, byte b) + public void WriteByte(int offset, byte b) { - *((byte*)this._memory + offset) = b; + unsafe + { + *((byte*)_memory + offset) = b; + } } public void WriteBytes(int offset, byte[] b) @@ -316,41 +405,53 @@ public void WriteBytes(int offset, byte[] b) Marshal.Copy(b, 0, _memory.Increment(offset), b.Length); } - public unsafe void WriteInt16(int offset, short i) + public void WriteInt16(int offset, short i) { - *(short*)((byte*)this._memory + offset) = i; + unsafe + { + *(short*)((byte*)_memory + offset) = i; + } } - public unsafe void WriteInt32(int offset, int i) + public void WriteInt32(int offset, int i) { - *(int*)((byte*)this._memory + offset) = i; + unsafe + { + *(int*)((byte*)_memory + offset) = i; + } } - public unsafe void WriteIntPtr(int offset, IntPtr i) + public void WriteIntPtr(int offset, IntPtr i) { - *(IntPtr*)((byte*)this._memory + offset) = i; + unsafe + { + *(IntPtr*)((byte*)_memory + offset) = i; + } } public void WriteMemory(int offset, IntPtr buffer, int length) { - Win32.RtlMoveMemory( + ProcessHacker.Native.Api.Win32.RtlMoveMemory( _memory.Increment(offset), buffer, length.ToIntPtr() ); } - public void WriteStruct(T s) where T : struct + public void WriteStruct(T s) + where T : struct { - Marshal.StructureToPtr(s, _memory, false); + this.WriteStruct(0, s); } - public void WriteStruct(int index, int size, T s) where T : struct + public void WriteStruct(int index, T s) + where T : struct { - this.WriteStruct(0, size, index, s); + this.WriteStruct(0, index, s); } - public void WriteStruct(int offset, int size, int index, T s) where T : struct + public void WriteStruct(int offset, int index, T s) + where T : struct { if (index == 0) { @@ -360,7 +461,7 @@ public void WriteStruct(int offset, int size, int index, T s) where T : struc { Marshal.StructureToPtr( s, - _memory.Increment(offset + size * index), + _memory.Increment(offset + GetStructSize(typeof(T)) * index), false ); } @@ -371,17 +472,20 @@ public void WriteStruct(int offset, int size, int index, T s) where T : struc /// /// The offset to add. /// The string to write. - public unsafe void WriteUnicodeString(int offset, string s) + public void WriteUnicodeString(int offset, string s) { - fixed (char* ptr = s) + unsafe { - this.WriteMemory(offset, (IntPtr)ptr, s.Length * 2); + fixed (char* ptr = s) + { + this.WriteMemory(offset, (IntPtr)ptr, s.Length * 2); + } } } public void Zero(int offset, int length) { - Win32.RtlZeroMemory( + ProcessHacker.Native.Api.Win32.RtlZeroMemory( _memory.Increment(offset), length.ToIntPtr() ); diff --git a/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegionStream.cs b/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegionStream.cs index e4674ecbc..103fc20fe 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegionStream.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/MemoryRegionStream.cs @@ -28,8 +28,8 @@ namespace ProcessHacker.Native { public class MemoryRegionStream : Stream { - private readonly MemoryRegion _memory; - private long _position; + private MemoryRegion _memory; + private long _position = 0; public MemoryRegionStream(MemoryRegion memory) { @@ -86,18 +86,12 @@ public override int ReadByte() public override long Seek(long offset, SeekOrigin origin) { - switch (origin) - { - case SeekOrigin.Begin: - this._position = offset; - break; - case SeekOrigin.Current: - this._position += offset; - break; - case SeekOrigin.End: - this._position = this._memory.Size + offset; - break; - } + if (origin == SeekOrigin.Begin) + _position = offset; + else if (origin == SeekOrigin.Current) + _position += offset; + else if (origin == SeekOrigin.End) + _position = _memory.Size + offset; return _position; } diff --git a/1.x/trunk/ProcessHacker.Native/Memory/PebMemoryAlloc.cs b/1.x/trunk/ProcessHacker.Native/Memory/PebMemoryAlloc.cs index aeb6f5439..73d2eb040 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/PebMemoryAlloc.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/PebMemoryAlloc.cs @@ -33,9 +33,11 @@ public sealed class PebMemoryAlloc : MemoryAlloc { public PebMemoryAlloc(int size) { + NtStatus status; IntPtr block; - Win32.RtlAllocateFromPeb(size, out block).ThrowIf(); + if ((status = Win32.RtlAllocateFromPeb(size, out block)) >= NtStatus.Error) + Win32.Throw(status); this.Memory = block; this.Size = size; @@ -43,7 +45,10 @@ public PebMemoryAlloc(int size) protected override void Free() { - Win32.RtlFreeToPeb(this, this.Size).ThrowIf(); + NtStatus status; + + if ((status = Win32.RtlFreeToPeb(this, this.Size)) >= NtStatus.Error) + Win32.Throw(status); } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPages.cs b/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPages.cs index 5090620f1..1da7fbca6 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPages.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPages.cs @@ -10,9 +10,9 @@ namespace ProcessHacker.Native.Memory /// public sealed class PhysicalPages : BaseObject { - private readonly ProcessHandle _processHandle; - private readonly int _count; - private readonly IntPtr[] _pfnArray; + private ProcessHandle _processHandle; + private int _count; + private IntPtr[] _pfnArray; /// /// Allocates physical pages. diff --git a/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPagesMapping.cs b/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPagesMapping.cs index 78e7f5962..ee1d5c134 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPagesMapping.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/PhysicalPagesMapping.cs @@ -1,10 +1,11 @@ using System; +using ProcessHacker.Native.Api; namespace ProcessHacker.Native.Memory { public sealed class PhysicalPagesMapping : MemoryAlloc { - private readonly PhysicalPages _physicalPages; + private PhysicalPages _physicalPages; internal PhysicalPagesMapping(PhysicalPages physicalPages, IntPtr baseAddress) { diff --git a/1.x/trunk/ProcessHacker.Native/Memory/PinnedObject.cs b/1.x/trunk/ProcessHacker.Native/Memory/PinnedObject.cs index f3c1f96dd..c1c675c22 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/PinnedObject.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/PinnedObject.cs @@ -1,11 +1,14 @@ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Text; +using ProcessHacker.Common.Objects; namespace ProcessHacker.Native { - public sealed class PinnedObject : MemoryRegion + public sealed class PinnedObject : BaseObject { - private readonly T _object; + private T _object; private GCHandle _handle; public PinnedObject(T obj) @@ -14,7 +17,7 @@ public PinnedObject(T obj) _handle = GCHandle.Alloc(obj, GCHandleType.Pinned); } - protected override void Free() + protected override void DisposeObject(bool disposing) { _handle.Free(); } diff --git a/1.x/trunk/ProcessHacker.Native/Memory/Section.cs b/1.x/trunk/ProcessHacker.Native/Memory/Section.cs index 9c68d63ff..7710ce9ce 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/Section.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/Section.cs @@ -9,7 +9,7 @@ namespace ProcessHacker.Native /// public sealed class Section : NativeObject { - private readonly MemoryProtection _originalProtection = MemoryProtection.ReadWrite; + private MemoryProtection _originalProtection = MemoryProtection.ReadWrite; /// /// Opens an existing section. @@ -64,7 +64,7 @@ public Section(string name, FileHandle fileHandle, bool image, MemoryProtection name, ObjectFlags.OpenIf, null, - fileHandle.FileSize, + fileHandle.GetSize(), image ? SectionAttributes.Image : SectionAttributes.Commit, protection, fileHandle diff --git a/1.x/trunk/ProcessHacker.Native/Memory/SectionView.cs b/1.x/trunk/ProcessHacker.Native/Memory/SectionView.cs index 1e67595e9..232feba5d 100644 --- a/1.x/trunk/ProcessHacker.Native/Memory/SectionView.cs +++ b/1.x/trunk/ProcessHacker.Native/Memory/SectionView.cs @@ -40,7 +40,10 @@ internal SectionView(IntPtr baseAddress, IntPtr commitSize) protected override void Free() { - Win32.NtUnmapViewOfSection(ProcessHandle.Current, this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtUnmapViewOfSection(ProcessHandle.Current, this)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -62,8 +65,8 @@ public bool IsSameFile(SectionView mappedAsFile) { if ((uint)Win32.NtAreMappedFilesTheSame(this, mappedAsFile) == this.Memory.ToUInt32()) return true; - - return false; + else + return false; } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/1.x/trunk/ProcessHacker.Native/Mfs/Exceptions.cs b/1.x/trunk/ProcessHacker.Native/Mfs/Exceptions.cs index efd54e387..cc14a02b7 100644 --- a/1.x/trunk/ProcessHacker.Native/Mfs/Exceptions.cs +++ b/1.x/trunk/ProcessHacker.Native/Mfs/Exceptions.cs @@ -1,11 +1,13 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Native.Mfs { - [Serializable] public class MfsException : Exception { public MfsException() + : base() { } public MfsException(string message) @@ -17,7 +19,6 @@ public MfsException(string message, Exception innerException) { } } - [Serializable] public class MfsInvalidFileSystemException : MfsException { public MfsInvalidFileSystemException() @@ -32,8 +33,7 @@ public MfsInvalidFileSystemException(string message, Exception innerException) : base(message, innerException) { } } - - [Serializable] + public class MfsInvalidOperationException : MfsException { public MfsInvalidOperationException() diff --git a/1.x/trunk/ProcessHacker.Native/Mfs/Internal.cs b/1.x/trunk/ProcessHacker.Native/Mfs/Internal.cs index 00e6c865b..0ce96a5aa 100644 --- a/1.x/trunk/ProcessHacker.Native/Mfs/Internal.cs +++ b/1.x/trunk/ProcessHacker.Native/Mfs/Internal.cs @@ -98,13 +98,6 @@ internal struct MfsBlockHeader [StructLayout(LayoutKind.Sequential, Pack = 4)] internal unsafe struct MfsObjectHeader { - public static readonly int SizeOf; - - static MfsObjectHeader() - { - SizeOf = Marshal.SizeOf(typeof(MfsObjectHeader)); - } - public MfsCellId Flink; public MfsCellId Blink; public MfsCellId Parent; @@ -118,11 +111,11 @@ static MfsObjectHeader() public MfsCellId LastData; public int NameLength; - public fixed char Name [32]; + public fixed char Name[32]; } [StructLayout(LayoutKind.Sequential, Pack = 4)] - internal struct MfsDataCell + internal unsafe struct MfsDataCell { public static readonly int DataOffset = Marshal.OffsetOf(typeof(MfsDataCell), "Data").ToInt32(); diff --git a/1.x/trunk/ProcessHacker.Native/Mfs/MemoryDataWriteStream.cs b/1.x/trunk/ProcessHacker.Native/Mfs/MemoryDataWriteStream.cs index 6569cd7f9..da9e844ff 100644 --- a/1.x/trunk/ProcessHacker.Native/Mfs/MemoryDataWriteStream.cs +++ b/1.x/trunk/ProcessHacker.Native/Mfs/MemoryDataWriteStream.cs @@ -21,15 +21,17 @@ */ using System; +using System.Collections.Generic; using System.IO; +using System.Text; using ProcessHacker.Common; namespace ProcessHacker.Native.Mfs { public class MemoryDataWriteStream : Stream { - private readonly MemoryObject _obj; - private readonly byte[] _buffer; + private MemoryObject _obj; + private byte[] _buffer; private int _bufferLength; internal MemoryDataWriteStream(MemoryObject obj, int bufferSize) diff --git a/1.x/trunk/ProcessHacker.Native/Mfs/MemoryFileSystem.cs b/1.x/trunk/ProcessHacker.Native/Mfs/MemoryFileSystem.cs index fd352806e..477ff087b 100644 --- a/1.x/trunk/ProcessHacker.Native/Mfs/MemoryFileSystem.cs +++ b/1.x/trunk/ProcessHacker.Native/Mfs/MemoryFileSystem.cs @@ -53,23 +53,26 @@ public void ResetObject() } } - private readonly bool _readOnly; - private readonly MemoryProtection _protection; - private readonly Section _section; + private bool _readOnly; + private MemoryProtection _protection; + private Section _section; private MfsFsHeader* _header; - private readonly int _blockSize; - private readonly int _blockMask; - private readonly int _cellSize; - private readonly int _cellCount; - private readonly int _dataCellDataMaxLength; - - private readonly MfsCellId _rootObjectCellId = new MfsCellId(0, 1); - private readonly MemoryObject _rootObjectMo; - - private readonly FreeList _vdFreeList = new FreeList(16); - private readonly Dictionary _views = new Dictionary(); - private readonly Dictionary _views2 = new Dictionary(); + private int _blockSize; + private int _blockMask; + private int _cellSize; + private int _cellCount; + private int _dataCellDataMaxLength; + + private MfsCellId _rootObjectCellId = new MfsCellId(0, 1); + private MfsObjectHeader* _rootObject; + private MemoryObject _rootObjectMo; + + private FreeList _vdFreeList = new FreeList(16); + private Dictionary _views = + new Dictionary(); + private Dictionary _views2 = + new Dictionary(); private ViewDescriptor _cachedLastBlockView; @@ -106,7 +109,7 @@ public MemoryFileSystem(string fileName, MfsOpenMode mode, bool readOnly, MfsPar break; } - using (FileHandle fhandle = FileHandle.CreateWin32( + using (var fhandle = FileHandle.CreateWin32( fileName, FileAccess.GenericRead | (!readOnly ? FileAccess.GenericWrite : 0), FileShareMode.Read, @@ -118,42 +121,46 @@ public MemoryFileSystem(string fileName, MfsOpenMode mode, bool readOnly, MfsPar _readOnly = readOnly; _protection = !readOnly ? MemoryProtection.ReadWrite : MemoryProtection.ReadOnly; - if (fhandle.FileSize == 0) + if (fhandle.GetSize() == 0) { if (readOnly) { throw new MfsInvalidFileSystemException(); } - - // File is too small. Make it 1 byte large and we'll deal with it soon. - fhandle.SetEnd(1); + else + { + // File is too small. Make it 1 byte large and we'll deal with it + // soon. + fhandle.SetEnd(1); + } } _section = new Section(fhandle, _protection); _blockSize = MfsBlockSizeBase; // fake block size to begin with; we'll fix it up later. - if (fhandle.FileSize < _blockSize) + if (fhandle.GetSize() < _blockSize) { if (readOnly) { throw new MfsInvalidFileSystemException(); } - - // We're creating a new file system. We need the correct block size now. - if (createParams != null) - this._blockSize = createParams.BlockSize; else - this._blockSize = MfsDefaultBlockSize; + { + // We're creating a new file system. We need the correct block size + // now. + if (createParams != null) + _blockSize = createParams.BlockSize; + else + _blockSize = MfsDefaultBlockSize; - this._section.Extend(this._blockSize); + _section.Extend(_blockSize); - using (SectionView view = this._section.MapView(0, this._blockSize, this._protection)) - { - this.InitializeFs((MfsFsHeader*)view.Memory, createParams); - } + using (var view = _section.MapView(0, _blockSize, _protection)) + this.InitializeFs((MfsFsHeader*)view.Memory, createParams); - justCreated = true; + justCreated = true; + } } _header = (MfsFsHeader*)this.ReferenceBlock(0); @@ -189,6 +196,7 @@ public MemoryFileSystem(string fileName, MfsOpenMode mode, bool readOnly, MfsPar _header = (MfsFsHeader*)this.ReferenceBlock(0); // Set up the root object. + _rootObject = (MfsObjectHeader*)((byte*)_header + _cellSize); _rootObjectMo = new MemoryObject(this, _rootObjectCellId, true); if (_header->NextFreeBlock != 1 && !readOnly) @@ -203,16 +211,15 @@ public MemoryFileSystem(string fileName, MfsOpenMode mode, bool readOnly, MfsPar protected override void DisposeObject(bool disposing) { - foreach (ViewDescriptor vd in _views.Values) + foreach (var vd in _views.Values) vd.View.Dispose(disposing); if (_rootObjectMo != null) _rootObjectMo.Dispose(); - if (_section != null) _section.Dispose(); - _header = null; + _rootObject = null; } public int BlockSize @@ -627,7 +634,7 @@ private void ValidateFsParameters(int blockSize, int cellSize) throw new ArgumentException("The block size must be a multiple of the cell size."); if ((blockSize / cellSize) < 2) throw new ArgumentException("There must be a least 2 cells in each block."); - if (cellSize < MfsObjectHeader.SizeOf) + if (cellSize < Marshal.SizeOf(typeof(MfsObjectHeader))) throw new ArgumentException("The cell size is too small."); } } diff --git a/1.x/trunk/ProcessHacker.Native/Mfs/MemoryObject.cs b/1.x/trunk/ProcessHacker.Native/Mfs/MemoryObject.cs index f3918503b..a057f4511 100644 --- a/1.x/trunk/ProcessHacker.Native/Mfs/MemoryObject.cs +++ b/1.x/trunk/ProcessHacker.Native/Mfs/MemoryObject.cs @@ -30,9 +30,9 @@ public unsafe sealed class MemoryObject : BaseObject { public delegate bool EnumChildrenDelegate(MemoryObject mo); - private readonly bool _fsInternal; - private readonly MemoryFileSystem _fs; - private readonly MfsCellId _cellId; + private bool _fsInternal; + private MemoryFileSystem _fs; + private MfsCellId _cellId; private MfsObjectHeader* _obj; private string _name; @@ -80,7 +80,7 @@ public string Name { get { - if (string.IsNullOrEmpty(_name)) + if (_name == null) _name = _fs.GetObjectName(_obj); return _name; @@ -184,26 +184,23 @@ public MemoryObject GetChild(string name) return null; } - public string[] ChildNames + public string[] GetChildNames() { - get - { - List names = new List(); + List names = new List(); - this.EnumChildren(mo => + this.EnumChildren((mo) => { names.Add(mo.Name); mo.Dispose(); return true; }); - return names.ToArray(); - } + return names.ToArray(); } - public MemoryObject Parent + public MemoryObject GetParent() { - get { return new MemoryObject(_fs, _obj->Parent); } + return new MemoryObject(_fs, _obj->Parent); } public MemoryDataWriteStream GetWriteStream() diff --git a/1.x/trunk/ProcessHacker.Native/NativeBitmap.cs b/1.x/trunk/ProcessHacker.Native/NativeBitmap.cs index 7bcdf6a0d..f0b5f4bff 100644 --- a/1.x/trunk/ProcessHacker.Native/NativeBitmap.cs +++ b/1.x/trunk/ProcessHacker.Native/NativeBitmap.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Common; using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; @@ -54,7 +56,7 @@ public int Length } private RtlBitmap _bitmap; - private readonly MemoryAlloc _buffer; + private MemoryAlloc _buffer; public NativeBitmap(int bits) { @@ -129,8 +131,9 @@ public BitmapRun[] FindClearRuns(int count) public BitmapRun[] FindClearRuns(int count, bool locateLongest) { RtlBitmapRun[] runs = new RtlBitmapRun[count]; + int numberOfRuns; - int numberOfRuns = Win32.RtlFindClearRuns(ref this._bitmap, runs, count, locateLongest); + numberOfRuns = Win32.RtlFindClearRuns(ref _bitmap, runs, count, locateLongest); BitmapRun[] returnRuns = new BitmapRun[numberOfRuns]; @@ -143,8 +146,9 @@ public BitmapRun[] FindClearRuns(int count, bool locateLongest) public BitmapRun FindBackwardClearRun(int index) { int startingIndex; + int numberOfBits; - int numberOfBits = Win32.RtlFindLastBackwardRunClear(ref this._bitmap, index, out startingIndex); + numberOfBits = Win32.RtlFindLastBackwardRunClear(ref _bitmap, index, out startingIndex); return new BitmapRun(startingIndex, numberOfBits); } @@ -152,8 +156,9 @@ public BitmapRun FindBackwardClearRun(int index) public BitmapRun FindFirstClearRun() { int startingIndex; + int numberOfBits; - int numberOfBits = Win32.RtlFindFirstRunClear(ref this._bitmap, out startingIndex); + numberOfBits = Win32.RtlFindFirstRunClear(ref _bitmap, out startingIndex); return new BitmapRun(startingIndex, numberOfBits); } @@ -161,8 +166,9 @@ public BitmapRun FindFirstClearRun() public BitmapRun FindForwardClearRun(int index) { int startingIndex; + int numberOfBits; - int numberOfBits = Win32.RtlFindNextForwardRunClear(ref this._bitmap, index, out startingIndex); + numberOfBits = Win32.RtlFindNextForwardRunClear(ref _bitmap, index, out startingIndex); return new BitmapRun(startingIndex, numberOfBits); } @@ -170,8 +176,9 @@ public BitmapRun FindForwardClearRun(int index) public BitmapRun FindLongestClearRun() { int startingIndex; + int numberOfBits; - int numberOfBits = Win32.RtlFindLongestRunClear(ref this._bitmap, out startingIndex); + numberOfBits = Win32.RtlFindLongestRunClear(ref _bitmap, out startingIndex); return new BitmapRun(startingIndex, numberOfBits); } @@ -196,14 +203,14 @@ public int FindSetAndClear(int length, int hintIndex) return Win32.RtlFindSetBitsAndClear(ref _bitmap, length, hintIndex); } - public int ClearCount + public int GetClearCount() { - get { return Win32.RtlNumberOfClearBits(ref _bitmap); } + return Win32.RtlNumberOfClearBits(ref _bitmap); } - public int SetCount + public int GetSetCount() { - get { return Win32.RtlNumberOfSetBits(ref _bitmap); } + return Win32.RtlNumberOfSetBits(ref _bitmap); } public void Set() diff --git a/1.x/trunk/ProcessHacker.Native/NativeLibrary.cs b/1.x/trunk/ProcessHacker.Native/NativeLibrary.cs deleted file mode 100644 index 1610003fc..000000000 --- a/1.x/trunk/ProcessHacker.Native/NativeLibrary.cs +++ /dev/null @@ -1,184 +0,0 @@ -namespace System -{ - using Runtime.InteropServices; - using ProcessHacker.Native; - using ProcessHacker.Native.Api; - using ProcessHacker.Native.Objects; - - /// - /// Utility class to wrap an unmanaged DLL and be responsible for freeing it. - /// - /// This is a managed wrapper over the native LoadLibrary, GetProcAddress, and FreeLibrary calls. - public sealed class NativeLibrary : NativeHandle - { - /// - /// LoadLibraryEx constructor to load a dll and be responsible for freeing it. - /// - /// full path name of dll to load - /// - /// Throws exceptions on failure. Most common failure would be file-not-found, or that the file is not a loadable image. - public NativeLibrary(string dllName, LoadLibraryFlags flags) - { - UnicodeString str = new UnicodeString(dllName); - - IntPtr ptr; - - NtStatus result = Win32.LdrLoadDll(null, (int)flags, ref str, out ptr); - - if (result.IsError()) - { - this.MarkAsInvalid(); - } - - str.Dispose(); - } - - /// - /// Dynamically lookup a function in the dll via kernel32!GetProcAddress. - /// - /// raw name of the function in the export table. - /// null if function is not found. Else a delegate to the unmanaged function. - /// GetProcAddress results are valid as long as the dll is not yet unloaded. This - /// is very very dangerous to use since you need to ensure that the dll is not unloaded - /// until after you're done with any objects implemented by the dll. For example, if you - /// get a delegate that then gets an IUnknown implemented by this dll, - /// you can not dispose this library until that IUnknown is collected. Else, you may free - /// the library and then the CLR may call release on that IUnknown and it will crash. - public TDelegate GetUnmanagedFunction(string functionName) where TDelegate : class - { - using (AnsiString str = new AnsiString(functionName)) - { - IntPtr functionPtr; - - NtStatus result = Win32.LdrGetProcedureAddress(this, str.Buffer, 0, out functionPtr); - - // Failure is a common case, especially for adaptive code. - if (result.IsError()) - { - //result.ReturnException().Log(); - - return null; - } - - Delegate function = Marshal.GetDelegateForFunctionPointer(functionPtr, typeof(TDelegate)); - - // Ideally, we'd just make the constraint on TDelegate be - // System.Delegate, but compiler error CS0702 (constrained can't be System.Delegate) - // prevents that. So we make the constraint system.object and do the cast from object-->TDelegate. - object o = function; - - return (TDelegate)o; - } - } - - #region Disposable Members - - /// - /// Call FreeLibrary on the unmanaged dll. All function pointers handed out from this class become invalid after this. - /// - /// This is very dangerous because it suddenly invalidate - /// everything retrieved from this dll. This includes any functions - /// handed out via GetProcAddress, and potentially any objects returned - /// from those functions (which may have an implementation in the dll). - /// - protected override void Close() - { - Win32.LdrUnloadDll(this).ThrowIf(); - } - - #endregion - - public IntPtr GetProcedure(string procedureName) - { - AnsiString str = new AnsiString(procedureName); - { - IntPtr functionPtr = IntPtr.Zero; - - NtStatus result = Win32.LdrGetProcedureAddress(this, functionPtr, 0, out functionPtr); - - return functionPtr; - } - } - - public IntPtr GetProcedure(int procedureNumber) - { - IntPtr functionPtr; - - NtStatus result = Win32.LdrGetProcedureAddress(this, IntPtr.Zero, procedureNumber, out functionPtr); - - return functionPtr; - } - - #region Static Methods - - public static IntPtr GetProcedure(string dllName, string procedureName) - { - return GetProcedure(GetModuleHandle(dllName), procedureName); - } - - public static IntPtr GetProcedure(IntPtr dllHandle, string procedureName) - { - IntPtr handle; - - using (AnsiString str = new AnsiString(procedureName)) - { - Win32.LdrGetProcedureAddress(dllHandle, str.Buffer, 0, out handle).ThrowIf(); - } - - return handle; - } - - public static IntPtr GetModuleHandle(string dllName) - { - IntPtr handle; - - UnicodeString str = new UnicodeString(dllName); - { - Win32.LdrGetDllHandle(null, 0, ref str, out handle).ThrowIf(); - } - - return handle; - } - - #endregion - } - - [Flags] //TODO: move to enum file - public enum LoadLibraryFlags - { - None = 0, - - /// - /// If this value is used, and the executable module is a DLL, the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module. Do not use this value; it is provided only for backwards compatibility. If you are planning to access only data or resources in the DLL, use LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_IMAGE_RESOURCE or both. Otherwise, load the library as a DLL or executable module using the LoadLibrary function. - /// - DontResolveDllReferences = 0x00000001, - - /// - /// If this value is used, the system maps the file into the calling process's virtual address space as if it were a data file. Nothing is done to execute or prepare to execute the mapped file. Therefore, you cannot call functions like GetModuleFileName, GetModuleHandle or GetProcAddress with this DLL. Using this value causes writes to read-only memory to raise an access violation. Use this flag when you want to load a DLL only to extract messages or resources from it. This value can be used with LOAD_LIBRARY_AS_IMAGE_RESOURCE. - /// - LOAD_LIBRARY_AS_DATAFILE = 0x00000002, - - /// - /// If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded. If this value is used and lpFileName specifies a relative path, the behavior is undefined. If this value is not used, or if lpFileName does not specify a path, the system uses the standard search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded. - /// - LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008, - - /// - /// If this value is used, the system does not check AppLocker rules or apply Software Restriction Policies for the DLL. This action applies only to the DLL being loaded and not to its dependents. This value is recommended for use in setup programs that must run extracted DLLs during installation. - /// - LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010, - - /// - /// If this value is used, the system maps the file into the process's virtual address space as an image file. However, the loader does not load the static imports or perform the other usual initialization steps. Use this flag when you want to load a DLL only to extract messages or resources from it. Unless the application depends on the image layout, this value should be used with either LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_DATAFILE. For more information, see the Remarks section. - /// - LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020, - - /// - /// Similar to LOAD_LIBRARY_AS_DATAFILE, except that the DLL file on the disk is opened for exclusive write access. Therefore, other processes cannot open the DLL file for write access while it is in use. However, the DLL can still be opened by other processes. This value can be used with LOAD_LIBRARY_AS_IMAGE_RESOURCE. For more information, see Remarks. - /// - LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040, - - - LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = 0x00000080 - } -} diff --git a/1.x/trunk/ProcessHacker.Native/NativeUtils.cs b/1.x/trunk/ProcessHacker.Native/NativeUtils.cs index bd67e9ed0..76f75c478 100644 --- a/1.x/trunk/ProcessHacker.Native/NativeUtils.cs +++ b/1.x/trunk/ProcessHacker.Native/NativeUtils.cs @@ -1,6 +1,7 @@ using System; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; +using System.Runtime.InteropServices; using ProcessHacker.Native.Security; namespace ProcessHacker.Native @@ -41,23 +42,34 @@ public unsafe static void CopyProcessParameters( ref StartupInfo startupInfo ) { + UnicodeString imagePathNameStr; + UnicodeString dllPathStr; + UnicodeString currentDirectoryStr; + UnicodeString commandLineStr; + UnicodeString windowTitleStr; + UnicodeString desktopInfoStr; + UnicodeString shellInfoStr; + UnicodeString runtimeInfoStr; + // Create the unicode strings. - UnicodeString imagePathNameStr = new UnicodeString(imagePathName); - UnicodeString dllPathStr = new UnicodeString(dllPath); - UnicodeString currentDirectoryStr = new UnicodeString(currentDirectory); - UnicodeString commandLineStr = new UnicodeString(commandLine); - UnicodeString windowTitleStr = new UnicodeString(windowTitle); - UnicodeString desktopInfoStr = new UnicodeString(desktopInfo); - UnicodeString shellInfoStr = new UnicodeString(shellInfo); - UnicodeString runtimeInfoStr = new UnicodeString(runtimeInfo); + imagePathNameStr = new UnicodeString(imagePathName); + dllPathStr = new UnicodeString(dllPath); + currentDirectoryStr = new UnicodeString(currentDirectory); + commandLineStr = new UnicodeString(commandLine); + windowTitleStr = new UnicodeString(windowTitle); + desktopInfoStr = new UnicodeString(desktopInfo); + shellInfoStr = new UnicodeString(shellInfo); + runtimeInfoStr = new UnicodeString(runtimeInfo); try { + NtStatus status; IntPtr processParameters; // Create the process parameter block. - Win32.RtlCreateProcessParameters( + + status = Win32.RtlCreateProcessParameters( out processParameters, ref imagePathNameStr, ref dllPathStr, @@ -68,15 +80,21 @@ ref StartupInfo startupInfo ref desktopInfoStr, ref shellInfoStr, ref runtimeInfoStr - ).ThrowIf(); + ); + + if (status >= NtStatus.Error) + Win32.Throw(status); try { // Allocate a new memory region in the remote process for // the environment block and copy it over. - int environmentLength = environment.Length; - IntPtr newEnvironment = processHandle.AllocateMemory( + int environmentLength; + IntPtr newEnvironment; + + environmentLength = environment.GetLength(); + newEnvironment = processHandle.AllocateMemory( environmentLength, MemoryProtection.ReadWrite ); @@ -113,9 +131,10 @@ ref runtimeInfoStr // Allocate a new memory region in the remote process for // the process parameters. + IntPtr newProcessParameters; IntPtr regionSize = paramsStruct->Length.ToIntPtr(); - IntPtr newProcessParameters = processHandle.AllocateMemory( + newProcessParameters = processHandle.AllocateMemory( IntPtr.Zero, ref regionSize, MemoryFlags.Commit, @@ -161,23 +180,25 @@ public static string FormatNativeKeyName(string nativeKeyName) if (nativeKeyName.StartsWith(hkcrString, StringComparison.OrdinalIgnoreCase)) return "HKCR" + nativeKeyName.Substring(hkcrString.Length); - if (nativeKeyName.StartsWith(hklmString, StringComparison.OrdinalIgnoreCase)) + else if (nativeKeyName.StartsWith(hklmString, StringComparison.OrdinalIgnoreCase)) return "HKLM" + nativeKeyName.Substring(hklmString.Length); - if (nativeKeyName.StartsWith(hkcucrString, StringComparison.OrdinalIgnoreCase)) + else if (nativeKeyName.StartsWith(hkcucrString, StringComparison.OrdinalIgnoreCase)) return @"HKCU\Software\Classes" + nativeKeyName.Substring(hkcucrString.Length); - if (nativeKeyName.StartsWith(hkcuString, StringComparison.OrdinalIgnoreCase)) + else if (nativeKeyName.StartsWith(hkcuString, StringComparison.OrdinalIgnoreCase)) return "HKCU" + nativeKeyName.Substring(hkcuString.Length); - if (nativeKeyName.StartsWith(hkuString, StringComparison.OrdinalIgnoreCase)) + else if (nativeKeyName.StartsWith(hkuString, StringComparison.OrdinalIgnoreCase)) return "HKU" + nativeKeyName.Substring(hkuString.Length); - return nativeKeyName; + else + return nativeKeyName; } public static string GetMessage(IntPtr dllHandle, int messageTableId, int messageLanguageId, int messageId) { + NtStatus status; IntPtr messageEntry; string message; - NtStatus status = Win32.RtlFindMessage( + status = Win32.RtlFindMessage( dllHandle, messageTableId, messageLanguageId, @@ -188,8 +209,8 @@ out messageEntry if (status.IsError()) return null; - MemoryRegion region = new MemoryRegion(messageEntry); - MessageResourceEntry entry = region.ReadStruct(); + var region = new MemoryRegion(messageEntry); + var entry = region.ReadStruct(); // Read the message, depending on format. if ((entry.Flags & MessageResourceFlags.Unicode) == MessageResourceFlags.Unicode) @@ -217,7 +238,7 @@ public static bool ObjectExists(string name) try { - using (var dhandle = new DirectoryHandle(dirPart, DirectoryAccess.Query)) + using (var dhandle = new DirectoryHandle(dirPart, ProcessHacker.Native.Security.DirectoryAccess.Query)) { var objects = dhandle.GetObjects(); @@ -242,7 +263,7 @@ public static NativeHandle OpenObject(int access, string name, ObjectFlags objec try { - return null;// new NativeHandle(KProcessHacker.Instance.KphOpenNamedObject(access, oa).ToIntPtr(), true); + return new NativeHandle(KProcessHacker.Instance.KphOpenNamedObject(access, oa).ToIntPtr(), true); } finally { diff --git a/1.x/trunk/ProcessHacker.Native/OSVersion.cs b/1.x/trunk/ProcessHacker.Native/OSVersion.cs index 83e4fcc7d..a07d5728f 100644 --- a/1.x/trunk/ProcessHacker.Native/OSVersion.cs +++ b/1.x/trunk/ProcessHacker.Native/OSVersion.cs @@ -25,7 +25,7 @@ namespace ProcessHacker.Native { - public enum OSArch + public enum OSArch : int { Unknown, I386, @@ -59,11 +59,6 @@ public enum WindowsVersion /// Seven = 61, - /// - /// Windows 8. - /// - Eight = 62, - /// /// An unknown version of Windows. /// @@ -72,31 +67,31 @@ public enum WindowsVersion public static class OSVersion { - private static readonly int _bits = IntPtr.Size * 8; - private static readonly OSArch _arch = IntPtr.Size == 4 ? OSArch.I386 : OSArch.Amd64; - private static readonly string _versionString; - private static readonly WindowsVersion _windowsVersion; - - private static readonly ProcessAccess _minProcessQueryInfoAccess = ProcessAccess.QueryInformation; - private static readonly ThreadAccess _minThreadQueryInfoAccess = ThreadAccess.QueryInformation; - private static readonly ThreadAccess _minThreadSetInfoAccess = ThreadAccess.SetInformation; - - private static readonly bool _hasCycleTime; - private static readonly bool _hasExtendedTaskbar; - private static readonly bool _hasIoPriority; - private static readonly bool _hasPagePriority; - private static readonly bool _hasProtectedProcesses; - private static readonly bool _hasPsSuspendResumeProcess; - private static readonly bool _hasQueryLimitedInformation; - private static readonly bool _hasSetAccessToken; - private static readonly bool _hasTaskDialogs; - private static readonly bool _hasThemes; - private static readonly bool _hasUac; - private static readonly bool _hasWin32ImageFileName; + private static int _bits = IntPtr.Size * 8; + private static OSArch _arch = IntPtr.Size == 4 ? OSArch.I386 : OSArch.Amd64; + private static string _versionString; + private static WindowsVersion _windowsVersion; + + private static ProcessAccess _minProcessQueryInfoAccess = ProcessAccess.QueryInformation; + private static ThreadAccess _minThreadQueryInfoAccess = ThreadAccess.QueryInformation; + private static ThreadAccess _minThreadSetInfoAccess = ThreadAccess.SetInformation; + + private static bool _hasCycleTime = false; + private static bool _hasExtendedTaskbar = false; + private static bool _hasIoPriority = false; + private static bool _hasPagePriority = false; + private static bool _hasProtectedProcesses = false; + private static bool _hasPsSuspendResumeProcess = false; + private static bool _hasQueryLimitedInformation = false; + private static bool _hasSetAccessToken = false; + private static bool _hasTaskDialogs = false; + private static bool _hasThemes = false; + private static bool _hasUac = false; + private static bool _hasWin32ImageFileName = false; static OSVersion() { - Version version = Environment.OSVersion.Version; + System.Version version = Environment.OSVersion.Version; if (version.Major == 5 && version.Minor == 0) _windowsVersion = WindowsVersion.TwoThousand; @@ -107,9 +102,7 @@ static OSVersion() else if (version.Major == 6 && version.Minor == 0) _windowsVersion = WindowsVersion.Vista; else if (version.Major == 6 && version.Minor == 1) - _windowsVersion = WindowsVersion.Seven; - else if (version.Major == 6 && version.Minor == 2) - _windowsVersion = WindowsVersion.Eight; + _windowsVersion = WindowsVersion.Seven; else _windowsVersion = WindowsVersion.Unknown; @@ -263,22 +256,22 @@ public static bool IsI386() public static bool IsAbove(WindowsVersion version) { - return _windowsVersion > version; + return (int)_windowsVersion > (int)version; } public static bool IsAboveOrEqual(WindowsVersion version) { - return _windowsVersion >= version; + return (int)_windowsVersion >= (int)version; } public static bool IsBelowOrEqual(WindowsVersion version) { - return _windowsVersion <= version; + return (int)_windowsVersion <= (int)version; } public static bool IsBelow(WindowsVersion version) { - return _windowsVersion < version; + return (int)_windowsVersion < (int)version; } public static bool IsEqualTo(WindowsVersion version) diff --git a/1.x/trunk/ProcessHacker.Native/Objects/DebugObjectHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/DebugObjectHandle.cs index 2416e0e13..879022ff9 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/DebugObjectHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/DebugObjectHandle.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -40,17 +42,19 @@ public static DebugObjectHandle Create(DebugObjectAccess access, string name, De public static DebugObjectHandle Create(DebugObjectAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, DebugObjectFlags flags) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateDebugObject( + if ((status = Win32.NtCreateDebugObject( out handle, access, ref oa, flags - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -80,26 +84,31 @@ public DebugObjectHandle(ProcessHandle processHandle) public void Continue(ClientId cid, NtStatus continueStatus) { - Win32.NtDebugContinue( + NtStatus status; + + if ((status = Win32.NtDebugContinue( this, ref cid, continueStatus - ).ThrowIf(); + )) > NtStatus.Error) + Win32.Throw(status); } public void SetFlags(DebugObjectFlags flags) { unsafe { + NtStatus status; int retLength; - Win32.NtSetInformationDebugObject( + if ((status = Win32.NtSetInformationDebugObject( this, DebugObjectInformationClass.DebugObjectFlags, new IntPtr(&flags), sizeof(DebugObjectFlags), out retLength - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } @@ -111,12 +120,13 @@ public IntPtr WaitForDebugEvent(bool alertable, long timeout, bool timeoutRelati //NtStatus status; //long realTimeout = timeoutRelative ? -timeout : timeout; - //Win32.NtWaitForDebugEvent( + //if ((status = Win32.NtWaitForDebugEvent( // this, // alertable, // ref realTimeout, // IntPtr.Zero - // ).ThrowIf(); + // )) >= NtStatus.Error) + // Win32.ThrowLastError(status); //return IntPtr.Zero; } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/DesktopHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/DesktopHandle.cs index 25a22dd99..9c95d819c 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/DesktopHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/DesktopHandle.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; diff --git a/1.x/trunk/ProcessHacker.Native/Objects/DirectoryHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/DirectoryHandle.cs index 0bb2a5f87..b6ed60e0b 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/DirectoryHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/DirectoryHandle.cs @@ -36,8 +36,8 @@ public class DirectoryHandle : NativeHandle public struct ObjectEntry { - private readonly string _name; - private readonly string _typeName; + private string _name; + private string _typeName; public ObjectEntry(string name, string typeName) { @@ -56,12 +56,14 @@ public static DirectoryHandle Create(DirectoryAccess access, string name) public static DirectoryHandle Create(DirectoryAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateDirectoryObject(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtCreateDirectoryObject(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -84,12 +86,21 @@ public DirectoryHandle(string name, DirectoryAccess access) public DirectoryHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, DirectoryAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenDirectoryObject(out handle, access, ref oa).ThrowIf(); + if (KProcessHacker.Instance != null) + { + handle = KProcessHacker.Instance.KphOpenDirectoryObject(access, oa).ToIntPtr(); + } + else + { + if ((status = Win32.NtOpenDirectoryObject(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); + } } finally { @@ -122,7 +133,7 @@ out retLength { // Check if we have at least one entry. If not, // we need to double the buffer size and try again. - if (data.ReadStruct(0, ObjectDirectoryInformation.SizeOf, 0).Name.Buffer != IntPtr.Zero) + if (data.ReadStruct(0).Name.Buffer != IntPtr.Zero) break; if (data.Size > 16 * 1024 * 1024) @@ -131,18 +142,19 @@ out retLength data.ResizeNew(data.Size * 2); } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); int i = 0; while (true) { - ObjectDirectoryInformation info = data.ReadStruct(0, ObjectDirectoryInformation.SizeOf, i); + ObjectDirectoryInformation info = data.ReadStruct(i); if (info.Name.Buffer == IntPtr.Zero) break; - if (!callback(new ObjectEntry(info.Name.Text, info.TypeName.Text))) + if (!callback(new ObjectEntry(info.Name.Read(), info.TypeName.Read()))) return; i++; @@ -164,7 +176,7 @@ public ObjectEntry[] GetObjects() { var objects = new List(); - this.EnumObjects(obj => + this.EnumObjects((obj) => { objects.Add(obj); return true; diff --git a/1.x/trunk/ProcessHacker.Native/Objects/DriverHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/DriverHandle.cs index 2e63b5571..ffff7d53d 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/DriverHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/DriverHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; namespace ProcessHacker.Native.Objects @@ -37,7 +38,7 @@ public DriverHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDi try { - this.Handle = IntPtr.Zero;// KProcessHacker.Instance.KphOpenDriver(oa).ToIntPtr(); + this.Handle = KProcessHacker.Instance.KphOpenDriver(oa).ToIntPtr(); } finally { @@ -45,63 +46,66 @@ public DriverHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDi } } - public string DriverName + public DriverBasicInformation GetBasicInformation() { - get { return this.GetInformationUnicodeString(DriverInformationClass.DriverNameInformation); } - } - - public string ServiceKeyName - { - get { return this.GetInformationUnicodeString(DriverInformationClass.DriverServiceKeyNameInformation); } - } - - public unsafe DriverBasicInformation BasicInformation - { - get + unsafe { - DriverBasicInformation basicInfo = new DriverBasicInformation(); + DriverBasicInformation basicInfo; + int retLength; - //KProcessHacker.Instance.KphQueryInformationDriver( - // this, - // DriverInformationClass.DriverBasicInformation, - // new IntPtr(&basicInfo), - // DriverBasicInformation.SizeOf, - // out retLength - // ); + KProcessHacker.Instance.KphQueryInformationDriver( + this, + DriverInformationClass.DriverBasicInformation, + new IntPtr(&basicInfo), + Marshal.SizeOf(typeof(DriverBasicInformation)), + out retLength + ); return basicInfo; } } + public string GetDriverName() + { + return this.GetInformationUnicodeString(DriverInformationClass.DriverNameInformation); + } + private string GetInformationUnicodeString(DriverInformationClass infoClass) { using (MemoryAlloc data = new MemoryAlloc(0x1000)) { - //try - //{ - // KProcessHacker.Instance.KphQueryInformationDriver( - // this, - // infoClass, - // data, - // data.Size, - // out retLength - // ); - //} - //catch (WindowsException) - //{ - // data.ResizeNew(retLength); + int retLength = 0; + + try + { + KProcessHacker.Instance.KphQueryInformationDriver( + this, + infoClass, + data, + data.Size, + out retLength + ); + } + catch (WindowsException) + { + data.ResizeNew(retLength); - // KProcessHacker.Instance.KphQueryInformationDriver( - // this, - // infoClass, - // data, - // data.Size, - // out retLength - // ); - //} + KProcessHacker.Instance.KphQueryInformationDriver( + this, + infoClass, + data, + data.Size, + out retLength + ); + } - return data.ReadStruct().Text; + return data.ReadStruct().Read(); } } + + public string GetServiceKeyName() + { + return this.GetInformationUnicodeString(DriverInformationClass.DriverServiceKeyNameInformation); + } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/EnlistmentHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/EnlistmentHandle.cs index 6a95d8c23..69eb2042f 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/EnlistmentHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/EnlistmentHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -40,12 +41,13 @@ public static EnlistmentHandle Create( IntPtr enlistmentKey ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateEnlistment( + if ((status = Win32.NtCreateEnlistment( out handle, access, resourceManagerHandle, @@ -54,7 +56,8 @@ IntPtr enlistmentKey createOptions, notificationMask, enlistmentKey - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -82,18 +85,20 @@ public EnlistmentHandle( EnlistmentAccess access ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenEnlistment( + if ((status = Win32.NtOpenEnlistment( out handle, access, resourceManagerHandle, ref guid, ref oa - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -105,76 +110,108 @@ ref oa public void Commit(long virtualClock) { - Win32.NtCommitEnlistment(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtCommitEnlistment(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void CommitComplete(long virtualClock) { - Win32.NtCommitComplete(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtCommitComplete(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } - public EnlistmentBasicInformation BasicInformation + public EnlistmentBasicInformation GetBasicInformation() { - get - { - EnlistmentBasicInformation basicInfo; - int retLength; - - Win32.NtQueryInformationEnlistment( - this, - EnlistmentInformationClass.EnlistmentBasicInformation, - out basicInfo, - EnlistmentBasicInformation.SizeOf, - out retLength - ).ThrowIf(); - - return basicInfo; - } + NtStatus status; + EnlistmentBasicInformation basicInfo; + int retLength; + + if ((status = Win32.NtQueryInformationEnlistment( + this, + EnlistmentInformationClass.EnlistmentBasicInformation, + out basicInfo, + Marshal.SizeOf(typeof(EnlistmentBasicInformation)), + out retLength + )) >= NtStatus.Error) + Win32.Throw(status); + + return basicInfo; } public void Prepare(long virtualClock) { - Win32.NtPrepareEnlistment(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtPrepareEnlistment(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void PrepareComplete(long virtualClock) { - Win32.NtPrepareComplete(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtPrepareComplete(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void PrePrepare(long virtualClock) { - Win32.NtPrePrepareEnlistment(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtPrePrepareEnlistment(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void PrePrepareComplete(long virtualClock) { - Win32.NtPrePrepareComplete(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtPrePrepareComplete(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void ReadOnly(long virtualClock) { - Win32.NtReadOnlyEnlistment(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtReadOnlyEnlistment(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void Recover(IntPtr enlistmentKey) { - Win32.NtRecoverEnlistment(this, enlistmentKey).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRecoverEnlistment(this, enlistmentKey)) >= NtStatus.Error) + Win32.Throw(status); } public void RejectSinglePhase(long virtualClock) { - Win32.NtSinglePhaseReject(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtSinglePhaseReject(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void Rollback(long virtualClock) { - Win32.NtRollbackEnlistment(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRollbackEnlistment(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } public void RollbackComplete(long virtualClock) { - Win32.NtRollbackComplete(this, ref virtualClock).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRollbackComplete(this, ref virtualClock)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/EnvironmentBlock.cs b/1.x/trunk/ProcessHacker.Native/Objects/EnvironmentBlock.cs index 68dc0a107..6c5434bfe 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/EnvironmentBlock.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/EnvironmentBlock.cs @@ -1,5 +1,9 @@ using System; +using System.Collections.Generic; +using System.Text; +using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; +using System.Runtime.InteropServices; namespace ProcessHacker.Native.Objects { @@ -12,9 +16,12 @@ public static EnvironmentBlock Zero get { return _zero; } } - public unsafe static EnvironmentBlock GetCurrent() + public static EnvironmentBlock GetCurrent() { - return new EnvironmentBlock(ProcessHandle.GetCurrentProcessParameters()->Environment); + unsafe + { + return new EnvironmentBlock(ProcessHandle.GetCurrentProcessParameters()->Environment); + } } public static string GetCurrentVariable(string name) @@ -24,32 +31,46 @@ public static string GetCurrentVariable(string name) public static EnvironmentBlock SetCurrent(EnvironmentBlock environmentBlock) { + NtStatus status; IntPtr previousEnvironment; - Win32.RtlSetCurrentEnvironment( + if ((status = Win32.RtlSetCurrentEnvironment( environmentBlock, out previousEnvironment - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new EnvironmentBlock(previousEnvironment); } public static void SetCurrentVariable(string name, string value) { - UnicodeString nameStr = new UnicodeString(name); - UnicodeString valueStr = new UnicodeString(value); + NtStatus status; + UnicodeString nameStr; + UnicodeString valueStr; + + nameStr = new UnicodeString(name); try { - Win32.RtlSetEnvironmentVariable( - IntPtr.Zero, - ref nameStr, - ref valueStr - ).ThrowIf(); + valueStr = new UnicodeString(value); + + try + { + if ((status = Win32.RtlSetEnvironmentVariable( + IntPtr.Zero, + ref nameStr, + ref valueStr + )) >= NtStatus.Error) + Win32.Throw(status); + } + finally + { + valueStr.Dispose(); + } } finally { - valueStr.Dispose(); nameStr.Dispose(); } } @@ -63,10 +84,13 @@ public static implicit operator IntPtr(EnvironmentBlock environmentBlock) public EnvironmentBlock(bool cloneCurrent) { - Win32.RtlCreateEnvironment( + NtStatus status; + + if ((status = Win32.RtlCreateEnvironment( cloneCurrent, out _environment - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public EnvironmentBlock(TokenHandle tokenHandle) @@ -90,41 +114,36 @@ public void Destroy() Win32.RtlDestroyEnvironment(this); } - public unsafe int Length + public unsafe int GetLength() { - get - { - short* ptr = (short*)_environment; + short* ptr = (short*)_environment; - while (*ptr != 0) - { - while (*ptr++ != 0) - { + while (*ptr != 0) + while (*ptr++ != 0) + ; - } - } + ptr++; - ptr++; - - return (new IntPtr(ptr)).Decrement(_environment).ToInt32(); - } + return (new IntPtr(ptr)).Decrement(_environment).ToInt32(); } public string GetVariable(string name) { - UnicodeString nameStr = new UnicodeString(name); + NtStatus status; + UnicodeString nameStr; + UnicodeString valueStr; + + nameStr = new UnicodeString(name); try { - using (MemoryAlloc data = new MemoryAlloc(100)) + using (var data = new MemoryAlloc(100)) { - UnicodeString valueStr = new UnicodeString - { - Buffer = data, - MaximumLength = (ushort)data.Size - }; + valueStr = new UnicodeString(); + valueStr.Buffer = data; + valueStr.MaximumLength = (ushort)data.Size; - NtStatus status = Win32.RtlQueryEnvironmentVariable_U( + status = Win32.RtlQueryEnvironmentVariable_U( this, ref nameStr, ref valueStr @@ -144,9 +163,10 @@ ref valueStr ); } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); - return valueStr.Text; + return valueStr.Read(); } } finally @@ -157,22 +177,33 @@ ref valueStr public void SetVariable(string name, string value) { + NtStatus status; IntPtr environment = _environment; + UnicodeString nameStr; + UnicodeString valueStr; - UnicodeString nameStr = new UnicodeString(name); - UnicodeString valueStr = new UnicodeString(value); + nameStr = new UnicodeString(name); try { - Win32.RtlSetEnvironmentVariable( - ref environment, - ref nameStr, - ref valueStr - ).ThrowIf(); + valueStr = new UnicodeString(value); + + try + { + if ((status = Win32.RtlSetEnvironmentVariable( + ref environment, + ref nameStr, + ref valueStr + )) >= NtStatus.Error) + Win32.Throw(status); + } + finally + { + valueStr.Dispose(); + } } finally { - valueStr.Dispose(); nameStr.Dispose(); } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/EventHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/EventHandle.cs index c332abfc9..5c6c7c8c4 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/EventHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/EventHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -40,12 +41,14 @@ public static EventHandle Create(EventAccess access, string name, EventType type public static EventHandle Create(EventAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, EventType type, bool initialState) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateEvent(out handle, access, ref oa, type, initialState).ThrowIf(); + if ((status = Win32.NtCreateEvent(out handle, access, ref oa, type, initialState)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -70,12 +73,14 @@ public EventHandle(string name, EventAccess access) public EventHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, EventAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenEvent(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenEvent(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -87,51 +92,54 @@ public EventHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDir public void Clear() { - Win32.NtClearEvent(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtClearEvent(this)) >= NtStatus.Error) + Win32.Throw(status); } - public EventBasicInformation BasicInformation + public EventBasicInformation GetBasicInformation() { - get - { - EventBasicInformation ebi; - int retLength; - - Win32.NtQueryEvent( - this, - EventInformationClass.EventBasicInformation, - out ebi, - EventBasicInformation.SizeOf, - out retLength - ).ThrowIf(); - - return ebi; - } + NtStatus status; + EventBasicInformation ebi; + int retLength; + + if ((status = Win32.NtQueryEvent(this, EventInformationClass.EventBasicInformation, + out ebi, Marshal.SizeOf(typeof(EventBasicInformation)), out retLength)) >= NtStatus.Error) + Win32.Throw(status); + + return ebi; } public int Pulse() { + NtStatus status; int previousState; - Win32.NtPulseEvent(this, out previousState).ThrowIf(); + if ((status = Win32.NtPulseEvent(this, out previousState)) >= NtStatus.Error) + Win32.Throw(status); return previousState; } public int Reset() { + NtStatus status; int previousState; - Win32.NtResetEvent(this, out previousState).ThrowIf(); + if ((status = Win32.NtResetEvent(this, out previousState)) >= NtStatus.Error) + Win32.Throw(status); return previousState; } public int Set() { + NtStatus status; int previousState; - Win32.NtSetEvent(this, out previousState).ThrowIf(); + if ((status = Win32.NtSetEvent(this, out previousState)) >= NtStatus.Error) + Win32.Throw(status); return previousState; } @@ -142,7 +150,10 @@ public int Set() /// public void SetBoostPriority() { - Win32.NtSetEventBoostPriority(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtSetEventBoostPriority(this)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/EventPairHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/EventPairHandle.cs index 23d923147..f562dc5e4 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/EventPairHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/EventPairHandle.cs @@ -56,12 +56,14 @@ public static EventPairHandle Create(EventPairAccess access) /// A handle to an event pair. public static EventPairHandle Create(EventPairAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateEventPair(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtCreateEventPair(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -91,12 +93,14 @@ private EventPairHandle(IntPtr handle, bool owned) /// The desired access to the event pair. public EventPairHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, EventPairAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenEventPair(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenEventPair(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -115,7 +119,10 @@ public EventPairHandle(string name, EventPairAccess access) /// public void SetHigh() { - Win32.NtSetHighEventPair(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtSetHighEventPair(this)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -123,7 +130,12 @@ public void SetHigh() /// public NtStatus SetHighWaitLow() { - return Win32.NtSetHighWaitLowEventPair(this); + NtStatus status; + + if ((status = Win32.NtSetHighWaitLowEventPair(this)) >= NtStatus.Error) + Win32.Throw(status); + + return status; } /// @@ -131,7 +143,10 @@ public NtStatus SetHighWaitLow() /// public void SetLow() { - Win32.NtSetLowEventPair(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtSetLowEventPair(this)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -139,7 +154,12 @@ public void SetLow() /// public NtStatus SetLowWaitHigh() { - return Win32.NtSetLowWaitHighEventPair(this); + NtStatus status; + + if ((status = Win32.NtSetLowWaitHighEventPair(this)) >= NtStatus.Error) + Win32.Throw(status); + + return status; } /// @@ -147,7 +167,12 @@ public NtStatus SetLowWaitHigh() /// public NtStatus WaitHigh() { - return Win32.NtWaitHighEventPair(this); + NtStatus status; + + if ((status = Win32.NtWaitHighEventPair(this)) >= NtStatus.Error) + Win32.Throw(status); + + return status; } /// @@ -155,7 +180,12 @@ public NtStatus WaitHigh() /// public NtStatus WaitLow() { - return Win32.NtWaitLowEventPair(this); + NtStatus status; + + if ((status = Win32.NtWaitLowEventPair(this)) >= NtStatus.Error) + Win32.Throw(status); + + return status; } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/FileHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/FileHandle.cs index 460b988aa..43d833d12 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/FileHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/FileHandle.cs @@ -126,13 +126,14 @@ public static FileHandle Create( out FileIoStatus ioStatus ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory); IoStatusBlock isb; IntPtr handle; try { - Win32.NtCreateFile( + if ((status = Win32.NtCreateFile( out handle, access, ref oa, @@ -144,7 +145,8 @@ out FileIoStatus ioStatus createOptions, IntPtr.Zero, 0 - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); ioStatus = (FileIoStatus)isb.Information.ToInt32(); } @@ -166,11 +168,14 @@ public static FileHandle CreateWin32(string fileName, FileAccess desiredAccess, return CreateWin32(fileName, desiredAccess, shareMode, FileCreationDispositionWin32.OpenAlways); } - public static FileHandle CreateWin32(string fileName, FileAccess desiredAccess, FileShareMode shareMode, FileCreationDispositionWin32 creationDisposition) + public static FileHandle CreateWin32(string fileName, FileAccess desiredAccess, FileShareMode shareMode, + FileCreationDispositionWin32 creationDisposition) { - IntPtr handle = Win32.CreateFile(fileName, desiredAccess, shareMode, 0, creationDisposition, 0, IntPtr.Zero); + IntPtr handle; + + handle = Win32.CreateFile(fileName, desiredAccess, shareMode, 0, creationDisposition, 0, IntPtr.Zero); - if (handle != MinusOne) + if (handle == NativeHandle.MinusOne) Win32.Throw(); return new FileHandle(handle, true); @@ -178,11 +183,13 @@ public static FileHandle CreateWin32(string fileName, FileAccess desiredAccess, public static void Delete(string fileName, ObjectFlags objectFlags) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, null); try { - Win32.NtDeleteFile(ref oa).ThrowIf(); + if ((status = Win32.NtDeleteFile(ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -257,20 +264,22 @@ public FileHandle( FileAccess access ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory); IoStatusBlock isb; IntPtr handle; try { - Win32.NtOpenFile( + if ((status = Win32.NtOpenFile( out handle, access, ref oa, out isb, shareMode, openOptions - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -474,9 +483,11 @@ public void BeginLock(AsyncIoContext asyncContext, long offset, long length, boo public void BeginLock(AsyncIoContext asyncContext, long offset, long length, bool wait, bool exclusive) { + NtStatus status; + asyncContext.NotifyPreBegin(); - NtStatus status = Win32.NtLockFile( + status = Win32.NtLockFile( this, asyncContext.EventHandle ?? IntPtr.Zero, null, @@ -506,13 +517,14 @@ public void BeginRead(AsyncIoContext asyncContext, long fileOffset, byte[] buffe public void BeginRead(AsyncIoContext asyncContext, long fileOffset, byte[] buffer, int offset, int length) { - Utils.ValidateBuffer(buffer, offset, length); + PinnedObject pinnedBuffer; + Utils.ValidateBuffer(buffer, offset, length); asyncContext.NotifyPreBegin(); // Pin the buffer because the I/O system may be writing to it after // this call returns. - PinnedObject pinnedBuffer = new PinnedObject(buffer); + pinnedBuffer = new PinnedObject(buffer); asyncContext.KeepAlive(pinnedBuffer); this.BeginRead(asyncContext, fileOffset, pinnedBuffer.Address.Increment(offset), length); } @@ -560,13 +572,13 @@ public void BeginWrite(AsyncIoContext asyncContext, long fileOffset, byte[] buff public void BeginWrite(AsyncIoContext asyncContext, long fileOffset, byte[] buffer, int offset, int length) { - Utils.ValidateBuffer(buffer, offset, length); + PinnedObject pinnedBuffer; + Utils.ValidateBuffer(buffer, offset, length); asyncContext.NotifyPreBegin(); - PinnedObject pinnedBuffer = new PinnedObject(buffer); + pinnedBuffer = new PinnedObject(buffer); asyncContext.KeepAlive(pinnedBuffer); - this.BeginWrite(asyncContext, fileOffset, pinnedBuffer.Address.Increment(offset), length); } @@ -612,9 +624,11 @@ protected void BeginWrite(AsyncIoContext asyncContext, long fileOffset, IntPtr b /// An I/O status block. public IoStatusBlock CancelIo() { + NtStatus status; IoStatusBlock isb; - Win32.NtCancelIoFile(this, out isb).ThrowIf(); + if ((status = Win32.NtCancelIoFile(this, out isb)) >= NtStatus.Error) + Win32.Throw(status); return isb; } @@ -624,10 +638,10 @@ public IoStatusBlock CancelIo() /// public void Delete() { - this.SetStruct(FileInformationClass.FileDispositionInformation, FileDispositionInformation.SizeOf, new FileDispositionInformation - { - DeleteFile = true - }); + this.SetStruct( + FileInformationClass.FileDispositionInformation, + new FileDispositionInformation() { DeleteFile = true } + ); } /// @@ -640,7 +654,8 @@ protected int EndCommonIo(AsyncIoContext asyncContext) asyncContext.Wait(); asyncContext.NotifyEnd(); - asyncContext.Status.ThrowIf(); + if (asyncContext.Status >= NtStatus.Error) + Win32.Throw(asyncContext.Status); return asyncContext.StatusBlock.Information.ToInt32(); } @@ -678,7 +693,8 @@ public bool EndLock(AsyncIoContext asyncContext) if (asyncContext.Status == NtStatus.LockNotGranted) return false; - asyncContext.Status.ThrowIf(); + if (asyncContext.Status >= NtStatus.Error) + Win32.Throw(asyncContext.Status); return true; } @@ -780,7 +796,8 @@ public void EnumFiles(EnumFilesDelegate callback, string searchPattern) break; // Handle any errors. - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); // Read the list of files we got in this batch. @@ -788,8 +805,7 @@ public void EnumFiles(EnumFilesDelegate callback, string searchPattern) while (true) { - FileDirectoryInformation info = data.ReadStruct(i, FileDirectoryInformation.SizeOf, 0); - + FileDirectoryInformation info = data.ReadStruct(i, 0); string name = data.ReadUnicodeString( i + FileDirectoryInformation.FileNameOffset, info.FileNameLength / 2 @@ -810,8 +826,8 @@ public void EnumFiles(EnumFilesDelegate callback, string searchPattern) if (info.NextEntryOffset == 0) break; - - i += info.NextEntryOffset; + else + i += info.NextEntryOffset; } firstTime = false; @@ -833,13 +849,13 @@ public void EnumFiles(EnumFilesDelegate callback, string searchPattern) /// The callback function to use. public void EnumStreams(EnumStreamsDelegate callback) { - using (MemoryAlloc data = this.QueryVariableSize(FileInformationClass.FileStreamInformation)) + using (var data = this.QueryVariableSize(FileInformationClass.FileStreamInformation)) { int i = 0; while (true) { - FileStreamInformation info = data.ReadStruct(i, FileStreamInformation.SizeOf, 0); + FileStreamInformation info = data.ReadStruct(i, 0); string name = data.ReadUnicodeString( i + FileStreamInformation.StreamNameOffset, info.StreamNameLength / 2 @@ -850,8 +866,8 @@ public void EnumStreams(EnumStreamsDelegate callback) if (info.NextEntryOffset == 0) break; - - i += info.NextEntryOffset; + else + i += info.NextEntryOffset; } } } @@ -861,9 +877,10 @@ public void EnumStreams(EnumStreamsDelegate callback) /// public void Flush() { + NtStatus status; IoStatusBlock isb; - NtStatus status = Win32.NtFlushBuffersFile( + status = Win32.NtFlushBuffersFile( this, out isb ); @@ -874,7 +891,8 @@ out isb status = isb.Status; } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); } /// @@ -945,9 +963,13 @@ public int FsControl( int outBufferLength ) { + NtStatus status; int returnLength; - this.FsControl(controlCode, inBuffer, inBufferLength, outBuffer, outBufferLength, out returnLength).ThrowIf(); + status = this.FsControl(controlCode, inBuffer, inBufferLength, outBuffer, outBufferLength, out returnLength); + + if (status >= NtStatus.Error) + Win32.Throw(status); return returnLength; } @@ -961,9 +983,10 @@ public NtStatus FsControl( out int returnLength ) { + NtStatus status; IoStatusBlock isb; - NtStatus status = Win32.NtFsControlFile( + status = Win32.NtFsControlFile( this, IntPtr.Zero, null, @@ -992,37 +1015,34 @@ out int returnLength /// Gets the attributes of the file. /// /// The attributes of the file. - public FileAttributes Attributes + public FileAttributes GetAttributes() { - get { return this.BasicInformation.FileAttributes; } + return this.GetBasicInformation().FileAttributes; } /// /// Gets basic information about the file. /// /// Basic information about the file. - public FileBasicInformation BasicInformation + public FileBasicInformation GetBasicInformation() { - get { return this.QueryStruct(FileInformationClass.FileBasicInformation, FileBasicInformation.SizeOf); } + return this.QueryStruct(FileInformationClass.FileBasicInformation); } /// /// Gets the partial name of the file. /// /// The name of the file, relative to its volume. - public string FileName + public string GetFileName() { - get + using (var data = this.QueryVariableSize(FileInformationClass.FileNameInformation)) { - using (MemoryAlloc data = this.QueryVariableSize(FileInformationClass.FileNameInformation)) - { - FileNameInformation info = data.ReadStruct(0, FileNameInformation.SizeOf, 0); + FileNameInformation info = data.ReadStruct(); - return data.ReadUnicodeString( - FileNameInformation.FileNameOffset, - info.FileNameLength/2 - ); - } + return data.ReadUnicodeString( + FileNameInformation.FileNameOffset, + info.FileNameLength / 2 + ); } } @@ -1030,9 +1050,9 @@ public string FileName /// Gets a list of the files contained in the directory. /// /// An array of file information structures. - public FileEntry[] Files + public FileEntry[] GetFiles() { - get { return this.GetFiles(null); } + return this.GetFiles(null); } /// @@ -1049,7 +1069,7 @@ public FileEntry[] GetFiles(string searchPattern) { List files = new List(); - this.EnumFiles(file => + this.EnumFiles((file) => { files.Add(file); return true; @@ -1062,15 +1082,9 @@ public FileEntry[] GetFiles(string searchPattern) /// Gets the current position. /// /// A byte offset from the beginning of the file. - public long Position + public long GetPosition() { - get - { - return this.QueryStruct( - FileInformationClass.FilePositionInformation, - FilePositionInformation.SizeOf - ).CurrentByteOffset; - } + return this.QueryStruct(FileInformationClass.FilePositionInformation).CurrentByteOffset; } /// @@ -1081,7 +1095,7 @@ public FileStreamEntry[] GetStreams() { List streams = new List(); - this.EnumStreams(file => + this.EnumStreams((file) => { streams.Add(file); return true; @@ -1094,53 +1108,46 @@ public FileStreamEntry[] GetStreams() /// Gets the size of the file. /// /// The size of the file. - public long FileSize + public long GetSize() { - get { return this.StandardInformation.EndOfFile; } + return this.GetStandardInformation().EndOfFile; } /// /// Gets standard information about the file. /// /// Standard information about the file. - public FileStandardInformation StandardInformation - { - get - { - return this.QueryStruct( - FileInformationClass.FileStandardInformation, - FileStandardInformation.SizeOf - ); - } + public FileStandardInformation GetStandardInformation() + { + return this.QueryStruct(FileInformationClass.FileStandardInformation); } /// /// Gets the file system name of the file's associated volume. /// /// The volume's file system name. - public string VolumeFsName + public string GetVolumeFsName() { - get + NtStatus status; + IoStatusBlock isb; + + using (var data = new MemoryAlloc(0x200)) { - IoStatusBlock isb; + if ((status = Win32.NtQueryVolumeInformationFile( + this, + out isb, + data, + data.Size, + FsInformationClass.FileFsAttributeInformation + )) >= NtStatus.Error) + Win32.Throw(status); - using (MemoryAlloc data = new MemoryAlloc(0x200)) - { - Win32.NtQueryVolumeInformationFile( - this, - out isb, - data, - data.Size, - FsInformationClass.FileFsAttributeInformation - ).ThrowIf(); - - FileFsAttributeInformation info = data.ReadStruct(0, FileFsAttributeInformation.SizeOf, 0); - - return Marshal.PtrToStringUni( - data.Memory.Increment(FileFsAttributeInformation.FileSystemNameOffset), - info.FileSystemNameLength/2 - ); - } + FileFsAttributeInformation info = data.ReadStruct(); + + return Marshal.PtrToStringUni( + data.Memory.Increment(Marshal.OffsetOf(typeof(FileFsAttributeInformation), "FileSystemName")), + info.FileSystemNameLength / 2 + ); } } @@ -1148,29 +1155,28 @@ public string VolumeFsName /// Gets the label of the file's associated volume. /// /// The volume label. - public string VolumeLabel + public string GetVolumeLabel() { - get - { - using (MemoryAlloc data = new MemoryAlloc(0x200)) - { - IoStatusBlock isb; + NtStatus status; + IoStatusBlock isb; - Win32.NtQueryVolumeInformationFile( - this, - out isb, - data, - data.Size, - FsInformationClass.FileFsVolumeInformation - ).ThrowIf(); + using (var data = new MemoryAlloc(0x200)) + { + if ((status = Win32.NtQueryVolumeInformationFile( + this, + out isb, + data, + data.Size, + FsInformationClass.FileFsVolumeInformation + )) >= NtStatus.Error) + Win32.Throw(status); - FileFsVolumeInformation info = data.ReadStruct(); + FileFsVolumeInformation info = data.ReadStruct(); - return Marshal.PtrToStringUni( - data.Memory.Increment(FileFsVolumeInformation.VolumeLabelOffset), - info.VolumeLabelLength/2 - ); - } + return Marshal.PtrToStringUni( + data.Memory.Increment(Marshal.OffsetOf(typeof(FileFsVolumeInformation), "VolumeLabel")), + info.VolumeLabelLength / 2 + ); } } @@ -1261,9 +1267,13 @@ public int IoControl( int outBufferLength ) { + NtStatus status; int returnLength; - this.IoControl(controlCode, inBuffer, inBufferLength, outBuffer, outBufferLength, out returnLength).ThrowIf(); + status = this.IoControl(controlCode, inBuffer, inBufferLength, outBuffer, outBufferLength, out returnLength); + + if (status >= NtStatus.Error) + Win32.Throw(status); return returnLength; } @@ -1277,9 +1287,10 @@ public NtStatus IoControl( out int returnLength ) { + NtStatus status; IoStatusBlock isb; - NtStatus status = Win32.NtDeviceIoControlFile( + status = Win32.NtDeviceIoControlFile( this, IntPtr.Zero, null, @@ -1345,9 +1356,10 @@ public bool Lock(long offset, long length, bool wait) /// True if the lock was acquired, otherwise false. public bool Lock(long offset, long length, bool wait, bool exclusive) { + NtStatus status; IoStatusBlock isb; - NtStatus status = Win32.NtLockFile( + status = Win32.NtLockFile( this, IntPtr.Zero, null, @@ -1369,26 +1381,30 @@ public bool Lock(long offset, long length, bool wait, bool exclusive) if (status == NtStatus.LockNotGranted) return false; - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return true; } - protected T QueryStruct(FileInformationClass infoClass, int size) where T : struct + protected T QueryStruct(FileInformationClass infoClass) + where T : struct { - using (MemoryAlloc data = new MemoryAlloc(size)) + NtStatus status; + IoStatusBlock isb; + + using (var data = new MemoryAlloc(Marshal.SizeOf(typeof(T)))) { - IoStatusBlock isb; - - Win32.NtQueryInformationFile( + if ((status = Win32.NtQueryInformationFile( this, out isb, data, data.Size, infoClass - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); - return data.ReadStruct(0, size, 0); + return data.ReadStruct(); } } @@ -1396,7 +1412,7 @@ protected MemoryAlloc QueryVariableSize(FileInformationClass infoClass) { NtStatus status; IoStatusBlock isb; - MemoryAlloc data = new MemoryAlloc(0x200); + var data = new MemoryAlloc(0x200); while (true) { @@ -1418,7 +1434,7 @@ protected MemoryAlloc QueryVariableSize(FileInformationClass infoClass) break; } - if (status.IsError()) + if (status >= NtStatus.Error) { data.Dispose(); Win32.Throw(status); @@ -1560,7 +1576,8 @@ public int Read(long fileOffset, IntPtr buffer, int length) status = isb.Status; } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return isb.Information.ToInt32(); } @@ -1571,10 +1588,10 @@ public int Read(long fileOffset, IntPtr buffer, int length) /// A byte offset from the beginning of the file. public void SetEnd(long offset) { - this.SetStruct(FileInformationClass.FileEndOfFileInformation, FileEndOfFileInformation.SizeOf, new FileEndOfFileInformation - { - EndOfFile = offset - }); + this.SetStruct( + FileInformationClass.FileEndOfFileInformation, + new FileEndOfFileInformation() { EndOfFile = offset } + ); } /// @@ -1602,13 +1619,11 @@ public void SetIoCompletion(IoCompletionHandle ioCompletionHandle) /// A key to associate with the file object. public void SetIoCompletion(IoCompletionHandle ioCompletionHandle, IntPtr keyContext) { - FileCompletionInformation info = new FileCompletionInformation - { - Port = ioCompletionHandle, - Key = keyContext - }; + FileCompletionInformation info = new FileCompletionInformation(); - this.SetStruct(FileInformationClass.FileCompletionInformation, FileCompletionInformation.SizeOf, info); + info.Port = ioCompletionHandle; + info.Key = keyContext; + this.SetStruct(FileInformationClass.FileCompletionInformation, info); } /// @@ -1617,10 +1632,10 @@ public void SetIoCompletion(IoCompletionHandle ioCompletionHandle, IntPtr keyCon /// A byte offset from the beginning of the file. public void SetPosition(long offset) { - this.SetStruct(FileInformationClass.FilePositionInformation, FilePositionInformation.SizeOf, new FilePositionInformation - { - CurrentByteOffset = offset - }); + this.SetStruct( + FileInformationClass.FilePositionInformation, + new FilePositionInformation() { CurrentByteOffset = offset } + ); } /// @@ -1632,7 +1647,7 @@ public long SetPosition(long offset, PositionOrigin origin) { long currentPosition; - currentPosition = this.Position; + currentPosition = this.GetPosition(); switch (origin) { @@ -1643,7 +1658,7 @@ public long SetPosition(long offset, PositionOrigin origin) currentPosition = offset; break; case PositionOrigin.End: - currentPosition = this.FileSize + offset; + currentPosition = this.GetSize() + offset; break; } @@ -1652,21 +1667,24 @@ public long SetPosition(long offset, PositionOrigin origin) return currentPosition; } - protected void SetStruct(FileInformationClass infoClass, int size, T info) where T : struct + protected void SetStruct(FileInformationClass infoClass, T info) + where T : struct { - using (MemoryAlloc data = new MemoryAlloc(size)) - { - data.WriteStruct(info); + NtStatus status; + IoStatusBlock isb; - IoStatusBlock isb; + using (var data = new MemoryAlloc(Marshal.SizeOf(typeof(T)))) + { + data.WriteStruct(info); - Win32.NtSetInformationFile( + if ((status = Win32.NtSetInformationFile( this, out isb, data, data.Size, infoClass - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } @@ -1677,15 +1695,19 @@ protected void SetStruct(FileInformationClass infoClass, int size, T info) wh /// The length of the byte range. public void Unlock(long offset, long length) { + NtStatus status; IoStatusBlock isb; - Win32.NtUnlockFile( + status = Win32.NtUnlockFile( this, out isb, ref offset, ref length, 0 - ).ThrowIf(); + ); + + if (status >= NtStatus.Error) + Win32.Throw(status); } /// @@ -1807,7 +1829,8 @@ public int Write(long fileOffset, IntPtr buffer, int length) status = isb.Status; } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return isb.Information.ToInt32(); } @@ -1828,7 +1851,7 @@ public enum PositionOrigin public sealed class AsyncIoCompletionPort : IDisposable { - private readonly IoCompletionHandle _ioCompletionHandle; + private IoCompletionHandle _ioCompletionHandle; public AsyncIoCompletionPort() : this(0) @@ -1856,17 +1879,19 @@ public AsyncIoContext Remove() public AsyncIoContext Remove(long timeout, bool relative) { + bool result; + AsyncIoContext asyncContext; IoStatusBlock isb; IntPtr keyContext; IntPtr apcContext; - bool result = this._ioCompletionHandle.Remove(out isb, out keyContext, out apcContext, relative ? -timeout : timeout, false); + result = _ioCompletionHandle.Remove(out isb, out keyContext, out apcContext, relative ? -timeout : timeout, false); // Fail? if (!result) return null; - AsyncIoContext asyncContext = AsyncIoContext.GetAsyncIoContext(apcContext); + asyncContext = AsyncIoContext.GetAsyncIoContext(apcContext); asyncContext.NotifyEnd(); return asyncContext; @@ -1885,17 +1910,19 @@ public sealed class AsyncIoContext : BaseObject, ISynchronizable { private unsafe sealed class UnmanagedIsb : BaseObject { + private static readonly int _isbSize = Marshal.SizeOf(typeof(IoStatusBlock)); + public static implicit operator IntPtr(UnmanagedIsb isb) { return isb.Memory; } - private readonly IoStatusBlock* _ioStatusBlock; + private IoStatusBlock* _ioStatusBlock; public UnmanagedIsb() { // Allocate an ISB. - _ioStatusBlock = (IoStatusBlock*)MemoryAlloc.PrivateHeap.Allocate(IoStatusBlock.SizeOf); + _ioStatusBlock = (IoStatusBlock*)MemoryAlloc.PrivateHeap.Allocate(0, _isbSize); // Zero the ISB. _ioStatusBlock->Pointer = IntPtr.Zero; _ioStatusBlock->Information = IntPtr.Zero; @@ -1905,7 +1932,7 @@ public UnmanagedIsb() protected override void DisposeObject(bool disposing) { if (_ioStatusBlock != null) - MemoryAlloc.PrivateHeap.Free(new IntPtr(_ioStatusBlock)); + MemoryAlloc.PrivateHeap.Free(0, new IntPtr(_ioStatusBlock)); } public IntPtr Information @@ -1944,12 +1971,12 @@ public static AsyncIoContext GetAsyncIoContext(IntPtr context) } private IntPtr _context = IntPtr.Zero; - private readonly EventHandle _eventHandle; - private readonly UnmanagedIsb _isb; - private bool _completedSynchronously; - private bool _started; + private EventHandle _eventHandle = null; + private UnmanagedIsb _isb; + private bool _completedSynchronously = false; + private bool _started = false; - private List _keepAliveList; + private List _keepAliveList = null; private object _tag; public AsyncIoContext() @@ -1958,10 +1985,8 @@ public AsyncIoContext() public AsyncIoContext(AsyncIoMethod method) { - _isb = new UnmanagedIsb - { - Status = NtStatus.Pending - }; + _isb = new UnmanagedIsb(); + _isb.Status = NtStatus.Pending; if (method == AsyncIoMethod.Event) { @@ -1990,16 +2015,6 @@ protected override void DisposeObject(bool disposing) _eventHandle.Dispose(); if (_isb != null) _isb.Dispose(); - - if (_context != IntPtr.Zero) - { - GCHandle handle = GCHandle.FromIntPtr(_context); - - if (handle.IsAllocated) - handle.Free(); - - _context = IntPtr.Zero; - } } public bool Cancelled diff --git a/1.x/trunk/ProcessHacker.Native/Objects/IoCompletionHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/IoCompletionHandle.cs index 943b5a341..e71db55b9 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/IoCompletionHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/IoCompletionHandle.cs @@ -21,7 +21,10 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; +using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; namespace ProcessHacker.Native.Objects @@ -45,12 +48,14 @@ public static IoCompletionHandle Create(IoCompletionAccess access, string name, public static IoCompletionHandle Create(IoCompletionAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, int count) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateIoCompletion(out handle, access, ref oa, count).ThrowIf(); + if ((status = Win32.NtCreateIoCompletion(out handle, access, ref oa, count)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -66,12 +71,14 @@ private IoCompletionHandle(IntPtr handle, bool owned) public IoCompletionHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, IoCompletionAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenIoCompletion(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenIoCompletion(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -92,20 +99,23 @@ public bool Remove(out IoStatusBlock isb, out IntPtr keyContext, out IntPtr apcC public bool Remove(out IoStatusBlock isb, out IntPtr keyContext, out IntPtr apcContext, long timeout, bool relative) { + NtStatus status; long realTimeout = relative ? -timeout : timeout; - return Win32.NtRemoveIoCompletion(this, out keyContext, out apcContext, out isb, ref realTimeout) != NtStatus.Timeout; + if ((status = Win32.NtRemoveIoCompletion( + this, out keyContext, out apcContext, out isb, ref realTimeout)) >= NtStatus.Error) + Win32.Throw(status); + + return status != NtStatus.Timeout; } public void Set(IntPtr keyContext, IntPtr apcContext, NtStatus ioStatus, IntPtr ioInformation) { - Win32.NtSetIoCompletion( - this, - keyContext, - apcContext, - ioStatus, - ioInformation - ).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtSetIoCompletion( + this, keyContext, apcContext, ioStatus, ioInformation)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/JobObjectHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/JobObjectHandle.cs index 43f2d1df3..9d4f242ee 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/JobObjectHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/JobObjectHandle.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -44,16 +45,18 @@ public static JobObjectHandle Create(JobObjectAccess access, string name) public static JobObjectHandle Create(JobObjectAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateJobObject( + if ((status = Win32.NtCreateJobObject( out handle, access, ref oa - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -67,15 +70,17 @@ internal static IntPtr Open(ProcessHandle processHandle, JobObjectAccess access) { try { - return KProcessHacker2.Instance.KphOpenProcessJob(processHandle, (TokenAccess)access); + return new IntPtr(KProcessHacker.Instance.KphOpenProcessJob(processHandle, access)); } catch (WindowsException) { + IntPtr handle; + // Use KPH to set the handle's granted access. - IntPtr handle = KProcessHacker2.Instance.KphOpenProcessJob(processHandle, (TokenAccess)StandardRights.Synchronize); - - //if (handle != IntPtr.Zero) - //KProcessHacker2.Instance.KphSetHandleGrantedAccess(handle, (int)access); + handle = new IntPtr(KProcessHacker.Instance.KphOpenProcessJob(processHandle, + (JobObjectAccess)StandardRights.Synchronize)); + if (handle != IntPtr.Zero) + KProcessHacker.Instance.KphSetHandleGrantedAccess(handle, (int)access); return handle; } @@ -102,16 +107,18 @@ public JobObjectHandle(string name, JobObjectAccess access) public JobObjectHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, JobObjectAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenJobObject( + if ((status = Win32.NtOpenJobObject( out handle, access, ref oa - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -138,80 +145,80 @@ public JobObjectHandle(ProcessHandle processHandle, JobObjectAccess access) } } + private T QueryStruct(JobObjectInformationClass informationClass) + where T : struct + { + int retLength; + + using (MemoryAlloc data = new MemoryAlloc(Marshal.SizeOf(typeof(T)))) + { + if (!Win32.QueryInformationJobObject(this, informationClass, data, data.Size, out retLength)) + { + data.ResizeNew(retLength); + + if (!Win32.QueryInformationJobObject(this, informationClass, data, data.Size, out retLength)) + Win32.Throw(); + } + + return data.ReadStruct(); + } + } + public JobObjectBasicAccountingInformation GetBasicAccountingInformation() { return this.QueryStruct( - JobObjectInformationClass.JobObjectBasicAccountingInformation, - JobObjectBasicAccountingInformation.SizeOf - ); + JobObjectInformationClass.JobObjectBasicAccountingInformation); } public JobObjectBasicAndIoAccountingInformation GetBasicAndIoAccountingInformation() { return this.QueryStruct( - JobObjectInformationClass.JobObjectBasicAndIoAccountingInformation, - JobObjectBasicAndIoAccountingInformation.SizeOf - ); + JobObjectInformationClass.JobObjectBasicAndIoAccountingInformation); } - public JobObjectBasicLimitInformation BasicLimitInformation + public JobObjectBasicLimitInformation GetBasicLimitInformation() { - get { return this.QueryStruct( - JobObjectInformationClass.JobObjectBasicLimitInformation, - JobObjectBasicLimitInformation.SizeOf - ); - } + return this.QueryStruct(JobObjectInformationClass.JobObjectBasicLimitInformation); } - public JobObjectBasicUiRestrictions BasicUiRestrictions + public int[] GetProcessIdList() { - get - { - JobObjectBasicUiRestrictions uiRestrictions; - int retLength; + List processIds = new List(); + int retLength; - if (!Win32.QueryInformationJobObject(this, JobObjectInformationClass.JobObjectBasicUIRestrictions, out uiRestrictions, 4, out retLength)) + // FIXME: Fixed buffer + using (MemoryAlloc data = new MemoryAlloc(0x1000)) + { + if (!Win32.QueryInformationJobObject(this, JobObjectInformationClass.JobObjectBasicProcessIdList, + data, data.Size, out retLength)) Win32.Throw(); - return uiRestrictions; - } - } + JobObjectBasicProcessIdList listInfo = data.ReadStruct(); - public JobObjectExtendedLimitInformation ExtendedLimitInformation - { - get - { - return this.QueryStruct( - JobObjectInformationClass.JobObjectExtendedLimitInformation, - JobObjectExtendedLimitInformation.SizeOf - ); + for (int i = 0; i < listInfo.NumberOfProcessIdsInList; i++) + { + processIds.Add(data.ReadInt32(8, i)); + } } + + return processIds.ToArray(); } - public int[] ProcessIdList + public JobObjectBasicUiRestrictions GetBasicUiRestrictions() { - get - { - List processIds = new List(); - int retLength; - - // FIXME: Fixed buffer - using (MemoryAlloc data = new MemoryAlloc(0x1000)) - { - if (!Win32.QueryInformationJobObject(this, JobObjectInformationClass.JobObjectBasicProcessIdList, - data, data.Size, out retLength)) - Win32.Throw(); + JobObjectBasicUiRestrictions uiRestrictions; + int retLength; - JobObjectBasicProcessIdList listInfo = data.ReadStruct(); + if (!Win32.QueryInformationJobObject(this, JobObjectInformationClass.JobObjectBasicUIRestrictions, + out uiRestrictions, 4, out retLength)) + Win32.Throw(); - for (int i = 0; i < listInfo.NumberOfProcessIdsInList; i++) - { - processIds.Add(data.ReadInt32(8, i)); - } - } + return uiRestrictions; + } - return processIds.ToArray(); - } + public JobObjectExtendedLimitInformation GetExtendedLimitInformation() + { + return this.QueryStruct(JobObjectInformationClass.JobObjectExtendedLimitInformation); } public void Terminate() @@ -224,26 +231,5 @@ public void Terminate(int exitCode) if (!Win32.TerminateJobObject(this, exitCode)) Win32.Throw(); } - - private T QueryStruct(JobObjectInformationClass informationClass, int size) where T : struct - { - int retLength; - - using (MemoryAlloc data = new MemoryAlloc(size)) - { - bool ret = Win32.QueryInformationJobObject(this, informationClass, data, data.Size, out retLength); - int res = System.Runtime.InteropServices.Marshal.GetLastWin32Error(); - - if (!Win32.QueryInformationJobObject(this, informationClass, data, data.Size, out retLength)) - { - data.ResizeNew(retLength); - - if (!Win32.QueryInformationJobObject(this, informationClass, data, data.Size, out retLength)) - Win32.Throw(); - } - - return data.ReadStruct(); - } - } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/KeyHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/KeyHandle.cs index 5e8603325..1c075c886 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/KeyHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/KeyHandle.cs @@ -21,6 +21,9 @@ */ using System; +using System.Collections.Generic; +using System.Text; +using ProcessHacker.Native; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -59,12 +62,13 @@ public static KeyHandle Create( out KeyCreationDisposition creationDisposition ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateKey( + if ((status = Win32.NtCreateKey( out handle, access, ref oa, @@ -72,7 +76,8 @@ out KeyCreationDisposition creationDisposition IntPtr.Zero, createOptions, out creationDisposition - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -92,16 +97,18 @@ public KeyHandle(string name, KeyAccess access) public KeyHandle(string name, ObjectFlags objectFlags, KeyHandle rootDirectory, KeyAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenKey( + if ((status = Win32.NtOpenKey( out handle, access, ref oa - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -113,16 +120,21 @@ ref oa public void Delete() { - Win32.NtDeleteKey(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtDeleteKey(this)) >= NtStatus.Error) + Win32.Throw(status); } public void DeleteValue(string name) { + NtStatus status; UnicodeString nameStr = new UnicodeString(name); try { - Win32.NtDeleteValueKey(this, ref nameStr).ThrowIf(); + if ((status = Win32.NtDeleteValueKey(this, ref nameStr)) >= NtStatus.Error) + Win32.Throw(status); } finally { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/KeyedEventHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/KeyedEventHandle.cs index af0e11d82..0cd6de4bb 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/KeyedEventHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/KeyedEventHandle.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -40,12 +42,14 @@ public static KeyedEventHandle Create(KeyedEventAccess access, string name) public static KeyedEventHandle Create(KeyedEventAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateKeyedEvent(out handle, access, ref oa, 0).ThrowIf(); + if ((status = Win32.NtCreateKeyedEvent(out handle, access, ref oa, 0)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -65,12 +69,14 @@ public KeyedEventHandle(string name, KeyedEventAccess access) public KeyedEventHandle(string name, DirectoryHandle rootDirectory, ObjectFlags objectFlags, KeyedEventAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenKeyedEvent(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenKeyedEvent(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -102,17 +108,21 @@ public NtStatus ReleaseKey(int key, bool alertable, long timeout) public NtStatus ReleaseKey(IntPtr key, bool alertable, long timeout, bool relative) { + NtStatus status; long realTimeout = relative ? -timeout : timeout; if (key.ToInt64() % 2 != 0) throw new ArgumentException("Key must be divisible by 2."); - return Win32.NtReleaseKeyedEvent( + if ((status = Win32.NtReleaseKeyedEvent( this, key, alertable, ref realTimeout - ); + )) >= NtStatus.Error) + Win32.Throw(status); + + return status; } public NtStatus WaitKey(int key) @@ -137,17 +147,21 @@ public NtStatus WaitKey(int key, bool alertable, long timeout) public NtStatus WaitKey(IntPtr key, bool alertable, long timeout, bool relative) { + NtStatus status; long realTimeout = relative ? -timeout : timeout; if (key.ToInt64() % 2 != 0) throw new ArgumentException("Key must be divisible by 2."); - return Win32.NtWaitForKeyedEvent( + if ((status = Win32.NtWaitForKeyedEvent( this, key, alertable, ref realTimeout - ); + )) >= NtStatus.Error) + Win32.Throw(status); + + return status; } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/LsaAccountHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/LsaAccountHandle.cs index 3785068a0..305b6e51d 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/LsaAccountHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/LsaAccountHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -33,14 +34,16 @@ public sealed class LsaAccountHandle : LsaHandle { public static LsaAccountHandle Create(LsaAccountAccess access, LsaPolicyHandle policyHandle, Sid sid) { + NtStatus status; IntPtr handle; - Win32.LsaCreateAccount( + if ((status = Win32.LsaCreateAccount( policyHandle, sid, access, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new LsaAccountHandle(handle, true); } @@ -57,14 +60,16 @@ private LsaAccountHandle(IntPtr handle, bool owned) /// The desired access to the account. public LsaAccountHandle(LsaPolicyHandle policyHandle, Sid sid, LsaAccountAccess access) { + NtStatus status; IntPtr handle; - Win32.LsaOpenAccount( + if ((status = Win32.LsaOpenAccount( policyHandle, sid, access, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.Handle = handle; } @@ -76,62 +81,61 @@ public void AddPrivilege(Privilege privilege) public void AddPrivileges(PrivilegeSet privileges) { - using (MemoryAlloc privilegeSetMemory = privileges.ToMemory()) + NtStatus status; + + using (var privilegeSetMemory = privileges.ToMemory()) { - Win32.LsaAddPrivilegesToAccount( + if ((status = Win32.LsaAddPrivilegesToAccount( this, privilegeSetMemory - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } - public PrivilegeSet Privileges + public PrivilegeSet GetPrivileges() { - get - { - IntPtr privileges; + NtStatus status; + IntPtr privileges; - Win32.LsaEnumeratePrivilegesOfAccount( - this, - out privileges - ).ThrowIf(); + if ((status = Win32.LsaEnumeratePrivilegesOfAccount( + this, + out privileges + )) >= NtStatus.Error) + Win32.Throw(status); - using (LsaMemoryAlloc privilegesAlloc = new LsaMemoryAlloc(privileges)) - { - return new PrivilegeSet(privilegesAlloc); - } + using (var privilegesAlloc = new LsaMemoryAlloc(privileges)) + { + return new PrivilegeSet(privilegesAlloc); } } - public QuotaLimits Quotas + public QuotaLimits GetQuotas() { - get - { - QuotaLimits quotas; + NtStatus status; + QuotaLimits quotas; - Win32.LsaGetQuotasForAccount( - this, - out quotas - ).ThrowIf(); + if ((status = Win32.LsaGetQuotasForAccount( + this, + out quotas + )) >= NtStatus.Error) + Win32.Throw(status); - return quotas; - } + return quotas; } - - public SecuritySystemAccess SystemAccess + public SecuritySystemAccess GetSystemAccess() { - get - { - SecuritySystemAccess access; + NtStatus status; + SecuritySystemAccess access; - Win32.LsaGetSystemAccessAccount( - this, - out access - ).ThrowIf(); + if ((status = Win32.LsaGetSystemAccessAccount( + this, + out access + )) >= NtStatus.Error) + Win32.Throw(status); - return access; - } + return access; } public void RemovePrivilege(Privilege privilege) @@ -141,39 +145,51 @@ public void RemovePrivilege(Privilege privilege) public void RemovePrivileges() { - Win32.LsaRemovePrivilegesFromAccount( + NtStatus status; + + if ((status = Win32.LsaRemovePrivilegesFromAccount( this, true, IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void RemovePrivileges(PrivilegeSet privileges) { - using (MemoryAlloc privilegeSetMemory = privileges.ToMemory()) + NtStatus status; + + using (var privilegeSetMemory = privileges.ToMemory()) { - Win32.LsaRemovePrivilegesFromAccount( + if ((status = Win32.LsaRemovePrivilegesFromAccount( this, false, privilegeSetMemory - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } public void SetQuotas(QuotaLimits quotas) { - Win32.LsaSetQuotasForAccount( + NtStatus status; + + if ((status = Win32.LsaSetQuotasForAccount( this, ref quotas - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void SetSystemAccess(SecuritySystemAccess access) { - Win32.LsaSetSystemAccessAccount( + NtStatus status; + + if ((status = Win32.LsaSetSystemAccessAccount( this, access - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/LsaAuthHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/LsaAuthHandle.cs index 6820913d7..bcb9dfaf2 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/LsaAuthHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/LsaAuthHandle.cs @@ -21,7 +21,10 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; +using ProcessHacker.Native.Security; using ProcessHacker.Native.Security.Authentication; namespace ProcessHacker.Native.Objects @@ -30,18 +33,21 @@ public sealed class LsaAuthHandle : NativeHandle { public static LsaAuthHandle Connect(string name) { + NtStatus status; + AnsiString nameStr; IntPtr handle; LsaOperationalMode mode; - AnsiString nameStr = new AnsiString(name); + nameStr = new AnsiString(name); try { - Win32.LsaRegisterLogonProcess( + if ((status = Win32.LsaRegisterLogonProcess( ref nameStr, out handle, out mode - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -53,9 +59,11 @@ out mode public static LsaAuthHandle ConnectUntrusted() { + NtStatus status; IntPtr handle; - Win32.LsaConnectUntrusted(out handle).ThrowIf(); + if ((status = Win32.LsaConnectUntrusted(out handle)) >= NtStatus.Error) + Win32.Throw(status); return new LsaAuthHandle(handle, true); } @@ -101,18 +109,20 @@ public TokenHandle LogonUser( out NtStatus subStatus ) { + NtStatus status; + AnsiString originNameStr; IntPtr profileBuffer; int profileBufferLength; IntPtr token; QuotaLimits quotas; - AnsiString originNameStr = new AnsiString(originName); + originNameStr = new AnsiString(originName); try { - using (MemoryRegion logonData = package.GetAuthData()) + using (var logonData = package.GetAuthData()) { - Win32.LsaLogonUser( + if ((status = Win32.LsaLogonUser( this, ref originNameStr, logonType, @@ -127,12 +137,11 @@ out NtStatus subStatus out token, out quotas, out subStatus - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); - using (new LsaMemoryAlloc(profileBuffer, true)) - { + using (var profileBufferAlloc = new LsaMemoryAlloc(profileBuffer, true)) profileData = package.GetProfileData(new MemoryRegion(profileBuffer, 0, profileBufferLength)); - } return new TokenHandle(token, true); } @@ -145,17 +154,20 @@ out subStatus public int LookupAuthenticationPackage(string packageName) { + NtStatus status; + AnsiString packageNameStr; int authenticationPackage; - AnsiString packageNameStr = new AnsiString(packageName); + packageNameStr = new AnsiString(packageName); try { - Win32.LsaLookupAuthenticationPackage( + if ((status = Win32.LsaLookupAuthenticationPackage( this, ref packageNameStr, out authenticationPackage - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/LsaHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/LsaHandle.cs index bea581c38..b34e33b2a 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/LsaHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/LsaHandle.cs @@ -46,29 +46,37 @@ protected override void Close() public void Delete() { - Win32.LsaDelete(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.LsaDelete(this)) >= NtStatus.Error) + Win32.Throw(status); } public override SecurityDescriptor GetSecurity(SecurityInformation securityInformation) { + NtStatus status; IntPtr securityDescriptor; - Win32.LsaQuerySecurityObject( + if ((status = Win32.LsaQuerySecurityObject( this, securityInformation, out securityDescriptor - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new SecurityDescriptor(new LsaMemoryAlloc(securityDescriptor)); } public override void SetSecurity(SecurityInformation securityInformation, SecurityDescriptor securityDescriptor) { - Win32.LsaSetSecurityObject( + NtStatus status; + + if ((status = Win32.LsaSetSecurityObject( this, securityInformation, securityDescriptor - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/LsaPolicyHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/LsaPolicyHandle.cs index 1b3290066..c2038f685 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/LsaPolicyHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/LsaPolicyHandle.cs @@ -45,7 +45,7 @@ public static LsaPolicyHandle LookupPolicyHandle if (weakRef != null) { - weakRef.TryGetTarget(out policyHandle); + policyHandle = weakRef.Target; } if (policyHandle == null) @@ -53,10 +53,9 @@ public static LsaPolicyHandle LookupPolicyHandle System.Threading.Interlocked.Increment(ref _lookupPolicyHandleMisses); policyHandle = new LsaPolicyHandle(LsaPolicyAccess.LookupNames); + if (policyHandle != null) - { _lookupPolicyHandle = new WeakReference(policyHandle); - } } return policyHandle; @@ -86,19 +85,22 @@ public LsaPolicyHandle(LsaPolicyAccess access) /// The desired access to the policy. public LsaPolicyHandle(string systemName, LsaPolicyAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(); + UnicodeString systemNameStr; IntPtr handle; - UnicodeString systemNameStr = new UnicodeString(systemName); + systemNameStr = new UnicodeString(systemName); try { - Win32.LsaOpenPolicy( + if ((status = Win32.LsaOpenPolicy( ref systemNameStr, ref oa, access, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -115,6 +117,7 @@ public void AddPrivilege(Sid accountSid, string privilege) public void AddPrivileges(Sid accountSid, string[] privileges) { + NtStatus status; UnicodeString[] privilegeStrArray = new UnicodeString[privileges.Length]; for (int i = 0; i < privileges.Length; i++) @@ -122,12 +125,13 @@ public void AddPrivileges(Sid accountSid, string[] privileges) try { - Win32.LsaAddAccountRights( + if ((status = Win32.LsaAddAccountRights( this, accountSid, privilegeStrArray, privilegeStrArray.Length - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -138,15 +142,19 @@ public void AddPrivileges(Sid accountSid, string[] privileges) public void DeletePrivateData(string name) { - UnicodeString nameStr = new UnicodeString(name); + NtStatus status; + UnicodeString nameStr; + + nameStr = new UnicodeString(name); try { - Win32.LsaStorePrivateData( + if ((status = Win32.LsaStorePrivateData( this, ref nameStr, IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -161,13 +169,14 @@ public void DeletePrivateData(string name) /// The callback for the enumeration. public void EnumAccounts(EnumAccountsDelegate callback) { + NtStatus status; int enumerationContext = 0; IntPtr buffer; int count; while (true) { - NtStatus status = Win32.LsaEnumerateAccounts( + status = Win32.LsaEnumerateAccounts( this, ref enumerationContext, out buffer, @@ -177,10 +186,10 @@ out count if (status == NtStatus.NoMoreEntries) break; + if (status >= NtStatus.Error) + Win32.Throw(status); - status.ThrowIf(); - - using (LsaMemoryAlloc bufferAlloc = new LsaMemoryAlloc(buffer)) + using (var bufferAlloc = new LsaMemoryAlloc(buffer)) { for (int i = 0; i < count; i++) { @@ -200,26 +209,31 @@ out count /// The callback for the enumeration. public void EnumAccountsWithPrivilege(string privilegeName, EnumAccountsDelegate callback) { + NtStatus status; + UnicodeString privilegeNameStr; IntPtr buffer; int count; - UnicodeString privilegeNameStr = new UnicodeString(privilegeName); + privilegeNameStr = new UnicodeString(privilegeName); try { - Win32.LsaEnumerateAccountsWithUserRight( + if ((status = Win32.LsaEnumerateAccountsWithUserRight( this, ref privilegeNameStr, out buffer, out count - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { privilegeNameStr.Dispose(); } - using (LsaMemoryAlloc bufferAlloc = new LsaMemoryAlloc(buffer)) + Sid[] sids = new Sid[count]; + + using (var bufferAlloc = new LsaMemoryAlloc(buffer)) { for (int i = 0; i < count; i++) { @@ -236,13 +250,14 @@ out count /// The callback for the enumeration. public void EnumPrivileges(EnumPrivilegesDelegate callback) { + NtStatus status; int enumerationContext = 0; IntPtr buffer; int count; while (true) { - NtStatus status = Win32.LsaEnumeratePrivileges( + status = Win32.LsaEnumeratePrivileges( this, ref enumerationContext, out buffer, @@ -252,14 +267,14 @@ out count if (status == NtStatus.NoMoreEntries) break; + if (status >= NtStatus.Error) + Win32.Throw(status); - status.ThrowIf(); - - using (LsaMemoryAlloc bufferAlloc = new LsaMemoryAlloc(buffer)) + using (var bufferAlloc = new LsaMemoryAlloc(buffer)) { for (int i = 0; i < count; i++) { - if (!callback(new Privilege(bufferAlloc.ReadStruct(0, PolicyPrivilegeDefinition.SizeOf, i).Name.Text))) + if (!callback(new Privilege(bufferAlloc.ReadStruct(i).Name.Read()))) return; } } @@ -270,20 +285,17 @@ out count /// Gets the accounts in the policy. This requires /// ViewLocalInformation access. /// - public Sid[] Accounts + public Sid[] GetAccounts() { - get - { - List sids = new List(); + List sids = new List(); - this.EnumAccounts(sid => + this.EnumAccounts((sid) => { sids.Add(sid); return true; }); - return sids.ToArray(); - } + return sids.ToArray(); } /// @@ -296,7 +308,7 @@ public Sid[] GetAccountsWithPrivilege(string privilegeName) { List sids = new List(); - this.EnumAccountsWithPrivilege(privilegeName, sid => + this.EnumAccountsWithPrivilege(privilegeName, (sid) => { sids.Add(sid); return true; @@ -305,20 +317,17 @@ public Sid[] GetAccountsWithPrivilege(string privilegeName) return sids.ToArray(); } - public Privilege[] Privileges + public Privilege[] GetPrivileges() { - get - { - List privileges = new List(); + List privileges = new List(); - this.EnumPrivileges(privilege => - { - privileges.Add(privilege); - return true; - }); + this.EnumPrivileges((privilege) => + { + privileges.Add(privilege); + return true; + }); - return privileges.ToArray(); - } + return privileges.ToArray(); } public string LookupName(Sid sid) @@ -354,7 +363,7 @@ public string LookupName(Sid sid, out SidNameUse nameUse, out string domainName) new IntPtr[] { sid }, out referencedDomains, out names - )).IsError()) + )) >= NtStatus.Error) { if (status == NtStatus.NoneMapped) { @@ -366,8 +375,8 @@ out names Win32.Throw(status); } - using (LsaMemoryAlloc referencedDomainsAlloc = new LsaMemoryAlloc(referencedDomains)) - using (LsaMemoryAlloc namesAlloc = new LsaMemoryAlloc(names)) + using (var referencedDomainsAlloc = new LsaMemoryAlloc(referencedDomains)) + using (var namesAlloc = new LsaMemoryAlloc(names)) { LsaTranslatedName translatedName = namesAlloc.ReadStruct(); @@ -384,16 +393,16 @@ out names { LsaReferencedDomainList domains = referencedDomainsAlloc.ReadStruct(); MemoryRegion trustArray = new MemoryRegion(domains.Domains); - LsaTrustInformation trustInfo = trustArray.ReadStruct(0, LsaTrustInformation.SizeOf, translatedName.DomainIndex); + LsaTrustInformation trustInfo = trustArray.ReadStruct(translatedName.DomainIndex); - domainName = trustInfo.Name.Text; + domainName = trustInfo.Name.Read(); } else { domainName = null; } - return translatedName.Name.Text; + return translatedName.Name.Read(); } } @@ -404,60 +413,68 @@ public string LookupPrivilegeDisplayName(Luid value) public string LookupPrivilegeDisplayName(string name) { + NtStatus status; + UnicodeString nameStr; IntPtr displayName; short language; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.LsaLookupPrivilegeDisplayName( + if ((status = Win32.LsaLookupPrivilegeDisplayName( this, ref nameStr, out displayName, out language - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { nameStr.Dispose(); } - using (LsaMemoryAlloc displayNameAlloc = new LsaMemoryAlloc(displayName)) + using (var displayNameAlloc = new LsaMemoryAlloc(displayName)) { - return displayNameAlloc.ReadStruct().Text; + return displayNameAlloc.ReadStruct().Read(); } } public string LookupPrivilegeName(Luid value) { + NtStatus status; IntPtr name; - Win32.LsaLookupPrivilegeName( + if ((status = Win32.LsaLookupPrivilegeName( this, ref value, out name - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); - using (LsaMemoryAlloc nameAlloc = new LsaMemoryAlloc(name)) + using (var nameAlloc = new LsaMemoryAlloc(name)) { - return nameAlloc.ReadStruct().Text; + return nameAlloc.ReadStruct().Read(); } } public Luid LookupPrivilegeValue(string name) { + NtStatus status; + UnicodeString nameStr; Luid luid; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.LsaLookupPrivilegeValue( + if ((status = Win32.LsaLookupPrivilegeValue( this, ref nameStr, out luid - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -491,10 +508,11 @@ public Sid LookupSid(string name, out string domainName) public Sid LookupSid(string name, out SidNameUse nameUse, out string domainName) { NtStatus status; + UnicodeString nameStr; IntPtr referencedDomains; IntPtr sids; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { @@ -505,7 +523,7 @@ public Sid LookupSid(string name, out SidNameUse nameUse, out string domainName) new UnicodeString[] { nameStr }, out referencedDomains, out sids - )).IsError()) + )) >= NtStatus.Error) { if (status == NtStatus.NoneMapped) { @@ -540,9 +558,9 @@ out sids { LsaReferencedDomainList domains = referencedDomainsAlloc.ReadStruct(); MemoryRegion trustArray = new MemoryRegion(domains.Domains); - LsaTrustInformation trustInfo = trustArray.ReadStruct(0, LsaTrustInformation.SizeOf, translatedSid.DomainIndex); + LsaTrustInformation trustInfo = trustArray.ReadStruct(translatedSid.DomainIndex); - domainName = trustInfo.Name.Text; + domainName = trustInfo.Name.Read(); } else { @@ -560,17 +578,21 @@ public void RemovePrivilege(Sid accountSid, string privilege) public void RemovePrivileges(Sid accountSid) { - Win32.LsaRemoveAccountRights( + NtStatus status; + + if ((status = Win32.LsaRemoveAccountRights( this, accountSid, true, null, 0 - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void RemovePrivileges(Sid accountSid, string[] privileges) { + NtStatus status; UnicodeString[] privilegeStrArray = new UnicodeString[privileges.Length]; for (int i = 0; i < privileges.Length; i++) @@ -578,13 +600,14 @@ public void RemovePrivileges(Sid accountSid, string[] privileges) try { - Win32.LsaRemoveAccountRights( + if ((status = Win32.LsaRemoveAccountRights( this, accountSid, false, privilegeStrArray, privilegeStrArray.Length - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -595,41 +618,47 @@ public void RemovePrivileges(Sid accountSid, string[] privileges) public string RetrievePrivateData(string name) { + NtStatus status; + UnicodeString nameStr; IntPtr privateData; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.LsaRetrievePrivateData( + if ((status = Win32.LsaRetrievePrivateData( this, ref nameStr, out privateData - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { nameStr.Dispose(); } - using (LsaMemoryAlloc privateDataAlloc = new LsaMemoryAlloc(privateData)) - { - return privateDataAlloc.ReadStruct().Text; - } + using (var privateDataAlloc = new LsaMemoryAlloc(privateData)) + return privateDataAlloc.ReadStruct().Read(); } public void StorePrivateData(string name, string privateData) { - UnicodeString nameStr = new UnicodeString(name); - UnicodeString privateDataStr = new UnicodeString(privateData); + NtStatus status; + UnicodeString nameStr; + UnicodeString privateDataStr; + + nameStr = new UnicodeString(name); + privateDataStr = new UnicodeString(privateData); try { - Win32.LsaStorePrivateData( + if ((status = Win32.LsaStorePrivateData( this, ref nameStr, ref privateDataStr - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/LsaSecretHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/LsaSecretHandle.cs index 77ada9075..7657956bb 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/LsaSecretHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/LsaSecretHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -33,18 +34,21 @@ public sealed class LsaSecretHandle : LsaHandle { public static LsaSecretHandle Create(LsaSecretAccess access, LsaPolicyHandle policyHandle, string name) { + NtStatus status; + UnicodeString nameStr; IntPtr handle; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.LsaCreateSecret( + if ((status = Win32.LsaCreateSecret( policyHandle, ref nameStr, access, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -60,18 +64,21 @@ private LsaSecretHandle(IntPtr handle, bool owned) public LsaSecretHandle(LsaPolicyHandle policyHandle, string name, LsaSecretAccess access) { + NtStatus status; + UnicodeString nameStr; IntPtr handle; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.LsaOpenSecret( + if ((status = Win32.LsaOpenSecret( policyHandle, ref nameStr, access, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -106,25 +113,27 @@ public void Query( out DateTime oldValueSetTime ) { + NtStatus status; IntPtr currentValueStr; long currentValueSetTimeLong; IntPtr oldValueStr; long oldValueSetTimeLong; - Win32.LsaQuerySecret( + if ((status = Win32.LsaQuerySecret( this, out currentValueStr, out currentValueSetTimeLong, out oldValueStr, out oldValueSetTimeLong - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); - using (LsaMemoryAlloc currentValueStrAlloc = new LsaMemoryAlloc(currentValueStr)) - using (LsaMemoryAlloc oldValueStrAlloc = new LsaMemoryAlloc(oldValueStr)) + using (var currentValueStrAlloc = new LsaMemoryAlloc(currentValueStr)) + using (var oldValueStrAlloc = new LsaMemoryAlloc(oldValueStr)) { - currentValue = currentValueStrAlloc.ReadStruct().Text; + currentValue = currentValueStrAlloc.ReadStruct().Read(); currentValueSetTime = DateTime.FromFileTime(currentValueSetTimeLong); - oldValue = oldValueStrAlloc.ReadStruct().Text; + oldValue = oldValueStrAlloc.ReadStruct().Read(); oldValueSetTime = DateTime.FromFileTime(oldValueSetTimeLong); } } @@ -136,16 +145,21 @@ public void Set(string currentValue) public void Set(string currentValue, string oldValue) { - UnicodeString currentValueStr = new UnicodeString(currentValue); - UnicodeString oldValueStr = new UnicodeString(oldValue); + NtStatus status; + UnicodeString currentValueStr; + UnicodeString oldValueStr; + + currentValueStr = new UnicodeString(currentValue); + oldValueStr = new UnicodeString(oldValue); try { - Win32.LsaSetSecret( + if ((status = Win32.LsaSetSecret( this, ref currentValueStr, ref oldValueStr - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/MailslotHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/MailslotHandle.cs index 45758ae47..f3b62c173 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/MailslotHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/MailslotHandle.cs @@ -56,13 +56,14 @@ public static MailslotHandle Create( FileCreateOptions createOptions ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory); IoStatusBlock isb; IntPtr handle; try { - Win32.NtCreateMailslotFile( + if ((status = Win32.NtCreateMailslotFile( out handle, access, ref oa, @@ -71,7 +72,8 @@ FileCreateOptions createOptions quota, maxMessageSize, ref readTimeout - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/MutantHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/MutantHandle.cs index f10b0362b..9e9fd229b 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/MutantHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/MutantHandle.cs @@ -21,8 +21,11 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; +using System.Runtime.InteropServices; namespace ProcessHacker.Native.Objects { @@ -40,12 +43,14 @@ public static MutantHandle Create(MutantAccess access, string name, bool initial public static MutantHandle Create(MutantAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, bool initialOwner) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateMutant(out handle, access, ref oa, initialOwner).ThrowIf(); + if ((status = Win32.NtCreateMutant(out handle, access, ref oa, initialOwner)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -66,12 +71,14 @@ private MutantHandle(IntPtr handle, bool owned) public MutantHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, MutantAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenMutant(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenMutant(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -85,49 +92,39 @@ public MutantHandle(string name, MutantAccess access) : this(name, 0, null, access) { } - public MutantBasicInformation BasicInformation + public MutantBasicInformation GetBasicInformation() { - get - { - MutantBasicInformation mbi; - int retLength; - - Win32.NtQueryMutant( - this, - MutantInformationClass.MutantBasicInformation, - out mbi, - MutantBasicInformation.SizeOf, - out retLength - ).ThrowIf(); - - return mbi; - } + NtStatus status; + MutantBasicInformation mbi; + int retLength; + + if ((status = Win32.NtQueryMutant(this, MutantInformationClass.MutantBasicInformation, + out mbi, Marshal.SizeOf(typeof(MutantBasicInformation)), out retLength)) >= NtStatus.Error) + Win32.Throw(status); + + return mbi; } - public MutantOwnerInformation OwnerInformation + public MutantOwnerInformation GetOwnerInformation() { - get - { - MutantOwnerInformation moi; - int retLength; - - Win32.NtQueryMutant( - this, - MutantInformationClass.MutantOwnerInformation, - out moi, - MutantOwnerInformation.SizeOf, - out retLength - ).ThrowIf(); - - return moi; - } + NtStatus status; + MutantOwnerInformation moi; + int retLength; + + if ((status = Win32.NtQueryMutant(this, MutantInformationClass.MutantOwnerInformation, + out moi, Marshal.SizeOf(typeof(MutantOwnerInformation)), out retLength)) >= NtStatus.Error) + Win32.Throw(status); + + return moi; } public int Release() { + NtStatus status; int previousCount; - Win32.NtReleaseMutant(this, out previousCount).ThrowIf(); + if ((status = Win32.NtReleaseMutant(this, out previousCount)) >= NtStatus.Error) + Win32.Throw(status); return previousCount; } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/NamedPipeHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/NamedPipeHandle.cs index 8d7659360..94075162c 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/NamedPipeHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/NamedPipeHandle.cs @@ -89,6 +89,7 @@ public static NamedPipeHandle Create( long defaultTimeout ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory); IoStatusBlock isb; IntPtr handle; @@ -99,7 +100,7 @@ long defaultTimeout try { - Win32.NtCreateNamedPipeFile( + if ((status = Win32.NtCreateNamedPipeFile( out handle, access, ref oa, @@ -114,7 +115,8 @@ long defaultTimeout inboundQuota, outboundQuota, ref defaultTimeout - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -153,33 +155,33 @@ public static bool Wait(string name, long timeout) public static bool Wait(string name, long timeout, bool relative) { - using (FileHandle npfsHandle = new FileHandle( + using (var npfsHandle = new FileHandle( Win32.NamedPipePath + "\\", FileShareMode.ReadWrite, FileCreateOptions.SynchronousIoNonAlert, FileAccess.ReadAttributes | (FileAccess)StandardRights.Synchronize )) { - using (MemoryAlloc data = new MemoryAlloc(FilePipeWaitForBuffer.NameOffset + name.Length * 2)) + using (var data = new MemoryAlloc(FilePipeWaitForBuffer.NameOffset + name.Length * 2)) { - FilePipeWaitForBuffer info = new FilePipeWaitForBuffer - { - Timeout = timeout, - TimeoutSpecified = true, - NameLength = name.Length * 2 - }; - - data.WriteStruct(info); + FilePipeWaitForBuffer info = new FilePipeWaitForBuffer(); + + info.Timeout = timeout; + info.TimeoutSpecified = true; + info.NameLength = name.Length * 2; + data.WriteStruct(info); data.WriteUnicodeString(FilePipeWaitForBuffer.NameOffset, name); + NtStatus status; int returnLength; - NtStatus status = npfsHandle.FsControl(FsCtlWait, data, data.Size, IntPtr.Zero, 0, out returnLength); + status = npfsHandle.FsControl(FsCtlWait, data, data.Size, IntPtr.Zero, 0, out returnLength); if (status == NtStatus.IoTimeout) return false; - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return true; } @@ -253,7 +255,8 @@ public bool EndListen(AsyncIoContext asyncContext) if (asyncContext.Status == NtStatus.PipeConnected) return true; - asyncContext.StatusBlock.Status.ThrowIf(); + if (asyncContext.StatusBlock.Status >= NtStatus.Error) + Win32.Throw(asyncContext.StatusBlock.Status); return false; } @@ -268,31 +271,19 @@ public void Disconnect() this.FsControl(FsCtlDisconnect, IntPtr.Zero, 0, IntPtr.Zero, 0); } - private FilePipeInformation Information + private FilePipeInformation GetInformation() { - get - { - return this.QueryStruct( - FileInformationClass.FilePipeInformation, - FilePipeInformation.SizeOf - ); - } + return this.QueryStruct(FileInformationClass.FilePipeInformation); } - private FilePipeLocalInformation LocalInformation + private FilePipeLocalInformation GetLocalInformation() { - get - { - return this.QueryStruct( - FileInformationClass.FilePipeLocalInformation, - FilePipeLocalInformation.SizeOf - ); - } + return this.QueryStruct(FileInformationClass.FilePipeLocalInformation); } - public PipeType PipeType + public PipeType GetPipeType() { - get { return this.Information.ReadMode; } + return this.GetInformation().ReadMode; } public void ImpersonateClient() @@ -302,14 +293,16 @@ public void ImpersonateClient() public bool Listen() { + NtStatus status; int returnLength; - NtStatus status = this.FsControl(FsCtlListen, IntPtr.Zero, 0, IntPtr.Zero, 0, out returnLength); + status = this.FsControl(FsCtlListen, IntPtr.Zero, 0, IntPtr.Zero, 0, out returnLength); if (status == NtStatus.PipeConnected) return true; - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return false; } @@ -374,7 +367,7 @@ public int Peek(byte[] buffer, int offset, int length, out int bytesAvailable, o public int Peek(IntPtr buffer, int length, out int bytesAvailable, out int bytesLeftInMessage) { - using (MemoryAlloc data = new MemoryAlloc(FilePipePeekBuffer.DataOffset + length)) + using (var data = new MemoryAlloc(FilePipePeekBuffer.DataOffset + length)) { NtStatus status; int returnLength; @@ -386,12 +379,14 @@ public int Peek(IntPtr buffer, int length, out int bytesAvailable, out int bytes if (status == NtStatus.BufferOverflow) status = NtStatus.Success; - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); FilePipePeekBuffer info = data.ReadStruct(); + int bytesRead; bytesAvailable = info.ReadDataAvailable; - int bytesRead = returnLength - FilePipePeekBuffer.DataOffset; + bytesRead = returnLength - FilePipePeekBuffer.DataOffset; bytesLeftInMessage = info.MessageLength - bytesRead; if (buffer != IntPtr.Zero) diff --git a/1.x/trunk/ProcessHacker.Native/Objects/NativeHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/NativeHandle.cs index 99031c6d4..2f60fdfb0 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/NativeHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/NativeHandle.cs @@ -90,19 +90,23 @@ public static NtStatus WaitAny(ISynchronizable[] objects, bool alertable, long t private static NtStatus WaitForMultipleObjects(ISynchronizable[] objects, WaitType waitType, bool alertable, long timeout, bool relative) { + NtStatus status; IntPtr[] handles = new IntPtr[objects.Length]; long realTimeout = relative ? -timeout : timeout; for (int i = 0; i < objects.Length; i++) handles[i] = objects[i].Handle; - return Win32.NtWaitForMultipleObjects( + if ((status = Win32.NtWaitForMultipleObjects( handles.Length, handles, waitType, alertable, ref realTimeout - ); + )) >= NtStatus.Error) + Win32.Throw(status); + + return status; } public static implicit operator int(NativeHandle handle) @@ -220,80 +224,66 @@ public override int GetHashCode() /// Gets the handle's name. /// /// A string. - public virtual string ObjectName + public virtual string GetObjectName() { - get - { - int retLength; + NtStatus status; + int retLength; - Win32.NtQueryObject( - this, - ObjectInformationClass.ObjectNameInformation, - IntPtr.Zero, - 0, - out retLength - ); + status = Win32.NtQueryObject(this, ObjectInformationClass.ObjectNameInformation, + IntPtr.Zero, 0, out retLength); - if (retLength > 0) + if (retLength > 0) + { + using (MemoryAlloc oniMem = new MemoryAlloc(retLength)) { - using (MemoryAlloc oniMem = new MemoryAlloc(retLength)) - { - Win32.NtQueryObject( - this, - ObjectInformationClass.ObjectNameInformation, - oniMem, - oniMem.Size, - out retLength - ).ThrowIf(); - - ObjectNameInformation oni = oniMem.ReadStruct(); - - return oni.Name.Text; - } - } + if ((status = Win32.NtQueryObject(this, ObjectInformationClass.ObjectNameInformation, + oniMem, oniMem.Size, out retLength)) >= NtStatus.Error) + Win32.Throw(status); - return null; + var oni = oniMem.ReadStruct(); + + return oni.Name.Read(); + } + } + else + { + Win32.Throw(status); } + + return null; } /// /// Gets the handle's type name. /// /// A string. - public virtual string ObjectTypeName + public virtual string GetObjectTypeName() { - get - { - int retLength; + NtStatus status; + int retLength; - Win32.NtQueryObject( - this, - ObjectInformationClass.ObjectTypeInformation, - IntPtr.Zero, - 0, - out retLength - ); + status = Win32.NtQueryObject(this, ObjectInformationClass.ObjectTypeInformation, + IntPtr.Zero, 0, out retLength); - if (retLength > 0) + if (retLength > 0) + { + using (MemoryAlloc otiMem = new MemoryAlloc(retLength)) { - using (MemoryAlloc otiMem = new MemoryAlloc(retLength)) - { - Win32.NtQueryObject( - this, - ObjectInformationClass.ObjectTypeInformation, - otiMem, - otiMem.Size, - out retLength - ).ThrowIf(); - - ObjectTypeInformation oni = otiMem.ReadStruct(); - - return oni.Name.Text; - } - } + if ((status = Win32.NtQueryObject(this, ObjectInformationClass.ObjectTypeInformation, + otiMem, otiMem.Size, out retLength)) >= NtStatus.Error) + Win32.Throw(status); - return null; + var oni = otiMem.ReadStruct(); + + return oni.Name.Read(); + } + } + else + { + Win32.Throw(status); } + + return null; } /// @@ -322,7 +312,10 @@ protected SecurityDescriptor GetSecurity(SeObjectType objectType, SecurityInform /// public virtual void MakeObjectPermanent() { - Win32.NtMakePermanentObject(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtMakePermanentObject(this)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -332,16 +325,10 @@ public virtual void MakeObjectPermanent() /// public virtual void MakeObjectTemporary() { - Win32.NtMakeTemporaryObject(this).ThrowIf(); - } + NtStatus status; - /// - /// Marks the handle as invalid. This method must only be called from - /// within a derived class constructor. - /// - protected bool IsValid - { - get { return this._handle != IntPtr.Zero; } + if ((status = Win32.NtMakeTemporaryObject(this)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -414,14 +401,18 @@ public virtual NtStatus SignalAndWait(ISynchronizable waitObject, bool alertable /// public virtual NtStatus SignalAndWait(ISynchronizable waitObject, bool alertable, long timeout, bool relative) { + NtStatus status; long realTimeout = relative ? -timeout : timeout; - return Win32.NtSignalAndWaitForSingleObject( + if ((status = Win32.NtSignalAndWaitForSingleObject( this, waitObject.Handle, alertable, - ref realTimeout - ); + ref timeout + )) >= NtStatus.Error) + Win32.Throw(status); + + return status; } /// @@ -522,20 +513,25 @@ public NtStatus Wait(long timeout, bool relative) /// Whether the timeout value is relative. public virtual NtStatus Wait(bool alertable, long timeout, bool relative) { + NtStatus status; long realTimeout = relative ? -timeout : timeout; - return Win32.NtWaitForSingleObject( + if ((status = Win32.NtWaitForSingleObject( this, alertable, ref realTimeout - ); + )) >= NtStatus.Error) + Win32.Throw(status); + + return status; } } /// /// Represents a generic Windows handle which acts as a kernel handle by default. /// - public class NativeHandle : NativeHandle where TAccess : struct + public class NativeHandle : NativeHandle + where TAccess : struct { /// /// Creates a new, invalid handle. You must set the handle using the Handle property. @@ -571,16 +567,8 @@ public NativeHandle(IntPtr handle, TAccess access) { IntPtr newHandle; - Win32.NtDuplicateObject( - ProcessHandle.Current, - handle, - ProcessHandle.Current, - out newHandle, - (int)Convert.ChangeType(access, typeof(int)), - 0, - 0 - ); - + Win32.DuplicateObject(ProcessHandle.Current, handle, ProcessHandle.Current, out newHandle, + (int)Convert.ChangeType(access, typeof(int)), 0, 0); this.Handle = newHandle; } @@ -594,16 +582,8 @@ public NativeHandle(ProcessHandle processHandle, IntPtr handle, TAccess access) { IntPtr newHandle; - Win32.NtDuplicateObject( - processHandle, - handle, - ProcessHandle.Current, - out newHandle, - (int)Convert.ChangeType(access, typeof(int)), - 0, - 0 - ); - + Win32.DuplicateObject(processHandle, handle, ProcessHandle.Current, out newHandle, + (int)Convert.ChangeType(access, typeof(int)), 0, 0); this.Handle = newHandle; } @@ -615,16 +595,8 @@ public void ChangeAccess(TAccess access) { IntPtr newHandle; - Win32.NtDuplicateObject( - ProcessHandle.Current, - this, - ProcessHandle.Current, - out newHandle, - (int)Convert.ChangeType(access, typeof(int)), - 0, - 0 - ); - + Win32.DuplicateObject(ProcessHandle.Current, this, ProcessHandle.Current, out newHandle, + (int)Convert.ChangeType(access, typeof(int)), 0, 0); this.SwapHandle(newHandle); } @@ -648,6 +620,7 @@ public class GenericHandle : NativeHandle /// Creates a new, invalid handle. You must set the handle using the Handle property. /// protected GenericHandle() + : base() { } /// diff --git a/1.x/trunk/ProcessHacker.Native/Objects/PortComHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/PortComHandle.cs index c52d814cd..a032c3a45 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/PortComHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/PortComHandle.cs @@ -31,13 +31,15 @@ public sealed class PortComHandle : NativeHandle { public static PortComHandle Connect(string portName) { + NtStatus status; UnicodeString portNameStr = new UnicodeString(portName); - SecurityQualityOfService securityQos = new SecurityQualityOfService(SecurityImpersonationLevel.SecurityImpersonation, true, false); + SecurityQualityOfService securityQos = + new SecurityQualityOfService(SecurityImpersonationLevel.SecurityImpersonation, true, false); IntPtr handle; try { - Win32.NtConnectPort( + if ((status = Win32.NtConnectPort( out handle, ref portNameStr, ref securityQos, @@ -46,7 +48,8 @@ public static PortComHandle Connect(string portName) IntPtr.Zero, IntPtr.Zero, IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -62,9 +65,12 @@ internal PortComHandle(IntPtr handle, bool owned) public void Reply(PortMessage message) { - using (MemoryAlloc messageMemory = message.ToMemory()) + NtStatus status; + + using (var messageMemory = message.ToMemory()) { - Win32.NtReplyPort(this, messageMemory).ThrowIf(); + if ((status = Win32.NtReplyPort(this, messageMemory)) >= NtStatus.Error) + Win32.Throw(status); message.SetHeader(messageMemory); } @@ -77,7 +83,10 @@ public PortMessage ReplyWaitReceive() public PortMessage ReplyWaitReceive(PortMessage message) { - using (MemoryAlloc buffer = PortMessage.AllocateBuffer()) + NtStatus status; + IntPtr context; + + using (var buffer = PortMessage.AllocateBuffer()) { MemoryAlloc messageMemory = null; @@ -86,14 +95,13 @@ public PortMessage ReplyWaitReceive(PortMessage message) try { - IntPtr context; - - Win32.NtReplyWaitReceivePort( + if ((status = Win32.NtReplyWaitReceivePort( this, out context, messageMemory ?? IntPtr.Zero, buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (message != null) message.SetHeader(messageMemory); @@ -110,12 +118,15 @@ public PortMessage ReplyWaitReceive(PortMessage message) public PortMessage ReplyWaitReply(PortMessage message) { - using (MemoryAlloc messageMemory = message.ToMemory()) + NtStatus status; + + using (var messageMemory = message.ToMemory()) { - Win32.NtReplyWaitReplyPort( + if ((status = Win32.NtReplyWaitReplyPort( this, messageMemory - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new PortMessage(messageMemory); } @@ -123,9 +134,12 @@ public PortMessage ReplyWaitReply(PortMessage message) public void Request(PortMessage message) { - using (MemoryAlloc messageMemory = message.ToMemory()) + NtStatus status; + + using (var messageMemory = message.ToMemory()) { - Win32.NtRequestPort(this, messageMemory).ThrowIf(); + if ((status = Win32.NtRequestPort(this, messageMemory)) >= NtStatus.Error) + Win32.Throw(status); message.SetHeader(messageMemory); } @@ -133,14 +147,17 @@ public void Request(PortMessage message) public PortMessage RequestWaitReply(PortMessage message) { - using (MemoryAlloc buffer = PortMessage.AllocateBuffer()) - using (MemoryAlloc messageMemory = message.ToMemory()) + NtStatus status; + + using (var buffer = PortMessage.AllocateBuffer()) + using (var messageMemory = message.ToMemory()) { - Win32.NtRequestWaitReplyPort( + if ((status = Win32.NtRequestWaitReplyPort( this, messageMemory, buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); message.SetHeader(messageMemory); diff --git a/1.x/trunk/ProcessHacker.Native/Objects/PortHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/PortHandle.cs index 5abd9caae..ca8032f92 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/PortHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/PortHandle.cs @@ -54,18 +54,20 @@ public static PortHandle Create( int maxPoolUsage ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreatePort( + if ((status = Win32.NtCreatePort( out handle, ref oa, maxConnectionInfoLength, maxMessageLength, maxPoolUsage - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -100,18 +102,20 @@ public static PortHandle CreateWaitable( int maxPoolUsage ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateWaitablePort( + if ((status = Win32.NtCreateWaitablePort( out handle, ref oa, maxConnectionInfoLength, maxMessageLength, maxPoolUsage - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -127,36 +131,44 @@ private PortHandle(IntPtr handle, bool owned) public PortComHandle AcceptConnect(PortMessage message, bool accept) { + NtStatus status; IntPtr portHandle; - using (MemoryAlloc messageMemory = message.ToMemory()) + using (var messageMemory = message.ToMemory()) { - Win32.NtAcceptConnectPort( + if ((status = Win32.NtAcceptConnectPort( out portHandle, IntPtr.Zero, messageMemory, accept, IntPtr.Zero, IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (!NativeHandle.IsInvalid(portHandle)) return new PortComHandle(portHandle, true); - - return null; + else + return null; } } public void CompleteConnect() { - Win32.NtCompleteConnectPort(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtCompleteConnectPort(this)) >= NtStatus.Error) + Win32.Throw(status); } public PortMessage Listen() { - using (MemoryAlloc buffer = PortMessage.AllocateBuffer()) + NtStatus status; + + using (var buffer = PortMessage.AllocateBuffer()) { - Win32.NtListenPort(this, buffer).ThrowIf(); + if ((status = Win32.NtListenPort(this, buffer)) >= NtStatus.Error) + Win32.Throw(status); return new PortMessage(buffer); } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs index b9cc3de4a..c3dbd7468 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/ProcessHandle.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Runtime.InteropServices; using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -106,12 +107,13 @@ public static ProcessHandle Create( DebugObjectHandle debugPort ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateProcess( + if ((status = Win32.NtCreateProcess( out handle, access, ref oa, @@ -120,7 +122,8 @@ DebugObjectHandle debugPort sectionHandle ?? IntPtr.Zero, debugPort ?? IntPtr.Zero, IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -169,24 +172,36 @@ out ThreadHandle threadHandle ) { ProcessHandle phandle; + ThreadHandle thandle; SectionImageInformation imageInfo; // If we don't have a desktop, use the current one. if (startupInfo.Desktop == null) - startupInfo.Desktop = Current.GetPebString(PebOffset.DesktopName); + startupInfo.Desktop = ProcessHandle.Current.GetPebString(PebOffset.DesktopName); // Open the file, create a section, and create a process. - using (FileHandle fhandle = new FileHandle(fileName, FileShareMode.Read | FileShareMode.Delete, FileAccess.Execute | (FileAccess)StandardRights.Synchronize)) - using (SectionHandle shandle = SectionHandle.Create(SectionAccess.All, SectionAttributes.Image, MemoryProtection.Execute, fhandle)) + using (var fhandle = new FileHandle( + fileName, + FileShareMode.Read | FileShareMode.Delete, + FileAccess.Execute | (FileAccess)StandardRights.Synchronize + )) { - imageInfo = shandle.GetImageInformation(); + using (var shandle = SectionHandle.Create( + SectionAccess.All, + SectionAttributes.Image, + MemoryProtection.Execute, + fhandle + )) + { + imageInfo = shandle.GetImageInformation(); - phandle = Create( - ProcessAccess.All, - parentProcess, - inheritHandles, - shandle - ); + phandle = Create( + ProcessAccess.All, + parentProcess, + inheritHandles, + shandle + ); + } } IntPtr peb = phandle.GetBasicInformation().PebBaseAddress; @@ -197,21 +212,21 @@ out ThreadHandle threadHandle peb, creationFlags, FileUtils.GetFileName(fileName), - Current.GetPebString(PebOffset.DllPath), + ProcessHandle.Current.GetPebString(PebOffset.DllPath), currentDirectory, fileName, environment, - !string.IsNullOrEmpty(startupInfo.Title) ? startupInfo.Title : fileName, - !string.IsNullOrEmpty(startupInfo.Desktop) ? startupInfo.Desktop : string.Empty, - !string.IsNullOrEmpty(startupInfo.Reserved) ? startupInfo.Reserved : string.Empty, - string.Empty, + startupInfo.Title != null ? startupInfo.Title : fileName, + startupInfo.Desktop != null ? startupInfo.Desktop : "", + startupInfo.Reserved != null ? startupInfo.Reserved : "", + "", ref startupInfo ); // TODO: Duplicate the console handles (stdin, stdout, stderr). // Create the initial thread. - ThreadHandle thandle = ThreadHandle.CreateUserThread( + thandle = ThreadHandle.CreateUserThread( phandle, true, imageInfo.StackCommit.Increment(imageInfo.StackReserved).ToInt32(), @@ -225,23 +240,24 @@ out clientId if (notifyCsr) { - BaseCreateProcessMsg processMsg = new BaseCreateProcessMsg - { - ProcessHandle = phandle, - ThreadHandle = thandle, - ClientId = clientId, - CreationFlags = creationFlags - }; + BaseCreateProcessMsg processMsg = new BaseCreateProcessMsg(); + + processMsg.ProcessHandle = phandle; + processMsg.ThreadHandle = thandle; + processMsg.ClientId = clientId; + processMsg.CreationFlags = creationFlags; - if ((creationFlags & (ProcessCreationFlags.DebugProcess | ProcessCreationFlags.DebugOnlyThisProcess)) != 0) + if ((creationFlags & (ProcessCreationFlags.DebugProcess | + ProcessCreationFlags.DebugOnlyThisProcess)) != 0) { - NtStatus status = Win32.DbgUiConnectToDbg(); + NtStatus status; + + status = Win32.DbgUiConnectToDbg(); - if (status.IsError()) + if (status >= NtStatus.Error) { phandle.Terminate(status); - - status.Throw(); + Win32.Throw(status); } processMsg.DebuggerClientId = ThreadHandle.GetCurrentCid(); @@ -251,28 +267,30 @@ out clientId // hourglass cursor on. if (imageInfo.ImageSubsystem == 2) processMsg.ProcessHandle = processMsg.ProcessHandle.Or((1 | 2).ToIntPtr()); - // We still have to honor the startup info settings, though. - if (startupInfo.Flags.HasFlag(StartupFlags.ForceOnFeedback)) + if ((startupInfo.Flags & StartupFlags.ForceOnFeedback) == + StartupFlags.ForceOnFeedback) processMsg.ProcessHandle = processMsg.ProcessHandle.Or((1).ToIntPtr()); - - if (startupInfo.Flags.HasFlag(StartupFlags.ForceOffFeedback)) + if ((startupInfo.Flags & StartupFlags.ForceOffFeedback) == + StartupFlags.ForceOffFeedback) processMsg.ProcessHandle = processMsg.ProcessHandle.And((1).ToIntPtr().Not()); - using (MemoryAlloc data = new MemoryAlloc(CsrApiMsg.ApiMessageDataOffset + BaseCreateProcessMsg.SizeOf)) + using (var data = new MemoryAlloc( + CsrApiMsg.ApiMessageDataOffset + Marshal.SizeOf(typeof(BaseCreateProcessMsg)) + )) { - data.WriteStruct(CsrApiMsg.ApiMessageDataOffset, BaseCreateProcessMsg.SizeOf, 0, processMsg); + data.WriteStruct(CsrApiMsg.ApiMessageDataOffset, 0, processMsg); Win32.CsrClientCallServer( data, IntPtr.Zero, Win32.CsrMakeApiNumber(Win32.BaseSrvServerDllIndex, (int)BaseSrvApiNumber.BasepCreateProcess), - BaseCreateProcessMsg.SizeOf + Marshal.SizeOf(typeof(BaseCreateProcessMsg)) ); NtStatus status = (NtStatus)data.ReadStruct().ReturnValue; - if (status.IsError()) + if (status >= NtStatus.Error) { phandle.Terminate(status); Win32.Throw(status); @@ -290,11 +308,12 @@ out clientId public static ProcessHandle CreateUserProcess(string fileName, out ClientId clientId, out ThreadHandle threadHandle) { + NtStatus status; UnicodeString fileNameStr = new UnicodeString(fileName); RtlUserProcessParameters processParams = new RtlUserProcessParameters(); RtlUserProcessInformation processInfo; - processParams.Length = RtlUserProcessParameters.SizeOf; + processParams.Length = Marshal.SizeOf(processParams); processParams.MaximumLength = processParams.Length; processParams.ImagePathName = new UnicodeString(fileName); processParams.CommandLine = new UnicodeString(fileName); @@ -303,7 +322,7 @@ public static ProcessHandle CreateUserProcess(string fileName, out ClientId clie try { - Win32.RtlCreateUserProcess( + if ((status = Win32.RtlCreateUserProcess( ref fileNameStr, 0, ref processParams, @@ -314,7 +333,8 @@ public static ProcessHandle CreateUserProcess(string fileName, out ClientId clie IntPtr.Zero, IntPtr.Zero, out processInfo - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); clientId = processInfo.ClientId; threadHandle = new ThreadHandle(processInfo.Thread, true); @@ -344,7 +364,7 @@ out ThreadHandle threadHandle { ProcessInformation processInformation; - startupInfo.Size = StartupInfo.SizeOf; + startupInfo.Size = Marshal.SizeOf(typeof(StartupInfo)); if (!Win32.CreateProcess( applicationName, @@ -381,7 +401,7 @@ out ThreadHandle threadHandle { ProcessInformation processInformation; - startupInfo.Size = StartupInfo.SizeOf; + startupInfo.Size = Marshal.SizeOf(typeof(StartupInfo)); if (!Win32.CreateProcessAsUser( tokenHandle, @@ -428,9 +448,9 @@ public static ProcessHandle GetCurrent() /// Gets the ID of the current process. /// /// The ID of the current process. - public static int CurrentId + public static int GetCurrentId() { - get { return Win32.GetCurrentProcessId(); } + return Win32.GetCurrentProcessId(); } /// @@ -506,7 +526,40 @@ public static ProcessHandle[] OpenByName(string processName, ProcessAccess acces /// A handle. public static ProcessHandle OpenCurrent(ProcessAccess access) { - return new ProcessHandle(CurrentId, access); + return new ProcessHandle(GetCurrentId(), access); + } + + public static ProcessHandle OpenWithAnyAccess(int pid) + { + try + { + return new ProcessHandle(pid, OSVersion.MinProcessQueryInfoAccess); + } + catch + { + try + { + return new ProcessHandle(pid, (ProcessAccess)StandardRights.Synchronize); + } + catch + { + try + { + return new ProcessHandle(pid, (ProcessAccess)StandardRights.ReadControl); + } + catch + { + try + { + return new ProcessHandle(pid, (ProcessAccess)StandardRights.WriteDac); + } + catch + { + return new ProcessHandle(pid, (ProcessAccess)StandardRights.WriteOwner); + } + } + } + } } private ProcessHandle(IntPtr handle, bool owned) @@ -529,11 +582,11 @@ public ProcessHandle(int pid) public ProcessHandle(int pid, ProcessAccess access) { // If we have KPH, use it. - if (KProcessHacker2.Instance.KphIsConnected) + if (KProcessHacker.Instance != null) { try { - this.Handle = KProcessHacker2.Instance.KphOpenProcess(pid, access); + this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenProcess(pid, access)); } catch (WindowsException) { @@ -541,7 +594,9 @@ public ProcessHandle(int pid, ProcessAccess access) // some part of ObReferenceObjectByHandle is hooked. We can // open the process with SYNCHRONIZE access and set the granted access // using KPH. - this.Handle = KProcessHacker2.Instance.KphOpenProcess(pid, (ProcessAccess)StandardRights.Synchronize); + this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenProcess(pid, + (ProcessAccess)StandardRights.Synchronize)); + KProcessHacker.Instance.KphSetHandleGrantedAccess(this.Handle, (int)access); } } else @@ -556,6 +611,19 @@ public ProcessHandle(int pid, ProcessAccess access) } } + /// + /// Opens a thread's process. + /// + /// A handle to a thread. + /// The desired access to the process. + public ProcessHandle(ThreadHandle threadHandle, ProcessAccess access) + { + if (KProcessHacker.Instance == null) + throw new NotSupportedException(); + + this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenThreadProcess(threadHandle, access)); + } + /// /// Opens a process. /// @@ -574,31 +642,34 @@ public ProcessHandle( ProcessAccess access ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { // NtOpenProcess fails when both a client ID and a name is specified. - if (!string.IsNullOrEmpty(name)) + if (name != null) { // Name specified, don't specify a CID. - Win32.NtOpenProcess( + if ((status = Win32.NtOpenProcess( out handle, access, ref oa, IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } else { // No name, specify a CID. - Win32.NtOpenProcess( + if ((status = Win32.NtOpenProcess( out handle, access, ref oa, ref clientId - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } finally @@ -680,14 +751,17 @@ public IntPtr AllocateMemory(IntPtr baseAddress, int size, MemoryFlags type, Mem /// The base address of the allocated pages. public IntPtr AllocateMemory(IntPtr baseAddress, ref IntPtr size, MemoryFlags type, MemoryProtection protection) { - Win32.NtAllocateVirtualMemory( + NtStatus status; + + if ((status = Win32.NtAllocateVirtualMemory( this, ref baseAddress, IntPtr.Zero, ref size, type, protection - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return baseAddress; } @@ -794,7 +868,9 @@ public ThreadHandle CreateThreadWin32(IntPtr startAddress, IntPtr parameter, boo /// A handle to the new thread. public ThreadHandle CreateThreadWin32(IntPtr startAddress, IntPtr parameter, bool createSuspended, out int threadId) { - IntPtr threadHandle = Win32.CreateRemoteThread( + IntPtr threadHandle; + + if ((threadHandle = Win32.CreateRemoteThread( this, IntPtr.Zero, IntPtr.Zero, @@ -802,9 +878,7 @@ public ThreadHandle CreateThreadWin32(IntPtr startAddress, IntPtr parameter, boo parameter, createSuspended ? ProcessCreationFlags.CreateSuspended : 0, out threadId - ); - - if (threadHandle == IntPtr.Zero) + )) == IntPtr.Zero) Win32.Throw(); return new ThreadHandle(threadHandle, true); @@ -817,7 +891,10 @@ out threadId /// A handle to a debug object. public void Debug(DebugObjectHandle debugObjectHandle) { - Win32.NtDebugActiveProcess(this, debugObjectHandle).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtDebugActiveProcess(this, debugObjectHandle)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -827,13 +904,16 @@ public void Debug(DebugObjectHandle debugObjectHandle) /// public void DisableHandleTracing() { + NtStatus status; + // Length 0 and NULL disables handle tracing. - Win32.NtSetInformationProcess( + if ((status = Win32.NtSetInformationProcess( this, ProcessInformationClass.ProcessHandleTracing, IntPtr.Zero, 0 - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -852,14 +932,16 @@ public void EmptyWorkingSet() /// public void EnableHandleTracing() { + NtStatus status; ProcessHandleTracingEnable phte = new ProcessHandleTracingEnable(); - Win32.NtSetInformationProcess( + if ((status = Win32.NtSetInformationProcess( this, ProcessInformationClass.ProcessHandleTracing, ref phte, - ProcessHandleTracingEnable.SizeOf - ).ThrowIf(); + Marshal.SizeOf(phte) + )) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -869,10 +951,10 @@ public void EnableHandleTracing() public void EnumMemory(EnumMemoryDelegate enumMemoryCallback) { IntPtr address = IntPtr.Zero; + MemoryBasicInformation mbi = new MemoryBasicInformation(); + int mbiSize = Marshal.SizeOf(mbi); - MemoryBasicInformation mbi; - - while (Win32.VirtualQueryEx(this, address, out mbi, MemoryBasicInformation.SizeOf) != 0) + while (Win32.VirtualQueryEx(this, address, out mbi, mbiSize) != 0) { if (!enumMemoryCallback(mbi)) break; @@ -905,23 +987,23 @@ private void EnumModulesApi(EnumModulesDelegate enumModulesCallback) if (!Win32.EnumProcessModules(this, moduleHandles, requiredSize, out requiredSize)) Win32.Throw(); - foreach (IntPtr t in moduleHandles) + for (int i = 0; i < moduleHandles.Length; i++) { ModuleInfo moduleInfo = new ModuleInfo(); StringBuilder baseName = new StringBuilder(0x400); StringBuilder fileName = new StringBuilder(0x400); - if (!Win32.GetModuleInformation(this, t, moduleInfo, ModuleInfo.SizeOf)) + if (!Win32.GetModuleInformation(this, moduleHandles[i], moduleInfo, Marshal.SizeOf(moduleInfo))) Win32.Throw(); - if (Win32.GetModuleBaseName(this, t, baseName, baseName.Capacity * 2) == 0) + if (Win32.GetModuleBaseName(this, moduleHandles[i], baseName, baseName.Capacity * 2) == 0) Win32.Throw(); - if (Win32.GetModuleFileNameEx(this, t, fileName, fileName.Capacity * 2) == 0) + if (Win32.GetModuleFileNameEx(this, moduleHandles[i], fileName, fileName.Capacity * 2) == 0) Win32.Throw(); if (!enumModulesCallback(new ProcessModule( - moduleInfo.BaseOfDll, moduleInfo.SizeOfImage, moduleInfo.EntryPoint, 0, - baseName.ToString(), FileUtils.GetFileName(fileName.ToString()) - ))) + moduleInfo.BaseOfDll, moduleInfo.SizeOfImage, moduleInfo.EntryPoint, 0, + baseName.ToString(), FileUtils.GetFileName(fileName.ToString()) + ))) break; } } @@ -941,7 +1023,7 @@ private unsafe void EnumModulesNative(EnumModulesDelegate enumModulesCallback) PebLdrData data; // Read the loader data table structure. - this.ReadMemory(loaderData, &data, PebLdrData.SizeOf); + this.ReadMemory(loaderData, &data, Marshal.SizeOf(typeof(PebLdrData))); if (!data.Initialized) throw new Exception("Loader data is not initialized."); @@ -961,7 +1043,7 @@ private unsafe void EnumModulesNative(EnumModulesDelegate enumModulesCallback) break; // Read the loader data table entry. - this.ReadMemory(currentLink, ¤tEntry, LdrDataTableEntry.SizeOf); + this.ReadMemory(currentLink, ¤tEntry, Marshal.SizeOf(typeof(LdrDataTableEntry))); // Check if the entry is valid. if (currentEntry.DllBase != IntPtr.Zero) @@ -1009,15 +1091,17 @@ private unsafe void EnumModulesNative(EnumModulesDelegate enumModulesCallback) /// A NT status value. public NtStatus FlushMemory(IntPtr baseAddress, int size) { + NtStatus status; IntPtr sizeIntPtr = size.ToIntPtr(); IoStatusBlock isb; - Win32.NtFlushVirtualMemory( + if ((status = Win32.NtFlushVirtualMemory( this, ref baseAddress, ref sizeIntPtr, out isb - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return isb.Status; } @@ -1041,37 +1125,31 @@ public void FreeMemory(IntPtr baseAddress, int size) /// reserve the memory instead of freeing it. public void FreeMemory(IntPtr baseAddress, int size, bool reserveOnly) { + NtStatus status; IntPtr sizeIntPtr = size.ToIntPtr(); // Size needs to be 0 if we're freeing. if (!reserveOnly) sizeIntPtr = IntPtr.Zero; - Win32.NtFreeVirtualMemory( + if ((status = Win32.NtFreeVirtualMemory( this, ref baseAddress, ref sizeIntPtr, reserveOnly ? MemoryFlags.Decommit : MemoryFlags.Release - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } /// - /// Gets/Sets the processor affinity for the process. + /// Gets the processor affinity for the process. /// /// The processor affinity for the process. - public long AffinityMask + public long GetAffinityMask() { - get - { - long systemMask; + long systemMask; - return this.GetAffinityMask(out systemMask); - } - set - { - if (!Win32.SetProcessAffinityMask(this, new IntPtr(value))) - Win32.Throw(); - } + return this.GetAffinityMask(out systemMask); } /// @@ -1095,10 +1173,9 @@ public long GetAffinityMask(out long systemMask) /// /// Gets the base priority of the process. /// - public int BasePriority + public int GetBasePriority() { - get { return this.GetInformationInt32(ProcessInformationClass.ProcessBasePriority); } - set { this.SetInformationInt32(ProcessInformationClass.ProcessBasePriority, value); } + return this.GetInformationInt32(ProcessInformationClass.ProcessBasePriority); } /// @@ -1108,16 +1185,13 @@ public int BasePriority /// A PROCESS_BASIC_INFORMATION structure. public ProcessBasicInformation GetBasicInformation() { + NtStatus status; ProcessBasicInformation pbi; int retLen; - Win32.NtQueryInformationProcess( - this, - ProcessInformationClass.ProcessBasicInformation, - out pbi, - ProcessBasicInformation.SizeOf, - out retLen - ).ThrowIf(); + if ((status = Win32.NtQueryInformationProcess(this, ProcessInformationClass.ProcessBasicInformation, + out pbi, Marshal.SizeOf(typeof(ProcessBasicInformation)), out retLen)) >= NtStatus.Error) + Win32.Throw(status); return pbi; } @@ -1127,15 +1201,12 @@ out retLen /// the PROCESS_QUERY_LIMITED_INFORMATION and PROCESS_VM_READ permissions. /// /// A string. - public string CommandLine + public string GetCommandLine() { - get - { - if (!this.IsPosix) - return this.GetPebString(PebOffset.CommandLine); - + if (!this.IsPosix()) + return this.GetPebString(PebOffset.CommandLine); + else return this.GetPosixCommandLine(); - } } /// @@ -1149,9 +1220,9 @@ public int GetCookie() /// /// Gets the creation time of the process. /// - public DateTime CreateTime + public DateTime GetCreateTime() { - get { return DateTime.FromFileTime(this.GetTimes()[0]); } + return DateTime.FromFileTime(this.GetTimes()[0]); } /// @@ -1173,7 +1244,9 @@ public ulong GetCycleTime() /// A debug object handle. public DebugObjectHandle GetDebugObject() { - IntPtr handle = this.GetDebugObjectHandle(); + IntPtr handle; + + handle = this.GetDebugObjectHandle(); // Check if we got a handle. If we didn't the process is not being debugged. if (handle == IntPtr.Zero) @@ -1188,61 +1261,43 @@ internal IntPtr GetDebugObjectHandle() } /// - /// Gets/Sets the process' DEP policy. + /// Gets the process' DEP policy. /// /// A DepStatus enum. - public DepStatus DepStatus + public DepStatus GetDepStatus() { - get - { - // If we're on 64-bit and the process isn't under - // WOW64, it must be under permanent DEP. - if (OSVersion.Architecture == OSArch.Amd64) - { - if (!this.IsWow64) - return DepStatus.Enabled | DepStatus.Permanent; - } + MemExecuteOptions options; - MemExecuteOptions options = (MemExecuteOptions)this.GetInformationInt32(ProcessInformationClass.ProcessExecuteFlags); - - DepStatus depStatus = 0; + // If we're on 64-bit and the process isn't under + // WOW64, it must be under permanent DEP. + if (OSVersion.Architecture == OSArch.Amd64) + { + if (!this.IsWow64()) + return DepStatus.Enabled | DepStatus.Permanent; + } - // Check if execution of data pages is enabled. - if ((options & MemExecuteOptions.ExecuteEnable) == MemExecuteOptions.ExecuteEnable) - return 0; + options = (MemExecuteOptions)this.GetInformationInt32(ProcessInformationClass.ProcessExecuteFlags); - // Check if execution of data pages is disabled. - if ((options & MemExecuteOptions.ExecuteDisable) == MemExecuteOptions.ExecuteDisable) - depStatus = DepStatus.Enabled; - // ExecuteDisable and ExecuteEnable are both disabled in OptOut mode. - else if ((options & MemExecuteOptions.ExecuteDisable) == 0 && - (options & MemExecuteOptions.ExecuteEnable) == 0) - depStatus = DepStatus.Enabled; + DepStatus depStatus = 0; - if ((options & MemExecuteOptions.DisableThunkEmulation) == MemExecuteOptions.DisableThunkEmulation) - depStatus |= DepStatus.AtlThunkEmulationDisabled; - if ((options & MemExecuteOptions.Permanent) == MemExecuteOptions.Permanent) - depStatus |= DepStatus.Permanent; + // Check if execution of data pages is enabled. + if ((options & MemExecuteOptions.ExecuteEnable) == MemExecuteOptions.ExecuteEnable) + return 0; - return depStatus; - } - set - { - MemExecuteOptions executeOptions = 0; + // Check if execution of data pages is disabled. + if ((options & MemExecuteOptions.ExecuteDisable) == MemExecuteOptions.ExecuteDisable) + depStatus = DepStatus.Enabled; + // ExecuteDisable and ExecuteEnable are both disabled in OptOut mode. + else if ((options & MemExecuteOptions.ExecuteDisable) == 0 && + (options & MemExecuteOptions.ExecuteEnable) == 0) + depStatus = DepStatus.Enabled; - if (value.HasFlag(DepStatus.Enabled)) - executeOptions |= MemExecuteOptions.ExecuteDisable; - else - executeOptions |= MemExecuteOptions.ExecuteEnable; + if ((options & MemExecuteOptions.DisableThunkEmulation) == MemExecuteOptions.DisableThunkEmulation) + depStatus |= DepStatus.AtlThunkEmulationDisabled; + if ((options & MemExecuteOptions.Permanent) == MemExecuteOptions.Permanent) + depStatus |= DepStatus.Permanent; - if (value.HasFlag(DepStatus.AtlThunkEmulationDisabled)) - executeOptions |= MemExecuteOptions.DisableThunkEmulation; - - if (value.HasFlag(DepStatus.Permanent)) - executeOptions |= MemExecuteOptions.Permanent; - - //KProcessHacker.Instance.SetExecuteOptions(this, executeOptions); - } + return depStatus; } /// @@ -1262,7 +1317,7 @@ public unsafe IDictionary GetEnvironmentVariables() // Get a pointer to the environment block. this.ReadMemory(processParameters.Increment(RtlUserProcessParameters.EnvironmentOffset), buffer, IntPtr.Size); IntPtr envBase = *(IntPtr*)buffer; - int length; + int length = 0; { MemoryBasicInformation mbi = this.QueryMemory(envBase); @@ -1356,7 +1411,8 @@ public DateTime GetExitTime() /// /// Gets a GUI handle count. /// - /// If true, returns the number of USER handles. Otherwise, returns the number of GDI handles. + /// If true, returns the number of USER handles. Otherwise, returns + /// the number of GDI handles. /// A handle count. public int GetGuiResources(bool userObjects) { @@ -1375,45 +1431,45 @@ public int GetHandleCount() /// Gets the handles owned by the process. /// /// An array of handle information structures. - //public ProcessHandleInformation[] GetHandles() - //{ - // int returnLength = 0; - // int attempts = 0; - - // using (MemoryAlloc data = new MemoryAlloc(0x1000)) - // { - // while (true) - // { - // try - // { - // //KProcessHacker.Instance.KphQueryProcessHandles(this, data, data.Size, out returnLength); - // } - // catch (WindowsException ex) - // { - // if (attempts > 3) - // throw ex; - - // if ( - // ex.Status == NtStatus.BufferTooSmall && - // returnLength > data.Size - // ) - // data.ResizeNew(returnLength); - - // attempts++; - - // continue; - // } - - // int handleCount = data.ReadInt32(0); - // ProcessHandleInformation[] handles = new ProcessHandleInformation[handleCount]; - - // for (int i = 0; i < handleCount; i++) - // handles[i] = data.ReadStruct(sizeof(int), ProcessHandleInformation.SizeOf, i); - - // return handles; - // } - // } - //} + public ProcessHandleInformation[] GetHandles() + { + int returnLength = 0; + int attempts = 0; + + using (var data = new MemoryAlloc(0x1000)) + { + while (true) + { + try + { + KProcessHacker.Instance.KphQueryProcessHandles(this, data, data.Size, out returnLength); + } + catch (WindowsException ex) + { + if (attempts > 3) + throw ex; + + if ( + ex.Status == NtStatus.BufferTooSmall && + returnLength > data.Size + ) + data.ResizeNew(returnLength); + + attempts++; + + continue; + } + + int handleCount = data.ReadInt32(0); + ProcessHandleInformation[] handles = new ProcessHandleInformation[handleCount]; + + for (int i = 0; i < handleCount; i++) + handles[i] = data.ReadStruct(sizeof(int), i); + + return handles; + } + } + } /// /// Gets a collection of handle stack traces. This requires @@ -1439,17 +1495,15 @@ public ProcessHandleTraceCollection GetHandleTraces(IntPtr handle) NtStatus status = NtStatus.Success; int retLength; - using (MemoryAlloc data = new MemoryAlloc(0x10000)) + using (var data = new MemoryAlloc(0x10000)) { + var query = new ProcessHandleTracingQuery(); + // If Handle is not NULL, NtQueryInformationProcess will // get a specific stack trace. Otherwise, it will get // all of the stack traces. - ProcessHandleTracingQuery query = new ProcessHandleTracingQuery - { - Handle = handle - }; - - data.WriteStruct(query); + query.Handle = handle; + data.WriteStruct(query); for (int i = 0; i < 8; i++) { @@ -1467,7 +1521,8 @@ out retLength continue; } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return new ProcessHandleTraceCollection(data); } @@ -1499,9 +1554,9 @@ public unsafe IntPtr GetHeap() /// QueryLimitedInformation access. /// /// A file name, in native format. - public string ImageFileName + public string GetImageFileName() { - get { return FileUtils.GetFileName(this.GetInformationUnicodeString(ProcessInformationClass.ProcessImageFileName)); } + return this.GetInformationUnicodeString(ProcessInformationClass.ProcessImageFileName); } /// @@ -1515,36 +1570,106 @@ public string GetImageFileNameWin32() } /// - /// Gets/Sets the process' I/O priority, ranging from 0-7. + /// Gets information about the process in an Int32. + /// + /// The class of information to retrieve. + /// An int. + private int GetInformationInt32(ProcessInformationClass infoClass) + { + if ( + KProcessHacker.Instance != null && + infoClass == ProcessInformationClass.ProcessIoPriority + ) + { + unsafe + { + int value; + int retLength; + + KProcessHacker.Instance.KphQueryInformationProcess( + this, infoClass, new IntPtr(&value), sizeof(int), out retLength + ); + + return value; + } + } + else + { + NtStatus status; + int value; + int retLength; + + if ((status = Win32.NtQueryInformationProcess( + this, infoClass, out value, sizeof(int), out retLength)) >= NtStatus.Error) + Win32.Throw(status); + + return value; + } + } + + /// + /// Gets information about the process in an IntPtr. + /// + /// The class of information to retrieve. + /// An IntPtr. + private IntPtr GetInformationIntPtr(ProcessInformationClass infoClass) + { + NtStatus status; + IntPtr value; + int retLength; + + if ((status = Win32.NtQueryInformationProcess( + this, infoClass, out value, IntPtr.Size, out retLength)) >= NtStatus.Error) + Win32.Throw(status); + + return value; + } + + private string GetInformationUnicodeString(ProcessInformationClass infoClass) + { + NtStatus status; + int retLen; + + Win32.NtQueryInformationProcess(this, infoClass, IntPtr.Zero, 0, out retLen); + + using (MemoryAlloc data = new MemoryAlloc(retLen)) + { + if ((status = Win32.NtQueryInformationProcess(this, infoClass, data, retLen, out retLen)) >= NtStatus.Error) + Win32.Throw(status); + + return data.ReadStruct().Read(); + } + } + + /// + /// Gets the process' I/O priority, ranging from 0-7. /// /// - public int IoPriority + public int GetIoPriority() { - get { return this.GetInformationInt32(ProcessInformationClass.ProcessIoPriority); } - set { this.SetInformationInt32(ProcessInformationClass.ProcessIoPriority, value); } - } + return this.GetInformationInt32(ProcessInformationClass.ProcessIoPriority); + } /// /// Gets I/O statistics for the process. /// /// A IoCounters structure. - public IoCounters IoStatistics + public IoCounters GetIoStatistics() { - get - { - IoCounters counters; - int retLength; + NtStatus status; + IoCounters counters; + int retLength; - Win32.NtQueryInformationProcess( - this, - ProcessInformationClass.ProcessIoCounters, - out counters, - IoCounters.SizeOf, - out retLength - ).ThrowIf(); + if ((status = Win32.NtQueryInformationProcess( + this, + ProcessInformationClass.ProcessIoCounters, + out counters, + Marshal.SizeOf(typeof(IoCounters)), + out retLength + )) >= NtStatus.Error) + Win32.Throw(status); - return counters; - } + return counters; } /// @@ -1553,50 +1678,51 @@ out retLength /// A job object handle. public JobObjectHandle GetJobObject(JobObjectAccess access) { - IntPtr handle = JobObjectHandle.Open(this, access); + IntPtr handle; + + handle = JobObjectHandle.Open(this, access); if (handle != IntPtr.Zero) return new JobObjectHandle(handle, true); - - return null; + else + return null; } /// /// Gets the type of well-known process. /// /// A known process type. - public KnownProcess KnownProcessType + public KnownProcess GetKnownProcessType() { - get - { - if (this.GetBasicInformation().UniqueProcessId.Equals(4)) - return KnownProcess.System; + if (this.GetBasicInformation().UniqueProcessId.Equals(4)) + return KnownProcess.System; - string fileName = this.ImageFileName; + string fileName = FileUtils.GetFileName(this.GetImageFileName()); - if (fileName.StartsWith(Environment.SystemDirectory, StringComparison.OrdinalIgnoreCase)) - { - string baseName = fileName.Remove(0, Environment.SystemDirectory.Length).TrimStart('\\').ToLowerInvariant(); + if (fileName.StartsWith(Environment.SystemDirectory, StringComparison.OrdinalIgnoreCase)) + { + string baseName = fileName.Remove(0, Environment.SystemDirectory.Length).TrimStart('\\').ToLowerInvariant(); - switch (baseName) - { - case "smss.exe": - return KnownProcess.SessionManager; - case "csrss.exe": - return KnownProcess.WindowsSubsystem; - case "wininit.exe": - return KnownProcess.WindowsStartup; - case "services.exe": - return KnownProcess.ServiceControlManager; - case "lsass.exe": - return KnownProcess.LocalSecurityAuthority; - case "lsm.exe": - return KnownProcess.LocalSessionManager; - default: - return KnownProcess.None; - } + switch (baseName) + { + case "smss.exe": + return KnownProcess.SessionManager; + case "csrss.exe": + return KnownProcess.WindowsSubsystem; + case "wininit.exe": + return KnownProcess.WindowsStartup; + case "services.exe": + return KnownProcess.ServiceControlManager; + case "lsass.exe": + return KnownProcess.LocalSecurityAuthority; + case "lsm.exe": + return KnownProcess.LocalSessionManager; + default: + return KnownProcess.None; } - + } + else + { return KnownProcess.None; } } @@ -1606,20 +1732,17 @@ public KnownProcess KnownProcessType /// PROCESS_QUERY_INFORMATION and PROCESS_VM_READ permissions. /// /// A ProcessModule. - public ProcessModule MainModule + public ProcessModule GetMainModule() { - get - { - ProcessModule mainModule = null; + ProcessModule mainModule = null; - this.EnumModules(module => - { - mainModule = module; - return false; - }); + this.EnumModules((module) => + { + mainModule = module; + return false; + }); - return mainModule; - } + return mainModule; } /// @@ -1655,10 +1778,10 @@ out retLength ); } - if (status.IsError()) + if (status >= NtStatus.Error) return null; - return FileUtils.GetFileName(data.ReadStruct().Text); + return FileUtils.GetFileName(data.ReadStruct().Read()); } } @@ -1666,23 +1789,22 @@ out retLength /// Gets memory statistics for the process. /// /// A VmCounters structure. - public VmCounters MemoryStatistics + public VmCounters GetMemoryStatistics() { - get - { - VmCounters counters; - int retLength; + NtStatus status; + VmCounters counters; + int retLength; - Win32.NtQueryInformationProcess( - this, - ProcessInformationClass.ProcessVmCounters, - out counters, - VmCounters.SizeOf, - out retLength - ).ThrowIf(); + if ((status = Win32.NtQueryInformationProcess( + this, + ProcessInformationClass.ProcessVmCounters, + out counters, + Marshal.SizeOf(typeof(VmCounters)), + out retLength + )) >= NtStatus.Error) + Win32.Throw(status); - return counters; - } + return counters; } /// @@ -1694,7 +1816,7 @@ public ProcessModule[] GetModules() { List modules = new List(); - this.EnumModules(module => + this.EnumModules((module) => { modules.Add(module); return true; @@ -1710,20 +1832,22 @@ public ProcessModule[] GetModules() /// A process handle. public ProcessHandle GetNextProcess(ProcessAccess access) { + NtStatus status; IntPtr handle; - Win32.NtGetNextProcess( + if ((status = Win32.NtGetNextProcess( this, access, 0, 0, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (handle != IntPtr.Zero) return new ProcessHandle(handle, true); - - return null; + else + return null; } /// @@ -1734,30 +1858,31 @@ out handle /// A thread handle. public ThreadHandle GetNextThread(ThreadHandle threadHandle, ThreadAccess access) { + NtStatus status; IntPtr handle; - Win32.NtGetNextThread( + if ((status = Win32.NtGetNextThread( this, - threadHandle ?? IntPtr.Zero, + threadHandle != null ? threadHandle : IntPtr.Zero, access, 0, 0, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (handle != IntPtr.Zero) return new ThreadHandle(handle, true); - - return null; + else + return null; } /// /// Gets the process' page priority, ranging from 0-7. /// - public int PagePriority + public int GetPagePriority() { - get { return this.GetInformationInt32(ProcessInformationClass.ProcessPagePriority); } - set { this.SetInformationInt32(ProcessInformationClass.ProcessPagePriority, value); } + return this.GetInformationInt32(ProcessInformationClass.ProcessPagePriority); } /// @@ -1765,9 +1890,9 @@ public int PagePriority /// the PROCESS_QUERY_LIMITED_INFORMATION permission. /// /// The process ID. - public int ParentPid + public int GetParentPid() { - get { return this.GetBasicInformation().InheritedFromUniqueProcessId.ToInt32(); } + return this.GetBasicInformation().InheritedFromUniqueProcessId.ToInt32(); } /// @@ -1790,7 +1915,7 @@ public unsafe string GetPebString(PebOffset offset) // Read the UNICODE_STRING structure. UnicodeString pebStr; - this.ReadMemory(processParameters.Increment(realOffset), &pebStr, UnicodeString.SizeOf); + this.ReadMemory(processParameters.Increment(realOffset), &pebStr, Marshal.SizeOf(typeof(UnicodeString))); // read string and decode it return Encoding.Unicode.GetString(this.ReadMemory(pebStr.Buffer, pebStr.Length), 0, pebStr.Length); @@ -1815,9 +1940,8 @@ public unsafe string GetPosixCommandLine() this.ReadMemory( processParameters.Increment(GetPebOffset(PebOffset.CommandLine)), &commandLineUs, - UnicodeString.SizeOf + Marshal.SizeOf(typeof(UnicodeString)) ); - IntPtr stringAddr = commandLineUs.Buffer; /* @@ -1852,8 +1976,7 @@ public unsafe string GetPosixCommandLine() if (zeroReached) break; - - if (value == IntPtr.Zero) + else if (value == IntPtr.Zero) zeroReached = true; } @@ -1880,56 +2003,61 @@ public unsafe string GetPosixCommandLine() } /// - /// Gets/Sets the process' priority class. + /// Gets the process' priority class. /// /// A ProcessPriorityClass enum. - public ProcessPriorityClass PriorityClass - { - get - { - ProcessPriorityClassStruct priorityClass; - int retLength; - - Win32.NtQueryInformationProcess( - this, - ProcessInformationClass.ProcessPriorityClass, - out priorityClass, - ProcessPriorityClassStruct.SizeOf, - out retLength - ).ThrowIf(); + public ProcessPriorityClass GetPriorityClass() + { + //switch (Win32.GetPriorityClass(this)) + //{ + // case ProcessPriorityClassWin32.AboveNormal: + // return ProcessPriorityClass.AboveNormal; + // case ProcessPriorityClassWin32.BelowNormal: + // return ProcessPriorityClass.BelowNormal; + // case ProcessPriorityClassWin32.High: + // return ProcessPriorityClass.High; + // case ProcessPriorityClassWin32.Idle: + // return ProcessPriorityClass.Idle; + // case ProcessPriorityClassWin32.Normal: + // return ProcessPriorityClass.Normal; + // case ProcessPriorityClassWin32.RealTime: + // return ProcessPriorityClass.RealTime; + // default: + // Win32.Throw(); + // // Stupid compiler + // return ProcessPriorityClass.Unknown; + //} - return (ProcessPriorityClass)priorityClass.PriorityClass; - } - set - { - ProcessPriorityClassStruct processPriority; + NtStatus status; + ProcessPriorityClassStruct priorityClass; + int retLength; - processPriority.Foreground = '\0'; - processPriority.PriorityClass = Convert.ToChar(value); + if ((status = Win32.NtQueryInformationProcess( + this, + ProcessInformationClass.ProcessPriorityClass, + out priorityClass, + Marshal.SizeOf(typeof(ProcessPriorityClassStruct)), + out retLength + )) != NtStatus.Success) + Win32.Throw(status); - Win32.NtSetInformationProcess( - this, - ProcessInformationClass.ProcessPriorityClass, - ref processPriority, - ProcessPriorityClassStruct.SizeOf - ).ThrowIf(); - } + return (ProcessPriorityClass)priorityClass.PriorityClass; } /// /// Gets the process' unique identifier. /// - public int ProcessId + public int GetProcessId() { - get { return this.GetBasicInformation().UniqueProcessId.ToInt32(); } + return this.GetBasicInformation().UniqueProcessId.ToInt32(); } /// /// Gets the process' session ID. /// - public int SessionId + public int GetSessionId() { - get { return this.GetInformationInt32(ProcessInformationClass.ProcessSessionInformation); } + return this.GetInformationInt32(ProcessInformationClass.ProcessSessionInformation); } /// @@ -2012,20 +2140,17 @@ public void InjectDll(string path, uint timeout) /// Gets whether the process is currently being debugged. This requires /// QueryInformation access. /// - public bool IsBeingDebugged + public bool IsBeingDebugged() { - get { return this.GetInformationIntPtr(ProcessInformationClass.ProcessDebugPort) != IntPtr.Zero; } + return this.GetInformationIntPtr(ProcessInformationClass.ProcessDebugPort) != IntPtr.Zero; } /// - /// Gets/Sets whether the system will crash upon the process being terminated. - /// This function requires SeTcbPrivilege. - /// Whether the system will crash upon the process being terminated. + /// Gets whether the system will crash upon the process being terminated. /// - public bool IsCritical + public bool IsCritical() { - get { return this.GetInformationInt32(ProcessInformationClass.ProcessBreakOnTermination) != 0; } - set { this.SetInformationInt32(ProcessInformationClass.ProcessBreakOnTermination, value ? 1 : 0); } + return this.GetInformationInt32(ProcessInformationClass.ProcessBreakOnTermination) != 0; } /// @@ -2060,46 +2185,38 @@ public bool IsInJob(JobObjectHandle jobObjectHandle) /// /// Gets whether the process is a NTVDM process. /// - public bool IsNtVdmProcess + public bool IsNtVdmProcess() { - get { return this.GetInformationInt32(ProcessInformationClass.ProcessWx86Information) != 0; } + return this.GetInformationInt32(ProcessInformationClass.ProcessWx86Information) != 0; } /// /// Gets whether the process is using the POSIX subsystem. /// - public unsafe bool IsPosix + public unsafe bool IsPosix() { - get - { - int subsystem; - IntPtr pebBaseAddress = this.GetBasicInformation().PebBaseAddress; + int subsystem; + IntPtr pebBaseAddress = this.GetBasicInformation().PebBaseAddress; - this.ReadMemory(pebBaseAddress.Increment(Peb.ImageSubsystemOffset), &subsystem, sizeof(int)); + this.ReadMemory(pebBaseAddress.Increment(Peb.ImageSubsystemOffset), &subsystem, sizeof(int)); - return subsystem == 7; - } + return subsystem == 7; } /// - /// Gets/Sets whether the process has priority boost enabled. + /// Gets whether the process has priority boost enabled. /// - public bool IsPriorityBoostEnabled + public bool IsPriorityBoostEnabled() { - get { return this.GetInformationInt32(ProcessInformationClass.ProcessPriorityBoost) == 0; } - set - { - // If priority boost is being enabled, we have to not disable it (hence the value of 0). - this.SetInformationInt32(ProcessInformationClass.ProcessPriorityBoost, value ? 0 : 1); - } + return this.GetInformationInt32(ProcessInformationClass.ProcessPriorityBoost) == 0; } /// /// Gets whether the process is running under WOW64. /// - public bool IsWow64 + public bool IsWow64() { - get { return this.GetInformationIntPtr(ProcessInformationClass.ProcessWow64Information) != IntPtr.Zero; } + return this.GetInformationIntPtr(ProcessInformationClass.ProcessWow64Information) != IntPtr.Zero; } /// @@ -2111,16 +2228,18 @@ public bool IsWow64 /// The old memory protection. public MemoryProtection ProtectMemory(IntPtr baseAddress, int size, MemoryProtection protection) { + NtStatus status; IntPtr sizeIntPtr = size.ToIntPtr(); MemoryProtection oldProtection; - Win32.NtProtectVirtualMemory( + if ((status = Win32.NtProtectVirtualMemory( this, ref baseAddress, ref sizeIntPtr, protection, out oldProtection - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return oldProtection; } @@ -2132,17 +2251,19 @@ out oldProtection /// A MEMORY_BASIC_INFORMATION structure. public MemoryBasicInformation QueryMemory(IntPtr baseAddress) { + NtStatus status; MemoryBasicInformation mbi; IntPtr retLength; - Win32.NtQueryVirtualMemory( + if ((status = Win32.NtQueryVirtualMemory( this, baseAddress, MemoryInformationClass.MemoryBasicInformation, out mbi, - MemoryBasicInformation.SizeOf.ToIntPtr(), + Marshal.SizeOf(typeof(MemoryBasicInformation)).ToIntPtr(), out retLength - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return mbi; } @@ -2196,23 +2317,34 @@ public unsafe int ReadMemory(IntPtr baseAddress, void* buffer, int length) /// The number of bytes read. public int ReadMemory(IntPtr baseAddress, IntPtr buffer, int length) { + int retLength; + if (this.Handle == Current) { Win32.RtlMoveMemory(buffer, baseAddress, length.ToIntPtr()); return length; } - IntPtr retLengthIntPtr; - - Win32.NtReadVirtualMemory( - this, - baseAddress, - buffer, - length.ToIntPtr(), - out retLengthIntPtr - ).ThrowIf(); + if (KProcessHacker.Instance != null) + { + KProcessHacker.Instance.KphReadVirtualMemory(this, baseAddress.ToInt32(), buffer, length, out retLength); + } + else + { + NtStatus status; + IntPtr retLengthIntPtr; - int retLength = retLengthIntPtr.ToInt32(); + if ((status = Win32.NtReadVirtualMemory( + this, + baseAddress, + buffer, + length.ToIntPtr(), + out retLengthIntPtr + )) >= NtStatus.Error) + Win32.Throw(status); + + retLength = retLengthIntPtr.ToInt32(); + } return retLength; } @@ -2244,7 +2376,10 @@ public ThreadHandle RemoteCall(IntPtr address, IntPtr[] arguments) /// The debug object which was used to debug the process. public void RemoveDebug(DebugObjectHandle debugObjectHandle) { - Win32.NtRemoveProcessDebug(this, debugObjectHandle).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRemoveProcessDebug(this, debugObjectHandle)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -2252,7 +2387,101 @@ public void RemoveDebug(DebugObjectHandle debugObjectHandle) /// public void Resume() { - Win32.NtResumeProcess(this).ThrowIf(); + if (KProcessHacker.Instance != null && OSVersion.HasPsSuspendResumeProcess) + { + KProcessHacker.Instance.KphResumeProcess(this); + } + else + { + NtStatus status; + + if ((status = Win32.NtResumeProcess(this)) >= NtStatus.Error) + Win32.Throw(status); + } + } + + /// + /// Sets the processor affinity for the process. + /// + /// The processor affinity mask. + public void SetAffinityMask(long processMask) + { + if (!Win32.SetProcessAffinityMask(this, new IntPtr(processMask))) + Win32.Throw(); + } + + /// + /// Sets the process' base priority. + /// + /// The process' base priority. + public void SetBasePriority(int basePriority) + { + this.SetInformationInt32(ProcessInformationClass.ProcessBasePriority, basePriority); + } + + /// + /// Sets whether the system will crash upon the process being terminated. + /// This function requires SeTcbPrivilege. + /// + /// Whether the system will crash upon the process being terminated. + public void SetCritical(bool critical) + { + this.SetInformationInt32(ProcessInformationClass.ProcessBreakOnTermination, critical ? 1 : 0); + } + + /// + /// Sets the process' DEP policy. + /// + /// The DEP options. + public void SetDepStatus(DepStatus depStatus) + { + MemExecuteOptions executeOptions = 0; + + if ((depStatus & DepStatus.Enabled) == DepStatus.Enabled) + executeOptions |= MemExecuteOptions.ExecuteDisable; + else + executeOptions |= MemExecuteOptions.ExecuteEnable; + + if ((depStatus & DepStatus.AtlThunkEmulationDisabled) == DepStatus.AtlThunkEmulationDisabled) + executeOptions |= MemExecuteOptions.DisableThunkEmulation; + if ((depStatus & DepStatus.Permanent) == DepStatus.Permanent) + executeOptions |= MemExecuteOptions.Permanent; + + KProcessHacker.Instance.SetExecuteOptions(this, executeOptions); + } + + /// + /// Sets information about the process in an Int32. + /// + /// The class of information to set. + /// The value to set. + private void SetInformationInt32(ProcessInformationClass infoClass, int value) + { + if ( + KProcessHacker.Instance != null && + infoClass == ProcessInformationClass.ProcessIoPriority + ) + { + unsafe + { + KProcessHacker.Instance.KphSetInformationProcess( + this, infoClass, new IntPtr(&value), sizeof(int) + ); + } + } + else + { + NtStatus status; + + if ((status = Win32.NtSetInformationProcess( + this, infoClass, ref value, sizeof(int))) >= NtStatus.Error) + Win32.Throw(status); + } + } + + public void SetIoPriority(int ioPriority) + { + this.SetInformationInt32(ProcessInformationClass.ProcessIoPriority, ioPriority); } /// @@ -2273,7 +2502,7 @@ public unsafe void SetModuleReferenceCount(IntPtr baseAddress, ushort count) IntPtr loaderData = *(IntPtr*)buffer; PebLdrData data; - this.ReadMemory(loaderData, &data, PebLdrData.SizeOf); + this.ReadMemory(loaderData, &data, Marshal.SizeOf(typeof(PebLdrData))); if (!data.Initialized) throw new Exception("Loader data is not initialized."); @@ -2291,7 +2520,7 @@ public unsafe void SetModuleReferenceCount(IntPtr baseAddress, ushort count) if (i > 0x800) break; - this.ReadMemory(currentLink, ¤tEntry, LdrDataTableEntry.SizeOf); + this.ReadMemory(currentLink, ¤tEntry, Marshal.SizeOf(typeof(LdrDataTableEntry))); if (currentEntry.DllBase == baseAddress) { @@ -2304,13 +2533,87 @@ public unsafe void SetModuleReferenceCount(IntPtr baseAddress, ushort count) } } + public void SetPagePriority(int pagePriority) + { + this.SetInformationInt32(ProcessInformationClass.ProcessPagePriority, pagePriority); + } + + /// + /// Sets the process' priority boost. + /// + /// Whether priority boost will be enabled. + public void SetPriorityBoost(bool enabled) + { + // If priority boost is being enabled, we have to not disable it (hence the value of 0). + this.SetInformationInt32(ProcessInformationClass.ProcessPriorityBoost, enabled ? 0 : 1); + } + + /// + /// Sets the process' priority class. + /// + /// The process' priority class. + public void SetPriorityClass(ProcessPriorityClass priorityClass) + { + //ProcessPriorityClassWin32 pcWin32; + + //switch (priorityClass) + //{ + // case ProcessPriorityClass.AboveNormal: + // pcWin32 = ProcessPriorityClassWin32.AboveNormal; + // break; + // case ProcessPriorityClass.BelowNormal: + // pcWin32 = ProcessPriorityClassWin32.BelowNormal; + // break; + // case ProcessPriorityClass.High: + // pcWin32 = ProcessPriorityClassWin32.High; + // break; + // case ProcessPriorityClass.Idle: + // pcWin32 = ProcessPriorityClassWin32.Idle; + // break; + // case ProcessPriorityClass.Normal: + // pcWin32 = ProcessPriorityClassWin32.Normal; + // break; + // case ProcessPriorityClass.RealTime: + // pcWin32 = ProcessPriorityClassWin32.RealTime; + // break; + // default: + // throw new ArgumentException("priorityClass"); + //} + + //if (!Win32.SetPriorityClass(this, pcWin32)) + // Win32.Throw(); + + NtStatus status; + ProcessPriorityClassStruct processPriority; + + processPriority.Foreground = '\0'; + processPriority.PriorityClass = Convert.ToChar(priorityClass); + + if ((status = Win32.NtSetInformationProcess( + this, + ProcessInformationClass.ProcessPriorityClass, + ref processPriority, + Marshal.SizeOf(typeof(ProcessPriorityClassStruct)) + )) != NtStatus.Success) + Win32.Throw(status); + } /// /// Suspends the process. This requires PROCESS_SUSPEND_RESUME access. /// public void Suspend() { - Win32.NtSuspendProcess(this).ThrowIf(); + if (KProcessHacker.Instance != null && OSVersion.HasPsSuspendResumeProcess) + { + KProcessHacker.Instance.KphSuspendProcess(this); + } + else + { + NtStatus status; + + if ((status = Win32.NtSuspendProcess(this)) >= NtStatus.Error) + Win32.Throw(status); + } } /// @@ -2327,7 +2630,17 @@ public void Terminate() /// The exit status. public void Terminate(NtStatus exitStatus) { - Win32.NtTerminateProcess(this, exitStatus).ThrowIf(); + if (KProcessHacker.Instance != null) + { + KProcessHacker.Instance.KphTerminateProcess(this, exitStatus); + } + else + { + NtStatus status; + + if ((status = Win32.NtTerminateProcess(this, exitStatus)) >= NtStatus.Error) + Win32.Throw(status); + } } /// @@ -2353,10 +2666,8 @@ public void WriteDump(string fileName) /// The type of minidump to write. public void WriteDump(string fileName, MinidumpType type) { - using (FileHandle fhandle = FileHandle.CreateWin32(fileName, FileAccess.GenericWrite)) - { + using (var fhandle = FileHandle.CreateWin32(fileName, FileAccess.GenericWrite)) this.WriteDump(fhandle, type); - } } /// @@ -2368,7 +2679,7 @@ public void WriteDump(FileHandle fileHandle, MinidumpType type) { if (!Win32.MiniDumpWriteDump( this, - this.ProcessId, + this.GetProcessId(), fileHandle, type, IntPtr.Zero, @@ -2384,11 +2695,14 @@ public void WriteDump(FileHandle fileHandle, MinidumpType type) /// The offset at which to begin writing. /// The data to write. /// The length, in bytes, that was written. - public unsafe int WriteMemory(IntPtr baseAddress, byte[] buffer) + public int WriteMemory(IntPtr baseAddress, byte[] buffer) { - fixed (byte* dataPtr = buffer) + unsafe { - return WriteMemory(baseAddress, dataPtr, buffer.Length); + fixed (byte* dataPtr = buffer) + { + return WriteMemory(baseAddress, dataPtr, buffer.Length); + } } } @@ -2413,94 +2727,36 @@ public unsafe int WriteMemory(IntPtr baseAddress, void* buffer, int length) /// The length, in bytes, that was written. public int WriteMemory(IntPtr baseAddress, IntPtr buffer, int length) { + int retLength; + if (this.Handle == Current) { Win32.RtlMoveMemory(baseAddress, buffer, length.ToIntPtr()); return length; } - IntPtr retLengthIntPtr; - - Win32.NtWriteVirtualMemory( - this, - baseAddress, - buffer, - length.ToIntPtr(), - out retLengthIntPtr - ).ThrowIf(); - - return retLengthIntPtr.ToInt32(); - } - - /// - /// Gets information about the process in an Int32. - /// - /// The class of information to retrieve. - /// An int. - private int GetInformationInt32(ProcessInformationClass infoClass) - { - int value; - int retLength; - - Win32.NtQueryInformationProcess( - this, - infoClass, - out value, - sizeof(int), - out retLength - ).ThrowIf(); - - return value; - } - - /// - /// Gets information about the process in an IntPtr. - /// - /// The class of information to retrieve. - /// An IntPtr. - private IntPtr GetInformationIntPtr(ProcessInformationClass infoClass) - { - IntPtr value; - int retLength; - - Win32.NtQueryInformationProcess( - this, - infoClass, - out value, - IntPtr.Size, - out retLength - ).ThrowIf(); - - return value; - } - - private string GetInformationUnicodeString(ProcessInformationClass infoClass) - { - int retLen; - - Win32.NtQueryInformationProcess(this, infoClass, IntPtr.Zero, 0, out retLen); - - using (MemoryAlloc data = new MemoryAlloc(retLen)) + if (KProcessHacker.Instance != null) { - Win32.NtQueryInformationProcess(this, infoClass, data, retLen, out retLen).ThrowIf(); + KProcessHacker.Instance.KphWriteVirtualMemory(this, baseAddress.ToInt32(), buffer, length, out retLength); + } + else + { + NtStatus status; + IntPtr retLengthIntPtr; - return data.ReadStruct().Text; + if ((status = Win32.NtWriteVirtualMemory( + this, + baseAddress, + buffer, + length.ToIntPtr(), + out retLengthIntPtr + )) >= NtStatus.Error) + Win32.Throw(status); + + retLength = retLengthIntPtr.ToInt32(); } - } - /// - /// Sets information about the process in an Int32. - /// - /// The class of information to set. - /// The value to set. - private void SetInformationInt32(ProcessInformationClass infoClass, int value) - { - Win32.NtSetInformationProcess( - this, - infoClass, - ref value, - sizeof(int) - ).ThrowIf(); + return retLength; } } @@ -2509,10 +2765,10 @@ private void SetInformationInt32(ProcessInformationClass infoClass, int value) /// public class ProcessHandleTrace { - private readonly ClientId _clientId; - private readonly IntPtr _handle; - private readonly IntPtr[] _stack; - private readonly HandleTraceType _type; + private ClientId _clientId; + private IntPtr _handle; + private IntPtr[] _stack; + private HandleTraceType _type; internal ProcessHandleTrace(ProcessHandleTracingEntry entry) { @@ -2521,7 +2777,7 @@ internal ProcessHandleTrace(ProcessHandleTracingEntry entry) _type = entry.Type; // Find the first occurrence of a NULL to find where the trace stops. - int zeroIndex = Array.IndexOf(entry.Stacks, IntPtr.Zero); + int zeroIndex = Array.IndexOf(entry.Stacks, IntPtr.Zero); // If there was no NULL, copy the entire array. if (zeroIndex == -1) @@ -2570,16 +2826,16 @@ public HandleTraceType Type /// public class ProcessHandleTraceCollection : ReadOnlyCollection { - private readonly IntPtr _handle; + private IntPtr _handle; internal ProcessHandleTraceCollection(MemoryAlloc data) : base(new List()) { - if (data.Size < ProcessHandleTracingEntry.SizeOf) + if (data.Size < Marshal.SizeOf(typeof(ProcessHandleTracingQuery))) throw new ArgumentException("Data memory allocation is too small."); // Read the structure. - ProcessHandleTracingQuery query = data.ReadStruct(); + var query = data.ReadStruct(); _handle = query.Handle; @@ -2588,9 +2844,8 @@ internal ProcessHandleTraceCollection(MemoryAlloc data) for (int i = 0; i < query.TotalTraces; i++) { - ProcessHandleTracingEntry entry = data.ReadStruct( - ProcessHandleTracingQuery.HandleTraceOffset, - ProcessHandleTracingEntry.SizeOf, + var entry = data.ReadStruct( + ProcessHandleTracingQuery.HandleTraceOffset, i ); diff --git a/1.x/trunk/ProcessHacker.Native/Objects/ProfileHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/ProfileHandle.cs index cad79dca2..73000759d 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/ProfileHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/ProfileHandle.cs @@ -38,6 +38,7 @@ public static ProfileHandle Create( IntPtr affinity ) { + NtStatus status; IntPtr handle; if (bucketSize < 2 || bucketSize > 30) @@ -48,7 +49,7 @@ IntPtr affinity uint realBucketSize = (uint)(2 << (bucketSize - 1)); MemoryAlloc buffer = new MemoryAlloc((int)((rangeSize - 1) / realBucketSize + 1) * sizeof(int)); // divide, round up - Win32.NtCreateProfile( + if ((status = Win32.NtCreateProfile( out handle, processHandle ?? IntPtr.Zero, rangeBase, @@ -58,7 +59,8 @@ IntPtr affinity buffer.Size, profileSource, affinity - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new ProfileHandle(handle, true, rangeBase, rangeSize, realBucketSize, buffer); } @@ -66,19 +68,27 @@ IntPtr affinity public static int GetInterval(KProfileSource profileSource) { + NtStatus status; int interval; - Win32.NtQueryIntervalProfile(profileSource, out interval).ThrowIf(); + if ((status = Win32.NtQueryIntervalProfile(profileSource, out interval)) >= NtStatus.Error) + Win32.Throw(status); return interval; } public static void SetInterval(KProfileSource profileSource, int interval) { - Win32.NtSetIntervalProfile(interval, profileSource).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtSetIntervalProfile(interval, profileSource)) >= NtStatus.Error) + Win32.Throw(status); } - private readonly MemoryAlloc _buffer; + private IntPtr _rangeBase; + private uint _rangeSize; + private uint _bucketSize; // not logarithmic + private MemoryAlloc _buffer; private ProfileHandle( IntPtr handle, @@ -90,6 +100,9 @@ MemoryAlloc buffer ) : base(handle, owned) { + _rangeBase = rangeBase; + _rangeSize = rangeSize; + _bucketSize = bucketSize; _buffer = buffer; } @@ -111,12 +124,18 @@ public int[] Collect() public void Start() { - Win32.NtStartProfile(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtStartProfile(this)) >= NtStatus.Error) + Win32.Throw(status); } public void Stop() { - Win32.NtStopProfile(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtStopProfile(this)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/RemoteHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/RemoteHandle.cs index d33c3ea84..2e2e0f757 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/RemoteHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/RemoteHandle.cs @@ -29,8 +29,8 @@ namespace ProcessHacker.Native.Objects /// public class RemoteHandle { - private readonly ProcessHandle _phandle; - private readonly IntPtr _handle; + private ProcessHandle _phandle; + private IntPtr _handle; public RemoteHandle(ProcessHandle phandle, IntPtr handle) { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/RemoteTokenHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/RemoteTokenHandle.cs index 379dbf3e4..6f3b6ae82 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/RemoteTokenHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/RemoteTokenHandle.cs @@ -42,7 +42,7 @@ public RemoteTokenHandle(ProcessHandle phandle, IntPtr handle) public new IntPtr GetHandle(int rights) { - IntPtr newHandle; + IntPtr newHandle = IntPtr.Zero; // We can use KPH here. RemoteHandle doesn't. Win32.DuplicateObject(this.ProcessHandle, this.Handle, new IntPtr(-1), out newHandle, rights, 0, 0); diff --git a/1.x/trunk/ProcessHacker.Native/Objects/ResourceManagerHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/ResourceManagerHandle.cs index f38161e7c..90dbe9f6b 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/ResourceManagerHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/ResourceManagerHandle.cs @@ -39,26 +39,34 @@ public static ResourceManagerHandle Create( string description ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; - UnicodeString descriptionStr = new UnicodeString(description); try { - Win32.NtCreateResourceManager( - out handle, - access, - tmHandle, - ref guid, - ref oa, - createOptions, - ref descriptionStr - ).ThrowIf(); + UnicodeString descriptionStr = new UnicodeString(description); + + try + { + if ((status = Win32.NtCreateResourceManager( + out handle, + access, + tmHandle, + ref guid, + ref oa, + createOptions, + ref descriptionStr + )) >= NtStatus.Error) + Win32.Throw(status); + } + finally + { + descriptionStr.Dispose(); + } } finally { - descriptionStr.Dispose(); - oa.Dispose(); } @@ -83,18 +91,20 @@ public ResourceManagerHandle( ResourceManagerAccess access ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenResourceManager( + if ((status = Win32.NtOpenResourceManager( out handle, access, tmHandle, ref guid, ref oa - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -109,7 +119,7 @@ private MemoryAlloc GetBasicInformation() NtStatus status; int retLength; - MemoryAlloc data = new MemoryAlloc(0x1000); + var data = new MemoryAlloc(0x1000); status = Win32.NtQueryInformationResourceManager( this, @@ -133,7 +143,7 @@ out retLength ); } - if (status.IsError()) + if (status >= NtStatus.Error) { data.Dispose(); Win32.Throw(status); @@ -142,36 +152,33 @@ out retLength return data; } - public string Description + public string GetDescription() { - get + using (var data = this.GetBasicInformation()) { - using (MemoryAlloc data = this.GetBasicInformation()) - { - ResourceManagerBasicInformation basicInfo = data.ReadStruct(); + var basicInfo = data.ReadStruct(); - return data.ReadUnicodeString( - ResourceManagerBasicInformation.DescriptionOffset, - basicInfo.DescriptionLength / 2 - ); - } + return data.ReadUnicodeString( + ResourceManagerBasicInformation.DescriptionOffset, + basicInfo.DescriptionLength / 2 + ); } } - public Guid Guid + public Guid GetGuid() { - get + using (var data = this.GetBasicInformation()) { - using (MemoryAlloc data = this.GetBasicInformation()) - { - return data.ReadStruct().ResourceManagerId; - } + return data.ReadStruct().ResourceManagerId; } } public void Recover() { - Win32.NtRecoverResourceManager(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRecoverResourceManager(this)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SamAliasHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SamAliasHandle.cs index 954f49183..8c328e0a8 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SamAliasHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SamAliasHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -33,19 +34,22 @@ public sealed class SamAliasHandle : SamHandle { public static SamAliasHandle Create(SamAliasAccess access, SamDomainHandle domainHandle, string name, out int aliasId) { + NtStatus status; + UnicodeString nameStr; IntPtr handle; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.SamCreateAliasInDomain( + if ((status = Win32.SamCreateAliasInDomain( domainHandle, ref nameStr, access, out handle, out aliasId - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -62,7 +66,7 @@ public static SamAliasHandle Open(string name, SamAliasAccess access) public static SamAliasHandle Open(Sid sid, SamAliasAccess access) { - using (SamDomainHandle dhandle = new SamDomainHandle(sid.DomainName, SamDomainAccess.Lookup)) + using (var dhandle = new SamDomainHandle(sid.DomainName, SamDomainAccess.Lookup)) { return new SamAliasHandle(dhandle, dhandle.LookupName(sid.Name), access); } @@ -80,119 +84,129 @@ private SamAliasHandle(IntPtr handle, bool owned) /// The desired access to the alias. public SamAliasHandle(SamDomainHandle domainHandle, int aliasId, SamAliasAccess access) { + NtStatus status; IntPtr handle; - Win32.SamOpenAlias( + if ((status = Win32.SamOpenAlias( domainHandle, access, aliasId, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.Handle = handle; } public void AddMember(Sid sid) { - Win32.SamAddMemberToAlias(this, sid).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamAddMemberToAlias(this, sid)) >= NtStatus.Error) + Win32.Throw(status); } public void AddMembers(Sid[] sids) { + NtStatus status; IntPtr[] sidArray = new IntPtr[sids.Length]; for (int i = 0; i < sids.Length; i++) sidArray[i] = sids[i]; - Win32.SamAddMultipleMembersToAlias( + if ((status = Win32.SamAddMultipleMembersToAlias( this, sidArray, sids.Length - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void Delete() { - Win32.SamDeleteAlias(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamDeleteAlias(this)) >= NtStatus.Error) + Win32.Throw(status); } private SamMemoryAlloc GetInformation(AliasInformationClass infoClass) { + NtStatus status; IntPtr buffer; - Win32.SamQueryInformationAlias( + if ((status = Win32.SamQueryInformationAlias( this, infoClass, out buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new SamMemoryAlloc(buffer); } - public string AdminComment + public string GetAdminComment() { - get + using (var data = this.GetInformation(AliasInformationClass.AliasAdminCommentInformation)) { - using (SamMemoryAlloc data = this.GetInformation(AliasInformationClass.AliasAdminCommentInformation)) - { - return data.ReadStruct().AdminComment.Text; - } + return data.ReadStruct().AdminComment.Read(); } } - public Sid[] Members + public Sid[] GetMembers() { - get - { - IntPtr members; - int count; + NtStatus status; + IntPtr members; + int count; - Win32.SamGetMembersInAlias( - this, - out members, - out count - ).ThrowIf(); + if ((status = Win32.SamGetMembersInAlias( + this, + out members, + out count + )) >= NtStatus.Error) + Win32.Throw(status); - using (SamMemoryAlloc membersAlloc = new SamMemoryAlloc(members)) - { - Sid[] sids = new Sid[count]; + using (var membersAlloc = new SamMemoryAlloc(members)) + { + Sid[] sids = new Sid[count]; - for (int i = 0; i < sids.Length; i++) - sids[i] = new Sid(membersAlloc.ReadIntPtr(0, i)); + for (int i = 0; i < sids.Length; i++) + sids[i] = new Sid(membersAlloc.ReadIntPtr(0, i)); - return sids; - } + return sids; } } - public string Name + public string GetName() { - get + using (var data = this.GetInformation(AliasInformationClass.AliasNameInformation)) { - using (SamMemoryAlloc data = this.GetInformation(AliasInformationClass.AliasNameInformation)) - { - return data.ReadStruct().Name.Text; - } + return data.ReadStruct().Name.Read(); } } public void RemoveMember(Sid sid) { - Win32.SamRemoveMemberFromAlias(this, sid).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamRemoveMemberFromAlias(this, sid)) >= NtStatus.Error) + Win32.Throw(status); } public void RemoveMembers(Sid[] sids) { + NtStatus status; IntPtr[] sidArray = new IntPtr[sids.Length]; for (int i = 0; i < sids.Length; i++) sidArray[i] = sids[i]; - Win32.SamRemoveMultipleMembersFromAlias( + if ((status = Win32.SamRemoveMultipleMembersFromAlias( this, sidArray, sids.Length - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SamDomainHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SamDomainHandle.cs index 12df34bac..a9a068a59 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SamDomainHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SamDomainHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -85,44 +86,49 @@ public SamDomainHandle(SamServerHandle serverHandle, string name, SamDomainAcces /// The desired access to the domain. public SamDomainHandle(SamServerHandle serverHandle, Sid domainId, SamDomainAccess access) { + NtStatus status; IntPtr handle; - Win32.SamOpenDomain( + if ((status = Win32.SamOpenDomain( serverHandle, access, domainId, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.Handle = handle; } public void EnumAliases(EnumAliasesDelegate callback) { + NtStatus status; int enumerationContext = 0; IntPtr buffer; int count; while (true) { - Win32.SamEnumerateAliasesInDomain( + status = Win32.SamEnumerateAliasesInDomain( this, ref enumerationContext, out buffer, 0x100, out count - ).ThrowIf(); + ); + if (status >= NtStatus.Error) + Win32.Throw(status); if (count == 0) break; - using (SamMemoryAlloc bufferAlloc = new SamMemoryAlloc(buffer)) + using (var bufferAlloc = new SamMemoryAlloc(buffer)) { for (int i = 0; i < count; i++) { - SamRidEnumeration data = bufferAlloc.ReadStruct(0, SamRidEnumeration.SizeOf, i); + var data = bufferAlloc.ReadStruct(i); - if (!callback(data.Name.Text, data.RelativeId)) + if (!callback(data.Name.Read(), data.RelativeId)) return; } } @@ -131,30 +137,33 @@ out count public void EnumGroups(EnumGroupsDelegate callback) { + NtStatus status; int enumerationContext = 0; IntPtr buffer; int count; while (true) { - Win32.SamEnumerateGroupsInDomain( + status = Win32.SamEnumerateGroupsInDomain( this, ref enumerationContext, out buffer, 0x100, out count - ).ThrowIf(); + ); + if (status >= NtStatus.Error) + Win32.Throw(status); if (count == 0) break; - using (SamMemoryAlloc bufferAlloc = new SamMemoryAlloc(buffer)) + using (var bufferAlloc = new SamMemoryAlloc(buffer)) { for (int i = 0; i < count; i++) { - SamRidEnumeration data = bufferAlloc.ReadStruct(0, SamRidEnumeration.SizeOf, i); + var data = bufferAlloc.ReadStruct(i); - if (!callback(data.Name.Text, data.RelativeId)) + if (!callback(data.Name.Read(), data.RelativeId)) return; } } @@ -168,31 +177,34 @@ public void EnumUsers(EnumUsersDelegate callback) public void EnumUsers(EnumUsersDelegate callback, UserAccountFlags flags) { + NtStatus status; int enumerationContext = 0; IntPtr buffer; int count; while (true) { - Win32.SamEnumerateUsersInDomain( + status = Win32.SamEnumerateUsersInDomain( this, ref enumerationContext, flags, out buffer, 0x100, out count - ).ThrowIf(); + ); + if (status >= NtStatus.Error) + Win32.Throw(status); if (count == 0) break; - using (SamMemoryAlloc bufferAlloc = new SamMemoryAlloc(buffer)) + using (var bufferAlloc = new SamMemoryAlloc(buffer)) { for (int i = 0; i < count; i++) { - var data = bufferAlloc.ReadStruct(0, SamRidEnumeration.SizeOf, i); + var data = bufferAlloc.ReadStruct(i); - if (!callback(data.Name.Text, data.RelativeId)) + if (!callback(data.Name.Read(), data.RelativeId)) return; } } @@ -201,44 +213,50 @@ out count public int[] GetAliasMembership(Sid sid) { + NtStatus status; IntPtr aliases; int count; - Win32.SamGetAliasMembership( + if ((status = Win32.SamGetAliasMembership( this, 1, new IntPtr[] { sid }, out count, out aliases - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (aliases != IntPtr.Zero) { using (var aliasesAlloc = new SamMemoryAlloc(aliases)) return aliasesAlloc.ReadInt32Array(0, count); } - - return new int[0]; + else + { + return new int[0]; + } } private SamMemoryAlloc GetInformation(DomainInformationClass infoClass) { + NtStatus status; IntPtr buffer; - Win32.SamQueryInformationDomain( + if ((status = Win32.SamQueryInformationDomain( this, infoClass, out buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new SamMemoryAlloc(buffer); } public DomainPasswordPolicy GetPasswordPolicy() { - using (SamMemoryAlloc data = this.GetInformation(DomainInformationClass.DomainPasswordInformation)) + using (var data = this.GetInformation(DomainInformationClass.DomainPasswordInformation)) { - DomainPasswordInformation info = data.ReadStruct(); + var info = data.ReadStruct(); return new DomainPasswordPolicy( info.MinPasswordLength, @@ -252,15 +270,17 @@ public DomainPasswordPolicy GetPasswordPolicy() public Sid GetSid(int relativeId) { + NtStatus status; IntPtr sid; - Win32.SamRidToSid( + if ((status = Win32.SamRidToSid( this, relativeId, out sid - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); - using (SamMemoryAlloc sidAlloc = new SamMemoryAlloc(sid)) + using (var sidAlloc = new SamMemoryAlloc(sid)) return new Sid(sidAlloc); } @@ -278,26 +298,28 @@ public string[] LookupIds(int[] relativeIds) public string[] LookupIds(int[] relativeIds, out SidNameUse[] uses) { + NtStatus status; IntPtr names; IntPtr use; - Win32.SamLookupIdsInDomain( + if ((status = Win32.SamLookupIdsInDomain( this, relativeIds.Length, relativeIds, out names, out use - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); - using (SamMemoryAlloc namesAlloc = new SamMemoryAlloc(names)) - using (SamMemoryAlloc useAlloc = new SamMemoryAlloc(use)) + using (var namesAlloc = new SamMemoryAlloc(names)) + using (var useAlloc = new SamMemoryAlloc(use)) { string[] nameArray = new string[relativeIds.Length]; SidNameUse[] useArray = new SidNameUse[relativeIds.Length]; for (int i = 0; i < relativeIds.Length; i++) { - nameArray[i] = namesAlloc.ReadStruct(0, UnicodeString.SizeOf, i).Text; + nameArray[i] = namesAlloc.ReadStruct(i).Read(); useArray[i] = (SidNameUse)useAlloc.ReadInt32(0, i); } @@ -321,23 +343,26 @@ public int[] LookupNames(string[] names) public int[] LookupNames(string[] names, out SidNameUse[] uses) { + NtStatus status; + UnicodeString[] nameStr; IntPtr relativeIds; IntPtr use; - UnicodeString[] nameStr = new UnicodeString[names.Length]; + nameStr = new UnicodeString[names.Length]; for (int i = 0; i < names.Length; i++) nameStr[i] = new UnicodeString(names[i]); try { - Win32.SamLookupNamesInDomain( + if ((status = Win32.SamLookupNamesInDomain( this, names.Length, nameStr, out relativeIds, out use - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -345,8 +370,8 @@ out use nameStr[i].Dispose(); } - using (SamMemoryAlloc relativeIdsAlloc = new SamMemoryAlloc(relativeIds)) - using (SamMemoryAlloc useAlloc = new SamMemoryAlloc(use)) + using (var relativeIdsAlloc = new SamMemoryAlloc(relativeIds)) + using (var useAlloc = new SamMemoryAlloc(use)) { SidNameUse[] useArray = new SidNameUse[names.Length]; @@ -361,25 +386,30 @@ out use private void SetInformation(DomainInformationClass infoClass, IntPtr buffer) { - Win32.SamSetInformationDomain( + NtStatus status; + + if ((status = Win32.SamSetInformationDomain( this, infoClass, buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } - public unsafe void SetPasswordPolicy(DomainPasswordPolicy policy) + public void SetPasswordPolicy(DomainPasswordPolicy policy) { - DomainPasswordInformation info = new DomainPasswordInformation + unsafe { - MinPasswordLength = policy.MinPasswordLength, - PasswordHistoryLength = policy.PasswordHistoryLength, - PasswordProperties = policy.PasswordProperties, - MaxPasswordAge = -policy.MaxPasswordAge.Ticks, - MinPasswordAge = -policy.MinPasswordAge.Ticks - }; - - this.SetInformation(DomainInformationClass.DomainPasswordInformation, new IntPtr(&info)); + DomainPasswordInformation info = new DomainPasswordInformation(); + + info.MinPasswordLength = policy.MinPasswordLength; + info.PasswordHistoryLength = policy.PasswordHistoryLength; + info.PasswordProperties = policy.PasswordProperties; + info.MaxPasswordAge = -policy.MaxPasswordAge.Ticks; + info.MinPasswordAge = -policy.MinPasswordAge.Ticks; + + this.SetInformation(DomainInformationClass.DomainPasswordInformation, new IntPtr(&info)); + } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SamGroupHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SamGroupHandle.cs index 0bc8d86e1..9b16d394f 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SamGroupHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SamGroupHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -33,19 +34,22 @@ public sealed class SamGroupHandle : SamHandle { public static SamGroupHandle Create(SamGroupAccess access, SamDomainHandle domainHandle, string name, out int groupId) { + NtStatus status; + UnicodeString nameStr; IntPtr handle; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.SamCreateGroupInDomain( + if ((status = Win32.SamCreateGroupInDomain( domainHandle, ref nameStr, access, out handle, out groupId - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -62,7 +66,7 @@ public static SamGroupHandle Open(string name, SamGroupAccess access) public static SamGroupHandle Open(Sid sid, SamGroupAccess access) { - using (SamDomainHandle dhandle = new SamDomainHandle(sid.DomainName, SamDomainAccess.Lookup)) + using (var dhandle = new SamDomainHandle(sid.DomainName, SamDomainAccess.Lookup)) { return new SamGroupHandle(dhandle, dhandle.LookupName(sid.Name), access); } @@ -80,89 +84,95 @@ private SamGroupHandle(IntPtr handle, bool owned) /// The desired access to the group. public SamGroupHandle(SamDomainHandle domainHandle, int groupId, SamGroupAccess access) { + NtStatus status; IntPtr handle; - Win32.SamOpenGroup( + if ((status = Win32.SamOpenGroup( domainHandle, access, groupId, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.Handle = handle; } public void AddMember(int memberId) { - Win32.SamAddMemberToGroup(this, memberId, 0).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamAddMemberToGroup(this, memberId, 0)) >= NtStatus.Error) + Win32.Throw(status); } public void Delete() { - Win32.SamDeleteGroup(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamDeleteGroup(this)) >= NtStatus.Error) + Win32.Throw(status); } private SamMemoryAlloc GetInformation(GroupInformationClass infoClass) { + NtStatus status; IntPtr buffer; - Win32.SamQueryInformationGroup( + if ((status = Win32.SamQueryInformationGroup( this, infoClass, out buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new SamMemoryAlloc(buffer); } - public string AdminComment + public string GetAdminComment() { - get + using (var data = this.GetInformation(GroupInformationClass.GroupAdminCommentInformation)) { - using (SamMemoryAlloc data = this.GetInformation(GroupInformationClass.GroupAdminCommentInformation)) - { - return data.ReadStruct().AdminComment.Text; - } + return data.ReadStruct().AdminComment.Read(); } } - public int[] Members + public int[] GetMembers() { - get + NtStatus status; + IntPtr memberIds; + IntPtr attributes; + int count; + + if ((status = Win32.SamGetMembersInGroup( + this, + out memberIds, + out attributes, + out count + )) >= NtStatus.Error) + Win32.Throw(status); + + using (var memberIdsAlloc = new SamMemoryAlloc(memberIds)) + using (var attributesAlloc = new SamMemoryAlloc(attributes)) { - IntPtr memberIds; - IntPtr attributes; - int count; - - Win32.SamGetMembersInGroup( - this, - out memberIds, - out attributes, - out count - ).ThrowIf(); - - using (SamMemoryAlloc memberIdsAlloc = new SamMemoryAlloc(memberIds)) - using (new SamMemoryAlloc(attributes)) - { - return memberIdsAlloc.ReadInt32Array(0, count); - } + return memberIdsAlloc.ReadInt32Array(0, count); } } - public string Name + public string GetName() { - get + using (var data = this.GetInformation(GroupInformationClass.GroupNameInformation)) { - using (SamMemoryAlloc data = this.GetInformation(GroupInformationClass.GroupNameInformation)) - { - return data.ReadStruct().Name.Text; - } + return data.ReadStruct().Name.Read(); } } public void RemoveMember(int memberId) { - Win32.SamRemoveMemberFromGroup(this, memberId).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamRemoveMemberFromGroup(this, memberId)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SamHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SamHandle.cs index 7810a4cbd..f97e51d7d 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SamHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SamHandle.cs @@ -46,24 +46,29 @@ protected override void Close() public override SecurityDescriptor GetSecurity(SecurityInformation securityInformation) { + NtStatus status; IntPtr securityDescriptor; - Win32.SamQuerySecurityObject( + if ((status = Win32.SamQuerySecurityObject( this, securityInformation, out securityDescriptor - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new SecurityDescriptor(new SamMemoryAlloc(securityDescriptor)); } public override void SetSecurity(SecurityInformation securityInformation, SecurityDescriptor securityDescriptor) { - Win32.SamSetSecurityObject( + NtStatus status; + + if ((status = Win32.SamSetSecurityObject( this, securityInformation, securityDescriptor - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SamServerHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SamServerHandle.cs index df0f676e4..56e527a63 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SamServerHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SamServerHandle.cs @@ -34,7 +34,7 @@ namespace ProcessHacker.Native.Objects public sealed class SamServerHandle : SamHandle { private static WeakReference _connectServerHandle; - private static int _connectServerHandleMisses; + private static int _connectServerHandleMisses = 0; public static SamServerHandle ConnectServerHandle { @@ -45,7 +45,7 @@ public static SamServerHandle ConnectServerHandle if (weakRef != null) { - weakRef.TryGetTarget(out connectHandle); + connectHandle = weakRef.Target; } if (connectHandle == null) @@ -53,10 +53,9 @@ public static SamServerHandle ConnectServerHandle System.Threading.Interlocked.Increment(ref _connectServerHandleMisses); connectHandle = new SamServerHandle(SamServerAccess.GenericRead | SamServerAccess.GenericExecute); + if (connectHandle != null) - { _connectServerHandle = new WeakReference(connectHandle); - } } return connectHandle; @@ -85,18 +84,22 @@ public SamServerHandle(SamServerAccess access) /// The desired access to the server. public SamServerHandle(string serverName, SamServerAccess access) { - IntPtr handle; + NtStatus status; ObjectAttributes oa = new ObjectAttributes(); - UnicodeString serverNameStr = new UnicodeString(serverName); + UnicodeString serverNameStr; + IntPtr handle; + + serverNameStr = new UnicodeString(serverName); try { - Win32.SamConnect( + if ((status = Win32.SamConnect( ref serverNameStr, out handle, access, ref oa - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -108,30 +111,33 @@ ref oa public void EnumDomains(EnumDomainsDelegate callback) { + NtStatus status; int enumerationContext = 0; IntPtr buffer; int count; while (true) { - Win32.SamEnumerateDomainsInSamServer( + status = Win32.SamEnumerateDomainsInSamServer( this, ref enumerationContext, out buffer, 0x100, out count - ).ThrowIf(); + ); + if (status >= NtStatus.Error) + Win32.Throw(status); if (count == 0) break; - using (SamMemoryAlloc bufferAlloc = new SamMemoryAlloc(buffer)) + using (var bufferAlloc = new SamMemoryAlloc(buffer)) { for (int i = 0; i < count; i++) { - SamSidEnumeration data = bufferAlloc.ReadStruct(0, SamSidEnumeration.SizeOf, i); + var data = bufferAlloc.ReadStruct(i); - if (!callback(data.Name.Text)) + if (!callback(data.Name.Read())) return; } } @@ -142,7 +148,7 @@ public string[] GetDomains() { List domains = new List(); - this.EnumDomains(name => + this.EnumDomains((name) => { domains.Add(name); return true; @@ -153,17 +159,20 @@ public string[] GetDomains() public Sid LookupDomain(string name) { + NtStatus status; + UnicodeString nameStr; IntPtr domainId; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.SamLookupDomainInSamServer( + if ((status = Win32.SamLookupDomainInSamServer( this, ref nameStr, out domainId - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -176,7 +185,10 @@ out domainId public void Shutdown() { - Win32.SamShutdownSamServer(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamShutdownSamServer(this)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SamUserHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SamUserHandle.cs index 0654bc6e5..dcc30fc12 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SamUserHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SamUserHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Collections.Generic; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -33,19 +34,22 @@ public sealed class SamUserHandle : SamHandle { public static SamUserHandle Create(SamUserAccess access, SamDomainHandle domainHandle, string name, out int userId) { + NtStatus status; + UnicodeString nameStr; IntPtr handle; - UnicodeString nameStr = new UnicodeString(name); + nameStr = new UnicodeString(name); try { - Win32.SamCreateUserInDomain( + if ((status = Win32.SamCreateUserInDomain( domainHandle, ref nameStr, access, out handle, out userId - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -84,30 +88,37 @@ public SamUserHandle(SamDomainHandle domainHandle, string name, SamUserAccess ac /// The desired access to the user. public SamUserHandle(SamDomainHandle domainHandle, int userId, SamUserAccess access) { + NtStatus status; IntPtr handle; - Win32.SamOpenUser( + if ((status = Win32.SamOpenUser( domainHandle, access, userId, out handle - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.Handle = handle; } public void ChangePassword(string oldPassword, string newPassword) { - UnicodeString oldPasswordStr = new UnicodeString(oldPassword); - UnicodeString newPasswordStr = new UnicodeString(newPassword); + NtStatus status; + UnicodeString oldPasswordStr; + UnicodeString newPasswordStr; + + oldPasswordStr = new UnicodeString(oldPassword); + newPasswordStr = new UnicodeString(newPassword); try { - Win32.SamChangePasswordUser( + if ((status = Win32.SamChangePasswordUser( this, ref oldPasswordStr, ref newPasswordStr - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -118,221 +129,220 @@ ref newPasswordStr public void Delete() { - Win32.SamDeleteUser(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.SamDeleteUser(this)) >= NtStatus.Error) + Win32.Throw(status); } - public string AdminComment + public string GetAdminComment() { - get { return this.Information.AdminComment; } + return this.GetInformation().AdminComment; } - public UserAccountFlags Flags + public UserAccountFlags GetFlags() { - get { return this.Information.UserFlags; } + return this.GetInformation().UserFlags; } - public string FullName + public string GetFullName() { - get - { - using (SamMemoryAlloc data = this.GetInformation(UserInformationClass.UserFullNameInformation)) - { - return data.ReadStruct().FullName.Text; - } - } + using (var data = this.GetInformation(UserInformationClass.UserFullNameInformation)) + return data.ReadStruct().FullName.Read(); } - public int[] Groups + public int[] GetGroups() { - get - { - IntPtr groups; - int count; + NtStatus status; + IntPtr groups; + int count; - Win32.SamGetGroupsForUser( - this, - out groups, - out count - ).ThrowIf(); + if ((status = Win32.SamGetGroupsForUser( + this, + out groups, + out count + )) >= NtStatus.Error) + Win32.Throw(status); - using (SamMemoryAlloc groupsAlloc = new SamMemoryAlloc(groups)) - { - return groupsAlloc.ReadInt32Array(0, count); - } + using (var groupsAlloc = new SamMemoryAlloc(groups)) + { + return groupsAlloc.ReadInt32Array(0, count); } } - public SamUserInformation Information + public SamUserInformation GetInformation() { - get + using (var data = this.GetInformation(UserInformationClass.UserAllInformation)) { - using (SamMemoryAlloc data = this.GetInformation(UserInformationClass.UserAllInformation)) - { - UserAllInformation info = data.ReadStruct(); - - return new SamUserInformation( - SamDomainHandle.ToDateTime(info.LastLogon), - SamDomainHandle.ToDateTime(info.LastLogoff), - SamDomainHandle.ToDateTime(info.PasswordLastSet), - SamDomainHandle.ToDateTime(info.AccountExpires), - SamDomainHandle.ToDateTime(info.PasswordCanChange), - SamDomainHandle.ToDateTime(info.PasswordMustChange), - info.UserName.Text, - info.FullName.Text, - info.AdminComment.Text, - info.UserComment.Text, - info.UserId, - info.PrimaryGroupId, - info.UserAccountControl, - info.PasswordExpired - ); - } + UserAllInformation info = data.ReadStruct(); + + return new SamUserInformation( + SamDomainHandle.ToDateTime(info.LastLogon), + SamDomainHandle.ToDateTime(info.LastLogoff), + SamDomainHandle.ToDateTime(info.PasswordLastSet), + SamDomainHandle.ToDateTime(info.AccountExpires), + SamDomainHandle.ToDateTime(info.PasswordCanChange), + SamDomainHandle.ToDateTime(info.PasswordMustChange), + info.UserName.Read(), + info.FullName.Read(), + info.AdminComment.Read(), + info.UserComment.Read(), + info.UserId, + info.PrimaryGroupId, + info.UserAccountControl, + info.PasswordExpired + ); } } private SamMemoryAlloc GetInformation(UserInformationClass infoClass) { + NtStatus status; IntPtr buffer; - Win32.SamQueryInformationUser( + if ((status = Win32.SamQueryInformationUser( this, infoClass, out buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new SamMemoryAlloc(buffer); } - public string Name + public string GetName() { - get - { - using (SamMemoryAlloc data = this.GetInformation(UserInformationClass.UserAccountNameInformation)) - { - return data.ReadStruct().UserName.Text; - } - } + using (var data = this.GetInformation(UserInformationClass.UserAccountNameInformation)) + return data.ReadStruct().UserName.Read(); + } + + public string GetPasswordHint() + { + using (var data = this.GetInformation(UserInformationClass.UserExtendedInformation)) + return data.ReadStruct().PasswordHint.Read(); } - public string PasswordHint + public void SetAdminComment(string comment) { - get + unsafe { - using (SamMemoryAlloc data = this.GetInformation(UserInformationClass.UserExtendedInformation)) + UserAllInformation info = new UserAllInformation(); + + info.WhichFields = UserWhichFields.AdminComment; + info.AdminComment = new UnicodeString(comment); + + try + { + this.SetInformation(UserInformationClass.UserAllInformation, new IntPtr(&info)); + } + finally { - return data.ReadStruct().PasswordHint.Text; + info.AdminComment.Dispose(); } } } - public unsafe void SetAdminComment(string comment) + public void SetFlags(UserAccountFlags flags) { - UserAllInformation info = new UserAllInformation + unsafe { - WhichFields = UserWhichFields.AdminComment, - AdminComment = new UnicodeString(comment) - }; + UserAllInformation info = new UserAllInformation(); + + info.WhichFields = UserWhichFields.UserAccountControl; + info.UserAccountControl = flags; - try - { this.SetInformation(UserInformationClass.UserAllInformation, new IntPtr(&info)); } - finally - { - info.AdminComment.Dispose(); - } } - public unsafe void SetFlags(UserAccountFlags flags) + public void SetFullName(string fullName) { - UserAllInformation info = new UserAllInformation + unsafe { - WhichFields = UserWhichFields.UserAccountControl, - UserAccountControl = flags - }; + UserFullNameInformation info = new UserFullNameInformation(); - this.SetInformation(UserInformationClass.UserAllInformation, new IntPtr(&info)); - } + info.FullName = new UnicodeString(fullName); - public unsafe void SetFullName(string fullName) - { - UserFullNameInformation info = new UserFullNameInformation - { - FullName = new UnicodeString(fullName) - }; - - try - { - this.SetInformation(UserInformationClass.UserFullNameInformation, new IntPtr(&info)); - } - finally - { - info.FullName.Dispose(); + try + { + this.SetInformation(UserInformationClass.UserFullNameInformation, new IntPtr(&info)); + } + finally + { + info.FullName.Dispose(); + } } } private void SetInformation(UserInformationClass infoClass, IntPtr buffer) { - Win32.SamSetInformationUser( + NtStatus status; + + if ((status = Win32.SamSetInformationUser( this, infoClass, buffer - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } - public unsafe void SetPassword(string password, bool expired) + public void SetPassword(string password, bool expired) { - UserSetPasswordInformation info = new UserSetPasswordInformation + unsafe { - Password = new UnicodeString(password), - PasswordExpired = expired - }; + UserSetPasswordInformation info = new UserSetPasswordInformation(); - try - { - this.SetInformation(UserInformationClass.UserSetPasswordInformation, new IntPtr(&info)); - } - finally - { - info.Password.Dispose(); + info.Password = new UnicodeString(password); + info.PasswordExpired = expired; + + try + { + this.SetInformation(UserInformationClass.UserSetPasswordInformation, new IntPtr(&info)); + } + finally + { + info.Password.Dispose(); + } } } - public unsafe void SetPasswordHint(string passwordHint) + public void SetPasswordHint(string passwordHint) { - UserExtendedInformation info = new UserExtendedInformation + unsafe { - ExtendedWhichFields = UserExtendedWhichFields.PasswordHint, - PasswordHint = new UnicodeString(passwordHint) - }; + UserExtendedInformation info = new UserExtendedInformation(); - try - { - this.SetInformation(UserInformationClass.UserExtendedInformation, new IntPtr(&info)); - } - finally - { - info.PasswordHint.Dispose(); + info.ExtendedWhichFields = UserExtendedWhichFields.PasswordHint; + info.PasswordHint = new UnicodeString(passwordHint); + + try + { + this.SetInformation(UserInformationClass.UserExtendedInformation, new IntPtr(&info)); + } + finally + { + info.PasswordHint.Dispose(); + } } } } public class SamUserInformation { - private readonly DateTime _lastLogon; - private readonly DateTime _lastLogoff; - private readonly DateTime _passwordLastSet; - private readonly DateTime _accountExpires; - private readonly DateTime _passwordCanChange; - private readonly DateTime _passwordMustChange; - private readonly string _userName; - private readonly string _fullName; - private readonly string _adminComment; - private readonly string _userComment; - private readonly int _userId; - private readonly int _primaryGroupId; - private readonly UserAccountFlags _userFlags; - private readonly bool _passwordExpired; + private DateTime _lastLogon; + private DateTime _lastLogoff; + private DateTime _passwordLastSet; + private DateTime _accountExpires; + private DateTime _passwordCanChange; + private DateTime _passwordMustChange; + private string _userName; + private string _fullName; + private string _adminComment; + private string _userComment; + private int _userId; + private int _primaryGroupId; + private UserAccountFlags _userFlags; + private bool _passwordExpired; public SamUserInformation( DateTime lastLogon, diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SectionHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SectionHandle.cs index 146ef2d9c..014957f95 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SectionHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SectionHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -82,6 +83,7 @@ public static SectionHandle Create( FileHandle fileHandle ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; @@ -89,7 +91,7 @@ FileHandle fileHandle { if (maximumSize != 0) { - Win32.NtCreateSection( + if ((status = Win32.NtCreateSection( out handle, access, ref oa, @@ -97,11 +99,12 @@ FileHandle fileHandle pageAttributes, sectionAttributes, fileHandle ?? IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } else { - Win32.NtCreateSection( + if ((status = Win32.NtCreateSection( out handle, access, ref oa, @@ -109,7 +112,8 @@ FileHandle fileHandle pageAttributes, sectionAttributes, fileHandle ?? IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } finally @@ -131,12 +135,14 @@ private SectionHandle(IntPtr handle, bool owned) public SectionHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, SectionAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenSection(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenSection(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -152,39 +158,36 @@ public SectionHandle(string name, SectionAccess access) public long Extend(long newSize) { - Win32.NtExtendSection(this, ref newSize).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtExtendSection(this, ref newSize)) >= NtStatus.Error) + Win32.Throw(status); return newSize; } public SectionBasicInformation GetBasicInformation() { + NtStatus status; SectionBasicInformation sbi; IntPtr retLength; - Win32.NtQuerySection( - this, - SectionInformationClass.SectionBasicInformation, - out sbi, - new IntPtr(SectionBasicInformation.SizeOf), - out retLength - ).ThrowIf(); + if ((status = Win32.NtQuerySection(this, SectionInformationClass.SectionBasicInformation, + out sbi, new IntPtr(Marshal.SizeOf(typeof(SectionBasicInformation))), out retLength)) >= NtStatus.Error) + Win32.Throw(status); return sbi; } public SectionImageInformation GetImageInformation() { + NtStatus status; SectionImageInformation sii; IntPtr retLength; - Win32.NtQuerySection( - this, - SectionInformationClass.SectionImageInformation, - out sii, - new IntPtr(SectionImageInformation.SizeOf), - out retLength - ).ThrowIf(); + if ((status = Win32.NtQuerySection(this, SectionInformationClass.SectionImageInformation, + out sii, new IntPtr(Marshal.SizeOf(typeof(SectionImageInformation))), out retLength)) >= NtStatus.Error) + Win32.Throw(status); return sii; } @@ -230,9 +233,11 @@ public SectionView MapView( MemoryProtection protection ) { + NtStatus status; + // sectionOffset requires 2 << 15 = 0x10000 = 65536 alignment. // viewSize will be rounded up to the page size. - Win32.NtMapViewOfSection( + if ((status = Win32.NtMapViewOfSection( this, processHandle, ref baseAddress, @@ -243,7 +248,8 @@ MemoryProtection protection inheritDisposition, allocationType, protection - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new SectionView(baseAddress, viewSize); } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SemaphoreHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SemaphoreHandle.cs index 735767bec..c73cdc2af 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SemaphoreHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SemaphoreHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -40,18 +41,15 @@ public static SemaphoreHandle Create(SemaphoreAccess access, string name, int in public static SemaphoreHandle Create(SemaphoreAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, int initialCount, int maximumCount) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateSemaphore( - out handle, - access, - ref oa, - initialCount, - maximumCount - ).ThrowIf(); + if ((status = Win32.NtCreateSemaphore(out handle, access, ref oa, + initialCount, maximumCount)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -72,12 +70,14 @@ private SemaphoreHandle(IntPtr handle, bool owned) public SemaphoreHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, SemaphoreAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenSemaphore(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenSemaphore(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -93,16 +93,13 @@ public SemaphoreHandle(string name, SemaphoreAccess access) public SemaphoreBasicInformation GetBasicInformation() { + NtStatus status; SemaphoreBasicInformation sbi; int retLength; - Win32.NtQuerySemaphore( - this, - SemaphoreInformationClass.SemaphoreBasicInformation, - out sbi, - SemaphoreBasicInformation.SizeOf, - out retLength - ).ThrowIf(); + if ((status = Win32.NtQuerySemaphore(this, SemaphoreInformationClass.SemaphoreBasicInformation, + out sbi, Marshal.SizeOf(typeof(SemaphoreBasicInformation)), out retLength)) >= NtStatus.Error) + Win32.Throw(status); return sbi; } @@ -114,9 +111,11 @@ public int Release() public int Release(int count) { + NtStatus status; int previousCount; - Win32.NtReleaseSemaphore(this, count, out previousCount).ThrowIf(); + if ((status = Win32.NtReleaseSemaphore(this, count, out previousCount)) >= NtStatus.Error) + Win32.Throw(status); return previousCount; } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/ServiceHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/ServiceHandle.cs index 5aabc23f8..543adb999 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/ServiceHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/ServiceHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; using ProcessHacker.Native.Security.AccessControl; @@ -95,7 +96,8 @@ public ServiceHandle(string serviceName) /// The desired access to the service. public ServiceHandle(string serviceName, ServiceAccess access) { - using (ServiceManagerHandle manager = new ServiceManagerHandle(ScManagerAccess.Connect)) + using (ServiceManagerHandle manager = + new ServiceManagerHandle(ScManagerAccess.Connect)) { this.Handle = Win32.OpenService(manager, serviceName, access); @@ -113,7 +115,7 @@ public ServiceHandle(string serviceName, ServiceAccess access) /// The message. public void Control(ServiceControl control) { - ServiceStatus status; + ServiceStatus status = new ServiceStatus(); if (!Win32.ControlService(this, control, out status)) Win32.Throw(); @@ -133,7 +135,7 @@ public void Delete() /// public QueryServiceConfig GetConfig() { - int requiredSize; + int requiredSize = 0; Win32.QueryServiceConfig(this, IntPtr.Zero, 0, out requiredSize); @@ -179,7 +181,7 @@ public ServiceStatusProcess GetStatus() ServiceStatusProcess status; int retLen; - if (!Win32.QueryServiceStatusEx(this, 0, out status, ServiceStatusProcess.SizeOf, out retLen)) + if (!Win32.QueryServiceStatusEx(this, 0, out status, Marshal.SizeOf(typeof(ServiceStatusProcess)), out retLen)) Win32.Throw(); return status; diff --git a/1.x/trunk/ProcessHacker.Native/Objects/ServiceManagerHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/ServiceManagerHandle.cs index 8a5769847..854f838f6 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/ServiceManagerHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/ServiceManagerHandle.cs @@ -60,25 +60,15 @@ public ServiceHandle CreateService(string name, string displayName, ServiceErrorControl.Ignore, binaryPath, null, null, null); } - public ServiceHandle CreateService(string name, string displayName, ServiceType type, ServiceStartType startType, ServiceErrorControl errorControl, string binaryPath, string group, string accountName, string password) + public ServiceHandle CreateService(string name, string displayName, + ServiceType type, ServiceStartType startType, ServiceErrorControl errorControl, + string binaryPath, string group, string accountName, string password) { - IntPtr service = Win32.CreateService( - this, - name, - displayName, - ServiceAccess.All, - type, - startType, - errorControl, - binaryPath, - group, - IntPtr.Zero, - IntPtr.Zero, - accountName, - password - ); + IntPtr service; - if (service == IntPtr.Zero) + if ((service = Win32.CreateService(this, name, displayName, ServiceAccess.All, + type, startType, errorControl, binaryPath, group, + IntPtr.Zero, IntPtr.Zero, accountName, password)) == IntPtr.Zero) Win32.Throw(); return new ServiceHandle(service, true); diff --git a/1.x/trunk/ProcessHacker.Native/Objects/SymbolicLinkHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/SymbolicLinkHandle.cs index d9282db85..fc0e3148f 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/SymbolicLinkHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/SymbolicLinkHandle.cs @@ -35,6 +35,7 @@ public static SymbolicLinkHandle Create(SymbolicLinkAccess access, string name, public static SymbolicLinkHandle Create(SymbolicLinkAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, string linkTarget) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; @@ -44,12 +45,9 @@ public static SymbolicLinkHandle Create(SymbolicLinkAccess access, string name, try { - Win32.NtCreateSymbolicLinkObject( - out handle, - access, - ref oa, - ref linkTargetString - ).ThrowIf(); + if ((status = Win32.NtCreateSymbolicLinkObject(out handle, access, + ref oa, ref linkTargetString)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -70,12 +68,14 @@ private SymbolicLinkHandle(IntPtr handle, bool owned) public SymbolicLinkHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, SymbolicLinkAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenSymbolicLinkObject(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenSymbolicLinkObject(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -89,30 +89,29 @@ public SymbolicLinkHandle(string name, SymbolicLinkAccess access) : this(name, 0, null, access) { } - public string Target + public string GetTarget() { - get + NtStatus status; + int retLength; + UnicodeString str = new UnicodeString(); + + using (var buffer = new MemoryAlloc(0x200)) { - int retLength; - UnicodeString str = new UnicodeString(); + str.Length = 0; + str.MaximumLength = (ushort)buffer.Size; + str.Buffer = buffer; - using (MemoryAlloc buffer = new MemoryAlloc(0x200)) + if ((status = Win32.NtQuerySymbolicLinkObject(this, ref str, out retLength)) >= NtStatus.Error) { - str.Length = 0; - str.MaximumLength = (ushort)buffer.Size; + buffer.ResizeNew(retLength); + str.MaximumLength = (ushort)retLength; str.Buffer = buffer; + } - if (Win32.NtQuerySymbolicLinkObject(this, ref str, out retLength).IsError()) - { - buffer.ResizeNew(retLength); - str.MaximumLength = (ushort)retLength; - str.Buffer = buffer; - } - - Win32.NtQuerySymbolicLinkObject(this, ref str, out retLength).ThrowIf(); + if ((status = Win32.NtQuerySymbolicLinkObject(this, ref str, out retLength)) >= NtStatus.Error) + Win32.Throw(status); - return str.Text; - } + return str.Read(); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/TerminalServerHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/TerminalServerHandle.cs index 4cbeb52dd..ae7bb2991 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/TerminalServerHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/TerminalServerHandle.cs @@ -74,7 +74,7 @@ public static void UnregisterNotificationsCurrent(IWin32Window window) Win32.Throw(); } - private readonly string _systemName; + private string _systemName; private TerminalServerHandle(IntPtr handle, bool owned) : base(handle, owned) @@ -120,13 +120,13 @@ public TerminalServerProcess[] GetProcesses() if (!Win32.WTSEnumerateProcesses(this, 0, 1, out dataPtr, out count)) Win32.Throw(); - using (WtsMemoryAlloc data = new WtsMemoryAlloc(dataPtr)) + using (var data = new WtsMemoryAlloc(dataPtr)) { processes = new TerminalServerProcess[count]; for (int i = 0; i < count; i++) { - var process = data.ReadStruct(0, WtsProcessInfo.SizeOf, i); + var process = data.ReadStruct(i); processes[i] = new TerminalServerProcess( process.ProcessId, process.SessionId, @@ -157,18 +157,18 @@ public TerminalServerSession[] GetSessions() { IntPtr dataPtr; int count; + TerminalServerSession[] sessions; if (!Win32.WTSEnumerateSessions(this, 0, 1, out dataPtr, out count)) Win32.Throw(); - using (WtsMemoryAlloc data = new WtsMemoryAlloc(dataPtr)) + using (var data = new WtsMemoryAlloc(dataPtr)) { - TerminalServerSession[] sessions = new TerminalServerSession[count]; + sessions = new TerminalServerSession[count]; for (int i = 0; i < count; i++) { - WtsSessionInfo session = data.ReadStruct(0, WtsSessionInfo.SizeOf, i); - + var session = data.ReadStruct(i); sessions[i] = new TerminalServerSession( this, session.SessionID, @@ -235,8 +235,8 @@ public static int GetActiveConsoleId() return Win32.WTSGetActiveConsoleSessionId(); } - private readonly TerminalServerHandle _serverHandle; - private readonly int _sessionId; + private TerminalServerHandle _serverHandle; + private int _sessionId; private string _name; private WtsConnectStateClass _state = (WtsConnectStateClass)(-1); private string _initialProgram; @@ -291,7 +291,8 @@ public WtsConnectStateClass State IntPtr dataPtr; int length; - if (!Win32.WTSQuerySessionInformation(_serverHandle, _sessionId, WtsInformationClass.ConnectState, out dataPtr, out length)) + if (!Win32.WTSQuerySessionInformation( + _serverHandle, _sessionId, WtsInformationClass.ConnectState, out dataPtr, out length)) Win32.Throw(); using (var data = new WtsMemoryAlloc(dataPtr)) @@ -381,17 +382,21 @@ public System.Net.IPAddress ClientAddress IntPtr dataPtr; int length; - if (!Win32.WTSQuerySessionInformation(_serverHandle, _sessionId, WtsInformationClass.ClientAddress, out dataPtr, out length)) + if (!Win32.WTSQuerySessionInformation( + _serverHandle, _sessionId, WtsInformationClass.ClientAddress, out dataPtr, out length)) Win32.Throw(); if (dataPtr != IntPtr.Zero) { - using (WtsMemoryAlloc data = new WtsMemoryAlloc(dataPtr)) + unsafe { - WtsClientAddress address = data.ReadStruct(); + using (var data = new WtsMemoryAlloc(dataPtr)) + { + var address = data.ReadStruct(); - if (address.AddressFamily != 0) - this._clientAddress = new System.Net.IPAddress(data.ReadBytes(6, 4)); + if (address.AddressFamily != 0) + _clientAddress = new System.Net.IPAddress(data.ReadBytes(6, 4)); + } } } } @@ -404,12 +409,13 @@ public WtsClientDisplay ClientDisplay { get { - if (!_clientDisplay.HasValue) + if (_clientDisplay == null) { IntPtr dataPtr; int length; - if (!Win32.WTSQuerySessionInformation(_serverHandle, _sessionId, WtsInformationClass.ClientDisplay, out dataPtr, out length)) + if (!Win32.WTSQuerySessionInformation( + _serverHandle, _sessionId, WtsInformationClass.ClientDisplay, out dataPtr, out length)) Win32.Throw(); if (dataPtr != IntPtr.Zero) @@ -508,10 +514,10 @@ bool synchronous public class TerminalServerProcess { - private readonly int _processId; - private readonly int _sessionId; - private readonly string _name; - private readonly Sid _sid; + private int _processId; + private int _sessionId; + private string _name; + private Sid _sid; internal TerminalServerProcess(int processId, int sessionId, string name, Sid sid) { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs index 7ed9432c9..5127762b1 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/ThreadHandle.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Runtime.InteropServices; using ProcessHacker.Common; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -58,12 +59,13 @@ public static ThreadHandle Create( bool createSuspended ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateThread( + if ((status = Win32.NtCreateThread( out handle, access, ref oa, @@ -72,7 +74,8 @@ bool createSuspended ref threadContext, ref initialTeb, createSuspended - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -109,9 +112,10 @@ public static ThreadHandle CreateUserThread( out ClientId clientId ) { + NtStatus status; IntPtr threadHandle; - Win32.RtlCreateUserThread( + if ((status = Win32.RtlCreateUserThread( processHandle, IntPtr.Zero, createSuspended, @@ -122,7 +126,8 @@ out ClientId clientId parameter, out threadHandle, out clientId - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return new ThreadHandle(threadHandle, true); } @@ -153,7 +158,7 @@ public static ThreadHandle GetCurrent() /// A client ID. public static ClientId GetCurrentCid() { - return new ClientId(ProcessHandle.CurrentId, GetCurrentId()); + return new ClientId(ProcessHandle.GetCurrentId(), ThreadHandle.GetCurrentId()); } /// @@ -223,7 +228,10 @@ public static ThreadHandle OpenWithAnyAccess(int tid) /// A handle to a port. public static void RegisterTerminationPort(PortHandle portHandle) { - Win32.NtRegisterThreadTerminatePort(portHandle).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRegisterThreadTerminatePort(portHandle)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -269,7 +277,12 @@ public static NtStatus Sleep(bool alertable, long timeout, bool relative) /// public static NtStatus TestAlert() { - return Win32.NtTestAlert(); + NtStatus status; + + if ((status = Win32.NtTestAlert()) >= NtStatus.Error) + Win32.Throw(status); + + return status; } /// @@ -299,24 +312,24 @@ public ThreadHandle(int tid) /// The desired access to the thread. public ThreadHandle(int tid, ThreadAccess access) { - //if (KProcessHacker.Instance != null) - //{ - // try - // { - // this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenThread(tid, access)); - // } - // catch (WindowsException) - // { - // // Open the thread with minimum access (SYNCHRONIZE) and set the granted access. - // this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenThread(tid, - // (ThreadAccess)StandardRights.Synchronize)); - // KProcessHacker.Instance.KphSetHandleGrantedAccess(this.Handle, (int)access); - // } - //} - //else - //{ + if (KProcessHacker.Instance != null) + { + try + { + this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenThread(tid, access)); + } + catch (WindowsException) + { + // Open the thread with minimum access (SYNCHRONIZE) and set the granted access. + this.Handle = new IntPtr(KProcessHacker.Instance.KphOpenThread(tid, + (ThreadAccess)StandardRights.Synchronize)); + KProcessHacker.Instance.KphSetHandleGrantedAccess(this.Handle, (int)access); + } + } + else + { this.Handle = Win32.OpenThread(access, false, tid); - //} + } if (this.Handle == IntPtr.Zero) { @@ -333,6 +346,7 @@ public ThreadHandle( ThreadAccess access ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; @@ -340,21 +354,23 @@ ThreadAccess access { if (clientId.ProcessId == 0 && clientId.ThreadId == 0) { - Win32.NtOpenThread( + if ((status = Win32.NtOpenThread( out handle, access, ref oa, IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } else { - Win32.NtOpenThread( + if ((status = Win32.NtOpenThread( out handle, access, ref oa, ref clientId - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } finally @@ -374,7 +390,10 @@ public ThreadHandle(string name, ThreadAccess access) /// public void Alert() { - Win32.NtAlertThread(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtAlertThread(this)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -382,9 +401,11 @@ public void Alert() /// public int AlertResume() { + NtStatus status; int suspendCount; - Win32.NtAlertResumeThread(this, out suspendCount).ThrowIf(); + if ((status = Win32.NtAlertResumeThread(this, out suspendCount)) >= NtStatus.Error) + Win32.Throw(status); return suspendCount; } @@ -405,24 +426,24 @@ public IntPtr[] CaptureKernelStack() /// An array of function addresses. public IntPtr[] CaptureKernelStack(int skipCount) { - //IntPtr[] stack = new IntPtr[62 - skipCount]; // 62 limit for XP and Server 2003 - //int hash; + IntPtr[] stack = new IntPtr[62 - skipCount]; // 62 limit for XP and Server 2003 + int hash; // Capture a kernel-mode stack trace. - //int captured = KProcessHacker.Instance.KphCaptureStackBackTraceThread( - // this, - // skipCount, - // stack.Length, - // stack, - // out hash - // ); + int captured = KProcessHacker.Instance.KphCaptureStackBackTraceThread( + this, + skipCount, + stack.Length, + stack, + out hash + ); // Create a new array with only the frames we captured. - //IntPtr[] newStack = new IntPtr[captured]; + IntPtr[] newStack = new IntPtr[captured]; - //Array.Copy(stack, 0, newStack, 0, captured); + Array.Copy(stack, 0, newStack, 0, captured); - return null;// newStack; + return newStack; } /// @@ -444,7 +465,7 @@ public ThreadStackFrame[] CaptureUserStack(int skipCount) List frames = new List(); // Walk the stack. - this.WalkStack(frame => { frames.Add(frame); return true; }); + this.WalkStack((frame) => { frames.Add(frame); return true; }); // If we want to skip frames than we have, just return an empty array. if (frames.Count <= skipCount) @@ -465,7 +486,7 @@ public ThreadStackFrame[] CaptureUserStack(int skipCount) /// The exit status. public void DangerousTerminate(NtStatus exitStatus) { - //KProcessHacker.Instance.KphDangerousTerminateThread(this, exitStatus); + KProcessHacker.Instance.KphDangerousTerminateThread(this, exitStatus); } /// @@ -496,16 +517,13 @@ public ThreadPriorityLevel GetBasePriorityWin32() /// A THREAD_BASIC_INFORMATION structure. public ThreadBasicInformation GetBasicInformation() { + NtStatus status; ThreadBasicInformation basicInfo = new ThreadBasicInformation(); int retLen; - Win32.NtQueryInformationThread( - this, - ThreadInformationClass.ThreadBasicInformation, - ref basicInfo, - ThreadBasicInformation.SizeOf, - out retLen - ).ThrowIf(); + if ((status = Win32.NtQueryInformationThread(this, ThreadInformationClass.ThreadBasicInformation, + ref basicInfo, Marshal.SizeOf(basicInfo), out retLen)) >= NtStatus.Error) + Win32.Throw(status); return basicInfo; } @@ -516,11 +534,9 @@ out retLen /// A CONTEXT struct. public Context GetContext(ContextFlags flags) { - Context context = new Context - { - ContextFlags = flags - }; + Context context = new Context(); + context.ContextFlags = flags; this.GetContext(ref context); return context; @@ -532,7 +548,18 @@ public Context GetContext(ContextFlags flags) /// A Context structure. The ContextFlags must be set appropriately. public unsafe void GetContext(ref Context context) { - Win32.NtGetContextThread(this, ref context).ThrowIf(); + if (KProcessHacker.Instance != null) + { + fixed (Context* contextPtr = &context) + KProcessHacker.Instance.KphGetContextThread(this, contextPtr); + } + else + { + NtStatus status; + + if ((status = Win32.NtGetContextThread(this, ref context)) >= NtStatus.Error) + Win32.Throw(status); + } } /// @@ -541,11 +568,9 @@ public unsafe void GetContext(ref Context context) /// A CONTEXT struct. public ContextAmd64 GetContext(ContextFlagsAmd64 flags) { - ContextAmd64 context = new ContextAmd64 - { - ContextFlags = flags - }; + ContextAmd64 context = new ContextAmd64(); + context.ContextFlags = flags; this.GetContext(ref context); return context; @@ -557,13 +582,16 @@ public ContextAmd64 GetContext(ContextFlagsAmd64 flags) /// A Context structure. The ContextFlags must be set appropriately. public void GetContext(ref ContextAmd64 context) { + NtStatus status; + // HACK: To avoid a datatype misalignment error, allocate some // aligned memory. - using (AlignedMemoryAlloc data = new AlignedMemoryAlloc(Utils.SizeOf(16, ContextAmd64.SizeOf), 16)) + using (var data = new AlignedMemoryAlloc(Utils.SizeOf(16), 16)) { - data.WriteStruct(context); + data.WriteStruct(context); - Win32.NtGetContextThread(this, data).ThrowIf(); + if ((status = Win32.NtGetContextThread(this, data)) >= NtStatus.Error) + Win32.Throw(status); context = data.ReadStruct(); } @@ -576,7 +604,10 @@ public void GetContext(ref ContextAmd64 context) /// A Context structure. The ContextFlags must be set appropriately. public void GetContextWow64(ref Context context) { - Win32.RtlWow64GetThreadContext(this, ref context).ThrowIf(); + NtStatus status; + + if ((status = Win32.RtlWow64GetThreadContext(this, ref context)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -617,32 +648,46 @@ public NtStatus GetExitStatus() private int GetInformationInt32(ThreadInformationClass infoClass) { - int value; - int retLength; - - Win32.NtQueryInformationThread( - this, - infoClass, - out value, - sizeof(int), - out retLength - ).ThrowIf(); + if ( + KProcessHacker.Instance != null && + infoClass == ThreadInformationClass.ThreadIoPriority + ) + { + unsafe + { + int value; + int retLength; - return value; + KProcessHacker.Instance.KphQueryInformationThread( + this, infoClass, new IntPtr(&value), sizeof(int), out retLength + ); + + return value; + } + } + else + { + NtStatus status; + int value; + int retLength; + + if ((status = Win32.NtQueryInformationThread( + this, infoClass, out value, sizeof(int), out retLength)) >= NtStatus.Error) + Win32.Throw(status); + + return value; + } } private IntPtr GetInformationIntPtr(ThreadInformationClass infoClass) { + NtStatus status; IntPtr value; int retLength; - Win32.NtQueryInformationThread( - this, - infoClass, - out value, - IntPtr.Size, - out retLength - ).ThrowIf(); + if ((status = Win32.NtQueryInformationThread( + this, infoClass, out value, IntPtr.Size, out retLength)) >= NtStatus.Error) + Win32.Throw(status); return value; } @@ -673,16 +718,13 @@ public int GetLastSystemCall() /// A system call number. public unsafe int GetLastSystemCall(out int firstArgument) { + NtStatus status; int* data = stackalloc int[2]; int retLength; - Win32.NtQueryInformationThread( - this, - ThreadInformationClass.ThreadLastSystemCall, - data, - sizeof(int) * 2, - out retLength - ).ThrowIf(); + if ((status = Win32.NtQueryInformationThread( + this, ThreadInformationClass.ThreadLastSystemCall, data, sizeof(int) * 2, out retLength)) >= NtStatus.Error) + Win32.Throw(status); firstArgument = data[0]; @@ -766,13 +808,12 @@ public IntPtr GetWin32StartAddress() /// The impersonation level to request. public void Impersonate(ThreadHandle clientThreadHandle, SecurityImpersonationLevel impersonationLevel) { - SecurityQualityOfService securityQos = new SecurityQualityOfService(impersonationLevel, false, false); + NtStatus status; + SecurityQualityOfService securityQos = + new SecurityQualityOfService(impersonationLevel, false, false); - Win32.NtImpersonateThread( - this, - clientThreadHandle, - ref securityQos - ).ThrowIf(); + if ((status = Win32.NtImpersonateThread(this, clientThreadHandle, ref securityQos)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -780,7 +821,10 @@ ref securityQos /// public void ImpersonateAnonymous() { - Win32.NtImpersonateAnonymousToken(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtImpersonateAnonymousToken(this)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -856,13 +900,16 @@ public void QueueApc(ApcRoutine action, IntPtr parameter) /// The third parameter to pass to the function. public void QueueApc(IntPtr address, IntPtr param1, IntPtr param2, IntPtr param3) { - Win32.NtQueueApcThread( + NtStatus status; + + if ((status = Win32.NtQueueApcThread( this, address, param1, param2, param3 - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void RemoteCall(IntPtr address, IntPtr[] arguments) @@ -872,7 +919,12 @@ public void RemoteCall(IntPtr address, IntPtr[] arguments) public void RemoteCall(IntPtr address, IntPtr[] arguments, bool alreadySuspended) { - ProcessHandle processHandle = new ProcessHandle(this.GetProcessId(), ProcessAccess.VmWrite); + ProcessHandle processHandle; + + if (KProcessHacker.Instance != null) + processHandle = this.GetProcess(ProcessAccess.VmWrite); + else + processHandle = new ProcessHandle(this.GetProcessId(), ProcessAccess.VmWrite); using (processHandle) this.RemoteCall(processHandle, address, arguments, alreadySuspended); @@ -880,7 +932,9 @@ public void RemoteCall(IntPtr address, IntPtr[] arguments, bool alreadySuspended public void RemoteCall(ProcessHandle processHandle, IntPtr address, IntPtr[] arguments, bool alreadySuspended) { - Win32.RtlRemoteCall( + NtStatus status; + + if ((status = Win32.RtlRemoteCall( processHandle, this, address, @@ -888,7 +942,8 @@ public void RemoteCall(ProcessHandle processHandle, IntPtr address, IntPtr[] arg arguments, false, alreadySuspended - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -896,9 +951,11 @@ public void RemoteCall(ProcessHandle processHandle, IntPtr address, IntPtr[] arg /// public int Resume() { + NtStatus status; int suspendCount; - Win32.NtResumeThread(this, out suspendCount).ThrowIf(); + if ((status = Win32.NtResumeThread(this, out suspendCount)) >= NtStatus.Error) + Win32.Throw(status); return suspendCount; } @@ -926,9 +983,19 @@ public void SetBasePriorityWin32(ThreadPriorityLevel basePriority) /// Sets the thread's context. /// /// A CONTEXT struct. - public void SetContext(Context context) + public unsafe void SetContext(Context context) { - Win32.NtSetContextThread(this, ref context).ThrowIf(); + if (KProcessHacker.Instance != null) + { + KProcessHacker.Instance.KphSetContextThread(this, &context); + } + else + { + NtStatus status; + + if ((status = Win32.NtSetContextThread(this, ref context)) >= NtStatus.Error) + Win32.Throw(status); + } } /// @@ -937,13 +1004,16 @@ public void SetContext(Context context) /// A CONTEXT struct. public void SetContext(ContextAmd64 context) { + NtStatus status; + // HACK: To avoid a datatype misalignment error, allocate // some aligned memory. - using (AlignedMemoryAlloc data = new AlignedMemoryAlloc(Utils.SizeOf(16, ContextAmd64.SizeOf), 16)) + using (var data = new AlignedMemoryAlloc(Utils.SizeOf(16), 16)) { - data.WriteStruct(context); + data.WriteStruct(context); - Win32.NtSetContextThread(this, data).ThrowIf(); + if ((status = Win32.NtSetContextThread(this, data)) >= NtStatus.Error) + Win32.Throw(status); } } @@ -954,7 +1024,10 @@ public void SetContext(ContextAmd64 context) /// A CONTEXT struct. public void SetContextWow64(Context context) { - Win32.RtlWow64SetThreadContext(this, ref context).ThrowIf(); + NtStatus status; + + if ((status = Win32.RtlWow64SetThreadContext(this, ref context)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -968,22 +1041,35 @@ public void SetCritical(bool critical) private void SetInformationInt32(ThreadInformationClass infoClass, int value) { - Win32.NtSetInformationThread( - this, - infoClass, - ref value, - sizeof(int) - ).ThrowIf(); + if ( + KProcessHacker.Instance != null && + infoClass == ThreadInformationClass.ThreadIoPriority + ) + { + unsafe + { + KProcessHacker.Instance.KphSetInformationThread( + this, infoClass, new IntPtr(&value), sizeof(int) + ); + } + } + else + { + NtStatus status; + + if ((status = Win32.NtSetInformationThread( + this, infoClass, ref value, sizeof(int))) >= NtStatus.Error) + Win32.Throw(status); + } } private void SetInformationIntPtr(ThreadInformationClass infoClass, IntPtr value) { - Win32.NtSetInformationThread( - this, - infoClass, - ref value, - sizeof(int) - ).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtSetInformationThread( + this, infoClass, ref value, sizeof(int))) >= NtStatus.Error) + Win32.Throw(status); } public void SetIoPriority(int ioPriority) @@ -1031,9 +1117,11 @@ public void SetToken(TokenHandle tokenHandle) /// public int Suspend() { + NtStatus status; int suspendCount; - Win32.NtSuspendThread(this, out suspendCount).ThrowIf(); + if ((status = Win32.NtSuspendThread(this, out suspendCount)) >= NtStatus.Error) + Win32.Throw(status); return suspendCount; } @@ -1052,7 +1140,24 @@ public void Terminate() /// The exit status. public void Terminate(NtStatus exitStatus) { - Win32.NtTerminateThread(this, exitStatus).ThrowIf(); + if (KProcessHacker.Instance != null) + { + try + { + KProcessHacker.Instance.KphTerminateThread(this, exitStatus); + return; + } + catch (WindowsException ex) + { + if (ex.ErrorCode != Win32Error.NotSupported) + throw ex; + } + } + + NtStatus status; + + if ((status = Win32.NtTerminateThread(this, exitStatus)) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -1075,14 +1180,23 @@ public void WalkStack(WalkStackDelegate walkStackCallback) /// public void WalkStack(WalkStackDelegate walkStackCallback, OSArch architecture) { - // We need to duplicate the handle to get QueryInformation access. - using (NativeHandle dupThreadHandle = this.Duplicate(OSVersion.MinThreadQueryInfoAccess)) - using (ProcessHandle phandle = new ProcessHandle( - FromHandle(dupThreadHandle).GetBasicInformation().ClientId.ProcessId, - ProcessAccess.QueryInformation | ProcessAccess.VmRead - )) + if (KProcessHacker.Instance != null) { - this.WalkStack(phandle, walkStackCallback, architecture); + // Use KPH to open the parent process. + using (var phandle = this.GetProcess(ProcessAccess.QueryInformation | ProcessAccess.VmRead)) + this.WalkStack(phandle, walkStackCallback, architecture); + } + else + { + // We need to duplicate the handle to get QueryInformation access. + using (var dupThreadHandle = this.Duplicate(OSVersion.MinThreadQueryInfoAccess)) + using (var phandle = new ProcessHandle( + ThreadHandle.FromHandle(dupThreadHandle).GetBasicInformation().ClientId.ProcessId, + ProcessAccess.QueryInformation | ProcessAccess.VmRead + )) + { + this.WalkStack(phandle, walkStackCallback, architecture); + } } } @@ -1091,7 +1205,7 @@ public void WalkStack(WalkStackDelegate walkStackCallback, OSArch architecture) /// /// A handle to the thread's parent process. /// A callback to execute. - public void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCallback) + public unsafe void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCallback) { this.WalkStack(parentProcess, walkStackCallback, OSVersion.Architecture); } @@ -1106,9 +1220,9 @@ public void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCa /// On 64-bit systems, this value can be set to I386 to walk the /// 32-bit stack. /// - public void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCallback, OSArch architecture) + public unsafe void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCallback, OSArch architecture) { - bool suspended; + bool suspended = false; // Suspend the thread to avoid inaccurate thread stacks. try @@ -1124,24 +1238,24 @@ public void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCa // Use KPH for reading memory if we can. ReadProcessMemoryProc64 readMemoryProc = null; - //if (KProcessHacker.Instance != null) - //{ - // readMemoryProc = - // (IntPtr processHandle, ulong baseAddress, IntPtr buffer, int size, out int bytesRead) - // => KProcessHacker.Instance.KphReadVirtualMemorySafe( - // ProcessHandle.FromHandle(processHandle), (int)baseAddress, buffer, size, out bytesRead - // ).IsSuccess(); - //} + if (KProcessHacker.Instance != null) + { + readMemoryProc = new ReadProcessMemoryProc64( + delegate(IntPtr processHandle, ulong baseAddress, IntPtr buffer, int size, out int bytesRead) + { + return KProcessHacker.Instance.KphReadVirtualMemorySafe( + ProcessHandle.FromHandle(processHandle), (int)baseAddress, buffer, size, out bytesRead).IsSuccess(); + }); + } try { // x86/WOW64 stack walk. if (OSVersion.Architecture == OSArch.I386 || (OSVersion.Architecture == OSArch.Amd64 && architecture == OSArch.I386)) { - Context context = new Context - { - ContextFlags = ContextFlags.All - }; + Context context = new Context(); + + context.ContextFlags = ContextFlags.All; if (OSVersion.Architecture == OSArch.I386) { @@ -1155,24 +1269,14 @@ public void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCa } // Set up the initial stack frame structure. - StackFrame64 stackFrame = new StackFrame64 - { - AddrPC = - { - Mode = AddressMode.AddrModeFlat, - Offset = (ulong)context.Eip - }, - AddrStack = - { - Mode = AddressMode.AddrModeFlat, - Offset = (ulong)context.Esp - }, - AddrFrame = - { - Mode = AddressMode.AddrModeFlat, - Offset = (ulong)context.Ebp - } - }; + var stackFrame = new StackFrame64(); + + stackFrame.AddrPC.Mode = AddressMode.AddrModeFlat; + stackFrame.AddrPC.Offset = (ulong)context.Eip; + stackFrame.AddrStack.Mode = AddressMode.AddrModeFlat; + stackFrame.AddrStack.Offset = (ulong)context.Esp; + stackFrame.AddrFrame.Mode = AddressMode.AddrModeFlat; + stackFrame.AddrFrame.Offset = (ulong)context.Ebp; while (true) { @@ -1204,34 +1308,21 @@ public void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCa // x64 stack walk. else if (OSVersion.Architecture == OSArch.Amd64) { - ContextAmd64 context = new ContextAmd64 - { - ContextFlags = ContextFlagsAmd64.All - }; + ContextAmd64 context = new ContextAmd64(); + context.ContextFlags = ContextFlagsAmd64.All; // Get the context. this.GetContext(ref context); // Set up the initial stack frame structure. - StackFrame64 stackFrame = new StackFrame64 - { - AddrPC = - { - Mode = AddressMode.AddrModeFlat, - Offset = (ulong)context.Rip - }, - AddrStack = - { - Mode = AddressMode.AddrModeFlat, - Offset = (ulong)context.Rsp - }, - AddrFrame = - { - Mode = AddressMode.AddrModeFlat, - Offset = (ulong)context.Rbp - } - }; + var stackFrame = new StackFrame64(); + stackFrame.AddrPC.Mode = AddressMode.AddrModeFlat; + stackFrame.AddrPC.Offset = (ulong)context.Rip; + stackFrame.AddrStack.Mode = AddressMode.AddrModeFlat; + stackFrame.AddrStack.Offset = (ulong)context.Rsp; + stackFrame.AddrFrame.Mode = AddressMode.AddrModeFlat; + stackFrame.AddrFrame.Offset = (ulong)context.Rbp; while (true) { @@ -1279,12 +1370,12 @@ public void WalkStack(ProcessHandle parentProcess, WalkStackDelegate walkStackCa public class ThreadStackFrame { - private readonly IntPtr _pcAddress; - private readonly IntPtr _returnAddress; - private readonly IntPtr _frameAddress; - private readonly IntPtr _stackAddress; - private readonly IntPtr _bStoreAddress; - private readonly IntPtr[] _params; + private IntPtr _pcAddress; + private IntPtr _returnAddress; + private IntPtr _frameAddress; + private IntPtr _stackAddress; + private IntPtr _bStoreAddress; + private IntPtr[] _params; internal ThreadStackFrame(ref StackFrame64 stackFrame) { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/TimerHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/TimerHandle.cs index 2a7b8308f..fd75b906c 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/TimerHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/TimerHandle.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -46,12 +47,14 @@ public static TimerHandle Create(TimerAccess access, string name, TimerType type /// A handle to the timer. public static TimerHandle Create(TimerAccess access, string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TimerType type) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtCreateTimer(out handle, access, ref oa, type).ThrowIf(); + if ((status = Win32.NtCreateTimer(out handle, access, ref oa, type)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -66,18 +69,22 @@ public static TimerHandle FromHandle(IntPtr handle) return new TimerHandle(handle, false); } + private TimerApcRoutine _routine; + private TimerHandle(IntPtr handle, bool owned) : base(handle, owned) { } public TimerHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TimerAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenTimer(out handle, access, ref oa).ThrowIf(); + if ((status = Win32.NtOpenTimer(out handle, access, ref oa)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -97,9 +104,11 @@ public TimerHandle(string name, TimerAccess access) /// The state of the timer (whether it is signaled). public bool Cancel() { + NtStatus status; bool currentState; - Win32.NtCancelTimer(this, out currentState).ThrowIf(); + if ((status = Win32.NtCancelTimer(this, out currentState)) >= NtStatus.Error) + Win32.Throw(status); return currentState; } @@ -107,23 +116,17 @@ public bool Cancel() /// /// Gets information about the timer. /// - public TimerBasicInformation BasicInformation + public TimerBasicInformation GetBasicInformation() { - get - { - TimerBasicInformation tbi; - int retLength; - - Win32.NtQueryTimer( - this, - TimerInformationClass.TimerBasicInformation, - out tbi, - TimerBasicInformation.SizeOf, - out retLength - ).ThrowIf(); - - return tbi; - } + NtStatus status; + TimerBasicInformation tbi; + int retLength; + + if ((status = Win32.NtQueryTimer(this, TimerInformationClass.TimerBasicInformation, + out tbi, Marshal.SizeOf(typeof(TimerBasicInformation)), out retLength)) >= NtStatus.Error) + Win32.Throw(status); + + return tbi; } /// @@ -203,12 +206,14 @@ public bool Set(long dueTime, bool relative, TimerApcRoutine routine, IntPtr con /// The state of the timer (whether it is signaled). public bool Set(long dueTime, bool relative, TimerApcRoutine routine, IntPtr context, bool resume, int period) { + NtStatus status; long realDueTime = relative ? -dueTime : dueTime; bool previousState; // Keep the APC routine alive. + _routine = routine; - Win32.NtSetTimer( + if ((status = Win32.NtSetTimer( this, ref realDueTime, routine, @@ -216,7 +221,8 @@ public bool Set(long dueTime, bool relative, TimerApcRoutine routine, IntPtr con resume, period, out previousState - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return previousState; } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/TmHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/TmHandle.cs index 40eb00148..6450d191a 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/TmHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/TmHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -37,24 +38,33 @@ public static TmHandle Create( TmOptions createOptions ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); - UnicodeString logFileNameStr = new UnicodeString(logFileName); IntPtr handle; try { - Win32.NtCreateTransactionManager( - out handle, - access, - ref oa, - ref logFileNameStr, - createOptions, - 0 - ).ThrowIf(); + UnicodeString logFileNameStr = new UnicodeString(logFileName); + + try + { + if ((status = Win32.NtCreateTransactionManager( + out handle, + access, + ref oa, + ref logFileNameStr, + createOptions, + 0 + )) >= NtStatus.Error) + Win32.Throw(status); + } + finally + { + logFileNameStr.Dispose(); + } } finally { - logFileNameStr.Dispose(); oa.Dispose(); } @@ -72,19 +82,21 @@ private TmHandle(IntPtr handle, bool owned) public TmHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TmAccess access) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenTransactionManager( + if ((status = Win32.NtOpenTransactionManager( out handle, access, ref oa, IntPtr.Zero, IntPtr.Zero, 0 - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -94,113 +106,115 @@ public TmHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirect this.Handle = handle; } - public TmBasicInformation BasicInformation + public TmBasicInformation GetBasicInformation() { - get - { - TmBasicInformation basicInfo; - int retLength; + NtStatus status; + TmBasicInformation basicInfo; + int retLength; - Win32.NtQueryInformationTransactionManager( - this, - TmInformationClass.TransactionManagerBasicInformation, - out basicInfo, - TmBasicInformation.SizeOf, - out retLength - ).ThrowIf(); - - return basicInfo; - } + if ((status = Win32.NtQueryInformationTransactionManager( + this, + TmInformationClass.TransactionManagerBasicInformation, + out basicInfo, + Marshal.SizeOf(typeof(TmBasicInformation)), + out retLength + )) >= NtStatus.Error) + Win32.Throw(status); + + return basicInfo; } - public long LastRecoveredLsn + public long GetLastRecoveredLsn() { - get - { - TmRecoveryInformation recoveryInfo; - int retLength; - - Win32.NtQueryInformationTransactionManager( - this, - TmInformationClass.TransactionManagerRecoveryInformation, - out recoveryInfo, - TmRecoveryInformation.SizeOf, - out retLength - ).ThrowIf(); + NtStatus status; + TmRecoveryInformation recoveryInfo; + int retLength; - return recoveryInfo.LastRecoveredLsn; - } + if ((status = Win32.NtQueryInformationTransactionManager( + this, + TmInformationClass.TransactionManagerRecoveryInformation, + out recoveryInfo, + Marshal.SizeOf(typeof(TmRecoveryInformation)), + out retLength + )) >= NtStatus.Error) + Win32.Throw(status); + + return recoveryInfo.LastRecoveredLsn; } - public string LogFileName + public string GetLogFileName() { - get + NtStatus status; + int retLength; + + using (var data = new MemoryAlloc(0x1000)) { - int retLength; + status = Win32.NtQueryInformationTransactionManager( + this, + TmInformationClass.TransactionManagerLogPathInformation, + data, + data.Size, + out retLength + ); - using (MemoryAlloc data = new MemoryAlloc(0x1000)) + if (status == NtStatus.BufferTooSmall) { - NtStatus status = Win32.NtQueryInformationTransactionManager( + // Resize the buffer and try again. + data.ResizeNew(retLength); + + status = Win32.NtQueryInformationTransactionManager( this, TmInformationClass.TransactionManagerLogPathInformation, data, data.Size, out retLength ); + } - if (status == NtStatus.BufferTooSmall) - { - // Resize the buffer and try again. - data.ResizeNew(retLength); - - Win32.NtQueryInformationTransactionManager( - this, - TmInformationClass.TransactionManagerLogPathInformation, - data, - data.Size, - out retLength - ).ThrowIf(); - } - - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); - TmLogPathInformation logPathInfo = data.ReadStruct(); + TmLogPathInformation logPathInfo = data.ReadStruct(); - return data.ReadUnicodeString(TmLogPathInformation.LogPathOffset, logPathInfo.LogPathLength); - } + return data.ReadUnicodeString(TmLogPathInformation.LogPathOffset, logPathInfo.LogPathLength); } } - public Guid LogIdentity + public Guid GetLogIdentity() { - get - { - TmLogInformation logInfo; - int retLength; - - Win32.NtQueryInformationTransactionManager( - this, - TmInformationClass.TransactionManagerLogInformation, - out logInfo, - TmLogInformation.SizeOf, - out retLength - ).ThrowIf(); + NtStatus status; + TmLogInformation logInfo; + int retLength; - return logInfo.LogIdentity; - } + if ((status = Win32.NtQueryInformationTransactionManager( + this, + TmInformationClass.TransactionManagerLogInformation, + out logInfo, + Marshal.SizeOf(typeof(TmLogInformation)), + out retLength + )) >= NtStatus.Error) + Win32.Throw(status); + + return logInfo.LogIdentity; } public void Recover() { - Win32.NtRecoverTransactionManager(this).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRecoverTransactionManager(this)) >= NtStatus.Error) + Win32.Throw(status); } public void Rollforward(long virtualClock) { - Win32.NtRollforwardTransactionManager( + NtStatus status; + + if ((status = Win32.NtRollforwardTransactionManager( this, ref virtualClock - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/TokenHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/TokenHandle.cs index b3f0d1225..7415127dd 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/TokenHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/TokenHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; using ProcessHacker.Native.Security.AccessControl; @@ -48,7 +49,7 @@ PrivilegeSet privileges ) { using (var administratorsSid = Sid.GetWellKnownSid(WellKnownSidType.WinBuiltinAdministratorsSid)) - using (var thandle = OpenCurrentPrimary(TokenAccess.Query)) + using (var thandle = TokenHandle.OpenCurrentPrimary(TokenAccess.Query)) return Create(access, 0, thandle, tokenType, user, groups, privileges, administratorsSid, administratorsSid); } @@ -64,7 +65,7 @@ public static TokenHandle Create( Sid primaryGroup ) { - var statistics = existingTokenHandle.Statistics; + var statistics = existingTokenHandle.GetStatistics(); return Create( access, @@ -101,6 +102,7 @@ public static TokenHandle Create( TokenSource source ) { + NtStatus status; TokenUser tokenUser = new TokenUser(user); TokenGroups tokenGroups = new TokenGroups(groups); TokenPrivileges tokenPrivileges = new TokenPrivileges(privileges); @@ -112,7 +114,7 @@ TokenSource source try { - Win32.NtCreateToken( + if ((status = Win32.NtCreateToken( out handle, access, ref oa, @@ -126,7 +128,8 @@ TokenSource source ref tokenPrimaryGroup, ref tokenDefaultDacl, ref source - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -174,7 +177,7 @@ public static TokenHandle OpenSelf(TokenAccess access) public static TokenHandle OpenSystemToken(TokenAccess access) { - using (ProcessHandle phandle = new ProcessHandle(4, OSVersion.MinProcessQueryInfoAccess)) + using (var phandle = new ProcessHandle(4, OSVersion.MinProcessQueryInfoAccess)) { return phandle.GetToken(access); } @@ -182,9 +185,9 @@ public static TokenHandle OpenSystemToken(TokenAccess access) public static TokenHandle OpenSystemToken(TokenAccess access, SecurityImpersonationLevel impersonationLevel, TokenType type) { - using (ProcessHandle phandle = new ProcessHandle(4, OSVersion.MinProcessQueryInfoAccess)) + using (var phandle = new ProcessHandle(4, OSVersion.MinProcessQueryInfoAccess)) { - using (TokenHandle thandle = phandle.GetToken(TokenAccess.Duplicate | access)) + using (var thandle = phandle.GetToken(TokenAccess.Duplicate | access)) { return thandle.Duplicate(access, impersonationLevel, type); } @@ -202,22 +205,22 @@ public TokenHandle(IntPtr handle, bool owned) /// The desired access to the token. public TokenHandle(ProcessHandle handle, TokenAccess access) { - if (KProcessHacker2.Instance != null && KProcessHacker2.Instance.KphIsConnected) + IntPtr h; + + if (KProcessHacker.Instance != null) { - this.Handle = KProcessHacker2.Instance.KphOpenProcessToken(handle, access); + h = new IntPtr(KProcessHacker.Instance.KphOpenProcessToken(handle, access)); } else { - IntPtr thandle; - - if (!Win32.OpenProcessToken(handle, access, out thandle)) + if (!Win32.OpenProcessToken(handle, access, out h)) { this.MarkAsInvalid(); Win32.Throw(); } - - this.Handle = thandle; } + + this.Handle = h; } /// @@ -250,11 +253,10 @@ public TokenHandle(ThreadHandle handle, TokenAccess access, bool openAsSelf) public void AdjustGroups(Sid[] groups) { - TokenGroups tokenGroups = new TokenGroups - { - GroupCount = groups.Length, - Groups = new SidAndAttributes[groups.Length] - }; + TokenGroups tokenGroups = new TokenGroups(); + + tokenGroups.GroupCount = groups.Length; + tokenGroups.Groups = new SidAndAttributes[groups.Length]; for (int i = 0; i < groups.Length; i++) tokenGroups.Groups[i] = groups[i].ToSidAndAttributes(); @@ -267,20 +269,25 @@ public void AdjustPrivileges(PrivilegeSet privileges) { var tokenPrivileges = privileges.ToTokenPrivileges(); - Win32.NtAdjustPrivilegesToken(this, false, ref tokenPrivileges, 0, IntPtr.Zero, IntPtr.Zero).ThrowIf(); + Win32.AdjustTokenPrivileges(this, false, ref tokenPrivileges, 0, IntPtr.Zero, IntPtr.Zero); + + if (Marshal.GetLastWin32Error() != 0) + Win32.Throw(); } public bool CheckPrivileges(PrivilegeSet privileges) { + NtStatus status; bool result; - using (MemoryAlloc privilegesMemory = privileges.ToMemory()) + using (var privilegesMemory = privileges.ToMemory()) { - Win32.NtPrivilegeCheck( + if ((status = Win32.NtPrivilegeCheck( this, privilegesMemory, out result - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return result; } @@ -310,13 +317,15 @@ public TokenHandle Duplicate(TokenAccess access, SecurityImpersonationLevel impe /// Whether they are equal. public bool Equals(TokenHandle other) { + NtStatus status; bool equal; - Win32.NtCompareTokens( + if ((status = Win32.NtCompareTokens( this, other, out equal - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return equal; } @@ -325,56 +334,135 @@ out equal /// Gets the elevation type of the token. /// /// A TOKEN_ELEVATION_TYPE enum. - public TokenElevationType ElevationType + public TokenElevationType GetElevationType() { - get { return (TokenElevationType)this.GetInformationInt32(TokenInformationClass.TokenElevationType); } + return (TokenElevationType)this.GetInformationInt32(TokenInformationClass.TokenElevationType); } /// /// Gets the token's groups. /// /// A TokenGroupsData struct. - public Sid[] Groups + public Sid[] GetGroups() { - get { return this.GetGroupsInternal(TokenInformationClass.TokenGroups); } + return this.GetGroupsInternal(TokenInformationClass.TokenGroups); } - public TokenHandle LinkedToken + private Sid[] GetGroupsInternal(TokenInformationClass infoClass) { - get - { - NtStatus status; + int retLen = 0; - IntPtr handle = this.GetInformationIntPtr(TokenInformationClass.TokenLinkedToken, out status); + Win32.GetTokenInformation(this, infoClass, IntPtr.Zero, 0, out retLen); + + using (MemoryAlloc data = new MemoryAlloc(retLen)) + { + if (!Win32.GetTokenInformation(this, infoClass, data, + data.Size, out retLen)) + Win32.Throw(); - if (status == NtStatus.NoSuchLogonSession) - return null; + int count = data.ReadStruct().GroupCount; + Sid[] sids = new Sid[count]; - status.ThrowIf(); + for (int i = 0; i < count; i++) + { + var saa = data.ReadStruct(TokenGroups.GroupsOffset, i); + sids[i] = new Sid(saa.Sid, saa.Attributes); + } - return new TokenHandle(handle, true); + return sids; } } + private int GetInformationInt32(TokenInformationClass infoClass) + { + NtStatus status; + int value; + + value = this.GetInformationInt32(infoClass, out status); + + if (status >= NtStatus.Error) + Win32.Throw(status); + + return value; + } + + private int GetInformationInt32(TokenInformationClass infoClass, out NtStatus status) + { + int value; + int retLength; + + status = Win32.NtQueryInformationToken( + this, + infoClass, + out value, + sizeof(int), + out retLength + ); + + return value; + } + + private IntPtr GetInformationIntPtr(TokenInformationClass infoClass) + { + NtStatus status; + IntPtr value; + + value = this.GetInformationIntPtr(infoClass, out status); + + if (status >= NtStatus.Error) + Win32.Throw(status); + + return value; + } + + private IntPtr GetInformationIntPtr(TokenInformationClass infoClass, out NtStatus status) + { + IntPtr value; + int retLength; + + status = Win32.NtQueryInformationToken( + this, + infoClass, + out value, + IntPtr.Size, + out retLength + ); + + return value; + } + + public TokenHandle GetLinkedToken() + { + NtStatus status; + IntPtr handle; + + handle = this.GetInformationIntPtr(TokenInformationClass.TokenLinkedToken, out status); + + if (status == NtStatus.NoSuchLogonSession) + return null; + if (status >= NtStatus.Error) + Win32.Throw(status); + + return new TokenHandle(handle, true); + } + /// /// Gets the token's owner. /// /// A WindowsSID instance. - public Sid Owner + public Sid GetOwner() { - get - { - int retLen; + int retLen; - Win32.GetTokenInformation(this, TokenInformationClass.TokenOwner, IntPtr.Zero, 0, out retLen); + Win32.GetTokenInformation(this, TokenInformationClass.TokenOwner, IntPtr.Zero, 0, out retLen); - using (MemoryAlloc data = new MemoryAlloc(retLen)) - { - if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenOwner, data, data.Size, out retLen)) - Win32.Throw(); + using (MemoryAlloc data = new MemoryAlloc(retLen)) + { + if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenOwner, data, + data.Size, out retLen)) + Win32.Throw(); - return new Sid(data.ReadIntPtr(0)); - } + return new Sid(data.ReadIntPtr(0)); } } @@ -382,21 +470,19 @@ public Sid Owner /// Gets the token's primary group. /// /// A WindowsSID instance. - public Sid PrimaryGroup + public Sid GetPrimaryGroup() { - get - { - int retLen; + int retLen; - Win32.GetTokenInformation(this, TokenInformationClass.TokenPrimaryGroup, IntPtr.Zero, 0, out retLen); + Win32.GetTokenInformation(this, TokenInformationClass.TokenPrimaryGroup, IntPtr.Zero, 0, out retLen); - using (MemoryAlloc data = new MemoryAlloc(retLen)) - { - if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenPrimaryGroup, data, data.Size, out retLen)) - Win32.Throw(); + using (MemoryAlloc data = new MemoryAlloc(retLen)) + { + if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenPrimaryGroup, data, + data.Size, out retLen)) + Win32.Throw(); - return new Sid(data.ReadIntPtr(0)); - } + return new Sid(data.ReadIntPtr(0)); } } @@ -404,30 +490,28 @@ public Sid PrimaryGroup /// Gets the token's privileges. /// /// A TOKEN_PRIVILEGES structure. - public Privilege[] Privileges + public Privilege[] GetPrivileges() { - get - { - int retLen; - - Win32.GetTokenInformation(this, TokenInformationClass.TokenPrivileges, IntPtr.Zero, 0, out retLen); + int retLen; - using (MemoryAlloc data = new MemoryAlloc(retLen)) - { - if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenPrivileges, data, data.Size, out retLen)) - Win32.Throw(); + Win32.GetTokenInformation(this, TokenInformationClass.TokenPrivileges, IntPtr.Zero, 0, out retLen); - uint count = data.ReadUInt32(0); - Privilege[] privileges = new Privilege[count]; + using (MemoryAlloc data = new MemoryAlloc(retLen)) + { + if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenPrivileges, data, + data.Size, out retLen)) + Win32.Throw(); - for (int i = 0; i < count; i++) - { - var laa = data.ReadStruct(sizeof(int), LuidAndAttributes.SizeOf, i); - privileges[i] = new Privilege(this, laa.Luid, laa.Attributes); - } + uint count = data.ReadUInt32(0); + Privilege[] privileges = new Privilege[count]; - return privileges; + for (int i = 0; i < count; i++) + { + var laa = data.ReadStruct(sizeof(int), i); + privileges[i] = new Privilege(this, laa.Luid, laa.Attributes); } + + return privileges; } } @@ -435,77 +519,71 @@ public Privilege[] Privileges /// Gets the restricted token's restricting SIDs. /// /// A TokenGroupsData struct. - public Sid[] RestrictingGroups + public Sid[] GetRestrictingGroups() { - get { return this.GetGroupsInternal(TokenInformationClass.TokenRestrictedSids); } + return this.GetGroupsInternal(TokenInformationClass.TokenRestrictedSids); } /// - /// Gets/Sets the token's session ID. + /// Gets the token's session ID. /// /// The session ID. - public int SessionId + public int GetSessionId() { - get { return this.GetInformationInt32(TokenInformationClass.TokenSessionId); } - set { this.SetInformationInt32(TokenInformationClass.TokenSessionId, value); } + return this.GetInformationInt32(TokenInformationClass.TokenSessionId); } /// /// Gets the token's source. /// /// A TOKEN_SOURCE struct. - public TokenSource Source + public TokenSource GetSource() { - get - { - TokenSource source; - int retLen; + TokenSource source; + int retLen; - if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenSource, out source, TokenSource.SizeOf, out retLen)) - Win32.Throw(); + if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenSource, + out source, Marshal.SizeOf(typeof(TokenSource)), out retLen)) + Win32.Throw(); - return source; - } + return source; } /// /// Gets statistics about the token. /// /// A TOKEN_STATISTICS structure. - public TokenStatistics Statistics + public TokenStatistics GetStatistics() { - get - { - TokenStatistics statistics; - int retLen; + TokenStatistics statistics; + int retLen; - if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenStatistics, out statistics, TokenStatistics.SizeOf, out retLen)) - Win32.Throw(); + if (!Win32.GetTokenInformation(this, TokenInformationClass.TokenStatistics, + out statistics, Marshal.SizeOf(typeof(TokenStatistics)), out retLen)) + Win32.Throw(); - return statistics; - } + return statistics; } /// /// Gets the token's user. /// /// A WindowsSID instance. - public Sid User + public Sid GetUser() { - get - { - int retLen; + int retLen; - Win32.NtQueryInformationToken(this, TokenInformationClass.TokenUser, IntPtr.Zero, 0, out retLen); + Win32.GetTokenInformation(this, TokenInformationClass.TokenUser, IntPtr.Zero, 0, out retLen); - using (MemoryAlloc data = new MemoryAlloc(retLen)) - { - Win32.NtQueryInformationToken(this.Handle, TokenInformationClass.TokenUser, data, data.Size, out retLen).ThrowIf(); + using (MemoryAlloc data = new MemoryAlloc(retLen)) + { + if (!Win32.GetTokenInformation(this.Handle, TokenInformationClass.TokenUser, data, + data.Size, out retLen)) + Win32.Throw(); - TokenUser user = data.ReadStruct(); + TokenUser user = data.ReadStruct(); - return new Sid(user.User.Sid, user.User.Attributes); - } + return new Sid(user.User.Sid, user.User.Attributes); } } @@ -513,124 +591,42 @@ public Sid User /// Gets whether the token has UAC elevation applied. /// /// A boolean. - public bool IsElevated + public bool IsElevated() { - get { return this.GetInformationInt32(TokenInformationClass.TokenElevation) != 0; } + return this.GetInformationInt32(TokenInformationClass.TokenElevation) != 0; } /// /// Gets whether virtualization is allowed. /// /// A boolean. - public bool IsVirtualizationAllowed + public bool IsVirtualizationAllowed() { - get { return this.GetInformationInt32(TokenInformationClass.TokenVirtualizationAllowed) != 0; } + return this.GetInformationInt32(TokenInformationClass.TokenVirtualizationAllowed) != 0; } /// - /// Gets/Sets whether virtualization is enabled or disabled. + /// Gets whether virtualization is enabled. /// /// A boolean. - public bool IsVirtualizationEnabled + public bool IsVirtualizationEnabled() { - get { return this.GetInformationInt32(TokenInformationClass.TokenVirtualizationEnabled) != 0; } - set - { - int val = value ? 1 : 0; - - Win32.NtSetInformationToken(this, TokenInformationClass.TokenVirtualizationEnabled, ref val, 4).ThrowIf(); - } + return this.GetInformationInt32(TokenInformationClass.TokenVirtualizationEnabled) != 0; } - private Sid[] GetGroupsInternal(TokenInformationClass infoClass) - { - int retLen; - - Win32.GetTokenInformation(this, infoClass, IntPtr.Zero, 0, out retLen); - - using (MemoryAlloc data = new MemoryAlloc(retLen)) - { - if (!Win32.GetTokenInformation(this, infoClass, data, - data.Size, out retLen)) - Win32.Throw(); - - int count = data.ReadStruct(0, TokenGroups.SizeOf, 0).GroupCount; - Sid[] sids = new Sid[count]; - - for (int i = 0; i < count; i++) - { - var saa = data.ReadStruct(TokenGroups.GroupsOffset, SidAndAttributes.SizeOf, i); - sids[i] = new Sid(saa.Sid, saa.Attributes); - } - - return sids; - } - } - - private int GetInformationInt32(TokenInformationClass infoClass) + private void SetInformationInt32(TokenInformationClass infoClass, int value) { NtStatus status; - - int value = this.GetInformationInt32(infoClass, out status); - - status.ThrowIf(); - return value; - } - - private int GetInformationInt32(TokenInformationClass infoClass, out NtStatus status) - { - int value; - int retLength; - - status = Win32.NtQueryInformationToken( - this, - infoClass, - out value, - sizeof(int), - out retLength - ); - - return value; - } - - private void SetInformationInt32(TokenInformationClass infoClass, int value) - { - Win32.NtSetInformationToken( + if ((status = Win32.NtSetInformationToken( this, infoClass, ref value, sizeof(int) - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } - private IntPtr GetInformationIntPtr(TokenInformationClass infoClass) - { - NtStatus status; - - IntPtr value = this.GetInformationIntPtr(infoClass, out status); - - status.ThrowIf(); - - return value; - } - - private IntPtr GetInformationIntPtr(TokenInformationClass infoClass, out NtStatus status) - { - IntPtr value; - int retLength; - - status = Win32.NtQueryInformationToken( - this, - infoClass, - out value, - IntPtr.Size, - out retLength - ); - - return value; - } - /// /// Sets a privilege's attributes. /// @@ -638,12 +634,33 @@ out retLength /// The new attributes of the privilege. public void SetPrivilege(string privilegeName, SePrivilegeAttributes attributes) { - this.TrySetPrivilege(privilegeName, attributes).ThrowIf(); + if (!this.TrySetPrivilege(privilegeName, attributes)) + Win32.Throw(); } public void SetPrivilege(Luid privilegeLuid, SePrivilegeAttributes attributes) { - this.TrySetPrivilege(privilegeLuid, attributes).ThrowIf(); + if (!this.TrySetPrivilege(privilegeLuid, attributes)) + Win32.Throw(); + } + + public void SetSessionId(int sessionId) + { + this.SetInformationInt32(TokenInformationClass.TokenSessionId, sessionId); + } + + /// + /// Sets whether virtualization is enabled. + /// + /// Whether virtualization is enabled. + public void SetVirtualizationEnabled(bool enabled) + { + int value = enabled ? 1 : 0; + + if (!Win32.SetTokenInformation(this, TokenInformationClass.TokenVirtualizationEnabled, ref value, 4)) + { + Win32.Throw(); + } } /// @@ -652,7 +669,7 @@ public void SetPrivilege(Luid privilegeLuid, SePrivilegeAttributes attributes) /// The name of the privilege. /// The new attributes of the privilege. /// True if the function succeeded, otherwise false. - public NtStatus TrySetPrivilege(string privilegeName, SePrivilegeAttributes attributes) + public bool TrySetPrivilege(string privilegeName, SePrivilegeAttributes attributes) { return this.TrySetPrivilege( LsaPolicyHandle.LookupPolicyHandle.LookupPrivilegeValue(privilegeName), @@ -660,18 +677,22 @@ public NtStatus TrySetPrivilege(string privilegeName, SePrivilegeAttributes attr ); } - public NtStatus TrySetPrivilege(Luid privilegeLuid, SePrivilegeAttributes attributes) + public bool TrySetPrivilege(Luid privilegeLuid, SePrivilegeAttributes attributes) { - TokenPrivileges tkp = new TokenPrivileges - { - Privileges = new LuidAndAttributes[1], - PrivilegeCount = 1 - }; + TokenPrivileges tkp = new TokenPrivileges(); + tkp.Privileges = new LuidAndAttributes[1]; + + tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = attributes; tkp.Privileges[0].Luid = privilegeLuid; - return Win32.NtAdjustPrivilegesToken(this, false, ref tkp, 0, IntPtr.Zero, IntPtr.Zero); + Win32.AdjustTokenPrivileges(this, false, ref tkp, 0, IntPtr.Zero, IntPtr.Zero); + + if (Marshal.GetLastWin32Error() != 0) + return false; + + return true; } } } \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker.Native/Objects/TokenWithLinkedToken.cs b/1.x/trunk/ProcessHacker.Native/Objects/TokenWithLinkedToken.cs index aec73840b..4fc88a731 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/TokenWithLinkedToken.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/TokenWithLinkedToken.cs @@ -20,13 +20,15 @@ * along with Process Hacker. If not, see . */ +using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; +using System; namespace ProcessHacker.Native.Objects { public sealed class TokenWithLinkedToken : IWithToken { - private readonly TokenHandle _token; + private TokenHandle _token; public TokenWithLinkedToken(TokenHandle token) { @@ -35,7 +37,7 @@ public TokenWithLinkedToken(TokenHandle token) public TokenHandle GetToken() { - return _token.LinkedToken; + return _token.GetLinkedToken(); } public TokenHandle GetToken(TokenAccess access) diff --git a/1.x/trunk/ProcessHacker.Native/Objects/TransactionHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/TransactionHandle.cs index 8870ed89b..765dd1c33 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/TransactionHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/TransactionHandle.cs @@ -21,6 +21,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -30,7 +31,7 @@ public class TransactionHandle : NativeHandle { public struct CurrentTransactionContext : IDisposable { - private readonly TransactionHandle _oldHandle; + private TransactionHandle _oldHandle; private bool _disposed; internal CurrentTransactionContext(TransactionHandle handle) @@ -83,6 +84,7 @@ public static TransactionHandle Create( string description ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; @@ -95,7 +97,7 @@ string description try { - Win32.NtCreateTransaction( + if ((status = Win32.NtCreateTransaction( out handle, access, ref oa, @@ -106,7 +108,8 @@ string description 0, ref timeout, ref descriptionStr - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -123,12 +126,14 @@ ref descriptionStr public static TransactionHandle GetCurrent() { - IntPtr handle = Win32.RtlGetCurrentTransaction(); + IntPtr handle; + + handle = Win32.RtlGetCurrentTransaction(); if (handle != IntPtr.Zero) return new TransactionHandle(handle, false); - - return null; + else + return null; } public static void SetCurrent(TransactionHandle transactionHandle) @@ -154,18 +159,20 @@ public TransactionHandle( TransactionAccess access ) { + NtStatus status; ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory); IntPtr handle; try { - Win32.NtOpenTransaction( + if ((status = Win32.NtOpenTransaction( out handle, access, ref oa, ref unitOfWorkGuid, tmHandle ?? IntPtr.Zero - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -182,51 +189,51 @@ public static TransactionHandle FromHandle(IntPtr handle) public void Commit(bool wait) { - Win32.NtCommitTransaction(this, wait).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtCommitTransaction(this, wait)) >= NtStatus.Error) + Win32.Throw(status); } - public TransactionBasicInformation BasicInformation + public TransactionBasicInformation GetBasicInformation() { - get - { - TransactionBasicInformation basicInfo; - int retLength; + NtStatus status; + TransactionBasicInformation basicInfo; + int retLength; - Win32.NtQueryInformationTransaction( - this, - TransactionInformationClass.TransactionBasicInformation, - out basicInfo, - TransactionBasicInformation.SizeOf, - out retLength - ).ThrowIf(); + if ((status = Win32.NtQueryInformationTransaction( + this, + TransactionInformationClass.TransactionBasicInformation, + out basicInfo, + Marshal.SizeOf(typeof(TransactionBasicInformation)), + out retLength + )) >= NtStatus.Error) + Win32.Throw(status); - return basicInfo; - } + return basicInfo; } - public string Description + public string GetDescription() { - get + using (var data = this.GetPropertiesInformation()) { - using (MemoryAlloc data = this.GetPropertiesInformation()) - { - TransactionPropertiesInformation propertiesInfo = data.ReadStruct(); + var propertiesInfo = data.ReadStruct(); - return data.ReadUnicodeString( - TransactionPropertiesInformation.DescriptionOffset, - propertiesInfo.DescriptionLength / 2 - ); - } + return data.ReadUnicodeString( + TransactionPropertiesInformation.DescriptionOffset, + propertiesInfo.DescriptionLength / 2 + ); } } private MemoryAlloc GetPropertiesInformation() { + NtStatus status; int retLength; - MemoryAlloc data = new MemoryAlloc(0x1000); + var data = new MemoryAlloc(0x1000); - NtStatus status = Win32.NtQueryInformationTransaction( + status = Win32.NtQueryInformationTransaction( this, TransactionInformationClass.TransactionPropertiesInformation, data, @@ -248,29 +255,27 @@ out retLength ); } - if (status.IsError()) + if (status >= NtStatus.Error) { data.Dispose(); - status.Throw(); + Win32.Throw(status); } return data; } - public long Timeout + public long GetTimeout() { - get - { - using (MemoryAlloc data = this.GetPropertiesInformation()) - { - return data.ReadStruct().Timeout; - } - } + using (var data = this.GetPropertiesInformation()) + return data.ReadStruct().Timeout; } public void Rollback(bool wait) { - Win32.NtRollbackTransaction(this, wait).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtRollbackTransaction(this, wait)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/TypeObjectHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/TypeObjectHandle.cs index 21fa5b789..85cf0b29a 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/TypeObjectHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/TypeObjectHandle.cs @@ -1,4 +1,8 @@ -using ProcessHacker.Native.Api; +using System; +using System.Collections.Generic; +using System.Text; +using ProcessHacker.Native; +using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; namespace ProcessHacker.Native.Objects @@ -15,7 +19,7 @@ public TypeObjectHandle(string name, ObjectFlags objectFlags, DirectoryHandle ro try { - //this.Handle = KProcessHacker.Instance.KphOpenType(oa).ToIntPtr(); + this.Handle = KProcessHacker.Instance.KphOpenType(oa).ToIntPtr(); } finally { diff --git a/1.x/trunk/ProcessHacker.Native/Objects/WindowHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/WindowHandle.cs index e67a00a66..91e29aae4 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/WindowHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/WindowHandle.cs @@ -1,5 +1,7 @@ using System; using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; using ProcessHacker.Native.Api; namespace ProcessHacker.Native.Objects @@ -8,7 +10,7 @@ namespace ProcessHacker.Native.Objects public struct WindowHandle : IEquatable, IEquatable, System.Windows.Forms.IWin32Window { - private static readonly WindowHandle _zero = new WindowHandle(IntPtr.Zero); + private static WindowHandle _zero = new WindowHandle(IntPtr.Zero); public static WindowHandle Zero { @@ -52,7 +54,7 @@ public static implicit operator IntPtr(WindowHandle windowHandle) return windowHandle.Handle; } - private readonly IntPtr _handle; + private IntPtr _handle; public WindowHandle(IntPtr handle) { @@ -104,83 +106,70 @@ public bool Equals(IntPtr other) return this.Handle.Equals(other); } - public ClientId ClientId + public ClientId GetClientId() { - get - { - int pid; + int tid, pid; - int tid = Win32.GetWindowThreadProcessId(this, out pid); + tid = Win32.GetWindowThreadProcessId(this, out pid); - return new ClientId(pid, tid); - } + return new ClientId(pid, tid); } - public WindowHandle Parent + public WindowHandle GetParent() { - get { return new WindowHandle(Win32.GetParent(this)); } + return new WindowHandle(Win32.GetParent(this)); } - public WindowPlacement Placement + public WindowPlacement GetPlacement() { - get - { - WindowPlacement placement = new WindowPlacement - { - Length = WindowPlacement.SizeOf - }; + WindowPlacement placement = new WindowPlacement(); + placement.Length = Marshal.SizeOf(placement); + Win32.GetWindowPlacement(this, ref placement); - Win32.GetWindowPlacement(this, ref placement); - - return placement; - } + return placement; } - public Rectangle Rectangle + public Rectangle GetRectangle() { - get - { - Rect rect; - - if (!Win32.GetWindowRect(this, out rect)) - return Rectangle.Empty; + Rect rect; + if (!Win32.GetWindowRect(this, out rect)) + return Rectangle.Empty; + else return rect.ToRectangle(); - } } - public string Text + public string GetText() { - get + int retChars; + + using (var data = new MemoryAlloc(0x200)) { - using (MemoryAlloc data = new MemoryAlloc(0x200)) - { - int retChars = Win32.InternalGetWindowText(this, data, data.Size/2); + retChars = Win32.InternalGetWindowText(this, data, data.Size / 2); - return data.ReadUnicodeString(0, retChars); - } + return data.ReadUnicodeString(0, retChars); } } - public bool IsHung + public bool IsHung() { - get { return Win32.IsHungAppWindow(this); } + return Win32.IsHungAppWindow(this); } - public bool IsParent + public bool IsParent() { - get { return this.Parent.Equals(Zero); } + return this.GetParent().Equals(WindowHandle.Zero); } - public bool IsWindow + public bool IsWindow() { - get { return Win32.IsWindow(this); } + return Win32.IsWindow(this); } - public bool IsVisible + public bool IsVisible() { - get { return Win32.IsWindowVisible(this); } + return Win32.IsWindowVisible(this); } public bool PostMessage(WindowMessage message, int wParam, int lParam) @@ -188,7 +177,7 @@ public bool PostMessage(WindowMessage message, int wParam, int lParam) return Win32.PostMessage(this, message, wParam, lParam); } - public IntPtr SendMessage(WindowMessage message, IntPtr wParam, IntPtr lParam) + public IntPtr SendMessage(WindowMessage message, int wParam, int lParam) { return Win32.SendMessage(this, message, wParam, lParam); } diff --git a/1.x/trunk/ProcessHacker.Native/Objects/WindowStationHandle.cs b/1.x/trunk/ProcessHacker.Native/Objects/WindowStationHandle.cs index 63fb29e5f..180a970f0 100644 --- a/1.x/trunk/ProcessHacker.Native/Objects/WindowStationHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/Objects/WindowStationHandle.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Security; @@ -48,7 +50,7 @@ public WindowStationHandle(string name, WindowStationAccess access) { this.Handle = Win32.OpenWindowStation(name, false, access); - if (this.Handle == IntPtr.Zero) + if (this.Handle == System.IntPtr.Zero) Win32.Throw(); } diff --git a/1.x/trunk/ProcessHacker.Native/ProcessHacker.Native.csproj b/1.x/trunk/ProcessHacker.Native/ProcessHacker.Native.csproj index f91925c68..e6e74a769 100644 --- a/1.x/trunk/ProcessHacker.Native/ProcessHacker.Native.csproj +++ b/1.x/trunk/ProcessHacker.Native/ProcessHacker.Native.csproj @@ -10,7 +10,7 @@ Properties ProcessHacker.Native ProcessHacker.Native - v4.5 + v4.0 512 @@ -47,8 +47,7 @@ AnyCPU - MinimumRecommendedRules.ruleset - false + AllRules.ruleset pdbonly @@ -62,7 +61,6 @@ 1591 AnyCPU AllRules.ruleset - false @@ -126,7 +124,6 @@ - @@ -152,12 +149,6 @@ - - UserControl - - - UserControl - @@ -280,6 +271,18 @@ + + Form + + + ChooseProcessDialog.cs + + + Form + + + HandlePropertiesWindow.cs + @@ -289,6 +292,14 @@ + + + ChooseProcessDialog.cs + + + HandlePropertiesWindow.cs + + {8E10F5E8-D4FA-4980-BB23-2EDD134AC15E} diff --git a/1.x/trunk/ProcessHacker.Native/PropertySheet/ProcessPropertySheetPage.cs b/1.x/trunk/ProcessHacker.Native/PropertySheet/ProcessPropertySheetPage.cs deleted file mode 100644 index 425d78117..000000000 --- a/1.x/trunk/ProcessHacker.Native/PropertySheet/ProcessPropertySheetPage.cs +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Process Hacker - - * Process Property Sheet Control - * - * Copyright (C) 2011 wj32 - * Copyright (C) 2011 dmex - * - * This file is part of Process Hacker. - * - * Process Hacker is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Process Hacker is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Process Hacker. If not, see . - */ - -using System; -using System.Runtime.InteropServices; - -using ProcessHacker.Native; -using ProcessHacker.Native.Api; - -namespace ProcessHacker.Api -{ - public class ProcessPropertySheetPage : PropertySheetPage - { - private IntPtr _pageHandle; - private IntPtr _dialogTemplate; - private readonly DialogProc _dialogProc; - private readonly PropSheetPageCallback _pagePageProc; - - public ProcessPropertySheetPage() - { - _dialogProc = this.DialogProc; - _pagePageProc = this.PropPageProc; - } - - protected override void Dispose(bool disposing) - { - MemoryAlloc.PrivateHeap.Free(this._dialogTemplate); - - base.Dispose(disposing); - } - - public override IntPtr CreatePageHandle() - { - if (_pageHandle != IntPtr.Zero) - return _pageHandle; - - PropSheetPageW psp = new PropSheetPageW(); - - // *Must* be 260x260. See PhAddPropPageLayoutItem in procprp.c. - _dialogTemplate = CreateDialogTemplate(260, 260, this.Text, 8, "MS Shell Dlg"); - - psp.dwSize = PropSheetPageW.SizeOf; - psp.dwFlags = PropSheetPageFlags.UseCallback | PropSheetPageFlags.DlgIndirect | PropSheetPageFlags.UseTitle | PropSheetPageFlags.DlgIndirect; - - psp.pszTitle = Marshal.StringToHGlobalUni("Details"); - - psp.pResource = _dialogTemplate; - - psp.pfnDlgProc = Marshal.GetFunctionPointerForDelegate(_dialogProc); - psp.pfnCallback = Marshal.GetFunctionPointerForDelegate(_pagePageProc); - - _pageHandle = Win32.CreatePropertySheetPageW(ref psp); - - return _pageHandle; - } - - protected override bool DialogProc(IntPtr hwndDlg, WindowMessage uMsg, IntPtr wParam, IntPtr lParam) - { - switch (uMsg) - { - case WindowMessage.InitDialog: - { - Rect initialSize = new Rect - { - Left = 0, - Top = 0, - Right = 260, - Bottom = 260 - }; - - Win32.MapDialogRect(hwndDlg, ref initialSize); - - this.Size = new System.Drawing.Size(initialSize.Right, initialSize.Bottom); - - this.Refresh(); - } - break; - } - - return base.DialogProc(hwndDlg, uMsg, wParam, lParam); - } - } -} diff --git a/1.x/trunk/ProcessHacker.Native/PropertySheet/PropertySheetPage.cs b/1.x/trunk/ProcessHacker.Native/PropertySheet/PropertySheetPage.cs deleted file mode 100644 index 278b1a0d3..000000000 --- a/1.x/trunk/ProcessHacker.Native/PropertySheet/PropertySheetPage.cs +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Process Hacker - - * Property Sheet Control - * - * Copyright (C) 2010 wj32 - * Copyright (C) 2010 dmex - * - * This file is part of Process Hacker. - * - * Process Hacker is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Process Hacker is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Process Hacker. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Windows.Forms; -using ProcessHacker.Native; -using ProcessHacker.Native.Api; - -namespace ProcessHacker.Api -{ - public class PropertySheetPage : UserControl - { - private static readonly List _keepAliveList = new List(); - - public unsafe static IntPtr CreateDialogTemplate(int width, int height, string title, short fontSize, string fontName) - { - DlgTemplate* template; - int templateStructSize; - int offset; - - templateStructSize = DlgTemplate.SizeOf; - template = (DlgTemplate*)MemoryAlloc.PrivateHeap.Allocate(templateStructSize + 2 + 2 + (title.Length + 1) * 2 + 2 + (fontName.Length + 1) * 2); - template->style = 0x40; // DS_SETFONT - template->dwExtendedStyle = 0; - template->cdit = 0; - template->x = 0; - template->y = 0; - template->cx = (short)width; - template->cy = (short)height; - - offset = templateStructSize; - - // No menu - *(short*)((byte*)template + offset) = 0; - offset += 2; - - // No class - *(short*)((byte*)template + offset) = 0; - offset += 2; - - // Title - fixed (char* titlePtr = title) - Win32.RtlMoveMemory((byte*)template + offset, titlePtr, (IntPtr)((title.Length + 1) * 2)); - offset += (title.Length + 1) * 2; - - // Font size - *(short*)((byte*)template + offset) = fontSize; - offset += 2; - - // Font name - fixed (char* fontNamePtr = fontName) - Win32.RtlMoveMemory((byte*)template + offset, fontNamePtr, (IntPtr)((fontName.Length + 1) * 2)); - //offset += (fontName.Length + 1) * 2; - - return (IntPtr)template; - } - - public event EventHandler PageGotFocus; - public event EventHandler PageLostFocus; - - private readonly IContainer components; - private IntPtr _dialogWindowParentHandle; - - public PropertySheetPage() - { - components = new Container(); - this.AutoScaleMode = AutoScaleMode.Font; - } - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - - base.Dispose(disposing); - } - - public virtual IntPtr CreatePageHandle() - { - throw new NotImplementedException(); - } - - protected virtual bool DialogProc(IntPtr hwndDlg, WindowMessage uMsg, IntPtr wParam, IntPtr lParam) - { - switch (uMsg) - { - case WindowMessage.InitDialog: - { - _dialogWindowParentHandle = Win32.GetParent(hwndDlg); - Win32.SetParent(this.Handle, hwndDlg); - - this.Refresh(); - } - break; - case WindowMessage.Notify: - return OnDialogNotify(hwndDlg, wParam, lParam); - } - - return false; - } - - private unsafe bool OnDialogNotify(IntPtr hwndDlg, IntPtr wParam, IntPtr lParam) - { - Win32.NmHdr* hdr = (Win32.NmHdr*)lParam; - - if (hdr->hwndFrom != _dialogWindowParentHandle) - return false; - - switch (hdr->code) - { - case (uint)PropSheetNotification.SetActive: - if (this.PageGotFocus != null) - this.PageGotFocus(this, new EventArgs()); - break; - case (uint)PropSheetNotification.KillActive: - if (this.PageLostFocus != null) - this.PageLostFocus(this, new EventArgs()); - break; - } - - return false; - } - - protected int PropPageProc(IntPtr hwnd, PropSheetPageCallbackMessage uMsg, IntPtr ppsp) - { - switch (uMsg) - { - case PropSheetPageCallbackMessage.AddRef: - _keepAliveList.Add(this); - break; - case PropSheetPageCallbackMessage.Release: - _keepAliveList.Remove(this); - break; - } - - return 1; - } - } -} diff --git a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/Acl.cs b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/Acl.cs index 02bdf0a97..cdc3b0bb0 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/Acl.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/Acl.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; @@ -39,10 +40,12 @@ public static implicit operator IntPtr(Acl acl) return acl.Memory; } - private readonly MemoryRegion _memory; + private MemoryRegion _memory; public Acl(int size) { + NtStatus status; + // Reserve 8 bytes for the ACL header. if (size < 8) throw new ArgumentException("Size must be greater than or equal to 8 bytes."); @@ -51,11 +54,11 @@ public Acl(int size) _memory = new MemoryAlloc(size); // Initialize the ACL. - if (Win32.RtlCreateAcl( + if ((status = Win32.RtlCreateAcl( _memory, size, Win32.AclRevision - ).IsError()) + )) >= NtStatus.Error) { // Dispose memory and disable ownership. _memory.Dispose(); @@ -137,61 +140,78 @@ public bool IsValid() public void AddAccessAllowed(int accessMask, Sid sid) { - Win32.RtlAddAccessAllowedAce( + NtStatus status; + + if ((status = Win32.RtlAddAccessAllowedAce( this, Win32.AclRevision, accessMask, sid - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void AddAccessAllowed(int accessMask, Sid sid, AceFlags flags) { - Win32.RtlAddAccessAllowedAceEx( + NtStatus status; + + if ((status = Win32.RtlAddAccessAllowedAceEx( this, Win32.AclRevision, flags, accessMask, sid - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void AddAccessDenied(int accessMask, Sid sid) { - Win32.RtlAddAccessDeniedAce( + NtStatus status; + + if ((status = Win32.RtlAddAccessDeniedAce( this, Win32.AclRevision, accessMask, sid - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void AddAccessDenied(int accessMask, Sid sid, AceFlags flags) { - Win32.RtlAddAccessDeniedAceEx( + NtStatus status; + + if ((status = Win32.RtlAddAccessDeniedAceEx( this, Win32.AclRevision, flags, accessMask, sid - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void AddAuditAccess(int accessMask, Sid sid, bool auditSuccess, bool auditFailure) { - Win32.RtlAddAuditAccessAce( + NtStatus status; + + if ((status = Win32.RtlAddAuditAccessAce( this, Win32.AclRevision, accessMask, sid, auditSuccess, auditFailure - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void AddAuditAccess(int accessMask, Sid sid, bool auditSuccess, bool auditFailure, AceFlags flags) { - Win32.RtlAddAuditAccessAceEx( + NtStatus status; + + if ((status = Win32.RtlAddAuditAccessAceEx( this, Win32.AclRevision, flags, @@ -199,19 +219,23 @@ public void AddAuditAccess(int accessMask, Sid sid, bool auditSuccess, bool audi sid, auditSuccess, auditFailure - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void AddCompound(AceType type, int accessMask, Sid serverSid, Sid clientSid) { - Win32.RtlAddCompoundAce( + NtStatus status; + + if ((status = Win32.RtlAddCompoundAce( this, Win32.AclRevision, type, accessMask, serverSid, clientSid - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } public void AddRange(int index, IEnumerable aceList) @@ -224,7 +248,7 @@ public void AddRange(int index, IEnumerable aceList) totalSize += ace.Size; } - using (MemoryAlloc aceListMemory = new MemoryAlloc(totalSize)) + using (var aceListMemory = new MemoryAlloc(totalSize)) { int i = 0; @@ -235,22 +259,27 @@ public void AddRange(int index, IEnumerable aceList) i += ace.Size; } + NtStatus status; + // Add the ACEs to the ACL. - Win32.RtlAddAce( + if ((status = Win32.RtlAddAce( this, Win32.AclRevision, index, aceListMemory, totalSize - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } public Ace GetAt(int index) { + NtStatus status; IntPtr ace; - Win32.RtlGetAce(this, index, out ace).ThrowIf(); + if ((status = Win32.RtlGetAce(this, index, out ace)) >= NtStatus.Error) + Win32.Throw(status); return Ace.GetAce(ace); } @@ -268,21 +297,26 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() public AclSizeInformation GetSizeInformation() { + NtStatus status; AclSizeInformation sizeInfo; - Win32.RtlQueryInformationAcl( + if ((status = Win32.RtlQueryInformationAcl( this, out sizeInfo, - AclSizeInformation.SizeOf, + Marshal.SizeOf(typeof(AclSizeInformation)), AclInformationClass.AclSizeInformation - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return sizeInfo; } public void RemoveAt(int index) { - Win32.RtlDeleteAce(this, index).ThrowIf(); + NtStatus status; + + if ((status = Win32.RtlDeleteAce(this, index)) >= NtStatus.Error) + Win32.Throw(status); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/KnownAce.cs b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/KnownAce.cs index c464cca2b..8b5c12192 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/KnownAce.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/KnownAce.cs @@ -22,15 +22,19 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; namespace ProcessHacker.Native.Security.AccessControl { - public sealed class KnownAce : Ace + public class KnownAce : Ace { private int _mask; private Sid _sid; + protected KnownAce() + { } + public KnownAce(AceType type, AceFlags flags, int mask, Sid sid) { if ( @@ -42,25 +46,20 @@ public KnownAce(AceType type, AceFlags flags, int mask, Sid sid) throw new ArgumentException("Invalid ACE type."); this.MemoryRegion = new MemoryAlloc( - KnownAceStruct.SizeOf - // known ace struct size + Marshal.SizeOf(typeof(KnownAceStruct)) - // known ace struct size sizeof(int) + // minus SidStart field sid.Length // plus SID length ); - // Initialize the ACE (minus the SID). - KnownAceStruct knownAce = new KnownAceStruct - { - Mask = mask, - Header = - { - AceType = type, - AceFlags = flags, - AceSize = (ushort)this.MemoryRegion.Size - } - }; + KnownAceStruct knownAce = new KnownAceStruct(); + // Initialize the ACE (minus the SID). + knownAce.Header.AceType = type; + knownAce.Header.AceFlags = flags; + knownAce.Header.AceSize = (ushort)this.MemoryRegion.Size; + knownAce.Mask = mask; // Write the ACE to memory. - this.MemoryRegion.WriteStruct(knownAce); + this.MemoryRegion.WriteStruct(knownAce); // Write the SID. this.MemoryRegion.WriteMemory(Win32.KnownAceSidStartOffset.ToInt32(), sid, sid.Length); // Update the cached info. diff --git a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityDescriptor.cs b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityDescriptor.cs index 3c45ab86a..116f03917 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityDescriptor.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityDescriptor.cs @@ -40,11 +40,12 @@ public sealed class SecurityDescriptor : BaseObject /// A security descriptor. public static SecurityDescriptor GetSecurity(IntPtr handle, SecurityInformation securityInformation) { - using (MemoryAlloc data = new MemoryAlloc(0x100)) - { - int retLength; + NtStatus status; + int retLength; - NtStatus status = Win32.NtQuerySecurityObject( + using (var data = new MemoryAlloc(0x100)) + { + status = Win32.NtQuerySecurityObject( handle, securityInformation, data, @@ -56,16 +57,17 @@ out retLength { data.ResizeNew(retLength); - Win32.NtQuerySecurityObject( + status = Win32.NtQuerySecurityObject( handle, securityInformation, data, data.Size, out retLength - ).ThrowIf(); + ); } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return new SecurityDescriptor(data); } @@ -103,11 +105,14 @@ out securityDescriptor /// The security descriptor. public static void SetSecurity(IntPtr handle, SecurityInformation securityInformation, SecurityDescriptor securityDescriptor) { - Win32.NtSetSecurityObject( + NtStatus status; + + if ((status = Win32.NtSetSecurityObject( handle, securityInformation, securityDescriptor - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } /// @@ -125,13 +130,13 @@ public static void SetSecurity(IntPtr handle, SeObjectType objectType, SecurityI IntPtr owner = IntPtr.Zero; IntPtr sacl = IntPtr.Zero; - if (securityInformation.HasFlag(SecurityInformation.Dacl)) + if ((securityInformation & SecurityInformation.Dacl) == SecurityInformation.Dacl) dacl = securityDescriptor.Dacl ?? IntPtr.Zero; - if (securityInformation.HasFlag(SecurityInformation.Group)) + if ((securityInformation & SecurityInformation.Group) == SecurityInformation.Group) group = securityDescriptor.Group; - if (securityInformation.HasFlag(SecurityInformation.Owner)) + if ((securityInformation & SecurityInformation.Owner) == SecurityInformation.Owner) owner = securityDescriptor.Owner; - if (securityInformation.HasFlag(SecurityInformation.Sacl)) + if ((securityInformation & SecurityInformation.Sacl) == SecurityInformation.Sacl) sacl = securityDescriptor.Sacl ?? IntPtr.Zero; if ((result = Win32.SetSecurityInfo( @@ -151,7 +156,7 @@ public static implicit operator IntPtr(SecurityDescriptor securityDescriptor) return securityDescriptor.Memory; } - private readonly MemoryRegion _memory; + private MemoryRegion _memory; private Acl _dacl; private Acl _sacl; private Sid _owner; @@ -169,7 +174,7 @@ public SecurityDescriptor() if ((status = Win32.RtlCreateSecurityDescriptor( _memory, Win32.SecurityDescriptorRevision - )).IsError()) + )) >= NtStatus.Error) { _memory.Dispose(); _memory = null; @@ -229,24 +234,29 @@ public SecurityDescriptorControlFlags ControlFlags { get { + NtStatus status; SecurityDescriptorControlFlags control; int revision; - Win32.RtlGetControlSecurityDescriptor( + if ((status = Win32.RtlGetControlSecurityDescriptor( this, out control, out revision - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return control; } set { - Win32.RtlSetControlSecurityDescriptor( + NtStatus status; + + if ((status = Win32.RtlSetControlSecurityDescriptor( this, value, value - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); } } @@ -258,12 +268,15 @@ public Acl Dacl get { return _dacl; } set { - Win32.RtlSetDaclSecurityDescriptor( + NtStatus status; + + if ((status = Win32.RtlSetDaclSecurityDescriptor( this, value != null, value ?? IntPtr.Zero, false - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.SwapDacl(value); } @@ -274,7 +287,11 @@ public Acl Dacl /// public bool DaclDefaulted { - get { return this.ControlFlags.HasFlag(SecurityDescriptorControlFlags.DaclDefaulted); } + get + { + return (this.ControlFlags & SecurityDescriptorControlFlags.DaclDefaulted) == + SecurityDescriptorControlFlags.DaclDefaulted; + } set { if (value) @@ -292,11 +309,14 @@ public Sid Group get { return _group; } set { - Win32.RtlSetGroupSecurityDescriptor( + NtStatus status; + + if ((status = Win32.RtlSetGroupSecurityDescriptor( this, value, false - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.SwapGroup(value); } @@ -307,7 +327,11 @@ public Sid Group /// public bool GroupDefaulted { - get { return this.ControlFlags.HasFlag(SecurityDescriptorControlFlags.GroupDefaulted); } + get + { + return (this.ControlFlags & SecurityDescriptorControlFlags.GroupDefaulted) == + SecurityDescriptorControlFlags.GroupDefaulted; + } set { if (value) @@ -341,11 +365,14 @@ public Sid Owner get { return _owner; } set { - Win32.RtlSetOwnerSecurityDescriptor( + NtStatus status; + + if ((status = Win32.RtlSetOwnerSecurityDescriptor( this, value, false - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.SwapOwner(value); } @@ -378,12 +405,15 @@ public Acl Sacl get { return _sacl; } set { - Win32.RtlSetSaclSecurityDescriptor( + NtStatus status; + + if ((status = Win32.RtlSetSaclSecurityDescriptor( this, value != null, value ?? IntPtr.Zero, false - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); this.SwapSacl(value); } @@ -394,7 +424,11 @@ public Acl Sacl /// public bool SaclDefaulted { - get { return this.ControlFlags.HasFlag(SecurityDescriptorControlFlags.SaclDefaulted); } + get + { + return (this.ControlFlags & SecurityDescriptorControlFlags.SaclDefaulted) == + SecurityDescriptorControlFlags.SaclDefaulted; + } set { if (value) @@ -409,7 +443,11 @@ public bool SaclDefaulted /// public bool SelfRelative { - get { return this.ControlFlags.HasFlag(SecurityDescriptorControlFlags.SelfRelative); } + get + { + return (this.ControlFlags & SecurityDescriptorControlFlags.SelfRelative) == + SecurityDescriptorControlFlags.SelfRelative; + } } /// @@ -422,10 +460,11 @@ public bool SelfRelative /// Success if access was granted, otherwise another NT status value. public NtStatus CheckAccess(TokenHandle tokenHandle, int desiredAccess, GenericMapping genericMapping, out int grantedAccess) { + NtStatus status; NtStatus accessStatus; int privilegeSetLength = 0; - Win32.NtAccessCheck( + if ((status = Win32.NtAccessCheck( this, tokenHandle, desiredAccess, @@ -434,7 +473,8 @@ public NtStatus CheckAccess(TokenHandle tokenHandle, int desiredAccess, GenericM ref privilegeSetLength, out grantedAccess, out accessStatus - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return accessStatus; } @@ -443,23 +483,25 @@ out accessStatus /// Checks whether the security descriptor is valid. /// /// True if the security descriptor is valid, otherwise false. - public bool IsValid + public bool IsValid() { - get { return Win32.RtlValidSecurityDescriptor(this); } + return Win32.RtlValidSecurityDescriptor(this); } private void Read() { + NtStatus status; bool present, defaulted; IntPtr dacl, group, owner, sacl; // Read the DACL. - Win32.RtlGetDaclSecurityDescriptor( + if ((status = Win32.RtlGetDaclSecurityDescriptor( this, out present, out dacl, out defaulted - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (present && dacl != IntPtr.Zero) this.SwapDacl(new Acl(Acl.FromPointer(dacl))); @@ -467,12 +509,13 @@ out defaulted this.SwapDacl(null); // Read the SACL. - Win32.RtlGetSaclSecurityDescriptor( + if ((status = Win32.RtlGetSaclSecurityDescriptor( this, out present, out sacl, out defaulted - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (present && sacl != IntPtr.Zero) this.SwapSacl(new Acl(Acl.FromPointer(sacl))); @@ -480,11 +523,12 @@ out defaulted this.SwapSacl(null); // Read the group. - Win32.RtlGetGroupSecurityDescriptor( + if ((status = Win32.RtlGetGroupSecurityDescriptor( this, out group, out defaulted - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (group != IntPtr.Zero) this.SwapGroup(new Sid(group)); @@ -492,11 +536,12 @@ out defaulted this.SwapGroup(null); // Read the owner. - Win32.RtlGetOwnerSecurityDescriptor( + if ((status = Win32.RtlGetOwnerSecurityDescriptor( this, out owner, out defaulted - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); if (owner != IntPtr.Zero) this.SwapOwner(new Sid(owner)); @@ -506,22 +551,22 @@ out defaulted private void SwapDacl(Acl dacl) { - BaseObject.SwapRef(ref _dacl, dacl); + BaseObject.SwapRef(ref _dacl, dacl); } private void SwapGroup(Sid group) { - BaseObject.SwapRef(ref _group, group); + BaseObject.SwapRef(ref _group, group); } private void SwapOwner(Sid owner) { - BaseObject.SwapRef(ref _owner, owner); + BaseObject.SwapRef(ref _owner, owner); } private void SwapSacl(Acl sacl) { - BaseObject.SwapRef(ref _sacl, sacl); + BaseObject.SwapRef(ref _sacl, sacl); } /// @@ -530,11 +575,13 @@ private void SwapSacl(Acl sacl) /// A new self-relative security descriptor. public SecurityDescriptor ToSelfRelative() { - using (MemoryAlloc data = new MemoryAlloc(Win32.SecurityDescriptorMinLength)) - { - int retLength = data.Size; + NtStatus status; + int retLength; - NtStatus status = Win32.RtlMakeSelfRelativeSD(this, data, ref retLength); + using (var data = new MemoryAlloc(Win32.SecurityDescriptorMinLength)) + { + retLength = data.Size; + status = Win32.RtlMakeSelfRelativeSD(this, data, ref retLength); if (status == NtStatus.BufferTooSmall) { @@ -542,7 +589,8 @@ public SecurityDescriptor ToSelfRelative() status = Win32.RtlMakeSelfRelativeSD(this, data, ref retLength); } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); return new SecurityDescriptor(data); } diff --git a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityEditor.cs b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityEditor.cs index f63653404..a2c609d3b 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityEditor.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/AccessControl/SecurityEditor.cs @@ -22,9 +22,11 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Windows.Forms; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; +using ProcessHacker.Native.Security.AccessControl; namespace ProcessHacker.Native.Security.AccessControl { @@ -32,7 +34,7 @@ public class SecurityEditor : IDisposable, ISecurityInformation { private class SecurableObjectWrapper : ISecurable { - private readonly Func _openMethod; + private Func _openMethod; public SecurableObjectWrapper(Func openMethod) { @@ -63,8 +65,8 @@ public void SetSecurity(SecurityInformation securityInformation, SecurityDescrip private class SeSecurableObjectWrapper : ISecurable { - private readonly SeObjectType _objectType; - private readonly Func _openMethod; + private SeObjectType _objectType; + private Func _openMethod; public SeSecurableObjectWrapper(SeObjectType objectType, Func openMethod) { @@ -96,24 +98,18 @@ public void SetSecurity(SecurityInformation securityInformation, SecurityDescrip public static void EditSecurity(IWin32Window owner, ISecurable securable, string name, IEnumerable accessEntries) { - using (SecurityEditor osi = new SecurityEditor(securable, name, accessEntries)) + using (var osi = new SecurityEditor(securable, name, accessEntries)) Win32.EditSecurity(owner != null ? owner.Handle : IntPtr.Zero, osi); } - - public static SecurityEditor EditSecurity2(IWin32Window owner, ISecurable securable, string name, IEnumerable accessEntries) - { - return new SecurityEditor(securable, name, accessEntries); - } - public static ISecurable GetSecurableWrapper(IntPtr handle) { - return GetSecurableWrapper(access => new NativeHandle(handle, access)); + return GetSecurableWrapper((access) => new NativeHandle(handle, access)); } public static ISecurable GetSecurableWrapper(SeObjectType objectType, IntPtr handle) { - return GetSecurableWrapper(objectType, access => new NativeHandle(handle, access)); + return GetSecurableWrapper(objectType, (access) => new NativeHandle(handle, access)); } public static ISecurable GetSecurableWrapper(Func openMethod) @@ -126,25 +122,27 @@ public static ISecurable GetSecurableWrapper(SeObjectType objectType, Func _pool = new List(); - private readonly string _name; - private readonly MemoryAlloc _accessRights; - private readonly int _accessRightCount; + private bool _disposed = false; + private ISecurable _securable; + private List _pool = new List(); + private string _name; + private MemoryAlloc _accessRights; + private int _accessRightCount; internal SecurityEditor(ISecurable securable, string name, IEnumerable accessEntries) { + List accesses; + _securable = securable; _name = name; - List accesses = new List(); + accesses = new List(); - foreach (AccessEntry entry in accessEntries) + foreach (var entry in accessEntries) { if (entry.Mask != 0) { - accesses.Add(new SiAccess + accesses.Add(new SiAccess() { Guid = IntPtr.Zero, Mask = entry.Mask, @@ -154,7 +152,7 @@ internal SecurityEditor(ISecurable securable, string name, IEnumerable(accesses.ToArray()); _accessRightCount = accesses.Count; } @@ -162,7 +160,7 @@ public void Dispose() { if (!_disposed) { - _pool.ForEach(alloc => alloc.Dispose()); + _pool.ForEach((alloc) => alloc.Dispose()); _pool.Clear(); _disposed = true; } @@ -202,37 +200,39 @@ private MemoryAlloc AllocateStringFromPool(string value) return m; } - private MemoryAlloc AllocateStruct(int size, T value) where T : struct + private MemoryAlloc AllocateStruct(T value) + where T : struct { - MemoryAlloc alloc = new MemoryAlloc(size); + MemoryAlloc alloc = new MemoryAlloc(Marshal.SizeOf(typeof(T))); - alloc.WriteStruct(0, size, value); + alloc.WriteStruct(0, value); return alloc; } - private MemoryAlloc AllocateStructFromPool(int size, T value) + private MemoryAlloc AllocateStructFromPool(T value) where T : struct { - MemoryAlloc m = this.AllocateStruct(size, value); + MemoryAlloc m = this.AllocateStruct(value); _pool.Add(m); return m; } - private MemoryAlloc AllocateStructArray(int size, T[] value) where T : struct + private MemoryAlloc AllocateStructArray(T[] value) + where T : struct { - MemoryAlloc alloc = new MemoryAlloc(size * value.Length); + MemoryAlloc alloc = new MemoryAlloc(Marshal.SizeOf(typeof(T)) * value.Length); for (int i = 0; i < value.Length; i++) - alloc.WriteStruct(i, size, value[i]); + alloc.WriteStruct(i, value[i]); return alloc; } - private MemoryAlloc AllocateStructArrayFromPool(int size, T[] value) + private MemoryAlloc AllocateStructArrayFromPool(T[] value) where T : struct { - MemoryAlloc m = this.AllocateStructArray(size, value); + MemoryAlloc m = this.AllocateStructArray(value); _pool.Add(m); return m; } @@ -241,18 +241,17 @@ private MemoryAlloc AllocateStructArrayFromPool(int size, T[] value) public HResult GetObjectInformation(out SiObjectInfo ObjectInfo) { - SiObjectInfo soi = new SiObjectInfo - { - Flags = SiObjectInfoFlags.EditAudits | - SiObjectInfoFlags.EditOwner | - SiObjectInfoFlags.EditPerms | - SiObjectInfoFlags.Advanced | - SiObjectInfoFlags.NoAclProtect | - SiObjectInfoFlags.NoTreeApply, - Instance = IntPtr.Zero, - ObjectName = this.AllocateStringFromPool(this._name) - }; - + SiObjectInfo soi = new SiObjectInfo(); + + soi.Flags = + SiObjectInfoFlags.EditAudits | + SiObjectInfoFlags.EditOwner | + SiObjectInfoFlags.EditPerms | + SiObjectInfoFlags.Advanced | + SiObjectInfoFlags.NoAclProtect | + SiObjectInfoFlags.NoTreeApply; + soi.Instance = IntPtr.Zero; + soi.ObjectName = this.AllocateStringFromPool(_name); ObjectInfo = soi; return HResult.OK; @@ -262,12 +261,12 @@ public HResult GetSecurity(SecurityInformation RequestedInformation, out IntPtr { try { - using (SecurityDescriptor sd = _securable.GetSecurity(RequestedInformation)) + using (var sd = _securable.GetSecurity(RequestedInformation)) { // Since the ACL editor will free the security descriptor using // LocalFree, we need to use a local memory allocation and copy // the security descriptor into it. - using (LocalMemoryAlloc localAlloc = new LocalMemoryAlloc(sd.Length)) + using (var localAlloc = new LocalMemoryAlloc(sd.Length)) { localAlloc.WriteMemory(0, sd.Memory, sd.Length); localAlloc.Reference(); // reference for ACL editor @@ -334,10 +333,10 @@ public HResult PropertySheetPageCallback(IntPtr hWnd, SiCallbackMessage Msg, SiP public struct AccessEntry { - private readonly bool _general; - private readonly int _mask; - private readonly string _name; - private readonly bool _specific; + private bool _general; + private int _mask; + private string _name; + private bool _specific; public AccessEntry(string name, object mask, bool general, bool specific) { diff --git a/1.x/trunk/ProcessHacker.Native/Security/Authentication/Credentials.cs b/1.x/trunk/ProcessHacker.Native/Security/Authentication/Credentials.cs index f00eb2973..55cbfbc3f 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/Authentication/Credentials.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/Authentication/Credentials.cs @@ -33,10 +33,10 @@ public static MemoryRegion PackCredentials(CredPackFlags flags, string userName, MemoryAlloc data = new MemoryAlloc(0x100); int size = data.Size; - if (string.IsNullOrEmpty(userName)) - userName = string.Empty; - if (string.IsNullOrEmpty(password)) - password = string.Empty; + if (userName == null) + userName = ""; + if (password == null) + password = ""; if (!Win32.CredPackAuthenticationBuffer(flags, userName, password, data, ref size)) { @@ -57,9 +57,9 @@ public static void UnpackCredentials( out string password ) { - using (MemoryAlloc domainNameBuffer = new MemoryAlloc(0x100)) - using (MemoryAlloc userNameBuffer = new MemoryAlloc(0x100)) - using (MemoryAlloc passwordBuffer = new MemoryAlloc(0x100)) + using (var domainNameBuffer = new MemoryAlloc(0x100)) + using (var userNameBuffer = new MemoryAlloc(0x100)) + using (var passwordBuffer = new MemoryAlloc(0x100)) { int domainNameSize = domainNameBuffer.Size / 2 - 1; int userNameSize = userNameBuffer.Size / 2 - 1; @@ -122,13 +122,13 @@ CredUiFlags flags if (userName.Length > maxChars || password.Length > maxChars) throw new ArgumentException("The user name or password string is too long."); - info.Size = CredUiInfo.SizeOf; + info.Size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(CredUiInfo)); info.Parent = parent != null ? parent.Handle : IntPtr.Zero; info.MessageText = messageText; info.CaptionText = captionText; - using (MemoryAlloc userNameAlloc = new MemoryAlloc(maxBytes)) - using (MemoryAlloc passwordAlloc = new MemoryAlloc(maxBytes)) + using (var userNameAlloc = new MemoryAlloc(maxBytes)) + using (var passwordAlloc = new MemoryAlloc(maxBytes)) { userNameAlloc.WriteUnicodeString(0, userName); userNameAlloc.WriteInt16(userName.Length * 2, 0); @@ -178,12 +178,12 @@ CredUiWinFlags flags IntPtr outAuthBuffer; int outAuthBufferSize; - info.Size = CredUiInfo.SizeOf; + info.Size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(CredUiInfo)); info.Parent = parent != null ? parent.Handle : IntPtr.Zero; info.MessageText = messageText; info.CaptionText = captionText; - using (MemoryRegion inAuthBuffer = PackCredentials(0, userName, password)) + using (var inAuthBuffer = PackCredentials(0, userName, password)) { result = Win32.CredUIPromptForWindowsCredentials( ref info, @@ -223,10 +223,11 @@ out password public static SecPkgInfo[] GetSSPackages() { + int result; int count; IntPtr packages; - int result = Win32.EnumerateSecurityPackages(out count, out packages); + result = Win32.EnumerateSecurityPackages(out count, out packages); if (result != 0) Win32.Throw(result); @@ -238,7 +239,7 @@ public static SecPkgInfo[] GetSSPackages() SecPkgInfo[] array = new SecPkgInfo[count]; for (int i = 0; i < count; i++) - array[i] = alloc.ReadStruct(0, SecPkgInfo.SizeOf, i); + array[i] = alloc.ReadStruct(i); return array; } diff --git a/1.x/trunk/ProcessHacker.Native/Security/Authentication/Msv1_0_InteractivePackage.cs b/1.x/trunk/ProcessHacker.Native/Security/Authentication/Msv1_0_InteractivePackage.cs index 1cd2595cb..ae0e2e3f6 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/Authentication/Msv1_0_InteractivePackage.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/Authentication/Msv1_0_InteractivePackage.cs @@ -20,6 +20,9 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; namespace ProcessHacker.Native.Security.Authentication @@ -77,24 +80,27 @@ public string Password public MemoryRegion GetAuthData() { - string lDomainName = !string.IsNullOrEmpty(_domainName) ? _domainName : string.Empty; - string lUserName = !string.IsNullOrEmpty(_userName) ? _userName : string.Empty; - string lPassword = !string.IsNullOrEmpty(_password) ? _password : string.Empty; + MemoryAlloc data; + int dataSize; + int domainNameOffset; + int userNameOffset; + int passwordOffset; + string lDomainName = _domainName != null ? _domainName : ""; + string lUserName = _userName != null ? _userName : ""; + string lPassword = _password != null ? _password : ""; // The structure plus the strings must be stored in the same buffer, // so we have to do some computation. - int domainNameOffset = Msv1_0_InteractiveLogon.SizeOf; - int userNameOffset = domainNameOffset + lDomainName.Length * 2; - int passwordOffset = userNameOffset + lUserName.Length * 2; - int dataSize = passwordOffset + lPassword.Length * 2; + domainNameOffset = Marshal.SizeOf(typeof(Msv1_0_InteractiveLogon)); + userNameOffset = domainNameOffset + lDomainName.Length * 2; + passwordOffset = userNameOffset + lUserName.Length * 2; + dataSize = passwordOffset + lPassword.Length * 2; + data = new MemoryAlloc(dataSize); - MemoryAlloc data = new MemoryAlloc(dataSize); + Msv1_0_InteractiveLogon info = new Msv1_0_InteractiveLogon(); - Msv1_0_InteractiveLogon info = new Msv1_0_InteractiveLogon - { - MessageType = Msv1_0_LogonSubmitType.Interactive - }; + info.MessageType = Msv1_0_LogonSubmitType.Interactive; info.LogonDomainName.MaximumLength = info.LogonDomainName.Length = (ushort)(lDomainName.Length * 2); info.LogonDomainName.Buffer = data.Memory.Increment(domainNameOffset); @@ -108,7 +114,7 @@ public MemoryRegion GetAuthData() info.Password.Buffer = data.Memory.Increment(passwordOffset); data.WriteUnicodeString(passwordOffset, lPassword); - data.WriteStruct(info); + data.WriteStruct(info); return data; } @@ -130,9 +136,9 @@ public void ReadAuthData(MemoryRegion buffer) if (info.Password.Buffer.CompareTo(buffer.Size) < 0) info.Password.Buffer = info.Password.Buffer.Increment(buffer); - _domainName = info.LogonDomainName.Text; - _userName = info.UserName.Text; - _password = info.Password.Text; + _domainName = info.LogonDomainName.Read(); + _userName = info.UserName.Read(); + _password = info.Password.Read(); } } } diff --git a/1.x/trunk/ProcessHacker.Native/Security/DesktopAccess.cs b/1.x/trunk/ProcessHacker.Native/Security/DesktopAccess.cs index 09c6e1eb5..e6268edbc 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/DesktopAccess.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/DesktopAccess.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Native.Security { diff --git a/1.x/trunk/ProcessHacker.Native/Security/EnlistmentAccess.cs b/1.x/trunk/ProcessHacker.Native/Security/EnlistmentAccess.cs index d3d12c451..061fd1f79 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/EnlistmentAccess.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/EnlistmentAccess.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Native.Security { diff --git a/1.x/trunk/ProcessHacker.Native/Security/ISecurable.cs b/1.x/trunk/ProcessHacker.Native/Security/ISecurable.cs index 552104ede..1c28e4ad1 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/ISecurable.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/ISecurable.cs @@ -1,4 +1,7 @@ -using ProcessHacker.Native.Api; +using System; +using System.Collections.Generic; +using System.Text; +using ProcessHacker.Native.Api; using ProcessHacker.Native.Security.AccessControl; namespace ProcessHacker.Native.Security diff --git a/1.x/trunk/ProcessHacker.Native/Security/IoCompletionAccess.cs b/1.x/trunk/ProcessHacker.Native/Security/IoCompletionAccess.cs index ba9646428..dc10c1ee0 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/IoCompletionAccess.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/IoCompletionAccess.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Native.Security { diff --git a/1.x/trunk/ProcessHacker.Native/Security/Privilege.cs b/1.x/trunk/ProcessHacker.Native/Security/Privilege.cs index c3fc71857..3b15299b3 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/Privilege.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/Privilege.cs @@ -21,6 +21,7 @@ */ using System; +using System.Text; using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; @@ -44,8 +45,8 @@ public static Privilege Enable(string name) } } - private readonly TokenHandle _tokenHandle; - private readonly Luid _luid; + private TokenHandle _tokenHandle; + private Luid _luid; private SePrivilegeAttributes _attributes; private string _name; private string _displayName; @@ -121,7 +122,8 @@ public bool Disabled { get { - return (_attributes & SePrivilegeAttributes.Disabled)!= SePrivilegeAttributes.Disabled; + return (_attributes & SePrivilegeAttributes.Disabled) + != SePrivilegeAttributes.Disabled; } set { @@ -133,7 +135,7 @@ public string DisplayName { get { - if (string.IsNullOrEmpty(_displayName)) + if (_displayName == null) { _displayName = LsaPolicyHandle.LookupPolicyHandle.LookupPrivilegeDisplayName(this.Name); } @@ -177,7 +179,7 @@ public string Name { get { - if (string.IsNullOrEmpty(_name)) + if (_name == null) { _name = LsaPolicyHandle.LookupPolicyHandle.LookupPrivilegeName(_luid); } @@ -262,7 +264,7 @@ private void SetState(TokenHandle tokenHandle, SePrivilegeAttributes attributes) public LuidAndAttributes ToLuidAndAttributes() { - return new LuidAndAttributes + return new LuidAndAttributes() { Attributes = _attributes, Luid = _luid diff --git a/1.x/trunk/ProcessHacker.Native/Security/PrivilegeSet.cs b/1.x/trunk/ProcessHacker.Native/Security/PrivilegeSet.cs index f32ed2ae0..01c18e857 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/PrivilegeSet.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/PrivilegeSet.cs @@ -22,14 +22,16 @@ using System; using System.Collections.Generic; - +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; namespace ProcessHacker.Native.Security { public sealed class PrivilegeSet : IList { - private readonly List _privileges; + private static int _sizeOfLaa = Marshal.SizeOf(typeof(LuidAndAttributes)); + + private List _privileges; private PrivilegeSetFlags _flags; public PrivilegeSet() @@ -61,7 +63,7 @@ public PrivilegeSet(IntPtr memory) for (int i = 0; i < privilegeSet.Count; i++) { - _privileges.Add(new Privilege(memoryRegion.ReadStruct(PrivilegeSetStruct.PrivilegesOffset, LuidAndAttributes.SizeOf, i))); + _privileges.Add(new Privilege(memoryRegion.ReadStruct(PrivilegeSetStruct.PrivilegesOffset, i))); } } @@ -73,24 +75,25 @@ public PrivilegeSetFlags Flags public MemoryAlloc ToMemory() { - int requiredSize = 8 + LuidAndAttributes.SizeOf * _privileges.Count; + int requiredSize = 8 + _sizeOfLaa * _privileges.Count; MemoryAlloc memory = new MemoryAlloc(requiredSize); memory.WriteInt32(0, _privileges.Count); memory.WriteInt32(4, (int)_flags); for (int i = 0; i < _privileges.Count; i++) - memory.WriteStruct(8, LuidAndAttributes.SizeOf, i, _privileges[i].ToLuidAndAttributes()); + memory.WriteStruct(8, i, _privileges[i].ToLuidAndAttributes()); return memory; } public TokenPrivileges ToTokenPrivileges() { - return new TokenPrivileges + return new TokenPrivileges() { PrivilegeCount = _privileges.Count, - Privileges = _privileges.ConvertAll(privilege => privilege.ToLuidAndAttributes()).ToArray() + Privileges = _privileges.ConvertAll( + (privilege) => privilege.ToLuidAndAttributes()).ToArray() }; } diff --git a/1.x/trunk/ProcessHacker.Native/Security/Sid.cs b/1.x/trunk/ProcessHacker.Native/Security/Sid.cs index 76dfe500f..b3fdc29a3 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/Sid.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/Sid.cs @@ -21,6 +21,7 @@ */ using System; +using System.Text; using ProcessHacker.Common; using ProcessHacker.Common.Objects; using ProcessHacker.Native.Api; @@ -51,7 +52,7 @@ public static Sid CurrentUser if (currentUser == null) { using (var thandle = TokenHandle.OpenCurrentPrimary(TokenAccess.Query)) - _currentUser = currentUser = thandle.User; + _currentUser = currentUser = thandle.GetUser(); } return currentUser; @@ -119,8 +120,8 @@ private static byte[] GetWellKnownSidIdentifierAuthority(WellKnownSidIdentifierA if (copy) return array.Duplicate(); - - return array; + else + return array; } public static implicit operator IntPtr(Sid sid) @@ -128,10 +129,10 @@ public static implicit operator IntPtr(Sid sid) return sid.Memory; } - private readonly MemoryRegion _memory; - private readonly string _systemName; - private readonly bool _hasAttributes; - private readonly SidAttributes _attributes; + private MemoryRegion _memory; + private string _systemName; + private bool _hasAttributes; + private SidAttributes _attributes; private string _stringSid; private string _domain; @@ -214,9 +215,12 @@ public Sid(IntPtr sid, SidAttributes attributes, string systemName) private Sid(IntPtr sid, bool hasAttributes, SidAttributes attributes, string systemName) { + NtStatus status; + _memory = new MemoryAlloc(Win32.RtlLengthSid(sid)); - Win32.RtlCopySid(_memory.Size, _memory, sid).ThrowIf(); + if ((status = Win32.RtlCopySid(_memory.Size, _memory, sid)) >= NtStatus.Error) + Win32.Throw(status); _hasAttributes = hasAttributes; _attributes = attributes; @@ -243,9 +247,15 @@ public string DomainName } } - public unsafe byte[] IdentifierAuthority + public byte[] IdentifierAuthority { - get { return Utils.Create((*Win32.RtlIdentifierAuthoritySid(this)).Value, 6); } + get + { + unsafe + { + return Utils.Create((*Win32.RtlIdentifierAuthoritySid(this)).Value, 6); + } + } } public bool HasAttributes @@ -267,9 +277,8 @@ public string Name { get { - if (string.IsNullOrEmpty(_name)) + if (_name == null) this.GetNameAndUse(out _domain, out _name, out _nameUse); - return _name; } } @@ -280,22 +289,24 @@ public SidNameUse NameUse { if (_nameUse == 0) this.GetNameAndUse(out _domain, out _name, out _nameUse); - return _nameUse; } } - public unsafe int[] SubAuthorities + public int[] SubAuthorities { get { - byte count = *Win32.RtlSubAuthorityCountSid(this); - int[] subAuthorities = new int[count]; + unsafe + { + byte count = *Win32.RtlSubAuthorityCountSid(this); + int[] subAuthorities = new int[count]; - for (int i = 0; i < count; i++) - subAuthorities[i] = *Win32.RtlSubAuthoritySid(this, i); + for (int i = 0; i < count; i++) + subAuthorities[i] = *Win32.RtlSubAuthoritySid(this, i); - return subAuthorities; + return subAuthorities; + } } } @@ -303,9 +314,8 @@ public string StringSid { get { - if (string.IsNullOrEmpty(_stringSid)) - _stringSid = this.String; - + if (_stringSid == null) + _stringSid = this.GetString(); return _stringSid; } } @@ -344,8 +354,8 @@ public string GetFullName(bool includeDomain) if (includeDomain && !string.IsNullOrEmpty(this.DomainName)) return this.DomainName + "\\" + this.Name; - - return this.Name; + else + return this.Name; } catch { @@ -359,7 +369,7 @@ public override int GetHashCode() byte[] identifierAuthority = this.IdentifierAuthority; int[] subAuthorities = this.SubAuthorities; - foreach (int t in subAuthorities) + for (int i = 0; i < subAuthorities.Length; i++) { hashCode ^= identifierAuthority[(uint)hashCode % identifierAuthority.Length]; // Reverse and XOR. @@ -379,7 +389,8 @@ public WellKnownSidIdentifierAuthority GetWellKnownIdentifierAuthority() { byte[] identifierAuthority = this.IdentifierAuthority; - foreach (WellKnownSidIdentifierAuthority value in Enum.GetValues(typeof(WellKnownSidIdentifierAuthority))) + foreach (WellKnownSidIdentifierAuthority value in + Enum.GetValues(typeof(WellKnownSidIdentifierAuthority))) { if (value == WellKnownSidIdentifierAuthority.None) continue; @@ -391,19 +402,16 @@ public WellKnownSidIdentifierAuthority GetWellKnownIdentifierAuthority() return WellKnownSidIdentifierAuthority.None; } - private string String + private string GetString() { - get - { - UnicodeString str = new UnicodeString(); + NtStatus status; + UnicodeString str = new UnicodeString(); - Win32.RtlConvertSidToUnicodeString(ref str, this, true).ThrowIf(); + if ((status = Win32.RtlConvertSidToUnicodeString(ref str, this, true)) >= NtStatus.Error) + Win32.Throw(status); - using (str) - { - return str.Text; - } - } + using (str) + return str.Read(); } public bool IsValid() @@ -418,7 +426,7 @@ public bool PrefixEquals(Sid obj) public SidAndAttributes ToSidAndAttributes() { - return new SidAndAttributes + return new SidAndAttributes() { Attributes = _attributes, Sid = this diff --git a/1.x/trunk/ProcessHacker.Native/Security/TransactionAccess.cs b/1.x/trunk/ProcessHacker.Native/Security/TransactionAccess.cs index bcf99cbff..870a38b8c 100644 --- a/1.x/trunk/ProcessHacker.Native/Security/TransactionAccess.cs +++ b/1.x/trunk/ProcessHacker.Native/Security/TransactionAccess.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Native.Security { diff --git a/1.x/trunk/ProcessHacker.Native/SsLogging/FilterType.cs b/1.x/trunk/ProcessHacker.Native/SsLogging/FilterType.cs index 17a32f6e0..111c53720 100644 --- a/1.x/trunk/ProcessHacker.Native/SsLogging/FilterType.cs +++ b/1.x/trunk/ProcessHacker.Native/SsLogging/FilterType.cs @@ -1,4 +1,8 @@ -namespace ProcessHacker.Native.SsLogging +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.Native.SsLogging { public enum FilterType { @@ -12,8 +16,8 @@ public static KphSsFilterType ToKphSs(this FilterType filterType) { if (filterType == FilterType.Include) return KphSsFilterType.Include; - - return KphSsFilterType.Exclude; + else + return KphSsFilterType.Exclude; } } } diff --git a/1.x/trunk/ProcessHacker.Native/SsLogging/KphTypes.cs b/1.x/trunk/ProcessHacker.Native/SsLogging/KphTypes.cs index 1e8b40d90..00b066e84 100644 --- a/1.x/trunk/ProcessHacker.Native/SsLogging/KphTypes.cs +++ b/1.x/trunk/ProcessHacker.Native/SsLogging/KphTypes.cs @@ -58,17 +58,24 @@ public enum KphSsRuleSetAction : int Log } + public class KphSsClientEntryHandle : KphHandle + { + internal KphSsClientEntryHandle(IntPtr handle) + : base(handle) + { } + } + + public class KphSsRuleSetEntryHandle : KphHandle + { + internal KphSsRuleSetEntryHandle(IntPtr handle) + : base(handle) + { } + } + [StructLayout(LayoutKind.Sequential)] public struct KphSsArgumentBlock { - public static readonly int SizeOf; - public static readonly int DataOffset; - - static KphSsArgumentBlock() - { - SizeOf = Marshal.SizeOf(typeof(KphSsArgumentBlock)); - DataOffset = Marshal.OffsetOf(typeof(KphSsArgumentBlock), "Data").ToInt32(); - } + public static readonly int DataOffset = Marshal.OffsetOf(typeof(KphSsArgumentBlock), "Data").ToInt32(); [StructLayout(LayoutKind.Explicit)] public struct KphSsArgumentUnion @@ -94,41 +101,22 @@ public struct KphSsArgumentUnion [StructLayout(LayoutKind.Sequential)] public struct KphSsBlockHeader { - public static readonly int SizeOf; - public ushort Size; public KphSsBlockType Type; - - static KphSsBlockHeader() - { - SizeOf = Marshal.SizeOf(typeof(KphSsBlockHeader)); - } } [StructLayout(LayoutKind.Sequential)] public struct KphSsBytes { - public static readonly int BufferOffset; + public static readonly int BufferOffset = Marshal.OffsetOf(typeof(KphSsBytes), "Buffer").ToInt32(); public ushort Length; public byte Buffer; - - static KphSsBytes() - { - BufferOffset = Marshal.OffsetOf(typeof(KphSsBytes), "Buffer").ToInt32(); - } } [StructLayout(LayoutKind.Sequential)] public struct KphSsClientInformation { - public static readonly int SizeOf; - - static KphSsClientInformation() - { - SizeOf = Marshal.SizeOf(typeof(KphSsClientInformation)); - } - public IntPtr ProcessId; public IntPtr BufferBase; public int BufferSize; @@ -139,13 +127,6 @@ static KphSsClientInformation() [StructLayout(LayoutKind.Sequential)] public struct KphSsEventBlock { - public static readonly int SizeOf; - - static KphSsEventBlock() - { - SizeOf = Marshal.SizeOf(typeof(KphSsEventBlock)); - } - public KphSsBlockHeader Header; public KphSsEventFlags Flags; public long Time; @@ -161,14 +142,7 @@ static KphSsEventBlock() [StructLayout(LayoutKind.Sequential)] public struct KphSsHandle - { - public static readonly int SizeOf; - - static KphSsHandle() - { - SizeOf = Marshal.SizeOf(typeof(KphSsHandle)); - } - + { public ClientId ClientId; public ushort TypeNameOffset; public ushort NameOffset; @@ -177,13 +151,6 @@ static KphSsHandle() [StructLayout(LayoutKind.Sequential)] public struct KphSsObjectAttributes { - public static readonly int SizeOf; - - static KphSsObjectAttributes() - { - SizeOf = Marshal.SizeOf(typeof(KphSsObjectAttributes)); - } - public ObjectAttributes ObjectAttributes; public ushort RootDirectoryOffset; public ushort ObjectNameOffset; @@ -192,14 +159,7 @@ static KphSsObjectAttributes() [StructLayout(LayoutKind.Sequential)] public struct KphSsUnicodeString { - public static readonly int SizeOf; - public static readonly int BufferOffset; - - static KphSsUnicodeString() - { - SizeOf = Marshal.SizeOf(typeof(KphSsUnicodeString)); - BufferOffset = Marshal.OffsetOf(typeof(KphSsUnicodeString), "Buffer").ToInt32(); - } + public static readonly int BufferOffset = Marshal.OffsetOf(typeof(KphSsUnicodeString), "Buffer").ToInt32(); public ushort Length; public ushort MaximumLength; @@ -210,14 +170,7 @@ static KphSsUnicodeString() [StructLayout(LayoutKind.Sequential)] public struct KphSsWString { - public static readonly int SizeOf; - public static readonly int BufferOffset; - - static KphSsWString() - { - SizeOf = Marshal.SizeOf(typeof(KphSsWString)); - BufferOffset = Marshal.OffsetOf(typeof(KphSsWString), "Buffer").ToInt32(); - } + public static readonly int BufferOffset = Marshal.OffsetOf(typeof(KphSsWString), "Buffer").ToInt32(); public ushort Length; public byte Buffer; diff --git a/1.x/trunk/ProcessHacker.Native/SsLogging/SsClientId.cs b/1.x/trunk/ProcessHacker.Native/SsLogging/SsClientId.cs index 323d075f3..7563d7766 100644 --- a/1.x/trunk/ProcessHacker.Native/SsLogging/SsClientId.cs +++ b/1.x/trunk/ProcessHacker.Native/SsLogging/SsClientId.cs @@ -1,4 +1,7 @@ -using ProcessHacker.Native.Api; +using System; +using System.Collections.Generic; +using System.Text; +using ProcessHacker.Native.Api; namespace ProcessHacker.Native.SsLogging { @@ -6,7 +9,7 @@ public class SsClientId : SsData { public SsClientId(MemoryRegion data) { - this.Original = data.ReadStruct(0, ClientId.SizeOf, 0); + this.Original = data.ReadStruct(); } public ClientId Original diff --git a/1.x/trunk/ProcessHacker.Native/SsLogging/SsHandle.cs b/1.x/trunk/ProcessHacker.Native/SsLogging/SsHandle.cs index e3f67af7f..d964e09e4 100644 --- a/1.x/trunk/ProcessHacker.Native/SsLogging/SsHandle.cs +++ b/1.x/trunk/ProcessHacker.Native/SsLogging/SsHandle.cs @@ -1,10 +1,14 @@ -namespace ProcessHacker.Native.SsLogging +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.Native.SsLogging { public sealed class SsHandle : SsData { internal SsHandle(MemoryRegion data) { - KphSsHandle handleInfo = data.ReadStruct(0, KphSsHandle.SizeOf, 0); + KphSsHandle handleInfo = data.ReadStruct(); if (handleInfo.TypeNameOffset != 0) { diff --git a/1.x/trunk/ProcessHacker.Native/SsLogging/SsLogger.cs b/1.x/trunk/ProcessHacker.Native/SsLogging/SsLogger.cs index 455a57e05..01f606245 100644 --- a/1.x/trunk/ProcessHacker.Native/SsLogging/SsLogger.cs +++ b/1.x/trunk/ProcessHacker.Native/SsLogging/SsLogger.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; using System.Threading; using ProcessHacker.Common; using ProcessHacker.Native.Api; @@ -19,7 +20,7 @@ public sealed class SsLogger public static SsData ReadArgumentBlock(MemoryRegion data) { - KphSsArgumentBlock argBlock = data.ReadStruct(0, KphSsArgumentBlock.SizeOf, 0); + var argBlock = data.ReadStruct(); MemoryRegion dataRegion; SsData ssArg = null; @@ -31,45 +32,37 @@ public static SsData ReadArgumentBlock(MemoryRegion data) { case KphSsArgumentType.Int8: { - SsSimple simpleArg = new SsSimple - { - Argument = argBlock.Data.Int8, - Type = typeof(Byte) - }; + SsSimple simpleArg = new SsSimple(); + simpleArg.Argument = argBlock.Data.Int8; + simpleArg.Type = typeof(Byte); ssArg = simpleArg; } break; case KphSsArgumentType.Int16: { - SsSimple simpleArg = new SsSimple - { - Argument = argBlock.Data.Int16, - Type = typeof(Int16) - }; + SsSimple simpleArg = new SsSimple(); + simpleArg.Argument = argBlock.Data.Int16; + simpleArg.Type = typeof(Int16); ssArg = simpleArg; } break; case KphSsArgumentType.Int32: { - SsSimple simpleArg = new SsSimple - { - Argument = argBlock.Data.Int32, - Type = typeof(Int32) - }; + SsSimple simpleArg = new SsSimple(); + simpleArg.Argument = argBlock.Data.Int32; + simpleArg.Type = typeof(Int32); ssArg = simpleArg; } break; case KphSsArgumentType.Int64: { - SsSimple simpleArg = new SsSimple - { - Argument = argBlock.Data.Int64, - Type = typeof(Int64) - }; + SsSimple simpleArg = new SsSimple(); + simpleArg.Argument = argBlock.Data.Int64; + simpleArg.Type = typeof(Int64); ssArg = simpleArg; } break; @@ -107,12 +100,15 @@ public static SsData ReadArgumentBlock(MemoryRegion data) public static SsEvent ReadEventBlock(MemoryRegion data) { - KphSsEventBlock eventBlock = data.ReadStruct(0, KphSsEventBlock.SizeOf, 0); + var eventBlock = data.ReadStruct(); + + int[] arguments; + IntPtr[] stackTrace; // Reconstruct the argument and stack trace arrays. - int[] arguments = new int[eventBlock.NumberOfArguments]; - IntPtr[] stackTrace = new IntPtr[eventBlock.TraceCount]; + arguments = new int[eventBlock.NumberOfArguments]; + stackTrace = new IntPtr[eventBlock.TraceCount]; for (int i = 0; i < arguments.Length; i++) arguments[i] = data.ReadInt32(eventBlock.ArgumentsOffset, i); @@ -120,20 +116,22 @@ public static SsEvent ReadEventBlock(MemoryRegion data) stackTrace[i] = data.ReadIntPtr(eventBlock.TraceOffset, i); // Create an event object. - SsEvent ssEvent = new SsEvent - { - // Basic information - Time = DateTime.FromFileTime(eventBlock.Time), - ThreadId = eventBlock.ClientId.ThreadId, - ProcessId = eventBlock.ClientId.ProcessId, - Arguments = arguments, - StackTrace = stackTrace, ArgumentsCopyFailed = - eventBlock.Flags.HasFlag(KphSsEventFlags.CopyArgumentsFailed), - ArgumentsProbeFailed = eventBlock.Flags.HasFlag(KphSsEventFlags.ProbeArgumentsFailed), - CallNumber = eventBlock.Number - }; + SsEvent ssEvent = new SsEvent(); + + // Basic information + ssEvent.Time = DateTime.FromFileTime(eventBlock.Time); + ssEvent.ThreadId = eventBlock.ClientId.ThreadId; + ssEvent.ProcessId = eventBlock.ClientId.ProcessId; + ssEvent.Arguments = arguments; + ssEvent.StackTrace = stackTrace; // Flags + ssEvent.ArgumentsCopyFailed = + (eventBlock.Flags & KphSsEventFlags.CopyArgumentsFailed) == KphSsEventFlags.CopyArgumentsFailed; + ssEvent.ArgumentsProbeFailed = + (eventBlock.Flags & KphSsEventFlags.ProbeArgumentsFailed) == KphSsEventFlags.ProbeArgumentsFailed; + ssEvent.CallNumber = eventBlock.Number; + if ((eventBlock.Flags & KphSsEventFlags.UserMode) == KphSsEventFlags.UserMode) ssEvent.Mode = KProcessorMode.UserMode; else @@ -144,7 +142,7 @@ public static SsEvent ReadEventBlock(MemoryRegion data) public static string ReadWString(MemoryRegion data) { - KphSsWString wString = data.ReadStruct(0, KphSsWString.SizeOf, 0); + KphSsWString wString = data.ReadStruct(); return data.ReadUnicodeString(KphSsWString.BufferOffset, wString.Length / 2); } @@ -154,18 +152,20 @@ public static string ReadWString(MemoryRegion data) public event RawArgumentBlockReceivedDelegate RawArgumentBlockReceived; public event RawEventBlockReceivedDelegate RawEventBlockReceived; - private bool _started; - private readonly object _startLock = new object(); + private bool _started = false; + private object _startLock = new object(); - private bool _terminating; + private bool _terminating = false; private Thread _bufferWorkerThread; private ThreadHandle _bufferWorkerThreadHandle; - private readonly Event _bufferWorkerThreadReadyEvent = new Event(true, false); + private Event _bufferWorkerThreadReadyEvent = new Event(true, false); - private readonly VirtualMemoryAlloc _buffer; - private readonly SemaphoreHandle _readSemaphore; - private readonly SemaphoreHandle _writeSemaphore; - private int _cursor; + private VirtualMemoryAlloc _buffer; + private SemaphoreHandle _readSemaphore; + private SemaphoreHandle _writeSemaphore; + private int _cursor = 0; + private KphSsClientEntryHandle _clientEntryHandle; + private KphSsRuleSetEntryHandle _ruleSetEntryHandle; public SsLogger(int bufferedBlockCount, bool includeAll) { @@ -180,57 +180,57 @@ public SsLogger(int bufferedBlockCount, bool includeAll) _writeSemaphore = SemaphoreHandle.Create(SemaphoreAccess.All, bufferedBlockCount, bufferedBlockCount); // Create the client entry. - //_clientEntryHandle = KProcessHacker.Instance.SsCreateClientEntry( - // ProcessHandle.Current, - // _readSemaphore, - // _writeSemaphore, - // _buffer, - // _buffer.Size - // ); + _clientEntryHandle = KProcessHacker.Instance.SsCreateClientEntry( + ProcessHandle.Current, + _readSemaphore, + _writeSemaphore, + _buffer, + _buffer.Size + ); // Create the ruleset entry. - //_ruleSetEntryHandle = KProcessHacker.Instance.SsCreateRuleSetEntry( - // _clientEntryHandle, - // includeAll ? KphSsFilterType.Include : KphSsFilterType.Exclude, - // KphSsRuleSetAction.Log - // ); + _ruleSetEntryHandle = KProcessHacker.Instance.SsCreateRuleSetEntry( + _clientEntryHandle, + includeAll ? KphSsFilterType.Include : KphSsFilterType.Exclude, + KphSsRuleSetAction.Log + ); + } + + public IntPtr AddNumberRule(FilterType filterType, int number) + { + return KProcessHacker.Instance.SsAddNumberRule( + _ruleSetEntryHandle, + filterType.ToKphSs(), + number + ); + } + + public IntPtr AddPreviousModeRule(FilterType filterType, KProcessorMode previousMode) + { + return KProcessHacker.Instance.SsAddPreviousModeRule( + _ruleSetEntryHandle, + filterType.ToKphSs(), + previousMode + ); } - //public IntPtr AddNumberRule(FilterType filterType, int number) - //{ - // return KProcessHacker.Instance.SsAddNumberRule( - // _ruleSetEntryHandle, - // filterType.ToKphSs(), - // number - // ); - //} - - //public IntPtr AddPreviousModeRule(FilterType filterType, KProcessorMode previousMode) - //{ - // return KProcessHacker.Instance.SsAddPreviousModeRule( - // _ruleSetEntryHandle, - // filterType.ToKphSs(), - // previousMode - // ); - //} - - //public IntPtr AddProcessIdRule(FilterType filterType, int pid) - //{ - // return KProcessHacker.Instance.SsAddProcessIdRule( - // _ruleSetEntryHandle, - // filterType.ToKphSs(), - // pid.ToIntPtr() - // ); - //} - - //public IntPtr AddThreadIdRule(FilterType filterType, int tid) - //{ - // return KProcessHacker.Instance.SsAddProcessIdRule( - // _ruleSetEntryHandle, - // filterType.ToKphSs(), - // tid.ToIntPtr() - // ); - //} + public IntPtr AddProcessIdRule(FilterType filterType, int pid) + { + return KProcessHacker.Instance.SsAddProcessIdRule( + _ruleSetEntryHandle, + filterType.ToKphSs(), + pid.ToIntPtr() + ); + } + + public IntPtr AddThreadIdRule(FilterType filterType, int tid) + { + return KProcessHacker.Instance.SsAddProcessIdRule( + _ruleSetEntryHandle, + filterType.ToKphSs(), + tid.ToIntPtr() + ); + } private void BufferWorkerThreadStart() { @@ -255,34 +255,37 @@ private void BufferWorkerThreadStart() return; // Check if we have an implicit cursor reset. - if (_buffer.Size - _cursor < KphSsBlockHeader.SizeOf) + if (_buffer.Size - _cursor < Marshal.SizeOf(typeof(KphSsBlockHeader))) _cursor = 0; // Read the block header. - blockHeader = _buffer.ReadStruct(_cursor, KphSsBlockHeader.SizeOf, 0); + blockHeader = _buffer.ReadStruct(_cursor, 0); // Check if we have an explicit cursor reset. if (blockHeader.Type == KphSsBlockType.Reset) { _cursor = 0; - blockHeader = _buffer.ReadStruct(_cursor, KphSsBlockHeader.SizeOf, 0); + blockHeader = _buffer.ReadStruct(_cursor, 0); } // Process the block. - switch (blockHeader.Type) + if (blockHeader.Type == KphSsBlockType.Event) { - case KphSsBlockType.Event: - if (this.EventBlockReceived != null) - this.EventBlockReceived(ReadEventBlock(new MemoryRegion(this._buffer, this._cursor))); - if (this.RawEventBlockReceived != null) - this.RawEventBlockReceived(new MemoryRegion(this._buffer, this._cursor)); - break; - case KphSsBlockType.Argument: - if (this.ArgumentBlockReceived != null) - this.ArgumentBlockReceived(ReadArgumentBlock(new MemoryRegion(this._buffer, this._cursor))); - if (this.RawArgumentBlockReceived != null) - this.RawArgumentBlockReceived(new MemoryRegion(this._buffer, this._cursor)); - break; + // Raise the events. + + if (this.EventBlockReceived != null) + this.EventBlockReceived(ReadEventBlock(new MemoryRegion(_buffer, _cursor))); + if (this.RawEventBlockReceived != null) + this.RawEventBlockReceived(new MemoryRegion(_buffer, _cursor)); + } + else if (blockHeader.Type == KphSsBlockType.Argument) + { + // Raise the events. + + if (this.ArgumentBlockReceived != null) + this.ArgumentBlockReceived(ReadArgumentBlock(new MemoryRegion(_buffer, _cursor))); + if (this.RawArgumentBlockReceived != null) + this.RawArgumentBlockReceived(new MemoryRegion(_buffer, _cursor)); } // Advance the cursor. @@ -294,24 +297,23 @@ private void BufferWorkerThreadStart() public void GetStatistics(out int blocksWritten, out int blocksDropped) { - //KphSsClientInformation info; - //KProcessHacker.Instance.SsQueryClientEntry( - // _clientEntryHandle, - // out info, - // KphSsClientInformation.SizeOf, - // out retLength - // ); - - //blocksWritten = info.NumberOfBlocksWritten; - //blocksDropped = info.NumberOfBlocksDropped; - - blocksWritten = 0; - blocksDropped = 0; + KphSsClientInformation info; + int retLength; + + KProcessHacker.Instance.SsQueryClientEntry( + _clientEntryHandle, + out info, + Marshal.SizeOf(typeof(KphSsClientInformation)), + out retLength + ); + + blocksWritten = info.NumberOfBlocksWritten; + blocksDropped = info.NumberOfBlocksDropped; } public void RemoveRule(IntPtr handle) { - //KProcessHacker.Instance.SsRemoveRule(_ruleSetEntryHandle, handle); + KProcessHacker.Instance.SsRemoveRule(_ruleSetEntryHandle, handle); } public void Start() @@ -320,17 +322,15 @@ public void Start() { if (!_started) { - //KProcessHacker.Instance.SsRef(); - //KProcessHacker.Instance.SsEnableClientEntry(_clientEntryHandle, true); + KProcessHacker.Instance.SsRef(); + KProcessHacker.Instance.SsEnableClientEntry(_clientEntryHandle, true); _started = true; _terminating = false; // Create the buffer worker thread. - _bufferWorkerThread = new Thread(this.BufferWorkerThreadStart, Utils.SixteenthStackSize) - { - IsBackground = true - }; + _bufferWorkerThread = new Thread(this.BufferWorkerThreadStart, Utils.SixteenthStackSize); + _bufferWorkerThread.IsBackground = true; _bufferWorkerThread.Start(); // Wait for the thread to initialize. _bufferWorkerThreadReadyEvent.Wait(); @@ -344,8 +344,8 @@ public void Stop() { if (_started) { - //KProcessHacker.Instance.SsEnableClientEntry(_clientEntryHandle, false); - //KProcessHacker.Instance.SsUnref(); + KProcessHacker.Instance.SsEnableClientEntry(_clientEntryHandle, false); + KProcessHacker.Instance.SsUnref(); _started = false; // Tell the worker thread to stop. diff --git a/1.x/trunk/ProcessHacker.Native/SsLogging/SsObjectAttributes.cs b/1.x/trunk/ProcessHacker.Native/SsLogging/SsObjectAttributes.cs index 6ba92e00b..82e4cc591 100644 --- a/1.x/trunk/ProcessHacker.Native/SsLogging/SsObjectAttributes.cs +++ b/1.x/trunk/ProcessHacker.Native/SsLogging/SsObjectAttributes.cs @@ -1,4 +1,7 @@ -using ProcessHacker.Native.Api; +using System; +using System.Collections.Generic; +using System.Text; +using ProcessHacker.Native.Api; namespace ProcessHacker.Native.SsLogging { @@ -6,7 +9,7 @@ public class SsObjectAttributes : SsData { internal SsObjectAttributes(MemoryRegion data) { - KphSsObjectAttributes oaInfo = data.ReadStruct(0, KphSsObjectAttributes.SizeOf, 0); + KphSsObjectAttributes oaInfo = data.ReadStruct(); if (oaInfo.ObjectNameOffset != 0) this.ObjectName = new SsUnicodeString(new MemoryRegion(data, oaInfo.ObjectNameOffset)); diff --git a/1.x/trunk/ProcessHacker.Native/SsLogging/SsUnicodeString.cs b/1.x/trunk/ProcessHacker.Native/SsLogging/SsUnicodeString.cs index 7a59c87dd..a224af7d4 100644 --- a/1.x/trunk/ProcessHacker.Native/SsLogging/SsUnicodeString.cs +++ b/1.x/trunk/ProcessHacker.Native/SsLogging/SsUnicodeString.cs @@ -1,4 +1,7 @@ -using ProcessHacker.Native.Api; +using System; +using System.Collections.Generic; +using System.Text; +using ProcessHacker.Native.Api; namespace ProcessHacker.Native.SsLogging { @@ -8,13 +11,12 @@ internal SsUnicodeString(MemoryRegion data) { KphSsUnicodeString unicodeStringInfo = data.ReadStruct(); - this.Original = new UnicodeString + this.Original = new UnicodeString() { Length = unicodeStringInfo.Length, MaximumLength = unicodeStringInfo.MaximumLength, Buffer = unicodeStringInfo.Pointer }; - this.String = data.ReadUnicodeString( KphSsUnicodeString.BufferOffset, unicodeStringInfo.Length / 2 diff --git a/1.x/trunk/ProcessHacker.Native/Symbols/SymbolProvider.cs b/1.x/trunk/ProcessHacker.Native/Symbols/SymbolProvider.cs index e0b4724a6..e2bf114c8 100644 --- a/1.x/trunk/ProcessHacker.Native/Symbols/SymbolProvider.cs +++ b/1.x/trunk/ProcessHacker.Native/Symbols/SymbolProvider.cs @@ -38,7 +38,7 @@ public sealed class SymbolProvider : IDisposable { private sealed class SymbolHandle : BaseObject { - private readonly ProcessHandle _processHandle; + private ProcessHandle _processHandle; private IntPtr _handle; public static implicit operator IntPtr(SymbolHandle symbolHandle) @@ -99,7 +99,7 @@ public IntPtr Handle } private const int _maxNameLen = 0x100; - private static readonly IdGenerator _idGen = new IdGenerator(); + private static IdGenerator _idGen = new IdGenerator(); public static SymbolOptions Options { @@ -116,8 +116,8 @@ public static SymbolOptions Options } } - private readonly SymbolHandle _handle; - private readonly List> _modules = new List>(); + private SymbolHandle _handle; + private List> _modules = new List>(); public SymbolProvider() { @@ -142,9 +142,11 @@ public bool Busy { return true; } - - Win32.DbgHelpLock.Release(); - return false; + else + { + Win32.DbgHelpLock.Release(); + return false; + } } } @@ -164,7 +166,7 @@ public string SearchPath using (Win32.DbgHelpLock.AcquireContext()) { if (!Win32.SymGetSearchPath(_handle, data, data.Capacity)) - return string.Empty; + return ""; } return data.ToString(); @@ -195,9 +197,10 @@ public void EnumSymbols(ulong moduleBase, string mask, SymbolEnumDelegate enumDe _handle, moduleBase, mask, - (symbolInfo, symbolSize, userContext) => enumDelegate(new SymbolInformation(symbolInfo, symbolSize)), - IntPtr.Zero) - ) + (symbolInfo, symbolSize, userContext) => + enumDelegate(new SymbolInformation(symbolInfo, symbolSize)), + IntPtr.Zero + )) Win32.Throw(); } } @@ -209,10 +212,10 @@ public string GetLineFromAddress(ulong address) this.GetLineFromAddress(address, out fileName, out lineNumber); - if (!string.IsNullOrEmpty(fileName)) - return fileName + ": line " + lineNumber; - - return null; + if (fileName != null) + return fileName + ": line " + lineNumber.ToString(); + else + return null; } public void GetLineFromAddress(ulong address, out string fileName, out int lineNumber) @@ -334,15 +337,14 @@ public string GetSymbolFromAddress(ulong address, out SymbolResolveLevel level, } // Allocate some memory for the symbol information. - using (MemoryAlloc data = new MemoryAlloc(SymbolInfo.SizeOf + _maxNameLen)) + using (var data = new MemoryAlloc(Marshal.SizeOf(typeof(SymbolInfo)) + _maxNameLen)) { - SymbolInfo info = new SymbolInfo - { - SizeOfStruct = SymbolInfo.SizeOf, - MaxNameLen = _maxNameLen - 1 - }; + var info = new SymbolInfo(); - data.WriteStruct(info); + info.SizeOfStruct = Marshal.SizeOf(info); + info.MaxNameLen = _maxNameLen - 1; + + Marshal.StructureToPtr(info, data, false); // Hack for drivers, since we don't get their module sizes. // Preloading modules will fix this. @@ -384,7 +386,7 @@ public string GetSymbolFromAddress(ulong address, out SymbolResolveLevel level, } // If we don't have a module name, return an address. - if (string.IsNullOrEmpty(modFileName)) + if (modFileName == null) { level = SymbolResolveLevel.Address; flags = 0; @@ -418,10 +420,12 @@ public string GetSymbolFromAddress(ulong address, out SymbolResolveLevel level, { return fi.Name + "+0x" + (address - modBase).ToString("x"); } + else + { + var s = modFileName.Split('\\'); - var s = modFileName.Split('\\'); - - return s[s.Length - 1] + "+0x" + (address - modBase).ToString("x"); + return s[s.Length - 1] + "+0x" + (address - modBase).ToString("x"); + } } // If we have everything, return the full symbol name: module!symbol+offset. @@ -433,22 +437,21 @@ public string GetSymbolFromAddress(ulong address, out SymbolResolveLevel level, if (displacement == 0) return fi.Name + "!" + name; - - return fi.Name + "!" + name + "+0x" + displacement.ToString("x"); + else + return fi.Name + "!" + name + "+0x" + displacement.ToString("x"); } } public SymbolInformation GetSymbolFromName(string symbolName) { - using (MemoryAlloc data = new MemoryAlloc(SymbolInfo.SizeOf + _maxNameLen)) + using (var data = new MemoryAlloc(Marshal.SizeOf(typeof(SymbolInfo)) + _maxNameLen)) { - SymbolInfo info = new SymbolInfo - { - SizeOfStruct = SymbolInfo.SizeOf, - MaxNameLen = _maxNameLen - 1 - }; + var info = new SymbolInfo(); + + info.SizeOfStruct = Marshal.SizeOf(info); + info.MaxNameLen = _maxNameLen - 1; - data.WriteStruct(info); + Marshal.StructureToPtr(info, data, false); using (Win32.DbgHelpLock.AcquireContext()) { diff --git a/1.x/trunk/ProcessHacker.Native/Threading/CurrentThread.cs b/1.x/trunk/ProcessHacker.Native/Threading/CurrentThread.cs index 3d9cb8d79..a269c9e0f 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/CurrentThread.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/CurrentThread.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; diff --git a/1.x/trunk/ProcessHacker.Native/Threading/Event.cs b/1.x/trunk/ProcessHacker.Native/Threading/Event.cs index c00551171..19b716f82 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/Event.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/Event.cs @@ -20,6 +20,9 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; @@ -93,7 +96,11 @@ public Event(string name, bool autoReset, bool initialState) /// public bool AutoReset { - get { return this.Handle.BasicInformation.EventType == EventType.SynchronizationEvent; } + get + { + return this.Handle.GetBasicInformation().EventType == + EventType.SynchronizationEvent; + } } /// @@ -101,7 +108,7 @@ public bool AutoReset /// public bool Signaled { - get { return this.Handle.BasicInformation.EventState != 0; } + get { return this.Handle.GetBasicInformation().EventState != 0; } } /// diff --git a/1.x/trunk/ProcessHacker.Native/Threading/EventPair.cs b/1.x/trunk/ProcessHacker.Native/Threading/EventPair.cs index bd4f3c1ca..4b78b733e 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/EventPair.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/EventPair.cs @@ -20,6 +20,9 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; diff --git a/1.x/trunk/ProcessHacker.Native/Threading/KeyedEvent.cs b/1.x/trunk/ProcessHacker.Native/Threading/KeyedEvent.cs index 966f5eef9..8c38b1f4c 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/KeyedEvent.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/KeyedEvent.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; diff --git a/1.x/trunk/ProcessHacker.Native/Threading/Mutant.cs b/1.x/trunk/ProcessHacker.Native/Threading/Mutant.cs index 4e3bcadda..f3841fcbf 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/Mutant.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/Mutant.cs @@ -20,6 +20,9 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; @@ -85,7 +88,7 @@ public Mutant(string name, bool owned) /// public bool Owned { - get { return this.Handle.BasicInformation.CurrentCount <= 0; } + get { return this.Handle.GetBasicInformation().CurrentCount <= 0; } } /// diff --git a/1.x/trunk/ProcessHacker.Native/Threading/NativeThreadPool.cs b/1.x/trunk/ProcessHacker.Native/Threading/NativeThreadPool.cs index 14bdf0d37..3074a7801 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/NativeThreadPool.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/NativeThreadPool.cs @@ -1,5 +1,8 @@ using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; +using ProcessHacker.Native.Objects; namespace ProcessHacker.Native.Threading { @@ -9,7 +12,7 @@ public static class NativeThreadPool { public static void QueueWorkItem(Action work, object argument) { - Win32.RtlQueueWorkItem(context => work(argument), IntPtr.Zero, WtFlags.ExecuteDefault).ThrowIf(); + Win32.RtlQueueWorkItem((context) => work(argument), IntPtr.Zero, WtFlags.ExecuteDefault).ThrowIf(); } public static IntPtr RegisterWait(IntPtr handle, RegisterWaitCallback callback, object argument, int timeoutMilliseconds) diff --git a/1.x/trunk/ProcessHacker.Native/Threading/Semaphore.cs b/1.x/trunk/ProcessHacker.Native/Threading/Semaphore.cs index d9f537613..cfbf60aea 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/Semaphore.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/Semaphore.cs @@ -20,6 +20,9 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; +using System.Text; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; diff --git a/1.x/trunk/ProcessHacker.Native/Threading/Timer.cs b/1.x/trunk/ProcessHacker.Native/Threading/Timer.cs index 2783784ee..4e9b104a5 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/Timer.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/Timer.cs @@ -38,6 +38,8 @@ namespace ProcessHacker.Native.Threading /// public sealed class Timer : NativeObject { + private TimerCallback _callback; + /// /// Creates a timer. /// @@ -90,7 +92,7 @@ public Timer(string name, bool autoReset) /// public TimeSpan RemainingTime { - get { return new TimeSpan(this.Handle.BasicInformation.RemainingTime); } + get { return new TimeSpan(this.Handle.GetBasicInformation().RemainingTime); } } /// @@ -98,7 +100,7 @@ public TimeSpan RemainingTime /// public bool Signaled { - get { return this.Handle.BasicInformation.TimerState; } + get { return this.Handle.GetBasicInformation().TimerState; } } /// @@ -150,6 +152,7 @@ public void Set(TimerCallback callback, int dueTime, int period, IntPtr context) { TimerApcRoutine apcRoutine = (context_, lowPart, highPart) => callback(context_); + _callback = callback; this.Handle.Set( dueTime * Win32.TimeMsTo100Ns, true, @@ -200,6 +203,7 @@ public void Set(TimerCallback callback, DateTime dueTime, int period, IntPtr con { TimerApcRoutine apcRoutine = (context_, lowPart, highPart) => callback(context_); + _callback = callback; this.Handle.Set( dueTime.ToFileTime(), false, diff --git a/1.x/trunk/ProcessHacker.Native/Threading/Waiter.cs b/1.x/trunk/ProcessHacker.Native/Threading/Waiter.cs index 0cdfff408..07f3f9461 100644 --- a/1.x/trunk/ProcessHacker.Native/Threading/Waiter.cs +++ b/1.x/trunk/ProcessHacker.Native/Threading/Waiter.cs @@ -41,22 +41,20 @@ private class WaiterThread : BaseObject { public event ObjectSignaledDelegate ObjectSignaled; - private readonly Waiter _owner; - private bool _terminating; - private readonly Thread _thread; + private Waiter _owner; + private bool _terminating = false; + private Thread _thread; private FastEvent _threadInitializedEvent = new FastEvent(false); private ThreadHandle _threadHandle; - private readonly List _waitObjects = new List(); + private List _waitObjects = new List(); public WaiterThread(Waiter owner) { _owner = owner; // Create the waiter thread. - _thread = new Thread(this.WaiterThreadStart, Common.Utils.SixteenthStackSize) - { - IsBackground = true - }; + _thread = new Thread(this.WaiterThreadStart, ProcessHacker.Common.Utils.SixteenthStackSize); + _thread.IsBackground = true; _thread.SetApartmentState(ApartmentState.STA); _thread.Start(); @@ -233,8 +231,8 @@ private void WaiterThreadStart() /// public event ObjectSignaledDelegate ObjectSignaled; - private readonly List _waiterThreads = new List(); - private readonly List _waitObjects = new List(); + private List _waiterThreads = new List(); + private List _waitObjects = new List(); /// /// Creates a waiter. @@ -303,7 +301,12 @@ internal void BalanceWaiterThreads() } } - private void CreateWaiterThread(ISynchronizable obj = null) + private WaiterThread CreateWaiterThread() + { + return this.CreateWaiterThread(null); + } + + private WaiterThread CreateWaiterThread(ISynchronizable obj) { WaiterThread waiterThread = new WaiterThread(this); @@ -314,6 +317,8 @@ private void CreateWaiterThread(ISynchronizable obj = null) lock (_waiterThreads) _waiterThreads.Add(waiterThread); + + return waiterThread; } private void DeleteWaiterThread(WaiterThread waiterThread) diff --git a/1.x/trunk/ProcessHacker/Forms/Ui/ChooseProcessDialog.Designer.cs b/1.x/trunk/ProcessHacker.Native/Ui/ChooseProcessDialog.Designer.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Forms/Ui/ChooseProcessDialog.Designer.cs rename to 1.x/trunk/ProcessHacker.Native/Ui/ChooseProcessDialog.Designer.cs diff --git a/1.x/trunk/ProcessHacker/Forms/Ui/ChooseProcessDialog.cs b/1.x/trunk/ProcessHacker.Native/Ui/ChooseProcessDialog.cs similarity index 76% rename from 1.x/trunk/ProcessHacker/Forms/Ui/ChooseProcessDialog.cs rename to 1.x/trunk/ProcessHacker.Native/Ui/ChooseProcessDialog.cs index 5a18f44c7..12d82eb22 100644 --- a/1.x/trunk/ProcessHacker/Forms/Ui/ChooseProcessDialog.cs +++ b/1.x/trunk/ProcessHacker.Native/Ui/ChooseProcessDialog.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using ProcessHacker.Native.Objects; @@ -28,7 +27,7 @@ public int SelectedPid private void RefreshProcesses() { - Dictionary processes = Windows.GetProcesses(); + var processes = Windows.GetProcesses(); listProcesses.BeginUpdate(); listProcesses.Items.Clear(); @@ -39,29 +38,30 @@ private void RefreshProcesses() foreach (var process in processes.Values) { - string userName = string.Empty; + string userName = ""; string fileName = null; try { - using (ProcessHandle phandle = new ProcessHandle(process.Process.ProcessId, OSVersion.MinProcessQueryInfoAccess)) + using (var phandle = new ProcessHandle(process.Process.ProcessId, OSVersion.MinProcessQueryInfoAccess)) { - using (TokenHandle thandle = phandle.GetToken(TokenAccess.Query)) - using (Sid sid = thandle.User) + using (var thandle = phandle.GetToken(TokenAccess.Query)) + using (var sid = thandle.GetUser()) userName = sid.GetFullName(true); - fileName = phandle.ImageFileName; + fileName = FileUtils.GetFileName(phandle.GetImageFileName()); } } catch { } - ListViewItem item = new ListViewItem(new string[] - { - process.Process.ProcessId == 0 ? "System Idle Process" : process.Name, - process.Process.ProcessId.ToString(), - userName - }); + ListViewItem item = new ListViewItem( + new string[] + { + process.Process.ProcessId == 0 ? "System Idle Process" : process.Name, + process.Process.ProcessId.ToString(), + userName + }); if (!string.IsNullOrEmpty(fileName)) { diff --git a/1.x/trunk/ProcessHacker/Forms/Ui/ChooseProcessDialog.resx b/1.x/trunk/ProcessHacker.Native/Ui/ChooseProcessDialog.resx similarity index 100% rename from 1.x/trunk/ProcessHacker/Forms/Ui/ChooseProcessDialog.resx rename to 1.x/trunk/ProcessHacker.Native/Ui/ChooseProcessDialog.resx diff --git a/1.x/trunk/ProcessHacker/Components/HandleDetails.Designer.cs b/1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.Designer.cs similarity index 63% rename from 1.x/trunk/ProcessHacker/Components/HandleDetails.Designer.cs rename to 1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.Designer.cs index 2e1263e1b..3b5f6a828 100644 --- a/1.x/trunk/ProcessHacker/Components/HandleDetails.Designer.cs +++ b/1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.Designer.cs @@ -1,13 +1,13 @@ -namespace ProcessHacker.Components +namespace ProcessHacker.Native.Ui { - partial class HandleDetails + partial class HandlePropertiesWindow { - /// + /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; - /// + /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. @@ -17,17 +17,20 @@ protected override void Dispose(bool disposing) { components.Dispose(); } + base.Dispose(disposing); } - #region Component Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify + /// + /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { + this.tabControl = new System.Windows.Forms.TabControl(); + this.tabDetails = new System.Windows.Forms.TabPage(); this.groupObjectInfo = new System.Windows.Forms.GroupBox(); this.groupQuotaCharges = new System.Windows.Forms.GroupBox(); this.labelNonPaged = new System.Windows.Forms.Label(); @@ -44,33 +47,63 @@ private void InitializeComponent() this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); + this.buttonClose = new System.Windows.Forms.Button(); + this.buttonPermissions = new System.Windows.Forms.Button(); + this.tabControl.SuspendLayout(); + this.tabDetails.SuspendLayout(); this.groupQuotaCharges.SuspendLayout(); this.groupReferences.SuspendLayout(); this.groupBasicInfo.SuspendLayout(); this.SuspendLayout(); // + // tabControl + // + this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl.Controls.Add(this.tabDetails); + this.tabControl.Location = new System.Drawing.Point(12, 12); + this.tabControl.Name = "tabControl"; + this.tabControl.SelectedIndex = 0; + this.tabControl.Size = new System.Drawing.Size(370, 382); + this.tabControl.TabIndex = 0; + // + // tabDetails + // + this.tabDetails.Controls.Add(this.groupObjectInfo); + this.tabDetails.Controls.Add(this.groupQuotaCharges); + this.tabDetails.Controls.Add(this.groupReferences); + this.tabDetails.Controls.Add(this.groupBasicInfo); + this.tabDetails.Location = new System.Drawing.Point(4, 22); + this.tabDetails.Name = "tabDetails"; + this.tabDetails.Padding = new System.Windows.Forms.Padding(3); + this.tabDetails.Size = new System.Drawing.Size(362, 356); + this.tabDetails.TabIndex = 0; + this.tabDetails.Text = "Details"; + this.tabDetails.UseVisualStyleBackColor = true; + // // groupObjectInfo // - this.groupObjectInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.groupObjectInfo.Location = new System.Drawing.Point(6, 189); + this.groupObjectInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupObjectInfo.Location = new System.Drawing.Point(6, 215); this.groupObjectInfo.Name = "groupObjectInfo"; - this.groupObjectInfo.Size = new System.Drawing.Size(430, 234); - this.groupObjectInfo.TabIndex = 7; + this.groupObjectInfo.Size = new System.Drawing.Size(350, 135); + this.groupObjectInfo.TabIndex = 3; this.groupObjectInfo.TabStop = false; this.groupObjectInfo.Text = "Object Information"; // // groupQuotaCharges // - this.groupQuotaCharges.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupQuotaCharges.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupQuotaCharges.Controls.Add(this.labelNonPaged); this.groupQuotaCharges.Controls.Add(this.labelPaged); - this.groupQuotaCharges.Location = new System.Drawing.Point(188, 112); + this.groupQuotaCharges.Location = new System.Drawing.Point(179, 138); this.groupQuotaCharges.Name = "groupQuotaCharges"; - this.groupQuotaCharges.Size = new System.Drawing.Size(248, 71); - this.groupQuotaCharges.TabIndex = 6; + this.groupQuotaCharges.Size = new System.Drawing.Size(177, 71); + this.groupQuotaCharges.TabIndex = 2; this.groupQuotaCharges.TabStop = false; this.groupQuotaCharges.Text = "Quota Charges"; // @@ -96,10 +129,10 @@ private void InitializeComponent() // this.groupReferences.Controls.Add(this.labelHandles); this.groupReferences.Controls.Add(this.labelReferences); - this.groupReferences.Location = new System.Drawing.Point(6, 112); + this.groupReferences.Location = new System.Drawing.Point(6, 138); this.groupReferences.Name = "groupReferences"; - this.groupReferences.Size = new System.Drawing.Size(176, 71); - this.groupReferences.TabIndex = 5; + this.groupReferences.Size = new System.Drawing.Size(167, 71); + this.groupReferences.TabIndex = 1; this.groupReferences.TabStop = false; this.groupReferences.Text = "References"; // @@ -123,8 +156,9 @@ private void InitializeComponent() // // groupBasicInfo // - this.groupBasicInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupBasicInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBasicInfo.Controls.Add(this.buttonPermissions); this.groupBasicInfo.Controls.Add(this.textGrantedAccess); this.groupBasicInfo.Controls.Add(this.textAddress); this.groupBasicInfo.Controls.Add(this.textType); @@ -135,49 +169,49 @@ private void InitializeComponent() this.groupBasicInfo.Controls.Add(this.label1); this.groupBasicInfo.Location = new System.Drawing.Point(6, 6); this.groupBasicInfo.Name = "groupBasicInfo"; - this.groupBasicInfo.Size = new System.Drawing.Size(430, 102); + this.groupBasicInfo.Size = new System.Drawing.Size(350, 126); this.groupBasicInfo.TabIndex = 0; this.groupBasicInfo.TabStop = false; this.groupBasicInfo.Text = "Basic Information"; // // textGrantedAccess // - this.textGrantedAccess.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textGrantedAccess.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textGrantedAccess.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textGrantedAccess.Location = new System.Drawing.Point(98, 76); this.textGrantedAccess.Name = "textGrantedAccess"; - this.textGrantedAccess.Size = new System.Drawing.Size(326, 13); - this.textGrantedAccess.TabIndex = 20; + this.textGrantedAccess.Size = new System.Drawing.Size(246, 13); + this.textGrantedAccess.TabIndex = 1; // // textAddress // - this.textAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textAddress.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textAddress.Location = new System.Drawing.Point(98, 57); this.textAddress.Name = "textAddress"; - this.textAddress.Size = new System.Drawing.Size(326, 13); + this.textAddress.Size = new System.Drawing.Size(246, 13); this.textAddress.TabIndex = 1; // // textType // - this.textType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textType.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textType.Location = new System.Drawing.Point(60, 38); this.textType.Name = "textType"; - this.textType.Size = new System.Drawing.Size(364, 13); + this.textType.Size = new System.Drawing.Size(284, 13); this.textType.TabIndex = 1; // // textName // - this.textName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textName.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textName.Location = new System.Drawing.Point(60, 19); this.textName.Name = "textName"; - this.textName.Size = new System.Drawing.Size(364, 13); + this.textName.Size = new System.Drawing.Size(284, 13); this.textName.TabIndex = 1; // // label4 @@ -186,7 +220,7 @@ private void InitializeComponent() this.label4.Location = new System.Drawing.Point(6, 76); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(86, 13); - this.label4.TabIndex = 21; + this.label4.TabIndex = 0; this.label4.Text = "Granted Access:"; // // label3 @@ -204,7 +238,7 @@ private void InitializeComponent() this.label2.Location = new System.Drawing.Point(6, 38); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(34, 13); - this.label2.TabIndex = 2; + this.label2.TabIndex = 0; this.label2.Text = "Type:"; // // label1 @@ -216,18 +250,47 @@ private void InitializeComponent() this.label1.TabIndex = 0; this.label1.Text = "Name:"; // - // HandleDetails + // buttonClose + // + this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonClose.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.buttonClose.Location = new System.Drawing.Point(307, 400); + this.buttonClose.Name = "buttonClose"; + this.buttonClose.Size = new System.Drawing.Size(75, 23); + this.buttonClose.TabIndex = 1; + this.buttonClose.Text = "Close"; + this.buttonClose.UseVisualStyleBackColor = true; + this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click); + // + // buttonPermissions + // + this.buttonPermissions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonPermissions.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.buttonPermissions.Location = new System.Drawing.Point(269, 97); + this.buttonPermissions.Name = "buttonPermissions"; + this.buttonPermissions.Size = new System.Drawing.Size(75, 23); + this.buttonPermissions.TabIndex = 2; + this.buttonPermissions.Text = "Permissions"; + this.buttonPermissions.UseVisualStyleBackColor = true; + this.buttonPermissions.Click += new System.EventHandler(this.buttonPermissions_Click); + // + // HandlePropertiesWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.groupObjectInfo); - this.Controls.Add(this.groupQuotaCharges); - this.Controls.Add(this.groupReferences); - this.Controls.Add(this.groupBasicInfo); - this.Name = "HandleDetails"; - this.Padding = new System.Windows.Forms.Padding(3); - this.Size = new System.Drawing.Size(442, 429); + this.ClientSize = new System.Drawing.Size(394, 435); + this.Controls.Add(this.buttonClose); + this.Controls.Add(this.tabControl); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "HandlePropertiesWindow"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Handle Properties"; + this.Load += new System.EventHandler(this.HandlePropertiesWindow_Load); + this.tabControl.ResumeLayout(false); + this.tabDetails.ResumeLayout(false); this.groupQuotaCharges.ResumeLayout(false); this.groupQuotaCharges.PerformLayout(); this.groupReferences.ResumeLayout(false); @@ -240,22 +303,25 @@ private void InitializeComponent() #endregion - private System.Windows.Forms.GroupBox groupObjectInfo; - private System.Windows.Forms.GroupBox groupQuotaCharges; - private System.Windows.Forms.Label labelNonPaged; - private System.Windows.Forms.Label labelPaged; - private System.Windows.Forms.GroupBox groupReferences; - private System.Windows.Forms.Label labelHandles; - private System.Windows.Forms.Label labelReferences; + private System.Windows.Forms.TabControl tabControl; + private System.Windows.Forms.TabPage tabDetails; + private System.Windows.Forms.Button buttonClose; private System.Windows.Forms.GroupBox groupBasicInfo; - private System.Windows.Forms.TextBox textGrantedAccess; - private System.Windows.Forms.TextBox textAddress; - private System.Windows.Forms.TextBox textType; private System.Windows.Forms.TextBox textName; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; - + private System.Windows.Forms.TextBox textGrantedAccess; + private System.Windows.Forms.TextBox textAddress; + private System.Windows.Forms.TextBox textType; + private System.Windows.Forms.GroupBox groupReferences; + private System.Windows.Forms.Label labelHandles; + private System.Windows.Forms.Label labelReferences; + private System.Windows.Forms.GroupBox groupQuotaCharges; + private System.Windows.Forms.Label labelNonPaged; + private System.Windows.Forms.Label labelPaged; + private System.Windows.Forms.GroupBox groupObjectInfo; + private System.Windows.Forms.Button buttonPermissions; } -} +} \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.cs b/1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.cs new file mode 100644 index 000000000..d74083378 --- /dev/null +++ b/1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.cs @@ -0,0 +1,151 @@ +/* + * Process Hacker - + * handle properties window + * + * Copyright (C) 2009 wj32 + * + * This file is part of Process Hacker. + * + * Process Hacker is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Process Hacker is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Process Hacker. If not, see . + */ + +using System; +using System.Windows.Forms; +using ProcessHacker.Native.Api; +using ProcessHacker.Native.Objects; +using ProcessHacker.Native.Security.AccessControl; + +namespace ProcessHacker.Native.Ui +{ + public partial class HandlePropertiesWindow : Form + { + public delegate void HandlePropertiesDelegate(Control objectGroup, string name, string typeName); + + public event HandlePropertiesDelegate HandlePropertiesCallback; + + private string _name, _typeName; + private NativeHandle _objectHandle; + + public HandlePropertiesWindow(SystemHandleEntry handle) + { + InitializeComponent(); + this.KeyPreview = true; + this.KeyDown += (sender, e) => + { + if (e.KeyCode == Keys.Escape) + { + this.Close(); + e.Handled = true; + } + }; + + var handleInfo = handle.GetHandleInfo(); + + textName.Text = _name = handleInfo.BestName; + if (textName.Text == "") + textName.Text = "(unnamed object)"; + textType.Text = _typeName = handleInfo.TypeName; + textAddress.Text = "0x" + handle.Object.ToString("x"); + textGrantedAccess.Text = "0x" + handle.GrantedAccess.ToString("x"); + + if (handle.GrantedAccess != 0) + { + try + { + Type accessEnumType = NativeTypeFactory.GetAccessType(handleInfo.TypeName); + + textGrantedAccess.Text += " (" + + NativeTypeFactory.GetAccessString(accessEnumType, handle.GrantedAccess) + + ")"; + } + catch (NotSupportedException) + { } + } + + var basicInfo = handle.GetBasicInfo(); + + labelReferences.Text = "References: " + (basicInfo.PointerCount - 1).ToString(); + labelHandles.Text = "Handles: " + basicInfo.HandleCount.ToString(); + labelPaged.Text = "Paged: " + basicInfo.PagedPoolUsage.ToString(); + labelNonPaged.Text = "Non-Paged: " + basicInfo.NonPagedPoolUsage.ToString(); + } + + private void HandlePropertiesWindow_Load(object sender, EventArgs e) + { + if (HandlePropertiesCallback != null) + { + try + { + HandlePropertiesCallback(groupObjectInfo, _name, _typeName); + } + catch + { } + + if (groupObjectInfo.Controls.Count == 0) + { + groupObjectInfo.Visible = false; + } + else if (groupObjectInfo.Controls.Count == 1) + { + Control control = groupObjectInfo.Controls[0]; + + // If it's a user control, dock it. + if (control is UserControl) + { + control.Dock = DockStyle.Fill; + control.Margin = new Padding(3); + } + else + { + control.Location = new System.Drawing.Point(10, 20); + } + } + } + + if (this.ObjectHandle == null) + buttonPermissions.Visible = false; + } + + public NativeHandle ObjectHandle + { + get { return _objectHandle; } + set { _objectHandle = value; } + } + + private void buttonClose_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void buttonPermissions_Click(object sender, EventArgs e) + { + if (_objectHandle != null) + { + try + { + SecurityEditor.EditSecurity( + this, + SecurityEditor.GetSecurableWrapper(_objectHandle), + _name, + NativeTypeFactory.GetAccessEntries(NativeTypeFactory.GetObjectType(_typeName)) + ); + } + catch (Exception ex) + { + MessageBox.Show("Unable to edit security: " + ex.Message, "Security Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.resx b/1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.resx similarity index 95% rename from 1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.resx rename to 1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.resx +++ b/1.x/trunk/ProcessHacker.Native/Ui/HandlePropertiesWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker.Native/Windows.cs b/1.x/trunk/ProcessHacker.Native/Windows.cs index edbff97b4..2cdece6a5 100644 --- a/1.x/trunk/ProcessHacker.Native/Windows.cs +++ b/1.x/trunk/ProcessHacker.Native/Windows.cs @@ -63,10 +63,10 @@ public static class Windows [ThreadStatic] private static MemoryAlloc _servicesBuffer; - private static int _numberOfProcessors; - private static int _pageSize; + private static int _numberOfProcessors = 0; + private static int _pageSize = 0; private static IntPtr _kernelBase = IntPtr.Zero; - private static string _kernelFileName; + private static string _kernelFileName = null; /// /// Gets the number of active processors. @@ -141,12 +141,13 @@ public static int BytesToPages(int bytes) /// A callback for the enumeration. public static void EnumKernelModules(EnumKernelModulesDelegate enumCallback) { + NtStatus status; int retLength; if (_kernelModulesBuffer == null) _kernelModulesBuffer = new MemoryAlloc(0x1000); - NtStatus status = Win32.NtQuerySystemInformation( + status = Win32.NtQuerySystemInformation( SystemInformationClass.SystemModuleInformation, _kernelModulesBuffer, _kernelModulesBuffer.Size, @@ -165,13 +166,14 @@ out retLength ); } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); RtlProcessModules modules = _kernelModulesBuffer.ReadStruct(); for (int i = 0; i < modules.NumberOfModules; i++) { - var module = _kernelModulesBuffer.ReadStruct(RtlProcessModules.ModulesOffset, RtlProcessModuleInformation.SizeOf, i); + var module = _kernelModulesBuffer.ReadStruct(RtlProcessModules.ModulesOffset, i); var moduleInfo = new Debugging.ModuleInformation(module); if (!enumCallback(new KernelModule( @@ -191,15 +193,17 @@ out retLength /// A structure containing basic information. public static SystemBasicInformation GetBasicInformation() { + NtStatus status; SystemBasicInformation sbi; int retLength; - Win32.NtQuerySystemInformation( + if ((status = Win32.NtQuerySystemInformation( SystemInformationClass.SystemBasicInformation, out sbi, - SystemBasicInformation.SizeOf, + Marshal.SizeOf(typeof(SystemBasicInformation)), out retLength - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); return sbi; } @@ -210,8 +214,8 @@ out retLength /// An array containing information about the handles. public static SystemHandleEntry[] GetHandles() { - int retLength; - int handleCount; + int retLength = 0; + int handleCount = 0; SystemHandleEntry[] returnHandles; if (_handlesBuffer == null) @@ -238,7 +242,8 @@ public static SystemHandleEntry[] GetHandles() throw new OutOfMemoryException(); } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); // The structure of the buffer is the handle count plus an array of SYSTEM_HANDLE_INFORMATION // structures. @@ -268,7 +273,7 @@ private static IntPtr GetKernelBase() { IntPtr kernelBase = IntPtr.Zero; - EnumKernelModules(module => + Windows.EnumKernelModules((module) => { kernelBase = module.BaseAddress; return false; @@ -285,7 +290,7 @@ private static string GetKernelFileName() { string kernelFileName = null; - EnumKernelModules(module => + EnumKernelModules((module) => { kernelFileName = module.FileName; return false; @@ -302,7 +307,7 @@ public static KernelModule[] GetKernelModules() { List kernelModules = new List(); - EnumKernelModules(kernelModule => + EnumKernelModules((kernelModule) => { kernelModules.Add(kernelModule); return true; @@ -313,49 +318,53 @@ public static KernelModule[] GetKernelModules() public static SystemLogonSession GetLogonSession(Luid logonId) { + NtStatus status; IntPtr logonSessionData; - Win32.LsaGetLogonSessionData( + if ((status = Win32.LsaGetLogonSessionData( ref logonId, out logonSessionData - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); using (var logonSessionDataAlloc = new LsaMemoryAlloc(logonSessionData, true)) { var info = logonSessionDataAlloc.ReadStruct(); return new SystemLogonSession( - info.AuthenticationPackage.Text, - info.DnsDomainName.Text, - info.LogonDomain.Text, + info.AuthenticationPackage.Read(), + info.DnsDomainName.Read(), + info.LogonDomain.Read(), info.LogonId, - info.LogonServer.Text, + info.LogonServer.Read(), DateTime.FromFileTime(info.LogonTime), info.LogonType, info.Session, new Sid(info.Sid), - info.Upn.Text, - info.UserName.Text + info.Upn.Read(), + info.UserName.Read() ); } } public static Luid[] GetLogonSessions() { + NtStatus status; int logonSessionCount; IntPtr logonSessionList; - Win32.LsaEnumerateLogonSessions( + if ((status = Win32.LsaEnumerateLogonSessions( out logonSessionCount, out logonSessionList - ).ThrowIf(); + )) >= NtStatus.Error) + Win32.Throw(status); Luid[] logonSessions = new Luid[logonSessionCount]; - using (LsaMemoryAlloc logonSessionListAlloc = new LsaMemoryAlloc(logonSessionList, true)) + using (var logonSessionListAlloc = new LsaMemoryAlloc(logonSessionList, true)) { for (int i = 0; i < logonSessionCount; i++) - logonSessions[i] = logonSessionListAlloc.ReadStruct(0, Luid.SizeOf, i); + logonSessions[i] = logonSessionListAlloc.ReadStruct(i); return logonSessions; } @@ -368,12 +377,14 @@ out logonSessionList public static Dictionary> GetNetworkConnections() { var retDict = new Dictionary>(); - int length = 0; + int length; // TCP IPv4 + + length = 0; Win32.GetExtendedTcpTable(IntPtr.Zero, ref length, false, AiFamily.INet, TcpTableClass.OwnerPidAll, 0); - using (MemoryAlloc mem = new MemoryAlloc(length)) + using (var mem = new MemoryAlloc(length)) { if (Win32.GetExtendedTcpTable(mem, ref length, false, AiFamily.INet, TcpTableClass.OwnerPidAll, 0) != 0) Win32.Throw(); @@ -382,12 +393,12 @@ public static Dictionary> GetNetworkConnections() for (int i = 0; i < count; i++) { - MibTcpRowOwnerPid struc = mem.ReadStruct(sizeof(int), MibTcpRowOwnerPid.SizeOf, i); + var struc = mem.ReadStruct(sizeof(int), i); if (!retDict.ContainsKey(struc.OwningProcessId)) retDict.Add(struc.OwningProcessId, new List()); - retDict[struc.OwningProcessId].Add(new NetworkConnection + retDict[struc.OwningProcessId].Add(new NetworkConnection() { Protocol = NetworkProtocol.Tcp, Local = new IPEndPoint(struc.LocalAddress, ((ushort)struc.LocalPort).Reverse()), @@ -403,7 +414,7 @@ public static Dictionary> GetNetworkConnections() length = 0; Win32.GetExtendedUdpTable(IntPtr.Zero, ref length, false, AiFamily.INet, UdpTableClass.OwnerPid, 0); - using (MemoryAlloc mem = new MemoryAlloc(length)) + using (var mem = new MemoryAlloc(length)) { if (Win32.GetExtendedUdpTable(mem, ref length, false, AiFamily.INet, UdpTableClass.OwnerPid, 0) != 0) Win32.Throw(); @@ -412,17 +423,18 @@ public static Dictionary> GetNetworkConnections() for (int i = 0; i < count; i++) { - MibUdpRowOwnerPid struc = mem.ReadStruct(sizeof(int), MibUdpRowOwnerPid.SizeOf, i); + var struc = mem.ReadStruct(sizeof(int), i); if (!retDict.ContainsKey(struc.OwningProcessId)) retDict.Add(struc.OwningProcessId, new List()); - retDict[struc.OwningProcessId].Add(new NetworkConnection - { - Protocol = NetworkProtocol.Udp, - Local = new IPEndPoint(struc.LocalAddress, ((ushort)struc.LocalPort).Reverse()), - Pid = struc.OwningProcessId - }); + retDict[struc.OwningProcessId].Add( + new NetworkConnection() + { + Protocol = NetworkProtocol.Udp, + Local = new IPEndPoint(struc.LocalAddress, ((ushort)struc.LocalPort).Reverse()), + Pid = struc.OwningProcessId + }); } } @@ -431,7 +443,7 @@ public static Dictionary> GetNetworkConnections() length = 0; Win32.GetExtendedTcpTable(IntPtr.Zero, ref length, false, AiFamily.INet6, TcpTableClass.OwnerPidAll, 0); - using (MemoryAlloc mem = new MemoryAlloc(length)) + using (var mem = new MemoryAlloc(length)) { if (Win32.GetExtendedTcpTable(mem, ref length, false, AiFamily.INet6, TcpTableClass.OwnerPidAll, 0) == 0) { @@ -439,12 +451,12 @@ public static Dictionary> GetNetworkConnections() for (int i = 0; i < count; i++) { - MibTcp6RowOwnerPid struc = mem.ReadStruct(sizeof(int), MibTcp6RowOwnerPid.SizeOf, i); + var struc = mem.ReadStruct(sizeof(int), i); if (!retDict.ContainsKey(struc.OwningProcessId)) retDict.Add(struc.OwningProcessId, new List()); - retDict[struc.OwningProcessId].Add(new NetworkConnection + retDict[struc.OwningProcessId].Add(new NetworkConnection() { Protocol = NetworkProtocol.Tcp6, Local = new IPEndPoint(new IPAddress(struc.LocalAddress, struc.LocalScopeId), ((ushort)struc.LocalPort).Reverse()), @@ -461,7 +473,7 @@ public static Dictionary> GetNetworkConnections() length = 0; Win32.GetExtendedUdpTable(IntPtr.Zero, ref length, false, AiFamily.INet6, UdpTableClass.OwnerPid, 0); - using (MemoryAlloc mem = new MemoryAlloc(length)) + using (var mem = new MemoryAlloc(length)) { if (Win32.GetExtendedUdpTable(mem, ref length, false, AiFamily.INet6, UdpTableClass.OwnerPid, 0) == 0) { @@ -469,17 +481,18 @@ public static Dictionary> GetNetworkConnections() for (int i = 0; i < count; i++) { - MibUdp6RowOwnerPid struc = mem.ReadStruct(sizeof(int), MibUdp6RowOwnerPid.SizeOf, i); + var struc = mem.ReadStruct(sizeof(int), i); if (!retDict.ContainsKey(struc.OwningProcessId)) retDict.Add(struc.OwningProcessId, new List()); - retDict[struc.OwningProcessId].Add(new NetworkConnection - { - Protocol = NetworkProtocol.Udp6, - Local = new IPEndPoint(new IPAddress(struc.LocalAddress, struc.LocalScopeId), ((ushort)struc.LocalPort).Reverse()), - Pid = struc.OwningProcessId - }); + retDict[struc.OwningProcessId].Add( + new NetworkConnection() + { + Protocol = NetworkProtocol.Udp6, + Local = new IPEndPoint(new IPAddress(struc.LocalAddress, struc.LocalScopeId), ((ushort)struc.LocalPort).Reverse()), + Pid = struc.OwningProcessId + }); } } } @@ -494,6 +507,7 @@ public static Dictionary> GetNetworkConnections() public static SystemPagefile[] GetPagefiles() { int retLength; + List pagefiles = new List(); using (MemoryAlloc data = new MemoryAlloc(0x200)) { @@ -513,22 +527,23 @@ public static SystemPagefile[] GetPagefiles() throw new OutOfMemoryException(); } - status.ThrowIf(); + if (status >= NtStatus.Error) + Win32.Throw(status); - List pagefiles = new List(2); + pagefiles = new List(2); int i = 0; SystemPagefileInformation currentPagefile; do { - currentPagefile = data.ReadStruct(i, SystemPagefileInformation.SizeOf, 0); + currentPagefile = data.ReadStruct(i, 0); pagefiles.Add(new SystemPagefile( currentPagefile.TotalSize, currentPagefile.TotalInUse, currentPagefile.PeakUsage, - FileUtils.GetFileName(currentPagefile.PageFileName.Text) + FileUtils.GetFileName(currentPagefile.PageFileName.Read()) )); i += currentPagefile.NextEntryOffset; @@ -555,6 +570,7 @@ public static Dictionary GetProcesses() public static Dictionary GetProcesses(bool getThreads) { int retLength; + Dictionary returnProcesses; if (_processesBuffer == null) _processesBuffer = new MemoryAlloc(0x10000); @@ -573,7 +589,7 @@ public static Dictionary GetProcesses(bool getThreads) data, data.Size, out retLength - )).IsError()) + )) >= NtStatus.Error) { if (attempts > 3) Win32.Throw(status); @@ -586,7 +602,7 @@ out retLength } } - Dictionary returnProcesses = new Dictionary(32); + returnProcesses = new Dictionary(32); // 32 processes on a computer? int i = 0; SystemProcess currentProcess = new SystemProcess(); @@ -599,15 +615,17 @@ out retLength currentProcess.Process = *(SystemProcessInformation*)((byte*)data.Memory + i); } - currentProcess.Name = currentProcess.Process.ImageName.Text; + currentProcess.Name = currentProcess.Process.ImageName.Read(); - if (getThreads && currentProcess.Process.ProcessId != 0) + if (getThreads && + currentProcess.Process.ProcessId != 0) { currentProcess.Threads = new Dictionary(); for (int j = 0; j < currentProcess.Process.NumberOfThreads; j++) { - var thread = data.ReadStruct(i + SystemProcessInformation.SizeOf, SystemThreadInformation.SizeOf, j); + var thread = data.ReadStruct(i + + Marshal.SizeOf(typeof(SystemProcessInformation)), j); currentProcess.Threads.Add(thread.ClientId.ThreadId, thread); } @@ -642,12 +660,8 @@ public static Dictionary GetProcessThreads(int pid { attempts++; - if ((status = Win32.NtQuerySystemInformation( - SystemInformationClass.SystemProcessInformation, - data.Memory, - data.Size, - out retLength) - ).IsError()) + if ((status = Win32.NtQuerySystemInformation(SystemInformationClass.SystemProcessInformation, data.Memory, + data.Size, out retLength)) >= NtStatus.Error) { if (attempts > 3) Win32.Throw(status); @@ -673,11 +687,12 @@ public static Dictionary GetProcessThreads(int pid if (process.ProcessId == pid) { - Dictionary threads = new Dictionary(); + var threads = new Dictionary(); for (int j = 0; j < process.NumberOfThreads; j++) { - SystemThreadInformation thread = data.ReadStruct(i + SystemProcessInformation.SizeOf, SystemThreadInformation.SizeOf, j); + var thread = data.ReadStruct(i + + Marshal.SizeOf(typeof(SystemProcessInformation)), j); if (pid != 0) { @@ -708,7 +723,8 @@ public static Dictionary GetProcessThreads(int pid /// A dictionary, indexed by service name. public static Dictionary GetServices() { - using (ServiceManagerHandle manager = new ServiceManagerHandle(ScManagerAccess.EnumerateService)) + using (ServiceManagerHandle manager = + new ServiceManagerHandle(ScManagerAccess.EnumerateService)) { int requiredSize; int servicesReturned; @@ -720,21 +736,25 @@ public static Dictionary GetServices() MemoryAlloc data = _servicesBuffer; if (!Win32.EnumServicesStatusEx(manager, IntPtr.Zero, ServiceQueryType.Win32 | ServiceQueryType.Driver, - ServiceQueryState.All, data, data.Size, out requiredSize, out servicesReturned, ref resume, null)) + ServiceQueryState.All, data, + data.Size, out requiredSize, out servicesReturned, + ref resume, null)) { // resize buffer data.ResizeNew(requiredSize); if (!Win32.EnumServicesStatusEx(manager, IntPtr.Zero, ServiceQueryType.Win32 | ServiceQueryType.Driver, - ServiceQueryState.All, data, data.Size, out requiredSize, out servicesReturned, ref resume, null)) + ServiceQueryState.All, data, + data.Size, out requiredSize, out servicesReturned, + ref resume, null)) Win32.Throw(); } - Dictionary dictionary = new Dictionary(servicesReturned); + var dictionary = new Dictionary(servicesReturned); for (int i = 0; i < servicesReturned; i++) { - EnumServiceStatusProcess service = data.ReadStruct(0, EnumServiceStatusProcess.SizeOf, i); + var service = data.ReadStruct(i); dictionary.Add(service.ServiceName, service); } @@ -750,12 +770,15 @@ public static Dictionary GetServices() public static long GetTickCount() { // Read the tick count multiplier. - int tickCountMultiplier = Marshal.ReadInt32(Win32.UserSharedData.Increment(KUserSharedData.TickCountMultiplierOffset)); + int tickCountMultiplier = Marshal.ReadInt32(Win32.UserSharedData.Increment( + KUserSharedData.TickCountMultiplierOffset)); // Read the tick count. - var tickCount = QueryKSystemTime(Win32.UserSharedData.Increment(KUserSharedData.TickCountOffset)); + var tickCount = QueryKSystemTime(Win32.UserSharedData.Increment( + KUserSharedData.TickCountOffset)); - return ((tickCount.LowPart * tickCountMultiplier) >> 24) + (((long)tickCount.HighPart * tickCountMultiplier) << 8); + return (((long)tickCount.LowPart * tickCountMultiplier) >> (int)24) + + (((long)tickCount.HighPart * tickCountMultiplier) << (int)8); } /// @@ -764,15 +787,19 @@ public static long GetTickCount() /// A time of day structure. public static SystemTimeOfDayInformation GetTimeOfDay() { + NtStatus status; SystemTimeOfDayInformation timeOfDay; int retLength; - Win32.NtQuerySystemInformation( + status = Win32.NtQuerySystemInformation( SystemInformationClass.SystemTimeOfDayInformation, out timeOfDay, - SystemTimeOfDayInformation.SizeOf, + Marshal.SizeOf(typeof(SystemTimeOfDayInformation)), out retLength - ).ThrowIf(); + ); + + if (status >= NtStatus.Error) + Win32.Throw(status); return timeOfDay; } @@ -794,11 +821,15 @@ public static TimeSpan GetUptime() /// The service name of the driver. public static void LoadDriver(string serviceName) { - UnicodeString str = new UnicodeString("\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\" + serviceName); + var str = new UnicodeString( + "\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\" + serviceName); try { - Win32.NtLoadDriver(ref str).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtLoadDriver(ref str)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -811,9 +842,12 @@ public static void LoadDriver(string serviceName) /// /// A pointer to a KSYSTEM_TIME value. /// A 64-bit time value. - private unsafe static LargeInteger QueryKSystemTime(IntPtr time) + private static LargeInteger QueryKSystemTime(IntPtr time) { - return QueryKSystemTime((KSystemTime*)time); + unsafe + { + return QueryKSystemTime((KSystemTime*)time); + } } /// @@ -860,11 +894,15 @@ private unsafe static LargeInteger QueryKSystemTime(KSystemTime* time) /// The service name of the driver. public static void UnloadDriver(string serviceName) { - UnicodeString str = new UnicodeString("\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\" + serviceName); + var str = new UnicodeString( + "\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\" + serviceName); try { - Win32.NtUnloadDriver(ref str).ThrowIf(); + NtStatus status; + + if ((status = Win32.NtUnloadDriver(ref str)) >= NtStatus.Error) + Win32.Throw(status); } finally { @@ -899,7 +937,7 @@ public struct NetworkConnection public void CloseTcpConnection() { - MibTcpRow row = new MibTcpRow + MibTcpRow row = new MibTcpRow() { State = MibTcpState.DeleteTcb, LocalAddress = (uint)this.Local.Address.Address, @@ -907,7 +945,6 @@ public void CloseTcpConnection() RemoteAddress = this.Remote != null ? (uint)this.Remote.Address.Address : 0, RemotePort = this.Remote != null ? ((ushort)this.Remote.Port).Reverse() : 0 }; - int result = Win32.SetTcpEntry(ref row); if (result != 0) diff --git a/1.x/trunk/ProcessHacker.Native/WindowsException.cs b/1.x/trunk/ProcessHacker.Native/WindowsException.cs index 0c196795e..74dd7cfcd 100644 --- a/1.x/trunk/ProcessHacker.Native/WindowsException.cs +++ b/1.x/trunk/ProcessHacker.Native/WindowsException.cs @@ -35,10 +35,10 @@ namespace ProcessHacker.Native /// public class WindowsException : Exception { - private readonly bool _isNtStatus; - private readonly Win32Error _errorCode = 0; - private readonly NtStatus _status; - private string _message; + private bool _isNtStatus = false; + private Win32Error _errorCode = 0; + private NtStatus _status; + private string _message = null; /// /// Creates an exception with no error. @@ -99,7 +99,7 @@ public override string Message { // No locking, for performance reasons. Getting the // message doesn't have any side-effects anyway. - if (string.IsNullOrEmpty(_message)) + if (_message == null) { // We prefer native status messages because they are usually // more detailed. However, for some status values we do @@ -113,7 +113,7 @@ public override string Message { string message = _status.GetMessage(); - if (string.IsNullOrEmpty(message)) + if (message == null) message = "Could not retrieve the error message (0x" + ((int)_status).ToString("x") + ")."; _message = message; diff --git a/1.x/trunk/ProcessHacker.Native/app.config b/1.x/trunk/ProcessHacker.Native/app.config index b4ca687d2..89dc7d426 100644 --- a/1.x/trunk/ProcessHacker.Native/app.config +++ b/1.x/trunk/ProcessHacker.Native/app.config @@ -1,3 +1,3 @@ - + diff --git a/1.x/trunk/ProcessHacker.sln b/1.x/trunk/ProcessHacker.sln index b7f653106..fc6e4066e 100644 --- a/1.x/trunk/ProcessHacker.sln +++ b/1.x/trunk/ProcessHacker.sln @@ -1,12 +1,14 @@  -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessHacker", "ProcessHacker\ProcessHacker.csproj", "{EEEA1778-1702-4964-8793-A98FE37E4D2B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessHacker.Common", "ProcessHacker.Common\ProcessHacker.Common.csproj", "{8E10F5E8-D4FA-4980-BB23-2EDD134AC15E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessHacker.Native", "ProcessHacker.Native\ProcessHacker.Native.csproj", "{8A448157-E1A7-4DDF-954E-287F1117832B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aga.Controls", "TreeViewAdv\Aga.Controls.csproj", "{E73BB233-D88B-44A7-A98F-D71EE158381D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -25,6 +27,10 @@ Global {8A448157-E1A7-4DDF-954E-287F1117832B}.Debug|Any CPU.Build.0 = Debug|Any CPU {8A448157-E1A7-4DDF-954E-287F1117832B}.Release|Any CPU.ActiveCfg = Release|Any CPU {8A448157-E1A7-4DDF-954E-287F1117832B}.Release|Any CPU.Build.0 = Release|Any CPU + {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E73BB233-D88B-44A7-A98F-D71EE158381D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E73BB233-D88B-44A7-A98F-D71EE158381D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/1.x/trunk/ProcessHacker/Common/CircularBuffer.cs b/1.x/trunk/ProcessHacker/Common/CircularBuffer.cs deleted file mode 100644 index 06e37d491..000000000 --- a/1.x/trunk/ProcessHacker/Common/CircularBuffer.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections; - -namespace ProcessHacker.Common -{ - /// - /// A Less than perfect CircularList. - /// - /// - public class CircularList : IList - { - private List data = new List(); - public int Max; - - // TODO: rewrite entire class at some stage. - public CircularList(int max) - { - this.Max = max; - } - - public int Count { get { return data.Count; } } - - public T this[int index] - { - get { return this.data[index]; } - set { this.data[index] = value; } - } - - public void Add(T item) - { - //Less than perfect. - if (this.data.Count >= this.Max) - { - this.data.RemoveRange(0, this.data.Count - this.Max); - - for (int i = 0; i <= this.data.Count - 2; i++) - { - this.data[i] = this.data[i + 1]; - } - this.data[this.data.Count - 1] = item; - } - else - { - this.data.Add(item); - } - } - - public int IndexOf(T item) - { - throw new NotImplementedException(); - } - - public void Insert(int index, T item) - { - throw new NotImplementedException(); - } - - public void RemoveAt(int index) - { - throw new NotImplementedException(); - } - - public void Clear() - { - data.Clear(); - } - - public bool Contains(T item) - { - return data.Contains(item); - } - - public void CopyTo(T[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - public bool IsReadOnly - { - get { throw new NotImplementedException(); } - } - - public bool Remove(T item) - { - return data.Remove(item); - } - - public IEnumerator GetEnumerator() - { - return data.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return data.GetEnumerator(); - } - } -} diff --git a/1.x/trunk/ProcessHacker/Common/Extensions.cs b/1.x/trunk/ProcessHacker/Common/Extensions.cs index caa1ee85c..7368f0440 100644 --- a/1.x/trunk/ProcessHacker/Common/Extensions.cs +++ b/1.x/trunk/ProcessHacker/Common/Extensions.cs @@ -22,20 +22,9 @@ using System; using System.Collections.Generic; -using System.Drawing; -using System.Windows.Forms; -using ProcessHacker.Native.Api; namespace ProcessHacker.Common { - public static class StringExtensions - { - public static bool Contains(this string source, string toCheck, StringComparison comp) - { - return source.IndexOf(toCheck, comp) >= 0; - } - } - public static class LongExtensions { /// @@ -95,141 +84,4 @@ public static IList Take(this IList source, int count) return newList; } } - - /// - /// MeasureText cache. - /// Cache the calls to MeasureText as this only needs to be called once. - /// - /// Invalidate the cache if UI changes (i.e. DPI) - public static class TextSizeCache - { - private static readonly Dictionary SizeCache = new Dictionary(); - - public static Size GetCachedSize(this Graphics device, string str, Font font) - { - if (SizeCache.ContainsKey(str)) - { - return SizeCache[str]; - } - - // we only need to Measure the string once, so we cache it. - Size strSize = TextRenderer.MeasureText(device, str, font); - - SizeCache.Add(str, strSize); - - return strSize; - } - - public static void InvalidateCache() - { - SizeCache.Clear(); - } - } - - public static class ControlExtensions - { - /// - /// An application sends the WM_CHANGEUISTATE message to indicate that the UI state should be changed. - /// - /// Value: 0x0127 - public const int WM_CHANGEUISTATE = 295; - - /// - /// An application sends the WM_UPDATEUISTATE message to change the UI state for the specified window and all its child windows. - /// - /// Value: 0x0128 - public const int WM_UPDATEUISTATE = 296; - - public enum UIS_Flags - { - /// - /// The UI state flags specified by the high-order word should be set. - /// - UIS_SET = 1, - - /// - /// The UI state flags specified by the high-order word should be cleared. - /// - UIS_CLEAR = 2, - - /// - /// The UI state flags specified by the high-order word should be changed based on the last input event. For more information, see Remarks. - /// - UIS_INITIALIZE = 3 - } - - [Flags] - public enum UISF_Flags - { - UISF_HIDEFOCUS = 0x1, - UISF_HIDEACCEL = 0x2, - UISF_ACTIVE = 0x4 - } - - public static void MakeAcceleratorsVisible(this Control c) - { - Win32.SendMessage(c.Handle, (WindowMessage)WM_CHANGEUISTATE, (IntPtr)MakeLong((int)UIS_Flags.UIS_CLEAR, (int)UISF_Flags.UISF_HIDEACCEL), IntPtr.Zero); - } - - public static void MakeAcceleratorsInvisible(this Control c) - { - Win32.SendMessage(c.Handle, (WindowMessage)WM_CHANGEUISTATE, (IntPtr)MakeLong((int)UIS_Flags.UIS_SET, (int)UISF_Flags.UISF_HIDEACCEL), IntPtr.Zero); - } - - public static void MakeFocusVisible(this Control c) - { - Win32.SendMessage(c.Handle, (WindowMessage)WM_CHANGEUISTATE, (IntPtr)MakeLong((int)UIS_Flags.UIS_CLEAR, (int)UISF_Flags.UISF_HIDEFOCUS), IntPtr.Zero); - } - - public static void MakeFocusInvisible(this Control c) - { - Win32.SendMessage(c.Handle, (WindowMessage)WM_CHANGEUISTATE, (IntPtr)MakeLong((int)UIS_Flags.UIS_SET, (int)UISF_Flags.UISF_HIDEFOCUS), IntPtr.Zero); - } - - public static void MakeActiveVisible(this Control c) - { - Win32.SendMessage(c.Handle, (WindowMessage)WM_CHANGEUISTATE, (IntPtr)MakeLong((int)UIS_Flags.UIS_SET, (int)UISF_Flags.UISF_ACTIVE), IntPtr.Zero); - } - - public static void MakeActiveInvisible(this Control c) - { - Win32.SendMessage(c.Handle, (WindowMessage)WM_CHANGEUISTATE, (IntPtr)MakeLong((int)UIS_Flags.UIS_CLEAR, (int)UISF_Flags.UISF_ACTIVE), IntPtr.Zero); - } - - private static int MakeLong(int loWord, int hiWord) - { - return (hiWord << 16) | (loWord & 0xffff); - } - - public static int LoWord(int number) - { - return number & 0xffff; - } - - //private int WM_CHANGEUISTATE = 0x127; - - //private enum WM_CHANGEUISTATE_low : short - //{ - // UIS_CLEAR = 2, - // UIS_INITIALIZE = 3, - // UIS_SET = 1 - //} - - //private enum WM_CHANGEUISTATE_high : short - //{ - // UISF_HIDEACCEL = 0x2, - // UISF_HIDEFOCUS = 0x1, - // UISF_ACTIVE = 4 - //} - - //private enum WM_CHANGEUISTATE : int - //{ - // UIS_CLEAR = WM_CHANGEUISTATE_low.UIS_CLEAR, - // UIS_INITIALIZE = WM_CHANGEUISTATE_low.UIS_INITIALIZE, - // UIS_SET = WM_CHANGEUISTATE_low.UIS_SET, - // UISF_HIDEACCEL = Convert.ToInt32(WM_CHANGEUISTATE_high.UISF_HIDEACCEL) << 16, - // UISF_HIDEFOCUS = Convert.ToInt32(WM_CHANGEUISTATE_high.UISF_HIDEFOCUS) << 16, - // UISF_ACTIVE = Convert.ToInt32(WM_CHANGEUISTATE_high.UISF_ACTIVE) << 16 - //} - } } diff --git a/1.x/trunk/ProcessHacker/Common/PhUtils.cs b/1.x/trunk/ProcessHacker/Common/PhUtils.cs index 8cf46b47c..f645511b2 100644 --- a/1.x/trunk/ProcessHacker/Common/PhUtils.cs +++ b/1.x/trunk/ProcessHacker/Common/PhUtils.cs @@ -31,14 +31,13 @@ using ProcessHacker.Native; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; -using ProcessHacker.Native.Security; using ProcessHacker.UI; namespace ProcessHacker.Common { public static class PhUtils { - public static readonly string[] DangerousNames = + public static string[] DangerousNames = { "csrss.exe", "dwm.exe", "logonui.exe", "lsass.exe", "lsm.exe", "services.exe", "smss.exe", "wininit.exe", "winlogon.exe" @@ -60,27 +59,28 @@ public static void AddShortcuts(this ListView lv) /// A virtual item handler, if any. public static void AddShortcuts(this ListView lv, RetrieveVirtualItemEventHandler retrieveVirtualItem) { - lv.KeyDown += (sender, e) => - { - if (e.Control && e.KeyCode == Keys.A) + lv.KeyDown += + (sender, e) => { - if (retrieveVirtualItem != null) + if (e.Control && e.KeyCode == Keys.A) { - for (int i = 0; i < lv.VirtualListSize; i++) - if (!lv.SelectedIndices.Contains(i)) - lv.SelectedIndices.Add(i); + if (retrieveVirtualItem != null) + { + for (int i = 0; i < lv.VirtualListSize; i++) + if (!lv.SelectedIndices.Contains(i)) + lv.SelectedIndices.Add(i); + } + else + { + lv.Items.SelectAll(); + } } - else + + if (e.Control && e.KeyCode == Keys.C) { - lv.Items.SelectAll(); + GenericViewMenu.ListViewCopy(lv, -1, retrieveVirtualItem); } - } - - if (e.Control && e.KeyCode == Keys.C) - { - GenericViewMenu.ListViewCopy(lv, -1, retrieveVirtualItem); - } - }; + }; } /// @@ -95,11 +95,13 @@ public static bool IsDangerousPid(int pid) try { - using (ProcessHandle phandle = new ProcessHandle(pid, OSVersion.MinProcessQueryInfoAccess)) + using (var phandle = new ProcessHandle(pid, OSVersion.MinProcessQueryInfoAccess)) { foreach (string s in DangerousNames) { - if ((Environment.SystemDirectory + "\\" + s).Equals(FileUtils.GetFileName(FileUtils.GetFileName(phandle.ImageFileName)), StringComparison.OrdinalIgnoreCase)) + if ((Environment.SystemDirectory + "\\" + s).Equals( + FileUtils.GetFileName(FileUtils.GetFileName(phandle.GetImageFileName())), + StringComparison.OrdinalIgnoreCase)) { return true; } @@ -123,9 +125,9 @@ public static bool IsDangerousPid(int pid) private static string FormatException(string operation, Exception ex) { if (!string.IsNullOrEmpty(operation)) - return operation + ": " + ex.Message + (ex.InnerException != null ? " (" + ex.InnerException.Message + ")" : string.Empty); - - return ex.Message + (ex.InnerException != null ? " (" + ex.InnerException.Message + ")" : string.Empty); + return operation + ": " + ex.Message + (ex.InnerException != null ? " (" + ex.InnerException.Message + ")" : ""); + else + return ex.Message + (ex.InnerException != null ? " (" + ex.InnerException.Message + ")" : ""); } public static string FormatFileInfo( @@ -183,17 +185,18 @@ public static string FormatPriorityClass(ProcessPriorityClass priorityClass) return "Normal"; case ProcessPriorityClass.RealTime: return "Realtime"; + case ProcessPriorityClass.Unknown: default: - return string.Empty; + return ""; } } public static string GetBestUserName(string userName, bool includeDomain) { - if (string.IsNullOrEmpty(userName)) - return string.Empty; + if (userName == null) + return ""; - if (!userName.Contains("\\", StringComparison.OrdinalIgnoreCase)) + if (!userName.Contains("\\")) return userName; string[] split = userName.Split(new char[] { '\\' }, 2); @@ -202,8 +205,8 @@ public static string GetBestUserName(string userName, bool includeDomain) if (includeDomain) return domain + "\\" + user; - - return user; + else + return user; } /// @@ -219,8 +222,8 @@ public static Color GetForeColor(Color backColor) { if (backColor.GetBrightness() > 0.4) return Color.Black; - - return Color.White; + else + return Color.White; } public static IWin32Window GetForegroundWindow() @@ -228,49 +231,40 @@ public static IWin32Window GetForegroundWindow() var window = WindowHandle.GetForegroundWindow(); // Make sure the foreground window belongs to us. - if (window.ClientId.ProcessId == ProcessHandle.CurrentId) + if (window.GetClientId().ProcessId == ProcessHandle.GetCurrentId()) return window; - - return new WindowFromHandle(Program.HackerWindowHandle); + else + return new WindowFromHandle(Program.HackerWindowHandle); } public static string GetIntegrity(this TokenHandle tokenHandle, out int integrityLevel) { - var groups = tokenHandle.Groups; + var groups = tokenHandle.GetGroups(); string integrity = null; integrityLevel = 0; - foreach (Sid t in groups) + for (int i = 0; i < groups.Length; i++) { - if ((t.Attributes & SidAttributes.IntegrityEnabled) != 0) + if ((groups[i].Attributes & SidAttributes.IntegrityEnabled) != 0) { - integrity = t.GetFullName(false).Replace(" Mandatory Level", string.Empty); - - switch (integrity) - { - case "Untrusted": - integrityLevel = 0; - break; - case "Low": - integrityLevel = 1; - break; - case "Medium": - integrityLevel = 2; - break; - case "High": - integrityLevel = 3; - break; - case "System": - integrityLevel = 4; - break; - case "Installer": - integrityLevel = 5; - break; - } + integrity = groups[i].GetFullName(false).Replace(" Mandatory Level", ""); + + if (integrity == "Untrusted") + integrityLevel = 0; + else if (integrity == "Low") + integrityLevel = 1; + else if (integrity == "Medium") + integrityLevel = 2; + else if (integrity == "High") + integrityLevel = 3; + else if (integrity == "System") + integrityLevel = 4; + else if (integrity == "Installer") + integrityLevel = 5; } - t.Dispose(); + groups[i].Dispose(); } return integrity; @@ -350,7 +344,7 @@ public static bool IsInternetConnected() { try { - IPHostEntry entry = Dns.GetHostEntry("www.msftncsi.com"); + System.Net.IPHostEntry entry = System.Net.Dns.GetHostEntry("www.msftncsi.com"); return true; //http://www.msftncsi.com/ncsi.txt @@ -399,13 +393,13 @@ public static void OpenKeyInRegedit(IWin32Window window, string keyName) string lastKey = keyName; // Expand the abbreviations. - if (lastKey.StartsWith("hkcu", StringComparison.OrdinalIgnoreCase)) + if (lastKey.ToLowerInvariant().StartsWith("hkcu")) lastKey = "HKEY_CURRENT_USER" + lastKey.Substring(4); - else if (lastKey.StartsWith("hku", StringComparison.OrdinalIgnoreCase)) + else if (lastKey.ToLowerInvariant().StartsWith("hku")) lastKey = "HKEY_USERS" + lastKey.Substring(3); - else if (lastKey.StartsWith("hkcr", StringComparison.OrdinalIgnoreCase)) + else if (lastKey.ToLowerInvariant().StartsWith("hkcr")) lastKey = "HKEY_CLASSES_ROOT" + lastKey.Substring(4); - else if (lastKey.StartsWith("hklm", StringComparison.OrdinalIgnoreCase)) + else if (lastKey.ToLowerInvariant().StartsWith("hklm")) lastKey = "HKEY_LOCAL_MACHINE" + lastKey.Substring(4); // Set the last opened key in regedit config. Note that if we are on @@ -431,7 +425,7 @@ public static void OpenKeyInRegedit(IWin32Window window, string keyName) { Program.StartProgramAdmin( Environment.SystemDirectory + "\\..\\regedit.exe", - string.Empty, + "", null, ShowWindowType.Normal, window != null ? window.Handle : IntPtr.Zero @@ -459,7 +453,21 @@ public static void SelectAll(this IEnumerable nodes) /// Whether the shield icon is visible. public static void SetShieldIcon(this Button button, bool visible) { - Win32.SendMessage(button.Handle, WindowMessage.BcmSetShield, IntPtr.Zero, visible ? (IntPtr)1 : IntPtr.Zero); + Win32.SendMessage(button.Handle, WindowMessage.BcmSetShield, 0, visible ? 1 : 0); + } + + /// + /// Sets the theme of a control. + /// + /// The control to modify. + /// A name of a theme. + public static void SetTheme(this Control control, string theme) + { + // Don't set on XP, doesn't look better than without SetWindowTheme. + if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) + { + Win32.SetWindowTheme(control.Handle, theme, null); + } } /// @@ -500,13 +508,11 @@ public static bool ShowConfirmMessage(string verb, string obj, string message, b if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog - { - WindowTitle = "Process Hacker", - MainIcon = warning ? TaskDialogIcon.Warning : TaskDialogIcon.None, - MainInstruction = "Do you want to " + action + "?", - PositionRelativeToWindow = true - }; + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainIcon = warning ? TaskDialogIcon.Warning : TaskDialogIcon.None; + td.MainInstruction = "Do you want to " + action + "?"; if (!string.IsNullOrEmpty(message)) td.Content = message + " Are you sure you want to continue?"; @@ -518,15 +524,17 @@ public static bool ShowConfirmMessage(string verb, string obj, string message, b }; td.DefaultButton = (int)DialogResult.No; - return td.Show(GetForegroundWindow()) == (int)DialogResult.Yes; + return td.Show(PhUtils.GetForegroundWindow()) == (int)DialogResult.Yes; + } + else + { + return MessageBox.Show( + message + " Are you sure you want to " + action + "?", + "Process Hacker", + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning + ) == DialogResult.Yes; } - - return MessageBox.Show( - message + " Are you sure you want to " + action + "?", - "Process Hacker", - MessageBoxButtons.YesNo, - MessageBoxIcon.Warning - ) == DialogResult.Yes; } /// @@ -573,7 +581,7 @@ public static void ShowException(string operation, Exception ex) #else MessageBox.Show( PhUtils.GetForegroundWindow(), - operation + "\n\n" + ex, + operation + "\n\n" + ex.ToString(), "Process Hacker", MessageBoxButtons.OK, MessageBoxIcon.Error diff --git a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DataMap.cs b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DataMap.cs index 46fc12ef7..f8fbccfcd 100644 --- a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DataMap.cs +++ b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DataMap.cs @@ -249,10 +249,10 @@ public IEnumerator GetEnumerator() #region Enumerator Nested Type internal class Enumerator : IEnumerator, IDisposable { - readonly DataMap _map; + DataMap _map; DataBlock _current; int _index; - readonly int _version; + int _version; internal Enumerator(DataMap map) { diff --git a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/Design/HexFontEditor.cs b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/Design/HexFontEditor.cs index cb4312b0e..e7bba5675 100644 --- a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/Design/HexFontEditor.cs +++ b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/Design/HexFontEditor.cs @@ -13,7 +13,14 @@ internal class HexFontEditor : FontEditor { object value; - /// + /// + /// Initializes an instance of HexFontEditor class. + /// + public HexFontEditor() + { + } + + /// /// Edits the value /// public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) @@ -24,18 +31,16 @@ public override object EditValue(System.ComponentModel.ITypeDescriptorContext co IWindowsFormsEditorService service1 = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); if (service1 != null) { - FontDialog fontDialog = new FontDialog - { - ShowApply = false, - ShowColor = false, - AllowVerticalFonts = false, - AllowScriptChange = false, - FixedPitchOnly = true, - ShowEffects = false, - ShowHelp = false - }; - - Font font = value as Font; + FontDialog fontDialog = new FontDialog(); + fontDialog.ShowApply = false; + fontDialog.ShowColor = false; + fontDialog.AllowVerticalFonts = false; + fontDialog.AllowScriptChange = false; + fontDialog.FixedPitchOnly = true; + fontDialog.ShowEffects = false; + fontDialog.ShowHelp = false; + + Font font = value as Font; if(font != null) { fontDialog.Font = font; @@ -52,11 +57,14 @@ public override object EditValue(System.ComponentModel.ITypeDescriptorContext co value = this.value; this.value = null; return value; + } public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) { return UITypeEditorEditStyle.Modal; } + + } } diff --git a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DynamicByteProvider.cs b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DynamicByteProvider.cs index 3d79b4ce6..7d09177c0 100644 --- a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DynamicByteProvider.cs +++ b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/DynamicByteProvider.cs @@ -14,7 +14,7 @@ public class DynamicByteProvider : IByteProvider /// /// Contains a byte collection. /// - readonly ByteCollection _bytes; + ByteCollection _bytes; /// /// Initializes a new instance of the DynamicByteProvider class. diff --git a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/FileByteProvider.cs b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/FileByteProvider.cs index e59f0aa67..6ae12babc 100644 --- a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/FileByteProvider.cs +++ b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/FileByteProvider.cs @@ -53,7 +53,7 @@ public bool Contains(long index) /// /// Contains all changes /// - readonly WriteCollection _writes = new WriteCollection(); + WriteCollection _writes = new WriteCollection(); /// /// Contains the file name. @@ -66,7 +66,7 @@ public bool Contains(long index) /// /// Read-only access. /// - readonly bool _readOnly; + bool _readOnly; /// /// Initializes a new instance of the FileByteProvider class. diff --git a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/HexBox.cs b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/HexBox.cs index 1f2371657..6aa75f59f 100644 --- a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/HexBox.cs +++ b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/HexBox.cs @@ -1,11 +1,11 @@ using System; using System.Drawing; using System.Windows.Forms; +using System.Runtime.InteropServices; using System.ComponentModel; using System.Security.Permissions; using System.Windows.Forms.VisualStyles; using Be.Windows.Forms.Design; -using ProcessHacker; namespace Be.Windows.Forms { @@ -41,16 +41,12 @@ public BytePositionInfo(long index, int characterPosition) public int CharacterPosition { get { return _characterPosition; } - } - - readonly int _characterPosition; + } int _characterPosition; public long Index { get { return _index; } - } - - readonly long _index; + } long _index; } #endregion @@ -108,7 +104,7 @@ interface IKeyInterpreter /// class EmptyKeyInterpreter : IKeyInterpreter { - readonly HexBox _hexBox; + HexBox _hexBox; public EmptyKeyInterpreter(HexBox hexBox) { @@ -145,12 +141,12 @@ class KeyInterpreter : IKeyInterpreter /// /// Contains the parent HexBox control /// - protected readonly HexBox _hexBox; + protected HexBox _hexBox; /// /// Contains True, if shift key is down /// - bool _shiftDown; + protected bool _shiftDown; /// /// Contains True, if mouse is down /// @@ -824,9 +820,11 @@ protected bool RaiseKeyPress(char keyChar) #region PreProcessWmKeyUp methods public virtual bool PreProcessWmKeyUp(ref Message m) { + System.Diagnostics.Debug.WriteLine("PreProcessWmKeyUp(ref Message m)", "KeyInterpreter"); + Keys vc = (Keys)m.WParam.ToInt32(); - Keys keyData = vc | ModifierKeys; + Keys keyData = vc | Control.ModifierKeys; switch(keyData) { @@ -856,7 +854,7 @@ protected virtual bool PreProcessWmKeyUp_Insert(ref Message m) return true; } - private bool RaiseKeyUp(Keys keyData) + protected bool RaiseKeyUp(Keys keyData) { KeyEventArgs e = new KeyEventArgs(keyData); _hexBox.OnKeyUp(e); @@ -974,12 +972,13 @@ protected virtual bool PerformPosMoveLeftByte() protected virtual bool PerformPosMoveRightByte() { long pos = _hexBox._bytePos; + int cp = _hexBox._byteCharacterPos; - if(pos == _hexBox._byteProvider.Length) + if(pos == _hexBox._byteProvider.Length) return true; pos = Math.Min(_hexBox._byteProvider.Length, pos+1); - int cp = 0; + cp = 0; _hexBox.SetPosition(pos, cp); @@ -1159,7 +1158,7 @@ protected override BytePositionInfo GetBytePositionInfo(Point p) /// /// Contains string format information for text drawing /// - readonly StringFormat _stringFormat; + StringFormat _stringFormat; /// /// Contains the width and height of a single char /// @@ -1193,11 +1192,11 @@ protected override BytePositionInfo GetBytePositionInfo(Point p) /// /// Contains a vertical scroll /// - readonly VScrollBar _vScrollBar; + VScrollBar _vScrollBar; /// /// Contains a timer for thumbtrack scrolling /// - readonly Timer _thumbTrackTimer = new Timer(); + Timer _thumbTrackTimer = new Timer(); /// /// Contains the thumbtrack scrolling position /// @@ -1383,22 +1382,22 @@ protected override BytePositionInfo GetBytePositionInfo(Point p) public HexBox() { this._vScrollBar = new VScrollBar(); - this._vScrollBar.Scroll += this._vScrollBar_Scroll; + this._vScrollBar.Scroll += new ScrollEventHandler(_vScrollBar_Scroll); - this.BackColor = Color.White; - this.Font = Settings.Instance.Font; + BackColor = Color.White; + Font = new Font("Courier New", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); + _stringFormat = new StringFormat(StringFormat.GenericTypographic); + _stringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces; - this._stringFormat = new StringFormat(StringFormat.GenericTypographic) - { - FormatFlags = StringFormatFlags.MeasureTrailingSpaces - }; - - this.ActivateEmptyKeyInterpreter(); - - this.SetStyle(ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); + ActivateEmptyKeyInterpreter(); + + SetStyle(ControlStyles.UserPaint, true); + SetStyle(ControlStyles.DoubleBuffer, true); + SetStyle(ControlStyles.AllPaintingInWmPaint, true); + SetStyle(ControlStyles.ResizeRedraw, true); - _thumbTrackTimer.Interval = 1000; - _thumbTrackTimer.Tick += this.PerformScrollThumbTrack; + _thumbTrackTimer.Interval = 50; + _thumbTrackTimer.Tick += new EventHandler(PerformScrollThumbTrack); } #endregion @@ -1434,7 +1433,7 @@ void _vScrollBar_Scroll(object sender, ScrollEventArgs e) _thumbTrackTimer.Enabled = false; // perform scroll immediately only if last refresh is very old - int currentThumbTrack = Environment.TickCount; + int currentThumbTrack = System.Environment.TickCount; if (currentThumbTrack - _lastThumbtrack > THUMPTRACKDELAY) { PerformScrollThumbTrack(null, null); @@ -1448,6 +1447,8 @@ void _vScrollBar_Scroll(object sender, ScrollEventArgs e) break; case ScrollEventType.First: break; + default: + break; } e.NewValue = ToScrollPos(_scrollVpos); @@ -1470,7 +1471,7 @@ void UpdateScrollSize() // calc scroll bar info if(VScrollBarVisible && _byteProvider != null && _byteProvider.Length > 0 && _iHexMaxHBytes != 0) { - long scrollmax = (long)Math.Ceiling(this._byteProvider.Length / (double)_iHexMaxHBytes - this._iHexMaxVBytes); + long scrollmax = (long)Math.Ceiling((double)_byteProvider.Length / (double)_iHexMaxHBytes - (double)_iHexMaxVBytes); scrollmax = Math.Max(0, scrollmax); long scrollpos = _startByte / _iHexMaxHBytes; @@ -1533,11 +1534,14 @@ long FromScrollPos(int value) int max = 65535; if(_scrollVmax < max) { - return value; + return (long)value; + } + else + { + double valperc = (double)value / (double)max * (double)100; + long res = (int)Math.Floor((double)_scrollVmax / (double)100 * valperc); + return res; } - double valperc = (double)value / (double)max * (double)100; - long res = (int)Math.Floor((double)this._scrollVmax / (double)100 * valperc); - return res; } int ToScrollMax(long value) @@ -1545,7 +1549,8 @@ int ToScrollMax(long value) long max = 65535; if(value > max) return (int)max; - return (int)value; + else + return (int)value; } void PerformScrollToLine(long pos) @@ -1636,12 +1641,12 @@ public void ScrollByteIntoView(long index) if(index < _startByte) { - long line = (long)Math.Floor(index / (double)_iHexMaxHBytes); + long line = (long)Math.Floor((double)index / (double)_iHexMaxHBytes); PerformScrollThumpPosition(line); } else if(index > _endByte) { - long line = (long)Math.Floor(index / (double)_iHexMaxHBytes); + long line = (long)Math.Floor((double)index / (double)_iHexMaxHBytes); line -= _iHexMaxVBytes-1; PerformScrollThumpPosition(line); } @@ -1791,8 +1796,8 @@ void SetCaretPosition(Point p) if(_byteProvider == null || _keyInterpreter == null) return; - long pos; - int cp; + long pos = _bytePos; + int cp = _byteCharacterPos; if(_recHex.Contains(p)) { @@ -2057,16 +2062,16 @@ public void Paste() if(_selectionLength > 0) _byteProvider.DeleteBytes(_bytePos, _selectionLength); - byte[] buffer; + byte[] buffer = null; IDataObject da = Clipboard.GetDataObject(); - if(da != null && da.GetDataPresent("BinaryData")) + if(da.GetDataPresent("BinaryData")) { System.IO.MemoryStream ms = (System.IO.MemoryStream)da.GetData("BinaryData"); buffer = new byte[ms.Length]; ms.Read(buffer, 0, buffer.Length); } - else if(da != null && da.GetDataPresent(typeof(string))) + else if(da.GetDataPresent(typeof(string))) { string sBuffer = (string)da.GetData(typeof(string)); buffer = System.Text.Encoding.ASCII.GetBytes(sBuffer); @@ -2102,9 +2107,10 @@ public bool CanPaste() IDataObject da = Clipboard.GetDataObject(); if(da.GetDataPresent("BinaryData")) return true; - if(da.GetDataPresent(typeof(string))) - return true; - return false; + else if(da.GetDataPresent(typeof(string))) + return true; + else + return false; } #endregion @@ -2405,7 +2411,7 @@ void PaintCurrentBytesSign(Graphics g) Rectangle betweenLines = new Rectangle( _recStringView.X, (int)(startSelPointF.Y+_charSize.Height), - this._recStringView.Width, + (int)(_recStringView.Width), (int)(_charSize.Height*(multiLine-1))); if(betweenLines.IntersectsWith(_recStringView)) { @@ -2527,18 +2533,18 @@ void PaintCurrentByteSign(Graphics g, Rectangle rec) Color GetDefaultForeColor() { - if(Enabled) + if(Enabled) return ForeColor; - return Color.Gray; + else + return Color.Gray; } - - void UpdateVisibilityBytes() + void UpdateVisibilityBytes() { if(_byteProvider == null || _byteProvider.Length == 0) return; _startByte = (_scrollVpos+1) * _iHexMaxHBytes - _iHexMaxHBytes; - _endByte = Math.Min(this._byteProvider.Length - 1, this._startByte + this._iHexMaxBytes); + _endByte = (long)Math.Min(_byteProvider.Length - 1, _startByte + _iHexMaxBytes); } #endregion @@ -2847,11 +2853,11 @@ public IByteProvider ByteProvider ActivateKeyInterpreter(); if(_byteProvider != null) - _byteProvider.LengthChanged -= this._byteProvider_LengthChanged; + _byteProvider.LengthChanged -= new EventHandler(_byteProvider_LengthChanged); _byteProvider = value; if(_byteProvider != null) - _byteProvider.LengthChanged += this._byteProvider_LengthChanged; + _byteProvider.LengthChanged += new EventHandler(_byteProvider_LengthChanged); OnByteProviderChanged(EventArgs.Empty); @@ -2967,13 +2973,14 @@ public bool StringViewVisible [DefaultValue(typeof(HexCasing), "Upper"), Category("Hex"), Description("Gets or sets whether the HexBox control displays the hex characters in upper or lower case.")] public HexCasing HexCasing { - get - { - if(_hexStringFormat == "X") + get + { + if(_hexStringFormat == "X") return HexCasing.Upper; - return HexCasing.Lower; + else + return HexCasing.Lower; } - set + set { string format; if(value == HexCasing.Upper) @@ -3181,7 +3188,7 @@ void SetVerticalByteCount(int value) void CheckCurrentLineChanged() { - long currentLine = (long)Math.Floor(this._bytePos / (double)_iHexMaxHBytes) + 1; + long currentLine = (long)Math.Floor((double)_bytePos / (double)_iHexMaxHBytes) + 1; if(_byteProvider == null && _currentLine != 0) { diff --git a/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/HexBox.snk b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/HexBox.snk new file mode 100644 index 000000000..8c596985e Binary files /dev/null and b/1.x/trunk/ProcessHacker/Components/Be.Windows.Forms.HexBox/HexBox.snk differ diff --git a/1.x/trunk/ProcessHacker/Components/ColorModifier.Designer.cs b/1.x/trunk/ProcessHacker/Components/ColorModifier.Designer.cs index 0be86b651..e88d39489 100644 --- a/1.x/trunk/ProcessHacker/Components/ColorModifier.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/ColorModifier.Designer.cs @@ -39,15 +39,14 @@ private void InitializeComponent() this.panelColor.Name = "panelColor"; this.panelColor.Size = new System.Drawing.Size(40, 20); this.panelColor.TabIndex = 0; + this.panelColor.MouseLeave += new System.EventHandler(this.panelColor_MouseLeave); this.panelColor.Click += new System.EventHandler(this.panelColor_Click); this.panelColor.MouseEnter += new System.EventHandler(this.panelColor_MouseEnter); - this.panelColor.MouseLeave += new System.EventHandler(this.panelColor_MouseLeave); // // ColorModifier // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.panelColor); this.Name = "ColorModifier"; this.Size = new System.Drawing.Size(40, 20); diff --git a/1.x/trunk/ProcessHacker/Components/ColorModifier.cs b/1.x/trunk/ProcessHacker/Components/ColorModifier.cs index 4e6927682..ee93afa12 100644 --- a/1.x/trunk/ProcessHacker/Components/ColorModifier.cs +++ b/1.x/trunk/ProcessHacker/Components/ColorModifier.cs @@ -21,7 +21,10 @@ */ using System; +using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; +using System.Text; using System.Windows.Forms; namespace ProcessHacker.Components @@ -39,20 +42,18 @@ public ColorModifier() private void panelColor_Click(object sender, EventArgs e) { - using (ColorDialog cd = new ColorDialog - { - Color = this.panelColor.BackColor, - FullOpen = true - }) + ColorDialog cd = new ColorDialog(); + + cd.Color = panelColor.BackColor; + cd.FullOpen = true; + + if (cd.ShowDialog() == DialogResult.OK) { - if (cd.ShowDialog() == DialogResult.OK) - { - _color = cd.Color; - panelColor.BackColor = cd.Color; + _color = cd.Color; + panelColor.BackColor = cd.Color; - if (this.ColorChanged != null) - this.ColorChanged(this, new EventArgs()); - } + if (this.ColorChanged != null) + this.ColorChanged(this, new EventArgs()); } } diff --git a/1.x/trunk/ProcessHacker/Components/ColorModifier.resx b/1.x/trunk/ProcessHacker/Components/ColorModifier.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/ColorModifier.resx +++ b/1.x/trunk/ProcessHacker/Components/ColorModifier.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/DotNetCounters.Designer.cs b/1.x/trunk/ProcessHacker/Components/DotNetCounters.Designer.cs index 69f9ea0de..5e04438ee 100644 --- a/1.x/trunk/ProcessHacker/Components/DotNetCounters.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/DotNetCounters.Designer.cs @@ -29,12 +29,12 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); - this.listAppDomains = new ProcessHacker.Components.ExtendedListView(); + this.listAppDomains = new System.Windows.Forms.ListView(); this.label2 = new System.Windows.Forms.Label(); this.comboCategories = new System.Windows.Forms.ComboBox(); - this.listValues = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listValues = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnValue = new System.Windows.Forms.ColumnHeader(); this.SuspendLayout(); // // label1 @@ -48,9 +48,8 @@ private void InitializeComponent() // // listAppDomains // - this.listAppDomains.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listAppDomains.DoubleClickChecks = true; + this.listAppDomains.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listAppDomains.FullRowSelect = true; this.listAppDomains.HideSelection = false; this.listAppDomains.Location = new System.Drawing.Point(9, 19); @@ -73,8 +72,8 @@ private void InitializeComponent() // // comboCategories // - this.comboCategories.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.comboCategories.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.comboCategories.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboCategories.FormattingEnabled = true; this.comboCategories.Location = new System.Drawing.Point(72, 105); @@ -85,13 +84,12 @@ private void InitializeComponent() // // listValues // - this.listValues.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listValues.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listValues.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnName, this.columnValue}); - this.listValues.DoubleClickChecks = true; this.listValues.FullRowSelect = true; this.listValues.HideSelection = false; this.listValues.Location = new System.Drawing.Point(9, 132); @@ -116,7 +114,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listValues); this.Controls.Add(this.comboCategories); this.Controls.Add(this.label2); @@ -133,10 +130,10 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Label label1; - private ExtendedListView listAppDomains; + private System.Windows.Forms.ListView listAppDomains; private System.Windows.Forms.Label label2; private System.Windows.Forms.ComboBox comboCategories; - private ExtendedListView listValues; + private System.Windows.Forms.ListView listValues; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnValue; } diff --git a/1.x/trunk/ProcessHacker/Components/DotNetCounters.cs b/1.x/trunk/ProcessHacker/Components/DotNetCounters.cs index ceaa7ef47..18ae62db3 100644 --- a/1.x/trunk/ProcessHacker/Components/DotNetCounters.cs +++ b/1.x/trunk/ProcessHacker/Components/DotNetCounters.cs @@ -32,9 +32,9 @@ namespace ProcessHacker.Components { public partial class DotNetCounters : UserControl { - private readonly int _pid; - private bool _initialized; - private readonly string _name; + private int _pid; + private bool _initialized = false; + private string _name; private string _instanceName; private string _categoryName; private PerformanceCounter[] _counters; @@ -43,6 +43,10 @@ public DotNetCounters(int pid, string name) { InitializeComponent(); + listAppDomains.SetTheme("explorer"); + + listValues.SetDoubleBuffered(true); + listValues.SetTheme("explorer"); listValues.ContextMenu = listValues.GetCopyMenu(); listValues.AddShortcuts(); @@ -121,7 +125,7 @@ public void Initialize() foreach (var category in categories) { - if (category.CategoryName.StartsWith(".NET CLR", StringComparison.OrdinalIgnoreCase)) + if (category.CategoryName.StartsWith(".NET CLR")) names.Add(category.CategoryName); } @@ -157,19 +161,22 @@ private void UpdateCounters() return; } - foreach (PerformanceCounter t in this._counters) + for (int i = 0; i < _counters.Length; i++) { + var counter = _counters[i]; + if ( - (t.CounterType == PerformanceCounterType.NumberOfItems32 || - t.CounterType == PerformanceCounterType.NumberOfItems64 || - t.CounterType == PerformanceCounterType.RawFraction) && - t.CounterName != "Not Displayed" + (counter.CounterType == PerformanceCounterType.NumberOfItems32 || + counter.CounterType == PerformanceCounterType.NumberOfItems64 || + counter.CounterType == PerformanceCounterType.RawFraction) && + counter.CounterName != "Not Displayed" ) { - this.listValues.Items.Add(new ListViewItem(new string[] + listValues.Items.Add(new ListViewItem( + new string[] { - t.CounterName, - string.Empty + _counters[i].CounterName, + "" })); } } diff --git a/1.x/trunk/ProcessHacker/Components/DotNetCounters.resx b/1.x/trunk/ProcessHacker/Components/DotNetCounters.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/DotNetCounters.resx +++ b/1.x/trunk/ProcessHacker/Components/DotNetCounters.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/EventPairProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/EventPairProperties.Designer.cs index 51ccce3c6..b553dbdec 100644 --- a/1.x/trunk/ProcessHacker/Components/EventPairProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/EventPairProperties.Designer.cs @@ -61,7 +61,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.buttonSetLow); this.Controls.Add(this.buttonSetHigh); this.Name = "EventPairProperties"; diff --git a/1.x/trunk/ProcessHacker/Components/EventPairProperties.cs b/1.x/trunk/ProcessHacker/Components/EventPairProperties.cs index e01514a8e..e704736ca 100644 --- a/1.x/trunk/ProcessHacker/Components/EventPairProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/EventPairProperties.cs @@ -7,7 +7,7 @@ namespace ProcessHacker.Components { public partial class EventPairProperties : UserControl { - private readonly EventPairHandle _eventPairHandle; + private EventPairHandle _eventPairHandle; public EventPairProperties(EventPairHandle eventPairHandle) { diff --git a/1.x/trunk/ProcessHacker/Components/EventPairProperties.resx b/1.x/trunk/ProcessHacker/Components/EventPairProperties.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/EventPairProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/EventPairProperties.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/EventProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/EventProperties.Designer.cs index 820b08667..5d06e00bb 100644 --- a/1.x/trunk/ProcessHacker/Components/EventProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/EventProperties.Designer.cs @@ -125,7 +125,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; this.Controls.Add(this.buttonReset); this.Controls.Add(this.buttonPulse); this.Controls.Add(this.buttonSet); diff --git a/1.x/trunk/ProcessHacker/Components/EventProperties.cs b/1.x/trunk/ProcessHacker/Components/EventProperties.cs index 8a3529caa..3b57c78bf 100644 --- a/1.x/trunk/ProcessHacker/Components/EventProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/EventProperties.cs @@ -1,7 +1,6 @@ using System; using System.Windows.Forms; using ProcessHacker.Common; -using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; @@ -9,7 +8,7 @@ namespace ProcessHacker.Components { public partial class EventProperties : UserControl { - private readonly EventHandle _eventHandle; + private EventHandle _eventHandle; public EventProperties(EventHandle eventHandle) { @@ -22,7 +21,7 @@ public EventProperties(EventHandle eventHandle) private void UpdateInfo() { - EventBasicInformation basicInfo = _eventHandle.BasicInformation; + var basicInfo = _eventHandle.GetBasicInformation(); labelType.Text = basicInfo.EventType.ToString(); labelSignaled.Text = (basicInfo.EventState != 0).ToString(); @@ -43,11 +42,11 @@ private void TryExecute(MethodInvoker action) private void UpgradeExecute(MethodInvoker action) { this.TryExecute(() => - { - _eventHandle.ChangeAccess(EventAccess.QueryState | EventAccess.ModifyState); + { + _eventHandle.ChangeAccess(EventAccess.QueryState | EventAccess.ModifyState); - action(); - }); + action(); + }); } private void buttonSet_Click(object sender, EventArgs e) @@ -64,7 +63,7 @@ private void buttonPulse_Click(object sender, EventArgs e) private void buttonClear_Click(object sender, EventArgs e) { - this.UpgradeExecute(_eventHandle.Clear); + this.UpgradeExecute(() => _eventHandle.Clear()); this.UpdateInfo(); } diff --git a/1.x/trunk/ProcessHacker/Components/EventProperties.resx b/1.x/trunk/ProcessHacker/Components/EventProperties.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/EventProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/EventProperties.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/ExtendedListView.cs b/1.x/trunk/ProcessHacker/Components/ExtendedListView.cs index 23871072a..26b4f9c19 100644 --- a/1.x/trunk/ProcessHacker/Components/ExtendedListView.cs +++ b/1.x/trunk/ProcessHacker/Components/ExtendedListView.cs @@ -31,7 +31,6 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; -using ProcessHacker.Common; using ProcessHacker.Native; using ProcessHacker.Native.Api; @@ -41,7 +40,7 @@ namespace ProcessHacker.Components public sealed class LinkClickedEventArgs : EventArgs { - private readonly ListViewGroup _group; + private ListViewGroup _group; public LinkClickedEventArgs(ListViewGroup group) { @@ -54,7 +53,7 @@ public ListViewGroup Group } } - public sealed class ExtendedListView : ListView + public class ExtendedListView : ListView { #region Control Variables @@ -85,17 +84,6 @@ public ExtendedListView() // Windows messages before they get to the form's WndProc. this.SetStyle(ControlStyles.EnableNotifyMessage, true); } - protected override void OnHandleCreated(EventArgs e) - { - base.OnHandleCreated(e); - - if (OSVersion.IsAbove(WindowsVersion.XP)) - { - Win32.SetWindowTheme(this.Handle, "Explorer", null); - } - - this.MakeFocusInvisible(); - } public bool DoubleClickChecks { @@ -126,9 +114,7 @@ private ListViewGroup FindGroup(int id) { foreach (ListViewGroup group in this.Groups) { - int? groupId = GetGroupID(group); - - if (groupId != null && groupId.Value == id) + if (GetGroupID(group).Value == id) return group; } @@ -139,17 +125,18 @@ private ListViewGroup FindGroup(int id) { int? grpId = null; Type grpType = lvGroup.GetType(); - - PropertyInfo pInfo = grpType.GetProperty("ID", BindingFlags.NonPublic | BindingFlags.Instance); - if (pInfo != null) + if (grpType != null) { - object tmprtnval = pInfo.GetValue(lvGroup, null); - if (tmprtnval != null) + PropertyInfo pInfo = grpType.GetProperty("ID", BindingFlags.NonPublic | BindingFlags.Instance); + if (pInfo != null) { - grpId = tmprtnval as int?; + object tmprtnval = pInfo.GetValue(lvGroup, null); + if (tmprtnval != null) + { + grpId = tmprtnval as int?; + } } } - return grpId; } @@ -160,13 +147,13 @@ private void SetGrpState(ListViewGroup lvGroup, ListViewGroupState grpState, str if (lvGroup == null || lvGroup.ListView == null) return; if (lvGroup.ListView.InvokeRequired) - lvGroup.ListView.BeginInvoke(new CallBackSetGroupState(SetGrpState), lvGroup, grpState, task); + lvGroup.ListView.Invoke(new CallBackSetGroupState(SetGrpState), lvGroup, grpState, task); else { int? GrpId = GetGroupID(lvGroup); int gIndex = lvGroup.ListView.Groups.IndexOf(lvGroup); LVGroup group = new LVGroup(); - group.CbSize = LVGroup.SizeOf; + group.CbSize = Marshal.SizeOf(group); if (!string.IsNullOrEmpty(task)) { @@ -188,12 +175,12 @@ private void SetGrpState(ListViewGroup lvGroup, ListViewGroupState grpState, str if (GrpId != null) { group.GroupId = GrpId.Value; - SendMessage(this.Handle, LVM_SetGroupInfo, GrpId.Value, ref group); + SendMessage(base.Handle, LVM_SetGroupInfo, GrpId.Value, ref group); } else { group.GroupId = gIndex; - SendMessage(this.Handle, LVM_SetGroupInfo, gIndex, ref group); + SendMessage(base.Handle, LVM_SetGroupInfo, gIndex, ref group); } lvGroup.ListView.Refresh(); @@ -281,15 +268,8 @@ protected override void WndProc(ref Message m) /// Used to set and retrieve groups. /// [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public struct LVGroup + private struct LVGroup { - public static readonly int SizeOf; - - static LVGroup() - { - SizeOf = Marshal.SizeOf(typeof(LVGroup)); - } - /// /// Size of this structure, in bytes. /// @@ -417,12 +397,12 @@ static LVGroup() /// public uint CchSubsetTitle; } - + /// /// WM_NOTIFY notificaiton message header. /// [StructLayout(LayoutKind.Sequential)] - public struct NMHDR + private struct NMHDR { /// /// Window handle to the control sending a message. @@ -442,7 +422,7 @@ public struct NMHDR /// Used to set and retrieve information about a link item. /// [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct LITEM + private struct LITEM { /// /// Combination of one or more of the LIF flags @@ -477,7 +457,7 @@ public struct LITEM /// Contains information about an LVN_LINKCLICK notification. /// [StructLayout(LayoutKind.Sequential)] - public struct NMLVLINK + private struct NMLVLINK { /// /// NMHDR structure that contains basic diff --git a/1.x/trunk/ProcessHacker/Components/ExtendedTreeView.cs b/1.x/trunk/ProcessHacker/Components/ExtendedTreeView.cs index 9fc67b2d3..0c1e49458 100644 --- a/1.x/trunk/ProcessHacker/Components/ExtendedTreeView.cs +++ b/1.x/trunk/ProcessHacker/Components/ExtendedTreeView.cs @@ -22,6 +22,7 @@ */ using System; +using System.Runtime.InteropServices; using ProcessHacker.Native; using ProcessHacker.Native.Api; @@ -41,8 +42,8 @@ protected override void OnHandleCreated(System.EventArgs e) { if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) { - Win32.SendMessage(this.Handle, (WindowMessage)TVM_SETEXTENDEDSTYLE, IntPtr.Zero, (IntPtr)TVS_EX_FADEINOUTEXPANDOS); - Win32.SetWindowTheme(this.Handle, "Explorer", null); + Win32.SendMessage(this.Handle, (WindowMessage)TVM_SETEXTENDEDSTYLE, 0, TVS_EX_FADEINOUTEXPANDOS); + ProcessHacker.Common.PhUtils.SetTheme(this, "explorer"); } base.OnHandleCreated(e); diff --git a/1.x/trunk/ProcessHacker/Components/FileNameBox.Designer.cs b/1.x/trunk/ProcessHacker/Components/FileNameBox.Designer.cs index ef1316274..0b69e8137 100644 --- a/1.x/trunk/ProcessHacker/Components/FileNameBox.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/FileNameBox.Designer.cs @@ -37,9 +37,9 @@ private void InitializeComponent() // // textFileName // - this.textFileName.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFileName.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFileName.Location = new System.Drawing.Point(0, 2); this.textFileName.Name = "textFileName"; this.textFileName.Size = new System.Drawing.Size(277, 20); @@ -48,8 +48,8 @@ private void InitializeComponent() // // buttonProperties // - this.buttonProperties.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); + this.buttonProperties.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); this.buttonProperties.Image = global::ProcessHacker.Properties.Resources.application_form_magnify; this.buttonProperties.Location = new System.Drawing.Point(279, 0); this.buttonProperties.Name = "buttonProperties"; @@ -61,8 +61,8 @@ private void InitializeComponent() // // buttonExplore // - this.buttonExplore.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); + this.buttonExplore.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); this.buttonExplore.Image = global::ProcessHacker.Properties.Resources.folder_explore; this.buttonExplore.Location = new System.Drawing.Point(304, 0); this.buttonExplore.Name = "buttonExplore"; @@ -76,7 +76,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.buttonExplore); this.Controls.Add(this.buttonProperties); this.Controls.Add(this.textFileName); diff --git a/1.x/trunk/ProcessHacker/Components/FileNameBox.resx b/1.x/trunk/ProcessHacker/Components/FileNameBox.resx index 026c576b4..a5979aadf 100644 --- a/1.x/trunk/ProcessHacker/Components/FileNameBox.resx +++ b/1.x/trunk/ProcessHacker/Components/FileNameBox.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/HandleDetails.cs b/1.x/trunk/ProcessHacker/Components/HandleDetails.cs deleted file mode 100644 index 4abc1a39d..000000000 --- a/1.x/trunk/ProcessHacker/Components/HandleDetails.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Process Hacker - - * .NET counters control - * - * Copyright (C) 2009-2010 wj32 - * - * This file is part of Process Hacker. - * - * Process Hacker is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Process Hacker is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Process Hacker. If not, see . - */ - -using System; -using System.Windows.Forms; -using ProcessHacker.Api; -using ProcessHacker.Native; -using ProcessHacker.Native.Api; - -namespace ProcessHacker.Components -{ - public partial class HandleDetails : ProcessPropertySheetPage - { - public delegate void HandlePropertiesDelegate(Control objectGroup, string name, string typeName); - - public event HandlePropertiesDelegate HandlePropertiesCallback; - public string _name; - public string _typeName; - - public SystemHandleEntry ObjectHandle { get; set; } - - public void Init() - { - try - { - ObjectInformation handleInfo = ObjectHandle.GetHandleInfo(); - - _name = textName.Text = handleInfo.BestName; - - if (string.IsNullOrEmpty(textName.Text)) - textName.Text = "(unnamed object)"; - - _typeName = textType.Text = handleInfo.TypeName; - textAddress.Text = "0x" + ObjectHandle.Object.ToString("x"); - textGrantedAccess.Text = "0x" + ObjectHandle.GrantedAccess.ToString("x"); - - if (ObjectHandle.GrantedAccess != 0) - { - try - { - Type accessEnumType = NativeTypeFactory.GetAccessType(handleInfo.TypeName); - textGrantedAccess.Text += " (" + NativeTypeFactory.GetAccessString(accessEnumType, ObjectHandle.GrantedAccess) + ")"; - } - catch (NotSupportedException) - { - } - } - - ObjectBasicInformation basicInfo = ObjectHandle.GetBasicInfo(); - - labelReferences.Text = "References: " + (basicInfo.PointerCount - 1); - labelHandles.Text = "Handles: " + basicInfo.HandleCount.ToString(); - labelPaged.Text = "Paged: " + basicInfo.PagedPoolUsage.ToString(); - labelNonPaged.Text = "Non-Paged: " + basicInfo.NonPagedPoolUsage.ToString(); - - if (HandlePropertiesCallback != null) - { - try - { - HandlePropertiesCallback(groupObjectInfo, _name, _typeName); - } - catch - { - } - - if (groupObjectInfo.Controls.Count == 0) - { - groupObjectInfo.Visible = false; - } - else if (groupObjectInfo.Controls.Count == 1) - { - Control control = groupObjectInfo.Controls[0]; - - // If it's a user control, dock it. - if (control is UserControl) - { - control.Dock = DockStyle.Fill; - control.Margin = new Padding(3); - } - else - { - control.Location = new System.Drawing.Point(10, 20); - } - } - } - } - catch (Exception) - { } - - this.ActiveControl = this.label1; - } - - public HandleDetails() - { - InitializeComponent(); - - this.ActiveControl = this.label1; - - this.label1.Refresh(); - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/HandleDetails.resx b/1.x/trunk/ProcessHacker/Components/HandleDetails.resx deleted file mode 100644 index c7e0d4bdf..000000000 --- a/1.x/trunk/ProcessHacker/Components/HandleDetails.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/HandleList.Designer.cs b/1.x/trunk/ProcessHacker/Components/HandleList.Designer.cs index 3289805b5..e1aecfac9 100644 --- a/1.x/trunk/ProcessHacker/Components/HandleList.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/HandleList.Designer.cs @@ -32,10 +32,12 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.listHandles = new ProcessHacker.Components.ExtendedListView(); - this.columnType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHandle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.components = new System.ComponentModel.Container(); + this.listHandles = new System.Windows.Forms.ListView(); + this.columnType = new System.Windows.Forms.ColumnHeader(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnHandle = new System.Windows.Forms.ColumnHeader(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.closeHandleMenuItem = new System.Windows.Forms.MenuItem(); this.copyHandleMenuItem = new System.Windows.Forms.MenuItem(); this.menuHandle = new System.Windows.Forms.ContextMenu(); @@ -43,6 +45,7 @@ private void InitializeComponent() this.inheritMenuItem = new System.Windows.Forms.MenuItem(); this.menuItem11 = new System.Windows.Forms.MenuItem(); this.propertiesHandleMenuItem = new System.Windows.Forms.MenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // listHandles @@ -53,7 +56,6 @@ private void InitializeComponent() this.columnName, this.columnHandle}); this.listHandles.Dock = System.Windows.Forms.DockStyle.Fill; - this.listHandles.DoubleClickChecks = true; this.listHandles.FullRowSelect = true; this.listHandles.HideSelection = false; this.listHandles.Location = new System.Drawing.Point(0, 0); @@ -79,14 +81,21 @@ private void InitializeComponent() // this.columnHandle.Text = "Handle"; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // closeHandleMenuItem // + this.vistaMenu.SetImage(this.closeHandleMenuItem, global::ProcessHacker.Properties.Resources.cross); this.closeHandleMenuItem.Index = 0; this.closeHandleMenuItem.Text = "Close"; this.closeHandleMenuItem.Click += new System.EventHandler(this.closeHandleMenuItem_Click); // // copyHandleMenuItem // + this.vistaMenu.SetImage(this.copyHandleMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyHandleMenuItem.Index = 4; this.copyHandleMenuItem.Text = "&Copy"; // @@ -128,20 +137,22 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listHandles); + this.DoubleBuffered = true; this.Name = "HandleList"; this.Size = new System.Drawing.Size(450, 472); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); } #endregion - private ExtendedListView listHandles; + private System.Windows.Forms.ListView listHandles; private System.Windows.Forms.ColumnHeader columnType; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnHandle; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.ContextMenu menuHandle; private System.Windows.Forms.MenuItem closeHandleMenuItem; private System.Windows.Forms.MenuItem copyHandleMenuItem; diff --git a/1.x/trunk/ProcessHacker/Components/HandleList.cs b/1.x/trunk/ProcessHacker/Components/HandleList.cs index 77c4a4807..895967535 100644 --- a/1.x/trunk/ProcessHacker/Components/HandleList.cs +++ b/1.x/trunk/ProcessHacker/Components/HandleList.cs @@ -23,22 +23,20 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Runtime.InteropServices; +using System.Reflection; using System.Windows.Forms; -using ProcessHacker.Api; using ProcessHacker.Common; using ProcessHacker.Common.Ui; using ProcessHacker.Native; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; -using ProcessHacker.Native.Security.AccessControl; using ProcessHacker.Native.Ui; using ProcessHacker.UI; namespace ProcessHacker.Components { - public partial class HandleList : ProcessPropertySheetPage + public partial class HandleList : UserControl { public static bool ConfirmHandleClose() { @@ -51,37 +49,22 @@ public static bool ConfirmHandleClose() false ); } - return true; + else + { + return true; + } } public static void ShowHandleProperties(SystemHandleEntry handleInfo) { try { + HandlePropertiesWindow window = new HandlePropertiesWindow(handleInfo); IntPtr handle = new IntPtr(handleInfo.Handle); ProcessHandle phandle = new ProcessHandle(handleInfo.ProcessId, ProcessAccess.DupHandle); - GenericHandle dupHandle = null; - - // Try to get a handle, since we need one for security editing. - try - { - dupHandle = new GenericHandle(phandle, handle, 0); - } - catch - { } - - PropSheetHeader64 header = new PropSheetHeader64 - { - dwSize = (uint)PropSheetHeader64.SizeOf, - nPages = 2, - dwFlags = (uint)PropSheetFlags.PSH_DEFAULT, - pszCaption = "Handle Properties" - }; + GenericHandle dupHandle = null; - using (HandleDetails hw = new HandleDetails()) - { - hw.ObjectHandle = handleInfo; - hw.HandlePropertiesCallback += (control, name, typeName) => + window.HandlePropertiesCallback += (control, name, typeName) => { switch (typeName.ToLowerInvariant()) { @@ -92,65 +75,76 @@ public static void ShowHandleProperties(SystemHandleEntry handleInfo) case "token": case "process": { - Button b = new Button - { - FlatStyle = FlatStyle.System, - Text = "Properties" - }; + Button b = new Button(); + b.FlatStyle = FlatStyle.System; + b.Text = "Properties"; b.Click += (sender, e) => - { - try { - switch (typeName.ToLowerInvariant()) + try { - case "file": - { - FileUtils.ShowProperties(name); - } - break; - case "job": - { - dupHandle = new GenericHandle(phandle, handle, (int)JobObjectAccess.Query); - - (new JobWindow(JobObjectHandle.FromHandle(dupHandle))).ShowDialog(); - } - break; - case "key": - { - try + switch (typeName.ToLowerInvariant()) + { + case "file": + { + FileUtils.ShowProperties(name); + } + break; + case "job": { - PhUtils.OpenKeyInRegedit(PhUtils.GetForegroundWindow(), name); + dupHandle = + new GenericHandle( + phandle, handle, + (int)JobObjectAccess.Query); + (new JobWindow(JobObjectHandle.FromHandle(dupHandle))).ShowDialog(); } - catch (Exception ex) + break; + case "key": { - PhUtils.ShowException("Unable to open the Registry Editor", ex); + try + { + PhUtils.OpenKeyInRegedit(PhUtils.GetForegroundWindow(), name); + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to open the Registry Editor", ex); + } } - } - break; - case "token": - { - using (TokenWindow twindow = new TokenWindow(new RemoteTokenHandle(phandle, handle))) + break; + case "token": { - twindow.ShowDialog(); + (new TokenWindow(new RemoteTokenHandle(phandle, + handle))).ShowDialog(); } - } - break; - case "process": - { - dupHandle = new GenericHandle(phandle, handle, (int)OSVersion.MinProcessQueryInfoAccess); - int pid = ProcessHandle.FromHandle(dupHandle).ProcessId; - - Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], Program.FocusWindow); - } - break; + break; + case "process": + { + int pid; + + if (KProcessHacker.Instance != null) + { + pid = KProcessHacker.Instance.KphGetProcessId(phandle, handle); + } + else + { + dupHandle = + new GenericHandle( + phandle, handle, + (int)OSVersion.MinProcessQueryInfoAccess); + pid = ProcessHandle.FromHandle(dupHandle).GetProcessId(); + } + + Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], + (f) => Program.FocusWindow(f)); + } + break; + } } - } - catch (Exception ex) - { - PhUtils.ShowException("Unable to show object properties", ex); - } - }; + catch (Exception ex) + { + PhUtils.ShowException("Unable to show object properties", ex); + } + }; control.Controls.Add(b); } @@ -214,25 +208,19 @@ public static void ShowHandleProperties(SystemHandleEntry handleInfo) } }; - hw.Init(); - - IntPtr[] pages = new IntPtr[2]; - pages[0] = hw.CreatePageHandle(); - pages[1] = CreateSecurityPage(SecurityEditor.EditSecurity2( - null, - SecurityEditor.GetSecurableWrapper(dupHandle), - hw._name, - NativeTypeFactory.GetAccessEntries(NativeTypeFactory.GetObjectType(hw._typeName)) - )); + if (dupHandle == null) + { + // Try to get a handle, since we need one for security editing. + try { dupHandle = new GenericHandle(phandle, handle, 0); } + catch { } + } - GCHandle gch = GCHandle.Alloc(pages, GCHandleType.Pinned); - header.phpage = gch.AddrOfPinnedObject(); + window.ObjectHandle = dupHandle; - PropertySheetW(ref header); + window.ShowDialog(); - if (dupHandle != null) - dupHandle.Dispose(); - } + if (dupHandle != null) + dupHandle.Dispose(); } catch (Exception ex) { @@ -240,84 +228,11 @@ public static void ShowHandleProperties(SystemHandleEntry handleInfo) } } - [DllImport("Comctl32.dll")] - public static extern IntPtr PropertySheetW([In, MarshalAs(UnmanagedType.Struct)]ref PropSheetHeader64 lppsph); - - [DllImport("Aclui.dll")] - public static extern IntPtr CreateSecurityPage(ISecurityInformation lppsph); - - [StructLayout(LayoutKind.Explicit, Pack = 8, CharSet = CharSet.Unicode)] - public struct PropSheetHeader64 - { - public static readonly int SizeOf; - - static PropSheetHeader64() - { - SizeOf = Marshal.SizeOf(typeof(PropSheetHeader64)); - } - - [FieldOffset(0)] - public UInt32 dwSize; - [FieldOffset(4)] - public UInt32 dwFlags; - [FieldOffset(8)] - public IntPtr hwndParent; - [FieldOffset(16)] - public IntPtr hInstance; - [FieldOffset(24)] - public IntPtr hIcon; - [FieldOffset(32)] - public String pszCaption; - [FieldOffset(40)] - public UInt32 nPages; - [FieldOffset(48)] - public string pStartPage; - [FieldOffset(56)] - public IntPtr phpage; - - // following fields all for PROPSHEETHEADER_V2 - [FieldOffset(64)] - public IntPtr pfnCallback; - [FieldOffset(72)] - public IntPtr hbmWatermark; - [FieldOffset(80)] - public IntPtr hplWatermark; - [FieldOffset(88)] - public IntPtr hbmHeader; - } - - [Flags] - internal enum PropSheetFlags : uint - { - PSH_DEFAULT = 0x00000000, - PSH_PROPTITLE = 0x00000001, - PSH_USEHICON = 0x00000002, - PSH_USEICONID = 0x00000004, - PSH_PROPSHEETPAGE = 0x00000008, - PSH_WIZARDHASFINISH = 0x00000010, - PSH_WIZARD = 0x00000020, - PSH_USEPSTARTPAGE = 0x00000040, - PSH_NOAPPLYNOW = 0x00000080, - PSH_USECALLBACK = 0x00000100, - PSH_HASHELP = 0x00000200, - PSH_MODELESS = 0x00000400, - PSH_RTLREADING = 0x00000800, - PSH_WIZARDCONTEXTHELP = 0x00001000, - PSH_WIZARD97 = 0x01000000, - PSH_WATERMARK = 0x00008000, - PSH_USEHBMWATERMARK = 0x00010000, // user pass in a hbmWatermark instead of pszbmWatermark - PSH_USEHPLWATERMARK = 0x00020000, // - PSH_STRETCHWATERMARK = 0x00040000, // stretchwatermark also applies for the header - PSH_HEADER = 0x00080000, - PSH_USEHBMHEADER = 0x00100000, - PSH_USEPAGELANG = 0x00200000 // use frame dialog template matched to page - } - - private readonly object _listLock = new object(); + private object _listLock = new object(); private HandleProvider _provider; - private int _runCount; - private readonly List _needsAdd = new List(); - private readonly HighlightingContext _highlightingContext; + private int _runCount = 0; + private List _needsAdd = new List(); + private HighlightingContext _highlightingContext; public new event KeyEventHandler KeyDown; public new event MouseEventHandler MouseDown; public new event MouseEventHandler MouseUp; @@ -328,11 +243,11 @@ public HandleList() InitializeComponent(); _highlightingContext = new HighlightingContext(listHandles); - listHandles.KeyDown += this.listHandles_KeyDown; - listHandles.MouseDown += this.listHandles_MouseDown; - listHandles.MouseUp += this.listHandles_MouseUp; - listHandles.DoubleClick += this.listHandles_DoubleClick; - listHandles.SelectedIndexChanged += this.listHandles_SelectedIndexChanged; + listHandles.KeyDown += new KeyEventHandler(listHandles_KeyDown); + listHandles.MouseDown += new MouseEventHandler(listHandles_MouseDown); + listHandles.MouseUp += new MouseEventHandler(listHandles_MouseUp); + listHandles.DoubleClick += new EventHandler(listHandles_DoubleClick); + listHandles.SelectedIndexChanged += new System.EventHandler(listHandles_SelectedIndexChanged); var comparer = (SortedListViewComparer) (listHandles.ListViewItemSorter = new SortedListViewComparer(listHandles)); @@ -345,7 +260,7 @@ public HandleList() GenericViewMenu.AddMenuItems(copyHandleMenuItem.MenuItems, listHandles, null); ColumnSettings.LoadSettings(Settings.Instance.HandleListViewColumns, listHandles); - //if (KProcessHacker.Instance == null) + if (KProcessHacker.Instance == null) { protectedMenuItem.Visible = false; inheritMenuItem.Visible = false; @@ -369,7 +284,7 @@ private void listHandles_MouseDown(object sender, MouseEventArgs e) this.MouseDown(sender, e); } - private void listHandles_SelectedIndexChanged(object sender, EventArgs e) + private void listHandles_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.SelectedIndexChanged != null) this.SelectedIndexChanged(sender, e); @@ -382,23 +297,36 @@ private void listHandles_KeyDown(object sender, KeyEventArgs e) if (!e.Handled) { - switch (e.KeyCode) + if (e.KeyCode == Keys.Enter) { - case Keys.Enter: - this.propertiesHandleMenuItem_Click(null, null); - break; - case Keys.Delete: - if (ConfirmHandleClose()) - { - this.closeHandleMenuItem_Click(null, null); - } - break; + propertiesHandleMenuItem_Click(null, null); + } + else if (e.KeyCode == Keys.Delete) + { + if (ConfirmHandleClose()) + { + closeHandleMenuItem_Click(null, null); + } } } } #region Properties + public new bool DoubleBuffered + { + get + { + return (bool)typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).GetValue(listHandles, null); + } + set + { + typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).SetValue(listHandles, value, null); + } + } + public override bool Focused { get @@ -407,13 +335,19 @@ public override bool Focused } } + public override ContextMenu ContextMenu + { + get { return listHandles.ContextMenu; } + set { listHandles.ContextMenu = value; } + } + public override ContextMenuStrip ContextMenuStrip { get { return listHandles.ContextMenuStrip; } set { listHandles.ContextMenuStrip = value; } } - public ExtendedListView List + public ListView List { get { return listHandles; } } @@ -506,13 +440,12 @@ private Color GetHandleColor(HandleItem item) (item.Handle.Flags & HandleFlags.ProtectFromClose) != 0 ) return Settings.Instance.ColorProtectedHandles; - - if (Settings.Instance.UseColorInheritHandles && + else if (Settings.Instance.UseColorInheritHandles && (item.Handle.Flags & HandleFlags.Inherit) != 0 ) return Settings.Instance.ColorInheritHandles; - - return SystemColors.Window; + else + return SystemColors.Window; } public void AddItem(HandleItem item) @@ -533,12 +466,11 @@ public void DumpDisableEvents() private void provider_DictionaryAdded(HandleItem item) { - HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, item.RunId > 0 && _runCount > 0) - { - Name = item.Handle.Handle.ToString(), - Text = item.ObjectInfo.TypeName - }; + HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, + item.RunId > 0 && _runCount > 0); + litem.Name = item.Handle.Handle.ToString(); + litem.Text = item.ObjectInfo.TypeName; litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.ObjectInfo.BestName)); litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "0x" + item.Handle.Handle.ToString("x"))); litem.Tag = item; @@ -552,21 +484,22 @@ private void provider_DictionaryAdded(HandleItem item) private void provider_DictionaryModified(HandleItem oldItem, HandleItem newItem) { this.BeginInvoke(new MethodInvoker(() => - { - lock (_listLock) { - ((HighlightedListViewItem)this.listHandles.Items[newItem.Handle.Handle.ToString()]).NormalColor = this.GetHandleColor(newItem); - } - })); + lock (_listLock) + { + (listHandles.Items[newItem.Handle.Handle.ToString()] as + HighlightedListViewItem).NormalColor = this.GetHandleColor(newItem); + } + })); } private void provider_DictionaryRemoved(HandleItem item) { this.BeginInvoke(new MethodInvoker(() => - { - lock (_listLock) - listHandles.Items[item.Handle.Handle.ToString()].Remove(); - })); + { + lock (_listLock) + listHandles.Items[item.Handle.Handle.ToString()].Remove(); + })); } private int _pid; @@ -583,7 +516,7 @@ private void menuHandle_Popup(object sender, EventArgs e) if (listHandles.SelectedItems.Count == 0) { - //menuHandle.DisableAll(); + menuHandle.DisableAll(); } else if (listHandles.SelectedItems.Count == 1) { @@ -653,8 +586,8 @@ private void protectedMenuItem_Click(object sender, EventArgs e) try { - //using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) - //KProcessHacker.Instance.SetHandleAttributes(phandle, new IntPtr(item.Handle.Handle), flags); + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) + KProcessHacker.Instance.SetHandleAttributes(phandle, new IntPtr(item.Handle.Handle), flags); } catch (Exception ex) { @@ -674,8 +607,8 @@ private void inheritMenuItem_Click(object sender, EventArgs e) try { - //using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) - //KProcessHacker.Instance.SetHandleAttributes(phandle, new IntPtr(item.Handle.Handle), flags); + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) + KProcessHacker.Instance.SetHandleAttributes(phandle, new IntPtr(item.Handle.Handle), flags); } catch (Exception ex) { diff --git a/1.x/trunk/ProcessHacker/Components/HandleList.resx b/1.x/trunk/ProcessHacker/Components/HandleList.resx index 051a81cde..90ace843e 100644 --- a/1.x/trunk/ProcessHacker/Components/HandleList.resx +++ b/1.x/trunk/ProcessHacker/Components/HandleList.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + 17, 17 + + 125, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/Indicator.cs b/1.x/trunk/ProcessHacker/Components/Indicator.cs index 9248e9362..d4a5a677a 100644 --- a/1.x/trunk/ProcessHacker/Components/Indicator.cs +++ b/1.x/trunk/ProcessHacker/Components/Indicator.cs @@ -21,7 +21,11 @@ */ using System; +using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; +using System.Data; +using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; @@ -41,38 +45,40 @@ public Color Color2 get { return _lineColor2; } set { _lineColor2 = value; } } + private long _data1; + public long Data1 + { + get { return _data1; } + set { _data1 = value; } + } + private long _data2; + public long Data2 + { + get { return _data2; } + set { _data2 = value; } + } - public long Data1 { get; set; } - public long Data2 { get; set; } + public Indicator() { InitializeComponent(); - - this.SetStyle( - ControlStyles.ResizeRedraw | - ControlStyles.UserPaint | - ControlStyles.OptimizedDoubleBuffer | - ControlStyles.AllPaintingInWmPaint, true); + base.SetStyle(ControlStyles.ResizeRedraw | ControlStyles.UserPaint | + ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); } protected override void OnPaint(PaintEventArgs e) { //SolidBrush brush = new SolidBrush(this.ForeColor); SolidBrush brush1 = new SolidBrush(this.Color1); SolidBrush brush2 = new SolidBrush(this.Color2); - int width = this.ClientSize.Width; - int height = this.ClientSize.Height; + int width = base.ClientSize.Width; + int height = base.ClientSize.Height; int num1 = height; num1 -= this.Font.Height + 4; - RectangleF layoutRectangle = new RectangleF(0f, num1, width, height); - - StringFormat format = new StringFormat(StringFormatFlags.NoWrap) - { - Alignment = StringAlignment.Center - }; - + RectangleF layoutRectangle = new RectangleF(0f, (float)num1, (float)width, (float)height); + StringFormat format = new StringFormat(StringFormatFlags.NoWrap); + format.Alignment = StringAlignment.Center; e.Graphics.DrawString(this.Text, this.Font, brush1, layoutRectangle, format); - int num2 = (((height - 6) - 4) - this.Font.Height) - 4; num2++; int num3 = num2 / 3; @@ -80,24 +86,25 @@ protected override void OnPaint(PaintEventArgs e) byte green = (byte)(this.ForeColor.G / 2); byte blue = (byte)(this.ForeColor.B / 2); - Pen pen = new Pen(Color.FromArgb(red, green, blue)) - { - DashStyle = DashStyle.Dot - }; + Pen pen = new Pen(Color.FromArgb(red, green, blue)); + pen.DashStyle = DashStyle.Dot; int num4 = (width - this.GraphWidth) / 2; int num5 = ((height - 4) - this.Font.Height) - 7; int num6 = this.GraphWidth / 2; - int num9 = (int)Math.Ceiling(((this.Data1 - this.Minimum) * 1.0) / ((this.Maximum - (this.Minimum * 1.0)) / num3)); - int num10 = (int)Math.Ceiling(((this.Data1 + this.Data2 - this.Minimum) * 1.0) / ((this.Maximum - (this.Minimum * 1.0)) / num3)); + int x = num4; + int y = 0; + int num7 = 0; + int num8 = 0; + int num9 = (int)Math.Ceiling((double)(((this.Data1 - this.Minimum) * 1.0) / ((this.Maximum - (this.Minimum * 1.0)) / ((double)num3)))); + int num10 = (int)Math.Ceiling((double)(((this.Data1 + this.Data2 - this.Minimum) * 1.0) / ((this.Maximum - (this.Minimum * 1.0)) / ((double)num3)))); for (int i = 0; i < num3; i++) { - int x = num4; - int y = (num5 - (i * 3)) - 1; - int num7 = x + num6; - int num8 = y; - + x = num4; + y = (num5 - (i * 3)) - 1; + num7 = x + num6; + num8 = y; if (i < num9) { e.Graphics.FillRectangle(brush1, x, y, num6, 2); @@ -132,9 +139,9 @@ protected override CreateParams CreateParams return createParams; } } - private int _GraphWidth = 0x21; + private int _GraphWidth=0x21; private long _Maximum = long.MaxValue; - private long _Minimum; + private long _Minimum = 0; public int GraphWidth { get @@ -144,7 +151,7 @@ public int GraphWidth set { this._GraphWidth = value; - this.Invalidate(); + base.Invalidate(); } } public long Maximum @@ -162,7 +169,7 @@ public long Maximum } this._Maximum = value; - this.Invalidate(); + base.Invalidate(); } } public long Minimum @@ -178,7 +185,7 @@ public long Minimum throw new ArgumentException(); } this._Minimum = value; - this.Invalidate(); + base.Invalidate(); } } public string TextValue @@ -190,7 +197,7 @@ public string TextValue set { base.Text = value; - this.Invalidate(); + base.Invalidate(); } } } diff --git a/1.x/trunk/ProcessHacker/Components/Indicator.resx b/1.x/trunk/ProcessHacker/Components/Indicator.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/Indicator.resx +++ b/1.x/trunk/ProcessHacker/Components/Indicator.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/JobProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/JobProperties.Designer.cs index a6ab51d28..dfd7017d7 100644 --- a/1.x/trunk/ProcessHacker/Components/JobProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/JobProperties.Designer.cs @@ -34,17 +34,16 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); this.tabControl = new System.Windows.Forms.TabControl(); this.tabGeneral = new System.Windows.Forms.TabPage(); - this.buttonTerminate = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textJobName = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); - this.listLimits = new ProcessHacker.Components.ExtendedListView(); - this.columnLimit = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.listProcesses = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnPid = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listLimits = new System.Windows.Forms.ListView(); + this.columnLimit = new System.Windows.Forms.ColumnHeader(); + this.columnValue = new System.Windows.Forms.ColumnHeader(); + this.listProcesses = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnPid = new System.Windows.Forms.ColumnHeader(); this.tabStatistics = new System.Windows.Forms.TabPage(); this.flowStatistics = new System.Windows.Forms.FlowLayoutPanel(); this.groupGeneral = new System.Windows.Forms.GroupBox(); @@ -88,6 +87,7 @@ private void InitializeComponent() this.labelIOOther = new System.Windows.Forms.Label(); this.labelIOOtherBytes = new System.Windows.Forms.Label(); this.timerUpdate = new System.Windows.Forms.Timer(this.components); + this.buttonTerminate = new System.Windows.Forms.Button(); this.tabControl.SuspendLayout(); this.tabGeneral.SuspendLayout(); this.tabStatistics.SuspendLayout(); @@ -110,7 +110,7 @@ private void InitializeComponent() this.tabControl.Location = new System.Drawing.Point(0, 0); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(456, 434); + this.tabControl.Size = new System.Drawing.Size(646, 434); this.tabControl.TabIndex = 0; // // tabGeneral @@ -125,23 +125,11 @@ private void InitializeComponent() this.tabGeneral.Location = new System.Drawing.Point(4, 22); this.tabGeneral.Name = "tabGeneral"; this.tabGeneral.Padding = new System.Windows.Forms.Padding(3); - this.tabGeneral.Size = new System.Drawing.Size(448, 408); + this.tabGeneral.Size = new System.Drawing.Size(638, 408); this.tabGeneral.TabIndex = 0; this.tabGeneral.Text = "General"; this.tabGeneral.UseVisualStyleBackColor = true; // - // buttonTerminate - // - this.buttonTerminate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonTerminate.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonTerminate.Location = new System.Drawing.Point(367, 6); - this.buttonTerminate.Name = "buttonTerminate"; - this.buttonTerminate.Size = new System.Drawing.Size(75, 23); - this.buttonTerminate.TabIndex = 5; - this.buttonTerminate.Text = "Terminate"; - this.buttonTerminate.UseVisualStyleBackColor = true; - this.buttonTerminate.Click += new System.EventHandler(this.buttonTerminate_Click); - // // label3 // this.label3.AutoSize = true; @@ -162,12 +150,12 @@ private void InitializeComponent() // // textJobName // - this.textJobName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textJobName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textJobName.Location = new System.Drawing.Point(50, 6); this.textJobName.Name = "textJobName"; this.textJobName.ReadOnly = true; - this.textJobName.Size = new System.Drawing.Size(311, 20); + this.textJobName.Size = new System.Drawing.Size(501, 20); this.textJobName.TabIndex = 2; // // label1 @@ -181,20 +169,19 @@ private void InitializeComponent() // // listLimits // - this.listLimits.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listLimits.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listLimits.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnLimit, this.columnValue}); - this.listLimits.DoubleClickChecks = true; this.listLimits.FullRowSelect = true; this.listLimits.HideSelection = false; this.listLimits.Location = new System.Drawing.Point(6, 165); this.listLimits.MultiSelect = false; this.listLimits.Name = "listLimits"; this.listLimits.ShowItemToolTips = true; - this.listLimits.Size = new System.Drawing.Size(436, 237); + this.listLimits.Size = new System.Drawing.Size(626, 237); this.listLimits.Sorting = System.Windows.Forms.SortOrder.Ascending; this.listLimits.TabIndex = 0; this.listLimits.UseCompatibleStateImageBehavior = false; @@ -212,19 +199,18 @@ private void InitializeComponent() // // listProcesses // - this.listProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listProcesses.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnName, this.columnPid}); - this.listProcesses.DoubleClickChecks = true; this.listProcesses.FullRowSelect = true; this.listProcesses.HideSelection = false; this.listProcesses.Location = new System.Drawing.Point(6, 50); this.listProcesses.MultiSelect = false; this.listProcesses.Name = "listProcesses"; this.listProcesses.ShowItemToolTips = true; - this.listProcesses.Size = new System.Drawing.Size(436, 96); + this.listProcesses.Size = new System.Drawing.Size(626, 96); this.listProcesses.Sorting = System.Windows.Forms.SortOrder.Ascending; this.listProcesses.TabIndex = 0; this.listProcesses.UseCompatibleStateImageBehavior = false; @@ -245,7 +231,7 @@ private void InitializeComponent() this.tabStatistics.Location = new System.Drawing.Point(4, 22); this.tabStatistics.Name = "tabStatistics"; this.tabStatistics.Padding = new System.Windows.Forms.Padding(3); - this.tabStatistics.Size = new System.Drawing.Size(448, 408); + this.tabStatistics.Size = new System.Drawing.Size(638, 408); this.tabStatistics.TabIndex = 2; this.tabStatistics.Text = "Statistics"; this.tabStatistics.UseVisualStyleBackColor = true; @@ -260,7 +246,7 @@ private void InitializeComponent() this.flowStatistics.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowStatistics.Location = new System.Drawing.Point(3, 3); this.flowStatistics.Name = "flowStatistics"; - this.flowStatistics.Size = new System.Drawing.Size(442, 402); + this.flowStatistics.Size = new System.Drawing.Size(632, 402); this.flowStatistics.TabIndex = 2; // // groupGeneral @@ -726,14 +712,26 @@ private void InitializeComponent() this.timerUpdate.Interval = 1000; this.timerUpdate.Tick += new System.EventHandler(this.timerUpdate_Tick); // + // buttonTerminate + // + this.buttonTerminate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonTerminate.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.buttonTerminate.Location = new System.Drawing.Point(557, 6); + this.buttonTerminate.Name = "buttonTerminate"; + this.buttonTerminate.Size = new System.Drawing.Size(75, 23); + this.buttonTerminate.TabIndex = 5; + this.buttonTerminate.Text = "Terminate"; + this.buttonTerminate.UseVisualStyleBackColor = true; + this.buttonTerminate.Click += new System.EventHandler(this.buttonTerminate_Click); + // // JobProperties // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.tabControl); + this.DoubleBuffered = true; this.Name = "JobProperties"; - this.Size = new System.Drawing.Size(456, 434); + this.Size = new System.Drawing.Size(646, 434); this.tabControl.ResumeLayout(false); this.tabGeneral.ResumeLayout(false); this.tabGeneral.PerformLayout(); @@ -763,11 +761,11 @@ private void InitializeComponent() private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textJobName; private System.Windows.Forms.Label label1; - private ExtendedListView listProcesses; + private System.Windows.Forms.ListView listProcesses; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnPid; private System.Windows.Forms.Label label3; - private ExtendedListView listLimits; + private System.Windows.Forms.ListView listLimits; private System.Windows.Forms.ColumnHeader columnLimit; private System.Windows.Forms.ColumnHeader columnValue; private System.Windows.Forms.GroupBox groupGeneral; diff --git a/1.x/trunk/ProcessHacker/Components/JobProperties.cs b/1.x/trunk/ProcessHacker/Components/JobProperties.cs index 5aa5d8e4b..c52274161 100644 --- a/1.x/trunk/ProcessHacker/Components/JobProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/JobProperties.cs @@ -33,14 +33,17 @@ namespace ProcessHacker.Components { public partial class JobProperties : UserControl { - private readonly JobObjectHandle _jobObject; + private JobObjectHandle _jobObject; public JobProperties(JobObjectHandle jobObject) { InitializeComponent(); + listProcesses.SetTheme("explorer"); listProcesses.AddShortcuts(); listProcesses.ContextMenu = listProcesses.GetCopyMenu(); + + listLimits.SetTheme("explorer"); listLimits.AddShortcuts(); listLimits.ContextMenu = listLimits.GetCopyMenu(); @@ -51,7 +54,7 @@ public JobProperties(JobObjectHandle jobObject) try { - string name = _jobObject.ObjectName; + string name = _jobObject.GetObjectName(); if (string.IsNullOrEmpty(name)) textJobName.Text = "(unnamed job)"; @@ -63,7 +66,7 @@ public JobProperties(JobObjectHandle jobObject) try { - foreach (int pid in _jobObject.ProcessIdList) + foreach (int pid in _jobObject.GetProcessIdList()) { ListViewItem item = new ListViewItem(); @@ -82,8 +85,8 @@ public JobProperties(JobObjectHandle jobObject) try { - var extendedLimits = _jobObject.ExtendedLimitInformation; - var uiRestrictions = _jobObject.BasicUiRestrictions; + var extendedLimits = _jobObject.GetExtendedLimitInformation(); + var uiRestrictions = _jobObject.GetBasicUiRestrictions(); var flags = extendedLimits.BasicLimitInformation.LimitFlags; if ((flags & JobObjectLimitFlags.ActiveProcess) != 0) @@ -165,8 +168,8 @@ private void UpdateStatistics() { try { - JobObjectBasicAndIoAccountingInformation accounting = _jobObject.GetBasicAndIoAccountingInformation(); - JobObjectExtendedLimitInformation limits = _jobObject.ExtendedLimitInformation; + var accounting = _jobObject.GetBasicAndIoAccountingInformation(); + var limits = _jobObject.GetExtendedLimitInformation(); labelGeneralActiveProcesses.Text = accounting.BasicInfo.ActiveProcesses.ToString("N0"); labelGeneralTotalProcesses.Text = accounting.BasicInfo.TotalProcesses.ToString("N0"); @@ -201,27 +204,26 @@ private void buttonTerminate_Click(object sender, EventArgs e) { if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainIcon = TaskDialogIcon.Warning; + td.MainInstruction = "Do you want to terminate the job?"; + td.Content = "Terminating a job will terminate all processes assigned to it. Are you sure " + + "you want to continue?"; + td.Buttons = new TaskDialogButton[] { - WindowTitle = "Process Hacker", - MainInstruction = "Do you want to terminate the job?", - Content = "Terminating a job will terminate all processes assigned to it. Are you sure " + "you want to continue?", - MainIcon = TaskDialogIcon.Warning, - DefaultButton = (int)DialogResult.No, - Buttons = new TaskDialogButton[] - { - new TaskDialogButton((int)DialogResult.Yes, "Terminate"), - new TaskDialogButton((int)DialogResult.No, "Cancel") - } + new TaskDialogButton((int)DialogResult.Yes, "Terminate"), + new TaskDialogButton((int)DialogResult.No, "Cancel") }; + td.DefaultButton = (int)DialogResult.No; if (td.Show(this) == (int)DialogResult.No) return; } else { - if (MessageBox.Show( - "Are you sure you want to terminate the job? This action will " + + if (MessageBox.Show("Are you sure you want to terminate the job? This action will " + "terminate all processes associated with the job.", "Process Hacker", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) return; @@ -229,7 +231,7 @@ private void buttonTerminate_Click(object sender, EventArgs e) try { - using (NativeHandle jhandle2 = _jobObject.Duplicate(JobObjectAccess.Terminate)) + using (var jhandle2 = _jobObject.Duplicate(JobObjectAccess.Terminate)) JobObjectHandle.FromHandle(jhandle2).Terminate(); } catch (Exception ex) diff --git a/1.x/trunk/ProcessHacker/Components/JobProperties.resx b/1.x/trunk/ProcessHacker/Components/JobProperties.resx index bfd9c479b..3add4121b 100644 --- a/1.x/trunk/ProcessHacker/Components/JobProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/JobProperties.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/MemoryList.Designer.cs b/1.x/trunk/ProcessHacker/Components/MemoryList.Designer.cs index 1cd68ea58..27b8fe625 100644 --- a/1.x/trunk/ProcessHacker/Components/MemoryList.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/MemoryList.Designer.cs @@ -31,11 +31,13 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.listMemory = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnProtection = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.components = new System.ComponentModel.Container(); + this.listMemory = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnAddress = new System.Windows.Forms.ColumnHeader(); + this.columnSize = new System.Windows.Forms.ColumnHeader(); + this.columnProtection = new System.Windows.Forms.ColumnHeader(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.changeMemoryProtectionMemoryMenuItem = new System.Windows.Forms.MenuItem(); this.readWriteMemoryMemoryMenuItem = new System.Windows.Forms.MenuItem(); this.readWriteAddressMemoryMenuItem = new System.Windows.Forms.MenuItem(); @@ -46,6 +48,7 @@ private void InitializeComponent() this.menuMemory = new System.Windows.Forms.ContextMenu(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.selectAllMemoryMenuItem = new System.Windows.Forms.MenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // listMemory @@ -57,7 +60,6 @@ private void InitializeComponent() this.columnSize, this.columnProtection}); this.listMemory.Dock = System.Windows.Forms.DockStyle.Fill; - this.listMemory.DoubleClickChecks = true; this.listMemory.FullRowSelect = true; this.listMemory.HideSelection = false; this.listMemory.Location = new System.Drawing.Point(0, 0); @@ -87,8 +89,14 @@ private void InitializeComponent() // this.columnProtection.Text = "Protection"; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // changeMemoryProtectionMemoryMenuItem // + this.vistaMenu.SetImage(this.changeMemoryProtectionMemoryMenuItem, global::ProcessHacker.Properties.Resources.lock_edit); this.changeMemoryProtectionMemoryMenuItem.Index = 2; this.changeMemoryProtectionMemoryMenuItem.Text = "Change &Memory Protection..."; this.changeMemoryProtectionMemoryMenuItem.Click += new System.EventHandler(this.changeMemoryProtectionMemoryMenuItem_Click); @@ -96,35 +104,41 @@ private void InitializeComponent() // readWriteMemoryMemoryMenuItem // this.readWriteMemoryMemoryMenuItem.DefaultItem = true; + this.vistaMenu.SetImage(this.readWriteMemoryMemoryMenuItem, global::ProcessHacker.Properties.Resources.page_edit); this.readWriteMemoryMemoryMenuItem.Index = 0; this.readWriteMemoryMemoryMenuItem.Text = "Read/Write Memory"; this.readWriteMemoryMemoryMenuItem.Click += new System.EventHandler(this.readWriteMemoryMemoryMenuItem_Click); // // readWriteAddressMemoryMenuItem // + this.vistaMenu.SetImage(this.readWriteAddressMemoryMenuItem, global::ProcessHacker.Properties.Resources.pencil_go); this.readWriteAddressMemoryMenuItem.Index = 6; this.readWriteAddressMemoryMenuItem.Text = "Read/Write Address..."; this.readWriteAddressMemoryMenuItem.Click += new System.EventHandler(this.readWriteAddressMemoryMenuItem_Click); // // copyMemoryMenuItem // + this.vistaMenu.SetImage(this.copyMemoryMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyMemoryMenuItem.Index = 7; this.copyMemoryMenuItem.Text = "C&opy"; // // freeMenuItem // + this.vistaMenu.SetImage(this.freeMenuItem, global::ProcessHacker.Properties.Resources.cross); this.freeMenuItem.Index = 3; this.freeMenuItem.Text = "&Free"; this.freeMenuItem.Click += new System.EventHandler(this.freeMenuItem_Click); // // decommitMenuItem // + this.vistaMenu.SetImage(this.decommitMenuItem, global::ProcessHacker.Properties.Resources.delete); this.decommitMenuItem.Index = 4; this.decommitMenuItem.Text = "&Decommit"; this.decommitMenuItem.Click += new System.EventHandler(this.decommitMenuItem_Click); // // dumpMemoryMenuItem // + this.vistaMenu.SetImage(this.dumpMemoryMenuItem, global::ProcessHacker.Properties.Resources.disk); this.dumpMemoryMenuItem.Index = 1; this.dumpMemoryMenuItem.Text = "Dump..."; this.dumpMemoryMenuItem.Click += new System.EventHandler(this.dumpMemoryMenuItem_Click); @@ -158,18 +172,20 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listMemory); + this.DoubleBuffered = true; this.Name = "MemoryList"; this.Size = new System.Drawing.Size(450, 472); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); } #endregion - private ExtendedListView listMemory; + private System.Windows.Forms.ListView listMemory; private System.Windows.Forms.ColumnHeader columnName; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.ColumnHeader columnSize; private System.Windows.Forms.ColumnHeader columnAddress; private System.Windows.Forms.ColumnHeader columnProtection; diff --git a/1.x/trunk/ProcessHacker/Components/MemoryList.cs b/1.x/trunk/ProcessHacker/Components/MemoryList.cs index 601f20f7b..c205cf43d 100644 --- a/1.x/trunk/ProcessHacker/Components/MemoryList.cs +++ b/1.x/trunk/ProcessHacker/Components/MemoryList.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Common.Ui; @@ -35,11 +36,12 @@ namespace ProcessHacker.Components { public partial class MemoryList : UserControl { - private int _runCount; + private object _listLock = new object(); + private int _runCount = 0; private MemoryProvider _provider; - private bool _needsSort; - private readonly List _needsAdd = new List(); - private readonly HighlightingContext _highlightingContext; + private bool _needsSort = false; + private List _needsAdd = new List(); + private HighlightingContext _highlightingContext; public new event KeyEventHandler KeyDown; public new event MouseEventHandler MouseDown; public new event MouseEventHandler MouseUp; @@ -50,27 +52,28 @@ public MemoryList() InitializeComponent(); _highlightingContext = new HighlightingContext(listMemory); - listMemory.KeyDown += this.listMemory_KeyDown; - listMemory.MouseDown += this.listMemory_MouseDown; - listMemory.MouseUp += this.listMemory_MouseUp; + listMemory.KeyDown += new KeyEventHandler(listMemory_KeyDown); + listMemory.MouseDown += new MouseEventHandler(listMemory_MouseDown); + listMemory.MouseUp += new MouseEventHandler(listMemory_MouseUp); ColumnSettings.LoadSettings(Settings.Instance.MemoryListViewColumns, listMemory); listMemory.ContextMenu = menuMemory; GenericViewMenu.AddMenuItems(copyMemoryMenuItem.MenuItems, listMemory, null); listMemory.ListViewItemSorter = new SortedListViewComparer(listMemory) - { - SortColumn = 1, - SortOrder = SortOrder.Ascending - }; + { + SortColumn = 1, + SortOrder = SortOrder.Ascending + }; - (listMemory.ListViewItemSorter as SortedListViewComparer).CustomSorters.Add(2, (x, y) => - { - MemoryItem ix = (MemoryItem)x.Tag; - MemoryItem iy = (MemoryItem)y.Tag; + (listMemory.ListViewItemSorter as SortedListViewComparer).CustomSorters.Add(2, + (x, y) => + { + MemoryItem ix = (MemoryItem)x.Tag; + MemoryItem iy = (MemoryItem)y.Tag; - return ix.Size.CompareTo(iy.Size); - }); + return ix.Size.CompareTo(iy.Size); + }); } private void listMemory_MouseUp(object sender, MouseEventArgs e) @@ -92,20 +95,35 @@ private void listMemory_KeyDown(object sender, KeyEventArgs e) if (!e.Handled) { - switch (e.KeyCode) + if (e.KeyCode == Keys.Enter) { - case Keys.Enter: - this.readWriteMemoryMemoryMenuItem_Click(null, null); - break; + readWriteMemoryMemoryMenuItem_Click(null, null); } } } #region Properties + public new bool DoubleBuffered + { + get + { + return (bool)typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).GetValue(listMemory, null); + } + set + { + typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).SetValue(listMemory, value, null); + } + } + public override bool Focused { - get { return listMemory.Focused; } + get + { + return listMemory.Focused; + } } public override ContextMenu ContextMenu @@ -120,7 +138,7 @@ public override ContextMenuStrip ContextMenuStrip set { listMemory.ContextMenuStrip = value; } } - public ExtendedListView List + public ListView List { get { return listMemory; } } @@ -132,10 +150,10 @@ public MemoryProvider Provider { if (_provider != null) { - _provider.DictionaryAdded -= this.provider_DictionaryAdded; - _provider.DictionaryModified -= this.provider_DictionaryModified; - _provider.DictionaryRemoved -= this.provider_DictionaryRemoved; - _provider.Updated -= this.provider_Updated; + _provider.DictionaryAdded -= new MemoryProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryModified -= new MemoryProvider.ProviderDictionaryModified(provider_DictionaryModified); + _provider.DictionaryRemoved -= new MemoryProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated -= new MemoryProvider.ProviderUpdateOnce(provider_Updated); } _provider = value; @@ -145,10 +163,10 @@ public MemoryProvider Provider if (_provider != null) { - _provider.DictionaryAdded += this.provider_DictionaryAdded; - _provider.DictionaryModified += this.provider_DictionaryModified; - _provider.DictionaryRemoved += this.provider_DictionaryRemoved; - _provider.Updated += this.provider_Updated; + _provider.DictionaryAdded += new MemoryProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryModified += new MemoryProvider.ProviderDictionaryModified(provider_DictionaryModified); + _provider.DictionaryRemoved += new MemoryProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated += new MemoryProvider.ProviderUpdateOnce(provider_Updated); _pid = _provider.Pid; foreach (MemoryItem item in _provider.Dictionary.Values) @@ -190,7 +208,7 @@ private string GetProtectStr(MemoryProtection protect) string protectStr; if (protect == MemoryProtection.AccessDenied) - protectStr = string.Empty; + protectStr = ""; else if ((protect & MemoryProtection.Execute) != 0) protectStr = "X"; else if ((protect & MemoryProtection.ExecuteRead) != 0) @@ -222,34 +240,28 @@ private string GetProtectStr(MemoryProtection protect) private string GetStateStr(MemoryState state) { - switch (state) - { - case MemoryState.Commit: - return "Commit"; - case MemoryState.Free: - return "Free"; - case MemoryState.Reserve: - return "Reserve"; - case MemoryState.Reset: - return "Reset"; - default: - return "Unknown"; - } + if (state == MemoryState.Commit) + return "Commit"; + else if (state == MemoryState.Free) + return "Free"; + else if (state == MemoryState.Reserve) + return "Reserve"; + else if (state == MemoryState.Reset) + return "Reset"; + else + return "Unknown"; } private string GetTypeStr(MemoryType type) { - switch (type) - { - case MemoryType.Image: - return "Image"; - case MemoryType.Mapped: - return "Mapped"; - case MemoryType.Private: - return "Private"; - default: - return "Unknown"; - } + if (type == MemoryType.Image) + return "Image"; + else if (type == MemoryType.Mapped) + return "Mapped"; + else if (type == MemoryType.Private) + return "Private"; + else + return "Unknown"; } private void provider_Updated() @@ -289,27 +301,23 @@ private void provider_Updated() private void FillMemoryListViewItem(ListViewItem litem, MemoryItem item) { - switch (item.State) + if (item.State == MemoryState.Free) { - case MemoryState.Free: - litem.Text = "Free"; - break; - default: - if (item.Type == MemoryType.Image) - { - if (!string.IsNullOrEmpty(item.ModuleName)) - litem.Text = item.ModuleName; - else - litem.Text = "Image"; + litem.Text = "Free"; + } + else if (item.Type == MemoryType.Image) + { + if (item.ModuleName != null) + litem.Text = item.ModuleName; + else + litem.Text = "Image"; - litem.Text += " (" + this.GetStateStr(item.State) + ")"; - } - else - { - litem.Text = this.GetTypeStr(item.Type); - litem.Text += " (" + this.GetStateStr(item.State) + ")"; - } - break; + litem.Text += " (" + GetStateStr(item.State) + ")"; + } + else + { + litem.Text = GetTypeStr(item.Type); + litem.Text += " (" + GetStateStr(item.State) + ")"; } litem.SubItems[1].Text = Utils.FormatAddress(item.Address); @@ -322,14 +330,14 @@ private void provider_DictionaryAdded(MemoryItem item) { this.BeginInvoke(new MethodInvoker(() => { - HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, item.RunId > 0 && _runCount > 0) - { - Name = item.Address.ToString() - }; + HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, + item.RunId > 0 && _runCount > 0); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); + litem.Name = item.Address.ToString(); + + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); this.FillMemoryListViewItem(litem, item); @@ -340,34 +348,34 @@ private void provider_DictionaryAdded(MemoryItem item) private void provider_DictionaryModified(MemoryItem oldItem, MemoryItem newItem) { this.BeginInvoke(new MethodInvoker(() => - { - lock (listMemory) { - ListViewItem litem = listMemory.Items[newItem.Address.ToString()]; + lock (listMemory) + { + ListViewItem litem = listMemory.Items[newItem.Address.ToString()]; - if (litem != null) - this.FillMemoryListViewItem(litem, newItem); - } - })); + if (litem != null) + this.FillMemoryListViewItem(litem, newItem); + } + })); } private void provider_DictionaryRemoved(MemoryItem item) { this.BeginInvoke(new MethodInvoker(() => - { - lock (listMemory) { - // FIXME - try - { - listMemory.Items.RemoveByKey(item.Address.ToString()); - } - catch (Exception ex) + lock (listMemory) { - Logging.Log(ex); + // FIXME + try + { + listMemory.Items.RemoveByKey(item.Address.ToString()); + } + catch (Exception ex) + { + Logging.Log(ex); + } } - } - })); + })); } public void SaveSettings() @@ -397,7 +405,7 @@ private void menuMemory_Popup(object sender, EventArgs e) } else { - //menuMemory.DisableAll(); + menuMemory.DisableAll(); dumpMemoryMenuItem.Enabled = true; readWriteAddressMemoryMenuItem.Enabled = true; @@ -420,12 +428,10 @@ private void menuMemory_Popup(object sender, EventArgs e) private void changeMemoryProtectionMemoryMenuItem_Click(object sender, EventArgs e) { - MemoryItem item = listMemory.SelectedItems[0].Tag as MemoryItem; + MemoryItem item = (MemoryItem)listMemory.SelectedItems[0].Tag; + VirtualProtectWindow w = new VirtualProtectWindow(_pid, item.Address, item.Size); - using (VirtualProtectWindow w = new VirtualProtectWindow(_pid, item.Address, item.Size)) - { - w.ShowDialog(); - } + w.ShowDialog(); } private void readWriteMemoryMemoryMenuItem_Click(object sender, EventArgs e) @@ -433,42 +439,48 @@ private void readWriteMemoryMemoryMenuItem_Click(object sender, EventArgs e) if (listMemory.SelectedIndices.Count != 1) return; - MemoryItem item = listMemory.SelectedItems[0].Tag as MemoryItem; + MemoryItem item = (MemoryItem)listMemory.SelectedItems[0].Tag; MemoryEditor.ReadWriteMemory(_pid, item.Address, (int)item.Size, false); } private void dumpMemoryMenuItem_Click(object sender, EventArgs e) { - using (SaveFileDialog sfd = new SaveFileDialog - { - FileName = "Memory.bin", - Filter = "Binary Files (*.bin)|*.bin|All Files (*.*)|*.*" - }) + SaveFileDialog sfd = new SaveFileDialog(); + + sfd.FileName = "Memory.bin"; + sfd.Filter = "Binary Files (*.bin)|*.bin|All Files (*.*)|*.*"; + + if (sfd.ShowDialog() == DialogResult.OK) { - if (sfd.ShowDialog() == DialogResult.OK) + try { - try + using (var phandle = new ProcessHandle(_pid, ProcessAccess.VmRead)) + using (var fhandle = FileHandle.CreateWin32(sfd.FileName, FileAccess.GenericWrite, FileShareMode.Read)) { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.VmRead)) - using (FileHandle fhandle = FileHandle.CreateWin32(sfd.FileName, FileAccess.GenericWrite, FileShareMode.Read)) + foreach (ListViewItem litem in listMemory.SelectedItems) { - foreach (ListViewItem litem in listMemory.SelectedItems) - { - MemoryItem item = (MemoryItem)litem.Tag; + MemoryItem item = (MemoryItem)litem.Tag; - using (MemoryAlloc alloc = new MemoryAlloc((int)item.Size)) + using (MemoryAlloc alloc = new MemoryAlloc((int)item.Size)) + { + try { - phandle.ReadMemory(item.Address, (IntPtr)alloc, (int)item.Size); - fhandle.Write(alloc.Memory, (int)item.Size); + unsafe + { + phandle.ReadMemory(item.Address, (IntPtr)alloc, (int)item.Size); + fhandle.Write(alloc.Memory, (int)item.Size); + } } + catch (WindowsException) + { } } } } - catch (Exception ex) - { - PhUtils.ShowException("Unable to dump the selected memory regions", ex); - } + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to dump the selected memory regions", ex); } } } @@ -538,19 +550,14 @@ private void readWriteAddressMemoryMenuItem_Click(object sender, EventArgs e) return; } - MemoryEditor.ReadWriteMemory( - _pid, - regionAddress, - (int)regionSize, - false, - f => f.Select(address.Decrement(regionAddress).ToInt64(), 1) - ); + MemoryEditor m_e = MemoryEditor.ReadWriteMemory(_pid, regionAddress, (int)regionSize, false, + new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { f.Select(address.Decrement(regionAddress).ToInt64(), 1); })); } } private void selectAllMemoryMenuItem_Click(object sender, EventArgs e) { - this.listMemory.Items.SelectAll(); + Utils.SelectAll(listMemory.Items); } private void freeMenuItem_Click(object sender, EventArgs e) @@ -564,9 +571,10 @@ private void freeMenuItem_Click(object sender, EventArgs e) { try { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.VmOperation)) + using (var phandle = + new ProcessHandle(_pid, ProcessAccess.VmOperation)) { - MemoryItem item = listMemory.SelectedItems[0].Tag as MemoryItem; + MemoryItem item = (MemoryItem)listMemory.SelectedItems[0].Tag; phandle.FreeMemory(item.Address, (int)item.Size, false); } @@ -589,9 +597,10 @@ private void decommitMenuItem_Click(object sender, EventArgs e) { try { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.VmOperation)) + using (ProcessHandle phandle = + new ProcessHandle(_pid, ProcessAccess.VmOperation)) { - MemoryItem item = listMemory.SelectedItems[0].Tag as MemoryItem; + MemoryItem item = (MemoryItem)listMemory.SelectedItems[0].Tag; phandle.FreeMemory(item.Address, (int)item.Size, true); } diff --git a/1.x/trunk/ProcessHacker/Components/MemoryList.resx b/1.x/trunk/ProcessHacker/Components/MemoryList.resx index 5c63cffa4..c7d3b3761 100644 --- a/1.x/trunk/ProcessHacker/Components/MemoryList.resx +++ b/1.x/trunk/ProcessHacker/Components/MemoryList.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 + + 125, 17 + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/MenuStripEx.cs b/1.x/trunk/ProcessHacker/Components/MenuStripEx.cs deleted file mode 100644 index 218221483..000000000 --- a/1.x/trunk/ProcessHacker/Components/MenuStripEx.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Windows.Forms; - -namespace System -{ - /// - /// This class adds some missing functionality that should have been provided in System.Windows.Forms.MenuStrip. - /// - public class MenuStripEx : MenuStrip - { - private const uint WM_MOUSEACTIVATE = 0x21; - private static readonly IntPtr MA_ACTIVATE = new IntPtr(1); - private static readonly IntPtr MA_ACTIVATEANDEAT = new IntPtr(2); - private const uint MA_NOACTIVATE = 3; - private static readonly IntPtr MA_NOACTIVATEANDEAT = new IntPtr(4); - - private bool clickThrough = true; - - /// Gets or sets whether the ToolStripEx honors item clicks when its containing form does not have input focus. - /// Default value is true, which is the same behavior provided by the base ToolStrip class. - public bool ClickThrough - { - get { return this.clickThrough; } - set { this.clickThrough = value; } - } - - protected override void WndProc(ref Message m) - { - base.WndProc(ref m); - - if (this.clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == MA_ACTIVATEANDEAT) - { - m.Result = MA_ACTIVATE; - } - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/MessageLabel.Designer.cs b/1.x/trunk/ProcessHacker/Components/MessageLabel.Designer.cs index 3e7a7c74f..4317ba5ff 100644 --- a/1.x/trunk/ProcessHacker/Components/MessageLabel.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/MessageLabel.Designer.cs @@ -46,9 +46,9 @@ private void InitializeComponent() // // labelText // - this.labelText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelText.Location = new System.Drawing.Point(16, 0); this.labelText.Name = "labelText"; this.labelText.Size = new System.Drawing.Size(170, 17); @@ -58,7 +58,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.labelText); this.Controls.Add(this.pictureIcon); this.Name = "MessageLabel"; diff --git a/1.x/trunk/ProcessHacker/Components/MessageLabel.cs b/1.x/trunk/ProcessHacker/Components/MessageLabel.cs index 10b29f6de..bd941c4f2 100644 --- a/1.x/trunk/ProcessHacker/Components/MessageLabel.cs +++ b/1.x/trunk/ProcessHacker/Components/MessageLabel.cs @@ -1,6 +1,9 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; +using System.Data; +using System.Text; using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Native.Api; @@ -27,9 +30,11 @@ public MessageLabelIcon Icon get { return _icon; } set { + Image oldImage; + _icon = value; - Image oldImage = this.pictureIcon.Image; + oldImage = pictureIcon.Image; pictureIcon.Image = this.GetBitmap(_icon); diff --git a/1.x/trunk/ProcessHacker/Components/MessageLabel.resx b/1.x/trunk/ProcessHacker/Components/MessageLabel.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/MessageLabel.resx +++ b/1.x/trunk/ProcessHacker/Components/MessageLabel.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/ModuleList.Designer.cs b/1.x/trunk/ProcessHacker/Components/ModuleList.Designer.cs index 3ae00532a..05a595408 100644 --- a/1.x/trunk/ProcessHacker/Components/ModuleList.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/ModuleList.Designer.cs @@ -32,11 +32,12 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.listModules = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnBaseAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnDesc = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.components = new System.ComponentModel.Container(); + this.listModules = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnBaseAddress = new System.Windows.Forms.ColumnHeader(); + this.columnSize = new System.Windows.Forms.ColumnHeader(); + this.columnDesc = new System.Windows.Forms.ColumnHeader(); this.changeMemoryProtectionModuleMenuItem = new System.Windows.Forms.MenuItem(); this.readMemoryModuleMenuItem = new System.Windows.Forms.MenuItem(); this.inspectModuleMenuItem = new System.Windows.Forms.MenuItem(); @@ -51,6 +52,8 @@ private void InitializeComponent() this.copyFileNameMenuItem = new System.Windows.Forms.MenuItem(); this.menuItem6 = new System.Windows.Forms.MenuItem(); this.selectAllModuleMenuItem = new System.Windows.Forms.MenuItem(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // listModules @@ -62,7 +65,6 @@ private void InitializeComponent() this.columnSize, this.columnDesc}); this.listModules.Dock = System.Windows.Forms.DockStyle.Fill; - this.listModules.DoubleClickChecks = true; this.listModules.FullRowSelect = true; this.listModules.HideSelection = false; this.listModules.Location = new System.Drawing.Point(0, 0); @@ -96,41 +98,48 @@ private void InitializeComponent() // // changeMemoryProtectionModuleMenuItem // + this.vistaMenu.SetImage(this.changeMemoryProtectionModuleMenuItem, global::ProcessHacker.Properties.Resources.lock_edit); this.changeMemoryProtectionModuleMenuItem.Index = 0; this.changeMemoryProtectionModuleMenuItem.Text = "Change &Memory Protection..."; this.changeMemoryProtectionModuleMenuItem.Click += new System.EventHandler(this.changeMemoryProtectionModuleMenuItem_Click); // // readMemoryModuleMenuItem // + this.vistaMenu.SetImage(this.readMemoryModuleMenuItem, global::ProcessHacker.Properties.Resources.page); this.readMemoryModuleMenuItem.Index = 2; this.readMemoryModuleMenuItem.Text = "Read Memory"; this.readMemoryModuleMenuItem.Click += new System.EventHandler(this.readMemoryModuleMenuItem_Click); // // inspectModuleMenuItem // + this.vistaMenu.SetImage(this.inspectModuleMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify); this.inspectModuleMenuItem.Index = 5; this.inspectModuleMenuItem.Text = "&Inspect"; this.inspectModuleMenuItem.Click += new System.EventHandler(this.inspectModuleMenuItem_Click); // // copyModuleMenuItem // + this.vistaMenu.SetImage(this.copyModuleMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyModuleMenuItem.Index = 8; this.copyModuleMenuItem.Text = "Copy"; // // openContainingFolderMenuItem // + this.vistaMenu.SetImage(this.openContainingFolderMenuItem, global::ProcessHacker.Properties.Resources.folder_explore); this.openContainingFolderMenuItem.Index = 9; this.openContainingFolderMenuItem.Text = "&Open Containing Folder"; this.openContainingFolderMenuItem.Click += new System.EventHandler(this.openContainingFolderMenuItem_Click); // // propertiesMenuItem // + this.vistaMenu.SetImage(this.propertiesMenuItem, global::ProcessHacker.Properties.Resources.application_view_detail); this.propertiesMenuItem.Index = 10; this.propertiesMenuItem.Text = "Prope&rties"; this.propertiesMenuItem.Click += new System.EventHandler(this.propertiesMenuItem_Click); // // unloadMenuItem // + this.vistaMenu.SetImage(this.unloadMenuItem, global::ProcessHacker.Properties.Resources.cross); this.unloadMenuItem.Index = 3; this.unloadMenuItem.Text = "&Unload"; this.unloadMenuItem.Click += new System.EventHandler(this.unloadMenuItem_Click); @@ -187,24 +196,32 @@ private void InitializeComponent() this.selectAllModuleMenuItem.Text = "Select &All"; this.selectAllModuleMenuItem.Click += new System.EventHandler(this.selectAllModuleMenuItem_Click); // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // ModuleList // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listModules); + this.DoubleBuffered = true; this.Name = "ModuleList"; this.Size = new System.Drawing.Size(450, 472); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); + } #endregion - private ExtendedListView listModules; + private System.Windows.Forms.ListView listModules; private System.Windows.Forms.ColumnHeader columnBaseAddress; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnSize; private System.Windows.Forms.ColumnHeader columnDesc; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.ContextMenu menuModule; private System.Windows.Forms.MenuItem getFuncAddressMenuItem; private System.Windows.Forms.MenuItem changeMemoryProtectionModuleMenuItem; diff --git a/1.x/trunk/ProcessHacker/Components/ModuleList.cs b/1.x/trunk/ProcessHacker/Components/ModuleList.cs index d6a001191..4e4f2d72c 100644 --- a/1.x/trunk/ProcessHacker/Components/ModuleList.cs +++ b/1.x/trunk/ProcessHacker/Components/ModuleList.cs @@ -24,6 +24,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Reflection; using System.Windows.Forms; using Microsoft.Win32; using ProcessHacker.Common; @@ -39,9 +40,9 @@ namespace ProcessHacker.Components public partial class ModuleList : UserControl { private ModuleProvider _provider; - private int _runCount; - private readonly List _needsAdd = new List(); - private readonly HighlightingContext _highlightingContext; + private int _runCount = 0; + private List _needsAdd = new List(); + private HighlightingContext _highlightingContext; public new event KeyEventHandler KeyDown; public new event MouseEventHandler MouseDown; public new event MouseEventHandler MouseUp; @@ -54,10 +55,10 @@ public ModuleList() InitializeComponent(); _highlightingContext = new HighlightingContext(listModules); - listModules.KeyDown += this.ModuleList_KeyDown; - listModules.MouseDown += this.listModules_MouseDown; - listModules.MouseUp += this.listModules_MouseUp; - listModules.DoubleClick += this.listModules_DoubleClick; + listModules.KeyDown += new KeyEventHandler(ModuleList_KeyDown); + listModules.MouseDown += new MouseEventHandler(listModules_MouseDown); + listModules.MouseUp += new MouseEventHandler(listModules_MouseUp); + listModules.DoubleClick += new EventHandler(listModules_DoubleClick); ColumnSettings.LoadSettings(Settings.Instance.ModuleListViewColumns, listModules); listModules.ContextMenu = menuModule; @@ -90,6 +91,20 @@ private void ModuleList_KeyDown(object sender, KeyEventArgs e) #region Properties + public new bool DoubleBuffered + { + get + { + return (bool)typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).GetValue(listModules, null); + } + set + { + typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).SetValue(listModules, value, null); + } + } + public override bool Focused { get @@ -110,7 +125,7 @@ public override ContextMenuStrip ContextMenuStrip set { listModules.ContextMenuStrip = value; } } - public ExtendedListView List + public ListView List { get { return listModules; } } @@ -122,9 +137,9 @@ public ModuleProvider Provider { if (_provider != null) { - _provider.DictionaryAdded -= this.provider_DictionaryAdded; - _provider.DictionaryRemoved -= this.provider_DictionaryRemoved; - _provider.Updated -= this.provider_Updated; + _provider.DictionaryAdded -= new ModuleProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryRemoved -= new ModuleProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated -= new ModuleProvider.ProviderUpdateOnce(provider_Updated); } _provider = value; @@ -141,9 +156,9 @@ public ModuleProvider Provider provider_DictionaryAdded(item); } - _provider.DictionaryAdded += this.provider_DictionaryAdded; - _provider.DictionaryRemoved += this.provider_DictionaryRemoved; - _provider.Updated += this.provider_Updated; + _provider.DictionaryAdded += new ModuleProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryRemoved += new ModuleProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated += new ModuleProvider.ProviderUpdateOnce(provider_Updated); _pid = _provider.Pid; try @@ -154,8 +169,10 @@ public ModuleProvider Provider } else { - using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) - _mainModule = FileUtils.GetFileName(phandle.MainModule.FileName); + using (var phandle = + new ProcessHandle(_pid, + Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) + _mainModule = FileUtils.GetFileName(phandle.GetMainModule().FileName); } this.SetMainModule(_mainModule); @@ -246,12 +263,12 @@ private Color GetModuleColor(ModuleItem item) (item.Flags & LdrpDataTableEntryFlags.CorImage) != 0 ) return Settings.Instance.ColorDotNetProcesses; - if (Settings.Instance.UseColorRelocatedDlls && + else if (Settings.Instance.UseColorRelocatedDlls && (item.Flags & LdrpDataTableEntryFlags.ImageNotAtBase) != 0 ) return Settings.Instance.ColorRelocatedDlls; - - return SystemColors.Window; + else + return SystemColors.Window; } public void AddItem(ModuleItem item) @@ -270,22 +287,22 @@ public void DumpSetMainModule(string mainModule) } private void provider_DictionaryAdded(ModuleItem item) - { - HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, item.RunId > 0 && _runCount > 0) - { - Name = item.BaseAddress.ToString(), - Text = item.Name - }; + { + HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, + item.RunId > 0 && _runCount > 0); + litem.Name = item.BaseAddress.ToString(); + litem.Text = item.Name; litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, Utils.FormatAddress(item.BaseAddress))); litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, Utils.FormatSize(item.Size))); litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.FileDescription)); - litem.ToolTipText = PhUtils.FormatFileInfo(item.FileName, item.FileDescription, item.FileCompanyName, item.FileVersion, 0); + litem.ToolTipText = PhUtils.FormatFileInfo( + item.FileName, item.FileDescription, item.FileCompanyName, item.FileVersion, 0); litem.Tag = item; litem.NormalColor = this.GetModuleColor(item); if (item.FileName.Equals(_mainModule, StringComparison.OrdinalIgnoreCase)) - litem.Font = new Font(litem.Font, FontStyle.Bold); + litem.Font = new System.Drawing.Font(litem.Font, System.Drawing.FontStyle.Bold); lock (_needsAdd) _needsAdd.Add(litem); @@ -293,7 +310,10 @@ private void provider_DictionaryAdded(ModuleItem item) private void provider_DictionaryRemoved(ModuleItem item) { - this.BeginInvoke(new MethodInvoker(() => this.listModules.Items[item.BaseAddress.ToString()].Remove())); + this.BeginInvoke(new MethodInvoker(() => + { + listModules.Items[item.BaseAddress.ToString()].Remove(); + })); } public void SaveSettings() @@ -312,9 +332,9 @@ private void menuModule_Popup(object sender, EventArgs e) { if (_pid == 4) { - //menuModule.DisableAll(); + menuModule.DisableAll(); - //if (KProcessHacker.Instance != null) + if (KProcessHacker.Instance != null) unloadMenuItem.Enabled = true; inspectModuleMenuItem.Enabled = true; @@ -331,7 +351,7 @@ private void menuModule_Popup(object sender, EventArgs e) } else { - // menuModule.DisableAll(); + menuModule.DisableAll(); if (listModules.SelectedItems.Count > 1) { @@ -365,7 +385,7 @@ private void searchModuleMenuItem_Click(object sender, EventArgs e) private void copyFileNameMenuItem_Click(object sender, EventArgs e) { - string text = string.Empty; + string text = ""; for (int i = 0; i < listModules.SelectedItems.Count; i++) { @@ -399,14 +419,22 @@ private void inspectModuleMenuItem_Click(object sender, EventArgs e) { try { - Program.GetPEWindow(this.GetItemFileName(listModules.SelectedItems[0]), f => - { - if (!f.IsDisposed) + PEWindow pw = Program.GetPEWindow(this.GetItemFileName(listModules.SelectedItems[0]), + new Program.PEWindowInvokeAction(delegate(PEWindow f) { - f.Show(); - f.Activate(); - } - }); + if (!f.IsDisposed) + { + try + { + f.Show(); + f.Activate(); + } + catch (Exception ex) + { + Logging.Log(ex); + } + } + })); } catch (Exception ex) { @@ -416,32 +444,30 @@ private void inspectModuleMenuItem_Click(object sender, EventArgs e) private void getFuncAddressMenuItem_Click(object sender, EventArgs e) { - using (GetProcAddressWindow gpaWindow = new GetProcAddressWindow(this.GetItemFileName(listModules.SelectedItems[0]))) - { - gpaWindow.ShowDialog(); - } + GetProcAddressWindow gpaWindow = new GetProcAddressWindow( + this.GetItemFileName(listModules.SelectedItems[0])); + + gpaWindow.ShowDialog(); } private void changeMemoryProtectionModuleMenuItem_Click(object sender, EventArgs e) { - ModuleItem item = this.listModules.SelectedItems[0].Tag as ModuleItem; - - using (VirtualProtectWindow w = new VirtualProtectWindow(_pid, item.BaseAddress.ToIntPtr(), item.Size)) - { - w.ShowDialog(); - } + ModuleItem item = (ModuleItem)listModules.SelectedItems[0].Tag; + VirtualProtectWindow w = new VirtualProtectWindow(_pid, item.BaseAddress.ToIntPtr(), item.Size); + + w.ShowDialog(); } private void readMemoryModuleMenuItem_Click(object sender, EventArgs e) { - ModuleItem item = this.listModules.SelectedItems[0].Tag as ModuleItem; + ModuleItem item = (ModuleItem)listModules.SelectedItems[0].Tag; MemoryEditor.ReadWriteMemory(_pid, item.BaseAddress.ToIntPtr(), item.Size, true); } private void selectAllModuleMenuItem_Click(object sender, EventArgs e) { - this.listModules.Items.SelectAll(); + Utils.SelectAll(listModules.Items); } private void unloadMenuItem_Click(object sender, EventArgs e) @@ -460,23 +486,23 @@ private void unloadMenuItem_Click(object sender, EventArgs e) { try { - ModuleItem moduleItem = listModules.SelectedItems[0].Tag as ModuleItem; + var moduleItem = (ModuleItem)listModules.SelectedItems[0].Tag; string serviceName = null; // Try to find the name of the service key for the driver by // looping through the objects in the Driver directory and // opening each one. - using (DirectoryHandle dhandle = new DirectoryHandle("\\Driver", DirectoryAccess.Query)) + using (var dhandle = new DirectoryHandle("\\Driver", DirectoryAccess.Query)) { - foreach (DirectoryHandle.ObjectEntry obj in dhandle.GetObjects()) + foreach (var obj in dhandle.GetObjects()) { try { - using (DriverHandle driverHandle = new DriverHandle("\\Driver\\" + obj.Name)) + using (var driverHandle = new DriverHandle("\\Driver\\" + obj.Name)) { - if (driverHandle.BasicInformation.DriverStart == moduleItem.BaseAddress.ToIntPtr()) + if (driverHandle.GetBasicInformation().DriverStart == moduleItem.BaseAddress.ToIntPtr()) { - serviceName = driverHandle.ServiceKeyName; + serviceName = driverHandle.GetServiceKeyName(); break; } } @@ -487,7 +513,7 @@ private void unloadMenuItem_Click(object sender, EventArgs e) } // If we didn't find the service name, use the driver base name. - if (string.IsNullOrEmpty(serviceName)) + if (serviceName == null) { if (moduleItem.Name.EndsWith(".sys", StringComparison.OrdinalIgnoreCase)) serviceName = moduleItem.Name.Remove(moduleItem.Name.Length - 4, 4); @@ -495,13 +521,15 @@ private void unloadMenuItem_Click(object sender, EventArgs e) serviceName = moduleItem.Name; } - RegistryKey servicesKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services", true); + RegistryKey servicesKey = + Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services", true); bool serviceKeyCreated; RegistryKey serviceKey; // Check if the service key exists so that we don't delete it // later if it does. - if (Array.Exists(servicesKey.GetSubKeyNames(), keyName => string.Compare(keyName, serviceName, true) == 0)) + if (Array.Exists(servicesKey.GetSubKeyNames(), + (keyName) => (string.Compare(keyName, serviceName, true) == 0))) { serviceKeyCreated = false; } @@ -544,10 +572,11 @@ private void unloadMenuItem_Click(object sender, EventArgs e) { try { - using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights | ProcessAccess.VmOperation | + using (ProcessHandle phandle = new ProcessHandle(_pid, + Program.MinProcessQueryRights | ProcessAccess.VmOperation | ProcessAccess.VmRead | ProcessAccess.VmWrite | ProcessAccess.CreateThread)) { - IntPtr baseAddress = (listModules.SelectedItems[0].Tag as ModuleItem).BaseAddress.ToIntPtr(); + IntPtr baseAddress = ((ModuleItem)listModules.SelectedItems[0].Tag).BaseAddress.ToIntPtr(); phandle.SetModuleReferenceCount(baseAddress, 1); @@ -579,11 +608,13 @@ private void unloadMenuItem_Click(object sender, EventArgs e) { if (OSVersion.Architecture == OSArch.Amd64) { - PhUtils.ShowError("Unable to find the module to unload. This may be caused by an attempt to unload a mapped file or a 32-bit module."); + PhUtils.ShowError("Unable to find the module to unload. This may be caused " + + "by an attempt to unload a mapped file or a 32-bit module."); } else { - PhUtils.ShowError("Unable to find the module to unload. This may be caused by an attempt to unload a mapped file."); + PhUtils.ShowError("Unable to find the module to unload. This may be caused " + + "by an attempt to unload a mapped file."); } } else @@ -606,7 +637,7 @@ private void unloadMenuItem_Click(object sender, EventArgs e) public class ModuleListComparer : ISortedListViewComparer { - private readonly string _mainModule; + private string _mainModule; public ModuleListComparer(string mainModule) { @@ -615,8 +646,8 @@ public ModuleListComparer(string mainModule) public int Compare(ListViewItem x, ListViewItem y, int column) { - ModuleItem mx = x.Tag as ModuleItem; - ModuleItem my = y.Tag as ModuleItem; + ModuleItem mx = (ModuleItem)x.Tag; + ModuleItem my = (ModuleItem)y.Tag; if (mx.FileName.Equals(_mainModule, StringComparison.OrdinalIgnoreCase)) return -1; diff --git a/1.x/trunk/ProcessHacker/Components/ModuleList.resx b/1.x/trunk/ProcessHacker/Components/ModuleList.resx index 3863ef654..70244693e 100644 --- a/1.x/trunk/ProcessHacker/Components/ModuleList.resx +++ b/1.x/trunk/ProcessHacker/Components/ModuleList.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + 17, 17 + + 120, 20 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/MutantProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/MutantProperties.Designer.cs index cd693c704..9fccd3850 100644 --- a/1.x/trunk/ProcessHacker/Components/MutantProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/MutantProperties.Designer.cs @@ -44,7 +44,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 3); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(84, 13); + this.label1.Size = new System.Drawing.Size(75, 13); this.label1.TabIndex = 0; this.label1.Text = "Current Count:"; // @@ -53,7 +53,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 26); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(71, 13); + this.label3.Size = new System.Drawing.Size(65, 13); this.label3.TabIndex = 0; this.label3.Text = "Abandoned:"; // @@ -71,7 +71,7 @@ private void InitializeComponent() this.labelAbandoned.AutoSize = true; this.labelAbandoned.Location = new System.Drawing.Point(102, 26); this.labelAbandoned.Name = "labelAbandoned"; - this.labelAbandoned.Size = new System.Drawing.Size(33, 13); + this.labelAbandoned.Size = new System.Drawing.Size(32, 13); this.labelAbandoned.TabIndex = 0; this.labelAbandoned.Text = "False"; // @@ -80,14 +80,14 @@ private void InitializeComponent() this.labelLabelOwner.AutoSize = true; this.labelLabelOwner.Location = new System.Drawing.Point(6, 49); this.labelLabelOwner.Name = "labelLabelOwner"; - this.labelLabelOwner.Size = new System.Drawing.Size(45, 13); + this.labelLabelOwner.Size = new System.Drawing.Size(41, 13); this.labelLabelOwner.TabIndex = 1; this.labelLabelOwner.Text = "Owner:"; // // labelOwner // - this.labelOwner.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelOwner.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelOwner.AutoEllipsis = true; this.labelOwner.Location = new System.Drawing.Point(102, 49); this.labelOwner.Name = "labelOwner"; @@ -99,7 +99,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.labelOwner); this.Controls.Add(this.labelLabelOwner); this.Controls.Add(this.label3); diff --git a/1.x/trunk/ProcessHacker/Components/MutantProperties.cs b/1.x/trunk/ProcessHacker/Components/MutantProperties.cs index b0f1efe57..374225f07 100644 --- a/1.x/trunk/ProcessHacker/Components/MutantProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/MutantProperties.cs @@ -1,13 +1,12 @@ using System.Windows.Forms; using ProcessHacker.Native; -using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; namespace ProcessHacker.Components { public partial class MutantProperties : UserControl { - private readonly MutantHandle _mutantHandle; + private MutantHandle _mutantHandle; public MutantProperties(MutantHandle mutantHandle) { @@ -21,7 +20,7 @@ public MutantProperties(MutantHandle mutantHandle) private void UpdateInfo() { - MutantBasicInformation basicInfo = _mutantHandle.BasicInformation; + var basicInfo = _mutantHandle.GetBasicInformation(); labelCurrentCount.Text = basicInfo.CurrentCount.ToString(); labelAbandoned.Text = basicInfo.AbandonedState.ToString(); @@ -29,7 +28,7 @@ private void UpdateInfo() // Windows Vista and above have owner information. if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) { - MutantOwnerInformation ownerInfo = _mutantHandle.OwnerInformation; + var ownerInfo = _mutantHandle.GetOwnerInformation(); if (ownerInfo.ClientId.ProcessId != 0) { diff --git a/1.x/trunk/ProcessHacker/Components/MutantProperties.resx b/1.x/trunk/ProcessHacker/Components/MutantProperties.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/MutantProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/MutantProperties.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/NetworkList.Designer.cs b/1.x/trunk/ProcessHacker/Components/NetworkList.Designer.cs index 5226dd496..9d62847ce 100644 --- a/1.x/trunk/ProcessHacker/Components/NetworkList.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/NetworkList.Designer.cs @@ -34,14 +34,14 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NetworkList)); - this.listNetwork = new ProcessHacker.Components.ExtendedListView(); - this.columnProcess = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnLocal = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnLocalPort = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnRemote = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnRemotePort = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnProtocol = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnState = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listNetwork = new System.Windows.Forms.ListView(); + this.columnProcess = new System.Windows.Forms.ColumnHeader(); + this.columnLocal = new System.Windows.Forms.ColumnHeader(); + this.columnLocalPort = new System.Windows.Forms.ColumnHeader(); + this.columnRemote = new System.Windows.Forms.ColumnHeader(); + this.columnRemotePort = new System.Windows.Forms.ColumnHeader(); + this.columnProtocol = new System.Windows.Forms.ColumnHeader(); + this.columnState = new System.Windows.Forms.ColumnHeader(); this.imageList = new System.Windows.Forms.ImageList(this.components); this.SuspendLayout(); // @@ -57,7 +57,6 @@ private void InitializeComponent() this.columnProtocol, this.columnState}); this.listNetwork.Dock = System.Windows.Forms.DockStyle.Fill; - this.listNetwork.DoubleClickChecks = true; this.listNetwork.FullRowSelect = true; this.listNetwork.HideSelection = false; this.listNetwork.Location = new System.Drawing.Point(0, 0); @@ -115,8 +114,8 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listNetwork); + this.DoubleBuffered = true; this.Name = "NetworkList"; this.Size = new System.Drawing.Size(685, 472); this.ResumeLayout(false); @@ -125,7 +124,7 @@ private void InitializeComponent() #endregion - private ExtendedListView listNetwork; + private System.Windows.Forms.ListView listNetwork; private System.Windows.Forms.ColumnHeader columnLocal; private System.Windows.Forms.ColumnHeader columnRemote; private System.Windows.Forms.ColumnHeader columnRemotePort; diff --git a/1.x/trunk/ProcessHacker/Components/NetworkList.cs b/1.x/trunk/ProcessHacker/Components/NetworkList.cs index 73c67c7e0..5e69f9658 100644 --- a/1.x/trunk/ProcessHacker/Components/NetworkList.cs +++ b/1.x/trunk/ProcessHacker/Components/NetworkList.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Reflection; using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Common.Ui; @@ -33,11 +34,11 @@ namespace ProcessHacker.Components public partial class NetworkList : UserControl { private NetworkProvider _provider; - private int _runCount; - private readonly List _needsAdd = new List(); - private readonly HighlightingContext _highlightingContext; - private bool _needsSort; - private bool _needsImageKeyReset; + private int _runCount = 0; + private List _needsAdd = new List(); + private HighlightingContext _highlightingContext; + private bool _needsSort = false; + private bool _needsImageKeyReset = false; public new event KeyEventHandler KeyDown; public new event MouseEventHandler MouseDown; public new event MouseEventHandler MouseMove; @@ -50,14 +51,14 @@ public NetworkList() InitializeComponent(); _highlightingContext = new HighlightingContext(listNetwork); - + listNetwork.SetTheme("explorer"); listNetwork.ListViewItemSorter = new SortedListViewComparer(listNetwork); - listNetwork.KeyDown += this.NetworkList_KeyDown; - listNetwork.MouseDown += this.listNetwork_MouseDown; - listNetwork.MouseMove += this.listNetwork_MouseMove; - listNetwork.MouseUp += this.listNetwork_MouseUp; - listNetwork.DoubleClick += this.listNetwork_DoubleClick; - listNetwork.SelectedIndexChanged += this.listNetwork_SelectedIndexChanged; + listNetwork.KeyDown += new KeyEventHandler(NetworkList_KeyDown); + listNetwork.MouseDown += new MouseEventHandler(listNetwork_MouseDown); + listNetwork.MouseMove += new MouseEventHandler(listNetwork_MouseMove); + listNetwork.MouseUp += new MouseEventHandler(listNetwork_MouseUp); + listNetwork.DoubleClick += new EventHandler(listNetwork_DoubleClick); + listNetwork.SelectedIndexChanged += new System.EventHandler(listNetwork_SelectedIndexChanged); } private void listNetwork_DoubleClick(object sender, EventArgs e) @@ -95,7 +96,7 @@ private void listNetwork_MouseMove(object sender, MouseEventArgs e) } } - private void listNetwork_SelectedIndexChanged(object sender, EventArgs e) + private void listNetwork_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.SelectedIndexChanged != null) this.SelectedIndexChanged(sender, e); @@ -109,6 +110,20 @@ private void NetworkList_KeyDown(object sender, KeyEventArgs e) #region Properties + public new bool DoubleBuffered + { + get + { + return (bool)typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).GetValue(listNetwork, null); + } + set + { + typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).SetValue(listNetwork, value, null); + } + } + public override bool Focused { get @@ -161,10 +176,10 @@ public NetworkProvider Provider provider_DictionaryAdded(item); } - _provider.DictionaryAdded += this.provider_DictionaryAdded; - _provider.DictionaryModified += this.provider_DictionaryModified; - _provider.DictionaryRemoved += this.provider_DictionaryRemoved; - _provider.Updated += this.provider_Updated; + _provider.DictionaryAdded += new NetworkProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryModified += new NetworkProvider.ProviderDictionaryModified(provider_DictionaryModified); + _provider.DictionaryRemoved += new NetworkProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated += new NetworkProvider.ProviderUpdateOnce(provider_Updated); } } } @@ -222,7 +237,7 @@ private void ResetImageKeys() { string t = lvItem.ImageKey; - lvItem.ImageKey = string.Empty; + lvItem.ImageKey = ""; lvItem.ImageKey = t; } } @@ -342,11 +357,10 @@ private void FillNetworkItemAddresses(ListViewItem litem, NetworkItem item) private void provider_DictionaryAdded(NetworkItem item) { - HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, item.Tag > 0 && _runCount > 0) - { - Name = item.Id, - Tag = item - }; + HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, (int)item.Tag > 0 && _runCount > 0); + + litem.Name = item.Id; + litem.Tag = item; Icon icon = null; @@ -394,8 +408,8 @@ private void provider_DictionaryAdded(NetworkItem item) } else { - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); } if (item.Connection.Remote != null && !item.Connection.Remote.IsEmpty()) @@ -405,14 +419,14 @@ private void provider_DictionaryAdded(NetworkItem item) } else { - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); } this.FillNetworkItemAddresses(litem, item); litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Connection.Protocol.ToString().ToUpper())); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Connection.State != 0 ? item.Connection.State.ToString() : string.Empty)); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Connection.State != 0 ? item.Connection.State.ToString() : "")); lock (_needsAdd) _needsAdd.Add(litem); @@ -432,7 +446,7 @@ private void provider_DictionaryModified(NetworkItem oldItem, NetworkItem newIte this.FillNetworkItemAddresses(litem, newItem); - litem.SubItems[6].Text = newItem.Connection.State != 0 ? newItem.Connection.State.ToString() : string.Empty; + litem.SubItems[6].Text = newItem.Connection.State != 0 ? newItem.Connection.State.ToString() : ""; _needsSort = true; } })); diff --git a/1.x/trunk/ProcessHacker/Components/NetworkList.resx b/1.x/trunk/ProcessHacker/Components/NetworkList.resx index 253cdb668..c680ceefe 100644 --- a/1.x/trunk/ProcessHacker/Components/NetworkList.resx +++ b/1.x/trunk/ProcessHacker/Components/NetworkList.resx @@ -112,40 +112,40 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACc - BQAAAk1TRnQBSQFMAwEBAAEkAQABJAEAARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMA + BQAAAk1TRnQBSQFMAwEBAAEcAQABHAEAARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMA ARADAAEBAQABIAYAARD/AP8AFAABlwGSAY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGSAY8B/wGXAZIBjwH/ AZcBkgGPAf8BlwGSAY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGSAY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGS AY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGSAY8B/8AAAZcBkgGPCf8D/gH/A/wB/wP6Af8D+AH/A/UB/wPz Af8D8QH/A+4B/wPsAf8D6QH/A+gB/wPmAf8BlwGSAY8B/8AAAZcBkgGPCf8D/gH/A/wB/wP6Af8D+AH/ - A/UB/wP1Af8D8wH/A/AB/wPuAf8D6wH/A+kB/wPnAf8BlwGSAY8B/8AAAZcBkgGPBf8BhwGdAU0B/wGC - AaIBUQH/AXUBqAFVAf8BbwGtAVkB/wFrAbEBXQH/A/cB/wHNAcwBygH/Ac0BzAHKAf8BzQHMAcoB/wHN - AcwBygH/A+0B/wPrAf8D6AH/AZcBkgGPAf/AAAGXAZIBjwX/AY0BlAFHAf8BiQGaAUsB/wGEAaABTwH/ - AXcBpQFTAf8BcgGqAVcB/wP5Af8D9gH/A/QB/wP0Af8D8QH/A+8B/wPsAf8D6gH/AZcBkgGPAf/AAAGX - AZIBjwX/AZMBiQFCAf8BjwGQAUUB/wGLAZcBSQH/AYcBnQFNAf8BggGiAVEB/wP7Af8BzQHMAcoB/wHN - AcwBygH/Ac0BzAHKAf8BzQHMAcoB/wPxAf8BcwGpAVYB/wPsAf8BlwGSAY8B/8AAAZcBkgGPBf8BmAF0 - ATwB/wGVAYQBQAH/AZEBjAFDAf8BjQGUAUcB/wGJAZoBSwH/A/wB/wP6Af8D+AH/A/gB/wP1Af8D8wH/ - AYsBlwFJAf8D7gH/AZcBkgGPAf/AAAGXAZIBjwX/AZ0BagE3Af8BmgFxAToB/wGWAYABPgH/AZMBiQFC - Af8BjwGQAUUB/wP9Af8BzQHMAcoB/wHNAcwBygH/Ac0BzAHKAf8BzQHMAcoB/wP1Af8BlwF2AT0B/wPv - Af8BlwGSAY8B/8AAAZcBkgGPBf8BoAFiATQB/wGeAWcBNgH/AZsBbQE5Af8BmAF0ATwB/wGVAYQBQAH/ - A/4B/wP+Af8D/QH/A/sB/wP5Af8D9gH/AaABYgE0Af8D8QH/AZcBkgGPAf/AAAGXAZIBjxn/A/4B/wP+ + A/UB/wP1Af8D8wH/A/AB/wPuAf8D6wH/A+kB/wPnAf8BlwGSAY8B/8AAAZcBkgGPBf8BhwGdAU4B/wGC + AaIBUgH/AXYBqAFWAf8BcAGtAVoB/wFsAbEBXgH/A/cB/wHNAcwBygH/Ac0BzAHKAf8BzQHMAcoB/wHN + AcwBygH/A+0B/wPrAf8D6AH/AZcBkgGPAf/AAAGXAZIBjwX/AY0BlAFIAf8BiQGaAUwB/wGEAaABUAH/ + AXgBpQFUAf8BcwGqAVgB/wP5Af8D9gH/A/QB/wP0Af8D8QH/A+8B/wPsAf8D6gH/AZcBkgGPAf/AAAGX + AZIBjwX/AZMBiQFDAf8BjwGQAUYB/wGLAZcBSgH/AYcBnQFOAf8BggGiAVIB/wP7Af8BzQHMAcoB/wHN + AcwBygH/Ac0BzAHKAf8BzQHMAcoB/wPxAf8BdAGpAVcB/wPsAf8BlwGSAY8B/8AAAZcBkgGPBf8BmAF1 + AT0B/wGVAYQBQQH/AZEBjAFEAf8BjQGUAUgB/wGJAZoBTAH/A/wB/wP6Af8D+AH/A/gB/wP1Af8D8wH/ + AYsBlwFKAf8D7gH/AZcBkgGPAf/AAAGXAZIBjwX/AZ0BawE4Af8BmgFyATsB/wGWAYABPwH/AZMBiQFD + Af8BjwGQAUYB/wP9Af8BzQHMAcoB/wHNAcwBygH/Ac0BzAHKAf8BzQHMAcoB/wP1Af8BlwF3AT4B/wPv + Af8BlwGSAY8B/8AAAZcBkgGPBf8BoAFjATUB/wGeAWgBNwH/AZsBbgE6Af8BmAF1AT0B/wGVAYQBQQH/ + A/4B/wP+Af8D/QH/A/sB/wP5Af8D9gH/AaABYwE1Af8D8QH/AZcBkgGPAf/AAAGXAZIBjxn/A/4B/wP+ Af8D/QH/A/sB/wP5Af8D9gH/A/QB/wPxAf8BlwGSAY8B/8AAAZcBkgGPAf8BzQHMAcoB/wHNAcwBygH/ Ac0BzAHKAf8BzQHMAcoB/wHNAcwBygH/Ac0BzAHKAf8BzQHMAcoB/wHNAcwBygH/Ac0BzAHKAf8BzQHM AcoB/wHNAcwBygH/Ac0BzAHKAf8BzQHMAcoB/wHNAcwBygH/AZcBkgGPAf/AAAGXAZIBjwH/AeAB2QHT Af8B4AHZAdMB/wHgAdkB0wH/AeAB2QHTAf8B4AHZAdMB/wHgAdkB0wH/AeAB2QHTAf8B4AHZAdMB/wHg - AdkB0wH/AZEBcQFgAf8B4AHZAdMB/wGRAXEBYAH/AeAB2QHTAf8BkQFxAWAB/wGXAZIBjwH/wAABlwGS + AdkB0wH/AZEBcgFhAf8B4AHZAdMB/wGRAXIBYQH/AeAB2QHTAf8BkQFyAWEB/wGXAZIBjwH/wAABlwGS AY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGSAY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGSAY8B/wGXAZIBjwH/ AZcBkgGPAf8BlwGSAY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGSAY8B/wGXAZIBjwH/AZcBkgGPAf8BlwGS AY8B//8AwQABQgFNAT4HAAE+AwABKAMAAUADAAEQAwABAQEAAQEFAAGAFwAD/wEAAv8GAAL/bgAC/wYA diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/NodePlotter.cs b/1.x/trunk/ProcessHacker/Components/NodePlotter.cs similarity index 90% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/NodePlotter.cs rename to 1.x/trunk/ProcessHacker/Components/NodePlotter.cs index 52dbff182..0a14d66eb 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/NodePlotter.cs +++ b/1.x/trunk/ProcessHacker/Components/NodePlotter.cs @@ -57,12 +57,10 @@ public override void Draw(TreeNodeAdv node, DrawContext context) if (_plotter == null) { - _plotter = new Plotter - { - BackColor = Color.Black, - ShowGrid = false, - OverlaySecondLine = false - }; + _plotter = new Plotter(); + _plotter.BackColor = Color.Black; + _plotter.ShowGrid = false; + _plotter.OverlaySecondLine = false; } if (info.UseLongData) @@ -93,7 +91,6 @@ public override void Draw(TreeNodeAdv node, DrawContext context) using (Bitmap b = new Bitmap(_plotter.Width, _plotter.Height)) { _plotter.DrawToBitmap(b, new Rectangle(0, 0, b.Width, b.Height)); - context.Graphics.DrawImage(b, context.Bounds.Location); } } diff --git a/1.x/trunk/ProcessHacker/Components/Plotter.Designer.cs b/1.x/trunk/ProcessHacker/Components/Plotter.Designer.cs index 8fb94fae8..9350da62c 100644 --- a/1.x/trunk/ProcessHacker/Components/Plotter.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/Plotter.Designer.cs @@ -45,14 +45,13 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Name = "Plotter"; this.Size = new System.Drawing.Size(150, 163); - this.Paint += new System.Windows.Forms.PaintEventHandler(this.Plotter_Paint); - this.MouseEnter += new System.EventHandler(this.Plotter_MouseEnter); this.MouseLeave += new System.EventHandler(this.Plotter_MouseLeave); + this.Paint += new System.Windows.Forms.PaintEventHandler(this.Plotter_Paint); this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Plotter_MouseMove); this.Resize += new System.EventHandler(this.Plotter_Resize); + this.MouseEnter += new System.EventHandler(this.Plotter_MouseEnter); this.ResumeLayout(false); } diff --git a/1.x/trunk/ProcessHacker/Components/Plotter.cs b/1.x/trunk/ProcessHacker/Components/Plotter.cs index 79aaf14b0..95e339cf9 100644 --- a/1.x/trunk/ProcessHacker/Components/Plotter.cs +++ b/1.x/trunk/ProcessHacker/Components/Plotter.cs @@ -65,11 +65,18 @@ public Plotter() public GetToolTipDelegate GetToolTip; - private int _gridStartPos; + private int _gridStartPos = 0; private void Plotter_Paint(object sender, PaintEventArgs e) { - this.Render(e.Graphics); + try + { + this.Render(e.Graphics); + } + catch (Exception ex) + { + Logging.Log(ex); + } } public void Render(Graphics g) @@ -148,11 +155,10 @@ public void Draw(Graphics g) int hPre = (int)(tHeight - (tHeight * fPre)); // Fill in the area below the line. - g.FillPolygon(new SolidBrush(Color.FromArgb(100, _lineColor1)),new Point[] - { - new Point(px, h), new Point(px + moveStep, hPre), - new Point(px + moveStep, tHeight), new Point(px, tHeight) - }); + + g.FillPolygon(new SolidBrush(Color.FromArgb(100, _lineColor1)), + new Point[] { new Point(px, h), new Point(px + moveStep, hPre), + new Point(px + moveStep, tHeight), new Point(px, tHeight) }); g.DrawLine(lGrid1, px, h, px + moveStep, hPre); if (this.UseSecondLine) @@ -175,25 +181,20 @@ public void Draw(Graphics g) hPre = (int)(tHeight - (tHeight * fPre)); // Draw the second line. + if (this.OverlaySecondLine) { - g.FillPolygon(new SolidBrush(Color.FromArgb(100, _lineColor2)), new Point[] - { - new Point(px, h), new Point(px + moveStep, hPre), - new Point(px + moveStep, tHeight), new Point(px, tHeight) - }); - + g.FillPolygon(new SolidBrush(Color.FromArgb(100, _lineColor2)), + new Point[] { new Point(px, h), new Point(px + moveStep, hPre), + new Point(px + moveStep, tHeight), new Point(px, tHeight) }); g.DrawLine(lGrid2, px, h, px + moveStep, hPre); } else { - g.FillPolygon(new SolidBrush(Color.FromArgb(100, _lineColor2)), new Point[] - { - new Point(px, h), new Point(px + moveStep, hPre), + g.FillPolygon(new SolidBrush(Color.FromArgb(100, _lineColor2)), + new Point[] { new Point(px, h), new Point(px + moveStep, hPre), new Point(px + moveStep, tHeight - (int)(tHeight * _data1[start])), - new Point(px, tHeight - (int)(tHeight * _data1[start + 1])) - }); - + new Point(px, tHeight - (int)(tHeight * _data1[start + 1])) }); g.DrawLine(lGrid2, px, h, px + moveStep, hPre); } } @@ -219,7 +220,12 @@ public void Draw(Graphics g) } } - private void ShowToolTip(bool force = false) + private void ShowToolTip() + { + this.ShowToolTip(false); + } + + private void ShowToolTip(bool force) { if (this.GetToolTip != null) { @@ -335,7 +341,7 @@ public override string Text { base.Text = _text = value; - _textSize = this.CreateGraphics().GetCachedSize(this.Text, this.Font); + _textSize = TextRenderer.MeasureText(this.Text, this.Font); _boxSize = new Size( _textSize.Width + _textPadding.Left + _textPadding.Right, _textSize.Height + _textPadding.Top + _textPadding.Bottom); diff --git a/1.x/trunk/ProcessHacker/Components/Plotter.resx b/1.x/trunk/ProcessHacker/Components/Plotter.resx index 026c576b4..a5979aadf 100644 --- a/1.x/trunk/ProcessHacker/Components/Plotter.resx +++ b/1.x/trunk/ProcessHacker/Components/Plotter.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/ProcessStatistics.Designer.cs b/1.x/trunk/ProcessHacker/Components/ProcessStatistics.Designer.cs index 9285e96ad..429319c24 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessStatistics.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/ProcessStatistics.Designer.cs @@ -136,7 +136,7 @@ private void InitializeComponent() this.tableLayoutPanel1.Controls.Add(this.labelCPUCyclesText, 0, 1); this.tableLayoutPanel1.Controls.Add(this.labelCPUCycles, 1, 1); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 18); + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 16); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 5; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); @@ -144,7 +144,7 @@ private void InitializeComponent() this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(189, 87); + this.tableLayoutPanel1.Size = new System.Drawing.Size(189, 89); this.tableLayoutPanel1.TabIndex = 1; // // label6 @@ -153,7 +153,7 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(3, 2); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(43, 13); + this.label6.Size = new System.Drawing.Size(38, 13); this.label6.TabIndex = 1; this.label6.Text = "Priority"; // @@ -163,7 +163,7 @@ private void InitializeComponent() this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(3, 36); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(65, 13); + this.label8.Size = new System.Drawing.Size(63, 13); this.label8.TabIndex = 1; this.label8.Text = "Kernel Time"; // @@ -173,7 +173,7 @@ private void InitializeComponent() this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(3, 53); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(56, 13); + this.label9.Size = new System.Drawing.Size(55, 13); this.label9.TabIndex = 1; this.label9.Text = "User Time"; // @@ -181,9 +181,9 @@ private void InitializeComponent() // this.label10.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(3, 71); + this.label10.Location = new System.Drawing.Point(3, 72); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(58, 13); + this.label10.Size = new System.Drawing.Size(57, 13); this.label10.TabIndex = 1; this.label10.Text = "Total Time"; // @@ -191,9 +191,9 @@ private void InitializeComponent() // this.labelCPUPriority.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelCPUPriority.AutoSize = true; - this.labelCPUPriority.Location = new System.Drawing.Point(152, 2); + this.labelCPUPriority.Location = new System.Drawing.Point(153, 2); this.labelCPUPriority.Name = "labelCPUPriority"; - this.labelCPUPriority.Size = new System.Drawing.Size(34, 13); + this.labelCPUPriority.Size = new System.Drawing.Size(33, 13); this.labelCPUPriority.TabIndex = 1; this.labelCPUPriority.Text = "value"; // @@ -201,9 +201,9 @@ private void InitializeComponent() // this.labelCPUKernelTime.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelCPUKernelTime.AutoSize = true; - this.labelCPUKernelTime.Location = new System.Drawing.Point(152, 36); + this.labelCPUKernelTime.Location = new System.Drawing.Point(153, 36); this.labelCPUKernelTime.Name = "labelCPUKernelTime"; - this.labelCPUKernelTime.Size = new System.Drawing.Size(34, 13); + this.labelCPUKernelTime.Size = new System.Drawing.Size(33, 13); this.labelCPUKernelTime.TabIndex = 1; this.labelCPUKernelTime.Text = "value"; // @@ -211,9 +211,9 @@ private void InitializeComponent() // this.labelCPUUserTime.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelCPUUserTime.AutoSize = true; - this.labelCPUUserTime.Location = new System.Drawing.Point(152, 53); + this.labelCPUUserTime.Location = new System.Drawing.Point(153, 53); this.labelCPUUserTime.Name = "labelCPUUserTime"; - this.labelCPUUserTime.Size = new System.Drawing.Size(34, 13); + this.labelCPUUserTime.Size = new System.Drawing.Size(33, 13); this.labelCPUUserTime.TabIndex = 1; this.labelCPUUserTime.Text = "value"; // @@ -221,9 +221,9 @@ private void InitializeComponent() // this.labelCPUTotalTime.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelCPUTotalTime.AutoSize = true; - this.labelCPUTotalTime.Location = new System.Drawing.Point(152, 71); + this.labelCPUTotalTime.Location = new System.Drawing.Point(153, 72); this.labelCPUTotalTime.Name = "labelCPUTotalTime"; - this.labelCPUTotalTime.Size = new System.Drawing.Size(34, 13); + this.labelCPUTotalTime.Size = new System.Drawing.Size(33, 13); this.labelCPUTotalTime.TabIndex = 1; this.labelCPUTotalTime.Text = "value"; // @@ -241,9 +241,9 @@ private void InitializeComponent() // this.labelCPUCycles.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelCPUCycles.AutoSize = true; - this.labelCPUCycles.Location = new System.Drawing.Point(152, 19); + this.labelCPUCycles.Location = new System.Drawing.Point(153, 19); this.labelCPUCycles.Name = "labelCPUCycles"; - this.labelCPUCycles.Size = new System.Drawing.Size(34, 13); + this.labelCPUCycles.Size = new System.Drawing.Size(33, 13); this.labelCPUCycles.TabIndex = 1; this.labelCPUCycles.Text = "value"; // @@ -281,7 +281,7 @@ private void InitializeComponent() this.tableLayoutPanel2.Controls.Add(this.label30, 0, 8); this.tableLayoutPanel2.Controls.Add(this.labelMemoryPP, 1, 8); this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 18); + this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 16); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.RowCount = 9; this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); @@ -293,7 +293,7 @@ private void InitializeComponent() this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 11.11111F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(189, 173); + this.tableLayoutPanel2.Size = new System.Drawing.Size(189, 175); this.tableLayoutPanel2.TabIndex = 1; // // label24 @@ -302,7 +302,7 @@ private void InitializeComponent() this.label24.AutoSize = true; this.label24.Location = new System.Drawing.Point(3, 117); this.label24.Name = "label24"; - this.label24.Size = new System.Drawing.Size(110, 13); + this.label24.Size = new System.Drawing.Size(107, 13); this.label24.TabIndex = 7; this.label24.Text = "Peak Pagefile Usage"; // @@ -312,7 +312,7 @@ private void InitializeComponent() this.label22.AutoSize = true; this.label22.Location = new System.Drawing.Point(3, 98); this.label22.Name = "label22"; - this.label22.Size = new System.Drawing.Size(83, 13); + this.label22.Size = new System.Drawing.Size(79, 13); this.label22.TabIndex = 5; this.label22.Text = "Pagefile Usage"; // @@ -322,7 +322,7 @@ private void InitializeComponent() this.label20.AutoSize = true; this.label20.Location = new System.Drawing.Point(3, 79); this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(91, 13); + this.label20.Size = new System.Drawing.Size(87, 13); this.label20.TabIndex = 3; this.label20.Text = "Peak Virtual Size"; // @@ -332,7 +332,7 @@ private void InitializeComponent() this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(3, 3); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(71, 13); + this.label11.Size = new System.Drawing.Size(69, 13); this.label11.TabIndex = 1; this.label11.Text = "Private Bytes"; // @@ -342,7 +342,7 @@ private void InitializeComponent() this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(3, 22); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(71, 13); + this.label12.Size = new System.Drawing.Size(66, 13); this.label12.TabIndex = 1; this.label12.Text = "Working Set"; // @@ -352,7 +352,7 @@ private void InitializeComponent() this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(3, 41); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(98, 13); + this.label13.Size = new System.Drawing.Size(94, 13); this.label13.TabIndex = 1; this.label13.Text = "Peak Working Set"; // @@ -362,7 +362,7 @@ private void InitializeComponent() this.label14.AutoSize = true; this.label14.Location = new System.Drawing.Point(3, 60); this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(64, 13); + this.label14.Size = new System.Drawing.Size(59, 13); this.label14.TabIndex = 1; this.label14.Text = "Virtual Size"; // @@ -370,9 +370,9 @@ private void InitializeComponent() // this.labelMemoryPB.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryPB.AutoSize = true; - this.labelMemoryPB.Location = new System.Drawing.Point(152, 3); + this.labelMemoryPB.Location = new System.Drawing.Point(153, 3); this.labelMemoryPB.Name = "labelMemoryPB"; - this.labelMemoryPB.Size = new System.Drawing.Size(34, 13); + this.labelMemoryPB.Size = new System.Drawing.Size(33, 13); this.labelMemoryPB.TabIndex = 1; this.labelMemoryPB.Text = "value"; // @@ -380,9 +380,9 @@ private void InitializeComponent() // this.labelMemoryWS.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryWS.AutoSize = true; - this.labelMemoryWS.Location = new System.Drawing.Point(152, 22); + this.labelMemoryWS.Location = new System.Drawing.Point(153, 22); this.labelMemoryWS.Name = "labelMemoryWS"; - this.labelMemoryWS.Size = new System.Drawing.Size(34, 13); + this.labelMemoryWS.Size = new System.Drawing.Size(33, 13); this.labelMemoryWS.TabIndex = 1; this.labelMemoryWS.Text = "value"; // @@ -390,9 +390,9 @@ private void InitializeComponent() // this.labelMemoryPWS.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryPWS.AutoSize = true; - this.labelMemoryPWS.Location = new System.Drawing.Point(152, 41); + this.labelMemoryPWS.Location = new System.Drawing.Point(153, 41); this.labelMemoryPWS.Name = "labelMemoryPWS"; - this.labelMemoryPWS.Size = new System.Drawing.Size(34, 13); + this.labelMemoryPWS.Size = new System.Drawing.Size(33, 13); this.labelMemoryPWS.TabIndex = 1; this.labelMemoryPWS.Text = "value"; // @@ -400,9 +400,9 @@ private void InitializeComponent() // this.labelMemoryVS.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryVS.AutoSize = true; - this.labelMemoryVS.Location = new System.Drawing.Point(152, 60); + this.labelMemoryVS.Location = new System.Drawing.Point(153, 60); this.labelMemoryVS.Name = "labelMemoryVS"; - this.labelMemoryVS.Size = new System.Drawing.Size(34, 13); + this.labelMemoryVS.Size = new System.Drawing.Size(33, 13); this.labelMemoryVS.TabIndex = 1; this.labelMemoryVS.Text = "value"; // @@ -410,9 +410,9 @@ private void InitializeComponent() // this.labelMemoryPVS.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryPVS.AutoSize = true; - this.labelMemoryPVS.Location = new System.Drawing.Point(152, 79); + this.labelMemoryPVS.Location = new System.Drawing.Point(153, 79); this.labelMemoryPVS.Name = "labelMemoryPVS"; - this.labelMemoryPVS.Size = new System.Drawing.Size(34, 13); + this.labelMemoryPVS.Size = new System.Drawing.Size(33, 13); this.labelMemoryPVS.TabIndex = 1; this.labelMemoryPVS.Text = "value"; // @@ -420,9 +420,9 @@ private void InitializeComponent() // this.labelMemoryPU.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryPU.AutoSize = true; - this.labelMemoryPU.Location = new System.Drawing.Point(152, 98); + this.labelMemoryPU.Location = new System.Drawing.Point(153, 98); this.labelMemoryPU.Name = "labelMemoryPU"; - this.labelMemoryPU.Size = new System.Drawing.Size(34, 13); + this.labelMemoryPU.Size = new System.Drawing.Size(33, 13); this.labelMemoryPU.TabIndex = 1; this.labelMemoryPU.Text = "value"; // @@ -430,9 +430,9 @@ private void InitializeComponent() // this.labelMemoryPPU.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryPPU.AutoSize = true; - this.labelMemoryPPU.Location = new System.Drawing.Point(152, 117); + this.labelMemoryPPU.Location = new System.Drawing.Point(153, 117); this.labelMemoryPPU.Name = "labelMemoryPPU"; - this.labelMemoryPPU.Size = new System.Drawing.Size(34, 13); + this.labelMemoryPPU.Size = new System.Drawing.Size(33, 13); this.labelMemoryPPU.TabIndex = 1; this.labelMemoryPPU.Text = "value"; // @@ -442,7 +442,7 @@ private void InitializeComponent() this.label25.AutoSize = true; this.label25.Location = new System.Drawing.Point(3, 136); this.label25.Name = "label25"; - this.label25.Size = new System.Drawing.Size(66, 13); + this.label25.Size = new System.Drawing.Size(63, 13); this.label25.TabIndex = 7; this.label25.Text = "Page Faults"; // @@ -450,9 +450,9 @@ private void InitializeComponent() // this.labelMemoryPF.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryPF.AutoSize = true; - this.labelMemoryPF.Location = new System.Drawing.Point(152, 136); + this.labelMemoryPF.Location = new System.Drawing.Point(153, 136); this.labelMemoryPF.Name = "labelMemoryPF"; - this.labelMemoryPF.Size = new System.Drawing.Size(34, 13); + this.labelMemoryPF.Size = new System.Drawing.Size(33, 13); this.labelMemoryPF.TabIndex = 1; this.labelMemoryPF.Text = "value"; // @@ -460,9 +460,9 @@ private void InitializeComponent() // this.label30.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label30.AutoSize = true; - this.label30.Location = new System.Drawing.Point(3, 156); + this.label30.Location = new System.Drawing.Point(3, 157); this.label30.Name = "label30"; - this.label30.Size = new System.Drawing.Size(71, 13); + this.label30.Size = new System.Drawing.Size(66, 13); this.label30.TabIndex = 7; this.label30.Text = "Page Priority"; // @@ -470,9 +470,9 @@ private void InitializeComponent() // this.labelMemoryPP.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelMemoryPP.AutoSize = true; - this.labelMemoryPP.Location = new System.Drawing.Point(152, 156); + this.labelMemoryPP.Location = new System.Drawing.Point(153, 157); this.labelMemoryPP.Name = "labelMemoryPP"; - this.labelMemoryPP.Size = new System.Drawing.Size(34, 13); + this.labelMemoryPP.Size = new System.Drawing.Size(33, 13); this.labelMemoryPP.TabIndex = 1; this.labelMemoryPP.Text = "value"; // @@ -506,7 +506,7 @@ private void InitializeComponent() this.tableLayoutPanel3.Controls.Add(this.label31, 0, 6); this.tableLayoutPanel3.Controls.Add(this.labelIOPriority, 1, 6); this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 18); + this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 16); this.tableLayoutPanel3.Name = "tableLayoutPanel3"; this.tableLayoutPanel3.RowCount = 7; this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); @@ -516,7 +516,7 @@ private void InitializeComponent() this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(189, 127); + this.tableLayoutPanel3.Size = new System.Drawing.Size(189, 129); this.tableLayoutPanel3.TabIndex = 1; // // label16 @@ -525,7 +525,7 @@ private void InitializeComponent() this.label16.AutoSize = true; this.label16.Location = new System.Drawing.Point(3, 92); this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(67, 13); + this.label16.Size = new System.Drawing.Size(62, 13); this.label16.TabIndex = 5; this.label16.Text = "Other Bytes"; // @@ -535,7 +535,7 @@ private void InitializeComponent() this.label17.AutoSize = true; this.label17.Location = new System.Drawing.Point(3, 74); this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(37, 13); + this.label17.Size = new System.Drawing.Size(33, 13); this.label17.TabIndex = 3; this.label17.Text = "Other"; // @@ -555,7 +555,7 @@ private void InitializeComponent() this.label19.AutoSize = true; this.label19.Location = new System.Drawing.Point(3, 20); this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(63, 13); + this.label19.Size = new System.Drawing.Size(62, 13); this.label19.TabIndex = 1; this.label19.Text = "Read Bytes"; // @@ -565,7 +565,7 @@ private void InitializeComponent() this.label21.AutoSize = true; this.label21.Location = new System.Drawing.Point(3, 38); this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(40, 13); + this.label21.Size = new System.Drawing.Size(37, 13); this.label21.TabIndex = 1; this.label21.Text = "Writes"; // @@ -575,7 +575,7 @@ private void InitializeComponent() this.label23.AutoSize = true; this.label23.Location = new System.Drawing.Point(3, 56); this.label23.Name = "label23"; - this.label23.Size = new System.Drawing.Size(65, 13); + this.label23.Size = new System.Drawing.Size(61, 13); this.label23.TabIndex = 1; this.label23.Text = "Write Bytes"; // @@ -583,9 +583,9 @@ private void InitializeComponent() // this.labelIOReads.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelIOReads.AutoSize = true; - this.labelIOReads.Location = new System.Drawing.Point(152, 2); + this.labelIOReads.Location = new System.Drawing.Point(153, 2); this.labelIOReads.Name = "labelIOReads"; - this.labelIOReads.Size = new System.Drawing.Size(34, 13); + this.labelIOReads.Size = new System.Drawing.Size(33, 13); this.labelIOReads.TabIndex = 1; this.labelIOReads.Text = "value"; // @@ -593,9 +593,9 @@ private void InitializeComponent() // this.labelIOReadBytes.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelIOReadBytes.AutoSize = true; - this.labelIOReadBytes.Location = new System.Drawing.Point(152, 20); + this.labelIOReadBytes.Location = new System.Drawing.Point(153, 20); this.labelIOReadBytes.Name = "labelIOReadBytes"; - this.labelIOReadBytes.Size = new System.Drawing.Size(34, 13); + this.labelIOReadBytes.Size = new System.Drawing.Size(33, 13); this.labelIOReadBytes.TabIndex = 1; this.labelIOReadBytes.Text = "value"; // @@ -603,9 +603,9 @@ private void InitializeComponent() // this.labelIOWrites.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelIOWrites.AutoSize = true; - this.labelIOWrites.Location = new System.Drawing.Point(152, 38); + this.labelIOWrites.Location = new System.Drawing.Point(153, 38); this.labelIOWrites.Name = "labelIOWrites"; - this.labelIOWrites.Size = new System.Drawing.Size(34, 13); + this.labelIOWrites.Size = new System.Drawing.Size(33, 13); this.labelIOWrites.TabIndex = 1; this.labelIOWrites.Text = "value"; // @@ -613,9 +613,9 @@ private void InitializeComponent() // this.labelIOWriteBytes.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelIOWriteBytes.AutoSize = true; - this.labelIOWriteBytes.Location = new System.Drawing.Point(152, 56); + this.labelIOWriteBytes.Location = new System.Drawing.Point(153, 56); this.labelIOWriteBytes.Name = "labelIOWriteBytes"; - this.labelIOWriteBytes.Size = new System.Drawing.Size(34, 13); + this.labelIOWriteBytes.Size = new System.Drawing.Size(33, 13); this.labelIOWriteBytes.TabIndex = 1; this.labelIOWriteBytes.Text = "value"; // @@ -623,9 +623,9 @@ private void InitializeComponent() // this.labelIOOther.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelIOOther.AutoSize = true; - this.labelIOOther.Location = new System.Drawing.Point(152, 74); + this.labelIOOther.Location = new System.Drawing.Point(153, 74); this.labelIOOther.Name = "labelIOOther"; - this.labelIOOther.Size = new System.Drawing.Size(34, 13); + this.labelIOOther.Size = new System.Drawing.Size(33, 13); this.labelIOOther.TabIndex = 1; this.labelIOOther.Text = "value"; // @@ -633,9 +633,9 @@ private void InitializeComponent() // this.labelIOOtherBytes.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelIOOtherBytes.AutoSize = true; - this.labelIOOtherBytes.Location = new System.Drawing.Point(152, 92); + this.labelIOOtherBytes.Location = new System.Drawing.Point(153, 92); this.labelIOOtherBytes.Name = "labelIOOtherBytes"; - this.labelIOOtherBytes.Size = new System.Drawing.Size(34, 13); + this.labelIOOtherBytes.Size = new System.Drawing.Size(33, 13); this.labelIOOtherBytes.TabIndex = 1; this.labelIOOtherBytes.Text = "value"; // @@ -643,9 +643,9 @@ private void InitializeComponent() // this.label31.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label31.AutoSize = true; - this.label31.Location = new System.Drawing.Point(3, 111); + this.label31.Location = new System.Drawing.Point(3, 112); this.label31.Name = "label31"; - this.label31.Size = new System.Drawing.Size(62, 13); + this.label31.Size = new System.Drawing.Size(57, 13); this.label31.TabIndex = 5; this.label31.Text = "I/O Priority"; // @@ -653,9 +653,9 @@ private void InitializeComponent() // this.labelIOPriority.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelIOPriority.AutoSize = true; - this.labelIOPriority.Location = new System.Drawing.Point(152, 111); + this.labelIOPriority.Location = new System.Drawing.Point(153, 112); this.labelIOPriority.Name = "labelIOPriority"; - this.labelIOPriority.Size = new System.Drawing.Size(34, 13); + this.labelIOPriority.Size = new System.Drawing.Size(33, 13); this.labelIOPriority.TabIndex = 1; this.labelIOPriority.Text = "value"; // @@ -682,23 +682,23 @@ private void InitializeComponent() this.tableLayoutPanel4.Controls.Add(this.labelOtherUSERHandles, 1, 2); this.tableLayoutPanel4.Controls.Add(this.buttonHandleDetails, 1, 3); this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 18); + this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 16); this.tableLayoutPanel4.Name = "tableLayoutPanel4"; this.tableLayoutPanel4.RowCount = 4; this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); - this.tableLayoutPanel4.Size = new System.Drawing.Size(189, 78); + this.tableLayoutPanel4.Size = new System.Drawing.Size(189, 80); this.tableLayoutPanel4.TabIndex = 1; // // label27 // this.label27.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label27.AutoSize = true; - this.label27.Location = new System.Drawing.Point(3, 1); + this.label27.Location = new System.Drawing.Point(3, 2); this.label27.Name = "label27"; - this.label27.Size = new System.Drawing.Size(49, 13); + this.label27.Size = new System.Drawing.Size(46, 13); this.label27.TabIndex = 1; this.label27.Text = "Handles"; // @@ -706,9 +706,9 @@ private void InitializeComponent() // this.labelOtherHandles.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelOtherHandles.AutoSize = true; - this.labelOtherHandles.Location = new System.Drawing.Point(152, 1); + this.labelOtherHandles.Location = new System.Drawing.Point(153, 2); this.labelOtherHandles.Name = "labelOtherHandles"; - this.labelOtherHandles.Size = new System.Drawing.Size(34, 13); + this.labelOtherHandles.Size = new System.Drawing.Size(33, 13); this.labelOtherHandles.TabIndex = 1; this.labelOtherHandles.Text = "value"; // @@ -716,9 +716,9 @@ private void InitializeComponent() // this.label28.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label28.AutoSize = true; - this.label28.Location = new System.Drawing.Point(3, 18); + this.label28.Location = new System.Drawing.Point(3, 19); this.label28.Name = "label28"; - this.label28.Size = new System.Drawing.Size(71, 13); + this.label28.Size = new System.Drawing.Size(68, 13); this.label28.TabIndex = 1; this.label28.Text = "GDI Handles"; // @@ -726,7 +726,7 @@ private void InitializeComponent() // this.label29.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label29.AutoSize = true; - this.label29.Location = new System.Drawing.Point(3, 35); + this.label29.Location = new System.Drawing.Point(3, 36); this.label29.Name = "label29"; this.label29.Size = new System.Drawing.Size(79, 13); this.label29.TabIndex = 1; @@ -736,9 +736,9 @@ private void InitializeComponent() // this.labelOtherGDIHandles.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelOtherGDIHandles.AutoSize = true; - this.labelOtherGDIHandles.Location = new System.Drawing.Point(152, 18); + this.labelOtherGDIHandles.Location = new System.Drawing.Point(153, 19); this.labelOtherGDIHandles.Name = "labelOtherGDIHandles"; - this.labelOtherGDIHandles.Size = new System.Drawing.Size(34, 13); + this.labelOtherGDIHandles.Size = new System.Drawing.Size(33, 13); this.labelOtherGDIHandles.TabIndex = 1; this.labelOtherGDIHandles.Text = "value"; // @@ -746,9 +746,9 @@ private void InitializeComponent() // this.labelOtherUSERHandles.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelOtherUSERHandles.AutoSize = true; - this.labelOtherUSERHandles.Location = new System.Drawing.Point(152, 35); + this.labelOtherUSERHandles.Location = new System.Drawing.Point(153, 36); this.labelOtherUSERHandles.Name = "labelOtherUSERHandles"; - this.labelOtherUSERHandles.Size = new System.Drawing.Size(34, 13); + this.labelOtherUSERHandles.Size = new System.Drawing.Size(33, 13); this.labelOtherUSERHandles.TabIndex = 1; this.labelOtherUSERHandles.Text = "value"; // @@ -756,9 +756,9 @@ private void InitializeComponent() // this.buttonHandleDetails.Anchor = System.Windows.Forms.AnchorStyles.Right; this.buttonHandleDetails.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonHandleDetails.Location = new System.Drawing.Point(112, 53); + this.buttonHandleDetails.Location = new System.Drawing.Point(112, 54); this.buttonHandleDetails.Name = "buttonHandleDetails"; - this.buttonHandleDetails.Size = new System.Drawing.Size(74, 22); + this.buttonHandleDetails.Size = new System.Drawing.Size(74, 23); this.buttonHandleDetails.TabIndex = 2; this.buttonHandleDetails.Text = "Details..."; this.buttonHandleDetails.UseVisualStyleBackColor = true; @@ -768,7 +768,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; this.Controls.Add(this.flowStats); this.Name = "ProcessStatistics"; this.Size = new System.Drawing.Size(433, 374); diff --git a/1.x/trunk/ProcessHacker/Components/ProcessStatistics.cs b/1.x/trunk/ProcessHacker/Components/ProcessStatistics.cs index dad9f635c..10632d2d4 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessStatistics.cs +++ b/1.x/trunk/ProcessHacker/Components/ProcessStatistics.cs @@ -24,12 +24,13 @@ using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Native; +using ProcessHacker.Native.Objects; namespace ProcessHacker.Components { public partial class ProcessStatistics : UserControl { - private readonly int _pid; + private int _pid; public ProcessStatistics(int pid) { @@ -45,37 +46,49 @@ public ProcessStatistics(int pid) { labelCPUCyclesText.Text = "N/A"; } + + _dontCalculate = false; + } + + private bool _dontCalculate = true; + + protected override void OnResize(EventArgs e) + { + if (_dontCalculate) + return; + + base.OnResize(e); } public void ClearStatistics() { - labelCPUPriority.Text = string.Empty; - labelCPUCycles.Text = string.Empty; - labelCPUKernelTime.Text = string.Empty; - labelCPUUserTime.Text = string.Empty; - labelCPUTotalTime.Text = string.Empty; - - labelMemoryPB.Text = string.Empty; - labelMemoryWS.Text = string.Empty; - labelMemoryPWS.Text = string.Empty; - labelMemoryVS.Text = string.Empty; - labelMemoryPVS.Text = string.Empty; - labelMemoryPU.Text = string.Empty; - labelMemoryPPU.Text = string.Empty; - labelMemoryPF.Text = string.Empty; - labelMemoryPP.Text = string.Empty; - - labelIOReads.Text = string.Empty; - labelIOReadBytes.Text = string.Empty; - labelIOWrites.Text = string.Empty; - labelIOWriteBytes.Text = string.Empty; - labelIOOther.Text = string.Empty; - labelIOOtherBytes.Text = string.Empty; - labelIOPriority.Text = string.Empty; - - labelOtherHandles.Text = string.Empty; - labelOtherGDIHandles.Text = string.Empty; - labelOtherUSERHandles.Text = string.Empty; + labelCPUPriority.Text = ""; + labelCPUCycles.Text = ""; + labelCPUKernelTime.Text = ""; + labelCPUUserTime.Text = ""; + labelCPUTotalTime.Text = ""; + + labelMemoryPB.Text = ""; + labelMemoryWS.Text = ""; + labelMemoryPWS.Text = ""; + labelMemoryVS.Text = ""; + labelMemoryPVS.Text = ""; + labelMemoryPU.Text = ""; + labelMemoryPPU.Text = ""; + labelMemoryPF.Text = ""; + labelMemoryPP.Text = ""; + + labelIOReads.Text = ""; + labelIOReadBytes.Text = ""; + labelIOWrites.Text = ""; + labelIOWriteBytes.Text = ""; + labelIOOther.Text = ""; + labelIOOtherBytes.Text = ""; + labelIOPriority.Text = ""; + + labelOtherHandles.Text = ""; + labelOtherGDIHandles.Text = ""; + labelOtherUSERHandles.Text = ""; } public void UpdateStatistics() @@ -99,31 +112,34 @@ public void UpdateStatistics() labelMemoryPPU.Text = Utils.FormatSize(item.Process.VirtualMemoryCounters.PeakPagefileUsage); labelMemoryPF.Text = ((ulong)item.Process.VirtualMemoryCounters.PageFaultCount).ToString("N0"); - labelIOReads.Text = item.Process.IoCounters.ReadOperationCount.ToString("N0"); + labelIOReads.Text = ((ulong)item.Process.IoCounters.ReadOperationCount).ToString("N0"); labelIOReadBytes.Text = Utils.FormatSize(item.Process.IoCounters.ReadTransferCount); - labelIOWrites.Text = item.Process.IoCounters.WriteOperationCount.ToString("N0"); + labelIOWrites.Text = ((ulong)item.Process.IoCounters.WriteOperationCount).ToString("N0"); labelIOWriteBytes.Text = Utils.FormatSize(item.Process.IoCounters.WriteTransferCount); - labelIOOther.Text = item.Process.IoCounters.OtherOperationCount.ToString("N0"); + labelIOOther.Text = ((ulong)item.Process.IoCounters.OtherOperationCount).ToString("N0"); labelIOOtherBytes.Text = Utils.FormatSize(item.Process.IoCounters.OtherTransferCount); labelOtherHandles.Text = ((ulong)item.Process.HandleCount).ToString("N0"); - + if (_pid > 0) { try { - labelOtherGDIHandles.Text = item.ProcessQueryHandle.GetGuiResources(false).ToString("N0"); - labelOtherUSERHandles.Text = item.ProcessQueryHandle.GetGuiResources(true).ToString("N0"); - - if (OSVersion.HasCycleTime) - labelCPUCycles.Text = item.ProcessQueryHandle.GetCycleTime().ToString("N0"); - else - labelCPUCycles.Text = "N/A"; - - if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) { - labelMemoryPP.Text = item.ProcessQueryHandle.PagePriority.ToString(); - labelIOPriority.Text = item.ProcessQueryHandle.IoPriority.ToString(); + labelOtherGDIHandles.Text = phandle.GetGuiResources(false).ToString("N0"); + labelOtherUSERHandles.Text = phandle.GetGuiResources(true).ToString("N0"); + + if (OSVersion.HasCycleTime) + labelCPUCycles.Text = phandle.GetCycleTime().ToString("N0"); + else + labelCPUCycles.Text = "N/A"; + + if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) + { + labelMemoryPP.Text = phandle.GetPagePriority().ToString(); + labelIOPriority.Text = phandle.GetIoPriority().ToString(); + } } } catch diff --git a/1.x/trunk/ProcessHacker/Components/ProcessStatistics.resx b/1.x/trunk/ProcessHacker/Components/ProcessStatistics.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessStatistics.resx +++ b/1.x/trunk/ProcessHacker/Components/ProcessStatistics.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs index 092c99a3d..3547d33e2 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs +++ b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs @@ -38,16 +38,16 @@ public class ProcessNode : Node, IDisposable private static ProcessNode[] _processNodeTreePathBuffer; private const int _processNodeTreePathMaxDepth = 512; - private ProcessNode _parent; - private readonly List _children = new List(); - private TreePath _treePath; + private ProcessNode _parent = null; + private List _children = new List(); + private TreePath _treePath = null; private ProcessItem _pitem; - private bool _wasNoIcon; + private bool _wasNoIcon = false; private Bitmap _icon; private string _tooltipText; - private int _lastTooltipTickCount; + private int _lastTooltipTickCount = 0; public ProcessNode(ProcessItem pitem) { @@ -57,7 +57,7 @@ public ProcessNode(ProcessItem pitem) if (_pitem.Icon == null) { _wasNoIcon = true; - _icon = Properties.Resources.Process_small.ToBitmap(); + _icon = global::ProcessHacker.Properties.Resources.Process_small.ToBitmap(); } else { @@ -68,7 +68,7 @@ public ProcessNode(ProcessItem pitem) catch { _wasNoIcon = true; - _icon = Properties.Resources.Process_small.ToBitmap(); + _icon = global::ProcessHacker.Properties.Resources.Process_small.ToBitmap(); } } } @@ -161,7 +161,9 @@ public TreePath RefreshTreePath() currentNode = currentNode.Parent; } - ProcessNode[] path = new ProcessNode[_processNodeTreePathMaxDepth - i]; + ProcessNode[] path; + + path = new ProcessNode[_processNodeTreePathMaxDepth - i]; Array.Copy(_processNodeTreePathBuffer, i, path, 0, _processNodeTreePathMaxDepth - i); _treePath = new TreePath(path); @@ -181,7 +183,7 @@ public ProcessHacker.Components.NodePlotter.PlotterInfo CpuHistory { get { - return new ProcessHacker.Components.NodePlotter.PlotterInfo + return new ProcessHacker.Components.NodePlotter.PlotterInfo() { UseSecondLine = true, OverlaySecondLine = false, @@ -198,7 +200,7 @@ public ProcessHacker.Components.NodePlotter.PlotterInfo IoHistory { get { - return new ProcessHacker.Components.NodePlotter.PlotterInfo + return new ProcessHacker.Components.NodePlotter.PlotterInfo() { UseSecondLine = true, OverlaySecondLine = true, @@ -213,7 +215,7 @@ public ProcessHacker.Components.NodePlotter.PlotterInfo IoHistory public string Name { - get { return _pitem.Name ?? string.Empty; } + get { return _pitem.Name ?? ""; } } public string DisplayPid @@ -222,8 +224,8 @@ public string DisplayPid { if (_pitem.Pid >= 0) return _pitem.Pid.ToString(); - - return string.Empty; + else + return ""; } } @@ -234,13 +236,7 @@ public int Pid public int PPid { - get - { - if (_pitem.Pid == _pitem.ParentPid) - return -1; - - return this._pitem.ParentPid; - } + get { if (_pitem.Pid == _pitem.ParentPid) return -1; else return _pitem.ParentPid; } } public string PvtMemory @@ -263,16 +259,19 @@ public string PeakWorkingSet private int GetWorkingSetNumber(NProcessHacker.WsInformationClass WsInformationClass) { - if (_pitem.ProcessQueryHandle == null) - return 0; - + NtStatus status; int wsInfo; int retLen; try { - if (NProcessHacker.PhQueryProcessWs(_pitem.ProcessQueryHandle, WsInformationClass, out wsInfo, 4, out retLen) < NtStatus.Error) - return wsInfo * Program.ProcessProvider.System.PageSize; + using (var phandle = new ProcessHandle(_pitem.Pid, + ProcessAccess.QueryInformation | ProcessAccess.VmRead)) + { + if ((status = NProcessHacker.PhQueryProcessWs(phandle, WsInformationClass, out wsInfo, + 4, out retLen)) < NtStatus.Error) + return wsInfo * Program.ProcessProvider.System.PageSize; + } } catch { } @@ -345,9 +344,9 @@ public string Cpu get { if (_pitem.CpuUsage == 0) - return string.Empty; - - return this._pitem.CpuUsage.ToString("F2"); + return ""; + else + return _pitem.CpuUsage.ToString("F2"); } } @@ -361,9 +360,9 @@ public string SessionId get { if (Pid < 4) - return string.Empty; - - return this._pitem.SessionId.ToString(); + return ""; + else + return _pitem.SessionId.ToString(); } } @@ -371,16 +370,14 @@ public string PriorityClass { get { - if (_pitem.ProcessQueryHandle == null) - return string.Empty; - try { - return PhUtils.FormatPriorityClass(_pitem.ProcessQueryHandle.PriorityClass); + using (var phandle = new ProcessHandle(Pid, Program.MinProcessQueryRights)) + return PhUtils.FormatPriorityClass(phandle.GetPriorityClass()); } catch { - return string.Empty; + return ""; } } } @@ -390,9 +387,9 @@ public string BasePriority get { if (Pid < 4) - return string.Empty; - - return this._pitem.Process.BasePriority.ToString(); + return ""; + else + return _pitem.Process.BasePriority.ToString(); } } @@ -400,22 +397,16 @@ public string Description { get { - switch (this.Pid) - { - case 0: - return "System Idle Process"; - case -2: - return "Deferred Procedure Calls"; - case -3: - return "Interrupts"; - default: - { - if (this._pitem.VersionInfo != null && !string.IsNullOrEmpty(this._pitem.VersionInfo.FileDescription)) - return this._pitem.VersionInfo.FileDescription; - - return string.Empty; - } - } + if (Pid == 0) + return "System Idle Process"; + else if (Pid == -2) + return "Deferred Procedure Calls"; + else if (Pid == -3) + return "Interrupts"; + else if (_pitem.VersionInfo != null && _pitem.VersionInfo.FileDescription != null) + return _pitem.VersionInfo.FileDescription; + else + return ""; } } @@ -423,10 +414,10 @@ public string Company { get { - if (_pitem.VersionInfo != null && !string.IsNullOrEmpty(_pitem.VersionInfo.CompanyName)) + if (_pitem.VersionInfo != null && _pitem.VersionInfo.CompanyName != null) return _pitem.VersionInfo.CompanyName; - - return string.Empty; + else + return ""; } } @@ -434,10 +425,10 @@ public string FileName { get { - if (string.IsNullOrEmpty(_pitem.FileName)) - return string.Empty; - - return this._pitem.FileName; + if (_pitem.FileName == null) + return ""; + else + return _pitem.FileName; } } @@ -445,10 +436,10 @@ public string CommandLine { get { - if (string.IsNullOrEmpty(_pitem.CmdLine)) - return string.Empty; - - return this._pitem.CmdLine;//.Replace("\0", string.Empty); + if (_pitem.CmdLine == null) + return ""; + else + return _pitem.CmdLine.Replace("\0", ""); } } @@ -457,9 +448,9 @@ public string Threads get { if (Pid < 4) - return string.Empty; - - return this._pitem.Process.NumberOfThreads.ToString(); + return ""; + else + return _pitem.Process.NumberOfThreads.ToString(); } } @@ -468,9 +459,9 @@ public string Handles get { if (Pid < 4) - return string.Empty; - - return this._pitem.Process.HandleCount.ToString(); + return ""; + else + return _pitem.Process.HandleCount.ToString(); } } @@ -478,12 +469,10 @@ public int GdiHandlesNumber { get { - if (_pitem.ProcessQueryHandle == null) - return 0; - try { - return _pitem.ProcessQueryHandle.GetGuiResources(false); + using (var phandle = new ProcessHandle(Pid, ProcessAccess.QueryInformation)) + return phandle.GetGuiResources(false); } catch { @@ -497,14 +486,16 @@ public string GdiHandles get { if (Pid < 4) - return string.Empty; - - int number = this.GdiHandlesNumber; + return ""; + else + { + int number = this.GdiHandlesNumber; - if (number == 0) - return string.Empty; - - return number.ToString(); + if (number == 0) + return ""; + else + return number.ToString(); + } } } @@ -512,12 +503,10 @@ public int UserHandlesNumber { get { - if (_pitem.ProcessQueryHandle == null) - return 0; - try { - return _pitem.ProcessQueryHandle.GetGuiResources(true); + using (var phandle = new ProcessHandle(Pid, ProcessAccess.QueryInformation)) + return phandle.GetGuiResources(true); } catch { @@ -531,20 +520,26 @@ public string UserHandles get { if (Pid < 4) - return string.Empty; - - int number = this.UserHandlesNumber; + return ""; + else + { + int number = this.UserHandlesNumber; - if (number == 0) - return string.Empty; - - return number.ToString(); + if (number == 0) + return ""; + else + return number.ToString(); + } } } public long IoTotalNumber { - get { return (_pitem.IoReadDelta.Delta + _pitem.IoWriteDelta.Delta + _pitem.IoOtherDelta.Delta) * 1000 / Settings.Instance.RefreshInterval; } + get + { + return (_pitem.IoReadDelta.Delta + _pitem.IoWriteDelta.Delta + + _pitem.IoOtherDelta.Delta) * 1000 / Settings.Instance.RefreshInterval; + } } public string IoTotal @@ -552,9 +547,9 @@ public string IoTotal get { if (this.IoTotalNumber == 0) - return string.Empty; - - return Utils.FormatSize(this.IoTotalNumber) + "/s"; + return ""; + else + return Utils.FormatSize(this.IoTotalNumber) + "/s"; } } @@ -562,7 +557,8 @@ public long IoReadOtherNumber { get { - return (_pitem.IoReadDelta.Delta + _pitem.IoOtherDelta.Delta) * 1000 / Settings.Instance.RefreshInterval; + return (_pitem.IoReadDelta.Delta + _pitem.IoOtherDelta.Delta) * 1000 / + Settings.Instance.RefreshInterval; } } @@ -571,15 +567,19 @@ public string IoReadOther get { if (this.IoReadOtherNumber == 0) - return string.Empty; - - return Utils.FormatSize(this.IoReadOtherNumber) + "/s"; + return ""; + else + return Utils.FormatSize(this.IoReadOtherNumber) + "/s"; } } public long IoWriteNumber { - get { return _pitem.IoWriteDelta.Delta * 1000 / Settings.Instance.RefreshInterval; } + get + { + return _pitem.IoWriteDelta.Delta * 1000 / + Settings.Instance.RefreshInterval; + } } public string IoWrite @@ -587,9 +587,9 @@ public string IoWrite get { if (this.IoWriteNumber == 0) - return string.Empty; - - return Utils.FormatSize(this.IoWriteNumber) + "/s"; + return ""; + else + return Utils.FormatSize(this.IoWriteNumber) + "/s"; } } @@ -607,12 +607,9 @@ public int IoPriority { get { - if (_pitem.ProcessQueryHandle == null) - return 0; - try { - return _pitem.ProcessQueryHandle.IoPriority; + return _pitem.ProcessQueryHandle.GetIoPriority(); } catch { @@ -625,12 +622,9 @@ public int PagePriority { get { - if (_pitem.ProcessQueryHandle == null) - return 0; - try { - return _pitem.ProcessQueryHandle.PagePriority; + return _pitem.ProcessQueryHandle.GetPagePriority(); } catch { @@ -649,9 +643,9 @@ public string StartTime get { if (Pid < 4 || _pitem.CreateTime.Year == 1) - return string.Empty; - - return this._pitem.CreateTime.ToString(); + return ""; + else + return _pitem.CreateTime.ToString(); } } @@ -660,9 +654,9 @@ public string RelativeStartTime get { if (Pid < 4 || _pitem.CreateTime.Year == 1) - return string.Empty; - - return Utils.FormatRelativeDateTime(this._pitem.CreateTime); + return ""; + else + return Utils.FormatRelativeDateTime(_pitem.CreateTime); } } @@ -683,12 +677,12 @@ public string UserCpuTime public string VerificationStatus { - get { return _pitem.VerifyResult == VerifyResult.Trusted ? "Verified" : string.Empty; } + get { return _pitem.VerifyResult == VerifyResult.Trusted ? "Verified" : ""; } } public string VerifiedSigner { - get { return _pitem.VerifyResult == VerifyResult.Trusted ? _pitem.VerifySignerName : string.Empty; } + get { return _pitem.VerifyResult == VerifyResult.Trusted ? _pitem.VerifySignerName : ""; } } } } diff --git a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs index 3cfd34fe2..9046d6086 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs +++ b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessToolTipProvider.cs @@ -24,7 +24,6 @@ using System.Collections.Generic; using System.Diagnostics; using Aga.Controls.Tree; -using Microsoft.Win32; using ProcessHacker.Common; using ProcessHacker.Native; using ProcessHacker.Native.Api; @@ -33,7 +32,7 @@ namespace ProcessHacker { public class ProcessToolTipProvider : IToolTipProvider { - private readonly ProcessTree _tree; + private ProcessTree _tree; public ProcessToolTipProvider(ProcessTree owner) { @@ -47,18 +46,18 @@ public string GetToolTip(TreeNodeAdv node, Aga.Controls.Tree.NodeControls.NodeCo // Use the process node's tooltip mechanism to allow caching. if (pNode != null) return pNode.GetTooltipText(this); - - return string.Empty; + else + return ""; } public string GetToolTip(ProcessNode pNode) { try { - string cmdText = (!string.IsNullOrEmpty(pNode.ProcessItem.CmdLine) ? - (Utils.CreateEllipsis(pNode.ProcessItem.CmdLine.Replace("\0", string.Empty), 100) + "\n") : string.Empty); + string cmdText = (pNode.ProcessItem.CmdLine != null ? + (Utils.CreateEllipsis(pNode.ProcessItem.CmdLine.Replace("\0", ""), 100) + "\n") : ""); - string fileText = string.Empty; + string fileText = ""; try { @@ -66,21 +65,22 @@ public string GetToolTip(ProcessNode pNode) { var info = pNode.ProcessItem.VersionInfo; - fileText = "File:\n" + PhUtils.FormatFileInfo(info.FileName, info.FileDescription, info.CompanyName, info.FileVersion, 4); + fileText = "File:\n" + PhUtils.FormatFileInfo( + info.FileName, info.FileDescription, info.CompanyName, info.FileVersion, 4); } } catch { - if (!string.IsNullOrEmpty(pNode.ProcessItem.FileName)) + if (pNode.ProcessItem.FileName != null) fileText = "File:\n " + pNode.ProcessItem.FileName; } - string runDllText = string.Empty; + string runDllText = ""; - if (!string.IsNullOrEmpty(pNode.ProcessItem.FileName) && + if (pNode.ProcessItem.FileName != null && pNode.ProcessItem.FileName.EndsWith("\\rundll32.exe", StringComparison.InvariantCultureIgnoreCase) && - !string.IsNullOrEmpty(pNode.ProcessItem.CmdLine)) + pNode.ProcessItem.CmdLine != null) { try { @@ -88,7 +88,7 @@ public string GetToolTip(ProcessNode pNode) string targetFile = pNode.ProcessItem.CmdLine.Split(new char[] { ' ' }, 2)[1].Split(',')[0]; // if it doesn't specify an absolute path, assume it's in system32. - if (!targetFile.Contains(":", StringComparison.OrdinalIgnoreCase)) + if (!targetFile.Contains(":")) targetFile = Environment.SystemDirectory + "\\" + targetFile; FileVersionInfo info = FileVersionInfo.GetVersionInfo(targetFile); @@ -103,32 +103,31 @@ public string GetToolTip(ProcessNode pNode) } } - string dllhostText = string.Empty; + string dllhostText = ""; - if (!string.IsNullOrEmpty(pNode.ProcessItem.FileName) && - pNode.ProcessItem.FileName.EndsWith("\\dllhost.exe", StringComparison.InvariantCultureIgnoreCase) && - !string.IsNullOrEmpty(pNode.ProcessItem.CmdLine)) + if (pNode.ProcessItem.FileName != null && + pNode.ProcessItem.FileName.EndsWith("\\dllhost.exe", + StringComparison.InvariantCultureIgnoreCase) && + pNode.ProcessItem.CmdLine != null) { try { - string clsid = pNode.ProcessItem.CmdLine.ToLowerInvariant().Split(new[] - { - "/processid:" - }, StringSplitOptions.None)[1].Split(' ')[0]; - - using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("CLSID\\" + clsid)) - using (RegistryKey inprocServer32 = key.OpenSubKey("InprocServer32")) + string clsid = pNode.ProcessItem.CmdLine.ToLowerInvariant().Split( + new string[] { "/processid:" }, StringSplitOptions.None)[1].Split(' ')[0]; + using (var key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID\\" + clsid)) { - string name = key.GetValue(string.Empty) as string; - string fileName = inprocServer32.GetValue(string.Empty) as string; + using (var inprocServer32 = key.OpenSubKey("InprocServer32")) + { + string name = key.GetValue("") as string; + string fileName = inprocServer32.GetValue("") as string; - FileVersionInfo info = FileVersionInfo.GetVersionInfo(Environment.ExpandEnvironmentVariables(fileName)); + FileVersionInfo info = FileVersionInfo.GetVersionInfo(Environment.ExpandEnvironmentVariables(fileName)); - dllhostText = "\nCOM Target:\n " + name + " (" + clsid.ToUpper() + ")\n " + - info.FileName + "\n " + - info.FileDescription + " " + info.FileVersion + "\n " + info.CompanyName; + dllhostText = "\nCOM Target:\n " + name + " (" + clsid.ToUpper() + ")\n " + + info.FileName + "\n " + + info.FileDescription + " " + info.FileVersion + "\n " + info.CompanyName; + } } - } catch (Exception ex) { @@ -136,7 +135,7 @@ public string GetToolTip(ProcessNode pNode) } } - string servicesText = string.Empty; + string servicesText = ""; try { @@ -160,8 +159,9 @@ public string GetToolTip(ProcessNode pNode) { if (services.ContainsKey(service)) { - if (string.IsNullOrEmpty(services[service].Status.DisplayName)) - servicesText += " " + service + " (" + services[service].Status.DisplayName + ")\n"; + if (services[service].Status.DisplayName != "") + servicesText += " " + service + " (" + + services[service].Status.DisplayName + ")\n"; else servicesText += " " + service + "\n"; } @@ -179,7 +179,7 @@ public string GetToolTip(ProcessNode pNode) Logging.Log(ex); } - string otherNotes = string.Empty; + string otherNotes = ""; try { @@ -202,7 +202,7 @@ public string GetToolTip(ProcessNode pNode) else if (pNode.ProcessItem.VerifyResult == VerifyResult.Unknown && !Settings.Instance.VerifySignatures) { - otherNotes += string.Empty; + otherNotes += ""; } else if (pNode.ProcessItem.VerifyResult == VerifyResult.Unknown && Settings.Instance.VerifySignatures && !_tree.DumpMode) @@ -231,7 +231,7 @@ public string GetToolTip(ProcessNode pNode) if (pNode.ProcessItem.IsWow64) otherNotes += "\n Process is 32-bit (running under WOW64)."; - if (otherNotes != string.Empty) + if (otherNotes != "") otherNotes = "\nNotes:" + otherNotes; } catch (Exception ex) diff --git a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.Designer.cs b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.Designer.cs index c7108c9c5..4726cdc9a 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.Designer.cs @@ -112,6 +112,7 @@ private void InitializeComponent() // // treeProcesses // + this.treeProcesses.AllowColumnReorder = true; this.treeProcesses.BackColor = System.Drawing.SystemColors.Window; this.treeProcesses.Columns.Add(this.columnName); this.treeProcesses.Columns.Add(this.columnPID); @@ -153,7 +154,10 @@ private void InitializeComponent() this.treeProcesses.Columns.Add(this.columnVerificationStatus); this.treeProcesses.Columns.Add(this.columnVerifiedSigner); this.treeProcesses.DefaultToolTipProvider = null; + this.treeProcesses.DisplayDraggingNodes = true; this.treeProcesses.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeProcesses.DragDropMarkColor = System.Drawing.Color.Black; + this.treeProcesses.FullRowSelect = true; this.treeProcesses.LineColor = System.Drawing.SystemColors.ControlDark; this.treeProcesses.Location = new System.Drawing.Point(0, 0); this.treeProcesses.Model = null; @@ -203,6 +207,7 @@ private void InitializeComponent() this.treeProcesses.ShowNodeToolTips = true; this.treeProcesses.Size = new System.Drawing.Size(808, 472); this.treeProcesses.TabIndex = 2; + this.treeProcesses.UseColumns = true; this.treeProcesses.NodeMouseDoubleClick += new System.EventHandler(this.treeProcesses_NodeMouseDoubleClick); this.treeProcesses.SelectionChanged += new System.EventHandler(this.treeProcesses_SelectionChanged); this.treeProcesses.ColumnClicked += new System.EventHandler(this.treeProcesses_ColumnClicked); @@ -961,6 +966,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.treeProcesses); + this.DoubleBuffered = true; this.Name = "ProcessTree"; this.Size = new System.Drawing.Size(808, 472); this.ResumeLayout(false); diff --git a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs index 414f3cd81..21783eca3 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs +++ b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTree.cs @@ -35,51 +35,47 @@ public partial class ProcessTree : UserControl { private ProcessSystemProvider _provider; private ProcessTreeModel _treeModel; - private readonly ProcessToolTipProvider _tooltipProvider; - private int _runCount; + private ProcessToolTipProvider _tooltipProvider; + private int _runCount = 0; public new event KeyEventHandler KeyDown; public new event MouseEventHandler MouseDown; public new event MouseEventHandler MouseUp; public new event EventHandler DoubleClick; public event EventHandler SelectionChanged; public event EventHandler NodeMouseDoubleClick; - private readonly object _listLock = new object(); + private object _listLock = new object(); private bool _draw = true; - private bool _dumpMode; + private bool _dumpMode = false; public ProcessTree() { InitializeComponent(); - TreeColumn column = new TreeColumn("CPU History", 60) - { - IsVisible = false, - MinColumnWidth = 10 - }; + var column = new TreeColumn("CPU History", 60); + column.IsVisible = false; + column.MinColumnWidth = 10; treeProcesses.Columns.Add(column); - treeProcesses.NodeControls.Add(new Components.NodePlotter + treeProcesses.NodeControls.Add(new ProcessHacker.Components.NodePlotter() { DataPropertyName = "CpuHistory", ParentColumn = column }); - column = new TreeColumn("I/O History", 60) - { - IsVisible = false, - MinColumnWidth = 10 - }; + column = new TreeColumn("I/O History", 60); + column.IsVisible = false; + column.MinColumnWidth = 10; treeProcesses.Columns.Add(column); - treeProcesses.NodeControls.Add(new Components.NodePlotter + treeProcesses.NodeControls.Add(new ProcessHacker.Components.NodePlotter() { DataPropertyName = "IoHistory", ParentColumn = column }); - treeProcesses.KeyDown += this.ProcessTree_KeyDown; - treeProcesses.MouseDown += this.treeProcesses_MouseDown; - treeProcesses.MouseUp += this.treeProcesses_MouseUp; - treeProcesses.DoubleClick += this.treeProcesses_DoubleClick; + treeProcesses.KeyDown += new KeyEventHandler(ProcessTree_KeyDown); + treeProcesses.MouseDown += new MouseEventHandler(treeProcesses_MouseDown); + treeProcesses.MouseUp += new MouseEventHandler(treeProcesses_MouseUp); + treeProcesses.DoubleClick += new EventHandler(treeProcesses_DoubleClick); nodeName.ToolTipProvider = _tooltipProvider = new ProcessToolTipProvider(this); @@ -264,15 +260,15 @@ private void provider_Updated() { if (_draw) { - this.BeginInvoke(new MethodInvoker(() => + this.BeginInvoke(new MethodInvoker(delegate { - if (this._treeModel.GetSortColumn() != string.Empty) + if (_treeModel.GetSortColumn() != "") { - this._treeModel.CallStructureChanged(new TreePathEventArgs(new TreePath())); + _treeModel.CallStructureChanged(new TreePathEventArgs(new TreePath())); } //treeProcesses.InvalidateNodeControlCache(); - this.treeProcesses.Invalidate(); + treeProcesses.Invalidate(); })); } @@ -283,12 +279,12 @@ private void PerformDelayed(int delay, MethodInvoker action) { Timer t = new Timer(); - t.Tick += (sender, args) => + t.Tick += new EventHandler(delegate(object o, EventArgs args) { t.Enabled = false; action(); t.Dispose(); - }; + }); t.Interval = delay; t.Enabled = true; @@ -298,66 +294,50 @@ private Color GetProcessColor(ProcessItem p) { if (Settings.Instance.UseColorDebuggedProcesses && p.IsBeingDebugged) return Settings.Instance.ColorDebuggedProcesses; - - if (Settings.Instance.UseColorElevatedProcesses && p.ElevationType == TokenElevationType.Full) + else if (Settings.Instance.UseColorElevatedProcesses && + p.ElevationType == TokenElevationType.Full) return Settings.Instance.ColorElevatedProcesses; - - if (Settings.Instance.UseColorPosixProcesses && p.IsPosix) + else if (Settings.Instance.UseColorPosixProcesses && + p.IsPosix) return Settings.Instance.ColorPosixProcesses; - - if (Settings.Instance.UseColorWow64Processes && p.IsWow64) + else if (Settings.Instance.UseColorWow64Processes && + p.IsWow64) return Settings.Instance.ColorWow64Processes; - - if (Settings.Instance.UseColorJobProcesses && p.IsInSignificantJob) + else if (Settings.Instance.UseColorJobProcesses && p.IsInSignificantJob) return Settings.Instance.ColorJobProcesses; - - if ( - Settings.Instance.UseColorPackedProcesses && - Settings.Instance.VerifySignatures && - !string.IsNullOrEmpty(p.Name) && + else if (Settings.Instance.UseColorPackedProcesses && + Settings.Instance.VerifySignatures && + p.Name != null && Program.ImposterNames.Contains(p.Name.ToLowerInvariant()) && - p.VerifyResult != VerifyResult.Trusted && - p.VerifyResult != VerifyResult.Unknown && - !string.IsNullOrEmpty(p.FileName) - ) + p.VerifyResult != VerifyResult.Trusted && + p.VerifyResult != VerifyResult.Unknown && + p.FileName != null) return Settings.Instance.ColorPackedProcesses; - - if (Settings.Instance.UseColorPackedProcesses && + else if (Settings.Instance.UseColorPackedProcesses && Settings.Instance.VerifySignatures && p.VerifyResult != VerifyResult.Trusted && p.VerifyResult != VerifyResult.NoSignature && p.VerifyResult != VerifyResult.Unknown) return Settings.Instance.ColorPackedProcesses; - - if (Settings.Instance.UseColorDotNetProcesses && p.IsDotNet) + else if (Settings.Instance.UseColorDotNetProcesses && p.IsDotNet) return Settings.Instance.ColorDotNetProcesses; - - if (Settings.Instance.UseColorPackedProcesses && p.IsPacked) + else if (Settings.Instance.UseColorPackedProcesses && p.IsPacked) return Settings.Instance.ColorPackedProcesses; - - if (this._dumpMode && Settings.Instance.UseColorServiceProcesses && - this.DumpProcessServices.ContainsKey(p.Pid) && this.DumpProcessServices[p.Pid].Count > 0) + else if (_dumpMode && Settings.Instance.UseColorServiceProcesses && + DumpProcessServices.ContainsKey(p.Pid) && DumpProcessServices[p.Pid].Count > 0) return Settings.Instance.ColorServiceProcesses; - - if (!this._dumpMode && Settings.Instance.UseColorServiceProcesses && + else if (!_dumpMode && Settings.Instance.UseColorServiceProcesses && Program.HackerWindow.ProcessServices.ContainsKey(p.Pid) && Program.HackerWindow.ProcessServices[p.Pid].Count > 0) return Settings.Instance.ColorServiceProcesses; - - if (Settings.Instance.UseColorSystemProcesses && string.Equals(p.Username, "NT AUTHORITY\\SYSTEM", StringComparison.OrdinalIgnoreCase)) + else if (Settings.Instance.UseColorSystemProcesses && p.Username == "NT AUTHORITY\\SYSTEM") return Settings.Instance.ColorSystemProcesses; - - if (this._dumpMode && - Settings.Instance.UseColorOwnProcesses && - string.Equals(p.Username, this.DumpUserName, StringComparison.OrdinalIgnoreCase)) + else if (_dumpMode && Settings.Instance.UseColorOwnProcesses && p.Username == DumpUserName) return Settings.Instance.ColorOwnProcesses; - - if (!this._dumpMode && - Settings.Instance.UseColorOwnProcesses && - string.Equals(p.Username, Program.CurrentUsername, StringComparison.OrdinalIgnoreCase)) + else if (!_dumpMode && Settings.Instance.UseColorOwnProcesses && p.Username == Program.CurrentUsername) return Settings.Instance.ColorOwnProcesses; - - return SystemColors.Window; + else + return SystemColors.Window; } public void AddItem(ProcessItem item) @@ -372,25 +352,25 @@ public void UpdateItems() private void provider_DictionaryAdded(ProcessItem item) { - this.BeginInvoke(new MethodInvoker(() => + this.BeginInvoke(new MethodInvoker(delegate { - lock (this._listLock) + lock (_listLock) { - this._treeModel.Add(item); + _treeModel.Add(item); TreeNodeAdv node = this.FindTreeNode(item.Pid); if (node != null) { - if (item.RunId > 0 && this._runCount > 0) + if (item.RunId > 0 && _runCount > 0) { node.State = TreeNodeAdv.NodeState.New; - - this.PerformDelayed(Settings.Instance.HighlightingDuration, () => + this.PerformDelayed(Settings.Instance.HighlightingDuration, + new MethodInvoker(delegate { node.State = TreeNodeAdv.NodeState.Normal; - this.treeProcesses.Invalidate(); - }); + treeProcesses.Invalidate(); + })); } node.BackColor = this.GetProcessColor(item); @@ -402,9 +382,9 @@ private void provider_DictionaryAdded(ProcessItem item) private void provider_DictionaryModified(ProcessItem oldItem, ProcessItem newItem) { - this.BeginInvoke(new MethodInvoker(() => + this.BeginInvoke(new MethodInvoker(delegate { - lock (this._listLock) + lock (_listLock) { TreeNodeAdv node = this.FindTreeNode(newItem.Pid); @@ -413,16 +393,16 @@ private void provider_DictionaryModified(ProcessItem oldItem, ProcessItem newIte node.BackColor = this.GetProcessColor(newItem); } - this._treeModel.Nodes[newItem.Pid].ProcessItem = newItem; + _treeModel.Nodes[newItem.Pid].ProcessItem = newItem; } })); } private void provider_DictionaryRemoved(ProcessItem item) { - this.BeginInvoke(new MethodInvoker(() => + this.BeginInvoke(new MethodInvoker(delegate { - lock (this._listLock) + lock (_listLock) { TreeNodeAdv node = this.FindTreeNode(item.Pid); @@ -430,27 +410,27 @@ private void provider_DictionaryRemoved(ProcessItem item) { //if (this.StateHighlighting) //{ - node.State = TreeNodeAdv.NodeState.Removed; - - this.PerformDelayed(Settings.Instance.HighlightingDuration, () => - { - try - { - this._treeModel.Remove(item); - this.RefreshItems(); - } - catch (Exception ex) + node.State = TreeNodeAdv.NodeState.Removed; + this.PerformDelayed(Settings.Instance.HighlightingDuration, + new MethodInvoker(delegate { - Logging.Log(ex); - } - }); + try + { + _treeModel.Remove(item); + this.RefreshItems(); + } + catch (Exception ex) + { + Logging.Log(ex); + } + })); //} //else //{ // _treeModel.Remove(item); //} - this.treeProcesses.Invalidate(); + treeProcesses.Invalidate(); } } })); @@ -498,8 +478,8 @@ public TreeNodeAdv FindTreeNode(int pid) { if (_treeModel.Nodes.ContainsKey(pid)) return treeProcesses.FindNode(_treeModel.GetPath(_treeModel.Nodes[pid])); - - return null; + else + return null; } public TreeNodeAdv FindTreeNode(ProcessNode node) diff --git a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs index be57269b4..d3583a538 100644 --- a/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs +++ b/1.x/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs @@ -37,9 +37,9 @@ namespace ProcessHacker /// public class ProcessTreeModel : ITreeModel { - private readonly ProcessTree _tree; - private readonly Dictionary _processes = new Dictionary(); - private readonly List _roots = new List(); + private ProcessTree _tree; + private Dictionary _processes = new Dictionary(); + private List _roots = new List(); public ProcessTreeModel(ProcessTree tree) { @@ -109,7 +109,7 @@ public void Modify(ProcessItem oldItem, ProcessItem newItem) public void Remove(ProcessItem item) { ProcessNode itemNode = _processes[item.Pid]; - ProcessNode[] itemChildren; + ProcessNode[] itemChildren = null; // Dispose of the process node we're removing. itemNode.Dispose(); @@ -141,19 +141,21 @@ public void Remove(ProcessItem item) this.StructureChanged(this, new TreePathEventArgs(new TreePath())); // Expand the children because TreeViewAdv collapses them by default. - foreach (ProcessNode n in itemChildren) + if (itemChildren != null) { - try + foreach (ProcessNode n in itemChildren) { - _tree.FindTreeNode(n).ExpandAll(); - } - catch (Exception ex) - { - Logging.Log(ex); + try + { + _tree.FindTreeNode(n).ExpandAll(); + } + catch (Exception ex) + { + Logging.Log(ex); + } } } - _tree.Invalidate(); } @@ -162,12 +164,14 @@ public TreePath GetPath(ProcessNode node) if (node == null) return TreePath.Empty; - if (this.GetSortColumn() != string.Empty) + if (this.GetSortColumn() != "") { return new TreePath(node); } - - return node.TreePath; + else + { + return node.TreePath; + } } public void MoveChildrenToRoot(ProcessNode node) @@ -199,7 +203,7 @@ public string GetSortColumn() if (column.SortOrder != SortOrder.None) return column.Header.ToLowerInvariant(); - return string.Empty; + return ""; } public SortOrder GetSortOrder() @@ -213,20 +217,17 @@ public SortOrder GetSortOrder() public int ModifySort(int sortResult, SortOrder order) { - switch (order) - { - case SortOrder.Ascending: - return -sortResult; - case SortOrder.Descending: - return sortResult; - } - - return 0; + if (order == SortOrder.Ascending) + return -sortResult; + else if (order == SortOrder.Descending) + return sortResult; + else + return 0; } public System.Collections.IEnumerable GetChildren(TreePath treePath) { - if (this.GetSortColumn() != string.Empty) + if (this.GetSortColumn() != "") { List nodes = new List(); string sortC = this.GetSortColumn(); @@ -234,140 +235,143 @@ public System.Collections.IEnumerable GetChildren(TreePath treePath) nodes.AddRange(_processes.Values); - nodes.Sort((n1, n2) => - { - // We have a problem here - the GdiHandlesNumber and UserHandlesNumber - // properties are dynamically retrieved, so if n1 == n2 we may end up - // getting different values for the same process due to the timing. - // If we do, then Array.Sort will throw an exception. - // - // The temporary HACK used here is to return 0 whenever n1 == n2. - if (n1 == n2) - return 0; - - switch (sortC) + nodes.Sort(new Comparison(delegate(ProcessNode n1, ProcessNode n2) { - case "name": - return this.ModifySort(string.Compare(n1.Name, n2.Name), sortO); - case "pid": - return this.ModifySort(n1.Pid.CompareTo(n2.Pid), sortO); - case "pvt. memory": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PrivatePageCount.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.PrivatePageCount), sortO); - case "working set": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.WorkingSetSize.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.WorkingSetSize), sortO); - case "peak working set": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakWorkingSetSize.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.PeakWorkingSetSize), sortO); - case "private ws": - return this.ModifySort(n1.PrivateWorkingSetNumber.CompareTo(n2.PrivateWorkingSetNumber), sortO); - case "shared ws": - return this.ModifySort(n1.SharedWorkingSetNumber.CompareTo(n2.SharedWorkingSetNumber), sortO); - case "shareable ws": - return this.ModifySort(n1.ShareableWorkingSetNumber.CompareTo(n2.ShareableWorkingSetNumber), sortO); - case "virtual size": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.VirtualSize.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.VirtualSize), sortO); - case "peak virtual size": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakVirtualSize.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.PeakVirtualSize), sortO); - case "pagefile usage": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PagefileUsage.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.PagefileUsage), sortO); - case "peak pagefile usage": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakPagefileUsage.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.PeakPagefileUsage), sortO); - case "page faults": - return this.ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PageFaultCount.CompareTo( - n2.ProcessItem.Process.VirtualMemoryCounters.PageFaultCount), sortO); - case "cpu": - return this.ModifySort(n1.ProcessItem.CpuUsage.CompareTo(n2.ProcessItem.CpuUsage), sortO); - case "username": - return this.ModifySort(string.Compare(n1.Username, n2.Username), sortO); - case "session id": - return this.ModifySort(n1.ProcessItem.SessionId.CompareTo(n2.ProcessItem.SessionId), sortO); - case "priority class": - case "base priority": - return this.ModifySort(n1.ProcessItem.Process.BasePriority.CompareTo( - n2.ProcessItem.Process.BasePriority), sortO); - case "description": - return this.ModifySort(string.Compare(n1.Description, n2.Description), sortO); - case "company": - return this.ModifySort(string.Compare(n1.Company, n2.Company), sortO); - case "file name": - return this.ModifySort(string.Compare(n1.FileName, n2.FileName), sortO); - case "command line": - return this.ModifySort(string.Compare(n1.CommandLine, n2.CommandLine), sortO); - case "threads": - return this.ModifySort(n1.ProcessItem.Process.NumberOfThreads.CompareTo( - n2.ProcessItem.Process.NumberOfThreads), sortO); - case "handles": - return this.ModifySort(n1.ProcessItem.Process.HandleCount.CompareTo( - n2.ProcessItem.Process.HandleCount), sortO); - case "gdi handles": - return this.ModifySort(n1.GdiHandlesNumber.CompareTo(n2.GdiHandlesNumber), sortO); - case "user handles": - return this.ModifySort(n1.UserHandlesNumber.CompareTo(n2.UserHandlesNumber), sortO); - case "i/o total": - return this.ModifySort(n1.IoTotalNumber.CompareTo(n2.IoTotalNumber), sortO); - case "i/o ro": - return this.ModifySort(n1.IoReadOtherNumber.CompareTo(n2.IoReadOtherNumber), sortO); - case "i/o w": - return this.ModifySort(n1.IoWriteNumber.CompareTo(n2.IoWriteNumber), sortO); - case "integrity": - return this.ModifySort(n1.IntegrityLevel.CompareTo(n2.IntegrityLevel), sortO); - case "i/o priority": - return this.ModifySort(n1.IoPriority.CompareTo(n2.IoPriority), sortO); - case "page priority": - return this.ModifySort(n1.PagePriority.CompareTo(n2.PagePriority), sortO); - case "start time": - return this.ModifySort(n1.ProcessItem.CreateTime.CompareTo(n2.ProcessItem.CreateTime), sortO); - case "start time (relative)": - // Invert the order - bigger dates are actually smaller if we use the relative time span. - return -this.ModifySort(n1.ProcessItem.CreateTime.CompareTo(n2.ProcessItem.CreateTime), sortO); - case "total cpu time": - return this.ModifySort((n1.ProcessItem.Process.KernelTime + n1.ProcessItem.Process.UserTime). - CompareTo(n2.ProcessItem.Process.KernelTime + n2.ProcessItem.Process.UserTime), sortO); - case "kernel cpu time": - return this.ModifySort(n1.ProcessItem.Process.KernelTime.CompareTo( - n2.ProcessItem.Process.KernelTime), sortO); - case "user cpu time": - return this.ModifySort(n1.ProcessItem.Process.UserTime.CompareTo( - n2.ProcessItem.Process.UserTime), sortO); - case "verification status": - return this.ModifySort(string.Compare(n1.VerificationStatus, n2.VerificationStatus), sortO); - case "verified signer": - return this.ModifySort(string.Compare(n1.VerifiedSigner, n2.VerifiedSigner), sortO); - default: + // We have a problem here - the GdiHandlesNumber and UserHandlesNumber + // properties are dynamically retrieved, so if n1 == n2 we may end up + // getting different values for the same process due to the timing. + // If we do, then Array.Sort will throw an exception. + // + // The temporary HACK used here is to return 0 whenever n1 == n2. + if (n1 == n2) return 0; - } - }); + + switch (sortC) + { + case "name": + return ModifySort(string.Compare(n1.Name, n2.Name), sortO); + case "pid": + return ModifySort(n1.Pid.CompareTo(n2.Pid), sortO); + case "pvt. memory": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PrivatePageCount.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.PrivatePageCount), sortO); + case "working set": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.WorkingSetSize.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.WorkingSetSize), sortO); + case "peak working set": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakWorkingSetSize.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.PeakWorkingSetSize), sortO); + case "private ws": + return ModifySort(n1.PrivateWorkingSetNumber.CompareTo(n2.PrivateWorkingSetNumber), sortO); + case "shared ws": + return ModifySort(n1.SharedWorkingSetNumber.CompareTo(n2.SharedWorkingSetNumber), sortO); + case "shareable ws": + return ModifySort(n1.ShareableWorkingSetNumber.CompareTo(n2.ShareableWorkingSetNumber), sortO); + case "virtual size": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.VirtualSize.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.VirtualSize), sortO); + case "peak virtual size": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakVirtualSize.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.PeakVirtualSize), sortO); + case "pagefile usage": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PagefileUsage.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.PagefileUsage), sortO); + case "peak pagefile usage": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakPagefileUsage.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.PeakPagefileUsage), sortO); + case "page faults": + return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PageFaultCount.CompareTo( + n2.ProcessItem.Process.VirtualMemoryCounters.PageFaultCount), sortO); + case "cpu": + return ModifySort(n1.ProcessItem.CpuUsage.CompareTo(n2.ProcessItem.CpuUsage), sortO); + case "username": + return ModifySort(string.Compare(n1.Username, n2.Username), sortO); + case "session id": + return ModifySort(n1.ProcessItem.SessionId.CompareTo(n2.ProcessItem.SessionId), sortO); + case "priority class": + case "base priority": + return ModifySort(n1.ProcessItem.Process.BasePriority.CompareTo( + n2.ProcessItem.Process.BasePriority), sortO); + case "description": + return ModifySort(string.Compare(n1.Description, n2.Description), sortO); + case "company": + return ModifySort(string.Compare(n1.Company, n2.Company), sortO); + case "file name": + return ModifySort(string.Compare(n1.FileName, n2.FileName), sortO); + case "command line": + return ModifySort(string.Compare(n1.CommandLine, n2.CommandLine), sortO); + case "threads": + return ModifySort(n1.ProcessItem.Process.NumberOfThreads.CompareTo( + n2.ProcessItem.Process.NumberOfThreads), sortO); + case "handles": + return ModifySort(n1.ProcessItem.Process.HandleCount.CompareTo( + n2.ProcessItem.Process.HandleCount), sortO); + case "gdi handles": + return ModifySort(n1.GdiHandlesNumber.CompareTo(n2.GdiHandlesNumber), sortO); + case "user handles": + return ModifySort(n1.UserHandlesNumber.CompareTo(n2.UserHandlesNumber), sortO); + case "i/o total": + return ModifySort(n1.IoTotalNumber.CompareTo(n2.IoTotalNumber), sortO); + case "i/o ro": + return ModifySort(n1.IoReadOtherNumber.CompareTo(n2.IoReadOtherNumber), sortO); + case "i/o w": + return ModifySort(n1.IoWriteNumber.CompareTo(n2.IoWriteNumber), sortO); + case "integrity": + return ModifySort(n1.IntegrityLevel.CompareTo(n2.IntegrityLevel), sortO); + case "i/o priority": + return ModifySort(n1.IoPriority.CompareTo(n2.IoPriority), sortO); + case "page priority": + return ModifySort(n1.PagePriority.CompareTo(n2.PagePriority), sortO); + case "start time": + return ModifySort(n1.ProcessItem.CreateTime.CompareTo(n2.ProcessItem.CreateTime), sortO); + case "start time (relative)": + // Invert the order - bigger dates are actually smaller if we use the relative time span. + return -ModifySort(n1.ProcessItem.CreateTime.CompareTo(n2.ProcessItem.CreateTime), sortO); + case "total cpu time": + return ModifySort((n1.ProcessItem.Process.KernelTime + n1.ProcessItem.Process.UserTime). + CompareTo(n2.ProcessItem.Process.KernelTime + n2.ProcessItem.Process.UserTime), sortO); + case "kernel cpu time": + return ModifySort(n1.ProcessItem.Process.KernelTime.CompareTo( + n2.ProcessItem.Process.KernelTime), sortO); + case "user cpu time": + return ModifySort(n1.ProcessItem.Process.UserTime.CompareTo( + n2.ProcessItem.Process.UserTime), sortO); + case "verification status": + return ModifySort(string.Compare(n1.VerificationStatus, n2.VerificationStatus), sortO); + case "verified signer": + return ModifySort(string.Compare(n1.VerifiedSigner, n2.VerifiedSigner), sortO); + default: + return 0; + } + })); return nodes; } if (treePath.IsEmpty()) return _roots; - - return (treePath.LastNode as ProcessNode).Children; + else + return (treePath.LastNode as ProcessNode).Children; } public bool IsLeaf(TreePath treePath) { // When we're sorting the whole tree is a flat list, so there are no children. - if (this.GetSortColumn() != string.Empty) + if (this.GetSortColumn() != "") return true; if (treePath.IsEmpty()) return false; - - return (treePath.LastNode as ProcessNode).Children.Count == 0; + else + return (treePath.LastNode as ProcessNode).Children.Count == 0; } public event EventHandler NodesChanged; + public event EventHandler NodesInserted; + public event EventHandler NodesRemoved; + public event EventHandler StructureChanged; public void CallStructureChanged(TreePathEventArgs args) diff --git a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoveryData.cs b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoveryData.cs index 5b79f4785..d3e500410 100644 --- a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoveryData.cs +++ b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoveryData.cs @@ -67,7 +67,7 @@ public RecoveryData(RecoveryCallback callback, object state) public void Invoke() { if(Callback != null) - Callback(State); + Callback(State); } } } diff --git a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoverySettings.cs b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoverySettings.cs index f8679aadf..0b7d57446 100644 --- a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoverySettings.cs +++ b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RecoverySettings.cs @@ -34,8 +34,8 @@ namespace ProcessHackerRestartRecovery /// public class RecoverySettings { - private readonly RecoveryData recoveryData; - private readonly uint pingInterval; + private RecoveryData recoveryData; + private uint pingInterval; /// /// Initializes a new instance of the RecoverySettings class. @@ -83,10 +83,9 @@ public uint PingInterval public override string ToString() { return String.Format("delegate: {0}, state: {1}, ping: {2}", - this.recoveryData.Callback.Method, - this.recoveryData.State, - this.PingInterval - ); + this.recoveryData.Callback.Method.ToString(), + this.recoveryData.State.ToString(), + this.PingInterval); } } } diff --git a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryInterop.cs b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryInterop.cs index 7a406b735..34976f142 100644 --- a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryInterop.cs +++ b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryInterop.cs @@ -44,7 +44,7 @@ static AppRestartRecoveryNativeMethods() private static UInt32 InternalRecoveryHandler(IntPtr parameter) { - bool cancelled; + bool cancelled = false; ApplicationRecoveryInProgress(out cancelled); GCHandle handle = GCHandle.FromIntPtr(parameter); diff --git a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryManager.cs b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryManager.cs index c42c6bee8..e2ea8dad4 100644 --- a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryManager.cs +++ b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartRecoveryManager.cs @@ -40,7 +40,10 @@ public static class ApplicationRestartRecoveryManager public static void RegisterForRestart() { // Register for automatic restart if the application was terminated for any reason other than a system reboot or a system update. - RegisterForApplicationRestart(new RestartSettings("-recovered", RestartRestrictions.NotOnReboot | RestartRestrictions.NotOnPatch)); + ApplicationRestartRecoveryManager.RegisterForApplicationRestart( + new RestartSettings("-recovered", + RestartRestrictions.NotOnReboot + | RestartRestrictions.NotOnPatch)); } public static void RegisterForRecovery() @@ -49,10 +52,9 @@ public static void RegisterForRecovery() // In some cases it might make sense to pass this initial state. // Another approach: When doing "auto-save", register for recovery everytime, and pass // the current state I.E. data for recovery at that time. - RecoveryData data = new RecoveryData(RecoveryProcedure, null); + RecoveryData data = new RecoveryData(new RecoveryCallback(RecoveryProcedure), null); RecoverySettings settings = new RecoverySettings(data, 0); - - RegisterForApplicationRecovery(settings); + ApplicationRestartRecoveryManager.RegisterForApplicationRecovery(settings); } /// @@ -71,12 +73,12 @@ private static int RecoveryProcedure(object state) try { // Remove the icons or they remain in the system try. - ProcessHacker.Program.HackerWindow.ExecuteOnIcons(icon => icon.Visible = false); - ProcessHacker.Program.HackerWindow.ExecuteOnIcons(icon => icon.Dispose()); + ProcessHacker.Program.HackerWindow.ExecuteOnIcons((icon) => icon.Visible = false); + ProcessHacker.Program.HackerWindow.ExecuteOnIcons((icon) => icon.Dispose()); // Make sure KPH connection is closed. - if (KProcessHacker2.Instance.KphIsConnected) - KProcessHacker2.Instance.Dispose(); + if (ProcessHacker.Native.KProcessHacker.Instance != null) + ProcessHacker.Native.KProcessHacker.Instance.Close(); } catch { } @@ -130,13 +132,10 @@ private static void RegisterForApplicationRecovery(RecoverySettings settings) HResult hr = AppRestartRecoveryNativeMethods.RegisterApplicationRecoveryCallback(AppRestartRecoveryNativeMethods.internalCallback, (IntPtr)handle, settings.PingInterval, (uint)0); - switch (hr) - { - case HResult.InvalidArgument: - throw new ArgumentException("Application was not registered for recovery due to bad parameters."); - case HResult.Fail: - throw new ExternalException("Application failed to register for recovery."); - } + if (hr == HResult.InvalidArgument) + throw new ArgumentException("Application was not registered for recovery due to bad parameters."); + else if (hr == HResult.Fail) + throw new ExternalException("Application failed to register for recovery."); } } @@ -177,7 +176,7 @@ private static bool ApplicationRecoveryInProgress() { if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) { - bool canceled; + bool canceled = false; HResult hr = AppRestartRecoveryNativeMethods.ApplicationRecoveryInProgress(out canceled); @@ -186,8 +185,8 @@ private static bool ApplicationRecoveryInProgress() return canceled; } - - return true; + else + return true; } /// @@ -219,13 +218,10 @@ private static void RegisterForApplicationRestart(RestartSettings settings) { HResult hr = AppRestartRecoveryNativeMethods.RegisterApplicationRestart(settings.Command, settings.Restrictions); - switch (hr) - { - case HResult.Fail: - throw new InvalidOperationException("Application failed to registered for restart."); - case HResult.InvalidArgument: - throw new ArgumentException("Failed to register application for restart due to bad parameters."); - } + if (hr == HResult.Fail) + throw new InvalidOperationException("Application failed to registered for restart."); + else if (hr == HResult.InvalidArgument) + throw new ArgumentException("Failed to register application for restart due to bad parameters."); } } } diff --git a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartSettings.cs b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartSettings.cs index 861f2b5df..877515386 100644 --- a/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartSettings.cs +++ b/1.x/trunk/ProcessHacker/Components/RestartRecoveryLib/RestartSettings.cs @@ -32,8 +32,8 @@ namespace ProcessHackerRestartRecovery /// less than 60 seconds beforeterminating. public class RestartSettings { - private readonly string command; - private readonly RestartRestrictions restrictions; + private string command; + private RestartRestrictions restrictions; /// /// Creates a new instance of the RestartSettings class. diff --git a/1.x/trunk/ProcessHacker/Components/SectionProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/SectionProperties.Designer.cs index 85bd5c3dd..8b9d45ebc 100644 --- a/1.x/trunk/ProcessHacker/Components/SectionProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/SectionProperties.Designer.cs @@ -42,7 +42,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 3); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(61, 13); + this.label1.Size = new System.Drawing.Size(54, 13); this.label1.TabIndex = 0; this.label1.Text = "Attributes:"; // @@ -69,7 +69,7 @@ private void InitializeComponent() this.labelAttributes.AutoSize = true; this.labelAttributes.Location = new System.Drawing.Point(75, 3); this.labelAttributes.Name = "labelAttributes"; - this.labelAttributes.Size = new System.Drawing.Size(38, 13); + this.labelAttributes.Size = new System.Drawing.Size(36, 13); this.labelAttributes.TabIndex = 0; this.labelAttributes.Text = "Image"; // @@ -77,7 +77,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.labelAttributes); this.Controls.Add(this.labelSize); this.Controls.Add(this.label2); diff --git a/1.x/trunk/ProcessHacker/Components/SectionProperties.cs b/1.x/trunk/ProcessHacker/Components/SectionProperties.cs index e0e9cb174..3dcc0c788 100644 --- a/1.x/trunk/ProcessHacker/Components/SectionProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/SectionProperties.cs @@ -6,7 +6,7 @@ namespace ProcessHacker.Components { public partial class SectionProperties : UserControl { - private readonly SectionHandle _sectionHandle; + private SectionHandle _sectionHandle; public SectionProperties(SectionHandle sectionHandle) { diff --git a/1.x/trunk/ProcessHacker/Components/SectionProperties.resx b/1.x/trunk/ProcessHacker/Components/SectionProperties.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/SectionProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/SectionProperties.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.Designer.cs index c187078fb..d158aa1e9 100644 --- a/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.Designer.cs @@ -44,7 +44,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 3); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(84, 13); + this.label1.Size = new System.Drawing.Size(75, 13); this.label1.TabIndex = 0; this.label1.Text = "Current Count:"; // @@ -53,7 +53,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 25); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(94, 13); + this.label2.Size = new System.Drawing.Size(85, 13); this.label2.TabIndex = 0; this.label2.Text = "Maximum Count:"; // @@ -101,7 +101,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.buttonAcquire); this.Controls.Add(this.buttonRelease); this.Controls.Add(this.label2); diff --git a/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.cs b/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.cs index 89e44030b..0cd493efe 100644 --- a/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.cs @@ -9,7 +9,7 @@ namespace ProcessHacker.Components { public partial class SemaphoreProperties : UserControl { - private readonly SemaphoreHandle _semaphoreHandle; + private SemaphoreHandle _semaphoreHandle; public SemaphoreProperties(SemaphoreHandle semaphoreHandle) { diff --git a/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.resx b/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/SemaphoreProperties.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/ServiceList.Designer.cs b/1.x/trunk/ProcessHacker/Components/ServiceList.Designer.cs index e8d1ed296..33bd1aa98 100644 --- a/1.x/trunk/ProcessHacker/Components/ServiceList.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/ServiceList.Designer.cs @@ -34,13 +34,13 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServiceList)); - this.listServices = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnStartType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnPID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listServices = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnDescription = new System.Windows.Forms.ColumnHeader(); + this.columnType = new System.Windows.Forms.ColumnHeader(); + this.columnStatus = new System.Windows.Forms.ColumnHeader(); + this.columnStartType = new System.Windows.Forms.ColumnHeader(); + this.columnPID = new System.Windows.Forms.ColumnHeader(); this.imageList = new System.Windows.Forms.ImageList(this.components); this.SuspendLayout(); // @@ -55,7 +55,6 @@ private void InitializeComponent() this.columnStartType, this.columnPID}); this.listServices.Dock = System.Windows.Forms.DockStyle.Fill; - this.listServices.DoubleClickChecks = true; this.listServices.FullRowSelect = true; this.listServices.HideSelection = false; this.listServices.Location = new System.Drawing.Point(0, 0); @@ -110,8 +109,8 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listServices); + this.DoubleBuffered = true; this.Name = "ServiceList"; this.Size = new System.Drawing.Size(685, 472); this.ResumeLayout(false); @@ -120,7 +119,7 @@ private void InitializeComponent() #endregion - private ExtendedListView listServices; + private System.Windows.Forms.ListView listServices; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ImageList imageList; private System.Windows.Forms.ColumnHeader columnDescription; diff --git a/1.x/trunk/ProcessHacker/Components/ServiceList.cs b/1.x/trunk/ProcessHacker/Components/ServiceList.cs index 8ed3b420a..851ae92d2 100644 --- a/1.x/trunk/ProcessHacker/Components/ServiceList.cs +++ b/1.x/trunk/ProcessHacker/Components/ServiceList.cs @@ -22,7 +22,9 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Windows.Forms; +using ProcessHacker.Common; using ProcessHacker.Common.Ui; using ProcessHacker.Native.Api; using ProcessHacker.UI; @@ -32,10 +34,10 @@ namespace ProcessHacker.Components public partial class ServiceList : UserControl { private ServiceProvider _provider; - private int _runCount; - private readonly HighlightingContext _highlightingContext; - private readonly List _needsAdd = new List(); - private bool _needsSort; + private int _runCount = 0; + private HighlightingContext _highlightingContext; + private List _needsAdd = new List(); + private bool _needsSort = false; public new event KeyEventHandler KeyDown; public new event MouseEventHandler MouseDown; public new event MouseEventHandler MouseUp; @@ -47,11 +49,12 @@ public ServiceList() InitializeComponent(); _highlightingContext = new HighlightingContext(listServices); - listServices.KeyDown += this.ServiceList_KeyDown; - listServices.MouseDown += this.listServices_MouseDown; - listServices.MouseUp += this.listServices_MouseUp; - listServices.DoubleClick += this.listServices_DoubleClick; - listServices.SelectedIndexChanged += this.listServices_SelectedIndexChanged; + listServices.SetTheme("explorer"); + listServices.KeyDown += new KeyEventHandler(ServiceList_KeyDown); + listServices.MouseDown += new MouseEventHandler(listServices_MouseDown); + listServices.MouseUp += new MouseEventHandler(listServices_MouseUp); + listServices.DoubleClick += new EventHandler(listServices_DoubleClick); + listServices.SelectedIndexChanged += new System.EventHandler(listServices_SelectedIndexChanged); listServices.ListViewItemSorter = new SortedListViewComparer(listServices); } @@ -87,6 +90,20 @@ private void ServiceList_KeyDown(object sender, KeyEventArgs e) #region Properties + public new bool DoubleBuffered + { + get + { + return (bool)typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).GetValue(listServices, null); + } + set + { + typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).SetValue(listServices, value, null); + } + } + public override bool Focused { get @@ -107,7 +124,7 @@ public override ContextMenuStrip ContextMenuStrip set { listServices.ContextMenuStrip = value; } } - public ExtendedListView List + public ListView List { get { return listServices; } } @@ -119,10 +136,10 @@ public ServiceProvider Provider { if (_provider != null) { - _provider.DictionaryAdded -= this.provider_DictionaryAdded; - _provider.DictionaryModified -= this.provider_DictionaryModified; - _provider.DictionaryRemoved -= this.provider_DictionaryRemoved; - _provider.Updated -= this.provider_Updated; + _provider.DictionaryAdded -= new ServiceProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryModified -= new ServiceProvider.ProviderDictionaryModified(provider_DictionaryModified); + _provider.DictionaryRemoved -= new ServiceProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated -= new ServiceProvider.ProviderUpdateOnce(provider_Updated); } _provider = value; @@ -133,10 +150,10 @@ public ServiceProvider Provider { //_provider.InterlockedExecute(new MethodInvoker(() => //{ - _provider.DictionaryAdded += this.provider_DictionaryAdded; - _provider.DictionaryModified += this.provider_DictionaryModified; - _provider.DictionaryRemoved += this.provider_DictionaryRemoved; - _provider.Updated += this.provider_Updated; + _provider.DictionaryAdded += new ServiceProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryModified += new ServiceProvider.ProviderDictionaryModified(provider_DictionaryModified); + _provider.DictionaryRemoved += new ServiceProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated += new ServiceProvider.ProviderUpdateOnce(provider_Updated); foreach (ServiceItem item in _provider.Dictionary.Values) { @@ -196,13 +213,13 @@ private void provider_Updated() if (_needsSort) { this.BeginInvoke(new MethodInvoker(() => - { - if (_needsSort) { - listServices.Sort(); - _needsSort = false; - } - })); + if (_needsSort) + { + listServices.Sort(); + _needsSort = false; + } + })); } _runCount++; @@ -220,18 +237,21 @@ public void UpdateItems() private void provider_DictionaryAdded(ServiceItem item) { - HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, item.RunId > 0 && _runCount > 0) - { - Name = item.Status.ServiceName, - Text = item.Status.ServiceName - }; - - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Status.DisplayName)); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Status.ServiceStatusProcess.ServiceType.ToString())); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Status.ServiceStatusProcess.CurrentState.ToString())); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Config.StartType.ToString())); + HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, + item.RunId > 0 && _runCount > 0); + + litem.Name = item.Status.ServiceName; + litem.Text = item.Status.ServiceName; + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, + item.Status.DisplayName)); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, + item.Status.ServiceStatusProcess.ServiceType.ToString())); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, + item.Status.ServiceStatusProcess.CurrentState.ToString())); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, + item.Config.StartType.ToString())); litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, - item.Status.ServiceStatusProcess.ProcessID == 0 ? string.Empty : + item.Status.ServiceStatusProcess.ProcessID == 0 ? "" : item.Status.ServiceStatusProcess.ProcessID.ToString())); if ((item.Status.ServiceStatusProcess.ServiceType & ServiceType.InteractiveProcess) != 0) @@ -267,7 +287,7 @@ private void provider_DictionaryModified(ServiceItem oldItem, ServiceItem newIte litem.SubItems[2].Text = newItem.Status.ServiceStatusProcess.ServiceType.ToString(); litem.SubItems[3].Text = newItem.Status.ServiceStatusProcess.CurrentState.ToString(); litem.SubItems[4].Text = newItem.Config.StartType.ToString(); - litem.SubItems[5].Text = newItem.Status.ServiceStatusProcess.ProcessID == 0 ? string.Empty : + litem.SubItems[5].Text = newItem.Status.ServiceStatusProcess.ProcessID == 0 ? "" : newItem.Status.ServiceStatusProcess.ProcessID.ToString(); _needsSort = true; } diff --git a/1.x/trunk/ProcessHacker/Components/ServiceList.resx b/1.x/trunk/ProcessHacker/Components/ServiceList.resx index 2d0bf5c69..6cdf0e270 100644 --- a/1.x/trunk/ProcessHacker/Components/ServiceList.resx +++ b/1.x/trunk/ProcessHacker/Components/ServiceList.resx @@ -112,99 +112,99 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACa - EwAAAk1TRnQBSQFMAgEBBAEAAQwBAAEMAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + EwAAAk1TRnQBSQFMAgEBBAEAAQwBAAEEAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABIAMAAQEBAAEgBgABIP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8AegADOwFjA1gBvwNX - Ab8DOwFjWAADQAFwAVICVAGmAVEBZQF5AeoBOwF/AaQB9wE7AX8BpAH3ATsBfwGkAfcBOwF/AaQB9wE7 - AX8BpAH3ATsBfwGkAfcBOwF/AaQB9wE7AX8BpAH3ATsBfQGkAfcBTAFwAZAB8QNMAZNUAAMdASkDCgEO - AwEBAgNjAeoDvQH/A7IB/wNcAeoDAQECAwoBDgMdASkUAAMKAQ0DDgETA04BmAFkAlgB4wGAAUYBQQH1 - AZIBTQEpAfoBkgFNASkB+gF7AUgBNwH2AWYBVQFSAeoBVwJVAboDEAEWAwoBDQgAAVgBaQF0AeYBiQGP - AZEB8AGnAcMB2gH9AZ4B2wH0Af8BlgHaAfMB/wGOAdgB8wH/AYYB1wHzAf8BdgHUAfIB/wFwAdMB8gH/ - AWkB0gHxAf8BYwHQAfEB/wFgAc8B8QH/AbEB2QHnAf4BTQFsAYcB8AgAA1IBqQHDAY4BXQH/AcABiwFb - Af8BvgGIAVkB/wG7AYUBVgH/AbkBgwFUAf8BtAFzAVEB/wGyAXEBTwH/AbEBcAFNAf8BrgFuAUwB/wGt - AWsBSwH/AasBagFJAf8BqQFoAUgB/wGpAWYBRgH/A1IBqQwAA1ABmwNaAf0DZAHnAxIBGQNkAecDywH/ - A8cB/wNiAecDEgEZA1wB5wNEAf0DTwGbDAADRAF5ASYBXwGlAfsBcwJfAfsBvwFVASoB/wH+AbkBVgH/ - Af4BuQFXAf8B/gG5AVcB/wH+AbkBVwH/Af4BuQFWAf8B/gG5AVYB/wGxAT4BGQH/AWgBWQFeAfUBPgFz - AZwB+ANIAYMEAAE/AYQBpwH3Ae8B+gH+Af8BoQHpAfkB/wGRAeUB+AH/AYEB4QH3Af8BaQHeAfYB/wFa - AdoB9QH/AUsB1wH0Af8BPgHTAfMB/wEwAdAB8gH/ASUBzQHxAf8BHQHLAfAB/wHKAfIB+wH/AT8BhAGn - AfcIAAHIAZIBYTX/AakBZwFGAf8IAANEAXsDvAH/A94B/wOmAf8DZwH0A38B/gPEAf8DwgH/A20B/gNl - AfQDpgH/A9IB/wOAAf8DRAF7CAABKQF9AbwB/gGCAboB7gH/AZ8BWwFNAf8B9QG7AYQC/wGsAVAB/wH+ - AagBTwH/Af4BogFMAf8B/gGcAUgC/wGjAUoC/wGfAUUB/wH4Aa4BbQH/AaQBUwE/Af8BgwG8Ae8B/wEq - AXcBtQH+BAABPgGEAaoB+AHyAfoB/QH/AbMB7QH6Af8BpAHpAfkB/wGVAeYB+AH/AYUB4gH3Af8BgQHh - AfcB/wFxAeAB9wH/AWYB3QH2Af8BWQHaAfUB/wFLAdYB8wH/AT4B0wHyAf8B6AH5Af0B/wEsAZQB2gH/ - CAABygGUAWML/wH+A/8B/QH/Av4B/QH/Av4B/AH/Av4B/AH/Av4B/AH/Av4B/AH/Av4B+gH/Av4B+gH/ - AvwB+QX/AaoBaAFIAf8IAANFAX0DkQH+A9UB/wPFAf8DywH/A9EB/wPJAf8DxwH/A8wB/wPFAf8DvQH/ - A8sB/wNuAf4DRQF9CAABKwFxAbMB/AFtAbMB6gH/AbMBngGUAv8BtwFVAv8BtgFYAf8B/gGyAVYB/wH+ - AawBUgH/Af4BpQFOAf8B/QGeAUgB/wH+AZcBQwL/AY0BOAH/AbwBjwGCAf8BcwG4Ae0B/wEqAWkBoAH6 - BAABQQGLAa8B+QH2AfwB/gH/AcgB8gH8Af8BuQHvAfsB/wGsAewB+gH/AYwB5AH4Af8BigHjAfgB/wGC - AeEB9wH/AXAB3wH3Af8BZAHdAfYB/wFYAdoB9QH/AU4B1wH0Af8B5wH4Af0B/wEsAZQB2gH/CAABzAGX - AWQH/wH8A/8B/QH/Av4B/AH/Av4B/AH/Av4B+wH/Av0B+gH/Av0B+gH/Av0B+gH/Av0B+gH/AvwB9wH/ - AvsB9gX/AawBagFJAf8MAANIAYUDxQH/A8EB/wPFAf8DxwH/A6oB/wOnAf8DwQH/A74B/wO1Af8DqgH/ - A0gBhQwAAzIBUAGKAUkBOQH/AfwByAGrAv8B0QGYAf8B/gHHAWIB/wH+Ab8BXQH/Af4BuQFZAf8B/gGx - AVMB/wH+AagBTgH/Af0BoAFJAv8BtwFvAf8B/gGpAYAB/wGIAUUBNwH/AjoBOQFgBAABQAGSAa8B+gH+ + Ab8DOwFjWAADQAFwAVICVAGmAVABZgF9AeoBOgGAAagB9wE6AYABqAH3AToBgAGoAfcBOgGAAagB9wE6 + AYABqAH3AToBgAGoAfcBOgGAAagB9wE6AYABqAH3AToBfwGoAfcBSQFyAZQB8QNMAZNUAAMdASkDCgEO + AwEBAgNkAeoDvQH/A7IB/wNcAeoDAQECAwoBDgMdASkUAAMKAQ0DDgETA04BmAFlAlgB4wGCAUYBPgH1 + AZUBTQEpAfoBlQFNASkB+gF9AUgBNgH2AWkBVQFRAeoBVwJVAboDEAEWAwoBDQgAAVgBagF5AeYBjgGW + AZgB8AGnAcYB3QH9AZ4B2wH0Af8BlgHaAfMB/wGOAdgB8wH/AYYB1wHzAf8BdwHUAfIB/wFxAdMB8gH/ + AWoB0gHxAf8BZAHQAfEB/wFhAc8B8QH/AbMB2wHpAf4BSwFuAYwB8AgAA1IBqQHDAY4BXgH/AcABiwFc + Af8BvgGIAVoB/wG7AYUBVwH/AbkBgwFVAf8BtAF0AVIB/wGyAXIBUAH/AbEBcQFOAf8BrgFvAU0B/wGt + AWwBTAH/AasBawFKAf8BqQFpAUkB/wGpAWcBRwH/A1IBqQwAA1ABmwNcAf0DZAHnAxIBGQNkAecDywH/ + A8cB/wNiAecDEgEZA1wB5wNFAf0DTwGbDAADRAF5ASYBXwGpAfsBdgJfAfsBvwFWASsB/wH+AbkBVwH/ + Af4BuQFYAf8B/gG5AVgB/wH+AbkBWAH/Af4BuQFXAf8B/gG5AVcB/wGxAT8BGgH/AWkBWQFgAfUBPgF0 + AZ8B+ANIAYMEAAE+AYUBqwH3Ae8B+gH+Af8BoQHpAfkB/wGRAeUB+AH/AYEB4QH3Af8BagHeAfYB/wFb + AdoB9QH/AUwB1wH0Af8BPwHTAfMB/wExAdAB8gH/ASYBzQHxAf8BHgHLAfAB/wHKAfIB+wH/AT4BhQGr + AfcIAAHIAZIBYjX/AakBaAFHAf8IAANEAXsDvAH/A94B/wOmAf8DagH0A38B/gPEAf8DwgH/A20B/gNl + AfQDpgH/A9IB/wOAAf8DRAF7CAABKQF9Ab4B/gGCAboB7gH/AZ8BXAFOAf8B9QG7AYQC/wGsAVEB/wH+ + AagBUAH/Af4BogFNAf8B/gGcAUkC/wGjAUsC/wGfAUYB/wH4Aa4BbgH/AaQBVAFAAf8BgwG8Ae8B/wEq + AXcBtwH+BAABPgGHAa8B+AHyAfoB/QH/AbMB7QH6Af8BpAHpAfkB/wGVAeYB+AH/AYUB4gH3Af8BgQHh + AfcB/wFyAeAB9wH/AWcB3QH2Af8BWgHaAfUB/wFMAdYB8wH/AT8B0wHyAf8B6AH5Af0B/wEtAZQB2gH/ + CAABygGUAWQL/wH+A/8B/QH/Av4B/QH/Av4B/AH/Av4B/AH/Av4B/AH/Av4B/AH/Av4B+gH/Av4B+gH/ + AvwB+QX/AaoBaQFJAf8IAANFAX0DkwH+A9UB/wPFAf8DywH/A9EB/wPJAf8DxwH/A8wB/wPFAf8DvQH/ + A8sB/wNuAf4DRQF9CAABKwFyAbUB/AFuAbMB6gH/AbMBngGUAv8BtwFWAv8BtgFZAf8B/gGyAVcB/wH+ + AawBUwH/Af4BpQFPAf8B/QGeAUkB/wH+AZcBRAL/AY0BOQH/AbwBjwGCAf8BdAG4Ae0B/wEqAWoBogH6 + BAABQQGMAbIB+QH2AfwB/gH/AcgB8gH8Af8BuQHvAfsB/wGsAewB+gH/AYwB5AH4Af8BigHjAfgB/wGC + AeEB9wH/AXEB3wH3Af8BZQHdAfYB/wFZAdoB9QH/AU8B1wH0Af8B5wH4Af0B/wEtAZQB2gH/CAABzAGX + AWUH/wH8A/8B/QH/Av4B/AH/Av4B/AH/Av4B+wH/Av0B+gH/Av0B+gH/Av0B+gH/Av0B+gH/AvwB9wH/ + AvsB9gX/AawBawFKAf8MAANIAYUDxQH/A8EB/wPFAf8DxwH/A6oB/wOnAf8DwQH/A74B/wO1Af8DqgH/ + A0gBhQwAAzIBUAGKAUoBOgH/AfwByAGrAv8B0QGYAf8B/gHHAWMB/wH+Ab8BXgH/Af4BuQFaAf8B/gGx + AVQB/wH+AagBTwH/Af0BoAFKAv8BtwFwAf8B/gGpAYAB/wGIAUYBOAH/AjoBOQFgBAABPwGVAbMB+gH+ A/8B+AH9Av8B9gH9Av8B9QH8Av8B3gHbAdEB/wGtAcoBxQH/AaYBxQHAAf8BpAHDAb0B/wGeAb0BtgH/ - AZcBugGzAf8BkgG4AbIB/wHhAcsBtwH/ASwBlAHaAf8BwwGEAUkB/wJVAVMBsAHRAZwBaAX/Av4B/AH/ + AZcBugGzAf8BkgG4AbIB/wHhAcsBtwH/AS0BlAHaAf8BwwGEAUoB/wJVAVMBsAHRAZwBaQX/Av4B/AH/ Av4B/AH/Av4B/AH/Av0B+wH/Av0B+wH/Av0B+gH/Av0B+AH/AvsB+QH/AfsB+gH3Af8B+wH6AfYB/wH7 - AfgB9AX/AbABbwFNAf8EAANcAc0DYAHjA2wB7gPPAf8DxgH/A8wB/wNbAcYDLAFEAywBRANbAcYDwQH/ - A7wB/wO5Af8DYQHuA1kB4wNaAc0HAAEBAjoBOQFgAcQBQQEUAf8B9gHkAdYC/wHkAaQC/wHUAWcC/wHJ - AV4C/wHAAVgC/wG2AVQC/wHBAYAB/wH2AdcBxgH/AcUBPgEUAf8DPQFpAwMBBAQAAT4BmAGvAfoB6AH2 - AfsB/wF1AcUB6gH/AVIBrgHjAf8BSAGoAeEB/wFYAa0B3wH/Ae0B9gH3Af8B7QH1AfYB/wHnAe8B8wH/ - AeUB7AHuAf8B5QHrAe0B/wHlAesB7QH/AfgB8wHvAf8BLAGUAdoB/wHwAeIB2AH/AbgBigFQAf0B1AGe - AWoF/wL+AfwB/wL9AfsB/wL9AfwB/wL9AfsB/wL9AfkB/wL8AfgB/wH7AfkB9wH/AfsB+QH1Af8B+wH4 - AfQB/wH7AfcB8gH/AfsB9QHyBf8BsgFxAU8B/wQAA7QB/QPiAf8D0gH/A8YB/wPNAf8DsQH/AywBRAgA - AywBRAOoAf8DwgH/A7cB/wPAAf8D0gH/A1AB/QgAAwUBBwM9AWkBvAE9AREB/wH0AeIB1AH/AUMBcAGp - Af8BQgFwAagB/wFCAXABqAH/AUMBcAGpAf8B8wHWAcMB/wG+ATsBEQH/AkABPwFvAwcBCggAAUsBfwGQ - AfIB8QH6Af0B/wGUAd4B9QH/AZMB3AH0Af8BgQHVAfIB/wHAAakBlwH/AZEBwQHkAf8BLAGUAdoB/wEs - AZQB2gH/ASwBlAHaAf8BLAGUAdoB/wEsAZQB2gH/ASwBlAHaAf8BLAGUAdoB/wHwAeIB2AH/AcQBhgFL - Af8B1QGgAWsF/wL9AfwB/wL9AfsB/wL9AfoB/wL8AfkB/wH8AfsB9wH/AfsB+QH1Af8B+wH4AfQB/wH7 - AfcB8wH/AfsB9QHyAf8B+gHzAe8B/wH4AfIB7AX/AbUBcwFRAf8EAAO2Af0D6QH/A9YB/wPJAf8DzgH/ - A6UB/wMsAUQIAAMsAUQDrAH/A8QB/wO6Af8DxgH/A90B/wNWAf0MAAMEAQUDUQGiASkBYgGnAf8BnAHM - AfgB/wGvAdQB9wH/Aa8B1AH3Af8BpQHPAfYB/wEpAWkBrgH/AVUCUwGtAwcBCQwAAU4BeQGIAfAB9wH8 + AfgB9AX/AbABcAFOAf8EAANcAc0DYgHjA24B7gPPAf8DxgH/A8wB/wNbAcYDLAFEAywBRANbAcYDwQH/ + A7wB/wO5Af8DYQHuA1kB4wNaAc0HAAEBAjoBOQFgAcQBQgEVAf8B9gHkAdYC/wHkAaQC/wHUAWgC/wHJ + AV8C/wHAAVkC/wG2AVUC/wHBAYAB/wH2AdcBxgH/AcUBPwEVAf8DPQFpAwMBBAQAAT0BmgGzAfoB6AH2 + AfsB/wF2AcUB6gH/AVMBrgHjAf8BSQGoAeEB/wFZAa0B3wH/Ae0B9gH3Af8B7QH1AfYB/wHnAe8B8wH/ + AeUB7AHuAf8B5QHrAe0B/wHlAesB7QH/AfgB8wHvAf8BLQGUAdoB/wHwAeIB2AH/AbkBigFRAf0B1AGe + AWsF/wL+AfwB/wL9AfsB/wL9AfwB/wL9AfsB/wL9AfkB/wL8AfgB/wH7AfkB9wH/AfsB+QH1Af8B+wH4 + AfQB/wH7AfcB8gH/AfsB9QHyBf8BsgFyAVAB/wQAA7UB/QPiAf8D0gH/A8YB/wPNAf8DsQH/AywBRAgA + AywBRAOoAf8DwgH/A7cB/wPAAf8D0gH/A1EB/QgAAwUBBwM9AWkBvAE+ARIB/wH0AeIB1AH/AUQBcQGp + Af8BQwFxAagB/wFDAXEBqAH/AUQBcQGpAf8B8wHWAcMB/wG+ATwBEgH/AkABPwFvAwcBCggAAUoBgwGW + AfIB8QH6Af0B/wGUAd4B9QH/AZMB3AH0Af8BgQHVAfIB/wHAAakBlwH/AZEBwQHkAf8BLQGUAdoB/wEt + AZQB2gH/AS0BlAHaAf8BLQGUAdoB/wEtAZQB2gH/AS0BlAHaAf8BLQGUAdoB/wHwAeIB2AH/AcQBhgFM + Af8B1QGgAWwF/wL9AfwB/wL9AfsB/wL9AfoB/wL8AfkB/wH8AfsB9wH/AfsB+QH1Af8B+wH4AfQB/wH7 + AfcB8wH/AfsB9QHyAf8B+gHzAe8B/wH4AfIB7AX/AbUBdAFSAf8EAAO3Af0D6QH/A9YB/wPJAf8DzgH/ + A6UB/wMsAUQIAAMsAUQDrAH/A8QB/wO6Af8DxgH/A90B/wNYAf0MAAMEAQUDUQGiASoBYwGnAf8BnAHM + AfgB/wGvAdQB9wH/Aa8B1AH3Af8BpQHPAfYB/wEqAWoBrgH/AVUCUwGtAwcBCQwAAUwBfAGNAfAB9wH8 Af4B/wGOAeQB+AH/AZEB3gH1Af8BnwHgAfUB/wHjAbEBjAH/AfoB9gHxAf8B6gHJAa4F/wHoAccBrBH/ - AfEB5QHbAf8BxgGGAUwB/wHYAaIBbgX/Av0B+gH/AvwB+gH/AfwB+wH5Af8B+wH6AfYB/wH7AfgB9QH/ - AfsB9wH0Af8B+wH2AfEB/wH4AfQB7gH/AfcB8gHrAf8B9wHwAeoB/wH2AewB6AX/AbcBgQFTAf8EAANc - Ac0DZgHjA3YB7gPYAf8DzQH/A7wB/wNbAcYDLAFEAywBRANbAcYDwwH/A8IB/wPNAf8DZwHuA18B4wNc + AfEB5QHbAf8BxgGGAU0B/wHYAaIBbwX/Av0B+gH/AvwB+gH/AfwB+wH5Af8B+wH6AfYB/wH7AfgB9QH/ + AfsB9wH0Af8B+wH2AfEB/wH4AfQB7gH/AfcB8gHrAf8B9wHwAeoB/wH2AewB6AX/AbcBgQFUAf8EAANc + Ac0DaAHjA3kB7gPYAf8DzQH/A7wB/wNbAcYDLAFEAywBRANbAcYDwwH/A8IB/wPNAf8DaQHuA2AB4wNc Ac0QAAFZAlsBxAGmAcoB7gH/AasBzAHqAf8BpwHQAfYB/wGoAdAB9gH/AasBzAHqAf8BpwHNAe4B/wFZ - AlwBzBAAAT4BlQGqAfgB/QL+Af8B/gP/Av4C/wH9Af4C/wHlAbQBjwH/AfoB9gHyAf8B6QHGAaoB/wHp - AcYBrAH/AegBxwGsAf8B6AHHAawB/wHpAckBsAH/AegByAGwAf8B6AHMAbUB/wHyAecB3gH/AcgBigFQ - Af8B2QGjAW4F/wH8AfsB+QH/AfwB+wH4Af8B+wH5AfcB/wH7AfcB9AH/AfoB9wHyAf8B+QH1AfAB/wH3 - AfMB7QH/AfYB7wHqAf8B9QHrAecB/wHzAeoB5AH/AfIB5wHeBf8BugGFAVUB/wwAA0gBhQPUAf8DzAH/ - A8kB/wO6Af8DnAH/A6EB/wPCAf8DxgH/A8EB/wO3Af8DSAGFGAABUQFdAWsB7QHZAegB9wH/AZcBxQHx - Af8BjgG7AeUB/wF0AakB0QH/AYkBtQHfAf8BzQHfAe4B/wFMAWQBdwHxAwQBBgwAAVsBXgFgAdABUAGi - AbYB+gFRAaMBtwH6AVEBowG3AfoBUQGjAbcB+gHnAbcBlAH/AfsB9wH0Af8B6QHDAaYF/wHoAccBrBH/ - AfcB8QHrAf8BywGPAVYB/wHbAaQBbzX/Ab0BhwFYAf8IAANFAX0DrwH+A9wB/wPUAf8D2QH/A9sB/wPW - Af8D1AH/A9kB/wPSAf8DywH/A8gB/wN5Af4DRQF9FAABAQEzAYcB/wFxAZcBuAH/AYoBtwHkAf8BZgGc - AcgB/wEKATUBYwH/AQ4BOQFnAf8BFwE6AWAB/wEjAUYBUgH6AwUBByAAAekBugGYAf8B+wH3AfQB/wHp + AlwBzBAAAT4BlwGvAfgB/QL+Af8B/gP/Av4C/wH9Af4C/wHlAbQBjwH/AfoB9gHyAf8B6QHGAaoB/wHp + AcYBrAH/AegBxwGsAf8B6AHHAawB/wHpAckBsAH/AegByAGwAf8B6AHMAbUB/wHyAecB3gH/AcgBigFR + Af8B2QGjAW8F/wH8AfsB+QH/AfwB+wH4Af8B+wH5AfcB/wH7AfcB9AH/AfoB9wHyAf8B+QH1AfAB/wH3 + AfMB7QH/AfYB7wHqAf8B9QHrAecB/wHzAeoB5AH/AfIB5wHeBf8BugGFAVYB/wwAA0gBhQPUAf8DzAH/ + A8kB/wO6Af8DnAH/A6EB/wPCAf8DxgH/A8EB/wO3Af8DSAGFGAABUAFdAW4B7QHZAegB9wH/AZcBxQHx + Af8BjgG7AeUB/wF1AakB0QH/AYkBtQHfAf8BzQHfAe4B/wFJAWQBewHxAwQBBgwAAVsBYAFiAdABUQGk + AbsB+gFSAaUBvAH6AVIBpQG8AfoBUgGlAbwB+gHnAbcBlAH/AfsB9wH0Af8B6QHDAaYF/wHoAccBrBH/ + AfcB8QHrAf8BywGPAVcB/wHbAaQBcDX/Ab0BhwFZAf8IAANFAX0DsQH+A9wB/wPUAf8D2QH/A9sB/wPW + Af8D1AH/A9kB/wPSAf8DywH/A8gB/wN5Af4DRQF9FAABAgE0AYcB/wFyAZcBuAH/AYoBtwHkAf8BZwGc + AcgB/wELATYBZAH/AQ8BOgFoAf8BGAE7AWEB/wEiAUUBUwH6AwUBByAAAekBugGYAf8B+wH3AfQB/wHp AcMBpgH/AekBwwGmAf8B6QHDAaYB/wHpAcMBpgH/AekBwwGmAf8B6QHDAaYB/wHpAcMBpgH/AfsB9wH0 - Af8BzgGTAVsB/wHcAacBcAH/AdwBpwFwAf8B3AGnAXAB/wHcAacBcAH/AdwBpwFwAf8B3AGnAXAB/wHc - AacBcAH/AdwBpwFwAf8B3AGnAXAB/wHcAacBcAH/AdwBpwFwAf8B3AGnAXAB/wHcAacBcAH/AdwBpwFw - Af8BwAGLAVsB/wgAA0QBewPcAf8D7QH/A9sB/wOGAfQDqQH+A9YB/wPUAf8DmwH+A30B9APLAf8D5wH/ - A7cB/wNEAXsUAAEEAUABlwH/AQcBTQGfAf8BBAE/AYoB/wEEAUABhwH/AQYBQAGHAf8BCgFBAYUB/wEH - ATYBagH/AUcBUwFgAfEkAAHrAb0BmwH/AfsB9wH0Hf8B+wH3AfQB/wHRAZcBYQH/Ab4BqAGFAf0B6AG5 + Af8BzgGTAVwB/wHcAacBcQH/AdwBpwFxAf8B3AGnAXEB/wHcAacBcQH/AdwBpwFxAf8B3AGnAXEB/wHc + AacBcQH/AdwBpwFxAf8B3AGnAXEB/wHcAacBcQH/AdwBpwFxAf8B3AGnAXEB/wHcAacBcQH/AdwBpwFx + Af8BwAGLAVwB/wgAA0QBewPcAf8D7QH/A9sB/wOKAfQDqwH+A9YB/wPUAf8DnQH+A38B9APLAf8D5wH/ + A7cB/wNEAXsUAAEFAUEBlwH/AQgBTgGfAf8BBQFAAYoB/wEFAUEBhwH/AQcBQQGHAf8BCwFCAYUB/wEI + ATcBawH/AUUBUQFgAfEkAAHrAb0BmwH/AfsB9wH0Hf8B+wH3AfQB/wHRAZcBYgH/AcABqAGFAf0B6AG5 AZIB/wHoAbkBkgH/AegBuQGSAf8B6AG5AZIB/wHoAbkBkgH/AegBuQGSAf8B6AG5AZIB/wHoAbkBkgH/ - AegBuQGSAf8B6AG5AZIB/wHoAbkBkgH/AegBuQGSAf8B6AG5AZIB/wG1AZABWgH9DAADUAGbA7kB/QNt - AecDEgEZA20B5wPeAf8D3QH/A2sB5wMSARkDaQHnA6cB/QNQAZsYAANDAXcBEQFOAYEB/gEHAU0BmwH/ - AQcBTQGZAf8BBgFIAZMB/wEEAT8BhwH/AQ4BPgFxAf4CRgFHAYEkAAHsAb8BngH/AfsB9wH0Af8BnAHV - AaUB/wGYAdMBoQH/AYsBywGTAf8BggHGAYkB/wF1AcMBhAH/AXEBwQGAAf8BbQG+AXMB/wH7AfcB9AH/ - AdQBmwFmAf8DPgFrAY4BfQFvAfQB3AGnAXAB/wHcAaYBbwH/AdoBpAFvAf8B2AGiAW4B/wHVAaABawH/ - AdQBngFqAf8B0gGdAWgB/wHPAZoBZwH/Ac4BmQFlAf8BywGWAWQB/wHJAZQBYQH/AYcBdwFlAfQDPgFr - EAADHQEpAwoBDgMBAQIDbwHqA+UB/wPkAf8DaQHqAwEBAgMKAQ4DHQEpIAADRQF9AT4BUgFvAfQBBQFA - AZAB/wEEAT0BigH/ATcBQwFpAfUDSAGEKAABhAF5AXMB6wH7AfcB9AH/AfsB9wH0Af8B+wH3AfQB/wH7 - AfcB9AH/AfsB9wH0Af8B+wH3AfQB/wH7AfcB9AH/AfsB9wH0Af8B+wH3AfQB/wGnAYsBaQH4WAADOwFj - A1kBvwNZAb8DOwFjbAADRgF+AXABaQFmAeMB7QHAAZ8B/wHrAb4BnQH/AecBtwGTAf8B5AGyAYwB/wHi - Aa8BiAH/AeABrAGEAf8B3QGpAYAB/wHcAaUBdAH/A10BygFCAU0BPgcAAT4DAAEoAwABQAMAASADAAEB + AegBuQGSAf8B6AG5AZIB/wHoAbkBkgH/AegBuQGSAf8B6AG5AZIB/wG2AZABXAH9DAADUAGbA7oB/QNv + AecDEgEZA28B5wPeAf8D3QH/A20B5wMSARkDawHnA6cB/QNQAZsYAANDAXcBEQFOAYMB/gEIAU4BmwH/ + AQgBTgGZAf8BBwFJAZMB/wEFAUABhwH/AQ4BPgFxAf4CRgFHAYEkAAHsAb8BngH/AfsB9wH0Af8BnAHV + AaUB/wGYAdMBoQH/AYsBywGTAf8BggHGAYkB/wF2AcMBhAH/AXIBwQGAAf8BbgG+AXQB/wH7AfcB9AH/ + AdQBmwFnAf8DPgFrAZIBgQFyAfQB3AGnAXEB/wHcAaYBcAH/AdoBpAFwAf8B2AGiAW8B/wHVAaABbAH/ + AdQBngFrAf8B0gGdAWkB/wHPAZoBaAH/Ac4BmQFmAf8BywGWAWUB/wHJAZQBYgH/AYsBeQFlAfQDPgFr + EAADHQEpAwoBDgMBAQIDcgHqA+UB/wPkAf8DbAHqAwEBAgMKAQ4DHQEpIAADRQF9AT0BUgFyAfQBBgFB + AZAB/wEFAT4BigH/ATQBQwFqAfUDSAGEKAABigF9AXYB6wH7AfcB9AH/AfsB9wH0Af8B+wH3AfQB/wH7 + AfcB9AH/AfsB9wH0Af8B+wH3AfQB/wH7AfcB9AH/AfsB9wH0Af8B+wH3AfQB/wGsAY4BawH4WAADOwFj + A1kBvwNZAb8DOwFjbAADRgF+AXYBbQFoAeMB7QHAAZ8B/wHrAb4BnQH/AecBtwGTAf8B5AGyAYwB/wHi + Aa8BiAH/AeABrAGEAf8B3QGpAYAB/wHcAaUBdQH/A10BygFCAU0BPgcAAT4DAAEoAwABQAMAASADAAEB AQABAQYAAQEWAAP/gQAC/wH8AT8C/wEAAQMC/wHgAQcBwAEDAQABAwEAAQEBwAEDAYABAQEAAQMBAAEB AYABAQGAAQEBAAEDAQABAQGAAQEBgAEBAQABAwEAAQEBwAEDAYABAQMAAQECAAGAAQEDAAIBAYABwAED AwACAQGAAeABBwMAAQECAAHwAQ8DAAEBAcABAwHwAQcDAAEBAYABAQHwAQcB+AIAAQEBgAEBAfABDwH4 diff --git a/1.x/trunk/ProcessHacker/Components/ServiceProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/ServiceProperties.Designer.cs index acfc699af..8d374d3d0 100644 --- a/1.x/trunk/ProcessHacker/Components/ServiceProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/ServiceProperties.Designer.cs @@ -33,10 +33,10 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.listServices = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listServices = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnDescription = new System.Windows.Forms.ColumnHeader(); + this.columnStatus = new System.Windows.Forms.ColumnHeader(); this.panelService = new System.Windows.Forms.Panel(); this.buttonPermissions = new System.Windows.Forms.Button(); this.textServiceDll = new System.Windows.Forms.TextBox(); @@ -70,14 +70,13 @@ private void InitializeComponent() // // listServices // - this.listServices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listServices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listServices.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnName, this.columnDescription, this.columnStatus}); - this.listServices.DoubleClickChecks = true; this.listServices.FullRowSelect = true; this.listServices.HideSelection = false; this.listServices.Location = new System.Drawing.Point(3, 3); @@ -108,8 +107,8 @@ private void InitializeComponent() // // panelService // - this.panelService.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.panelService.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.panelService.Controls.Add(this.buttonPermissions); this.panelService.Controls.Add(this.textServiceDll); this.panelService.Controls.Add(this.label8); @@ -156,12 +155,12 @@ private void InitializeComponent() // // textServiceDll // - this.textServiceDll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textServiceDll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textServiceDll.Location = new System.Drawing.Point(107, 222); this.textServiceDll.Name = "textServiceDll"; this.textServiceDll.ReadOnly = true; - this.textServiceDll.Size = new System.Drawing.Size(274, 22); + this.textServiceDll.Size = new System.Drawing.Size(274, 20); this.textServiceDll.TabIndex = 23; // // label8 @@ -169,7 +168,7 @@ private void InitializeComponent() this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(6, 225); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(66, 13); + this.label8.Size = new System.Drawing.Size(69, 13); this.label8.TabIndex = 22; this.label8.Text = "Service DLL:"; // @@ -188,11 +187,11 @@ private void InitializeComponent() // // textPassword // - this.textPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textPassword.Location = new System.Drawing.Point(107, 196); this.textPassword.Name = "textPassword"; - this.textPassword.Size = new System.Drawing.Size(251, 22); + this.textPassword.Size = new System.Drawing.Size(251, 20); this.textPassword.TabIndex = 20; this.textPassword.Text = "password"; this.textPassword.UseSystemPasswordChar = true; @@ -203,7 +202,7 @@ private void InitializeComponent() this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(6, 199); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(59, 13); + this.label7.Size = new System.Drawing.Size(56, 13); this.label7.TabIndex = 19; this.label7.Text = "Password:"; // @@ -233,17 +232,16 @@ private void InitializeComponent() // // textDescription // - this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textDescription.BackColor = System.Drawing.Color.WhiteSmoke; - this.textDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textDescription.Location = new System.Drawing.Point(6, 21); + this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textDescription.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textDescription.Location = new System.Drawing.Point(6, 47); this.textDescription.Multiline = true; this.textDescription.Name = "textDescription"; this.textDescription.ReadOnly = true; this.textDescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textDescription.Size = new System.Drawing.Size(375, 64); + this.textDescription.Size = new System.Drawing.Size(375, 38); this.textDescription.TabIndex = 17; // // buttonStart @@ -272,11 +270,11 @@ private void InitializeComponent() // // textLoadOrderGroup // - this.textLoadOrderGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textLoadOrderGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textLoadOrderGroup.Location = new System.Drawing.Point(240, 118); this.textLoadOrderGroup.Name = "textLoadOrderGroup"; - this.textLoadOrderGroup.Size = new System.Drawing.Size(141, 22); + this.textLoadOrderGroup.Size = new System.Drawing.Size(141, 20); this.textLoadOrderGroup.TabIndex = 15; // // comboErrorControl @@ -311,7 +309,7 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(195, 94); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(60, 13); + this.label6.Size = new System.Drawing.Size(59, 13); this.label6.TabIndex = 11; this.label6.Text = "Start Type:"; // @@ -320,7 +318,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(6, 121); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(77, 13); + this.label5.Size = new System.Drawing.Size(68, 13); this.label5.TabIndex = 10; this.label5.Text = "Error Control:"; // @@ -329,7 +327,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(6, 94); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(33, 13); + this.label4.Size = new System.Drawing.Size(34, 13); this.label4.TabIndex = 9; this.label4.Text = "Type:"; // @@ -338,7 +336,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(195, 121); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(43, 13); + this.label3.Size = new System.Drawing.Size(39, 13); this.label3.TabIndex = 8; this.label3.Text = "Group:"; // @@ -359,17 +357,17 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 147); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(68, 13); + this.label2.Size = new System.Drawing.Size(64, 13); this.label2.TabIndex = 5; this.label2.Text = "Binary Path:"; // // textUserAccount // - this.textUserAccount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textUserAccount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textUserAccount.Location = new System.Drawing.Point(107, 170); this.textUserAccount.Name = "textUserAccount"; - this.textUserAccount.Size = new System.Drawing.Size(274, 22); + this.textUserAccount.Size = new System.Drawing.Size(274, 20); this.textUserAccount.TabIndex = 4; // // label1 @@ -377,34 +375,33 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 173); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(78, 13); + this.label1.Size = new System.Drawing.Size(75, 13); this.label1.TabIndex = 3; this.label1.Text = "User Account:"; // // textServiceBinaryPath // - this.textServiceBinaryPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textServiceBinaryPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textServiceBinaryPath.Location = new System.Drawing.Point(107, 144); this.textServiceBinaryPath.Name = "textServiceBinaryPath"; - this.textServiceBinaryPath.Size = new System.Drawing.Size(274, 22); + this.textServiceBinaryPath.Size = new System.Drawing.Size(274, 20); this.textServiceBinaryPath.TabIndex = 2; // // labelServiceDisplayName // - this.labelServiceDisplayName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelServiceDisplayName.Location = new System.Drawing.Point(198, 5); + this.labelServiceDisplayName.AutoSize = true; + this.labelServiceDisplayName.Location = new System.Drawing.Point(6, 26); this.labelServiceDisplayName.Name = "labelServiceDisplayName"; - this.labelServiceDisplayName.Size = new System.Drawing.Size(183, 13); + this.labelServiceDisplayName.Size = new System.Drawing.Size(111, 13); this.labelServiceDisplayName.TabIndex = 1; this.labelServiceDisplayName.Text = "Service Display Name"; - this.labelServiceDisplayName.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // labelServiceName // this.labelServiceName.AutoSize = true; this.labelServiceName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelServiceName.Location = new System.Drawing.Point(6, 4); + this.labelServiceName.Location = new System.Drawing.Point(6, 5); this.labelServiceName.Name = "labelServiceName"; this.labelServiceName.Size = new System.Drawing.Size(86, 13); this.labelServiceName.TabIndex = 0; @@ -414,7 +411,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listServices); this.Controls.Add(this.panelService); this.Name = "ServiceProperties"; @@ -427,7 +423,7 @@ private void InitializeComponent() #endregion - private ExtendedListView listServices; + private System.Windows.Forms.ListView listServices; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnDescription; private System.Windows.Forms.ColumnHeader columnStatus; diff --git a/1.x/trunk/ProcessHacker/Components/ServiceProperties.cs b/1.x/trunk/ProcessHacker/Components/ServiceProperties.cs index bf15a7173..f24df402f 100644 --- a/1.x/trunk/ProcessHacker/Components/ServiceProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/ServiceProperties.cs @@ -39,7 +39,7 @@ namespace ProcessHacker.Components public partial class ServiceProperties : UserControl { private QueryServiceConfig _oldConfig; - private readonly ServiceProvider _provider; + private ServiceProvider _provider; public event EventHandler NeedsClose; @@ -52,6 +52,7 @@ public ServiceProperties(string[] services) InitializeComponent(); listServices.ListViewItemSorter = new SortedListViewComparer(listServices); + listServices.SetTheme("explorer"); ColumnSettings.LoadSettings(Settings.Instance.ServiceMiniListColumns, listServices); PID = -1; @@ -73,12 +74,12 @@ public ServiceProperties(string[] services) _provider.Dictionary[s].Status.ServiceStatusProcess.CurrentState.ToString() })).Name = s; } - _provider.DictionaryModified += this._provider_DictionaryModified; - _provider.DictionaryRemoved += this._provider_DictionaryRemoved; + _provider.DictionaryModified += new ServiceProvider.ProviderDictionaryModified(_provider_DictionaryModified); + _provider.DictionaryRemoved += new ServiceProvider.ProviderDictionaryRemoved(_provider_DictionaryRemoved); - this.comboErrorControl.Fill(typeof(ServiceErrorControl)); - this.comboStartType.Fill(typeof(ServiceStartType)); - this.comboType.Fill(typeof(ProcessHacker.Native.Api.ServiceType)); + Utils.Fill(comboErrorControl, typeof(ServiceErrorControl)); + Utils.Fill(comboStartType, typeof(ServiceStartType)); + Utils.Fill(comboType, typeof(ProcessHacker.Native.Api.ServiceType)); comboType.Items.Add("Win32OwnProcess, InteractiveProcess"); comboType.Items.Add("Win32ShareProcess, InteractiveProcess"); @@ -94,7 +95,7 @@ public ServiceProperties(string[] services) public int PID { get; set; } - public ExtendedListView List + public ListView List { get { return listServices; } } @@ -126,11 +127,11 @@ private void Close() private void _provider_DictionaryRemoved(ServiceItem item) { this.BeginInvoke(new MethodInvoker(() => - { - // remove the item from the list if it's there - if (listServices.Items.ContainsKey(item.Status.ServiceName)) - listServices.Items[item.Status.ServiceName].Remove(); - })); + { + // remove the item from the list if it's there + if (listServices.Items.ContainsKey(item.Status.ServiceName)) + listServices.Items[item.Status.ServiceName].Remove(); + })); } private void _provider_DictionaryModified(ServiceItem oldItem, ServiceItem newItem) @@ -139,46 +140,40 @@ private void _provider_DictionaryModified(ServiceItem oldItem, ServiceItem newIt return; this.BeginInvoke(new MethodInvoker(() => - { - // update the state of the service - if (listServices.Items.ContainsKey(newItem.Status.ServiceName)) - listServices.Items[newItem.Status.ServiceName].SubItems[2].Text = - newItem.Status.ServiceStatusProcess.CurrentState.ToString(); - - // update the start and stop buttons if we have a service selected - if (listServices.SelectedItems.Count == 1) { - if (listServices.SelectedItems[0].Name == newItem.Status.ServiceName) - { - buttonStart.Enabled = false; - buttonStop.Enabled = false; + // update the state of the service + if (listServices.Items.ContainsKey(newItem.Status.ServiceName)) + listServices.Items[newItem.Status.ServiceName].SubItems[2].Text = + newItem.Status.ServiceStatusProcess.CurrentState.ToString(); - switch (newItem.Status.ServiceStatusProcess.CurrentState) + // update the start and stop buttons if we have a service selected + if (listServices.SelectedItems.Count == 1) + { + if (listServices.SelectedItems[0].Name == newItem.Status.ServiceName) { - case ServiceState.Running: - this.buttonStop.Enabled = true; - break; - case ServiceState.Stopped: - this.buttonStart.Enabled = true; - break; + buttonStart.Enabled = false; + buttonStop.Enabled = false; + + if (newItem.Status.ServiceStatusProcess.CurrentState == ServiceState.Running) + buttonStop.Enabled = true; + else if (newItem.Status.ServiceStatusProcess.CurrentState == ServiceState.Stopped) + buttonStart.Enabled = true; } } - } - // if the service was just started in this process, add it to the list - if (newItem.Status.ServiceStatusProcess.ProcessID == this.PID && oldItem.Status.ServiceStatusProcess.ProcessID == 0) - { - if (!listServices.Items.ContainsKey(newItem.Status.ServiceName)) + // if the service was just started in this process, add it to the list + if (newItem.Status.ServiceStatusProcess.ProcessID == this.PID && oldItem.Status.ServiceStatusProcess.ProcessID == 0) { - listServices.Items.Add(new ListViewItem(new string[] + if (!listServices.Items.ContainsKey(newItem.Status.ServiceName)) { - newItem.Status.ServiceName, - newItem.Status.DisplayName, - newItem.Status.ServiceStatusProcess.CurrentState.ToString() - })).Name = newItem.Status.ServiceName; + listServices.Items.Add(new ListViewItem(new string[] { + newItem.Status.ServiceName, + newItem.Status.DisplayName, + newItem.Status.ServiceStatusProcess.CurrentState.ToString() + })).Name = newItem.Status.ServiceName; + } } - } - })); + })); } private void listServices_SelectedIndexChanged(object sender, EventArgs e) @@ -270,10 +265,10 @@ private void UpdateInformation() } catch { - textDescription.Text = string.Empty; + textDescription.Text = ""; } - textServiceDll.Text = string.Empty; + textServiceDll.Text = ""; if (item.Config.ServiceType == ProcessHacker.Native.Api.ServiceType.Win32ShareProcess) { @@ -315,17 +310,17 @@ private void UpdateInformation() private void ClearControls() { - labelServiceName.Text = string.Empty; - labelServiceDisplayName.Text = string.Empty; - comboType.Text = string.Empty; - comboStartType.Text = string.Empty; - comboErrorControl.Text = string.Empty; - textServiceBinaryPath.Text = string.Empty; - textUserAccount.Text = string.Empty; + labelServiceName.Text = ""; + labelServiceDisplayName.Text = ""; + comboType.Text = ""; + comboStartType.Text = ""; + comboErrorControl.Text = ""; + textServiceBinaryPath.Text = ""; + textUserAccount.Text = ""; textPassword.Text = "password"; - textLoadOrderGroup.Text = string.Empty; - textDescription.Text = string.Empty; - textServiceDll.Text = string.Empty; + textLoadOrderGroup.Text = ""; + textDescription.Text = ""; + textServiceDll.Text = ""; } private void buttonApply_Click(object sender, EventArgs e) @@ -430,7 +425,8 @@ private void buttonDependents_Click(object sender, EventArgs e) { try { - using (ServiceController controller = new ServiceController(listServices.SelectedItems[0].Name)) + using (ServiceController controller = new ServiceController( + listServices.SelectedItems[0].Name)) { List dependents = new List(); @@ -452,7 +448,8 @@ private void buttonDependencies_Click(object sender, EventArgs e) { try { - using (ServiceController controller = new ServiceController(listServices.SelectedItems[0].Name)) + using (ServiceController controller = new ServiceController( + listServices.SelectedItems[0].Name)) { List dependencies = new List(); @@ -482,7 +479,7 @@ private void buttonPermissions_Click(object sender, EventArgs e) SecurityEditor.EditSecurity( this, SecurityEditor.GetSecurableWrapper( - access => new ServiceHandle(listServices.SelectedItems[0].Name, (ServiceAccess)access) + (access) => new ServiceHandle(listServices.SelectedItems[0].Name, (ServiceAccess)access) ), listServices.SelectedItems[0].Name, NativeTypeFactory.GetAccessEntries(NativeTypeFactory.ObjectType.Service) diff --git a/1.x/trunk/ProcessHacker/Components/ServiceProperties.resx b/1.x/trunk/ProcessHacker/Components/ServiceProperties.resx index 026c576b4..a5979aadf 100644 --- a/1.x/trunk/ProcessHacker/Components/ServiceProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/ServiceProperties.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/SplitButton.cs b/1.x/trunk/ProcessHacker/Components/SplitButton.cs index 46c331906..49f3c78ca 100644 --- a/1.x/trunk/ProcessHacker/Components/SplitButton.cs +++ b/1.x/trunk/ProcessHacker/Components/SplitButton.cs @@ -20,18 +20,22 @@ namespace wyDay.Controls { - public sealed class SplitButton : Button + public class SplitButton : Button { private PushButtonState _state; private const int SplitSectionWidth = 18; - private static readonly int BorderSize = SystemInformation.Border3DSize.Width * 2; - private bool skipNextOpen; - private Rectangle dropDownRectangle; - private bool showSplit; - private bool isSplitMenuVisible; - private ContextMenuStrip m_SplitMenuStrip; + private static int BorderSize = SystemInformation.Border3DSize.Width * 2; + private bool skipNextOpen = false; + private Rectangle dropDownRectangle = new Rectangle(); + private bool showSplit = false; + + private bool isSplitMenuVisible = false; + + + private ContextMenuStrip m_SplitMenuStrip = null; + private ContextMenu m_SplitMenu = null; TextFormatFlags textFormatFlags = TextFormatFlags.Default; @@ -55,6 +59,31 @@ public override ContextMenuStrip ContextMenuStrip } } + [DefaultValue(null)] + public ContextMenu SplitMenu + { + get { return m_SplitMenu; } + set + { + //remove the event handlers for the old SplitMenu + if (m_SplitMenu != null) + { + m_SplitMenu.Popup -= new EventHandler(SplitMenu_Popup); + } + + //add the event handlers for the new SplitMenu + if (value != null) + { + ShowSplit = true; + value.Popup += new EventHandler(SplitMenu_Popup); + } + else + ShowSplit = false; + + m_SplitMenu = value; + } + } + [DefaultValue(null)] public ContextMenuStrip SplitMenuStrip { @@ -67,16 +96,16 @@ public ContextMenuStrip SplitMenuStrip //remove the event handlers for the old SplitMenuStrip if (m_SplitMenuStrip != null) { - m_SplitMenuStrip.Closing -= this.SplitMenuStrip_Closing; - m_SplitMenuStrip.Opening -= this.SplitMenuStrip_Opening; + m_SplitMenuStrip.Closing -= new ToolStripDropDownClosingEventHandler(SplitMenuStrip_Closing); + m_SplitMenuStrip.Opening -= new CancelEventHandler(SplitMenuStrip_Opening); } //add the event handlers for the new SplitMenuStrip if (value != null) { ShowSplit = true; - value.Closing += this.SplitMenuStrip_Closing; - value.Opening += this.SplitMenuStrip_Opening; + value.Closing += new ToolStripDropDownClosingEventHandler(SplitMenuStrip_Closing); + value.Opening += new CancelEventHandler(SplitMenuStrip_Opening); } else ShowSplit = false; @@ -262,7 +291,7 @@ protected override void OnMouseDown(MouseEventArgs e) } //handle ContextMenu re-clicking the drop-down region to close the menu - if (m_SplitMenuStrip != null && e.Button == MouseButtons.Left && !isMouseEntered) + if (m_SplitMenu != null && e.Button == MouseButtons.Left && !isMouseEntered) skipNextOpen = true; if (dropDownRectangle.Contains(e.Location) && !isSplitMenuVisible && e.Button == MouseButtons.Left) @@ -288,7 +317,7 @@ protected override void OnMouseUp(MouseEventArgs mevent) { ShowContextMenuStrip(); } - else if (m_SplitMenuStrip == null && m_SplitMenuStrip == null || !isSplitMenuVisible) + else if (m_SplitMenuStrip == null && m_SplitMenu == null || !isSplitMenuVisible) { SetButtonDrawState(); @@ -429,8 +458,7 @@ public override Size GetPreferredSize(Size proposedSize) { if (AutoSize) return CalculateButtonAutoSize(); - - if (!string.IsNullOrEmpty(this.Text) && TextRenderer.MeasureText(this.Text, this.Font).Width + SplitSectionWidth > preferredSize.Width) + else if (!string.IsNullOrEmpty(Text) && TextRenderer.MeasureText(Text, Font).Width + SplitSectionWidth > preferredSize.Width) return preferredSize + new Size(SplitSectionWidth + BorderSize * 2, 0); } @@ -607,9 +635,9 @@ private void LayoutTextBeforeOrAfterImage(Rectangle totalArea, bool textFirst, S else if (h_image == HorizontalAlignment.Right && h_text == HorizontalAlignment.Right) offset = excess_width; else if (h_image == HorizontalAlignment.Center && (h_text == HorizontalAlignment.Left || h_text == HorizontalAlignment.Center)) - offset += excess_width / 3; + offset += (int)(excess_width / 3); else - offset += 2 * (excess_width / 3); + offset += (int)(2 * (excess_width / 3)); if (textFirst) { @@ -658,9 +686,9 @@ private void LayoutTextAboveOrBelowImage(Rectangle totalArea, bool textFirst, Si else if (v_image == VerticalAlignment.Bottom && v_text == VerticalAlignment.Bottom) offset = excess_height; else if (v_image == VerticalAlignment.Center && (v_text == VerticalAlignment.Top || v_text == VerticalAlignment.Center)) - offset += excess_height / 3; + offset += (int)(excess_height / 3); else - offset += 2 * (excess_height / 3); + offset += (int)(2 * (excess_height / 3)); if (textFirst) { @@ -758,7 +786,11 @@ private void ShowContextMenuStrip() State = PushButtonState.Pressed; - if (m_SplitMenuStrip != null) + if (m_SplitMenu != null) + { + m_SplitMenu.Show(this, new Point(0, Height)); + } + else if (m_SplitMenuStrip != null) { m_SplitMenuStrip.Show(this, new Point(0, Height), ToolStripDropDownDirection.BelowRight); } diff --git a/1.x/trunk/ProcessHacker/Components/StructViewer.Designer.cs b/1.x/trunk/ProcessHacker/Components/StructViewer.Designer.cs index 2076588ad..f9c95d1bc 100644 --- a/1.x/trunk/ProcessHacker/Components/StructViewer.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/StructViewer.Designer.cs @@ -28,6 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.treeStruct = new Aga.Controls.Tree.TreeViewAdv(); this.columnName = new Aga.Controls.Tree.TreeColumn(); this.columnValue = new Aga.Controls.Tree.TreeColumn(); @@ -38,6 +39,8 @@ private void InitializeComponent() this.decMenuItem = new System.Windows.Forms.MenuItem(); this.hexMenuItem = new System.Windows.Forms.MenuItem(); this.copyMenuItem = new System.Windows.Forms.MenuItem(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // treeStruct @@ -47,6 +50,9 @@ private void InitializeComponent() this.treeStruct.Columns.Add(this.columnValue); this.treeStruct.DefaultToolTipProvider = null; this.treeStruct.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeStruct.DragDropMarkColor = System.Drawing.Color.Black; + this.treeStruct.FullRowSelect = true; + this.treeStruct.GridLineStyle = Aga.Controls.Tree.GridLineStyle.Horizontal; this.treeStruct.LineColor = System.Drawing.SystemColors.ControlDark; this.treeStruct.Location = new System.Drawing.Point(0, 0); this.treeStruct.Model = null; @@ -58,6 +64,7 @@ private void InitializeComponent() this.treeStruct.ShowNodeToolTips = true; this.treeStruct.Size = new System.Drawing.Size(362, 331); this.treeStruct.TabIndex = 0; + this.treeStruct.UseColumns = true; // // columnName // @@ -120,17 +127,22 @@ private void InitializeComponent() // // copyMenuItem // + this.vistaMenu.SetImage(this.copyMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyMenuItem.Index = 1; this.copyMenuItem.Text = "&Copy"; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + // // StructViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.treeStruct); this.Name = "StructViewer"; this.Size = new System.Drawing.Size(362, 331); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); } @@ -147,5 +159,6 @@ private void InitializeComponent() private System.Windows.Forms.MenuItem decMenuItem; private System.Windows.Forms.MenuItem hexMenuItem; private System.Windows.Forms.MenuItem copyMenuItem; + private wyDay.Controls.VistaMenu vistaMenu; } } diff --git a/1.x/trunk/ProcessHacker/Components/StructViewer.cs b/1.x/trunk/ProcessHacker/Components/StructViewer.cs index b83c7d689..06a7ccc54 100644 --- a/1.x/trunk/ProcessHacker/Components/StructViewer.cs +++ b/1.x/trunk/ProcessHacker/Components/StructViewer.cs @@ -32,13 +32,17 @@ namespace ProcessHacker.Components { public partial class StructViewer : UserControl { - private readonly StructModel _model = new StructModel(); - readonly StructDef _struct; + private StructModel _model = new StructModel(); + int _pid; + IntPtr _address; + StructDef _struct; public StructViewer(int pid, IntPtr address, StructDef struc) { InitializeComponent(); + _pid = pid; + _address = address; _struct = struc; treeStruct.Model = _model; treeStruct.ContextMenu = menuStruct; @@ -54,12 +58,8 @@ public StructViewer(int pid, IntPtr address, StructDef struc) _struct.Structs = Program.Structs; values = _struct.Read(); - _model.Nodes.Add(new StructNode(new FieldValue - { - Name = "Struct", - FieldType = FieldType.StringUTF16, - Value = string.Empty - })); + _model.Nodes.Add(new StructNode(new FieldValue() + { Name = "Struct", FieldType = FieldType.StringUTF16, Value = "" })); foreach (FieldValue val in values) this.AddNode(_model.Nodes[0], val); @@ -158,7 +158,8 @@ public string Value if (_value.StructName != null) return _value.StructName + "[" + memberCount.ToString() + "]"; - return type.ToString() + "[" + memberCount.ToString() + "]"; + else + return type.ToString() + "[" + memberCount.ToString() + "]"; } if (_value.StructName != null) diff --git a/1.x/trunk/ProcessHacker/Components/StructViewer.resx b/1.x/trunk/ProcessHacker/Components/StructViewer.resx index 50dae8683..62e3a554d 100644 --- a/1.x/trunk/ProcessHacker/Components/StructViewer.resx +++ b/1.x/trunk/ProcessHacker/Components/StructViewer.resx @@ -112,12 +112,18 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 + + 132, 17 + + + 132, 17 + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TargetWindowButton.cs b/1.x/trunk/ProcessHacker/Components/TargetWindowButton.cs index 2bc1a00a5..1c5723060 100644 --- a/1.x/trunk/ProcessHacker/Components/TargetWindowButton.cs +++ b/1.x/trunk/ProcessHacker/Components/TargetWindowButton.cs @@ -28,14 +28,14 @@ namespace ProcessHacker.Components { public delegate void TargetWindowFoundDelegate(int pid, int tid); - public sealed class TargetWindowButton : ToolStripButton + public class TargetWindowButton : ToolStripButton { public event TargetWindowFoundDelegate TargetWindowFound; private Control _parent; - private readonly Control _dummy; + private Control _dummy; private IntPtr _currentHWnd; - private bool _targeting; + private bool _targeting = false; public TargetWindowButton() { @@ -93,7 +93,12 @@ private void DrawWindowRectangle(IntPtr hWnd) } } - private void RedrawWindow(IntPtr hWnd, bool workaround = true) + private void RedrawWindow(IntPtr hWnd) + { + this.RedrawWindow(hWnd, true); + } + + private void RedrawWindow(IntPtr hWnd, bool workaround) { if (!Win32.RedrawWindow( hWnd, @@ -150,10 +155,11 @@ void dummy_MouseMove(object sender, MouseEventArgs e) if (oldHWnd != IntPtr.Zero) this.RedrawWindow(oldHWnd); - int pid; + bool isPhWindow = false; + int pid, tid; - Win32.GetWindowThreadProcessId(this._currentHWnd, out pid); - bool isPhWindow = pid == Program.CurrentProcessId; + tid = Win32.GetWindowThreadProcessId(_currentHWnd, out pid); + isPhWindow = pid == Program.CurrentProcessId; // Draw a rectangle over the current window. if ( @@ -174,9 +180,9 @@ void dummy_MouseUp(object sender, MouseEventArgs e) // Redraw the window we found. this.RedrawWindow(_currentHWnd, false); - int pid; + int pid, tid; - int tid = Win32.GetWindowThreadProcessId(this._currentHWnd, out pid); + tid = Win32.GetWindowThreadProcessId(_currentHWnd, out pid); if (this.TargetWindowFound != null) this.TargetWindowFound(pid, tid); diff --git a/1.x/trunk/ProcessHacker/Components/TaskDialog/ActiveTaskDialog.cs b/1.x/trunk/ProcessHacker/Components/TaskDialog/ActiveTaskDialog.cs index 87581f86e..aaa4f1007 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskDialog/ActiveTaskDialog.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskDialog/ActiveTaskDialog.cs @@ -11,6 +11,8 @@ namespace ProcessHacker.Components using System; using System.Drawing; using System.Windows.Forms; + using System.Runtime.InteropServices; + using System.Diagnostics.CodeAnalysis; /// /// The active Task Dialog window. Provides several methods for acting on the active TaskDialog. @@ -22,7 +24,7 @@ public class ActiveTaskDialog : IWin32Window /// /// The Task Dialog's window handle. /// - private readonly IntPtr handle; + private IntPtr handle; /// /// Creates a ActiveTaskDialog. @@ -125,7 +127,7 @@ public bool SetProgressBarRange(Int16 minRange, Int16 maxRange) // TDM_SET_PROGRESS_BAR_RANGE = WM_USER+105, // lParam = MAKELPARAM(nMinRange, nMaxRange) // #define MAKELPARAM(l, h) ((LPARAM)(DWORD)MAKELONG(l, h)) // #define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD_PTR)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(b)) & 0xffff))) << 16)) - IntPtr lparam = (IntPtr)((minRange & 0xffff) | ((maxRange & 0xffff) << 16)); + IntPtr lparam = (IntPtr)((((Int32)minRange) & 0xffff) | ((((Int32)maxRange) & 0xffff) << 16)); return UnsafeNativeMethods.SendMessage( this.handle, (uint)UnsafeNativeMethods.TASKDIALOG_MESSAGES.TDM_SET_PROGRESS_BAR_RANGE, @@ -365,7 +367,7 @@ public void SetButtonElevationRequiredState(int buttonId, bool elevationRequired this.handle, (uint)UnsafeNativeMethods.TASKDIALOG_MESSAGES.TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, (IntPtr)buttonId, - elevationRequired ? new IntPtr(1) : IntPtr.Zero); + (IntPtr)(elevationRequired ? new IntPtr(1) : IntPtr.Zero)); } /// diff --git a/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs b/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs index 8ecc00828..f71864eae 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialog.cs @@ -13,7 +13,6 @@ namespace ProcessHacker.Components using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; - using ProcessHacker.Native; /// /// The signature of the callback that recieves notificaitons from the Task Dialog. @@ -267,8 +266,6 @@ public enum ProgressBarState [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)] public struct TaskDialogButton { - public static readonly int SizeOf; - /// /// The ID of the button. This value is returned by TaskDialog.Show when the button is clicked. /// @@ -309,11 +306,6 @@ public string ButtonText get { return this.buttonText; } set { this.buttonText = value; } } - - static TaskDialogButton() - { - SizeOf = Marshal.SizeOf(typeof(TaskDialogButton)); - } } /// @@ -1008,12 +1000,12 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out { verificationFlagChecked = false; radioButtonResult = 0; - int result; + int result = 0; UnsafeNativeMethods.TASKDIALOGCONFIG config = new UnsafeNativeMethods.TASKDIALOGCONFIG(); try { - config.cbSize = (uint)UnsafeNativeMethods.TASKDIALOGCONFIG.SizeOf; + config.cbSize = (uint)Marshal.SizeOf(typeof(UnsafeNativeMethods.TASKDIALOGCONFIG)); config.hwndParent = hwndOwner; config.dwFlags = this.flags; config.dwCommonButtons = this.commonButtons; @@ -1044,8 +1036,8 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out if (customButtons.Length > 0) { // Hand marshal the buttons array. - int elementSize = TaskDialogButton.SizeOf; - config.pButtons = MemoryAlloc.PrivateHeap.Allocate(elementSize * customButtons.Length); + int elementSize = Marshal.SizeOf(typeof(TaskDialogButton)); + config.pButtons = Marshal.AllocHGlobal(elementSize * (int)customButtons.Length); for (int i = 0; i < customButtons.Length; i++) { unsafe // Unsafe because of pointer arithmatic. @@ -1062,8 +1054,8 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out if (customRadioButtons.Length > 0) { // Hand marshal the buttons array. - int elementSize = TaskDialogButton.SizeOf; - config.pRadioButtons = MemoryAlloc.PrivateHeap.Allocate(elementSize * customRadioButtons.Length); + int elementSize = Marshal.SizeOf(typeof(TaskDialogButton)); + config.pRadioButtons = Marshal.AllocHGlobal(elementSize * (int)customRadioButtons.Length); for (int i = 0; i < customRadioButtons.Length; i++) { unsafe // Unsafe because of pointer arithmatic. @@ -1115,7 +1107,7 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out // translate to the friendly version. if (this.callback != null) { - config.pfCallback = this.PrivateCallback; + config.pfCallback = new UnsafeNativeMethods.TaskDialogCallback(this.PrivateCallback); } ////config.lpCallbackData = this.callbackData; // How do you do this? Need to pin the ref? @@ -1132,7 +1124,7 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out // that are not required for the users of this class. if (config.pButtons != IntPtr.Zero) { - int elementSize = TaskDialogButton.SizeOf; + int elementSize = Marshal.SizeOf(typeof(TaskDialogButton)); for (int i = 0; i < config.cButtons; i++) { unsafe @@ -1142,12 +1134,12 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out } } - MemoryAlloc.PrivateHeap.Free(config.pButtons); + Marshal.FreeHGlobal(config.pButtons); } if (config.pRadioButtons != IntPtr.Zero) { - int elementSize = TaskDialogButton.SizeOf; + int elementSize = Marshal.SizeOf(typeof(TaskDialogButton)); for (int i = 0; i < config.cRadioButtons; i++) { unsafe @@ -1157,7 +1149,7 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out } } - MemoryAlloc.PrivateHeap.Free(config.pRadioButtons); + Marshal.FreeHGlobal(config.pRadioButtons); } } @@ -1173,20 +1165,17 @@ private int PrivateShow(IntPtr hwndOwner, out bool verificationFlagChecked, out /// Specifies additional noitification information. The contents of this parameter depends on the value of the msg parameter. /// Specifies the application-defined value given in the call to TaskDialogIndirect. /// A HRESULT. It's not clear in the spec what a failed result will do. - private int PrivateCallback([In] IntPtr hwnd, [In] TaskDialogNotification msg, [In] UIntPtr wparam, [In] IntPtr lparam, [In] IntPtr refData) + private int PrivateCallback([In] IntPtr hwnd, [In] uint msg, [In] UIntPtr wparam, [In] IntPtr lparam, [In] IntPtr refData) { - TaskDialogCallback cb = this.callback; - if (cb != null) + TaskDialogCallback callback = this.callback; + if (callback != null) { // Prepare arguments for the callback to the user we are insulating from Interop casting sillyness. // Future: Consider reusing a single ActiveTaskDialog object and mark it as destroyed on the destry notification. ActiveTaskDialog activeDialog = new ActiveTaskDialog(hwnd); - TaskDialogNotificationArgs args = new TaskDialogNotificationArgs - { - Notification = msg - }; - + TaskDialogNotificationArgs args = new TaskDialogNotificationArgs(); + args.Notification = (TaskDialogNotification)msg; switch (args.Notification) { case TaskDialogNotification.ButtonClicked: @@ -1207,7 +1196,7 @@ private int PrivateCallback([In] IntPtr hwnd, [In] TaskDialogNotification msg, [ break; } - return (cb(activeDialog, args, this.callbackData) ? 1 : 0); + return (callback(activeDialog, args, this.callbackData) ? 1 : 0); } return 0; // false; diff --git a/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialogCommonDialog.cs b/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialogCommonDialog.cs index a8700a423..e401e5d2b 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialogCommonDialog.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskDialog/TaskDialogCommonDialog.cs @@ -22,7 +22,7 @@ public class TaskDialogCommonDialog : CommonDialog /// /// The TaskDialog we will display. /// - private readonly TaskDialog taskDialog; + private TaskDialog taskDialog; /// /// The result of the dialog, either a DialogResult value for common push buttons set in the TaskDialog.CommonButtons diff --git a/1.x/trunk/ProcessHacker/Components/TaskDialog/UnsafeNativeMethods.cs b/1.x/trunk/ProcessHacker/Components/TaskDialog/UnsafeNativeMethods.cs index 075d50565..3f2273ede 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskDialog/UnsafeNativeMethods.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskDialog/UnsafeNativeMethods.cs @@ -9,13 +9,14 @@ namespace ProcessHacker.Components { using System; + using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; /// /// Class to hold native code interop declarations. /// [System.Security.SuppressUnmanagedCodeSecurity] - internal static class UnsafeNativeMethods + internal static partial class UnsafeNativeMethods { /// /// WM_USER taken from WinUser.h @@ -31,7 +32,7 @@ internal static class UnsafeNativeMethods /// wParam which is interpreted differently depending on the message. /// The refrence data that was set to TaskDialog.CallbackData. /// A HRESULT value. The return value is specific to the message being processed. - internal delegate int TaskDialogCallback([In] IntPtr hwnd, [In] TaskDialogNotification msg, [In] UIntPtr wParam, [In] IntPtr lParam, [In] IntPtr refData); + internal delegate int TaskDialogCallback([In] IntPtr hwnd, [In] uint msg, [In] UIntPtr wParam, [In] IntPtr lParam, [In] IntPtr refData); /// /// TASKDIALOG_FLAGS taken from CommCtrl.h. @@ -312,8 +313,6 @@ internal static extern void TaskDialogIndirect( [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)] internal struct TASKDIALOGCONFIG { - public static readonly int SizeOf; - /// /// Size of the structure in bytes. /// @@ -441,12 +440,7 @@ internal struct TASKDIALOGCONFIG /// Width of the Task Dialog's client area in DLU's. /// If 0, Task Dialog will calculate the ideal width. /// - public uint cxWidth; - - static TASKDIALOGCONFIG() - { - SizeOf = Marshal.SizeOf(typeof(TASKDIALOGCONFIG)); - } + public uint cxWidth; } } } diff --git a/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/COMTypes.cs b/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/COMTypes.cs index d0c262547..3d938138b 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/COMTypes.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/COMTypes.cs @@ -24,38 +24,39 @@ using System; using System.Runtime.InteropServices; using System.Text; +using System.Runtime.CompilerServices; using ProcessHacker.Native.Api; namespace TaskbarLib.Interop { #region "Interface Classes" - [ComImportAttribute] + [ComImportAttribute()] [GuidAttribute("86C14003-4D6B-4EF3-A7B4-0506663B2E68")] [ClassInterfaceAttribute(ClassInterfaceType.None)] internal class CApplicationDestinations { } - [ComImportAttribute] + [ComImportAttribute()] [GuidAttribute("86BEC222-30F2-47E0-9F25-60D11CD75C28")] [ClassInterfaceAttribute(ClassInterfaceType.None)] internal class CApplicationDocumentLists { } - [ComImportAttribute] + [ComImportAttribute()] [GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")] [ClassInterfaceAttribute(ClassInterfaceType.None)] internal class CTaskbarList { } - [ComImportAttribute] + [ComImportAttribute()] [GuidAttribute("00021401-0000-0000-C000-000000000046")] [ClassInterfaceAttribute(ClassInterfaceType.None)] internal class CShellLink { } - [ComImportAttribute] + [ComImportAttribute()] [GuidAttribute("77F10CF0-3DB5-4966-B520-B7C54FD35ED6")] [ClassInterfaceAttribute(ClassInterfaceType.None)] internal class CDestinationList { } - [ComImportAttribute] + [ComImportAttribute()] [GuidAttribute("2D3468C1-36A7-43B6-AC24-D3F02FD9607A")] [ClassInterfaceAttribute(ClassInterfaceType.None)] internal class CEnumerableObjectCollection { } @@ -64,7 +65,7 @@ internal class CEnumerableObjectCollection { } #region "Interfaces" - [ComImportAttribute] + [ComImportAttribute()] [GuidAttribute("92CA9DCD-5622-4BBA-A805-5E9F541BD8C9")] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] internal interface IObjectArray diff --git a/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/Interop.cs b/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/Interop.cs index 87633043c..1724f50d0 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/Interop.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskbarLib/Interop/Interop.cs @@ -24,6 +24,7 @@ using System; using System.Runtime.InteropServices; using System.Security; +using System.Text; using ProcessHacker.Native.Api; namespace TaskbarLib.Interop @@ -139,16 +140,16 @@ internal struct CALPWSTR } [StructLayout(LayoutKind.Explicit)] - public struct PropVariant : IDisposable + internal struct PropVariant : IDisposable { [FieldOffset(0)] private ushort vt; [FieldOffset(8)] private IntPtr pointerValue; [FieldOffset(8)] - public byte byteValue; + private byte byteValue; [FieldOffset(8)] - public long longValue; + private long longValue; [FieldOffset(8)] private short boolValue; [MarshalAs(UnmanagedType.Struct)] @@ -245,10 +246,10 @@ internal static class UnsafeNativeMethods public static extern HResult SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID); [DllImport("shell32.dll")] - public static extern HResult GetCurrentProcessExplicitAppUserModelID([Out, MarshalAs(UnmanagedType.LPWStr)] out string AppID); + public static extern HResult GetCurrentProcessExplicitAppUserModelID([Out(), MarshalAs(UnmanagedType.LPWStr)] out string AppID); [DllImport("shell32.dll")] - public static extern HResult SHGetPropertyStoreForWindow(IntPtr hwnd, ref Guid iid /*IID_IPropertyStore*/, [Out, MarshalAs(UnmanagedType.Interface)] out IPropertyStore propertyStore); + public static extern HResult SHGetPropertyStoreForWindow(IntPtr hwnd, ref Guid iid /*IID_IPropertyStore*/, [Out(), MarshalAs(UnmanagedType.Interface)] out IPropertyStore propertyStore); [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern HResult SHCreateItemFromParsingName(string path, /* The following parameter is not used - binding context. */ IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem); diff --git a/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListImpl.cs b/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListImpl.cs index 4fe093d2f..dfde269d8 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListImpl.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListImpl.cs @@ -25,6 +25,7 @@ using System.Collections.Generic; using System.Linq; using TaskbarLib.Interop; +using System.Runtime.InteropServices; using ProcessHacker.Native.Api; namespace TaskbarLib @@ -36,7 +37,7 @@ internal sealed class JumpListDestinations { //TODO: This is highly inefficient, but we want to maintain insertion order when adding the categories //because the bottom categories are first to be truncated if screen estate is low. - private readonly SortedDictionary> _categorizedDestinations = + private SortedDictionary> _categorizedDestinations = new SortedDictionary>(); public void AddDestination(IJumpListDestination destination) @@ -96,7 +97,8 @@ public IEnumerable Categories select _categorizedDestinations[d].First().Category); } } - public IEnumerable GetDestinationsByCategory(string category) + public IEnumerable GetDestinationsByCategory( + string category) { return (from k in _categorizedDestinations.Keys @@ -116,7 +118,7 @@ public void Clear() /// internal sealed class JumpListTasks { - private readonly List _tasks = new List(); + private List _tasks = new List(); public void AddTask(IJumpListTask task) { diff --git a/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListManager.cs b/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListManager.cs index 5b863e49a..dd058596b 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListManager.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskbarLib/JumpLists/JumpListManager.cs @@ -27,8 +27,10 @@ using System.IO; using System.Runtime.InteropServices; using System.Text; +using System.Threading; using Microsoft.Win32; using TaskbarLib.Interop; +using System.Runtime.CompilerServices; using ProcessHacker.Native.Api; namespace TaskbarLib @@ -51,13 +53,13 @@ public sealed class JumpListManager : IDisposable { #region Members - readonly string _appId; + string _appId; uint _maxSlotsInList; - readonly JumpListTasks _tasks; - readonly JumpListDestinations _destinations; - readonly EventHandler _displaySettingsChangeHandler; - readonly ICustomDestinationList _customDestinationList; + JumpListTasks _tasks; + JumpListDestinations _destinations; + EventHandler _displaySettingsChangeHandler; + ICustomDestinationList _customDestinationList; ApplicationDestinationType _enabledAutoDestinationType; // = ApplicationDestinationType.Recent; #endregion diff --git a/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButton.cs b/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButton.cs index 830a8b0dd..b3630b3ff 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButton.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButton.cs @@ -32,7 +32,7 @@ namespace TaskbarLib /// public sealed class ThumbButton { - private readonly ThumbButtonManager _manager; + private ThumbButtonManager _manager; internal ThumbButton(ThumbButtonManager manager, int id, Icon icon, string tooltip) { @@ -70,15 +70,13 @@ internal THUMBBUTTON Win32ThumbButton { get { - THUMBBUTTON win32ThumbButton = new THUMBBUTTON - { - iId = this.Id, - szTip = this.Tooltip, - hIcon = this.Icon.Handle, - dwFlags = this.Flags | ThumbnailButtonFlags.DISMISSONCLICK, - dwMask = ThumbnailButtonMask.Flags - }; + THUMBBUTTON win32ThumbButton = new THUMBBUTTON(); + win32ThumbButton.iId = Id; + win32ThumbButton.szTip = Tooltip; + win32ThumbButton.hIcon = Icon.Handle; + win32ThumbButton.dwFlags = Flags | ThumbnailButtonFlags.DISMISSONCLICK; + win32ThumbButton.dwMask = ThumbnailButtonMask.Flags; if (Tooltip != null) win32ThumbButton.dwMask |= ThumbnailButtonMask.Tooltip; if (Icon != null) diff --git a/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButtonManager.cs b/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButtonManager.cs index 6d1e74ede..69ba0de5a 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButtonManager.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskbarLib/ThumbnailButtons/ThumbButtonManager.cs @@ -37,7 +37,7 @@ public sealed class ThumbButtonManager : IDisposable { private sealed class MessageFilter : IMessageFilter { - private readonly ThumbButtonManager _manager; + private ThumbButtonManager _manager; public MessageFilter(ThumbButtonManager manager) { @@ -48,13 +48,12 @@ public bool PreFilterMessage(ref Message m) { if (m.Msg == (int)Windows7Taskbar.TaskbarButtonCreatedMessage) { - this._manager.OnTaskbarButtonCreated(); + _manager.OnTaskbarButtonCreated(); return true; } - - if (m.Msg == (int)ProcessHacker.Native.Api.WindowMessage.Command) + else if (m.Msg == (int)ProcessHacker.Native.Api.WindowMessage.Command) { - this._manager.OnCommand(m.WParam); + _manager.OnCommand(m.WParam); } return false; @@ -63,8 +62,8 @@ public bool PreFilterMessage(ref Message m) public event EventHandler TaskbarButtonCreated; - private readonly Form _form; - private readonly MessageFilter _filter; + private Form _form; + private MessageFilter _filter; private bool _disposed; /// @@ -166,7 +165,7 @@ internal void RefreshThumbButtons() } } - private readonly Dictionary _thumbButtons = new Dictionary(); + private Dictionary _thumbButtons = new Dictionary(); #endregion } diff --git a/1.x/trunk/ProcessHacker/Components/TaskbarLib/Windows7Taskbar.cs b/1.x/trunk/ProcessHacker/Components/TaskbarLib/Windows7Taskbar.cs index b05156236..e24e2c8f2 100644 --- a/1.x/trunk/ProcessHacker/Components/TaskbarLib/Windows7Taskbar.cs +++ b/1.x/trunk/ProcessHacker/Components/TaskbarLib/Windows7Taskbar.cs @@ -72,8 +72,9 @@ public static JumpListManager CreateJumpListManager() private static IPropertyStore InternalGetWindowPropertyStore(IntPtr hwnd) { IPropertyStore propStore; - - UnsafeNativeMethods.SHGetPropertyStoreForWindow(hwnd, ref SafeNativeMethods.IID_IPropertyStore, out propStore); + HResult shGetPropertyStoreResult = UnsafeNativeMethods.SHGetPropertyStoreForWindow( + hwnd, ref SafeNativeMethods.IID_IPropertyStore, out propStore); + shGetPropertyStoreResult.ThrowIf(); return propStore; } @@ -118,16 +119,15 @@ public static string AppId set { IPropertyStore propStore = InternalGetWindowPropertyStore(Program.HackerWindowHandle); - if (propStore != null) - { - PropVariant pv = new PropVariant(); - pv.SetValue(value); - propStore.SetValue(ref PropertyKey.PKEY_AppUserModel_ID, ref pv); + PropVariant pv = new PropVariant(); + pv.SetValue(value); - Marshal.ReleaseComObject(propStore); - pv.Dispose(); - } + HResult setValueResult = propStore.SetValue(ref PropertyKey.PKEY_AppUserModel_ID, ref pv); + setValueResult.ThrowIf(); + + Marshal.ReleaseComObject(propStore); + pv.Dispose(); } } @@ -139,12 +139,14 @@ public static string ProcessAppId get { string appId; - UnsafeNativeMethods.GetCurrentProcessExplicitAppUserModelID(out appId); + HResult getProcessAppUserModeIDResult = UnsafeNativeMethods.GetCurrentProcessExplicitAppUserModelID(out appId); + getProcessAppUserModeIDResult.ThrowIf(); return appId; } set { - UnsafeNativeMethods.SetCurrentProcessExplicitAppUserModelID(value); + HResult setProcessAppUserModeIDResult = UnsafeNativeMethods.SetCurrentProcessExplicitAppUserModelID(value); + setProcessAppUserModeIDResult.ThrowIf(); } } diff --git a/1.x/trunk/ProcessHacker/Components/ThreadList.Designer.cs b/1.x/trunk/ProcessHacker/Components/ThreadList.Designer.cs index 9cff647c8..8fd5967a5 100644 --- a/1.x/trunk/ProcessHacker/Components/ThreadList.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/ThreadList.Designer.cs @@ -32,11 +32,12 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.listThreads = new ProcessHacker.Components.ExtendedListView(); - this.columnThreadID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnContextSwitchesDelta = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnStartAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnPriority = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.components = new System.ComponentModel.Container(); + this.listThreads = new System.Windows.Forms.ListView(); + this.columnThreadID = new System.Windows.Forms.ColumnHeader(); + this.columnContextSwitchesDelta = new System.Windows.Forms.ColumnHeader(); + this.columnStartAddress = new System.Windows.Forms.ColumnHeader(); + this.columnPriority = new System.Windows.Forms.ColumnHeader(); this.menuThread = new System.Windows.Forms.ContextMenu(); this.inspectThreadMenuItem = new System.Windows.Forms.MenuItem(); this.terminateThreadMenuItem = new System.Windows.Forms.MenuItem(); @@ -83,22 +84,23 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.labelTEBAddress = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.fileModule = new ProcessHacker.Components.FileNameBox(); this.tableInformation.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // listThreads // this.listThreads.AllowColumnReorder = true; - this.listThreads.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listThreads.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listThreads.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnThreadID, this.columnContextSwitchesDelta, this.columnStartAddress, this.columnPriority}); - this.listThreads.DoubleClickChecks = true; this.listThreads.FullRowSelect = true; this.listThreads.HideSelection = false; this.listThreads.Location = new System.Drawing.Point(0, 0); @@ -154,12 +156,14 @@ private void InitializeComponent() // inspectThreadMenuItem // this.inspectThreadMenuItem.DefaultItem = true; + this.vistaMenu.SetImage(this.inspectThreadMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify); this.inspectThreadMenuItem.Index = 0; this.inspectThreadMenuItem.Text = "&Inspect"; this.inspectThreadMenuItem.Click += new System.EventHandler(this.inspectThreadMenuItem_Click); // // terminateThreadMenuItem // + this.vistaMenu.SetImage(this.terminateThreadMenuItem, global::ProcessHacker.Properties.Resources.cross); this.terminateThreadMenuItem.Index = 1; this.terminateThreadMenuItem.Text = "&Terminate"; this.terminateThreadMenuItem.Click += new System.EventHandler(this.terminateThreadMenuItem_Click); @@ -172,12 +176,14 @@ private void InitializeComponent() // // suspendThreadMenuItem // + this.vistaMenu.SetImage(this.suspendThreadMenuItem, global::ProcessHacker.Properties.Resources.control_pause_blue); this.suspendThreadMenuItem.Index = 3; this.suspendThreadMenuItem.Text = "&Suspend"; this.suspendThreadMenuItem.Click += new System.EventHandler(this.suspendThreadMenuItem_Click); // // resumeThreadMenuItem // + this.vistaMenu.SetImage(this.resumeThreadMenuItem, global::ProcessHacker.Properties.Resources.control_play_blue); this.resumeThreadMenuItem.Index = 4; this.resumeThreadMenuItem.Text = "&Resume"; this.resumeThreadMenuItem.Click += new System.EventHandler(this.resumeThreadMenuItem_Click); @@ -201,6 +207,7 @@ private void InitializeComponent() // // tokenThreadMenuItem // + this.vistaMenu.SetImage(this.tokenThreadMenuItem, global::ProcessHacker.Properties.Resources.locked); this.tokenThreadMenuItem.Index = 8; this.tokenThreadMenuItem.Text = "Token"; this.tokenThreadMenuItem.Click += new System.EventHandler(this.tokenThreadMenuItem_Click); @@ -321,6 +328,7 @@ private void InitializeComponent() // // copyThreadMenuItem // + this.vistaMenu.SetImage(this.copyThreadMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyThreadMenuItem.Index = 13; this.copyThreadMenuItem.Text = "C&opy"; // @@ -332,8 +340,8 @@ private void InitializeComponent() // // tableInformation // - this.tableInformation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.tableInformation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tableInformation.ColumnCount = 4; this.tableInformation.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableInformation.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); @@ -372,7 +380,7 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(3, 3); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(33, 13); + this.label6.Size = new System.Drawing.Size(32, 13); this.label6.TabIndex = 1; this.label6.Text = "State"; // @@ -382,7 +390,7 @@ private void InitializeComponent() this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(3, 22); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(65, 13); + this.label8.Size = new System.Drawing.Size(63, 13); this.label8.TabIndex = 1; this.label8.Text = "Kernel Time"; // @@ -392,7 +400,7 @@ private void InitializeComponent() this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(3, 41); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(56, 13); + this.label9.Size = new System.Drawing.Size(55, 13); this.label9.TabIndex = 1; this.label9.Text = "User Time"; // @@ -400,9 +408,9 @@ private void InitializeComponent() // this.labelState.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelState.AutoSize = true; - this.labelState.Location = new System.Drawing.Point(187, 3); + this.labelState.Location = new System.Drawing.Point(188, 3); this.labelState.Name = "labelState"; - this.labelState.Size = new System.Drawing.Size(34, 13); + this.labelState.Size = new System.Drawing.Size(33, 13); this.labelState.TabIndex = 1; this.labelState.Text = "value"; // @@ -410,9 +418,9 @@ private void InitializeComponent() // this.labelKernelTime.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelKernelTime.AutoSize = true; - this.labelKernelTime.Location = new System.Drawing.Point(187, 22); + this.labelKernelTime.Location = new System.Drawing.Point(188, 22); this.labelKernelTime.Name = "labelKernelTime"; - this.labelKernelTime.Size = new System.Drawing.Size(34, 13); + this.labelKernelTime.Size = new System.Drawing.Size(33, 13); this.labelKernelTime.TabIndex = 1; this.labelKernelTime.Text = "value"; // @@ -420,9 +428,9 @@ private void InitializeComponent() // this.labelUserTime.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelUserTime.AutoSize = true; - this.labelUserTime.Location = new System.Drawing.Point(187, 41); + this.labelUserTime.Location = new System.Drawing.Point(188, 41); this.labelUserTime.Name = "labelUserTime"; - this.labelUserTime.Size = new System.Drawing.Size(34, 13); + this.labelUserTime.Size = new System.Drawing.Size(33, 13); this.labelUserTime.TabIndex = 1; this.labelUserTime.Text = "value"; // @@ -430,9 +438,9 @@ private void InitializeComponent() // this.labelTotalTime.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelTotalTime.AutoSize = true; - this.labelTotalTime.Location = new System.Drawing.Point(187, 61); + this.labelTotalTime.Location = new System.Drawing.Point(188, 61); this.labelTotalTime.Name = "labelTotalTime"; - this.labelTotalTime.Size = new System.Drawing.Size(34, 13); + this.labelTotalTime.Size = new System.Drawing.Size(33, 13); this.labelTotalTime.TabIndex = 1; this.labelTotalTime.Text = "value"; // @@ -442,7 +450,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(227, 61); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(95, 13); + this.label1.Size = new System.Drawing.Size(89, 13); this.label1.TabIndex = 6; this.label1.Text = "Context Switches"; // @@ -452,7 +460,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(227, 41); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(70, 13); + this.label2.Size = new System.Drawing.Size(65, 13); this.label2.TabIndex = 2; this.label2.Text = "Base Priority"; // @@ -462,7 +470,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(227, 22); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(43, 13); + this.label3.Size = new System.Drawing.Size(38, 13); this.label3.TabIndex = 5; this.label3.Text = "Priority"; // @@ -470,9 +478,9 @@ private void InitializeComponent() // this.labelContextSwitches.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelContextSwitches.AutoSize = true; - this.labelContextSwitches.Location = new System.Drawing.Point(413, 61); + this.labelContextSwitches.Location = new System.Drawing.Point(414, 61); this.labelContextSwitches.Name = "labelContextSwitches"; - this.labelContextSwitches.Size = new System.Drawing.Size(34, 13); + this.labelContextSwitches.Size = new System.Drawing.Size(33, 13); this.labelContextSwitches.TabIndex = 7; this.labelContextSwitches.Text = "value"; // @@ -480,9 +488,9 @@ private void InitializeComponent() // this.labelBasePriority.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelBasePriority.AutoSize = true; - this.labelBasePriority.Location = new System.Drawing.Point(413, 41); + this.labelBasePriority.Location = new System.Drawing.Point(414, 41); this.labelBasePriority.Name = "labelBasePriority"; - this.labelBasePriority.Size = new System.Drawing.Size(34, 13); + this.labelBasePriority.Size = new System.Drawing.Size(33, 13); this.labelBasePriority.TabIndex = 4; this.labelBasePriority.Text = "value"; // @@ -490,9 +498,9 @@ private void InitializeComponent() // this.labelPriority.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelPriority.AutoSize = true; - this.labelPriority.Location = new System.Drawing.Point(413, 22); + this.labelPriority.Location = new System.Drawing.Point(414, 22); this.labelPriority.Name = "labelPriority"; - this.labelPriority.Size = new System.Drawing.Size(34, 13); + this.labelPriority.Size = new System.Drawing.Size(33, 13); this.labelPriority.TabIndex = 3; this.labelPriority.Text = "value"; // @@ -502,7 +510,7 @@ private void InitializeComponent() this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(3, 61); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(58, 13); + this.label10.Size = new System.Drawing.Size(57, 13); this.label10.TabIndex = 1; this.label10.Text = "Total Time"; // @@ -520,9 +528,9 @@ private void InitializeComponent() // this.labelTEBAddress.Anchor = System.Windows.Forms.AnchorStyles.Right; this.labelTEBAddress.AutoSize = true; - this.labelTEBAddress.Location = new System.Drawing.Point(413, 3); + this.labelTEBAddress.Location = new System.Drawing.Point(414, 3); this.labelTEBAddress.Name = "labelTEBAddress"; - this.labelTEBAddress.Size = new System.Drawing.Size(34, 13); + this.labelTEBAddress.Size = new System.Drawing.Size(33, 13); this.labelTEBAddress.TabIndex = 3; this.labelTEBAddress.Text = "value"; // @@ -532,14 +540,19 @@ private void InitializeComponent() this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(3, 356); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(77, 13); + this.label7.Size = new System.Drawing.Size(70, 13); this.label7.TabIndex = 5; this.label7.Text = "Start Module:"; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // fileModule // - this.fileModule.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.fileModule.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.fileModule.Location = new System.Drawing.Point(79, 351); this.fileModule.Name = "fileModule"; this.fileModule.ReadOnly = true; @@ -550,15 +563,16 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.fileModule); this.Controls.Add(this.label7); this.Controls.Add(this.tableInformation); this.Controls.Add(this.listThreads); + this.DoubleBuffered = true; this.Name = "ThreadList"; this.Size = new System.Drawing.Size(450, 460); this.tableInformation.ResumeLayout(false); this.tableInformation.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -566,10 +580,11 @@ private void InitializeComponent() #endregion - private ExtendedListView listThreads; + private System.Windows.Forms.ListView listThreads; private System.Windows.Forms.ColumnHeader columnThreadID; private System.Windows.Forms.ColumnHeader columnContextSwitchesDelta; private System.Windows.Forms.ColumnHeader columnStartAddress; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.ContextMenu menuThread; private System.Windows.Forms.MenuItem inspectThreadMenuItem; private System.Windows.Forms.MenuItem terminateThreadMenuItem; diff --git a/1.x/trunk/ProcessHacker/Components/ThreadList.cs b/1.x/trunk/ProcessHacker/Components/ThreadList.cs index 88c816297..08803545f 100644 --- a/1.x/trunk/ProcessHacker/Components/ThreadList.cs +++ b/1.x/trunk/ProcessHacker/Components/ThreadList.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Reflection; using System.Text; using System.Windows.Forms; using ProcessHacker.Common; @@ -40,11 +41,11 @@ namespace ProcessHacker.Components public partial class ThreadList : UserControl { private ThreadProvider _provider; - private bool _useCycleTime; - private int _runCount; - private readonly List _needsAdd = new List(); - private readonly HighlightingContext _highlightingContext; - private bool _needsSort; + private bool _useCycleTime = false; + private int _runCount = 0; + private List _needsAdd = new List(); + private HighlightingContext _highlightingContext; + private bool _needsSort = false; public new event KeyEventHandler KeyDown; public new event MouseEventHandler MouseDown; public new event MouseEventHandler MouseUp; @@ -71,16 +72,23 @@ public ThreadList() var comparer = (SortedListViewComparer) (listThreads.ListViewItemSorter = new SortedListViewComparer(listThreads)); - comparer.CustomSorters.Add(1, (x, y) => - { - if (OSVersion.HasCycleTime) + comparer.CustomSorters.Add(1, + (x, y) => { - return ((ThreadItem)x.Tag).CyclesDelta.CompareTo((y.Tag as ThreadItem).CyclesDelta); - } - - return ((ThreadItem)x.Tag).ContextSwitchesDelta.CompareTo((y.Tag as ThreadItem).ContextSwitchesDelta); - }); - comparer.CustomSorters.Add(3, (x, y) => ((ThreadItem)x.Tag).PriorityI.CompareTo((y.Tag as ThreadItem).PriorityI)); + if (OSVersion.HasCycleTime) + { + return (x.Tag as ThreadItem).CyclesDelta.CompareTo((y.Tag as ThreadItem).CyclesDelta); + } + else + { + return (x.Tag as ThreadItem).ContextSwitchesDelta.CompareTo((y.Tag as ThreadItem).ContextSwitchesDelta); + } + }); + comparer.CustomSorters.Add(3, + (x, y) => + { + return (x.Tag as ThreadItem).PriorityI.CompareTo((y.Tag as ThreadItem).PriorityI); + }); comparer.ColumnSortOrder.Add(0); comparer.ColumnSortOrder.Add(2); comparer.ColumnSortOrder.Add(3); @@ -88,15 +96,27 @@ public ThreadList() comparer.SortColumn = 1; comparer.SortOrder = SortOrder.Descending; - listThreads.KeyDown += this.ThreadList_KeyDown; - listThreads.MouseDown += this.listThreads_MouseDown; - listThreads.MouseUp += this.listThreads_MouseUp; - listThreads.SelectedIndexChanged += this.listThreads_SelectedIndexChanged; + listThreads.KeyDown += new KeyEventHandler(ThreadList_KeyDown); + listThreads.MouseDown += new MouseEventHandler(listThreads_MouseDown); + listThreads.MouseUp += new MouseEventHandler(listThreads_MouseUp); + listThreads.SelectedIndexChanged += new System.EventHandler(listThreads_SelectedIndexChanged); ColumnSettings.LoadSettings(Settings.Instance.ThreadListViewColumns, listThreads); listThreads.ContextMenu = menuThread; GenericViewMenu.AddMenuItems(copyThreadMenuItem.MenuItems, listThreads, null); listThreads_SelectedIndexChanged(null, null); + + _dontCalculate = false; + } + + private bool _dontCalculate = true; + + protected override void OnResize(EventArgs e) + { + if (_dontCalculate) + return; + + base.OnResize(e); } private void listThreads_MouseUp(object sender, MouseEventArgs e) @@ -166,16 +186,16 @@ private void listThreads_SelectedIndexChanged(object sender, System.EventArgs e) } else { - fileModule.Text = string.Empty; + fileModule.Text = ""; fileModule.Enabled = false; - labelState.Text = string.Empty; - labelKernelTime.Text = string.Empty; - labelUserTime.Text = string.Empty; - labelTotalTime.Text = string.Empty; - labelTEBAddress.Text = string.Empty; - labelPriority.Text = string.Empty; - labelBasePriority.Text = string.Empty; - labelContextSwitches.Text = string.Empty; + labelState.Text = ""; + labelKernelTime.Text = ""; + labelUserTime.Text = ""; + labelTotalTime.Text = ""; + labelTEBAddress.Text = ""; + labelPriority.Text = ""; + labelBasePriority.Text = ""; + labelContextSwitches.Text = ""; } if (this.SelectedIndexChanged != null) @@ -189,20 +209,33 @@ private void ThreadList_KeyDown(object sender, KeyEventArgs e) if (!e.Handled) { - switch (e.KeyCode) + if (e.KeyCode == Keys.Enter) + { + inspectThreadMenuItem_Click(null, null); + } + else if (e.KeyCode == Keys.Delete) { - case Keys.Enter: - this.inspectThreadMenuItem_Click(null, null); - break; - case Keys.Delete: - this.terminateThreadMenuItem_Click(null, null); - break; + terminateThreadMenuItem_Click(null, null); } } } #region Properties + public new bool DoubleBuffered + { + get + { + return (bool)typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).GetValue(listThreads, null); + } + set + { + typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance).SetValue(listThreads, value, null); + } + } + public override bool Focused { get @@ -223,7 +256,7 @@ public override ContextMenuStrip ContextMenuStrip set { listThreads.ContextMenuStrip = value; } } - public ExtendedListView List + public ListView List { get { return listThreads; } } @@ -237,11 +270,11 @@ public ThreadProvider Provider if (_provider != null) { - _provider.DictionaryAdded -= this.provider_DictionaryAdded; - _provider.DictionaryModified -= this.provider_DictionaryModified; - _provider.DictionaryRemoved -= this.provider_DictionaryRemoved; - _provider.Updated -= this.provider_Updated; - _provider.LoadingStateChanged -= this.provider_LoadingStateChanged; + _provider.DictionaryAdded -= new ThreadProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryModified -= new ThreadProvider.ProviderDictionaryModified(provider_DictionaryModified); + _provider.DictionaryRemoved -= new ThreadProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated -= new ThreadProvider.ProviderUpdateOnce(provider_Updated); + _provider.LoadingStateChanged -= new ThreadProvider.LoadingStateChangedDelegate(provider_LoadingStateChanged); } _provider = value; @@ -273,11 +306,11 @@ public ThreadProvider Provider else listThreads.Columns[1].Text = "Context Switches Delta"; - _provider.DictionaryAdded += this.provider_DictionaryAdded; - _provider.DictionaryModified += this.provider_DictionaryModified; - _provider.DictionaryRemoved += this.provider_DictionaryRemoved; - _provider.Updated += this.provider_Updated; - _provider.LoadingStateChanged += this.provider_LoadingStateChanged; + _provider.DictionaryAdded += new ThreadProvider.ProviderDictionaryAdded(provider_DictionaryAdded); + _provider.DictionaryModified += new ThreadProvider.ProviderDictionaryModified(provider_DictionaryModified); + _provider.DictionaryRemoved += new ThreadProvider.ProviderDictionaryRemoved(provider_DictionaryRemoved); + _provider.Updated += new ThreadProvider.ProviderUpdateOnce(provider_Updated); + _provider.LoadingStateChanged += new ThreadProvider.LoadingStateChangedDelegate(provider_LoadingStateChanged); this.EnableDisableMenuItems(); } @@ -335,13 +368,13 @@ private void provider_Updated() if (_needsSort) { this.BeginInvoke(new MethodInvoker(() => - { - if (_needsSort) { - listThreads.Sort(); - _needsSort = false; - } - })); + if (_needsSort) + { + listThreads.Sort(); + _needsSort = false; + } + })); } _runCount++; @@ -351,7 +384,7 @@ private void EnableDisableMenuItems() { if ( // If KProcessHacker isn't available, hide Force Terminate. - //KProcessHacker.Instance != null && + KProcessHacker.Instance != null && // Terminating a system thread is the same as Force Terminate, // so hide it if we're viewing PID 4. _pid != 4 @@ -365,8 +398,7 @@ private System.Drawing.Color GetThreadColor(ThreadItem titem) { if (Settings.Instance.UseColorSuspended && titem.WaitReason == KWaitReason.Suspended) return Settings.Instance.ColorSuspended; - - if (Settings.Instance.UseColorGuiThreads && titem.IsGuiThread) + else if (Settings.Instance.UseColorGuiThreads && titem.IsGuiThread) return Settings.Instance.ColorGuiThreads; return System.Drawing.SystemColors.Window; @@ -374,13 +406,12 @@ private System.Drawing.Color GetThreadColor(ThreadItem titem) private void provider_DictionaryAdded(ThreadItem item) { - HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, item.RunId > 0 && _runCount > 0) - { - Name = item.Tid.ToString(), - Text = item.Tid.ToString() - }; + HighlightedListViewItem litem = new HighlightedListViewItem(_highlightingContext, + item.RunId > 0 && _runCount > 0); - litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, string.Empty)); + litem.Name = item.Tid.ToString(); + litem.Text = item.Tid.ToString(); + litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, "")); litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.StartAddress)); litem.SubItems.Add(new ListViewItem.ListViewSubItem(litem, item.Priority)); litem.Tag = item; @@ -393,60 +424,60 @@ private void provider_DictionaryAdded(ThreadItem item) private void provider_DictionaryModified(ThreadItem oldItem, ThreadItem newItem) { this.BeginInvoke(new MethodInvoker(() => - { - lock (listThreads) { - ListViewItem litem = listThreads.Items[newItem.Tid.ToString()]; + lock (listThreads) + { + ListViewItem litem = listThreads.Items[newItem.Tid.ToString()]; - if (litem == null) - return; + if (litem == null) + return; - if (!_useCycleTime) - { - if (newItem.ContextSwitchesDelta == 0) - litem.SubItems[1].Text = string.Empty; - else - litem.SubItems[1].Text = newItem.ContextSwitchesDelta.ToString("N0"); - } - else - { - if (newItem.CyclesDelta == 0) - litem.SubItems[1].Text = string.Empty; + if (!_useCycleTime) + { + if (newItem.ContextSwitchesDelta == 0) + litem.SubItems[1].Text = ""; + else + litem.SubItems[1].Text = newItem.ContextSwitchesDelta.ToString("N0"); + } else - litem.SubItems[1].Text = newItem.CyclesDelta.ToString("N0"); - } + { + if (newItem.CyclesDelta == 0) + litem.SubItems[1].Text = ""; + else + litem.SubItems[1].Text = newItem.CyclesDelta.ToString("N0"); + } - litem.SubItems[2].Text = newItem.StartAddress; - litem.SubItems[3].Text = newItem.Priority; - litem.Tag = newItem; + litem.SubItems[2].Text = newItem.StartAddress; + litem.SubItems[3].Text = newItem.Priority; + litem.Tag = newItem; - (litem as HighlightedListViewItem).NormalColor = GetThreadColor(newItem); - _needsSort = true; - } - })); + (litem as HighlightedListViewItem).NormalColor = GetThreadColor(newItem); + _needsSort = true; + } + })); } private void provider_DictionaryRemoved(ThreadItem item) { this.BeginInvoke(new MethodInvoker(() => - { - lock (listThreads) { - if (listThreads.Items.ContainsKey(item.Tid.ToString())) - listThreads.Items[item.Tid.ToString()].Remove(); - } - })); + lock (listThreads) + { + if (listThreads.Items.ContainsKey(item.Tid.ToString())) + listThreads.Items[item.Tid.ToString()].Remove(); + } + })); } private void provider_LoadingStateChanged(bool loading) { this.BeginInvoke(new MethodInvoker(() => - { - if (loading) - listThreads.Cursor = Cursors.AppStarting; - else - listThreads.Cursor = Cursors.Default; - })); + { + if (loading) + listThreads.Cursor = Cursors.AppStarting; + else + listThreads.Cursor = Cursors.Default; + })); } public void SaveSettings() @@ -460,7 +491,7 @@ private void SetThreadPriority(ThreadPriorityLevel priority) { int tid = int.Parse(listThreads.SelectedItems[0].SubItems[0].Text); - using (ThreadHandle thandle = new ThreadHandle(tid, OSVersion.MinThreadSetInfoAccess)) + using (var thandle = new ThreadHandle(tid, OSVersion.MinThreadSetInfoAccess)) thandle.SetBasePriorityWin32(priority); } catch (Exception ex) @@ -475,7 +506,7 @@ private void SetThreadIoPriority(int ioPriority) { int tid = int.Parse(listThreads.SelectedItems[0].SubItems[0].Text); - using (ThreadHandle thandle = new ThreadHandle(tid, OSVersion.MinThreadSetInfoAccess)) + using (var thandle = new ThreadHandle(tid, OSVersion.MinThreadSetInfoAccess)) thandle.SetIoPriority(ioPriority); } catch (Exception ex) @@ -491,120 +522,136 @@ private void listThreads_DoubleClick(object sender, EventArgs e) private void menuThread_Popup(object sender, EventArgs e) { - switch (this.listThreads.SelectedItems.Count) + if (listThreads.SelectedItems.Count == 0) { - case 0: - return; - case 1: - this.menuThread.EnableAll(); - this.terminateThreadMenuItem.Text = "&Terminate Thread"; - this.forceTerminateThreadMenuItem.Text = "Force Terminate Thread"; - this.suspendThreadMenuItem.Text = "&Suspend Thread"; - this.resumeThreadMenuItem.Text = "&Resume Thread"; - this.priorityThreadMenuItem.Text = "&Priority"; - this.timeCriticalThreadMenuItem.Checked = false; - this.highestThreadMenuItem.Checked = false; - this.aboveNormalThreadMenuItem.Checked = false; - this.normalThreadMenuItem.Checked = false; - this.belowNormalThreadMenuItem.Checked = false; - this.lowestThreadMenuItem.Checked = false; - this.idleThreadMenuItem.Checked = false; - this.ioPriority0ThreadMenuItem.Checked = false; - this.ioPriority1ThreadMenuItem.Checked = false; - this.ioPriority2ThreadMenuItem.Checked = false; - this.ioPriority3ThreadMenuItem.Checked = false; - try + menuThread.DisableAll(); + + return; + } + else if (listThreads.SelectedItems.Count == 1) + { + menuThread.EnableAll(); + + terminateThreadMenuItem.Text = "&Terminate Thread"; + forceTerminateThreadMenuItem.Text = "Force Terminate Thread"; + suspendThreadMenuItem.Text = "&Suspend Thread"; + resumeThreadMenuItem.Text = "&Resume Thread"; + priorityThreadMenuItem.Text = "&Priority"; + + timeCriticalThreadMenuItem.Checked = false; + highestThreadMenuItem.Checked = false; + aboveNormalThreadMenuItem.Checked = false; + normalThreadMenuItem.Checked = false; + belowNormalThreadMenuItem.Checked = false; + lowestThreadMenuItem.Checked = false; + idleThreadMenuItem.Checked = false; + + ioPriority0ThreadMenuItem.Checked = false; + ioPriority1ThreadMenuItem.Checked = false; + ioPriority2ThreadMenuItem.Checked = false; + ioPriority3ThreadMenuItem.Checked = false; + + try + { + using (var thandle = new ThreadHandle( + int.Parse(listThreads.SelectedItems[0].SubItems[0].Text), + Program.MinThreadQueryRights)) { - using (var thandle = new ThreadHandle(int.Parse(this.listThreads.SelectedItems[0].SubItems[0].Text), Program.MinThreadQueryRights)) + try { - try + switch (thandle.GetBasePriorityWin32()) + { + case ThreadPriorityLevel.TimeCritical: + timeCriticalThreadMenuItem.Checked = true; + break; + case ThreadPriorityLevel.Highest: + highestThreadMenuItem.Checked = true; + break; + case ThreadPriorityLevel.AboveNormal: + aboveNormalThreadMenuItem.Checked = true; + break; + case ThreadPriorityLevel.Normal: + normalThreadMenuItem.Checked = true; + break; + case ThreadPriorityLevel.BelowNormal: + belowNormalThreadMenuItem.Checked = true; + break; + case ThreadPriorityLevel.Lowest: + lowestThreadMenuItem.Checked = true; + break; + case ThreadPriorityLevel.Idle: + idleThreadMenuItem.Checked = true; + break; + } + } + catch + { + priorityThreadMenuItem.Enabled = false; + } + + try + { + if (OSVersion.HasIoPriority) { - switch (thandle.GetBasePriorityWin32()) + switch (thandle.GetIoPriority()) { - case ThreadPriorityLevel.TimeCritical: - this.timeCriticalThreadMenuItem.Checked = true; - break; - case ThreadPriorityLevel.Highest: - this.highestThreadMenuItem.Checked = true; - break; - case ThreadPriorityLevel.AboveNormal: - this.aboveNormalThreadMenuItem.Checked = true; - break; - case ThreadPriorityLevel.Normal: - this.normalThreadMenuItem.Checked = true; + case 0: + ioPriority0ThreadMenuItem.Checked = true; break; - case ThreadPriorityLevel.BelowNormal: - this.belowNormalThreadMenuItem.Checked = true; + case 1: + ioPriority1ThreadMenuItem.Checked = true; break; - case ThreadPriorityLevel.Lowest: - this.lowestThreadMenuItem.Checked = true; + case 2: + ioPriority2ThreadMenuItem.Checked = true; break; - case ThreadPriorityLevel.Idle: - this.idleThreadMenuItem.Checked = true; + case 3: + ioPriority3ThreadMenuItem.Checked = true; break; } } - catch - { - this.priorityThreadMenuItem.Enabled = false; - } - - try - { - if (OSVersion.HasIoPriority) - { - switch (thandle.GetIoPriority()) - { - case 0: - this.ioPriority0ThreadMenuItem.Checked = true; - break; - case 1: - this.ioPriority1ThreadMenuItem.Checked = true; - break; - case 2: - this.ioPriority2ThreadMenuItem.Checked = true; - break; - case 3: - this.ioPriority3ThreadMenuItem.Checked = true; - break; - } - } - } - catch - { - this.ioPriorityThreadMenuItem.Enabled = false; - } + } + catch + { + ioPriorityThreadMenuItem.Enabled = false; } } - catch - { - this.priorityThreadMenuItem.Enabled = false; - this.ioPriorityThreadMenuItem.Enabled = false; - } - try + } + catch + { + priorityThreadMenuItem.Enabled = false; + ioPriorityThreadMenuItem.Enabled = false; + } + + try + { + using (ThreadHandle thandle = new ThreadHandle( + int.Parse(listThreads.SelectedItems[0].Text), Program.MinThreadQueryRights + )) { - using (ThreadHandle thandle = new ThreadHandle(int.Parse(this.listThreads.SelectedItems[0].Text), Program.MinThreadQueryRights)) using (TokenHandle tokenHandle = thandle.GetToken(TokenAccess.Query)) { - this.tokenThreadMenuItem.Enabled = true; + tokenThreadMenuItem.Enabled = true; } } - catch (WindowsException) - { - this.tokenThreadMenuItem.Enabled = false; - } - break; - default: - this.terminateThreadMenuItem.Enabled = true; - this.forceTerminateThreadMenuItem.Enabled = true; - this.suspendThreadMenuItem.Enabled = true; - this.resumeThreadMenuItem.Enabled = true; - this.terminateThreadMenuItem.Text = "&Terminate Threads"; - this.forceTerminateThreadMenuItem.Text = "Force Terminate Threads"; - this.suspendThreadMenuItem.Text = "&Suspend Threads"; - this.resumeThreadMenuItem.Text = "&Resume Threads"; - this.copyThreadMenuItem.Enabled = true; - break; + } + catch (WindowsException) + { + tokenThreadMenuItem.Enabled = false; + } + } + else + { + menuThread.DisableAll(); + + terminateThreadMenuItem.Enabled = true; + forceTerminateThreadMenuItem.Enabled = true; + suspendThreadMenuItem.Enabled = true; + resumeThreadMenuItem.Enabled = true; + terminateThreadMenuItem.Text = "&Terminate Threads"; + forceTerminateThreadMenuItem.Text = "Force Terminate Threads"; + suspendThreadMenuItem.Text = "&Suspend Threads"; + resumeThreadMenuItem.Text = "&Resume Threads"; + copyThreadMenuItem.Enabled = true; } if (listThreads.Items.Count == 0) @@ -623,7 +670,10 @@ private void inspectThreadMenuItem_Click(object sender, EventArgs e) return; // Can't view system thread stacks if KPH isn't present. - if (_pid == 4) + if ( + _pid == 4 && + KProcessHacker.Instance == null + ) { PhUtils.ShowError( "Process Hacker cannot view system thread stacks without KProcessHacker. " + @@ -635,7 +685,7 @@ private void inspectThreadMenuItem_Click(object sender, EventArgs e) } // Suspending PH threads is not a good idea :( - if (_pid == ProcessHandle.CurrentId) + if (_pid == ProcessHandle.GetCurrentId()) { if (!PhUtils.ShowConfirmMessage( "inspect", @@ -651,10 +701,18 @@ private void inspectThreadMenuItem_Click(object sender, EventArgs e) ProcessHandle phandle = null; // If we have KPH, we don't need much access. - if ((_provider.ProcessAccess & ProcessAccess.QueryLimitedInformation) != 0 || - (_provider.ProcessAccess & ProcessAccess.QueryInformation) != 0) - phandle = _provider.ProcessHandle; - + if (KProcessHacker.Instance != null) + { + if ((_provider.ProcessAccess & ProcessAccess.QueryLimitedInformation) != 0 || + (_provider.ProcessAccess & ProcessAccess.QueryInformation) != 0) + phandle = _provider.ProcessHandle; + } + else + { + if ((_provider.ProcessAccess & (ProcessAccess.QueryInformation | ProcessAccess.VmRead)) != 0) + phandle = _provider.ProcessHandle; + } + // If we have KPH load kernel modules so we can get the kernel-mode stack. try { @@ -684,7 +742,7 @@ private void terminateThreadMenuItem_Click(object sender, EventArgs e) // Special case for system threads. if ( - // KProcessHacker.Instance != null && + KProcessHacker.Instance != null && _pid == 4 ) { @@ -723,19 +781,21 @@ private void terminateThreadMenuItem_Click(object sender, EventArgs e) return; if (Program.ElevationType == TokenElevationType.Limited && + KProcessHacker.Instance == null && Settings.Instance.ElevationLevel != (int)ElevationLevel.Never) { try { foreach (ListViewItem item in listThreads.SelectedItems) { - using (var thandle = new ThreadHandle(int.Parse(item.SubItems[0].Text), ThreadAccess.Terminate)) + using (var thandle = new ThreadHandle(int.Parse(item.SubItems[0].Text), + ThreadAccess.Terminate)) { } } } catch { - string objects = string.Empty; + string objects = ""; foreach (ListViewItem item in listThreads.SelectedItems) objects += item.SubItems[0].Text + ","; @@ -808,24 +868,28 @@ private void suspendThreadMenuItem_Click(object sender, EventArgs e) // return; //} - if (Program.ElevationType == TokenElevationType.Limited && Settings.Instance.ElevationLevel != (int)ElevationLevel.Never) + if (Program.ElevationType == TokenElevationType.Limited && + KProcessHacker.Instance == null && + Settings.Instance.ElevationLevel != (int)ElevationLevel.Never) { try { foreach (ListViewItem item in listThreads.SelectedItems) { - using (var thandle = new ThreadHandle(int.Parse(item.SubItems[0].Text), ThreadAccess.SuspendResume)) + using (var thandle = new ThreadHandle(int.Parse(item.SubItems[0].Text), + ThreadAccess.SuspendResume)) { } } } catch { - string objects = string.Empty; + string objects = ""; foreach (ListViewItem item in listThreads.SelectedItems) objects += item.SubItems[0].Text + ","; - Program.StartProcessHackerAdmin("-e -type thread -action suspend -obj \"" + objects + "\" -hwnd " + this.Handle.ToString(), null, this.Handle); + Program.StartProcessHackerAdmin("-e -type thread -action suspend -obj \"" + + objects + "\" -hwnd " + this.Handle.ToString(), null, this.Handle); return; } @@ -835,7 +899,8 @@ private void suspendThreadMenuItem_Click(object sender, EventArgs e) { try { - using (var thandle = new ThreadHandle(Int32.Parse(item.SubItems[0].Text), ThreadAccess.SuspendResume)) + using (var thandle = new ThreadHandle(Int32.Parse(item.SubItems[0].Text), + ThreadAccess.SuspendResume)) thandle.Suspend(); } catch (Exception ex) @@ -861,7 +926,9 @@ private void resumeThreadMenuItem_Click(object sender, EventArgs e) // return; //} - if (Program.ElevationType == TokenElevationType.Limited && Settings.Instance.ElevationLevel != (int)ElevationLevel.Never) + if (Program.ElevationType == TokenElevationType.Limited && + KProcessHacker.Instance == null && + Settings.Instance.ElevationLevel != (int)ElevationLevel.Never) { try { @@ -874,7 +941,7 @@ private void resumeThreadMenuItem_Click(object sender, EventArgs e) } catch { - string objects = string.Empty; + string objects = ""; foreach (ListViewItem item in listThreads.SelectedItems) objects += item.SubItems[0].Text + ","; @@ -889,7 +956,8 @@ private void resumeThreadMenuItem_Click(object sender, EventArgs e) { try { - using (ThreadHandle thandle = new ThreadHandle(Int32.Parse(item.SubItems[0].Text), ThreadAccess.SuspendResume)) + using (var thandle = new ThreadHandle(Int32.Parse(item.SubItems[0].Text), + ThreadAccess.SuspendResume)) thandle.Resume(); } catch (Exception ex) @@ -917,12 +985,20 @@ private void inspectTEBMenuItem_Click(object sender, EventArgs e) { IntPtr tebBaseAddress = thandle.GetBasicInformation().TebBaseAddress; - Program.HackerWindow.BeginInvoke(new MethodInvoker(() => - { - StructWindow sw = new StructWindow(this._pid, tebBaseAddress, Program.Structs["TEB"]); - sw.Show(); - sw.Activate(); - })); + Program.HackerWindow.BeginInvoke(new MethodInvoker(delegate + { + StructWindow sw = new StructWindow(_pid, tebBaseAddress, Program.Structs["TEB"]); + + try + { + sw.Show(); + sw.Activate(); + } + catch (Exception ex) + { + Logging.Log(ex); + } + })); } } catch (Exception ex) @@ -938,7 +1014,7 @@ private void permissionsThreadMenuItem_Click(object sender, EventArgs e) SecurityEditor.EditSecurity( this, SecurityEditor.GetSecurableWrapper( - access => new ThreadHandle(int.Parse(listThreads.SelectedItems[0].Text), (ThreadAccess)access) + (access) => new ThreadHandle(int.Parse(listThreads.SelectedItems[0].Text), (ThreadAccess)access) ), "Thread " + listThreads.SelectedItems[0].Text, NativeTypeFactory.GetAccessEntries(NativeTypeFactory.ObjectType.Thread) @@ -954,13 +1030,18 @@ private void tokenThreadMenuItem_Click(object sender, EventArgs e) { try { - using (ThreadHandle thandle = new ThreadHandle(int.Parse(listThreads.SelectedItems[0].Text), Program.MinThreadQueryRights)) - using (TokenWindow tokForm = new TokenWindow(thandle)) + using (ThreadHandle thandle = new ThreadHandle( + int.Parse(listThreads.SelectedItems[0].Text), Program.MinThreadQueryRights + )) { + TokenWindow tokForm = new TokenWindow(thandle); + tokForm.Text = "Thread Token"; tokForm.ShowDialog(); } } + catch (ObjectDisposedException) + { } catch (Exception ex) { PhUtils.ShowException("Unable to view the thread token", ex); @@ -1006,287 +1087,287 @@ private unsafe void analyzeWaitMenuItem_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); int tid = int.Parse(listThreads.SelectedItems[0].SubItems[0].Text); - ProcessHandle phandle; + ProcessHandle phandle = null; if ((_provider.ProcessAccess & (ProcessAccess.QueryInformation | ProcessAccess.VmRead)) != 0) phandle = _provider.ProcessHandle; else phandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | ProcessAccess.VmRead); - //ProcessHandle processDupHandle = new ProcessHandle(_pid, ProcessAccess.DupHandle); + ProcessHandle processDupHandle = new ProcessHandle(_pid, ProcessAccess.DupHandle); bool found = false; - using (ThreadHandle thandle = new ThreadHandle(tid, ThreadAccess.GetContext | ThreadAccess.SuspendResume)) + using (var thandle = new ThreadHandle(tid, ThreadAccess.GetContext | ThreadAccess.SuspendResume)) { IntPtr[] lastParams = new IntPtr[4]; - thandle.WalkStack(phandle, stackFrame => - { - uint address = stackFrame.PcAddress.ToUInt32(); - string name = _provider.Symbols.GetSymbolFromAddress(address).ToLowerInvariant(); - - if (string.IsNullOrEmpty(name)) + thandle.WalkStack(phandle, (stackFrame) => { - // dummy - } - else if ( - name.StartsWith("kernel32.dll!sleep", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; - - sb.Append("Thread is sleeping. Timeout: " + - stackFrame.Params[0].ToInt32().ToString() + " milliseconds"); - } - else if ( - name.StartsWith("ntdll.dll!zwdelayexecution", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntdelayexecution", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; - - //bool alertable = stackFrame.Params[0].ToInt32() != 0; - IntPtr timeoutAddress = stackFrame.Params[1]; - long timeout; - - phandle.ReadMemory(timeoutAddress, &timeout, sizeof(long)); + uint address = stackFrame.PcAddress.ToUInt32(); + string name = _provider.Symbols.GetSymbolFromAddress(address).ToLowerInvariant(); - if (timeout < 0) + if (name == null) { - sb.Append("Thread is sleeping. Timeout: " + - (new TimeSpan(-timeout)).TotalMilliseconds.ToString() + " milliseconds"); + // dummy } - else + else if ( + name.StartsWith("kernel32.dll!sleep") + ) { - sb.AppendLine("Thread is sleeping. Timeout: " + (new DateTime(timeout)).ToString()); + found = true; + + sb.Append("Thread is sleeping. Timeout: " + + stackFrame.Params[0].ToInt32().ToString() + " milliseconds"); } - } - else if ( - name.StartsWith("ntdll.dll!zwdeviceiocontrolfile", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntdeviceiocontrolfile", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + else if ( + name.StartsWith("ntdll.dll!zwdelayexecution") || + name.StartsWith("ntdll.dll!ntdelayexecution") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; + bool alertable = stackFrame.Params[0].ToInt32() != 0; + IntPtr timeoutAddress = stackFrame.Params[1]; + long timeout; - sb.AppendLine("Thread " + tid.ToString() + " is waiting for an I/O control request:"); + phandle.ReadMemory(timeoutAddress, &timeout, sizeof(long)); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!ntfscontrolfile", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwfscontrolfile", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + if (timeout < 0) + { + sb.Append("Thread is sleeping. Timeout: " + + (new TimeSpan(-timeout)).TotalMilliseconds.ToString() + " milliseconds"); + } + else + { + sb.AppendLine("Thread is sleeping. Timeout: " + (new DateTime(timeout)).ToString()); + } + } + else if ( + name.StartsWith("ntdll.dll!zwdeviceiocontrolfile") || + name.StartsWith("ntdll.dll!ntdeviceiocontrolfile") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; + IntPtr handle = stackFrame.Params[0]; - sb.AppendLine("Thread " + tid.ToString() + " is waiting for an FS control request:"); + sb.AppendLine("Thread " + tid.ToString() + " is waiting for an I/O control request:"); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!ntqueryobject", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwqueryobject", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("ntdll.dll!ntfscontrolfile") || + name.StartsWith("ntdll.dll!zwfscontrolfile") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; + IntPtr handle = stackFrame.Params[0]; - // Use the KiFastSystemCallRet args if the handle we have is wrong. - if (handle.ToInt32() % 2 != 0 || handle == IntPtr.Zero) - handle = lastParams[1]; + sb.AppendLine("Thread " + tid.ToString() + " is waiting for an FS control request:"); - sb.AppendLine("Thread " + tid.ToString() + " is querying an object (most likely a named pipe):"); + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("ntdll.dll!ntqueryobject") || + name.StartsWith("ntdll.dll!zwqueryobject") + ) + { + found = true; - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!zwreadfile", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntreadfile", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwwritefile", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwritefile", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + IntPtr handle = stackFrame.Params[0]; - IntPtr handle = stackFrame.Params[0]; + // Use the KiFastSystemCallRet args if the handle we have is wrong. + if (handle.ToInt32() % 2 != 0 || handle == IntPtr.Zero) + handle = lastParams[1]; - sb.AppendLine("Thread " + tid.ToString() + " is waiting for a named pipe or a file:"); + sb.AppendLine("Thread " + tid.ToString() + " is querying an object (most likely a named pipe):"); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!zwremoveiocompletion", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntremoveiocompletion", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("ntdll.dll!zwreadfile") || + name.StartsWith("ntdll.dll!ntreadfile") || + name.StartsWith("ntdll.dll!zwwritefile") || + name.StartsWith("ntdll.dll!ntwritefile") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; + IntPtr handle = stackFrame.Params[0]; - sb.AppendLine("Thread " + tid.ToString() + " is waiting for an I/O completion object:"); + sb.AppendLine("Thread " + tid.ToString() + " is waiting for a named pipe or a file:"); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!zwreplywaitreceiveport", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntreplywaitreceiveport", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwrequestwaitreplyport", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntrequestwaitreplyport", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwalpcsendwaitreceiveport", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntalpcsendwaitreceiveport", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("ntdll.dll!zwremoveiocompletion") || + name.StartsWith("ntdll.dll!ntremoveiocompletion") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; + IntPtr handle = stackFrame.Params[0]; - sb.AppendLine("Thread " + tid.ToString() + " is waiting for a LPC port:"); + sb.AppendLine("Thread " + tid.ToString() + " is waiting for an I/O completion object:"); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if - ( - name.StartsWith("ntdll.dll!zwsethighwaitloweventpair", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntsethighwaitloweventpair", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwsetlowwaithigheventpair", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntsetlowwaithigheventpair", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwwaithigheventpair", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwaithigheventpair", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwwaitloweventpair", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwaitloweventpair", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("ntdll.dll!zwreplywaitreceiveport") || + name.StartsWith("ntdll.dll!ntreplywaitreceiveport") || + name.StartsWith("ntdll.dll!zwrequestwaitreplyport") || + name.StartsWith("ntdll.dll!ntrequestwaitreplyport") || + name.StartsWith("ntdll.dll!zwalpcsendwaitreceiveport") || + name.StartsWith("ntdll.dll!ntalpcsendwaitreceiveport") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; + IntPtr handle = stackFrame.Params[0]; - // Use the KiFastSystemCallRet args if the handle we have is wrong. - if (handle.ToInt32() % 2 != 0) - handle = lastParams[1]; + sb.AppendLine("Thread " + tid.ToString() + " is waiting for a LPC port:"); - sb.AppendLine("Thread " + tid.ToString() + " is waiting (" + name + ") for an event pair:"); + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if + ( + name.StartsWith("ntdll.dll!zwsethighwaitloweventpair") || + name.StartsWith("ntdll.dll!ntsethighwaitloweventpair") || + name.StartsWith("ntdll.dll!zwsetlowwaithigheventpair") || + name.StartsWith("ntdll.dll!ntsetlowwaithigheventpair") || + name.StartsWith("ntdll.dll!zwwaithigheventpair") || + name.StartsWith("ntdll.dll!ntwaithigheventpair") || + name.StartsWith("ntdll.dll!zwwaitloweventpair") || + name.StartsWith("ntdll.dll!ntwaitloweventpair") + ) + { + found = true; - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("user32.dll!ntusergetmessage", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("user32.dll!ntuserwaitmessage", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + IntPtr handle = stackFrame.Params[0]; - sb.AppendLine("Thread " + tid.ToString() + " is waiting for a USER message."); - } - else if ( - name.StartsWith("ntdll.dll!zwwaitfordebugevent", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwaitfordebugevent", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + // Use the KiFastSystemCallRet args if the handle we have is wrong. + if (handle.ToInt32() % 2 != 0) + handle = lastParams[1]; - IntPtr handle = stackFrame.Params[0]; + sb.AppendLine("Thread " + tid.ToString() + " is waiting (" + name + ") for an event pair:"); - sb.AppendLine("Thread " + tid.ToString() + " is waiting for a debug event:"); + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("user32.dll!ntusergetmessage") || + name.StartsWith("user32.dll!ntuserwaitmessage") + ) + { + found = true; - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!zwwaitforkeyedevent", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwaitforkeyedevent", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!zwreleasekeyedevent", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntreleasekeyedevent", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + sb.AppendLine("Thread " + tid.ToString() + " is waiting for a USER message."); + } + else if ( + name.StartsWith("ntdll.dll!zwwaitfordebugevent") || + name.StartsWith("ntdll.dll!ntwaitfordebugevent") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; - IntPtr key = stackFrame.Params[1]; + IntPtr handle = stackFrame.Params[0]; - sb.AppendLine("Thread " + tid.ToString() + - " is waiting (" + name + ") for a keyed event (key 0x" + - key.ToString("x") + "):"); + sb.AppendLine("Thread " + tid.ToString() + " is waiting for a debug event:"); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!zwwaitformultipleobjects", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwaitformultipleobjects", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("kernel32.dll!waitformultipleobjects", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("ntdll.dll!zwwaitforkeyedevent") || + name.StartsWith("ntdll.dll!ntwaitforkeyedevent") || + name.StartsWith("ntdll.dll!zwreleasekeyedevent") || + name.StartsWith("ntdll.dll!ntreleasekeyedevent") + ) + { + found = true; - int handleCount = stackFrame.Params[0].ToInt32(); - IntPtr handleAddress = stackFrame.Params[1]; - WaitType waitType = (WaitType)stackFrame.Params[2].ToInt32(); - bool alertable = stackFrame.Params[3].ToInt32() != 0; + IntPtr handle = stackFrame.Params[0]; + IntPtr key = stackFrame.Params[1]; - // use the KiFastSystemCallRet args if we have the wrong args - if (handleCount > 64) - { - handleCount = lastParams[1].ToInt32(); - handleAddress = lastParams[2]; - waitType = (WaitType)lastParams[3].ToInt32(); + sb.AppendLine("Thread " + tid.ToString() + + " is waiting (" + name + ") for a keyed event (key 0x" + + key.ToString("x") + "):"); + + sb.AppendLine(this.GetHandleString(_pid, handle)); } + else if ( + name.StartsWith("ntdll.dll!zwwaitformultipleobjects") || + name.StartsWith("ntdll.dll!ntwaitformultipleobjects") || + name.StartsWith("kernel32.dll!waitformultipleobjects") + ) + { + found = true; - IntPtr* handles = stackalloc IntPtr[handleCount]; + int handleCount = stackFrame.Params[0].ToInt32(); + IntPtr handleAddress = stackFrame.Params[1]; + WaitType waitType = (WaitType)stackFrame.Params[2].ToInt32(); + bool alertable = stackFrame.Params[3].ToInt32() != 0; - phandle.ReadMemory(handleAddress, handles, handleCount * IntPtr.Size); + // use the KiFastSystemCallRet args if we have the wrong args + if (handleCount > 64) + { + handleCount = lastParams[1].ToInt32(); + handleAddress = lastParams[2]; + waitType = (WaitType)lastParams[3].ToInt32(); + } - sb.AppendLine("Thread " + tid.ToString() + - " is waiting (alertable: " + alertable.ToString() + ", wait type: " + - waitType.ToString() + ") for:"); + IntPtr* handles = stackalloc IntPtr[handleCount]; - for (int i = 0; i < handleCount; i++) - { - sb.AppendLine(this.GetHandleString(_pid, handles[i])); + phandle.ReadMemory(handleAddress, handles, handleCount * IntPtr.Size); + + sb.AppendLine("Thread " + tid.ToString() + + " is waiting (alertable: " + alertable.ToString() + ", wait type: " + + waitType.ToString() + ") for:"); + + for (int i = 0; i < handleCount; i++) + { + sb.AppendLine(this.GetHandleString(_pid, handles[i])); + } } - } - else if ( - name.StartsWith("ntdll.dll!zwwaitforsingleobject", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwaitforsingleobject", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("kernel32.dll!waitforsingleobject", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + else if ( + name.StartsWith("ntdll.dll!zwwaitforsingleobject") || + name.StartsWith("ntdll.dll!ntwaitforsingleobject") || + name.StartsWith("kernel32.dll!waitforsingleobject") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; - bool alertable = stackFrame.Params[1].ToInt32() != 0; + IntPtr handle = stackFrame.Params[0]; + bool alertable = stackFrame.Params[1].ToInt32() != 0; - sb.AppendLine("Thread " + tid.ToString() + - " is waiting (alertable: " + alertable.ToString() + ") for:"); + sb.AppendLine("Thread " + tid.ToString() + + " is waiting (alertable: " + alertable.ToString() + ") for:"); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } - else if ( - name.StartsWith("ntdll.dll!zwwaitforworkviaworkerfactory", StringComparison.OrdinalIgnoreCase) || - name.StartsWith("ntdll.dll!ntwaitforworkviaworkerfactory", StringComparison.OrdinalIgnoreCase) - ) - { - found = true; + sb.AppendLine(this.GetHandleString(_pid, handle)); + } + else if ( + name.StartsWith("ntdll.dll!zwwaitforworkviaworkerfactory") || + name.StartsWith("ntdll.dll!ntwaitforworkviaworkerfactory") + ) + { + found = true; - IntPtr handle = stackFrame.Params[0]; + IntPtr handle = stackFrame.Params[0]; - sb.AppendLine("Thread " + tid.ToString() + " is waiting for work from a worker factory:"); + sb.AppendLine("Thread " + tid.ToString() + " is waiting for work from a worker factory:"); - sb.AppendLine(this.GetHandleString(_pid, handle)); - } + sb.AppendLine(this.GetHandleString(_pid, handle)); + } - lastParams = stackFrame.Params; + lastParams = stackFrame.Params; - return !found; - }); + return !found; + }); } if (found) { - new InformationBox(sb.ToString()).ShowDialog(); + ScratchpadWindow.Create(sb.ToString()); } else { @@ -1366,7 +1447,7 @@ private void ioPriority3ThreadMenuItem_Click(object sender, EventArgs e) private void selectAllThreadMenuItem_Click(object sender, EventArgs e) { - this.listThreads.Items.SelectAll(); + Utils.SelectAll(listThreads.Items); } } } diff --git a/1.x/trunk/ProcessHacker/Components/ThreadList.resx b/1.x/trunk/ProcessHacker/Components/ThreadList.resx index b6e44613c..65a9bbfba 100644 --- a/1.x/trunk/ProcessHacker/Components/ThreadList.resx +++ b/1.x/trunk/ProcessHacker/Components/ThreadList.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 125, 17 + + 17, 17 + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TimerProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/TimerProperties.Designer.cs index 74840966a..d803079f0 100644 --- a/1.x/trunk/ProcessHacker/Components/TimerProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/TimerProperties.Designer.cs @@ -50,7 +50,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 3); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(55, 13); + this.label1.Size = new System.Drawing.Size(51, 13); this.label1.TabIndex = 0; this.label1.Text = "Signaled:"; // @@ -69,7 +69,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 25); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(91, 13); + this.label3.Size = new System.Drawing.Size(86, 13); this.label3.TabIndex = 0; this.label3.Text = "Time Remaining:"; this.label3.Visible = false; @@ -79,7 +79,7 @@ private void InitializeComponent() this.labelSignaled.AutoSize = true; this.labelSignaled.Location = new System.Drawing.Point(98, 3); this.labelSignaled.Name = "labelSignaled"; - this.labelSignaled.Size = new System.Drawing.Size(33, 13); + this.labelSignaled.Size = new System.Drawing.Size(32, 13); this.labelSignaled.TabIndex = 1; this.labelSignaled.Text = "False"; // @@ -98,7 +98,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.buttonCancel); this.Controls.Add(this.labelSignaled); this.Controls.Add(this.labelTimeRemaining); diff --git a/1.x/trunk/ProcessHacker/Components/TimerProperties.cs b/1.x/trunk/ProcessHacker/Components/TimerProperties.cs index a5b60295e..ad7164745 100644 --- a/1.x/trunk/ProcessHacker/Components/TimerProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/TimerProperties.cs @@ -8,7 +8,7 @@ namespace ProcessHacker.Components { public partial class TimerProperties : UserControl { - private readonly TimerHandle _timerHandle; + private TimerHandle _timerHandle; public TimerProperties(TimerHandle timerHandle) { @@ -24,7 +24,7 @@ private void UpdateInfo() { try { - var basicInfo = _timerHandle.BasicInformation; + var basicInfo = _timerHandle.GetBasicInformation(); labelSignaled.Text = basicInfo.TimerState.ToString(); labelTimeRemaining.Text = (new TimeSpan(-basicInfo.RemainingTime)).ToString(); diff --git a/1.x/trunk/ProcessHacker/Components/TimerProperties.resx b/1.x/trunk/ProcessHacker/Components/TimerProperties.resx index bfd9c479b..3add4121b 100644 --- a/1.x/trunk/ProcessHacker/Components/TimerProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/TimerProperties.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TmRmProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/TmRmProperties.Designer.cs index 4316da35f..e022334d4 100644 --- a/1.x/trunk/ProcessHacker/Components/TmRmProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/TmRmProperties.Designer.cs @@ -42,7 +42,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 9); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(69, 13); + this.label1.Size = new System.Drawing.Size(63, 13); this.label1.TabIndex = 0; this.label1.Text = "Description:"; // @@ -57,29 +57,28 @@ private void InitializeComponent() // // textDescription // - this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textDescription.Location = new System.Drawing.Point(75, 6); this.textDescription.Name = "textDescription"; this.textDescription.ReadOnly = true; - this.textDescription.Size = new System.Drawing.Size(252, 22); + this.textDescription.Size = new System.Drawing.Size(252, 20); this.textDescription.TabIndex = 1; // // textGuid // - this.textGuid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textGuid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textGuid.Location = new System.Drawing.Point(49, 32); this.textGuid.Name = "textGuid"; this.textGuid.ReadOnly = true; - this.textGuid.Size = new System.Drawing.Size(278, 22); + this.textGuid.Size = new System.Drawing.Size(278, 20); this.textGuid.TabIndex = 1; // // TmRmProperties // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.textGuid); this.Controls.Add(this.textDescription); this.Controls.Add(this.label2); diff --git a/1.x/trunk/ProcessHacker/Components/TmRmProperties.cs b/1.x/trunk/ProcessHacker/Components/TmRmProperties.cs index a981cd548..20db152ad 100644 --- a/1.x/trunk/ProcessHacker/Components/TmRmProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/TmRmProperties.cs @@ -1,4 +1,9 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; using System.Windows.Forms; using ProcessHacker.Native.Objects; @@ -6,7 +11,7 @@ namespace ProcessHacker.Components { public partial class TmRmProperties : UserControl { - private readonly ResourceManagerHandle _rmHandle; + private ResourceManagerHandle _rmHandle; public TmRmProperties(ResourceManagerHandle rmHandle) { @@ -22,8 +27,8 @@ private void UpdateInfo() { try { - textDescription.Text = _rmHandle.Description; - textGuid.Text = _rmHandle.Guid.ToString("B"); + textDescription.Text = _rmHandle.GetDescription(); + textGuid.Text = _rmHandle.GetGuid().ToString("B"); } catch (Exception ex) { diff --git a/1.x/trunk/ProcessHacker/Components/TmRmProperties.resx b/1.x/trunk/ProcessHacker/Components/TmRmProperties.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/TmRmProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/TmRmProperties.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TmTmProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/TmTmProperties.Designer.cs index e6bee1e3c..2dfb45364 100644 --- a/1.x/trunk/ProcessHacker/Components/TmTmProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/TmTmProperties.Designer.cs @@ -48,12 +48,12 @@ private void InitializeComponent() // // textGuid // - this.textGuid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textGuid.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textGuid.Location = new System.Drawing.Point(49, 6); this.textGuid.Name = "textGuid"; this.textGuid.ReadOnly = true; - this.textGuid.Size = new System.Drawing.Size(244, 22); + this.textGuid.Size = new System.Drawing.Size(244, 20); this.textGuid.TabIndex = 1; // // label2 @@ -61,25 +61,24 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 35); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(82, 13); + this.label2.Size = new System.Drawing.Size(78, 13); this.label2.TabIndex = 0; this.label2.Text = "Log File Name:"; // // textLogFileName // - this.textLogFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textLogFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textLogFileName.Location = new System.Drawing.Point(90, 32); this.textLogFileName.Name = "textLogFileName"; this.textLogFileName.ReadOnly = true; - this.textLogFileName.Size = new System.Drawing.Size(203, 22); + this.textLogFileName.Size = new System.Drawing.Size(203, 20); this.textLogFileName.TabIndex = 1; // // TmTmProperties // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.textLogFileName); this.Controls.Add(this.textGuid); this.Controls.Add(this.label2); diff --git a/1.x/trunk/ProcessHacker/Components/TmTmProperties.cs b/1.x/trunk/ProcessHacker/Components/TmTmProperties.cs index 117196aa9..6b6ad3bc7 100644 --- a/1.x/trunk/ProcessHacker/Components/TmTmProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/TmTmProperties.cs @@ -1,4 +1,9 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; using System.Windows.Forms; using ProcessHacker.Native.Objects; using ProcessHacker.Native; @@ -7,7 +12,7 @@ namespace ProcessHacker.Components { public partial class TmTmProperties : UserControl { - private readonly TmHandle _tmHandle; + private TmHandle _tmHandle; public TmTmProperties(TmHandle tmHandle) { @@ -23,8 +28,8 @@ private void UpdateInfo() { try { - textGuid.Text = _tmHandle.BasicInformation.TmIdentity.ToString("B"); - textLogFileName.Text = FileUtils.GetFileName(FileUtils.GetFileName(_tmHandle.LogFileName)); + textGuid.Text = _tmHandle.GetBasicInformation().TmIdentity.ToString("B"); + textLogFileName.Text = FileUtils.GetFileName(FileUtils.GetFileName(_tmHandle.GetLogFileName())); } catch (Exception ex) { diff --git a/1.x/trunk/ProcessHacker/Components/TmTmProperties.resx b/1.x/trunk/ProcessHacker/Components/TmTmProperties.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/TmTmProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/TmTmProperties.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TokenGroupsList.Designer.cs b/1.x/trunk/ProcessHacker/Components/TokenGroupsList.Designer.cs index ea9ca5c04..120f3f5d5 100644 --- a/1.x/trunk/ProcessHacker/Components/TokenGroupsList.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/TokenGroupsList.Designer.cs @@ -28,9 +28,9 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.listGroups = new ProcessHacker.Components.ExtendedListView(); - this.columnGroupName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnFlags = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listGroups = new System.Windows.Forms.ListView(); + this.columnGroupName = new System.Windows.Forms.ColumnHeader(); + this.columnFlags = new System.Windows.Forms.ColumnHeader(); this.SuspendLayout(); // // listGroups @@ -40,12 +40,11 @@ private void InitializeComponent() this.columnGroupName, this.columnFlags}); this.listGroups.Dock = System.Windows.Forms.DockStyle.Fill; - this.listGroups.DoubleClickChecks = true; this.listGroups.FullRowSelect = true; this.listGroups.Location = new System.Drawing.Point(0, 0); this.listGroups.Name = "listGroups"; this.listGroups.ShowItemToolTips = true; - this.listGroups.Size = new System.Drawing.Size(416, 397); + this.listGroups.Size = new System.Drawing.Size(431, 397); this.listGroups.Sorting = System.Windows.Forms.SortOrder.Ascending; this.listGroups.TabIndex = 4; this.listGroups.UseCompatibleStateImageBehavior = false; @@ -61,21 +60,20 @@ private void InitializeComponent() this.columnFlags.Text = "Flags"; this.columnFlags.Width = 180; // - // TokenGroupsList + // TokenGroups // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.listGroups); - this.Name = "TokenGroupsList"; - this.Size = new System.Drawing.Size(416, 397); + this.Name = "TokenGroups"; + this.Size = new System.Drawing.Size(431, 397); this.ResumeLayout(false); } #endregion - private ExtendedListView listGroups; + private System.Windows.Forms.ListView listGroups; private System.Windows.Forms.ColumnHeader columnGroupName; private System.Windows.Forms.ColumnHeader columnFlags; } diff --git a/1.x/trunk/ProcessHacker/Components/TokenGroupsList.cs b/1.x/trunk/ProcessHacker/Components/TokenGroupsList.cs index 9c3acb4e9..2af0f40cd 100644 --- a/1.x/trunk/ProcessHacker/Components/TokenGroupsList.cs +++ b/1.x/trunk/ProcessHacker/Components/TokenGroupsList.cs @@ -38,17 +38,18 @@ public TokenGroupsList(Sid[] groups) if (groups != null) { - foreach (Sid t in groups) + for (int i = 0; i < groups.Length; i++) { - ListViewItem item = this.listGroups.Items.Add(new ListViewItem()); + ListViewItem item = listGroups.Items.Add(new ListViewItem()); - item.Text = t.GetFullName(Settings.Instance.ShowAccountDomains); - item.BackColor = this.GetAttributeColor(t.Attributes); - item.SubItems.Add(new ListViewItem.ListViewSubItem(item, this.GetAttributeString(t.Attributes))); + item.Text = groups[i].GetFullName(Settings.Instance.ShowAccountDomains); + item.BackColor = GetAttributeColor(groups[i].Attributes); + item.SubItems.Add(new ListViewItem.ListViewSubItem(item, GetAttributeString(groups[i].Attributes))); } } listGroups.ListViewItemSorter = new SortedListViewComparer(listGroups); + listGroups.SetDoubleBuffered(true); listGroups.ContextMenu = listGroups.GetCopyMenu(); ColumnSettings.LoadSettings(Settings.Instance.GroupListColumns, listGroups); listGroups.AddShortcuts(); @@ -70,17 +71,16 @@ public void DumpAddGroup(string name, SidAttributes attributes) private string GetAttributeString(SidAttributes Attributes) { - string text = string.Empty; + string text = ""; if ((Attributes & SidAttributes.Integrity) != 0) { if ((Attributes & SidAttributes.IntegrityEnabled) != 0) return "Integrity"; - - return "Integrity (Disabled)"; + else + return "Integrity (Disabled)"; } - - if ((Attributes & SidAttributes.LogonId) != 0) + else if ((Attributes & SidAttributes.LogonId) != 0) text = "Logon ID"; else if ((Attributes & SidAttributes.Mandatory) != 0) text = "Mandatory"; @@ -93,11 +93,10 @@ private string GetAttributeString(SidAttributes Attributes) if ((Attributes & SidAttributes.EnabledByDefault) != 0) return text + " (Default Enabled)"; - - if ((Attributes & SidAttributes.Enabled) != 0) + else if ((Attributes & SidAttributes.Enabled) != 0) return text; - - return text + " (Disabled)"; + else + return text + " (Disabled)"; } private Color GetAttributeColor(SidAttributes Attributes) @@ -106,17 +105,16 @@ private Color GetAttributeColor(SidAttributes Attributes) { if ((Attributes & SidAttributes.IntegrityEnabled) == 0) return Color.FromArgb(0xe0e0e0); - - return Color.White; + else + return Color.White; } if ((Attributes & SidAttributes.EnabledByDefault) != 0) return Color.FromArgb(0xe0f0e0); - - if ((Attributes & SidAttributes.Enabled) != 0) + else if ((Attributes & SidAttributes.Enabled) != 0) return Color.White; - - return Color.FromArgb(0xf0e0e0); + else + return Color.FromArgb(0xf0e0e0); } } } diff --git a/1.x/trunk/ProcessHacker/Components/TokenGroupsList.resx b/1.x/trunk/ProcessHacker/Components/TokenGroupsList.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Components/TokenGroupsList.resx +++ b/1.x/trunk/ProcessHacker/Components/TokenGroupsList.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TokenProperties.Designer.cs b/1.x/trunk/ProcessHacker/Components/TokenProperties.Designer.cs index 7af872ded..42dcc3850 100644 --- a/1.x/trunk/ProcessHacker/Components/TokenProperties.Designer.cs +++ b/1.x/trunk/ProcessHacker/Components/TokenProperties.Designer.cs @@ -32,6 +32,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.tabControl = new System.Windows.Forms.TabControl(); this.tabGeneral = new System.Windows.Forms.TabPage(); this.groupSource = new System.Windows.Forms.GroupBox(); @@ -71,10 +72,10 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.tabGroups = new System.Windows.Forms.TabPage(); this.tabPrivileges = new System.Windows.Forms.TabPage(); - this.listPrivileges = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnDesc = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listPrivileges = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnStatus = new System.Windows.Forms.ColumnHeader(); + this.columnDesc = new System.Windows.Forms.ColumnHeader(); this.enableMenuItem = new System.Windows.Forms.MenuItem(); this.disableMenuItem = new System.Windows.Forms.MenuItem(); this.removeMenuItem = new System.Windows.Forms.MenuItem(); @@ -82,12 +83,14 @@ private void InitializeComponent() this.menuPrivileges = new System.Windows.Forms.ContextMenu(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.selectAllMenuItem = new System.Windows.Forms.MenuItem(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.tabControl.SuspendLayout(); this.tabGeneral.SuspendLayout(); this.groupSource.SuspendLayout(); this.groupToken.SuspendLayout(); this.tabAdvanced.SuspendLayout(); this.tabPrivileges.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // tabControl @@ -100,7 +103,7 @@ private void InitializeComponent() this.tabControl.Location = new System.Drawing.Point(0, 0); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(431, 433); + this.tabControl.Size = new System.Drawing.Size(575, 433); this.tabControl.TabIndex = 3; // // tabGeneral @@ -111,22 +114,22 @@ private void InitializeComponent() this.tabGeneral.Location = new System.Drawing.Point(4, 22); this.tabGeneral.Name = "tabGeneral"; this.tabGeneral.Padding = new System.Windows.Forms.Padding(3, 5, 3, 3); - this.tabGeneral.Size = new System.Drawing.Size(423, 407); + this.tabGeneral.Size = new System.Drawing.Size(567, 407); this.tabGeneral.TabIndex = 2; this.tabGeneral.Text = "General"; this.tabGeneral.UseVisualStyleBackColor = true; // // groupSource // - this.groupSource.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupSource.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupSource.Controls.Add(this.label7); this.groupSource.Controls.Add(this.label6); this.groupSource.Controls.Add(this.textSourceName); this.groupSource.Controls.Add(this.textSourceLUID); this.groupSource.Location = new System.Drawing.Point(6, 247); this.groupSource.Name = "groupSource"; - this.groupSource.Size = new System.Drawing.Size(411, 75); + this.groupSource.Size = new System.Drawing.Size(555, 75); this.groupSource.TabIndex = 15; this.groupSource.TabStop = false; this.groupSource.Text = "Source"; @@ -136,7 +139,7 @@ private void InitializeComponent() this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(6, 48); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(34, 13); + this.label7.Size = new System.Drawing.Size(35, 13); this.label7.TabIndex = 3; this.label7.Text = "LUID:"; // @@ -145,18 +148,18 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(6, 22); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(39, 13); + this.label6.Size = new System.Drawing.Size(38, 13); this.label6.TabIndex = 2; this.label6.Text = "Name:"; // // textSourceName // - this.textSourceName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textSourceName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textSourceName.Location = new System.Drawing.Point(73, 19); this.textSourceName.Name = "textSourceName"; this.textSourceName.ReadOnly = true; - this.textSourceName.Size = new System.Drawing.Size(332, 22); + this.textSourceName.Size = new System.Drawing.Size(476, 20); this.textSourceName.TabIndex = 1; // // textSourceLUID @@ -164,13 +167,13 @@ private void InitializeComponent() this.textSourceLUID.Location = new System.Drawing.Point(73, 45); this.textSourceLUID.Name = "textSourceLUID"; this.textSourceLUID.ReadOnly = true; - this.textSourceLUID.Size = new System.Drawing.Size(109, 22); + this.textSourceLUID.Size = new System.Drawing.Size(109, 20); this.textSourceLUID.TabIndex = 4; // // groupToken // - this.groupToken.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupToken.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupToken.Controls.Add(this.buttonPermissions); this.groupToken.Controls.Add(this.label9); this.groupToken.Controls.Add(this.label1); @@ -189,7 +192,7 @@ private void InitializeComponent() this.groupToken.Controls.Add(this.textUserSID); this.groupToken.Location = new System.Drawing.Point(6, 8); this.groupToken.Name = "groupToken"; - this.groupToken.Size = new System.Drawing.Size(411, 233); + this.groupToken.Size = new System.Drawing.Size(555, 233); this.groupToken.TabIndex = 14; this.groupToken.TabStop = false; this.groupToken.Text = "Token"; @@ -198,7 +201,7 @@ private void InitializeComponent() // this.buttonPermissions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonPermissions.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonPermissions.Location = new System.Drawing.Point(330, 201); + this.buttonPermissions.Location = new System.Drawing.Point(474, 201); this.buttonPermissions.Name = "buttonPermissions"; this.buttonPermissions.Size = new System.Drawing.Size(75, 23); this.buttonPermissions.TabIndex = 18; @@ -211,7 +214,7 @@ private void InitializeComponent() this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(6, 100); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(83, 13); + this.label9.Size = new System.Drawing.Size(76, 13); this.label9.TabIndex = 17; this.label9.Text = "Primary Group:"; // @@ -220,7 +223,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 22); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(33, 13); + this.label1.Size = new System.Drawing.Size(32, 13); this.label1.TabIndex = 2; this.label1.Text = "User:"; // @@ -237,22 +240,22 @@ private void InitializeComponent() // // textPrimaryGroup // - this.textPrimaryGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textPrimaryGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textPrimaryGroup.Location = new System.Drawing.Point(88, 97); this.textPrimaryGroup.Name = "textPrimaryGroup"; this.textPrimaryGroup.ReadOnly = true; - this.textPrimaryGroup.Size = new System.Drawing.Size(317, 22); + this.textPrimaryGroup.Size = new System.Drawing.Size(461, 20); this.textPrimaryGroup.TabIndex = 16; // // textUser // - this.textUser.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textUser.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textUser.Location = new System.Drawing.Point(88, 19); this.textUser.Name = "textUser"; this.textUser.ReadOnly = true; - this.textUser.Size = new System.Drawing.Size(317, 22); + this.textUser.Size = new System.Drawing.Size(461, 20); this.textUser.TabIndex = 1; // // textElevated @@ -260,7 +263,7 @@ private void InitializeComponent() this.textElevated.Location = new System.Drawing.Point(88, 149); this.textElevated.Name = "textElevated"; this.textElevated.ReadOnly = true; - this.textElevated.Size = new System.Drawing.Size(109, 22); + this.textElevated.Size = new System.Drawing.Size(109, 20); this.textElevated.TabIndex = 12; // // label8 @@ -268,18 +271,18 @@ private void InitializeComponent() this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(6, 74); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(45, 13); + this.label8.Size = new System.Drawing.Size(41, 13); this.label8.TabIndex = 15; this.label8.Text = "Owner:"; // // textOwner // - this.textOwner.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textOwner.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textOwner.Location = new System.Drawing.Point(88, 71); this.textOwner.Name = "textOwner"; this.textOwner.ReadOnly = true; - this.textOwner.Size = new System.Drawing.Size(317, 22); + this.textOwner.Size = new System.Drawing.Size(461, 20); this.textOwner.TabIndex = 14; // // label2 @@ -287,18 +290,18 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 126); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(63, 13); + this.label2.Size = new System.Drawing.Size(61, 13); this.label2.TabIndex = 3; this.label2.Text = "Session ID:"; // // textVirtualized // - this.textVirtualized.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textVirtualized.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textVirtualized.Location = new System.Drawing.Point(88, 175); this.textVirtualized.Name = "textVirtualized"; this.textVirtualized.ReadOnly = true; - this.textVirtualized.Size = new System.Drawing.Size(317, 22); + this.textVirtualized.Size = new System.Drawing.Size(461, 20); this.textVirtualized.TabIndex = 11; // // textSessionID @@ -306,7 +309,7 @@ private void InitializeComponent() this.textSessionID.Location = new System.Drawing.Point(88, 123); this.textSessionID.Name = "textSessionID"; this.textSessionID.ReadOnly = true; - this.textSessionID.Size = new System.Drawing.Size(109, 22); + this.textSessionID.Size = new System.Drawing.Size(109, 20); this.textSessionID.TabIndex = 4; // // labelVirtualization @@ -314,7 +317,7 @@ private void InitializeComponent() this.labelVirtualization.AutoSize = true; this.labelVirtualization.Location = new System.Drawing.Point(6, 178); this.labelVirtualization.Name = "labelVirtualization"; - this.labelVirtualization.Size = new System.Drawing.Size(79, 13); + this.labelVirtualization.Size = new System.Drawing.Size(69, 13); this.labelVirtualization.TabIndex = 8; this.labelVirtualization.Text = "Virtualization:"; // @@ -332,18 +335,18 @@ private void InitializeComponent() this.labelElevated.AutoSize = true; this.labelElevated.Location = new System.Drawing.Point(6, 152); this.labelElevated.Name = "labelElevated"; - this.labelElevated.Size = new System.Drawing.Size(53, 13); + this.labelElevated.Size = new System.Drawing.Size(52, 13); this.labelElevated.TabIndex = 7; this.labelElevated.Text = "Elevated:"; // // textUserSID // - this.textUserSID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textUserSID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textUserSID.Location = new System.Drawing.Point(88, 45); this.textUserSID.Name = "textUserSID"; this.textUserSID.ReadOnly = true; - this.textUserSID.Size = new System.Drawing.Size(317, 22); + this.textUserSID.Size = new System.Drawing.Size(461, 20); this.textUserSID.TabIndex = 6; // // tabAdvanced @@ -363,7 +366,7 @@ private void InitializeComponent() this.tabAdvanced.Location = new System.Drawing.Point(4, 22); this.tabAdvanced.Name = "tabAdvanced"; this.tabAdvanced.Padding = new System.Windows.Forms.Padding(3); - this.tabAdvanced.Size = new System.Drawing.Size(423, 407); + this.tabAdvanced.Size = new System.Drawing.Size(567, 407); this.tabAdvanced.TabIndex = 3; this.tabAdvanced.Text = "Advanced"; this.tabAdvanced.UseVisualStyleBackColor = true; @@ -373,7 +376,7 @@ private void InitializeComponent() this.textMemoryAvailable.Location = new System.Drawing.Point(118, 136); this.textMemoryAvailable.Name = "textMemoryAvailable"; this.textMemoryAvailable.ReadOnly = true; - this.textMemoryAvailable.Size = new System.Drawing.Size(284, 22); + this.textMemoryAvailable.Size = new System.Drawing.Size(191, 20); this.textMemoryAvailable.TabIndex = 1; // // textMemoryUsed @@ -381,7 +384,7 @@ private void InitializeComponent() this.textMemoryUsed.Location = new System.Drawing.Point(118, 110); this.textMemoryUsed.Name = "textMemoryUsed"; this.textMemoryUsed.ReadOnly = true; - this.textMemoryUsed.Size = new System.Drawing.Size(284, 22); + this.textMemoryUsed.Size = new System.Drawing.Size(191, 20); this.textMemoryUsed.TabIndex = 1; // // textAuthenticationId @@ -389,7 +392,7 @@ private void InitializeComponent() this.textAuthenticationId.Location = new System.Drawing.Point(118, 84); this.textAuthenticationId.Name = "textAuthenticationId"; this.textAuthenticationId.ReadOnly = true; - this.textAuthenticationId.Size = new System.Drawing.Size(284, 22); + this.textAuthenticationId.Size = new System.Drawing.Size(191, 20); this.textAuthenticationId.TabIndex = 1; // // textTokenId @@ -397,7 +400,7 @@ private void InitializeComponent() this.textTokenId.Location = new System.Drawing.Point(118, 58); this.textTokenId.Name = "textTokenId"; this.textTokenId.ReadOnly = true; - this.textTokenId.Size = new System.Drawing.Size(284, 22); + this.textTokenId.Size = new System.Drawing.Size(191, 20); this.textTokenId.TabIndex = 1; // // textImpersonationLevel @@ -405,7 +408,7 @@ private void InitializeComponent() this.textImpersonationLevel.Location = new System.Drawing.Point(118, 32); this.textImpersonationLevel.Name = "textImpersonationLevel"; this.textImpersonationLevel.ReadOnly = true; - this.textImpersonationLevel.Size = new System.Drawing.Size(284, 22); + this.textImpersonationLevel.Size = new System.Drawing.Size(191, 20); this.textImpersonationLevel.TabIndex = 1; // // textTokenType @@ -413,7 +416,7 @@ private void InitializeComponent() this.textTokenType.Location = new System.Drawing.Point(118, 6); this.textTokenType.Name = "textTokenType"; this.textTokenType.ReadOnly = true; - this.textTokenType.Size = new System.Drawing.Size(284, 22); + this.textTokenType.Size = new System.Drawing.Size(191, 20); this.textTokenType.TabIndex = 1; // // label13 @@ -421,7 +424,7 @@ private void InitializeComponent() this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(6, 139); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(100, 13); + this.label13.Size = new System.Drawing.Size(93, 13); this.label13.TabIndex = 0; this.label13.Text = "Memory Available:"; // @@ -430,7 +433,7 @@ private void InitializeComponent() this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(6, 113); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(80, 13); + this.label12.Size = new System.Drawing.Size(75, 13); this.label12.TabIndex = 0; this.label12.Text = "Memory Used:"; // @@ -439,7 +442,7 @@ private void InitializeComponent() this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(6, 87); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(114, 13); + this.label11.Size = new System.Drawing.Size(106, 13); this.label11.TabIndex = 0; this.label11.Text = "Authentication LUID:"; // @@ -448,7 +451,7 @@ private void InitializeComponent() this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(6, 61); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(68, 13); + this.label10.Size = new System.Drawing.Size(69, 13); this.label10.TabIndex = 0; this.label10.Text = "Token LUID:"; // @@ -457,7 +460,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(6, 35); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(113, 13); + this.label5.Size = new System.Drawing.Size(105, 13); this.label5.TabIndex = 0; this.label5.Text = "Impersonation Level:"; // @@ -466,7 +469,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(6, 9); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(33, 13); + this.label4.Size = new System.Drawing.Size(34, 13); this.label4.TabIndex = 0; this.label4.Text = "Type:"; // @@ -475,7 +478,7 @@ private void InitializeComponent() this.tabGroups.Location = new System.Drawing.Point(4, 22); this.tabGroups.Name = "tabGroups"; this.tabGroups.Padding = new System.Windows.Forms.Padding(3); - this.tabGroups.Size = new System.Drawing.Size(423, 407); + this.tabGroups.Size = new System.Drawing.Size(567, 407); this.tabGroups.TabIndex = 1; this.tabGroups.Text = "Groups"; this.tabGroups.UseVisualStyleBackColor = true; @@ -486,7 +489,7 @@ private void InitializeComponent() this.tabPrivileges.Location = new System.Drawing.Point(4, 22); this.tabPrivileges.Name = "tabPrivileges"; this.tabPrivileges.Padding = new System.Windows.Forms.Padding(3); - this.tabPrivileges.Size = new System.Drawing.Size(423, 407); + this.tabPrivileges.Size = new System.Drawing.Size(567, 407); this.tabPrivileges.TabIndex = 0; this.tabPrivileges.Text = "Privileges"; this.tabPrivileges.UseVisualStyleBackColor = true; @@ -499,12 +502,11 @@ private void InitializeComponent() this.columnStatus, this.columnDesc}); this.listPrivileges.Dock = System.Windows.Forms.DockStyle.Fill; - this.listPrivileges.DoubleClickChecks = true; this.listPrivileges.FullRowSelect = true; this.listPrivileges.Location = new System.Drawing.Point(3, 3); this.listPrivileges.Name = "listPrivileges"; this.listPrivileges.ShowItemToolTips = true; - this.listPrivileges.Size = new System.Drawing.Size(417, 401); + this.listPrivileges.Size = new System.Drawing.Size(561, 401); this.listPrivileges.Sorting = System.Windows.Forms.SortOrder.Ascending; this.listPrivileges.TabIndex = 0; this.listPrivileges.UseCompatibleStateImageBehavior = false; @@ -527,24 +529,28 @@ private void InitializeComponent() // // enableMenuItem // + this.vistaMenu.SetImage(this.enableMenuItem, global::ProcessHacker.Properties.Resources.tick); this.enableMenuItem.Index = 0; this.enableMenuItem.Text = "&Enable"; this.enableMenuItem.Click += new System.EventHandler(this.enableMenuItem_Click); // // disableMenuItem // + this.vistaMenu.SetImage(this.disableMenuItem, global::ProcessHacker.Properties.Resources.cross); this.disableMenuItem.Index = 1; this.disableMenuItem.Text = "&Disable"; this.disableMenuItem.Click += new System.EventHandler(this.disableMenuItem_Click); // // removeMenuItem // + this.vistaMenu.SetImage(this.removeMenuItem, global::ProcessHacker.Properties.Resources.delete); this.removeMenuItem.Index = 2; this.removeMenuItem.Text = "&Remove"; this.removeMenuItem.Click += new System.EventHandler(this.removeMenuItem_Click); // // copyMenuItem // + this.vistaMenu.SetImage(this.copyMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyMenuItem.Index = 4; this.copyMenuItem.Text = "&Copy"; // @@ -570,14 +576,18 @@ private void InitializeComponent() this.selectAllMenuItem.Text = "Select &All"; this.selectAllMenuItem.Click += new System.EventHandler(this.selectAllMenuItem_Click); // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // TokenProperties // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.Controls.Add(this.tabControl); this.Name = "TokenProperties"; - this.Size = new System.Drawing.Size(431, 433); + this.Size = new System.Drawing.Size(575, 433); this.tabControl.ResumeLayout(false); this.tabGeneral.ResumeLayout(false); this.groupSource.ResumeLayout(false); @@ -587,6 +597,7 @@ private void InitializeComponent() this.tabAdvanced.ResumeLayout(false); this.tabAdvanced.PerformLayout(); this.tabPrivileges.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); } @@ -601,10 +612,11 @@ private void InitializeComponent() private System.Windows.Forms.TextBox textUser; private System.Windows.Forms.TabPage tabGroups; private System.Windows.Forms.TabPage tabPrivileges; - private ExtendedListView listPrivileges; + private System.Windows.Forms.ListView listPrivileges; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnStatus; private System.Windows.Forms.ColumnHeader columnDesc; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.MenuItem enableMenuItem; private System.Windows.Forms.MenuItem disableMenuItem; private System.Windows.Forms.MenuItem removeMenuItem; diff --git a/1.x/trunk/ProcessHacker/Components/TokenProperties.cs b/1.x/trunk/ProcessHacker/Components/TokenProperties.cs index c7cb9dcef..1cbd6e191 100644 --- a/1.x/trunk/ProcessHacker/Components/TokenProperties.cs +++ b/1.x/trunk/ProcessHacker/Components/TokenProperties.cs @@ -31,19 +31,19 @@ using ProcessHacker.Native.Security; using ProcessHacker.Native.Security.AccessControl; using ProcessHacker.UI; -using ProcessHacker.Api; namespace ProcessHacker.Components { - public partial class TokenProperties : ProcessPropertySheetPage + public partial class TokenProperties : UserControl { - private readonly IWithToken _object; + private IWithToken _object; private TokenGroupsList _groups; public TokenProperties(IWithToken obj) { InitializeComponent(); + listPrivileges.SetDoubleBuffered(true); listPrivileges.ListViewItemSorter = new SortedListViewComparer(listPrivileges); GenericViewMenu.AddMenuItems(copyMenuItem.MenuItems, listPrivileges, null); listPrivileges.ContextMenu = menuPrivileges; @@ -60,10 +60,10 @@ public TokenProperties(IWithToken obj) // "General" try { - textUser.Text = thandle.User.GetFullName(true); - textUserSID.Text = thandle.User.StringSid; - textOwner.Text = thandle.Owner.GetFullName(true); - textPrimaryGroup.Text = thandle.PrimaryGroup.GetFullName(true); + textUser.Text = thandle.GetUser().GetFullName(true); + textUserSID.Text = thandle.GetUser().StringSid; + textOwner.Text = thandle.GetOwner().GetFullName(true); + textPrimaryGroup.Text = thandle.GetPrimaryGroup().GetFullName(true); } catch (Exception ex) { @@ -72,7 +72,7 @@ public TokenProperties(IWithToken obj) try { - textSessionID.Text = thandle.SessionId.ToString(); + textSessionID.Text = thandle.GetSessionId().ToString(); } catch (Exception ex) { @@ -81,20 +81,14 @@ public TokenProperties(IWithToken obj) try { - TokenElevationType type = thandle.ElevationType; - - switch (type) - { - case TokenElevationType.Default: - this.textElevated.Text = "N/A"; - break; - case TokenElevationType.Full: - this.textElevated.Text = "True"; - break; - case TokenElevationType.Limited: - this.textElevated.Text = "False"; - break; - } + var type = thandle.GetElevationType(); + + if (type == TokenElevationType.Default) + textElevated.Text = "N/A"; + else if (type == TokenElevationType.Full) + textElevated.Text = "True"; + else if (type == TokenElevationType.Limited) + textElevated.Text = "False"; } catch (Exception ex) { @@ -106,7 +100,7 @@ public TokenProperties(IWithToken obj) { try { - TokenHandle linkedToken = thandle.LinkedToken; + TokenHandle linkedToken = thandle.GetLinkedToken(); if (linkedToken != null) linkedToken.Dispose(); @@ -125,8 +119,8 @@ public TokenProperties(IWithToken obj) try { - bool virtAllowed = thandle.IsVirtualizationAllowed; - bool virtEnabled = thandle.IsVirtualizationEnabled; + bool virtAllowed = thandle.IsVirtualizationAllowed(); + bool virtEnabled = thandle.IsVirtualizationEnabled(); if (virtEnabled) textVirtualized.Text = "Enabled"; @@ -144,7 +138,7 @@ public TokenProperties(IWithToken obj) { using (TokenHandle tokenSource = _object.GetToken(TokenAccess.QuerySource)) { - var source = tokenSource.Source; + var source = tokenSource.GetSource(); textSourceName.Text = source.SourceName.TrimEnd('\0', '\r', '\n', ' '); @@ -161,7 +155,7 @@ public TokenProperties(IWithToken obj) // "Advanced" try { - var statistics = thandle.Statistics; + var statistics = thandle.GetStatistics(); textTokenType.Text = statistics.TokenType.ToString(); textImpersonationLevel.Text = statistics.ImpersonationLevel.ToString(); @@ -177,7 +171,7 @@ public TokenProperties(IWithToken obj) try { - Sid[] groups = thandle.Groups; + var groups = thandle.GetGroups(); _groups = new TokenGroupsList(groups); @@ -194,11 +188,11 @@ public TokenProperties(IWithToken obj) try { - var privileges = thandle.Privileges; + var privileges = thandle.GetPrivileges(); - foreach (Privilege t in privileges) + for (int i = 0; i < privileges.Length; i++) { - this.AddPrivilege(t); + this.AddPrivilege(privileges[i]); } } catch (Exception ex) @@ -211,10 +205,9 @@ public TokenProperties(IWithToken obj) { tabControl.Visible = false; - Label errorMessage = new Label - { - Text = ex.Message - }; + Label errorMessage = new Label(); + + errorMessage.Text = ex.Message; this.Padding = new Padding(15, 10, 0, 0); this.Controls.Add(errorMessage); @@ -224,10 +217,10 @@ public TokenProperties(IWithToken obj) { labelElevated.Enabled = false; textElevated.Enabled = false; - textElevated.Text = string.Empty; + textElevated.Text = ""; labelVirtualization.Enabled = false; textVirtualized.Enabled = false; - textVirtualized.Text = string.Empty; + textVirtualized.Text = ""; } if (tabControl.TabPages[Settings.Instance.TokenWindowTab] != null) @@ -257,10 +250,8 @@ public void DumpInitialize() buttonPermissions.Visible = false; listPrivileges.ContextMenu = listPrivileges.GetCopyMenu(); - _groups = new TokenGroupsList(null) - { - Dock = DockStyle.Fill - }; + _groups = new TokenGroupsList(null); + _groups.Dock = DockStyle.Fill; tabGroups.Controls.Add(_groups); } @@ -343,35 +334,31 @@ private string GetAttributeString(SePrivilegeAttributes Attributes) { if ((Attributes & SePrivilegeAttributes.EnabledByDefault) != 0) return "Default Enabled"; - - if ((Attributes & SePrivilegeAttributes.Enabled) != 0) + else if ((Attributes & SePrivilegeAttributes.Enabled) != 0) return "Enabled"; - - if (Attributes == SePrivilegeAttributes.Disabled) + else if (Attributes == SePrivilegeAttributes.Disabled) return "Disabled"; - - return "Unknown"; + else + return "Unknown"; } private Color GetAttributeColor(SePrivilegeAttributes Attributes) { if ((Attributes & SePrivilegeAttributes.EnabledByDefault) != 0) return Color.FromArgb(0xc0f0c0); - - if ((Attributes & SePrivilegeAttributes.Enabled) != 0) + else if ((Attributes & SePrivilegeAttributes.Enabled) != 0) return Color.FromArgb(0xe0f0e0); - - if (Attributes == SePrivilegeAttributes.Disabled) + else if (Attributes == SePrivilegeAttributes.Disabled) return Color.FromArgb(0xf0e0e0); - - return Color.White; + else + return Color.White; } private void menuPrivileges_Popup(object sender, EventArgs e) { if (listPrivileges.SelectedItems.Count == 0) { - //menuPrivileges.DisableAll(); + menuPrivileges.DisableAll(); } else { @@ -481,14 +468,14 @@ private void removeMenuItem_Click(object sender, EventArgs e) private void selectAllMenuItem_Click(object sender, EventArgs e) { - this.listPrivileges.Items.SelectAll(); + Utils.SelectAll(listPrivileges.Items); } private void buttonLinkedToken_Click(object sender, EventArgs e) { - using (TokenHandle thandle = _object.GetToken(TokenAccess.Query)) + using (var thandle = _object.GetToken(TokenAccess.Query)) { - TokenWithLinkedToken token = new TokenWithLinkedToken(thandle); + var token = new TokenWithLinkedToken(thandle); TokenWindow window = new TokenWindow(token); window.ShowDialog(); @@ -501,7 +488,7 @@ private void buttonPermissions_Click(object sender, EventArgs e) { SecurityEditor.EditSecurity( this, - SecurityEditor.GetSecurableWrapper(access => _object.GetToken((TokenAccess)access)), + SecurityEditor.GetSecurableWrapper((access) => _object.GetToken((TokenAccess)access)), "Token", NativeTypeFactory.GetAccessEntries(NativeTypeFactory.ObjectType.Token) ); diff --git a/1.x/trunk/ProcessHacker/Components/TokenProperties.resx b/1.x/trunk/ProcessHacker/Components/TokenProperties.resx index 802907d2f..0bae7478e 100644 --- a/1.x/trunk/ProcessHacker/Components/TokenProperties.resx +++ b/1.x/trunk/ProcessHacker/Components/TokenProperties.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + 17, 17 + + 125, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/ToolStripEx.cs b/1.x/trunk/ProcessHacker/Components/ToolStripEx.cs deleted file mode 100644 index 6a0907c20..000000000 --- a/1.x/trunk/ProcessHacker/Components/ToolStripEx.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Windows.Forms; -using ProcessHacker.Common; - -namespace System -{ - public class ToolStripEx : ToolStrip - { - private const uint WM_MOUSEACTIVATE = 0x21; - private static readonly IntPtr MA_ACTIVATE = new IntPtr(1); - private static readonly IntPtr MA_ACTIVATEANDEAT = new IntPtr(2); - private const uint MA_NOACTIVATE = 3; - private const uint MA_NOACTIVATEANDEAT = 4; - - private bool clickThrough = true; - - /// - /// Gets or sets whether the ToolStripEx honors item clicks when its containing form does not have input focus. - /// - /// - /// Default value is true, which is the same behavior provided by the base ToolStrip class. - /// - public bool ClickThrough - { - get { return this.clickThrough; } - set { this.clickThrough = value; } - } - - protected override void WndProc(ref Message m) - { - base.WndProc(ref m); - - if (this.clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == MA_ACTIVATEANDEAT) - { - m.Result = MA_ACTIVATE; - } - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/Tracker.cs b/1.x/trunk/ProcessHacker/Components/Tracker.cs deleted file mode 100644 index af4882b58..000000000 --- a/1.x/trunk/ProcessHacker/Components/Tracker.cs +++ /dev/null @@ -1,385 +0,0 @@ -using System; -using ProcessHacker.Common; - -namespace ProcessHacker -{ - using System.Windows.Forms; - using System.ComponentModel; - using System.Drawing; - - public class Tracker : Control - { - public Color DrawColor = Color.Empty; - - //SedondLine Maximum - public int value2Max = 100; - - private int mover; - - public System.Collections.Generic.IList values; - public System.Collections.Generic.IList values2; - - private int mValue; - private int mMinimum; - private int mMaximum = 100; - private int mLower = 25; - private int mUpper = 75; - - private int intDivision = 2; - private int mGrid = 12; - - public bool UseSecondLine { get; set; } - - public Tracker() - { - this.SetStyle(ControlStyles.ResizeRedraw, true); - this.SetStyle(ControlStyles.UserPaint, true); - this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); - this.SetStyle(ControlStyles.DoubleBuffer, true); - - this.Draw(); - } - - [Category("Behavior"), DefaultValue(12), Description("The grid of Tracker.")] - public int Grid - { - get { return mGrid; } - set - { - if (value > 0) - mGrid = value; - } - } - - [Category("Behavior"), DefaultValue(0), Description("The current value of Tracker, in the range specified by the Minimum and Maximum properties.")] - public int Value - { - get { return this.mValue; } - set - { - if (value > this.mMaximum) - { - this.mValue = this.mMaximum; - } - else if (value < this.mMinimum) - { - this.mValue = this.mMinimum; - } - else - { - this.mValue = value; - } - } - } - - [Category("Behavior"), DefaultValue(0), Description("The lower bound of the range this Tracker is working with.")] - public int Minimum - { - get { return mMinimum; } - set - { - if (value > mLower) - { - mMinimum = mLower; - } - else - { - mMinimum = value; - } - this.Invalidate(); - } - } - - [Category("Behavior"), DefaultValue(100), Description("The upper bound of the range this Tracker is working with.")] - public int Maximum - { - get { return mMaximum; } - set - { - if (value < mUpper) - { - mMaximum = mUpper; - } - else - { - mMaximum = value; - } - - this.Invalidate(); - } - } - - [Category("Behavior"), DefaultValue(75), Description("The upper value of the normal range.")] - public int UpperRange - { - get { return mUpper; } - set - { - if (value > mMaximum) - { - mUpper = mMaximum; - } - else if (value < mLower) - { - mUpper = mLower; - } - else - { - mUpper = value; - } - this.Invalidate(); - } - } - - [Category("Behavior"), DefaultValue(25), Description("The lower value of the normal range.")] - public int LowerRange - { - get { return mLower; } - set - { - if (value > mUpper) - { - mLower = mUpper; - } - else if (value < mMinimum) - { - mLower = mMinimum; - } - else - { - mLower = value; - } - this.Invalidate(); - } - } - - public void Draw() - { - if (this.mover >= this.mGrid - intDivision) - { - mover = 0; - } - else - { - mover += intDivision; - } - - this.Refresh(); - } - - protected override void OnPaint(PaintEventArgs e) - { - e.Graphics.Clear(Color.Black); - e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; - - int width = this.Width; - int height = this.Height; - - // draw grid - using (Pen p = new Pen(Color.DarkGreen)) - { - int pos; - - // X Axis - for (int i = 0; i <= height / this.mGrid; i++) - { - pos = i * this.mGrid; - - e.Graphics.DrawLine(p, 0, pos, width, pos); - } - // Y Axis - for (int i = 0; i <= width + 1 / this.mGrid; i++) - { - pos = i * this.mGrid - this.mover; - - e.Graphics.DrawLine(p, pos, 0, pos, height); - } - } - - if (this.values != null) - { - for (int i = 1; i <= this.values.Count - 1; i++) - { - int x = width - intDivision*(this.values.Count - i); - int y = height*(this.Maximum - this.values[i])/(this.Maximum - this.Minimum); - - int xx = width - intDivision*(this.values.Count - i + 1); - int yy = (height*(this.Maximum - this.values[i - 1])/(this.Maximum - this.Minimum)); - - using (Pen p = new Pen(this.DrawColor)) - { - p.Width = 2; - - using (SolidBrush b = new SolidBrush(Color.FromArgb(100, p.Color))) - { - // Fill in the area below the line. - e.Graphics.FillPolygon(b, new[] - { - new Point(x, y), - new Point(x + intDivision, yy), - new Point(x + intDivision, height), - new Point(x, height) - }); - - //draw first line - e.Graphics.DrawLine(p, x, y, xx, yy); - } - } - } - } - - - //todo: complete. - if (this.UseSecondLine) - { - for (int i = 0; i <= this.values2.Count - 1; i++) - { - int x = width - intDivision*(values2.Count - i); - int y = height*(value2Max - (int)values2[i])/(value2Max - this.Minimum); - - int xx = width - intDivision*(values2.Count - i + 1); - int yy = (height*(value2Max - (int)values2[i - 1])/(value2Max - this.Minimum)); - - using (Pen p = new Pen(Color.Pink)) - { - // Fill in the area below the line. - e.Graphics.FillPolygon(new SolidBrush(Color.FromArgb(100, p.Color)), new[] - { - new Point(x, y), - new Point(x + intDivision, yy), - new Point(x + intDivision, height), - new Point(x, height) - }); - - //draw first line - e.Graphics.DrawLine(p, x, y, xx, yy); - } - } - } - - // Draw the text, if any. - if (!string.IsNullOrEmpty(this.Text)) - { - using (SolidBrush b = new SolidBrush(this._textBoxColor)) - { - // Draw the background for the text. - e.Graphics.FillRectangle(b, new Rectangle(this._boxPosition, this._boxSize)); - } - - // Draw the text. - TextRenderer.DrawText(e.Graphics, this.Text, this.Font, this._textPosition, _textColor); - } - - //todo: Draw the Border? - //ControlPaint.DrawBorder3D(e.Graphics, 0, 0, this.Width, this.Height, Border3DStyle.Sunken); - } - - private Color _textBoxColor = Color.FromArgb(127, Color.Black); - public Color TextBoxColor - { - get { return _textBoxColor; } - set { _textBoxColor = value; } - } - - private Color _textColor = Color.FromArgb(0, 255, 0); - public Color TextColor - { - get { return _textColor; } - set { _textColor = value; } - } - - private Point _textPosition, _boxPosition; - private Size _textSize, _boxSize; - - private Padding _textMargin = new Padding(3, 3, 3, 3); - public Padding TextMargin - { - get { return _textMargin; } - set { _textMargin = value; } - } - - private Padding _textPadding = new Padding(3, 3, 3, 3); - public Padding TextPadding - { - get { return _textPadding; } - set { _textPadding = value; } - } - - private ContentAlignment _textAlign = ContentAlignment.TopLeft; - public ContentAlignment TextPosition - { - get { return _textAlign; } - set { _textAlign = value; } - } - - private string _text; - public override string Text - { - get { return _text; } - set - { - _text = value; - - _textSize = TextRenderer.MeasureText(this.Text, this.Font); - _boxSize = new Size(_textSize.Width + _textPadding.Left + _textPadding.Right, _textSize.Height + _textPadding.Top + _textPadding.Bottom); - - // work out Y - switch (_textAlign) - { - case ContentAlignment.BottomCenter: - case ContentAlignment.BottomLeft: - case ContentAlignment.BottomRight: - { - _boxPosition.Y = this.Size.Height - _boxSize.Height - _textMargin.Bottom; - break; - } - case ContentAlignment.MiddleCenter: - case ContentAlignment.MiddleLeft: - case ContentAlignment.MiddleRight: - { - _boxPosition.Y = (this.Size.Height - _boxSize.Height) / 2; - break; - } - - case ContentAlignment.TopCenter: - case ContentAlignment.TopLeft: - case ContentAlignment.TopRight: - { - _boxPosition.Y = _textMargin.Top; - break; - } - } - - // work out X - switch (_textAlign) - { - case ContentAlignment.BottomLeft: - case ContentAlignment.MiddleLeft: - case ContentAlignment.TopLeft: - { - _boxPosition.X = _textMargin.Left; - break; - } - case ContentAlignment.BottomCenter: - case ContentAlignment.MiddleCenter: - case ContentAlignment.TopCenter: - { - _boxPosition.X = (this.Size.Width - _boxSize.Width) / 2; - break; - } - case ContentAlignment.BottomRight: - case ContentAlignment.MiddleRight: - case ContentAlignment.TopRight: - { - _boxPosition.X = this.Size.Width - _boxSize.Width - _textMargin.Right; - break; - } - } - - _textPosition = new Point(_boxPosition.X + _textPadding.Left, _boxPosition.Y + _textPadding.Top); - } - } - - - } -} \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/PerformanceAnalyzer.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/PerformanceAnalyzer.cs deleted file mode 100644 index 7d99ab48c..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/PerformanceAnalyzer.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Diagnostics; - -namespace Aga.Controls -{ - /// - /// Is used to analyze code performance - /// - public static class PerformanceAnalyzer - { - public class PerformanceInfo - { - public string Name { get; set; } - public int Count { get; set; } - public double TotalTime { get; set; } - - public Int64 Start { get; set; } - - public PerformanceInfo(string name) - { - this.Name = name; - } - } - - private static readonly Dictionary _performances = new Dictionary(); - - public static IEnumerable Performances - { - get - { - return _performances.Values; - } - } - - [Conditional("DEBUG")] - public static void Start(string pieceOfCode) - { - lock(_performances) - { - PerformanceInfo info; - - if (_performances.ContainsKey(pieceOfCode)) - info = _performances[pieceOfCode]; - else - { - info = new PerformanceInfo(pieceOfCode); - _performances.Add(pieceOfCode, info); - } - - info.Count++; - info.Start = TimeCounter.GetStartValue(); - } - } - - [Conditional("DEBUG")] - public static void Finish(string pieceOfCode) - { - lock (_performances) - { - if (_performances.ContainsKey(pieceOfCode)) - { - PerformanceInfo info = _performances[pieceOfCode]; - info.Count++; - info.TotalTime += TimeCounter.Finish(info.Start); - } - } - } - - public static void Reset() - { - _performances.Clear(); - } - - public static string GenerateReport() - { - return GenerateReport(0); - } - - public static string GenerateReport(string mainPieceOfCode) - { - if (_performances.ContainsKey(mainPieceOfCode)) - return GenerateReport(_performances[mainPieceOfCode].TotalTime); - else - return GenerateReport(0); - } - - public static string GenerateReport(double totalTime) - { - StringBuilder sb = new StringBuilder(); - int len = 0; - foreach (PerformanceInfo info in Performances) - len = Math.Max(info.Name.Length, len); - - sb.AppendLine("Name".PadRight(len) + " Count Total Time, ms Avg. Time, ms Percentage, %"); - sb.AppendLine("----------------------------------------------------------------------------------------------"); - foreach (PerformanceInfo info in Performances) - { - sb.Append(info.Name.PadRight(len)); - double p = 0; - double avgt = 0; - if (totalTime != 0) - p = info.TotalTime / totalTime; - if (info.Count > 0) - avgt = info.TotalTime * 1000 / info.Count; - string c = info.Count.ToString("0,0").PadRight(20); - string tt = (info.TotalTime * 1000).ToString("0,0.00").PadRight(20); - string t = avgt.ToString("0.0000").PadRight(20); - string sp = (p * 100).ToString("###").PadRight(20); - sb.AppendFormat(" " + c + tt + t + sp + "\n"); - } - return sb.ToString(); - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/TextHelper.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/TextHelper.cs deleted file mode 100644 index 79f252391..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/TextHelper.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using System.Drawing; - -namespace Aga.Controls -{ - public static class TextHelper - { - public static StringAlignment TranslateAligment(HorizontalAlignment aligment) - { - switch (aligment) - { - case HorizontalAlignment.Left: - { - return StringAlignment.Near; - } - case HorizontalAlignment.Right: - { - return StringAlignment.Far; - } - default: - { - return StringAlignment.Center; - } - } - } - - public static TextFormatFlags TranslateAligmentToFlag(HorizontalAlignment aligment) - { - switch (aligment) - { - case HorizontalAlignment.Left: - { - return TextFormatFlags.Left; - } - case HorizontalAlignment.Right: - { - return TextFormatFlags.Right; - } - default: - { - return TextFormatFlags.HorizontalCenter; - } - } - } - - public static TextFormatFlags TranslateTrimmingToFlag(StringTrimming trimming) - { - switch (trimming) - { - case StringTrimming.EllipsisCharacter: - { - return TextFormatFlags.EndEllipsis; - } - case StringTrimming.EllipsisPath: - { - return TextFormatFlags.PathEllipsis; - } - case StringTrimming.EllipsisWord: - { - return TextFormatFlags.WordEllipsis; - } - case StringTrimming.Word: - { - return TextFormatFlags.WordBreak; - } - default: - { - return TextFormatFlags.Default; - } - } - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/DrawContext.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/DrawContext.cs deleted file mode 100644 index d3a352494..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/DrawContext.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Drawing; - -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public struct DrawContext - { - public Graphics Graphics; - public Rectangle Bounds; - public Font Font; - public DrawSelectionMode DrawSelection; - public bool DrawFocus; - public NodeControl CurrentEditorOwner; - public bool Enabled; - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/IncrementalSearch.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/IncrementalSearch.cs deleted file mode 100644 index 6010a1c67..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/IncrementalSearch.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Collections.Generic; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - internal class IncrementalSearch - { - private const int SearchTimeout = 300; //end of incremental search timeot in msec - - private readonly TreeViewAdv _tree; - private TreeNodeAdv _currentNode; - private string _searchString = string.Empty; - private DateTime _lastKeyPressed = DateTime.Now; - - public IncrementalSearch(TreeViewAdv tree) - { - _tree = tree; - } - - public void Search(Char value) - { - if (!Char.IsControl(value)) - { - Char ch = Char.ToLowerInvariant(value); - DateTime dt = DateTime.Now; - TimeSpan ts = dt - _lastKeyPressed; - _lastKeyPressed = dt; - if (ts.TotalMilliseconds < SearchTimeout) - { - if (_searchString == value.ToString()) - FirstCharSearch(ch); - else - ContinuousSearch(ch); - } - else - { - FirstCharSearch(ch); - } - } - } - - private void ContinuousSearch(Char value) - { - if (value == ' ' && String.IsNullOrEmpty(_searchString)) - return; //Ingnore leading space - - _searchString += value; - DoContinuousSearch(); - } - - private void FirstCharSearch(Char value) - { - if (value == ' ') - return; - - _searchString = value.ToString(); - TreeNodeAdv node = null; - if (_tree.SelectedNode != null) - node = _tree.SelectedNode.NextVisibleNode; - if (node == null) - node = _tree.Root; - - foreach (string label in IterateNodeLabels(node)) - { - if (label.StartsWith(_searchString)) - { - _tree.SelectedNode = _currentNode; - return; - } - } - } - - public virtual void EndSearch() - { - _currentNode = null; - _searchString = string.Empty; - } - - protected IEnumerable IterateNodeLabels(TreeNodeAdv start) - { - _currentNode = start; - while(_currentNode != null) - { - foreach (string label in GetNodeLabels(_currentNode)) - yield return label; - - _currentNode = _currentNode.NextVisibleNode; - if (_currentNode == null) - _currentNode = _tree.Root; - - if (start == _currentNode) - break; - } - } - - private IEnumerable GetNodeLabels(TreeNodeAdv node) - { - foreach (NodeControl nc in _tree.NodeControls) - { - BindableControl bc = nc as BindableControl; - if (bc != null && bc.IncrementalSearchEnabled) - { - object obj = bc.GetValue(node); - if (obj != null) - yield return obj.ToString().ToLowerInvariant(); - } - } - } - - private void DoContinuousSearch() - { - if (!string.IsNullOrEmpty(_searchString)) - { - TreeNodeAdv node = null; - if (_tree.SelectedNode != null) - node = _tree.SelectedNode; - if (node == null) - node = _tree.Root.NextVisibleNode; - - if (!string.IsNullOrEmpty(_searchString)) - { - foreach (string label in IterateNodeLabels(node)) - { - if (label.StartsWith(_searchString)) - { - _tree.SelectedNode = _currentNode; - break; - } - } - } - } - return; - } - - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ColumnState.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ColumnState.cs deleted file mode 100644 index 676ef6e62..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ColumnState.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Aga.Controls.Tree -{ - internal abstract class ColumnState : InputState - { - public TreeColumn Column { get; private set; } - - protected ColumnState(TreeViewAdv tree, TreeColumn column) - : base(tree) - { - this.Column = column; - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/NormalInputState.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/NormalInputState.cs deleted file mode 100644 index 0c5a429ad..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/NormalInputState.cs +++ /dev/null @@ -1,208 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace Aga.Controls.Tree -{ - internal class NormalInputState : InputState - { - private bool _mouseDownFlag; - - public NormalInputState(TreeViewAdv tree) : base(tree) - { - } - - public override void KeyDown(KeyEventArgs args) - { - if (this.Tree.CurrentNode == null && this.Tree.Root.Nodes.Count > 0) - this.Tree.CurrentNode = this.Tree.Root.Nodes[0]; - - if (this.Tree.CurrentNode != null) - { - switch (args.KeyCode) - { - case Keys.Right: - if (!this.Tree.CurrentNode.IsExpanded) - { - this.Tree.CurrentNode.IsExpanded = true; - // by fliser - this.Tree.FullUpdate(); - } - else if (this.Tree.CurrentNode.Nodes.Count > 0) - this.Tree.SelectedNode = this.Tree.CurrentNode.Nodes[0]; - args.Handled = true; - break; - case Keys.Left: - if (this.Tree.CurrentNode.IsExpanded) - { - this.Tree.CurrentNode.IsExpanded = false; - // by fliser - this.Tree.FullUpdate(); - } - else if (this.Tree.CurrentNode.Parent != this.Tree.Root) - this.Tree.SelectedNode = this.Tree.CurrentNode.Parent; - args.Handled = true; - break; - case Keys.Down: - NavigateForward(1); - args.Handled = true; - break; - case Keys.Up: - NavigateBackward(1); - args.Handled = true; - break; - case Keys.PageDown: - NavigateForward(Math.Max(1, this.Tree.CurrentPageSize - 1)); - args.Handled = true; - break; - case Keys.PageUp: - NavigateBackward(Math.Max(1, this.Tree.CurrentPageSize - 1)); - args.Handled = true; - break; - case Keys.Home: - if (this.Tree.RowMap.Count > 0) - FocusRow(this.Tree.RowMap[0]); - args.Handled = true; - break; - case Keys.End: - if (this.Tree.RowMap.Count > 0) - FocusRow(this.Tree.RowMap[this.Tree.RowMap.Count-1]); - args.Handled = true; - break; - case Keys.Subtract: - this.Tree.CurrentNode.Collapse(); - // by fliser - this.Tree.FullUpdate(); - args.Handled = true; - args.SuppressKeyPress = true; - break; - case Keys.Add: - this.Tree.CurrentNode.Expand(); - // by fliser - this.Tree.FullUpdate(); - args.Handled = true; - args.SuppressKeyPress = true; - break; - case Keys.Multiply: - this.Tree.CurrentNode.ExpandAll(); - // by fliser - this.Tree.FullUpdate(); - args.Handled = true; - args.SuppressKeyPress = true; - break; - } - } - } - - public override void MouseDown(TreeNodeAdvMouseEventArgs args) - { - if (args.Node != null) - { - if (args.Button == MouseButtons.Left || args.Button == MouseButtons.Right) - { - this.Tree.BeginUpdate(); - try - { - this.Tree.CurrentNode = args.Node; - - if (args.Node.IsSelected) - _mouseDownFlag = true; - else - { - _mouseDownFlag = false; - DoMouseOperation(args); - } - } - finally - { - this.Tree.EndUpdate(); - } - } - - } - else - { - MouseDownAtEmptySpace(args); - } - } - - public override void MouseUp(TreeNodeAdvMouseEventArgs args) - { - if (_mouseDownFlag) - { - switch (args.Button) - { - case MouseButtons.Left: - this.DoMouseOperation(args); - break; - case MouseButtons.Right: - this.Tree.CurrentNode = args.Node; - break; - } - } - _mouseDownFlag = false; - } - - - private void NavigateBackward(int n) - { - int row = Math.Max(this.Tree.CurrentNode.Row - n, 0); - if (row != this.Tree.CurrentNode.Row) - FocusRow(this.Tree.RowMap[row]); - } - - private void NavigateForward(int n) - { - int row = Math.Min(this.Tree.CurrentNode.Row + n, this.Tree.RowCount - 1); - if (row != this.Tree.CurrentNode.Row) - FocusRow(this.Tree.RowMap[row]); - } - - protected virtual void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args) - { - this.Tree.ClearSelectionInternal(); - } - - protected virtual void FocusRow(TreeNodeAdv node) - { - this.Tree.SuspendSelectionEvent = true; - try - { - this.Tree.ClearSelectionInternal(); - this.Tree.CurrentNode = node; - this.Tree.SelectionStart = node; - node.IsSelected = true; - this.Tree.ScrollTo(node); - } - finally - { - this.Tree.SuspendSelectionEvent = false; - } - } - - protected bool CanSelect(TreeNodeAdv node) - { - if (this.Tree.SelectionMode == TreeSelectionMode.MultiSameParent) - { - return (this.Tree.SelectionStart == null || node.Parent == this.Tree.SelectionStart.Parent); - } - - return true; - } - - protected virtual void DoMouseOperation(TreeNodeAdvMouseEventArgs args) - { - this.Tree.SuspendSelectionEvent = true; - try - { - this.Tree.ClearSelectionInternal(); - if (args.Node != null) - args.Node.IsSelected = true; - this.Tree.SelectionStart = args.Node; - } - finally - { - this.Tree.SuspendSelectionEvent = false; - } - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControlInfo.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControlInfo.cs deleted file mode 100644 index 25d772ea9..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControlInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Aga.Controls.Tree.NodeControls; -using System.Drawing; - -namespace Aga.Controls.Tree -{ - public struct NodeControlInfo - { - public static readonly NodeControlInfo Empty = new NodeControlInfo(null, Rectangle.Empty, null); - - public NodeControl Control; - public Rectangle Bounds; - public TreeNodeAdv Node; - - public NodeControlInfo(NodeControl control, Rectangle bounds, TreeNodeAdv node) : this() - { - this.Control = control; - this.Bounds = bounds; - this.Node = node; - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/BindableControl.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/BindableControl.cs deleted file mode 100644 index 2bc33036a..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/BindableControl.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System; -using System.Reflection; -using System.ComponentModel; - -namespace Aga.Controls.Tree.NodeControls -{ - public abstract class BindableControl : NodeControl - { - private struct MemberAdapter - { - private object _obj; - private PropertyInfo _pi; - private FieldInfo _fi; - - public static readonly MemberAdapter Empty; - - public Type MemberType - { - get - { - if (_pi != null) - return _pi.PropertyType; - - if (_fi != null) - return _fi.FieldType; - - return null; - } - } - - public object Value - { - get - { - if (_pi != null && _pi.CanRead) - return _pi.GetValue(_obj, null); - - if (_fi != null) - return _fi.GetValue(_obj); - - return null; - } - set - { - if (_pi != null && _pi.CanWrite) - _pi.SetValue(_obj, value, null); - else if (_fi != null) - _fi.SetValue(_obj, value); - } - } - - public MemberAdapter(object obj, PropertyInfo pi) - { - _obj = obj; - _pi = pi; - _fi = null; - } - - public MemberAdapter(object obj, FieldInfo fi) - { - _obj = obj; - _fi = fi; - _pi = null; - } - } - - #region Properties - - [DefaultValue(false), Category("Data")] - public bool VirtualMode { get; set; } - - protected BindableControl() - { - this.DataPropertyName = string.Empty; - } - - [DefaultValue(""), Category("Data")] - public string DataPropertyName { get; set; } - - [DefaultValue(false)] - public bool IncrementalSearchEnabled { get; set; } - - #endregion - - public virtual object GetValue(TreeNodeAdv node) - { - if (this.VirtualMode) - { - NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); - OnValueNeeded(args); - return args.Value; - } - - return this.GetMemberAdapter(node).Value; - } - - public virtual void SetValue(TreeNodeAdv node, object value) - { - if (this.VirtualMode) - { - NodeControlValueEventArgs args = new NodeControlValueEventArgs(node) - { - Value = value - }; - - OnValuePushed(args); - } - else - { - MemberAdapter ma = GetMemberAdapter(node); - - ma.Value = value; - } - } - - public Type GetPropertyType(TreeNodeAdv node) - { - return GetMemberAdapter(node).MemberType; - } - - private MemberAdapter GetMemberAdapter(TreeNodeAdv node) - { - - MemberAdapter adapter = MemberAdapter.Empty; - - if (node.Tag != null && !string.IsNullOrEmpty(this.DataPropertyName)) - { - Type type = node.Tag.GetType(); - PropertyInfo pi = type.GetProperty(this.DataPropertyName); - - if (pi != null) - { - return new MemberAdapter(node.Tag, pi); - } - - FieldInfo fi = type.GetField(this.DataPropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - - if (fi != null) - return new MemberAdapter(node.Tag, fi); - } - - return adapter; - } - - public override string ToString() - { - if (string.IsNullOrEmpty(this.DataPropertyName)) - return GetType().Name; - - return this.GetType().Name + " (" + this.DataPropertyName + ")"; - } - - public event EventHandler ValueNeeded; - private void OnValueNeeded(NodeControlValueEventArgs args) - { - if (this.ValueNeeded != null) - this.ValueNeeded(this, args); - } - - public event EventHandler ValuePushed; - private void OnValuePushed(NodeControlValueEventArgs args) - { - if (this.ValuePushed != null) - this.ValuePushed(this, args); - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/DrawEventArgs.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/DrawEventArgs.cs deleted file mode 100644 index ce83c907b..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/DrawEventArgs.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Drawing; - -namespace Aga.Controls.Tree.NodeControls -{ - public class DrawEventArgs : NodeEventArgs - { - public DrawContext Context { get; private set; } - public Brush BackgroundBrush { get; set; } - public Font Font { get; set; } - public Color TextColor { get; set; } - public string Text { get; private set; } - - public DrawEventArgs(TreeNodeAdv node, DrawContext context, string text) - : base(node) - { - this.Context = context; - this.Text = text; - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControlValueEventArgs.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControlValueEventArgs.cs deleted file mode 100644 index 64697454b..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControlValueEventArgs.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeControlValueEventArgs : NodeEventArgs - { - public object Value { get; set; } - - public NodeControlValueEventArgs(TreeNodeAdv node) - :base(node) - { - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeEventArgs.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeEventArgs.cs deleted file mode 100644 index d5cd00d67..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeEventArgs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace Aga.Controls.Tree.NodeControls -{ - public class NodeEventArgs : EventArgs - { - public TreeNodeAdv Node { get; private set; } - - public NodeEventArgs(TreeNodeAdv node) - { - this.Node = node; - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeNodeAdvMouseEventArgs.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeNodeAdvMouseEventArgs.cs deleted file mode 100644 index f39706790..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeNodeAdvMouseEventArgs.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Windows.Forms; -using System.Drawing; -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public class TreeNodeAdvMouseEventArgs : MouseEventArgs - { - public TreeNodeAdv Node { get; internal set; } - public NodeControl Control { get; internal set; } - public Point ViewLocation { get; internal set; } - public Keys ModifierKeys { get; internal set; } - public bool Handled { get; set; } - public Rectangle ControlBounds { get; internal set; } - - public TreeNodeAdvMouseEventArgs(MouseEventArgs args) - : base(args.Button, args.Clicks, args.X, args.Y, args.Delta) - { - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Draw.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Draw.cs deleted file mode 100644 index 451e7fa41..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Draw.cs +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Modified by wj32. - */ - -using System; -using System.Windows.Forms; -using System.Drawing; -using System.Drawing.Drawing2D; - -namespace Aga.Controls.Tree -{ - public sealed partial class TreeViewAdv - { - private void CreatePens() - { - CreateLinePen(); - } - - private void CreateLinePen() - { - _linePen = new Pen(_lineColor) - { - DashStyle = DashStyle.Dot - }; - } - - protected override void OnPaint(PaintEventArgs e) - { -#if DEBUG - this.BeginPerformanceCount(); -#endif - DrawContext context = new DrawContext - { - Graphics = e.Graphics, - Font = this.Font, - Enabled = Enabled - }; - - this.DrawColumnHeaders(e.Graphics); - - int y = this.ColumnHeaderHeight; - - if (this.Columns.Count == 0 || e.ClipRectangle.Height <= y) - return; - - int firstRowY = _rowLayout.GetRowBounds(this.FirstVisibleRow).Y; - - y -= firstRowY; - - e.Graphics.ResetTransform(); - e.Graphics.TranslateTransform(-OffsetX, y); - - Rectangle displayRect = e.ClipRectangle; - - for (int row = this.FirstVisibleRow; row < this.RowCount; row++) - { - Rectangle rowRect = _rowLayout.GetRowBounds(row); - - if (rowRect.Y + y > displayRect.Bottom) - break; - - this.DrawRow(e, ref context, row, rowRect); - } - - e.Graphics.ResetTransform(); - - this.DrawScrollBarsBox(e.Graphics); - -#if DEBUG - this.EndPerformanceCount(e); -#endif - } - - private void DrawRow(PaintEventArgs e, ref DrawContext context, int row, Rectangle rowRect) - { - TreeNodeAdv node = this.RowMap[row]; - - context.DrawSelection = DrawSelectionMode.None; - context.CurrentEditorOwner = _currentEditorOwner; - - bool focused = this.Focused; - - if (node.IsSelected && focused) - { - context.DrawSelection = DrawSelectionMode.Active; - } - else if (node.IsSelected && !focused && !this.HideSelection) - { - context.DrawSelection = DrawSelectionMode.Inactive; - } - - Rectangle focusRect = new Rectangle(OffsetX, rowRect.Y, this.Width - (this._vScrollBar.Visible ? this._vScrollBar.Width : 0), rowRect.Height); - - context.DrawFocus = false; - - if (context.DrawSelection != DrawSelectionMode.Active) - { - using (SolidBrush b = new SolidBrush(node.BackColor)) - { - e.Graphics.FillRectangle(b, focusRect); - } - } - - if (context.DrawSelection == DrawSelectionMode.Active || context.DrawSelection == DrawSelectionMode.Inactive) - { - if (context.DrawSelection == DrawSelectionMode.Active) - { - context.DrawSelection = DrawSelectionMode.FullRowSelect; - - if (ExplorerVisualStyle.VisualStylesEnabled) - { - ExplorerVisualStyle.TvItemSelectedRenderer.DrawBackground(context.Graphics, focusRect); - } - else - { - e.Graphics.FillRectangle(SystemBrushes.Highlight, focusRect); - } - } - else - { - context.DrawSelection = DrawSelectionMode.None; - } - } - - this.DrawNode(node, context); - } - - private void DrawColumnHeaders(Graphics gr) - { - ReorderColumnState reorder = this.Input as ReorderColumnState; - - int x = 0; - - TreeColumn.DrawBackground(gr, new Rectangle(0, 0, ClientRectangle.Width + 2, this.ColumnHeaderHeight - 1), false, false); - - gr.TranslateTransform(-OffsetX, 0); - - foreach (TreeColumn c in this.Columns) - { - if (!c.IsVisible) - continue; - - if (x + c.Width >= this.OffsetX && x - this.OffsetX < this.Bounds.Width)// skip invisible columns (fixed by wj32) - { - Rectangle rect = new Rectangle(x, 0, c.Width, this.ColumnHeaderHeight - 1); - - gr.SetClip(rect); - - bool pressed = ((this.Input is ClickColumnState || reorder != null) && ((this.Input as ColumnState).Column == c)); - - c.Draw(gr, rect, this.Font, pressed, this._hotColumn == c); - - gr.ResetClip(); - - if (reorder != null && reorder.DropColumn == c) - { - TreeColumn.DrawDropMark(gr, rect); - } - } - x += c.Width; - } - - if (reorder != null) - { - if (reorder.DropColumn == null) - { - TreeColumn.DrawDropMark(gr, new Rectangle(x, 0, 0, this.ColumnHeaderHeight)); - } - - gr.DrawImage(reorder.GhostImage, new Point(reorder.Location.X + + reorder.DragOffset, reorder.Location.Y)); - } - } - - public void DrawNode(TreeNodeAdv node, DrawContext context) - { - //todo, node collection needs locking. - foreach (NodeControlInfo item in GetNodeControls(node)) - { - if (item.Bounds.X + item.Bounds.Width >= OffsetX && item.Bounds.X - OffsetX < this.Bounds.Width)// skip invisible nodes (fixed by wj32) - { - context.Bounds = item.Bounds; - - context.Graphics.SetClip(context.Bounds); - - item.Control.Draw(node, context); - - context.Graphics.ResetClip(); - } - } - } - - private void DrawScrollBarsBox(Graphics gr) - { - Rectangle r1 = this.DisplayRectangle; - Rectangle r2 = this.ClientRectangle; - - gr.FillRectangle(SystemBrushes.Control, new Rectangle(r1.Right, r1.Bottom, r2.Width - r1.Width, r2.Height - r1.Height)); - } - - private double _totalTime; - private int _paintCount; - - private void BeginPerformanceCount() - { - _paintCount++; - TimeCounter.Start(); - } - - private void EndPerformanceCount(PaintEventArgs e) - { - double time = TimeCounter.Finish(); - _totalTime += time; - - string debugText = string.Format("FPS {0:0.0}; Avg. FPS {1:0.0}", 1 / time, 1 / (_totalTime / _paintCount)); - - e.Graphics.FillRectangle(Brushes.White, new Rectangle(this.DisplayRectangle.Width - 150, this.DisplayRectangle.Height - 20, 150, 20)); - - TextRenderer.DrawText(e.Graphics, debugText, this.Font, new Point(this.DisplayRectangle.Width - 150, this.DisplayRectangle.Height - 20), Color.Black); - - //e.Graphics.DrawString(debugText, this.Font, Brushes.Gray, new PointF(DisplayRectangle.Width - 150, DisplayRectangle.Height - 20)); - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Properties.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Properties.cs deleted file mode 100644 index 32f2316b7..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Properties.cs +++ /dev/null @@ -1,454 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; -using System.Collections.ObjectModel; -using System.Drawing.Design; - -using Aga.Controls.Tree.NodeControls; - -namespace Aga.Controls.Tree -{ - public sealed partial class TreeViewAdv - { - private Cursor _innerCursor; - - public override Cursor Cursor - { - get - { - if (_innerCursor != null) - return _innerCursor; - - return base.Cursor; - } - set { base.Cursor = value; } - } - - #region Internal Properties - - private IRowLayout _rowLayout; - - public int ColumnHeaderHeight { get; private set; } - - /// - /// returns all nodes, which parent is expanded - /// - private IEnumerable VisibleNodes - { - get - { - TreeNodeAdv node = this.Root; - - while (node != null) - { - node = node.NextVisibleNode; - - if (node != null) - yield return node; - } - } - } - - private bool _suspendSelectionEvent; - internal bool SuspendSelectionEvent - { - get { return _suspendSelectionEvent; } - set - { - if (value != _suspendSelectionEvent) - { - _suspendSelectionEvent = value; - if (!_suspendSelectionEvent && _fireSelectionEvent) - OnSelectionChanged(); - } - } - } - - internal List RowMap { get; private set; } - internal TreeNodeAdv SelectionStart { get; set; } - internal InputState Input { get; set; } - - /// - /// Number of rows fits to the current page - /// - internal int CurrentPageSize - { - get { return _rowLayout.CurrentPageSize; } - } - - /// - /// Number of all visible nodes (which parent is expanded) - /// - internal int RowCount - { - get { return this.RowMap.Count; } - } - - private int ContentWidth { get; set; } - - private int _firstVisibleRow; - internal int FirstVisibleRow - { - get { return _firstVisibleRow; } - set - { - HideEditor(); - - _firstVisibleRow = value; - - UpdateView(); - } - } - - private int _offsetX; - internal int OffsetX - { - get { return _offsetX; } - private set - { - HideEditor(); - - _offsetX = value; - - UpdateView(); - } - } - - public override Rectangle DisplayRectangle - { - get - { - Rectangle r = ClientRectangle; - //r.Y += ColumnHeaderHeight; - //r.Height -= ColumnHeaderHeight; - int w = _vScrollBar.Visible ? _vScrollBar.Width : 0; - int h = _hScrollBar.Visible ? _hScrollBar.Height : 0; - return new Rectangle(r.X, r.Y, r.Width - w, r.Height - h); - } - } - - internal List Selection { get; private set; } - - #endregion - - #region Public Properties - - #region DesignTime - - private bool _showLines = true; - [DefaultValue(true), Category("Behavior")] - public bool ShowLines - { - get { return _showLines; } - set - { - _showLines = value; - UpdateView(); - } - } - - private bool _showPlusMinus = true; - [DefaultValue(true), Category("Behavior")] - public bool ShowPlusMinus - { - get { return _showPlusMinus; } - set - { - _showPlusMinus = value; - FullUpdate(); - } - } - - [DefaultValue(false), Category("Behavior")] - public bool ShowNodeToolTips { get; set; } - - private ITreeModel _model; - [Category("Data")] - public ITreeModel Model - { - get { return _model; } - set - { - if (_model != value) - { - if (_model != null) - UnbindModelEvents(); - - _model = value; - - CreateNodes(); - FullUpdate(); - - if (_model != null) - BindModelEvents(); - } - } - } - - // Font proprety for Tahoma as default font - // wj32: Apparently some people don't have Tahoma... - //private static Font _font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)), false); - private static Font _font = DefaultFont; - [Category("Appearance")] - public override Font Font - { - get - { - return (base.Font); - } - set - { - if (value == null) - base.Font = _font; - else - { - if (value == Control.DefaultFont) - base.Font = _font; - else - base.Font = value; - } - } - } - public override void ResetFont() - { - Font = null; - } - private bool ShouldSerializeFont() - { - return (!Font.Equals(_font)); - } - // End font property - - private BorderStyle _borderStyle = BorderStyle.Fixed3D; - [DefaultValue(BorderStyle.Fixed3D), Category("Appearance")] - public BorderStyle BorderStyle - { - get { return this._borderStyle; } - set - { - if (_borderStyle != value) - { - _borderStyle = value; - - this.RecreateHandle(); - this.Invalidate(); - } - } - } - - private bool _autoRowHeight; - [DefaultValue(false), Category("Appearance")] - public bool AutoRowHeight - { - get { return _autoRowHeight; } - set - { - _autoRowHeight = value; - if (value) - _rowLayout = new AutoRowHeightLayout(this, RowHeight); - else - _rowLayout = new FixedRowHeightLayout(this, RowHeight); - FullUpdate(); - } - } - - private int _rowHeight = 16; - [DefaultValue(16), Category("Appearance")] - public int RowHeight - { - get - { - return _rowHeight; - } - set - { - if (value <= 0) - throw new ArgumentOutOfRangeException("value"); - - _rowHeight = value; - _rowLayout.PreferredRowHeight = value; - FullUpdate(); - } - } - - private TreeSelectionMode _selectionMode = TreeSelectionMode.Single; - [DefaultValue(TreeSelectionMode.Single), Category("Behavior")] - public TreeSelectionMode SelectionMode - { - get { return _selectionMode; } - set { _selectionMode = value; } - } - - private bool _hideSelection; - [DefaultValue(false), Category("Behavior")] - public bool HideSelection - { - get { return _hideSelection; } - set - { - _hideSelection = value; - UpdateView(); - } - } - - private float _topEdgeSensivity = 0.3f; - [DefaultValue(0.3f), Category("Behavior")] - public float TopEdgeSensivity - { - get { return _topEdgeSensivity; } - set - { - if (value < 0 || value > 1) - throw new ArgumentOutOfRangeException(); - _topEdgeSensivity = value; - } - } - - private float _bottomEdgeSensivity = 0.3f; - [DefaultValue(0.3f), Category("Behavior")] - public float BottomEdgeSensivity - { - get { return _bottomEdgeSensivity; } - set - { - if (value < 0 || value > 1) - throw new ArgumentOutOfRangeException("BottomEdgeSensivity", "value should be from 0 to 1"); - _bottomEdgeSensivity = value; - } - } - - [DefaultValue(false), Category("Behavior")] - public bool LoadOnDemand { get; set; } - - private int _indent = 19; - [DefaultValue(19), Category("Behavior")] - public int Indent - { - get { return _indent; } - set - { - _indent = value; - UpdateView(); - } - } - - private Color _lineColor = SystemColors.ControlDark; - [Category("Behavior")] - public Color LineColor - { - get { return _lineColor; } - set - { - _lineColor = value; - CreateLinePen(); - UpdateView(); - } - } - - [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] - public TreeColumnCollection Columns { get; private set; } - - [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Editor(typeof(NodeControlCollectionEditor), typeof(UITypeEditor))] - public NodeControlsCollection NodeControls { get; private set; } - - #endregion - - #region RunTime - - [Browsable(false)] - public IToolTipProvider DefaultToolTipProvider { get; set; } - - [Browsable(false)] - public IEnumerable AllNodes - { - get - { - if (this.Root.Nodes.Count > 0) - { - TreeNodeAdv node = this.Root.Nodes[0]; - - while (node != null) - { - yield return node; - - if (node.Nodes.Count > 0) - node = node.Nodes[0]; - else if (node.NextNode != null) - node = node.NextNode; - else - node = node.BottomNode; - } - } - } - } - - [Browsable(false)] - public TreeNodeAdv Root { get; private set; } - - [Browsable(false)] - public ReadOnlyCollection SelectedNodes { get; private set; } - - [Browsable(false)] - public TreeNodeAdv SelectedNode - { - get - { - if (this.Selection.Count > 0) - { - if (this.CurrentNode != null && this.CurrentNode.IsSelected) - return this.CurrentNode; - - return this.Selection[0]; - } - - return null; - } - set - { - if (SelectedNode == value) - return; - - BeginUpdate(); - - try - { - if (value == null) - { - ClearSelectionInternal(); - } - else - { - if (!IsMyNode(value)) - throw new ArgumentException(); - - ClearSelectionInternal(); - value.IsSelected = true; - this.CurrentNode = value; - EnsureVisible(value); - } - } - finally - { - EndUpdate(); - } - } - } - - [Browsable(false)] - public TreeNodeAdv CurrentNode { get; internal set; } - - [Browsable(false)] - public int ItemCount - { - get { return this.RowMap.Count; } - } - - #endregion - - #endregion - - } -} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdvEventArgs.cs b/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdvEventArgs.cs deleted file mode 100644 index a2e88438e..000000000 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdvEventArgs.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace Aga.Controls.Tree -{ - public class TreeViewAdvEventArgs : EventArgs - { - public TreeNodeAdv Node { get; private set; } - - public TreeViewAdvEventArgs(TreeNodeAdv node) - { - this.Node = node; - } - } -} diff --git a/1.x/trunk/ProcessHacker/Components/VerticleProgressBar.cs b/1.x/trunk/ProcessHacker/Components/VerticleProgressBar.cs index ddde1dcaa..45693bae4 100644 --- a/1.x/trunk/ProcessHacker/Components/VerticleProgressBar.cs +++ b/1.x/trunk/ProcessHacker/Components/VerticleProgressBar.cs @@ -20,7 +20,12 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; +using System.Data; +using System.Text; using System.Windows.Forms; using System.Windows.Forms.VisualStyles; diff --git a/1.x/trunk/ProcessHacker/Components/VistaMenu/OwnerDrawnMenu.cs b/1.x/trunk/ProcessHacker/Components/VistaMenu/OwnerDrawnMenu.cs new file mode 100644 index 000000000..10cab6d31 --- /dev/null +++ b/1.x/trunk/ProcessHacker/Components/VistaMenu/OwnerDrawnMenu.cs @@ -0,0 +1,235 @@ +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + + +namespace wyDay.Controls +{ + public partial class VistaMenu + { + ContainerControl ownerForm; + + //conditionally draw the little lines under menu items with keyboard accelators on Win 2000+ + private bool isUsingKeyboardAccel; + + + public VistaMenu(ContainerControl parentControl) + : this() + { + ownerForm = parentControl; + } + public ContainerControl ContainerControl + { + get { return ownerForm; } + set { ownerForm = value; } + } + public override ISite Site + { + set + { + // Runs at design time, ensures designer initializes ContainerControl + base.Site = value; + if (value == null) return; + IDesignerHost service = value.GetService(typeof(IDesignerHost)) as IDesignerHost; + if (service == null) return; + IComponent rootComponent = service.RootComponent; + ContainerControl = rootComponent as ContainerControl; + } + } + + + void ownerForm_ChangeUICues(object sender, UICuesEventArgs e) + { + isUsingKeyboardAccel = e.ShowKeyboard; + } + + + const int SEPARATOR_HEIGHT = 9; + const int BORDER_VERTICAL = 4; + const int LEFT_MARGIN = 4; + const int RIGHT_MARGIN = 6; + const int SHORTCUT_MARGIN = 20; + const int ARROW_MARGIN = 12; + const int ICON_SIZE = 16; + + + static void MenuItem_MeasureItem(object sender, MeasureItemEventArgs e) + { + Font font = ((MenuItem)sender).DefaultItem + ? new Font(SystemFonts.MenuFont, FontStyle.Bold) + : SystemFonts.MenuFont; + + if (((MenuItem)sender).Text == "-") + e.ItemHeight = SEPARATOR_HEIGHT; + else + { + e.ItemHeight = ((SystemFonts.MenuFont.Height > ICON_SIZE) ? SystemFonts.MenuFont.Height : ICON_SIZE) + + BORDER_VERTICAL; + + e.ItemWidth = LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN + + //item text width + + TextRenderer.MeasureText(((MenuItem)sender).Text, font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping).Width + + SHORTCUT_MARGIN + + //shortcut text width + + TextRenderer.MeasureText(ShortcutToString(((MenuItem)sender).Shortcut), font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping).Width + + //arrow width + + ((((MenuItem)sender).IsParent) ? ARROW_MARGIN : 0); + } + } + + void MenuItem_DrawItem(object sender, DrawItemEventArgs e) + { + e.Graphics.CompositingQuality = CompositingQuality.HighSpeed; + e.Graphics.InterpolationMode = InterpolationMode.Low; + + bool menuSelected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; + + if (menuSelected) + e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); + else + e.Graphics.FillRectangle(SystemBrushes.Menu, e.Bounds); + + if (((MenuItem)sender).Text == "-") + { + //draw the separator + int yCenter = e.Bounds.Top + (e.Bounds.Height / 2) - 1; + + e.Graphics.DrawLine(SystemPens.ControlDark, e.Bounds.Left + 1, yCenter, (e.Bounds.Left + e.Bounds.Width - 2), yCenter); + e.Graphics.DrawLine(SystemPens.ControlLightLight, e.Bounds.Left + 1, yCenter + 1, (e.Bounds.Left + e.Bounds.Width - 2), yCenter + 1); + } + else //regular menu items + { + //draw the item text + DrawText(sender, e, menuSelected); + + if (((MenuItem)sender).Checked) + { + if (((MenuItem)sender).RadioCheck) + { + //draw the bullet + ControlPaint.DrawMenuGlyph(e.Graphics, + e.Bounds.Left + (LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN - SystemInformation.MenuCheckSize.Width) / 2, + e.Bounds.Top + (e.Bounds.Height - SystemInformation.MenuCheckSize.Height) / 2 + 1, + SystemInformation.MenuCheckSize.Width, + SystemInformation.MenuCheckSize.Height, + MenuGlyph.Bullet, + menuSelected ? SystemColors.HighlightText : SystemColors.MenuText, + menuSelected ? SystemColors.Highlight : SystemColors.Menu); + } + else + { + //draw the check mark + ControlPaint.DrawMenuGlyph(e.Graphics, + e.Bounds.Left + (LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN - SystemInformation.MenuCheckSize.Width) / 2, + e.Bounds.Top + (e.Bounds.Height - SystemInformation.MenuCheckSize.Height) / 2 + 1, + SystemInformation.MenuCheckSize.Width, + SystemInformation.MenuCheckSize.Height, + MenuGlyph.Checkmark, + menuSelected ? SystemColors.HighlightText : SystemColors.MenuText, + menuSelected ? SystemColors.Highlight : SystemColors.Menu); + } + } + else + { + Image drawImg = EnsurePropertiesExists((MenuItem)sender).PreVistaBitmap; + + if (drawImg != null) + { + //draw the image + if (((MenuItem)sender).Enabled) + e.Graphics.DrawImage(drawImg, e.Bounds.Left + LEFT_MARGIN, + e.Bounds.Top + ((e.Bounds.Height - ICON_SIZE) / 2), + ICON_SIZE, ICON_SIZE); + else + ControlPaint.DrawImageDisabled(e.Graphics, drawImg, + e.Bounds.Left + LEFT_MARGIN, + e.Bounds.Top + ((e.Bounds.Height - ICON_SIZE) / 2), + SystemColors.Menu); + } + } + } + } + + + private static string ShortcutToString(Shortcut shortcut) + { + if (shortcut != Shortcut.None) + { + Keys keys = (Keys)shortcut; + return TypeDescriptor.GetConverter(keys.GetType()).ConvertToString(keys); + } + + return null; + } + + private void DrawText(object sender, DrawItemEventArgs e, bool isSelected) + { + string shortcutText = ShortcutToString(((MenuItem)sender).Shortcut); + + int yPos = e.Bounds.Top + (e.Bounds.Height - SystemFonts.MenuFont.Height) / 2; + + Font font = ((MenuItem)sender).DefaultItem + ? new Font(SystemFonts.MenuFont, FontStyle.Bold) + : SystemFonts.MenuFont; + + Size textSize = TextRenderer.MeasureText(((MenuItem)sender).Text, + font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping); + + Rectangle textRect = new Rectangle(e.Bounds.Left + LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN, yPos, + textSize.Width, textSize.Height); + + if (!((MenuItem)sender).Enabled && !isSelected) // disabled and not selected + { + textRect.Offset(1, 1); + + TextRenderer.DrawText(e.Graphics, ((MenuItem)sender).Text, font, + textRect, + SystemColors.ControlLightLight, + TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix) | TextFormatFlags.NoClipping); + + textRect.Offset(-1, -1); + } + + //Draw the menu item text + TextRenderer.DrawText(e.Graphics, ((MenuItem)sender).Text, font, + textRect, + ((MenuItem)sender).Enabled ? (isSelected ? SystemColors.HighlightText : SystemColors.MenuText) : SystemColors.GrayText, + TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix) | TextFormatFlags.NoClipping); + + + + //Draw the shortcut text + if (shortcutText != null) + { + textSize = TextRenderer.MeasureText(shortcutText, + font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping); + + + textRect = new Rectangle(e.Bounds.Width - textSize.Width - ARROW_MARGIN, yPos, textSize.Width, + textSize.Height); + + if (!((MenuItem)sender).Enabled && !isSelected) // disabled and not selected + { + textRect.Offset(1, 1); + + TextRenderer.DrawText(e.Graphics, shortcutText, font, + textRect, + SystemColors.ControlLightLight, + TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix) | TextFormatFlags.NoClipping); + + textRect.Offset(-1, -1); + } + + TextRenderer.DrawText(e.Graphics, shortcutText, font, + textRect, + ((MenuItem)sender).Enabled ? (isSelected ? SystemColors.HighlightText : SystemColors.MenuText) : SystemColors.GrayText, + TextFormatFlags.SingleLine | TextFormatFlags.NoClipping); + } + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/VistaMenu/VistaMenu.cs b/1.x/trunk/ProcessHacker/Components/VistaMenu/VistaMenu.cs new file mode 100644 index 000000000..60c06b132 --- /dev/null +++ b/1.x/trunk/ProcessHacker/Components/VistaMenu/VistaMenu.cs @@ -0,0 +1,411 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using ProcessHacker.Native; + + +//VistaMenu v1.7, created by Wyatt O'Day +//Visit: http://wyday.com/vistamenu/ + +namespace wyDay.Controls +{ + //Properties for the MenuItem + internal class Properties + { + public Image Image; + public IntPtr renderBmpHbitmap = IntPtr.Zero; + public Bitmap PreVistaBitmap; + } + + //enum WindowsType { VistaOrLater, XP, PreXP } + + [ProvideProperty("Image", typeof(MenuItem))] + public partial class VistaMenu : Component, IExtenderProvider, ISupportInitialize + { + private Container components; + private readonly Hashtable properties = new Hashtable(); + private readonly Hashtable menuParents = new Hashtable(); + + private bool formHasBeenIntialized; + + // performance hacks + private Queue> _pendingSetImageCalls = + new Queue>(); + + private static bool _firstVistaMenu = true; + private bool _delaySetImageCalls = false; + + public bool DelaySetImageCalls + { + get { return _delaySetImageCalls; } + set { _delaySetImageCalls = value; } + } + + #region Imports + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern bool SetMenuItemInfo(HandleRef hMenu, int uItem, bool fByPosition, MENUITEMINFO_T_RW lpmii); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern bool SetMenuInfo(HandleRef hMenu, MENUINFO lpcmi); + + [DllImport("gdi32.dll")] + public static extern bool DeleteObject(IntPtr hObject); + + #endregion + + + public VistaMenu() + { + InitializeComponent(); + } + + public VistaMenu(IContainer container) + : this() + { + container.Add(this); + + if (_firstVistaMenu) + { + _delaySetImageCalls = true; + _firstVistaMenu = false; + } + } + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new Container(); + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + //release all the HBitmap handles created + foreach (DictionaryEntry de in properties) + { + if (((Properties)de.Value).renderBmpHbitmap != IntPtr.Zero) + DeleteObject(((Properties)de.Value).renderBmpHbitmap); + if (((Properties)de.Value).PreVistaBitmap != null) + ((Properties)de.Value).PreVistaBitmap.Dispose(); + } + + + if (components != null) + { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + bool IExtenderProvider.CanExtend(object o) + { + if (o is MenuItem) + { + // reject the menuitem if it's a top level element on a MainMenu bar + if (((MenuItem)o).Parent != null) + return ((MenuItem)o).Parent.GetType() != typeof(MainMenu); + + // parent is null - meaning it's a context menu + return true; + } + + if (o is Form) + return true; + + return false; + } + + private Properties EnsurePropertiesExists(MenuItem key) + { + Properties p = (Properties)properties[key]; + + if (p == null) + { + p = new Properties(); + + properties[key] = p; + } + + return p; + } + + + #region MenuItem.Image + + [DefaultValue(null)] + [Description("The Image for the MenuItem")] + [Category("Appearance")] + public Image GetImage(MenuItem mnuItem) + { + return EnsurePropertiesExists(mnuItem).Image; + } + + [DefaultValue(null)] + public void SetImage(MenuItem mnuItem, Image value) + { + this.SetImage(mnuItem, value, false); + } + + public void SetImage(MenuItem mnuItem, Image value, bool ignorePending) + { + if (_delaySetImageCalls && !ignorePending) + { + _pendingSetImageCalls.Enqueue(new KeyValuePair(mnuItem, value)); + return; + } + + Properties prop = EnsurePropertiesExists(mnuItem); + + if (DesignMode) + prop.Image = value; + + if (!DesignMode && OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) + { + //Destroy old bitmap object + if (prop.renderBmpHbitmap != IntPtr.Zero) + { + DeleteObject(prop.renderBmpHbitmap); + prop.renderBmpHbitmap = IntPtr.Zero; + } + + //if there's no Image, then just bail out + if (value == null) + { + // wj32: clean up resources before doing that... + RemoveVistaMenuItem(mnuItem); + return; + } + + //convert to 32bppPArgb (the 'P' means The red, green, and blue components are premultiplied, according to the alpha component.) + Bitmap renderBmp = new Bitmap(value.Width, value.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); + Graphics g = Graphics.FromImage(renderBmp); + + g.DrawImage(value, 0, 0, value.Width, value.Height); + g.Dispose(); + + prop.renderBmpHbitmap = renderBmp.GetHbitmap(Color.FromArgb(0, 0, 0, 0)); + renderBmp.Dispose(); + + if (formHasBeenIntialized) + { + AddVistaMenuItem(mnuItem); + } + } + else if (!DesignMode && OSVersion.IsBelow(WindowsVersion.Vista)) + { + if (prop.PreVistaBitmap != null) + { + prop.PreVistaBitmap.Dispose(); + prop.PreVistaBitmap = null; + } + + if (value == null) + { + RemoveVistaMenuItem(mnuItem); + return; + } + + Bitmap bmp = new Bitmap(value.Width, value.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); + Graphics g = Graphics.FromImage(bmp); + + g.DrawImage(value, 0, 0, value.Width, value.Height); + g.Dispose(); + + prop.PreVistaBitmap = bmp; + + //for every Pre-Vista Windows, add the parent of the menu item to the list of parents + if (formHasBeenIntialized) + { + AddPreVistaMenuItem(mnuItem); + } + } + } + + public void PerformPendingSetImageCalls() + { + while (_pendingSetImageCalls.Count > 0) + { + var call = _pendingSetImageCalls.Dequeue(); + + this.SetImage(call.Key, call.Value, true); + } + } + + #endregion + + + + void ISupportInitialize.BeginInit() + { + } + + readonly MENUINFO mnuInfo = new MENUINFO(); + + void AddVistaMenuItem(MenuItem mnuItem) + { + //get the bitmap children of the parent + List mnuBitmapChildren = (List)menuParents[mnuItem.Parent.Handle]; + + + if (mnuBitmapChildren == null) + { + if (mnuItem.Parent.GetType() == typeof(ContextMenu)) + ((ContextMenu)mnuItem.Parent).Popup += MenuItem_Popup; + else + ((MenuItem)mnuItem.Parent).Popup += MenuItem_Popup; + + //intialize all the topmost menus to be of type "MNS_CHECKORBMP" (for Vista classic theme) + SetMenuInfo(new HandleRef(null, mnuItem.Parent.Handle), mnuInfo); + + + mnuBitmapChildren = new List { mnuItem }; + + //set the new children list to the corresponding parent + menuParents[mnuItem.Parent.Handle] = mnuBitmapChildren; + } + else + { + mnuBitmapChildren.Add(mnuItem); + } + } + + void AddPreVistaMenuItem(MenuItem mnuItem) + { + if (menuParents[mnuItem.Parent] == null) + { + menuParents[mnuItem.Parent] = true; + + if (formHasBeenIntialized) + { + //add all the menu items with custom paint events + foreach (MenuItem menu in mnuItem.Parent.MenuItems) + { + menu.DrawItem += MenuItem_DrawItem; + menu.MeasureItem += MenuItem_MeasureItem; + menu.OwnerDraw = true; + } + } + } + } + + public void RemoveVistaMenuItem(MenuItem mnuItem) + { + if (menuParents[mnuItem.Parent.Handle] != null) + { + List mnuBitmapChildren = (List)menuParents[mnuItem.Parent.Handle]; + + mnuBitmapChildren.Remove(mnuItem); + } + } + + public void RemovePreVistaMenuItem(MenuItem mnuItem) + { + mnuItem.DrawItem -= MenuItem_DrawItem; + mnuItem.MeasureItem -= MenuItem_MeasureItem; + mnuItem.OwnerDraw = false; + } + + void ISupportInitialize.EndInit() + { + if (!DesignMode) + { + if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) + { + foreach (DictionaryEntry de in properties) + { + AddVistaMenuItem((MenuItem)de.Key); + } + } + else // Pre-Vista menus + { + if (ownerForm != null) + ownerForm.ChangeUICues += ownerForm_ChangeUICues; + + foreach (DictionaryEntry de in properties) + { + AddPreVistaMenuItem((MenuItem)de.Key); + } + + //add event handle for each menu item's measure & draw routines + foreach (DictionaryEntry parent in menuParents) + { + foreach (MenuItem mnuItem in ((Menu)parent.Key).MenuItems) + { + mnuItem.DrawItem += MenuItem_DrawItem; + mnuItem.MeasureItem += MenuItem_MeasureItem; + mnuItem.OwnerDraw = true; + } + } + } + + formHasBeenIntialized = true; + } + } + + void MenuItem_Popup(object sender, EventArgs e) + { + //get the parentHandle + IntPtr parentHandle = ((Menu)sender).Handle; + + //get the list of children menuitems to "refresh" + List mnuBitmapChildren = (List)menuParents[parentHandle]; + + MENUITEMINFO_T_RW menuItemInfo = new MENUITEMINFO_T_RW(); + + foreach (MenuItem menuItem in mnuBitmapChildren) + { + //menuItem. + menuItemInfo.hbmpItem = ((Properties)properties[menuItem]).renderBmpHbitmap; + + //refresh the menu item + SetMenuItemInfo(new HandleRef(null, parentHandle), + (int)typeof(MenuItem).InvokeMember("MenuID", BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty, null, menuItem, null), + false, + menuItemInfo); + } + } + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public class MENUITEMINFO_T_RW + { + public int cbSize = Marshal.SizeOf(typeof(MENUITEMINFO_T_RW)); + public int fMask = 0x00000080; //MIIM_BITMAP = 0x00000080 + public int fType; + public int fState; + public int wID; + public IntPtr hSubMenu = IntPtr.Zero; + public IntPtr hbmpChecked = IntPtr.Zero; + public IntPtr hbmpUnchecked = IntPtr.Zero; + public IntPtr dwItemData = IntPtr.Zero; + public IntPtr dwTypeData = IntPtr.Zero; + public int cch; + public IntPtr hbmpItem = IntPtr.Zero; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public class MENUINFO + { + public int cbSize = Marshal.SizeOf(typeof(MENUINFO)); + public int fMask = 0x00000010; //MIM_STYLE; + public int dwStyle = 0x04000000; //MNS_CHECKORBMP; + public uint cyMax; + public IntPtr hbrBack = IntPtr.Zero; + public int dwContextHelpID; + public IntPtr dwMenuData = IntPtr.Zero; + } +} \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/VistaSearchBox.cs b/1.x/trunk/ProcessHacker/Components/VistaSearchBox.cs index 7988a7b91..29b1a2b31 100644 --- a/1.x/trunk/ProcessHacker/Components/VistaSearchBox.cs +++ b/1.x/trunk/ProcessHacker/Components/VistaSearchBox.cs @@ -9,7 +9,7 @@ namespace ProcessHacker { [DefaultEvent("TextChanged")] [DefaultProperty("Text")] - public sealed partial class VistaSearchBox : Control + public partial class VistaSearchBox : Control { private const string DefaultInactiveText = "Search"; private string _inactiveText; @@ -29,9 +29,9 @@ protected override CreateParams CreateParams [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] get { - const int WS_BORDER = 0x00800000; - const int WS_EX_CLIENTEDGE = 0x00000200; - const int WS_EX_CONTROLPARENT = 0x00010000; + int WS_BORDER = 0x00800000; + int WS_EX_CLIENTEDGE = 0x00000200; + int WS_EX_CONTROLPARENT = 0x00010000; CreateParams createParams = base.CreateParams; createParams.ExStyle |= WS_EX_CONTROLPARENT; @@ -202,7 +202,7 @@ public override string Text set { searchText.Text = value; } } - private bool TextEntered + protected bool TextEntered { get { return !String.IsNullOrEmpty(searchText.Text); } } @@ -283,7 +283,7 @@ protected override void OnBackColorChanged(EventArgs e) protected override void OnTextChanged(EventArgs e) { - searchImage.Image = TextEntered ? Properties.Resources.active_search : Properties.Resources.inactive_search; + searchImage.Image = TextEntered ? ProcessHacker.Properties.Resources.active_search : ProcessHacker.Properties.Resources.inactive_search; base.OnTextChanged(e); } @@ -293,7 +293,7 @@ protected override void OnTextChanged(EventArgs e) [DllImport("user32.dll", EntryPoint = "SetCapture")] public static extern IntPtr StartMouseCapture(IntPtr hWnd); - private void searchImage_MouseMove(object sender, MouseEventArgs e) + private void searchImage_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.X < 0 || e.X > searchImage.Width || e.Y < 0 || e.Y > searchImage.Height) { @@ -308,7 +308,7 @@ private void searchImage_MouseMove(object sender, MouseEventArgs e) } } - private void searchImage_Click(object sender, EventArgs e) + private void searchImage_Click(object sender, System.EventArgs e) { if (TextEntered) { @@ -322,12 +322,12 @@ private void searchText_TextChanged(object sender, EventArgs e) OnTextChanged(e); } - private void searchText_LostFocus(object sender, EventArgs e) + private void searchText_LostFocus(object sender, System.EventArgs e) { OnLostFocus(e); } - private void searchText_GotFocus(object sender, EventArgs e) + private void searchText_GotFocus(object sender, System.EventArgs e) { OnGotFocus(e); } diff --git a/1.x/trunk/ProcessHacker/Components/VistaSearchBox.designer.cs b/1.x/trunk/ProcessHacker/Components/VistaSearchBox.designer.cs index 215e194ab..c47dc9345 100644 --- a/1.x/trunk/ProcessHacker/Components/VistaSearchBox.designer.cs +++ b/1.x/trunk/ProcessHacker/Components/VistaSearchBox.designer.cs @@ -1,6 +1,6 @@ namespace ProcessHacker { - sealed partial class VistaSearchBox + partial class VistaSearchBox { /// /// Clean up any resources being used. diff --git a/1.x/trunk/ProcessHacker/Forms/AboutWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/AboutWindow.Designer.cs index df517e93a..05dfb151b 100644 --- a/1.x/trunk/ProcessHacker/Forms/AboutWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/AboutWindow.Designer.cs @@ -49,7 +49,6 @@ private void InitializeComponent() this.label9 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); - this.label13 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.linkGamingMasteR = new System.Windows.Forms.LinkLabel(); this.linkKerem = new System.Windows.Forms.LinkLabel(); @@ -63,6 +62,7 @@ private void InitializeComponent() this.labelFiller = new System.Windows.Forms.Label(); this.buttonChangelog = new System.Windows.Forms.Button(); this.buttonDiagnostics = new System.Windows.Forms.Button(); + this.label13 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); this.flowCredits.SuspendLayout(); this.SuspendLayout(); @@ -70,7 +70,6 @@ private void InitializeComponent() // buttonClose // this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.buttonClose.FlatStyle = System.Windows.Forms.FlatStyle.System; this.buttonClose.Location = new System.Drawing.Point(420, 320); this.buttonClose.Name = "buttonClose"; @@ -203,16 +202,15 @@ private void InitializeComponent() // // flowCredits // - this.flowCredits.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.flowCredits.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.flowCredits.AutoScroll = true; - this.flowCredits.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.flowCredits.Controls.Add(this.label8); this.flowCredits.Controls.Add(this.label5); - this.flowCredits.Controls.Add(this.label12); this.flowCredits.Controls.Add(this.label1); this.flowCredits.Controls.Add(this.label6); + this.flowCredits.Controls.Add(this.label12); this.flowCredits.Controls.Add(this.label10); this.flowCredits.Controls.Add(this.label9); this.flowCredits.Controls.Add(this.label7); @@ -265,8 +263,8 @@ private void InitializeComponent() // label12 // this.label12.AutoSize = true; - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(6, 29); + this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label12.Location = new System.Drawing.Point(6, 55); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(90, 13); this.label12.TabIndex = 29; @@ -275,7 +273,7 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 42); + this.label1.Location = new System.Drawing.Point(6, 29); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(188, 13); this.label1.TabIndex = 13; @@ -285,7 +283,7 @@ private void InitializeComponent() // this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(6, 55); + this.label6.Location = new System.Drawing.Point(6, 42); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(91, 13); this.label6.TabIndex = 18; @@ -331,15 +329,6 @@ private void InitializeComponent() this.label11.TabIndex = 17; this.label11.Text = "Thanks to:"; // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(6, 120); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(189, 13); - this.label13.TabIndex = 30; - this.label13.Text = "Donators - Thank you for your support!"; - // // label2 // this.label2.AutoSize = true; @@ -484,12 +473,19 @@ private void InitializeComponent() this.buttonDiagnostics.UseVisualStyleBackColor = true; this.buttonDiagnostics.Click += new System.EventHandler(this.buttonDiagnostics_Click); // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(6, 120); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(189, 13); + this.label13.TabIndex = 30; + this.label13.Text = "Donators - Thank you for your support!"; + // // AboutWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.CancelButton = this.buttonClose; this.ClientSize = new System.Drawing.Size(507, 355); this.Controls.Add(this.buttonDiagnostics); this.Controls.Add(this.buttonChangelog); diff --git a/1.x/trunk/ProcessHacker/Forms/AboutWindow.cs b/1.x/trunk/ProcessHacker/Forms/AboutWindow.cs index 52ecc4cca..0d3965c16 100644 --- a/1.x/trunk/ProcessHacker/Forms/AboutWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/AboutWindow.cs @@ -31,16 +31,17 @@ partial class AboutWindow : Form public AboutWindow() { InitializeComponent(); - + this.AddEscapeToClose(); this.SetTopMost(); - this.labelVersion.Text = Application.ProductVersion; - this.buttonChangelog.Visible = System.IO.File.Exists(Application.StartupPath + "\\CHANGELOG.txt"); + labelVersion.Text = Application.ProductVersion; + + buttonChangelog.Visible = System.IO.File.Exists(Application.StartupPath + "\\CHANGELOG.txt"); } private void flowCredits_MouseEnter(object sender, EventArgs e) { - this.flowCredits.Select(); + flowCredits.Select(); } private void buttonClose_Click(object sender, EventArgs e) @@ -52,12 +53,11 @@ private void buttonChangelog_Click(object sender, EventArgs e) { try { - using (InformationBox box = new InformationBox(System.IO.File.ReadAllText(Application.StartupPath + "\\CHANGELOG.txt"))) - { - box.ShowSaveButton = false; - box.Title = "Process Hacker Changelog"; - box.ShowDialog(); - } + InformationBox box = new InformationBox(System.IO.File.ReadAllText(Application.StartupPath + "\\CHANGELOG.txt")); + + box.ShowSaveButton = false; + box.Title = "Process Hacker Changelog"; + box.ShowDialog(); } catch (Exception ex) { @@ -67,11 +67,9 @@ private void buttonChangelog_Click(object sender, EventArgs e) private void buttonDiagnostics_Click(object sender, EventArgs e) { - using (InformationBox box = new InformationBox(Program.GetDiagnosticInformation())) - { - box.DefaultFileName = "Process Hacker Diagnostics Info"; - box.ShowDialog(); - } + InformationBox box = new InformationBox(Program.GetDiagnosticInformation()); + box.DefaultFileName = "Process Hacker Diagnostics Info"; + box.ShowDialog(); } private void linkHexBox_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) diff --git a/1.x/trunk/ProcessHacker/Forms/AboutWindow.resx b/1.x/trunk/ProcessHacker/Forms/AboutWindow.resx index 29dcb1b3a..5ea0895e3 100644 --- a/1.x/trunk/ProcessHacker/Forms/AboutWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/AboutWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.Designer.cs index 90aa9cccd..1c2091a20 100644 --- a/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class ChooseColumnsWindow { @@ -30,18 +28,17 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.listColumns = new ProcessHacker.Components.ExtendedListView(); + this.listColumns = new System.Windows.Forms.ListView(); this.buttonCancel = new System.Windows.Forms.Button(); this.buttonOK = new System.Windows.Forms.Button(); this.SuspendLayout(); // // listColumns // - this.listColumns.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listColumns.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listColumns.CheckBoxes = true; - this.listColumns.DoubleClickChecks = true; this.listColumns.FullRowSelect = true; this.listColumns.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.listColumns.Location = new System.Drawing.Point(12, 12); @@ -82,7 +79,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(464, 314); this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonCancel); @@ -101,7 +97,7 @@ private void InitializeComponent() #endregion - private ExtendedListView listColumns; + private System.Windows.Forms.ListView listColumns; private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.Button buttonOK; diff --git a/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.cs b/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.cs index 6d2077969..7f2320844 100644 --- a/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.cs @@ -24,6 +24,7 @@ using System.Collections.Generic; using System.Windows.Forms; using Aga.Controls.Tree; +using ProcessHacker.Common; namespace ProcessHacker { @@ -36,7 +37,7 @@ private struct TvColumn public bool Visible; } - private readonly object _list; + private object _list; public ChooseColumnsWindow(ListView list) : this() @@ -62,7 +63,7 @@ public ChooseColumnsWindow(TreeViewAdv tree) foreach (TreeColumn column in tree.Columns) { - columns.Add(new TvColumn + columns.Add(new TvColumn() { Header = column.Header, Index = column.Index, @@ -101,9 +102,11 @@ public ChooseColumnsWindow(TreeViewAdv tree) private ChooseColumnsWindow() { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); + + listColumns.SetDoubleBuffered(true); + listColumns.SetTheme("explorer"); } private void buttonCancel_Click(object sender, EventArgs e) diff --git a/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.resx b/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ChooseColumnsWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.Designer.cs index ec3124a45..83ce192c8 100644 --- a/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.Designer.cs @@ -39,14 +39,14 @@ private void InitializeComponent() this.labelText.AutoSize = true; this.labelText.Location = new System.Drawing.Point(12, 9); this.labelText.Name = "labelText"; - this.labelText.Size = new System.Drawing.Size(32, 13); + this.labelText.Size = new System.Drawing.Size(30, 13); this.labelText.TabIndex = 0; this.labelText.Text = "Item:"; // // comboBox // - this.comboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.comboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox.FormattingEnabled = true; this.comboBox.Location = new System.Drawing.Point(12, 35); @@ -83,7 +83,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(342, 97); this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonCancel); diff --git a/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.resx b/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ComboBoxPickerWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.Designer.cs index 7aead78e1..75926e5a6 100644 --- a/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.Designer.cs @@ -50,7 +50,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 15); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(39, 13); + this.label1.Size = new System.Drawing.Size(38, 13); this.label1.TabIndex = 9; this.label1.Text = "Name:"; // @@ -59,7 +59,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 41); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(79, 13); + this.label2.Size = new System.Drawing.Size(75, 13); this.label2.TabIndex = 10; this.label2.Text = "Display Name:"; // @@ -78,7 +78,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 67); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(33, 13); + this.label3.Size = new System.Drawing.Size(34, 13); this.label3.TabIndex = 11; this.label3.Text = "Type:"; // @@ -87,7 +87,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(12, 94); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(60, 13); + this.label4.Size = new System.Drawing.Size(59, 13); this.label4.TabIndex = 12; this.label4.Text = "Start Type:"; // @@ -106,7 +106,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(12, 121); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(77, 13); + this.label5.Size = new System.Drawing.Size(68, 13); this.label5.TabIndex = 13; this.label5.Text = "Error Control:"; // @@ -125,7 +125,7 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(12, 148); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(68, 13); + this.label6.Size = new System.Drawing.Size(64, 13); this.label6.TabIndex = 14; this.label6.Text = "Binary Path:"; // @@ -155,29 +155,29 @@ private void InitializeComponent() // // textName // - this.textName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textName.Location = new System.Drawing.Point(100, 12); this.textName.Name = "textName"; - this.textName.Size = new System.Drawing.Size(304, 22); + this.textName.Size = new System.Drawing.Size(304, 20); this.textName.TabIndex = 0; // // textDisplayName // - this.textDisplayName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textDisplayName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textDisplayName.Location = new System.Drawing.Point(100, 38); this.textDisplayName.Name = "textDisplayName"; - this.textDisplayName.Size = new System.Drawing.Size(304, 22); + this.textDisplayName.Size = new System.Drawing.Size(304, 20); this.textDisplayName.TabIndex = 1; // // textBinaryPath // - this.textBinaryPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textBinaryPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textBinaryPath.Location = new System.Drawing.Point(100, 145); this.textBinaryPath.Name = "textBinaryPath"; - this.textBinaryPath.Size = new System.Drawing.Size(223, 22); + this.textBinaryPath.Size = new System.Drawing.Size(223, 20); this.textBinaryPath.TabIndex = 5; // // buttonBrowse @@ -196,7 +196,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(416, 220); this.Controls.Add(this.buttonBrowse); this.Controls.Add(this.textBinaryPath); diff --git a/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.cs b/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.cs index 19ff390aa..7e29a3cfd 100644 --- a/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.cs @@ -1,4 +1,9 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Native.Api; @@ -12,14 +17,12 @@ public partial class CreateServiceWindow : Form public CreateServiceWindow() { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); - this.comboErrorControl.Fill(typeof(ServiceErrorControl)); - this.comboStartType.Fill(typeof(ServiceStartType)); - this.comboType.Fill(typeof(ServiceType)); - + Utils.Fill(comboErrorControl, typeof(ServiceErrorControl)); + Utils.Fill(comboStartType, typeof(ServiceStartType)); + Utils.Fill(comboType, typeof(ServiceType)); comboType.Items.Add("Win32OwnProcess, InteractiveProcess"); comboErrorControl.SelectedItem = "Ignore"; comboStartType.SelectedItem = "DemandStart"; @@ -33,22 +36,20 @@ private void CreateServiceWindow_Load(object sender, EventArgs e) private void buttonBrowse_Click(object sender, EventArgs e) { - using (OpenFileDialog ofd = new OpenFileDialog - { - Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*", - FileName = this.textBinaryPath.Text - }) - { - if (ofd.ShowDialog() == DialogResult.OK) - textBinaryPath.Text = ofd.FileName; - } + OpenFileDialog ofd = new OpenFileDialog(); + + ofd.Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*"; + ofd.FileName = textBinaryPath.Text; + + if (ofd.ShowDialog() == DialogResult.OK) + textBinaryPath.Text = ofd.FileName; } private void buttonOK_Click(object sender, EventArgs e) { try { - using (ServiceManagerHandle scmhandle = new ServiceManagerHandle(ScManagerAccess.CreateService)) + using (var scmhandle = new ServiceManagerHandle(ScManagerAccess.CreateService)) { ServiceType serviceType; diff --git a/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.resx b/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/CreateServiceWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.Designer.cs index dddf9a982..6eddf95a6 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.Designer.cs @@ -28,6 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DumpHackerWindow)); this.treeProcesses = new ProcessHacker.ProcessTree(); this.tabControl = new System.Windows.Forms.TabControl(); @@ -38,6 +39,7 @@ private void InitializeComponent() this.propertiesMenuItem = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.copyMenuItem = new System.Windows.Forms.MenuItem(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.goToProcessServiceMenuItem = new System.Windows.Forms.MenuItem(); this.propertiesServiceMenuItem = new System.Windows.Forms.MenuItem(); this.copyServiceMenuItem = new System.Windows.Forms.MenuItem(); @@ -46,6 +48,7 @@ private void InitializeComponent() this.tabControl.SuspendLayout(); this.tabProcesses.SuspendLayout(); this.tabServices.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // treeProcesses @@ -100,6 +103,7 @@ private void InitializeComponent() // listServices // this.listServices.Dock = System.Windows.Forms.DockStyle.Fill; + this.listServices.DoubleBuffered = true; this.listServices.Location = new System.Drawing.Point(3, 3); this.listServices.Name = "listServices"; this.listServices.Provider = null; @@ -117,6 +121,7 @@ private void InitializeComponent() // propertiesMenuItem // this.propertiesMenuItem.DefaultItem = true; + this.vistaMenu.SetImage(this.propertiesMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify); this.propertiesMenuItem.Index = 0; this.propertiesMenuItem.Text = "Properties"; this.propertiesMenuItem.Click += new System.EventHandler(this.propertiesMenuItem_Click); @@ -128,11 +133,18 @@ private void InitializeComponent() // // copyMenuItem // + this.vistaMenu.SetImage(this.copyMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyMenuItem.Index = 2; this.copyMenuItem.Text = "Copy"; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // goToProcessServiceMenuItem // + this.vistaMenu.SetImage(this.goToProcessServiceMenuItem, global::ProcessHacker.Properties.Resources.arrow_right); this.goToProcessServiceMenuItem.Index = 0; this.goToProcessServiceMenuItem.Text = "Go to Process"; this.goToProcessServiceMenuItem.Click += new System.EventHandler(this.goToProcessServiceMenuItem_Click); @@ -140,12 +152,14 @@ private void InitializeComponent() // propertiesServiceMenuItem // this.propertiesServiceMenuItem.DefaultItem = true; + this.vistaMenu.SetImage(this.propertiesServiceMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify); this.propertiesServiceMenuItem.Index = 1; this.propertiesServiceMenuItem.Text = "Properties"; this.propertiesServiceMenuItem.Click += new System.EventHandler(this.propertiesServiceMenuItem_Click); // // copyServiceMenuItem // + this.vistaMenu.SetImage(this.copyServiceMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyServiceMenuItem.Index = 3; this.copyServiceMenuItem.Text = "Copy"; // @@ -167,17 +181,17 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(903, 525); this.Controls.Add(this.tabControl); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "DumpHackerWindow"; this.Text = "Dump Viewer"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DumpHackerWindow_FormClosing); this.Load += new System.EventHandler(this.DumpHackerWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DumpHackerWindow_FormClosing); this.tabControl.ResumeLayout(false); this.tabProcesses.ResumeLayout(false); this.tabServices.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); } @@ -191,7 +205,7 @@ private void InitializeComponent() private ProcessHacker.Components.ServiceList listServices; private System.Windows.Forms.ContextMenu menuProcess; private System.Windows.Forms.MenuItem propertiesMenuItem; - + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.MenuItem copyMenuItem; private System.Windows.Forms.ContextMenu menuService; private System.Windows.Forms.MenuItem goToProcessServiceMenuItem; diff --git a/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.cs b/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.cs index 8c214fdec..a3bcbf82d 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.cs @@ -27,22 +27,23 @@ using ProcessHacker.Native; using ProcessHacker.Native.Api; using ProcessHacker.Native.Mfs; +using ProcessHacker.Native.Objects; using ProcessHacker.UI; namespace ProcessHacker { public partial class DumpHackerWindow : Form { - private readonly MemoryFileSystem _mfs; + private MemoryFileSystem _mfs; private MemoryObject _processesMo; private MemoryObject _servicesMo; private string _phVersion; private string _osVersion; private OSArch _architecture; private string _userName; - private readonly Dictionary _processes = new Dictionary(); - private readonly Dictionary _services = new Dictionary(); - private readonly Dictionary> _processServices = new Dictionary>(); + private Dictionary _processes = new Dictionary(); + private Dictionary _services = new Dictionary(); + private Dictionary> _processServices = new Dictionary>(); public DumpHackerWindow(string fileName) { @@ -54,7 +55,7 @@ public DumpHackerWindow(string fileName) ColumnSettings.LoadSettings(Settings.Instance.ProcessTreeColumns, treeProcesses.Tree); ColumnSettings.LoadSettings(Settings.Instance.ServiceListViewColumns, listServices.List); - listServices.DoubleClick += this.listServices_DoubleClick; + listServices.DoubleClick += new EventHandler(listServices_DoubleClick); } private void DumpHackerWindow_Load(object sender, EventArgs e) @@ -105,7 +106,9 @@ public Dictionary Processes private void LoadSystemInformation() { - MemoryObject sysInfoMo = this._mfs.RootObject.GetChild("SystemInformation"); + MemoryObject sysInfoMo; + + sysInfoMo = _mfs.RootObject.GetChild("SystemInformation"); if (sysInfoMo == null) { @@ -114,7 +117,7 @@ private void LoadSystemInformation() return; } - IDictionary dict = Dump.GetDictionary(sysInfoMo); + var dict = Dump.GetDictionary(sysInfoMo); sysInfoMo.Dispose(); @@ -133,27 +136,30 @@ private void LoadSystemInformation() private void LoadProcesses() { - MemoryObject processesMo = this._mfs.RootObject.GetChild("Processes"); + MemoryObject processesMo; + + processesMo = _mfs.RootObject.GetChild("Processes"); _processesMo = processesMo; if (processesMo == null) { - PhUtils.ShowWarning("The dump file does not contain process information. This most likely means the file is corrupt."); + PhUtils.ShowWarning("The dump file does not contain process information. This most likely " + + "means the file is corrupt."); return; } - processesMo.EnumChildren(childMo => - { - using (childMo) - this.LoadProcess(childMo); + processesMo.EnumChildren((childMo) => + { + using (childMo) + this.LoadProcess(childMo); - return true; - }); + return true; + }); } private void LoadProcess(MemoryObject mo) { - var names = mo.ChildNames; + var names = mo.GetChildNames(); ProcessItem pitem; if (!names.Contains("General")) @@ -161,15 +167,13 @@ private void LoadProcess(MemoryObject mo) IDictionary generalDict; - using (MemoryObject general = mo.GetChild("General")) + using (var general = mo.GetChild("General")) generalDict = Dump.GetDictionary(general); - pitem = new ProcessItem - { - Pid = Dump.ParseInt32(generalDict["ProcessId"]), - Name = generalDict["Name"], - ParentPid = Dump.ParseInt32(generalDict["ParentPid"]) - }; + pitem = new ProcessItem(); + pitem.Pid = Dump.ParseInt32(generalDict["ProcessId"]); + pitem.Name = generalDict["Name"]; + pitem.ParentPid = Dump.ParseInt32(generalDict["ParentPid"]); if (generalDict.ContainsKey("HasParent")) pitem.HasParent = Dump.ParseBool(generalDict["HasParent"]); @@ -183,13 +187,11 @@ private void LoadProcess(MemoryObject mo) if (generalDict.ContainsKey("FileDescription")) { - pitem.VersionInfo = new ImageVersionInfo - { - FileDescription = generalDict["FileDescription"], - CompanyName = generalDict["FileCompanyName"], - FileVersion = generalDict["FileVersion"], - FileName = pitem.FileName - }; + pitem.VersionInfo = new ImageVersionInfo(); + pitem.VersionInfo.FileDescription = generalDict["FileDescription"]; + pitem.VersionInfo.CompanyName = generalDict["FileCompanyName"]; + pitem.VersionInfo.FileVersion = generalDict["FileVersion"]; + pitem.VersionInfo.FileName = pitem.FileName; } if (generalDict.ContainsKey("CommandLine")) @@ -266,7 +268,7 @@ private void LoadServices() return; } - servicesMo.EnumChildren(childMo => + servicesMo.EnumChildren((childMo) => { using (childMo) this.LoadService(childMo); @@ -363,17 +365,18 @@ private void treeProcesses_NodeMouseDoubleClick(object sender, Aga.Controls.Tree private void menuProcess_Popup(object sender, EventArgs e) { - switch (this.treeProcesses.SelectedTreeNodes.Count) + if (treeProcesses.SelectedTreeNodes.Count == 0) + { + menuProcess.DisableAll(); + } + else if (treeProcesses.SelectedTreeNodes.Count == 1) + { + menuProcess.EnableAll(); + } + else { - case 0: - break; - case 1: - this.menuProcess.EnableAll(); - break; - default: - this.menuProcess.EnableAll(); - this.propertiesMenuItem.Enabled = false; - break; + menuProcess.EnableAll(); + propertiesMenuItem.Enabled = false; } } @@ -396,7 +399,7 @@ private void menuService_Popup(object sender, EventArgs e) { if (listServices.SelectedItems.Count == 0) { - //menuService.DisableAll(); + menuService.DisableAll(); } else if (listServices.SelectedItems.Count == 1) { diff --git a/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.resx b/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.resx index 09cc1a538..a5532164d 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/DumpHackerWindow.resx @@ -112,18 +112,18 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - - 249, 17 + + 141, 17 - + AAABAA8AMDAQAAEABABoBgAA9gAAACAgEAABAAQA6AIAAF4HAAAQEBAAAQAEACgBAABGCgAAAAAAAAEA @@ -912,4 +912,7 @@ QQAArEEAAKxBAACsQXAArEFwAKxBcACsQXAArEFwAKxBAACsQQ== + + 249, 17 + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.Designer.cs index cab4ac1ca..d9bb00827 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.Designer.cs @@ -1,6 +1,6 @@ namespace ProcessHacker { - sealed partial class DumpProcessWindow + partial class DumpProcessWindow { /// /// Required designer variable. @@ -34,6 +34,13 @@ private void InitializeComponent() { this.tabControl = new System.Windows.Forms.TabControl(); this.tabGeneral = new System.Windows.Forms.TabPage(); + this.tabToken = new System.Windows.Forms.TabPage(); + this.tabModules = new System.Windows.Forms.TabPage(); + this.tabEnvironment = new System.Windows.Forms.TabPage(); + this.listEnvironment = new System.Windows.Forms.ListView(); + this.columnVarName = new System.Windows.Forms.ColumnHeader(); + this.columnVarValue = new System.Windows.Forms.ColumnHeader(); + this.tabHandles = new System.Windows.Forms.TabPage(); this.groupProcess = new System.Windows.Forms.GroupBox(); this.labelProcessTypeValue = new System.Windows.Forms.Label(); this.labelProcessType = new System.Windows.Forms.Label(); @@ -46,7 +53,6 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textStartTime = new System.Windows.Forms.TextBox(); - this.textCurrentDirectory = new System.Windows.Forms.TextBox(); this.textCmdLine = new System.Windows.Forms.TextBox(); this.groupFile = new System.Windows.Forms.GroupBox(); this.pictureIcon = new System.Windows.Forms.PictureBox(); @@ -54,25 +60,19 @@ private void InitializeComponent() this.textFileCompany = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); - this.textFileName = new System.Windows.Forms.TextBox(); this.textFileVersion = new System.Windows.Forms.TextBox(); - this.tabToken = new System.Windows.Forms.TabPage(); - this.tabModules = new System.Windows.Forms.TabPage(); + this.textFileName = new System.Windows.Forms.TextBox(); + this.textCurrentDirectory = new System.Windows.Forms.TextBox(); this.listModules = new ProcessHacker.Components.ModuleList(); - this.tabEnvironment = new System.Windows.Forms.TabPage(); - this.listEnvironment = new ProcessHacker.Components.ExtendedListView(); - this.columnVarName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnVarValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.tabHandles = new System.Windows.Forms.TabPage(); this.listHandles = new ProcessHacker.Components.HandleList(); this.tabControl.SuspendLayout(); this.tabGeneral.SuspendLayout(); - this.groupProcess.SuspendLayout(); - this.groupFile.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureIcon)).BeginInit(); this.tabModules.SuspendLayout(); this.tabEnvironment.SuspendLayout(); this.tabHandles.SuspendLayout(); + this.groupProcess.SuspendLayout(); + this.groupFile.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureIcon)).BeginInit(); this.SuspendLayout(); // // tabControl @@ -101,11 +101,80 @@ private void InitializeComponent() this.tabGeneral.Text = "General"; this.tabGeneral.UseVisualStyleBackColor = true; // + // tabToken + // + this.tabToken.Location = new System.Drawing.Point(4, 22); + this.tabToken.Name = "tabToken"; + this.tabToken.Size = new System.Drawing.Size(469, 441); + this.tabToken.TabIndex = 4; + this.tabToken.Text = "Token"; + this.tabToken.UseVisualStyleBackColor = true; + // + // tabModules + // + this.tabModules.Controls.Add(this.listModules); + this.tabModules.Location = new System.Drawing.Point(4, 22); + this.tabModules.Name = "tabModules"; + this.tabModules.Padding = new System.Windows.Forms.Padding(3); + this.tabModules.Size = new System.Drawing.Size(469, 441); + this.tabModules.TabIndex = 1; + this.tabModules.Text = "Modules"; + this.tabModules.UseVisualStyleBackColor = true; + // + // tabEnvironment + // + this.tabEnvironment.Controls.Add(this.listEnvironment); + this.tabEnvironment.Location = new System.Drawing.Point(4, 22); + this.tabEnvironment.Name = "tabEnvironment"; + this.tabEnvironment.Padding = new System.Windows.Forms.Padding(3); + this.tabEnvironment.Size = new System.Drawing.Size(469, 441); + this.tabEnvironment.TabIndex = 3; + this.tabEnvironment.Text = "Environment"; + this.tabEnvironment.UseVisualStyleBackColor = true; + // + // listEnvironment + // + this.listEnvironment.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnVarName, + this.columnVarValue}); + this.listEnvironment.Dock = System.Windows.Forms.DockStyle.Fill; + this.listEnvironment.FullRowSelect = true; + this.listEnvironment.HideSelection = false; + this.listEnvironment.Location = new System.Drawing.Point(3, 3); + this.listEnvironment.Name = "listEnvironment"; + this.listEnvironment.ShowItemToolTips = true; + this.listEnvironment.Size = new System.Drawing.Size(463, 435); + this.listEnvironment.Sorting = System.Windows.Forms.SortOrder.Ascending; + this.listEnvironment.TabIndex = 1; + this.listEnvironment.UseCompatibleStateImageBehavior = false; + this.listEnvironment.View = System.Windows.Forms.View.Details; + // + // columnVarName + // + this.columnVarName.Text = "Name"; + this.columnVarName.Width = 150; + // + // columnVarValue + // + this.columnVarValue.Text = "Value"; + this.columnVarValue.Width = 250; + // + // tabHandles + // + this.tabHandles.Controls.Add(this.listHandles); + this.tabHandles.Location = new System.Drawing.Point(4, 22); + this.tabHandles.Name = "tabHandles"; + this.tabHandles.Padding = new System.Windows.Forms.Padding(3); + this.tabHandles.Size = new System.Drawing.Size(469, 441); + this.tabHandles.TabIndex = 2; + this.tabHandles.Text = "Handles"; + this.tabHandles.UseVisualStyleBackColor = true; + // // groupProcess // - this.groupProcess.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupProcess.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupProcess.Controls.Add(this.labelProcessTypeValue); this.groupProcess.Controls.Add(this.labelProcessType); this.groupProcess.Controls.Add(this.label26); @@ -141,7 +210,7 @@ private void InitializeComponent() this.labelProcessType.AutoSize = true; this.labelProcessType.Location = new System.Drawing.Point(6, 157); this.labelProcessType.Name = "labelProcessType"; - this.labelProcessType.Size = new System.Drawing.Size(74, 13); + this.labelProcessType.Size = new System.Drawing.Size(75, 13); this.labelProcessType.TabIndex = 19; this.labelProcessType.Text = "Process Type:"; this.labelProcessType.Visible = false; @@ -151,19 +220,19 @@ private void InitializeComponent() this.label26.AutoSize = true; this.label26.Location = new System.Drawing.Point(6, 22); this.label26.Name = "label26"; - this.label26.Size = new System.Drawing.Size(47, 13); + this.label26.Size = new System.Drawing.Size(44, 13); this.label26.TabIndex = 12; this.label26.Text = "Started:"; // // textDEP // - this.textDEP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textDEP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textDEP.BackColor = System.Drawing.SystemColors.Control; this.textDEP.Location = new System.Drawing.Point(101, 128); this.textDEP.Name = "textDEP"; this.textDEP.ReadOnly = true; - this.textDEP.Size = new System.Drawing.Size(348, 22); + this.textDEP.Size = new System.Drawing.Size(348, 20); this.textDEP.TabIndex = 8; // // labelDEP @@ -171,7 +240,7 @@ private void InitializeComponent() this.labelDEP.AutoSize = true; this.labelDEP.Location = new System.Drawing.Point(6, 131); this.labelDEP.Name = "labelDEP"; - this.labelDEP.Size = new System.Drawing.Size(30, 13); + this.labelDEP.Size = new System.Drawing.Size(32, 13); this.labelDEP.TabIndex = 17; this.labelDEP.Text = "DEP:"; // @@ -191,19 +260,19 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(6, 105); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(43, 13); + this.label5.Size = new System.Drawing.Size(41, 13); this.label5.TabIndex = 16; this.label5.Text = "Parent:"; // // textParent // - this.textParent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textParent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textParent.BackColor = System.Drawing.SystemColors.Control; this.textParent.Location = new System.Drawing.Point(101, 102); this.textParent.Name = "textParent"; this.textParent.ReadOnly = true; - this.textParent.Size = new System.Drawing.Size(318, 22); + this.textParent.Size = new System.Drawing.Size(318, 20); this.textParent.TabIndex = 6; // // label4 @@ -211,7 +280,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(6, 76); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(98, 13); + this.label4.Size = new System.Drawing.Size(89, 13); this.label4.TabIndex = 14; this.label4.Text = "Current Directory:"; // @@ -220,44 +289,34 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 48); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(86, 13); + this.label2.Size = new System.Drawing.Size(80, 13); this.label2.TabIndex = 13; this.label2.Text = "Command Line:"; // // textStartTime // - this.textStartTime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textStartTime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textStartTime.Location = new System.Drawing.Point(101, 19); this.textStartTime.Name = "textStartTime"; this.textStartTime.ReadOnly = true; - this.textStartTime.Size = new System.Drawing.Size(348, 22); + this.textStartTime.Size = new System.Drawing.Size(348, 20); this.textStartTime.TabIndex = 0; // - // textCurrentDirectory - // - this.textCurrentDirectory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textCurrentDirectory.Location = new System.Drawing.Point(101, 73); - this.textCurrentDirectory.Name = "textCurrentDirectory"; - this.textCurrentDirectory.ReadOnly = true; - this.textCurrentDirectory.Size = new System.Drawing.Size(348, 22); - this.textCurrentDirectory.TabIndex = 2; - // // textCmdLine // - this.textCmdLine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textCmdLine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textCmdLine.Location = new System.Drawing.Point(101, 45); this.textCmdLine.Name = "textCmdLine"; this.textCmdLine.ReadOnly = true; - this.textCmdLine.Size = new System.Drawing.Size(348, 22); + this.textCmdLine.Size = new System.Drawing.Size(348, 20); this.textCmdLine.TabIndex = 2; // // groupFile // - this.groupFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupFile.Controls.Add(this.pictureIcon); this.groupFile.Controls.Add(this.textFileDescription); this.groupFile.Controls.Add(this.textFileCompany); @@ -283,27 +342,27 @@ private void InitializeComponent() // // textFileDescription // - this.textFileDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFileDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFileDescription.BackColor = System.Drawing.SystemColors.Window; this.textFileDescription.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textFileDescription.Location = new System.Drawing.Point(44, 20); this.textFileDescription.Name = "textFileDescription"; this.textFileDescription.ReadOnly = true; - this.textFileDescription.Size = new System.Drawing.Size(407, 15); + this.textFileDescription.Size = new System.Drawing.Size(407, 13); this.textFileDescription.TabIndex = 2; this.textFileDescription.Text = "File Description"; // // textFileCompany // - this.textFileCompany.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFileCompany.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFileCompany.BackColor = System.Drawing.SystemColors.Window; this.textFileCompany.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textFileCompany.Location = new System.Drawing.Point(44, 38); this.textFileCompany.Name = "textFileCompany"; this.textFileCompany.ReadOnly = true; - this.textFileCompany.Size = new System.Drawing.Size(407, 15); + this.textFileCompany.Size = new System.Drawing.Size(407, 13); this.textFileCompany.TabIndex = 3; this.textFileCompany.Text = "File Company"; // @@ -312,7 +371,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 60); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(83, 13); + this.label1.Size = new System.Drawing.Size(77, 13); this.label1.TabIndex = 4; this.label1.Text = "Image Version:"; // @@ -321,112 +380,54 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 88); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(94, 13); + this.label3.Size = new System.Drawing.Size(89, 13); this.label3.TabIndex = 5; this.label3.Text = "Image File Name:"; // - // textFileName - // - this.textFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textFileName.Location = new System.Drawing.Point(103, 85); - this.textFileName.Name = "textFileName"; - this.textFileName.ReadOnly = true; - this.textFileName.Size = new System.Drawing.Size(348, 22); - this.textFileName.TabIndex = 0; - // // textFileVersion // - this.textFileVersion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFileVersion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFileVersion.Location = new System.Drawing.Point(103, 57); this.textFileVersion.Name = "textFileVersion"; this.textFileVersion.ReadOnly = true; - this.textFileVersion.Size = new System.Drawing.Size(348, 22); + this.textFileVersion.Size = new System.Drawing.Size(348, 20); this.textFileVersion.TabIndex = 0; // - // tabToken + // textFileName // - this.tabToken.Location = new System.Drawing.Point(4, 22); - this.tabToken.Name = "tabToken"; - this.tabToken.Size = new System.Drawing.Size(469, 441); - this.tabToken.TabIndex = 4; - this.tabToken.Text = "Token"; - this.tabToken.UseVisualStyleBackColor = true; + this.textFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textFileName.Location = new System.Drawing.Point(103, 85); + this.textFileName.Name = "textFileName"; + this.textFileName.ReadOnly = true; + this.textFileName.Size = new System.Drawing.Size(348, 20); + this.textFileName.TabIndex = 0; // - // tabModules + // textCurrentDirectory // - this.tabModules.Controls.Add(this.listModules); - this.tabModules.Location = new System.Drawing.Point(4, 22); - this.tabModules.Name = "tabModules"; - this.tabModules.Padding = new System.Windows.Forms.Padding(3); - this.tabModules.Size = new System.Drawing.Size(469, 441); - this.tabModules.TabIndex = 1; - this.tabModules.Text = "Modules"; - this.tabModules.UseVisualStyleBackColor = true; + this.textCurrentDirectory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textCurrentDirectory.Location = new System.Drawing.Point(101, 73); + this.textCurrentDirectory.Name = "textCurrentDirectory"; + this.textCurrentDirectory.ReadOnly = true; + this.textCurrentDirectory.Size = new System.Drawing.Size(348, 20); + this.textCurrentDirectory.TabIndex = 2; // // listModules // this.listModules.Dock = System.Windows.Forms.DockStyle.Fill; + this.listModules.DoubleBuffered = true; this.listModules.Location = new System.Drawing.Point(3, 3); this.listModules.Name = "listModules"; this.listModules.Provider = null; this.listModules.Size = new System.Drawing.Size(463, 435); this.listModules.TabIndex = 0; // - // tabEnvironment - // - this.tabEnvironment.Controls.Add(this.listEnvironment); - this.tabEnvironment.Location = new System.Drawing.Point(4, 22); - this.tabEnvironment.Name = "tabEnvironment"; - this.tabEnvironment.Padding = new System.Windows.Forms.Padding(3); - this.tabEnvironment.Size = new System.Drawing.Size(469, 441); - this.tabEnvironment.TabIndex = 3; - this.tabEnvironment.Text = "Environment"; - this.tabEnvironment.UseVisualStyleBackColor = true; - // - // listEnvironment - // - this.listEnvironment.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnVarName, - this.columnVarValue}); - this.listEnvironment.Dock = System.Windows.Forms.DockStyle.Fill; - this.listEnvironment.DoubleClickChecks = true; - this.listEnvironment.FullRowSelect = true; - this.listEnvironment.HideSelection = false; - this.listEnvironment.Location = new System.Drawing.Point(3, 3); - this.listEnvironment.Name = "listEnvironment"; - this.listEnvironment.ShowItemToolTips = true; - this.listEnvironment.Size = new System.Drawing.Size(463, 435); - this.listEnvironment.Sorting = System.Windows.Forms.SortOrder.Ascending; - this.listEnvironment.TabIndex = 1; - this.listEnvironment.UseCompatibleStateImageBehavior = false; - this.listEnvironment.View = System.Windows.Forms.View.Details; - // - // columnVarName - // - this.columnVarName.Text = "Name"; - this.columnVarName.Width = 150; - // - // columnVarValue - // - this.columnVarValue.Text = "Value"; - this.columnVarValue.Width = 250; - // - // tabHandles - // - this.tabHandles.Controls.Add(this.listHandles); - this.tabHandles.Location = new System.Drawing.Point(4, 22); - this.tabHandles.Name = "tabHandles"; - this.tabHandles.Padding = new System.Windows.Forms.Padding(3); - this.tabHandles.Size = new System.Drawing.Size(469, 441); - this.tabHandles.TabIndex = 2; - this.tabHandles.Text = "Handles"; - this.tabHandles.UseVisualStyleBackColor = true; - // // listHandles // this.listHandles.Dock = System.Windows.Forms.DockStyle.Fill; + this.listHandles.DoubleBuffered = true; this.listHandles.Location = new System.Drawing.Point(3, 3); this.listHandles.Name = "listHandles"; this.listHandles.Provider = null; @@ -437,24 +438,23 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(483, 473); this.Controls.Add(this.tabControl); this.Name = "DumpProcessWindow"; this.Padding = new System.Windows.Forms.Padding(3); this.Text = "Process"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DumpProcessWindow_FormClosing); this.Load += new System.EventHandler(this.DumpProcessWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DumpProcessWindow_FormClosing); this.tabControl.ResumeLayout(false); this.tabGeneral.ResumeLayout(false); + this.tabModules.ResumeLayout(false); + this.tabEnvironment.ResumeLayout(false); + this.tabHandles.ResumeLayout(false); this.groupProcess.ResumeLayout(false); this.groupProcess.PerformLayout(); this.groupFile.ResumeLayout(false); this.groupFile.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureIcon)).EndInit(); - this.tabModules.ResumeLayout(false); - this.tabEnvironment.ResumeLayout(false); - this.tabHandles.ResumeLayout(false); this.ResumeLayout(false); } @@ -469,7 +469,7 @@ private void InitializeComponent() private System.Windows.Forms.TabPage tabEnvironment; private ProcessHacker.Components.ModuleList listModules; private ProcessHacker.Components.HandleList listHandles; - private ProcessHacker.Components.ExtendedListView listEnvironment; + private System.Windows.Forms.ListView listEnvironment; private System.Windows.Forms.ColumnHeader columnVarName; private System.Windows.Forms.ColumnHeader columnVarValue; private System.Windows.Forms.GroupBox groupProcess; diff --git a/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.cs b/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.cs index de9275d00..171e72bc1 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.cs @@ -21,7 +21,6 @@ */ using System; -using System.Collections.Generic; using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Components; @@ -33,11 +32,11 @@ namespace ProcessHacker { - public sealed partial class DumpProcessWindow : Form + public partial class DumpProcessWindow : Form { - private readonly DumpHackerWindow _hw; - private readonly ProcessItem _item; - private readonly MemoryObject _processMo; + private DumpHackerWindow _hw; + private ProcessItem _item; + private MemoryObject _processMo; private TokenProperties _tokenProps; @@ -66,10 +65,8 @@ private void DumpProcessWindow_Load(object sender, EventArgs e) { this.LoadProperties(); - _tokenProps = new TokenProperties(null) - { - Dock = DockStyle.Fill - }; + _tokenProps = new TokenProperties(null); + _tokenProps.Dock = DockStyle.Fill; tabToken.Controls.Add(_tokenProps); _tokenProps.DumpInitialize(); this.LoadToken(); @@ -77,6 +74,7 @@ private void DumpProcessWindow_Load(object sender, EventArgs e) // Modules if (_item.FileName != null) listModules.DumpSetMainModule(_item.FileName); + listModules.List.SetTheme("explorer"); listModules.List.AddShortcuts(); listModules.List.ContextMenu = listModules.List.GetCopyMenu(); @@ -84,6 +82,7 @@ private void DumpProcessWindow_Load(object sender, EventArgs e) listModules.UpdateItems(); // Environment + listEnvironment.SetTheme("explorer"); listEnvironment.AddShortcuts(); listEnvironment.ContextMenu = listEnvironment.GetCopyMenu(); @@ -91,6 +90,7 @@ private void DumpProcessWindow_Load(object sender, EventArgs e) // Handles listHandles.DumpDisableEvents(); + listHandles.List.SetTheme("explorer"); listHandles.List.AddShortcuts(); listHandles.List.ContextMenu = listHandles.List.GetCopyMenu(); @@ -110,7 +110,7 @@ private void DumpProcessWindow_FormClosing(object sender, FormClosingEventArgs e private void LoadProperties() { - var names = _processMo.ChildNames; + var names = _processMo.GetChildNames(); if (names.Contains("LargeIcon")) { @@ -131,8 +131,8 @@ private void LoadProperties() else { textFileDescription.Text = _item.Name; - textFileCompany.Text = string.Empty; - textFileVersion.Text = string.Empty; + textFileCompany.Text = ""; + textFileVersion.Text = ""; } textFileName.Text = _item.FileName; @@ -297,7 +297,7 @@ private void LoadModules() if (modulesMo == null) return; - modulesMo.EnumChildren(childMo => + modulesMo.EnumChildren((childMo) => { using (childMo) this.LoadModule(childMo); @@ -331,17 +331,17 @@ private void LoadModule(MemoryObject mo) private void LoadEnvironment() { - MemoryObject env = _processMo.GetChild("Environment"); + var env = _processMo.GetChild("Environment"); if (env == null) return; - IDictionary dict = Dump.GetDictionary(env); + var dict = Dump.GetDictionary(env); foreach (var kvp in dict) { if (!string.IsNullOrEmpty(kvp.Key)) - listEnvironment.Items.Add(new ListViewItem(new[] { kvp.Key, kvp.Value })); + listEnvironment.Items.Add(new ListViewItem(new string[] { kvp.Key, kvp.Value })); } env.Dispose(); @@ -356,7 +356,7 @@ private void LoadHandles() if (handlesMo == null) return; - handlesMo.EnumChildren(childMo => + handlesMo.EnumChildren((childMo) => { using (childMo) this.LoadHandles(childMo); diff --git a/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.resx b/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/DumpProcessWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.Designer.cs index 96c14100f..eab5689bc 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.Designer.cs @@ -50,127 +50,126 @@ private void InitializeComponent() // // textServiceDll // - this.textServiceDll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textServiceDll.Location = new System.Drawing.Point(91, 230); + this.textServiceDll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textServiceDll.Location = new System.Drawing.Point(93, 200); this.textServiceDll.Name = "textServiceDll"; this.textServiceDll.ReadOnly = true; - this.textServiceDll.Size = new System.Drawing.Size(303, 22); + this.textServiceDll.Size = new System.Drawing.Size(303, 20); this.textServiceDll.TabIndex = 43; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(10, 233); + this.label8.Location = new System.Drawing.Point(12, 203); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(66, 13); + this.label8.Size = new System.Drawing.Size(69, 13); this.label8.TabIndex = 42; this.label8.Text = "Service DLL:"; // // textDescription // - this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textDescription.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textDescription.Location = new System.Drawing.Point(13, 44); + this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textDescription.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textDescription.Location = new System.Drawing.Point(12, 51); this.textDescription.Multiline = true; this.textDescription.Name = "textDescription"; this.textDescription.ReadOnly = true; this.textDescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textDescription.Size = new System.Drawing.Size(384, 75); + this.textDescription.Size = new System.Drawing.Size(384, 38); this.textDescription.TabIndex = 38; - this.textDescription.TextChanged += new System.EventHandler(this.textDescription_TextChanged); // // textLoadOrderGroup // - this.textLoadOrderGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textLoadOrderGroup.Location = new System.Drawing.Point(244, 152); + this.textLoadOrderGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textLoadOrderGroup.Location = new System.Drawing.Point(246, 122); this.textLoadOrderGroup.Name = "textLoadOrderGroup"; this.textLoadOrderGroup.ReadOnly = true; - this.textLoadOrderGroup.Size = new System.Drawing.Size(150, 22); + this.textLoadOrderGroup.Size = new System.Drawing.Size(150, 20); this.textLoadOrderGroup.TabIndex = 37; // // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(199, 128); + this.label6.Location = new System.Drawing.Point(201, 98); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(60, 13); + this.label6.Size = new System.Drawing.Size(59, 13); this.label6.TabIndex = 33; this.label6.Text = "Start Type:"; // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(10, 155); + this.label5.Location = new System.Drawing.Point(12, 125); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(77, 13); + this.label5.Size = new System.Drawing.Size(68, 13); this.label5.TabIndex = 32; this.label5.Text = "Error Control:"; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(10, 128); + this.label4.Location = new System.Drawing.Point(12, 98); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(33, 13); + this.label4.Size = new System.Drawing.Size(34, 13); this.label4.TabIndex = 31; this.label4.Text = "Type:"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(199, 155); + this.label3.Location = new System.Drawing.Point(201, 125); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(43, 13); + this.label3.Size = new System.Drawing.Size(39, 13); this.label3.TabIndex = 30; this.label3.Text = "Group:"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(10, 181); + this.label2.Location = new System.Drawing.Point(12, 151); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(68, 13); + this.label2.Size = new System.Drawing.Size(64, 13); this.label2.TabIndex = 29; this.label2.Text = "Binary Path:"; // // textUserAccount // - this.textUserAccount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textUserAccount.Location = new System.Drawing.Point(91, 204); + this.textUserAccount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textUserAccount.Location = new System.Drawing.Point(93, 174); this.textUserAccount.Name = "textUserAccount"; this.textUserAccount.ReadOnly = true; - this.textUserAccount.Size = new System.Drawing.Size(303, 22); + this.textUserAccount.Size = new System.Drawing.Size(303, 20); this.textUserAccount.TabIndex = 28; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(10, 207); + this.label1.Location = new System.Drawing.Point(12, 177); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(78, 13); + this.label1.Size = new System.Drawing.Size(75, 13); this.label1.TabIndex = 27; this.label1.Text = "User Account:"; // // textServiceBinaryPath // - this.textServiceBinaryPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textServiceBinaryPath.Location = new System.Drawing.Point(91, 178); + this.textServiceBinaryPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textServiceBinaryPath.Location = new System.Drawing.Point(93, 148); this.textServiceBinaryPath.Name = "textServiceBinaryPath"; this.textServiceBinaryPath.ReadOnly = true; - this.textServiceBinaryPath.Size = new System.Drawing.Size(303, 22); + this.textServiceBinaryPath.Size = new System.Drawing.Size(303, 20); this.textServiceBinaryPath.TabIndex = 26; // // labelServiceDisplayName // this.labelServiceDisplayName.AutoSize = true; - this.labelServiceDisplayName.Location = new System.Drawing.Point(12, 28); + this.labelServiceDisplayName.Location = new System.Drawing.Point(12, 30); this.labelServiceDisplayName.Name = "labelServiceDisplayName"; - this.labelServiceDisplayName.Size = new System.Drawing.Size(114, 13); + this.labelServiceDisplayName.Size = new System.Drawing.Size(111, 13); this.labelServiceDisplayName.TabIndex = 25; this.labelServiceDisplayName.Text = "Service Display Name"; // @@ -188,7 +187,7 @@ private void InitializeComponent() // this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonClose.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonClose.Location = new System.Drawing.Point(321, 272); + this.buttonClose.Location = new System.Drawing.Point(321, 232); this.buttonClose.Name = "buttonClose"; this.buttonClose.Size = new System.Drawing.Size(75, 23); this.buttonClose.TabIndex = 44; @@ -198,40 +197,39 @@ private void InitializeComponent() // // textServiceType // - this.textServiceType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textServiceType.Location = new System.Drawing.Point(50, 125); + this.textServiceType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textServiceType.Location = new System.Drawing.Point(52, 95); this.textServiceType.Name = "textServiceType"; this.textServiceType.ReadOnly = true; - this.textServiceType.Size = new System.Drawing.Size(143, 22); + this.textServiceType.Size = new System.Drawing.Size(143, 20); this.textServiceType.TabIndex = 37; // // textStartType // - this.textStartType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textStartType.Location = new System.Drawing.Point(264, 125); + this.textStartType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textStartType.Location = new System.Drawing.Point(266, 95); this.textStartType.Name = "textStartType"; this.textStartType.ReadOnly = true; - this.textStartType.Size = new System.Drawing.Size(130, 22); + this.textStartType.Size = new System.Drawing.Size(130, 20); this.textStartType.TabIndex = 37; // // textErrorControl // - this.textErrorControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textErrorControl.Location = new System.Drawing.Point(84, 152); + this.textErrorControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textErrorControl.Location = new System.Drawing.Point(86, 122); this.textErrorControl.Name = "textErrorControl"; this.textErrorControl.ReadOnly = true; - this.textErrorControl.Size = new System.Drawing.Size(109, 22); + this.textErrorControl.Size = new System.Drawing.Size(109, 20); this.textErrorControl.TabIndex = 37; // // DumpServiceWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(408, 307); + this.ClientSize = new System.Drawing.Size(408, 267); this.Controls.Add(this.buttonClose); this.Controls.Add(this.textServiceDll); this.Controls.Add(this.label8); diff --git a/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.cs b/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.cs index 2aa10ddd6..544c5a8d5 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.cs @@ -29,7 +29,7 @@ namespace ProcessHacker { public partial class DumpServiceWindow : Form { - private readonly MemoryObject _serviceMo; + private MemoryObject _serviceMo; public DumpServiceWindow(ServiceItem item, MemoryObject serviceMo) { @@ -76,10 +76,5 @@ private void buttonClose_Click(object sender, EventArgs e) { this.Close(); } - - private void textDescription_TextChanged(object sender, EventArgs e) - { - - } } } diff --git a/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.resx b/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/DumpServiceWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.Designer.cs index 81cbf9b4c..003cd449a 100644 --- a/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.Designer.cs @@ -40,14 +40,14 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 15); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(68, 13); + this.label1.Size = new System.Drawing.Size(65, 13); this.label1.TabIndex = 0; this.label1.Text = "New Status:"; // // comboStatus // - this.comboStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.comboStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.comboStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboStatus.FlatStyle = System.Windows.Forms.FlatStyle.System; this.comboStatus.FormattingEnabled = true; @@ -90,7 +90,7 @@ private void InitializeComponent() this.checkPermanent.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkPermanent.Location = new System.Drawing.Point(12, 39); this.checkPermanent.Name = "checkPermanent"; - this.checkPermanent.Size = new System.Drawing.Size(87, 18); + this.checkPermanent.Size = new System.Drawing.Size(83, 18); this.checkPermanent.TabIndex = 2; this.checkPermanent.Text = "Permanent"; this.checkPermanent.UseVisualStyleBackColor = true; @@ -101,7 +101,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(315, 104); this.Controls.Add(this.checkPermanent); this.Controls.Add(this.buttonCancel); diff --git a/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.cs b/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.cs index 96202ba6b..62d29908a 100644 --- a/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.cs @@ -32,12 +32,11 @@ namespace ProcessHacker { public partial class EditDEPWindow : Form { - private readonly int _pid; + private int _pid; public EditDEPWindow(int PID) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); @@ -45,9 +44,10 @@ public EditDEPWindow(int PID) try { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation)) + using (ProcessHandle phandle + = new ProcessHandle(_pid, ProcessAccess.QueryInformation)) { - var depStatus = phandle.DepStatus; + var depStatus = phandle.GetDepStatus(); string str; if ((depStatus & DepStatus.Enabled) != 0) @@ -64,7 +64,7 @@ public EditDEPWindow(int PID) comboStatus.SelectedItem = str; - if (KProcessHacker2.Instance.KphIsConnected) + if (KProcessHacker.Instance != null) checkPermanent.Visible = true; } } @@ -74,7 +74,7 @@ public EditDEPWindow(int PID) private void buttonOK_Click(object sender, EventArgs e) { - if (KProcessHacker2.Instance.KphIsConnected) + if (KProcessHacker.Instance != null) this.SetDepStatusKph(); else this.SetDepStatusNoKph(); @@ -82,22 +82,18 @@ private void buttonOK_Click(object sender, EventArgs e) private void SetDepStatusKph() { - DepStatus depStatus; + DepStatus depStatus = DepStatus.Enabled; - switch (this.comboStatus.SelectedItem.ToString()) + if (comboStatus.SelectedItem.ToString() == "Disabled") + depStatus = 0; + else if (comboStatus.SelectedItem.ToString() == "Enabled") + depStatus = DepStatus.Enabled; + else if (comboStatus.SelectedItem.ToString() == "Enabled, DEP-ATL thunk emulation disabled") + depStatus = DepStatus.Enabled | DepStatus.AtlThunkEmulationDisabled; + else { - case "Disabled": - depStatus = 0; - break; - case "Enabled": - depStatus = DepStatus.Enabled; - break; - case "Enabled, DEP-ATL thunk emulation disabled": - depStatus = DepStatus.Enabled | DepStatus.AtlThunkEmulationDisabled; - break; - default: - PhUtils.ShowError("Invalid value."); - return; + PhUtils.ShowError("Invalid value."); + return; } if (checkPermanent.Checked) @@ -105,8 +101,8 @@ private void SetDepStatusKph() try { - using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) - phandle.DepStatus = depStatus; + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) + phandle.SetDepStatus(depStatus); this.DialogResult = DialogResult.OK; this.Close(); @@ -119,15 +115,13 @@ private void SetDepStatusKph() private void SetDepStatusNoKph() { - if (comboStatus.SelectedItem.ToString().StartsWith("Enabled", StringComparison.OrdinalIgnoreCase)) - { + if (comboStatus.SelectedItem.ToString().StartsWith("Enabled")) if (!PhUtils.ShowConfirmMessage( "set", "the DEP status", "Enabling DEP in a process is a permanent action.", false)) return; - } DepFlags flags = DepFlags.Enable; diff --git a/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.resx b/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/EditDEPWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ErrorDialog.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ErrorDialog.Designer.cs index 63d062393..d894fef35 100644 --- a/1.x/trunk/ProcessHacker/Forms/ErrorDialog.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ErrorDialog.Designer.cs @@ -39,15 +39,15 @@ private void InitializeComponent() // // labelIntro // - this.labelIntro.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelIntro.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelIntro.Location = new System.Drawing.Point(12, 26); this.labelIntro.Name = "labelIntro"; this.labelIntro.Size = new System.Drawing.Size(484, 32); this.labelIntro.TabIndex = 0; this.labelIntro.Text = "Please report this error to the Process Hacker team via our bug tracker hosted at" + - " SourceForge by clicking Send Report. You will recieve a tracker item for keeing" + - " track of its resolution status."; + " SourceForge by clicking Send Report. You will recieve a tracker item for keeing" + + " track of its resolution status."; // // buttonContinue // @@ -75,9 +75,9 @@ private void InitializeComponent() // // textException // - this.textException.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textException.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textException.BackColor = System.Drawing.SystemColors.Control; this.textException.Location = new System.Drawing.Point(12, 61); this.textException.Multiline = true; @@ -106,7 +106,7 @@ private void InitializeComponent() this.statusLinkLabel.Enabled = false; this.statusLinkLabel.Location = new System.Drawing.Point(12, 336); this.statusLinkLabel.Name = "statusLinkLabel"; - this.statusLinkLabel.Size = new System.Drawing.Size(210, 13); + this.statusLinkLabel.Size = new System.Drawing.Size(199, 13); this.statusLinkLabel.TabIndex = 6; this.statusLinkLabel.TabStop = true; this.statusLinkLabel.Text = "Please Wait, Reporting to Bug Tracker..."; @@ -128,7 +128,7 @@ private void InitializeComponent() this.AcceptButton = this.buttonQuit; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; + this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(508, 366); this.Controls.Add(this.labelIntro); this.Controls.Add(this.label1); diff --git a/1.x/trunk/ProcessHacker/Forms/ErrorDialog.cs b/1.x/trunk/ProcessHacker/Forms/ErrorDialog.cs index 3ebc7552a..651e5ef8e 100644 --- a/1.x/trunk/ProcessHacker/Forms/ErrorDialog.cs +++ b/1.x/trunk/ProcessHacker/Forms/ErrorDialog.cs @@ -27,14 +27,13 @@ using System.Text.RegularExpressions; using System.Windows.Forms; using ProcessHacker.Common; -using ProcessHacker.Native; using ProcessHacker.Native.Api; namespace ProcessHacker { public partial class ErrorDialog : Form { - private readonly Exception _exception; + private Exception _exception; private string _trackerItem; public ErrorDialog(Exception ex, bool terminating) @@ -79,12 +78,12 @@ private void buttonQuit_Click(object sender, EventArgs e) Settings.Instance.Save(); // Remove the icons or they remain in the system try. - Program.HackerWindow.ExecuteOnIcons(icon => icon.Visible = false); - Program.HackerWindow.ExecuteOnIcons(icon => icon.Dispose()); + Program.HackerWindow.ExecuteOnIcons((icon) => icon.Visible = false); + Program.HackerWindow.ExecuteOnIcons((icon) => icon.Dispose()); // Make sure KPH connection is closed. - if (KProcessHacker2.Instance != null) - KProcessHacker2.Instance.Dispose(); + if (ProcessHacker.Native.KProcessHacker.Instance != null) + ProcessHacker.Native.KProcessHacker.Instance.Close(); } catch (Exception ex) { @@ -102,8 +101,8 @@ private void submitReportButton_Click(object sender, EventArgs e) this.statusLinkLabel.Visible = true; SFBugReporter wc = new SFBugReporter(); - wc.DownloadProgressChanged += wc_DownloadProgressChanged; - wc.DownloadStringCompleted += wc_DownloadStringCompleted; + wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged); + wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); NameValueCollection qc = new NameValueCollection(); qc.Add("group_id", "242527"); //PH BugTracker ID: Required Do Not Change! @@ -136,7 +135,7 @@ private void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEv buttonContinue.Enabled = true; buttonQuit.Enabled = true; - if (e.Error != null || this.GetTitle(e.Result).Contains("ERROR", StringComparison.OrdinalIgnoreCase)) + if (e.Error != null || this.GetTitle(e.Result).Contains("ERROR")) { buttonSubmitReport.Enabled = true; statusLinkLabel.Visible = false; @@ -170,8 +169,10 @@ private string GetTitle(string data) { return m.Groups[1].Value; } - - return string.Empty; + else + { + return ""; + } } private string GetResult(string data) @@ -182,8 +183,10 @@ private string GetResult(string data) { return m.Groups[1].Value; } - - return string.Empty; + else + { + return ""; + } } private string GetUrl(string data) @@ -194,15 +197,17 @@ private string GetUrl(string data) { return m.Value; } - - return string.Empty; + else + { + return ""; + } } - public class SFBugReporter : WebClient + public partial class SFBugReporter : WebClient { protected override WebRequest GetWebRequest(Uri uri) { - HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri); + System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)base.GetWebRequest(uri); webRequest.UserAgent = "Process Hacker " + Application.ProductVersion; webRequest.Timeout = System.Threading.Timeout.Infinite; webRequest.ServicePoint.Expect100Continue = true; //fix for Sourceforge's lighttpd Server diff --git a/1.x/trunk/ProcessHacker/Forms/ErrorDialog.resx b/1.x/trunk/ProcessHacker/Forms/ErrorDialog.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ErrorDialog.resx +++ b/1.x/trunk/ProcessHacker/Forms/ErrorDialog.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.Designer.cs index fbe53d50e..042fd6062 100644 --- a/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.Designer.cs @@ -41,7 +41,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 15); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(118, 13); + this.label1.Size = new System.Drawing.Size(109, 13); this.label1.TabIndex = 4; this.label1.Text = "Export Name/Ordinal:"; // @@ -50,29 +50,29 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 41); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(51, 13); + this.label2.Size = new System.Drawing.Size(48, 13); this.label2.TabIndex = 5; this.label2.Text = "Address:"; // // textProcName // - this.textProcName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textProcName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textProcName.Location = new System.Drawing.Point(127, 12); this.textProcName.Name = "textProcName"; - this.textProcName.Size = new System.Drawing.Size(255, 22); + this.textProcName.Size = new System.Drawing.Size(255, 20); this.textProcName.TabIndex = 0; - this.textProcName.Enter += new System.EventHandler(this.textProcName_Enter); this.textProcName.Leave += new System.EventHandler(this.textProcName_Leave); + this.textProcName.Enter += new System.EventHandler(this.textProcName_Enter); // // textProcAddress // - this.textProcAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textProcAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textProcAddress.Location = new System.Drawing.Point(127, 38); this.textProcAddress.Name = "textProcAddress"; this.textProcAddress.ReadOnly = true; - this.textProcAddress.Size = new System.Drawing.Size(255, 22); + this.textProcAddress.Size = new System.Drawing.Size(255, 20); this.textProcAddress.TabIndex = 1; // // buttonLookup @@ -103,7 +103,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(394, 99); this.Controls.Add(this.buttonClose); this.Controls.Add(this.buttonLookup); diff --git a/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.cs b/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.cs index 196dd5453..fccbc20c6 100644 --- a/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.cs @@ -29,7 +29,7 @@ namespace ProcessHacker { public partial class GetProcAddressWindow : Form { - private readonly string _fileName; + private string _fileName; public GetProcAddressWindow(string fileName) { @@ -45,7 +45,7 @@ public GetProcAddressWindow(string fileName) private void buttonLookup_Click(object sender, EventArgs e) { IntPtr module = Win32.LoadLibraryEx(_fileName, IntPtr.Zero, Win32.DontResolveDllReferences); - IntPtr address; + IntPtr address = IntPtr.Zero; int ordinal = 0; if (module == IntPtr.Zero) diff --git a/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.resx b/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/GetProcAddressWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/HackerWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/HackerWindow.Designer.cs index 105cfb5a0..5841ae453 100644 --- a/1.x/trunk/ProcessHacker/Forms/HackerWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/HackerWindow.Designer.cs @@ -30,6 +30,54 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HackerWindow)); + this.menuProcess = new System.Windows.Forms.ContextMenu(); + this.terminateMenuItem = new System.Windows.Forms.MenuItem(); + this.terminateProcessTreeMenuItem = new System.Windows.Forms.MenuItem(); + this.suspendMenuItem = new System.Windows.Forms.MenuItem(); + this.resumeMenuItem = new System.Windows.Forms.MenuItem(); + this.restartProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.reduceWorkingSetProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.virtualizationProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem5 = new System.Windows.Forms.MenuItem(); + this.affinityProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.createDumpFileProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.terminatorProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.miscellaneousProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.analyzeWaitChainProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.detachFromDebuggerProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.heapsProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.injectDllProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.ioPriorityThreadMenuItem = new System.Windows.Forms.MenuItem(); + this.ioPriority0ThreadMenuItem = new System.Windows.Forms.MenuItem(); + this.ioPriority1ThreadMenuItem = new System.Windows.Forms.MenuItem(); + this.ioPriority2ThreadMenuItem = new System.Windows.Forms.MenuItem(); + this.ioPriority3ThreadMenuItem = new System.Windows.Forms.MenuItem(); + this.protectionProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.setTokenProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.VirusTotalMenuItem = new System.Windows.Forms.MenuItem(); + this.priorityMenuItem = new System.Windows.Forms.MenuItem(); + this.realTimeMenuItem = new System.Windows.Forms.MenuItem(); + this.highMenuItem = new System.Windows.Forms.MenuItem(); + this.aboveNormalMenuItem = new System.Windows.Forms.MenuItem(); + this.normalMenuItem = new System.Windows.Forms.MenuItem(); + this.belowNormalMenuItem = new System.Windows.Forms.MenuItem(); + this.idleMenuItem = new System.Windows.Forms.MenuItem(); + this.runAsProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.launchAsUserProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.launchAsThisUserProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.windowProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.bringToFrontProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.restoreProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.minimizeProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.maximizeProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem15 = new System.Windows.Forms.MenuItem(); + this.closeProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.propertiesProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem7 = new System.Windows.Forms.MenuItem(); + this.searchProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.reanalyzeProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.copyProcessMenuItem = new System.Windows.Forms.MenuItem(); + this.selectAllProcessMenuItem = new System.Windows.Forms.MenuItem(); this.toolStripMenuItem9 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem10 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem11 = new System.Windows.Forms.ToolStripMenuItem(); @@ -37,170 +85,464 @@ private void InitializeComponent() this.toolStripMenuItem13 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem14 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem15 = new System.Windows.Forms.ToolStripMenuItem(); + this.mainMenu = new System.Windows.Forms.MainMenu(this.components); + this.hackerMenuItem = new System.Windows.Forms.MenuItem(); + this.runMenuItem = new System.Windows.Forms.MenuItem(); + this.runAsAdministratorMenuItem = new System.Windows.Forms.MenuItem(); + this.runAsMenuItem = new System.Windows.Forms.MenuItem(); + this.runAsServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.showDetailsForAllProcessesMenuItem = new System.Windows.Forms.MenuItem(); + this.uacSeparatorMenuItem = new System.Windows.Forms.MenuItem(); + this.openMenuItem = new System.Windows.Forms.MenuItem(); + this.saveMenuItem = new System.Windows.Forms.MenuItem(); + this.findHandlesMenuItem = new System.Windows.Forms.MenuItem(); + this.inspectPEFileMenuItem = new System.Windows.Forms.MenuItem(); + this.reloadStructsMenuItem = new System.Windows.Forms.MenuItem(); + this.optionsMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem2 = new System.Windows.Forms.MenuItem(); + this.shutdownMenuItem = new System.Windows.Forms.MenuItem(); + this.exitMenuItem = new System.Windows.Forms.MenuItem(); + this.viewMenuItem = new System.Windows.Forms.MenuItem(); + this.toolbarMenuItem = new System.Windows.Forms.MenuItem(); + this.sysInfoMenuItem = new System.Windows.Forms.MenuItem(); + this.trayIconsMenuItem = new System.Windows.Forms.MenuItem(); + this.cpuHistoryMenuItem = new System.Windows.Forms.MenuItem(); + this.cpuUsageMenuItem = new System.Windows.Forms.MenuItem(); + this.ioHistoryMenuItem = new System.Windows.Forms.MenuItem(); + this.commitHistoryMenuItem = new System.Windows.Forms.MenuItem(); + this.physMemHistoryMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem3 = new System.Windows.Forms.MenuItem(); + this.updateNowMenuItem = new System.Windows.Forms.MenuItem(); + this.updateProcessesMenuItem = new System.Windows.Forms.MenuItem(); + this.updateServicesMenuItem = new System.Windows.Forms.MenuItem(); + this.toolsMenuItem = new System.Windows.Forms.MenuItem(); + this.createServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.hiddenProcessesMenuItem = new System.Windows.Forms.MenuItem(); + this.verifyFileSignatureMenuItem = new System.Windows.Forms.MenuItem(); + this.usersMenuItem = new System.Windows.Forms.MenuItem(); + this.windowMenuItem = new System.Windows.Forms.MenuItem(); + this.helpMenu = new System.Windows.Forms.MenuItem(); + this.freeMemoryMenuItem = new System.Windows.Forms.MenuItem(); + this.checkForUpdatesMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem1 = new System.Windows.Forms.MenuItem(); + this.logMenuItem = new System.Windows.Forms.MenuItem(); + this.helpMenuItem = new System.Windows.Forms.MenuItem(); + this.donateMenuItem = new System.Windows.Forms.MenuItem(); + this.aboutMenuItem = new System.Windows.Forms.MenuItem(); + this.statusBar = new System.Windows.Forms.StatusBar(); + this.statusGeneral = new System.Windows.Forms.StatusBarPanel(); + this.statusCPU = new System.Windows.Forms.StatusBarPanel(); + this.statusMemory = new System.Windows.Forms.StatusBarPanel(); this.tabControl = new System.Windows.Forms.TabControl(); this.tabProcesses = new System.Windows.Forms.TabPage(); this.treeProcesses = new ProcessHacker.ProcessTree(); - this.contextMenuStripProcess = new System.Windows.Forms.ContextMenuStrip(this.components); - this.terminateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.terminateProcessTreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.suspendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.resumeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.restartToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.reduceWorkingSetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.virtualizationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator14 = new System.Windows.Forms.ToolStripSeparator(); - this.affinityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.createDumpFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.terminatorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.miscellaneousToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.analyzeWaitChainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.detachFromDebuggerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.heapsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.injectDLLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.iOPriorityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ioPriority0ThreadMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ioPriority1ThreadMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ioPriority3ThreadMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem(); - this.protectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.setTokenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.uploadToVirusTotalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.priorityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.realTimeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.highToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.aboveNormalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.normalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.belowNormalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.idleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.runAsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.launchAsUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.launchAsThisUserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.windowToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.bringToFrontToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.minimizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.maximizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator17 = new System.Windows.Forms.ToolStripSeparator(); - this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator15 = new System.Windows.Forms.ToolStripSeparator(); - this.searchOnlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.reanalyzeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.copyProcessMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator16 = new System.Windows.Forms.ToolStripSeparator(); - this.propertiesToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.tabServices = new System.Windows.Forms.TabPage(); this.listServices = new ProcessHacker.Components.ServiceList(); - this.contextMenuStripService = new System.Windows.Forms.ContextMenuStrip(this.components); - this.goToProcessServiceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator11 = new System.Windows.Forms.ToolStripSeparator(); - this.startToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pauseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.continueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.stopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator(); - this.copyToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.selectAllServiceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator13 = new System.Windows.Forms.ToolStripSeparator(); - this.propertiesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tabNetwork = new System.Windows.Forms.TabPage(); this.listNetwork = new ProcessHacker.Components.NetworkList(); - this.contextMenuStripNetwork = new System.Windows.Forms.ContextMenuStrip(this.components); - this.goToProcessNetworkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.whoisNetworkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tracertNetworkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pingNetworkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.closeNetworkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); - this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.selectAllNetworkMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStrip = new System.ToolStripEx(); + this.toolStrip = new System.Windows.Forms.ToolStrip(); this.refreshToolStripButton = new System.Windows.Forms.ToolStripButton(); this.optionsToolStripButton = new System.Windows.Forms.ToolStripButton(); this.shutDownToolStripMenuItem = new System.Windows.Forms.ToolStripDropDownButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.findHandlesToolStripButton = new System.Windows.Forms.ToolStripButton(); this.sysInfoToolStripButton = new System.Windows.Forms.ToolStripButton(); - this.toolStripTextBox2 = new ProcessHacker.HackerWindow.ToolStripSearchBox(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.statusMemory = new System.Windows.Forms.ToolStripStatusLabel(); - this.statusCPU = new System.Windows.Forms.ToolStripStatusLabel(); - this.statusGeneral = new System.Windows.Forms.ToolStripStatusLabel(); - this.menuStripEx1 = new System.MenuStripEx(); - this.hackerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.runToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.runAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.runAsAdministratorMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showDetailsForAllProcessesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.findHandlesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.inspectPEFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.optionsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.shutdownMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolbarMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.sysInfoMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.trayIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cpuHistoryMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cpuUsageMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ioHistoryMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.commitHistoryMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.physMemHistoryMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.updateProcessesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.updateServicesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.createServiceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.hiddenProcessesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.verifyFileSignatureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.usersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.windowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.checkForUpdatesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.logToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.contextMenuStripTray = new System.Windows.Forms.ContextMenuStrip(this.components); - this.showHideProcessHackerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.systemInformationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.networkInfomationMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); - this.processesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.notificationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.enableAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.disableAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator10 = new System.Windows.Forms.ToolStripSeparator(); - this.newProcessesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.terminatedProcessesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.newServicesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.startedServicesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.stoppedServicesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.deletedServicesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); - this.shutdownTrayMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.menuService = new System.Windows.Forms.ContextMenu(); + this.goToProcessServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.startServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.continueServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.pauseServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.stopServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.deleteServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.propertiesServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem8 = new System.Windows.Forms.MenuItem(); + this.copyServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.selectAllServiceMenuItem = new System.Windows.Forms.MenuItem(); + this.menuIcon = new System.Windows.Forms.ContextMenu(); + this.showHideMenuItem = new System.Windows.Forms.MenuItem(); + this.sysInformationIconMenuItem = new System.Windows.Forms.MenuItem(); + this.networkInfomationMenuItem = new System.Windows.Forms.MenuItem(); + this.notificationsMenuItem = new System.Windows.Forms.MenuItem(); + this.enableAllNotificationsMenuItem = new System.Windows.Forms.MenuItem(); + this.disableAllNotificationsMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem4 = new System.Windows.Forms.MenuItem(); + this.NPMenuItem = new System.Windows.Forms.MenuItem(); + this.TPMenuItem = new System.Windows.Forms.MenuItem(); + this.NSMenuItem = new System.Windows.Forms.MenuItem(); + this.startedSMenuItem = new System.Windows.Forms.MenuItem(); + this.stoppedSMenuItem = new System.Windows.Forms.MenuItem(); + this.DSMenuItem = new System.Windows.Forms.MenuItem(); + this.processesMenuItem = new System.Windows.Forms.MenuItem(); + this.shutdownTrayMenuItem = new System.Windows.Forms.MenuItem(); + this.exitTrayMenuItem = new System.Windows.Forms.MenuItem(); + this.goToProcessNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.copyNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.closeNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.menuNetwork = new System.Windows.Forms.ContextMenu(); + this.toolsNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.whoisNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.tracertNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.pingNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.menuItem6 = new System.Windows.Forms.MenuItem(); + this.selectAllNetworkMenuItem = new System.Windows.Forms.MenuItem(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); + ((System.ComponentModel.ISupportInitialize)(this.statusGeneral)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusCPU)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusMemory)).BeginInit(); this.tabControl.SuspendLayout(); this.tabProcesses.SuspendLayout(); - this.contextMenuStripProcess.SuspendLayout(); this.tabServices.SuspendLayout(); - this.contextMenuStripService.SuspendLayout(); this.tabNetwork.SuspendLayout(); - this.contextMenuStripNetwork.SuspendLayout(); this.toolStrip.SuspendLayout(); - this.statusStrip1.SuspendLayout(); - this.menuStripEx1.SuspendLayout(); - this.contextMenuStripTray.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // + // menuProcess + // + this.menuProcess.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.terminateMenuItem, + this.terminateProcessTreeMenuItem, + this.suspendMenuItem, + this.resumeMenuItem, + this.restartProcessMenuItem, + this.reduceWorkingSetProcessMenuItem, + this.virtualizationProcessMenuItem, + this.menuItem5, + this.affinityProcessMenuItem, + this.createDumpFileProcessMenuItem, + this.terminatorProcessMenuItem, + this.miscellaneousProcessMenuItem, + this.priorityMenuItem, + this.runAsProcessMenuItem, + this.windowProcessMenuItem, + this.propertiesProcessMenuItem, + this.menuItem7, + this.searchProcessMenuItem, + this.reanalyzeProcessMenuItem, + this.copyProcessMenuItem, + this.selectAllProcessMenuItem}); + this.menuProcess.Popup += new System.EventHandler(this.menuProcess_Popup); + // + // terminateMenuItem + // + this.vistaMenu.SetImage(this.terminateMenuItem, global::ProcessHacker.Properties.Resources.cross); + this.terminateMenuItem.Index = 0; + this.terminateMenuItem.Shortcut = System.Windows.Forms.Shortcut.Del; + this.terminateMenuItem.Text = "&Terminate"; + this.terminateMenuItem.Click += new System.EventHandler(this.terminateMenuItem_Click); + // + // terminateProcessTreeMenuItem + // + this.terminateProcessTreeMenuItem.Index = 1; + this.terminateProcessTreeMenuItem.Text = "Terminate Process Tree"; + this.terminateProcessTreeMenuItem.Click += new System.EventHandler(this.terminateProcessTreeMenuItem_Click); + // + // suspendMenuItem + // + this.vistaMenu.SetImage(this.suspendMenuItem, global::ProcessHacker.Properties.Resources.control_pause_blue); + this.suspendMenuItem.Index = 2; + this.suspendMenuItem.Text = "&Suspend"; + this.suspendMenuItem.Click += new System.EventHandler(this.suspendMenuItem_Click); + // + // resumeMenuItem + // + this.vistaMenu.SetImage(this.resumeMenuItem, global::ProcessHacker.Properties.Resources.control_play_blue); + this.resumeMenuItem.Index = 3; + this.resumeMenuItem.Text = "&Resume"; + this.resumeMenuItem.Click += new System.EventHandler(this.resumeMenuItem_Click); + // + // restartProcessMenuItem + // + this.restartProcessMenuItem.Index = 4; + this.restartProcessMenuItem.Text = "Restart"; + this.restartProcessMenuItem.Click += new System.EventHandler(this.restartProcessMenuItem_Click); + // + // reduceWorkingSetProcessMenuItem + // + this.reduceWorkingSetProcessMenuItem.Index = 5; + this.reduceWorkingSetProcessMenuItem.Text = "Reduce Working Set"; + this.reduceWorkingSetProcessMenuItem.Click += new System.EventHandler(this.reduceWorkingSetProcessMenuItem_Click); + // + // virtualizationProcessMenuItem + // + this.virtualizationProcessMenuItem.Index = 6; + this.virtualizationProcessMenuItem.Text = "Virtualization"; + this.virtualizationProcessMenuItem.Click += new System.EventHandler(this.virtualizationProcessMenuItem_Click); + // + // menuItem5 + // + this.menuItem5.Index = 7; + this.menuItem5.Text = "-"; + // + // affinityProcessMenuItem + // + this.affinityProcessMenuItem.Index = 8; + this.affinityProcessMenuItem.Text = "Affinity..."; + this.affinityProcessMenuItem.Click += new System.EventHandler(this.affinityProcessMenuItem_Click); + // + // createDumpFileProcessMenuItem + // + this.createDumpFileProcessMenuItem.Index = 9; + this.createDumpFileProcessMenuItem.Text = "Create Dump File..."; + this.createDumpFileProcessMenuItem.Click += new System.EventHandler(this.createDumpFileProcessMenuItem_Click); + // + // terminatorProcessMenuItem + // + this.terminatorProcessMenuItem.Index = 10; + this.terminatorProcessMenuItem.Text = "Terminator"; + this.terminatorProcessMenuItem.Click += new System.EventHandler(this.terminatorProcessMenuItem_Click); + // + // miscellaneousProcessMenuItem + // + this.miscellaneousProcessMenuItem.Index = 11; + this.miscellaneousProcessMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.analyzeWaitChainProcessMenuItem, + this.detachFromDebuggerProcessMenuItem, + this.heapsProcessMenuItem, + this.injectDllProcessMenuItem, + this.ioPriorityThreadMenuItem, + this.protectionProcessMenuItem, + this.setTokenProcessMenuItem, + this.VirusTotalMenuItem}); + this.miscellaneousProcessMenuItem.Text = "Miscellaneous"; + // + // analyzeWaitChainProcessMenuItem + // + this.analyzeWaitChainProcessMenuItem.Index = 0; + this.analyzeWaitChainProcessMenuItem.Text = "Analyze Wait Chain"; + this.analyzeWaitChainProcessMenuItem.Click += new System.EventHandler(this.analyzeWaitChainProcessMenuItem_Click); + // + // detachFromDebuggerProcessMenuItem + // + this.detachFromDebuggerProcessMenuItem.Index = 1; + this.detachFromDebuggerProcessMenuItem.Text = "Detach from Debugger"; + this.detachFromDebuggerProcessMenuItem.Click += new System.EventHandler(this.detachFromDebuggerProcessMenuItem_Click); + // + // heapsProcessMenuItem + // + this.heapsProcessMenuItem.Index = 2; + this.heapsProcessMenuItem.Text = "Heaps"; + this.heapsProcessMenuItem.Click += new System.EventHandler(this.heapsProcessMenuItem_Click); + // + // injectDllProcessMenuItem + // + this.injectDllProcessMenuItem.Index = 3; + this.injectDllProcessMenuItem.Text = "Inject DLL..."; + this.injectDllProcessMenuItem.Click += new System.EventHandler(this.injectDllProcessMenuItem_Click); + // + // ioPriorityThreadMenuItem + // + this.ioPriorityThreadMenuItem.Index = 4; + this.ioPriorityThreadMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.ioPriority0ThreadMenuItem, + this.ioPriority1ThreadMenuItem, + this.ioPriority2ThreadMenuItem, + this.ioPriority3ThreadMenuItem}); + this.ioPriorityThreadMenuItem.Text = "I/O Priority"; + // + // ioPriority0ThreadMenuItem + // + this.ioPriority0ThreadMenuItem.Index = 0; + this.ioPriority0ThreadMenuItem.Text = "0"; + this.ioPriority0ThreadMenuItem.Click += new System.EventHandler(this.ioPriority0ThreadMenuItem_Click); + // + // ioPriority1ThreadMenuItem + // + this.ioPriority1ThreadMenuItem.Index = 1; + this.ioPriority1ThreadMenuItem.Text = "1"; + this.ioPriority1ThreadMenuItem.Click += new System.EventHandler(this.ioPriority1ThreadMenuItem_Click); + // + // ioPriority2ThreadMenuItem + // + this.ioPriority2ThreadMenuItem.Index = 2; + this.ioPriority2ThreadMenuItem.Text = "2"; + this.ioPriority2ThreadMenuItem.Click += new System.EventHandler(this.ioPriority2ThreadMenuItem_Click); + // + // ioPriority3ThreadMenuItem + // + this.ioPriority3ThreadMenuItem.Index = 3; + this.ioPriority3ThreadMenuItem.Text = "3"; + this.ioPriority3ThreadMenuItem.Click += new System.EventHandler(this.ioPriority3ThreadMenuItem_Click); + // + // protectionProcessMenuItem + // + this.protectionProcessMenuItem.Index = 5; + this.protectionProcessMenuItem.Text = "Protection"; + this.protectionProcessMenuItem.Click += new System.EventHandler(this.protectionProcessMenuItem_Click); + // + // setTokenProcessMenuItem + // + this.setTokenProcessMenuItem.Index = 6; + this.setTokenProcessMenuItem.Text = "Set Token..."; + this.setTokenProcessMenuItem.Click += new System.EventHandler(this.setTokenProcessMenuItem_Click); + // + // VirusTotalMenuItem + // + this.VirusTotalMenuItem.Index = 7; + this.VirusTotalMenuItem.Text = "Upload to VirusTotal"; + this.VirusTotalMenuItem.Click += new System.EventHandler(this.virusTotalMenuItem_Click); + // + // priorityMenuItem + // + this.vistaMenu.SetImage(this.priorityMenuItem, global::ProcessHacker.Properties.Resources.control_equalizer_blue); + this.priorityMenuItem.Index = 12; + this.priorityMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.realTimeMenuItem, + this.highMenuItem, + this.aboveNormalMenuItem, + this.normalMenuItem, + this.belowNormalMenuItem, + this.idleMenuItem}); + this.priorityMenuItem.Text = "&Priority"; + // + // realTimeMenuItem + // + this.realTimeMenuItem.Index = 0; + this.realTimeMenuItem.RadioCheck = true; + this.realTimeMenuItem.Text = "Real Time"; + this.realTimeMenuItem.Click += new System.EventHandler(this.realTimeMenuItem_Click); + // + // highMenuItem + // + this.highMenuItem.Index = 1; + this.highMenuItem.RadioCheck = true; + this.highMenuItem.Text = "High"; + this.highMenuItem.Click += new System.EventHandler(this.highMenuItem_Click); + // + // aboveNormalMenuItem + // + this.aboveNormalMenuItem.Index = 2; + this.aboveNormalMenuItem.RadioCheck = true; + this.aboveNormalMenuItem.Text = "Above Normal"; + this.aboveNormalMenuItem.Click += new System.EventHandler(this.aboveNormalMenuItem_Click); + // + // normalMenuItem + // + this.normalMenuItem.Index = 3; + this.normalMenuItem.RadioCheck = true; + this.normalMenuItem.Text = "Normal"; + this.normalMenuItem.Click += new System.EventHandler(this.normalMenuItem_Click); + // + // belowNormalMenuItem + // + this.belowNormalMenuItem.Index = 4; + this.belowNormalMenuItem.RadioCheck = true; + this.belowNormalMenuItem.Text = "Below Normal"; + this.belowNormalMenuItem.Click += new System.EventHandler(this.belowNormalMenuItem_Click); + // + // idleMenuItem + // + this.idleMenuItem.Index = 5; + this.idleMenuItem.RadioCheck = true; + this.idleMenuItem.Text = "Idle"; + this.idleMenuItem.Click += new System.EventHandler(this.idleMenuItem_Click); + // + // runAsProcessMenuItem + // + this.runAsProcessMenuItem.Index = 13; + this.runAsProcessMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.launchAsUserProcessMenuItem, + this.launchAsThisUserProcessMenuItem}); + this.runAsProcessMenuItem.Text = "Run As"; + // + // launchAsUserProcessMenuItem + // + this.launchAsUserProcessMenuItem.Index = 0; + this.launchAsUserProcessMenuItem.Text = "Launch As User..."; + this.launchAsUserProcessMenuItem.Click += new System.EventHandler(this.launchAsUserProcessMenuItem_Click); + // + // launchAsThisUserProcessMenuItem + // + this.launchAsThisUserProcessMenuItem.Index = 1; + this.launchAsThisUserProcessMenuItem.Text = "Launch As This User..."; + this.launchAsThisUserProcessMenuItem.Click += new System.EventHandler(this.launchAsThisUserProcessMenuItem_Click); + // + // windowProcessMenuItem + // + this.windowProcessMenuItem.Index = 14; + this.windowProcessMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.bringToFrontProcessMenuItem, + this.restoreProcessMenuItem, + this.minimizeProcessMenuItem, + this.maximizeProcessMenuItem, + this.menuItem15, + this.closeProcessMenuItem}); + this.windowProcessMenuItem.Text = "&Window"; + // + // bringToFrontProcessMenuItem + // + this.bringToFrontProcessMenuItem.Index = 0; + this.bringToFrontProcessMenuItem.Text = "&Bring to Front"; + this.bringToFrontProcessMenuItem.Click += new System.EventHandler(this.bringToFrontProcessMenuItem_Click); + // + // restoreProcessMenuItem + // + this.restoreProcessMenuItem.Index = 1; + this.restoreProcessMenuItem.Text = "&Restore"; + this.restoreProcessMenuItem.Click += new System.EventHandler(this.restoreProcessMenuItem_Click); + // + // minimizeProcessMenuItem + // + this.minimizeProcessMenuItem.Index = 2; + this.minimizeProcessMenuItem.Text = "&Minimize"; + this.minimizeProcessMenuItem.Click += new System.EventHandler(this.minimizeProcessMenuItem_Click); + // + // maximizeProcessMenuItem + // + this.maximizeProcessMenuItem.Index = 3; + this.maximizeProcessMenuItem.Text = "Ma&ximize"; + this.maximizeProcessMenuItem.Click += new System.EventHandler(this.maximizeProcessMenuItem_Click); + // + // menuItem15 + // + this.menuItem15.Index = 4; + this.menuItem15.Text = "-"; + // + // closeProcessMenuItem + // + this.closeProcessMenuItem.Index = 5; + this.closeProcessMenuItem.Text = "&Close"; + this.closeProcessMenuItem.Click += new System.EventHandler(this.closeProcessMenuItem_Click); + // + // propertiesProcessMenuItem + // + this.propertiesProcessMenuItem.DefaultItem = true; + this.vistaMenu.SetImage(this.propertiesProcessMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify); + this.propertiesProcessMenuItem.Index = 15; + this.propertiesProcessMenuItem.Text = "&Properties"; + this.propertiesProcessMenuItem.Click += new System.EventHandler(this.propertiesProcessMenuItem_Click); + // + // menuItem7 + // + this.menuItem7.Index = 16; + this.menuItem7.Text = "-"; + // + // searchProcessMenuItem + // + this.searchProcessMenuItem.Index = 17; + this.searchProcessMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlM; + this.searchProcessMenuItem.Text = "&Search Online"; + this.searchProcessMenuItem.Click += new System.EventHandler(this.searchProcessMenuItem_Click); + // + // reanalyzeProcessMenuItem + // + this.reanalyzeProcessMenuItem.Index = 18; + this.reanalyzeProcessMenuItem.Text = "Re-analyze"; + this.reanalyzeProcessMenuItem.Click += new System.EventHandler(this.reanalyzeProcessMenuItem_Click); + // + // copyProcessMenuItem + // + this.vistaMenu.SetImage(this.copyProcessMenuItem, global::ProcessHacker.Properties.Resources.page_copy); + this.copyProcessMenuItem.Index = 19; + this.copyProcessMenuItem.Text = "&Copy"; + // + // selectAllProcessMenuItem + // + this.selectAllProcessMenuItem.Index = 20; + this.selectAllProcessMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlA; + this.selectAllProcessMenuItem.Text = "Select &All"; + this.selectAllProcessMenuItem.Click += new System.EventHandler(this.selectAllProcessMenuItem_Click); + // // toolStripMenuItem9 // this.toolStripMenuItem9.Name = "toolStripMenuItem9"; @@ -243,409 +585,391 @@ private void InitializeComponent() this.toolStripMenuItem15.Size = new System.Drawing.Size(151, 22); this.toolStripMenuItem15.Text = "Idle"; // - // tabControl - // - this.tabControl.Controls.Add(this.tabProcesses); - this.tabControl.Controls.Add(this.tabServices); - this.tabControl.Controls.Add(this.tabNetwork); - this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl.Location = new System.Drawing.Point(0, 52); - this.tabControl.Name = "tabControl"; - this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(804, 494); - this.tabControl.TabIndex = 6; - this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControlBig_SelectedIndexChanged); + // mainMenu // - // tabProcesses + this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.hackerMenuItem, + this.viewMenuItem, + this.toolsMenuItem, + this.usersMenuItem, + this.windowMenuItem, + this.helpMenu}); // - this.tabProcesses.Controls.Add(this.treeProcesses); - this.tabProcesses.Location = new System.Drawing.Point(4, 22); - this.tabProcesses.Name = "tabProcesses"; - this.tabProcesses.Padding = new System.Windows.Forms.Padding(3); - this.tabProcesses.Size = new System.Drawing.Size(796, 468); - this.tabProcesses.TabIndex = 0; - this.tabProcesses.Text = "Processes"; - this.tabProcesses.UseVisualStyleBackColor = true; + // hackerMenuItem // - // treeProcesses + this.hackerMenuItem.Index = 0; + this.hackerMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.runMenuItem, + this.runAsAdministratorMenuItem, + this.runAsMenuItem, + this.runAsServiceMenuItem, + this.showDetailsForAllProcessesMenuItem, + this.uacSeparatorMenuItem, + this.openMenuItem, + this.saveMenuItem, + this.findHandlesMenuItem, + this.inspectPEFileMenuItem, + this.reloadStructsMenuItem, + this.optionsMenuItem, + this.menuItem2, + this.shutdownMenuItem, + this.exitMenuItem}); + this.hackerMenuItem.Text = "&Hacker"; // - this.treeProcesses.ContextMenuStrip = this.contextMenuStripProcess; - this.treeProcesses.Dock = System.Windows.Forms.DockStyle.Fill; - this.treeProcesses.Draw = true; - this.treeProcesses.DumpMode = false; - this.treeProcesses.DumpProcesses = null; - this.treeProcesses.DumpProcessServices = null; - this.treeProcesses.DumpServices = null; - this.treeProcesses.DumpUserName = null; - this.treeProcesses.Location = new System.Drawing.Point(3, 3); - this.treeProcesses.Name = "treeProcesses"; - this.treeProcesses.Provider = null; - this.treeProcesses.Size = new System.Drawing.Size(790, 462); - this.treeProcesses.TabIndex = 4; - this.treeProcesses.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeProcesses_KeyDown); - this.treeProcesses.SelectionChanged += new System.EventHandler(this.treeProcesses_SelectionChanged); - this.treeProcesses.NodeMouseDoubleClick += new System.EventHandler(this.treeProcesses_NodeMouseDoubleClick); + // runMenuItem // - // contextMenuStripProcess - // - this.contextMenuStripProcess.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.terminateToolStripMenuItem, - this.terminateProcessTreeToolStripMenuItem, - this.suspendToolStripMenuItem, - this.resumeToolStripMenuItem, - this.restartToolStripMenuItem, - this.reduceWorkingSetToolStripMenuItem, - this.virtualizationToolStripMenuItem, - this.toolStripSeparator14, - this.affinityToolStripMenuItem, - this.createDumpFileToolStripMenuItem, - this.terminatorToolStripMenuItem, - this.miscellaneousToolStripMenuItem, - this.priorityToolStripMenuItem, - this.runAsToolStripMenuItem1, - this.windowToolStripMenuItem1, - this.toolStripSeparator15, - this.searchOnlineToolStripMenuItem, - this.reanalyzeToolStripMenuItem, - this.copyProcessMenuItem, - this.selectAllToolStripMenuItem, - this.toolStripSeparator16, - this.propertiesToolStripMenuItem1}); - this.contextMenuStripProcess.Name = "contextMenuStripProcess"; - this.contextMenuStripProcess.Size = new System.Drawing.Size(198, 462); + this.runMenuItem.Index = 0; + this.runMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlR; + this.runMenuItem.Text = "&Run..."; + this.runMenuItem.Click += new System.EventHandler(this.runMenuItem_Click); // - // terminateToolStripMenuItem + // runAsAdministratorMenuItem // - this.terminateToolStripMenuItem.Name = "terminateToolStripMenuItem"; - this.terminateToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.terminateToolStripMenuItem.Text = "&Terminate"; - this.terminateToolStripMenuItem.Click += new System.EventHandler(this.terminateMenuItem_Click); + this.runAsAdministratorMenuItem.Index = 1; + this.runAsAdministratorMenuItem.Text = "Run As Administrator..."; + this.runAsAdministratorMenuItem.Click += new System.EventHandler(this.runAsAdministratorMenuItem_Click); // - // terminateProcessTreeToolStripMenuItem + // runAsMenuItem // - this.terminateProcessTreeToolStripMenuItem.Name = "terminateProcessTreeToolStripMenuItem"; - this.terminateProcessTreeToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.terminateProcessTreeToolStripMenuItem.Text = "Terminate Process Tree"; - this.terminateProcessTreeToolStripMenuItem.Click += new System.EventHandler(this.terminateProcessTreeMenuItem_Click); + this.runAsMenuItem.Index = 2; + this.runAsMenuItem.Text = "Run As..."; + this.runAsMenuItem.Visible = false; + this.runAsMenuItem.Click += new System.EventHandler(this.runAsMenuItem_Click); // - // suspendToolStripMenuItem + // runAsServiceMenuItem // - this.suspendToolStripMenuItem.Name = "suspendToolStripMenuItem"; - this.suspendToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.suspendToolStripMenuItem.Text = "&Suspend"; - this.suspendToolStripMenuItem.Click += new System.EventHandler(this.suspendMenuItem_Click); + this.runAsServiceMenuItem.Index = 3; + this.runAsServiceMenuItem.Text = "Run As..."; + this.runAsServiceMenuItem.Click += new System.EventHandler(this.runAsServiceMenuItem_Click); // - // resumeToolStripMenuItem + // showDetailsForAllProcessesMenuItem // - this.resumeToolStripMenuItem.Name = "resumeToolStripMenuItem"; - this.resumeToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.resumeToolStripMenuItem.Text = "&Resume"; - this.resumeToolStripMenuItem.Click += new System.EventHandler(this.resumeMenuItem_Click); + this.showDetailsForAllProcessesMenuItem.Index = 4; + this.showDetailsForAllProcessesMenuItem.Text = "Show Details for All Processes"; + this.showDetailsForAllProcessesMenuItem.Click += new System.EventHandler(this.showDetailsForAllProcessesMenuItem_Click); // - // restartToolStripMenuItem + // uacSeparatorMenuItem // - this.restartToolStripMenuItem.Name = "restartToolStripMenuItem"; - this.restartToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.restartToolStripMenuItem.Text = "Restart"; - this.restartToolStripMenuItem.Click += new System.EventHandler(this.restartProcessMenuItem_Click); + this.uacSeparatorMenuItem.Index = 5; + this.uacSeparatorMenuItem.Text = "-"; // - // reduceWorkingSetToolStripMenuItem + // openMenuItem // - this.reduceWorkingSetToolStripMenuItem.Name = "reduceWorkingSetToolStripMenuItem"; - this.reduceWorkingSetToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.reduceWorkingSetToolStripMenuItem.Text = "Reduce Working Set"; - this.reduceWorkingSetToolStripMenuItem.Click += new System.EventHandler(this.reduceWorkingSetProcessMenuItem_Click); + this.vistaMenu.SetImage(this.openMenuItem, global::ProcessHacker.Properties.Resources.folder); + this.openMenuItem.Index = 6; + this.openMenuItem.Text = "Open..."; + this.openMenuItem.Click += new System.EventHandler(this.openMenuItem_Click); // - // virtualizationToolStripMenuItem + // saveMenuItem // - this.virtualizationToolStripMenuItem.Name = "virtualizationToolStripMenuItem"; - this.virtualizationToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.virtualizationToolStripMenuItem.Text = "Virtualization"; - this.virtualizationToolStripMenuItem.Click += new System.EventHandler(this.virtualizationProcessMenuItem_Click); + this.vistaMenu.SetImage(this.saveMenuItem, global::ProcessHacker.Properties.Resources.disk); + this.saveMenuItem.Index = 7; + this.saveMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlS; + this.saveMenuItem.Text = "Save..."; + this.saveMenuItem.Click += new System.EventHandler(this.saveMenuItem_Click); // - // toolStripSeparator14 + // findHandlesMenuItem // - this.toolStripSeparator14.Name = "toolStripSeparator14"; - this.toolStripSeparator14.Size = new System.Drawing.Size(194, 6); + this.vistaMenu.SetImage(this.findHandlesMenuItem, global::ProcessHacker.Properties.Resources.find); + this.findHandlesMenuItem.Index = 8; + this.findHandlesMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlF; + this.findHandlesMenuItem.Text = "&Find Handles or DLLs..."; + this.findHandlesMenuItem.Click += new System.EventHandler(this.findHandlesMenuItem_Click); // - // affinityToolStripMenuItem + // inspectPEFileMenuItem // - this.affinityToolStripMenuItem.Name = "affinityToolStripMenuItem"; - this.affinityToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.affinityToolStripMenuItem.Text = "Affinity..."; - this.affinityToolStripMenuItem.Click += new System.EventHandler(this.affinityProcessMenuItem_Click); + this.vistaMenu.SetImage(this.inspectPEFileMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify); + this.inspectPEFileMenuItem.Index = 9; + this.inspectPEFileMenuItem.Text = "Inspect &PE File..."; + this.inspectPEFileMenuItem.Click += new System.EventHandler(this.inspectPEFileMenuItem_Click); // - // createDumpFileToolStripMenuItem + // reloadStructsMenuItem // - this.createDumpFileToolStripMenuItem.Name = "createDumpFileToolStripMenuItem"; - this.createDumpFileToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.createDumpFileToolStripMenuItem.Text = "Create Dump File..."; - this.createDumpFileToolStripMenuItem.Click += new System.EventHandler(this.createDumpFileProcessMenuItem_Click); + this.vistaMenu.SetImage(this.reloadStructsMenuItem, global::ProcessHacker.Properties.Resources.arrow_refresh); + this.reloadStructsMenuItem.Index = 10; + this.reloadStructsMenuItem.Text = "Reload Struct Definitions"; + this.reloadStructsMenuItem.Click += new System.EventHandler(this.reloadStructsMenuItem_Click); // - // terminatorToolStripMenuItem + // optionsMenuItem // - this.terminatorToolStripMenuItem.Name = "terminatorToolStripMenuItem"; - this.terminatorToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.terminatorToolStripMenuItem.Text = "Terminator"; - this.terminatorToolStripMenuItem.Click += new System.EventHandler(this.terminatorProcessMenuItem_Click); + this.vistaMenu.SetImage(this.optionsMenuItem, global::ProcessHacker.Properties.Resources.page_gear); + this.optionsMenuItem.Index = 11; + this.optionsMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlO; + this.optionsMenuItem.Text = "&Options..."; + this.optionsMenuItem.Click += new System.EventHandler(this.optionsMenuItem_Click); // - // miscellaneousToolStripMenuItem + // menuItem2 // - this.miscellaneousToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.analyzeWaitChainToolStripMenuItem, - this.detachFromDebuggerToolStripMenuItem, - this.heapsToolStripMenuItem, - this.injectDLLToolStripMenuItem, - this.iOPriorityToolStripMenuItem, - this.protectionToolStripMenuItem, - this.setTokenToolStripMenuItem, - this.uploadToVirusTotalToolStripMenuItem}); - this.miscellaneousToolStripMenuItem.Name = "miscellaneousToolStripMenuItem"; - this.miscellaneousToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.miscellaneousToolStripMenuItem.Text = "Miscellaneous"; + this.menuItem2.Index = 12; + this.menuItem2.Text = "-"; // - // analyzeWaitChainToolStripMenuItem + // shutdownMenuItem // - this.analyzeWaitChainToolStripMenuItem.Name = "analyzeWaitChainToolStripMenuItem"; - this.analyzeWaitChainToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.analyzeWaitChainToolStripMenuItem.Text = "Analyze Wait Chain"; + this.shutdownMenuItem.Index = 13; + this.shutdownMenuItem.Text = "Shutdown"; // - // detachFromDebuggerToolStripMenuItem + // exitMenuItem // - this.detachFromDebuggerToolStripMenuItem.Name = "detachFromDebuggerToolStripMenuItem"; - this.detachFromDebuggerToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.detachFromDebuggerToolStripMenuItem.Text = "Detach from Debugger"; + this.vistaMenu.SetImage(this.exitMenuItem, global::ProcessHacker.Properties.Resources.door_out); + this.exitMenuItem.Index = 14; + this.exitMenuItem.Text = "E&xit"; + this.exitMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click); // - // heapsToolStripMenuItem + // viewMenuItem // - this.heapsToolStripMenuItem.Name = "heapsToolStripMenuItem"; - this.heapsToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.heapsToolStripMenuItem.Text = "Heaps"; + this.viewMenuItem.Index = 1; + this.viewMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.toolbarMenuItem, + this.sysInfoMenuItem, + this.trayIconsMenuItem, + this.menuItem3, + this.updateNowMenuItem, + this.updateProcessesMenuItem, + this.updateServicesMenuItem}); + this.viewMenuItem.Text = "&View"; // - // injectDLLToolStripMenuItem + // toolbarMenuItem // - this.injectDLLToolStripMenuItem.Name = "injectDLLToolStripMenuItem"; - this.injectDLLToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.injectDLLToolStripMenuItem.Text = "Inject DLL..."; + this.toolbarMenuItem.Index = 0; + this.toolbarMenuItem.Text = "Toolbar"; + this.toolbarMenuItem.Click += new System.EventHandler(this.toolbarMenuItem_Click); // - // iOPriorityToolStripMenuItem + // sysInfoMenuItem // - this.iOPriorityToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.ioPriority0ThreadMenuItem, - this.ioPriority1ThreadMenuItem, - this.ioPriority3ThreadMenuItem, - this.toolStripMenuItem5}); - this.iOPriorityToolStripMenuItem.Name = "iOPriorityToolStripMenuItem"; - this.iOPriorityToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.iOPriorityToolStripMenuItem.Text = "I/O Priority"; + this.sysInfoMenuItem.Index = 1; + this.sysInfoMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlI; + this.sysInfoMenuItem.Text = "System &Information"; + this.sysInfoMenuItem.Click += new System.EventHandler(this.sysInfoMenuItem_Click); // - // ioPriority0ThreadMenuItem + // trayIconsMenuItem // - this.ioPriority0ThreadMenuItem.Name = "ioPriority0ThreadMenuItem"; - this.ioPriority0ThreadMenuItem.Size = new System.Drawing.Size(80, 22); - this.ioPriority0ThreadMenuItem.Text = "0"; + this.trayIconsMenuItem.Index = 2; + this.trayIconsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.cpuHistoryMenuItem, + this.cpuUsageMenuItem, + this.ioHistoryMenuItem, + this.commitHistoryMenuItem, + this.physMemHistoryMenuItem}); + this.trayIconsMenuItem.Text = "Tray Icons"; // - // ioPriority1ThreadMenuItem + // cpuHistoryMenuItem // - this.ioPriority1ThreadMenuItem.Name = "ioPriority1ThreadMenuItem"; - this.ioPriority1ThreadMenuItem.Size = new System.Drawing.Size(80, 22); - this.ioPriority1ThreadMenuItem.Text = "1"; + this.cpuHistoryMenuItem.Index = 0; + this.cpuHistoryMenuItem.Text = "CPU History"; + this.cpuHistoryMenuItem.Click += new System.EventHandler(this.cpuHistoryMenuItem_Click); // - // ioPriority3ThreadMenuItem + // cpuUsageMenuItem // - this.ioPriority3ThreadMenuItem.Name = "ioPriority3ThreadMenuItem"; - this.ioPriority3ThreadMenuItem.Size = new System.Drawing.Size(80, 22); - this.ioPriority3ThreadMenuItem.Text = "2"; + this.cpuUsageMenuItem.Index = 1; + this.cpuUsageMenuItem.Text = "CPU Usage"; + this.cpuUsageMenuItem.Click += new System.EventHandler(this.cpuUsageMenuItem_Click); // - // toolStripMenuItem5 + // ioHistoryMenuItem // - this.toolStripMenuItem5.Name = "toolStripMenuItem5"; - this.toolStripMenuItem5.Size = new System.Drawing.Size(80, 22); - this.toolStripMenuItem5.Text = "3"; + this.ioHistoryMenuItem.Index = 2; + this.ioHistoryMenuItem.Text = "I/O History"; + this.ioHistoryMenuItem.Click += new System.EventHandler(this.ioHistoryMenuItem_Click); // - // protectionToolStripMenuItem + // commitHistoryMenuItem // - this.protectionToolStripMenuItem.Name = "protectionToolStripMenuItem"; - this.protectionToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.protectionToolStripMenuItem.Text = "Protection"; + this.commitHistoryMenuItem.Index = 3; + this.commitHistoryMenuItem.Text = "Commit History"; + this.commitHistoryMenuItem.Click += new System.EventHandler(this.commitHistoryMenuItem_Click); // - // setTokenToolStripMenuItem + // physMemHistoryMenuItem // - this.setTokenToolStripMenuItem.Name = "setTokenToolStripMenuItem"; - this.setTokenToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.setTokenToolStripMenuItem.Text = "Set Token..."; + this.physMemHistoryMenuItem.Index = 4; + this.physMemHistoryMenuItem.Text = "Physical Memory History"; + this.physMemHistoryMenuItem.Click += new System.EventHandler(this.physMemHistoryMenuItem_Click); // - // uploadToVirusTotalToolStripMenuItem + // menuItem3 // - this.uploadToVirusTotalToolStripMenuItem.Name = "uploadToVirusTotalToolStripMenuItem"; - this.uploadToVirusTotalToolStripMenuItem.Size = new System.Drawing.Size(195, 22); - this.uploadToVirusTotalToolStripMenuItem.Text = "Upload to VirusTotal"; + this.menuItem3.Index = 3; + this.menuItem3.Text = "-"; // - // priorityToolStripMenuItem + // updateNowMenuItem // - this.priorityToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.realTimeToolStripMenuItem, - this.highToolStripMenuItem, - this.aboveNormalToolStripMenuItem, - this.normalToolStripMenuItem, - this.belowNormalToolStripMenuItem, - this.idleToolStripMenuItem}); - this.priorityToolStripMenuItem.Name = "priorityToolStripMenuItem"; - this.priorityToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.priorityToolStripMenuItem.Text = "&Priority"; + this.vistaMenu.SetImage(this.updateNowMenuItem, global::ProcessHacker.Properties.Resources.arrow_refresh); + this.updateNowMenuItem.Index = 4; + this.updateNowMenuItem.Shortcut = System.Windows.Forms.Shortcut.F5; + this.updateNowMenuItem.Text = "&Refresh"; + this.updateNowMenuItem.Click += new System.EventHandler(this.updateNowMenuItem_Click); // - // realTimeToolStripMenuItem + // updateProcessesMenuItem // - this.realTimeToolStripMenuItem.Name = "realTimeToolStripMenuItem"; - this.realTimeToolStripMenuItem.Size = new System.Drawing.Size(151, 22); - this.realTimeToolStripMenuItem.Text = "Real Time"; + this.updateProcessesMenuItem.Index = 5; + this.updateProcessesMenuItem.Text = "Update &Processes"; + this.updateProcessesMenuItem.Click += new System.EventHandler(this.updateProcessesMenuItem_Click); // - // highToolStripMenuItem + // updateServicesMenuItem // - this.highToolStripMenuItem.Name = "highToolStripMenuItem"; - this.highToolStripMenuItem.Size = new System.Drawing.Size(151, 22); - this.highToolStripMenuItem.Text = "High"; + this.updateServicesMenuItem.Index = 6; + this.updateServicesMenuItem.Text = "Update &Services"; + this.updateServicesMenuItem.Click += new System.EventHandler(this.updateServicesMenuItem_Click); // - // aboveNormalToolStripMenuItem + // toolsMenuItem // - this.aboveNormalToolStripMenuItem.Name = "aboveNormalToolStripMenuItem"; - this.aboveNormalToolStripMenuItem.Size = new System.Drawing.Size(151, 22); - this.aboveNormalToolStripMenuItem.Text = "Above Normal"; + this.toolsMenuItem.Index = 2; + this.toolsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.createServiceMenuItem, + this.hiddenProcessesMenuItem, + this.verifyFileSignatureMenuItem}); + this.toolsMenuItem.Text = "&Tools"; // - // normalToolStripMenuItem + // createServiceMenuItem // - this.normalToolStripMenuItem.Name = "normalToolStripMenuItem"; - this.normalToolStripMenuItem.Size = new System.Drawing.Size(151, 22); - this.normalToolStripMenuItem.Text = "Normal"; + this.createServiceMenuItem.Index = 0; + this.createServiceMenuItem.Text = "Create &Service..."; + this.createServiceMenuItem.Click += new System.EventHandler(this.createServiceMenuItem_Click); // - // belowNormalToolStripMenuItem + // hiddenProcessesMenuItem // - this.belowNormalToolStripMenuItem.Name = "belowNormalToolStripMenuItem"; - this.belowNormalToolStripMenuItem.Size = new System.Drawing.Size(151, 22); - this.belowNormalToolStripMenuItem.Text = "Below Normal"; + this.hiddenProcessesMenuItem.Index = 1; + this.hiddenProcessesMenuItem.Text = "&Hidden Processes"; + this.hiddenProcessesMenuItem.Click += new System.EventHandler(this.hiddenProcessesMenuItem_Click); // - // idleToolStripMenuItem + // verifyFileSignatureMenuItem // - this.idleToolStripMenuItem.Name = "idleToolStripMenuItem"; - this.idleToolStripMenuItem.Size = new System.Drawing.Size(151, 22); - this.idleToolStripMenuItem.Text = "Idle"; + this.verifyFileSignatureMenuItem.Index = 2; + this.verifyFileSignatureMenuItem.Text = "&Verify File Signature..."; + this.verifyFileSignatureMenuItem.Click += new System.EventHandler(this.verifyFileSignatureMenuItem_Click); // - // runAsToolStripMenuItem1 + // usersMenuItem // - this.runAsToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.launchAsUserToolStripMenuItem, - this.launchAsThisUserToolStripMenuItem}); - this.runAsToolStripMenuItem1.Name = "runAsToolStripMenuItem1"; - this.runAsToolStripMenuItem1.Size = new System.Drawing.Size(197, 22); - this.runAsToolStripMenuItem1.Text = "Run As"; + this.usersMenuItem.Index = 3; + this.usersMenuItem.Text = "&Users"; // - // launchAsUserToolStripMenuItem + // windowMenuItem // - this.launchAsUserToolStripMenuItem.Name = "launchAsUserToolStripMenuItem"; - this.launchAsUserToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.launchAsUserToolStripMenuItem.Text = "Launch As User..."; + this.windowMenuItem.Index = 4; + this.windowMenuItem.Text = "&Window"; // - // launchAsThisUserToolStripMenuItem + // helpMenu // - this.launchAsThisUserToolStripMenuItem.Name = "launchAsThisUserToolStripMenuItem"; - this.launchAsThisUserToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.launchAsThisUserToolStripMenuItem.Text = "Launch As This User..."; + this.helpMenu.Index = 5; + this.helpMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.freeMemoryMenuItem, + this.checkForUpdatesMenuItem, + this.menuItem1, + this.logMenuItem, + this.helpMenuItem, + this.donateMenuItem, + this.aboutMenuItem}); + this.helpMenu.Text = "H&elp"; // - // windowToolStripMenuItem1 + // freeMemoryMenuItem // - this.windowToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.bringToFrontToolStripMenuItem, - this.restoreToolStripMenuItem, - this.minimizeToolStripMenuItem, - this.maximizeToolStripMenuItem, - this.toolStripSeparator17, - this.closeToolStripMenuItem}); - this.windowToolStripMenuItem1.Name = "windowToolStripMenuItem1"; - this.windowToolStripMenuItem1.Size = new System.Drawing.Size(197, 22); - this.windowToolStripMenuItem1.Text = "&Window"; + this.freeMemoryMenuItem.Index = 0; + this.freeMemoryMenuItem.Text = "Free Memory"; + this.freeMemoryMenuItem.Click += new System.EventHandler(this.freeMemoryMenuItem_Click); // - // bringToFrontToolStripMenuItem + // checkForUpdatesMenuItem // - this.bringToFrontToolStripMenuItem.Name = "bringToFrontToolStripMenuItem"; - this.bringToFrontToolStripMenuItem.Size = new System.Drawing.Size(147, 22); - this.bringToFrontToolStripMenuItem.Text = "&Bring to Front"; + this.checkForUpdatesMenuItem.Index = 1; + this.checkForUpdatesMenuItem.Text = "Check for Updates"; + this.checkForUpdatesMenuItem.Click += new System.EventHandler(this.checkForUpdatesMenuItem_Click); // - // restoreToolStripMenuItem + // menuItem1 // - this.restoreToolStripMenuItem.Name = "restoreToolStripMenuItem"; - this.restoreToolStripMenuItem.Size = new System.Drawing.Size(147, 22); - this.restoreToolStripMenuItem.Text = "&Restore"; - this.restoreToolStripMenuItem.Click += new System.EventHandler(this.restoreProcessMenuItem_Click); + this.menuItem1.Index = 2; + this.menuItem1.Text = "-"; // - // minimizeToolStripMenuItem + // logMenuItem // - this.minimizeToolStripMenuItem.Name = "minimizeToolStripMenuItem"; - this.minimizeToolStripMenuItem.Size = new System.Drawing.Size(147, 22); - this.minimizeToolStripMenuItem.Text = "&Minimize"; - this.minimizeToolStripMenuItem.Click += new System.EventHandler(this.minimizeProcessMenuItem_Click); + this.vistaMenu.SetImage(this.logMenuItem, global::ProcessHacker.Properties.Resources.page_white_text); + this.logMenuItem.Index = 3; + this.logMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlL; + this.logMenuItem.Text = "&Log"; + this.logMenuItem.Click += new System.EventHandler(this.logMenuItem_Click); // - // maximizeToolStripMenuItem + // helpMenuItem // - this.maximizeToolStripMenuItem.Name = "maximizeToolStripMenuItem"; - this.maximizeToolStripMenuItem.Size = new System.Drawing.Size(147, 22); - this.maximizeToolStripMenuItem.Text = "Ma&ximize"; - this.maximizeToolStripMenuItem.Click += new System.EventHandler(this.maximizeProcessMenuItem_Click); + this.vistaMenu.SetImage(this.helpMenuItem, global::ProcessHacker.Properties.Resources.help); + this.helpMenuItem.Index = 4; + this.helpMenuItem.Shortcut = System.Windows.Forms.Shortcut.F1; + this.helpMenuItem.Text = "&Help"; + this.helpMenuItem.Click += new System.EventHandler(this.helpMenuItem_Click); // - // toolStripSeparator17 + // donateMenuItem // - this.toolStripSeparator17.Name = "toolStripSeparator17"; - this.toolStripSeparator17.Size = new System.Drawing.Size(144, 6); + this.vistaMenu.SetImage(this.donateMenuItem, global::ProcessHacker.Properties.Resources.money); + this.donateMenuItem.Index = 5; + this.donateMenuItem.Text = "Donate"; + this.donateMenuItem.Click += new System.EventHandler(this.donateMenuItem_Click); // - // closeToolStripMenuItem + // aboutMenuItem // - this.closeToolStripMenuItem.Name = "closeToolStripMenuItem"; - this.closeToolStripMenuItem.Size = new System.Drawing.Size(147, 22); - this.closeToolStripMenuItem.Text = "&Close"; - this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeProcessMenuItem_Click); + this.vistaMenu.SetImage(this.aboutMenuItem, global::ProcessHacker.Properties.Resources.information); + this.aboutMenuItem.Index = 6; + this.aboutMenuItem.Text = "&About"; + this.aboutMenuItem.Click += new System.EventHandler(this.aboutMenuItem_Click); // - // toolStripSeparator15 + // statusBar // - this.toolStripSeparator15.Name = "toolStripSeparator15"; - this.toolStripSeparator15.Size = new System.Drawing.Size(194, 6); + this.statusBar.Location = new System.Drawing.Point(0, 350); + this.statusBar.Name = "statusBar"; + this.statusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] { + this.statusGeneral, + this.statusCPU, + this.statusMemory}); + this.statusBar.ShowPanels = true; + this.statusBar.Size = new System.Drawing.Size(804, 22); + this.statusBar.TabIndex = 5; // - // searchOnlineToolStripMenuItem + // statusGeneral // - this.searchOnlineToolStripMenuItem.Name = "searchOnlineToolStripMenuItem"; - this.searchOnlineToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.searchOnlineToolStripMenuItem.Text = "&Search Online"; - this.searchOnlineToolStripMenuItem.Click += new System.EventHandler(this.searchProcessMenuItem_Click); + this.statusGeneral.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents; + this.statusGeneral.Name = "statusGeneral"; + this.statusGeneral.Width = 10; // - // reanalyzeToolStripMenuItem + // statusCPU // - this.reanalyzeToolStripMenuItem.Name = "reanalyzeToolStripMenuItem"; - this.reanalyzeToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.reanalyzeToolStripMenuItem.Text = "Re-analyze"; - this.reanalyzeToolStripMenuItem.Click += new System.EventHandler(this.reanalyzeProcessMenuItem_Click); + this.statusCPU.Name = "statusCPU"; + this.statusCPU.Text = "CPU: 99.99%"; + this.statusCPU.Width = 80; // - // copyProcessMenuItem + // statusMemory // - this.copyProcessMenuItem.Name = "copyProcessMenuItem"; - this.copyProcessMenuItem.Size = new System.Drawing.Size(197, 22); - this.copyProcessMenuItem.Text = "&Copy"; + this.statusMemory.Name = "statusMemory"; + this.statusMemory.Text = "Phys. Memory: 50%"; + this.statusMemory.Width = 120; // - // selectAllToolStripMenuItem + // tabControl // - this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; - this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(197, 22); - this.selectAllToolStripMenuItem.Text = "Select All"; - this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllProcessMenuItem_Click); + this.tabControl.Controls.Add(this.tabProcesses); + this.tabControl.Controls.Add(this.tabServices); + this.tabControl.Controls.Add(this.tabNetwork); + this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl.Location = new System.Drawing.Point(0, 25); + this.tabControl.Name = "tabControl"; + this.tabControl.SelectedIndex = 0; + this.tabControl.Size = new System.Drawing.Size(804, 325); + this.tabControl.TabIndex = 6; + this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControlBig_SelectedIndexChanged); // - // toolStripSeparator16 + // tabProcesses // - this.toolStripSeparator16.Name = "toolStripSeparator16"; - this.toolStripSeparator16.Size = new System.Drawing.Size(194, 6); + this.tabProcesses.Controls.Add(this.treeProcesses); + this.tabProcesses.Location = new System.Drawing.Point(4, 22); + this.tabProcesses.Name = "tabProcesses"; + this.tabProcesses.Padding = new System.Windows.Forms.Padding(3); + this.tabProcesses.Size = new System.Drawing.Size(796, 299); + this.tabProcesses.TabIndex = 0; + this.tabProcesses.Text = "Processes"; + this.tabProcesses.UseVisualStyleBackColor = true; // - // propertiesToolStripMenuItem1 + // treeProcesses // - this.propertiesToolStripMenuItem1.Name = "propertiesToolStripMenuItem1"; - this.propertiesToolStripMenuItem1.Size = new System.Drawing.Size(197, 22); - this.propertiesToolStripMenuItem1.Text = "&Properties"; - this.propertiesToolStripMenuItem1.Click += new System.EventHandler(this.propertiesProcessMenuItem_Click); + this.treeProcesses.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeProcesses.Draw = true; + this.treeProcesses.Location = new System.Drawing.Point(3, 3); + this.treeProcesses.Name = "treeProcesses"; + this.treeProcesses.Provider = null; + this.treeProcesses.Size = new System.Drawing.Size(790, 293); + this.treeProcesses.TabIndex = 4; + this.treeProcesses.SelectionChanged += new System.EventHandler(this.treeProcesses_SelectionChanged); + this.treeProcesses.NodeMouseDoubleClick += new System.EventHandler(this.treeProcesses_NodeMouseDoubleClick); + this.treeProcesses.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeProcesses_KeyDown); // // tabServices // @@ -653,118 +977,22 @@ private void InitializeComponent() this.tabServices.Location = new System.Drawing.Point(4, 22); this.tabServices.Name = "tabServices"; this.tabServices.Padding = new System.Windows.Forms.Padding(3); - this.tabServices.Size = new System.Drawing.Size(796, 468); + this.tabServices.Size = new System.Drawing.Size(796, 299); this.tabServices.TabIndex = 1; this.tabServices.Text = "Services"; this.tabServices.UseVisualStyleBackColor = true; // // listServices // - this.listServices.ContextMenuStrip = this.contextMenuStripService; this.listServices.Dock = System.Windows.Forms.DockStyle.Fill; + this.listServices.DoubleBuffered = true; this.listServices.Location = new System.Drawing.Point(3, 3); this.listServices.Name = "listServices"; this.listServices.Provider = null; - this.listServices.Size = new System.Drawing.Size(790, 462); + this.listServices.Size = new System.Drawing.Size(790, 293); this.listServices.TabIndex = 0; - this.listServices.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listServices_KeyDown); this.listServices.DoubleClick += new System.EventHandler(this.listServices_DoubleClick); - // - // contextMenuStripService - // - this.contextMenuStripService.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.goToProcessServiceMenuItem, - this.toolStripSeparator11, - this.startToolStripMenuItem, - this.pauseToolStripMenuItem, - this.continueToolStripMenuItem, - this.stopToolStripMenuItem, - this.deleteToolStripMenuItem, - this.toolStripSeparator12, - this.copyToolStripMenuItem1, - this.selectAllServiceMenuItem, - this.toolStripSeparator13, - this.propertiesToolStripMenuItem}); - this.contextMenuStripService.Name = "contextMenuStripService"; - this.contextMenuStripService.Size = new System.Drawing.Size(147, 220); - this.contextMenuStripService.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripService_Opening); - // - // goToProcessServiceMenuItem - // - this.goToProcessServiceMenuItem.Name = "goToProcessServiceMenuItem"; - this.goToProcessServiceMenuItem.Size = new System.Drawing.Size(146, 22); - this.goToProcessServiceMenuItem.Text = "&Go to Process"; - this.goToProcessServiceMenuItem.Click += new System.EventHandler(this.goToProcessServiceMenuItem_Click); - // - // toolStripSeparator11 - // - this.toolStripSeparator11.Name = "toolStripSeparator11"; - this.toolStripSeparator11.Size = new System.Drawing.Size(143, 6); - // - // startToolStripMenuItem - // - this.startToolStripMenuItem.Name = "startToolStripMenuItem"; - this.startToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.startToolStripMenuItem.Text = "&Start"; - this.startToolStripMenuItem.Click += new System.EventHandler(this.startServiceMenuItem_Click); - // - // pauseToolStripMenuItem - // - this.pauseToolStripMenuItem.Name = "pauseToolStripMenuItem"; - this.pauseToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.pauseToolStripMenuItem.Text = "&Pause"; - this.pauseToolStripMenuItem.Click += new System.EventHandler(this.pauseServiceMenuItem_Click); - // - // continueToolStripMenuItem - // - this.continueToolStripMenuItem.Name = "continueToolStripMenuItem"; - this.continueToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.continueToolStripMenuItem.Text = "&Continue"; - this.continueToolStripMenuItem.Click += new System.EventHandler(this.continueServiceMenuItem_Click); - // - // stopToolStripMenuItem - // - this.stopToolStripMenuItem.Name = "stopToolStripMenuItem"; - this.stopToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.stopToolStripMenuItem.Text = "S&top"; - this.stopToolStripMenuItem.Click += new System.EventHandler(this.stopServiceMenuItem_Click); - // - // deleteToolStripMenuItem - // - this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; - this.deleteToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.deleteToolStripMenuItem.Text = "Delete"; - this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteServiceMenuItem_Click); - // - // toolStripSeparator12 - // - this.toolStripSeparator12.Name = "toolStripSeparator12"; - this.toolStripSeparator12.Size = new System.Drawing.Size(143, 6); - // - // copyToolStripMenuItem1 - // - this.copyToolStripMenuItem1.Name = "copyToolStripMenuItem1"; - this.copyToolStripMenuItem1.Size = new System.Drawing.Size(146, 22); - this.copyToolStripMenuItem1.Text = "Copy"; - // - // selectAllServiceMenuItem - // - this.selectAllServiceMenuItem.Name = "selectAllServiceMenuItem"; - this.selectAllServiceMenuItem.Size = new System.Drawing.Size(146, 22); - this.selectAllServiceMenuItem.Text = "Select All"; - this.selectAllServiceMenuItem.Click += new System.EventHandler(this.selectAllServiceMenuItem_Click); - // - // toolStripSeparator13 - // - this.toolStripSeparator13.Name = "toolStripSeparator13"; - this.toolStripSeparator13.Size = new System.Drawing.Size(143, 6); - // - // propertiesToolStripMenuItem - // - this.propertiesToolStripMenuItem.Name = "propertiesToolStripMenuItem"; - this.propertiesToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.propertiesToolStripMenuItem.Text = "&Properties"; - this.propertiesToolStripMenuItem.Click += new System.EventHandler(this.propertiesServiceMenuItem_Click); + this.listServices.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listServices_KeyDown); // // tabNetwork // @@ -772,101 +1000,25 @@ private void InitializeComponent() this.tabNetwork.Location = new System.Drawing.Point(4, 22); this.tabNetwork.Name = "tabNetwork"; this.tabNetwork.Padding = new System.Windows.Forms.Padding(3); - this.tabNetwork.Size = new System.Drawing.Size(796, 468); + this.tabNetwork.Size = new System.Drawing.Size(796, 299); this.tabNetwork.TabIndex = 2; this.tabNetwork.Text = "Network"; this.tabNetwork.UseVisualStyleBackColor = true; // // listNetwork // - this.listNetwork.ContextMenuStrip = this.contextMenuStripNetwork; this.listNetwork.Dock = System.Windows.Forms.DockStyle.Fill; + this.listNetwork.DoubleBuffered = true; this.listNetwork.Location = new System.Drawing.Point(3, 3); this.listNetwork.Name = "listNetwork"; this.listNetwork.Provider = null; - this.listNetwork.Size = new System.Drawing.Size(790, 462); + this.listNetwork.Size = new System.Drawing.Size(790, 293); this.listNetwork.TabIndex = 0; - this.listNetwork.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listNetwork_KeyDown); this.listNetwork.DoubleClick += new System.EventHandler(this.listNetwork_DoubleClick); - // - // contextMenuStripNetwork - // - this.contextMenuStripNetwork.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.goToProcessNetworkMenuItem, - this.toolsToolStripMenuItem1, - this.closeNetworkMenuItem, - this.toolStripSeparator7, - this.copyToolStripMenuItem, - this.selectAllNetworkMenuItem}); - this.contextMenuStripNetwork.Name = "contextMenuStripNetwork"; - this.contextMenuStripNetwork.Size = new System.Drawing.Size(147, 120); - // - // goToProcessNetworkMenuItem - // - this.goToProcessNetworkMenuItem.Name = "goToProcessNetworkMenuItem"; - this.goToProcessNetworkMenuItem.Size = new System.Drawing.Size(146, 22); - this.goToProcessNetworkMenuItem.Text = "&Go to Process"; - this.goToProcessNetworkMenuItem.Click += new System.EventHandler(this.goToProcessNetworkMenuItem_Click); - // - // toolsToolStripMenuItem1 - // - this.toolsToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.whoisNetworkMenuItem, - this.tracertNetworkMenuItem, - this.pingNetworkMenuItem}); - this.toolsToolStripMenuItem1.Name = "toolsToolStripMenuItem1"; - this.toolsToolStripMenuItem1.Size = new System.Drawing.Size(146, 22); - this.toolsToolStripMenuItem1.Text = "Tools"; - // - // whoisNetworkMenuItem - // - this.whoisNetworkMenuItem.Name = "whoisNetworkMenuItem"; - this.whoisNetworkMenuItem.Size = new System.Drawing.Size(111, 22); - this.whoisNetworkMenuItem.Text = "Whois"; - this.whoisNetworkMenuItem.Click += new System.EventHandler(this.whoisNetworkMenuItem_Click); - // - // tracertNetworkMenuItem - // - this.tracertNetworkMenuItem.Name = "tracertNetworkMenuItem"; - this.tracertNetworkMenuItem.Size = new System.Drawing.Size(111, 22); - this.tracertNetworkMenuItem.Text = "Tracert"; - this.tracertNetworkMenuItem.Click += new System.EventHandler(this.tracertNetworkMenuItem_Click); - // - // pingNetworkMenuItem - // - this.pingNetworkMenuItem.Name = "pingNetworkMenuItem"; - this.pingNetworkMenuItem.Size = new System.Drawing.Size(111, 22); - this.pingNetworkMenuItem.Text = "Ping"; - this.pingNetworkMenuItem.Click += new System.EventHandler(this.pingNetworkMenuItem_Click); - // - // closeNetworkMenuItem - // - this.closeNetworkMenuItem.Name = "closeNetworkMenuItem"; - this.closeNetworkMenuItem.Size = new System.Drawing.Size(146, 22); - this.closeNetworkMenuItem.Text = "Close"; - this.closeNetworkMenuItem.Click += new System.EventHandler(this.closeNetworkMenuItem_Click); - // - // toolStripSeparator7 - // - this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(143, 6); - // - // copyToolStripMenuItem - // - this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.copyToolStripMenuItem.Text = "Copy"; - // - // selectAllNetworkMenuItem - // - this.selectAllNetworkMenuItem.Name = "selectAllNetworkMenuItem"; - this.selectAllNetworkMenuItem.Size = new System.Drawing.Size(146, 22); - this.selectAllNetworkMenuItem.Text = "Select All"; - this.selectAllNetworkMenuItem.Click += new System.EventHandler(this.selectAllNetworkMenuItem_Click); + this.listNetwork.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listNetwork_KeyDown); // // toolStrip // - this.toolStrip.ClickThrough = true; this.toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.refreshToolStripButton, @@ -874,30 +1026,31 @@ private void InitializeComponent() this.shutDownToolStripMenuItem, this.toolStripSeparator1, this.findHandlesToolStripButton, - this.sysInfoToolStripButton, - this.toolStripTextBox2}); - this.toolStrip.Location = new System.Drawing.Point(0, 24); + this.sysInfoToolStripButton}); + this.toolStrip.Location = new System.Drawing.Point(0, 0); this.toolStrip.Name = "toolStrip"; - this.toolStrip.Size = new System.Drawing.Size(804, 28); + this.toolStrip.Size = new System.Drawing.Size(804, 25); this.toolStrip.TabIndex = 5; this.toolStrip.Text = "toolStrip1"; // // refreshToolStripButton // + this.refreshToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.refreshToolStripButton.Image = global::ProcessHacker.Properties.Resources.arrow_refresh; this.refreshToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.refreshToolStripButton.Name = "refreshToolStripButton"; - this.refreshToolStripButton.Size = new System.Drawing.Size(66, 25); + this.refreshToolStripButton.Size = new System.Drawing.Size(23, 22); this.refreshToolStripButton.Text = "Refresh"; this.refreshToolStripButton.ToolTipText = "Refresh (F5)"; this.refreshToolStripButton.Click += new System.EventHandler(this.refreshToolStripButton_Click); // // optionsToolStripButton // + this.optionsToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.optionsToolStripButton.Image = global::ProcessHacker.Properties.Resources.cog_edit; this.optionsToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.optionsToolStripButton.Name = "optionsToolStripButton"; - this.optionsToolStripButton.Size = new System.Drawing.Size(69, 25); + this.optionsToolStripButton.Size = new System.Drawing.Size(23, 22); this.optionsToolStripButton.Text = "Options"; this.optionsToolStripButton.ToolTipText = "Options... (Ctrl+O)"; this.optionsToolStripButton.Click += new System.EventHandler(this.optionsToolStripButton_Click); @@ -908,561 +1061,331 @@ private void InitializeComponent() this.shutDownToolStripMenuItem.Image = global::ProcessHacker.Properties.Resources.lightbulb_off; this.shutDownToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.shutDownToolStripMenuItem.Name = "shutDownToolStripMenuItem"; - this.shutDownToolStripMenuItem.Size = new System.Drawing.Size(29, 25); + this.shutDownToolStripMenuItem.Size = new System.Drawing.Size(29, 22); this.shutDownToolStripMenuItem.Text = "Shutdown"; // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(6, 28); + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); // // findHandlesToolStripButton // + this.findHandlesToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.findHandlesToolStripButton.Image = global::ProcessHacker.Properties.Resources.find; this.findHandlesToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.findHandlesToolStripButton.Name = "findHandlesToolStripButton"; - this.findHandlesToolStripButton.Size = new System.Drawing.Size(147, 25); + this.findHandlesToolStripButton.Size = new System.Drawing.Size(23, 22); this.findHandlesToolStripButton.Text = "Find Handles or DLLs..."; this.findHandlesToolStripButton.ToolTipText = "Find Handles or DLLs... (Ctrl+F)"; this.findHandlesToolStripButton.Click += new System.EventHandler(this.findHandlesToolStripButton_Click); // // sysInfoToolStripButton // + this.sysInfoToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.sysInfoToolStripButton.Image = global::ProcessHacker.Properties.Resources.chart_line; this.sysInfoToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.sysInfoToolStripButton.Name = "sysInfoToolStripButton"; - this.sysInfoToolStripButton.Size = new System.Drawing.Size(140, 25); + this.sysInfoToolStripButton.Size = new System.Drawing.Size(23, 22); this.sysInfoToolStripButton.Text = "System Information..."; this.sysInfoToolStripButton.ToolTipText = "System Information... (Ctrl+I)"; this.sysInfoToolStripButton.Click += new System.EventHandler(this.sysInfoToolStripButton_Click); // - // toolStripTextBox2 - // - this.toolStripTextBox2.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.toolStripTextBox2.BackColor = System.Drawing.SystemColors.InactiveBorder; - this.toolStripTextBox2.ForeColor = System.Drawing.SystemColors.GrayText; - this.toolStripTextBox2.Name = "toolStripTextBox2"; - this.toolStripTextBox2.Size = new System.Drawing.Size(180, 25); - // - // statusStrip1 - // - this.statusStrip1.AllowItemReorder = true; - this.statusStrip1.BackColor = System.Drawing.SystemColors.Control; - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.statusMemory, - this.statusCPU, - this.statusGeneral}); - this.statusStrip1.Location = new System.Drawing.Point(0, 546); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode; - this.statusStrip1.Size = new System.Drawing.Size(804, 22); - this.statusStrip1.TabIndex = 7; - this.statusStrip1.Text = "statusStrip1"; - // - // statusMemory - // - this.statusMemory.Name = "statusMemory"; - this.statusMemory.Size = new System.Drawing.Size(52, 17); - this.statusMemory.Text = "Memory"; - // - // statusCPU - // - this.statusCPU.Name = "statusCPU"; - this.statusCPU.Size = new System.Drawing.Size(30, 17); - this.statusCPU.Text = "CPU"; - // - // statusGeneral - // - this.statusGeneral.Name = "statusGeneral"; - this.statusGeneral.Size = new System.Drawing.Size(47, 17); - this.statusGeneral.Text = "General"; - // - // menuStripEx1 - // - this.menuStripEx1.ClickThrough = true; - this.menuStripEx1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.hackerToolStripMenuItem, - this.viewToolStripMenuItem, - this.toolsToolStripMenuItem, - this.usersToolStripMenuItem, - this.windowToolStripMenuItem, - this.helpToolStripMenuItem}); - this.menuStripEx1.Location = new System.Drawing.Point(0, 0); - this.menuStripEx1.Name = "menuStripEx1"; - this.menuStripEx1.Size = new System.Drawing.Size(804, 24); - this.menuStripEx1.TabIndex = 8; - this.menuStripEx1.Text = "menuStripEx1"; - // - // hackerToolStripMenuItem - // - this.hackerToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.runToolStripMenuItem, - this.runAsToolStripMenuItem, - this.runAsAdministratorMenuItem, - this.showDetailsForAllProcessesMenuItem, - this.toolStripSeparator4, - this.openToolStripMenuItem, - this.saveToolStripMenuItem, - this.toolStripSeparator6, - this.findHandlesMenuItem, - this.inspectPEFileToolStripMenuItem, - this.optionsMenuItem, - this.toolStripSeparator5, - this.shutdownMenuItem, - this.exitToolStripMenuItem}); - this.hackerToolStripMenuItem.Name = "hackerToolStripMenuItem"; - this.hackerToolStripMenuItem.Size = new System.Drawing.Size(56, 20); - this.hackerToolStripMenuItem.Text = "Hacker"; - // - // runToolStripMenuItem - // - this.runToolStripMenuItem.Name = "runToolStripMenuItem"; - this.runToolStripMenuItem.Size = new System.Drawing.Size(230, 22); - this.runToolStripMenuItem.Text = "Run..."; - this.runToolStripMenuItem.Click += new System.EventHandler(this.runMenuItem_Click); - // - // runAsToolStripMenuItem - // - this.runAsToolStripMenuItem.Name = "runAsToolStripMenuItem"; - this.runAsToolStripMenuItem.Size = new System.Drawing.Size(230, 22); - this.runAsToolStripMenuItem.Text = "Run As..."; - this.runAsToolStripMenuItem.Click += new System.EventHandler(this.runAsServiceMenuItem_Click); - // - // runAsAdministratorMenuItem - // - this.runAsAdministratorMenuItem.Name = "runAsAdministratorMenuItem"; - this.runAsAdministratorMenuItem.Size = new System.Drawing.Size(230, 22); - this.runAsAdministratorMenuItem.Text = "Run As Administrator..."; - this.runAsAdministratorMenuItem.Click += new System.EventHandler(this.runAsAdministratorMenuItem_Click); - // - // showDetailsForAllProcessesMenuItem - // - this.showDetailsForAllProcessesMenuItem.Name = "showDetailsForAllProcessesMenuItem"; - this.showDetailsForAllProcessesMenuItem.Size = new System.Drawing.Size(230, 22); - this.showDetailsForAllProcessesMenuItem.Text = "Show Details for All Processes"; - this.showDetailsForAllProcessesMenuItem.Click += new System.EventHandler(this.showDetailsForAllProcessesMenuItem_Click); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(227, 6); - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(230, 22); - this.openToolStripMenuItem.Text = "Open"; - this.openToolStripMenuItem.Click += new System.EventHandler(this.openMenuItem_Click); - // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(230, 22); - this.saveToolStripMenuItem.Text = "Save"; - this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveMenuItem_Click); + // menuService // - // toolStripSeparator6 - // - this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(227, 6); - // - // findHandlesMenuItem - // - this.findHandlesMenuItem.Name = "findHandlesMenuItem"; - this.findHandlesMenuItem.Size = new System.Drawing.Size(230, 22); - this.findHandlesMenuItem.Text = "&Find Handles or DLLs..."; - this.findHandlesMenuItem.Click += new System.EventHandler(this.findHandlesMenuItem_Click); - // - // inspectPEFileToolStripMenuItem - // - this.inspectPEFileToolStripMenuItem.Name = "inspectPEFileToolStripMenuItem"; - this.inspectPEFileToolStripMenuItem.Size = new System.Drawing.Size(230, 22); - this.inspectPEFileToolStripMenuItem.Text = "Inspect &PE File..."; - this.inspectPEFileToolStripMenuItem.Click += new System.EventHandler(this.inspectPEFileMenuItem_Click); - // - // optionsMenuItem - // - this.optionsMenuItem.Name = "optionsMenuItem"; - this.optionsMenuItem.Size = new System.Drawing.Size(230, 22); - this.optionsMenuItem.Text = "&Options..."; - this.optionsMenuItem.Click += new System.EventHandler(this.optionsMenuItem_Click); - // - // toolStripSeparator5 - // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(227, 6); - // - // shutdownMenuItem - // - this.shutdownMenuItem.Name = "shutdownMenuItem"; - this.shutdownMenuItem.Size = new System.Drawing.Size(230, 22); - this.shutdownMenuItem.Text = "Shutdown"; - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(230, 22); - this.exitToolStripMenuItem.Text = "Exit"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click); - // - // viewToolStripMenuItem - // - this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolbarMenuItem, - this.sysInfoMenuItem, - this.trayIconsToolStripMenuItem, - this.toolStripSeparator3, - this.refreshToolStripMenuItem, - this.updateProcessesMenuItem, - this.updateServicesMenuItem}); - this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; - this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); - this.viewToolStripMenuItem.Text = "View"; - // - // toolbarMenuItem - // - this.toolbarMenuItem.Name = "toolbarMenuItem"; - this.toolbarMenuItem.Size = new System.Drawing.Size(178, 22); - this.toolbarMenuItem.Text = "Toolbar"; - this.toolbarMenuItem.Click += new System.EventHandler(this.toolbarMenuItem_Click); - // - // sysInfoMenuItem - // - this.sysInfoMenuItem.Name = "sysInfoMenuItem"; - this.sysInfoMenuItem.Size = new System.Drawing.Size(178, 22); - this.sysInfoMenuItem.Text = "System &Information"; - this.sysInfoMenuItem.Click += new System.EventHandler(this.sysInfoMenuItem_Click); - // - // trayIconsToolStripMenuItem - // - this.trayIconsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.cpuHistoryMenuItem, - this.cpuUsageMenuItem, - this.ioHistoryMenuItem, - this.commitHistoryMenuItem, - this.physMemHistoryMenuItem}); - this.trayIconsToolStripMenuItem.Name = "trayIconsToolStripMenuItem"; - this.trayIconsToolStripMenuItem.Size = new System.Drawing.Size(178, 22); - this.trayIconsToolStripMenuItem.Text = "Tray Icons"; - // - // cpuHistoryMenuItem - // - this.cpuHistoryMenuItem.Name = "cpuHistoryMenuItem"; - this.cpuHistoryMenuItem.Size = new System.Drawing.Size(206, 22); - this.cpuHistoryMenuItem.Text = "CPU History"; - this.cpuHistoryMenuItem.Click += new System.EventHandler(this.cpuHistoryMenuItem_Click); - // - // cpuUsageMenuItem - // - this.cpuUsageMenuItem.Name = "cpuUsageMenuItem"; - this.cpuUsageMenuItem.Size = new System.Drawing.Size(206, 22); - this.cpuUsageMenuItem.Text = "CPU Usage"; - this.cpuUsageMenuItem.Click += new System.EventHandler(this.cpuUsageMenuItem_Click); + this.menuService.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.goToProcessServiceMenuItem, + this.startServiceMenuItem, + this.continueServiceMenuItem, + this.pauseServiceMenuItem, + this.stopServiceMenuItem, + this.deleteServiceMenuItem, + this.propertiesServiceMenuItem, + this.menuItem8, + this.copyServiceMenuItem, + this.selectAllServiceMenuItem}); + this.menuService.Popup += new System.EventHandler(this.menuService_Popup); // - // ioHistoryMenuItem + // goToProcessServiceMenuItem // - this.ioHistoryMenuItem.Name = "ioHistoryMenuItem"; - this.ioHistoryMenuItem.Size = new System.Drawing.Size(206, 22); - this.ioHistoryMenuItem.Text = "I/O History"; - this.ioHistoryMenuItem.Click += new System.EventHandler(this.ioHistoryMenuItem_Click); + this.vistaMenu.SetImage(this.goToProcessServiceMenuItem, global::ProcessHacker.Properties.Resources.arrow_right); + this.goToProcessServiceMenuItem.Index = 0; + this.goToProcessServiceMenuItem.Text = "&Go to Process"; + this.goToProcessServiceMenuItem.Click += new System.EventHandler(this.goToProcessServiceMenuItem_Click); // - // commitHistoryMenuItem + // startServiceMenuItem // - this.commitHistoryMenuItem.Name = "commitHistoryMenuItem"; - this.commitHistoryMenuItem.Size = new System.Drawing.Size(206, 22); - this.commitHistoryMenuItem.Text = "Commit History"; - this.commitHistoryMenuItem.Click += new System.EventHandler(this.commitHistoryMenuItem_Click); + this.vistaMenu.SetImage(this.startServiceMenuItem, global::ProcessHacker.Properties.Resources.control_play_blue); + this.startServiceMenuItem.Index = 1; + this.startServiceMenuItem.Text = "&Start"; + this.startServiceMenuItem.Click += new System.EventHandler(this.startServiceMenuItem_Click); // - // physMemHistoryMenuItem + // continueServiceMenuItem // - this.physMemHistoryMenuItem.Name = "physMemHistoryMenuItem"; - this.physMemHistoryMenuItem.Size = new System.Drawing.Size(206, 22); - this.physMemHistoryMenuItem.Text = "Physical Memory History"; - this.physMemHistoryMenuItem.Click += new System.EventHandler(this.physMemHistoryMenuItem_Click); + this.continueServiceMenuItem.Index = 2; + this.continueServiceMenuItem.Text = "&Continue"; + this.continueServiceMenuItem.Click += new System.EventHandler(this.continueServiceMenuItem_Click); // - // toolStripSeparator3 + // pauseServiceMenuItem // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(175, 6); + this.vistaMenu.SetImage(this.pauseServiceMenuItem, global::ProcessHacker.Properties.Resources.control_pause_blue); + this.pauseServiceMenuItem.Index = 3; + this.pauseServiceMenuItem.Text = "&Pause"; + this.pauseServiceMenuItem.Click += new System.EventHandler(this.pauseServiceMenuItem_Click); // - // refreshToolStripMenuItem + // stopServiceMenuItem // - this.refreshToolStripMenuItem.Name = "refreshToolStripMenuItem"; - this.refreshToolStripMenuItem.Size = new System.Drawing.Size(178, 22); - this.refreshToolStripMenuItem.Text = "Refresh"; - this.refreshToolStripMenuItem.Click += new System.EventHandler(this.refreshToolStripButton_Click); + this.vistaMenu.SetImage(this.stopServiceMenuItem, global::ProcessHacker.Properties.Resources.control_stop_blue); + this.stopServiceMenuItem.Index = 4; + this.stopServiceMenuItem.Text = "S&top"; + this.stopServiceMenuItem.Click += new System.EventHandler(this.stopServiceMenuItem_Click); // - // updateProcessesMenuItem + // deleteServiceMenuItem // - this.updateProcessesMenuItem.Name = "updateProcessesMenuItem"; - this.updateProcessesMenuItem.Size = new System.Drawing.Size(178, 22); - this.updateProcessesMenuItem.Text = "Update &Processes"; - this.updateProcessesMenuItem.Click += new System.EventHandler(this.updateProcessesMenuItem_Click); + this.vistaMenu.SetImage(this.deleteServiceMenuItem, global::ProcessHacker.Properties.Resources.cross); + this.deleteServiceMenuItem.Index = 5; + this.deleteServiceMenuItem.Shortcut = System.Windows.Forms.Shortcut.Del; + this.deleteServiceMenuItem.Text = "Delete"; + this.deleteServiceMenuItem.Click += new System.EventHandler(this.deleteServiceMenuItem_Click); // - // updateServicesMenuItem + // propertiesServiceMenuItem // - this.updateServicesMenuItem.Name = "updateServicesMenuItem"; - this.updateServicesMenuItem.Size = new System.Drawing.Size(178, 22); - this.updateServicesMenuItem.Text = "Update &Services"; - this.updateServicesMenuItem.Click += new System.EventHandler(this.updateServicesMenuItem_Click); + this.propertiesServiceMenuItem.DefaultItem = true; + this.vistaMenu.SetImage(this.propertiesServiceMenuItem, global::ProcessHacker.Properties.Resources.application_form_magnify); + this.propertiesServiceMenuItem.Index = 6; + this.propertiesServiceMenuItem.Text = "&Properties"; + this.propertiesServiceMenuItem.Click += new System.EventHandler(this.propertiesServiceMenuItem_Click); // - // toolsToolStripMenuItem + // menuItem8 // - this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.createServiceToolStripMenuItem, - this.hiddenProcessesToolStripMenuItem, - this.verifyFileSignatureToolStripMenuItem}); - this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; - this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20); - this.toolsToolStripMenuItem.Text = "Tools"; + this.menuItem8.Index = 7; + this.menuItem8.Text = "-"; // - // createServiceToolStripMenuItem + // copyServiceMenuItem // - this.createServiceToolStripMenuItem.Name = "createServiceToolStripMenuItem"; - this.createServiceToolStripMenuItem.Size = new System.Drawing.Size(187, 22); - this.createServiceToolStripMenuItem.Text = "Create &Service"; - this.createServiceToolStripMenuItem.Click += new System.EventHandler(this.createServiceMenuItem_Click); + this.vistaMenu.SetImage(this.copyServiceMenuItem, global::ProcessHacker.Properties.Resources.page_copy); + this.copyServiceMenuItem.Index = 8; + this.copyServiceMenuItem.Text = "Copy"; // - // hiddenProcessesToolStripMenuItem + // selectAllServiceMenuItem // - this.hiddenProcessesToolStripMenuItem.Name = "hiddenProcessesToolStripMenuItem"; - this.hiddenProcessesToolStripMenuItem.Size = new System.Drawing.Size(187, 22); - this.hiddenProcessesToolStripMenuItem.Text = "&Hidden Processes"; - this.hiddenProcessesToolStripMenuItem.Click += new System.EventHandler(this.hiddenProcessesMenuItem_Click); + this.selectAllServiceMenuItem.Index = 9; + this.selectAllServiceMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlA; + this.selectAllServiceMenuItem.Text = "Select &All"; + this.selectAllServiceMenuItem.Click += new System.EventHandler(this.selectAllServiceMenuItem_Click); // - // verifyFileSignatureToolStripMenuItem + // menuIcon // - this.verifyFileSignatureToolStripMenuItem.Name = "verifyFileSignatureToolStripMenuItem"; - this.verifyFileSignatureToolStripMenuItem.Size = new System.Drawing.Size(187, 22); - this.verifyFileSignatureToolStripMenuItem.Text = "&Verify File Signature..."; - this.verifyFileSignatureToolStripMenuItem.Click += new System.EventHandler(this.verifyFileSignatureMenuItem_Click); + this.menuIcon.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.showHideMenuItem, + this.sysInformationIconMenuItem, + this.networkInfomationMenuItem, + this.notificationsMenuItem, + this.processesMenuItem, + this.shutdownTrayMenuItem, + this.exitTrayMenuItem}); + this.menuIcon.Popup += new System.EventHandler(this.menuIcon_Popup); // - // usersToolStripMenuItem + // showHideMenuItem // - this.usersToolStripMenuItem.Name = "usersToolStripMenuItem"; - this.usersToolStripMenuItem.Size = new System.Drawing.Size(47, 20); - this.usersToolStripMenuItem.Text = "Users"; + this.showHideMenuItem.Index = 0; + this.showHideMenuItem.Text = "&Show/Hide Process Hacker"; + this.showHideMenuItem.Click += new System.EventHandler(this.showHideMenuItem_Click); // - // windowToolStripMenuItem + // sysInformationIconMenuItem // - this.windowToolStripMenuItem.Name = "windowToolStripMenuItem"; - this.windowToolStripMenuItem.Size = new System.Drawing.Size(63, 20); - this.windowToolStripMenuItem.Text = "Window"; + this.sysInformationIconMenuItem.Index = 1; + this.sysInformationIconMenuItem.Text = "System &Information"; + this.sysInformationIconMenuItem.Click += new System.EventHandler(this.sysInformationIconMenuItem_Click); // - // helpToolStripMenuItem + // networkInfomationMenuItem // - this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.checkForUpdatesMenuItem, - this.toolStripSeparator2, - this.logToolStripMenuItem, - this.helpToolStripMenuItem1, - this.aboutToolStripMenuItem}); - this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; - this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); - this.helpToolStripMenuItem.Text = "Help"; + this.networkInfomationMenuItem.Index = 2; + this.networkInfomationMenuItem.Text = "Network Infomation"; + this.networkInfomationMenuItem.Click += new System.EventHandler(this.networkInfomationMenuItem_Click); // - // checkForUpdatesMenuItem + // notificationsMenuItem // - this.checkForUpdatesMenuItem.Enabled = false; - this.checkForUpdatesMenuItem.Name = "checkForUpdatesMenuItem"; - this.checkForUpdatesMenuItem.Size = new System.Drawing.Size(173, 22); - this.checkForUpdatesMenuItem.Text = "Check For Updates"; + this.notificationsMenuItem.Index = 3; + this.notificationsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.enableAllNotificationsMenuItem, + this.disableAllNotificationsMenuItem, + this.menuItem4, + this.NPMenuItem, + this.TPMenuItem, + this.NSMenuItem, + this.startedSMenuItem, + this.stoppedSMenuItem, + this.DSMenuItem}); + this.notificationsMenuItem.Text = "&Notifications"; // - // toolStripSeparator2 + // enableAllNotificationsMenuItem // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(170, 6); + this.enableAllNotificationsMenuItem.Index = 0; + this.enableAllNotificationsMenuItem.Text = "&Enable All"; + this.enableAllNotificationsMenuItem.Click += new System.EventHandler(this.enableAllNotificationsMenuItem_Click); // - // logToolStripMenuItem + // disableAllNotificationsMenuItem // - this.logToolStripMenuItem.Name = "logToolStripMenuItem"; - this.logToolStripMenuItem.Size = new System.Drawing.Size(173, 22); - this.logToolStripMenuItem.Text = "Log"; - this.logToolStripMenuItem.Click += new System.EventHandler(this.logMenuItem_Click); + this.disableAllNotificationsMenuItem.Index = 1; + this.disableAllNotificationsMenuItem.Text = "&Disable All"; + this.disableAllNotificationsMenuItem.Click += new System.EventHandler(this.disableAllNotificationsMenuItem_Click); // - // helpToolStripMenuItem1 + // menuItem4 // - this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1"; - this.helpToolStripMenuItem1.Size = new System.Drawing.Size(173, 22); - this.helpToolStripMenuItem1.Text = "Help"; - this.helpToolStripMenuItem1.Click += new System.EventHandler(this.helpMenuItem_Click); + this.menuItem4.Index = 2; + this.menuItem4.Text = "-"; // - // aboutToolStripMenuItem + // NPMenuItem // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(173, 22); - this.aboutToolStripMenuItem.Text = "About"; - this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutMenuItem_Click); + this.NPMenuItem.Index = 3; + this.NPMenuItem.Text = "New Processes"; // - // contextMenuStripTray + // TPMenuItem // - this.contextMenuStripTray.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.showHideProcessHackerToolStripMenuItem, - this.systemInformationToolStripMenuItem, - this.networkInfomationMenuItem, - this.toolStripSeparator9, - this.processesMenuItem, - this.notificationsToolStripMenuItem, - this.toolStripSeparator8, - this.shutdownTrayMenuItem, - this.exitToolStripMenuItem1}); - this.contextMenuStripTray.Name = "contextMenuStripTray"; - this.contextMenuStripTray.Size = new System.Drawing.Size(217, 170); + this.TPMenuItem.Index = 4; + this.TPMenuItem.Text = "Terminated Processes"; // - // showHideProcessHackerToolStripMenuItem + // NSMenuItem // - this.showHideProcessHackerToolStripMenuItem.Name = "showHideProcessHackerToolStripMenuItem"; - this.showHideProcessHackerToolStripMenuItem.Size = new System.Drawing.Size(216, 22); - this.showHideProcessHackerToolStripMenuItem.Text = "&Show/Hide Process Hacker"; - this.showHideProcessHackerToolStripMenuItem.Click += new System.EventHandler(this.showHideMenuItem_Click); + this.NSMenuItem.Index = 5; + this.NSMenuItem.Text = "New Services"; // - // systemInformationToolStripMenuItem + // startedSMenuItem // - this.systemInformationToolStripMenuItem.Name = "systemInformationToolStripMenuItem"; - this.systemInformationToolStripMenuItem.Size = new System.Drawing.Size(216, 22); - this.systemInformationToolStripMenuItem.Text = "System &Information"; - this.systemInformationToolStripMenuItem.Click += new System.EventHandler(this.sysInfoMenuItem_Click); + this.startedSMenuItem.Index = 6; + this.startedSMenuItem.Text = "Started Services"; // - // networkInfomationMenuItem + // stoppedSMenuItem // - this.networkInfomationMenuItem.Name = "networkInfomationMenuItem"; - this.networkInfomationMenuItem.Size = new System.Drawing.Size(216, 22); - this.networkInfomationMenuItem.Text = "Network Infomation"; - this.networkInfomationMenuItem.Click += new System.EventHandler(this.networkInfomationMenuItem_Click); + this.stoppedSMenuItem.Index = 7; + this.stoppedSMenuItem.Text = "Stopped Services"; // - // toolStripSeparator9 + // DSMenuItem // - this.toolStripSeparator9.Name = "toolStripSeparator9"; - this.toolStripSeparator9.Size = new System.Drawing.Size(213, 6); + this.DSMenuItem.Index = 8; + this.DSMenuItem.Text = "Deleted Services"; // // processesMenuItem // - this.processesMenuItem.Name = "processesMenuItem"; - this.processesMenuItem.Size = new System.Drawing.Size(216, 22); + this.processesMenuItem.Index = 4; this.processesMenuItem.Text = "&Processes"; // - // notificationsToolStripMenuItem + // shutdownTrayMenuItem // - this.notificationsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.enableAllToolStripMenuItem, - this.disableAllToolStripMenuItem, - this.toolStripSeparator10, - this.newProcessesToolStripMenuItem, - this.terminatedProcessesToolStripMenuItem, - this.newServicesToolStripMenuItem, - this.startedServicesToolStripMenuItem, - this.stoppedServicesToolStripMenuItem, - this.deletedServicesToolStripMenuItem}); - this.notificationsToolStripMenuItem.Name = "notificationsToolStripMenuItem"; - this.notificationsToolStripMenuItem.Size = new System.Drawing.Size(216, 22); - this.notificationsToolStripMenuItem.Text = "&Notifications"; + this.shutdownTrayMenuItem.Index = 5; + this.shutdownTrayMenuItem.Text = "Shutdown"; // - // enableAllToolStripMenuItem + // exitTrayMenuItem // - this.enableAllToolStripMenuItem.Name = "enableAllToolStripMenuItem"; - this.enableAllToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.enableAllToolStripMenuItem.Text = "&Enable All"; - this.enableAllToolStripMenuItem.Click += new System.EventHandler(this.enableAllNotificationsMenuItem_Click); + this.vistaMenu.SetImage(this.exitTrayMenuItem, global::ProcessHacker.Properties.Resources.door_out); + this.exitTrayMenuItem.Index = 6; + this.exitTrayMenuItem.Text = "E&xit"; + this.exitTrayMenuItem.Click += new System.EventHandler(this.exitTrayMenuItem_Click); // - // disableAllToolStripMenuItem + // goToProcessNetworkMenuItem // - this.disableAllToolStripMenuItem.Name = "disableAllToolStripMenuItem"; - this.disableAllToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.disableAllToolStripMenuItem.Text = "&Disable All"; - this.disableAllToolStripMenuItem.Click += new System.EventHandler(this.disableAllNotificationsMenuItem_Click); + this.goToProcessNetworkMenuItem.DefaultItem = true; + this.vistaMenu.SetImage(this.goToProcessNetworkMenuItem, global::ProcessHacker.Properties.Resources.arrow_right); + this.goToProcessNetworkMenuItem.Index = 0; + this.goToProcessNetworkMenuItem.Text = "&Go to Process"; + this.goToProcessNetworkMenuItem.Click += new System.EventHandler(this.goToProcessNetworkMenuItem_Click); // - // toolStripSeparator10 + // copyNetworkMenuItem // - this.toolStripSeparator10.Name = "toolStripSeparator10"; - this.toolStripSeparator10.Size = new System.Drawing.Size(186, 6); + this.vistaMenu.SetImage(this.copyNetworkMenuItem, global::ProcessHacker.Properties.Resources.page_copy); + this.copyNetworkMenuItem.Index = 4; + this.copyNetworkMenuItem.Text = "&Copy"; // - // newProcessesToolStripMenuItem + // closeNetworkMenuItem // - this.newProcessesToolStripMenuItem.Name = "newProcessesToolStripMenuItem"; - this.newProcessesToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.newProcessesToolStripMenuItem.Text = "New Processes"; - this.newProcessesToolStripMenuItem.Click += new System.EventHandler(this.CheckedMenuItem_Click); + this.vistaMenu.SetImage(this.closeNetworkMenuItem, global::ProcessHacker.Properties.Resources.cross); + this.closeNetworkMenuItem.Index = 2; + this.closeNetworkMenuItem.Text = "Close"; + this.closeNetworkMenuItem.Click += new System.EventHandler(this.closeNetworkMenuItem_Click); // - // terminatedProcessesToolStripMenuItem + // menuNetwork // - this.terminatedProcessesToolStripMenuItem.Name = "terminatedProcessesToolStripMenuItem"; - this.terminatedProcessesToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.terminatedProcessesToolStripMenuItem.Text = "Terminated Processes"; + this.menuNetwork.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.goToProcessNetworkMenuItem, + this.toolsNetworkMenuItem, + this.closeNetworkMenuItem, + this.menuItem6, + this.copyNetworkMenuItem, + this.selectAllNetworkMenuItem}); + this.menuNetwork.Popup += new System.EventHandler(this.menuNetwork_Popup); // - // newServicesToolStripMenuItem + // toolsNetworkMenuItem // - this.newServicesToolStripMenuItem.Name = "newServicesToolStripMenuItem"; - this.newServicesToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.newServicesToolStripMenuItem.Text = "New Services"; + this.toolsNetworkMenuItem.Index = 1; + this.toolsNetworkMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.whoisNetworkMenuItem, + this.tracertNetworkMenuItem, + this.pingNetworkMenuItem}); + this.toolsNetworkMenuItem.Text = "Tools"; // - // startedServicesToolStripMenuItem + // whoisNetworkMenuItem // - this.startedServicesToolStripMenuItem.Name = "startedServicesToolStripMenuItem"; - this.startedServicesToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.startedServicesToolStripMenuItem.Text = "Started Services"; + this.whoisNetworkMenuItem.Index = 0; + this.whoisNetworkMenuItem.Text = "Whois"; + this.whoisNetworkMenuItem.Click += new System.EventHandler(this.whoisNetworkMenuItem_Click); // - // stoppedServicesToolStripMenuItem + // tracertNetworkMenuItem // - this.stoppedServicesToolStripMenuItem.Name = "stoppedServicesToolStripMenuItem"; - this.stoppedServicesToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.stoppedServicesToolStripMenuItem.Text = "Stopped Services"; + this.tracertNetworkMenuItem.Index = 1; + this.tracertNetworkMenuItem.Text = "Tracert"; + this.tracertNetworkMenuItem.Click += new System.EventHandler(this.tracertNetworkMenuItem_Click); // - // deletedServicesToolStripMenuItem + // pingNetworkMenuItem // - this.deletedServicesToolStripMenuItem.Name = "deletedServicesToolStripMenuItem"; - this.deletedServicesToolStripMenuItem.Size = new System.Drawing.Size(189, 22); - this.deletedServicesToolStripMenuItem.Text = "Deleted Services"; + this.pingNetworkMenuItem.Index = 2; + this.pingNetworkMenuItem.Text = "Ping"; + this.pingNetworkMenuItem.Click += new System.EventHandler(this.pingNetworkMenuItem_Click); // - // toolStripSeparator8 + // menuItem6 // - this.toolStripSeparator8.Name = "toolStripSeparator8"; - this.toolStripSeparator8.Size = new System.Drawing.Size(213, 6); + this.menuItem6.Index = 3; + this.menuItem6.Text = "-"; // - // shutdownTrayMenuItem + // selectAllNetworkMenuItem // - this.shutdownTrayMenuItem.Name = "shutdownTrayMenuItem"; - this.shutdownTrayMenuItem.Size = new System.Drawing.Size(216, 22); - this.shutdownTrayMenuItem.Text = "Shutdown"; + this.selectAllNetworkMenuItem.Index = 5; + this.selectAllNetworkMenuItem.Text = "Select &All"; + this.selectAllNetworkMenuItem.Click += new System.EventHandler(this.selectAllNetworkMenuItem_Click); // - // exitToolStripMenuItem1 + // vistaMenu // - this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1"; - this.exitToolStripMenuItem1.Size = new System.Drawing.Size(216, 22); - this.exitToolStripMenuItem1.Text = "Exit"; - this.exitToolStripMenuItem1.Click += new System.EventHandler(this.exitMenuItem_Click); + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; // // HackerWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(804, 568); + this.ClientSize = new System.Drawing.Size(804, 372); this.Controls.Add(this.tabControl); this.Controls.Add(this.toolStrip); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.menuStripEx1); + this.Controls.Add(this.statusBar); + this.DoubleBuffered = true; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.KeyPreview = true; - this.MainMenuStrip = this.menuStripEx1; + this.Menu = this.mainMenu; this.Name = "HackerWindow"; this.Text = "Process Hacker"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HackerWindow_FormClosing); this.Load += new System.EventHandler(this.HackerWindow_Load); + this.SizeChanged += new System.EventHandler(this.HackerWindow_SizeChanged); this.VisibleChanged += new System.EventHandler(this.HackerWindow_VisibleChanged); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HackerWindow_FormClosing); + ((System.ComponentModel.ISupportInitialize)(this.statusGeneral)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusCPU)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.statusMemory)).EndInit(); this.tabControl.ResumeLayout(false); this.tabProcesses.ResumeLayout(false); - this.contextMenuStripProcess.ResumeLayout(false); this.tabServices.ResumeLayout(false); - this.contextMenuStripService.ResumeLayout(false); this.tabNetwork.ResumeLayout(false); - this.contextMenuStripNetwork.ResumeLayout(false); this.toolStrip.ResumeLayout(false); this.toolStrip.PerformLayout(); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); - this.menuStripEx1.ResumeLayout(false); - this.menuStripEx1.PerformLayout(); - this.contextMenuStripTray.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1470,6 +1393,19 @@ private void InitializeComponent() #endregion + private System.Windows.Forms.ContextMenu menuProcess; + private System.Windows.Forms.MenuItem terminateMenuItem; + private System.Windows.Forms.MenuItem suspendMenuItem; + private System.Windows.Forms.MenuItem resumeMenuItem; + private System.Windows.Forms.MenuItem menuItem5; + private System.Windows.Forms.MenuItem priorityMenuItem; + private System.Windows.Forms.MenuItem menuItem7; + private System.Windows.Forms.MenuItem realTimeMenuItem; + private System.Windows.Forms.MenuItem highMenuItem; + private System.Windows.Forms.MenuItem aboveNormalMenuItem; + private System.Windows.Forms.MenuItem normalMenuItem; + private System.Windows.Forms.MenuItem belowNormalMenuItem; + private System.Windows.Forms.MenuItem idleMenuItem; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem10; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem11; @@ -1477,157 +1413,142 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem13; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem14; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem15; + private wyDay.Controls.VistaMenu vistaMenu; + private System.Windows.Forms.MainMenu mainMenu; + private System.Windows.Forms.MenuItem hackerMenuItem; + private System.Windows.Forms.MenuItem aboutMenuItem; + private System.Windows.Forms.MenuItem optionsMenuItem; + private System.Windows.Forms.MenuItem helpMenuItem; + private System.Windows.Forms.MenuItem exitMenuItem; + private System.Windows.Forms.MenuItem windowMenuItem; private ProcessHacker.ProcessTree treeProcesses; + private System.Windows.Forms.MenuItem inspectPEFileMenuItem; + private System.Windows.Forms.MenuItem propertiesProcessMenuItem; + private System.Windows.Forms.MenuItem searchProcessMenuItem; + private System.Windows.Forms.StatusBar statusBar; + private System.Windows.Forms.MenuItem logMenuItem; + private System.Windows.Forms.StatusBarPanel statusGeneral; private System.Windows.Forms.TabControl tabControl; private System.Windows.Forms.TabPage tabProcesses; private System.Windows.Forms.TabPage tabServices; private ProcessHacker.Components.ServiceList listServices; + private System.Windows.Forms.ContextMenu menuService; + private System.Windows.Forms.MenuItem propertiesServiceMenuItem; + private System.Windows.Forms.MenuItem startServiceMenuItem; + private System.Windows.Forms.MenuItem pauseServiceMenuItem; + private System.Windows.Forms.MenuItem stopServiceMenuItem; + private System.Windows.Forms.MenuItem deleteServiceMenuItem; + private System.Windows.Forms.MenuItem continueServiceMenuItem; + private System.Windows.Forms.MenuItem goToProcessServiceMenuItem; + private System.Windows.Forms.MenuItem menuItem8; + private System.Windows.Forms.MenuItem copyServiceMenuItem; + private System.Windows.Forms.MenuItem selectAllServiceMenuItem; + private System.Windows.Forms.MenuItem toolsMenuItem; + private System.Windows.Forms.ContextMenu menuIcon; + private System.Windows.Forms.MenuItem showHideMenuItem; + private System.Windows.Forms.MenuItem exitTrayMenuItem; + private System.Windows.Forms.MenuItem notificationsMenuItem; + private System.Windows.Forms.MenuItem NPMenuItem; + private System.Windows.Forms.MenuItem TPMenuItem; + private System.Windows.Forms.MenuItem NSMenuItem; + private System.Windows.Forms.MenuItem startedSMenuItem; + private System.Windows.Forms.MenuItem stoppedSMenuItem; + private System.Windows.Forms.MenuItem DSMenuItem; + private System.Windows.Forms.MenuItem findHandlesMenuItem; + private System.Windows.Forms.MenuItem affinityProcessMenuItem; + private System.Windows.Forms.MenuItem runAsServiceMenuItem; + private System.Windows.Forms.MenuItem runAsProcessMenuItem; + private System.Windows.Forms.MenuItem launchAsUserProcessMenuItem; + private System.Windows.Forms.MenuItem launchAsThisUserProcessMenuItem; + private System.Windows.Forms.MenuItem sysInfoMenuItem; + private System.Windows.Forms.MenuItem copyProcessMenuItem; + private System.Windows.Forms.MenuItem selectAllProcessMenuItem; + private System.Windows.Forms.MenuItem terminatorProcessMenuItem; + private System.Windows.Forms.MenuItem menuItem2; + private System.Windows.Forms.StatusBarPanel statusCPU; + private System.Windows.Forms.StatusBarPanel statusMemory; + private System.Windows.Forms.MenuItem reloadStructsMenuItem; private System.Windows.Forms.TabPage tabNetwork; private ProcessHacker.Components.NetworkList listNetwork; - private System.ToolStripEx toolStrip; + private System.Windows.Forms.MenuItem sysInformationIconMenuItem; + private System.Windows.Forms.MenuItem hiddenProcessesMenuItem; + private System.Windows.Forms.MenuItem viewMenuItem; + private System.Windows.Forms.MenuItem updateNowMenuItem; + private System.Windows.Forms.MenuItem updateProcessesMenuItem; + private System.Windows.Forms.MenuItem updateServicesMenuItem; + private System.Windows.Forms.MenuItem processesMenuItem; + private System.Windows.Forms.MenuItem restartProcessMenuItem; + private System.Windows.Forms.MenuItem setTokenProcessMenuItem; + private System.Windows.Forms.MenuItem helpMenu; + private System.Windows.Forms.MenuItem menuItem3; + private System.Windows.Forms.MenuItem verifyFileSignatureMenuItem; + private System.Windows.Forms.MenuItem enableAllNotificationsMenuItem; + private System.Windows.Forms.MenuItem disableAllNotificationsMenuItem; + private System.Windows.Forms.MenuItem menuItem4; + private System.Windows.Forms.MenuItem shutdownTrayMenuItem; + private System.Windows.Forms.MenuItem shutdownMenuItem; + private System.Windows.Forms.MenuItem runAsAdministratorMenuItem; + private System.Windows.Forms.MenuItem showDetailsForAllProcessesMenuItem; + private System.Windows.Forms.MenuItem uacSeparatorMenuItem; + private System.Windows.Forms.MenuItem runMenuItem; + private System.Windows.Forms.MenuItem runAsMenuItem; + private System.Windows.Forms.MenuItem freeMemoryMenuItem; + private System.Windows.Forms.MenuItem menuItem1; + private System.Windows.Forms.MenuItem reanalyzeProcessMenuItem; + private System.Windows.Forms.MenuItem reduceWorkingSetProcessMenuItem; + private System.Windows.Forms.MenuItem virtualizationProcessMenuItem; + private System.Windows.Forms.ToolStrip toolStrip; private System.Windows.Forms.ToolStripButton refreshToolStripButton; private System.Windows.Forms.ToolStripButton findHandlesToolStripButton; private System.Windows.Forms.ToolStripButton sysInfoToolStripButton; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripDropDownButton shutDownToolStripMenuItem; private System.Windows.Forms.ToolStripButton optionsToolStripButton; - private System.Windows.Forms.StatusStrip statusStrip1; - private System.Windows.Forms.ToolStripStatusLabel statusMemory; - private System.Windows.Forms.ToolStripStatusLabel statusCPU; - private System.Windows.Forms.ToolStripStatusLabel statusGeneral; - private System.MenuStripEx menuStripEx1; - private System.Windows.Forms.ToolStripMenuItem hackerToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem usersToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem windowToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem checkForUpdatesMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem logToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private ToolStripSearchBox toolStripTextBox2; - private System.Windows.Forms.ToolStripMenuItem toolbarMenuItem; - private System.Windows.Forms.ToolStripMenuItem sysInfoMenuItem; - private System.Windows.Forms.ToolStripMenuItem trayIconsToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem updateProcessesMenuItem; - private System.Windows.Forms.ToolStripMenuItem updateServicesMenuItem; - private System.Windows.Forms.ToolStripMenuItem runToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem runAsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem runAsAdministratorMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripMenuItem shutdownMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem showDetailsForAllProcessesMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; - private System.Windows.Forms.ToolStripMenuItem findHandlesMenuItem; - private System.Windows.Forms.ToolStripMenuItem inspectPEFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem optionsMenuItem; - private System.Windows.Forms.ToolStripMenuItem createServiceToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem hiddenProcessesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem verifyFileSignatureToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cpuHistoryMenuItem; - private System.Windows.Forms.ToolStripMenuItem cpuUsageMenuItem; - private System.Windows.Forms.ToolStripMenuItem ioHistoryMenuItem; - private System.Windows.Forms.ToolStripMenuItem commitHistoryMenuItem; - private System.Windows.Forms.ToolStripMenuItem physMemHistoryMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripNetwork; - private System.Windows.Forms.ToolStripMenuItem goToProcessNetworkMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolsToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem closeNetworkMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; - private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem selectAllNetworkMenuItem; - private System.Windows.Forms.ToolStripMenuItem whoisNetworkMenuItem; - private System.Windows.Forms.ToolStripMenuItem tracertNetworkMenuItem; - private System.Windows.Forms.ToolStripMenuItem pingNetworkMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripTray; - private System.Windows.Forms.ToolStripMenuItem showHideProcessHackerToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem systemInformationToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem networkInfomationMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator8; - private System.Windows.Forms.ToolStripMenuItem shutdownTrayMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem1; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; - private System.Windows.Forms.ToolStripMenuItem processesMenuItem; - private System.Windows.Forms.ToolStripMenuItem notificationsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem enableAllToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem disableAllToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator10; - private System.Windows.Forms.ToolStripMenuItem newProcessesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem terminatedProcessesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem newServicesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem startedServicesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem stoppedServicesToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem deletedServicesToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripService; - private System.Windows.Forms.ToolStripMenuItem goToProcessServiceMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator11; - private System.Windows.Forms.ToolStripMenuItem startToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem continueToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem pauseToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem stopToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator12; - private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem selectAllServiceMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator13; - private System.Windows.Forms.ToolStripMenuItem propertiesToolStripMenuItem; - private System.Windows.Forms.ContextMenuStrip contextMenuStripProcess; - private System.Windows.Forms.ToolStripMenuItem terminateToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem terminateProcessTreeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem suspendToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem resumeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem restartToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem reduceWorkingSetToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem virtualizationToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator14; - private System.Windows.Forms.ToolStripMenuItem affinityToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem createDumpFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem terminatorToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem miscellaneousToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem priorityToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem runAsToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem windowToolStripMenuItem1; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator15; - private System.Windows.Forms.ToolStripMenuItem searchOnlineToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem reanalyzeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem copyProcessMenuItem; - private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator16; - private System.Windows.Forms.ToolStripMenuItem propertiesToolStripMenuItem1; - private System.Windows.Forms.ToolStripMenuItem launchAsUserToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem launchAsThisUserToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem bringToFrontToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem restoreToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem minimizeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem maximizeToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator17; - private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem realTimeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem highToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem aboveNormalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem normalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem belowNormalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem idleToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem analyzeWaitChainToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem detachFromDebuggerToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heapsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem injectDLLToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem iOPriorityToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem protectionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem setTokenToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem uploadToVirusTotalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem ioPriority0ThreadMenuItem; - private System.Windows.Forms.ToolStripMenuItem ioPriority1ThreadMenuItem; - private System.Windows.Forms.ToolStripMenuItem ioPriority3ThreadMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5; + private System.Windows.Forms.MenuItem toolbarMenuItem; + private System.Windows.Forms.MenuItem saveMenuItem; + private System.Windows.Forms.ContextMenu menuNetwork; + private System.Windows.Forms.MenuItem goToProcessNetworkMenuItem; + private System.Windows.Forms.MenuItem copyNetworkMenuItem; + private System.Windows.Forms.MenuItem menuItem6; + private System.Windows.Forms.MenuItem selectAllNetworkMenuItem; + private System.Windows.Forms.MenuItem injectDllProcessMenuItem; + private System.Windows.Forms.MenuItem terminateProcessTreeMenuItem; + private System.Windows.Forms.MenuItem trayIconsMenuItem; + private System.Windows.Forms.MenuItem cpuHistoryMenuItem; + private System.Windows.Forms.MenuItem cpuUsageMenuItem; + private System.Windows.Forms.MenuItem ioHistoryMenuItem; + private System.Windows.Forms.MenuItem commitHistoryMenuItem; + private System.Windows.Forms.MenuItem physMemHistoryMenuItem; + private System.Windows.Forms.MenuItem closeNetworkMenuItem; + private System.Windows.Forms.MenuItem protectionProcessMenuItem; + private System.Windows.Forms.MenuItem createDumpFileProcessMenuItem; + private System.Windows.Forms.MenuItem miscellaneousProcessMenuItem; + private System.Windows.Forms.MenuItem detachFromDebuggerProcessMenuItem; + private System.Windows.Forms.MenuItem usersMenuItem; + private System.Windows.Forms.MenuItem createServiceMenuItem; + private System.Windows.Forms.MenuItem heapsProcessMenuItem; + private System.Windows.Forms.MenuItem windowProcessMenuItem; + private System.Windows.Forms.MenuItem bringToFrontProcessMenuItem; + private System.Windows.Forms.MenuItem restoreProcessMenuItem; + private System.Windows.Forms.MenuItem minimizeProcessMenuItem; + private System.Windows.Forms.MenuItem maximizeProcessMenuItem; + private System.Windows.Forms.MenuItem menuItem15; + private System.Windows.Forms.MenuItem closeProcessMenuItem; + private System.Windows.Forms.MenuItem checkForUpdatesMenuItem; + private System.Windows.Forms.MenuItem toolsNetworkMenuItem; + private System.Windows.Forms.MenuItem whoisNetworkMenuItem; + private System.Windows.Forms.MenuItem tracertNetworkMenuItem; + private System.Windows.Forms.MenuItem pingNetworkMenuItem; + private System.Windows.Forms.MenuItem VirusTotalMenuItem; + private System.Windows.Forms.MenuItem networkInfomationMenuItem; + private System.Windows.Forms.MenuItem analyzeWaitChainProcessMenuItem; + private System.Windows.Forms.MenuItem donateMenuItem; + private System.Windows.Forms.MenuItem ioPriorityThreadMenuItem; + private System.Windows.Forms.MenuItem ioPriority0ThreadMenuItem; + private System.Windows.Forms.MenuItem ioPriority1ThreadMenuItem; + private System.Windows.Forms.MenuItem ioPriority2ThreadMenuItem; + private System.Windows.Forms.MenuItem ioPriority3ThreadMenuItem; + private System.Windows.Forms.MenuItem openMenuItem; } } diff --git a/1.x/trunk/ProcessHacker/Forms/HackerWindow.cs b/1.x/trunk/ProcessHacker/Forms/HackerWindow.cs index 83593796e..28c3c81b1 100644 --- a/1.x/trunk/ProcessHacker/Forms/HackerWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/HackerWindow.cs @@ -35,7 +35,6 @@ using ProcessHacker.Native.Debugging; using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; -using ProcessHacker.Native.Threading; using ProcessHacker.UI; using ProcessHacker.UI.Actions; using TaskbarLib; @@ -46,10 +45,10 @@ public partial class HackerWindow : Form { public delegate void LogUpdatedEventHandler(KeyValuePair? value); - private readonly ThumbButtonManager thumbButtonManager; + private ThumbButtonManager thumbButtonManager; //private JumpListManager jumpListManager; //Reserved for future use - public delegate void AddMenuItemDelegate(string text, EventHandler onClick); + private delegate void AddMenuItemDelegate(string text, EventHandler onClick); // This entire file is a big monolithic mess. @@ -73,6 +72,11 @@ public partial class HackerWindow : Form /// public SysInfoWindow SysInfoWindow; + /// + /// The UAC shield bitmap. Used for the various menu items which + /// require UAC elevation. + /// + Bitmap uacShieldIcon; /// /// A black icon which all notification icons are set to initially /// before their first paint. @@ -86,7 +90,7 @@ public partial class HackerWindow : Form /// /// The list of notification icons. /// - readonly List notifyIcons = new List(); + List notifyIcons = new List(); /// /// The CPU history icon, with a history of CPU usage. /// @@ -114,7 +118,7 @@ public partial class HackerWindow : Form /// A dictionary relating services to processes. Each key is a PID and /// each value is a list of service names hosted in that particular process. /// - readonly Dictionary> processServices = new Dictionary>(); + Dictionary> processServices = new Dictionary>(); /// /// The number of selected processes. Not used. @@ -129,7 +133,7 @@ public partial class HackerWindow : Form /// The PH log, with events such as process creation/termination and various /// service events. /// - readonly List> _log = new List>(); + List> _log = new List>(); /// /// windowhandle owned by the currently selected process. @@ -157,9 +161,14 @@ public partial class HackerWindow : Form // The following two properties were used by the Window menu system. // Not very useful, but still needed for now. - public ToolStripMenuItem WindowMenuItem + public MenuItem WindowMenuItem { - get { return windowToolStripMenuItem; } + get { return windowMenuItem; } + } + + public wyDay.Controls.VistaMenu VistaMenu + { + get { return vistaMenu; } } // Mostly used by Save.cs. @@ -259,18 +268,15 @@ private void runAsMenuItem_Click(object sender, EventArgs e) private void runAsAdministratorMenuItem_Click(object sender, EventArgs e) { - using (PromptBox box = new PromptBox - { - Text = "Enter the command to start" - }) - { - box.TextBox.AutoCompleteSource = AutoCompleteSource.AllSystemSources; - box.TextBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; + PromptBox box = new PromptBox(); - if (box.ShowDialog() == DialogResult.OK) - { - Program.StartProgramAdmin(box.Value, "", null, ShowWindowType.Show, this.Handle); - } + box.Text = "Enter the command to start"; + box.TextBox.AutoCompleteSource = AutoCompleteSource.AllSystemSources; + box.TextBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend; + + if (box.ShowDialog() == DialogResult.OK) + { + Program.StartProgramAdmin(box.Value, "", null, ShowWindowType.Show, this.Handle); } } @@ -282,7 +288,10 @@ private void runAsServiceMenuItem_Click(object sender, EventArgs e) private void showDetailsForAllProcessesMenuItem_Click(object sender, EventArgs e) { - Program.StartProcessHackerAdmin("-v", this.Exit, this.Handle); + Program.StartProcessHackerAdmin("-v", () => + { + this.Exit(); + }, this.Handle); } private void findHandlesMenuItem_Click(object sender, EventArgs e) @@ -343,7 +352,7 @@ private void sysInfoMenuItem_Click(object sender, EventArgs e) } else { - SysInfoWindow.BeginInvoke(new MethodInvoker(() => + SysInfoWindow.BeginInvoke(new MethodInvoker(delegate { SysInfoWindow.Show(); SysInfoWindow.Activate(); @@ -368,21 +377,20 @@ private void logMenuItem_Click(object sender, EventArgs e) private void aboutMenuItem_Click(object sender, EventArgs e) { - using (AboutWindow about = new AboutWindow()) - { - about.ShowDialog(); - } + AboutWindow about = new AboutWindow(); + about.ShowDialog(); } private void optionsMenuItem_Click(object sender, EventArgs e) { - using (OptionsWindow options = new OptionsWindow()) - { - if (options.ShowDialog() == DialogResult.OK) - { - this.LoadOtherSettings(); - } - } + OptionsWindow options = new OptionsWindow(); + + DialogResult result = options.ShowDialog(); + + if (result == DialogResult.OK) + { + this.LoadOtherSettings(); + } } private void freeMemoryMenuItem_Click(object sender, EventArgs e) @@ -410,6 +418,15 @@ private void toolbarMenuItem_Click(object sender, EventArgs e) Settings.Instance.ToolbarVisible = toolStrip.Visible = toolbarMenuItem.Checked; } + private void updateNowMenuItem_Click(object sender, EventArgs e) + { + if (Program.ProcessProvider.RunCount > 1) + Program.ProcessProvider.Boost(); + + if (Program.ServiceProvider.RunCount > 1) + Program.ServiceProvider.Boost(); + } + private void updateProcessesMenuItem_Click(object sender, EventArgs e) { updateProcessesMenuItem.Checked = !updateProcessesMenuItem.Checked; @@ -437,85 +454,81 @@ private void hiddenProcessesMenuItem_Click(object sender, EventArgs e) private void verifyFileSignatureMenuItem_Click(object sender, EventArgs e) { - using (OpenFileDialog ofd = new OpenFileDialog - { - CheckFileExists = true, - CheckPathExists = true, - Filter = "Executable files (*.exe;*.dll;*.sys;*.scr;*.cpl)|*.exe;*.dll;*.sys;*.scr;*.cpl|All files (*.*)|*.*" - }) + OpenFileDialog ofd = new OpenFileDialog(); + + ofd.CheckFileExists = true; + ofd.CheckPathExists = true; + ofd.Filter = "Executable files (*.exe;*.dll;*.sys;*.scr;*.cpl)|*.exe;*.dll;*.sys;*.scr;*.cpl|All files (*.*)|*.*"; + + if (ofd.ShowDialog() == DialogResult.OK) { - if (ofd.ShowDialog() == DialogResult.OK) + try { - try - { - var result = Cryptography.VerifyFile(ofd.FileName); - string message = string.Empty; + var result = Cryptography.VerifyFile(ofd.FileName); + string message = ""; - switch (result) - { - case VerifyResult.Distrust: - message = "is not trusted"; - break; - case VerifyResult.Expired: - message = "has an expired certificate"; - break; - case VerifyResult.NoSignature: - message = "does not have a digital signature"; - break; - case VerifyResult.Revoked: - message = "has a revoked certificate"; - break; - case VerifyResult.SecuritySettings: - message = "could not be verified due to security settings"; - break; - case VerifyResult.Trusted: - message = "is trusted"; - break; - case VerifyResult.Unknown: - message = "could not be verified"; - break; - default: - message = "could not be verified"; - break; - } - - PhUtils.ShowInformation("The file \"" + ofd.FileName + "\" " + message + "."); - } - catch (Exception ex) + switch (result) { - PhUtils.ShowException("Unable to verify the file", ex); + case VerifyResult.Distrust: + message = "is not trusted"; + break; + case VerifyResult.Expired: + message = "has an expired certificate"; + break; + case VerifyResult.NoSignature: + message = "does not have a digital signature"; + break; + case VerifyResult.Revoked: + message = "has a revoked certificate"; + break; + case VerifyResult.SecuritySettings: + message = "could not be verified due to security settings"; + break; + case VerifyResult.Trusted: + message = "is trusted"; + break; + case VerifyResult.Unknown: + message = "could not be verified"; + break; + default: + message = "could not be verified"; + break; } + + PhUtils.ShowInformation("The file \"" + ofd.FileName + "\" " + message + "."); + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to verify the file", ex); } } } private void openMenuItem_Click(object sender, EventArgs e) { - using (OpenFileDialog ofd = new OpenFileDialog - { - Filter = "Process Hacker Dump Files (*.phi)|*.phi|All Files (*.*)|*.*" - }) - { - if (ofd.ShowDialog() == DialogResult.OK) - { - DumpHackerWindow dhw = null; + OpenFileDialog ofd = new OpenFileDialog(); - try - { - dhw = new DumpHackerWindow(ofd.FileName); - } - catch (ProcessHacker.Native.Mfs.MfsInvalidFileSystemException) - { - PhUtils.ShowError("Unable to open the dump file: the dump file is invalid."); - } - catch (Exception ex) - { - PhUtils.ShowException("Unable to open the dump file", ex); - } + ofd.Filter = "Process Hacker Dump Files (*.phi)|*.phi|All Files (*.*)|*.*"; + + if (ofd.ShowDialog() == DialogResult.OK) + { + DumpHackerWindow dhw = null; - if (dhw != null) - dhw.Show(); + try + { + dhw = new DumpHackerWindow(ofd.FileName); } + catch (ProcessHacker.Native.Mfs.MfsInvalidFileSystemException) + { + PhUtils.ShowError("Unable to open the dump file: the dump file is invalid."); + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to open the dump file", ex); + } + + if (dhw != null) + dhw.Show(); } } @@ -590,30 +603,21 @@ private void physMemHistoryMenuItem_Click(object sender, EventArgs e) #endregion - public class ToolStripSearchBox : ToolStripControlHost - { - public ToolStripSearchBox() - : base(new VistaSearchBox()) - { - - } - } - #region Network Context Menu private void menuNetwork_Popup(object sender, EventArgs e) { if (listNetwork.SelectedItems.Count == 0) { - //contextMenuStripNetwork.DisableAll(); + menuNetwork.DisableAll(); } else if (listNetwork.SelectedItems.Count == 1) { - //contextMenuStripNetwork.EnableAll(); + menuNetwork.EnableAll(); } else { - //contextMenuStripNetwork.EnableAll(); + menuNetwork.EnableAll(); goToProcessNetworkMenuItem.Enabled = false; } @@ -799,7 +803,7 @@ private void closeNetworkMenuItem_Click(object sender, EventArgs e) private void selectAllNetworkMenuItem_Click(object sender, EventArgs e) { - this.listNetwork.List.Items.SelectAll(); + Utils.SelectAll(listNetwork.List.Items); } #endregion @@ -816,10 +820,10 @@ private void menuIcon_Popup(object sender, EventArgs e) List processes = new List(); // Clear the images so we don't get GDI+ handle leaks - //foreach (MenuItem item in processesMenuItem.MenuItems) - //vistaMenu.SetImage(item, null); + foreach (MenuItem item in processesMenuItem.MenuItems) + vistaMenu.SetImage(item, null); - processesMenuItem.DropDownItems.Clear(); + processesMenuItem.MenuItems.DisposeAndClear(); // HACK: To be fixed later - we need some sort of locking for the process provider try @@ -872,61 +876,62 @@ private void menuIcon_Popup(object sender, EventArgs e) processItem.Text = process.Name + " (" + process.Pid.ToString() + ")"; processItem.Tag = process; - terminateItem.Click += (sender_, e_) => + terminateItem.Click += new EventHandler((sender_, e_) => { - ProcessItem item = ((MenuItem)sender_).Parent.Tag as ProcessItem; + ProcessItem item = (ProcessItem)((MenuItem)sender_).Parent.Tag; ProcessActions.Terminate(this, new int[] { item.Pid }, new string[] { item.Name }, true); - }; + }); terminateItem.Text = "Terminate"; - suspendItem.Click += (sender_, e_) => + suspendItem.Click += new EventHandler((sender_, e_) => { - ProcessItem item = ((MenuItem)sender_).Parent.Tag as ProcessItem; + ProcessItem item = (ProcessItem)((MenuItem)sender_).Parent.Tag; ProcessActions.Suspend(this, new int[] { item.Pid }, new string[] { item.Name }, true); - }; + }); suspendItem.Text = "Suspend"; - resumeItem.Click += (sender_, e_) => + resumeItem.Click += new EventHandler((sender_, e_) => { - ProcessItem item = ((MenuItem)sender_).Parent.Tag as ProcessItem; + ProcessItem item = (ProcessItem)((MenuItem)sender_).Parent.Tag; ProcessActions.Resume(this, new int[] { item.Pid }, new string[] { item.Name }, true); - }; + }); resumeItem.Text = "Resume"; - //propertiesItem.Click += (sender_, e_) => - //{ - // try - // { - // ProcessItem item = (ProcessItem)((MenuItem)sender_).Parent.Tag; - - // Program.GetProcessWindow(Program.ProcessProvider.Dictionary[item.Pid], f => - // { - // f.Show(); - // f.Activate(); - // }); - // } - // catch (Exception ex) - // { - // PhUtils.ShowException("Unable to inspect the process", ex); - // } - //}; - //propertiesItem.Text = "Properties"; - - //processItem.MenuItems.AddRange(new MenuItem[] { terminateItem, suspendItem, resumeItem, propertiesItem }); - //processesMenuItem.DropDownItems.Add(processItem); - - // vistaMenu.SetImage(processItem, (treeProcesses.Tree.Model as ProcessTreeModel).Nodes[process.Pid].Icon); + propertiesItem.Click += new EventHandler((sender_, e_) => + { + try + { + ProcessItem item = (ProcessItem)((MenuItem)sender_).Parent.Tag; + + ProcessWindow pForm = Program.GetProcessWindow(Program.ProcessProvider.Dictionary[item.Pid], + new Program.PWindowInvokeAction(delegate(ProcessWindow f) + { + f.Show(); + f.Activate(); + })); + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to inspect the process", ex); + } + }); + propertiesItem.Text = "Properties"; + + processItem.MenuItems.AddRange(new MenuItem[] { terminateItem, suspendItem, resumeItem, propertiesItem }); + processesMenuItem.MenuItems.Add(processItem); + + vistaMenu.SetImage(processItem, (treeProcesses.Tree.Model as ProcessTreeModel).Nodes[process.Pid].Icon); } } catch { - //foreach (MenuItem item in processesMenuItem.MenuItems) - //vistaMenu.SetImage(item, null); + foreach (MenuItem item in processesMenuItem.MenuItems) + vistaMenu.SetImage(item, null); - processesMenuItem.DropDownItems.Clear(); + processesMenuItem.MenuItems.DisposeAndClear(); } } @@ -962,22 +967,22 @@ private void networkInfomationMenuItem_Click(object sender, EventArgs e) private void enableAllNotificationsMenuItem_Click(object sender, EventArgs e) { - newProcessesToolStripMenuItem.Checked = true; - terminatedProcessesToolStripMenuItem.Checked = true; - newServicesToolStripMenuItem.Checked = true; - startedServicesToolStripMenuItem.Checked = true; - stoppedServicesToolStripMenuItem.Checked = true; - deletedServicesToolStripMenuItem.Checked = true; + NPMenuItem.Checked = true; + TPMenuItem.Checked = true; + NSMenuItem.Checked = true; + startedSMenuItem.Checked = true; + stoppedSMenuItem.Checked = true; + DSMenuItem.Checked = true; } private void disableAllNotificationsMenuItem_Click(object sender, EventArgs e) { - newProcessesToolStripMenuItem.Checked = false; - terminatedProcessesToolStripMenuItem.Checked = false; - newServicesToolStripMenuItem.Checked = false; - startedServicesToolStripMenuItem.Checked = false; - stoppedServicesToolStripMenuItem.Checked = false; - deletedServicesToolStripMenuItem.Checked = false; + NPMenuItem.Checked = false; + TPMenuItem.Checked = false; + NSMenuItem.Checked = false; + startedSMenuItem.Checked = false; + stoppedSMenuItem.Checked = false; + DSMenuItem.Checked = false; } private void exitTrayMenuItem_Click(object sender, EventArgs e) @@ -991,7 +996,7 @@ private void exitTrayMenuItem_Click(object sender, EventArgs e) private void menuProcess_Popup(object sender, EventArgs e) { - virtualizationToolStripMenuItem.Checked = false; + virtualizationProcessMenuItem.Checked = false; // Menu item fixup... if (treeProcesses.SelectedTreeNodes.Count == 0) @@ -999,72 +1004,72 @@ private void menuProcess_Popup(object sender, EventArgs e) // If nothing is selected, disable everything. // The Select All menu item will be enabled later if // we have at least one process in the tree. - //contextMenuStripProcess.DisableAll(); + menuProcess.DisableAll(); } else if (treeProcesses.SelectedTreeNodes.Count == 1) { // All actions should work with one process selected. - //contextMenuStripProcess.EnableAll(); + menuProcess.EnableAll(); // Singular nouns. - //priorityMenuItem.Text = "&Priority"; - //terminateToolStripMenuItem.Text = "&Terminate Process"; - //suspendToolStripMenuItem.Text = "&Suspend Process"; - //resumeToolStripMenuItem.Text = "&Resume Process"; + priorityMenuItem.Text = "&Priority"; + terminateMenuItem.Text = "&Terminate Process"; + suspendMenuItem.Text = "&Suspend Process"; + resumeMenuItem.Text = "&Resume Process"; // Clear the priority menu items. - realTimeToolStripMenuItem.Checked = false; - highToolStripMenuItem.Checked = false; - aboveNormalToolStripMenuItem.Checked = false; - normalToolStripMenuItem.Checked = false; - belowNormalToolStripMenuItem.Checked = false; - idleToolStripMenuItem.Checked = false; + realTimeMenuItem.Checked = false; + highMenuItem.Checked = false; + aboveNormalMenuItem.Checked = false; + normalMenuItem.Checked = false; + belowNormalMenuItem.Checked = false; + idleMenuItem.Checked = false; // Clear the I/O priority menu items. - iOPriorityToolStripMenuItem.Enabled = true; + ioPriorityThreadMenuItem.Enabled = true; ioPriority0ThreadMenuItem.Checked = false; ioPriority1ThreadMenuItem.Checked = false; - ioPriority3ThreadMenuItem.Checked = false; + ioPriority2ThreadMenuItem.Checked = false; ioPriority3ThreadMenuItem.Checked = false; try { - using (ProcessHandle phandle = new ProcessHandle(processSelectedPid, Program.MinProcessQueryRights)) + using (var phandle = new ProcessHandle(processSelectedPid, Program.MinProcessQueryRights)) { try { - switch (phandle.PriorityClass) + switch (phandle.GetPriorityClass()) { case ProcessPriorityClass.RealTime: - realTimeToolStripMenuItem.Checked = true; + realTimeMenuItem.Checked = true; break; case ProcessPriorityClass.High: - highToolStripMenuItem.Checked = true; + highMenuItem.Checked = true; break; case ProcessPriorityClass.AboveNormal: - aboveNormalToolStripMenuItem.Checked = true; + aboveNormalMenuItem.Checked = true; break; case ProcessPriorityClass.Normal: - normalToolStripMenuItem.Checked = true; + normalMenuItem.Checked = true; break; case ProcessPriorityClass.BelowNormal: - belowNormalToolStripMenuItem.Checked = true; + belowNormalMenuItem.Checked = true; break; case ProcessPriorityClass.Idle: - idleToolStripMenuItem.Checked = true; + idleMenuItem.Checked = true; break; } } catch { - realTimeToolStripMenuItem.Enabled = false; + priorityMenuItem.Enabled = false; } try { if (OSVersion.HasIoPriority) { - switch (phandle.IoPriority) + switch (phandle.GetIoPriority()) { case 0: ioPriority0ThreadMenuItem.Checked = true; @@ -1073,7 +1078,7 @@ private void menuProcess_Popup(object sender, EventArgs e) ioPriority1ThreadMenuItem.Checked = true; break; case 2: - ioPriority3ThreadMenuItem.Checked = true; + ioPriority2ThreadMenuItem.Checked = true; break; case 3: ioPriority3ThreadMenuItem.Checked = true; @@ -1083,37 +1088,44 @@ private void menuProcess_Popup(object sender, EventArgs e) } catch { - iOPriorityToolStripMenuItem.Enabled = false; + ioPriorityThreadMenuItem.Enabled = false; } } } catch { - priorityToolStripMenuItem.Enabled = false; - iOPriorityToolStripMenuItem.Enabled = false; + priorityMenuItem.Enabled = false; + ioPriorityThreadMenuItem.Enabled = false; } // Check if we think the process exists. If we don't, disable all menu items // to avoid random exceptions occurring when the user clicks on certain things. if (!Program.ProcessProvider.Dictionary.ContainsKey(processSelectedPid)) { - //menuProcess.DisableAll(); + menuProcess.DisableAll(); } else { // Check the virtualization menu item. try { - using (ProcessHandle phandle = new ProcessHandle(processSelectedPid, Program.MinProcessQueryRights)) - using (TokenHandle thandle = phandle.GetToken(TokenAccess.Query)) + using (var phandle = new ProcessHandle(processSelectedPid, Program.MinProcessQueryRights)) { - if (virtualizationToolStripMenuItem.Enabled = thandle.IsVirtualizationAllowed) - virtualizationToolStripMenuItem.Checked = thandle.IsVirtualizationEnabled; + try + { + using (var thandle = phandle.GetToken(TokenAccess.Query)) + { + if (virtualizationProcessMenuItem.Enabled = thandle.IsVirtualizationAllowed()) + virtualizationProcessMenuItem.Checked = thandle.IsVirtualizationEnabled(); + } + } + catch + { } } } catch { - virtualizationToolStripMenuItem.Enabled = false; + virtualizationProcessMenuItem.Enabled = false; } // Enable/disable DLL injection based on the process' session ID. This only applies @@ -1124,9 +1136,9 @@ private void menuProcess_Popup(object sender, EventArgs e) OSVersion.IsBelowOrEqual(WindowsVersion.XP) && Program.ProcessProvider.Dictionary[processSelectedPid].SessionId != Program.CurrentSessionId ) - injectDLLToolStripMenuItem.Enabled = false; + injectDllProcessMenuItem.Enabled = false; else - injectDLLToolStripMenuItem.Enabled = true; + injectDllProcessMenuItem.Enabled = true; } catch (Exception ex) { @@ -1138,10 +1150,11 @@ private void menuProcess_Popup(object sender, EventArgs e) // is sorting the list (!). try { - if (treeProcesses.SelectedTreeNodes[0].IsLeaf && string.IsNullOrEmpty((treeProcesses.Tree.Model as ProcessTreeModel).GetSortColumn())) - terminateProcessTreeToolStripMenuItem.Visible = false; + if (treeProcesses.SelectedTreeNodes[0].IsLeaf && + (treeProcesses.Tree.Model as ProcessTreeModel).GetSortColumn() == "") + terminateProcessTreeMenuItem.Visible = false; else - terminateProcessTreeToolStripMenuItem.Visible = true; + terminateProcessTreeMenuItem.Visible = true; } catch (Exception ex) { @@ -1150,47 +1163,48 @@ private void menuProcess_Popup(object sender, EventArgs e) // Find the process' window (if any). windowHandle = WindowHandle.Zero; - WindowHandle.Enumerate(handle => - { - // GetWindowLong - // Shell_TrayWnd - if (handle.IsWindow && handle.IsVisible && handle.IsParent) + WindowHandle.Enumerate( + (handle) => { - int pid; - Win32.GetWindowThreadProcessId(handle, out pid); - - if (pid == processSelectedPid) + // GetWindowLong + // Shell_TrayWnd + if (handle.IsWindow() && handle.IsVisible() && handle.IsParent()) { - windowHandle = handle; - return false; + int pid; + Win32.GetWindowThreadProcessId(handle, out pid); + + if (pid == processSelectedPid) + { + windowHandle = handle; + return false; + } } - } - return true; - }); + return true; + }); // Enable the Window submenu if we found window owned // by the process. Otherwise, disable the submenu. if (windowHandle.IsInvalid) { - windowToolStripMenuItem1.Enabled = false; + windowProcessMenuItem.Enabled = false; } else { - windowToolStripMenuItem1.Enabled = true; - //windowToolStripMenuItem1.EnableAll(); + windowProcessMenuItem.Enabled = true; + windowProcessMenuItem.EnableAll(); - switch (windowHandle.Placement.ShowState) + switch (windowHandle.GetPlacement().ShowState) { case ShowWindowType.ShowMinimized: - minimizeToolStripMenuItem.Enabled = false; + minimizeProcessMenuItem.Enabled = false; break; case ShowWindowType.ShowMaximized: - maximizeToolStripMenuItem.Enabled = false; + maximizeProcessMenuItem.Enabled = false; break; case ShowWindowType.ShowNormal: - restoreToolStripMenuItem.Enabled = false; + restoreProcessMenuItem.Enabled = false; break; } } @@ -1199,37 +1213,37 @@ private void menuProcess_Popup(object sender, EventArgs e) else { // Assume most process actions will not work with more than one process. - //menuProcess.DisableAll(); + menuProcess.DisableAll(); // Use plural nouns. - terminateProcessTreeToolStripMenuItem.Text = "&Terminate Processes"; - suspendToolStripMenuItem.Text = "&Suspend Processes"; - resumeToolStripMenuItem.Text = "&Resume Processes"; + terminateMenuItem.Text = "&Terminate Processes"; + suspendMenuItem.Text = "&Suspend Processes"; + resumeMenuItem.Text = "&Resume Processes"; // Enable a specific set of actions. - terminateToolStripMenuItem.Enabled = true; - suspendToolStripMenuItem.Enabled = true; - resumeToolStripMenuItem.Enabled = true; - reduceWorkingSetToolStripMenuItem.Enabled = true; + terminateMenuItem.Enabled = true; + suspendMenuItem.Enabled = true; + resumeMenuItem.Enabled = true; + reduceWorkingSetProcessMenuItem.Enabled = true; copyProcessMenuItem.Enabled = true; } // Special case for invalid PIDs. if (processSelectedPid <= 0 && treeProcesses.SelectedNodes.Count == 1) { - //priorityMenuItem.Text = "&Priority"; - //menuProcess.DisableAll(); - propertiesToolStripMenuItem1.Enabled = true; + priorityMenuItem.Text = "&Priority"; + menuProcess.DisableAll(); + propertiesProcessMenuItem.Enabled = true; } // Enable/disable the Select All menu item. if (treeProcesses.Model.Nodes.Count == 0) { - selectAllToolStripMenuItem.Enabled = false; + selectAllProcessMenuItem.Enabled = false; } else { - selectAllToolStripMenuItem.Enabled = true; + selectAllProcessMenuItem.Enabled = true; } } @@ -1418,10 +1432,12 @@ private void virtualizationProcessMenuItem_Click(object sender, EventArgs e) try { - using (ProcessHandle phandle = new ProcessHandle(processSelectedPid, Program.MinProcessQueryRights)) - using (TokenHandle thandle = phandle.GetToken(TokenAccess.GenericWrite)) + using (var phandle = new ProcessHandle(processSelectedPid, Program.MinProcessQueryRights)) { - thandle.IsVirtualizationEnabled = !virtualizationToolStripMenuItem.Checked; + using (var thandle = phandle.GetToken(TokenAccess.GenericWrite)) + { + thandle.SetVirtualizationEnabled(!virtualizationProcessMenuItem.Checked); + } } } catch (Exception ex) @@ -1441,16 +1457,15 @@ private void propertiesProcessMenuItem_Click(object sender, EventArgs e) private void affinityProcessMenuItem_Click(object sender, EventArgs e) { - using (ProcessAffinity affForm = new ProcessAffinity(processSelectedPid)) + ProcessAffinity affForm = new ProcessAffinity(processSelectedPid); + + try { - try - { - affForm.ShowDialog(); - } - catch (Exception ex) - { - Logging.Log(ex); - } + affForm.ShowDialog(); + } + catch (Exception ex) + { + Logging.Log(ex); } } @@ -1500,7 +1515,6 @@ private void createDumpFileProcessMenuItem_Click(object sender, EventArgs e) td.MainInstruction = "Creating the dump file..."; td.ShowMarqueeProgressBar = true; td.EnableHyperlinks = true; - td.PositionRelativeToWindow = true; td.CallbackTimer = true; td.Callback = (taskDialog, args, userData) => { @@ -1571,14 +1585,11 @@ private void createDumpFileProcessMenuItem_Click(object sender, EventArgs e) private void terminatorProcessMenuItem_Click(object sender, EventArgs e) { - using (TerminatorWindow w = new TerminatorWindow(processSelectedPid) - { - Text = "Terminator - " + Program.ProcessProvider.Dictionary[this.processSelectedPid].Name + - " (PID " + this.processSelectedPid.ToString() + ")" - }) - { - w.ShowDialog(); - } + TerminatorWindow w = new TerminatorWindow(processSelectedPid); + + w.Text = "Terminator - " + Program.ProcessProvider.Dictionary[processSelectedPid].Name + + " (PID " + processSelectedPid.ToString() + ")"; + w.ShowDialog(); } #region Run As @@ -1589,10 +1600,8 @@ private void launchAsUserProcessMenuItem_Click(object sender, EventArgs e) { Settings.Instance.RunAsCommand = Program.ProcessProvider.Dictionary[processSelectedPid].FileName; - using (RunWindow run = new RunWindow()) - { - run.ShowDialog(); - } + RunWindow run = new RunWindow(); + run.ShowDialog(); } catch (Exception ex) { @@ -1604,11 +1613,9 @@ private void launchAsThisUserProcessMenuItem_Click(object sender, EventArgs e) { try { - using (RunWindow run = new RunWindow()) - { - run.UsePID(processSelectedPid); - run.ShowDialog(); - } + RunWindow run = new RunWindow(); + run.UsePID(processSelectedPid); + run.ShowDialog(); } catch (Exception ex) { @@ -1674,25 +1681,24 @@ private void heapsProcessMenuItem_Click(object sender, EventArgs e) private void injectDllProcessMenuItem_Click(object sender, EventArgs e) { - using (OpenFileDialog ofd = new OpenFileDialog - { - Filter = "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*" - }) + OpenFileDialog ofd = new OpenFileDialog(); + + ofd.Filter = "DLL Files (*.dll)|*.dll|All Files (*.*)|*.*"; + + if (ofd.ShowDialog() == DialogResult.OK) { - if (ofd.ShowDialog() == DialogResult.OK) + try { - try - { - using (ProcessHandle phandle = new ProcessHandle(processSelectedPid, ProcessAccess.CreateThread | ProcessAccess.VmOperation | ProcessAccess.VmWrite)) - { - phandle.InjectDll(ofd.FileName, 5000); - } - } - catch (Exception ex) + using (var phandle = new ProcessHandle(processSelectedPid, + ProcessAccess.CreateThread | ProcessAccess.VmOperation | ProcessAccess.VmWrite)) { - PhUtils.ShowException("Unable to inject the DLL", ex); + phandle.InjectDll(ofd.FileName, 5000); } } + catch (Exception ex) + { + PhUtils.ShowException("Unable to inject the DLL", ex); + } } } @@ -1728,21 +1734,19 @@ private void protectionProcessMenuItem_Click(object sender, EventArgs e) private void setTokenProcessMenuItem_Click(object sender, EventArgs e) { - using (ProcessPickerWindow picker = new ProcessPickerWindow - { - Label = "Select the source of the token:" - }) + ProcessPickerWindow picker = new ProcessPickerWindow(); + + picker.Label = "Select the source of the token:"; + + if (picker.ShowDialog() == DialogResult.OK) { - if (picker.ShowDialog() == DialogResult.OK) + try { - try - { - //KProcessHacker2.Instance.KphOpenProcessToken(picker, processSelectedPid); - } - catch (Exception ex) - { - PhUtils.ShowException("Unable to set the process token", ex); - } + KProcessHacker.Instance.SetProcessToken(picker.SelectedPid, processSelectedPid); + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to set the process token", ex); } } } @@ -1787,9 +1791,9 @@ private void idleMenuItem_Click(object sender, EventArgs e) private void bringToFrontProcessMenuItem_Click(object sender, EventArgs e) { - if (!windowHandle.IsInvalid && windowHandle.IsWindow) + if (!windowHandle.IsInvalid && windowHandle.IsWindow()) { - WindowPlacement placement = windowHandle.Placement; + WindowPlacement placement = windowHandle.GetPlacement(); if (placement.ShowState == ShowWindowType.ShowMinimized) windowHandle.Show(ShowWindowType.Restore); @@ -1800,7 +1804,7 @@ private void bringToFrontProcessMenuItem_Click(object sender, EventArgs e) private void restoreProcessMenuItem_Click(object sender, EventArgs e) { - if (!windowHandle.IsInvalid && windowHandle.IsWindow) + if (!windowHandle.IsInvalid && windowHandle.IsWindow()) { windowHandle.Show(ShowWindowType.Restore); } @@ -1808,7 +1812,7 @@ private void restoreProcessMenuItem_Click(object sender, EventArgs e) private void minimizeProcessMenuItem_Click(object sender, EventArgs e) { - if (!windowHandle.IsInvalid && windowHandle.IsWindow) + if (!windowHandle.IsInvalid && windowHandle.IsWindow()) { windowHandle.Show(ShowWindowType.ShowMinimized); } @@ -1816,7 +1820,7 @@ private void minimizeProcessMenuItem_Click(object sender, EventArgs e) private void maximizeProcessMenuItem_Click(object sender, EventArgs e) { - if (!windowHandle.IsInvalid && windowHandle.IsWindow) + if (!windowHandle.IsInvalid && windowHandle.IsWindow()) { windowHandle.Show(ShowWindowType.ShowMaximized); } @@ -1824,7 +1828,7 @@ private void maximizeProcessMenuItem_Click(object sender, EventArgs e) private void closeProcessMenuItem_Click(object sender, EventArgs e) { - if (!windowHandle.IsInvalid && windowHandle.IsWindow) + if (!windowHandle.IsInvalid && windowHandle.IsWindow()) { windowHandle.PostMessage(WindowMessage.Close, 0, 0); //windowHandle.Close(); @@ -1838,7 +1842,8 @@ private void searchProcessMenuItem_Click(object sender, EventArgs e) if (treeProcesses.SelectedNodes.Count != 1) return; - Program.TryStart(Settings.Instance.SearchEngine.Replace("%s", treeProcesses.SelectedNodes[0].Name)); + Program.TryStart(Settings.Instance.SearchEngine.Replace("%s", + treeProcesses.SelectedNodes[0].Name)); } private void reanalyzeProcessMenuItem_Click(object sender, EventArgs e) @@ -1884,9 +1889,7 @@ private void virusTotalMenuItem_Click(object sender, EventArgs e) vt.Show(); } else - { PhUtils.ShowError("An Internet session could not be established. Please verify connectivity."); - } } private void analyzeWaitChainProcessMenuItem_Click(object sender, EventArgs e) @@ -1912,41 +1915,41 @@ private void processP_Updated() Program.ProcessProvider.DictionaryRemoved += processP_DictionaryRemoved; Program.ProcessProvider.Updated -= processP_Updated; - ProcessHandle.Current.PriorityClass = ProcessPriorityClass.High; + try { ProcessHandle.Current.SetPriorityClass(ProcessPriorityClass.High); } + catch { } _enableNetworkProviderSync.Increment(); _refreshHighlightingSync.Increment(); if (Program.ProcessProvider.RunCount >= 1) - this.BeginInvoke(new MethodInvoker(() => + this.BeginInvoke(new MethodInvoker(delegate { - this.treeProcesses.Tree.EndCompleteUpdate(); - this.treeProcesses.Tree.EndUpdate(); + treeProcesses.Tree.EndCompleteUpdate(); + treeProcesses.Tree.EndUpdate(); if (Settings.Instance.ScrollDownProcessTree) { // HACK try { - foreach (var process in this.treeProcesses.Model.Roots) + foreach (var process in treeProcesses.Model.Roots) { if ( string.Equals(process.Name, "explorer.exe", - StringComparison.OrdinalIgnoreCase) && + StringComparison.OrdinalIgnoreCase) && process.ProcessItem.Username == Program.CurrentUsername) { - this.treeProcesses.FindTreeNode(process).EnsureVisible2(); + treeProcesses.FindTreeNode(process).EnsureVisible2(); break; } } } catch - { - } + { } } - this.treeProcesses.Invalidate(); + treeProcesses.Invalidate(); Program.ProcessProvider.Boost(); this.Cursor = Cursors.Default; })); @@ -1954,7 +1957,10 @@ private void processP_Updated() private void processP_InfoUpdater() { - this.BeginInvoke(new MethodInvoker(this.UpdateStatusInfo)); + this.BeginInvoke(new MethodInvoker(delegate + { + UpdateStatusInfo(); + })); } private void processP_FileProcessingReceived(int stage, int pid) @@ -1970,7 +1976,7 @@ private void processP_FileProcessingReceived(int stage, int pid) public void processP_DictionaryAdded(ProcessItem item) { ProcessItem parent = null; - string parentText = string.Empty; + string parentText = ""; if (item.HasParent && Program.ProcessProvider.Dictionary.ContainsKey(item.ParentPid)) { @@ -1988,11 +1994,11 @@ public void processP_DictionaryAdded(ProcessItem item) this.QueueMessage("New Process: " + item.Name + " (PID " + item.Pid.ToString() + ")" + parentText); - if (newProcessesToolStripMenuItem.Checked) + if (NPMenuItem.Checked) this.GetFirstIcon().ShowBalloonTip(2000, "New Process", "The process " + item.Name + " (" + item.Pid.ToString() + - ") was started" + ((parentText != string.Empty) ? " by " + - parent.Name + " (" + parent.Pid.ToString() + ")" : string.Empty) + ".", ToolTipIcon.Info); + ") was started" + ((parentText != "") ? " by " + + parent.Name + " (" + parent.Pid.ToString() + ")" : "") + ".", ToolTipIcon.Info); } public void processP_DictionaryRemoved(ProcessItem item) @@ -2002,14 +2008,17 @@ public void processP_DictionaryRemoved(ProcessItem item) if (processServices.ContainsKey(item.Pid)) processServices.Remove(item.Pid); - if (terminatedProcessesToolStripMenuItem.Checked) + if (TPMenuItem.Checked) this.GetFirstIcon().ShowBalloonTip(2000, "Terminated Process", "The process " + item.Name + " (" + item.Pid.ToString() + ") was terminated.", ToolTipIcon.Info); } private void serviceP_Updated() { - listServices.BeginInvoke(new MethodInvoker(() => this.listServices.List.EndUpdate())); + listServices.BeginInvoke(new MethodInvoker(delegate + { + listServices.List.EndUpdate(); + })); HighlightingContext.StateHighlighting = true; @@ -2025,11 +2034,11 @@ public void serviceP_DictionaryAdded(ServiceItem item) { this.QueueMessage("New Service: " + item.Status.ServiceName + " (" + item.Status.ServiceStatusProcess.ServiceType.ToString() + ")" + - (!string.IsNullOrEmpty(item.Status.DisplayName) ? + ((item.Status.DisplayName != "") ? " (" + item.Status.DisplayName + ")" : - string.Empty)); + "")); - if (newServicesToolStripMenuItem.Checked) + if (NSMenuItem.Checked) this.GetFirstIcon().ShowBalloonTip(2000, "New Service", "The service " + item.Status.ServiceName + " (" + item.Status.DisplayName + ") has been created.", ToolTipIcon.Info); @@ -2057,11 +2066,11 @@ public void serviceP_DictionaryModified(ServiceItem oldItem, ServiceItem newItem { this.QueueMessage("Service Started: " + newItem.Status.ServiceName + " (" + newItem.Status.ServiceStatusProcess.ServiceType.ToString() + ")" + - ((newItem.Status.DisplayName != string.Empty) ? + ((newItem.Status.DisplayName != "") ? " (" + newItem.Status.DisplayName + ")" : - string.Empty)); + "")); - if (startedServicesToolStripMenuItem.Checked) + if (startedSMenuItem.Checked) this.GetFirstIcon().ShowBalloonTip(2000, "Service Started", "The service " + newItem.Status.ServiceName + " (" + newItem.Status.DisplayName + ") has been started.", ToolTipIcon.Info); @@ -2071,20 +2080,20 @@ public void serviceP_DictionaryModified(ServiceItem oldItem, ServiceItem newItem newState == ServiceState.Paused) this.QueueMessage("Service Paused: " + newItem.Status.ServiceName + " (" + newItem.Status.ServiceStatusProcess.ServiceType.ToString() + ")" + - ((newItem.Status.DisplayName != string.Empty) ? + ((newItem.Status.DisplayName != "") ? " (" + newItem.Status.DisplayName + ")" : - string.Empty)); + "")); if (oldState == ServiceState.Running && newState == ServiceState.Stopped) { this.QueueMessage("Service Stopped: " + newItem.Status.ServiceName + " (" + newItem.Status.ServiceStatusProcess.ServiceType.ToString() + ")" + - ((newItem.Status.DisplayName != string.Empty) ? + ((newItem.Status.DisplayName != "") ? " (" + newItem.Status.DisplayName + ")" : - string.Empty)); + "")); - if (stoppedServicesToolStripMenuItem.Checked) + if (stoppedSMenuItem.Checked) this.GetFirstIcon().ShowBalloonTip(2000, "Service Stopped", "The service " + newItem.Status.ServiceName + " (" + newItem.Status.DisplayName + ") has been stopped.", ToolTipIcon.Info); @@ -2123,11 +2132,11 @@ public void serviceP_DictionaryRemoved(ServiceItem item) { this.QueueMessage("Deleted Service: " + item.Status.ServiceName + " (" + item.Status.ServiceStatusProcess.ServiceType.ToString() + ")" + - ((item.Status.DisplayName != string.Empty) ? + ((item.Status.DisplayName != "") ? " (" + item.Status.DisplayName + ")" : - string.Empty)); + "")); - if (deletedServicesToolStripMenuItem.Checked) + if (DSMenuItem.Checked) this.GetFirstIcon().ShowBalloonTip(2000, "Service Deleted", "The service " + item.Status.ServiceName + " (" + item.Status.DisplayName + ") has been deleted.", ToolTipIcon.Info); @@ -2150,6 +2159,102 @@ public void serviceP_DictionaryRemoved_Process(ServiceItem item) #region Service Context Menu + private void menuService_Popup(object sender, EventArgs e) + { + if (listServices.SelectedItems.Count == 0) + { + menuService.DisableAll(); + goToProcessServiceMenuItem.Visible = true; + startServiceMenuItem.Visible = true; + continueServiceMenuItem.Visible = true; + pauseServiceMenuItem.Visible = true; + stopServiceMenuItem.Visible = true; + + selectAllServiceMenuItem.Enabled = true; + } + else if (listServices.SelectedItems.Count == 1) + { + menuService.EnableAll(); + + goToProcessServiceMenuItem.Visible = true; + startServiceMenuItem.Visible = true; + continueServiceMenuItem.Visible = true; + pauseServiceMenuItem.Visible = true; + stopServiceMenuItem.Visible = true; + + try + { + ServiceItem item = Program.ServiceProvider.Dictionary[listServices.SelectedItems[0].Name]; + + if (item.Status.ServiceStatusProcess.ProcessID != 0) + { + goToProcessServiceMenuItem.Enabled = true; + } + else + { + goToProcessServiceMenuItem.Enabled = false; + } + + if ((item.Status.ServiceStatusProcess.ControlsAccepted & ServiceAccept.PauseContinue) + == 0) + { + continueServiceMenuItem.Visible = false; + pauseServiceMenuItem.Visible = false; + } + else + { + continueServiceMenuItem.Visible = true; + pauseServiceMenuItem.Visible = true; + } + + if (item.Status.ServiceStatusProcess.CurrentState == ServiceState.Paused) + { + startServiceMenuItem.Enabled = false; + pauseServiceMenuItem.Enabled = false; + } + else if (item.Status.ServiceStatusProcess.CurrentState == ServiceState.Running) + { + startServiceMenuItem.Enabled = false; + continueServiceMenuItem.Enabled = false; + } + else if (item.Status.ServiceStatusProcess.CurrentState == ServiceState.Stopped) + { + pauseServiceMenuItem.Enabled = false; + stopServiceMenuItem.Enabled = false; + } + + if ((item.Status.ServiceStatusProcess.ControlsAccepted & ServiceAccept.Stop) == 0 && + item.Status.ServiceStatusProcess.CurrentState == ServiceState.Running) + { + stopServiceMenuItem.Enabled = false; + } + } + catch + { + menuService.DisableAll(); + copyServiceMenuItem.Enabled = true; + propertiesServiceMenuItem.Enabled = true; + } + } + else + { + menuService.DisableAll(); + + goToProcessServiceMenuItem.Visible = false; + startServiceMenuItem.Visible = false; + continueServiceMenuItem.Visible = false; + pauseServiceMenuItem.Visible = false; + stopServiceMenuItem.Visible = false; + + copyServiceMenuItem.Enabled = true; + propertiesServiceMenuItem.Enabled = true; + selectAllServiceMenuItem.Enabled = true; + } + + if (listServices.List.Items.Count == 0) + selectAllServiceMenuItem.Enabled = false; + } + private void goToProcessServiceMenuItem_Click(object sender, EventArgs e) { this.SelectProcess( @@ -2209,7 +2314,7 @@ private void propertiesServiceMenuItem_Click(object sender, EventArgs e) private void selectAllServiceMenuItem_Click(object sender, EventArgs e) { - this.listServices.Items.SelectAll(); + Utils.SelectAll(listServices.Items); } #endregion @@ -2328,26 +2433,22 @@ private void thumbButtonManager_TaskbarButtonCreated(object sender, EventArgs e) private void findHandlesToolStripButton_Click(object sender, EventArgs e) { - findHandlesMenuItem.PerformClick(); + findHandlesMenuItem_Click(sender, e); } private void refreshToolStripButton_Click(object sender, EventArgs e) { - if (Program.ProcessProvider.RunCount > 1) - Program.ProcessProvider.Boost(); - - if (Program.ServiceProvider.RunCount > 1) - Program.ServiceProvider.Boost(); + updateNowMenuItem_Click(sender, e); } private void sysInfoToolStripButton_Click(object sender, EventArgs e) { - sysInfoMenuItem.PerformClick(); + sysInfoMenuItem_Click(sender, e); } private void optionsToolStripButton_Click(object sender, EventArgs e) { - optionsMenuItem.PerformClick(); + optionsMenuItem_Click(sender, e); } #endregion @@ -2422,18 +2523,18 @@ public void ClearLog() private void CreateShutdownMenuItems() { - AddMenuItemDelegate addMenuItem = (text, onClick) => + AddMenuItemDelegate addMenuItem = (string text, EventHandler onClick) => { - shutdownMenuItem.DropDownItems.Add(text, null, onClick); - shutdownTrayMenuItem.DropDownItems.Add(text, null, onClick); + shutdownMenuItem.MenuItems.Add(new MenuItem(text, onClick)); + shutdownTrayMenuItem.MenuItems.Add(new MenuItem(text, onClick)); shutDownToolStripMenuItem.DropDownItems.Add(text, null, onClick); }; - addMenuItem("Lock", (sender, e) => Win32.LockWorkStation()); - addMenuItem("Logoff", (sender, e) => Win32.ExitWindowsEx(ExitWindowsFlags.Logoff, 0)); + addMenuItem("Lock", (sender, e) => { Win32.LockWorkStation(); }); + addMenuItem("Logoff", (sender, e) => { Win32.ExitWindowsEx(ExitWindowsFlags.Logoff, 0); }); addMenuItem("-", null); - addMenuItem("Sleep", (sender, e) => Win32.SetSuspendState(false, false, false)); - addMenuItem("Hibernate", (sender, e) => Win32.SetSuspendState(true, false, false)); + addMenuItem("Sleep", (sender, e) => { Win32.SetSuspendState(false, false, false); }); + addMenuItem("Hibernate", (sender, e) => { Win32.SetSuspendState(true, false, false); }); addMenuItem("-", null); addMenuItem("Restart", (sender, e) => { @@ -2471,7 +2572,7 @@ private Bitmap GetUacShieldIcon() const int height = 50; const int margin = 4; Bitmap shieldImage; - Button button = new Button + Button button = new Button() { Text = " ", Size = new Size(width, height), @@ -2614,10 +2715,25 @@ private void LoadOtherSettings() if (Loader.LoadDll(Settings.Instance.DbgHelpPath) == IntPtr.Zero) Loader.LoadDll("dbghelp.dll"); - // Load symsrv.dll from the same directory as dbghelp.dll. - // TODO: improve logic. - if (Loader.LoadDll(System.IO.Path.GetDirectoryName(Settings.Instance.DbgHelpPath) + "\\symsrv.dll") == IntPtr.Zero) - Loader.LoadDll("symsrv.dll"); + // Find the location of the dbghelp.dll we loaded and load symsrv.dll. + try + { + ProcessHandle.Current.EnumModules((module) => + { + if (module.FileName.ToLowerInvariant().EndsWith("dbghelp.dll")) + { + // Load symsrv.dll from the same directory as dbghelp.dll. + + Loader.LoadDll(System.IO.Path.GetDirectoryName(module.FileName) + "\\symsrv.dll"); + + return false; + } + + return true; + }); + } + catch + { } // Set the first run setting here. Settings.Instance.FirstRun = false; @@ -2657,12 +2773,12 @@ private void SaveSettings() Settings.Instance.ServiceListViewColumns = ColumnSettings.SaveSettings(listServices.List); Settings.Instance.NetworkListViewColumns = ColumnSettings.SaveSettings(listNetwork.List); - Settings.Instance.NewProcesses = newProcessesToolStripMenuItem.Checked; - Settings.Instance.TerminatedProcesses = terminatedProcessesToolStripMenuItem.Checked; - Settings.Instance.NewServices = newServicesToolStripMenuItem.Checked; - Settings.Instance.StartedServices = startedServicesToolStripMenuItem.Checked; - Settings.Instance.StoppedServices = stoppedServicesToolStripMenuItem.Checked; - Settings.Instance.DeletedServices = deletedServicesToolStripMenuItem.Checked; + Settings.Instance.NewProcesses = NPMenuItem.Checked; + Settings.Instance.TerminatedProcesses = TPMenuItem.Checked; + Settings.Instance.NewServices = NSMenuItem.Checked; + Settings.Instance.StartedServices = startedSMenuItem.Checked; + Settings.Instance.StoppedServices = stoppedSMenuItem.Checked; + Settings.Instance.DeletedServices = DSMenuItem.Checked; try { @@ -2705,18 +2821,20 @@ private void UpdateProgram(bool interactive) { checkForUpdatesMenuItem.Enabled = false; - NativeThreadPool.QueueWorkItem(o => - { - Updater.Update(this, interactive); - this.BeginInvoke(new MethodInvoker(() => this.checkForUpdatesMenuItem.Enabled = true)); - }, null); + Thread t = new Thread(new ThreadStart(() => + { + Updater.Update(this, interactive); + this.Invoke(new MethodInvoker(() => checkForUpdatesMenuItem.Enabled = true)); + }), Utils.SixteenthStackSize); + t.IsBackground = true; + t.Start(); } private void UpdateSessions() { - TerminalServerHandle currentServer = TerminalServerHandle.GetCurrent(); + var currentServer = TerminalServerHandle.GetCurrent(); - usersToolStripMenuItem.DropDownItems.Clear(); + usersMenuItem.MenuItems.Clear(); foreach (var session in currentServer.GetSessions()) { @@ -2729,82 +2847,88 @@ private void UpdateSessions() continue; } - AddMenuItemDelegate addMenuItem = (text, onClick) => - { - usersToolStripMenuItem.DropDownItems.Add(text, null, onClick); - shutdownTrayMenuItem.DropDownItems.Add(text, null, onClick); - shutDownToolStripMenuItem.DropDownItems.Add(text, null, onClick); - }; + MenuItem userMenuItem = new MenuItem(); - addMenuItem("Disconnect", (sender, e) => - { - int sessionId = (int)((MenuItem)sender).Tag; + userMenuItem.Text = session.SessionId + ": " + displayName; + + MenuItem currentMenuItem; - SessionActions.Disconnect(this, session.SessionId, false); - }); + currentMenuItem = new MenuItem() { Text = "Disconnect", Tag = session.SessionId }; + currentMenuItem.Click += (sender, e) => + { + int sessionId = (int)((MenuItem)sender).Tag; - //MenuItem userMenuItem = new MenuItem(); - //userMenuItem.Text = session.SessionId + ": " + displayName; - addMenuItem("Logoff", (sender, e) => + SessionActions.Disconnect(this, sessionId, false); + }; + userMenuItem.MenuItems.Add(currentMenuItem); + currentMenuItem = new MenuItem() { Text = "Logoff", Tag = session.SessionId }; + currentMenuItem.Click += (sender, e) => { int sessionId = (int)((MenuItem)sender).Tag; - SessionActions.Logoff(this, session.SessionId, true); - }); - - addMenuItem("Send Message...", (sender, e) => + SessionActions.Logoff(this, sessionId, true); + }; + userMenuItem.MenuItems.Add(currentMenuItem); + currentMenuItem = new MenuItem() { Text = "Send Message...", Tag = session.SessionId }; + currentMenuItem.Click += (sender, e) => { + int sessionId = (int)((MenuItem)sender).Tag; + try { - MessageBoxWindow mbw = new MessageBoxWindow - { - MessageBoxTitle = "Message from " + Program.CurrentUsername - }; + var mbw = new MessageBoxWindow(); + mbw.MessageBoxTitle = "Message from " + Program.CurrentUsername; mbw.OkButtonClicked += () => - { - try - { - TerminalServerHandle.GetCurrent().GetSession(session.SessionId).SendMessage( - mbw.MessageBoxTitle, - mbw.MessageBoxText, - MessageBoxButtons.OK, - mbw.MessageBoxIcon, - 0, - 0, - mbw.MessageBoxTimeout, - false - ); - - return true; - } - catch (Exception ex) { - PhUtils.ShowException("Unable to send the message", ex); - return false; - } - }; + try + { + TerminalServerHandle.GetCurrent().GetSession(sessionId).SendMessage( + mbw.MessageBoxTitle, + mbw.MessageBoxText, + MessageBoxButtons.OK, + mbw.MessageBoxIcon, + 0, + 0, + mbw.MessageBoxTimeout, + false + ); + return true; + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to send the message", ex); + return false; + } + }; mbw.ShowDialog(); } catch (Exception ex) { PhUtils.ShowException("Unable to show the message window", ex); } - }); - - addMenuItem("Properties...", (sender, e) => + }; + userMenuItem.MenuItems.Add(currentMenuItem); + currentMenuItem = new MenuItem() { Text = "Properties...", Tag = session.SessionId }; + currentMenuItem.Click += (sender, e) => { + int sessionId = (int)((MenuItem)sender).Tag; + try { - using (var sessionWindow = new SessionInformationWindow(TerminalServerHandle.GetCurrent().GetSession(session.SessionId))) - sessionWindow.ShowDialog(); + var sessionInformationWindow = + new SessionInformationWindow(TerminalServerHandle.GetCurrent().GetSession(sessionId)); + + sessionInformationWindow.ShowDialog(); } catch (Exception ex) { PhUtils.ShowException("Unable to show session properties", ex); } - }); + }; + userMenuItem.MenuItems.Add(currentMenuItem); + usersMenuItem.MenuItems.Add(userMenuItem); session.Dispose(); } } @@ -2830,8 +2954,8 @@ private void SetProcessPriority(ProcessPriorityClass priority) { try { - using (ProcessHandle phandle = new ProcessHandle(processSelectedPid, ProcessAccess.SetInformation)) - phandle.PriorityClass = priority; + using (var phandle = new ProcessHandle(processSelectedPid, ProcessAccess.SetInformation)) + phandle.SetPriorityClass(priority); } catch (Exception ex) { @@ -2843,8 +2967,8 @@ private void SetProcessIoPriority(int ioPriority) { try { - using (ProcessHandle phandle = new ProcessHandle(processSelectedPid, ProcessAccess.SetInformation)) - phandle.IoPriority = ioPriority; + using (var phandle = new ProcessHandle(processSelectedPid, ProcessAccess.SetInformation)) + phandle.SetIoPriority(ioPriority); } catch (Exception ex) { @@ -2942,6 +3066,11 @@ protected override void WndProc(ref Message m) } } break; + + case (int)WindowMessage.Paint: + this.Painting(); + break; + case (int)WindowMessage.Activate: case (int)WindowMessage.KillFocus: { @@ -2974,7 +3103,7 @@ protected override void WndProc(ref Message m) case (int)WindowMessage.SettingChange: { // Refresh icon sizes. - this.ExecuteOnIcons(icon => icon.Size = UsageIcon.GetSmallIconSize()); + this.ExecuteOnIcons((icon) => icon.Size = UsageIcon.GetSmallIconSize()); // Refresh the tree view visual style. treeProcesses.Tree.RefreshVisualStyles(); } @@ -2991,27 +3120,29 @@ public void Exit() public void Exit(bool saveSettings) { - Program.ProcessProvider.Enabled = false; - Program.ProcessProvider.Dispose(); + //processP.Dispose(); + //serviceP.Dispose(); + //networkP.Dispose(); - Program.ServiceProvider.Enabled = false; - Program.ServiceProvider.Dispose(); - - Program.NetworkProvider.Enabled = false; - Program.NetworkProvider.Dispose(); - - this.ExecuteOnIcons(icon => icon.Visible = false); - this.ExecuteOnIcons(icon => icon.Dispose()); + this.ExecuteOnIcons((icon) => icon.Visible = false); + this.ExecuteOnIcons((icon) => icon.Dispose()); // Only save settings if requested and no other instance of // PH is running. if (saveSettings && !Program.CheckPreviousInstance()) SaveSettings(); - if (KProcessHacker2.Instance != null) - KProcessHacker2.Instance.Dispose(); + this.Visible = false; + + if (KProcessHacker.Instance != null) + KProcessHacker.Instance.Close(); - Win32.NtTerminateProcess(ProcessHandle.Current, NtStatus.Success); + try + { + Win32.ExitProcess(0); + } + catch + { } } private void HackerWindow_FormClosing(object sender, FormClosingEventArgs e) @@ -3023,7 +3154,7 @@ private void HackerWindow_FormClosing(object sender, FormClosingEventArgs e) ) { e.Cancel = true; - this.showHideProcessHackerToolStripMenuItem.PerformClick(); + showHideMenuItem_Click(sender, null); return; } @@ -3037,26 +3168,26 @@ private void CheckedMenuItem_Click(object sender, EventArgs e) public void LoadFixOSSpecific() { - //if (KProcessHacker.Instance == null) - //hiddenProcessesMenuItem.Visible = false; + if (KProcessHacker.Instance == null) + hiddenProcessesMenuItem.Visible = false; - //if (KProcessHacker.Instance == null || !OSVersion.HasSetAccessToken) - setTokenToolStripMenuItem.Visible = false; + if (KProcessHacker.Instance == null || !OSVersion.HasSetAccessToken) + setTokenProcessMenuItem.Visible = false; - //if (KProcessHacker.Instance == null || !Settings.Instance.EnableExperimentalFeatures) - protectionToolStripMenuItem.Visible = false; + if (KProcessHacker.Instance == null || !Settings.Instance.EnableExperimentalFeatures) + protectionProcessMenuItem.Visible = false; if (!OSVersion.HasUac) - virtualizationToolStripMenuItem.Visible = false; + virtualizationProcessMenuItem.Visible = false; if (OSVersion.IsBelow(WindowsVersion.Vista)) - analyzeWaitChainToolStripMenuItem.Visible = false; + analyzeWaitChainProcessMenuItem.Visible = false; if (OSVersion.IsBelow(WindowsVersion.XP)) tabControl.TabPages.Remove(tabNetwork); if (!OSVersion.HasIoPriority) - iOPriorityToolStripMenuItem.Visible = false; + ioPriorityThreadMenuItem.Visible = false; } private void LoadFixNProcessHacker() @@ -3105,8 +3236,9 @@ private void LoadUac() { if (Program.ElevationType == TokenElevationType.Limited) { - this.showDetailsForAllProcessesMenuItem.Image = this.GetUacShieldIcon(); - //vistaMenu.SetImage(showDetailsForAllProcessesMenuItem, uacShieldIcon); + uacShieldIcon = this.GetUacShieldIcon(); + + vistaMenu.SetImage(showDetailsForAllProcessesMenuItem, uacShieldIcon); //vistaMenu.SetImage(startServiceMenuItem, uacShieldIcon); //vistaMenu.SetImage(continueServiceMenuItem, uacShieldIcon); //vistaMenu.SetImage(pauseServiceMenuItem, uacShieldIcon); @@ -3143,39 +3275,42 @@ private void LoadNotificationIcons() foreach (var icon in notifyIcons) icon.Icon = (Icon)blackIcon.Clone(); - this.ExecuteOnIcons(icon => icon.ContextMenu = contextMenuStripTray); - this.ExecuteOnIcons(icon => icon.MouseDoubleClick += notifyIcon_MouseDoubleClick); - - this.cpuHistoryMenuItem.Checked = Settings.Instance.CpuHistoryIconVisible; - this.cpuUsageMenuItem.Checked = Settings.Instance.CpuUsageIconVisible; - this.ioHistoryMenuItem.Checked = Settings.Instance.IoHistoryIconVisible; - this.commitHistoryMenuItem.Checked = Settings.Instance.CommitHistoryIconVisible; - this.physMemHistoryMenuItem.Checked = Settings.Instance.PhysMemHistoryIconVisible; + this.ExecuteOnIcons((icon) => icon.ContextMenu = menuIcon); + this.ExecuteOnIcons((icon) => icon.MouseDoubleClick += notifyIcon_MouseDoubleClick); + cpuHistoryMenuItem.Checked = Settings.Instance.CpuHistoryIconVisible; + cpuUsageMenuItem.Checked = Settings.Instance.CpuUsageIconVisible; + ioHistoryMenuItem.Checked = Settings.Instance.IoHistoryIconVisible; + commitHistoryMenuItem.Checked = Settings.Instance.CommitHistoryIconVisible; + physMemHistoryMenuItem.Checked = Settings.Instance.PhysMemHistoryIconVisible; this.ApplyIconVisibilities(); - this.newProcessesToolStripMenuItem.Checked = Settings.Instance.NewProcesses; - this.terminatedProcessesToolStripMenuItem.Checked = Settings.Instance.TerminatedProcesses; - this.newServicesToolStripMenuItem.Checked = Settings.Instance.NewServices; - this.startedServicesToolStripMenuItem.Checked = Settings.Instance.StartedServices; - this.stoppedServicesToolStripMenuItem.Checked = Settings.Instance.StoppedServices; - this.deletedServicesToolStripMenuItem.Checked = Settings.Instance.DeletedServices; + NPMenuItem.Checked = Settings.Instance.NewProcesses; + TPMenuItem.Checked = Settings.Instance.TerminatedProcesses; + NSMenuItem.Checked = Settings.Instance.NewServices; + startedSMenuItem.Checked = Settings.Instance.StartedServices; + stoppedSMenuItem.Checked = Settings.Instance.StoppedServices; + DSMenuItem.Checked = Settings.Instance.DeletedServices; - this.newProcessesToolStripMenuItem.Click += this.CheckedMenuItem_Click; - this.terminatedProcessesToolStripMenuItem.Click += this.CheckedMenuItem_Click; - this.newServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click; - this.startedServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click; - this.stoppedServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click; - this.deletedServicesToolStripMenuItem.Click += this.CheckedMenuItem_Click; + NPMenuItem.Click += new EventHandler(CheckedMenuItem_Click); + TPMenuItem.Click += new EventHandler(CheckedMenuItem_Click); + NSMenuItem.Click += new EventHandler(CheckedMenuItem_Click); + startedSMenuItem.Click += new EventHandler(CheckedMenuItem_Click); + stoppedSMenuItem.Click += new EventHandler(CheckedMenuItem_Click); + DSMenuItem.Click += new EventHandler(CheckedMenuItem_Click); } private void LoadControls() { networkInfomationMenuItem.Visible = false; // not ready - analyzeWaitChainToolStripMenuItem.Visible = false; // not ready + analyzeWaitChainProcessMenuItem.Visible = false; // not ready + + GenericViewMenu.AddMenuItems(copyProcessMenuItem.MenuItems, treeProcesses.Tree); + GenericViewMenu.AddMenuItems(copyServiceMenuItem.MenuItems, listServices.List, null); + GenericViewMenu.AddMenuItems(copyNetworkMenuItem.MenuItems, listNetwork.List, null); - //GenericViewMenu.AddMenuItems(copyProcessMenuItem.MenuItems, treeProcesses.Tree); - //GenericViewMenu.AddMenuItems(copyToolStripMenuItem1.MenuItems, listServices.List, null); - //GenericViewMenu.AddMenuItems(copyNetworkMenuItem.MenuItems, listNetwork.List, null); + treeProcesses.ContextMenu = menuProcess; + listServices.ContextMenu = menuService; + listNetwork.ContextMenu = menuNetwork; treeProcesses.Provider = Program.ProcessProvider; treeProcesses.Tree.BeginUpdate(); @@ -3205,33 +3340,30 @@ private void LoadControls() } treeProcesses.Tree.MouseDown += (sender, e) => - { - if (e.Button == MouseButtons.Right && e.Location.Y < treeProcesses.Tree.ColumnHeaderHeight) { - ContextMenu menu = new ContextMenu(); - - menu.MenuItems.Add(new MenuItem("Choose Columns...", (sender_, e_) => + if (e.Button == MouseButtons.Right && e.Location.Y < treeProcesses.Tree.ColumnHeaderHeight) { - using (var c = new ChooseColumnsWindow(treeProcesses.Tree)) - { - c.ShowDialog(); - } + ContextMenu menu = new ContextMenu(); - copyProcessMenuItem.DropDownItems.Clear(); - //GenericViewMenu.AddMenuItems(copyProcessMenuItem.MenuItems, treeProcesses.Tree); - treeProcesses.Tree.InvalidateNodeControlCache(); - treeProcesses.Tree.Invalidate(); - })); + menu.MenuItems.Add(new MenuItem("Choose Columns...", (sender_, e_) => + { + (new ChooseColumnsWindow(treeProcesses.Tree) + { }).ShowDialog(); - menu.Show(treeProcesses.Tree, e.Location); - } - }; + copyProcessMenuItem.MenuItems.DisposeAndClear(); + GenericViewMenu.AddMenuItems(copyProcessMenuItem.MenuItems, treeProcesses.Tree); + treeProcesses.Tree.InvalidateNodeControlCache(); + treeProcesses.Tree.Invalidate(); + })); - treeProcesses.Tree.ColumnClicked += (sender, e) => this.DeselectAll(this.treeProcesses.Tree); + menu.Show(treeProcesses.Tree, e.Location); + } + }; + treeProcesses.Tree.ColumnClicked += (sender, e) => { DeselectAll(treeProcesses.Tree); }; treeProcesses.Tree.ColumnReordered += (sender, e) => { - copyProcessMenuItem.DropDownItems.Clear(); - // GenericViewMenu.AddMenuItems(copyProcessMenuItem.MenuItems, treeProcesses.Tree); + copyProcessMenuItem.MenuItems.DisposeAndClear(); + GenericViewMenu.AddMenuItems(copyProcessMenuItem.MenuItems, treeProcesses.Tree); }; tabControlBig_SelectedIndexChanged(null, null); @@ -3239,17 +3371,17 @@ private void LoadControls() private void LoadAddShortcuts() { - treeProcesses.Tree.KeyDown += (sender, e) => - { - if (e.Control && e.KeyCode == Keys.A) + treeProcesses.Tree.KeyDown += + (sender, e) => { - treeProcesses.TreeNodes.SelectAll(); - treeProcesses.Tree.Invalidate(); - } - - if (e.Control && e.KeyCode == Keys.C) GenericViewMenu.TreeViewAdvCopy(treeProcesses.Tree, -1); - }; + if (e.Control && e.KeyCode == Keys.A) + { + treeProcesses.TreeNodes.SelectAll(); + treeProcesses.Tree.Invalidate(); + } + if (e.Control && e.KeyCode == Keys.C) GenericViewMenu.TreeViewAdvCopy(treeProcesses.Tree, -1); + }; listServices.List.AddShortcuts(); listNetwork.List.AddShortcuts(); } @@ -3261,31 +3393,31 @@ private void LoadApplyCommandLineArgs() private void LoadStructs() { - WorkQueue.GlobalQueueWorkItemTag(new MethodInvoker(() => - { - try + WorkQueue.GlobalQueueWorkItemTag(new Action(() => { - if (System.IO.File.Exists(Application.StartupPath + "\\structs.txt")) + try { - Structs.StructParser parser = new ProcessHacker.Structs.StructParser(Program.Structs); + if (System.IO.File.Exists(Application.StartupPath + "\\structs.txt")) + { + Structs.StructParser parser = new ProcessHacker.Structs.StructParser(Program.Structs); - parser.Parse(Application.StartupPath + "\\structs.txt"); + parser.Parse(Application.StartupPath + "\\structs.txt"); + } } - } - catch (Exception ex) - { - QueueMessage("Error loading structure definitions: " + ex.Message); - } - }), "load-structs"); + catch (Exception ex) + { + QueueMessage("Error loading structure definitions: " + ex.Message); + } + }), "load-structs"); } private void LoadOther() { try { - using (TokenHandle thandle = ProcessHandle.Current.GetToken(TokenAccess.Query)) - using (Sid sid = thandle.User) - this.Text += " [" + sid.GetFullName(true) + "]" + (KProcessHacker2.Instance != null ? "+" : string.Empty); + using (var thandle = ProcessHandle.Current.GetToken(TokenAccess.Query)) + using (var sid = thandle.GetUser()) + this.Text += " [" + sid.GetFullName(true) + (KProcessHacker.Instance != null ? "+" : "") + "]"; } catch { } @@ -3303,6 +3435,10 @@ public HackerWindow() { InitializeComponent(); + // Force the handle to be created + { var handle = this.Handle; } + Program.HackerWindowHandle = this.Handle; + if (OSVersion.HasExtendedTaskbar) { // We need to call this here or we don't receive the TaskbarButtonCreated message @@ -3311,7 +3447,7 @@ public HackerWindow() Windows7Taskbar.ProcessAppId = "ProcessHacker"; thumbButtonManager = new ThumbButtonManager(this); - thumbButtonManager.TaskbarButtonCreated += this.thumbButtonManager_TaskbarButtonCreated; + thumbButtonManager.TaskbarButtonCreated += new EventHandler(thumbButtonManager_TaskbarButtonCreated); } this.AddEscapeToClose(); @@ -3323,8 +3459,11 @@ public HackerWindow() Program.NetworkProvider.Enabled = true; Program.NetworkProvider.Boost(); }, 2); - - _refreshHighlightingSync = new ActionSync(() => this.BeginInvoke(new MethodInvoker(this.treeProcesses.RefreshItems), null), 2); + _refreshHighlightingSync = new ActionSync( + () => + { + this.BeginInvoke(new Action(treeProcesses.RefreshItems), null); + }, 2); Logging.Logged += this.QueueMessage; this.LoadWindowSettings(); @@ -3332,7 +3471,8 @@ public HackerWindow() this.LoadControls(); this.LoadNotificationIcons(); - if ((!Settings.Instance.StartHidden && !Program.StartHidden) || Program.StartVisible) + if ((!Settings.Instance.StartHidden && !Program.StartHidden) || + Program.StartVisible) { this.Visible = true; } @@ -3343,145 +3483,110 @@ public HackerWindow() this.LoadOther(); this.LoadStructs(); + vistaMenu.DelaySetImageCalls = false; + vistaMenu.PerformPendingSetImageCalls(); + Program.ServiceProvider.Enabled = true; Program.ServiceProvider.Boost(); - ProcessHackerRestartRecovery.ApplicationRestartRecoveryManager.RegisterForRestart(); - //ProcessHackerRestartRecovery.ApplicationRestartRecoveryManager.RegisterForRecovery(); - - this.CreateShutdownMenuItems(); - this.LoadFixOSSpecific(); - this.LoadUac(); - this.LoadAddShortcuts(); - this.LoadFixNProcessHacker(); - - toolStrip.Items.Add(new ToolStripSeparator()); - var targetButton = new TargetWindowButton(); - targetButton.TargetWindowFound += (pid, tid) => this.SelectProcess(pid); - toolStrip.Items.Add(targetButton); - - var targetThreadButton = new TargetWindowButton(); - targetThreadButton.TargetWindowFound += (pid, tid) => Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], f => - { - Program.FocusWindow(f); - f.SelectThread(tid); - }); - targetThreadButton.Image = Properties.Resources.application_go; - targetThreadButton.Text = "Find window and select thread"; - targetThreadButton.ToolTipText = "Find window and select thread"; - toolStrip.Items.Add(targetThreadButton); - - try { TerminalServerHandle.RegisterNotificationsCurrent(this, true); } - catch (Exception ex) { Logging.Log(ex); } - try { this.UpdateSessions(); } - catch (Exception ex) { Logging.Log(ex); } - - try { Win32.SetProcessShutdownParameters(0x100, 0); } - catch { } - - if (Settings.Instance.AppUpdateAutomatic) - this.UpdateProgram(false); - - ToolStripManager.Renderer = new AeroRenderer(ToolbarTheme.Blue); + _dontCalculate = false; } private void HackerWindow_Load(object sender, EventArgs e) { - Program.UpdateWindowMenu(windowToolStripMenuItem, this); + Program.UpdateWindowMenu(windowMenuItem, this); this.ApplyFont(Settings.Instance.Font); this.BeginInvoke(new MethodInvoker(this.LoadApplyCommandLineArgs)); } + private void HackerWindow_SizeChanged(object sender, EventArgs e) + { + tabControl.Invalidate(false); + } + private void HackerWindow_VisibleChanged(object sender, EventArgs e) { treeProcesses.Draw = this.Visible; } - private void contextMenuStripService_Opening(object sender, System.ComponentModel.CancelEventArgs e) + // ==== Performance hacks section ==== + private bool _dontCalculate = true; + private int _layoutCount = 0; + + protected override void OnLayout(LayoutEventArgs levent) { - switch (this.listServices.SelectedItems.Count) + _layoutCount++; + + if (_layoutCount < 3) + return; + + base.OnLayout(levent); + } + + protected override void OnResize(EventArgs e) + { + if (_dontCalculate) + return; + + // + // Size grip bug fix as per + // http://jelle.druyts.net/2003/10/20/StatusBarResizeBug.aspx + // + if (statusBar != null) { - case 0: - this.goToProcessServiceMenuItem.Visible = true; - this.startToolStripMenuItem.Visible = true; - this.continueToolStripMenuItem.Visible = true; - this.pauseToolStripMenuItem.Visible = true; - this.stopToolStripMenuItem.Visible = true; - this.selectAllServiceMenuItem.Enabled = true; - break; - case 1: - this.goToProcessServiceMenuItem.Visible = true; - this.startToolStripMenuItem.Visible = true; - this.continueToolStripMenuItem.Visible = true; - this.pauseToolStripMenuItem.Visible = true; - this.stopToolStripMenuItem.Visible = true; - try - { - ServiceItem item = Program.ServiceProvider.Dictionary[this.listServices.SelectedItems[0].Name]; + statusBar.SizingGrip = (WindowState == FormWindowState.Normal); + } - if (item.Status.ServiceStatusProcess.ProcessID != 0) - { - this.goToProcessServiceMenuItem.Enabled = true; - } - else - { - this.goToProcessServiceMenuItem.Enabled = false; - } + base.OnResize(e); + } - if ((item.Status.ServiceStatusProcess.ControlsAccepted & ServiceAccept.PauseContinue) == 0) - { - this.continueToolStripMenuItem.Visible = false; - this.pauseToolStripMenuItem.Visible = false; - } - else - { - this.continueToolStripMenuItem.Visible = true; - this.pauseToolStripMenuItem.Visible = true; - } + private bool isFirstPaint = true; - switch (item.Status.ServiceStatusProcess.CurrentState) - { - case ServiceState.Paused: - this.startToolStripMenuItem.Enabled = false; - this.pauseToolStripMenuItem.Enabled = false; - break; - case ServiceState.Running: - this.startToolStripMenuItem.Enabled = false; - this.continueToolStripMenuItem.Enabled = false; - break; - case ServiceState.Stopped: - this.pauseToolStripMenuItem.Enabled = false; - this.stopToolStripMenuItem.Enabled = false; - break; - } + private void Painting() + { + if (isFirstPaint) + { + isFirstPaint = false; + + ProcessHackerRestartRecovery.ApplicationRestartRecoveryManager.RegisterForRestart(); + //ProcessHackerRestartRecovery.ApplicationRestartRecoveryManager.RegisterForRecovery(); - if ((item.Status.ServiceStatusProcess.ControlsAccepted & ServiceAccept.Stop) == 0 && - item.Status.ServiceStatusProcess.CurrentState == ServiceState.Running) - { - this.stopToolStripMenuItem.Enabled = false; - } - } - catch + this.CreateShutdownMenuItems(); + this.LoadFixOSSpecific(); + this.LoadUac(); + this.LoadAddShortcuts(); + this.LoadFixNProcessHacker(); + + toolStrip.Items.Add(new ToolStripSeparator()); + var targetButton = new TargetWindowButton(); + targetButton.TargetWindowFound += (pid, tid) => this.SelectProcess(pid); + toolStrip.Items.Add(targetButton); + + var targetThreadButton = new TargetWindowButton(); + targetThreadButton.TargetWindowFound += (pid, tid) => { - //contextMenuStripService.DisableAll(); - this.copyToolStripMenuItem1.Enabled = true; - this.propertiesToolStripMenuItem.Enabled = true; - } - break; - default: - this.goToProcessServiceMenuItem.Visible = false; - this.startToolStripMenuItem.Visible = false; - this.continueToolStripMenuItem.Visible = false; - this.pauseToolStripMenuItem.Visible = false; - this.stopToolStripMenuItem.Visible = false; - this.copyToolStripMenuItem1.Enabled = true; - this.propertiesToolStripMenuItem.Enabled = true; - this.selectAllServiceMenuItem.Enabled = true; - break; - } + Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], (f) => + { + Program.FocusWindow(f); + f.SelectThread(tid); + }); + }; + targetThreadButton.Image = Properties.Resources.application_go; + targetThreadButton.Text = "Find window and select thread"; + targetThreadButton.ToolTipText = "Find window and select thread"; + toolStrip.Items.Add(targetThreadButton); - if (listServices.List.Items.Count == 0) - selectAllServiceMenuItem.Enabled = false; + try { TerminalServerHandle.RegisterNotificationsCurrent(this, true); } + catch (Exception ex) { Logging.Log(ex); } + try { this.UpdateSessions(); } + catch (Exception ex) { Logging.Log(ex); } + + try { Win32.SetProcessShutdownParameters(0x100, 0); } + catch { } + + if (Settings.Instance.AppUpdateAutomatic) + this.UpdateProgram(false); + } } } } diff --git a/1.x/trunk/ProcessHacker/Forms/HackerWindow.resx b/1.x/trunk/ProcessHacker/Forms/HackerWindow.resx index 127dec02d..9f272f97e 100644 --- a/1.x/trunk/ProcessHacker/Forms/HackerWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/HackerWindow.resx @@ -112,36 +112,24 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 357, 17 - - - 742, 17 - - - 547, 17 - - - 143, 17 - - - 241, 17 - - + 17, 17 - - 929, 17 + + 141, 17 - - 69 + + 113 - + + 586, 17 + + AAABAA0AMDAQAAEABABoBgAA1gAAACAgEAABAAQA6AIAAD4HAAAYGBAAAQAEAOgBAAAmCgAAEBAQAAEA @@ -1771,4 +1759,16 @@ QeAArEH//6xB + + 249, 17 + + + 359, 17 + + + 480, 17 + + + 684, 17 + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.Designer.cs index 29627348a..476c399f1 100644 --- a/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class HandleFilterWindow { @@ -30,21 +28,24 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HandleFilterWindow)); this.label1 = new System.Windows.Forms.Label(); this.textFilter = new System.Windows.Forms.TextBox(); this.buttonFind = new System.Windows.Forms.Button(); - this.listHandles = new ProcessHacker.Components.ExtendedListView(); - this.columnProcess = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHandle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listHandles = new System.Windows.Forms.ListView(); + this.columnProcess = new System.Windows.Forms.ColumnHeader(); + this.columnType = new System.Windows.Forms.ColumnHeader(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnHandle = new System.Windows.Forms.ColumnHeader(); this.menuHandle = new System.Windows.Forms.ContextMenu(); this.closeMenuItem = new System.Windows.Forms.MenuItem(); this.processPropertiesMenuItem = new System.Windows.Forms.MenuItem(); this.propertiesMenuItem = new System.Windows.Forms.MenuItem(); this.copyMenuItem = new System.Windows.Forms.MenuItem(); this.progress = new System.Windows.Forms.ProgressBar(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // label1 @@ -52,21 +53,21 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 17); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(36, 13); + this.label1.Size = new System.Drawing.Size(32, 13); this.label1.TabIndex = 0; this.label1.Text = "Filter:"; // // textFilter // - this.textFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFilter.Location = new System.Drawing.Point(50, 14); this.textFilter.Name = "textFilter"; - this.textFilter.Size = new System.Drawing.Size(395, 22); + this.textFilter.Size = new System.Drawing.Size(395, 20); this.textFilter.TabIndex = 1; this.textFilter.TextChanged += new System.EventHandler(this.textFilter_TextChanged); - this.textFilter.Enter += new System.EventHandler(this.textFilter_Enter); this.textFilter.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textFilter_KeyPress); + this.textFilter.Enter += new System.EventHandler(this.textFilter_Enter); // // buttonFind // @@ -84,15 +85,14 @@ private void InitializeComponent() // listHandles // this.listHandles.AllowColumnReorder = true; - this.listHandles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listHandles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listHandles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnProcess, this.columnType, this.columnName, this.columnHandle}); - this.listHandles.DoubleClickChecks = true; this.listHandles.FullRowSelect = true; this.listHandles.HideSelection = false; this.listHandles.Location = new System.Drawing.Point(12, 41); @@ -136,6 +136,7 @@ private void InitializeComponent() // // closeMenuItem // + this.vistaMenu.SetImage(this.closeMenuItem, global::ProcessHacker.Properties.Resources.cross); this.closeMenuItem.Index = 0; this.closeMenuItem.Text = "Close"; this.closeMenuItem.Click += new System.EventHandler(this.closeMenuItem_Click); @@ -154,25 +155,30 @@ private void InitializeComponent() // // copyMenuItem // + this.vistaMenu.SetImage(this.copyMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyMenuItem.Index = 3; this.copyMenuItem.Text = "&Copy"; // // progress // - this.progress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.progress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.progress.Location = new System.Drawing.Point(50, 11); this.progress.Name = "progress"; this.progress.Size = new System.Drawing.Size(395, 23); this.progress.TabIndex = 4; this.progress.Visible = false; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // HandleFilterWindow // this.AcceptButton = this.buttonFind; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(538, 427); this.Controls.Add(this.progress); this.Controls.Add(this.listHandles); @@ -183,9 +189,10 @@ private void InitializeComponent() this.Name = "HandleFilterWindow"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Find Handles or DLLs"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HandleFilterWindow_FormClosing); this.Load += new System.EventHandler(this.HandleFilterWindow_Load); this.VisibleChanged += new System.EventHandler(this.HandleFilterWindow_VisibleChanged); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HandleFilterWindow_FormClosing); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -196,13 +203,14 @@ private void InitializeComponent() private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textFilter; private System.Windows.Forms.Button buttonFind; - private ExtendedListView listHandles; + private System.Windows.Forms.ListView listHandles; private System.Windows.Forms.ColumnHeader columnProcess; private System.Windows.Forms.ColumnHeader columnType; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnHandle; private System.Windows.Forms.ContextMenu menuHandle; private System.Windows.Forms.MenuItem closeMenuItem; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.MenuItem copyMenuItem; private System.Windows.Forms.ProgressBar progress; private System.Windows.Forms.MenuItem propertiesMenuItem; diff --git a/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.cs b/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.cs index b2be8bf99..7f108d7a7 100644 --- a/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.cs @@ -44,10 +44,11 @@ public partial class HandleFilterWindow : Form public HandleFilterWindow() { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); + listHandles.SetDoubleBuffered(true); + listHandles.SetTheme("explorer"); GenericViewMenu.AddMenuItems(copyMenuItem.MenuItems, listHandles, null); listHandles.ContextMenu = menuHandle; @@ -94,6 +95,7 @@ private void HandleFilterWindow_VisibleChanged(object sender, EventArgs e) { if (this.Visible) { + this.SetPhParent(); textFilter.SelectAll(); } } @@ -102,7 +104,7 @@ private void menuHandle_Popup(object sender, EventArgs e) { if (listHandles.SelectedItems.Count == 0) { - // menuHandle.DisableAll(); + menuHandle.DisableAll(); } else if (listHandles.SelectedItems.Count == 1) { @@ -322,7 +324,7 @@ private void listHandles_KeyDown(object sender, KeyEventArgs e) private void textFilter_TextChanged(object sender, EventArgs e) { - if (textFilter.Text == string.Empty) + if (textFilter.Text == "") buttonFind.Enabled = false; else buttonFind.Enabled = true; diff --git a/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.resx b/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.resx index e2f9da947..f917f4d06 100644 --- a/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/HandleFilterWindow.resx @@ -112,15 +112,18 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - + + 138, 17 + + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA diff --git a/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.Designer.cs index 565980585..1272243fe 100644 --- a/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class HandleStatisticsWindow { @@ -31,9 +29,9 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.buttonClose = new System.Windows.Forms.Button(); - this.listTypes = new ProcessHacker.Components.ExtendedListView(); - this.columnType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnNumber = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listTypes = new System.Windows.Forms.ListView(); + this.columnType = new System.Windows.Forms.ColumnHeader(); + this.columnNumber = new System.Windows.Forms.ColumnHeader(); this.SuspendLayout(); // // buttonClose @@ -50,13 +48,12 @@ private void InitializeComponent() // // listTypes // - this.listTypes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listTypes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listTypes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnType, this.columnNumber}); - this.listTypes.DoubleClickChecks = true; this.listTypes.FullRowSelect = true; this.listTypes.HideSelection = false; this.listTypes.Location = new System.Drawing.Point(12, 12); @@ -82,7 +79,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(351, 303); this.Controls.Add(this.listTypes); this.Controls.Add(this.buttonClose); @@ -101,7 +97,7 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Button buttonClose; - private ExtendedListView listTypes; + private System.Windows.Forms.ListView listTypes; private System.Windows.Forms.ColumnHeader columnType; private System.Windows.Forms.ColumnHeader columnNumber; } diff --git a/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.cs b/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.cs index 34527dc7c..8431841c0 100644 --- a/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.cs @@ -12,13 +12,18 @@ namespace ProcessHacker { public partial class HandleStatisticsWindow : Form { + private int _pid; + public HandleStatisticsWindow(int pid) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); + _pid = pid; + + listTypes.SetDoubleBuffered(true); + listTypes.SetTheme("explorer"); listTypes.AddShortcuts(); listTypes.ContextMenu = listTypes.GetCopyMenu(); listTypes.ListViewItemSorter = new SortedListViewComparer(listTypes); diff --git a/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.resx b/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/HandleStatisticsWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/HeapsWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/HeapsWindow.Designer.cs index 0285815ca..01a3f1238 100644 --- a/1.x/trunk/ProcessHacker/Forms/HeapsWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/HeapsWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class HeapsWindow { @@ -30,16 +28,19 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.buttonClose = new System.Windows.Forms.Button(); - this.listHeaps = new ProcessHacker.Components.ExtendedListView(); - this.columnAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnUsed = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnCommitted = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnEntries = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listHeaps = new System.Windows.Forms.ListView(); + this.columnAddress = new System.Windows.Forms.ColumnHeader(); + this.columnUsed = new System.Windows.Forms.ColumnHeader(); + this.columnCommitted = new System.Windows.Forms.ColumnHeader(); + this.columnEntries = new System.Windows.Forms.ColumnHeader(); this.menuHeap = new System.Windows.Forms.ContextMenu(); this.destroyMenuItem = new System.Windows.Forms.MenuItem(); this.copyMenuItem = new System.Windows.Forms.MenuItem(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.checkSizesInBytes = new System.Windows.Forms.CheckBox(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // buttonClose @@ -56,15 +57,14 @@ private void InitializeComponent() // // listHeaps // - this.listHeaps.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listHeaps.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listHeaps.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnAddress, this.columnUsed, this.columnCommitted, this.columnEntries}); - this.listHeaps.DoubleClickChecks = true; this.listHeaps.FullRowSelect = true; this.listHeaps.HideSelection = false; this.listHeaps.Location = new System.Drawing.Point(12, 12); @@ -102,15 +102,22 @@ private void InitializeComponent() // // destroyMenuItem // + this.vistaMenu.SetImage(this.destroyMenuItem, global::ProcessHacker.Properties.Resources.cross); this.destroyMenuItem.Index = 0; this.destroyMenuItem.Text = "&Destroy"; this.destroyMenuItem.Click += new System.EventHandler(this.destroyMenuItem_Click); // // copyMenuItem // + this.vistaMenu.SetImage(this.copyMenuItem, global::ProcessHacker.Properties.Resources.page_copy); this.copyMenuItem.Index = 1; this.copyMenuItem.Text = "&Copy"; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // checkSizesInBytes // this.checkSizesInBytes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -120,7 +127,7 @@ private void InitializeComponent() this.checkSizesInBytes.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkSizesInBytes.Location = new System.Drawing.Point(12, 423); this.checkSizesInBytes.Name = "checkSizesInBytes"; - this.checkSizesInBytes.Size = new System.Drawing.Size(100, 18); + this.checkSizesInBytes.Size = new System.Drawing.Size(96, 18); this.checkSizesInBytes.TabIndex = 1; this.checkSizesInBytes.Text = "Sizes in bytes"; this.checkSizesInBytes.UseVisualStyleBackColor = true; @@ -131,7 +138,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonClose; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(503, 454); this.Controls.Add(this.checkSizesInBytes); this.Controls.Add(this.listHeaps); @@ -144,6 +150,7 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Process Heaps"; + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -152,13 +159,14 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Button buttonClose; - private ExtendedListView listHeaps; + private System.Windows.Forms.ListView listHeaps; private System.Windows.Forms.ColumnHeader columnAddress; private System.Windows.Forms.ColumnHeader columnUsed; private System.Windows.Forms.ColumnHeader columnCommitted; private System.Windows.Forms.ColumnHeader columnEntries; private System.Windows.Forms.ContextMenu menuHeap; private System.Windows.Forms.MenuItem destroyMenuItem; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.MenuItem copyMenuItem; private System.Windows.Forms.CheckBox checkSizesInBytes; } diff --git a/1.x/trunk/ProcessHacker/Forms/HeapsWindow.cs b/1.x/trunk/ProcessHacker/Forms/HeapsWindow.cs index 96797edbb..e3f0b3025 100644 --- a/1.x/trunk/ProcessHacker/Forms/HeapsWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/HeapsWindow.cs @@ -36,7 +36,7 @@ namespace ProcessHacker { public partial class HeapsWindow : Form { - private readonly int _pid; + private int _pid; public HeapsWindow(int pid, HeapInformation[] heaps) { @@ -44,6 +44,8 @@ public HeapsWindow(int pid, HeapInformation[] heaps) this.AddEscapeToClose(); this.SetTopMost(); + listHeaps.SetDoubleBuffered(true); + listHeaps.SetTheme("explorer"); listHeaps.AddShortcuts(); listHeaps.ContextMenu = menuHeap; GenericViewMenu.AddMenuItems(copyMenuItem.MenuItems, listHeaps, null); @@ -135,18 +137,21 @@ private void buttonClose_Click(object sender, EventArgs e) private void menuHeap_Popup(object sender, EventArgs e) { - switch (this.listHeaps.SelectedItems.Count) + if (listHeaps.SelectedItems.Count == 0) { - case 0: - break; - case 1: - this.menuHeap.EnableAll(); - if (this.listHeaps.SelectedItems[0].Text == "Totals") - this.destroyMenuItem.Enabled = false; - break; - default: - this.copyMenuItem.Enabled = true; - break; + menuHeap.DisableAll(); + } + else if (listHeaps.SelectedItems.Count == 1) + { + menuHeap.EnableAll(); + + if (listHeaps.SelectedItems[0].Text == "Totals") + destroyMenuItem.Enabled = false; + } + else + { + menuHeap.DisableAll(); + copyMenuItem.Enabled = true; } } diff --git a/1.x/trunk/ProcessHacker/Forms/HeapsWindow.resx b/1.x/trunk/ProcessHacker/Forms/HeapsWindow.resx index 8979fb40e..aae741422 100644 --- a/1.x/trunk/ProcessHacker/Forms/HeapsWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/HeapsWindow.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 + + 128, 17 + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/HelpWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/HelpWindow.Designer.cs index 1414f2ecc..a7872fa97 100644 --- a/1.x/trunk/ProcessHacker/Forms/HelpWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/HelpWindow.Designer.cs @@ -37,26 +37,26 @@ private void InitializeComponent() // this.webBrowser.AllowNavigation = false; this.webBrowser.AllowWebBrowserDrop = false; - this.webBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.webBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.webBrowser.IsWebBrowserContextMenuEnabled = false; this.webBrowser.Location = new System.Drawing.Point(201, 12); this.webBrowser.MinimumSize = new System.Drawing.Size(20, 20); this.webBrowser.Name = "webBrowser"; - this.webBrowser.Size = new System.Drawing.Size(535, 404); + this.webBrowser.Size = new System.Drawing.Size(535, 490); this.webBrowser.TabIndex = 0; this.webBrowser.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.webBrowser_PreviewKeyDown); // // listBoxContents // - this.listBoxContents.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); + this.listBoxContents.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); this.listBoxContents.FormattingEnabled = true; this.listBoxContents.IntegralHeight = false; this.listBoxContents.Location = new System.Drawing.Point(12, 12); this.listBoxContents.Name = "listBoxContents"; - this.listBoxContents.Size = new System.Drawing.Size(183, 404); + this.listBoxContents.Size = new System.Drawing.Size(183, 490); this.listBoxContents.TabIndex = 1; this.listBoxContents.SelectedIndexChanged += new System.EventHandler(this.listBoxContents_SelectedIndexChanged); // @@ -64,8 +64,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(748, 428); + this.ClientSize = new System.Drawing.Size(748, 514); this.Controls.Add(this.listBoxContents); this.Controls.Add(this.webBrowser); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); diff --git a/1.x/trunk/ProcessHacker/Forms/HelpWindow.resx b/1.x/trunk/ProcessHacker/Forms/HelpWindow.resx index 816fcb8b7..a9216861a 100644 --- a/1.x/trunk/ProcessHacker/Forms/HelpWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/HelpWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA diff --git a/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.Designer.cs index 7f66d5c89..73655bf0d 100644 --- a/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.Designer.cs @@ -29,9 +29,9 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HiddenProcessesWindow)); - this.listProcesses = new ProcessHacker.Components.ExtendedListView(); - this.columnProcess = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnPID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listProcesses = new System.Windows.Forms.ListView(); + this.columnProcess = new System.Windows.Forms.ColumnHeader(); + this.columnPID = new System.Windows.Forms.ColumnHeader(); this.buttonClose = new System.Windows.Forms.Button(); this.buttonScan = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); @@ -43,13 +43,12 @@ private void InitializeComponent() // // listProcesses // - this.listProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listProcesses.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnProcess, this.columnPID}); - this.listProcesses.DoubleClickChecks = true; this.listProcesses.FullRowSelect = true; this.listProcesses.HideSelection = false; this.listProcesses.Location = new System.Drawing.Point(12, 44); @@ -97,15 +96,15 @@ private void InitializeComponent() // // label2 // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.label2.AutoEllipsis = true; this.label2.Location = new System.Drawing.Point(12, 9); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(487, 32); this.label2.TabIndex = 0; this.label2.Text = "Processes highlighted red are hidden while those highlighted gray have terminated" + - " but are still being referenced by other processes."; + " but are still being referenced by other processes."; // // buttonTerminate // @@ -134,8 +133,8 @@ private void InitializeComponent() // // labelCount // - this.labelCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelCount.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelCount.Location = new System.Drawing.Point(12, 343); this.labelCount.Name = "labelCount"; this.labelCount.Size = new System.Drawing.Size(487, 15); @@ -161,7 +160,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(511, 396); this.Controls.Add(this.comboMethod); this.Controls.Add(this.labelCount); @@ -175,15 +173,15 @@ private void InitializeComponent() this.KeyPreview = true; this.Name = "HiddenProcessesWindow"; this.Text = "Hidden Processes"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HiddenProcessesWindow_FormClosing); this.Load += new System.EventHandler(this.HiddenProcessesWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HiddenProcessesWindow_FormClosing); this.ResumeLayout(false); } #endregion - private ProcessHacker.Components.ExtendedListView listProcesses; + private System.Windows.Forms.ListView listProcesses; private System.Windows.Forms.ColumnHeader columnProcess; private System.Windows.Forms.ColumnHeader columnPID; private System.Windows.Forms.Button buttonClose; diff --git a/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.cs b/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.cs index 1109ea605..ad1e1417f 100644 --- a/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.cs @@ -39,17 +39,19 @@ public partial class HiddenProcessesWindow : Form { public HiddenProcessesWindow() { + this.SetPhParent(); InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); listProcesses.ListViewItemSorter = new SortedListViewComparer(listProcesses); listProcesses.ContextMenu = listProcesses.GetCopyMenu(); listProcesses.AddShortcuts(); + listProcesses.SetDoubleBuffered(true); + listProcesses.SetTheme("explorer"); comboMethod.SelectedItem = "CSR Handles"; - labelCount.Text = string.Empty; + labelCount.Text = ""; } private void HiddenProcessesWindow_Load(object sender, EventArgs e) @@ -80,19 +82,19 @@ private void AddProcessItem( Func exists ) { - string fileName = phandle.ImageFileName; + string fileName = phandle.GetImageFileName(); - if (!string.IsNullOrEmpty(fileName)) + if (fileName != null) fileName = FileUtils.GetFileName(fileName); if (pid == 0) pid = phandle.GetBasicInformation().UniqueProcessId.ToInt32(); - ListViewItem item = listProcesses.Items.Add(new ListViewItem(new string[] - { - fileName, - pid.ToString() - })); + var item = listProcesses.Items.Add(new ListViewItem(new string[] + { + fileName, + pid.ToString() + })); // Check if the process has terminated. This is possible because // a process can be terminated while its object is still being @@ -131,10 +133,10 @@ private void AddErrorItem( return; var item = listProcesses.Items.Add(new ListViewItem(new string[] - { - "(" + ex.Message + ")", - pid.ToString() - })); + { + "(" + ex.Message + ")", + pid.ToString() + })); item.BackColor = Color.Red; item.ForeColor = Color.White; @@ -161,7 +163,7 @@ private void ScanBruteForce() phandle, pid, ref totalCount, ref hiddenCount, ref terminatedCount, - processes.ContainsKey + (pid_) => processes.ContainsKey(pid_) ); } catch (WindowsException ex) @@ -202,77 +204,84 @@ private void ScanCsrHandles() var csrProcesses = this.GetCsrProcesses(); // Duplicate each process handle and check if they exist in the normal list. - foreach (ProcessHandle csrhandle in csrProcesses) + foreach (var csrhandle in csrProcesses) { try { - //var handles = csrhandle.GetHandles(); - - //foreach (ProcessHandleInformation handle in handles) - //{ - // int pid = 0; - // bool isThread = false; - - // try - // { - // pid = 0;//pid = KProcessHacker.Instance.KphGetProcessId(csrhandle, handle.Handle); - - // // HACK: Using exception for program flow! - // if (pid == 0) - // throw new Exception(); - // } - // catch - // { - // // Probably not a process handle. - // // Try opening it as a thread. - // try - // { - // int tid =0;// KProcessHacker.Instance.KphGetThreadId(csrhandle, handle.Handle, out pid); - // isThread = true; - - // if (tid == 0) - // throw new Exception(); - // } - // catch - // { - // continue; - // } - // } - - // // Avoid duplicate PIDs. - // if (foundPids.Contains(pid)) - // continue; - - // foundPids.Add(pid); - - // try - // { - // ProcessHandle phandle; - - // if (!isThread) - // { - // var dupHandle = new NativeHandle(csrhandle, handle.Handle, Program.MinProcessQueryRights); - // phandle = ProcessHandle.FromHandle(dupHandle); - // } - // else - // { - // using (var dupHandle = new NativeHandle(csrhandle, handle.Handle, Program.MinThreadQueryRights)) - // phandle = ThreadHandle.FromHandle(dupHandle).GetProcess(Program.MinProcessQueryRights); - // } - - // AddProcessItem( - // phandle, - // pid, - // ref totalCount, ref hiddenCount, ref terminatedCount, - // processes.ContainsKey - // ); - // phandle.Dispose(); - // } - // catch (WindowsException ex2) - // { - // AddErrorItem(ex2, pid, ref totalCount, ref hiddenCount, ref terminatedCount); - // } - //} + var handles = csrhandle.GetHandles(); + + foreach (var handle in handles) + { + int pid = 0; + bool isThread = false; + + try + { + pid = KProcessHacker.Instance.KphGetProcessId(csrhandle, handle.Handle); + + // HACK: Using exception for program flow! + if (pid == 0) + throw new Exception(); + } + catch + { + // Probably not a process handle. + // Try opening it as a thread. + try + { + int tid = KProcessHacker.Instance.KphGetThreadId(csrhandle, handle.Handle, out pid); + isThread = true; + + if (tid == 0) + throw new Exception(); + } + catch + { + continue; + } + } + + // Avoid duplicate PIDs. + if (foundPids.Contains(pid)) + continue; + + foundPids.Add(pid); + + try + { + ProcessHandle phandle; + + if (!isThread) + { + var dupHandle = + new NativeHandle(csrhandle, + handle.Handle, + Program.MinProcessQueryRights); + phandle = ProcessHandle.FromHandle(dupHandle); + } + else + { + using (var dupHandle = + new NativeHandle(csrhandle, + handle.Handle, + Program.MinThreadQueryRights)) + phandle = ThreadHandle.FromHandle(dupHandle). + GetProcess(Program.MinProcessQueryRights); + } + + AddProcessItem( + phandle, + pid, + ref totalCount, ref hiddenCount, ref terminatedCount, + (pid_) => processes.ContainsKey(pid_) + ); + phandle.Dispose(); + } + catch (WindowsException ex2) + { + AddErrorItem(ex2, pid, ref totalCount, ref hiddenCount, ref terminatedCount); + } + } } catch (WindowsException ex) { @@ -298,24 +307,24 @@ private void ScanCsrHandles() } } - private ProcessHandle[] GetCsrProcesses() + private List GetCsrProcesses() { List csrProcesses = new List(); try { - foreach (KeyValuePair process in Windows.GetProcesses()) + foreach (var process in Windows.GetProcesses()) { if (process.Key <= 4) continue; try { - ProcessHandle phandle = new ProcessHandle(process.Key, + var phandle = new ProcessHandle(process.Key, Program.MinProcessQueryRights | ProcessAccess.DupHandle ); - if (phandle.KnownProcessType == KnownProcess.WindowsSubsystem) + if (phandle.GetKnownProcessType() == KnownProcess.WindowsSubsystem) csrProcesses.Add(phandle); else phandle.Dispose(); @@ -327,9 +336,10 @@ private ProcessHandle[] GetCsrProcesses() catch (Exception ex) { PhUtils.ShowException("Unable to get the list of CSR processes", ex); + return new List(); } - return csrProcesses.ToArray(); + return csrProcesses; } private ProcessHandle OpenProcessCsr(int pid, ProcessAccess access) @@ -338,43 +348,43 @@ private ProcessHandle OpenProcessCsr(int pid, ProcessAccess access) foreach (var csrProcess in csrProcesses) { - // foreach (var handle in csrProcess.GetHandles()) - // { - // try - // { - // // Assume that the handle is a process handle. - // int handlePid = 0;// KProcessHacker.Instance.KphGetProcessId(csrProcess, handle.Handle); - - // if (handlePid == pid) - // return ProcessHandle.FromHandle( - // new NativeHandle(csrProcess, handle.Handle, access) - // ); - // else if (handlePid == 0) - // throw new Exception(); // HACK - // } - // catch - // { - // try - // { - // // Assume that the handle is a thread handle. - // int handlePid = 0; - - // int tid = 0;// KProcessHacker.Instance.KphGetThreadId(csrProcess, handle.Handle, out handlePid); - - // if (tid == 0) - // throw new Exception(); - - // if (handlePid == pid) - // { - // using (var dupHandle = - // new NativeHandle(csrProcess, handle.Handle, Program.MinThreadQueryRights)) - // return ThreadHandle.FromHandle(dupHandle).GetProcess(access); - // } - // } - // catch - // { } - // } - // } + foreach (var handle in csrProcess.GetHandles()) + { + try + { + // Assume that the handle is a process handle. + int handlePid = KProcessHacker.Instance.KphGetProcessId(csrProcess, handle.Handle); + + if (handlePid == pid) + return ProcessHandle.FromHandle( + new NativeHandle(csrProcess, handle.Handle, access) + ); + else if (handlePid == 0) + throw new Exception(); // HACK + } + catch + { + try + { + // Assume that the handle is a thread handle. + int handlePid; + + int tid = KProcessHacker.Instance.KphGetThreadId(csrProcess, handle.Handle, out handlePid); + + if (tid == 0) + throw new Exception(); + + if (handlePid == pid) + { + using (var dupHandle = + new NativeHandle(csrProcess, handle.Handle, Program.MinThreadQueryRights)) + return ThreadHandle.FromHandle(dupHandle).GetProcess(access); + } + } + catch + { } + } + } csrProcess.Dispose(); } @@ -465,35 +475,34 @@ private void listProcesses_SelectedIndexChanged(object sender, EventArgs e) private void buttonSave_Click(object sender, EventArgs e) { - using (SaveFileDialog sfd = new SaveFileDialog()) - { - sfd.FileName = "Process Scan.txt"; - sfd.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; - sfd.OverwritePrompt = true; + SaveFileDialog sfd = new SaveFileDialog(); + + sfd.FileName = "Process Scan.txt"; + sfd.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; + sfd.OverwritePrompt = true; - if (sfd.ShowDialog() == DialogResult.OK) + if (sfd.ShowDialog() == DialogResult.OK) + { + try { - try + using (var sw = new StreamWriter(sfd.FileName)) { - using (var sw = new StreamWriter(sfd.FileName)) - { - sw.WriteLine("Process Hacker Hidden Processes Scan"); - sw.WriteLine("Method: " + comboMethod.SelectedItem.ToString()); - sw.WriteLine(); + sw.WriteLine("Process Hacker Hidden Processes Scan"); + sw.WriteLine("Method: " + comboMethod.SelectedItem.ToString()); + sw.WriteLine(); - foreach (ListViewItem item in listProcesses.Items) - { - sw.WriteLine( - (item.BackColor == Color.Red ? "[HIDDEN] " : "") + - (item.BackColor == Color.DarkGray ? "[Terminated] " : "") + - item.SubItems[1].Text + ": " + item.SubItems[0].Text); - } + foreach (ListViewItem item in listProcesses.Items) + { + sw.WriteLine( + (item.BackColor == Color.Red ? "[HIDDEN] " : "") + + (item.BackColor == Color.DarkGray ? "[Terminated] " : "") + + item.SubItems[1].Text + ": " + item.SubItems[0].Text); } } - catch (Exception ex) - { - PhUtils.ShowException("Unable to save the scan results", ex); - } + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to save the scan results", ex); } } } diff --git a/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.resx b/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.resx index 1e4b7cfa9..912b30118 100644 --- a/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/HiddenProcessesWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + AAABAA0AMDAQAAEABABoBgAA1gAAACAgEAABAAQA6AIAAD4HAAAYGBAAAQAEAOgBAAAmCgAAEBAQAAEA diff --git a/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.Designer.cs index 3e3b50b28..c712a064e 100644 --- a/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class IPInfoWindow { @@ -32,7 +30,7 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IPInfoWindow)); this.buttonClose = new System.Windows.Forms.Button(); - this.listInfo = new ProcessHacker.Components.ExtendedListView(); + this.listInfo = new System.Windows.Forms.ListView(); this.labelInfo = new System.Windows.Forms.Label(); this.labelStatus = new System.Windows.Forms.Label(); this.SuspendLayout(); @@ -51,10 +49,9 @@ private void InitializeComponent() // // listInfo // - this.listInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listInfo.DoubleClickChecks = true; + this.listInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listInfo.FullRowSelect = true; this.listInfo.Location = new System.Drawing.Point(12, 31); this.listInfo.Name = "listInfo"; @@ -69,7 +66,7 @@ private void InitializeComponent() this.labelInfo.AutoSize = true; this.labelInfo.Location = new System.Drawing.Point(12, 9); this.labelInfo.Name = "labelInfo"; - this.labelInfo.Size = new System.Drawing.Size(38, 13); + this.labelInfo.Size = new System.Drawing.Size(35, 13); this.labelInfo.TabIndex = 3; this.labelInfo.Text = "label1"; // @@ -79,7 +76,7 @@ private void InitializeComponent() this.labelStatus.AutoSize = true; this.labelStatus.Location = new System.Drawing.Point(12, 334); this.labelStatus.Name = "labelStatus"; - this.labelStatus.Size = new System.Drawing.Size(61, 13); + this.labelStatus.Size = new System.Drawing.Size(56, 13); this.labelStatus.TabIndex = 4; this.labelStatus.Text = "Working..."; // @@ -87,7 +84,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(463, 364); this.Controls.Add(this.listInfo); this.Controls.Add(this.labelStatus); @@ -101,8 +97,8 @@ private void InitializeComponent() this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "IP information"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.IPInfoWindow_FormClosing); this.Load += new System.EventHandler(this.IPInfoWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.IPInfoWindow_FormClosing); this.ResumeLayout(false); this.PerformLayout(); @@ -111,7 +107,7 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Button buttonClose; - private ExtendedListView listInfo; + private System.Windows.Forms.ListView listInfo; private System.Windows.Forms.Label labelInfo; private System.Windows.Forms.Label labelStatus; } diff --git a/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.cs b/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.cs index a3a0cb17c..ccb9df110 100644 --- a/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.cs @@ -42,8 +42,8 @@ public enum IpAction : int public partial class IPInfoWindow : Form { - private readonly IPAddress _ipAddress; - private readonly IpAction _ipAction; + private IPAddress _ipAddress; + private IpAction _ipAction; public IPInfoWindow(IPAddress ipAddress, IpAction action) { @@ -56,36 +56,38 @@ public IPInfoWindow(IPAddress ipAddress, IpAction action) listInfo.AddShortcuts(); listInfo.ContextMenu = listInfo.GetCopyMenu(); + listInfo.SetTheme("explorer"); + listInfo.SetDoubleBuffered(true); } private void IPInfoWindow_Load(object sender, EventArgs e) { Thread t = null; - switch (this._ipAction) + if (_ipAction == IpAction.Whois) { - case IpAction.Whois: - t = new Thread(this.Whois, Utils.SixteenthStackSize); - this.labelInfo.Text = "Whois host infomation for address: " + this._ipAddress.ToString(); - this.labelStatus.Text = "Checking..."; - this.listInfo.Columns.Add("Results"); - ColumnSettings.LoadSettings(Settings.Instance.IPInfoWhoIsListViewColumns, this.listInfo); - break; - case IpAction.Tracert: - t = new Thread(this.Tracert, Utils.SixteenthStackSize); - this.labelStatus.Text = "Tracing route..."; - this.listInfo.Columns.Add("Count"); - this.listInfo.Columns.Add("Reply Time"); - this.listInfo.Columns.Add("IP Address"); - this.listInfo.Columns.Add("Hostname"); - ColumnSettings.LoadSettings(Settings.Instance.IPInfoTracertListViewColumns, this.listInfo); - break; - case IpAction.Ping: - t = new Thread(this.Ping, Utils.SixteenthStackSize); - this.labelStatus.Text = "Pinging..."; - this.listInfo.Columns.Add("Results"); - ColumnSettings.LoadSettings(Settings.Instance.IPInfoPingListViewColumns, this.listInfo); - break; + t = new Thread(new ParameterizedThreadStart(Whois), Utils.SixteenthStackSize); + labelInfo.Text = "Whois host infomation for address: " + _ipAddress.ToString(); + labelStatus.Text = "Checking..."; + listInfo.Columns.Add("Results"); + ColumnSettings.LoadSettings(Settings.Instance.IPInfoWhoIsListViewColumns, listInfo); + } + else if (_ipAction == IpAction.Tracert) + { + t = new Thread(new ParameterizedThreadStart(Tracert), Utils.SixteenthStackSize); + labelStatus.Text = "Tracing route..."; + listInfo.Columns.Add("Count"); + listInfo.Columns.Add("Reply Time"); + listInfo.Columns.Add("IP Address"); + listInfo.Columns.Add("Hostname"); + ColumnSettings.LoadSettings(Settings.Instance.IPInfoTracertListViewColumns, listInfo); + } + else if (_ipAction == IpAction.Ping) + { + t = new Thread(new ParameterizedThreadStart(Ping), Utils.SixteenthStackSize); + labelStatus.Text = "Pinging..."; + listInfo.Columns.Add("Results"); + ColumnSettings.LoadSettings(Settings.Instance.IPInfoPingListViewColumns, listInfo); } t.IsBackground = true; @@ -94,18 +96,12 @@ private void IPInfoWindow_Load(object sender, EventArgs e) private void IPInfoWindow_FormClosing(object sender, FormClosingEventArgs e) { - switch (this._ipAction) - { - case IpAction.Whois: - Settings.Instance.IPInfoWhoIsListViewColumns = ColumnSettings.SaveSettings(this.listInfo); - break; - case IpAction.Tracert: - Settings.Instance.IPInfoTracertListViewColumns = ColumnSettings.SaveSettings(this.listInfo); - break; - case IpAction.Ping: - Settings.Instance.IPInfoPingListViewColumns = ColumnSettings.SaveSettings(this.listInfo); - break; - } + if (_ipAction == IpAction.Whois) + Settings.Instance.IPInfoWhoIsListViewColumns = ColumnSettings.SaveSettings(listInfo); + else if (_ipAction == IpAction.Tracert) + Settings.Instance.IPInfoTracertListViewColumns = ColumnSettings.SaveSettings(listInfo); + else if (_ipAction == IpAction.Ping) + Settings.Instance.IPInfoPingListViewColumns = ColumnSettings.SaveSettings(listInfo); Settings.Instance.Save(); } @@ -120,6 +116,7 @@ private void Ping(object ip) using (Ping pingSender = new Ping()) { PingOptions pingOptions = new PingOptions(); + PingReply pingReply = null; IPAddress ipAddress = (IPAddress)ip; int numberOfPings = 4; @@ -141,7 +138,6 @@ private void Ping(object ip) { sentPings++; - PingReply pingReply; try { pingReply = pingSender.Send(ipAddress, pingTimeout, buffer, pingOptions); @@ -152,47 +148,44 @@ private void Ping(object ip) break; } - if (pingReply != null) + if (pingReply.Status == IPStatus.Success) { - if (pingReply.Status == IPStatus.Success) + if (pingReply.Options != null) //IPv6 ping causes pingReply.Options to become null { - if (pingReply.Options != null) //IPv6 ping causes pingReply.Options to become null - { - WriteResult(string.Format("Reply from {0}: bytes={1} time={2}ms TTL={3}", ipAddress, byteSize, pingReply.RoundtripTime, pingReply.Options.Ttl), string.Empty, string.Empty); - } - else - { - WriteResult(string.Format("Reply from {0}: bytes={1} time={2}ms TTL={3}", ipAddress, byteSize, pingReply.RoundtripTime, pingOptions.Ttl), string.Empty, string.Empty); - } - - if (minPingResponse == 0) - { - minPingResponse = pingReply.RoundtripTime; - maxPingResponse = minPingResponse; - } - else if (pingReply.RoundtripTime < minPingResponse) - { - minPingResponse = pingReply.RoundtripTime; - } - else if (pingReply.RoundtripTime > maxPingResponse) - { - maxPingResponse = pingReply.RoundtripTime; - } - - receivedPings++; + WriteResult(string.Format("Reply from {0}: bytes={1} time={2}ms TTL={3}", ipAddress, byteSize, pingReply.RoundtripTime, pingReply.Options.Ttl), "", ""); } else { - WriteResult(pingReply.Status.ToString(), string.Empty, string.Empty); - lostPings++; + WriteResult(string.Format("Reply from {0}: bytes={1} time={2}ms TTL={3}", ipAddress, byteSize, pingReply.RoundtripTime, pingOptions.Ttl), "", ""); } + + if (minPingResponse == 0) + { + minPingResponse = pingReply.RoundtripTime; + maxPingResponse = minPingResponse; + } + else if (pingReply.RoundtripTime < minPingResponse) + { + minPingResponse = pingReply.RoundtripTime; + } + else if (pingReply.RoundtripTime > maxPingResponse) + { + maxPingResponse = pingReply.RoundtripTime; + } + + receivedPings++; + } + else + { + WriteResult(pingReply.Status.ToString(), "", ""); + lostPings++; } } - WriteResult(string.Empty, string.Empty, string.Empty); - WriteResult(string.Format("Ping statistics for {0}:", ipAddress), string.Empty, string.Empty); - WriteResult(string.Format(" Packets: Sent = {0}, Received = {1}, Lost = {2}", sentPings, receivedPings, lostPings), string.Empty, string.Empty); - WriteResult("Approximate round trip times in milli-seconds:", string.Empty, string.Empty); - WriteResult(string.Format(" Minimum = {0}ms, Maximum = {1}ms", minPingResponse, maxPingResponse), string.Empty, string.Empty); + WriteResult("", "", ""); + WriteResult(string.Format("Ping statistics for {0}:", ipAddress), "", ""); + WriteResult(string.Format(" Packets: Sent = {0}, Received = {1}, Lost = {2}", sentPings, receivedPings, lostPings), "", ""); + WriteResult("Approximate round trip times in milli-seconds:", "", ""); + WriteResult(string.Format(" Minimum = {0}ms, Maximum = {1}ms", minPingResponse, maxPingResponse), "", ""); } WriteStatus("Ping complete.", false); } @@ -205,6 +198,7 @@ private void Tracert(object ip) { PingOptions pingOptions = new PingOptions(); Stopwatch stopWatch = new Stopwatch(); + byte[] bytes = new byte[32]; pingOptions.DontFragment = true; pingOptions.Ttl = 1; @@ -236,33 +230,33 @@ private void Tracert(object ip) WriteResult(string.Format("{0}" , i), string.Format("{0} ms", stopWatch.ElapsedMilliseconds), string.Format("{0}", pingReply.Address)); WorkQueue.GlobalQueueWorkItemTag(new Action((address, hopNumber) => - { - string hostName; - - try { - hostName = Dns.GetHostEntry(address).HostName; - } - catch - { - hostName = string.Empty; - } + string hostName; - if (this.IsHandleCreated) - { - this.BeginInvoke(new MethodInvoker(() => + try + { + hostName = Dns.GetHostEntry(address).HostName; + } + catch { - foreach (ListViewItem item in listInfo.Items) - { - if (item.Text == hopNumber.ToString()) + hostName = ""; + } + + if (this.IsHandleCreated) + { + this.BeginInvoke(new MethodInvoker(() => { - item.SubItems[3].Text = hostName; - break; - } - } - })); - } - }), "ipinfowindow-resolveaddress", pingReply.Address, i); + foreach (ListViewItem item in listInfo.Items) + { + if (item.Text == hopNumber.ToString()) + { + item.SubItems[3].Text = hostName; + break; + } + } + })); + } + }), "ipinfowindow-resolveaddress", pingReply.Address, i); if (pingReply.Status == IPStatus.Success) { @@ -293,9 +287,9 @@ private void Whois(object ip) while (!streamReaderReceive.EndOfStream) { string data = streamReaderReceive.ReadLine(); - if (!data.Contains("#", StringComparison.OrdinalIgnoreCase) | !data.Contains("?", StringComparison.OrdinalIgnoreCase)) + if (!data.Contains("#") | !data.Contains("?")) { - WriteResult(data, string.Empty, string.Empty); + WriteResult(data, "", ""); } } } @@ -342,7 +336,7 @@ private void WriteResult(string hop, string time, string ip) ListViewItem litem = new ListViewItem(hop); litem.SubItems.Add(time); litem.SubItems.Add(ip); - litem.SubItems.Add(string.Empty); + litem.SubItems.Add(""); listInfo.Items.Add(litem); } diff --git a/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.resx b/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.resx index 2cbf80acc..4a18a8b93 100644 --- a/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/IPInfoWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + AAABAA0AMDAQAAEABABoBgAA1gAAACAgEAABAAQA6AIAAD4HAAAYGBAAAQAEAOgBAAAmCgAAEBAQAAEA diff --git a/1.x/trunk/ProcessHacker/Forms/InformationBox.Designer.cs b/1.x/trunk/ProcessHacker/Forms/InformationBox.Designer.cs index 5e8fe8422..3eea860c3 100644 --- a/1.x/trunk/ProcessHacker/Forms/InformationBox.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/InformationBox.Designer.cs @@ -36,10 +36,9 @@ private void InitializeComponent() // // textValues // - this.textValues.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textValues.BackColor = System.Drawing.Color.WhiteSmoke; + this.textValues.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textValues.HideSelection = false; this.textValues.Location = new System.Drawing.Point(12, 12); this.textValues.Multiline = true; @@ -52,7 +51,6 @@ private void InitializeComponent() // buttonClose // this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.buttonClose.FlatStyle = System.Windows.Forms.FlatStyle.System; this.buttonClose.Location = new System.Drawing.Point(462, 306); this.buttonClose.Name = "buttonClose"; @@ -88,11 +86,8 @@ private void InitializeComponent() // // InformationBox // - this.AcceptButton = this.buttonSave; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.CancelButton = this.buttonClose; this.ClientSize = new System.Drawing.Size(549, 341); this.Controls.Add(this.buttonCopy); this.Controls.Add(this.buttonSave); @@ -106,8 +101,8 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Information"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InformationBox_FormClosing); this.Load += new System.EventHandler(this.InformationBox_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InformationBox_FormClosing); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.InformationBox_KeyDown); this.ResumeLayout(false); this.PerformLayout(); diff --git a/1.x/trunk/ProcessHacker/Forms/InformationBox.cs b/1.x/trunk/ProcessHacker/Forms/InformationBox.cs index fd8b427ee..c18306c41 100644 --- a/1.x/trunk/ProcessHacker/Forms/InformationBox.cs +++ b/1.x/trunk/ProcessHacker/Forms/InformationBox.cs @@ -30,7 +30,7 @@ public partial class InformationBox : Form public InformationBox(string values) { InitializeComponent(); - + this.AddEscapeToClose(); this.SetTopMost(); if (!Program.BadConfig) @@ -76,15 +76,13 @@ private void buttonClose_Click(object sender, EventArgs e) private void buttonSave_Click(object sender, EventArgs e) { - using (SaveFileDialog sfd = new SaveFileDialog - { - FileName = this.DefaultFileName, - Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" - }) - { - if (sfd.ShowDialog() == DialogResult.OK) - System.IO.File.WriteAllText(sfd.FileName, textValues.Text); - } + SaveFileDialog sfd = new SaveFileDialog(); + + sfd.FileName = DefaultFileName; + sfd.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; + + if (sfd.ShowDialog() == DialogResult.OK) + System.IO.File.WriteAllText(sfd.FileName, textValues.Text); } private void buttonCopy_Click(object sender, EventArgs e) diff --git a/1.x/trunk/ProcessHacker/Forms/InformationBox.resx b/1.x/trunk/ProcessHacker/Forms/InformationBox.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/InformationBox.resx +++ b/1.x/trunk/ProcessHacker/Forms/InformationBox.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/JobWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/JobWindow.Designer.cs index 3a0fe6c84..dd7b2f571 100644 --- a/1.x/trunk/ProcessHacker/Forms/JobWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/JobWindow.Designer.cs @@ -37,9 +37,9 @@ private void InitializeComponent() // // panelJob // - this.panelJob.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.panelJob.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.panelJob.Location = new System.Drawing.Point(12, 12); this.panelJob.Name = "panelJob"; this.panelJob.Size = new System.Drawing.Size(444, 372); @@ -61,7 +61,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(468, 425); this.Controls.Add(this.buttonClose); this.Controls.Add(this.panelJob); diff --git a/1.x/trunk/ProcessHacker/Forms/JobWindow.cs b/1.x/trunk/ProcessHacker/Forms/JobWindow.cs index 0095a986a..b0b83e3ca 100644 --- a/1.x/trunk/ProcessHacker/Forms/JobWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/JobWindow.cs @@ -1,4 +1,9 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; using System.Windows.Forms; using ProcessHacker.Components; using ProcessHacker.Native.Objects; @@ -7,19 +12,16 @@ namespace ProcessHacker { public partial class JobWindow : Form { - readonly JobProperties _jobProps; + JobProperties _jobProps; public JobWindow(JobObjectHandle jobHandle) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); - _jobProps = new JobProperties(jobHandle) - { - Dock = DockStyle.Fill - }; + _jobProps = new JobProperties(jobHandle); + _jobProps.Dock = DockStyle.Fill; panelJob.Controls.Add(_jobProps); } diff --git a/1.x/trunk/ProcessHacker/Forms/JobWindow.resx b/1.x/trunk/ProcessHacker/Forms/JobWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/JobWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/JobWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.Designer.cs index c803bba79..907e29d57 100644 --- a/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.Designer.cs @@ -35,9 +35,9 @@ private void InitializeComponent() // // listItems // - this.listItems.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listItems.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listItems.FormattingEnabled = true; this.listItems.IntegralHeight = false; this.listItems.Location = new System.Drawing.Point(12, 12); @@ -75,7 +75,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(406, 171); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOK); diff --git a/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.resx b/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ListPickerWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ListWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ListWindow.Designer.cs index 14a39cd3a..de2be5cbf 100644 --- a/1.x/trunk/ProcessHacker/Forms/ListWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ListWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class ListWindow { @@ -31,9 +29,9 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.buttonClose = new System.Windows.Forms.Button(); - this.listView = new ProcessHacker.Components.ExtendedListView(); - this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listView = new System.Windows.Forms.ListView(); + this.columnName = new System.Windows.Forms.ColumnHeader(); + this.columnValue = new System.Windows.Forms.ColumnHeader(); this.SuspendLayout(); // // buttonClose @@ -50,13 +48,12 @@ private void InitializeComponent() // // listView // - this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnName, this.columnValue}); - this.listView.DoubleClickChecks = true; this.listView.FullRowSelect = true; this.listView.Location = new System.Drawing.Point(12, 12); this.listView.Name = "listView"; @@ -80,7 +77,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(511, 310); this.Controls.Add(this.listView); this.Controls.Add(this.buttonClose); @@ -92,6 +88,7 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "List"; + this.Load += new System.EventHandler(this.ListWindow_Load); this.ResumeLayout(false); } @@ -99,7 +96,7 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Button buttonClose; - private ExtendedListView listView; + private System.Windows.Forms.ListView listView; private System.Windows.Forms.ColumnHeader columnName; private System.Windows.Forms.ColumnHeader columnValue; } diff --git a/1.x/trunk/ProcessHacker/Forms/ListWindow.cs b/1.x/trunk/ProcessHacker/Forms/ListWindow.cs index f35a26dcc..777fc1d00 100644 --- a/1.x/trunk/ProcessHacker/Forms/ListWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/ListWindow.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; using System.Windows.Forms; +using ProcessHacker.Common; using ProcessHacker.UI; namespace ProcessHacker @@ -37,11 +38,9 @@ public ListWindow(List> list) foreach (KeyValuePair kvp in list) { - ListViewItem item = new ListViewItem - { - Text = kvp.Key - }; + ListViewItem item = new ListViewItem(); + item.Text = kvp.Key; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, kvp.Value)); listView.Items.Add(item); @@ -50,6 +49,11 @@ public ListWindow(List> list) listView.ContextMenu = listView.GetCopyMenu(); } + private void ListWindow_Load(object sender, EventArgs e) + { + listView.SetTheme("explorer"); + } + private void buttonClose_Click(object sender, EventArgs e) { this.Close(); diff --git a/1.x/trunk/ProcessHacker/Forms/ListWindow.resx b/1.x/trunk/ProcessHacker/Forms/ListWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ListWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ListWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/LogWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/LogWindow.Designer.cs index bdc180cc3..bbc6bfa84 100644 --- a/1.x/trunk/ProcessHacker/Forms/LogWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/LogWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class LogWindow { @@ -31,9 +29,9 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.listLog = new ProcessHacker.Components.ExtendedListView(); - this.columnTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnMessage = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listLog = new System.Windows.Forms.ListView(); + this.columnTime = new System.Windows.Forms.ColumnHeader(); + this.columnMessage = new System.Windows.Forms.ColumnHeader(); this.buttonClose = new System.Windows.Forms.Button(); this.timerScroll = new System.Windows.Forms.Timer(this.components); this.buttonCopy = new System.Windows.Forms.Button(); @@ -44,25 +42,24 @@ private void InitializeComponent() // // listLog // - this.listLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listLog.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnTime, this.columnMessage}); - this.listLog.DoubleClickChecks = true; this.listLog.FullRowSelect = true; this.listLog.HideSelection = false; this.listLog.Location = new System.Drawing.Point(12, 12); this.listLog.Name = "listLog"; this.listLog.ShowItemToolTips = true; - this.listLog.Size = new System.Drawing.Size(555, 297); + this.listLog.Size = new System.Drawing.Size(555, 419); this.listLog.TabIndex = 0; this.listLog.UseCompatibleStateImageBehavior = false; this.listLog.View = System.Windows.Forms.View.Details; this.listLog.VirtualMode = true; - this.listLog.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listLog_RetrieveVirtualItem); this.listLog.DoubleClick += new System.EventHandler(this.listLog_DoubleClick); + this.listLog.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listLog_RetrieveVirtualItem); // // columnTime // @@ -78,7 +75,7 @@ private void InitializeComponent() // this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonClose.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonClose.Location = new System.Drawing.Point(492, 315); + this.buttonClose.Location = new System.Drawing.Point(492, 437); this.buttonClose.Name = "buttonClose"; this.buttonClose.Size = new System.Drawing.Size(75, 23); this.buttonClose.TabIndex = 5; @@ -96,7 +93,7 @@ private void InitializeComponent() // this.buttonCopy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCopy.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonCopy.Location = new System.Drawing.Point(411, 315); + this.buttonCopy.Location = new System.Drawing.Point(411, 437); this.buttonCopy.Name = "buttonCopy"; this.buttonCopy.Size = new System.Drawing.Size(75, 23); this.buttonCopy.TabIndex = 4; @@ -108,7 +105,7 @@ private void InitializeComponent() // this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonSave.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonSave.Location = new System.Drawing.Point(330, 315); + this.buttonSave.Location = new System.Drawing.Point(330, 437); this.buttonSave.Name = "buttonSave"; this.buttonSave.Size = new System.Drawing.Size(75, 23); this.buttonSave.TabIndex = 3; @@ -120,7 +117,7 @@ private void InitializeComponent() // this.buttonClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonClear.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonClear.Location = new System.Drawing.Point(12, 315); + this.buttonClear.Location = new System.Drawing.Point(12, 437); this.buttonClear.Name = "buttonClear"; this.buttonClear.Size = new System.Drawing.Size(75, 23); this.buttonClear.TabIndex = 1; @@ -135,9 +132,9 @@ private void InitializeComponent() this.checkAutoscroll.Checked = true; this.checkAutoscroll.CheckState = System.Windows.Forms.CheckState.Checked; this.checkAutoscroll.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.checkAutoscroll.Location = new System.Drawing.Point(93, 318); + this.checkAutoscroll.Location = new System.Drawing.Point(93, 440); this.checkAutoscroll.Name = "checkAutoscroll"; - this.checkAutoscroll.Size = new System.Drawing.Size(88, 18); + this.checkAutoscroll.Size = new System.Drawing.Size(81, 18); this.checkAutoscroll.TabIndex = 2; this.checkAutoscroll.Text = "Auto-scroll"; this.checkAutoscroll.UseVisualStyleBackColor = true; @@ -146,8 +143,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(579, 350); + this.ClientSize = new System.Drawing.Size(579, 472); this.Controls.Add(this.checkAutoscroll); this.Controls.Add(this.buttonClear); this.Controls.Add(this.buttonSave); @@ -155,6 +151,7 @@ private void InitializeComponent() this.Controls.Add(this.buttonClose); this.Controls.Add(this.listLog); this.Name = "LogWindow"; + this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Log"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LogWindow_FormClosing); @@ -165,7 +162,7 @@ private void InitializeComponent() #endregion - private ExtendedListView listLog; + private System.Windows.Forms.ListView listLog; private System.Windows.Forms.ColumnHeader columnTime; private System.Windows.Forms.ColumnHeader columnMessage; private System.Windows.Forms.Button buttonClose; diff --git a/1.x/trunk/ProcessHacker/Forms/LogWindow.cs b/1.x/trunk/ProcessHacker/Forms/LogWindow.cs index 2be5bcce8..9917bcf1a 100644 --- a/1.x/trunk/ProcessHacker/Forms/LogWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/LogWindow.cs @@ -35,23 +35,25 @@ public partial class LogWindow : Form public LogWindow() { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); - this.listLog.ContextMenu = this.listLog.GetCopyMenu(this.listLog_RetrieveVirtualItem); - this.listLog.AddShortcuts(this.listLog_RetrieveVirtualItem); + listLog.SetDoubleBuffered(true); + listLog.SetTheme("explorer"); + listLog.ContextMenu = listLog.GetCopyMenu(listLog_RetrieveVirtualItem); + listLog.AddShortcuts(listLog_RetrieveVirtualItem); this.UpdateLog(); - if (this.listLog.SelectedIndices.Count == 0 && this.listLog.VirtualListSize > 0) - this.listLog.EnsureVisible(this.listLog.VirtualListSize - 1); + if (listLog.SelectedIndices.Count == 0 && listLog.VirtualListSize > 0) + listLog.EnsureVisible(listLog.VirtualListSize - 1); - Program.HackerWindow.LogUpdated += this.HackerWindow_LogUpdated; + Program.HackerWindow.LogUpdated += new HackerWindow.LogUpdatedEventHandler(HackerWindow_LogUpdated); this.Size = Settings.Instance.LogWindowSize; - this.Location = Utils.FitRectangle(new Rectangle(Settings.Instance.LogWindowLocation, this.Size), this).Location; - this.checkAutoscroll.Checked = Settings.Instance.LogWindowAutoScroll; + this.Location = Utils.FitRectangle(new Rectangle( + Settings.Instance.LogWindowLocation, this.Size), this).Location; + checkAutoscroll.Checked = Settings.Instance.LogWindowAutoScroll; } private void HackerWindow_LogUpdated(KeyValuePair? value) @@ -83,7 +85,7 @@ private void LogWindow_FormClosing(object sender, FormClosingEventArgs e) Settings.Instance.LogWindowAutoScroll = checkAutoscroll.Checked; - Program.HackerWindow.LogUpdated -= this.HackerWindow_LogUpdated; + Program.HackerWindow.LogUpdated -= new HackerWindow.LogUpdatedEventHandler(HackerWindow_LogUpdated); } private void buttonClose_Click(object sender, EventArgs e) @@ -123,29 +125,27 @@ private void buttonCopy_Click(object sender, EventArgs e) private void buttonSave_Click(object sender, EventArgs e) { - using (SaveFileDialog sfd = new SaveFileDialog - { - FileName = "Process Hacker Log.txt", - Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" - }) + SaveFileDialog sfd = new SaveFileDialog(); + + sfd.FileName = "Process Hacker Log.txt"; + sfd.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; + + if (sfd.ShowDialog() == DialogResult.OK) { - if (sfd.ShowDialog() == DialogResult.OK) + StringBuilder sb = new StringBuilder(); + + foreach (var value in Program.HackerWindow.Log) { - StringBuilder sb = new StringBuilder(); - - foreach (var value in Program.HackerWindow.Log) - { - sb.AppendLine(value.Key.ToString() + ": " + value.Value); - } - - try - { - System.IO.File.WriteAllText(sfd.FileName, sb.ToString()); - } - catch (Exception ex) - { - PhUtils.ShowException("Unable to save the log", ex); - } + sb.AppendLine(value.Key.ToString() + ": " + value.Value); + } + + try + { + System.IO.File.WriteAllText(sfd.FileName, sb.ToString()); + } + catch (Exception ex) + { + PhUtils.ShowException("Unable to save the log", ex); } } } @@ -157,10 +157,9 @@ private void buttonClear_Click(object sender, EventArgs e) private void listLog_DoubleClick(object sender, EventArgs e) { - using (InformationBox info = new InformationBox(Program.HackerWindow.Log[listLog.SelectedIndices[0]].Value)) - { - info.ShowDialog(); - } + InformationBox info = new InformationBox(Program.HackerWindow.Log[listLog.SelectedIndices[0]].Value); + + info.ShowDialog(); } } } diff --git a/1.x/trunk/ProcessHacker/Forms/LogWindow.resx b/1.x/trunk/ProcessHacker/Forms/LogWindow.resx index dd32a4d9f..c4b54ad1e 100644 --- a/1.x/trunk/ProcessHacker/Forms/LogWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/LogWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/MemoryEditor.Designer.cs b/1.x/trunk/ProcessHacker/Forms/MemoryEditor.Designer.cs index 236fb809f..a4ab33a23 100644 --- a/1.x/trunk/ProcessHacker/Forms/MemoryEditor.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/MemoryEditor.Designer.cs @@ -57,20 +57,22 @@ private void InitializeComponent() this.menuItem4 = new System.Windows.Forms.MenuItem(); this.windowMenuItem = new System.Windows.Forms.MenuItem(); this.buttonStruct = new System.Windows.Forms.Button(); - this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.hexBoxMemory = new Be.Windows.Forms.HexBox(); this.utilitiesButtonMemory = new ProcessHacker.Components.UtilitiesButton(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // labelHexSelection // - this.labelHexSelection.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelHexSelection.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelHexSelection.BorderStyle = System.Windows.Forms.BorderStyle.None; this.labelHexSelection.Location = new System.Drawing.Point(12, 2); this.labelHexSelection.Name = "labelHexSelection"; this.labelHexSelection.ReadOnly = true; - this.labelHexSelection.Size = new System.Drawing.Size(751, 15); + this.labelHexSelection.Size = new System.Drawing.Size(751, 13); this.labelHexSelection.TabIndex = 0; this.labelHexSelection.Text = "Selection:"; // @@ -78,7 +80,7 @@ private void InitializeComponent() // this.buttonValues.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonValues.Image = global::ProcessHacker.Properties.Resources.information; - this.buttonValues.Location = new System.Drawing.Point(709, 202); + this.buttonValues.Location = new System.Drawing.Point(709, 328); this.buttonValues.Name = "buttonValues"; this.buttonValues.Size = new System.Drawing.Size(24, 24); this.buttonValues.TabIndex = 9; @@ -90,7 +92,7 @@ private void InitializeComponent() // this.buttonGoToMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonGoToMemory.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonGoToMemory.Location = new System.Drawing.Point(275, 204); + this.buttonGoToMemory.Location = new System.Drawing.Point(275, 330); this.buttonGoToMemory.Name = "buttonGoToMemory"; this.buttonGoToMemory.Size = new System.Drawing.Size(47, 23); this.buttonGoToMemory.TabIndex = 7; @@ -102,18 +104,18 @@ private void InitializeComponent() // textGoTo // this.textGoTo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textGoTo.Location = new System.Drawing.Point(188, 206); + this.textGoTo.Location = new System.Drawing.Point(188, 332); this.textGoTo.Name = "textGoTo"; - this.textGoTo.Size = new System.Drawing.Size(81, 22); + this.textGoTo.Size = new System.Drawing.Size(81, 20); this.textGoTo.TabIndex = 6; - this.textGoTo.Enter += new System.EventHandler(this.textGoTo_Enter); this.textGoTo.Leave += new System.EventHandler(this.textGoTo_Leave); + this.textGoTo.Enter += new System.EventHandler(this.textGoTo_Enter); // // buttonTopFind // this.buttonTopFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonTopFind.Image = global::ProcessHacker.Properties.Resources.arrow_up; - this.buttonTopFind.Location = new System.Drawing.Point(159, 204); + this.buttonTopFind.Location = new System.Drawing.Point(159, 330); this.buttonTopFind.Name = "buttonTopFind"; this.buttonTopFind.Size = new System.Drawing.Size(23, 23); this.buttonTopFind.TabIndex = 5; @@ -125,7 +127,7 @@ private void InitializeComponent() // this.buttonNextFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.buttonNextFind.Image = global::ProcessHacker.Properties.Resources.arrow_right; - this.buttonNextFind.Location = new System.Drawing.Point(130, 204); + this.buttonNextFind.Location = new System.Drawing.Point(130, 330); this.buttonNextFind.Name = "buttonNextFind"; this.buttonNextFind.Size = new System.Drawing.Size(23, 23); this.buttonNextFind.TabIndex = 4; @@ -136,21 +138,21 @@ private void InitializeComponent() // textSearchMemory // this.textSearchMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.textSearchMemory.Location = new System.Drawing.Point(48, 206); + this.textSearchMemory.Location = new System.Drawing.Point(48, 332); this.textSearchMemory.Name = "textSearchMemory"; - this.textSearchMemory.Size = new System.Drawing.Size(76, 22); + this.textSearchMemory.Size = new System.Drawing.Size(76, 20); this.textSearchMemory.TabIndex = 3; this.textSearchMemory.TextChanged += new System.EventHandler(this.textSearchMemory_TextChanged); - this.textSearchMemory.Enter += new System.EventHandler(this.textSearchMemory_Enter); this.textSearchMemory.Leave += new System.EventHandler(this.textSearchMemory_Leave); + this.textSearchMemory.Enter += new System.EventHandler(this.textSearchMemory_Enter); // // labelFind // this.labelFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.labelFind.AutoSize = true; - this.labelFind.Location = new System.Drawing.Point(12, 209); + this.labelFind.Location = new System.Drawing.Point(12, 335); this.labelFind.Name = "labelFind"; - this.labelFind.Size = new System.Drawing.Size(33, 13); + this.labelFind.Size = new System.Drawing.Size(30, 13); this.labelFind.TabIndex = 2; this.labelFind.Text = "Find:"; // @@ -173,6 +175,7 @@ private void InitializeComponent() // // menuItem6 // + this.vistaMenu.SetImage(this.menuItem6, global::ProcessHacker.Properties.Resources.page); this.menuItem6.Index = 0; this.menuItem6.Shortcut = System.Windows.Forms.Shortcut.F5; this.menuItem6.Text = "&Read"; @@ -180,12 +183,14 @@ private void InitializeComponent() // // writeMenuItem // + this.vistaMenu.SetImage(this.writeMenuItem, global::ProcessHacker.Properties.Resources.page_edit); this.writeMenuItem.Index = 1; this.writeMenuItem.Text = "&Write"; this.writeMenuItem.Click += new System.EventHandler(this.writeMenuItem_Click); // // menuItem2 // + this.vistaMenu.SetImage(this.menuItem2, global::ProcessHacker.Properties.Resources.disk); this.menuItem2.Index = 2; this.menuItem2.Shortcut = System.Windows.Forms.Shortcut.CtrlS; this.menuItem2.Text = "&Save..."; @@ -198,6 +203,7 @@ private void InitializeComponent() // // menuItem4 // + this.vistaMenu.SetImage(this.menuItem4, global::ProcessHacker.Properties.Resources.door_out); this.menuItem4.Index = 4; this.menuItem4.Text = "&Close"; this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); @@ -211,7 +217,7 @@ private void InitializeComponent() // this.buttonStruct.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonStruct.Image = global::ProcessHacker.Properties.Resources.bricks; - this.buttonStruct.Location = new System.Drawing.Point(679, 202); + this.buttonStruct.Location = new System.Drawing.Point(679, 328); this.buttonStruct.Name = "buttonStruct"; this.buttonStruct.Size = new System.Drawing.Size(24, 24); this.buttonStruct.TabIndex = 8; @@ -221,9 +227,9 @@ private void InitializeComponent() // // hexBoxMemory // - this.hexBoxMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.hexBoxMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.hexBoxMemory.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.hexBoxMemory.HexCasing = Be.Windows.Forms.HexCasing.Lower; this.hexBoxMemory.LineInfoForeColor = System.Drawing.Color.Empty; @@ -231,7 +237,7 @@ private void InitializeComponent() this.hexBoxMemory.Location = new System.Drawing.Point(12, 21); this.hexBoxMemory.Name = "hexBoxMemory"; this.hexBoxMemory.ShadowSelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(60)))), ((int)(((byte)(188)))), ((int)(((byte)(255))))); - this.hexBoxMemory.Size = new System.Drawing.Size(751, 175); + this.hexBoxMemory.Size = new System.Drawing.Size(751, 301); this.hexBoxMemory.StringViewVisible = true; this.hexBoxMemory.TabIndex = 1; this.hexBoxMemory.UseFixedBytesPerLine = true; @@ -243,18 +249,22 @@ private void InitializeComponent() // this.utilitiesButtonMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.utilitiesButtonMemory.HexBox = this.hexBoxMemory; - this.utilitiesButtonMemory.Location = new System.Drawing.Point(739, 202); + this.utilitiesButtonMemory.Location = new System.Drawing.Point(739, 328); this.utilitiesButtonMemory.Name = "utilitiesButtonMemory"; this.utilitiesButtonMemory.Size = new System.Drawing.Size(24, 24); this.utilitiesButtonMemory.TabIndex = 10; this.toolTip.SetToolTip(this.utilitiesButtonMemory, "Insert Data"); // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // MemoryEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(775, 238); + this.ClientSize = new System.Drawing.Size(775, 364); this.Controls.Add(this.hexBoxMemory); this.Controls.Add(this.labelFind); this.Controls.Add(this.utilitiesButtonMemory); @@ -270,8 +280,9 @@ private void InitializeComponent() this.Menu = this.mainMenu; this.Name = "MemoryEditor"; this.Text = "Memory Editor"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MemoryEditor_FormClosing); this.Load += new System.EventHandler(this.MemoryEditor_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MemoryEditor_FormClosing); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -292,6 +303,7 @@ private void InitializeComponent() private System.Windows.Forms.MainMenu mainMenu; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.MenuItem writeMenuItem; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.MenuItem menuItem4; diff --git a/1.x/trunk/ProcessHacker/Forms/MemoryEditor.cs b/1.x/trunk/ProcessHacker/Forms/MemoryEditor.cs index 6ae3c4f61..4df828dd8 100644 --- a/1.x/trunk/ProcessHacker/Forms/MemoryEditor.cs +++ b/1.x/trunk/ProcessHacker/Forms/MemoryEditor.cs @@ -34,23 +34,28 @@ public partial class MemoryEditor : Form { public static MemoryEditor ReadWriteMemory(int pid, IntPtr address, int size, bool RO) { - return ReadWriteMemory(pid, address, size, RO, editor => { }); + return ReadWriteMemory(pid, address, size, RO, + new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { })); } - public static MemoryEditor ReadWriteMemory(int pid, IntPtr address, int size, bool RO, Program.MemoryEditorInvokeAction action) + public static MemoryEditor ReadWriteMemory(int pid, IntPtr address, int size, bool RO, + Program.MemoryEditorInvokeAction action) { try { - MemoryEditor ed = Program.GetMemoryEditor(pid, address, size, f => - { - if (!f.IsDisposed) + MemoryEditor ed = null; + + ed = Program.GetMemoryEditor(pid, address, size, + new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) { - f.ReadOnly = RO; - f.Show(); - action(f); - f.Activate(); - } - }); + if (!f.IsDisposed) + { + f.ReadOnly = RO; + f.Show(); + action(f); + f.Activate(); + } + })); return ed; } @@ -60,8 +65,8 @@ public static MemoryEditor ReadWriteMemory(int pid, IntPtr address, int size, bo } } - private readonly int _pid; - private readonly long _length; + private int _pid; + private long _length; private IntPtr _address; private byte[] _data; @@ -110,9 +115,10 @@ public MemoryEditor(int PID, IntPtr Address, long Length) private void MemoryEditor_Load(object sender, EventArgs e) { - //Program.UpdateWindowMenu(windowMenuItem, this); + Program.UpdateWindowMenu(windowMenuItem, this); this.Size = Settings.Instance.MemoryWindowSize; + this.SetPhParent(false); } private void MemoryEditor_FormClosing(object sender, FormClosingEventArgs e) @@ -155,7 +161,7 @@ public void Select(long start, long length) private void ReadMemory() { - using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessReadMemoryRights)) + using (var phandle = new ProcessHandle(_pid, Program.MinProcessReadMemoryRights)) { _data = new byte[_length]; @@ -182,7 +188,7 @@ private void WriteMemory() private void buttonValues_Click(object sender, EventArgs e) { - string values = string.Empty; + string values = ""; InformationBox valuesForm; long addr = hexBoxMemory.SelectionStart; long space = hexBoxMemory.ByteProvider.Length - hexBoxMemory.SelectionStart; @@ -301,9 +307,9 @@ private void menuItem2_Click(object sender, EventArgs e) try { - using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) { - string fileName = phandle.ImageFileName; + string fileName = phandle.GetImageFileName(); sfd.FileName = fileName.Substring(fileName.LastIndexOf('\\') + 1) + "-" + Utils.FormatAddress(_address) + ".bin"; } @@ -403,12 +409,19 @@ private void buttonStruct_Click(object sender, EventArgs e) if (Program.Structs.ContainsKey(lpw.SelectedItem)) { // stupid TreeViewAdv only works on the one thread - Program.HackerWindow.BeginInvoke(new MethodInvoker(() => - { - StructWindow sw = new StructWindow(this._pid, (this._address.Increment(selectionStart)), Program.Structs[lpw.SelectedItem]); - sw.Show(); - sw.Activate(); - })); + Program.HackerWindow.BeginInvoke(new MethodInvoker(delegate + { + StructWindow sw = new StructWindow(_pid, (_address.Increment(selectionStart)), + Program.Structs[lpw.SelectedItem]); + + try + { + sw.Show(); + sw.Activate(); + } + catch + { } + })); } } } diff --git a/1.x/trunk/ProcessHacker/Forms/MemoryEditor.resx b/1.x/trunk/ProcessHacker/Forms/MemoryEditor.resx index 01d2c7ff3..434f2b895 100644 --- a/1.x/trunk/ProcessHacker/Forms/MemoryEditor.resx +++ b/1.x/trunk/ProcessHacker/Forms/MemoryEditor.resx @@ -112,18 +112,21 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 235, 17 - + 17, 17 - + + 127, 17 + + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA diff --git a/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.Designer.cs index 093bd7f7f..0ba239b6a 100644 --- a/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.Designer.cs @@ -45,7 +45,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 15); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(31, 13); + this.label1.Size = new System.Drawing.Size(30, 13); this.label1.TabIndex = 6; this.label1.Text = "Title:"; // @@ -54,24 +54,24 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 41); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(30, 13); + this.label2.Size = new System.Drawing.Size(31, 13); this.label2.TabIndex = 7; this.label2.Text = "Text:"; // // textTitle // - this.textTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textTitle.Location = new System.Drawing.Point(49, 12); this.textTitle.Name = "textTitle"; - this.textTitle.Size = new System.Drawing.Size(354, 22); + this.textTitle.Size = new System.Drawing.Size(354, 20); this.textTitle.TabIndex = 0; // // textText // - this.textText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textText.Location = new System.Drawing.Point(49, 38); this.textText.Multiline = true; this.textText.Name = "textText"; @@ -84,7 +84,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 155); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(32, 13); + this.label3.Size = new System.Drawing.Size(31, 13); this.label3.TabIndex = 8; this.label3.Text = "Icon:"; // @@ -94,14 +94,14 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(12, 182); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(65, 13); + this.label4.Size = new System.Drawing.Size(62, 13); this.label4.TabIndex = 9; this.label4.Text = "Timeout (s):"; // // comboIcon // - this.comboIcon.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.comboIcon.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.comboIcon.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboIcon.FormattingEnabled = true; this.comboIcon.Items.AddRange(new object[] { @@ -120,7 +120,7 @@ private void InitializeComponent() this.textTimeout.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.textTimeout.Location = new System.Drawing.Point(80, 179); this.textTimeout.Name = "textTimeout"; - this.textTimeout.Size = new System.Drawing.Size(100, 22); + this.textTimeout.Size = new System.Drawing.Size(100, 20); this.textTimeout.TabIndex = 3; // // buttonCancel @@ -152,7 +152,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(415, 240); this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonCancel); diff --git a/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.resx b/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/MessageBoxWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/MiniSysInfo.cs b/1.x/trunk/ProcessHacker/Forms/MiniSysInfo.cs index 1a39ae3b5..b213852ab 100644 --- a/1.x/trunk/ProcessHacker/Forms/MiniSysInfo.cs +++ b/1.x/trunk/ProcessHacker/Forms/MiniSysInfo.cs @@ -42,13 +42,7 @@ struct MARGINS [DllImport("dwmapi.dll", SetLastError = true)] static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS inset); - readonly MARGINS margins = new MARGINS - { - Left = -1, - Right = -1, - Top = -1, - Bottom = -1 - }; + MARGINS margins = new MARGINS() { Left = -1, Right = -1, Top = -1, Bottom = -1 }; public MiniSysInfo() { @@ -68,7 +62,7 @@ public MiniSysInfo() plotterIO.LongData1 = Program.ProcessProvider.IoReadOtherHistory; plotterIO.LongData2 = Program.ProcessProvider.IoWriteHistory; - Program.ProcessProvider.Updated += this.ProcessProvider_Updated; + Program.ProcessProvider.Updated += new ProcessSystemProvider.ProviderUpdateOnce(ProcessProvider_Updated); } protected override void WndProc(ref Message m) @@ -91,22 +85,22 @@ private void MiniSysInfo_Deactivate(object sender, EventArgs e) private void MiniSysInfo_FormClosing(object sender, FormClosingEventArgs e) { - Program.ProcessProvider.Updated -= this.ProcessProvider_Updated; + Program.ProcessProvider.Updated -= new ProcessSystemProvider.ProviderUpdateOnce(ProcessProvider_Updated); } private void ProcessProvider_Updated() { - this.BeginInvoke(new MethodInvoker(() => + this.BeginInvoke(new MethodInvoker(delegate { - this.plotterCPU.LineColor1 = Settings.Instance.PlotterCPUKernelColor; - this.plotterCPU.LineColor2 = Settings.Instance.PlotterCPUUserColor; - this.plotterCPU.MoveGrid(); - this.plotterCPU.Draw(); + plotterCPU.LineColor1 = Settings.Instance.PlotterCPUKernelColor; + plotterCPU.LineColor2 = Settings.Instance.PlotterCPUUserColor; + plotterCPU.MoveGrid(); + plotterCPU.Draw(); - this.plotterIO.LineColor1 = Settings.Instance.PlotterIOROColor; - this.plotterIO.LineColor2 = Settings.Instance.PlotterIOWColor; - this.plotterIO.MoveGrid(); - this.plotterIO.Draw(); + plotterIO.LineColor1 = Settings.Instance.PlotterIOROColor; + plotterIO.LineColor2 = Settings.Instance.PlotterIOWColor; + plotterIO.MoveGrid(); + plotterIO.Draw(); })); } } diff --git a/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.Designer.cs index 089da0f73..549b40492 100644 --- a/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.Designer.cs @@ -46,7 +46,6 @@ private void InitializeComponent() this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.plotter1 = new ProcessHacker.Components.Plotter(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.label20 = new System.Windows.Forms.Label(); this.label19 = new System.Windows.Forms.Label(); @@ -60,6 +59,7 @@ private void InitializeComponent() this.label24 = new System.Windows.Forms.Label(); this.label25 = new System.Windows.Forms.Label(); this.label26 = new System.Windows.Forms.Label(); + this.plotter1 = new ProcessHacker.Components.Plotter(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -94,7 +94,7 @@ private void InitializeComponent() this.label15.AutoSize = true; this.label15.Location = new System.Drawing.Point(122, 157); this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(44, 13); + this.label15.Size = new System.Drawing.Size(41, 13); this.label15.TabIndex = 14; this.label15.Text = "label15"; // @@ -103,7 +103,7 @@ private void InitializeComponent() this.label14.AutoSize = true; this.label14.Location = new System.Drawing.Point(122, 133); this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(44, 13); + this.label14.Size = new System.Drawing.Size(41, 13); this.label14.TabIndex = 13; this.label14.Text = "label14"; // @@ -112,7 +112,7 @@ private void InitializeComponent() this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(122, 105); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(44, 13); + this.label13.Size = new System.Drawing.Size(41, 13); this.label13.TabIndex = 12; this.label13.Text = "label13"; // @@ -121,7 +121,7 @@ private void InitializeComponent() this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(6, 157); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(44, 13); + this.label12.Size = new System.Drawing.Size(41, 13); this.label12.TabIndex = 11; this.label12.Text = "label12"; // @@ -130,7 +130,7 @@ private void InitializeComponent() this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(6, 133); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(44, 13); + this.label11.Size = new System.Drawing.Size(41, 13); this.label11.TabIndex = 10; this.label11.Text = "label11"; // @@ -139,7 +139,7 @@ private void InitializeComponent() this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(6, 105); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(44, 13); + this.label10.Size = new System.Drawing.Size(41, 13); this.label10.TabIndex = 9; this.label10.Text = "label10"; // @@ -148,7 +148,7 @@ private void InitializeComponent() this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(231, 75); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(38, 13); + this.label9.Size = new System.Drawing.Size(35, 13); this.label9.TabIndex = 8; this.label9.Text = "label9"; // @@ -157,7 +157,7 @@ private void InitializeComponent() this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(231, 51); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(38, 13); + this.label8.Size = new System.Drawing.Size(35, 13); this.label8.TabIndex = 7; this.label8.Text = "label8"; // @@ -166,7 +166,7 @@ private void InitializeComponent() this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(231, 28); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(38, 13); + this.label7.Size = new System.Drawing.Size(35, 13); this.label7.TabIndex = 6; this.label7.Text = "label7"; // @@ -175,7 +175,7 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(122, 75); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(38, 13); + this.label6.Size = new System.Drawing.Size(35, 13); this.label6.TabIndex = 5; this.label6.Text = "label6"; // @@ -184,7 +184,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(122, 51); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(38, 13); + this.label5.Size = new System.Drawing.Size(35, 13); this.label5.TabIndex = 4; this.label5.Text = "label5"; // @@ -193,7 +193,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(122, 28); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(38, 13); + this.label4.Size = new System.Drawing.Size(35, 13); this.label4.TabIndex = 3; this.label4.Text = "label4"; // @@ -202,7 +202,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 75); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 13); + this.label3.Size = new System.Drawing.Size(35, 13); this.label3.TabIndex = 2; this.label3.Text = "label3"; // @@ -211,7 +211,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 51); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(38, 13); + this.label2.Size = new System.Drawing.Size(35, 13); this.label2.TabIndex = 1; this.label2.Text = "label2"; // @@ -220,7 +220,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 28); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 13); + this.label1.Size = new System.Drawing.Size(35, 13); this.label1.TabIndex = 0; this.label1.Text = "label1"; // @@ -234,33 +234,6 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "Network Usage"; // - // plotter1 - // - this.plotter1.BackColor = System.Drawing.Color.Black; - this.plotter1.Data1 = null; - this.plotter1.Data2 = null; - this.plotter1.GridColor = System.Drawing.Color.Green; - this.plotter1.GridSize = new System.Drawing.Size(12, 12); - this.plotter1.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.plotter1.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.plotter1.Location = new System.Drawing.Point(6, 19); - this.plotter1.LongData1 = null; - this.plotter1.LongData2 = null; - this.plotter1.MinMaxValue = ((long)(0)); - this.plotter1.MoveStep = -1; - this.plotter1.Name = "plotter1"; - this.plotter1.OverlaySecondLine = true; - this.plotter1.ShowGrid = true; - this.plotter1.Size = new System.Drawing.Size(538, 71); - this.plotter1.TabIndex = 0; - this.plotter1.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.plotter1.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.plotter1.TextMargin = new System.Windows.Forms.Padding(3); - this.plotter1.TextPadding = new System.Windows.Forms.Padding(3); - this.plotter1.TextPosition = System.Drawing.ContentAlignment.TopLeft; - this.plotter1.UseLongData = false; - this.plotter1.UseSecondLine = true; - // // groupBox3 // this.groupBox3.Controls.Add(this.label20); @@ -280,7 +253,7 @@ private void InitializeComponent() this.label20.AutoSize = true; this.label20.Location = new System.Drawing.Point(6, 105); this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(44, 13); + this.label20.Size = new System.Drawing.Size(41, 13); this.label20.TabIndex = 11; this.label20.Text = "label20"; // @@ -289,7 +262,7 @@ private void InitializeComponent() this.label19.AutoSize = true; this.label19.Location = new System.Drawing.Point(114, 28); this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(44, 13); + this.label19.Size = new System.Drawing.Size(41, 13); this.label19.TabIndex = 10; this.label19.Text = "label19"; // @@ -298,7 +271,7 @@ private void InitializeComponent() this.label18.AutoSize = true; this.label18.Location = new System.Drawing.Point(114, 64); this.label18.Name = "label18"; - this.label18.Size = new System.Drawing.Size(44, 13); + this.label18.Size = new System.Drawing.Size(41, 13); this.label18.TabIndex = 9; this.label18.Text = "label18"; // @@ -307,7 +280,7 @@ private void InitializeComponent() this.label17.AutoSize = true; this.label17.Location = new System.Drawing.Point(6, 64); this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(44, 13); + this.label17.Size = new System.Drawing.Size(41, 13); this.label17.TabIndex = 8; this.label17.Text = "label17"; // @@ -316,7 +289,7 @@ private void InitializeComponent() this.label16.AutoSize = true; this.label16.Location = new System.Drawing.Point(6, 28); this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(44, 13); + this.label16.Size = new System.Drawing.Size(41, 13); this.label16.TabIndex = 7; this.label16.Text = "label16"; // @@ -331,7 +304,7 @@ private void InitializeComponent() this.label21.AutoSize = true; this.label21.Location = new System.Drawing.Point(18, 309); this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(44, 13); + this.label21.Size = new System.Drawing.Size(41, 13); this.label21.TabIndex = 16; this.label21.Text = "label21"; // @@ -340,7 +313,7 @@ private void InitializeComponent() this.label22.AutoSize = true; this.label22.Location = new System.Drawing.Point(18, 331); this.label22.Name = "label22"; - this.label22.Size = new System.Drawing.Size(44, 13); + this.label22.Size = new System.Drawing.Size(41, 13); this.label22.TabIndex = 15; this.label22.Text = "label22"; // @@ -349,7 +322,7 @@ private void InitializeComponent() this.label23.AutoSize = true; this.label23.Location = new System.Drawing.Point(169, 309); this.label23.Name = "label23"; - this.label23.Size = new System.Drawing.Size(44, 13); + this.label23.Size = new System.Drawing.Size(41, 13); this.label23.TabIndex = 18; this.label23.Text = "label23"; // @@ -358,7 +331,7 @@ private void InitializeComponent() this.label24.AutoSize = true; this.label24.Location = new System.Drawing.Point(169, 331); this.label24.Name = "label24"; - this.label24.Size = new System.Drawing.Size(44, 13); + this.label24.Size = new System.Drawing.Size(41, 13); this.label24.TabIndex = 17; this.label24.Text = "label24"; // @@ -367,7 +340,7 @@ private void InitializeComponent() this.label25.AutoSize = true; this.label25.Location = new System.Drawing.Point(308, 309); this.label25.Name = "label25"; - this.label25.Size = new System.Drawing.Size(44, 13); + this.label25.Size = new System.Drawing.Size(41, 13); this.label25.TabIndex = 20; this.label25.Text = "label25"; // @@ -376,15 +349,41 @@ private void InitializeComponent() this.label26.AutoSize = true; this.label26.Location = new System.Drawing.Point(308, 331); this.label26.Name = "label26"; - this.label26.Size = new System.Drawing.Size(44, 13); + this.label26.Size = new System.Drawing.Size(41, 13); this.label26.TabIndex = 19; this.label26.Text = "label26"; // + // plotter1 + // + this.plotter1.BackColor = System.Drawing.Color.Black; + this.plotter1.Data1 = null; + this.plotter1.Data2 = null; + this.plotter1.GridColor = System.Drawing.Color.Green; + this.plotter1.GridSize = new System.Drawing.Size(12, 12); + this.plotter1.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotter1.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotter1.Location = new System.Drawing.Point(6, 19); + this.plotter1.LongData1 = null; + this.plotter1.LongData2 = null; + this.plotter1.MinMaxValue = ((long)(0)); + this.plotter1.MoveStep = -1; + this.plotter1.Name = "plotter1"; + this.plotter1.OverlaySecondLine = true; + this.plotter1.ShowGrid = true; + this.plotter1.Size = new System.Drawing.Size(538, 71); + this.plotter1.TabIndex = 0; + this.plotter1.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotter1.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotter1.TextMargin = new System.Windows.Forms.Padding(3); + this.plotter1.TextPadding = new System.Windows.Forms.Padding(3); + this.plotter1.TextPosition = System.Drawing.ContentAlignment.TopLeft; + this.plotter1.UseLongData = false; + this.plotter1.UseSecondLine = true; + // // NetInfoWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(573, 353); this.Controls.Add(this.label25); this.Controls.Add(this.label26); diff --git a/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.cs b/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.cs index c254f01ac..9ec37bffd 100644 --- a/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.cs @@ -251,9 +251,9 @@ public string Speed(int index) /// public class NetworkMonitor { - private readonly System.Timers.Timer timer; // The timer event executes every second to refresh the values in adapters. - private readonly ArrayList adapters; // The list of adapters on the computer. - private readonly ArrayList monitoredAdapters; // The list of currently monitored adapters. + private System.Timers.Timer timer; // The timer event executes every second to refresh the values in adapters. + private ArrayList adapters; // The list of adapters on the computer. + private ArrayList monitoredAdapters; // The list of currently monitored adapters. /// /// NetworkMonitor @@ -265,7 +265,7 @@ public NetworkMonitor() this.EnumerateNetworkAdapters(); this.timer = new System.Timers.Timer(1000); - this.timer.Elapsed += this.timer_Elapsed; + this.timer.Elapsed += new ElapsedEventHandler(this.timer_Elapsed); } /// diff --git a/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.resx b/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.resx index bb3c53021..93f75a972 100644 --- a/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/NetInfoWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs index a59f10aff..d0d92eca5 100644 --- a/1.x/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/OptionsWindow.Designer.cs @@ -39,6 +39,7 @@ private void InitializeComponent() this.tabGeneral = new System.Windows.Forms.TabPage(); this.label20 = new System.Windows.Forms.Label(); this.comboToolbarStyle = new System.Windows.Forms.ComboBox(); + this.checkFloatChildWindows = new System.Windows.Forms.CheckBox(); this.checkScrollDownProcessTree = new System.Windows.Forms.CheckBox(); this.checkAllowOnlyOneInstance = new System.Windows.Forms.CheckBox(); this.buttonFont = new System.Windows.Forms.Button(); @@ -67,10 +68,14 @@ private void InitializeComponent() this.label11 = new System.Windows.Forms.Label(); this.buttonDisableAll = new System.Windows.Forms.Button(); this.buttonEnableAll = new System.Windows.Forms.Button(); + this.listHighlightingColors = new ProcessHacker.Components.ExtendedListView(); + this.columnDescription = new System.Windows.Forms.ColumnHeader(); this.textHighlightingDuration = new System.Windows.Forms.NumericUpDown(); this.label7 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); + this.colorRemovedProcesses = new ProcessHacker.Components.ColorModifier(); + this.colorNewProcesses = new ProcessHacker.Components.ColorModifier(); this.tabPlotting = new System.Windows.Forms.TabPage(); this.textStep = new System.Windows.Forms.NumericUpDown(); this.label8 = new System.Windows.Forms.Label(); @@ -81,6 +86,12 @@ private void InitializeComponent() this.label15 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label(); + this.colorIORO = new ProcessHacker.Components.ColorModifier(); + this.colorIOW = new ProcessHacker.Components.ColorModifier(); + this.colorMemoryWS = new ProcessHacker.Components.ColorModifier(); + this.colorMemoryPB = new ProcessHacker.Components.ColorModifier(); + this.colorCPUUT = new ProcessHacker.Components.ColorModifier(); + this.colorCPUKT = new ProcessHacker.Components.ColorModifier(); this.tabSymbols = new System.Windows.Forms.TabPage(); this.checkUndecorate = new System.Windows.Forms.CheckBox(); this.textSearchPath = new System.Windows.Forms.TextBox(); @@ -97,16 +108,6 @@ private void InitializeComponent() this.buttonCancel = new System.Windows.Forms.Button(); this.buttonApply = new System.Windows.Forms.Button(); this.buttonReset = new System.Windows.Forms.Button(); - this.listHighlightingColors = new ProcessHacker.Components.ExtendedListView(); - this.columnDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colorRemovedProcesses = new ProcessHacker.Components.ColorModifier(); - this.colorNewProcesses = new ProcessHacker.Components.ColorModifier(); - this.colorIORO = new ProcessHacker.Components.ColorModifier(); - this.colorIOW = new ProcessHacker.Components.ColorModifier(); - this.colorMemoryWS = new ProcessHacker.Components.ColorModifier(); - this.colorMemoryPB = new ProcessHacker.Components.ColorModifier(); - this.colorCPUUT = new ProcessHacker.Components.ColorModifier(); - this.colorCPUKT = new ProcessHacker.Components.ColorModifier(); ((System.ComponentModel.ISupportInitialize)(this.textUpdateInterval)).BeginInit(); this.tabControl.SuspendLayout(); this.tabGeneral.SuspendLayout(); @@ -137,7 +138,7 @@ private void InitializeComponent() 0, 0, 0}); - this.textUpdateInterval.Location = new System.Drawing.Point(136, 6); + this.textUpdateInterval.Location = new System.Drawing.Point(134, 6); this.textUpdateInterval.Maximum = new decimal(new int[] { 10000, 0, @@ -203,18 +204,18 @@ private void InitializeComponent() // // textSearchEngine // - this.textSearchEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textSearchEngine.Location = new System.Drawing.Point(136, 58); + this.textSearchEngine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textSearchEngine.Location = new System.Drawing.Point(134, 58); this.textSearchEngine.Name = "textSearchEngine"; - this.textSearchEngine.Size = new System.Drawing.Size(339, 20); + this.textSearchEngine.Size = new System.Drawing.Size(341, 20); this.textSearchEngine.TabIndex = 2; // // tabControl // - this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tabControl.Controls.Add(this.tabGeneral); this.tabControl.Controls.Add(this.tabAdvanced); this.tabControl.Controls.Add(this.tabHighlighting); @@ -231,6 +232,7 @@ private void InitializeComponent() // this.tabGeneral.Controls.Add(this.label20); this.tabGeneral.Controls.Add(this.comboToolbarStyle); + this.tabGeneral.Controls.Add(this.checkFloatChildWindows); this.tabGeneral.Controls.Add(this.checkScrollDownProcessTree); this.tabGeneral.Controls.Add(this.checkAllowOnlyOneInstance); this.tabGeneral.Controls.Add(this.buttonFont); @@ -279,6 +281,17 @@ private void InitializeComponent() this.comboToolbarStyle.Size = new System.Drawing.Size(135, 21); this.comboToolbarStyle.TabIndex = 18; // + // checkFloatChildWindows + // + this.checkFloatChildWindows.AutoSize = true; + this.checkFloatChildWindows.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.checkFloatChildWindows.Location = new System.Drawing.Point(211, 199); + this.checkFloatChildWindows.Name = "checkFloatChildWindows"; + this.checkFloatChildWindows.Size = new System.Drawing.Size(124, 18); + this.checkFloatChildWindows.TabIndex = 10; + this.checkFloatChildWindows.Text = "Float child windows"; + this.checkFloatChildWindows.UseVisualStyleBackColor = true; + // // checkScrollDownProcessTree // this.checkScrollDownProcessTree.AutoSize = true; @@ -314,11 +327,11 @@ private void InitializeComponent() // // textImposterNames // - this.textImposterNames.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textImposterNames.Location = new System.Drawing.Point(136, 84); + this.textImposterNames.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textImposterNames.Location = new System.Drawing.Point(134, 84); this.textImposterNames.Name = "textImposterNames"; - this.textImposterNames.Size = new System.Drawing.Size(339, 20); + this.textImposterNames.Size = new System.Drawing.Size(341, 20); this.textImposterNames.TabIndex = 3; // // label21 @@ -401,7 +414,7 @@ private void InitializeComponent() // // textIconMenuProcesses // - this.textIconMenuProcesses.Location = new System.Drawing.Point(136, 32); + this.textIconMenuProcesses.Location = new System.Drawing.Point(134, 32); this.textIconMenuProcesses.Minimum = new decimal(new int[] { 1, 0, @@ -434,7 +447,7 @@ private void InitializeComponent() this.tabAdvanced.Location = new System.Drawing.Point(4, 22); this.tabAdvanced.Name = "tabAdvanced"; this.tabAdvanced.Padding = new System.Windows.Forms.Padding(3); - this.tabAdvanced.Size = new System.Drawing.Size(481, 306); + this.tabAdvanced.Size = new System.Drawing.Size(481, 333); this.tabAdvanced.TabIndex = 3; this.tabAdvanced.Text = "Advanced"; this.tabAdvanced.UseVisualStyleBackColor = true; @@ -590,7 +603,7 @@ private void InitializeComponent() this.tabHighlighting.Location = new System.Drawing.Point(4, 22); this.tabHighlighting.Name = "tabHighlighting"; this.tabHighlighting.Padding = new System.Windows.Forms.Padding(3); - this.tabHighlighting.Size = new System.Drawing.Size(481, 306); + this.tabHighlighting.Size = new System.Drawing.Size(481, 333); this.tabHighlighting.TabIndex = 1; this.tabHighlighting.Text = "Highlighting"; this.tabHighlighting.UseVisualStyleBackColor = true; @@ -629,6 +642,33 @@ private void InitializeComponent() this.buttonEnableAll.UseVisualStyleBackColor = true; this.buttonEnableAll.Click += new System.EventHandler(this.buttonEnableAll_Click); // + // listHighlightingColors + // + this.listHighlightingColors.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listHighlightingColors.CheckBoxes = true; + this.listHighlightingColors.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnDescription}); + this.listHighlightingColors.DoubleClickChecks = false; + this.listHighlightingColors.FullRowSelect = true; + this.listHighlightingColors.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.listHighlightingColors.HideSelection = false; + this.listHighlightingColors.Location = new System.Drawing.Point(6, 60); + this.listHighlightingColors.MultiSelect = false; + this.listHighlightingColors.Name = "listHighlightingColors"; + this.listHighlightingColors.ShowItemToolTips = true; + this.listHighlightingColors.Size = new System.Drawing.Size(469, 238); + this.listHighlightingColors.TabIndex = 3; + this.listHighlightingColors.UseCompatibleStateImageBehavior = false; + this.listHighlightingColors.View = System.Windows.Forms.View.Details; + this.listHighlightingColors.DoubleClick += new System.EventHandler(this.listHighlightingColors_DoubleClick); + // + // columnDescription + // + this.columnDescription.Text = "Description"; + this.columnDescription.Width = 250; + // // textHighlightingDuration // this.textHighlightingDuration.Increment = new decimal(new int[] { @@ -636,7 +676,7 @@ private void InitializeComponent() 0, 0, 0}); - this.textHighlightingDuration.Location = new System.Drawing.Point(130, 7); + this.textHighlightingDuration.Location = new System.Drawing.Point(127, 7); this.textHighlightingDuration.Maximum = new decimal(new int[] { 10000, 0, @@ -683,6 +723,22 @@ private void InitializeComponent() this.label3.TabIndex = 7; this.label3.Text = "New Objects:"; // + // colorRemovedProcesses + // + this.colorRemovedProcesses.Color = System.Drawing.Color.Transparent; + this.colorRemovedProcesses.Location = new System.Drawing.Point(351, 34); + this.colorRemovedProcesses.Name = "colorRemovedProcesses"; + this.colorRemovedProcesses.Size = new System.Drawing.Size(40, 20); + this.colorRemovedProcesses.TabIndex = 2; + // + // colorNewProcesses + // + this.colorNewProcesses.Color = System.Drawing.Color.Transparent; + this.colorNewProcesses.Location = new System.Drawing.Point(127, 33); + this.colorNewProcesses.Name = "colorNewProcesses"; + this.colorNewProcesses.Size = new System.Drawing.Size(40, 20); + this.colorNewProcesses.TabIndex = 1; + // // tabPlotting // this.tabPlotting.Controls.Add(this.textStep); @@ -703,14 +759,14 @@ private void InitializeComponent() this.tabPlotting.Location = new System.Drawing.Point(4, 22); this.tabPlotting.Name = "tabPlotting"; this.tabPlotting.Padding = new System.Windows.Forms.Padding(3); - this.tabPlotting.Size = new System.Drawing.Size(481, 306); + this.tabPlotting.Size = new System.Drawing.Size(481, 333); this.tabPlotting.TabIndex = 2; this.tabPlotting.Text = "Plotting"; this.tabPlotting.UseVisualStyleBackColor = true; // // textStep // - this.textStep.Location = new System.Drawing.Point(44, 6); + this.textStep.Location = new System.Drawing.Point(44, 30); this.textStep.Minimum = new decimal(new int[] { 1, 0, @@ -728,7 +784,7 @@ private void InitializeComponent() // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(6, 8); + this.label8.Location = new System.Drawing.Point(6, 32); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(32, 13); this.label8.TabIndex = 8; @@ -738,7 +794,7 @@ private void InitializeComponent() // this.checkPlotterAntialias.AutoSize = true; this.checkPlotterAntialias.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.checkPlotterAntialias.Location = new System.Drawing.Point(124, 8); + this.checkPlotterAntialias.Location = new System.Drawing.Point(6, 6); this.checkPlotterAntialias.Name = "checkPlotterAntialias"; this.checkPlotterAntialias.Size = new System.Drawing.Size(110, 18); this.checkPlotterAntialias.TabIndex = 0; @@ -748,7 +804,7 @@ private void InitializeComponent() // label12 // this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(6, 141); + this.label12.Location = new System.Drawing.Point(6, 165); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(92, 13); this.label12.TabIndex = 13; @@ -757,7 +813,7 @@ private void InitializeComponent() // label13 // this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(6, 166); + this.label13.Location = new System.Drawing.Point(6, 190); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(59, 13); this.label13.TabIndex = 14; @@ -766,7 +822,7 @@ private void InitializeComponent() // label14 // this.label14.AutoSize = true; - this.label14.Location = new System.Drawing.Point(6, 115); + this.label14.Location = new System.Drawing.Point(6, 139); this.label14.Name = "label14"; this.label14.Size = new System.Drawing.Size(69, 13); this.label14.TabIndex = 12; @@ -775,7 +831,7 @@ private void InitializeComponent() // label15 // this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(6, 89); + this.label15.Location = new System.Drawing.Point(6, 113); this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(72, 13); this.label15.TabIndex = 11; @@ -784,7 +840,7 @@ private void InitializeComponent() // label16 // this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(6, 64); + this.label16.Location = new System.Drawing.Point(6, 88); this.label16.Name = "label16"; this.label16.Size = new System.Drawing.Size(83, 13); this.label16.TabIndex = 10; @@ -793,12 +849,60 @@ private void InitializeComponent() // label17 // this.label17.AutoSize = true; - this.label17.Location = new System.Drawing.Point(6, 38); + this.label17.Location = new System.Drawing.Point(6, 62); this.label17.Name = "label17"; this.label17.Size = new System.Drawing.Size(91, 13); this.label17.TabIndex = 9; this.label17.Text = "CPU Kernel Time:"; // + // colorIORO + // + this.colorIORO.Color = System.Drawing.Color.Transparent; + this.colorIORO.Location = new System.Drawing.Point(124, 163); + this.colorIORO.Name = "colorIORO"; + this.colorIORO.Size = new System.Drawing.Size(40, 20); + this.colorIORO.TabIndex = 6; + // + // colorIOW + // + this.colorIOW.Color = System.Drawing.Color.Transparent; + this.colorIOW.Location = new System.Drawing.Point(124, 189); + this.colorIOW.Name = "colorIOW"; + this.colorIOW.Size = new System.Drawing.Size(40, 20); + this.colorIOW.TabIndex = 7; + // + // colorMemoryWS + // + this.colorMemoryWS.Color = System.Drawing.Color.Transparent; + this.colorMemoryWS.Location = new System.Drawing.Point(124, 137); + this.colorMemoryWS.Name = "colorMemoryWS"; + this.colorMemoryWS.Size = new System.Drawing.Size(40, 20); + this.colorMemoryWS.TabIndex = 5; + // + // colorMemoryPB + // + this.colorMemoryPB.Color = System.Drawing.Color.Transparent; + this.colorMemoryPB.Location = new System.Drawing.Point(124, 111); + this.colorMemoryPB.Name = "colorMemoryPB"; + this.colorMemoryPB.Size = new System.Drawing.Size(40, 20); + this.colorMemoryPB.TabIndex = 4; + // + // colorCPUUT + // + this.colorCPUUT.Color = System.Drawing.Color.Transparent; + this.colorCPUUT.Location = new System.Drawing.Point(124, 85); + this.colorCPUUT.Name = "colorCPUUT"; + this.colorCPUUT.Size = new System.Drawing.Size(40, 20); + this.colorCPUUT.TabIndex = 3; + // + // colorCPUKT + // + this.colorCPUKT.Color = System.Drawing.Color.Transparent; + this.colorCPUKT.Location = new System.Drawing.Point(124, 59); + this.colorCPUKT.Name = "colorCPUKT"; + this.colorCPUKT.Size = new System.Drawing.Size(40, 20); + this.colorCPUKT.TabIndex = 2; + // // tabSymbols // this.tabSymbols.Controls.Add(this.checkUndecorate); @@ -810,7 +914,7 @@ private void InitializeComponent() this.tabSymbols.Location = new System.Drawing.Point(4, 22); this.tabSymbols.Name = "tabSymbols"; this.tabSymbols.Padding = new System.Windows.Forms.Padding(3); - this.tabSymbols.Size = new System.Drawing.Size(481, 306); + this.tabSymbols.Size = new System.Drawing.Size(481, 333); this.tabSymbols.TabIndex = 4; this.tabSymbols.Text = "Symbols"; this.tabSymbols.UseVisualStyleBackColor = true; @@ -828,11 +932,11 @@ private void InitializeComponent() // // textSearchPath // - this.textSearchPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textSearchPath.Location = new System.Drawing.Point(110, 34); + this.textSearchPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textSearchPath.Location = new System.Drawing.Point(99, 34); this.textSearchPath.Name = "textSearchPath"; - this.textSearchPath.Size = new System.Drawing.Size(365, 20); + this.textSearchPath.Size = new System.Drawing.Size(376, 20); this.textSearchPath.TabIndex = 2; // // label10 @@ -858,11 +962,11 @@ private void InitializeComponent() // // textDbghelpPath // - this.textDbghelpPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textDbghelpPath.Location = new System.Drawing.Point(110, 8); + this.textDbghelpPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textDbghelpPath.Location = new System.Drawing.Point(99, 8); this.textDbghelpPath.Name = "textDbghelpPath"; - this.textDbghelpPath.Size = new System.Drawing.Size(284, 20); + this.textDbghelpPath.Size = new System.Drawing.Size(295, 20); this.textDbghelpPath.TabIndex = 0; // // label9 @@ -884,7 +988,7 @@ private void InitializeComponent() this.tabUpdates.Location = new System.Drawing.Point(4, 22); this.tabUpdates.Name = "tabUpdates"; this.tabUpdates.Padding = new System.Windows.Forms.Padding(3); - this.tabUpdates.Size = new System.Drawing.Size(481, 306); + this.tabUpdates.Size = new System.Drawing.Size(481, 333); this.tabUpdates.TabIndex = 5; this.tabUpdates.Text = "Updates"; this.tabUpdates.UseVisualStyleBackColor = true; @@ -892,7 +996,6 @@ private void InitializeComponent() // checkUpdateAutomatically // this.checkUpdateAutomatically.AutoSize = true; - this.checkUpdateAutomatically.Enabled = false; this.checkUpdateAutomatically.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkUpdateAutomatically.Location = new System.Drawing.Point(6, 6); this.checkUpdateAutomatically.Name = "checkUpdateAutomatically"; @@ -914,7 +1017,6 @@ private void InitializeComponent() // this.optUpdateStable.AutoSize = true; this.optUpdateStable.Checked = true; - this.optUpdateStable.Enabled = false; this.optUpdateStable.FlatStyle = System.Windows.Forms.FlatStyle.System; this.optUpdateStable.Location = new System.Drawing.Point(68, 30); this.optUpdateStable.Name = "optUpdateStable"; @@ -927,7 +1029,6 @@ private void InitializeComponent() // optUpdateBeta // this.optUpdateBeta.AutoSize = true; - this.optUpdateBeta.Enabled = false; this.optUpdateBeta.FlatStyle = System.Windows.Forms.FlatStyle.System; this.optUpdateBeta.Location = new System.Drawing.Point(68, 54); this.optUpdateBeta.Name = "optUpdateBeta"; @@ -939,7 +1040,6 @@ private void InitializeComponent() // optUpdateAlpha // this.optUpdateAlpha.AutoSize = true; - this.optUpdateAlpha.Enabled = false; this.optUpdateAlpha.FlatStyle = System.Windows.Forms.FlatStyle.System; this.optUpdateAlpha.Location = new System.Drawing.Point(68, 78); this.optUpdateAlpha.Name = "optUpdateAlpha"; @@ -984,126 +1084,27 @@ private void InitializeComponent() this.buttonReset.UseVisualStyleBackColor = true; this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click); // - // listHighlightingColors - // - this.listHighlightingColors.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listHighlightingColors.CheckBoxes = true; - this.listHighlightingColors.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnDescription}); - this.listHighlightingColors.DoubleClickChecks = false; - this.listHighlightingColors.FullRowSelect = true; - this.listHighlightingColors.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; - this.listHighlightingColors.HideSelection = false; - this.listHighlightingColors.Location = new System.Drawing.Point(6, 60); - this.listHighlightingColors.MultiSelect = false; - this.listHighlightingColors.Name = "listHighlightingColors"; - this.listHighlightingColors.ShowItemToolTips = true; - this.listHighlightingColors.Size = new System.Drawing.Size(469, 238); - this.listHighlightingColors.TabIndex = 3; - this.listHighlightingColors.UseCompatibleStateImageBehavior = false; - this.listHighlightingColors.View = System.Windows.Forms.View.Details; - this.listHighlightingColors.DoubleClick += new System.EventHandler(this.listHighlightingColors_DoubleClick); - // - // columnDescription - // - this.columnDescription.Text = "Description"; - this.columnDescription.Width = 250; - // - // colorRemovedProcesses - // - this.colorRemovedProcesses.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorRemovedProcesses.Color = System.Drawing.Color.Transparent; - this.colorRemovedProcesses.Location = new System.Drawing.Point(351, 34); - this.colorRemovedProcesses.Name = "colorRemovedProcesses"; - this.colorRemovedProcesses.Size = new System.Drawing.Size(40, 20); - this.colorRemovedProcesses.TabIndex = 2; - // - // colorNewProcesses - // - this.colorNewProcesses.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorNewProcesses.Color = System.Drawing.Color.Transparent; - this.colorNewProcesses.Location = new System.Drawing.Point(130, 33); - this.colorNewProcesses.Name = "colorNewProcesses"; - this.colorNewProcesses.Size = new System.Drawing.Size(40, 20); - this.colorNewProcesses.TabIndex = 1; - // - // colorIORO - // - this.colorIORO.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorIORO.Color = System.Drawing.Color.Transparent; - this.colorIORO.Location = new System.Drawing.Point(124, 139); - this.colorIORO.Name = "colorIORO"; - this.colorIORO.Size = new System.Drawing.Size(40, 20); - this.colorIORO.TabIndex = 6; - // - // colorIOW - // - this.colorIOW.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorIOW.Color = System.Drawing.Color.Transparent; - this.colorIOW.Location = new System.Drawing.Point(124, 165); - this.colorIOW.Name = "colorIOW"; - this.colorIOW.Size = new System.Drawing.Size(40, 20); - this.colorIOW.TabIndex = 7; - // - // colorMemoryWS - // - this.colorMemoryWS.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorMemoryWS.Color = System.Drawing.Color.Transparent; - this.colorMemoryWS.Location = new System.Drawing.Point(124, 113); - this.colorMemoryWS.Name = "colorMemoryWS"; - this.colorMemoryWS.Size = new System.Drawing.Size(40, 20); - this.colorMemoryWS.TabIndex = 5; - // - // colorMemoryPB - // - this.colorMemoryPB.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorMemoryPB.Color = System.Drawing.Color.Transparent; - this.colorMemoryPB.Location = new System.Drawing.Point(124, 87); - this.colorMemoryPB.Name = "colorMemoryPB"; - this.colorMemoryPB.Size = new System.Drawing.Size(40, 20); - this.colorMemoryPB.TabIndex = 4; - // - // colorCPUUT - // - this.colorCPUUT.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorCPUUT.Color = System.Drawing.Color.Transparent; - this.colorCPUUT.Location = new System.Drawing.Point(124, 61); - this.colorCPUUT.Name = "colorCPUUT"; - this.colorCPUUT.Size = new System.Drawing.Size(40, 20); - this.colorCPUUT.TabIndex = 3; - // - // colorCPUKT - // - this.colorCPUKT.BackColor = System.Drawing.Color.WhiteSmoke; - this.colorCPUKT.Color = System.Drawing.Color.Transparent; - this.colorCPUKT.Location = new System.Drawing.Point(124, 35); - this.colorCPUKT.Name = "colorCPUKT"; - this.colorCPUKT.Size = new System.Drawing.Size(40, 20); - this.colorCPUKT.TabIndex = 2; - // // OptionsWindow // this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(513, 385); this.Controls.Add(this.buttonReset); this.Controls.Add(this.buttonApply); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.tabControl); this.Controls.Add(this.buttonOK); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "OptionsWindow"; + this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Options"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OptionsWindow_FormClosing); this.Load += new System.EventHandler(this.OptionsWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OptionsWindow_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.textUpdateInterval)).EndInit(); this.tabControl.ResumeLayout(false); this.tabGeneral.ResumeLayout(false); @@ -1194,6 +1195,7 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox checkEnableExperimentalFeatures; private System.Windows.Forms.Label label11; private System.Windows.Forms.CheckBox checkScrollDownProcessTree; + private System.Windows.Forms.CheckBox checkFloatChildWindows; private System.Windows.Forms.TabPage tabUpdates; private System.Windows.Forms.Label label5; private System.Windows.Forms.RadioButton optUpdateAlpha; diff --git a/1.x/trunk/ProcessHacker/Forms/OptionsWindow.cs b/1.x/trunk/ProcessHacker/Forms/OptionsWindow.cs index 92069ce16..82e0182d7 100644 --- a/1.x/trunk/ProcessHacker/Forms/OptionsWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/OptionsWindow.cs @@ -32,17 +32,21 @@ using ProcessHacker.Native; using ProcessHacker.Native.Api; using ProcessHacker.Native.Objects; -using ProcessHacker.Native.Threading; using ProcessHacker.UI; +using System.Runtime.InteropServices; +using System.Net; +using System.Collections.Generic; +using System.Text.RegularExpressions; namespace ProcessHacker { public partial class OptionsWindow : Form { + private bool _isFirstPaint = true; private string _oldDbghelp; private string _oldTaskMgrDebugger; private Font _font; - private readonly bool _dontApply; + private bool _dontApply; public OptionsWindow() : this(false) @@ -51,13 +55,10 @@ public OptionsWindow() public OptionsWindow(bool dontApply) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); _dontApply = dontApply; - - this.LoadStage1(); } public TabPage SelectedTab @@ -83,6 +84,25 @@ private void OptionsWindow_Load(object sender, EventArgs e) } } + protected override void WndProc(ref Message m) + { + switch (m.Msg) + { + case (int)WindowMessage.Paint: + { + if (_isFirstPaint) + { + this.LoadStage1(); + } + + _isFirstPaint = false; + } + break; + } + + base.WndProc(ref m); + } + private void LoadStage1() { this.InitializeHighlightingColors(); @@ -118,9 +138,7 @@ private void LoadStage1() else if (c is ColorModifier) (c as ColorModifier).ColorChanged += (sender, e) => this.EnableApplyButton(); else if (c is Button || c is Label || c is GroupBox) - { - // Nothing - } + Program.Void(); // Nothing else c.Click += (sender, e) => this.EnableApplyButton(); } @@ -140,38 +158,54 @@ private void EnableApplyButton() private void AddToList(string key, string description, string longDescription) { - listHighlightingColors.Items.Add(new ListViewItem - { - Name = key, - Text = description, - ToolTipText = longDescription - }); + listHighlightingColors.Items.Add(new ListViewItem() + { + Name = key, + Text = description, + ToolTipText = longDescription + }); } private void InitializeHighlightingColors() { - AddToList("ColorOwnProcesses", "Own Processes", "Processes running under the same user account as Process Hacker."); - AddToList("ColorSystemProcesses", "System Processes", "Processes running under the NT AUTHORITY\\SYSTEM user account."); - AddToList("ColorServiceProcesses", "Service Processes", "Processes which host one or more services."); - AddToList("ColorDebuggedProcesses", "Debugged Processes", "Processes that are currently being debugged."); - AddToList("ColorElevatedProcesses", "Elevated Processes", "Processes with full privileges on a Windows Vista system with UAC enabled."); - AddToList("ColorJobProcesses", "Job Processes", "Processes associated with a job."); - AddToList("ColorDotNetProcesses", ".NET Processes and DLLs", ".NET, or managed processes and DLLs."); - AddToList("ColorPosixProcesses", "POSIX Processes", "Processes running under the POSIX subsystem."); - AddToList("ColorPackedProcesses", "Packed/Dangerous Processes", "Executables are sometimes \"packed\" to reduce their size.\n" + - "\"Dangerous processes\" includes processes with invalid signatures and unverified " + "processes with the name of a system process."); + AddToList("ColorOwnProcesses", "Own Processes", + "Processes running under the same user account as Process Hacker."); + AddToList("ColorSystemProcesses", "System Processes", + "Processes running under the NT AUTHORITY\\SYSTEM user account."); + AddToList("ColorServiceProcesses", "Service Processes", + "Processes which host one or more services."); + AddToList("ColorDebuggedProcesses", "Debugged Processes", + "Processes that are currently being debugged."); + AddToList("ColorElevatedProcesses", "Elevated Processes", + "Processes with full privileges on a Windows Vista system with UAC enabled."); + AddToList("ColorJobProcesses", "Job Processes", + "Processes associated with a job."); + AddToList("ColorDotNetProcesses", ".NET Processes and DLLs", + ".NET, or managed processes and DLLs."); + AddToList("ColorPosixProcesses", "POSIX Processes", + "Processes running under the POSIX subsystem."); + AddToList("ColorPackedProcesses", "Packed/Dangerous Processes", + "Executables are sometimes \"packed\" to reduce their size.\n" + + "\"Dangerous processes\" includes processes with invalid signatures and unverified " + + "processes with the name of a system process."); // WOW64, 64-bit only. if (OSVersion.Architecture == OSArch.Amd64) { - AddToList("ColorWow64Processes", "32-bit Processes", "Processes running under WOW64, i.e. 32-bit."); + AddToList("ColorWow64Processes", "32-bit Processes", + "Processes running under WOW64, i.e. 32-bit."); } - AddToList("ColorSuspended", "Suspended Threads","Threads that are suspended from execution."); - AddToList("ColorGuiThreads", "GUI Threads", "Threads that have made at least one GUI-related system call."); - AddToList("ColorRelocatedDlls", "Relocated DLLs", "DLLs that were not loaded at their preferred image bases."); - AddToList("ColorProtectedHandles", "Protected Handles", "Handles that are protected from being closed."); - AddToList("ColorInheritHandles", "Inherit Handles", "Handles that are to be inherited by any child processes."); + AddToList("ColorSuspended", "Suspended Threads", + "Threads that are suspended from execution."); + AddToList("ColorGuiThreads", "GUI Threads", + "Threads that have made at least one GUI-related system call."); + AddToList("ColorRelocatedDlls", "Relocated DLLs", + "DLLs that were not loaded at their preferred image bases."); + AddToList("ColorProtectedHandles", "Protected Handles", + "Handles that are protected from being closed."); + AddToList("ColorInheritHandles", "Inherit Handles", + "Handles that are to be inherited by any child processes."); } private void listHighlightingColors_DoubleClick(object sender, EventArgs e) @@ -233,10 +267,12 @@ private void LoadSettings() checkAllowOnlyOneInstance.Checked = Settings.Instance.AllowOnlyOneInstance; checkVerifySignatures.Checked = Settings.Instance.VerifySignatures; checkHideHandlesWithNoName.Checked = Settings.Instance.HideHandlesWithNoName; + checkEnableKPH.Enabled = OSVersion.Architecture == OSArch.I386; checkEnableKPH.Checked = Settings.Instance.EnableKPH; checkEnableExperimentalFeatures.Checked = Settings.Instance.EnableExperimentalFeatures; checkStartHidden.Checked = Settings.Instance.StartHidden; checkScrollDownProcessTree.Checked = Settings.Instance.ScrollDownProcessTree; + checkFloatChildWindows.Checked = Settings.Instance.FloatChildWindows; checkHidePhConnections.Checked = Settings.Instance.HideProcessHackerNetworkConnections; if (OSVersion.HasUac) @@ -301,7 +337,7 @@ private void LoadSettings() try { - if (!Array.Exists(key.GetSubKeyNames(), s => s.Equals("taskmgr.exe", StringComparison.OrdinalIgnoreCase))) + if (!Array.Exists(key.GetSubKeyNames(), s => s.Equals("taskmgr.exe", StringComparison.OrdinalIgnoreCase))) key.CreateSubKey("taskmgr.exe"); Microsoft.Win32.Registry.LocalMachine.OpenSubKey( @@ -326,8 +362,8 @@ private void LoadSettings() false )) { - if ((_oldTaskMgrDebugger = (string)key.GetValue("Debugger", string.Empty)).Trim('"').Equals( - ProcessHandle.Current.MainModule.FileName, StringComparison.OrdinalIgnoreCase)) + if ((_oldTaskMgrDebugger = (string)key.GetValue("Debugger", "")).Trim('"').Equals( + ProcessHandle.Current.GetMainModule().FileName, StringComparison.OrdinalIgnoreCase)) { checkReplaceTaskManager.Checked = true; } @@ -393,6 +429,7 @@ private void SaveSettings() Settings.Instance.VerifySignatures = checkVerifySignatures.Checked; Settings.Instance.HideHandlesWithNoName = checkHideHandlesWithNoName.Checked; Settings.Instance.ScrollDownProcessTree = checkScrollDownProcessTree.Checked; + Settings.Instance.FloatChildWindows = checkFloatChildWindows.Checked; Settings.Instance.StartHidden = checkStartHidden.Checked; Settings.Instance.EnableKPH = checkEnableKPH.Checked; Settings.Instance.EnableExperimentalFeatures = checkEnableExperimentalFeatures.Checked; @@ -403,7 +440,7 @@ private void SaveSettings() Settings.Instance.MaxSamples = (int)textMaxSamples.Value; Program.ProcessProvider.HistoryMaxSize = Settings.Instance.MaxSamples; Settings.Instance.PlotterStep = (int)textStep.Value; - Plotter.GlobalMoveStep = Settings.Instance.PlotterStep; + ProcessHacker.Components.Plotter.GlobalMoveStep = Settings.Instance.PlotterStep; Settings.Instance.HighlightingDuration = (int)textHighlightingDuration.Value; Settings.Instance.ColorNew = colorNewProcesses.Color; @@ -466,7 +503,7 @@ private void SaveSettings() { try { - string fileName = ProcessHandle.Current.MainModule.FileName; + string fileName = ProcessHandle.Current.GetMainModule().FileName; using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey( "Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\taskmgr.exe", @@ -486,7 +523,7 @@ private void SaveSettings() if (_oldTaskMgrDebugger.Trim('"').Equals(fileName, StringComparison.OrdinalIgnoreCase)) { key.DeleteValue("Debugger"); - _oldTaskMgrDebugger = string.Empty; + _oldTaskMgrDebugger = ""; } } } @@ -547,19 +584,17 @@ private void buttonCancel_Click(object sender, EventArgs e) private void buttonFont_Click(object sender, EventArgs e) { - using (FontDialog fd = new FontDialog - { - Font = this._font, - FontMustExist = true, - ShowEffects = true - }) + FontDialog fd = new FontDialog(); + + fd.Font = _font; + fd.FontMustExist = true; + fd.ShowEffects = true; + + if (fd.ShowDialog() == DialogResult.OK) { - if (fd.ShowDialog() == DialogResult.OK) - { - _font = fd.Font; - buttonFont.Font = _font; - this.EnableApplyButton(); - } + _font = fd.Font; + buttonFont.Font = _font; + this.EnableApplyButton(); } } @@ -571,26 +606,28 @@ private void buttonChangeReplaceTaskManager_Click(object sender, EventArgs e) buttonApply.Enabled = false; string args = "-o -hwnd " + this.Handle.ToString() + - " -rect " + this.Location.X.ToString() + "," + this.Location.Y.ToString() + "," + - this.Size.Width.ToString() + "," + this.Size.Height.ToString(); + " -rect " + this.Location.X.ToString() + "," + this.Location.Y.ToString() + "," + + this.Size.Width.ToString() + "," + this.Size.Height.ToString(); - NativeThreadPool.QueueWorkItem(thisHandle => - { - Program.StartProcessHackerAdminWait(args, (IntPtr)thisHandle, 0xffffffff); + // Avoid cross-thread operation. + IntPtr thisHandle = this.Handle; - this.BeginInvoke(new MethodInvoker(() => + Thread t = new Thread(() => { - Settings.Instance.Reload(); - this.LoadSettings(); + Program.StartProcessHackerAdminWait(args, thisHandle, 0xffffffff); - if (!_dontApply) - this.ApplySettings(); - - buttonApply.Enabled = false; - buttonOK.Select(); - })); - - }, this.Handle); + this.BeginInvoke(new MethodInvoker(() => + { + Settings.Instance.Reload(); + this.LoadSettings(); + if (!_dontApply) + this.ApplySettings(); + buttonApply.Enabled = false; + buttonOK.Select(); + })); + }, Utils.SixteenthStackSize); + + t.Start(); } private void buttonEnableAll_Click(object sender, EventArgs e) @@ -611,15 +648,13 @@ private void buttonDisableAll_Click(object sender, EventArgs e) private void buttonDbghelpBrowse_Click(object sender, EventArgs e) { - using (OpenFileDialog ofd = new OpenFileDialog - { - Filter = "dbghelp.dll|dbghelp.dll|DLL files (*.dll)|*.dll|All files (*.*)|*.*", - FileName = this.textDbghelpPath.Text - }) - { - if (ofd.ShowDialog() == DialogResult.OK) - textDbghelpPath.Text = ofd.FileName; - } + OpenFileDialog ofd = new OpenFileDialog(); + + ofd.Filter = "dbghelp.dll|dbghelp.dll|DLL files (*.dll)|*.dll|All files (*.*)|*.*"; + ofd.FileName = textDbghelpPath.Text; + + if (ofd.ShowDialog() == DialogResult.OK) + textDbghelpPath.Text = ofd.FileName; } private void buttonApply_Click(object sender, EventArgs e) @@ -636,7 +671,7 @@ private void buttonReset_Click(object sender, EventArgs e) { Settings.Instance.Reset(); Program.GlobalMutex.Dispose(); - Program.TryStart(ProcessHandle.Current.MainModule.FileName); + Program.TryStart(ProcessHandle.Current.GetMainModule().FileName); Program.HackerWindow.Exit(false); } } diff --git a/1.x/trunk/ProcessHacker/Forms/OptionsWindow.resx b/1.x/trunk/ProcessHacker/Forms/OptionsWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/OptionsWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/OptionsWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/PEWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/PEWindow.Designer.cs index 333d6811c..a69c4c5d2 100644 --- a/1.x/trunk/ProcessHacker/Forms/PEWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/PEWindow.Designer.cs @@ -1,8 +1,6 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { - sealed partial class PEWindow + partial class PEWindow { /// /// Required designer variable. @@ -33,37 +31,39 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PEWindow)); this.tabControl = new System.Windows.Forms.TabControl(); this.tabCOFFHeader = new System.Windows.Forms.TabPage(); - this.listCOFFHeader = new ProcessHacker.Components.ExtendedListView(); - this.columnCHName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnCHValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listCOFFHeader = new System.Windows.Forms.ListView(); + this.columnCHName = new System.Windows.Forms.ColumnHeader(); + this.columnCHValue = new System.Windows.Forms.ColumnHeader(); this.tabCOFFOptionalHeader = new System.Windows.Forms.TabPage(); - this.listCOFFOptionalHeader = new ProcessHacker.Components.ExtendedListView(); - this.columnCOHName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnCOHValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listCOFFOptionalHeader = new System.Windows.Forms.ListView(); + this.columnCOHName = new System.Windows.Forms.ColumnHeader(); + this.columnCOHValue = new System.Windows.Forms.ColumnHeader(); this.tabImageData = new System.Windows.Forms.TabPage(); - this.listImageData = new ProcessHacker.Components.ExtendedListView(); - this.columnIDName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnIDRVA = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnIDSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listImageData = new System.Windows.Forms.ListView(); + this.columnIDName = new System.Windows.Forms.ColumnHeader(); + this.columnIDRVA = new System.Windows.Forms.ColumnHeader(); + this.columnIDSize = new System.Windows.Forms.ColumnHeader(); this.tabSections = new System.Windows.Forms.TabPage(); - this.listSections = new ProcessHacker.Components.ExtendedListView(); - this.columnSectionName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnSectionVA = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnSectionVS = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnSectionFileAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnSectionCharacteristics = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listSections = new System.Windows.Forms.ListView(); + this.columnSectionName = new System.Windows.Forms.ColumnHeader(); + this.columnSectionVA = new System.Windows.Forms.ColumnHeader(); + this.columnSectionVS = new System.Windows.Forms.ColumnHeader(); + this.columnSectionFileAddress = new System.Windows.Forms.ColumnHeader(); + this.columnSectionCharacteristics = new System.Windows.Forms.ColumnHeader(); this.tabExports = new System.Windows.Forms.TabPage(); - this.listExports = new ProcessHacker.Components.ExtendedListView(); - this.columnExportOrdinal = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnExportName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnExportFileAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listExports = new System.Windows.Forms.ListView(); + this.columnExportOrdinal = new System.Windows.Forms.ColumnHeader(); + this.columnExportName = new System.Windows.Forms.ColumnHeader(); + this.columnExportFileAddress = new System.Windows.Forms.ColumnHeader(); this.tabImports = new System.Windows.Forms.TabPage(); this.listImports = new ProcessHacker.Components.ExtendedListView(); - this.columnImportName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnImportHint = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnImportName = new System.Windows.Forms.ColumnHeader(); + this.columnImportHint = new System.Windows.Forms.ColumnHeader(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.tabControl.SuspendLayout(); this.tabCOFFHeader.SuspendLayout(); this.tabCOFFOptionalHeader.SuspendLayout(); @@ -71,23 +71,22 @@ private void InitializeComponent() this.tabSections.SuspendLayout(); this.tabExports.SuspendLayout(); this.tabImports.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // tabControl // - this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.tabControl.Controls.Add(this.tabCOFFHeader); this.tabControl.Controls.Add(this.tabCOFFOptionalHeader); this.tabControl.Controls.Add(this.tabImageData); this.tabControl.Controls.Add(this.tabSections); this.tabControl.Controls.Add(this.tabExports); this.tabControl.Controls.Add(this.tabImports); - this.tabControl.Location = new System.Drawing.Point(12, 12); + this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl.Location = new System.Drawing.Point(0, 0); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(439, 465); + this.tabControl.Size = new System.Drawing.Size(423, 402); this.tabControl.TabIndex = 0; // // tabCOFFHeader @@ -96,7 +95,7 @@ private void InitializeComponent() this.tabCOFFHeader.Location = new System.Drawing.Point(4, 22); this.tabCOFFHeader.Name = "tabCOFFHeader"; this.tabCOFFHeader.Padding = new System.Windows.Forms.Padding(3); - this.tabCOFFHeader.Size = new System.Drawing.Size(431, 439); + this.tabCOFFHeader.Size = new System.Drawing.Size(415, 376); this.tabCOFFHeader.TabIndex = 0; this.tabCOFFHeader.Text = "COFF Header"; this.tabCOFFHeader.UseVisualStyleBackColor = true; @@ -107,13 +106,12 @@ private void InitializeComponent() this.columnCHName, this.columnCHValue}); this.listCOFFHeader.Dock = System.Windows.Forms.DockStyle.Fill; - this.listCOFFHeader.DoubleClickChecks = true; this.listCOFFHeader.FullRowSelect = true; this.listCOFFHeader.HideSelection = false; this.listCOFFHeader.Location = new System.Drawing.Point(3, 3); this.listCOFFHeader.Name = "listCOFFHeader"; this.listCOFFHeader.ShowItemToolTips = true; - this.listCOFFHeader.Size = new System.Drawing.Size(425, 433); + this.listCOFFHeader.Size = new System.Drawing.Size(409, 370); this.listCOFFHeader.Sorting = System.Windows.Forms.SortOrder.Ascending; this.listCOFFHeader.TabIndex = 0; this.listCOFFHeader.UseCompatibleStateImageBehavior = false; @@ -146,7 +144,6 @@ private void InitializeComponent() this.columnCOHName, this.columnCOHValue}); this.listCOFFOptionalHeader.Dock = System.Windows.Forms.DockStyle.Fill; - this.listCOFFOptionalHeader.DoubleClickChecks = true; this.listCOFFOptionalHeader.FullRowSelect = true; this.listCOFFOptionalHeader.HideSelection = false; this.listCOFFOptionalHeader.Location = new System.Drawing.Point(3, 3); @@ -186,7 +183,6 @@ private void InitializeComponent() this.columnIDRVA, this.columnIDSize}); this.listImageData.Dock = System.Windows.Forms.DockStyle.Fill; - this.listImageData.DoubleClickChecks = true; this.listImageData.FullRowSelect = true; this.listImageData.HideSelection = false; this.listImageData.Location = new System.Drawing.Point(3, 3); @@ -232,7 +228,6 @@ private void InitializeComponent() this.columnSectionFileAddress, this.columnSectionCharacteristics}); this.listSections.Dock = System.Windows.Forms.DockStyle.Fill; - this.listSections.DoubleClickChecks = true; this.listSections.FullRowSelect = true; this.listSections.HideSelection = false; this.listSections.Location = new System.Drawing.Point(3, 3); @@ -285,7 +280,6 @@ private void InitializeComponent() this.columnExportName, this.columnExportFileAddress}); this.listExports.Dock = System.Windows.Forms.DockStyle.Fill; - this.listExports.DoubleClickChecks = true; this.listExports.FullRowSelect = true; this.listExports.HideSelection = false; this.listExports.Location = new System.Drawing.Point(3, 3); @@ -297,8 +291,8 @@ private void InitializeComponent() this.listExports.UseCompatibleStateImageBehavior = false; this.listExports.View = System.Windows.Forms.View.Details; this.listExports.VirtualMode = true; - this.listExports.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listExports_RetrieveVirtualItem); this.listExports.DoubleClick += new System.EventHandler(this.listExports_DoubleClick); + this.listExports.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listExports_RetrieveVirtualItem); // // columnExportOrdinal // @@ -354,18 +348,22 @@ private void InitializeComponent() this.columnImportHint.Text = "Hint"; this.columnImportHint.Width = 80; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // PEWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(463, 489); + this.ClientSize = new System.Drawing.Size(423, 402); this.Controls.Add(this.tabControl); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "PEWindow"; this.Text = "PE File"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PEWindow_FormClosing); this.Load += new System.EventHandler(this.PEWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PEWindow_FormClosing); this.tabControl.ResumeLayout(false); this.tabCOFFHeader.ResumeLayout(false); this.tabCOFFOptionalHeader.ResumeLayout(false); @@ -373,36 +371,38 @@ private void InitializeComponent() this.tabSections.ResumeLayout(false); this.tabExports.ResumeLayout(false); this.tabImports.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); } #endregion + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.TabControl tabControl; private System.Windows.Forms.TabPage tabCOFFHeader; private System.Windows.Forms.TabPage tabCOFFOptionalHeader; private System.Windows.Forms.TabPage tabSections; private System.Windows.Forms.TabPage tabExports; private System.Windows.Forms.TabPage tabImports; - private ExtendedListView listExports; + private System.Windows.Forms.ListView listExports; private System.Windows.Forms.ColumnHeader columnExportName; private System.Windows.Forms.ColumnHeader columnExportOrdinal; private System.Windows.Forms.ColumnHeader columnExportFileAddress; - private ExtendedListView listCOFFHeader; + private System.Windows.Forms.ListView listCOFFHeader; private System.Windows.Forms.ColumnHeader columnCHName; private System.Windows.Forms.ColumnHeader columnCHValue; - private ExtendedListView listCOFFOptionalHeader; + private System.Windows.Forms.ListView listCOFFOptionalHeader; private System.Windows.Forms.ColumnHeader columnCOHName; private System.Windows.Forms.ColumnHeader columnCOHValue; - private ExtendedListView listSections; + private System.Windows.Forms.ListView listSections; private System.Windows.Forms.ColumnHeader columnSectionName; private System.Windows.Forms.ColumnHeader columnSectionVA; private System.Windows.Forms.ColumnHeader columnSectionFileAddress; private System.Windows.Forms.ColumnHeader columnSectionCharacteristics; private System.Windows.Forms.ColumnHeader columnSectionVS; private System.Windows.Forms.TabPage tabImageData; - private ExtendedListView listImageData; + private System.Windows.Forms.ListView listImageData; private System.Windows.Forms.ColumnHeader columnIDName; private System.Windows.Forms.ColumnHeader columnIDRVA; private System.Windows.Forms.ColumnHeader columnIDSize; diff --git a/1.x/trunk/ProcessHacker/Forms/PEWindow.cs b/1.x/trunk/ProcessHacker/Forms/PEWindow.cs index 83c901b93..0146968df 100644 --- a/1.x/trunk/ProcessHacker/Forms/PEWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/PEWindow.cs @@ -32,10 +32,10 @@ namespace ProcessHacker { - public sealed partial class PEWindow : Form + public partial class PEWindow : Form { - private readonly string _path; - private readonly MappedImage _mappedImage; + private string _path; + private MappedImage _mappedImage; public PEWindow(string path) { @@ -44,7 +44,6 @@ public PEWindow(string path) this.SetTopMost(); _path = path; - this.Text = "PE File - " + path; Program.PEWindows.Add(Id, this); @@ -66,6 +65,8 @@ public PEWindow(string path) private void PEWindow_Load(object sender, EventArgs e) { this.Size = Settings.Instance.PEWindowSize; + + this.SetPhParent(); } private void PEWindow_FormClosing(object sender, FormClosingEventArgs e) @@ -86,26 +87,38 @@ private void PEWindow_FormClosing(object sender, FormClosingEventArgs e) private void InitializeLists() { + listCOFFHeader.SetDoubleBuffered(true); + listCOFFHeader.SetTheme("explorer"); listCOFFHeader.ContextMenu = listCOFFHeader.GetCopyMenu(); listCOFFHeader.AddShortcuts(); ColumnSettings.LoadSettings(Settings.Instance.PECOFFHColumns, listCOFFHeader); + listCOFFOptionalHeader.SetDoubleBuffered(true); + listCOFFOptionalHeader.SetTheme("explorer"); listCOFFOptionalHeader.ContextMenu = listCOFFOptionalHeader.GetCopyMenu(); listCOFFOptionalHeader.AddShortcuts(); ColumnSettings.LoadSettings(Settings.Instance.PECOFFOHColumns, listCOFFOptionalHeader); + listImageData.SetDoubleBuffered(true); + listImageData.SetTheme("explorer"); listImageData.ContextMenu = listImageData.GetCopyMenu(); listImageData.AddShortcuts(); ColumnSettings.LoadSettings(Settings.Instance.PEImageDataColumns, listImageData); + listSections.SetDoubleBuffered(true); + listSections.SetTheme("explorer"); listSections.ContextMenu = listSections.GetCopyMenu(); listSections.AddShortcuts(); ColumnSettings.LoadSettings(Settings.Instance.PESectionsColumns, listSections); + listExports.SetDoubleBuffered(true); + listExports.SetTheme("explorer"); listExports.ContextMenu = listExports.GetCopyMenu(listExports_RetrieveVirtualItem); listExports.AddShortcuts(this.listExports_RetrieveVirtualItem); ColumnSettings.LoadSettings(Settings.Instance.PEExportsColumns, listExports); + listImports.SetDoubleBuffered(true); + listImports.SetTheme("explorer"); listImports.ContextMenu = listImports.GetCopyMenu(); listImports.AddShortcuts(); ColumnSettings.LoadSettings(Settings.Instance.PEImportsColumns, listImports); @@ -212,11 +225,9 @@ private unsafe void Read() if (dataEntry != null && dataEntry->VirtualAddress != 0) { - ListViewItem item = new ListViewItem - { - Text = ((ImageDataEntry)i).ToString() - }; + ListViewItem item = new ListViewItem(); + item.Text = ((ImageDataEntry)i).ToString(); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "0x" + dataEntry->VirtualAddress.ToString("x"))); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "0x" + dataEntry->Size.ToString("x"))); @@ -233,11 +244,9 @@ private unsafe void Read() for (int i = 0; i < _mappedImage.NumberOfSections; i++) { ImageSectionHeader* section = &_mappedImage.Sections[i]; - ListViewItem item = new ListViewItem - { - Text = this._mappedImage.GetSectionName(section) - }; + ListViewItem item = new ListViewItem(); + item.Text = _mappedImage.GetSectionName(section); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "0x" + section->VirtualAddress.ToString("x"))); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "0x" + section->SizeOfRawData.ToString("x"))); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "0x" + section->PointerToRawData.ToString("x"))); @@ -299,17 +308,22 @@ private unsafe void Read() #endregion } - private unsafe void listExports_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) + private void listExports_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { - ImageExportEntry entry = this._mappedImage.Exports.GetEntry(e.ItemIndex); - ImageExportFunction function = this._mappedImage.Exports.GetFunction(entry.Ordinal); - - e.Item = new ListViewItem(new string[] + unsafe { - entry.Ordinal.ToString(), - !string.IsNullOrEmpty(function.ForwardedName) ? entry.Name + " > " + function.ForwardedName : entry.Name, - string.IsNullOrEmpty(function.ForwardedName) ? "0x" + function.Function.Decrement(new IntPtr(this._mappedImage.Memory)).ToString("x") : string.Empty - }); + var entry = _mappedImage.Exports.GetEntry(e.ItemIndex); + var function = _mappedImage.Exports.GetFunction(entry.Ordinal); + + e.Item = new ListViewItem(new string[] + { + entry.Ordinal.ToString(), + function.ForwardedName != null ? entry.Name + " > " + function.ForwardedName : entry.Name, + function.ForwardedName == null ? + "0x" + function.Function.Decrement(new IntPtr(_mappedImage.Memory)).ToString("x") : + "" + }); + } } private void listExports_DoubleClick(object sender, EventArgs e) @@ -330,9 +344,9 @@ private void listImports_GroupLinkClicked(object sender, ProcessHacker.Component { fileName = FileUtils.FindFile(System.IO.Path.GetDirectoryName(_path), e.Group.Header); - if (!string.IsNullOrEmpty(fileName)) + if (fileName != null) { - Program.GetPEWindow(fileName, Program.FocusWindow); + Program.GetPEWindow(fileName, (f) => Program.FocusWindow(f)); } else { diff --git a/1.x/trunk/ProcessHacker/Forms/PEWindow.resx b/1.x/trunk/ProcessHacker/Forms/PEWindow.resx index 12b61ce8c..d2605a850 100644 --- a/1.x/trunk/ProcessHacker/Forms/PEWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/PEWindow.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + 127, 17 + + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.Designer.cs index 71d883670..6be25606b 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.Designer.cs @@ -47,9 +47,9 @@ private void InitializeComponent() // // flowPanel // - this.flowPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.flowPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.flowPanel.AutoScroll = true; this.flowPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowPanel.Location = new System.Drawing.Point(12, 12); @@ -74,7 +74,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(448, 222); this.Controls.Add(this.buttonOK); this.Controls.Add(this.flowPanel); diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.cs b/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.cs index 1ed4907cc..b157c4d33 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.cs @@ -30,12 +30,11 @@ namespace ProcessHacker { public partial class ProcessAffinity : Form { - private readonly int _pid; + private int _pid; public ProcessAffinity(int pid) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); @@ -46,20 +45,21 @@ public ProcessAffinity(int pid) using (ProcessHandle phandle = new ProcessHandle(pid, ProcessAccess.QueryInformation)) { long systemMask; + long processMask; - long processMask = phandle.GetAffinityMask(out systemMask); + processMask = phandle.GetAffinityMask(out systemMask); for (int i = 0; (systemMask & (1 << i)) != 0; i++) { - CheckBox c = new CheckBox - { - Name = "cpu" + i, - Text = "CPU " + i, - Tag = i, - FlatStyle = FlatStyle.System, - Checked = (processMask & (1 << i)) != 0, - Margin = new Padding(3, 3, 3, 0) - }; + CheckBox c = new CheckBox(); + + c.Name = "cpu" + i.ToString(); + c.Text = "CPU " + i.ToString(); + c.Tag = i; + + c.FlatStyle = FlatStyle.System; + c.Checked = (processMask & (1 << i)) != 0; + c.Margin = new Padding(3, 3, 3, 0); flowPanel.Controls.Add(c); } @@ -93,7 +93,7 @@ private void buttonOK_Click(object sender, EventArgs e) try { using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.SetInformation)) - phandle.AffinityMask = newMask; + phandle.SetAffinityMask(newMask); this.Close(); } diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.resx b/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.resx +++ b/1.x/trunk/ProcessHacker/Forms/ProcessAffinity.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.Designer.cs index 9721a4965..75dfdf22c 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.Designer.cs @@ -61,15 +61,10 @@ private void InitializeComponent() // // treeProcesses // - this.treeProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.treeProcesses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.treeProcesses.Draw = true; - this.treeProcesses.DumpMode = false; - this.treeProcesses.DumpProcesses = null; - this.treeProcesses.DumpProcessServices = null; - this.treeProcesses.DumpServices = null; - this.treeProcesses.DumpUserName = null; this.treeProcesses.Location = new System.Drawing.Point(12, 28); this.treeProcesses.Name = "treeProcesses"; this.treeProcesses.Provider = null; @@ -80,8 +75,8 @@ private void InitializeComponent() // // labelLabel // - this.labelLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelLabel.AutoEllipsis = true; this.labelLabel.Location = new System.Drawing.Point(12, 9); this.labelLabel.Name = "labelLabel"; @@ -94,7 +89,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(485, 392); this.Controls.Add(this.labelLabel); this.Controls.Add(this.treeProcesses); @@ -107,8 +101,8 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Choose a Process"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProcessPickerWindow_FormClosing); this.Load += new System.EventHandler(this.ProcessPickerWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProcessPickerWindow_FormClosing); this.ResumeLayout(false); } diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.resx b/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ProcessPickerWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs index ab872d370..7730e7c7d 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProcessWindow.Designer.cs @@ -1,6 +1,4 @@ using ProcessHacker.Common; -using ProcessHacker.Components; - namespace ProcessHacker { partial class ProcessWindow @@ -77,6 +75,10 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + this.mainMenu = new System.Windows.Forms.MainMenu(this.components); + this.processMenuItem = new System.Windows.Forms.MenuItem(); + this.inspectImageFileMenuItem = new System.Windows.Forms.MenuItem(); + this.windowMenuItem = new System.Windows.Forms.MenuItem(); this.tabControl = new System.Windows.Forms.TabControl(); this.tabGeneral = new System.Windows.Forms.TabPage(); this.groupProcess = new System.Windows.Forms.GroupBox(); @@ -134,25 +136,26 @@ private void InitializeComponent() this.label15 = new System.Windows.Forms.Label(); this.checkHideFreeRegions = new System.Windows.Forms.CheckBox(); this.buttonSearch = new wyDay.Controls.SplitButton(); + this.menuSearch = new System.Windows.Forms.ContextMenu(); + this.newWindowSearchMenuItem = new System.Windows.Forms.MenuItem(); + this.literalSearchMenuItem = new System.Windows.Forms.MenuItem(); + this.regexSearchMenuItem = new System.Windows.Forms.MenuItem(); + this.stringScanMenuItem = new System.Windows.Forms.MenuItem(); + this.heapScanMenuItem = new System.Windows.Forms.MenuItem(); + this.structSearchMenuItem = new System.Windows.Forms.MenuItem(); this.listMemory = new ProcessHacker.Components.MemoryList(); this.tabEnvironment = new System.Windows.Forms.TabPage(); - this.listEnvironment = new ProcessHacker.Components.ExtendedListView(); - this.columnVarName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnVarValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listEnvironment = new System.Windows.Forms.ListView(); + this.columnVarName = new System.Windows.Forms.ColumnHeader(); + this.columnVarValue = new System.Windows.Forms.ColumnHeader(); this.tabHandles = new System.Windows.Forms.TabPage(); this.checkHideHandlesNoName = new System.Windows.Forms.CheckBox(); this.listHandles = new ProcessHacker.Components.HandleList(); this.tabJob = new System.Windows.Forms.TabPage(); this.tabServices = new System.Windows.Forms.TabPage(); - this.tabDotNet = new System.Windows.Forms.TabPage(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); - this.contextMenuStripSearch = new System.Windows.Forms.ContextMenuStrip(this.components); - this.newWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.literalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.regexToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.stringScanToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.heapScanToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.structToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); + this.tabDotNet = new System.Windows.Forms.TabPage(); this.tabControl.SuspendLayout(); this.tabGeneral.SuspendLayout(); this.groupProcess.SuspendLayout(); @@ -171,14 +174,49 @@ private void InitializeComponent() this.tabMemory.SuspendLayout(); this.tabEnvironment.SuspendLayout(); this.tabHandles.SuspendLayout(); - this.contextMenuStripSearch.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // + // ProcessWindow + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(488, 431); + this.KeyPreview = true; + this.Menu = this.mainMenu; + this.MinimumSize = new System.Drawing.Size(454, 433); + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "Process"; + this.Load += new System.EventHandler(this.ProcessWindow_Load); + this.SizeChanged += new System.EventHandler(this.ProcessWindow_SizeChanged); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProcessWindow_FormClosing); + // + // mainMenu + // + this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.processMenuItem, + this.windowMenuItem}); + // + // processMenuItem + // + this.processMenuItem.Index = 0; + this.processMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.inspectImageFileMenuItem}); + this.processMenuItem.Text = "&Process"; + // + // inspectImageFileMenuItem + // + this.inspectImageFileMenuItem.Index = 0; + this.inspectImageFileMenuItem.Text = "&Inspect Image File..."; + this.inspectImageFileMenuItem.Click += new System.EventHandler(this.inspectImageFileMenuItem_Click); + // + // windowMenuItem + // + this.windowMenuItem.Index = 1; + this.windowMenuItem.Text = "&Window"; + // // tabControl // - this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.tabControl.Controls.Add(this.tabGeneral); this.tabControl.Controls.Add(this.tabStatistics); this.tabControl.Controls.Add(this.tabPerformance); @@ -191,12 +229,12 @@ private void InitializeComponent() this.tabControl.Controls.Add(this.tabJob); this.tabControl.Controls.Add(this.tabServices); this.tabControl.Controls.Add(this.tabDotNet); + this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl.ItemSize = new System.Drawing.Size(80, 18); - this.tabControl.Location = new System.Drawing.Point(12, 12); + this.tabControl.Location = new System.Drawing.Point(0, 0); this.tabControl.Multiline = true; - this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(483, 524); + this.tabControl.Size = new System.Drawing.Size(488, 431); this.tabControl.SizeMode = System.Windows.Forms.TabSizeMode.FillToRight; this.tabControl.TabIndex = 0; this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged); @@ -207,18 +245,17 @@ private void InitializeComponent() this.tabGeneral.Controls.Add(this.groupProcess); this.tabGeneral.Controls.Add(this.groupFile); this.tabGeneral.Location = new System.Drawing.Point(4, 40); - this.tabGeneral.Name = "tabGeneral"; this.tabGeneral.Padding = new System.Windows.Forms.Padding(3); - this.tabGeneral.Size = new System.Drawing.Size(475, 480); + this.tabGeneral.Size = new System.Drawing.Size(480, 387); this.tabGeneral.TabIndex = 2; this.tabGeneral.Text = "General"; this.tabGeneral.UseVisualStyleBackColor = true; // // groupProcess // - this.groupProcess.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupProcess.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupProcess.Controls.Add(this.buttonPermissions); this.groupProcess.Controls.Add(this.labelProcessTypeValue); this.groupProcess.Controls.Add(this.labelProcessType); @@ -242,8 +279,7 @@ private void InitializeComponent() this.groupProcess.Controls.Add(this.textStartTime); this.groupProcess.Controls.Add(this.textCmdLine); this.groupProcess.Location = new System.Drawing.Point(8, 126); - this.groupProcess.Name = "groupProcess"; - this.groupProcess.Size = new System.Drawing.Size(461, 348); + this.groupProcess.Size = new System.Drawing.Size(466, 255); this.groupProcess.TabIndex = 1; this.groupProcess.TabStop = false; this.groupProcess.Text = "Process"; @@ -252,8 +288,7 @@ private void InitializeComponent() // this.buttonPermissions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonPermissions.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonPermissions.Location = new System.Drawing.Point(299, 206); - this.buttonPermissions.Name = "buttonPermissions"; + this.buttonPermissions.Location = new System.Drawing.Point(304, 206); this.buttonPermissions.Size = new System.Drawing.Size(75, 23); this.buttonPermissions.TabIndex = 21; this.buttonPermissions.Text = "Permissions"; @@ -264,7 +299,6 @@ private void InitializeComponent() // this.labelProcessTypeValue.AutoSize = true; this.labelProcessTypeValue.Location = new System.Drawing.Point(98, 208); - this.labelProcessTypeValue.Name = "labelProcessTypeValue"; this.labelProcessTypeValue.Size = new System.Drawing.Size(16, 13); this.labelProcessTypeValue.TabIndex = 20; this.labelProcessTypeValue.Text = "..."; @@ -273,29 +307,26 @@ private void InitializeComponent() // labelProcessType // this.labelProcessType.AutoSize = true; - this.labelProcessType.Location = new System.Drawing.Point(4, 208); - this.labelProcessType.Name = "labelProcessType"; - this.labelProcessType.Size = new System.Drawing.Size(74, 13); + this.labelProcessType.Location = new System.Drawing.Point(6, 208); + this.labelProcessType.Size = new System.Drawing.Size(75, 13); this.labelProcessType.TabIndex = 19; this.labelProcessType.Text = "Process Type:"; this.labelProcessType.Visible = false; // // fileCurrentDirectory // - this.fileCurrentDirectory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.fileCurrentDirectory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.fileCurrentDirectory.Location = new System.Drawing.Point(101, 71); - this.fileCurrentDirectory.Name = "fileCurrentDirectory"; this.fileCurrentDirectory.ReadOnly = true; - this.fileCurrentDirectory.Size = new System.Drawing.Size(354, 24); + this.fileCurrentDirectory.Size = new System.Drawing.Size(359, 24); this.fileCurrentDirectory.TabIndex = 3; // // label26 // this.label26.AutoSize = true; - this.label26.Location = new System.Drawing.Point(4, 22); - this.label26.Name = "label26"; - this.label26.Size = new System.Drawing.Size(47, 13); + this.label26.Location = new System.Drawing.Point(6, 22); + this.label26.Size = new System.Drawing.Size(44, 13); this.label26.TabIndex = 12; this.label26.Text = "Started:"; this.toolTip.SetToolTip(this.label26, "The time at which the program was started."); @@ -303,51 +334,46 @@ private void InitializeComponent() // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(4, 104); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(73, 13); + this.label7.Location = new System.Drawing.Point(6, 104); + this.label7.Size = new System.Drawing.Size(72, 13); this.label7.TabIndex = 15; this.label7.Text = "PEB Address:"; this.toolTip.SetToolTip(this.label7, "The address of the Process Environment Block (PEB)."); // // textProtected // - this.textProtected.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textProtected.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textProtected.BackColor = System.Drawing.SystemColors.Control; this.textProtected.Location = new System.Drawing.Point(101, 179); - this.textProtected.Name = "textProtected"; this.textProtected.ReadOnly = true; - this.textProtected.Size = new System.Drawing.Size(324, 22); + this.textProtected.Size = new System.Drawing.Size(329, 20); this.textProtected.TabIndex = 10; // // labelProtected // this.labelProtected.AutoSize = true; - this.labelProtected.Location = new System.Drawing.Point(4, 182); - this.labelProtected.Name = "labelProtected"; - this.labelProtected.Size = new System.Drawing.Size(59, 13); + this.labelProtected.Location = new System.Drawing.Point(6, 182); + this.labelProtected.Size = new System.Drawing.Size(56, 13); this.labelProtected.TabIndex = 18; this.labelProtected.Text = "Protected:"; this.toolTip.SetToolTip(this.labelProtected, "Whether the process is DRM-protected."); // // textDEP // - this.textDEP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textDEP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textDEP.BackColor = System.Drawing.SystemColors.Control; this.textDEP.Location = new System.Drawing.Point(101, 153); - this.textDEP.Name = "textDEP"; this.textDEP.ReadOnly = true; - this.textDEP.Size = new System.Drawing.Size(324, 22); + this.textDEP.Size = new System.Drawing.Size(329, 20); this.textDEP.TabIndex = 8; // // labelDEP // this.labelDEP.AutoSize = true; - this.labelDEP.Location = new System.Drawing.Point(4, 156); - this.labelDEP.Name = "labelDEP"; - this.labelDEP.Size = new System.Drawing.Size(30, 13); + this.labelDEP.Location = new System.Drawing.Point(6, 156); + this.labelDEP.Size = new System.Drawing.Size(32, 13); this.labelDEP.TabIndex = 17; this.labelDEP.Text = "DEP:"; this.toolTip.SetToolTip(this.labelDEP, "The status of Data Execution Prevention (DEP) for this process."); @@ -356,8 +382,7 @@ private void InitializeComponent() // this.buttonTerminate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonTerminate.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonTerminate.Location = new System.Drawing.Point(380, 206); - this.buttonTerminate.Name = "buttonTerminate"; + this.buttonTerminate.Location = new System.Drawing.Point(385, 206); this.buttonTerminate.Size = new System.Drawing.Size(75, 23); this.buttonTerminate.TabIndex = 1; this.buttonTerminate.Text = "Terminate"; @@ -368,8 +393,7 @@ private void InitializeComponent() // this.buttonInspectPEB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonInspectPEB.Image = global::ProcessHacker.Properties.Resources.application_form_magnify; - this.buttonInspectPEB.Location = new System.Drawing.Point(431, 98); - this.buttonInspectPEB.Name = "buttonInspectPEB"; + this.buttonInspectPEB.Location = new System.Drawing.Point(436, 98); this.buttonInspectPEB.Size = new System.Drawing.Size(24, 24); this.buttonInspectPEB.TabIndex = 5; this.toolTip.SetToolTip(this.buttonInspectPEB, "Inspects the PEB."); @@ -380,8 +404,7 @@ private void InitializeComponent() // this.buttonEditProtected.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonEditProtected.Image = global::ProcessHacker.Properties.Resources.cog_edit; - this.buttonEditProtected.Location = new System.Drawing.Point(431, 176); - this.buttonEditProtected.Name = "buttonEditProtected"; + this.buttonEditProtected.Location = new System.Drawing.Point(436, 176); this.buttonEditProtected.Size = new System.Drawing.Size(24, 24); this.buttonEditProtected.TabIndex = 11; this.toolTip.SetToolTip(this.buttonEditProtected, "Allows you to protect or unprotect the process."); @@ -392,8 +415,7 @@ private void InitializeComponent() // this.buttonInspectParent.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonInspectParent.Image = global::ProcessHacker.Properties.Resources.application_form_magnify; - this.buttonInspectParent.Location = new System.Drawing.Point(431, 124); - this.buttonInspectParent.Name = "buttonInspectParent"; + this.buttonInspectParent.Location = new System.Drawing.Point(436, 124); this.buttonInspectParent.Size = new System.Drawing.Size(24, 24); this.buttonInspectParent.TabIndex = 7; this.toolTip.SetToolTip(this.buttonInspectParent, "Inspects the parent process."); @@ -404,8 +426,7 @@ private void InitializeComponent() // this.buttonEditDEP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.buttonEditDEP.Image = global::ProcessHacker.Properties.Resources.cog_edit; - this.buttonEditDEP.Location = new System.Drawing.Point(431, 150); - this.buttonEditDEP.Name = "buttonEditDEP"; + this.buttonEditDEP.Location = new System.Drawing.Point(436, 150); this.buttonEditDEP.Size = new System.Drawing.Size(24, 24); this.buttonEditDEP.TabIndex = 9; this.toolTip.SetToolTip(this.buttonEditDEP, "Allows you to change the process\' DEP policy."); @@ -415,78 +436,71 @@ private void InitializeComponent() // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(4, 130); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(43, 13); + this.label5.Location = new System.Drawing.Point(6, 130); + this.label5.Size = new System.Drawing.Size(41, 13); this.label5.TabIndex = 16; this.label5.Text = "Parent:"; this.toolTip.SetToolTip(this.label5, "The name and ID of the process which started this process."); // // textParent // - this.textParent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textParent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textParent.BackColor = System.Drawing.SystemColors.Control; this.textParent.Location = new System.Drawing.Point(101, 127); - this.textParent.Name = "textParent"; this.textParent.ReadOnly = true; - this.textParent.Size = new System.Drawing.Size(324, 22); + this.textParent.Size = new System.Drawing.Size(329, 20); this.textParent.TabIndex = 6; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(4, 76); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(98, 13); + this.label4.Location = new System.Drawing.Point(6, 76); + this.label4.Size = new System.Drawing.Size(89, 13); this.label4.TabIndex = 14; this.label4.Text = "Current Directory:"; this.toolTip.SetToolTip(this.label4, "The program\'s current directory."); // // textPEBAddress // - this.textPEBAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textPEBAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textPEBAddress.Location = new System.Drawing.Point(101, 101); - this.textPEBAddress.Name = "textPEBAddress"; this.textPEBAddress.ReadOnly = true; - this.textPEBAddress.Size = new System.Drawing.Size(324, 22); + this.textPEBAddress.Size = new System.Drawing.Size(329, 20); this.textPEBAddress.TabIndex = 4; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(4, 48); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(86, 13); + this.label2.Location = new System.Drawing.Point(6, 48); + this.label2.Size = new System.Drawing.Size(80, 13); this.label2.TabIndex = 13; this.label2.Text = "Command Line:"; this.toolTip.SetToolTip(this.label2, "The command used to start the program."); // // textStartTime // - this.textStartTime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textStartTime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textStartTime.Location = new System.Drawing.Point(101, 19); - this.textStartTime.Name = "textStartTime"; this.textStartTime.ReadOnly = true; - this.textStartTime.Size = new System.Drawing.Size(354, 22); + this.textStartTime.Size = new System.Drawing.Size(359, 20); this.textStartTime.TabIndex = 0; // // textCmdLine // - this.textCmdLine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textCmdLine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textCmdLine.Location = new System.Drawing.Point(101, 45); - this.textCmdLine.Name = "textCmdLine"; this.textCmdLine.ReadOnly = true; - this.textCmdLine.Size = new System.Drawing.Size(354, 22); + this.textCmdLine.Size = new System.Drawing.Size(359, 20); this.textCmdLine.TabIndex = 2; // // groupFile // - this.groupFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupFile.Controls.Add(this.fileImage); this.groupFile.Controls.Add(this.pictureIcon); this.groupFile.Controls.Add(this.textFileDescription); @@ -495,26 +509,23 @@ private void InitializeComponent() this.groupFile.Controls.Add(this.label3); this.groupFile.Controls.Add(this.textFileVersion); this.groupFile.Location = new System.Drawing.Point(6, 7); - this.groupFile.Name = "groupFile"; - this.groupFile.Size = new System.Drawing.Size(463, 114); + this.groupFile.Size = new System.Drawing.Size(468, 114); this.groupFile.TabIndex = 0; this.groupFile.TabStop = false; this.groupFile.Text = "File"; // // fileImage // - this.fileImage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.fileImage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.fileImage.Location = new System.Drawing.Point(103, 83); - this.fileImage.Name = "fileImage"; this.fileImage.ReadOnly = true; - this.fileImage.Size = new System.Drawing.Size(354, 24); + this.fileImage.Size = new System.Drawing.Size(359, 24); this.fileImage.TabIndex = 1; // // pictureIcon // this.pictureIcon.Location = new System.Drawing.Point(6, 19); - this.pictureIcon.Name = "pictureIcon"; this.pictureIcon.Size = new System.Drawing.Size(32, 32); this.pictureIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureIcon.TabIndex = 1; @@ -522,27 +533,25 @@ private void InitializeComponent() // // textFileDescription // - this.textFileDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFileDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFileDescription.BackColor = System.Drawing.SystemColors.Window; this.textFileDescription.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textFileDescription.Location = new System.Drawing.Point(44, 20); - this.textFileDescription.Name = "textFileDescription"; this.textFileDescription.ReadOnly = true; - this.textFileDescription.Size = new System.Drawing.Size(413, 15); + this.textFileDescription.Size = new System.Drawing.Size(418, 13); this.textFileDescription.TabIndex = 2; this.textFileDescription.Text = "File Description"; // // textFileCompany // - this.textFileCompany.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFileCompany.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFileCompany.BackColor = System.Drawing.SystemColors.Window; this.textFileCompany.BorderStyle = System.Windows.Forms.BorderStyle.None; this.textFileCompany.Location = new System.Drawing.Point(44, 38); - this.textFileCompany.Name = "textFileCompany"; this.textFileCompany.ReadOnly = true; - this.textFileCompany.Size = new System.Drawing.Size(413, 15); + this.textFileCompany.Size = new System.Drawing.Size(418, 13); this.textFileCompany.TabIndex = 3; this.textFileCompany.Text = "File Company"; // @@ -550,8 +559,7 @@ private void InitializeComponent() // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 60); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(83, 13); + this.label1.Size = new System.Drawing.Size(77, 13); this.label1.TabIndex = 4; this.label1.Text = "Image Version:"; this.toolTip.SetToolTip(this.label1, "The version of the program."); @@ -560,28 +568,25 @@ private void InitializeComponent() // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 88); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(94, 13); + this.label3.Size = new System.Drawing.Size(89, 13); this.label3.TabIndex = 5; this.label3.Text = "Image File Name:"; this.toolTip.SetToolTip(this.label3, "The file name of the program."); // // textFileVersion // - this.textFileVersion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textFileVersion.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textFileVersion.Location = new System.Drawing.Point(103, 57); - this.textFileVersion.Name = "textFileVersion"; this.textFileVersion.ReadOnly = true; - this.textFileVersion.Size = new System.Drawing.Size(354, 22); + this.textFileVersion.Size = new System.Drawing.Size(359, 20); this.textFileVersion.TabIndex = 0; // // tabStatistics // - this.tabStatistics.Location = new System.Drawing.Point(4, 40); - this.tabStatistics.Name = "tabStatistics"; + this.tabStatistics.Location = new System.Drawing.Point(4, 22); this.tabStatistics.Padding = new System.Windows.Forms.Padding(3); - this.tabStatistics.Size = new System.Drawing.Size(475, 480); + this.tabStatistics.Size = new System.Drawing.Size(480, 405); this.tabStatistics.TabIndex = 9; this.tabStatistics.Text = "Statistics"; this.tabStatistics.UseVisualStyleBackColor = true; @@ -589,10 +594,9 @@ private void InitializeComponent() // tabPerformance // this.tabPerformance.Controls.Add(this.tablePerformance); - this.tabPerformance.Location = new System.Drawing.Point(4, 40); - this.tabPerformance.Name = "tabPerformance"; + this.tabPerformance.Location = new System.Drawing.Point(4, 22); this.tabPerformance.Padding = new System.Windows.Forms.Padding(3); - this.tabPerformance.Size = new System.Drawing.Size(475, 480); + this.tabPerformance.Size = new System.Drawing.Size(480, 405); this.tabPerformance.TabIndex = 8; this.tabPerformance.Text = "Performance"; this.tabPerformance.UseVisualStyleBackColor = true; @@ -610,21 +614,19 @@ private void InitializeComponent() this.tablePerformance.Controls.Add(this.groupBoxCpu, 0, 0); this.tablePerformance.Dock = System.Windows.Forms.DockStyle.Fill; this.tablePerformance.Location = new System.Drawing.Point(3, 3); - this.tablePerformance.Name = "tablePerformance"; this.tablePerformance.RowCount = 3; this.tablePerformance.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.tablePerformance.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.tablePerformance.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.tablePerformance.Size = new System.Drawing.Size(469, 474); + this.tablePerformance.Size = new System.Drawing.Size(474, 399); this.tablePerformance.TabIndex = 1; // // groupBoxIO // this.groupBoxIO.Controls.Add(this.indicatorIO); this.groupBoxIO.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBoxIO.Location = new System.Drawing.Point(3, 319); - this.groupBoxIO.Name = "groupBoxIO"; - this.groupBoxIO.Size = new System.Drawing.Size(80, 152); + this.groupBoxIO.Location = new System.Drawing.Point(3, 269); + this.groupBoxIO.Size = new System.Drawing.Size(80, 127); this.groupBoxIO.TabIndex = 3; this.groupBoxIO.TabStop = false; this.groupBoxIO.Text = "I/O (R+O)"; @@ -639,11 +641,10 @@ private void InitializeComponent() this.indicatorIO.Dock = System.Windows.Forms.DockStyle.Fill; this.indicatorIO.ForeColor = System.Drawing.Color.Lime; this.indicatorIO.GraphWidth = 33; - this.indicatorIO.Location = new System.Drawing.Point(3, 18); + this.indicatorIO.Location = new System.Drawing.Point(3, 16); this.indicatorIO.Maximum = ((long)(2147483647)); this.indicatorIO.Minimum = ((long)(0)); - this.indicatorIO.Name = "indicatorIO"; - this.indicatorIO.Size = new System.Drawing.Size(74, 131); + this.indicatorIO.Size = new System.Drawing.Size(74, 108); this.indicatorIO.TabIndex = 1; this.indicatorIO.TextValue = ""; // @@ -651,9 +652,8 @@ private void InitializeComponent() // this.groupBoxPvt.Controls.Add(this.indicatorPvt); this.groupBoxPvt.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBoxPvt.Location = new System.Drawing.Point(3, 161); - this.groupBoxPvt.Name = "groupBoxPvt"; - this.groupBoxPvt.Size = new System.Drawing.Size(80, 152); + this.groupBoxPvt.Location = new System.Drawing.Point(3, 136); + this.groupBoxPvt.Size = new System.Drawing.Size(80, 127); this.groupBoxPvt.TabIndex = 2; this.groupBoxPvt.TabStop = false; this.groupBoxPvt.Text = "Pvt. Pages"; @@ -668,11 +668,10 @@ private void InitializeComponent() this.indicatorPvt.Dock = System.Windows.Forms.DockStyle.Fill; this.indicatorPvt.ForeColor = System.Drawing.Color.Lime; this.indicatorPvt.GraphWidth = 33; - this.indicatorPvt.Location = new System.Drawing.Point(3, 18); + this.indicatorPvt.Location = new System.Drawing.Point(3, 16); this.indicatorPvt.Maximum = ((long)(2147483647)); this.indicatorPvt.Minimum = ((long)(0)); - this.indicatorPvt.Name = "indicatorPvt"; - this.indicatorPvt.Size = new System.Drawing.Size(74, 131); + this.indicatorPvt.Size = new System.Drawing.Size(74, 108); this.indicatorPvt.TabIndex = 1; this.indicatorPvt.TextValue = ""; // @@ -681,8 +680,7 @@ private void InitializeComponent() this.groupCPUUsage.Controls.Add(this.plotterCPUUsage); this.groupCPUUsage.Dock = System.Windows.Forms.DockStyle.Fill; this.groupCPUUsage.Location = new System.Drawing.Point(89, 3); - this.groupCPUUsage.Name = "groupCPUUsage"; - this.groupCPUUsage.Size = new System.Drawing.Size(377, 152); + this.groupCPUUsage.Size = new System.Drawing.Size(382, 127); this.groupCPUUsage.TabIndex = 0; this.groupCPUUsage.TabStop = false; this.groupCPUUsage.Text = "CPU Usage (Kernel, User)"; @@ -690,22 +688,16 @@ private void InitializeComponent() // plotterCPUUsage // this.plotterCPUUsage.BackColor = System.Drawing.Color.Black; - this.plotterCPUUsage.Data1 = null; - this.plotterCPUUsage.Data2 = null; this.plotterCPUUsage.Dock = System.Windows.Forms.DockStyle.Fill; this.plotterCPUUsage.GridColor = System.Drawing.Color.Green; this.plotterCPUUsage.GridSize = new System.Drawing.Size(12, 12); this.plotterCPUUsage.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); this.plotterCPUUsage.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.plotterCPUUsage.Location = new System.Drawing.Point(3, 18); - this.plotterCPUUsage.LongData1 = null; - this.plotterCPUUsage.LongData2 = null; + this.plotterCPUUsage.Location = new System.Drawing.Point(3, 16); this.plotterCPUUsage.MinMaxValue = ((long)(0)); this.plotterCPUUsage.MoveStep = -1; - this.plotterCPUUsage.Name = "plotterCPUUsage"; this.plotterCPUUsage.OverlaySecondLine = false; - this.plotterCPUUsage.ShowGrid = true; - this.plotterCPUUsage.Size = new System.Drawing.Size(371, 131); + this.plotterCPUUsage.Size = new System.Drawing.Size(376, 108); this.plotterCPUUsage.TabIndex = 0; this.plotterCPUUsage.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.plotterCPUUsage.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); @@ -719,9 +711,8 @@ private void InitializeComponent() // this.groupBox2.Controls.Add(this.plotterMemory); this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox2.Location = new System.Drawing.Point(89, 161); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(377, 152); + this.groupBox2.Location = new System.Drawing.Point(89, 136); + this.groupBox2.Size = new System.Drawing.Size(382, 127); this.groupBox2.TabIndex = 0; this.groupBox2.TabStop = false; this.groupBox2.Text = "Memory (Private Pages, Working Set)"; @@ -729,22 +720,16 @@ private void InitializeComponent() // plotterMemory // this.plotterMemory.BackColor = System.Drawing.Color.Black; - this.plotterMemory.Data1 = null; - this.plotterMemory.Data2 = null; this.plotterMemory.Dock = System.Windows.Forms.DockStyle.Fill; this.plotterMemory.GridColor = System.Drawing.Color.Green; this.plotterMemory.GridSize = new System.Drawing.Size(12, 12); this.plotterMemory.LineColor1 = System.Drawing.Color.Orange; this.plotterMemory.LineColor2 = System.Drawing.Color.Cyan; - this.plotterMemory.Location = new System.Drawing.Point(3, 18); - this.plotterMemory.LongData1 = null; - this.plotterMemory.LongData2 = null; + this.plotterMemory.Location = new System.Drawing.Point(3, 16); this.plotterMemory.MinMaxValue = ((long)(0)); this.plotterMemory.MoveStep = -1; - this.plotterMemory.Name = "plotterMemory"; this.plotterMemory.OverlaySecondLine = true; - this.plotterMemory.ShowGrid = true; - this.plotterMemory.Size = new System.Drawing.Size(371, 131); + this.plotterMemory.Size = new System.Drawing.Size(376, 108); this.plotterMemory.TabIndex = 0; this.plotterMemory.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.plotterMemory.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); @@ -758,9 +743,8 @@ private void InitializeComponent() // this.groupBox3.Controls.Add(this.plotterIO); this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox3.Location = new System.Drawing.Point(89, 319); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(377, 152); + this.groupBox3.Location = new System.Drawing.Point(89, 269); + this.groupBox3.Size = new System.Drawing.Size(382, 127); this.groupBox3.TabIndex = 0; this.groupBox3.TabStop = false; this.groupBox3.Text = "I/O (R+O, W)"; @@ -775,15 +759,14 @@ private void InitializeComponent() this.plotterIO.GridSize = new System.Drawing.Size(12, 12); this.plotterIO.LineColor1 = System.Drawing.Color.Yellow; this.plotterIO.LineColor2 = System.Drawing.Color.Purple; - this.plotterIO.Location = new System.Drawing.Point(3, 18); + this.plotterIO.Location = new System.Drawing.Point(3, 16); this.plotterIO.LongData1 = null; this.plotterIO.LongData2 = null; this.plotterIO.MinMaxValue = ((long)(0)); this.plotterIO.MoveStep = -1; - this.plotterIO.Name = "plotterIO"; this.plotterIO.OverlaySecondLine = true; this.plotterIO.ShowGrid = true; - this.plotterIO.Size = new System.Drawing.Size(371, 131); + this.plotterIO.Size = new System.Drawing.Size(376, 108); this.plotterIO.TabIndex = 0; this.plotterIO.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.plotterIO.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); @@ -798,8 +781,7 @@ private void InitializeComponent() this.groupBoxCpu.Controls.Add(this.indicatorCpu); this.groupBoxCpu.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBoxCpu.Location = new System.Drawing.Point(3, 3); - this.groupBoxCpu.Name = "groupBoxCpu"; - this.groupBoxCpu.Size = new System.Drawing.Size(80, 152); + this.groupBoxCpu.Size = new System.Drawing.Size(80, 127); this.groupBoxCpu.TabIndex = 1; this.groupBoxCpu.TabStop = false; this.groupBoxCpu.Text = "CPU Usage"; @@ -814,20 +796,18 @@ private void InitializeComponent() this.indicatorCpu.Dock = System.Windows.Forms.DockStyle.Fill; this.indicatorCpu.ForeColor = System.Drawing.Color.Lime; this.indicatorCpu.GraphWidth = 33; - this.indicatorCpu.Location = new System.Drawing.Point(3, 18); + this.indicatorCpu.Location = new System.Drawing.Point(3, 16); this.indicatorCpu.Maximum = ((long)(2147483647)); this.indicatorCpu.Minimum = ((long)(0)); - this.indicatorCpu.Name = "indicatorCpu"; - this.indicatorCpu.Size = new System.Drawing.Size(74, 131); + this.indicatorCpu.Size = new System.Drawing.Size(74, 108); this.indicatorCpu.TabIndex = 0; this.indicatorCpu.TextValue = ""; // // tabThreads // this.tabThreads.Controls.Add(this.listThreads); - this.tabThreads.Location = new System.Drawing.Point(4, 40); - this.tabThreads.Name = "tabThreads"; - this.tabThreads.Size = new System.Drawing.Size(475, 480); + this.tabThreads.Location = new System.Drawing.Point(4, 22); + this.tabThreads.Size = new System.Drawing.Size(480, 405); this.tabThreads.TabIndex = 3; this.tabThreads.Text = "Threads"; this.tabThreads.UseVisualStyleBackColor = true; @@ -836,18 +816,16 @@ private void InitializeComponent() // this.listThreads.Cursor = System.Windows.Forms.Cursors.Default; this.listThreads.Dock = System.Windows.Forms.DockStyle.Fill; + this.listThreads.DoubleBuffered = true; this.listThreads.Location = new System.Drawing.Point(0, 0); - this.listThreads.Name = "listThreads"; - this.listThreads.Provider = null; - this.listThreads.Size = new System.Drawing.Size(475, 480); + this.listThreads.Size = new System.Drawing.Size(480, 405); this.listThreads.TabIndex = 0; // // tabToken // - this.tabToken.Location = new System.Drawing.Point(4, 40); - this.tabToken.Name = "tabToken"; + this.tabToken.Location = new System.Drawing.Point(4, 22); this.tabToken.Padding = new System.Windows.Forms.Padding(3); - this.tabToken.Size = new System.Drawing.Size(475, 480); + this.tabToken.Size = new System.Drawing.Size(480, 405); this.tabToken.TabIndex = 1; this.tabToken.Text = "Token"; this.tabToken.UseVisualStyleBackColor = true; @@ -855,9 +833,8 @@ private void InitializeComponent() // tabModules // this.tabModules.Controls.Add(this.listModules); - this.tabModules.Location = new System.Drawing.Point(4, 40); - this.tabModules.Name = "tabModules"; - this.tabModules.Size = new System.Drawing.Size(475, 480); + this.tabModules.Location = new System.Drawing.Point(4, 22); + this.tabModules.Size = new System.Drawing.Size(480, 405); this.tabModules.TabIndex = 6; this.tabModules.Text = "Modules"; this.tabModules.UseVisualStyleBackColor = true; @@ -865,10 +842,9 @@ private void InitializeComponent() // listModules // this.listModules.Dock = System.Windows.Forms.DockStyle.Fill; + this.listModules.DoubleBuffered = true; this.listModules.Location = new System.Drawing.Point(0, 0); - this.listModules.Name = "listModules"; - this.listModules.Provider = null; - this.listModules.Size = new System.Drawing.Size(475, 480); + this.listModules.Size = new System.Drawing.Size(480, 405); this.listModules.TabIndex = 0; // // tabMemory @@ -877,10 +853,9 @@ private void InitializeComponent() this.tabMemory.Controls.Add(this.checkHideFreeRegions); this.tabMemory.Controls.Add(this.buttonSearch); this.tabMemory.Controls.Add(this.listMemory); - this.tabMemory.Location = new System.Drawing.Point(4, 40); - this.tabMemory.Name = "tabMemory"; + this.tabMemory.Location = new System.Drawing.Point(4, 22); this.tabMemory.Padding = new System.Windows.Forms.Padding(3); - this.tabMemory.Size = new System.Drawing.Size(475, 480); + this.tabMemory.Size = new System.Drawing.Size(480, 405); this.tabMemory.TabIndex = 4; this.tabMemory.Text = "Memory"; this.tabMemory.UseVisualStyleBackColor = true; @@ -889,7 +864,6 @@ private void InitializeComponent() // this.label15.AutoSize = true; this.label15.Location = new System.Drawing.Point(8, 11); - this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(44, 13); this.label15.TabIndex = 3; this.label15.Text = "Search:"; @@ -901,8 +875,7 @@ private void InitializeComponent() this.checkHideFreeRegions.CheckState = System.Windows.Forms.CheckState.Checked; this.checkHideFreeRegions.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkHideFreeRegions.Location = new System.Drawing.Point(6, 35); - this.checkHideFreeRegions.Name = "checkHideFreeRegions"; - this.checkHideFreeRegions.Size = new System.Drawing.Size(126, 18); + this.checkHideFreeRegions.Size = new System.Drawing.Size(120, 18); this.checkHideFreeRegions.TabIndex = 1; this.checkHideFreeRegions.Text = "Hide Free Regions"; this.checkHideFreeRegions.UseVisualStyleBackColor = true; @@ -912,31 +885,75 @@ private void InitializeComponent() // this.buttonSearch.AutoSize = true; this.buttonSearch.Location = new System.Drawing.Point(58, 7); - this.buttonSearch.Name = "buttonSearch"; this.buttonSearch.Size = new System.Drawing.Size(117, 25); + this.buttonSearch.SplitMenu = this.menuSearch; this.buttonSearch.TabIndex = 0; this.buttonSearch.Text = "&String Scan..."; this.buttonSearch.UseVisualStyleBackColor = true; this.buttonSearch.Click += new System.EventHandler(this.buttonSearch_Click); // + // menuSearch + // + this.menuSearch.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.newWindowSearchMenuItem, + this.literalSearchMenuItem, + this.regexSearchMenuItem, + this.stringScanMenuItem, + this.heapScanMenuItem, + this.structSearchMenuItem}); + // + // newWindowSearchMenuItem + // + this.newWindowSearchMenuItem.Index = 0; + this.newWindowSearchMenuItem.Text = "&New Window..."; + this.newWindowSearchMenuItem.Click += new System.EventHandler(this.newWindowSearchMenuItem_Click); + // + // literalSearchMenuItem + // + this.literalSearchMenuItem.Index = 1; + this.literalSearchMenuItem.Text = "&Literal..."; + this.literalSearchMenuItem.Click += new System.EventHandler(this.literalSearchMenuItem_Click); + // + // regexSearchMenuItem + // + this.regexSearchMenuItem.Index = 2; + this.regexSearchMenuItem.Text = "&Regex..."; + this.regexSearchMenuItem.Click += new System.EventHandler(this.regexSearchMenuItem_Click); + // + // stringScanMenuItem + // + this.stringScanMenuItem.Index = 3; + this.stringScanMenuItem.Text = "&String Scan..."; + this.stringScanMenuItem.Click += new System.EventHandler(this.stringScanMenuItem_Click); + // + // heapScanMenuItem + // + this.heapScanMenuItem.Index = 4; + this.heapScanMenuItem.Text = "&Heap Scan..."; + this.heapScanMenuItem.Click += new System.EventHandler(this.heapScanMenuItem_Click); + // + // structSearchMenuItem + // + this.structSearchMenuItem.Index = 5; + this.structSearchMenuItem.Text = "S&truct..."; + this.structSearchMenuItem.Click += new System.EventHandler(this.structSearchMenuItem_Click); + // // listMemory // - this.listMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listMemory.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listMemory.DoubleBuffered = true; this.listMemory.Location = new System.Drawing.Point(6, 59); - this.listMemory.Name = "listMemory"; - this.listMemory.Provider = null; - this.listMemory.Size = new System.Drawing.Size(463, 415); + this.listMemory.Size = new System.Drawing.Size(469, 340); this.listMemory.TabIndex = 2; // // tabEnvironment // this.tabEnvironment.Controls.Add(this.listEnvironment); - this.tabEnvironment.Location = new System.Drawing.Point(4, 40); - this.tabEnvironment.Name = "tabEnvironment"; + this.tabEnvironment.Location = new System.Drawing.Point(4, 22); this.tabEnvironment.Padding = new System.Windows.Forms.Padding(3); - this.tabEnvironment.Size = new System.Drawing.Size(475, 480); + this.tabEnvironment.Size = new System.Drawing.Size(480, 405); this.tabEnvironment.TabIndex = 10; this.tabEnvironment.Text = "Environment"; this.tabEnvironment.UseVisualStyleBackColor = true; @@ -947,13 +964,11 @@ private void InitializeComponent() this.columnVarName, this.columnVarValue}); this.listEnvironment.Dock = System.Windows.Forms.DockStyle.Fill; - this.listEnvironment.DoubleClickChecks = true; this.listEnvironment.FullRowSelect = true; this.listEnvironment.HideSelection = false; this.listEnvironment.Location = new System.Drawing.Point(3, 3); - this.listEnvironment.Name = "listEnvironment"; this.listEnvironment.ShowItemToolTips = true; - this.listEnvironment.Size = new System.Drawing.Size(469, 474); + this.listEnvironment.Size = new System.Drawing.Size(474, 399); this.listEnvironment.Sorting = System.Windows.Forms.SortOrder.Ascending; this.listEnvironment.TabIndex = 0; this.listEnvironment.UseCompatibleStateImageBehavior = false; @@ -974,9 +989,8 @@ private void InitializeComponent() this.tabHandles.Controls.Add(this.checkHideHandlesNoName); this.tabHandles.Controls.Add(this.listHandles); this.tabHandles.Location = new System.Drawing.Point(4, 40); - this.tabHandles.Name = "tabHandles"; this.tabHandles.Padding = new System.Windows.Forms.Padding(3); - this.tabHandles.Size = new System.Drawing.Size(475, 480); + this.tabHandles.Size = new System.Drawing.Size(480, 387); this.tabHandles.TabIndex = 5; this.tabHandles.Text = "Handles"; this.tabHandles.UseVisualStyleBackColor = true; @@ -986,8 +1000,7 @@ private void InitializeComponent() this.checkHideHandlesNoName.AutoSize = true; this.checkHideHandlesNoName.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkHideHandlesNoName.Location = new System.Drawing.Point(6, 7); - this.checkHideHandlesNoName.Name = "checkHideHandlesNoName"; - this.checkHideHandlesNoName.Size = new System.Drawing.Size(174, 18); + this.checkHideHandlesNoName.Size = new System.Drawing.Size(160, 18); this.checkHideHandlesNoName.TabIndex = 0; this.checkHideHandlesNoName.Text = "Hide handles with no name"; this.checkHideHandlesNoName.UseVisualStyleBackColor = true; @@ -995,20 +1008,18 @@ private void InitializeComponent() // // listHandles // - this.listHandles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listHandles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listHandles.DoubleBuffered = true; this.listHandles.Location = new System.Drawing.Point(6, 30); - this.listHandles.Name = "listHandles"; - this.listHandles.Provider = null; - this.listHandles.Size = new System.Drawing.Size(463, 444); + this.listHandles.Size = new System.Drawing.Size(469, 351); this.listHandles.TabIndex = 1; // // tabJob // this.tabJob.Location = new System.Drawing.Point(4, 40); - this.tabJob.Name = "tabJob"; - this.tabJob.Size = new System.Drawing.Size(475, 480); + this.tabJob.Size = new System.Drawing.Size(480, 387); this.tabJob.TabIndex = 11; this.tabJob.Text = "Job"; this.tabJob.UseVisualStyleBackColor = true; @@ -1016,91 +1027,27 @@ private void InitializeComponent() // tabServices // this.tabServices.Location = new System.Drawing.Point(4, 40); - this.tabServices.Name = "tabServices"; - this.tabServices.Size = new System.Drawing.Size(475, 480); + this.tabServices.Size = new System.Drawing.Size(480, 387); this.tabServices.TabIndex = 7; this.tabServices.Text = "Services"; this.tabServices.UseVisualStyleBackColor = true; // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // tabDotNet // this.tabDotNet.Location = new System.Drawing.Point(4, 40); - this.tabDotNet.Name = "tabDotNet"; this.tabDotNet.Padding = new System.Windows.Forms.Padding(3); - this.tabDotNet.Size = new System.Drawing.Size(475, 480); + this.tabDotNet.Size = new System.Drawing.Size(480, 387); this.tabDotNet.TabIndex = 12; this.tabDotNet.Text = ".NET"; this.tabDotNet.UseVisualStyleBackColor = true; - // - // contextMenuStripSearch - // - this.contextMenuStripSearch.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newWindowToolStripMenuItem, - this.literalToolStripMenuItem, - this.regexToolStripMenuItem, - this.stringScanToolStripMenuItem, - this.heapScanToolStripMenuItem, - this.structToolStripMenuItem}); - this.contextMenuStripSearch.Name = "contextMenuStripSearch"; - this.contextMenuStripSearch.Size = new System.Drawing.Size(155, 136); - // - // newWindowToolStripMenuItem - // - this.newWindowToolStripMenuItem.Name = "newWindowToolStripMenuItem"; - this.newWindowToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.newWindowToolStripMenuItem.Text = "&New Window..."; - this.newWindowToolStripMenuItem.Click += new System.EventHandler(this.newWindowSearchMenuItem_Click); - // - // literalToolStripMenuItem - // - this.literalToolStripMenuItem.Name = "literalToolStripMenuItem"; - this.literalToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.literalToolStripMenuItem.Text = "&Literal..."; - this.literalToolStripMenuItem.Click += new System.EventHandler(this.literalSearchMenuItem_Click); - // - // regexToolStripMenuItem - // - this.regexToolStripMenuItem.Name = "regexToolStripMenuItem"; - this.regexToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.regexToolStripMenuItem.Text = "&Regex..."; - this.regexToolStripMenuItem.Click += new System.EventHandler(this.regexSearchMenuItem_Click); - // - // stringScanToolStripMenuItem - // - this.stringScanToolStripMenuItem.Name = "stringScanToolStripMenuItem"; - this.stringScanToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.stringScanToolStripMenuItem.Text = "&String Scan..."; - this.stringScanToolStripMenuItem.Click += new System.EventHandler(this.stringScanMenuItem_Click); - // - // heapScanToolStripMenuItem - // - this.heapScanToolStripMenuItem.Name = "heapScanToolStripMenuItem"; - this.heapScanToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.heapScanToolStripMenuItem.Text = "&Heap Scan..."; - this.heapScanToolStripMenuItem.Click += new System.EventHandler(this.heapScanMenuItem_Click); - // - // structToolStripMenuItem - // - this.structToolStripMenuItem.Name = "structToolStripMenuItem"; - this.structToolStripMenuItem.Size = new System.Drawing.Size(154, 22); - this.structToolStripMenuItem.Text = "S&truct..."; - this.structToolStripMenuItem.Click += new System.EventHandler(this.structSearchMenuItem_Click); - // - // ProcessWindow - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(507, 548); + this.Controls.Add(this.tabControl); - this.KeyPreview = true; - this.MinimumSize = new System.Drawing.Size(523, 586); - this.Name = "ProcessWindow"; - this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; - this.Text = "Process"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProcessWindow_FormClosing); - this.Load += new System.EventHandler(this.ProcessWindow_Load); - this.SizeChanged += new System.EventHandler(this.ProcessWindow_SizeChanged); + this.tabControl.ResumeLayout(false); this.tabGeneral.ResumeLayout(false); this.groupProcess.ResumeLayout(false); @@ -1123,13 +1070,18 @@ private void InitializeComponent() this.tabEnvironment.ResumeLayout(false); this.tabHandles.ResumeLayout(false); this.tabHandles.PerformLayout(); - this.contextMenuStripSearch.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); } #endregion + private System.Windows.Forms.MainMenu mainMenu; + private wyDay.Controls.VistaMenu vistaMenu; + private System.Windows.Forms.MenuItem processMenuItem; + private System.Windows.Forms.MenuItem windowMenuItem; + private System.Windows.Forms.MenuItem inspectImageFileMenuItem; private System.Windows.Forms.TabControl tabControl; private System.Windows.Forms.TabPage tabToken; private System.Windows.Forms.TabPage tabGeneral; @@ -1153,12 +1105,19 @@ private void InitializeComponent() private ProcessHacker.Components.ModuleList listModules; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox textParent; + private ProcessHacker.Components.HandleList listHandles; private ProcessHacker.Components.MemoryList listMemory; private System.Windows.Forms.Button buttonTerminate; private System.Windows.Forms.TextBox textDEP; private System.Windows.Forms.Label labelDEP; private System.Windows.Forms.Button buttonEditDEP; private System.Windows.Forms.Button buttonInspectParent; + private System.Windows.Forms.ContextMenu menuSearch; + private System.Windows.Forms.MenuItem newWindowSearchMenuItem; + private System.Windows.Forms.MenuItem literalSearchMenuItem; + private System.Windows.Forms.MenuItem regexSearchMenuItem; + private System.Windows.Forms.MenuItem stringScanMenuItem; + private System.Windows.Forms.MenuItem heapScanMenuItem; private System.Windows.Forms.CheckBox checkHideFreeRegions; private System.Windows.Forms.CheckBox checkHideHandlesNoName; private wyDay.Controls.SplitButton buttonSearch; @@ -1179,12 +1138,13 @@ private void InitializeComponent() private System.Windows.Forms.TextBox textStartTime; private ProcessHacker.Components.FileNameBox fileCurrentDirectory; private ProcessHacker.Components.FileNameBox fileImage; + private System.Windows.Forms.MenuItem structSearchMenuItem; private System.Windows.Forms.TextBox textProtected; private System.Windows.Forms.Label labelProtected; private System.Windows.Forms.Button buttonEditProtected; private System.Windows.Forms.ToolTip toolTip; private System.Windows.Forms.TabPage tabEnvironment; - private ExtendedListView listEnvironment; + private System.Windows.Forms.ListView listEnvironment; private System.Windows.Forms.ColumnHeader columnVarName; private System.Windows.Forms.ColumnHeader columnVarValue; private System.Windows.Forms.TabPage tabJob; @@ -1198,13 +1158,5 @@ private void InitializeComponent() private System.Windows.Forms.Label labelProcessTypeValue; private System.Windows.Forms.Button buttonPermissions; private System.Windows.Forms.TabPage tabDotNet; - private System.Windows.Forms.ContextMenuStrip contextMenuStripSearch; - private System.Windows.Forms.ToolStripMenuItem newWindowToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem literalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem regexToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem stringScanToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem heapScanToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem structToolStripMenuItem; - private HandleList listHandles; } } \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessWindow.cs b/1.x/trunk/ProcessHacker/Forms/ProcessWindow.cs index 85d39aabd..28ced5283 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProcessWindow.cs @@ -41,8 +41,10 @@ namespace ProcessHacker { public partial class ProcessWindow : Form { - private readonly ProcessItem _processItem; - private readonly int _pid; + private bool _isFirstPaint = true; + + private ProcessItem _processItem; + private int _pid; private ProcessHandle _processHandle; private Bitmap _processImage; @@ -56,12 +58,13 @@ public partial class ProcessWindow : Form private JobProperties _jobProps; private ServiceProperties _serviceProps; private DotNetCounters _dotNetCounters; - private bool _dotNetCountersInitialized; + private bool _dotNetCountersInitialized = false; private ProcessHacker.Common.Threading.ActionSync _selectThreadRun; public ProcessWindow(ProcessItem process) { + this.SetPhParent(); InitializeComponent(); this.AddEscapeToClose(); this.SetTopMost(); @@ -74,15 +77,16 @@ public ProcessWindow(ProcessItem process) else this.Icon = Program.HackerWindow.Icon; - textFileDescription.Text = string.Empty; - textFileCompany.Text = string.Empty; - textFileVersion.Text = string.Empty; + textFileDescription.Text = ""; + textFileCompany.Text = ""; + textFileVersion.Text = ""; if (!Program.PWindows.ContainsKey(_pid)) Program.PWindows.Add(_pid, this); this.FixTabs(); - + + _dontCalculate = false; _selectThreadRun = new ProcessHacker.Common.Threading.ActionSync(this.SelectThreadInternal, 2); } @@ -111,38 +115,66 @@ private void ProcessWindow_Load(object sender, EventArgs e) Utils.FitRectangle(new Rectangle(location, this.Size), this).Location; // Update the Window menu. - //Program.UpdateWindowMenu(windowMenuItem, this); + Program.UpdateWindowMenu(windowMenuItem, this); SymbolProviderExtensions.ShowWarning(this, false); - - this.LoadStage1(); } - public ExtendedListView ThreadListView + public ListView ThreadListView { get { return listThreads.List; } } - public ExtendedListView ModuleListView + public ListView ModuleListView { get { return listModules.List; } } - public ExtendedListView MemoryListView + public ListView MemoryListView { get { return listMemory.List; } } - public ExtendedListView HandleListView + public ListView HandleListView { get { return listHandles.List; } } - public ExtendedListView ServiceListView + public ListView ServiceListView { get { return _serviceProps.List; } } + // ==== Performance hacks ==== + protected override void WndProc(ref Message m) + { + switch (m.Msg) + { + case (int)WindowMessage.Paint: + { + if (_isFirstPaint) + { + _isFirstPaint = false; + this.LoadStage1(); + } + } + break; + } + + if (!this.IsDisposed) + base.WndProc(ref m); + } + + private bool _dontCalculate = true; + + protected override void OnResize(EventArgs e) + { + if (_dontCalculate) + return; + + base.OnResize(e); + } + private void FixTabs() { if (_pid <= 0) @@ -153,7 +185,7 @@ private void FixTabs() buttonInspectParent.Enabled = false; buttonInspectPEB.Enabled = false; - if (fileCurrentDirectory.Text != string.Empty) + if (fileCurrentDirectory.Text != "") fileCurrentDirectory.Enabled = false; if (_pid != 4) @@ -242,7 +274,7 @@ private void LoadStage1() { this.Text = _processItem.Name; textFileDescription.Text = _processItem.Name; - textFileCompany.Text = string.Empty; + textFileCompany.Text = ""; } else { @@ -252,7 +284,8 @@ private void LoadStage1() Application.DoEvents(); // add our handler to the process provider - Program.ProcessProvider.Updated += this.ProcessProvider_Updated; + Program.ProcessProvider.Updated += + new ProcessSystemProvider.ProviderUpdateOnce(ProcessProvider_Updated); // Check if window was closed before this began executing, bail out if true. if (!this.IsHandleCreated) @@ -376,7 +409,8 @@ private void ProcessWindow_FormClosing(object sender, FormClosingEventArgs e) _processImage.Dispose(); } - Program.ProcessProvider.Updated -= this.ProcessProvider_Updated; + Program.ProcessProvider.Updated -= + new ProcessSystemProvider.ProviderUpdateOnce(ProcessProvider_Updated); Settings.Instance.EnvironmentListViewColumns = ColumnSettings.SaveSettings(listEnvironment); Settings.Instance.ProcessWindowSelectedTab = tabControl.SelectedTab.Name; @@ -439,7 +473,7 @@ private void UpdateProcessProperties() textFileCompany.Text = _processItem.VerifySignerName; if (verifyResult == VerifyResult.Unknown) - textFileCompany.Text += string.Empty; + textFileCompany.Text += ""; else if (verifyResult == VerifyResult.Trusted) textFileCompany.Text += " (verified)"; else if (verifyResult == VerifyResult.NoSignature) @@ -458,8 +492,8 @@ private void UpdateProcessProperties() catch { fileImage.Text = _processItem.FileName; - textFileDescription.Text = string.Empty; - textFileCompany.Text = string.Empty; + textFileDescription.Text = ""; + textFileCompany.Text = ""; } // Update WOW64 info. @@ -479,7 +513,7 @@ private void UpdateProcessProperties() { using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) { - labelProcessTypeValue.Text = phandle.IsWow64 ? "32-bit" : "64-bit"; + labelProcessTypeValue.Text = phandle.IsWow64() ? "32-bit" : "64-bit"; } } catch (Exception ex) @@ -492,7 +526,7 @@ private void UpdateProcessProperties() return; if (_processItem.CmdLine != null) - textCmdLine.Text = _processItem.CmdLine.Replace("\0", string.Empty); + textCmdLine.Text = _processItem.CmdLine.Replace("\0", ""); try { @@ -649,6 +683,8 @@ private void InitializeSubControls() } listEnvironment.ListViewItemSorter = new SortedListViewComparer(listEnvironment); + listEnvironment.SetDoubleBuffered(true); + listEnvironment.SetTheme("explorer"); listEnvironment.ContextMenu = listEnvironment.GetCopyMenu(); ColumnSettings.LoadSettings(Settings.Instance.EnvironmentListViewColumns, listEnvironment); } @@ -658,29 +694,34 @@ private void InitializeProviders() listThreads.BeginUpdate(); _threadP = new ThreadProvider(_pid); Program.SecondaryProviderThread.Add(_threadP); - _threadP.Updated += this._threadP_Updated; + _threadP.Updated += new ThreadProvider.ProviderUpdateOnce(_threadP_Updated); listThreads.Provider = _threadP; listModules.BeginUpdate(); _moduleP = new ModuleProvider(_pid); Program.SecondaryProviderThread.Add(_moduleP); - _moduleP.Updated += this._moduleP_Updated; + _moduleP.Updated += new ModuleProvider.ProviderUpdateOnce(_moduleP_Updated); listModules.Provider = _moduleP; listMemory.BeginUpdate(); _memoryP = new MemoryProvider(_pid); Program.SecondaryProviderThread.Add(_memoryP); _memoryP.IgnoreFreeRegions = true; - _memoryP.Updated += this._memoryP_Updated; + _memoryP.Updated += new MemoryProvider.ProviderUpdateOnce(_memoryP_Updated); listMemory.Provider = _memoryP; listHandles.BeginUpdate(); _handleP = new HandleProvider(_pid); Program.SecondaryProviderThread.Add(_handleP); _handleP.HideHandlesWithNoName = Settings.Instance.HideHandlesWithNoName; - _handleP.Updated += this._handleP_Updated; + _handleP.Updated += new HandleProvider.ProviderUpdateOnce(_handleP_Updated); listHandles.Provider = _handleP; + listThreads.List.SetTheme("explorer"); + listModules.List.SetTheme("explorer"); + listMemory.List.SetTheme("explorer"); + listHandles.List.SetTheme("explorer"); + this.InitializeShortcuts(); } @@ -696,37 +737,43 @@ private void InitializeShortcuts() private void UpdateEnvironmentVariables() { listEnvironment.Items.Clear(); + listEnvironment.BeginUpdate(); - WorkQueue.GlobalQueueWorkItemTag(new MethodInvoker(() => - { - try + WorkQueue.GlobalQueueWorkItemTag(new Action(() => { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights)) + try { - foreach (KeyValuePair pair in phandle.GetEnvironmentVariables()) + using (ProcessHandle phandle = new ProcessHandle(_pid, + ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights)) { - if (!string.IsNullOrEmpty(pair.Key)) + foreach (var pair in phandle.GetEnvironmentVariables()) { - if (this.IsHandleCreated) + if (pair.Key != "") { - // Work around delegate variable capturing. - var localPair = pair; - - this.BeginInvoke(new MethodInvoker(() => this.listEnvironment.Items.Add(new ListViewItem(new[] { localPair.Key, localPair.Value })))); + if (this.IsHandleCreated) + { + // Work around delegate variable capturing. + var localPair = pair; + + this.BeginInvoke(new MethodInvoker(() => + { + listEnvironment.Items.Add( + new ListViewItem(new string[] { localPair.Key, localPair.Value })); + })); + } } } } } - } - catch - { } + catch + { } - if (this.IsHandleCreated) - { - this.BeginInvoke(new MethodInvoker(() => listEnvironment.EndUpdate())); - } - }), "process-update-environment-variables"); + if (this.IsHandleCreated) + { + this.BeginInvoke(new MethodInvoker(() => listEnvironment.EndUpdate())); + } + }), "process-update-environment-variables"); } public void UpdateProtected() @@ -735,24 +782,24 @@ public void UpdateProtected() textProtected.Enabled = true; buttonEditProtected.Enabled = true; - //if (KProcessHacker.Instance != null && OSVersion.HasProtectedProcesses) - //{ - // try - // { - // textProtected.Text = KProcessHacker.Instance.GetProcessProtected(_pid) ? "Protected" : "Not Protected"; - // } - // catch (Exception ex) - // { - // textProtected.Text = "(" + ex.Message + ")"; - // buttonEditProtected.Enabled = false; - // } - //} - //else - //{ - - labelProtected.Enabled = false; - textProtected.Enabled = false; - buttonEditProtected.Enabled = false; + if (KProcessHacker.Instance != null && OSVersion.HasProtectedProcesses) + { + try + { + textProtected.Text = KProcessHacker.Instance.GetProcessProtected(_pid) ? "Protected" : "Not Protected"; + } + catch (Exception ex) + { + textProtected.Text = "(" + ex.Message + ")"; + buttonEditProtected.Enabled = false; + } + } + else + { + labelProtected.Enabled = false; + textProtected.Enabled = false; + buttonEditProtected.Enabled = false; + } } public void UpdateDepStatus() @@ -763,7 +810,7 @@ public void UpdateDepStatus() { using (var phandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation)) { - var depStatus = phandle.DepStatus; + var depStatus = phandle.GetDepStatus(); string str; if ((depStatus & DepStatus.Enabled) != 0) @@ -791,7 +838,7 @@ public void UpdateDepStatus() { labelDEP.Enabled = false; textDEP.Enabled = false; - textDEP.Text = string.Empty; + textDEP.Text = ""; //textDEP.Text = "(This feature is not supported on your version of Windows)"; buttonEditDEP.Enabled = false; } @@ -802,67 +849,74 @@ public void UpdateDepStatus() } // Can't set DEP status on processes in other sessions without KPH. - //if (KProcessHacker.Instance == null && _processItem.SessionId != Program.CurrentSessionId) + if ( + KProcessHacker.Instance == null && + _processItem.SessionId != Program.CurrentSessionId + ) buttonEditDEP.Enabled = false; } private void PerformSearch(string text) { Point location = this.Location; - Size size = this.Size; + System.Drawing.Size size = this.Size; - Program.GetResultsWindow(_pid, f => + ResultsWindow rw = Program.GetResultsWindow(_pid, + new Program.ResultsWindowInvokeAction(delegate(ResultsWindow f) { - switch (text) + if (text == "&New Results Window...") { - case "&New Results Window...": + f.Show(); + } + else if (text == "&Literal...") + { + if (f.EditSearch(SearchType.Literal, location, size) == DialogResult.OK) + { f.Show(); - break; - case "&Literal...": - if (f.EditSearch(SearchType.Literal, location, size) == DialogResult.OK) - { - f.Show(); - f.StartSearch(); - } - else - { - f.Close(); - } - break; - case "&Regex...": - if (f.EditSearch(SearchType.Regex, location, size) == DialogResult.OK) - { - f.Show(); - f.StartSearch(); - } - else - { - f.Close(); - } - break; - case "&String Scan...": - f.SearchOptions.Type = SearchType.String; + f.StartSearch(); + } + else + { + f.Close(); + } + } + else if (text == "&Regex...") + { + if (f.EditSearch(SearchType.Regex, location, size) == DialogResult.OK) + { f.Show(); f.StartSearch(); - break; - case "&Heap Scan...": - f.SearchOptions.Type = SearchType.Heap; + } + else + { + f.Close(); + } + } + else if (text == "&String Scan...") + { + f.SearchOptions.Type = SearchType.String; + f.Show(); + f.StartSearch(); + } + else if (text == "&Heap Scan...") + { + f.SearchOptions.Type = SearchType.Heap; + f.Show(); + f.StartSearch(); + } + else if (text == "S&truct...") + { + if (f.EditSearch(SearchType.Struct, location, size) == DialogResult.OK) + { f.Show(); f.StartSearch(); - break; - case "S&truct...": - if (f.EditSearch(SearchType.Struct, location, size) == DialogResult.OK) - { - f.Show(); - f.StartSearch(); - } - else - { - f.Close(); - } - break; + } + else + { + f.Close(); + } } - }); + })); buttonSearch.Text = text; } @@ -987,18 +1041,15 @@ private void SelectThread_listThreads_ThreadItemsAdded() private void buttonTerminate_Click(object sender, EventArgs e) { - ProcessActions.Terminate(this, new[] { _processItem.Pid }, new[] { _processItem.Name }, true); + ProcessActions.Terminate(this, new int[] { _processItem.Pid }, new string[] { _processItem.Name }, true); } private void buttonEditDEP_Click(object sender, EventArgs e) { - using (EditDEPWindow w = new EditDEPWindow(_pid) - { - TopMost = this.TopMost - }) - { - w.ShowDialog(); - } + EditDEPWindow w = new EditDEPWindow(_pid); + + w.TopMost = this.TopMost; + w.ShowDialog(); this.UpdateDepStatus(); } @@ -1007,16 +1058,15 @@ private void buttonEditProtected_Click(object sender, EventArgs e) { try { - using (ComboBoxPickerWindow picker = new ComboBoxPickerWindow(new[] { "Protect", "Unprotect" })) - { - picker.Message = "Select an action below:"; - picker.SelectedItem = string.Equals(this.textProtected.Text, "Protected", StringComparison.OrdinalIgnoreCase) ? "Protect" : "Unprotect"; + ComboBoxPickerWindow picker = new ComboBoxPickerWindow(new string[] { "Protect", "Unprotect" }); - if (picker.ShowDialog() == DialogResult.OK) - { - //KProcessHacker.Instance.SetProcessProtected(_pid, string.Equals(picker.SelectedItem, "Protect", StringComparison.OrdinalIgnoreCase)); - this.UpdateProtected(); - } + picker.Message = "Select an action below:"; + picker.SelectedItem = (textProtected.Text == "Protected") ? "Protect" : "Unprotect"; + + if (picker.ShowDialog() == DialogResult.OK) + { + KProcessHacker.Instance.SetProcessProtected(_pid, picker.SelectedItem == "Protect"); + this.UpdateProtected(); } } catch (Exception ex) @@ -1036,7 +1086,7 @@ private void buttonInspectPEB_Click(object sender, EventArgs e) { IntPtr baseAddress = phandle.GetBasicInformation().PebBaseAddress; - Program.HackerWindow.BeginInvoke(new MethodInvoker(() => + Program.HackerWindow.BeginInvoke(new MethodInvoker(delegate { StructWindow sw = new StructWindow(_pid, baseAddress, Program.Structs["PEB"]); @@ -1087,7 +1137,7 @@ private void buttonPermissions_Click(object sender, EventArgs e) { SecurityEditor.EditSecurity( this, - SecurityEditor.GetSecurableWrapper(access => new ProcessHandle(_pid, (ProcessAccess)access)), + SecurityEditor.GetSecurableWrapper((access) => new ProcessHandle(_pid, (ProcessAccess)access)), _processItem.Name, NativeTypeFactory.GetAccessEntries(NativeTypeFactory.ObjectType.Process) ); @@ -1202,60 +1252,56 @@ private void _memoryP_Updated() { if (_memoryP.RunCount > 1) { - this.BeginInvoke(new MethodInvoker(() => + this.BeginInvoke(new MethodInvoker(delegate { - this.listMemory.EndUpdate(); - this.listMemory.Refresh(); - this.checkHideFreeRegions.Enabled = true; + listMemory.EndUpdate(); + listMemory.Refresh(); + checkHideFreeRegions.Enabled = true; this.Cursor = Cursors.Default; })); - - _memoryP.Updated -= this._memoryP_Updated; + _memoryP.Updated -= new MemoryProvider.ProviderUpdateOnce(_memoryP_Updated); } } private void _handleP_Updated() { - if (this._handleP.RunCount <= 1) - return; - - this.BeginInvoke(new MethodInvoker(() => + if (_handleP.RunCount > 1) { - this.listHandles.EndUpdate(); - this.listHandles.Refresh(); - this.checkHideHandlesNoName.Enabled = true; - this.Cursor = Cursors.Default; - })); - - this._handleP.Updated -= this._handleP_Updated; + this.BeginInvoke(new MethodInvoker(delegate + { + listHandles.EndUpdate(); + listHandles.Refresh(); + checkHideHandlesNoName.Enabled = true; + this.Cursor = Cursors.Default; + })); + _handleP.Updated -= new HandleProvider.ProviderUpdateOnce(_handleP_Updated); + } } private void _moduleP_Updated() { - if (this._moduleP.RunCount <= 1) - return; - - this.BeginInvoke(new MethodInvoker(() => + if (_moduleP.RunCount > 1) { - this.listModules.EndUpdate(); - this.listModules.Refresh(); - })); - - this._moduleP.Updated -= this._moduleP_Updated; + this.BeginInvoke(new MethodInvoker(delegate + { + listModules.EndUpdate(); + listModules.Refresh(); + })); + _moduleP.Updated -= new ModuleProvider.ProviderUpdateOnce(_moduleP_Updated); + } } private void _threadP_Updated() { - if (this._threadP.RunCount <= 1) - return; - - this.BeginInvoke(new MethodInvoker(() => + if (_threadP.RunCount > 1) { - this.listThreads.EndUpdate(); - this.listThreads.Refresh(); - })); - - this._threadP.Updated -= this._threadP_Updated; + this.BeginInvoke(new MethodInvoker(delegate + { + listThreads.EndUpdate(); + listThreads.Refresh(); + })); + _threadP.Updated -= new ThreadProvider.ProviderUpdateOnce(_threadP_Updated); + } } #endregion @@ -1264,32 +1310,32 @@ private void _threadP_Updated() private void newWindowSearchMenuItem_Click(object sender, EventArgs e) { - this.PerformSearch(this.newWindowToolStripMenuItem.Text); + PerformSearch(newWindowSearchMenuItem.Text); } private void literalSearchMenuItem_Click(object sender, EventArgs e) { - this.PerformSearch(this.literalToolStripMenuItem.Text); + PerformSearch(literalSearchMenuItem.Text); } private void regexSearchMenuItem_Click(object sender, EventArgs e) { - this.PerformSearch(this.regexToolStripMenuItem.Text); + PerformSearch(regexSearchMenuItem.Text); } private void stringScanMenuItem_Click(object sender, EventArgs e) { - this.PerformSearch(this.stringScanToolStripMenuItem.Text); + PerformSearch(stringScanMenuItem.Text); } private void heapScanMenuItem_Click(object sender, EventArgs e) { - this.PerformSearch(this.heapScanToolStripMenuItem.Text); + PerformSearch(heapScanMenuItem.Text); } private void structSearchMenuItem_Click(object sender, EventArgs e) { - this.PerformSearch(this.structToolStripMenuItem.Text); + PerformSearch(structSearchMenuItem.Text); } #endregion @@ -1299,25 +1345,17 @@ private void structSearchMenuItem_Click(object sender, EventArgs e) private void tabControl_SelectedIndexChanged(object sender, EventArgs e) { if (_threadP != null) - { if (_threadP.Enabled = tabControl.SelectedTab == tabThreads) _threadP.Boost(); - } if (_moduleP != null) - { if (_moduleP.Enabled = tabControl.SelectedTab == tabModules) _moduleP.Boost(); - } if (_memoryP != null) - { if (_memoryP.Enabled = tabControl.SelectedTab == tabMemory) _memoryP.Boost(); - } if (_handleP != null) - { if (_handleP.Enabled = tabControl.SelectedTab == tabHandles) _handleP.Boost(); - } if (tabControl.SelectedTab == tabStatistics) { @@ -1366,26 +1404,26 @@ private void SharedWaiter_ObjectSignaled(ISynchronizable obj) if (this.IsHandleCreated) { this.BeginInvoke(new MethodInvoker(() => - { - NtStatus exitStatus = _processHandle.GetExitStatus(); - string exitString = exitStatus.ToString(); - long exitLong; + { + NtStatus exitStatus = _processHandle.GetExitStatus(); + string exitString = exitStatus.ToString(); + long exitLong; - // We want "Success" instead of "Wait0" (both are 0x0). - if (exitString == "Wait0") - exitString = "Success"; + // We want "Success" instead of "Wait0" (both are 0x0). + if (exitString == "Wait0") + exitString = "Success"; - // If we have a NT status string, display it. - // Otherwise, display the NT status value in hex. - if (!long.TryParse(exitString, out exitLong)) - { - this.Text += " (exited with status " + exitString + ")"; - } - else - { - this.Text += " (exited with status 0x" + exitLong.ToString("x8") + ")"; - } - })); + // If we have a NT status string, display it. + // Otherwise, display the NT status value in hex. + if (!long.TryParse(exitString, out exitLong)) + { + this.Text += " (exited with status " + exitString + ")"; + } + else + { + this.Text += " (exited with status 0x" + exitLong.ToString("x8") + ")"; + } + })); } } } diff --git a/1.x/trunk/ProcessHacker/Forms/ProcessWindow.resx b/1.x/trunk/ProcessHacker/Forms/ProcessWindow.resx index d69b86343..f07a5387f 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProcessWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ProcessWindow.resx @@ -112,18 +112,21 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - - 17, 17 + + 354, 17 + + + 235, 17 - - 107, 17 + + 127, 17 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ProgressWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ProgressWindow.Designer.cs index f95a83886..171fa748f 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProgressWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProgressWindow.Designer.cs @@ -35,8 +35,8 @@ private void InitializeComponent() // // labelProgressText // - this.labelProgressText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelProgressText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelProgressText.AutoEllipsis = true; this.labelProgressText.Location = new System.Drawing.Point(12, 9); this.labelProgressText.Name = "labelProgressText"; @@ -45,8 +45,8 @@ private void InitializeComponent() // // progressBar // - this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.progressBar.Location = new System.Drawing.Point(12, 48); this.progressBar.Name = "progressBar"; this.progressBar.Size = new System.Drawing.Size(227, 16); @@ -67,7 +67,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(339, 80); this.ControlBox = false; this.Controls.Add(this.buttonClose); diff --git a/1.x/trunk/ProcessHacker/Forms/ProgressWindow.resx b/1.x/trunk/ProcessHacker/Forms/ProgressWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProgressWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ProgressWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/PromptBox.Designer.cs b/1.x/trunk/ProcessHacker/Forms/PromptBox.Designer.cs index 711a8b021..5dfd277b8 100644 --- a/1.x/trunk/ProcessHacker/Forms/PromptBox.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/PromptBox.Designer.cs @@ -39,18 +39,18 @@ private void InitializeComponent() this.labelValue.AutoSize = true; this.labelValue.Location = new System.Drawing.Point(12, 15); this.labelValue.Name = "labelValue"; - this.labelValue.Size = new System.Drawing.Size(39, 13); + this.labelValue.Size = new System.Drawing.Size(37, 13); this.labelValue.TabIndex = 3; this.labelValue.Text = "Value:"; // // textValue // - this.textValue.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textValue.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textValue.Location = new System.Drawing.Point(55, 12); this.textValue.Name = "textValue"; - this.textValue.Size = new System.Drawing.Size(319, 22); + this.textValue.Size = new System.Drawing.Size(319, 20); this.textValue.TabIndex = 0; // // buttonOK @@ -81,8 +81,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(386, 93); + this.ClientSize = new System.Drawing.Size(386, 73); this.ControlBox = false; this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOK); diff --git a/1.x/trunk/ProcessHacker/Forms/PromptBox.cs b/1.x/trunk/ProcessHacker/Forms/PromptBox.cs index e208c9824..da630878f 100644 --- a/1.x/trunk/ProcessHacker/Forms/PromptBox.cs +++ b/1.x/trunk/ProcessHacker/Forms/PromptBox.cs @@ -39,11 +39,11 @@ public string Value get { return _value; } } - public PromptBox() : this(string.Empty, false) { } + public PromptBox() : this("", false) { } public PromptBox(string value) : this(value, false) { } - public PromptBox(bool multiline) : this(string.Empty, multiline) { } + public PromptBox(bool multiline) : this("", multiline) { } public PromptBox(string value, bool multiline) { @@ -51,7 +51,7 @@ public PromptBox(string value, bool multiline) this.AddEscapeToClose(); this.SetTopMost(); - if (value == string.Empty) + if (value == "") { textValue.Text = LastValue; } diff --git a/1.x/trunk/ProcessHacker/Forms/PromptBox.resx b/1.x/trunk/ProcessHacker/Forms/PromptBox.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/PromptBox.resx +++ b/1.x/trunk/ProcessHacker/Forms/PromptBox.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.Designer.cs index c398fc935..b6371a1a9 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.Designer.cs @@ -44,7 +44,7 @@ private void InitializeComponent() this.checkProtect.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkProtect.Location = new System.Drawing.Point(12, 12); this.checkProtect.Name = "checkProtect"; - this.checkProtect.Size = new System.Drawing.Size(132, 18); + this.checkProtect.Size = new System.Drawing.Size(125, 18); this.checkProtect.TabIndex = 0; this.checkProtect.Text = "Protect this process"; this.checkProtect.UseVisualStyleBackColor = true; @@ -52,30 +52,30 @@ private void InitializeComponent() // // label1 // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 62); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(129, 13); + this.label1.Size = new System.Drawing.Size(124, 13); this.label1.TabIndex = 2; this.label1.Text = "Allowed process access:"; // // label2 // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 175); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(124, 13); + this.label2.Size = new System.Drawing.Size(117, 13); this.label2.TabIndex = 4; this.label2.Text = "Allowed thread access:"; // // listProcessAccess // - this.listProcessAccess.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listProcessAccess.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listProcessAccess.FormattingEnabled = true; this.listProcessAccess.Location = new System.Drawing.Point(12, 78); this.listProcessAccess.Name = "listProcessAccess"; @@ -84,8 +84,8 @@ private void InitializeComponent() // // listThreadAccess // - this.listThreadAccess.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listThreadAccess.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listThreadAccess.FormattingEnabled = true; this.listThreadAccess.Location = new System.Drawing.Point(12, 191); this.listThreadAccess.Name = "listThreadAccess"; @@ -122,7 +122,7 @@ private void InitializeComponent() this.checkDontAllowKernelMode.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkDontAllowKernelMode.Location = new System.Drawing.Point(12, 36); this.checkDontAllowKernelMode.Name = "checkDontAllowKernelMode"; - this.checkDontAllowKernelMode.Size = new System.Drawing.Size(297, 18); + this.checkDontAllowKernelMode.Size = new System.Drawing.Size(270, 18); this.checkDontAllowKernelMode.TabIndex = 1; this.checkDontAllowKernelMode.Text = "Don\'t allow kernel-mode code to bypass protection"; this.checkDontAllowKernelMode.UseVisualStyleBackColor = true; @@ -132,7 +132,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(498, 326); this.Controls.Add(this.checkDontAllowKernelMode); this.Controls.Add(this.buttonOK); diff --git a/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.cs b/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.cs index 8b6b19f06..d28bb0c3b 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.cs @@ -1,13 +1,20 @@ using System; -using System.Windows.Forms; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using ProcessHacker.Native; +using ProcessHacker.Native.Objects; using ProcessHacker.Native.Security; namespace ProcessHacker { public partial class ProtectProcessWindow : Form { - private readonly int _pid; - //private readonly bool _isProtected; + private int _pid; + private bool _isProtected; public ProtectProcessWindow(int pid) { @@ -17,23 +24,23 @@ public ProtectProcessWindow(int pid) _pid = pid; - //bool allowKernelMode; - //ProcessAccess processAccess; - //ThreadAccess threadAccess; + bool allowKernelMode; + ProcessAccess processAccess; + ThreadAccess threadAccess; - //if (ProtectQuery(_pid, out allowKernelMode, out processAccess, out threadAccess)) - //{ - // checkProtect.Checked = _isProtected = true; - // checkDontAllowKernelMode.Checked = !allowKernelMode; - //} + if (ProtectQuery(_pid, out allowKernelMode, out processAccess, out threadAccess)) + { + checkProtect.Checked = _isProtected = true; + checkDontAllowKernelMode.Checked = !allowKernelMode; + } foreach (string value in Enum.GetNames(typeof(ProcessAccess))) { if (value == "All") continue; - //listProcessAccess.Items.Add(value, - //(processAccess & (ProcessAccess)Enum.Parse(typeof(ProcessAccess), value)) != 0); + listProcessAccess.Items.Add(value, + (processAccess & (ProcessAccess)Enum.Parse(typeof(ProcessAccess), value)) != 0); } foreach (string value in Enum.GetNames(typeof(ThreadAccess))) @@ -41,31 +48,31 @@ public ProtectProcessWindow(int pid) if (value == "All") continue; - //listThreadAccess.Items.Add(value, - //(threadAccess & (ThreadAccess)Enum.Parse(typeof(ThreadAccess), value)) != 0); + listThreadAccess.Items.Add(value, + (threadAccess & (ThreadAccess)Enum.Parse(typeof(ThreadAccess), value)) != 0); } checkProtect_CheckedChanged(null, null); } - //private bool ProtectQuery(int pid, out bool allowKernelMode, out ProcessAccess processAccess, out ThreadAccess threadAccess) - //{ - // try - // { - //using (ProcessHandle phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) - //KProcessHacker.Instance.ProtectQuery(phandle, out allowKernelMode, out processAccess, out threadAccess); - - // return true; - // } - // catch - // { - // allowKernelMode = true; - // processAccess = 0; - // threadAccess = 0; - - // return false; - // } - //} + private bool ProtectQuery(int pid, out bool allowKernelMode, out ProcessAccess processAccess, out ThreadAccess threadAccess) + { + try + { + using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) + KProcessHacker.Instance.ProtectQuery(phandle, out allowKernelMode, out processAccess, out threadAccess); + + return true; + } + catch + { + allowKernelMode = true; + processAccess = 0; + threadAccess = 0; + + return false; + } + } private void buttonCancel_Click(object sender, EventArgs e) { @@ -75,16 +82,16 @@ private void buttonCancel_Click(object sender, EventArgs e) private void buttonOK_Click(object sender, EventArgs e) { // remove protection - //if (_isProtected) - //{ - // try - // { - // //using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) - // //KProcessHacker.Instance.ProtectRemove(phandle); - // } - // catch - // { } - //} + if (_isProtected) + { + try + { + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) + KProcessHacker.Instance.ProtectRemove(phandle); + } + catch + { } + } // re-add protection (with new masks) if (checkProtect.Checked) @@ -99,13 +106,13 @@ private void buttonOK_Click(object sender, EventArgs e) try { - //using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) - //KProcessHacker.Instance.ProtectAdd( - //phandle, - //!checkDontAllowKernelMode.Checked, - //processAccess, - //threadAccess - //); + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) + KProcessHacker.Instance.ProtectAdd( + phandle, + !checkDontAllowKernelMode.Checked, + processAccess, + threadAccess + ); } catch { } diff --git a/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.resx b/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ProtectProcessWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ResultsWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ResultsWindow.Designer.cs index c25d02f7d..b821be6c8 100644 --- a/1.x/trunk/ProcessHacker/Forms/ResultsWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ResultsWindow.Designer.cs @@ -43,11 +43,11 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ResultsWindow)); - this.listResults = new ProcessHacker.Components.ExtendedListView(); - this.columnAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnOffset = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnLength = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnString = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listResults = new System.Windows.Forms.ListView(); + this.columnAddress = new System.Windows.Forms.ColumnHeader(); + this.columnOffset = new System.Windows.Forms.ColumnHeader(); + this.columnLength = new System.Windows.Forms.ColumnHeader(); + this.columnString = new System.Windows.Forms.ColumnHeader(); this.labelText = new System.Windows.Forms.Label(); this.mainMenu = new System.Windows.Forms.MainMenu(this.components); this.windowMenuItem = new System.Windows.Forms.MenuItem(); @@ -56,21 +56,22 @@ private void InitializeComponent() this.buttonEdit = new System.Windows.Forms.Button(); this.buttonFind = new System.Windows.Forms.Button(); this.buttonSave = new System.Windows.Forms.Button(); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.toolTip = new System.Windows.Forms.ToolTip(this.components); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // // listResults // this.listResults.AllowColumnReorder = true; - this.listResults.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listResults.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listResults.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnAddress, this.columnOffset, this.columnLength, this.columnString}); - this.listResults.DoubleClickChecks = true; this.listResults.FullRowSelect = true; this.listResults.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.listResults.HideSelection = false; @@ -83,8 +84,8 @@ private void InitializeComponent() this.listResults.UseCompatibleStateImageBehavior = false; this.listResults.View = System.Windows.Forms.View.Details; this.listResults.VirtualMode = true; - this.listResults.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listResults_RetrieveVirtualItem); this.listResults.DoubleClick += new System.EventHandler(this.listResults_DoubleClick); + this.listResults.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.listResults_RetrieveVirtualItem); // // columnAddress // @@ -184,11 +185,15 @@ private void InitializeComponent() this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // ResultsWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(488, 343); this.Controls.Add(this.buttonFilter); this.Controls.Add(this.buttonIntersect); @@ -201,8 +206,9 @@ private void InitializeComponent() this.Menu = this.mainMenu; this.Name = "ResultsWindow"; this.Text = "Results"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ResultsWindow_FormClosing); this.Load += new System.EventHandler(this.ResultsWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ResultsWindow_FormClosing); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -210,7 +216,7 @@ private void InitializeComponent() #endregion - private ProcessHacker.Components.ExtendedListView listResults; + private System.Windows.Forms.ListView listResults; private System.Windows.Forms.ColumnHeader columnAddress; private System.Windows.Forms.ColumnHeader columnOffset; private System.Windows.Forms.ColumnHeader columnLength; @@ -220,6 +226,7 @@ private void InitializeComponent() private System.Windows.Forms.Button buttonFind; private System.Windows.Forms.Button buttonEdit; private System.Windows.Forms.Button buttonIntersect; + private wyDay.Controls.VistaMenu vistaMenu; private System.Windows.Forms.MainMenu mainMenu; private System.Windows.Forms.MenuItem windowMenuItem; private System.Windows.Forms.Button buttonFilter; diff --git a/1.x/trunk/ProcessHacker/Forms/ResultsWindow.cs b/1.x/trunk/ProcessHacker/Forms/ResultsWindow.cs index 4d1658ff3..b538d6db6 100644 --- a/1.x/trunk/ProcessHacker/Forms/ResultsWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/ResultsWindow.cs @@ -37,10 +37,10 @@ public partial class ResultsWindow : Form { private delegate bool Matcher(string s1, string s2); - private readonly int _pid; + private int _pid; private SearchOptions _so; private Thread _searchThread; - private readonly int _id; + private int _id; public string Id { @@ -53,6 +53,9 @@ public ResultsWindow(int pid) this.AddEscapeToClose(); this.SetTopMost(); + listResults.SetDoubleBuffered(true); + listResults.SetTheme("explorer"); + Thread.CurrentThread.Priority = ThreadPriority.Highest; _pid = pid; @@ -80,13 +83,14 @@ public ResultsWindow(int pid) private void ResultsWindow_Load(object sender, EventArgs e) { - //Program.UpdateWindowMenu(windowMenuItem, this); + Program.UpdateWindowMenu(windowMenuItem, this); listResults.ContextMenu = listResults.GetCopyMenu(listResults_RetrieveVirtualItem); this.Size = Settings.Instance.ResultsWindowSize; ColumnSettings.LoadSettings(Settings.Instance.ResultsListViewColumns, listResults); + this.SetPhParent(false); } private void ResultsWindow_FormClosing(object sender, FormClosingEventArgs e) @@ -131,28 +135,27 @@ public DialogResult EditSearch(SearchType type) return EditSearch(type, this.Location, this.Size); } - public DialogResult EditSearch(SearchType type, Point location, Size size) + public DialogResult EditSearch(SearchType type, System.Drawing.Point location, System.Drawing.Size size) { DialogResult dr = DialogResult.Cancel; _so.Type = type; - using (SearchWindow sw = new SearchWindow(_pid, _so)) - { - sw.StartPosition = FormStartPosition.Manual; - sw.Location = new Point( - location.X + (size.Width - sw.Width)/2, - location.Y + (size.Height - sw.Height)/2); + SearchWindow sw = new SearchWindow(_pid, _so); - Rectangle newRect = Utils.FitRectangle(new Rectangle(sw.Location, sw.Size), Screen.GetWorkingArea(sw)); + sw.StartPosition = FormStartPosition.Manual; + sw.Location = new System.Drawing.Point( + location.X + (size.Width - sw.Width) / 2, + location.Y + (size.Height - sw.Height) / 2); - sw.Location = newRect.Location; - sw.Size = newRect.Size; + Rectangle newRect = Utils.FitRectangle(new Rectangle(sw.Location, sw.Size), Screen.GetWorkingArea(sw)); - if ((dr = sw.ShowDialog()) == DialogResult.OK) - { - _so = sw.SearchOptions; - } + sw.Location = newRect.Location; + sw.Size = newRect.Size; + + if ((dr = sw.ShowDialog()) == DialogResult.OK) + { + _so = sw.SearchOptions; } return dr; @@ -172,7 +175,7 @@ public void StartSearch() { this.Cursor = Cursors.WaitCursor; - buttonFind.Image = Properties.Resources.cross; + buttonFind.Image = global::ProcessHacker.Properties.Resources.cross; toolTip.SetToolTip(buttonFind, "Cancel"); buttonEdit.Enabled = false; buttonFilter.Enabled = false; @@ -184,11 +187,11 @@ public void StartSearch() // refresh _so.Type = _so.Type; - _so.Searcher.SearchFinished += this.Searcher_SearchFinished; - _so.Searcher.SearchProgressChanged += this.Searcher_SearchProgressChanged; - _so.Searcher.SearchError += this.SearchError; + _so.Searcher.SearchFinished += new SearchFinished(Searcher_SearchFinished); + _so.Searcher.SearchProgressChanged += new SearchProgressChanged(Searcher_SearchProgressChanged); + _so.Searcher.SearchError += new SearchError(SearchError); - _searchThread = new Thread(this._so.Searcher.Search, Utils.SixteenthStackSize); + _searchThread = new Thread(new ThreadStart(_so.Searcher.Search), Utils.SixteenthStackSize); _searchThread.Start(); } @@ -196,35 +199,38 @@ public void StartSearch() private void SearchError(string message) { - this.BeginInvoke(new MethodInvoker(() => + this.Invoke(new MethodInvoker(delegate { PhUtils.ShowError("Unable to search memory: " + message); - this._searchThread = null; - this.Searcher_SearchFinished(); + _searchThread = null; + Searcher_SearchFinished(); })); } private void Searcher_SearchProgressChanged(string progress) { - this.BeginInvoke(new MethodInvoker(() => this.labelText.Text = progress)); + this.BeginInvoke(new MethodInvoker(delegate + { + labelText.Text = progress; + })); } private void Searcher_SearchFinished() { - this.BeginInvoke(new MethodInvoker(() => + this.Invoke(new MethodInvoker(delegate { - this.listResults.VirtualListSize = this._so.Searcher.Results.Count; + listResults.VirtualListSize = _so.Searcher.Results.Count; - this.labelText.Text = String.Format("{0} results.", this.listResults.Items.Count); + labelText.Text = String.Format("{0} results.", listResults.Items.Count); - this.buttonFind.Image = Properties.Resources.arrow_refresh; - this.toolTip.SetToolTip(this.buttonFind, "Search"); + buttonFind.Image = global::ProcessHacker.Properties.Resources.arrow_refresh; + toolTip.SetToolTip(buttonFind, "Search"); this.Cursor = Cursors.Default; - this.buttonEdit.Enabled = true; - this.buttonFilter.Enabled = true; - this.buttonIntersect.Enabled = true; - this.buttonSave.Enabled = true; - this.buttonFind.Enabled = true; + buttonEdit.Enabled = true; + buttonFilter.Enabled = true; + buttonIntersect.Enabled = true; + buttonSave.Enabled = true; + buttonFind.Enabled = true; })); _searchThread = null; @@ -247,29 +253,29 @@ private void listResults_RetrieveVirtualItem(object sender, RetrieveVirtualItemE private void buttonSave_Click(object sender, EventArgs e) { + string filename = ""; DialogResult dr = DialogResult.Cancel; ResultsWindow rw = this; - using (SaveFileDialog sfd = new SaveFileDialog()) + SaveFileDialog sfd = new SaveFileDialog(); + + sfd.Filter = "Text Document (*.txt)|*.txt|All Files (*.*)|*.*"; + dr = sfd.ShowDialog(); + filename = sfd.FileName; + + if (dr == DialogResult.OK) { - sfd.Filter = "Text Document (*.txt)|*.txt|All Files (*.*)|*.*"; - dr = sfd.ShowDialog(); - string filename = sfd.FileName; + System.IO.StreamWriter sw = new System.IO.StreamWriter(filename); - if (dr == DialogResult.OK) + foreach (string[] s in _so.Searcher.Results) { - using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filename)) - { - - foreach (string[] s in _so.Searcher.Results) - { - sw.Write("0x{0:x} ({1}){2}\r\n", int.Parse(s[0].Replace("0x", string.Empty), - System.Globalization.NumberStyles.HexNumber) + int.Parse(s[1].Replace("0x", string.Empty), - System.Globalization.NumberStyles.HexNumber), int.Parse(s[2]), - s[3] != string.Empty ? (": " + s[3]) : string.Empty); - } - } + sw.Write("0x{0:x} ({1}){2}\r\n", Int32.Parse(s[0].Replace("0x", ""), + System.Globalization.NumberStyles.HexNumber) + Int32.Parse(s[1].Replace("0x", ""), + System.Globalization.NumberStyles.HexNumber), Int32.Parse(s[2]), + s[3] != "" ? (": " + s[3]) : ""); } + + sw.Close(); } } @@ -305,32 +311,35 @@ private void listResults_DoubleClick(object sender, EventArgs e) return; } - phandle.EnumMemory(info => - { - if (info.BaseAddress.ToInt64() > s_a) + phandle.EnumMemory((info) => { - long selectlength = - (long)BaseConverter.ToNumberParse(_so.Searcher.Results[listResults.SelectedIndices[0]][2]); - - Program.GetMemoryEditor(_pid, lastInfo.BaseAddress, lastInfo.RegionSize.ToInt64(), f => + if (info.BaseAddress.ToInt64() > s_a) { - try - { - f.ReadOnly = false; - f.Activate(); - f.Select(s_a - lastInfo.BaseAddress.ToInt64(), selectlength); - } - catch - { } - }); + long selectlength = + (long)BaseConverter.ToNumberParse(_so.Searcher.Results[listResults.SelectedIndices[0]][2]); + + MemoryEditor ed = Program.GetMemoryEditor(_pid, + lastInfo.BaseAddress, + lastInfo.RegionSize.ToInt64(), + new Program.MemoryEditorInvokeAction(delegate(MemoryEditor f) + { + try + { + f.ReadOnly = false; + f.Activate(); + f.Select(s_a - lastInfo.BaseAddress.ToInt64(), selectlength); + } + catch + { } + })); - return false; - } + return false; + } - lastInfo = info; + lastInfo = info; - return true; - }); + return true; + }); } catch { } @@ -401,7 +410,7 @@ private void buttonIntersect_Click(object sender, EventArgs e) item.Click += new EventHandler(intersectItemClicked); menu.MenuItems.Add(item); - //vistaMenu.SetImage(item, global::ProcessHacker.Properties.Resources.table); + vistaMenu.SetImage(item, global::ProcessHacker.Properties.Resources.table); } menu.Show(buttonIntersect, new System.Drawing.Point(buttonIntersect.Size.Width, 0)); @@ -413,140 +422,116 @@ private void buttonFilter_Click(object sender, EventArgs e) foreach (ColumnHeader ch in listResults.Columns) { - MenuItem columnMenu = new MenuItem(ch.Text) - { - Tag = ch.Index - }; + MenuItem columnMenu = new MenuItem(ch.Text); + MenuItem item; + + columnMenu.Tag = ch.Index; - MenuItem item = new MenuItem("Contains...", this.filterMenuItem_Clicked) + item = new MenuItem("Contains...", new EventHandler(filterMenuItem_Clicked)); + item.Tag = new Matcher(delegate(string s1, string s2) { - Tag = new Matcher((s1, s2) => s1.Contains(s2, StringComparison.OrdinalIgnoreCase)) - }; + return s1.Contains(s2); + }); columnMenu.MenuItems.Add(item); - item = new MenuItem("Contains (case-insensitive)...", this.filterMenuItem_Clicked) + item = new MenuItem("Contains (case-insensitive)...", new EventHandler(filterMenuItem_Clicked)); + item.Tag = new Matcher(delegate(string s1, string s2) { - Tag = new Matcher((s1, s2) => s1.Contains(s2, StringComparison.OrdinalIgnoreCase)) - }; + return s1.ToUpperInvariant().Contains(s2.ToUpperInvariant()); + }); columnMenu.MenuItems.Add(item); - item = new MenuItem("Regex...", this.filterMenuItem_Clicked) + item = new MenuItem("Regex...", new EventHandler(filterMenuItem_Clicked)); + item.Tag = new Matcher(delegate(string s1, string s2) { - Tag = new Matcher((s1, s2) => + try { - try - { - System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(s2); + System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(s2); - return r.IsMatch(s1); - } - catch - { - return false; - } - }) - }; + return r.IsMatch(s1); + } + catch + { + return false; + } + }); columnMenu.MenuItems.Add(item); - item = new MenuItem("Regex (case-insensitive)...", this.filterMenuItem_Clicked) + item = new MenuItem("Regex (case-insensitive)...", new EventHandler(filterMenuItem_Clicked)); + item.Tag = new Matcher(delegate(string s1, string s2) { - Tag = new Matcher((s1, s2) => + try { - try - { - System.Text.RegularExpressions.Regex r = - new System.Text.RegularExpressions.Regex(s2, System.Text.RegularExpressions.RegexOptions.IgnoreCase); + System.Text.RegularExpressions.Regex r = + new System.Text.RegularExpressions.Regex(s2, System.Text.RegularExpressions.RegexOptions.IgnoreCase); - return r.IsMatch(s1); - } - catch - { - return false; - } - }) - }; + return r.IsMatch(s1); + } + catch + { + return false; + } + }); columnMenu.MenuItems.Add(item); - columnMenu.MenuItems.Add(new MenuItem("-")); - item = new MenuItem("Numerical relation...", this.filterMenuItem_Clicked) + columnMenu.MenuItems.Add(new MenuItem("-")); + + item = new MenuItem("Numerical relation...", new EventHandler(filterMenuItem_Clicked)); + item.Tag = new Matcher(delegate(string s1, string s2) { - Tag = new Matcher((s1, s2) => + if (s2.Contains("!=")) { - if (s2.Contains("!=", StringComparison.OrdinalIgnoreCase)) - { - decimal n1 = BaseConverter.ToNumberParse(s1); - decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] - { - "!=" - }, StringSplitOptions.None)[1]); - - return n1 != n2; - } + decimal n1 = BaseConverter.ToNumberParse(s1); + decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "!=" }, StringSplitOptions.None)[1]); - if (s2.Contains("<=", StringComparison.OrdinalIgnoreCase)) - { - decimal n1 = BaseConverter.ToNumberParse(s1); - decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] - { - "<=" - }, StringSplitOptions.None)[1]); - - return n1 <= n2; - } - - if (s2.Contains(">=", StringComparison.OrdinalIgnoreCase)) - { - decimal n1 = BaseConverter.ToNumberParse(s1); - decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] - { - ">=" - }, StringSplitOptions.None)[1]); + return n1 != n2; + } + else if (s2.Contains("<=")) + { + decimal n1 = BaseConverter.ToNumberParse(s1); + decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "<=" }, StringSplitOptions.None)[1]); - return n1 >= n2; - } + return n1 <= n2; + } + else if (s2.Contains(">=")) + { + decimal n1 = BaseConverter.ToNumberParse(s1); + decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { ">=" }, StringSplitOptions.None)[1]); - if (s2.Contains("<", StringComparison.OrdinalIgnoreCase)) - { - decimal n1 = BaseConverter.ToNumberParse(s1); - decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] - { - "<" - }, StringSplitOptions.None)[1]); + return n1 >= n2; + } + else if (s2.Contains("<")) + { + decimal n1 = BaseConverter.ToNumberParse(s1); + decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "<" }, StringSplitOptions.None)[1]); - return n1 < n2; - } - - if (s2.Contains(">", StringComparison.OrdinalIgnoreCase)) - { - decimal n1 = BaseConverter.ToNumberParse(s1); - decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] - { - ">" - }, StringSplitOptions.None)[1]); + return n1 < n2; + } + else if (s2.Contains(">")) + { + decimal n1 = BaseConverter.ToNumberParse(s1); + decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { ">" }, StringSplitOptions.None)[1]); - return n1 > n2; - } - - if (s2.Contains("=", StringComparison.OrdinalIgnoreCase)) - { - decimal n1 = BaseConverter.ToNumberParse(s1); - decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] - { - "=" - }, StringSplitOptions.None)[1]); + return n1 > n2; + } + else if (s2.Contains("=")) + { + decimal n1 = BaseConverter.ToNumberParse(s1); + decimal n2 = BaseConverter.ToNumberParse(s2.Split(new string[] { "=" }, StringSplitOptions.None)[1]); - return n1 == n2; - } - + return n1 == n2; + } + else + { return false; - }) - }; + } + }); columnMenu.MenuItems.Add(item); menu.MenuItems.Add(columnMenu); } - menu.Show(buttonFilter, new Point(buttonFilter.Size.Width, 0)); + menu.Show(buttonFilter, new System.Drawing.Point(buttonFilter.Size.Width, 0)); } private void filterMenuItem_Clicked(object sender, EventArgs e) @@ -566,32 +551,31 @@ private void filterMenuItem_Clicked(object sender, EventArgs e) private void Filter(int index, Matcher m) { - using (PromptBox prompt = new PromptBox()) + PromptBox prompt = new PromptBox(); + + if (prompt.ShowDialog() == DialogResult.OK) { - if (prompt.ShowDialog() == DialogResult.OK) - { - this.Cursor = Cursors.WaitCursor; + this.Cursor = Cursors.WaitCursor; - Program.GetResultsWindow(_pid, f => - { - f.ResultsList.VirtualListSize = 0; + ResultsWindow rw = Program.GetResultsWindow(_pid, new Program.ResultsWindowInvokeAction(delegate(ResultsWindow f) + { + f.ResultsList.VirtualListSize = 0; - foreach (string[] s in this.Results) + foreach (string[] s in Results) + { + if (m(s[index], prompt.Value)) { - if (m(s[index], prompt.Value)) - { - f.Results.Add(s); - f.ResultsList.VirtualListSize++; - } + f.Results.Add(s); + f.ResultsList.VirtualListSize++; } + } - f.Label = "Filter: " + f.Results.Count + " results."; - - f.Show(); - }); + f.Label = "Filter: " + f.Results.Count + " results."; + + f.Show(); + })); - this.Cursor = Cursors.Default; - } + this.Cursor = Cursors.Default; } } } diff --git a/1.x/trunk/ProcessHacker/Forms/ResultsWindow.resx b/1.x/trunk/ProcessHacker/Forms/ResultsWindow.resx index ba26bb9fd..694764c12 100644 --- a/1.x/trunk/ProcessHacker/Forms/ResultsWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ResultsWindow.resx @@ -112,18 +112,21 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 125, 17 - + 235, 17 - + + 17, 17 + + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA diff --git a/1.x/trunk/ProcessHacker/Forms/RunWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/RunWindow.Designer.cs index 49c90cc10..c0363a7f3 100644 --- a/1.x/trunk/ProcessHacker/Forms/RunWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/RunWindow.Designer.cs @@ -50,19 +50,19 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 49); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(53, 13); + this.label1.Size = new System.Drawing.Size(49, 13); this.label1.TabIndex = 10; this.label1.Text = "Program:"; // // textCmdLine // - this.textCmdLine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textCmdLine.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textCmdLine.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.textCmdLine.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.AllSystemSources; this.textCmdLine.Location = new System.Drawing.Point(79, 46); this.textCmdLine.Name = "textCmdLine"; - this.textCmdLine.Size = new System.Drawing.Size(230, 22); + this.textCmdLine.Size = new System.Drawing.Size(230, 20); this.textCmdLine.TabIndex = 0; // // label2 @@ -70,7 +70,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 75); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(61, 13); + this.label2.Size = new System.Drawing.Size(58, 13); this.label2.TabIndex = 11; this.label2.Text = "Username:"; // @@ -89,7 +89,7 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 128); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(63, 13); + this.label3.Size = new System.Drawing.Size(61, 13); this.label3.TabIndex = 14; this.label3.Text = "Session ID:"; // @@ -97,7 +97,7 @@ private void InitializeComponent() // this.textSessionID.Location = new System.Drawing.Point(79, 125); this.textSessionID.Name = "textSessionID"; - this.textSessionID.Size = new System.Drawing.Size(100, 22); + this.textSessionID.Size = new System.Drawing.Size(100, 20); this.textSessionID.TabIndex = 5; // // label4 @@ -105,7 +105,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(12, 102); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(59, 13); + this.label4.Size = new System.Drawing.Size(56, 13); this.label4.TabIndex = 13; this.label4.Text = "Password:"; // @@ -113,7 +113,7 @@ private void InitializeComponent() // this.textPassword.Location = new System.Drawing.Point(79, 99); this.textPassword.Name = "textPassword"; - this.textPassword.Size = new System.Drawing.Size(154, 22); + this.textPassword.Size = new System.Drawing.Size(154, 20); this.textPassword.TabIndex = 4; this.textPassword.UseSystemPasswordChar = true; // @@ -155,14 +155,14 @@ private void InitializeComponent() // // label5 // - this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.label5.Location = new System.Drawing.Point(12, 9); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(378, 30); this.label5.TabIndex = 9; this.label5.Text = "Enter the command to start as the specified user. Note that the program may take " + - "a while to start as Windows loads the user\'s profile."; + "a while to start as Windows loads the user\'s profile."; // // buttonSessions // @@ -180,7 +180,7 @@ private void InitializeComponent() this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(239, 75); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(33, 13); + this.label6.Size = new System.Drawing.Size(34, 13); this.label6.TabIndex = 12; this.label6.Text = "Type:"; // @@ -207,8 +207,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.CancelButton = this.buttonCancel; this.ClientSize = new System.Drawing.Size(402, 190); this.Controls.Add(this.comboType); this.Controls.Add(this.label6); @@ -231,8 +229,8 @@ private void InitializeComponent() this.Name = "RunWindow"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Run As..."; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RunWindow_FormClosing); this.Load += new System.EventHandler(this.RunWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RunWindow_FormClosing); this.ResumeLayout(false); this.PerformLayout(); diff --git a/1.x/trunk/ProcessHacker/Forms/RunWindow.cs b/1.x/trunk/ProcessHacker/Forms/RunWindow.cs index 9c2feadf6..34231eaf6 100644 --- a/1.x/trunk/ProcessHacker/Forms/RunWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/RunWindow.cs @@ -39,7 +39,7 @@ public partial class RunWindow : Form public RunWindow() { InitializeComponent(); - + this.AddEscapeToClose(); this.SetTopMost(); textSessionID.Text = Program.CurrentSessionId.ToString(); @@ -48,22 +48,19 @@ public RunWindow() if (Program.ElevationType == TokenElevationType.Limited) buttonOK.SetShieldIcon(true); - List users = new List - { - "NT AUTHORITY\\SYSTEM", - "NT AUTHORITY\\LOCAL SERVICE", - "NT AUTHORITY\\NETWORK SERVICE" - }; + List users = new List(); + + users.Add("NT AUTHORITY\\SYSTEM"); + users.Add("NT AUTHORITY\\LOCAL SERVICE"); + users.Add("NT AUTHORITY\\NETWORK SERVICE"); try { - using (LsaPolicyHandle phandle = new LsaPolicyHandle(LsaPolicyAccess.ViewLocalInformation)) + using (var phandle = new LsaPolicyHandle(LsaPolicyAccess.ViewLocalInformation)) { - foreach (Sid sid in phandle.Accounts) - { + foreach (var sid in phandle.GetAccounts()) if (sid.NameUse == SidNameUse.User) users.Add(sid.GetFullName(true)); - } } } catch @@ -112,17 +109,21 @@ private void RunWindow_FormClosing(object sender, FormClosingEventArgs e) private void buttonBrowse_Click(object sender, EventArgs e) { - using (OpenFileDialog ofd = new OpenFileDialog()) + OpenFileDialog ofd = new OpenFileDialog(); + + try { ofd.FileName = textCmdLine.Text; + } + catch + { } - ofd.CheckFileExists = true; - ofd.CheckPathExists = true; - ofd.Multiselect = false; + ofd.CheckFileExists = true; + ofd.CheckPathExists = true; + ofd.Multiselect = false; - if (ofd.ShowDialog() == DialogResult.OK) - textCmdLine.Text = ofd.FileName; - } + if (ofd.ShowDialog() == DialogResult.OK) + textCmdLine.Text = ofd.FileName; } private void buttonCancel_Click(object sender, EventArgs e) @@ -144,18 +145,20 @@ private void buttonOK_Click(object sender, EventArgs e) try { + string binPath; + string mailslotName; bool omitUserAndType = false; if (_pid != -1) omitUserAndType = true; - string mailslotName = "ProcessHackerAssistant" + Utils.CreateRandomString(8); - - string binPath = "\"" + Application.ExecutablePath + "\" -assistant " + - (omitUserAndType ? string.Empty : ("-u \"" + this.comboUsername.Text + "\" -t " + this.comboType.SelectedItem.ToString().ToLowerInvariant() + " ")) + - (this._pid != -1 ? ("-P " + this._pid.ToString() + " ") : string.Empty) + "-p \"" + - this.textPassword.Text.Replace("\"", "\\\"") + "\" -s " + this.textSessionID.Text + " -c \"" + - this.textCmdLine.Text.Replace("\"", "\\\"") + "\" -E " + mailslotName; + mailslotName = "ProcessHackerAssistant" + Utils.CreateRandomString(8); + binPath = "\"" + Application.ExecutablePath + "\" -assistant " + + (omitUserAndType ? "" : + ("-u \"" + comboUsername.Text + "\" -t " + comboType.SelectedItem.ToString().ToLowerInvariant() + " ")) + + (_pid != -1 ? ("-P " + _pid.ToString() + " ") : "") + "-p \"" + + textPassword.Text.Replace("\"", "\\\"") + "\" -s " + textSessionID.Text + " -c \"" + + textCmdLine.Text.Replace("\"", "\\\"") + "\" -E " + mailslotName; if (Program.ElevationType == TokenElevationType.Limited) { @@ -171,38 +174,36 @@ private void buttonOK_Click(object sender, EventArgs e) { string serviceName = Utils.CreateRandomString(8); - using (ServiceManagerHandle manager = new ServiceManagerHandle(ScManagerAccess.CreateService)) - using (ServiceHandle service = manager.CreateService( - serviceName, - serviceName + " (Process Hacker Assistant)", - ServiceType.Win32OwnProcess, - ServiceStartType.DemandStart, - ServiceErrorControl.Ignore, - binPath, - string.Empty, - "LocalSystem", - null - )) + using (var manager = new ServiceManagerHandle(ScManagerAccess.CreateService)) { - // Create a mailslot so we can receive the error code for Assistant. - using (MailslotHandle mhandle = MailslotHandle.Create(FileAccess.GenericRead, @"\Device\Mailslot\" + mailslotName, 0, 5000)) + using (var service = manager.CreateService( + serviceName, + serviceName + " (Process Hacker Assistant)", + ServiceType.Win32OwnProcess, + ServiceStartType.DemandStart, + ServiceErrorControl.Ignore, + binPath, + "", + "LocalSystem", + null)) { - try + // Create a mailslot so we can receive the error code for Assistant. + using (var mhandle = MailslotHandle.Create( + FileAccess.GenericRead, @"\Device\Mailslot\" + mailslotName, 0, 5000) + ) { - service.Start(); - } - catch { } - - service.Delete(); + try { service.Start(); } + catch { } + service.Delete(); - Win32Error errorCode = (Win32Error)mhandle.Read(4).ToInt32(); + Win32Error errorCode = (Win32Error)mhandle.Read(4).ToInt32(); - if (errorCode != Win32Error.Success) - throw new WindowsException(errorCode); + if (errorCode != Win32Error.Success) + throw new WindowsException(errorCode); + } } } - this.Close(); } } @@ -216,12 +217,12 @@ private void buttonOK_Click(object sender, EventArgs e) private bool isServiceUser() { - if (comboUsername.Text.Equals("NT AUTHORITY\\SYSTEM", StringComparison.OrdinalIgnoreCase) || - comboUsername.Text.Equals("NT AUTHORITY\\LOCAL SERVICE", StringComparison.OrdinalIgnoreCase) || - comboUsername.Text.Equals("NT AUTHORITY\\NETWORK SERVICE", StringComparison.OrdinalIgnoreCase)) + if (comboUsername.Text.ToUpper() == "NT AUTHORITY\\SYSTEM" || + comboUsername.Text.ToUpper() == "NT AUTHORITY\\LOCAL SERVICE" || + comboUsername.Text.ToUpper() == "NT AUTHORITY\\NETWORK SERVICE") return true; - - return false; + else + return false; } private void comboUsername_TextChanged(object sender, EventArgs e) @@ -250,7 +251,7 @@ private void buttonSessions_Click(object sender, EventArgs e) { ContextMenu menu = new ContextMenu(); - foreach (TerminalServerSession session in TerminalServerHandle.GetCurrent().GetSessions()) + foreach (var session in TerminalServerHandle.GetCurrent().GetSessions()) { MenuItem item = new MenuItem(); @@ -258,17 +259,13 @@ private void buttonSessions_Click(object sender, EventArgs e) string displayName = session.SessionId.ToString(); if (!string.IsNullOrEmpty(session.Name)) - { - displayName += ": " + session.Name + (userName != "\\" ? (" (" + userName + ")") : string.Empty); - } + displayName += ": " + session.Name + (userName != "\\" ? (" (" + userName + ")") : ""); else if (userName != "\\") - { displayName += ": " + userName; - } item.Text = displayName; item.Tag = session.SessionId; - item.Click += this.item_Click; + item.Click += new EventHandler(item_Click); menu.MenuItems.Add(item); } @@ -278,7 +275,7 @@ private void buttonSessions_Click(object sender, EventArgs e) private void item_Click(object sender, EventArgs e) { - textSessionID.Text = (sender as MenuItem).Tag.ToString(); + textSessionID.Text = ((MenuItem)sender).Tag.ToString(); } } } diff --git a/1.x/trunk/ProcessHacker/Forms/RunWindow.resx b/1.x/trunk/ProcessHacker/Forms/RunWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/RunWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/RunWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.Designer.cs new file mode 100644 index 000000000..3cec867b0 --- /dev/null +++ b/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.Designer.cs @@ -0,0 +1,97 @@ +namespace ProcessHacker +{ + partial class ScratchpadWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ScratchpadWindow)); + this.textText = new System.Windows.Forms.TextBox(); + this.buttonCopy = new System.Windows.Forms.Button(); + this.buttonSave = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textText + // + this.textText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textText.Location = new System.Drawing.Point(12, 12); + this.textText.Multiline = true; + this.textText.Name = "textText"; + this.textText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textText.Size = new System.Drawing.Size(530, 305); + this.textText.TabIndex = 0; + // + // buttonCopy + // + this.buttonCopy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCopy.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.buttonCopy.Location = new System.Drawing.Point(467, 323); + this.buttonCopy.Name = "buttonCopy"; + this.buttonCopy.Size = new System.Drawing.Size(75, 23); + this.buttonCopy.TabIndex = 2; + this.buttonCopy.Text = "Copy"; + this.buttonCopy.UseVisualStyleBackColor = true; + this.buttonCopy.Click += new System.EventHandler(this.buttonCopy_Click); + // + // buttonSave + // + this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonSave.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.buttonSave.Location = new System.Drawing.Point(386, 323); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(75, 23); + this.buttonSave.TabIndex = 1; + this.buttonSave.Text = "Save..."; + this.buttonSave.UseVisualStyleBackColor = true; + this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); + // + // ScratchpadWindow + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(554, 358); + this.Controls.Add(this.buttonSave); + this.Controls.Add(this.buttonCopy); + this.Controls.Add(this.textText); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.KeyPreview = true; + this.Name = "ScratchpadWindow"; + this.Text = "Scratchpad"; + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ScratchpadWindow_KeyDown); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textText; + private System.Windows.Forms.Button buttonCopy; + private System.Windows.Forms.Button buttonSave; + } +} \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.cs b/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.cs new file mode 100644 index 000000000..572044eeb --- /dev/null +++ b/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace ProcessHacker +{ + public partial class ScratchpadWindow : Form + { + public static void Create(string text) + { + // Create the window on the main thread. + Program.HackerWindow.BeginInvoke(new MethodInvoker(delegate + { + (new ScratchpadWindow(text)).Show(); + })); + } + + public ScratchpadWindow() + { + InitializeComponent(); + this.AddEscapeToClose(); + this.SetTopMost(); + } + + public ScratchpadWindow(string text) + { + InitializeComponent(); + + textText.Text = text; + textText.Select(0, 0); + } + + private void buttonCopy_Click(object sender, EventArgs e) + { + if (textText.Text.Length == 0) + return; + + if (textText.SelectionLength == 0) + { + Clipboard.SetText(textText.Text); + textText.Select(); + textText.SelectAll(); + } + else + { + Clipboard.SetText(textText.SelectedText); + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + SaveFileDialog sfd = new SaveFileDialog(); + + sfd.FileName = "scratchpad.txt"; + sfd.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; + + if (sfd.ShowDialog() == DialogResult.OK) + System.IO.File.WriteAllText(sfd.FileName, textText.Text); + } + + private void ScratchpadWindow_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control && e.KeyCode == Keys.A) + { + textText.SelectAll(); + e.Handled = true; + } + } + } +} diff --git a/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.resx b/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.resx new file mode 100644 index 000000000..b1bcc39c8 --- /dev/null +++ b/1.x/trunk/ProcessHacker/Forms/ScratchpadWindow.resx @@ -0,0 +1,909 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAA8AMDAQAAEABABoBgAA9gAAACAgEAABAAQA6AIAAF4HAAAQEBAAAQAEACgBAABGCgAAAAAAAAEA + CABqDQAAbgsAADAwAAABAAgAqA4AANgYAAAgIAAAAQAIAKgIAACAJwAAEBAAAAEACABoBQAAKDAAAAAA + AAABABgAOQ0AAJA1AAAwMAAAAQAYAKgcAADJQgAAICAAAAEAGACoDAAAcV8AABAQAAABABgAaAMAABls + AAAAAAAAAQAgAHANAACBbwAAMDAAAAEAIACoJQAA8XwAACAgAAABACAAqBAAAJmiAAAQEAAAAQAgAGgE + AABBswAAKAAAADAAAABgAAAAAQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIAAAACA + gACAAAAAgACAAICAAACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAAwMDAAP///wDwAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFRGVGVlZGVkdGVlAAAA + AAAAAAAAAAAAAFZGtkZLa2Rka0a0AAAAAAAAAAAAAAAAAGtka2tka2trZkZHAAAAAAAAAAAAAAAAAGRr + a2tmtmtra2tkAAAAAAAAAAAAAAAAAFZrZma2a2a2a2tnAAAAAAAAAAAAAAAAAEa2a2tra2tra2ZkAAAA + AAAAAAAAAAAAAGa2trZra2a2a2tlAAAAAAAAAAAAAAAAAHa2bbZrZttmtmtmAAAAAAABODE4ExgxAFa2 + tra2tra2tmtlAAAAAAABgxg4E4OBAEZrZrZr1rZr29tmAAAAAAADgTETgxMTAHvWvb22tmvba2tlAAAA + AAADE4ODgxg4AGRr272729tr29vUAAAAAAAIE4MTgTgxAF2729vb22bb29tnAAAAAAABODg4ODgxAEbb + 29vb29u2vb22AAAAAAADg4ODg4ODAEZmZmZmZm1mZmZlAAAAAAABODg4ODg4AHR2VlZWR1ZHRlZWAAAA + AAAIODg4ODg4AAAAAAAAAAAAAAAAAAAAAAADg4ODg4ODM4ODiDiDg4ODg4OIOIODg44BODiDioOBiuiu + p6euinqK6K6np66o6j4BioODg4ODOurqjq6nrq6urqeup3qK6h4Dg4OKg4ODjoruqK6o6o6o6uqOqurq + 6o4Bg4ODiDg4Oq6orqeup66np6iuqOqOqD4Dg4qIOKg4h6eup66Kenp6eurqeup66j4Biog4qDiDPqen + p66urq6np66K6np6eo4DiKg4OKiBiq6nrqiuqKeup6p6enp66j4Bg4OIODgzOup66nrqeup6eurqenrq + eo4BMRMTgTGBh66orqenp6rorop66np66j4AAAAAAAAAOup66np66nrqrqrqenrqeo4AAAAAAAAAinp6 + eup6enrqeurqeup66j4AAAAAAAAAPqrq6qeq6up6euqK6q6uqh4AAAAAAAAAiup6eup6eqeup66urqiu + 6j4AAAAAAAAAOup66np66n6qeqeqenrqqo4AAAAAAAAAGq6q6q6q6qrq6urqrqrq6j4AAAAAAAAAPq6u + qurq6urq6uqurq6q6o4AAAAAAAAAiq6q6uqq6q6qququqq6q6j4AAAAAAAAAOuqurqrq6uqurq6urq6u + ro4AAAAAAAAAiurqqurq6q6urqrqrqquqj4AAAAAAAAAPq6q6urqququqq6q6q6uro4AAAAAAAAAOqrq + 6qqurq6q6urqrq6q6j4AAAAAAAAAOurqqurqrqququqq6uquqj4AAAAAAAAAiuqurqrqrq6q6q6uqq6q + 6o4AAAAAAAAAOuququrqrqrq6q6q6uquqn4AAAAAAAAAeq6uququrqrqrq6q6q6uqo4AAAAAAAAAOq6q + rqquqq6qrqquqq6qrj4AAAAAAAAAgzODM4MzgzODM4MzgzODMT8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AA9///////4AAP///////wAA//8AAAP/AAD//wAAA/8AAP//AAAD/wAA//8AAAP/AAD//wAAA/8AAP// + AAAD/wAA//8AAAP/AAD//wAAA/8AAIADAAAD/wAAgAMAAAP/AACAAwAAA/8AAIADAAAD/wAAgAMAAAP/ + AACAAwAAA/8AAIADAAAD/wAAgAMAAAP/AACAA/////8AAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAA + AAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAIAAAAAAAAAA//wAAAAA + AAD//AAAAAAAAP/8AAAAAAAA//wAAAAAAAD//AAAAAAAAP/8AAAAAAAA//wAAAAAAAD//AAAAAAAAP/8 + AAAAAAAA//wAAAAAAAD//AAAAAAAAP/8AAAAAAAA//wAAAAAAAD//AAAAAAAAP/8AAAAAAAA//wAAAAA + AAD//AAAAAAAAP/8AAAAAAAA///////+AAAoAAAAIAAAAEAAAAABAAQAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP// + AADAwMAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVlZWVkZWVAAAAAAAAAAAAGRra2tGS2TgAAAAAA + AAAABWtrZrZrZl4AAAAAAAAAAAZrZra2trZHAAAAAAAAAAAFa2trZmtmTgAAAAAAAAAABrZra2tmtk4A + AADhOBMYMAVmtmZrbbZ+AAAA8Tg4MTcGtr2727a2RwAAAOGDE4OOBW1r29vb224AAADhODgxjgRrZmZm + ZmZOAAAA6Dg4OD4FZWVlZUZWdwAAAOODg4OOAAAAAAAAAAAAAADhg4OIMziIg4g4iDiIODg+44OKg4Gn + p66np6enp6jqPug4g4g4rqenqOp6enrqeo7xo4qIOHp6eurq6up6euo34YiDgxOup6enqK6K6np6h+MT + ETgYp66nqueqenp66j4AAAAAA66np656p+p66nqOAAAAAAGnrqeqfqp6enrqNwAAAAAD6uqurqqurq6q + 6ocAAAAACK6urqrq6q6q6uo+AAAAAAOuququ6urqrq6qjgAAAAAIququqqrq6uqq6jcAAAAAA+rq6q6u + rqqurq6OAAAAAAOq6q+uqqrq6q6qjgAAAAADrqrqqq6uququrj4AAAAAA66q6urqrqrq6qqHAAAAAAiu + quqq6q6q6qrqPgAAAAADODODgzg4M4ODOD4AAAAADu7u7u7u7u7u7u7v///////gAH//4AA//+AAP//g + AD//4AA//+AAPwBgAD8AIAA/ACAAPwAgAD8AIAA/AD///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP+A + AAD/gAAA/4AAAP+AAAD/gAAA/4AAAP+AAAD/gAAA/4AAAP+AAAD/gAAA/4AAAP+AAAAoAAAAEAAAACAA + AAABAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICA + gAAAAP8AAP8AAAD//wD/AAAA/wD/AP//AADAwMAA////AAAAAAAAAAAAAAAHu2a2cAAAAAdmtrtwAOc3 + B2a2ZnAAeDh+tr22cAB4OD5HZWVwAOg4Pn7qfn6ueIOKp6jqend6iIeup6enp+eOPqenrqenAAAK6qen + rqcAAArq6uqupwAADqrqrqrqAAAKrqrq6uoAAAqq6qqqpwAADu7q7u7u//8AAPgHAAD4BwAACAcAAAAH + AAAABwAAAAAAAAAAAAAAAAAAAAAAAPgAAAD4AAAA+AAAAPgAAAD4AAAA+AAAAIlQTkcNChoKAAAADUlI + RFIAAAEAAAABAAgGAAAAXHKoZgAADTFJREFUeNrt3QuoZVUZwPF9zrlN06SNltWYSoVMSFEUex5mvp2X + j6QiiEqskIysDIQeCBUVSA8QsjIypBIrgqgwdRrH16hNzovCKKRBKtTJzNTRaZoZz6Oz5t59717n7n1n + P9baa317/X+g39lnUPZ5/Wfts8+5txMBCFZH/WvnztHI9Y4AaNaKFZ3ObACWLnW9OwCasndvFKnXvBaA + 5cungwCg3dRrfvFiAgAESb3mp6YIABAkAgAEjAAAASMANfzqgxGnTSHSu38y95onABURAEhFAAwgAJCK + ABhAACAVATCAAEAqAmBAVgAu/u4a17sFzHPLJ+7UtgmAAQQAUhAACwgApCAAFhAASEEALCAAkIIAWEAA + IAUBsIAAQAoCYEFWAN553Zqo03O9Z4COAFiQtwIYDaLDEWAyfZm/uZIAGJe3AgB8QwAsIACQggBYQAAg + BQGwgABACgJgAQGAFATAgrwADPudqDs1YjK9mAoBsIAVACRQIbjtqs3adQTAgKwAXHjtWte7BcxDACzI + C8Dk8gto2uRhAIcAFiy0AkjufKBp6edecpkVgAUcAkAKAmABAYAUBMACAgApCIAFBABSEAALCACkIAAW + EABIQQAsyAvAsK9Ov0SHp8JlLru+vPGzBMC4hQKguH7QuczlBAGwICsA538j+SDQ+AE4NJ6LUjP1gGh/ + zvVcb+l6ta1wCGDBQgHINBz/0+V6rm/o+hRWABaUDoAynFsVaA8a13O9jetn/mzj5wmAcZkB+FpOANSD + MnS9xwhSlxWAFZVWAIADBMACAgAROASwo9QhAOAQAbCAAEAKAmABAYAUBMACAgApCIAFWQFYf83aqNuN + oiGn/OCRTVcTAONYAUAC9ZcRAbAgbwUA+EStSDkEsIAAQApWABYQAEhBACzIC8CoP75Dx3cqk+nDVAiA + BawAIAUBsCArAOu+QgDgnzu+SACMWygAPiz9mMxkEgALWAFAAhUBDgEsIACQghWABQQAUhAACwgApCAA + FhAA+G406ESd3ogA2JAXAHWnAz7Z/OU7tG0CYEBWANZ+ad3h4iblZTJdT4UAWJAXACV95wOuJM9DAmDB + QgEAfEIALCAAkIIAWEAAIAUBsIAAQAoCYEFWAM77wrrZHwrKZPowlbu+SgCMWygAig8PPpOpJgGwIC8A + gG8IgAUEAFIQAAsIAKQgABYQAEhBACzIC8BooD6CGTGZXkyFAFiQFYBzr2YFAP/cfQ0BMI4AQAoCYAEB + gBQEwAICACkIgAUEAFIQAAuyAnDO5wgA/HPP1wmAcQsFwIfTP0xmMgmABawAIAUBsIAAQAoCYAEBgBQE + wAICACkIgAUEAFIQAAuyAnD2ZwgA/HPvNwmAcQQAUhAACwgApCAAFhAASEEALCAAkIIAWJAXgOEgirq9 + iMn0YioEwAICwJQy77uWABiXFYAzr+IQAP4hABYQAEhBACzICsAZn17vereAWZ3e9FOUAFiw0ApAHXsN + DnWi3qIRk+l83v+tTdrzlAAYwAoAUhAACxYKgOviM5lGVgA/juc/yRFFH9oVdVgBQAL1PkDl9wAIQDYC + AElYARhGACAJATCMAEASAmAYAYAkRgNw1kmub07ztjyqbxMASGI2ACe6vjnN2/KYvp0XgNM/RQDgnwe+ + TQBqIQCQzGgATj/B9c1p3gOP69sEAJIQgJq27omiYeqeIACQhADUVHQF8I4rCAD887vrCUAtZQPg+rfB + MpnpSQBqYgUAyYwG4NTjp+dUN4r6wzAmAYBkxlcA6oURkgf/qW8TAEhiZQWg+PC3cxNz+xPFzgIQAPjI + WAC64z9Ztcz1zWkeKwBIZnQFsOp4fXv8l2Q0bPlUAVDxS1YBBACSGF0BrAhwBbC9xApg2B/fT+M7lcn0 + YSpWVwAhKBqAt1/OCgD++f0NBgOw4tXjsnRd36RmDGfOduz8l349hwCQQK0CFKMBUCuAYUCnAVXsthd8 + D0CtAJLlF+AL4yuA0BRdAXAIAB8RgJoIACQjADURAEhmNABvfaXrm9O8P/5b3yYAkIQVQEXJdx6KBuDU + ywgA/JF8HfjBG1kB1PLQU8W+C5AEwPX3v5nM9DQWAHUq7E3HRVHP9SuyYWUOAXx4wJlMNRV1mfcAaiq7 + AlBGw07U6Y6YTKdTMXoI8ObAAqBWO7wHAGnU3/zDF6YjQABq+nPBFcDqj2xwvavArGQlsO2Hv9WuJwAl + /angCiAJQLL0AlxQL/o0AlBT2QAAPjEaAHUWIDTqECCNAEASAlATAYBkBKAmAgDJCEBNBACSGQ3AKS93 + fXOa9/DT+nbRAAwHUdTtMZluJwGoqWgAVl66YfaOT/jwBGCGPQlABYPxLe/N3BNlAqBMRgBwacdNBgOw + /FjXN6c5KgAqBLuf0a8/UgAAnxgLgPo24MnHzL0w2j4TBACSsQKo6ZFni30XYOUlGyIvfpURk5maBKCm + UisATx50ZuAzmrk8tuNmgwFQhwChUSuAIr8X4PAKAPAMAahJBSAtLwCABASgJAKANiEAJREAtImRAAyG + UdTrhjH//px+HxAASFYrAK97mevdb15WAFzvE1AXASiIAKCNCEBBBABtVCsA/fGfTHXCmHv2zf8koOsH + D6irUgBOPNr1bjfvsef1bQKANiAABbECQBsRgIJYAaCNKgXghKPG/0FgT38VgMnvAhT57+L4cj4r0EK7 + dt3QildA5QCE5vF9+jYBCBsBCAwBQFrQAVj2Ute73bwn/qtvE4CwEYDAPLm/2lkAAtBOBCAwJlcAuy66 + 0vXNQUnxrddp2wQgMCoAps4CEAB5CEBKqAFIIwBhIQApSQD6wyia6oYxn/qffh8YCcBw6PrxR0Hx7d/R + toMOwHEvcb3bzTMagAs+OffTRiACAUgJMQBPHzB3FmA2ABAj3nS9tk0AAmN0BbD+Ctc3B2WMV2qsAFJC + DYCxswAEQI6ZBzze/D3tagIQGKMrgLUfd31zUBIBSDnmxa53u3nPHtS3aweAMwCixHd9X9sOOgBqBeDD + qbmmpmI0AOd9zPXjjjK6XVYAaSGuAJ47ZPAsAAEQhxVASogBMLoCOOejrm8OylArAAIwJ9QAGDsLQADE + ie/5gbZNAALDCiBsBCDlqBe53u3m7XtB364VgDMvc31zUFJ8343adrABUMvgJVPT75CHIDkLQADCRgBS + 0isA9frotngm9vcNngVIAtAfjEvaYwqY8dYf6Y9hyAFYkgqADy9SGzNNXWd0BXDah6cvJE8y+G38OLEC + SFkS4HsAB0yuAJIAQAxWACkhBmC/jRUAxCAAKZMBUB9r77b8TUEVAGOfA1AB4OcBiBJvu0nbJgDR3PdZ + 1Iu/rd9tSW7bgYlD9VoBWH2p65uFkghAyuLe/P9RmyOgEICwEYCUrAC0ndEArLzE9c1BGeq7AARgThKA + /vhPplpxNxwZAQhbvONmbZsARHMBaPtUjAYg/oDrxx15kmPZiXe1CUBKKB8DTutPvL9BAAKhTvt0O1G8 + 66fa1cEGQJ0K67bippdjNABve7/rm4MyCICOFQABCE38h59p2wQgIGoVOJy4FwhAyyW/uWlmEoCUEA8B + Zg4FzXwSUAWATwKKEj/0c2076ACgZgDe8j7Xu4+SCAA0tQOQfNc84cF33pn5kwBAYyQACQ+e4MyMmXp8 + CAA0tQLwxve63n2UFP/lF9p2MAFAPUcMQPKpM6Zfc/JxJACoIjcAIXyXukXih3+pbRMAFJIZgFPe43q3 + UIb6NiArAFRBANqBFQAqyQzAG97lerdQhloBEABUQQDaIf7rr7VtAoBCCEA7EABUkhmAky92vVsoKX7k + Fm2bAKCQzAC8/iI/znUzC38mgACgktwVAOf+RYn/dqu2TQBQSO4KAKIQAFSSG4AhX7GQJP7Hbdo2AUAh + mQF47YWudwslEQBUkhsA3gMQJX50o7ZNAFBIZgBOOt/1bqGMQSeK99yuXUUAUEhmAF5zwcwl9UMnekzv + Z0QAUE12ANa73i2U0iMAqCZ/BTCo8H+DK/GeTdo2AUAhmQFYts71bqEM9ZuBCACqIADCzZytiZ+8U7ua + AKCQzAC8ao3r3UJJBACVEIB2IACoJDcAE797jun3JACoJDMArzh37skFEeL/3K1tEwAUkhsA199xZx55 + KsnPAyAAqGLBAECM+Jl7tW0CgEIyA3Ds2a53CyURAFSSGwB+HoAo8d4t2jYBQCGZAVh6luvdQkkEAJXk + BoD3AESJn79f2yYAKCQzAEef4Xq3UIb6zUCsAFAFAWgHVgCoJDMAS05zvVsoqjfzA0EIAKogAO0Q79+q + bRMAFEIA2oEAoBIC0A4EAJXkBqDPjwQTY6pHAFBNZgAWrXa9WygpPrRN2yYAKIQAtAMBQCW5AeC7AKLE + /e3aNgFAIZkBmFrlerdQEgFAJVkBgHwEAIUQgHYiACiEALQTAUAhBKCdCAAA8QgAEDACAASMAAABIwBA + wAgAEDACAASMAAABmxcA1zsEoFmzAVB27x6NDh6Mon7f9W4BaMr/AZCxqA55eVu6AAAAAElFTkSuQmCC + KAAAADAAAABgAAAAAQAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmMzMAmjkDAJ46AACePgMA + oj8AAKJCAwCmQwAApkcDAKpJAACpTAMArk4AAK1RAwCyUwAAsVYDALVZAAC5XQAAvmIAALxkAwDBaAAA + w24DAMZtAADHcwMAynIAAMt3AwDOdwAA0nwAAAAzoQAANKMAADSkAAA2qQAAOa4AADqyAAA8tQAAPbkA + AD+8AABbrwAAQL4AAEHBAABDxQAARMYAAEXJAABGzAAASM8AAEjQAABK1AAATNkASLnkAEi95gBHwugA + R8XqAEfI6wBHyuwARs3tAEbR7wBG0/AARtbyAEba9ABF3fUAReD3AEXj+ABF5vkAROn7AETt/ABE8P4A + rLzZALrH3wDl2eIA/uHhAACwNgAAz0AAAPBKABH/WwAx/3EAUf+HAHH/nQCR/7IAsf/JANH/3wD///8A + AAAAAAIvAAAEUAAABnAAAAiQAAAKsAAAC88AAA7wAAAg/xIAPf8xAFv/UQB5/3EAmP+RALX/sQDU/9EA + ////AAAAAAAULwAAIlAAADBwAAA9kAAATLAAAFnPAABn8AAAeP8RAIr/MQCc/1EArv9xAMD/kQDS/7EA + 5P/RAP///wAAAAAAJi8AAEBQAABacAAAdJAAAI6wAACpzwAAwvAAANH/EQDY/zEA3v9RAOP/cQDp/5EA + 7/+xAPb/0QD///8AAAAAAC8mAABQQQAAcFsAAJB0AACwjgAAz6kAAPDDAAD/0hEA/9gxAP/dUQD/5HEA + /+qRAP/wsQD/9tEA////AAAAAAAvFAAAUCIAAHAwAACQPgAAsE0AAM9bAADwaQAA/3kRAP+KMQD/nVEA + /69xAP/BkQD/0rEA/+XRAP///wAAAAAALwMAAFAEAABwBgAAkAkAALAKAADPDAAA8A4AAP8gEgD/PjEA + /1xRAP96cQD/l5EA/7axAP/U0QD///8AAAAAAC8ADgBQABcAcAAhAJAAKwCwADYAzwBAAPAASQD/EVoA + /zFwAP9RhgD/cZwA/5GyAP+xyAD/0d8A////AAAAAAAvACAAUAA2AHAATACQAGIAsAB4AM8AjgDwAKQA + /xGzAP8xvgD/UccA/3HRAP+R3AD/seUA/9HwAP///wAAAAAALAAvAEsAUABpAHAAhwCQAKUAsADEAM8A + 4QDwAPAR/wDyMf8A9FH/APZx/wD3kf8A+bH/APvR/wD///8AAAAAABsALwAtAFAAPwBwAFIAkABjALAA + dgDPAIgA8ACZEf8ApjH/ALRR/wDCcf8Az5H/ANyx/wDr0f8A////AAAAAAAIAC8ADgBQABUAcAAbAJAA + IQCwACYAzwAsAPAAPhH/AFgx/wBxUf8AjHH/AKaR/wC/sf8A2tH/AP///wBEAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQIDAwMDAwMDAwMDAwMDAwMDAwMDAQAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAQQFBQUFBQUFBQUFBQUFBQUFBQUFAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AQYHBwcHBwcHBwcHBwcHBwcHBwcHAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQgJCQkJCQkJCQkJ + CQkJCQkJCQkJAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQoMlZWVlZWVlZWVlZWVlZWVlZWVAQAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQwNDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NAQAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAQ4PEA8PDw8PDw8PDw8PDw8PDw8PAQAAAAAAAAAAAAAAGxsbGxsbGxsbGxsbHAAA + AQ8QEBAQEBAQEBAQEBAQEBAQEBAQAQAAAAAAAAAAAAAAGxwdHR0dHR0dHR0dGwAAARASERERERERERER + ERERERERERERAQAAAAAAAAAAAAAAHB4eHh4eHh4eHh4eGwAAARITExMTExMTExMTExMTExMTExMTAQAA + AAAAAAAAAAAAGx4eHh8eHx4fHh8fGwAAARMVFRUVFRUVFRUVFRUVFRUVFRUVAQAAAAAAAAAAAAAAGx8f + Hx8fHx8fHx8fGwAAARQXFxcXFxcXFxcXFxcXFxcXFxcXAQAAAAAAAAAAAAAAGyAhISEhISEhISEgGwAA + ARYZGRkZGRkZGRkZGRkZGRkZGRkZAQAAAAAAAAAAAAAAGyEhISEhISEhISEhGwAAARgaGhoaGhoaGhoa + GhoaGhoaGhoaAQAAAAAAAAAAAAAAGyIiIyIjIyIjIyMiGwAAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQAA + AAAAAAAAAAAAGyUlJSUlJSUlJSUlGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGyYm + JiYmJiYmJiYmGyQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJEIAGyYnJygnKCcoJycnHCQv + Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vJEEAGygpKSkpKSkpKSkpHCQwLzAwMDAwMDAwMDAw + MDAwMDAwMDAwMDAwMDAwMDAvJEEAGykrKiorKisqKyoqHCQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw + MDAwMDAwJEEAGyosLCwsLCwsLCwsGyQwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwJEEAGywt + LS0tLS0tLS0tHCQxMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExJEEAGy0uLi4uLi4uLi4uHCQy + MjIxMjEyMTIxMjEyMTIxMjEyMTIxMjEyMTIxMjEyJEEAGy4uLi4uLi4uLi4uGyQyMjIyMjIyMjIyMjIy + MjIyMjIyMjIyMjIyMjIyMjIyJEEAGyorKysrKysrKysrGyQzMzQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0 + NDQ0NDQzJEEAGxsbGxsbGxsbGxsbHCQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDU0JEEAAAAA + AAAAAAAAAAAAACQ1NTU1NTU1NTU1NTU1NTU1NTU1NTU1NTU1NTU1NTU1JEEAAAAAAAAAAAAAAAAAACQ1 + NTU1NTU1NTU1NTU1NTU1NTU1NTU1NTU1NTU1NTU1JEEAAAAAAAAAAAAAAAAAACQ2Njc3Nzc3Nzc3Nzc3 + Nzc3Nzc3Nzc3Nzc3Nzc3NzY2JEEAAAAAAAAAAAAAAAAAACQ3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3 + Nzc3Nzg3JEEAAAAAAAAAAAAAAAAAACQ4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4JEEAAAAA + AAAAAAAAAAAAACQ4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4JEEAAAAAAAAAAAAAAAAAACQ5 + OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5JEEAAAAAAAAAAAAAAAAAACQ6Ojo6Ojo6Ojo6Ojo6 + Ojo6Ojo6Ojo6Ojo6Ojo6Ojo6JEEAAAAAAAAAAAAAAAAAACQ7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7 + Ozs7Ozs7JEEAAAAAAAAAAAAAAAAAACQ7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7JEEAAAAA + AAAAAAAAAAAAACQ8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8JEEAAAAAAAAAAAAAAAAAACQ9 + PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09JEEAAAAAAAAAAAAAAAAAACQ9PT09PT09PT09PT09 + PT09PT09PT09PT09PT09PT09JEEAAAAAAAAAAAAAAAAAACQ+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+ + Pj4+Pj4+JEEAAAAAAAAAAAAAAAAAACQ/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/JEEAAAAA + AAAAAAAAAAAAACQ/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/Pz8/JEEAAAAAAAAAAAAAAAAAACRA + QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAJEEAAAAAAAAAAAAAAAAAACQkJCQkJCQkJCQkJCQk + JCQkJCQkJCQkJCQkJCQkJCQkJEMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAER///////4O7v///////w7u//8AAAP/Du7//wAAA/8O7v//AAAD/w7u//8AAAP/Du7//wAA + A/8O7v//AAAD/w7u//8AAAP/Du7//wAAA/8O7oADAAAD/w7ugAMAAAP/Du6AAwAAA/8O7oADAAAD/w7u + gAMAAAP/Du6AAwAAA/8O7oADAAAD/w7ugAMAAAP/Du6AA/////8O7oAAAAAAAA7ugAAAAAAADu6AAAAA + AAAO7oAAAAAAAA7ugAAAAAAADu6AAAAAAAAO7oAAAAAAAA7ugAAAAAAADu6AAAAAAAAO7oAAAAAAAA7u + //wAAAAADu7//AAAAAAO7v/8AAAAAA7u//wAAAAADu7//AAAAAAO7v/8AAAAAA7u//wAAAAADu7//AAA + AAAO7v/8AAAAAA7u//wAAAAADu7//AAAAAAO7v/8AAAAAA7u//wAAAAADu7//AAAAAAO7v/8AAAAAA7u + //wAAAAADu7//AAAAAAO7v/8AAAAAA7u///////+Du4oAAAAIAAAAEAAAAABAAgAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAGYzMwCfOwAApEEAAKtKAACwUQAAt1oAALxgAADDaQAAyHAAAM94AAAAM6EA + ADapAAA4rQAAO7QAAD24AABbrwAAQL8AAELDAABFygAAR84AAErVAABM2gBVfMEAf5jPAHygzABIuuUA + SL7mAEfB6ABHxOkAR8jrAEfL7ABGz+4ARtLvAEbV8gBG2fMARd31AEXj+ABF5vkAROr7AETt/ACxmJgA + gaTOAJCqzwDHu9QAx7zUAMfE1gDf1d8A59beAAAvIQAAUDcAAHBMAACQYwAAsHkAAM+PAADwpgAR/7QA + Mf++AFH/yABx/9MAkf/cALH/5QDR//AA////AAAAAAAALw4AAFAYAABwIgAAkCwAALA2AADPQAAA8EoA + Ef9bADH/cQBR/4cAcf+dAJH/sgCx/8kA0f/fAP///wAAAAAAAi8AAARQAAAGcAAACJAAAAqwAAALzwAA + DvAAACD/EgA9/zEAW/9RAHn/cQCY/5EAtf+xANT/0QD///8AAAAAABQvAAAiUAAAMHAAAD2QAABMsAAA + Wc8AAGfwAAB4/xEAiv8xAJz/UQCu/3EAwP+RANL/sQDk/9EA////AAAAAAAmLwAAQFAAAFpwAAB0kAAA + jrAAAKnPAADC8AAA0f8RANj/MQDe/1EA4/9xAOn/kQDv/7EA9v/RAP///wAAAAAALyYAAFBBAABwWwAA + kHQAALCOAADPqQAA8MMAAP/SEQD/2DEA/91RAP/kcQD/6pEA//CxAP/20QD///8AAAAAAC8UAABQIgAA + cDAAAJA+AACwTQAAz1sAAPBpAAD/eREA/4oxAP+dUQD/r3EA/8GRAP/SsQD/5dEA////AAAAAAAvAwAA + UAQAAHAGAACQCQAAsAoAAM8MAADwDgAA/yASAP8+MQD/XFEA/3pxAP+XkQD/trEA/9TRAP///wAAAAAA + LwAOAFAAFwBwACEAkAArALAANgDPAEAA8ABJAP8RWgD/MXAA/1GGAP9xnAD/kbIA/7HIAP/R3wD///8A + AAAAAC8AIABQADYAcABMAJAAYgCwAHgAzwCOAPAApAD/EbMA/zG+AP9RxwD/cdEA/5HcAP+x5QD/0fAA + ////AAAAAAAsAC8ASwBQAGkAcACHAJAApQCwAMQAzwDhAPAA8BH/APIx/wD0Uf8A9nH/APeR/wD5sf8A + +9H/AP///wAAAAAAGwAvAC0AUAA/AHAAUgCQAGMAsAB2AM8AiADwAJkR/wCmMf8AtFH/AMJx/wDPkf8A + 3LH/AOvR/wD///8AAAAAAAgALwAOAFAAFQBwABsAkAAhALAAJgDPACwA8AA+Ef8AWDH/AHFR/wCMcf8A + ppH/AL+x/wDa0f8A////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB + AQEBAQEBAQEBAQEBAQAAAAAAAAAAAAAAAAAAAAAAAAECAgICAgICAgICAgIBKQAAAAAAAAAAAAAAAAAA + AAAAAQMDAwMDAwMDAwMDAwEpAAAAAAAAAAAAAAAAAAAAAAABBAQEBAQEBAQEBAQEASkAAAAAAAAAAAAA + AAAAAAAAAAEFBQUFBQUFBQUFBQUBKQAAAAAAAAAAAAAAAAAAAAAAAQYGBgYGBgYGBgYGBgEpAAAAAAAA + LAsLCwsLCwsLAAABBwcHBwcHBwcHBwcHASkAAAAAAAAsCwwMDAwMDAsYAAEICAgICAgICAgICAgBKQAA + AAAAACwLDQ0NDQ0NCxgAAQkJCQkJCQkJCQkJCQEpAAAAAAAALAsODg4ODg4LGAABCgoKCgoKCgoKCgoK + ASkAAAAAAAAsCw8PDw8PDwsYAAEBAQEBAQEBAQEBAQEBKQAAAAAAACwLERERERERCxcAAAAAAAAAAAAA + AAAAAAAAAAAAAAAALAsSEhISEhILEBAQEBAQEBAQEBAQEBAQEBAQEBAQECosCxMTExMTEwsQGhoaGhoa + GhoaGhoaGhoaGhoaGhoQGSwLFBQUFBQUCxAbGxsbGxsbGxsbGxsbGxsbGxsbGxAZLAsVFRUVFRULEBwc + HBwcHBwcHBwcHBwcHBwcHBwcEBktCxYWFhYWFgsQHR0dHR0dHR0dHR0dHR0dHR0dHR0QGS0LCwsLCwsL + CxAeHh4eHh4eHh4eHh4eHh4eHh4eHhAZAAAAAAAAAAAAEB8fHx8fHx8fHx8fHx8fHx8fHx8fEBkAAAAA + AAAAAAAQICAgICAgICAgICAgICAgICAgICAQGQAAAAAAAAAAABAhISEhISEhISEhISEhISEhISEhIRAZ + AAAAAAAAAAAAECIiIiIiIiIiIiIiIiIiIiIiIiIiEBkAAAAAAAAAAAAQIyMjIyMjIyMjIyMjIyMjIyMj + IyMQGQAAAAAAAAAAABAkJCQkJCQkJCQkJCQkJCQkJCQkJBAZAAAAAAAAAAAAECUkJSQlJCQkJCQkJCQk + JCQkJCQkEBkAAAAAAAAAAAAQJSUlJSUlJSUlJSUlJSUlJSUlJSUQGQAAAAAAAAAAABAmJiYmJiYmJiYm + JiYmJiYmJiYmJhAZAAAAAAAAAAAAECcnJycnJycnJycnJycnJycnJycnEBkAAAAAAAAAAAAQKCgoKCgo + KCgoKCgoKCgoKCgoKCgQGQAAAAAAAAAAABAQEBAQEBAQEBAQEBAQEBAQEBAQEBArAAAAAAAAAAAALy4u + Li4uLi4uLi4uLi4uLi4uLi4uLjD//////+AAf//gAD//4AA//+AAP//gAD//4AA/AGAAPwAgAD8AIAA/ + ACAAPwAgAD8AP///AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/4AAAP+AAAD/gAAA/4AAAP+AAAD/gAAA + /4AAAP+AAAD/gAAA/4AAAP+AAAD/gAAA/4AAACgAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAoj8AAK5OAAC6XQAAr2MPAMZtAACqbEwAsHNMALZ7TACwflQAvINMALKDbwC2h28A + uYxvAL2RbwC2jnQAADerAAA8tgAQUL8AQGi9AABCwgAAR80AEFPEAABM2AAlW8AAQGrDAD6w3wA+tuEA + PrzkAHiGwgB4iMUAcIzKAHiJyQB4jM0AZI3QAHCT2QBftdwAX7neAGCt2ABgstoAR7zmAF+/4QA9wucA + PcjqADzO7QA81O8AO9ryAEfD6QBGyuwAXsLhAEbR7wBG2PIARd/1AEXl+ABE7PwAu7zZALu93ACBuuAA + g73iAJrA3wClw9sApsbcALfH3AD///8AAAAAAAAvDgAAUBgAAHAiAACQLAAAsDYAAM9AAADwSgAR/1sA + Mf9xAFH/hwBx/50Akf+yALH/yQDR/98A////AAAAAAACLwAABFAAAAZwAAAIkAAACrAAAAvPAAAO8AAA + IP8SAD3/MQBb/1EAef9xAJj/kQC1/7EA1P/RAP///wAAAAAAFC8AACJQAAAwcAAAPZAAAEywAABZzwAA + Z/AAAHj/EQCK/zEAnP9RAK7/cQDA/5EA0v+xAOT/0QD///8AAAAAACYvAABAUAAAWnAAAHSQAACOsAAA + qc8AAMLwAADR/xEA2P8xAN7/UQDj/3EA6f+RAO//sQD2/9EA////AAAAAAAvJgAAUEEAAHBbAACQdAAA + sI4AAM+pAADwwwAA/9IRAP/YMQD/3VEA/+RxAP/qkQD/8LEA//bRAP///wAAAAAALxQAAFAiAABwMAAA + kD4AALBNAADPWwAA8GkAAP95EQD/ijEA/51RAP+vcQD/wZEA/9KxAP/l0QD///8AAAAAAC8DAABQBAAA + cAYAAJAJAACwCgAAzwwAAPAOAAD/IBIA/z4xAP9cUQD/enEA/5eRAP+2sQD/1NEA////AAAAAAAvAA4A + UAAXAHAAIQCQACsAsAA2AM8AQADwAEkA/xFaAP8xcAD/UYYA/3GcAP+RsgD/scgA/9HfAP///wAAAAAA + LwAgAFAANgBwAEwAkABiALAAeADPAI4A8ACkAP8RswD/Mb4A/1HHAP9x0QD/kdwA/7HlAP/R8AD///8A + AAAAACwALwBLAFAAaQBwAIcAkAClALAAxADPAOEA8ADwEf8A8jH/APRR/wD2cf8A95H/APmx/wD70f8A + ////AAAAAAAbAC8ALQBQAD8AcABSAJAAYwCwAHYAzwCIAPAAmRH/AKYx/wC0Uf8AwnH/AM+R/wDcsf8A + 69H/AP///wAAAAAACAAvAA4AUAAVAHAAGwCQACEAsAAmAM8ALADwAD4R/wBYMf8AcVH/AIxx/wCmkf8A + v7H/ANrR/wD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAACwEBAQEBAQYAAAAAAAAAAAwCAgICAgIHAAAA + Nx8fHwANAwMDAwMDCAAAAB0QEBATDgUFBQUFBQoAAAAeERERGQ8EBAQEBAQJAAAAIBQUFBg5Ojo6Ojo6 + Ojo6OyAVFRUSGigoKCgoKCgoKCYhFxcXFhsvLy8vLy8vLy8mOCMjIyIcMDAwMDAwMDAwJwAAAAAAKjIy + MjIyMjIyMiQAAAAAACszMzMzMzMzMzMlAAAAAAAsNDQ0NDQ0NDQ0JQAAAAAALTU1NTU1NTU1NSkAAAAA + AC42NjY2NjY2NjYxAAAAAAA8PT09PT09PT09Pv//AAD4BwAA+AcAAAgHAAAABwAAAAcAAAAAAAAAAAAA + AAAAAAAAAAD4AAAA+AAAAPgAAAD4AAAA+AAAAPgAAACJUE5HDQoaCgAAAA1JSERSAAABAAAAAQAIBgAA + AFxyqGYAAA0ASURBVHja7dp1tJdFHsfxi4KigihggB3YPXSrlL1u79rd2B3Y3Qp2YGzvuiLdl7i03dgF + SkiJICB7OHvOXWbv3HNmfs/3eWbmN+/XH/ecz3/f4fC8+YNbpwJAsuqs+TF9+urVvg8BUKyWLevUqQ5A + o0a+zwFQlIULKyrWfPNaAFq0+G8QAJS3Nd98/foEAEjSmm++Xj0CACRpzTdfty4BAJJEAICEEYAMXjqm + gv82RZSOfvF/3zwBKBEBQKwIgAACgFgRAAEEALEiAAIIAGJFAASYAnBUv26+zwJqePnskdomAAIIAGJB + AHJgDEBfAoDwvHwOARBHABALApADUwCOJAAI0AACIM8YgIcJAMIz4FwCII4AIBYEIAfGADxEABCeAecR + AHEEALEgADkwBeCIBwkAwvNKbwIgjgAgFgQgBwQAsSAAOTAG4AECgPC8cj4BEEcAEAsCkANTAA6/v7vv + s4AaBl4wQtsEQAABQCwIQA6MAbiPACA8Ay8kAOIIAGJBAHJAABALApADUwAOu5cAIDyDLiIA4ggAYkEA + cmAMwD0EAOEZdDEBEEcAEAsCkANjAO4mAAjPoEsIgDhTAA4lAAjQYAIgjwAgFgQgB8YA3EUAEJ7BlxIA + cQQAsSAAOTAG4E4CgPAMvowAiDMF4BACgAANIQDyjAG4gwAgPEMuJwDiCABiQQByQAAQCwKQA2MAbicA + CM+QKwiAOAKAWBCAHJgC0Os2AoDwDL2SAIgjAIgFAciBMQC3EgCEZ+hVBEAcAUAsCEAOCABiQQByYApA + z1sIAMIz7GoCII4AIBYEIAfGANxMABCeYdcQAHEEALEgADkwBuAmAoDwDLuWAIgzBaAHAUCAhhMAeQQA + sSAAOTAG4EYCgPAMv44AiCMAiAUByIExADcQAIRneB8CIM4UgO439PB9FlDDiD7DtU0ABBgDcD0BQHhG + XE8AxBEAxIIA5IAAIBYEIAfGAPQhAAjPiBsIgDhTALoRAARoJAGQZwzAdQQA4Rl5IwEQRwAQCwKQA2MA + riUACM/ImwiAOAKAWBCAHJgCcDABQIBGEQB5xgBcQwAQnlE3EwBxBACxIAA5MAbgagKA8Iy6hQCIIwCI + BQHIgSkAB11FABCe0bcSAHEEALEgADkgAIgFAciBMQBXEgCEZ/RtBEAcAUAsCEAOTAE48AoCgPCMuZ0A + iCMAiAUByIExAJcTAIRnzB0EQBwBQCwIQA6MAbiMACA8Y+4kAOJMAehKABCgsQRAHgFALAhADowBuJQA + IDxj7yIA4ggAYkEAcmAMwCUEAOEZezcBEGcKQBcCgABVEgB5xgBcTAAQnsp7CIA4AoBYEIAcEADEggDk + wBiAiwgAwlN5LwEQZwpA54t6+j4LqGHcvcO0TQAEGANwIQFAeMbdRwDEEQDEggDkwBiACwgAwjPufgIg + jgAgFiUHoL+q+ZccFRUnzKioYwpAJwKAAI0nALJqDcD5BADhGf8AARBFABATAiCs1gD0JgAIz/gHCYAo + AoCYiAagyza+n1O8yi/1XVsAOp5HABCeCQ9JBmBr388pXuVX+iYAiIloADonGIBxBAAREw1ApwQDMN42 + AOcSAIRnwsOCAei4le/nFG/C1/omAIgJAcjINgAdziEACM/EvoIB6JBgACYSAERMNADtEwxAlW0AziYA + CM/EfpIBaO77OcWr+kbfBAAxEQ1AuwQDMIkAIGKiAWibYAAm2wbgLAKA8Ex8RDIAzXw/p3iTZ+m7tgC0 + JwAIUJVkANokGIAptgE4kwAgPFWPCgagdYIBmEoAEDHRALTa0vdzijdttr5rDcAZBADhqXqMAGRCABAz + 0QC0TDAA0y0D0I4AIECTJAOgtvD9nOLN+FbftQbgdAKA8Ex6nABkQgAQM9EAHJBgAF61DcBpBADhmfSE + YAD239z3c4r32nf6JgCICQHIyDYAbU8lAAjP5CcFA7BfggF4nQAgYqIB2Hcz388p3htz9E0AEBMCkJF1 + AE4hAAjP5KcEA7BPggF4kwAgYqIB2DvBALxlGYA2J/fyfSpQw5Snh2o7UwD2aur7OcV7e66+CQBiQgAy + sg7ASQQA4ZnyjGAA9kwwAO8QAERMNAB7NPH9nOK9O0/fBAAxIQAZ2Qag9YkEAOGZ+qxgAHZPMADvEQBE + TDQAuzX2/ZzivT9f37UG4AQCgPBM7U8AMiEAiJloAHZNMAAf2AbgeAKA8Ex9TjAAu2zq+znF+/B7fdcW + gFYEAAGaRgCyIQCImWgAWiQYgJm2ATiOACA8054XDMDOm/h+TvE+WqBvAoCYiAZgpwQD8LFtAI4lAAjP + tBcIQCa2AQBikCkAOzbyfX7xPlmobwKAmGUKwA4JBuBTAoAyQgAcEQCUk0wB2D7BAHxmCIDvm4CsSgrA + dhv7Prt4ny/SNwFAOSAAlggAylFJAdg2wQB8QQBQhkoKwDYNfZ9dvC8X65sAoByUFICtEwzAVwQAZYgA + WCIAKEclBWCrBr7PLt7XS/RtGwClTud3BcrQjBmPl8U/ACUFoHmCAfiGAGAtBCAxBABrSzoAzTbyfXbx + Zv2gbwKQtqQDsGWCAZhNALAWApAYyQDMOLy37+fAkRr4oLaTDsAWG/o+u3jfLtV3pgAcdp7v58CRGvSQ + tpMOwOYJBuA7yQAcSgBiowYTgGoEIGMADjnX93PgSA15WNtJB2CzDXyfXbw5P+o7UwB6neP7OXCkhvbV + dtIBaJpgAOZKBqDn2b6fA0dqWD9tJx2AJgkGYJ5kAHoQgNio4QSgGgHIGIDuZ/l+DhypEY9oO+kANK7v + ++zizV+m70wB6Ham7+fAkRr5qLaTDsCmCQbge8kAHHyG7+fAkRr1mLYJQGIIQNoIwFo2Wd/32cVbsFzf + mQJw0Om+nwNHavTj2k46AI0SDMBCyQAceJrv58CRGvOEtglAYkQD0PVU38+BIzX2SW0nHYCN1/N9dvEW + /aTvTAHoQgBioyoJQLWGCQZgsWQAOp/i+zlwpMY9pW0CkBjRAHQ62fdz4EiNf1rbSQegQT3fZxdvyQp9 + ZwpAx5N8PweO1IRntJ10ADZKMAA/SAagAwGIjZpIAKptmGAAlkoGoP2Jvp8DR6rqWW2nHYC6vs8u3tKV + +s4UgHYn+H4OHKlJ/bWddAA2SDAAP0oGoO3xvp8DR2ryc9pOOgD1EwzAMskAtCEAsVFTCEC1+uv6Prt4 + y1bpO1MAWh/n+zlwpKY+r+2kA7B+ggFYLhmAVsf6fg4cqWkvaDvpAKyXYAB+kgxAy2N8PweO1PQXtU0A + EiMaAEUAYqNmEIBq9dbxfXbxVvys70wBOOCPvp8DR+rVP2k76QDUTTAAKyUDsP8ffD8HjtRrf9Z20gFY + N8EArJIMwH6/9/0cOFKv/0XbaQegLJ7uZtX//SlkCsC+BCA26g0CUG2dsni6m58lA7DP73w/B47Um3/V + dtIBQMYA7P1b3+fDkXrrb9omAInLFIC9fuP7fDhSb/9d2wQgcZkCsCcBiI16hwBgLZkCsMevfZ8PR+rd + f2g7mQAgG2MAdv+V77PgSL33T20TAFgxBmC3X/o+C47U+//SNgGAFQJQHggASmIMwK5H+z4LjtQHL2mb + AMCKMQC7/ML3WXCkPvy3tgkArBgD0OIo32fBkZr5srYJAKwYA7AzAYiN+ogAoATGAOx0pO+z4Eh9PEDb + BABWjAHY8QjfZ8GR+uQVbRMAWDEGYIfDfZ8FR+rTgdomALBiDMD2BCA26jMCgBIYA7DdYb7PgiP1+SBt + EwBYMQZg20N9nwVH6ovB2iYAsGIMwDaH+D4LjtSXQ7RNAGDFGICtCUBs1FcEACUwBmCrXr7PgiP19VBt + EwBYMQageU/fZ8GR+maYtgkArBgD0KyH77PgSM0arm0CACvGAGxJAGKjZhMAlMAYgC26+z4LjtS3I7RN + AGDFGIDNu/k+C47UdyO1TQBgxRiAzQ72fRYcqTmjtE0AYMUYgKYEIDZqLgFACYwBaHKQ77PgSM0brW0C + ACvGADQ+0PdZcKTmj9E2AYAVYwA27er7LDhS34/VNgGAFWMANunq+yw4UgvGapsAwIoxAI26+D4LjtTC + Sm0TAFgxBmDjzr7PgiO1aJy2CQCsGAPQsJPvs+BILR6vbQIAKwSgPBAAlMQYgAYdfZ8FR2rJBG0TAFgx + BmCjDr7PgiP1w0RtEwBYMQZgw/a+z4IjtbRK2wQAVowB2IAAxEb9SABQAmMA6rfzfRYcqWWTtE0AYMUY + gPXb+j4LjtTyydomALBiDMB6bXyfBUfqpynaJgCwYgxAPQIQG7WCAKAExgDUbe37LDhSK6dqmwDAijEA + 67byfRYcqVXTtE0AYMUUAMSPAMAKAShPBABWCEB5IgCwQgDKEwEAED0CACSMAAAJIwBAwggAkDACACSM + AAAJIwBAwmoEwPdBAIpVHYA1Zs5cvXr58oqKVasqKsgBkIb/AA/38rf1PkgbAAAAAElFTkSuQmCCKAAA + ADAAAABgAAAAAQAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7i4gAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7g + 4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAGYzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2Yz + M2YzM2YzM2YzM2YzM2YzM2YzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM5o5A546AJ46AJ46AJ46AJ46AJ46 + AJ46AJ46AJ46AJ46AJ46AJ46AJ46AJ46AJ46AJ46AJ46AJ46AJ46AGYzMwAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AGYzM54+A6I/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/AKI/ + AKI/AGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM6JCA6ZDAKZDAKZDAKZDAKZDAKZDAKZDAKZDAKZDAKZD + AKZDAKZDAKZDAKZDAKZDAKZDAKZDAKZDAKZDAGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM6ZHA6pJAKpJ + AKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAKpJAGYzMwAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAGYzM6lMA65OAK5OAK5OAK5OAK5OAK5OAK5OAK5OAK5OAK5OAK5OAK5OAK5OAK5O + AK5OAK5OAK5OAK5OAK5OAGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM61RA7JTALJTALJTALJTALJTALJT + ALJTALJTALJTALJTALJTALJTALJTALJTALJTALJTALJTALJTALJTAGYzMwAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AGYzM7FWA7ZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZALZZ + ALZZAGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzoQAzoQAzoQAzoQAzoQAzoQAz + oQAzoQAzoQAzoQAzoQAzoQAzoQAAAAAAAGYzM7RaA7pdALpdALpdALpdALpdALpdALpdALpdALpdALpd + ALpdALpdALpdALpdALpdALpdALpdALpdALpdAGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAzoQA0owA0pAA0pAA0pAA0pAA0pAA0pAA0pAA0pAA0pAA0pAAzoQAAAAAAAGYzM7hfA75iAL5i + AL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAL5iAGYzMwAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzoQA2pwA2qAA2qAA2qAA2qAA2qAA2qAA2qAA2qAA2 + qAA2qAAzoQAAAAAAAGYzM7xkA8JoAMJoAMJoAMJoAMJoAMJoAMJoAMJoAMJoAMJoAMJoAMJoAMJoAMJo + AMJoAMJoAMJoAMJoAMJoAGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzoQA3qwA3 + qwA3qwA3qwA3qwA3qwA3qwA3qwA3qwA3qwA3qwAzoQAAAAAAAGYzM8BpA8ZtAMZtAMZtAMZtAMZtAMZt + AMZtAMZtAMZtAMZtAMZtAMZtAMZtAMZtAMZtAMZtAMZtAMZtAMZtAGYzMwAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAzoQA5rgA5rwA5rwA5rwA5rwA5rwA5rwA5rwA5rwA5rwA5rwAzoQAAAAAA + AGYzM8NuA8pyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpyAMpy + AMpyAGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzoQA6sQA7swA7swA7swA7swA7 + swA7swA7swA7swA7swA7swAzoQAAAAAAAGYzM8dzA853AM53AM53AM53AM53AM53AM53AM53AM53AM53 + AM53AM53AM53AM53AM53AM53AM53AM53AM53AGYzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAzoQA8tQA8tgA8tgA8tgA8tgA8tgA8tgA8tgA8tgA8tgA8tgAzoQAAAAAAAGYzM8t3A9J8ANJ8 + ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8ANJ8AGYzMwAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzoQA9uAA+ugA+ugA+ugA+ugA+ugA+ugA+ugA+ugA+ + ugA+ugAzoQAAAAAAAGYzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2YzM2Yz + M2YzM2YzM2YzM2YzM2YzM2YzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAzoQA/vABA + vgBAvgBAvgBAvgBAvgBAvgBAvgBAvgBAvgBAvgAzoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAzoQBBvwBBwQBBwQBBwQBBwQBBwQBBwQBBwQBBwQBBwQBBwQAzoQBbrwBb + rwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBb + rwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbr7rH3wAAAAAzoQBCwwBDxQBDxQBDxQBDxQBD + xQBDxQBDxQBDxQBDxQBDxQAzoQBbr0i45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei4 + 5Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45Ei45ABbr6y8 + 2QAAAAAzoQBExgBFyQBFyQBFyQBFyQBFyQBFyQBFyQBFyQBFyQBFyQAzoQBbr0i65Ui65Ui65Ui65Ui6 + 5Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui65Ui6 + 5Ui65Ui65Ui65Ui65Ui65Ui65QBbr6y82QAAAAAzoQBFygBHzABHzABHzABHzABHzABHzABHzABHzABH + zABHzAAzoQBbr0i85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki8 + 5ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85ki85gBbr6y82QAAAAAzoQBHzQBI + 0ABI0ABI0ABI0ABI0ABI0ABI0ABI0ABI0ABI0AAzoQBbr0i/50i/50i/50i/50i/50i/50i/50i/50i/ + 50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/50i/ + 50i/50i/5wBbr6y82QAAAAAzoQBI0QBK1ABK1ABK1ABK1ABK1ABK1ABK1ABK1ABK1ABK1AAzoQBbr0fB + 6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB + 6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6EfB6ABbr6y82QAAAAAzoQBK1ABM2ABM2ABM2ABM2ABM + 2ABM2ABM2ABM2ABM2ABM2AAzoQBbr0fD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD + 6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6UfD6QBbr6y8 + 2QAAAAAzoQBM2ABN2wBN2wBN2wBN2wBN2wBN2wBN2wBN2wBN2wBN2wAzoQBbr0fF6kfF6kfF6kfF6kfF + 6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF6kfF + 6kfF6kfF6kfF6kfF6kfF6kfF6gBbr6y82QAAAAAzoQBGzABIzwBIzwBIzwBIzwBIzwBIzwBIzwBIzwBI + zwBIzwAzoQBbr0fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI + 60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI60fI6wBbr6y82QAAAAAzoQAzoQAz + oQAzoQAzoQAzoQAzoQAzoQAzoQAzoQAzoQAzoQAzoQBbr0fK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK + 7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK7EfK + 7EfK7EfK7ABbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0fM + 7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM + 7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7UfM7QBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAABbr0bO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO + 7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7kbO7gBbr6y8 + 2QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0bR70bR70bR70bR70bR + 70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR70bR + 70bR70bR70bR70bR70bR70bR7wBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAABbr0bT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT + 8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8EbT8ABbr6y82QAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0bV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV + 8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV8kbV + 8kbV8kbV8gBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0bX + 80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX + 80bX80bX80bX80bX80bX80bX80bX80bX80bX80bX8wBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAABbr0ba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba + 9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9Eba9ABbr6y8 + 2QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0Xc9UXc9UXc9UXc9UXc + 9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc9UXc + 9UXc9UXc9UXc9UXc9UXc9UXc9QBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAABbr0Xe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe + 9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9kXe9gBbr6y82QAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg + 90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg90Xg + 90Xg90Xg9wBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0Xj + +EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj + +EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+EXj+ABbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAABbr0Xl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl + +UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+UXl+QBbr6y8 + 2QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0Xn+kXn+kXn+kXn+kXn + +kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn+kXn + +kXn+kXn+kXn+kXn+kXn+kXn+gBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAABbr0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp + +0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+0Tp+wBbr6y82QAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0Ts/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs + /ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs/ETs + /ETs/ETs/ABbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr0Tu + /UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu + /UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/UTu/QBbr6y82QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAABbr0Tw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw + /kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/kTw/gBbr669 + 2QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbrwBbrwBbrwBbrwBbrwBb + rwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBbrwBb + rwBbrwBbrwBbrwBbrwBbrwBbrwBbr+XZ4gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7i4n///////g7u//// + ////Du7//wAAA/8O7v//AAAD/w7u//8AAAP/Du7//wAAA/8O7v//AAAD/w7u//8AAAP/Du7//wAAA/8O + 7v//AAAD/w7ugAMAAAP/Du6AAwAAA/8O7oADAAAD/w7ugAMAAAP/Du6AAwAAA/8O7oADAAAD/w7ugAMA + AAP/Du6AAwAAA/8O7oAD/////w7ugAAAAAAADu6AAAAAAAAO7oAAAAAAAA7ugAAAAAAADu6AAAAAAAAO + 7oAAAAAAAA7ugAAAAAAADu6AAAAAAAAO7oAAAAAAAA7ugAAAAAAADu7//AAAAAAO7v/8AAAAAA7u//wA + AAAADu7//AAAAAAO7v/8AAAAAA7u//wAAAAADu7//AAAAAAO7v/8AAAAAA7u//wAAAAADu7//AAAAAAO + 7v/8AAAAAA7u//wAAAAADu7//AAAAAAO7v/8AAAAAA7u//wAAAAADu7//AAAAAAO7v/8AAAAAA7u//wA + AAAADu7///////4O7igAAAAgAAAAQAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AABmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzMAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmMzOfOwCfOwCfOwCfOwCfOwCfOwCf + OwCfOwCfOwCfOwCfOwCfOwBmMzOxmJgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAABmMzOkQQCkQQCkQQCkQQCkQQCkQQCkQQCkQQCkQQCkQQCkQQCkQQBmMzOxmJgA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmMzOrSgCrSgCr + SgCrSgCrSgCrSgCrSgCrSgCrSgCrSgCrSgCrSgBmMzOxmJgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmMzOwUQCwUQCwUQCwUQCwUQCwUQCwUQCwUQCwUQCwUQCw + UQCwUQBmMzOxmJgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AABmMzO3WgC3WgC3WgC3WgC3WgC3WgC3WgC3WgC3WgC3WgC3WgC3WgBmMzOxmJgAAAAAAAAAAAAAAAAA + AAAAAADHu9QAM6EAM6EAM6EAM6EAM6EAM6EAM6EAM6EAAAAAAABmMzO8YAC8YAC8YAC8YAC8YAC8YAC8 + YAC8YAC8YAC8YAC8YAC8YABmMzOxmJgAAAAAAAAAAAAAAAAAAAAAAADHu9QAM6EANqkANqkANqkANqkA + NqkANqkAM6F/mM8AAABmMzPDaQDDaQDDaQDDaQDDaQDDaQDDaQDDaQDDaQDDaQDDaQDDaQBmMzOxmJgA + AAAAAAAAAAAAAAAAAAAAAADHu9QAM6EAOK0AOK0AOK0AOK0AOK0AOK0AM6F/mM8AAABmMzPIcADIcADI + cADIcADIcADIcADIcADIcADIcADIcADIcADIcABmMzOxmJgAAAAAAAAAAAAAAAAAAAAAAADHu9QAM6EA + O7QAO7QAO7QAO7QAO7QAO7QAM6F/mM8AAABmMzPPeADPeADPeADPeADPeADPeADPeADPeADPeADPeADP + eADPeABmMzOxmJgAAAAAAAAAAAAAAAAAAAAAAADHu9QAM6EAPbgAPbgAPbgAPbgAPbgAPbgAM6F/mM8A + AABmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzNmMzOxmJgAAAAAAAAAAAAAAAAA + AAAAAADHu9QAM6EAQL8AQL8AQL8AQL8AQL8AQL8AM6FVfMEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADHu9QAM6EAQsMAQsMAQsMAQsMA + QsMAQsMAM6EAW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68A + W68AW68AW68AW68AW6+BpM7Hu9QAM6EARcoARcoARcoARcoARcoARcoAM6EAW69IuuVIuuVIuuVIuuVI + uuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuVIuuUAW698oMzHu9QAM6EA + R84AR84AR84AR84AR84AR84AM6EAW69IvuZIvuZIvuZIvuZIvuZIvuZIvuZIvuZIvuZIvuZIvuZIvuZI + vuZIvuZIvuZIvuZIvuZIvuZIvuZIvuYAW698oMzHu9QAM6EAStUAStUAStUAStUAStUAStUAM6EAW69H + wehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwehHwegA + W698oMzHvNQAM6EATNoATNoATNoATNoATNoATNoAM6EAW69HxOlHxOlHxOlHxOlHxOlHxOlHxOlHxOlH + xOlHxOlHxOlHxOlHxOlHxOlHxOlHxOlHxOlHxOlHxOlHxOkAW698oMzHvNQAM6EAM6EAM6EAM6EAM6EA + M6EAM6EAM6EAW69HyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtHyOtH + yOtHyOtHyOtHyOsAW698oMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW69Hy+xHy+xHy+xHy+xH + y+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+xHy+wAW698oMwAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAW69Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5G + z+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+5Gz+4AW698oMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW69G + 0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u9G0u8A + W698oMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW69G1fJG1fJG1fJG1fJG1fJG1fJG1fJG1fJG + 1fJG1fJG1fJG1fJG1fJG1fJG1fJG1fJG1fJG1fJG1fJG1fIAW698oMwAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAW69G2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG2fNG + 2fNG2fNG2fNG2fMAW698oMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW69F3PVF3PVF3PVF3PVF + 3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PVF3PUAW698oMwAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAW69F3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF + 3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/ZF3/YAW698oMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW69F + 4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/hF4/gA + W698oMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW69F5vlF5vlF5vlF5vlF5vlF5vlF5vlF5vlF + 5vlF5vlF5vlF5vlF5vlF5vlF5vlF5vlF5vlF5vlF5vlF5vkAW698oMwAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAW69E6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE6vtE + 6vtE6vtE6vtE6vsAW698oMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW69E7fxE7fxE7fxE7fxE + 7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fxE7fwAW698oMwAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68AW68A + W68AW68AW68AW68AW68AW68AW68AW68AW6+Qqs8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADf1d/H + xdfHxdfHxdfHxdfHxdfHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbHxNbH + xNbn1t7//////+AAf//gAD//4AA//+AAP//gAD//4AA/AGAAPwAgAD8AIAA/ACAAPwAgAD8AP///AAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAA/4AAAP+AAAD/gAAA/4AAAP+AAAD/gAAA/4AAAP+AAAD/gAAA/4AA + AP+AAAD/gAAA/4AAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACyg2+i + PwCiPwCiPwCiPwCiPwCiPwCqbEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC2h2+uTgCuTgCuTgCuTgCu + TgCuTgCwc0wAAAAAAAAAAAC7vNlwjMpwjMpwjMoAAAC5jG+6XQC6XQC6XQC6XQC6XQC6XQC2e0wAAAAA + AAAAAAB4hsIAN6sAN6sAN6tAaL29kW/GbQDGbQDGbQDGbQDGbQDGbQC8g0wAAAAAAAAAAAB4iMUAPLYA + PLYAPLZAasO2jnSvYw+vYw+vYw+vYw+vYw+vYw+wflQAAAAAAAAAAAB4icgAQsIAQsIAQsIlW8CBuuCD + veKDveKDveKDveKDveKDveKDveKDveKDveKawN94issAR80AR80AR80QUL8+sN9HvOZHvOZHvOZHvOZH + vOZHvOZHvOZHvOZHvOZgrNh4jM0ATNgATNgATNgQU8Q+tuFHw+lHw+lHw+lHw+lHw+lHw+lHw+lHw+lH + w+lgrtm7vdxwk9lwk9lwk9lkjdA+vORGyuxGyuxGyuxGyuxGyuxGyuxGyuxGyuxGyuxgstoAAAAAAAAA + AAAAAAAAAAA9wudG0e9G0e9G0e9G0e9G0e9G0e9G0e9G0e9G0e9ftdwAAAAAAAAAAAAAAAAAAAA9yOpG + 2PJG2PJG2PJG2PJG2PJG2PJG2PJG2PJG2PJfuN0AAAAAAAAAAAAAAAAAAAA8zu1F3/VF3/VF3/VF3/VF + 3/VF3/VF3/VF3/VF3/Vfu98AAAAAAAAAAAAAAAAAAAA81O9F5fhF5fhF5fhF5fhF5fhF5fhF5fhF5fhF + 5fhfv+EAAAAAAAAAAAAAAAAAAAA72vJE7PxE7PxE7PxE7PxE7PxE7PxE7PxE7PxE7PxewuEAAAAAAAAA + AAAAAAAAAAClw9umxtymxtymxtymxtymxtymxtymxtymxtymxty3x9z//6xB+AesQfgHrEEIB6xBAAes + QQAHrEEAAKxBAACsQQAArEEAAKxB+ACsQfgArEH4AKxB+ACsQfgArEH4AKxBiVBORw0KGgoAAAANSUhE + UgAAAQAAAAEACAYAAABccqhmAAANN0lEQVR42u3aV5BWRRqHcUdRMSFgwJzFgIraQ45KFNO6edecI+ac + M+acc9xdNylIzkMYhjBmxRxRQAygEgyos1VbU7T0WN3fec/p7q+fX9WB+ldx8fYFDxdMxQoAklXxv19m + zPjpJ9+HAChWZWVFxbIBGOj7IACF2b/uG/jLANT4vgpAIQbUfa+ZAvCu78sA5O6pum9WQwF4yfd1AHI1 + s+6b82sBmO37QgC5mV/3zf3VAFRWVizwfSUAef//O08ASvH0gSvw36aI0gFPav/1TwBKQQAQKwIggAAg + VgRAAAFArAiAAAKAWLVqrVTLs2ufIwAZmAKw/109fZ8FLGfgCaO1TQAEEADEggDkwBiAOwkAwjPwRAIg + jgAgFgQgB6YA7EcAEKBBBECeMQB3EACEZ9BJBEAcAUAsCEAOjAG4nQAgPIP6EwBxBACxIAA5MAVg39sI + AMLz7MkEQBwBQCwIQA4IAGJBAHJgDMCtBADhefYUAiCOACAWBCAHpgDsc0sv32cByxl86ihtEwABBACx + IAA5MAbgZgKA8Aw+jQCIIwCIBQHIAQFALAhADkwB2PsmAoDwDDmdAIgjAIgFAciBMQA3EgCEZ8gZBEAc + AUAsCEAOjAG4gQAgPEPOJADiTAHoRwAQoKEEQB4BQCwIQA6MAbieACA8Q88iAOIIAGJBAHJgDMB1BADh + GXo2ARBnCsBeBAABGkYA5BkDcC0BQHiGnUMAxBEAxIIA5IAAIBYEIAfGAFxDABCeYecSAHEEALEgADkw + BaDvAAKA8Aw/jwCIIwCIBQHIgTEAVxMAhGf4+QRAHAFALAhADggAYkEAcmAKQJ+rCADCM+ICAiCOACAW + BCAHxgBcSQAQnhEXEgBxBACxIAA5MAbgCgKA8Iy4iACIMwWgNwFAgEYSAHkEALEgADkwBuByAoDwjLyY + AIgjAIgFAciBMQCXEQCEZ+QlBECcKQC9Luvt+yxgOaMuGaltAiDAGIBLCQDCM+pSAiCOACAWBCAHBACx + IAA5MAbgEgKA8Iy6jACIMwWgJwFAgEYTAHnGAFxMABCe0ZcTAHEEALEgADkwBuAiAoDwjL6CAIgjAIgF + AciBKQA9CAACNIYAyDMG4EICgPCMuZIAiCMAiAUByIExABcQAIRnzFUEQBwBQCwIQA5MAdjzfAKA8Iy9 + mgCIIwCIBQHIAQFALAhADowBOI8AIDxjBxAAcQQAsSAAOTAFYI9zCQDCM+4aAiCOACAWBCAHxgCcQwAQ + nnHXEgBxBACxIAA5MAbgbAKA8Iy7jgCIMwWgOwFAgMYTAHkEALEgADkwBuAsAoDwjL+eAIgjAIgFAciB + MQBnEgCEZ/wNBECcKQDdCAACVEUA5BkDcAYBQHiqbiQA4ggAYkEAckAAEAsCkANjAE4nAAhP1U0EQJwp + AF1P7+P7LGA5E24aoW0CIMAYgNMIAMIz4WYCII4AIBYEIAfGAJxKABCeCbcQAHEEALEoOQCvHlsx0/fx + ITq0doUKUwC6EAAEaCIBkNVgAE4hAAjPxFsJgCgCgJgQAGENBuBkAoDwTLyNAIgiAIiJaAC6ber7OcWr + +kjfDQWgc38CgPBMul0yAJv4fk7xqmbpmwAgJqIB6JpgACYQAERMNABdEgzARNsAnEQAEJ5JdwgGoPPG + vp9TvEkf65sAICYEICPbAHQ6kQAgPJPvFAxApwQDMJkAIGKiAeiYYACqbQNwAgFAeCbfJRmAjXw/p3jV + n+ibACAmogHokGAAphAAREw0AO0TDECNbQCOJwAIz+S7JQOwoe/nFK9mtr4bCkBHAoAAVUsGoF2CAZhq + G4DjCADCU32PYADaJhiAaQQAERMNQJsNfD+neNPn6LvBABxLABCe6nsJQCYEADETDUBlggGYYRmADgQA + AZoiGQDVwvdzilc7V98NBuAYAoDwTLmPAGRCABAz0QDsnmAAnrMNwNEEAOGZcr9gAHZb3/dzivf8p/om + AIgJAcjINgDtjyIACE/NA4IB2DXBALxAABAx0QC0Xs/3c4r34jx9EwDEhABkZB2AIwkAwlPzoGAAdkkw + AC8RAERMNAA7JxiAly0D0O6Ivr5PBZYz9aHh2s4UgJ3W9f2c4r3ymb4JAGJCADKyDsDhBADhmfqwYABa + JRiAVwkAIiYagB3X8f2c4r32ub4JAGJCADKyDUDbwwgAwjPtEcEA7JBgAGYSAERMNADbN/f9nOK9/oW+ + GwzAoQQA4Zn2KAHIhAAgZqIB2C7BALxhG4BDCADCM+0xwQC0bOb7OcV780t9NxSANgQAAZpOALIhAIiZ + aAC2TTAAb9kG4GACgPBMf1wwANs09f2c4r09X98EADERDcDWCQbgHdsAHEQAEJ7pTxCATGwDAMQgUwC2 + Wtv3+cV7d4G+CQBilikAWyYYgPcIAMoIAXBEAFBOMgVgiwQD8L4hAL/8M29ep3b3fSdgq+QAbN7E9+nF + ++ArfZsCAMSGAFgiAChHJQVgswQD8CEBQBkqKQCbruX77OJ99LW+CQDKQUkB2CTBAMwiAChDBMASAUA5 + KikAG6/p++ziffyNvm0DoNQx/KxAGaqtva8s/gEoKQAbJRiATwgAlkEAEkMAsKykA7DhGr7PLt7shfom + AGlLOgAbJBiAOQQAyyAAiZEMQO0+J/t+DhypwbdpO+kAtFjd99nFm7tI35kCsHd/38+BIzXkdm0nHYD1 + EwzAp5IB6EcAYqOGEoB6BCBjAPY6yfdz4EgNu0PbSQdgvdV8n128eYv1nSkAfU/0/Rw4UsPv1HbSAVg3 + wQB8JhmAPif4fg4cqRF3aTvpAKyTYAA+lwxAbwIQGzWSANQjABkD0Ot438+BIzXqbm0nHYDmjX2fXbwv + lug7UwB6Huf7OXCkRt+j7aQD0CzBAHwpGYAex/p+DhypMfdqmwAkhgCkjQAso+mqvs8u3vxv9Z0pAHse + 4/s5cKTG3qftpAOwdoIBWCAZgD2O9v0cOFLj7tc2AUiMaAC6H+X7OXCkxj+g7aQD0GQV32cX76vv9J0p + AN0IQGxUFQGot1aCAfhaMgBdj/T9HDhSEx7UNgFIjGgAuhzh+zlwpCY+pO2kA7Dmyr7PLt433+s7UwA6 + H+77OXCkJj2s7aQDsEaCAVgoGYBOBCA2ajIBqLd6ggFYJBmAjof5fg4cqepHtJ12ABr5Prt4i37Qd6YA + dDjU93PgSE15VNtJB2C1BAOwWDIA7Q/x/Rw4UjWPaTvpADROMABLJAPQjgDERk0lAPUar+T77OItWarv + TAFoe7Dv58CRmva4tpMOwKoJBuBbyQC0Ocj3c+BITX9C20kHYJUEA/CdZAAqD/T9HDhSM57UNgFIjGgA + FAGIjaolAPVWXtH32cX7/kd9ZwrA7n/1/Rw4Us/9TdtJB6BRggH4QTIAu/3F93PgSD3/d20nHYCVEgzA + UskA7Ppn38+BI/XCP7SddgDK4ululv7ir3GmALQmALFRLxKAeiuWxdPd/CgZgF3+5Ps5cKReekrbSQcA + GQOw8x99nw9H6uV/apsAJC5TAHb6g+/z4Ui98i9tE4DEZQpAKwIQG/UqAcAyMgVgx9/7Ph+O1Gv/1nYy + Aaj7ZldWVizwfWisjAHY4Xe+z4IjNfM/2iYAsGIMwPa/9X0WHKnX/6ttAgArBKA8EACUxBiA7Q7wfRYc + qTee1jYBgBVjAFr+xvdZcKTefEbbBABWjAHYdn/fZ8GRemugtgkArBgDsA0BiI16mwCgBMYAbL2f77Pg + SL0zSNsEAFaMAdhqX99nwZF691ltEwBYMQZgy318nwVH6r3B2iYAsGIMwBYEIDbqfQKAEhgDsPnevs+C + I/XBEG0TAFgxBmCzfr7PgiP14VBtEwBYMQZg0718nwVH6qNh2iYAsGIMwCYEIDZqFgFACYwB2Liv77Pg + SH08XNsEAFaMAdioj++z4Eh9MkLbBABWjAHYsLfvs+BIzR6pbQIAK8YAbEAAYqPmEACUwBiAFr18nwVH + au4obRMAWDEGYP2evs+CI/XpaG0TAFgxBmC9Hr7PgiM1b4y2CQCsGAOwLgGIjfqMAKAExgCss6fvs+BI + fT5W2wQAVowBaL6H77PgSH0xTtsEAFaMAWjW3fdZcKS+HK9tAgArxgA07e77LDhS88drmwDAijEAa3fz + fRYcqQVV2iYAsGIMQJOuvs+CI/XVBG0TAFgxBmCtLr7PgiP19URtEwBYIQDlgQCgJMYArNnZ91lwpL6Z + pG0CACvGAKzRyfdZcKQWTtY2AYAVYwBW7+j7LDhSi6q1TQBgxRiA1QhAbNRiAoASGAPQuIPvs+BILZmi + bQIAK8YArNre91lwpL6t0TYBgBVjAFZp5/ssOFLfTdU2AYAVYwBWJgCxUd8TAJTAGIBGbX2fBUfqh2na + JgCwYgzASm18nwVHaul0bRMAWDEFAPEjALBCAMoTAYAVAlCeCACsEIDyRAAARI8AAAkjAEDCCACQMAIA + JIwAAAkjAEDCCACQMFMAAKRlbv1PNdVF4Jm637at+5rUfY3qvrL4iScADfsZgOX03tj+IOMAAAAASUVO + RK5CYIIoAAAAMAAAAGAAAAABACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/svLi/7Ly2D+y8tb/svL + W/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svL + W/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svL + W/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8tb/svLW/7Ly1v+y8uU/svL + ev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AGUyMhxlMjIgZTIyIGUyMiBlMjIgZTIyIGUyMiBlMjIgZTIyIGUyMiBlMjIgZTIyIGUyMiBlMjIgZTIy + IGUyMiBlMjIgZTIyIGUyMiBlMjIgZTIyIGUyMiBlMjIIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAD+y8tb/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAGYzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz + /2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM/+aOQP/njoA/546AP+eOgD/njoA/546AP+eOgD/njoA + /546AP+eOgD/njoA/546AP+eOgD/njoA/546AP+eOgD/njoA/546AP+eOgD/njoA/2YzM/9lMjJAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM/+ePgP/oj8A/6I/AP+iPwD/oj8A + /6I/AP+iPwD/oj8A/6I/AP+iPwD/oj8A/6I/AP+iPwD/oj8A/6I/AP+iPwD/oj8A/6I/AP+iPwD/oj8A + /2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLev7LywgAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM/+iQgP/pkMA + /6ZDAP+mQwD/pkMA/6ZDAP+mQwD/pkMA/6ZDAP+mQwD/pkMA/6ZDAP+mQwD/pkMA/6ZDAP+mQwD/pkMA + /6ZDAP+mQwD/pkMA/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svL + ev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AGYzM/+mRwP/qkkA/6pJAP+qSQD/qkkA/6pJAP+qSQD/qkkA/6pJAP+qSQD/qkkA/6pJAP+qSQD/qkkA + /6pJAP+qSQD/qkkA/6pJAP+qSQD/qkkA/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAD+y8tb/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAGYzM/+pTAP/rk4A/65OAP+uTgD/rk4A/65OAP+uTgD/rk4A/65OAP+uTgD/rk4A + /65OAP+uTgD/rk4A/65OAP+uTgD/rk4A/65OAP+uTgD/rk4A/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM/+tUQP/slMA/7JTAP+yUwD/slMA/7JTAP+yUwD/slMA + /7JTAP+yUwD/slMA/7JTAP+yUwD/slMA/7JTAP+yUwD/slMA/7JTAP+yUwD/slMA/2YzM/9lMjJAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM/+xVgP/tlkA/7ZZAP+2WQD/tlkA + /7ZZAP+2WQD/tlkA/7ZZAP+2WQD/tlkA/7ZZAP+2WQD/tlkA/7ZZAP+2WQD/tlkA/7ZZAP+2WQD/tlkA + /2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLegAzof8AM6H/ADOh + /wAzof8AM6H/ADOh/wAzof8AM6H/ADOh/wAzof8AM6H/ADOh/wAzof8AMqAsAAAAAGYzM/+0WgP/ul0A + /7pdAP+6XQD/ul0A/7pdAP+6XQD/ul0A/7pdAP+6XQD/ul0A/7pdAP+6XQD/ul0A/7pdAP+6XQD/ul0A + /7pdAP+6XQD/ul0A/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svL + egAzof8ANKP/ADSk/wA0pP8ANKT/ADSk/wA0pP8ANKT/ADSk/wA0pP8ANKT/ADSk/wAzof8AMqBAAAAA + AGYzM/+4XwP/vmIA/75iAP++YgD/vmIA/75iAP++YgD/vmIA/75iAP++YgD/vmIA/75iAP++YgD/vmIA + /75iAP++YgD/vmIA/75iAP++YgD/vmIA/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAD+y8tb/svLegAzof8ANqf/ADao/wA2qP8ANqj/ADao/wA2qP8ANqj/ADao/wA2qP8ANqj/ADao + /wAzof8AMqBAAAAAAGYzM/+8ZAP/wmgA/8JoAP/CaAD/wmgA/8JoAP/CaAD/wmgA/8JoAP/CaAD/wmgA + /8JoAP/CaAD/wmgA/8JoAP/CaAD/wmgA/8JoAP/CaAD/wmgA/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLegAzof8AN6v/ADer/wA3q/8AN6v/ADer/wA3q/8AN6v/ADer + /wA3q/8AN6v/ADer/wAzof8AMqBAAAAAAGYzM//AaQP/xm0A/8ZtAP/GbQD/xm0A/8ZtAP/GbQD/xm0A + /8ZtAP/GbQD/xm0A/8ZtAP/GbQD/xm0A/8ZtAP/GbQD/xm0A/8ZtAP/GbQD/xm0A/2YzM/9lMjJAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLegAzof8AOa7/ADmv/wA5r/8AOa//ADmv + /wA5r/8AOa//ADmv/wA5r/8AOa//ADmv/wAzof8AMqBAAAAAAGYzM//DbgP/ynIA/8pyAP/KcgD/ynIA + /8pyAP/KcgD/ynIA/8pyAP/KcgD/ynIA/8pyAP/KcgD/ynIA/8pyAP/KcgD/ynIA/8pyAP/KcgD/ynIA + /2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLegAzof8AOrH/ADuz + /wA7s/8AO7P/ADuz/wA7s/8AO7P/ADuz/wA7s/8AO7P/ADuz/wAzof8AMqBAAAAAAGYzM//HcwP/zncA + /853AP/OdwD/zncA/853AP/OdwD/zncA/853AP/OdwD/zncA/853AP/OdwD/zncA/853AP/OdwD/zncA + /853AP/OdwD/zncA/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svL + egAzof8APLX/ADy2/wA8tv8APLb/ADy2/wA8tv8APLb/ADy2/wA8tv8APLb/ADy2/wAzof8AMqBAAAAA + AGYzM//LdwP/0nwA/9J8AP/SfAD/0nwA/9J8AP/SfAD/0nwA/9J8AP/SfAD/0nwA/9J8AP/SfAD/0nwA + /9J8AP/SfAD/0nwA/9J8AP/SfAD/0nwA/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAD+y8tb/svLegAzof8APbj/AD66/wA+uv8APrr/AD66/wA+uv8APrr/AD66/wA+uv8APrr/AD66 + /wAzof8AMqBAAAAAAGYzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz + /2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9lMjJAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLegAzof8AP7z/AEC+/wBAvv8AQL7/AEC+/wBAvv8AQL7/AEC+ + /wBAvv8AQL7/AEC+/wAzof8AMqBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tb/svLegAzof8AQb//AEHB/wBBwf8AQcH/AEHB + /wBBwf8AQcH/AEHB/wBBwf8AQcH/AEHB/wAzof8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv + /wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv + /wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/+InsiS/svLegAzof8AQsP/AEPF + /wBDxf8AQ8X/AEPF/wBDxf8AQ8X/AEPF/wBDxf8AQ8X/AEPF/wAzof8AW6//SLjk/0i45P9IuOT/SLjk + /0i45P9IuOT/SLjk/0i45P9IuOT/SLjk/0i45P9IuOT/SLjk/0i45P9IuOT/SLjk/0i45P9IuOT/SLjk + /0i45P9IuOT/SLjk/0i45P9IuOT/SLjk/0i45P9IuOT/SLjk/0i45P9IuOT/SLjk/wBbr/9+mMWk/svL + egAzof8ARMb/AEXJ/wBFyf8ARcn/AEXJ/wBFyf8ARcn/AEXJ/wBFyf8ARcn/AEXJ/wAzof8AW6//SLrl + /0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl + /0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl + /wBbr/9+mMWk/svLegAzof8ARcr/AEfM/wBHzP8AR8z/AEfM/wBHzP8AR8z/AEfM/wBHzP8AR8z/AEfM + /wAzof8AW6//SLzm/0i85v9IvOb/SLzm/0i85v9IvOb/SLzm/0i85v9IvOb/SLzm/0i85v9IvOb/SLzm + /0i85v9IvOb/SLzm/0i85v9IvOb/SLzm/0i85v9IvOb/SLzm/0i85v9IvOb/SLzm/0i85v9IvOb/SLzm + /0i85v9IvOb/SLzm/wBbr/9+mMWk/svLegAzof8AR83/AEjQ/wBI0P8ASND/AEjQ/wBI0P8ASND/AEjQ + /wBI0P8ASND/AEjQ/wAzof8AW6//SL/n/0i/5/9Iv+f/SL/n/0i/5/9Iv+f/SL/n/0i/5/9Iv+f/SL/n + /0i/5/9Iv+f/SL/n/0i/5/9Iv+f/SL/n/0i/5/9Iv+f/SL/n/0i/5/9Iv+f/SL/n/0i/5/9Iv+f/SL/n + /0i/5/9Iv+f/SL/n/0i/5/9Iv+f/SL/n/wBbr/9+mMWk/svLegAzof8ASNH/AErU/wBK1P8AStT/AErU + /wBK1P8AStT/AErU/wBK1P8AStT/AErU/wAzof8AW6//R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho + /0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho + /0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/wBbr/9+mMWk/8zMegAzof8AStT/AEzY + /wBM2P8ATNj/AEzY/wBM2P8ATNj/AEzY/wBM2P8ATNj/AEzY/wAzof8AW6//R8Pp/0fD6f9Hw+n/R8Pp + /0fD6f9Hw+n/R8Pp/0fD6f9Hw+n/R8Pp/0fD6f9Hw+n/R8Pp/0fD6f9Hw+n/R8Pp/0fD6f9Hw+n/R8Pp + /0fD6f9Hw+n/R8Pp/0fD6f9Hw+n/R8Pp/0fD6f9Hw+n/R8Pp/0fD6f9Hw+n/R8Pp/wBbr/9+mMWk/8zM + egAzof8ATNj/AE3b/wBN2/8ATdv/AE3b/wBN2/8ATdv/AE3b/wBN2/8ATdv/AE3b/wAzof8AW6//R8Xq + /0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq + /0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq/0fF6v9Hxer/R8Xq + /wBbr/9+mMWk/8zMegAzof8ARsz/AEjP/wBIz/8ASM//AEjP/wBIz/8ASM//AEjP/wBIz/8ASM//AEjP + /wAzof8AW6//R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr + /0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr + /0fI6/9HyOv/R8jr/wBbr/9+mMWk/8zMegAzof8AM6H/ADOh/wAzof8AM6H/ADOh/wAzof8AM6H/ADOh + /wAzof8AM6H/ADOh/wAzof8AW6//R8rs/0fK7P9Hyuz/R8rs/0fK7P9Hyuz/R8rs/0fK7P9Hyuz/R8rs + /0fK7P9Hyuz/R8rs/0fK7P9Hyuz/R8rs/0fK7P9Hyuz/R8rs/0fK7P9Hyuz/R8rs/0fK7P9Hyuz/R8rs + /0fK7P9Hyuz/R8rs/0fK7P9Hyuz/R8rs/wBbr/9+mMWk/8zMev/MzAgAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//R8zt/0fM7f9HzO3/R8zt/0fM7f9HzO3/R8zt + /0fM7f9HzO3/R8zt/0fM7f9HzO3/R8zt/0fM7f9HzO3/R8zt/0fM7f9HzO3/R8zt/0fM7f9HzO3/R8zt + /0fM7f9HzO3/R8zt/0fM7f9HzO3/R8zt/0fM7f9HzO3/R8zt/wBbr/9+mMWk/8zMev/MzAgAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//Rs7u/0bO7v9Gzu7/Rs7u + /0bO7v9Gzu7/Rs7u/0bO7v9Gzu7/Rs7u/0bO7v9Gzu7/Rs7u/0bO7v9Gzu7/Rs7u/0bO7v9Gzu7/Rs7u + /0bO7v9Gzu7/Rs7u/0bO7v9Gzu7/Rs7u/0bO7v9Gzu7/Rs7u/0bO7v9Gzu7/Rs7u/wBbr/9+mMWk/8zM + ev/MzAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//RtHv + /0bR7/9G0e//RtHv/0bR7/9G0e//RtHv/0bR7/9G0e//RtHv/0bR7/9G0e//RtHv/0bR7/9G0e//RtHv + /0bR7/9G0e//RtHv/0bR7/9G0e//RtHv/0bR7/9G0e//RtHv/0bR7/9G0e//RtHv/0bR7/9G0e//RtHv + /wBbr/9+mMWk/8zMev/MzAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAW6//RtPw/0bT8P9G0/D/RtPw/0bT8P9G0/D/RtPw/0bT8P9G0/D/RtPw/0bT8P9G0/D/RtPw + /0bT8P9G0/D/RtPw/0bT8P9G0/D/RtPw/0bT8P9G0/D/RtPw/0bT8P9G0/D/RtPw/0bT8P9G0/D/RtPw + /0bT8P9G0/D/RtPw/wBbr/9+mMWk/8zMev/MzAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAW6//RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy + /0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy + /0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/wBbr/9+mMWk/8zMev/MzAgAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//Rtfz/0bX8/9G1/P/Rtfz/0bX8/9G1/P/Rtfz + /0bX8/9G1/P/Rtfz/0bX8/9G1/P/Rtfz/0bX8/9G1/P/Rtfz/0bX8/9G1/P/Rtfz/0bX8/9G1/P/Rtfz + /0bX8/9G1/P/Rtfz/0bX8/9G1/P/Rtfz/0bX8/9G1/P/Rtfz/wBbr/9+mMWk/8zMev/MzAgAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//Rtr0/0ba9P9G2vT/Rtr0 + /0ba9P9G2vT/Rtr0/0ba9P9G2vT/Rtr0/0ba9P9G2vT/Rtr0/0ba9P9G2vT/Rtr0/0ba9P9G2vT/Rtr0 + /0ba9P9G2vT/Rtr0/0ba9P9G2vT/Rtr0/0ba9P9G2vT/Rtr0/0ba9P9G2vT/Rtr0/wBbr/9+mMWk/svL + ev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//Rdz1 + /0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1 + /0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1 + /wBbr/9+mMWk/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAW6//Rd72/0Xe9v9F3vb/Rd72/0Xe9v9F3vb/Rd72/0Xe9v9F3vb/Rd72/0Xe9v9F3vb/Rd72 + /0Xe9v9F3vb/Rd72/0Xe9v9F3vb/Rd72/0Xe9v9F3vb/Rd72/0Xe9v9F3vb/Rd72/0Xe9v9F3vb/Rd72 + /0Xe9v9F3vb/Rd72/wBbr/9+mMWk/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAW6//ReD3/0Xg9/9F4Pf/ReD3/0Xg9/9F4Pf/ReD3/0Xg9/9F4Pf/ReD3 + /0Xg9/9F4Pf/ReD3/0Xg9/9F4Pf/ReD3/0Xg9/9F4Pf/ReD3/0Xg9/9F4Pf/ReD3/0Xg9/9F4Pf/ReD3 + /0Xg9/9F4Pf/ReD3/0Xg9/9F4Pf/ReD3/wBbr/9+mMWk/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4 + /0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4 + /0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/wBbr/9+mMWk/svLev7LywgAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//ReX5/0Xl+f9F5fn/ReX5 + /0Xl+f9F5fn/ReX5/0Xl+f9F5fn/ReX5/0Xl+f9F5fn/ReX5/0Xl+f9F5fn/ReX5/0Xl+f9F5fn/ReX5 + /0Xl+f9F5fn/ReX5/0Xl+f9F5fn/ReX5/0Xl+f9F5fn/ReX5/0Xl+f9F5fn/ReX5/wBbr/9+mMWk/svL + ev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//Ref6 + /0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6 + /0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6/0Xn+v9F5/r/Ref6 + /wBbr/9+mMWk/svLev7LywgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAW6//ROn7/0Tp+/9E6fv/ROn7/0Tp+/9E6fv/ROn7/0Tp+/9E6fv/ROn7/0Tp+/9E6fv/ROn7 + /0Tp+/9E6fv/ROn7/0Tp+/9E6fv/ROn7/0Tp+/9E6fv/ROn7/0Tp+/9E6fv/ROn7/0Tp+/9E6fv/ROn7 + /0Tp+/9E6fv/ROn7/wBbr/9+mMWk/8zMev/MzAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAW6//ROz8/0Ts/P9E7Pz/ROz8/0Ts/P9E7Pz/ROz8/0Ts/P9E7Pz/ROz8 + /0Ts/P9E7Pz/ROz8/0Ts/P9E7Pz/ROz8/0Ts/P9E7Pz/ROz8/0Ts/P9E7Pz/ROz8/0Ts/P9E7Pz/ROz8 + /0Ts/P9E7Pz/ROz8/0Ts/P9E7Pz/ROz8/wBbr/9+mMWk/svLev/LywgAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//RO79/0Tu/f9E7v3/RO79/0Tu/f9E7v3/RO79 + /0Tu/f9E7v3/RO79/0Tu/f9E7v3/RO79/0Tu/f9E7v3/RO79/0Tu/f9E7v3/RO79/0Tu/f9E7v3/RO79 + /0Tu/f9E7v3/RO79/0Tu/f9E7v3/RO79/0Tu/f9E7v3/RO79/wBbr/9+mMWk/svLev7LywgAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//RPD+/0Tw/v9E8P7/RPD+ + /0Tw/v9E8P7/RPD+/0Tw/v9E8P7/RPD+/0Tw/v9E8P7/RPD+/0Tw/v9E8P7/RPD+/0Tw/v9E8P7/RPD+ + /0Tw/v9E8P7/RPD+/0Tw/v9E8P7/RPD+/0Tw/v9E8P7/RPD+/0Tw/v9E8P7/RPD+/wBbr/+BmMSi/svL + ev7Lyw7+y8sI/8zMCP/MzAj+y8sI/svLCP7Lywj+y8sI/svLCP7Lywj+y8sI/8zMCP/MzAgAW6//AFuv + /wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv + /wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv + /wBbr//NtcaA/svLfP/Ly3r+y8t6/8zMev/MzHr+y8t6/svLev7Ly3r+y8t6/svLev7Ly3r+y8t6/8zM + ev/MzHr/zMx6/8zMev/MzHr/zMx6/8zMev/MzHr/zMx6/8zMev/MzHr+y8t6/svLev7Ly3r+y8t6/svL + ev7Ly3r+y8t6/svLev7Ly3r+y8t6/svLev7Ly3r+y8t6/svLev7Ly3r+y8t6/svLev7Ly3r+y8t6/svL + ev7Ly3r+y8t6/svLev7Ly3r+y8uLAAAAAAAADu4//wAAAf4O7j//AAAB/g7uP/8AAAH+Du4//wAAAf4O + 7j//AAAB/g7uP/8AAAH+Du4//wAAAf4O7j//AAAB/g7uP/8AAAH+Du4AAQAAAf4O7gABAAAB/g7uAAEA + AAH+Du4AAQAAAf4O7gABAAAB/g7uAAEAAAH+Du4AAQAAAf4O7gABAAAB/g7uAAH////+Du4AAAAAAAAO + 7gAAAAAAAA7uAAAAAAAADu4AAAAAAAAO7gAAAAAAAA7uAAAAAAAADu4AAAAAAAAO7gAAAAAAAA7uAAAA + AAAADu4AAAAAAAAO7j/8AAAAAA7uP/wAAAAADu4//AAAAAAO7j/8AAAAAA7uP/wAAAAADu4//AAAAAAO + 7j/8AAAAAA7uP/wAAAAADu4//AAAAAAO7j/8AAAAAA7uP/wAAAAADu4//AAAAAAO7j/8AAAAAA7uP/wA + AAAADu4//AAAAAAO7j/8AAAAAA7uP/wAAAAADu4AAAAAAAAO7gAAAAAAAA7uKAAAACAAAABAAAAAAQAg + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7Ly2/+y8s//svLPf7Lyz3+y8s9/svLPf7Lyz3+y8s9/svL + Pf7Lyz3hrq5Ay5iYR8uYmEfLmJhHy5iYR8uYmEfLmJhHy5iYR8uYmEfLmJhHy5iYR8uYmEfLmJhHy5iY + R8uYmEfLmJhC/svLPf7Lyz3+y8s9/svLPf7Lyz3+y8tq/svLVP7LywMAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAGUyMjxmMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz + /2YzM/9mMzP/ZjMz/2UyMloAAAAAAAAAAAAAAAAAAAAAAAAAAP7Lyz3+y8tU/svLAwAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAZjMzVWYzM/+fOwD/nzsA/587AP+fOwD/nzsA/587AP+fOwD/nzsA + /587AP+fOwD/nzsA/587AP9mMzP/ZTIygAAAAAAAAAAAAAAAAAAAAAAAAAAA/svLPf7Ly1T+y8sDAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmMzNVZjMz/6RBAP+kQQD/pEEA/6RBAP+kQQD/pEEA + /6RBAP+kQQD/pEEA/6RBAP+kQQD/pEEA/2YzM/9lMjKAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8s9/svL + VP7LywMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGYzM1VmMzP/q0oA/6tKAP+rSgD/q0oA + /6tKAP+rSgD/q0oA/6tKAP+rSgD/q0oA/6tKAP+rSgD/ZjMz/2UyMoAAAAAAAAAAAAAAAAAAAAAAAAAA + AP7Lyz3+y8tU/svLAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZjMzVWYzM/+wUQD/sFEA + /7BRAP+wUQD/sFEA/7BRAP+wUQD/sFEA/7BRAP+wUQD/sFEA/7BRAP9mMzP/ZTIygAAAAAAAAAAAAAAA + AAAAAAAAAAAA/svLPeG6xm9da7BXADOhVQAzoVUAM6FVADOhVQAzoVUAM6FVADOhVQAyoCZmMzNVZjMz + /7daAP+3WgD/t1oA/7daAP+3WgD/t1oA/7daAP+3WgD/t1oA/7daAP+3WgD/t1oA/2YzM/9lMjKAAAAA + AAAAAAAAAAAAAAAAAAAAAAD+y8s9qZi9pgAzof8AM6H/ADOh/wAzof8AM6H/ADOh/wAzof8AM6H/ADKg + e2YzM1VmMzP/vGAA/7xgAP+8YAD/vGAA/7xgAP+8YAD/vGAA/7xgAP+8YAD/vGAA/7xgAP+8YAD/ZjMz + /2UyMoAAAAAAAAAAAAAAAAAAAAAAAAAAAP7Lyz2pmL2mADOh/wA2qf8ANqn/ADap/wA2qf8ANqn/ADap + /wAzof8AMqCAZjMzVWYzM//DaQD/w2kA/8NpAP/DaQD/w2kA/8NpAP/DaQD/w2kA/8NpAP/DaQD/w2kA + /8NpAP9mMzP/ZTIygAAAAAAAAAAAAAAAAAAAAAAAAAAA/svLPamYvaYAM6H/ADit/wA4rf8AOK3/ADit + /wA4rf8AOK3/ADOh/wAyoIBmMzNVZjMz/8hwAP/IcAD/yHAA/8hwAP/IcAD/yHAA/8hwAP/IcAD/yHAA + /8hwAP/IcAD/yHAA/2YzM/9lMjKAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8s9qZi9pgAzof8AO7T/ADu0 + /wA7tP8AO7T/ADu0/wA7tP8AM6H/ADKggGYzM1VmMzP/z3gA/894AP/PeAD/z3gA/894AP/PeAD/z3gA + /894AP/PeAD/z3gA/894AP/PeAD/ZjMz/2UyMoAAAAAAAAAAAAAAAAAAAAAAAAAAAP7Lyz2pmL2mADOh + /wA9uP8APbj/AD24/wA9uP8APbj/AD24/wAzof8AMqCAZjMzVWYzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz + /2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZTIygAAAAAAAAAAAAAAAAAAAAAAAAAAA/svL + PamYvaYAM6H/AEC//wBAv/8AQL//AEC//wBAv/8AQL//ADOh/wA7o6oAW69VAFuvVQBbr1UAW69VAFuv + VQBbr1UAW69VAFuvVQBbr1UAW69VAFuvVQBbr1UAW69VAFuvVQBbr1UAW69VAFuvVQBbr1UAW69VAFuv + VQBbr1WsqMRlqZi9pgAzof8AQsP/AELD/wBCw/8AQsP/AELD/wBCw/8AM6H/AFuv/wBbr/8AW6//AFuv + /wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv + /wBbr/8AW6//AFuv/1aFvr6pmL2mADOh/wBFyv8ARcr/AEXK/wBFyv8ARcr/AEXK/wAzof8AW6//SLrl + /0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl/0i65f9IuuX/SLrl + /0i65f9IuuX/SLrl/0i65f8AW6//VIO9wqmYvaYAM6H/AEfO/wBHzv8AR87/AEfO/wBHzv8AR87/ADOh + /wBbr/9Ivub/SL7m/0i+5v9Ivub/SL7m/0i+5v9Ivub/SL7m/0i+5v9Ivub/SL7m/0i+5v9Ivub/SL7m + /0i+5v9Ivub/SL7m/0i+5v9Ivub/SL7m/wBbr/9Ug73CqZi9pgAzof8AStX/AErV/wBK1f8AStX/AErV + /wBK1f8AM6H/AFuv/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho + /0fB6P9Hwej/R8Ho/0fB6P9Hwej/R8Ho/0fB6P9Hwej/AFuv/1SDvcKqmb2mADOh/wBM2v8ATNr/AEza + /wBM2v8ATNr/AEza/wAzof8AW6//R8Tp/0fE6f9HxOn/R8Tp/0fE6f9HxOn/R8Tp/0fE6f9HxOn/R8Tp + /0fE6f9HxOn/R8Tp/0fE6f9HxOn/R8Tp/0fE6f9HxOn/R8Tp/0fE6f8AW6//VIO9wqqZvaYAM6H/ADOh + /wAzof8AM6H/ADOh/wAzof8AM6H/ADOh/wBbr/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr + /0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/0fI6/9HyOv/R8jr/wBbr/9Ug73C4rvH + b15rsFcAM6FVADOhVQAzoVUAM6FVADOhVQAzoVUAM6FVAFuv/0fL7P9Hy+z/R8vs/0fL7P9Hy+z/R8vs + /0fL7P9Hy+z/R8vs/0fL7P9Hy+z/R8vs/0fL7P9Hy+z/R8vs/0fL7P9Hy+z/R8vs/0fL7P9Hy+z/AFuv + /1SDvcL/zMxU/8zMAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//Rs/u/0bP7v9Gz+7/Rs/u + /0bP7v9Gz+7/Rs/u/0bP7v9Gz+7/Rs/u/0bP7v9Gz+7/Rs/u/0bP7v9Gz+7/Rs/u/0bP7v9Gz+7/Rs/u + /0bP7v8AW6//VIO9wv/MzFT/zMwDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr/9G0u//RtLv + /0bS7/9G0u//RtLv/0bS7/9G0u//RtLv/0bS7/9G0u//RtLv/0bS7/9G0u//RtLv/0bS7/9G0u//RtLv + /0bS7/9G0u//RtLv/wBbr/9Ug73C/8zMVP/MzAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFuv + /0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy/0bV8v9G1fL/RtXy + /0bV8v9G1fL/RtXy/0bV8v9G1fL/AFuv/1SDvcL/zMxU/8zMAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAW6//Rtnz/0bZ8/9G2fP/Rtnz/0bZ8/9G2fP/Rtnz/0bZ8/9G2fP/Rtnz/0bZ8/9G2fP/Rtnz + /0bZ8/9G2fP/Rtnz/0bZ8/9G2fP/Rtnz/0bZ8/8AW6//VIO9wv7Ly1T+y8sDAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAABbr/9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1 + /0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/0Xc9f9F3PX/Rdz1/wBbr/9Ug73C/svLVP7LywMAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAFuv/0Xf9v9F3/b/Rd/2/0Xf9v9F3/b/Rd/2/0Xf9v9F3/b/Rd/2 + /0Xf9v9F3/b/Rd/2/0Xf9v9F3/b/Rd/2/0Xf9v9F3/b/Rd/2/0Xf9v9F3/b/AFuv/1SDvcL+y8tU/svL + AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4 + /0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/0Xj+P9F4/j/ReP4/0Xj+P8AW6//VIO9 + wv7Ly1T+y8sDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABbr/9F5vn/Reb5/0Xm+f9F5vn/Reb5 + /0Xm+f9F5vn/Reb5/0Xm+f9F5vn/Reb5/0Xm+f9F5vn/Reb5/0Xm+f9F5vn/Reb5/0Xm+f9F5vn/Reb5 + /wBbr/9Ug73C/svLVP7LywMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFuv/0Tq+/9E6vv/ROr7 + /0Tq+/9E6vv/ROr7/0Tq+/9E6vv/ROr7/0Tq+/9E6vv/ROr7/0Tq+/9E6vv/ROr7/0Tq+/9E6vv/ROr7 + /0Tq+/9E6vv/AFuv/1SDvcL+y8tU/8vLAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW6//RO38 + /0Tt/P9E7fz/RO38/0Tt/P9E7fz/RO38/0Tt/P9E7fz/RO38/0Tt/P9E7fz/RO38/0Tt/P9E7fz/RO38 + /0Tt/P9E7fz/RO38/0Tt/P8AW6//VIO9wv7Ly1X+y8sF/8zMA/7LywP+y8sD/svLA/7LywP+y8sD/8zM + AwBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv + /wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/9mir25/svLb/7Ly1X/zMxU/svLVP7Ly1T+y8tU/svL + VP7Ly1T/zMxUxrLFi6qmwqaqpsKmqqbCpqqmwqaqpsKmqaXBpqmlwaappcGmqaXBpqmlwaappcGmqaXB + pqmlwaappcGmqaXBpqmlwaappcGmqaXBpqmlwaappcGmqaXBpta5xpIAAAAAP8AAPj/AAD4/wAA+P8AA + Pj/AAD4AAAA+AAAAPgAAAD4AAAA+AAAAPgAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AD+AAAA/gAAAP4AAAD+AAAA/gAAAP4AAAD+AAAA/gAAAP4AAAD+AAAAAAAAAAAAAACgAAAAQAAAAIAAA + AAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+y8tB/svLHv7Lyx7+y8se/svLHp1qanCYZWWjmGVl + o5hlZaOYZWWjmGVlo5hlZaOYZWV4/svLHv7Lyx7+y8s5/svLLAAAAAAAAAAAAAAAAAAAAABmMzP/ZjMz + /2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/wAAAAAAAAAA/svLHv7LyywAAAAAAAAAAAAAAAAAAAAAZjMz + /61NAP+tTQD/rU0A/61NAP+tTQD/rU0A/2YzM/8AAAAAAAAAAP7Lyx4AM6H/ADOh/wAzof8AM6H/ADOh + /2YzM/+5XQD/uV0A/7ldAP+5XQD/uV0A/7ldAP9mMzP/AAAAAAAAAAD+y8seADOh/wA3q/8AN6v/ADer + /wAzof9mMzP/xWwA/8VsAP/FbAD/xWwA/8VsAP/FbAD/ZjMz/wAAAAAAAAAA/svLHgAzof8APLb/ADy2 + /wA8tv8AM6H/ZjMz/2YzM/9mMzP/ZjMz/2YzM/9mMzP/ZjMz/2YzM/8AAAAAAAAAAP7Lyx4AM6H/AEHB + /wBBwf8AQcH/ADOh/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//ADOh + /wBGzP8ARsz/AEbM/wAzof9IvOX/SLzl/0i85f9IvOX/SLzl/0i85f9IvOX/SLzl/0i85f9IvOX/AFuv + /wAzof8AS9f/AEvX/wBL1/8AM6H/R8Lo/0fC6P9Hwuj/R8Lo/0fC6P9Hwuj/R8Lo/0fC6P9Hwuj/R8Lo + /wBbr/8AM6H/ADOh/wAzof8AM6H/ADOh/0fJ6/9Hyev/R8nr/0fJ6/9Hyev/R8nr/0fJ6/9Hyev/R8nr + /0fJ6/8AW6///8zMLAAAAAAAAAAAAAAAAABbr/9G0O7/RtDu/0bQ7v9G0O7/RtDu/0bQ7v9G0O7/RtDu + /0bQ7v9G0O7/AFuv///MzCwAAAAAAAAAAAAAAAAAW6//Rtfy/0bX8v9G1/L/Rtfy/0bX8v9G1/L/Rtfy + /0bX8v9G1/L/Rtfy/wBbr//+y8ssAAAAAAAAAAAAAAAAAFuv/0Xd9f9F3fX/Rd31/0Xd9f9F3fX/Rd31 + /0Xd9f9F3fX/Rd31/0Xd9f8AW6///svLLAAAAAAAAAAAAAAAAABbr/9F5Pj/ReT4/0Xk+P9F5Pj/ReT4 + /0Xk+P9F5Pj/ReT4/0Xk+P9F5Pj/AFuv//7LyywAAAAAAAAAAAAAAAAAW6//ROv7/0Tr+/9E6/v/ROv7 + /0Tr+/9E6/v/ROv7/0Tr+/9E6/v/ROv7/wBbr//+y8tI/svLLP7Lyyz+y8ssAFuv/wBbr/8AW6//AFuv + /wBbr/8AW6//AFuv/wBbr/8AW6//AFuv/wBbr/8AW6//AACsQXgGrEF4BqxBAAasQQAGrEEABqxBAACs + QQAArEEAAKxBAACsQXAArEFwAKxBcACsQXAArEFwAKxBAACsQQ== + + + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/SearchWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/SearchWindow.Designer.cs index 2d5cdcbab..8097dde5d 100644 --- a/1.x/trunk/ProcessHacker/Forms/SearchWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/SearchWindow.Designer.cs @@ -64,9 +64,9 @@ private void InitializeComponent() // // tabControl // - this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tabControl.Controls.Add(this.tabLiteral); this.tabControl.Controls.Add(this.tabRegex); this.tabControl.Controls.Add(this.tabString); @@ -98,7 +98,7 @@ private void InitializeComponent() this.checkNoOverlap.AutoSize = true; this.checkNoOverlap.Location = new System.Drawing.Point(6, 262); this.checkNoOverlap.Name = "checkNoOverlap"; - this.checkNoOverlap.Size = new System.Drawing.Size(166, 17); + this.checkNoOverlap.Size = new System.Drawing.Size(154, 17); this.checkNoOverlap.TabIndex = 1; this.checkNoOverlap.Text = "Prevent overlapping results"; this.checkNoOverlap.UseVisualStyleBackColor = true; @@ -114,9 +114,9 @@ private void InitializeComponent() // // hexBoxSearch // - this.hexBoxSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.hexBoxSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.hexBoxSearch.BytesPerLine = 8; this.hexBoxSearch.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.hexBoxSearch.HexCasing = Be.Windows.Forms.HexCasing.Lower; @@ -149,16 +149,16 @@ private void InitializeComponent() this.checkIgnoreCase.AutoSize = true; this.checkIgnoreCase.Location = new System.Drawing.Point(6, 262); this.checkIgnoreCase.Name = "checkIgnoreCase"; - this.checkIgnoreCase.Size = new System.Drawing.Size(87, 17); + this.checkIgnoreCase.Size = new System.Drawing.Size(83, 17); this.checkIgnoreCase.TabIndex = 1; this.checkIgnoreCase.Text = "Ignore Case"; this.checkIgnoreCase.UseVisualStyleBackColor = true; // // textRegex // - this.textRegex.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textRegex.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textRegex.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.textRegex.Location = new System.Drawing.Point(6, 6); this.textRegex.Multiline = true; @@ -184,7 +184,7 @@ private void InitializeComponent() this.checkUnicode.AutoSize = true; this.checkUnicode.Location = new System.Drawing.Point(8, 34); this.checkUnicode.Name = "checkUnicode"; - this.checkUnicode.Size = new System.Drawing.Size(133, 17); + this.checkUnicode.Size = new System.Drawing.Size(122, 17); this.checkUnicode.TabIndex = 1; this.checkUnicode.Text = "Find Unicode strings"; this.checkUnicode.UseVisualStyleBackColor = true; @@ -193,7 +193,7 @@ private void InitializeComponent() // this.textStringMS.Location = new System.Drawing.Point(88, 8); this.textStringMS.Name = "textStringMS"; - this.textStringMS.Size = new System.Drawing.Size(100, 22); + this.textStringMS.Size = new System.Drawing.Size(100, 20); this.textStringMS.TabIndex = 0; // // label2 @@ -201,7 +201,7 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(8, 11); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(81, 13); + this.label2.Size = new System.Drawing.Size(74, 13); this.label2.TabIndex = 2; this.label2.Text = "Minimum Size:"; // @@ -221,7 +221,7 @@ private void InitializeComponent() // this.textHeapMS.Location = new System.Drawing.Point(88, 8); this.textHeapMS.Name = "textHeapMS"; - this.textHeapMS.Size = new System.Drawing.Size(100, 22); + this.textHeapMS.Size = new System.Drawing.Size(100, 20); this.textHeapMS.TabIndex = 0; // // label4 @@ -229,7 +229,7 @@ private void InitializeComponent() this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(8, 11); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(81, 13); + this.label4.Size = new System.Drawing.Size(74, 13); this.label4.TabIndex = 1; this.label4.Text = "Minimum Size:"; // @@ -251,7 +251,7 @@ private void InitializeComponent() // this.textStructAlign.Location = new System.Drawing.Point(68, 259); this.textStructAlign.Name = "textStructAlign"; - this.textStructAlign.Size = new System.Drawing.Size(100, 22); + this.textStructAlign.Size = new System.Drawing.Size(100, 20); this.textStructAlign.TabIndex = 1; // // label5 @@ -259,7 +259,7 @@ private void InitializeComponent() this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(6, 262); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(63, 13); + this.label5.Size = new System.Drawing.Size(56, 13); this.label5.TabIndex = 3; this.label5.Text = "Alignment:"; // @@ -268,15 +268,15 @@ private void InitializeComponent() this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 6); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(40, 13); + this.label3.Size = new System.Drawing.Size(38, 13); this.label3.TabIndex = 2; this.label3.Text = "Struct:"; // // listStructName // - this.listStructName.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listStructName.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listStructName.FormattingEnabled = true; this.listStructName.IntegralHeight = false; this.listStructName.Location = new System.Drawing.Point(50, 6); @@ -293,7 +293,7 @@ private void InitializeComponent() this.checkPrivate.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkPrivate.Location = new System.Drawing.Point(73, 328); this.checkPrivate.Name = "checkPrivate"; - this.checkPrivate.Size = new System.Drawing.Size(66, 18); + this.checkPrivate.Size = new System.Drawing.Size(65, 18); this.checkPrivate.TabIndex = 2; this.checkPrivate.Text = "Private"; this.checkPrivate.UseVisualStyleBackColor = true; @@ -305,7 +305,7 @@ private void InitializeComponent() this.checkImage.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkImage.Location = new System.Drawing.Point(138, 328); this.checkImage.Name = "checkImage"; - this.checkImage.Size = new System.Drawing.Size(63, 18); + this.checkImage.Size = new System.Drawing.Size(61, 18); this.checkImage.TabIndex = 3; this.checkImage.Text = "Image"; this.checkImage.UseVisualStyleBackColor = true; @@ -317,7 +317,7 @@ private void InitializeComponent() this.checkMapped.FlatStyle = System.Windows.Forms.FlatStyle.System; this.checkMapped.Location = new System.Drawing.Point(199, 328); this.checkMapped.Name = "checkMapped"; - this.checkMapped.Size = new System.Drawing.Size(75, 18); + this.checkMapped.Size = new System.Drawing.Size(71, 18); this.checkMapped.TabIndex = 4; this.checkMapped.Text = "Mapped"; this.checkMapped.UseVisualStyleBackColor = true; @@ -328,7 +328,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 330); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(57, 13); + this.label1.Size = new System.Drawing.Size(55, 13); this.label1.TabIndex = 1; this.label1.Text = "Search in:"; // @@ -360,7 +360,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(517, 377); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOK); diff --git a/1.x/trunk/ProcessHacker/Forms/SearchWindow.cs b/1.x/trunk/ProcessHacker/Forms/SearchWindow.cs index 9d11dde74..d742edfba 100644 --- a/1.x/trunk/ProcessHacker/Forms/SearchWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/SearchWindow.cs @@ -22,6 +22,9 @@ using System; using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; using System.Windows.Forms; namespace ProcessHacker @@ -29,13 +32,12 @@ namespace ProcessHacker public partial class SearchWindow : Form { private SearchOptions _so; - private readonly List _oldresults; - private readonly int _pid; + private List _oldresults; + private int _pid; public SearchWindow(int PID, SearchOptions so) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); diff --git a/1.x/trunk/ProcessHacker/Forms/SearchWindow.resx b/1.x/trunk/ProcessHacker/Forms/SearchWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/SearchWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/SearchWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/ServiceWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ServiceWindow.Designer.cs index 170ccdc0f..0c7ec4cdb 100644 --- a/1.x/trunk/ProcessHacker/Forms/ServiceWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ServiceWindow.Designer.cs @@ -1,6 +1,6 @@ namespace ProcessHacker { - sealed partial class ServiceWindow + partial class ServiceWindow { /// /// Required designer variable. @@ -38,8 +38,8 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(412, 398); + this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; diff --git a/1.x/trunk/ProcessHacker/Forms/ServiceWindow.cs b/1.x/trunk/ProcessHacker/Forms/ServiceWindow.cs index d1fb70698..e08460fdf 100644 --- a/1.x/trunk/ProcessHacker/Forms/ServiceWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/ServiceWindow.cs @@ -26,9 +26,9 @@ namespace ProcessHacker { - public sealed partial class ServiceWindow : Form + public partial class ServiceWindow : Form { - private readonly ServiceProperties _serviceProps; + private ServiceProperties _serviceProps; public ServiceWindow(string service) : this(new string[] { service }) @@ -40,11 +40,9 @@ public ServiceWindow(string[] services) this.AddEscapeToClose(); this.SetTopMost(); - _serviceProps = new ServiceProperties(services) - { - Dock = DockStyle.Fill - }; - _serviceProps.NeedsClose += this._serviceProps_NeedsClose; + _serviceProps = new ServiceProperties(services); + _serviceProps.Dock = DockStyle.Fill; + _serviceProps.NeedsClose += new EventHandler(_serviceProps_NeedsClose); this.Controls.Add(_serviceProps); this.Text = _serviceProps.Text; this.AcceptButton = _serviceProps.ApplyButton; diff --git a/1.x/trunk/ProcessHacker/Forms/ServiceWindow.resx b/1.x/trunk/ProcessHacker/Forms/ServiceWindow.resx index 8d60e5edb..8b9ee9a60 100644 --- a/1.x/trunk/ProcessHacker/Forms/ServiceWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ServiceWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA diff --git a/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.Designer.cs index b845a259c..bede8aeb2 100644 --- a/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.Designer.cs @@ -51,7 +51,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(3, 4); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(64, 13); + this.label1.Size = new System.Drawing.Size(61, 13); this.label1.TabIndex = 0; this.label1.Text = "User name:"; // @@ -59,9 +59,9 @@ private void InitializeComponent() // this.label2.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 25); + this.label2.Location = new System.Drawing.Point(3, 26); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(63, 13); + this.label2.Size = new System.Drawing.Size(61, 13); this.label2.TabIndex = 0; this.label2.Text = "Session ID:"; // @@ -69,9 +69,9 @@ private void InitializeComponent() // this.label3.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 46); + this.label3.Location = new System.Drawing.Point(3, 48); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(36, 13); + this.label3.Size = new System.Drawing.Size(35, 13); this.label3.TabIndex = 0; this.label3.Text = "State:"; // @@ -79,9 +79,9 @@ private void InitializeComponent() // this.label4.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 67); + this.label4.Location = new System.Drawing.Point(3, 70); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(71, 13); + this.label4.Size = new System.Drawing.Size(65, 13); this.label4.TabIndex = 0; this.label4.Text = "Client name:"; // @@ -89,9 +89,9 @@ private void InitializeComponent() // this.label5.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(3, 88); + this.label5.Location = new System.Drawing.Point(3, 92); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(83, 13); + this.label5.Size = new System.Drawing.Size(76, 13); this.label5.TabIndex = 0; this.label5.Text = "Client address:"; // @@ -99,9 +99,9 @@ private void InitializeComponent() // this.label6.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(3, 112); + this.label6.Location = new System.Drawing.Point(3, 114); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(135, 13); + this.label6.Size = new System.Drawing.Size(119, 13); this.label6.TabIndex = 0; this.label6.Text = "Client display resolution:"; // @@ -109,7 +109,7 @@ private void InitializeComponent() // this.labelUsername.Anchor = System.Windows.Forms.AnchorStyles.Left; this.labelUsername.AutoSize = true; - this.labelUsername.Location = new System.Drawing.Point(144, 4); + this.labelUsername.Location = new System.Drawing.Point(128, 4); this.labelUsername.Name = "labelUsername"; this.labelUsername.Size = new System.Drawing.Size(24, 13); this.labelUsername.TabIndex = 1; @@ -119,7 +119,7 @@ private void InitializeComponent() // this.labelSessionId.Anchor = System.Windows.Forms.AnchorStyles.Left; this.labelSessionId.AutoSize = true; - this.labelSessionId.Location = new System.Drawing.Point(144, 25); + this.labelSessionId.Location = new System.Drawing.Point(128, 26); this.labelSessionId.Name = "labelSessionId"; this.labelSessionId.Size = new System.Drawing.Size(24, 13); this.labelSessionId.TabIndex = 1; @@ -127,9 +127,9 @@ private void InitializeComponent() // // tableLayoutPanel1 // - this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tableLayoutPanel1.ColumnCount = 2; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); @@ -161,7 +161,7 @@ private void InitializeComponent() // this.labelState.Anchor = System.Windows.Forms.AnchorStyles.Left; this.labelState.AutoSize = true; - this.labelState.Location = new System.Drawing.Point(144, 46); + this.labelState.Location = new System.Drawing.Point(128, 48); this.labelState.Name = "labelState"; this.labelState.Size = new System.Drawing.Size(24, 13); this.labelState.TabIndex = 1; @@ -171,7 +171,7 @@ private void InitializeComponent() // this.labelClientName.Anchor = System.Windows.Forms.AnchorStyles.Left; this.labelClientName.AutoSize = true; - this.labelClientName.Location = new System.Drawing.Point(144, 67); + this.labelClientName.Location = new System.Drawing.Point(128, 70); this.labelClientName.Name = "labelClientName"; this.labelClientName.Size = new System.Drawing.Size(24, 13); this.labelClientName.TabIndex = 1; @@ -181,7 +181,7 @@ private void InitializeComponent() // this.labelClientAddress.Anchor = System.Windows.Forms.AnchorStyles.Left; this.labelClientAddress.AutoSize = true; - this.labelClientAddress.Location = new System.Drawing.Point(144, 88); + this.labelClientAddress.Location = new System.Drawing.Point(128, 92); this.labelClientAddress.Name = "labelClientAddress"; this.labelClientAddress.Size = new System.Drawing.Size(24, 13); this.labelClientAddress.TabIndex = 1; @@ -191,7 +191,7 @@ private void InitializeComponent() // this.labelClientDisplayResolution.Anchor = System.Windows.Forms.AnchorStyles.Left; this.labelClientDisplayResolution.AutoSize = true; - this.labelClientDisplayResolution.Location = new System.Drawing.Point(144, 112); + this.labelClientDisplayResolution.Location = new System.Drawing.Point(128, 114); this.labelClientDisplayResolution.Name = "labelClientDisplayResolution"; this.labelClientDisplayResolution.Size = new System.Drawing.Size(24, 13); this.labelClientDisplayResolution.TabIndex = 1; @@ -214,7 +214,6 @@ private void InitializeComponent() this.AcceptButton = this.buttonClose; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(333, 187); this.Controls.Add(this.buttonClose); this.Controls.Add(this.tableLayoutPanel1); diff --git a/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.resx b/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/SessionInformationWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/StructWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/StructWindow.Designer.cs index 7e0b79284..574beb547 100644 --- a/1.x/trunk/ProcessHacker/Forms/StructWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/StructWindow.Designer.cs @@ -47,9 +47,9 @@ private void InitializeComponent() // // panel // - this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.panel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.panel.Location = new System.Drawing.Point(12, 12); this.panel.Name = "panel"; this.panel.Size = new System.Drawing.Size(548, 392); diff --git a/1.x/trunk/ProcessHacker/Forms/StructWindow.cs b/1.x/trunk/ProcessHacker/Forms/StructWindow.cs index 73f584562..5864a8fc3 100644 --- a/1.x/trunk/ProcessHacker/Forms/StructWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/StructWindow.cs @@ -29,9 +29,9 @@ namespace ProcessHacker { public partial class StructWindow : Form { - private readonly int _pid; - private readonly IntPtr _address; - private readonly StructDef _struct; + private int _pid; + private IntPtr _address; + private StructDef _struct; public StructWindow(int pid, IntPtr address, StructDef struc) { diff --git a/1.x/trunk/ProcessHacker/Forms/StructWindow.resx b/1.x/trunk/ProcessHacker/Forms/StructWindow.resx index 9598de423..117a2c160 100644 --- a/1.x/trunk/ProcessHacker/Forms/StructWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/StructWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA diff --git a/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.Designer.cs index 580c83058..aa45adb08 100644 --- a/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.Designer.cs @@ -31,24 +31,30 @@ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SysInfoWindow)); this.gboxCPUPlotter = new System.Windows.Forms.GroupBox(); this.tableCPUs = new System.Windows.Forms.TableLayoutPanel(); + this.plotterCPU = new ProcessHacker.Components.Plotter(); this.tableGraphs = new System.Windows.Forms.TableLayoutPanel(); - this.groupBox15 = new System.Windows.Forms.GroupBox(); - this.groupBox14 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.plotterIO = new ProcessHacker.Components.Plotter(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.plotterMemory = new ProcessHacker.Components.Plotter(); this.groupBox11 = new System.Windows.Forms.GroupBox(); + this.indicatorPhysical = new ProcessHacker.Components.Indicator(); this.groupBox12 = new System.Windows.Forms.GroupBox(); + this.indicatorIO = new ProcessHacker.Components.Indicator(); this.groupBox13 = new System.Windows.Forms.GroupBox(); + this.indicatorCpu = new ProcessHacker.Components.Indicator(); this.checkShowOneGraphPerCPU = new System.Windows.Forms.CheckBox(); - this.groupBox16 = new System.Windows.Forms.GroupBox(); + this.flowInfo = new System.Windows.Forms.FlowLayoutPanel(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.labelTotalsUptime = new System.Windows.Forms.Label(); - this.labelTotalsHandles = new System.Windows.Forms.Label(); - this.labelTotalsThreads = new System.Windows.Forms.Label(); - this.label42 = new System.Windows.Forms.Label(); - this.label40 = new System.Windows.Forms.Label(); - this.label46 = new System.Windows.Forms.Label(); - this.label39 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); this.labelTotalsProcesses = new System.Windows.Forms.Label(); + this.labelTotalsThreads = new System.Windows.Forms.Label(); + this.labelTotalsHandles = new System.Windows.Forms.Label(); + this.label34 = new System.Windows.Forms.Label(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.label1 = new System.Windows.Forms.Label(); @@ -57,15 +63,6 @@ private void InitializeComponent() this.labelCCC = new System.Windows.Forms.Label(); this.labelCCP = new System.Windows.Forms.Label(); this.labelCCL = new System.Windows.Forms.Label(); - this.groupBox6 = new System.Windows.Forms.GroupBox(); - this.labelCachePeak = new System.Windows.Forms.Label(); - this.labelCacheCurrent = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.labelCacheMaximum = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.labelCacheMinimum = new System.Windows.Forms.Label(); - this.label13 = new System.Windows.Forms.Label(); - this.label15 = new System.Windows.Forms.Label(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.label4 = new System.Windows.Forms.Label(); @@ -74,6 +71,16 @@ private void InitializeComponent() this.labelPMT = new System.Windows.Forms.Label(); this.label19 = new System.Windows.Forms.Label(); this.labelPSC = new System.Windows.Forms.Label(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); + this.label15 = new System.Windows.Forms.Label(); + this.labelCacheMaximum = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.labelCacheMinimum = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.labelCacheCurrent = new System.Windows.Forms.Label(); + this.labelCachePeak = new System.Windows.Forms.Label(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); this.label14 = new System.Windows.Forms.Label(); @@ -131,33 +138,22 @@ private void InitializeComponent() this.label41 = new System.Windows.Forms.Label(); this.labelCPUInterrupts = new System.Windows.Forms.Label(); this.checkAlwaysOnTop = new System.Windows.Forms.CheckBox(); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.tabPage2 = new System.Windows.Forms.TabPage(); - this.CloseButton = new System.Windows.Forms.Button(); - this.indicatorCommit = new ProcessHacker.Components.Indicator(); - this.trackerCommit = new ProcessHacker.Tracker(); - this.plotterCPU = new ProcessHacker.Components.Plotter(); - this.plotterIO = new ProcessHacker.Components.Plotter(); - this.trackerMemory = new ProcessHacker.Tracker(); - this.indicatorPhysical = new ProcessHacker.Components.Indicator(); - this.indicatorIO = new ProcessHacker.Components.Indicator(); - this.indicatorCpu = new ProcessHacker.Components.Indicator(); this.gboxCPUPlotter.SuspendLayout(); this.tableGraphs.SuspendLayout(); - this.groupBox15.SuspendLayout(); - this.groupBox14.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox11.SuspendLayout(); this.groupBox12.SuspendLayout(); this.groupBox13.SuspendLayout(); - this.groupBox16.SuspendLayout(); + this.flowInfo.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); this.groupBox4.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); - this.groupBox6.SuspendLayout(); this.groupBox5.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); + this.groupBox6.SuspendLayout(); + this.tableLayoutPanel4.SuspendLayout(); this.groupBox7.SuspendLayout(); this.tableLayoutPanel5.SuspendLayout(); this.groupBox8.SuspendLayout(); @@ -166,9 +162,6 @@ private void InitializeComponent() this.tableLayoutPanel7.SuspendLayout(); this.groupBox10.SuspendLayout(); this.tableLayoutPanel8.SuspendLayout(); - this.tabControl1.SuspendLayout(); - this.tabPage1.SuspendLayout(); - this.tabPage2.SuspendLayout(); this.SuspendLayout(); // // gboxCPUPlotter @@ -178,7 +171,7 @@ private void InitializeComponent() this.gboxCPUPlotter.Dock = System.Windows.Forms.DockStyle.Fill; this.gboxCPUPlotter.Location = new System.Drawing.Point(89, 3); this.gboxCPUPlotter.Name = "gboxCPUPlotter"; - this.gboxCPUPlotter.Size = new System.Drawing.Size(604, 113); + this.gboxCPUPlotter.Size = new System.Drawing.Size(726, 62); this.gboxCPUPlotter.TabIndex = 2; this.gboxCPUPlotter.TabStop = false; this.gboxCPUPlotter.Text = "CPU Usage (Kernel, User)"; @@ -195,116 +188,229 @@ private void InitializeComponent() this.tableCPUs.TabIndex = 3; this.tableCPUs.Visible = false; // + // plotterCPU + // + this.plotterCPU.BackColor = System.Drawing.Color.Black; + this.plotterCPU.Data1 = null; + this.plotterCPU.Data2 = null; + this.plotterCPU.Dock = System.Windows.Forms.DockStyle.Fill; + this.plotterCPU.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(128)))), ((int)(((byte)(64))))); + this.plotterCPU.GridSize = new System.Drawing.Size(12, 12); + this.plotterCPU.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotterCPU.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotterCPU.Location = new System.Drawing.Point(3, 16); + this.plotterCPU.LongData1 = null; + this.plotterCPU.LongData2 = null; + this.plotterCPU.MinMaxValue = ((long)(0)); + this.plotterCPU.MoveStep = -1; + this.plotterCPU.Name = "plotterCPU"; + this.plotterCPU.OverlaySecondLine = false; + this.plotterCPU.ShowGrid = true; + this.plotterCPU.Size = new System.Drawing.Size(720, 43); + this.plotterCPU.TabIndex = 0; + this.plotterCPU.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotterCPU.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotterCPU.TextMargin = new System.Windows.Forms.Padding(3); + this.plotterCPU.TextPadding = new System.Windows.Forms.Padding(3); + this.plotterCPU.TextPosition = System.Drawing.ContentAlignment.TopLeft; + this.plotterCPU.UseLongData = false; + this.plotterCPU.UseSecondLine = true; + // // tableGraphs // - this.tableGraphs.BackColor = System.Drawing.Color.White; + this.tableGraphs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tableGraphs.ColumnCount = 2; this.tableGraphs.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 86F)); this.tableGraphs.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableGraphs.Controls.Add(this.groupBox15, 0, 2); - this.tableGraphs.Controls.Add(this.groupBox14, 1, 2); this.tableGraphs.Controls.Add(this.gboxCPUPlotter, 1, 0); - this.tableGraphs.Controls.Add(this.groupBox2, 1, 3); - this.tableGraphs.Controls.Add(this.groupBox1, 1, 4); - this.tableGraphs.Controls.Add(this.groupBox11, 0, 4); - this.tableGraphs.Controls.Add(this.groupBox12, 0, 3); + this.tableGraphs.Controls.Add(this.groupBox2, 1, 2); + this.tableGraphs.Controls.Add(this.groupBox1, 1, 3); + this.tableGraphs.Controls.Add(this.groupBox11, 0, 3); + this.tableGraphs.Controls.Add(this.groupBox12, 0, 2); this.tableGraphs.Controls.Add(this.groupBox13, 0, 0); - this.tableGraphs.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableGraphs.Location = new System.Drawing.Point(3, 3); + this.tableGraphs.Controls.Add(this.checkShowOneGraphPerCPU, 1, 1); + this.tableGraphs.Location = new System.Drawing.Point(12, 12); this.tableGraphs.Name = "tableGraphs"; - this.tableGraphs.RowCount = 5; - this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.00062F)); + this.tableGraphs.RowCount = 4; + this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.00062F)); - this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.00062F)); - this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 24.99813F)); - this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableGraphs.Size = new System.Drawing.Size(696, 478); + this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableGraphs.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableGraphs.Size = new System.Drawing.Size(818, 228); this.tableGraphs.TabIndex = 3; // - // groupBox15 - // - this.groupBox15.Controls.Add(this.indicatorCommit); - this.groupBox15.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox15.Location = new System.Drawing.Point(3, 122); - this.groupBox15.Name = "groupBox15"; - this.groupBox15.Size = new System.Drawing.Size(80, 113); - this.groupBox15.TabIndex = 13; - this.groupBox15.TabStop = false; - this.groupBox15.Text = "Commit"; - // - // groupBox14 - // - this.groupBox14.Controls.Add(this.trackerCommit); - this.groupBox14.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox14.Location = new System.Drawing.Point(89, 122); - this.groupBox14.Name = "groupBox14"; - this.groupBox14.Size = new System.Drawing.Size(604, 113); - this.groupBox14.TabIndex = 12; - this.groupBox14.TabStop = false; - this.groupBox14.Text = "Commit History"; - // // groupBox2 // this.groupBox2.Controls.Add(this.plotterIO); this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox2.Location = new System.Drawing.Point(89, 241); + this.groupBox2.Location = new System.Drawing.Point(89, 95); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(604, 113); + this.groupBox2.Size = new System.Drawing.Size(726, 62); this.groupBox2.TabIndex = 5; this.groupBox2.TabStop = false; this.groupBox2.Text = "I/O (R+O, W)"; // + // plotterIO + // + this.plotterIO.BackColor = System.Drawing.Color.Black; + this.plotterIO.Data1 = null; + this.plotterIO.Data2 = null; + this.plotterIO.Dock = System.Windows.Forms.DockStyle.Fill; + this.plotterIO.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(128)))), ((int)(((byte)(64))))); + this.plotterIO.GridSize = new System.Drawing.Size(12, 12); + this.plotterIO.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotterIO.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotterIO.Location = new System.Drawing.Point(3, 16); + this.plotterIO.LongData1 = null; + this.plotterIO.LongData2 = null; + this.plotterIO.MinMaxValue = ((long)(0)); + this.plotterIO.MoveStep = -1; + this.plotterIO.Name = "plotterIO"; + this.plotterIO.OverlaySecondLine = true; + this.plotterIO.ShowGrid = true; + this.plotterIO.Size = new System.Drawing.Size(720, 43); + this.plotterIO.TabIndex = 5; + this.plotterIO.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotterIO.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotterIO.TextMargin = new System.Windows.Forms.Padding(3); + this.plotterIO.TextPadding = new System.Windows.Forms.Padding(3); + this.plotterIO.TextPosition = System.Drawing.ContentAlignment.TopLeft; + this.plotterIO.UseLongData = true; + this.plotterIO.UseSecondLine = true; + // // groupBox1 // - this.groupBox1.Controls.Add(this.trackerMemory); + this.groupBox1.Controls.Add(this.plotterMemory); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(89, 360); + this.groupBox1.Location = new System.Drawing.Point(89, 163); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(604, 115); + this.groupBox1.Size = new System.Drawing.Size(726, 62); this.groupBox1.TabIndex = 7; this.groupBox1.TabStop = false; - this.groupBox1.Text = "Physical Memory"; + this.groupBox1.Text = "Commit, Physical Memory"; + // + // plotterMemory + // + this.plotterMemory.BackColor = System.Drawing.Color.Black; + this.plotterMemory.Data1 = null; + this.plotterMemory.Data2 = null; + this.plotterMemory.Dock = System.Windows.Forms.DockStyle.Fill; + this.plotterMemory.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(128)))), ((int)(((byte)(64))))); + this.plotterMemory.GridSize = new System.Drawing.Size(12, 12); + this.plotterMemory.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotterMemory.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotterMemory.Location = new System.Drawing.Point(3, 16); + this.plotterMemory.LongData1 = null; + this.plotterMemory.LongData2 = null; + this.plotterMemory.MinMaxValue = ((long)(0)); + this.plotterMemory.MoveStep = -1; + this.plotterMemory.Name = "plotterMemory"; + this.plotterMemory.OverlaySecondLine = true; + this.plotterMemory.ShowGrid = true; + this.plotterMemory.Size = new System.Drawing.Size(720, 43); + this.plotterMemory.TabIndex = 5; + this.plotterMemory.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.plotterMemory.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.plotterMemory.TextMargin = new System.Windows.Forms.Padding(3); + this.plotterMemory.TextPadding = new System.Windows.Forms.Padding(3); + this.plotterMemory.TextPosition = System.Drawing.ContentAlignment.TopLeft; + this.plotterMemory.UseLongData = true; + this.plotterMemory.UseSecondLine = true; // // groupBox11 // this.groupBox11.Controls.Add(this.indicatorPhysical); this.groupBox11.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox11.Location = new System.Drawing.Point(3, 360); + this.groupBox11.Location = new System.Drawing.Point(3, 163); this.groupBox11.Name = "groupBox11"; - this.groupBox11.Size = new System.Drawing.Size(80, 115); + this.groupBox11.Size = new System.Drawing.Size(80, 62); this.groupBox11.TabIndex = 9; this.groupBox11.TabStop = false; this.groupBox11.Text = "Physical"; // + // indicatorPhysical + // + this.indicatorPhysical.BackColor = System.Drawing.Color.Black; + this.indicatorPhysical.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.indicatorPhysical.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.indicatorPhysical.Data1 = ((long)(0)); + this.indicatorPhysical.Data2 = ((long)(0)); + this.indicatorPhysical.Dock = System.Windows.Forms.DockStyle.Fill; + this.indicatorPhysical.ForeColor = System.Drawing.Color.Lime; + this.indicatorPhysical.GraphWidth = 33; + this.indicatorPhysical.Location = new System.Drawing.Point(3, 16); + this.indicatorPhysical.Maximum = ((long)(2147483647)); + this.indicatorPhysical.Minimum = ((long)(0)); + this.indicatorPhysical.Name = "indicatorPhysical"; + this.indicatorPhysical.Size = new System.Drawing.Size(74, 43); + this.indicatorPhysical.TabIndex = 8; + this.indicatorPhysical.TextValue = ""; + // // groupBox12 // this.groupBox12.Controls.Add(this.indicatorIO); this.groupBox12.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox12.Location = new System.Drawing.Point(3, 241); + this.groupBox12.Location = new System.Drawing.Point(3, 95); this.groupBox12.Name = "groupBox12"; - this.groupBox12.Size = new System.Drawing.Size(80, 113); + this.groupBox12.Size = new System.Drawing.Size(80, 62); this.groupBox12.TabIndex = 10; this.groupBox12.TabStop = false; this.groupBox12.Text = "I/O (R+O)"; // + // indicatorIO + // + this.indicatorIO.BackColor = System.Drawing.Color.Black; + this.indicatorIO.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.indicatorIO.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.indicatorIO.Data1 = ((long)(0)); + this.indicatorIO.Data2 = ((long)(0)); + this.indicatorIO.Dock = System.Windows.Forms.DockStyle.Fill; + this.indicatorIO.ForeColor = System.Drawing.Color.Lime; + this.indicatorIO.GraphWidth = 33; + this.indicatorIO.Location = new System.Drawing.Point(3, 16); + this.indicatorIO.Maximum = ((long)(2147483647)); + this.indicatorIO.Minimum = ((long)(0)); + this.indicatorIO.Name = "indicatorIO"; + this.indicatorIO.Size = new System.Drawing.Size(74, 43); + this.indicatorIO.TabIndex = 8; + this.indicatorIO.TextValue = ""; + // // groupBox13 // this.groupBox13.Controls.Add(this.indicatorCpu); this.groupBox13.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox13.Location = new System.Drawing.Point(3, 3); this.groupBox13.Name = "groupBox13"; - this.groupBox13.Size = new System.Drawing.Size(80, 113); + this.groupBox13.Size = new System.Drawing.Size(80, 62); this.groupBox13.TabIndex = 11; this.groupBox13.TabStop = false; this.groupBox13.Text = "CPU Usage"; // + // indicatorCpu + // + this.indicatorCpu.BackColor = System.Drawing.Color.Black; + this.indicatorCpu.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.indicatorCpu.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); + this.indicatorCpu.Data1 = ((long)(500000000)); + this.indicatorCpu.Data2 = ((long)(500000000)); + this.indicatorCpu.Dock = System.Windows.Forms.DockStyle.Fill; + this.indicatorCpu.ForeColor = System.Drawing.Color.Lime; + this.indicatorCpu.GraphWidth = 33; + this.indicatorCpu.Location = new System.Drawing.Point(3, 16); + this.indicatorCpu.Maximum = ((long)(2147483647)); + this.indicatorCpu.Minimum = ((long)(0)); + this.indicatorCpu.Name = "indicatorCpu"; + this.indicatorCpu.Size = new System.Drawing.Size(74, 43); + this.indicatorCpu.TabIndex = 8; + this.indicatorCpu.TextValue = ""; + // // checkShowOneGraphPerCPU // - this.checkShowOneGraphPerCPU.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.checkShowOneGraphPerCPU.AutoSize = true; this.checkShowOneGraphPerCPU.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.checkShowOneGraphPerCPU.Location = new System.Drawing.Point(12, 532); + this.checkShowOneGraphPerCPU.Location = new System.Drawing.Point(89, 71); this.checkShowOneGraphPerCPU.Name = "checkShowOneGraphPerCPU"; this.checkShowOneGraphPerCPU.Size = new System.Drawing.Size(153, 18); this.checkShowOneGraphPerCPU.TabIndex = 3; @@ -312,105 +418,149 @@ private void InitializeComponent() this.checkShowOneGraphPerCPU.UseVisualStyleBackColor = true; this.checkShowOneGraphPerCPU.CheckedChanged += new System.EventHandler(this.checkShowOneGraphPerCPU_CheckedChanged); // - // groupBox16 - // - this.groupBox16.Controls.Add(this.labelTotalsUptime); - this.groupBox16.Controls.Add(this.labelTotalsHandles); - this.groupBox16.Controls.Add(this.labelTotalsThreads); - this.groupBox16.Controls.Add(this.label42); - this.groupBox16.Controls.Add(this.label40); - this.groupBox16.Controls.Add(this.label46); - this.groupBox16.Controls.Add(this.label39); - this.groupBox16.Controls.Add(this.labelTotalsProcesses); - this.groupBox16.Location = new System.Drawing.Point(9, 6); - this.groupBox16.Name = "groupBox16"; - this.groupBox16.Size = new System.Drawing.Size(193, 84); - this.groupBox16.TabIndex = 6; - this.groupBox16.TabStop = false; - this.groupBox16.Text = "System"; + // flowInfo + // + this.flowInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.flowInfo.AutoScroll = true; + this.flowInfo.Controls.Add(this.groupBox3); + this.flowInfo.Controls.Add(this.groupBox4); + this.flowInfo.Controls.Add(this.groupBox5); + this.flowInfo.Controls.Add(this.groupBox6); + this.flowInfo.Controls.Add(this.groupBox7); + this.flowInfo.Controls.Add(this.groupBox8); + this.flowInfo.Controls.Add(this.groupBox9); + this.flowInfo.Controls.Add(this.groupBox10); + this.flowInfo.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowInfo.Location = new System.Drawing.Point(12, 246); + this.flowInfo.Name = "flowInfo"; + this.flowInfo.Size = new System.Drawing.Size(818, 256); + this.flowInfo.TabIndex = 4; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.tableLayoutPanel1); + this.groupBox3.Location = new System.Drawing.Point(3, 3); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(195, 84); + this.groupBox3.TabIndex = 1; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "System"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.Controls.Add(this.labelTotalsUptime, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.label6, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.label8, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.label9, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.labelTotalsProcesses, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.labelTotalsThreads, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.labelTotalsHandles, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.label34, 0, 3); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 16); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 4; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(189, 65); + this.tableLayoutPanel1.TabIndex = 1; // // labelTotalsUptime // this.labelTotalsUptime.AutoEllipsis = true; - this.labelTotalsUptime.Location = new System.Drawing.Point(68, 62); + this.labelTotalsUptime.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelTotalsUptime.Location = new System.Drawing.Point(65, 48); this.labelTotalsUptime.Name = "labelTotalsUptime"; - this.labelTotalsUptime.Size = new System.Drawing.Size(121, 15); - this.labelTotalsUptime.TabIndex = 1; + this.labelTotalsUptime.Size = new System.Drawing.Size(121, 17); + this.labelTotalsUptime.TabIndex = 2; this.labelTotalsUptime.Text = "value"; this.labelTotalsUptime.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // labelTotalsHandles + // label6 // - this.labelTotalsHandles.AutoEllipsis = true; - this.labelTotalsHandles.Location = new System.Drawing.Point(68, 47); - this.labelTotalsHandles.Name = "labelTotalsHandles"; - this.labelTotalsHandles.Size = new System.Drawing.Size(121, 15); - this.labelTotalsHandles.TabIndex = 1; - this.labelTotalsHandles.Text = "value"; - this.labelTotalsHandles.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label6.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(3, 1); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(56, 13); + this.label6.TabIndex = 1; + this.label6.Text = "Processes"; // - // labelTotalsThreads + // label8 // - this.labelTotalsThreads.AutoEllipsis = true; - this.labelTotalsThreads.Location = new System.Drawing.Point(68, 32); - this.labelTotalsThreads.Name = "labelTotalsThreads"; - this.labelTotalsThreads.Size = new System.Drawing.Size(121, 15); - this.labelTotalsThreads.TabIndex = 2; - this.labelTotalsThreads.Text = "value"; - this.labelTotalsThreads.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label8.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(3, 17); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(46, 13); + this.label8.TabIndex = 1; + this.label8.Text = "Threads"; // - // label42 + // label9 // - this.label42.AutoSize = true; - this.label42.Location = new System.Drawing.Point(6, 48); - this.label42.Name = "label42"; - this.label42.Size = new System.Drawing.Size(46, 13); - this.label42.TabIndex = 1; - this.label42.Text = "Handles"; - // - // label40 - // - this.label40.AutoSize = true; - this.label40.Location = new System.Drawing.Point(6, 33); - this.label40.Name = "label40"; - this.label40.Size = new System.Drawing.Size(46, 13); - this.label40.TabIndex = 1; - this.label40.Text = "Threads"; - // - // label46 - // - this.label46.AutoSize = true; - this.label46.Location = new System.Drawing.Point(6, 63); - this.label46.Name = "label46"; - this.label46.Size = new System.Drawing.Size(40, 13); - this.label46.TabIndex = 1; - this.label46.Text = "Uptime"; - // - // label39 - // - this.label39.AutoSize = true; - this.label39.Location = new System.Drawing.Point(6, 18); - this.label39.Name = "label39"; - this.label39.Size = new System.Drawing.Size(56, 13); - this.label39.TabIndex = 1; - this.label39.Text = "Processes"; + this.label9.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(3, 33); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(46, 13); + this.label9.TabIndex = 1; + this.label9.Text = "Handles"; // // labelTotalsProcesses // this.labelTotalsProcesses.AutoEllipsis = true; - this.labelTotalsProcesses.Location = new System.Drawing.Point(68, 18); + this.labelTotalsProcesses.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelTotalsProcesses.Location = new System.Drawing.Point(65, 0); this.labelTotalsProcesses.Name = "labelTotalsProcesses"; - this.labelTotalsProcesses.Size = new System.Drawing.Size(121, 15); + this.labelTotalsProcesses.Size = new System.Drawing.Size(121, 16); this.labelTotalsProcesses.TabIndex = 1; this.labelTotalsProcesses.Text = "value"; this.labelTotalsProcesses.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // + // labelTotalsThreads + // + this.labelTotalsThreads.AutoEllipsis = true; + this.labelTotalsThreads.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelTotalsThreads.Location = new System.Drawing.Point(65, 16); + this.labelTotalsThreads.Name = "labelTotalsThreads"; + this.labelTotalsThreads.Size = new System.Drawing.Size(121, 16); + this.labelTotalsThreads.TabIndex = 1; + this.labelTotalsThreads.Text = "value"; + this.labelTotalsThreads.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // labelTotalsHandles + // + this.labelTotalsHandles.AutoEllipsis = true; + this.labelTotalsHandles.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelTotalsHandles.Location = new System.Drawing.Point(65, 32); + this.labelTotalsHandles.Name = "labelTotalsHandles"; + this.labelTotalsHandles.Size = new System.Drawing.Size(121, 16); + this.labelTotalsHandles.TabIndex = 1; + this.labelTotalsHandles.Text = "value"; + this.labelTotalsHandles.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label34 + // + this.label34.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label34.AutoSize = true; + this.label34.Location = new System.Drawing.Point(3, 50); + this.label34.Name = "label34"; + this.label34.Size = new System.Drawing.Size(40, 13); + this.label34.TabIndex = 1; + this.label34.Text = "Uptime"; + // // groupBox4 // this.groupBox4.Controls.Add(this.tableLayoutPanel2); - this.groupBox4.Location = new System.Drawing.Point(9, 96); + this.groupBox4.Location = new System.Drawing.Point(3, 93); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(193, 78); + this.groupBox4.Size = new System.Drawing.Size(195, 78); this.groupBox4.TabIndex = 2; this.groupBox4.TabStop = false; this.groupBox4.Text = "Commit Charge"; @@ -433,7 +583,7 @@ private void InitializeComponent() this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(187, 59); + this.tableLayoutPanel2.Size = new System.Drawing.Size(189, 59); this.tableLayoutPanel2.TabIndex = 1; // // label1 @@ -499,107 +649,10 @@ private void InitializeComponent() this.labelCCL.Text = "value"; this.labelCCL.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // - // groupBox6 - // - this.groupBox6.Controls.Add(this.labelCachePeak); - this.groupBox6.Controls.Add(this.labelCacheCurrent); - this.groupBox6.Controls.Add(this.label5); - this.groupBox6.Controls.Add(this.labelCacheMaximum); - this.groupBox6.Controls.Add(this.label10); - this.groupBox6.Controls.Add(this.labelCacheMinimum); - this.groupBox6.Controls.Add(this.label13); - this.groupBox6.Controls.Add(this.label15); - this.groupBox6.Location = new System.Drawing.Point(208, 6); - this.groupBox6.Name = "groupBox6"; - this.groupBox6.Size = new System.Drawing.Size(190, 84); - this.groupBox6.TabIndex = 4; - this.groupBox6.TabStop = false; - this.groupBox6.Text = "File Cache"; - // - // labelCachePeak - // - this.labelCachePeak.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelCachePeak.AutoEllipsis = true; - this.labelCachePeak.Location = new System.Drawing.Point(63, 19); - this.labelCachePeak.Name = "labelCachePeak"; - this.labelCachePeak.Size = new System.Drawing.Size(121, 13); - this.labelCachePeak.TabIndex = 1; - this.labelCachePeak.Text = "value"; - this.labelCachePeak.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // labelCacheCurrent - // - this.labelCacheCurrent.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelCacheCurrent.AutoEllipsis = true; - this.labelCacheCurrent.Location = new System.Drawing.Point(63, 48); - this.labelCacheCurrent.Name = "labelCacheCurrent"; - this.labelCacheCurrent.Size = new System.Drawing.Size(121, 13); - this.labelCacheCurrent.TabIndex = 1; - this.labelCacheCurrent.Text = "value"; - this.labelCacheCurrent.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(6, 18); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(41, 13); - this.label5.TabIndex = 1; - this.label5.Text = "Current"; - // - // labelCacheMaximum - // - this.labelCacheMaximum.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelCacheMaximum.AutoEllipsis = true; - this.labelCacheMaximum.Location = new System.Drawing.Point(63, 33); - this.labelCacheMaximum.Name = "labelCacheMaximum"; - this.labelCacheMaximum.Size = new System.Drawing.Size(121, 13); - this.labelCacheMaximum.TabIndex = 4; - this.labelCacheMaximum.Text = "value"; - this.labelCacheMaximum.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(6, 33); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(32, 13); - this.label10.TabIndex = 1; - this.label10.Text = "Peak"; - // - // labelCacheMinimum - // - this.labelCacheMinimum.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.labelCacheMinimum.AutoEllipsis = true; - this.labelCacheMinimum.Location = new System.Drawing.Point(63, 63); - this.labelCacheMinimum.Name = "labelCacheMinimum"; - this.labelCacheMinimum.Size = new System.Drawing.Size(121, 13); - this.labelCacheMinimum.TabIndex = 2; - this.labelCacheMinimum.Text = "value"; - this.labelCacheMinimum.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(6, 63); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(48, 13); - this.label13.TabIndex = 3; - this.label13.Text = "Minimum"; - // - // label15 - // - this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(6, 48); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(51, 13); - this.label15.TabIndex = 5; - this.label15.Text = "Maximum"; - // // groupBox5 // this.groupBox5.Controls.Add(this.tableLayoutPanel3); - this.groupBox5.Location = new System.Drawing.Point(7, 180); + this.groupBox5.Location = new System.Drawing.Point(3, 177); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(195, 75); this.groupBox5.TabIndex = 3; @@ -690,10 +743,128 @@ private void InitializeComponent() this.labelPSC.Text = "value"; this.labelPSC.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // + // groupBox6 + // + this.groupBox6.Controls.Add(this.tableLayoutPanel4); + this.groupBox6.Location = new System.Drawing.Point(204, 3); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(195, 85); + this.groupBox6.TabIndex = 4; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "File Cache"; + // + // tableLayoutPanel4 + // + this.tableLayoutPanel4.ColumnCount = 2; + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel4.Controls.Add(this.label15, 0, 3); + this.tableLayoutPanel4.Controls.Add(this.labelCacheMaximum, 0, 3); + this.tableLayoutPanel4.Controls.Add(this.label13, 0, 2); + this.tableLayoutPanel4.Controls.Add(this.labelCacheMinimum, 0, 2); + this.tableLayoutPanel4.Controls.Add(this.label5, 0, 0); + this.tableLayoutPanel4.Controls.Add(this.label10, 0, 1); + this.tableLayoutPanel4.Controls.Add(this.labelCacheCurrent, 1, 0); + this.tableLayoutPanel4.Controls.Add(this.labelCachePeak, 1, 1); + this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 16); + this.tableLayoutPanel4.Name = "tableLayoutPanel4"; + this.tableLayoutPanel4.RowCount = 4; + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); + this.tableLayoutPanel4.Size = new System.Drawing.Size(189, 66); + this.tableLayoutPanel4.TabIndex = 1; + // + // label15 + // + this.label15.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(3, 50); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(51, 13); + this.label15.TabIndex = 5; + this.label15.Text = "Maximum"; + // + // labelCacheMaximum + // + this.labelCacheMaximum.AutoEllipsis = true; + this.labelCacheMaximum.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelCacheMaximum.Location = new System.Drawing.Point(60, 48); + this.labelCacheMaximum.Name = "labelCacheMaximum"; + this.labelCacheMaximum.Size = new System.Drawing.Size(130, 18); + this.labelCacheMaximum.TabIndex = 4; + this.labelCacheMaximum.Text = "value"; + this.labelCacheMaximum.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label13 + // + this.label13.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(3, 33); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(48, 13); + this.label13.TabIndex = 3; + this.label13.Text = "Minimum"; + // + // labelCacheMinimum + // + this.labelCacheMinimum.AutoEllipsis = true; + this.labelCacheMinimum.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelCacheMinimum.Location = new System.Drawing.Point(60, 32); + this.labelCacheMinimum.Name = "labelCacheMinimum"; + this.labelCacheMinimum.Size = new System.Drawing.Size(130, 16); + this.labelCacheMinimum.TabIndex = 2; + this.labelCacheMinimum.Text = "value"; + this.labelCacheMinimum.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label5 + // + this.label5.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(3, 1); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(41, 13); + this.label5.TabIndex = 1; + this.label5.Text = "Current"; + // + // label10 + // + this.label10.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(3, 17); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(32, 13); + this.label10.TabIndex = 1; + this.label10.Text = "Peak"; + // + // labelCacheCurrent + // + this.labelCacheCurrent.AutoEllipsis = true; + this.labelCacheCurrent.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelCacheCurrent.Location = new System.Drawing.Point(60, 0); + this.labelCacheCurrent.Name = "labelCacheCurrent"; + this.labelCacheCurrent.Size = new System.Drawing.Size(130, 16); + this.labelCacheCurrent.TabIndex = 1; + this.labelCacheCurrent.Text = "value"; + this.labelCacheCurrent.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // labelCachePeak + // + this.labelCachePeak.AutoEllipsis = true; + this.labelCachePeak.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelCachePeak.Location = new System.Drawing.Point(60, 16); + this.labelCachePeak.Name = "labelCachePeak"; + this.labelCachePeak.Size = new System.Drawing.Size(130, 16); + this.labelCachePeak.TabIndex = 1; + this.labelCachePeak.Text = "value"; + this.labelCachePeak.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // // groupBox7 // this.groupBox7.Controls.Add(this.tableLayoutPanel5); - this.groupBox7.Location = new System.Drawing.Point(208, 96); + this.groupBox7.Location = new System.Drawing.Point(204, 94); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(195, 157); this.groupBox7.TabIndex = 5; @@ -932,7 +1103,7 @@ private void InitializeComponent() // groupBox8 // this.groupBox8.Controls.Add(this.tableLayoutPanel6); - this.groupBox8.Location = new System.Drawing.Point(409, 12); + this.groupBox8.Location = new System.Drawing.Point(405, 3); this.groupBox8.Name = "groupBox8"; this.groupBox8.Size = new System.Drawing.Size(195, 121); this.groupBox8.TabIndex = 6; @@ -1098,9 +1269,9 @@ private void InitializeComponent() // groupBox9 // this.groupBox9.Controls.Add(this.tableLayoutPanel7); - this.groupBox9.Location = new System.Drawing.Point(409, 139); + this.groupBox9.Location = new System.Drawing.Point(405, 130); this.groupBox9.Name = "groupBox9"; - this.groupBox9.Size = new System.Drawing.Size(195, 113); + this.groupBox9.Size = new System.Drawing.Size(195, 121); this.groupBox9.TabIndex = 7; this.groupBox9.TabStop = false; this.groupBox9.Text = "I/O"; @@ -1132,14 +1303,14 @@ private void InitializeComponent() this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); - this.tableLayoutPanel7.Size = new System.Drawing.Size(189, 94); + this.tableLayoutPanel7.Size = new System.Drawing.Size(189, 102); this.tableLayoutPanel7.TabIndex = 1; // // label16 // this.label16.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(3, 78); + this.label16.Location = new System.Drawing.Point(3, 84); this.label16.Name = "label16"; this.label16.Size = new System.Drawing.Size(62, 13); this.label16.TabIndex = 7; @@ -1149,9 +1320,9 @@ private void InitializeComponent() // this.labelIOOB.AutoEllipsis = true; this.labelIOOB.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelIOOB.Location = new System.Drawing.Point(71, 75); + this.labelIOOB.Location = new System.Drawing.Point(71, 80); this.labelIOOB.Name = "labelIOOB"; - this.labelIOOB.Size = new System.Drawing.Size(115, 19); + this.labelIOOB.Size = new System.Drawing.Size(115, 22); this.labelIOOB.TabIndex = 6; this.labelIOOB.Text = "value"; this.labelIOOB.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -1160,7 +1331,7 @@ private void InitializeComponent() // this.label22.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label22.AutoSize = true; - this.label22.Location = new System.Drawing.Point(3, 61); + this.label22.Location = new System.Drawing.Point(3, 65); this.label22.Name = "label22"; this.label22.Size = new System.Drawing.Size(33, 13); this.label22.TabIndex = 5; @@ -1170,7 +1341,7 @@ private void InitializeComponent() // this.label26.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label26.AutoSize = true; - this.label26.Location = new System.Drawing.Point(3, 46); + this.label26.Location = new System.Drawing.Point(3, 49); this.label26.Name = "label26"; this.label26.Size = new System.Drawing.Size(61, 13); this.label26.TabIndex = 3; @@ -1180,9 +1351,9 @@ private void InitializeComponent() // this.labelIOO.AutoEllipsis = true; this.labelIOO.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelIOO.Location = new System.Drawing.Point(71, 60); + this.labelIOO.Location = new System.Drawing.Point(71, 64); this.labelIOO.Name = "labelIOO"; - this.labelIOO.Size = new System.Drawing.Size(115, 15); + this.labelIOO.Size = new System.Drawing.Size(115, 16); this.labelIOO.TabIndex = 4; this.labelIOO.Text = "value"; this.labelIOO.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -1201,7 +1372,7 @@ private void InitializeComponent() // this.label32.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label32.AutoSize = true; - this.label32.Location = new System.Drawing.Point(3, 31); + this.label32.Location = new System.Drawing.Point(3, 33); this.label32.Name = "label32"; this.label32.Size = new System.Drawing.Size(37, 13); this.label32.TabIndex = 1; @@ -1213,7 +1384,7 @@ private void InitializeComponent() this.labelIOR.Dock = System.Windows.Forms.DockStyle.Fill; this.labelIOR.Location = new System.Drawing.Point(71, 0); this.labelIOR.Name = "labelIOR"; - this.labelIOR.Size = new System.Drawing.Size(115, 15); + this.labelIOR.Size = new System.Drawing.Size(115, 16); this.labelIOR.TabIndex = 1; this.labelIOR.Text = "value"; this.labelIOR.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -1222,9 +1393,9 @@ private void InitializeComponent() // this.labelIOW.AutoEllipsis = true; this.labelIOW.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelIOW.Location = new System.Drawing.Point(71, 30); + this.labelIOW.Location = new System.Drawing.Point(71, 32); this.labelIOW.Name = "labelIOW"; - this.labelIOW.Size = new System.Drawing.Size(115, 15); + this.labelIOW.Size = new System.Drawing.Size(115, 16); this.labelIOW.TabIndex = 1; this.labelIOW.Text = "value"; this.labelIOW.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -1233,7 +1404,7 @@ private void InitializeComponent() // this.label35.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label35.AutoSize = true; - this.label35.Location = new System.Drawing.Point(3, 16); + this.label35.Location = new System.Drawing.Point(3, 17); this.label35.Name = "label35"; this.label35.Size = new System.Drawing.Size(62, 13); this.label35.TabIndex = 1; @@ -1243,9 +1414,9 @@ private void InitializeComponent() // this.labelIORB.AutoEllipsis = true; this.labelIORB.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelIORB.Location = new System.Drawing.Point(71, 15); + this.labelIORB.Location = new System.Drawing.Point(71, 16); this.labelIORB.Name = "labelIORB"; - this.labelIORB.Size = new System.Drawing.Size(115, 15); + this.labelIORB.Size = new System.Drawing.Size(115, 16); this.labelIORB.TabIndex = 1; this.labelIORB.Text = "value"; this.labelIORB.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -1254,17 +1425,18 @@ private void InitializeComponent() // this.labelIOWB.AutoEllipsis = true; this.labelIOWB.Dock = System.Windows.Forms.DockStyle.Fill; - this.labelIOWB.Location = new System.Drawing.Point(71, 45); + this.labelIOWB.Location = new System.Drawing.Point(71, 48); this.labelIOWB.Name = "labelIOWB"; - this.labelIOWB.Size = new System.Drawing.Size(115, 15); + this.labelIOWB.Size = new System.Drawing.Size(115, 16); this.labelIOWB.TabIndex = 2; this.labelIOWB.Text = "value"; this.labelIOWB.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // groupBox10 // + this.groupBox10.AutoSize = true; this.groupBox10.Controls.Add(this.tableLayoutPanel8); - this.groupBox10.Location = new System.Drawing.Point(8, 261); + this.groupBox10.Location = new System.Drawing.Point(606, 3); this.groupBox10.MinimumSize = new System.Drawing.Size(195, 76); this.groupBox10.Name = "groupBox10"; this.groupBox10.Size = new System.Drawing.Size(195, 76); @@ -1317,6 +1489,7 @@ private void InitializeComponent() // labelCPUContextSwitches // this.labelCPUContextSwitches.AutoEllipsis = true; + this.labelCPUContextSwitches.AutoSize = true; this.labelCPUContextSwitches.Dock = System.Windows.Forms.DockStyle.Fill; this.labelCPUContextSwitches.Location = new System.Drawing.Point(98, 0); this.labelCPUContextSwitches.Name = "labelCPUContextSwitches"; @@ -1328,6 +1501,7 @@ private void InitializeComponent() // labelCPUSystemCalls // this.labelCPUSystemCalls.AutoEllipsis = true; + this.labelCPUSystemCalls.AutoSize = true; this.labelCPUSystemCalls.Dock = System.Windows.Forms.DockStyle.Fill; this.labelCPUSystemCalls.Location = new System.Drawing.Point(98, 38); this.labelCPUSystemCalls.Name = "labelCPUSystemCalls"; @@ -1349,6 +1523,7 @@ private void InitializeComponent() // labelCPUInterrupts // this.labelCPUInterrupts.AutoEllipsis = true; + this.labelCPUInterrupts.AutoSize = true; this.labelCPUInterrupts.Dock = System.Windows.Forms.DockStyle.Fill; this.labelCPUInterrupts.Location = new System.Drawing.Point(98, 19); this.labelCPUInterrupts.Name = "labelCPUInterrupts"; @@ -1359,10 +1534,10 @@ private void InitializeComponent() // // checkAlwaysOnTop // - this.checkAlwaysOnTop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.checkAlwaysOnTop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.checkAlwaysOnTop.AutoSize = true; this.checkAlwaysOnTop.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.checkAlwaysOnTop.Location = new System.Drawing.Point(180, 532); + this.checkAlwaysOnTop.Location = new System.Drawing.Point(728, 508); this.checkAlwaysOnTop.Name = "checkAlwaysOnTop"; this.checkAlwaysOnTop.Size = new System.Drawing.Size(102, 18); this.checkAlwaysOnTop.TabIndex = 5; @@ -1370,260 +1545,43 @@ private void InitializeComponent() this.checkAlwaysOnTop.UseVisualStyleBackColor = true; this.checkAlwaysOnTop.CheckedChanged += new System.EventHandler(this.checkAlwaysOnTop_CheckedChanged); // - // tabControl1 - // - this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabControl1.Controls.Add(this.tabPage1); - this.tabControl1.Controls.Add(this.tabPage2); - this.tabControl1.Location = new System.Drawing.Point(12, 12); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(710, 510); - this.tabControl1.TabIndex = 6; - // - // tabPage1 - // - this.tabPage1.Controls.Add(this.tableGraphs); - this.tabPage1.Location = new System.Drawing.Point(4, 22); - this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(702, 484); - this.tabPage1.TabIndex = 0; - this.tabPage1.Text = "Summary"; - this.tabPage1.UseVisualStyleBackColor = true; - // - // tabPage2 - // - this.tabPage2.Controls.Add(this.groupBox4); - this.tabPage2.Controls.Add(this.groupBox16); - this.tabPage2.Controls.Add(this.groupBox7); - this.tabPage2.Controls.Add(this.groupBox5); - this.tabPage2.Controls.Add(this.groupBox6); - this.tabPage2.Controls.Add(this.groupBox10); - this.tabPage2.Controls.Add(this.groupBox9); - this.tabPage2.Controls.Add(this.groupBox8); - this.tabPage2.Location = new System.Drawing.Point(4, 22); - this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(702, 484); - this.tabPage2.TabIndex = 1; - this.tabPage2.Text = "Stats"; - this.tabPage2.UseVisualStyleBackColor = true; - // - // CloseButton - // - this.CloseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CloseButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.CloseButton.Location = new System.Drawing.Point(647, 528); - this.CloseButton.Name = "CloseButton"; - this.CloseButton.Size = new System.Drawing.Size(75, 23); - this.CloseButton.TabIndex = 7; - this.CloseButton.Text = "Close"; - this.CloseButton.UseVisualStyleBackColor = true; - this.CloseButton.Click += new System.EventHandler(this.CloseButton_Click); - // - // indicatorCommit - // - this.indicatorCommit.BackColor = System.Drawing.Color.Black; - this.indicatorCommit.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.indicatorCommit.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.indicatorCommit.Data1 = ((long)(0)); - this.indicatorCommit.Data2 = ((long)(0)); - this.indicatorCommit.Dock = System.Windows.Forms.DockStyle.Fill; - this.indicatorCommit.ForeColor = System.Drawing.Color.Lime; - this.indicatorCommit.GraphWidth = 33; - this.indicatorCommit.Location = new System.Drawing.Point(3, 16); - this.indicatorCommit.Maximum = ((long)(2147483647)); - this.indicatorCommit.Minimum = ((long)(0)); - this.indicatorCommit.Name = "indicatorCommit"; - this.indicatorCommit.Size = new System.Drawing.Size(74, 94); - this.indicatorCommit.TabIndex = 8; - this.indicatorCommit.TextValue = "value"; - // - // trackerCommit - // - this.trackerCommit.BackColor = System.Drawing.Color.Black; - this.trackerCommit.Dock = System.Windows.Forms.DockStyle.Fill; - this.trackerCommit.Location = new System.Drawing.Point(3, 16); - this.trackerCommit.LowerRange = 30; - this.trackerCommit.Name = "trackerCommit"; - this.trackerCommit.Size = new System.Drawing.Size(598, 94); - this.trackerCommit.TabIndex = 6; - this.trackerCommit.Text = null; - this.trackerCommit.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.trackerCommit.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.trackerCommit.TextMargin = new System.Windows.Forms.Padding(3); - this.trackerCommit.TextPadding = new System.Windows.Forms.Padding(3); - this.trackerCommit.TextPosition = System.Drawing.ContentAlignment.TopLeft; - this.trackerCommit.UpperRange = 90; - this.trackerCommit.UseSecondLine = false; - // - // plotterCPU - // - this.plotterCPU.BackColor = System.Drawing.Color.Black; - this.plotterCPU.Data1 = null; - this.plotterCPU.Data2 = null; - this.plotterCPU.Dock = System.Windows.Forms.DockStyle.Fill; - this.plotterCPU.GridColor = System.Drawing.Color.Green; - this.plotterCPU.GridSize = new System.Drawing.Size(12, 12); - this.plotterCPU.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.plotterCPU.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.plotterCPU.Location = new System.Drawing.Point(3, 16); - this.plotterCPU.LongData1 = null; - this.plotterCPU.LongData2 = null; - this.plotterCPU.MinMaxValue = ((long)(0)); - this.plotterCPU.MoveStep = -1; - this.plotterCPU.Name = "plotterCPU"; - this.plotterCPU.OverlaySecondLine = false; - this.plotterCPU.ShowGrid = true; - this.plotterCPU.Size = new System.Drawing.Size(598, 94); - this.plotterCPU.TabIndex = 0; - this.plotterCPU.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.plotterCPU.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.plotterCPU.TextMargin = new System.Windows.Forms.Padding(3); - this.plotterCPU.TextPadding = new System.Windows.Forms.Padding(3); - this.plotterCPU.TextPosition = System.Drawing.ContentAlignment.TopLeft; - this.plotterCPU.UseLongData = false; - this.plotterCPU.UseSecondLine = true; - // - // plotterIO - // - this.plotterIO.BackColor = System.Drawing.Color.Black; - this.plotterIO.Data1 = null; - this.plotterIO.Data2 = null; - this.plotterIO.Dock = System.Windows.Forms.DockStyle.Fill; - this.plotterIO.GridColor = System.Drawing.Color.Green; - this.plotterIO.GridSize = new System.Drawing.Size(12, 12); - this.plotterIO.LineColor1 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.plotterIO.LineColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.plotterIO.Location = new System.Drawing.Point(3, 16); - this.plotterIO.LongData1 = null; - this.plotterIO.LongData2 = null; - this.plotterIO.MinMaxValue = ((long)(0)); - this.plotterIO.MoveStep = -1; - this.plotterIO.Name = "plotterIO"; - this.plotterIO.OverlaySecondLine = true; - this.plotterIO.ShowGrid = true; - this.plotterIO.Size = new System.Drawing.Size(598, 94); - this.plotterIO.TabIndex = 5; - this.plotterIO.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.plotterIO.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.plotterIO.TextMargin = new System.Windows.Forms.Padding(3); - this.plotterIO.TextPadding = new System.Windows.Forms.Padding(3); - this.plotterIO.TextPosition = System.Drawing.ContentAlignment.TopLeft; - this.plotterIO.UseLongData = true; - this.plotterIO.UseSecondLine = true; - // - // trackerMemory - // - this.trackerMemory.BackColor = System.Drawing.Color.Black; - this.trackerMemory.Dock = System.Windows.Forms.DockStyle.Fill; - this.trackerMemory.Location = new System.Drawing.Point(3, 16); - this.trackerMemory.LowerRange = 30; - this.trackerMemory.Name = "trackerMemory"; - this.trackerMemory.Size = new System.Drawing.Size(598, 96); - this.trackerMemory.TabIndex = 6; - this.trackerMemory.Text = null; - this.trackerMemory.TextBoxColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.trackerMemory.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.trackerMemory.TextMargin = new System.Windows.Forms.Padding(3); - this.trackerMemory.TextPadding = new System.Windows.Forms.Padding(3); - this.trackerMemory.TextPosition = System.Drawing.ContentAlignment.TopLeft; - this.trackerMemory.UpperRange = 90; - this.trackerMemory.UseSecondLine = false; - // - // indicatorPhysical - // - this.indicatorPhysical.BackColor = System.Drawing.Color.Black; - this.indicatorPhysical.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.indicatorPhysical.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.indicatorPhysical.Data1 = ((long)(0)); - this.indicatorPhysical.Data2 = ((long)(0)); - this.indicatorPhysical.Dock = System.Windows.Forms.DockStyle.Fill; - this.indicatorPhysical.ForeColor = System.Drawing.Color.Lime; - this.indicatorPhysical.GraphWidth = 33; - this.indicatorPhysical.Location = new System.Drawing.Point(3, 16); - this.indicatorPhysical.Maximum = ((long)(2147483647)); - this.indicatorPhysical.Minimum = ((long)(0)); - this.indicatorPhysical.Name = "indicatorPhysical"; - this.indicatorPhysical.Size = new System.Drawing.Size(74, 96); - this.indicatorPhysical.TabIndex = 8; - this.indicatorPhysical.TextValue = "value"; - // - // indicatorIO - // - this.indicatorIO.BackColor = System.Drawing.Color.Black; - this.indicatorIO.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.indicatorIO.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.indicatorIO.Data1 = ((long)(0)); - this.indicatorIO.Data2 = ((long)(0)); - this.indicatorIO.Dock = System.Windows.Forms.DockStyle.Fill; - this.indicatorIO.ForeColor = System.Drawing.Color.Lime; - this.indicatorIO.GraphWidth = 33; - this.indicatorIO.Location = new System.Drawing.Point(3, 16); - this.indicatorIO.Maximum = ((long)(2147483647)); - this.indicatorIO.Minimum = ((long)(0)); - this.indicatorIO.Name = "indicatorIO"; - this.indicatorIO.Size = new System.Drawing.Size(74, 94); - this.indicatorIO.TabIndex = 8; - this.indicatorIO.TextValue = "value"; - // - // indicatorCpu - // - this.indicatorCpu.BackColor = System.Drawing.Color.Black; - this.indicatorCpu.Color1 = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.indicatorCpu.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(255)))), ((int)(((byte)(0))))); - this.indicatorCpu.Data1 = ((long)(500000000)); - this.indicatorCpu.Data2 = ((long)(500000000)); - this.indicatorCpu.Dock = System.Windows.Forms.DockStyle.Fill; - this.indicatorCpu.ForeColor = System.Drawing.Color.Lime; - this.indicatorCpu.GraphWidth = 33; - this.indicatorCpu.Location = new System.Drawing.Point(3, 16); - this.indicatorCpu.Maximum = ((long)(2147483647)); - this.indicatorCpu.Minimum = ((long)(0)); - this.indicatorCpu.Name = "indicatorCpu"; - this.indicatorCpu.Size = new System.Drawing.Size(74, 94); - this.indicatorCpu.TabIndex = 8; - this.indicatorCpu.TextValue = "value"; - // // SysInfoWindow // - this.AcceptButton = this.CloseButton; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.CancelButton = this.CloseButton; - this.ClientSize = new System.Drawing.Size(734, 562); - this.Controls.Add(this.CloseButton); + this.ClientSize = new System.Drawing.Size(842, 538); this.Controls.Add(this.checkAlwaysOnTop); - this.Controls.Add(this.checkShowOneGraphPerCPU); - this.Controls.Add(this.tabControl1); + this.Controls.Add(this.flowInfo); + this.Controls.Add(this.tableGraphs); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MinimumSize = new System.Drawing.Size(750, 600); + this.MinimumSize = new System.Drawing.Size(200, 500); this.Name = "SysInfoWindow"; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "System Information"; + this.Paint += new System.Windows.Forms.PaintEventHandler(this.SysInfoWindow_Paint); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SysInfoWindow_FormClosing); this.gboxCPUPlotter.ResumeLayout(false); this.tableGraphs.ResumeLayout(false); - this.groupBox15.ResumeLayout(false); - this.groupBox14.ResumeLayout(false); + this.tableGraphs.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.groupBox11.ResumeLayout(false); this.groupBox12.ResumeLayout(false); this.groupBox13.ResumeLayout(false); - this.groupBox16.ResumeLayout(false); - this.groupBox16.PerformLayout(); + this.flowInfo.ResumeLayout(false); + this.flowInfo.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); this.groupBox4.ResumeLayout(false); this.tableLayoutPanel2.ResumeLayout(false); this.tableLayoutPanel2.PerformLayout(); - this.groupBox6.ResumeLayout(false); - this.groupBox6.PerformLayout(); this.groupBox5.ResumeLayout(false); this.tableLayoutPanel3.ResumeLayout(false); this.tableLayoutPanel3.PerformLayout(); + this.groupBox6.ResumeLayout(false); + this.tableLayoutPanel4.ResumeLayout(false); + this.tableLayoutPanel4.PerformLayout(); this.groupBox7.ResumeLayout(false); this.tableLayoutPanel5.ResumeLayout(false); this.tableLayoutPanel5.PerformLayout(); @@ -1637,9 +1595,6 @@ private void InitializeComponent() this.groupBox10.PerformLayout(); this.tableLayoutPanel8.ResumeLayout(false); this.tableLayoutPanel8.PerformLayout(); - this.tabControl1.ResumeLayout(false); - this.tabPage1.ResumeLayout(false); - this.tabPage2.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -1654,6 +1609,17 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox checkShowOneGraphPerCPU; private System.Windows.Forms.GroupBox groupBox2; private ProcessHacker.Components.Plotter plotterIO; + private System.Windows.Forms.GroupBox groupBox1; + private ProcessHacker.Components.Plotter plotterMemory; + private System.Windows.Forms.FlowLayoutPanel flowInfo; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label labelTotalsProcesses; + private System.Windows.Forms.Label labelTotalsThreads; + private System.Windows.Forms.Label labelTotalsHandles; private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private System.Windows.Forms.Label label1; @@ -1669,6 +1635,7 @@ private void InitializeComponent() private System.Windows.Forms.Label labelPMC; private System.Windows.Forms.Label labelPMT; private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label labelCacheCurrent; @@ -1734,32 +1701,15 @@ private void InitializeComponent() private System.Windows.Forms.Label labelPSC; private ProcessHacker.Components.Indicator indicatorCpu; private ProcessHacker.Components.Indicator indicatorIO; + private ProcessHacker.Components.Indicator indicatorPhysical; + private System.Windows.Forms.GroupBox groupBox11; private System.Windows.Forms.GroupBox groupBox12; private System.Windows.Forms.GroupBox groupBox13; private System.Windows.Forms.Label label29; private System.Windows.Forms.Label labelKPPL; private System.Windows.Forms.Label label33; private System.Windows.Forms.Label labelKPNPL; - private System.Windows.Forms.GroupBox groupBox14; - private Tracker trackerCommit; - private System.Windows.Forms.GroupBox groupBox1; - private Tracker trackerMemory; - private System.Windows.Forms.GroupBox groupBox11; - private ProcessHacker.Components.Indicator indicatorPhysical; - private System.Windows.Forms.GroupBox groupBox15; - private ProcessHacker.Components.Indicator indicatorCommit; - private System.Windows.Forms.GroupBox groupBox16; private System.Windows.Forms.Label labelTotalsUptime; - private System.Windows.Forms.Label labelTotalsHandles; - private System.Windows.Forms.Label labelTotalsThreads; - private System.Windows.Forms.Label label42; - private System.Windows.Forms.Label label40; - private System.Windows.Forms.Label label46; - private System.Windows.Forms.Label label39; - private System.Windows.Forms.Label labelTotalsProcesses; - private System.Windows.Forms.TabControl tabControl1; - private System.Windows.Forms.TabPage tabPage1; - private System.Windows.Forms.TabPage tabPage2; - private System.Windows.Forms.Button CloseButton; + private System.Windows.Forms.Label label34; } } \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.cs b/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.cs index 1d208da98..350b9781f 100644 --- a/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.cs @@ -23,12 +23,13 @@ using System; using System.Drawing; +using System.Runtime.InteropServices; using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Components; using ProcessHacker.Native; -using ProcessHacker.Native.Symbols; using ProcessHacker.Native.Api; +using ProcessHacker.Native.Symbols; namespace ProcessHacker { @@ -37,60 +38,66 @@ public partial class SysInfoWindow : Form private static IntPtr _mmSizeOfPagedPoolInBytes; private static IntPtr _mmMaximumNonPagedPoolInBytes; - private readonly Plotter[] _cpuPlotters; - private readonly uint _noOfCPUs = Program.ProcessProvider.System.NumberOfProcessors; - private readonly int _pages = Program.ProcessProvider.System.NumberOfPhysicalPages; - private readonly int _pageSize = Program.ProcessProvider.System.PageSize; + private bool _isFirstPaint = true; + private Components.Plotter[] _cpuPlotters; + private uint _noOfCPUs = Program.ProcessProvider.System.NumberOfProcessors; + private uint _pages = (uint)Program.ProcessProvider.System.NumberOfPhysicalPages; + private uint _pageSize = (uint)Program.ProcessProvider.System.PageSize; public SysInfoWindow() - { - this.InitializeComponent(); + { + InitializeComponent(); + this.AddEscapeToClose(); - //if (!Settings.Instance.SysInfoWindowBounds.IsEmpty) - //this.DesktopBounds = Utils.FitRectangle(Settings.Instance.SysInfoWindowBounds, this); + this.Size = Settings.Instance.SysInfoWindowSize; + this.Location = Utils.FitRectangle(new Rectangle( + Settings.Instance.SysInfoWindowLocation, this.Size), this).Location; // Load the pool limit addresses. - if (_mmSizeOfPagedPoolInBytes == IntPtr.Zero) + if ( + _mmSizeOfPagedPoolInBytes == IntPtr.Zero && + KProcessHacker.Instance != null + ) { WorkQueue.GlobalQueueWorkItemTag(new Action(() => - { - try { - using (SymbolProvider symbols = new SymbolProvider()) + try { - symbols.LoadModule(Windows.KernelFileName, Windows.KernelBase); + SymbolProvider symbols = new SymbolProvider(); - _mmSizeOfPagedPoolInBytes = (IntPtr)symbols.GetSymbolFromName("MmSizeOfPagedPoolInBytes").Address; - _mmMaximumNonPagedPoolInBytes = (IntPtr)symbols.GetSymbolFromName("MmMaximumNonPagedPoolInBytes").Address; + symbols.LoadModule(Windows.KernelFileName, Windows.KernelBase); + _mmSizeOfPagedPoolInBytes = + symbols.GetSymbolFromName("MmSizeOfPagedPoolInBytes").Address.ToIntPtr(); + _mmMaximumNonPagedPoolInBytes = + symbols.GetSymbolFromName("MmMaximumNonPagedPoolInBytes").Address.ToIntPtr(); } - } - catch (Exception) { } + catch + { } + }), "load-mm-addresses"); + } + } - }), "load-mm-addresses"); + private void SysInfoWindow_Paint(object sender, PaintEventArgs e) + { + if (_isFirstPaint) + { + this.LoadStage1(); } - this.trackerMemory.values = Program.ProcessProvider.PhysicalMemoryHistory; - this.trackerMemory.DrawColor = Settings.Instance.PlotterMemoryPrivateColor; + _isFirstPaint = false; + } - this.trackerCommit.Maximum = (int)Program.ProcessProvider.Performance.CommitLimit; - this.trackerCommit.values = Program.ProcessProvider.CommitHistory; - this.trackerCommit.DrawColor = Settings.Instance.PlotterMemoryWSColor; + private void LoadStage1() + { + // Maximum physical memory. + indicatorPhysical.Maximum = (int)_pages; // Set indicators color - this.indicatorCpu.Color1 = Settings.Instance.PlotterCPUUserColor; - this.indicatorCpu.Color2 = Settings.Instance.PlotterCPUKernelColor; - - this.indicatorIO.Color1 = Settings.Instance.PlotterIOROColor; - this.indicatorPhysical.Color1 = Settings.Instance.PlotterMemoryPrivateColor; + indicatorCpu.Color1 = Settings.Instance.PlotterCPUKernelColor; + indicatorCpu.Color2 = Settings.Instance.PlotterCPUUserColor; + indicatorIO.Color1 = Settings.Instance.PlotterIOROColor; + indicatorPhysical.Color1 = Settings.Instance.PlotterMemoryWSColor; - this.plotterCPU.LineColor2 = Settings.Instance.PlotterCPUKernelColor; - this.plotterCPU.LineColor1 = Settings.Instance.PlotterCPUUserColor; - - this.plotterIO.LineColor1 = Settings.Instance.PlotterIOROColor; - this.plotterIO.LineColor2 = Settings.Instance.PlotterIOWColor; - - // Maximum physical memory. - this.indicatorPhysical.Maximum = _pages; // Set up the plotter controls. plotterCPU.Data1 = Program.ProcessProvider.CpuKernelHistory; @@ -101,7 +108,6 @@ public SysInfoWindow() "% (K " + (plotterCPU.Data1[i] * 100).ToString("N2") + "%, U " + (plotterCPU.Data2[i] * 100).ToString("N2") + "%)" + "\n" + Program.ProcessProvider.TimeHistory[i].ToString(); - plotterIO.LongData1 = Program.ProcessProvider.IoReadOtherHistory; plotterIO.LongData2 = Program.ProcessProvider.IoWriteHistory; plotterIO.GetToolTip = i => @@ -109,11 +115,12 @@ public SysInfoWindow() "R+O: " + Utils.FormatSize(plotterIO.LongData1[i]) + "\n" + "W: " + Utils.FormatSize(plotterIO.LongData2[i]) + "\n" + Program.ProcessProvider.TimeHistory[i].ToString(); - - //plotterMemory.Data1 = Program.ProcessProvider.CommitHistory; - //plotterMemory.Data2 = Program.ProcessProvider.PhysicalMemoryHistory; - //plotterMemory.GetToolTip = i => "Commit: " + plotterMemory.Data1[i] + "\n" + - // "Phys. Memory: " + plotterMemory.Data2[i] + "\n" + Program.ProcessProvider.TimeHistory[i].ToString(); + plotterMemory.LongData1 = Program.ProcessProvider.CommitHistory; + plotterMemory.LongData2 = Program.ProcessProvider.PhysicalMemoryHistory; + plotterMemory.GetToolTip = i => + "Commit: " + Utils.FormatSize(plotterMemory.LongData1[i]) + "\n" + + "Phys. Memory: " + Utils.FormatSize(plotterMemory.LongData2[i]) + "\n" + + Program.ProcessProvider.TimeHistory[i].ToString(); // Create a plotter per CPU. _cpuPlotters = new Plotter[_noOfCPUs]; @@ -126,8 +133,7 @@ public SysInfoWindow() Plotter plotter; tableCPUs.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 1.0f / _noOfCPUs)); - _cpuPlotters[i] = plotter = new Plotter(); - + _cpuPlotters[i] = plotter = new ProcessHacker.Components.Plotter(); plotter.BackColor = Color.Black; plotter.Dock = DockStyle.Fill; plotter.Margin = new Padding(i == 0 ? 0 : 3, 0, 0, 0); // nice spacing @@ -140,223 +146,252 @@ public SysInfoWindow() "% (K " + (plotter.Data1[j] * 100).ToString("N2") + "%, U " + (plotter.Data2[j] * 100).ToString("N2") + "%)" + "\n" + Program.ProcessProvider.TimeHistory[j].ToString(); - - this.tableCPUs.Controls.Add(plotter, i, 0); + tableCPUs.Controls.Add(plotter, i, 0); } - this.checkShowOneGraphPerCPU.Checked = Settings.Instance.ShowOneGraphPerCPU; + tableCPUs.Visible = true; + tableCPUs.Visible = false; + checkShowOneGraphPerCPU.Checked = Settings.Instance.ShowOneGraphPerCPU; if (_noOfCPUs == 1) checkShowOneGraphPerCPU.Enabled = false; - Program.ProcessProvider.Updated += ProcessProvider_Updated; - - //We need to do this here or TopMost property gets over-rided by AlwaysOnTopCheckbox - this.TopMost = Settings.Instance.AlwaysOnTop; - this.UpdateGraphs(); this.UpdateInfo(); + + Program.ProcessProvider.Updated += + new ProcessSystemProvider.ProviderUpdateOnce(ProcessProvider_Updated); + + //We need todo this here or TopMost property gets over-rided + //by AlwaysOnTopCheckbox + this.SetTopMost(); } - private void UpdateGraphs() + private void SysInfoWindow_FormClosing(object sender, FormClosingEventArgs e) { - switch (this.tabControl1.SelectedIndex) + if (this.WindowState == FormWindowState.Normal) { - case 0: - { - // Update the CPU indicator. - this.indicatorCpu.Data1 = (int)(Program.ProcessProvider.CurrentCpuKernelUsage * this.indicatorCpu.Maximum); - this.indicatorCpu.Data2 = (int)(Program.ProcessProvider.CurrentCpuUserUsage * this.indicatorCpu.Maximum); - this.indicatorCpu.TextValue = (Program.ProcessProvider.CurrentCpuUsage * 100).ToString("F2") + "%"; - - // Update the I/O indicator. - int count = this.plotterIO.Width / this.plotterIO.EffectiveMoveStep; - long maxRO = Program.ProcessProvider.IoReadOtherHistory.Take(count).Max(); - long maxW = Program.ProcessProvider.IoWriteHistory.Take(count).Max(); - - if (maxRO > maxW) - this.indicatorIO.Maximum = maxRO; - else - this.indicatorIO.Maximum = maxW; + Settings.Instance.SysInfoWindowLocation = this.Location; + Settings.Instance.SysInfoWindowSize = this.Size; + } + + Program.ProcessProvider.Updated -= + new ProcessSystemProvider.ProviderUpdateOnce(ProcessProvider_Updated); + Settings.Instance.ShowOneGraphPerCPU = checkShowOneGraphPerCPU.Checked; + } - this.indicatorIO.Data1 = Program.ProcessProvider.IoReadOtherHistory[0]; - this.indicatorIO.TextValue = Utils.FormatSize(Program.ProcessProvider.IoReadOtherHistory[0]); + private void UpdateGraphs() + { + // Update the CPU indicator. + indicatorCpu.Data1 = (int)(Program.ProcessProvider.CurrentCpuKernelUsage * indicatorCpu.Maximum); + indicatorCpu.Data2 = (int)(Program.ProcessProvider.CurrentCpuUserUsage * indicatorCpu.Maximum); + indicatorCpu.TextValue = (Program.ProcessProvider.CurrentCpuUsage * 100).ToString("F2") + "%"; + + // Update the I/O indicator. + int count = plotterIO.Width / plotterIO.EffectiveMoveStep; + long maxRO = Program.ProcessProvider.IoReadOtherHistory.Take(count).Max(); + long maxW = Program.ProcessProvider.IoWriteHistory.Take(count).Max(); + if(maxRO>maxW) + indicatorIO.Maximum = maxRO; + else + indicatorIO.Maximum = maxW; + indicatorIO.Data1 = Program.ProcessProvider.IoReadOtherHistory[0]; + indicatorIO.TextValue = Utils.FormatSize(Program.ProcessProvider.IoReadOtherHistory[0]); - // Update the plotter settings. - this.plotterIO.LongData1 = Program.ProcessProvider.IoReadOtherHistory; - this.plotterIO.LongData2 = Program.ProcessProvider.IoWriteHistory; + // Update the plotter settings. + plotterIO.LongData1 = Program.ProcessProvider.IoReadOtherHistory; + plotterIO.LongData2 = Program.ProcessProvider.IoWriteHistory; - if (this.checkShowOneGraphPerCPU.Checked) - { - for (int i = 0; i < _cpuPlotters.Length; i++) - { - _cpuPlotters[i].LineColor2 = Settings.Instance.PlotterCPUKernelColor; - _cpuPlotters[i].LineColor1 = Settings.Instance.PlotterCPUUserColor; - _cpuPlotters[i].Text = ((_cpuPlotters[i].Data1[0] + _cpuPlotters[i].Data2[0]) * 100).ToString("F2") + "% (K: " + (_cpuPlotters[i].Data1[0] * 100).ToString("F2") + "%, U: " + (_cpuPlotters[i].Data2[0] * 100).ToString("F2") + "%)"; - _cpuPlotters[i].MoveGrid(); - _cpuPlotters[i].Draw(); - } - } + plotterCPU.LineColor1 = Settings.Instance.PlotterCPUKernelColor; + plotterCPU.LineColor2 = Settings.Instance.PlotterCPUUserColor; + plotterIO.LineColor1 = Settings.Instance.PlotterIOROColor; + plotterIO.LineColor2 = Settings.Instance.PlotterIOWColor; + plotterMemory.LineColor1 = Settings.Instance.PlotterMemoryPrivateColor; + plotterMemory.LineColor2 = Settings.Instance.PlotterMemoryWSColor; - this.plotterCPU.Text = ((plotterCPU.Data1[0] + plotterCPU.Data2[0]) * 100).ToString("F2") + "% (K: " + (plotterCPU.Data1[0] * 100).ToString("F2") + "%, U: " + (plotterCPU.Data2[0] * 100).ToString("F2") + "%)"; + for (int i = 0; i < _cpuPlotters.Length; i++) + { + _cpuPlotters[i].LineColor1 = Settings.Instance.PlotterCPUKernelColor; + _cpuPlotters[i].LineColor2 = Settings.Instance.PlotterCPUUserColor; + _cpuPlotters[i].Text = ((_cpuPlotters[i].Data1[0] + _cpuPlotters[i].Data2[0]) * 100).ToString("F2") + + "% (K: " + (_cpuPlotters[i].Data1[0] * 100).ToString("F2") + + "%, U: " + (_cpuPlotters[i].Data2[0] * 100).ToString("F2") + "%)"; + _cpuPlotters[i].MoveGrid(); + _cpuPlotters[i].Draw(); + } - // update the I/O graph text - this.plotterIO.Text = "R+O: " + Utils.FormatSize(plotterIO.LongData1[0]) + ", W: " + Utils.FormatSize(plotterIO.LongData2[0]); + plotterCPU.Text = ((plotterCPU.Data1[0] + plotterCPU.Data2[0]) * 100).ToString("F2") + + "% (K: " + (plotterCPU.Data1[0] * 100).ToString("F2") + + "%, U: " + (plotterCPU.Data2[0] * 100).ToString("F2") + "%)"; - this.plotterCPU.MoveGrid(); - this.plotterIO.MoveGrid(); + // update the I/O graph text + plotterIO.Text = "R+O: " + Utils.FormatSize(plotterIO.LongData1[0]) + + ", W: " + Utils.FormatSize(plotterIO.LongData2[0]); - this.plotterCPU.Draw(); - this.plotterIO.Draw(); + // update the memory graph text + plotterMemory.Text = "Commit: " + Utils.FormatSize(plotterMemory.LongData1[0]) + + ", Phys. Mem: " + Utils.FormatSize(plotterMemory.LongData2[0]); - this.trackerCommit.Draw(); - this.trackerMemory.Draw(); + plotterCPU.MoveGrid(); + plotterCPU.Draw(); + plotterIO.MoveGrid(); + plotterIO.Draw(); + plotterMemory.MoveGrid(); + plotterMemory.Draw(); + } - break; - } - } + private unsafe void GetPoolLimits(out int paged, out int nonPaged) + { + int pagedLocal, nonPagedLocal; + int retLength; + + // Read the two variables, stored in kernel-mode memory. + KProcessHacker.Instance.KphReadVirtualMemoryUnsafe( + ProcessHacker.Native.Objects.ProcessHandle.Current, + _mmSizeOfPagedPoolInBytes.ToInt32(), + &pagedLocal, + sizeof(int), + out retLength + ); + KProcessHacker.Instance.KphReadVirtualMemoryUnsafe( + ProcessHacker.Native.Objects.ProcessHandle.Current, + _mmMaximumNonPagedPoolInBytes.ToInt32(), + &nonPagedLocal, + sizeof(int), + out retLength + ); + + paged = pagedLocal; + nonPaged = nonPagedLocal; } private void UpdateInfo() { - SystemPerformanceInformation perfInfo = Program.ProcessProvider.Performance; - int retLen; - - PerformanceInformation info; - SystemCacheInformation cacheInfo; + var perfInfo = Program.ProcessProvider.Performance; + var info = new PerformanceInformation(); - Win32.GetPerformanceInfo(out info, PerformanceInformation.SizeOf); - Win32.NtQuerySystemInformation(SystemInformationClass.SystemFileCacheInformation, out cacheInfo, SystemCacheInformation.SizeOf, out retLen); + Win32.GetPerformanceInfo(out info, System.Runtime.InteropServices.Marshal.SizeOf(info)); - string physMemText = Utils.FormatSize((_pages - perfInfo.AvailablePages) * _pageSize); + SystemCacheInformation cacheInfo; + int retLen; - string commitText = Utils.FormatSize(perfInfo.CommittedPages * _pageSize); - - switch (this.tabControl1.SelectedIndex) + Win32.NtQuerySystemInformation(SystemInformationClass.SystemFileCacheInformation, + out cacheInfo, Marshal.SizeOf(typeof(SystemCacheInformation)), out retLen); + + // Totals + labelTotalsProcesses.Text = ((ulong)info.ProcessCount).ToString("N0"); + labelTotalsThreads.Text = ((ulong)info.ThreadCount).ToString("N0"); + labelTotalsHandles.Text = ((ulong)info.HandlesCount).ToString("N0"); + labelTotalsUptime.Text = Utils.FormatLongTimeSpan(Windows.GetUptime()); + + // Commit + labelCCC.Text = Utils.FormatSize((ulong)perfInfo.CommittedPages * _pageSize); + labelCCP.Text = Utils.FormatSize((ulong)perfInfo.PeakCommitment * _pageSize); + labelCCL.Text = Utils.FormatSize((ulong)perfInfo.CommitLimit * _pageSize); + + // Physical Memory + string physMemText = Utils.FormatSize((ulong)(_pages - perfInfo.AvailablePages) * _pageSize); + + labelPMC.Text = physMemText; + labelPSC.Text = Utils.FormatSize((ulong)info.SystemCache * _pageSize); + labelPMT.Text = Utils.FormatSize((ulong)_pages * _pageSize); + + // Update the physical memory indicator here because we have perfInfo available. + + indicatorPhysical.Data1 = _pages - perfInfo.AvailablePages; + indicatorPhysical.TextValue = physMemText; + + // File cache + labelCacheCurrent.Text = Utils.FormatSize(cacheInfo.SystemCacheWsSize); + labelCachePeak.Text = Utils.FormatSize(cacheInfo.SystemCacheWsPeakSize); + labelCacheMinimum.Text = Utils.FormatSize((ulong)cacheInfo.SystemCacheWsMinimum * _pageSize); + labelCacheMaximum.Text = Utils.FormatSize((ulong)cacheInfo.SystemCacheWsMaximum * _pageSize); + + // Paged/Non-paged pools + labelKPPPU.Text = Utils.FormatSize((ulong)perfInfo.ResidentPagedPoolPage * _pageSize); + labelKPPVU.Text = Utils.FormatSize((ulong)perfInfo.PagedPoolPages * _pageSize); + labelKPPA.Text = ((ulong)perfInfo.PagedPoolAllocs).ToString("N0"); + labelKPPF.Text = ((ulong)perfInfo.PagedPoolFrees).ToString("N0"); + labelKPNPU.Text = Utils.FormatSize((ulong)perfInfo.NonPagedPoolPages * _pageSize); + labelKPNPA.Text = ((ulong)perfInfo.NonPagedPoolAllocs).ToString("N0"); + labelKPNPF.Text = ((ulong)perfInfo.NonPagedPoolFrees).ToString("N0"); + + // Get the pool limits + long pagedLimit = 0; + long nonPagedLimit = 0; + + if ( + _mmSizeOfPagedPoolInBytes != IntPtr.Zero && + _mmMaximumNonPagedPoolInBytes != IntPtr.Zero && + KProcessHacker.Instance != null + ) { - case 0: - { - // Update the physical memory indicator here because we have perfInfo available. - this.indicatorPhysical.Data1 = _pages - perfInfo.AvailablePages; - this.indicatorPhysical.TextValue = physMemText; - - long memCount = (Program.ProcessProvider.System.NumberOfPhysicalPages - Program.ProcessProvider.Performance.AvailablePages) * Program.ProcessProvider.System.PageSize; - - this.trackerMemory.Text = "Phys. Mem: " + Utils.FormatSize(memCount) + " / " + Utils.FormatSize((long)info.PhysicalTotal * (long)info.PageSize); - this.trackerCommit.Text = - "Commit: " + - Utils.FormatSize(Program.ProcessProvider.Performance.CommittedPages * Program.ProcessProvider.System.PageSize) - + " / " + Utils.FormatSize(Program.ProcessProvider.Performance.CommitLimit * Program.ProcessProvider.System.PageSize); - this.indicatorCommit.Color1 = Settings.Instance.PlotterMemoryWSColor; - this.indicatorCommit.TextValue = commitText; - this.indicatorCommit.Maximum = Program.ProcessProvider.Performance.CommitLimit * Program.ProcessProvider.System.PageSize; - this.indicatorCommit.Data1 = Program.ProcessProvider.Performance.CommittedPages * Program.ProcessProvider.System.PageSize; - break; - } - case 1: - { - // Totals - this.labelTotalsProcesses.Text = info.ProcessCount.ToString("N0"); - this.labelTotalsThreads.Text = info.ThreadCount.ToString("N0"); - this.labelTotalsHandles.Text = info.HandlesCount.ToString("N0"); - this.labelTotalsUptime.Text = Utils.FormatLongTimeSpan(Windows.GetUptime()); - - // Commit - this.labelCCC.Text = commitText; - this.labelCCP.Text = Utils.FormatSize(perfInfo.PeakCommitment * _pageSize); - this.labelCCL.Text = Utils.FormatSize(perfInfo.CommitLimit * _pageSize); - - // Physical Memory - this.labelPMC.Text = physMemText; - this.labelPSC.Text = Utils.FormatSize(info.SystemCache.ToInt32() * _pageSize); - this.labelPMT.Text = Utils.FormatSize(_pages * _pageSize); - - // File cache - this.labelCacheCurrent.Text = Utils.FormatSize(cacheInfo.SystemCacheWsSize); - this.labelCachePeak.Text = Utils.FormatSize(cacheInfo.SystemCacheWsPeakSize); - this.labelCacheMinimum.Text = Utils.FormatSize(cacheInfo.SystemCacheWsMinimum.ToInt32() * _pageSize); - this.labelCacheMaximum.Text = Utils.FormatSize(cacheInfo.SystemCacheWsMaximum.ToInt32() * _pageSize); - - // Paged/Non-paged pools - this.labelKPPPU.Text = Utils.FormatSize(perfInfo.ResidentPagedPoolPage * _pageSize); - this.labelKPPVU.Text = Utils.FormatSize(perfInfo.PagedPoolPages * _pageSize); - this.labelKPPA.Text = ((ulong)perfInfo.PagedPoolAllocs).ToString("N0"); - this.labelKPPF.Text = ((ulong)perfInfo.PagedPoolFrees).ToString("N0"); - this.labelKPNPU.Text = Utils.FormatSize(perfInfo.NonPagedPoolPages * _pageSize); - this.labelKPNPA.Text = ((ulong)perfInfo.NonPagedPoolAllocs).ToString("N0"); - this.labelKPNPF.Text = ((ulong)perfInfo.NonPagedPoolFrees).ToString("N0"); - - // Get the pool limits - // long pagedLimit = 0; - // long nonPagedLimit = 0; - - //if (_mmSizeOfPagedPoolInBytes != IntPtr.Zero && _mmMaximumNonPagedPoolInBytes != IntPtr.Zero && KProcessHacker.Instance != null) - //{ - // int pl, npl; - - // this.GetPoolLimits(out pl, out npl); - // pagedLimit = pl; - // nonPagedLimit = npl; - //} - - //if (pagedLimit != 0) - //labelKPPL.Text = Utils.FormatSize(pagedLimit); - //else - this.labelKPPL.Text = "no symbols"; - - // if (nonPagedLimit != 0) - // labelKPNPL.Text = Utils.FormatSize(nonPagedLimit); - // else - this.labelKPNPL.Text = "no symbols"; - - // Page faults - this.labelPFTotal.Text = ((ulong)perfInfo.PageFaultCount).ToString("N0"); - this.labelPFCOW.Text = ((ulong)perfInfo.CopyOnWriteCount).ToString("N0"); - this.labelPFTrans.Text = ((ulong)perfInfo.TransitionCount).ToString("N0"); - this.labelPFCacheTrans.Text = ((ulong)perfInfo.CacheTransitionCount).ToString("N0"); - this.labelPFDZ.Text = ((ulong)perfInfo.CacheTransitionCount).ToString("N0"); - this.labelPFCache.Text = ((ulong)cacheInfo.SystemCacheWsFaults).ToString("N0"); - - // I/O - this.labelIOR.Text = ((ulong)perfInfo.IoReadOperationCount).ToString("N0"); - this.labelIORB.Text = Utils.FormatSize(perfInfo.IoReadTransferCount); - this.labelIOW.Text = ((ulong)perfInfo.IoWriteOperationCount).ToString("N0"); - this.labelIOWB.Text = Utils.FormatSize(perfInfo.IoWriteTransferCount); - this.labelIOO.Text = ((ulong)perfInfo.IoOtherOperationCount).ToString("N0"); - this.labelIOOB.Text = Utils.FormatSize(perfInfo.IoOtherTransferCount); - - // CPU - this.labelCPUContextSwitches.Text = ((ulong)perfInfo.ContextSwitches).ToString("N0"); - this.labelCPUInterrupts.Text = ((ulong)Program.ProcessProvider.ProcessorPerf.InterruptCount).ToString("N0"); - this.labelCPUSystemCalls.Text = ((ulong)perfInfo.SystemCalls).ToString("N0"); - break; - } + try + { + int pl, npl; + + this.GetPoolLimits(out pl, out npl); + pagedLimit = pl; + nonPagedLimit = npl; + } + catch + { } } + + if (pagedLimit != 0) + labelKPPL.Text = Utils.FormatSize(pagedLimit); + else if (KProcessHacker.Instance == null) + labelKPPL.Text = "no driver"; + else + labelKPPL.Text = "no symbols"; + + if (nonPagedLimit != 0) + labelKPNPL.Text = Utils.FormatSize(nonPagedLimit); + else if (KProcessHacker.Instance == null) + labelKPNPL.Text = "no driver"; + else + labelKPNPL.Text = "no symbols"; + + // Page faults + labelPFTotal.Text = ((ulong)perfInfo.PageFaultCount).ToString("N0"); + labelPFCOW.Text = ((ulong)perfInfo.CopyOnWriteCount).ToString("N0"); + labelPFTrans.Text = ((ulong)perfInfo.TransitionCount).ToString("N0"); + labelPFCacheTrans.Text = ((ulong)perfInfo.CacheTransitionCount).ToString("N0"); + labelPFDZ.Text = ((ulong)perfInfo.CacheTransitionCount).ToString("N0"); + labelPFCache.Text = ((ulong)cacheInfo.SystemCacheWsFaults).ToString("N0"); + + // I/O + labelIOR.Text = ((ulong)perfInfo.IoReadOperationCount).ToString("N0"); + labelIORB.Text = Utils.FormatSize(perfInfo.IoReadTransferCount); + labelIOW.Text = ((ulong)perfInfo.IoWriteOperationCount).ToString("N0"); + labelIOWB.Text = Utils.FormatSize(perfInfo.IoWriteTransferCount); + labelIOO.Text = ((ulong)perfInfo.IoOtherOperationCount).ToString("N0"); + labelIOOB.Text = Utils.FormatSize(perfInfo.IoOtherTransferCount); + + // CPU + labelCPUContextSwitches.Text = ((ulong)perfInfo.ContextSwitches).ToString("N0"); + labelCPUInterrupts.Text = ((ulong)Program.ProcessProvider.ProcessorPerf.InterruptCount).ToString("N0"); + labelCPUSystemCalls.Text = ((ulong)perfInfo.SystemCalls).ToString("N0"); } private void ProcessProvider_Updated() { - if (this.InvokeRequired) - this.BeginInvoke(new Action(this.ProcessProvider_Updated)); - else + this.BeginInvoke(new MethodInvoker(delegate { this.UpdateGraphs(); this.UpdateInfo(); - } + })); } private void checkShowOneGraphPerCPU_CheckedChanged(object sender, EventArgs e) { - if (this.checkShowOneGraphPerCPU.Checked) + if (checkShowOneGraphPerCPU.Checked) { - this.tableCPUs.Visible = true; - - //force a redraw, TODO: only required once. - this.UpdateGraphs(); + tableCPUs.Visible = true; } else { - this.tableCPUs.Visible = false; + tableCPUs.Visible = false; } } @@ -364,19 +399,5 @@ private void checkAlwaysOnTop_CheckedChanged(object sender, EventArgs e) { this.TopMost = checkAlwaysOnTop.Checked; } - - private void SysInfoWindow_FormClosing(object sender, FormClosingEventArgs e) - { - //if (this.WindowState == FormWindowState.Normal) - //Settings.Instance.SysInfoWindowBounds = this.DesktopBounds; - - Program.ProcessProvider.Updated -= this.ProcessProvider_Updated; - Settings.Instance.ShowOneGraphPerCPU = checkShowOneGraphPerCPU.Checked; - } - - private void CloseButton_Click(object sender, EventArgs e) - { - this.Close(); - } } } diff --git a/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.resx b/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.resx index 0af958e10..4283d8b1c 100644 --- a/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/SysInfoWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + AAABAAwAMDAQAAEABABoBgAAxgAAACAgEAABAAQA6AIAAC4HAAAYGBAAAQAEAOgBAAAWCgAAEBAQAAEA diff --git a/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.Designer.cs index 32027a993..4706d16e3 100644 --- a/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.Designer.cs @@ -1,6 +1,4 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { partial class TerminatorWindow { @@ -33,9 +31,9 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TerminatorWindow)); this.labelProgress = new System.Windows.Forms.Label(); - this.listTests = new ProcessHacker.Components.ExtendedListView(); - this.columnID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listTests = new System.Windows.Forms.ListView(); + this.columnID = new System.Windows.Forms.ColumnHeader(); + this.columnDescription = new System.Windows.Forms.ColumnHeader(); this.imageList = new System.Windows.Forms.ImageList(this.components); this.buttonRun = new System.Windows.Forms.Button(); this.SuspendLayout(); @@ -45,7 +43,7 @@ private void InitializeComponent() this.labelProgress.AutoSize = true; this.labelProgress.Location = new System.Drawing.Point(12, 9); this.labelProgress.Name = "labelProgress"; - this.labelProgress.Size = new System.Drawing.Size(55, 13); + this.labelProgress.Size = new System.Drawing.Size(53, 13); this.labelProgress.TabIndex = 0; this.labelProgress.Text = "Message."; // @@ -54,7 +52,6 @@ private void InitializeComponent() this.listTests.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnID, this.columnDescription}); - this.listTests.DoubleClickChecks = true; this.listTests.FullRowSelect = true; this.listTests.Location = new System.Drawing.Point(12, 38); this.listTests.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); @@ -100,7 +97,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(466, 437); this.Controls.Add(this.buttonRun); this.Controls.Add(this.listTests); @@ -122,7 +118,7 @@ private void InitializeComponent() #endregion private System.Windows.Forms.Label labelProgress; - private ExtendedListView listTests; + private System.Windows.Forms.ListView listTests; private System.Windows.Forms.Button buttonRun; private System.Windows.Forms.ColumnHeader columnDescription; private System.Windows.Forms.ImageList imageList; diff --git a/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.cs b/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.cs index 13a9aa32d..f80860b81 100644 --- a/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.cs @@ -33,13 +33,12 @@ namespace ProcessHacker { public partial class TerminatorWindow : Form { - private readonly int _pid; - private readonly List _tests = new List(); + private int _pid; + private List _tests = new List(); public TerminatorWindow(int PID) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); @@ -63,7 +62,7 @@ public TerminatorWindow(int PID) this.AddTest("TD1", "Debugs the process and closes the debug object"); this.AddTest("TP3", "Terminates the process in kernel-mode (if possible)"); this.AddTest("TT3", "Terminates the process' threads in kernel-mode (if possible)"); - if (KProcessHacker2.Instance != null) + if (KProcessHacker.Instance != null) this.AddTest("TT4", "Terminates the process' threads using a dangerous kernel-mode method"); this.AddTest("M1", "Writes garbage to the process' memory regions"); this.AddTest("M2", "Sets the page protection of the process' memory regions to PAGE_NOACCESS"); @@ -162,13 +161,15 @@ private void M1() this.M1Internal(); } - private void M1Internal() + private unsafe void M1Internal() { using (MemoryAlloc alloc = new MemoryAlloc(0x1000)) { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | Program.MinProcessWriteMemoryRights)) + using (ProcessHandle phandle = new ProcessHandle(_pid, + ProcessAccess.QueryInformation | + Program.MinProcessWriteMemoryRights)) { - phandle.EnumMemory(info => + phandle.EnumMemory((info) => { for (int i = 0; i < info.RegionSize.ToInt32(); i += 0x1000) { @@ -188,9 +189,10 @@ private void M1Internal() private void M2() { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | ProcessAccess.VmOperation)) + using (ProcessHandle phandle = new ProcessHandle(_pid, + ProcessAccess.QueryInformation | ProcessAccess.VmOperation)) { - phandle.EnumMemory(info => + phandle.EnumMemory((info) => { phandle.ProtectMemory(info.BaseAddress, info.RegionSize.ToInt32(), MemoryProtection.NoAccess); return true; @@ -200,38 +202,43 @@ private void M2() private void TD1() { - using (DebugObjectHandle dhandle = DebugObjectHandle.Create(DebugObjectAccess.ProcessAssign, DebugObjectFlags.KillOnClose)) - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.SuspendResume)) + using (var dhandle = + DebugObjectHandle.Create(DebugObjectAccess.ProcessAssign, DebugObjectFlags.KillOnClose)) { - phandle.Debug(dhandle); + using (var phandle = new ProcessHandle(_pid, ProcessAccess.SuspendResume)) + phandle.Debug(dhandle); } - } private void TJ1() { - //if (KProcessHacker.Instance != null) - //{ - // try - // { - // using (ProcessHandle phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) - // { - // JobObjectHandle jhandle = phandle.GetJobObject(JobObjectAccess.Query | JobObjectAccess.Terminate); - - // // Make sure we're not terminating more than one process - // if (jhandle.ProcessIdList.Length == 1) - // { - // jhandle.Terminate(); - // } - // } - // } - // catch - // { } - //} - - using (JobObjectHandle jhandle = JobObjectHandle.Create(JobObjectAccess.AssignProcess | JobObjectAccess.Terminate)) + if (KProcessHacker.Instance != null) { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.SetQuota | ProcessAccess.Terminate)) + try + { + using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights)) + { + var jhandle = phandle.GetJobObject(JobObjectAccess.Query | JobObjectAccess.Terminate); + + if (jhandle != null) + { + // Make sure we're not terminating more than one process + if (jhandle.GetProcessIdList().Length == 1) + { + jhandle.Terminate(); + return; + } + } + } + } + catch + { } + } + + using (var jhandle = JobObjectHandle.Create(JobObjectAccess.AssignProcess | JobObjectAccess.Terminate)) + { + using (ProcessHandle phandle = + new ProcessHandle(_pid, ProcessAccess.SetQuota | ProcessAccess.Terminate)) { phandle.AssignToJobObject(jhandle); } @@ -261,7 +268,7 @@ private void TP1a() { phandle = phandle.GetNextProcess(Program.MinProcessQueryRights | ProcessAccess.Terminate); - if (phandle.ProcessId == _pid) + if (phandle.GetProcessId() == _pid) { found = true; break; @@ -277,7 +284,8 @@ private void TP1a() private void TP2() { - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.CreateThread | ProcessAccess.VmOperation | ProcessAccess.VmWrite)) + using (ProcessHandle phandle = new ProcessHandle(_pid, + ProcessAccess.CreateThread | ProcessAccess.VmOperation | ProcessAccess.VmWrite)) { if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) { @@ -378,20 +386,20 @@ private void TT4() private void W1() { - WindowHandle.Enumerate(window => - { - if (window.ClientId.ProcessId == _pid) - window.PostMessage(WindowMessage.Destroy, 0, 0); + WindowHandle.Enumerate((window) => + { + if (window.GetClientId().ProcessId == _pid) + window.PostMessage(WindowMessage.Destroy, 0, 0); - return true; - }); + return true; + }); } private void W2() { - WindowHandle.Enumerate(window => + WindowHandle.Enumerate((window) => { - if (window.ClientId.ProcessId == _pid) + if (window.GetClientId().ProcessId == _pid) window.PostMessage(WindowMessage.Quit, 0, 0); return true; diff --git a/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.resx b/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.resx index b7fe4b4d4..009bf9b6f 100644 --- a/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/TerminatorWindow.resx @@ -112,46 +112,46 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAi - BwAAAk1TRnQBSQFMAgEBAgEAAQwBAAEMAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA - AwABEAMAAQEBAAEgBgABEP8AJwADBwEKAwUBBzAAAyoBQQMGAQgYAAMGAQgDKgFBnAADBwEKAS8BgwE1 - Af8BMgFkATIB+wMFAQcoAAMqAUEBRwFEAfIB/wJAAdYB/QMGAQgQAAMGAQgBKwEqAcUB/AEpAScB6gH/ - AyoBQZQAAwcBCgE4AY4BPwH/AUwBowFUAf8BRwGfAU8B/wEyAXwBOAH+AwYBCCAAAyoBQQFQAU4B9QH/ - AVsBWQH6Af8BUAFNAfYB/wE5ATgBywH8AwYBCAgAAwYBCAIrAccB/AE5ATcB8QH/AUQBQgH2Af8BKQEn - AeoB/wMqAUGMAAMHAQoBQQGaAUkB/wFTAawBXAH/AW8BygGCAf8BbAHIAXYB/wFJAaABUQH/ATMBfQE5 - Af4DBgEIHAADHgErAVMBUAH2Af8BXQFaAfoB/wFpAWgC/wFRAU4B9gH/ATkBOAHLAfwDBgEIAwYBCAEu - ASsByAH8AT8BPQHyAf8BWwFaAv8BQgFAAfQB/wEnASUB6QH/Ax4BK4gAAwcBCgFJAaYBUgH/AVsBtQFl - Af8BdgHOAYkB/wFzAcwBhwH/AW4BygGBAf8BbgHJAYEB/wFKAaIBUgH/ATQBfgE6Af4DBgEIHAADHgEr - AVMBUQH2Af8BXgFbAfoB/wFsAWkC/wFSAVAB9gH/AToBOQHLAfwCQAHVAf0BSAFFAfQB/wFgAV8C/wFI - AUYB9QH/AS4BLAHrAf8DHgEriAADBwEJAVEBsAFbAf8BYwG9AW4B/wGEAdIBkAH/AXIByQGFAf8BWAGy - AWIB/wFbAbQBZQH/AXAByQGDAf8BcAHLAYIB/wFLAaMBVAH/ATwBcQFAAf0DBgEIHAADHgErAVQBUgH2 - Af8BXwFcAfoB/wFsAWoC/wFrAWgC/wFoAWYC/wFmAWQC/wFPAU0B9wH/ATcBNQHuAf8DHgErjAADLQFG - AVoBawFhAeQBcQHJAYYB/wGAAc4BjQH/AUIBjwFPAfwDQAFvA0oBiwFUAa0BXwH/AXQBzAGGAf8BcQHL - AYUB/wFMAaQBVQH/AS4BdwE0AfwDBgEIHAADHgErAVUBUwH3Af8BcQFuAv8BUQFOAv8BTwFMAv8BagFo - Av8BQAE+AfAB/wMeASuUAAMoATwBYQFzAWEB5gFlAcABcQH/A0ABbwgAAUwCTQGRAVYBrgFgAf8BdQHN - AYkB/wF0Ac0BhwH/AU4BpQFXAf8BLwF4ATUB/AMGAQgYAAMGAQgBUQFQAd8B/QF1AXEC/wFWAVMC/wFT - AVAC/wFuAWwC/wJAAdgB/QMGAQiYAAMsAUMDOwFlEAABTAJNAZEBVwGvAWEB/wF3Ac4BigH/AXYBzgGJ - Af8BTwGmAVgB/wEwAXgBNgH8AwYBCBAAAwYBCAFeAVsB0gH8AWgBZQH7Af8BgAF2Av8BdgFzAv8BdAFx - Av8BcQFvAv8BVgFUAfcB/wE8AToBzAH8AwYBCLAAAUwCTQGRAVgBsAFiAf8BgQHPAY0B/wF3Ac8BiwH/ - AVABpwFZAf8BMQGFATgB/wMGAQgIAAMGAQgBZgFjAdUB/AFvAWwB/QH/AYYBggL/AW4BawH8Af8BXAFa - AfgB/wFYAVUB9wH/AWUBYgH6Af8BcwFxAv8BWAFVAfcB/wE8ATsBzAH8AwYBCLAAAUwCTQGRAVoBsgFk - Af8BggHRAY8B/wFyAcgBhQH/AU8BpgFYAf8DRAF7BAADBgEIAWUBYgHnAf0BdQFyAf4B/wGKAYcC/wF0 - AXEB/QH/AWQBYQH7Af8DHgErAx4BKwFZAVYB+AH/AWYBZAH6Af8BdQFyAv8BWQFXAfcB/wE9ATsBzQH8 - AwQBBbAAA00BkQFbAbMBZQH/AVcBrwFhAf8DRAF5CAADFgEfAXIBbwL/AYEBdgL/AYEBdgH+Af8BbAFp - Af0B/wMeASsIAAMeASsBWgFXAfgB/wFnAWUB+wH/AXYBdAL/AVoBVwH4Af8DQAFvAwEBArAAA00BkQNG - AX8QAAMWAR8BcgFvAv8BcQFuAf4B/wMeASsQAAMeASsBXAFZAfgB/wFiAWAB+QH/AVMBUgFTAagDHQEp + BwAAAk1TRnQBSQFMAgEBAgEAAQQBAAEEAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + AwABEAMAAQEBAAEgBgABEP8AJwADBwEKAwUBBzAAAyoBQQMGAQgYAAMGAQgDKgFBnAADBwEKATABgwE2 + Af8BMgFnATIB+wMFAQcoAAMqAUEBSAFFAfIB/wJAAdkB/QMGAQgQAAMGAQgBKwEpAcgB/AEqASgB6gH/ + AyoBQZQAAwcBCgE5AY4BQAH/AU0BowFVAf8BSAGfAVAB/wEyAXwBOAH+AwYBCCAAAyoBQQFRAU8B9QH/ + AVwBWgH6Af8BUQFOAfYB/wE6ATkBzgH8AwYBCAgAAwYBCAIrAcoB/AE6ATgB8QH/AUUBQwH2Af8BKgEo + AeoB/wMqAUGMAAMHAQoBQgGaAUoB/wFUAawBXQH/AXABygGCAf8BbQHIAXcB/wFKAaABUgH/ATMBfQE5 + Af4DBgEIHAADHgErAVQBUQH2Af8BXgFbAfoB/wFqAWkC/wFSAU8B9gH/AToBOQHOAfwDBgEIAwYBCAEv + ASwBywH8AUABPgHyAf8BXAFbAv8BQwFBAfQB/wEoASYB6QH/Ax4BK4gAAwcBCgFKAaYBUwH/AVwBtQFm + Af8BdwHOAYkB/wF0AcwBhwH/AW8BygGBAf8BbwHJAYEB/wFLAaIBUwH/ATQBfgE6Af4DBgEIHAADHgEr + AVQBUgH2Af8BXwFcAfoB/wFtAWoC/wFTAVEB9gH/ATsBOgHOAfwCQAHYAf0BSQFGAfQB/wFhAWAC/wFJ + AUcB9QH/AS8BLQHrAf8DHgEriAADBwEJAVIBsAFcAf8BZAG9AW8B/wGEAdIBkAH/AXMByQGFAf8BWQGy + AWMB/wFcAbQBZgH/AXEByQGDAf8BcQHLAYIB/wFMAaMBVQH/ATsBcwFAAf0DBgEIHAADHgErAVUBUwH2 + Af8BYAFdAfoB/wFtAWsC/wFsAWkC/wFpAWcC/wFnAWUC/wFQAU4B9wH/ATgBNgHuAf8DHgErjAADLQFG + AVoBcAFhAeQBcgHJAYYB/wGAAc4BjQH/AUQBkgFRAfwDQAFvA0oBiwFVAa0BYAH/AXUBzAGGAf8BcgHL + AYUB/wFNAaQBVgH/AS8BeAE1AfwDBgEIHAADHgErAVYBVAH3Af8BcgFvAv8BUgFPAv8BUAFNAv8BawFp + Av8BQQE/AfAB/wMeASuUAAMoATwBYQF4AWEB5gFmAcABcgH/A0ABbwgAAUwCTQGRAVcBrgFhAf8BdgHN + AYkB/wF1Ac0BhwH/AU8BpQFYAf8BMAF5ATYB/AMGAQgYAAMGAQgBUgFRAeIB/QF2AXIC/wFXAVQC/wFU + AVEC/wFvAW0C/wJAAdsB/QMGAQiYAAMsAUMDOwFlEAABTAJNAZEBWAGvAWIB/wF4Ac4BigH/AXcBzgGJ + Af8BUAGmAVkB/wExAXkBNwH8AwYBCBAAAwYBCAFfAVwB1wH8AWkBZgH7Af8BgAF3Av8BdwF0Av8BdQFy + Av8BcgFwAv8BVwFVAfcB/wE9ATsBzwH8AwYBCLAAAUwCTQGRAVkBsAFjAf8BgQHPAY0B/wF4Ac8BiwH/ + AVEBpwFaAf8BMgGFATkB/wMGAQgIAAMGAQgBZwFkAdoB/AFwAW0B/QH/AYYBggL/AW8BbAH8Af8BXQFb + AfgB/wFZAVYB9wH/AWYBYwH6Af8BdAFyAv8BWQFWAfcB/wE9ATwBzwH8AwYBCLAAAUwCTQGRAVsBsgFl + Af8BggHRAY8B/wFzAcgBhQH/AVABpgFZAf8DRAF7BAADBgEIAWcBZAHqAf0BdgFzAf4B/wGKAYcC/wF1 + AXIB/QH/AWUBYgH7Af8DHgErAx4BKwFaAVcB+AH/AWcBZQH6Af8BdgFzAv8BWgFYAfcB/wE+ATwB0AH8 + AwQBBbAAA00BkQFcAbMBZgH/AVgBrwFiAf8DRAF5CAADFgEfAXMBcAL/AYEBdwL/AYEBdwH+Af8BbQFq + Af0B/wMeASsIAAMeASsBWwFYAfgB/wFoAWYB+wH/AXcBdQL/AVsBWAH4Af8DQAFvAwEBArAAA00BkQNG + AX8QAAMWAR8BcwFwAv8BcgFvAf4B/wMeASsQAAMeASsBXQFaAfgB/wFjAWEB+QH/AVMBUgFTAagDHQEp 0AADFgEfAx4BKxgAAx4BKwNAAW8DKQE++AADBwEKjAABQgFNAT4HAAE+AwABKAMAAUADAAEQAwABAQEA AQEFAAGAFwAD/wEABP8EAAH5Af8C5wQAAfAB/wLDBAAB4AF/AoEEAAHAAT8BgAEBBAABgAEfAcABAwUA AQ8B4AEHBQABBwHwAQ8EAAGGAQMB8AEPBAABzwEBAeABBwQAAf8BgAHAAQMEAAH/AcABgAEBBAAB/wHh diff --git a/1.x/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs index e0b946241..a860bf26c 100644 --- a/1.x/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs @@ -1,8 +1,6 @@ -using ProcessHacker.Components; - -namespace ProcessHacker +namespace ProcessHacker { - sealed partial class ThreadWindow + partial class ThreadWindow { /// /// Required designer variable. @@ -36,19 +34,27 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ThreadWindow)); + this.vistaMenu = new wyDay.Controls.VistaMenu(this.components); this.fileModule = new ProcessHacker.Components.FileNameBox(); this.label1 = new System.Windows.Forms.Label(); this.buttonWalk = new System.Windows.Forms.Button(); - this.listViewCallStack = new ProcessHacker.Components.ExtendedListView(); - this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listViewCallStack = new System.Windows.Forms.ListView(); + this.columnHeader3 = new System.Windows.Forms.ColumnHeader(); + this.columnHeader4 = new System.Windows.Forms.ColumnHeader(); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).BeginInit(); this.SuspendLayout(); // + // vistaMenu + // + this.vistaMenu.ContainerControl = this; + this.vistaMenu.DelaySetImageCalls = false; + // // fileModule // - this.fileModule.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.fileModule.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.fileModule.Location = new System.Drawing.Point(63, 347); this.fileModule.Name = "fileModule"; this.fileModule.ReadOnly = true; @@ -61,7 +67,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 353); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(50, 13); + this.label1.Size = new System.Drawing.Size(45, 13); this.label1.TabIndex = 8; this.label1.Text = "Module:"; // @@ -79,13 +85,12 @@ private void InitializeComponent() // // listViewCallStack // - this.listViewCallStack.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.listViewCallStack.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.listViewCallStack.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader3, this.columnHeader4}); - this.listViewCallStack.DoubleClickChecks = true; this.listViewCallStack.FullRowSelect = true; this.listViewCallStack.HideSelection = false; this.listViewCallStack.Location = new System.Drawing.Point(12, 12); @@ -111,7 +116,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(399, 383); this.Controls.Add(this.fileModule); this.Controls.Add(this.label1); @@ -123,8 +127,9 @@ private void InitializeComponent() this.Name = "ThreadWindow"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Thread"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ThreadWindow_FormClosing); this.Load += new System.EventHandler(this.ThreadWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ThreadWindow_FormClosing); + ((System.ComponentModel.ISupportInitialize)(this.vistaMenu)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -132,10 +137,11 @@ private void InitializeComponent() #endregion + private wyDay.Controls.VistaMenu vistaMenu; private ProcessHacker.Components.FileNameBox fileModule; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button buttonWalk; - private ExtendedListView listViewCallStack; + private System.Windows.Forms.ListView listViewCallStack; private System.Windows.Forms.ColumnHeader columnHeader3; private System.Windows.Forms.ColumnHeader columnHeader4; } diff --git a/1.x/trunk/ProcessHacker/Forms/ThreadWindow.cs b/1.x/trunk/ProcessHacker/Forms/ThreadWindow.cs index 9246866a7..c3f24ca5e 100644 --- a/1.x/trunk/ProcessHacker/Forms/ThreadWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/ThreadWindow.cs @@ -21,6 +21,7 @@ */ using System; +using System.Reflection; using System.Windows.Forms; using ProcessHacker.Common; using ProcessHacker.Native; @@ -31,13 +32,13 @@ namespace ProcessHacker { - public sealed partial class ThreadWindow : Form + public partial class ThreadWindow : Form { - private readonly int _pid; - private readonly int _tid; - private readonly ProcessHandle _phandle; - private readonly bool _processHandleOwned = true; - private readonly ThreadHandle _thandle; + private int _pid; + private int _tid; + private ProcessHandle _phandle; + private bool _processHandleOwned = true; + private ThreadHandle _thandle; private SymbolProvider _symbols; public const string DisplayFormat = "0x{0:x}"; @@ -62,6 +63,11 @@ public ThreadWindow(int PID, int TID, SymbolProvider symbols, ProcessHandle proc this.Text = Program.ProcessProvider.Dictionary[_pid].Name + " (PID " + _pid.ToString() + ") - Thread " + _tid.ToString(); + PropertyInfo property = typeof(ListView).GetProperty("DoubleBuffered", + BindingFlags.NonPublic | BindingFlags.Instance); + + property.SetValue(listViewCallStack, true, null); + listViewCallStack.ContextMenu = listViewCallStack.GetCopyMenu(); try @@ -73,7 +79,23 @@ public ThreadWindow(int PID, int TID, SymbolProvider symbols, ProcessHandle proc } else { - _phandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | ProcessAccess.VmRead); + try + { + _phandle = new ProcessHandle(_pid, + ProcessAccess.QueryInformation | ProcessAccess.VmRead + ); + } + catch + { + if (KProcessHacker.Instance != null) + { + _phandle = new ProcessHandle(_pid, Program.MinProcessReadMemoryRights); + } + else + { + throw; + } + } } } catch (Exception ex) @@ -87,7 +109,23 @@ public ThreadWindow(int PID, int TID, SymbolProvider symbols, ProcessHandle proc try { - _thandle = new ThreadHandle(_tid, ThreadAccess.GetContext | ThreadAccess.SuspendResume); + try + { + _thandle = new ThreadHandle(_tid, ThreadAccess.GetContext | ThreadAccess.SuspendResume); + } + catch + { + if (KProcessHacker.Instance != null) + { + _thandle = new ThreadHandle(_tid, + Program.MinThreadQueryRights | ThreadAccess.SuspendResume + ); + } + else + { + throw; + } + } } catch (Exception ex) { @@ -101,6 +139,7 @@ public ThreadWindow(int PID, int TID, SymbolProvider symbols, ProcessHandle proc private void ThreadWindow_Load(object sender, EventArgs e) { + listViewCallStack.SetTheme("explorer"); listViewCallStack.AddShortcuts(); this.Size = Settings.Instance.ThreadWindowSize; @@ -139,9 +178,9 @@ private void WalkCallStack() try { // Process the kernel-mode stack (if KPH is present). - //if (KProcessHacker.Instance != null) + if (KProcessHacker.Instance != null) { - //this.WalkKernelStack(); + this.WalkKernelStack(); } // Process the user-mode stack. @@ -150,7 +189,7 @@ private void WalkCallStack() _thandle.WalkStack(_phandle, this.WalkStackCallback); - if (OSVersion.Architecture == OSArch.Amd64 && _phandle.IsWow64) + if (OSVersion.Architecture == OSArch.Amd64 && _phandle.IsWow64()) { _thandle.WalkStack(_phandle, this.WalkStackCallback, OSArch.I386); } @@ -183,11 +222,12 @@ private void WalkKernelStack() try { - ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem(new[] - { - Utils.FormatAddress(address), - _symbols.GetSymbolFromAddress(address) - })); + ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem( + new string[] + { + Utils.FormatAddress(address), + _symbols.GetSymbolFromAddress(address) + })); newItem.Tag = address; } @@ -216,11 +256,12 @@ private bool WalkStackCallback(ThreadStackFrame stackFrame) try { - ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem(new[] - { - Utils.FormatAddress(address), - _symbols.GetSymbolFromAddress(address) - })); + ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem( + new string[] + { + Utils.FormatAddress(address), + _symbols.GetSymbolFromAddress(address) + })); newItem.Tag = address; @@ -243,8 +284,7 @@ private bool WalkStackCallback(ThreadStackFrame stackFrame) newItem.ToolTipText += "\nFile: " + fileAndLine; } catch - { - } + { } } catch (Exception ex2) { @@ -255,11 +295,10 @@ private bool WalkStackCallback(ThreadStackFrame stackFrame) { Logging.Log(ex); - ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem(new string[] - { - Utils.FormatAddress(address), - "???" - })); + ListViewItem newItem = listViewCallStack.Items.Add(new ListViewItem(new string[] { + Utils.FormatAddress(address), + "???" + })); newItem.Tag = address; } diff --git a/1.x/trunk/ProcessHacker/Forms/ThreadWindow.resx b/1.x/trunk/ProcessHacker/Forms/ThreadWindow.resx index cad68d580..b98da9944 100644 --- a/1.x/trunk/ProcessHacker/Forms/ThreadWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/ThreadWindow.resx @@ -112,12 +112,15 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + 17, 17 + + AAABAAMAEBAQAAEABAAoAQAANgAAABAQAAABAAgAaAUAAF4BAAAQEAAAAQAgAGgEAADGBgAAKAAAABAA diff --git a/1.x/trunk/ProcessHacker/Forms/TokenWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/TokenWindow.Designer.cs index fb018da9d..74f377046 100644 --- a/1.x/trunk/ProcessHacker/Forms/TokenWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/TokenWindow.Designer.cs @@ -39,7 +39,7 @@ private void InitializeComponent() // this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonClose.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonClose.Location = new System.Drawing.Point(378, 377); + this.buttonClose.Location = new System.Drawing.Point(378, 397); this.buttonClose.Name = "buttonClose"; this.buttonClose.Size = new System.Drawing.Size(75, 23); this.buttonClose.TabIndex = 1; @@ -49,20 +49,19 @@ private void InitializeComponent() // // panelToken // - this.panelToken.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.panelToken.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.panelToken.Location = new System.Drawing.Point(12, 12); this.panelToken.Name = "panelToken"; - this.panelToken.Size = new System.Drawing.Size(441, 359); + this.panelToken.Size = new System.Drawing.Size(441, 379); this.panelToken.TabIndex = 2; // // TokenWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(465, 412); + this.ClientSize = new System.Drawing.Size(465, 432); this.Controls.Add(this.panelToken); this.Controls.Add(this.buttonClose); this.MaximizeBox = false; @@ -72,8 +71,8 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Token"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TokenWindow_FormClosing); this.Load += new System.EventHandler(this.TokenWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TokenWindow_FormClosing); this.ResumeLayout(false); } diff --git a/1.x/trunk/ProcessHacker/Forms/TokenWindow.cs b/1.x/trunk/ProcessHacker/Forms/TokenWindow.cs index 38ffd903c..6ca7336c1 100644 --- a/1.x/trunk/ProcessHacker/Forms/TokenWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/TokenWindow.cs @@ -29,7 +29,7 @@ namespace ProcessHacker { public partial class TokenWindow : Form { - readonly TokenProperties _tokenProps; + TokenProperties _tokenProps; public TokenWindow(IWithToken obj) { diff --git a/1.x/trunk/ProcessHacker/Forms/TokenWindow.resx b/1.x/trunk/ProcessHacker/Forms/TokenWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/TokenWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/TokenWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.Designer.cs deleted file mode 100644 index c7a0f8d93..000000000 --- a/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.Designer.cs +++ /dev/null @@ -1,112 +0,0 @@ -namespace ProcessHacker.Native.Ui -{ - partial class HandlePropertiesWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.tabControl = new System.Windows.Forms.TabControl(); - this.tabDetails = new System.Windows.Forms.TabPage(); - this.handleDetails1 = new ProcessHacker.Components.HandleDetails(); - this.buttonClose = new System.Windows.Forms.Button(); - this.tabControl.SuspendLayout(); - this.tabDetails.SuspendLayout(); - this.SuspendLayout(); - // - // tabControl - // - this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tabControl.Controls.Add(this.tabDetails); - this.tabControl.Location = new System.Drawing.Point(12, 12); - this.tabControl.Name = "tabControl"; - this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(370, 382); - this.tabControl.TabIndex = 0; - // - // tabDetails - // - this.tabDetails.Controls.Add(this.handleDetails1); - this.tabDetails.Location = new System.Drawing.Point(4, 22); - this.tabDetails.Name = "tabDetails"; - this.tabDetails.Padding = new System.Windows.Forms.Padding(3); - this.tabDetails.Size = new System.Drawing.Size(362, 356); - this.tabDetails.TabIndex = 0; - this.tabDetails.Text = "Details"; - this.tabDetails.UseVisualStyleBackColor = true; - // - // handleDetails1 - // - this.handleDetails1.BackColor = System.Drawing.Color.White; - this.handleDetails1.Dock = System.Windows.Forms.DockStyle.Fill; - this.handleDetails1.Location = new System.Drawing.Point(3, 3); - this.handleDetails1.Name = "handleDetails1"; - this.handleDetails1.Padding = new System.Windows.Forms.Padding(3); - this.handleDetails1.Size = new System.Drawing.Size(356, 350); - this.handleDetails1.TabIndex = 0; - // - // buttonClose - // - this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonClose.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.buttonClose.Location = new System.Drawing.Point(307, 400); - this.buttonClose.Name = "buttonClose"; - this.buttonClose.Size = new System.Drawing.Size(75, 23); - this.buttonClose.TabIndex = 1; - this.buttonClose.Text = "Close"; - this.buttonClose.UseVisualStyleBackColor = true; - this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click); - // - // HandlePropertiesWindow - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(394, 435); - this.Controls.Add(this.buttonClose); - this.Controls.Add(this.tabControl); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "HandlePropertiesWindow"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Handle Properties"; - this.tabControl.ResumeLayout(false); - this.tabDetails.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TabControl tabControl; - private System.Windows.Forms.TabPage tabDetails; - private System.Windows.Forms.Button buttonClose; - public Components.HandleDetails handleDetails1; - } -} \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.cs b/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.cs deleted file mode 100644 index 67ca4abd7..000000000 --- a/1.x/trunk/ProcessHacker/Forms/Ui/HandlePropertiesWindow.cs +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Process Hacker - - * handle properties window - * - * Copyright (C) 2009 wj32 - * - * This file is part of Process Hacker. - * - * Process Hacker is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Process Hacker is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Process Hacker. If not, see . - */ - -using System; -using System.Windows.Forms; -using ProcessHacker.Native.Api; - -namespace ProcessHacker.Native.Ui -{ - public partial class HandlePropertiesWindow : Form - { - public HandlePropertiesWindow(SystemHandleEntry handle) - { - InitializeComponent(); - - this.KeyPreview = true; - this.KeyDown += (sender, e) => - { - if (e.KeyCode == Keys.Escape) - { - this.Close(); - e.Handled = true; - } - }; - - this.handleDetails1.ObjectHandle = handle; - } - - public void Init() - { - this.handleDetails1.Init(); - } - - private void buttonClose_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void buttonPermissions_Click(object sender, EventArgs e) - { - //if (_objectHandle != null) - //{ - // try - // { - // SecurityEditor.EditSecurity( - // this, - // SecurityEditor.GetSecurableWrapper(_objectHandle), - // _name, - // NativeTypeFactory.GetAccessEntries(NativeTypeFactory.GetObjectType(_typeName)) - // ); - // } - // catch (Exception ex) - // { - // MessageBox.Show("Unable to edit security: " + ex.Message, "Security Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); - // } - //} - } - } -} diff --git a/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.Designer.cs index 4a8012e4c..21ef7a944 100644 --- a/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.Designer.cs @@ -146,8 +146,8 @@ private void InitializeComponent() this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Process Hacker Update"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UpdaterDownloadWindow_FormClosing); this.Load += new System.EventHandler(this.UpdaterDownload_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UpdaterDownloadWindow_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); this.ResumeLayout(false); diff --git a/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs b/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs index f4622ccc1..a59752344 100644 --- a/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.cs @@ -36,16 +36,15 @@ namespace ProcessHacker { public partial class UpdaterDownloadWindow : Form { - private readonly Updater.UpdateItem _updateItem; + private Updater.UpdateItem _updateItem; private WebClient _webClient; private string _fileName; private ThreadTask _verifyTask; - private bool _redirected; + private bool _redirected = false; public UpdaterDownloadWindow(Updater.UpdateItem updateItem) { InitializeComponent(); - this.AddEscapeToClose(); this.SetTopMost(); @@ -54,19 +53,21 @@ public UpdaterDownloadWindow(Updater.UpdateItem updateItem) private void UpdaterDownload_Load(object sender, EventArgs e) { - string currentVersion = Application.ProductVersion; - string version = this._updateItem.Version.Major + "." + this._updateItem.Version.Minor; - + string currentVersion; + string version; + + currentVersion = Application.ProductVersion; + version = _updateItem.Version.Major + "." + _updateItem.Version.Minor; _fileName = Path.GetTempPath() + "processhacker-" + version + "-setup.exe"; labelTitle.Text = "Downloading: Process Hacker " + version; labelReleased.Text = "Released: " + _updateItem.Date.ToString(); _webClient = new WebClient(); - _webClient.DownloadProgressChanged += this.webClient_DownloadProgressChanged; - _webClient.DownloadFileCompleted += this.webClient_DownloadFileCompleted; + _webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged); + _webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted); _webClient.Headers.Add("User-Agent", "PH/" + currentVersion + " (compatible; PH " + - currentVersion + "; PH " + currentVersion + "; .NET CLR " + Environment.Version + ";)"); + currentVersion + "; PH " + currentVersion + "; .NET CLR " + Environment.Version.ToString() + ";)"); try { @@ -218,17 +219,15 @@ private void verifyTask_RunTask(object param, ref object result) if (this.IsHandleCreated) { - long read = totalBytesRead; - this.BeginInvoke(new MethodInvoker(() => - { - int value = (int)((double)read * 100 / size); - - if (value >= this.progressDownload.Minimum && value <= this.progressDownload.Maximum) { - this.progressDownload.Value = value; - } - })); + int value = (int)((double)totalBytesRead * 100 / size); + + if (value >= this.progressDownload.Minimum && value <= this.progressDownload.Maximum) + { + this.progressDownload.Value = value; + } + })); } } while (bytesRead != 0); @@ -289,8 +288,8 @@ private void buttonInstall_Click(object sender, EventArgs e) { Program.StartProgramAdmin( _fileName, - string.Empty, - () => success = true, + "", + new MethodInvoker(() => success = true), ShowWindowType.Normal, this.Handle ); @@ -317,7 +316,7 @@ private void buttonInstall_Click(object sender, EventArgs e) // User canceled. Re-open the mutex. try { - Program.GlobalMutex = new Native.Threading.Mutant(Program.GlobalMutexName); + Program.GlobalMutex = new ProcessHacker.Native.Threading.Mutant(Program.GlobalMutexName); } catch (Exception ex) { diff --git a/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.resx b/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.resx index 769f0e996..21f86819c 100644 --- a/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/UpdaterDownloadWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + iVBORw0KGgoAAAANSUhEUgAAAHgAAAAeCAMAAADQFyqnAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 diff --git a/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.Designer.cs index df6c5cdb7..066fc2e07 100644 --- a/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.Designer.cs @@ -74,10 +74,10 @@ private void InitializeComponent() this.textNewProtection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.textNewProtection.Location = new System.Drawing.Point(167, 186); this.textNewProtection.Name = "textNewProtection"; - this.textNewProtection.Size = new System.Drawing.Size(82, 22); + this.textNewProtection.Size = new System.Drawing.Size(82, 20); this.textNewProtection.TabIndex = 7; - this.textNewProtection.Enter += new System.EventHandler(this.textNewProtection_Enter); this.textNewProtection.Leave += new System.EventHandler(this.textNewProtection_Leave); + this.textNewProtection.Enter += new System.EventHandler(this.textNewProtection_Enter); // // labelNewValue // @@ -85,17 +85,14 @@ private void InitializeComponent() this.labelNewValue.AutoSize = true; this.labelNewValue.Location = new System.Drawing.Point(100, 189); this.labelNewValue.Name = "labelNewValue"; - this.labelNewValue.Size = new System.Drawing.Size(63, 13); + this.labelNewValue.Size = new System.Drawing.Size(61, 13); this.labelNewValue.TabIndex = 6; this.labelNewValue.Text = "New value:"; // // VirtualProtectWindow // - this.AcceptButton = this.buttonVirtualProtect; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; - this.CancelButton = this.buttonCloseVirtualProtect; this.ClientSize = new System.Drawing.Size(423, 219); this.Controls.Add(this.buttonCloseVirtualProtect); this.Controls.Add(this.buttonVirtualProtect); diff --git a/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.cs b/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.cs index 432e9d37f..874b11675 100644 --- a/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.cs @@ -31,14 +31,14 @@ namespace ProcessHacker { public partial class VirtualProtectWindow : Form { - private readonly int _pid; - private readonly long _size; - private readonly IntPtr _address; + private int _pid; + private long _size; + private IntPtr _address; public VirtualProtectWindow(int pid, IntPtr address, long size) { InitializeComponent(); - + this.AddEscapeToClose(); this.SetTopMost(); _pid = pid; @@ -71,7 +71,8 @@ private void buttonVirtualProtect_Click(object sender, EventArgs e) return; } - using (ProcessHandle phandle = new ProcessHandle(_pid, ProcessAccess.VmOperation)) + using (ProcessHandle phandle = + new ProcessHandle(_pid, ProcessAccess.VmOperation)) { try { diff --git a/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.resx b/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.resx index e411c0496..481674719 100644 --- a/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/VirtualProtectWindow.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Possible values: diff --git a/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.Designer.cs index c20c4b77b..6408048fe 100644 --- a/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.Designer.cs @@ -53,7 +53,7 @@ private void InitializeComponent() this.labelFile.AutoSize = true; this.labelFile.Location = new System.Drawing.Point(12, 9); this.labelFile.Name = "labelFile"; - this.labelFile.Size = new System.Drawing.Size(65, 13); + this.labelFile.Size = new System.Drawing.Size(58, 13); this.labelFile.TabIndex = 2; this.labelFile.Text = "Uploading:"; // @@ -62,7 +62,7 @@ private void InitializeComponent() this.uploadedLabel.AutoSize = true; this.uploadedLabel.Location = new System.Drawing.Point(12, 54); this.uploadedLabel.Name = "uploadedLabel"; - this.uploadedLabel.Size = new System.Drawing.Size(61, 13); + this.uploadedLabel.Size = new System.Drawing.Size(56, 13); this.uploadedLabel.TabIndex = 3; this.uploadedLabel.Text = "Uploaded:"; // @@ -83,7 +83,7 @@ private void InitializeComponent() this.speedLabel.AutoSize = true; this.speedLabel.Location = new System.Drawing.Point(213, 54); this.speedLabel.Name = "speedLabel"; - this.speedLabel.Size = new System.Drawing.Size(42, 13); + this.speedLabel.Size = new System.Drawing.Size(41, 13); this.speedLabel.TabIndex = 6; this.speedLabel.Text = "Speed:"; // @@ -92,14 +92,14 @@ private void InitializeComponent() this.totalSizeLabel.AutoSize = true; this.totalSizeLabel.Location = new System.Drawing.Point(12, 32); this.totalSizeLabel.Name = "totalSizeLabel"; - this.totalSizeLabel.Size = new System.Drawing.Size(58, 13); + this.totalSizeLabel.Size = new System.Drawing.Size(57, 13); this.totalSizeLabel.TabIndex = 7; this.totalSizeLabel.Text = "Total Size:"; // // progressUpload // - this.progressUpload.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.progressUpload.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.progressUpload.Location = new System.Drawing.Point(12, 75); this.progressUpload.Name = "progressUpload"; this.progressUpload.Size = new System.Drawing.Size(325, 23); @@ -109,7 +109,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(430, 110); this.Controls.Add(this.progressUpload); this.Controls.Add(this.totalSizeLabel); @@ -125,8 +124,8 @@ private void InitializeComponent() this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "VirusTotal Uploader"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VirusTotalUploaderWindow_FormClosing); this.Load += new System.EventHandler(this.VirusTotalUploaderWindow_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VirusTotalUploaderWindow_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.LogoImg)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.cs b/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.cs index 75bc7c751..4f369b7e9 100644 --- a/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.cs @@ -42,8 +42,8 @@ namespace ProcessHacker { public partial class VirusTotalUploaderWindow : Form { - readonly string fileName; - readonly string processName; + string fileName; + string processName; long totalFileSize; long bytesPerSecond; @@ -54,6 +54,7 @@ public partial class VirusTotalUploaderWindow : Form public VirusTotalUploaderWindow(string procName, string procPath) { + this.SetPhParent(); InitializeComponent(); this.AddEscapeToClose(); this.SetTopMost(); @@ -73,16 +74,13 @@ private void VirusTotalUploaderWindow_Load(object sender, EventArgs e) { if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog - { - PositionRelativeToWindow = true, - Content = "The selected file doesn't exist or couldnt be found!", - MainInstruction = "File Location not Available!", - WindowTitle = "System Error", - MainIcon = TaskDialogIcon.CircleX, - CommonButtons = TaskDialogCommonButtons.Ok - }; - + TaskDialog td = new TaskDialog(); + td.PositionRelativeToWindow = true; + td.Content = "The selected file doesn't exist or couldnt be found!"; + td.MainInstruction = "File Location not Available!"; + td.WindowTitle = "System Error"; + td.MainIcon = TaskDialogIcon.CircleX; + td.CommonButtons = TaskDialogCommonButtons.Ok; td.Show(Program.HackerWindow.Handle); } else @@ -99,15 +97,13 @@ private void VirusTotalUploaderWindow_Load(object sender, EventArgs e) { if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog - { - PositionRelativeToWindow = true, - Content = "This file is larger than 20MB, above the VirusTotal limit!", - MainInstruction = "File is too large", - WindowTitle = "VirusTotal Error", - MainIcon = TaskDialogIcon.CircleX, - CommonButtons = TaskDialogCommonButtons.Ok - }; + TaskDialog td = new TaskDialog(); + td.PositionRelativeToWindow = true; + td.Content = "This file is larger than 20MB, above the VirusTotal limit!"; + td.MainInstruction = "File is too large"; + td.WindowTitle = "VirusTotal Error"; + td.MainIcon = TaskDialogIcon.CircleX; + td.CommonButtons = TaskDialogCommonButtons.Ok; td.Show(Program.HackerWindow.Handle); } else @@ -130,8 +126,8 @@ private void VirusTotalUploaderWindow_Load(object sender, EventArgs e) ThreadTask getSessionTokenTask = new ThreadTask(); - getSessionTokenTask.RunTask += this.getSessionTokenTask_RunTask; - getSessionTokenTask.Completed += this.getSessionTokenTask_Completed; + getSessionTokenTask.RunTask += new ThreadTaskRunTaskDelegate(getSessionTokenTask_RunTask); + getSessionTokenTask.Completed += new ThreadTaskCompletedDelegate(getSessionTokenTask_Completed); getSessionTokenTask.Start(); } @@ -153,7 +149,7 @@ private void getSessionTokenTask_RunTask(object param, ref object result) { try { - HttpWebRequest sessionRequest = (HttpWebRequest)WebRequest.Create("http://www.virustotal.com/vt/en/identificador"); + HttpWebRequest sessionRequest = (HttpWebRequest)HttpWebRequest.Create("http://www.virustotal.com/vt/en/identificador"); sessionRequest.ServicePoint.ConnectionLimit = 20; sessionRequest.UserAgent = "Process Hacker " + Application.ProductVersion; sessionRequest.Timeout = System.Threading.Timeout.Infinite; @@ -279,13 +275,16 @@ private void uploadTask_RunTask(object param, ref object result) { // RequestCanceled will occour when we cancel the WebRequest. // Filter out that exception but log all others. - if (ex.Status != WebExceptionStatus.RequestCanceled) + if (ex != null) { - PhUtils.ShowException("Unable to upload the file", ex); - Logging.Log(ex); + if (ex.Status != WebExceptionStatus.RequestCanceled) + { + PhUtils.ShowException("Unable to upload the file", ex); + Logging.Log(ex); - if (this.IsHandleCreated) - this.BeginInvoke(new MethodInvoker(this.Close)); + if (this.IsHandleCreated) + this.BeginInvoke(new MethodInvoker(this.Close)); + } } } @@ -314,7 +313,7 @@ private void ChangeProgress(int progress) progressUpload.Value = progress; if (OSVersion.HasExtendedTaskbar) - Program.HackerWindow.SetTaskbarProgress(this.progressUpload); + Windows7Taskbar.SetTaskbarProgress(Program.HackerWindow, this.progressUpload); } private void uploadTask_Completed(object result) diff --git a/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.resx b/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/VirusTotalUploaderWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.Designer.cs b/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.Designer.cs index aa37b4374..5951b2aa9 100644 --- a/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.Designer.cs +++ b/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.Designer.cs @@ -39,25 +39,25 @@ private void InitializeComponent() // // textDescription // - this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.textDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.textDescription.BackColor = System.Drawing.SystemColors.Control; this.textDescription.Location = new System.Drawing.Point(12, 12); this.textDescription.Name = "textDescription"; - this.textDescription.Size = new System.Drawing.Size(361, 22); + this.textDescription.Size = new System.Drawing.Size(361, 20); this.textDescription.TabIndex = 1; // // labelIntro // - this.labelIntro.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.labelIntro.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.labelIntro.Location = new System.Drawing.Point(12, 253); this.labelIntro.Name = "labelIntro"; this.labelIntro.Size = new System.Drawing.Size(390, 41); this.labelIntro.TabIndex = 2; this.labelIntro.Text = "Analyzing the Wait Chain for a process helps diagnose application hangs and deadl" + - "ocks caused by a process using or waiting to use a resource that is being used b" + - "y another process."; + "ocks caused by a process using or waiting to use a resource that is being used b" + + "y another process."; this.labelIntro.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // buttonCancel @@ -90,7 +90,7 @@ private void InitializeComponent() this.moreInfoLink.AutoSize = true; this.moreInfoLink.Location = new System.Drawing.Point(9, 304); this.moreInfoLink.Name = "moreInfoLink"; - this.moreInfoLink.Size = new System.Drawing.Size(133, 13); + this.moreInfoLink.Size = new System.Drawing.Size(121, 13); this.moreInfoLink.TabIndex = 5; this.moreInfoLink.TabStop = true; this.moreInfoLink.Text = "More about Wait Chains"; @@ -98,8 +98,8 @@ private void InitializeComponent() // // buttonProperties // - this.buttonProperties.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); + this.buttonProperties.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); this.buttonProperties.Image = global::ProcessHacker.Properties.Resources.application_form_magnify; this.buttonProperties.Location = new System.Drawing.Point(379, 9); this.buttonProperties.Name = "buttonProperties"; @@ -120,7 +120,6 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(415, 329); this.Controls.Add(this.threadTree); this.Controls.Add(this.buttonProperties); diff --git a/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.cs b/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.cs index 7eeb0a5df..c670039d4 100644 --- a/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.cs +++ b/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.cs @@ -1,22 +1,28 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; using System.Text; using System.Windows.Forms; using ProcessHacker.Common; using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; +using System.Diagnostics; using ProcessHacker.Native; +using ProcessHacker.Native.Api; namespace ProcessHacker { public partial class WaitChainWindow : Form { - private readonly int processPid; - private readonly string processName; + private int processPid; + private string processName; public WaitChainWindow(string procName, int procPid) { InitializeComponent(); - + this.SetPhParent(); this.AddEscapeToClose(); this.SetTopMost(); @@ -113,7 +119,7 @@ private void DisplayThreadData(WaitData data, bool allData) { sb.Append(string.Format(" {0} Status: {1}", node.ObjectType, node.ObjectStatus)); - String name = node.ObjectName; + String name = node.ObjectName(); if (!String.IsNullOrEmpty(name)) { sb.Append(string.Format(" Name: {0}", name)); @@ -132,12 +138,13 @@ private void buttonProperties_Click(object sender, EventArgs e) { try { - Program.GetProcessWindow(Program.ProcessProvider.Dictionary[processPid], f => - { - Settings.Instance.ProcessWindowSelectedTab = "tabThreads"; - f.Show(); - f.Activate(); - }); + ProcessWindow pForm = Program.GetProcessWindow(Program.ProcessProvider.Dictionary[processPid], + new Program.PWindowInvokeAction(delegate(ProcessWindow f) + { + Settings.Instance.ProcessWindowSelectedTab = "tabThreads"; + f.Show(); + f.Activate(); + })); } catch (Exception ex) { @@ -149,7 +156,7 @@ private void buttonProperties_Click(object sender, EventArgs e) /// /// Wraps all the native Wait Chain Traversal code. /// - public static class WaitChainNativeMethods + public static partial class WaitChainNativeMethods { // Keep the module handle around for the life of the application as the WCT code has pointers into it. private static SafeModuleHandle oleModule; @@ -213,7 +220,7 @@ public unsafe struct WAITCHAIN_NODE_INFO // The name union. [FieldOffset(0x8)] - public fixed ushort RealObjectName[WCT_OBJNAME_LENGTH]; + private fixed ushort RealObjectName[WCT_OBJNAME_LENGTH]; [FieldOffset(0x108)] public int TimeOutLowPart; [FieldOffset(0x10C)] @@ -233,14 +240,11 @@ public unsafe struct WAITCHAIN_NODE_INFO //TODO: fix this... fixes old VS05 bug thats now non-existent //Does the work to get the ObjectName field. - public string ObjectName + public String ObjectName() { - get + fixed (WAITCHAIN_NODE_INFO* p = &this) { - fixed (WAITCHAIN_NODE_INFO* p = &this) - { - return (p->RealObjectName[0] != '\0') ? new string((char*)p->RealObjectName) : string.Empty; - } + return (p->RealObjectName[0] != '\0') ? new string((char*)p->RealObjectName) : string.Empty; } } } @@ -337,9 +341,9 @@ protected override bool ReleaseHandle() public sealed class WaitData { - private readonly WaitChainNativeMethods.WAITCHAIN_NODE_INFO[] data; - private readonly bool isDeadlock; - private readonly int nodeCount; + private WaitChainNativeMethods.WAITCHAIN_NODE_INFO[] data; + private bool isDeadlock; + private int nodeCount; public WaitData(WaitChainNativeMethods.WAITCHAIN_NODE_INFO[] data, int nodeCount, bool isDeadlock) { @@ -350,23 +354,32 @@ public WaitData(WaitChainNativeMethods.WAITCHAIN_NODE_INFO[] data, int nodeCount public WaitChainNativeMethods.WAITCHAIN_NODE_INFO[] Nodes { - get { return (data); } + get + { + return (data); + } } public int NodeCount { - get { return (nodeCount); } + get + { + return (nodeCount); + } } public bool IsDeadlock { - get { return (isDeadlock); } + get + { + return (isDeadlock); + } } } public sealed class WaitChainTraversal : IDisposable { - private readonly SafeWaitChainHandle waitChainHandle; + private SafeWaitChainHandle waitChainHandle; public WaitChainTraversal() { @@ -376,14 +389,14 @@ public WaitChainTraversal() public WaitData GetThreadWaitChain(int threadId) { WaitChainNativeMethods.WAITCHAIN_NODE_INFO[] data = new WaitChainNativeMethods.WAITCHAIN_NODE_INFO[WaitChainNativeMethods.WCT_MAX_NODE_COUNT]; - int isDeadlock; + int isDeadlock = 0; int nodeCount = WaitChainNativeMethods.WCT_MAX_NODE_COUNT; WaitData retData = null; if (WaitChainNativeMethods.GetThreadWaitChain(waitChainHandle, threadId, ref nodeCount, data, out isDeadlock)) { - retData = new WaitData(data, nodeCount, isDeadlock == 1); + retData = new WaitData(data, (int)nodeCount, isDeadlock == 1); } return (retData); diff --git a/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.resx b/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.resx index c7e0d4bdf..ff31a6db5 100644 --- a/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.resx +++ b/1.x/trunk/ProcessHacker/Forms/WaitChainWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Help.htm b/1.x/trunk/ProcessHacker/Help.htm index 513807d5f..986210822 100644 --- a/1.x/trunk/ProcessHacker/Help.htm +++ b/1.x/trunk/ProcessHacker/Help.htm @@ -419,6 +419,7 @@

Terminator tests

M2
Uses VirtualProtectEx to prevent the process' pages from being used, crashing the process.
+

Process Properties

diff --git a/1.x/trunk/ProcessHacker/ProcessHacker.csproj b/1.x/trunk/ProcessHacker/ProcessHacker.csproj index 2004fc2f8..53c5abcd7 100644 --- a/1.x/trunk/ProcessHacker/ProcessHacker.csproj +++ b/1.x/trunk/ProcessHacker/ProcessHacker.csproj @@ -10,7 +10,7 @@ Properties ProcessHacker ProcessHacker - v4.5 + v4.0 512 ProcessHacker.ico ProcessHacker.Program @@ -48,7 +48,6 @@ true AnyCPU AllRules.ruleset - false pdbonly @@ -62,7 +61,6 @@ false AnyCPU AllRules.ruleset - false @@ -76,7 +74,6 @@ - @@ -91,116 +88,6 @@ - - UserControl - - - HandleDetails.cs - - - Component - - - Component - - - Component - - - - - Component - - - Component - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Component - - - Component - - - - Component - - - Component - - - Component - - - - - - Component - - - Component - - - Component - - - Component - - - - Component - - - - - - - - - - - - - Component - - - TreeViewAdv.cs - - - Component - - - Component - - - Component - - Form @@ -213,18 +100,6 @@ HackerWindow.cs - - Form - - - ChooseProcessDialog.cs - - - Form - - - HandlePropertiesWindow.cs - Form @@ -233,25 +108,10 @@ PromptBox.cs - - HandleDetails.cs - - - Tracker.cs - - - TreeViewAdv.cs - HackerWindow.cs Designer - - ChooseProcessDialog.cs - - - HandlePropertiesWindow.cs - ResXFileCodeGenerator Resources.Designer.cs @@ -262,10 +122,14 @@ Resources.resx True - - SysInfoWindow.cs - + + + Component + + + Component + @@ -448,12 +312,18 @@ ProtectProcessWindow.cs + + ScratchpadWindow.cs + SessionInformationWindow.cs StructWindow.cs + + SysInfoWindow.cs + TerminatorWindow.cs @@ -537,7 +407,6 @@ WaitChainWindow.cs - @@ -710,6 +579,12 @@ ProtectProcessWindow.cs + + Form + + + ScratchpadWindow.cs + Form @@ -741,16 +616,8 @@ - - Form - - - SysInfoWindow.cs - - - @@ -759,6 +626,7 @@ + UserControl @@ -802,6 +670,9 @@ HandleList.cs + + Component + @@ -945,6 +816,12 @@ StructWindow.cs + + Form + + + SysInfoWindow.cs + Form @@ -1153,15 +1030,6 @@ - - - - - - - - - @@ -1193,6 +1061,10 @@ {8A448157-E1A7-4DDF-954E-287F1117832B} ProcessHacker.Native + + {E73BB233-D88B-44A7-A98F-D71EE158381D} + Aga.Controls + diff --git a/1.x/trunk/ProcessHacker/Program/Assistant.cs b/1.x/trunk/ProcessHacker/Program/Assistant.cs index ef9320918..a5f1ce7b6 100644 --- a/1.x/trunk/ProcessHacker/Program/Assistant.cs +++ b/1.x/trunk/ProcessHacker/Program/Assistant.cs @@ -172,18 +172,18 @@ public static void Main(Dictionary pArgs) TokenHandle token = null; string domain = null; - string username; + string username = ""; if (args.ContainsKey("-u")) { string user = args["-u"]; - if (user.Contains("\\", StringComparison.OrdinalIgnoreCase)) + if (user.Contains("\\")) { domain = user.Split('\\')[0]; username = user.Split('\\')[1]; } - else if (user.Contains("@", StringComparison.OrdinalIgnoreCase)) + else if (user.Contains("@")) { username = user.Split('@')[0]; domain = user.Split('@')[1]; @@ -288,7 +288,7 @@ public static void Main(Dictionary pArgs) try { - token.SessionId = sessionId; + token.SetSessionId(sessionId); } catch (Exception ex) { diff --git a/1.x/trunk/ProcessHacker/Program/Dump.cs b/1.x/trunk/ProcessHacker/Program/Dump.cs index a8fe33753..e1da848a7 100644 --- a/1.x/trunk/ProcessHacker/Program/Dump.cs +++ b/1.x/trunk/ProcessHacker/Program/Dump.cs @@ -73,17 +73,18 @@ public static void Write(this BinaryWriter bw, string key, DateTime value) public static void WriteListEntry(this BinaryWriter bw, string value) { - if (string.IsNullOrEmpty(value)) - value = string.Empty; + if (value == null) + value = ""; bw.Write(Encoding.Unicode.GetBytes(value.Replace("\0", "") + "\0")); } - public static void AppendStruct(MemoryObject mo, int size, T s) where T : struct + public static void AppendStruct(MemoryObject mo, T s) + where T : struct { - using (MemoryAlloc data = new MemoryAlloc(size)) + using (var data = new MemoryAlloc(Marshal.SizeOf(typeof(T)))) { - data.WriteStruct(s); + data.WriteStruct(s); mo.AppendData(data.ReadBytes(data.Size)); } } @@ -94,7 +95,7 @@ public static IDictionary GetDictionary(MemoryObject mo) string str = Encoding.Unicode.GetString(mo.ReadData()); int i = 0; - if (string.IsNullOrEmpty(str)) + if (str == "") return dict; while (true) @@ -123,7 +124,7 @@ public static IDictionary GetDictionary(MemoryObject mo) public static Icon GetIcon(MemoryObject mo) { byte[] data = mo.ReadData(); - ByteStreamReader reader = new ByteStreamReader(data); + ProcessHacker.Common.ByteStreamReader reader = new ProcessHacker.Common.ByteStreamReader(data); using (Bitmap b = new Bitmap(reader)) { @@ -186,7 +187,7 @@ public static MemoryFileSystem BeginDump(string fileName, MfsOpenMode mode) { MemoryFileSystem mfs = new MemoryFileSystem(fileName, mode); - using (MemoryObject sysinfo = mfs.RootObject.CreateChild("SystemInformation")) + using (var sysinfo = mfs.RootObject.CreateChild("SystemInformation")) { BinaryWriter bw = new BinaryWriter(sysinfo.GetWriteStream()); @@ -208,7 +209,7 @@ public static MemoryFileSystem BeginDump(string fileName, MfsOpenMode mode) public static void DumpProcesses(MemoryFileSystem mfs, ProcessSystemProvider provider) { - using (MemoryObject processes = mfs.RootObject.GetChild("Processes")) + using (var processes = mfs.RootObject.GetChild("Processes")) { var p = Windows.GetProcesses(); @@ -308,8 +309,8 @@ object handles if (pid != 4) { - using (ProcessHandle phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) - fileName = phandle.ImageFileName; + using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) + fileName = FileUtils.GetFileName(phandle.GetImageFileName()); } else { @@ -370,9 +371,9 @@ object handles { using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights | ProcessAccess.VmRead)) { - bw.Write("CommandLine", phandle.CommandLine); + bw.Write("CommandLine", phandle.GetCommandLine()); bw.Write("CurrentDirectory", phandle.GetPebString(PebOffset.CurrentDirectoryPath)); - bw.Write("IsPosix", phandle.IsPosix); + bw.Write("IsPosix", phandle.IsPosix()); } } catch @@ -383,14 +384,14 @@ object handles using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) { if (OSVersion.Architecture == OSArch.Amd64) - bw.Write("IsWow64", phandle.IsWow64); + bw.Write("IsWow64", phandle.IsWow64()); } using (var phandle = new ProcessHandle(pid, ProcessAccess.QueryInformation)) { - bw.Write("IsBeingDebugged", phandle.IsBeingDebugged); - bw.Write("IsCritical", phandle.IsCritical); - bw.Write("DepStatus", (int)phandle.DepStatus); + bw.Write("IsBeingDebugged", phandle.IsBeingDebugged()); + bw.Write("IsCritical", phandle.IsCritical()); + bw.Write("DepStatus", (int)phandle.GetDepStatus()); } } catch @@ -404,11 +405,11 @@ object handles { using (var thandle = phandle.GetToken(TokenAccess.Query)) { - bw.Write("UserName", thandle.User.GetFullName(true)); + bw.Write("UserName", thandle.GetUser().GetFullName(true)); userNameWritten = true; if (OSVersion.HasUac) - bw.Write("ElevationType", (int)thandle.ElevationType); + bw.Write("ElevationType", (int)thandle.GetElevationType()); } } } @@ -438,9 +439,9 @@ object handles } using (var vmCounters = processMo.CreateChild("VmCounters")) - AppendStruct(vmCounters, VmCountersEx64.SizeOf, new VmCountersEx64(process.Process.VirtualMemoryCounters)); + AppendStruct(vmCounters, new VmCountersEx64(process.Process.VirtualMemoryCounters)); using (var ioCounters = processMo.CreateChild("IoCounters")) - AppendStruct(ioCounters, IoCounters.SizeOf, process.Process.IoCounters); + AppendStruct(ioCounters, process.Process.IoCounters); try { @@ -488,62 +489,62 @@ private static void DumpProcessModules(MemoryObject processMo, int pid) if (pid <= 0) return; - using (MemoryObject modules = processMo.CreateChild("Modules")) + using (var modules = processMo.CreateChild("Modules")) { if (pid != 4) { var baseAddressList = new Dictionary(); bool isWow64 = false; - using (ProcessHandle phandle = new ProcessHandle(pid, Program.MinProcessQueryRights | ProcessAccess.VmRead)) + using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights | ProcessAccess.VmRead)) { if (OSVersion.Architecture == OSArch.Amd64) - isWow64 = phandle.IsWow64; + isWow64 = phandle.IsWow64(); - phandle.EnumModules(module => - { - if (!baseAddressList.ContainsKey(module.BaseAddress)) + phandle.EnumModules((module) => { - DumpProcessModule(modules, module); - baseAddressList.Add(module.BaseAddress, null); - } + if (!baseAddressList.ContainsKey(module.BaseAddress)) + { + DumpProcessModule(modules, module); + baseAddressList.Add(module.BaseAddress, null); + } - return true; - }); + return true; + }); } try { - using (ProcessHandle phandle = new ProcessHandle(pid, ProcessAccess.QueryInformation | ProcessAccess.VmRead)) + using (var phandle = new ProcessHandle(pid, ProcessAccess.QueryInformation | ProcessAccess.VmRead)) { - phandle.EnumMemory(memory => - { - if (memory.Type == MemoryType.Mapped) + phandle.EnumMemory((memory) => { - if (!baseAddressList.ContainsKey(memory.BaseAddress)) + if (memory.Type == MemoryType.Mapped) { - string fileName = phandle.GetMappedFileName(memory.BaseAddress); - - if (!string.IsNullOrEmpty(fileName)) + if (!baseAddressList.ContainsKey(memory.BaseAddress)) { - fileName = FileUtils.GetFileName(fileName); - - DumpProcessModule(modules, new ProcessModule( - memory.BaseAddress, - memory.RegionSize.ToInt32(), - IntPtr.Zero, - 0, - Path.GetFileName(fileName), - fileName - )); - - baseAddressList.Add(memory.BaseAddress, null); + string fileName = phandle.GetMappedFileName(memory.BaseAddress); + + if (fileName != null) + { + fileName = FileUtils.GetFileName(fileName); + + DumpProcessModule(modules, new ProcessModule( + memory.BaseAddress, + memory.RegionSize.ToInt32(), + IntPtr.Zero, + 0, + Path.GetFileName(fileName), + fileName + )); + + baseAddressList.Add(memory.BaseAddress, null); + } } } - } - return true; - }); + return true; + }); } } catch @@ -561,16 +562,16 @@ private static void DumpProcessModules(MemoryObject processMo, int pid) RtlQueryProcessDebugFlags.NonInvasive ); - buffer.EnumModules(module => - { - if (!baseAddressList.ContainsKey(module.BaseAddress)) + buffer.EnumModules((module) => { - DumpProcessModule(modules, module); - baseAddressList.Add(module.BaseAddress, null); - } + if (!baseAddressList.ContainsKey(module.BaseAddress)) + { + DumpProcessModule(modules, module); + baseAddressList.Add(module.BaseAddress, null); + } - return true; - }); + return true; + }); } } catch @@ -622,22 +623,22 @@ private static void DumpProcessToken(MemoryObject processMo, int pid) using (var thandle = phandle.GetToken(TokenAccess.Query)) { - Sid user = thandle.User; + Sid user = thandle.GetUser(); bw.Write("UserName", user.GetFullName(true)); bw.Write("UserStringSid", user.StringSid); - bw.Write("OwnerName", thandle.Owner.GetFullName(true)); - bw.Write("PrimaryGroupName", thandle.PrimaryGroup.GetFullName(true)); - bw.Write("SessionId", thandle.SessionId); + bw.Write("OwnerName", thandle.GetOwner().GetFullName(true)); + bw.Write("PrimaryGroupName", thandle.GetPrimaryGroup().GetFullName(true)); + bw.Write("SessionId", thandle.GetSessionId()); if (OSVersion.HasUac) { - bw.Write("Elevated", thandle.IsElevated); - bw.Write("VirtualizationAllowed", thandle.IsVirtualizationAllowed); - bw.Write("VirtualizationEnabled", thandle.IsVirtualizationEnabled); + bw.Write("Elevated", thandle.IsElevated()); + bw.Write("VirtualizationAllowed", thandle.IsVirtualizationAllowed()); + bw.Write("VirtualizationEnabled", thandle.IsVirtualizationEnabled()); } - var statistics = thandle.Statistics; + var statistics = thandle.GetStatistics(); bw.Write("Type", (int)statistics.TokenType); bw.Write("ImpersonationLevel", (int)statistics.ImpersonationLevel); @@ -646,7 +647,7 @@ private static void DumpProcessToken(MemoryObject processMo, int pid) bw.Write("MemoryUsed", statistics.DynamicCharged); bw.Write("MemoryAvailable", statistics.DynamicAvailable); - var groups = thandle.Groups; + var groups = thandle.GetGroups(); using (var groupsMo = tokenMo.CreateChild("Groups")) { @@ -662,18 +663,18 @@ private static void DumpProcessToken(MemoryObject processMo, int pid) bw2.Close(); } - var privileges = thandle.Privileges; + var privileges = thandle.GetPrivileges(); using (var privilegesMo = tokenMo.CreateChild("Privileges")) { BinaryWriter bw2 = new BinaryWriter(privilegesMo.GetWriteStream()); - foreach (Privilege t in privileges) + for (int i = 0; i < privileges.Length; i++) { bw2.WriteListEntry( - t.Name + ";" + - t.DisplayName + ";" + - ((int)t.Attributes).ToString("x") + privileges[i].Name + ";" + + privileges[i].DisplayName + ";" + + ((int)privileges[i].Attributes).ToString("x") ); } @@ -685,7 +686,7 @@ private static void DumpProcessToken(MemoryObject processMo, int pid) { using (var thandle = phandle.GetToken(TokenAccess.QuerySource)) { - var source = thandle.Source; + var source = thandle.GetSource(); bw.Write("SourceName", source.SourceName.TrimEnd('\0', '\r', '\n', ' ')); bw.Write("SourceLuid", source.SourceIdentifier.QuadPart); diff --git a/1.x/trunk/ProcessHacker/Program/ExtendedCmd.cs b/1.x/trunk/ProcessHacker/Program/ExtendedCmd.cs index 94d416705..2bea572d7 100644 --- a/1.x/trunk/ProcessHacker/Program/ExtendedCmd.cs +++ b/1.x/trunk/ProcessHacker/Program/ExtendedCmd.cs @@ -37,6 +37,13 @@ public static class ExtendedCmd { public static void Run(IDictionary args) { + try + { + ThemingScope.Activate(); + } + catch + { } + if (!args.ContainsKey("-type")) throw new Exception("-type switch required."); diff --git a/1.x/trunk/ProcessHacker/Program/Program.cs b/1.x/trunk/ProcessHacker/Program/Program.cs index b98af76f7..b3cd6fe3e 100644 --- a/1.x/trunk/ProcessHacker/Program/Program.cs +++ b/1.x/trunk/ProcessHacker/Program/Program.cs @@ -60,10 +60,7 @@ public static class Program /// /// The Results Window ID Generator /// - public static IdGenerator ResultsIds = new IdGenerator - { - Sort = true - }; + public static IdGenerator ResultsIds = new IdGenerator() { Sort = true }; public static Dictionary Structs = new Dictionary(); @@ -75,7 +72,7 @@ public static class Program public static Dictionary ResultsWindows = new Dictionary(); public static Dictionary ResultsThreads = new Dictionary(); - public static bool PEWindowsThreaded = true; + public static bool PEWindowsThreaded = false; public static Dictionary PEWindows = new Dictionary(); public static Dictionary PEThreads = new Dictionary(); @@ -94,22 +91,22 @@ public static class Program public static ServiceProvider ServiceProvider; public static NetworkProvider NetworkProvider; - public static bool BadConfig; + public static bool BadConfig = false; public static TokenElevationType ElevationType; public static ProcessHacker.Native.Threading.Mutant GlobalMutex; public static string GlobalMutexName = @"\BaseNamedObjects\ProcessHackerMutex"; public static System.Collections.Specialized.StringCollection ImposterNames = new System.Collections.Specialized.StringCollection(); public static int InspectPid = -1; - public static bool NoKph; + public static bool NoKph = false; public static string SelectTab = "Processes"; - public static bool StartHidden; - public static bool StartVisible; + public static bool StartHidden = false; + public static bool StartVisible = false; public static ProviderThread PrimaryProviderThread; public static ProviderThread SecondaryProviderThread; public static ProcessHacker.Native.Threading.Waiter SharedWaiter; - private static readonly object CollectWorkerThreadsLock = new object(); + private static object CollectWorkerThreadsLock = new object(); /// /// The main entry point for the application. @@ -117,7 +114,7 @@ public static class Program [STAThread] public static void Main(string[] args) { - Dictionary pArgs; + Dictionary pArgs = null; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); @@ -129,7 +126,7 @@ public static void Main(string[] args) } // Check OS support. - if (OSVersion.IsBelow(WindowsVersion.TwoThousand) || OSVersion.IsAbove(WindowsVersion.Eight)) + if (OSVersion.IsBelow(WindowsVersion.TwoThousand) || OSVersion.IsAbove(WindowsVersion.Seven)) { PhUtils.ShowWarning("Your operating system is not supported by Process Hacker."); } @@ -149,20 +146,6 @@ public static void Main(string[] args) pArgs = new Dictionary(); } - try - { - if ( - // Only load KPH if it's enabled. - Settings.Instance.EnableKPH && !NoKph && - // Don't load KPH if we're going to install/uninstall it. - !pArgs.ContainsKey("-installkph") && !pArgs.ContainsKey("-uninstallkph") - ) - KProcessHacker2.Instance = new KProcessHacker2(); - } - catch - { } - - if (pArgs.ContainsKey("-h") || pArgs.ContainsKey("-help") || pArgs.ContainsKey("-?")) { ShowCommandLineUsage(); @@ -192,7 +175,9 @@ public static void Main(string[] args) catch { } - WorkQueue.GlobalWorkQueue.MaxWorkerThreads = Environment.ProcessorCount; + ThreadPool.SetMinThreads(1, 1); + ThreadPool.SetMaxThreads(2, 2); + WorkQueue.GlobalWorkQueue.MaxWorkerThreads = 2; // Create or open the Process Hacker mutex, used only by the installer. try @@ -206,7 +191,7 @@ public static void Main(string[] args) try { - using (TokenHandle thandle = ProcessHandle.Current.GetToken()) + using (var thandle = ProcessHandle.Current.GetToken()) { thandle.TrySetPrivilege("SeDebugPrivilege", SePrivilegeAttributes.Enabled); thandle.TrySetPrivilege("SeIncreaseBasePriorityPrivilege", SePrivilegeAttributes.Enabled); @@ -217,7 +202,7 @@ public static void Main(string[] args) if (OSVersion.HasUac) { - try { ElevationType = thandle.ElevationType; } + try { ElevationType = thandle.GetElevationType(); } catch { ElevationType = TokenElevationType.Full; } if (ElevationType == TokenElevationType.Default && @@ -238,15 +223,30 @@ public static void Main(string[] args) Logging.Log(ex); } + try + { + if ( + // Only load KPH if we're on 32-bit and it's enabled. + OSVersion.Architecture == OSArch.I386 && + Settings.Instance.EnableKPH && + !NoKph && + // Don't load KPH if we're going to install/uninstall it. + !pArgs.ContainsKey("-installkph") && !pArgs.ContainsKey("-uninstallkph") + ) + KProcessHacker.Instance = new KProcessHacker("KProcessHacker"); + } + catch + { } + MinProcessQueryRights = OSVersion.MinProcessQueryInfoAccess; MinThreadQueryRights = OSVersion.MinThreadQueryInfoAccess; - //if (KProcessHacker2.Instance != null) - //{ - // MinProcessGetHandleInformationRights = MinProcessQueryRights; - // MinProcessReadMemoryRights = MinProcessQueryRights; - // MinProcessWriteMemoryRights = MinProcessQueryRights; - //} + if (KProcessHacker.Instance != null) + { + MinProcessGetHandleInformationRights = MinProcessQueryRights; + MinProcessReadMemoryRights = MinProcessQueryRights; + MinProcessWriteMemoryRights = MinProcessQueryRights; + } try { @@ -261,7 +261,7 @@ public static void Main(string[] args) { CurrentProcessId = Win32.GetCurrentProcessId(); CurrentSessionId = Win32.GetProcessSessionId(Win32.GetCurrentProcessId()); - Thread.CurrentThread.Priority = ThreadPriority.Highest; + System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Highest; } catch (Exception ex) { @@ -273,7 +273,7 @@ public static void Main(string[] args) Win32.FileIconInit(true); LoadProviders(); - Windows.GetProcessName = pid => + Windows.GetProcessName = (pid) => ProcessProvider.Dictionary.ContainsKey(pid) ? ProcessProvider.Dictionary[pid].Name : null; @@ -304,7 +304,7 @@ private static void ShowCommandLineUsage() "-t n\tShows the specified tab. 0 is Processes, 1 is Services and 2 is Network.\n" + "-uninstallkph\tUninstalls the KProcessHacker service.\n" + "-v\tStarts Process Hacker visible.\n" + - string.Empty + "" ); } @@ -313,15 +313,13 @@ private static void LoadProviders() ProcessProvider = new ProcessSystemProvider(); ServiceProvider = new ServiceProvider(); NetworkProvider = new NetworkProvider(); - - Program.PrimaryProviderThread = new ProviderThread(Settings.Instance.RefreshInterval) - { - ProcessProvider, - ServiceProvider, - NetworkProvider - }; - - Program.SecondaryProviderThread = new ProviderThread(Settings.Instance.RefreshInterval); + Program.PrimaryProviderThread = + new ProviderThread(Settings.Instance.RefreshInterval); + Program.PrimaryProviderThread.Add(ProcessProvider); + Program.PrimaryProviderThread.Add(ServiceProvider); + Program.PrimaryProviderThread.Add(NetworkProvider); + Program.SecondaryProviderThread = + new ProviderThread(Settings.Instance.RefreshInterval); } private static void LoadSettings(bool useSettings, string settingsFileName) @@ -354,11 +352,15 @@ private static void LoadSettings(bool useSettings, string settingsFileName) { settingsFileName = appData + @"\Process Hacker\settings.xml"; } + else + { + settingsFileName = null; + } } // Make sure we have an absolute path so we don't run into problems // when saving. - if (!string.IsNullOrEmpty(settingsFileName)) + if (settingsFileName != null) { try { @@ -378,26 +380,31 @@ private static void LoadSettings(bool useSettings, string settingsFileName) catch { // Settings file is probably corrupt. Ask the user. + + try { ThemingScope.Activate(); } + catch { } + DialogResult result; if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog + TaskDialog td = new TaskDialog(); + + td.MainIcon = TaskDialogIcon.Warning; + td.MainInstruction = "The settings file is corrupt"; + td.WindowTitle = "Process Hacker"; + td.Content = "The settings file used by Process Hacker is corrupt. You can either " + + "delete the settings file or start Process Hacker with default settings."; + td.UseCommandLinks = true; + + td.Buttons = new TaskDialogButton[] { - MainIcon = TaskDialogIcon.Warning, - PositionRelativeToWindow = true, - MainInstruction = "The settings file is corrupt", - WindowTitle = "Process Hacker", - Content = "The settings file used by Process Hacker is corrupt. You can either " + - "delete the settings file or start Process Hacker with default settings.", - UseCommandLinks = true, - Buttons = new TaskDialogButton[] - { - new TaskDialogButton((int)DialogResult.Yes, "Delete the settings file\n" + settingsFileName), - new TaskDialogButton((int)DialogResult.No, "Start with default settings\nAny settings you change will not be saved."), - }, - CommonButtons = TaskDialogCommonButtons.Cancel + new TaskDialogButton((int)DialogResult.Yes, "Delete the settings file\n" + settingsFileName), + new TaskDialogButton((int)DialogResult.No, "Start with default settings\n" + + "Any settings you change will not be saved."), }; + td.CommonButtons = TaskDialogCommonButtons.Cancel; + result = (DialogResult)td.Show(); } else @@ -411,32 +418,24 @@ private static void LoadSettings(bool useSettings, string settingsFileName) result = DialogResult.Cancel; } - switch (result) + if (result == DialogResult.Yes) { - case DialogResult.Yes: - { - try - { - System.IO.File.Delete(settingsFileName); - } - catch (Exception ex) - { - PhUtils.ShowException("Unable to delete the settings file", ex); - Environment.Exit(1); - } - Settings.Instance = new Settings(settingsFileName); - break; - } - case DialogResult.No: - { - Settings.Instance = new Settings(null); - break; - } - case DialogResult.Cancel: - { - Environment.Exit(0); - } - break; + try { System.IO.File.Delete(settingsFileName); } + catch (Exception ex) + { + PhUtils.ShowException("Unable to delete the settings file", ex); + Environment.Exit(1); + } + + Settings.Instance = new Settings(settingsFileName); + } + else if (result == DialogResult.No) + { + Settings.Instance = new Settings(null); + } + else if (result == DialogResult.Cancel) + { + Environment.Exit(0); } } } @@ -468,11 +467,11 @@ private static bool ProcessCommandLine(Dictionary pArgs) { try { - using (ServiceManagerHandle scm = new ServiceManagerHandle(ScManagerAccess.CreateService)) + using (var scm = new ServiceManagerHandle(ScManagerAccess.CreateService)) { - using (ServiceHandle shandle = scm.CreateService( - "KProcessHacker2", - "KProcessHacker2", + using (var shandle = scm.CreateService( + "KProcessHacker", + "KProcessHacker", ServiceType.KernelDriver, ServiceStartType.SystemStart, ServiceErrorControl.Ignore, @@ -499,7 +498,7 @@ private static bool ProcessCommandLine(Dictionary pArgs) { try { - using (ServiceHandle shandle = new ServiceHandle("KProcessHacker2", ServiceAccess.Stop | (ServiceAccess)StandardRights.Delete)) + using (var shandle = new ServiceHandle("KProcessHacker", ServiceAccess.Stop | (ServiceAccess)StandardRights.Delete)) { try { shandle.Control(ServiceControl.Stop); } catch { } @@ -601,8 +600,8 @@ private static bool ProcessCommandLine(Dictionary pArgs) return true; } - if (pArgs.ContainsKey(string.Empty)) - if (pArgs[string.Empty].Replace("\"", string.Empty).Trim().EndsWith("taskmgr.exe", StringComparison.OrdinalIgnoreCase)) + if (pArgs.ContainsKey("")) + if (pArgs[""].Replace("\"", "").Trim().EndsWith("taskmgr.exe", StringComparison.OrdinalIgnoreCase)) StartVisible = true; if (pArgs.ContainsKey("-m")) @@ -636,10 +635,11 @@ public static void Unhook() ProcessHacker.Native.Image.MappedImage file = new ProcessHacker.Native.Image.MappedImage(Environment.SystemDirectory + "\\ntdll.dll"); IntPtr ntdll = Loader.GetDllHandle("ntdll.dll"); + MemoryProtection oldProtection; - MemoryProtection oldProtection = ProcessHandle.Current.ProtectMemory( + oldProtection = ProcessHandle.Current.ProtectMemory( ntdll, - file.Size, + (int)file.Size, MemoryProtection.ExecuteReadWrite ); @@ -647,9 +647,11 @@ public static void Unhook() { var entry = file.Exports.GetEntry(i); - if (!entry.Name.StartsWith("Nt", StringComparison.OrdinalIgnoreCase) || entry.Name.StartsWith("Ntdll", StringComparison.OrdinalIgnoreCase)) + if (!entry.Name.StartsWith("Nt") || entry.Name.StartsWith("Ntdll")) continue; + byte[] fileData = new byte[5]; + unsafe { IntPtr function = file.Exports.GetFunction(entry.Ordinal).Function; @@ -664,7 +666,7 @@ public static void Unhook() ProcessHandle.Current.ProtectMemory( ntdll, - file.Size, + (int)file.Size, oldProtection ); @@ -718,24 +720,24 @@ private static void ActivatePreviousInstance() { bool found = false; - WindowHandle.Enumerate(window => - { - if (window.Text.StartsWith("Process Hacker [", StringComparison.OrdinalIgnoreCase)) + WindowHandle.Enumerate((window) => { - int result; + if (window.GetText().Contains("Process Hacker [")) + { + int result; - window.SendMessageTimeout((WindowMessage) 0x9991, 0, 0, SmtoFlags.Block, 5000, out result); + window.SendMessageTimeout((WindowMessage)0x9991, 0, 0, SmtoFlags.Block, 5000, out result); - if (result == 0x1119) - { - window.SetForeground(); - found = true; - return false; + if (result == 0x1119) + { + window.SetForeground(); + found = true; + return false; + } } - } - return true; - }); + return true; + }); if (found) Environment.Exit(0); @@ -743,7 +745,7 @@ private static void ActivatePreviousInstance() public static void StartProcessHackerAdmin() { - StartProcessHackerAdmin(string.Empty, null, IntPtr.Zero); + StartProcessHackerAdmin("", null, IntPtr.Zero); } public static void StartProcessHackerAdmin(string args, MethodInvoker successAction) @@ -753,7 +755,8 @@ public static void StartProcessHackerAdmin(string args, MethodInvoker successAct public static void StartProcessHackerAdmin(string args, MethodInvoker successAction, IntPtr hWnd) { - StartProgramAdmin(ProcessHandle.Current.MainModule.FileName, args, successAction, ShowWindowType.Show, hWnd); + StartProgramAdmin(ProcessHandle.Current.GetMainModule().FileName, + args, successAction, ShowWindowType.Show, hWnd); } public static WaitResult StartProcessHackerAdminWait(string args, IntPtr hWnd, uint timeout) @@ -763,44 +766,45 @@ public static WaitResult StartProcessHackerAdminWait(string args, IntPtr hWnd, u public static WaitResult StartProcessHackerAdminWait(string args, MethodInvoker successAction, IntPtr hWnd, uint timeout) { - ShellExecuteInfo info = new ShellExecuteInfo - { - cbSize = ShellExecuteInfo.SizeOf, - lpFile = ProcessHandle.Current.MainModule.FileName, - nShow = ShowWindowType.Show, - fMask = 0x40, // SEE_MASK_NOCLOSEPROCESS - lpVerb = "runas", - lpParameters = args, - hWnd = hWnd - }; + var info = new ShellExecuteInfo(); + + info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info); + info.lpFile = ProcessHandle.Current.GetMainModule().FileName; + info.nShow = ShowWindowType.Show; + info.fMask = 0x40; // SEE_MASK_NOCLOSEPROCESS + info.lpVerb = "runas"; + info.lpParameters = args; + info.hWnd = hWnd; if (Win32.ShellExecuteEx(ref info)) { if (successAction != null) successAction(); - WaitResult result = Win32.WaitForSingleObject(info.hProcess, timeout); + var result = Win32.WaitForSingleObject(info.hProcess, timeout); - Win32.NtClose(info.hProcess); + Win32.CloseHandle(info.hProcess); return result; } - - // An error occured - the user probably canceled the elevation dialog. - return WaitResult.Abandoned; + else + { + // An error occured - the user probably canceled the elevation dialog. + return WaitResult.Abandoned; + } } - public static void StartProgramAdmin(string program, string args, MethodInvoker successAction, ShowWindowType showType, IntPtr hWnd) + public static void StartProgramAdmin(string program, string args, + MethodInvoker successAction, ShowWindowType showType, IntPtr hWnd) { - ShellExecuteInfo info = new ShellExecuteInfo - { - cbSize = ShellExecuteInfo.SizeOf, - lpFile = program, - nShow = showType, - lpVerb = "runas", - lpParameters = args, - hWnd = hWnd - }; + var info = new ShellExecuteInfo(); + + info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info); + info.lpFile = program; + info.nShow = showType; + info.lpVerb = "runas"; + info.lpParameters = args; + info.hWnd = hWnd; if (Win32.ShellExecuteEx(ref info)) { @@ -817,7 +821,7 @@ public static void TryStart(string command) } catch (Exception ex) { - if (command.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) + if (command.StartsWith("http://")) { if (ex is System.ComponentModel.Win32Exception) { @@ -838,12 +842,12 @@ private static Dictionary ParseArgs(string[] args) foreach (string s in args) { - if (s.StartsWith("-", StringComparison.OrdinalIgnoreCase)) + if (s.StartsWith("-")) { if (dict.ContainsKey(s)) throw new Exception("Option already specified."); - dict.Add(s, string.Empty); + dict.Add(s, ""); argPending = s; } else @@ -863,8 +867,8 @@ private static Dictionary ParseArgs(string[] args) //if (dict.ContainsKey("")) // throw new Exception("Input file already specified."); - if (!dict.ContainsKey(string.Empty)) - dict.Add(string.Empty, s); + if (!dict.ContainsKey("")) + dict.Add("", s); } } } @@ -874,12 +878,11 @@ private static Dictionary ParseArgs(string[] args) public static void ApplyFont(Font font) { - HackerWindow.BeginInvoke(new MethodInvoker(() => HackerWindow.ApplyFont(font))); + HackerWindow.BeginInvoke(new MethodInvoker(() => { HackerWindow.ApplyFont(font); })); foreach (var processWindow in PWindows.Values) { - ProcessWindow window = processWindow; - processWindow.BeginInvoke(new MethodInvoker(() => window.ApplyFont(font))); + processWindow.BeginInvoke(new MethodInvoker(() => { processWindow.ApplyFont(font); })); } } @@ -906,13 +909,16 @@ public static void CollectWorkerThreads() workerThreads = maxWorkerThreads - workerThreads; completionPortThreads = maxCompletionPortThreads - completionPortThreads; + + ThreadPool.SetMaxThreads(0, 0); + ThreadPool.SetMaxThreads(workerThreads, completionPortThreads); } } public static void CompactNativeHeaps() { foreach (var heap in Heap.GetHeaps()) - heap.Compact(); + heap.Compact(0); } public static string GetDiagnosticInformation() @@ -928,20 +934,20 @@ public static string GetDiagnosticInformation() info.AppendLine("Working set: " + Utils.FormatSize(Environment.WorkingSet)); if (Settings.Instance != null) - info.AppendLine("Settings file: " + (!string.IsNullOrEmpty(Settings.Instance.SettingsFileName) ? Settings.Instance.SettingsFileName : "(volatile)")); + info.AppendLine("Settings file: " + (Settings.Instance.SettingsFileName != null ? Settings.Instance.SettingsFileName : "(volatile)")); else info.AppendLine("Settings file: (not initialized)"); - if (KProcessHacker2.Instance != null) - info.AppendLine("KProcessHacker: " + KProcessHacker2.Instance.Features.ToString()); + if (KProcessHacker.Instance != null) + info.AppendLine("KProcessHacker: " + KProcessHacker.Instance.Features.ToString()); else info.AppendLine("KProcessHacker: not running"); info.AppendLine(); info.AppendLine("OBJECTS"); - long objectsCreatedCount = BaseObject.CreatedCount; - long objectsFreedCount = BaseObject.FreedCount; + int objectsCreatedCount = BaseObject.CreatedCount; + int objectsFreedCount = BaseObject.FreedCount; info.AppendLine("Live: " + (objectsCreatedCount - objectsFreedCount).ToString()); info.AppendLine("Created: " + objectsCreatedCount.ToString()); @@ -970,23 +976,17 @@ public static string GetDiagnosticInformation() info.AppendLine(); info.AppendLine("PROCESS HACKER THREAD POOL"); - info.AppendLine("Worker thread maximum: " + WorkQueue.GlobalWorkQueue.MaxWorkerThreads); - info.AppendLine("Worker thread minimum: " + WorkQueue.GlobalWorkQueue.MinWorkerThreads); - info.AppendLine("Busy worker threads: " + WorkQueue.GlobalWorkQueue.BusyCount); - info.AppendLine("Total worker threads: " + WorkQueue.GlobalWorkQueue.WorkerCount); - info.AppendLine("Queued work items: " + WorkQueue.GlobalWorkQueue.QueuedCount); + info.AppendLine("Worker thread maximum: " + WorkQueue.GlobalWorkQueue.MaxWorkerThreads.ToString()); + info.AppendLine("Worker thread minimum: " + WorkQueue.GlobalWorkQueue.MinWorkerThreads.ToString()); + info.AppendLine("Busy worker threads: " + WorkQueue.GlobalWorkQueue.BusyCount.ToString()); + info.AppendLine("Total worker threads: " + WorkQueue.GlobalWorkQueue.WorkerCount.ToString()); + info.AppendLine("Queued work items: " + WorkQueue.GlobalWorkQueue.QueuedCount.ToString()); foreach (WorkQueue.WorkItem workItem in WorkQueue.GlobalWorkQueue.GetQueuedWorkItems()) - { if (workItem.Tag != null) - { info.AppendLine("[" + workItem.Tag + "]: " + workItem.Work.Method.Name); - } else - { info.AppendLine(workItem.Work.Method.Name); - } - } info.AppendLine(); info.AppendLine("CLR THREAD POOL"); @@ -1042,6 +1042,31 @@ public static string GetDiagnosticInformation() info.AppendLine("PWindows: " + PWindows.Count.ToString() + ", " + PThreads.Count.ToString()); info.AppendLine("ResultsWindows: " + ResultsWindows.Count.ToString() + ", " + ResultsThreads.Count.ToString()); + //info.AppendLine(); + //info.AppendLine("LOADED MODULES"); + //info.AppendLine(); + + //foreach (ProcessModule module in ProcessHandle.Current.GetModules()) + //{ + // info.AppendLine("Module: " + module.BaseName); + // info.AppendLine("Location: " + module.FileName); + + // DateTime fileCreatedInfo = System.IO.File.GetCreationTime(module.FileName); + // info.AppendLine( + // "Created: " + fileCreatedInfo.ToLongDateString().ToString(System.Globalization.DateTimeFormatInfo.InvariantInfo) + " " + + // fileCreatedInfo.ToLongTimeString().ToString(System.Globalization.DateTimeFormatInfo.InvariantInfo) + // ); + + // DateTime fileModifiedInfo = System.IO.File.GetLastWriteTime(module.FileName); + // info.AppendLine( + // "Modified: " + fileModifiedInfo.ToLongDateString().ToString(System.Globalization.DateTimeFormatInfo.InvariantInfo) + " " + + // fileModifiedInfo.ToLongTimeString().ToString(System.Globalization.DateTimeFormatInfo.InvariantInfo) + // ); + + // info.AppendLine("Version: " + System.Diagnostics.FileVersionInfo.GetVersionInfo(module.FileName).FileVersion); + // info.AppendLine(); + //} + return info.ToString(); } @@ -1059,10 +1084,9 @@ private static void UnhandledException(Exception ex, bool terminating) { Logging.Log(Logging.Importance.Critical, ex.ToString()); - using (ErrorDialog ed = new ErrorDialog(ex, terminating)) - { - ed.ShowDialog(); - } + ErrorDialog ed = new ErrorDialog(ex, terminating); + + ed.ShowDialog(); } /// @@ -1073,7 +1097,7 @@ private static void UnhandledException(Exception ex, bool terminating) /// The length to edit public static MemoryEditor GetMemoryEditor(int PID, IntPtr address, long length) { - return GetMemoryEditor(PID, address, length, delegate {}); + return GetMemoryEditor(PID, address, length, new MemoryEditorInvokeAction(delegate {})); } /// @@ -1093,14 +1117,14 @@ public static MemoryEditor GetMemoryEditor(int PID, IntPtr address, long length, { ed = MemoryEditors[id]; - ed.BeginInvoke(action, ed); + ed.Invoke(action, ed); return ed; } if (MemoryEditorsThreaded) { - Thread t = new Thread(() => + Thread t = new Thread(new ThreadStart(delegate { ed = new MemoryEditor(PID, address, length); @@ -1110,7 +1134,7 @@ public static MemoryEditor GetMemoryEditor(int PID, IntPtr address, long length, Application.Run(ed); Program.MemoryEditorsThreads.Remove(id); - }, Utils.SixteenthStackSize); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); @@ -1134,7 +1158,7 @@ public static MemoryEditor GetMemoryEditor(int PID, IntPtr address, long length, /// public static ResultsWindow GetResultsWindow(int PID) { - return GetResultsWindow(PID, delegate { }); + return GetResultsWindow(PID, new ResultsWindowInvokeAction(delegate { })); } /// @@ -1144,30 +1168,28 @@ public static ResultsWindow GetResultsWindow(int PID) public static ResultsWindow GetResultsWindow(int PID, ResultsWindowInvokeAction action) { ResultsWindow rw = null; - string id = string.Empty; + string id = ""; if (ResultsWindowsThreaded) { - Thread t = new Thread(() => + Thread t = new Thread(new ThreadStart(delegate { rw = new ResultsWindow(PID); id = rw.Id; if (!rw.IsDisposed) - action(rw); + action(rw); if (!rw.IsDisposed) Application.Run(rw); Program.ResultsThreads.Remove(id); - }, Utils.SixteenthStackSize); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); - while (string.IsNullOrEmpty(id)) - Thread.Sleep(1); - + while (id == "") Thread.Sleep(1); Program.ResultsThreads.Add(id, t); } else @@ -1187,7 +1209,7 @@ public static ResultsWindow GetResultsWindow(int PID, ResultsWindowInvokeAction /// public static PEWindow GetPEWindow(string path) { - return GetPEWindow(path, delegate { }); + return GetPEWindow(path, new PEWindowInvokeAction(delegate { })); } /// @@ -1202,14 +1224,14 @@ public static PEWindow GetPEWindow(string path, PEWindowInvokeAction action) { pw = PEWindows[path]; - pw.BeginInvoke(action, pw); + pw.Invoke(action, pw); return pw; } if (PEWindowsThreaded) { - Thread t = new Thread(() => + Thread t = new Thread(new ThreadStart(delegate { pw = new PEWindow(path); @@ -1219,7 +1241,7 @@ public static PEWindow GetPEWindow(string path, PEWindowInvokeAction action) Application.Run(pw); Program.PEThreads.Remove(path); - }, Utils.SixteenthStackSize); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); @@ -1243,7 +1265,7 @@ public static PEWindow GetPEWindow(string path, PEWindowInvokeAction action) /// public static ProcessWindow GetProcessWindow(ProcessItem process) { - return GetProcessWindow(process, delegate { }); + return GetProcessWindow(process, new PWindowInvokeAction(delegate { })); } /// @@ -1258,14 +1280,14 @@ public static ProcessWindow GetProcessWindow(ProcessItem process, PWindowInvokeA { pw = PWindows[process.Pid]; - pw.BeginInvoke(action, pw); + pw.Invoke(action, pw); return pw; } if (PWindowsThreaded) { - Thread t = new Thread(() => + Thread t = new Thread(new ThreadStart(delegate { pw = new ProcessWindow(process); @@ -1275,7 +1297,7 @@ public static ProcessWindow GetProcessWindow(ProcessItem process, PWindowInvokeA Application.Run(pw); Program.PThreads.Remove(process.Pid); - }, Utils.SixteenthStackSize); + }), Utils.SixteenthStackSize); t.SetApartmentState(ApartmentState.STA); t.Start(); @@ -1294,11 +1316,25 @@ public static ProcessWindow GetProcessWindow(ProcessItem process, PWindowInvokeA return pw; } + /// + /// Does nothing. + /// + [System.Diagnostics.Conditional("NOT_DEFINED")] + public static void Void() + { + // Do nothing + int a = 0; + int b = a * (a + 0); + + for (a = 0; a < b; a++) + a += a * (a + b); + } + public static void FocusWindow(Form f) { if (f.InvokeRequired) { - f.BeginInvoke(new MethodInvoker(() => FocusWindow(f))); + f.BeginInvoke(new MethodInvoker(delegate { Program.FocusWindow(f); })); return; } @@ -1311,39 +1347,24 @@ public static void FocusWindow(Form f) f.Activate(); } - public static void UpdateWindowMenu(ToolStripMenuItem windowMenuItem, Form f) + public static void UpdateWindowMenu(Menu windowMenuItem, Form f) { WeakReference
fRef = new WeakReference(f); - windowMenuItem.DropDownItems.Clear(); - HackerWindow.AddMenuItemDelegate addMenuItem = (text, onClick) => windowMenuItem.DropDownItems.Add(text, null, onClick); - - addMenuItem("&Always On Top", (sender, e) => - { - Form targetForm = null; - - if (fRef.TryGetTarget(out targetForm)) - { - targetForm.BeginInvoke(new Action((bgTargetForm, ts) => - { - bgTargetForm.TopMost = !bgTargetForm.TopMost; - if (bgTargetForm == HackerWindow) - HackerWindowTopMost = bgTargetForm.TopMost; + windowMenuItem.MenuItems.DisposeAndClear(); - ts.Checked = HackerWindowTopMost; - }), targetForm, sender); - } - }); + MenuItem item; - addMenuItem("&Close", (sender, e) => - { - Form targetForm = null; + item = new MenuItem("&Always On Top"); + item.Tag = fRef; + item.Click += new EventHandler(windowAlwaysOnTopItemClicked); + item.Checked = f.TopMost; + windowMenuItem.MenuItems.Add(item); - if (fRef.TryGetTarget(out targetForm)) - { - targetForm.BeginInvoke(new Action(bgTargetForm => bgTargetForm.Close()), targetForm); - } - }); + item = new MenuItem("&Close"); + item.Tag = fRef; + item.Click += new EventHandler(windowCloseItemClicked); + windowMenuItem.MenuItems.Add(item); } public static void AddEscapeToClose(this Form f) @@ -1364,5 +1385,59 @@ public static void SetTopMost(this Form f) if (HackerWindowTopMost) f.TopMost = true; } + + /// + /// Floats the window on top of the main Process Hacker window. + /// + /// The form to float. + /// + /// Always call this method before calling InitializeComponent in order for the + /// parent to be restored properly. + /// + public static void SetPhParent(this Form f) + { + f.SetPhParent(true); + } + + public static void SetPhParent(this Form f, bool hideInTaskbar) + { + if (Settings.Instance.FloatChildWindows) + { + if (hideInTaskbar) + f.ShowInTaskbar = false; + + IntPtr oldParent = Win32.SetWindowLongPtr(f.Handle, GetWindowLongOffset.HwndParent, Program.HackerWindowHandle); + + //f.FormClosing += (sender, e) => Win32.SetWindowLongPtr(f.Handle, GetWindowLongOffset.HwndParent, oldParent); + } + } + + private static void windowAlwaysOnTopItemClicked(object sender, EventArgs e) + { + Form f = ((WeakReference)((MenuItem)sender).Tag).Target; + + if (f == null) + return; + + f.Invoke(new MethodInvoker(delegate + { + f.TopMost = !f.TopMost; + + if (f == HackerWindow) + HackerWindowTopMost = f.TopMost; + })); + + UpdateWindowMenu(((MenuItem)sender).Parent, f); + } + + private static void windowCloseItemClicked(object sender, EventArgs e) + { + Form f = ((WeakReference)((MenuItem)sender).Tag).Target; + + if (f == null) + return; + + f.Invoke(new MethodInvoker(delegate { f.Close(); })); + } } } diff --git a/1.x/trunk/ProcessHacker/Program/Save.cs b/1.x/trunk/ProcessHacker/Program/Save.cs index 9a782f4ef..8bf5b4bbe 100644 --- a/1.x/trunk/ProcessHacker/Program/Save.cs +++ b/1.x/trunk/ProcessHacker/Program/Save.cs @@ -88,7 +88,7 @@ public static void SaveToFile(IWin32Window owner) progressWindow.ProgressBarStyle = ProgressBarStyle.Marquee; progressWindow.ProgressText = "Creating the dump file..."; - dumpTask.Completed += result => + dumpTask.Completed += (result) => { progressWindow.SetCompleted(); @@ -216,8 +216,8 @@ private static string GetProcessTreeText(bool tabs) // Fill in the cell. str[i + 1][columnIndex] = // If this is the first column in the row, add some indentation. - (columnIndex == 0 ? (new string(' ', (node.Level - 1) * 2)) : string.Empty) + - (text != null ? text : string.Empty); + (columnIndex == 0 ? (new string(' ', (node.Level - 1) * 2)) : "") + + (text != null ? text : ""); } i++; @@ -286,9 +286,9 @@ private static string GetProcessDetailsText(int pid) try { - using (ProcessHandle phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) + using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) { - var fileName = phandle.ImageFileName; + var fileName = phandle.GetImageFileName(); sb.AppendLine("Native file name: " + fileName); fileName = FileUtils.GetFileName(fileName); @@ -307,9 +307,9 @@ private static string GetProcessDetailsText(int pid) sb.AppendLine("Version info section failed! " + ex2.Message); } - sb.AppendLine("Started: " + phandle.CreateTime); + sb.AppendLine("Started: " + phandle.GetCreateTime().ToString()); - var memoryInfo = phandle.MemoryStatistics; + var memoryInfo = phandle.GetMemoryStatistics(); sb.AppendLine("WS: " + Utils.FormatSize(memoryInfo.WorkingSetSize)); sb.AppendLine("Pagefile usage: " + Utils.FormatSize(memoryInfo.PagefileUsage)); @@ -324,7 +324,7 @@ private static string GetProcessDetailsText(int pid) { using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights | ProcessAccess.VmRead)) { - var commandLine = phandle.CommandLine; + var commandLine = phandle.GetCommandLine(); var currentDirectory = phandle.GetPebString(PebOffset.CurrentDirectoryPath); sb.AppendLine("Command line: " + commandLine); @@ -381,16 +381,16 @@ private static string GetProcessDetailsText(int pid) using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) using (var thandle = phandle.GetToken(TokenAccess.Query)) { - sb.AppendLine("User: " + thandle.User.GetFullName(true)); - sb.AppendLine("Owner: " + thandle.Owner.GetFullName(true)); - sb.AppendLine("Primary group: " + thandle.PrimaryGroup.GetFullName(true)); + sb.AppendLine("User: " + thandle.GetUser().GetFullName(true)); + sb.AppendLine("Owner: " + thandle.GetOwner().GetFullName(true)); + sb.AppendLine("Primary group: " + thandle.GetPrimaryGroup().GetFullName(true)); - foreach (var group in thandle.Groups) + foreach (var group in thandle.GetGroups()) { sb.AppendLine("Group " + group.GetFullName(true)); } - foreach (var privilege in thandle.Privileges) + foreach (var privilege in thandle.GetPrivileges()) { sb.AppendLine("Privilege " + privilege.Name + ": " + privilege.Attributes.ToString()); } diff --git a/1.x/trunk/ProcessHacker/Program/Settings.cs b/1.x/trunk/ProcessHacker/Program/Settings.cs index 10c07c610..9b6d84827 100644 --- a/1.x/trunk/ProcessHacker/Program/Settings.cs +++ b/1.x/trunk/ProcessHacker/Program/Settings.cs @@ -1,4 +1,9 @@ -using System.Drawing; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using System.Xml; +using ProcessHacker.Common; using ProcessHacker.Common.Settings; using System.Windows.Forms; @@ -52,6 +57,7 @@ public override void Invalidate() _colorWow64Processes = null; _deletedServices = null; _elevationLevel = (int)this["ElevationLevel"]; + _floatChildWindows = null; _font = null; _hideWhenClosed = null; _hideWhenMinimized = null; @@ -365,11 +371,19 @@ public bool FirstRun set { this["FirstRun"] = value; } } + private bool? _floatChildWindows; + [SettingDefault("True")] + public bool FloatChildWindows + { + get { return _floatChildWindows.HasValue ? _floatChildWindows.Value : (_floatChildWindows = (bool)this["FloatChildWindows"]).Value; } + set { this["FloatChildWindows"] = _floatChildWindows = value; } + } + private Font _font; [SettingDefault("Microsoft Sans Serif, 8.25pt")] public Font Font { - get { return this._font ?? (this._font = (Font)this["Font"]); } + get { return _font != null ? _font : (_font = (Font)this["Font"]); } set { this["Font"] = _font = value; } } diff --git a/1.x/trunk/ProcessHacker/Program/ThemingScope.cs b/1.x/trunk/ProcessHacker/Program/ThemingScope.cs new file mode 100644 index 000000000..5d260e836 --- /dev/null +++ b/1.x/trunk/ProcessHacker/Program/ThemingScope.cs @@ -0,0 +1,27 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace ProcessHacker +{ + public static class ThemingScope + { + [DllImport("kernel32.dll")] + private static extern bool ActivateActCtx(IntPtr hActCtx, out IntPtr lpCookie); + + public static void Activate() + { + IntPtr zero = IntPtr.Zero; + Assembly windowsForms = Assembly.GetAssembly(typeof(Control)); + + // HACK + IntPtr hActCtx = (IntPtr)windowsForms.GetType("System.Windows.Forms.UnsafeNativeMethods", true). + GetNestedType("ThemingScope", BindingFlags.NonPublic | BindingFlags.Static). + GetField("hActCtx", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); + + if (OSFeature.Feature.IsPresent(OSFeature.Themes)) + ActivateActCtx(hActCtx, out zero); + } + } +} diff --git a/1.x/trunk/ProcessHacker/Program/Updater.cs b/1.x/trunk/ProcessHacker/Program/Updater.cs index ab62dd506..275d414c0 100644 --- a/1.x/trunk/ProcessHacker/Program/Updater.cs +++ b/1.x/trunk/ProcessHacker/Program/Updater.cs @@ -187,16 +187,15 @@ private static void PromptWithUpdate(Form form, UpdateItem bestUpdate, UpdateIte { if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog - { - PositionRelativeToWindow = true, - Content = "Your Version: " + currentVersion.Version + "\nServer Version: " + bestUpdate.Version, - MainInstruction = "Process Hacker is up-to-date", - WindowTitle = "No updates available", - MainIcon = TaskDialogIcon.SecuritySuccess, - CommonButtons = TaskDialogCommonButtons.Ok - }; - + TaskDialog td = new TaskDialog(); + td.PositionRelativeToWindow = true; + td.Content = + "Your Version: " + currentVersion.Version.ToString() + + "\nServer Version: " + bestUpdate.Version.ToString(); + td.MainInstruction = "Process Hacker is up-to-date"; + td.WindowTitle = "No updates available"; + td.MainIcon = TaskDialogIcon.SecuritySuccess; + td.CommonButtons = TaskDialogCommonButtons.Ok; td.Show(form); } else diff --git a/1.x/trunk/ProcessHacker/Properties/Resources.Designer.cs b/1.x/trunk/ProcessHacker/Properties/Resources.Designer.cs index bb6926b36..c31cf9bc6 100644 --- a/1.x/trunk/ProcessHacker/Properties/Resources.Designer.cs +++ b/1.x/trunk/ProcessHacker/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18331 +// Runtime Version:4.0.30319.235 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -60,9 +60,6 @@ internal Resources() { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap active_search { get { object obj = ResourceManager.GetObject("active_search", resourceCulture); @@ -70,9 +67,6 @@ internal static System.Drawing.Bitmap active_search { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap application { get { object obj = ResourceManager.GetObject("application", resourceCulture); @@ -80,9 +74,6 @@ internal static System.Drawing.Bitmap application { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap application_delete { get { object obj = ResourceManager.GetObject("application_delete", resourceCulture); @@ -90,9 +81,6 @@ internal static System.Drawing.Bitmap application_delete { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap application_form_magnify { get { object obj = ResourceManager.GetObject("application_form_magnify", resourceCulture); @@ -100,9 +88,6 @@ internal static System.Drawing.Bitmap application_form_magnify { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap application_go { get { object obj = ResourceManager.GetObject("application_go", resourceCulture); @@ -110,9 +95,6 @@ internal static System.Drawing.Bitmap application_go { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap application_view_detail { get { object obj = ResourceManager.GetObject("application_view_detail", resourceCulture); @@ -120,9 +102,6 @@ internal static System.Drawing.Bitmap application_view_detail { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap arrow_refresh { get { object obj = ResourceManager.GetObject("arrow_refresh", resourceCulture); @@ -130,9 +109,6 @@ internal static System.Drawing.Bitmap arrow_refresh { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap arrow_right { get { object obj = ResourceManager.GetObject("arrow_right", resourceCulture); @@ -140,9 +116,6 @@ internal static System.Drawing.Bitmap arrow_right { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap arrow_up { get { object obj = ResourceManager.GetObject("arrow_up", resourceCulture); @@ -150,9 +123,6 @@ internal static System.Drawing.Bitmap arrow_up { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap asterisk_orange { get { object obj = ResourceManager.GetObject("asterisk_orange", resourceCulture); @@ -160,9 +130,6 @@ internal static System.Drawing.Bitmap asterisk_orange { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap bricks { get { object obj = ResourceManager.GetObject("bricks", resourceCulture); @@ -170,9 +137,6 @@ internal static System.Drawing.Bitmap bricks { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap chart_curve { get { object obj = ResourceManager.GetObject("chart_curve", resourceCulture); @@ -180,9 +144,6 @@ internal static System.Drawing.Bitmap chart_curve { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap chart_line { get { object obj = ResourceManager.GetObject("chart_line", resourceCulture); @@ -190,9 +151,6 @@ internal static System.Drawing.Bitmap chart_line { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap cog { get { object obj = ResourceManager.GetObject("cog", resourceCulture); @@ -200,9 +158,6 @@ internal static System.Drawing.Bitmap cog { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap cog_edit { get { object obj = ResourceManager.GetObject("cog_edit", resourceCulture); @@ -210,9 +165,6 @@ internal static System.Drawing.Bitmap cog_edit { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_equalizer { get { object obj = ResourceManager.GetObject("control_equalizer", resourceCulture); @@ -220,9 +172,6 @@ internal static System.Drawing.Bitmap control_equalizer { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_equalizer_blue { get { object obj = ResourceManager.GetObject("control_equalizer_blue", resourceCulture); @@ -230,9 +179,6 @@ internal static System.Drawing.Bitmap control_equalizer_blue { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_pause { get { object obj = ResourceManager.GetObject("control_pause", resourceCulture); @@ -240,9 +186,6 @@ internal static System.Drawing.Bitmap control_pause { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_pause_blue { get { object obj = ResourceManager.GetObject("control_pause_blue", resourceCulture); @@ -250,9 +193,6 @@ internal static System.Drawing.Bitmap control_pause_blue { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_play { get { object obj = ResourceManager.GetObject("control_play", resourceCulture); @@ -260,9 +200,6 @@ internal static System.Drawing.Bitmap control_play { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_play_blue { get { object obj = ResourceManager.GetObject("control_play_blue", resourceCulture); @@ -270,9 +207,6 @@ internal static System.Drawing.Bitmap control_play_blue { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_stop { get { object obj = ResourceManager.GetObject("control_stop", resourceCulture); @@ -280,9 +214,6 @@ internal static System.Drawing.Bitmap control_stop { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap control_stop_blue { get { object obj = ResourceManager.GetObject("control_stop_blue", resourceCulture); @@ -290,9 +221,6 @@ internal static System.Drawing.Bitmap control_stop_blue { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap cross { get { object obj = ResourceManager.GetObject("cross", resourceCulture); @@ -300,9 +228,6 @@ internal static System.Drawing.Bitmap cross { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap delete { get { object obj = ResourceManager.GetObject("delete", resourceCulture); @@ -310,9 +235,6 @@ internal static System.Drawing.Bitmap delete { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap disk { get { object obj = ResourceManager.GetObject("disk", resourceCulture); @@ -320,9 +242,6 @@ internal static System.Drawing.Bitmap disk { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap door_out { get { object obj = ResourceManager.GetObject("door_out", resourceCulture); @@ -330,19 +249,6 @@ internal static System.Drawing.Bitmap door_out { } } - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] DVSplit { - get { - object obj = ResourceManager.GetObject("DVSplit", resourceCulture); - return ((byte[])(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap find { get { object obj = ResourceManager.GetObject("find", resourceCulture); @@ -350,9 +256,6 @@ internal static System.Drawing.Bitmap find { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap folder { get { object obj = ResourceManager.GetObject("folder", resourceCulture); @@ -360,9 +263,6 @@ internal static System.Drawing.Bitmap folder { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap folder_explore { get { object obj = ResourceManager.GetObject("folder_explore", resourceCulture); @@ -370,9 +270,6 @@ internal static System.Drawing.Bitmap folder_explore { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap folder_go { get { object obj = ResourceManager.GetObject("folder_go", resourceCulture); @@ -380,9 +277,6 @@ internal static System.Drawing.Bitmap folder_go { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap group { get { object obj = ResourceManager.GetObject("group", resourceCulture); @@ -390,9 +284,6 @@ internal static System.Drawing.Bitmap group { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap help { get { object obj = ResourceManager.GetObject("help", resourceCulture); @@ -400,9 +291,6 @@ internal static System.Drawing.Bitmap help { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap inactive_search { get { object obj = ResourceManager.GetObject("inactive_search", resourceCulture); @@ -410,9 +298,6 @@ internal static System.Drawing.Bitmap inactive_search { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap information { get { object obj = ResourceManager.GetObject("information", resourceCulture); @@ -420,9 +305,6 @@ internal static System.Drawing.Bitmap information { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap lightbulb_off { get { object obj = ResourceManager.GetObject("lightbulb_off", resourceCulture); @@ -430,19 +312,6 @@ internal static System.Drawing.Bitmap lightbulb_off { } } - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] loading_icon { - get { - object obj = ResourceManager.GetObject("loading_icon", resourceCulture); - return ((byte[])(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap lock_edit { get { object obj = ResourceManager.GetObject("lock_edit", resourceCulture); @@ -450,9 +319,6 @@ internal static System.Drawing.Bitmap lock_edit { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap locked { get { object obj = ResourceManager.GetObject("locked", resourceCulture); @@ -460,19 +326,6 @@ internal static System.Drawing.Bitmap locked { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap minus { - get { - object obj = ResourceManager.GetObject("minus", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap money { get { object obj = ResourceManager.GetObject("money", resourceCulture); @@ -480,9 +333,6 @@ internal static System.Drawing.Bitmap money { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap mouse { get { object obj = ResourceManager.GetObject("mouse", resourceCulture); @@ -490,9 +340,6 @@ internal static System.Drawing.Bitmap mouse { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap page { get { object obj = ResourceManager.GetObject("page", resourceCulture); @@ -500,9 +347,6 @@ internal static System.Drawing.Bitmap page { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap page_copy { get { object obj = ResourceManager.GetObject("page_copy", resourceCulture); @@ -510,9 +354,6 @@ internal static System.Drawing.Bitmap page_copy { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap page_edit { get { object obj = ResourceManager.GetObject("page_edit", resourceCulture); @@ -520,9 +361,6 @@ internal static System.Drawing.Bitmap page_edit { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap page_gear { get { object obj = ResourceManager.GetObject("page_gear", resourceCulture); @@ -530,9 +368,6 @@ internal static System.Drawing.Bitmap page_gear { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap page_save { get { object obj = ResourceManager.GetObject("page_save", resourceCulture); @@ -540,9 +375,6 @@ internal static System.Drawing.Bitmap page_save { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap page_white_text { get { object obj = ResourceManager.GetObject("page_white_text", resourceCulture); @@ -550,9 +382,6 @@ internal static System.Drawing.Bitmap page_white_text { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap pencil { get { object obj = ResourceManager.GetObject("pencil", resourceCulture); @@ -560,9 +389,6 @@ internal static System.Drawing.Bitmap pencil { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap pencil_go { get { object obj = ResourceManager.GetObject("pencil_go", resourceCulture); @@ -570,19 +396,6 @@ internal static System.Drawing.Bitmap pencil_go { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap plus { - get { - object obj = ResourceManager.GetObject("plus", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). - /// internal static System.Drawing.Icon Process { get { object obj = ResourceManager.GetObject("Process", resourceCulture); @@ -590,9 +403,6 @@ internal static System.Drawing.Icon Process { } } - /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). - /// internal static System.Drawing.Icon Process_small { get { object obj = ResourceManager.GetObject("Process_small", resourceCulture); @@ -600,9 +410,6 @@ internal static System.Drawing.Icon Process_small { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap ProcessHacker { get { object obj = ResourceManager.GetObject("ProcessHacker", resourceCulture); @@ -610,9 +417,6 @@ internal static System.Drawing.Bitmap ProcessHacker { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap report { get { object obj = ResourceManager.GetObject("report", resourceCulture); @@ -620,9 +424,6 @@ internal static System.Drawing.Bitmap report { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap report_user { get { object obj = ResourceManager.GetObject("report_user", resourceCulture); @@ -630,9 +431,6 @@ internal static System.Drawing.Bitmap report_user { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap sflogo { get { object obj = ResourceManager.GetObject("sflogo", resourceCulture); @@ -640,9 +438,6 @@ internal static System.Drawing.Bitmap sflogo { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap table { get { object obj = ResourceManager.GetObject("table", resourceCulture); @@ -650,9 +445,6 @@ internal static System.Drawing.Bitmap table { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap table_relationship { get { object obj = ResourceManager.GetObject("table_relationship", resourceCulture); @@ -660,9 +452,6 @@ internal static System.Drawing.Bitmap table_relationship { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap table_sort { get { object obj = ResourceManager.GetObject("table_sort", resourceCulture); @@ -670,9 +459,6 @@ internal static System.Drawing.Bitmap table_sort { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap tick { get { object obj = ResourceManager.GetObject("tick", resourceCulture); @@ -680,9 +466,6 @@ internal static System.Drawing.Bitmap tick { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap user { get { object obj = ResourceManager.GetObject("user", resourceCulture); @@ -690,9 +473,6 @@ internal static System.Drawing.Bitmap user { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// internal static System.Drawing.Bitmap VirusTotal_logo { get { object obj = ResourceManager.GetObject("VirusTotal_logo", resourceCulture); diff --git a/1.x/trunk/ProcessHacker/Properties/Resources.resx b/1.x/trunk/ProcessHacker/Properties/Resources.resx index e096e2820..a9b040a4a 100644 --- a/1.x/trunk/ProcessHacker/Properties/Resources.resx +++ b/1.x/trunk/ProcessHacker/Properties/Resources.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + ..\Resources\application_go.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -298,16 +298,4 @@ ..\Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\components\treeviewadv\resources\dvsplit.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\components\treeviewadv\resources\loading_icon;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\components\treeviewadv\resources\minus.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\components\treeviewadv\resources\plus.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Providers/HandleProvider.cs b/1.x/trunk/ProcessHacker/Providers/HandleProvider.cs index 571d23f20..a1bea8bdc 100644 --- a/1.x/trunk/ProcessHacker/Providers/HandleProvider.cs +++ b/1.x/trunk/ProcessHacker/Providers/HandleProvider.cs @@ -42,12 +42,13 @@ public object Clone() public class HandleProvider : Provider { - private readonly ProcessHandle _processHandle; - private readonly int _pid; + private ProcessHandle _processHandle; + private int _pid; public HandleProvider(int pid) + : base() { - this.Name = "HandleProvider"; + this.Name = this.GetType().Name; _pid = pid; try @@ -64,7 +65,7 @@ public HandleProvider(int pid) { } } - this.Disposed += provider => { if (_processHandle != null) _processHandle.Dispose(); }; + this.Disposed += (provider) => { if (_processHandle != null) _processHandle.Dispose(); }; } protected override void Update() @@ -108,7 +109,8 @@ protected override void Update() { info = processHandles[h].GetHandleInfo(_processHandle); - if (string.IsNullOrEmpty(info.BestName) && HideHandlesWithNoName) + if ((info.BestName == null || info.BestName == "") && + HideHandlesWithNoName) continue; } catch diff --git a/1.x/trunk/ProcessHacker/Providers/MemoryProvider.cs b/1.x/trunk/ProcessHacker/Providers/MemoryProvider.cs index 6728fc5dc..b9fb9d9c2 100644 --- a/1.x/trunk/ProcessHacker/Providers/MemoryProvider.cs +++ b/1.x/trunk/ProcessHacker/Providers/MemoryProvider.cs @@ -43,26 +43,29 @@ public object Clone() public MemoryType Type; public MemoryState State; public MemoryProtection Protection; + } public class MemoryProvider : Provider { - private readonly ProcessHandle _processHandle; - private readonly int _pid; + private ProcessHandle _processHandle; + private int _pid; public MemoryProvider(int pid) + : base() { - this.Name = "MemoryProvider"; + this.Name = this.GetType().Name; _pid = pid; try { - _processHandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights); + _processHandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | + Program.MinProcessReadMemoryRights); } catch { } - this.Disposed += provider => { if (_processHandle != null) _processHandle.Dispose(); }; + this.Disposed += (provider) => { if (_processHandle != null) _processHandle.Dispose(); }; } protected override void Update() @@ -83,13 +86,14 @@ protected override void Update() var memoryInfo = new Dictionary(); var newdictionary = new Dictionary(this.Dictionary); - _processHandle.EnumMemory(info => - { - if ((this.IgnoreFreeRegions && info.State != MemoryState.Free) || !this.IgnoreFreeRegions) - memoryInfo.Add(info.BaseAddress, info); + _processHandle.EnumMemory((info) => + { + if ((this.IgnoreFreeRegions && info.State != MemoryState.Free) || + !this.IgnoreFreeRegions) + memoryInfo.Add(info.BaseAddress, info); - return true; - }); + return true; + }); // look for freed memory regions foreach (IntPtr address in Dictionary.Keys) @@ -107,19 +111,18 @@ protected override void Update() foreach (IntPtr address in memoryInfo.Keys) { - MemoryBasicInformation info = memoryInfo[address]; + var info = memoryInfo[address]; if (!this.Dictionary.ContainsKey(address)) { - MemoryItem item = new MemoryItem - { - RunId = this.RunCount, - Address = address, - Size = info.RegionSize.ToInt64(), - Type = info.Type, - State = info.State, - Protection = info.Protect - }; + MemoryItem item = new MemoryItem(); + + item.RunId = this.RunCount; + item.Address = address; + item.Size = info.RegionSize.ToInt64(); + item.Type = info.Type; + item.State = info.State; + item.Protection = info.Protect; if (modules.ContainsKey(item.Address)) { diff --git a/1.x/trunk/ProcessHacker/Providers/ModuleProvider.cs b/1.x/trunk/ProcessHacker/Providers/ModuleProvider.cs index 7cbaf2b12..8c33c45a1 100644 --- a/1.x/trunk/ProcessHacker/Providers/ModuleProvider.cs +++ b/1.x/trunk/ProcessHacker/Providers/ModuleProvider.cs @@ -51,24 +51,27 @@ public object Clone() public class ModuleProvider : Provider { - private readonly ProcessHandle _processHandle; - private readonly int _pid; - private readonly bool _isWow64; + private ProcessHandle _processHandle; + private int _pid; + private bool _isWow64 = false; public ModuleProvider(int pid) + : base() { this.Name = this.GetType().Name; _pid = pid; try { - _processHandle = new ProcessHandle(_pid, ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights); + _processHandle = new ProcessHandle(_pid, + ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights); } catch { try { - _processHandle = new ProcessHandle(_pid, Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights); + _processHandle = new ProcessHandle(_pid, + Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights); } catch { } @@ -78,13 +81,13 @@ public ModuleProvider(int pid) { try { - _isWow64 = _processHandle.IsWow64; + _isWow64 = _processHandle.IsWow64(); } catch { } } - this.Disposed += provider => { if (_processHandle != null) _processHandle.Dispose(); }; + this.Disposed += (provider) => { if (_processHandle != null) _processHandle.Dispose(); }; } protected override void Update() @@ -103,13 +106,13 @@ protected override void Update() // Is this a WOW64 process? If it is, get the 32-bit modules. if (!_isWow64) { - _processHandle.EnumModules(module => - { - if (!modules.ContainsKey(module.BaseAddress)) - modules.Add(module.BaseAddress, module); + _processHandle.EnumModules((module) => + { + if (!modules.ContainsKey(module.BaseAddress)) + modules.Add(module.BaseAddress, module); - return true; - }); + return true; + }); } else { @@ -146,7 +149,7 @@ protected override void Update() } // add mapped files - _processHandle.EnumMemory(info => + _processHandle.EnumMemory((info) => { if (info.Type == MemoryType.Mapped) { @@ -177,7 +180,7 @@ protected override void Update() else { // Add loaded kernel modules. - Windows.EnumKernelModules(module => + Windows.EnumKernelModules((module) => { if (!modules.ContainsKey(module.BaseAddress)) modules.Add(module.BaseAddress, module); @@ -202,13 +205,10 @@ protected override void Update() if (!Dictionary.ContainsKey(b)) { var m = modules[b]; + ModuleItem item = new ModuleItem(); - ModuleItem item = new ModuleItem - { - RunId = this.RunCount, - Name = m.BaseName - }; - + item.RunId = this.RunCount; + item.Name = m.BaseName; try { diff --git a/1.x/trunk/ProcessHacker/Providers/NetworkProvider.cs b/1.x/trunk/ProcessHacker/Providers/NetworkProvider.cs index 8f114ac37..a105432a1 100644 --- a/1.x/trunk/ProcessHacker/Providers/NetworkProvider.cs +++ b/1.x/trunk/ProcessHacker/Providers/NetworkProvider.cs @@ -60,28 +60,30 @@ private class AddressResolveMessage : Message public string HostName; } - private readonly MessageQueue _messageQueue = new MessageQueue(); - private readonly Dictionary _resolveCache = new Dictionary(); - private readonly FastResourceLock _resolveCacheLock = new FastResourceLock(); + private MessageQueue _messageQueue = new MessageQueue(); + private Dictionary _resolveCache = new Dictionary(); + private FastResourceLock _resolveCacheLock = new FastResourceLock(); public NetworkProvider() + : base() { - this.Name = "NetworkProvider"; + this.Name = this.GetType().Name; - _messageQueue.AddListener(new MessageQueueListener(message => - { - if (Dictionary.ContainsKey(message.Id)) + _messageQueue.AddListener( + new MessageQueueListener((message) => { - var item = Dictionary[message.Id]; + if (Dictionary.ContainsKey(message.Id)) + { + var item = Dictionary[message.Id]; - if (message.Remote) - item.RemoteString = message.HostName; - else - item.LocalString = message.HostName; + if (message.Remote) + item.RemoteString = message.HostName; + else + item.LocalString = message.HostName; - item.JustProcessed = true; - } - })); + item.JustProcessed = true; + } + })); } protected override void Update() @@ -116,12 +118,10 @@ protected override void Update() foreach (string s in preKeyDict.Keys) { var connection = preKeyDict[s].Value; - NetworkItem item = new NetworkItem - { - Id = s + "-" + preKeyDict[s].Key.ToString(), - Connection = connection - }; + NetworkItem item = new NetworkItem(); + item.Id = s + "-" + preKeyDict[s].Key.ToString(); + item.Connection = connection; keyDict.Add(s + "-" + preKeyDict[s].Key.ToString(), item); } @@ -301,7 +301,7 @@ private void ResolveAddresses(string id, bool remote, IPAddress address) } } - _messageQueue.Enqueue(new AddressResolveMessage + _messageQueue.Enqueue(new AddressResolveMessage() { Id = id, Remote = remote, diff --git a/1.x/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs b/1.x/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs index bfbef6536..380c80152 100644 --- a/1.x/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs +++ b/1.x/trunk/ProcessHacker/Providers/ProcessSystemProvider.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Drawing; using System.Runtime.InteropServices; @@ -61,7 +62,7 @@ public class ProcessItem : ICloneable { public object Clone() { - return this.MemberwiseClone(); + return base.MemberwiseClone(); } public int RunId; @@ -167,9 +168,9 @@ public SystemPerformanceInformation Performance get { return _performance; } } - private readonly int _processorPerfArraySize; - private readonly MemoryAlloc _processorPerfBuffer; - private readonly SystemProcessorPerformanceInformation[] _processorPerfArray; + private int _processorPerfArraySize; + private MemoryAlloc _processorPerfBuffer; + private SystemProcessorPerformanceInformation[] _processorPerfArray; public SystemProcessorPerformanceInformation[] ProcessorPerfArray { get { return _processorPerfArray; } @@ -208,16 +209,16 @@ public SystemProcessorPerformanceInformation ProcessorPerf public IList[] CpusKernelHistory { get { return _cpusKernelHistory; } } public IList[] CpusUserHistory { get { return _cpusUserHistory; } } public IList[] CpusOtherHistory { get { return _cpusOtherHistory; } } - public CircularList CommitHistory { get { return _commitHistory; } } - public CircularList PhysicalMemoryHistory { get { return _physicalMemoryHistory; } } + public IList CommitHistory { get { return _commitHistory; } } + public IList PhysicalMemoryHistory { get { return _physicalMemoryHistory; } } public IList TimeHistory { get { return _timeHistory; } } public IList MostCpuHistory { get { return _cpuMostUsageHistory; } } public IList MostIoHistory { get { return _ioMostUsageHistory; } } private delegate ProcessQueryMessage QueryProcessDelegate(int pid, string fileName, bool useCache); - private readonly MessageQueue _messageQueue = new MessageQueue(); - private readonly Dictionary _fileResults = new Dictionary(); + private MessageQueue _messageQueue = new MessageQueue(); + private Dictionary _fileResults = new Dictionary(); private Int64Delta _ioReadDelta; private Int64Delta _ioWriteDelta; @@ -225,31 +226,31 @@ public SystemProcessorPerformanceInformation ProcessorPerf private Int64Delta _cpuKernelDelta; private Int64Delta _cpuUserDelta; private Int64Delta _cpuOtherDelta; - private readonly Int64Delta[] _cpuKernelDeltas; - private readonly Int64Delta[] _cpuUserDeltas; - private readonly Int64Delta[] _cpuOtherDeltas; + private Int64Delta[] _cpuKernelDeltas; + private Int64Delta[] _cpuUserDeltas; + private Int64Delta[] _cpuOtherDeltas; private int _historyMaxSize = 100; - private readonly CircularBuffer _ioReadHistory; - private readonly CircularBuffer _ioWriteHistory; - private readonly CircularBuffer _ioOtherHistory; - private readonly CircularBuffer _ioReadOtherHistory; - private readonly CircularBuffer _cpuKernelHistory; - private readonly CircularBuffer _cpuUserHistory; - private readonly CircularBuffer _cpuOtherHistory; - private readonly CircularBuffer[] _cpusKernelHistory; - private readonly CircularBuffer[] _cpusUserHistory; - private readonly CircularBuffer[] _cpusOtherHistory; - private readonly CircularList _commitHistory; - private readonly CircularList _physicalMemoryHistory; - private readonly CircularBuffer _timeHistory; - private readonly CircularBuffer _cpuMostUsageHistory; - private readonly CircularBuffer _ioMostUsageHistory; - - private SystemProcess _dpcs = new SystemProcess + private CircularBuffer _ioReadHistory; + private CircularBuffer _ioWriteHistory; + private CircularBuffer _ioOtherHistory; + private CircularBuffer _ioReadOtherHistory; + private CircularBuffer _cpuKernelHistory; + private CircularBuffer _cpuUserHistory; + private CircularBuffer _cpuOtherHistory; + private CircularBuffer[] _cpusKernelHistory; + private CircularBuffer[] _cpusUserHistory; + private CircularBuffer[] _cpusOtherHistory; + private CircularBuffer _commitHistory; + private CircularBuffer _physicalMemoryHistory; + private CircularBuffer _timeHistory; + private CircularBuffer _cpuMostUsageHistory; + private CircularBuffer _ioMostUsageHistory; + + private SystemProcess _dpcs = new SystemProcess() { Name = "DPCs", - Process = new SystemProcessInformation + Process = new SystemProcessInformation() { ProcessId = -2, InheritedFromProcessId = 0, @@ -257,10 +258,10 @@ public SystemProcessorPerformanceInformation ProcessorPerf } }; - private SystemProcess _interrupts = new SystemProcess + private SystemProcess _interrupts = new SystemProcess() { Name = "Interrupts", - Process = new SystemProcessInformation + Process = new SystemProcessInformation() { ProcessId = -3, InheritedFromProcessId = 0, @@ -269,33 +270,31 @@ public SystemProcessorPerformanceInformation ProcessorPerf }; public ProcessSystemProvider() + : base() { - this.Name = "ProcessSystemProvider"; + this.Name = this.GetType().Name; // Add the file processing results listener. - _messageQueue.AddListener(new MessageQueueListener(message => - { - if (this.Dictionary.ContainsKey(message.Pid)) - { - ProcessItem item = this.Dictionary[message.Pid]; + _messageQueue.AddListener( + new MessageQueueListener((message) => + { + if (this.Dictionary.ContainsKey(message.Pid)) + { + ProcessItem item = this.Dictionary[message.Pid]; - this.FillPqResult(item, message); - item.JustProcessed = true; - } - })); + this.FillPqResult(item, message); + item.JustProcessed = true; + } + })); SystemBasicInformation basic; int retLen; - Win32.NtQuerySystemInformation( - SystemInformationClass.SystemBasicInformation, - out basic, - SystemBasicInformation.SizeOf, - out retLen - ); - + Win32.NtQuerySystemInformation(SystemInformationClass.SystemBasicInformation, out basic, + Marshal.SizeOf(typeof(SystemBasicInformation)), out retLen); _system = basic; - _processorPerfArraySize = SystemProcessorPerformanceInformation.SizeOf * _system.NumberOfProcessors; + _processorPerfArraySize = Marshal.SizeOf(typeof(SystemProcessorPerformanceInformation)) * + _system.NumberOfProcessors; _processorPerfBuffer = new MemoryAlloc(_processorPerfArraySize); _processorPerfArray = new SystemProcessorPerformanceInformation[_system.NumberOfProcessors]; @@ -305,7 +304,8 @@ out retLen _cpuKernelDelta = new Int64Delta(this.ProcessorPerf.KernelTime); _cpuUserDelta = new Int64Delta(this.ProcessorPerf.UserTime); - _cpuOtherDelta = new Int64Delta(this.ProcessorPerf.IdleTime + this.ProcessorPerf.DpcTime + this.ProcessorPerf.InterruptTime); + _cpuOtherDelta = new Int64Delta( + this.ProcessorPerf.IdleTime + this.ProcessorPerf.DpcTime + this.ProcessorPerf.InterruptTime); _ioReadDelta = new Int64Delta(this.Performance.IoReadTransferCount); _ioWriteDelta = new Int64Delta(this.Performance.IoWriteTransferCount); _ioOtherDelta = new Int64Delta(this.Performance.IoOtherTransferCount); @@ -319,8 +319,8 @@ out retLen _ioWriteHistory = new CircularBuffer(_historyMaxSize); _ioOtherHistory = new CircularBuffer(_historyMaxSize); _ioReadOtherHistory = new CircularBuffer(_historyMaxSize); - _commitHistory = new CircularList(_historyMaxSize); - _physicalMemoryHistory = new CircularList(_historyMaxSize); + _commitHistory = new CircularBuffer(_historyMaxSize); + _physicalMemoryHistory = new CircularBuffer(_historyMaxSize); _timeHistory = new CircularBuffer(_historyMaxSize); _ioMostUsageHistory = new CircularBuffer(_historyMaxSize); _cpuMostUsageHistory = new CircularBuffer(_historyMaxSize); @@ -339,21 +339,14 @@ out retLen { Int64Delta.Update(ref _cpuKernelDeltas[i], this.ProcessorPerfArray[i].KernelTime); Int64Delta.Update(ref _cpuUserDeltas[i], this.ProcessorPerfArray[i].UserTime); - - Int64Delta.Update( - ref _cpuOtherDeltas[i], - this.ProcessorPerfArray[i].IdleTime + this.ProcessorPerfArray[i].DpcTime + this.ProcessorPerfArray[i].InterruptTime - ); + Int64Delta.Update(ref _cpuOtherDeltas[i], + this.ProcessorPerfArray[i].IdleTime + this.ProcessorPerfArray[i].DpcTime + + this.ProcessorPerfArray[i].InterruptTime); _cpusKernelHistory[i] = new CircularBuffer(_historyMaxSize); _cpusUserHistory[i] = new CircularBuffer(_historyMaxSize); _cpusOtherHistory[i] = new CircularBuffer(_historyMaxSize); } - - _cpuKernelHistory.Add(0); - - _commitHistory.Add(0); - _physicalMemoryHistory.Add(0); } public SystemProcess DpcsProcess @@ -374,24 +367,12 @@ private void UpdateCb(CircularBuffer cb, T value) cb.Add(value); } - private void UpdateList(CircularList cb, T value) - { - //if (cb.Max != this.HistoryMaxSize) - cb.Max = this.HistoryMaxSize; - - cb.Add(value); - } - private void UpdateProcessorPerf() { int retLen; - Win32.NtQuerySystemInformation( - SystemInformationClass.SystemProcessorPerformanceInformation, - _processorPerfBuffer, - _processorPerfArraySize, - out retLen - ); + Win32.NtQuerySystemInformation(SystemInformationClass.SystemProcessorPerformanceInformation, + _processorPerfBuffer, _processorPerfArraySize, out retLen); _processorPerf = new SystemProcessorPerformanceInformation(); @@ -402,7 +383,7 @@ out retLen // This is why I love free software. for (int i = 0; i < _processorPerfArray.Length; i++) { - var cpuPerf = _processorPerfBuffer.ReadStruct(0, SystemProcessorPerformanceInformation.SizeOf, i); + var cpuPerf = _processorPerfBuffer.ReadStruct(i); cpuPerf.KernelTime -= cpuPerf.IdleTime + cpuPerf.DpcTime + cpuPerf.InterruptTime; _processorPerf.DpcTime += cpuPerf.DpcTime; @@ -419,12 +400,8 @@ private void UpdatePerformance() { int retLen; - Win32.NtQuerySystemInformation( - SystemInformationClass.SystemPerformanceInformation, - out _performance, - SystemPerformanceInformation.SizeOf, - out retLen - ); + Win32.NtQuerySystemInformation(SystemInformationClass.SystemPerformanceInformation, + out _performance, SystemPerformanceInformation.Size, out retLen); } private ProcessQueryMessage QueryProcessStage1(int pid, string fileName, bool forced) @@ -437,43 +414,42 @@ private ProcessQueryMessage QueryProcessStage1(int pid, string fileName, bool fo ///
private ProcessQueryMessage QueryProcessStage1(int pid, string fileName, bool forced, bool addToQueue) { - ProcessQueryMessage fpResult = new ProcessQueryMessage - { - Pid = pid, - Stage = 0x1 - }; + ProcessQueryMessage fpResult = new ProcessQueryMessage(); - if (string.IsNullOrEmpty(fileName)) - fileName = GetFileName(pid); + fpResult.Pid = pid; + fpResult.Stage = 0x1; + + if (fileName == null) + fileName = this.GetFileName(pid); + + if (fileName == null) + Logging.Log(Logging.Importance.Warning, "Could not get file name for PID " + pid.ToString()); fpResult.FileName = fileName; try { - using (ProcessHandle queryLimitedHandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) + using (var queryLimitedHandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) { try { // Get a handle to the process' token and get its // elevation type, and integrity. - using (TokenHandle thandle = queryLimitedHandle.GetToken(TokenAccess.Query)) + using (var thandle = queryLimitedHandle.GetToken(TokenAccess.Query)) { - try - { - fpResult.ElevationType = thandle.ElevationType; - } + try { fpResult.ElevationType = thandle.GetElevationType(); } + catch { } + try { fpResult.IsElevated = thandle.IsElevated(); } catch { } + // Try to get the integrity level. try { - fpResult.IsElevated = thandle.IsElevated; + fpResult.Integrity = thandle.GetIntegrity(out fpResult.IntegrityLevel); } - catch { } - - // Try to get the integrity level. - - fpResult.Integrity = thandle.GetIntegrity(out fpResult.IntegrityLevel); + catch + { } } } catch @@ -484,28 +460,35 @@ private ProcessQueryMessage QueryProcessStage1(int pid, string fileName, bool fo { try { - fpResult.IsWow64 = queryLimitedHandle.IsWow64; + fpResult.IsWow64 = queryLimitedHandle.IsWow64(); } catch { } } // Get the process' job if we have KProcessHacker. - if (KProcessHacker2.Instance != null) + // Otherwise, don't do anything. + + if (KProcessHacker.Instance != null) { try { - using (JobObjectHandle jhandle = queryLimitedHandle.GetJobObject(JobObjectAccess.Query)) + var jhandle = queryLimitedHandle.GetJobObject(JobObjectAccess.Query); + + if (jhandle != null) { - JobObjectBasicLimitInformation limits = jhandle.BasicLimitInformation; + using (jhandle) + { + var limits = jhandle.GetBasicLimitInformation(); - fpResult.IsInJob = true; - fpResult.JobName = jhandle.ObjectName; + fpResult.IsInJob = true; + fpResult.JobName = jhandle.GetObjectName(); - // This is what Process Explorer does... - if (limits.LimitFlags != JobObjectLimitFlags.SilentBreakawayOk) - { - fpResult.IsInSignificantJob = true; + // This is what Process Explorer does... + if (limits.LimitFlags != JobObjectLimitFlags.SilentBreakawayOk) + { + fpResult.IsInSignificantJob = true; + } } } } @@ -516,24 +499,17 @@ private ProcessQueryMessage QueryProcessStage1(int pid, string fileName, bool fo fpResult.IsInSignificantJob = false; } } - - try - { - fpResult.IsInJob = queryLimitedHandle.IsInJob(); - } - catch { } - - if (pid > 4) + else { - fpResult.CmdLine = queryLimitedHandle.CommandLine; - fpResult.IsPosix = queryLimitedHandle.IsPosix; + try { fpResult.IsInJob = queryLimitedHandle.IsInJob(); } + catch { } } } } catch { } - if (!string.IsNullOrEmpty(fileName)) + if (fileName != null) { try { @@ -551,6 +527,21 @@ private ProcessQueryMessage QueryProcessStage1(int pid, string fileName, bool fo { } } + if (pid > 4) + { + try + { + using (var phandle = new ProcessHandle(pid, + Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) + { + fpResult.CmdLine = phandle.GetCommandLine(); + fpResult.IsPosix = phandle.IsPosix(); + } + } + catch + { } + } + if (addToQueue) _messageQueue.Enqueue(fpResult); @@ -576,18 +567,16 @@ private ProcessQueryMessage QueryProcessStage1(int pid, string fileName, bool fo ///
private ProcessQueryMessage QueryProcessStage1a(int pid, string fileName, bool forced) { - ProcessQueryMessage fpResult = new ProcessQueryMessage - { - Pid = pid, - Stage = 0x1a - }; + ProcessQueryMessage fpResult = new ProcessQueryMessage(); + fpResult.Pid = pid; + fpResult.Stage = 0x1a; if (pid > 4) { try { - fpResult.IsDotNet = false; //PhUtils.IsDotNetProcess(pid); + fpResult.IsDotNet = PhUtils.IsDotNetProcess(pid); } catch { } @@ -606,20 +595,19 @@ private ProcessQueryMessage QueryProcessStage1a(int pid, string fileName, bool f ///
private ProcessQueryMessage QueryProcessStage2(int pid, string fileName, bool forced) { - ProcessQueryMessage fpResult = new ProcessQueryMessage - { - Pid = pid, - Stage = 0x2, - IsPacked = false - }; + ProcessQueryMessage fpResult = new ProcessQueryMessage(); - if (string.IsNullOrEmpty(fileName)) + fpResult.Pid = pid; + fpResult.Stage = 0x2; + fpResult.IsPacked = false; + + if (fileName == null) return null; // Don't process the file if it is too big (above 32MB). try { - if ((new System.IO.FileInfo(fileName)).Length > 32 * 1024 * 1024) + if ((new global::System.IO.FileInfo(fileName)).Length > 32 * 1024 * 1024) return null; } catch @@ -635,11 +623,11 @@ private ProcessQueryMessage QueryProcessStage2(int pid, string fileName, bool fo // 1. The function-to-library ratio is lower than 4 // (on average less than 4 functions are imported from each library) // 2. It references more than 3 libraries but less than 14 libraries. - if (!string.IsNullOrEmpty(fileName) && (Settings.Instance.VerifySignatures || forced)) + if (fileName != null && (Settings.Instance.VerifySignatures || forced)) { try { - using (MappedImage mappedImage = new MappedImage(fileName)) + using (var mappedImage = new MappedImage(fileName)) { int libraryTotal = mappedImage.Imports.Count; int funcTotal = 0; @@ -670,7 +658,7 @@ private ProcessQueryMessage QueryProcessStage2(int pid, string fileName, bool fo { if (Settings.Instance.VerifySignatures || forced) { - if (!string.IsNullOrEmpty(fileName)) + if (fileName != null) { string uniName = global::System.IO.Path.GetFullPath(fileName).ToLowerInvariant(); @@ -709,50 +697,54 @@ private ProcessQueryMessage QueryProcessStage2(int pid, string fileName, bool fo return fpResult; } - private static string GetFileName(int pid) + private string GetFileName(int pid) { string fileName = null; if (pid != 4) { - if (OSVersion.IsAbove(WindowsVersion.XP)) - { - fileName = FileUtils.GetVistaFileName(pid); - } - else + try { - try + using (var phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) { - using (ProcessHandle phandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) + // First try to get the native file name, to prevent PEB + // file name spoofing. + try + { + fileName = FileUtils.GetFileName(phandle.GetImageFileName()); + } + catch + { } + + // If we couldn't get it or we couldn't resolve the \Device prefix, + // we'll use the Win32 variant. + if ((fileName == null || fileName.StartsWith("\\")) && + OSVersion.HasWin32ImageFileName) { - // First try to get the native file name, to prevent PEB file name spoofing. try { - fileName = phandle.ImageFileName; + fileName = phandle.GetImageFileNameWin32(); } catch { } - - // If we couldn't get it or we couldn't resolve the \Device prefix, we'll use the Win32 variant. - if ((string.IsNullOrEmpty(fileName) || fileName.StartsWith("\\", StringComparison.OrdinalIgnoreCase)) && OSVersion.HasWin32ImageFileName) - { - fileName = phandle.GetImageFileNameWin32(); - } } } - catch { } } + catch + { } - if (string.IsNullOrEmpty(fileName) || fileName.StartsWith("\\Device\\", StringComparison.OrdinalIgnoreCase)) + if (fileName == null || fileName.StartsWith("\\Device\\")) { try { - using (ProcessHandle phandle = new ProcessHandle(pid, ProcessAccess.QueryInformation | ProcessAccess.VmRead)) + using (var phandle = + new ProcessHandle(pid, ProcessAccess.QueryInformation | ProcessAccess.VmRead)) { // We can try to use the PEB. try { - fileName = FileUtils.GetFileName(phandle.GetPebString(PebOffset.ImagePathName)); + fileName = FileUtils.GetFileName( + FileUtils.GetFileName(phandle.GetPebString(PebOffset.ImagePathName))); } catch { } @@ -760,7 +752,7 @@ private static string GetFileName(int pid) // If all else failed, we get the main module file name. try { - fileName = phandle.MainModule.FileName; + fileName = phandle.GetMainModule().FileName; } catch { } @@ -772,7 +764,12 @@ private static string GetFileName(int pid) } else { - fileName = Windows.KernelFileName; + try + { + fileName = Windows.KernelFileName; + } + catch + { } } return fileName; @@ -789,39 +786,41 @@ public void QueueProcessQuery(int pid) private void FillPqResult(ProcessItem item, ProcessQueryMessage result) { - switch (result.Stage) + if (result.Stage == 0x1) + { + item.FileName = result.FileName; + item.ElevationType = result.ElevationType; + item.IsElevated = result.IsElevated; + item.Integrity = result.Integrity; + item.IntegrityLevel = result.IntegrityLevel; + item.IsWow64 = result.IsWow64; + item.IsInJob = result.IsInJob; + item.JobName = result.JobName; + item.IsInSignificantJob = result.IsInSignificantJob; + item.Icon = result.Icon; + item.LargeIcon = result.LargeIcon; + item.VersionInfo = result.VersionInfo; + item.CmdLine = result.CmdLine; + item.IsPosix = result.IsPosix; + } + else if (result.Stage == 0x1a) + { + item.IsDotNet = result.IsDotNet; + + if (item.IsDotNet) + item.IsPacked = false; + } + else if (result.Stage == 0x2) + { + item.IsPacked = (item.IsDotNet || result.IsDotNet) ? false : result.IsPacked; + item.VerifyResult = result.VerifyResult; + item.VerifySignerName = result.VerifySignerName; + item.ImportFunctions = result.ImportFunctions; + item.ImportModules = result.ImportModules; + } + else { - case 0x1: - item.FileName = result.FileName; - item.ElevationType = result.ElevationType; - item.IsElevated = result.IsElevated; - item.Integrity = result.Integrity; - item.IntegrityLevel = result.IntegrityLevel; - item.IsWow64 = result.IsWow64; - item.IsInJob = result.IsInJob; - item.JobName = result.JobName; - item.IsInSignificantJob = result.IsInSignificantJob; - item.Icon = result.Icon; - item.LargeIcon = result.LargeIcon; - item.VersionInfo = result.VersionInfo; - item.CmdLine = result.CmdLine; - item.IsPosix = result.IsPosix; - break; - case 0x1a: - item.IsDotNet = result.IsDotNet; - if (item.IsDotNet) - item.IsPacked = false; - break; - case 0x2: - item.IsPacked = !(item.IsDotNet || result.IsDotNet) && result.IsPacked; - item.VerifyResult = result.VerifyResult; - item.VerifySignerName = result.VerifySignerName; - item.ImportFunctions = result.ImportFunctions; - item.ImportModules = result.ImportModules; - break; - default: - Logging.Log(Logging.Importance.Warning, "Unknown stage " + result.Stage.ToString("x")); - break; + Logging.Log(Logging.Importance.Warning, "Unknown stage " + result.Stage.ToString("x")); } if (this.ProcessQueryReceived != null) @@ -902,13 +901,10 @@ protected override void Update() UpdateCb(_ioWriteHistory, _ioWriteDelta.Delta); UpdateCb(_ioOtherHistory, _ioOtherDelta.Delta); UpdateCb(_ioReadOtherHistory, _ioReadDelta.Delta + _ioOtherDelta.Delta); + UpdateCb(_commitHistory, (long)_performance.CommittedPages * _system.PageSize); + UpdateCb(_physicalMemoryHistory, + (long)(_system.NumberOfPhysicalPages - _performance.AvailablePages) * _system.PageSize); - this.UpdateList(this.CommitHistory, (int)this.Performance.CommittedPages); - - MEMORYSTATUSEX ex = new MEMORYSTATUSEX(); - if (GlobalMemoryStatusEx(ex)) - this.UpdateList(this.PhysicalMemoryHistory, ex.memoryLoad); - // set System Idle Process CPU time if (procs.ContainsKey(0)) { @@ -958,56 +954,53 @@ protected override void Update() if (!Dictionary.ContainsKey(pid)) { + ProcessItem item = new ProcessItem(); + // Set up basic process information. - ProcessItem item = new ProcessItem - { - RunId = this.RunCount, - Pid = pid, - Process = processInfo, - SessionId = processInfo.SessionId, - ProcessingAttempts = 1, - Name = procs[pid].Name, - // Create the delta and history managers. - CpuKernelDelta = new Int64Delta(processInfo.KernelTime), - CpuUserDelta = new Int64Delta(processInfo.UserTime), - IoReadDelta = new Int64Delta((long)processInfo.IoCounters.ReadTransferCount), - IoWriteDelta = new Int64Delta((long)processInfo.IoCounters.WriteTransferCount), - IoOtherDelta = new Int64Delta((long)processInfo.IoCounters.OtherTransferCount), - CpuKernelHistory = new CircularBuffer(this._historyMaxSize), - CpuUserHistory = new CircularBuffer(this._historyMaxSize), - IoReadHistory = new CircularBuffer(this._historyMaxSize), - IoWriteHistory = new CircularBuffer(this._historyMaxSize), - IoOtherHistory = new CircularBuffer(this._historyMaxSize), - IoReadOtherHistory = new CircularBuffer(this._historyMaxSize), - PrivateMemoryHistory = new CircularBuffer(this._historyMaxSize), - WorkingSetHistory = new CircularBuffer(this._historyMaxSize) - }; + item.RunId = this.RunCount; + item.Pid = pid; + item.Process = processInfo; + item.SessionId = processInfo.SessionId; + item.ProcessingAttempts = 1; - try - { - item.ProcessQueryHandle = new ProcessHandle(pid, (ProcessAccess)StandardRights.MaximumAllowed); - } - catch - { } + item.Name = procs[pid].Name; + + // Create the delta and history managers. + + item.CpuKernelDelta = new Int64Delta(processInfo.KernelTime); + item.CpuUserDelta = new Int64Delta(processInfo.UserTime); + item.IoReadDelta = new Int64Delta((long)processInfo.IoCounters.ReadTransferCount); + item.IoWriteDelta = new Int64Delta((long)processInfo.IoCounters.WriteTransferCount); + item.IoOtherDelta = new Int64Delta((long)processInfo.IoCounters.OtherTransferCount); + + item.CpuKernelHistory = new CircularBuffer(_historyMaxSize); + item.CpuUserHistory = new CircularBuffer(_historyMaxSize); + item.IoReadHistory = new CircularBuffer(_historyMaxSize); + item.IoWriteHistory = new CircularBuffer(_historyMaxSize); + item.IoOtherHistory = new CircularBuffer(_historyMaxSize); + item.IoReadOtherHistory = new CircularBuffer(_historyMaxSize); + item.PrivateMemoryHistory = new CircularBuffer(_historyMaxSize); + item.WorkingSetHistory = new CircularBuffer(_historyMaxSize); // HACK: Shouldn't happen, but it does - sometimes // the process name is null. - if (item.ProcessQueryHandle != null) + if (item.Name == null) { - if (string.IsNullOrEmpty(item.Name)) + try { - try - { - item.Name = item.ProcessQueryHandle.MainModule.BaseName; - } - catch - { - item.Name = string.Empty; - } + using (var phandle = + new ProcessHandle(pid, ProcessAccess.QueryInformation | ProcessAccess.VmRead)) + item.Name = phandle.GetMainModule().BaseName; + } + catch + { + item.Name = ""; } } - // Get the process' creation time and check the parent process ID. + // Get the process' creation time and check the + // parent process ID. + try { item.CreateTime = DateTime.FromFileTime(processInfo.CreateTime); @@ -1035,52 +1028,64 @@ protected override void Update() } // Get the process' token's username. - if (item.ProcessQueryHandle != null) + + try { - try + using (var queryLimitedHandle = new ProcessHandle(pid, Program.MinProcessQueryRights)) { - using (TokenHandle thandle = item.ProcessQueryHandle.GetToken(TokenAccess.Query)) + try { - try + using (var thandle = queryLimitedHandle.GetToken(TokenAccess.Query)) { - using (Sid sid = thandle.User) - item.Username = sid.GetFullName(true); + try + { + using (var sid = thandle.GetUser()) + item.Username = sid.GetFullName(true); + } + catch + { } } - catch - { } } + catch + { } } - catch - { } } + catch + { } + + // Get a process handle with QUERY_INFORMATION access, and + // see if it's being debugged. - // Get a process handle with QUERY_INFORMATION access, and see if it's being debugged. - if (item.ProcessQueryHandle != null) + try { + item.ProcessQueryHandle = new ProcessHandle(pid, ProcessAccess.QueryInformation); + try { - item.IsBeingDebugged = item.ProcessQueryHandle.IsBeingDebugged; + item.IsBeingDebugged = item.ProcessQueryHandle.IsBeingDebugged(); } catch { } } + catch + { } } // Update the process name if it's a fake process. - switch (pid) + if (pid == 0) { - case 0: - item.Name = "System Idle Process"; - break; - case -2: - item.ParentPid = 0; - item.HasParent = true; - break; - case -3: - item.ParentPid = 0; - item.HasParent = true; - break; + item.Name = "System Idle Process"; + } + else if (pid == -2) + { + item.ParentPid = 0; + item.HasParent = true; + } + else if (pid == -3) + { + item.ParentPid = 0; + item.HasParent = true; } // If this is not the first run, we process the item immediately. @@ -1109,7 +1114,7 @@ protected override void Update() // If we didn't get a username, try to use Terminal Services // to get the SID of the process' token's user. - if (pid > 4 && string.IsNullOrEmpty(item.Username)) + if (pid > 4 && item.Username == null) { if (tsProcesses == null) { @@ -1146,14 +1151,21 @@ protected override void Update() item.IoWriteDelta.Update((long)processInfo.IoCounters.WriteTransferCount); item.IoOtherDelta.Update((long)processInfo.IoCounters.OtherTransferCount); - UpdateCb(item.CpuKernelHistory, (float)item.CpuKernelDelta.Delta / (sysKernelTime + sysUserTime + otherTime)); - UpdateCb(item.CpuUserHistory, (float)item.CpuUserDelta.Delta / (sysKernelTime + sysUserTime + otherTime)); + UpdateCb(item.CpuKernelHistory, + (float)item.CpuKernelDelta.Delta / + (sysKernelTime + sysUserTime + otherTime)); + UpdateCb(item.CpuUserHistory, + (float)item.CpuUserDelta.Delta / + (sysKernelTime + sysUserTime + otherTime)); UpdateCb(item.IoReadHistory, item.IoReadDelta.Delta); UpdateCb(item.IoWriteHistory, item.IoWriteDelta.Delta); UpdateCb(item.IoOtherHistory, item.IoOtherDelta.Delta); - UpdateCb(item.IoReadOtherHistory, item.IoReadDelta.Delta + item.IoOtherDelta.Delta); - UpdateCb(item.PrivateMemoryHistory, processInfo.VirtualMemoryCounters.PrivatePageCount.ToInt64()); - UpdateCb(item.WorkingSetHistory, processInfo.VirtualMemoryCounters.WorkingSetSize.ToInt64()); + UpdateCb(item.IoReadOtherHistory, + item.IoReadDelta.Delta + item.IoOtherDelta.Delta); + UpdateCb(item.PrivateMemoryHistory, + processInfo.VirtualMemoryCounters.PrivatePageCount.ToInt64()); + UpdateCb(item.WorkingSetHistory, + processInfo.VirtualMemoryCounters.WorkingSetSize.ToInt64()); // Update the struct. item.Process = processInfo; @@ -1162,9 +1174,12 @@ protected override void Update() try { - item.CpuUsage = (float)(item.CpuUserDelta.Delta + item.CpuKernelDelta.Delta) * 100 / (sysKernelTime + sysUserTime + otherTime); + item.CpuUsage = (float) + (item.CpuUserDelta.Delta + item.CpuKernelDelta.Delta) * 100 / + (sysKernelTime + sysUserTime + otherTime); // HACK. + if (item.CpuUsage > 400.0f) item.CpuUsage /= 8.0f; else if (item.CpuUsage > 200.0f) @@ -1188,11 +1203,12 @@ protected override void Update() { } // Determine whether the process is being debugged. + if (item.ProcessQueryHandle != null) { try { - bool isBeingDebugged = item.ProcessQueryHandle.IsBeingDebugged; + bool isBeingDebugged = item.ProcessQueryHandle.IsBeingDebugged(); if (isBeingDebugged != item.IsBeingDebugged) { @@ -1264,33 +1280,5 @@ protected override void Update() if (wtsEnumData.Memory != null) wtsEnumData.Memory.Dispose(); } - - - [DllImport("kernel32.dll", SetLastError = true), System.Security.SuppressUnmanagedCodeSecurity] - public static extern bool GlobalMemoryStatusEx([In, Out] MEMORYSTATUSEX buffer); } - - [StructLayout(LayoutKind.Sequential)] - public class MEMORYSTATUSEX - { - public static readonly int SizeOf = Marshal.SizeOf(typeof(MEMORYSTATUSEX)); - - private int length; - public int memoryLoad; - public ulong totalPhys; - public ulong availPhys; - public ulong totalPageFile; - public ulong availPageFile; - public ulong totalVirtual; - public ulong availVirtual; - public ulong availExtendedVirtual; - - internal MEMORYSTATUSEX() - { - this.length = SizeOf; - } - } - - - } diff --git a/1.x/trunk/ProcessHacker/Providers/Provider.cs b/1.x/trunk/ProcessHacker/Providers/Provider.cs index ab2472b7d..842f193ac 100644 --- a/1.x/trunk/ProcessHacker/Providers/Provider.cs +++ b/1.x/trunk/ProcessHacker/Providers/Provider.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; +using System.Threading; using ProcessHacker.Common; using ProcessHacker.Common.Objects; @@ -46,8 +47,7 @@ public abstract class Provider : BaseObject, IProvider /// /// Represents a handler called when a dictionary item is modified. /// - /// The old item. - /// The new item. + /// The modified item. public delegate void ProviderDictionaryModified(TValue oldItem, TValue newItem); /// @@ -94,19 +94,19 @@ public abstract class Provider : BaseObject, IProvider private string _name = string.Empty; private IDictionary _dictionary; - private bool _disposing; - private bool _boosting; - private bool _busy; - private bool _enabled; - private readonly LinkedListEntry _listEntry; + private bool _disposing = false; + private bool _boosting = false; + private bool _busy = false; + private bool _enabled = false; + private LinkedListEntry _listEntry; private ProviderThread _owner; - private int _runCount; - private bool _unregistering; + private int _runCount = 0; + private bool _unregistering = false; /// /// Creates a new instance of the Provider class. /// - protected Provider() + public Provider() : this(new Dictionary()) { } @@ -114,7 +114,7 @@ protected Provider() /// Creates a new instance of the Provider class, specifying a /// custom equality comparer. /// - protected Provider(IEqualityComparer comparer) + public Provider(IEqualityComparer comparer) : this(new Dictionary(comparer)) { } @@ -122,20 +122,20 @@ protected Provider(IEqualityComparer comparer) /// Creates a new instance of the Provider class, specifying a /// custom instance. ///
- protected Provider(IDictionary dictionary) + public Provider(IDictionary dictionary) { if (dictionary == null) throw new ArgumentNullException("dictionary"); _dictionary = dictionary; - _listEntry = new LinkedListEntry - { - Value = this - }; + _listEntry = new LinkedListEntry(); + _listEntry.Value = this; } protected override void DisposeObject(bool disposing) { + Logging.Log(Logging.Importance.Information, "Provider (" + this.Name + "): disposing (" + disposing.ToString() + ")"); + _disposing = true; if (this.Disposed != null) @@ -149,6 +149,8 @@ protected override void DisposeObject(bool disposing) Logging.Log(ex); } } + + Logging.Log(Logging.Importance.Information, "Provider (" + this.Name + "): finished disposing (" + disposing.ToString() + ")"); } public string Name @@ -292,22 +294,34 @@ public void Run() _busy = false; } + private void CallEvent(Delegate e, params object[] args) + { + if (e != null) + { + try + { + e.DynamicInvoke(args); + } + catch (Exception ex) + { + Logging.Log(ex); + } + } + } + protected void OnDictionaryAdded(TValue item) { - if (this.DictionaryAdded != null) - this.DictionaryAdded(item); + this.CallEvent(this.DictionaryAdded, item); } protected void OnDictionaryModified(TValue oldItem, TValue newItem) { - if (this.DictionaryModified != null) - this.DictionaryModified(oldItem, newItem); + this.CallEvent(this.DictionaryModified, oldItem, newItem); } protected void OnDictionaryRemoved(TValue item) { - if (this.DictionaryRemoved != null) - this.DictionaryRemoved(item); + this.CallEvent(this.DictionaryRemoved, item); } protected virtual void Update() diff --git a/1.x/trunk/ProcessHacker/Providers/ProviderThread.cs b/1.x/trunk/ProcessHacker/Providers/ProviderThread.cs index aa474f106..ae7df9abf 100644 --- a/1.x/trunk/ProcessHacker/Providers/ProviderThread.cs +++ b/1.x/trunk/ProcessHacker/Providers/ProviderThread.cs @@ -20,7 +20,9 @@ * along with Process Hacker. If not, see . */ +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Threading; using ProcessHacker.Common; using ProcessHacker.Common.Objects; @@ -35,16 +37,16 @@ namespace ProcessHacker { public class ProviderThread : BaseObject, IEnumerable { - private readonly LinkedListEntry _listHead = new LinkedListEntry(); - private int _boostCount; + private LinkedListEntry _listHead = new LinkedListEntry(); + private int _boostCount = 0; private int _count; private Thread _thread; private ThreadHandle _threadHandle; private FastEvent _initializedEvent = new FastEvent(false); - private bool _terminating; + private bool _terminating = false; private int _interval; - private readonly TimerHandle _timerHandle; + private TimerHandle _timerHandle; public ProviderThread(int interval) { @@ -53,10 +55,8 @@ public ProviderThread(int interval) _timerHandle = TimerHandle.Create(TimerAccess.All, TimerType.SynchronizationTimer); this.Interval = interval; - _thread = new Thread(this.Update, Utils.QuarterStackSize) - { - IsBackground = true - }; + _thread = new Thread(new ThreadStart(this.Update), ProcessHacker.Common.Utils.QuarterStackSize); + _thread.IsBackground = true; _thread.SetApartmentState(ApartmentState.STA); _thread.Start(); _thread.Priority = ThreadPriority.Lowest; diff --git a/1.x/trunk/ProcessHacker/Providers/ServiceProvider.cs b/1.x/trunk/ProcessHacker/Providers/ServiceProvider.cs index 35705d196..ed258696d 100644 --- a/1.x/trunk/ProcessHacker/Providers/ServiceProvider.cs +++ b/1.x/trunk/ProcessHacker/Providers/ServiceProvider.cs @@ -96,11 +96,10 @@ protected override void Update() { if (!Dictionary.ContainsKey(s)) { - ServiceItem item = new ServiceItem - { - RunId = this.RunCount, - Status = newdictionary[s] - }; + ServiceItem item = new ServiceItem(); + + item.RunId = this.RunCount; + item.Status = newdictionary[s]; try { diff --git a/1.x/trunk/ProcessHacker/Providers/ThreadProvider.cs b/1.x/trunk/ProcessHacker/Providers/ThreadProvider.cs index dad0d8214..3e45135e6 100644 --- a/1.x/trunk/ProcessHacker/Providers/ThreadProvider.cs +++ b/1.x/trunk/ProcessHacker/Providers/ThreadProvider.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; using System.Threading; - using ProcessHacker.Common; using ProcessHacker.Common.Messaging; using ProcessHacker.Common.Threading; @@ -59,7 +58,6 @@ public object Clone() public bool IsGuiThread; public bool JustResolved; - public ThreadHandle ThreadQueryHandle; public ThreadHandle ThreadQueryLimitedHandle; } @@ -76,38 +74,37 @@ private class ResolveMessage : Message public delegate void LoadingStateChangedDelegate(bool loading); private delegate void ResolveThreadStartAddressDelegate(int tid, ulong startAddress); - private static readonly WorkQueue _symbolsWorkQueue = new WorkQueue - { - MaxWorkerThreads = 1 - }; + private static readonly WorkQueue _symbolsWorkQueue = new WorkQueue() { MaxWorkerThreads = 1 }; public event LoadingStateChangedDelegate LoadingStateChanged; - private readonly ProcessHandle _processHandle; - private readonly ProcessAccess _processAccess; + private ProcessHandle _processHandle; + private ProcessAccess _processAccess; private SymbolProvider _symbols; - private int _kernelSymbolsLoaded; - private readonly int _pid; - private int _loading; - private readonly MessageQueue _messageQueue = new MessageQueue(); - private int _symbolsStartedLoading; + private int _kernelSymbolsLoaded = 0; + private int _pid; + private int _loading = 0; + private MessageQueue _messageQueue = new MessageQueue(); + private int _symbolsStartedLoading = 0; private FastEvent _moduleLoadCompletedEvent = new FastEvent(false); public ThreadProvider(int pid) + : base() { - this.Name = "ThreadProvider"; + this.Name = this.GetType().Name; _pid = pid; - _messageQueue.AddListener(new MessageQueueListener(message => - { - if (message.Symbol != null) + _messageQueue.AddListener( + new MessageQueueListener((message) => { - this.Dictionary[message.Tid].StartAddress = message.Symbol; - this.Dictionary[message.Tid].FileName = message.FileName; - this.Dictionary[message.Tid].StartAddressLevel = message.ResolveLevel; - this.Dictionary[message.Tid].JustResolved = true; - } - })); + if (message.Symbol != null) + { + this.Dictionary[message.Tid].StartAddress = message.Symbol; + this.Dictionary[message.Tid].FileName = message.FileName; + this.Dictionary[message.Tid].StartAddressLevel = message.ResolveLevel; + this.Dictionary[message.Tid].JustResolved = true; + } + })); this.Disposed += ThreadProvider_Disposed; @@ -121,8 +118,16 @@ public ThreadProvider(int pid) { try { - _processAccess = Program.MinProcessQueryRights; - _processHandle = new ProcessHandle(_pid, _processAccess); + if (KProcessHacker.Instance != null) + { + _processAccess = Program.MinProcessReadMemoryRights; + _processHandle = new ProcessHandle(_pid, _processAccess); + } + else + { + _processAccess = Program.MinProcessQueryRights; + _processHandle = new ProcessHandle(_pid, _processAccess); + } } catch (WindowsException ex) { @@ -152,8 +157,8 @@ public void LoadKernelSymbols(bool force) if (Interlocked.CompareExchange(ref _kernelSymbolsLoaded, 1, 0) == 1) return; - //if (KProcessHacker.Instance != null || force) - //_symbols.LoadKernelModules(); + if (KProcessHacker.Instance != null || force) + _symbols.LoadKernelModules(); } private void LoadSymbols() @@ -186,16 +191,17 @@ private void LoadSymbols() SymbolProvider.Options = SymbolOptions.DeferredLoads | (Settings.Instance.DbgHelpUndecorate ? SymbolOptions.UndName : 0); - if (!string.IsNullOrEmpty(Settings.Instance.DbgHelpSearchPath)) + if (Settings.Instance.DbgHelpSearchPath != "") _symbols.SearchPath = Settings.Instance.DbgHelpSearchPath; try { if (_pid > 4) { - using (var phandle = new ProcessHandle(_pid, Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) + using (var phandle = + new ProcessHandle(_pid, Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) { - if (OSVersion.Architecture == OSArch.I386 || !phandle.IsWow64) + if (OSVersion.Architecture == OSArch.I386 || !phandle.IsWow64()) { // Load the process' modules. try { _symbols.LoadProcessModules(phandle); } @@ -210,7 +216,7 @@ private void LoadSymbols() // If the process is CSRSS we should load kernel modules // due to the presence of kernel-mode threads. - if (phandle.KnownProcessType == KnownProcess.WindowsSubsystem) + if (phandle.GetKnownProcessType() == KnownProcess.WindowsSubsystem) this.LoadKernelSymbols(true); } } @@ -225,7 +231,7 @@ private void LoadSymbols() // kernel32.dll and ntdll.dll. try { - ProcessHandle.Current.EnumModules(module => + ProcessHandle.Current.EnumModules((module) => { if ( module.BaseName.Equals("kernel32.dll", StringComparison.OrdinalIgnoreCase) || @@ -276,11 +282,9 @@ private void ThreadProvider_Disposed(IProvider provider) private void ResolveThreadStartAddress(int tid, ulong startAddress) { - ResolveMessage result = new ResolveMessage - { - Tid = tid - }; + ResolveMessage result = new ResolveMessage(); + result.Tid = tid; _moduleLoadCompletedEvent.Wait(); @@ -339,7 +343,7 @@ private string GetThreadBasicStartAddress(ulong startAddress, out SymbolResolveL ulong modBase; string fileName = _symbols.GetModuleFromAddress(startAddress, out modBase); - if (string.IsNullOrEmpty(fileName)) + if (fileName == null) { level = SymbolResolveLevel.Address; return "0x" + startAddress.ToString("x"); @@ -384,21 +388,19 @@ protected override void Update() // look for new threads foreach (int tid in threads.Keys) { - SystemThreadInformation t = threads[tid]; + var t = threads[tid]; if (!Dictionary.ContainsKey(tid)) { - ThreadItem item = new ThreadItem - { - RunId = this.RunCount, - Tid = tid, - ContextSwitches = t.ContextSwitchCount, - WaitReason = t.WaitReason - }; + ThreadItem item = new ThreadItem(); + + item.RunId = this.RunCount; + item.Tid = tid; + item.ContextSwitches = t.ContextSwitchCount; + item.WaitReason = t.WaitReason; try { - item.ThreadQueryHandle = new ThreadHandle(tid, OSVersion.MinThreadQueryInfoAccess); item.ThreadQueryLimitedHandle = new ThreadHandle(tid, Program.MinThreadQueryRights); try @@ -407,19 +409,18 @@ protected override void Update() item.Priority = item.ThreadQueryLimitedHandle.GetBasePriorityWin32().ToString(); } catch + { } + + if (KProcessHacker.Instance != null) { + try + { + item.IsGuiThread = KProcessHacker.Instance.KphGetThreadWin32Thread(item.ThreadQueryLimitedHandle) != 0; + } + catch + { } } - //if (KProcessHacker.Instance != null) - //{ - // try - // { - // item.IsGuiThread = KProcessHacker.Instance.KphGetThreadWin32Thread(item.ThreadQueryLimitedHandle) != 0; - // } - // catch - // { } - //} - if (OSVersion.HasCycleTime) { try @@ -427,17 +428,37 @@ protected override void Update() item.Cycles = item.ThreadQueryLimitedHandle.GetCycleTime(); } catch - { - } + { } } - - item.StartAddressI = item.ThreadQueryLimitedHandle.GetWin32StartAddress(); } catch + { } + + if (KProcessHacker.Instance != null && item.ThreadQueryLimitedHandle != null) { - item.StartAddressI = t.StartAddress; + try + { + item.StartAddressI = + KProcessHacker.Instance.GetThreadStartAddress(item.ThreadQueryLimitedHandle).ToIntPtr(); + } + catch + { } + } + else + { + try + { + using (ThreadHandle thandle = + new ThreadHandle(tid, ThreadAccess.QueryInformation)) + { + item.StartAddressI = thandle.GetWin32StartAddress(); + } + } + catch + { + item.StartAddressI = t.StartAddress; + } } - if (_moduleLoadCompletedEvent.Wait(0)) { @@ -480,6 +501,16 @@ protected override void Update() catch { } + if (KProcessHacker.Instance != null) + { + try + { + newitem.IsGuiThread = KProcessHacker.Instance.KphGetThreadWin32Thread(newitem.ThreadQueryLimitedHandle) != 0; + } + catch + { } + } + if (OSVersion.HasCycleTime) { try diff --git a/1.x/trunk/ProcessHacker/Searchers/HeapSearcher.cs b/1.x/trunk/ProcessHacker/Searchers/HeapSearcher.cs index e9464d665..544122b11 100644 --- a/1.x/trunk/ProcessHacker/Searchers/HeapSearcher.cs +++ b/1.x/trunk/ProcessHacker/Searchers/HeapSearcher.cs @@ -35,8 +35,9 @@ public override void Search() { Results.Clear(); - HeapList32 hlist = new HeapList32(); - HeapEntry32 heap = new HeapEntry32(); + IntPtr snapshot; + var hlist = new HeapList32(); + var heap = new HeapEntry32(); int minsize; int count = 0; @@ -50,10 +51,10 @@ public override void Search() return; } - IntPtr snapshot = Win32.CreateToolhelp32Snapshot(SnapshotFlags.HeapList, this.PID); + snapshot = Win32.CreateToolhelp32Snapshot(SnapshotFlags.HeapList, PID); - hlist.dwSize = HeapList32.SizeOf; - heap.dwSize = HeapEntry32.SizeOf; + hlist.dwSize = Marshal.SizeOf(hlist); + heap.dwSize = Marshal.SizeOf(heap); if (snapshot != IntPtr.Zero && Marshal.GetLastWin32Error() == 0) { diff --git a/1.x/trunk/ProcessHacker/Searchers/LiteralSearcher.cs b/1.x/trunk/ProcessHacker/Searchers/LiteralSearcher.cs index 95874a959..4928ec9e6 100644 --- a/1.x/trunk/ProcessHacker/Searchers/LiteralSearcher.cs +++ b/1.x/trunk/ProcessHacker/Searchers/LiteralSearcher.cs @@ -55,7 +55,9 @@ public override void Search() try { - phandle = new ProcessHandle(PID, ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights); + phandle = new ProcessHandle(PID, + ProcessAccess.QueryInformation | + Program.MinProcessReadMemoryRights); } catch { @@ -63,74 +65,73 @@ public override void Search() return; } - phandle.EnumMemory(info => - { - // skip unreadable areas - if (info.Protect == MemoryProtection.AccessDenied) - return true; - if (info.State != MemoryState.Commit) - return true; + phandle.EnumMemory((info) => + { + // skip unreadable areas + if (info.Protect == MemoryProtection.AccessDenied) + return true; + if (info.State != MemoryState.Commit) + return true; - if ((!opt_priv) && (info.Type == MemoryType.Private)) - return true; + if ((!opt_priv) && (info.Type == MemoryType.Private)) + return true; - if ((!opt_img) && (info.Type == MemoryType.Image)) - return true; + if ((!opt_img) && (info.Type == MemoryType.Image)) + return true; - if ((!opt_map) && (info.Type == MemoryType.Mapped)) - return true; + if ((!opt_map) && (info.Type == MemoryType.Mapped)) + return true; - byte[] data = new byte[info.RegionSize.ToInt32()]; - int bytesRead = 0; + byte[] data = new byte[info.RegionSize.ToInt32()]; + int bytesRead = 0; - CallSearchProgressChanged( - String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); + CallSearchProgressChanged( + String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); - try - { - bytesRead = phandle.ReadMemory(info.BaseAddress, data, data.Length); + try + { + bytesRead = phandle.ReadMemory(info.BaseAddress, data, data.Length); - if (bytesRead == 0) + if (bytesRead == 0) + return true; + } + catch + { return true; - } - catch - { - return true; - } - - for (int i = 0; i < bytesRead; i++) - { - bool good = true; + } - for (int j = 0; j < text.Length; j++) + for (int i = 0; i < bytesRead; i++) { - if (i + j > bytesRead - 1) - continue; + bool good = true; - if (data[i + j] != text[j]) + for (int j = 0; j < text.Length; j++) { - good = false; - break; + if (i + j > bytesRead - 1) + continue; + + if (data[i + j] != text[j]) + { + good = false; + break; + } } - } - if (good) - { - Results.Add(new string[] + if (good) { - Utils.FormatAddress(info.BaseAddress), - String.Format("0x{0:x}", i), text.Length.ToString(), "" - }); + Results.Add(new string[] { Utils.FormatAddress(info.BaseAddress), + String.Format("0x{0:x}", i), text.Length.ToString(), "" }); - count++; + count++; - if (nooverlap) - i += text.Length - 1; + if (nooverlap) + i += text.Length - 1; + } } - } - return true; - }); + data = null; + + return true; + }); phandle.Dispose(); diff --git a/1.x/trunk/ProcessHacker/Searchers/RegexSearcher.cs b/1.x/trunk/ProcessHacker/Searchers/RegexSearcher.cs index 4c4f33c7c..125388133 100644 --- a/1.x/trunk/ProcessHacker/Searchers/RegexSearcher.cs +++ b/1.x/trunk/ProcessHacker/Searchers/RegexSearcher.cs @@ -70,7 +70,9 @@ public override void Search() try { - phandle = new ProcessHandle(PID, ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights); + phandle = new ProcessHandle(PID, + ProcessAccess.QueryInformation | + Program.MinProcessReadMemoryRights); } catch { @@ -78,66 +80,65 @@ public override void Search() return; } - phandle.EnumMemory(info => - { - // skip unreadable areas - if (info.Protect == MemoryProtection.AccessDenied) - return true; - if (info.State != MemoryState.Commit) - return true; + phandle.EnumMemory((info) => + { + // skip unreadable areas + if (info.Protect == MemoryProtection.AccessDenied) + return true; + if (info.State != MemoryState.Commit) + return true; - if ((!opt_priv) && (info.Type == MemoryType.Private)) - return true; + if ((!opt_priv) && (info.Type == MemoryType.Private)) + return true; - if ((!opt_img) && (info.Type == MemoryType.Image)) - return true; + if ((!opt_img) && (info.Type == MemoryType.Image)) + return true; - if ((!opt_map) && (info.Type == MemoryType.Mapped)) - return true; + if ((!opt_map) && (info.Type == MemoryType.Mapped)) + return true; - byte[] data = new byte[info.RegionSize.ToInt32()]; - int bytesRead = 0; + byte[] data = new byte[info.RegionSize.ToInt32()]; + int bytesRead = 0; - CallSearchProgressChanged( - String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); + CallSearchProgressChanged( + String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); - try - { - bytesRead = phandle.ReadMemory(info.BaseAddress, data, data.Length); + try + { + bytesRead = phandle.ReadMemory(info.BaseAddress, data, data.Length); - if (bytesRead == 0) + if (bytesRead == 0) + return true; + } + catch + { return true; - } - catch - { - return true; - } + } - StringBuilder sdata = new StringBuilder(); - string sdata2 = string.Empty; + StringBuilder sdata = new StringBuilder(); + string sdata2 = ""; - for (int i = 0; i < data.Length; i++) - sdata.Append((char)data[i]); + for (int i = 0; i < data.Length; i++) + sdata.Append((char)data[i]); - sdata2 = sdata.ToString(); - sdata = null; + sdata2 = sdata.ToString(); + sdata = null; - MatchCollection mc = rx.Matches(sdata2); + MatchCollection mc = rx.Matches(sdata2); - foreach (Match m in mc) - { - Results.Add(new string[] + foreach (Match m in mc) { - Utils.FormatAddress(info.BaseAddress), - String.Format("0x{0:x}", m.Index), m.Length.ToString(), - Utils.MakePrintable(m.Value) - }); + Results.Add(new string[] { Utils.FormatAddress(info.BaseAddress), + String.Format("0x{0:x}", m.Index), m.Length.ToString(), + Utils.MakePrintable(m.Value) }); - count++; - } + count++; + } - return true; - }); + data = null; + + return true; + }); phandle.Dispose(); diff --git a/1.x/trunk/ProcessHacker/Searchers/SearchOptions.cs b/1.x/trunk/ProcessHacker/Searchers/SearchOptions.cs index d1b7d8d7b..d948c4617 100644 --- a/1.x/trunk/ProcessHacker/Searchers/SearchOptions.cs +++ b/1.x/trunk/ProcessHacker/Searchers/SearchOptions.cs @@ -20,7 +20,9 @@ * along with Process Hacker. If not, see . */ +using System; using System.Collections.Generic; +using System.Text; namespace ProcessHacker { @@ -37,7 +39,7 @@ public enum SearchType ///
public class SearchOptions { - private readonly int _pid; + private int _pid; private SearchType _type = SearchType.Literal; private Searcher _searcher; @@ -54,7 +56,7 @@ public SearchOptions(int PID, SearchType type) // defaults _searcher.Params.Add("text", new byte[0]); - _searcher.Params.Add("regex", string.Empty); + _searcher.Params.Add("regex", ""); _searcher.Params.Add("s_ms", "10"); _searcher.Params.Add("unicode", true); _searcher.Params.Add("h_ms", "1024"); @@ -63,7 +65,7 @@ public SearchOptions(int PID, SearchType type) _searcher.Params.Add("private", true); _searcher.Params.Add("image", false); _searcher.Params.Add("mapped", false); - _searcher.Params.Add("struct", string.Empty); + _searcher.Params.Add("struct", ""); _searcher.Params.Add("struct_align", "4"); Type = type; diff --git a/1.x/trunk/ProcessHacker/Searchers/Searcher.cs b/1.x/trunk/ProcessHacker/Searchers/Searcher.cs index 98d4530f2..3e08d9d04 100644 --- a/1.x/trunk/ProcessHacker/Searchers/Searcher.cs +++ b/1.x/trunk/ProcessHacker/Searchers/Searcher.cs @@ -20,7 +20,10 @@ * along with Process Hacker. If not, see . */ +using System; using System.Collections.Generic; +using System.Text; +using System.Threading; namespace ProcessHacker { @@ -47,8 +50,8 @@ public interface ISearcher ///
public class Searcher : ISearcher { - private readonly int _pid; - private readonly Dictionary _params; + private int _pid; + private Dictionary _params; private List _results; public event SearchFinished SearchFinished; @@ -83,7 +86,7 @@ public Dictionary Params } /// - /// A containing the search results. + /// A containing the search results. /// public List Results { diff --git a/1.x/trunk/ProcessHacker/Searchers/StringSearcher.cs b/1.x/trunk/ProcessHacker/Searchers/StringSearcher.cs index caf7a1ca7..295feeba6 100644 --- a/1.x/trunk/ProcessHacker/Searchers/StringSearcher.cs +++ b/1.x/trunk/ProcessHacker/Searchers/StringSearcher.cs @@ -55,7 +55,9 @@ public override void Search() try { - phandle = new ProcessHandle(PID, ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights); + phandle = new ProcessHandle(PID, + ProcessAccess.QueryInformation | + Program.MinProcessReadMemoryRights); } catch { @@ -63,106 +65,105 @@ public override void Search() return; } - phandle.EnumMemory(info => - { - // skip unreadable areas - if (info.Protect == MemoryProtection.AccessDenied) - return true; - if (info.State != MemoryState.Commit) - return true; - - if ((!opt_priv) && (info.Type == MemoryType.Private)) - return true; - - if ((!opt_img) && (info.Type == MemoryType.Image)) - return true; - - if ((!opt_map) && (info.Type == MemoryType.Mapped)) - return true; - - byte[] data = new byte[info.RegionSize.ToInt32()]; - int bytesRead = 0; - - CallSearchProgressChanged( - String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); - - try + phandle.EnumMemory((info) => { - bytesRead = phandle.ReadMemory(info.BaseAddress, data, data.Length); + // skip unreadable areas + if (info.Protect == MemoryProtection.AccessDenied) + return true; + if (info.State != MemoryState.Commit) + return true; - if (bytesRead == 0) + if ((!opt_priv) && (info.Type == MemoryType.Private)) return true; - } - catch - { - return true; - } - StringBuilder curstr = new StringBuilder(); - bool isUnicode = false; - byte byte2 = 0; - byte byte1 = 0; + if ((!opt_img) && (info.Type == MemoryType.Image)) + return true; - for (int i = 0; i < bytesRead; i++) - { - bool isChar = IsChar(data[i]); + if ((!opt_map) && (info.Type == MemoryType.Mapped)) + return true; - if (unicode && isChar && isUnicode && byte1 != 0) - { - isUnicode = false; + byte[] data = new byte[info.RegionSize.ToInt32()]; + int bytesRead = 0; - if (curstr.Length > 0) - curstr.Remove(curstr.Length - 1, 1); + CallSearchProgressChanged( + String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); - curstr.Append((char)data[i]); - } - else if (isChar) - { - curstr.Append((char)data[i]); - } - else if (unicode && data[i] == 0 && IsChar(byte1) && !IsChar(byte2)) + try { - // skip null byte - isUnicode = true; + bytesRead = phandle.ReadMemory(info.BaseAddress, data, data.Length); + + if (bytesRead == 0) + return true; } - else if (unicode && - data[i] == 0 && IsChar(byte1) && IsChar(byte2) && curstr.Length < minsize) + catch { - // ... [char] [char] *[null]* ([char] [null] [char] [null]) ... - // ^ we are here - isUnicode = true; - curstr = new StringBuilder(); - curstr.Append((char)byte1); + return true; } - else + + StringBuilder curstr = new StringBuilder(); + bool isUnicode = false; + byte byte2 = 0; + byte byte1 = 0; + + for (int i = 0; i < bytesRead; i++) { - if (curstr.Length >= minsize) + bool isChar = IsChar(data[i]); + + if (unicode && isChar && isUnicode && byte1 != 0) { - int length = curstr.Length; + isUnicode = false; - if (isUnicode) - length *= 2; + if (curstr.Length > 0) + curstr.Remove(curstr.Length - 1, 1); - Results.Add(new string[] + curstr.Append((char)data[i]); + } + else if (isChar) + { + curstr.Append((char)data[i]); + } + else if (unicode && data[i] == 0 && IsChar(byte1) && !IsChar(byte2)) + { + // skip null byte + isUnicode = true; + } + else if (unicode && + data[i] == 0 && IsChar(byte1) && IsChar(byte2) && curstr.Length < minsize) + { + // ... [char] [char] *[null]* ([char] [null] [char] [null]) ... + // ^ we are here + isUnicode = true; + curstr = new StringBuilder(); + curstr.Append((char)byte1); + } + else + { + if (curstr.Length >= minsize) { - Utils.FormatAddress(info.BaseAddress), - String.Format("0x{0:x}", i - length), length.ToString(), - curstr.ToString() - }); + int length = curstr.Length; + + if (isUnicode) + length *= 2; + + Results.Add(new string[] { Utils.FormatAddress(info.BaseAddress), + String.Format("0x{0:x}", i - length), length.ToString(), + curstr.ToString() }); - count++; + count++; + } + + isUnicode = false; + curstr = new StringBuilder(); } - isUnicode = false; - curstr = new StringBuilder(); + byte2 = byte1; + byte1 = data[i]; } - byte2 = byte1; - byte1 = data[i]; - } + data = null; - return true; - }); + return true; + }); phandle.Dispose(); diff --git a/1.x/trunk/ProcessHacker/Searchers/StructSearcher.cs b/1.x/trunk/ProcessHacker/Searchers/StructSearcher.cs index b427bbe9b..76257558e 100644 --- a/1.x/trunk/ProcessHacker/Searchers/StructSearcher.cs +++ b/1.x/trunk/ProcessHacker/Searchers/StructSearcher.cs @@ -68,48 +68,44 @@ public override void Search() return; } - phandle.EnumMemory(info => - { - // skip unreadable areas - if (info.Protect == MemoryProtection.AccessDenied) - return true; - if (info.State != MemoryState.Commit) - return true; + phandle.EnumMemory((info) => + { + // skip unreadable areas + if (info.Protect == MemoryProtection.AccessDenied) + return true; + if (info.State != MemoryState.Commit) + return true; - if ((!opt_priv) && (info.Type == MemoryType.Private)) - return true; + if ((!opt_priv) && (info.Type == MemoryType.Private)) + return true; - if ((!opt_img) && (info.Type == MemoryType.Image)) - return true; + if ((!opt_img) && (info.Type == MemoryType.Image)) + return true; - if ((!opt_map) && (info.Type == MemoryType.Mapped)) - return true; + if ((!opt_map) && (info.Type == MemoryType.Mapped)) + return true; - CallSearchProgressChanged( - String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); + CallSearchProgressChanged( + String.Format("Searching 0x{0} ({1} found)...", info.BaseAddress.ToString("x"), count)); - for (int i = 0; i < info.RegionSize.ToInt32(); i += align) - { - try + for (int i = 0; i < info.RegionSize.ToInt32(); i += align) { - structDef.Offset = info.BaseAddress.Increment(i); - structDef.Read(); - - // read succeeded, add it to the results - Results.Add(new string[] + try { - Utils.FormatAddress(info.BaseAddress), - String.Format("0x{0:x}", i), structLen, string.Empty - }); - count++; + structDef.Offset = info.BaseAddress.Increment(i); + structDef.Read(); + + // read succeeded, add it to the results + Results.Add(new string[] { Utils.FormatAddress(info.BaseAddress), + String.Format("0x{0:x}", i), structLen, "" }); + count++; + } + catch + { } } - catch - { - } - } - return true; - }); + return true; + }); phandle.Dispose(); diff --git a/1.x/trunk/ProcessHacker/SharpDevelop/MTA2STA.cs b/1.x/trunk/ProcessHacker/SharpDevelop/MTA2STA.cs index 6fcd1904b..1c358eea6 100644 --- a/1.x/trunk/ProcessHacker/SharpDevelop/MTA2STA.cs +++ b/1.x/trunk/ProcessHacker/SharpDevelop/MTA2STA.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; @@ -15,275 +14,239 @@ namespace Debugger.Interop { - public delegate T MethodInvokerWithReturnValue(); - - public enum CallMethod - { - DirectCall, - Manual, - HiddenForm, - HiddenFormWithTimeout - }; - - public class MTA2STA - { - private readonly Form hiddenForm; - - private readonly Thread targetThread; - private CallMethod callMethod = CallMethod.HiddenFormWithTimeout; - - private readonly Queue pendingCalls = new Queue(); - private readonly ManualResetEvent pendingCallsNotEmpty = new ManualResetEvent(false); - - private WaitHandle EnqueueCall(MethodInvoker callDelegate) - { - lock (pendingCalls) - { - ManualResetEvent callDone = new ManualResetEvent(false); - - pendingCalls.Enqueue(() => - { - callDelegate(); - callDone.Set(); - }); - - pendingCallsNotEmpty.Set(); - return callDone; - } - } - - /// - /// Wait until a call a made - /// - public void WaitForCall() - { - pendingCallsNotEmpty.WaitOne(); - } - - public void WaitForCall(TimeSpan timeout) - { - pendingCallsNotEmpty.WaitOne(timeout, false); - } - - /// - /// Performs all waiting calls on the current thread - /// - public void PerformAllCalls() - { - while (true) - { - if (!PerformCall()) - { - return; - } - } - } - - /// - /// Performs all waiting calls on the current thread - /// - public bool PerformCall() - { - MethodInvoker nextMethod; - lock (pendingCalls) - { - if (pendingCalls.Count > 0) - { - nextMethod = pendingCalls.Dequeue(); - } - else - { - pendingCallsNotEmpty.Reset(); - return false; - } - } - nextMethod(); - return true; - } - - public CallMethod CallMethod - { - get { return callMethod; } - set { callMethod = value; } - } - - public MTA2STA() - { - targetThread = Thread.CurrentThread; - - hiddenForm = new Form(); - // Force handle creation - } - - /// - /// SoftWait waits for any of the given WaitHandles and allows processing of calls during the wait - /// - public int SoftWait(params WaitHandle[] waitFor) - { - List waits = new List(waitFor) - { - this.pendingCallsNotEmpty - }; - - while (true) - { - int i = WaitHandle.WaitAny(waits.ToArray()); - - PerformAllCalls(); - - if (i < waits.Count - 1) - { - // If not pendingCallsNotEmpty - return i; - } - } - } - - /// - /// Schedules invocation of method and returns immediately - /// - public WaitHandle AsyncCall(MethodInvoker callDelegate) - { - WaitHandle callDone = EnqueueCall(callDelegate); - TriggerInvoke(); - return callDone; - } - - public T Call(MethodInvokerWithReturnValue callDelegate) - { - T returnValue = default(T); - Call(delegate { returnValue = callDelegate(); }, true); - return returnValue; - } - - public void Call(MethodInvoker callDelegate) - { - Call(callDelegate, false); - } - - private void Call(MethodInvoker callDelegate, bool hasReturnValue) - { - // Enqueue the call - WaitHandle callDone = EnqueueCall(callDelegate); - - if (targetThread == Thread.CurrentThread) - { - PerformAllCalls(); - return; - } - - // We have the call waiting in queue, we need to call it (not waiting for it to finish) - TriggerInvoke(); - - // Wait for the call to finish - if (!hasReturnValue && callMethod == CallMethod.HiddenFormWithTimeout) - { - // Give it 5 seconds to run - if (!callDone.WaitOne(5000, true)) - { - Debug.WriteLine("Call time out! (continuing)"); - Debug.WriteLine(new StackTrace(true).ToString()); - } - } - else - { - callDone.WaitOne(); - } - } - - private void TriggerInvoke() - { - switch (callMethod) - { - case CallMethod.DirectCall: - PerformAllCalls(); - break; - case CallMethod.Manual: - // Nothing we can do - someone else must call SoftWait or Pulse - break; - case CallMethod.HiddenForm: - case CallMethod.HiddenFormWithTimeout: - hiddenForm.BeginInvoke((MethodInvoker)PerformAllCalls); - break; - } - } - - public static object MarshalParamTo(object param, Type outputType) - { - if (param is IntPtr) - { - return MarshalIntPtrTo((IntPtr)param, outputType); - } - - return param; - } - - public static T MarshalIntPtrTo(IntPtr param) - { - return (T)MarshalIntPtrTo(param, typeof(T)); - } - - public static object MarshalIntPtrTo(IntPtr param, Type outputType) - { - // IntPtr requested as output (must be before the null check so that we pass IntPtr.Zero) - if (outputType == typeof(IntPtr)) - { - return param; - } - // The parameter is null pointer - if (param == IntPtr.Zero) - { - return null; - } - // String requested as output - if (outputType == typeof(string)) - { - return Marshal.PtrToStringAuto(param); - } - // Marshal a COM object - object comObject = Marshal.GetObjectForIUnknown(param); - return Activator.CreateInstance(outputType, comObject); - } - - /// - /// Uses reflection to call method. Automaticaly marshals parameters. - /// - /// Targed object which contains the method. In case of static mehod pass the Type - /// The name of the function to call - /// Parameters which should be send to the function. Parameters will be marshaled to proper type. - /// Return value of the called function - public static object InvokeMethod(object targetObject, string functionName, object[] functionParameters) - { - MethodInfo method; - if (targetObject is Type) - { - method = ((Type)targetObject).GetMethod(functionName); - } - else - { - method = targetObject.GetType().GetMethod(functionName); - } - - ParameterInfo[] methodParamsInfo = method.GetParameters(); - object[] convertedParams = new object[methodParamsInfo.Length]; - - for (int i = 0; i < convertedParams.Length; i++) - { - convertedParams[i] = MarshalParamTo(functionParameters[i], methodParamsInfo[i].ParameterType); - } - - try - { - if (targetObject is Type) - { - return method.Invoke(null, convertedParams); - } - return method.Invoke(targetObject, convertedParams); - } - catch (Exception exception) - { - throw new Exception("Invoke of " + functionName + " failed.", exception); - } - } - } + public delegate T MethodInvokerWithReturnValue(); + + public enum CallMethod {DirectCall, Manual, HiddenForm, HiddenFormWithTimeout}; + + public class MTA2STA + { + Form hiddenForm; + IntPtr hiddenFormHandle; + + System.Threading.Thread targetThread; + CallMethod callMethod = CallMethod.HiddenFormWithTimeout; + + Queue pendingCalls = new Queue(); + ManualResetEvent pendingCallsNotEmpty = new ManualResetEvent(false); + + WaitHandle EnqueueCall(MethodInvoker callDelegate) + { + lock (pendingCalls) { + ManualResetEvent callDone = new ManualResetEvent(false); + pendingCalls.Enqueue(delegate{ + callDelegate(); + callDone.Set(); + }); + pendingCallsNotEmpty.Set(); + return callDone; + } + } + + /// + /// Wait until a call a made + /// + public void WaitForCall() + { + pendingCallsNotEmpty.WaitOne(); + } + + public void WaitForCall(TimeSpan timeout) + { + pendingCallsNotEmpty.WaitOne(timeout, false); + } + + /// + /// Performs all waiting calls on the current thread + /// + public void PerformAllCalls() + { + while (true) { + if (!PerformCall()) { + return; + } + } + } + + /// + /// Performs all waiting calls on the current thread + /// + public bool PerformCall() + { + MethodInvoker nextMethod; + lock (pendingCalls) { + if (pendingCalls.Count > 0) { + nextMethod = pendingCalls.Dequeue(); + } else { + pendingCallsNotEmpty.Reset(); + return false; + } + } + nextMethod(); + return true; + } + + public CallMethod CallMethod { + get { + return callMethod; + } + set { + callMethod = value; + } + } + + public MTA2STA() + { + targetThread = System.Threading.Thread.CurrentThread; + + hiddenForm = new Form(); + // Force handle creation + hiddenFormHandle = hiddenForm.Handle; + } + + /// + /// SoftWait waits for any of the given WaitHandles and allows processing of calls during the wait + /// + public int SoftWait(params WaitHandle[] waitFor) + { + List waits = new List (waitFor); + waits.Add(pendingCallsNotEmpty); + while(true) { + int i = WaitHandle.WaitAny(waits.ToArray()); + PerformAllCalls(); + if (i < waits.Count - 1) { // If not pendingCallsNotEmpty + return i; + } + } + } + + /// + /// Schedules invocation of method and returns immediately + /// + public WaitHandle AsyncCall(MethodInvoker callDelegate) + { + WaitHandle callDone = EnqueueCall(callDelegate); + TriggerInvoke(); + return callDone; + } + + public T Call(MethodInvokerWithReturnValue callDelegate) + { + T returnValue = default(T); + Call(delegate { returnValue = callDelegate(); }, true); + return returnValue; + } + + public void Call(MethodInvoker callDelegate) + { + Call(callDelegate, false); + } + + void Call(MethodInvoker callDelegate, bool hasReturnValue) + { + // Enqueue the call + WaitHandle callDone = EnqueueCall(callDelegate); + + if (targetThread == System.Threading.Thread.CurrentThread) { + PerformAllCalls(); + return; + } + + // We have the call waiting in queue, we need to call it (not waiting for it to finish) + TriggerInvoke(); + + // Wait for the call to finish + if (!hasReturnValue && callMethod == CallMethod.HiddenFormWithTimeout) { + // Give it 5 seconds to run + if (!callDone.WaitOne(5000, true)) { + System.Console.WriteLine("Call time out! (continuing)"); + System.Console.WriteLine(new System.Diagnostics.StackTrace(true).ToString()); + } + } else { + callDone.WaitOne(); + } + } + + void TriggerInvoke() + { + switch (callMethod) { + case CallMethod.DirectCall: + PerformAllCalls(); + break; + case CallMethod.Manual: + // Nothing we can do - someone else must call SoftWait or Pulse + break; + case CallMethod.HiddenForm: + case CallMethod.HiddenFormWithTimeout: + hiddenForm.BeginInvoke((MethodInvoker)PerformAllCalls); + break; + } + } + + public static object MarshalParamTo(object param, Type outputType) + { + if (param is IntPtr) { + return MarshalIntPtrTo((IntPtr)param, outputType); + } else { + return param; + } + } + + public static T MarshalIntPtrTo(IntPtr param) + { + return (T)MarshalIntPtrTo(param, typeof(T)); + } + + public static object MarshalIntPtrTo(IntPtr param, Type outputType) + { + // IntPtr requested as output (must be before the null check so that we pass IntPtr.Zero) + if (outputType == typeof(IntPtr)) { + return param; + } + // The parameter is null pointer + if ((IntPtr)param == IntPtr.Zero) { + return null; + } + // String requested as output + if (outputType == typeof(string)) { + return Marshal.PtrToStringAuto((IntPtr)param); + } + // Marshal a COM object + object comObject = Marshal.GetObjectForIUnknown(param); + return Activator.CreateInstance(outputType, comObject); + } + + /// + /// Uses reflection to call method. Automaticaly marshals parameters. + /// + /// Targed object which contains the method. In case of static mehod pass the Type + /// The name of the function to call + /// Parameters which should be send to the function. Parameters will be marshaled to proper type. + /// Return value of the called function + public static object InvokeMethod(object targetObject, string functionName, object[] functionParameters) + { + System.Reflection.MethodInfo method; + if (targetObject is Type) { + method = ((Type)targetObject).GetMethod(functionName); + } else { + method = targetObject.GetType().GetMethod(functionName); + } + + ParameterInfo[] methodParamsInfo = method.GetParameters(); + object[] convertedParams = new object[methodParamsInfo.Length]; + + for (int i = 0; i < convertedParams.Length; i++) { + convertedParams[i] = MarshalParamTo(functionParameters[i], methodParamsInfo[i].ParameterType); + } + + try { + if (targetObject is Type) { + return method.Invoke(null, convertedParams); + } else { + return method.Invoke(targetObject, convertedParams); + } + } catch (System.Exception exception) { + throw new Exception("Invoke of " + functionName + " failed.", exception); + } + } + } } diff --git a/1.x/trunk/ProcessHacker/SharpDevelop/NDebugger.cs b/1.x/trunk/ProcessHacker/SharpDevelop/NDebugger.cs index 411ef91d6..174f1770c 100644 --- a/1.x/trunk/ProcessHacker/SharpDevelop/NDebugger.cs +++ b/1.x/trunk/ProcessHacker/SharpDevelop/NDebugger.cs @@ -3,30 +3,35 @@ namespace Debugger { - [Serializable] - public class DebuggerEventArgs : EventArgs - { - private readonly object debugger; + [Serializable] + public class DebuggerEventArgs : EventArgs + { + object debugger; public object Debugger { - get { return debugger; } - } + get { + return debugger; + } + } public DebuggerEventArgs(object debugger) - { - this.debugger = debugger; - } - } + { + this.debugger = debugger; + } + } [Serializable] public class ProcessEventArgs : DebuggerEventArgs { - private readonly Process process; + Process process; public Process Process { - get { return process; } + get + { + return process; + } } public ProcessEventArgs(Process process) @@ -39,23 +44,32 @@ public ProcessEventArgs(Process process) [Serializable] public class MessageEventArgs : ProcessEventArgs { - private readonly int level; - private readonly string message; - private readonly string category; + int level; + string message; + string category; public int Level { - get { return level; } + get + { + return level; + } } public string Message { - get { return message; } + get + { + return message; + } } public string Category { - get { return category; } + get + { + return category; + } } public MessageEventArgs(Process process, string message) diff --git a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublish.cs b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublish.cs index c8ec2dd33..d73cbdf1e 100644 --- a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublish.cs +++ b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublish.cs @@ -9,18 +9,22 @@ namespace Debugger.Core.Wrappers.CorPub { - public class ICorPublish + using System; + using System.Runtime.InteropServices; + using Debugger.Wrappers; + + public partial class ICorPublish { - private readonly Interop.CorPub.CorpubPublishClass corpubPublishClass; + private Debugger.Interop.CorPub.CorpubPublishClass corpubPublishClass; public ICorPublish() { - corpubPublishClass = new Interop.CorPub.CorpubPublishClass(); + corpubPublishClass = new Debugger.Interop.CorPub.CorpubPublishClass(); } public ICorPublishProcess GetProcess(int id) { - Interop.CorPub.ICorPublishProcess process; + Debugger.Interop.CorPub.ICorPublishProcess process; this.corpubPublishClass.GetProcess((uint)id, out process); return ICorPublishProcess.Wrap(process); } diff --git a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublishProcess.cs b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublishProcess.cs index c9ffa7a98..ec20015f6 100644 --- a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublishProcess.cs +++ b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/CorPub/ICorPublishProcess.cs @@ -9,13 +9,16 @@ namespace Debugger.Core.Wrappers.CorPub { - using Debugger.Wrappers; + using System; + using System.Runtime.InteropServices; + using System.Text; + using Debugger.Wrappers; - public class ICorPublishProcess + public partial class ICorPublishProcess { - private readonly Interop.CorPub.ICorPublishProcess wrappedObject; + private Debugger.Interop.CorPub.ICorPublishProcess wrappedObject; - internal Interop.CorPub.ICorPublishProcess WrappedObject + internal Debugger.Interop.CorPub.ICorPublishProcess WrappedObject { get { @@ -23,23 +26,24 @@ internal Interop.CorPub.ICorPublishProcess WrappedObject } } - public ICorPublishProcess(Interop.CorPub.ICorPublishProcess wrappedObject) + public ICorPublishProcess(Debugger.Interop.CorPub.ICorPublishProcess wrappedObject) { this.wrappedObject = wrappedObject; ResourceManager.TrackCOMObject(wrappedObject, typeof(ICorPublishProcess)); } - public static ICorPublishProcess Wrap(Interop.CorPub.ICorPublishProcess objectToWrap) + public static ICorPublishProcess Wrap(Debugger.Interop.CorPub.ICorPublishProcess objectToWrap) { - if (objectToWrap != null) + if ((objectToWrap != null)) { return new ICorPublishProcess(objectToWrap); + } else + { + return null; } - - return null; } - - public int ProcessId + + public int ProcessId { get { diff --git a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/NativeMethods.cs b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/NativeMethods.cs index 9cd37870d..91ad5d2c7 100644 --- a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/NativeMethods.cs +++ b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/NativeMethods.cs @@ -33,9 +33,9 @@ public static class NativeMethods public static string GetDebuggerVersion() { int size; - GetCORVersion(null, 0, out size); + NativeMethods.GetCORVersion(null, 0, out size); StringBuilder sb = new StringBuilder(size); - int hr = GetCORVersion(sb, sb.Capacity, out size); + int hr = NativeMethods.GetCORVersion(sb, sb.Capacity, out size); return sb.ToString(); } } diff --git a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/ResourceManager.cs b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/ResourceManager.cs index b49bbe815..d2e496f06 100644 --- a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/ResourceManager.cs +++ b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/ResourceManager.cs @@ -29,9 +29,9 @@ public TrackedObjectMetaData(Type objectType, int refCount) public static class ResourceManager { - static readonly MTA2STA mta2sta = new MTA2STA(); - static bool trace; - static readonly Dictionary trackedCOMObjects = new Dictionary(); + static MTA2STA mta2sta = new MTA2STA(); + static bool trace = false; + static Dictionary trackedCOMObjects = new Dictionary(); public static bool TraceMessagesEnabled { get { @@ -57,65 +57,57 @@ public static void TrackCOMObject(object comObject, Type type) if (trace) Trace("AddRef {0,2}: {1}", metaData.RefCount, type.Name); } } - - public static void ReleaseCOMObject(object comObject, Type type) - { - // Ensure that the release is done synchronosly - try - { - mta2sta.AsyncCall(() => ReleaseCOMObjectInternal(comObject, type)); - } - catch (InvalidOperationException) - { - // This might happen when the application is shuting down - } - } - - static void ReleaseCOMObjectInternal(object comObject, Type type) - { - TrackedObjectMetaData metaData; - if (comObject != null && trackedCOMObjects.TryGetValue(comObject, out metaData)) - { - metaData.RefCount -= 1; - if (metaData.RefCount == 0) - { - Marshal.FinalReleaseComObject(comObject); - trackedCOMObjects.Remove(comObject); - } - if (trace) Trace("Release {0,2}: {1}", metaData.RefCount, type.Name); - } - else - { - if (trace) Trace("Was not tracked: {0}", type.Name); - } - } - - public static void ReleaseAllTrackedCOMObjects() - { - if (trace) Trace("Releasing {0} tracked COM objects... ", trackedCOMObjects.Count); - while (trackedCOMObjects.Count > 0) - { - foreach (KeyValuePair pair in trackedCOMObjects) - { - Marshal.FinalReleaseComObject(pair.Key); - if (trace) Trace(" * Releasing {0} ({1} references)", pair.Value.ObjectType.Name, pair.Value.RefCount); - trackedCOMObjects.Remove(pair.Key); - break; - } - } - if (trace) Trace(" * Done"); - } - - public static event EventHandler TraceMessage; - - static void Trace(string msg, params object[] pars) - { - if (TraceMessage != null && trace) - { - string message = String.Format("COM({0,-3}): {1}", trackedCOMObjects.Count, String.Format(msg, pars)); - TraceMessage(null, new MessageEventArgs(null, message)); - } - } + + public static void ReleaseCOMObject(object comObject, Type type) + { + // Ensure that the release is done synchronosly + try { + mta2sta.AsyncCall(delegate { + ReleaseCOMObjectInternal(comObject, type); + }); + } catch (InvalidOperationException) { + // This might happen when the application is shuting down + } + } + + static void ReleaseCOMObjectInternal(object comObject, Type type) + { + TrackedObjectMetaData metaData; + if (comObject != null && trackedCOMObjects.TryGetValue(comObject, out metaData)) { + metaData.RefCount -= 1; + if (metaData.RefCount == 0) { + Marshal.FinalReleaseComObject(comObject); + trackedCOMObjects.Remove(comObject); + } + if (trace) Trace("Release {0,2}: {1}", metaData.RefCount, type.Name); + } else { + if (trace) Trace("Was not tracked: {0}", type.Name); + } + } + + public static void ReleaseAllTrackedCOMObjects() + { + if (trace) Trace("Releasing {0} tracked COM objects... ", trackedCOMObjects.Count); + while(trackedCOMObjects.Count > 0) { + foreach (KeyValuePair pair in trackedCOMObjects) { + Marshal.FinalReleaseComObject(pair.Key); + if (trace) Trace(" * Releasing {0} ({1} references)", pair.Value.ObjectType.Name, pair.Value.RefCount); + trackedCOMObjects.Remove(pair.Key); + break; + } + } + if (trace) Trace(" * Done"); + } + + public static event EventHandler TraceMessage; + + static void Trace(string msg, params object[] pars) + { + if (TraceMessage != null && trace) { + string message = String.Format("COM({0,-3}): {1}", trackedCOMObjects.Count, String.Format(msg, pars)); + TraceMessage(null, new MessageEventArgs(null, message)); + } + } } } diff --git a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/Util.cs b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/Util.cs index 96839ba83..5b0b2814e 100644 --- a/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/Util.cs +++ b/1.x/trunk/ProcessHacker/SharpDevelop/Wrappers/Util.cs @@ -9,11 +9,10 @@ using System; using System.Runtime.InteropServices; -using ProcessHacker.Native; namespace Debugger.Wrappers { - public delegate void UnmanagedStringGetter(uint pStringLenght, out uint stringLenght, IntPtr pString); + public delegate void UnmanagedStringGetter(uint pStringLenght, out uint stringLenght, System.IntPtr pString); public static class Util { @@ -24,30 +23,29 @@ public static string GetString(UnmanagedStringGetter getter) public static string GetString(UnmanagedStringGetter getter, uint defaultLenght, bool trim) { - uint exactLenght; + string managedString; + IntPtr unmanagedString; + uint exactLenght; // First attempt - IntPtr unmanagedString = MemoryAlloc.PrivateHeap.Allocate((int)defaultLenght * 2 + 2); + unmanagedString = Marshal.AllocHGlobal((int)defaultLenght * 2 + 2); // + 2 for terminating zero getter(defaultLenght, out exactLenght, defaultLenght > 0 ? unmanagedString : IntPtr.Zero); - if(exactLenght > defaultLenght) - { + if(exactLenght > defaultLenght) { // Second attempt - MemoryAlloc.PrivateHeap.Free(unmanagedString); - unmanagedString = MemoryAlloc.PrivateHeap.Allocate((int)exactLenght * 2 + 2); // + 2 for terminating zero + Marshal.FreeHGlobal(unmanagedString); + unmanagedString = Marshal.AllocHGlobal((int)exactLenght * 2 + 2); // + 2 for terminating zero getter(exactLenght, out exactLenght, unmanagedString); } // Return managed string and free unmanaged memory - string managedString = Marshal.PtrToStringUni(unmanagedString, (int)exactLenght); + managedString = Marshal.PtrToStringUni(unmanagedString, (int)exactLenght); //Console.WriteLine("Marshaled string from COM: \"" + managedString + "\" lenght=" + managedString.Length + " arrayLenght=" + exactLenght); // The API might or might not include terminating null at the end - if (trim) - { + if (trim) { managedString = managedString.TrimEnd('\0'); } - - MemoryAlloc.PrivateHeap.Free(unmanagedString); + Marshal.FreeHGlobal(unmanagedString); return managedString; } } diff --git a/1.x/trunk/ProcessHacker/Structs/FieldType.cs b/1.x/trunk/ProcessHacker/Structs/FieldType.cs index f1a707f8f..d32b1b304 100644 --- a/1.x/trunk/ProcessHacker/Structs/FieldType.cs +++ b/1.x/trunk/ProcessHacker/Structs/FieldType.cs @@ -21,10 +21,11 @@ */ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Structs { - [Flags] public enum FieldType : uint { Bool8 = 0x1, diff --git a/1.x/trunk/ProcessHacker/Structs/FieldValue.cs b/1.x/trunk/ProcessHacker/Structs/FieldValue.cs index 781493dea..0df47d56b 100644 --- a/1.x/trunk/ProcessHacker/Structs/FieldValue.cs +++ b/1.x/trunk/ProcessHacker/Structs/FieldValue.cs @@ -21,6 +21,8 @@ */ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Structs { diff --git a/1.x/trunk/ProcessHacker/Structs/ProcessMemoryIO.cs b/1.x/trunk/ProcessHacker/Structs/ProcessMemoryIO.cs index 9f858fc1b..8145910ad 100644 --- a/1.x/trunk/ProcessHacker/Structs/ProcessMemoryIO.cs +++ b/1.x/trunk/ProcessHacker/Structs/ProcessMemoryIO.cs @@ -27,8 +27,8 @@ namespace ProcessHacker.Structs { public class ProcessMemoryIO : IStructIOProvider { - private readonly ProcessHandle _phandleR; - private readonly ProcessHandle _phandleW; + private ProcessHandle _phandleR; + private ProcessHandle _phandleW; public ProcessMemoryIO(int pid) { diff --git a/1.x/trunk/ProcessHacker/Structs/StructDef.cs b/1.x/trunk/ProcessHacker/Structs/StructDef.cs index 67f6c7ec5..338941d3e 100644 --- a/1.x/trunk/ProcessHacker/Structs/StructDef.cs +++ b/1.x/trunk/ProcessHacker/Structs/StructDef.cs @@ -30,8 +30,8 @@ namespace ProcessHacker.Structs { public class StructDef { - private readonly List _fields = new List(); - private readonly Dictionary _fieldsByName = new Dictionary(); + private List _fields = new List(); + private Dictionary _fieldsByName = new Dictionary(); public IStructIOProvider IOProvider { get; set; } @@ -49,6 +49,7 @@ public int Size } public IntPtr Offset { get; set; } + public Dictionary Structs { get; set; } public StructField AddField(StructField field) @@ -131,18 +132,14 @@ private int Read(StructField field, IntPtr offset, out FieldValue valueOut) private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue valueOut) { - FieldValue value = new FieldValue - { - FieldType = field.Type, - Name = field.Name - }; - - int readSize; + FieldValue value = new FieldValue() { FieldType = field.Type, Name = field.Name }; + int readSize = 0; switch (field.Type) { case FieldType.Bool32: - value.Value = this.IOProvider.ReadBytes(offset, 4).ToInt32(Utils.Endianness.Little) != 0; + value.Value = Utils.ToInt32(IOProvider.ReadBytes(offset, 4), + Utils.Endianness.Little) != 0; readSize = 4; break; case FieldType.Bool8: @@ -159,22 +156,26 @@ private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue val break; case FieldType.Double: { - long data = this.IOProvider.ReadBytes(offset, 8).ToInt64(Utils.Endianness.Little); + long data = Utils.ToInt64( + IOProvider.ReadBytes(offset, 8), Utils.Endianness.Little); value.Value = *(double*)&data; readSize = 8; } break; case FieldType.Int16: - value.Value = (short)this.IOProvider.ReadBytes(offset, 2).ToUInt16(Utils.Endianness.Little); + value.Value = (short)Utils.ToUInt16( + IOProvider.ReadBytes(offset, 2), Utils.Endianness.Little); readSize = 2; break; case FieldType.Int32: - value.Value = this.IOProvider.ReadBytes(offset, 4).ToInt32(Utils.Endianness.Little); + value.Value = Utils.ToInt32( + IOProvider.ReadBytes(offset, 4), Utils.Endianness.Little); readSize = 4; break; case FieldType.Int64: - value.Value = this.IOProvider.ReadBytes(offset, 8).ToInt64(Utils.Endianness.Little); + value.Value = Utils.ToInt64( + IOProvider.ReadBytes(offset, 8), Utils.Endianness.Little); readSize = 8; break; case FieldType.Int8: @@ -187,7 +188,8 @@ private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue val break; case FieldType.Single: { - int data = this.IOProvider.ReadBytes(offset, 4).ToInt32(Utils.Endianness.Little); + int data = Utils.ToInt32( + IOProvider.ReadBytes(offset, 4), Utils.Endianness.Little); value.Value = *(float*)&data; readSize = 4; @@ -215,7 +217,8 @@ private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue val } else { - str.Append(Encoding.ASCII.GetString(IOProvider.ReadBytes(offset, field.VarLength))); + str.Append(Encoding.ASCII.GetString( + IOProvider.ReadBytes(offset, field.VarLength))); readSize = field.VarLength; } @@ -235,7 +238,7 @@ private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue val { byte[] b = IOProvider.ReadBytes(offset.Increment(i), 2); - if (b.IsEmpty()) + if (Utils.IsEmpty(b)) break; str.Append(Encoding.Unicode.GetString(b)); @@ -245,7 +248,8 @@ private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue val } else { - str.Append(Encoding.Unicode.GetString(IOProvider.ReadBytes(offset, field.VarLength * 2))); // each char is 2 bytes + str.Append(Encoding.Unicode.GetString( + IOProvider.ReadBytes(offset, field.VarLength * 2))); // each char is 2 bytes readSize = field.VarLength; } @@ -268,15 +272,18 @@ private unsafe int ReadOnce(StructField field, IntPtr offset, out FieldValue val break; case FieldType.UInt16: - value.Value = this.IOProvider.ReadBytes(offset, 2).ToUInt16(Utils.Endianness.Little); + value.Value = Utils.ToUInt16( + IOProvider.ReadBytes(offset, 2), Utils.Endianness.Little); readSize = 2; break; case FieldType.UInt32: - value.Value = this.IOProvider.ReadBytes(offset, 4).ToUInt32(Utils.Endianness.Little); + value.Value = Utils.ToUInt32( + IOProvider.ReadBytes(offset, 4), Utils.Endianness.Little); readSize = 4; break; case FieldType.UInt64: - value.Value = (ulong)this.IOProvider.ReadBytes(offset, 8).ToInt64(Utils.Endianness.Little); + value.Value = (ulong)Utils.ToInt64( + IOProvider.ReadBytes(offset, 8), Utils.Endianness.Little); readSize = 8; break; case FieldType.UInt8: @@ -313,18 +320,9 @@ public int Read(out FieldValue[] values) localOffset += IntPtr.Size; if (pointingTo == IntPtr.Zero) - { - value = new FieldValue - { - Name = field.Name, - FieldType = field.RawType, - Value = null - }; - } + value = new FieldValue() { Name = field.Name, FieldType = field.RawType, Value = null }; else - { Read(field, pointingTo, out value); - } value.PointerValue = pointingTo; } @@ -335,8 +333,10 @@ public int Read(out FieldValue[] values) if (field.SetsVarOn != null) { - _fieldsByName[field.SetsVarOn].VarLength = field.SetsVarOnAdd + (int)(int.Parse(value.Value.ToString()) * (decimal)field.SetsVarOnMultiply); - _fieldsByName[field.SetsVarOn].VarArrayLength = field.SetsVarOnAdd + (int)(int.Parse(value.Value.ToString()) * (decimal)field.SetsVarOnMultiply); + _fieldsByName[field.SetsVarOn].VarLength = + field.SetsVarOnAdd + (int)(int.Parse(value.Value.ToString()) * (decimal)field.SetsVarOnMultiply); + _fieldsByName[field.SetsVarOn].VarArrayLength = + field.SetsVarOnAdd + (int)(int.Parse(value.Value.ToString()) * (decimal)field.SetsVarOnMultiply); } list.Add(value); diff --git a/1.x/trunk/ProcessHacker/Structs/StructField.cs b/1.x/trunk/ProcessHacker/Structs/StructField.cs index bf6b9c9b3..7efc0df6b 100644 --- a/1.x/trunk/ProcessHacker/Structs/StructField.cs +++ b/1.x/trunk/ProcessHacker/Structs/StructField.cs @@ -21,12 +21,14 @@ */ using System; +using System.Collections.Generic; +using System.Text; namespace ProcessHacker.Structs { public class StructField { - private readonly FieldType _type; + private FieldType _type; public StructField(string name, FieldType type) { @@ -115,83 +117,91 @@ public int Size { return IntPtr.Size; } + else + { + int size; - int size; + switch (_type) + { + case FieldType.Bool32: + size = 4; + break; + case FieldType.Bool8: + size = 1; + break; + case FieldType.CharASCII: + size = 1; + break; + case FieldType.CharUTF16: + size = 2; // UCS-2 + break; + case FieldType.Double: + size = 8; + break; + case FieldType.Int16: + size = 2; + break; + case FieldType.Int32: + size = 4; + break; + case FieldType.Int64: + size = 8; + break; + case FieldType.Int8: + size = 1; + break; + case FieldType.PVoid: + size = IntPtr.Size; + break; + case FieldType.Single: + size = 4; + break; + case FieldType.StringASCII: + size = VarLength; + break; + case FieldType.StringUTF16: + size = VarLength * 2; + break; + case FieldType.Struct: + size = 0; + break; + case FieldType.UInt16: + size = 2; + break; + case FieldType.UInt32: + size = 4; + break; + case FieldType.UInt64: + size = 8; + break; + case FieldType.UInt8: + size = 1; + break; + default: + size = 0; + break; + } - switch (this._type) - { - case FieldType.Bool32: - size = 4; - break; - case FieldType.Bool8: - size = 1; - break; - case FieldType.CharASCII: - size = 1; - break; - case FieldType.CharUTF16: - size = 2; // UCS-2 - break; - case FieldType.Double: - size = 8; - break; - case FieldType.Int16: - size = 2; - break; - case FieldType.Int32: - size = 4; - break; - case FieldType.Int64: - size = 8; - break; - case FieldType.Int8: - size = 1; - break; - case FieldType.PVoid: - size = IntPtr.Size; - break; - case FieldType.Single: - size = 4; - break; - case FieldType.StringASCII: - size = this.VarLength; - break; - case FieldType.StringUTF16: - size = this.VarLength * 2; - break; - case FieldType.Struct: - size = 0; - break; - case FieldType.UInt16: - size = 2; - break; - case FieldType.UInt32: - size = 4; - break; - case FieldType.UInt64: - size = 8; - break; - case FieldType.UInt8: - size = 1; - break; - default: - size = 0; - break; + if (this.IsArray) + return size * VarArrayLength; + else + return size; } - - if (this.IsArray) - return size * this.VarArrayLength; - - return size; } } public string Name { get; set; } + internal int VarArrayLength { get; set; } + internal int VarLength { get; set; } + public string SetsVarOn { get; set; } + public int SetsVarOnAdd { get; set; } + public float SetsVarOnMultiply { get; set; } + public string StructName { get; set; } public FieldType Type diff --git a/1.x/trunk/ProcessHacker/Structs/StructParser.cs b/1.x/trunk/ProcessHacker/Structs/StructParser.cs index 6cb5960a9..cbd566a3a 100644 --- a/1.x/trunk/ProcessHacker/Structs/StructParser.cs +++ b/1.x/trunk/ProcessHacker/Structs/StructParser.cs @@ -36,13 +36,13 @@ public ParserException(string fileName, int line, string message) : public class StructParser { - private readonly Dictionary _structs; + private Dictionary _structs; - private string _fileName = string.Empty; + private string _fileName = ""; private int _lineNumber = 1; - private readonly Dictionary _typeDefs = new Dictionary(); - private readonly Dictionary _defines = new Dictionary(); - private bool _eatResult; + private Dictionary _typeDefs = new Dictionary(); + private Dictionary _defines = new Dictionary(); + private bool _eatResult = false; public Dictionary Structs { @@ -69,8 +69,8 @@ private FieldType GetType(string typeName) { if (_typeDefs.ContainsKey(typeName)) return _typeDefs[typeName]; - - throw new ParserException(this._fileName, this._lineNumber, "Unknown identifier '" + typeName + "' (type name)"); + else + throw new ParserException(_fileName, _lineNumber, "Unknown identifier '" + typeName + "' (type name)"); } private bool IsTypePointer(FieldType type) @@ -88,14 +88,14 @@ private string Preprocess(string text) { string line = lines[i].Trim(' ', '\t', '\r'); - if (line.StartsWith("#if", StringComparison.OrdinalIgnoreCase)) + if (line.StartsWith("#if")) { string conditionText = line.Remove(0, "#if".Length).Trim(' ', '\t', '\r'); includeStack.Push(include); include = _defines.ContainsKey(conditionText); } - else if (line.StartsWith("#elseif", StringComparison.OrdinalIgnoreCase)) + else if (line.StartsWith("#elseif")) { if (!include) { @@ -108,11 +108,11 @@ private string Preprocess(string text) include = false; } } - else if (line.StartsWith("#else", StringComparison.OrdinalIgnoreCase)) + else if (line.StartsWith("#else")) { include = !include; } - else if (line.StartsWith("#define", StringComparison.OrdinalIgnoreCase)) + else if (line.StartsWith("#define")) { string conditionText = line.Remove(0, "#define".Length).Trim(' ', '\t', '\r'); @@ -121,14 +121,14 @@ private string Preprocess(string text) _defines.Add(conditionText, null); } } - else if (line.StartsWith("#endif", StringComparison.OrdinalIgnoreCase)) + else if (line.StartsWith("#endif")) { include = includeStack.Pop(); } - if (!include || line.StartsWith("#", StringComparison.OrdinalIgnoreCase)) + if (!include || line.StartsWith("#")) { - lines[i] = string.Empty; + lines[i] = ""; } } @@ -137,6 +137,7 @@ private string Preprocess(string text) public void Parse(string fileName) { + List defs = new List(); int i = 0; string text = System.IO.File.ReadAllText(fileName); @@ -151,23 +152,23 @@ public void Parse(string fileName) string modeName = EatId(text, ref i); - if (string.IsNullOrEmpty(modeName)) + if (modeName == "") throw new ParserException(_fileName, _lineNumber, "Expected keyword"); - if (modeName.Equals("typedef", StringComparison.OrdinalIgnoreCase)) + if (modeName == "typedef") { this.ParseTypeDef(text, ref i); } - else if (modeName.Equals("struct", StringComparison.OrdinalIgnoreCase)) + else if (modeName == "struct") { this.ParseStructDef(text, ref i); } - else if (modeName.Equals("include", StringComparison.OrdinalIgnoreCase)) + else if (modeName == "include") { _eatResult = EatWhitespace(text, ref i); string includeFile = EatQuotedString(text, ref i); - if (_eatResult || string.IsNullOrEmpty(includeFile)) + if (_eatResult || includeFile == "") throw new ParserException(_fileName, _lineNumber, "String expected (file name)"); _eatResult = EatWhitespace(text, ref i); @@ -185,7 +186,7 @@ public void Parse(string fileName) try { - if (includeFile.Contains(":", StringComparison.OrdinalIgnoreCase)) + if (includeFile.Contains(":")) this.Parse(includeFile); else this.Parse(info.DirectoryName + "\\" + includeFile); @@ -210,7 +211,7 @@ private void ParseTypeDef(string text, ref int i) _eatResult = EatWhitespace(text, ref i); string existingType = EatId(text, ref i); - if (_eatResult || string.IsNullOrEmpty(existingType)) + if (_eatResult || existingType == "") throw new ParserException(_fileName, _lineNumber, "Expected identifier (type name)"); if (!_typeDefs.ContainsKey(existingType)) @@ -226,7 +227,7 @@ private void ParseTypeDef(string text, ref int i) _eatResult = EatWhitespace(text, ref i); string newType = EatId(text, ref i); - if (_eatResult || string.IsNullOrEmpty(existingType)) + if (_eatResult || existingType == "") throw new ParserException(_fileName, _lineNumber, "Expected identifier (new type name)"); if (_typeDefs.ContainsKey(newType)) @@ -251,7 +252,7 @@ private void ParseStructDef(string text, ref int i) _eatResult = EatWhitespace(text, ref i); string structName = EatId(text, ref i); - if (_eatResult || string.IsNullOrEmpty(structName)) + if (_eatResult || structName == "") throw new ParserException(_fileName, _lineNumber, "Expected identifier (struct name)"); if (_structs.ContainsKey(structName)) @@ -284,7 +285,7 @@ private void ParseStructDef(string text, ref int i) _eatResult = EatWhitespace(text, ref i); string typeName = EatId(text, ref i); - if (_eatResult || string.IsNullOrEmpty(typeName)) + if (_eatResult || typeName == "") throw new ParserException(_fileName, _lineNumber, "Expected type name"); FieldType type; @@ -320,7 +321,7 @@ private void ParseStructDef(string text, ref int i) _eatResult = EatWhitespace(text, ref i); string fieldName = EatId(text, ref i); - if (_eatResult || string.IsNullOrEmpty(fieldName)) + if (_eatResult || fieldName == "") throw new ParserException(_fileName, _lineNumber, "Expected identifier (struct field name)"); if (def.ContainsField(fieldName)) @@ -336,7 +337,7 @@ private void ParseStructDef(string text, ref int i) string fieldRefName = EatId(text, ref i); string fieldSizeSpec = EatNumber(text, ref i); - if (!string.IsNullOrEmpty(fieldRefName)) + if (fieldRefName != "") { if (!def.ContainsField(fieldRefName)) throw new ParserException(_fileName, _lineNumber, "Unknown identifier '" + fieldRefName + "' (field name)"); @@ -390,11 +391,11 @@ private void ParseStructDef(string text, ref int i) i = iSave; } } - else if (!string.IsNullOrEmpty(fieldSizeSpec)) + else if (fieldSizeSpec != "") { try { - //varLength = (int)BaseConverter.ToNumberParse(fieldSizeSpec); + varLength = (int)BaseConverter.ToNumberParse(fieldSizeSpec); varLength = (int)BaseConverter.ToNumberParse(fieldSizeSpec); } catch @@ -447,7 +448,7 @@ private float EatParseFloat(string text, ref int i) _eatResult = EatWhitespace(text, ref i); string number = EatNumber(text, ref i); - if (_eatResult || string.IsNullOrEmpty(number)) + if (_eatResult || number == "") throw new ParserException(_fileName, _lineNumber, "Expected floating-point number"); try @@ -465,7 +466,7 @@ private int EatParseInt(string text, ref int i) _eatResult = EatWhitespace(text, ref i); string number = EatNumber(text, ref i); - if (_eatResult || string.IsNullOrEmpty(number)) + if (_eatResult || number == "") throw new ParserException(_fileName, _lineNumber, "Expected integer"); try @@ -494,23 +495,20 @@ private bool EatWhitespace(string text, ref int i) // and comments i++; continue; } - - if (prePostComment && text[i] == '/') + else if (prePostComment && text[i] == '/') { prePostComment = false; inComment = false; i++; continue; } - - if (!inComment && text[i] == '/') + else if (!inComment && text[i] == '/') { preComment = true; i++; continue; } - - if (preComment) + else if (preComment) { if (text[i] == '*') { @@ -519,14 +517,18 @@ private bool EatWhitespace(string text, ref int i) // and comments i++; continue; } - - // it's a mistake, revert! - i -= 1; - break; + else + { + // it's a mistake, revert! + i -= 1; + break; + } + } + else + { + preComment = false; + prePostComment = false; } - - //preComment = false; - prePostComment = false; if (text[i] == '\n') _lineNumber++; @@ -553,7 +555,7 @@ private string EatQuotedString(string text, ref int i) i++; } else - return string.Empty; + return ""; while (i < text.Length) { @@ -563,38 +565,28 @@ private string EatQuotedString(string text, ref int i) i++; continue; } - if (inEscape) + else if (inEscape) { - switch (text[i]) - { - case '\\': - sb.Append('\\'); - break; - case '"': - sb.Append('"'); - break; - case '\'': - sb.Append('\''); - break; - case 'r': - sb.Append('\r'); - break; - case 'n': - sb.Append('\n'); - break; - case 't': - sb.Append('\t'); - break; - default: - throw new ParserException(this._fileName, this._lineNumber, "Unrecognized escape sequence '\\" + text[i] + "'"); - } + if (text[i] == '\\') + sb.Append('\\'); + else if (text[i] == '"') + sb.Append('"'); + else if (text[i] == '\'') + sb.Append('\''); + else if (text[i] == 'r') + sb.Append('\r'); + else if (text[i] == 'n') + sb.Append('\n'); + else if (text[i] == 't') + sb.Append('\t'); + else + throw new ParserException(_fileName, _lineNumber, "Unrecognized escape sequence '\\" + text[i] + "'"); i++; inEscape = false; continue; } - - if (text[i] == '"') + else if (text[i] == '"') { i++; break; diff --git a/1.x/trunk/ProcessHacker/Symbols/SymbolProviderExtensions.cs b/1.x/trunk/ProcessHacker/Symbols/SymbolProviderExtensions.cs index 391441d9b..cd3ca1a92 100644 --- a/1.x/trunk/ProcessHacker/Symbols/SymbolProviderExtensions.cs +++ b/1.x/trunk/ProcessHacker/Symbols/SymbolProviderExtensions.cs @@ -47,7 +47,7 @@ public static void ShowWarning(IWin32Window window, bool force) foreach (var module in modules) { - if (module.FileName.EndsWith("dbghelp.dll", StringComparison.OrdinalIgnoreCase)) + if (module.FileName.ToLowerInvariant().EndsWith("dbghelp.dll")) { if (!File.Exists(Path.GetDirectoryName(module.FileName) + "\\symsrv.dll")) { @@ -56,7 +56,7 @@ public static void ShowWarning(IWin32Window window, bool force) TaskDialog td = new TaskDialog(); bool verificationChecked; - td.PositionRelativeToWindow = true; + td.CommonButtons = TaskDialogCommonButtons.Ok; td.WindowTitle = "Process Hacker"; td.MainIcon = TaskDialogIcon.Warning; diff --git a/1.x/trunk/ProcessHacker/UI/Actions/ElevationLevel.cs b/1.x/trunk/ProcessHacker/UI/Actions/ElevationLevel.cs index b70c3ee50..a4f82417c 100644 --- a/1.x/trunk/ProcessHacker/UI/Actions/ElevationLevel.cs +++ b/1.x/trunk/ProcessHacker/UI/Actions/ElevationLevel.cs @@ -1,4 +1,8 @@ -namespace ProcessHacker.UI.Actions +using System; +using System.Collections.Generic; +using System.Text; + +namespace ProcessHacker.UI.Actions { public enum ElevationLevel { diff --git a/1.x/trunk/ProcessHacker/UI/Actions/ProcessActions.cs b/1.x/trunk/ProcessHacker/UI/Actions/ProcessActions.cs index e1aed5d54..8a78b860a 100644 --- a/1.x/trunk/ProcessHacker/UI/Actions/ProcessActions.cs +++ b/1.x/trunk/ProcessHacker/UI/Actions/ProcessActions.cs @@ -74,7 +74,7 @@ private static bool Prompt(IWin32Window window, int[] pids, string[] names, { using (var phandle = new ProcessHandle(pid, ProcessAccess.QueryInformation)) { - if (phandle.IsCritical) + if (phandle.IsCritical()) { critical = true; break; @@ -92,12 +92,11 @@ private static bool Prompt(IWin32Window window, int[] pids, string[] names, if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog - { - PositionRelativeToWindow = true, - WindowTitle = "Process Hacker", - MainInstruction = "Do you want to " + action + " " + name + "?", Content = content - }; + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainInstruction = "Do you want to " + action + " " + name + "?"; + td.Content = content; if (critical) { @@ -120,23 +119,23 @@ private static bool Prompt(IWin32Window window, int[] pids, string[] names, for (int i = 0; i < pids.Length; i++) { - bool criticalPid; + bool dangerousPid, criticalPid; - bool dangerousPid = PhUtils.IsDangerousPid(pids[i]); + dangerousPid = PhUtils.IsDangerousPid(pids[i]); try { - using (ProcessHandle phandle = new ProcessHandle(pids[i], ProcessAccess.QueryInformation)) - criticalPid = phandle.IsCritical; + using (var phandle = new ProcessHandle(pids[i], ProcessAccess.QueryInformation)) + criticalPid = phandle.IsCritical(); } catch { criticalPid = false; } - td.ExpandedInformation += names[i] + " (PID " + pids[i].ToString() + ")" + - (dangerousPid ? " (system process) " : string.Empty) + - (criticalPid ? " (CRITICAL) " : string.Empty) + + td.ExpandedInformation += names[i] + " (PID " + pids[i].ToString() + ")" + + (dangerousPid ? " (system process) " : "") + + (criticalPid ? " (CRITICAL) " : "") + "\r\n"; } @@ -180,18 +179,23 @@ private static bool Prompt(IWin32Window window, int[] pids, string[] names, return result == DialogResult.Yes; } - private static ElevationAction PromptForElevation(IWin32Window window, int[] pids, string[] names, ProcessAccess access, string elevateAction, string action) + private static ElevationAction PromptForElevation(IWin32Window window, int[] pids, string[] names, + ProcessAccess access, string elevateAction, string action) { if (Settings.Instance.ElevationLevel == (int)ElevationLevel.Never) return ElevationAction.NotRequired; - if (OSVersion.HasUac && Program.ElevationType == TokenElevationType.Limited) + if ( + OSVersion.HasUac && + Program.ElevationType == ProcessHacker.Native.Api.TokenElevationType.Limited && + KProcessHacker.Instance == null + ) { try { foreach (int pid in pids) { - using (ProcessHandle phandle = new ProcessHandle(pid, access)) + using (var phandle = new ProcessHandle(pid, access)) { } } } @@ -203,44 +207,47 @@ private static ElevationAction PromptForElevation(IWin32Window window, int[] pid if (Settings.Instance.ElevationLevel == (int)ElevationLevel.Elevate) return ElevationAction.Elevate; - TaskDialog td = new TaskDialog + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainIcon = TaskDialogIcon.Warning; + td.MainInstruction = "Do you want to " + elevateAction + "?"; + td.Content = "The action cannot be performed in the current security context. " + + "Do you want Process Hacker to prompt for the appropriate credentials and " + elevateAction + "?"; + + td.ExpandedInformation = "Error: " + ex.Message + " (0x" + ex.ErrorCode.ToString("x") + ")"; + td.ExpandFooterArea = true; + + td.Buttons = new TaskDialogButton[] { - PositionRelativeToWindow = true, - WindowTitle = "Process Hacker", - MainIcon = TaskDialogIcon.Warning, - MainInstruction = "Do you want to " + elevateAction + "?", - Content = "The action cannot be performed in the current security context. " + - "Do you want Process Hacker to prompt for the appropriate credentials and " + elevateAction + "?", - ExpandedInformation = "Error: " + ex.Message + " (0x" + ex.ErrorCode.ToString("x") + ")", - ExpandFooterArea = true, - Buttons = new TaskDialogButton[] - { - new TaskDialogButton((int)DialogResult.Yes, "Elevate\nPrompt for credentials and " + elevateAction + "."), - new TaskDialogButton((int)DialogResult.No, "Continue\nAttempt to perform the action without elevation.") - }, - CommonButtons = TaskDialogCommonButtons.Cancel, - UseCommandLinks = true, - Callback = (taskDialog, args, userData) => + new TaskDialogButton((int)DialogResult.Yes, "Elevate\nPrompt for credentials and " + elevateAction + "."), + new TaskDialogButton((int)DialogResult.No, "Continue\nAttempt to perform the action without elevation.") + }; + td.CommonButtons = TaskDialogCommonButtons.Cancel; + td.UseCommandLinks = true; + td.Callback = (taskDialog, args, userData) => + { + if (args.Notification == TaskDialogNotification.Created) { - if (args.Notification == TaskDialogNotification.Created) - { - taskDialog.SetButtonElevationRequiredState((int)DialogResult.Yes, true); - } - - return false; + taskDialog.SetButtonElevationRequiredState((int)DialogResult.Yes, true); } + + return false; }; DialogResult result = (DialogResult)td.Show(window); - switch (result) + if (result == DialogResult.Yes) + { + return ElevationAction.Elevate; + } + else if (result == DialogResult.No) + { + return ElevationAction.DontElevate; + } + else if (result == DialogResult.Cancel) { - case DialogResult.Yes: - return ElevationAction.Elevate; - case DialogResult.No: - return ElevationAction.DontElevate; - case DialogResult.Cancel: - return ElevationAction.Cancel; + return ElevationAction.Cancel; } } } @@ -248,35 +255,36 @@ private static ElevationAction PromptForElevation(IWin32Window window, int[] pid return ElevationAction.NotRequired; } - private static bool ElevateIfRequired(IWin32Window window, int[] pids, string[] names, ProcessAccess access, string action) + private static bool ElevateIfRequired(IWin32Window window, int[] pids, string[] names, + ProcessAccess access, string action) { - ElevationAction result = PromptForElevation(window, pids, names, access, "elevate the action", action); + ElevationAction result; + + result = PromptForElevation(window, pids, names, access, "elevate the action", action); - switch (result) + if (result == ElevationAction.NotRequired || result == ElevationAction.DontElevate) { - case ElevationAction.DontElevate: - case ElevationAction.NotRequired: - return false; - case ElevationAction.Cancel: - return true; - case ElevationAction.Elevate: - { - string objects = string.Empty; + return false; + } + else if (result == ElevationAction.Cancel) + { + return true; + } + else if (result == ElevationAction.Elevate) + { + string objects = ""; - foreach (int pid in pids) - objects += pid + ","; + foreach (int pid in pids) + objects += pid + ","; - Program.StartProcessHackerAdmin( - "-e -type process -action " + action + " -obj \"" + objects + "\" -hwnd " + window.Handle.ToString() - , - null, - window.Handle - ); + Program.StartProcessHackerAdmin("-e -type process -action " + action + " -obj \"" + + objects + "\" -hwnd " + window.Handle.ToString(), null, window.Handle); - return true; - } - default: - return false; + return true; + } + else + { + return false; } } @@ -307,20 +315,29 @@ public static bool ShowProperties(IWin32Window window, int pid, string name) result = ElevationAction.NotRequired; } - switch (result) + if (result == ElevationAction.Elevate) { - case ElevationAction.Elevate: - Program.StartProcessHackerAdmin("-v -ip " + pid.ToString(), () => Program.HackerWindow.Exit(), window.Handle); - return false; - case ElevationAction.Cancel: - return false; + Program.StartProcessHackerAdmin("-v -ip " + pid.ToString(), () => + { + Program.HackerWindow.Exit(); + }, window.Handle); + + return false; + } + else if (result == ElevationAction.Cancel) + { + return false; } if (Program.ProcessProvider.Dictionary.ContainsKey(pid)) { try { - Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], Program.FocusWindow); + ProcessWindow pForm = Program.GetProcessWindow(Program.ProcessProvider.Dictionary[pid], + new Program.PWindowInvokeAction(delegate(ProcessWindow f) + { + Program.FocusWindow(f); + })); } catch (Exception ex) { @@ -353,7 +370,8 @@ public static bool Terminate(IWin32Window window, int[] pids, string[] names, bo { try { - using (ProcessHandle phandle = new ProcessHandle(pids[i], ProcessAccess.Terminate)) + using (ProcessHandle phandle = + new ProcessHandle(pids[i], ProcessAccess.Terminate)) phandle.Terminate(); } catch (Exception ex) @@ -387,9 +405,9 @@ public static bool TerminateTree(IWin32Window window, int[] pids, string[] names var processes = Windows.GetProcesses(); - foreach (int t in pids) + for (int i = 0; i < pids.Length; i++) { - if (!TerminateTree(window, processes, t)) + if (!TerminateTree(window, processes, pids[i])) allGood = false; } diff --git a/1.x/trunk/ProcessHacker/UI/Actions/ServiceActions.cs b/1.x/trunk/ProcessHacker/UI/Actions/ServiceActions.cs index 748ffdb99..10a4180dc 100644 --- a/1.x/trunk/ProcessHacker/UI/Actions/ServiceActions.cs +++ b/1.x/trunk/ProcessHacker/UI/Actions/ServiceActions.cs @@ -38,39 +38,34 @@ private static bool Prompt(IWin32Window window, string service, string action, s if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainInstruction = "Do you want to " + action + " " + service + "?"; + td.MainIcon = icon; + td.Content = content; + + td.Buttons = new TaskDialogButton[] { - PositionRelativeToWindow = true, - WindowTitle = "Process Hacker", - MainInstruction = "Do you want to " + action + " " + service + "?", - MainIcon = icon, - Content = content, - Buttons = new TaskDialogButton[] - { - new TaskDialogButton((int)DialogResult.Yes, char.ToUpper(action[0]) + action.Substring(1)), - new TaskDialogButton((int)DialogResult.No, "Cancel") - }, - DefaultButton = (int)DialogResult.No + new TaskDialogButton((int)DialogResult.Yes, char.ToUpper(action[0]) + action.Substring(1)), + new TaskDialogButton((int)DialogResult.No, "Cancel") }; - + td.DefaultButton = (int)DialogResult.No; result = (DialogResult)td.Show(window); } else { - result = MessageBox.Show( - "Are you sure you want to " + action + " " + service + "?", - "Process Hacker", - MessageBoxButtons.YesNo, - MessageBoxIcon.Exclamation, - MessageBoxDefaultButton.Button2 - ); + result = MessageBox.Show("Are you sure you want to " + action + " " + service + "?", + "Process Hacker", MessageBoxButtons.YesNo, + MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); } return result == DialogResult.Yes; } - private static bool ElevateIfRequired(IWin32Window window, string service, ServiceAccess access, string action) + private static bool ElevateIfRequired(IWin32Window window, string service, + ServiceAccess access, string action) { if (Settings.Instance.ElevationLevel == (int)ElevationLevel.Never) return false; @@ -79,7 +74,7 @@ private static bool ElevateIfRequired(IWin32Window window, string service, Servi { try { - using (ServiceHandle shandle = new ServiceHandle(service, access)) + using (var shandle = new ServiceHandle(service, access)) { } } catch (WindowsException ex) @@ -92,24 +87,25 @@ private static bool ElevateIfRequired(IWin32Window window, string service, Servi } else { - TaskDialog td = new TaskDialog + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainIcon = TaskDialogIcon.Warning; + td.MainInstruction = "Do you want to elevate the action?"; + td.Content = "The action cannot be performed in the current security context. " + + "Do you want Process Hacker to prompt for the appropriate credentials and elevate the action?"; + + td.ExpandedInformation = "Error: " + ex.Message + " (0x" + ex.ErrorCode.ToString("x") + ")"; + td.ExpandFooterArea = true; + + td.Buttons = new TaskDialogButton[] { - PositionRelativeToWindow = true, - WindowTitle = "Process Hacker", - MainIcon = TaskDialogIcon.Warning, - MainInstruction = "Do you want to elevate the action?", - Content = "The action cannot be performed in the current security context. " + - "Do you want Process Hacker to prompt for the appropriate credentials and elevate the action?", - ExpandedInformation = "Error: " + ex.Message + " (0x" + ex.ErrorCode.ToString("x") + ")", - ExpandFooterArea = true, - Buttons = new TaskDialogButton[] - { - new TaskDialogButton((int)DialogResult.Yes, "Elevate\nPrompt for credentials and elevate the action."), - new TaskDialogButton((int)DialogResult.No, "Continue\nAttempt to perform the action without elevation.") - }, - CommonButtons = TaskDialogCommonButtons.Cancel, - UseCommandLinks = true, - Callback = (taskDialog, args, userData) => + new TaskDialogButton((int)DialogResult.Yes, "Elevate\nPrompt for credentials and elevate the action."), + new TaskDialogButton((int)DialogResult.No, "Continue\nAttempt to perform the action without elevation.") + }; + td.CommonButtons = TaskDialogCommonButtons.Cancel; + td.UseCommandLinks = true; + td.Callback = (taskDialog, args, userData) => { if (args.Notification == TaskDialogNotification.Created) { @@ -117,23 +113,25 @@ private static bool ElevateIfRequired(IWin32Window window, string service, Servi } return false; - } - }; + }; result = (DialogResult)td.Show(window); } - switch (result) + if (result == DialogResult.Yes) + { + Program.StartProcessHackerAdmin("-e -type service -action " + action + " -obj \"" + + service + "\" -hwnd " + window.Handle.ToString(), null, window.Handle); + + return true; + } + else if (result == DialogResult.No) + { + return false; + } + else if (result == DialogResult.Cancel) { - case DialogResult.Yes: - Program.StartProcessHackerAdmin( - "-e -type service -action " + action + " -obj \"" + - service + "\" -hwnd " + window.Handle.ToString(), null, window.Handle); - return true; - case DialogResult.No: - return false; - case DialogResult.Cancel: - return true; + return true; } } } diff --git a/1.x/trunk/ProcessHacker/UI/Actions/SessionActions.cs b/1.x/trunk/ProcessHacker/UI/Actions/SessionActions.cs index e614b378c..2adc99288 100644 --- a/1.x/trunk/ProcessHacker/UI/Actions/SessionActions.cs +++ b/1.x/trunk/ProcessHacker/UI/Actions/SessionActions.cs @@ -10,32 +10,31 @@ namespace ProcessHacker.UI.Actions { public class SessionActions { - private static bool Prompt(IWin32Window window, string name, string action, string content) + private static bool Prompt(IWin32Window window, string name, + string action, string content) { DialogResult result = DialogResult.No; if (OSVersion.HasTaskDialogs) { - TaskDialog td = new TaskDialog + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainInstruction = "Do you want to " + action + " " + name + "?"; + td.Content = content; + + td.Buttons = new TaskDialogButton[] { - PositionRelativeToWindow = true, - WindowTitle = "Process Hacker", - MainInstruction = "Do you want to " + action + " " + name + "?", - Content = content, - Buttons = new[] - { - new TaskDialogButton((int)DialogResult.Yes, char.ToUpper(action[0]) + action.Substring(1)), - new TaskDialogButton((int)DialogResult.No, "Cancel") - }, - DefaultButton = (int)DialogResult.No + new TaskDialogButton((int)DialogResult.Yes, char.ToUpper(action[0]) + action.Substring(1)), + new TaskDialogButton((int)DialogResult.No, "Cancel") }; + td.DefaultButton = (int)DialogResult.No; result = (DialogResult)td.Show(window); } else { - result = MessageBox.Show( - "Are you sure you want to " + action + " " + name + "?", + result = MessageBox.Show("Are you sure you want to " + action + " " + name + "?", "Process Hacker", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); } @@ -54,7 +53,9 @@ private static void ElevateIfRequired(IWin32Window window, int session, string a } catch (WindowsException ex) { - if (ex.ErrorCode == Win32Error.AccessDenied && OSVersion.HasUac && Program.ElevationType == TokenElevationType.Limited) + if (ex.ErrorCode == Win32Error.AccessDenied && + OSVersion.HasUac && + Program.ElevationType == ProcessHacker.Native.Api.TokenElevationType.Limited) { DialogResult result; @@ -64,31 +65,31 @@ private static void ElevateIfRequired(IWin32Window window, int session, string a } else { - TaskDialog td = new TaskDialog + TaskDialog td = new TaskDialog(); + + td.WindowTitle = "Process Hacker"; + td.MainIcon = TaskDialogIcon.Warning; + td.MainInstruction = "Do you want to elevate the action?"; + td.Content = "The action could not be performed in the current security context. " + + "Do you want Process Hacker to prompt for the appropriate credentials and elevate the action?"; + + td.ExpandedInformation = "Error: " + ex.Message + " (0x" + ex.ErrorCode.ToString("x") + ")"; + td.ExpandFooterArea = true; + + td.Buttons = new TaskDialogButton[] { - PositionRelativeToWindow = true, - WindowTitle = "Process Hacker", - MainIcon = TaskDialogIcon.Warning, - MainInstruction = "Do you want to elevate the action?", - Content = "The action could not be performed in the current security context. " + - "Do you want Process Hacker to prompt for the appropriate credentials and elevate the action?", - ExpandedInformation = "Error: " + ex.Message + " (0x" + ex.ErrorCode.ToString("x") + ")", - ExpandFooterArea = true, - Buttons = new TaskDialogButton[] - { - new TaskDialogButton((int)DialogResult.Yes, "Elevate\nPrompt for credentials and elevate the action.") - }, - CommonButtons = TaskDialogCommonButtons.Cancel, - UseCommandLinks = true, - Callback = (taskDialog, args, userData) => + new TaskDialogButton((int)DialogResult.Yes, "Elevate\nPrompt for credentials and elevate the action.") + }; + td.CommonButtons = TaskDialogCommonButtons.Cancel; + td.UseCommandLinks = true; + td.Callback = (taskDialog, args, userData) => + { + if (args.Notification == TaskDialogNotification.Created) { - if (args.Notification == TaskDialogNotification.Created) - { - taskDialog.SetButtonElevationRequiredState((int)DialogResult.Yes, true); - } - - return false; + taskDialog.SetButtonElevationRequiredState((int)DialogResult.Yes, true); } + + return false; }; result = (DialogResult)td.Show(window); @@ -96,8 +97,7 @@ private static void ElevateIfRequired(IWin32Window window, int session, string a if (result == DialogResult.Yes) { - Program.StartProcessHackerAdmin( - "-e -type session -action " + actionName + " -obj \"" + + Program.StartProcessHackerAdmin("-e -type session -action " + actionName + " -obj \"" + session.ToString() + "\" -hwnd " + window.Handle.ToString(), null, window.Handle); } } @@ -113,7 +113,10 @@ public static void Disconnect(IWin32Window window, int session, bool prompt) if (prompt && !Prompt(window, "the session", "disconnect", "")) return; - ElevateIfRequired(window, session, "disconnect", () => TerminalServerHandle.GetCurrent().GetSession(session).Disconnect()); + ElevateIfRequired(window, session, "disconnect", () => + { + TerminalServerHandle.GetCurrent().GetSession(session).Disconnect(); + }); } public static void Logoff(IWin32Window window, int session, bool prompt) @@ -121,7 +124,10 @@ public static void Logoff(IWin32Window window, int session, bool prompt) if (prompt && !Prompt(window, "the session", "logoff", "")) return; - ElevateIfRequired(window, session, "logoff", () => TerminalServerHandle.GetCurrent().GetSession(session).Logoff()); + ElevateIfRequired(window, session, "logoff", () => + { + TerminalServerHandle.GetCurrent().GetSession(session).Logoff(); + }); } } } diff --git a/1.x/trunk/ProcessHacker/UI/AeroRenderer.cs b/1.x/trunk/ProcessHacker/UI/AeroRenderer.cs deleted file mode 100644 index c293dba20..000000000 --- a/1.x/trunk/ProcessHacker/UI/AeroRenderer.cs +++ /dev/null @@ -1,556 +0,0 @@ -using System.Linq; - -namespace System -{ - using System.Drawing; - using System.Runtime.InteropServices; - using Windows.Forms; - using System.Windows.Forms.VisualStyles; - - public enum ToolbarTheme - { - Toolbar, - Black, - Blue, - BrowserTabBar, - HelpBar - } - - /// Renders a toolstrip using the UxTheme API via VisualStyleRenderer using specific styles. - /// Special thanks to Szotar and Lee. - public class AeroRenderer : ToolStripSystemRenderer - { - private VisualStyleRenderer Renderer; - private readonly ToolbarTheme Theme; - - const int RebarBackground = 6; - - public AeroRenderer(ToolbarTheme theme) - { - this.Theme = theme; - } - - /// - /// It shouldn't be necessary to P/Invoke like this, however VisualStyleRenderer.GetMargins misses out a parameter in its own P/Invoke. - /// - internal static class NativeMethods - { - [StructLayout(LayoutKind.Sequential)] - public struct Margins - { - public int cxLeftWidth; - public int cxRightWidth; - public int cyTopHeight; - public int cyBottomHeight; - } - - [DllImport("uxtheme.dll"), Security.SuppressUnmanagedCodeSecurity] - public extern static int GetThemeMargins(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, IntPtr rect, out Margins pMargins); - } - - Padding GetThemeMargins(IDeviceContext dc, MarginTypes marginType) - { - NativeMethods.Margins margins; - try - { - IntPtr hDc = dc.GetHdc(); - - if (NativeMethods.GetThemeMargins(Renderer.Handle, hDc, Renderer.Part, Renderer.State, (int)marginType, IntPtr.Zero, out margins) == 0) - { - return new Padding(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight); - } - - return new Padding(0); - } - finally - { - dc.ReleaseHdc(); - } - } - - // See http://msdn2.microsoft.com/en-us/library/bb773210.aspx - "Parts and States" - // Only menu-related parts/states are needed here, VisualStyleRenderer handles most of the rest. - private enum MenuParts - { - ItemTMSchema = 1, - DropDownTMSchema = 2, - BarItemTMSchema = 3, - BarDropDownTMSchema = 4, - ChevronTMSchema = 5, - SeparatorTMSchema = 6, - BarBackground = 7, - BarItem = 8, - PopupBackground = 9, - PopupBorders = 10, - PopupCheck = 11, - PopupCheckBackground = 12, - PopupGutter = 13, - PopupItem = 14, - PopupSeparator = 15, - PopupSubmenu = 16, - SystemClose = 17, - SystemMaximize = 18, - SystemMinimize = 19, - SystemRestore = 20 - } - - private enum MenuBarStates - { - Active = 1, - Inactive = 2 - } - - private enum MenuBarItemStates - { - Normal = 1, - Hover = 2, - Pushed = 3, - Disabled = 4, - DisabledHover = 5, - DisabledPushed = 6 - } - - private enum MenuPopupItemStates - { - Normal = 1, - Hover = 2, - Disabled = 3, - DisabledHover = 4 - } - - private enum MenuPopupCheckStates - { - CheckmarkNormal = 1, - CheckmarkDisabled = 2, - BulletNormal = 3, - BulletDisabled = 4 - } - - private enum MenuPopupCheckBackgroundStates - { - Disabled = 1, - Normal = 2, - Bitmap = 3 - } - - private enum MenuPopupSubMenuStates - { - Normal = 1, - Disabled = 2 - } - - private enum MarginTypes - { - Sizing = 3601, - Content = 3602, - Caption = 3603 - } - - private static int GetItemState(ToolStripItem item) - { - bool hot = item.Selected; - - if (item.IsOnDropDown) - { - if (item.Enabled) - return hot ? (int)MenuPopupItemStates.Hover : (int)MenuPopupItemStates.Normal; - - return hot ? (int)MenuPopupItemStates.DisabledHover : (int)MenuPopupItemStates.Disabled; - } - - if (item.Pressed) - return item.Enabled ? (int)MenuBarItemStates.Pushed : (int)MenuBarItemStates.DisabledPushed; - - if (item.Enabled) - return hot ? (int)MenuBarItemStates.Hover : (int)MenuBarItemStates.Normal; - - return hot ? (int)MenuBarItemStates.DisabledHover : (int)MenuBarItemStates.Disabled; - } - - private string RebarClass - { - get { return this.SubclassPrefix + "Rebar"; } - } - - private string ToolbarClass - { - get { return this.SubclassPrefix + "ToolBar"; } - } - - private string MenuClass - { - get { return this.SubclassPrefix + "Menu"; } - } - - private string SubclassPrefix - { - get - { - switch (this.Theme) - { - case ToolbarTheme.Black: - return "Media::"; - case ToolbarTheme.Blue: - return "Communications::"; - case ToolbarTheme.BrowserTabBar: - return "BrowserTabBar::"; - case ToolbarTheme.HelpBar: - return "Help::"; - default: - return string.Empty; - } - } - } - - private VisualStyleElement Subclass(VisualStyleElement element) - { - return VisualStyleElement.CreateElement(SubclassPrefix + element.ClassName, element.Part, element.State); - } - - private bool EnsureRenderer() - { - if (!this.IsSupported) - return false; - - if (this.Renderer == null) - this.Renderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal); - - return true; - } - - // Gives parented ToolStrips a transparent background. - protected override void Initialize(ToolStrip toolStrip) - { - if (toolStrip.Parent is ToolStripPanel) - toolStrip.BackColor = Color.Transparent; - - base.Initialize(toolStrip); - } - - // Using just ToolStripManager.Renderer without setting the Renderer individually per ToolStrip means - // that the ToolStrip is not passed to the Initialize method. ToolStripPanels, however, are. So we can - // simply initialize it here too, and this should guarantee that the ToolStrip is initialized at least - // once. Hopefully it isn't any more complicated than this. - protected override void InitializePanel(ToolStripPanel toolStripPanel) - { - foreach (ToolStrip c in toolStripPanel.Controls.OfType()) - { - this.Initialize(c); - } - - base.InitializePanel(toolStripPanel); - } - - protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - this.Renderer.SetParameters(this.MenuClass, (int)MenuParts.PopupBorders, 0); - - if (e.ToolStrip.IsDropDown) - { - Region oldClip = e.Graphics.Clip; - - // Tool strip borders are rendered *after* the content, for some reason. - // So we have to exclude the inside of the popup otherwise we'll draw over it. - Rectangle insideRect = e.ToolStrip.ClientRectangle; - insideRect.Inflate(-1, -1); - - e.Graphics.ExcludeClip(insideRect); - - Renderer.DrawBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.AffectedBounds); - - // Restore the old clip in case the Graphics is used again (does that ever happen?) - e.Graphics.Clip = oldClip; - } - } - else - { - base.OnRenderToolStripBorder(e); - } - } - - Rectangle GetBackgroundRectangle(ToolStripItem item) - { - if (!item.IsOnDropDown) - return new Rectangle(new Point(), item.Bounds.Size); - - // For a drop-down menu item, the background rectangles of the items should be touching vertically. - // This ensures that's the case. - Rectangle rect = item.Bounds; - - // The background rectangle should be inset two pixels horizontally (on both sides), but we have - // to take into account the border. - rect.X = item.ContentRectangle.X + 1; - rect.Width = item.ContentRectangle.Width - 1; - - // Make sure we're using all of the vertical space, so that the edges touch. - rect.Y = 0; - return rect; - } - - protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - int partId = e.Item.IsOnDropDown ? (int)MenuParts.PopupItem : (int)MenuParts.BarItem; - this.Renderer.SetParameters(MenuClass, partId, GetItemState(e.Item)); - - Rectangle bgRect = this.GetBackgroundRectangle(e.Item); - this.Renderer.DrawBackground(e.Graphics, bgRect, bgRect); - } - else - { - base.OnRenderMenuItemBackground(e); - } - } - - protected override void OnRenderToolStripPanelBackground(ToolStripPanelRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - // Draw the background using Rebar & RP_BACKGROUND (or, if that is not available, fall back to Rebar.Band.Normal) - if (VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement(RebarClass, RebarBackground, 0))) - { - this.Renderer.SetParameters(RebarClass, RebarBackground, 0); - } - else - { - this.Renderer.SetParameters(RebarClass, 0, 0); - } - - if (this.Renderer.IsBackgroundPartiallyTransparent()) - this.Renderer.DrawParentBackground(e.Graphics, e.ToolStripPanel.ClientRectangle, e.ToolStripPanel); - - this.Renderer.DrawBackground(e.Graphics, e.ToolStripPanel.ClientRectangle); - - e.Handled = true; - } - else - { - base.OnRenderToolStripPanelBackground(e); - } - } - - // Render the background of an actual menu bar, dropdown menu or toolbar. - protected override void OnRenderToolStripBackground(System.Windows.Forms.ToolStripRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - if (e.ToolStrip.IsDropDown) - { - this.Renderer.SetParameters(MenuClass, (int)MenuParts.PopupBackground, 0); - } - else - { - // It's a MenuStrip or a ToolStrip. If it's contained inside a larger panel, it should have a - // transparent background, showing the panel's background. - - if (e.ToolStrip.Parent is ToolStripPanel) - { - // The background should be transparent, because the ToolStripPanel's background will be visible. - // Of course, we assume the ToolStripPanel is drawn using the same theme, but it's not my fault - // if someone does that. - return; - } - else - { - // A lone toolbar/menubar should act like it's inside a toolbox, I guess. - // Maybe I should use the MenuClass in the case of a MenuStrip, although that would break - // the other themes... - if (VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement(this.RebarClass, RebarBackground, 0))) - this.Renderer.SetParameters(this.RebarClass, RebarBackground, 0); - else - this.Renderer.SetParameters(this.RebarClass, 0, 0); - } - } - - if (this.Renderer.IsBackgroundPartiallyTransparent()) - this.Renderer.DrawParentBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.ToolStrip); - - this.Renderer.DrawBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.AffectedBounds); - } - else - { - base.OnRenderToolStripBackground(e); - } - } - - // The only purpose of this override is to change the arrow colour. - // It's OK to just draw over the default arrow since we also pass down arrow drawing to the system renderer. - protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - ToolStripSplitButton sb = e.Item as ToolStripSplitButton; - base.OnRenderSplitButtonBackground(e); - - // It doesn't matter what colour of arrow we tell it to draw. OnRenderArrow will compute it from the item anyway. - this.OnRenderArrow(new ToolStripArrowRenderEventArgs(e.Graphics, sb, sb.DropDownButtonBounds, Color.Red, ArrowDirection.Down)); - } - else - { - base.OnRenderSplitButtonBackground(e); - } - } - - Color GetItemTextColor(ToolStripItem item) - { - int partId = item.IsOnDropDown ? (int)MenuParts.PopupItem : (int)MenuParts.BarItem; - - this.Renderer.SetParameters(MenuClass, partId, GetItemState(item)); - - return Renderer.GetColor(ColorProperty.TextColor); - } - - protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) - { - if (this.EnsureRenderer()) - e.TextColor = this.GetItemTextColor(e.Item); - - base.OnRenderItemText(e); - } - - protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - if (e.ToolStrip.IsDropDown) - { - this.Renderer.SetParameters(this.MenuClass, (int)MenuParts.PopupGutter, 0); - // The AffectedBounds is usually too small, way too small to look right. Instead of using that, - // use the AffectedBounds but with the right width. Then narrow the rectangle to the correct edge - // based on whether or not it's RTL. - //(It doesn't need to be narrowed to an edge in LTR mode, but let's do that anyway.) - // Using the DisplayRectangle gets roughly the right size so that the separator is closer to the text. - - Padding margins = this.GetThemeMargins(e.Graphics, MarginTypes.Sizing); - int extraWidth = (e.ToolStrip.Width - e.ToolStrip.DisplayRectangle.Width - margins.Left - margins.Right - 1) - e.AffectedBounds.Width; - Rectangle rect = e.AffectedBounds; - rect.Y += 2; - rect.Height -= 4; - int sepWidth = this.Renderer.GetPartSize(e.Graphics, ThemeSizeType.True).Width; - if (e.ToolStrip.RightToLeft == RightToLeft.Yes) - { - rect = new Rectangle(rect.X - extraWidth, rect.Y, sepWidth, rect.Height); - rect.X += sepWidth; - } - else - { - rect = new Rectangle(rect.Width + extraWidth - sepWidth, rect.Y, sepWidth, rect.Height); - } - this.Renderer.DrawBackground(e.Graphics, rect); - } - } - else - { - base.OnRenderImageMargin(e); - } - } - - protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) - { - if (e.ToolStrip.IsDropDown && this.EnsureRenderer()) - { - this.Renderer.SetParameters(MenuClass, (int)MenuParts.PopupSeparator, 0); - Rectangle rect = new Rectangle(e.ToolStrip.DisplayRectangle.Left, 0, e.ToolStrip.DisplayRectangle.Width, e.Item.Height); - this.Renderer.DrawBackground(e.Graphics, rect, rect); - } - else - { - base.OnRenderSeparator(e); - } - } - - protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - Rectangle bgRect = this.GetBackgroundRectangle(e.Item); - bgRect.Width = bgRect.Height; - - // Now, mirror its position if the menu item is RTL. - if (e.Item.RightToLeft == RightToLeft.Yes) - bgRect = new Rectangle(e.ToolStrip.ClientSize.Width - bgRect.X - bgRect.Width, bgRect.Y, bgRect.Width, bgRect.Height); - - this.Renderer.SetParameters(this.MenuClass, (int)MenuParts.PopupCheckBackground, e.Item.Enabled ? (int)MenuPopupCheckBackgroundStates.Normal : (int)MenuPopupCheckBackgroundStates.Disabled); - this.Renderer.DrawBackground(e.Graphics, bgRect); - - Rectangle checkRect = e.ImageRectangle; - checkRect.X = bgRect.X + bgRect.Width / 2 - checkRect.Width / 2; - checkRect.Y = bgRect.Y + bgRect.Height / 2 - checkRect.Height / 2; - - // I don't think ToolStrip even supports radio box items, so no need to render them. - var item = e.Item as ToolStripMenuItem; - - if (item.CheckState == CheckState.Indeterminate) - { - this.Renderer.SetParameters(this.MenuClass, (int)MenuParts.PopupCheck, e.Item.Enabled ? (int)MenuPopupCheckStates.BulletNormal : (int)MenuPopupCheckStates.BulletDisabled); - } - else - { - this.Renderer.SetParameters(this.MenuClass, (int)MenuParts.PopupCheck, e.Item.Enabled ? (int)MenuPopupCheckStates.CheckmarkNormal : (int)MenuPopupCheckStates.CheckmarkDisabled); - } - - this.Renderer.DrawBackground(e.Graphics, checkRect); - } - else - { - base.OnRenderItemCheck(e); - } - } - - protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) - { - // The default renderer will draw an arrow for us (the UXTheme API seems not to have one for all directions), - // but it will get the colour wrong in many cases. The text colour is probably the best colour to use. - if (this.EnsureRenderer()) - { - e.ArrowColor = this.GetItemTextColor(e.Item); - } - - base.OnRenderArrow(e); - } - - protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e) - { - if (this.EnsureRenderer()) - { - // BrowserTabBar::Rebar draws the chevron using the default background. Odd. - string rebarClass = this.RebarClass; - - if (this.Theme == ToolbarTheme.BrowserTabBar) - rebarClass = "Rebar"; - - int state = VisualStyleElement.Rebar.Chevron.Normal.State; - - if (e.Item.Pressed) - state = VisualStyleElement.Rebar.Chevron.Pressed.State; - else if (e.Item.Selected) - state = VisualStyleElement.Rebar.Chevron.Hot.State; - - Renderer.SetParameters(rebarClass, VisualStyleElement.Rebar.Chevron.Normal.Part, state); - Renderer.DrawBackground(e.Graphics, new Rectangle(Point.Empty, e.Item.Size)); - } - else - { - base.OnRenderOverflowButtonBackground(e); - } - } - - private bool IsSupported - { - get - { - // TODO: Needs a more robust check. - - return VisualStyleRenderer.IsSupported && - VisualStyleRenderer.IsElementDefined( - VisualStyleElement.CreateElement("Menu", - (int)MenuParts.BarBackground, - (int)MenuBarStates.Active) - ); - } - } - } -} \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/UI/Async/AsyncUtils.cs b/1.x/trunk/ProcessHacker/UI/Async/AsyncUtils.cs index b511ed113..720a39963 100644 --- a/1.x/trunk/ProcessHacker/UI/Async/AsyncUtils.cs +++ b/1.x/trunk/ProcessHacker/UI/Async/AsyncUtils.cs @@ -22,6 +22,7 @@ */ using System; +using System.Windows.Forms; using System.Threading; using System.ComponentModel; @@ -30,7 +31,7 @@ namespace ProcessHacker.FormHelper /// /// Exception thrown when an operation is already in progress. /// - public class AlreadyRunningException : ApplicationException + public class AlreadyRunningException : System.ApplicationException { public AlreadyRunningException() : base("Operation already running") { } @@ -39,88 +40,88 @@ public AlreadyRunningException() : base("Operation already running") public abstract class AsyncOperation { private Thread _asyncThread; - private readonly object _asyncLock = new object(); + private object _asyncLock = new object(); - protected AsyncOperation(ISynchronizeInvoke target) + public AsyncOperation(ISynchronizeInvoke target) { - this.isiTarget = target; - this.isRunning = false; + isiTarget = target; + isRunning = false; } public void Start() { - lock (this._asyncLock) + lock (_asyncLock) { - if (this.isRunning) + if (isRunning) { throw new AlreadyRunningException(); } - this.isRunning = true; + isRunning = true; } - this._asyncThread = new Thread(this.InternalStart, Common.Utils.SixteenthStackSize); - this._asyncThread.Start(); + _asyncThread = new Thread(InternalStart, ProcessHacker.Common.Utils.SixteenthStackSize); + _asyncThread.Start(); } public void Cancel() { - lock (this._asyncLock) + lock (_asyncLock) { - this.cancelledFlag = true; + cancelledFlag = true; } } public bool CancelAndWait() { - lock (this._asyncLock) - { - this.cancelledFlag = true; + lock (_asyncLock) + { + cancelledFlag = true; - while (!this.IsDone) + while (!IsDone) { - Monitor.Wait(this._asyncLock, 1000); + Monitor.Wait(_asyncLock, 1000); } } - return !this.HasCompleted; + return !HasCompleted; } public bool WaitUntilDone() { - lock (this._asyncLock) + lock (_asyncLock) { // Wait for either completion or cancellation. As with // CancelAndWait, we don't sleep forever - to reduce the // chances of deadlock in obscure race conditions, we wake // up every second to check we didn't miss a Pulse. - while (!this.IsDone) + while (!IsDone) { - Monitor.Wait(this._asyncLock, 1000); + Monitor.Wait(_asyncLock, 1000); } } - return this.HasCompleted; + return HasCompleted; } public bool IsDone { get { - lock (this._asyncLock) + lock (_asyncLock) { - return this.completeFlag || this.cancelAcknowledgedFlag || this.failedFlag; + return completeFlag || cancelAcknowledgedFlag || failedFlag; } } } public event EventHandler Completed; public event EventHandler Cancelled; - public event ThreadExceptionEventHandler Failed; + public event System.Threading.ThreadExceptionEventHandler Failed; - private readonly ISynchronizeInvoke isiTarget; + private ISynchronizeInvoke isiTarget; protected ISynchronizeInvoke Target { - get { return this.isiTarget; } + get { return isiTarget; } } /// @@ -129,42 +130,31 @@ protected ISynchronizeInvoke Target protected abstract void DoWork(); private bool cancelledFlag; - protected bool CancelRequested { get { - lock (this._asyncLock) - { - return this.cancelledFlag; - } + lock (_asyncLock) { return cancelledFlag; } } } private bool completeFlag; - protected bool HasCompleted { get { - lock (this._asyncLock) - { - return this.completeFlag; - } + lock (_asyncLock) { return completeFlag; } } } protected void AcknowledgeCancel() { - lock (this._asyncLock) + lock (_asyncLock) { - this.cancelAcknowledgedFlag = true; - this.isRunning = false; - - Monitor.Pulse(this._asyncLock); - - if (this.Cancelled != null) - this.Cancelled(this, EventArgs.Empty); + cancelAcknowledgedFlag = true; + isRunning = false; + Monitor.Pulse(_asyncLock); + FireAsync(Cancelled, this, EventArgs.Empty); } } @@ -175,21 +165,21 @@ protected void AcknowledgeCancel() private bool isRunning; private void InternalStart() - { - this.cancelledFlag = false; - this.completeFlag = false; - this.cancelAcknowledgedFlag = false; - this.failedFlag = false; + { + cancelledFlag = false; + completeFlag = false; + cancelAcknowledgedFlag = false; + failedFlag = false; try { - this.DoWork(); + DoWork(); } catch (Exception e) { try { - this.FailOperation(e); + FailOperation(e); } catch { } @@ -200,41 +190,43 @@ private void InternalStart() } } - lock (this._asyncLock) + lock (_asyncLock) { // raise the Completion event - if (!this.cancelAcknowledgedFlag && !this.failedFlag) + if (!cancelAcknowledgedFlag && !failedFlag) { - this.CompleteOperation(); + CompleteOperation(); } } } private void CompleteOperation() { - lock (this._asyncLock) + lock (_asyncLock) { - this.completeFlag = true; - this.isRunning = false; - - Monitor.Pulse(this._asyncLock); - - if (this.Completed != null) - this.Completed(this, EventArgs.Empty); + completeFlag = true; + isRunning = false; + Monitor.Pulse(_asyncLock); + FireAsync(Completed, this, EventArgs.Empty); } } private void FailOperation(Exception e) { - lock (this._asyncLock) + lock (_asyncLock) { - this.failedFlag = true; - this.isRunning = false; - - Monitor.Pulse(this._asyncLock); + failedFlag = true; + isRunning = false; + Monitor.Pulse(_asyncLock); + FireAsync(Failed, this, new ThreadExceptionEventArgs(e)); + } + } - if (this.Failed != null) - this.Failed(this, new ThreadExceptionEventArgs(e)); + protected void FireAsync(Delegate dlg, params object[] pList) + { + if (dlg != null) + { + Target.BeginInvoke(dlg, pList); } } } diff --git a/1.x/trunk/ProcessHacker/UI/Async/HandleFilter.cs b/1.x/trunk/ProcessHacker/UI/Async/HandleFilter.cs index 26cb5e5af..ec23f8921 100644 --- a/1.x/trunk/ProcessHacker/UI/Async/HandleFilter.cs +++ b/1.x/trunk/ProcessHacker/UI/Async/HandleFilter.cs @@ -42,14 +42,16 @@ public sealed class HandleFilter : AsyncOperation public delegate void MatchProgressEvent(int currentValue, int count); public event MatchListViewEvent MatchListView; public event MatchProgressEvent MatchProgress; - private readonly string strFilterLower; - private readonly IntPtr intPtrFilter; + private string strFilter; + private string strFilterLower; + private IntPtr intPtrFilter; private List listViewItemContainer = new List(BufferSize); - private readonly Dictionary isCurrentSessionIdCache = new Dictionary(); + private Dictionary isCurrentSessionIdCache = new Dictionary(); public HandleFilter(ISynchronizeInvoke isi, string strFilter) : base(isi) { + this.strFilter = strFilter; strFilterLower = strFilter.ToLowerInvariant(); try @@ -100,34 +102,36 @@ private void DoFilter() phandle.Dispose(); // Find DLLs and mapped files - Dictionary processes = Windows.GetProcesses(); + var processes = Windows.GetProcesses(); - foreach (KeyValuePair process in processes) + foreach (var process in processes) { try { // Modules - using (ProcessHandle phandle = new ProcessHandle(process.Key, Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) + using (var phandle = new ProcessHandle(process.Key, + Program.MinProcessQueryRights | Program.MinProcessReadMemoryRights)) { - phandle.EnumModules(module => + phandle.EnumModules((module) => { - if (module.FileName.Contains(strFilterLower, StringComparison.OrdinalIgnoreCase)) + if (module.FileName.ToLowerInvariant().Contains(strFilterLower)) this.CallDllMatchListView(process.Key, module); return true; }); } // Memory - using (ProcessHandle phandle = new ProcessHandle(process.Key, ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights)) + using (var phandle = new ProcessHandle(process.Key, + ProcessAccess.QueryInformation | Program.MinProcessReadMemoryRights)) { - phandle.EnumMemory(region => + phandle.EnumMemory((region) => { if (region.Type != MemoryType.Mapped) return true; string name = phandle.GetMappedFileName(region.BaseAddress); - if (!string.IsNullOrEmpty(name) && name.Contains(strFilterLower, StringComparison.OrdinalIgnoreCase)) + if (name != null && name.ToLowerInvariant().Contains(strFilterLower)) this.CallMappedFileMatchListView(process.Key, region.BaseAddress, name); return true; @@ -145,12 +149,12 @@ private void DoFilter() RtlQueryProcessDebugFlags.NonInvasive ); - buffer.EnumModules(module => - { - if (module.FileName.Contains(strFilterLower, StringComparison.OrdinalIgnoreCase)) - this.CallDllMatchListView(process.Key, module); - return true; - }); + buffer.EnumModules((module) => + { + if (module.FileName.ToLowerInvariant().Contains(strFilterLower)) + this.CallDllMatchListView(process.Key, module); + return true; + }); } } } @@ -164,38 +168,42 @@ private void DoFilter() } } - private void CompareHandleBestNameWithFilter(Dictionary processHandles, SystemHandleEntry currhandle) + private void CompareHandleBestNameWithFilter( + Dictionary processHandles, + SystemHandleEntry currhandle) { try { // Don't get handles from processes in other session // if we don't have KPH to reduce freezes. - - try + if (KProcessHacker.Instance == null) { - if (isCurrentSessionIdCache.ContainsKey(currhandle.ProcessId)) - { - if (!isCurrentSessionIdCache[currhandle.ProcessId]) - return; - } - else + try { - bool isCurrentSessionId = Win32.GetProcessSessionId(currhandle.ProcessId) == Program.CurrentSessionId; + if (isCurrentSessionIdCache.ContainsKey(currhandle.ProcessId)) + { + if (!isCurrentSessionIdCache[currhandle.ProcessId]) + return; + } + else + { + bool isCurrentSessionId = Win32.GetProcessSessionId(currhandle.ProcessId) == Program.CurrentSessionId; - isCurrentSessionIdCache.Add(currhandle.ProcessId, isCurrentSessionId); + isCurrentSessionIdCache.Add(currhandle.ProcessId, isCurrentSessionId); - if (!isCurrentSessionId) - return; + if (!isCurrentSessionId) + return; + } + } + catch + { + return; } } - catch - { - return; - } - if (!processHandles.ContainsKey(currhandle.ProcessId)) - processHandles.Add(currhandle.ProcessId, new ProcessHandle(currhandle.ProcessId, Program.MinProcessGetHandleInformationRights)); + processHandles.Add(currhandle.ProcessId, + new ProcessHandle(currhandle.ProcessId, Program.MinProcessGetHandleInformationRights)); var info = currhandle.GetHandleInfo(processHandles[currhandle.ProcessId]); @@ -203,7 +211,7 @@ private void CompareHandleBestNameWithFilter(Dictionary proc return; if ( - (!string.IsNullOrEmpty(info.BestName) && info.BestName.Contains(strFilterLower, StringComparison.OrdinalIgnoreCase)) || + (info.BestName != null && info.BestName.ToLowerInvariant().Contains(strFilterLower)) || (intPtrFilter != IntPtr.Zero && currhandle.Object == intPtrFilter) ) { @@ -218,13 +226,11 @@ private void CompareHandleBestNameWithFilter(Dictionary proc private void CallHandleMatchListView(SystemHandleEntry handle, ObjectInformation info) { - ListViewItem item = new ListViewItem - { - Name = handle.ProcessId.ToString() + " " + handle.Handle.ToString(), - Text = Program.ProcessProvider.Dictionary[handle.ProcessId].Name + " (" + handle.ProcessId.ToString() + ")", - Tag = handle - }; - + ListViewItem item = new ListViewItem(); + item.Name = handle.ProcessId.ToString() + " " + handle.Handle.ToString(); + item.Text = Program.ProcessProvider.Dictionary[handle.ProcessId].Name + + " (" + handle.ProcessId.ToString() + ")"; + item.Tag = handle; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.TypeName)); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.BestName)); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "0x" + handle.Handle.ToString("x"))); @@ -233,13 +239,11 @@ private void CallHandleMatchListView(SystemHandleEntry handle, ObjectInformation private void CallDllMatchListView(int pid, ILoadedModule module) { - ListViewItem item = new ListViewItem - { - Name = pid.ToString() + " " + module.BaseAddress.ToString(), - Text = Program.ProcessProvider.Dictionary[pid].Name + " (" + pid.ToString() + ")", - Tag = pid - }; - + ListViewItem item = new ListViewItem(); + item.Name = pid.ToString() + " " + module.BaseAddress.ToString(); + item.Text = Program.ProcessProvider.Dictionary[pid].Name + + " (" + pid.ToString() + ")"; + item.Tag = pid; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "DLL")); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, module.FileName)); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, Utils.FormatAddress(module.BaseAddress))); @@ -248,12 +252,11 @@ private void CallDllMatchListView(int pid, ILoadedModule module) private void CallMappedFileMatchListView(int pid, IntPtr address, string fileName) { - ListViewItem item = new ListViewItem - { - Name = pid.ToString() + " " + address.ToString(), - Text = Program.ProcessProvider.Dictionary[pid].Name + " (" + pid.ToString() + ")", - Tag = pid - }; + ListViewItem item = new ListViewItem(); + item.Name = pid.ToString() + " " + address.ToString(); + item.Text = Program.ProcessProvider.Dictionary[pid].Name + + " (" + pid.ToString() + ")"; + item.Tag = pid; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, "Mapped File")); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, fileName)); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, Utils.FormatAddress(address))); @@ -265,11 +268,7 @@ private void OnMatchListView(ListViewItem item) if (item == null) { if (listViewItemContainer.Count > 0) - { - if (MatchListView != null) - MatchListView(listViewItemContainer); - } - + FireAsync(MatchListView, listViewItemContainer); return; } @@ -279,17 +278,14 @@ private void OnMatchListView(ListViewItem item) { List items = listViewItemContainer; - if (MatchListView != null) - MatchListView(items); - + FireAsync(MatchListView, items); listViewItemContainer = new List(BufferSize); } } private void OnMatchProgress(int currentValue, int allValue) { - if (MatchProgress != null) - MatchProgress(currentValue, allValue); + FireAsync(MatchProgress, currentValue, allValue); } } } diff --git a/1.x/trunk/ProcessHacker/UI/ExplorerVisualStyle.cs b/1.x/trunk/ProcessHacker/UI/ExplorerVisualStyle.cs deleted file mode 100644 index 83d6cad25..000000000 --- a/1.x/trunk/ProcessHacker/UI/ExplorerVisualStyle.cs +++ /dev/null @@ -1,264 +0,0 @@ -namespace System -{ - using Windows.Forms.VisualStyles; - - public static class ExplorerVisualStyle - { - private static bool? useVisualStyles; - private static bool? visualStylesEnabled; - - public static bool VisualStylesEnabled - { - get - { - if (!visualStylesEnabled.HasValue) - visualStylesEnabled = (Windows.Forms.Application.RenderWithVisualStyles && VisualStyleInformation.IsEnabledByUser); - - return visualStylesEnabled.Value; - } - } - - /// - /// Checks Application and OS Visual Style status - /// - public static bool UseVisualStyles - { - get - { - // if useVisualStyles is null, check application and OS VisualStyle status, cache result and return cached result. - // these are the only two checks required because of the way RenderWithVisualStyles and IsEnabledByUser is implemented. - - if (!useVisualStyles.HasValue) - useVisualStyles = VisualStylesEnabled && VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement("Explorer::TreeView", 4, 1)); - - return useVisualStyles.Value; - } - set - { - // allow application to enable/disable VisualStyles if required. - useVisualStyles = value; - } - } - - #region Default Renderers - - // TODO: add Backwards compatibility with XP by moving Custom Colors used in ListTreeControl.cs to here. - - private static VisualStyleRenderer minusRenderer; - private static VisualStyleRenderer plusRenderer; - - public static VisualStyleRenderer MinusRenderer - { - get - { - if (minusRenderer == null) - minusRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed); - - return minusRenderer; - } - } - - public static VisualStyleRenderer PlusRenderer - { - get - { - if (plusRenderer == null) - plusRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened); - - return plusRenderer; - } - } - - #endregion - - #region TreeView Renderers - - private static VisualStyleRenderer tvClosedRenderer; - private static VisualStyleRenderer tvOpenedRenderer; - private static VisualStyleRenderer tvHoverClosedRenderer; - private static VisualStyleRenderer tvHoverOpenedRenderer; - private static VisualStyleRenderer tvItemHoverRenderer; - private static VisualStyleRenderer tvItemSelectedRenderer; - private static VisualStyleRenderer tvLostFocusSelectedRenderer; - private static VisualStyleRenderer tvSelectedHoverRenderer; - - /// - /// Default style used for the TreeViewNode closed Glyph. - /// - public static VisualStyleRenderer TvClosedRenderer - { - get - { - if (tvClosedRenderer == null) - tvClosedRenderer = new VisualStyleRenderer("Explorer::TreeView", 2, 1); - - return tvClosedRenderer; - } - } - - /// - /// Default style used for the TreeViewNode opened Glyph. - /// - public static VisualStyleRenderer TvOpenedRenderer - { - get - { - if (tvOpenedRenderer == null) - tvOpenedRenderer = new VisualStyleRenderer("Explorer::TreeView", 2, 2); - - return tvOpenedRenderer; - } - } - - /// - /// Style used when the mouse is positioned over the TreeView's Closed Glyph. - /// - public static VisualStyleRenderer TvHoverClosedRenderer - { - get - { - if (tvHoverClosedRenderer == null) - tvHoverClosedRenderer = new VisualStyleRenderer("Explorer::TreeView", 4, 1); - - return tvHoverClosedRenderer; - } - } - - /// - /// Style used when the mouse is positioned over the TreeView's Opened Glyph. - /// - public static VisualStyleRenderer TvHoverOpenedRenderer - { - get - { - if (tvHoverOpenedRenderer == null) - tvHoverOpenedRenderer = new VisualStyleRenderer("Explorer::TreeView", 4, 2); - - return tvHoverOpenedRenderer; - } - } - - /// - /// Style used when mouse is hovering over a TreeViewNode. - /// - public static VisualStyleRenderer TvItemHoverRenderer - { - get - { - if (tvItemHoverRenderer == null) - tvItemHoverRenderer = new VisualStyleRenderer("Explorer::TreeView", 1, 2); - - return tvItemHoverRenderer; - } - } - - /// - /// Style used when a TreeViewNode is selected. - /// - public static VisualStyleRenderer TvItemSelectedRenderer - { - get - { - if (tvItemSelectedRenderer == null) - tvItemSelectedRenderer = new VisualStyleRenderer("Explorer::TreeView", 1, 3); - - return tvItemSelectedRenderer; - } - } - - /// - /// Style used when a TreeViewNode is selected but remains highlighted if the control has lost focus. (when TreeView.HideSelecton = false)) - /// - public static VisualStyleRenderer TvLostFocusSelectedRenderer - { - get - { - if (tvLostFocusSelectedRenderer == null) - tvLostFocusSelectedRenderer = new VisualStyleRenderer("Explorer::TreeView", 1, 5); - - return tvLostFocusSelectedRenderer; - } - } - - /// - /// Style used when the mouse is hovering over a currently selected TreeViewNode. - /// - public static VisualStyleRenderer TvSelectedItemHoverRenderer - { - get - { - if (tvSelectedHoverRenderer == null) - tvSelectedHoverRenderer = new VisualStyleRenderer("Explorer::TreeView", 1, 6); - - return tvSelectedHoverRenderer; - } - } - - #endregion - - #region ListView Renderers - - private static VisualStyleRenderer lvItemHoverRenderer; - private static VisualStyleRenderer lvItemSelectedRenderer; - private static VisualStyleRenderer lvLostFocusSelectedRenderer; - private static VisualStyleRenderer lvSelectedItemHoverRenderer; - - /// - /// Style used when mouse is hovering over a ListViewItem. - /// - public static VisualStyleRenderer LvItemHoverRenderer - { - get - { - if (lvItemHoverRenderer == null) - lvItemHoverRenderer = new VisualStyleRenderer("Explorer::ListView", 1, 2); - - return lvItemHoverRenderer; - } - } - - /// - /// Style used when a ListViewItem is selected. - /// - public static VisualStyleRenderer LvItemSelectedRenderer - { - get - { - if (lvItemSelectedRenderer == null) - lvItemSelectedRenderer = new VisualStyleRenderer("Explorer::ListView", 1, 3); - - return lvItemSelectedRenderer; - } - } - - /// - /// Style used when a ListViewItem is selected but remains highlighted if the control has lost focus. (when ListView.HideSelecton = false)) - /// - public static VisualStyleRenderer LvLostFocusSelectedRenderer - { - get - { - if (lvLostFocusSelectedRenderer == null) - lvLostFocusSelectedRenderer = new VisualStyleRenderer("Explorer::ListView", 1, 5); - - return lvLostFocusSelectedRenderer; - } - } - - /// - /// Style used when the mouse is hovering over a currently selected ListViewItem. - /// - public static VisualStyleRenderer LvSelectedItemHoverRenderer - { - get - { - if (lvSelectedItemHoverRenderer == null) - lvSelectedItemHoverRenderer = new VisualStyleRenderer("Explorer::ListView", 1, 6); - - return lvSelectedItemHoverRenderer; - } - } - - #endregion - } -} diff --git a/1.x/trunk/ProcessHacker/UI/GenericViewMenu.cs b/1.x/trunk/ProcessHacker/UI/GenericViewMenu.cs index 0e266d4ad..cdeb19e94 100644 --- a/1.x/trunk/ProcessHacker/UI/GenericViewMenu.cs +++ b/1.x/trunk/ProcessHacker/UI/GenericViewMenu.cs @@ -39,12 +39,10 @@ public static ContextMenu GetMenu(ListView lv) public static ContextMenu GetMenu(ListView lv, RetrieveVirtualItemEventHandler retrieveVirtualItem) { - ContextMenu menu = new ContextMenu - { - Tag = lv - }; + ContextMenu menu = new ContextMenu(); - menu.Popup += ListViewMenu_Popup; + menu.Tag = lv; + menu.Popup += new EventHandler(ListViewMenu_Popup); AddMenuItems(menu.MenuItems, lv, retrieveVirtualItem); return menu; @@ -52,29 +50,19 @@ public static ContextMenu GetMenu(ListView lv, RetrieveVirtualItemEventHandler r public static void AddMenuItems(MenuItem.MenuItemCollection items, ListView lv, RetrieveVirtualItemEventHandler retrieveVirtualItem) { - MenuItem copyItem = new MenuItem("Copy") - { - Tag = new object[] - { - -1, lv, retrieveVirtualItem - } - }; + MenuItem copyItem = new MenuItem("Copy"); - copyItem.Click += ListViewMenuItem_Click; + copyItem.Tag = new object[] { -1, lv, retrieveVirtualItem }; + copyItem.Click += new EventHandler(ListViewMenuItem_Click); items.Add(copyItem); foreach (ColumnHeader ch in lv.Columns) { - MenuItem item = new MenuItem("Copy \"" + ch.Text + "\"") - { - Tag = new object[] - { - ch.Index, lv, retrieveVirtualItem - } - }; + MenuItem item = new MenuItem("Copy \"" + ch.Text + "\""); - item.Click += ListViewMenuItem_Click; + item.Tag = new object[] { ch.Index, lv, retrieveVirtualItem }; + item.Click += new EventHandler(ListViewMenuItem_Click); items.Add(item); } @@ -87,7 +75,7 @@ private static void ListViewMenu_Popup(object sender, EventArgs e) if (lv.SelectedIndices.Count == 0) { - //Utils.DisableAllMenuItems(citem); + Utils.DisableAllMenuItems(citem); } else { @@ -159,15 +147,10 @@ private static void ListViewMenuItem_Click(object sender, EventArgs e) public static void AddMenuItems(MenuItem.MenuItemCollection items, TreeViewAdv tv) { - MenuItem copyItem = new MenuItem("Copy") - { - Tag = new object[] - { - -1, tv - } - }; + MenuItem copyItem = new MenuItem("Copy"); - copyItem.Click += TreeViewAdvMenuItem_Click; + copyItem.Tag = new object[] { -1, tv }; + copyItem.Click += new EventHandler(TreeViewAdvMenuItem_Click); items.Add(copyItem); @@ -190,15 +173,10 @@ public static void AddMenuItems(MenuItem.MenuItemCollection items, TreeViewAdv t if (!c.IsVisible || index == -1) continue; - MenuItem item = new MenuItem("Copy \"" + c.Header + "\"") - { - Tag = new object[] - { - index, tv - } - }; + MenuItem item = new MenuItem("Copy \"" + c.Header + "\""); - item.Click += TreeViewAdvMenuItem_Click; + item.Tag = new object[] { index, tv }; + item.Click += new EventHandler(TreeViewAdvMenuItem_Click); items.Add(item); } diff --git a/1.x/trunk/ProcessHacker/UI/HighlightedListViewItem.cs b/1.x/trunk/ProcessHacker/UI/HighlightedListViewItem.cs index fdff1e01d..04b696596 100644 --- a/1.x/trunk/ProcessHacker/UI/HighlightedListViewItem.cs +++ b/1.x/trunk/ProcessHacker/UI/HighlightedListViewItem.cs @@ -37,7 +37,7 @@ public class HighlightingContext : IDisposable { public static event MethodInvoker HighlightingDurationChanged; - private static readonly Dictionary _colors = new Dictionary(); + private static Dictionary _colors = new Dictionary(); private static int _highlightingDuration = 1000; private static bool _stateHighlighting = true; @@ -76,10 +76,10 @@ public static bool StateHighlighting set { _stateHighlighting = value; } } - private readonly ListView _list; - private readonly Queue _queue = new Queue(); - private readonly Queue _postQueue = new Queue(); - private readonly Queue _postQueuePending = new Queue(); + private ListView _list; + private Queue _queue = new Queue(); + private Queue _postQueue = new Queue(); + private Queue _postQueuePending = new Queue(); public HighlightingContext(ListView list) { @@ -91,45 +91,45 @@ public void Tick() if (!_list.IsHandleCreated) return; - _list.BeginInvoke(new MethodInvoker(() => + _list.BeginInvoke(new MethodInvoker(delegate { // Execute the queue items. - this._list.BeginUpdate(); + _list.BeginUpdate(); - lock (this._queue) + lock (_queue) { - while (this._queue.Count > 0) - this._queue.Dequeue().Invoke(); + while (_queue.Count > 0) + _queue.Dequeue().Invoke(); } - this._list.EndUpdate(); + _list.EndUpdate(); // Execute the post-queue items. System.Threading.Timer t = null; t = new System.Threading.Timer(o => { - if (this._list.IsHandleCreated) + if (_list.IsHandleCreated) { - this._list.BeginInvoke(new MethodInvoker(() => + _list.BeginInvoke(new MethodInvoker(delegate { - this._list.BeginUpdate(); + _list.BeginUpdate(); - lock (this._postQueue) + lock (_postQueue) { - while (this._postQueue.Count > 0) - this._postQueue.Dequeue().Invoke(); + while (_postQueue.Count > 0) + _postQueue.Dequeue().Invoke(); } - this._list.EndUpdate(); + _list.EndUpdate(); // Re-enqueue the pending post-queue items. - lock (this._postQueuePending) + lock (_postQueuePending) { - lock (this._postQueue) + lock (_postQueue) { - while (this._postQueuePending.Count > 0) - this._postQueue.Enqueue(this._postQueuePending.Dequeue()); + while (_postQueuePending.Count > 0) + _postQueue.Enqueue(_postQueuePending.Dequeue()); } } })); @@ -163,7 +163,7 @@ public void Dispose() /// public class HighlightedListViewItem : ListViewItem { - private readonly HighlightingContext _context; + private HighlightingContext _context; private Color _normalColor = SystemColors.Window; private ListViewItemState _state = ListViewItemState.Normal; @@ -190,12 +190,12 @@ public HighlightedListViewItem(HighlightingContext context, string text, bool hi this.ForeColor = PhUtils.GetForeColor(this.BackColor); _state = ListViewItemState.New; - _context.EnqueuePost(() => - { - this.BackColor = this._normalColor; - this.ForeColor = PhUtils.GetForeColor(this.BackColor); - this._state = ListViewItemState.Normal; - }); + _context.EnqueuePost(delegate + { + this.BackColor = _normalColor; + this.ForeColor = PhUtils.GetForeColor(this.BackColor); + _state = ListViewItemState.Normal; + }); } else { @@ -207,13 +207,16 @@ public override void Remove() { if (HighlightingContext.StateHighlighting) { - _context.Enqueue(() => - { - this.BackColor = HighlightingContext.Colors[ListViewItemState.Removed]; - this.ForeColor = PhUtils.GetForeColor(this.BackColor); + _context.Enqueue(delegate + { + this.BackColor = HighlightingContext.Colors[ListViewItemState.Removed]; + this.ForeColor = PhUtils.GetForeColor(this.BackColor); - this._context.EnqueuePost(this.BaseRemove); - }); + _context.EnqueuePost(delegate + { + this.BaseRemove(); + }); + }); } else { @@ -243,17 +246,17 @@ public Color NormalColor public void SetTemporaryState(ListViewItemState state) { - _context.Enqueue(() => + _context.Enqueue(delegate { this.BackColor = HighlightingContext.Colors[state]; this.ForeColor = PhUtils.GetForeColor(this.BackColor); - this._state = state; + _state = state; - this._context.EnqueuePost(() => + _context.EnqueuePost(delegate { - this.BackColor = this._normalColor; + this.BackColor = _normalColor; this.ForeColor = PhUtils.GetForeColor(this.BackColor); - this._state = ListViewItemState.Normal; + _state = ListViewItemState.Normal; }); }); } diff --git a/1.x/trunk/ProcessHacker/UI/Icons/CommitHistoryIcon.cs b/1.x/trunk/ProcessHacker/UI/Icons/CommitHistoryIcon.cs index 5f24a495f..fcc938217 100644 --- a/1.x/trunk/ProcessHacker/UI/Icons/CommitHistoryIcon.cs +++ b/1.x/trunk/ProcessHacker/UI/Icons/CommitHistoryIcon.cs @@ -20,6 +20,7 @@ * along with Process Hacker. If not, see . */ +using System.Runtime.InteropServices; using ProcessHacker.Common; using ProcessHacker.Native.Api; @@ -32,13 +33,10 @@ public CommitHistoryIcon() this.UseSecondLine = false; this.UseLongData = true; - PerformanceInformation info = new PerformanceInformation - { - cbSize = PerformanceInformation.SizeOf - }; - - Win32.GetPerformanceInfo(out info, info.cbSize); + PerformanceInformation info = new PerformanceInformation(); + info.Size = Marshal.SizeOf(info); + Win32.GetPerformanceInfo(out info, info.Size); this.MinMaxValue = info.CommitLimit.ToInt64(); } @@ -48,7 +46,8 @@ protected override void ProviderUpdated() this.Update(this.Provider.Performance.CommittedPages, 0); this.Redraw(); - this.Text = "Commit: " + Utils.FormatSize(this.Provider.Performance.CommittedPages * this.Provider.System.PageSize); + this.Text = "Commit: " + Utils.FormatSize( + (long)this.Provider.Performance.CommittedPages * this.Provider.System.PageSize); } } } diff --git a/1.x/trunk/ProcessHacker/UI/Icons/CpuHistoryIcon.cs b/1.x/trunk/ProcessHacker/UI/Icons/CpuHistoryIcon.cs index 24ad2fc20..63b4c7eec 100644 --- a/1.x/trunk/ProcessHacker/UI/Icons/CpuHistoryIcon.cs +++ b/1.x/trunk/ProcessHacker/UI/Icons/CpuHistoryIcon.cs @@ -20,6 +20,10 @@ * along with Process Hacker. If not, see . */ +using System; +using System.Collections.Generic; +using System.Text; + namespace ProcessHacker { public class CpuHistoryIcon : ProviderIcon diff --git a/1.x/trunk/ProcessHacker/UI/Icons/CpuUsageIcon.cs b/1.x/trunk/ProcessHacker/UI/Icons/CpuUsageIcon.cs index 73ba2a240..fdf0941fb 100644 --- a/1.x/trunk/ProcessHacker/UI/Icons/CpuUsageIcon.cs +++ b/1.x/trunk/ProcessHacker/UI/Icons/CpuUsageIcon.cs @@ -26,8 +26,8 @@ namespace ProcessHacker { public class CpuUsageIcon : UsageIcon { - private readonly ProcessSystemProvider _provider = Program.ProcessProvider; - private bool _enabled; + private ProcessSystemProvider _provider = Program.ProcessProvider; + private bool _enabled = false; public CpuUsageIcon() { } @@ -103,7 +103,7 @@ private void ProviderUpdated() var oldIcon = this.Icon; this.Icon = newIcon; - Native.Api.Win32.DestroyIcon(oldIcon.Handle); + ProcessHacker.Native.Api.Win32.DestroyIcon(oldIcon.Handle); } string mostCpuProcess = _provider.MostCpuHistory[0]; diff --git a/1.x/trunk/ProcessHacker/UI/Icons/PhysMemHistoryIcon.cs b/1.x/trunk/ProcessHacker/UI/Icons/PhysMemHistoryIcon.cs index 2c0f49204..5e70f4539 100644 --- a/1.x/trunk/ProcessHacker/UI/Icons/PhysMemHistoryIcon.cs +++ b/1.x/trunk/ProcessHacker/UI/Icons/PhysMemHistoryIcon.cs @@ -20,6 +20,7 @@ * along with Process Hacker. If not, see . */ +using System.Runtime.InteropServices; using ProcessHacker.Common; using ProcessHacker.Native.Api; @@ -32,13 +33,10 @@ public PhysMemHistoryIcon() this.UseSecondLine = false; this.UseLongData = true; - PerformanceInformation info = new PerformanceInformation - { - cbSize = PerformanceInformation.SizeOf - }; - - Win32.GetPerformanceInfo(out info, info.cbSize); + PerformanceInformation info = new PerformanceInformation(); + info.Size = Marshal.SizeOf(info); + Win32.GetPerformanceInfo(out info, info.Size); this.MinMaxValue = info.PhysicalTotal.ToInt64(); } @@ -48,7 +46,9 @@ protected override void ProviderUpdated() this.Update(this.MinMaxValue - this.Provider.Performance.AvailablePages, 0); this.Redraw(); - this.Text = "Physical Memory: " + Utils.FormatSize((this.MinMaxValue - this.Provider.Performance.AvailablePages) * this.Provider.System.PageSize); + this.Text = "Physical Memory: " + Utils.FormatSize( + (long)(this.MinMaxValue - this.Provider.Performance.AvailablePages) * + this.Provider.System.PageSize); } } } diff --git a/1.x/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs b/1.x/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs index dbbe2616f..2400c8a25 100644 --- a/1.x/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs +++ b/1.x/trunk/ProcessHacker/UI/Icons/PlotterIcon.cs @@ -21,6 +21,7 @@ */ using System.Drawing; +using System.Windows.Forms; // DO NOT REMOVE, needed in Debug mode using ProcessHacker.Common; using ProcessHacker.Components; @@ -28,20 +29,20 @@ namespace ProcessHacker { public abstract class PlotterIcon : UsageIcon { - private readonly CircularBuffer _dataHistory1; - private readonly CircularBuffer _dataHistory2; - private readonly CircularBuffer _longDataHistory1; - private readonly CircularBuffer _longDataHistory2; - private readonly Plotter _plotter; + private CircularBuffer _dataHistory1; + private CircularBuffer _dataHistory2; + private CircularBuffer _longDataHistory1; + private CircularBuffer _longDataHistory2; + private Plotter _plotter; - protected PlotterIcon() + public PlotterIcon() { _dataHistory1 = new CircularBuffer(20); _dataHistory2 = new CircularBuffer(20); _longDataHistory1 = new CircularBuffer(20); _longDataHistory2 = new CircularBuffer(20); - _plotter = new Plotter + _plotter = new Plotter() { Size = this.Size, ShowGrid = false, @@ -90,7 +91,7 @@ public void Redraw() } this.Icon = newIcon; - Native.Api.Win32.DestroyIcon(oldIcon.Handle); + ProcessHacker.Native.Api.Win32.DestroyIcon(oldIcon.Handle); } protected bool UseLongData diff --git a/1.x/trunk/ProcessHacker/UI/Icons/ProviderIcon.cs b/1.x/trunk/ProcessHacker/UI/Icons/ProviderIcon.cs index b4d728ed4..36c13861b 100644 --- a/1.x/trunk/ProcessHacker/UI/Icons/ProviderIcon.cs +++ b/1.x/trunk/ProcessHacker/UI/Icons/ProviderIcon.cs @@ -20,11 +20,16 @@ * along with Process Hacker. If not, see . */ +using System.Windows.Forms; + namespace ProcessHacker { public class ProviderIcon : PlotterIcon { - private bool _enabled; + private bool _enabled = false; + + public ProviderIcon() + { } public override void Dispose() { diff --git a/1.x/trunk/ProcessHacker/UI/Icons/UsageIcon.cs b/1.x/trunk/ProcessHacker/UI/Icons/UsageIcon.cs index 3f522d82a..7c67d0a84 100644 --- a/1.x/trunk/ProcessHacker/UI/Icons/UsageIcon.cs +++ b/1.x/trunk/ProcessHacker/UI/Icons/UsageIcon.cs @@ -45,7 +45,7 @@ public static UsageIcon ActiveUsageIcon { TaskbarLib.Windows7Taskbar.SetTaskbarOverlayIcon( null, - string.Empty + "" ); } } @@ -65,14 +65,14 @@ public static Size GetSmallIconSize() private Control _parent; private Size _size; - private readonly NotifyIcon _notifyIcon; + private NotifyIcon _notifyIcon; public UsageIcon() { _notifyIcon = new NotifyIcon(); - _notifyIcon.MouseClick += this.notifyIcon_MouseClick; - _notifyIcon.MouseDoubleClick += this.notifyIcon_MouseDoubleClick; + _notifyIcon.MouseClick += new MouseEventHandler(notifyIcon_MouseClick); + _notifyIcon.MouseDoubleClick += new MouseEventHandler(notifyIcon_MouseDoubleClick); _size = GetSmallIconSize(); } @@ -105,10 +105,10 @@ public Control Parent set { _parent = value; } } - public ContextMenuStrip ContextMenu + public ContextMenu ContextMenu { - get { return _notifyIcon.ContextMenuStrip; } - set { _notifyIcon.ContextMenuStrip = value; } + get { return _notifyIcon.ContextMenu; } + set { _notifyIcon.ContextMenu = value; } } public Icon Icon diff --git a/1.x/trunk/ProcessHacker/UI/WindowFromHandle.cs b/1.x/trunk/ProcessHacker/UI/WindowFromHandle.cs index 0f2871c7d..98f8c23e1 100644 --- a/1.x/trunk/ProcessHacker/UI/WindowFromHandle.cs +++ b/1.x/trunk/ProcessHacker/UI/WindowFromHandle.cs @@ -1,11 +1,13 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Windows.Forms; namespace ProcessHacker.UI { public struct WindowFromHandle : IWin32Window { - private readonly IntPtr _handle; + private IntPtr _handle; public WindowFromHandle(IntPtr handle) { diff --git a/1.x/trunk/ProcessHacker/app.config b/1.x/trunk/ProcessHacker/app.config index b7a7ef166..cb2586beb 100644 --- a/1.x/trunk/ProcessHacker/app.config +++ b/1.x/trunk/ProcessHacker/app.config @@ -1,3 +1,3 @@ - + diff --git a/1.x/trunk/ProcessHacker/app.manifest b/1.x/trunk/ProcessHacker/app.manifest index 5972a7b29..dc0cdf024 100644 --- a/1.x/trunk/ProcessHacker/app.manifest +++ b/1.x/trunk/ProcessHacker/app.manifest @@ -4,32 +4,19 @@ - + + - - - - - - - - - - - - - - - - - diff --git a/1.x/trunk/TreeViewAdv/Aga.Controls.csproj b/1.x/trunk/TreeViewAdv/Aga.Controls.csproj new file mode 100644 index 000000000..b66313e54 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Aga.Controls.csproj @@ -0,0 +1,271 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {E73BB233-D88B-44A7-A98F-D71EE158381D} + Library + Properties + Aga.Controls + Aga.Controls + + + + + + + + + false + + + + + 3.5 + v4.0 + + + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + + true + full + false + bin\Debug\ + TRACE;DEBUG;PERF_TEST + prompt + 4 + + + true + AnyCPU + Migrated rules for Aga.Controls.ruleset + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + AnyCPU + AllRules.ruleset + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + + + + Component + + + Component + + + Component + + + Component + + + Component + + + + + + + + + + Component + + + Component + + + + + + + Component + + + + + Component + + + + + + Component + + + Component + + + Component + + + + + + + Component + + + + + + + + + + + + + + Component + + + + Component + + + Component + + + Component + + + + + Component + + + Component + + + + Component + + + + + + Component + + + TreeViewAdv.cs + + + + + + + + + + + + + + + + Designer + ResXFileCodeGenerator + Resources.Designer.cs + + + TreeViewAdv.cs + + + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 2.0 %28AnyCPU%29 + false + + + False + .NET Framework 3.0 %28AnyCPU%29 + false + + + False + .NET Framework 3.5 + true + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/BitmapHelper.cs b/1.x/trunk/TreeViewAdv/BitmapHelper.cs similarity index 89% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/BitmapHelper.cs rename to 1.x/trunk/TreeViewAdv/BitmapHelper.cs index 8c5ae8930..3237db260 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/BitmapHelper.cs +++ b/1.x/trunk/TreeViewAdv/BitmapHelper.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Drawing; using System.Runtime.InteropServices; using System.Drawing.Imaging; @@ -8,7 +10,7 @@ namespace Aga.Controls public static class BitmapHelper { [StructLayout(LayoutKind.Sequential)] - public struct PixelData + private struct PixelData { public byte B; public byte G; diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/GifDecoder.cs b/1.x/trunk/TreeViewAdv/GifDecoder.cs similarity index 94% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/GifDecoder.cs rename to 1.x/trunk/TreeViewAdv/GifDecoder.cs index ae612c13c..838d79806 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/GifDecoder.cs +++ b/1.x/trunk/TreeViewAdv/GifDecoder.cs @@ -27,19 +27,20 @@ using System; using System.Collections; using System.Drawing; +using System.Drawing.Imaging; using System.IO; namespace Aga.Controls { public class GifFrame { - private readonly Image _image; + private Image _image; public Image Image { get { return _image; } } - private readonly int _delay; + private int _delay; public int Delay { get { return _delay; } @@ -706,7 +707,7 @@ private void ReadHeader() { id += (char) Read(); } - if (!id.StartsWith("GIF", StringComparison.OrdinalIgnoreCase)) + if (!id.StartsWith("GIF")) { status = StatusFormatError; return; diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/NumericTextBox.cs b/1.x/trunk/TreeViewAdv/NumericTextBox.cs similarity index 93% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/NumericTextBox.cs rename to 1.x/trunk/TreeViewAdv/NumericTextBox.cs index 4118f4fb6..ee1ee0650 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/NumericTextBox.cs +++ b/1.x/trunk/TreeViewAdv/NumericTextBox.cs @@ -147,14 +147,12 @@ protected override void WndProc(ref Message m) } - public uint IntValue + public int IntValue { get { - uint intValue; - - uint.TryParse(this.Text, numberStyle, CultureInfo.CurrentCulture.NumberFormat, out intValue); - + int intValue; + Int32.TryParse(this.Text, numberStyle, CultureInfo.CurrentCulture.NumberFormat, out intValue); return intValue; } } diff --git a/1.x/trunk/TreeViewAdv/Properties/AssemblyInfo.cs b/1.x/trunk/TreeViewAdv/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..23c410313 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System; +using System.Security.Permissions; + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: SecurityPermission(SecurityAction.RequestMinimum, Execution = true)] + +[assembly: AssemblyTitle("Aga.Controls")] +[assembly: AssemblyCopyright("Copyright © Andrey Gliznetsov 2006 - 2007, modified by wj32")] +[assembly: AssemblyDescription("http://sourceforge.net/projects/treeviewadv/")] + +[assembly: AssemblyVersion("1.6.1.0")] diff --git a/1.x/trunk/TreeViewAdv/Properties/Resources.Designer.cs b/1.x/trunk/TreeViewAdv/Properties/Resources.Designer.cs new file mode 100644 index 000000000..c2139b598 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Properties/Resources.Designer.cs @@ -0,0 +1,133 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.235 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Aga.Controls.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Aga.Controls.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + internal static System.Drawing.Bitmap check { + get { + object obj = ResourceManager.GetObject("check", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static byte[] DVSplit { + get { + object obj = ResourceManager.GetObject("DVSplit", resourceCulture); + return ((byte[])(obj)); + } + } + + internal static System.Drawing.Bitmap Folder { + get { + object obj = ResourceManager.GetObject("Folder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap FolderClosed { + get { + object obj = ResourceManager.GetObject("FolderClosed", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap Leaf { + get { + object obj = ResourceManager.GetObject("Leaf", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static byte[] loading_icon { + get { + object obj = ResourceManager.GetObject("loading_icon", resourceCulture); + return ((byte[])(obj)); + } + } + + internal static System.Drawing.Bitmap minus { + get { + object obj = ResourceManager.GetObject("minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap plus { + get { + object obj = ResourceManager.GetObject("plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap uncheck { + get { + object obj = ResourceManager.GetObject("uncheck", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + internal static System.Drawing.Bitmap unknown { + get { + object obj = ResourceManager.GetObject("unknown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/Tracker.resx b/1.x/trunk/TreeViewAdv/Properties/Resources.resx similarity index 66% rename from 1.x/trunk/ProcessHacker/Components/Tracker.resx rename to 1.x/trunk/TreeViewAdv/Properties/Resources.resx index 6e04bf688..5307ac87d 100644 --- a/1.x/trunk/ProcessHacker/Components/Tracker.resx +++ b/1.x/trunk/TreeViewAdv/Properties/Resources.resx @@ -112,15 +112,40 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - - - False - + + + ..\Resources\check.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\dvsplit.cur;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Folder.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\FolderClosed.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\leaf.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\loading_icon;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\minus.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\plus.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\uncheck.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\resources\unknown.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/ResourceHelper.cs b/1.x/trunk/TreeViewAdv/ResourceHelper.cs similarity index 76% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/ResourceHelper.cs rename to 1.x/trunk/TreeViewAdv/ResourceHelper.cs index 3c2b101ab..99176f294 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/ResourceHelper.cs +++ b/1.x/trunk/TreeViewAdv/ResourceHelper.cs @@ -1,18 +1,22 @@ +using System; using System.IO; +using System.Reflection; using System.Windows.Forms; +using System.Collections.Generic; +using System.Text; namespace Aga.Controls { public static class ResourceHelper { // VSpilt Cursor with Innerline (symbolisize hidden column) - private static readonly Cursor _dVSplitCursor = GetCursor(ProcessHacker.Properties.Resources.DVSplit); + private static Cursor _dVSplitCursor = GetCursor(Properties.Resources.DVSplit); public static Cursor DVSplitCursor { get { return _dVSplitCursor; } } - private static readonly GifDecoder _loadingIcon = GetGifDecoder(ProcessHacker.Properties.Resources.loading_icon); + private static GifDecoder _loadingIcon = GetGifDecoder(Properties.Resources.loading_icon); public static GifDecoder LoadingIcon { get { return _loadingIcon; } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/DVSplit.cur b/1.x/trunk/TreeViewAdv/Resources/DVSplit.cur similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/DVSplit.cur rename to 1.x/trunk/TreeViewAdv/Resources/DVSplit.cur diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/Folder.bmp b/1.x/trunk/TreeViewAdv/Resources/Folder.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/Folder.bmp rename to 1.x/trunk/TreeViewAdv/Resources/Folder.bmp diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/FolderClosed.bmp b/1.x/trunk/TreeViewAdv/Resources/FolderClosed.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/FolderClosed.bmp rename to 1.x/trunk/TreeViewAdv/Resources/FolderClosed.bmp diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/Leaf.bmp b/1.x/trunk/TreeViewAdv/Resources/Leaf.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/Leaf.bmp rename to 1.x/trunk/TreeViewAdv/Resources/Leaf.bmp diff --git a/1.x/trunk/TreeViewAdv/Resources/Thumbs.db b/1.x/trunk/TreeViewAdv/Resources/Thumbs.db new file mode 100644 index 000000000..983f52698 Binary files /dev/null and b/1.x/trunk/TreeViewAdv/Resources/Thumbs.db differ diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/check.bmp b/1.x/trunk/TreeViewAdv/Resources/check.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/check.bmp rename to 1.x/trunk/TreeViewAdv/Resources/check.bmp diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/loading_icon b/1.x/trunk/TreeViewAdv/Resources/loading_icon similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/loading_icon rename to 1.x/trunk/TreeViewAdv/Resources/loading_icon diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/minus.bmp b/1.x/trunk/TreeViewAdv/Resources/minus.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/minus.bmp rename to 1.x/trunk/TreeViewAdv/Resources/minus.bmp diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/plus.bmp b/1.x/trunk/TreeViewAdv/Resources/plus.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/plus.bmp rename to 1.x/trunk/TreeViewAdv/Resources/plus.bmp diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/uncheck.bmp b/1.x/trunk/TreeViewAdv/Resources/uncheck.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/uncheck.bmp rename to 1.x/trunk/TreeViewAdv/Resources/uncheck.bmp diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/unknown.bmp b/1.x/trunk/TreeViewAdv/Resources/unknown.bmp similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Resources/unknown.bmp rename to 1.x/trunk/TreeViewAdv/Resources/unknown.bmp diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/StringCollectionEditor.cs b/1.x/trunk/TreeViewAdv/StringCollectionEditor.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/StringCollectionEditor.cs rename to 1.x/trunk/TreeViewAdv/StringCollectionEditor.cs diff --git a/1.x/trunk/TreeViewAdv/TextHelper.cs b/1.x/trunk/TreeViewAdv/TextHelper.cs new file mode 100644 index 000000000..756500e32 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/TextHelper.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using System.Drawing; + +namespace Aga.Controls +{ + public static class TextHelper + { + public static StringAlignment TranslateAligment(HorizontalAlignment aligment) + { + if (aligment == HorizontalAlignment.Left) + return StringAlignment.Near; + else if (aligment == HorizontalAlignment.Right) + return StringAlignment.Far; + else + return StringAlignment.Center; + } + + public static TextFormatFlags TranslateAligmentToFlag(HorizontalAlignment aligment) + { + if (aligment == HorizontalAlignment.Left) + return TextFormatFlags.Left; + else if (aligment == HorizontalAlignment.Right) + return TextFormatFlags.Right; + else + return TextFormatFlags.HorizontalCenter; + } + + public static TextFormatFlags TranslateTrimmingToFlag(StringTrimming trimming) + { + if (trimming == StringTrimming.EllipsisCharacter) + return TextFormatFlags.EndEllipsis; + else if (trimming == StringTrimming.EllipsisPath) + return TextFormatFlags.PathEllipsis; + if (trimming == StringTrimming.EllipsisWord) + return TextFormatFlags.WordEllipsis; + if (trimming == StringTrimming.Word) + return TextFormatFlags.WordBreak; + else + return TextFormatFlags.Default; + } + } +} diff --git a/1.x/trunk/TreeViewAdv/Threading/AbortableThreadPool.cs b/1.x/trunk/TreeViewAdv/Threading/AbortableThreadPool.cs new file mode 100644 index 000000000..9b390aa1e --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Threading/AbortableThreadPool.cs @@ -0,0 +1,118 @@ +// Stephen Toub +// stoub@microsoft.com + +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; + +namespace Aga.Controls.Threading +{ + public class AbortableThreadPool + { + private LinkedList _callbacks = new LinkedList(); + private Dictionary _threads = new Dictionary(); + + public WorkItem QueueUserWorkItem(WaitCallback callback) + { + return QueueUserWorkItem(callback, null); + } + + public WorkItem QueueUserWorkItem(WaitCallback callback, object state) + { + if (callback == null) throw new ArgumentNullException("callback"); + + WorkItem item = new WorkItem(callback, state, ExecutionContext.Capture()); + lock (_callbacks) + { + _callbacks.AddLast(item); + } + ThreadPool.QueueUserWorkItem(new WaitCallback(HandleItem)); + return item; + } + + private void HandleItem(object ignored) + { + WorkItem item = null; + try + { + lock (_callbacks) + { + if (_callbacks.Count > 0) + { + item = _callbacks.First.Value; + _callbacks.RemoveFirst(); + } + if (item == null) + return; + _threads.Add(item, Thread.CurrentThread); + + } + ExecutionContext.Run(item.Context, + delegate { item.Callback(item.State); }, null); + } + finally + { + lock (_callbacks) + { + if (item != null) + _threads.Remove(item); + } + } + } + + public bool IsMyThread(Thread thread) + { + lock (_callbacks) + { + foreach (Thread t in _threads.Values) + { + if (t == thread) + return true; + } + return false; + } + } + + public WorkItemStatus Cancel(WorkItem item, bool allowAbort) + { + if (item == null) + throw new ArgumentNullException("item"); + lock (_callbacks) + { + LinkedListNode node = _callbacks.Find(item); + if (node != null) + { + _callbacks.Remove(node); + return WorkItemStatus.Queued; + } + else if (_threads.ContainsKey(item)) + { + if (allowAbort) + { + _threads[item].Abort(); + _threads.Remove(item); + return WorkItemStatus.Aborted; + } + else + return WorkItemStatus.Executing; + } + else + return WorkItemStatus.Completed; + } + } + + public void CancelAll(bool allowAbort) + { + lock (_callbacks) + { + _callbacks.Clear(); + if (allowAbort) + { + foreach (Thread t in _threads.Values) + t.Abort(); + } + } + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Threading/WorkItem.cs b/1.x/trunk/TreeViewAdv/Threading/WorkItem.cs similarity index 69% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Threading/WorkItem.cs rename to 1.x/trunk/TreeViewAdv/Threading/WorkItem.cs index 56d9d97fb..c422a722e 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Threading/WorkItem.cs +++ b/1.x/trunk/TreeViewAdv/Threading/WorkItem.cs @@ -1,12 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; using System.Threading; namespace Aga.Controls.Threading { public sealed class WorkItem { - private readonly WaitCallback _callback; - private readonly object _state; - private readonly ExecutionContext _ctx; + private WaitCallback _callback; + private object _state; + private ExecutionContext _ctx; internal WorkItem(WaitCallback wc, object state, ExecutionContext ctx) { diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Threading/WorkItemStatus.cs b/1.x/trunk/TreeViewAdv/Threading/WorkItemStatus.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Threading/WorkItemStatus.cs rename to 1.x/trunk/TreeViewAdv/Threading/WorkItemStatus.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/TimeCounter.cs b/1.x/trunk/TreeViewAdv/TimeCounter.cs similarity index 81% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/TimeCounter.cs rename to 1.x/trunk/TreeViewAdv/TimeCounter.cs index 4473f01d7..e7afc3aac 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/TimeCounter.cs +++ b/1.x/trunk/TreeViewAdv/TimeCounter.cs @@ -9,7 +9,6 @@ namespace Aga.Controls /// /// High resolution timer, used to test performance /// - [System.Security.SuppressUnmanagedCodeSecurity] public static class TimeCounter { private static Int64 _start; @@ -51,10 +50,10 @@ public static double Finish(Int64 start) [DllImport("Kernel32.dll")] [return: MarshalAs(UnmanagedType.Bool)] - static extern bool QueryPerformanceCounter(ref long performanceCount); + static extern bool QueryPerformanceCounter(ref Int64 performanceCount); [DllImport("Kernel32.dll")] [return: MarshalAs(UnmanagedType.Bool)] - static extern bool QueryPerformanceFrequency(ref long frequency); + static extern bool QueryPerformanceFrequency(ref Int64 frequency); } } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/AutoRowHeightLayout.cs b/1.x/trunk/TreeViewAdv/Tree/AutoRowHeightLayout.cs similarity index 66% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/AutoRowHeightLayout.cs rename to 1.x/trunk/TreeViewAdv/Tree/AutoRowHeightLayout.cs index 7b345d6be..8b89a9879 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/AutoRowHeightLayout.cs +++ b/1.x/trunk/TreeViewAdv/Tree/AutoRowHeightLayout.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text; using System.Drawing; using Aga.Controls.Tree.NodeControls; @@ -8,8 +9,8 @@ namespace Aga.Controls.Tree public class AutoRowHeightLayout: IRowLayout { private DrawContext _measureContext; - private readonly TreeViewAdv _treeView; - private readonly List _rowCache; + private TreeViewAdv _treeView; + private List _rowCache; public AutoRowHeightLayout(TreeViewAdv treeView, int rowHeight) { @@ -34,15 +35,18 @@ public int PageRowCount { if (_treeView.RowCount == 0) return 0; - int pageHeight = this._treeView.DisplayRectangle.Height - this._treeView.ColumnHeaderHeight; - int y = 0; - for (int i = this._treeView.RowCount - 1; i >= 0; i--) - { - y += this.GetRowHeight(i); - if (y > pageHeight) - return Math.Max(0, this._treeView.RowCount - 1 - i); - } - return this._treeView.RowCount; + else + { + int pageHeight = _treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight; + int y = 0; + for (int i = _treeView.RowCount - 1; i >= 0; i--) + { + y += GetRowHeight(i); + if (y > pageHeight) + return Math.Max(0, _treeView.RowCount - 1 - i); + } + return _treeView.RowCount; + } } } @@ -52,15 +56,18 @@ public int CurrentPageSize { if (_treeView.RowCount == 0) return 0; - int pageHeight = this._treeView.DisplayRectangle.Height - this._treeView.ColumnHeaderHeight; - int y = 0; - for (int i = this._treeView.FirstVisibleRow; i < this._treeView.RowCount; i++) - { - y += this.GetRowHeight(i); - if (y > pageHeight) - return Math.Max(0, i - this._treeView.FirstVisibleRow); - } - return Math.Max(0, this._treeView.RowCount - this._treeView.FirstVisibleRow); + else + { + int pageHeight = _treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight; + int y = 0; + for (int i = _treeView.FirstVisibleRow; i < _treeView.RowCount; i++) + { + y += GetRowHeight(i); + if (y > pageHeight) + return Math.Max(0, i - _treeView.FirstVisibleRow); + } + return Math.Max(0, _treeView.RowCount - _treeView.FirstVisibleRow); + } } } @@ -81,12 +88,13 @@ public Rectangle GetRowBounds(int rowNo) } if (rowNo >= 0 && rowNo < _rowCache.Count) return _rowCache[rowNo]; - return Rectangle.Empty; + else + return Rectangle.Empty; } private int GetRowHeight(int rowNo) { - if (rowNo < _treeView.RowMap.Count) + if (rowNo < _treeView.RowMap.Count) { TreeNodeAdv node = _treeView.RowMap[rowNo]; if (node.Height == null) @@ -103,10 +111,11 @@ private int GetRowHeight(int rowNo) } return node.Height.Value; } - return 0; + else + return 0; } - public int GetRowAt(Point point) + public int GetRowAt(Point point) { int py = point.Y - _treeView.ColumnHeaderHeight; int y = 0; @@ -115,7 +124,8 @@ public int GetRowAt(Point point) int h = GetRowHeight(i); if (py >= y && py < y + h) return i; - y += h; + else + y += h; } return -1; } diff --git a/1.x/trunk/TreeViewAdv/Tree/ClassDiagram.cd b/1.x/trunk/TreeViewAdv/Tree/ClassDiagram.cd new file mode 100644 index 000000000..0bd16eff1 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/ClassDiagram.cd @@ -0,0 +1,84 @@ + + + + + + + Tree\TreeModel.cs + AAAkgAAAAAAQAGQAAAAAEAAAEAACQAAAUAAAAAAAAQE= + + + + + + + + + + + + Tree\TreePath.cs + GABAAAAAAAACAAAAAAIAAAAAAAAACAAAAAAAAAAAAAA= + + + + + + + + + + + Tree\Node.cs + AAAgABAAgCAAAAAAAgAEVAAQAAAQAAAIAAsgCAAAAAA= + + + + + + + + + + Tree\Node.cs + + + + + + + + Tree\NodeControls\NodeControl.cs + AAAAAAAAgAAAgsIAAAhAQAAwAAAAEAAAAEAIAAAAAAA= + + + + + + + + Tree\ITreeModel.cs + AAAEAAAAAAAAAEQAAAAAEAAAEAAAQAAAAAAAAAAAAAA= + + + + + + Tree\IToolTipProvider.cs + AAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAA= + + + \ No newline at end of file diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/ColumnCollection.cs b/1.x/trunk/TreeViewAdv/Tree/ColumnCollection.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/ColumnCollection.cs rename to 1.x/trunk/TreeViewAdv/Tree/ColumnCollection.cs diff --git a/1.x/trunk/TreeViewAdv/Tree/DrawContext.cs b/1.x/trunk/TreeViewAdv/Tree/DrawContext.cs new file mode 100644 index 000000000..88a97486a --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/DrawContext.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using Aga.Controls.Tree.NodeControls; + +namespace Aga.Controls.Tree +{ + public struct DrawContext + { + private Graphics _graphics; + public Graphics Graphics + { + get { return _graphics; } + set { _graphics = value; } + } + + private Rectangle _bounds; + public Rectangle Bounds + { + get { return _bounds; } + set { _bounds = value; } + } + + private Font _font; + public Font Font + { + get { return _font; } + set { _font = value; } + } + + private DrawSelectionMode _drawSelection; + public DrawSelectionMode DrawSelection + { + get { return _drawSelection; } + set { _drawSelection = value; } + } + + private bool _drawFocus; + public bool DrawFocus + { + get { return _drawFocus; } + set { _drawFocus = value; } + } + + private NodeControl _currentEditorOwner; + public NodeControl CurrentEditorOwner + { + get { return _currentEditorOwner; } + set { _currentEditorOwner = value; } + } + + private bool _enabled; + public bool Enabled + { + get { return _enabled; } + set { _enabled = value; } + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/DropPosition.cs b/1.x/trunk/TreeViewAdv/Tree/DropPosition.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/DropPosition.cs rename to 1.x/trunk/TreeViewAdv/Tree/DropPosition.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/EditorContext.cs b/1.x/trunk/TreeViewAdv/Tree/EditorContext.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/EditorContext.cs rename to 1.x/trunk/TreeViewAdv/Tree/EditorContext.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Enums.cs b/1.x/trunk/TreeViewAdv/Tree/Enums.cs similarity index 63% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Enums.cs rename to 1.x/trunk/TreeViewAdv/Tree/Enums.cs index 29d6839c0..687c6fca2 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Enums.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Enums.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace Aga.Controls.Tree { @@ -27,4 +29,12 @@ public enum IncrementalSearchMode None, Standard, Continuous } + [Flags] + public enum GridLineStyle + { + None = 0, + Horizontal = 1, + Vertical = 2, + HorizontalAndVertical = 3 + } } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/FixedRowHeightLayout.cs b/1.x/trunk/TreeViewAdv/Tree/FixedRowHeightLayout.cs similarity index 87% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/FixedRowHeightLayout.cs rename to 1.x/trunk/TreeViewAdv/Tree/FixedRowHeightLayout.cs index 49f799850..b43df6660 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/FixedRowHeightLayout.cs +++ b/1.x/trunk/TreeViewAdv/Tree/FixedRowHeightLayout.cs @@ -1,11 +1,13 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Drawing; namespace Aga.Controls.Tree { internal class FixedRowHeightLayout : IRowLayout { - private readonly TreeViewAdv _treeView; + private TreeViewAdv _treeView; public FixedRowHeightLayout(TreeViewAdv treeView, int rowHeight) { diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/IRowLayout.cs b/1.x/trunk/TreeViewAdv/Tree/IRowLayout.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/IRowLayout.cs rename to 1.x/trunk/TreeViewAdv/Tree/IRowLayout.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/IToolTipProvider.cs b/1.x/trunk/TreeViewAdv/Tree/IToolTipProvider.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/IToolTipProvider.cs rename to 1.x/trunk/TreeViewAdv/Tree/IToolTipProvider.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/ITreeModel.cs b/1.x/trunk/TreeViewAdv/Tree/ITreeModel.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/ITreeModel.cs rename to 1.x/trunk/TreeViewAdv/Tree/ITreeModel.cs diff --git a/1.x/trunk/TreeViewAdv/Tree/IncrementalSearch.cs b/1.x/trunk/TreeViewAdv/Tree/IncrementalSearch.cs new file mode 100644 index 000000000..4cee0cc63 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/IncrementalSearch.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Aga.Controls.Tree.NodeControls; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +namespace Aga.Controls.Tree +{ + internal class IncrementalSearch + { + private const int SearchTimeout = 300; //end of incremental search timeot in msec + + private TreeViewAdv _tree; + private TreeNodeAdv _currentNode; + private string _searchString = ""; + private DateTime _lastKeyPressed = DateTime.Now; + + public IncrementalSearch(TreeViewAdv tree) + { + _tree = tree; + } + + public void Search(Char value) + { + if (!Char.IsControl(value)) + { + Char ch = Char.ToLowerInvariant(value); + DateTime dt = DateTime.Now; + TimeSpan ts = dt - _lastKeyPressed; + _lastKeyPressed = dt; + if (ts.TotalMilliseconds < SearchTimeout) + { + if (_searchString == value.ToString()) + FirstCharSearch(ch); + else + ContinuousSearch(ch); + } + else + { + FirstCharSearch(ch); + } + } + } + + private void ContinuousSearch(Char value) + { + if (value == ' ' && String.IsNullOrEmpty(_searchString)) + return; //Ingnore leading space + + _searchString += value; + DoContinuousSearch(); + } + + private void FirstCharSearch(Char value) + { + if (value == ' ') + return; + + _searchString = value.ToString(); + TreeNodeAdv node = null; + if (_tree.SelectedNode != null) + node = _tree.SelectedNode.NextVisibleNode; + if (node == null) + node = _tree.Root; + + foreach (string label in IterateNodeLabels(node)) + { + if (label.StartsWith(_searchString)) + { + _tree.SelectedNode = _currentNode; + return; + } + } + } + + public virtual void EndSearch() + { + _currentNode = null; + _searchString = ""; + } + + protected IEnumerable IterateNodeLabels(TreeNodeAdv start) + { + _currentNode = start; + while(_currentNode != null) + { + foreach (string label in GetNodeLabels(_currentNode)) + yield return label; + + _currentNode = _currentNode.NextVisibleNode; + if (_currentNode == null) + _currentNode = _tree.Root; + + if (start == _currentNode) + break; + } + } + + private IEnumerable GetNodeLabels(TreeNodeAdv node) + { + foreach (NodeControl nc in _tree.NodeControls) + { + BindableControl bc = nc as BindableControl; + if (bc != null && bc.IncrementalSearchEnabled) + { + object obj = bc.GetValue(node); + if (obj != null) + yield return obj.ToString().ToLowerInvariant(); + } + } + } + + private bool DoContinuousSearch() + { + bool found = false; + if (!String.IsNullOrEmpty(_searchString)) + { + TreeNodeAdv node = null; + if (_tree.SelectedNode != null) + node = _tree.SelectedNode; + if (node == null) + node = _tree.Root.NextVisibleNode; + + if (!String.IsNullOrEmpty(_searchString)) + { + foreach (string label in IterateNodeLabels(node)) + { + if (label.StartsWith(_searchString)) + { + found = true; + _tree.SelectedNode = _currentNode; + break; + } + } + } + } + return found; + } + + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ClickColumnState.cs b/1.x/trunk/TreeViewAdv/Tree/Input/ClickColumnState.cs similarity index 72% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ClickColumnState.cs rename to 1.x/trunk/TreeViewAdv/Tree/Input/ClickColumnState.cs index cdc3bffe3..9fa19239a 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ClickColumnState.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Input/ClickColumnState.cs @@ -26,20 +26,20 @@ public override void MouseDown(TreeNodeAdvMouseEventArgs args) public override bool MouseMove(MouseEventArgs args) { - if (TreeViewAdv.Dist(_location, args.Location) > TreeViewAdv.ItemDragSensivity) + if (TreeViewAdv.Dist(_location, args.Location) > TreeViewAdv.ItemDragSensivity + && Tree.AllowColumnReorder) { - this.Tree.Input = new ReorderColumnState(this.Tree, this.Column, args.Location); - this.Tree.UpdateView(); + Tree.Input = new ReorderColumnState(Tree, Column, args.Location); + Tree.UpdateView(); } - return true; } public override void MouseUp(TreeNodeAdvMouseEventArgs args) { - this.Tree.ChangeInput(); - this.Tree.UpdateView(); - this.Tree.OnColumnClicked(this.Column); + Tree.ChangeInput(); + Tree.UpdateView(); + Tree.OnColumnClicked(Column); } } } diff --git a/1.x/trunk/TreeViewAdv/Tree/Input/ColumnState.cs b/1.x/trunk/TreeViewAdv/Tree/Input/ColumnState.cs new file mode 100644 index 000000000..10e064fb7 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/Input/ColumnState.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Aga.Controls.Tree +{ + internal abstract class ColumnState : InputState + { + private TreeColumn _column; + public TreeColumn Column + { + get { return _column; } + } + + public ColumnState(TreeViewAdv tree, TreeColumn column) + : base(tree) + { + _column = column; + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputState.cs b/1.x/trunk/TreeViewAdv/Tree/Input/InputState.cs similarity index 61% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputState.cs rename to 1.x/trunk/TreeViewAdv/Tree/Input/InputState.cs index b9d45d1cb..2d5ca2864 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputState.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Input/InputState.cs @@ -1,17 +1,22 @@ -using System.Windows.Forms; - +using System; +using System.Windows.Forms; namespace Aga.Controls.Tree { internal abstract class InputState { - public TreeViewAdv Tree { get; private set; } + private TreeViewAdv _tree; + + public TreeViewAdv Tree + { + get { return _tree; } + } - protected InputState(TreeViewAdv tree) + public InputState(TreeViewAdv tree) { - this.Tree = tree; + _tree = tree; } - public abstract void KeyDown(KeyEventArgs args); + public abstract void KeyDown(System.Windows.Forms.KeyEventArgs args); public abstract void MouseDown(TreeNodeAdvMouseEventArgs args); public abstract void MouseUp(TreeNodeAdvMouseEventArgs args); diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputWithControl.cs b/1.x/trunk/TreeViewAdv/Tree/Input/InputWithControl.cs similarity index 63% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputWithControl.cs rename to 1.x/trunk/TreeViewAdv/Tree/Input/InputWithControl.cs index 1f258fe93..94bd8571b 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputWithControl.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Input/InputWithControl.cs @@ -1,6 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + namespace Aga.Controls.Tree { - internal class InputWithControl : NormalInputState + internal class InputWithControl: NormalInputState { public InputWithControl(TreeViewAdv tree): base(tree) { @@ -8,14 +12,14 @@ public InputWithControl(TreeViewAdv tree): base(tree) protected override void DoMouseOperation(TreeNodeAdvMouseEventArgs args) { - if (this.Tree.SelectionMode == TreeSelectionMode.Single) + if (Tree.SelectionMode == TreeSelectionMode.Single) { base.DoMouseOperation(args); } else if (CanSelect(args.Node)) { args.Node.IsSelected = !args.Node.IsSelected; - this.Tree.SelectionStart = args.Node; + Tree.SelectionStart = args.Node; } } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputWithShift.cs b/1.x/trunk/TreeViewAdv/Tree/Input/InputWithShift.cs similarity index 53% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputWithShift.cs rename to 1.x/trunk/TreeViewAdv/Tree/Input/InputWithShift.cs index 2d98e3a9c..a5a7aa036 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/InputWithShift.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Input/InputWithShift.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; namespace Aga.Controls.Tree { @@ -10,40 +12,40 @@ public InputWithShift(TreeViewAdv tree): base(tree) protected override void FocusRow(TreeNodeAdv node) { - this.Tree.SuspendSelectionEvent = true; + Tree.SuspendSelectionEvent = true; try { - if (this.Tree.SelectionMode == TreeSelectionMode.Single || this.Tree.SelectionStart == null) + if (Tree.SelectionMode == TreeSelectionMode.Single || Tree.SelectionStart == null) base.FocusRow(node); else if (CanSelect(node)) { SelectAllFromStart(node); - this.Tree.CurrentNode = node; - this.Tree.ScrollTo(node); + Tree.CurrentNode = node; + Tree.ScrollTo(node); } } finally { - this.Tree.SuspendSelectionEvent = false; + Tree.SuspendSelectionEvent = false; } } protected override void DoMouseOperation(TreeNodeAdvMouseEventArgs args) { - if (this.Tree.SelectionMode == TreeSelectionMode.Single || this.Tree.SelectionStart == null) + if (Tree.SelectionMode == TreeSelectionMode.Single || Tree.SelectionStart == null) { base.DoMouseOperation(args); } else if (CanSelect(args.Node)) { - this.Tree.SuspendSelectionEvent = true; + Tree.SuspendSelectionEvent = true; try { SelectAllFromStart(args.Node); } finally { - this.Tree.SuspendSelectionEvent = false; + Tree.SuspendSelectionEvent = false; } } } @@ -54,13 +56,13 @@ protected override void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args) private void SelectAllFromStart(TreeNodeAdv node) { - this.Tree.ClearSelectionInternal(); + Tree.ClearSelectionInternal(); int a = node.Row; - int b = this.Tree.SelectionStart.Row; + int b = Tree.SelectionStart.Row; for (int i = Math.Min(a, b); i <= Math.Max(a, b); i++) { - if (this.Tree.SelectionMode == TreeSelectionMode.Multi || this.Tree.RowMap[i].Parent == node.Parent) - this.Tree.RowMap[i].IsSelected = true; + if (Tree.SelectionMode == TreeSelectionMode.Multi || Tree.RowMap[i].Parent == node.Parent) + Tree.RowMap[i].IsSelected = true; } } } diff --git a/1.x/trunk/TreeViewAdv/Tree/Input/NormalInputState.cs b/1.x/trunk/TreeViewAdv/Tree/Input/NormalInputState.cs new file mode 100644 index 000000000..30933c9e8 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/Input/NormalInputState.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Aga.Controls.Tree +{ + internal class NormalInputState : InputState + { + private bool _mouseDownFlag = false; + + public NormalInputState(TreeViewAdv tree) : base(tree) + { + } + + public override void KeyDown(KeyEventArgs args) + { + if (Tree.CurrentNode == null && Tree.Root.Nodes.Count > 0) + Tree.CurrentNode = Tree.Root.Nodes[0]; + + if (Tree.CurrentNode != null) + { + switch (args.KeyCode) + { + case Keys.Right: + if (!Tree.CurrentNode.IsExpanded) + { + Tree.CurrentNode.IsExpanded = true; + // by fliser + Tree.FullUpdate(); + } + else if (Tree.CurrentNode.Nodes.Count > 0) + Tree.SelectedNode = Tree.CurrentNode.Nodes[0]; + args.Handled = true; + break; + case Keys.Left: + if (Tree.CurrentNode.IsExpanded) + { + Tree.CurrentNode.IsExpanded = false; + // by fliser + Tree.FullUpdate(); + } + else if (Tree.CurrentNode.Parent != Tree.Root) + Tree.SelectedNode = Tree.CurrentNode.Parent; + args.Handled = true; + break; + case Keys.Down: + NavigateForward(1); + args.Handled = true; + break; + case Keys.Up: + NavigateBackward(1); + args.Handled = true; + break; + case Keys.PageDown: + NavigateForward(Math.Max(1, Tree.CurrentPageSize - 1)); + args.Handled = true; + break; + case Keys.PageUp: + NavigateBackward(Math.Max(1, Tree.CurrentPageSize - 1)); + args.Handled = true; + break; + case Keys.Home: + if (Tree.RowMap.Count > 0) + FocusRow(Tree.RowMap[0]); + args.Handled = true; + break; + case Keys.End: + if (Tree.RowMap.Count > 0) + FocusRow(Tree.RowMap[Tree.RowMap.Count-1]); + args.Handled = true; + break; + case Keys.Subtract: + Tree.CurrentNode.Collapse(); + // by fliser + Tree.FullUpdate(); + args.Handled = true; + args.SuppressKeyPress = true; + break; + case Keys.Add: + Tree.CurrentNode.Expand(); + // by fliser + Tree.FullUpdate(); + args.Handled = true; + args.SuppressKeyPress = true; + break; + case Keys.Multiply: + Tree.CurrentNode.ExpandAll(); + // by fliser + Tree.FullUpdate(); + args.Handled = true; + args.SuppressKeyPress = true; + break; + } + } + } + + public override void MouseDown(TreeNodeAdvMouseEventArgs args) + { + if (args.Node != null) + { + Tree.ItemDragMode = true; + Tree.ItemDragStart = args.Location; + + if (args.Button == MouseButtons.Left || args.Button == MouseButtons.Right) + { + Tree.BeginUpdate(); + try + { + Tree.CurrentNode = args.Node; + if (args.Node.IsSelected) + _mouseDownFlag = true; + else + { + _mouseDownFlag = false; + DoMouseOperation(args); + } + } + finally + { + Tree.EndUpdate(); + } + } + + } + else + { + Tree.ItemDragMode = false; + MouseDownAtEmptySpace(args); + } + } + + public override void MouseUp(TreeNodeAdvMouseEventArgs args) + { + Tree.ItemDragMode = false; + if (_mouseDownFlag) + { + if (args.Button == MouseButtons.Left) + DoMouseOperation(args); + else if (args.Button == MouseButtons.Right) + Tree.CurrentNode = args.Node; + } + _mouseDownFlag = false; + } + + + private void NavigateBackward(int n) + { + int row = Math.Max(Tree.CurrentNode.Row - n, 0); + if (row != Tree.CurrentNode.Row) + FocusRow(Tree.RowMap[row]); + } + + private void NavigateForward(int n) + { + int row = Math.Min(Tree.CurrentNode.Row + n, Tree.RowCount - 1); + if (row != Tree.CurrentNode.Row) + FocusRow(Tree.RowMap[row]); + } + + protected virtual void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args) + { + Tree.ClearSelectionInternal(); + } + + protected virtual void FocusRow(TreeNodeAdv node) + { + Tree.SuspendSelectionEvent = true; + try + { + Tree.ClearSelectionInternal(); + Tree.CurrentNode = node; + Tree.SelectionStart = node; + node.IsSelected = true; + Tree.ScrollTo(node); + } + finally + { + Tree.SuspendSelectionEvent = false; + } + } + + protected bool CanSelect(TreeNodeAdv node) + { + if (Tree.SelectionMode == TreeSelectionMode.MultiSameParent) + { + return (Tree.SelectionStart == null || node.Parent == Tree.SelectionStart.Parent); + } + else + return true; + } + + protected virtual void DoMouseOperation(TreeNodeAdvMouseEventArgs args) + { + Tree.SuspendSelectionEvent = true; + try + { + Tree.ClearSelectionInternal(); + if (args.Node != null) + args.Node.IsSelected = true; + Tree.SelectionStart = args.Node; + } + finally + { + Tree.SuspendSelectionEvent = false; + } + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ReorderColumnState.cs b/1.x/trunk/TreeViewAdv/Tree/Input/ReorderColumnState.cs similarity index 72% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ReorderColumnState.cs rename to 1.x/trunk/TreeViewAdv/Tree/Input/ReorderColumnState.cs index 22b3cceb9..2fe445f1f 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ReorderColumnState.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Input/ReorderColumnState.cs @@ -39,7 +39,7 @@ public int DragOffset public ReorderColumnState(TreeViewAdv tree, TreeColumn column, Point initialMouseLocation) : base(tree, column) { - _location = new Point(initialMouseLocation.X + this.Tree.OffsetX, 0); + _location = new Point(initialMouseLocation.X + Tree.OffsetX, 0); _dragOffset = tree.GetColumnX(column) - initialMouseLocation.X; _ghostImage = column.CreateGhostImage(new Rectangle(0, 0, column.Width, tree.ColumnHeaderHeight), tree.Font); } @@ -63,9 +63,9 @@ public override void MouseUp(TreeNodeAdvMouseEventArgs args) public override bool MouseMove(MouseEventArgs args) { _dropColumn = null; - _location = new Point(args.X + this.Tree.OffsetX, 0); + _location = new Point(args.X + Tree.OffsetX, 0); int x = 0; - foreach (TreeColumn c in this.Tree.Columns) + foreach (TreeColumn c in Tree.Columns) { if (c.IsVisible) { @@ -77,24 +77,24 @@ public override bool MouseMove(MouseEventArgs args) x += c.Width; } } - this.Tree.UpdateHeaders(); + Tree.UpdateHeaders(); return true; } private void FinishResize() { - this.Tree.ChangeInput(); - if (this.Column == DropColumn) - this.Tree.UpdateView(); + Tree.ChangeInput(); + if (Column == DropColumn) + Tree.UpdateView(); else { - this.Tree.Columns.Remove(this.Column); + Tree.Columns.Remove(Column); if (DropColumn == null) - this.Tree.Columns.Add(this.Column); + Tree.Columns.Add(Column); else - this.Tree.Columns.Insert(this.Tree.Columns.IndexOf(DropColumn), this.Column); + Tree.Columns.Insert(Tree.Columns.IndexOf(DropColumn), Column); - this.Tree.OnColumnReordered(this.Column); + Tree.OnColumnReordered(Column); } } } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ResizeColumnState.cs b/1.x/trunk/TreeViewAdv/Tree/Input/ResizeColumnState.cs similarity index 75% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ResizeColumnState.cs rename to 1.x/trunk/TreeViewAdv/Tree/Input/ResizeColumnState.cs index 46218276c..486ed3d39 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Input/ResizeColumnState.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Input/ResizeColumnState.cs @@ -37,16 +37,16 @@ public override void MouseUp(TreeNodeAdvMouseEventArgs args) private void FinishResize() { - this.Tree.ChangeInput(); - this.Tree.FullUpdate(); - this.Tree.OnColumnWidthChanged(this.Column); + Tree.ChangeInput(); + Tree.FullUpdate(); + Tree.OnColumnWidthChanged(Column); } public override bool MouseMove(MouseEventArgs args) { - this.Column.Width = _initWidth + args.Location.X - _initLocation.X; - this.Tree.UpdateView(); - this.Tree.Invalidate(); + Column.Width = _initWidth + args.Location.X - _initLocation.X; + Tree.UpdateView(); + Tree.Invalidate(); return true; } } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Node.cs b/1.x/trunk/TreeViewAdv/Tree/Node.cs similarity index 75% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Node.cs rename to 1.x/trunk/TreeViewAdv/Tree/Node.cs index fbb90fcee..a00a7fe9b 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/Node.cs +++ b/1.x/trunk/TreeViewAdv/Tree/Node.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Collections.ObjectModel; using System.Windows.Forms; using System.Drawing; @@ -9,7 +11,7 @@ public class Node { #region NodeCollection - public class NodeCollection : Collection + private class NodeCollection : Collection { private Node _owner; @@ -73,11 +75,20 @@ protected override void SetItem(int index, Node item) #region Properties - internal TreeModel Model { get; set; } + private TreeModel _model; + internal TreeModel Model + { + get { return _model; } + set { _model = value; } + } - public NodeCollection Nodes { get; private set; } + private NodeCollection _nodes; + public Collection Nodes + { + get { return _nodes; } + } - private Node _parent; + private Node _parent; public Node Parent { get { return _parent; } @@ -97,19 +108,21 @@ public Node Parent private int _index = -1; public int Index { - get { return _index; } + get + { + return _index; + } } public Node PreviousNode { get { - int index = this.Index; - - if (index > 0) + int index = Index; + if (index > 0) return _parent.Nodes[index - 1]; - - return null; + else + return null; } } @@ -118,11 +131,10 @@ public Node NextNode get { int index = Index; - if (index >= 0 && index < _parent.Nodes.Count - 1) return _parent.Nodes[index + 1]; - - return null; + else + return null; } } @@ -168,9 +180,14 @@ public Image Image } } - public object Tag { get; set; } + private object _tag; + public object Tag + { + get { return _tag; } + set { _tag = value; } + } - public bool IsChecked + public bool IsChecked { get { @@ -187,7 +204,10 @@ public bool IsChecked public virtual bool IsLeaf { - get { return false; } + get + { + return false; + } } #endregion @@ -200,7 +220,7 @@ public Node() public Node(string text) { _text = text; - this.Nodes = new NodeCollection(this); + _nodes = new NodeCollection(this); } public override string ToString() @@ -211,29 +231,25 @@ public override string ToString() public TreeModel FindModel() { Node node = this; - while (node != null) { if (node.Model != null) return node.Model; - node = node.Parent; } - return null; } protected void NotifyModel() { TreeModel model = FindModel(); - if (model != null && Parent != null) { TreePath path = model.GetPath(Parent); - - if (path != null) + if (path != null) { - model.OnNodesChanged(new TreeModelEventArgs(path, new int[] { Index }, new object[] { this })); + TreeModelEventArgs args = new TreeModelEventArgs(path, new int[] { Index }, new object[] { this }); + model.OnNodesChanged(args); } } } diff --git a/1.x/trunk/TreeViewAdv/Tree/NodeControlInfo.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControlInfo.cs new file mode 100644 index 000000000..db9d68470 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControlInfo.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Aga.Controls.Tree.NodeControls; +using System.Drawing; + +namespace Aga.Controls.Tree +{ + public struct NodeControlInfo + { + public static readonly NodeControlInfo Empty = new NodeControlInfo(null, Rectangle.Empty, null); + + private NodeControl _control; + public NodeControl Control + { + get { return _control; } + } + + private Rectangle _bounds; + public Rectangle Bounds + { + get { return _bounds; } + } + + private TreeNodeAdv _node; + public TreeNodeAdv Node + { + get { return _node; } + } + + public NodeControlInfo(NodeControl control, Rectangle bounds, TreeNodeAdv node) + { + _control = control; + _bounds = bounds; + _node = node; + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/BaseTextControl.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/BaseTextControl.cs similarity index 52% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/BaseTextControl.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/BaseTextControl.cs index db2004d7d..dda18cf8d 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/BaseTextControl.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/BaseTextControl.cs @@ -4,27 +4,40 @@ using System; using System.Collections.Generic; +using System.Text; using System.Drawing; using System.Windows.Forms; +using System.Reflection; using System.ComponentModel; -using ProcessHacker.Common; namespace Aga.Controls.Tree.NodeControls { public abstract class BaseTextControl : EditableControl { - private readonly TextFormatFlags _baseFormatFlags; + private TextFormatFlags _baseFormatFlags; private TextFormatFlags _formatFlags; - private readonly Pen _focusPen; - private readonly StringFormat _format; + private Pen _focusPen; + private StringFormat _format; #region Properties - private Font _font; + private Font _font = null; public Font Font { - get { return this._font ?? Control.DefaultFont; } - set { this._font = value == Control.DefaultFont ? null : value; } + get + { + if (_font == null) + return Control.DefaultFont; + else + return _font; + } + set + { + if (value == Control.DefaultFont) + _font = null; + else + _font = value; + } } protected bool ShouldSerializeFont() @@ -64,22 +77,25 @@ public bool DisplayHiddenContentInToolTip set { _displayHiddenContentInToolTip = value; } } - [DefaultValue(false)] - public bool UseCompatibleTextRendering { get; set; } + private bool _useCompatibleTextRendering = false; + [DefaultValue(false)] + public bool UseCompatibleTextRendering + { + get { return _useCompatibleTextRendering; } + set { _useCompatibleTextRendering = value; } + } - #endregion + #endregion protected BaseTextControl() { - this.IncrementalSearchEnabled = true; + IncrementalSearchEnabled = true; + _focusPen = new Pen(Color.Black); + _focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; - _focusPen = new Pen(Color.Black) - { - DashStyle = System.Drawing.Drawing2D.DashStyle.Dot - }; - - _format = new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.FitBlackBox | StringFormatFlags.MeasureTrailingSpaces); - _baseFormatFlags = TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.NoPrefix | TextFormatFlags.PreserveGraphicsTranslateTransform; + _format = new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.FitBlackBox | StringFormatFlags.MeasureTrailingSpaces); + _baseFormatFlags = TextFormatFlags.PreserveGraphicsClipping | TextFormatFlags.NoPrefix | + TextFormatFlags.PreserveGraphicsTranslateTransform; SetFormatFlags(); LeftMargin = 3; } @@ -89,7 +105,8 @@ private void SetFormatFlags() _format.Alignment = TextHelper.TranslateAligment(TextAlign); _format.Trimming = Trimming; - _formatFlags = _baseFormatFlags | TextHelper.TranslateAligmentToFlag(TextAlign)| TextHelper.TranslateTrimmingToFlag(Trimming); + _formatFlags = _baseFormatFlags | TextHelper.TranslateAligmentToFlag(TextAlign) + | TextHelper.TranslateTrimmingToFlag(Trimming); } public override Size MeasureSize(TreeNodeAdv node, DrawContext context) @@ -104,44 +121,45 @@ protected Size GetLabelSize(TreeNodeAdv node, DrawContext context) protected Size GetLabelSize(TreeNodeAdv node, DrawContext context, string label) { + CheckThread(); Font font = GetDrawingFont(node, context, label); + Size s = Size.Empty; + + if (!UseCompatibleTextRendering) + { + SizeF sf = context.Graphics.MeasureString(label, font); + s = Size.Ceiling(sf); + } + else + { + s = TextRenderer.MeasureText(label, font); + } - Size s = context.Graphics.GetCachedSize(label, font); - if (!s.IsEmpty) return s; - - return new Size(10, this.Font.Height); + else + return new Size(10, Font.Height); } protected Font GetDrawingFont(TreeNodeAdv node, DrawContext context, string label) { Font font = context.Font; - - if (this.DrawText != null) + if (DrawText != null) { - DrawEventArgs args = new DrawEventArgs(node, context, label) - { - Font = context.Font - }; - - OnDrawText(args); + DrawEventArgs args = new DrawEventArgs(node, context, label); + args.Font = context.Font; + OnDrawText(args); font = args.Font; } - return font; } protected void SetEditControlProperties(Control control, TreeNodeAdv node) { string label = GetLabel(node); - - DrawContext context = new DrawContext - { - Font = control.Font - }; - - control.Font = GetDrawingFont(node, context, label); + DrawContext context = new DrawContext(); + context.Font = control.Font; + control.Font = GetDrawingFont(node, context, label); } public override void Draw(TreeNodeAdv node, DrawContext context) @@ -150,59 +168,45 @@ public override void Draw(TreeNodeAdv node, DrawContext context) return; string label = GetLabel(node); - Rectangle bounds = GetBounds(node, context); - Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y, bounds.Width, context.Bounds.Height); + Rectangle focusRect = new Rectangle(bounds.X, context.Bounds.Y, + bounds.Width, context.Bounds.Height); Brush backgroundBrush; Color textColor; Font font; - CreateBrushes(node, context, label, out backgroundBrush, out textColor, out font, ref label); - if (backgroundBrush != null) - { - context.Graphics.FillRectangle(backgroundBrush, focusRect); - } - - if (context.DrawFocus) + if (backgroundBrush != null) + context.Graphics.FillRectangle(backgroundBrush, focusRect); + if (context.DrawFocus) { focusRect.Width--; focusRect.Height--; - - //switch (context.DrawSelection) - //{ - // case DrawSelectionMode.None: - // this._focusPen.Color = SystemColors.ControlText; - // break; - // default: - // this._focusPen.Color = SystemColors.InactiveCaption; - // break; - //} - + if (context.DrawSelection == DrawSelectionMode.None) + _focusPen.Color = SystemColors.ControlText; + else + _focusPen.Color = SystemColors.InactiveCaption; context.Graphics.DrawRectangle(_focusPen, focusRect); } - if (!this.UseCompatibleTextRendering) - { + if (!UseCompatibleTextRendering) context.Graphics.DrawString(label, font, GetFrush(textColor), bounds, _format); - } else - { TextRenderer.DrawText(context.Graphics, label, font, bounds, textColor, _formatFlags); - } } private static Dictionary _brushes = new Dictionary(); private static Brush GetFrush(Color color) { - if (_brushes.ContainsKey(color)) - return _brushes[color]; - - Brush br = new SolidBrush(color); - - _brushes.Add(color, br); - - return br; + Brush br; + if (_brushes.ContainsKey(color)) + br = _brushes[color]; + else + { + br = new SolidBrush(color); + _brushes.Add(color, br); + } + return br; } private void CreateBrushes(TreeNodeAdv node, DrawContext context, string text, out Brush backgroundBrush, out Color textColor, out Font font, ref string label) @@ -214,62 +218,50 @@ private void CreateBrushes(TreeNodeAdv node, DrawContext context, string text, o backgroundBrush = null; font = context.Font; - switch (context.DrawSelection) + if (context.DrawSelection == DrawSelectionMode.Active) { - case DrawSelectionMode.Active: - { - //textColor = SystemColors.HighlightText; - //backgroundBrush = SystemBrushes.Highlight; - break; - } - case DrawSelectionMode.Inactive: - { - //textColor = SystemColors.ControlText; - //backgroundBrush = SystemBrushes.InactiveBorder; - break; - } - case DrawSelectionMode.FullRowSelect: - { - //textColor = SystemColors.HighlightText; - break; - } + textColor = SystemColors.HighlightText; + backgroundBrush = SystemBrushes.Highlight; } + else if (context.DrawSelection == DrawSelectionMode.Inactive) + { + textColor = SystemColors.ControlText; + backgroundBrush = SystemBrushes.InactiveBorder; + } + else if (context.DrawSelection == DrawSelectionMode.FullRowSelect) + textColor = SystemColors.HighlightText; - //if (!context.Enabled) - //textColor = SystemColors.GrayText; + if (!context.Enabled) + textColor = SystemColors.GrayText; - if (this.DrawText != null) + if (DrawText != null) { - //DrawEventArgs args = new DrawEventArgs(node, context, text) - //{ - // TextColor = textColor, - // BackgroundBrush = backgroundBrush, - // Font = font - //}; - - //OnDrawText(args); - - //textColor = args.TextColor; - //backgroundBrush = args.BackgroundBrush; - //font = args.Font; - //label = args.Text; + DrawEventArgs args = new DrawEventArgs(node, context, text); + args.TextColor = textColor; + args.BackgroundBrush = backgroundBrush; + args.Font = font; + + OnDrawText(args); + + textColor = args.TextColor; + backgroundBrush = args.BackgroundBrush; + font = args.Font; + label = args.Text; } } public string GetLabel(TreeNodeAdv node) { - if (node != null && node.Tag != null) - { - object obj = GetValue(node); - - if (obj != null) - return FormatLabel(obj); - } - - return string.Empty; + if (node != null && node.Tag != null) + { + object obj = GetValue(node); + if (obj != null) + return FormatLabel(obj); + } + return string.Empty; } - protected virtual string FormatLabel(object obj) + protected virtual string FormatLabel(object obj) { return obj.ToString(); } @@ -282,7 +274,6 @@ public void SetLabel(TreeNodeAdv node, string value) protected override void Dispose(bool disposing) { base.Dispose(disposing); - if (disposing) { _focusPen.Dispose(); diff --git a/1.x/trunk/TreeViewAdv/Tree/NodeControls/BindableControl.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/BindableControl.cs new file mode 100644 index 000000000..043a0d296 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/BindableControl.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using System.ComponentModel; + +namespace Aga.Controls.Tree.NodeControls +{ + public abstract class BindableControl : NodeControl + { + private struct MemberAdapter + { + private object _obj; + private PropertyInfo _pi; + private FieldInfo _fi; + + public static readonly MemberAdapter Empty = new MemberAdapter(); + + public Type MemberType + { + get + { + if (_pi != null) + return _pi.PropertyType; + else if (_fi != null) + return _fi.FieldType; + else + return null; + } + } + + public object Value + { + get + { + if (_pi != null && _pi.CanRead) + return _pi.GetValue(_obj, null); + else if (_fi != null) + return _fi.GetValue(_obj); + else + return null; + } + set + { + if (_pi != null && _pi.CanWrite) + _pi.SetValue(_obj, value, null); + else if (_fi != null) + _fi.SetValue(_obj, value); + } + } + + public MemberAdapter(object obj, PropertyInfo pi) + { + _obj = obj; + _pi = pi; + _fi = null; + } + + public MemberAdapter(object obj, FieldInfo fi) + { + _obj = obj; + _fi = fi; + _pi = null; + } + } + + #region Properties + + private bool _virtualMode = false; + [DefaultValue(false), Category("Data")] + public bool VirtualMode + { + get { return _virtualMode; } + set { _virtualMode = value; } + } + + private string _propertyName = ""; + [DefaultValue(""), Category("Data")] + public string DataPropertyName + { + get { return _propertyName; } + set { _propertyName = value != null ? value : ""; } + } + + private bool _incrementalSearchEnabled = false; + [DefaultValue(false)] + public bool IncrementalSearchEnabled + { + get { return _incrementalSearchEnabled; } + set { _incrementalSearchEnabled = value; } + } + + #endregion + + public virtual object GetValue(TreeNodeAdv node) + { + if (VirtualMode) + { + NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); + OnValueNeeded(args); + return args.Value; + } + else + { + try + { + return GetMemberAdapter(node).Value; + } + catch (TargetInvocationException ex) + { + if (ex.InnerException != null) + throw new ArgumentException(ex.InnerException.Message, ex.InnerException); + else + throw new ArgumentException(ex.Message); + } + } + } + + public virtual void SetValue(TreeNodeAdv node, object value) + { + if (VirtualMode) + { + NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); + args.Value = value; + OnValuePushed(args); + } + else + { + try + { + MemberAdapter ma = GetMemberAdapter(node); + ma.Value = value; + } + catch (TargetInvocationException ex) + { + if (ex.InnerException != null) + throw new ArgumentException(ex.InnerException.Message, ex.InnerException); + else + throw new ArgumentException(ex.Message); + } + } + } + + public Type GetPropertyType(TreeNodeAdv node) + { + return GetMemberAdapter(node).MemberType; + } + + private MemberAdapter GetMemberAdapter(TreeNodeAdv node) + { + MemberAdapter adapter = MemberAdapter.Empty; + + if (node.Tag != null && !string.IsNullOrEmpty(DataPropertyName)) + { + Type type = node.Tag.GetType(); + PropertyInfo pi = type.GetProperty(DataPropertyName); + + if (pi != null) + { + return new MemberAdapter(node.Tag, pi); + } + else + { + FieldInfo fi = type.GetField(DataPropertyName, + BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + if (fi != null) + return new MemberAdapter(node.Tag, fi); + } + } + + return adapter; + } + + public override string ToString() + { + if (string.IsNullOrEmpty(DataPropertyName)) + return GetType().Name; + else + return string.Format("{0} ({1})", GetType().Name, DataPropertyName); + } + + public event EventHandler ValueNeeded; + private void OnValueNeeded(NodeControlValueEventArgs args) + { + if (ValueNeeded != null) + ValueNeeded(this, args); + } + + public event EventHandler ValuePushed; + private void OnValuePushed(NodeControlValueEventArgs args) + { + if (ValuePushed != null) + ValuePushed(this, args); + } + } +} diff --git a/1.x/trunk/TreeViewAdv/Tree/NodeControls/ClassDiagram.cd b/1.x/trunk/TreeViewAdv/Tree/NodeControls/ClassDiagram.cd new file mode 100644 index 000000000..437ad6dbb --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/ClassDiagram.cd @@ -0,0 +1,105 @@ + + + + + + + Tree\NodeControls\NodeStateIcon.cs + ABAAAAAAAAQAQAAAAAAAAAAAAAAAAAAAQIAAAAAAAAA= + + + + + + Tree\NodeControls\BindableControl.cs + FAAAAAAQIBAQCgAEAAAAIAAAAAAAAAEMAAACAAAAAAE= + + + + + + Tree\NodeControls\NodeCheckBox.cs + AAEAAAAAAAACgkQCAAAAAAigAgAAEGABAAAIAAAAAAA= + + + + + + Tree\NodeControls\NodeControl.cs + AAAAAJAAgIgBkkoQAAgAQAAwAAABEIQAAEBIAAAAAAA= + + + + + + + + + Tree\NodeControls\NodeIcon.cs + ABAAAAAAAAAAAgAAAAAAAAAgAAAAAAAAAAAAAAAAAAA= + + + + + + Tree\NodeControls\NodePlusMinus.cs + AAAAAAAAAAAAAgAAAAAAAEAgAAAAMCAAAAAIACAAAAA= + + + + + + Tree\NodeControls\BaseTextControl.cs + AAAAICBQACAAIgACBCAEAQA8AgmFoAAwAAAAACACAMA= + + + + + + Tree\NodeControls\NodeTextBox.cs + QQQAhAAAADAMgAAAABAAAAAAAgEAIAAAAAAAAIAAAAA= + + + + + + Tree\NodeControls\EditableControl.cs + QQAgAAAACGgkAMAABAEEkADAEAAUEAAABAGoAAAAAQA= + + + + + + Tree\NodeControls\NodeComboBox.cs + wQACAAAAAAAMAEBAAAAAAABAAAAAAAABAAAAAAAAAAA= + + + + + + Tree\NodeControls\NodeNumericUpDown.cs + wQAAAACAAAAEAABAIAAQIAAAAAAAAAABAAAIAAAAAII= + + + + + + Tree\NodeControls\InteractiveControl.cs + AAAABAAAAAAAAAAACAAAAAAAABAAAQAAAAAAAAIAAAA= + + + + + + Tree\NodeControls\NodeDecimalTextBox.cs + AQAAAAAAAACAAAACAAAAAAQAAAAAIAAAAAgAAAAAAAA= + + + + + + Tree\NodeControls\NodeIntegerTextBox.cs + AQAAAAAAAAAAAAACAAAAAAQAAAAAIAAAAAAAAAAAAAA= + + + \ No newline at end of file diff --git a/1.x/trunk/TreeViewAdv/Tree/NodeControls/DrawEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/DrawEventArgs.cs new file mode 100644 index 000000000..56b24bc61 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/DrawEventArgs.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; + +namespace Aga.Controls.Tree.NodeControls +{ + public class DrawEventArgs : NodeEventArgs + { + private DrawContext _context; + public DrawContext Context + { + get { return _context; } + } + + private Brush _textBrush; + [Obsolete("Use TextColor")] + public Brush TextBrush + { + get { return _textBrush; } + set { _textBrush = value; } + } + + private Brush _backgroundBrush; + public Brush BackgroundBrush + { + get { return _backgroundBrush; } + set { _backgroundBrush = value; } + } + + private Font _font; + public Font Font + { + get { return _font; } + set { _font = value; } + } + + private Color _textColor; + public Color TextColor + { + get { return _textColor; } + set { _textColor = value; } + } + + private string _text; + public string Text + { + get { return _text; } + } + + public DrawEventArgs(TreeNodeAdv node, DrawContext context, string text) + : base(node) + { + _context = context; + _text = text; + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/EditableControl.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/EditableControl.cs similarity index 63% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/EditableControl.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/EditableControl.cs index ae3bc0b86..cbed3db22 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/EditableControl.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/EditableControl.cs @@ -14,38 +14,48 @@ public abstract class EditableControl : InteractiveControl #region Properties - protected TreeNodeAdv EditNode { get; private set; } - protected Control CurrentEditor { get; private set; } + private TreeNodeAdv _editNode; + protected TreeNodeAdv EditNode + { + get { return _editNode; } + } - [DefaultValue(false)] - public bool EditOnClick { get; set; } + private Control _editor; + protected Control CurrentEditor + { + get { return _editor; } + } - #endregion + private bool _editOnClick = false; + [DefaultValue(false)] + public bool EditOnClick + { + get { return _editOnClick; } + set { _editOnClick = value; } + } + + #endregion protected EditableControl() { - _timer = new Timer - { - Interval = 1000 - }; - - _timer.Tick += this.TimerTick; + _timer = new Timer(); + _timer.Interval = 1000; + _timer.Tick += new EventHandler(TimerTick); } private void TimerTick(object sender, EventArgs e) { _timer.Stop(); - if (_editFlag) BeginEditByUser(); - - _editFlag = false; + _editFlag = false; } public void SetEditorBounds(EditorContext context) { Size size = CalculateEditorSize(context); - context.Editor.Bounds = new Rectangle(context.Bounds.X, context.Bounds.Y, Math.Min(size.Width, context.Bounds.Width), context.Bounds.Height); + context.Editor.Bounds = new Rectangle(context.Bounds.X, context.Bounds.Y, + Math.Min(size.Width, context.Bounds.Width), context.Bounds.Height); } protected abstract Size CalculateEditorSize(EditorContext context); @@ -67,49 +77,43 @@ public void BeginEdit() { CancelEventArgs args = new CancelEventArgs(); OnEditorShowing(args); - if (!args.Cancel) { - this.CurrentEditor = CreateEditor(Parent.CurrentNode); - this.CurrentEditor.Validating += this.EditorValidating; - this.CurrentEditor.KeyDown += this.EditorKeyDown; - this.EditNode = Parent.CurrentNode; - Parent.DisplayEditor(this.CurrentEditor, this); + _editor = CreateEditor(Parent.CurrentNode); + _editor.Validating += new CancelEventHandler(EditorValidating); + _editor.KeyDown += new KeyEventHandler(EditorKeyDown); + _editNode = Parent.CurrentNode; + Parent.DisplayEditor(_editor, this); } } } private void EditorKeyDown(object sender, KeyEventArgs e) { - switch (e.KeyCode) - { - case Keys.Escape: - this.EndEdit(false); - break; - case Keys.Enter: - this.EndEdit(true); - break; - } + if (e.KeyCode == Keys.Escape) + EndEdit(false); + else if (e.KeyCode == Keys.Enter) + EndEdit(true); } - private void EditorValidating(object sender, CancelEventArgs e) + private void EditorValidating(object sender, CancelEventArgs e) { ApplyChanges(); } internal void HideEditor(Control editor) { - editor.Validating -= this.EditorValidating; + editor.Validating -= new CancelEventHandler(EditorValidating); editor.Parent = null; editor.Dispose(); - this.EditNode = null; + _editNode = null; OnEditorHided(); } public void EndEdit(bool applyChanges) { if (!applyChanges) - this.CurrentEditor.Validating -= this.EditorValidating; + _editor.Validating -= new CancelEventHandler(EditorValidating); Parent.Focus(); } @@ -121,7 +125,7 @@ public virtual void ApplyChanges() { try { - DoApplyChanges(this.EditNode, this.CurrentEditor); + DoApplyChanges(_editNode, _editor); } catch (ArgumentException ex) { @@ -135,14 +139,15 @@ public virtual void ApplyChanges() public override void MouseDown(TreeNodeAdvMouseEventArgs args) { - _editFlag = (!this.EditOnClick && args.Button == MouseButtons.Left + _editFlag = (!EditOnClick && args.Button == MouseButtons.Left && args.ModifierKeys == Keys.None && args.Node.IsSelected); } public override void MouseUp(TreeNodeAdvMouseEventArgs args) { - if (this.EditOnClick && args.Button == MouseButtons.Left && args.ModifierKeys == Keys.None) + if (EditOnClick && args.Button == MouseButtons.Left && args.ModifierKeys == Keys.None) { + Parent.ItemDragMode = false; BeginEdit(); args.Handled = true; } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/ExpandingIcon.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/ExpandingIcon.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/ExpandingIcon.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/ExpandingIcon.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/InteractiveControl.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/InteractiveControl.cs similarity index 75% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/InteractiveControl.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/InteractiveControl.cs index 502d004a5..d418f3615 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/InteractiveControl.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/InteractiveControl.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.ComponentModel; namespace Aga.Controls.Tree.NodeControls @@ -17,17 +19,13 @@ protected bool IsEditEnabled(TreeNodeAdv node) { if (EditEnabled) { - NodeControlValueEventArgs args = new NodeControlValueEventArgs(node) - { - Value = true - }; - - OnIsEditEnabledValueNeeded(args); - - return (bool)args.Value; + NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); + args.Value = true; + OnIsEditEnabledValueNeeded(args); + return Convert.ToBoolean(args.Value); } - - return false; + else + return false; } public event EventHandler IsEditEnabledValueNeeded; diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeCheckBox.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeCheckBox.cs similarity index 73% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeCheckBox.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeCheckBox.cs index 26719f05b..311cf5dd2 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeCheckBox.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeCheckBox.cs @@ -1,27 +1,34 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Drawing; +using Aga.Controls.Properties; +using System.Reflection; using System.Windows.Forms; using System.Windows.Forms.VisualStyles; using System.ComponentModel; -using ProcessHacker.Properties; - namespace Aga.Controls.Tree.NodeControls { public class NodeCheckBox : InteractiveControl { public const int ImageSize = 13; - private readonly Bitmap _check; - private readonly Bitmap _uncheck; - private readonly Bitmap _unknown; + private Bitmap _check; + private Bitmap _uncheck; + private Bitmap _unknown; #region Properties - [DefaultValue(false)] - public bool ThreeState { get; set; } + private bool _threeState; + [DefaultValue(false)] + public bool ThreeState + { + get { return _threeState; } + set { _threeState = value; } + } - #endregion + #endregion public NodeCheckBox() : this(string.Empty) @@ -72,17 +79,16 @@ public override void Draw(TreeNodeAdv node, DrawContext context) protected virtual CheckState GetCheckState(TreeNodeAdv node) { - object obj = GetValue(node); - - if (obj is CheckState) - return (CheckState)obj; - else if (obj is bool) - return (bool)obj ? CheckState.Checked : CheckState.Unchecked; - - return CheckState.Unchecked; + object obj = GetValue(node); + if (obj is CheckState) + return (CheckState)obj; + else if (obj is bool) + return (bool)obj ? CheckState.Checked : CheckState.Unchecked; + else + return CheckState.Unchecked; } - protected virtual void SetCheckState(TreeNodeAdv node, CheckState value) + protected virtual void SetCheckState(TreeNodeAdv node, CheckState value) { if (VirtualMode) { @@ -109,13 +115,9 @@ public override void MouseDown(TreeNodeAdvMouseEventArgs args) { if (args.Button == MouseButtons.Left && IsEditEnabled(args.Node)) { - DrawContext context = new DrawContext - { - Bounds = args.ControlBounds - }; - - Rectangle rect = GetBounds(args.Node, context); - + DrawContext context = new DrawContext(); + context.Bounds = args.ControlBounds; + Rectangle rect = GetBounds(args.Node, context); if (rect.Contains(args.ViewLocation)) { CheckState state = GetCheckState(args.Node); @@ -134,18 +136,15 @@ public override void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) private CheckState GetNewState(CheckState state) { - switch (state) - { - case CheckState.Indeterminate: - return CheckState.Unchecked; - case CheckState.Unchecked: - return CheckState.Checked; - default: - return this.ThreeState ? CheckState.Indeterminate : CheckState.Unchecked; - } + if (state == CheckState.Indeterminate) + return CheckState.Unchecked; + else if(state == CheckState.Unchecked) + return CheckState.Checked; + else + return ThreeState ? CheckState.Indeterminate : CheckState.Unchecked; } - public override void KeyDown(KeyEventArgs args) + public override void KeyDown(KeyEventArgs args) { if (args.KeyCode == Keys.Space && EditEnabled) { diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeComboBox.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeComboBox.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeComboBox.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeComboBox.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControl.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControl.cs similarity index 69% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControl.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControl.cs index e70a0b255..4fe4732e1 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControl.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControl.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Windows.Forms; using System.Drawing; using System.ComponentModel; @@ -62,7 +64,7 @@ public VerticalAlignment VerticalAlign } } - private int _leftMargin; + private int _leftMargin = 0; public int LeftMargin { get { return _leftMargin; } @@ -97,31 +99,36 @@ private void parent_ColumnWidthChanged(object sender, TreeColumnEventArgs e) protected virtual Rectangle GetBounds(TreeNodeAdv node, DrawContext context) { Rectangle r = context.Bounds; - - Size s = GetActualSize(node, context); - - Size bs = new Size(r.Width - LeftMargin, Math.Min(r.Height, s.Height)); - - switch (this.VerticalAlign) + Size s = GetActualSize(node, context); + Size bs = new Size(r.Width - LeftMargin, Math.Min(r.Height, s.Height)); + switch (VerticalAlign) { - case VerticalAlignment.Top: - { - return new Rectangle(new Point(r.X + LeftMargin, r.Y), bs); - } - case VerticalAlignment.Bottom: - { - return new Rectangle(new Point(r.X + LeftMargin, r.Bottom - s.Height), bs); - } - default: - { - return new Rectangle(new Point(r.X + LeftMargin, r.Y + (r.Height - s.Height)/2), bs); - } + case VerticalAlignment.Top: + return new Rectangle(new Point(r.X + LeftMargin, r.Y), bs); + case VerticalAlignment.Bottom: + return new Rectangle(new Point(r.X + LeftMargin, r.Bottom - s.Height), bs); + default: + return new Rectangle(new Point(r.X + LeftMargin, r.Y + (r.Height - s.Height) / 2), bs); } } + protected void CheckThread() + { + if (Parent != null && Control.CheckForIllegalCrossThreadCalls) + if (Parent.InvokeRequired) + throw new InvalidOperationException("Cross-thread calls are not allowed"); + } + + public bool IsVisible(TreeNodeAdv node) + { + NodeControlValueEventArgs args = new NodeControlValueEventArgs(node); + args.Value = true; + OnIsVisibleValueNeeded(args); + return Convert.ToBoolean(args.Value); + } // wj32: getting sizes takes a lot of CPU time, so let's cache it. - private bool _cachedSizeValid; + private bool _cachedSizeValid = false; private Size _cachedSize = Size.Empty; internal Size GetActualSize(TreeNodeAdv node, DrawContext context) @@ -145,21 +152,36 @@ internal Size GetActualSize(TreeNodeAdv node, DrawContext context) } public abstract Size MeasureSize(TreeNodeAdv node, DrawContext context); + public abstract void Draw(TreeNodeAdv node, DrawContext context); public virtual string GetToolTip(TreeNodeAdv node) { if (ToolTipProvider != null) return ToolTipProvider.GetToolTip(node, this); - - return string.Empty; + else + return string.Empty; + } + + public virtual void MouseDown(TreeNodeAdvMouseEventArgs args) + { + } + + public virtual void MouseUp(TreeNodeAdvMouseEventArgs args) + { + } + + public virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) + { } - public virtual void MouseDown(TreeNodeAdvMouseEventArgs args) { } - public virtual void MouseUp(TreeNodeAdvMouseEventArgs args) { } - public virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs args) { } - public virtual void KeyDown(KeyEventArgs args) { } - public virtual void KeyUp(KeyEventArgs args) { } + public virtual void KeyDown(KeyEventArgs args) + { + } + + public virtual void KeyUp(KeyEventArgs args) + { + } public event EventHandler IsVisibleValueNeeded; protected virtual void OnIsVisibleValueNeeded(NodeControlValueEventArgs args) diff --git a/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControlValueEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControlValueEventArgs.cs new file mode 100644 index 000000000..d4f72ece2 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControlValueEventArgs.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Aga.Controls.Tree.NodeControls +{ + public class NodeControlValueEventArgs : NodeEventArgs + { + private object _value; + public object Value + { + get { return _value; } + set { _value = value; } + } + + public NodeControlValueEventArgs(TreeNodeAdv node) + :base(node) + { + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControlsCollection.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControlsCollection.cs similarity index 56% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControlsCollection.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControlsCollection.cs index 16468b5b8..1177ec48c 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeControlsCollection.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeControlsCollection.cs @@ -1,10 +1,14 @@ using System; +using System.Collections.Generic; +using System.Text; using System.ComponentModel.Design; using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing.Design; namespace Aga.Controls.Tree.NodeControls { - public class NodeControlsCollection : Collection + internal class NodeControlsCollection : Collection { private TreeViewAdv _tree; @@ -16,8 +20,7 @@ public NodeControlsCollection(TreeViewAdv tree) protected override void ClearItems() { _tree.BeginUpdate(); - - try + try { while (this.Count != 0) this.RemoveAt(this.Count - 1); @@ -33,30 +36,24 @@ protected override void InsertItem(int index, NodeControl item) if (item == null) throw new ArgumentNullException("item"); - if (item.Parent == this._tree) - return; - - if (item.Parent != null) - { - item.Parent.NodeControls.Remove(item); - } - - base.InsertItem(index, item); - - item.AssignParent(this._tree); - - this._tree.FullUpdate(); + if (item.Parent != _tree) + { + if (item.Parent != null) + { + item.Parent.NodeControls.Remove(item); + } + base.InsertItem(index, item); + item.AssignParent(_tree); + _tree.FullUpdate(); + } } protected override void RemoveItem(int index) { NodeControl value = this[index]; - - value.AssignParent(null); - - base.RemoveItem(index); - - _tree.FullUpdate(); + value.AssignParent(null); + base.RemoveItem(index); + _tree.FullUpdate(); } protected override void SetItem(int index, NodeControl item) @@ -65,7 +62,6 @@ protected override void SetItem(int index, NodeControl item) throw new ArgumentNullException("item"); _tree.BeginUpdate(); - try { RemoveAt(index); @@ -85,15 +81,12 @@ internal class NodeControlCollectionEditor : CollectionEditor public NodeControlCollectionEditor(Type type) : base(type) { - _types = new[] - { - typeof(NodeTextBox), - typeof(NodeIntegerTextBox), - typeof(NodeIcon), - }; + _types = new Type[] { typeof(NodeTextBox), typeof(NodeIntegerTextBox), typeof(NodeDecimalTextBox), + typeof(NodeComboBox), typeof(NodeCheckBox), + typeof(NodeStateIcon), typeof(NodeIcon), typeof(NodeNumericUpDown), typeof(ExpandingIcon) }; } - protected override Type[] CreateNewItemTypes() + protected override System.Type[] CreateNewItemTypes() { return _types; } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeDecimalTextBox.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeDecimalTextBox.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeDecimalTextBox.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeDecimalTextBox.cs diff --git a/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeEventArgs.cs new file mode 100644 index 000000000..5ee8e4fa9 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeEventArgs.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Aga.Controls.Tree.NodeControls +{ + public class NodeEventArgs : EventArgs + { + private TreeNodeAdv _node; + public TreeNodeAdv Node + { + get { return _node; } + } + + public NodeEventArgs(TreeNodeAdv node) + { + _node = node; + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeIcon.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeIcon.cs similarity index 74% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeIcon.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeIcon.cs index c16a02c34..f8b3138d7 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeIcon.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeIcon.cs @@ -1,4 +1,9 @@ +using System; +using System.Collections.Generic; +using System.Text; using System.Drawing; +using System.Windows.Forms; +using Aga.Controls.Properties; namespace Aga.Controls.Tree.NodeControls { @@ -12,21 +17,18 @@ public NodeIcon() public override Size MeasureSize(TreeNodeAdv node, DrawContext context) { Image image = GetIcon(node); - - if (image != null) + if (image != null) return image.Size; - - return Size.Empty; + else + return Size.Empty; } public override void Draw(TreeNodeAdv node, DrawContext context) { Image image = GetIcon(node); - if (image != null) { Rectangle r = GetBounds(node, context); - context.Graphics.DrawImage(image, r.Location); } } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeIntegerTextBox.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeIntegerTextBox.cs similarity index 58% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeIntegerTextBox.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeIntegerTextBox.cs index ed19492e5..a1e55a0ee 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeIntegerTextBox.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeIntegerTextBox.cs @@ -1,3 +1,6 @@ +using System; +using System.Collections.Generic; +using System.Text; using System.ComponentModel; using System.Windows.Forms; @@ -14,13 +17,16 @@ public bool AllowNegativeSign set { _allowNegativeSign = value; } } - protected override TextBox CreateTextBox() + public NodeIntegerTextBox() { - return new NumericTextBox - { - AllowDecimalSeperator = false, - AllowNegativeSign = this.AllowNegativeSign - }; + } + + protected override TextBox CreateTextBox() + { + NumericTextBox textBox = new NumericTextBox(); + textBox.AllowDecimalSeperator = false; + textBox.AllowNegativeSign = AllowNegativeSign; + return textBox; } protected override void DoApplyChanges(TreeNodeAdv node, Control editor) diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeNumericUpDown.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeNumericUpDown.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeNumericUpDown.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeNumericUpDown.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodePlusMinus.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodePlusMinus.cs similarity index 56% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodePlusMinus.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodePlusMinus.cs index f2ca0dfcd..03c2c1c00 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodePlusMinus.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodePlusMinus.cs @@ -3,18 +3,21 @@ */ using System; +using System.Collections.Generic; +using System.Text; using System.Drawing; +using Aga.Controls.Properties; using System.Windows.Forms; using System.Windows.Forms.VisualStyles; -using ProcessHacker.Properties; namespace Aga.Controls.Tree.NodeControls { internal class NodePlusMinus : NodeControl { - private readonly TreeViewAdv _tree; - public static int ImageSize = 9; - public static int Width = 16; + private TreeViewAdv _tree; + public const int ImageSize = 9; + public const int Width = 16; + private bool _useVisualStyles; private VisualStyleRenderer _openedRenderer; private VisualStyleRenderer _closedRenderer; private Bitmap _plus; @@ -50,20 +53,9 @@ private Bitmap Minus public void RefreshVisualStyles() { - if (ExplorerVisualStyle.VisualStylesEnabled) - { - try - { - _openedRenderer = ExplorerVisualStyle.TvOpenedRenderer; - _closedRenderer = ExplorerVisualStyle.TvClosedRenderer; - } - catch - { - _openedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened); - _closedRenderer = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed); - } - } - else + bool useVisualStyles = Application.RenderWithVisualStyles; + + if (useVisualStyles) { try { @@ -72,8 +64,11 @@ public void RefreshVisualStyles() } catch { + useVisualStyles = false; } } + + _useVisualStyles = useVisualStyles; } public override Size MeasureSize(TreeNodeAdv node, DrawContext context) @@ -83,42 +78,43 @@ public override Size MeasureSize(TreeNodeAdv node, DrawContext context) public override void Draw(TreeNodeAdv node, DrawContext context) { - if (!node.CanExpand) - return; - - Rectangle r = context.Bounds; - - if (ExplorerVisualStyle.VisualStylesEnabled) - { - VisualStyleRenderer renderer; - - if (node.IsExpanded) - renderer = this._openedRenderer; - else - renderer = this._closedRenderer; - - try - { - renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y, Width, Width)); - } - catch (InvalidOperationException) - { - - } - } - else - { - Image img; - - if (node.IsExpanded) - img = this.Minus; - else - img = this.Plus; - - int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2); - - context.Graphics.DrawImageUnscaled(img, new Point(r.X, r.Y + dy)); - } + if (node.CanExpand) + { + Rectangle r = context.Bounds; + int dy = (int)Math.Round((float)(r.Height - ImageSize) / 2); + + if (_useVisualStyles) + { + VisualStyleRenderer renderer; + + if (node.IsExpanded) + renderer = _openedRenderer; + else + renderer = _closedRenderer; + + try + { + renderer.DrawBackground(context.Graphics, new Rectangle(r.X, r.Y + dy, ImageSize, ImageSize)); + } + catch (InvalidOperationException) + { + // Fucking retarded VisualStyleRenderer throws exceptions. + _useVisualStyles = false; + } + } + + if (!_useVisualStyles) + { + Image img; + + if (node.IsExpanded) + img = this.Minus; + else + img = this.Plus; + + context.Graphics.DrawImageUnscaled(img, new Point(r.X, r.Y + dy)); + } + } } public override void MouseDown(TreeNodeAdvMouseEventArgs args) diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeStateIcon.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeStateIcon.cs similarity index 71% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeStateIcon.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeStateIcon.cs index 71de4a433..20c751c7d 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeStateIcon.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeStateIcon.cs @@ -1,19 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; using System.Drawing; - -using ProcessHacker.Properties; +using Aga.Controls.Properties; namespace Aga.Controls.Tree.NodeControls { public class NodeStateIcon: NodeIcon { - private readonly Image _leaf; - private readonly Image _opened; - private readonly Image _closed; + private Image _leaf; + private Image _opened; + private Image _closed; public NodeStateIcon() { _leaf = MakeTransparent(Resources.Leaf); - _opened = MakeTransparent(Resources.folder); + _opened = MakeTransparent(Resources.Folder); _closed = MakeTransparent(Resources.FolderClosed); } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeTextBox.cs b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeTextBox.cs similarity index 71% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeTextBox.cs rename to 1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeTextBox.cs index 19bf6562c..ef34be310 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/NodeControls/NodeTextBox.cs +++ b/1.x/trunk/TreeViewAdv/Tree/NodeControls/NodeTextBox.cs @@ -10,17 +10,33 @@ namespace Aga.Controls.Tree.NodeControls { public class NodeTextBox: BaseTextControl { - private TextBox EditorTextBox + private const int MinTextBoxWidth = 30; + + private TextBox EditorTextBox + { + get + { + return CurrentEditor as TextBox; + } + } + + public NodeTextBox() { - get { return this.CurrentEditor as TextBox; } } - protected override Size CalculateEditorSize(EditorContext context) + protected override Size CalculateEditorSize(EditorContext context) { - return context.Bounds.Size; + if (Parent.UseColumns) + return context.Bounds.Size; + else + { + Size size = GetLabelSize(context.CurrentNode, context.DrawContext, _label); + int width = Math.Max(size.Width + Font.Height, MinTextBoxWidth); // reserve a place for new typed character + return new Size(width, size.Height); + } } - public override void KeyDown(KeyEventArgs args) + public override void KeyDown(KeyEventArgs args) { if (args.KeyCode == Keys.F2 && Parent.CurrentNode != null) { @@ -35,7 +51,7 @@ protected override Control CreateEditor(TreeNodeAdv node) textBox.TextAlign = TextAlign; textBox.Text = GetLabel(node); textBox.BorderStyle = BorderStyle.FixedSingle; - textBox.TextChanged += this.textBox_TextChanged; + textBox.TextChanged += new EventHandler(textBox_TextChanged); _label = textBox.Text; SetEditControlProperties(textBox, node); return textBox; diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/SortedTreeModel.cs b/1.x/trunk/TreeViewAdv/Tree/SortedTreeModel.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/SortedTreeModel.cs rename to 1.x/trunk/TreeViewAdv/Tree/SortedTreeModel.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumn.cs b/1.x/trunk/TreeViewAdv/Tree/TreeColumn.cs similarity index 53% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumn.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeColumn.cs index 0bf7fd772..462b1a2f9 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumn.cs +++ b/1.x/trunk/TreeViewAdv/Tree/TreeColumn.cs @@ -1,14 +1,15 @@ using System; +using System.Collections.Generic; +using System.Text; using System.ComponentModel; using System.Windows.Forms; using System.Drawing; using System.Windows.Forms.VisualStyles; using System.Drawing.Imaging; -using ProcessHacker.Common; namespace Aga.Controls.Tree { - [TypeConverter(typeof(TreeColumnConverter)), DesignTimeVisible(false), ToolboxItem(false)] + [TypeConverter(typeof(TreeColumn.TreeColumnConverter)), DesignTimeVisible(false), ToolboxItem(false)] public class TreeColumn : Component { private class TreeColumnConverter : ComponentConverter @@ -24,29 +25,34 @@ public override bool GetPropertiesSupported(ITypeDescriptorContext context) } } - private static int HeaderLeftMargin = 5; - private static int HeaderRightMargin = 5; - private static int SortOrderMarkMargin = 8; + private const int HeaderLeftMargin = 5; + private const int HeaderRightMargin = 5; + private const int SortOrderMarkMargin = 8; private TextFormatFlags _headerFlags; - private static TextFormatFlags _baseHeaderFlags = TextFormatFlags.NoPadding | + private TextFormatFlags _baseHeaderFlags = TextFormatFlags.NoPadding | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.PreserveGraphicsTranslateTransform; #region Properties - internal TreeColumnCollection Owner { get; set; } + private TreeColumnCollection _owner; + internal TreeColumnCollection Owner + { + get { return _owner; } + set { _owner = value; } + } - [Browsable(false)] + [Browsable(false)] public int Index { - get + get { - if (this.Owner != null) - return this.Owner.IndexOf(this); - - return -1; + if (Owner != null) + return Owner.IndexOf(this); + else + return -1; } } @@ -62,10 +68,15 @@ public string Header } } - [Localizable(true)] - public string TooltipText { get; set; } + private string _tooltipText; + [Localizable(true)] + public string TooltipText + { + get { return _tooltipText; } + set { _tooltipText = value; } + } - private int _width; + private int _width; [DefaultValue(50), Localizable(true)] public int Width { @@ -146,10 +157,15 @@ public HorizontalAlignment TextAlign } } - [DefaultValue(false)] - public bool Sortable { get; set; } + private bool _sortable = false; + [DefaultValue(false)] + public bool Sortable + { + get { return _sortable; } + set { _sortable = value; } + } - private SortOrder _sort_order = SortOrder.None; + private SortOrder _sort_order = SortOrder.None; public SortOrder SortOrder { get { return _sort_order; } @@ -166,10 +182,10 @@ public Size SortMarkSize { get { - if (ExplorerVisualStyle.VisualStylesEnabled) + if (Application.RenderWithVisualStyles) return new Size(9, 5); - - return new Size(7, 4); + else + return new Size(7, 4); } } #endregion @@ -188,13 +204,18 @@ public TreeColumn(string header, int width) public override string ToString() { - if (string.IsNullOrEmpty(Header)) + if (string.IsNullOrEmpty(Header)) return GetType().Name; - - return this.Header; + else + return Header; } - #region Draw + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + } + + #region Draw private static VisualStyleRenderer _normalRenderer; private static VisualStyleRenderer _hotRenderer; @@ -203,17 +224,11 @@ public override string ToString() internal Bitmap CreateGhostImage(Rectangle bounds, Font font) { Bitmap b = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb); - - using (Graphics gr = Graphics.FromImage(b)) - { - gr.FillRectangle(SystemBrushes.ControlDark, bounds); - - DrawContent(gr, bounds, font); - - BitmapHelper.SetAlphaChanelValue(b, 150); - } - - return b; + Graphics gr = Graphics.FromImage(b); + gr.FillRectangle(SystemBrushes.ControlDark, bounds); + DrawContent(gr, bounds, font); + BitmapHelper.SetAlphaChanelValue(b, 150); + return b; } internal void Draw(Graphics gr, Rectangle bounds, Font font, bool pressed, bool hot) @@ -224,46 +239,34 @@ internal void Draw(Graphics gr, Rectangle bounds, Font font, bool pressed, bool internal void DrawContent(Graphics gr, Rectangle bounds, Font font) { - Rectangle innerBounds = new Rectangle(bounds.X + HeaderLeftMargin, bounds.Y, bounds.Width - HeaderLeftMargin - HeaderRightMargin, bounds.Height); + Rectangle innerBounds = new Rectangle(bounds.X + HeaderLeftMargin, bounds.Y, + bounds.Width - HeaderLeftMargin - HeaderRightMargin, + bounds.Height); - if (this.SortOrder != SortOrder.None) - innerBounds.Width -= (this.SortMarkSize.Width + SortOrderMarkMargin); + if (SortOrder != SortOrder.None) + innerBounds.Width -= (SortMarkSize.Width + SortOrderMarkMargin); - Size maxTextSize = gr.GetCachedSize(this.Header, font);// innerBounds.Size, TextFormatFlags.NoPadding); - Size textSize = gr.GetCachedSize(this.Header, font);// innerBounds.Size, _baseHeaderFlags); + Size maxTextSize = TextRenderer.MeasureText(gr, Header, font, innerBounds.Size, TextFormatFlags.NoPadding); + Size textSize = TextRenderer.MeasureText(gr, Header, font, innerBounds.Size, _baseHeaderFlags); if (SortOrder != SortOrder.None) { int tw = Math.Min(textSize.Width, innerBounds.Size.Width); - int x; - - switch (this.TextAlign) - { - case HorizontalAlignment.Left: - { - x = innerBounds.X + tw + SortOrderMarkMargin; - break; - } - case HorizontalAlignment.Right: - { - x = innerBounds.Right + SortOrderMarkMargin; - break; - } - default: - { - x = innerBounds.X + tw + (innerBounds.Width - tw) / 2 + SortOrderMarkMargin; - break; - } - } - + int x = 0; + if (TextAlign == HorizontalAlignment.Left) + x = innerBounds.X + tw + SortOrderMarkMargin; + else if (TextAlign == HorizontalAlignment.Right) + x = innerBounds.Right + SortOrderMarkMargin; + else + x = innerBounds.X + tw + (innerBounds.Width - tw) / 2 + SortOrderMarkMargin; DrawSortMark(gr, bounds, x); } - if (textSize.Width < maxTextSize.Width) - TextRenderer.DrawText(gr, Header, font, innerBounds, SystemColors.ControlText, _baseHeaderFlags | TextFormatFlags.Left); + if (textSize.Width < maxTextSize.Width) + TextRenderer.DrawText(gr, Header, font, innerBounds, SystemColors.ControlText, _baseHeaderFlags | TextFormatFlags.Left); else - TextRenderer.DrawText(gr, Header, font, innerBounds, SystemColors.ControlText, _headerFlags); + TextRenderer.DrawText(gr, Header, font, innerBounds, SystemColors.ControlText, _headerFlags); } private void DrawSortMark(Graphics gr, Rectangle bounds, int x) @@ -272,33 +275,15 @@ private void DrawSortMark(Graphics gr, Rectangle bounds, int x) x = Math.Max(x, bounds.X + SortOrderMarkMargin); int w2 = SortMarkSize.Width / 2; - - switch (this.SortOrder) + if (SortOrder == SortOrder.Ascending) { - case SortOrder.Ascending: - { - Point[] points = new[] - { - new Point(x, y), - new Point(x + this.SortMarkSize.Width, y), - new Point(x + w2, y + this.SortMarkSize.Height) - }; - - gr.FillPolygon(SystemBrushes.ControlDark, points); - } - break; - case SortOrder.Descending: - { - Point[] points = new[] - { - new Point(x - 1, y + this.SortMarkSize.Height), - new Point(x + this.SortMarkSize.Width, y + this.SortMarkSize.Height), - new Point(x + w2, y - 1) - }; - - gr.FillPolygon(SystemBrushes.ControlDark, points); - } - break; + Point[] points = new Point[] { new Point(x, y), new Point(x + SortMarkSize.Width, y), new Point(x + w2, y + SortMarkSize.Height) }; + gr.FillPolygon(SystemBrushes.ControlDark, points); + } + else if (SortOrder == SortOrder.Descending) + { + Point[] points = new Point[] { new Point(x - 1, y + SortMarkSize.Height), new Point(x + SortMarkSize.Width, y + SortMarkSize.Height), new Point(x + w2, y - 1) }; + gr.FillPolygon(SystemBrushes.ControlDark, points); } } @@ -309,14 +294,12 @@ internal static void DrawDropMark(Graphics gr, Rectangle rect) internal static void DrawBackground(Graphics gr, Rectangle bounds, bool pressed, bool hot) { - if (ExplorerVisualStyle.VisualStylesEnabled) + if (Application.RenderWithVisualStyles) { if (_normalRenderer == null) _normalRenderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal); - if (_hotRenderer == null) _hotRenderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Hot); - if (_pressedRenderer == null) _pressedRenderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Pressed); @@ -327,26 +310,24 @@ internal static void DrawBackground(Graphics gr, Rectangle bounds, bool pressed, else _normalRenderer.DrawBackground(gr, bounds); } - else - { - gr.Clear(SystemColors.Control); - - Pen p1 = SystemPens.ControlLightLight; - Pen p2 = SystemPens.ControlDark; - Pen p3 = SystemPens.ControlDarkDark; - - if (pressed) - gr.DrawRectangle(p2, bounds.X, bounds.Y, bounds.Width, bounds.Height); - else - { - gr.DrawLine(p1, bounds.X, bounds.Y, bounds.Right, bounds.Y); - gr.DrawLine(p3, bounds.X, bounds.Bottom, bounds.Right, bounds.Bottom); - gr.DrawLine(p3, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 1); - gr.DrawLine(p1, bounds.Left, bounds.Y + 1, bounds.Left, bounds.Bottom - 2); - gr.DrawLine(p2, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 2); - gr.DrawLine(p2, bounds.X, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1); - } - } + else + { + gr.FillRectangle(SystemBrushes.Control, bounds); + Pen p1 = SystemPens.ControlLightLight; + Pen p2 = SystemPens.ControlDark; + Pen p3 = SystemPens.ControlDarkDark; + if (pressed) + gr.DrawRectangle(p2, bounds.X, bounds.Y, bounds.Width, bounds.Height); + else + { + gr.DrawLine(p1, bounds.X, bounds.Y, bounds.Right, bounds.Y); + gr.DrawLine(p3, bounds.X, bounds.Bottom, bounds.Right, bounds.Bottom); + gr.DrawLine(p3, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 1); + gr.DrawLine(p1, bounds.Left, bounds.Y + 1, bounds.Left, bounds.Bottom - 2); + gr.DrawLine(p2, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 2); + gr.DrawLine(p2, bounds.X, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1); + } + } } #endregion diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumnCollection.cs b/1.x/trunk/TreeViewAdv/Tree/TreeColumnCollection.cs similarity index 89% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumnCollection.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeColumnCollection.cs index 5802f699d..431af4ce9 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumnCollection.cs +++ b/1.x/trunk/TreeViewAdv/Tree/TreeColumnCollection.cs @@ -1,10 +1,13 @@ using System; +using System.Collections.Generic; +using System.Text; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Windows.Forms; namespace Aga.Controls.Tree { - public class TreeColumnCollection : Collection + internal class TreeColumnCollection : Collection { private TreeViewAdv _treeView; diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumnEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/TreeColumnEventArgs.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeColumnEventArgs.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeColumnEventArgs.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeListAdapter.cs b/1.x/trunk/TreeViewAdv/Tree/TreeListAdapter.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeListAdapter.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeListAdapter.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeModel.cs b/1.x/trunk/TreeViewAdv/Tree/TreeModel.cs similarity index 62% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeModel.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeModel.cs index 47d171dd5..44a3ddb85 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeModel.cs +++ b/1.x/trunk/TreeViewAdv/Tree/TreeModel.cs @@ -12,58 +12,58 @@ namespace Aga.Controls.Tree ///
public class TreeModel : ITreeModel { - public Node Root { get; private set; } + private Node _root; + public Node Root + { + get { return _root; } + } - public Collection Nodes + public Collection Nodes { - get { return this.Root.Nodes; } + get { return _root.Nodes; } } public TreeModel() { - this.Root = new Node - { - Model = this - }; + _root = new Node(); + _root.Model = this; } public TreePath GetPath(Node node) { - if (node == this.Root) + if (node == _root) return TreePath.Empty; - - Stack stack = new Stack(); - - while (node != this.Root) - { - stack.Push(node); - node = node.Parent; - } - - return new TreePath(stack.ToArray()); + else + { + Stack stack = new Stack(); + while (node != _root) + { + stack.Push(node); + node = node.Parent; + } + return new TreePath(stack.ToArray()); + } } public Node FindNode(TreePath path) { if (path.IsEmpty()) - return this.Root; - - return FindNode(this.Root, path, 0); + return _root; + else + return FindNode(_root, path, 0); } private Node FindNode(Node root, TreePath path, int level) { - foreach (Node node in root.Nodes) - { - if (node == path.FullPath[level]) - { - if (level == path.FullPath.Length - 1) - return node; - - return FindNode(node, path, level + 1); - } - } - return null; + foreach (Node node in root.Nodes) + if (node == path.FullPath[level]) + { + if (level == path.FullPath.Length - 1) + return node; + else + return FindNode(node, path, level + 1); + } + return null; } #region ITreeModel Members @@ -71,14 +71,11 @@ private Node FindNode(Node root, TreePath path, int level) public System.Collections.IEnumerable GetChildren(TreePath treePath) { Node node = FindNode(treePath); - - if (node != null) - { - foreach (Node n in node.Nodes) - yield return n; - } - else - yield break; + if (node != null) + foreach (Node n in node.Nodes) + yield return n; + else + yield break; } public bool IsLeaf(TreePath treePath) @@ -86,8 +83,8 @@ public bool IsLeaf(TreePath treePath) Node node = FindNode(treePath); if (node != null) return node.IsLeaf; - - throw new ArgumentException("treePath"); + else + throw new ArgumentException("treePath"); } public event EventHandler NodesChanged; diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeModelBase.cs b/1.x/trunk/TreeViewAdv/Tree/TreeModelBase.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeModelBase.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeModelBase.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeModelEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/TreeModelEventArgs.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeModelEventArgs.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeModelEventArgs.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeNodeAdv.cs b/1.x/trunk/TreeViewAdv/Tree/TreeNodeAdv.cs similarity index 86% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeNodeAdv.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeNodeAdv.cs index 8b4e1aabb..dcb588d47 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeNodeAdv.cs +++ b/1.x/trunk/TreeViewAdv/Tree/TreeNodeAdv.cs @@ -78,9 +78,13 @@ protected override void SetItem(int index, TreeNodeAdv item) #region Properties - internal TreeViewAdv Tree { get; private set; } + private TreeViewAdv _tree; + internal TreeViewAdv Tree + { + get { return _tree; } + } - private int _row; + private int _row; internal int Row { get { return _row; } @@ -116,20 +120,19 @@ public NodeState State } } - private Color _backColor = Color.White; + private Color _backColor = SystemColors.Window; public Color BackColor { get { if (_state != NodeState.Normal) return StateColors[_state]; - - return _backColor; + else + return _backColor; } set { _backColor = value; - if (_automaticForeColor) _autoForeColor = GetForeColor(this.BackColor); } @@ -177,21 +180,21 @@ public bool IsSelected { if (_isSelected != value) { - if (this.Tree.IsMyNode(this)) + if (Tree.IsMyNode(this)) { //_tree.OnSelectionChanging if (value) { - if (!this.Tree.Selection.Contains(this)) - this.Tree.Selection.Add(this); + if (!_tree.Selection.Contains(this)) + _tree.Selection.Add(this); - if (this.Tree.Selection.Count == 1) - this.Tree.CurrentNode = this; + if (_tree.Selection.Count == 1) + _tree.CurrentNode = this; } else - this.Tree.Selection.Remove(this); - this.Tree.UpdateView(); - this.Tree.OnSelectionChanged(); + _tree.Selection.Remove(this); + _tree.UpdateView(); + _tree.OnSelectionChanged(); } _isSelected = value; } @@ -371,21 +374,21 @@ public TreeNodeAdv(object tag): this(null, tag) internal TreeNodeAdv(TreeViewAdv tree, object tag) { _row = -1; - this.Tree = tree; + _tree = tree; _nodes = new NodeCollection(this); _children = new ReadOnlyCollection(_nodes); _tag = tag; } public override string ToString() - { - if (Tag != null) + { + if (Tag != null) return Tag.ToString(); - - return base.ToString(); + else + return base.ToString(); } - public void Collapse() + public void Collapse() { if (_isExpanded) Collapse(true); @@ -405,26 +408,26 @@ public void EnsureVisible() { TreeNodeAdv parent = this.Parent; - while (parent != this.Tree.Root) + while (parent != _tree.Root) { parent.Expand(); parent = parent.Parent; } - this.Tree.ScrollTo(this); + _tree.ScrollTo(this); } public void EnsureVisible2() { TreeNodeAdv parent = this.Parent; - while (parent != this.Tree.Root) + while (parent != _tree.Root) { parent.Expand(); parent = parent.Parent; } - this.Tree.ScrollTo2(this); + _tree.ScrollTo2(this); } public void Expand() @@ -445,14 +448,14 @@ public void Expand(bool ignoreChildren) private void SetIsExpanded(bool value, bool ignoreChildren) { - if (this.Tree == null) + if (Tree == null) { _isExpanded = value; if (!ignoreChildren) - this.Tree.SetIsExpandedRecursive(this, value); + Tree.SetIsExpandedRecursive(this, value); } else - this.Tree.SetIsExpanded(this, value, ignoreChildren); + Tree.SetIsExpanded(this, value, ignoreChildren); } #region ISerializable Members diff --git a/1.x/trunk/TreeViewAdv/Tree/TreeNodeAdvMouseEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/TreeNodeAdvMouseEventArgs.cs new file mode 100644 index 000000000..79d7b20b2 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/TreeNodeAdvMouseEventArgs.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using System.Drawing; +using Aga.Controls.Tree.NodeControls; + +namespace Aga.Controls.Tree +{ + public class TreeNodeAdvMouseEventArgs : MouseEventArgs + { + private TreeNodeAdv _node; + public TreeNodeAdv Node + { + get { return _node; } + internal set { _node = value; } + } + + private NodeControl _control; + public NodeControl Control + { + get { return _control; } + internal set { _control = value; } + } + + private Point _viewLocation; + public Point ViewLocation + { + get { return _viewLocation; } + internal set { _viewLocation = value; } + } + + private Keys _modifierKeys; + public Keys ModifierKeys + { + get { return _modifierKeys; } + internal set { _modifierKeys = value; } + } + + private bool _handled; + public bool Handled + { + get { return _handled; } + set { _handled = value; } + } + + private Rectangle _controlBounds; + public Rectangle ControlBounds + { + get { return _controlBounds; } + internal set { _controlBounds = value; } + } + + public TreeNodeAdvMouseEventArgs(MouseEventArgs args) + : base(args.Button, args.Clicks, args.X, args.Y, args.Delta) + { + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreePath.cs b/1.x/trunk/TreeViewAdv/Tree/TreePath.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreePath.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreePath.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreePathEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/TreePathEventArgs.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreePathEventArgs.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreePathEventArgs.cs diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Designer.cs b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Designer.cs similarity index 95% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Designer.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Designer.cs index 032a70b55..68d7cdc4e 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Designer.cs +++ b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Designer.cs @@ -2,7 +2,7 @@ namespace Aga.Controls.Tree { - sealed partial class TreeViewAdv + partial class TreeViewAdv { private System.ComponentModel.IContainer components = null; diff --git a/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Draw.cs b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Draw.cs new file mode 100644 index 000000000..a470157f5 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Draw.cs @@ -0,0 +1,261 @@ +/* + * Modified by wj32. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using System.Drawing; +using System.Windows.Forms.VisualStyles; +using System.Diagnostics; +using System.Drawing.Drawing2D; +using Aga.Controls.Tree.NodeControls; + +namespace Aga.Controls.Tree +{ + public partial class TreeViewAdv + { + private void CreatePens() + { + CreateLinePen(); + CreateMarkPen(); + } + + private void CreateMarkPen() + { + GraphicsPath path = new GraphicsPath(); + path.AddLines(new Point[] { new Point(0, 0), new Point(1, 1), new Point(-1, 1), new Point(0, 0) }); + CustomLineCap cap = new CustomLineCap(null, path); + cap.WidthScale = 1.0f; + + _markPen = new Pen(_dragDropMarkColor, _dragDropMarkWidth); + _markPen.CustomStartCap = cap; + _markPen.CustomEndCap = cap; + } + + private void CreateLinePen() + { + _linePen = new Pen(_lineColor); + _linePen.DashStyle = DashStyle.Dot; + } + + protected override void OnPaint(PaintEventArgs e) + { + DrawContext context = new DrawContext(); + context.Graphics = e.Graphics; + context.Font = this.Font; + context.Enabled = Enabled; + + int y = 0; + int gridHeight = 0; + + if (UseColumns) + { + DrawColumnHeaders(e.Graphics); + y += ColumnHeaderHeight; + if (Columns.Count == 0 || e.ClipRectangle.Height <= y) + return; + } + + int firstRowY = _rowLayout.GetRowBounds(FirstVisibleRow).Y; + y -= firstRowY; + + e.Graphics.ResetTransform(); + e.Graphics.TranslateTransform(-OffsetX, y); + Rectangle displayRect = DisplayRectangle; + for (int row = FirstVisibleRow; row < RowCount; row++) + { + Rectangle rowRect = _rowLayout.GetRowBounds(row); + gridHeight += rowRect.Height; + if (rowRect.Y + y > displayRect.Bottom) + break; + else + DrawRow(e, ref context, row, rowRect); + } + + if ((GridLineStyle & GridLineStyle.Vertical) == GridLineStyle.Vertical && UseColumns) + DrawVerticalGridLines(e.Graphics, firstRowY); + + if (_dropPosition.Node != null && DragMode && HighlightDropPosition) + DrawDropMark(e.Graphics); + + e.Graphics.ResetTransform(); + DrawScrollBarsBox(e.Graphics); + + if (DragMode && _dragBitmap != null) + e.Graphics.DrawImage(_dragBitmap, PointToClient(MousePosition)); + } + + private void DrawRow(PaintEventArgs e, ref DrawContext context, int row, Rectangle rowRect) + { + TreeNodeAdv node = RowMap[row]; + context.DrawSelection = DrawSelectionMode.None; + context.CurrentEditorOwner = _currentEditorOwner; + + if (DragMode) + { + if ((_dropPosition.Node == node) && _dropPosition.Position == NodePosition.Inside && HighlightDropPosition) + context.DrawSelection = DrawSelectionMode.Active; + } + else + { + if (node.IsSelected && Focused) + context.DrawSelection = DrawSelectionMode.Active; + else if (node.IsSelected && !Focused && !HideSelection) + context.DrawSelection = DrawSelectionMode.Inactive; + } + + context.DrawFocus = Focused && CurrentNode == node; + + Rectangle focusRect = new Rectangle(OffsetX, rowRect.Y, ClientRectangle.Width, rowRect.Height); + + if (!FullRowSelect || (FullRowSelect && + context.DrawSelection != DrawSelectionMode.Active && + context.DrawSelection != DrawSelectionMode.Inactive)) + e.Graphics.FillRectangle(new SolidBrush(node.BackColor), focusRect); + + if (FullRowSelect) + { + context.DrawFocus = false; + + if (context.DrawSelection == DrawSelectionMode.Active || context.DrawSelection == DrawSelectionMode.Inactive) + { + if (context.DrawSelection == DrawSelectionMode.Active) + { + e.Graphics.FillRectangle(SystemBrushes.Highlight, focusRect); + context.DrawSelection = DrawSelectionMode.FullRowSelect; + } + else + { + e.Graphics.FillRectangle(SystemBrushes.InactiveBorder, focusRect); + context.DrawSelection = DrawSelectionMode.None; + } + } + } + + if ((GridLineStyle & GridLineStyle.Horizontal) == GridLineStyle.Horizontal) + e.Graphics.DrawLine(SystemPens.InactiveBorder, 0, rowRect.Bottom, e.Graphics.ClipBounds.Right, rowRect.Bottom); + + if (ShowLines) + DrawLines(e.Graphics, node, rowRect); + + DrawNode(node, context); + } + + private void DrawVerticalGridLines(Graphics gr, int y) + { + int x = 0; + foreach (TreeColumn c in Columns) + { + if (c.IsVisible) + { + x += c.Width; + gr.DrawLine(SystemPens.InactiveBorder, x - 1, y, x - 1, gr.ClipBounds.Bottom); + } + } + } + + private void DrawColumnHeaders(Graphics gr) + { + ReorderColumnState reorder = Input as ReorderColumnState; + int x = 0; + TreeColumn.DrawBackground(gr, new Rectangle(0, 0, ClientRectangle.Width + 2, ColumnHeaderHeight - 1), false, false); + gr.TranslateTransform(-OffsetX, 0); + foreach (TreeColumn c in Columns) + { + if (c.IsVisible) + { + if (x + c.Width >= OffsetX && x - OffsetX < this.Bounds.Width)// skip invisible columns (fixed by wj32) + { + Rectangle rect = new Rectangle(x, 0, c.Width, ColumnHeaderHeight - 1); + gr.SetClip(rect); + bool pressed = ((Input is ClickColumnState || reorder != null) && ((Input as ColumnState).Column == c)); + c.Draw(gr, rect, Font, pressed, _hotColumn == c); + gr.ResetClip(); + + if (reorder != null && reorder.DropColumn == c) + TreeColumn.DrawDropMark(gr, rect); + } + x += c.Width; + } + } + + if (reorder != null) + { + if (reorder.DropColumn == null) + TreeColumn.DrawDropMark(gr, new Rectangle(x, 0, 0, ColumnHeaderHeight)); + gr.DrawImage(reorder.GhostImage, new Point(reorder.Location.X + + reorder.DragOffset, reorder.Location.Y)); + } + } + + public void DrawNode(TreeNodeAdv node, DrawContext context) + { + foreach (NodeControlInfo item in GetNodeControls(node)) + { + if (item.Bounds.X + item.Bounds.Width >= OffsetX && + item.Bounds.X - OffsetX < this.Bounds.Width)// skip invisible nodes (fixed by wj32) + { + context.Bounds = item.Bounds; + context.Graphics.SetClip(context.Bounds); + item.Control.Draw(node, context); + context.Graphics.ResetClip(); + } + } + } + + private void DrawScrollBarsBox(Graphics gr) + { + Rectangle r1 = DisplayRectangle; + Rectangle r2 = ClientRectangle; + gr.FillRectangle(SystemBrushes.Control, + new Rectangle(r1.Right, r1.Bottom, r2.Width - r1.Width, r2.Height - r1.Height)); + } + + private void DrawDropMark(Graphics gr) + { + if (_dropPosition.Position == NodePosition.Inside) + return; + + Rectangle rect = GetNodeBounds(_dropPosition.Node); + int right = DisplayRectangle.Right - LeftMargin + OffsetX; + int y = rect.Y; + if (_dropPosition.Position == NodePosition.After) + y = rect.Bottom; + gr.DrawLine(_markPen, rect.X, y, right, y); + } + + private void DrawLines(Graphics gr, TreeNodeAdv node, Rectangle rowRect) + { + if (UseColumns && Columns.Count > 0) + gr.SetClip(new Rectangle(0, rowRect.Y, Columns[0].Width, rowRect.Bottom)); + + TreeNodeAdv curNode = node; + while (curNode != _root && curNode != null) + { + int level = curNode.Level; + int x = (level - 1) * _indent + NodePlusMinus.ImageSize / 2 + LeftMargin; + int width = NodePlusMinus.Width - NodePlusMinus.ImageSize / 2; + int y = rowRect.Y; + int y2 = y + rowRect.Height; + + if (curNode == node) + { + int midy = y + rowRect.Height / 2; + gr.DrawLine(_linePen, x, midy, x + width, midy); + if (curNode.NextNode == null) + y2 = y + rowRect.Height / 2; + } + + if (node.Row == 0) + y = rowRect.Height / 2; + if (curNode.NextNode != null || curNode == node) + gr.DrawLine(_linePen, x, y, x, y2); + + curNode = curNode.Parent; + } + + gr.ResetClip(); + } + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Input.cs b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Input.cs similarity index 50% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Input.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Input.cs index f4af2aad3..24eff6ddc 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.Input.cs +++ b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Input.cs @@ -9,7 +9,7 @@ namespace Aga.Controls.Tree { - public sealed partial class TreeViewAdv + public partial class TreeViewAdv { // Note by wj32: I've added a whole bunch of this.Invalidate()s that are necessary for PH. #region Keys @@ -34,18 +34,18 @@ internal void ChangeInput() { if ((ModifierKeys & Keys.Shift) == Keys.Shift) { - if (!(this.Input is InputWithShift)) - this.Input = new InputWithShift(this); + if (!(Input is InputWithShift)) + Input = new InputWithShift(this); } else if ((ModifierKeys & Keys.Control) == Keys.Control) { - if (!(this.Input is InputWithControl)) - this.Input = new InputWithControl(this); + if (!(Input is InputWithControl)) + Input = new InputWithControl(this); } else { - if (!(this.Input.GetType() == typeof(NormalInputState))) - this.Input = new NormalInputState(this); + if (!(Input.GetType() == typeof(NormalInputState))) + Input = new NormalInputState(this); } } @@ -56,10 +56,10 @@ protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.ControlKey) ChangeInput(); - this.Input.KeyDown(e); + Input.KeyDown(e); if (!e.Handled) { - foreach (NodeControlInfo item in GetNodeControls(this.CurrentNode)) + foreach (NodeControlInfo item in GetNodeControls(CurrentNode)) { item.Control.KeyDown(e); if (e.Handled) @@ -79,7 +79,7 @@ protected override void OnKeyUp(KeyEventArgs e) ChangeInput(); if (!e.Handled) { - foreach (NodeControlInfo item in GetNodeControls(this.CurrentNode)) + foreach (NodeControlInfo item in GetNodeControls(CurrentNode)) { item.Control.KeyUp(e); if (e.Handled) @@ -105,7 +105,7 @@ private TreeNodeAdvMouseEventArgs CreateMouseArgs(MouseEventArgs e) { TreeNodeAdvMouseEventArgs args = new TreeNodeAdvMouseEventArgs(e); args.ViewLocation = new Point(e.X + OffsetX, - e.Y + _rowLayout.GetRowBounds(FirstVisibleRow).Y - this.ColumnHeaderHeight); + e.Y + _rowLayout.GetRowBounds(FirstVisibleRow).Y - ColumnHeaderHeight); args.ModifierKeys = ModifierKeys; args.Node = GetNodeAt(e.Location); NodeControlInfo info = GetNodeControlInfoAt(args.Node, e.Location); @@ -141,14 +141,14 @@ protected override void OnMouseDown(MouseEventArgs e) c = GetColumnDividerAt(e.Location); if (c != null) { - this.Input = new ResizeColumnState(this, c, e.Location); + Input = new ResizeColumnState(this, c, e.Location); this.Invalidate(); return; } c = GetColumnAt(e.Location); if (c != null) { - this.Input = new ClickColumnState(this, c, e.Location); + Input = new ClickColumnState(this, c, e.Location); UpdateView(); this.Invalidate(); return; @@ -162,7 +162,7 @@ protected override void OnMouseDown(MouseEventArgs e) args.Control.MouseDown(args); if (!args.Handled) - this.Input.MouseDown(args); + Input.MouseDown(args); base.OnMouseDown(e); this.Invalidate(); @@ -170,13 +170,12 @@ protected override void OnMouseDown(MouseEventArgs e) protected override void OnMouseClick(MouseEventArgs e) { + //TODO: Disable when click on plusminus icon TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); - - if (args.Node != null) + if (args.Node != null) OnNodeMouseClick(args); base.OnMouseClick(e); - this.FullUpdate(); this.Invalidate(); } @@ -190,6 +189,10 @@ protected override void OnMouseDoubleClick(MouseEventArgs e) if (!args.Handled) { + // disabled by wj32 - I think this behaviour sucks. + //if (args.Node != null && args.Button == MouseButtons.Left) + // args.Node.IsExpanded = !args.Node.IsExpanded; + if (args.Node != null) OnNodeMouseDoubleClick(args); } @@ -200,32 +203,34 @@ protected override void OnMouseDoubleClick(MouseEventArgs e) protected override void OnMouseUp(MouseEventArgs e) { TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); - - if (this.Input is ResizeColumnState) - this.Input.MouseUp(args); + if (Input is ResizeColumnState) + Input.MouseUp(args); else { if (args.Node != null && args.Control != null) args.Control.MouseUp(args); - - if (!args.Handled) - this.Input.MouseUp(args); + if (!args.Handled) + Input.MouseUp(args); base.OnMouseUp(e); } } - protected override void OnMouseMove(MouseEventArgs e) { - if (this.Input.MouseMove(e)) + if (Input.MouseMove(e)) return; base.OnMouseMove(e); - SetCursor(e); - UpdateToolTip(e); + if (ItemDragMode && Dist(e.Location, ItemDragStart) > ItemDragSensivity + && CurrentNode != null && CurrentNode.IsSelected) + { + ItemDragMode = false; + _toolTip.Active = false; + OnItemDrag(e.Button, Selection.ToArray()); + } } protected override void OnMouseLeave(EventArgs e) @@ -237,50 +242,39 @@ protected override void OnMouseLeave(EventArgs e) private void SetCursor(MouseEventArgs e) { - using (TreeColumn col = this.GetColumnDividerAt(e.Location)) - { - if (col == null) - this._innerCursor = null; - else - { - switch (col.Width) - { - case 0: - this._innerCursor = Cursors.VSplit; - break; - default: - this._innerCursor = Cursors.VSplit; - break; - } - } - - //col = this.GetColumnAt(e.Location); - - if (col != this._hotColumn) - { - this._hotColumn = col; - - this.UpdateHeaders(); - } - } + TreeColumn col; + col = GetColumnDividerAt(e.Location); + if (col == null) + _innerCursor = null; + else + { + if (col.Width == 0) + _innerCursor = ResourceHelper.DVSplitCursor; + else + _innerCursor = Cursors.VSplit; + } + + col = GetColumnAt(e.Location); + if (col != _hotColumn) + { + _hotColumn = col; + UpdateHeaders(); + } } internal TreeColumn GetColumnAt(Point p) { - if (p.Y > this.ColumnHeaderHeight) + if (p.Y > ColumnHeaderHeight) return null; int x = -OffsetX; - - foreach (TreeColumn col in this.Columns) + foreach (TreeColumn col in Columns) { if (col.IsVisible) { - Rectangle rect = new Rectangle(x, 0, col.Width, this.ColumnHeaderHeight); - - x += col.Width; - - if (rect.Contains(p)) + Rectangle rect = new Rectangle(x, 0, col.Width, ColumnHeaderHeight); + x += col.Width; + if (rect.Contains(p)) return col; } } @@ -290,14 +284,14 @@ internal TreeColumn GetColumnAt(Point p) internal int GetColumnX(TreeColumn column) { int x = -OffsetX; - foreach (TreeColumn col in this.Columns) + foreach (TreeColumn col in Columns) { if (col.IsVisible) { - if (column == col) + if (column == col) return x; - - x += col.Width; + else + x += col.Width; } } return x; @@ -305,23 +299,21 @@ internal int GetColumnX(TreeColumn column) internal TreeColumn GetColumnDividerAt(Point p) { - if (p.Y > this.ColumnHeaderHeight) + if (p.Y > ColumnHeaderHeight) return null; int x = -OffsetX; TreeColumn prevCol = null; Rectangle left, right; - - foreach (TreeColumn col in this.Columns) + foreach (TreeColumn col in Columns) { if (col.IsVisible) { if (col.Width > 0) { - left = new Rectangle(x, 0, DividerWidth / 2, this.ColumnHeaderHeight); - right = new Rectangle(x + col.Width - (DividerWidth / 2), 0, DividerWidth / 2, this.ColumnHeaderHeight); - - if (left.Contains(p) && prevCol != null) + left = new Rectangle(x, 0, DividerWidth / 2, ColumnHeaderHeight); + right = new Rectangle(x + col.Width - (DividerWidth / 2), 0, DividerWidth / 2, ColumnHeaderHeight); + if (left.Contains(p) && prevCol != null) return prevCol; else if (right.Contains(p)) return col; @@ -331,9 +323,8 @@ internal TreeColumn GetColumnDividerAt(Point p) } } - left = new Rectangle(x, 0, DividerWidth / 2, this.ColumnHeaderHeight); - - if (left.Contains(p) && prevCol != null) + left = new Rectangle(x, 0, DividerWidth / 2, ColumnHeaderHeight); + if (left.Contains(p) && prevCol != null) return prevCol; return null; @@ -355,10 +346,9 @@ private void UpdateToolTip(MouseEventArgs e) TreeNodeAdv _hotNode; NodeControl _hotControl; - private void DisplayNodesTooltip(MouseEventArgs e) { - if (this.ShowNodeToolTips) + if (ShowNodeToolTips) { TreeNodeAdvMouseEventArgs args = CreateMouseArgs(e); if (args.Node != null && args.Control != null) @@ -401,12 +391,166 @@ private string GetNodeToolTip(TreeNodeAdvMouseEventArgs args) msg = btc.GetLabel(args.Node); } - if (String.IsNullOrEmpty(msg) && this.DefaultToolTipProvider != null) - msg = this.DefaultToolTipProvider.GetToolTip(args.Node, args.Control); + if (String.IsNullOrEmpty(msg) && DefaultToolTipProvider != null) + msg = DefaultToolTipProvider.GetToolTip(args.Node, args.Control); return msg; } #endregion + + #region DragDrop + + private bool _dragAutoScrollFlag = false; + private Bitmap _dragBitmap = null; + private System.Threading.Timer _dragTimer; + + private void StartDragTimer() + { + if (_dragTimer == null) + _dragTimer = new System.Threading.Timer(new TimerCallback(DragTimerTick), null, 0, 100); + } + + private void StopDragTimer() + { + if (_dragTimer != null) + { + _dragTimer.Dispose(); + _dragTimer = null; + } + } + + private void SetDropPosition(Point pt) + { + TreeNodeAdv node = GetNodeAt(pt); + _dropPosition.Node = node; + if (node != null) + { + Rectangle first = _rowLayout.GetRowBounds(FirstVisibleRow); + Rectangle bounds = _rowLayout.GetRowBounds(node.Row); + float pos = (pt.Y + first.Y - ColumnHeaderHeight - bounds.Y) / (float)bounds.Height; + if (pos < TopEdgeSensivity) + _dropPosition.Position = NodePosition.Before; + else if (pos > (1 - BottomEdgeSensivity)) + _dropPosition.Position = NodePosition.After; + else + _dropPosition.Position = NodePosition.Inside; + } + } + + private void DragTimerTick(object state) + { + _dragAutoScrollFlag = true; + } + + private void DragAutoScroll() + { + _dragAutoScrollFlag = false; + Point pt = PointToClient(MousePosition); + if (pt.Y < 20 && _vScrollBar.Value > 0) + _vScrollBar.Value--; + else if (pt.Y > Height - 20 && _vScrollBar.Value <= _vScrollBar.Maximum - _vScrollBar.LargeChange) + _vScrollBar.Value++; + } + + public void DoDragDropSelectedNodes(DragDropEffects allowedEffects) + { + if (SelectedNodes.Count > 0) + { + TreeNodeAdv[] nodes = new TreeNodeAdv[SelectedNodes.Count]; + SelectedNodes.CopyTo(nodes, 0); + DoDragDrop(nodes, allowedEffects); + } + } + + private void CreateDragBitmap(IDataObject data) + { + if (UseColumns || !DisplayDraggingNodes) + return; + + TreeNodeAdv[] nodes = data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[]; + if (nodes != null && nodes.Length > 0) + { + Rectangle rect = DisplayRectangle; + Bitmap bitmap = new Bitmap(rect.Width, rect.Height); + using (Graphics gr = Graphics.FromImage(bitmap)) + { + gr.Clear(BackColor); + DrawContext context = new DrawContext(); + context.Graphics = gr; + context.Font = Font; + context.Enabled = true; + int y = 0; + int maxWidth = 0; + foreach (TreeNodeAdv node in nodes) + { + if (node.Tree == this) + { + int x = 0; + int height = _rowLayout.GetRowBounds(node.Row).Height; + foreach (NodeControl c in NodeControls) + { + Size s = c.GetActualSize(node, context); + if (!s.IsEmpty) + { + int width = s.Width; + rect = new Rectangle(x, y, width, height); + x += (width + 1); + context.Bounds = rect; + c.Draw(node, context); + } + } + y += height; + maxWidth = Math.Max(maxWidth, x); + } + } + + if (maxWidth > 0 && y > 0) + { + _dragBitmap = new Bitmap(maxWidth, y, PixelFormat.Format32bppArgb); + using (Graphics tgr = Graphics.FromImage(_dragBitmap)) + tgr.DrawImage(bitmap, Point.Empty); + BitmapHelper.SetAlphaChanelValue(_dragBitmap, 150); + } + else + _dragBitmap = null; + } + } + } + + protected override void OnDragOver(DragEventArgs drgevent) + { + ItemDragMode = false; + Point pt = PointToClient(new Point(drgevent.X, drgevent.Y)); + if (_dragAutoScrollFlag) + DragAutoScroll(); + SetDropPosition(pt); + UpdateView(); + base.OnDragOver(drgevent); + } + + protected override void OnDragEnter(DragEventArgs drgevent) + { + _search.EndSearch(); + DragMode = true; + CreateDragBitmap(drgevent.Data); + base.OnDragEnter(drgevent); + } + + protected override void OnDragLeave(EventArgs e) + { + DragMode = false; + UpdateView(); + base.OnDragLeave(e); + } + + protected override void OnDragDrop(DragEventArgs drgevent) + { + DragMode = false; + UpdateView(); + base.OnDragDrop(drgevent); + } + + #endregion } } diff --git a/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Properties.cs b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Properties.cs new file mode 100644 index 000000000..8a7ef7cdf --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.Properties.cs @@ -0,0 +1,691 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; +using System.Collections.ObjectModel; +using System.Drawing.Design; + +using Aga.Controls.Tree.NodeControls; + +namespace Aga.Controls.Tree +{ + public partial class TreeViewAdv + { + private Cursor _innerCursor = null; + + public override Cursor Cursor + { + get + { + if (_innerCursor != null) + return _innerCursor; + else + return base.Cursor; + } + set + { + base.Cursor = value; + } + } + + #region Internal Properties + + private IRowLayout _rowLayout; + + private bool _dragMode; + private bool DragMode + { + get { return _dragMode; } + set + { + _dragMode = value; + if (!value) + { + StopDragTimer(); + if (_dragBitmap != null) + _dragBitmap.Dispose(); + _dragBitmap = null; + } + else + StartDragTimer(); + } + } + + public int ColumnHeaderHeight + { + get + { + if (UseColumns) + return _columnHeaderHeight; + else + return 0; + } + } + + /// + /// returns all nodes, which parent is expanded + /// + private IEnumerable VisibleNodes + { + get + { + TreeNodeAdv node = Root; + while (node != null) + { + node = node.NextVisibleNode; + if (node != null) + yield return node; + } + } + } + + private bool _suspendSelectionEvent; + internal bool SuspendSelectionEvent + { + get { return _suspendSelectionEvent; } + set + { + if (value != _suspendSelectionEvent) + { + _suspendSelectionEvent = value; + if (!_suspendSelectionEvent && _fireSelectionEvent) + OnSelectionChanged(); + } + } + } + + private List _rowMap; + internal List RowMap + { + get { return _rowMap; } + } + + private TreeNodeAdv _selectionStart; + internal TreeNodeAdv SelectionStart + { + get { return _selectionStart; } + set { _selectionStart = value; } + } + + private InputState _input; + internal InputState Input + { + get { return _input; } + set + { + _input = value; + } + } + + private bool _itemDragMode; + internal bool ItemDragMode + { + get { return _itemDragMode; } + set { _itemDragMode = value; } + } + + private Point _itemDragStart; + internal Point ItemDragStart + { + get { return _itemDragStart; } + set { _itemDragStart = value; } + } + + + /// + /// Number of rows fits to the current page + /// + internal int CurrentPageSize + { + get + { + return _rowLayout.CurrentPageSize; + } + } + + /// + /// Number of all visible nodes (which parent is expanded) + /// + internal int RowCount + { + get + { + return RowMap.Count; + } + } + + private int _contentWidth = 0; + private int ContentWidth + { + get + { + return _contentWidth; + } + } + + private int _firstVisibleRow; + internal int FirstVisibleRow + { + get { return _firstVisibleRow; } + set + { + HideEditor(); + _firstVisibleRow = value; + UpdateView(); + } + } + + private int _offsetX; + internal int OffsetX + { + get { return _offsetX; } + private set + { + HideEditor(); + _offsetX = value; + UpdateView(); + } + } + + public override Rectangle DisplayRectangle + { + get + { + Rectangle r = ClientRectangle; + //r.Y += ColumnHeaderHeight; + //r.Height -= ColumnHeaderHeight; + int w = _vScrollBar.Visible ? _vScrollBar.Width : 0; + int h = _hScrollBar.Visible ? _hScrollBar.Height : 0; + return new Rectangle(r.X, r.Y, r.Width - w, r.Height - h); + } + } + + private List _selection; + internal List Selection + { + get { return _selection; } + } + + #endregion + + #region Public Properties + + #region DesignTime + + private bool _displayDraggingNodes; + [DefaultValue(false), Category("Behavior")] + public bool DisplayDraggingNodes + { + get { return _displayDraggingNodes; } + set { _displayDraggingNodes = value; } + } + + private bool _fullRowSelect; + [DefaultValue(false), Category("Behavior")] + public bool FullRowSelect + { + get { return _fullRowSelect; } + set + { + _fullRowSelect = value; + UpdateView(); + } + } + + private bool _useColumns; + [DefaultValue(false), Category("Behavior")] + public bool UseColumns + { + get { return _useColumns; } + set + { + _useColumns = value; + FullUpdate(); + } + } + + private bool _allowColumnReorder; + [DefaultValue(false), Category("Behavior")] + public bool AllowColumnReorder + { + get { return _allowColumnReorder; } + set { _allowColumnReorder = value; } + } + + private bool _showLines = true; + [DefaultValue(true), Category("Behavior")] + public bool ShowLines + { + get { return _showLines; } + set + { + _showLines = value; + UpdateView(); + } + } + + private bool _showPlusMinus = true; + [DefaultValue(true), Category("Behavior")] + public bool ShowPlusMinus + { + get { return _showPlusMinus; } + set + { + _showPlusMinus = value; + FullUpdate(); + } + } + + private bool _showNodeToolTips = false; + [DefaultValue(false), Category("Behavior")] + public bool ShowNodeToolTips + { + get { return _showNodeToolTips; } + set { _showNodeToolTips = value; } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic"), DefaultValue(true), Category("Behavior"), Obsolete("No longer used")] + public bool KeepNodesExpanded + { + get { return true; } + set {} + } + + private ITreeModel _model; + [Category("Data")] + public ITreeModel Model + { + get { return _model; } + set + { + if (_model != value) + { + AbortBackgroundExpandingThreads(); + if (_model != null) + UnbindModelEvents(); + _model = value; + CreateNodes(); + FullUpdate(); + if (_model != null) + BindModelEvents(); + } + } + } + + // Font proprety for Tahoma as default font + // wj32: Apparently some people don't have Tahoma... + //private static Font _font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)), false); + private static Font _font = System.Windows.Forms.Control.DefaultFont; + [Category("Appearance")] + public override Font Font + { + get + { + return (base.Font); + } + set + { + if (value == null) + base.Font = _font; + else + { + if (value == System.Windows.Forms.Control.DefaultFont) + base.Font = _font; + else + base.Font = value; + } + } + } + public override void ResetFont() + { + Font = null; + } + private bool ShouldSerializeFont() + { + return (!Font.Equals(_font)); + } + // End font property + + private BorderStyle _borderStyle = BorderStyle.Fixed3D; + [DefaultValue(BorderStyle.Fixed3D), Category("Appearance")] + public BorderStyle BorderStyle + { + get + { + return this._borderStyle; + } + set + { + if (_borderStyle != value) + { + _borderStyle = value; + this.RecreateHandle(); + this.Invalidate(); + } + } + } + + private bool _autoRowHeight = false; + [DefaultValue(false), Category("Appearance")] + public bool AutoRowHeight + { + get + { + return _autoRowHeight; + } + set + { + _autoRowHeight = value; + if (value) + _rowLayout = new AutoRowHeightLayout(this, RowHeight); + else + _rowLayout = new FixedRowHeightLayout(this, RowHeight); + FullUpdate(); + } + } + + private GridLineStyle _gridLineStyle = GridLineStyle.None; + [DefaultValue(GridLineStyle.None), Category("Appearance")] + public GridLineStyle GridLineStyle + { + get + { + return _gridLineStyle; + } + set + { + if (value != _gridLineStyle) + { + _gridLineStyle = value; + UpdateView(); + OnGridLineStyleChanged(); + } + } + } + + private int _rowHeight = 16; + [DefaultValue(16), Category("Appearance")] + public int RowHeight + { + get + { + return _rowHeight; + } + set + { + if (value <= 0) + throw new ArgumentOutOfRangeException("value"); + + _rowHeight = value; + _rowLayout.PreferredRowHeight = value; + FullUpdate(); + } + } + + private TreeSelectionMode _selectionMode = TreeSelectionMode.Single; + [DefaultValue(TreeSelectionMode.Single), Category("Behavior")] + public TreeSelectionMode SelectionMode + { + get { return _selectionMode; } + set { _selectionMode = value; } + } + + private bool _hideSelection; + [DefaultValue(false), Category("Behavior")] + public bool HideSelection + { + get { return _hideSelection; } + set + { + _hideSelection = value; + UpdateView(); + } + } + + private float _topEdgeSensivity = 0.3f; + [DefaultValue(0.3f), Category("Behavior")] + public float TopEdgeSensivity + { + get { return _topEdgeSensivity; } + set + { + if (value < 0 || value > 1) + throw new ArgumentOutOfRangeException(); + _topEdgeSensivity = value; + } + } + + private float _bottomEdgeSensivity = 0.3f; + [DefaultValue(0.3f), Category("Behavior")] + public float BottomEdgeSensivity + { + get { return _bottomEdgeSensivity; } + set + { + if (value < 0 || value > 1) + throw new ArgumentOutOfRangeException("value should be from 0 to 1"); + _bottomEdgeSensivity = value; + } + } + + private bool _loadOnDemand; + [DefaultValue(false), Category("Behavior")] + public bool LoadOnDemand + { + get { return _loadOnDemand; } + set { _loadOnDemand = value; } + } + + private int _indent = 19; + [DefaultValue(19), Category("Behavior")] + public int Indent + { + get { return _indent; } + set + { + _indent = value; + UpdateView(); + } + } + + private Color _lineColor = SystemColors.ControlDark; + [Category("Behavior")] + public Color LineColor + { + get { return _lineColor; } + set + { + _lineColor = value; + CreateLinePen(); + UpdateView(); + } + } + + private Color _dragDropMarkColor = Color.Black; + [Category("Behavior")] + public Color DragDropMarkColor + { + get { return _dragDropMarkColor; } + set + { + _dragDropMarkColor = value; + CreateMarkPen(); + } + } + + private float _dragDropMarkWidth = 3.0f; + [DefaultValue(3.0f), Category("Behavior")] + public float DragDropMarkWidth + { + get { return _dragDropMarkWidth; } + set + { + _dragDropMarkWidth = value; + CreateMarkPen(); + } + } + + private bool _highlightDropPosition = true; + [DefaultValue(true), Category("Behavior")] + public bool HighlightDropPosition + { + get { return _highlightDropPosition; } + set { _highlightDropPosition = value; } + } + + private TreeColumnCollection _columns; + [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public Collection Columns + { + get { return _columns; } + } + + private NodeControlsCollection _controls; + [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + [Editor(typeof(NodeControlCollectionEditor), typeof(UITypeEditor))] + public Collection NodeControls + { + get + { + return _controls; + } + } + + private bool _asyncExpanding; + /// + /// When set to true, node contents will be read in background thread + /// + [Category("Behavior")] + [DefaultValue(false)] + public bool AsyncExpanding + { + get { return _asyncExpanding; } + set { _asyncExpanding = value; } + } + + #endregion + + #region RunTime + + private IToolTipProvider _defaultToolTipProvider = null; + [Browsable(false)] + public IToolTipProvider DefaultToolTipProvider + { + get { return _defaultToolTipProvider; } + set { _defaultToolTipProvider = value; } + } + + [Browsable(false)] + public IEnumerable AllNodes + { + get + { + if (_root.Nodes.Count > 0) + { + TreeNodeAdv node = _root.Nodes[0]; + while (node != null) + { + yield return node; + if (node.Nodes.Count > 0) + node = node.Nodes[0]; + else if (node.NextNode != null) + node = node.NextNode; + else + node = node.BottomNode; + } + } + } + } + + private DropPosition _dropPosition; + [Browsable(false)] + public DropPosition DropPosition + { + get { return _dropPosition; } + set { _dropPosition = value; } + } + + private TreeNodeAdv _root; + [Browsable(false)] + public TreeNodeAdv Root + { + get { return _root; } + } + + private ReadOnlyCollection _readonlySelection; + [Browsable(false)] + public ReadOnlyCollection SelectedNodes + { + get + { + return _readonlySelection; + } + } + + [Browsable(false)] + public TreeNodeAdv SelectedNode + { + get + { + if (Selection.Count > 0) + { + if (CurrentNode != null && CurrentNode.IsSelected) + return CurrentNode; + else + return Selection[0]; + } + else + return null; + } + set + { + if (SelectedNode == value) + return; + + BeginUpdate(); + try + { + if (value == null) + { + ClearSelectionInternal(); + } + else + { + if (!IsMyNode(value)) + throw new ArgumentException(); + + ClearSelectionInternal(); + value.IsSelected = true; + CurrentNode = value; + EnsureVisible(value); + } + } + finally + { + EndUpdate(); + } + } + } + + private TreeNodeAdv _currentNode; + [Browsable(false)] + public TreeNodeAdv CurrentNode + { + get { return _currentNode; } + internal set { _currentNode = value; } + } + + [Browsable(false)] + public int ItemCount + { + get { return RowMap.Count; } + } + + #endregion + + #endregion + + } +} diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.cs b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.cs similarity index 59% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.cs index ef72bb82b..298bf8caa 100644 --- a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.cs +++ b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.cs @@ -9,22 +9,25 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing; +using System.Security.Permissions; +using System.Threading; using System.Windows.Forms; +using Aga.Controls.Threading; using Aga.Controls.Tree.NodeControls; -using ProcessHacker; -using ProcessHacker.Common; -using ProcessHacker.Native; namespace Aga.Controls.Tree { - public sealed partial class TreeViewAdv : Control + public partial class TreeViewAdv : Control { private const int LeftMargin = 7; internal const int ItemDragSensivity = 4; - private const int DividerWidth = 9; + private readonly int _columnHeaderHeight; + private const int DividerWidth = 9; + private const int DividerCorrectionGap = -2; - private Pen _linePen; + private Pen _linePen; + private Pen _markPen; private bool _suspendUpdate; private bool _completeSuspendUpdate; // Overrides my (wj32's) hacks private bool _needFullUpdate; @@ -34,12 +37,22 @@ public sealed partial class TreeViewAdv : Control private EditableControl _currentEditorOwner; private ToolTip _toolTip; private DrawContext _measureContext; - private TreeColumn _hotColumn; + private TreeColumn _hotColumn = null; private IncrementalSearch _search; + private List _expandingNodes = new List(); + private AbortableThreadPool _threadPool = new AbortableThreadPool(); private Stack _suspendedStack = new Stack(); #region Public Events + [Category("Action")] + public event ItemDragEventHandler ItemDrag; + private void OnItemDrag(MouseButtons buttons, object item) + { + if (ItemDrag != null) + ItemDrag(this, new ItemDragEventArgs(buttons, item)); + } + [Category("Behavior")] public event EventHandler NodeMouseClick; private void OnNodeMouseClick(TreeNodeAdvMouseEventArgs args) @@ -145,66 +158,100 @@ private void OnGridLineStyleChanged() public TreeViewAdv() { InitializeComponent(); + SetStyle(ControlStyles.AllPaintingInWmPaint + | ControlStyles.UserPaint + | ControlStyles.OptimizedDoubleBuffer + | ControlStyles.ResizeRedraw + | ControlStyles.Selectable + , true); - this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.Selectable | ControlStyles.CacheText, true); - if (OSVersion.IsBelow(WindowsVersion.Vista)) + if (Environment.OSVersion.Version.Major < 6) { - this.ColumnHeaderHeight = ExplorerVisualStyle.VisualStylesEnabled ? 20 : 17; + if (Application.RenderWithVisualStyles) + _columnHeaderHeight = 20; + else + _columnHeaderHeight = 17; } else { - this.ColumnHeaderHeight = ExplorerVisualStyle.VisualStylesEnabled ? 25 : 17; + if (Application.RenderWithVisualStyles) + _columnHeaderHeight = 25; + else + _columnHeaderHeight = 17; } //BorderStyle = BorderStyle.Fixed3D; _hScrollBar.Height = SystemInformation.HorizontalScrollBarHeight; _vScrollBar.Width = SystemInformation.VerticalScrollBarWidth; - _rowLayout = new FixedRowHeightLayout(this, RowHeight); - this.RowMap = new List(); - this.Selection = new List(); - this.SelectedNodes = new ReadOnlyCollection(this.Selection); - this.Columns = new TreeColumnCollection(this); + _rowMap = new List(); + _selection = new List(); + _readonlySelection = new ReadOnlyCollection(_selection); + _columns = new TreeColumnCollection(this); _toolTip = new ToolTip(); - _measureContext = new DrawContext - { - Font = this.Font, - Graphics = Graphics.FromImage(new Bitmap(1, 1)) - }; + _measureContext = new DrawContext(); + _measureContext.Font = Font; + _measureContext.Graphics = Graphics.FromImage(new Bitmap(1, 1)); - this.Input = new NormalInputState(this); + Input = new NormalInputState(this); _search = new IncrementalSearch(this); - CreateNodes(); CreatePens(); ArrangeControls(); _plusMinus = new NodePlusMinus(this); - this.NodeControls = new NodeControlsCollection(this); + _controls = new NodeControlsCollection(this); Font = _font; + ExpandingIcon.IconChanged += ExpandingIconChanged; + } + + void ExpandingIconChanged(object sender, EventArgs e) + { + if (IsHandleCreated) + Invoke(new MethodInvoker(DrawIcons)); + } + + private void DrawIcons() + { + Graphics gr = Graphics.FromHwnd(this.Handle); + int firstRowY = _rowLayout.GetRowBounds(FirstVisibleRow).Y; + DrawContext context = new DrawContext(); + context.Graphics = gr; + for (int i = 0; i < _expandingNodes.Count; i++) + { + foreach (NodeControlInfo info in GetNodeControls(_expandingNodes[i])) + if (info.Control is ExpandingIcon) + { + Rectangle rect = info.Bounds; + rect.X -= OffsetX; + rect.Y -= firstRowY; + context.Bounds = rect; + info.Control.Draw(info.Node, context); + } + } + gr.Dispose(); } #region Public Methods public TreePath GetPath(TreeNodeAdv node) { - if (node == this.Root) + if (node == _root) return TreePath.Empty; - - Stack stack = new Stack(); - - while (node != this.Root && node != null) - { - stack.Push(node.Tag); - - node = node.Parent; - } - - return new TreePath(stack.ToArray()); + else + { + Stack stack = new Stack(); + while (node != _root && node != null) + { + stack.Push(node.Tag); + node = node.Parent; + } + return new TreePath(stack.ToArray()); + } } public TreeNodeAdv GetNodeAt(Point point) @@ -219,29 +266,28 @@ public NodeControlInfo GetNodeControlInfoAt(Point point) return NodeControlInfo.Empty; int row = _rowLayout.GetRowAt(point); - - if (row < RowCount && row >= 0) - return GetNodeControlInfoAt(this.RowMap[row], point); - - return NodeControlInfo.Empty; + if (row < RowCount && row >= 0) + return GetNodeControlInfoAt(RowMap[row], point); + else + return NodeControlInfo.Empty; } private NodeControlInfo GetNodeControlInfoAt(TreeNodeAdv node, Point point) { - Rectangle rect = _rowLayout.GetRowBounds(FirstVisibleRow); - point.Y += (rect.Y - this.ColumnHeaderHeight); - point.X += OffsetX; - - foreach (NodeControlInfo info in GetNodeControls(node)) - { - if (info.Bounds.Contains(point)) - return info; - } + Rectangle rect = _rowLayout.GetRowBounds(FirstVisibleRow); + point.Y += (rect.Y - ColumnHeaderHeight); + point.X += OffsetX; + foreach (NodeControlInfo info in GetNodeControls(node)) + if (info.Bounds.Contains(point)) + return info; - return new NodeControlInfo(null, Rectangle.Empty, node); + if (FullRowSelect) + return new NodeControlInfo(null, Rectangle.Empty, node); + else + return NodeControlInfo.Empty; } - public void BeginUpdate() + public void BeginUpdate() { _suspendedStack.Push(_suspendUpdate); _suspendUpdate = true; @@ -272,12 +318,12 @@ public void EndCompleteUpdate() public void ExpandAll() { - this.Root.ExpandAll(); + _root.ExpandAll(); } public void CollapseAll() { - this.Root.CollapseAll(); + _root.CollapseAll(); } /// @@ -292,13 +338,11 @@ public void EnsureVisible(TreeNodeAdv node) throw new ArgumentException(); TreeNodeAdv parent = node.Parent; - - while (parent != this.Root) + while (parent != _root) { parent.IsExpanded = true; parent = parent.Parent; } - ScrollTo(node); } @@ -327,7 +371,7 @@ public void ScrollTo(TreeNodeAdv node) { int pageStart = _rowLayout.GetRowBounds(FirstVisibleRow).Top; int rowBottom = _rowLayout.GetRowBounds(node.Row).Bottom; - if (rowBottom > pageStart + DisplayRectangle.Height - this.ColumnHeaderHeight) + if (rowBottom > pageStart + DisplayRectangle.Height - ColumnHeaderHeight) row = _rowLayout.GetFirstRow(node.Row); } @@ -363,7 +407,7 @@ public void ScrollTo2(TreeNodeAdv node) { int pageStart = _rowLayout.GetRowBounds(FirstVisibleRow).Top; int rowBottom = _rowLayout.GetRowBounds(node.Row).Bottom; - if (rowBottom > pageStart + DisplayRectangle.Height - this.ColumnHeaderHeight) + if (rowBottom > pageStart + DisplayRectangle.Height - ColumnHeaderHeight) row = _rowLayout.GetFirstRow(node.Row); // Ugh, who wants the node at the BOTTOM of the screen? Put it in the MIDDLE! @@ -381,7 +425,6 @@ public void ScrollTo2(TreeNodeAdv node) public void ClearSelection() { BeginUpdate(); - try { ClearSelectionInternal(); @@ -394,8 +437,8 @@ public void ClearSelection() internal void ClearSelectionInternal() { - while (this.Selection.Count > 0) - this.Selection[0].IsSelected = false; + while (Selection.Count > 0) + Selection[0].IsSelected = false; } #endregion @@ -404,9 +447,7 @@ protected override void OnSizeChanged(EventArgs e) { ArrangeControls(); SafeUpdateScrollBars(); - base.OnSizeChanged(e); - this.Invalidate(); } @@ -425,7 +466,10 @@ private void ArrangeControls() private void SafeUpdateScrollBars() { - this.UpdateScrollBars(); + if (InvokeRequired) + Invoke(new MethodInvoker(UpdateScrollBars)); + else + UpdateScrollBars(); } private void UpdateScrollBars() @@ -440,7 +484,7 @@ private void UpdateScrollBars() private void UpdateHScrollBar() { - _hScrollBar.Maximum = this.ContentWidth; + _hScrollBar.Maximum = ContentWidth; _hScrollBar.LargeChange = Math.Max(DisplayRectangle.Width, 0); _hScrollBar.SmallChange = 5; _hScrollBar.Visible = _hScrollBar.LargeChange < _hScrollBar.Maximum; @@ -457,22 +501,18 @@ private void UpdateVScrollBar() protected override CreateParams CreateParams { + [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] get { CreateParams res = base.CreateParams; - - switch (this.BorderStyle) + switch (BorderStyle) { - case BorderStyle.FixedSingle: - { - res.Style |= 0x800000; - break; - } + case BorderStyle.FixedSingle: + res.Style |= 0x800000; + break; case BorderStyle.Fixed3D: - { - res.ExStyle |= 0x20000; - break; - } + res.ExStyle |= 0x20000; + break; } return res; } @@ -483,7 +523,6 @@ protected override void OnGotFocus(EventArgs e) HideEditor(); UpdateView(); ChangeInput(); - base.OnGotFocus(e); } @@ -491,36 +530,32 @@ protected override void OnLeave(EventArgs e) { if (_currentEditorOwner != null) _currentEditorOwner.ApplyChanges(); - - HideEditor(); + HideEditor(); UpdateView(); - base.OnLeave(e); } protected override void OnFontChanged(EventArgs e) { base.OnFontChanged(e); - _measureContext.Font = Font; FullUpdate(); } - private Dictionary> _cachedNodeControls = new Dictionary>(); + private Dictionary> _cachedNodeControls = + new Dictionary>(); internal IEnumerable GetNodeControls(TreeNodeAdv node) { if (node == null) - return new List(); + return new List(); if (!_cachedNodeControls.ContainsKey(node)) { List ncList = new List(); - foreach (NodeControlInfo item in this.GetNodeControlsInternal(node)) - { + foreach (var item in this.GetNodeControlsInternal(node)) ncList.Add(item); - } _cachedNodeControls.Add(node, ncList); } @@ -537,94 +572,97 @@ private IEnumerable GetNodeControlsInternal(TreeNodeAdv node) { if (node == null) yield break; - Rectangle rowRect = _rowLayout.GetRowBounds(node.Row); - - foreach (NodeControlInfo n in GetNodeControls(node, rowRect)) - { - yield return n; - } + foreach (NodeControlInfo n in GetNodeControls(node, rowRect)) + yield return n; } internal IEnumerable GetNodeControls(TreeNodeAdv node, Rectangle rowRect) { - if (node == null) - yield break; - - int y = rowRect.Y; - int x = (node.Level - 1)*_indent + LeftMargin; - int width; - Rectangle rect; - - if (ShowPlusMinus) - { - width = _plusMinus.GetActualSize(node, _measureContext).Width; - rect = new Rectangle(x, y, width, rowRect.Height); - - if (this.Columns.Count > 0 && this.Columns[0].Width < rect.Right) - rect.Width = this.Columns[0].Width - x; - - yield return new NodeControlInfo(_plusMinus, rect, node); - - x += width; - } - - - int right = 0; - - foreach (TreeColumn col in this.Columns) - { - if (!col.IsVisible || col.Width <= 0) - continue; - - right += col.Width; - - for (int i = 0; i < this.NodeControls.Count; i++) - { - NodeControl nc = this.NodeControls[i]; - - if (nc.ParentColumn != col) - continue; - - Size s = nc.GetActualSize(node, _measureContext); + if (node == null) + yield break; - if (s.IsEmpty) - continue; + int y = rowRect.Y; + int x = (node.Level - 1) * _indent + LeftMargin; + int width = 0; + Rectangle rect = Rectangle.Empty; - bool isLastControl = true; - - for (int k = i + 1; k < this.NodeControls.Count; k++) - { - if (this.NodeControls[k].ParentColumn == col) - { - isLastControl = false; - break; - } - } + if (ShowPlusMinus) + { + width = _plusMinus.GetActualSize(node, _measureContext).Width; + rect = new Rectangle(x, y, width, rowRect.Height); + if (UseColumns && Columns.Count > 0 && Columns[0].Width < rect.Right) + rect.Width = Columns[0].Width - x; - width = right - x; - - if (!isLastControl) - width = s.Width; - - int maxWidth = Math.Max(0, right - x); - rect = new Rectangle(x, y, Math.Min(maxWidth, width), rowRect.Height); - x += width; + yield return new NodeControlInfo(_plusMinus, rect, node); + x += width; + } - yield return new NodeControlInfo(nc, rect, node); - } - x = right; - } + if (!UseColumns) + { + foreach (NodeControl c in NodeControls) + { + Size s = c.GetActualSize(node, _measureContext); + if (!s.IsEmpty) + { + width = s.Width; + rect = new Rectangle(x, y, width, rowRect.Height); + x += rect.Width; + yield return new NodeControlInfo(c, rect, node); + } + } + } + else + { + int right = 0; + foreach (TreeColumn col in Columns) + { + if (col.IsVisible && col.Width > 0) + { + right += col.Width; + for (int i = 0; i < NodeControls.Count; i++) + { + NodeControl nc = NodeControls[i]; + if (nc.ParentColumn == col) + { + Size s = nc.GetActualSize(node, _measureContext); + if (!s.IsEmpty) + { + bool isLastControl = true; + for (int k = i + 1; k < NodeControls.Count; k++) + if (NodeControls[k].ParentColumn == col) + { + isLastControl = false; + break; + } + + width = right - x; + if (!isLastControl) + width = s.Width; + int maxWidth = Math.Max(0, right - x); + rect = new Rectangle(x, y, Math.Min(maxWidth, width), rowRect.Height); + x += width; + yield return new NodeControlInfo(nc, rect, node); + } + } + } + x = right; + } + } + } } - internal static double Dist(Point p1, Point p2) + internal static double Dist(Point p1, Point p2) { return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)); } public void FullUpdate() { - UnsafeFullUpdate(); + if (InvokeRequired) + Invoke(new MethodInvoker(UnsafeFullUpdate)); + else + UnsafeFullUpdate(); } public void RefreshVisualStyles() @@ -644,35 +682,34 @@ private void UnsafeFullUpdate() internal void UpdateView() { if (!_suspendUpdate) - this.Invalidate(false); + Invalidate(false); } internal void UpdateHeaders() { - this.Invalidate(new Rectangle(0, 0, this.Width, this.ColumnHeaderHeight)); + Invalidate(new Rectangle(0,0, Width, ColumnHeaderHeight)); } internal void UpdateColumns() { - this.FullUpdate(); + FullUpdate(); } private void CreateNodes() { - this.Selection.Clear(); - this.SelectionStart = null; - this.Root = new TreeNodeAdv(this, null); - this.Root.IsExpanded = true; - - if (this.Root.Nodes.Count > 0) - this.CurrentNode = this.Root.Nodes[0]; + Selection.Clear(); + SelectionStart = null; + _root = new TreeNodeAdv(this, null); + _root.IsExpanded = true; + if (_root.Nodes.Count > 0) + CurrentNode = _root.Nodes[0]; else - this.CurrentNode = null; + CurrentNode = null; } internal void ReadChilds(TreeNodeAdv parentNode) { - this.ReadChilds(parentNode, false); + ReadChilds(parentNode, false); } internal void ReadChilds(TreeNodeAdv parentNode, bool performFullUpdate) @@ -729,7 +766,7 @@ private void AddNode(TreeNodeAdv parent, int index, TreeNodeAdv node) node.IsLeaf = Model.IsLeaf(GetPath(node)); if (node.IsLeaf) node.Nodes.Clear(); - if (!this.LoadOnDemand || node.IsExpandedOnce) + if (!LoadOnDemand || node.IsExpandedOnce) ReadChilds(node); this.InvalidateNodeControlCache(); @@ -742,33 +779,54 @@ private struct ExpandArgs public bool IgnoreChildren; } - internal void SetIsExpanded(TreeNodeAdv node, bool value, bool ignoreChildren) - { - ExpandArgs eargs = new ExpandArgs {Node = node, Value = value, IgnoreChildren = ignoreChildren}; - - SetIsExpanded(eargs); - } - - private void SetIsExpanded(ExpandArgs eargs) + public void AbortBackgroundExpandingThreads() { - bool update = !eargs.IgnoreChildren; + _threadPool.CancelAll(true); + for (int i = 0; i < _expandingNodes.Count; i++) + _expandingNodes[i].IsExpandingNow = false; + _expandingNodes.Clear(); + Invalidate(); + } - if (update) - BeginUpdate(); + internal void SetIsExpanded(TreeNodeAdv node, bool value, bool ignoreChildren) + { + ExpandArgs eargs = new ExpandArgs(); + eargs.Node = node; + eargs.Value = value; + eargs.IgnoreChildren = ignoreChildren; - if (IsMyNode(eargs.Node) && eargs.Node.IsExpanded != eargs.Value) - SetIsExpanded(eargs.Node, eargs.Value); + if (AsyncExpanding && LoadOnDemand && !_threadPool.IsMyThread(Thread.CurrentThread)) + { + WaitCallback wc = delegate(object argument) { SetIsExpanded((ExpandArgs)argument); }; + _threadPool.QueueUserWorkItem(wc, eargs); + } + else + SetIsExpanded(eargs); + } - if (!eargs.IgnoreChildren) - SetIsExpandedRecursive(eargs.Node, eargs.Value); + private void SetIsExpanded(ExpandArgs eargs) + { + bool update = !eargs.IgnoreChildren && !AsyncExpanding; + if (update) + BeginUpdate(); + try + { + if (IsMyNode(eargs.Node) && eargs.Node.IsExpanded != eargs.Value) + SetIsExpanded(eargs.Node, eargs.Value); - if (update) - EndUpdate(); + if (!eargs.IgnoreChildren) + SetIsExpandedRecursive(eargs.Node, eargs.Value); + } + finally + { + if (update) + EndUpdate(); + } } - internal void SetIsExpanded(TreeNodeAdv node, bool value) + internal void SetIsExpanded(TreeNodeAdv node, bool value) { - if (this.Root == node && !value) + if (Root == node && !value) return; //Can't collapse root node if (value) @@ -778,14 +836,15 @@ internal void SetIsExpanded(TreeNodeAdv node, bool value) if (value && !node.IsExpandedOnce) { - if (this.LoadOnDemand) + if (AsyncExpanding && LoadOnDemand) { + AddExpandingNode(node); node.AssignIsExpanded(true); Invalidate(); } - ReadChilds(node); + ReadChilds(node, AsyncExpanding); + RemoveExpandingNode(node); } - node.AssignIsExpanded(value); SmartFullUpdate(); @@ -795,51 +854,77 @@ internal void SetIsExpanded(TreeNodeAdv node, bool value) OnCollapsed(node); } - internal void SetIsExpandedRecursive(TreeNodeAdv root, bool value) + private void RemoveExpandingNode(TreeNodeAdv node) { - foreach (TreeNodeAdv node in root.Nodes) - { - node.IsExpanded = value; - SetIsExpandedRecursive(node, value); - } + node.IsExpandingNow = false; + _expandingNodes.Remove(node); } - private void CreateRowMap() - { - this.RowMap.Clear(); - int row = 0; - this.ContentWidth = 0; - - foreach (TreeNodeAdv node in VisibleNodes) - { - node.Row = row; + private void AddExpandingNode(TreeNodeAdv node) + { + node.IsExpandingNow = true; + _expandingNodes.Add(node); + ExpandingIcon.Start(); + } - this.RowMap.Add(node); + internal void SetIsExpandedRecursive(TreeNodeAdv root, bool value) + { + for (int i = 0; i < root.Nodes.Count; i++) + { + TreeNodeAdv node = root.Nodes[i]; + node.IsExpanded = value; + SetIsExpandedRecursive(node, value); + } + } - row++; - } + private void CreateRowMap() + { + RowMap.Clear(); + int row = 0; + _contentWidth = 0; + foreach (TreeNodeAdv node in VisibleNodes) + { + node.Row = row; + RowMap.Add(node); + if (!UseColumns) + { + _contentWidth = Math.Max(_contentWidth, GetNodeWidth(node)); + } + row++; + } + if (UseColumns) + { + _contentWidth = 0; + foreach (TreeColumn col in _columns) + if (col.IsVisible) + _contentWidth += col.Width; + } + } - this.ContentWidth = 0; - - foreach (TreeColumn col in this.Columns) - { - if (col.IsVisible) - this.ContentWidth += col.Width; - } - } + private int GetNodeWidth(TreeNodeAdv node) + { + if (node.RightBounds == null) + { + Rectangle res = GetNodeBounds(GetNodeControls(node, Rectangle.Empty)); + node.RightBounds = res.Right; + } + return node.RightBounds.Value; + } - internal Rectangle GetNodeBounds(TreeNodeAdv node) + internal Rectangle GetNodeBounds(TreeNodeAdv node) { return GetNodeBounds(GetNodeControls(node)); } - private static Rectangle GetNodeBounds(IEnumerable nodeControls) + private Rectangle GetNodeBounds(IEnumerable nodeControls) { Rectangle res = Rectangle.Empty; - foreach (NodeControlInfo info in nodeControls) { - res = res == Rectangle.Empty ? info.Bounds : Rectangle.Union(res, info.Bounds); + if (res == Rectangle.Empty) + res = info.Bounds; + else + res = Rectangle.Union(res, info.Bounds); } return res; } @@ -875,23 +960,23 @@ internal bool IsMyNode(TreeNodeAdv node) while (node.Parent != null) node = node.Parent; - return node == this.Root; + return node == _root; } private void UpdateSelection() { bool flag = false; - if (!IsMyNode(this.CurrentNode)) - this.CurrentNode = null; - if (!IsMyNode(this.SelectionStart)) - this.SelectionStart = null; + if (!IsMyNode(CurrentNode)) + CurrentNode = null; + if (!IsMyNode(_selectionStart)) + _selectionStart = null; - for (int i = this.Selection.Count - 1; i >= 0; i--) - if (!IsMyNode(this.Selection[i])) + for (int i = Selection.Count - 1; i >= 0; i--) + if (!IsMyNode(Selection[i])) { flag = true; - this.Selection.RemoveAt(i); + Selection.RemoveAt(i); } if (flag) @@ -900,7 +985,7 @@ private void UpdateSelection() internal void ChangeColumnWidth(TreeColumn column) { - if (!(this.Input is ResizeColumnState)) + if (!(_input is ResizeColumnState)) { FullUpdate(); OnColumnWidthChanged(column); @@ -915,9 +1000,9 @@ public TreeNodeAdv FindNode(TreePath path) public TreeNodeAdv FindNode(TreePath path, bool readChilds) { if (path.IsEmpty()) - return this.Root; - - return FindNode(this.Root, path, 0, readChilds); + return _root; + else + return FindNode(_root, path, 0, readChilds); } private TreeNodeAdv FindNode(TreeNodeAdv root, TreePath path, int level, bool readChilds) @@ -925,37 +1010,35 @@ private TreeNodeAdv FindNode(TreeNodeAdv root, TreePath path, int level, bool re if (!root.IsExpandedOnce && readChilds) ReadChilds(root); - foreach (TreeNodeAdv node in root.Nodes) + for (int i = 0; i < root.Nodes.Count; i++) { - if (node.Tag != path.FullPath[level]) - continue; - - if (level == path.FullPath.Length - 1) - return node; - - return FindNode(node, path, level + 1, readChilds); + TreeNodeAdv node = root.Nodes[i]; + if (node.Tag == path.FullPath[level]) + { + if (level == path.FullPath.Length - 1) + return node; + else + return FindNode(node, path, level + 1, readChilds); + } } return null; } public TreeNodeAdv FindNodeByTag(object tag) { - return FindNodeByTag(this.Root, tag); + return FindNodeByTag(_root, tag); } - private static TreeNodeAdv FindNodeByTag(TreeNodeAdv root, object tag) + private TreeNodeAdv FindNodeByTag(TreeNodeAdv root, object tag) { foreach (TreeNodeAdv node in root.Nodes) { if (node.Tag == tag) return node; - - TreeNodeAdv res = FindNodeByTag(node, tag); - - if (res != null) + TreeNodeAdv res = FindNodeByTag(node, tag); + if (res != null) return res; } - return null; } @@ -966,7 +1049,7 @@ public void DisplayEditor(Control control, EditableControl owner) if (control == null || owner == null) throw new ArgumentNullException(); - if (this.CurrentNode != null) + if (CurrentNode != null) { HideEditor(); _currentEditor = control; @@ -984,15 +1067,13 @@ public void UpdateEditorBounds() { if (_currentEditor != null) { - EditorContext context = new EditorContext - { - Owner = this._currentEditorOwner, - CurrentNode = this.CurrentNode, - Editor = this._currentEditor, - DrawContext = this._measureContext - }; + EditorContext context = new EditorContext(); + context.Owner = _currentEditorOwner; + context.CurrentNode = CurrentNode; + context.Editor = _currentEditor; + context.DrawContext = _measureContext; - SetEditorBounds(context); + SetEditorBounds(context); } } @@ -1015,17 +1096,14 @@ private void SetEditorBounds(EditorContext context) Point p = info.Bounds.Location; p.X += info.Control.LeftMargin; p.X -= OffsetX; - p.Y -= (_rowLayout.GetRowBounds(FirstVisibleRow).Y - this.ColumnHeaderHeight); + p.Y -= (_rowLayout.GetRowBounds(FirstVisibleRow).Y - ColumnHeaderHeight); int width = DisplayRectangle.Width - p.X; - - if ( info.Control.ParentColumn != null && this.Columns.Contains(info.Control.ParentColumn)) + if (UseColumns && info.Control.ParentColumn != null && Columns.Contains(info.Control.ParentColumn)) { Rectangle rect = GetColumnBounds(info.Control.ParentColumn.Index); width = rect.Right - OffsetX - p.X; } - context.Bounds = new Rectangle(p.X, p.Y, width, info.Bounds.Height); - ((EditableControl)info.Control).SetEditorBounds(context); return; } @@ -1035,14 +1113,14 @@ private void SetEditorBounds(EditorContext context) private Rectangle GetColumnBounds(int column) { int x = 0; - for (int i = 0; i < this.Columns.Count; i++) + for (int i = 0; i < Columns.Count; i++) { - if (this.Columns[i].IsVisible) + if (Columns[i].IsVisible) { if (i < column) - x += this.Columns[i].Width; + x += Columns[i].Width; else - return new Rectangle(x, 0, this.Columns[i].Width, 0); + return new Rectangle(x, 0, Columns[i].Width, 0); } } return Rectangle.Empty; @@ -1053,18 +1131,18 @@ private Rectangle GetColumnBounds(int column) #region ModelEvents private void BindModelEvents() { - _model.NodesChanged += _model_NodesChanged; - _model.NodesInserted += _model_NodesInserted; - _model.NodesRemoved += _model_NodesRemoved; - _model.StructureChanged += _model_StructureChanged; + _model.NodesChanged += new EventHandler(_model_NodesChanged); + _model.NodesInserted += new EventHandler(_model_NodesInserted); + _model.NodesRemoved += new EventHandler(_model_NodesRemoved); + _model.StructureChanged += new EventHandler(_model_StructureChanged); } private void UnbindModelEvents() { - _model.NodesChanged -= _model_NodesChanged; - _model.NodesInserted -= _model_NodesInserted; - _model.NodesRemoved -= _model_NodesRemoved; - _model.StructureChanged -= _model_StructureChanged; + _model.NodesChanged -= new EventHandler(_model_NodesChanged); + _model.NodesInserted -= new EventHandler(_model_NodesInserted); + _model.NodesRemoved -= new EventHandler(_model_NodesRemoved); + _model.StructureChanged -= new EventHandler(_model_StructureChanged); } private void _model_StructureChanged(object sender, TreePathEventArgs e) @@ -1073,19 +1151,18 @@ private void _model_StructureChanged(object sender, TreePathEventArgs e) throw new ArgumentNullException(); TreeNodeAdv node = FindNode(e.Path); - - if (node == null) - return; - - ReadChilds(node); - UpdateSelection(); - - if (_completeSuspendUpdate) - return; - - this.FullUpdate(); - this.Invalidate(); - //else + if (node != null) + { + ReadChilds(node); + UpdateSelection(); + + if (!_completeSuspendUpdate) + { + this.FullUpdate(); + this.Invalidate(); + } + } + //else // throw new ArgumentException("Path not found"); } @@ -1097,14 +1174,11 @@ private void _model_NodesRemoved(object sender, TreeModelEventArgs e) if (e.Indices != null) { List list = new List(e.Indices); - - list.Sort(); - - for (int n = list.Count - 1; n >= 0; n--) + list.Sort(); + for (int n = list.Count - 1; n >= 0; n--) { int index = list[n]; - - if (index >= 0 && index <= parent.Nodes.Count) + if (index >= 0 && index <= parent.Nodes.Count) parent.Nodes.RemoveAt(index); else throw new ArgumentOutOfRangeException("Index out of range"); @@ -1114,14 +1188,12 @@ private void _model_NodesRemoved(object sender, TreeModelEventArgs e) { for (int i = parent.Nodes.Count - 1; i >= 0; i--) { - for (int n = 0; n < e.Children.Length; n++) - { - if (parent.Nodes[i].Tag == e.Children[n]) - { - parent.Nodes.RemoveAt(i); - break; - } - } + for (int n = 0; n < e.Children.Length; n++) + if (parent.Nodes[i].Tag == e.Children[n]) + { + parent.Nodes.RemoveAt(i); + break; + } } } } @@ -1150,16 +1222,15 @@ private void _model_NodesChanged(object sender, TreeModelEventArgs e) if (parent != null && parent.IsVisible && parent.IsExpanded) { if (InvokeRequired) - this.BeginInvoke(new UpdateContentWidthDelegate(ClearNodesSize), e, parent); + Invoke(new UpdateContentWidthDelegate(ClearNodesSize), e, parent); else ClearNodesSize(e, parent); - SmartFullUpdate(); } } private delegate void UpdateContentWidthDelegate(TreeModelEventArgs e, TreeNodeAdv parent); - private static void ClearNodesSize(TreeModelEventArgs e, TreeNodeAdv parent) + private void ClearNodesSize(TreeModelEventArgs e, TreeNodeAdv parent) { if (e.Indices != null) { @@ -1178,13 +1249,11 @@ private static void ClearNodesSize(TreeModelEventArgs e, TreeNodeAdv parent) { foreach (TreeNodeAdv node in parent.Nodes) { - foreach (object obj in e.Children) - { - if (node.Tag == obj) - { - node.Height = node.RightBounds = null; - } - } + foreach (object obj in e.Children) + if (node.Tag == obj) + { + node.Height = node.RightBounds = null; + } } } } diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.resx b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.resx similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdv.resx rename to 1.x/trunk/TreeViewAdv/Tree/TreeViewAdv.resx diff --git a/1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdvCancelEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdvCancelEventArgs.cs similarity index 100% rename from 1.x/trunk/ProcessHacker/Components/TreeViewAdv/Tree/TreeViewAdvCancelEventArgs.cs rename to 1.x/trunk/TreeViewAdv/Tree/TreeViewAdvCancelEventArgs.cs diff --git a/1.x/trunk/TreeViewAdv/Tree/TreeViewAdvEventArgs.cs b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdvEventArgs.cs new file mode 100644 index 000000000..254a8be8f --- /dev/null +++ b/1.x/trunk/TreeViewAdv/Tree/TreeViewAdvEventArgs.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Aga.Controls.Tree +{ + public class TreeViewAdvEventArgs : EventArgs + { + private TreeNodeAdv _node; + + public TreeNodeAdv Node + { + get { return _node; } + } + + public TreeViewAdvEventArgs(TreeNodeAdv node) + { + _node = node; + } + } +} diff --git a/1.x/trunk/TreeViewAdv/app.config b/1.x/trunk/TreeViewAdv/app.config new file mode 100644 index 000000000..89dc7d426 --- /dev/null +++ b/1.x/trunk/TreeViewAdv/app.config @@ -0,0 +1,3 @@ + + + diff --git a/2.x/trunk/CHANGELOG.txt b/2.x/trunk/CHANGELOG.txt index d12a77909..9beb8a8b1 100644 --- a/2.x/trunk/CHANGELOG.txt +++ b/2.x/trunk/CHANGELOG.txt @@ -1,8 +1,41 @@ Process Hacker +2.34 + * NEW/IMPROVED: + * FIXED: + +2.33 + * NEW/IMPROVED: + * View digital signature information from process properties and peview + * Signatures for Windows 8 apps are now detected + * Improved file, key, process and thread handle properties + * Added DPI Awareness column + * Added new Windows 8.1 process protection information + * KProcessHacker is no longer needed for highlighting of GUI threads + * Added suspend count for threads on Windows 8.1 + * Updated DotNetTools plugin: + * Improved .NET assembly enumeration timeout handling + * FIXED: + * Service start type and error control are never updated if modified outside of Process Hacker + 2.32 + * NOTE: + * All executable files are now signed. * NEW/IMPROVED: + * Updated for Windows 8.1 + * Added progress display for thread stacks + * Updated ExtendedServices plugin: + * Added new trigger data types + * Updated NetworkTools plugin: + * Updated UI + * Updated OnlineChecks plugin: + * Added file analyzed prompt * FIXED: + * Fixed handling of long symbol names + * Fixed Run As preventing Windows 8 apps from starting + * Fixed console host information for Windows 8.1 + * Fixed reflected processes not terminating on Windows 8.1 + * Fixed CPU frequency on Windows 8.1 2.31 * NEW/IMPROVED: @@ -30,10 +63,8 @@ Process Hacker * NEW/IMPROVED: * Added App ID column for processes * Added new ASLR information for Windows 8 - * Added Restart to Boot Options and Hybrid Shutdown menu items for - Windows 8 - * Added ability to specify processes by their names and inject and - unload DLLs in command line + * Added Restart to Boot Options and Hybrid Shutdown menu items for Windows 8 + * Added ability to specify processes by their names and inject and unload DLLs in command line * Removed 512 character limit when copying text * Moved Terminator to Miscellaneous menu * Updated default dbghelp.dll path for Windows SDK v8 @@ -62,10 +93,8 @@ Process Hacker 2.28 * NEW/IMPROVED: * peview now resolves .lnk targets - * Fixed Ctrl+A for processes, services and network connections and - added Ctrl+A for other windows - * Changed confirmation prompts to select the destructive action by - default + * Fixed Ctrl+A for processes, services and network connections and added Ctrl+A for other windows + * Changed confirmation prompts to select the destructive action by default * Updated DotNetTools plugin: * Fixed inaccurate stack traces for certain .NET programs * Updated ExtendedTools plugin: @@ -89,8 +118,7 @@ Process Hacker 2.26 * NEW/IMPROVED: - * Added option to show Commit Charge in system information - summary view + * Added option to show Commit Charge in system information summary view * Added -priority and -selectpid command line options * Updated ExtendedTools plugin: * Improved support for multiple GPUs @@ -110,8 +138,7 @@ Process Hacker 2.24 * NOTE: - * This release has significant internal code changes. Please - make sure all plugins are up-to-date. + * This release has significant internal code changes. Please make sure all plugins are up-to-date. * NEW/IMPROVED: * Completely new system information window * Added option to scroll to new processes @@ -134,8 +161,7 @@ Process Hacker 2.23 * NEW/IMPROVED: - * Added display of token capabilities, user/device claims - and security attributes + * Added display of token capabilities, user/device claims and security attributes * Added ability to change token integrity levels * Added Description column to service list * Added option to reset all settings @@ -149,8 +175,7 @@ Process Hacker * Added rate columns for disk and network I/O * FIXED: * Fixed copying lists when plugin columns are enabled - * Freezing when viewing the tooltip for a process with a - very long command line + * Freezing when viewing the tooltip for a process with a very long command line * Disabled Hidden Processes feature on 64-bit systems 2.22 @@ -167,8 +192,7 @@ Process Hacker * Fixed hook support for low integrity processes * FIXED: * Fixed memory leaks - * Fixed bug preventing Interrupts/DPCs from being shown - as the max. CPU process on 64-bit systems + * Fixed bug preventing Interrupts/DPCs from being shown as the max. CPU process on 64-bit systems * Fixed DEP Status column on 64-bit systems 2.21 @@ -193,17 +217,14 @@ Process Hacker * Extended header context menu * Removed tooltip text truncation * Improved cycle-based CPU usage calculation - * Set default KProcessHacker security level to only allow - connections when Process Hacker is running as administrator. - See README.txt for instructions on how to restore the old - behavior. + * Set default KProcessHacker security level to only allow connections when Process Hacker is running as administrator. + See README.txt for instructions on how to restore the old behavior. * Added Updater plugin * Updated DotNetTools plugin: * Added managed symbol resolution for thread stacks * Updated ExtendedTools plugin: * Added Disk tab - * Added Hard Faults, Hard Faults Delta and Peak Threads - columns to process tree list + * Added Hard Faults, Hard Faults Delta and Peak Threads columns to process tree list * Added Firewall Status column * FIXED: * Fixed file name resolution bug @@ -219,10 +240,8 @@ Process Hacker * Added Show CPU Below 0.01 * Added OS Context column * Rewrote graph drawing code for improved performance - * Optimized retrieval of cycle time and private working set - information for Windows 7 - * Added Open File Location to process context menu and - reorganized some items + * Optimized retrieval of cycle time and private working set information for Windows 7 + * Added Open File Location to process context menu and reorganized some items * Added checkboxes to Terminator * FIXED: * Crash when sorting by Time Stamp @@ -237,8 +256,7 @@ Process Hacker * Bug fixes * Added more process tree list columns * Added Time stamp column to network list - * Date/time display is now swapped (so time is shown before - date) + * Date/time display is now swapped (so time is shown before date) * Added W3 terminator test * Added DotNetTools plugin * Updated ExtendedServices plugin: @@ -257,8 +275,7 @@ Process Hacker * NEW/IMPROVED: * Added support for setting page priority * Added elevation support for setting priority - * Added support for automatically using a settings file in - the program directory (e.g. ProcessHacker.exe.settings.xml) + * Added support for automatically using a settings file in the program directory (e.g. ProcessHacker.exe.settings.xml) * Improved Run As mechanism * Updated ExtendedServices plugin: * Added support for editing triggers @@ -277,8 +294,7 @@ Process Hacker * PE viewer: Added display of delay imports * PE viewer: Added Load Config tab * Improved wait analysis - * Added arrows to the service list to indicate whether a - service is running + * Added arrows to the service list to indicate whether a service is running * FIXED: * Fixed the IPv6-related workaround causing crashes * Incorrect handling of window positions @@ -298,19 +314,15 @@ Process Hacker 2.14 * NEW/IMPROVED: - * ExtendedServices plugin: Option to add a Services menu - for processes - * Command line support for setting process priority and - I/O priority + * ExtendedServices plugin: Option to add a Services menu for processes + * Command line support for setting process priority and I/O priority * Improved termination of explorer.exe * FIXED: * Icon should restore the main window if it is minimized * System Information window crashes - * Hide Processes From Other Users and Hide Signed Processes - settings are now saved + * Hide Processes From Other Users and Hide Signed Processes settings are now saved * Font selection on Windows XP - * ToolStatus plugin: Always on Top status being reset by - Find Window + * ToolStatus plugin: Always on Top status being reset by Find Window * Service-related crashes * WindowExplorer plugin: sorting in tree list * Process minidump creation with old versions of dbghelp.dll @@ -318,8 +330,7 @@ Process Hacker 2.13 * NEW/IMPROVED: * Added copy support to PE viewer - * Added Connect Time, Disconnect Time and Last Input Time - to session properties + * Added Connect Time, Disconnect Time and Last Input Time to session properties * Added more working set counters to the Statistics tab * FIXED: * Column sort arrows @@ -339,13 +350,11 @@ Process Hacker 2.11 * NEW/IMPROVED: - * Added WS Watch and other features to ExtendedTools - plugin + * Added WS Watch and other features to ExtendedTools plugin * Added WindowExplorer plugin * Properties for hidden processes * Improved menus - * Debug console can now be closed without affecting the - entire program + * Debug console can now be closed without affecting the entire program * FIXED: * Always on Top issues * Hang when setting DEP status of a terminating process @@ -355,8 +364,7 @@ Process Hacker 2.10 * NEW/IMPROVED: - * KProcessHacker is now signed, so it works on 64-bit - systems. Thank you to the ReactOS Foundation. + * KProcessHacker is now signed, so it works on 64-bit systems. Thank you to the ReactOS Foundation. * Added Run As Limited User * Added CPU, private bytes and I/O history columns * Added font selection @@ -375,16 +383,11 @@ Process Hacker * Added column selection for modules list * Added wait analysis for 64-bit systems * Added signature verification for modules - * Added ExtendedTools plugin (Vista and above only) - with Disk and Network information - * Updated ExtendedNotifications plugin: added ability - to log events to a file - * Updated ExtendedServices plugin: new tab on Vista - and above - * Updated ToolStatus plugin: resolves ghost windows - to hung windows - * Environment variables and current directory are - now correctly shown for WOW64 processes + * Added ExtendedTools plugin (Vista and above only) with Disk and Network information + * Updated ExtendedNotifications plugin: added ability to log events to a file + * Updated ExtendedServices plugin: new tab on Vista and above + * Updated ToolStatus plugin: resolves ghost windows to hung windows + * Environment variables and current directory are now correctly shown for WOW64 processes * I/O priority names are now used instead of numbers * FIXED: * Network list bug @@ -397,8 +400,7 @@ Process Hacker * Process tree sorting is now preserved * Save works for services and network connections * Pausing now works correctly with the Network tab - * Added option to display inclusive CPU usages for - collapsed processes + * Added option to display inclusive CPU usages for collapsed processes * Added CLR tab to peview * Added ability to destroy heaps * Improved process tree list appearance @@ -412,8 +414,7 @@ Process Hacker * NEW/IMPROVED: * Vastly improved startup time and lower memory usage * Added Cycles and Cycles Delta columns - * Added option to disable address resolution for - network connections + * Added option to disable address resolution for network connections * Added Logon Time to session properties * Added time stamp display to peview * FIXED: @@ -425,8 +426,7 @@ Process Hacker * NEW/IMPROVED: * Sorting for most lists is now much faster * Hide Signed Processes option - * Added plugin for uploading files to online virus - scanners + * Added plugin for uploading files to online virus scanners * Added Network tools plugin * Updated ExtendedServices plugin * PE viewer now verifies checksums @@ -437,8 +437,7 @@ Process Hacker 2.5 * NEW/IMPROVED: * Unmap section views in Memory tab - * Plugin for extended service information (including - recovery information, dependencies and dependents) + * Plugin for extended service information (including recovery information, dependencies and dependents) * FIXED: * Critical bug for file dialogs on Windows XP * Esc couldn't close Service Properties on open @@ -466,8 +465,7 @@ Process Hacker 2.3 * NEW/IMPROVED: * Can add processes to jobs - * Double-clicking in the system information graphs now opens - information for the relevant process + * Double-clicking in the system information graphs now opens information for the relevant process * Setting I/O priority doesn't need KProcessHacker anymore * Elevation for certain actions * FIXED: @@ -496,8 +494,7 @@ Process Hacker * Add Pause key shortcut to pause/resume updates * Added Ctrl+Tab and Ctrl+Shift+Tab shortcuts * Grid is a bit darker - * Checks for digital signatures and packing is now - off by default and optional + * Checks for digital signatures and packing is now off by default and optional * FIXED: * MD5 calculation code for files was wrong * Process record bugs diff --git a/2.x/trunk/HACKING.txt b/2.x/trunk/HACKING.txt index 1130f5561..97cb6f748 100644 --- a/2.x/trunk/HACKING.txt +++ b/2.x/trunk/HACKING.txt @@ -2,9 +2,7 @@ Process Hacker must be built using a Microsoft C compiler. Do not attempt to use any other compiler or be prepared to spend a long time trying to fix things. The only tested -IDE is Visual Studio 2012. Note that -"Text Editor > C/C++ > Advanced > Disable Error Reporting" should be -set to workaround the fact that IntelliSense thinks all C code is C++. +IDE is Visual Studio 2013. The Windows SDK v8 must be installed. To create a XP-compatible driver, KProcessHacker must be built using WDK v7, not the latest WDK. @@ -55,7 +53,7 @@ Always use: to test a boolean value. ==== Annotations, qualifiers ==== - * All parameters must use annotations, such as __in, __inout, __out, etc. + * All functions use SAL annotations, such as _In_, _Inout_, _Out_, etc. * Do not use "const", unless obvious optimizations can be made by the compiler (e.g. inlining). * Do not use "volatile" in definitions. Instead, cast to a volatile @@ -71,7 +69,7 @@ There are three main types of indicators used: A special value (e.g. NULL) indicates failure. Unless indicated, a function which fails is guaranteed not to -modify any of its output parameters (__out, __out_opt, etc.). +modify any of its output parameters (_Out_, _Out_opt_, etc.). For functions which are passed a callback function, it is not guaranteed that a failed function has not executed the callback @@ -81,7 +79,7 @@ function. Every thread start routine must have the following signature: NTSTATUS NameOfRoutine( - __in PVOID Parameter + _In_ PVOID Parameter ); Thread creation is done through the PhCreateThread function. @@ -129,117 +127,6 @@ modified use PhSetWakeEvent to wake waiters. If after calling PhQueueWakeEvent it is determined that no blocking should occur, use PhSetWakeEvent. -==== (Lazy) Singletons ==== - -====== Not thread-safe ====== - BOOLEAN initialized = FALSE; - OBJECT object = NULL; - - DoSomething() - { - if (!initialized) - { - object = Create(); - initialized = TRUE; - } - - Use(object); - } - -Disadvantages: - * Not thread-safe - -====== Thread-safe (locking, double-checked) ====== - BOOLEAN initialized = FALSE; - OBJECT object = NULL; - PH_QUEUED_LOCK lock = PH_QUEUED_LOCK_INIT; - - DoSomething() - { - if (!initialized) - { - PhAcquireQueuedLockExclusiveFast(&lock); - - if (!initialized) - { - object = Create(); - MemoryBarrier(); - initialized = TRUE; - } - - PhReleaseQueuedLockExclusiveFast(&lock); - } - - Use(object); - } - -Advantages: - * Thread-safe -Disadvantages: - * Lock overhead - * More code - -====== Thread-safe (PH_INITONCE) ====== - PH_INITONCE initOnce = PH_INITONCE_INIT; - OBJECT object = NULL; - - DoSomething() - { - if (PhBeginInitOnce(&initOnce)) - { - object = Create(); - PhEndInitOnce(&initOnce); - } - - Use(object); - } - -Advantages: - * Less overhead - * Less code - -====== Thread-safe (custom) ====== - OBJECT object = NULL; - - DoSomething() - { - OBJECT localObject; - OBJECT newObject; - - localObject = object; - - if (!localObject) - { - newObject = Create(); - - // Try to store the created object. - localObject = InterlockedCompareExchangePointer( - &object, - newObject, - NULL - ); - - if (!localObject) - { - // Success. - localObject = newObject; - } - else - { - // Someone else already stored the object. - Destroy(newObject); - } - } - - return localObject; - } - -Advantages: - * Less overhead -Disadvantages: - * More code - * Created object may need to be destroyed - ==== Exceptions (SEH) ==== The only method of error handling used in Process Hacker is the return value (NTSTATUS, BOOLEAN, etc.). Exceptions are used for diff --git a/2.x/trunk/KProcessHacker/KProcessHacker.vcxproj b/2.x/trunk/KProcessHacker/KProcessHacker.vcxproj index 8f15bfb15..803c2784e 100644 --- a/2.x/trunk/KProcessHacker/KProcessHacker.vcxproj +++ b/2.x/trunk/KProcessHacker/KProcessHacker.vcxproj @@ -88,10 +88,6 @@ KPH_CONFIG_CLEAN;_X86_=1;i386=1;STD_CALL;%(PreprocessorDefinitions) Level3 - - - - @@ -99,10 +95,6 @@ KPH_CONFIG_CLEAN;_X86_=1;i386=1;STD_CALL;%(PreprocessorDefinitions) Level3 - - - - @@ -110,10 +102,6 @@ KPH_CONFIG_CLEAN;_WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions) Level3 - - - - @@ -121,10 +109,6 @@ KPH_CONFIG_CLEAN;_WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions) Level3 - - - - diff --git a/2.x/trunk/KProcessHacker/bin-signed/amd64/kprocesshacker.sys b/2.x/trunk/KProcessHacker/bin-signed/amd64/kprocesshacker.sys index 5a88f2668..437bb63a3 100644 Binary files a/2.x/trunk/KProcessHacker/bin-signed/amd64/kprocesshacker.sys and b/2.x/trunk/KProcessHacker/bin-signed/amd64/kprocesshacker.sys differ diff --git a/2.x/trunk/KProcessHacker/bin-signed/i386/kprocesshacker.sys b/2.x/trunk/KProcessHacker/bin-signed/i386/kprocesshacker.sys index 94ca85330..d2a78667c 100644 Binary files a/2.x/trunk/KProcessHacker/bin-signed/i386/kprocesshacker.sys and b/2.x/trunk/KProcessHacker/bin-signed/i386/kprocesshacker.sys differ diff --git a/2.x/trunk/KProcessHacker/bin-signed/readme.txt b/2.x/trunk/KProcessHacker/bin-signed/readme.txt deleted file mode 100644 index c18d7c492..000000000 --- a/2.x/trunk/KProcessHacker/bin-signed/readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -These binaries have been signed by the ReactOS Foundation. - -(Note: the 32-bit version might not be signed.) \ No newline at end of file diff --git a/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.pdb b/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.pdb index 4991d0f02..089538122 100644 Binary files a/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.pdb and b/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.pdb differ diff --git a/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.sys b/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.sys index 8e3b266d8..c2f2ebae7 100644 Binary files a/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.sys and b/2.x/trunk/KProcessHacker/bin/amd64/kprocesshacker.sys differ diff --git a/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.pdb b/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.pdb index edffcccfe..1a08a8f4e 100644 Binary files a/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.pdb and b/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.pdb differ diff --git a/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.sys b/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.sys index 94ca85330..2832127d8 100644 Binary files a/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.sys and b/2.x/trunk/KProcessHacker/bin/i386/kprocesshacker.sys differ diff --git a/2.x/trunk/KProcessHacker/clean/sources b/2.x/trunk/KProcessHacker/clean/sources index daa8b37ec..e2834d805 100644 --- a/2.x/trunk/KProcessHacker/clean/sources +++ b/2.x/trunk/KProcessHacker/clean/sources @@ -4,5 +4,4 @@ This builds a clean version of KProcessHacker suitable for driver signing. !ENDIF -C_DEFINES = $(C_DEFINES) /DKPH_CONFIG_CLEAN !include ..\sources.inc diff --git a/2.x/trunk/KProcessHacker/dirs b/2.x/trunk/KProcessHacker/dirs index 39fc552d8..1caf7fa5b 100644 --- a/2.x/trunk/KProcessHacker/dirs +++ b/2.x/trunk/KProcessHacker/dirs @@ -1,2 +1 @@ DIRS=clean -OPTIONAL_DIRS=dirty diff --git a/2.x/trunk/KProcessHacker/dirty/makefile b/2.x/trunk/KProcessHacker/dirty/makefile deleted file mode 100644 index 05a507be4..000000000 --- a/2.x/trunk/KProcessHacker/dirty/makefile +++ /dev/null @@ -1 +0,0 @@ -!INCLUDE $(NTMAKEENV)\makefile.def \ No newline at end of file diff --git a/2.x/trunk/KProcessHacker/dirty/sources b/2.x/trunk/KProcessHacker/dirty/sources deleted file mode 100644 index e6d79dca3..000000000 --- a/2.x/trunk/KProcessHacker/dirty/sources +++ /dev/null @@ -1,8 +0,0 @@ -!IF 0 - -This builds a dirty version of KProcessHacker that includes all functionality. - -!ENDIF - -TARGETNAME=kprocesshacker-dirty -!include ..\sources.inc diff --git a/2.x/trunk/KProcessHacker/dyndata.c b/2.x/trunk/KProcessHacker/dyndata.c index 467178505..7b8c42693 100644 --- a/2.x/trunk/KProcessHacker/dyndata.c +++ b/2.x/trunk/KProcessHacker/dyndata.c @@ -1,7 +1,7 @@ /* * KProcessHacker * - * Copyright (C) 2010-2012 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -102,6 +102,12 @@ static UCHAR PsTerminateProcess62Bytes[] = 0x8b, 0x1d, 0x24, 0x01, 0x00, 0x00, 0x56, 0x8d, 0xb3, 0x3c, 0x01, 0x00, 0x00, 0x66, 0xff, 0x0e }; +static UCHAR PsTerminateProcess63Bytes[] = +{ + 0x8b, 0xff, 0x55, 0x8b, 0xec, 0x83, 0xe4, 0xf8, + 0x56, 0x64, 0x8b, 0x35, 0x24, 0x01, 0x00, 0x00, + 0x57, 0x66, 0xff, 0x8e, 0x3c, 0x01, 0x00, 0x00 +}; // PspTerminateThreadByPointer static UCHAR PspTerminateThreadByPointer51Bytes[] = @@ -131,6 +137,11 @@ static UCHAR PspTerminateThreadByPointer62Bytes[] = 0x8b, 0xff, 0x55, 0x8b, 0xec, 0x8d, 0x87, 0x68, 0x02, 0x00, 0x00, 0xf6, 0x00, 0x20, 0x53, 0x8a }; +static UCHAR PspTerminateThreadByPointer63Bytes[] = +{ + 0x8b, 0xff, 0x55, 0x8b, 0xec, 0x53, 0x56, 0x8b, + 0xf1, 0x8b, 0xda, 0x57, 0x8d, 0xbe, 0xb8, 0x03 +}; #endif @@ -264,13 +275,13 @@ NTSTATUS KphpLoadDynamicConfiguration( KphDynEgeGuid = C_2sTo4(package->StructData.EgeGuid); KphDynEpObjectTable = C_2sTo4(package->StructData.EpObjectTable); - KphDynEpProtectedProcessOff = C_2sTo4(package->StructData.EpProtectedProcessOff); - KphDynEpProtectedProcessBit = C_2sTo4(package->StructData.EpProtectedProcessBit); KphDynEpRundownProtect = C_2sTo4(package->StructData.EpRundownProtect); KphDynEreGuidEntry = C_2sTo4(package->StructData.EreGuidEntry); KphDynHtHandleContentionEvent = C_2sTo4(package->StructData.HtHandleContentionEvent); KphDynOtName = C_2sTo4(package->StructData.OtName); KphDynOtIndex = C_2sTo4(package->StructData.OtIndex); + KphDynObDecodeShift = C_2sTo4(package->StructData.ObDecodeShift); + KphDynObAttributesShift = C_2sTo4(package->StructData.ObAttributesShift); return STATUS_SUCCESS; } @@ -430,8 +441,6 @@ static NTSTATUS KphpX86DataInitialization( KphDynEgeGuid = 0xc; KphDynEpObjectTable = 0xdc; - KphDynEpProtectedProcessOff = 0x224; - KphDynEpProtectedProcessBit = 0xb; KphDynEpRundownProtect = 0x98; KphDynEreGuidEntry = 0x8; @@ -474,8 +483,6 @@ static NTSTATUS KphpX86DataInitialization( KphDynEgeGuid = 0xc; KphDynEpObjectTable = 0xf4; - KphDynEpProtectedProcessOff = 0x26c; - KphDynEpProtectedProcessBit = 0xb; KphDynEpRundownProtect = 0xb0; KphDynEreGuidEntry = 0x8; KphDynOtName = 0x8; @@ -548,7 +555,52 @@ static NTSTATUS KphpX86DataInitialization( dprintf("Initialized version-specific data for Windows 8 SP%d\n", servicePack); } - else if (majorVersion == 6 && minorVersion > 2 || majorVersion > 6) + // Windows 8.1, Windows Server 2012 R2 + else if (majorVersion == 6 && minorVersion == 3) + { + ULONG_PTR searchOffset1 = (ULONG_PTR)KphGetSystemRoutineAddress(L"IoSetIoCompletion"); + ULONG_PTR searchOffset2 = searchOffset1; + + KphDynNtVersion = PHNT_WINBLUE; + + if (servicePack == 0) + { + } + else + { + return STATUS_NOT_SUPPORTED; + } + + KphDynEgeGuid = 0xc; + KphDynEpObjectTable = 0x150; + KphDynEpRundownProtect = 0xb0; + KphDynEreGuidEntry = 0x8; + KphDynOtName = 0x8; + KphDynOtIndex = 0x14; + + if (searchOffset1) + { + INIT_SCAN( + &KphDynPsTerminateProcessScan, + PsTerminateProcess63Bytes, + sizeof(PsTerminateProcess63Bytes), + searchOffset1, 0x8000, 0 + ); + } + + if (searchOffset2) + { + INIT_SCAN( + &KphDynPspTerminateThreadByPointerScan, + PspTerminateThreadByPointer63Bytes, + sizeof(PspTerminateThreadByPointer63Bytes), + searchOffset2, 0x8000, 0 + ); + } + + dprintf("Initialized version-specific data for Windows 8.1 SP%d\n", servicePack); + } + else if (majorVersion == 6 && minorVersion > 3 || majorVersion > 6) { KphDynNtVersion = 0xffffffff; return STATUS_NOT_SUPPORTED; @@ -671,7 +723,20 @@ static NTSTATUS KphpAmd64DataInitialization( return STATUS_NOT_SUPPORTED; } } - else if (majorVersion == 6 && minorVersion > 2 || majorVersion > 6) + // Windows 8.1, Windows Server 2012 R2 + else if (majorVersion == 6 && minorVersion == 3) + { + KphDynNtVersion = PHNT_WINBLUE; + + if (servicePack == 0) + { + } + else + { + return STATUS_NOT_SUPPORTED; + } + } + else if (majorVersion == 6 && minorVersion > 3 || majorVersion > 6) { KphDynNtVersion = 0xffffffff; return STATUS_NOT_SUPPORTED; diff --git a/2.x/trunk/KProcessHacker/include/dyndata.h b/2.x/trunk/KProcessHacker/include/dyndata.h index 095f4903f..9407daf85 100644 --- a/2.x/trunk/KProcessHacker/include/dyndata.h +++ b/2.x/trunk/KProcessHacker/include/dyndata.h @@ -6,6 +6,11 @@ typedef NTSTATUS (NTAPI *_PsTerminateProcess)( __in NTSTATUS ExitStatus ); +typedef NTSTATUS (FASTCALL *_PsTerminateProcess63)( + __in PEPROCESS Process, + __in NTSTATUS ExitStatus + ); + typedef NTSTATUS (NTAPI *_PspTerminateThreadByPointer51)( __in PETHREAD Thread, __in NTSTATUS ExitStatus @@ -17,6 +22,12 @@ typedef NTSTATUS (NTAPI *_PspTerminateThreadByPointer52)( __in BOOLEAN DirectTerminate ); +typedef NTSTATUS (FASTCALL *_PspTerminateThreadByPointer63)( + __in PETHREAD Thread, + __in NTSTATUS ExitStatus, + __in BOOLEAN DirectTerminate + ); + typedef struct _KPH_PROCEDURE_SCAN { BOOLEAN Initialized; @@ -54,15 +65,17 @@ EXT RTL_OSVERSIONINFOEXW KphDynOsVersionInfo; // Oh: OBJECT_HEADER // Ot: OBJECT_TYPE // Oti: OBJECT_TYPE_INITIALIZER, offset measured from an OBJECT_TYPE +// ObDecodeShift: shift value in ObpDecodeObject +// ObAttributesShift: shift value in ObpGetHandleAttributes EXT ULONG KphDynEgeGuid OFFDEFAULT; EXT ULONG KphDynEpObjectTable OFFDEFAULT; -EXT ULONG KphDynEpProtectedProcessOff OFFDEFAULT; -EXT ULONG KphDynEpProtectedProcessBit OFFDEFAULT; EXT ULONG KphDynEpRundownProtect OFFDEFAULT; EXT ULONG KphDynEreGuidEntry OFFDEFAULT; EXT ULONG KphDynHtHandleContentionEvent OFFDEFAULT; EXT ULONG KphDynOtName OFFDEFAULT; EXT ULONG KphDynOtIndex OFFDEFAULT; +EXT ULONG KphDynObDecodeShift OFFDEFAULT; +EXT ULONG KphDynObAttributesShift OFFDEFAULT; // Procedures EXT KPH_PROCEDURE_SCAN KphDynPsTerminateProcessScan; diff --git a/2.x/trunk/KProcessHacker/include/kph.h b/2.x/trunk/KProcessHacker/include/kph.h index c22f07e5c..50d42cc83 100644 --- a/2.x/trunk/KProcessHacker/include/kph.h +++ b/2.x/trunk/KProcessHacker/include/kph.h @@ -7,11 +7,6 @@ #include #include -// Configuration - -// Disable features that conflict with driver signing requirements. -// KPH_CONFIG_CLEAN - // Debugging #ifdef DBG diff --git a/2.x/trunk/KProcessHacker/include/ntfill.h b/2.x/trunk/KProcessHacker/include/ntfill.h index 9c4d79120..a3f89e286 100644 --- a/2.x/trunk/KProcessHacker/include/ntfill.h +++ b/2.x/trunk/KProcessHacker/include/ntfill.h @@ -1,6 +1,10 @@ #ifndef NTFILL_H #define NTFILL_H +extern ULONG KphDynNtVersion; +extern ULONG KphDynObDecodeShift; +extern ULONG KphDynObAttributesShift; + // IO extern POBJECT_TYPE *IoDriverObjectType; @@ -130,31 +134,45 @@ ZwQuerySystemInformation( #define ObpDecodeGrantedAccess(Access) \ ((Access) & ~ObpAccessProtectCloseBit) +FORCEINLINE PVOID ObpDecodeObject(PVOID Object) +{ #ifdef _M_X64 -#define ObpDecodeObject(Object) \ - (KphDynNtVersion >= PHNT_WIN8 ? \ - (PVOID)(((LONG_PTR)(Object) >> 19) & ~(ULONG_PTR)0xf) : \ - (PVOID)((ULONG_PTR)(Object) & ~OBJ_HANDLE_ATTRIBUTES)) + if (KphDynNtVersion >= PHNT_WIN8) + { + if (KphDynObDecodeShift != -1) + return (PVOID)(((LONG_PTR)Object >> KphDynObDecodeShift) & ~(ULONG_PTR)0xf); + else + return NULL; + } + else + { + return (PVOID)((ULONG_PTR)Object & ~OBJ_HANDLE_ATTRIBUTES); + } #else -#define ObpDecodeObject(Object) \ - ((PVOID)((ULONG_PTR)(Object) & ~OBJ_HANDLE_ATTRIBUTES)) + return (PVOID)((ULONG_PTR)Object & ~OBJ_HANDLE_ATTRIBUTES); #endif +} +FORCEINLINE ULONG ObpGetHandleAttributes(PHANDLE_TABLE_ENTRY HandleTableEntry) +{ #ifdef _M_X64 -#define ObpGetHandleAttributes(HandleTableEntry) \ - (KphDynNtVersion >= PHNT_WIN8 ? \ - ((ULONG)((HandleTableEntry)->Value >> 20) & 0x3) : \ - (((HandleTableEntry)->ObAttributes & (OBJ_INHERIT | OBJ_AUDIT_OBJECT_CLOSE)) | \ - (((HandleTableEntry)->GrantedAccess & ObpAccessProtectCloseBit) ? \ - OBJ_PROTECT_CLOSE : 0) \ - )) + if (KphDynNtVersion >= PHNT_WIN8) + { + if (KphDynObAttributesShift != -1) + return (ULONG)(HandleTableEntry->Value >> KphDynObAttributesShift) & 0x3; + else + return 0; + } + else + { + return (HandleTableEntry->ObAttributes & (OBJ_INHERIT | OBJ_AUDIT_OBJECT_CLOSE)) | + ((HandleTableEntry->GrantedAccess & ObpAccessProtectCloseBit) ? OBJ_PROTECT_CLOSE : 0); + } #else -#define ObpGetHandleAttributes(HandleTableEntry) \ - (((HandleTableEntry)->ObAttributes & (OBJ_INHERIT | OBJ_AUDIT_OBJECT_CLOSE)) | \ - (((HandleTableEntry)->GrantedAccess & ObpAccessProtectCloseBit) ? \ - OBJ_PROTECT_CLOSE : 0) \ - ) + return (HandleTableEntry->ObAttributes & (OBJ_INHERIT | OBJ_AUDIT_OBJECT_CLOSE)) | + ((HandleTableEntry->GrantedAccess & ObpAccessProtectCloseBit) ? OBJ_PROTECT_CLOSE : 0); #endif +} typedef struct _OBJECT_CREATE_INFORMATION OBJECT_CREATE_INFORMATION, *POBJECT_CREATE_INFORMATION; diff --git a/2.x/trunk/KProcessHacker/object.c b/2.x/trunk/KProcessHacker/object.c index 342115523..bc49ba538 100644 --- a/2.x/trunk/KProcessHacker/object.c +++ b/2.x/trunk/KProcessHacker/object.c @@ -1,7 +1,7 @@ /* * KProcessHacker * - * Copyright (C) 2010-2012 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -191,30 +191,32 @@ BOOLEAN KphpEnumerateProcessHandlesEnumCallback61( { PKPHP_ENUMERATE_PROCESS_HANDLES_CONTEXT context = Context; KPH_PROCESS_HANDLE handleInfo; + POBJECT_HEADER objectHeader; POBJECT_TYPE objectType; PKPH_PROCESS_HANDLE entryInBuffer; PAGED_CODE(); + objectHeader = ObpDecodeObject(HandleTableEntry->Object); handleInfo.Handle = Handle; - handleInfo.Object = &((POBJECT_HEADER)ObpDecodeObject(HandleTableEntry->Object))->Body; + handleInfo.Object = objectHeader ? &objectHeader->Body : NULL; handleInfo.GrantedAccess = ObpDecodeGrantedAccess(HandleTableEntry->GrantedAccess); + handleInfo.ObjectTypeIndex = -1; handleInfo.Reserved1 = 0; handleInfo.HandleAttributes = ObpGetHandleAttributes(HandleTableEntry); handleInfo.Reserved2 = 0; - objectType = KphGetObjectType(handleInfo.Object); - - if (objectType && KphDynOtIndex != -1) - { - if (KphDynNtVersion >= PHNT_WIN7) - handleInfo.ObjectTypeIndex = (USHORT)*(PUCHAR)((ULONG_PTR)objectType + KphDynOtIndex); - else - handleInfo.ObjectTypeIndex = (USHORT)*(PULONG)((ULONG_PTR)objectType + KphDynOtIndex); - } - else + if (handleInfo.Object) { - handleInfo.ObjectTypeIndex = -1; + objectType = KphGetObjectType(handleInfo.Object); + + if (objectType && KphDynOtIndex != -1) + { + if (KphDynNtVersion >= PHNT_WIN7) + handleInfo.ObjectTypeIndex = (USHORT)*(PUCHAR)((ULONG_PTR)objectType + KphDynOtIndex); + else + handleInfo.ObjectTypeIndex = (USHORT)*(PULONG)((ULONG_PTR)objectType + KphDynOtIndex); + } } // Advance the current entry pointer regardless of whether the information will be written; diff --git a/2.x/trunk/KProcessHacker/process.c b/2.x/trunk/KProcessHacker/process.c index 1c2cdd97e..6cdcaf9a0 100644 --- a/2.x/trunk/KProcessHacker/process.c +++ b/2.x/trunk/KProcessHacker/process.c @@ -1,7 +1,7 @@ /* * KProcessHacker * - * Copyright (C) 2010-2011 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -435,6 +435,13 @@ NTSTATUS KphTerminateProcessInternal( mov [status], eax } } + else if (KphDynNtVersion == PHNT_WINBLUE) + { + dprintf("Calling 8.1-style PsTerminateProcess\n"); + + // PsTerminateProcess on 8.1 is fastcall. + status = ((_PsTerminateProcess63)PsTerminateProcess_I)(Process, ExitStatus); + } else { return STATUS_NOT_SUPPORTED; @@ -585,22 +592,12 @@ NTSTATUS KpiQueryInformationProcess( { case KphProcessProtectionInformation: { - BOOLEAN protectedProcess = FALSE; // stupid x64 compiler + BOOLEAN protectedProcess = FALSE; if (PsIsProtectedProcess_I) - { protectedProcess = PsIsProtectedProcess_I(process); - } -#if !defined(KPH_CONFIG_CLEAN) - else if (KphDynEpProtectedProcessOff != -1 && KphDynEpProtectedProcessBit != -1) - { - protectedProcess = (*(PULONG)((ULONG_PTR)process + KphDynEpProtectedProcessOff) >> KphDynEpProtectedProcessBit) & 0x1; - } -#endif else - { status = STATUS_NOT_SUPPORTED; - } if (NT_SUCCESS(status)) { @@ -766,9 +763,6 @@ NTSTATUS KpiSetInformationProcess( switch (ProcessInformationClass) { - case KphProcessProtectionInformation: - alignment = sizeof(KPH_PROCESS_PROTECTION_INFORMATION); - break; default: alignment = sizeof(ULONG); break; @@ -798,48 +792,6 @@ NTSTATUS KpiSetInformationProcess( switch (ProcessInformationClass) { - case KphProcessProtectionInformation: - { -#if defined(KPH_CONFIG_CLEAN) - status = STATUS_IMPLEMENTATION_LIMIT; -#else - BOOLEAN protectedProcess = FALSE; // stupid x64 compiler - BOOLEAN change; - - if (KphDynEpProtectedProcessOff != -1 && KphDynEpProtectedProcessBit != -1) - { - if (ProcessInformationLength == sizeof(KPH_PROCESS_PROTECTION_INFORMATION)) - { - __try - { - protectedProcess = ((PKPH_PROCESS_PROTECTION_INFORMATION)ProcessInformation)->IsProtectedProcess; - change = TRUE; - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - status = GetExceptionCode(); - } - } - else - { - status = STATUS_INFO_LENGTH_MISMATCH; - } - } - else - { - status = STATUS_NOT_SUPPORTED; - } - - if (NT_SUCCESS(status)) - { - if (protectedProcess) - InterlockedOr((PLONG)((ULONG_PTR)process + KphDynEpProtectedProcessOff), (ULONG)(1 << KphDynEpProtectedProcessBit)); - else - InterlockedAnd((PLONG)((ULONG_PTR)process + KphDynEpProtectedProcessOff), ~(ULONG)(1 << KphDynEpProtectedProcessBit)); - } -#endif - } - break; case KphProcessExecuteFlags: { ULONG executeFlags; diff --git a/2.x/trunk/KProcessHacker/resource.rc b/2.x/trunk/KProcessHacker/resource.rc index 7d8e6c25f..a08183112 100644 --- a/2.x/trunk/KProcessHacker/resource.rc +++ b/2.x/trunk/KProcessHacker/resource.rc @@ -1,7 +1,7 @@ #include -#define VER_COMMA 2,6,0,0 -#define VER_STR "2.6\0" +#define VER_COMMA 2,7,0,0 +#define VER_STR "2.7\0" #define VER_FILEVERSION VER_COMMA #define VER_FILEVERSION_STR VER_STR diff --git a/2.x/trunk/KProcessHacker/sign.cmd b/2.x/trunk/KProcessHacker/sign.cmd new file mode 100644 index 000000000..fe9c32599 --- /dev/null +++ b/2.x/trunk/KProcessHacker/sign.cmd @@ -0,0 +1,7 @@ +@echo off +set PHBASE=.. +set SIGN_TIMESTAMP=1 +copy bin\i386\kprocesshacker.sys bin-signed\i386\kprocesshacker.sys +copy bin\amd64\kprocesshacker.sys bin-signed\amd64\kprocesshacker.sys +call ..\build\internal\sign.cmd bin-signed\i386\kprocesshacker.sys kmcs +call ..\build\internal\sign.cmd bin-signed\amd64\kprocesshacker.sys kmcs diff --git a/2.x/trunk/KProcessHacker/testsign.cmd b/2.x/trunk/KProcessHacker/testsign.cmd deleted file mode 100644 index 060e34b23..000000000 --- a/2.x/trunk/KProcessHacker/testsign.cmd +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -pushd bin\amd64 -signtool sign /a /d "KProcessHacker" kprocesshacker.sys -popd \ No newline at end of file diff --git a/2.x/trunk/KProcessHacker/thread.c b/2.x/trunk/KProcessHacker/thread.c index 9b846e5fe..5618bdfa2 100644 --- a/2.x/trunk/KProcessHacker/thread.c +++ b/2.x/trunk/KProcessHacker/thread.c @@ -1,7 +1,7 @@ /* * KProcessHacker * - * Copyright (C) 2010-2011 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -328,6 +328,15 @@ NTSTATUS KphTerminateThreadByPointerInternal( return status; } + else if (KphDynNtVersion == PHNT_WINBLUE) + { + dprintf("Calling 8.1-style PspTerminateThreadByPointer\n"); + return ((_PspTerminateThreadByPointer63)PspTerminateThreadByPointer_I)( + Thread, + ExitStatus, + Thread == PsGetCurrentThread() + ); + } else { return STATUS_NOT_SUPPORTED; diff --git a/2.x/trunk/ProcessHacker.sln b/2.x/trunk/ProcessHacker.sln index c8ecd8b31..4e1fb38a5 100644 --- a/2.x/trunk/ProcessHacker.sln +++ b/2.x/trunk/ProcessHacker.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{2758DC86-368B-430C-9D29-F1EF20032A71}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProcessHacker", "ProcessHacker\ProcessHacker.vcxproj", "{0271DD27-6707-4290-8DFE-285702B7115D}" diff --git a/2.x/trunk/ProcessHacker/ProcessHacker.manifest b/2.x/trunk/ProcessHacker/ProcessHacker.manifest index c0c3e2355..f97a0d688 100644 --- a/2.x/trunk/ProcessHacker/ProcessHacker.manifest +++ b/2.x/trunk/ProcessHacker/ProcessHacker.manifest @@ -31,11 +31,15 @@ + true + + true + \ No newline at end of file diff --git a/2.x/trunk/ProcessHacker/ProcessHacker.rc b/2.x/trunk/ProcessHacker/ProcessHacker.rc index a3c61ad21..b6a1b82a8 100644 --- a/2.x/trunk/ProcessHacker/ProcessHacker.rc +++ b/2.x/trunk/ProcessHacker/ProcessHacker.rc @@ -159,7 +159,7 @@ IDR_THREAD MENU BEGIN POPUP "Thread" BEGIN - MENUITEM "&Inspect", ID_THREAD_INSPECT + MENUITEM "&Inspect\aEnter", ID_THREAD_INSPECT MENUITEM "T&erminate\aDel", ID_THREAD_TERMINATE MENUITEM "Force Terminate", ID_THREAD_FORCETERMINATE MENUITEM "&Suspend", ID_THREAD_SUSPEND @@ -211,7 +211,7 @@ BEGIN MENUITEM "&Inherit", ID_HANDLE_INHERIT MENUITEM SEPARATOR MENUITEM "&Copy\aCtrl+C", ID_HANDLE_COPY - MENUITEM "Prope&rties", ID_HANDLE_PROPERTIES + MENUITEM "Prope&rties\aEnter", ID_HANDLE_PROPERTIES END END @@ -221,9 +221,9 @@ BEGIN BEGIN MENUITEM "&Unload\aDel", ID_MODULE_UNLOAD MENUITEM SEPARATOR - MENUITEM "&Inspect", ID_MODULE_INSPECT - MENUITEM "&Search Online", ID_MODULE_SEARCHONLINE - MENUITEM "Open &File Location", ID_MODULE_OPENFILELOCATION + MENUITEM "&Inspect\aEnter", ID_MODULE_INSPECT + MENUITEM "&Search Online\aCtrl+M", ID_MODULE_SEARCHONLINE + MENUITEM "Open &File Location\aCtrl+Enter", ID_MODULE_OPENFILELOCATION MENUITEM "&Copy\aCtrl+C", ID_MODULE_COPY MENUITEM "P&roperties", ID_MODULE_PROPERTIES END @@ -346,10 +346,10 @@ BEGIN POPUP "Object" BEGIN MENUITEM "C&lose\aDel", ID_OBJECT_CLOSE - MENUITEM "&Process Properties", ID_OBJECT_PROCESSPROPERTIES - MENUITEM "Prope&rties", ID_OBJECT_PROPERTIES MENUITEM SEPARATOR MENUITEM "&Copy\aCtrl+C", ID_OBJECT_COPY + MENUITEM "Go to Owning &Process", ID_OBJECT_GOTOOWNINGPROCESS + MENUITEM "Prope&rties", ID_OBJECT_PROPERTIES END END @@ -489,15 +489,16 @@ BEGIN EDITTEXT IDC_PARENTPROCESS,65,165,161,12,ES_AUTOHSCROLL | ES_READONLY LTEXT "DEP:",IDC_STATIC,13,183,16,8 EDITTEXT IDC_DEP,65,181,161,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Protected:",IDC_STATIC,13,200,35,8 - LTEXT "Process Type:",IDC_PROCESSTYPELABEL,13,219,46,8,NOT WS_VISIBLE - LTEXT "32-bit",IDC_PROCESSTYPETEXT,67,219,20,8,NOT WS_VISIBLE + LTEXT "Protection:",IDC_STATIC,13,200,36,8 + LTEXT "Process Type:",IDC_PROCESSTYPELABEL,13,216,46,8,NOT WS_VISIBLE + LTEXT "32-bit",IDC_PROCESSTYPETEXT,67,216,20,8,NOT WS_VISIBLE PUSHBUTTON "Edit",IDC_EDITDEP,230,179,17,15,BS_BITMAP | WS_DISABLED PUSHBUTTON "View",IDC_VIEWPARENTPROCESS,230,163,17,15,BS_BITMAP PUSHBUTTON "Open",IDC_OPENFILENAME,230,64,17,15,BS_BITMAP - LTEXT "Yes?",IDC_PROTECTION,55,200,24,8 - LTEXT "ASLR:",IDC_ASLRLABEL,91,200,20,8 - EDITTEXT IDC_ASLR,116,199,131,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ASLR:",IDC_ASLRLABEL,125,200,20,8 + EDITTEXT IDC_ASLR,147,200,99,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + CONTROL "Company Name Link",IDC_COMPANYNAME_LINK,"SysLink",LWS_NOPREFIX | NOT WS_VISIBLE | WS_TABSTOP,46,29,183,9 + EDITTEXT IDC_PROTECTION,51,200,69,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER END IDD_PROCMODULES DIALOGEX 0, 0, 260, 260 @@ -589,7 +590,7 @@ BEGIN ICON IDI_PROCESSHACKER,IDC_STATIC,16,15,20,20 LTEXT "Process Hacker",IDC_ABOUT_NAME,45,14,192,8 LTEXT "Licensed under the GNU GPL, v3.",IDC_STATIC,45,27,193,8 - LTEXT "Copyright (c) 2008-2012 wj32",IDC_STATIC,15,40,97,8 + LTEXT "Copyright (c) 2008-2013 Wen Jia Liu (wj32)",IDC_STATIC,15,40,140,8 PUSHBUTTON "Diagnostics",IDC_DIAGNOSTICS,160,174,50,14 CONTROL "Process Hacker on SourceForge.net",IDC_LINK_SF, "SysLink",WS_TABSTOP,7,177,130,11 @@ -657,7 +658,6 @@ BEGIN LTEXT "Static",IDC_PAGED,182,89,39,8 LTEXT "Non-Paged:",IDC_STATIC,138,100,39,8 LTEXT "Static",IDC_NONPAGED,182,100,39,8 - PUSHBUTTON "Properties",IDC_PROPERTIES,7,122,50,14 END IDD_INFORMATION DIALOGEX 0, 0, 317, 184 diff --git a/2.x/trunk/ProcessHacker/ProcessHacker.vcxproj b/2.x/trunk/ProcessHacker/ProcessHacker.vcxproj index e85bf7e39..851b6c69c 100644 --- a/2.x/trunk/ProcessHacker/ProcessHacker.vcxproj +++ b/2.x/trunk/ProcessHacker/ProcessHacker.vcxproj @@ -63,7 +63,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)bin\$(Configuration)$(PlatformArchitecture)\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ false @@ -93,7 +92,6 @@ StdCall true true - StreamingSIMDExtensions noarg.obj;noenv.obj;ntdll.lib;winsta.lib;comctl32.lib;version.lib;%(AdditionalDependencies) @@ -101,7 +99,7 @@ true Windows MachineX86 - /SUBSYSTEM:WINDOWS,5.01 %(AdditionalOptions) + 5.01 update_rev.bat @@ -111,9 +109,6 @@ - - X64 - Disabled ../phlib/include;include;%(AdditionalIncludeDirectories) @@ -125,7 +120,6 @@ StdCall true true - NotSet noarg.obj;noenv.obj;ntdll.lib;winsta.lib;comctl32.lib;version.lib;%(AdditionalDependencies) @@ -133,7 +127,7 @@ true Windows MachineX64 - /SUBSYSTEM:WINDOWS,5.02 %(AdditionalOptions) + 5.02 update_rev.bat @@ -168,7 +162,7 @@ true MachineX86 true - /SUBSYSTEM:WINDOWS,5.01 %(AdditionalOptions) + 5.01 update_rev.bat @@ -178,9 +172,6 @@ - - X64 - MaxSpeed true @@ -195,7 +186,6 @@ StdCall true true - NotSet noarg.obj;noenv.obj;ntdll.lib;winsta.lib;comctl32.lib;version.lib;%(AdditionalDependencies) @@ -206,7 +196,7 @@ true MachineX64 true - /SUBSYSTEM:WINDOWS,5.02 %(AdditionalOptions) + 5.02 update_rev.bat diff --git a/2.x/trunk/ProcessHacker/about.c b/2.x/trunk/ProcessHacker/about.c index c3842da1c..429efdd02 100644 --- a/2.x/trunk/ProcessHacker/about.c +++ b/2.x/trunk/ProcessHacker/about.c @@ -2,7 +2,7 @@ * Process Hacker - * about dialog * - * Copyright (C) 2010-2011 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -24,10 +24,10 @@ #include static INT_PTR CALLBACK PhpAboutDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -56,10 +56,9 @@ static INT_PTR CALLBACK PhpAboutDlgProc( SetDlgItemText(hwndDlg, IDC_CREDITS, L" Installer by XhmikosR\n" - L" Driver signed by the ReactOS Foundation\n" L"Thanks to:\n" L" dmex\n" - L" Donators - thank you for your support!\n" + L" Donors - thank you for your support!\n" L" Sysinternals Forums\n" L" ReactOS\n" L"Process Hacker uses the following components:\n" @@ -116,7 +115,7 @@ static INT_PTR CALLBACK PhpAboutDlgProc( } VOID PhShowAboutDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ) { DialogBox( @@ -128,7 +127,7 @@ VOID PhShowAboutDialog( } FORCEINLINE ULONG PhpGetObjectTypeObjectCount( - __in PPH_OBJECT_TYPE ObjectType + _In_ PPH_OBJECT_TYPE ObjectType ) { PH_OBJECT_TYPE_INFORMATION info; diff --git a/2.x/trunk/ProcessHacker/actions.c b/2.x/trunk/ProcessHacker/actions.c index 27007b93e..63512e66d 100644 --- a/2.x/trunk/ProcessHacker/actions.c +++ b/2.x/trunk/ProcessHacker/actions.c @@ -35,7 +35,7 @@ #include typedef DWORD (WINAPI *_SetTcpEntry)( - __in PMIB_TCPROW pTcpRow + _In_ PMIB_TCPROW pTcpRow ); static PWSTR DangerousProcesses[] = @@ -50,11 +50,11 @@ static ULONG PhSvcReferenceCount = 0; static PH_QUEUED_LOCK PhSvcStartLock = PH_QUEUED_LOCK_INIT; HRESULT CALLBACK PhpElevateActionCallbackProc( - __in HWND hwnd, - __in UINT uNotification, - __in WPARAM wParam, - __in LPARAM lParam, - __in LONG_PTR dwRefData + _In_ HWND hwnd, + _In_ UINT uNotification, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ LONG_PTR dwRefData ) { switch (uNotification) @@ -68,10 +68,10 @@ HRESULT CALLBACK PhpElevateActionCallbackProc( } BOOLEAN PhpShowElevatePrompt( - __in HWND hWnd, - __in PWSTR Message, - __in NTSTATUS Status, - __out PINT Button + _In_ HWND hWnd, + _In_ PWSTR Message, + _In_ NTSTATUS Status, + _Out_ PINT Button ) { TASKDIALOGCONFIG config = { sizeof(config) }; @@ -138,11 +138,11 @@ BOOLEAN PhpShowElevatePrompt( * FALSE, in which case you need to show your own error message. */ BOOLEAN PhpShowErrorAndElevateAction( - __in HWND hWnd, - __in PWSTR Message, - __in NTSTATUS Status, - __in PWSTR Command, - __out PBOOLEAN Success + _In_ HWND hWnd, + _In_ PWSTR Message, + _In_ NTSTATUS Status, + _In_ PWSTR Command, + _Out_ PBOOLEAN Success ) { PH_ACTION_ELEVATION_LEVEL elevationLevel; @@ -230,10 +230,10 @@ BOOLEAN PhpShowErrorAndElevateAction( * FALSE, in which case you need to show your own error message. */ BOOLEAN PhpShowErrorAndConnectToPhSvc( - __in HWND hWnd, - __in PWSTR Message, - __in NTSTATUS Status, - __out PBOOLEAN Connected + _In_ HWND hWnd, + _In_ PWSTR Message, + _In_ NTSTATUS Status, + _Out_ PBOOLEAN Connected ) { PH_ACTION_ELEVATION_LEVEL elevationLevel; @@ -286,8 +286,8 @@ BOOLEAN PhpShowErrorAndConnectToPhSvc( * attempt failed. */ BOOLEAN PhUiConnectToPhSvc( - __in HWND hWnd, - __in BOOLEAN ConnectOnly + _In_ HWND hWnd, + _In_ BOOLEAN ConnectOnly ) { NTSTATUS status; @@ -387,7 +387,7 @@ VOID PhUiDisconnectFromPhSvc( } BOOLEAN PhUiLockComputer( - __in HWND hWnd + _In_ HWND hWnd ) { if (LockWorkStation()) @@ -399,7 +399,7 @@ BOOLEAN PhUiLockComputer( } BOOLEAN PhUiLogoffComputer( - __in HWND hWnd + _In_ HWND hWnd ) { if (ExitWindowsEx(EWX_LOGOFF, 0)) @@ -411,7 +411,7 @@ BOOLEAN PhUiLogoffComputer( } BOOLEAN PhUiSleepComputer( - __in HWND hWnd + _In_ HWND hWnd ) { NTSTATUS status; @@ -430,7 +430,7 @@ BOOLEAN PhUiSleepComputer( } BOOLEAN PhUiHibernateComputer( - __in HWND hWnd + _In_ HWND hWnd ) { NTSTATUS status; @@ -449,8 +449,8 @@ BOOLEAN PhUiHibernateComputer( } BOOLEAN PhUiRestartComputer( - __in HWND hWnd, - __in ULONG Flags + _In_ HWND hWnd, + _In_ ULONG Flags ) { if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage( @@ -471,8 +471,8 @@ BOOLEAN PhUiRestartComputer( } BOOLEAN PhUiShutdownComputer( - __in HWND hWnd, - __in ULONG Flags + _In_ HWND hWnd, + _In_ ULONG Flags ) { if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage( @@ -501,8 +501,8 @@ BOOLEAN PhUiShutdownComputer( } BOOLEAN PhUiConnectSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ) { BOOLEAN success = FALSE; @@ -556,8 +556,8 @@ BOOLEAN PhUiConnectSession( } BOOLEAN PhUiDisconnectSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ) { if (WinStationDisconnect(NULL, SessionId, FALSE)) @@ -569,8 +569,8 @@ BOOLEAN PhUiDisconnectSession( } BOOLEAN PhUiLogoffSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ) { if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage( @@ -596,7 +596,7 @@ BOOLEAN PhUiLogoffSession( * \param ProcessId The PID of the process to check. */ static BOOLEAN PhpIsDangerousProcess( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -663,12 +663,12 @@ static BOOLEAN PhpIsDangerousProcess( * otherwise FALSE. */ static BOOLEAN PhpShowContinueMessageProcesses( - __in HWND hWnd, - __in PWSTR Verb, - __in_opt PWSTR Message, - __in BOOLEAN WarnOnlyIfDangerous, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_opt_ PWSTR Message, + _In_ BOOLEAN WarnOnlyIfDangerous, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ) { PWSTR object; @@ -814,11 +814,11 @@ static BOOLEAN PhpShowContinueMessageProcesses( * executing an action on multiple processes. */ static BOOLEAN PhpShowErrorProcess( - __in HWND hWnd, - __in PWSTR Verb, - __in PPH_PROCESS_ITEM Process, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_ PPH_PROCESS_ITEM Process, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ) { if (!PH_IS_FAKE_PROCESS_ID(Process->ProcessId)) @@ -851,12 +851,13 @@ static BOOLEAN PhpShowErrorProcess( } BOOLEAN PhUiTerminateProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ) { BOOLEAN success = TRUE; + BOOLEAN cancelled = FALSE; ULONG i; if (!PhpShowContinueMessageProcesses( @@ -894,7 +895,7 @@ BOOLEAN PhUiTerminateProcesses( success = FALSE; - if (NumberOfProcesses == 1 && PhpShowErrorAndConnectToPhSvc( + if (!cancelled && PhpShowErrorAndConnectToPhSvc( hWnd, PhaConcatStrings2(L"Unable to terminate ", Processes[i]->ProcessName->Buffer)->Buffer, status, @@ -903,13 +904,17 @@ BOOLEAN PhUiTerminateProcesses( { if (connected) { - if (NT_SUCCESS(status = PhSvcCallControlProcess(Processes[0]->ProcessId, PhSvcControlProcessTerminate, 0))) + if (NT_SUCCESS(status = PhSvcCallControlProcess(Processes[i]->ProcessId, PhSvcControlProcessTerminate, 0))) success = TRUE; else - PhpShowErrorProcess(hWnd, L"terminate", Processes[0], status, 0); + PhpShowErrorProcess(hWnd, L"terminate", Processes[i], status, 0); PhUiDisconnectFromPhSvc(); } + else + { + cancelled = TRUE; + } } else { @@ -923,10 +928,10 @@ BOOLEAN PhUiTerminateProcesses( } BOOLEAN PhpUiTerminateTreeProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in PVOID Processes, - __inout PBOOLEAN Success + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ PVOID Processes, + _Inout_ PBOOLEAN Success ) { NTSTATUS status; @@ -991,8 +996,8 @@ BOOLEAN PhpUiTerminateTreeProcess( } BOOLEAN PhUiTerminateTreeProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { NTSTATUS status; @@ -1031,12 +1036,13 @@ BOOLEAN PhUiTerminateTreeProcess( } BOOLEAN PhUiSuspendProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ) { BOOLEAN success = TRUE; + BOOLEAN cancelled = FALSE; ULONG i; if (!PhpShowContinueMessageProcesses( @@ -1070,7 +1076,7 @@ BOOLEAN PhUiSuspendProcesses( success = FALSE; - if (NumberOfProcesses == 1 && PhpShowErrorAndConnectToPhSvc( + if (!cancelled && PhpShowErrorAndConnectToPhSvc( hWnd, PhaConcatStrings2(L"Unable to suspend ", Processes[i]->ProcessName->Buffer)->Buffer, status, @@ -1079,13 +1085,17 @@ BOOLEAN PhUiSuspendProcesses( { if (connected) { - if (NT_SUCCESS(status = PhSvcCallControlProcess(Processes[0]->ProcessId, PhSvcControlProcessSuspend, 0))) + if (NT_SUCCESS(status = PhSvcCallControlProcess(Processes[i]->ProcessId, PhSvcControlProcessSuspend, 0))) success = TRUE; else - PhpShowErrorProcess(hWnd, L"suspend", Processes[0], status, 0); + PhpShowErrorProcess(hWnd, L"suspend", Processes[i], status, 0); PhUiDisconnectFromPhSvc(); } + else + { + cancelled = TRUE; + } } else { @@ -1099,12 +1109,13 @@ BOOLEAN PhUiSuspendProcesses( } BOOLEAN PhUiResumeProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ) { BOOLEAN success = TRUE; + BOOLEAN cancelled = FALSE; ULONG i; if (!PhpShowContinueMessageProcesses( @@ -1138,7 +1149,7 @@ BOOLEAN PhUiResumeProcesses( success = FALSE; - if (NumberOfProcesses == 1 && PhpShowErrorAndConnectToPhSvc( + if (!cancelled && PhpShowErrorAndConnectToPhSvc( hWnd, PhaConcatStrings2(L"Unable to resume ", Processes[i]->ProcessName->Buffer)->Buffer, status, @@ -1147,13 +1158,17 @@ BOOLEAN PhUiResumeProcesses( { if (connected) { - if (NT_SUCCESS(status = PhSvcCallControlProcess(Processes[0]->ProcessId, PhSvcControlProcessResume, 0))) + if (NT_SUCCESS(status = PhSvcCallControlProcess(Processes[i]->ProcessId, PhSvcControlProcessResume, 0))) success = TRUE; else - PhpShowErrorProcess(hWnd, L"resume", Processes[0], status, 0); + PhpShowErrorProcess(hWnd, L"resume", Processes[i], status, 0); PhUiDisconnectFromPhSvc(); } + else + { + cancelled = TRUE; + } } else { @@ -1167,8 +1182,8 @@ BOOLEAN PhUiResumeProcesses( } BOOLEAN PhUiRestartProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { NTSTATUS status; @@ -1282,8 +1297,8 @@ BOOLEAN PhUiRestartProcess( // Contributed by evilpie (#2981421) BOOLEAN PhUiDebugProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { NTSTATUS status; @@ -1380,9 +1395,9 @@ BOOLEAN PhUiDebugProcess( } BOOLEAN PhUiReduceWorkingSetProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ) { BOOLEAN success = TRUE; @@ -1428,9 +1443,9 @@ BOOLEAN PhUiReduceWorkingSetProcesses( } BOOLEAN PhUiSetVirtualizationProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in BOOLEAN Enable + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ BOOLEAN Enable ) { NTSTATUS status; @@ -1487,8 +1502,8 @@ BOOLEAN PhUiSetVirtualizationProcess( } BOOLEAN PhUiDetachFromDebuggerProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { NTSTATUS status; @@ -1542,8 +1557,8 @@ BOOLEAN PhUiDetachFromDebuggerProcess( } BOOLEAN PhUiInjectDllProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { static PH_FILETYPE_FILTER filters[] = @@ -1598,9 +1613,9 @@ BOOLEAN PhUiInjectDllProcess( } BOOLEAN PhUiSetIoPriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG IoPriority + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG IoPriority ) { NTSTATUS status; @@ -1652,9 +1667,9 @@ BOOLEAN PhUiSetIoPriorityProcess( } BOOLEAN PhUiSetPagePriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG PagePriority + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG PagePriority ) { NTSTATUS status; @@ -1686,9 +1701,9 @@ BOOLEAN PhUiSetPagePriorityProcess( } BOOLEAN PhUiSetPriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG PriorityClass + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG PriorityClass ) { NTSTATUS status; @@ -1743,8 +1758,8 @@ BOOLEAN PhUiSetPriorityProcess( } BOOLEAN PhUiSetDepStatusProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { static WCHAR *choices[] = { L"Disabled", L"Enabled", L"Enabled, DEP-ATL thunk emulation disabled" }; @@ -1865,8 +1880,8 @@ BOOLEAN PhUiSetDepStatusProcess( } BOOLEAN PhUiSetProtectionProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { static WCHAR *choices[] = { L"Protected", L"Not Protected" }; @@ -1941,11 +1956,11 @@ BOOLEAN PhUiSetProtectionProcess( } static VOID PhpShowErrorService( - __in HWND hWnd, - __in PWSTR Verb, - __in PPH_SERVICE_ITEM Service, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_ PPH_SERVICE_ITEM Service, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ) { PhShowStatus( @@ -1961,8 +1976,8 @@ static VOID PhpShowErrorService( } BOOLEAN PhUiStartService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ) { SC_HANDLE serviceHandle; @@ -2012,8 +2027,8 @@ BOOLEAN PhUiStartService( } BOOLEAN PhUiContinueService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ) { SC_HANDLE serviceHandle; @@ -2065,8 +2080,8 @@ BOOLEAN PhUiContinueService( } BOOLEAN PhUiPauseService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ) { SC_HANDLE serviceHandle; @@ -2118,8 +2133,8 @@ BOOLEAN PhUiPauseService( } BOOLEAN PhUiStopService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ) { SC_HANDLE serviceHandle; @@ -2171,8 +2186,8 @@ BOOLEAN PhUiStopService( } BOOLEAN PhUiDeleteService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ) { SC_HANDLE serviceHandle; @@ -2233,13 +2248,14 @@ BOOLEAN PhUiDeleteService( } BOOLEAN PhUiCloseConnections( - __in HWND hWnd, - __in PPH_NETWORK_ITEM *Connections, - __in ULONG NumberOfConnections + _In_ HWND hWnd, + _In_ PPH_NETWORK_ITEM *Connections, + _In_ ULONG NumberOfConnections ) { BOOLEAN success = TRUE; + BOOLEAN cancelled = FALSE; ULONG result; ULONG i; _SetTcpEntry SetTcpEntry_I; @@ -2281,7 +2297,7 @@ BOOLEAN PhUiCloseConnections( if (result == ERROR_MR_MID_NOT_FOUND) result = ERROR_ACCESS_DENIED; - if (NumberOfConnections == 1 && PhpShowErrorAndConnectToPhSvc( + if (!cancelled && PhpShowErrorAndConnectToPhSvc( hWnd, L"Unable to close the TCP connection", NTSTATUS_FROM_WIN32(result), @@ -2297,6 +2313,10 @@ BOOLEAN PhUiCloseConnections( PhUiDisconnectFromPhSvc(); } + else + { + cancelled = TRUE; + } } else { @@ -2317,12 +2337,12 @@ BOOLEAN PhUiCloseConnections( } static BOOLEAN PhpShowContinueMessageThreads( - __in HWND hWnd, - __in PWSTR Verb, - __in PWSTR Message, - __in BOOLEAN Warning, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_ PWSTR Message, + _In_ BOOLEAN Warning, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ) { PWSTR object; @@ -2359,11 +2379,11 @@ static BOOLEAN PhpShowContinueMessageThreads( } static BOOLEAN PhpShowErrorThread( - __in HWND hWnd, - __in PWSTR Verb, - __in PPH_THREAD_ITEM Thread, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_ PPH_THREAD_ITEM Thread, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ) { return PhShowContinueStatus( @@ -2379,12 +2399,13 @@ static BOOLEAN PhpShowErrorThread( } BOOLEAN PhUiTerminateThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ) { BOOLEAN success = TRUE; + BOOLEAN cancelled = FALSE; ULONG i; if (!PhpShowContinueMessageThreads( @@ -2418,7 +2439,7 @@ BOOLEAN PhUiTerminateThreads( success = FALSE; - if (NumberOfThreads == 1 && PhpShowErrorAndConnectToPhSvc( + if (!cancelled && PhpShowErrorAndConnectToPhSvc( hWnd, PhaFormatString(L"Unable to terminate thread %u", (ULONG)Threads[i]->ThreadId)->Buffer, status, @@ -2427,13 +2448,17 @@ BOOLEAN PhUiTerminateThreads( { if (connected) { - if (NT_SUCCESS(status = PhSvcCallControlThread(Threads[0]->ThreadId, PhSvcControlThreadTerminate, 0))) + if (NT_SUCCESS(status = PhSvcCallControlThread(Threads[i]->ThreadId, PhSvcControlThreadTerminate, 0))) success = TRUE; else - PhpShowErrorThread(hWnd, L"terminate", Threads[0], status, 0); + PhpShowErrorThread(hWnd, L"terminate", Threads[i], status, 0); PhUiDisconnectFromPhSvc(); } + else + { + cancelled = TRUE; + } } else { @@ -2447,10 +2472,10 @@ BOOLEAN PhUiTerminateThreads( } BOOLEAN PhUiForceTerminateThreads( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ) { BOOLEAN success = TRUE; @@ -2515,12 +2540,13 @@ BOOLEAN PhUiForceTerminateThreads( } BOOLEAN PhUiSuspendThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ) { BOOLEAN success = TRUE; + BOOLEAN cancelled = FALSE; ULONG i; for (i = 0; i < NumberOfThreads; i++) @@ -2544,7 +2570,7 @@ BOOLEAN PhUiSuspendThreads( success = FALSE; - if (NumberOfThreads == 1 && PhpShowErrorAndConnectToPhSvc( + if (!cancelled && PhpShowErrorAndConnectToPhSvc( hWnd, PhaFormatString(L"Unable to suspend thread %u", (ULONG)Threads[i]->ThreadId)->Buffer, status, @@ -2553,13 +2579,17 @@ BOOLEAN PhUiSuspendThreads( { if (connected) { - if (NT_SUCCESS(status = PhSvcCallControlThread(Threads[0]->ThreadId, PhSvcControlThreadSuspend, 0))) + if (NT_SUCCESS(status = PhSvcCallControlThread(Threads[i]->ThreadId, PhSvcControlThreadSuspend, 0))) success = TRUE; else - PhpShowErrorThread(hWnd, L"suspend", Threads[0], status, 0); + PhpShowErrorThread(hWnd, L"suspend", Threads[i], status, 0); PhUiDisconnectFromPhSvc(); } + else + { + cancelled = TRUE; + } } else { @@ -2573,12 +2603,13 @@ BOOLEAN PhUiSuspendThreads( } BOOLEAN PhUiResumeThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ) { BOOLEAN success = TRUE; + BOOLEAN cancelled = FALSE; ULONG i; for (i = 0; i < NumberOfThreads; i++) @@ -2602,7 +2633,7 @@ BOOLEAN PhUiResumeThreads( success = FALSE; - if (NumberOfThreads == 1 && PhpShowErrorAndConnectToPhSvc( + if (!cancelled && PhpShowErrorAndConnectToPhSvc( hWnd, PhaFormatString(L"Unable to resume thread %u", (ULONG)Threads[i]->ThreadId)->Buffer, status, @@ -2611,13 +2642,17 @@ BOOLEAN PhUiResumeThreads( { if (connected) { - if (NT_SUCCESS(status = PhSvcCallControlThread(Threads[0]->ThreadId, PhSvcControlThreadResume, 0))) + if (NT_SUCCESS(status = PhSvcCallControlThread(Threads[i]->ThreadId, PhSvcControlThreadResume, 0))) success = TRUE; else - PhpShowErrorThread(hWnd, L"resume", Threads[0], status, 0); + PhpShowErrorThread(hWnd, L"resume", Threads[i], status, 0); PhUiDisconnectFromPhSvc(); } + else + { + cancelled = TRUE; + } } else { @@ -2631,9 +2666,9 @@ BOOLEAN PhUiResumeThreads( } BOOLEAN PhUiSetPriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG ThreadPriorityWin32 + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG ThreadPriorityWin32 ) { NTSTATUS status; @@ -2662,9 +2697,9 @@ BOOLEAN PhUiSetPriorityThread( } BOOLEAN PhUiSetIoPriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG IoPriority + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG IoPriority ) { NTSTATUS status; @@ -2716,9 +2751,9 @@ BOOLEAN PhUiSetIoPriorityThread( } BOOLEAN PhUiSetPagePriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG PagePriority + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG PagePriority ) { NTSTATUS status; @@ -2750,9 +2785,9 @@ BOOLEAN PhUiSetPagePriorityThread( } BOOLEAN PhUiUnloadModule( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_MODULE_ITEM Module + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_MODULE_ITEM Module ) { NTSTATUS status; @@ -2926,10 +2961,10 @@ BOOLEAN PhUiUnloadModule( } BOOLEAN PhUiFreeMemory( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_MEMORY_ITEM MemoryItem, - __in BOOLEAN Free + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_MEMORY_ITEM MemoryItem, + _In_ BOOLEAN Free ) { NTSTATUS status; @@ -3039,11 +3074,11 @@ BOOLEAN PhUiFreeMemory( } static BOOLEAN PhpShowErrorHandle( - __in HWND hWnd, - __in PWSTR Verb, - __in PPH_HANDLE_ITEM Handle, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_ PPH_HANDLE_ITEM Handle, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ) { if (!PhIsNullOrEmptyString(Handle->BestObjectName)) @@ -3076,11 +3111,11 @@ static BOOLEAN PhpShowErrorHandle( } BOOLEAN PhUiCloseHandles( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM *Handles, - __in ULONG NumberOfHandles, - __in BOOLEAN Warn + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM *Handles, + _In_ ULONG NumberOfHandles, + _In_ BOOLEAN Warn ) { NTSTATUS status; @@ -3156,10 +3191,10 @@ BOOLEAN PhUiCloseHandles( } BOOLEAN PhUiSetAttributesHandle( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM Handle, - __in ULONG Attributes + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM Handle, + _In_ ULONG Attributes ) { NTSTATUS status; @@ -3203,9 +3238,9 @@ BOOLEAN PhUiSetAttributesHandle( } BOOLEAN PhUiDestroyHeap( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PVOID HeapHandle + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PVOID HeapHandle ) { NTSTATUS status; diff --git a/2.x/trunk/ProcessHacker/affinity.c b/2.x/trunk/ProcessHacker/affinity.c index 2b83df846..ee1b3ece6 100644 --- a/2.x/trunk/ProcessHacker/affinity.c +++ b/2.x/trunk/ProcessHacker/affinity.c @@ -39,16 +39,16 @@ typedef struct _AFFINITY_DIALOG_CONTEXT } AFFINITY_DIALOG_CONTEXT, *PAFFINITY_DIALOG_CONTEXT; INT_PTR CALLBACK PhpProcessAffinityDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowProcessAffinityDialog( - __in HWND ParentWindowHandle, - __in_opt PPH_PROCESS_ITEM ProcessItem, - __in_opt PPH_THREAD_ITEM ThreadItem + _In_ HWND ParentWindowHandle, + _In_opt_ PPH_PROCESS_ITEM ProcessItem, + _In_opt_ PPH_THREAD_ITEM ThreadItem ) { AFFINITY_DIALOG_CONTEXT context; @@ -68,9 +68,9 @@ VOID PhShowProcessAffinityDialog( } BOOLEAN PhShowProcessAffinityDialog2( - __in HWND ParentWindowHandle, - __in ULONG_PTR AffinityMask, - __out PULONG_PTR NewAffinityMask + _In_ HWND ParentWindowHandle, + _In_ ULONG_PTR AffinityMask, + _Out_ PULONG_PTR NewAffinityMask ) { AFFINITY_DIALOG_CONTEXT context; @@ -98,10 +98,10 @@ BOOLEAN PhShowProcessAffinityDialog2( } static INT_PTR CALLBACK PhpProcessAffinityDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/anawait.c b/2.x/trunk/ProcessHacker/anawait.c index 606211cb2..0f793fe1c 100644 --- a/2.x/trunk/ProcessHacker/anawait.c +++ b/2.x/trunk/ProcessHacker/anawait.c @@ -36,15 +36,15 @@ #include typedef HWND (WINAPI *_GetSendMessageReceiver)( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ); typedef NTSTATUS (NTAPI *_NtAlpcQueryInformation)( - __in HANDLE PortHandle, - __in ALPC_PORT_INFORMATION_CLASS PortInformationClass, - __out_bcount(Length) PVOID PortInformation, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE PortHandle, + _In_ ALPC_PORT_INFORMATION_CLASS PortInformationClass, + _Out_writes_bytes_(Length) PVOID PortInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); typedef struct _ANALYZE_WAIT_CONTEXT @@ -62,18 +62,18 @@ typedef struct _ANALYZE_WAIT_CONTEXT } ANALYZE_WAIT_CONTEXT, *PANALYZE_WAIT_CONTEXT; VOID PhpAnalyzeWaitPassive( - __in HWND hWnd, - __in HANDLE ProcessId, - __in HANDLE ThreadId + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ HANDLE ThreadId ); BOOLEAN NTAPI PhpWalkThreadStackAnalyzeCallback( - __in PPH_THREAD_STACK_FRAME StackFrame, - __in_opt PVOID Context + _In_ PPH_THREAD_STACK_FRAME StackFrame, + _In_opt_ PVOID Context ); VOID PhpAnalyzeWaitFallbacks( - __in PANALYZE_WAIT_CONTEXT Context + _In_ PANALYZE_WAIT_CONTEXT Context ); VOID PhpInitializeServiceNumbers( @@ -81,37 +81,38 @@ VOID PhpInitializeServiceNumbers( ); PPH_STRING PhapGetHandleString( - __in HANDLE ProcessHandle, - __in HANDLE Handle + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle ); VOID PhpGetWfmoInformation( - __in HANDLE ProcessHandle, - __in BOOLEAN IsWow64, - __in ULONG NumberOfHandles, - __in PHANDLE AddressOfHandles, - __in WAIT_TYPE WaitType, - __in BOOLEAN Alertable, - __inout PPH_STRING_BUILDER StringBuilder + _In_ HANDLE ProcessHandle, + _In_ BOOLEAN IsWow64, + _In_ ULONG NumberOfHandles, + _In_ PHANDLE AddressOfHandles, + _In_ WAIT_TYPE WaitType, + _In_ BOOLEAN Alertable, + _Inout_ PPH_STRING_BUILDER StringBuilder ); PPH_STRING PhapGetSendMessageReceiver( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ); PPH_STRING PhapGetAlpcInformation( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ); static PH_INITONCE ServiceNumbersInitOnce = PH_INITONCE_INIT; -static USHORT WfsoNumber = -1; -static USHORT WfmoNumber = -1; +static USHORT NumberForWfso = -1; +static USHORT NumberForWfmo = -1; +static USHORT NumberForRf = -1; VOID PhUiAnalyzeWaitThread( - __in HWND hWnd, - __in HANDLE ProcessId, - __in HANDLE ThreadId, - __in PPH_SYMBOL_PROVIDER SymbolProvider + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ HANDLE ThreadId, + _In_ PPH_SYMBOL_PROVIDER SymbolProvider ) { NTSTATUS status; @@ -186,9 +187,9 @@ VOID PhUiAnalyzeWaitThread( } VOID PhpAnalyzeWaitPassive( - __in HWND hWnd, - __in HANDLE ProcessId, - __in HANDLE ThreadId + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ HANDLE ThreadId ) { NTSTATUS status; @@ -228,16 +229,23 @@ VOID PhpAnalyzeWaitPassive( PhInitializeStringBuilder(&stringBuilder, 100); - if (lastSystemCall.SystemCallNumber == WfsoNumber) + if (lastSystemCall.SystemCallNumber == NumberForWfso) { string = PhapGetHandleString(processHandle, lastSystemCall.FirstArgument); PhAppendFormatStringBuilder(&stringBuilder, L"Thread is waiting for:\r\n"); PhAppendStringBuilder(&stringBuilder, string); } - else if (lastSystemCall.SystemCallNumber == WfmoNumber) + else if (lastSystemCall.SystemCallNumber == NumberForWfmo) { - PhAppendStringBuilder2(&stringBuilder, L"Thread is waiting for multiple objects."); + PhAppendFormatStringBuilder(&stringBuilder, L"Thread is waiting for multiple (%u) objects.", (ULONG)lastSystemCall.FirstArgument); + } + else if (lastSystemCall.SystemCallNumber == NumberForRf) + { + string = PhapGetHandleString(processHandle, lastSystemCall.FirstArgument); + + PhAppendFormatStringBuilder(&stringBuilder, L"Thread is waiting for file I/O:\r\n"); + PhAppendStringBuilder(&stringBuilder, string); } else { @@ -271,8 +279,8 @@ VOID PhpAnalyzeWaitPassive( } static BOOLEAN NTAPI PhpWalkThreadStackAnalyzeCallback( - __in PPH_THREAD_STACK_FRAME StackFrame, - __in_opt PVOID Context + _In_ PPH_THREAD_STACK_FRAME StackFrame, + _In_opt_ PVOID Context ) { PANALYZE_WAIT_CONTEXT context = (PANALYZE_WAIT_CONTEXT)Context; @@ -606,7 +614,7 @@ static BOOLEAN NTAPI PhpWalkThreadStackAnalyzeCallback( } static VOID PhpAnalyzeWaitFallbacks( - __in PANALYZE_WAIT_CONTEXT Context + _In_ PANALYZE_WAIT_CONTEXT Context ) { PPH_STRING info; @@ -640,7 +648,7 @@ static VOID PhpAnalyzeWaitFallbacks( } static BOOLEAN PhpWaitUntilThreadIsWaiting( - __in HANDLE ThreadHandle + _In_ HANDLE ThreadHandle ) { ULONG attempts; @@ -672,7 +680,8 @@ static BOOLEAN PhpWaitUntilThreadIsWaiting( if ( processInfo->Threads[i].ClientId.UniqueThread == basicInfo.ClientId.UniqueThread && processInfo->Threads[i].ThreadState == Waiting && - processInfo->Threads[i].WaitReason == UserRequest + (processInfo->Threads[i].WaitReason == UserRequest || + processInfo->Threads[i].WaitReason == Executive) ) { isWaiting = TRUE; @@ -694,8 +703,8 @@ static BOOLEAN PhpWaitUntilThreadIsWaiting( } static VOID PhpGetThreadLastSystemCallNumber( - __in HANDLE ThreadHandle, - __out PUSHORT LastSystemCallNumber + _In_ HANDLE ThreadHandle, + _Out_ PUSHORT LastSystemCallNumber ) { THREAD_LAST_SYSCALL_INFORMATION lastSystemCall; @@ -713,7 +722,7 @@ static VOID PhpGetThreadLastSystemCallNumber( } static NTSTATUS PhpWfsoThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { HANDLE eventHandle; @@ -728,7 +737,7 @@ static NTSTATUS PhpWfsoThreadStart( } static NTSTATUS PhpWfmoThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { HANDLE eventHandle; @@ -742,6 +751,21 @@ static NTSTATUS PhpWfmoThreadStart( return STATUS_SUCCESS; } +static NTSTATUS PhpRfThreadStart( + _In_ PVOID Parameter + ) +{ + HANDLE fileHandle; + IO_STATUS_BLOCK isb; + ULONG data; + + fileHandle = Parameter; + + NtReadFile(fileHandle, NULL, NULL, NULL, &isb, &data, sizeof(ULONG), NULL, NULL); + + return STATUS_SUCCESS; +} + static VOID PhpInitializeServiceNumbers( VOID ) @@ -751,6 +775,8 @@ static VOID PhpInitializeServiceNumbers( NTSTATUS status; HANDLE eventHandle; HANDLE threadHandle; + HANDLE pipeReadHandle; + HANDLE pipeWriteHandle; // The ThreadLastSystemCall info class only works when the thread is in the Waiting // state. We'll create a thread which blocks on an event object we create, then wait @@ -767,7 +793,7 @@ static VOID PhpInitializeServiceNumbers( { if (PhpWaitUntilThreadIsWaiting(threadHandle)) { - PhpGetThreadLastSystemCallNumber(threadHandle, &WfsoNumber); + PhpGetThreadLastSystemCallNumber(threadHandle, &NumberForWfso); } // Allow the thread to exit. @@ -788,7 +814,7 @@ static VOID PhpInitializeServiceNumbers( { if (PhpWaitUntilThreadIsWaiting(threadHandle)) { - PhpGetThreadLastSystemCallNumber(threadHandle, &WfmoNumber); + PhpGetThreadLastSystemCallNumber(threadHandle, &NumberForWfmo); } NtSetEvent(eventHandle, NULL); @@ -798,13 +824,35 @@ static VOID PhpInitializeServiceNumbers( NtClose(eventHandle); } + // NtReadFile + + if (CreatePipe(&pipeReadHandle, &pipeWriteHandle, NULL, 0)) + { + if (threadHandle = PhCreateThread(0, PhpRfThreadStart, pipeReadHandle)) + { + ULONG data = 0; + IO_STATUS_BLOCK isb; + + if (PhpWaitUntilThreadIsWaiting(threadHandle)) + { + PhpGetThreadLastSystemCallNumber(threadHandle, &NumberForRf); + } + + NtWriteFile(pipeWriteHandle, NULL, NULL, NULL, &isb, &data, sizeof(data), NULL, NULL); + NtClose(threadHandle); + } + + NtClose(pipeReadHandle); + NtClose(pipeWriteHandle); + } + PhEndInitOnce(&ServiceNumbersInitOnce); } } static PPH_STRING PhapGetHandleString( - __in HANDLE ProcessHandle, - __in HANDLE Handle + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle ) { PPH_STRING typeName = NULL; @@ -847,13 +895,13 @@ static PPH_STRING PhapGetHandleString( } static VOID PhpGetWfmoInformation( - __in HANDLE ProcessHandle, - __in BOOLEAN IsWow64, - __in ULONG NumberOfHandles, - __in PHANDLE AddressOfHandles, - __in WAIT_TYPE WaitType, - __in BOOLEAN Alertable, - __inout PPH_STRING_BUILDER StringBuilder + _In_ HANDLE ProcessHandle, + _In_ BOOLEAN IsWow64, + _In_ ULONG NumberOfHandles, + _In_ PHANDLE AddressOfHandles, + _In_ WAIT_TYPE WaitType, + _In_ BOOLEAN Alertable, + _Inout_ PPH_STRING_BUILDER StringBuilder ) { NTSTATUS status; @@ -928,7 +976,7 @@ static VOID PhpGetWfmoInformation( } static PPH_STRING PhapGetSendMessageReceiver( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ) { static _GetSendMessageReceiver GetSendMessageReceiver_I; @@ -971,7 +1019,7 @@ static PPH_STRING PhapGetSendMessageReceiver( } static PPH_STRING PhapGetAlpcInformation( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ) { static _NtAlpcQueryInformation NtAlpcQueryInformation_I; diff --git a/2.x/trunk/ProcessHacker/appsup.c b/2.x/trunk/ProcessHacker/appsup.c index 2a3db819c..e24c8064f 100644 --- a/2.x/trunk/ProcessHacker/appsup.c +++ b/2.x/trunk/ProcessHacker/appsup.c @@ -2,7 +2,7 @@ * Process Hacker - * application support functions * - * Copyright (C) 2010-2012 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -25,20 +25,37 @@ #include #include #include +#include #include "mxml/mxml.h" #include #include +#include typedef LONG (WINAPI *_GetPackageFullName)( - __in HANDLE hProcess, - __inout UINT32 *packageFullNameLength, - __out_opt PWSTR packageFullName + _In_ HANDLE hProcess, + _Inout_ UINT32 *packageFullNameLength, + _Out_opt_ PWSTR packageFullName + ); + +typedef LONG (WINAPI *_GetPackagePath)( + _In_ PACKAGE_ID *packageId, + _Reserved_ UINT32 reserved, + _Inout_ UINT32 *pathLength, + _Out_opt_ PWSTR path + ); + +typedef LONG (WINAPI *_PackageIdFromFullName)( + _In_ PCWSTR packageFullName, + _In_ UINT32 flags, + _Inout_ UINT32 *bufferLength, + _Out_opt_ BYTE *buffer ); GUID XP_CONTEXT_GUID = { 0xbeb1b341, 0x6837, 0x4c83, { 0x83, 0x66, 0x2b, 0x45, 0x1e, 0x7c, 0xe6, 0x9b } }; GUID VISTA_CONTEXT_GUID = { 0xe2011457, 0x1546, 0x43c5, { 0xa5, 0xfe, 0x00, 0x8d, 0xee, 0xe3, 0xd3, 0xf0 } }; GUID WIN7_CONTEXT_GUID = { 0x35138b9a, 0x5d96, 0x4fbd, { 0x8e, 0x2d, 0xa2, 0x44, 0x02, 0x25, 0xf9, 0x3a } }; GUID WIN8_CONTEXT_GUID = { 0x4a2f28e3, 0x53b9, 0x4441, { 0xba, 0x9c, 0xd6, 0x9d, 0x4a, 0x4a, 0x6e, 0x38 } }; +GUID WINBLUE_CONTEXT_GUID = { 0x1f676c76, 0x80e1, 0x4239, { 0x95, 0xbb, 0x83, 0xd0, 0xf6, 0xd0, 0xda, 0x78 } }; /** * Determines whether a process is suspended. @@ -47,7 +64,7 @@ GUID WIN8_CONTEXT_GUID = { 0x4a2f28e3, 0x53b9, 0x4441, { 0xba, 0x9c, 0xd6, 0x9d, * of the process. */ BOOLEAN PhGetProcessIsSuspended( - __in PSYSTEM_PROCESS_INFORMATION Process + _In_ PSYSTEM_PROCESS_INFORMATION Process ) { ULONG i; @@ -72,8 +89,8 @@ BOOLEAN PhGetProcessIsSuspended( * operating system version. */ NTSTATUS PhGetProcessSwitchContext( - __in HANDLE ProcessHandle, - __out PGUID Guid + _In_ HANDLE ProcessHandle, + _Out_ PGUID Guid ) { NTSTATUS status; @@ -150,7 +167,18 @@ NTSTATUS PhGetProcessSwitchContext( if (!data) return STATUS_UNSUCCESSFUL; // no compatibility context data - if (WindowsVersion >= WINDOWS_8) + if (WindowsVersion >= WINDOWS_81) + { + if (!NT_SUCCESS(status = PhReadVirtualMemory( + ProcessHandle, + PTR_ADD_OFFSET(data, 2040 + 16), // Magic value from SbReadProcContextByHandle + Guid, + sizeof(GUID), + NULL + ))) + return status; + } + else if (WindowsVersion >= WINDOWS_8) { if (!NT_SUCCESS(status = PhReadVirtualMemory( ProcessHandle, @@ -177,7 +205,7 @@ NTSTATUS PhGetProcessSwitchContext( } PPH_STRING PhGetProcessPackageFullName( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ) { static _GetPackageFullName getPackageFullName = NULL; @@ -188,7 +216,6 @@ PPH_STRING PhGetProcessPackageFullName( if (!getPackageFullName) getPackageFullName = PhGetProcAddress(L"kernel32.dll", "GetPackageFullName"); - if (!getPackageFullName) return NULL; @@ -217,11 +244,90 @@ PPH_STRING PhGetProcessPackageFullName( } } +PACKAGE_ID *PhPackageIdFromFullName( + _In_ PWSTR PackageFullName + ) +{ + static _PackageIdFromFullName packageIdFromFullName = NULL; + + LONG result; + PVOID packageIdBuffer; + ULONG packageIdBufferSize; + + if (!packageIdFromFullName) + packageIdFromFullName = PhGetProcAddress(L"kernel32.dll", "PackageIdFromFullName"); + if (!packageIdFromFullName) + return NULL; + + packageIdBufferSize = 100; + packageIdBuffer = PhAllocate(packageIdBufferSize); + + result = packageIdFromFullName(PackageFullName, PACKAGE_INFORMATION_BASIC, &packageIdBufferSize, (PBYTE)packageIdBuffer); + + if (result == ERROR_INSUFFICIENT_BUFFER) + { + PhFree(packageIdBuffer); + packageIdBuffer = PhAllocate(packageIdBufferSize); + + result = packageIdFromFullName(PackageFullName, PACKAGE_INFORMATION_BASIC, &packageIdBufferSize, (PBYTE)packageIdBuffer); + } + + if (result == ERROR_SUCCESS) + { + return packageIdBuffer; + } + else + { + PhFree(packageIdBuffer); + return NULL; + } +} + +PPH_STRING PhGetPackagePath( + _In_ PACKAGE_ID *PackageId + ) +{ + static _GetPackagePath getPackagePath = NULL; + + LONG result; + PPH_STRING path; + ULONG pathLength; + + if (!getPackagePath) + getPackagePath = PhGetProcAddress(L"kernel32.dll", "GetPackagePath"); + if (!getPackagePath) + return NULL; + + pathLength = 101; + path = PhCreateStringEx(NULL, (pathLength - 1) * 2); + + result = getPackagePath(PackageId, 0, &pathLength, path->Buffer); + + if (result == ERROR_INSUFFICIENT_BUFFER) + { + PhDereferenceObject(path); + path = PhCreateStringEx(NULL, (pathLength - 1) * 2); + + result = getPackagePath(PackageId, 0, &pathLength, path->Buffer); + } + + if (result == ERROR_SUCCESS) + { + PhTrimToNullTerminatorString(path); + return path; + } + else + { + PhDereferenceObject(path); + return NULL; + } +} + VOID PhEnumChildWindows( - __in_opt HWND hWnd, - __in ULONG Limit, - __in WNDENUMPROC Callback, - __in LPARAM lParam + _In_opt_ HWND hWnd, + _In_ ULONG Limit, + _In_ WNDENUMPROC Callback, + _In_ LPARAM lParam ) { HWND childWindow = NULL; @@ -244,8 +350,8 @@ VOID PhEnumChildWindows( * type. */ NTSTATUS PhGetProcessKnownType( - __in HANDLE ProcessHandle, - __out PH_KNOWN_PROCESS_TYPE *KnownProcessType + _In_ HANDLE ProcessHandle, + _Out_ PH_KNOWN_PROCESS_TYPE *KnownProcessType ) { NTSTATUS status; @@ -355,9 +461,9 @@ NTSTATUS PhGetProcessKnownType( } static BOOLEAN NTAPI PhpSvchostCommandLineCallback( - __in_opt PPH_COMMAND_LINE_OPTION Option, - __in_opt PPH_STRING Value, - __in_opt PVOID Context + _In_opt_ PPH_COMMAND_LINE_OPTION Option, + _In_opt_ PPH_STRING Value, + _In_opt_ PVOID Context ) { PPH_KNOWN_PROCESS_COMMAND_LINE knownCommandLine = Context; @@ -371,9 +477,9 @@ static BOOLEAN NTAPI PhpSvchostCommandLineCallback( } BOOLEAN PhaGetProcessKnownCommandLine( - __in PPH_STRING CommandLine, - __in PH_KNOWN_PROCESS_TYPE KnownProcessType, - __out PPH_KNOWN_PROCESS_COMMAND_LINE KnownCommandLine + _In_ PPH_STRING CommandLine, + _In_ PH_KNOWN_PROCESS_TYPE KnownProcessType, + _Out_ PPH_KNOWN_PROCESS_COMMAND_LINE KnownCommandLine ) { switch (KnownProcessType & KnownProcessTypeMask) @@ -582,8 +688,8 @@ BOOLEAN PhaGetProcessKnownCommandLine( } PPH_STRING PhEscapeStringForDelimiter( - __in PPH_STRING String, - __in WCHAR Delimiter + _In_ PPH_STRING String, + _In_ WCHAR Delimiter ) { PH_STRING_BUILDER stringBuilder; @@ -613,8 +719,8 @@ PPH_STRING PhEscapeStringForDelimiter( } PPH_STRING PhUnescapeStringForDelimiter( - __in PPH_STRING String, - __in WCHAR Delimiter + _In_ PPH_STRING String, + _In_ WCHAR Delimiter ) { PH_STRING_BUILDER stringBuilder; @@ -649,7 +755,7 @@ PPH_STRING PhUnescapeStringForDelimiter( } PPH_STRING PhGetOpaqueXmlNodeText( - __in mxml_node_t *node + _In_ mxml_node_t *node ) { if (node->child && node->child->type == MXML_OPAQUE && node->child->value.opaque) @@ -663,19 +769,19 @@ PPH_STRING PhGetOpaqueXmlNodeText( } VOID PhSearchOnlineString( - __in HWND hWnd, - __in PWSTR String + _In_ HWND hWnd, + _In_ PWSTR String ) { PhShellExecuteUserString(hWnd, L"SearchEngine", String, TRUE, NULL); } VOID PhShellExecuteUserString( - __in HWND hWnd, - __in PWSTR Setting, - __in PWSTR String, - __in BOOLEAN UseShellExecute, - __in_opt PWSTR ErrorMessage + _In_ HWND hWnd, + _In_ PWSTR Setting, + _In_ PWSTR String, + _In_ BOOLEAN UseShellExecute, + _In_opt_ PWSTR ErrorMessage ) { static PH_STRINGREF replacementToken = PH_STRINGREF_INIT(L"%s"); @@ -742,7 +848,7 @@ VOID PhShellExecuteUserString( } VOID PhLoadSymbolProviderOptions( - __inout PPH_SYMBOL_PROVIDER SymbolProvider + _Inout_ PPH_SYMBOL_PROVIDER SymbolProvider ) { PPH_STRING searchPath; @@ -776,8 +882,8 @@ PWSTR PhMakeContextAtom( * \remarks The text is truncated if it is too long. */ VOID PhCopyListViewInfoTip( - __inout LPNMLVGETINFOTIP GetInfoTip, - __in PPH_STRINGREF Tip + _Inout_ LPNMLVGETINFOTIP GetInfoTip, + _In_ PPH_STRINGREF Tip ) { ULONG copyIndex; @@ -810,7 +916,7 @@ VOID PhCopyListViewInfoTip( } VOID PhCopyListView( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ) { PPH_STRING text; @@ -821,20 +927,20 @@ VOID PhCopyListView( } VOID PhHandleListViewNotifyForCopy( - __in LPARAM lParam, - __in HWND ListViewHandle + _In_ LPARAM lParam, + _In_ HWND ListViewHandle ) { PhHandleListViewNotifyBehaviors(lParam, ListViewHandle, PH_LIST_VIEW_CTRL_C_BEHAVIOR); } VOID PhHandleListViewNotifyBehaviors( - __in LPARAM lParam, - __in HWND ListViewHandle, - __in ULONG Behaviors + _In_ LPARAM lParam, + _In_ HWND ListViewHandle, + _In_ ULONG Behaviors ) { - if (((LPNMHDR)lParam)->hwndFrom == ListViewHandle) + if (((LPNMHDR)lParam)->hwndFrom == ListViewHandle && ((LPNMHDR)lParam)->code == LVN_KEYDOWN) { LPNMLVKEYDOWN keyDown = (LPNMLVKEYDOWN)lParam; @@ -859,8 +965,8 @@ VOID PhHandleListViewNotifyBehaviors( } BOOLEAN PhGetListViewContextMenuPoint( - __in HWND ListViewHandle, - __out PPOINT Point + _In_ HWND ListViewHandle, + _Out_ PPOINT Point ) { INT selectedIndex; @@ -900,8 +1006,8 @@ BOOLEAN PhGetListViewContextMenuPoint( } HFONT PhDuplicateFontWithNewWeight( - __in HFONT Font, - __in LONG NewWeight + _In_ HFONT Font, + _In_ LONG NewWeight ) { LOGFONT logFont; @@ -918,9 +1024,9 @@ HFONT PhDuplicateFontWithNewWeight( } VOID PhLoadWindowPlacementFromSetting( - __in_opt PWSTR PositionSettingName, - __in_opt PWSTR SizeSettingName, - __in HWND WindowHandle + _In_opt_ PWSTR PositionSettingName, + _In_opt_ PWSTR SizeSettingName, + _In_ HWND WindowHandle ) { PH_RECTANGLE windowRectangle; @@ -980,9 +1086,9 @@ VOID PhLoadWindowPlacementFromSetting( } VOID PhSaveWindowPlacementToSetting( - __in_opt PWSTR PositionSettingName, - __in_opt PWSTR SizeSettingName, - __in HWND WindowHandle + _In_opt_ PWSTR PositionSettingName, + _In_opt_ PWSTR SizeSettingName, + _In_ HWND WindowHandle ) { WINDOWPLACEMENT placement = { sizeof(placement) }; @@ -1006,8 +1112,8 @@ VOID PhSaveWindowPlacementToSetting( } VOID PhLoadListViewColumnsFromSetting( - __in PWSTR Name, - __in HWND ListViewHandle + _In_ PWSTR Name, + _In_ HWND ListViewHandle ) { PPH_STRING string; @@ -1018,8 +1124,8 @@ VOID PhLoadListViewColumnsFromSetting( } VOID PhSaveListViewColumnsToSetting( - __in PWSTR Name, - __in HWND ListViewHandle + _In_ PWSTR Name, + _In_ HWND ListViewHandle ) { PPH_STRING string; @@ -1043,10 +1149,10 @@ PPH_STRING PhGetPhVersion( } VOID PhGetPhVersionNumbers( - __out_opt PULONG MajorVersion, - __out_opt PULONG MinorVersion, - __reserved PULONG Reserved, - __out_opt PULONG RevisionNumber + _Out_opt_ PULONG MajorVersion, + _Out_opt_ PULONG MinorVersion, + _Reserved_ PULONG Reserved, + _Out_opt_ PULONG RevisionNumber ) { if (MajorVersion) @@ -1058,7 +1164,7 @@ VOID PhGetPhVersionNumbers( } VOID PhWritePhTextHeader( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ) { PPH_STRING version; @@ -1097,13 +1203,13 @@ VOID PhWritePhTextHeader( } BOOLEAN PhShellProcessHacker( - __in HWND hWnd, - __in_opt PWSTR Parameters, - __in ULONG ShowWindowType, - __in ULONG Flags, - __in ULONG AppFlags, - __in_opt ULONG Timeout, - __out_opt PHANDLE ProcessHandle + _In_ HWND hWnd, + _In_opt_ PWSTR Parameters, + _In_ ULONG ShowWindowType, + _In_ ULONG Flags, + _In_ ULONG AppFlags, + _In_opt_ ULONG Timeout, + _Out_opt_ PHANDLE ProcessHandle ) { BOOLEAN result; @@ -1190,7 +1296,7 @@ BOOLEAN PhShellProcessHacker( } BOOLEAN PhCreateProcessIgnoreIfeoDebugger( - __in PWSTR FileName + _In_ PWSTR FileName ) { BOOLEAN result; @@ -1235,15 +1341,15 @@ BOOLEAN PhCreateProcessIgnoreIfeoDebugger( } VOID PhInitializeTreeNewColumnMenu( - __inout PPH_TN_COLUMN_MENU_DATA Data + _Inout_ PPH_TN_COLUMN_MENU_DATA Data ) { PhInitializeTreeNewColumnMenuEx(Data, 0); } VOID PhInitializeTreeNewColumnMenuEx( - __inout PPH_TN_COLUMN_MENU_DATA Data, - __in ULONG Flags + _Inout_ PPH_TN_COLUMN_MENU_DATA Data, + _In_ ULONG Flags ) { PPH_EMENU_ITEM sizeColumnToFitMenuItem; @@ -1295,9 +1401,9 @@ VOID PhInitializeTreeNewColumnMenuEx( } VOID PhpEnsureValidSortColumnTreeNew( - __inout HWND TreeNewHandle, - __in ULONG DefaultSortColumn, - __in PH_SORT_ORDER DefaultSortOrder + _Inout_ HWND TreeNewHandle, + _In_ ULONG DefaultSortColumn, + _In_ PH_SORT_ORDER DefaultSortOrder ) { ULONG sortColumn; @@ -1360,7 +1466,7 @@ VOID PhpEnsureValidSortColumnTreeNew( } BOOLEAN PhHandleTreeNewColumnMenu( - __inout PPH_TN_COLUMN_MENU_DATA Data + _Inout_ PPH_TN_COLUMN_MENU_DATA Data ) { if (!Data->Selection) @@ -1421,7 +1527,7 @@ BOOLEAN PhHandleTreeNewColumnMenu( } VOID PhDeleteTreeNewColumnMenu( - __in PPH_TN_COLUMN_MENU_DATA Data + _In_ PPH_TN_COLUMN_MENU_DATA Data ) { if (Data->Menu) @@ -1432,9 +1538,9 @@ VOID PhDeleteTreeNewColumnMenu( } VOID PhInitializeTreeNewFilterSupport( - __out PPH_TN_FILTER_SUPPORT Support, - __in HWND TreeNewHandle, - __in PPH_LIST NodeList + _Out_ PPH_TN_FILTER_SUPPORT Support, + _In_ HWND TreeNewHandle, + _In_ PPH_LIST NodeList ) { Support->FilterList = NULL; @@ -1443,16 +1549,16 @@ VOID PhInitializeTreeNewFilterSupport( } VOID PhDeleteTreeNewFilterSupport( - __in PPH_TN_FILTER_SUPPORT Support + _In_ PPH_TN_FILTER_SUPPORT Support ) { PhDereferenceObject(Support->FilterList); } PPH_TN_FILTER_ENTRY PhAddTreeNewFilter( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TN_FILTER_FUNCTION Filter, - __in_opt PVOID Context + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TN_FILTER_FUNCTION Filter, + _In_opt_ PVOID Context ) { PPH_TN_FILTER_ENTRY entry; @@ -1470,8 +1576,8 @@ PPH_TN_FILTER_ENTRY PhAddTreeNewFilter( } VOID PhRemoveTreeNewFilter( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TN_FILTER_ENTRY Entry + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TN_FILTER_ENTRY Entry ) { ULONG index; @@ -1489,8 +1595,8 @@ VOID PhRemoveTreeNewFilter( } BOOLEAN PhApplyTreeNewFiltersToNode( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TREENEW_NODE Node + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TREENEW_NODE Node ) { BOOLEAN show; @@ -1518,7 +1624,7 @@ BOOLEAN PhApplyTreeNewFiltersToNode( } VOID PhApplyTreeNewFilters( - __in PPH_TN_FILTER_SUPPORT Support + _In_ PPH_TN_FILTER_SUPPORT Support ) { ULONG i; @@ -1540,7 +1646,7 @@ VOID PhApplyTreeNewFilters( } VOID NTAPI PhpCopyCellEMenuItemDeleteFunction( - __in struct _PH_EMENU_ITEM *Item + _In_ struct _PH_EMENU_ITEM *Item ) { PPH_COPY_CELL_CONTEXT context; @@ -1551,10 +1657,10 @@ VOID NTAPI PhpCopyCellEMenuItemDeleteFunction( } BOOLEAN PhInsertCopyCellEMenuItem( - __in struct _PH_EMENU_ITEM *Menu, - __in ULONG InsertAfterId, - __in HWND TreeNewHandle, - __in PPH_TREENEW_COLUMN Column + _In_ struct _PH_EMENU_ITEM *Menu, + _In_ ULONG InsertAfterId, + _In_ HWND TreeNewHandle, + _In_ PPH_TREENEW_COLUMN Column ) { PPH_EMENU_ITEM parentItem; @@ -1594,7 +1700,7 @@ BOOLEAN PhInsertCopyCellEMenuItem( } BOOLEAN PhHandleCopyCellEMenuItem( - __in struct _PH_EMENU_ITEM *SelectedItem + _In_ struct _PH_EMENU_ITEM *SelectedItem ) { PPH_COPY_CELL_CONTEXT context; @@ -1643,3 +1749,161 @@ BOOLEAN PhHandleCopyCellEMenuItem( return TRUE; } + +BOOLEAN PhpSelectFavoriteInRegedit( + _In_ HWND RegeditWindow, + _In_ PPH_STRINGREF FavoriteName, + _In_ BOOLEAN UsePhSvc + ) +{ + HMENU menu; + HMENU favoritesMenu; + ULONG count; + ULONG i; + ULONG id = -1; + + if (!(menu = GetMenu(RegeditWindow))) + return FALSE; + + // Cause the Registry Editor to refresh the Favorites menu. + if (UsePhSvc) + PhSvcCallSendMessage(RegeditWindow, WM_MENUSELECT, MAKEWPARAM(3, MF_POPUP), (LPARAM)menu); + else + SendMessage(RegeditWindow, WM_MENUSELECT, MAKEWPARAM(3, MF_POPUP), (LPARAM)menu); + + if (!(favoritesMenu = GetSubMenu(menu, 3))) + return FALSE; + + // Find our entry. + + count = GetMenuItemCount(favoritesMenu); + + if (count == -1) + return FALSE; + if (count > 1000) + count = 1000; + + for (i = 3; i < count; i++) + { + MENUITEMINFO info = { sizeof(MENUITEMINFO) }; + WCHAR buffer[32]; + + info.fMask = MIIM_ID | MIIM_STRING; + info.dwTypeData = buffer; + info.cch = sizeof(buffer) / sizeof(WCHAR); + GetMenuItemInfo(favoritesMenu, i, TRUE, &info); + + if (info.cch == FavoriteName->Length / 2) + { + PH_STRINGREF text; + + text.Buffer = buffer; + text.Length = info.cch * 2; + + if (PhEqualStringRef(&text, FavoriteName, TRUE)) + { + id = info.wID; + break; + } + } + } + + if (id == -1) + return FALSE; + + // Activate our entry. + if (UsePhSvc) + PhSvcCallSendMessage(RegeditWindow, WM_COMMAND, MAKEWPARAM(id, 0), 0); + else + SendMessage(RegeditWindow, WM_COMMAND, MAKEWPARAM(id, 0), 0); + + // "Close" the Favorites menu and restore normal status bar text. + if (UsePhSvc) + PhSvcCallPostMessage(RegeditWindow, WM_MENUSELECT, MAKEWPARAM(0, 0xffff), 0); + else + PostMessage(RegeditWindow, WM_MENUSELECT, MAKEWPARAM(0, 0xffff), 0); + + // Bring regedit to the top. + if (IsIconic(RegeditWindow)) + { + ShowWindow(RegeditWindow, SW_RESTORE); + SetForegroundWindow(RegeditWindow); + } + else + { + SetForegroundWindow(RegeditWindow); + } + + return TRUE; +} + +/** + * Opens a key in the Registry Editor. If the Registry Editor is already open, + * the specified key is selected in the Registry Editor. + * + * \param hWnd A handle to the parent window. + * \param KeyName The key name to open. + */ +BOOLEAN PhShellOpenKey2( + _In_ HWND hWnd, + _In_ PPH_STRING KeyName + ) +{ + static PH_STRINGREF favoritesKeyName = PH_STRINGREF_INIT(L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites"); + + BOOLEAN result = FALSE; + HWND regeditWindow; + HANDLE favoritesKeyHandle; + WCHAR favoriteName[32]; + UNICODE_STRING valueName; + PH_STRINGREF valueNameSr; + PPH_STRING expandedKeyName; + + regeditWindow = FindWindow(L"RegEdit_RegEdit", NULL); + + if (!regeditWindow) + { + PhShellOpenKey(hWnd, KeyName); + return TRUE; + } + + if (!PhElevated) + { + if (!PhUiConnectToPhSvc(hWnd, FALSE)) + return FALSE; + } + + // Create our entry in Favorites. + + if (!NT_SUCCESS(PhCreateKey( + &favoritesKeyHandle, + KEY_WRITE, + PH_KEY_CURRENT_USER, + &favoritesKeyName, + 0, + 0, + NULL + ))) + goto CleanupExit; + + memcpy(favoriteName, L"A_ProcessHacker", 15 * sizeof(WCHAR)); + PhGenerateRandomAlphaString(&favoriteName[15], 16); + RtlInitUnicodeString(&valueName, favoriteName); + PhUnicodeStringToStringRef(&valueName, &valueNameSr); + + expandedKeyName = PhExpandKeyName(KeyName, TRUE); + NtSetValueKey(favoritesKeyHandle, &valueName, 0, REG_SZ, expandedKeyName->Buffer, (ULONG)expandedKeyName->Length + 2); + PhDereferenceObject(expandedKeyName); + + // Select our entry in regedit. + result = PhpSelectFavoriteInRegedit(regeditWindow, &valueNameSr, !PhElevated); + + NtDeleteValueKey(favoritesKeyHandle, &valueName); + NtClose(favoritesKeyHandle); + +CleanupExit: + if (!PhElevated) + PhUiDisconnectFromPhSvc(); + + return result; +} diff --git a/2.x/trunk/ProcessHacker/chcol.c b/2.x/trunk/ProcessHacker/chcol.c index 171da6abc..b68a6cb15 100644 --- a/2.x/trunk/ProcessHacker/chcol.c +++ b/2.x/trunk/ProcessHacker/chcol.c @@ -35,16 +35,16 @@ typedef struct _COLUMNS_DIALOG_CONTEXT } COLUMNS_DIALOG_CONTEXT, *PCOLUMNS_DIALOG_CONTEXT; INT_PTR CALLBACK PhpColumnsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowChooseColumnsDialog( - __in HWND ParentWindowHandle, - __in HWND ControlHandle, - __in ULONG Type + _In_ HWND ParentWindowHandle, + _In_ HWND ControlHandle, + _In_ ULONG Type ) { COLUMNS_DIALOG_CONTEXT context; @@ -69,8 +69,8 @@ VOID PhShowChooseColumnsDialog( } static int __cdecl PhpColumnsCompareDisplayIndexTn( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PPH_TREENEW_COLUMN column1 = *(PPH_TREENEW_COLUMN *)elem1; @@ -79,10 +79,10 @@ static int __cdecl PhpColumnsCompareDisplayIndexTn( return uintcmp(column1->DisplayIndex, column2->DisplayIndex); } -__success(return != -1) +_Success_(return != -1) static ULONG IndexOfStringInList( - __in PPH_LIST List, - __in PWSTR String + _In_ PPH_LIST List, + _In_ PWSTR String ) { ULONG i; @@ -97,10 +97,10 @@ static ULONG IndexOfStringInList( } INT_PTR CALLBACK PhpColumnsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCOLUMNS_DIALOG_CONTEXT context = NULL; diff --git a/2.x/trunk/ProcessHacker/chdlg.c b/2.x/trunk/ProcessHacker/chdlg.c index e3bf68aa5..ffe9ec2fa 100644 --- a/2.x/trunk/ProcessHacker/chdlg.c +++ b/2.x/trunk/ProcessHacker/chdlg.c @@ -40,10 +40,10 @@ typedef struct _CHOICE_DIALOG_CONTEXT } CHOICE_DIALOG_CONTEXT, *PCHOICE_DIALOG_CONTEXT; INT_PTR CALLBACK PhpChoiceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); /** @@ -53,16 +53,16 @@ INT_PTR CALLBACK PhpChoiceDlgProc( * returned in \a SelectedChoice is NOT auto-dereferenced. */ BOOLEAN PhaChoiceDialog( - __in HWND ParentWindowHandle, - __in PWSTR Title, - __in PWSTR Message, - __in_opt PWSTR *Choices, - __in_opt ULONG NumberOfChoices, - __in_opt PWSTR Option, - __in ULONG Flags, - __inout PPH_STRING *SelectedChoice, - __inout_opt PBOOLEAN SelectedOption, - __in_opt PWSTR SavedChoicesSettingName + _In_ HWND ParentWindowHandle, + _In_ PWSTR Title, + _In_ PWSTR Message, + _In_opt_ PWSTR *Choices, + _In_opt_ ULONG NumberOfChoices, + _In_opt_ PWSTR Option, + _In_ ULONG Flags, + _Inout_ PPH_STRING *SelectedChoice, + _Inout_opt_ PBOOLEAN SelectedOption, + _In_opt_ PWSTR SavedChoicesSettingName ) { CHOICE_DIALOG_CONTEXT context; @@ -87,10 +87,10 @@ BOOLEAN PhaChoiceDialog( } INT_PTR CALLBACK PhpChoiceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/chproc.c b/2.x/trunk/ProcessHacker/chproc.c index 521e73c13..fd2c3570d 100644 --- a/2.x/trunk/ProcessHacker/chproc.c +++ b/2.x/trunk/ProcessHacker/chproc.c @@ -34,16 +34,16 @@ typedef struct _CHOOSE_PROCESS_DIALOG_CONTEXT } CHOOSE_PROCESS_DIALOG_CONTEXT, *PCHOOSE_PROCESS_DIALOG_CONTEXT; INT_PTR CALLBACK PhpChooseProcessDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); BOOLEAN PhShowChooseProcessDialog( - __in HWND ParentWindowHandle, - __in PWSTR Message, - __out PHANDLE ProcessId + _In_ HWND ParentWindowHandle, + _In_ PWSTR Message, + _Out_ PHANDLE ProcessId ) { CHOOSE_PROCESS_DIALOG_CONTEXT context; @@ -70,8 +70,8 @@ BOOLEAN PhShowChooseProcessDialog( } static VOID PhpRefreshProcessList( - __in HWND hwndDlg, - __in PCHOOSE_PROCESS_DIALOG_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PCHOOSE_PROCESS_DIALOG_CONTEXT Context ) { NTSTATUS status; @@ -178,10 +178,10 @@ static VOID PhpRefreshProcessList( } INT_PTR CALLBACK PhpChooseProcessDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCHOOSE_PROCESS_DIALOG_CONTEXT context = NULL; diff --git a/2.x/trunk/ProcessHacker/cmdmode.c b/2.x/trunk/ProcessHacker/cmdmode.c index a75ab1b31..cef0b2edb 100644 --- a/2.x/trunk/ProcessHacker/cmdmode.c +++ b/2.x/trunk/ProcessHacker/cmdmode.c @@ -23,9 +23,9 @@ #include NTSTATUS PhpGetDllBaseRemote( - __in HANDLE ProcessHandle, - __in PPH_STRINGREF BaseDllName, - __out PVOID *DllBase + _In_ HANDLE ProcessHandle, + _In_ PPH_STRINGREF BaseDllName, + _Out_ PVOID *DllBase ); static HWND CommandModeWindowHandle; @@ -33,9 +33,9 @@ static HWND CommandModeWindowHandle; #define PH_COMMAND_OPTION_HWND 1 BOOLEAN NTAPI PhpCommandModeOptionCallback( - __in_opt PPH_COMMAND_LINE_OPTION Option, - __in_opt PPH_STRING Value, - __in_opt PVOID Context + _In_opt_ PPH_COMMAND_LINE_OPTION Option, + _In_opt_ PPH_STRING Value, + _In_opt_ PVOID Context ) { ULONG64 integer; @@ -401,8 +401,8 @@ typedef struct _GET_DLL_BASE_REMOTE_CONTEXT } GET_DLL_BASE_REMOTE_CONTEXT, *PGET_DLL_BASE_REMOTE_CONTEXT; static BOOLEAN PhpGetDllBaseRemoteCallback( - __in PLDR_DATA_TABLE_ENTRY Module, - __in_opt PVOID Context + _In_ PLDR_DATA_TABLE_ENTRY Module, + _In_opt_ PVOID Context ) { PGET_DLL_BASE_REMOTE_CONTEXT context = Context; @@ -420,9 +420,9 @@ static BOOLEAN PhpGetDllBaseRemoteCallback( } NTSTATUS PhpGetDllBaseRemote( - __in HANDLE ProcessHandle, - __in PPH_STRINGREF BaseDllName, - __out PVOID *DllBase + _In_ HANDLE ProcessHandle, + _In_ PPH_STRINGREF BaseDllName, + _Out_ PVOID *DllBase ) { NTSTATUS status; diff --git a/2.x/trunk/ProcessHacker/colmgr.c b/2.x/trunk/ProcessHacker/colmgr.c index d1692cce9..f11ef1e42 100644 --- a/2.x/trunk/ProcessHacker/colmgr.c +++ b/2.x/trunk/ProcessHacker/colmgr.c @@ -35,10 +35,10 @@ typedef struct _PH_CM_SORT_CONTEXT } PH_CM_SORT_CONTEXT, *PPH_CM_SORT_CONTEXT; VOID PhCmInitializeManager( - __out PPH_CM_MANAGER Manager, - __in HWND Handle, - __in ULONG MinId, - __in PPH_CM_POST_SORT_FUNCTION PostSortFunction + _Out_ PPH_CM_MANAGER Manager, + _In_ HWND Handle, + _In_ ULONG MinId, + _In_ PPH_CM_POST_SORT_FUNCTION PostSortFunction ) { Manager->Handle = Handle; @@ -50,7 +50,7 @@ VOID PhCmInitializeManager( } VOID PhCmDeleteManager( - __in PPH_CM_MANAGER Manager + _In_ PPH_CM_MANAGER Manager ) { PLIST_ENTRY listEntry; @@ -71,12 +71,12 @@ VOID PhCmDeleteManager( } PPH_CM_COLUMN PhCmCreateColumn( - __inout PPH_CM_MANAGER Manager, - __in PPH_TREENEW_COLUMN Column, - __in struct _PH_PLUGIN *Plugin, - __in ULONG SubId, - __in_opt PVOID Context, - __in PVOID SortFunction + _Inout_ PPH_CM_MANAGER Manager, + _In_ PPH_TREENEW_COLUMN Column, + _In_ struct _PH_PLUGIN *Plugin, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_ PVOID SortFunction ) { PPH_CM_COLUMN column; @@ -108,9 +108,9 @@ PPH_CM_COLUMN PhCmCreateColumn( } PPH_CM_COLUMN PhCmFindColumn( - __in PPH_CM_MANAGER Manager, - __in PPH_STRINGREF PluginName, - __in ULONG SubId + _In_ PPH_CM_MANAGER Manager, + _In_ PPH_STRINGREF PluginName, + _In_ ULONG SubId ) { PLIST_ENTRY listEntry; @@ -132,8 +132,8 @@ PPH_CM_COLUMN PhCmFindColumn( } VOID PhCmSetNotifyPlugin( - __in PPH_CM_MANAGER Manager, - __in struct _PH_PLUGIN *Plugin + _In_ PPH_CM_MANAGER Manager, + _In_ struct _PH_PLUGIN *Plugin ) { if (!Manager->NotifyList) @@ -150,11 +150,11 @@ VOID PhCmSetNotifyPlugin( } BOOLEAN PhCmForwardMessage( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in PPH_CM_MANAGER Manager + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_ PPH_CM_MANAGER Manager ) { PH_PLUGIN_TREENEW_MESSAGE pluginMessage; @@ -247,9 +247,9 @@ BOOLEAN PhCmForwardMessage( } static int __cdecl PhCmpSortFunction( - __in void *context, - __in const void *elem1, - __in const void *elem2 + _In_ void *context, + _In_ const void *elem1, + _In_ const void *elem2 ) { PPH_CM_SORT_CONTEXT sortContext = context; @@ -263,11 +263,11 @@ static int __cdecl PhCmpSortFunction( } BOOLEAN PhCmForwardSort( - __in PPH_TREENEW_NODE *Nodes, - __in ULONG NumberOfNodes, - __in ULONG SortColumn, - __in PH_SORT_ORDER SortOrder, - __in PPH_CM_MANAGER Manager + _In_ PPH_TREENEW_NODE *Nodes, + _In_ ULONG NumberOfNodes, + _In_ ULONG SortColumn, + _In_ PH_SORT_ORDER SortOrder, + _In_ PPH_CM_MANAGER Manager ) { PH_TREENEW_COLUMN tnColumn; @@ -296,19 +296,19 @@ BOOLEAN PhCmForwardSort( } BOOLEAN PhCmLoadSettings( - __in HWND TreeNewHandle, - __in PPH_STRINGREF Settings + _In_ HWND TreeNewHandle, + _In_ PPH_STRINGREF Settings ) { return PhCmLoadSettingsEx(TreeNewHandle, NULL, 0, Settings, NULL); } BOOLEAN PhCmLoadSettingsEx( - __in HWND TreeNewHandle, - __in_opt PPH_CM_MANAGER Manager, - __in ULONG Flags, - __in PPH_STRINGREF Settings, - __in_opt PPH_STRINGREF SortSettings + _In_ HWND TreeNewHandle, + _In_opt_ PPH_CM_MANAGER Manager, + _In_ ULONG Flags, + _In_ PPH_STRINGREF Settings, + _In_opt_ PPH_STRINGREF SortSettings ) { BOOLEAN result = FALSE; @@ -545,17 +545,17 @@ BOOLEAN PhCmLoadSettingsEx( } PPH_STRING PhCmSaveSettings( - __in HWND TreeNewHandle + _In_ HWND TreeNewHandle ) { return PhCmSaveSettingsEx(TreeNewHandle, NULL, 0, NULL); } PPH_STRING PhCmSaveSettingsEx( - __in HWND TreeNewHandle, - __in_opt PPH_CM_MANAGER Manager, - __in ULONG Flags, - __out_opt PPH_STRING *SortSettings + _In_ HWND TreeNewHandle, + _In_opt_ PPH_CM_MANAGER Manager, + _In_ ULONG Flags, + _Out_opt_ PPH_STRING *SortSettings ) { PH_STRING_BUILDER stringBuilder; diff --git a/2.x/trunk/ProcessHacker/dbgcon.c b/2.x/trunk/ProcessHacker/dbgcon.c index cdd4d1657..f998002dc 100644 --- a/2.x/trunk/ProcessHacker/dbgcon.c +++ b/2.x/trunk/ProcessHacker/dbgcon.c @@ -37,15 +37,15 @@ typedef struct _STRING_TABLE_ENTRY } STRING_TABLE_ENTRY, *PSTRING_TABLE_ENTRY; BOOL ConsoleHandlerRoutine( - __in DWORD dwCtrlType + _In_ DWORD dwCtrlType ); VOID PhpPrintHashtableStatistics( - __in PPH_HASHTABLE Hashtable + _In_ PPH_HASHTABLE Hashtable ); NTSTATUS PhpDebugConsoleThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); extern PH_FREE_LIST PhObjectSmallFreeList; @@ -114,7 +114,7 @@ VOID PhCloseDebugConsole( } static BOOL ConsoleHandlerRoutine( - __in DWORD dwCtrlType + _In_ DWORD dwCtrlType ) { switch (dwCtrlType) @@ -130,8 +130,8 @@ static BOOL ConsoleHandlerRoutine( } static BOOLEAN NTAPI PhpLoadCurrentProcessSymbolsCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PhLoadModuleSymbolProvider((PPH_SYMBOL_PROVIDER)Context, Module->FileName->Buffer, @@ -141,7 +141,7 @@ static BOOLEAN NTAPI PhpLoadCurrentProcessSymbolsCallback( } static PWSTR PhpGetSymbolForAddress( - __in PVOID Address + _In_ PVOID Address ) { return ((PPH_STRING)PHA_DEREFERENCE(PhGetSymbolFromAddress( @@ -150,8 +150,8 @@ static PWSTR PhpGetSymbolForAddress( } static VOID PhpPrintObjectInfo( - __in PPH_OBJECT_HEADER ObjectHeader, - __in LONG RefToSubtract + _In_ PPH_OBJECT_HEADER ObjectHeader, + _In_ LONG RefToSubtract ) { WCHAR c = ' '; @@ -217,7 +217,7 @@ static VOID PhpPrintObjectInfo( } static VOID PhpDumpObjectInfo( - __in PPH_OBJECT_HEADER ObjectHeader + _In_ PPH_OBJECT_HEADER ObjectHeader ) { __try @@ -253,7 +253,7 @@ static VOID PhpDumpObjectInfo( } static VOID PhpPrintHashtableStatistics( - __in PPH_HASHTABLE Hashtable + _In_ PPH_HASHTABLE Hashtable ) { ULONG i; @@ -322,10 +322,10 @@ static VOID PhpPrintHashtableStatistics( #ifdef DEBUG static VOID PhpDebugCreateObjectHook( - __in PVOID Object, - __in SIZE_T Size, - __in ULONG Flags, - __in PPH_OBJECT_TYPE ObjectType + _In_ PVOID Object, + _In_ SIZE_T Size, + _In_ ULONG Flags, + _In_ PPH_OBJECT_TYPE ObjectType ) { PhAcquireQueuedLockExclusive(&NewObjectListLock); @@ -359,8 +359,8 @@ static VOID PhpDeleteNewObjectList( #endif static BOOLEAN PhpStringHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PSTRING_TABLE_ENTRY entry1 = Entry1; @@ -370,7 +370,7 @@ static BOOLEAN PhpStringHashtableCompareFunction( } static ULONG PhpStringHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PSTRING_TABLE_ENTRY entry = Entry; @@ -379,8 +379,8 @@ static ULONG PhpStringHashtableHashFunction( } static int __cdecl PhpStringEntryCompareByCount( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PSTRING_TABLE_ENTRY entry1 = *(PSTRING_TABLE_ENTRY *)elem1; @@ -390,12 +390,12 @@ static int __cdecl PhpStringEntryCompareByCount( } static NTSTATUS PhpLeakEnumerationRoutine( - __in LONG Reserved, - __in PVOID HeapHandle, - __in PVOID BaseAddress, - __in SIZE_T BlockSize, - __in ULONG StackTraceDepth, - __in PVOID *StackTrace + _In_ LONG Reserved, + _In_ PVOID HeapHandle, + _In_ PVOID BaseAddress, + _In_ SIZE_T BlockSize, + _In_ ULONG StackTraceDepth, + _In_ PVOID *StackTrace ) { ULONG i; @@ -440,7 +440,7 @@ typedef struct _STOPWATCH } STOPWATCH, *PSTOPWATCH; static VOID PhInitializeStopwatch( - __out PSTOPWATCH Stopwatch + _Out_ PSTOPWATCH Stopwatch ) { Stopwatch->StartCounter.QuadPart = 0; @@ -448,21 +448,21 @@ static VOID PhInitializeStopwatch( } static VOID PhStartStopwatch( - __inout PSTOPWATCH Stopwatch + _Inout_ PSTOPWATCH Stopwatch ) { NtQueryPerformanceCounter(&Stopwatch->StartCounter, &Stopwatch->Frequency); } static VOID PhStopStopwatch( - __inout PSTOPWATCH Stopwatch + _Inout_ PSTOPWATCH Stopwatch ) { NtQueryPerformanceCounter(&Stopwatch->EndCounter, NULL); } static ULONG PhGetMillisecondsStopwatch( - __in PSTOPWATCH Stopwatch + _In_ PSTOPWATCH Stopwatch ) { LARGE_INTEGER countsPerMs; @@ -475,7 +475,7 @@ static ULONG PhGetMillisecondsStopwatch( } typedef VOID (FASTCALL *PPHF_RW_LOCK_FUNCTION)( - __in PVOID Parameter + _In_ PVOID Parameter ); typedef struct _RW_TEST_CONTEXT @@ -495,7 +495,7 @@ static LONG RwReadersActive; static LONG RwWritersActive; static NTSTATUS PhpRwLockTestThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { #define RW_ITERS 10000 @@ -567,7 +567,7 @@ static NTSTATUS PhpRwLockTestThreadStart( } static VOID PhpTestRwLock( - __in PRW_TEST_CONTEXT Context + _In_ PRW_TEST_CONTEXT Context ) { #define RW_PROCESSORS 4 @@ -622,28 +622,28 @@ static VOID PhpTestRwLock( } VOID FASTCALL PhfAcquireCriticalSection( - __in PRTL_CRITICAL_SECTION CriticalSection + _In_ PRTL_CRITICAL_SECTION CriticalSection ) { RtlEnterCriticalSection(CriticalSection); } VOID FASTCALL PhfReleaseCriticalSection( - __in PRTL_CRITICAL_SECTION CriticalSection + _In_ PRTL_CRITICAL_SECTION CriticalSection ) { RtlLeaveCriticalSection(CriticalSection); } VOID FASTCALL PhfReleaseQueuedLockExclusiveUsingInline( - __in PPH_QUEUED_LOCK QueuedLock + _In_ PPH_QUEUED_LOCK QueuedLock ) { PhReleaseQueuedLockExclusive(QueuedLock); } NTSTATUS PhpDebugConsoleThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PH_AUTO_POOL autoPool; @@ -1239,61 +1239,58 @@ NTSTATUS PhpDebugConsoleThreadStart( else if (WSTR_IEQUAL(command, L"provthreads")) { #ifdef DEBUG - PLIST_ENTRY currentEntry; - - PhAcquireQueuedLockShared(&PhDbgProviderListLock); - - currentEntry = PhDbgProviderListHead.Flink; + ULONG i; - while (currentEntry != &PhDbgProviderListHead) + if (PhDbgProviderList) { - PPH_PROVIDER_THREAD providerThread; - THREAD_BASIC_INFORMATION basicInfo; - PLIST_ENTRY providerEntry; - - providerThread = CONTAINING_RECORD(currentEntry, PH_PROVIDER_THREAD, DbgListEntry); + PhAcquireQueuedLockShared(&PhDbgProviderListLock); - if (providerThread->ThreadHandle) + for (i = 0; i < PhDbgProviderList->Count; i++) { - PhGetThreadBasicInformation(providerThread->ThreadHandle, &basicInfo); - wprintf(L"Thread %u\n", (ULONG)basicInfo.ClientId.UniqueThread); - } - else - { - wprintf(L"Thread not running\n"); - } + PPH_PROVIDER_THREAD providerThread = PhDbgProviderList->Items[i]; + THREAD_BASIC_INFORMATION basicInfo; + PLIST_ENTRY providerEntry; - PhAcquireQueuedLockExclusive(&providerThread->Lock); + if (providerThread->ThreadHandle) + { + PhGetThreadBasicInformation(providerThread->ThreadHandle, &basicInfo); + wprintf(L"Thread %u\n", (ULONG)basicInfo.ClientId.UniqueThread); + } + else + { + wprintf(L"Thread not running\n"); + } - providerEntry = providerThread->ListHead.Flink; + PhAcquireQueuedLockExclusive(&providerThread->Lock); - while (providerEntry != &providerThread->ListHead) - { - PPH_PROVIDER_REGISTRATION registration; + providerEntry = providerThread->ListHead.Flink; - registration = CONTAINING_RECORD(providerEntry, PH_PROVIDER_REGISTRATION, ListEntry); + while (providerEntry != &providerThread->ListHead) + { + PPH_PROVIDER_REGISTRATION registration; - wprintf(L"\tProvider registration at %Ix\n", registration); - wprintf(L"\t\tEnabled: %s\n", registration->Enabled ? L"Yes" : L"No"); - wprintf(L"\t\tFunction: %s\n", PhpGetSymbolForAddress(registration->Function)); + registration = CONTAINING_RECORD(providerEntry, PH_PROVIDER_REGISTRATION, ListEntry); - if (registration->Object) - { - wprintf(L"\t\tObject:\n"); - PhpPrintObjectInfo(PhObjectToObjectHeader(registration->Object), 0); - } + wprintf(L"\tProvider registration at %Ix\n", registration); + wprintf(L"\t\tEnabled: %s\n", registration->Enabled ? L"Yes" : L"No"); + wprintf(L"\t\tFunction: %s\n", PhpGetSymbolForAddress(registration->Function)); - providerEntry = providerEntry->Flink; - } + if (registration->Object) + { + wprintf(L"\t\tObject:\n"); + PhpPrintObjectInfo(PhObjectToObjectHeader(registration->Object), 0); + } - PhReleaseQueuedLockExclusive(&providerThread->Lock); + providerEntry = providerEntry->Flink; + } - wprintf(L"\n"); + PhReleaseQueuedLockExclusive(&providerThread->Lock); - currentEntry = currentEntry->Flink; - } + wprintf(L"\n"); + } - PhReleaseQueuedLockShared(&PhDbgProviderListLock); + PhReleaseQueuedLockShared(&PhDbgProviderListLock); + } #else wprintf(commandDebugOnly); #endif @@ -1301,53 +1298,50 @@ NTSTATUS PhpDebugConsoleThreadStart( else if (WSTR_IEQUAL(command, L"workqueues")) { #ifdef DEBUG - PLIST_ENTRY currentEntry; - - PhAcquireQueuedLockShared(&PhDbgWorkQueueListLock); - - currentEntry = PhDbgWorkQueueListHead.Flink; + ULONG i; - while (currentEntry != &PhDbgWorkQueueListHead) + if (PhDbgWorkQueueList) { - PPH_WORK_QUEUE workQueue; - PLIST_ENTRY workQueueItemEntry; + PhAcquireQueuedLockShared(&PhDbgWorkQueueListLock); - workQueue = CONTAINING_RECORD(currentEntry, PH_WORK_QUEUE, DbgListEntry); + for (i = 0; i < PhDbgWorkQueueList->Count; i++) + { + PPH_WORK_QUEUE workQueue = PhDbgWorkQueueList->Items[i]; + PLIST_ENTRY workQueueItemEntry; - wprintf(L"Work queue at %s\n", PhpGetSymbolForAddress(workQueue)); - wprintf(L"Maximum threads: %u\n", workQueue->MaximumThreads); - wprintf(L"Minimum threads: %u\n", workQueue->MinimumThreads); - wprintf(L"No work timeout: %d\n", workQueue->NoWorkTimeout); + wprintf(L"Work queue at %s\n", PhpGetSymbolForAddress(workQueue)); + wprintf(L"Maximum threads: %u\n", workQueue->MaximumThreads); + wprintf(L"Minimum threads: %u\n", workQueue->MinimumThreads); + wprintf(L"No work timeout: %d\n", workQueue->NoWorkTimeout); - wprintf(L"Current threads: %u\n", workQueue->CurrentThreads); - wprintf(L"Busy threads: %u\n", workQueue->BusyThreads); + wprintf(L"Current threads: %u\n", workQueue->CurrentThreads); + wprintf(L"Busy threads: %u\n", workQueue->BusyThreads); - PhAcquireQueuedLockExclusive(&workQueue->QueueLock); + PhAcquireQueuedLockExclusive(&workQueue->QueueLock); - // List the items backwards. - workQueueItemEntry = workQueue->QueueListHead.Blink; + // List the items backwards. + workQueueItemEntry = workQueue->QueueListHead.Blink; - while (workQueueItemEntry != &workQueue->QueueListHead) - { - PPH_WORK_QUEUE_ITEM workQueueItem; + while (workQueueItemEntry != &workQueue->QueueListHead) + { + PPH_WORK_QUEUE_ITEM workQueueItem; - workQueueItem = CONTAINING_RECORD(workQueueItemEntry, PH_WORK_QUEUE_ITEM, ListEntry); + workQueueItem = CONTAINING_RECORD(workQueueItemEntry, PH_WORK_QUEUE_ITEM, ListEntry); - wprintf(L"\tWork queue item at %Ix\n", workQueueItem); - wprintf(L"\t\tFunction: %s\n", PhpGetSymbolForAddress(workQueueItem->Function)); - wprintf(L"\t\tContext: %Ix\n", workQueueItem->Context); + wprintf(L"\tWork queue item at %Ix\n", workQueueItem); + wprintf(L"\t\tFunction: %s\n", PhpGetSymbolForAddress(workQueueItem->Function)); + wprintf(L"\t\tContext: %Ix\n", workQueueItem->Context); - workQueueItemEntry = workQueueItemEntry->Blink; - } + workQueueItemEntry = workQueueItemEntry->Blink; + } - PhReleaseQueuedLockExclusive(&workQueue->QueueLock); + PhReleaseQueuedLockExclusive(&workQueue->QueueLock); - wprintf(L"\n"); + wprintf(L"\n"); + } - currentEntry = currentEntry->Flink; + PhReleaseQueuedLockShared(&PhDbgWorkQueueListLock); } - - PhReleaseQueuedLockShared(&PhDbgWorkQueueListLock); #else wprintf(commandDebugOnly); #endif diff --git a/2.x/trunk/ProcessHacker/extmgr.c b/2.x/trunk/ProcessHacker/extmgr.c index 6f375521a..ecb7cee9a 100644 --- a/2.x/trunk/ProcessHacker/extmgr.c +++ b/2.x/trunk/ProcessHacker/extmgr.c @@ -55,8 +55,8 @@ VOID PhEmInitialization( * \param AppName The application name. */ VOID PhEmInitializeAppContext( - __out PPH_EM_APP_CONTEXT AppContext, - __in PPH_STRINGREF AppName + _Out_ PPH_EM_APP_CONTEXT AppContext, + _In_ PPH_STRINGREF AppName ) { AppContext->AppName = *AppName; @@ -76,11 +76,11 @@ VOID PhEmInitializeAppContext( * \param DeleteCallback The object deletion callback. */ VOID PhEmSetObjectExtension( - __inout PPH_EM_APP_CONTEXT AppContext, - __in PH_EM_OBJECT_TYPE ObjectType, - __in SIZE_T ExtensionSize, - __in_opt PPH_EM_OBJECT_CALLBACK CreateCallback, - __in_opt PPH_EM_OBJECT_CALLBACK DeleteCallback + _Inout_ PPH_EM_APP_CONTEXT AppContext, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ SIZE_T ExtensionSize, + _In_opt_ PPH_EM_OBJECT_CALLBACK CreateCallback, + _In_opt_ PPH_EM_OBJECT_CALLBACK DeleteCallback ) { PPH_EM_OBJECT_TYPE_STATE objectTypeState; @@ -114,9 +114,9 @@ VOID PhEmSetObjectExtension( * \param Object The object. */ PVOID PhEmGetObjectExtension( - __in PPH_EM_APP_CONTEXT AppContext, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Object + _In_ PPH_EM_APP_CONTEXT AppContext, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Object ) { PPH_EM_OBJECT_EXTENSION objectExtension; @@ -136,8 +136,8 @@ PVOID PhEmGetObjectExtension( * \param InitialSize The initial size of the object. */ SIZE_T PhEmGetObjectSize( - __in PH_EM_OBJECT_TYPE ObjectType, - __in SIZE_T InitialSize + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ SIZE_T InitialSize ) { PhEmObjectTypeState[ObjectType].InitialSize = InitialSize; @@ -153,9 +153,9 @@ SIZE_T PhEmGetObjectSize( * \param Operation The operation being performed. */ VOID PhEmCallObjectOperation( - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Object, - __in PH_EM_OBJECT_OPERATION Operation + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Object, + _In_ PH_EM_OBJECT_OPERATION Operation ) { PPH_EM_OBJECT_TYPE_STATE objectTypeState; @@ -194,9 +194,9 @@ VOID PhEmCallObjectOperation( * \param SubId A variable which receives the sub-ID. */ BOOLEAN PhEmParseCompoundId( - __in PPH_STRINGREF CompoundId, - __out PPH_STRINGREF AppName, - __out PULONG SubId + _In_ PPH_STRINGREF CompoundId, + _Out_ PPH_STRINGREF AppName, + _Out_ PULONG SubId ) { PH_STRINGREF firstPart; diff --git a/2.x/trunk/ProcessHacker/findobj.c b/2.x/trunk/ProcessHacker/findobj.c index a7a753f0a..8201341cb 100644 --- a/2.x/trunk/ProcessHacker/findobj.c +++ b/2.x/trunk/ProcessHacker/findobj.c @@ -2,7 +2,7 @@ * Process Hacker - * object search * - * Copyright (C) 2010-2012 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -21,6 +21,8 @@ */ #include +#include +#include #include #define WM_PH_SEARCH_UPDATE (WM_APP + 801) @@ -49,14 +51,14 @@ typedef struct _PHP_OBJECT_SEARCH_RESULT } PHP_OBJECT_SEARCH_RESULT, *PPHP_OBJECT_SEARCH_RESULT; INT_PTR CALLBACK PhpFindObjectsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); NTSTATUS PhpFindObjectsThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); HWND PhFindObjectsWindowHandle = NULL; @@ -95,9 +97,9 @@ VOID PhShowFindObjectsDialog( } VOID PhpInitializeFindObjMenu( - __in HMENU Menu, - __in PPHP_OBJECT_SEARCH_RESULT *Results, - __in ULONG NumberOfResults + _In_ PPH_EMENU Menu, + _In_ PPHP_OBJECT_SEARCH_RESULT *Results, + _In_ ULONG NumberOfResults ) { BOOLEAN allCanBeClosed = TRUE; @@ -105,12 +107,18 @@ VOID PhpInitializeFindObjMenu( if (NumberOfResults == 1) { - // Nothing + PH_HANDLE_ITEM_INFO info; + + info.ProcessId = Results[0]->ProcessId; + info.Handle = Results[0]->Handle; + info.TypeName = Results[0]->TypeName; + info.BestObjectName = Results[0]->Name; + PhInsertHandleObjectPropertiesEMenuItems(Menu, ID_OBJECT_COPY, FALSE, &info); } else { - PhEnableAllMenuItems(Menu, FALSE); - PhEnableMenuItem(Menu, ID_OBJECT_COPY, TRUE); + PhSetFlagsAllEMenuItems(Menu, PH_EMENU_DISABLED, PH_EMENU_DISABLED); + PhEnableEMenuItem(Menu, ID_OBJECT_COPY, TRUE); } for (i = 0; i < NumberOfResults; i++) @@ -122,13 +130,13 @@ VOID PhpInitializeFindObjMenu( } } - PhEnableMenuItem(Menu, ID_OBJECT_CLOSE, allCanBeClosed); + PhEnableEMenuItem(Menu, ID_OBJECT_CLOSE, allCanBeClosed); } INT NTAPI PhpObjectProcessCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPHP_OBJECT_SEARCH_RESULT item1 = Item1; @@ -144,9 +152,9 @@ INT NTAPI PhpObjectProcessCompareFunction( } INT NTAPI PhpObjectTypeCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPHP_OBJECT_SEARCH_RESULT item1 = Item1; @@ -156,9 +164,9 @@ INT NTAPI PhpObjectTypeCompareFunction( } INT NTAPI PhpObjectNameCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPHP_OBJECT_SEARCH_RESULT item1 = Item1; @@ -168,9 +176,9 @@ INT NTAPI PhpObjectNameCompareFunction( } INT NTAPI PhpObjectHandleCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPHP_OBJECT_SEARCH_RESULT item1 = Item1; @@ -180,10 +188,10 @@ INT NTAPI PhpObjectHandleCompareFunction( } static INT_PTR CALLBACK PhpFindObjectsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -396,19 +404,42 @@ static INT_PTR CALLBACK PhpFindObjectsDlgProc( PhFree(results); } break; - case ID_OBJECT_PROCESSPROPERTIES: + case ID_HANDLE_OBJECTPROPERTIES1: + case ID_HANDLE_OBJECTPROPERTIES2: { PPHP_OBJECT_SEARCH_RESULT result = PhGetSelectedListViewItemParam(PhFindObjectsListViewHandle); if (result) { - PPH_PROCESS_ITEM processItem; + PH_HANDLE_ITEM_INFO info; + + info.ProcessId = result->ProcessId; + info.Handle = result->Handle; + info.TypeName = result->TypeName; + info.BestObjectName = result->Name; - if (processItem = PhReferenceProcessItem(result->ProcessId)) + if (LOWORD(wParam) == ID_HANDLE_OBJECTPROPERTIES1) + PhShowHandleObjectProperties1(hwndDlg, &info); + else + PhShowHandleObjectProperties2(hwndDlg, &info); + } + } + break; + case ID_OBJECT_GOTOOWNINGPROCESS: + { + PPHP_OBJECT_SEARCH_RESULT result = + PhGetSelectedListViewItemParam(PhFindObjectsListViewHandle); + + if (result) + { + PPH_PROCESS_NODE processNode; + + if (processNode = PhFindProcessNode(result->ProcessId)) { - ProcessHacker_ShowProcessProperties(PhMainWndHandle, processItem); - PhDereferenceObject(processItem); + ProcessHacker_SelectTabPage(PhMainWndHandle, 0); + ProcessHacker_SelectProcessNode(PhMainWndHandle, processNode); + ProcessHacker_ToggleVisible(PhMainWndHandle, TRUE); } } } @@ -513,26 +544,28 @@ static INT_PTR CALLBACK PhpFindObjectsDlgProc( if (numberOfResults != 0) { - HMENU menu; - HMENU subMenu; + PPH_EMENU menu; + PPH_EMENU_ITEM item; - menu = LoadMenu(PhInstanceHandle, MAKEINTRESOURCE(IDR_FINDOBJ)); - subMenu = GetSubMenu(menu, 0); + menu = PhCreateEMenu(); + PhLoadResourceEMenuItem(menu, PhInstanceHandle, MAKEINTRESOURCE(IDR_FINDOBJ), 0); + PhSetFlagsEMenuItem(menu, ID_OBJECT_PROPERTIES, PH_EMENU_DEFAULT, PH_EMENU_DEFAULT); - SetMenuDefaultItem(subMenu, ID_OBJECT_PROPERTIES, FALSE); - PhpInitializeFindObjMenu( - subMenu, - results, - numberOfResults - ); + PhpInitializeFindObjMenu(menu, results, numberOfResults); - PhShowContextMenu( - hwndDlg, + item = PhShowEMenu( + menu, PhFindObjectsListViewHandle, - subMenu, - point + PH_EMENU_SHOW_LEFTRIGHT, + PH_ALIGN_LEFT | PH_ALIGN_TOP, + point.x, + point.y ); - DestroyMenu(menu); + + if (item) + SendMessage(hwndDlg, WM_COMMAND, item->Id, 0); + + PhDestroyEMenu(menu); } PhFree(results); @@ -632,8 +665,8 @@ static INT_PTR CALLBACK PhpFindObjectsDlgProc( } static BOOLEAN NTAPI EnumModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PPH_STRING upperFileName; @@ -689,7 +722,7 @@ static BOOLEAN NTAPI EnumModulesCallback( } static NTSTATUS PhpFindObjectsThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PSYSTEM_HANDLE_INFORMATION_EX handles; diff --git a/2.x/trunk/ProcessHacker/gdihndl.c b/2.x/trunk/ProcessHacker/gdihndl.c index 15894fab0..33b372832 100644 --- a/2.x/trunk/ProcessHacker/gdihndl.c +++ b/2.x/trunk/ProcessHacker/gdihndl.c @@ -39,15 +39,15 @@ typedef struct _PH_GDI_HANDLE_ITEM } PH_GDI_HANDLE_ITEM, *PPH_GDI_HANDLE_ITEM; INT_PTR CALLBACK PhpGdiHandlesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowGdiHandlesDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ) { GDI_HANDLES_CONTEXT context; @@ -78,7 +78,7 @@ VOID PhShowGdiHandlesDialog( } PWSTR PhpGetGdiHandleTypeName( - __in ULONG Unique + _In_ ULONG Unique ) { switch (GDI_CLIENT_TYPE_FROM_UNIQUE(Unique)) @@ -117,7 +117,7 @@ PWSTR PhpGetGdiHandleTypeName( } PPH_STRING PhpGetGdiHandleInformation( - __in ULONG Handle + _In_ ULONG Handle ) { HGDIOBJ handle; @@ -220,8 +220,8 @@ PPH_STRING PhpGetGdiHandleInformation( } VOID PhpRefreshGdiHandles( - __in HWND hwndDlg, - __in PGDI_HANDLES_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PGDI_HANDLES_CONTEXT Context ) { HWND lvHandle; @@ -288,9 +288,9 @@ VOID PhpRefreshGdiHandles( } INT NTAPI PhpGdiHandleHandleCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPH_GDI_HANDLE_ITEM item1 = Item1; @@ -300,9 +300,9 @@ INT NTAPI PhpGdiHandleHandleCompareFunction( } INT NTAPI PhpGdiHandleObjectCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPH_GDI_HANDLE_ITEM item1 = Item1; @@ -312,10 +312,10 @@ INT NTAPI PhpGdiHandleObjectCompareFunction( } INT_PTR CALLBACK PhpGdiHandlesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/heapinfo.c b/2.x/trunk/ProcessHacker/heapinfo.c index bc860aa4d..2e47c6e09 100644 --- a/2.x/trunk/ProcessHacker/heapinfo.c +++ b/2.x/trunk/ProcessHacker/heapinfo.c @@ -35,15 +35,15 @@ typedef struct _PROCESS_HEAPS_CONTEXT } PROCESS_HEAPS_CONTEXT, *PPROCESS_HEAPS_CONTEXT; INT_PTR CALLBACK PhpProcessHeapsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowProcessHeapsDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ) { NTSTATUS status; @@ -96,9 +96,9 @@ VOID PhShowProcessHeapsDialog( } static INT NTAPI PhpHeapAddressCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_HEAP_INFORMATION heapInfo1 = Item1; @@ -108,9 +108,9 @@ static INT NTAPI PhpHeapAddressCompareFunction( } static INT NTAPI PhpHeapUsedCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_HEAP_INFORMATION heapInfo1 = Item1; @@ -120,9 +120,9 @@ static INT NTAPI PhpHeapUsedCompareFunction( } static INT NTAPI PhpHeapCommittedCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_HEAP_INFORMATION heapInfo1 = Item1; @@ -132,9 +132,9 @@ static INT NTAPI PhpHeapCommittedCompareFunction( } static INT NTAPI PhpHeapEntriesCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_HEAP_INFORMATION heapInfo1 = Item1; @@ -144,9 +144,9 @@ static INT NTAPI PhpHeapEntriesCompareFunction( } static HFONT NTAPI PhpHeapFontFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ) { PRTL_HEAP_INFORMATION heapInfo = Param; @@ -164,10 +164,10 @@ static HFONT NTAPI PhpHeapFontFunction( } INT_PTR CALLBACK PhpProcessHeapsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPROCESS_HEAPS_CONTEXT context = NULL; @@ -347,8 +347,8 @@ INT_PTR CALLBACK PhpProcessHeapsDlgProc( } NTSTATUS PhGetProcessDefaultHeap( - __in HANDLE ProcessHandle, - __out PPVOID Heap + _In_ HANDLE ProcessHandle, + _Out_ PPVOID Heap ) { NTSTATUS status; diff --git a/2.x/trunk/ProcessHacker/hidnproc.c b/2.x/trunk/ProcessHacker/hidnproc.c index d9c39337f..49163184c 100644 --- a/2.x/trunk/ProcessHacker/hidnproc.c +++ b/2.x/trunk/ProcessHacker/hidnproc.c @@ -46,25 +46,25 @@ #include INT_PTR CALLBACK PhpHiddenProcessesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); COLORREF NTAPI PhpHiddenProcessesColorFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ); BOOLEAN NTAPI PhpHiddenProcessesCallback( - __in PPH_HIDDEN_PROCESS_ENTRY Process, - __in_opt PVOID Context + _In_ PPH_HIDDEN_PROCESS_ENTRY Process, + _In_opt_ PVOID Context ); PPH_PROCESS_ITEM PhpCreateProcessItemForHiddenProcess( - __in PPH_HIDDEN_PROCESS_ENTRY Entry + _In_ PPH_HIDDEN_PROCESS_ENTRY Entry ); HWND PhHiddenProcessesWindowHandle = NULL; @@ -107,10 +107,10 @@ VOID PhShowHiddenProcessesDialog( } static INT_PTR CALLBACK PhpHiddenProcessesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -485,9 +485,9 @@ static INT_PTR CALLBACK PhpHiddenProcessesDlgProc( } static COLORREF NTAPI PhpHiddenProcessesColorFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ) { PPH_HIDDEN_PROCESS_ENTRY entry = Param; @@ -505,8 +505,8 @@ static COLORREF NTAPI PhpHiddenProcessesColorFunction( } static BOOLEAN NTAPI PhpHiddenProcessesCallback( - __in PPH_HIDDEN_PROCESS_ENTRY Process, - __in_opt PVOID Context + _In_ PPH_HIDDEN_PROCESS_ENTRY Process, + _In_opt_ PVOID Context ) { PPH_HIDDEN_PROCESS_ENTRY entry; @@ -534,7 +534,7 @@ static BOOLEAN NTAPI PhpHiddenProcessesCallback( } static PPH_PROCESS_ITEM PhpCreateProcessItemForHiddenProcess( - __in PPH_HIDDEN_PROCESS_ENTRY Entry + _In_ PPH_HIDDEN_PROCESS_ENTRY Entry ) { NTSTATUS status; @@ -746,8 +746,8 @@ static PPH_PROCESS_ITEM PhpCreateProcessItemForHiddenProcess( } NTSTATUS PhpEnumHiddenProcessesBruteForce( - __in PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -868,8 +868,8 @@ typedef struct _CSR_HANDLES_CONTEXT } CSR_HANDLES_CONTEXT, *PCSR_HANDLES_CONTEXT; static BOOLEAN NTAPI PhpCsrProcessHandlesCallback( - __in PPH_CSR_HANDLE_INFO Handle, - __in_opt PVOID Context + _In_ PPH_CSR_HANDLE_INFO Handle, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -929,8 +929,8 @@ static BOOLEAN NTAPI PhpCsrProcessHandlesCallback( } NTSTATUS PhpEnumHiddenProcessesCsrHandles( - __in PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -965,9 +965,9 @@ NTSTATUS PhpEnumHiddenProcessesCsrHandles( } NTSTATUS PhEnumHiddenProcesses( - __in PH_HIDDEN_PROCESS_METHOD Method, - __in PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, - __in_opt PVOID Context + _In_ PH_HIDDEN_PROCESS_METHOD Method, + _In_ PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, + _In_opt_ PVOID Context ) { if (Method == BruteForceScanMethod) @@ -987,8 +987,8 @@ NTSTATUS PhEnumHiddenProcesses( } NTSTATUS PhpOpenCsrProcesses( - __out PHANDLE *ProcessHandles, - __out PULONG NumberOfProcessHandles + _Out_ PHANDLE *ProcessHandles, + _Out_ PULONG NumberOfProcessHandles ) { NTSTATUS status; @@ -1040,7 +1040,7 @@ NTSTATUS PhpOpenCsrProcesses( } NTSTATUS PhpGetCsrHandleProcessId( - __inout PPH_CSR_HANDLE_INFO Handle + _Inout_ PPH_CSR_HANDLE_INFO Handle ) { NTSTATUS status; @@ -1091,8 +1091,8 @@ NTSTATUS PhpGetCsrHandleProcessId( } NTSTATUS PhEnumCsrProcessHandles( - __in PPH_ENUM_CSR_PROCESS_HANDLES_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_ENUM_CSR_PROCESS_HANDLES_CALLBACK Callback, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -1161,9 +1161,9 @@ NTSTATUS PhEnumCsrProcessHandles( } NTSTATUS PhOpenProcessByCsrHandle( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in PPH_CSR_HANDLE_INFO Handle + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PPH_CSR_HANDLE_INFO Handle ) { NTSTATUS status; @@ -1215,8 +1215,8 @@ typedef struct _OPEN_PROCESS_BY_CSR_CONTEXT } OPEN_PROCESS_BY_CSR_CONTEXT, *POPEN_PROCESS_BY_CSR_CONTEXT; static BOOLEAN NTAPI PhpOpenProcessByCsrHandlesCallback( - __in PPH_CSR_HANDLE_INFO Handle, - __in_opt PVOID Context + _In_ PPH_CSR_HANDLE_INFO Handle, + _In_opt_ PVOID Context ) { POPEN_PROCESS_BY_CSR_CONTEXT context = Context; @@ -1236,9 +1236,9 @@ static BOOLEAN NTAPI PhpOpenProcessByCsrHandlesCallback( } NTSTATUS PhOpenProcessByCsrHandles( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ProcessId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ProcessId ) { NTSTATUS status; diff --git a/2.x/trunk/ProcessHacker/hndllist.c b/2.x/trunk/ProcessHacker/hndllist.c index 554cd39f0..2067af0e1 100644 --- a/2.x/trunk/ProcessHacker/hndllist.c +++ b/2.x/trunk/ProcessHacker/hndllist.c @@ -2,7 +2,7 @@ * Process Hacker - * handle list * - * Copyright (C) 2011-2012 wj32 + * Copyright (C) 2011-2013 wj32 * * This file is part of Process Hacker. * @@ -27,43 +27,43 @@ #include BOOLEAN PhpHandleNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG PhpHandleNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID PhpDestroyHandleNode( - __in PPH_HANDLE_NODE HandleNode + _In_ PPH_HANDLE_NODE HandleNode ); VOID PhpRemoveHandleNode( - __in PPH_HANDLE_NODE HandleNode, - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_NODE HandleNode, + _In_ PPH_HANDLE_LIST_CONTEXT Context ); LONG PhpHandleTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ); BOOLEAN NTAPI PhpHandleTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); VOID PhInitializeHandleList( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __out PPH_HANDLE_LIST_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _Out_ PPH_HANDLE_LIST_CONTEXT Context ) { HWND hwnd; @@ -108,7 +108,7 @@ VOID PhInitializeHandleList( } VOID PhDeleteHandleList( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ) { ULONG i; @@ -123,8 +123,8 @@ VOID PhDeleteHandleList( } BOOLEAN PhpHandleNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_HANDLE_NODE handleNode1 = *(PPH_HANDLE_NODE *)Entry1; @@ -134,14 +134,14 @@ BOOLEAN PhpHandleNodeHashtableCompareFunction( } ULONG PhpHandleNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { return (ULONG)(*(PPH_HANDLE_NODE *)Entry)->Handle / 4; } VOID PhLoadSettingsHandleList( - __inout PPH_HANDLE_LIST_CONTEXT Context + _Inout_ PPH_HANDLE_LIST_CONTEXT Context ) { PPH_STRING settings; @@ -155,7 +155,7 @@ VOID PhLoadSettingsHandleList( } VOID PhSaveSettingsHandleList( - __inout PPH_HANDLE_LIST_CONTEXT Context + _Inout_ PPH_HANDLE_LIST_CONTEXT Context ) { PPH_STRING settings; @@ -169,8 +169,8 @@ VOID PhSaveSettingsHandleList( } VOID PhSetOptionsHandleList( - __inout PPH_HANDLE_LIST_CONTEXT Context, - __in BOOLEAN HideUnnamedHandles + _Inout_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ BOOLEAN HideUnnamedHandles ) { ULONG i; @@ -207,9 +207,9 @@ VOID PhSetOptionsHandleList( } PPH_HANDLE_NODE PhAddHandleNode( - __inout PPH_HANDLE_LIST_CONTEXT Context, - __in PPH_HANDLE_ITEM HandleItem, - __in ULONG RunId + _Inout_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ PPH_HANDLE_ITEM HandleItem, + _In_ ULONG RunId ) { PPH_HANDLE_NODE handleNode; @@ -252,8 +252,8 @@ PPH_HANDLE_NODE PhAddHandleNode( } PPH_HANDLE_NODE PhFindHandleNode( - __in PPH_HANDLE_LIST_CONTEXT Context, - __in HANDLE Handle + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ HANDLE Handle ) { PH_HANDLE_NODE lookupHandleNode; @@ -274,8 +274,8 @@ PPH_HANDLE_NODE PhFindHandleNode( } VOID PhRemoveHandleNode( - __in PPH_HANDLE_LIST_CONTEXT Context, - __in PPH_HANDLE_NODE HandleNode + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ PPH_HANDLE_NODE HandleNode ) { // Remove from the hashtable here to avoid problems in case the key is re-used. @@ -299,7 +299,7 @@ VOID PhRemoveHandleNode( } VOID PhpDestroyHandleNode( - __in PPH_HANDLE_NODE HandleNode + _In_ PPH_HANDLE_NODE HandleNode ) { PhEmCallObjectOperation(EmHandleNodeType, HandleNode, EmObjectDelete); @@ -312,8 +312,8 @@ VOID PhpDestroyHandleNode( } VOID PhpRemoveHandleNode( - __in PPH_HANDLE_NODE HandleNode, - __in PPH_HANDLE_LIST_CONTEXT Context // PH_TICK_SH_STATE requires this parameter to be after HandleNode + _In_ PPH_HANDLE_NODE HandleNode, + _In_ PPH_HANDLE_LIST_CONTEXT Context // PH_TICK_SH_STATE requires this parameter to be after HandleNode ) { ULONG index; @@ -329,8 +329,8 @@ VOID PhpRemoveHandleNode( } VOID PhUpdateHandleNode( - __in PPH_HANDLE_LIST_CONTEXT Context, - __in PPH_HANDLE_NODE HandleNode + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ PPH_HANDLE_NODE HandleNode ) { memset(HandleNode->TextCache, 0, sizeof(PH_STRINGREF) * PHHNTLC_MAXIMUM); @@ -340,7 +340,7 @@ VOID PhUpdateHandleNode( } VOID PhTickHandleNodes( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ) { PH_TICK_SH_STATE_TN(PH_HANDLE_NODE, ShState, Context->NodeStateList, PhpRemoveHandleNode, PhCsHighlightingDuration, Context->TreeNewHandle, TRUE, NULL, Context); @@ -349,9 +349,9 @@ VOID PhTickHandleNodes( #define SORT_FUNCTION(Column) PhpHandleTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpHandleTreeNewCompare##Column( \ - __in void *_context, \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ void *_context, \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PPH_HANDLE_NODE node1 = *(PPH_HANDLE_NODE *)_elem1; \ @@ -369,10 +369,10 @@ VOID PhTickHandleNodes( } LONG PhpHandleTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ) { if (Result == 0) @@ -434,11 +434,11 @@ BEGIN_SORT_FUNCTION(FileShareAccess) END_SORT_FUNCTION BOOLEAN NTAPI PhpHandleTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PPH_HANDLE_LIST_CONTEXT context; @@ -642,7 +642,10 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback( SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_HANDLE_CLOSE, 1); break; case VK_RETURN: - SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_HANDLE_PROPERTIES, 0); + if (GetKeyState(VK_CONTROL) >= 0) + SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_HANDLE_PROPERTIES, 0); + else + SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_HANDLE_OBJECTPROPERTIES1, 0); break; } } @@ -692,7 +695,7 @@ BOOLEAN NTAPI PhpHandleTreeNewCallback( } PPH_HANDLE_ITEM PhGetSelectedHandleItem( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ) { PPH_HANDLE_ITEM handleItem = NULL; @@ -713,9 +716,9 @@ PPH_HANDLE_ITEM PhGetSelectedHandleItem( } VOID PhGetSelectedHandleItems( - __in PPH_HANDLE_LIST_CONTEXT Context, - __out PPH_HANDLE_ITEM **Handles, - __out PULONG NumberOfHandles + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _Out_ PPH_HANDLE_ITEM **Handles, + _Out_ PULONG NumberOfHandles ) { PPH_LIST list; @@ -740,7 +743,7 @@ VOID PhGetSelectedHandleItems( } VOID PhDeselectAllHandleNodes( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ) { TreeNew_DeselectRange(Context->TreeNewHandle, 0, -1); diff --git a/2.x/trunk/ProcessHacker/hndlprp.c b/2.x/trunk/ProcessHacker/hndlprp.c index 695d87fe4..6a5aa4b91 100644 --- a/2.x/trunk/ProcessHacker/hndlprp.c +++ b/2.x/trunk/ProcessHacker/hndlprp.c @@ -2,7 +2,7 @@ * Process Hacker - * handle properties * - * Copyright (C) 2010 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -31,16 +31,16 @@ typedef struct _HANDLE_PROPERTIES_CONTEXT } HANDLE_PROPERTIES_CONTEXT, *PHANDLE_PROPERTIES_CONTEXT; INT_PTR CALLBACK PhpHandleGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static NTSTATUS PhpDuplicateHandleFromProcess( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -69,9 +69,9 @@ static NTSTATUS PhpDuplicateHandleFromProcess( } VOID PhShowHandleProperties( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM HandleItem + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM HandleItem ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -206,19 +206,11 @@ VOID PhShowHandleProperties( PropertySheet(&propSheetHeader); } -static VOID PhpShowProcessPropContext( - __in PVOID Parameter - ) -{ - PhShowProcessProperties(Parameter); - PhDereferenceObject(Parameter); -} - INT_PTR CALLBACK PhpHandleGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -227,7 +219,6 @@ INT_PTR CALLBACK PhpHandleGeneralDlgProc( { LPPROPSHEETPAGE propSheetPage = (LPPROPSHEETPAGE)lParam; PHANDLE_PROPERTIES_CONTEXT context = (PHANDLE_PROPERTIES_CONTEXT)propSheetPage->lParam; - BOOLEAN showPropertiesButton = FALSE; PPH_ACCESS_ENTRY accessEntries; ULONG numberOfAccessEntries; HANDLE processHandle; @@ -236,29 +227,6 @@ INT_PTR CALLBACK PhpHandleGeneralDlgProc( SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)context); - if (!context) - { - // Dummy - } - else if (PhEqualString2(context->HandleItem->TypeName, L"File", TRUE)) - { - showPropertiesButton = TRUE; - } - else if (PhEqualString2(context->HandleItem->TypeName, L"Key", TRUE)) - { - showPropertiesButton = TRUE; - } - else if (PhEqualString2(context->HandleItem->TypeName, L"Process", TRUE)) - { - showPropertiesButton = TRUE; - } - else if (PhEqualString2(context->HandleItem->TypeName, L"Thread", TRUE)) - { - showPropertiesButton = TRUE; - } - - ShowWindow(GetDlgItem(hwndDlg, IDC_PROPERTIES), showPropertiesButton ? SW_SHOW : SW_HIDE); - SetDlgItemText(hwndDlg, IDC_NAME, PhGetString(context->HandleItem->BestObjectName)); SetDlgItemText(hwndDlg, IDC_TYPE, context->HandleItem->TypeName->Buffer); SetDlgItemText(hwndDlg, IDC_ADDRESS, context->HandleItem->ObjectString); @@ -343,170 +311,6 @@ INT_PTR CALLBACK PhpHandleGeneralDlgProc( RemoveProp(hwndDlg, PhMakeContextAtom()); } break; - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_PROPERTIES: - { - PHANDLE_PROPERTIES_CONTEXT context = (PHANDLE_PROPERTIES_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom()); - - if (!context) - { - // Dummy - } - else if (PhEqualString2(context->HandleItem->TypeName, L"File", TRUE)) - { - if (context->HandleItem->BestObjectName) - PhShellProperties(hwndDlg, context->HandleItem->BestObjectName->Buffer); - else - PhShowError(hwndDlg, L"Unable to open file properties because the object is unnamed."); - } - else if (PhEqualString2(context->HandleItem->TypeName, L"Key", TRUE)) - { - PhShellOpenKey(hwndDlg, context->HandleItem->BestObjectName); - } - else if (PhEqualString2(context->HandleItem->TypeName, L"Process", TRUE)) - { - HANDLE processHandle; - HANDLE processId; - PPH_PROCESS_ITEM processItem; - - processId = NULL; - - if (KphIsConnected()) - { - if (NT_SUCCESS(PhOpenProcess( - &processHandle, - ProcessQueryAccess, - context->ProcessId - ))) - { - PROCESS_BASIC_INFORMATION basicInfo; - - if (NT_SUCCESS(KphQueryInformationObject( - processHandle, - context->HandleItem->Handle, - KphObjectProcessBasicInformation, - &basicInfo, - sizeof(PROCESS_BASIC_INFORMATION), - NULL - ))) - { - processId = basicInfo.UniqueProcessId; - } - - NtClose(processHandle); - } - } - else - { - HANDLE handle; - PROCESS_BASIC_INFORMATION basicInfo; - - if (NT_SUCCESS(PhpDuplicateHandleFromProcess( - &handle, - ProcessQueryAccess, - context - ))) - { - if (NT_SUCCESS(PhGetProcessBasicInformation(handle, &basicInfo))) - processId = basicInfo.UniqueProcessId; - - NtClose(handle); - } - } - - if (processId) - { - processItem = PhReferenceProcessItem(processId); - - if (processItem) - { - ProcessHacker_ShowProcessProperties(PhMainWndHandle, processItem); - PhDereferenceObject(processItem); - } - else - { - PhShowError(hwndDlg, L"The process does not exist."); - } - } - } - else if (PhEqualString2(context->HandleItem->TypeName, L"Thread", TRUE)) - { - HANDLE processHandle; - CLIENT_ID clientId; - PPH_PROCESS_ITEM processItem; - PPH_PROCESS_PROPCONTEXT propContext; - - clientId.UniqueProcess = NULL; - clientId.UniqueThread = NULL; - - if (KphIsConnected()) - { - if (NT_SUCCESS(PhOpenProcess( - &processHandle, - ProcessQueryAccess, - context->ProcessId - ))) - { - THREAD_BASIC_INFORMATION basicInfo; - - if (NT_SUCCESS(KphQueryInformationObject( - processHandle, - context->HandleItem->Handle, - KphObjectThreadBasicInformation, - &basicInfo, - sizeof(THREAD_BASIC_INFORMATION), - NULL - ))) - { - clientId = basicInfo.ClientId; - } - - NtClose(processHandle); - } - } - else - { - HANDLE handle; - THREAD_BASIC_INFORMATION basicInfo; - - if (NT_SUCCESS(PhpDuplicateHandleFromProcess( - &handle, - ThreadQueryAccess, - context - ))) - { - if (NT_SUCCESS(PhGetThreadBasicInformation(handle, &basicInfo))) - clientId = basicInfo.ClientId; - - NtClose(handle); - } - } - - if (clientId.UniqueProcess) - { - processItem = PhReferenceProcessItem(clientId.UniqueProcess); - - if (processItem) - { - propContext = PhCreateProcessPropContext(PhMainWndHandle, processItem); - PhDereferenceObject(processItem); - PhSetSelectThreadIdProcessPropContext(propContext, clientId.UniqueThread); - ProcessHacker_Invoke(PhMainWndHandle, PhpShowProcessPropContext, propContext); - } - else - { - PhShowError(hwndDlg, L"The process does not exist."); - } - } - } - } - break; - } - } - break; case WM_NOTIFY: { LPNMHDR header = (LPNMHDR)lParam; diff --git a/2.x/trunk/ProcessHacker/hndlprv.c b/2.x/trunk/ProcessHacker/hndlprv.c index 1a9aba6eb..3ee2e117f 100644 --- a/2.x/trunk/ProcessHacker/hndlprv.c +++ b/2.x/trunk/ProcessHacker/hndlprv.c @@ -26,13 +26,13 @@ #include VOID NTAPI PhpHandleProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); VOID NTAPI PhpHandleItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); PPH_OBJECT_TYPE PhHandleProviderType; @@ -62,7 +62,7 @@ BOOLEAN PhHandleProviderInitialization( } PPH_HANDLE_PROVIDER PhCreateHandleProvider( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { PPH_HANDLE_PROVIDER handleProvider; @@ -88,7 +88,7 @@ PPH_HANDLE_PROVIDER PhCreateHandleProvider( handleProvider->ProcessId = ProcessId; handleProvider->ProcessHandle = NULL; - PhOpenProcess( + handleProvider->RunStatus = PhOpenProcess( &handleProvider->ProcessHandle, PROCESS_DUP_HANDLE, ProcessId @@ -100,8 +100,8 @@ PPH_HANDLE_PROVIDER PhCreateHandleProvider( } VOID PhpHandleProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_HANDLE_PROVIDER handleProvider = (PPH_HANDLE_PROVIDER)Object; @@ -121,7 +121,7 @@ VOID PhpHandleProviderDeleteProcedure( } PPH_HANDLE_ITEM PhCreateHandleItem( - __in_opt PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handle + _In_opt_ PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handle ) { PPH_HANDLE_ITEM handleItem; @@ -153,8 +153,8 @@ PPH_HANDLE_ITEM PhCreateHandleItem( } VOID PhpHandleItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_HANDLE_ITEM handleItem = (PPH_HANDLE_ITEM)Object; @@ -167,23 +167,23 @@ VOID PhpHandleItemDeleteProcedure( } FORCEINLINE BOOLEAN PhCompareHandleItem( - __in PPH_HANDLE_ITEM Value1, - __in PPH_HANDLE_ITEM Value2 + _In_ PPH_HANDLE_ITEM Value1, + _In_ PPH_HANDLE_ITEM Value2 ) { return Value1->Handle == Value2->Handle; } FORCEINLINE ULONG PhHashHandleItem( - __in PPH_HANDLE_ITEM Value + _In_ PPH_HANDLE_ITEM Value ) { return (ULONG)Value->Handle / 4; } PPH_HANDLE_ITEM PhpLookupHandleItem( - __in __assumeLocked PPH_HANDLE_PROVIDER HandleProvider, - __in HANDLE Handle + _In_ PPH_HANDLE_PROVIDER HandleProvider, + _In_ HANDLE Handle ) { PH_HANDLE_ITEM lookupHandleItem; @@ -209,8 +209,8 @@ PPH_HANDLE_ITEM PhpLookupHandleItem( } PPH_HANDLE_ITEM PhReferenceHandleItem( - __in PPH_HANDLE_PROVIDER HandleProvider, - __in HANDLE Handle + _In_ PPH_HANDLE_PROVIDER HandleProvider, + _In_ HANDLE Handle ) { PPH_HANDLE_ITEM handleItem; @@ -228,7 +228,7 @@ PPH_HANDLE_ITEM PhReferenceHandleItem( } VOID PhDereferenceAllHandleItems( - __in PPH_HANDLE_PROVIDER HandleProvider + _In_ PPH_HANDLE_PROVIDER HandleProvider ) { ULONG i; @@ -252,9 +252,9 @@ VOID PhDereferenceAllHandleItems( PhReleaseQueuedLockExclusive(&HandleProvider->HandleHashSetLock); } -__assumeLocked VOID PhpAddHandleItem( - __in PPH_HANDLE_PROVIDER HandleProvider, - __in __assumeRefs(1) PPH_HANDLE_ITEM HandleItem +VOID PhpAddHandleItem( + _In_ PPH_HANDLE_PROVIDER HandleProvider, + _In_ _Assume_refs_(1) PPH_HANDLE_ITEM HandleItem ) { if (HandleProvider->HandleHashSetSize < HandleProvider->HandleHashSetCount + 1) @@ -275,9 +275,9 @@ __assumeLocked VOID PhpAddHandleItem( HandleProvider->HandleHashSetCount++; } -__assumeLocked VOID PhpRemoveHandleItem( - __in PPH_HANDLE_PROVIDER HandleProvider, - __in PPH_HANDLE_ITEM HandleItem +VOID PhpRemoveHandleItem( + _In_ PPH_HANDLE_PROVIDER HandleProvider, + _In_ PPH_HANDLE_ITEM HandleItem ) { PhRemoveEntryHashSet(HandleProvider->HandleHashSet, HandleProvider->HandleHashSetSize, &HandleItem->HashEntry); @@ -296,10 +296,10 @@ __assumeLocked VOID PhpRemoveHandleItem( * whether the handle information needs to be filtered by process ID. */ NTSTATUS PhEnumHandlesGeneric( - __in HANDLE ProcessId, - __in HANDLE ProcessHandle, - __out PSYSTEM_HANDLE_INFORMATION_EX *Handles, - __out PBOOLEAN FilterNeeded + _In_ HANDLE ProcessId, + _In_ HANDLE ProcessHandle, + _Out_ PSYSTEM_HANDLE_INFORMATION_EX *Handles, + _Out_ PBOOLEAN FilterNeeded ) { NTSTATUS status; @@ -423,7 +423,7 @@ NTSTATUS PhEnumHandlesGeneric( } VOID PhHandleProviderUpdate( - __in PVOID Object + _In_ PVOID Object ) { PPH_HANDLE_PROVIDER handleProvider = (PPH_HANDLE_PROVIDER)Object; @@ -436,15 +436,15 @@ VOID PhHandleProviderUpdate( PPH_KEY_VALUE_PAIR handlePair; if (!handleProvider->ProcessHandle) - return; + goto UpdateExit; - if (!NT_SUCCESS(PhEnumHandlesGeneric( + if (!NT_SUCCESS(handleProvider->RunStatus = PhEnumHandlesGeneric( handleProvider->ProcessId, handleProvider->ProcessHandle, &handleInfo, &filterNeeded ))) - return; + goto UpdateExit; handles = handleInfo->Handles; numberOfHandles = (ULONG)handleInfo->NumberOfHandles; @@ -640,5 +640,6 @@ VOID PhHandleProviderUpdate( PhClearHashtable(handleProvider->TempListHashtable); } +UpdateExit: PhInvokeCallback(&handleProvider->UpdatedEvent, NULL); } diff --git a/2.x/trunk/ProcessHacker/hndlstat.c b/2.x/trunk/ProcessHacker/hndlstat.c index 8efa859e5..010280cef 100644 --- a/2.x/trunk/ProcessHacker/hndlstat.c +++ b/2.x/trunk/ProcessHacker/hndlstat.c @@ -38,15 +38,15 @@ typedef struct _HANDLE_STATISTICS_CONTEXT } HANDLE_STATISTICS_CONTEXT, *PHANDLE_STATISTICS_CONTEXT; INT_PTR CALLBACK PhpHandleStatisticsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowHandleStatisticsDialog( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -101,9 +101,9 @@ VOID PhShowHandleStatisticsDialog( } static INT NTAPI PhpTypeCountCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PHANDLE_STATISTICS_ENTRY entry1 = Item1; @@ -113,10 +113,10 @@ static INT NTAPI PhpTypeCountCompareFunction( } INT_PTR CALLBACK PhpHandleStatisticsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/include/colmgr.h b/2.x/trunk/ProcessHacker/include/colmgr.h index 8e601ddf8..3c66e5bdf 100644 --- a/2.x/trunk/ProcessHacker/include/colmgr.h +++ b/2.x/trunk/ProcessHacker/include/colmgr.h @@ -4,10 +4,10 @@ #define PH_CM_ORDER_LIMIT 160 typedef LONG (NTAPI *PPH_CM_POST_SORT_FUNCTION)( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ); typedef struct _PH_CM_MANAGER @@ -31,82 +31,82 @@ typedef struct _PH_CM_COLUMN } PH_CM_COLUMN, *PPH_CM_COLUMN; VOID PhCmInitializeManager( - __out PPH_CM_MANAGER Manager, - __in HWND Handle, - __in ULONG MinId, - __in PPH_CM_POST_SORT_FUNCTION PostSortFunction + _Out_ PPH_CM_MANAGER Manager, + _In_ HWND Handle, + _In_ ULONG MinId, + _In_ PPH_CM_POST_SORT_FUNCTION PostSortFunction ); VOID PhCmDeleteManager( - __in PPH_CM_MANAGER Manager + _In_ PPH_CM_MANAGER Manager ); PPH_CM_COLUMN PhCmCreateColumn( - __inout PPH_CM_MANAGER Manager, - __in PPH_TREENEW_COLUMN Column, - __in struct _PH_PLUGIN *Plugin, - __in ULONG SubId, - __in_opt PVOID Context, - __in PVOID SortFunction + _Inout_ PPH_CM_MANAGER Manager, + _In_ PPH_TREENEW_COLUMN Column, + _In_ struct _PH_PLUGIN *Plugin, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_ PVOID SortFunction ); PPH_CM_COLUMN PhCmFindColumn( - __in PPH_CM_MANAGER Manager, - __in PPH_STRINGREF PluginName, - __in ULONG SubId + _In_ PPH_CM_MANAGER Manager, + _In_ PPH_STRINGREF PluginName, + _In_ ULONG SubId ); VOID PhCmSetNotifyPlugin( - __in PPH_CM_MANAGER Manager, - __in struct _PH_PLUGIN *Plugin + _In_ PPH_CM_MANAGER Manager, + _In_ struct _PH_PLUGIN *Plugin ); BOOLEAN PhCmForwardMessage( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in PPH_CM_MANAGER Manager + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_ PPH_CM_MANAGER Manager ); BOOLEAN PhCmForwardSort( - __in PPH_TREENEW_NODE *Nodes, - __in ULONG NumberOfNodes, - __in ULONG SortColumn, - __in PH_SORT_ORDER SortOrder, - __in PPH_CM_MANAGER Manager + _In_ PPH_TREENEW_NODE *Nodes, + _In_ ULONG NumberOfNodes, + _In_ ULONG SortColumn, + _In_ PH_SORT_ORDER SortOrder, + _In_ PPH_CM_MANAGER Manager ); PHAPPAPI BOOLEAN NTAPI PhCmLoadSettings( - __in HWND TreeNewHandle, - __in PPH_STRINGREF Settings + _In_ HWND TreeNewHandle, + _In_ PPH_STRINGREF Settings ); #define PH_CM_COLUMN_WIDTHS_ONLY 0x1 BOOLEAN PhCmLoadSettingsEx( - __in HWND TreeNewHandle, - __in_opt PPH_CM_MANAGER Manager, - __in ULONG Flags, - __in PPH_STRINGREF Settings, - __in_opt PPH_STRINGREF SortSettings + _In_ HWND TreeNewHandle, + _In_opt_ PPH_CM_MANAGER Manager, + _In_ ULONG Flags, + _In_ PPH_STRINGREF Settings, + _In_opt_ PPH_STRINGREF SortSettings ); PHAPPAPI PPH_STRING NTAPI PhCmSaveSettings( - __in HWND TreeNewHandle + _In_ HWND TreeNewHandle ); PPH_STRING PhCmSaveSettingsEx( - __in HWND TreeNewHandle, - __in_opt PPH_CM_MANAGER Manager, - __in ULONG Flags, - __out_opt PPH_STRING *SortSettings + _In_ HWND TreeNewHandle, + _In_opt_ PPH_CM_MANAGER Manager, + _In_ ULONG Flags, + _Out_opt_ PPH_STRING *SortSettings ); #endif diff --git a/2.x/trunk/ProcessHacker/include/extmgr.h b/2.x/trunk/ProcessHacker/include/extmgr.h index cb3c7f78c..96344f0fd 100644 --- a/2.x/trunk/ProcessHacker/include/extmgr.h +++ b/2.x/trunk/ProcessHacker/include/extmgr.h @@ -29,9 +29,9 @@ typedef enum _PH_EM_OBJECT_OPERATION } PH_EM_OBJECT_OPERATION; typedef VOID (NTAPI *PPH_EM_OBJECT_CALLBACK)( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ); typedef struct _PH_EM_APP_CONTEXT diff --git a/2.x/trunk/ProcessHacker/include/extmgri.h b/2.x/trunk/ProcessHacker/include/extmgri.h index 3876d336e..dcbf701b5 100644 --- a/2.x/trunk/ProcessHacker/include/extmgri.h +++ b/2.x/trunk/ProcessHacker/include/extmgri.h @@ -23,39 +23,39 @@ VOID PhEmInitialization( ); VOID PhEmInitializeAppContext( - __out PPH_EM_APP_CONTEXT AppContext, - __in PPH_STRINGREF AppName + _Out_ PPH_EM_APP_CONTEXT AppContext, + _In_ PPH_STRINGREF AppName ); VOID PhEmSetObjectExtension( - __inout PPH_EM_APP_CONTEXT AppContext, - __in PH_EM_OBJECT_TYPE ObjectType, - __in SIZE_T ExtensionSize, - __in_opt PPH_EM_OBJECT_CALLBACK CreateCallback, - __in_opt PPH_EM_OBJECT_CALLBACK DeleteCallback + _Inout_ PPH_EM_APP_CONTEXT AppContext, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ SIZE_T ExtensionSize, + _In_opt_ PPH_EM_OBJECT_CALLBACK CreateCallback, + _In_opt_ PPH_EM_OBJECT_CALLBACK DeleteCallback ); PVOID PhEmGetObjectExtension( - __in PPH_EM_APP_CONTEXT AppContext, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Object + _In_ PPH_EM_APP_CONTEXT AppContext, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Object ); SIZE_T PhEmGetObjectSize( - __in PH_EM_OBJECT_TYPE ObjectType, - __in SIZE_T InitialSize + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ SIZE_T InitialSize ); VOID PhEmCallObjectOperation( - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Object, - __in PH_EM_OBJECT_OPERATION Operation + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Object, + _In_ PH_EM_OBJECT_OPERATION Operation ); BOOLEAN PhEmParseCompoundId( - __in PPH_STRINGREF CompoundId, - __out PPH_STRINGREF AppName, - __out PULONG SubId + _In_ PPH_STRINGREF CompoundId, + _Out_ PPH_STRINGREF AppName, + _Out_ PULONG SubId ); #endif diff --git a/2.x/trunk/ProcessHacker/include/hidnproc.h b/2.x/trunk/ProcessHacker/include/hidnproc.h index 60d3b0d01..9fd4129cb 100644 --- a/2.x/trunk/ProcessHacker/include/hidnproc.h +++ b/2.x/trunk/ProcessHacker/include/hidnproc.h @@ -32,48 +32,48 @@ typedef struct _PH_CSR_HANDLE_INFO } PH_CSR_HANDLE_INFO, *PPH_CSR_HANDLE_INFO; typedef BOOLEAN (NTAPI *PPH_ENUM_HIDDEN_PROCESSES_CALLBACK)( - __in PPH_HIDDEN_PROCESS_ENTRY Process, - __in_opt PVOID Context + _In_ PPH_HIDDEN_PROCESS_ENTRY Process, + _In_opt_ PVOID Context ); PHAPPAPI NTSTATUS NTAPI PhEnumHiddenProcesses( - __in PH_HIDDEN_PROCESS_METHOD Method, - __in PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, - __in_opt PVOID Context + _In_ PH_HIDDEN_PROCESS_METHOD Method, + _In_ PPH_ENUM_HIDDEN_PROCESSES_CALLBACK Callback, + _In_opt_ PVOID Context ); typedef BOOLEAN (NTAPI *PPH_ENUM_CSR_PROCESS_HANDLES_CALLBACK)( - __in PPH_CSR_HANDLE_INFO Handle, - __in_opt PVOID Context + _In_ PPH_CSR_HANDLE_INFO Handle, + _In_opt_ PVOID Context ); PHAPPAPI NTSTATUS NTAPI PhEnumCsrProcessHandles( - __in PPH_ENUM_CSR_PROCESS_HANDLES_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_ENUM_CSR_PROCESS_HANDLES_CALLBACK Callback, + _In_opt_ PVOID Context ); PHAPPAPI NTSTATUS NTAPI PhOpenProcessByCsrHandle( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in PPH_CSR_HANDLE_INFO Handle + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PPH_CSR_HANDLE_INFO Handle ); PHAPPAPI NTSTATUS NTAPI PhOpenProcessByCsrHandles( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ProcessId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ProcessId ); #endif diff --git a/2.x/trunk/ProcessHacker/include/mainwndp.h b/2.x/trunk/ProcessHacker/include/mainwndp.h index 9a4edc903..b1606ad54 100644 --- a/2.x/trunk/ProcessHacker/include/mainwndp.h +++ b/2.x/trunk/ProcessHacker/include/mainwndp.h @@ -2,10 +2,10 @@ #define MAINWNDP_H LRESULT CALLBACK PhMwpWndProc( - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hWnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // Initialization @@ -23,7 +23,7 @@ VOID PhMwpInitializeControls( ); NTSTATUS PhMwpDelayedLoadFunction( - __in PVOID Parameter + _In_ PVOID Parameter ); PPH_STRING PhMwpFindDbghelpPath( @@ -45,29 +45,29 @@ VOID PhMwpOnSettingChange( ); VOID PhMwpOnCommand( - __in ULONG Id + _In_ ULONG Id ); VOID PhMwpOnShowWindow( - __in BOOLEAN Showing, - __in ULONG State + _In_ BOOLEAN Showing, + _In_ ULONG State ); BOOLEAN PhMwpOnSysCommand( - __in ULONG Type, - __in LONG CursorScreenX, - __in LONG CursorScreenY + _In_ ULONG Type, + _In_ LONG CursorScreenX, + _In_ LONG CursorScreenY ); VOID PhMwpOnMenuCommand( - __in ULONG Index, - __in HMENU Menu + _In_ ULONG Index, + _In_ HMENU Menu ); VOID PhMwpOnInitMenuPopup( - __in HMENU Menu, - __in ULONG Index, - __in BOOLEAN IsWindowMenu + _In_ HMENU Menu, + _In_ ULONG Index, + _In_ BOOLEAN IsWindowMenu ); VOID PhMwpOnSize( @@ -75,8 +75,8 @@ VOID PhMwpOnSize( ); VOID PhMwpOnSizing( - __in ULONG Edge, - __in PRECT DragRectangle + _In_ ULONG Edge, + _In_ PRECT DragRectangle ); VOID PhMwpOnSetFocus( @@ -84,81 +84,81 @@ VOID PhMwpOnSetFocus( ); BOOLEAN PhMwpOnNotify( - __in NMHDR *Header, - __out LRESULT *Result + _In_ NMHDR *Header, + _Out_ LRESULT *Result ); VOID PhMwpOnWtsSessionChange( - __in ULONG Reason, - __in ULONG SessionId + _In_ ULONG Reason, + _In_ ULONG SessionId ); ULONG_PTR PhMwpOnUserMessage( - __in ULONG Message, - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ ULONG Message, + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ); // Callbacks VOID NTAPI PhMwpProcessAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpProcessModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpProcessRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpProcessesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpServiceAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpServiceModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpServiceRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpServicesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpNetworkItemAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpNetworkItemModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpNetworkItemRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI PhMwpNetworkItemsUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); // Settings @@ -178,8 +178,8 @@ VOID PhMwpSaveWindowSettings( // Misc. VOID PhMwpSymInitHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID PhMwpUpdateLayoutPadding( @@ -187,150 +187,150 @@ VOID PhMwpUpdateLayoutPadding( ); VOID PhMwpApplyLayoutPadding( - __inout PRECT Rect, - __in PRECT Padding + _Inout_ PRECT Rect, + _In_ PRECT Padding ); VOID PhMwpLayout( - __inout HDWP *DeferHandle + _Inout_ HDWP *DeferHandle ); VOID PhMwpSetCheckOpacityMenu( - __in BOOLEAN AssumeAllUnchecked, - __in ULONG Opacity + _In_ BOOLEAN AssumeAllUnchecked, + _In_ ULONG Opacity ); VOID PhMwpSetWindowOpacity( - __in ULONG Opacity + _In_ ULONG Opacity ); VOID PhMwpSetupComputerMenu( - __in PPH_EMENU_ITEM Root + _In_ PPH_EMENU_ITEM Root ); BOOLEAN PhMwpExecuteComputerCommand( - __in ULONG Id + _In_ ULONG Id ); VOID PhMwpActivateWindow( - __in BOOLEAN Toggle + _In_ BOOLEAN Toggle ); // Main menu VOID PhMwpInitializeMainMenu( - __in HMENU Menu + _In_ HMENU Menu ); VOID PhMwpDispatchMenuCommand( - __in HMENU MenuHandle, - __in ULONG ItemIndex, - __in ULONG ItemId, - __in ULONG_PTR ItemData + _In_ HMENU MenuHandle, + _In_ ULONG ItemIndex, + _In_ ULONG ItemId, + _In_ ULONG_PTR ItemData ); ULONG_PTR PhMwpLegacyAddPluginMenuItem( - __in PPH_ADDMENUITEM AddMenuItem + _In_ PPH_ADDMENUITEM AddMenuItem ); VOID PhMwpInitializeSubMenu( - __in PPH_EMENU Menu, - __in ULONG Index + _In_ PPH_EMENU Menu, + _In_ ULONG Index ); PPH_EMENU_ITEM PhMwpFindTrayIconsMenuItem( - __in PPH_EMENU Menu + _In_ PPH_EMENU Menu ); VOID PhMwpInitializeSectionMenuItems( - __in PPH_EMENU Menu, - __in ULONG StartIndex + _In_ PPH_EMENU Menu, + _In_ ULONG StartIndex ); // Tab control VOID PhMwpLayoutTabControl( - __inout HDWP *DeferHandle + _Inout_ HDWP *DeferHandle ); VOID PhMwpNotifyTabControl( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID PhMwpSelectionChangedTabControl( - __in ULONG OldIndex + _In_ ULONG OldIndex ); PPH_ADDITIONAL_TAB_PAGE PhMwpAddTabPage( - __in PPH_ADDITIONAL_TAB_PAGE TabPage + _In_ PPH_ADDITIONAL_TAB_PAGE TabPage ); VOID PhMwpSelectTabPage( - __in ULONG Index + _In_ ULONG Index ); // Notifications VOID PhMwpAddIconProcesses( - __in PPH_EMENU_ITEM Menu, - __in ULONG NumberOfProcesses + _In_ PPH_EMENU_ITEM Menu, + _In_ ULONG NumberOfProcesses ); VOID PhMwpShowIconContextMenu( - __in POINT Location + _In_ POINT Location ); BOOLEAN PhMwpPluginNotifyEvent( - __in ULONG Type, - __in PVOID Parameter + _In_ ULONG Type, + _In_ PVOID Parameter ); // Processes VOID PhMwpShowProcessProperties( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); BOOLEAN PhMwpCurrentUserProcessTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); BOOLEAN PhMwpSignedProcessTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); BOOLEAN PhMwpExecuteProcessPriorityCommand( - __in ULONG Id, - __in PPH_PROCESS_ITEM ProcessItem + _In_ ULONG Id, + _In_ PPH_PROCESS_ITEM ProcessItem ); VOID PhMwpSetProcessMenuPriorityChecks( - __in PPH_EMENU Menu, - __in PPH_PROCESS_ITEM Process, - __in BOOLEAN SetPriority, - __in BOOLEAN SetIoPriority, - __in BOOLEAN SetPagePriority + _In_ PPH_EMENU Menu, + _In_ PPH_PROCESS_ITEM Process, + _In_ BOOLEAN SetPriority, + _In_ BOOLEAN SetIoPriority, + _In_ BOOLEAN SetPagePriority ); VOID PhMwpInitializeProcessMenu( - __in PPH_EMENU Menu, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ PPH_EMENU Menu, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); VOID PhMwpOnProcessAdded( - __in __assumeRefs(1) PPH_PROCESS_ITEM ProcessItem, - __in ULONG RunId + _In_ _Assume_refs_(1) PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG RunId ); VOID PhMwpOnProcessModified( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); VOID PhMwpOnProcessRemoved( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); VOID PhMwpOnProcessesUpdated( @@ -344,27 +344,27 @@ VOID PhMwpNeedServiceTreeList( ); BOOLEAN PhMwpDriverServiceTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); VOID PhMwpInitializeServiceMenu( - __in PPH_EMENU Menu, - __in PPH_SERVICE_ITEM *Services, - __in ULONG NumberOfServices + _In_ PPH_EMENU Menu, + _In_ PPH_SERVICE_ITEM *Services, + _In_ ULONG NumberOfServices ); VOID PhMwpOnServiceAdded( - __in __assumeRefs(1) PPH_SERVICE_ITEM ServiceItem, - __in ULONG RunId + _In_ _Assume_refs_(1) PPH_SERVICE_ITEM ServiceItem, + _In_ ULONG RunId ); VOID PhMwpOnServiceModified( - __in PPH_SERVICE_MODIFIED_DATA ServiceModifiedData + _In_ PPH_SERVICE_MODIFIED_DATA ServiceModifiedData ); VOID PhMwpOnServiceRemoved( - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_SERVICE_ITEM ServiceItem ); VOID PhMwpOnServicesUpdated( @@ -378,32 +378,32 @@ VOID PhMwpNeedNetworkTreeList( ); BOOLEAN PhMwpCurrentUserNetworkTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); BOOLEAN PhMwpSignedNetworkTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); VOID PhMwpInitializeNetworkMenu( - __in PPH_EMENU Menu, - __in PPH_NETWORK_ITEM *NetworkItems, - __in ULONG NumberOfNetworkItems + _In_ PPH_EMENU Menu, + _In_ PPH_NETWORK_ITEM *NetworkItems, + _In_ ULONG NumberOfNetworkItems ); VOID PhMwpOnNetworkItemAdded( - __in ULONG RunId, - __in __assumeRefs(1) PPH_NETWORK_ITEM NetworkItem + _In_ ULONG RunId, + _In_ _Assume_refs_(1) PPH_NETWORK_ITEM NetworkItem ); VOID PhMwpOnNetworkItemModified( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ); VOID PhMwpOnNetworkItemRemoved( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ); VOID PhMwpOnNetworkItemsUpdated( diff --git a/2.x/trunk/ProcessHacker/include/memsrch.h b/2.x/trunk/ProcessHacker/include/memsrch.h index e9bf35033..6b74e77b5 100644 --- a/2.x/trunk/ProcessHacker/include/memsrch.h +++ b/2.x/trunk/ProcessHacker/include/memsrch.h @@ -10,8 +10,8 @@ typedef struct _PH_MEMORY_RESULT } PH_MEMORY_RESULT, *PPH_MEMORY_RESULT; typedef VOID (NTAPI *PPH_MEMORY_RESULT_CALLBACK)( - __in __assumeRefs(1) PPH_MEMORY_RESULT Result, - __in_opt PVOID Context + _In_ _Assume_refs_(1) PPH_MEMORY_RESULT Result, + _In_opt_ PVOID Context ); #define PH_DISPLAY_BUFFER_COUNT (PAGE_SIZE * 2 - 1) @@ -33,29 +33,29 @@ typedef struct _PH_MEMORY_STRING_OPTIONS } PH_MEMORY_STRING_OPTIONS, *PPH_MEMORY_STRING_OPTIONS; PVOID PhAllocateForMemorySearch( - __in SIZE_T Size + _In_ SIZE_T Size ); VOID PhFreeForMemorySearch( - __in __post_invalid PVOID Memory + _In_ _Post_invalid_ PVOID Memory ); PVOID PhCreateMemoryResult( - __in PVOID Address, - __in SIZE_T Length + _In_ PVOID Address, + _In_ SIZE_T Length ); VOID PhReferenceMemoryResult( - __in PPH_MEMORY_RESULT Result + _In_ PPH_MEMORY_RESULT Result ); VOID PhDereferenceMemoryResult( - __in PPH_MEMORY_RESULT Result + _In_ PPH_MEMORY_RESULT Result ); VOID PhDereferenceMemoryResults( - __in_ecount(NumberOfResults) PPH_MEMORY_RESULT *Results, - __in ULONG NumberOfResults + _In_reads_(NumberOfResults) PPH_MEMORY_RESULT *Results, + _In_ ULONG NumberOfResults ); #endif diff --git a/2.x/trunk/ProcessHacker/include/notifico.h b/2.x/trunk/ProcessHacker/include/notifico.h index b94ba242f..3cfd69064 100644 --- a/2.x/trunk/ProcessHacker/include/notifico.h +++ b/2.x/trunk/ProcessHacker/include/notifico.h @@ -14,16 +14,16 @@ #define PH_ICON_ALL 0xffffffff typedef VOID (NTAPI *PPH_NF_UPDATE_REGISTERED_ICON)( - __in struct _PH_NF_ICON *Icon + _In_ struct _PH_NF_ICON *Icon ); typedef VOID (NTAPI *PPH_NF_BEGIN_BITMAP)( - __out PULONG Width, - __out PULONG Height, - __out HBITMAP *Bitmap, - __out_opt PVOID *Bits, - __out HDC *Hdc, - __out HBITMAP *OldBitmap + _Out_ PULONG Width, + _Out_ PULONG Height, + _Out_ HBITMAP *Bitmap, + _Out_opt_ PVOID *Bits, + _Out_ HDC *Hdc, + _Out_ HBITMAP *OldBitmap ); typedef struct _PH_NF_POINTERS @@ -36,18 +36,18 @@ typedef struct _PH_NF_POINTERS #define PH_NF_UPDATE_DESTROY_RESOURCE 0x2 typedef VOID (NTAPI *PPH_NF_ICON_UPDATE_CALLBACK)( - __in struct _PH_NF_ICON *Icon, - __out PVOID *NewIconOrBitmap, - __out PULONG Flags, - __out PPH_STRING *NewText, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _Out_ PVOID *NewIconOrBitmap, + _Out_ PULONG Flags, + _Out_ PPH_STRING *NewText, + _In_opt_ PVOID Context ); typedef BOOLEAN (NTAPI *PPH_NF_ICON_MESSAGE_CALLBACK)( - __in struct _PH_NF_ICON *Icon, - __in ULONG_PTR WParam, - __in ULONG_PTR LParam, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam, + _In_opt_ PVOID Context ); #define PH_NF_ICON_UNAVAILABLE 0x1 @@ -83,8 +83,8 @@ VOID PhNfUninitialization( ); VOID PhNfForwardMessage( - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ); ULONG PhNfGetMaximumIconId( @@ -92,43 +92,43 @@ ULONG PhNfGetMaximumIconId( ); ULONG PhNfTestIconMask( - __in ULONG Id + _In_ ULONG Id ); VOID PhNfSetVisibleIcon( - __in ULONG Id, - __in BOOLEAN Visible + _In_ ULONG Id, + _In_ BOOLEAN Visible ); BOOLEAN PhNfShowBalloonTip( - __in_opt ULONG Id, - __in PWSTR Title, - __in PWSTR Text, - __in ULONG Timeout, - __in ULONG Flags + _In_opt_ ULONG Id, + _In_ PWSTR Title, + _In_ PWSTR Text, + _In_ ULONG Timeout, + _In_ ULONG Flags ); HICON PhNfBitmapToIcon( - __in HBITMAP Bitmap + _In_ HBITMAP Bitmap ); PPH_NF_ICON PhNfRegisterIcon( - __in struct _PH_PLUGIN *Plugin, - __in ULONG SubId, - __in_opt PVOID Context, - __in PWSTR Text, - __in ULONG Flags, - __in_opt PPH_NF_ICON_UPDATE_CALLBACK UpdateCallback, - __in_opt PPH_NF_ICON_MESSAGE_CALLBACK MessageCallback + _In_ struct _PH_PLUGIN *Plugin, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_ PWSTR Text, + _In_ ULONG Flags, + _In_opt_ PPH_NF_ICON_UPDATE_CALLBACK UpdateCallback, + _In_opt_ PPH_NF_ICON_MESSAGE_CALLBACK MessageCallback ); PPH_NF_ICON PhNfGetIconById( - __in ULONG Id + _In_ ULONG Id ); PPH_NF_ICON PhNfFindIcon( - __in PPH_STRINGREF PluginName, - __in ULONG SubId + _In_ PPH_STRINGREF PluginName, + _In_ ULONG SubId ); // Public registration data diff --git a/2.x/trunk/ProcessHacker/include/phapp.h b/2.x/trunk/ProcessHacker/include/phapp.h index 6ec89d94e..ef2fa9ec1 100644 --- a/2.x/trunk/ProcessHacker/include/phapp.h +++ b/2.x/trunk/ProcessHacker/include/phapp.h @@ -88,17 +88,17 @@ typedef struct _PH_STARTUP_PARAMETERS PHAPPAPI VOID PhRegisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ); PHAPPAPI VOID PhUnregisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ); typedef BOOLEAN (NTAPI *PPH_MESSAGE_LOOP_FILTER)( - __in PMSG Message, - __in PVOID Context + _In_ PMSG Message, + _In_ PVOID Context ); typedef struct _PH_MESSAGE_LOOP_FILTER_ENTRY @@ -109,21 +109,21 @@ typedef struct _PH_MESSAGE_LOOP_FILTER_ENTRY PHAPPAPI struct _PH_MESSAGE_LOOP_FILTER_ENTRY *PhRegisterMessageLoopFilter( - __in PPH_MESSAGE_LOOP_FILTER Filter, - __in_opt PVOID Context + _In_ PPH_MESSAGE_LOOP_FILTER Filter, + _In_opt_ PVOID Context ); PHAPPAPI VOID PhUnregisterMessageLoopFilter( - __in struct _PH_MESSAGE_LOOP_FILTER_ENTRY *FilterEntry + _In_ struct _PH_MESSAGE_LOOP_FILTER_ENTRY *FilterEntry ); VOID PhApplyUpdateInterval( - __in ULONG Interval + _In_ ULONG Interval ); VOID PhInitializeFont( - __in HWND hWnd + _In_ HWND hWnd ); // appsup @@ -132,26 +132,37 @@ extern GUID XP_CONTEXT_GUID; extern GUID VISTA_CONTEXT_GUID; extern GUID WIN7_CONTEXT_GUID; extern GUID WIN8_CONTEXT_GUID; +extern GUID WINBLUE_CONTEXT_GUID; + +typedef struct PACKAGE_ID PACKAGE_ID; PHAPPAPI BOOLEAN PhGetProcessIsSuspended( - __in PSYSTEM_PROCESS_INFORMATION Process + _In_ PSYSTEM_PROCESS_INFORMATION Process ); NTSTATUS PhGetProcessSwitchContext( - __in HANDLE ProcessHandle, - __out PGUID Guid + _In_ HANDLE ProcessHandle, + _Out_ PGUID Guid ); PPH_STRING PhGetProcessPackageFullName( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle + ); + +PACKAGE_ID *PhPackageIdFromFullName( + _In_ PWSTR PackageFullName + ); + +PPH_STRING PhGetPackagePath( + _In_ PACKAGE_ID *PackageId ); VOID PhEnumChildWindows( - __in_opt HWND hWnd, - __in ULONG Limit, - __in WNDENUMPROC Callback, - __in LPARAM lParam + _In_opt_ HWND hWnd, + _In_ ULONG Limit, + _In_ WNDENUMPROC Callback, + _In_ LPARAM lParam ); typedef enum _PH_KNOWN_PROCESS_TYPE @@ -178,8 +189,8 @@ typedef enum _PH_KNOWN_PROCESS_TYPE PHAPPAPI NTSTATUS PhGetProcessKnownType( - __in HANDLE ProcessHandle, - __out PH_KNOWN_PROCESS_TYPE *KnownProcessType + _In_ HANDLE ProcessHandle, + _Out_ PH_KNOWN_PROCESS_TYPE *KnownProcessType ); typedef union _PH_KNOWN_PROCESS_COMMAND_LINE @@ -203,45 +214,45 @@ typedef union _PH_KNOWN_PROCESS_COMMAND_LINE PHAPPAPI BOOLEAN PhaGetProcessKnownCommandLine( - __in PPH_STRING CommandLine, - __in PH_KNOWN_PROCESS_TYPE KnownProcessType, - __out PPH_KNOWN_PROCESS_COMMAND_LINE KnownCommandLine + _In_ PPH_STRING CommandLine, + _In_ PH_KNOWN_PROCESS_TYPE KnownProcessType, + _Out_ PPH_KNOWN_PROCESS_COMMAND_LINE KnownCommandLine ); PPH_STRING PhEscapeStringForDelimiter( - __in PPH_STRING String, - __in WCHAR Delimiter + _In_ PPH_STRING String, + _In_ WCHAR Delimiter ); PPH_STRING PhUnescapeStringForDelimiter( - __in PPH_STRING String, - __in WCHAR Delimiter + _In_ PPH_STRING String, + _In_ WCHAR Delimiter ); typedef struct mxml_node_s mxml_node_t; PPH_STRING PhGetOpaqueXmlNodeText( - __in mxml_node_t *node + _In_ mxml_node_t *node ); PHAPPAPI VOID PhSearchOnlineString( - __in HWND hWnd, - __in PWSTR String + _In_ HWND hWnd, + _In_ PWSTR String ); PHAPPAPI VOID PhShellExecuteUserString( - __in HWND hWnd, - __in PWSTR Setting, - __in PWSTR String, - __in BOOLEAN UseShellExecute, - __in_opt PWSTR ErrorMessage + _In_ HWND hWnd, + _In_ PWSTR Setting, + _In_ PWSTR String, + _In_ BOOLEAN UseShellExecute, + _In_opt_ PWSTR ErrorMessage ); PHAPPAPI VOID PhLoadSymbolProviderOptions( - __inout PPH_SYMBOL_PROVIDER SymbolProvider + _Inout_ PPH_SYMBOL_PROVIDER SymbolProvider ); PWSTR PhMakeContextAtom( @@ -250,19 +261,19 @@ PWSTR PhMakeContextAtom( PHAPPAPI VOID PhCopyListViewInfoTip( - __inout LPNMLVGETINFOTIP GetInfoTip, - __in PPH_STRINGREF Tip + _Inout_ LPNMLVGETINFOTIP GetInfoTip, + _In_ PPH_STRINGREF Tip ); PHAPPAPI VOID PhCopyListView( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ); PHAPPAPI VOID PhHandleListViewNotifyForCopy( - __in LPARAM lParam, - __in HWND ListViewHandle + _In_ LPARAM lParam, + _In_ HWND ListViewHandle ); #define PH_LIST_VIEW_CTRL_C_BEHAVIOR 0x1 @@ -270,46 +281,46 @@ VOID PhHandleListViewNotifyForCopy( #define PH_LIST_VIEW_DEFAULT_1_BEHAVIORS (PH_LIST_VIEW_CTRL_C_BEHAVIOR | PH_LIST_VIEW_CTRL_A_BEHAVIOR) VOID PhHandleListViewNotifyBehaviors( - __in LPARAM lParam, - __in HWND ListViewHandle, - __in ULONG Behaviors + _In_ LPARAM lParam, + _In_ HWND ListViewHandle, + _In_ ULONG Behaviors ); PHAPPAPI BOOLEAN PhGetListViewContextMenuPoint( - __in HWND ListViewHandle, - __out PPOINT Point + _In_ HWND ListViewHandle, + _Out_ PPOINT Point ); HFONT PhDuplicateFontWithNewWeight( - __in HFONT Font, - __in LONG NewWeight + _In_ HFONT Font, + _In_ LONG NewWeight ); PHAPPAPI VOID PhLoadWindowPlacementFromSetting( - __in_opt PWSTR PositionSettingName, - __in_opt PWSTR SizeSettingName, - __in HWND WindowHandle + _In_opt_ PWSTR PositionSettingName, + _In_opt_ PWSTR SizeSettingName, + _In_ HWND WindowHandle ); PHAPPAPI VOID PhSaveWindowPlacementToSetting( - __in_opt PWSTR PositionSettingName, - __in_opt PWSTR SizeSettingName, - __in HWND WindowHandle + _In_opt_ PWSTR PositionSettingName, + _In_opt_ PWSTR SizeSettingName, + _In_ HWND WindowHandle ); PHAPPAPI VOID PhLoadListViewColumnsFromSetting( - __in PWSTR Name, - __in HWND ListViewHandle + _In_ PWSTR Name, + _In_ HWND ListViewHandle ); PHAPPAPI VOID PhSaveListViewColumnsToSetting( - __in PWSTR Name, - __in HWND ListViewHandle + _In_ PWSTR Name, + _In_ HWND ListViewHandle ); PHAPPAPI @@ -319,15 +330,15 @@ PPH_STRING PhGetPhVersion( PHAPPAPI VOID PhGetPhVersionNumbers( - __out_opt PULONG MajorVersion, - __out_opt PULONG MinorVersion, - __reserved PULONG Reserved, - __out_opt PULONG RevisionNumber + _Out_opt_ PULONG MajorVersion, + _Out_opt_ PULONG MinorVersion, + _Reserved_ PULONG Reserved, + _Out_opt_ PULONG RevisionNumber ); PHAPPAPI VOID PhWritePhTextHeader( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ); #define PH_SHELL_APP_PROPAGATE_PARAMETERS 0x1 @@ -335,17 +346,17 @@ VOID PhWritePhTextHeader( #define PH_SHELL_APP_PROPAGATE_PARAMETERS_FORCE_SETTINGS 0x4 BOOLEAN PhShellProcessHacker( - __in HWND hWnd, - __in_opt PWSTR Parameters, - __in ULONG ShowWindowType, - __in ULONG Flags, - __in ULONG AppFlags, - __in_opt ULONG Timeout, - __out_opt PHANDLE ProcessHandle + _In_ HWND hWnd, + _In_opt_ PWSTR Parameters, + _In_ ULONG ShowWindowType, + _In_ ULONG Flags, + _In_ ULONG AppFlags, + _In_opt_ ULONG Timeout, + _Out_opt_ PHANDLE ProcessHandle ); BOOLEAN PhCreateProcessIgnoreIfeoDebugger( - __in PWSTR FileName + _In_ PWSTR FileName ); typedef struct _PH_TN_COLUMN_MENU_DATA @@ -367,24 +378,24 @@ typedef struct _PH_TN_COLUMN_MENU_DATA PHAPPAPI VOID PhInitializeTreeNewColumnMenu( - __inout PPH_TN_COLUMN_MENU_DATA Data + _Inout_ PPH_TN_COLUMN_MENU_DATA Data ); #define PH_TN_COLUMN_MENU_NO_VISIBILITY 0x1 VOID PhInitializeTreeNewColumnMenuEx( - __inout PPH_TN_COLUMN_MENU_DATA Data, - __in ULONG Flags + _Inout_ PPH_TN_COLUMN_MENU_DATA Data, + _In_ ULONG Flags ); PHAPPAPI BOOLEAN PhHandleTreeNewColumnMenu( - __inout PPH_TN_COLUMN_MENU_DATA Data + _Inout_ PPH_TN_COLUMN_MENU_DATA Data ); PHAPPAPI VOID PhDeleteTreeNewColumnMenu( - __in PPH_TN_COLUMN_MENU_DATA Data + _In_ PPH_TN_COLUMN_MENU_DATA Data ); typedef struct _PH_TN_FILTER_SUPPORT @@ -395,8 +406,8 @@ typedef struct _PH_TN_FILTER_SUPPORT } PH_TN_FILTER_SUPPORT, *PPH_TN_FILTER_SUPPORT; typedef BOOLEAN (NTAPI *PPH_TN_FILTER_FUNCTION)( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); typedef struct _PH_TN_FILTER_ENTRY @@ -406,36 +417,36 @@ typedef struct _PH_TN_FILTER_ENTRY } PH_TN_FILTER_ENTRY, *PPH_TN_FILTER_ENTRY; VOID PhInitializeTreeNewFilterSupport( - __out PPH_TN_FILTER_SUPPORT Support, - __in HWND TreeNewHandle, - __in PPH_LIST NodeList + _Out_ PPH_TN_FILTER_SUPPORT Support, + _In_ HWND TreeNewHandle, + _In_ PPH_LIST NodeList ); VOID PhDeleteTreeNewFilterSupport( - __in PPH_TN_FILTER_SUPPORT Support + _In_ PPH_TN_FILTER_SUPPORT Support ); PHAPPAPI PPH_TN_FILTER_ENTRY PhAddTreeNewFilter( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TN_FILTER_FUNCTION Filter, - __in_opt PVOID Context + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TN_FILTER_FUNCTION Filter, + _In_opt_ PVOID Context ); PHAPPAPI VOID PhRemoveTreeNewFilter( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TN_FILTER_ENTRY Entry + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TN_FILTER_ENTRY Entry ); BOOLEAN PhApplyTreeNewFiltersToNode( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TREENEW_NODE Node + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TREENEW_NODE Node ); PHAPPAPI VOID PhApplyTreeNewFilters( - __in PPH_TN_FILTER_SUPPORT Support + _In_ PPH_TN_FILTER_SUPPORT Support ); typedef struct _PH_COPY_CELL_CONTEXT @@ -446,24 +457,29 @@ typedef struct _PH_COPY_CELL_CONTEXT } PH_COPY_CELL_CONTEXT, *PPH_COPY_CELL_CONTEXT; BOOLEAN PhInsertCopyCellEMenuItem( - __in struct _PH_EMENU_ITEM *Menu, - __in ULONG InsertAfterId, - __in HWND TreeNewHandle, - __in PPH_TREENEW_COLUMN Column + _In_ struct _PH_EMENU_ITEM *Menu, + _In_ ULONG InsertAfterId, + _In_ HWND TreeNewHandle, + _In_ PPH_TREENEW_COLUMN Column ); BOOLEAN PhHandleCopyCellEMenuItem( - __in struct _PH_EMENU_ITEM *SelectedItem + _In_ struct _PH_EMENU_ITEM *SelectedItem + ); + +BOOLEAN PhShellOpenKey2( + _In_ HWND hWnd, + _In_ PPH_STRING KeyName ); #define PH_LOAD_SHARED_IMAGE(Name, Type) LoadImage(PhInstanceHandle, (Name), (Type), 0, 0, LR_SHARED) FORCEINLINE PVOID PhpGenericPropertyPageHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __in PWSTR ContextName + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ PWSTR ContextName ) { PVOID context; @@ -559,8 +575,8 @@ extern BOOLEAN PhMainWndExiting; SendMessage(hWnd, WM_PH_PREPARE_FOR_EARLY_SHUTDOWN, 0, 0) #define ProcessHacker_CancelEarlyShutdown(hWnd) \ SendMessage(hWnd, WM_PH_CANCEL_EARLY_SHUTDOWN, 0, 0) -#define ProcessHacker_ToggleVisible(hWnd) \ - SendMessage(hWnd, WM_PH_TOGGLE_VISIBLE, 0, 0) +#define ProcessHacker_ToggleVisible(hWnd, AlwaysShow) \ + SendMessage(hWnd, WM_PH_TOGGLE_VISIBLE, (WPARAM)(AlwaysShow), 0) #define ProcessHacker_ShowMemoryEditor(hWnd, ShowMemoryEditor) \ PostMessage(hWnd, WM_PH_SHOW_MEMORY_EDITOR, 0, (LPARAM)(ShowMemoryEditor)) #define ProcessHacker_ShowMemoryResults(hWnd, ShowMemoryResults) \ @@ -614,24 +630,24 @@ typedef struct _PH_LAYOUT_PADDING_DATA typedef struct _PH_ADDMENUITEM { - __in PVOID Plugin; - __in ULONG Location; - __in_opt PWSTR InsertAfter; - __in ULONG Flags; - __in ULONG Id; - __in PWSTR Text; - __in_opt PVOID Context; + _In_ PVOID Plugin; + _In_ ULONG Location; + _In_opt_ PWSTR InsertAfter; + _In_ ULONG Flags; + _In_ ULONG Id; + _In_ PWSTR Text; + _In_opt_ PVOID Context; } PH_ADDMENUITEM, *PPH_ADDMENUITEM; typedef HWND (NTAPI *PPH_TAB_PAGE_CREATE_FUNCTION)( - __in PVOID Context + _In_ PVOID Context ); typedef VOID (NTAPI *PPH_TAB_PAGE_CALLBACK_FUNCTION)( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ); typedef struct _PH_ADDITIONAL_TAB_PAGE @@ -659,30 +675,30 @@ typedef struct _PH_ADDITIONAL_TAB_PAGE #define PH_NOTIFY_VALID_MASK 0x3f BOOLEAN PhMainWndInitialization( - __in INT ShowCommand + _In_ INT ShowCommand ); VOID PhShowIconContextMenu( - __in POINT Location + _In_ POINT Location ); PHAPPAPI VOID PhShowIconNotification( - __in PWSTR Title, - __in PWSTR Text, - __in ULONG Flags + _In_ PWSTR Title, + _In_ PWSTR Text, + _In_ ULONG Flags ); VOID PhShowProcessContextMenu( - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ); VOID PhShowServiceContextMenu( - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ); VOID PhShowNetworkContextMenu( - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ); // plugin @@ -694,12 +710,12 @@ VOID PhPluginsInitialization( ); BOOLEAN PhIsPluginDisabled( - __in PPH_STRINGREF BaseName + _In_ PPH_STRINGREF BaseName ); VOID PhSetPluginDisabled( - __in PPH_STRINGREF BaseName, - __in BOOLEAN Disable + _In_ PPH_STRINGREF BaseName, + _In_ BOOLEAN Disable ); VOID PhLoadPlugins( @@ -757,80 +773,80 @@ BOOLEAN PhProcessPropInitialization( PHAPPAPI PPH_PROCESS_PROPCONTEXT PhCreateProcessPropContext( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); VOID PhRefreshProcessPropContext( - __inout PPH_PROCESS_PROPCONTEXT PropContext + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext ); PHAPPAPI VOID PhSetSelectThreadIdProcessPropContext( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in HANDLE ThreadId + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ HANDLE ThreadId ); PHAPPAPI BOOLEAN PhAddProcessPropPage( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in __assumeRefs(1) PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ _Assume_refs_(1) PPH_PROCESS_PROPPAGECONTEXT PropPageContext ); PHAPPAPI BOOLEAN PhAddProcessPropPage2( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in HPROPSHEETPAGE PropSheetPageHandle + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ HPROPSHEETPAGE PropSheetPageHandle ); PHAPPAPI PPH_PROCESS_PROPPAGECONTEXT PhCreateProcessPropPageContext( - __in LPCWSTR Template, - __in DLGPROC DlgProc, - __in_opt PVOID Context + _In_ LPCWSTR Template, + _In_ DLGPROC DlgProc, + _In_opt_ PVOID Context ); PHAPPAPI PPH_PROCESS_PROPPAGECONTEXT PhCreateProcessPropPageContextEx( - __in_opt PVOID InstanceHandle, - __in LPCWSTR Template, - __in DLGPROC DlgProc, - __in_opt PVOID Context + _In_opt_ PVOID InstanceHandle, + _In_ LPCWSTR Template, + _In_ DLGPROC DlgProc, + _In_opt_ PVOID Context ); PHAPPAPI BOOLEAN PhPropPageDlgProcHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam, - __out LPPROPSHEETPAGE *PropSheetPage, - __out PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, - __out PPH_PROCESS_ITEM *ProcessItem + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam, + _Out_ LPPROPSHEETPAGE *PropSheetPage, + _Out_ PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, + _Out_ PPH_PROCESS_ITEM *ProcessItem ); PHAPPAPI VOID PhPropPageDlgProcDestroy( - __in HWND hwndDlg + _In_ HWND hwndDlg ); #define PH_PROP_PAGE_TAB_CONTROL_PARENT ((PPH_LAYOUT_ITEM)0x1) PHAPPAPI PPH_LAYOUT_ITEM PhAddPropPageLayoutItem( - __in HWND hwnd, - __in HWND Handle, - __in PPH_LAYOUT_ITEM ParentItem, - __in ULONG Anchor + _In_ HWND hwnd, + _In_ HWND Handle, + _In_ PPH_LAYOUT_ITEM ParentItem, + _In_ ULONG Anchor ); PHAPPAPI VOID PhDoPropPageLayout( - __in HWND hwnd + _In_ HWND hwnd ); FORCEINLINE PPH_LAYOUT_ITEM PhBeginPropPageLayout( - __in HWND hwndDlg, - __in PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_PROPPAGECONTEXT PropPageContext ) { if (!PropPageContext->LayoutInitialized) @@ -845,8 +861,8 @@ FORCEINLINE PPH_LAYOUT_ITEM PhBeginPropPageLayout( } FORCEINLINE VOID PhEndPropPageLayout( - __in HWND hwndDlg, - __in PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_PROPPAGECONTEXT PropPageContext ) { PhDoPropPageLayout(hwndDlg); @@ -855,7 +871,7 @@ FORCEINLINE VOID PhEndPropPageLayout( PHAPPAPI BOOLEAN PhShowProcessProperties( - __in PPH_PROCESS_PROPCONTEXT Context + _In_ PPH_PROCESS_PROPCONTEXT Context ); // sysinfo @@ -867,9 +883,9 @@ typedef enum _PH_SYSINFO_VIEW_TYPE } PH_SYSINFO_VIEW_TYPE; typedef VOID (NTAPI *PPH_SYSINFO_COLOR_SETUP_FUNCTION)( - __out PPH_GRAPH_DRAW_INFO DrawInfo, - __in COLORREF Color1, - __in COLORREF Color2 + _Out_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ COLORREF Color1, + _In_ COLORREF Color2 ); typedef struct _PH_SYSINFO_PARAMETERS @@ -907,10 +923,10 @@ typedef enum _PH_SYSINFO_SECTION_MESSAGE } PH_SYSINFO_SECTION_MESSAGE; typedef BOOLEAN (NTAPI *PPH_SYSINFO_SECTION_CALLBACK)( - __in struct _PH_SYSINFO_SECTION *Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ struct _PH_SYSINFO_SECTION *Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); typedef struct _PH_SYSINFO_CREATE_DIALOG @@ -980,14 +996,15 @@ VOID PhSiNotifyChangeSettings( VOID ); +PHAPPAPI VOID PhSiSetColorsGraphDrawInfo( - __out PPH_GRAPH_DRAW_INFO DrawInfo, - __in COLORREF Color1, - __in COLORREF Color2 + _Out_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ COLORREF Color1, + _In_ COLORREF Color2 ); VOID PhShowSystemInformationDialog( - __in_opt PWSTR SectionName + _In_opt_ PWSTR SectionName ); // log @@ -1047,28 +1064,28 @@ VOID PhClearLogEntries( ); VOID PhLogProcessEntry( - __in UCHAR Type, - __in HANDLE ProcessId, - __in PPH_STRING Name, - __in_opt HANDLE ParentProcessId, - __in_opt PPH_STRING ParentName + _In_ UCHAR Type, + _In_ HANDLE ProcessId, + _In_ PPH_STRING Name, + _In_opt_ HANDLE ParentProcessId, + _In_opt_ PPH_STRING ParentName ); VOID PhLogServiceEntry( - __in UCHAR Type, - __in PPH_STRING Name, - __in PPH_STRING DisplayName + _In_ UCHAR Type, + _In_ PPH_STRING Name, + _In_ PPH_STRING DisplayName ); PHAPPAPI VOID PhLogMessageEntry( - __in UCHAR Type, - __in PPH_STRING Message + _In_ UCHAR Type, + _In_ PPH_STRING Message ); PHAPPAPI PPH_STRING PhFormatLogEntry( - __in PPH_LOG_ENTRY Entry + _In_ PPH_LOG_ENTRY Entry ); // dbgcon @@ -1087,8 +1104,8 @@ typedef enum _PH_ACTION_ELEVATION_LEVEL } PH_ACTION_ELEVATION_LEVEL; BOOLEAN PhUiConnectToPhSvc( - __in HWND hWnd, - __in BOOLEAN ConnectOnly + _In_ HWND hWnd, + _In_ BOOLEAN ConnectOnly ); VOID PhUiDisconnectFromPhSvc( @@ -1097,280 +1114,280 @@ VOID PhUiDisconnectFromPhSvc( PHAPPAPI BOOLEAN PhUiLockComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN PhUiLogoffComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN PhUiSleepComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN PhUiHibernateComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN PhUiRestartComputer( - __in HWND hWnd, - __in ULONG Flags + _In_ HWND hWnd, + _In_ ULONG Flags ); PHAPPAPI BOOLEAN PhUiShutdownComputer( - __in HWND hWnd, - __in ULONG Flags + _In_ HWND hWnd, + _In_ ULONG Flags ); PHAPPAPI BOOLEAN PhUiConnectSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ); PHAPPAPI BOOLEAN PhUiDisconnectSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ); PHAPPAPI BOOLEAN PhUiLogoffSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ); PHAPPAPI BOOLEAN PhUiTerminateProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN PhUiTerminateTreeProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN PhUiSuspendProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN PhUiResumeProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN PhUiRestartProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN PhUiDebugProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN PhUiReduceWorkingSetProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN PhUiSetVirtualizationProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in BOOLEAN Enable + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ BOOLEAN Enable ); PHAPPAPI BOOLEAN PhUiDetachFromDebuggerProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN PhUiInjectDllProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN PhUiSetIoPriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG IoPriority + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG IoPriority ); PHAPPAPI BOOLEAN PhUiSetPagePriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG PagePriority + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG PagePriority ); PHAPPAPI BOOLEAN PhUiSetPriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG PriorityClass + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG PriorityClass ); PHAPPAPI BOOLEAN PhUiSetDepStatusProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN PhUiStartService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN PhUiContinueService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN PhUiPauseService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN PhUiStopService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN PhUiDeleteService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN PhUiCloseConnections( - __in HWND hWnd, - __in PPH_NETWORK_ITEM *Connections, - __in ULONG NumberOfConnections + _In_ HWND hWnd, + _In_ PPH_NETWORK_ITEM *Connections, + _In_ ULONG NumberOfConnections ); PHAPPAPI BOOLEAN PhUiTerminateThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN PhUiForceTerminateThreads( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN PhUiSuspendThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN PhUiResumeThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN PhUiSetPriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG ThreadPriorityWin32 + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG ThreadPriorityWin32 ); PHAPPAPI BOOLEAN PhUiSetIoPriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG IoPriority + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG IoPriority ); PHAPPAPI BOOLEAN PhUiSetPagePriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG PagePriority + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG PagePriority ); PHAPPAPI BOOLEAN PhUiUnloadModule( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_MODULE_ITEM Module + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_MODULE_ITEM Module ); PHAPPAPI BOOLEAN PhUiFreeMemory( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_MEMORY_ITEM MemoryItem, - __in BOOLEAN Free + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_MEMORY_ITEM MemoryItem, + _In_ BOOLEAN Free ); PHAPPAPI BOOLEAN PhUiCloseHandles( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM *Handles, - __in ULONG NumberOfHandles, - __in BOOLEAN Warn + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM *Handles, + _In_ ULONG NumberOfHandles, + _In_ BOOLEAN Warn ); PHAPPAPI BOOLEAN PhUiSetAttributesHandle( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM Handle, - __in ULONG Attributes + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM Handle, + _In_ ULONG Attributes ); PHAPPAPI BOOLEAN PhUiDestroyHeap( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PVOID HeapHandle + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PVOID HeapHandle ); // itemtips PPH_STRING PhGetProcessTooltipText( - __in PPH_PROCESS_ITEM Process + _In_ PPH_PROCESS_ITEM Process ); PPH_STRING PhGetServiceTooltipText( - __in PPH_SERVICE_ITEM Service + _In_ PPH_SERVICE_ITEM Service ); // cmdmode @@ -1382,23 +1399,23 @@ NTSTATUS PhCommandModeStart( // anawait VOID PhUiAnalyzeWaitThread( - __in HWND hWnd, - __in HANDLE ProcessId, - __in HANDLE ThreadId, - __in PPH_SYMBOL_PROVIDER SymbolProvider + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ HANDLE ThreadId, + _In_ PPH_SYMBOL_PROVIDER SymbolProvider ); // mdump BOOLEAN PhUiCreateDumpFileProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); // about VOID PhShowAboutDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ); PPH_STRING PhGetDiagnosticsString( @@ -1408,16 +1425,16 @@ PPH_STRING PhGetDiagnosticsString( // affinity VOID PhShowProcessAffinityDialog( - __in HWND ParentWindowHandle, - __in_opt PPH_PROCESS_ITEM ProcessItem, - __in_opt PPH_THREAD_ITEM ThreadItem + _In_ HWND ParentWindowHandle, + _In_opt_ PPH_PROCESS_ITEM ProcessItem, + _In_opt_ PPH_THREAD_ITEM ThreadItem ); PHAPPAPI BOOLEAN PhShowProcessAffinityDialog2( - __in HWND ParentWindowHandle, - __in ULONG_PTR AffinityMask, - __out PULONG_PTR NewAffinityMask + _In_ HWND ParentWindowHandle, + _In_ ULONG_PTR AffinityMask, + _Out_ PULONG_PTR NewAffinityMask ); // chcol @@ -1425,9 +1442,9 @@ BOOLEAN PhShowProcessAffinityDialog2( #define PH_CONTROL_TYPE_TREE_NEW 1 VOID PhShowChooseColumnsDialog( - __in HWND ParentWindowHandle, - __in HWND ControlHandle, - __in ULONG Type + _In_ HWND ParentWindowHandle, + _In_ HWND ControlHandle, + _In_ ULONG Type ); // chdlg @@ -1441,25 +1458,25 @@ VOID PhShowChooseColumnsDialog( PHAPPAPI BOOLEAN PhaChoiceDialog( - __in HWND ParentWindowHandle, - __in PWSTR Title, - __in PWSTR Message, - __in_opt PWSTR *Choices, - __in_opt ULONG NumberOfChoices, - __in_opt PWSTR Option, - __in ULONG Flags, - __inout PPH_STRING *SelectedChoice, - __inout_opt PBOOLEAN SelectedOption, - __in_opt PWSTR SavedChoicesSettingName + _In_ HWND ParentWindowHandle, + _In_ PWSTR Title, + _In_ PWSTR Message, + _In_opt_ PWSTR *Choices, + _In_opt_ ULONG NumberOfChoices, + _In_opt_ PWSTR Option, + _In_ ULONG Flags, + _Inout_ PPH_STRING *SelectedChoice, + _Inout_opt_ PBOOLEAN SelectedOption, + _In_opt_ PWSTR SavedChoicesSettingName ); // chproc PHAPPAPI BOOLEAN PhShowChooseProcessDialog( - __in HWND ParentWindowHandle, - __in PWSTR Message, - __out PHANDLE ProcessId + _In_ HWND ParentWindowHandle, + _In_ PWSTR Message, + _Out_ PHANDLE ProcessId ); // findobj @@ -1471,20 +1488,20 @@ VOID PhShowFindObjectsDialog( // gdihndl VOID PhShowGdiHandlesDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); // heapinfo VOID PhShowProcessHeapsDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); NTSTATUS PhGetProcessDefaultHeap( - __in HANDLE ProcessHandle, - __out PPVOID Heap + _In_ HANDLE ProcessHandle, + _Out_ PPVOID Heap ); // hidnproc @@ -1496,38 +1513,38 @@ VOID PhShowHiddenProcessesDialog( // hndlprp VOID PhShowHandleProperties( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM HandleItem + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM HandleItem ); // hndlstat VOID PhShowHandleStatisticsDialog( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId ); // infodlg VOID PhShowInformationDialog( - __in HWND ParentWindowHandle, - __in PWSTR String + _In_ HWND ParentWindowHandle, + _In_ PWSTR String ); // jobprp VOID PhShowJobProperties( - __in HWND ParentWindowHandle, - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt PWSTR Title + _In_ HWND ParentWindowHandle, + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ PWSTR Title ); HPROPSHEETPAGE PhCreateJobPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt DLGPROC HookProc + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ DLGPROC HookProc ); // logwnd @@ -1539,106 +1556,106 @@ VOID PhShowLogDialog( // memedit VOID PhShowMemoryEditorDialog( - __in HANDLE ProcessId, - __in PVOID BaseAddress, - __in SIZE_T RegionSize, - __in ULONG SelectOffset, - __in ULONG SelectLength + _In_ HANDLE ProcessId, + _In_ PVOID BaseAddress, + _In_ SIZE_T RegionSize, + _In_ ULONG SelectOffset, + _In_ ULONG SelectLength ); // memlists VOID PhShowMemoryListsDialog( - __in HWND ParentWindowHandle, - __in_opt VOID (NTAPI *RegisterDialog)(HWND), - __in_opt VOID (NTAPI *UnregisterDialog)(HWND) + _In_ HWND ParentWindowHandle, + _In_opt_ VOID (NTAPI *RegisterDialog)(HWND), + _In_opt_ VOID (NTAPI *UnregisterDialog)(HWND) ); // memprot VOID PhShowMemoryProtectDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_MEMORY_ITEM MemoryItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_MEMORY_ITEM MemoryItem ); // memrslt VOID PhShowMemoryResultsDialog( - __in HANDLE ProcessId, - __in PPH_LIST Results + _In_ HANDLE ProcessId, + _In_ PPH_LIST Results ); // memsrch VOID PhShowMemoryStringDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); // netstk VOID PhShowNetworkStackDialog( - __in HWND ParentWindowHandle, - __in PPH_NETWORK_ITEM NetworkItem + _In_ HWND ParentWindowHandle, + _In_ PPH_NETWORK_ITEM NetworkItem ); // ntobjprp HPROPSHEETPAGE PhCreateEventPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ); HPROPSHEETPAGE PhCreateEventPairPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ); HPROPSHEETPAGE PhCreateMutantPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ); HPROPSHEETPAGE PhCreateSectionPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ); HPROPSHEETPAGE PhCreateSemaphorePage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ); HPROPSHEETPAGE PhCreateTimerPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ); // options VOID PhShowOptionsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ); // pagfiles VOID PhShowPagefilesDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ); // plugman VOID PhShowPluginsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ); // procrec PHAPPAPI VOID PhShowProcessRecordDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_RECORD Record + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_RECORD Record ); // runas @@ -1659,59 +1676,59 @@ typedef struct _PH_RUNAS_SERVICE_PARAMETERS } PH_RUNAS_SERVICE_PARAMETERS, *PPH_RUNAS_SERVICE_PARAMETERS; VOID PhShowRunAsDialog( - __in HWND ParentWindowHandle, - __in_opt HANDLE ProcessId + _In_ HWND ParentWindowHandle, + _In_opt_ HANDLE ProcessId ); NTSTATUS PhExecuteRunAsCommand( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ); NTSTATUS PhExecuteRunAsCommand2( - __in HWND hWnd, - __in PWSTR Program, - __in_opt PWSTR UserName, - __in_opt PWSTR Password, - __in_opt ULONG LogonType, - __in_opt HANDLE ProcessIdWithToken, - __in ULONG SessionId, - __in PWSTR DesktopName, - __in BOOLEAN UseLinkedToken + _In_ HWND hWnd, + _In_ PWSTR Program, + _In_opt_ PWSTR UserName, + _In_opt_ PWSTR Password, + _In_opt_ ULONG LogonType, + _In_opt_ HANDLE ProcessIdWithToken, + _In_ ULONG SessionId, + _In_ PWSTR DesktopName, + _In_ BOOLEAN UseLinkedToken ); NTSTATUS PhRunAsServiceStart( - __in PPH_STRING ServiceName + _In_ PPH_STRING ServiceName ); NTSTATUS PhInvokeRunAsService( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ); // sessmsg VOID PhShowSessionSendMessageDialog( - __in HWND ParentWindowHandle, - __in ULONG SessionId + _In_ HWND ParentWindowHandle, + _In_ ULONG SessionId ); // sessprp VOID PhShowSessionProperties( - __in HWND ParentWindowHandle, - __in ULONG SessionId + _In_ HWND ParentWindowHandle, + _In_ ULONG SessionId ); // sessshad VOID PhShowSessionShadowDialog( - __in HWND ParentWindowHandle, - __in ULONG SessionId + _In_ HWND ParentWindowHandle, + _In_ ULONG SessionId ); // srvcr VOID PhShowCreateServiceDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ); // srvctl @@ -1720,55 +1737,55 @@ VOID PhShowCreateServiceDialog( PHAPPAPI HWND PhCreateServiceListControl( - __in HWND ParentWindowHandle, - __in PPH_SERVICE_ITEM *Services, - __in ULONG NumberOfServices + _In_ HWND ParentWindowHandle, + _In_ PPH_SERVICE_ITEM *Services, + _In_ ULONG NumberOfServices ); // srvprp VOID PhShowServiceProperties( - __in HWND ParentWindowHandle, - __in PPH_SERVICE_ITEM ServiceItem + _In_ HWND ParentWindowHandle, + _In_ PPH_SERVICE_ITEM ServiceItem ); // termator VOID PhShowProcessTerminatorDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); // thrdstk VOID PhShowThreadStackDialog( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId, - __in HANDLE ThreadId, - __in PPH_SYMBOL_PROVIDER SymbolProvider + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId, + _In_ HANDLE ThreadId, + _In_ PPH_SYMBOL_PROVIDER SymbolProvider ); // tokprp PPH_STRING PhGetGroupAttributesString( - __in ULONG Attributes + _In_ ULONG Attributes ); PWSTR PhGetPrivilegeAttributesString( - __in ULONG Attributes + _In_ ULONG Attributes ); VOID PhShowTokenProperties( - __in HWND ParentWindowHandle, - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt PWSTR Title + _In_ HWND ParentWindowHandle, + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ PWSTR Title ); HPROPSHEETPAGE PhCreateTokenPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt DLGPROC HookProc + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ DLGPROC HookProc ); #endif diff --git a/2.x/trunk/ProcessHacker/include/phappres.h b/2.x/trunk/ProcessHacker/include/phappres.h index a42d267e8..7e42dc9cc 100644 --- a/2.x/trunk/ProcessHacker/include/phappres.h +++ b/2.x/trunk/ProcessHacker/include/phappres.h @@ -7,7 +7,7 @@ #include "phapprev.h" #define PHAPP_VERSION_MAJOR 2 -#define PHAPP_VERSION_MINOR 32 +#define PHAPP_VERSION_MINOR 34 #define PHAPP_VERSION_BUILD 0 #if (PHAPP_VERSION_BUILD == 0) diff --git a/2.x/trunk/ProcessHacker/include/phplug.h b/2.x/trunk/ProcessHacker/include/phplug.h index 9217ee8ad..3a27cb06f 100644 --- a/2.x/trunk/ProcessHacker/include/phplug.h +++ b/2.x/trunk/ProcessHacker/include/phplug.h @@ -210,15 +210,15 @@ typedef struct _PH_PLUGIN_THREAD_STACK_CONTROL } PH_PLUGIN_THREAD_STACK_CONTROL, *PPH_PLUGIN_THREAD_STACK_CONTROL; typedef PPH_SYSINFO_SECTION (NTAPI *PPH_SYSINFO_CREATE_SECTION)( - __in PPH_SYSINFO_SECTION Template + _In_ PPH_SYSINFO_SECTION Template ); typedef PPH_SYSINFO_SECTION (NTAPI *PPH_SYSINFO_FIND_SECTION)( - __in PPH_STRINGREF Name + _In_ PPH_STRINGREF Name ); typedef VOID (NTAPI *PPH_SYSINFO_ENTER_SECTION_VIEW)( - __in PPH_SYSINFO_SECTION NewSection + _In_ PPH_SYSINFO_SECTION NewSection ); typedef VOID (NTAPI *PPH_SYSINFO_RESTORE_SUMMARY_VIEW)( @@ -245,10 +245,10 @@ typedef struct _PH_PLUGIN_TREENEW_MESSAGE } PH_PLUGIN_TREENEW_MESSAGE, *PPH_PLUGIN_TREENEW_MESSAGE; typedef LONG (NTAPI *PPH_PLUGIN_TREENEW_SORT_FUNCTION)( - __in PVOID Node1, - __in PVOID Node2, - __in ULONG SubId, - __in PVOID Context + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ ULONG SubId, + _In_ PVOID Context ); typedef enum _PH_PLUGIN_CALLBACK @@ -272,7 +272,7 @@ typedef struct _PH_PLUGIN_INFORMATION BOOLEAN Reserved1[3]; } PH_PLUGIN_INFORMATION, *PPH_PLUGIN_INFORMATION; -#define PH_PLUGIN_FLAG_IS_CLR 0x1 // plugin is .NET +#define PH_PLUGIN_FLAG_RESERVED 0x1 typedef struct _PH_PLUGIN { @@ -293,42 +293,42 @@ PHAPPAPI PPH_PLUGIN NTAPI PhRegisterPlugin( - __in PWSTR Name, - __in PVOID DllBase, - __out_opt PPH_PLUGIN_INFORMATION *Information + _In_ PWSTR Name, + _In_ PVOID DllBase, + _Out_opt_ PPH_PLUGIN_INFORMATION *Information ); PHAPPAPI PPH_PLUGIN NTAPI PhFindPlugin( - __in PWSTR Name + _In_ PWSTR Name ); PHAPPAPI PPH_CALLBACK NTAPI PhGetPluginCallback( - __in PPH_PLUGIN Plugin, - __in PH_PLUGIN_CALLBACK Callback + _In_ PPH_PLUGIN Plugin, + _In_ PH_PLUGIN_CALLBACK Callback ); PHAPPAPI PPH_CALLBACK NTAPI PhGetGeneralCallback( - __in PH_GENERAL_CALLBACK Callback + _In_ PH_GENERAL_CALLBACK Callback ); PHAPPAPI ULONG NTAPI PhPluginReserveIds( - __in ULONG Count + _In_ ULONG Count ); typedef VOID (NTAPI *PPH_PLUGIN_MENU_ITEM_DELETE_FUNCTION)( - __in struct _PH_PLUGIN_MENU_ITEM *MenuItem + _In_ struct _PH_PLUGIN_MENU_ITEM *MenuItem ); typedef struct _PH_PLUGIN_MENU_ITEM @@ -357,12 +357,12 @@ PHAPPAPI ULONG_PTR NTAPI PhPluginAddMenuItem( - __in PPH_PLUGIN Plugin, - __in ULONG_PTR Location, - __in_opt PWSTR InsertAfter, - __in ULONG Id, - __in PWSTR Text, - __in_opt PVOID Context + _In_ PPH_PLUGIN Plugin, + _In_ ULONG_PTR Location, + _In_opt_ PWSTR InsertAfter, + _In_ ULONG Id, + _In_ PWSTR Text, + _In_opt_ PVOID Context ); typedef struct _PH_PLUGIN_SYSTEM_STATISTICS @@ -406,78 +406,78 @@ PHAPPAPI VOID NTAPI PhPluginGetSystemStatistics( - __out PPH_PLUGIN_SYSTEM_STATISTICS Statistics + _Out_ PPH_PLUGIN_SYSTEM_STATISTICS Statistics ); PHAPPAPI PPH_EMENU_ITEM NTAPI PhPluginCreateEMenuItem( - __in PPH_PLUGIN Plugin, - __in ULONG Flags, - __in ULONG Id, - __in PWSTR Text, - __in_opt PVOID Context + _In_ PPH_PLUGIN Plugin, + _In_ ULONG Flags, + _In_ ULONG Id, + _In_ PWSTR Text, + _In_opt_ PVOID Context ); PHAPPAPI BOOLEAN NTAPI PhPluginTriggerEMenuItem( - __in HWND OwnerWindow, - __in PPH_EMENU_ITEM Item + _In_ HWND OwnerWindow, + _In_ PPH_EMENU_ITEM Item ); PHAPPAPI BOOLEAN NTAPI PhPluginAddTreeNewColumn( - __in PPH_PLUGIN Plugin, - __in PVOID CmData, - __in PPH_TREENEW_COLUMN Column, - __in ULONG SubId, - __in_opt PVOID Context, - __in_opt PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction + _In_ PPH_PLUGIN Plugin, + _In_ PVOID CmData, + _In_ PPH_TREENEW_COLUMN Column, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_opt_ PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction ); PHAPPAPI VOID NTAPI PhPluginSetObjectExtension( - __in PPH_PLUGIN Plugin, - __in PH_EM_OBJECT_TYPE ObjectType, - __in ULONG ExtensionSize, - __in_opt PPH_EM_OBJECT_CALLBACK CreateCallback, - __in_opt PPH_EM_OBJECT_CALLBACK DeleteCallback + _In_ PPH_PLUGIN Plugin, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ ULONG ExtensionSize, + _In_opt_ PPH_EM_OBJECT_CALLBACK CreateCallback, + _In_opt_ PPH_EM_OBJECT_CALLBACK DeleteCallback ); PHAPPAPI PVOID NTAPI PhPluginGetObjectExtension( - __in PPH_PLUGIN Plugin, - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType + _In_ PPH_PLUGIN Plugin, + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType ); PHAPPAPI struct _PH_NF_ICON * NTAPI PhPluginRegisterIcon( - __in PPH_PLUGIN Plugin, - __in ULONG SubId, - __in_opt PVOID Context, - __in PWSTR Text, - __in ULONG Flags, - __in struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData + _In_ PPH_PLUGIN Plugin, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_ PWSTR Text, + _In_ ULONG Flags, + _In_ struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData ); PHAPPAPI VOID NTAPI PhPluginEnableTreeNewNotify( - __in PPH_PLUGIN Plugin, - __in PVOID CmData + _In_ PPH_PLUGIN Plugin, + _In_ PVOID CmData ); #ifdef __cplusplus diff --git a/2.x/trunk/ProcessHacker/include/phsvc.h b/2.x/trunk/ProcessHacker/include/phsvc.h index ba78d38bb..913f4a731 100644 --- a/2.x/trunk/ProcessHacker/include/phsvc.h +++ b/2.x/trunk/ProcessHacker/include/phsvc.h @@ -15,13 +15,13 @@ typedef struct _PHSVC_STOP } PHSVC_STOP, *PPHSVC_STOP; NTSTATUS PhSvcMain( - __in_opt PUNICODE_STRING PortName, - __in_opt PLARGE_INTEGER Timeout, - __inout_opt PPHSVC_STOP Stop + _In_opt_ PUNICODE_STRING PortName, + _In_opt_ PLARGE_INTEGER Timeout, + _Inout_opt_ PPHSVC_STOP Stop ); VOID PhSvcStop( - __inout PPHSVC_STOP Stop + _Inout_ PPHSVC_STOP Stop ); // svcclient @@ -34,8 +34,6 @@ typedef struct _PHSVC_CLIENT HANDLE PortHandle; PVOID ClientViewBase; PVOID ClientViewLimit; - - PPH_HANDLE_TABLE HandleTable; } PHSVC_CLIENT, *PPHSVC_CLIENT; NTSTATUS PhSvcClientInitialization( @@ -43,11 +41,11 @@ NTSTATUS PhSvcClientInitialization( ); PPHSVC_CLIENT PhSvcCreateClient( - __in_opt PCLIENT_ID ClientId + _In_opt_ PCLIENT_ID ClientId ); PPHSVC_CLIENT PhSvcReferenceClientByClientId( - __in PCLIENT_ID ClientId + _In_ PCLIENT_ID ClientId ); PPHSVC_CLIENT PhSvcGetCurrentClient( @@ -55,28 +53,11 @@ PPHSVC_CLIENT PhSvcGetCurrentClient( ); BOOLEAN PhSvcAttachClient( - __in PPHSVC_CLIENT Client + _In_ PPHSVC_CLIENT Client ); VOID PhSvcDetachClient( - __in PPHSVC_CLIENT Client - ); - -NTSTATUS PhSvcCreateHandle( - __out PHANDLE Handle, - __in PVOID Object, - __in ACCESS_MASK GrantedAccess - ); - -NTSTATUS PhSvcCloseHandle( - __in HANDLE Handle - ); - -NTSTATUS PhSvcReferenceObjectByHandle( - __in HANDLE Handle, - __in_opt PPH_OBJECT_TYPE ObjectType, - __in_opt ACCESS_MASK DesiredAccess, - __out PVOID *Object + _In_ PPHSVC_CLIENT Client ); // svcapiport @@ -88,7 +69,7 @@ typedef struct _PHSVC_THREAD_CONTEXT } PHSVC_THREAD_CONTEXT, *PPHSVC_THREAD_CONTEXT; NTSTATUS PhSvcApiPortInitialization( - __in PUNICODE_STRING PortName + _In_ PUNICODE_STRING PortName ); PPHSVC_THREAD_CONTEXT PhSvcGetCurrentThreadContext( @@ -96,7 +77,7 @@ PPHSVC_THREAD_CONTEXT PhSvcGetCurrentThreadContext( ); VOID PhSvcHandleConnectionRequest( - __in PPHSVC_API_MSG Message + _In_ PPHSVC_API_MSG Message ); // svcapi @@ -106,98 +87,108 @@ NTSTATUS PhSvcApiInitialization( ); typedef NTSTATUS (NTAPI *PPHSVC_API_PROCEDURE)( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); VOID PhSvcDispatchApiCall( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message, - __out PPHSVC_API_MSG *ReplyMessage, - __out PHANDLE ReplyPortHandle + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message, + _Out_ PPHSVC_API_MSG *ReplyMessage, + _Out_ PHANDLE ReplyPortHandle ); NTSTATUS PhSvcCaptureBuffer( - __in PPH_RELATIVE_STRINGREF String, - __in BOOLEAN AllowNull, - __out PVOID *CapturedBuffer + _In_ PPH_RELATIVE_STRINGREF String, + _In_ BOOLEAN AllowNull, + _Out_ PVOID *CapturedBuffer ); NTSTATUS PhSvcCaptureString( - __in PPH_RELATIVE_STRINGREF String, - __in BOOLEAN AllowNull, - __out PPH_STRING *CapturedString + _In_ PPH_RELATIVE_STRINGREF String, + _In_ BOOLEAN AllowNull, + _Out_ PPH_STRING *CapturedString ); NTSTATUS PhSvcCaptureSid( - __in PPH_RELATIVE_STRINGREF String, - __in BOOLEAN AllowNull, - __out PSID *CapturedSid + _In_ PPH_RELATIVE_STRINGREF String, + _In_ BOOLEAN AllowNull, + _Out_ PSID *CapturedSid ); -NTSTATUS PhSvcApiClose( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message +NTSTATUS PhSvcApiDefault( + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiExecuteRunAsCommand( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiUnloadDriver( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiControlProcess( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiControlService( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiCreateService( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiChangeServiceConfig( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiChangeServiceConfig2( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiSetTcpEntry( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiControlThread( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiAddAccountRight( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiInvokeRunAsService( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); NTSTATUS PhSvcApiIssueMemoryListCommand( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message + ); + +NTSTATUS PhSvcApiPostMessage( + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message + ); + +NTSTATUS PhSvcApiSendMessage( + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ); #endif diff --git a/2.x/trunk/ProcessHacker/include/phsvcapi.h b/2.x/trunk/ProcessHacker/include/phsvcapi.h index fc5f60056..ed37de05a 100644 --- a/2.x/trunk/ProcessHacker/include/phsvcapi.h +++ b/2.x/trunk/ProcessHacker/include/phsvcapi.h @@ -5,7 +5,7 @@ typedef enum _PHSVC_API_NUMBER { - PhSvcCloseApiNumber = 1, + PhSvcReserved1ApiNumber = 1, PhSvcExecuteRunAsCommandApiNumber = 2, PhSvcUnloadDriverApiNumber = 3, PhSvcControlProcessApiNumber = 4, @@ -18,6 +18,8 @@ typedef enum _PHSVC_API_NUMBER PhSvcAddAccountRightApiNumber = 11, PhSvcInvokeRunAsServiceApiNumber = 12, PhSvcIssueMemoryListCommandApiNumber = 13, + PhSvcPostMessageApiNumber = 14, + PhSvcSendMessageApiNumber = 15, PhSvcMaximumApiNumber } PHSVC_API_NUMBER, *PPHSVC_API_NUMBER; @@ -26,14 +28,6 @@ typedef struct _PHSVC_API_CONNECTINFO HANDLE ServerProcessId; } PHSVC_API_CONNECTINFO, *PPHSVC_API_CONNECTINFO; -typedef union _PHSVC_API_CLOSE -{ - struct - { - HANDLE Handle; - } i; -} PHSVC_API_CLOSE, *PPHSVC_API_CLOSE; - typedef union _PHSVC_API_EXECUTERUNASCOMMAND { struct @@ -200,6 +194,17 @@ typedef union _PHSVC_API_ISSUEMEMORYLISTCOMMAND } i; } PHSVC_API_ISSUEMEMORYLISTCOMMAND, *PPHSVC_API_ISSUEMEMORYLISTCOMMAND; +typedef union _PHSVC_API_POSTMESSAGE +{ + struct + { + HWND hWnd; + UINT Msg; + WPARAM wParam; + LPARAM lParam; + } i; +} PHSVC_API_POSTMESSAGE, *PPHSVC_API_POSTMESSAGE; + typedef struct _PHSVC_API_MSG { PORT_MESSAGE h; @@ -213,7 +218,6 @@ typedef struct _PHSVC_API_MSG union { - PHSVC_API_CLOSE Close; PHSVC_API_EXECUTERUNASCOMMAND ExecuteRunAsCommand; PHSVC_API_UNLOADDRIVER UnloadDriver; PHSVC_API_CONTROLPROCESS ControlProcess; @@ -225,6 +229,7 @@ typedef struct _PHSVC_API_MSG PHSVC_API_CONTROLTHREAD ControlThread; PHSVC_API_ADDACCOUNTRIGHT AddAccountRight; PHSVC_API_ISSUEMEMORYLISTCOMMAND IssueMemoryListCommand; + PHSVC_API_POSTMESSAGE PostMessage; } u; }; }; diff --git a/2.x/trunk/ProcessHacker/include/phsvccl.h b/2.x/trunk/ProcessHacker/include/phsvccl.h index e0d643568..3e261f830 100644 --- a/2.x/trunk/ProcessHacker/include/phsvccl.h +++ b/2.x/trunk/ProcessHacker/include/phsvccl.h @@ -4,93 +4,103 @@ #include NTSTATUS PhSvcConnectToServer( - __in PUNICODE_STRING PortName, - __in_opt SIZE_T PortSectionSize + _In_ PUNICODE_STRING PortName, + _In_opt_ SIZE_T PortSectionSize ); VOID PhSvcDisconnectFromServer( VOID ); -NTSTATUS PhSvcCallClose( - __in HANDLE Handle - ); - NTSTATUS PhSvcCallExecuteRunAsCommand( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ); NTSTATUS PhSvcCallUnloadDriver( - __in_opt PVOID BaseAddress, - __in_opt PWSTR Name + _In_opt_ PVOID BaseAddress, + _In_opt_ PWSTR Name ); NTSTATUS PhSvcCallControlProcess( - __in HANDLE ProcessId, - __in PHSVC_API_CONTROLPROCESS_COMMAND Command, - __in ULONG Argument + _In_ HANDLE ProcessId, + _In_ PHSVC_API_CONTROLPROCESS_COMMAND Command, + _In_ ULONG Argument ); NTSTATUS PhSvcCallControlService( - __in PWSTR ServiceName, - __in PHSVC_API_CONTROLSERVICE_COMMAND Command + _In_ PWSTR ServiceName, + _In_ PHSVC_API_CONTROLSERVICE_COMMAND Command ); NTSTATUS PhSvcCallCreateService( - __in PWSTR ServiceName, - __in_opt PWSTR DisplayName, - __in ULONG ServiceType, - __in ULONG StartType, - __in ULONG ErrorControl, - __in_opt PWSTR BinaryPathName, - __in_opt PWSTR LoadOrderGroup, - __out_opt PULONG TagId, - __in_opt PWSTR Dependencies, - __in_opt PWSTR ServiceStartName, - __in_opt PWSTR Password + _In_ PWSTR ServiceName, + _In_opt_ PWSTR DisplayName, + _In_ ULONG ServiceType, + _In_ ULONG StartType, + _In_ ULONG ErrorControl, + _In_opt_ PWSTR BinaryPathName, + _In_opt_ PWSTR LoadOrderGroup, + _Out_opt_ PULONG TagId, + _In_opt_ PWSTR Dependencies, + _In_opt_ PWSTR ServiceStartName, + _In_opt_ PWSTR Password ); NTSTATUS PhSvcCallChangeServiceConfig( - __in PWSTR ServiceName, - __in ULONG ServiceType, - __in ULONG StartType, - __in ULONG ErrorControl, - __in_opt PWSTR BinaryPathName, - __in_opt PWSTR LoadOrderGroup, - __out_opt PULONG TagId, - __in_opt PWSTR Dependencies, - __in_opt PWSTR ServiceStartName, - __in_opt PWSTR Password, - __in_opt PWSTR DisplayName + _In_ PWSTR ServiceName, + _In_ ULONG ServiceType, + _In_ ULONG StartType, + _In_ ULONG ErrorControl, + _In_opt_ PWSTR BinaryPathName, + _In_opt_ PWSTR LoadOrderGroup, + _Out_opt_ PULONG TagId, + _In_opt_ PWSTR Dependencies, + _In_opt_ PWSTR ServiceStartName, + _In_opt_ PWSTR Password, + _In_opt_ PWSTR DisplayName ); NTSTATUS PhSvcCallChangeServiceConfig2( - __in PWSTR ServiceName, - __in ULONG InfoLevel, - __in PVOID Info + _In_ PWSTR ServiceName, + _In_ ULONG InfoLevel, + _In_ PVOID Info ); NTSTATUS PhSvcCallSetTcpEntry( - __in PVOID TcpRow + _In_ PVOID TcpRow ); NTSTATUS PhSvcCallControlThread( - __in HANDLE ThreadId, - __in PHSVC_API_CONTROLTHREAD_COMMAND Command, - __in ULONG Argument + _In_ HANDLE ThreadId, + _In_ PHSVC_API_CONTROLTHREAD_COMMAND Command, + _In_ ULONG Argument ); NTSTATUS PhSvcCallAddAccountRight( - __in PSID AccountSid, - __in PUNICODE_STRING UserRight + _In_ PSID AccountSid, + _In_ PUNICODE_STRING UserRight ); NTSTATUS PhSvcCallInvokeRunAsService( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ); NTSTATUS PhSvcCallIssueMemoryListCommand( - __in SYSTEM_MEMORY_LIST_COMMAND Command + _In_ SYSTEM_MEMORY_LIST_COMMAND Command + ); + +NTSTATUS PhSvcCallPostMessage( + _In_opt_ HWND hWnd, + _In_ UINT Msg, + _In_ WPARAM wParam, + _In_ LPARAM lParam + ); + +NTSTATUS PhSvcCallSendMessage( + _In_opt_ HWND hWnd, + _In_ UINT Msg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); #endif diff --git a/2.x/trunk/ProcessHacker/include/procprpp.h b/2.x/trunk/ProcessHacker/include/procprpp.h index 1f486bf5f..283b62474 100644 --- a/2.x/trunk/ProcessHacker/include/procprpp.h +++ b/2.x/trunk/ProcessHacker/include/procprpp.h @@ -10,106 +10,133 @@ typedef struct _PH_PROCESS_PROPSHEETCONTEXT } PH_PROCESS_PROPSHEETCONTEXT, *PPH_PROCESS_PROPSHEETCONTEXT; VOID NTAPI PhpProcessPropContextDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); INT CALLBACK PhpPropSheetProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam ); PPH_PROCESS_PROPSHEETCONTEXT PhpGetPropSheetContext( - __in HWND hwnd + _In_ HWND hwnd ); LRESULT CALLBACK PhpPropSheetWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID NTAPI PhpProcessPropPageContextDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); INT CALLBACK PhpStandardPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ); INT_PTR CALLBACK PhpProcessGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessStatisticsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessPerformanceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessThreadsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessTokenHookProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessModulesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessMemoryDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessEnvironmentDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam + ); + +typedef struct _PH_HANDLE_ITEM_INFO +{ + HANDLE ProcessId; + HANDLE Handle; + PPH_STRING TypeName; + PPH_STRING BestObjectName; +} PH_HANDLE_ITEM_INFO, *PPH_HANDLE_ITEM_INFO; + +#define PHA_APPEND_CTRL_ENTER(Text, Enable) ((Enable) ? PhaConcatStrings2((Text), L"\tCtrl+Enter")->Buffer : (Text)) + +VOID PhInsertHandleObjectPropertiesEMenuItems( + _In_ struct _PH_EMENU_ITEM *Menu, + _In_ ULONG InsertBeforeId, + _In_ BOOLEAN EnableShortcut, + _In_ PPH_HANDLE_ITEM_INFO Info + ); + +VOID PhShowHandleObjectProperties1( + _In_ HWND hWnd, + _In_ PPH_HANDLE_ITEM_INFO Info + ); + +VOID PhShowHandleObjectProperties2( + _In_ HWND hWnd, + _In_ PPH_HANDLE_ITEM_INFO Info ); INT_PTR CALLBACK PhpProcessHandlesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpProcessServicesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); #define WM_PH_THREAD_ADDED (WM_APP + 201) @@ -152,6 +179,8 @@ typedef struct _PH_MODULES_CONTEXT PH_MODULE_LIST_CONTEXT ListContext; BOOLEAN NeedsRedraw; + NTSTATUS LastRunStatus; + PPH_STRING ErrorMessage; } PH_MODULES_CONTEXT, *PPH_MODULES_CONTEXT; #define WM_PH_HANDLE_ADDED (WM_APP + 221) @@ -174,6 +203,8 @@ typedef struct _PH_HANDLES_CONTEXT BOOLEAN NeedsRedraw; BOOLEAN SelectedHandleProtected; BOOLEAN SelectedHandleInherit; + NTSTATUS LastRunStatus; + PPH_STRING ErrorMessage; } PH_HANDLES_CONTEXT, *PPH_HANDLES_CONTEXT; typedef struct _PH_MEMORY_CONTEXT diff --git a/2.x/trunk/ProcessHacker/include/providers.h b/2.x/trunk/ProcessHacker/include/providers.h index ad262484b..8914578ca 100644 --- a/2.x/trunk/ProcessHacker/include/providers.h +++ b/2.x/trunk/ProcessHacker/include/providers.h @@ -254,82 +254,91 @@ BOOLEAN PhProcessProviderInitialization( PHAPPAPI PPH_STRING PhGetClientIdName( - __in PCLIENT_ID ClientId + _In_ PCLIENT_ID ClientId ); PHAPPAPI PPH_STRING PhGetClientIdNameEx( - __in PCLIENT_ID ClientId, - __in_opt PPH_STRING ProcessName + _In_ PCLIENT_ID ClientId, + _In_opt_ PPH_STRING ProcessName ); PHAPPAPI PWSTR PhGetProcessPriorityClassString( - __in ULONG PriorityClass + _In_ ULONG PriorityClass ); PPH_PROCESS_ITEM PhCreateProcessItem( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); PHAPPAPI PPH_PROCESS_ITEM PhReferenceProcessItem( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); PHAPPAPI VOID PhEnumProcessItems( - __out_opt PPH_PROCESS_ITEM **ProcessItems, - __out PULONG NumberOfProcessItems + _Out_opt_ PPH_PROCESS_ITEM **ProcessItems, + _Out_ PULONG NumberOfProcessItems + ); + +typedef struct _PH_VERIFY_FILE_INFO *PPH_VERIFY_FILE_INFO; + +VERIFY_RESULT PhVerifyFileWithAdditionalCatalog( + _In_ PPH_VERIFY_FILE_INFO Information, + _In_opt_ PWSTR PackageFullName, + _Out_opt_ PPH_STRING *SignerName ); VERIFY_RESULT PhVerifyFileCached( - __in PPH_STRING FileName, - __out_opt PPH_STRING *SignerName, - __in BOOLEAN CachedOnly + _In_ PPH_STRING FileName, + _In_opt_ PWSTR PackageFullName, + _Out_opt_ PPH_STRING *SignerName, + _In_ BOOLEAN CachedOnly ); PHAPPAPI BOOLEAN PhGetStatisticsTime( - __in_opt PPH_PROCESS_ITEM ProcessItem, - __in ULONG Index, - __out PLARGE_INTEGER Time + _In_opt_ PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG Index, + _Out_ PLARGE_INTEGER Time ); PHAPPAPI PPH_STRING PhGetStatisticsTimeString( - __in_opt PPH_PROCESS_ITEM ProcessItem, - __in ULONG Index + _In_opt_ PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG Index ); VOID PhProcessProviderUpdate( - __in PVOID Object + _In_ PVOID Object ); PHAPPAPI VOID PhReferenceProcessRecord( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ); PHAPPAPI BOOLEAN PhReferenceProcessRecordSafe( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ); PHAPPAPI VOID PhReferenceProcessRecordForStatistics( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ); PHAPPAPI VOID PhDereferenceProcessRecord( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ); PHAPPAPI PPH_PROCESS_RECORD PhFindProcessRecord( - __in_opt HANDLE ProcessId, - __in PLARGE_INTEGER Time + _In_opt_ HANDLE ProcessId, + _In_ PLARGE_INTEGER Time ); VOID PhPurgeProcessRecords( @@ -338,14 +347,14 @@ VOID PhPurgeProcessRecords( PHAPPAPI PPH_PROCESS_ITEM PhReferenceProcessItemForParent( - __in HANDLE ParentProcessId, - __in HANDLE ProcessId, - __in PLARGE_INTEGER CreateTime + _In_ HANDLE ParentProcessId, + _In_ HANDLE ProcessId, + _In_ PLARGE_INTEGER CreateTime ); PHAPPAPI PPH_PROCESS_ITEM PhReferenceProcessItemForRecord( - __in PPH_PROCESS_RECORD Record + _In_ PPH_PROCESS_RECORD Record ); // srvprv @@ -403,29 +412,29 @@ BOOLEAN PhServiceProviderInitialization( ); PPH_SERVICE_ITEM PhCreateServiceItem( - __in_opt LPENUM_SERVICE_STATUS_PROCESS Information + _In_opt_ LPENUM_SERVICE_STATUS_PROCESS Information ); PHAPPAPI PPH_SERVICE_ITEM PhReferenceServiceItem( - __in PWSTR Name + _In_ PWSTR Name ); VOID PhMarkNeedsConfigUpdateServiceItem( - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_SERVICE_ITEM ServiceItem ); PHAPPAPI PH_SERVICE_CHANGE PhGetServiceChange( - __in PPH_SERVICE_MODIFIED_DATA Data + _In_ PPH_SERVICE_MODIFIED_DATA Data ); VOID PhUpdateProcessItemServices( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); VOID PhServiceProviderUpdate( - __in PVOID Object + _In_ PVOID Object ); // netprv @@ -478,28 +487,28 @@ PPH_NETWORK_ITEM PhCreateNetworkItem( PHAPPAPI PPH_NETWORK_ITEM PhReferenceNetworkItem( - __in ULONG ProtocolType, - __in PPH_IP_ENDPOINT LocalEndpoint, - __in PPH_IP_ENDPOINT RemoteEndpoint, - __in HANDLE ProcessId + _In_ ULONG ProtocolType, + _In_ PPH_IP_ENDPOINT LocalEndpoint, + _In_ PPH_IP_ENDPOINT RemoteEndpoint, + _In_ HANDLE ProcessId ); PPH_STRING PhGetHostNameFromAddress( - __in PPH_IP_ADDRESS Address + _In_ PPH_IP_ADDRESS Address ); VOID PhNetworkProviderUpdate( - __in PVOID Object + _In_ PVOID Object ); PHAPPAPI PWSTR PhGetProtocolTypeName( - __in ULONG ProtocolType + _In_ ULONG ProtocolType ); PHAPPAPI PWSTR PhGetTcpStateName( - __in ULONG State + _In_ ULONG State ); // modprv @@ -545,7 +554,9 @@ typedef struct _PH_MODULE_PROVIDER HANDLE ProcessId; HANDLE ProcessHandle; + PPH_STRING PackageFullName; SLIST_HEADER QueryListHead; + NTSTATUS RunStatus; } PH_MODULE_PROVIDER, *PPH_MODULE_PROVIDER; BOOLEAN PhModuleProviderInitialization( @@ -553,7 +564,7 @@ BOOLEAN PhModuleProviderInitialization( ); PPH_MODULE_PROVIDER PhCreateModuleProvider( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); PPH_MODULE_ITEM PhCreateModuleItem( @@ -561,16 +572,16 @@ PPH_MODULE_ITEM PhCreateModuleItem( ); PPH_MODULE_ITEM PhReferenceModuleItem( - __in PPH_MODULE_PROVIDER ModuleProvider, - __in PVOID BaseAddress + _In_ PPH_MODULE_PROVIDER ModuleProvider, + _In_ PVOID BaseAddress ); VOID PhDereferenceAllModuleItems( - __in PPH_MODULE_PROVIDER ModuleProvider + _In_ PPH_MODULE_PROVIDER ModuleProvider ); VOID PhModuleProviderUpdate( - __in PVOID Object + _In_ PVOID Object ); // thrdprv @@ -640,39 +651,39 @@ BOOLEAN PhThreadProviderInitialization( ); PPH_THREAD_PROVIDER PhCreateThreadProvider( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); VOID PhRegisterThreadProvider( - __in PPH_THREAD_PROVIDER ThreadProvider, - __out PPH_CALLBACK_REGISTRATION CallbackRegistration + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _Out_ PPH_CALLBACK_REGISTRATION CallbackRegistration ); VOID PhUnregisterThreadProvider( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in PPH_CALLBACK_REGISTRATION CallbackRegistration + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ PPH_CALLBACK_REGISTRATION CallbackRegistration ); PPH_THREAD_ITEM PhCreateThreadItem( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ); PPH_THREAD_ITEM PhReferenceThreadItem( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in HANDLE ThreadId + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ HANDLE ThreadId ); VOID PhDereferenceAllThreadItems( - __in PPH_THREAD_PROVIDER ThreadProvider + _In_ PPH_THREAD_PROVIDER ThreadProvider ); PHAPPAPI PPH_STRING PhGetThreadPriorityWin32String( - __in LONG PriorityWin32 + _In_ LONG PriorityWin32 ); VOID PhThreadProviderInitialUpdate( - __in PPH_THREAD_PROVIDER ThreadProvider + _In_ PPH_THREAD_PROVIDER ThreadProvider ); // hndlprv @@ -722,6 +733,7 @@ typedef struct _PH_HANDLE_PROVIDER HANDLE ProcessHandle; PPH_HASHTABLE TempListHashtable; + NTSTATUS RunStatus; } PH_HANDLE_PROVIDER, *PPH_HANDLE_PROVIDER; BOOLEAN PhHandleProviderInitialization( @@ -729,31 +741,31 @@ BOOLEAN PhHandleProviderInitialization( ); PPH_HANDLE_PROVIDER PhCreateHandleProvider( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); PPH_HANDLE_ITEM PhCreateHandleItem( - __in_opt PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handle + _In_opt_ PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handle ); PPH_HANDLE_ITEM PhReferenceHandleItem( - __in PPH_HANDLE_PROVIDER HandleProvider, - __in HANDLE Handle + _In_ PPH_HANDLE_PROVIDER HandleProvider, + _In_ HANDLE Handle ); VOID PhDereferenceAllHandleItems( - __in PPH_HANDLE_PROVIDER HandleProvider + _In_ PPH_HANDLE_PROVIDER HandleProvider ); NTSTATUS PhEnumHandlesGeneric( - __in HANDLE ProcessId, - __in HANDLE ProcessHandle, - __out PSYSTEM_HANDLE_INFORMATION_EX *Handles, - __out PBOOLEAN FilterNeeded + _In_ HANDLE ProcessId, + _In_ HANDLE ProcessHandle, + _Out_ PSYSTEM_HANDLE_INFORMATION_EX *Handles, + _Out_ PBOOLEAN FilterNeeded ); VOID PhHandleProviderUpdate( - __in PVOID Object + _In_ PVOID Object ); // memprv @@ -776,8 +788,8 @@ typedef struct _PH_MEMORY_ITEM typedef struct _PH_MEMORY_PROVIDER *PPH_MEMORY_PROVIDER; typedef BOOLEAN (NTAPI *PPH_MEMORY_PROVIDER_CALLBACK)( - __in PPH_MEMORY_PROVIDER Provider, - __in __assumeRefs(1) PPH_MEMORY_ITEM MemoryItem + _In_ PPH_MEMORY_PROVIDER Provider, + _In_ _Assume_refs_(1) PPH_MEMORY_ITEM MemoryItem ); typedef struct _PH_MEMORY_PROVIDER @@ -796,14 +808,14 @@ BOOLEAN PhMemoryProviderInitialization( ); VOID PhInitializeMemoryProvider( - __out PPH_MEMORY_PROVIDER Provider, - __in HANDLE ProcessId, - __in PPH_MEMORY_PROVIDER_CALLBACK Callback, - __in_opt PVOID Context + _Out_ PPH_MEMORY_PROVIDER Provider, + _In_ HANDLE ProcessId, + _In_ PPH_MEMORY_PROVIDER_CALLBACK Callback, + _In_opt_ PVOID Context ); VOID PhDeleteMemoryProvider( - __inout PPH_MEMORY_PROVIDER Provider + _Inout_ PPH_MEMORY_PROVIDER Provider ); PPH_MEMORY_ITEM PhCreateMemoryItem( @@ -812,22 +824,22 @@ PPH_MEMORY_ITEM PhCreateMemoryItem( PHAPPAPI VOID PhGetMemoryProtectionString( - __in ULONG Protection, - __out_ecount(17) PWSTR String + _In_ ULONG Protection, + _Out_writes_(17) PWSTR String ); PHAPPAPI PWSTR PhGetMemoryStateString( - __in ULONG State + _In_ ULONG State ); PHAPPAPI PWSTR PhGetMemoryTypeString( - __in ULONG Type + _In_ ULONG Type ); VOID PhMemoryProviderUpdate( - __in PPH_MEMORY_PROVIDER Provider + _In_ PPH_MEMORY_PROVIDER Provider ); #endif diff --git a/2.x/trunk/ProcessHacker/include/settings.h b/2.x/trunk/ProcessHacker/include/settings.h index 47d569093..af7915cc4 100644 --- a/2.x/trunk/ProcessHacker/include/settings.h +++ b/2.x/trunk/ProcessHacker/include/settings.h @@ -31,42 +31,42 @@ VOID PhUpdateCachedSettings( ); PHAPPAPI -__mayRaise ULONG PhGetIntegerSetting( - __in PWSTR Name +_May_raise_ ULONG PhGetIntegerSetting( + _In_ PWSTR Name ); PHAPPAPI -__mayRaise PH_INTEGER_PAIR PhGetIntegerPairSetting( - __in PWSTR Name +_May_raise_ PH_INTEGER_PAIR PhGetIntegerPairSetting( + _In_ PWSTR Name ); PHAPPAPI -__mayRaise PPH_STRING PhGetStringSetting( - __in PWSTR Name +_May_raise_ PPH_STRING PhGetStringSetting( + _In_ PWSTR Name ); PHAPPAPI -__mayRaise VOID PhSetIntegerSetting( - __in PWSTR Name, - __in ULONG Value +_May_raise_ VOID PhSetIntegerSetting( + _In_ PWSTR Name, + _In_ ULONG Value ); PHAPPAPI -__mayRaise VOID PhSetIntegerPairSetting( - __in PWSTR Name, - __in PH_INTEGER_PAIR Value +_May_raise_ VOID PhSetIntegerPairSetting( + _In_ PWSTR Name, + _In_ PH_INTEGER_PAIR Value ); PHAPPAPI -__mayRaise VOID PhSetStringSetting( - __in PWSTR Name, - __in PWSTR Value +_May_raise_ VOID PhSetStringSetting( + _In_ PWSTR Name, + _In_ PWSTR Value ); PHAPPAPI -__mayRaise VOID PhSetStringSetting2( - __in PWSTR Name, - __in PPH_STRINGREF Value +_May_raise_ VOID PhSetStringSetting2( + _In_ PWSTR Name, + _In_ PPH_STRINGREF Value ); VOID PhClearIgnoredSettings( @@ -78,11 +78,11 @@ VOID PhConvertIgnoredSettings( ); NTSTATUS PhLoadSettings( - __in PWSTR FileName + _In_ PWSTR FileName ); NTSTATUS PhSaveSettings( - __in PWSTR FileName + _In_ PWSTR FileName ); VOID PhResetSettings( @@ -102,8 +102,8 @@ typedef struct _PH_CREATE_SETTING PHAPPAPI VOID PhAddSettings( - __in PPH_SETTING_CREATE Settings, - __in ULONG NumberOfSettings + _In_ PPH_SETTING_CREATE Settings, + _In_ ULONG NumberOfSettings ); // Cached settings diff --git a/2.x/trunk/ProcessHacker/include/settingsp.h b/2.x/trunk/ProcessHacker/include/settingsp.h index 7d778728d..0470e93bf 100644 --- a/2.x/trunk/ProcessHacker/include/settingsp.h +++ b/2.x/trunk/ProcessHacker/include/settingsp.h @@ -4,39 +4,39 @@ #include BOOLEAN NTAPI PhpSettingsHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI PhpSettingsHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); -__assumeLocked VOID PhpAddSetting( - __in PH_SETTING_TYPE Type, - __in PPH_STRINGREF Name, - __in PPH_STRINGREF DefaultValue +VOID PhpAddSetting( + _In_ PH_SETTING_TYPE Type, + _In_ PPH_STRINGREF Name, + _In_ PPH_STRINGREF DefaultValue ); PPH_STRING PhpSettingToString( - __in PH_SETTING_TYPE Type, - __in PPH_SETTING Setting + _In_ PH_SETTING_TYPE Type, + _In_ PPH_SETTING Setting ); BOOLEAN PhpSettingFromString( - __in PH_SETTING_TYPE Type, - __in PPH_STRINGREF StringRef, - __in_opt PPH_STRING String, - __inout PPH_SETTING Setting + _In_ PH_SETTING_TYPE Type, + _In_ PPH_STRINGREF StringRef, + _In_opt_ PPH_STRING String, + _Inout_ PPH_SETTING Setting ); VOID PhpFreeSettingValue( - __in PH_SETTING_TYPE Type, - __in PPH_SETTING Setting + _In_ PH_SETTING_TYPE Type, + _In_ PPH_SETTING Setting ); PVOID PhpLookupSetting( - __in PPH_STRINGREF Name + _In_ PPH_STRINGREF Name ); #endif diff --git a/2.x/trunk/ProcessHacker/include/sysinfop.h b/2.x/trunk/ProcessHacker/include/sysinfop.h index 37d1130ce..83b256d0b 100644 --- a/2.x/trunk/ProcessHacker/include/sysinfop.h +++ b/2.x/trunk/ProcessHacker/include/sysinfop.h @@ -23,28 +23,28 @@ // Misc. typedef HRESULT (WINAPI *_EnableThemeDialogTexture)( - __in HWND hwnd, - __in DWORD dwFlags + _In_ HWND hwnd, + _In_ DWORD dwFlags ); // Thread & window NTSTATUS PhSipSysInfoThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); INT_PTR CALLBACK PhSipSysInfoDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhSipContainerDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // Event handlers @@ -62,8 +62,8 @@ VOID PhSipOnNcDestroy( ); VOID PhSipOnShowWindow( - __in BOOLEAN Showing, - __in ULONG State + _In_ BOOLEAN Showing, + _In_ ULONG State ); VOID PhSipOnSize( @@ -71,8 +71,8 @@ VOID PhSipOnSize( ); VOID PhSipOnSizing( - __in ULONG Edge, - __in PRECT DragRectangle + _In_ ULONG Edge, + _In_ PRECT DragRectangle ); VOID PhSipOnThemeChanged( @@ -80,34 +80,34 @@ VOID PhSipOnThemeChanged( ); VOID PhSipOnCommand( - __in ULONG Id, - __in ULONG Code + _In_ ULONG Id, + _In_ ULONG Code ); BOOLEAN PhSipOnNotify( - __in NMHDR *Header, - __out LRESULT *Result + _In_ NMHDR *Header, + _Out_ LRESULT *Result ); BOOLEAN PhSipOnDrawItem( - __in ULONG_PTR Id, - __in DRAWITEMSTRUCT *DrawItemStruct + _In_ ULONG_PTR Id, + _In_ DRAWITEMSTRUCT *DrawItemStruct ); VOID PhSipOnUserMessage( - __in ULONG Message, - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ ULONG Message, + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ); // Framework VOID PhSipRegisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ); VOID PhSipUnregisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ); VOID PhSipInitializeParameters( @@ -123,42 +123,42 @@ VOID PhSipUpdateColorParameters( ); PPH_SYSINFO_SECTION PhSipCreateSection( - __in PPH_SYSINFO_SECTION Template + _In_ PPH_SYSINFO_SECTION Template ); VOID PhSipDestroySection( - __in PPH_SYSINFO_SECTION Section + _In_ PPH_SYSINFO_SECTION Section ); PPH_SYSINFO_SECTION PhSipFindSection( - __in PPH_STRINGREF Name + _In_ PPH_STRINGREF Name ); PPH_SYSINFO_SECTION PhSipCreateInternalSection( - __in PWSTR Name, - __in ULONG Flags, - __in PPH_SYSINFO_SECTION_CALLBACK Callback + _In_ PWSTR Name, + _In_ ULONG Flags, + _In_ PPH_SYSINFO_SECTION_CALLBACK Callback ); VOID PhSipDrawRestoreSummaryPanel( - __in HDC hdc, - __in PRECT Rect + _In_ HDC hdc, + _In_ PRECT Rect ); VOID PhSipDrawSeparator( - __in HDC hdc, - __in PRECT Rect + _In_ HDC hdc, + _In_ PRECT Rect ); VOID PhSipDrawPanel( - __in PPH_SYSINFO_SECTION Section, - __in HDC hdc, - __in PRECT Rect + _In_ PPH_SYSINFO_SECTION Section, + _In_ HDC hdc, + _In_ PRECT Rect ); VOID PhSipDefaultDrawPanel( - __in PPH_SYSINFO_SECTION Section, - __in PPH_SYSINFO_DRAW_PANEL DrawPanel + _In_ PPH_SYSINFO_SECTION Section, + _In_ PPH_SYSINFO_DRAW_PANEL DrawPanel ); VOID PhSipLayoutSummaryView( @@ -170,7 +170,7 @@ VOID PhSipLayoutSectionView( ); VOID PhSipEnterSectionView( - __in PPH_SYSINFO_SECTION NewSection + _In_ PPH_SYSINFO_SECTION NewSection ); VOID PhSipRestoreSummaryView( @@ -178,28 +178,28 @@ VOID PhSipRestoreSummaryView( ); HWND PhSipDefaultCreateDialog( - __in PVOID Instance, - __in PWSTR Template, - __in DLGPROC DialogProc, - __in PVOID Parameter + _In_ PVOID Instance, + _In_ PWSTR Template, + _In_ DLGPROC DialogProc, + _In_ PVOID Parameter ); VOID PhSipCreateSectionDialog( - __in PPH_SYSINFO_SECTION Section + _In_ PPH_SYSINFO_SECTION Section ); LRESULT CALLBACK PhSipGraphHookWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); LRESULT CALLBACK PhSipPanelHookWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // Misc. @@ -213,22 +213,28 @@ VOID PhSipSetAlwaysOnTop( ); VOID NTAPI PhSipSysInfoUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); PPH_STRING PhSipFormatSizeWithPrecision( - __in ULONG64 Size, - __in USHORT Precision + _In_ ULONG64 Size, + _In_ USHORT Precision ); // CPU section +typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8 +{ + ULONG Hits; + UCHAR PercentFrequency; +} SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8, *PSYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8; + BOOLEAN PhSipCpuSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); VOID PhSipInitializeCpuDialog( @@ -244,17 +250,17 @@ VOID PhSipTickCpuDialog( ); INT_PTR CALLBACK PhSipCpuDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhSipCpuPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhSipCreateCpuGraphs( @@ -270,8 +276,8 @@ VOID PhSipSetOneGraphPerCpu( ); VOID PhSipNotifyCpuGraph( - __in ULONG Index, - __in NMHDR *Header + _In_ ULONG Index, + _In_ NMHDR *Header ); VOID PhSipUpdateCpuGraphs( @@ -283,32 +289,32 @@ VOID PhSipUpdateCpuPanel( ); PPH_PROCESS_RECORD PhSipReferenceMaxCpuRecord( - __in LONG Index + _In_ LONG Index ); PPH_STRING PhSipGetMaxCpuString( - __in LONG Index + _In_ LONG Index ); VOID PhSipGetCpuBrandString( - __out_ecount(49) PWSTR BrandString + _Out_writes_(49) PWSTR BrandString ); BOOLEAN PhSipGetCpuFrequencyFromDistribution( - __out DOUBLE *Fraction + _Out_ DOUBLE *Fraction ); NTSTATUS PhSipQueryProcessorPerformanceDistribution( - __out PVOID *Buffer + _Out_ PVOID *Buffer ); // Memory section BOOLEAN PhSipMemorySectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); VOID PhSipInitializeMemoryDialog( @@ -324,17 +330,17 @@ VOID PhSipTickMemoryDialog( ); INT_PTR CALLBACK PhSipMemoryDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhSipMemoryPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhSipLayoutMemoryGraphs( @@ -342,11 +348,11 @@ VOID PhSipLayoutMemoryGraphs( ); VOID PhSipNotifyCommitGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID PhSipNotifyPhysicalGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID PhSipUpdateMemoryGraphs( @@ -358,21 +364,21 @@ VOID PhSipUpdateMemoryPanel( ); NTSTATUS PhSipLoadMmAddresses( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID PhSipGetPoolLimits( - __out PSIZE_T Paged, - __out PSIZE_T NonPaged + _Out_ PSIZE_T Paged, + _Out_ PSIZE_T NonPaged ); // I/O section BOOLEAN PhSipIoSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); VOID PhSipInitializeIoDialog( @@ -388,21 +394,21 @@ VOID PhSipTickIoDialog( ); INT_PTR CALLBACK PhSipIoDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhSipIoPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhSipNotifyIoGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID PhSipUpdateIoGraph( @@ -414,11 +420,11 @@ VOID PhSipUpdateIoPanel( ); PPH_PROCESS_RECORD PhSipReferenceMaxIoRecord( - __in LONG Index + _In_ LONG Index ); PPH_STRING PhSipGetMaxIoString( - __in LONG Index + _In_ LONG Index ); #endif diff --git a/2.x/trunk/ProcessHacker/include/uimodels.h b/2.x/trunk/ProcessHacker/include/uimodels.h index bc88cc8b4..2aa7b7a0b 100644 --- a/2.x/trunk/ProcessHacker/include/uimodels.h +++ b/2.x/trunk/ProcessHacker/include/uimodels.h @@ -11,12 +11,12 @@ typedef struct _PH_SH_STATE } PH_SH_STATE, *PPH_SH_STATE; FORCEINLINE VOID PhChangeShStateTn( - __inout PPH_TREENEW_NODE Node, - __inout PPH_SH_STATE ShState, - __inout PPH_POINTER_LIST *StateList, - __in PH_ITEM_STATE NewState, - __in COLORREF NewTempBackColor, - __in_opt HWND TreeNewHandleForUpdate + _Inout_ PPH_TREENEW_NODE Node, + _Inout_ PPH_SH_STATE ShState, + _Inout_ PPH_POINTER_LIST *StateList, + _In_ PH_ITEM_STATE NewState, + _In_ COLORREF NewTempBackColor, + _In_opt_ HWND TreeNewHandleForUpdate ) { if (!*StateList) @@ -188,8 +188,9 @@ FORCEINLINE VOID PhChangeShStateTn( #define PHPRTLC_SUBSYSTEM 71 #define PHPRTLC_PACKAGENAME 72 #define PHPRTLC_APPID 73 +#define PHPRTLC_DPIAWARENESS 74 -#define PHPRTLC_MAXIMUM 74 +#define PHPRTLC_MAXIMUM 75 #define PHPRTLC_IOGROUP_COUNT 9 #define PHPN_WSCOUNTERS 0x1 @@ -202,6 +203,7 @@ FORCEINLINE VOID PhChangeShStateTn( #define PHPN_QUOTALIMITS 0x80 #define PHPN_IMAGE 0x100 #define PHPN_APPID 0x200 +#define PHPN_DPIAWARENESS 0x400 typedef struct _PH_PROCESS_NODE { @@ -257,6 +259,8 @@ typedef struct _PH_PROCESS_NODE PPH_STRING AppIdText; // Cycles (Vista only) PH_UINT64_DELTA CyclesDelta; + // DPI Awareness + ULONG DpiAwareness; PPH_STRING TooltipText; @@ -312,7 +316,7 @@ VOID PhProcessTreeListInitialization( ); VOID PhInitializeProcessTreeList( - __in HWND hwnd + _In_ HWND hwnd ); VOID PhLoadSettingsProcessTreeList( @@ -333,22 +337,22 @@ struct _PH_TN_FILTER_SUPPORT *PhGetFilterSupportProcessTreeList( ); PPH_PROCESS_NODE PhAddProcessNode( - __in PPH_PROCESS_ITEM ProcessItem, - __in ULONG RunId + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG RunId ); PHAPPAPI PPH_PROCESS_NODE PhFindProcessNode( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); VOID PhRemoveProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ); PHAPPAPI VOID PhUpdateProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ); VOID PhTickProcessNodes( @@ -362,8 +366,8 @@ PPH_PROCESS_ITEM PhGetSelectedProcessItem( PHAPPAPI VOID PhGetSelectedProcessItems( - __out PPH_PROCESS_ITEM **Processes, - __out PULONG NumberOfProcesses + _Out_ PPH_PROCESS_ITEM **Processes, + _Out_ PULONG NumberOfProcesses ); PHAPPAPI @@ -373,7 +377,7 @@ VOID PhDeselectAllProcessNodes( PHAPPAPI VOID PhExpandAllProcessNodes( - __in BOOLEAN Expand + _In_ BOOLEAN Expand ); PHAPPAPI @@ -383,14 +387,14 @@ VOID PhInvalidateAllProcessNodes( PHAPPAPI VOID PhSelectAndEnsureVisibleProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ); PPH_LIST PhGetProcessTreeListLines( - __in HWND TreeListHandle, - __in ULONG NumberOfNodes, - __in PPH_LIST RootNodes, - __in ULONG Mode + _In_ HWND TreeListHandle, + _In_ ULONG NumberOfNodes, + _In_ PPH_LIST RootNodes, + _In_ ULONG Mode ); VOID PhCopyProcessTree( @@ -398,8 +402,8 @@ VOID PhCopyProcessTree( ); VOID PhWriteProcessTree( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ); // srvlist @@ -449,7 +453,7 @@ VOID PhServiceTreeListInitialization( ); VOID PhInitializeServiceTreeList( - __in HWND hwnd + _In_ HWND hwnd ); VOID PhLoadSettingsServiceTreeList( @@ -466,22 +470,22 @@ struct _PH_TN_FILTER_SUPPORT *PhGetFilterSupportServiceTreeList( ); PPH_SERVICE_NODE PhAddServiceNode( - __in PPH_SERVICE_ITEM ServiceItem, - __in ULONG RunId + _In_ PPH_SERVICE_ITEM ServiceItem, + _In_ ULONG RunId ); PHAPPAPI PPH_SERVICE_NODE PhFindServiceNode( - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_SERVICE_ITEM ServiceItem ); VOID PhRemoveServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ); PHAPPAPI VOID PhUpdateServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ); VOID PhTickServiceNodes( @@ -495,8 +499,8 @@ PPH_SERVICE_ITEM PhGetSelectedServiceItem( PHAPPAPI VOID PhGetSelectedServiceItems( - __out PPH_SERVICE_ITEM **Services, - __out PULONG NumberOfServices + _Out_ PPH_SERVICE_ITEM **Services, + _Out_ PULONG NumberOfServices ); PHAPPAPI @@ -506,7 +510,7 @@ VOID PhDeselectAllServiceNodes( PHAPPAPI VOID PhSelectAndEnsureVisibleServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ); VOID PhCopyServiceList( @@ -514,8 +518,8 @@ VOID PhCopyServiceList( ); VOID PhWriteServiceList( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ); // netlist @@ -557,7 +561,7 @@ VOID PhNetworkTreeListInitialization( ); VOID PhInitializeNetworkTreeList( - __in HWND hwnd + _In_ HWND hwnd ); VOID PhLoadSettingsNetworkTreeList( @@ -574,23 +578,23 @@ struct _PH_TN_FILTER_SUPPORT *PhGetFilterSupportNetworkTreeList( ); PPH_NETWORK_NODE PhAddNetworkNode( - __in PPH_NETWORK_ITEM NetworkItem, - __in ULONG RunId + _In_ PPH_NETWORK_ITEM NetworkItem, + _In_ ULONG RunId ); PHAPPAPI PPH_NETWORK_NODE NTAPI PhFindNetworkNode( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ); VOID PhRemoveNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ); VOID PhUpdateNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ); VOID PhTickNetworkNodes( @@ -602,8 +606,8 @@ PPH_NETWORK_ITEM PhGetSelectedNetworkItem( ); VOID PhGetSelectedNetworkItems( - __out PPH_NETWORK_ITEM **NetworkItems, - __out PULONG NumberOfNetworkItems + _Out_ PPH_NETWORK_ITEM **NetworkItems, + _Out_ PULONG NumberOfNetworkItems ); VOID PhDeselectAllNetworkNodes( @@ -611,7 +615,7 @@ VOID PhDeselectAllNetworkNodes( ); VOID PhSelectAndEnsureVisibleNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ); VOID PhCopyNetworkList( @@ -619,8 +623,8 @@ VOID PhCopyNetworkList( ); VOID PhWriteNetworkList( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ); // thrdlist @@ -673,61 +677,61 @@ typedef struct _PH_THREAD_LIST_CONTEXT } PH_THREAD_LIST_CONTEXT, *PPH_THREAD_LIST_CONTEXT; VOID PhInitializeThreadList( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __out PPH_THREAD_LIST_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _Out_ PPH_THREAD_LIST_CONTEXT Context ); VOID PhDeleteThreadList( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ); VOID PhLoadSettingsThreadList( - __inout PPH_THREAD_LIST_CONTEXT Context + _Inout_ PPH_THREAD_LIST_CONTEXT Context ); VOID PhSaveSettingsThreadList( - __inout PPH_THREAD_LIST_CONTEXT Context + _Inout_ PPH_THREAD_LIST_CONTEXT Context ); PPH_THREAD_NODE PhAddThreadNode( - __inout PPH_THREAD_LIST_CONTEXT Context, - __in PPH_THREAD_ITEM ThreadItem, - __in ULONG RunId + _Inout_ PPH_THREAD_LIST_CONTEXT Context, + _In_ PPH_THREAD_ITEM ThreadItem, + _In_ ULONG RunId ); PPH_THREAD_NODE PhFindThreadNode( - __in PPH_THREAD_LIST_CONTEXT Context, - __in HANDLE ThreadId + _In_ PPH_THREAD_LIST_CONTEXT Context, + _In_ HANDLE ThreadId ); VOID PhRemoveThreadNode( - __in PPH_THREAD_LIST_CONTEXT Context, - __in PPH_THREAD_NODE ThreadNode + _In_ PPH_THREAD_LIST_CONTEXT Context, + _In_ PPH_THREAD_NODE ThreadNode ); VOID PhUpdateThreadNode( - __in PPH_THREAD_LIST_CONTEXT Context, - __in PPH_THREAD_NODE ThreadNode + _In_ PPH_THREAD_LIST_CONTEXT Context, + _In_ PPH_THREAD_NODE ThreadNode ); VOID PhTickThreadNodes( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ); PPH_THREAD_ITEM PhGetSelectedThreadItem( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ); VOID PhGetSelectedThreadItems( - __in PPH_THREAD_LIST_CONTEXT Context, - __out PPH_THREAD_ITEM **Threads, - __out PULONG NumberOfThreads + _In_ PPH_THREAD_LIST_CONTEXT Context, + _Out_ PPH_THREAD_ITEM **Threads, + _Out_ PULONG NumberOfThreads ); VOID PhDeselectAllThreadNodes( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ); // modlist @@ -789,61 +793,61 @@ typedef struct _PH_MODULE_LIST_CONTEXT } PH_MODULE_LIST_CONTEXT, *PPH_MODULE_LIST_CONTEXT; VOID PhInitializeModuleList( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __out PPH_MODULE_LIST_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _Out_ PPH_MODULE_LIST_CONTEXT Context ); VOID PhDeleteModuleList( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ); VOID PhLoadSettingsModuleList( - __inout PPH_MODULE_LIST_CONTEXT Context + _Inout_ PPH_MODULE_LIST_CONTEXT Context ); VOID PhSaveSettingsModuleList( - __inout PPH_MODULE_LIST_CONTEXT Context + _Inout_ PPH_MODULE_LIST_CONTEXT Context ); PPH_MODULE_NODE PhAddModuleNode( - __inout PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_ITEM ModuleItem, - __in ULONG RunId + _Inout_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_ITEM ModuleItem, + _In_ ULONG RunId ); PPH_MODULE_NODE PhFindModuleNode( - __in PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_ITEM ModuleItem + _In_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_ITEM ModuleItem ); VOID PhRemoveModuleNode( - __in PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_NODE ModuleNode + _In_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_NODE ModuleNode ); VOID PhUpdateModuleNode( - __in PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_NODE ModuleNode + _In_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_NODE ModuleNode ); VOID PhTickModuleNodes( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ); PPH_MODULE_ITEM PhGetSelectedModuleItem( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ); VOID PhGetSelectedModuleItems( - __in PPH_MODULE_LIST_CONTEXT Context, - __out PPH_MODULE_ITEM **Modules, - __out PULONG NumberOfModules + _In_ PPH_MODULE_LIST_CONTEXT Context, + _Out_ PPH_MODULE_ITEM **Modules, + _Out_ PULONG NumberOfModules ); VOID PhDeselectAllModuleNodes( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ); // hndllist @@ -895,66 +899,66 @@ typedef struct _PH_HANDLE_LIST_CONTEXT } PH_HANDLE_LIST_CONTEXT, *PPH_HANDLE_LIST_CONTEXT; VOID PhInitializeHandleList( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __out PPH_HANDLE_LIST_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _Out_ PPH_HANDLE_LIST_CONTEXT Context ); VOID PhDeleteHandleList( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ); VOID PhLoadSettingsHandleList( - __inout PPH_HANDLE_LIST_CONTEXT Context + _Inout_ PPH_HANDLE_LIST_CONTEXT Context ); VOID PhSaveSettingsHandleList( - __inout PPH_HANDLE_LIST_CONTEXT Context + _Inout_ PPH_HANDLE_LIST_CONTEXT Context ); VOID PhSetOptionsHandleList( - __inout PPH_HANDLE_LIST_CONTEXT Context, - __in BOOLEAN HideUnnamedHandles + _Inout_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ BOOLEAN HideUnnamedHandles ); PPH_HANDLE_NODE PhAddHandleNode( - __inout PPH_HANDLE_LIST_CONTEXT Context, - __in PPH_HANDLE_ITEM HandleItem, - __in ULONG RunId + _Inout_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ PPH_HANDLE_ITEM HandleItem, + _In_ ULONG RunId ); PPH_HANDLE_NODE PhFindHandleNode( - __in PPH_HANDLE_LIST_CONTEXT Context, - __in HANDLE Handle + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ HANDLE Handle ); VOID PhRemoveHandleNode( - __in PPH_HANDLE_LIST_CONTEXT Context, - __in PPH_HANDLE_NODE HandleNode + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ PPH_HANDLE_NODE HandleNode ); VOID PhUpdateHandleNode( - __in PPH_HANDLE_LIST_CONTEXT Context, - __in PPH_HANDLE_NODE HandleNode + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _In_ PPH_HANDLE_NODE HandleNode ); VOID PhTickHandleNodes( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ); PPH_HANDLE_ITEM PhGetSelectedHandleItem( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ); VOID PhGetSelectedHandleItems( - __in PPH_HANDLE_LIST_CONTEXT Context, - __out PPH_HANDLE_ITEM **Handles, - __out PULONG NumberOfHandles + _In_ PPH_HANDLE_LIST_CONTEXT Context, + _Out_ PPH_HANDLE_ITEM **Handles, + _Out_ PULONG NumberOfHandles ); VOID PhDeselectAllHandleNodes( - __in PPH_HANDLE_LIST_CONTEXT Context + _In_ PPH_HANDLE_LIST_CONTEXT Context ); #endif diff --git a/2.x/trunk/ProcessHacker/infodlg.c b/2.x/trunk/ProcessHacker/infodlg.c index 7b158b974..397fec98d 100644 --- a/2.x/trunk/ProcessHacker/infodlg.c +++ b/2.x/trunk/ProcessHacker/infodlg.c @@ -26,10 +26,10 @@ static RECT MinimumSize = { -1, -1, -1, -1 }; static INT_PTR CALLBACK PhpInformationDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -186,8 +186,8 @@ static INT_PTR CALLBACK PhpInformationDlgProc( } VOID PhShowInformationDialog( - __in HWND ParentWindowHandle, - __in PWSTR String + _In_ HWND ParentWindowHandle, + _In_ PWSTR String ) { DialogBoxParam( diff --git a/2.x/trunk/ProcessHacker/itemtips.c b/2.x/trunk/ProcessHacker/itemtips.c index efaddabc9..bfae60db9 100644 --- a/2.x/trunk/ProcessHacker/itemtips.c +++ b/2.x/trunk/ProcessHacker/itemtips.c @@ -2,7 +2,7 @@ * Process Hacker - * item tooltips * - * Copyright (C) 2010-2011 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -27,15 +27,15 @@ #include VOID PhpFillRunningTasks( - __in PPH_PROCESS_ITEM Process, - __inout PPH_STRING_BUILDER Tasks + _In_ PPH_PROCESS_ITEM Process, + _Inout_ PPH_STRING_BUILDER Tasks ); VOID PhpAppendStringWithLineBreaks( - __inout PPH_STRING_BUILDER StringBuilder, - __in PPH_STRINGREF String, - __in ULONG CharactersPerLine, - __in_opt PWSTR IndentAfterFirstLine + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ PPH_STRINGREF String, + _In_ ULONG CharactersPerLine, + _In_opt_ PWSTR IndentAfterFirstLine ) { PH_STRINGREF line; @@ -69,14 +69,14 @@ VOID PhpAppendStringWithLineBreaks( PhAppendStringBuilderEx(StringBuilder, line.Buffer, bytesToAppend); afterFirstLine = TRUE; - line.Buffer = (PWSTR)((PCHAR)line.Buffer + bytesToAppend); + line.Buffer = (PWCHAR)((PCHAR)line.Buffer + bytesToAppend); line.Length -= bytesToAppend; } } static int __cdecl ServiceForTooltipCompare( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PPH_SERVICE_ITEM serviceItem1 = *(PPH_SERVICE_ITEM *)elem1; @@ -86,7 +86,7 @@ static int __cdecl ServiceForTooltipCompare( } PPH_STRING PhGetProcessTooltipText( - __in PPH_PROCESS_ITEM Process + _In_ PPH_PROCESS_ITEM Process ) { PH_STRING_BUILDER stringBuilder; @@ -348,16 +348,20 @@ PPH_STRING PhGetProcessTooltipText( ); } - if (Process->ConsoleHostProcessId) + if ((ULONG_PTR)Process->ConsoleHostProcessId & ~3) { CLIENT_ID clientId; + PWSTR description = L"Console host"; PPH_STRING clientIdString; - clientId.UniqueProcess = Process->ConsoleHostProcessId; + clientId.UniqueProcess = (HANDLE)((ULONG_PTR)Process->ConsoleHostProcessId & ~3); clientId.UniqueThread = NULL; + if ((ULONG_PTR)Process->ConsoleHostProcessId & 2) + description = L"Console application"; + clientIdString = PhGetClientIdName(&clientId); - PhAppendFormatStringBuilder(¬es, L" Console host: %s\n", clientIdString->Buffer); + PhAppendFormatStringBuilder(¬es, L" %s: %s\n", description, clientIdString->Buffer); PhDereferenceObject(clientIdString); } @@ -396,8 +400,8 @@ PPH_STRING PhGetProcessTooltipText( } VOID PhpFillRunningTasks( - __in PPH_PROCESS_ITEM Process, - __inout PPH_STRING_BUILDER Tasks + _In_ PPH_PROCESS_ITEM Process, + _Inout_ PPH_STRING_BUILDER Tasks ) { static CLSID CLSID_TaskScheduler_I = { 0x0f87369f, 0xa4e5, 0x4cfc, { 0xbd, 0x3e, 0x73, 0xe6, 0x15, 0x45, 0x72, 0xdd } }; @@ -479,7 +483,7 @@ VOID PhpFillRunningTasks( } PPH_STRING PhGetServiceTooltipText( - __in PPH_SERVICE_ITEM Service + _In_ PPH_SERVICE_ITEM Service ) { PH_STRING_BUILDER stringBuilder; diff --git a/2.x/trunk/ProcessHacker/jobprp.c b/2.x/trunk/ProcessHacker/jobprp.c index 0b9705de6..50d9edc8c 100644 --- a/2.x/trunk/ProcessHacker/jobprp.c +++ b/2.x/trunk/ProcessHacker/jobprp.c @@ -31,35 +31,35 @@ typedef struct _JOB_PAGE_CONTEXT } JOB_PAGE_CONTEXT, *PJOB_PAGE_CONTEXT; INT CALLBACK PhpJobPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ); INT_PTR CALLBACK PhpJobPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhpShowJobAdvancedProperties( - __in HWND ParentWindowHandle, - __in PJOB_PAGE_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ PJOB_PAGE_CONTEXT Context ); INT_PTR CALLBACK PhpJobStatisticsPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowJobProperties( - __in HWND ParentWindowHandle, - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt PWSTR Title + _In_ HWND ParentWindowHandle, + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ PWSTR Title ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -81,9 +81,9 @@ VOID PhShowJobProperties( } HPROPSHEETPAGE PhCreateJobPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt DLGPROC HookProc + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ DLGPROC HookProc ) { HPROPSHEETPAGE propSheetPageHandle; @@ -115,9 +115,9 @@ HPROPSHEETPAGE PhCreateJobPage( } INT CALLBACK PhpJobPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ) { PJOB_PAGE_CONTEXT jobPageContext; @@ -137,10 +137,10 @@ INT CALLBACK PhpJobPropPageProc( } FORCEINLINE PJOB_PAGE_CONTEXT PhpJobPageHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { return (PJOB_PAGE_CONTEXT)PhpGenericPropertyPageHeader( @@ -148,9 +148,9 @@ FORCEINLINE PJOB_PAGE_CONTEXT PhpJobPageHeader( } static VOID PhpAddLimit( - __in HWND Handle, - __in PWSTR Name, - __in PWSTR Value + _In_ HWND Handle, + _In_ PWSTR Name, + _In_ PWSTR Value ) { INT lvItemIndex; @@ -160,8 +160,8 @@ static VOID PhpAddLimit( } static VOID PhpAddJobProcesses( - __in HWND hwndDlg, - __in HANDLE JobHandle + _In_ HWND hwndDlg, + _In_ HANDLE JobHandle ) { PJOBOBJECT_BASIC_PROCESS_ID_LIST processIdList; @@ -190,10 +190,10 @@ static VOID PhpAddJobProcesses( } INT_PTR CALLBACK PhpJobPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PJOB_PAGE_CONTEXT jobPageContext; @@ -483,8 +483,8 @@ INT_PTR CALLBACK PhpJobPageProc( } VOID PhpShowJobAdvancedProperties( - __in HWND ParentWindowHandle, - __in PJOB_PAGE_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ PJOB_PAGE_CONTEXT Context ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -536,8 +536,8 @@ VOID PhpShowJobAdvancedProperties( } static VOID PhpRefreshJobStatisticsInfo( - __in HWND hwndDlg, - __in PJOB_PAGE_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PJOB_PAGE_CONTEXT Context ) { HANDLE jobHandle = NULL; @@ -619,10 +619,10 @@ static VOID PhpRefreshJobStatisticsInfo( } INT_PTR CALLBACK PhpJobStatisticsPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PJOB_PAGE_CONTEXT jobPageContext; diff --git a/2.x/trunk/ProcessHacker/log.c b/2.x/trunk/ProcessHacker/log.c index 50ecb2733..cfcd969c3 100644 --- a/2.x/trunk/ProcessHacker/log.c +++ b/2.x/trunk/ProcessHacker/log.c @@ -40,7 +40,7 @@ VOID PhLogInitialization( } PPH_LOG_ENTRY PhpCreateLogEntry( - __in UCHAR Type + _In_ UCHAR Type ) { PPH_LOG_ENTRY entry; @@ -55,7 +55,7 @@ PPH_LOG_ENTRY PhpCreateLogEntry( } VOID PhpFreeLogEntry( - __inout PPH_LOG_ENTRY Entry + _Inout_ PPH_LOG_ENTRY Entry ) { if (Entry->Type >= PH_LOG_ENTRY_PROCESS_FIRST && Entry->Type <= PH_LOG_ENTRY_PROCESS_LAST) @@ -77,11 +77,11 @@ VOID PhpFreeLogEntry( } PPH_LOG_ENTRY PhpCreateProcessLogEntry( - __in UCHAR Type, - __in HANDLE ProcessId, - __in PPH_STRING Name, - __in_opt HANDLE ParentProcessId, - __in_opt PPH_STRING ParentName + _In_ UCHAR Type, + _In_ HANDLE ProcessId, + _In_ PPH_STRING Name, + _In_opt_ HANDLE ParentProcessId, + _In_opt_ PPH_STRING ParentName ) { PPH_LOG_ENTRY entry; @@ -103,9 +103,9 @@ PPH_LOG_ENTRY PhpCreateProcessLogEntry( } PPH_LOG_ENTRY PhpCreateServiceLogEntry( - __in UCHAR Type, - __in PPH_STRING Name, - __in PPH_STRING DisplayName + _In_ UCHAR Type, + _In_ PPH_STRING Name, + _In_ PPH_STRING DisplayName ) { PPH_LOG_ENTRY entry; @@ -120,8 +120,8 @@ PPH_LOG_ENTRY PhpCreateServiceLogEntry( } PPH_LOG_ENTRY PhpCreateMessageLogEntry( - __in UCHAR Type, - __in PPH_STRING Message + _In_ UCHAR Type, + _In_ PPH_STRING Message ) { PPH_LOG_ENTRY entry; @@ -134,7 +134,7 @@ PPH_LOG_ENTRY PhpCreateMessageLogEntry( } VOID PhpLogEntry( - __in PPH_LOG_ENTRY Entry + _In_ PPH_LOG_ENTRY Entry ) { PPH_LOG_ENTRY oldEntry; @@ -164,35 +164,35 @@ VOID PhClearLogEntries( } VOID PhLogProcessEntry( - __in UCHAR Type, - __in HANDLE ProcessId, - __in PPH_STRING Name, - __in_opt HANDLE ParentProcessId, - __in_opt PPH_STRING ParentName + _In_ UCHAR Type, + _In_ HANDLE ProcessId, + _In_ PPH_STRING Name, + _In_opt_ HANDLE ParentProcessId, + _In_opt_ PPH_STRING ParentName ) { PhpLogEntry(PhpCreateProcessLogEntry(Type, ProcessId, Name, ParentProcessId, ParentName)); } VOID PhLogServiceEntry( - __in UCHAR Type, - __in PPH_STRING Name, - __in PPH_STRING DisplayName + _In_ UCHAR Type, + _In_ PPH_STRING Name, + _In_ PPH_STRING DisplayName ) { PhpLogEntry(PhpCreateServiceLogEntry(Type, Name, DisplayName)); } VOID PhLogMessageEntry( - __in UCHAR Type, - __in PPH_STRING Message + _In_ UCHAR Type, + _In_ PPH_STRING Message ) { PhpLogEntry(PhpCreateMessageLogEntry(Type, Message)); } PPH_STRING PhFormatLogEntry( - __in PPH_LOG_ENTRY Entry + _In_ PPH_LOG_ENTRY Entry ) { switch (Entry->Type) diff --git a/2.x/trunk/ProcessHacker/logwnd.c b/2.x/trunk/ProcessHacker/logwnd.c index ae55be24e..a84f8b85f 100644 --- a/2.x/trunk/ProcessHacker/logwnd.c +++ b/2.x/trunk/ProcessHacker/logwnd.c @@ -26,10 +26,10 @@ #define WM_PH_LOG_UPDATED (WM_APP + 300) INT_PTR CALLBACK PhpLogDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); HWND PhLogWindowHandle = NULL; @@ -62,8 +62,8 @@ VOID PhShowLogDialog( } static VOID NTAPI LoggedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PostMessage(PhLogWindowHandle, WM_PH_LOG_UPDATED, 0, 0); @@ -74,19 +74,19 @@ static VOID PhpUpdateLogList( ) { ListViewCount = PhLogBuffer.Count; - ListView_SetItemCount(ListViewHandle, ListViewCount); + ListView_SetItemCountEx(ListViewHandle, ListViewCount, LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL); if (ListViewCount >= 2 && Button_GetCheck(GetDlgItem(PhLogWindowHandle, IDC_AUTOSCROLL)) == BST_CHECKED) { - // This is a real WTF. EnsureVisible doesn't work if IsItemVisible is used and there is - // an item selected. - //if (ListView_IsItemVisible(ListViewHandle, ListViewCount - 2)) - ListView_EnsureVisible(ListViewHandle, ListViewCount - 1, FALSE); + if (ListView_IsItemVisible(ListViewHandle, ListViewCount - 2)) + { + ListView_EnsureVisible(ListViewHandle, ListViewCount - 1, FALSE); + } } } static PPH_STRING PhpGetStringForSelectedLogEntries( - __in BOOLEAN All + _In_ BOOLEAN All ) { PH_STRING_BUILDER stringBuilder; @@ -142,10 +142,10 @@ static PPH_STRING PhpGetStringForSelectedLogEntries( } INT_PTR CALLBACK PhpLogDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/main.c b/2.x/trunk/ProcessHacker/main.c index e6c88fd1f..20c48abef 100644 --- a/2.x/trunk/ProcessHacker/main.c +++ b/2.x/trunk/ProcessHacker/main.c @@ -84,11 +84,11 @@ static PPH_LIST DialogList = NULL; static PPH_LIST FilterList = NULL; static PH_AUTO_POOL BaseAutoPool; -INT WINAPI WinMain( - __in HINSTANCE hInstance, - __in_opt HINSTANCE hPrevInstance, - __in LPSTR lpCmdLine, - __in INT nCmdShow +INT WINAPI wWinMain( + _In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ PWSTR lpCmdLine, + _In_ INT nCmdShow ) { LONG result; @@ -177,6 +177,12 @@ INT WINAPI WinMain( if (PhStartupParameters.PhSvc) { + MSG message; + + // Turn the feedback cursor off. + PostMessage(NULL, WM_NULL, 0, 0); + GetMessage(&message, NULL, 0, 0); + RtlExitUserProcess(PhSvcMain(NULL, NULL, NULL)); } @@ -213,7 +219,7 @@ INT WINAPI WinMain( #ifdef DEBUG dbg.ClientId = NtCurrentTeb()->ClientId; - dbg.StartAddress = WinMain; + dbg.StartAddress = wWinMain; dbg.Parameter = NULL; InsertTailList(&PhDbgThreadListHead, &dbg.ListEntry); TlsSetValue(PhDbgThreadDbgTlsIndex, &dbg); @@ -327,7 +333,7 @@ LONG PhMainMessageLoop( } VOID PhRegisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ) { if (!DialogList) @@ -337,7 +343,7 @@ VOID PhRegisterDialog( } VOID PhUnregisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ) { ULONG indexOfDialog; @@ -352,8 +358,8 @@ VOID PhUnregisterDialog( } struct _PH_MESSAGE_LOOP_FILTER_ENTRY *PhRegisterMessageLoopFilter( - __in PPH_MESSAGE_LOOP_FILTER Filter, - __in_opt PVOID Context + _In_ PPH_MESSAGE_LOOP_FILTER Filter, + _In_opt_ PVOID Context ) { PPH_MESSAGE_LOOP_FILTER_ENTRY entry; @@ -370,7 +376,7 @@ struct _PH_MESSAGE_LOOP_FILTER_ENTRY *PhRegisterMessageLoopFilter( } VOID PhUnregisterMessageLoopFilter( - __in struct _PH_MESSAGE_LOOP_FILTER_ENTRY *FilterEntry + _In_ struct _PH_MESSAGE_LOOP_FILTER_ENTRY *FilterEntry ) { ULONG indexOfFilter; @@ -387,7 +393,7 @@ VOID PhUnregisterMessageLoopFilter( } VOID PhApplyUpdateInterval( - __in ULONG Interval + _In_ ULONG Interval ) { PhSetIntervalProviderThread(&PhPrimaryProviderThread, Interval); @@ -434,10 +440,10 @@ VOID PhInitializeCommonControls( } HFONT PhpCreateFont( - __in HWND hWnd, - __in PWSTR Name, - __in ULONG Size, - __in ULONG Weight + _In_ HWND hWnd, + _In_ PWSTR Name, + _In_ ULONG Size, + _In_ ULONG Weight ) { HFONT font; @@ -474,7 +480,7 @@ HFONT PhpCreateFont( } VOID PhInitializeFont( - __in HWND hWnd + _In_ HWND hWnd ) { NONCLIENTMETRICS metrics = { sizeof(metrics) }; @@ -677,9 +683,9 @@ VOID PhpInitializeSettings( #define PH_ARG_PRIORITY 25 BOOLEAN NTAPI PhpCommandLineOptionCallback( - __in_opt PPH_COMMAND_LINE_OPTION Option, - __in_opt PPH_STRING Value, - __in_opt PVOID Context + _In_opt_ PPH_COMMAND_LINE_OPTION Option, + _In_opt_ PPH_STRING Value, + _In_opt_ PVOID Context ) { ULONG64 integer; diff --git a/2.x/trunk/ProcessHacker/mainwnd.c b/2.x/trunk/ProcessHacker/mainwnd.c index 7b6c4f718..51fd8332a 100644 --- a/2.x/trunk/ProcessHacker/mainwnd.c +++ b/2.x/trunk/ProcessHacker/mainwnd.c @@ -40,10 +40,10 @@ #define RUNAS_MODE_LIMITED 2 typedef HRESULT (WINAPI *_LoadIconMetric)( - __in HINSTANCE hinst, - __in PCWSTR pszName, - __in int lims, - __out HICON *phico + _In_ HINSTANCE hinst, + _In_ PCWSTR pszName, + _In_ int lims, + _Out_ HICON *phico ); PHAPPAPI HWND PhMainWndHandle; @@ -118,7 +118,7 @@ static PPH_TN_FILTER_ENTRY SignedFilterEntry = NULL; static PPH_TN_FILTER_ENTRY DriverFilterEntry = NULL; BOOLEAN PhMainWndInitialization( - __in INT ShowCommand + _In_ INT ShowCommand ) { PH_RECTANGLE windowRectangle; @@ -255,10 +255,10 @@ BOOLEAN PhMainWndInitialization( } LRESULT CALLBACK PhMwpWndProc( - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hWnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -547,7 +547,7 @@ VOID PhMwpInitializeControls( } NTSTATUS PhMwpDelayedLoadFunction( - __in PVOID Parameter + _In_ PVOID Parameter ) { // Register for window station notifications. @@ -568,39 +568,38 @@ PPH_STRING PhMwpFindDbghelpPath( VOID ) { - PPH_STRING path; - - path = PhGetKnownLocation( - CSIDL_PROGRAM_FILES, + static struct + { + ULONG Folder; + PWSTR AppendPath; + } locations[] = + { #ifdef _M_IX86 - L"\\Debugging Tools for Windows (x86)\\dbghelp.dll" + { CSIDL_PROGRAM_FILES, L"\\Windows Kits\\8.1\\Debuggers\\x86\\dbghelp.dll" }, + { CSIDL_PROGRAM_FILES, L"\\Windows Kits\\8.0\\Debuggers\\x86\\dbghelp.dll" }, + { CSIDL_PROGRAM_FILES, L"\\Debugging Tools for Windows (x86)\\dbghelp.dll" } #else - L"\\Debugging Tools for Windows (x64)\\dbghelp.dll" + { CSIDL_PROGRAM_FILESX86, L"\\Windows Kits\\8.1\\Debuggers\\x64\\dbghelp.dll" }, + { CSIDL_PROGRAM_FILESX86, L"\\Windows Kits\\8.0\\Debuggers\\x64\\dbghelp.dll" }, + { CSIDL_PROGRAM_FILES, L"\\Debugging Tools for Windows (x64)\\dbghelp.dll" } #endif - ); + }; - if (path && RtlDoesFileExists_U(path->Buffer)) - return path; - if (path) - PhDereferenceObject(path); + PPH_STRING path; + ULONG i; - path = PhGetKnownLocation( -#ifdef _M_IX86 - CSIDL_PROGRAM_FILES, -#else - CSIDL_PROGRAM_FILESX86, -#endif -#ifdef _M_IX86 - L"\\Windows Kits\\8.0\\Debuggers\\x86\\dbghelp.dll" -#else - L"\\Windows Kits\\8.0\\Debuggers\\x64\\dbghelp.dll" -#endif - ); + for (i = 0; i < sizeof(locations) / sizeof(locations[0]); i++) + { + path = PhGetKnownLocation(locations[i].Folder, locations[i].AppendPath); - if (path && RtlDoesFileExists_U(path->Buffer)) - return path; - if (path) - PhDereferenceObject(path); + if (path) + { + if (RtlDoesFileExists_U(path->Buffer)) + return path; + + PhDereferenceObject(path); + } + } return NULL; } @@ -644,7 +643,7 @@ VOID PhMwpOnSettingChange( } VOID PhMwpOnCommand( - __in ULONG Id + _In_ ULONG Id ) { switch (Id) @@ -1707,8 +1706,8 @@ VOID PhMwpOnCommand( } VOID PhMwpOnShowWindow( - __in BOOLEAN Showing, - __in ULONG State + _In_ BOOLEAN Showing, + _In_ ULONG State ) { if (NeedsMaximize) @@ -1719,9 +1718,9 @@ VOID PhMwpOnShowWindow( } BOOLEAN PhMwpOnSysCommand( - __in ULONG Type, - __in LONG CursorScreenX, - __in LONG CursorScreenY + _In_ ULONG Type, + _In_ LONG CursorScreenX, + _In_ LONG CursorScreenY ) { switch (Type) @@ -1754,8 +1753,8 @@ BOOLEAN PhMwpOnSysCommand( } VOID PhMwpOnMenuCommand( - __in ULONG Index, - __in HMENU Menu + _In_ ULONG Index, + _In_ HMENU Menu ) { MENUITEMINFO menuItemInfo; @@ -1770,9 +1769,9 @@ VOID PhMwpOnMenuCommand( } VOID PhMwpOnInitMenuPopup( - __in HMENU Menu, - __in ULONG Index, - __in BOOLEAN IsWindowMenu + _In_ HMENU Menu, + _In_ ULONG Index, + _In_ BOOLEAN IsWindowMenu ) { ULONG i; @@ -1846,8 +1845,8 @@ VOID PhMwpOnSize( } VOID PhMwpOnSizing( - __in ULONG Edge, - __in PRECT DragRectangle + _In_ ULONG Edge, + _In_ PRECT DragRectangle ) { PhResizingMinimumSize(DragRectangle, Edge, 400, 340); @@ -1868,8 +1867,8 @@ VOID PhMwpOnSetFocus( } BOOLEAN PhMwpOnNotify( - __in NMHDR *Header, - __out LRESULT *Result + _In_ NMHDR *Header, + _Out_ LRESULT *Result ) { if (Header->hwndFrom == TabControlHandle) @@ -1964,8 +1963,8 @@ BOOLEAN PhMwpOnNotify( } VOID PhMwpOnWtsSessionChange( - __in ULONG Reason, - __in ULONG SessionId + _In_ ULONG Reason, + _In_ ULONG SessionId ) { if (Reason == WTS_SESSION_LOGON || Reason == WTS_SESSION_LOGOFF) @@ -1978,9 +1977,9 @@ VOID PhMwpOnWtsSessionChange( } ULONG_PTR PhMwpOnUserMessage( - __in ULONG Message, - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ ULONG Message, + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ) { switch (Message) @@ -2053,7 +2052,7 @@ ULONG_PTR PhMwpOnUserMessage( break; case WM_PH_TOGGLE_VISIBLE: { - PhMwpActivateWindow(TRUE); + PhMwpActivateWindow(!WParam); } break; case WM_PH_SHOW_MEMORY_EDITOR: @@ -2311,8 +2310,8 @@ ULONG_PTR PhMwpOnUserMessage( } VOID NTAPI PhMwpProcessAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PROCESS_ITEM processItem = (PPH_PROCESS_ITEM)Parameter; @@ -2329,8 +2328,8 @@ VOID NTAPI PhMwpProcessAddedHandler( } VOID NTAPI PhMwpProcessModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PROCESS_ITEM processItem = (PPH_PROCESS_ITEM)Parameter; @@ -2339,8 +2338,8 @@ VOID NTAPI PhMwpProcessModifiedHandler( } VOID NTAPI PhMwpProcessRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PROCESS_ITEM processItem = (PPH_PROCESS_ITEM)Parameter; @@ -2351,16 +2350,16 @@ VOID NTAPI PhMwpProcessRemovedHandler( } VOID NTAPI PhMwpProcessesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PostMessage(PhMainWndHandle, WM_PH_PROCESSES_UPDATED, 0, 0); } VOID NTAPI PhMwpServiceAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_SERVICE_ITEM serviceItem = (PPH_SERVICE_ITEM)Parameter; @@ -2375,8 +2374,8 @@ VOID NTAPI PhMwpServiceAddedHandler( } VOID NTAPI PhMwpServiceModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_SERVICE_MODIFIED_DATA serviceModifiedData = (PPH_SERVICE_MODIFIED_DATA)Parameter; @@ -2388,8 +2387,8 @@ VOID NTAPI PhMwpServiceModifiedHandler( } VOID NTAPI PhMwpServiceRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_SERVICE_ITEM serviceItem = (PPH_SERVICE_ITEM)Parameter; @@ -2398,16 +2397,16 @@ VOID NTAPI PhMwpServiceRemovedHandler( } VOID NTAPI PhMwpServicesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PostMessage(PhMainWndHandle, WM_PH_SERVICES_UPDATED, 0, 0); } VOID NTAPI PhMwpNetworkItemAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_NETWORK_ITEM networkItem = (PPH_NETWORK_ITEM)Parameter; @@ -2422,8 +2421,8 @@ VOID NTAPI PhMwpNetworkItemAddedHandler( } VOID NTAPI PhMwpNetworkItemModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_NETWORK_ITEM networkItem = (PPH_NETWORK_ITEM)Parameter; @@ -2432,8 +2431,8 @@ VOID NTAPI PhMwpNetworkItemModifiedHandler( } VOID NTAPI PhMwpNetworkItemRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_NETWORK_ITEM networkItem = (PPH_NETWORK_ITEM)Parameter; @@ -2442,8 +2441,8 @@ VOID NTAPI PhMwpNetworkItemRemovedHandler( } VOID NTAPI PhMwpNetworkItemsUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PostMessage(PhMainWndHandle, WM_PH_NETWORK_ITEMS_UPDATED, 0, 0); @@ -2537,8 +2536,8 @@ VOID PhMwpSaveWindowSettings( } VOID PhMwpSymInitHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_STRING dbghelpPath; @@ -2553,6 +2552,7 @@ VOID PhMwpSymInitHandler( PH_STRINGREF dbghelpFolder; PPH_STRING symsrvPath; + PhSymPreferredDbgHelpBase = dbghelpModule; fullDbghelpPath = PhGetDllFileName(dbghelpModule, &indexOfFileName); if (fullDbghelpPath) @@ -2595,8 +2595,8 @@ VOID PhMwpUpdateLayoutPadding( } VOID PhMwpApplyLayoutPadding( - __inout PRECT Rect, - __in PRECT Padding + _Inout_ PRECT Rect, + _In_ PRECT Padding ) { Rect->left += Padding->left; @@ -2606,7 +2606,7 @@ VOID PhMwpApplyLayoutPadding( } VOID PhMwpLayout( - __inout HDWP *DeferHandle + _Inout_ HDWP *DeferHandle ) { RECT rect; @@ -2632,7 +2632,7 @@ VOID PhMwpLayout( } VOID PhMwpSetWindowOpacity( - __in ULONG Opacity + _In_ ULONG Opacity ) { if (Opacity == 0) @@ -2658,7 +2658,7 @@ VOID PhMwpSetWindowOpacity( } VOID PhMwpSetupComputerMenu( - __in PPH_EMENU_ITEM Root + _In_ PPH_EMENU_ITEM Root ) { PPH_EMENU_ITEM menuItem; @@ -2673,7 +2673,7 @@ VOID PhMwpSetupComputerMenu( } BOOLEAN PhMwpExecuteComputerCommand( - __in ULONG Id + _In_ ULONG Id ) { switch (Id) @@ -2708,7 +2708,7 @@ BOOLEAN PhMwpExecuteComputerCommand( } VOID PhMwpActivateWindow( - __in BOOLEAN Toggle + _In_ BOOLEAN Toggle ) { if (IsIconic(PhMainWndHandle)) @@ -2731,7 +2731,7 @@ VOID PhMwpActivateWindow( } VOID PhMwpInitializeMainMenu( - __in HMENU Menu + _In_ HMENU Menu ) { MENUINFO menuInfo; @@ -2749,10 +2749,10 @@ VOID PhMwpInitializeMainMenu( } VOID PhMwpDispatchMenuCommand( - __in HMENU MenuHandle, - __in ULONG ItemIndex, - __in ULONG ItemId, - __in ULONG_PTR ItemData + _In_ HMENU MenuHandle, + _In_ ULONG ItemIndex, + _In_ ULONG ItemId, + _In_ ULONG_PTR ItemData ) { switch (ItemId) @@ -2802,7 +2802,7 @@ VOID PhMwpDispatchMenuCommand( } ULONG_PTR PhMwpLegacyAddPluginMenuItem( - __in PPH_ADDMENUITEM AddMenuItem + _In_ PPH_ADDMENUITEM AddMenuItem ) { PPH_ADDMENUITEM addMenuItem; @@ -2826,8 +2826,8 @@ ULONG_PTR PhMwpLegacyAddPluginMenuItem( } VOID PhMwpInitializeSubMenu( - __in PPH_EMENU Menu, - __in ULONG Index + _In_ PPH_EMENU Menu, + _In_ ULONG Index ) { PPH_EMENU_ITEM menuItem; @@ -3060,7 +3060,7 @@ VOID PhMwpInitializeSubMenu( } PPH_EMENU_ITEM PhMwpFindTrayIconsMenuItem( - __in PPH_EMENU Menu + _In_ PPH_EMENU Menu ) { ULONG i; @@ -3078,8 +3078,8 @@ PPH_EMENU_ITEM PhMwpFindTrayIconsMenuItem( } VOID PhMwpInitializeSectionMenuItems( - __in PPH_EMENU Menu, - __in ULONG StartIndex + _In_ PPH_EMENU Menu, + _In_ ULONG StartIndex ) { INT selectedIndex; @@ -3163,7 +3163,7 @@ VOID PhMwpInitializeSectionMenuItems( } VOID PhMwpLayoutTabControl( - __inout HDWP *DeferHandle + _Inout_ HDWP *DeferHandle ) { RECT rect; @@ -3233,7 +3233,7 @@ VOID PhMwpLayoutTabControl( } VOID PhMwpNotifyTabControl( - __in NMHDR *Header + _In_ NMHDR *Header ) { if (Header->code == TCN_SELCHANGING) @@ -3247,7 +3247,7 @@ VOID PhMwpNotifyTabControl( } VOID PhMwpSelectionChangedTabControl( - __in ULONG OldIndex + _In_ ULONG OldIndex ) { INT selectedIndex; @@ -3316,7 +3316,7 @@ VOID PhMwpSelectionChangedTabControl( } PPH_ADDITIONAL_TAB_PAGE PhMwpAddTabPage( - __in PPH_ADDITIONAL_TAB_PAGE TabPage + _In_ PPH_ADDITIONAL_TAB_PAGE TabPage ) { PPH_ADDITIONAL_TAB_PAGE newTabPage; @@ -3343,7 +3343,7 @@ PPH_ADDITIONAL_TAB_PAGE PhMwpAddTabPage( } VOID PhMwpSelectTabPage( - __in ULONG Index + _In_ ULONG Index ) { INT oldIndex; @@ -3354,8 +3354,8 @@ VOID PhMwpSelectTabPage( } static int __cdecl IconProcessesCpuUsageCompare( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PPH_PROCESS_ITEM processItem1 = *(PPH_PROCESS_ITEM *)elem1; @@ -3365,8 +3365,8 @@ static int __cdecl IconProcessesCpuUsageCompare( } static int __cdecl IconProcessesNameCompare( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PPH_PROCESS_ITEM processItem1 = *(PPH_PROCESS_ITEM *)elem1; @@ -3376,8 +3376,8 @@ static int __cdecl IconProcessesNameCompare( } VOID PhMwpAddIconProcesses( - __in PPH_EMENU_ITEM Menu, - __in ULONG NumberOfProcesses + _In_ PPH_EMENU_ITEM Menu, + _In_ ULONG NumberOfProcesses ) { ULONG i; @@ -3514,7 +3514,7 @@ VOID PhMwpAddIconProcesses( } VOID PhShowIconContextMenu( - __in POINT Location + _In_ POINT Location ) { PPH_EMENU menu; @@ -3732,17 +3732,17 @@ VOID PhShowIconContextMenu( } VOID PhShowIconNotification( - __in PWSTR Title, - __in PWSTR Text, - __in ULONG Flags + _In_ PWSTR Title, + _In_ PWSTR Text, + _In_ ULONG Flags ) { PhNfShowBalloonTip(0, Title, Text, 10, Flags); } BOOLEAN PhMwpPluginNotifyEvent( - __in ULONG Type, - __in PVOID Parameter + _In_ ULONG Type, + _In_ PVOID Parameter ) { PH_PLUGIN_NOTIFY_EVENT notifyEvent; @@ -3757,7 +3757,7 @@ BOOLEAN PhMwpPluginNotifyEvent( } VOID PhMwpShowProcessProperties( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { PPH_PROCESS_PROPCONTEXT propContext; @@ -3775,8 +3775,8 @@ VOID PhMwpShowProcessProperties( } BOOLEAN PhMwpCurrentUserProcessTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { PPH_PROCESS_NODE processNode = (PPH_PROCESS_NODE)Node; @@ -3794,8 +3794,8 @@ BOOLEAN PhMwpCurrentUserProcessTreeFilter( } BOOLEAN PhMwpSignedProcessTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { PPH_PROCESS_NODE processNode = (PPH_PROCESS_NODE)Node; @@ -3807,8 +3807,8 @@ BOOLEAN PhMwpSignedProcessTreeFilter( } BOOLEAN PhMwpExecuteProcessPriorityCommand( - __in ULONG Id, - __in PPH_PROCESS_ITEM ProcessItem + _In_ ULONG Id, + _In_ PPH_PROCESS_ITEM ProcessItem ) { ULONG priorityClass; @@ -3843,11 +3843,11 @@ BOOLEAN PhMwpExecuteProcessPriorityCommand( } VOID PhMwpSetProcessMenuPriorityChecks( - __in PPH_EMENU Menu, - __in PPH_PROCESS_ITEM Process, - __in BOOLEAN SetPriority, - __in BOOLEAN SetIoPriority, - __in BOOLEAN SetPagePriority + _In_ PPH_EMENU Menu, + _In_ PPH_PROCESS_ITEM Process, + _In_ BOOLEAN SetPriority, + _In_ BOOLEAN SetIoPriority, + _In_ BOOLEAN SetPagePriority ) { HANDLE processHandle; @@ -3985,8 +3985,8 @@ VOID PhMwpSetProcessMenuPriorityChecks( } static BOOL CALLBACK EnumProcessWindowsProc( - __in HWND hwnd, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ LPARAM lParam ) { ULONG processId; @@ -4011,9 +4011,9 @@ static BOOL CALLBACK EnumProcessWindowsProc( } VOID PhMwpInitializeProcessMenu( - __in PPH_EMENU Menu, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ PPH_EMENU Menu, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ) { PPH_EMENU_ITEM item; @@ -4159,7 +4159,7 @@ VOID PhMwpInitializeProcessMenu( } VOID PhShowProcessContextMenu( - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ) { PPH_PROCESS_ITEM *processes; @@ -4220,8 +4220,8 @@ VOID PhShowProcessContextMenu( } VOID PhMwpOnProcessAdded( - __in __assumeRefs(1) PPH_PROCESS_ITEM ProcessItem, - __in ULONG RunId + _In_ _Assume_refs_(1) PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG RunId ) { PPH_PROCESS_NODE processNode; @@ -4292,7 +4292,7 @@ VOID PhMwpOnProcessAdded( } VOID PhMwpOnProcessModified( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { PhUpdateProcessNode(PhFindProcessNode(ProcessItem->ProcessId)); @@ -4302,7 +4302,7 @@ VOID PhMwpOnProcessModified( } VOID PhMwpOnProcessRemoved( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { PPH_PROCESS_NODE processNode; @@ -4405,8 +4405,8 @@ VOID PhMwpNeedServiceTreeList( } BOOLEAN PhMwpDriverServiceTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { PPH_SERVICE_NODE serviceNode = (PPH_SERVICE_NODE)Node; @@ -4418,9 +4418,9 @@ BOOLEAN PhMwpDriverServiceTreeFilter( } VOID PhMwpInitializeServiceMenu( - __in PPH_EMENU Menu, - __in PPH_SERVICE_ITEM *Services, - __in ULONG NumberOfServices + _In_ PPH_EMENU Menu, + _In_ PPH_SERVICE_ITEM *Services, + _In_ ULONG NumberOfServices ) { if (NumberOfServices == 0) @@ -4495,7 +4495,7 @@ VOID PhMwpInitializeServiceMenu( } VOID PhShowServiceContextMenu( - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ) { PPH_SERVICE_ITEM *services; @@ -4556,8 +4556,8 @@ VOID PhShowServiceContextMenu( } VOID PhMwpOnServiceAdded( - __in __assumeRefs(1) PPH_SERVICE_ITEM ServiceItem, - __in ULONG RunId + _In_ _Assume_refs_(1) PPH_SERVICE_ITEM ServiceItem, + _In_ ULONG RunId ) { PPH_SERVICE_NODE serviceNode; @@ -4603,7 +4603,7 @@ VOID PhMwpOnServiceAdded( } VOID PhMwpOnServiceModified( - __in PPH_SERVICE_MODIFIED_DATA ServiceModifiedData + _In_ PPH_SERVICE_MODIFIED_DATA ServiceModifiedData ) { PH_SERVICE_CHANGE serviceChange; @@ -4679,7 +4679,7 @@ VOID PhMwpOnServiceModified( } VOID PhMwpOnServiceRemoved( - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_SERVICE_ITEM ServiceItem ) { if (ServiceTreeListLoaded) @@ -4755,8 +4755,8 @@ VOID PhMwpNeedNetworkTreeList( } BOOLEAN PhMwpCurrentUserNetworkTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { PPH_NETWORK_NODE networkNode = (PPH_NETWORK_NODE)Node; @@ -4771,8 +4771,8 @@ BOOLEAN PhMwpCurrentUserNetworkTreeFilter( } BOOLEAN PhMwpSignedNetworkTreeFilter( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { PPH_NETWORK_NODE networkNode = (PPH_NETWORK_NODE)Node; @@ -4787,9 +4787,9 @@ BOOLEAN PhMwpSignedNetworkTreeFilter( } VOID PhMwpInitializeNetworkMenu( - __in PPH_EMENU Menu, - __in PPH_NETWORK_ITEM *NetworkItems, - __in ULONG NumberOfNetworkItems + _In_ PPH_EMENU Menu, + _In_ PPH_NETWORK_ITEM *NetworkItems, + _In_ ULONG NumberOfNetworkItems ) { ULONG i; @@ -4840,7 +4840,7 @@ VOID PhMwpInitializeNetworkMenu( } VOID PhShowNetworkContextMenu( - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ) { PPH_NETWORK_ITEM *networkItems; @@ -4901,8 +4901,8 @@ VOID PhShowNetworkContextMenu( } VOID PhMwpOnNetworkItemAdded( - __in ULONG RunId, - __in __assumeRefs(1) PPH_NETWORK_ITEM NetworkItem + _In_ ULONG RunId, + _In_ _Assume_refs_(1) PPH_NETWORK_ITEM NetworkItem ) { PPH_NETWORK_NODE networkNode; @@ -4918,14 +4918,14 @@ VOID PhMwpOnNetworkItemAdded( } VOID PhMwpOnNetworkItemModified( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ) { PhUpdateNetworkNode(PhFindNetworkNode(NetworkItem)); } VOID PhMwpOnNetworkItemRemoved( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ) { if (!NetworkNeedsRedraw) diff --git a/2.x/trunk/ProcessHacker/mdump.c b/2.x/trunk/ProcessHacker/mdump.c index 4ddbd01a3..aed223c47 100644 --- a/2.x/trunk/ProcessHacker/mdump.c +++ b/2.x/trunk/ProcessHacker/mdump.c @@ -47,22 +47,22 @@ typedef struct _PROCESS_MINIDUMP_CONTEXT } PROCESS_MINIDUMP_CONTEXT, *PPROCESS_MINIDUMP_CONTEXT; BOOLEAN PhpCreateProcessMiniDumpWithProgress( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PWSTR FileName, - __in MINIDUMP_TYPE DumpType + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PWSTR FileName, + _In_ MINIDUMP_TYPE DumpType ); INT_PTR CALLBACK PhpProcessMiniDumpDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); BOOLEAN PhUiCreateDumpFileProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ) { static PH_FILETYPE_FILTER filters[] = @@ -100,10 +100,10 @@ BOOLEAN PhUiCreateDumpFileProcess( } BOOLEAN PhpCreateProcessMiniDumpWithProgress( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PWSTR FileName, - __in MINIDUMP_TYPE DumpType + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PWSTR FileName, + _In_ MINIDUMP_TYPE DumpType ) { NTSTATUS status; @@ -158,9 +158,9 @@ BOOLEAN PhpCreateProcessMiniDumpWithProgress( } static BOOL CALLBACK PhpProcessMiniDumpCallback( - __in PVOID CallbackParam, - __in const PMINIDUMP_CALLBACK_INPUT CallbackInput, - __inout PMINIDUMP_CALLBACK_OUTPUT CallbackOutput + _In_ PVOID CallbackParam, + _In_ const PMINIDUMP_CALLBACK_INPUT CallbackInput, + _Inout_ PMINIDUMP_CALLBACK_OUTPUT CallbackOutput ) { PPROCESS_MINIDUMP_CONTEXT context = CallbackParam; @@ -209,7 +209,7 @@ static BOOL CALLBACK PhpProcessMiniDumpCallback( } NTSTATUS PhpProcessMiniDumpThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPROCESS_MINIDUMP_CONTEXT context = Parameter; @@ -268,10 +268,10 @@ NTSTATUS PhpProcessMiniDumpThreadStart( } INT_PTR CALLBACK PhpProcessMiniDumpDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/memedit.c b/2.x/trunk/ProcessHacker/memedit.c index 4493a70e0..586d19f1c 100644 --- a/2.x/trunk/ProcessHacker/memedit.c +++ b/2.x/trunk/ProcessHacker/memedit.c @@ -52,26 +52,26 @@ typedef struct _MEMORY_EDITOR_CONTEXT } MEMORY_EDITOR_CONTEXT, *PMEMORY_EDITOR_CONTEXT; INT NTAPI PhpMemoryEditorCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ); INT_PTR CALLBACK PhpMemoryEditorDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); PH_AVL_TREE PhMemoryEditorSet = PH_AVL_TREE_INIT(PhpMemoryEditorCompareFunction); static RECT MinimumSize = { -1, -1, -1, -1 }; VOID PhShowMemoryEditorDialog( - __in HANDLE ProcessId, - __in PVOID BaseAddress, - __in SIZE_T RegionSize, - __in ULONG SelectOffset, - __in ULONG SelectLength + _In_ HANDLE ProcessId, + _In_ PVOID BaseAddress, + _In_ SIZE_T RegionSize, + _In_ ULONG SelectOffset, + _In_ ULONG SelectLength ) { PMEMORY_EDITOR_CONTEXT context; @@ -132,8 +132,8 @@ VOID PhShowMemoryEditorDialog( } INT NTAPI PhpMemoryEditorCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ) { PMEMORY_EDITOR_CONTEXT context1 = CONTAINING_RECORD(Links1, MEMORY_EDITOR_CONTEXT, Links); @@ -143,10 +143,10 @@ INT NTAPI PhpMemoryEditorCompareFunction( } INT_PTR CALLBACK PhpMemoryEditorDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PMEMORY_EDITOR_CONTEXT context; diff --git a/2.x/trunk/ProcessHacker/memlists.c b/2.x/trunk/ProcessHacker/memlists.c index f3d245795..b9b788908 100644 --- a/2.x/trunk/ProcessHacker/memlists.c +++ b/2.x/trunk/ProcessHacker/memlists.c @@ -26,10 +26,10 @@ #define MSG_UPDATE (WM_APP + 1) INT_PTR CALLBACK PhpMemoryListsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); HWND PhMemoryListsWindowHandle = NULL; @@ -37,9 +37,9 @@ static VOID (NTAPI *UnregisterDialogFunction)(HWND); static PH_CALLBACK_REGISTRATION ProcessesUpdatedRegistration; VOID PhShowMemoryListsDialog( - __in HWND ParentWindowHandle, - __in_opt VOID (NTAPI *RegisterDialog)(HWND), - __in_opt VOID (NTAPI *UnregisterDialog)(HWND) + _In_ HWND ParentWindowHandle, + _In_opt_ VOID (NTAPI *RegisterDialog)(HWND), + _In_opt_ VOID (NTAPI *UnregisterDialog)(HWND) ) { if (!PhMemoryListsWindowHandle) @@ -63,15 +63,15 @@ VOID PhShowMemoryListsDialog( } static VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PostMessage(PhMemoryListsWindowHandle, MSG_UPDATE, 0, 0); } static VOID PhpUpdateMemoryListInfo( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { SYSTEM_MEMORY_LIST_INFORMATION memoryListInfo; @@ -155,10 +155,10 @@ static VOID PhpUpdateMemoryListInfo( } INT_PTR CALLBACK PhpMemoryListsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/memprot.c b/2.x/trunk/ProcessHacker/memprot.c index 586f2f22b..c9ce1a7ca 100644 --- a/2.x/trunk/ProcessHacker/memprot.c +++ b/2.x/trunk/ProcessHacker/memprot.c @@ -30,16 +30,16 @@ typedef struct _MEMORY_PROTECT_CONTEXT } MEMORY_PROTECT_CONTEXT, *PMEMORY_PROTECT_CONTEXT; INT_PTR CALLBACK PhpMemoryProtectDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowMemoryProtectDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_MEMORY_ITEM MemoryItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_MEMORY_ITEM MemoryItem ) { MEMORY_PROTECT_CONTEXT context; @@ -57,10 +57,10 @@ VOID PhShowMemoryProtectDialog( } static INT_PTR CALLBACK PhpMemoryProtectDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/memprv.c b/2.x/trunk/ProcessHacker/memprv.c index 07dfa4085..8915d3d4b 100644 --- a/2.x/trunk/ProcessHacker/memprv.c +++ b/2.x/trunk/ProcessHacker/memprv.c @@ -24,8 +24,8 @@ #include VOID PhpMemoryItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); PPH_OBJECT_TYPE PhMemoryItemType; @@ -46,10 +46,10 @@ BOOLEAN PhMemoryProviderInitialization( } VOID PhInitializeMemoryProvider( - __out PPH_MEMORY_PROVIDER Provider, - __in HANDLE ProcessId, - __in PPH_MEMORY_PROVIDER_CALLBACK Callback, - __in_opt PVOID Context + _Out_ PPH_MEMORY_PROVIDER Provider, + _In_ HANDLE ProcessId, + _In_ PPH_MEMORY_PROVIDER_CALLBACK Callback, + _In_opt_ PVOID Context ) { Provider->Callback = Callback; @@ -73,7 +73,7 @@ VOID PhInitializeMemoryProvider( } VOID PhDeleteMemoryProvider( - __inout PPH_MEMORY_PROVIDER Provider + _Inout_ PPH_MEMORY_PROVIDER Provider ) { if (Provider->ProcessHandle) @@ -100,8 +100,8 @@ PPH_MEMORY_ITEM PhCreateMemoryItem( } VOID PhpMemoryItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_MEMORY_ITEM memoryItem = (PPH_MEMORY_ITEM)Object; @@ -111,8 +111,8 @@ VOID PhpMemoryItemDeleteProcedure( } VOID PhGetMemoryProtectionString( - __in ULONG Protection, - __out_ecount(17) PWSTR String + _In_ ULONG Protection, + _Out_writes_(17) PWSTR String ) { PWSTR string; @@ -170,7 +170,7 @@ VOID PhGetMemoryProtectionString( } PWSTR PhGetMemoryStateString( - __in ULONG State + _In_ ULONG State ) { if (State & MEM_COMMIT) @@ -184,7 +184,7 @@ PWSTR PhGetMemoryStateString( } PWSTR PhGetMemoryTypeString( - __in ULONG Type + _In_ ULONG Type ) { if (Type & MEM_PRIVATE) @@ -198,7 +198,7 @@ PWSTR PhGetMemoryTypeString( } VOID PhMemoryProviderUpdate( - __in PPH_MEMORY_PROVIDER Provider + _In_ PPH_MEMORY_PROVIDER Provider ) { PVOID baseAddress; diff --git a/2.x/trunk/ProcessHacker/memrslt.c b/2.x/trunk/ProcessHacker/memrslt.c index e21af5017..ca15d9daf 100644 --- a/2.x/trunk/ProcessHacker/memrslt.c +++ b/2.x/trunk/ProcessHacker/memrslt.c @@ -40,17 +40,17 @@ typedef struct _MEMORY_RESULTS_CONTEXT } MEMORY_RESULTS_CONTEXT, *PMEMORY_RESULTS_CONTEXT; INT_PTR CALLBACK PhpMemoryResultsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static RECT MinimumSize = { -1, -1, -1, -1 }; VOID PhShowMemoryResultsDialog( - __in HANDLE ProcessId, - __in PPH_LIST Results + _In_ HANDLE ProcessId, + _In_ PPH_LIST Results ) { HWND windowHandle; @@ -77,9 +77,9 @@ VOID PhShowMemoryResultsDialog( } static PPH_STRING PhpGetStringForSelectedResults( - __in HWND ListViewHandle, - __in PPH_LIST Results, - __in BOOLEAN All + _In_ HWND ListViewHandle, + _In_ PPH_LIST Results, + _In_ BOOLEAN All ) { PH_STRING_BUILDER stringBuilder; @@ -107,9 +107,9 @@ static PPH_STRING PhpGetStringForSelectedResults( } static VOID FilterResults( - __in HWND hwndDlg, - __in PMEMORY_RESULTS_CONTEXT Context, - __in ULONG Type + _In_ HWND hwndDlg, + _In_ PMEMORY_RESULTS_CONTEXT Context, + _In_ ULONG Type ) { PPH_STRING selectedChoice = NULL; @@ -282,10 +282,10 @@ static VOID FilterResults( } INT_PTR CALLBACK PhpMemoryResultsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PMEMORY_RESULTS_CONTEXT context; diff --git a/2.x/trunk/ProcessHacker/memsrch.c b/2.x/trunk/ProcessHacker/memsrch.c index ccd729d65..fe225b5b9 100644 --- a/2.x/trunk/ProcessHacker/memsrch.c +++ b/2.x/trunk/ProcessHacker/memsrch.c @@ -46,17 +46,17 @@ typedef struct _MEMORY_STRING_CONTEXT } MEMORY_STRING_CONTEXT, *PMEMORY_STRING_CONTEXT; INT_PTR CALLBACK PhpMemoryStringDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpMemoryStringProgressDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); PVOID PhMemorySearchHeap = NULL; @@ -64,7 +64,7 @@ LONG PhMemorySearchHeapRefCount = 0; PH_QUEUED_LOCK PhMemorySearchHeapLock = PH_QUEUED_LOCK_INIT; PVOID PhAllocateForMemorySearch( - __in SIZE_T Size + _In_ SIZE_T Size ) { PVOID memory; @@ -103,7 +103,7 @@ PVOID PhAllocateForMemorySearch( } VOID PhFreeForMemorySearch( - __in __post_invalid PVOID Memory + _In_ _Post_invalid_ PVOID Memory ) { PhAcquireQueuedLockExclusive(&PhMemorySearchHeapLock); @@ -120,8 +120,8 @@ VOID PhFreeForMemorySearch( } PVOID PhCreateMemoryResult( - __in PVOID Address, - __in SIZE_T Length + _In_ PVOID Address, + _In_ SIZE_T Length ) { PPH_MEMORY_RESULT result; @@ -141,14 +141,14 @@ PVOID PhCreateMemoryResult( } VOID PhReferenceMemoryResult( - __in PPH_MEMORY_RESULT Result + _In_ PPH_MEMORY_RESULT Result ) { _InterlockedIncrement(&Result->RefCount); } VOID PhDereferenceMemoryResult( - __in PPH_MEMORY_RESULT Result + _In_ PPH_MEMORY_RESULT Result ) { if (_InterlockedDecrement(&Result->RefCount) == 0) @@ -161,8 +161,8 @@ VOID PhDereferenceMemoryResult( } VOID PhDereferenceMemoryResults( - __in_ecount(NumberOfResults) PPH_MEMORY_RESULT *Results, - __in ULONG NumberOfResults + _In_reads_(NumberOfResults) PPH_MEMORY_RESULT *Results, + _In_ ULONG NumberOfResults ) { ULONG i; @@ -172,8 +172,8 @@ VOID PhDereferenceMemoryResults( } VOID PhSearchMemoryString( - __in HANDLE ProcessHandle, - __in PPH_MEMORY_STRING_OPTIONS Options + _In_ HANDLE ProcessHandle, + _In_ PPH_MEMORY_STRING_OPTIONS Options ) { ULONG minimumLength; @@ -461,8 +461,8 @@ VOID PhSearchMemoryString( } VOID PhShowMemoryStringDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ) { NTSTATUS status; @@ -522,10 +522,10 @@ VOID PhShowMemoryStringDialog( } INT_PTR CALLBACK PhpMemoryStringDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -581,8 +581,8 @@ INT_PTR CALLBACK PhpMemoryStringDlgProc( } static BOOL NTAPI PhpMemoryStringResultCallback( - __in __assumeRefs(1) PPH_MEMORY_RESULT Result, - __in_opt PVOID Context + _In_ _Assume_refs_(1) PPH_MEMORY_RESULT Result, + _In_opt_ PVOID Context ) { PMEMORY_STRING_CONTEXT context = Context; @@ -593,7 +593,7 @@ static BOOL NTAPI PhpMemoryStringResultCallback( } NTSTATUS PhpMemoryStringThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PMEMORY_STRING_CONTEXT context = Parameter; @@ -623,10 +623,10 @@ NTSTATUS PhpMemoryStringThreadStart( } INT_PTR CALLBACK PhpMemoryStringProgressDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/modlist.c b/2.x/trunk/ProcessHacker/modlist.c index 4a2e2676e..50a81d5b8 100644 --- a/2.x/trunk/ProcessHacker/modlist.c +++ b/2.x/trunk/ProcessHacker/modlist.c @@ -2,7 +2,7 @@ * Process Hacker - * module list * - * Copyright (C) 2010-2012 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -27,43 +27,43 @@ #include BOOLEAN PhpModuleNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG PhpModuleNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID PhpDestroyModuleNode( - __in PPH_MODULE_NODE ModuleNode + _In_ PPH_MODULE_NODE ModuleNode ); VOID PhpRemoveModuleNode( - __in PPH_MODULE_NODE ModuleNode, - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_NODE ModuleNode, + _In_ PPH_MODULE_LIST_CONTEXT Context ); LONG PhpModuleTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ); BOOLEAN NTAPI PhpModuleTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); VOID PhInitializeModuleList( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __out PPH_MODULE_LIST_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _Out_ PPH_MODULE_LIST_CONTEXT Context ) { HWND hwnd; @@ -114,7 +114,7 @@ VOID PhInitializeModuleList( } VOID PhDeleteModuleList( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ) { ULONG i; @@ -132,8 +132,8 @@ VOID PhDeleteModuleList( } BOOLEAN PhpModuleNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_MODULE_NODE moduleNode1 = *(PPH_MODULE_NODE *)Entry1; @@ -143,7 +143,7 @@ BOOLEAN PhpModuleNodeHashtableCompareFunction( } ULONG PhpModuleNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { #ifdef _M_IX86 @@ -154,7 +154,7 @@ ULONG PhpModuleNodeHashtableHashFunction( } VOID PhLoadSettingsModuleList( - __inout PPH_MODULE_LIST_CONTEXT Context + _Inout_ PPH_MODULE_LIST_CONTEXT Context ) { PPH_STRING settings; @@ -168,7 +168,7 @@ VOID PhLoadSettingsModuleList( } VOID PhSaveSettingsModuleList( - __inout PPH_MODULE_LIST_CONTEXT Context + _Inout_ PPH_MODULE_LIST_CONTEXT Context ) { PPH_STRING settings; @@ -182,9 +182,9 @@ VOID PhSaveSettingsModuleList( } PPH_MODULE_NODE PhAddModuleNode( - __inout PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_ITEM ModuleItem, - __in ULONG RunId + _Inout_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_ITEM ModuleItem, + _In_ ULONG RunId ) { PPH_MODULE_NODE moduleNode; @@ -223,8 +223,8 @@ PPH_MODULE_NODE PhAddModuleNode( } PPH_MODULE_NODE PhFindModuleNode( - __in PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_ITEM ModuleItem + _In_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_ITEM ModuleItem ) { PH_MODULE_NODE lookupModuleNode; @@ -245,8 +245,8 @@ PPH_MODULE_NODE PhFindModuleNode( } VOID PhRemoveModuleNode( - __in PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_NODE ModuleNode + _In_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_NODE ModuleNode ) { // Remove from the hashtable here to avoid problems in case the key is re-used. @@ -270,7 +270,7 @@ VOID PhRemoveModuleNode( } VOID PhpDestroyModuleNode( - __in PPH_MODULE_NODE ModuleNode + _In_ PPH_MODULE_NODE ModuleNode ) { PhEmCallObjectOperation(EmModuleNodeType, ModuleNode, EmObjectDelete); @@ -286,8 +286,8 @@ VOID PhpDestroyModuleNode( } VOID PhpRemoveModuleNode( - __in PPH_MODULE_NODE ModuleNode, - __in PPH_MODULE_LIST_CONTEXT Context // PH_TICK_SH_STATE requires this parameter to be after ModuleNode + _In_ PPH_MODULE_NODE ModuleNode, + _In_ PPH_MODULE_LIST_CONTEXT Context // PH_TICK_SH_STATE requires this parameter to be after ModuleNode ) { ULONG index; @@ -303,8 +303,8 @@ VOID PhpRemoveModuleNode( } VOID PhUpdateModuleNode( - __in PPH_MODULE_LIST_CONTEXT Context, - __in PPH_MODULE_NODE ModuleNode + _In_ PPH_MODULE_LIST_CONTEXT Context, + _In_ PPH_MODULE_NODE ModuleNode ) { memset(ModuleNode->TextCache, 0, sizeof(PH_STRINGREF) * PHMOTLC_MAXIMUM); @@ -316,7 +316,7 @@ VOID PhUpdateModuleNode( } VOID PhTickModuleNodes( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ) { PH_TICK_SH_STATE_TN(PH_MODULE_NODE, ShState, Context->NodeStateList, PhpRemoveModuleNode, PhCsHighlightingDuration, Context->TreeNewHandle, TRUE, NULL, Context); @@ -325,9 +325,9 @@ VOID PhTickModuleNodes( #define SORT_FUNCTION(Column) PhpModuleTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpModuleTreeNewCompare##Column( \ - __in void *_context, \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ void *_context, \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PPH_MODULE_NODE node1 = *(PPH_MODULE_NODE *)_elem1; \ @@ -344,10 +344,10 @@ VOID PhTickModuleNodes( } LONG PhpModuleTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ) { if (Result == 0) @@ -459,11 +459,11 @@ BEGIN_SORT_FUNCTION(TimeStamp) END_SORT_FUNCTION BOOLEAN NTAPI PhpModuleTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PPH_MODULE_LIST_CONTEXT context; @@ -767,11 +767,18 @@ BOOLEAN NTAPI PhpModuleTreeNewCallback( if (GetKeyState(VK_CONTROL) < 0) TreeNew_SelectRange(context->TreeNewHandle, 0, -1); break; + case 'M': + if (GetKeyState(VK_CONTROL) < 0) + SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_MODULE_SEARCHONLINE, 0); + break; case VK_DELETE: SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_MODULE_UNLOAD, 0); break; case VK_RETURN: - SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_MODULE_INSPECT, 0); + if (GetKeyState(VK_CONTROL) >= 0) + SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_MODULE_INSPECT, 0); + else + SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_MODULE_OPENFILELOCATION, 0); break; } } @@ -821,7 +828,7 @@ BOOLEAN NTAPI PhpModuleTreeNewCallback( } PPH_MODULE_ITEM PhGetSelectedModuleItem( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ) { PPH_MODULE_ITEM moduleItem = NULL; @@ -842,9 +849,9 @@ PPH_MODULE_ITEM PhGetSelectedModuleItem( } VOID PhGetSelectedModuleItems( - __in PPH_MODULE_LIST_CONTEXT Context, - __out PPH_MODULE_ITEM **Modules, - __out PULONG NumberOfModules + _In_ PPH_MODULE_LIST_CONTEXT Context, + _Out_ PPH_MODULE_ITEM **Modules, + _Out_ PULONG NumberOfModules ) { PPH_LIST list; @@ -869,7 +876,7 @@ VOID PhGetSelectedModuleItems( } VOID PhDeselectAllModuleNodes( - __in PPH_MODULE_LIST_CONTEXT Context + _In_ PPH_MODULE_LIST_CONTEXT Context ) { TreeNew_DeselectRange(Context->TreeNewHandle, 0, -1); diff --git a/2.x/trunk/ProcessHacker/modprv.c b/2.x/trunk/ProcessHacker/modprv.c index f431cee72..5e2bb679f 100644 --- a/2.x/trunk/ProcessHacker/modprv.c +++ b/2.x/trunk/ProcessHacker/modprv.c @@ -2,7 +2,7 @@ * Process Hacker - * module provider * - * Copyright (C) 2009-2011 wj32 + * Copyright (C) 2009-2013 wj32 * * This file is part of Process Hacker. * @@ -35,22 +35,22 @@ typedef struct _PH_MODULE_QUERY_DATA } PH_MODULE_QUERY_DATA, *PPH_MODULE_QUERY_DATA; VOID NTAPI PhpModuleProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); VOID NTAPI PhpModuleItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); BOOLEAN NTAPI PhpModuleHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI PhpModuleHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); PPH_OBJECT_TYPE PhModuleProviderType; @@ -80,9 +80,10 @@ BOOLEAN PhModuleProviderInitialization( } PPH_MODULE_PROVIDER PhCreateModuleProvider( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { + NTSTATUS status; PPH_MODULE_PROVIDER moduleProvider; if (!NT_SUCCESS(PhCreateObject( @@ -108,11 +109,13 @@ PPH_MODULE_PROVIDER PhCreateModuleProvider( moduleProvider->ProcessId = ProcessId; moduleProvider->ProcessHandle = NULL; + moduleProvider->PackageFullName = NULL; + moduleProvider->RunStatus = STATUS_SUCCESS; // It doesn't matter if we can't get a process handle. // Try to get a handle with query information + vm read access. - if (!NT_SUCCESS(PhOpenProcess( + if (!NT_SUCCESS(status = PhOpenProcess( &moduleProvider->ProcessHandle, PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, ProcessId @@ -121,22 +124,27 @@ PPH_MODULE_PROVIDER PhCreateModuleProvider( if (WINDOWS_HAS_LIMITED_ACCESS) { // Try to get a handle with query limited information + vm read access. - PhOpenProcess( + status = PhOpenProcess( &moduleProvider->ProcessHandle, PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ, ProcessId ); } + + moduleProvider->RunStatus = status; } + if (moduleProvider->ProcessHandle) + moduleProvider->PackageFullName = PhGetProcessPackageFullName(moduleProvider->ProcessHandle); + RtlInitializeSListHead(&moduleProvider->QueryListHead); return moduleProvider; } VOID PhpModuleProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_MODULE_PROVIDER moduleProvider = (PPH_MODULE_PROVIDER)Object; @@ -170,6 +178,7 @@ VOID PhpModuleProviderDeleteProcedure( } } + if (moduleProvider->PackageFullName) PhDereferenceObject(moduleProvider->PackageFullName); if (moduleProvider->ProcessHandle) NtClose(moduleProvider->ProcessHandle); } @@ -194,8 +203,8 @@ PPH_MODULE_ITEM PhCreateModuleItem( } VOID PhpModuleItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_MODULE_ITEM moduleItem = (PPH_MODULE_ITEM)Object; @@ -209,8 +218,8 @@ VOID PhpModuleItemDeleteProcedure( } BOOLEAN NTAPI PhpModuleHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { return @@ -219,7 +228,7 @@ BOOLEAN NTAPI PhpModuleHashtableCompareFunction( } ULONG NTAPI PhpModuleHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PVOID baseAddress = (*(PPH_MODULE_ITEM *)Entry)->BaseAddress; @@ -232,8 +241,8 @@ ULONG NTAPI PhpModuleHashtableHashFunction( } PPH_MODULE_ITEM PhReferenceModuleItem( - __in PPH_MODULE_PROVIDER ModuleProvider, - __in PVOID BaseAddress + _In_ PPH_MODULE_PROVIDER ModuleProvider, + _In_ PVOID BaseAddress ) { PH_MODULE_ITEM lookupModuleItem; @@ -266,7 +275,7 @@ PPH_MODULE_ITEM PhReferenceModuleItem( } VOID PhDereferenceAllModuleItems( - __in PPH_MODULE_PROVIDER ModuleProvider + _In_ PPH_MODULE_PROVIDER ModuleProvider ) { ULONG enumerationKey = 0; @@ -282,9 +291,9 @@ VOID PhDereferenceAllModuleItems( PhReleaseFastLockExclusive(&ModuleProvider->ModuleHashtableLock); } -__assumeLocked VOID PhpRemoveModuleItem( - __in PPH_MODULE_PROVIDER ModuleProvider, - __in PPH_MODULE_ITEM ModuleItem +VOID PhpRemoveModuleItem( + _In_ PPH_MODULE_PROVIDER ModuleProvider, + _In_ PPH_MODULE_ITEM ModuleItem ) { PhRemoveEntryHashtable(ModuleProvider->ModuleHashtable, &ModuleItem); @@ -292,13 +301,14 @@ __assumeLocked VOID PhpRemoveModuleItem( } NTSTATUS PhpModuleQueryWorker( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_MODULE_QUERY_DATA data = (PPH_MODULE_QUERY_DATA)Parameter; data->VerifyResult = PhVerifyFileCached( data->ModuleItem->FileName, + PhGetString(data->ModuleProvider->PackageFullName), &data->VerifySignerName, FALSE ); @@ -311,8 +321,8 @@ NTSTATUS PhpModuleQueryWorker( } VOID PhpQueueModuleQuery( - __in PPH_MODULE_PROVIDER ModuleProvider, - __in PPH_MODULE_ITEM ModuleItem + _In_ PPH_MODULE_PROVIDER ModuleProvider, + _In_ PPH_MODULE_ITEM ModuleItem ) { PPH_MODULE_QUERY_DATA data; @@ -331,8 +341,8 @@ VOID PhpQueueModuleQuery( } static BOOLEAN NTAPI EnumModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PPH_MODULE_INFO copy; @@ -347,7 +357,7 @@ static BOOLEAN NTAPI EnumModulesCallback( } VOID PhModuleProviderUpdate( - __in PVOID Object + _In_ PVOID Object ) { PPH_MODULE_PROVIDER moduleProvider = (PPH_MODULE_PROVIDER)Object; @@ -358,11 +368,11 @@ VOID PhModuleProviderUpdate( // abort (unless this is the System process - in that case // we don't need a handle). if (!moduleProvider->ProcessHandle && moduleProvider->ProcessId != SYSTEM_PROCESS_ID) - return; + goto UpdateExit; modules = PhCreateList(20); - PhEnumGenericModules( + moduleProvider->RunStatus = PhEnumGenericModules( moduleProvider->ProcessId, moduleProvider->ProcessHandle, PH_ENUM_GENERIC_MAPPED_FILES | PH_ENUM_GENERIC_MAPPED_IMAGES, @@ -525,7 +535,7 @@ VOID PhModuleProviderUpdate( { // See if the file has already been verified; if not, queue for verification. - moduleItem->VerifyResult = PhVerifyFileCached(moduleItem->FileName, &moduleItem->VerifySignerName, TRUE); + moduleItem->VerifyResult = PhVerifyFileCached(moduleItem->FileName, NULL, &moduleItem->VerifySignerName, TRUE); if (moduleItem->VerifyResult == VrUnknown) PhpQueueModuleQuery(moduleProvider, moduleItem); @@ -568,5 +578,6 @@ VOID PhModuleProviderUpdate( PhDereferenceObject(modules); +UpdateExit: PhInvokeCallback(&moduleProvider->UpdatedEvent, NULL); } diff --git a/2.x/trunk/ProcessHacker/netlist.c b/2.x/trunk/ProcessHacker/netlist.c index 55ac9dfd5..5fe414b3b 100644 --- a/2.x/trunk/ProcessHacker/netlist.c +++ b/2.x/trunk/ProcessHacker/netlist.c @@ -28,39 +28,39 @@ #include BOOLEAN PhpNetworkNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG PhpNetworkNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID PhpRemoveNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ); LONG PhpNetworkTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ); BOOLEAN NTAPI PhpNetworkTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); PPH_STRING PhpGetNetworkItemProcessName( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ); VOID PhpUpdateNetworkNodeAddressStrings( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ); static HWND NetworkTreeListHandle; @@ -91,8 +91,8 @@ VOID PhNetworkTreeListInitialization( } BOOLEAN PhpNetworkNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_NETWORK_NODE networkNode1 = *(PPH_NETWORK_NODE *)Entry1; @@ -102,7 +102,7 @@ BOOLEAN PhpNetworkNodeHashtableCompareFunction( } ULONG PhpNetworkNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { #ifdef _M_IX86 @@ -113,7 +113,7 @@ ULONG PhpNetworkNodeHashtableHashFunction( } VOID PhInitializeNetworkTreeList( - __in HWND hwnd + _In_ HWND hwnd ) { NetworkTreeListHandle = hwnd; @@ -189,8 +189,8 @@ struct _PH_TN_FILTER_SUPPORT *PhGetFilterSupportNetworkTreeList( } PPH_NETWORK_NODE PhAddNetworkNode( - __in PPH_NETWORK_ITEM NetworkItem, - __in ULONG RunId + _In_ PPH_NETWORK_ITEM NetworkItem, + _In_ ULONG RunId ) { PPH_NETWORK_NODE networkNode; @@ -236,7 +236,7 @@ PPH_NETWORK_NODE PhAddNetworkNode( } PPH_NETWORK_NODE PhFindNetworkNode( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ) { PH_NETWORK_NODE lookupNetworkNode; @@ -257,7 +257,7 @@ PPH_NETWORK_NODE PhFindNetworkNode( } VOID PhRemoveNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ) { // Remove from the hashtable here to avoid problems in case the key is re-used. @@ -281,7 +281,7 @@ VOID PhRemoveNetworkNode( } VOID PhpRemoveNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ) { ULONG index; @@ -305,7 +305,7 @@ VOID PhpRemoveNetworkNode( } VOID PhUpdateNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ) { memset(NetworkNode->TextCache, 0, sizeof(PH_STRINGREF) * PHNETLC_MAXIMUM); @@ -333,8 +333,8 @@ VOID PhTickNetworkNodes( #define SORT_FUNCTION(Column) PhpNetworkTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpNetworkTreeNewCompare##Column( \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PPH_NETWORK_NODE node1 = *(PPH_NETWORK_NODE *)_elem1; \ @@ -351,10 +351,10 @@ VOID PhTickNetworkNodes( } LONG PhpNetworkTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ) { if (Result == 0) @@ -418,11 +418,11 @@ BEGIN_SORT_FUNCTION(TimeStamp) END_SORT_FUNCTION BOOLEAN NTAPI PhpNetworkTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PPH_NETWORK_NODE node; @@ -658,7 +658,7 @@ BOOLEAN NTAPI PhpNetworkTreeNewCallback( } PPH_STRING PhpGetNetworkItemProcessName( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ) { PH_FORMAT format[4]; @@ -679,7 +679,7 @@ PPH_STRING PhpGetNetworkItemProcessName( } VOID PhpUpdateNetworkNodeAddressStrings( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ) { if (NetworkNode->NetworkItem->LocalHostString) @@ -715,8 +715,8 @@ PPH_NETWORK_ITEM PhGetSelectedNetworkItem( } VOID PhGetSelectedNetworkItems( - __out PPH_NETWORK_ITEM **NetworkItems, - __out PULONG NumberOfNetworkItems + _Out_ PPH_NETWORK_ITEM **NetworkItems, + _Out_ PULONG NumberOfNetworkItems ) { PPH_LIST list; @@ -748,7 +748,7 @@ VOID PhDeselectAllNetworkNodes( } VOID PhSelectAndEnsureVisibleNetworkNode( - __in PPH_NETWORK_NODE NetworkNode + _In_ PPH_NETWORK_NODE NetworkNode ) { PhDeselectAllNetworkNodes(); @@ -774,8 +774,8 @@ VOID PhCopyNetworkList( } VOID PhWriteNetworkList( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ) { PPH_LIST lines; diff --git a/2.x/trunk/ProcessHacker/netprv.c b/2.x/trunk/ProcessHacker/netprv.c index 00169d8c2..916825b3f 100644 --- a/2.x/trunk/ProcessHacker/netprv.c +++ b/2.x/trunk/ProcessHacker/netprv.c @@ -56,72 +56,72 @@ typedef struct _PHP_RESOLVE_CACHE_ITEM } PHP_RESOLVE_CACHE_ITEM, *PPHP_RESOLVE_CACHE_ITEM; typedef DWORD (WINAPI *_GetExtendedTcpTable)( - __out_bcount_opt(*pdwSize) PVOID pTcpTable, - __inout PDWORD pdwSize, - __in BOOL bOrder, - __in ULONG ulAf, - __in TCP_TABLE_CLASS TableClass, - __in ULONG Reserved + _Out_writes_bytes_opt_(*pdwSize) PVOID pTcpTable, + _Inout_ PDWORD pdwSize, + _In_ BOOL bOrder, + _In_ ULONG ulAf, + _In_ TCP_TABLE_CLASS TableClass, + _In_ ULONG Reserved ); typedef DWORD (WINAPI *_GetExtendedUdpTable)( - __out_bcount_opt(*pdwSize) PVOID pUdpTable, - __inout PDWORD pdwSize, - __in BOOL bOrder, - __in ULONG ulAf, - __in UDP_TABLE_CLASS TableClass, - __in ULONG Reserved + _Out_writes_bytes_opt_(*pdwSize) PVOID pUdpTable, + _Inout_ PDWORD pdwSize, + _In_ BOOL bOrder, + _In_ ULONG ulAf, + _In_ UDP_TABLE_CLASS TableClass, + _In_ ULONG Reserved ); typedef int (WSAAPI *_WSAStartup)( - __in WORD wVersionRequested, - __out LPWSADATA lpWSAData + _In_ WORD wVersionRequested, + _Out_ LPWSADATA lpWSAData ); typedef int (WSAAPI *_WSAGetLastError)(); typedef INT (WSAAPI *_GetNameInfoW)( - __in_bcount(SockaddrLength) const SOCKADDR *pSockaddr, - __in socklen_t SockaddrLength, - __out_ecount_opt(NodeBufferSize) PWCHAR pNodeBuffer, - __in DWORD NodeBufferSize, - __out_ecount_opt(ServiceBufferSize) PWCHAR pServiceBuffer, - __in DWORD ServiceBufferSize, - __in INT Flags + _In_reads_bytes_(SockaddrLength) const SOCKADDR *pSockaddr, + _In_ socklen_t SockaddrLength, + _Out_writes_opt_(NodeBufferSize) PWCHAR pNodeBuffer, + _In_ DWORD NodeBufferSize, + _Out_writes_opt_(ServiceBufferSize) PWCHAR pServiceBuffer, + _In_ DWORD ServiceBufferSize, + _In_ INT Flags ); typedef struct hostent *(WSAAPI *_gethostbyaddr)( - __in_bcount(len) const char *addr, - __in int len, - __in int type + _In_reads_bytes_(len) const char *addr, + _In_ int len, + _In_ int type ); VOID NTAPI PhpNetworkItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); BOOLEAN PhpNetworkHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI PhpNetworkHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); BOOLEAN PhpResolveCacheHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI PhpResolveCacheHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); BOOLEAN PhGetNetworkConnections( - __out PPH_NETWORK_CONNECTION *Connections, - __out PULONG NumberOfConnections + _Out_ PPH_NETWORK_CONNECTION *Connections, + _Out_ PULONG NumberOfConnections ); PPH_OBJECT_TYPE PhNetworkItemType; @@ -203,8 +203,8 @@ PPH_NETWORK_ITEM PhCreateNetworkItem( } VOID NTAPI PhpNetworkItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_NETWORK_ITEM networkItem = (PPH_NETWORK_ITEM)Object; @@ -222,8 +222,8 @@ VOID NTAPI PhpNetworkItemDeleteProcedure( } BOOLEAN PhpNetworkHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_NETWORK_ITEM networkItem1 = *(PPH_NETWORK_ITEM *)Entry1; @@ -237,7 +237,7 @@ BOOLEAN PhpNetworkHashtableCompareFunction( } ULONG NTAPI PhpNetworkHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PPH_NETWORK_ITEM networkItem = *(PPH_NETWORK_ITEM *)Entry; @@ -250,10 +250,10 @@ ULONG NTAPI PhpNetworkHashtableHashFunction( } PPH_NETWORK_ITEM PhReferenceNetworkItem( - __in ULONG ProtocolType, - __in PPH_IP_ENDPOINT LocalEndpoint, - __in PPH_IP_ENDPOINT RemoteEndpoint, - __in HANDLE ProcessId + _In_ ULONG ProtocolType, + _In_ PPH_IP_ENDPOINT LocalEndpoint, + _In_ PPH_IP_ENDPOINT RemoteEndpoint, + _In_ HANDLE ProcessId ) { PH_NETWORK_ITEM lookupNetworkItem; @@ -288,8 +288,8 @@ PPH_NETWORK_ITEM PhReferenceNetworkItem( return networkItem; } -__assumeLocked VOID PhpRemoveNetworkItem( - __in PPH_NETWORK_ITEM NetworkItem +VOID PhpRemoveNetworkItem( + _In_ PPH_NETWORK_ITEM NetworkItem ) { PhRemoveEntryHashtable(PhNetworkHashtable, &NetworkItem); @@ -297,8 +297,8 @@ __assumeLocked VOID PhpRemoveNetworkItem( } BOOLEAN PhpResolveCacheHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPHP_RESOLVE_CACHE_ITEM cacheItem1 = *(PPHP_RESOLVE_CACHE_ITEM *)Entry1; @@ -308,7 +308,7 @@ BOOLEAN PhpResolveCacheHashtableCompareFunction( } ULONG NTAPI PhpResolveCacheHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PPHP_RESOLVE_CACHE_ITEM cacheItem = *(PPHP_RESOLVE_CACHE_ITEM *)Entry; @@ -316,8 +316,8 @@ ULONG NTAPI PhpResolveCacheHashtableHashFunction( return PhHashIpAddress(&cacheItem->Address); } -__assumeLocked PPHP_RESOLVE_CACHE_ITEM PhpLookupResolveCacheItem( - __in PPH_IP_ADDRESS Address +PPHP_RESOLVE_CACHE_ITEM PhpLookupResolveCacheItem( + _In_ PPH_IP_ADDRESS Address ) { PHP_RESOLVE_CACHE_ITEM lookupCacheItem; @@ -339,7 +339,7 @@ __assumeLocked PPHP_RESOLVE_CACHE_ITEM PhpLookupResolveCacheItem( } PPH_STRING PhGetHostNameFromAddress( - __in PPH_IP_ADDRESS Address + _In_ PPH_IP_ADDRESS Address ) { struct sockaddr_in ipv4Address; @@ -412,7 +412,7 @@ PPH_STRING PhGetHostNameFromAddress( } NTSTATUS PhpNetworkItemQueryWorker( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_NETWORK_ITEM_QUERY_DATA data = (PPH_NETWORK_ITEM_QUERY_DATA)Parameter; @@ -468,8 +468,8 @@ NTSTATUS PhpNetworkItemQueryWorker( } VOID PhpQueueNetworkItemQuery( - __in PPH_NETWORK_ITEM NetworkItem, - __in BOOLEAN Remote + _In_ PPH_NETWORK_ITEM NetworkItem, + _In_ BOOLEAN Remote ) { PPH_NETWORK_ITEM_QUERY_DATA data; @@ -499,8 +499,8 @@ VOID PhpQueueNetworkItemQuery( } VOID PhpUpdateNetworkItemOwner( - __in PPH_NETWORK_ITEM NetworkItem, - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_NETWORK_ITEM NetworkItem, + _In_ PPH_PROCESS_ITEM ProcessItem ) { if (*(PULONG64)NetworkItem->OwnerInfo) @@ -518,7 +518,7 @@ VOID PhpUpdateNetworkItemOwner( } VOID PhNetworkProviderUpdate( - __in PVOID Object + _In_ PVOID Object ) { PPH_NETWORK_CONNECTION connections; @@ -799,7 +799,7 @@ VOID PhNetworkProviderUpdate( } PWSTR PhGetProtocolTypeName( - __in ULONG ProtocolType + _In_ ULONG ProtocolType ) { switch (ProtocolType) @@ -818,7 +818,7 @@ PWSTR PhGetProtocolTypeName( } PWSTR PhGetTcpStateName( - __in ULONG State + _In_ ULONG State ) { switch (State) @@ -853,8 +853,8 @@ PWSTR PhGetTcpStateName( } BOOLEAN PhGetNetworkConnections( - __out PPH_NETWORK_CONNECTION *Connections, - __out PULONG NumberOfConnections + _Out_ PPH_NETWORK_CONNECTION *Connections, + _Out_ PULONG NumberOfConnections ) { PVOID table; diff --git a/2.x/trunk/ProcessHacker/netstk.c b/2.x/trunk/ProcessHacker/netstk.c index f15642484..299b3a125 100644 --- a/2.x/trunk/ProcessHacker/netstk.c +++ b/2.x/trunk/ProcessHacker/netstk.c @@ -31,17 +31,17 @@ typedef struct NETWORK_STACK_CONTEXT } NETWORK_STACK_CONTEXT, *PNETWORK_STACK_CONTEXT; INT_PTR CALLBACK PhpNetworkStackDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static RECT MinimumSize = { -1, -1, -1, -1 }; static BOOLEAN LoadSymbolsEnumGenericModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PNETWORK_STACK_CONTEXT context = Context; @@ -68,8 +68,8 @@ static BOOLEAN LoadSymbolsEnumGenericModulesCallback( } VOID PhShowNetworkStackDialog( - __in HWND ParentWindowHandle, - __in PPH_NETWORK_ITEM NetworkItem + _In_ HWND ParentWindowHandle, + _In_ PPH_NETWORK_ITEM NetworkItem ) { NETWORK_STACK_CONTEXT networkStackContext; @@ -117,10 +117,10 @@ VOID PhShowNetworkStackDialog( } static INT_PTR CALLBACK PhpNetworkStackDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/notifico.c b/2.x/trunk/ProcessHacker/notifico.c index 51a79581a..cb807724c 100644 --- a/2.x/trunk/ProcessHacker/notifico.c +++ b/2.x/trunk/ProcessHacker/notifico.c @@ -32,36 +32,36 @@ HICON PhNfpGetBlackIcon( ); BOOLEAN PhNfpAddNotifyIcon( - __in ULONG Id + _In_ ULONG Id ); BOOLEAN PhNfpRemoveNotifyIcon( - __in ULONG Id + _In_ ULONG Id ); BOOLEAN PhNfpModifyNotifyIcon( - __in ULONG Id, - __in ULONG Flags, - __in_opt PWSTR Text, - __in_opt HICON Icon + _In_ ULONG Id, + _In_ ULONG Flags, + _In_opt_ PWSTR Text, + _In_opt_ HICON Icon ); VOID PhNfpProcessesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID PhNfpUpdateRegisteredIcon( - __in PPH_NF_ICON Icon + _In_ PPH_NF_ICON Icon ); VOID PhNfpBeginBitmap( - __out PULONG Width, - __out PULONG Height, - __out HBITMAP *Bitmap, - __out_opt PVOID *Bits, - __out HDC *Hdc, - __out HBITMAP *OldBitmap + _Out_ PULONG Width, + _Out_ PULONG Height, + _Out_ HBITMAP *Bitmap, + _Out_opt_ PVOID *Bits, + _Out_ HDC *Hdc, + _Out_ HBITMAP *OldBitmap ); VOID PhNfpUpdateIconCpuHistory( @@ -218,8 +218,8 @@ VOID PhNfUninitialization( } VOID PhNfForwardMessage( - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ) { ULONG iconIndex; @@ -275,15 +275,15 @@ ULONG PhNfGetMaximumIconId( } ULONG PhNfTestIconMask( - __in ULONG Id + _In_ ULONG Id ) { return PhNfIconMask & Id; } VOID PhNfSetVisibleIcon( - __in ULONG Id, - __in BOOLEAN Visible + _In_ ULONG Id, + _In_ BOOLEAN Visible ) { if (Visible) @@ -299,11 +299,11 @@ VOID PhNfSetVisibleIcon( } BOOLEAN PhNfShowBalloonTip( - __in_opt ULONG Id, - __in PWSTR Title, - __in PWSTR Text, - __in ULONG Timeout, - __in ULONG Flags + _In_opt_ ULONG Id, + _In_ PWSTR Title, + _In_ PWSTR Text, + _In_ ULONG Timeout, + _In_ ULONG Flags ) { NOTIFYICONDATA notifyIcon = { NOTIFYICONDATA_V3_SIZE }; @@ -331,7 +331,7 @@ BOOLEAN PhNfShowBalloonTip( } HICON PhNfBitmapToIcon( - __in HBITMAP Bitmap + _In_ HBITMAP Bitmap ) { ICONINFO iconInfo; @@ -348,13 +348,13 @@ HICON PhNfBitmapToIcon( } PPH_NF_ICON PhNfRegisterIcon( - __in struct _PH_PLUGIN *Plugin, - __in ULONG SubId, - __in_opt PVOID Context, - __in PWSTR Text, - __reserved ULONG Flags, - __in_opt PPH_NF_ICON_UPDATE_CALLBACK UpdateCallback, - __in_opt PPH_NF_ICON_MESSAGE_CALLBACK MessageCallback + _In_ struct _PH_PLUGIN *Plugin, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_ PWSTR Text, + _In_ ULONG Flags, + _In_opt_ PPH_NF_ICON_UPDATE_CALLBACK UpdateCallback, + _In_opt_ PPH_NF_ICON_MESSAGE_CALLBACK MessageCallback ) { PPH_NF_ICON icon; @@ -395,7 +395,7 @@ PPH_NF_ICON PhNfRegisterIcon( } PPH_NF_ICON PhNfGetIconById( - __in ULONG Id + _In_ ULONG Id ) { ULONG iconIndex; @@ -407,8 +407,8 @@ PPH_NF_ICON PhNfGetIconById( } PPH_NF_ICON PhNfFindIcon( - __in PPH_STRINGREF PluginName, - __in ULONG SubId + _In_ PPH_STRINGREF PluginName, + _In_ ULONG SubId ) { ULONG i; @@ -450,7 +450,7 @@ HICON PhNfpGetBlackIcon( } BOOLEAN PhNfpAddNotifyIcon( - __in ULONG Id + _In_ ULONG Id ) { NOTIFYICONDATA notifyIcon = { NOTIFYICONDATA_V3_SIZE }; @@ -479,7 +479,7 @@ BOOLEAN PhNfpAddNotifyIcon( } BOOLEAN PhNfpRemoveNotifyIcon( - __in ULONG Id + _In_ ULONG Id ) { NOTIFYICONDATA notifyIcon = { NOTIFYICONDATA_V3_SIZE }; @@ -500,10 +500,10 @@ BOOLEAN PhNfpRemoveNotifyIcon( } BOOLEAN PhNfpModifyNotifyIcon( - __in ULONG Id, - __in ULONG Flags, - __in_opt PWSTR Text, - __in_opt HICON Icon + _In_ ULONG Id, + _In_ ULONG Flags, + _In_opt_ PWSTR Text, + _In_opt_ HICON Icon ) { NOTIFYICONDATA notifyIcon = { NOTIFYICONDATA_V3_SIZE }; @@ -536,8 +536,8 @@ BOOLEAN PhNfpModifyNotifyIcon( } VOID PhNfpProcessesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { ULONG registeredIconMask; @@ -573,7 +573,7 @@ VOID PhNfpProcessesUpdatedHandler( } VOID PhNfpUpdateRegisteredIcon( - __in PPH_NF_ICON Icon + _In_ PPH_NF_ICON Icon ) { PVOID newIconOrBitmap; @@ -630,12 +630,12 @@ VOID PhNfpUpdateRegisteredIcon( } VOID PhNfpBeginBitmap( - __out PULONG Width, - __out PULONG Height, - __out HBITMAP *Bitmap, - __out_opt PVOID *Bits, - __out HDC *Hdc, - __out HBITMAP *OldBitmap + _Out_ PULONG Width, + _Out_ PULONG Height, + _Out_ HBITMAP *Bitmap, + _Out_opt_ PVOID *Bits, + _Out_ HDC *Hdc, + _Out_ HBITMAP *OldBitmap ) { static BOOLEAN initialized = FALSE; diff --git a/2.x/trunk/ProcessHacker/ntobjprp.c b/2.x/trunk/ProcessHacker/ntobjprp.c index 3b0731ce0..319daee51 100644 --- a/2.x/trunk/ProcessHacker/ntobjprp.c +++ b/2.x/trunk/ProcessHacker/ntobjprp.c @@ -29,65 +29,65 @@ typedef struct _COMMON_PAGE_CONTEXT } COMMON_PAGE_CONTEXT, *PCOMMON_PAGE_CONTEXT; HPROPSHEETPAGE PhpCommonCreatePage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in PWSTR Template, - __in DLGPROC DlgProc + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_ PWSTR Template, + _In_ DLGPROC DlgProc ); INT CALLBACK PhpCommonPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ); INT_PTR CALLBACK PhpEventPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpEventPairPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpMutantPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpSectionPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpSemaphorePageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpTimerPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static HPROPSHEETPAGE PhpCommonCreatePage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in PWSTR Template, - __in DLGPROC DlgProc + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_ PWSTR Template, + _In_ DLGPROC DlgProc ) { HPROPSHEETPAGE propSheetPageHandle; @@ -118,9 +118,9 @@ static HPROPSHEETPAGE PhpCommonCreatePage( } INT CALLBACK PhpCommonPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ) { PCOMMON_PAGE_CONTEXT pageContext; @@ -140,10 +140,10 @@ INT CALLBACK PhpCommonPropPageProc( } FORCEINLINE PCOMMON_PAGE_CONTEXT PhpCommonPageHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { return (PCOMMON_PAGE_CONTEXT)PhpGenericPropertyPageHeader( @@ -151,8 +151,8 @@ FORCEINLINE PCOMMON_PAGE_CONTEXT PhpCommonPageHeader( } HPROPSHEETPAGE PhCreateEventPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ) { return PhpCommonCreatePage( @@ -164,8 +164,8 @@ HPROPSHEETPAGE PhCreateEventPage( } static VOID PhpRefreshEventPageInfo( - __in HWND hwndDlg, - __in PCOMMON_PAGE_CONTEXT PageContext + _In_ HWND hwndDlg, + _In_ PCOMMON_PAGE_CONTEXT PageContext ) { HANDLE eventHandle; @@ -203,10 +203,10 @@ static VOID PhpRefreshEventPageInfo( } INT_PTR CALLBACK PhpEventPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCOMMON_PAGE_CONTEXT pageContext; @@ -271,8 +271,8 @@ INT_PTR CALLBACK PhpEventPageProc( } HPROPSHEETPAGE PhCreateEventPairPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ) { return PhpCommonCreatePage( @@ -284,10 +284,10 @@ HPROPSHEETPAGE PhCreateEventPairPage( } INT_PTR CALLBACK PhpEventPairPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCOMMON_PAGE_CONTEXT pageContext; @@ -346,8 +346,8 @@ INT_PTR CALLBACK PhpEventPairPageProc( } HPROPSHEETPAGE PhCreateMutantPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ) { return PhpCommonCreatePage( @@ -359,8 +359,8 @@ HPROPSHEETPAGE PhCreateMutantPage( } static VOID PhpRefreshMutantPageInfo( - __in HWND hwndDlg, - __in PCOMMON_PAGE_CONTEXT PageContext + _In_ HWND hwndDlg, + _In_ PCOMMON_PAGE_CONTEXT PageContext ) { HANDLE mutantHandle; @@ -413,10 +413,10 @@ static VOID PhpRefreshMutantPageInfo( } INT_PTR CALLBACK PhpMutantPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCOMMON_PAGE_CONTEXT pageContext; @@ -445,8 +445,8 @@ INT_PTR CALLBACK PhpMutantPageProc( } HPROPSHEETPAGE PhCreateSectionPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ) { return PhpCommonCreatePage( @@ -458,8 +458,8 @@ HPROPSHEETPAGE PhCreateSectionPage( } static VOID PhpRefreshSectionPageInfo( - __in HWND hwndDlg, - __in PCOMMON_PAGE_CONTEXT PageContext + _In_ HWND hwndDlg, + _In_ PCOMMON_PAGE_CONTEXT PageContext ) { HANDLE sectionHandle; @@ -496,10 +496,10 @@ static VOID PhpRefreshSectionPageInfo( } INT_PTR CALLBACK PhpSectionPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCOMMON_PAGE_CONTEXT pageContext; @@ -522,8 +522,8 @@ INT_PTR CALLBACK PhpSectionPageProc( } HPROPSHEETPAGE PhCreateSemaphorePage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ) { return PhpCommonCreatePage( @@ -535,8 +535,8 @@ HPROPSHEETPAGE PhCreateSemaphorePage( } static VOID PhpRefreshSemaphorePageInfo( - __in HWND hwndDlg, - __in PCOMMON_PAGE_CONTEXT PageContext + _In_ HWND hwndDlg, + _In_ PCOMMON_PAGE_CONTEXT PageContext ) { HANDLE semaphoreHandle; @@ -565,10 +565,10 @@ static VOID PhpRefreshSemaphorePageInfo( } INT_PTR CALLBACK PhpSemaphorePageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCOMMON_PAGE_CONTEXT pageContext; @@ -634,8 +634,8 @@ INT_PTR CALLBACK PhpSemaphorePageProc( } HPROPSHEETPAGE PhCreateTimerPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context ) { return PhpCommonCreatePage( @@ -647,8 +647,8 @@ HPROPSHEETPAGE PhCreateTimerPage( } static VOID PhpRefreshTimerPageInfo( - __in HWND hwndDlg, - __in PCOMMON_PAGE_CONTEXT PageContext + _In_ HWND hwndDlg, + _In_ PCOMMON_PAGE_CONTEXT PageContext ) { HANDLE timerHandle; @@ -675,10 +675,10 @@ static VOID PhpRefreshTimerPageInfo( } INT_PTR CALLBACK PhpTimerPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PCOMMON_PAGE_CONTEXT pageContext; diff --git a/2.x/trunk/ProcessHacker/options.c b/2.x/trunk/ProcessHacker/options.c index c8ede2f39..414297bf4 100644 --- a/2.x/trunk/ProcessHacker/options.c +++ b/2.x/trunk/ProcessHacker/options.c @@ -28,51 +28,51 @@ #define WM_PH_CHILD_EXIT (WM_APP + 301) INT CALLBACK PhpOptionsPropSheetProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam ); LRESULT CALLBACK PhpOptionsWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpOptionsGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpOptionsAdvancedDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpOptionsSymbolsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpOptionsHighlightingDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpOptionsGraphsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // All @@ -96,7 +96,7 @@ static HWND WindowHandleForElevate; static HWND HighlightingListViewHandle; VOID PhShowOptionsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -220,9 +220,9 @@ VOID PhShowOptionsDialog( } INT CALLBACK PhpOptionsPropSheetProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam ) { switch (uMsg) @@ -241,7 +241,7 @@ INT CALLBACK PhpOptionsPropSheetProc( } static VOID PhpPageInit( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { if (!PageInit) @@ -296,10 +296,10 @@ static VOID PhpPageInit( } LRESULT CALLBACK PhpOptionsWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -359,7 +359,7 @@ LRESULT CALLBACK PhpOptionsWndProc( #define DialogChanged PropSheet_Changed(GetParent(hwndDlg), hwndDlg) static BOOLEAN GetCurrentFont( - __out PLOGFONT Font + _Out_ PLOGFONT Font ) { BOOLEAN result; @@ -386,10 +386,10 @@ static BOOLEAN GetCurrentFont( } INT_PTR CALLBACK PhpOptionsGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -523,7 +523,7 @@ INT_PTR CALLBACK PhpOptionsGeneralDlgProc( } static BOOLEAN PathMatchesPh( - __in PPH_STRING Path + _In_ PPH_STRING Path ) { BOOLEAN match = FALSE; @@ -552,7 +552,7 @@ static BOOLEAN PathMatchesPh( } VOID PhpAdvancedPageLoad( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { HWND changeButton; @@ -635,7 +635,7 @@ VOID PhpAdvancedPageLoad( } VOID PhpAdvancedPageSave( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { ULONG sampleCount; @@ -709,7 +709,7 @@ VOID PhpAdvancedPageSave( } NTSTATUS PhpElevateAdvancedThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_STRING arguments; @@ -732,10 +732,10 @@ NTSTATUS PhpElevateAdvancedThreadStart( } INT_PTR CALLBACK PhpOptionsAdvancedDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -833,10 +833,10 @@ INT_PTR CALLBACK PhpOptionsAdvancedDlgProc( } INT_PTR CALLBACK PhpOptionsSymbolsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -956,9 +956,9 @@ static COLOR_ITEM ColorItems[] = }; COLORREF NTAPI PhpColorItemColorFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ) { PCOLOR_ITEM item = Param; @@ -967,10 +967,10 @@ COLORREF NTAPI PhpColorItemColorFunction( } INT_PTR CALLBACK PhpOptionsHighlightingDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -1106,10 +1106,10 @@ INT_PTR CALLBACK PhpOptionsHighlightingDlgProc( } INT_PTR CALLBACK PhpOptionsGraphsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/pagfiles.c b/2.x/trunk/ProcessHacker/pagfiles.c index b78410663..e1a801643 100644 --- a/2.x/trunk/ProcessHacker/pagfiles.c +++ b/2.x/trunk/ProcessHacker/pagfiles.c @@ -23,14 +23,14 @@ #include INT_PTR CALLBACK PhpPagefilesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowPagefilesDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ) { DialogBox( @@ -42,8 +42,8 @@ VOID PhShowPagefilesDialog( } static VOID PhpAddPagefileItems( - __in HWND ListViewHandle, - __in PVOID Pagefiles + _In_ HWND ListViewHandle, + _In_ PVOID Pagefiles ) { PSYSTEM_PAGEFILE_INFORMATION pagefile; @@ -86,10 +86,10 @@ static VOID PhpAddPagefileItems( } INT_PTR CALLBACK PhpPagefilesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/phsvc/clapi.c b/2.x/trunk/ProcessHacker/phsvc/clapi.c index 15b1cab6e..1b87e663a 100644 --- a/2.x/trunk/ProcessHacker/phsvc/clapi.c +++ b/2.x/trunk/ProcessHacker/phsvc/clapi.c @@ -2,7 +2,7 @@ * Process Hacker - * phsvc client * - * Copyright (C) 2011 wj32 + * Copyright (C) 2011-2013 wj32 * * This file is part of Process Hacker. * @@ -28,8 +28,8 @@ PVOID PhSvcClPortHeap; HANDLE PhSvcClServerProcessId; NTSTATUS PhSvcConnectToServer( - __in PUNICODE_STRING PortName, - __in_opt SIZE_T PortSectionSize + _In_ PUNICODE_STRING PortName, + _In_opt_ SIZE_T PortSectionSize ) { NTSTATUS status; @@ -139,8 +139,8 @@ VOID PhSvcDisconnectFromServer( } PVOID PhSvcpAllocateHeap( - __in SIZE_T Size, - __out PULONG Offset + _In_ SIZE_T Size, + _Out_ PULONG Offset ) { PVOID memory; @@ -159,7 +159,7 @@ PVOID PhSvcpAllocateHeap( } VOID PhSvcpFreeHeap( - __in PVOID Memory + _In_ PVOID Memory ) { if (!PhSvcClPortHeap) @@ -169,9 +169,9 @@ VOID PhSvcpFreeHeap( } PVOID PhSvcpCreateString( - __in PVOID String, - __in SIZE_T Length, - __out PPH_RELATIVE_STRINGREF StringRef + _In_ PVOID String, + _In_ SIZE_T Length, + _Out_ PPH_RELATIVE_STRINGREF StringRef ) { PVOID memory; @@ -200,7 +200,7 @@ PVOID PhSvcpCreateString( } NTSTATUS PhSvcpCallServer( - __inout PPHSVC_API_MSG Message + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -217,24 +217,9 @@ NTSTATUS PhSvcpCallServer( return Message->ReturnStatus; } -NTSTATUS PhSvcCallClose( - __in HANDLE Handle - ) -{ - PHSVC_API_MSG m; - - if (!PhSvcClPortHandle) - return STATUS_PORT_DISCONNECTED; - - m.ApiNumber = PhSvcCloseApiNumber; - m.u.Close.i.Handle = Handle; - - return PhSvcpCallServer(&m); -} - NTSTATUS PhSvcpCallExecuteRunAsCommand( - __in PHSVC_API_NUMBER ApiNumber, - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PHSVC_API_NUMBER ApiNumber, + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ) { NTSTATUS status; @@ -305,15 +290,15 @@ NTSTATUS PhSvcpCallExecuteRunAsCommand( } NTSTATUS PhSvcCallExecuteRunAsCommand( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ) { return PhSvcpCallExecuteRunAsCommand(PhSvcExecuteRunAsCommandApiNumber, Parameters); } NTSTATUS PhSvcCallUnloadDriver( - __in_opt PVOID BaseAddress, - __in_opt PWSTR Name + _In_opt_ PVOID BaseAddress, + _In_opt_ PWSTR Name ) { NTSTATUS status; @@ -346,9 +331,9 @@ NTSTATUS PhSvcCallUnloadDriver( } NTSTATUS PhSvcCallControlProcess( - __in HANDLE ProcessId, - __in PHSVC_API_CONTROLPROCESS_COMMAND Command, - __in ULONG Argument + _In_ HANDLE ProcessId, + _In_ PHSVC_API_CONTROLPROCESS_COMMAND Command, + _In_ ULONG Argument ) { PHSVC_API_MSG m; @@ -365,8 +350,8 @@ NTSTATUS PhSvcCallControlProcess( } NTSTATUS PhSvcCallControlService( - __in PWSTR ServiceName, - __in PHSVC_API_CONTROLSERVICE_COMMAND Command + _In_ PWSTR ServiceName, + _In_ PHSVC_API_CONTROLSERVICE_COMMAND Command ) { NTSTATUS status; @@ -397,17 +382,17 @@ NTSTATUS PhSvcCallControlService( } NTSTATUS PhSvcCallCreateService( - __in PWSTR ServiceName, - __in_opt PWSTR DisplayName, - __in ULONG ServiceType, - __in ULONG StartType, - __in ULONG ErrorControl, - __in_opt PWSTR BinaryPathName, - __in_opt PWSTR LoadOrderGroup, - __out_opt PULONG TagId, - __in_opt PWSTR Dependencies, - __in_opt PWSTR ServiceStartName, - __in_opt PWSTR Password + _In_ PWSTR ServiceName, + _In_opt_ PWSTR DisplayName, + _In_ ULONG ServiceType, + _In_ ULONG StartType, + _In_ ULONG ErrorControl, + _In_opt_ PWSTR BinaryPathName, + _In_opt_ PWSTR LoadOrderGroup, + _Out_opt_ PULONG TagId, + _In_opt_ PWSTR Dependencies, + _In_opt_ PWSTR ServiceStartName, + _In_opt_ PWSTR Password ) { NTSTATUS status; @@ -501,17 +486,17 @@ NTSTATUS PhSvcCallCreateService( } NTSTATUS PhSvcCallChangeServiceConfig( - __in PWSTR ServiceName, - __in ULONG ServiceType, - __in ULONG StartType, - __in ULONG ErrorControl, - __in_opt PWSTR BinaryPathName, - __in_opt PWSTR LoadOrderGroup, - __out_opt PULONG TagId, - __in_opt PWSTR Dependencies, - __in_opt PWSTR ServiceStartName, - __in_opt PWSTR Password, - __in_opt PWSTR DisplayName + _In_ PWSTR ServiceName, + _In_ ULONG ServiceType, + _In_ ULONG StartType, + _In_ ULONG ErrorControl, + _In_opt_ PWSTR BinaryPathName, + _In_opt_ PWSTR LoadOrderGroup, + _Out_opt_ PULONG TagId, + _In_opt_ PWSTR Dependencies, + _In_opt_ PWSTR ServiceStartName, + _In_opt_ PWSTR Password, + _In_opt_ PWSTR DisplayName ) { NTSTATUS status; @@ -607,9 +592,9 @@ NTSTATUS PhSvcCallChangeServiceConfig( } NTSTATUS PhSvcCallChangeServiceConfig2( - __in PWSTR ServiceName, - __in ULONG InfoLevel, - __in PVOID Info + _In_ PWSTR ServiceName, + _In_ ULONG InfoLevel, + _In_ PVOID Info ) { NTSTATUS status; @@ -654,7 +639,7 @@ NTSTATUS PhSvcCallChangeServiceConfig2( } NTSTATUS PhSvcCallSetTcpEntry( - __in PVOID TcpRow + _In_ PVOID TcpRow ) { PHSVC_API_MSG m; @@ -682,9 +667,9 @@ NTSTATUS PhSvcCallSetTcpEntry( } NTSTATUS PhSvcCallControlThread( - __in HANDLE ThreadId, - __in PHSVC_API_CONTROLTHREAD_COMMAND Command, - __in ULONG Argument + _In_ HANDLE ThreadId, + _In_ PHSVC_API_CONTROLTHREAD_COMMAND Command, + _In_ ULONG Argument ) { PHSVC_API_MSG m; @@ -701,8 +686,8 @@ NTSTATUS PhSvcCallControlThread( } NTSTATUS PhSvcCallAddAccountRight( - __in PSID AccountSid, - __in PUNICODE_STRING UserRight + _In_ PSID AccountSid, + _In_ PUNICODE_STRING UserRight ) { NTSTATUS status; @@ -732,14 +717,14 @@ NTSTATUS PhSvcCallAddAccountRight( } NTSTATUS PhSvcCallInvokeRunAsService( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ) { return PhSvcpCallExecuteRunAsCommand(PhSvcInvokeRunAsServiceApiNumber, Parameters); } NTSTATUS PhSvcCallIssueMemoryListCommand( - __in SYSTEM_MEMORY_LIST_COMMAND Command + _In_ SYSTEM_MEMORY_LIST_COMMAND Command ) { PHSVC_API_MSG m; @@ -752,3 +737,45 @@ NTSTATUS PhSvcCallIssueMemoryListCommand( return PhSvcpCallServer(&m); } + +NTSTATUS PhSvcCallPostMessage( + _In_opt_ HWND hWnd, + _In_ UINT Msg, + _In_ WPARAM wParam, + _In_ LPARAM lParam + ) +{ + PHSVC_API_MSG m; + + if (!PhSvcClPortHandle) + return STATUS_PORT_DISCONNECTED; + + m.ApiNumber = PhSvcPostMessageApiNumber; + m.u.PostMessage.i.hWnd = hWnd; + m.u.PostMessage.i.Msg = Msg; + m.u.PostMessage.i.wParam = wParam; + m.u.PostMessage.i.lParam = lParam; + + return PhSvcpCallServer(&m); +} + +NTSTATUS PhSvcCallSendMessage( + _In_opt_ HWND hWnd, + _In_ UINT Msg, + _In_ WPARAM wParam, + _In_ LPARAM lParam + ) +{ + PHSVC_API_MSG m; + + if (!PhSvcClPortHandle) + return STATUS_PORT_DISCONNECTED; + + m.ApiNumber = PhSvcSendMessageApiNumber; + m.u.PostMessage.i.hWnd = hWnd; + m.u.PostMessage.i.Msg = Msg; + m.u.PostMessage.i.wParam = wParam; + m.u.PostMessage.i.lParam = lParam; + + return PhSvcpCallServer(&m); +} diff --git a/2.x/trunk/ProcessHacker/phsvc/svcapi.c b/2.x/trunk/ProcessHacker/phsvc/svcapi.c index ad967ffec..192c03c48 100644 --- a/2.x/trunk/ProcessHacker/phsvc/svcapi.c +++ b/2.x/trunk/ProcessHacker/phsvc/svcapi.c @@ -2,7 +2,7 @@ * Process Hacker - * server API * - * Copyright (C) 2011 wj32 + * Copyright (C) 2011-2013 wj32 * * This file is part of Process Hacker. * @@ -36,7 +36,7 @@ typedef struct _PHSVCP_CAPTURED_RUNAS_SERVICE_PARAMETERS PPHSVC_API_PROCEDURE PhSvcApiCallTable[] = { - PhSvcApiClose, + PhSvcApiDefault, PhSvcApiExecuteRunAsCommand, PhSvcApiUnloadDriver, PhSvcApiControlProcess, @@ -48,7 +48,9 @@ PPHSVC_API_PROCEDURE PhSvcApiCallTable[] = PhSvcApiControlThread, PhSvcApiAddAccountRight, PhSvcApiInvokeRunAsService, - PhSvcApiIssueMemoryListCommand + PhSvcApiIssueMemoryListCommand, + PhSvcApiPostMessage, + PhSvcApiSendMessage }; C_ASSERT(sizeof(PhSvcApiCallTable) / sizeof(PPHSVC_API_PROCEDURE) == PhSvcMaximumApiNumber - 1); @@ -60,10 +62,10 @@ NTSTATUS PhSvcApiInitialization( } VOID PhSvcDispatchApiCall( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message, - __out PPHSVC_API_MSG *ReplyMessage, - __out PHANDLE ReplyPortHandle + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message, + _Out_ PPHSVC_API_MSG *ReplyMessage, + _Out_ PHANDLE ReplyPortHandle ) { NTSTATUS status; @@ -88,9 +90,9 @@ VOID PhSvcDispatchApiCall( } NTSTATUS PhSvcCaptureBuffer( - __in PPH_RELATIVE_STRINGREF String, - __in BOOLEAN AllowNull, - __out PVOID *CapturedBuffer + _In_ PPH_RELATIVE_STRINGREF String, + _In_ BOOLEAN AllowNull, + _Out_ PVOID *CapturedBuffer ) { PPHSVC_CLIENT client = PhSvcGetCurrentClient(); @@ -130,9 +132,9 @@ NTSTATUS PhSvcCaptureBuffer( } NTSTATUS PhSvcCaptureString( - __in PPH_RELATIVE_STRINGREF String, - __in BOOLEAN AllowNull, - __out PPH_STRING *CapturedString + _In_ PPH_RELATIVE_STRINGREF String, + _In_ BOOLEAN AllowNull, + _Out_ PPH_STRING *CapturedString ) { PPHSVC_CLIENT client = PhSvcGetCurrentClient(); @@ -178,9 +180,9 @@ NTSTATUS PhSvcCaptureString( } NTSTATUS PhSvcCaptureSid( - __in PPH_RELATIVE_STRINGREF String, - __in BOOLEAN AllowNull, - __out PSID *CapturedSid + _In_ PPH_RELATIVE_STRINGREF String, + _In_ BOOLEAN AllowNull, + _Out_ PSID *CapturedSid ) { NTSTATUS status; @@ -211,19 +213,19 @@ NTSTATUS PhSvcCaptureSid( return STATUS_SUCCESS; } -NTSTATUS PhSvcApiClose( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message +NTSTATUS PhSvcApiDefault( + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { - return PhSvcCloseHandle(Message->u.Close.i.Handle); + return STATUS_NOT_IMPLEMENTED; } NTSTATUS PhSvcpCaptureRunAsServiceParameters( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message, - __out PPH_RUNAS_SERVICE_PARAMETERS Parameters, - __out PPHSVCP_CAPTURED_RUNAS_SERVICE_PARAMETERS CapturedParameters + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message, + _Out_ PPH_RUNAS_SERVICE_PARAMETERS Parameters, + _Out_ PPHSVCP_CAPTURED_RUNAS_SERVICE_PARAMETERS CapturedParameters ) { NTSTATUS status; @@ -261,7 +263,7 @@ NTSTATUS PhSvcpCaptureRunAsServiceParameters( } VOID PhSvcpReleaseRunAsServiceParameters( - __in PPHSVCP_CAPTURED_RUNAS_SERVICE_PARAMETERS CapturedParameters + _In_ PPHSVCP_CAPTURED_RUNAS_SERVICE_PARAMETERS CapturedParameters ) { if (CapturedParameters->UserName) @@ -286,7 +288,7 @@ VOID PhSvcpReleaseRunAsServiceParameters( } NTSTATUS PhSvcpValidateRunAsServiceParameters( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ) { if ((!Parameters->UserName || !Parameters->Password) && !Parameters->ProcessId) @@ -300,8 +302,8 @@ NTSTATUS PhSvcpValidateRunAsServiceParameters( } NTSTATUS PhSvcApiExecuteRunAsCommand( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -322,8 +324,8 @@ NTSTATUS PhSvcApiExecuteRunAsCommand( } NTSTATUS PhSvcApiUnloadDriver( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -339,8 +341,8 @@ NTSTATUS PhSvcApiUnloadDriver( } NTSTATUS PhSvcApiControlProcess( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -400,8 +402,8 @@ NTSTATUS PhSvcApiControlProcess( } NTSTATUS PhSvcApiControlService( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -505,8 +507,8 @@ NTSTATUS PhSvcApiControlService( } NTSTATUS PhSvcApiCreateService( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -587,8 +589,8 @@ NTSTATUS PhSvcApiCreateService( } NTSTATUS PhSvcApiChangeServiceConfig( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -666,8 +668,8 @@ NTSTATUS PhSvcApiChangeServiceConfig( } NTSTATUS PhSvcApiChangeServiceConfig2( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -715,8 +717,8 @@ NTSTATUS PhSvcApiChangeServiceConfig2( } NTSTATUS PhSvcApiSetTcpEntry( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { static PVOID setTcpEntry = NULL; @@ -770,8 +772,8 @@ NTSTATUS PhSvcApiSetTcpEntry( } NTSTATUS PhSvcApiControlThread( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -819,8 +821,8 @@ NTSTATUS PhSvcApiControlThread( } NTSTATUS PhSvcApiAddAccountRight( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -850,8 +852,8 @@ NTSTATUS PhSvcApiAddAccountRight( } NTSTATUS PhSvcApiInvokeRunAsService( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -872,8 +874,8 @@ NTSTATUS PhSvcApiInvokeRunAsService( } NTSTATUS PhSvcApiIssueMemoryListCommand( - __in PPHSVC_CLIENT Client, - __inout PPHSVC_API_MSG Message + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message ) { NTSTATUS status; @@ -886,3 +888,43 @@ NTSTATUS PhSvcApiIssueMemoryListCommand( return status; } + +NTSTATUS PhSvcApiPostMessage( + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message + ) +{ + if (PostMessage( + Message->u.PostMessage.i.hWnd, + Message->u.PostMessage.i.Msg, + Message->u.PostMessage.i.wParam, + Message->u.PostMessage.i.lParam + )) + { + return STATUS_SUCCESS; + } + else + { + return PhGetLastWin32ErrorAsNtStatus(); + } +} + +NTSTATUS PhSvcApiSendMessage( + _In_ PPHSVC_CLIENT Client, + _Inout_ PPHSVC_API_MSG Message + ) +{ + if (SendMessage( + Message->u.PostMessage.i.hWnd, + Message->u.PostMessage.i.Msg, + Message->u.PostMessage.i.wParam, + Message->u.PostMessage.i.lParam + )) + { + return STATUS_SUCCESS; + } + else + { + return PhGetLastWin32ErrorAsNtStatus(); + } +} diff --git a/2.x/trunk/ProcessHacker/phsvc/svcapiport.c b/2.x/trunk/ProcessHacker/phsvc/svcapiport.c index 4722f948b..a85de5d97 100644 --- a/2.x/trunk/ProcessHacker/phsvc/svcapiport.c +++ b/2.x/trunk/ProcessHacker/phsvc/svcapiport.c @@ -24,7 +24,7 @@ #include NTSTATUS PhSvcApiRequestThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); extern HANDLE PhSvcTimeoutStandbyEventHandle; @@ -35,7 +35,7 @@ HANDLE PhSvcApiPortHandle; ULONG PhSvcApiNumberOfClients = 0; NTSTATUS PhSvcApiPortInitialization( - __in PUNICODE_STRING PortName + _In_ PUNICODE_STRING PortName ) { static SID_IDENTIFIER_AUTHORITY ntAuthority = SECURITY_NT_AUTHORITY; @@ -116,7 +116,7 @@ PPHSVC_THREAD_CONTEXT PhSvcGetCurrentThreadContext( } NTSTATUS PhSvcApiRequestThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { NTSTATUS status; @@ -187,7 +187,7 @@ NTSTATUS PhSvcApiRequestThreadStart( } VOID PhSvcHandleConnectionRequest( - __in PPHSVC_API_MSG Message + _In_ PPHSVC_API_MSG Message ) { NTSTATUS status; diff --git a/2.x/trunk/ProcessHacker/phsvc/svcclient.c b/2.x/trunk/ProcessHacker/phsvc/svcclient.c index f6168b5d9..4ec418da4 100644 --- a/2.x/trunk/ProcessHacker/phsvc/svcclient.c +++ b/2.x/trunk/ProcessHacker/phsvc/svcclient.c @@ -2,7 +2,7 @@ * Process Hacker - * server client * - * Copyright (C) 2011 wj32 + * Copyright (C) 2011-2013 wj32 * * This file is part of Process Hacker. * @@ -24,8 +24,8 @@ #include VOID NTAPI PhSvcpClientDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); PPH_OBJECT_TYPE PhSvcClientType; @@ -52,20 +52,10 @@ NTSTATUS PhSvcClientInitialization( } PPHSVC_CLIENT PhSvcCreateClient( - __in_opt PCLIENT_ID ClientId + _In_opt_ PCLIENT_ID ClientId ) { PPHSVC_CLIENT client; - PPH_HANDLE_TABLE handleTable; - - __try - { - handleTable = PhCreateHandleTable(); - } - __except (SIMPLE_EXCEPTION_FILTER(GetExceptionCode() == STATUS_NO_MEMORY)) - { - return NULL; - } if (!NT_SUCCESS(PhCreateObject( &client, @@ -74,7 +64,6 @@ PPHSVC_CLIENT PhSvcCreateClient( PhSvcClientType ))) { - PhDestroyHandleTable(handleTable); return NULL; } @@ -83,8 +72,6 @@ PPHSVC_CLIENT PhSvcCreateClient( if (ClientId) client->ClientId = *ClientId; - client->HandleTable = handleTable; - PhAcquireQueuedLockExclusive(&PhSvcClientListLock); InsertTailList(&PhSvcClientListHead, &client->ListEntry); PhReleaseQueuedLockExclusive(&PhSvcClientListLock); @@ -93,8 +80,8 @@ PPHSVC_CLIENT PhSvcCreateClient( } VOID NTAPI PhSvcpClientDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPHSVC_CLIENT client = (PPHSVC_CLIENT)Object; @@ -103,14 +90,12 @@ VOID NTAPI PhSvcpClientDeleteProcedure( RemoveEntryList(&client->ListEntry); PhReleaseQueuedLockExclusive(&PhSvcClientListLock); - PhDestroyHandleTable(client->HandleTable); - if (client->PortHandle) NtClose(client->PortHandle); } PPHSVC_CLIENT PhSvcReferenceClientByClientId( - __in PCLIENT_ID ClientId + _In_ PCLIENT_ID ClientId ) { PLIST_ENTRY listEntry; @@ -164,7 +149,7 @@ PPHSVC_CLIENT PhSvcGetCurrentClient( } BOOLEAN PhSvcAttachClient( - __in PPHSVC_CLIENT Client + _In_ PPHSVC_CLIENT Client ) { PPHSVC_THREAD_CONTEXT threadContext = PhSvcGetCurrentThreadContext(); @@ -180,7 +165,7 @@ BOOLEAN PhSvcAttachClient( } VOID PhSvcDetachClient( - __in PPHSVC_CLIENT Client + _In_ PPHSVC_CLIENT Client ) { PPHSVC_THREAD_CONTEXT threadContext = PhSvcGetCurrentThreadContext(); @@ -189,82 +174,3 @@ VOID PhSvcDetachClient( threadContext->CurrentClient = threadContext->OldClient; threadContext->OldClient = NULL; } - -NTSTATUS PhSvcCreateHandle( - __out PHANDLE Handle, - __in PVOID Object, - __in ACCESS_MASK GrantedAccess - ) -{ - PPHSVC_CLIENT client = PhSvcGetCurrentClient(); - HANDLE handle; - PH_HANDLE_TABLE_ENTRY entry; - - entry.Object = Object; - entry.GrantedAccess = GrantedAccess; - - __try - { - handle = PhCreateHandle(client->HandleTable, &entry); - } - __except (SIMPLE_EXCEPTION_FILTER(GetExceptionCode() == STATUS_NO_MEMORY)) - { - return STATUS_NO_MEMORY; - } - - if (!handle) - return STATUS_NO_MEMORY; - - PhReferenceObject(Object); - - *Handle = handle; - - return STATUS_SUCCESS; -} - -NTSTATUS PhSvcCloseHandle( - __in HANDLE Handle - ) -{ - PPHSVC_CLIENT client = PhSvcGetCurrentClient(); - PPH_HANDLE_TABLE_ENTRY entry; - - entry = PhLookupHandleTableEntry(client->HandleTable, Handle); - - if (!entry) - return STATUS_INVALID_HANDLE; - - PhDereferenceObject(entry->Object); - PhDestroyHandle(client->HandleTable, Handle, entry); - - return STATUS_SUCCESS; -} - -NTSTATUS PhSvcReferenceObjectByHandle( - __in HANDLE Handle, - __in_opt PPH_OBJECT_TYPE ObjectType, - __in_opt ACCESS_MASK DesiredAccess, - __out PVOID *Object - ) -{ - PPHSVC_CLIENT client = PhSvcGetCurrentClient(); - PPH_HANDLE_TABLE_ENTRY entry; - - entry = PhLookupHandleTableEntry(client->HandleTable, Handle); - - if (!entry) - return STATUS_INVALID_HANDLE; - - if (ObjectType && PhGetObjectType(entry->Object) != ObjectType) - { - PhUnlockHandleTableEntry(client->HandleTable, entry); - return STATUS_OBJECT_TYPE_MISMATCH; - } - - PhReferenceObject(entry->Object); - *Object = entry->Object; - - PhUnlockHandleTableEntry(client->HandleTable, entry); - - return STATUS_SUCCESS; -} diff --git a/2.x/trunk/ProcessHacker/phsvc/svcmain.c b/2.x/trunk/ProcessHacker/phsvc/svcmain.c index 7fa5ef9c3..816f440de 100644 --- a/2.x/trunk/ProcessHacker/phsvc/svcmain.c +++ b/2.x/trunk/ProcessHacker/phsvc/svcmain.c @@ -27,9 +27,9 @@ HANDLE PhSvcTimeoutStandbyEventHandle; HANDLE PhSvcTimeoutCancelEventHandle; NTSTATUS PhSvcMain( - __in_opt PUNICODE_STRING PortName, - __in_opt PLARGE_INTEGER Timeout, - __inout_opt PPHSVC_STOP Stop + _In_opt_ PUNICODE_STRING PortName, + _In_opt_ PLARGE_INTEGER Timeout, + _Inout_opt_ PPHSVC_STOP Stop ) { NTSTATUS status; @@ -95,7 +95,7 @@ NTSTATUS PhSvcMain( } VOID PhSvcStop( - __inout PPHSVC_STOP Stop + _Inout_ PPHSVC_STOP Stop ) { Stop->Stop = TRUE; diff --git a/2.x/trunk/ProcessHacker/plugin.c b/2.x/trunk/ProcessHacker/plugin.c index c2e4df43a..e8ed6a7e1 100644 --- a/2.x/trunk/ProcessHacker/plugin.c +++ b/2.x/trunk/ProcessHacker/plugin.c @@ -26,42 +26,18 @@ #include #include #include -#define CINTERFACE -#define COBJMACROS -#include -#include - -typedef HRESULT (STDAPICALLTYPE *_CLRCreateInstance)( - __in REFCLSID clsid, - __in REFIID riid, - __out LPVOID *ppInterface - ); - -typedef HRESULT (STDAPICALLTYPE *_CorBindToRuntimeEx)( - __in LPCWSTR pwszVersion, - __in LPCWSTR pwszBuildFlavor, - __in DWORD startupFlags, - __in REFCLSID rclsid, - __in REFIID riid, - __out LPVOID *ppv - ); INT NTAPI PhpPluginsCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ); BOOLEAN PhLoadPlugin( - __in PPH_STRING FileName - ); - -BOOLEAN PhpLoadClrPlugin( - __in PPH_STRING FileName, - __out_opt PPH_STRING *ErrorMessage + _In_ PPH_STRING FileName ); VOID PhpExecuteCallbackForAllPlugins( - __in PH_PLUGIN_CALLBACK Callback + _In_ PH_PLUGIN_CALLBACK Callback ); PH_AVL_TREE PhPluginsByName = PH_AVL_TREE_INIT(PhpPluginsCompareFunction); @@ -69,19 +45,8 @@ PH_AVL_TREE PhPluginsByName = PH_AVL_TREE_INIT(PhpPluginsCompareFunction); static PH_CALLBACK GeneralCallbacks[GeneralCallbackMaximum]; static PPH_STRING PluginsDirectory; static PPH_STRING LoadingPluginFileName; -static BOOLEAN LoadingPluginIsClr = FALSE; static ULONG NextPluginId = IDPLUGINS + 1; -static BOOLEAN PhPluginsClrHostInitialized = FALSE; -static PVOID PhPluginsClrHost = NULL; -static PVOID PhPluginsMetaHost = NULL; - -static CLSID CLSID_CLRRuntimeHost_I = { 0x90f1a06e, 0x7712, 0x4762, { 0x86, 0xb5, 0x7a, 0x5e, 0xba, 0x6b, 0xdb, 0x02 } }; -static IID IID_ICLRRuntimeHost_I = { 0x90f1a06c, 0x7712, 0x4762, { 0x86, 0xb5, 0x7a, 0x5e, 0xba, 0x6b, 0xdb, 0x02 } }; -static CLSID CLSID_CLRMetaHost_I = { 0x9280188d, 0xe8e, 0x4867, { 0xb3, 0xc, 0x7f, 0xa8, 0x38, 0x84, 0xe8, 0xde } }; -static IID IID_ICLRMetaHost_I = { 0xd332db9e, 0xb9b3, 0x4125, { 0x82, 0x07, 0xa1, 0x48, 0x84, 0xf5, 0x32, 0x16 } }; -static IID IID_ICLRRuntimeInfo_I = { 0xbd39d1d2, 0xba2f, 0x486a, { 0x89, 0xb0, 0xb4, 0xb0, 0xcb, 0x46, 0x68, 0x91 } }; - VOID PhPluginsInitialization( VOID ) @@ -102,8 +67,8 @@ VOID PhPluginsInitialization( } INT NTAPI PhpPluginsCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ) { PPH_PLUGIN plugin1 = CONTAINING_RECORD(Links1, PH_PLUGIN, Links); @@ -113,9 +78,9 @@ INT NTAPI PhpPluginsCompareFunction( } BOOLEAN PhpLocateDisabledPlugin( - __in PPH_STRING List, - __in PPH_STRINGREF BaseName, - __out_opt PULONG FoundIndex + _In_ PPH_STRING List, + _In_ PPH_STRINGREF BaseName, + _Out_opt_ PULONG FoundIndex ) { BOOLEAN found; @@ -155,7 +120,7 @@ BOOLEAN PhpLocateDisabledPlugin( } BOOLEAN PhIsPluginDisabled( - __in PPH_STRINGREF BaseName + _In_ PPH_STRINGREF BaseName ) { BOOLEAN found; @@ -169,8 +134,8 @@ BOOLEAN PhIsPluginDisabled( } VOID PhSetPluginDisabled( - __in PPH_STRINGREF BaseName, - __in BOOLEAN Disable + _In_ PPH_STRINGREF BaseName, + _In_ BOOLEAN Disable ) { BOOLEAN found; @@ -234,8 +199,8 @@ VOID PhSetPluginDisabled( } static BOOLEAN EnumPluginsDirectoryCallback( - __in PFILE_DIRECTORY_INFORMATION Information, - __in_opt PVOID Context + _In_ PFILE_DIRECTORY_INFORMATION Information, + _In_opt_ PVOID Context ) { PH_STRINGREF baseName; @@ -321,8 +286,8 @@ VOID PhUnloadPlugins( } VOID PhpHandlePluginLoadError( - __in PPH_STRING FileName, - __in_opt PPH_STRING ErrorMessage + _In_ PPH_STRING FileName, + _In_opt_ PPH_STRING ErrorMessage ) { PPH_STRING baseName; @@ -349,7 +314,7 @@ VOID PhpHandlePluginLoadError( * \param FileName The full file name of the plugin. */ BOOLEAN PhLoadPlugin( - __in PPH_STRING FileName + _In_ PPH_STRING FileName ) { BOOLEAN success; @@ -368,22 +333,10 @@ BOOLEAN PhLoadPlugin( success = TRUE; - if (!PhEndsWithString2(fileName, L".clr.dll", TRUE)) - { - if (!LoadLibrary(fileName->Buffer)) - { - success = FALSE; - errorMessage = PhGetWin32Message(GetLastError()); - } - } - else + if (!LoadLibrary(fileName->Buffer)) { - errorMessage = NULL; - - if (!PhpLoadClrPlugin(fileName, &errorMessage)) - { - success = FALSE; - } + success = FALSE; + errorMessage = PhGetWin32Message(GetLastError()); } if (!success) @@ -400,168 +353,8 @@ BOOLEAN PhLoadPlugin( return success; } -BOOLEAN PhpLoadV2ClrHost( - __in _CorBindToRuntimeEx CorBindToRuntimeEx_I - ) -{ - ICLRRuntimeHost *clrHost; - - if (SUCCEEDED(CorBindToRuntimeEx_I(NULL, L"wks", STARTUP_CONCURRENT_GC, &CLSID_CLRRuntimeHost_I, - &IID_ICLRRuntimeHost_I, &clrHost))) - { - PhPluginsClrHost = clrHost; - - return TRUE; - } - - return FALSE; -} - -BOOLEAN PhpLoadV4ClrHost( - __in _CLRCreateInstance CLRCreateInstance_I - ) -{ - ICLRMetaHost *metaHost; - - if (SUCCEEDED(CLRCreateInstance_I(&CLSID_CLRMetaHost_I, &IID_ICLRMetaHost_I, &metaHost))) - { - PhPluginsMetaHost = metaHost; - - return TRUE; - } - - return FALSE; -} - -PVOID PhpGetClrHostForPlugin( - __in PPH_STRING FileName, - __out_opt PPH_STRING *ErrorMessage - ) -{ - if (PhPluginsMetaHost) - { - HRESULT result; - ICLRMetaHost *metaHost; - WCHAR runtimeVersion[MAX_PATH]; - ULONG runtimeVersionSize; - - metaHost = (ICLRMetaHost *)PhPluginsMetaHost; - runtimeVersionSize = sizeof(runtimeVersion) / sizeof(WCHAR); - - // Get the framework version required by the plugin. - if (SUCCEEDED(result = ICLRMetaHost_GetVersionFromFile( - metaHost, - FileName->Buffer, - runtimeVersion, - &runtimeVersionSize - ))) - { - ICLRRuntimeInfo *runtimeInfo; - - if (SUCCEEDED(ICLRMetaHost_GetRuntime( - metaHost, - runtimeVersion, - &IID_ICLRRuntimeInfo_I, - &runtimeInfo - ))) - { - ICLRRuntimeHost *clrHost; - - if (SUCCEEDED(ICLRRuntimeInfo_GetInterface( - runtimeInfo, - &CLSID_CLRRuntimeHost_I, - &IID_ICLRRuntimeHost_I, - &clrHost - ))) - { - return clrHost; - } - - ICLRRuntimeInfo_Release(runtimeInfo); - } - } - else - { - *ErrorMessage = PhFormatString(L"Unable to get the runtime version: Error 0x%x", result); - } - - return NULL; - } - else - { - if (PhPluginsClrHost) - ICLRRuntimeHost_AddRef((ICLRRuntimeHost *)PhPluginsClrHost); - - return PhPluginsClrHost; - } -} - -BOOLEAN PhpLoadClrPlugin( - __in PPH_STRING FileName, - __out_opt PPH_STRING *ErrorMessage - ) -{ - ICLRRuntimeHost *clrHost; - HRESULT result; - ULONG returnValue; - - if (!PhPluginsClrHostInitialized) - { - _CLRCreateInstance CLRCreateInstance_I; - _CorBindToRuntimeEx CorBindToRuntimeEx_I; - HMODULE mscoreeHandle; - - if (mscoreeHandle = LoadLibrary(L"mscoree.dll")) - { - CLRCreateInstance_I = (_CLRCreateInstance)GetProcAddress(mscoreeHandle, "CLRCreateInstance"); - - if (!CLRCreateInstance_I || !PhpLoadV4ClrHost(CLRCreateInstance_I)) - { - CorBindToRuntimeEx_I = (_CorBindToRuntimeEx)GetProcAddress(mscoreeHandle, "CorBindToRuntimeEx"); - - if (CorBindToRuntimeEx_I) - PhpLoadV2ClrHost(CorBindToRuntimeEx_I); - } - } - - PhPluginsClrHostInitialized = TRUE; - } - - clrHost = (ICLRRuntimeHost *)PhpGetClrHostForPlugin(FileName, ErrorMessage); - - if (clrHost) - { - ICLRRuntimeHost_Start(clrHost); - - LoadingPluginIsClr = TRUE; - result = ICLRRuntimeHost_ExecuteInDefaultAppDomain( - clrHost, - FileName->Buffer, - L"ProcessHacker.Plugin", - L"PluginEntry", - FileName->Buffer, - &returnValue - ); - LoadingPluginIsClr = FALSE; - - ICLRRuntimeHost_Release(clrHost); - - if (!SUCCEEDED(result)) - { - *ErrorMessage = PhFormatString(L"Error 0x%x", result); - return FALSE; - } - } - else - { - return FALSE; - } - - return TRUE; -} - VOID PhpExecuteCallbackForAllPlugins( - __in PH_PLUGIN_CALLBACK Callback + _In_ PH_PLUGIN_CALLBACK Callback ) { PPH_AVL_LINKS links; @@ -579,7 +372,7 @@ VOID PhpExecuteCallbackForAllPlugins( } BOOLEAN PhpValidatePluginName( - __in PPH_STRINGREF Name + _In_ PPH_STRINGREF Name ) { SIZE_T i; @@ -617,9 +410,9 @@ BOOLEAN PhpValidatePluginName( * function failed. */ PPH_PLUGIN PhRegisterPlugin( - __in PWSTR Name, - __in PVOID DllBase, - __out_opt PPH_PLUGIN_INFORMATION *Information + _In_ PWSTR Name, + _In_ PVOID DllBase, + _Out_opt_ PPH_PLUGIN_INFORMATION *Information ) { PPH_PLUGIN plugin; @@ -633,23 +426,10 @@ PPH_PLUGIN PhRegisterPlugin( if (!PhpValidatePluginName(&pluginName)) return NULL; - if (DllBase) - { - fileName = PhGetDllFileName(DllBase, NULL); + fileName = PhGetDllFileName(DllBase, NULL); - if (!fileName) - return NULL; - } - else - { - // Should only happen for .NET DLLs. - - if (!LoadingPluginFileName) - return NULL; - - fileName = LoadingPluginFileName; - PhReferenceObject(fileName); - } + if (!fileName) + return NULL; plugin = PhAllocate(sizeof(PH_PLUGIN)); memset(plugin, 0, sizeof(PH_PLUGIN)); @@ -668,9 +448,6 @@ PPH_PLUGIN PhRegisterPlugin( return NULL; } - if (LoadingPluginIsClr) - plugin->Flags |= PH_PLUGIN_FLAG_IS_CLR; - for (i = 0; i < PluginCallbackMaximum; i++) PhInitializeCallback(&plugin->Callbacks[i]); @@ -691,7 +468,7 @@ PPH_PLUGIN PhRegisterPlugin( * was not found. */ PPH_PLUGIN PhFindPlugin( - __in PWSTR Name + _In_ PWSTR Name ) { PPH_AVL_LINKS links; @@ -716,8 +493,8 @@ PPH_PLUGIN PhFindPlugin( * specific to a plugin. */ PPH_CALLBACK PhGetPluginCallback( - __in PPH_PLUGIN Plugin, - __in PH_PLUGIN_CALLBACK Callback + _In_ PPH_PLUGIN Plugin, + _In_ PH_PLUGIN_CALLBACK Callback ) { if (Callback >= PluginCallbackMaximum) @@ -735,7 +512,7 @@ PPH_CALLBACK PhGetPluginCallback( * notifications. */ PPH_CALLBACK PhGetGeneralCallback( - __in PH_GENERAL_CALLBACK Callback + _In_ PH_GENERAL_CALLBACK Callback ) { if (Callback >= GeneralCallbackMaximum) @@ -755,7 +532,7 @@ PPH_CALLBACK PhGetGeneralCallback( * guaranteed to be unique throughout the program. */ ULONG PhPluginReserveIds( - __in ULONG Count + _In_ ULONG Count ) { ULONG nextPluginId; @@ -789,12 +566,12 @@ ULONG PhPluginReserveIds( * will contain the \a Id and \a Context values passed to this function. */ ULONG_PTR PhPluginAddMenuItem( - __in PPH_PLUGIN Plugin, - __in ULONG_PTR Location, - __in_opt PWSTR InsertAfter, - __in ULONG Id, - __in PWSTR Text, - __in_opt PVOID Context + _In_ PPH_PLUGIN Plugin, + _In_ ULONG_PTR Location, + _In_opt_ PWSTR InsertAfter, + _In_ ULONG Id, + _In_ PWSTR Text, + _In_opt_ PVOID Context ) { PH_ADDMENUITEM addMenuItem; @@ -824,7 +601,7 @@ ULONG_PTR PhPluginAddMenuItem( * Retrieves current system statistics. */ VOID PhPluginGetSystemStatistics( - __out PPH_PLUGIN_SYSTEM_STATISTICS Statistics + _Out_ PPH_PLUGIN_SYSTEM_STATISTICS Statistics ) { Statistics->Performance = &PhPerfInformation; @@ -869,7 +646,7 @@ VOID PhPluginGetSystemStatistics( } static VOID NTAPI PhpPluginEMenuItemDeleteFunction( - __in PPH_EMENU_ITEM Item + _In_ PPH_EMENU_ITEM Item ) { PPH_PLUGIN_MENU_ITEM pluginMenuItem; @@ -900,11 +677,11 @@ static VOID NTAPI PhpPluginEMenuItemDeleteFunction( * will contain the \a Id and \a Context values passed to this function. */ PPH_EMENU_ITEM PhPluginCreateEMenuItem( - __in PPH_PLUGIN Plugin, - __in ULONG Flags, - __in ULONG Id, - __in PWSTR Text, - __in_opt PVOID Context + _In_ PPH_PLUGIN Plugin, + _In_ ULONG Flags, + _In_ ULONG Id, + _In_ PWSTR Text, + _In_opt_ PVOID Context ) { PPH_EMENU_ITEM item; @@ -933,8 +710,8 @@ PPH_EMENU_ITEM PhPluginCreateEMenuItem( * \remarks This function is reserved for internal use. */ BOOLEAN PhPluginTriggerEMenuItem( - __in HWND OwnerWindow, - __in PPH_EMENU_ITEM Item + _In_ HWND OwnerWindow, + _In_ PPH_EMENU_ITEM Item ) { PPH_PLUGIN_MENU_ITEM pluginMenuItem; @@ -964,12 +741,12 @@ BOOLEAN PhPluginTriggerEMenuItem( * \param SortFunction The sort function for the column. */ BOOLEAN PhPluginAddTreeNewColumn( - __in PPH_PLUGIN Plugin, - __in PVOID CmData, - __in PPH_TREENEW_COLUMN Column, - __in ULONG SubId, - __in_opt PVOID Context, - __in_opt PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction + _In_ PPH_PLUGIN Plugin, + _In_ PVOID CmData, + _In_ PPH_TREENEW_COLUMN Column, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_opt_ PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction ) { return !!PhCmCreateColumn( @@ -992,11 +769,11 @@ BOOLEAN PhPluginAddTreeNewColumn( * \param DeleteCallback The object deletion callback. */ VOID PhPluginSetObjectExtension( - __in PPH_PLUGIN Plugin, - __in PH_EM_OBJECT_TYPE ObjectType, - __in ULONG ExtensionSize, - __in_opt PPH_EM_OBJECT_CALLBACK CreateCallback, - __in_opt PPH_EM_OBJECT_CALLBACK DeleteCallback + _In_ PPH_PLUGIN Plugin, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ ULONG ExtensionSize, + _In_opt_ PPH_EM_OBJECT_CALLBACK CreateCallback, + _In_opt_ PPH_EM_OBJECT_CALLBACK DeleteCallback ) { PhEmSetObjectExtension( @@ -1016,9 +793,9 @@ VOID PhPluginSetObjectExtension( * \param ObjectType The type of object for which an extension has been registered. */ PVOID PhPluginGetObjectExtension( - __in PPH_PLUGIN Plugin, - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType + _In_ PPH_PLUGIN Plugin, + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType ) { return PhEmGetObjectExtension( @@ -1042,12 +819,12 @@ PVOID PhPluginGetObjectExtension( * contains registration information. */ struct _PH_NF_ICON *PhPluginRegisterIcon( - __in PPH_PLUGIN Plugin, - __in ULONG SubId, - __in_opt PVOID Context, - __in PWSTR Text, - __in ULONG Flags, - __in struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData + _In_ PPH_PLUGIN Plugin, + _In_ ULONG SubId, + _In_opt_ PVOID Context, + _In_ PWSTR Text, + _In_ ULONG Flags, + _In_ struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData ) { return PhNfRegisterIcon( @@ -1069,8 +846,8 @@ struct _PH_NF_ICON *PhPluginRegisterIcon( * structure. */ VOID PhPluginEnableTreeNewNotify( - __in PPH_PLUGIN Plugin, - __in PVOID CmData + _In_ PPH_PLUGIN Plugin, + _In_ PVOID CmData ) { PhCmSetNotifyPlugin(CmData, Plugin); diff --git a/2.x/trunk/ProcessHacker/plugman.c b/2.x/trunk/ProcessHacker/plugman.c index aab8a21b7..c4b1a80c3 100644 --- a/2.x/trunk/ProcessHacker/plugman.c +++ b/2.x/trunk/ProcessHacker/plugman.c @@ -33,14 +33,14 @@ static PPH_LIST DisabledPluginInstances; // fake PH_PLUGIN structures for disabl static PPH_HASHTABLE DisabledPluginLookup; // list of all disabled plugins (including fake structures) by PH_PLUGIN address INT_PTR CALLBACK PhpPluginsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowPluginsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ) { if (PhPluginsEnabled) @@ -60,7 +60,7 @@ VOID PhShowPluginsDialog( } PWSTR PhpGetPluginBaseName( - __in PPH_PLUGIN Plugin + _In_ PPH_PLUGIN Plugin ) { PWSTR baseName; @@ -84,7 +84,7 @@ PWSTR PhpGetPluginBaseName( } PWSTR PhpGetPluginDisableButtonText( - __in PWSTR BaseName + _In_ PWSTR BaseName ) { PH_STRINGREF baseName; @@ -98,7 +98,7 @@ PWSTR PhpGetPluginDisableButtonText( } VOID PhpRefreshPluginDetails( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { PPH_STRING fileName; @@ -159,7 +159,7 @@ VOID PhpRefreshPluginDetails( } BOOLEAN PhpIsPluginLoadedByBaseName( - __in PPH_STRINGREF BaseName + _In_ PPH_STRINGREF BaseName ) { PPH_AVL_LINKS links; @@ -186,7 +186,7 @@ BOOLEAN PhpIsPluginLoadedByBaseName( } PPH_PLUGIN PhpCreateDisabledPlugin( - __in PPH_STRINGREF BaseName + _In_ PPH_STRINGREF BaseName ) { PPH_PLUGIN plugin; @@ -202,7 +202,7 @@ PPH_PLUGIN PhpCreateDisabledPlugin( } VOID PhpFreeDisabledPlugin( - __in PPH_PLUGIN Plugin + _In_ PPH_PLUGIN Plugin ) { PhFree(Plugin->Name); @@ -246,10 +246,10 @@ VOID PhpAddDisabledPlugins( } VOID PhpUpdateDisabledPlugin( - __in HWND hwndDlg, - __in INT ItemIndex, - __in PPH_PLUGIN Plugin, - __in BOOLEAN NewDisabledState + _In_ HWND hwndDlg, + _In_ INT ItemIndex, + _In_ PPH_PLUGIN Plugin, + _In_ BOOLEAN NewDisabledState ) { if (NewDisabledState) @@ -273,15 +273,13 @@ VOID PhpUpdateDisabledPlugin( } static COLORREF PhpPluginColorFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ) { PPH_PLUGIN plugin = Param; - if (plugin->Flags & PH_PLUGIN_FLAG_IS_CLR) - return RGB(0xde, 0xff, 0x00); if (PhFindItemSimpleHashtable(DisabledPluginLookup, plugin)) return RGB(0x77, 0x77, 0x77); // fake disabled plugin @@ -289,10 +287,10 @@ static COLORREF PhpPluginColorFunction( } INT_PTR CALLBACK PhpPluginsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/procprp.c b/2.x/trunk/ProcessHacker/procprp.c index 929168a2d..247d9a116 100644 --- a/2.x/trunk/ProcessHacker/procprp.c +++ b/2.x/trunk/ProcessHacker/procprp.c @@ -2,7 +2,7 @@ * Process Hacker - * process properties * - * Copyright (C) 2009-2012 wj32 + * Copyright (C) 2009-2013 wj32 * * This file is part of Process Hacker. * @@ -28,6 +28,7 @@ #include #include #include +#include #include #define SET_BUTTON_BITMAP(Id, Bitmap) \ @@ -37,6 +38,12 @@ PPH_OBJECT_TYPE PhpProcessPropContextType; PPH_OBJECT_TYPE PhpProcessPropPageContextType; static RECT MinimumSize = { -1, -1, -1, -1 }; +static PWSTR ProtectedSignerStrings[] = { L"", L" (Authenticode)", L" (CodeGen)", L" (Antimalware)", L" (Lsa)", L" (Windows)", L" (WinTcb)" }; + +static PH_STRINGREF LoadingText = PH_STRINGREF_INIT(L"Loading..."); +static PH_STRINGREF EmptyThreadsText = PH_STRINGREF_INIT(L"There are no threads to display."); +static PH_STRINGREF EmptyModulesText = PH_STRINGREF_INIT(L"There are no modules to display."); +static PH_STRINGREF EmptyHandlesText = PH_STRINGREF_INIT(L"There are no handles to display."); BOOLEAN PhProcessPropInitialization( VOID @@ -62,8 +69,8 @@ BOOLEAN PhProcessPropInitialization( } PPH_PROCESS_PROPCONTEXT PhCreateProcessPropContext( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ) { PPH_PROCESS_PROPCONTEXT propContext; @@ -127,8 +134,8 @@ PPH_PROCESS_PROPCONTEXT PhCreateProcessPropContext( } VOID NTAPI PhpProcessPropContextDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_PROCESS_PROPCONTEXT propContext = (PPH_PROCESS_PROPCONTEXT)Object; @@ -139,24 +146,24 @@ VOID NTAPI PhpProcessPropContextDeleteProcedure( } VOID PhRefreshProcessPropContext( - __inout PPH_PROCESS_PROPCONTEXT PropContext + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext ) { PropContext->PropSheetHeader.hIcon = PropContext->ProcessItem->SmallIcon; } VOID PhSetSelectThreadIdProcessPropContext( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in HANDLE ThreadId + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ HANDLE ThreadId ) { PropContext->SelectThreadId = ThreadId; } INT CALLBACK PhpPropSheetProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam ) { #define PROPSHEET_ADD_STYLE (WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME); @@ -212,17 +219,17 @@ INT CALLBACK PhpPropSheetProc( } PPH_PROCESS_PROPSHEETCONTEXT PhpGetPropSheetContext( - __in HWND hwnd + _In_ HWND hwnd ) { return (PPH_PROCESS_PROPSHEETCONTEXT)GetProp(hwnd, PhMakeContextAtom()); } LRESULT CALLBACK PhpPropSheetWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPH_PROCESS_PROPSHEETCONTEXT propSheetContext = PhpGetPropSheetContext(hwnd); @@ -294,7 +301,7 @@ LRESULT CALLBACK PhpPropSheetWndProc( } BOOLEAN PhpInitializePropSheetLayoutStage1( - __in HWND hwnd + _In_ HWND hwnd ) { PPH_PROCESS_PROPSHEETCONTEXT propSheetContext = PhpGetPropSheetContext(hwnd); @@ -330,7 +337,7 @@ BOOLEAN PhpInitializePropSheetLayoutStage1( } VOID PhpInitializePropSheetLayoutStage2( - __in HWND hwnd + _In_ HWND hwnd ) { PH_RECTANGLE windowRectangle; @@ -356,8 +363,8 @@ VOID PhpInitializePropSheetLayoutStage2( } BOOLEAN PhAddProcessPropPage( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in __assumeRefs(1) PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ _Assume_refs_(1) PPH_PROCESS_PROPPAGECONTEXT PropPageContext ) { HPROPSHEETPAGE propSheetPageHandle; @@ -383,8 +390,8 @@ BOOLEAN PhAddProcessPropPage( } BOOLEAN PhAddProcessPropPage2( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in HPROPSHEETPAGE PropSheetPageHandle + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ HPROPSHEETPAGE PropSheetPageHandle ) { if (PropContext->PropSheetHeader.nPages == PH_PROCESS_PROPCONTEXT_MAXPAGES) @@ -398,19 +405,19 @@ BOOLEAN PhAddProcessPropPage2( } PPH_PROCESS_PROPPAGECONTEXT PhCreateProcessPropPageContext( - __in LPCWSTR Template, - __in DLGPROC DlgProc, - __in_opt PVOID Context + _In_ LPCWSTR Template, + _In_ DLGPROC DlgProc, + _In_opt_ PVOID Context ) { return PhCreateProcessPropPageContextEx(NULL, Template, DlgProc, Context); } PPH_PROCESS_PROPPAGECONTEXT PhCreateProcessPropPageContextEx( - __in_opt PVOID InstanceHandle, - __in LPCWSTR Template, - __in DLGPROC DlgProc, - __in_opt PVOID Context + _In_opt_ PVOID InstanceHandle, + _In_ LPCWSTR Template, + _In_ DLGPROC DlgProc, + _In_opt_ PVOID Context ) { PPH_PROCESS_PROPPAGECONTEXT propPageContext; @@ -440,8 +447,8 @@ PPH_PROCESS_PROPPAGECONTEXT PhCreateProcessPropPageContextEx( } VOID NTAPI PhpProcessPropPageContextDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_PROCESS_PROPPAGECONTEXT propPageContext = (PPH_PROCESS_PROPPAGECONTEXT)Object; @@ -451,9 +458,9 @@ VOID NTAPI PhpProcessPropPageContextDeleteProcedure( } INT CALLBACK PhpStandardPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ) { PPH_PROCESS_PROPPAGECONTEXT propPageContext; @@ -469,12 +476,12 @@ INT CALLBACK PhpStandardPropPageProc( } FORCEINLINE BOOLEAN PhpPropPageDlgProcHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam, - __out LPPROPSHEETPAGE *PropSheetPage, - __out PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, - __out PPH_PROCESS_ITEM *ProcessItem + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam, + _Out_ LPPROPSHEETPAGE *PropSheetPage, + _Out_ PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, + _Out_ PPH_PROCESS_ITEM *ProcessItem ) { LPPROPSHEETPAGE propSheetPage; @@ -499,36 +506,36 @@ FORCEINLINE BOOLEAN PhpPropPageDlgProcHeader( } BOOLEAN PhPropPageDlgProcHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam, - __out LPPROPSHEETPAGE *PropSheetPage, - __out PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, - __out PPH_PROCESS_ITEM *ProcessItem + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam, + _Out_ LPPROPSHEETPAGE *PropSheetPage, + _Out_ PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, + _Out_ PPH_PROCESS_ITEM *ProcessItem ) { return PhpPropPageDlgProcHeader(hwndDlg, uMsg, lParam, PropSheetPage, PropPageContext, ProcessItem); } VOID PhpPropPageDlgProcDestroy( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { RemoveProp(hwndDlg, PhMakeContextAtom()); } VOID PhPropPageDlgProcDestroy( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { PhpPropPageDlgProcDestroy(hwndDlg); } PPH_LAYOUT_ITEM PhAddPropPageLayoutItem( - __in HWND hwnd, - __in HWND Handle, - __in PPH_LAYOUT_ITEM ParentItem, - __in ULONG Anchor + _In_ HWND hwnd, + _In_ HWND Handle, + _In_ PPH_LAYOUT_ITEM ParentItem, + _In_ ULONG Anchor ) { HWND parent; @@ -589,7 +596,7 @@ PPH_LAYOUT_ITEM PhAddPropPageLayoutItem( } VOID PhDoPropPageLayout( - __in HWND hwnd + _In_ HWND hwnd ) { HWND parent; @@ -601,16 +608,16 @@ VOID PhDoPropPageLayout( } NTSTATUS PhpProcessGeneralOpenProcess( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { return PhOpenProcess(Handle, DesiredAccess, (HANDLE)Context); } FORCEINLINE PWSTR PhpGetStringOrNa( - __in PPH_STRING String + _In_ PPH_STRING String ) { if (String) @@ -620,8 +627,8 @@ FORCEINLINE PWSTR PhpGetStringOrNa( } VOID PhpUpdateProcessDep( - __in HWND hwndDlg, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_ITEM ProcessItem ) { HANDLE processHandle; @@ -678,10 +685,10 @@ VOID PhpUpdateProcessDep( } INT_PTR CALLBACK PhpProcessGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -717,7 +724,6 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( SET_BUTTON_BITMAP(IDC_OPENFILENAME, folder); SET_BUTTON_BITMAP(IDC_VIEWPARENTPROCESS, magnifier); SET_BUTTON_BITMAP(IDC_EDITDEP, pencil); - SET_BUTTON_BITMAP(IDC_EDITPROTECTION, pencil); } // File @@ -744,8 +750,10 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( { if (processItem->VerifySignerName) { - SetDlgItemText(hwndDlg, IDC_COMPANYNAME, - PhaConcatStrings2(L"(Verified) ", processItem->VerifySignerName->Buffer)->Buffer); + SetDlgItemText(hwndDlg, IDC_COMPANYNAME_LINK, + PhaFormatString(L"(Verified) %s", processItem->VerifySignerName->Buffer)->Buffer); + ShowWindow(GetDlgItem(hwndDlg, IDC_COMPANYNAME), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_COMPANYNAME_LINK), SW_SHOW); } else { @@ -756,6 +764,14 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( )->Buffer); } } + else if (processItem->VerifyResult != VrUnknown) + { + SetDlgItemText(hwndDlg, IDC_COMPANYNAME, + PhaConcatStrings2( + L"(UNVERIFIED) ", + PhGetStringOrEmpty(processItem->VersionInfo.CompanyName) + )->Buffer); + } else { SetDlgItemText(hwndDlg, IDC_COMPANYNAME, @@ -884,13 +900,52 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( #endif } - // Protected + // Protection SetDlgItemText(hwndDlg, IDC_PROTECTION, L"N/A"); if (WINDOWS_HAS_LIMITED_ACCESS && processHandle) { - if (KphIsConnected()) + if (WindowsVersion >= WINDOWS_81) + { + PS_PROTECTION protection; + + if (NT_SUCCESS(NtQueryInformationProcess( + processHandle, + ProcessProtectionInformation, + &protection, + sizeof(PS_PROTECTION), + NULL + ))) + { + PWSTR type; + PWSTR signer; + + switch (protection.Type) + { + case PsProtectedTypeNone: + type = L"None"; + break; + case PsProtectedTypeProtectedLight: + type = L"Light"; + break; + case PsProtectedTypeProtected: + type = L"Full"; + break; + default: + type = L"Unknown"; + break; + } + + if (protection.Signer < sizeof(ProtectedSignerStrings) / sizeof(PWSTR)) + signer = ProtectedSignerStrings[protection.Signer]; + else + signer = L""; + + SetDlgItemText(hwndDlg, IDC_PROTECTION, PhaConcatStrings2(type, signer)->Buffer); + } + } + else if (KphIsConnected()) { KPH_PROCESS_PROTECTION_INFORMATION protectionInfo; @@ -902,7 +957,7 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( NULL ))) { - SetDlgItemText(hwndDlg, IDC_PROTECTION, protectionInfo.IsProtectedProcess ? L"Yes" : L"No"); + SetDlgItemText(hwndDlg, IDC_PROTECTION, protectionInfo.IsProtectedProcess ? L"Yes" : L"None"); EnableWindow(GetDlgItem(hwndDlg, IDC_EDITPROTECTION), TRUE); } } @@ -915,8 +970,7 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( &extendedBasicInfo ))) { - SetDlgItemText(hwndDlg, IDC_PROTECTION, - extendedBasicInfo.IsProtectedProcess ? L"Yes" : L"No"); + SetDlgItemText(hwndDlg, IDC_PROTECTION, extendedBasicInfo.IsProtectedProcess ? L"Yes" : L"None"); } } } @@ -1015,6 +1069,8 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( dialogItem, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT); PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_COMPANYNAME), dialogItem, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT); + PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_COMPANYNAME_LINK), + dialogItem, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT); PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_VERSION), dialogItem, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT); PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_FILENAME), @@ -1122,14 +1178,48 @@ INT_PTR CALLBACK PhpProcessGeneralDlgProc( } } break; + case WM_NOTIFY: + { + LPNMHDR header = (LPNMHDR)lParam; + + switch (header->code) + { + case NM_CLICK: + { + switch (header->idFrom) + { + case IDC_COMPANYNAME_LINK: + { + if (processItem->FileName) + { + PH_VERIFY_FILE_INFO info; + + memset(&info, 0, sizeof(PH_VERIFY_FILE_INFO)); + info.FileName = processItem->FileName->Buffer; + info.Flags = PH_VERIFY_VIEW_PROPERTIES; + info.hWnd = hwndDlg; + PhVerifyFileWithAdditionalCatalog( + &info, + PhGetString(processItem->PackageFullName), + NULL + ); + } + } + break; + } + } + break; + } + } + break; } return FALSE; } static VOID NTAPI StatisticsUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_STATISTICS_CONTEXT statisticsContext = (PPH_STATISTICS_CONTEXT)Context; @@ -1139,9 +1229,9 @@ static VOID NTAPI StatisticsUpdateHandler( } VOID PhpUpdateProcessStatistics( - __in HWND hwndDlg, - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_STATISTICS_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_STATISTICS_CONTEXT Context ) { WCHAR timeSpan[PH_TIMESPAN_STR_LEN_1]; @@ -1306,10 +1396,10 @@ VOID PhpUpdateProcessStatistics( } INT_PTR CALLBACK PhpProcessStatisticsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -1424,8 +1514,8 @@ INT_PTR CALLBACK PhpProcessStatisticsDlgProc( } static VOID NTAPI PerformanceUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PERFORMANCE_CONTEXT performanceContext = (PPH_PERFORMANCE_CONTEXT)Context; @@ -1434,10 +1524,10 @@ static VOID NTAPI PerformanceUpdateHandler( } INT_PTR CALLBACK PhpProcessPerformanceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -1879,8 +1969,8 @@ INT_PTR CALLBACK PhpProcessPerformanceDlgProc( } static VOID NTAPI ThreadAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_THREADS_CONTEXT threadsContext = (PPH_THREADS_CONTEXT)Context; @@ -1896,8 +1986,8 @@ static VOID NTAPI ThreadAddedHandler( } static VOID NTAPI ThreadModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_THREADS_CONTEXT threadsContext = (PPH_THREADS_CONTEXT)Context; @@ -1906,8 +1996,8 @@ static VOID NTAPI ThreadModifiedHandler( } static VOID NTAPI ThreadRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_THREADS_CONTEXT threadsContext = (PPH_THREADS_CONTEXT)Context; @@ -1916,8 +2006,8 @@ static VOID NTAPI ThreadRemovedHandler( } static VOID NTAPI ThreadsUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_THREADS_CONTEXT threadsContext = (PPH_THREADS_CONTEXT)Context; @@ -1926,8 +2016,8 @@ static VOID NTAPI ThreadsUpdatedHandler( } static VOID NTAPI ThreadsLoadingStateChangedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_THREADS_CONTEXT threadsContext = (PPH_THREADS_CONTEXT)Context; @@ -1942,10 +2032,10 @@ static VOID NTAPI ThreadsLoadingStateChangedHandler( } VOID PhpInitializeThreadMenu( - __in PPH_EMENU Menu, - __in HANDLE ProcessId, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ PPH_EMENU Menu, + _In_ HANDLE ProcessId, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ) { PPH_EMENU_ITEM item; @@ -2164,18 +2254,18 @@ VOID PhpInitializeThreadMenu( } static NTSTATUS NTAPI PhpThreadPermissionsOpenThread( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { return PhOpenThread(Handle, DesiredAccess, (HANDLE)Context); } static NTSTATUS NTAPI PhpOpenThreadTokenObject( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { return PhOpenThreadToken( @@ -2187,9 +2277,9 @@ static NTSTATUS NTAPI PhpOpenThreadTokenObject( } VOID PhpUpdateThreadDetails( - __in HWND hwndDlg, - __in PPH_THREADS_CONTEXT Context, - __in BOOLEAN Force + _In_ HWND hwndDlg, + _In_ PPH_THREADS_CONTEXT Context, + _In_ BOOLEAN Force ) { PPH_THREAD_ITEM *threads; @@ -2212,6 +2302,7 @@ VOID PhpUpdateThreadDetails( ULONG ioPriorityInteger; ULONG pagePriorityInteger; PROCESSOR_NUMBER idealProcessorNumber; + ULONG suspendCount; PhGetSelectedThreadItems(&Context->ListContext, &threads, &numberOfThreads); @@ -2279,6 +2370,17 @@ VOID PhpUpdateThreadDetails( PhFormatToBuffer(format, 3, idealProcessor, sizeof(idealProcessor), NULL); } + if (threadItem->WaitReason == Suspended && NT_SUCCESS(NtQueryInformationThread(threadHandle, ThreadSuspendCount, &suspendCount, sizeof(ULONG), NULL))) + { + PH_FORMAT format[4]; + + PhInitFormatSR(&format[0], state->sr); + PhInitFormatS(&format[1], L" ("); + PhInitFormatU(&format[2], suspendCount); + PhInitFormatS(&format[3], L")"); + state = PHA_DEREFERENCE(PhFormat(format, 4, 30)); + } + NtClose(threadHandle); } } @@ -2306,10 +2408,10 @@ VOID PhpUpdateThreadDetails( } VOID PhShowThreadContextMenu( - __in HWND hwndDlg, - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_THREADS_CONTEXT Context, - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_THREADS_CONTEXT Context, + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ) { PPH_THREAD_ITEM *threads; @@ -2371,10 +2473,10 @@ VOID PhShowThreadContextMenu( } INT_PTR CALLBACK PhpProcessThreadsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -2444,6 +2546,7 @@ INT_PTR CALLBACK PhpProcessThreadsDlgProc( tnHandle = threadsContext->ListContext.TreeNewHandle; BringWindowToTop(tnHandle); PhInitializeThreadList(hwndDlg, tnHandle, processItem, &threadsContext->ListContext); + TreeNew_SetEmptyText(tnHandle, &EmptyThreadsText, 0); threadsContext->NeedsRedraw = FALSE; // Use Cycles instead of Context Switches on Vista and above, but only when we can @@ -3012,9 +3115,9 @@ INT_PTR CALLBACK PhpProcessThreadsDlgProc( } static NTSTATUS NTAPI PhpOpenProcessToken( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -3034,10 +3137,10 @@ static NTSTATUS NTAPI PhpOpenProcessToken( } INT_PTR CALLBACK PhpProcessTokenHookProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -3106,8 +3209,8 @@ INT_PTR CALLBACK PhpProcessTokenHookProc( } static VOID NTAPI ModuleAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_MODULES_CONTEXT modulesContext = (PPH_MODULES_CONTEXT)Context; @@ -3123,8 +3226,8 @@ static VOID NTAPI ModuleAddedHandler( } static VOID NTAPI ModuleModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_MODULES_CONTEXT modulesContext = (PPH_MODULES_CONTEXT)Context; @@ -3133,8 +3236,8 @@ static VOID NTAPI ModuleModifiedHandler( } static VOID NTAPI ModuleRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_MODULES_CONTEXT modulesContext = (PPH_MODULES_CONTEXT)Context; @@ -3143,8 +3246,8 @@ static VOID NTAPI ModuleRemovedHandler( } static VOID NTAPI ModulesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_MODULES_CONTEXT modulesContext = (PPH_MODULES_CONTEXT)Context; @@ -3153,10 +3256,10 @@ static VOID NTAPI ModulesUpdatedHandler( } VOID PhpInitializeModuleMenu( - __in PPH_EMENU Menu, - __in HANDLE ProcessId, - __in PPH_MODULE_ITEM *Modules, - __in ULONG NumberOfModules + _In_ PPH_EMENU Menu, + _In_ HANDLE ProcessId, + _In_ PPH_MODULE_ITEM *Modules, + _In_ ULONG NumberOfModules ) { PPH_EMENU_ITEM item; @@ -3188,10 +3291,10 @@ VOID PhpInitializeModuleMenu( } VOID PhShowModuleContextMenu( - __in HWND hwndDlg, - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_MODULES_CONTEXT Context, - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_MODULES_CONTEXT Context, + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ) { PPH_MODULE_ITEM *modules; @@ -3253,10 +3356,10 @@ VOID PhShowModuleContextMenu( } INT_PTR CALLBACK PhpProcessModulesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -3327,7 +3430,10 @@ INT_PTR CALLBACK PhpProcessModulesDlgProc( tnHandle = modulesContext->ListContext.TreeNewHandle; BringWindowToTop(tnHandle); PhInitializeModuleList(hwndDlg, tnHandle, processItem, &modulesContext->ListContext); + TreeNew_SetEmptyText(tnHandle, &LoadingText, 0); modulesContext->NeedsRedraw = FALSE; + modulesContext->LastRunStatus = -1; + modulesContext->ErrorMessage = NULL; PhEmCallObjectOperation(EmModulesContextType, modulesContext, EmObjectCreate); @@ -3382,6 +3488,7 @@ INT_PTR CALLBACK PhpProcessModulesDlgProc( PhSaveSettingsModuleList(&modulesContext->ListContext); PhDeleteModuleList(&modulesContext->ListContext); + PhSwapReference(&modulesContext->ErrorMessage, NULL); PhFree(modulesContext); PhpPropPageDlgProcDestroy(hwndDlg); @@ -3546,6 +3653,32 @@ INT_PTR CALLBACK PhpProcessModulesDlgProc( { PhTickModuleNodes(&modulesContext->ListContext); + if (modulesContext->LastRunStatus != modulesContext->Provider->RunStatus) + { + NTSTATUS status; + PPH_STRING message; + + status = modulesContext->Provider->RunStatus; + modulesContext->LastRunStatus = status; + + if (!PH_IS_REAL_PROCESS_ID(processItem->ProcessId)) + status = STATUS_SUCCESS; + + if (NT_SUCCESS(status)) + { + TreeNew_SetEmptyText(tnHandle, &EmptyModulesText, 0); + } + else + { + message = PhGetStatusMessage(status, 0); + PhSwapReference2(&modulesContext->ErrorMessage, PhFormatString(L"Unable to query module information:\n%s", PhGetStringOrDefault(message, L"Unknown error."))); + PhSwapReference(&message, NULL); + TreeNew_SetEmptyText(tnHandle, &modulesContext->ErrorMessage->sr, 0); + } + + InvalidateRect(tnHandle, NULL, FALSE); + } + if (modulesContext->NeedsRedraw) { TreeNew_SetRedraw(tnHandle, TRUE); @@ -3559,8 +3692,8 @@ INT_PTR CALLBACK PhpProcessModulesDlgProc( } VOID PhpRefreshProcessMemoryList( - __in HWND hwndDlg, - __in PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_PROPPAGECONTEXT PropPageContext ) { PPH_MEMORY_CONTEXT memoryContext = PropPageContext->Context; @@ -3578,8 +3711,8 @@ VOID PhpRefreshProcessMemoryList( } BOOLEAN NTAPI PhpProcessMemoryCallback( - __in PPH_MEMORY_PROVIDER Provider, - __in __assumeRefs(1) PPH_MEMORY_ITEM MemoryItem + _In_ PPH_MEMORY_PROVIDER Provider, + _In_ _Assume_refs_(1) PPH_MEMORY_ITEM MemoryItem ) { PPH_PROCESS_PROPPAGECONTEXT propPageContext = Provider->Context; @@ -3645,8 +3778,8 @@ BOOLEAN NTAPI PhpProcessMemoryCallback( } VOID PhpUpdateMemoryItemInListView( - __in HANDLE ListViewHandle, - __in PPH_MEMORY_ITEM MemoryItem + _In_ HANDLE ListViewHandle, + _In_ PPH_MEMORY_ITEM MemoryItem ) { INT lvItemIndex; @@ -3663,9 +3796,9 @@ VOID PhpUpdateMemoryItemInListView( } INT NTAPI PhpMemoryAddressCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPH_MEMORY_ITEM item1 = Item1; @@ -3675,9 +3808,9 @@ INT NTAPI PhpMemoryAddressCompareFunction( } INT NTAPI PhpMemorySizeCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PPH_MEMORY_ITEM item1 = Item1; @@ -3687,10 +3820,10 @@ INT NTAPI PhpMemorySizeCompareFunction( } VOID PhpInitializeMemoryMenu( - __in PPH_EMENU Menu, - __in HANDLE ProcessId, - __in PPH_MEMORY_ITEM *MemoryItems, - __in ULONG NumberOfMemoryItems + _In_ PPH_EMENU Menu, + _In_ HANDLE ProcessId, + _In_ PPH_MEMORY_ITEM *MemoryItems, + _In_ ULONG NumberOfMemoryItems ) { if (NumberOfMemoryItems == 0) @@ -3721,10 +3854,10 @@ VOID PhpInitializeMemoryMenu( } INT_PTR CALLBACK PhpProcessMemoryDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -4144,10 +4277,10 @@ INT_PTR CALLBACK PhpProcessMemoryDlgProc( } INT_PTR CALLBACK PhpProcessEnvironmentDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -4264,8 +4397,8 @@ INT_PTR CALLBACK PhpProcessEnvironmentDlgProc( } static VOID NTAPI HandleAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_HANDLES_CONTEXT handlesContext = (PPH_HANDLES_CONTEXT)Context; @@ -4281,8 +4414,8 @@ static VOID NTAPI HandleAddedHandler( } static VOID NTAPI HandleModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_HANDLES_CONTEXT handlesContext = (PPH_HANDLES_CONTEXT)Context; @@ -4291,8 +4424,8 @@ static VOID NTAPI HandleModifiedHandler( } static VOID NTAPI HandleRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_HANDLES_CONTEXT handlesContext = (PPH_HANDLES_CONTEXT)Context; @@ -4301,8 +4434,8 @@ static VOID NTAPI HandleRemovedHandler( } static VOID NTAPI HandlesUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_HANDLES_CONTEXT handlesContext = (PPH_HANDLES_CONTEXT)Context; @@ -4310,12 +4443,259 @@ static VOID NTAPI HandlesUpdatedHandler( PostMessage(handlesContext->WindowHandle, WM_PH_HANDLES_UPDATED, 0, 0); } +static NTSTATUS PhpDuplicateHandleFromProcessItem( + _Out_ PHANDLE NewHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ProcessId, + _In_ HANDLE Handle + ) +{ + NTSTATUS status; + HANDLE processHandle; + + if (!NT_SUCCESS(status = PhOpenProcess( + &processHandle, + PROCESS_DUP_HANDLE, + ProcessId + ))) + return status; + + status = PhDuplicateObject( + processHandle, + Handle, + NtCurrentProcess(), + NewHandle, + DesiredAccess, + 0, + 0 + ); + NtClose(processHandle); + + return status; +} + +static VOID PhpShowProcessPropContext( + _In_ PVOID Parameter + ) +{ + PhShowProcessProperties(Parameter); + PhDereferenceObject(Parameter); +} + +VOID PhInsertHandleObjectPropertiesEMenuItems( + _In_ struct _PH_EMENU_ITEM *Menu, + _In_ ULONG InsertBeforeId, + _In_ BOOLEAN EnableShortcut, + _In_ PPH_HANDLE_ITEM_INFO Info + ) +{ + PPH_EMENU_ITEM parentItem; + ULONG indexInParent; + + if (!PhFindEMenuItemEx(Menu, 0, NULL, InsertBeforeId, &parentItem, &indexInParent)) + return; + + if (PhEqualString2(Info->TypeName, L"File", TRUE) || PhEqualString2(Info->TypeName, L"DLL", TRUE) || + PhEqualString2(Info->TypeName, L"Mapped File", TRUE) || PhEqualString2(Info->TypeName, L"Mapped Image", TRUE)) + { + PhInsertEMenuItem(parentItem, PhCreateEMenuItem(0, ID_HANDLE_OBJECTPROPERTIES2, L"File Properties", NULL, NULL), indexInParent); + PhInsertEMenuItem(parentItem, PhCreateEMenuItem(0, ID_HANDLE_OBJECTPROPERTIES1, PHA_APPEND_CTRL_ENTER(L"Open &File Location", EnableShortcut), NULL, NULL), indexInParent); + } + else if (PhEqualString2(Info->TypeName, L"Key", TRUE)) + { + PhInsertEMenuItem(parentItem, PhCreateEMenuItem(0, ID_HANDLE_OBJECTPROPERTIES1, PHA_APPEND_CTRL_ENTER(L"Open Key", EnableShortcut), NULL, NULL), indexInParent); + } + else if (PhEqualString2(Info->TypeName, L"Process", TRUE)) + { + PhInsertEMenuItem(parentItem, PhCreateEMenuItem(0, ID_HANDLE_OBJECTPROPERTIES1, PHA_APPEND_CTRL_ENTER(L"Process Properties", EnableShortcut), NULL, NULL), indexInParent); + } + else if (PhEqualString2(Info->TypeName, L"Thread", TRUE)) + { + PhInsertEMenuItem(parentItem, PhCreateEMenuItem(0, ID_HANDLE_OBJECTPROPERTIES1, PHA_APPEND_CTRL_ENTER(L"Go to Thread", EnableShortcut), NULL, NULL), indexInParent); + } +} + +VOID PhShowHandleObjectProperties1( + _In_ HWND hWnd, + _In_ PPH_HANDLE_ITEM_INFO Info + ) +{ + if (PhEqualString2(Info->TypeName, L"File", TRUE) || PhEqualString2(Info->TypeName, L"DLL", TRUE) || + PhEqualString2(Info->TypeName, L"Mapped File", TRUE) || PhEqualString2(Info->TypeName, L"Mapped Image", TRUE)) + { + if (Info->BestObjectName) + PhShellExploreFile(hWnd, Info->BestObjectName->Buffer); + else + PhShowError(hWnd, L"Unable to open file location because the object is unnamed."); + } + else if (PhEqualString2(Info->TypeName, L"Key", TRUE)) + { + if (Info->BestObjectName) + PhShellOpenKey2(hWnd, Info->BestObjectName); + else + PhShowError(hWnd, L"Unable to open key because the object is unnamed."); + } + else if (PhEqualString2(Info->TypeName, L"Process", TRUE)) + { + HANDLE processHandle; + HANDLE processId; + PPH_PROCESS_ITEM targetProcessItem; + + processId = NULL; + + if (KphIsConnected()) + { + if (NT_SUCCESS(PhOpenProcess( + &processHandle, + ProcessQueryAccess, + Info->ProcessId + ))) + { + PROCESS_BASIC_INFORMATION basicInfo; + + if (NT_SUCCESS(KphQueryInformationObject( + processHandle, + Info->Handle, + KphObjectProcessBasicInformation, + &basicInfo, + sizeof(PROCESS_BASIC_INFORMATION), + NULL + ))) + { + processId = basicInfo.UniqueProcessId; + } + + NtClose(processHandle); + } + } + else + { + HANDLE handle; + PROCESS_BASIC_INFORMATION basicInfo; + + if (NT_SUCCESS(PhpDuplicateHandleFromProcessItem( + &handle, + ProcessQueryAccess, + Info->ProcessId, + Info->Handle + ))) + { + if (NT_SUCCESS(PhGetProcessBasicInformation(handle, &basicInfo))) + processId = basicInfo.UniqueProcessId; + + NtClose(handle); + } + } + + if (processId) + { + targetProcessItem = PhReferenceProcessItem(processId); + + if (targetProcessItem) + { + ProcessHacker_ShowProcessProperties(PhMainWndHandle, targetProcessItem); + PhDereferenceObject(targetProcessItem); + } + else + { + PhShowError(hWnd, L"The process does not exist."); + } + } + } + else if (PhEqualString2(Info->TypeName, L"Thread", TRUE)) + { + HANDLE processHandle; + CLIENT_ID clientId; + PPH_PROCESS_ITEM targetProcessItem; + PPH_PROCESS_PROPCONTEXT propContext; + + clientId.UniqueProcess = NULL; + clientId.UniqueThread = NULL; + + if (KphIsConnected()) + { + if (NT_SUCCESS(PhOpenProcess( + &processHandle, + ProcessQueryAccess, + Info->ProcessId + ))) + { + THREAD_BASIC_INFORMATION basicInfo; + + if (NT_SUCCESS(KphQueryInformationObject( + processHandle, + Info->Handle, + KphObjectThreadBasicInformation, + &basicInfo, + sizeof(THREAD_BASIC_INFORMATION), + NULL + ))) + { + clientId = basicInfo.ClientId; + } + + NtClose(processHandle); + } + } + else + { + HANDLE handle; + THREAD_BASIC_INFORMATION basicInfo; + + if (NT_SUCCESS(PhpDuplicateHandleFromProcessItem( + &handle, + ThreadQueryAccess, + Info->ProcessId, + Info->Handle + ))) + { + if (NT_SUCCESS(PhGetThreadBasicInformation(handle, &basicInfo))) + clientId = basicInfo.ClientId; + + NtClose(handle); + } + } + + if (clientId.UniqueProcess) + { + targetProcessItem = PhReferenceProcessItem(clientId.UniqueProcess); + + if (targetProcessItem) + { + propContext = PhCreateProcessPropContext(PhMainWndHandle, targetProcessItem); + PhDereferenceObject(targetProcessItem); + PhSetSelectThreadIdProcessPropContext(propContext, clientId.UniqueThread); + ProcessHacker_Invoke(PhMainWndHandle, PhpShowProcessPropContext, propContext); + } + else + { + PhShowError(hWnd, L"The process does not exist."); + } + } + } +} + +VOID PhShowHandleObjectProperties2( + _In_ HWND hWnd, + _In_ PPH_HANDLE_ITEM_INFO Info + ) +{ + if (PhEqualString2(Info->TypeName, L"File", TRUE) || PhEqualString2(Info->TypeName, L"DLL", TRUE) || + PhEqualString2(Info->TypeName, L"Mapped File", TRUE) || PhEqualString2(Info->TypeName, L"Mapped Image", TRUE)) + { + if (Info->BestObjectName) + PhShellProperties(hWnd, Info->BestObjectName->Buffer); + else + PhShowError(hWnd, L"Unable to open file properties because the object is unnamed."); + } +} + VOID PhpInitializeHandleMenu( - __in PPH_EMENU Menu, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM *Handles, - __in ULONG NumberOfHandles, - __inout PPH_HANDLES_CONTEXT HandlesContext + _In_ PPH_EMENU Menu, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM *Handles, + _In_ ULONG NumberOfHandles, + _Inout_ PPH_HANDLES_CONTEXT HandlesContext ) { PPH_EMENU_ITEM item; @@ -4326,7 +4706,13 @@ VOID PhpInitializeHandleMenu( } else if (NumberOfHandles == 1) { - // Nothing + PH_HANDLE_ITEM_INFO info; + + info.ProcessId = ProcessId; + info.Handle = Handles[0]->Handle; + info.TypeName = Handles[0]->TypeName; + info.BestObjectName = Handles[0]->BestObjectName; + PhInsertHandleObjectPropertiesEMenuItems(Menu, ID_HANDLE_COPY, TRUE, &info); } else { @@ -4367,10 +4753,10 @@ VOID PhpInitializeHandleMenu( } VOID PhShowHandleContextMenu( - __in HWND hwndDlg, - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_HANDLES_CONTEXT Context, - __in PPH_TREENEW_CONTEXT_MENU ContextMenu + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_HANDLES_CONTEXT Context, + _In_ PPH_TREENEW_CONTEXT_MENU ContextMenu ) { PPH_HANDLE_ITEM *handles; @@ -4432,10 +4818,10 @@ VOID PhShowHandleContextMenu( } INT_PTR CALLBACK PhpProcessHandlesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -4504,7 +4890,10 @@ INT_PTR CALLBACK PhpProcessHandlesDlgProc( tnHandle = handlesContext->ListContext.TreeNewHandle; BringWindowToTop(tnHandle); PhInitializeHandleList(hwndDlg, tnHandle, processItem, &handlesContext->ListContext); + TreeNew_SetEmptyText(tnHandle, &EmptyHandlesText, 0); handlesContext->NeedsRedraw = FALSE; + handlesContext->LastRunStatus = -1; + handlesContext->ErrorMessage = NULL; PhEmCallObjectOperation(EmHandlesContextType, handlesContext, EmObjectCreate); @@ -4640,6 +5029,27 @@ INT_PTR CALLBACK PhpProcessHandlesDlgProc( } } break; + case ID_HANDLE_OBJECTPROPERTIES1: + case ID_HANDLE_OBJECTPROPERTIES2: + { + PPH_HANDLE_ITEM handleItem = PhGetSelectedHandleItem(&handlesContext->ListContext); + + if (handleItem) + { + PH_HANDLE_ITEM_INFO info; + + info.ProcessId = processItem->ProcessId; + info.Handle = handleItem->Handle; + info.TypeName = handleItem->TypeName; + info.BestObjectName = handleItem->BestObjectName; + + if (id == ID_HANDLE_OBJECTPROPERTIES1) + PhShowHandleObjectProperties1(hwndDlg, &info); + else + PhShowHandleObjectProperties2(hwndDlg, &info); + } + } + break; case ID_HANDLE_PROPERTIES: { PPH_HANDLE_ITEM handleItem = PhGetSelectedHandleItem(&handlesContext->ListContext); @@ -4732,6 +5142,32 @@ INT_PTR CALLBACK PhpProcessHandlesDlgProc( { PhTickHandleNodes(&handlesContext->ListContext); + if (handlesContext->LastRunStatus != handlesContext->Provider->RunStatus) + { + NTSTATUS status; + PPH_STRING message; + + status = handlesContext->Provider->RunStatus; + handlesContext->LastRunStatus = status; + + if (!PH_IS_REAL_PROCESS_ID(processItem->ProcessId)) + status = STATUS_SUCCESS; + + if (NT_SUCCESS(status)) + { + TreeNew_SetEmptyText(tnHandle, &EmptyHandlesText, 0); + } + else + { + message = PhGetStatusMessage(status, 0); + PhSwapReference2(&handlesContext->ErrorMessage, PhFormatString(L"Unable to query handle information:\n%s", PhGetStringOrDefault(message, L"Unknown error."))); + PhSwapReference(&message, NULL); + TreeNew_SetEmptyText(tnHandle, &handlesContext->ErrorMessage->sr, 0); + } + + InvalidateRect(tnHandle, NULL, FALSE); + } + if (handlesContext->NeedsRedraw) { TreeNew_SetRedraw(tnHandle, TRUE); @@ -4745,9 +5181,9 @@ INT_PTR CALLBACK PhpProcessHandlesDlgProc( } static NTSTATUS NTAPI PhpOpenProcessJob( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -4777,10 +5213,10 @@ static NTSTATUS NTAPI PhpOpenProcessJob( } INT_PTR CALLBACK PhpProcessJobHookProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -4825,8 +5261,8 @@ INT_PTR CALLBACK PhpProcessJobHookProc( } static VOID PhpLayoutServiceListControl( - __in HWND hwndDlg, - __in HWND ServiceListHandle + _In_ HWND hwndDlg, + _In_ HWND ServiceListHandle ) { RECT rect; @@ -4845,10 +5281,10 @@ static VOID PhpLayoutServiceListControl( } INT_PTR CALLBACK PhpProcessServicesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -4937,7 +5373,7 @@ INT_PTR CALLBACK PhpProcessServicesDlgProc( } NTSTATUS PhpProcessPropertiesThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PH_AUTO_POOL autoPool; @@ -5111,7 +5547,7 @@ NTSTATUS PhpProcessPropertiesThreadStart( } BOOLEAN PhShowProcessProperties( - __in PPH_PROCESS_PROPCONTEXT Context + _In_ PPH_PROCESS_PROPCONTEXT Context ) { HANDLE threadHandle; diff --git a/2.x/trunk/ProcessHacker/procprv.c b/2.x/trunk/ProcessHacker/procprv.c index 9c00cd5ed..cf5966451 100644 --- a/2.x/trunk/ProcessHacker/procprv.c +++ b/2.x/trunk/ProcessHacker/procprv.c @@ -2,7 +2,7 @@ * Process Hacker - * process provider * - * Copyright (C) 2009-2011 wj32 + * Copyright (C) 2009-2013 wj32 * * This file is part of Process Hacker. * @@ -60,6 +60,7 @@ #include #include #include +#include #include #define PROCESS_ID_BUCKETS 64 @@ -122,33 +123,33 @@ typedef struct _PH_VERIFY_CACHE_ENTRY } PH_VERIFY_CACHE_ENTRY, *PPH_VERIFY_CACHE_ENTRY; VOID NTAPI PhpProcessItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); INT NTAPI PhpVerifyCacheCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ); VOID PhpQueueProcessQueryStage1( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); VOID PhpQueueProcessQueryStage2( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); PPH_PROCESS_RECORD PhpCreateProcessRecord( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); VOID PhpAddProcessRecord( - __inout PPH_PROCESS_RECORD ProcessRecord + _Inout_ PPH_PROCESS_RECORD ProcessRecord ); VOID PhpRemoveProcessRecord( - __inout PPH_PROCESS_RECORD ProcessRecord + _Inout_ PPH_PROCESS_RECORD ProcessRecord ); PPH_OBJECT_TYPE PhProcessItemType; @@ -323,7 +324,7 @@ BOOLEAN PhProcessProviderInitialization( } PPH_STRING PhGetClientIdName( - __in PCLIENT_ID ClientId + _In_ PCLIENT_ID ClientId ) { PPH_STRING name; @@ -345,8 +346,8 @@ PPH_STRING PhGetClientIdName( } PPH_STRING PhGetClientIdNameEx( - __in PCLIENT_ID ClientId, - __in_opt PPH_STRING ProcessName + _In_ PCLIENT_ID ClientId, + _In_opt_ PPH_STRING ProcessName ) { PPH_STRING name; @@ -399,7 +400,7 @@ PPH_STRING PhGetClientIdNameEx( } PWSTR PhGetProcessPriorityClassString( - __in ULONG PriorityClass + _In_ ULONG PriorityClass ) { switch (PriorityClass) @@ -425,7 +426,7 @@ PWSTR PhGetProcessPriorityClassString( * Creates a process item. */ PPH_PROCESS_ITEM PhCreateProcessItem( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { PPH_PROCESS_ITEM processItem; @@ -462,8 +463,8 @@ PPH_PROCESS_ITEM PhCreateProcessItem( } VOID PhpProcessItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_PROCESS_ITEM processItem = (PPH_PROCESS_ITEM)Object; @@ -508,15 +509,15 @@ VOID PhpProcessItemDeleteProcedure( } FORCEINLINE BOOLEAN PhCompareProcessItem( - __in PPH_PROCESS_ITEM Value1, - __in PPH_PROCESS_ITEM Value2 + _In_ PPH_PROCESS_ITEM Value1, + _In_ PPH_PROCESS_ITEM Value2 ) { return Value1->ProcessId == Value2->ProcessId; } FORCEINLINE ULONG PhHashProcessItem( - __in PPH_PROCESS_ITEM Value + _In_ PPH_PROCESS_ITEM Value ) { return (ULONG)Value->ProcessId / 4; @@ -531,8 +532,8 @@ FORCEINLINE ULONG PhHashProcessItem( * function. The reference count of the found process item is * not incremented. */ -__assumeLocked PPH_PROCESS_ITEM PhpLookupProcessItem( - __in HANDLE ProcessId +PPH_PROCESS_ITEM PhpLookupProcessItem( + _In_ HANDLE ProcessId ) { PH_PROCESS_ITEM lookupProcessItem; @@ -565,7 +566,7 @@ __assumeLocked PPH_PROCESS_ITEM PhpLookupProcessItem( * \return The found process item. */ PPH_PROCESS_ITEM PhReferenceProcessItem( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { PPH_PROCESS_ITEM processItem; @@ -592,8 +593,8 @@ PPH_PROCESS_ITEM PhReferenceProcessItem( * number of process items returned in \a ProcessItems. */ VOID PhEnumProcessItems( - __out_opt PPH_PROCESS_ITEM **ProcessItems, - __out PULONG NumberOfProcessItems + _Out_opt_ PPH_PROCESS_ITEM **ProcessItems, + _Out_ PULONG NumberOfProcessItems ) { PPH_PROCESS_ITEM *processItems; @@ -630,8 +631,8 @@ VOID PhEnumProcessItems( *NumberOfProcessItems = numberOfProcessItems; } -__assumeLocked VOID PhpAddProcessItem( - __in __assumeRefs(1) PPH_PROCESS_ITEM ProcessItem +VOID PhpAddProcessItem( + _In_ _Assume_refs_(1) PPH_PROCESS_ITEM ProcessItem ) { PhAddEntryHashSet( @@ -643,8 +644,8 @@ __assumeLocked VOID PhpAddProcessItem( PhProcessHashSetCount++; } -__assumeLocked VOID PhpRemoveProcessItem( - __in PPH_PROCESS_ITEM ProcessItem +VOID PhpRemoveProcessItem( + _In_ PPH_PROCESS_ITEM ProcessItem ) { PhRemoveEntryHashSet(PhProcessHashSet, PH_HASH_SET_SIZE(PhProcessHashSet), &ProcessItem->HashEntry); @@ -653,8 +654,8 @@ __assumeLocked VOID PhpRemoveProcessItem( } INT NTAPI PhpVerifyCacheCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ) { PPH_VERIFY_CACHE_ENTRY entry1 = CONTAINING_RECORD(Links1, PH_VERIFY_CACHE_ENTRY, Links); @@ -663,11 +664,71 @@ INT NTAPI PhpVerifyCacheCompareFunction( return PhCompareString(entry1->FileName, entry2->FileName, TRUE); } +VERIFY_RESULT PhVerifyFileWithAdditionalCatalog( + _In_ PPH_VERIFY_FILE_INFO Information, + _In_opt_ PWSTR PackageFullName, + _Out_opt_ PPH_STRING *SignerName + ) +{ + static PH_STRINGREF codeIntegrityFileName = PH_STRINGREF_INIT(L"\\AppxMetadata\\CodeIntegrity.cat"); + + VERIFY_RESULT result; + PPH_STRING additionalCatalogFileName = NULL; + PCERT_CONTEXT *signatures; + ULONG numberOfSignatures; + + if (PackageFullName) + { + PACKAGE_ID *packageId; + PPH_STRING packagePath; + + if (packageId = PhPackageIdFromFullName(PackageFullName)) + { + if (packagePath = PhGetPackagePath(packageId)) + { + additionalCatalogFileName = PhConcatStringRef2(&packagePath->sr, &codeIntegrityFileName); + PhDereferenceObject(packagePath); + } + + PhFree(packageId); + } + } + + if (additionalCatalogFileName) + { + Information->NumberOfCatalogFileNames = 1; + Information->CatalogFileNames = &additionalCatalogFileName->Buffer; + } + + if (!NT_SUCCESS(PhVerifyFileEx(Information, &result, &signatures, &numberOfSignatures))) + { + result = VrNoSignature; + signatures = NULL; + numberOfSignatures = 0; + } + + if (additionalCatalogFileName) + PhDereferenceObject(additionalCatalogFileName); + + if (SignerName) + { + if (numberOfSignatures != 0) + *SignerName = PhGetSignerNameFromCertificate(signatures[0]); + else + *SignerName = NULL; + } + + PhFreeVerifySignatures(signatures, numberOfSignatures); + + return result; +} + /** * Verifies a file's digital signature, using a cached * result if possible. * * \param FileName A file name. + * \param ProcessItem An associated process item. * \param SignerName A variable which receives a pointer * to a string containing the signer name. You must free * the string using PhDereferenceObject() when you no @@ -679,9 +740,10 @@ INT NTAPI PhpVerifyCacheCompareFunction( * \return A VERIFY_RESULT value. */ VERIFY_RESULT PhVerifyFileCached( - __in PPH_STRING FileName, - __out_opt PPH_STRING *SignerName, - __in BOOLEAN CachedOnly + _In_ PPH_STRING FileName, + _In_opt_ PWSTR PackageFullName, + _Out_opt_ PPH_STRING *SignerName, + _In_ BOOLEAN CachedOnly ) { #ifdef PH_ENABLE_VERIFY_CACHE @@ -716,7 +778,15 @@ VERIFY_RESULT PhVerifyFileCached( if (!CachedOnly) { - result = PhVerifyFile(FileName->Buffer, &signerName); + PH_VERIFY_FILE_INFO info; + + memset(&info, 0, sizeof(PH_VERIFY_FILE_INFO)); + info.FileName = FileName->Buffer; + info.Flags = PH_VERIFY_PREVENT_NETWORK_ACCESS; + result = PhVerifyFileWithAdditionalCatalog(&info, PackageFullName, &signerName); + + if (result != VrTrusted) + PhSwapReference(&signerName, NULL); } else { @@ -764,15 +834,34 @@ VERIFY_RESULT PhVerifyFileCached( return result; } #else - return PhVerifyFile( - FileName->Buffer, - SignerName - ); + VERIFY_RESULT result; + PPH_STRING signerName; + PH_VERIFY_FILE_INFO info; + + memset(&info, 0, sizeof(PH_VERIFY_FILE_INFO)); + info.FileName = FileName->Buffer; + info.Flags = PH_VERIFY_PREVENT_NETWORK_ACCESS; + result = PhVerifyFileWithAdditionalCatalog(&info, PackageFullName, &signerName); + + if (result != VrTrusted) + PhSwapReference(&signerName, NULL); + + if (SignerName) + { + *SignerName = signerName; + } + else + { + if (signerName) + PhDereferenceObject(signerName); + } + + return result; #endif } VOID PhpProcessQueryStage1( - __inout PPH_PROCESS_QUERY_S1_DATA Data + _Inout_ PPH_PROCESS_QUERY_S1_DATA Data ) { NTSTATUS status; @@ -836,6 +925,7 @@ VOID PhpProcessQueryStage1( // POSIX, command line, .NET { HANDLE processHandle; + BOOLEAN queryAccess = FALSE; status = PhOpenProcess( &processHandle, @@ -843,6 +933,16 @@ VOID PhpProcessQueryStage1( processId ); + if (!NT_SUCCESS(status) && WindowsVersion >= WINDOWS_81) + { + queryAccess = TRUE; + status = PhOpenProcess( + &processHandle, + ProcessQueryAccess, + processId + ); + } + if (NT_SUCCESS(status)) { BOOLEAN isPosix = FALSE; @@ -850,8 +950,11 @@ VOID PhpProcessQueryStage1( PPH_STRING commandLine; ULONG i; - status = PhGetProcessIsPosix(processHandle, &isPosix); - Data->IsPosix = isPosix; + if (!queryAccess) + { + status = PhGetProcessIsPosix(processHandle, &isPosix); + Data->IsPosix = isPosix; + } if (!NT_SUCCESS(status) || !isPosix) { @@ -880,18 +983,21 @@ VOID PhpProcessQueryStage1( Data->CommandLine = commandLine; } - PhGetProcessIsDotNetEx( - processId, - processHandle, + if (!queryAccess) + { + PhGetProcessIsDotNetEx( + processId, + processHandle, #ifdef _M_X64 - PH_CLR_NO_WOW64_CHECK | (Data->IsWow64 ? PH_CLR_KNOWN_IS_WOW64 : 0), + PH_CLR_NO_WOW64_CHECK | (Data->IsWow64 ? PH_CLR_KNOWN_IS_WOW64 : 0), #else - 0, + 0, #endif - &isDotNet, - NULL - ); - Data->IsDotNet = isDotNet; + &isDotNet, + NULL + ); + Data->IsDotNet = isDotNet; + } NtClose(processHandle); } @@ -1001,7 +1107,7 @@ VOID PhpProcessQueryStage1( } VOID PhpProcessQueryStage2( - __inout PPH_PROCESS_QUERY_S2_DATA Data + _Inout_ PPH_PROCESS_QUERY_S2_DATA Data ) { NTSTATUS status; @@ -1010,12 +1116,21 @@ VOID PhpProcessQueryStage2( if (PhEnableProcessQueryStage2 && processItem->FileName) { + PPH_STRING packageFullName = NULL; + + if (processItem->QueryHandle) + packageFullName = PhGetProcessPackageFullName(processItem->QueryHandle); + Data->VerifyResult = PhVerifyFileCached( processItem->FileName, + PhGetString(packageFullName), &Data->VerifySignerName, FALSE ); + if (packageFullName) + PhDereferenceObject(packageFullName); + status = PhIsExecutablePacked( processItem->FileName->Buffer, &Data->IsPacked, @@ -1038,7 +1153,7 @@ VOID PhpProcessQueryStage2( } NTSTATUS PhpProcessQueryStage1Worker( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PROCESS_QUERY_S1_DATA data; @@ -1057,7 +1172,7 @@ NTSTATUS PhpProcessQueryStage1Worker( } NTSTATUS PhpProcessQueryStage2Worker( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PROCESS_QUERY_S2_DATA data; @@ -1076,7 +1191,7 @@ NTSTATUS PhpProcessQueryStage2Worker( } VOID PhpQueueProcessQueryStage1( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { // Ref: dereferenced when the provider update function removes the item from @@ -1086,7 +1201,7 @@ VOID PhpQueueProcessQueryStage1( } VOID PhpQueueProcessQueryStage2( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { if (PhEnableProcessQueryStage2) @@ -1097,7 +1212,7 @@ VOID PhpQueueProcessQueryStage2( } VOID PhpFillProcessItemStage1( - __in PPH_PROCESS_QUERY_S1_DATA Data + _In_ PPH_PROCESS_QUERY_S1_DATA Data ) { PPH_PROCESS_ITEM processItem = Data->Header.ProcessItem; @@ -1124,7 +1239,7 @@ VOID PhpFillProcessItemStage1( } VOID PhpFillProcessItemStage2( - __in PPH_PROCESS_QUERY_S2_DATA Data + _In_ PPH_PROCESS_QUERY_S2_DATA Data ) { PPH_PROCESS_ITEM processItem = Data->Header.ProcessItem; @@ -1137,8 +1252,8 @@ VOID PhpFillProcessItemStage2( } VOID PhpFillProcessItem( - __inout PPH_PROCESS_ITEM ProcessItem, - __in PSYSTEM_PROCESS_INFORMATION Process + _Inout_ PPH_PROCESS_ITEM ProcessItem, + _In_ PSYSTEM_PROCESS_INFORMATION Process ) { NTSTATUS status; @@ -1279,8 +1394,8 @@ VOID PhpFillProcessItem( } FORCEINLINE VOID PhpUpdateDynamicInfoProcessItem( - __inout PPH_PROCESS_ITEM ProcessItem, - __in PSYSTEM_PROCESS_INFORMATION Process + _Inout_ PPH_PROCESS_ITEM ProcessItem, + _In_ PSYSTEM_PROCESS_INFORMATION Process ) { ProcessItem->BasePriority = Process->BasePriority; @@ -1335,8 +1450,8 @@ VOID PhpUpdatePerfInformation( } VOID PhpUpdateCpuInformation( - __in BOOLEAN SetCpuUsage, - __out PULONG64 TotalTime + _In_ BOOLEAN SetCpuUsage, + _Out_ PULONG64 TotalTime ) { ULONG i; @@ -1413,7 +1528,7 @@ VOID PhpUpdateCpuInformation( } VOID PhpUpdateCpuCycleInformation( - __out PULONG64 IdleCycleTime + _Out_ PULONG64 IdleCycleTime ) { ULONG i; @@ -1461,8 +1576,8 @@ VOID PhpUpdateCpuCycleInformation( } VOID PhpUpdateCpuCycleUsageInformation( - __in ULONG64 TotalCycleTime, - __in ULONG64 IdleCycleTime + _In_ ULONG64 TotalCycleTime, + _In_ ULONG64 IdleCycleTime ) { ULONG i; @@ -1609,9 +1724,9 @@ VOID PhpUpdateSystemHistory( * past for that process item. */ BOOLEAN PhGetStatisticsTime( - __in_opt PPH_PROCESS_ITEM ProcessItem, - __in ULONG Index, - __out PLARGE_INTEGER Time + _In_opt_ PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG Index, + _Out_ PLARGE_INTEGER Time ) { ULONG secondsSince1980; @@ -1645,8 +1760,8 @@ BOOLEAN PhGetStatisticsTime( } PPH_STRING PhGetStatisticsTimeString( - __in_opt PPH_PROCESS_ITEM ProcessItem, - __in ULONG Index + _In_opt_ PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG Index ) { LARGE_INTEGER time; @@ -1665,16 +1780,16 @@ PPH_STRING PhGetStatisticsTimeString( } VOID PhpGetProcessThreadInformation( - __in PSYSTEM_PROCESS_INFORMATION Process, - __out_opt PBOOLEAN IsSuspended, - __out_opt PULONG ContextSwitches + _In_ PSYSTEM_PROCESS_INFORMATION Process, + _Out_opt_ PBOOLEAN IsSuspended, + _Out_opt_ PULONG ContextSwitches ) { ULONG i; BOOLEAN isSuspended; ULONG contextSwitches; - isSuspended = Process->NumberOfThreads != 0; + isSuspended = PH_IS_REAL_PROCESS_ID(Process->UniqueProcessId); contextSwitches = 0; for (i = 0; i < Process->NumberOfThreads; i++) @@ -1697,7 +1812,7 @@ VOID PhpGetProcessThreadInformation( } VOID PhProcessProviderUpdate( - __in PVOID Object + _In_ PVOID Object ) { static ULONG runCount = 0; @@ -2004,10 +2119,15 @@ VOID PhProcessProviderUpdate( processItem->Record = processRecord; // Open a handle to the process for later usage. - PhOpenProcess(&processItem->QueryHandle, PROCESS_QUERY_INFORMATION, processItem->ProcessId); + // Don't try to do this if the process has no threads. On Windows 8.1, processes without threads are + // probably reflected processes which will not terminate if we have a handle open. + if (process->NumberOfThreads != 0) + { + PhOpenProcess(&processItem->QueryHandle, PROCESS_QUERY_INFORMATION, processItem->ProcessId); - if (WINDOWS_HAS_LIMITED_ACCESS && !processItem->QueryHandle) - PhOpenProcess(&processItem->QueryHandle, PROCESS_QUERY_LIMITED_INFORMATION, processItem->ProcessId); + if (WINDOWS_HAS_LIMITED_ACCESS && !processItem->QueryHandle) + PhOpenProcess(&processItem->QueryHandle, PROCESS_QUERY_LIMITED_INFORMATION, processItem->ProcessId); + } PhpGetProcessThreadInformation(process, &isSuspended, &contextSwitches); PhpUpdateDynamicInfoProcessItem(processItem, process); @@ -2324,7 +2444,7 @@ VOID PhProcessProviderUpdate( } PPH_PROCESS_RECORD PhpCreateProcessRecord( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { PPH_PROCESS_RECORD processRecord; @@ -2365,9 +2485,9 @@ PPH_PROCESS_RECORD PhpCreateProcessRecord( } PPH_PROCESS_RECORD PhpSearchProcessRecordList( - __in PLARGE_INTEGER Time, - __out_opt PULONG Index, - __out_opt PULONG InsertIndex + _In_ PLARGE_INTEGER Time, + _Out_opt_ PULONG Index, + _Out_opt_ PULONG InsertIndex ) { PPH_PROCESS_RECORD processRecord; @@ -2430,7 +2550,7 @@ PPH_PROCESS_RECORD PhpSearchProcessRecordList( } VOID PhpAddProcessRecord( - __inout PPH_PROCESS_RECORD ProcessRecord + _Inout_ PPH_PROCESS_RECORD ProcessRecord ) { PPH_PROCESS_RECORD processRecord; @@ -2455,7 +2575,7 @@ VOID PhpAddProcessRecord( } VOID PhpRemoveProcessRecord( - __inout PPH_PROCESS_RECORD ProcessRecord + _Inout_ PPH_PROCESS_RECORD ProcessRecord ) { ULONG i; @@ -2482,21 +2602,21 @@ VOID PhpRemoveProcessRecord( } VOID PhReferenceProcessRecord( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ) { _InterlockedIncrement(&ProcessRecord->RefCount); } BOOLEAN PhReferenceProcessRecordSafe( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ) { return _InterlockedIncrementNoZero(&ProcessRecord->RefCount); } VOID PhReferenceProcessRecordForStatistics( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ) { if (!(ProcessRecord->Flags & PH_PROCESS_RECORD_STAT_REF)) @@ -2507,7 +2627,7 @@ VOID PhReferenceProcessRecordForStatistics( } VOID PhDereferenceProcessRecord( - __in PPH_PROCESS_RECORD ProcessRecord + _In_ PPH_PROCESS_RECORD ProcessRecord ) { if (_InterlockedDecrement(&ProcessRecord->RefCount) == 0) @@ -2523,8 +2643,8 @@ VOID PhDereferenceProcessRecord( } PPH_PROCESS_RECORD PhpFindProcessRecord( - __in PPH_PROCESS_RECORD ProcessRecord, - __in HANDLE ProcessId + _In_ PPH_PROCESS_RECORD ProcessRecord, + _In_ HANDLE ProcessId ) { PPH_PROCESS_RECORD startProcessRecord; @@ -2554,8 +2674,8 @@ PPH_PROCESS_RECORD PhpFindProcessRecord( * the record. */ PPH_PROCESS_RECORD PhFindProcessRecord( - __in_opt HANDLE ProcessId, - __in PLARGE_INTEGER Time + _In_opt_ HANDLE ProcessId, + _In_ PLARGE_INTEGER Time ) { PPH_PROCESS_RECORD processRecord; @@ -2705,9 +2825,9 @@ VOID PhPurgeProcessRecords( } PPH_PROCESS_ITEM PhReferenceProcessItemForParent( - __in HANDLE ParentProcessId, - __in HANDLE ProcessId, - __in PLARGE_INTEGER CreateTime + _In_ HANDLE ParentProcessId, + _In_ HANDLE ProcessId, + _In_ PLARGE_INTEGER CreateTime ) { PPH_PROCESS_ITEM processItem; @@ -2733,7 +2853,7 @@ PPH_PROCESS_ITEM PhReferenceProcessItemForParent( } PPH_PROCESS_ITEM PhReferenceProcessItemForRecord( - __in PPH_PROCESS_RECORD Record + _In_ PPH_PROCESS_RECORD Record ) { PPH_PROCESS_ITEM processItem; diff --git a/2.x/trunk/ProcessHacker/procrec.c b/2.x/trunk/ProcessHacker/procrec.c index 4d094e8de..fdea249c5 100644 --- a/2.x/trunk/ProcessHacker/procrec.c +++ b/2.x/trunk/ProcessHacker/procrec.c @@ -29,15 +29,15 @@ typedef struct _PROCESS_RECORD_CONTEXT } PROCESS_RECORD_CONTEXT, *PPROCESS_RECORD_CONTEXT; INT_PTR CALLBACK PhpProcessRecordDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowProcessRecordDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_RECORD Record + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_RECORD Record ) { PROCESS_RECORD_CONTEXT context; @@ -54,7 +54,7 @@ VOID PhShowProcessRecordDialog( } PPH_STRING PhapGetRelativeTimeString( - __in PLARGE_INTEGER Time + _In_ PLARGE_INTEGER Time ) { LARGE_INTEGER time; @@ -74,7 +74,7 @@ PPH_STRING PhapGetRelativeTimeString( } FORCEINLINE PWSTR PhpGetStringOrNa( - __in PPH_STRING String + _In_ PPH_STRING String ) { if (String) @@ -84,10 +84,10 @@ FORCEINLINE PWSTR PhpGetStringOrNa( } INT_PTR CALLBACK PhpProcessRecordDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPROCESS_RECORD_CONTEXT context = NULL; diff --git a/2.x/trunk/ProcessHacker/proctree.c b/2.x/trunk/ProcessHacker/proctree.c index 28e0a8250..3534c92ce 100644 --- a/2.x/trunk/ProcessHacker/proctree.c +++ b/2.x/trunk/ProcessHacker/proctree.c @@ -2,7 +2,7 @@ * Process Hacker - * process tree list * - * Copyright (C) 2010-2012 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -36,12 +36,12 @@ #include VOID PhpEnableColumnCustomDraw( - __in HWND hwnd, - __in ULONG Id + _In_ HWND hwnd, + _In_ ULONG Id ); VOID PhpRemoveProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ); VOID PhpUpdateNeedCyclesInformation( @@ -49,22 +49,22 @@ VOID PhpUpdateNeedCyclesInformation( ); VOID PhpUpdateProcessNodeCycles( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ); LONG PhpProcessTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ); BOOLEAN NTAPI PhpProcessTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); static HWND ProcessTreeListHandle; @@ -98,7 +98,7 @@ VOID PhProcessTreeListInitialization( } VOID PhInitializeProcessTreeList( - __in HWND hwnd + _In_ HWND hwnd ) { ProcessTreeListHandle = hwnd; @@ -195,6 +195,7 @@ VOID PhInitializeProcessTreeList( PhAddTreeNewColumn(hwnd, PHPRTLC_SUBSYSTEM, FALSE, L"Subsystem", 110, PH_ALIGN_LEFT, -1, 0); PhAddTreeNewColumn(hwnd, PHPRTLC_PACKAGENAME, FALSE, L"Package Name", 160, PH_ALIGN_LEFT, -1, 0); PhAddTreeNewColumn(hwnd, PHPRTLC_APPID, FALSE, L"App ID", 160, PH_ALIGN_LEFT, -1, 0); + PhAddTreeNewColumn(hwnd, PHPRTLC_DPIAWARENESS, FALSE, L"DPI Awareness", 110, PH_ALIGN_LEFT, -1, 0); TreeNew_SetRedraw(hwnd, TRUE); @@ -220,8 +221,8 @@ VOID PhInitializeProcessTreeList( } static VOID PhpEnableColumnCustomDraw( - __in HWND hwnd, - __in ULONG Id + _In_ HWND hwnd, + _In_ ULONG Id ) { PH_TREENEW_COLUMN column; @@ -282,23 +283,23 @@ struct _PH_TN_FILTER_SUPPORT *PhGetFilterSupportProcessTreeList( } FORCEINLINE BOOLEAN PhCompareProcessNode( - __in PPH_PROCESS_NODE Value1, - __in PPH_PROCESS_NODE Value2 + _In_ PPH_PROCESS_NODE Value1, + _In_ PPH_PROCESS_NODE Value2 ) { return Value1->ProcessId == Value2->ProcessId; } FORCEINLINE ULONG PhHashProcessNode( - __in PPH_PROCESS_NODE Value + _In_ PPH_PROCESS_NODE Value ) { return (ULONG)Value->ProcessId / 4; } PPH_PROCESS_NODE PhAddProcessNode( - __in PPH_PROCESS_ITEM ProcessItem, - __in ULONG RunId + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG RunId ) { PPH_PROCESS_NODE processNode; @@ -425,7 +426,7 @@ PPH_PROCESS_NODE PhAddProcessNode( } PPH_PROCESS_NODE PhFindProcessNode( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { PH_PROCESS_NODE lookupNode; @@ -451,7 +452,7 @@ PPH_PROCESS_NODE PhFindProcessNode( } VOID PhRemoveProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ) { // Remove from the hashtable here to avoid problems in case the key is re-used. @@ -475,7 +476,7 @@ VOID PhRemoveProcessNode( } VOID PhpRemoveProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ) { ULONG index; @@ -564,7 +565,7 @@ VOID PhpRemoveProcessNode( } VOID PhUpdateProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ) { memset(ProcessNode->TextCache, 0, sizeof(PH_STRINGREF) * PHPRTLC_MAXIMUM); @@ -596,7 +597,7 @@ VOID PhTickProcessNodes( // The name and PID never change, so we don't invalidate that. memset(&node->TextCache[2], 0, sizeof(PH_STRINGREF) * (PHPRTLC_MAXIMUM - 2)); - node->ValidMask &= PHPN_OSCONTEXT | PHPN_IMAGE; // OS Context always remains valid + node->ValidMask &= PHPN_OSCONTEXT | PHPN_IMAGE | PHPN_DPIAWARENESS; // Items that always remain valid // Invalidate graph buffers. node->CpuGraphBuffers.Valid = FALSE; @@ -635,9 +636,9 @@ VOID PhTickProcessNodes( } static VOID PhpNeedGraphContext( - __in HDC hdc, - __in ULONG Width, - __in ULONG Height + _In_ HDC hdc, + _In_ ULONG Width, + _In_ ULONG Height ) { BITMAPINFOHEADER header; @@ -672,10 +673,10 @@ static VOID PhpNeedGraphContext( } static BOOLEAN PhpFormatInt32GroupDigits( - __in ULONG Value, - __out_bcount(BufferLength) PWCHAR Buffer, - __in ULONG BufferLength, - __out_opt PPH_STRINGREF String + _In_ ULONG Value, + _Out_writes_bytes_(BufferLength) PWCHAR Buffer, + _In_ ULONG BufferLength, + _Out_opt_ PPH_STRINGREF String ) { PH_FORMAT format; @@ -701,7 +702,7 @@ static BOOLEAN PhpFormatInt32GroupDigits( } static FLOAT PhpCalculateInclusiveCpuUsage( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ) { FLOAT cpuUsage; @@ -718,7 +719,7 @@ static FLOAT PhpCalculateInclusiveCpuUsage( } static VOID PhpUpdateProcessNodeWsCounters( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_WSCOUNTERS)) @@ -749,7 +750,7 @@ static VOID PhpUpdateProcessNodeWsCounters( } static VOID PhpUpdateProcessNodeGdiUserHandles( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_GDIUSERHANDLES)) @@ -770,7 +771,7 @@ static VOID PhpUpdateProcessNodeGdiUserHandles( } static VOID PhpUpdateProcessNodeIoPagePriority( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_IOPAGEPRIORITY)) @@ -793,8 +794,8 @@ static VOID PhpUpdateProcessNodeIoPagePriority( } static BOOL CALLBACK PhpEnumProcessNodeWindowsProc( - __in HWND hwnd, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ LPARAM lParam ) { PPH_PROCESS_NODE processNode = (PPH_PROCESS_NODE)lParam; @@ -822,7 +823,7 @@ static BOOL CALLBACK PhpEnumProcessNodeWindowsProc( } static VOID PhpUpdateProcessNodeWindow( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_WINDOW)) @@ -843,7 +844,7 @@ static VOID PhpUpdateProcessNodeWindow( } static VOID PhpUpdateProcessNodeDepStatus( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_DEPSTATUS)) @@ -882,7 +883,7 @@ static VOID PhpUpdateProcessNodeDepStatus( } static VOID PhpUpdateProcessNodeToken( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_TOKEN)) @@ -918,7 +919,7 @@ static VOID PhpUpdateProcessNodeToken( } static VOID PhpUpdateProcessOsContext( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_OSCONTEXT)) @@ -931,7 +932,9 @@ static VOID PhpUpdateProcessOsContext( { if (NT_SUCCESS(PhGetProcessSwitchContext(processHandle, &ProcessNode->OsContextGuid))) { - if (memcmp(&ProcessNode->OsContextGuid, &WIN8_CONTEXT_GUID, sizeof(GUID)) == 0) + if (memcmp(&ProcessNode->OsContextGuid, &WINBLUE_CONTEXT_GUID, sizeof(GUID)) == 0) + ProcessNode->OsContextVersion = WINDOWS_81; + else if (memcmp(&ProcessNode->OsContextGuid, &WIN8_CONTEXT_GUID, sizeof(GUID)) == 0) ProcessNode->OsContextVersion = WINDOWS_8; else if (memcmp(&ProcessNode->OsContextGuid, &WIN7_CONTEXT_GUID, sizeof(GUID)) == 0) ProcessNode->OsContextVersion = WINDOWS_7; @@ -950,7 +953,7 @@ static VOID PhpUpdateProcessOsContext( } static VOID PhpUpdateProcessNodeQuotaLimits( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_QUOTALIMITS)) @@ -979,7 +982,7 @@ static VOID PhpUpdateProcessNodeQuotaLimits( } static VOID PhpUpdateProcessNodeImage( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_IMAGE)) @@ -1029,7 +1032,7 @@ static VOID PhpUpdateProcessNodeImage( } static VOID PhpUpdateProcessNodeAppId( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (!(ProcessNode->ValidMask & PHPN_APPID)) @@ -1072,6 +1075,39 @@ static VOID PhpUpdateProcessNodeAppId( } } +static VOID PhpUpdateProcessNodeDpiAwareness( + _Inout_ PPH_PROCESS_NODE ProcessNode + ) +{ + static PH_INITONCE initOnce = PH_INITONCE_INIT; + static BOOL (WINAPI *getProcessDpiAwarenessInternal)( + _In_ HANDLE hprocess, + _Out_ ULONG *value + ); + + if (PhBeginInitOnce(&initOnce)) + { + getProcessDpiAwarenessInternal = PhGetProcAddress(L"user32.dll", "GetProcessDpiAwarenessInternal"); + PhEndInitOnce(&initOnce); + } + + if (!getProcessDpiAwarenessInternal) + return; + + if (!(ProcessNode->ValidMask & PHPN_DPIAWARENESS)) + { + if (ProcessNode->ProcessItem->QueryHandle) + { + ULONG dpiAwareness; + + if (getProcessDpiAwarenessInternal(ProcessNode->ProcessItem->QueryHandle, &dpiAwareness)) + ProcessNode->DpiAwareness = dpiAwareness + 1; + } + + ProcessNode->ValidMask |= PHPN_DPIAWARENESS; + } +} + static VOID PhpUpdateNeedCyclesInformation( VOID ) @@ -1104,7 +1140,7 @@ static VOID PhpUpdateNeedCyclesInformation( } static VOID PhpUpdateProcessNodeCycles( - __inout PPH_PROCESS_NODE ProcessNode + _Inout_ PPH_PROCESS_NODE ProcessNode ) { if (ProcessNode->ProcessId == SYSTEM_IDLE_PROCESS_ID) @@ -1160,8 +1196,8 @@ static VOID PhpUpdateProcessNodeCycles( #define SORT_FUNCTION(Column) PhpProcessTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpProcessTreeNewCompare##Column( \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PPH_PROCESS_NODE node1 = *(PPH_PROCESS_NODE *)_elem1; \ @@ -1178,10 +1214,10 @@ static VOID PhpUpdateProcessNodeCycles( } LONG PhpProcessTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ) { if (Result == 0) @@ -1738,12 +1774,20 @@ BEGIN_SORT_FUNCTION(AppId) } END_SORT_FUNCTION +BEGIN_SORT_FUNCTION(DpiAwareness) +{ + PhpUpdateProcessNodeDpiAwareness(node1); + PhpUpdateProcessNodeDpiAwareness(node2); + sortResult = uintcmp(node1->DpiAwareness, node2->DpiAwareness); +} +END_SORT_FUNCTION + BOOLEAN NTAPI PhpProcessTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PPH_PROCESS_NODE node; @@ -1851,7 +1895,8 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback( SORT_FUNCTION(PrivateBytesDelta), SORT_FUNCTION(Subsystem), SORT_FUNCTION(PackageName), - SORT_FUNCTION(AppId) + SORT_FUNCTION(AppId), + SORT_FUNCTION(DpiAwareness) }; static PH_INITONCE initOnce = PH_INITONCE_INIT; int (__cdecl *sortFunction)(const void *, const void *); @@ -2407,6 +2452,9 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback( { switch (node->OsContextVersion) { + case WINDOWS_81: + PhInitializeStringRef(&getCellText->Text, L"Windows 8.1"); + break; case WINDOWS_8: PhInitializeStringRef(&getCellText->Text, L"Windows 8"); break; @@ -2515,6 +2563,24 @@ BOOLEAN NTAPI PhpProcessTreeNewCallback( PhpUpdateProcessNodeAppId(node); getCellText->Text = PhGetStringRef(node->AppIdText); break; + case PHPRTLC_DPIAWARENESS: + PhpUpdateProcessNodeDpiAwareness(node); + + switch (node->DpiAwareness) + { + case 0: + break; + case 1: + PhInitializeStringRef(&getCellText->Text, L"Unaware"); + break; + case 2: + PhInitializeStringRef(&getCellText->Text, L"System Aware"); + break; + case 3: + PhInitializeStringRef(&getCellText->Text, L"Per-Monitor Aware"); + break; + } + break; default: return FALSE; } @@ -2951,8 +3017,8 @@ PPH_PROCESS_ITEM PhGetSelectedProcessItem( } VOID PhGetSelectedProcessItems( - __out PPH_PROCESS_ITEM **Processes, - __out PULONG NumberOfProcesses + _Out_ PPH_PROCESS_ITEM **Processes, + _Out_ PULONG NumberOfProcesses ) { PPH_LIST list; @@ -2984,7 +3050,7 @@ VOID PhDeselectAllProcessNodes( } VOID PhExpandAllProcessNodes( - __in BOOLEAN Expand + _In_ BOOLEAN Expand ) { ULONG i; @@ -3029,7 +3095,7 @@ VOID PhInvalidateAllProcessNodes( } VOID PhSelectAndEnsureVisibleProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ) { PPH_PROCESS_NODE processNode; @@ -3065,13 +3131,13 @@ VOID PhSelectAndEnsureVisibleProcessNode( } VOID PhpPopulateTableWithProcessNodes( - __in HWND TreeListHandle, - __in PPH_PROCESS_NODE Node, - __in ULONG Level, - __in PPH_STRING **Table, - __inout PULONG Index, - __in PULONG DisplayToId, - __in ULONG Columns + _In_ HWND TreeListHandle, + _In_ PPH_PROCESS_NODE Node, + _In_ ULONG Level, + _In_ PPH_STRING **Table, + _Inout_ PULONG Index, + _In_ PULONG DisplayToId, + _In_ ULONG Columns ) { ULONG i; @@ -3122,10 +3188,10 @@ VOID PhpPopulateTableWithProcessNodes( } PPH_LIST PhGetProcessTreeListLines( - __in HWND TreeListHandle, - __in ULONG NumberOfNodes, - __in PPH_LIST RootNodes, - __in ULONG Mode + _In_ HWND TreeListHandle, + _In_ ULONG NumberOfNodes, + _In_ PPH_LIST RootNodes, + _In_ ULONG Mode ) { PH_AUTO_POOL autoPool; @@ -3198,8 +3264,8 @@ VOID PhCopyProcessTree( } VOID PhWriteProcessTree( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ) { PPH_LIST lines; diff --git a/2.x/trunk/ProcessHacker/resource.h b/2.x/trunk/ProcessHacker/resource.h index f3f902af3..5f83e7828 100644 --- a/2.x/trunk/ProcessHacker/resource.h +++ b/2.x/trunk/ProcessHacker/resource.h @@ -14,7 +14,6 @@ #define IDD_THRDSTACK 108 #define IDR_THREAD 110 #define IDR_HANDLE 111 -#define IDC_LAYOUTDUMMY 111 #define IDR_MODULE 112 #define IDC_CPU 112 #define IDC_PRIVATEBYTES 113 @@ -23,7 +22,6 @@ #define IDB_CROSS 117 #define IDB_TICK 118 #define IDC_PHYSICAL 119 -#define IDR_SHUTDOWN 120 #define IDR_COMPUTER 120 #define IDC_MEMORY 120 #define IDD_ABOUT 121 @@ -77,7 +75,6 @@ #define IDB_MAGNIFIER 159 #define IDD_OPTGENERAL 162 #define IDD_OPTHIGHLIGHTING 163 -#define IDR_MENU1 164 #define IDR_NETWORK 164 #define IDD_CHOOSECOLUMNS 166 #define IDD_NETSTACK 167 @@ -119,11 +116,8 @@ #define IDD_SYSINFO_IO 200 #define IDD_SYSINFO_IOPANEL 201 #define IDD_MEMLISTS 202 -#define IDR_EMPTYMEMORYLISTS 203 #define IDR_EMPTYMEMLISTS 204 -#define IDD_DIALOG1 205 #define IDD_CONTAINER 205 -#define IDD_SYSINFO_MEMPANEL1 206 #define IDD_SYSINFO_MEMPANELXP 206 #define IDC_TERMINATE 1003 #define IDC_FILEICON 1005 @@ -131,11 +125,9 @@ #define IDC_PROCESS 1007 #define IDC_COMPANYNAME 1009 #define IDC_VERSION 1010 -#define IDC_THRDSTACK_LIST 1013 #define IDC_REFRESH 1015 #define IDC_PERMISSIONS 1018 #define IDC_FILENAME 1020 -#define IDC_RUN_ALL 1021 #define IDC_CMDLINE 1021 #define IDC_URL 1021 #define IDC_RUNSELECTED 1021 @@ -188,7 +180,6 @@ #define IDC_OWNER 1054 #define IDC_GROUPS 1055 #define IDC_PRIMARYGROUP 1055 -#define IDC_GROUPS2 1056 #define IDC_PRIVILEGES 1056 #define IDC_VIRTUALIZATION 1056 #define IDC_SESSIONID 1057 @@ -212,7 +203,6 @@ #define IDC_DESKTOPS 1075 #define IDC_PROGRESS 1076 #define IDC_PROGRESSTEXT 1077 -#define IDC_BUTTON1 1079 #define IDC_LINKEDTOKEN 1079 #define IDC_EDITPROTECTION 1079 #define IDC_DISABLEALL 1079 @@ -247,14 +237,12 @@ #define IDC_SIZE_ 1098 #define IDC_CPU0 1099 #define IDC_CPU1 1100 -#define IDC_ZSYSTEM 1100 #define IDC_CPU2 1101 #define IDC_CPU3 1102 #define IDC_CPU4 1103 #define IDC_CPU5 1104 #define IDC_CPU6 1105 #define IDC_CPU7 1106 -#define IDC_ZPROCESSES_L 1106 #define IDC_CPU8 1107 #define IDC_TITLE 1107 #define IDC_CPU9 1108 @@ -321,7 +309,6 @@ #define IDC_STARTHIDDEN 1148 #define IDC_ENABLEKERNELMODEDRIVER 1149 #define IDC_PEVIEWER 1151 -#define IDC_HIGHLIGHTINGDURATIONSPIN 1154 #define IDC_HIGHLIGHTINGDURATION 1155 #define IDC_ENABLEALL 1157 #define IDC_ZACTIVEPROCESSES_V 1158 @@ -340,7 +327,6 @@ #define IDC_ZIOWRITEBYTES_V 1171 #define IDC_ZIOOTHER_V 1172 #define IDC_ZIOOTHERBYTES_V 1173 -#define IDC_LIST2 1175 #define IDC_MOVEDOWN 1176 #define IDC_DISPLAYNAME 1179 #define IDC_ZPRIORITY_V 1181 @@ -351,7 +337,6 @@ #define IDC_ZPEAKWORKINGSET_V 1188 #define IDC_ZVIRTUALSIZE_V 1189 #define IDC_ZPEAKVIRTUALSIZE_V 1190 -#define IDC_ZPEAKPAGEFILEUSAGE_V 1191 #define IDC_ZPEAKPRIVATEBYTES_V 1191 #define IDC_ZPAGEPRIORITY_V 1192 #define IDC_ZIOPRIORITY_V 1194 @@ -365,7 +350,6 @@ #define IDC_GROUPIO 1200 #define IDC_ONEGRAPHPERCPU 1202 #define IDC_ALWAYSONTOP 1203 -#define IDC_GROUPPHYSICAL 1204 #define IDC_COPY 1206 #define IDC_INACTIVE 1207 #define IDC_ACTIVE 1208 @@ -379,10 +363,8 @@ #define IDC_COLLAPSESERVICES 1219 #define IDC_ICONSINGLECLICK 1220 #define IDC_DESKTOP 1221 -#define IDC_ENABLEPROCDB 1222 #define IDC_REREAD 1224 #define IDC_WRITE 1225 -#define IDC_MEMORY_LAYOUT 1227 #define IDC_VALUE 1230 #define IDC_DELAYEDSTART 1234 #define IDC_MINIMUMLENGTH 1236 @@ -391,17 +373,8 @@ #define IDC_IMAGE 1239 #define IDC_MAPPED 1240 #define IDC_STRINGS 1242 -#define IDC_NEWOBJECTS_LAYOUT 1243 -#define IDC_REMOVEDOBJECTS_LAYOUT 1244 #define IDC_SHOWTEXT 1245 -#define IDC_CPUKERNEL_LAYOUT 1246 -#define IDC_CPUUSER_LAYOUT 1247 -#define IDC_IORO_LAYOUT 1248 #define IDC_ICONPROCESSES 1248 -#define IDC_IOW_LAYOUT 1249 -#define IDC_PRIVATE_LAYOUT 1250 -#define IDC_PHYSICAL_LAYOUT 1251 -#define IDC_BUTTON2 1251 #define IDC_ENABLE 1251 #define IDC_CLEANUP 1251 #define IDC_ENABLESTAGE2 1253 @@ -415,21 +388,17 @@ #define IDC_ENABLENETWORKRESOLVE 1271 #define IDC_LOGONTIME 1272 #define IDC_ZPEAKHANDLES_V 1273 -#define IDC_CHECK1 1274 #define IDC_PROPAGATECPUUSAGE 1274 #define IDC_SHIFT 1274 #define IDC_USEOLDCOLORS 1274 #define IDC_ICONTOGGLESVISIBILITY 1274 -#define IDC_CUSTOM1 1276 -#define IDC_SYSLINK1 1279 #define IDC_OPENURL 1279 +#define IDC_COMPANYNAME_LINK 1279 #define IDC_SAMPLECOUNT 1280 -#define IDC_SAMPLECOUNT_L 1281 #define IDC_SAMPLECOUNTLABEL 1281 #define IDC_DISABLE 1282 #define IDC_VIRTUALKEY 1283 #define IDC_CTRL 1284 -#define IDC_CHECK3 1285 #define IDC_ALT 1285 #define IDC_CONNECTTIME 1286 #define IDC_DISCONNECTTIME 1287 @@ -447,21 +416,11 @@ #define IDC_LAYOUT 1300 #define IDC_UTILIZATION 1301 #define IDC_SPEED 1302 -#define IDC_PROCESSES_V 1303 #define IDC_ZPROCESSES_V 1303 -#define IDC_THREADS_V 1304 #define IDC_ZTHREADS_V 1304 -#define IDC_UTILIZATION2 1305 -#define IDC_HANDLES_V 1305 -#define IDC_UPTIME_V 1306 -#define IDC_CONTEXTSWITCHESDELTA_V 1307 #define IDC_ZCONTEXTSWITCHESDELTA_V 1307 -#define IDC_INTERRUPTSDELTA_V 1308 #define IDC_ZINTERRUPTSDELTA_V 1308 -#define IDC_DPCSDELTA_V 1309 #define IDC_ZDPCSDELTA_V 1309 -#define IDC_SYSTEMCALLDELTA_V 1310 -#define IDC_SYSTEMCALLSDELTA_V 1310 #define IDC_ZSYSTEMCALLSDELTA_V 1310 #define IDC_GRAPH_LAYOUT 1311 #define IDC_TOTALPHYSICAL 1312 @@ -505,7 +464,6 @@ #define IDC_ZLISTBAD_V 1350 #define IDC_ZWRITEBYTES_V 1350 #define IDC_ZLISTREPURPOSED_V 1351 -#define IDC_ZOTHERBYTESDELTA_V2 1351 #define IDC_ZOTHERBYTES_V 1351 #define IDC_ZLISTREPURPOSED0_V 1352 #define IDC_ZLISTREPURPOSED1_V 1353 @@ -516,7 +474,6 @@ #define IDC_ZLISTREPURPOSED6_V 1358 #define IDC_ZLISTREPURPOSED7_V 1359 #define IDC_EMPTY 1360 -#define IDC_CHECK2 1361 #define IDC_SAMPLECOUNTAUTOMATIC 1361 #define IDC_SHOWCOMMITINSUMMARY 1361 #define IDC_ASLRLABEL 1363 @@ -534,9 +491,6 @@ #define ID_MAINWND_NETWORKTL 2003 #define ID_MAINWND_PROCESSLV 2004 #define ID_HACKER_EXIT 40001 -#define ID_USERS 40002 -#define ID_TOOLS 40003 -#define ID_VIEW 40004 #define ID_PROCESS_PROPERTIES 40006 #define ID_PROCESS_TERMINATE 40007 #define ID_PROCESS_SUSPEND 40008 @@ -548,9 +502,7 @@ #define ID_THREAD_FORCETERMINATE 40014 #define ID_THREAD_PERMISSIONS 40015 #define ID_THREAD_TOKEN 40016 -#define ID_THREAD_ANALYZE 40017 #define ID_ANALYZE_WAIT 40018 -#define ID_THREAD_PRIORITY 40019 #define ID_PRIORITY_TIMECRITICAL 40020 #define ID_PRIORITY_HIGHEST 40021 #define ID_PRIORITY_ABOVENORMAL 40022 @@ -558,26 +510,19 @@ #define ID_PRIORITY_BELOWNORMAL 40024 #define ID_PRIORITY_LOWEST 40025 #define ID_PRIORITY_IDLE 40026 -#define ID_THREAD_I 40027 #define ID_I_0 40028 #define ID_I_1 40029 #define ID_I_2 40030 #define ID_I_3 40031 #define ID_PROCESS_RESTART 40032 -#define ID_PROCESS_REDUCEWORKINGSET 40033 #define ID_PROCESS_VIRTUALIZATION 40034 #define ID_PROCESS_AFFINITY 40035 #define ID_PROCESS_CREATEDUMPFILE 40036 -#define ID_PROCESS_TERMINATOR 40037 -#define ID_PROCESS_MISCELLANEOUS 40038 #define ID_MISCELLANEOUS_DETACHFROMDEBUGGER 40039 #define ID_MISCELLANEOUS_HEAPS 40040 #define ID_MISCELLANEOUS_INJECTDLL 40041 -#define ID_MISCELLANEOUS_I 40042 -#define ID_PROCESS_PRIORITY 40047 #define ID_PRIORITY_REALTIME 40048 #define ID_PRIORITY_HIGH 40049 -#define ID_PROCESS_WINDOW 40054 #define ID_WINDOW_BRINGTOFRONT 40055 #define ID_WINDOW_RESTORE 40056 #define ID_WINDOW_MINIMIZE 40057 @@ -589,7 +534,6 @@ #define ID_HANDLE_INHERIT 40063 #define ID_HANDLE_PROPERTIES 40064 #define ID_MODULE_UNLOAD 40066 -#define ID_MODULE_OPENCONTAININGFOLDER 40067 #define ID_MODULE_PROPERTIES 40068 #define ID_PROCESS_TERMINATETREE 40069 #define ID_THREAD_INSPECT 40075 @@ -597,26 +541,14 @@ #define ID_HACKER_RUNASADMINISTRATOR 40077 #define ID_HACKER_RUNAS 40078 #define ID_HACKER_SHOWDETAILSFORALLPROCESSES 40079 -#define ID_HACKER_0 40080 #define ID_HACKER_FINDHANDLESORDLLS 40082 #define ID_HACKER_OPTIONS 40083 -#define ID_SHUTDOWN_LOCK 40084 -#define ID_SHUTDOWN_LOGOFF 40085 -#define ID_SHUTDOWN_SLEEP 40086 -#define ID_SHUTDOWN_HIBERNATE 40087 -#define ID_SHUTDOWN_RESTART 40088 -#define ID_SHUTDOWN_SHUTDOWN 40089 -#define ID_SHUTDOWN_POWEROFF 40090 #define ID_VIEW_SYSTEMINFORMATION 40091 -#define ID_VIEW_TRAYICONS 40092 #define ID_TRAYICONS_CPUHISTORY 40093 #define ID_TRAYICONS_CPUUSAGE 40094 -#define ID_TRAYICONS_I 40095 #define ID_TRAYICONS_COMMITHISTORY 40096 #define ID_TRAYICONS_PHYSICALMEMORYHISTORY 40097 #define ID_VIEW_REFRESH 40098 -#define ID_VIEW_UPDATEPROCESSES 40099 -#define ID_VIEW_UPDATESERVICES 40100 #define ID_TOOLS_CREATESERVICE 40101 #define ID_TOOLS_HIDDENPROCESSES 40102 #define ID_TOOLS_VERIFYFILESIGNATURE 40103 @@ -635,7 +567,6 @@ #define ID_PRIVILEGE_REMOVE 40118 #define ID_OBJECT_CLOSE 40119 #define ID_OBJECT_PROPERTIES 40120 -#define ID_OBJECT_PROCESSPROPERTIES 40121 #define ID_HELP_DEBUGCONSOLE 40122 #define ID_MODULE_SEARCHONLINE 40125 #define ID_TOOLS_PAGEFILES 40126 @@ -646,13 +577,9 @@ #define ID_USERS_DUMMY 40131 #define ID_MODULE_INSPECT 40132 #define ID_PROCESS_DEBUG 40133 -#define ID_COMPUTER_FORCEON 40135 -#define ID_FORCEON_SYSTEM 40136 -#define ID_FORCEON_DISPLAY 40137 #define ID_USER_CONNECT 40138 #define ID_NETWORK_GOTOPROCESS 40139 #define ID_NETWORK_CLOSE 40140 -#define ID_VIEW_OPACITY 40141 #define ID_OPACITY_10 40142 #define ID_OPACITY_20 40143 #define ID_OPACITY_30 40144 @@ -664,7 +591,6 @@ #define ID_OPACITY_90 40150 #define ID_OPACITY_OPAQUE 40151 #define ID_VIEW_ALWAYSONTOP 40153 -#define ID_VIEW_UPDATEINTERVAL 40154 #define ID_UPDATEINTERVAL_FAST 40155 #define ID_UPDATEINTERVAL_NORMAL 40156 #define ID_UPDATEINTERVAL_BELOWNORMAL 40157 @@ -676,17 +602,11 @@ #define ID_COMPUTER_HIBERNATE 40163 #define ID_COMPUTER_RESTART 40164 #define ID_COMPUTER_SHUTDOWN 40165 -#define ID_COMPUTER_POWEROFF 40166 #define ID_NETWORK_VIEWSTACK 40167 #define ID_TRAYICONS_IOHISTORY 40168 #define ID_ICON_EXIT 40169 -#define ID_ICON_SHOW 40170 #define ID_ICON_SHOWHIDEPROCESSHACKER 40171 #define ID_ICON_SYSTEMINFORMATION 40172 -#define ID_ICON_NOTIFICATIONS 40173 -#define ID_ICON_PROCESSES 40174 -#define ID_ICON_SHUTDOWN 40175 -#define ID_ICON_COMPUTER 40176 #define ID_PROCESSES_DUMMY 40177 #define ID_NOTIFICATIONS_ENABLEALL 40178 #define ID_NOTIFICATIONS_DISABLEALL 40179 @@ -706,26 +626,17 @@ #define ID_MODULE_COPY 40199 #define ID_HANDLE_COPY 40200 #define ID_OBJECT_COPY 40201 -#define ID_PRIORITY_PERMANENT 40203 -#define ID_PRIORITY_RESTORE 40204 -#define ID_PRIORITY_SAVE 40205 -#define ID_MEMORY_R 40206 -#define ID_MEMORY_READ 40207 #define ID_MEMORY_SAVE 40208 #define ID_MEMORY_CHANGEPROTECTION 40209 #define ID_MEMORY_FREE 40210 #define ID_MEMORY_DECOMMIT 40211 -#define ID_MEMORY_READ40212 40212 #define ID_MEMORY_COPY 40213 #define ID_MEMORY_READWRITEMEMORY 40214 #define ID_MEMORY_READWRITEADDRESS 40215 #define ID_FILTER_CONTAINS 40216 -#define ID_FILTER_CONTAINS40217 40217 #define ID_FILTER_CONTAINS_CASEINSENSITIVE 40218 #define ID_FILTER_REGEX 40219 -#define ID_FILTER_REGEX40220 40220 #define ID_FILTER_REGEX_CASEINSENSITIVE 40221 -#define ID_VIEW_PAUSE 40222 #define ID_TAB_NEXT 40223 #define ID_TAB_PREV 40224 #define ID_MISCELLANEOUS_RUNAS 40229 @@ -737,14 +648,11 @@ #define ID_VIEW_UPDATEAUTOMATICALLY 40235 #define ID_HACKER_RUNASLIMITEDUSER 40236 #define ID_USER_REMOTECONTROL 40237 -#define ID_MISCELLANEOUS_PAGEPRIORITY 40238 #define ID_PAGEPRIORITY_5 40239 #define ID_PAGEPRIORITY_4 40240 #define ID_PAGEPRIORITY_3 40241 #define ID_PAGEPRIORITY_2 40242 #define ID_PAGEPRIORITY_1 40243 -#define ID_VIEW_SHOWCPUBELOW0 40244 -#define ID_VIEW_SHOWCPUBELOW 40245 #define ID_VIEW_SHOWCPUBELOW001 40246 #define ID_MODULE_OPENFILELOCATION 40247 #define ID_PROCESS_OPENFILELOCATION 40248 @@ -766,22 +674,22 @@ #define ID_VIEW_HIDEDRIVERSERVICES 40273 #define ID_VIEW_SECTIONPLACEHOLDER 40274 #define ID_VIEW_SCROLLTONEWPROCESSES 40275 -#define ID_TOOLS_STARTORIGINALTASKMANAGER 40276 #define ID_TOOLS_STARTTASKMANAGER 40277 #define ID_COMPUTER_SHUTDOWNHYBRID 40278 -#define ID_COMPUTER_SHUTDOWN40279 40279 #define ID_COMPUTER_RESTARTBOOTOPTIONS 40280 #define ID_MISCELLANEOUS_TERMINATOR 40281 +#define ID_HANDLE_OBJECTPROPERTIES1 40282 +#define ID_HANDLE_OBJECTPROPERTIES2 40283 +#define ID_OBJECT_GOTOOWNINGPROCESS 40284 #define IDDYNAMIC 50000 #define IDPLUGINS 55000 -#define IDPLUGINS_END 56000 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 206 -#define _APS_NEXT_COMMAND_VALUE 40282 +#define _APS_NEXT_COMMAND_VALUE 40285 #define _APS_NEXT_CONTROL_VALUE 1364 #define _APS_NEXT_SYMED_VALUE 137 #endif diff --git a/2.x/trunk/ProcessHacker/runas.c b/2.x/trunk/ProcessHacker/runas.c index f2a5b4c40..88cab8374 100644 --- a/2.x/trunk/ProcessHacker/runas.c +++ b/2.x/trunk/ProcessHacker/runas.c @@ -75,10 +75,10 @@ typedef struct _RUNAS_DIALOG_CONTEXT } RUNAS_DIALOG_CONTEXT, *PRUNAS_DIALOG_CONTEXT; INT_PTR CALLBACK PhpRunAsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhSetDesktopWinStaAccess( @@ -86,9 +86,9 @@ VOID PhSetDesktopWinStaAccess( ); VOID PhpSplitUserName( - __in PWSTR UserName, - __out PPH_STRING *DomainPart, - __out PPH_STRING *UserPart + _In_ PWSTR UserName, + _Out_ PPH_STRING *DomainPart, + _Out_ PPH_STRING *UserPart ); #define SIP(String, Integer) { (String), (PVOID)(Integer) } @@ -110,8 +110,8 @@ static SERVICE_STATUS_HANDLE RunAsServiceStatusHandle; static PHSVC_STOP RunAsServiceStop; VOID PhShowRunAsDialog( - __in HWND ParentWindowHandle, - __in_opt HANDLE ProcessId + _In_ HWND ParentWindowHandle, + _In_opt_ HANDLE ProcessId ) { RUNAS_DIALOG_CONTEXT context; @@ -129,7 +129,7 @@ VOID PhShowRunAsDialog( } static VOID PhpAddAccountsToComboBox( - __in HWND ComboBoxHandle + _In_ HWND ComboBoxHandle ) { LSA_HANDLE policyHandle; @@ -171,7 +171,7 @@ static VOID PhpAddAccountsToComboBox( } static BOOLEAN IsServiceAccount( - __in PPH_STRING UserName + _In_ PPH_STRING UserName ) { if ( @@ -215,8 +215,8 @@ static PPH_STRING GetCurrentWinStaName( } static BOOL CALLBACK EnumDesktopsCallback( - __in PWSTR DesktopName, - __in LPARAM Context + _In_ PWSTR DesktopName, + _In_ LPARAM Context ) { PRUNAS_DIALOG_CONTEXT context = (PRUNAS_DIALOG_CONTEXT)Context; @@ -232,10 +232,10 @@ static BOOL CALLBACK EnumDesktopsCallback( } INT_PTR CALLBACK PhpRunAsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PRUNAS_DIALOG_CONTEXT context; @@ -738,26 +738,44 @@ VOID PhSetDesktopWinStaAccess( VOID ) { + static SID_IDENTIFIER_AUTHORITY appPackageAuthority = SECURITY_APP_PACKAGE_AUTHORITY; + HWINSTA wsHandle; HDESK desktopHandle; ULONG allocationLength; PSECURITY_DESCRIPTOR securityDescriptor; PACL dacl; + CHAR allAppPackagesSidBuffer[FIELD_OFFSET(SID, SubAuthority) + sizeof(ULONG) * 2]; + PSID allAppPackagesSid; // TODO: Set security on the correct window station and desktop. + allAppPackagesSid = (PISID)allAppPackagesSidBuffer; + RtlInitializeSid(allAppPackagesSid, &appPackageAuthority, SECURITY_BUILTIN_APP_PACKAGE_RID_COUNT); + *RtlSubAuthoritySid(allAppPackagesSid, 0) = SECURITY_APP_PACKAGE_BASE_RID; + *RtlSubAuthoritySid(allAppPackagesSid, 1) = SECURITY_BUILTIN_PACKAGE_ANY_PACKAGE; + // We create a DACL that allows everyone to access everything. allocationLength = SECURITY_DESCRIPTOR_MIN_LENGTH + (ULONG)sizeof(ACL) + (ULONG)sizeof(ACCESS_ALLOWED_ACE) + - RtlLengthSid(&PhSeEveryoneSid); + RtlLengthSid(&PhSeEveryoneSid) + + (ULONG)sizeof(ACCESS_ALLOWED_ACE) + + RtlLengthSid(allAppPackagesSid); securityDescriptor = PhAllocate(allocationLength); dacl = (PACL)((PCHAR)securityDescriptor + SECURITY_DESCRIPTOR_MIN_LENGTH); RtlCreateSecurityDescriptor(securityDescriptor, SECURITY_DESCRIPTOR_REVISION); + RtlCreateAcl(dacl, allocationLength - SECURITY_DESCRIPTOR_MIN_LENGTH, ACL_REVISION); RtlAddAccessAllowedAce(dacl, ACL_REVISION, GENERIC_ALL, &PhSeEveryoneSid); + + if (WindowsVersion >= WINDOWS_8) + { + RtlAddAccessAllowedAce(dacl, ACL_REVISION, GENERIC_ALL, allAppPackagesSid); + } + RtlSetDaclSecurityDescriptor(securityDescriptor, TRUE, dacl, FALSE); if (wsHandle = OpenWindowStation( @@ -792,7 +810,7 @@ VOID PhSetDesktopWinStaAccess( * \remarks This function requires administrator-level access. */ NTSTATUS PhExecuteRunAsCommand( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ) { NTSTATUS status; @@ -901,15 +919,15 @@ NTSTATUS PhExecuteRunAsCommand( * through a UAC elevation prompt. */ NTSTATUS PhExecuteRunAsCommand2( - __in HWND hWnd, - __in PWSTR Program, - __in_opt PWSTR UserName, - __in_opt PWSTR Password, - __in_opt ULONG LogonType, - __in_opt HANDLE ProcessIdWithToken, - __in ULONG SessionId, - __in PWSTR DesktopName, - __in BOOLEAN UseLinkedToken + _In_ HWND hWnd, + _In_ PWSTR Program, + _In_opt_ PWSTR UserName, + _In_opt_ PWSTR Password, + _In_opt_ ULONG LogonType, + _In_opt_ HANDLE ProcessIdWithToken, + _In_ ULONG SessionId, + _In_ PWSTR DesktopName, + _In_ BOOLEAN UseLinkedToken ) { NTSTATUS status = STATUS_SUCCESS; @@ -983,9 +1001,9 @@ NTSTATUS PhExecuteRunAsCommand2( } static VOID PhpSplitUserName( - __in PWSTR UserName, - __out PPH_STRING *DomainPart, - __out PPH_STRING *UserPart + _In_ PWSTR UserName, + _Out_ PPH_STRING *DomainPart, + _Out_ PPH_STRING *UserPart ) { PH_STRINGREF userName; @@ -1007,7 +1025,7 @@ static VOID PhpSplitUserName( } static VOID SetRunAsServiceStatus( - __in ULONG State + _In_ ULONG State ) { SERVICE_STATUS status; @@ -1021,10 +1039,10 @@ static VOID SetRunAsServiceStatus( } static DWORD WINAPI RunAsServiceHandlerEx( - __in DWORD dwControl, - __in DWORD dwEventType, - __in LPVOID lpEventData, - __in LPVOID lpContext + _In_ DWORD dwControl, + _In_ DWORD dwEventType, + _In_ LPVOID lpEventData, + _In_ LPVOID lpContext ) { switch (dwControl) @@ -1040,8 +1058,8 @@ static DWORD WINAPI RunAsServiceHandlerEx( } static VOID WINAPI RunAsServiceMain( - __in DWORD dwArgc, - __in LPTSTR *lpszArgv + _In_ DWORD dwArgc, + _In_ LPTSTR *lpszArgv ) { PPH_STRING portName; @@ -1063,7 +1081,7 @@ static VOID WINAPI RunAsServiceMain( } NTSTATUS PhRunAsServiceStart( - __in PPH_STRING ServiceName + _In_ PPH_STRING ServiceName ) { HANDLE tokenHandle; @@ -1096,7 +1114,7 @@ NTSTATUS PhRunAsServiceStart( } NTSTATUS PhInvokeRunAsService( - __in PPH_RUNAS_SERVICE_PARAMETERS Parameters + _In_ PPH_RUNAS_SERVICE_PARAMETERS Parameters ) { NTSTATUS status; diff --git a/2.x/trunk/ProcessHacker/sdk/phapppub.h b/2.x/trunk/ProcessHacker/sdk/phapppub.h index b3274f4d3..bf00f4f82 100644 --- a/2.x/trunk/ProcessHacker/sdk/phapppub.h +++ b/2.x/trunk/ProcessHacker/sdk/phapppub.h @@ -15,30 +15,30 @@ PHAPPAPI VOID NTAPI PhRegisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ); PHAPPAPI VOID NTAPI PhUnregisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ); typedef BOOLEAN (NTAPI *PPH_MESSAGE_LOOP_FILTER)( - __in PMSG Message, - __in PVOID Context + _In_ PMSG Message, + _In_ PVOID Context ); PHAPPAPI struct _PH_MESSAGE_LOOP_FILTER_ENTRY *PhRegisterMessageLoopFilter( - __in PPH_MESSAGE_LOOP_FILTER Filter, - __in_opt PVOID Context + _In_ PPH_MESSAGE_LOOP_FILTER Filter, + _In_opt_ PVOID Context ); PHAPPAPI VOID PhUnregisterMessageLoopFilter( - __in struct _PH_MESSAGE_LOOP_FILTER_ENTRY *FilterEntry + _In_ struct _PH_MESSAGE_LOOP_FILTER_ENTRY *FilterEntry ); // Common state highlighting support @@ -193,14 +193,14 @@ PHAPPAPI PPH_PROCESS_NODE NTAPI PhFindProcessNode( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); PHAPPAPI VOID NTAPI PhUpdateProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ); PHAPPAPI @@ -214,8 +214,8 @@ PHAPPAPI VOID NTAPI PhGetSelectedProcessItems( - __out PPH_PROCESS_ITEM **Processes, - __out PULONG NumberOfProcesses + _Out_ PPH_PROCESS_ITEM **Processes, + _Out_ PULONG NumberOfProcesses ); PHAPPAPI @@ -229,7 +229,7 @@ PHAPPAPI VOID NTAPI PhExpandAllProcessNodes( - __in BOOLEAN Expand + _In_ BOOLEAN Expand ); PHAPPAPI @@ -243,12 +243,12 @@ PHAPPAPI VOID NTAPI PhSelectAndEnsureVisibleProcessNode( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ); typedef BOOLEAN (NTAPI *PPH_PROCESS_TREE_FILTER)( - __in PPH_PROCESS_NODE ProcessNode, - __in_opt PVOID Context + _In_ PPH_PROCESS_NODE ProcessNode, + _In_opt_ PVOID Context ); typedef struct _PH_PROCESS_TREE_FILTER_ENTRY *PPH_PROCESS_TREE_FILTER_ENTRY; @@ -257,15 +257,15 @@ PHAPPAPI PPH_PROCESS_TREE_FILTER_ENTRY NTAPI PhAddProcessTreeFilter( - __in PPH_PROCESS_TREE_FILTER Filter, - __in_opt PVOID Context + _In_ PPH_PROCESS_TREE_FILTER Filter, + _In_opt_ PVOID Context ); PHAPPAPI VOID NTAPI PhRemoveProcessTreeFilter( - __in PPH_PROCESS_TREE_FILTER_ENTRY Entry + _In_ PPH_PROCESS_TREE_FILTER_ENTRY Entry ); PHAPPAPI @@ -288,14 +288,14 @@ PHAPPAPI PPH_SERVICE_NODE NTAPI PhFindServiceNode( - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_SERVICE_ITEM ServiceItem ); PHAPPAPI VOID NTAPI PhUpdateServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ); PHAPPAPI @@ -309,8 +309,8 @@ PHAPPAPI VOID NTAPI PhGetSelectedServiceItems( - __out PPH_SERVICE_ITEM **Services, - __out PULONG NumberOfServices + _Out_ PPH_SERVICE_ITEM **Services, + _Out_ PULONG NumberOfServices ); PHAPPAPI @@ -324,7 +324,7 @@ PHAPPAPI VOID NTAPI PhSelectAndEnsureVisibleServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ); // netlist @@ -340,7 +340,7 @@ PHAPPAPI PPH_NETWORK_NODE NTAPI PhFindNetworkNode( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ); // appsup @@ -349,7 +349,7 @@ PHAPPAPI BOOLEAN NTAPI PhGetProcessIsSuspended( - __in PSYSTEM_PROCESS_INFORMATION Process + _In_ PSYSTEM_PROCESS_INFORMATION Process ); typedef enum _PH_KNOWN_PROCESS_TYPE @@ -378,8 +378,8 @@ PHAPPAPI NTSTATUS NTAPI PhGetProcessKnownType( - __in HANDLE ProcessHandle, - __out PH_KNOWN_PROCESS_TYPE *KnownProcessType + _In_ HANDLE ProcessHandle, + _Out_ PH_KNOWN_PROCESS_TYPE *KnownProcessType ); typedef union _PH_KNOWN_PROCESS_COMMAND_LINE @@ -405,100 +405,100 @@ PHAPPAPI BOOLEAN NTAPI PhaGetProcessKnownCommandLine( - __in PPH_STRING CommandLine, - __in PH_KNOWN_PROCESS_TYPE KnownProcessType, - __out PPH_KNOWN_PROCESS_COMMAND_LINE KnownCommandLine + _In_ PPH_STRING CommandLine, + _In_ PH_KNOWN_PROCESS_TYPE KnownProcessType, + _Out_ PPH_KNOWN_PROCESS_COMMAND_LINE KnownCommandLine ); PHAPPAPI VOID NTAPI PhSearchOnlineString( - __in HWND hWnd, - __in PWSTR String + _In_ HWND hWnd, + _In_ PWSTR String ); PHAPPAPI VOID NTAPI PhShellExecuteUserString( - __in HWND hWnd, - __in PWSTR Setting, - __in PWSTR String, - __in BOOLEAN UseShellExecute, - __in_opt PWSTR ErrorMessage + _In_ HWND hWnd, + _In_ PWSTR Setting, + _In_ PWSTR String, + _In_ BOOLEAN UseShellExecute, + _In_opt_ PWSTR ErrorMessage ); PHAPPAPI VOID NTAPI PhLoadSymbolProviderOptions( - __inout PPH_SYMBOL_PROVIDER SymbolProvider + _Inout_ PPH_SYMBOL_PROVIDER SymbolProvider ); PHAPPAPI VOID NTAPI PhCopyListViewInfoTip( - __inout LPNMLVGETINFOTIP GetInfoTip, - __in PPH_STRINGREF Tip + _Inout_ LPNMLVGETINFOTIP GetInfoTip, + _In_ PPH_STRINGREF Tip ); PHAPPAPI VOID NTAPI PhCopyListView( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ); PHAPPAPI VOID NTAPI PhHandleListViewNotifyForCopy( - __in LPARAM lParam, - __in HWND ListViewHandle + _In_ LPARAM lParam, + _In_ HWND ListViewHandle ); PHAPPAPI BOOLEAN NTAPI PhGetListViewContextMenuPoint( - __in HWND ListViewHandle, - __out PPOINT Point + _In_ HWND ListViewHandle, + _Out_ PPOINT Point ); PHAPPAPI VOID NTAPI PhLoadWindowPlacementFromSetting( - __in_opt PWSTR PositionSettingName, - __in_opt PWSTR SizeSettingName, - __in HWND WindowHandle + _In_opt_ PWSTR PositionSettingName, + _In_opt_ PWSTR SizeSettingName, + _In_ HWND WindowHandle ); PHAPPAPI VOID NTAPI PhSaveWindowPlacementToSetting( - __in_opt PWSTR PositionSettingName, - __in_opt PWSTR SizeSettingName, - __in HWND WindowHandle + _In_opt_ PWSTR PositionSettingName, + _In_opt_ PWSTR SizeSettingName, + _In_ HWND WindowHandle ); PHAPPAPI VOID NTAPI PhLoadListViewColumnsFromSetting( - __in PWSTR Name, - __in HWND ListViewHandle + _In_ PWSTR Name, + _In_ HWND ListViewHandle ); PHAPPAPI VOID NTAPI PhSaveListViewColumnsToSetting( - __in PWSTR Name, - __in HWND ListViewHandle + _In_ PWSTR Name, + _In_ HWND ListViewHandle ); PHAPPAPI @@ -512,17 +512,17 @@ PHAPPAPI VOID NTAPI PhGetPhVersionNumbers( - __out_opt PULONG MajorVersion, - __out_opt PULONG MinorVersion, - __reserved PULONG Reserved, - __out_opt PULONG RevisionNumber + _Out_opt_ PULONG MajorVersion, + _Out_opt_ PULONG MinorVersion, + _Reserved_ PULONG Reserved, + _Out_opt_ PULONG RevisionNumber ); PHAPPAPI VOID NTAPI PhWritePhTextHeader( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ); typedef struct _PH_TN_COLUMN_MENU_DATA @@ -546,21 +546,21 @@ PHAPPAPI VOID NTAPI PhInitializeTreeNewColumnMenu( - __inout PPH_TN_COLUMN_MENU_DATA Data + _Inout_ PPH_TN_COLUMN_MENU_DATA Data ); PHAPPAPI BOOLEAN NTAPI PhHandleTreeNewColumnMenu( - __inout PPH_TN_COLUMN_MENU_DATA Data + _Inout_ PPH_TN_COLUMN_MENU_DATA Data ); PHAPPAPI VOID NTAPI PhDeleteTreeNewColumnMenu( - __in PPH_TN_COLUMN_MENU_DATA Data + _In_ PPH_TN_COLUMN_MENU_DATA Data ); typedef struct _PH_TN_FILTER_SUPPORT @@ -571,8 +571,8 @@ typedef struct _PH_TN_FILTER_SUPPORT } PH_TN_FILTER_SUPPORT, *PPH_TN_FILTER_SUPPORT; typedef BOOLEAN (NTAPI *PPH_TN_FILTER_FUNCTION)( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); typedef struct _PH_TN_FILTER_ENTRY @@ -585,24 +585,24 @@ PHAPPAPI PPH_TN_FILTER_ENTRY NTAPI PhAddTreeNewFilter( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TN_FILTER_FUNCTION Filter, - __in_opt PVOID Context + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TN_FILTER_FUNCTION Filter, + _In_opt_ PVOID Context ); PHAPPAPI VOID NTAPI PhRemoveTreeNewFilter( - __in PPH_TN_FILTER_SUPPORT Support, - __in PPH_TN_FILTER_ENTRY Entry + _In_ PPH_TN_FILTER_SUPPORT Support, + _In_ PPH_TN_FILTER_ENTRY Entry ); PHAPPAPI VOID NTAPI PhApplyTreeNewFilters( - __in PPH_TN_FILTER_SUPPORT Support + _In_ PPH_TN_FILTER_SUPPORT Support ); // mainwnd @@ -640,8 +640,8 @@ PHAPPAPI extern HWND PhMainWndHandle; SendMessage(hWnd, WM_PH_PREPARE_FOR_EARLY_SHUTDOWN, 0, 0) #define ProcessHacker_CancelEarlyShutdown(hWnd) \ SendMessage(hWnd, WM_PH_CANCEL_EARLY_SHUTDOWN, 0, 0) -#define ProcessHacker_ToggleVisible(hWnd) \ - SendMessage(hWnd, WM_PH_TOGGLE_VISIBLE, 0, 0) +#define ProcessHacker_ToggleVisible(hWnd, AlwaysShow) \ + SendMessage(hWnd, WM_PH_TOGGLE_VISIBLE, (WPARAM)(AlwaysShow), 0) #define ProcessHacker_SelectTabPage(hWnd, Index) \ SendMessage(hWnd, WM_PH_SELECT_TAB_PAGE, (WPARAM)(Index), 0) #define ProcessHacker_GetCallbackLayoutPadding(hWnd) \ @@ -674,24 +674,24 @@ typedef struct _PH_LAYOUT_PADDING_DATA typedef struct _PH_ADDMENUITEM { - __in PVOID Plugin; - __in ULONG Location; - __in_opt PWSTR InsertAfter; - __in ULONG Flags; - __in ULONG Id; - __in PWSTR Text; - __in_opt PVOID Context; + _In_ PVOID Plugin; + _In_ ULONG Location; + _In_opt_ PWSTR InsertAfter; + _In_ ULONG Flags; + _In_ ULONG Id; + _In_ PWSTR Text; + _In_opt_ PVOID Context; } PH_ADDMENUITEM, *PPH_ADDMENUITEM; typedef HWND (NTAPI *PPH_TAB_PAGE_CREATE_FUNCTION)( - __in PVOID Context + _In_ PVOID Context ); typedef VOID (NTAPI *PPH_TAB_PAGE_CALLBACK_FUNCTION)( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ); typedef struct _PH_ADDITIONAL_TAB_PAGE @@ -722,9 +722,9 @@ PHAPPAPI VOID NTAPI PhShowIconNotification( - __in PWSTR Title, - __in PWSTR Text, - __in ULONG Flags + _In_ PWSTR Title, + _In_ PWSTR Text, + _In_ ULONG Flags ); // procprp @@ -744,61 +744,61 @@ PHAPPAPI PPH_PROCESS_PROPCONTEXT NTAPI PhCreateProcessPropContext( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); PHAPPAPI VOID NTAPI PhSetSelectThreadIdProcessPropContext( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in HANDLE ThreadId + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ HANDLE ThreadId ); PHAPPAPI BOOLEAN NTAPI PhAddProcessPropPage( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in __assumeRefs(1) PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ _Assume_refs_(1) PPH_PROCESS_PROPPAGECONTEXT PropPageContext ); PHAPPAPI BOOLEAN NTAPI PhAddProcessPropPage2( - __inout PPH_PROCESS_PROPCONTEXT PropContext, - __in HPROPSHEETPAGE PropSheetPageHandle + _Inout_ PPH_PROCESS_PROPCONTEXT PropContext, + _In_ HPROPSHEETPAGE PropSheetPageHandle ); PHAPPAPI PPH_PROCESS_PROPPAGECONTEXT NTAPI PhCreateProcessPropPageContextEx( - __in_opt PVOID InstanceHandle, - __in LPCWSTR Template, - __in DLGPROC DlgProc, - __in_opt PVOID Context + _In_opt_ PVOID InstanceHandle, + _In_ LPCWSTR Template, + _In_ DLGPROC DlgProc, + _In_opt_ PVOID Context ); PHAPPAPI BOOLEAN NTAPI PhPropPageDlgProcHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam, - __out LPPROPSHEETPAGE *PropSheetPage, - __out PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, - __out PPH_PROCESS_ITEM *ProcessItem + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam, + _Out_ LPPROPSHEETPAGE *PropSheetPage, + _Out_ PPH_PROCESS_PROPPAGECONTEXT *PropPageContext, + _Out_ PPH_PROCESS_ITEM *ProcessItem ); PHAPPAPI VOID NTAPI PhPropPageDlgProcDestroy( - __in HWND hwndDlg + _In_ HWND hwndDlg ); #define PH_PROP_PAGE_TAB_CONTROL_PARENT ((PPH_LAYOUT_ITEM)0x1) @@ -807,22 +807,22 @@ PHAPPAPI PPH_LAYOUT_ITEM NTAPI PhAddPropPageLayoutItem( - __in HWND hwnd, - __in HWND Handle, - __in PPH_LAYOUT_ITEM ParentItem, - __in ULONG Anchor + _In_ HWND hwnd, + _In_ HWND Handle, + _In_ PPH_LAYOUT_ITEM ParentItem, + _In_ ULONG Anchor ); PHAPPAPI VOID NTAPI PhDoPropPageLayout( - __in HWND hwnd + _In_ HWND hwnd ); FORCEINLINE PPH_LAYOUT_ITEM PhBeginPropPageLayout( - __in HWND hwndDlg, - __in PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_PROPPAGECONTEXT PropPageContext ) { if (!PropPageContext->LayoutInitialized) @@ -837,8 +837,8 @@ FORCEINLINE PPH_LAYOUT_ITEM PhBeginPropPageLayout( } FORCEINLINE VOID PhEndPropPageLayout( - __in HWND hwndDlg, - __in PPH_PROCESS_PROPPAGECONTEXT PropPageContext + _In_ HWND hwndDlg, + _In_ PPH_PROCESS_PROPPAGECONTEXT PropPageContext ) { PhDoPropPageLayout(hwndDlg); @@ -849,7 +849,7 @@ PHAPPAPI BOOLEAN NTAPI PhShowProcessProperties( - __in PPH_PROCESS_PROPCONTEXT Context + _In_ PPH_PROCESS_PROPCONTEXT Context ); // sysinfo @@ -861,9 +861,9 @@ typedef enum _PH_SYSINFO_VIEW_TYPE } PH_SYSINFO_VIEW_TYPE; typedef VOID (NTAPI *PPH_SYSINFO_COLOR_SETUP_FUNCTION)( - __out PPH_GRAPH_DRAW_INFO DrawInfo, - __in COLORREF Color1, - __in COLORREF Color2 + _Out_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ COLORREF Color1, + _In_ COLORREF Color2 ); typedef struct _PH_SYSINFO_PARAMETERS @@ -899,10 +899,10 @@ typedef enum _PH_SYSINFO_SECTION_MESSAGE } PH_SYSINFO_SECTION_MESSAGE; typedef BOOLEAN (NTAPI *PPH_SYSINFO_SECTION_CALLBACK)( - __in struct _PH_SYSINFO_SECTION *Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ struct _PH_SYSINFO_SECTION *Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); typedef struct _PH_SYSINFO_CREATE_DIALOG @@ -954,6 +954,13 @@ typedef struct _PH_SYSINFO_SECTION // ... } PH_SYSINFO_SECTION, *PPH_SYSINFO_SECTION; +PHAPPAPI +VOID PhSiSetColorsGraphDrawInfo( + _Out_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ COLORREF Color1, + _In_ COLORREF Color2 + ); + // log #define PH_LOG_ENTRY_MESSAGE 9 @@ -966,15 +973,15 @@ PHAPPAPI VOID NTAPI PhLogMessageEntry( - __in UCHAR Type, - __in PPH_STRING Message + _In_ UCHAR Type, + _In_ PPH_STRING Message ); PHAPPAPI PPH_STRING NTAPI PhFormatLogEntry( - __in PPH_LOG_ENTRY Entry + _In_ PPH_LOG_ENTRY Entry ); // actions @@ -983,350 +990,350 @@ PHAPPAPI BOOLEAN NTAPI PhUiLockComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN NTAPI PhUiLogoffComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN NTAPI PhUiSleepComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN NTAPI PhUiHibernateComputer( - __in HWND hWnd + _In_ HWND hWnd ); PHAPPAPI BOOLEAN NTAPI PhUiRestartComputer( - __in HWND hWnd, - __in ULONG Flags + _In_ HWND hWnd, + _In_ ULONG Flags ); PHAPPAPI BOOLEAN NTAPI PhUiShutdownComputer( - __in HWND hWnd, - __in ULONG Flags + _In_ HWND hWnd, + _In_ ULONG Flags ); PHAPPAPI BOOLEAN NTAPI PhUiConnectSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ); PHAPPAPI BOOLEAN NTAPI PhUiDisconnectSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ); PHAPPAPI BOOLEAN NTAPI PhUiLogoffSession( - __in HWND hWnd, - __in ULONG SessionId + _In_ HWND hWnd, + _In_ ULONG SessionId ); PHAPPAPI BOOLEAN NTAPI PhUiTerminateProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN NTAPI PhUiTerminateTreeProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN NTAPI PhUiSuspendProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN NTAPI PhUiResumeProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN NTAPI PhUiRestartProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN NTAPI PhUiDebugProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN NTAPI PhUiReduceWorkingSetProcesses( - __in HWND hWnd, - __in PPH_PROCESS_ITEM *Processes, - __in ULONG NumberOfProcesses + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM *Processes, + _In_ ULONG NumberOfProcesses ); PHAPPAPI BOOLEAN NTAPI PhUiSetVirtualizationProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in BOOLEAN Enable + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ BOOLEAN Enable ); PHAPPAPI BOOLEAN NTAPI PhUiDetachFromDebuggerProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN NTAPI PhUiInjectDllProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN NTAPI PhUiSetIoPriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG IoPriority + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG IoPriority ); PHAPPAPI BOOLEAN NTAPI PhUiSetPagePriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG PagePriority + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG PagePriority ); PHAPPAPI BOOLEAN NTAPI PhUiSetPriorityProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process, - __in ULONG PriorityClass + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process, + _In_ ULONG PriorityClass ); PHAPPAPI BOOLEAN NTAPI PhUiSetDepStatusProcess( - __in HWND hWnd, - __in PPH_PROCESS_ITEM Process + _In_ HWND hWnd, + _In_ PPH_PROCESS_ITEM Process ); PHAPPAPI BOOLEAN NTAPI PhUiStartService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN NTAPI PhUiContinueService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN NTAPI PhUiPauseService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN NTAPI PhUiStopService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN NTAPI PhUiDeleteService( - __in HWND hWnd, - __in PPH_SERVICE_ITEM Service + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM Service ); PHAPPAPI BOOLEAN NTAPI PhUiCloseConnections( - __in HWND hWnd, - __in PPH_NETWORK_ITEM *Connections, - __in ULONG NumberOfConnections + _In_ HWND hWnd, + _In_ PPH_NETWORK_ITEM *Connections, + _In_ ULONG NumberOfConnections ); PHAPPAPI BOOLEAN NTAPI PhUiTerminateThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN NTAPI PhUiForceTerminateThreads( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN NTAPI PhUiSuspendThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN NTAPI PhUiResumeThreads( - __in HWND hWnd, - __in PPH_THREAD_ITEM *Threads, - __in ULONG NumberOfThreads + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM *Threads, + _In_ ULONG NumberOfThreads ); PHAPPAPI BOOLEAN NTAPI PhUiSetPriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG ThreadPriorityWin32 + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG ThreadPriorityWin32 ); PHAPPAPI BOOLEAN NTAPI PhUiSetIoPriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG IoPriority + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG IoPriority ); PHAPPAPI BOOLEAN NTAPI PhUiSetPagePriorityThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread, - __in ULONG PagePriority + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread, + _In_ ULONG PagePriority ); PHAPPAPI BOOLEAN NTAPI PhUiUnloadModule( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_MODULE_ITEM Module + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_MODULE_ITEM Module ); PHAPPAPI BOOLEAN NTAPI PhUiFreeMemory( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_MEMORY_ITEM MemoryItem, - __in BOOLEAN Free + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_MEMORY_ITEM MemoryItem, + _In_ BOOLEAN Free ); PHAPPAPI BOOLEAN NTAPI PhUiCloseHandles( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM *Handles, - __in ULONG NumberOfHandles, - __in BOOLEAN Warn + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM *Handles, + _In_ ULONG NumberOfHandles, + _In_ BOOLEAN Warn ); PHAPPAPI BOOLEAN NTAPI PhUiSetAttributesHandle( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PPH_HANDLE_ITEM Handle, - __in ULONG Attributes + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PPH_HANDLE_ITEM Handle, + _In_ ULONG Attributes ); PHAPPAPI BOOLEAN NTAPI PhUiDestroyHeap( - __in HWND hWnd, - __in HANDLE ProcessId, - __in PVOID HeapHandle + _In_ HWND hWnd, + _In_ HANDLE ProcessId, + _In_ PVOID HeapHandle ); // affinity @@ -1335,9 +1342,9 @@ PHAPPAPI BOOLEAN NTAPI PhShowProcessAffinityDialog2( - __in HWND ParentWindowHandle, - __in ULONG_PTR AffinityMask, - __out PULONG_PTR NewAffinityMask + _In_ HWND ParentWindowHandle, + _In_ ULONG_PTR AffinityMask, + _Out_ PULONG_PTR NewAffinityMask ); // chdlg @@ -1351,16 +1358,16 @@ PhShowProcessAffinityDialog2( PHAPPAPI BOOLEAN PhaChoiceDialog( - __in HWND ParentWindowHandle, - __in PWSTR Title, - __in PWSTR Message, - __in_opt PWSTR *Choices, - __in_opt ULONG NumberOfChoices, - __in_opt PWSTR Option, - __in ULONG Flags, - __inout PPH_STRING *SelectedChoice, - __inout_opt PBOOLEAN SelectedOption, - __in_opt PWSTR SavedChoicesSettingName + _In_ HWND ParentWindowHandle, + _In_ PWSTR Title, + _In_ PWSTR Message, + _In_opt_ PWSTR *Choices, + _In_opt_ ULONG NumberOfChoices, + _In_opt_ PWSTR Option, + _In_ ULONG Flags, + _Inout_ PPH_STRING *SelectedChoice, + _Inout_opt_ PBOOLEAN SelectedOption, + _In_opt_ PWSTR SavedChoicesSettingName ); // chproc @@ -1369,9 +1376,9 @@ PHAPPAPI BOOLEAN NTAPI PhShowChooseProcessDialog( - __in HWND ParentWindowHandle, - __in PWSTR Message, - __out PHANDLE ProcessId + _In_ HWND ParentWindowHandle, + _In_ PWSTR Message, + _Out_ PHANDLE ProcessId ); // procrec @@ -1380,8 +1387,8 @@ PHAPPAPI VOID NTAPI PhShowProcessRecordDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_RECORD Record + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_RECORD Record ); // srvctl @@ -1392,9 +1399,9 @@ PHAPPAPI HWND NTAPI PhCreateServiceListControl( - __in HWND ParentWindowHandle, - __in PPH_SERVICE_ITEM *Services, - __in ULONG NumberOfServices + _In_ HWND ParentWindowHandle, + _In_ PPH_SERVICE_ITEM *Services, + _In_ ULONG NumberOfServices ); // settings @@ -1407,56 +1414,56 @@ typedef enum _PH_SETTING_TYPE } PH_SETTING_TYPE, PPH_SETTING_TYPE; PHAPPAPI -__mayRaise ULONG +_May_raise_ ULONG NTAPI PhGetIntegerSetting( - __in PWSTR Name + _In_ PWSTR Name ); PHAPPAPI -__mayRaise PH_INTEGER_PAIR +_May_raise_ PH_INTEGER_PAIR NTAPI PhGetIntegerPairSetting( - __in PWSTR Name + _In_ PWSTR Name ); PHAPPAPI -__mayRaise PPH_STRING +_May_raise_ PPH_STRING NTAPI PhGetStringSetting( - __in PWSTR Name + _In_ PWSTR Name ); PHAPPAPI -__mayRaise VOID +_May_raise_ VOID NTAPI PhSetIntegerSetting( - __in PWSTR Name, - __in ULONG Value + _In_ PWSTR Name, + _In_ ULONG Value ); PHAPPAPI -__mayRaise VOID +_May_raise_ VOID NTAPI PhSetIntegerPairSetting( - __in PWSTR Name, - __in PH_INTEGER_PAIR Value + _In_ PWSTR Name, + _In_ PH_INTEGER_PAIR Value ); PHAPPAPI -__mayRaise VOID +_May_raise_ VOID NTAPI PhSetStringSetting( - __in PWSTR Name, - __in PWSTR Value + _In_ PWSTR Name, + _In_ PWSTR Value ); PHAPPAPI -__mayRaise VOID +_May_raise_ VOID NTAPI PhSetStringSetting2( - __in PWSTR Name, - __in PPH_STRINGREF Value + _In_ PWSTR Name, + _In_ PPH_STRINGREF Value ); // High-level settings creation @@ -1472,8 +1479,8 @@ PHAPPAPI VOID NTAPI PhAddSettings( - __in PPH_SETTING_CREATE Settings, - __in ULONG NumberOfSettings + _In_ PPH_SETTING_CREATE Settings, + _In_ ULONG NumberOfSettings ); #ifdef __cplusplus diff --git a/2.x/trunk/ProcessHacker/sessmsg.c b/2.x/trunk/ProcessHacker/sessmsg.c index 69a08c7a3..77f9bf5a3 100644 --- a/2.x/trunk/ProcessHacker/sessmsg.c +++ b/2.x/trunk/ProcessHacker/sessmsg.c @@ -36,15 +36,15 @@ static PH_KEY_VALUE_PAIR PhpMessageBoxIconPairs[] = }; INT_PTR CALLBACK PhpSessionSendMessageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowSessionSendMessageDialog( - __in HWND ParentWindowHandle, - __in ULONG SessionId + _In_ HWND ParentWindowHandle, + _In_ ULONG SessionId ) { DialogBoxParam( @@ -57,10 +57,10 @@ VOID PhShowSessionSendMessageDialog( } INT_PTR CALLBACK PhpSessionSendMessageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/sessprp.c b/2.x/trunk/ProcessHacker/sessprp.c index 9d1ae2857..9dc7b4483 100644 --- a/2.x/trunk/ProcessHacker/sessprp.c +++ b/2.x/trunk/ProcessHacker/sessprp.c @@ -25,10 +25,10 @@ #include INT_PTR CALLBACK PhpSessionPropertiesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); #define SIP(String, Integer) { (String), (PVOID)(Integer) } @@ -48,8 +48,8 @@ static PH_KEY_VALUE_PAIR PhpConnectStatePairs[] = }; VOID PhShowSessionProperties( - __in HWND ParentWindowHandle, - __in ULONG SessionId + _In_ HWND ParentWindowHandle, + _In_ ULONG SessionId ) { DialogBoxParam( @@ -62,10 +62,10 @@ VOID PhShowSessionProperties( } INT_PTR CALLBACK PhpSessionPropertiesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/sessshad.c b/2.x/trunk/ProcessHacker/sessshad.c index 3aa5b6749..57789d4d7 100644 --- a/2.x/trunk/ProcessHacker/sessshad.c +++ b/2.x/trunk/ProcessHacker/sessshad.c @@ -97,15 +97,15 @@ static PH_KEY_VALUE_PAIR VirtualKeyPairs[] = }; INT_PTR CALLBACK PhpSessionShadowDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowSessionShadowDialog( - __in HWND ParentWindowHandle, - __in ULONG SessionId + _In_ HWND ParentWindowHandle, + _In_ ULONG SessionId ) { if (SessionId == NtCurrentPeb()->SessionId) @@ -124,10 +124,10 @@ VOID PhShowSessionShadowDialog( } INT_PTR CALLBACK PhpSessionShadowDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/settings.c b/2.x/trunk/ProcessHacker/settings.c index 3d3354661..c67350e05 100644 --- a/2.x/trunk/ProcessHacker/settings.c +++ b/2.x/trunk/ProcessHacker/settings.c @@ -85,7 +85,7 @@ VOID PhSettingsInitialization( PhpAddIntegerSetting(L"EnableNetworkResolve", L"1"); PhpAddIntegerSetting(L"EnablePlugins", L"1"); PhpAddIntegerSetting(L"EnableServiceNonPoll", L"0"); - PhpAddIntegerSetting(L"EnableStage2", L"0"); + PhpAddIntegerSetting(L"EnableStage2", L"1"); PhpAddIntegerSetting(L"EnableWarnings", L"1"); PhpAddStringSetting(L"EnvironmentListViewColumns", L""); PhpAddStringSetting(L"FindObjListViewColumns", L""); @@ -278,8 +278,8 @@ VOID PhUpdateCachedSettings( } BOOLEAN NTAPI PhpSettingsHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_SETTING setting1 = (PPH_SETTING)Entry1; @@ -289,7 +289,7 @@ BOOLEAN NTAPI PhpSettingsHashtableCompareFunction( } ULONG NTAPI PhpSettingsHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PPH_SETTING setting = (PPH_SETTING)Entry; @@ -297,10 +297,10 @@ ULONG NTAPI PhpSettingsHashtableHashFunction( return PhHashBytes((PUCHAR)setting->Name.Buffer, setting->Name.Length); } -__assumeLocked static VOID PhpAddSetting( - __in PH_SETTING_TYPE Type, - __in PPH_STRINGREF Name, - __in PPH_STRINGREF DefaultValue +static VOID PhpAddSetting( + _In_ PH_SETTING_TYPE Type, + _In_ PPH_STRINGREF Name, + _In_ PPH_STRINGREF DefaultValue ) { PH_SETTING setting; @@ -316,8 +316,8 @@ __assumeLocked static VOID PhpAddSetting( } static PPH_STRING PhpSettingToString( - __in PH_SETTING_TYPE Type, - __in PPH_SETTING Setting + _In_ PH_SETTING_TYPE Type, + _In_ PPH_SETTING Setting ) { switch (Type) @@ -347,10 +347,10 @@ static PPH_STRING PhpSettingToString( } static BOOLEAN PhpSettingFromString( - __in PH_SETTING_TYPE Type, - __in PPH_STRINGREF StringRef, - __in_opt PPH_STRING String, - __inout PPH_SETTING Setting + _In_ PH_SETTING_TYPE Type, + _In_ PPH_STRINGREF StringRef, + _In_opt_ PPH_STRING String, + _Inout_ PPH_SETTING Setting ) { switch (Type) @@ -410,8 +410,8 @@ static BOOLEAN PhpSettingFromString( } static VOID PhpFreeSettingValue( - __in PH_SETTING_TYPE Type, - __in PPH_SETTING Setting + _In_ PH_SETTING_TYPE Type, + _In_ PPH_SETTING Setting ) { switch (Type) @@ -424,7 +424,7 @@ static VOID PhpFreeSettingValue( } static PVOID PhpLookupSetting( - __in PPH_STRINGREF Name + _In_ PPH_STRINGREF Name ) { PH_SETTING lookupSetting; @@ -439,8 +439,8 @@ static PVOID PhpLookupSetting( return setting; } -__mayRaise ULONG PhGetIntegerSetting( - __in PWSTR Name +_May_raise_ ULONG PhGetIntegerSetting( + _In_ PWSTR Name ) { PPH_SETTING setting; @@ -470,8 +470,8 @@ __mayRaise ULONG PhGetIntegerSetting( return value; } -__mayRaise PH_INTEGER_PAIR PhGetIntegerPairSetting( - __in PWSTR Name +_May_raise_ PH_INTEGER_PAIR PhGetIntegerPairSetting( + _In_ PWSTR Name ) { PPH_SETTING setting; @@ -501,8 +501,8 @@ __mayRaise PH_INTEGER_PAIR PhGetIntegerPairSetting( return value; } -__mayRaise PPH_STRING PhGetStringSetting( - __in PWSTR Name +_May_raise_ PPH_STRING PhGetStringSetting( + _In_ PWSTR Name ) { PPH_SETTING setting; @@ -545,9 +545,9 @@ __mayRaise PPH_STRING PhGetStringSetting( return value; } -__mayRaise VOID PhSetIntegerSetting( - __in PWSTR Name, - __in ULONG Value +_May_raise_ VOID PhSetIntegerSetting( + _In_ PWSTR Name, + _In_ ULONG Value ) { PPH_SETTING setting; @@ -570,9 +570,9 @@ __mayRaise VOID PhSetIntegerSetting( PhRaiseStatus(STATUS_NOT_FOUND); } -__mayRaise VOID PhSetIntegerPairSetting( - __in PWSTR Name, - __in PH_INTEGER_PAIR Value +_May_raise_ VOID PhSetIntegerPairSetting( + _In_ PWSTR Name, + _In_ PH_INTEGER_PAIR Value ) { PPH_SETTING setting; @@ -595,9 +595,9 @@ __mayRaise VOID PhSetIntegerPairSetting( PhRaiseStatus(STATUS_NOT_FOUND); } -__mayRaise VOID PhSetStringSetting( - __in PWSTR Name, - __in PWSTR Value +_May_raise_ VOID PhSetStringSetting( + _In_ PWSTR Name, + _In_ PWSTR Value ) { PPH_SETTING setting; @@ -621,9 +621,9 @@ __mayRaise VOID PhSetStringSetting( PhRaiseStatus(STATUS_NOT_FOUND); } -__mayRaise VOID PhSetStringSetting2( - __in PWSTR Name, - __in PPH_STRINGREF Value +_May_raise_ VOID PhSetStringSetting2( + _In_ PWSTR Name, + _In_ PPH_STRINGREF Value ) { PPH_SETTING setting; @@ -648,7 +648,7 @@ __mayRaise VOID PhSetStringSetting2( } VOID PhpFreeIgnoredSetting( - __in PPH_SETTING Setting + _In_ PPH_SETTING Setting ) { PhFree(Setting->Name.Buffer); @@ -727,14 +727,14 @@ VOID PhConvertIgnoredSettings( } mxml_type_t PhpSettingsLoadCallback( - __in mxml_node_t *node + _In_ mxml_node_t *node ) { return MXML_OPAQUE; } NTSTATUS PhLoadSettings( - __in PWSTR FileName + _In_ PWSTR FileName ) { NTSTATUS status; @@ -853,8 +853,8 @@ NTSTATUS PhLoadSettings( } char *PhpSettingsSaveCallback( - __in mxml_node_t *node, - __in int position + _In_ mxml_node_t *node, + _In_ int position ) { if (STR_IEQUAL(node->value.element.name, "setting")) @@ -874,9 +874,9 @@ char *PhpSettingsSaveCallback( } mxml_node_t *PhpCreateSettingElement( - __inout mxml_node_t *ParentNode, - __in PPH_STRINGREF SettingName, - __in PPH_STRINGREF SettingValue + _Inout_ mxml_node_t *ParentNode, + _In_ PPH_STRINGREF SettingName, + _In_ PPH_STRINGREF SettingValue ) { mxml_node_t *settingNode; @@ -902,7 +902,7 @@ mxml_node_t *PhpCreateSettingElement( } NTSTATUS PhSaveSettings( - __in PWSTR FileName + _In_ PWSTR FileName ) { NTSTATUS status; @@ -1007,8 +1007,8 @@ VOID PhResetSettings( } VOID PhAddSettings( - __in PPH_SETTING_CREATE Settings, - __in ULONG NumberOfSettings + _In_ PPH_SETTING_CREATE Settings, + _In_ ULONG NumberOfSettings ) { ULONG i; diff --git a/2.x/trunk/ProcessHacker/srvcr.c b/2.x/trunk/ProcessHacker/srvcr.c index bada11e48..43272ee23 100644 --- a/2.x/trunk/ProcessHacker/srvcr.c +++ b/2.x/trunk/ProcessHacker/srvcr.c @@ -25,14 +25,14 @@ #include INT_PTR CALLBACK PhpCreateServiceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowCreateServiceDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ) { DialogBox( @@ -44,10 +44,10 @@ VOID PhShowCreateServiceDialog( } INT_PTR CALLBACK PhpCreateServiceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/srvctl.c b/2.x/trunk/ProcessHacker/srvctl.c index ef902a6c1..d0d8dd6a7 100644 --- a/2.x/trunk/ProcessHacker/srvctl.c +++ b/2.x/trunk/ProcessHacker/srvctl.c @@ -35,15 +35,15 @@ typedef struct _PH_SERVICES_CONTEXT } PH_SERVICES_CONTEXT, *PPH_SERVICES_CONTEXT; VOID NTAPI ServiceModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); INT_PTR CALLBACK PhpServicesPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); /** @@ -59,9 +59,9 @@ INT_PTR CALLBACK PhpServicesPageProc( * in \a Services. */ HWND PhCreateServiceListControl( - __in HWND ParentWindowHandle, - __in PPH_SERVICE_ITEM *Services, - __in ULONG NumberOfServices + _In_ HWND ParentWindowHandle, + _In_ PPH_SERVICE_ITEM *Services, + _In_ ULONG NumberOfServices ) { HWND windowHandle; @@ -91,8 +91,8 @@ HWND PhCreateServiceListControl( } static VOID NTAPI ServiceModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_SERVICE_MODIFIED_DATA serviceModifiedData = (PPH_SERVICE_MODIFIED_DATA)Parameter; @@ -105,8 +105,8 @@ static VOID NTAPI ServiceModifiedHandler( } VOID PhpFixProcessServicesControls( - __in HWND hWnd, - __in_opt PPH_SERVICE_ITEM ServiceItem + _In_ HWND hWnd, + _In_opt_ PPH_SERVICE_ITEM ServiceItem ) { HWND startButton; @@ -186,10 +186,10 @@ VOID PhpFixProcessServicesControls( } INT_PTR CALLBACK PhpServicesPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPH_SERVICES_CONTEXT servicesContext; diff --git a/2.x/trunk/ProcessHacker/srvlist.c b/2.x/trunk/ProcessHacker/srvlist.c index f10d067e9..0c0660d6f 100644 --- a/2.x/trunk/ProcessHacker/srvlist.c +++ b/2.x/trunk/ProcessHacker/srvlist.c @@ -28,31 +28,31 @@ #include BOOLEAN PhpServiceNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG PhpServiceNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID PhpRemoveServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ); LONG PhpServiceTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ); BOOLEAN NTAPI PhpServiceTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); static HWND ServiceTreeListHandle; @@ -87,8 +87,8 @@ VOID PhServiceTreeListInitialization( } BOOLEAN PhpServiceNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_SERVICE_NODE serviceNode1 = *(PPH_SERVICE_NODE *)Entry1; @@ -98,7 +98,7 @@ BOOLEAN PhpServiceNodeHashtableCompareFunction( } ULONG PhpServiceNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { #ifdef _M_IX86 @@ -109,7 +109,7 @@ ULONG PhpServiceNodeHashtableHashFunction( } VOID PhInitializeServiceTreeList( - __in HWND hwnd + _In_ HWND hwnd ) { ServiceApplicationIcon = PH_LOAD_SHARED_IMAGE(MAKEINTRESOURCE(IDI_PHAPPLICATION), IMAGE_ICON); @@ -192,8 +192,8 @@ struct _PH_TN_FILTER_SUPPORT *PhGetFilterSupportServiceTreeList( } PPH_SERVICE_NODE PhAddServiceNode( - __in PPH_SERVICE_ITEM ServiceItem, - __in ULONG RunId + _In_ PPH_SERVICE_ITEM ServiceItem, + _In_ ULONG RunId ) { PPH_SERVICE_NODE serviceNode; @@ -235,7 +235,7 @@ PPH_SERVICE_NODE PhAddServiceNode( } PPH_SERVICE_NODE PhFindServiceNode( - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_SERVICE_ITEM ServiceItem ) { PH_SERVICE_NODE lookupServiceNode; @@ -256,7 +256,7 @@ PPH_SERVICE_NODE PhFindServiceNode( } VOID PhRemoveServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ) { // Remove from the hashtable here to avoid problems in case the key is re-used. @@ -280,7 +280,7 @@ VOID PhRemoveServiceNode( } VOID PhpRemoveServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ) { ULONG index; @@ -306,7 +306,7 @@ VOID PhpRemoveServiceNode( } VOID PhUpdateServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ) { memset(ServiceNode->TextCache, 0, sizeof(PH_STRINGREF) * PHSVTLC_MAXIMUM); @@ -332,7 +332,7 @@ VOID PhTickServiceNodes( } static VOID PhpUpdateServiceNodeConfig( - __inout PPH_SERVICE_NODE ServiceNode + _Inout_ PPH_SERVICE_NODE ServiceNode ) { if (!(ServiceNode->ValidMask & PHSN_CONFIG)) @@ -360,7 +360,7 @@ static VOID PhpUpdateServiceNodeConfig( } static VOID PhpUpdateServiceNodeDescription( - __inout PPH_SERVICE_NODE ServiceNode + _Inout_ PPH_SERVICE_NODE ServiceNode ) { if (!(ServiceNode->ValidMask & PHSN_DESCRIPTION)) @@ -381,8 +381,8 @@ static VOID PhpUpdateServiceNodeDescription( #define SORT_FUNCTION(Column) PhpServiceTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpServiceTreeNewCompare##Column( \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PPH_SERVICE_NODE node1 = *(PPH_SERVICE_NODE *)_elem1; \ @@ -399,10 +399,10 @@ static VOID PhpUpdateServiceNodeDescription( } LONG PhpServiceTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ) { return PhModifySort(Result, SortOrder); @@ -475,11 +475,11 @@ BEGIN_SORT_FUNCTION(Description) END_SORT_FUNCTION BOOLEAN NTAPI PhpServiceTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PPH_SERVICE_NODE node; @@ -724,8 +724,8 @@ PPH_SERVICE_ITEM PhGetSelectedServiceItem( } VOID PhGetSelectedServiceItems( - __out PPH_SERVICE_ITEM **Services, - __out PULONG NumberOfServices + _Out_ PPH_SERVICE_ITEM **Services, + _Out_ PULONG NumberOfServices ) { PPH_LIST list; @@ -757,7 +757,7 @@ VOID PhDeselectAllServiceNodes( } VOID PhSelectAndEnsureVisibleServiceNode( - __in PPH_SERVICE_NODE ServiceNode + _In_ PPH_SERVICE_NODE ServiceNode ) { PhDeselectAllServiceNodes(); @@ -783,8 +783,8 @@ VOID PhCopyServiceList( } VOID PhWriteServiceList( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ) { PPH_LIST lines; diff --git a/2.x/trunk/ProcessHacker/srvprp.c b/2.x/trunk/ProcessHacker/srvprp.c index f9d92503c..84fe8fbb9 100644 --- a/2.x/trunk/ProcessHacker/srvprp.c +++ b/2.x/trunk/ProcessHacker/srvprp.c @@ -35,16 +35,16 @@ typedef struct _SERVICE_PROPERTIES_CONTEXT } SERVICE_PROPERTIES_CONTEXT, *PSERVICE_PROPERTIES_CONTEXT; INT_PTR CALLBACK PhpServiceGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static NTSTATUS PhpOpenService( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { SC_HANDLE serviceHandle; @@ -61,8 +61,8 @@ static NTSTATUS PhpOpenService( } VOID PhShowServiceProperties( - __in HWND ParentWindowHandle, - __in PPH_SERVICE_ITEM ServiceItem + _In_ HWND ParentWindowHandle, + _In_ PPH_SERVICE_ITEM ServiceItem ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -134,7 +134,7 @@ VOID PhShowServiceProperties( } static VOID PhpRefreshControls( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { if ( @@ -151,10 +151,10 @@ static VOID PhpRefreshControls( } INT_PTR CALLBACK PhpServiceGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -165,6 +165,8 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc( PSERVICE_PROPERTIES_CONTEXT context = (PSERVICE_PROPERTIES_CONTEXT)propSheetPage->lParam; PPH_SERVICE_ITEM serviceItem = context->ServiceItem; SC_HANDLE serviceHandle; + ULONG startType; + ULONG errorControl; // HACK PhCenterWindow(GetParent(hwndDlg), GetParent(GetParent(hwndDlg))); @@ -181,11 +183,9 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc( SetDlgItemText(hwndDlg, IDC_DESCRIPTION, serviceItem->DisplayName->Buffer); PhSelectComboBoxString(GetDlgItem(hwndDlg, IDC_TYPE), PhGetServiceTypeString(serviceItem->Type), FALSE); - PhSelectComboBoxString(GetDlgItem(hwndDlg, IDC_STARTTYPE), - PhGetServiceStartTypeString(serviceItem->StartType), FALSE); - PhSelectComboBoxString(GetDlgItem(hwndDlg, IDC_ERRORCONTROL), - PhGetServiceErrorControlString(serviceItem->ErrorControl), FALSE); + startType = serviceItem->StartType; + errorControl = serviceItem->ErrorControl; serviceHandle = PhOpenService(serviceItem->Name->Buffer, SERVICE_QUERY_CONFIG); if (serviceHandle) @@ -200,6 +200,13 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc( SetDlgItemText(hwndDlg, IDC_BINARYPATH, config->lpBinaryPathName); SetDlgItemText(hwndDlg, IDC_USERACCOUNT, config->lpServiceStartName); + if (startType != config->dwStartType || errorControl != config->dwErrorControl) + { + startType = config->dwStartType; + errorControl = config->dwErrorControl; + PhMarkNeedsConfigUpdateServiceItem(serviceItem); + } + PhFree(config); } @@ -223,6 +230,11 @@ INT_PTR CALLBACK PhpServiceGeneralDlgProc( CloseServiceHandle(serviceHandle); } + PhSelectComboBoxString(GetDlgItem(hwndDlg, IDC_STARTTYPE), + PhGetServiceStartTypeString(startType), FALSE); + PhSelectComboBoxString(GetDlgItem(hwndDlg, IDC_ERRORCONTROL), + PhGetServiceErrorControlString(errorControl), FALSE); + SetDlgItemText(hwndDlg, IDC_PASSWORD, L"password"); Button_SetCheck(GetDlgItem(hwndDlg, IDC_PASSWORDCHECK), BST_UNCHECKED); diff --git a/2.x/trunk/ProcessHacker/srvprv.c b/2.x/trunk/ProcessHacker/srvprv.c index 5dee549cc..a047db506 100644 --- a/2.x/trunk/ProcessHacker/srvprv.c +++ b/2.x/trunk/ProcessHacker/srvprv.c @@ -26,24 +26,24 @@ #include typedef DWORD (WINAPI *_NotifyServiceStatusChangeW)( - __in SC_HANDLE hService, - __in DWORD dwNotifyMask, - __in PSERVICE_NOTIFYW pNotifyBuffer + _In_ SC_HANDLE hService, + _In_ DWORD dwNotifyMask, + _In_ PSERVICE_NOTIFYW pNotifyBuffer ); typedef BOOL (WINAPI *_EvtClose)( - __in EVT_HANDLE Object + _In_ EVT_HANDLE Object ); typedef EVT_HANDLE (WINAPI *_EvtSubscribe)( - __in EVT_HANDLE Session, - __in HANDLE SignalEvent, - __in LPCWSTR ChannelPath, - __in LPCWSTR Query, - __in EVT_HANDLE Bookmark, - __in PVOID context, - __in EVT_SUBSCRIBE_CALLBACK Callback, - __in DWORD Flags + _In_ EVT_HANDLE Session, + _In_ HANDLE SignalEvent, + _In_ LPCWSTR ChannelPath, + _In_ LPCWSTR Query, + _In_ EVT_HANDLE Bookmark, + _In_ PVOID context, + _In_ EVT_SUBSCRIBE_CALLBACK Callback, + _In_ DWORD Flags ); typedef struct _PHP_SERVICE_NAME_ENTRY @@ -54,27 +54,27 @@ typedef struct _PHP_SERVICE_NAME_ENTRY } PHP_SERVICE_NAME_ENTRY, *PPHP_SERVICE_NAME_ENTRY; VOID NTAPI PhpServiceItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); BOOLEAN NTAPI PhpServiceHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI PhpServiceHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID PhpAddProcessItemService( - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_SERVICE_ITEM ServiceItem ); VOID PhpRemoveProcessItemService( - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_SERVICE_ITEM ServiceItem ); VOID PhpInitializeServiceNonPoll( @@ -123,7 +123,7 @@ BOOLEAN PhServiceProviderInitialization( } PPH_SERVICE_ITEM PhCreateServiceItem( - __in_opt LPENUM_SERVICE_STATUS_PROCESS Information + _In_opt_ LPENUM_SERVICE_STATUS_PROCESS Information ) { PPH_SERVICE_ITEM serviceItem; @@ -159,8 +159,8 @@ PPH_SERVICE_ITEM PhCreateServiceItem( } VOID PhpServiceItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_SERVICE_ITEM serviceItem = (PPH_SERVICE_ITEM)Object; @@ -178,8 +178,8 @@ VOID PhpServiceItemDeleteProcedure( * \param Count The number of characters to hash. */ FORCEINLINE ULONG PhpHashStringIgnoreCase( - __in PWSTR String, - __in SIZE_T Count + _In_ PWSTR String, + _In_ SIZE_T Count ) { ULONG hash = (ULONG)Count; @@ -197,8 +197,8 @@ FORCEINLINE ULONG PhpHashStringIgnoreCase( } BOOLEAN PhpServiceHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_SERVICE_ITEM serviceItem1 = *(PPH_SERVICE_ITEM *)Entry1; @@ -208,7 +208,7 @@ BOOLEAN PhpServiceHashtableCompareFunction( } ULONG PhpServiceHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PPH_SERVICE_ITEM serviceItem = *(PPH_SERVICE_ITEM *)Entry; @@ -216,8 +216,8 @@ ULONG PhpServiceHashtableHashFunction( return PhpHashStringIgnoreCase(serviceItem->Key.Buffer, serviceItem->Key.Length / sizeof(WCHAR)); } -__assumeLocked PPH_SERVICE_ITEM PhpLookupServiceItem( - __in PPH_STRINGREF Name +PPH_SERVICE_ITEM PhpLookupServiceItem( + _In_ PPH_STRINGREF Name ) { PH_SERVICE_ITEM lookupServiceItem; @@ -238,7 +238,7 @@ __assumeLocked PPH_SERVICE_ITEM PhpLookupServiceItem( } PPH_SERVICE_ITEM PhReferenceServiceItem( - __in PWSTR Name + _In_ PWSTR Name ) { PPH_SERVICE_ITEM serviceItem; @@ -260,14 +260,14 @@ PPH_SERVICE_ITEM PhReferenceServiceItem( } VOID PhMarkNeedsConfigUpdateServiceItem( - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_SERVICE_ITEM ServiceItem ) { ServiceItem->NeedsConfigUpdate = TRUE; } -__assumeLocked VOID PhpRemoveServiceItem( - __in PPH_SERVICE_ITEM ServiceItem +VOID PhpRemoveServiceItem( + _In_ PPH_SERVICE_ITEM ServiceItem ) { PhRemoveEntryHashtable(PhServiceHashtable, &ServiceItem); @@ -275,7 +275,7 @@ __assumeLocked VOID PhpRemoveServiceItem( } PH_SERVICE_CHANGE PhGetServiceChange( - __in PPH_SERVICE_MODIFIED_DATA Data + _In_ PPH_SERVICE_MODIFIED_DATA Data ) { if ( @@ -326,7 +326,7 @@ PH_SERVICE_CHANGE PhGetServiceChange( } VOID PhUpdateProcessItemServices( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { PH_HASHTABLE_ENUM_CONTEXT enumContext; @@ -351,8 +351,8 @@ VOID PhUpdateProcessItemServices( } VOID PhpAddProcessItemService( - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_SERVICE_ITEM ServiceItem ) { PhAcquireQueuedLockExclusive(&ProcessItem->ServiceListLock); @@ -373,8 +373,8 @@ VOID PhpAddProcessItemService( } VOID PhpRemoveProcessItemService( - __in PPH_PROCESS_ITEM ProcessItem, - __in PPH_SERVICE_ITEM ServiceItem + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ PPH_SERVICE_ITEM ServiceItem ) { HANDLE pointerHandle; @@ -396,8 +396,8 @@ VOID PhpRemoveProcessItemService( } VOID PhpUpdateServiceItemConfig( - __in SC_HANDLE ScManagerHandle, - __in PPH_SERVICE_ITEM ServiceItem + _In_ SC_HANDLE ScManagerHandle, + _In_ PPH_SERVICE_ITEM ServiceItem ) { SC_HANDLE serviceHandle; @@ -423,22 +423,22 @@ VOID PhpUpdateServiceItemConfig( } static BOOLEAN PhpCompareServiceNameEntry( - __in PPHP_SERVICE_NAME_ENTRY Value1, - __in PPHP_SERVICE_NAME_ENTRY Value2 + _In_ PPHP_SERVICE_NAME_ENTRY Value1, + _In_ PPHP_SERVICE_NAME_ENTRY Value2 ) { return PhEqualStringRef(&Value1->Name, &Value2->Name, TRUE); } static ULONG PhpHashServiceNameEntry( - __in PPHP_SERVICE_NAME_ENTRY Value + _In_ PPHP_SERVICE_NAME_ENTRY Value ) { return PhHashBytes((PUCHAR)Value->Name.Buffer, Value->Name.Length); } VOID PhServiceProviderUpdate( - __in PVOID Object + _In_ PVOID Object ) { static SC_HANDLE scManagerHandle = NULL; @@ -768,9 +768,9 @@ VOID PhServiceProviderUpdate( } DWORD WINAPI PhpServiceNonPollSubscribeCallback( - __in EVT_SUBSCRIBE_NOTIFY_ACTION Action, - __in PVOID UserContext, - __in EVT_HANDLE Event + _In_ EVT_SUBSCRIBE_NOTIFY_ACTION Action, + _In_ PVOID UserContext, + _In_ EVT_HANDLE Event ) { PhpNonPollGate = 1; @@ -778,7 +778,7 @@ DWORD WINAPI PhpServiceNonPollSubscribeCallback( } VOID CALLBACK PhpServiceNonPollScNotifyCallback( - __in PVOID pParameter + _In_ PVOID pParameter ) { PSERVICE_NOTIFYW notifyBuffer = pParameter; @@ -797,7 +797,7 @@ VOID CALLBACK PhpServiceNonPollScNotifyCallback( } NTSTATUS PhpServiceNonPollThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { EVT_HANDLE subscriptionHandle; diff --git a/2.x/trunk/ProcessHacker/sysinfo.c b/2.x/trunk/ProcessHacker/sysinfo.c index 288a6ccf1..7e5c3c9da 100644 --- a/2.x/trunk/ProcessHacker/sysinfo.c +++ b/2.x/trunk/ProcessHacker/sysinfo.c @@ -2,7 +2,7 @@ * Process Hacker - * system information window * - * Copyright (C) 2011-2012 wj32 + * Copyright (C) 2011-2013 wj32 * * This file is part of Process Hacker. * @@ -144,7 +144,7 @@ static PH_UINT64_DELTA IoOtherDelta; static BOOLEAN AlwaysOnTop; VOID PhShowSystemInformationDialog( - __in_opt PWSTR SectionName + _In_opt_ PWSTR SectionName ) { if (!PhSipWindow) @@ -162,7 +162,7 @@ VOID PhShowSystemInformationDialog( } NTSTATUS PhSipSysInfoThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PH_AUTO_POOL autoPool; @@ -243,10 +243,10 @@ NTSTATUS PhSipSysInfoThreadStart( } INT_PTR CALLBACK PhSipSysInfoDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -320,10 +320,10 @@ INT_PTR CALLBACK PhSipSysInfoDialogProc( } INT_PTR CALLBACK PhSipContainerDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { return FALSE; @@ -407,8 +407,8 @@ VOID PhSipOnNcDestroy( } VOID PhSipOnShowWindow( - __in BOOLEAN Showing, - __in ULONG State + _In_ BOOLEAN Showing, + _In_ ULONG State ) { RECT buttonRect; @@ -542,8 +542,8 @@ VOID PhSipOnSize( } VOID PhSipOnSizing( - __in ULONG Edge, - __in PRECT DragRectangle + _In_ ULONG Edge, + _In_ PRECT DragRectangle ) { PhResizingMinimumSize(DragRectangle, Edge, MinimumSize.right, MinimumSize.bottom); @@ -557,8 +557,8 @@ VOID PhSipOnThemeChanged( } VOID PhSipOnCommand( - __in ULONG Id, - __in ULONG Code + _In_ ULONG Id, + _In_ ULONG Code ) { switch (Id) @@ -627,8 +627,8 @@ VOID PhSipOnCommand( } BOOLEAN PhSipOnNotify( - __in NMHDR *Header, - __out LRESULT *Result + _In_ NMHDR *Header, + _Out_ LRESULT *Result ) { switch (Header->code) @@ -734,8 +734,8 @@ BOOLEAN PhSipOnNotify( } BOOLEAN PhSipOnDrawItem( - __in ULONG_PTR Id, - __in DRAWITEMSTRUCT *DrawItemStruct + _In_ ULONG_PTR Id, + _In_ DRAWITEMSTRUCT *DrawItemStruct ) { ULONG i; @@ -767,9 +767,9 @@ BOOLEAN PhSipOnDrawItem( } VOID PhSipOnUserMessage( - __in ULONG Message, - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ ULONG Message, + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ) { switch (Message) @@ -847,9 +847,9 @@ VOID PhSiNotifyChangeSettings( } VOID PhSiSetColorsGraphDrawInfo( - __out PPH_GRAPH_DRAW_INFO DrawInfo, - __in COLORREF Color1, - __in COLORREF Color2 + _Out_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ COLORREF Color1, + _In_ COLORREF Color2 ) { switch (PhCsGraphColorMode) @@ -878,7 +878,7 @@ VOID PhSiSetColorsGraphDrawInfo( } VOID PhSipRegisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ) { if (!PhSipDialogList) @@ -888,7 +888,7 @@ VOID PhSipRegisterDialog( } VOID PhSipUnregisterDialog( - __in HWND DialogWindowHandle + _In_ HWND DialogWindowHandle ) { ULONG index; @@ -995,7 +995,7 @@ VOID PhSipUpdateColorParameters( } PPH_SYSINFO_SECTION PhSipCreateSection( - __in PPH_SYSINFO_SECTION Template + _In_ PPH_SYSINFO_SECTION Template ) { PPH_SYSINFO_SECTION section; @@ -1063,7 +1063,7 @@ PPH_SYSINFO_SECTION PhSipCreateSection( } VOID PhSipDestroySection( - __in PPH_SYSINFO_SECTION Section + _In_ PPH_SYSINFO_SECTION Section ) { Section->Callback(Section, SysInfoDestroy, NULL, NULL); @@ -1073,7 +1073,7 @@ VOID PhSipDestroySection( } PPH_SYSINFO_SECTION PhSipFindSection( - __in PPH_STRINGREF Name + _In_ PPH_STRINGREF Name ) { ULONG i; @@ -1091,9 +1091,9 @@ PPH_SYSINFO_SECTION PhSipFindSection( } PPH_SYSINFO_SECTION PhSipCreateInternalSection( - __in PWSTR Name, - __in ULONG Flags, - __in PPH_SYSINFO_SECTION_CALLBACK Callback + _In_ PWSTR Name, + _In_ ULONG Flags, + _In_ PPH_SYSINFO_SECTION_CALLBACK Callback ) { PH_SYSINFO_SECTION section; @@ -1107,8 +1107,8 @@ PPH_SYSINFO_SECTION PhSipCreateInternalSection( } VOID PhSipDrawRestoreSummaryPanel( - __in HDC hdc, - __in PRECT Rect + _In_ HDC hdc, + _In_ PRECT Rect ) { FillRect(hdc, Rect, GetSysColorBrush(COLOR_3DFACE)); @@ -1140,8 +1140,8 @@ VOID PhSipDrawRestoreSummaryPanel( } VOID PhSipDrawSeparator( - __in HDC hdc, - __in PRECT Rect + _In_ HDC hdc, + _In_ PRECT Rect ) { RECT rect; @@ -1153,9 +1153,9 @@ VOID PhSipDrawSeparator( } VOID PhSipDrawPanel( - __in PPH_SYSINFO_SECTION Section, - __in HDC hdc, - __in PRECT Rect + _In_ PPH_SYSINFO_SECTION Section, + _In_ HDC hdc, + _In_ PRECT Rect ) { PH_SYSINFO_DRAW_PANEL sysInfoDrawPanel; @@ -1186,8 +1186,8 @@ VOID PhSipDrawPanel( } VOID PhSipDefaultDrawPanel( - __in PPH_SYSINFO_SECTION Section, - __in PPH_SYSINFO_DRAW_PANEL DrawPanel + _In_ PPH_SYSINFO_SECTION Section, + _In_ PPH_SYSINFO_DRAW_PANEL DrawPanel ) { HDC hdc; @@ -1477,7 +1477,7 @@ VOID PhSipLayoutSectionView( } VOID PhSipEnterSectionView( - __in PPH_SYSINFO_SECTION NewSection + _In_ PPH_SYSINFO_SECTION NewSection ) { ULONG i; @@ -1563,10 +1563,10 @@ VOID PhSipRestoreSummaryView( } HWND PhSipDefaultCreateDialog( - __in PVOID Instance, - __in PWSTR Template, - __in DLGPROC DialogProc, - __in PVOID Parameter + _In_ PVOID Instance, + _In_ PWSTR Template, + _In_ DLGPROC DialogProc, + _In_ PVOID Parameter ) { HRSRC resourceInfo; @@ -1615,7 +1615,7 @@ HWND PhSipDefaultCreateDialog( } VOID PhSipCreateSectionDialog( - __in PPH_SYSINFO_SECTION Section + _In_ PPH_SYSINFO_SECTION Section ) { PH_SYSINFO_CREATE_DIALOG createDialog; @@ -1632,10 +1632,10 @@ VOID PhSipCreateSectionDialog( } LRESULT CALLBACK PhSipGraphHookWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { WNDPROC oldWndProc; @@ -1794,10 +1794,10 @@ LRESULT CALLBACK PhSipGraphHookWndProc( } LRESULT CALLBACK PhSipPanelHookWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { WNDPROC oldWndProc; @@ -1969,16 +1969,16 @@ VOID PhSipSetAlwaysOnTop( } VOID NTAPI PhSipSysInfoUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PostMessage(PhSipWindow, SI_MSG_SYSINFO_UPDATE, 0, 0); } PPH_STRING PhSipFormatSizeWithPrecision( - __in ULONG64 Size, - __in USHORT Precision + _In_ ULONG64 Size, + _In_ USHORT Precision ) { PH_FORMAT format; @@ -1991,10 +1991,10 @@ PPH_STRING PhSipFormatSizeWithPrecision( } BOOLEAN PhSipCpuSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ) { switch (Message) @@ -2194,10 +2194,10 @@ VOID PhSipTickCpuDialog( } INT_PTR CALLBACK PhSipCpuDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -2285,10 +2285,10 @@ INT_PTR CALLBACK PhSipCpuDialogProc( } INT_PTR CALLBACK PhSipCpuPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -2431,8 +2431,8 @@ VOID PhSipSetOneGraphPerCpu( } VOID PhSipNotifyCpuGraph( - __in ULONG Index, - __in NMHDR *Header + _In_ ULONG Index, + _In_ NMHDR *Header ) { switch (Header->code) @@ -2642,7 +2642,7 @@ VOID PhSipUpdateCpuPanel( } PPH_PROCESS_RECORD PhSipReferenceMaxCpuRecord( - __in LONG Index + _In_ LONG Index ) { LARGE_INTEGER time; @@ -2674,7 +2674,7 @@ PPH_PROCESS_RECORD PhSipReferenceMaxCpuRecord( } PPH_STRING PhSipGetMaxCpuString( - __in LONG Index + _In_ LONG Index ) { PPH_PROCESS_RECORD maxProcessRecord; @@ -2718,7 +2718,7 @@ PPH_STRING PhSipGetMaxCpuString( } VOID PhSipGetCpuBrandString( - __out_ecount(49) PWSTR BrandString + _Out_writes_(49) PWSTR BrandString ) { ULONG brandString[4 * 3]; @@ -2732,11 +2732,14 @@ VOID PhSipGetCpuBrandString( } BOOLEAN PhSipGetCpuFrequencyFromDistribution( - __out DOUBLE *Fraction + _Out_ DOUBLE *Fraction ) { - PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION differences; + ULONG stateSize; + PVOID differences; PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION stateDistribution; + PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION stateDifference; + PSYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8 hitcountOld; ULONG i; ULONG j; DOUBLE count; @@ -2747,11 +2750,13 @@ BOOLEAN PhSipGetCpuFrequencyFromDistribution( if (CurrentPerformanceDistribution->ProcessorCount != NumberOfProcessors || PreviousPerformanceDistribution->ProcessorCount != NumberOfProcessors) return FALSE; - differences = PhAllocate((FIELD_OFFSET(SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION, States) + sizeof(SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT) * 2) * NumberOfProcessors); + stateSize = FIELD_OFFSET(SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION, States) + sizeof(SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT) * 2; + differences = PhAllocate(stateSize * NumberOfProcessors); for (i = 0; i < NumberOfProcessors; i++) { stateDistribution = (PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION)((PCHAR)CurrentPerformanceDistribution + CurrentPerformanceDistribution->Offsets[i]); + stateDifference = (PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION)((PCHAR)differences + stateSize * i); if (stateDistribution->StateCount != 2) { @@ -2761,13 +2766,23 @@ BOOLEAN PhSipGetCpuFrequencyFromDistribution( for (j = 0; j < stateDistribution->StateCount; j++) { - differences[i].States[j] = stateDistribution->States[j]; + if (WindowsVersion >= WINDOWS_81) + { + stateDifference->States[j] = stateDistribution->States[j]; + } + else + { + hitcountOld = (PSYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8)((PCHAR)stateDistribution->States + sizeof(SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8) * j); + stateDifference->States[j].Hits.QuadPart = hitcountOld->Hits; + stateDifference->States[j].PercentFrequency = hitcountOld->PercentFrequency; + } } } for (i = 0; i < NumberOfProcessors; i++) { stateDistribution = (PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION)((PCHAR)PreviousPerformanceDistribution + PreviousPerformanceDistribution->Offsets[i]); + stateDifference = (PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION)((PCHAR)differences + stateSize * i); if (stateDistribution->StateCount != 2) { @@ -2777,7 +2792,15 @@ BOOLEAN PhSipGetCpuFrequencyFromDistribution( for (j = 0; j < stateDistribution->StateCount; j++) { - differences[i].States[j].Hits -= stateDistribution->States[j].Hits; + if (WindowsVersion >= WINDOWS_81) + { + stateDifference->States[j].Hits.QuadPart -= stateDistribution->States[j].Hits.QuadPart; + } + else + { + hitcountOld = (PSYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8)((PCHAR)stateDistribution->States + sizeof(SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8) * j); + stateDifference->States[j].Hits.QuadPart -= hitcountOld->Hits; + } } } @@ -2788,10 +2811,12 @@ BOOLEAN PhSipGetCpuFrequencyFromDistribution( for (i = 0; i < NumberOfProcessors; i++) { + stateDifference = (PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION)((PCHAR)differences + stateSize * i); + for (j = 0; j < 2; j++) { - count += differences[i].States[j].Hits; - total += differences[i].States[j].Hits * differences[i].States[j].PercentFrequency; + count += (ULONGLONG)stateDifference->States[j].Hits.QuadPart; + total += (ULONGLONG)stateDifference->States[j].Hits.QuadPart * stateDifference->States[j].PercentFrequency; } } @@ -2808,7 +2833,7 @@ BOOLEAN PhSipGetCpuFrequencyFromDistribution( } NTSTATUS PhSipQueryProcessorPerformanceDistribution( - __out PVOID *Buffer + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -2850,10 +2875,10 @@ NTSTATUS PhSipQueryProcessorPerformanceDistribution( } BOOLEAN PhSipMemorySectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ) { switch (Message) @@ -3064,10 +3089,10 @@ VOID PhSipTickMemoryDialog( } INT_PTR CALLBACK PhSipMemoryDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -3180,10 +3205,10 @@ INT_PTR CALLBACK PhSipMemoryDialogProc( } INT_PTR CALLBACK PhSipMemoryPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -3280,7 +3305,7 @@ VOID PhSipLayoutMemoryGraphs( } VOID PhSipNotifyCommitGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -3348,7 +3373,7 @@ VOID PhSipNotifyCommitGraph( } VOID PhSipNotifyPhysicalGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -3608,7 +3633,7 @@ VOID PhSipUpdateMemoryPanel( } NTSTATUS PhSipLoadMmAddresses( - __in PVOID Parameter + _In_ PVOID Parameter ) { PRTL_PROCESS_MODULES kernelModules; @@ -3664,8 +3689,8 @@ NTSTATUS PhSipLoadMmAddresses( } VOID PhSipGetPoolLimits( - __out PSIZE_T Paged, - __out PSIZE_T NonPaged + _Out_ PSIZE_T Paged, + _Out_ PSIZE_T NonPaged ) { SIZE_T paged = 0; @@ -3698,10 +3723,10 @@ VOID PhSipGetPoolLimits( } BOOLEAN PhSipIoSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ) { switch (Message) @@ -3859,10 +3884,10 @@ VOID PhSipTickIoDialog( } INT_PTR CALLBACK PhSipIoDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -3932,10 +3957,10 @@ INT_PTR CALLBACK PhSipIoDialogProc( } INT_PTR CALLBACK PhSipIoPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -3951,7 +3976,7 @@ INT_PTR CALLBACK PhSipIoPanelDialogProc( } VOID PhSipNotifyIoGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -4118,7 +4143,7 @@ VOID PhSipUpdateIoPanel( } PPH_PROCESS_RECORD PhSipReferenceMaxIoRecord( - __in LONG Index + _In_ LONG Index ) { LARGE_INTEGER time; @@ -4139,7 +4164,7 @@ PPH_PROCESS_RECORD PhSipReferenceMaxIoRecord( } PPH_STRING PhSipGetMaxIoString( - __in LONG Index + _In_ LONG Index ) { PPH_PROCESS_RECORD maxProcessRecord; diff --git a/2.x/trunk/ProcessHacker/termator.c b/2.x/trunk/ProcessHacker/termator.c index f449b5b85..7e57ff24f 100644 --- a/2.x/trunk/ProcessHacker/termator.c +++ b/2.x/trunk/ProcessHacker/termator.c @@ -27,7 +27,7 @@ #define TICK_INDEX 1 typedef NTSTATUS (NTAPI *PTEST_PROC)( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); typedef struct _TEST_ITEM @@ -38,15 +38,15 @@ typedef struct _TEST_ITEM } TEST_ITEM, *PTEST_ITEM; INT_PTR CALLBACK PhpProcessTerminatorDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowProcessTerminatorDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ) { NTSTATUS status; @@ -114,7 +114,7 @@ static PVOID GetExitProcessFunction( } static NTSTATUS NTAPI TerminatorTP1( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -136,7 +136,7 @@ static NTSTATUS NTAPI TerminatorTP1( } static NTSTATUS NTAPI TerminatorTP2( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -168,9 +168,9 @@ static NTSTATUS NTAPI TerminatorTP2( } static NTSTATUS NTAPI TerminatorTTGeneric( - __in HANDLE ProcessId, - __in BOOLEAN UseKph, - __in BOOLEAN UseKphDangerous + _In_ HANDLE ProcessId, + _In_ BOOLEAN UseKph, + _In_ BOOLEAN UseKphDangerous ) { NTSTATUS status; @@ -219,14 +219,14 @@ static NTSTATUS NTAPI TerminatorTTGeneric( } static NTSTATUS NTAPI TerminatorTT1( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { return TerminatorTTGeneric(ProcessId, FALSE, FALSE); } static NTSTATUS NTAPI TerminatorTT2( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -281,7 +281,7 @@ static NTSTATUS NTAPI TerminatorTT2( } static NTSTATUS NTAPI TerminatorTP1a( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -336,7 +336,7 @@ static NTSTATUS NTAPI TerminatorTP1a( } static NTSTATUS NTAPI TerminatorTT1a( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -398,7 +398,7 @@ static NTSTATUS NTAPI TerminatorTT1a( } static NTSTATUS NTAPI TerminatorCH1( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -432,8 +432,8 @@ static NTSTATUS NTAPI TerminatorCH1( } static BOOL CALLBACK DestroyProcessWindowsProc( - __in HWND hwnd, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ LPARAM lParam ) { ULONG processId; @@ -449,7 +449,7 @@ static BOOL CALLBACK DestroyProcessWindowsProc( } static NTSTATUS NTAPI TerminatorW1( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { EnumWindows(DestroyProcessWindowsProc, (LPARAM)ProcessId); @@ -457,8 +457,8 @@ static NTSTATUS NTAPI TerminatorW1( } static BOOL CALLBACK QuitProcessWindowsProc( - __in HWND hwnd, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ LPARAM lParam ) { ULONG processId; @@ -474,7 +474,7 @@ static BOOL CALLBACK QuitProcessWindowsProc( } static NTSTATUS NTAPI TerminatorW2( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { EnumWindows(QuitProcessWindowsProc, (LPARAM)ProcessId); @@ -482,8 +482,8 @@ static NTSTATUS NTAPI TerminatorW2( } static BOOL CALLBACK CloseProcessWindowsProc( - __in HWND hwnd, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ LPARAM lParam ) { ULONG processId; @@ -499,7 +499,7 @@ static BOOL CALLBACK CloseProcessWindowsProc( } static NTSTATUS NTAPI TerminatorW3( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { EnumWindows(CloseProcessWindowsProc, (LPARAM)ProcessId); @@ -507,7 +507,7 @@ static NTSTATUS NTAPI TerminatorW3( } static NTSTATUS NTAPI TerminatorTJ1( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -542,7 +542,7 @@ static NTSTATUS NTAPI TerminatorTJ1( } static NTSTATUS NTAPI TerminatorTD1( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -583,7 +583,7 @@ static NTSTATUS NTAPI TerminatorTD1( } static NTSTATUS NTAPI TerminatorTP3( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -607,21 +607,21 @@ static NTSTATUS NTAPI TerminatorTP3( } static NTSTATUS NTAPI TerminatorTT3( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { return TerminatorTTGeneric(ProcessId, TRUE, FALSE); } static NTSTATUS NTAPI TerminatorTT4( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { return TerminatorTTGeneric(ProcessId, FALSE, TRUE); } static NTSTATUS NTAPI TerminatorM1( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -702,7 +702,7 @@ static NTSTATUS NTAPI TerminatorM1( } static NTSTATUS NTAPI TerminatorM2( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { NTSTATUS status; @@ -770,8 +770,8 @@ TEST_ITEM PhTerminatorTests[] = }; static BOOLEAN PhpRunTerminatorTest( - __in HWND WindowHandle, - __in INT Index + _In_ HWND WindowHandle, + _In_ INT Index ) { NTSTATUS status; @@ -840,10 +840,10 @@ static BOOLEAN PhpRunTerminatorTest( } static INT_PTR CALLBACK PhpProcessTerminatorDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/ProcessHacker/thrdlist.c b/2.x/trunk/ProcessHacker/thrdlist.c index 7f4fdecad..8f73a7ae9 100644 --- a/2.x/trunk/ProcessHacker/thrdlist.c +++ b/2.x/trunk/ProcessHacker/thrdlist.c @@ -28,43 +28,43 @@ #include BOOLEAN PhpThreadNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG PhpThreadNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID PhpDestroyThreadNode( - __in PPH_THREAD_NODE ThreadNode + _In_ PPH_THREAD_NODE ThreadNode ); VOID PhpRemoveThreadNode( - __in PPH_THREAD_NODE ThreadNode, - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_NODE ThreadNode, + _In_ PPH_THREAD_LIST_CONTEXT Context ); LONG PhpThreadTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ); BOOLEAN NTAPI PhpThreadTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); VOID PhInitializeThreadList( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __in PPH_PROCESS_ITEM ProcessItem, - __out PPH_THREAD_LIST_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _In_ PPH_PROCESS_ITEM ProcessItem, + _Out_ PPH_THREAD_LIST_CONTEXT Context ) { HWND hwnd; @@ -105,7 +105,7 @@ VOID PhInitializeThreadList( } VOID PhDeleteThreadList( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ) { ULONG i; @@ -120,8 +120,8 @@ VOID PhDeleteThreadList( } BOOLEAN PhpThreadNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_THREAD_NODE threadNode1 = *(PPH_THREAD_NODE *)Entry1; @@ -131,14 +131,14 @@ BOOLEAN PhpThreadNodeHashtableCompareFunction( } ULONG PhpThreadNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { return (ULONG)(*(PPH_THREAD_NODE *)Entry)->ThreadId / 4; } VOID PhLoadSettingsThreadList( - __inout PPH_THREAD_LIST_CONTEXT Context + _Inout_ PPH_THREAD_LIST_CONTEXT Context ) { PPH_STRING settings; @@ -177,7 +177,7 @@ VOID PhLoadSettingsThreadList( } VOID PhSaveSettingsThreadList( - __inout PPH_THREAD_LIST_CONTEXT Context + _Inout_ PPH_THREAD_LIST_CONTEXT Context ) { PPH_STRING settings; @@ -191,9 +191,9 @@ VOID PhSaveSettingsThreadList( } PPH_THREAD_NODE PhAddThreadNode( - __inout PPH_THREAD_LIST_CONTEXT Context, - __in PPH_THREAD_ITEM ThreadItem, - __in ULONG RunId + _Inout_ PPH_THREAD_LIST_CONTEXT Context, + _In_ PPH_THREAD_ITEM ThreadItem, + _In_ ULONG RunId ) { PPH_THREAD_NODE threadNode; @@ -233,8 +233,8 @@ PPH_THREAD_NODE PhAddThreadNode( } PPH_THREAD_NODE PhFindThreadNode( - __in PPH_THREAD_LIST_CONTEXT Context, - __in HANDLE ThreadId + _In_ PPH_THREAD_LIST_CONTEXT Context, + _In_ HANDLE ThreadId ) { PH_THREAD_NODE lookupThreadNode; @@ -255,8 +255,8 @@ PPH_THREAD_NODE PhFindThreadNode( } VOID PhRemoveThreadNode( - __in PPH_THREAD_LIST_CONTEXT Context, - __in PPH_THREAD_NODE ThreadNode + _In_ PPH_THREAD_LIST_CONTEXT Context, + _In_ PPH_THREAD_NODE ThreadNode ) { // Remove from the hashtable here to avoid problems in case the key is re-used. @@ -280,7 +280,7 @@ VOID PhRemoveThreadNode( } VOID PhpDestroyThreadNode( - __in PPH_THREAD_NODE ThreadNode + _In_ PPH_THREAD_NODE ThreadNode ) { PhEmCallObjectOperation(EmThreadNodeType, ThreadNode, EmObjectDelete); @@ -295,8 +295,8 @@ VOID PhpDestroyThreadNode( } VOID PhpRemoveThreadNode( - __in PPH_THREAD_NODE ThreadNode, - __in PPH_THREAD_LIST_CONTEXT Context // PH_TICK_SH_STATE requires this parameter to be after ThreadNode + _In_ PPH_THREAD_NODE ThreadNode, + _In_ PPH_THREAD_LIST_CONTEXT Context // PH_TICK_SH_STATE requires this parameter to be after ThreadNode ) { ULONG index; @@ -312,8 +312,8 @@ VOID PhpRemoveThreadNode( } VOID PhUpdateThreadNode( - __in PPH_THREAD_LIST_CONTEXT Context, - __in PPH_THREAD_NODE ThreadNode + _In_ PPH_THREAD_LIST_CONTEXT Context, + _In_ PPH_THREAD_NODE ThreadNode ) { memset(ThreadNode->TextCache, 0, sizeof(PH_STRINGREF) * PHTHTLC_MAXIMUM); @@ -324,7 +324,7 @@ VOID PhUpdateThreadNode( } VOID PhTickThreadNodes( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ) { PH_TICK_SH_STATE_TN(PH_THREAD_NODE, ShState, Context->NodeStateList, PhpRemoveThreadNode, PhCsHighlightingDuration, Context->TreeNewHandle, TRUE, NULL, Context); @@ -333,9 +333,9 @@ VOID PhTickThreadNodes( #define SORT_FUNCTION(Column) PhpThreadTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl PhpThreadTreeNewCompare##Column( \ - __in void *_context, \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ void *_context, \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PPH_THREAD_NODE node1 = *(PPH_THREAD_NODE *)_elem1; \ @@ -353,10 +353,10 @@ VOID PhTickThreadNodes( } LONG PhpThreadTreeNewPostSortFunction( - __in LONG Result, - __in PVOID Node1, - __in PVOID Node2, - __in PH_SORT_ORDER SortOrder + _In_ LONG Result, + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ PH_SORT_ORDER SortOrder ) { if (Result == 0) @@ -413,11 +413,11 @@ BEGIN_SORT_FUNCTION(Service) END_SORT_FUNCTION BOOLEAN NTAPI PhpThreadTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PPH_THREAD_LIST_CONTEXT context; @@ -668,7 +668,7 @@ BOOLEAN NTAPI PhpThreadTreeNewCallback( } PPH_THREAD_ITEM PhGetSelectedThreadItem( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ) { PPH_THREAD_ITEM threadItem = NULL; @@ -689,9 +689,9 @@ PPH_THREAD_ITEM PhGetSelectedThreadItem( } VOID PhGetSelectedThreadItems( - __in PPH_THREAD_LIST_CONTEXT Context, - __out PPH_THREAD_ITEM **Threads, - __out PULONG NumberOfThreads + _In_ PPH_THREAD_LIST_CONTEXT Context, + _Out_ PPH_THREAD_ITEM **Threads, + _Out_ PULONG NumberOfThreads ) { PPH_LIST list; @@ -716,7 +716,7 @@ VOID PhGetSelectedThreadItems( } VOID PhDeselectAllThreadNodes( - __in PPH_THREAD_LIST_CONTEXT Context + _In_ PPH_THREAD_LIST_CONTEXT Context ) { TreeNew_DeselectRange(Context->TreeNewHandle, 0, -1); diff --git a/2.x/trunk/ProcessHacker/thrdprv.c b/2.x/trunk/ProcessHacker/thrdprv.c index c39208a15..e0b7729db 100644 --- a/2.x/trunk/ProcessHacker/thrdprv.c +++ b/2.x/trunk/ProcessHacker/thrdprv.c @@ -52,36 +52,36 @@ typedef struct _PH_THREAD_SYMBOL_LOAD_CONTEXT } PH_THREAD_SYMBOL_LOAD_CONTEXT, *PPH_THREAD_SYMBOL_LOAD_CONTEXT; VOID NTAPI PhpThreadProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); NTSTATUS PhpThreadProviderLoadSymbols( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID NTAPI PhpThreadItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); BOOLEAN NTAPI PhpThreadHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI PhpThreadHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID PhpThreadProviderCallbackHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID PhpThreadProviderUpdate( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in PVOID ProcessInformation + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ PVOID ProcessInformation ); PPH_OBJECT_TYPE PhThreadProviderType; @@ -114,8 +114,8 @@ BOOLEAN PhThreadProviderInitialization( } VOID PhpQueueThreadWorkQueueItem( - __in PTHREAD_START_ROUTINE Function, - __in_opt PVOID Context + _In_ PTHREAD_START_ROUTINE Function, + _In_opt_ PVOID Context ) { if (PhBeginInitOnce(&PhThreadProviderWorkQueueInitOnce)) @@ -128,7 +128,7 @@ VOID PhpQueueThreadWorkQueueItem( } PPH_THREAD_PROVIDER PhCreateThreadProvider( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { PPH_THREAD_PROVIDER threadProvider; @@ -178,8 +178,8 @@ PPH_THREAD_PROVIDER PhCreateThreadProvider( } VOID PhpThreadProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_THREAD_PROVIDER threadProvider = (PPH_THREAD_PROVIDER)Object; @@ -221,8 +221,8 @@ VOID PhpThreadProviderDeleteProcedure( } VOID PhRegisterThreadProvider( - __in PPH_THREAD_PROVIDER ThreadProvider, - __out PPH_CALLBACK_REGISTRATION CallbackRegistration + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _Out_ PPH_CALLBACK_REGISTRATION CallbackRegistration ) { PhReferenceObject(ThreadProvider); @@ -230,8 +230,8 @@ VOID PhRegisterThreadProvider( } VOID PhUnregisterThreadProvider( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in PPH_CALLBACK_REGISTRATION CallbackRegistration + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ PPH_CALLBACK_REGISTRATION CallbackRegistration ) { PhUnregisterCallback(&PhProcessesUpdatedEvent, CallbackRegistration); @@ -239,8 +239,8 @@ VOID PhUnregisterThreadProvider( } static BOOLEAN LoadSymbolsEnumGenericModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PPH_THREAD_SYMBOL_LOAD_CONTEXT context = Context; @@ -267,8 +267,8 @@ static BOOLEAN LoadSymbolsEnumGenericModulesCallback( } static BOOLEAN LoadBasicSymbolsEnumGenericModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PPH_THREAD_SYMBOL_LOAD_CONTEXT context = Context; @@ -291,7 +291,7 @@ static BOOLEAN LoadBasicSymbolsEnumGenericModulesCallback( } NTSTATUS PhpThreadProviderLoadSymbols( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_THREAD_PROVIDER threadProvider = (PPH_THREAD_PROVIDER)Parameter; @@ -398,7 +398,7 @@ NTSTATUS PhpThreadProviderLoadSymbols( } PPH_THREAD_ITEM PhCreateThreadItem( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ) { PPH_THREAD_ITEM threadItem; @@ -421,8 +421,8 @@ PPH_THREAD_ITEM PhCreateThreadItem( } VOID PhpThreadItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_THREAD_ITEM threadItem = (PPH_THREAD_ITEM)Object; @@ -436,8 +436,8 @@ VOID PhpThreadItemDeleteProcedure( } BOOLEAN PhpThreadHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { return @@ -446,15 +446,15 @@ BOOLEAN PhpThreadHashtableCompareFunction( } ULONG PhpThreadHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { return (ULONG)(*(PPH_THREAD_ITEM *)Entry)->ThreadId / 4; } PPH_THREAD_ITEM PhReferenceThreadItem( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in HANDLE ThreadId + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ HANDLE ThreadId ) { PH_THREAD_ITEM lookupThreadItem; @@ -487,7 +487,7 @@ PPH_THREAD_ITEM PhReferenceThreadItem( } VOID PhDereferenceAllThreadItems( - __in PPH_THREAD_PROVIDER ThreadProvider + _In_ PPH_THREAD_PROVIDER ThreadProvider ) { ULONG enumerationKey = 0; @@ -503,9 +503,9 @@ VOID PhDereferenceAllThreadItems( PhReleaseFastLockExclusive(&ThreadProvider->ThreadHashtableLock); } -__assumeLocked VOID PhpRemoveThreadItem( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in PPH_THREAD_ITEM ThreadItem +VOID PhpRemoveThreadItem( + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ PPH_THREAD_ITEM ThreadItem ) { PhRemoveEntryHashtable(ThreadProvider->ThreadHashtable, &ThreadItem); @@ -513,7 +513,7 @@ __assumeLocked VOID PhpRemoveThreadItem( } NTSTATUS PhpThreadQueryWorker( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_THREAD_QUERY_DATA data = (PPH_THREAD_QUERY_DATA)Parameter; @@ -572,8 +572,8 @@ NTSTATUS PhpThreadQueryWorker( } VOID PhpQueueThreadQuery( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in PPH_THREAD_ITEM ThreadItem + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ PPH_THREAD_ITEM ThreadItem ) { PPH_THREAD_QUERY_DATA data; @@ -589,9 +589,9 @@ VOID PhpQueueThreadQuery( } PPH_STRING PhpGetThreadBasicStartAddress( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in ULONG64 Address, - __out PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ ULONG64 Address, + _Out_ PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel ) { ULONG64 modBase; @@ -636,9 +636,9 @@ PPH_STRING PhpGetThreadBasicStartAddress( } static NTSTATUS PhpGetThreadCycleTime( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in PPH_THREAD_ITEM ThreadItem, - __out PULONG64 CycleTime + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ PPH_THREAD_ITEM ThreadItem, + _Out_ PULONG64 CycleTime ) { if (ThreadProvider->ProcessId != SYSTEM_IDLE_PROCESS_ID) @@ -658,7 +658,7 @@ static NTSTATUS PhpGetThreadCycleTime( } PPH_STRING PhGetThreadPriorityWin32String( - __in LONG PriorityWin32 + _In_ LONG PriorityWin32 ) { switch (PriorityWin32) @@ -685,7 +685,7 @@ PPH_STRING PhGetThreadPriorityWin32String( } VOID PhThreadProviderInitialUpdate( - __in PPH_THREAD_PROVIDER ThreadProvider + _In_ PPH_THREAD_PROVIDER ThreadProvider ) { PVOID processes; @@ -698,8 +698,8 @@ VOID PhThreadProviderInitialUpdate( } VOID PhpThreadProviderCallbackHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { if (PhProcessInformation) @@ -709,8 +709,8 @@ VOID PhpThreadProviderCallbackHandler( } VOID PhpThreadProviderUpdate( - __in PPH_THREAD_PROVIDER ThreadProvider, - __in PVOID ProcessInformation + _In_ PPH_THREAD_PROVIDER ThreadProvider, + _In_ PVOID ProcessInformation ) { PPH_THREAD_PROVIDER threadProvider = ThreadProvider; @@ -940,6 +940,12 @@ VOID PhpThreadProviderUpdate( threadItem->IsGuiThread = win32Thread != NULL; } } + else + { + GUITHREADINFO info = { sizeof(GUITHREADINFO) }; + + threadItem->IsGuiThread = !!GetGUIThreadInfo((ULONG)threadItem->ThreadId, &info); + } // Add the thread item to the hashtable. PhAcquireFastLockExclusive(&threadProvider->ThreadHashtableLock); @@ -1098,6 +1104,16 @@ VOID PhpThreadProviderUpdate( modified = TRUE; } } + else + { + GUITHREADINFO info = { sizeof(GUITHREADINFO) }; + BOOLEAN oldIsGuiThread = threadItem->IsGuiThread; + + threadItem->IsGuiThread = !!GetGUIThreadInfo((ULONG)threadItem->ThreadId, &info); + + if (threadItem->IsGuiThread != oldIsGuiThread) + modified = TRUE; + } threadItem->JustResolved = FALSE; diff --git a/2.x/trunk/ProcessHacker/thrdstk.c b/2.x/trunk/ProcessHacker/thrdstk.c index 84abfaa69..54c1bd192 100644 --- a/2.x/trunk/ProcessHacker/thrdstk.c +++ b/2.x/trunk/ProcessHacker/thrdstk.c @@ -25,7 +25,10 @@ #include #include -typedef struct THREAD_STACK_CONTEXT +#define WM_PH_COMPLETED (WM_APP + 301) +#define WM_PH_STATUS_UPDATE (WM_APP + 302) + +typedef struct _THREAD_STACK_CONTEXT { HANDLE ProcessId; HANDLE ThreadId; @@ -34,28 +37,52 @@ typedef struct THREAD_STACK_CONTEXT PPH_SYMBOL_PROVIDER SymbolProvider; BOOLEAN CustomWalk; - ULONG Index; + BOOLEAN StopWalk; PPH_LIST List; + PPH_LIST NewList; + HWND ProgressWindowHandle; + NTSTATUS WalkStatus; + PPH_STRING StatusMessage; + PH_QUEUED_LOCK StatusLock; } THREAD_STACK_CONTEXT, *PTHREAD_STACK_CONTEXT; +typedef struct _THREAD_STACK_ITEM +{ + PH_THREAD_STACK_FRAME StackFrame; + ULONG Index; + PPH_STRING Symbol; +} THREAD_STACK_ITEM, *PTHREAD_STACK_ITEM; + INT_PTR CALLBACK PhpThreadStackDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam + ); + +VOID PhpFreeThreadStackItem( + _In_ PTHREAD_STACK_ITEM StackItem ); NTSTATUS PhpRefreshThreadStack( - __in PTHREAD_STACK_CONTEXT ThreadStackContext + _In_ HWND hwnd, + _In_ PTHREAD_STACK_CONTEXT ThreadStackContext + ); + +INT_PTR CALLBACK PhpThreadStackProgressDlgProc( + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static RECT MinimumSize = { -1, -1, -1, -1 }; VOID PhShowThreadStackDialog( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId, - __in HANDLE ThreadId, - __in PPH_SYMBOL_PROVIDER SymbolProvider + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId, + _In_ HANDLE ThreadId, + _In_ PPH_SYMBOL_PROVIDER SymbolProvider ) { NTSTATUS status; @@ -70,10 +97,10 @@ VOID PhShowThreadStackDialog( return; } + memset(&threadStackContext, 0, sizeof(THREAD_STACK_CONTEXT)); threadStackContext.ProcessId = ProcessId; threadStackContext.ThreadId = ThreadId; threadStackContext.SymbolProvider = SymbolProvider; - threadStackContext.CustomWalk = FALSE; if (!NT_SUCCESS(status = PhOpenThread( &threadHandle, @@ -99,6 +126,8 @@ VOID PhShowThreadStackDialog( threadStackContext.ThreadHandle = threadHandle; threadStackContext.List = PhCreateList(10); + threadStackContext.NewList = PhCreateList(10); + PhInitializeQueuedLock(&threadStackContext.StatusLock); DialogBoxParam( PhInstanceHandle, @@ -108,6 +137,8 @@ VOID PhShowThreadStackDialog( (LPARAM)&threadStackContext ); + PhSwapReference(&threadStackContext.StatusMessage, NULL); + PhDereferenceObject(threadStackContext.NewList); PhDereferenceObject(threadStackContext.List); if (threadStackContext.ThreadHandle) @@ -115,16 +146,17 @@ VOID PhShowThreadStackDialog( } static INT_PTR CALLBACK PhpThreadStackDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) { case WM_INITDIALOG: { + NTSTATUS status; PTHREAD_STACK_CONTEXT threadStackContext; PPH_STRING title; HWND lvHandle; @@ -191,7 +223,12 @@ static INT_PTR CALLBACK PhpThreadStackDlgProc( threadStackContext->CustomWalk = control.u.Initializing.CustomWalk; } - PhpRefreshThreadStack(threadStackContext); + status = PhpRefreshThreadStack(hwndDlg, threadStackContext); + + if (status == STATUS_ABANDONED) + EndDialog(hwndDlg, IDCANCEL); + else if (!NT_SUCCESS(status)) + PhShowStatus(hwndDlg, L"Unable to load the stack", status, 0); } break; case WM_DESTROY: @@ -216,7 +253,7 @@ static INT_PTR CALLBACK PhpThreadStackDlgProc( } for (i = 0; i < threadStackContext->List->Count; i++) - PhFree(threadStackContext->List->Items[i]); + PhpFreeThreadStackItem(threadStackContext->List->Items[i]); PhSaveListViewColumnsToSetting(L"ThreadStackListViewColumns", GetDlgItem(hwndDlg, IDC_LIST)); PhSaveWindowPlacementToSetting(NULL, L"ThreadStackWindowSize", hwndDlg); @@ -237,9 +274,15 @@ static INT_PTR CALLBACK PhpThreadStackDlgProc( break; case IDC_REFRESH: { - PhpRefreshThreadStack( + NTSTATUS status; + + if (!NT_SUCCESS(status = PhpRefreshThreadStack( + hwndDlg, (PTHREAD_STACK_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom()) - ); + ))) + { + PhShowStatus(hwndDlg, L"Unable to load the stack", status, 0); + } } break; case IDC_COPY: @@ -275,14 +318,16 @@ static INT_PTR CALLBACK PhpThreadStackDlgProc( if (header->hwndFrom == lvHandle) { + PTHREAD_STACK_ITEM stackItem; PPH_THREAD_STACK_FRAME stackFrame; - if (PhGetListViewItemParam(lvHandle, getInfoTip->iItem, &stackFrame)) + if (PhGetListViewItemParam(lvHandle, getInfoTip->iItem, &stackItem)) { PH_STRING_BUILDER stringBuilder; PPH_STRING fileName; PH_SYMBOL_LINE_INFORMATION lineInfo; + stackFrame = &stackItem->StackFrame; PhInitializeStringBuilder(&stringBuilder, 40); // There are no params for kernel-mode stack traces. @@ -356,16 +401,89 @@ static INT_PTR CALLBACK PhpThreadStackDlgProc( return FALSE; } +static VOID PhpFreeThreadStackItem( + _In_ PTHREAD_STACK_ITEM StackItem + ) +{ + PhSwapReference(&StackItem->Symbol, NULL); + PhFree(StackItem); +} + +static NTSTATUS PhpRefreshThreadStack( + _In_ HWND hwnd, + _In_ PTHREAD_STACK_CONTEXT ThreadStackContext + ) +{ + ULONG i; + + ThreadStackContext->StopWalk = FALSE; + PhSwapReference2(&ThreadStackContext->StatusMessage, PhCreateString(L"Loading stack...")); + + DialogBoxParam( + PhInstanceHandle, + MAKEINTRESOURCE(IDD_PROGRESS), + hwnd, + PhpThreadStackProgressDlgProc, + (LPARAM)ThreadStackContext + ); + + if (!ThreadStackContext->StopWalk && NT_SUCCESS(ThreadStackContext->WalkStatus)) + { + for (i = 0; i < ThreadStackContext->List->Count; i++) + PhpFreeThreadStackItem(ThreadStackContext->List->Items[i]); + + PhDereferenceObject(ThreadStackContext->List); + ThreadStackContext->List = ThreadStackContext->NewList; + ThreadStackContext->NewList = PhCreateList(10); + + ListView_DeleteAllItems(ThreadStackContext->ListViewHandle); + SendMessage(ThreadStackContext->ListViewHandle, WM_SETREDRAW, FALSE, 0); + + for (i = 0; i < ThreadStackContext->List->Count; i++) + { + PTHREAD_STACK_ITEM item = ThreadStackContext->List->Items[i]; + INT lvItemIndex; + WCHAR integerString[PH_INT32_STR_LEN_1]; + + PhPrintUInt32(integerString, item->Index); + lvItemIndex = PhAddListViewItem(ThreadStackContext->ListViewHandle, MAXINT, integerString, item); + PhSetListViewSubItem(ThreadStackContext->ListViewHandle, lvItemIndex, 1, PhGetStringOrDefault(item->Symbol, L"???")); + } + + SendMessage(ThreadStackContext->ListViewHandle, WM_SETREDRAW, TRUE, 0); + InvalidateRect(ThreadStackContext->ListViewHandle, NULL, FALSE); + } + else + { + for (i = 0; i < ThreadStackContext->NewList->Count; i++) + PhpFreeThreadStackItem(ThreadStackContext->NewList->Items[i]); + + PhClearList(ThreadStackContext->NewList); + } + + if (ThreadStackContext->StopWalk) + return STATUS_ABANDONED; + + return ThreadStackContext->WalkStatus; +} + static BOOLEAN NTAPI PhpWalkThreadStackCallback( - __in PPH_THREAD_STACK_FRAME StackFrame, - __in_opt PVOID Context + _In_ PPH_THREAD_STACK_FRAME StackFrame, + _In_opt_ PVOID Context ) { PTHREAD_STACK_CONTEXT threadStackContext = (PTHREAD_STACK_CONTEXT)Context; PPH_STRING symbol; - INT lvItemIndex; - WCHAR integerString[PH_INT32_STR_LEN_1]; - PPH_THREAD_STACK_FRAME stackFrame; + PTHREAD_STACK_ITEM item; + + if (threadStackContext->StopWalk) + return FALSE; + + PhAcquireQueuedLockExclusive(&threadStackContext->StatusLock); + PhSwapReference2(&threadStackContext->StatusMessage, + PhFormatString(L"Processing frame %u...", threadStackContext->NewList->Count)); + PhReleaseQueuedLockExclusive(&threadStackContext->StatusLock); + PostMessage(threadStackContext->ProgressWindowHandle, WM_PH_STATUS_UPDATE, 0, 0); symbol = PhGetSymbolFromAddress( threadStackContext->SymbolProvider, @@ -376,12 +494,9 @@ static BOOLEAN NTAPI PhpWalkThreadStackCallback( NULL ); - PhPrintUInt32(integerString, threadStackContext->Index++); - - stackFrame = PhAllocateCopy(StackFrame, sizeof(PH_THREAD_STACK_FRAME)); - PhAddItemList(threadStackContext->List, stackFrame); - lvItemIndex = PhAddListViewItem(threadStackContext->ListViewHandle, MAXINT, - integerString, stackFrame); + item = PhAllocate(sizeof(THREAD_STACK_ITEM)); + item->StackFrame = *StackFrame; + item->Index = threadStackContext->NewList->Count; if (PhPluginsEnabled) { @@ -396,57 +511,38 @@ static BOOLEAN NTAPI PhpWalkThreadStackCallback( symbol = control.u.ResolveSymbol.Symbol; } - if (symbol) - { - PhSetListViewSubItem(threadStackContext->ListViewHandle, lvItemIndex, 1, - symbol->Buffer); - PhDereferenceObject(symbol); - } - else - { - PhSetListViewSubItem(threadStackContext->ListViewHandle, lvItemIndex, 1, - L"???"); - } + item->Symbol = symbol; + PhAddItemList(threadStackContext->NewList, item); return TRUE; } -static NTSTATUS PhpRefreshThreadStack( - __in PTHREAD_STACK_CONTEXT ThreadStackContext +static NTSTATUS PhpRefreshThreadStackThreadStart( + _In_ PVOID Parameter ) { NTSTATUS status; - ULONG i; + PTHREAD_STACK_CONTEXT threadStackContext = Parameter; CLIENT_ID clientId; BOOLEAN defaultWalk; - clientId.UniqueProcess = ThreadStackContext->ProcessId; - clientId.UniqueThread = ThreadStackContext->ThreadId; - - ListView_DeleteAllItems(ThreadStackContext->ListViewHandle); - - for (i = 0; i < ThreadStackContext->List->Count; i++) - PhFree(ThreadStackContext->List->Items[i]); - - PhClearList(ThreadStackContext->List); - - SendMessage(ThreadStackContext->ListViewHandle, WM_SETREDRAW, FALSE, 0); - ThreadStackContext->Index = 0; + clientId.UniqueProcess = threadStackContext->ProcessId; + clientId.UniqueThread = threadStackContext->ThreadId; defaultWalk = TRUE; - if (ThreadStackContext->CustomWalk) + if (threadStackContext->CustomWalk) { PH_PLUGIN_THREAD_STACK_CONTROL control; control.Type = PluginThreadStackWalkStack; - control.UniqueKey = ThreadStackContext; + control.UniqueKey = threadStackContext; control.u.WalkStack.Status = STATUS_UNSUCCESSFUL; - control.u.WalkStack.ThreadHandle = ThreadStackContext->ThreadHandle; - control.u.WalkStack.ProcessHandle = ThreadStackContext->SymbolProvider->ProcessHandle; + control.u.WalkStack.ThreadHandle = threadStackContext->ThreadHandle; + control.u.WalkStack.ProcessHandle = threadStackContext->SymbolProvider->ProcessHandle; control.u.WalkStack.ClientId = &clientId; control.u.WalkStack.Flags = PH_WALK_I386_STACK | PH_WALK_AMD64_STACK | PH_WALK_KERNEL_STACK; control.u.WalkStack.Callback = PhpWalkThreadStackCallback; - control.u.WalkStack.CallbackContext = ThreadStackContext; + control.u.WalkStack.CallbackContext = threadStackContext; PhInvokeCallback(PhGetGeneralCallback(GeneralCallbackThreadStackControl), &control); status = control.u.WalkStack.Status; @@ -457,17 +553,100 @@ static NTSTATUS PhpRefreshThreadStack( if (defaultWalk) { status = PhWalkThreadStack( - ThreadStackContext->ThreadHandle, - ThreadStackContext->SymbolProvider->ProcessHandle, + threadStackContext->ThreadHandle, + threadStackContext->SymbolProvider->ProcessHandle, &clientId, PH_WALK_I386_STACK | PH_WALK_AMD64_STACK | PH_WALK_KERNEL_STACK, PhpWalkThreadStackCallback, - ThreadStackContext + threadStackContext ); } - SendMessage(ThreadStackContext->ListViewHandle, WM_SETREDRAW, TRUE, 0); - InvalidateRect(ThreadStackContext->ListViewHandle, NULL, FALSE); + if (threadStackContext->NewList->Count != 0) + status = STATUS_SUCCESS; + + threadStackContext->WalkStatus = status; + PostMessage(threadStackContext->ProgressWindowHandle, WM_PH_COMPLETED, 0, 0); + + return STATUS_SUCCESS; +} + +static INT_PTR CALLBACK PhpThreadStackProgressDlgProc( + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam + ) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + PTHREAD_STACK_CONTEXT threadStackContext; + HANDLE threadHandle; + + threadStackContext = (PTHREAD_STACK_CONTEXT)lParam; + SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)threadStackContext); + threadStackContext->ProgressWindowHandle = hwndDlg; + + if (threadHandle = PhCreateThread(0, PhpRefreshThreadStackThreadStart, threadStackContext)) + { + NtClose(threadHandle); + } + else + { + threadStackContext->WalkStatus = STATUS_UNSUCCESSFUL; + EndDialog(hwndDlg, IDOK); + break; + } + + PhCenterWindow(hwndDlg, GetParent(hwndDlg)); + + PhSetWindowStyle(GetDlgItem(hwndDlg, IDC_PROGRESS), PBS_MARQUEE, PBS_MARQUEE); + SendMessage(GetDlgItem(hwndDlg, IDC_PROGRESS), PBM_SETMARQUEE, TRUE, 75); + SetWindowText(hwndDlg, L"Loading stack..."); + } + break; + case WM_DESTROY: + { + RemoveProp(hwndDlg, PhMakeContextAtom()); + } + break; + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDCANCEL: + { + PTHREAD_STACK_CONTEXT threadStackContext = (PTHREAD_STACK_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom()); + + EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE); + threadStackContext->StopWalk = TRUE; + } + break; + } + } + break; + case WM_PH_COMPLETED: + { + EndDialog(hwndDlg, IDOK); + } + break; + case WM_PH_STATUS_UPDATE: + { + PTHREAD_STACK_CONTEXT threadStackContext = (PTHREAD_STACK_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom()); + PPH_STRING message; + + PhAcquireQueuedLockExclusive(&threadStackContext->StatusLock); + message = threadStackContext->StatusMessage; + PhReferenceObject(message); + PhReleaseQueuedLockExclusive(&threadStackContext->StatusLock); + + SetDlgItemText(hwndDlg, IDC_PROGRESSTEXT, message->Buffer); + PhDereferenceObject(message); + } + break; + } - return status; + return 0; } diff --git a/2.x/trunk/ProcessHacker/tokprp.c b/2.x/trunk/ProcessHacker/tokprp.c index 24c8de269..d395b66ae 100644 --- a/2.x/trunk/ProcessHacker/tokprp.c +++ b/2.x/trunk/ProcessHacker/tokprp.c @@ -55,71 +55,71 @@ typedef struct _TOKEN_PAGE_CONTEXT } TOKEN_PAGE_CONTEXT, *PTOKEN_PAGE_CONTEXT; INT CALLBACK PhpTokenPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ); INT_PTR CALLBACK PhpTokenPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhpShowTokenAdvancedProperties( - __in HWND ParentWindowHandle, - __in PTOKEN_PAGE_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ PTOKEN_PAGE_CONTEXT Context ); INT_PTR CALLBACK PhpTokenGeneralPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpTokenAdvancedPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpTokenCapabilitiesPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); BOOLEAN NTAPI PhpAttributeTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); INT_PTR CALLBACK PhpTokenClaimsPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PhpTokenAttributesPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhShowTokenProperties( - __in HWND ParentWindowHandle, - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt PWSTR Title + _In_ HWND ParentWindowHandle, + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ PWSTR Title ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -141,9 +141,9 @@ VOID PhShowTokenProperties( } HPROPSHEETPAGE PhCreateTokenPage( - __in PPH_OPEN_OBJECT OpenObject, - __in_opt PVOID Context, - __in_opt DLGPROC HookProc + _In_ PPH_OPEN_OBJECT OpenObject, + _In_opt_ PVOID Context, + _In_opt_ DLGPROC HookProc ) { HPROPSHEETPAGE propSheetPageHandle; @@ -175,9 +175,9 @@ HPROPSHEETPAGE PhCreateTokenPage( } INT CALLBACK PhpTokenPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ) { PTOKEN_PAGE_CONTEXT tokenPageContext; @@ -197,7 +197,7 @@ INT CALLBACK PhpTokenPropPageProc( } PPH_STRING PhGetGroupAttributesString( - __in ULONG Attributes + _In_ ULONG Attributes ) { PWSTR baseString; @@ -245,7 +245,7 @@ PPH_STRING PhGetGroupAttributesString( } COLORREF PhGetGroupAttributesColor( - __in ULONG Attributes + _In_ ULONG Attributes ) { if (Attributes & SE_GROUP_INTEGRITY) @@ -265,9 +265,9 @@ COLORREF PhGetGroupAttributesColor( } static COLORREF NTAPI PhpTokenGroupColorFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ) { PSID_AND_ATTRIBUTES sidAndAttributes = Param; @@ -276,7 +276,7 @@ static COLORREF NTAPI PhpTokenGroupColorFunction( } PWSTR PhGetPrivilegeAttributesString( - __in ULONG Attributes + _In_ ULONG Attributes ) { if (Attributes & SE_PRIVILEGE_ENABLED_BY_DEFAULT) @@ -288,7 +288,7 @@ PWSTR PhGetPrivilegeAttributesString( } COLORREF PhGetPrivilegeAttributesColor( - __in ULONG Attributes + _In_ ULONG Attributes ) { if (Attributes & SE_PRIVILEGE_ENABLED_BY_DEFAULT) @@ -300,9 +300,9 @@ COLORREF PhGetPrivilegeAttributesColor( } static COLORREF NTAPI PhpTokenPrivilegeColorFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ) { PLUID_AND_ATTRIBUTES luidAndAttributes = Param; @@ -311,7 +311,7 @@ static COLORREF NTAPI PhpTokenPrivilegeColorFunction( } PWSTR PhGetElevationTypeString( - __in TOKEN_ELEVATION_TYPE ElevationType + _In_ TOKEN_ELEVATION_TYPE ElevationType ) { switch (ElevationType) @@ -326,7 +326,7 @@ PWSTR PhGetElevationTypeString( } PWSTR PhGetBuiltinCapabilityString( - __in PSID CapabilitySid + _In_ PSID CapabilitySid ) { static SID_IDENTIFIER_AUTHORITY appPackageAuthority = SECURITY_APP_PACKAGE_AUTHORITY; @@ -364,10 +364,10 @@ PWSTR PhGetBuiltinCapabilityString( } BOOLEAN PhpUpdateTokenGroups( - __in HWND hwndDlg, - __in PTOKEN_PAGE_CONTEXT TokenPageContext, - __in HWND GroupsLv, - __in HANDLE TokenHandle + _In_ HWND hwndDlg, + _In_ PTOKEN_PAGE_CONTEXT TokenPageContext, + _In_ HWND GroupsLv, + _In_ HANDLE TokenHandle ) { PTOKEN_GROUPS groups; @@ -413,10 +413,10 @@ BOOLEAN PhpUpdateTokenGroups( } FORCEINLINE PTOKEN_PAGE_CONTEXT PhpTokenPageHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { return (PTOKEN_PAGE_CONTEXT)PhpGenericPropertyPageHeader( @@ -424,10 +424,10 @@ FORCEINLINE PTOKEN_PAGE_CONTEXT PhpTokenPageHeader( } INT_PTR CALLBACK PhpTokenPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PTOKEN_PAGE_CONTEXT tokenPageContext; @@ -760,8 +760,8 @@ INT_PTR CALLBACK PhpTokenPageProc( if (!PhShowContinueStatus( hwndDlg, PhaFormatString(L"Unable to %s %s", action, privilegeName->Buffer)->Buffer, - 0, - GetLastError() + STATUS_UNSUCCESSFUL, + 0 )) break; } @@ -967,8 +967,8 @@ INT_PTR CALLBACK PhpTokenPageProc( } VOID PhpShowTokenAdvancedProperties( - __in HWND ParentWindowHandle, - __in PTOKEN_PAGE_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ PTOKEN_PAGE_CONTEXT Context ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -1066,19 +1066,19 @@ VOID PhpShowTokenAdvancedProperties( } static NTSTATUS PhpOpenLinkedToken( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ) { return PhGetTokenLinkedToken((HANDLE)Context, Handle); } INT_PTR CALLBACK PhpTokenGeneralPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PTOKEN_PAGE_CONTEXT tokenPageContext; @@ -1243,10 +1243,10 @@ INT_PTR CALLBACK PhpTokenGeneralPageProc( } INT_PTR CALLBACK PhpTokenAdvancedPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PTOKEN_PAGE_CONTEXT tokenPageContext; @@ -1337,9 +1337,9 @@ INT_PTR CALLBACK PhpTokenAdvancedPageProc( } static COLORREF NTAPI PhpTokenCapabilitiesColorFunction( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ) { PSID_AND_ATTRIBUTES sidAndAttributes = Param; @@ -1348,10 +1348,10 @@ static COLORREF NTAPI PhpTokenCapabilitiesColorFunction( } INT_PTR CALLBACK PhpTokenCapabilitiesPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PTOKEN_PAGE_CONTEXT tokenPageContext; @@ -1449,11 +1449,11 @@ INT_PTR CALLBACK PhpTokenCapabilitiesPageProc( } BOOLEAN NTAPI PhpAttributeTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PATTRIBUTE_TREE_CONTEXT context; @@ -1527,9 +1527,9 @@ BOOLEAN NTAPI PhpAttributeTreeNewCallback( } PATTRIBUTE_NODE PhpAddAttributeNode( - __in PATTRIBUTE_TREE_CONTEXT Context, - __in_opt PATTRIBUTE_NODE Parent, - __in_opt __assumeRefs(1) PPH_STRING Text + _In_ PATTRIBUTE_TREE_CONTEXT Context, + _In_opt_ PATTRIBUTE_NODE Parent, + _In_opt_ _Assume_refs_(1) PPH_STRING Text ) { PATTRIBUTE_NODE node; @@ -1553,7 +1553,7 @@ PATTRIBUTE_NODE PhpAddAttributeNode( } VOID PhpDestroyAttributeNode( - __in PATTRIBUTE_NODE Node + _In_ PATTRIBUTE_NODE Node ) { PhDereferenceObject(Node->Children); @@ -1562,8 +1562,8 @@ VOID PhpDestroyAttributeNode( } VOID PhpInitializeAttributeTreeContext( - __out PATTRIBUTE_TREE_CONTEXT Context, - __in HWND TreeNewHandle + _Out_ PATTRIBUTE_TREE_CONTEXT Context, + _In_ HWND TreeNewHandle ) { PH_TREENEW_VIEW_PARTS parts; @@ -1578,7 +1578,7 @@ VOID PhpInitializeAttributeTreeContext( } VOID PhpDeleteAttributeTreeContext( - __inout PATTRIBUTE_TREE_CONTEXT Context + _Inout_ PATTRIBUTE_TREE_CONTEXT Context ) { ULONG i; @@ -1591,7 +1591,7 @@ VOID PhpDeleteAttributeTreeContext( } PWSTR PhGetSecurityAttributeTypeString( - __in USHORT Type + _In_ USHORT Type ) { // These types are shared between CLAIM_* and TOKEN_* security attributes. @@ -1620,7 +1620,7 @@ PWSTR PhGetSecurityAttributeTypeString( } PPH_STRING PhGetSecurityAttributeFlagsString( - __in ULONG Flags + _In_ ULONG Flags ) { PH_STRING_BUILDER sb; @@ -1651,8 +1651,8 @@ PPH_STRING PhGetSecurityAttributeFlagsString( } PPH_STRING PhFormatClaimSecurityAttributeValue( - __in PCLAIM_SECURITY_ATTRIBUTE_V1 Attribute, - __in ULONG ValueIndex + _In_ PCLAIM_SECURITY_ATTRIBUTE_V1 Attribute, + _In_ ULONG ValueIndex ) { PH_FORMAT format; @@ -1699,8 +1699,8 @@ PPH_STRING PhFormatClaimSecurityAttributeValue( } PPH_STRING PhFormatTokenSecurityAttributeValue( - __in PTOKEN_SECURITY_ATTRIBUTE_V1 Attribute, - __in ULONG ValueIndex + _In_ PTOKEN_SECURITY_ATTRIBUTE_V1 Attribute, + _In_ ULONG ValueIndex ) { PH_FORMAT format; @@ -1748,10 +1748,10 @@ PPH_STRING PhFormatTokenSecurityAttributeValue( } BOOLEAN PhpAddTokenClaimAttributes( - __in PTOKEN_PAGE_CONTEXT TokenPageContext, - __in HWND tnHandle, - __in BOOLEAN DeviceClaims, - __in PATTRIBUTE_NODE Parent + _In_ PTOKEN_PAGE_CONTEXT TokenPageContext, + _In_ HWND tnHandle, + _In_ BOOLEAN DeviceClaims, + _In_ PATTRIBUTE_NODE Parent ) { HANDLE tokenHandle; @@ -1806,10 +1806,10 @@ BOOLEAN PhpAddTokenClaimAttributes( } INT_PTR CALLBACK PhpTokenClaimsPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PTOKEN_PAGE_CONTEXT tokenPageContext; @@ -1858,8 +1858,8 @@ INT_PTR CALLBACK PhpTokenClaimsPageProc( } BOOLEAN PhpAddTokenAttributes( - __in PTOKEN_PAGE_CONTEXT TokenPageContext, - __in HWND tnHandle + _In_ PTOKEN_PAGE_CONTEXT TokenPageContext, + _In_ HWND tnHandle ) { HANDLE tokenHandle; @@ -1915,10 +1915,10 @@ BOOLEAN PhpAddTokenAttributes( } INT_PTR CALLBACK PhpTokenAttributesPageProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PTOKEN_PAGE_CONTEXT tokenPageContext; diff --git a/2.x/trunk/README.txt b/2.x/trunk/README.txt index 385143700..f2a95fc0b 100644 --- a/2.x/trunk/README.txt +++ b/2.x/trunk/README.txt @@ -39,9 +39,6 @@ rights. == KProcessHacker == -NOTE: The driver has been very generously signed by the -ReactOS Foundation (http://www.reactos.org). - Process Hacker uses a kernel-mode driver, KProcessHacker, to assist with certain functionality. This includes: @@ -57,10 +54,6 @@ assist with certain functionality. This includes: The feature(s) marked with an asterisk (*) are NOT available on 64-bit versions of Windows. -Certain features such as modifying process protection are disabled -in the released driver binary due to legal reasons. You can enable -them by building KProcessHacker with the "dirty" configuration. - Note that by default, KProcessHacker only allows connections from processes with SeDebugPrivilege. To allow Process Hacker to show details for all processes when it is not running as administrator: diff --git a/2.x/trunk/build/Installer/Process_Hacker2_installer.iss b/2.x/trunk/build/Installer/Process_Hacker2_installer.iss index a5eba0f8a..9c7a92424 100644 --- a/2.x/trunk/build/Installer/Process_Hacker2_installer.iss +++ b/2.x/trunk/build/Installer/Process_Hacker2_installer.iss @@ -1,7 +1,7 @@ ;* Process Hacker 2 - Installer script ;* ;* Copyright (C) 2011 wj32 -;* Copyright (C) 2010-2013 XhmikosR +;* Copyright (C) 2010-2014 XhmikosR ;* ;* This file is part of Process Hacker. ;* @@ -34,7 +34,7 @@ #include "Services.iss" #define installer_build_number "13" -#define copyright "Copyright � 2010-2013, Process Hacker Team. Licensed under the GNU GPL, v3." +#define copyright "Copyright � 2010-2014, Process Hacker Team. Licensed under the GNU GPL, v3." #if defined(TWO_DIGIT_VER) #define app_version str(PHAPP_VERSION_MAJOR) + "." + str(PHAPP_VERSION_MINOR) diff --git a/2.x/trunk/build/internal/DigiCert High Assurance EV Root CA.crt b/2.x/trunk/build/internal/DigiCert High Assurance EV Root CA.crt new file mode 100644 index 000000000..40929ff9b --- /dev/null +++ b/2.x/trunk/build/internal/DigiCert High Assurance EV Root CA.crt @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFOzCCAyOgAwIBAgIKYSBNtAAAAAAAJzANBgkqhkiG9w0BAQUFADB/MQswCQYD +VQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9uZDEe +MBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSkwJwYDVQQDEyBNaWNyb3Nv +ZnQgQ29kZSBWZXJpZmljYXRpb24gUm9vdDAeFw0xMTA0MTUxOTQ1MzNaFw0yMTA0 +MTUxOTU1MzNaMGwxCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMx +GTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xKzApBgNVBAMTIkRpZ2lDZXJ0IEhp +Z2ggQXNzdXJhbmNlIEVWIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQDGzOVz5vvUu+UtLTKm3+WBP8nNJUm2cSrD1ZQ0Z6IKHLBfaaZAscS3 +so/QmKSpQVk609yU1jzbdDikSsxNJYL3SqVTEjju80ltcZF+Y7arpl/DpIT4T2JR +vvjF7Ns4kuMG5QiRDMQoQVX7y1qJFX5x6DW/TXIJPb46OFBbdzEbjbPHJEWap6xt +ABRaBLe6E+tRCphBQSJOZWGHgUFQpnlcid4ZSlfVLuZdHFMsfpjNGgYWpGhz0DQE +E1yhcdNafFXbXmThN4cwVgTlEbQpgBLxeTmIogIRfCdmt4i3ePLKCqg4qwpkwr9m +XZWEwaElHoddGlALIBLMQbtuC1E4uEvLAgMBAAGjgcswgcgwEQYDVR0gBAowCDAG +BgRVHSAAMAsGA1UdDwQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSx +PsNpA/i/RwHUmCYaCALvY2QrwzAfBgNVHSMEGDAWgBRi+wohW39DbhHaCVRQa/XS +lnHxnjBVBgNVHR8ETjBMMEqgSKBGhkRodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20v +cGtpL2NybC9wcm9kdWN0cy9NaWNyb3NvZnRDb2RlVmVyaWZSb290LmNybDANBgkq +hkiG9w0BAQUFAAOCAgEAIIzBWe1vnGstwUo+dR1FTEFQHL2A6tmwkosGKhM/Uxae +VjlqimO2eCR59X24uUehCpbC9su9omafBuGs0nkJDv083KwCDHCvPxvseH7U60sF +YCbZc2GRIe2waGPglxKrb6AS7dmf0tonPLPkVvnR1IEPcb1CfKaJ3M3VvZWiq/GT +EX3orDEpqF1mcEGd/HXJ1bMaOSrQhQVQi6yRysSTy3GlnaSUb1gM+m4gxAgxtYWd +foH50j3KWxiFbAqG7CIJG6V0NE9/KLyVSqsdtpiwXQmkd3Z+76eOXYT2GCTL0W2m +w6GcwhB1gP+dMv3mz0M6gvfOj+FyKptit1/tlRo5XC+UbUi3AV8zL7vcLXM0iQRC +ChyLefmj+hfv+qEaEN/gssGV61wMBZc7NT4YiE3bbL8kiY3Ivdifezk6JKDV39Hz +ShqX9qZveh+wkKmzrAE5kdNht2TxPlc4A6/OetK1kPWu3DmZ1bY8l+2myxbHfWsq +TJCU5kxU/R7NIOzOaJyHWOlhYL7rDsnVGX2f6Xi9DqwhdQePqW7gjGoqa5zj52W8 +vC08bdwE3GdFNjKvBIG8qABuYUyVxVzUjo6fL8EydL29EWUDB83vt14CV9qG1Boo +NK+ISbLPpd2CVm9oqhTiWVT+/+ru7+qScCJggeMlI8CfzA9JsjWqWMM6w9kWlBA= +-----END CERTIFICATE----- diff --git a/2.x/trunk/build/internal/DigiCertHighAssuranceCodeSigningCA-1.crt b/2.x/trunk/build/internal/DigiCertHighAssuranceCodeSigningCA-1.crt new file mode 100644 index 000000000..cddf4d075 Binary files /dev/null and b/2.x/trunk/build/internal/DigiCertHighAssuranceCodeSigningCA-1.crt differ diff --git a/2.x/trunk/build/internal/dobuildrelease.cmd b/2.x/trunk/build/internal/dobuildrelease.cmd index 07aaa3541..4371c5e72 100644 --- a/2.x/trunk/build/internal/dobuildrelease.cmd +++ b/2.x/trunk/build/internal/dobuildrelease.cmd @@ -1,7 +1,6 @@ @echo off -rem The first parameter specifies the ProcessHacker2 -rem base directory. +rem The first parameter specifies the ProcessHacker2 base directory. rem The second parameter specifies the output directory. rem Variables: rem INNOBIN - Specify the path to Inno Setup. @@ -9,12 +8,15 @@ rem e.g. C:\Program Files\Inno Setup 5 rem SVNBIN - Specify the path to the SVN client. rem SEVENZIPBIN - Specify the path to 7-Zip. rem e.g. C:\Program Files\7-Zip -rem MINORVERSION - Specify the minor version of -rem the Process Hacker release being built. +rem SIGN - Specify 1 to sign executable files. +rem SIGN_TIMESTAMP - Specify 1 to timestamp executable files. +rem MINORVERSION - Specify the minor version of the Process Hacker release being built. rem e.g. 8 rem Build the main projects +set PHBASE=%1 + devenv %1\ProcessHacker.sln /build "Release|Win32" devenv %1\ProcessHacker.sln /build "Release|x64" call %1\build\internal\wait.cmd 2 @@ -27,13 +29,4 @@ devenv %1\plugins\Plugins.sln /build "Release|Win32" devenv %1\plugins\Plugins.sln /build "Release|x64" call %1\build\internal\wait.cmd 2 -rem Build the installer (HARDCODED PATH) - -if exist "%INNOBIN%\iscc.exe". ( - pushd %1\build\Installer\ - del *.exe - "%INNOBIN%\iscc.exe" Process_Hacker2_installer.iss - popd -) - call %1\build\internal\dorelease.cmd %1 %2 diff --git a/2.x/trunk/build/internal/dorelease.cmd b/2.x/trunk/build/internal/dorelease.cmd index 7e17cb839..5107f27f1 100644 --- a/2.x/trunk/build/internal/dorelease.cmd +++ b/2.x/trunk/build/internal/dorelease.cmd @@ -12,7 +12,7 @@ if exist "%SVNBIN%\svn.exe". ( "%SVNBIN%\svn.exe" export %1 %2\ProcessHacker2 echo #define PHAPP_VERSION_REVISION 0 > %2\ProcessHacker2\ProcessHacker\include\phapprev.h if exist "%SEVENZIPBIN%\7z.exe" "%SEVENZIPBIN%\7z.exe" a -mx9 %2\processhacker-2.%MINORVERSION%-src.zip %2\ProcessHacker2\* - ) +) rem SDK distribution @@ -28,7 +28,14 @@ for %%a in ( COPYRIGHT.txt LICENSE.txt README.txt - ) do copy %1\%%a %2\bin\%%a +) do copy %1\%%a %2\bin\%%a + +if "%SIGN%" == "1" ( + call %1\build\internal\sign.cmd %1\bin\Release32\ProcessHacker.exe + call %1\build\internal\sign.cmd %1\bin\Release32\peview.exe + call %1\build\internal\sign.cmd %1\bin\Release64\ProcessHacker.exe + call %1\build\internal\sign.cmd %1\bin\Release64\peview.exe +) mkdir %2\bin\x86 copy %1\bin\Release32\ProcessHacker.exe %2\bin\x86\ @@ -53,7 +60,12 @@ for %%a in ( Updater UserNotes WindowExplorer - ) do copy %1\bin\Release32\plugins\%%a.dll %2\bin\x86\plugins\%%a.dll +) do ( + if "%SIGN%" == "1" ( + call %1\build\internal\sign.cmd %1\bin\Release32\plugins\%%a.dll + ) + copy %1\bin\Release32\plugins\%%a.dll %2\bin\x86\plugins\%%a.dll +) mkdir %2\bin\x64\plugins for %%a in ( @@ -68,10 +80,30 @@ for %%a in ( Updater UserNotes WindowExplorer - ) do copy %1\bin\Release64\plugins\%%a.dll %2\bin\x64\plugins\%%a.dll +) do ( + if "%SIGN%" == "1" ( + call %1\build\internal\sign.cmd %1\bin\Release64\plugins\%%a.dll + ) + copy %1\bin\Release64\plugins\%%a.dll %2\bin\x64\plugins\%%a.dll +) if exist "%SEVENZIPBIN%\7z.exe" "%SEVENZIPBIN%\7z.exe" a -mx9 %2\processhacker-2.%MINORVERSION%-bin.zip %2\bin\* -if exist %1\build\Installer\processhacker-*-setup.exe copy %1\build\Installer\processhacker-*-setup.exe %2\ + +rem Installer distribution + +if exist "%INNOBIN%\iscc.exe". ( + pushd %1\build\Installer\ + del *.exe + "%INNOBIN%\iscc.exe" Process_Hacker2_installer.iss + popd +) + +if exist %1\build\Installer\processhacker-2.%MINORVERSION%-setup.exe ( + copy %1\build\Installer\processhacker-2.%MINORVERSION%-setup.exe %2\ + if "%SIGN%" == "1" ( + call %1\build\internal\sign.cmd %2\processhacker-2.%MINORVERSION%-setup.exe + ) +) goto :end diff --git a/2.x/trunk/build/internal/sign.cmd b/2.x/trunk/build/internal/sign.cmd new file mode 100644 index 000000000..d917ee946 --- /dev/null +++ b/2.x/trunk/build/internal/sign.cmd @@ -0,0 +1,19 @@ +@echo off + +if "%1" == "" goto :notset + +set additional= +if "%2" == "kmcs" set additional=/ac "%PHBASE%\build\internal\DigiCert High Assurance EV Root CA.crt" + +set timestamp= +if "%SIGN_TIMESTAMP%" == "1" set timestamp=/t http://timestamp.digicert.com + +signtool sign %timestamp% /i "DigiCert High Assurance Code Signing CA-1" %additional% %1 + +goto :end + +:notset +echo Parameters not set. +pause + +:end diff --git a/2.x/trunk/build/sdk/makesdk.cmd b/2.x/trunk/build/sdk/makesdk.cmd index 40c84e9cd..c1de9a5bf 100644 --- a/2.x/trunk/build/sdk/makesdk.cmd +++ b/2.x/trunk/build/sdk/makesdk.cmd @@ -99,6 +99,8 @@ rem Symbols copy ..\..\bin\Release32\ProcessHacker.pdb ..\..\sdk\dbg\i386\ copy ..\..\bin\Release64\ProcessHacker.pdb ..\..\sdk\dbg\amd64\ +copy ..\..\KProcessHacker\bin\i386\kprocesshacker.pdb ..\..\sdk\dbg\i386\ +copy ..\..\KProcessHacker\bin\amd64\kprocesshacker.pdb ..\..\sdk\dbg\amd64\ rem Libraries diff --git a/2.x/trunk/phlib/basesup.c b/2.x/trunk/phlib/basesup.c index cb14e0c80..da746acf0 100644 --- a/2.x/trunk/phlib/basesup.c +++ b/2.x/trunk/phlib/basesup.c @@ -73,28 +73,28 @@ typedef struct _PHP_BASE_THREAD_CONTEXT } PHP_BASE_THREAD_CONTEXT, *PPHP_BASE_THREAD_CONTEXT; VOID NTAPI PhpFullStringDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); VOID NTAPI PhpListDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); VOID NTAPI PhpPointerListDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); VOID NTAPI PhpQueueDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); VOID NTAPI PhpHashtableDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); // Types @@ -138,7 +138,7 @@ static ULONG PhpPrimeNumbers[] = * Initializes the base support module. */ BOOLEAN PhInitializeBase( - __in ULONG Flags + _In_ ULONG Flags ) { PH_OBJECT_TYPE_PARAMETERS parameters; @@ -209,7 +209,7 @@ BOOLEAN PhInitializeBase( } NTSTATUS PhpBaseThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { NTSTATUS status; @@ -265,9 +265,9 @@ NTSTATUS PhpBaseThreadStart( * \param Parameter A user-defined value to pass to the function. */ HANDLE PhCreateThread( - __in_opt SIZE_T StackSize, - __in PUSER_THREAD_START_ROUTINE StartAddress, - __in_opt PVOID Parameter + _In_opt_ SIZE_T StackSize, + _In_ PUSER_THREAD_START_ROUTINE StartAddress, + _In_opt_ PVOID Parameter ) { HANDLE threadHandle; @@ -306,7 +306,7 @@ HANDLE PhCreateThread( * because no system calls are involved. */ VOID PhQuerySystemTime( - __out PLARGE_INTEGER SystemTime + _Out_ PLARGE_INTEGER SystemTime ) { do @@ -320,7 +320,7 @@ VOID PhQuerySystemTime( * Gets the offset of the current time zone from UTC. */ VOID PhQueryTimeZoneBias( - __out PLARGE_INTEGER TimeZoneBias + _Out_ PLARGE_INTEGER TimeZoneBias ) { do @@ -341,8 +341,8 @@ VOID PhQueryTimeZoneBias( * because no system calls are involved. */ VOID PhSystemTimeToLocalTime( - __in PLARGE_INTEGER SystemTime, - __out PLARGE_INTEGER LocalTime + _In_ PLARGE_INTEGER SystemTime, + _Out_ PLARGE_INTEGER LocalTime ) { LARGE_INTEGER timeZoneBias; @@ -362,8 +362,8 @@ VOID PhSystemTimeToLocalTime( * because no system calls are involved. */ VOID PhLocalTimeToSystemTime( - __in PLARGE_INTEGER LocalTime, - __out PLARGE_INTEGER SystemTime + _In_ PLARGE_INTEGER LocalTime, + _Out_ PLARGE_INTEGER SystemTime ) { LARGE_INTEGER timeZoneBias; @@ -385,12 +385,12 @@ VOID PhLocalTimeToSystemTime( * The block is guaranteed to be aligned at * MEMORY_ALLOCATION_ALIGNMENT bytes. */ -__mayRaise -__checkReturn -__notnull -__bcount(Size) +_May_raise_ +_Check_return_ +_Ret_notnull_ +_Post_writable_byte_size_(Size) PVOID PhAllocate( - __in SIZE_T Size + _In_ SIZE_T Size ) { return RtlAllocateHeap(PhHeapHandle, HEAP_GENERATE_EXCEPTIONS, Size); @@ -405,7 +405,7 @@ PVOID PhAllocate( * memory, or NULL if the block could not be allocated. */ PVOID PhAllocateSafe( - __in SIZE_T Size + _In_ SIZE_T Size ) { return RtlAllocateHeap(PhHeapHandle, 0, Size); @@ -421,8 +421,8 @@ PVOID PhAllocateSafe( * memory, or NULL if the block could not be allocated. */ PVOID PhAllocateExSafe( - __in SIZE_T Size, - __in ULONG Flags + _In_ SIZE_T Size, + _In_ ULONG Flags ) { return RtlAllocateHeap(PhHeapHandle, Flags, Size); @@ -435,7 +435,7 @@ PVOID PhAllocateExSafe( * \param Memory A pointer to a block of memory. */ VOID PhFree( - __in __post_invalid PVOID Memory + _Frees_ptr_opt_ PVOID Memory ) { RtlFreeHeap(PhHeapHandle, 0, Memory); @@ -456,9 +456,11 @@ VOID PhFree( * \remarks If the function fails to allocate * the block of memory, it raises an exception. */ -__mayRaise PVOID PhReAllocate( - __in PVOID Memory, - __in SIZE_T Size +_May_raise_ +_Post_writable_byte_size_(Size) +PVOID PhReAllocate( + _Frees_ptr_opt_ PVOID Memory, + _In_ SIZE_T Size ) { return RtlReAllocateHeap(PhHeapHandle, HEAP_GENERATE_EXCEPTIONS, Memory, Size); @@ -478,8 +480,8 @@ __mayRaise PVOID PhReAllocate( * copied to the new block. */ PVOID PhReAllocateSafe( - __in PVOID Memory, - __in SIZE_T Size + _In_ PVOID Memory, + _In_ SIZE_T Size ) { return RtlReAllocateHeap(PhHeapHandle, 0, Memory, Size); @@ -496,11 +498,11 @@ PVOID PhReAllocateSafe( * \return A pointer to the allocated block of memory, or NULL * if the block could not be allocated. */ -__checkReturn -__maybenull +_Check_return_ +_Ret_maybenull_ PVOID PhAllocatePage( - __in SIZE_T Size, - __out_opt PSIZE_T NewSize + _In_ SIZE_T Size, + _Out_opt_ PSIZE_T NewSize ) { PVOID baseAddress; @@ -533,7 +535,7 @@ PVOID PhAllocatePage( * \param Memory A pointer to a block of memory. */ VOID PhFreePage( - __in __post_invalid PVOID Memory + _Frees_ptr_opt_ PVOID Memory ) { SIZE_T size; @@ -556,7 +558,7 @@ VOID PhFreePage( * \return The new string, which can be freed using PhFree(). */ PSTR PhDuplicateAnsiStringZ( - __in PSTR String + _In_ PSTR String ) { PSTR newString; @@ -579,7 +581,7 @@ PSTR PhDuplicateAnsiStringZ( * NULL if storage could not be allocated. */ PSTR PhDuplicateAnsiStringZSafe( - __in PSTR String + _In_ PSTR String ) { PSTR newString; @@ -605,7 +607,7 @@ PSTR PhDuplicateAnsiStringZSafe( * \return The new string, which can be freed using PhFree(). */ PWSTR PhDuplicateUnicodeStringZ( - __in PWSTR String + _In_ PWSTR String ) { PWSTR newString; @@ -646,11 +648,11 @@ PWSTR PhDuplicateUnicodeStringZ( * \a InputCount is not -1. */ BOOLEAN PhCopyAnsiStringZ( - __in PSTR InputBuffer, - __in ULONG InputCount, - __out_ecount_z_opt(OutputCount) PSTR OutputBuffer, - __in ULONG OutputCount, - __out_opt PULONG ReturnCount + _In_ PSTR InputBuffer, + _In_ ULONG InputCount, + _Out_writes_opt_z_(OutputCount) PSTR OutputBuffer, + _In_ ULONG OutputCount, + _Out_opt_ PULONG ReturnCount ) { ULONG i; @@ -716,11 +718,11 @@ BOOLEAN PhCopyAnsiStringZ( * \a InputCount is not -1. */ BOOLEAN PhCopyUnicodeStringZ( - __in PWSTR InputBuffer, - __in ULONG InputCount, - __out_ecount_z_opt(OutputCount) PWSTR OutputBuffer, - __in ULONG OutputCount, - __out_opt PULONG ReturnCount + _In_ PWSTR InputBuffer, + _In_ ULONG InputCount, + _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer, + _In_ ULONG OutputCount, + _Out_opt_ PULONG ReturnCount ) { ULONG i; @@ -786,11 +788,11 @@ BOOLEAN PhCopyUnicodeStringZ( * \a InputCount is not -1. */ BOOLEAN PhCopyUnicodeStringZFromAnsi( - __in PSTR InputBuffer, - __in ULONG InputCount, - __out_ecount_z_opt(OutputCount) PWSTR OutputBuffer, - __in ULONG OutputCount, - __out_opt PULONG ReturnCount + _In_ PSTR InputBuffer, + _In_ ULONG InputCount, + _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer, + _In_ ULONG OutputCount, + _Out_opt_ PULONG ReturnCount ) { NTSTATUS status; @@ -863,8 +865,8 @@ BOOLEAN PhCopyUnicodeStringZFromAnsi( } FORCEINLINE LONG PhpCompareRightNatural( - __in PWSTR A, - __in PWSTR B + _In_ PWSTR A, + _In_ PWSTR B ) { LONG bias = 0; @@ -903,8 +905,8 @@ FORCEINLINE LONG PhpCompareRightNatural( } FORCEINLINE LONG PhpCompareLeftNatural( - __in PWSTR A, - __in PWSTR B + _In_ PWSTR A, + _In_ PWSTR B ) { for (; ; A++, B++) @@ -935,9 +937,9 @@ FORCEINLINE LONG PhpCompareLeftNatural( } FORCEINLINE LONG PhpCompareUnicodeStringZNatural( - __in PWSTR A, - __in PWSTR B, - __in BOOLEAN IgnoreCase + _In_ PWSTR A, + _In_ PWSTR B, + _In_ BOOLEAN IgnoreCase ) { /* strnatcmp.c -- Perform 'natural order' comparisons of strings in C. @@ -1030,9 +1032,9 @@ FORCEINLINE LONG PhpCompareUnicodeStringZNatural( * \param IgnoreCase Whether to ignore character cases. */ LONG PhCompareUnicodeStringZNatural( - __in PWSTR A, - __in PWSTR B, - __in BOOLEAN IgnoreCase + _In_ PWSTR A, + _In_ PWSTR B, + _In_ BOOLEAN IgnoreCase ) { if (!IgnoreCase) @@ -1050,18 +1052,18 @@ LONG PhCompareUnicodeStringZNatural( * FALSE. */ LONG PhCompareStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ) { SIZE_T l1; SIZE_T l2; - PWSTR s1; - PWSTR s2; + PWCHAR s1; + PWCHAR s2; WCHAR c1; WCHAR c2; - PWSTR end; + PWCHAR end; // Note: this function assumes that the difference between the lengths of // the two strings can fit inside a LONG. @@ -1073,7 +1075,7 @@ LONG PhCompareStringRef( s1 = String1->Buffer; s2 = String2->Buffer; - end = (PWSTR)((PCHAR)s1 + (l1 <= l2 ? l1 : l2)); + end = (PWCHAR)((PCHAR)s1 + (l1 <= l2 ? l1 : l2)); if (!IgnoreCase) { @@ -1122,9 +1124,9 @@ LONG PhCompareStringRef( * FALSE. */ BOOLEAN PhEqualStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ) { SIZE_T l1; @@ -1272,9 +1274,9 @@ BOOLEAN PhEqualStringRef( * \a Character in \a String1. If \a Character was not found, -1 is returned. */ ULONG_PTR PhFindCharInStringRef( - __in PPH_STRINGREF String, - __in WCHAR Character, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String, + _In_ WCHAR Character, + _In_ BOOLEAN IgnoreCase ) { PWSTR buffer; @@ -1359,15 +1361,15 @@ ULONG_PTR PhFindCharInStringRef( * \a Character in \a String1. If \a Character was not found, -1 is returned. */ ULONG_PTR PhFindLastCharInStringRef( - __in PPH_STRINGREF String, - __in WCHAR Character, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String, + _In_ WCHAR Character, + _In_ BOOLEAN IgnoreCase ) { - PWSTR buffer; + PWCHAR buffer; SIZE_T length; - buffer = (PWSTR)((PCHAR)String->Buffer + String->Length); + buffer = (PWCHAR)((PCHAR)String->Buffer + String->Length); length = String->Length / sizeof(WCHAR); if (!IgnoreCase) @@ -1452,9 +1454,9 @@ ULONG_PTR PhFindLastCharInStringRef( * \a String2 in \a String1. If \a String2 was not found, -1 is returned. */ ULONG_PTR PhFindStringInStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ) { SIZE_T length1; @@ -1526,10 +1528,10 @@ ULONG_PTR PhFindStringInStringRef( * \return TRUE if \a Separator was found in \a Input, otherwise FALSE. */ BOOLEAN PhSplitStringRefAtChar( - __in PPH_STRINGREF Input, - __in WCHAR Separator, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart + _In_ PPH_STRINGREF Input, + _In_ WCHAR Separator, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart ) { PH_STRINGREF input; @@ -1552,7 +1554,7 @@ BOOLEAN PhSplitStringRefAtChar( FirstPart->Buffer = input.Buffer; FirstPart->Length = index * sizeof(WCHAR); - SecondPart->Buffer = (PWSTR)((PCHAR)input.Buffer + index * sizeof(WCHAR) + sizeof(WCHAR)); + SecondPart->Buffer = (PWCHAR)((PCHAR)input.Buffer + index * sizeof(WCHAR) + sizeof(WCHAR)); SecondPart->Length = input.Length - index * sizeof(WCHAR) - sizeof(WCHAR); return TRUE; @@ -1575,10 +1577,10 @@ BOOLEAN PhSplitStringRefAtChar( * \return TRUE if \a Separator was found in \a Input, otherwise FALSE. */ BOOLEAN PhSplitStringRefAtLastChar( - __in PPH_STRINGREF Input, - __in WCHAR Separator, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart + _In_ PPH_STRINGREF Input, + _In_ WCHAR Separator, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart ) { PH_STRINGREF input; @@ -1601,7 +1603,7 @@ BOOLEAN PhSplitStringRefAtLastChar( FirstPart->Buffer = input.Buffer; FirstPart->Length = index * sizeof(WCHAR); - SecondPart->Buffer = (PWSTR)((PCHAR)input.Buffer + index * sizeof(WCHAR) + sizeof(WCHAR)); + SecondPart->Buffer = (PWCHAR)((PCHAR)input.Buffer + index * sizeof(WCHAR) + sizeof(WCHAR)); SecondPart->Length = input.Length - index * sizeof(WCHAR) - sizeof(WCHAR); return TRUE; @@ -1626,11 +1628,11 @@ BOOLEAN PhSplitStringRefAtLastChar( * \return TRUE if \a Separator was found in \a Input, otherwise FALSE. */ BOOLEAN PhSplitStringRefAtString( - __in PPH_STRINGREF Input, - __in PPH_STRINGREF Separator, - __in BOOLEAN IgnoreCase, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart + _In_ PPH_STRINGREF Input, + _In_ PPH_STRINGREF Separator, + _In_ BOOLEAN IgnoreCase, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart ) { PH_STRINGREF input; @@ -1653,7 +1655,7 @@ BOOLEAN PhSplitStringRefAtString( FirstPart->Buffer = input.Buffer; FirstPart->Length = index * sizeof(WCHAR); - SecondPart->Buffer = (PWSTR)((PCHAR)input.Buffer + index * sizeof(WCHAR) + Separator->Length); + SecondPart->Buffer = (PWCHAR)((PCHAR)input.Buffer + index * sizeof(WCHAR) + Separator->Length); SecondPart->Length = input.Length - index * sizeof(WCHAR) - Separator->Length; return TRUE; @@ -1696,25 +1698,25 @@ BOOLEAN PhSplitStringRefAtString( * \return TRUE if a separator was found in \a Input, otherwise FALSE. */ BOOLEAN PhSplitStringRefEx( - __in PPH_STRINGREF Input, - __in PPH_STRINGREF Separator, - __in ULONG Flags, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart, - __out_opt PPH_STRINGREF SeparatorPart + _In_ PPH_STRINGREF Input, + _In_ PPH_STRINGREF Separator, + _In_ ULONG Flags, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart, + _Out_opt_ PPH_STRINGREF SeparatorPart ) { PH_STRINGREF input; SIZE_T separatorIndex; SIZE_T separatorLength; - PWSTR charSet; + PWCHAR charSet; SIZE_T charSetCount; BOOLEAN charSetTable[256]; BOOLEAN charSetTableComplete; SIZE_T i; SIZE_T j; USHORT c; - PWSTR s; + PWCHAR s; LONG_PTR direction; input = *Input; // get a copy of the input because FirstPart/SecondPart/SeparatorPart may alias Input @@ -1796,7 +1798,7 @@ BOOLEAN PhSplitStringRefEx( } else { - s = (PWSTR)((PCHAR)input.Buffer + input.Length - sizeof(WCHAR)); + s = (PWCHAR)((PCHAR)input.Buffer + input.Length - sizeof(WCHAR)); direction = -1; } @@ -1886,7 +1888,7 @@ BOOLEAN PhSplitStringRefEx( SeparatorFound: FirstPart->Buffer = input.Buffer; FirstPart->Length = separatorIndex * sizeof(WCHAR); - SecondPart->Buffer = (PWSTR)((PCHAR)input.Buffer + separatorIndex * sizeof(WCHAR) + separatorLength); + SecondPart->Buffer = (PWCHAR)((PCHAR)input.Buffer + separatorIndex * sizeof(WCHAR) + separatorLength); SecondPart->Length = input.Length - separatorIndex * sizeof(WCHAR) - separatorLength; if (SeparatorPart) @@ -1919,7 +1921,7 @@ BOOLEAN PhSplitStringRefEx( * \param Buffer A null-terminated Unicode string. */ PPH_STRING PhCreateString( - __in PWSTR Buffer + _In_ PWSTR Buffer ) { return PhCreateStringEx(Buffer, wcslen(Buffer) * sizeof(WCHAR)); @@ -1932,8 +1934,8 @@ PPH_STRING PhCreateString( * \param Length The length, in bytes, of the string. */ PPH_STRING PhCreateStringEx( - __in_opt PWSTR Buffer, - __in SIZE_T Length + _In_opt_ PWCHAR Buffer, + _In_ SIZE_T Length ) { PPH_STRING string; @@ -1966,7 +1968,7 @@ PPH_STRING PhCreateStringEx( * \param Buffer A null-terminated ANSI string. */ PPH_STRING PhCreateStringFromAnsi( - __in PSTR Buffer + _In_ PSTR Buffer ) { return PhCreateStringFromAnsiEx( @@ -1983,8 +1985,8 @@ PPH_STRING PhCreateStringFromAnsi( * \param Length The number of bytes to use. */ PPH_STRING PhCreateStringFromAnsiEx( - __in PSTR Buffer, - __in SIZE_T Length + _In_ PCHAR Buffer, + _In_ SIZE_T Length ) { NTSTATUS status; @@ -2062,7 +2064,7 @@ PPH_STRING PhReferenceEmptyString( * \param Count The number of strings to concatenate. */ PPH_STRING PhConcatStrings( - __in ULONG Count, + _In_ ULONG Count, ... ) { @@ -2080,8 +2082,8 @@ PPH_STRING PhConcatStrings( * \param ArgPtr A pointer to an array of strings. */ PPH_STRING PhConcatStrings_V( - __in ULONG Count, - __in va_list ArgPtr + _In_ ULONG Count, + _In_ va_list ArgPtr ) { va_list argptr; @@ -2142,8 +2144,8 @@ PPH_STRING PhConcatStrings_V( * \param String2 The second string. */ PPH_STRING PhConcatStrings2( - __in PWSTR String1, - __in PWSTR String2 + _In_ PWSTR String1, + _In_ PWSTR String2 ) { PPH_STRING string; @@ -2174,8 +2176,8 @@ PPH_STRING PhConcatStrings2( * \param String2 The second string. */ PPH_STRING PhConcatStringRef2( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2 + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2 ) { PPH_STRING string; @@ -2198,9 +2200,9 @@ PPH_STRING PhConcatStringRef2( * \param String3 The third string. */ PPH_STRING PhConcatStringRef3( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in PPH_STRINGREF String3 + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ PPH_STRINGREF String3 ) { PPH_STRING string; @@ -2230,7 +2232,7 @@ PPH_STRING PhConcatStringRef3( * \param Format The format-control string. */ PPH_STRING PhFormatString( - __in __format_string PWSTR Format, + _In_ _Printf_format_string_ PWSTR Format, ... ) { @@ -2248,8 +2250,8 @@ PPH_STRING PhFormatString( * \param ArgPtr A pointer to the list of arguments. */ PPH_STRING PhFormatString_V( - __in __format_string PWSTR Format, - __in va_list ArgPtr + _In_ _Printf_format_string_ PWSTR Format, + _In_ va_list ArgPtr ) { PPH_STRING string; @@ -2273,7 +2275,7 @@ PPH_STRING PhFormatString_V( * \param Buffer A null-terminated ANSI string. */ PPH_ANSI_STRING PhCreateAnsiString( - __in PSTR Buffer + _In_ PSTR Buffer ) { return PhCreateAnsiStringEx(Buffer, strlen(Buffer)); @@ -2286,8 +2288,8 @@ PPH_ANSI_STRING PhCreateAnsiString( * \param Length The length, in bytes, of the string. */ PPH_ANSI_STRING PhCreateAnsiStringEx( - __in_opt PSTR Buffer, - __in SIZE_T Length + _In_opt_ PCHAR Buffer, + _In_ SIZE_T Length ) { PPH_ANSI_STRING string; @@ -2319,7 +2321,7 @@ PPH_ANSI_STRING PhCreateAnsiStringEx( * \param Buffer A null-terminated Unicode string. */ PPH_ANSI_STRING PhCreateAnsiStringFromUnicode( - __in PWSTR Buffer + _In_ PWSTR Buffer ) { return PhCreateAnsiStringFromUnicodeEx( @@ -2336,8 +2338,8 @@ PPH_ANSI_STRING PhCreateAnsiStringFromUnicode( * \param Length The number of bytes to use. */ PPH_ANSI_STRING PhCreateAnsiStringFromUnicodeEx( - __in PWSTR Buffer, - __in SIZE_T Length + _In_ PWCHAR Buffer, + _In_ SIZE_T Length ) { NTSTATUS status; @@ -2380,8 +2382,8 @@ PPH_ANSI_STRING PhCreateAnsiStringFromUnicodeEx( * initially. */ VOID PhInitializeStringBuilder( - __out PPH_STRING_BUILDER StringBuilder, - __in SIZE_T InitialCapacity + _Out_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T InitialCapacity ) { // Make sure the initial capacity is even, as required for all string objects. @@ -2417,15 +2419,15 @@ VOID PhInitializeStringBuilder( * \param StringBuilder A string builder object. */ VOID PhDeleteStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder + _Inout_ PPH_STRING_BUILDER StringBuilder ) { PhDereferenceObject(StringBuilder->String); } VOID PhpResizeStringBuilder( - __in PPH_STRING_BUILDER StringBuilder, - __in SIZE_T NewCapacity + _In_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T NewCapacity ) { PPH_STRING newString; @@ -2460,7 +2462,7 @@ VOID PhpResizeStringBuilder( } FORCEINLINE VOID PhpWriteNullTerminatorStringBuilder( - __in PPH_STRING_BUILDER StringBuilder + _In_ PPH_STRING_BUILDER StringBuilder ) { assert(!(StringBuilder->String->Length & 1)); @@ -2482,7 +2484,7 @@ FORCEINLINE VOID PhpWriteNullTerminatorStringBuilder( * Otherwise, the string may change unexpectedly. */ PPH_STRING PhReferenceStringBuilderString( - __in PPH_STRING_BUILDER StringBuilder + _In_ PPH_STRING_BUILDER StringBuilder ) { PPH_STRING string; @@ -2509,7 +2511,7 @@ PPH_STRING PhReferenceStringBuilderString( * PhDeleteStringBuilder(). */ PPH_STRING PhFinalStringBuilderString( - __inout PPH_STRING_BUILDER StringBuilder + _Inout_ PPH_STRING_BUILDER StringBuilder ) { return StringBuilder->String; @@ -2523,8 +2525,8 @@ PPH_STRING PhFinalStringBuilderString( * \param String The string to append. */ VOID PhAppendStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in PPH_STRING String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ PPH_STRING String ) { PhAppendStringBuilderEx( @@ -2542,8 +2544,8 @@ VOID PhAppendStringBuilder( * \param String The string to append. */ VOID PhAppendStringBuilder2( - __inout PPH_STRING_BUILDER StringBuilder, - __in PWSTR String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ PWSTR String ) { PhAppendStringBuilderEx( @@ -2563,9 +2565,9 @@ VOID PhAppendStringBuilder2( * \param Length The number of bytes to append. */ VOID PhAppendStringBuilderEx( - __inout PPH_STRING_BUILDER StringBuilder, - __in_opt PWSTR String, - __in SIZE_T Length + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_opt_ PWCHAR String, + _In_ SIZE_T Length ) { if (Length == 0) @@ -2600,8 +2602,8 @@ VOID PhAppendStringBuilderEx( * \param Character The character to append. */ VOID PhAppendCharStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in WCHAR Character + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ WCHAR Character ) { if (StringBuilder->AllocatedLength < StringBuilder->String->Length + sizeof(WCHAR)) @@ -2623,9 +2625,9 @@ VOID PhAppendCharStringBuilder( * \param Count The number of times to append the character. */ VOID PhAppendCharStringBuilder2( - __inout PPH_STRING_BUILDER StringBuilder, - __in WCHAR Character, - __in SIZE_T Count + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ WCHAR Character, + _In_ SIZE_T Count ) { if (Count == 0) @@ -2655,8 +2657,8 @@ VOID PhAppendCharStringBuilder2( * \param Format The format-control string. */ VOID PhAppendFormatStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in __format_string PWSTR Format, + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ _Printf_format_string_ PWSTR Format, ... ) { @@ -2667,9 +2669,9 @@ VOID PhAppendFormatStringBuilder( } VOID PhAppendFormatStringBuilder_V( - __inout PPH_STRING_BUILDER StringBuilder, - __in __format_string PWSTR Format, - __in va_list ArgPtr + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ _Printf_format_string_ PWSTR Format, + _In_ va_list ArgPtr ) { int length; @@ -2705,9 +2707,9 @@ VOID PhAppendFormatStringBuilder_V( * \param String The string to insert. */ VOID PhInsertStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T Index, - __in PPH_STRING String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T Index, + _In_ PPH_STRING String ) { PhInsertStringBuilderEx( @@ -2727,9 +2729,9 @@ VOID PhInsertStringBuilder( * \param String The string to insert. */ VOID PhInsertStringBuilder2( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T Index, - __in PWSTR String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T Index, + _In_ PWSTR String ) { PhInsertStringBuilderEx( @@ -2751,10 +2753,10 @@ VOID PhInsertStringBuilder2( * \param Length The number of bytes to insert. */ VOID PhInsertStringBuilderEx( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T Index, - __in_opt PWSTR String, - __in SIZE_T Length + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T Index, + _In_opt_ PWCHAR String, + _In_ SIZE_T Length ) { if (Length == 0) @@ -2799,9 +2801,9 @@ VOID PhInsertStringBuilderEx( * \param Count The number of characters to remove. */ VOID PhRemoveStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T StartIndex, - __in SIZE_T Count + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T StartIndex, + _In_ SIZE_T Count ) { // Overwrite the removed part with the part @@ -2823,7 +2825,7 @@ VOID PhRemoveStringBuilder( * allocate storage for initially. */ PPH_LIST PhCreateList( - __in ULONG InitialCapacity + _In_ ULONG InitialCapacity ) { PPH_LIST list; @@ -2848,8 +2850,8 @@ PPH_LIST PhCreateList( } VOID PhpListDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_LIST list = (PPH_LIST)Object; @@ -2866,8 +2868,8 @@ VOID PhpListDeleteProcedure( * than the current number of items in the list. */ VOID PhResizeList( - __inout PPH_LIST List, - __in ULONG NewCapacity + _Inout_ PPH_LIST List, + _In_ ULONG NewCapacity ) { if (List->Count > NewCapacity) @@ -2884,8 +2886,8 @@ VOID PhResizeList( * \param Item The item to add. */ VOID PhAddItemList( - __inout PPH_LIST List, - __in PVOID Item + _Inout_ PPH_LIST List, + _In_ PVOID Item ) { // See if we need to resize the list. @@ -2906,9 +2908,9 @@ VOID PhAddItemList( * \param Count The number of items to add. */ VOID PhAddItemsList( - __inout PPH_LIST List, - __in PVOID *Items, - __in ULONG Count + _Inout_ PPH_LIST List, + _In_ PVOID *Items, + _In_ ULONG Count ) { // See if we need to resize the list. @@ -2937,13 +2939,13 @@ VOID PhAddItemsList( * \param List A list object. */ VOID PhClearList( - __inout PPH_LIST List + _Inout_ PPH_LIST List ) { List->Count = 0; } -__success(return != -1) +_Success_(return != -1) /** * Locates an item in a list. * @@ -2954,8 +2956,8 @@ __success(return != -1) * item was not found, -1 is returned. */ ULONG PhFindItemList( - __in PPH_LIST List, - __in PVOID Item + _In_ PPH_LIST List, + _In_ PVOID Item ) { ULONG i; @@ -2977,9 +2979,9 @@ ULONG PhFindItemList( * \param Item The item to add. */ VOID PhInsertItemList( - __inout PPH_LIST List, - __in ULONG Index, - __in PVOID Item + _Inout_ PPH_LIST List, + _In_ ULONG Index, + _In_ PVOID Item ) { PhInsertItemsList(List, Index, &Item, 1); @@ -2994,10 +2996,10 @@ VOID PhInsertItemList( * \param Count The number of items to add. */ VOID PhInsertItemsList( - __inout PPH_LIST List, - __in ULONG Index, - __in PVOID *Items, - __in ULONG Count + _Inout_ PPH_LIST List, + _In_ ULONG Index, + _In_ PVOID *Items, + _In_ ULONG Count ) { // See if we need to resize the list. @@ -3038,8 +3040,8 @@ VOID PhInsertItemsList( * \param Index The index of the item. */ VOID PhRemoveItemList( - __inout PPH_LIST List, - __in ULONG Index + _Inout_ PPH_LIST List, + _In_ ULONG Index ) { PhRemoveItemsList(List, Index, 1); @@ -3054,9 +3056,9 @@ VOID PhRemoveItemList( * \param Count The number of items to remove. */ VOID PhRemoveItemsList( - __inout PPH_LIST List, - __in ULONG StartIndex, - __in ULONG Count + _Inout_ PPH_LIST List, + _In_ ULONG StartIndex, + _In_ ULONG Count ) { // Shift the items after the items forward. @@ -3076,7 +3078,7 @@ VOID PhRemoveItemsList( * allocate storage for initially. */ PPH_POINTER_LIST PhCreatePointerList( - __in ULONG InitialCapacity + _In_ ULONG InitialCapacity ) { PPH_POINTER_LIST pointerList; @@ -3103,8 +3105,8 @@ PPH_POINTER_LIST PhCreatePointerList( } VOID NTAPI PhpPointerListDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_POINTER_LIST pointerList = (PPH_POINTER_LIST)Object; @@ -3116,7 +3118,7 @@ VOID NTAPI PhpPointerListDeleteProcedure( * Decodes an index stored in a free entry. */ FORCEINLINE ULONG PhpDecodePointerListIndex( - __in PVOID Index + _In_ PVOID Index ) { // At least with Microsoft's compiler, shift right on @@ -3130,14 +3132,14 @@ FORCEINLINE ULONG PhpDecodePointerListIndex( * Encodes an index for storage in a free entry. */ FORCEINLINE PVOID PhpEncodePointerListIndex( - __in ULONG Index + _In_ ULONG Index ) { return (PVOID)(((ULONG_PTR)Index << 1) | 0x1); } FORCEINLINE HANDLE PhpPointerListIndexToHandle( - __in ULONG Index + _In_ ULONG Index ) { // Add one to allow NULL handles to indicate @@ -3146,7 +3148,7 @@ FORCEINLINE HANDLE PhpPointerListIndexToHandle( } FORCEINLINE ULONG PhpPointerListHandleToIndex( - __in HANDLE Handle + _In_ HANDLE Handle ) { return (ULONG)Handle - 1; @@ -3163,8 +3165,8 @@ FORCEINLINE ULONG PhpPointerListHandleToIndex( * the pointer is removed from the pointer list. */ HANDLE PhAddItemPointerList( - __inout PPH_POINTER_LIST PointerList, - __in PVOID Pointer + _Inout_ PPH_POINTER_LIST PointerList, + _In_ PVOID Pointer ) { ULONG index; @@ -3200,10 +3202,10 @@ HANDLE PhAddItemPointerList( } BOOLEAN PhEnumPointerListEx( - __in PPH_POINTER_LIST PointerList, - __inout PULONG EnumerationKey, - __out PVOID *Pointer, - __out PHANDLE PointerHandle + _In_ PPH_POINTER_LIST PointerList, + _Inout_ PULONG EnumerationKey, + _Out_ PVOID *Pointer, + _Out_ PHANDLE PointerHandle ) { ULONG index; @@ -3239,8 +3241,8 @@ BOOLEAN PhEnumPointerListEx( * list, NULL is returned. */ HANDLE PhFindItemPointerList( - __in PPH_POINTER_LIST PointerList, - __in PVOID Pointer + _In_ PPH_POINTER_LIST PointerList, + _In_ PVOID Pointer ) { ULONG i; @@ -3268,8 +3270,8 @@ HANDLE PhFindItemPointerList( * before calling the function. */ VOID PhRemoveItemPointerList( - __inout PPH_POINTER_LIST PointerList, - __in HANDLE PointerHandle + _Inout_ PPH_POINTER_LIST PointerList, + _In_ HANDLE PointerHandle ) { ULONG index; @@ -3285,7 +3287,7 @@ VOID PhRemoveItemPointerList( } FORCEINLINE ULONG PhpValidateHash( - __in ULONG Hash + _In_ ULONG Hash ) { // No point in using a full hash when we're going to @@ -3301,8 +3303,8 @@ FORCEINLINE ULONG PhpValidateHash( } FORCEINLINE ULONG PhpIndexFromHash( - __in PPH_HASHTABLE Hashtable, - __in ULONG Hash + _In_ PPH_HASHTABLE Hashtable, + _In_ ULONG Hash ) { #ifdef PH_HASHTABLE_POWER_OF_TWO_SIZE @@ -3313,7 +3315,7 @@ FORCEINLINE ULONG PhpIndexFromHash( } FORCEINLINE ULONG PhpGetNumberOfBuckets( - __in ULONG Capacity + _In_ ULONG Capacity ) { #ifdef PH_HASHTABLE_POWER_OF_TWO_SIZE @@ -3336,10 +3338,10 @@ FORCEINLINE ULONG PhpGetNumberOfBuckets( * allocate storage for initially. */ PPH_HASHTABLE PhCreateHashtable( - __in ULONG EntrySize, - __in PPH_HASHTABLE_COMPARE_FUNCTION CompareFunction, - __in PPH_HASHTABLE_HASH_FUNCTION HashFunction, - __in ULONG InitialCapacity + _In_ ULONG EntrySize, + _In_ PPH_HASHTABLE_COMPARE_FUNCTION CompareFunction, + _In_ PPH_HASHTABLE_HASH_FUNCTION HashFunction, + _In_ ULONG InitialCapacity ) { PPH_HASHTABLE hashtable; @@ -3378,8 +3380,8 @@ PPH_HASHTABLE PhCreateHashtable( } VOID PhpHashtableDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_HASHTABLE hashtable = (PPH_HASHTABLE)Object; @@ -3389,8 +3391,8 @@ VOID PhpHashtableDeleteProcedure( } VOID PhpResizeHashtable( - __inout PPH_HASHTABLE Hashtable, - __in ULONG NewCapacity + _Inout_ PPH_HASHTABLE Hashtable, + _In_ ULONG NewCapacity ) { PPH_HASHTABLE_ENTRY entry; @@ -3431,10 +3433,10 @@ VOID PhpResizeHashtable( } FORCEINLINE PVOID PhpAddEntryHashtable( - __inout PPH_HASHTABLE Hashtable, - __in PVOID Entry, - __in BOOLEAN CheckForDuplicate, - __out_opt PBOOLEAN Added + _Inout_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry, + _In_ BOOLEAN CheckForDuplicate, + _Out_opt_ PBOOLEAN Added ) { ULONG hashCode; // hash code of the new entry @@ -3515,8 +3517,8 @@ FORCEINLINE PVOID PhpAddEntryHashtable( * aligned, even on 64-bit systems. */ PVOID PhAddEntryHashtable( - __inout PPH_HASHTABLE Hashtable, - __in PVOID Entry + _Inout_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry ) { PVOID entry; @@ -3550,9 +3552,9 @@ PVOID PhAddEntryHashtable( * aligned, even on 64-bit systems. */ PVOID PhAddEntryHashtableEx( - __inout PPH_HASHTABLE Hashtable, - __in PVOID Entry, - __out_opt PBOOLEAN Added + _Inout_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry, + _Out_opt_ PBOOLEAN Added ) { return PhpAddEntryHashtable(Hashtable, Entry, TRUE, Added); @@ -3564,7 +3566,7 @@ PVOID PhAddEntryHashtableEx( * \param Hashtable A hashtable object. */ VOID PhClearHashtable( - __inout PPH_HASHTABLE Hashtable + _Inout_ PPH_HASHTABLE Hashtable ) { if (Hashtable->Count > 0) @@ -3598,9 +3600,9 @@ VOID PhClearHashtable( * restart the enumeration. */ BOOLEAN PhEnumHashtable( - __in PPH_HASHTABLE Hashtable, - __out PVOID *Entry, - __inout PULONG EnumerationKey + _In_ PPH_HASHTABLE Hashtable, + _Out_ PVOID *Entry, + _Inout_ PULONG EnumerationKey ) { while (*EnumerationKey < Hashtable->NextEntry) @@ -3637,8 +3639,8 @@ BOOLEAN PhEnumHashtable( * work with them. */ PVOID PhFindEntryHashtable( - __in PPH_HASHTABLE Hashtable, - __in PVOID Entry + _In_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry ) { ULONG hashCode; @@ -3677,8 +3679,8 @@ PVOID PhFindEntryHashtable( * entry. */ BOOLEAN PhRemoveEntryHashtable( - __inout PPH_HASHTABLE Hashtable, - __in PVOID Entry + _Inout_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry ) { ULONG hashCode; @@ -3729,8 +3731,8 @@ BOOLEAN PhRemoveEntryHashtable( * \param Length The number of bytes to hash. */ ULONG FASTCALL PhfHashBytesHsieh( - __in PUCHAR Bytes, - __in SIZE_T Length + _In_ PUCHAR Bytes, + _In_ SIZE_T Length ) { // Hsieh hash, http://www.azillionmonkeys.com/qed/hash.html @@ -3791,8 +3793,8 @@ ULONG FASTCALL PhfHashBytesHsieh( * \param Length The number of bytes to hash. */ ULONG FASTCALL PhfHashBytesMurmur( - __in PUCHAR Bytes, - __in SIZE_T Length + _In_ PUCHAR Bytes, + _In_ SIZE_T Length ) { // Murmur hash, http://murmurhash.googlepages.com @@ -3842,8 +3844,8 @@ ULONG FASTCALL PhfHashBytesMurmur( * \param Length The number of bytes to hash. */ ULONG FASTCALL PhfHashBytesSdbm( - __in PUCHAR Bytes, - __in SIZE_T Length + _In_ PUCHAR Bytes, + _In_ SIZE_T Length ) { ULONG hash = (ULONG)Length; @@ -3859,8 +3861,8 @@ ULONG FASTCALL PhfHashBytesSdbm( } BOOLEAN NTAPI PhpSimpleHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PPH_KEY_VALUE_PAIR entry1 = Entry1; @@ -3870,7 +3872,7 @@ BOOLEAN NTAPI PhpSimpleHashtableCompareFunction( } ULONG NTAPI PhpSimpleHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PPH_KEY_VALUE_PAIR entry = Entry; @@ -3883,7 +3885,7 @@ ULONG NTAPI PhpSimpleHashtableHashFunction( } PPH_HASHTABLE PhCreateSimpleHashtable( - __in ULONG InitialCapacity + _In_ ULONG InitialCapacity ) { return PhCreateHashtable( @@ -3895,9 +3897,9 @@ PPH_HASHTABLE PhCreateSimpleHashtable( } PVOID PhAddItemSimpleHashtable( - __inout PPH_HASHTABLE SimpleHashtable, - __in_opt PVOID Key, - __in_opt PVOID Value + _Inout_ PPH_HASHTABLE SimpleHashtable, + _In_opt_ PVOID Key, + _In_opt_ PVOID Value ) { PH_KEY_VALUE_PAIR entry; @@ -3912,8 +3914,8 @@ PVOID PhAddItemSimpleHashtable( } PVOID *PhFindItemSimpleHashtable( - __in PPH_HASHTABLE SimpleHashtable, - __in_opt PVOID Key + _In_ PPH_HASHTABLE SimpleHashtable, + _In_opt_ PVOID Key ) { PH_KEY_VALUE_PAIR lookupEntry; @@ -3929,8 +3931,8 @@ PVOID *PhFindItemSimpleHashtable( } BOOLEAN PhRemoveItemSimpleHashtable( - __inout PPH_HASHTABLE SimpleHashtable, - __in_opt PVOID Key + _Inout_ PPH_HASHTABLE SimpleHashtable, + _In_opt_ PVOID Key ) { PH_KEY_VALUE_PAIR lookupEntry; @@ -3949,9 +3951,9 @@ BOOLEAN PhRemoveItemSimpleHashtable( * to store. */ VOID PhInitializeFreeList( - __out PPH_FREE_LIST FreeList, - __in SIZE_T Size, - __in ULONG MaximumCount + _Out_ PPH_FREE_LIST FreeList, + _In_ SIZE_T Size, + _In_ ULONG MaximumCount ) { RtlInitializeSListHead(&FreeList->ListHead); @@ -3966,7 +3968,7 @@ VOID PhInitializeFreeList( * \param FreeList A pointer to the free list object. */ VOID PhDeleteFreeList( - __inout PPH_FREE_LIST FreeList + _Inout_ PPH_FREE_LIST FreeList ) { PPH_FREE_LIST_ENTRY entry; @@ -3993,7 +3995,7 @@ VOID PhDeleteFreeList( * aligned at MEMORY_ALLOCATION_ALIGNMENT bytes. */ PVOID PhAllocateFromFreeList( - __inout PPH_FREE_LIST FreeList + _Inout_ PPH_FREE_LIST FreeList ) { PPH_FREE_LIST_ENTRY entry; @@ -4021,8 +4023,8 @@ PVOID PhAllocateFromFreeList( * \param Memory A pointer to a block of memory. */ VOID PhFreeToFreeList( - __inout PPH_FREE_LIST FreeList, - __in PVOID Memory + _Inout_ PPH_FREE_LIST FreeList, + _In_ PVOID Memory ) { PPH_FREE_LIST_ENTRY entry; @@ -4048,7 +4050,7 @@ VOID PhFreeToFreeList( * \param Callback A pointer to a callback object. */ VOID PhInitializeCallback( - __out PPH_CALLBACK Callback + _Out_ PPH_CALLBACK Callback ) { InitializeListHead(&Callback->ListHead); @@ -4062,7 +4064,7 @@ VOID PhInitializeCallback( * \param Callback A pointer to a callback object. */ VOID PhDeleteCallback( - __inout PPH_CALLBACK Callback + _Inout_ PPH_CALLBACK Callback ) { // Nothing for now @@ -4082,10 +4084,10 @@ VOID PhDeleteCallback( * unregistered the callback. */ VOID PhRegisterCallback( - __inout PPH_CALLBACK Callback, - __in PPH_CALLBACK_FUNCTION Function, - __in_opt PVOID Context, - __out PPH_CALLBACK_REGISTRATION Registration + _Inout_ PPH_CALLBACK Callback, + _In_ PPH_CALLBACK_FUNCTION Function, + _In_opt_ PVOID Context, + _Out_ PPH_CALLBACK_REGISTRATION Registration ) { PhRegisterCallbackEx( @@ -4113,11 +4115,11 @@ VOID PhRegisterCallback( * unregistered the callback. */ VOID PhRegisterCallbackEx( - __inout PPH_CALLBACK Callback, - __in PPH_CALLBACK_FUNCTION Function, - __in_opt PVOID Context, - __in USHORT Flags, - __out PPH_CALLBACK_REGISTRATION Registration + _Inout_ PPH_CALLBACK Callback, + _In_ PPH_CALLBACK_FUNCTION Function, + _In_opt_ PVOID Context, + _In_ USHORT Flags, + _Out_ PPH_CALLBACK_REGISTRATION Registration ) { Registration->Function = Function; @@ -4144,8 +4146,8 @@ VOID PhRegisterCallbackEx( * from within the same function will result in a deadlock. */ VOID PhUnregisterCallback( - __inout PPH_CALLBACK Callback, - __inout PPH_CALLBACK_REGISTRATION Registration + _Inout_ PPH_CALLBACK Callback, + _Inout_ PPH_CALLBACK_REGISTRATION Registration ) { Registration->Unregistering = TRUE; @@ -4169,8 +4171,8 @@ VOID PhUnregisterCallback( * functions. */ VOID PhInvokeCallback( - __in PPH_CALLBACK Callback, - __in_opt PVOID Parameter + _In_ PPH_CALLBACK Callback, + _In_opt_ PVOID Parameter ) { PLIST_ENTRY listEntry; @@ -4222,7 +4224,7 @@ VOID PhInvokeCallback( * specified number. */ ULONG PhGetPrimeNumber( - __in ULONG Minimum + _In_ ULONG Minimum ) { ULONG i, j; @@ -4259,7 +4261,7 @@ ULONG PhGetPrimeNumber( * Rounds up a number to the next power of two. */ ULONG PhRoundUpToPowerOfTwo( - __in ULONG Number + _In_ ULONG Number ) { Number--; @@ -4277,8 +4279,8 @@ ULONG PhRoundUpToPowerOfTwo( * Performs exponentiation. */ ULONG PhExponentiate( - __in ULONG Base, - __in ULONG Exponent + _In_ ULONG Base, + _In_ ULONG Exponent ) { ULONG result = 1; @@ -4299,8 +4301,8 @@ ULONG PhExponentiate( * Performs 64-bit exponentiation. */ ULONG64 PhExponentiate64( - __in ULONG64 Base, - __in ULONG Exponent + _In_ ULONG64 Base, + _In_ ULONG Exponent ) { ULONG64 result = 1; @@ -4324,7 +4326,7 @@ ULONG64 PhExponentiate64( * This is the same as the position of the highest set bit. */ ULONG PhLog2( - __in ULONG Exponent + _In_ ULONG Exponent ) { ULONG result = 0; @@ -4349,8 +4351,8 @@ ULONG PhLog2( * \return TRUE if the string was successfully converted, otherwise FALSE. */ BOOLEAN PhHexStringToBuffer( - __in PPH_STRINGREF String, - __out_bcount(String->Length / sizeof(WCHAR) / 2) PUCHAR Buffer + _In_ PPH_STRINGREF String, + _Out_writes_bytes_(String->Length / sizeof(WCHAR) / 2) PUCHAR Buffer ) { SIZE_T i; @@ -4381,19 +4383,43 @@ BOOLEAN PhHexStringToBuffer( * \return A string containing a sequence of hexadecimal digits. */ PPH_STRING PhBufferToHexString( - __in PUCHAR Buffer, - __in ULONG Length + _In_reads_bytes_(Length) PUCHAR Buffer, + _In_ ULONG Length ) { + return PhBufferToHexStringEx(Buffer, Length, FALSE); +} + +/** + * Converts a byte array into a sequence of hexadecimal digits. + * + * \param Buffer The input buffer. + * \param Length The number of bytes to convert. + * \param UpperCase TRUE to use uppercase characters, otherwise FALSE. + * + * \return A string containing a sequence of hexadecimal digits. + */ +PPH_STRING PhBufferToHexStringEx( + _In_reads_bytes_(Length) PUCHAR Buffer, + _In_ ULONG Length, + _In_ BOOLEAN UpperCase + ) +{ + PCHAR table; PPH_STRING string; ULONG i; + if (UpperCase) + table = PhIntegerToCharUpper; + else + table = PhIntegerToChar; + string = PhCreateStringEx(NULL, Length * 2 * sizeof(WCHAR)); for (i = 0; i < Length; i++) { - string->Buffer[i * 2] = PhIntegerToChar[Buffer[i] >> 4]; - string->Buffer[i * 2 + 1] = PhIntegerToChar[Buffer[i] & 0xf]; + string->Buffer[i * 2] = table[Buffer[i] >> 4]; + string->Buffer[i * 2 + 1] = table[Buffer[i] & 0xf]; } return string; @@ -4409,9 +4435,9 @@ PPH_STRING PhBufferToHexString( * \param Integer The resulting integer. */ BOOLEAN PhpStringToInteger64( - __in PPH_STRINGREF String, - __in ULONG Base, - __out PULONG64 Integer + _In_ PPH_STRINGREF String, + _In_ ULONG Base, + _Out_ PULONG64 Integer ) { BOOLEAN valid = TRUE; @@ -4464,9 +4490,9 @@ BOOLEAN PhpStringToInteger64( * used. */ BOOLEAN PhStringToInteger64( - __in PPH_STRINGREF String, - __in_opt ULONG Base, - __out_opt PLONG64 Integer + _In_ PPH_STRINGREF String, + _In_opt_ ULONG Base, + _Out_opt_ PLONG64 Integer ) { BOOLEAN valid; @@ -4566,9 +4592,9 @@ BOOLEAN PhStringToInteger64( * occurred. */ PPH_STRING PhIntegerToString64( - __in LONG64 Integer, - __in_opt ULONG Base, - __in BOOLEAN Signed + _In_ LONG64 Integer, + _In_opt_ ULONG Base, + _In_ BOOLEAN Signed ) { PH_FORMAT format; @@ -4591,9 +4617,9 @@ PPH_STRING PhIntegerToString64( } VOID PhPrintTimeSpan( - __out_ecount(PH_TIMESPAN_STR_LEN_1) PWSTR Destination, - __in ULONG64 Ticks, - __in_opt ULONG Mode + _Out_writes_(PH_TIMESPAN_STR_LEN_1) PWSTR Destination, + _In_ ULONG64 Ticks, + _In_opt_ ULONG Mode ) { switch (Mode) diff --git a/2.x/trunk/phlib/basesupa.c b/2.x/trunk/phlib/basesupa.c index 19689ffa6..02c40672c 100644 --- a/2.x/trunk/phlib/basesupa.c +++ b/2.x/trunk/phlib/basesupa.c @@ -23,29 +23,29 @@ #include PPH_STRING PhaCreateString( - __in PWSTR Buffer + _In_ PWSTR Buffer ) { return PHA_DEREFERENCE(PhCreateString(Buffer)); } PPH_STRING PhaCreateStringEx( - __in_opt PWSTR Buffer, - __in SIZE_T Length + _In_opt_ PWSTR Buffer, + _In_ SIZE_T Length ) { return PHA_DEREFERENCE(PhCreateStringEx(Buffer, Length)); } PPH_STRING PhaDuplicateString( - __in PPH_STRING String + _In_ PPH_STRING String ) { return PHA_DEREFERENCE(PhDuplicateString(String)); } PPH_STRING PhaConcatStrings( - __in ULONG Count, + _In_ ULONG Count, ... ) { @@ -57,15 +57,15 @@ PPH_STRING PhaConcatStrings( } PPH_STRING PhaConcatStrings2( - __in PWSTR String1, - __in PWSTR String2 + _In_ PWSTR String1, + _In_ PWSTR String2 ) { return PHA_DEREFERENCE(PhConcatStrings2(String1, String2)); } PPH_STRING PhaFormatString( - __in __format_string PWSTR Format, + _In_ _Printf_format_string_ PWSTR Format, ... ) { @@ -77,7 +77,7 @@ PPH_STRING PhaFormatString( } PPH_STRING PhaLowerString( - __in PPH_STRING String + _In_ PPH_STRING String ) { PPH_STRING newString; @@ -89,7 +89,7 @@ PPH_STRING PhaLowerString( } PPH_STRING PhaUpperString( - __in PPH_STRING String + _In_ PPH_STRING String ) { PPH_STRING newString; @@ -101,9 +101,9 @@ PPH_STRING PhaUpperString( } PPH_STRING PhaSubstring( - __in PPH_STRING String, - __in SIZE_T StartIndex, - __in SIZE_T Count + _In_ PPH_STRING String, + _In_ SIZE_T StartIndex, + _In_ SIZE_T Count ) { return PHA_DEREFERENCE(PhSubstring(String, StartIndex, Count)); diff --git a/2.x/trunk/phlib/basesupx.c b/2.x/trunk/phlib/basesupx.c index cc742b816..b7ed5132a 100644 --- a/2.x/trunk/phlib/basesupx.c +++ b/2.x/trunk/phlib/basesupx.c @@ -273,9 +273,9 @@ unsigned short __cdecl ph_chksum(unsigned long sum, unsigned short *buf, unsigne #endif VOID FASTCALL PhxpfFillMemoryUlongFallback( - __inout PULONG Memory, - __in ULONG Value, - __in ULONG Count + _Inout_ PULONG Memory, + _In_ ULONG Value, + _In_ ULONG Count ) { if (Count != 0) @@ -299,9 +299,9 @@ PHLIBAPI VOID FASTCALL PhxfFillMemoryUlong( - __inout PULONG Memory, - __in ULONG Value, - __in ULONG Count + _Inout_ PULONG Memory, + _In_ ULONG Value, + _In_ ULONG Count ) { __m128i pattern; @@ -368,9 +368,9 @@ PhxfFillMemoryUlong( } VOID FASTCALL PhxpfAddInt32Fallback( - __inout PLONG A, - __in PLONG B, - __in ULONG Count + _Inout_ PLONG A, + _In_ PLONG B, + _In_ ULONG Count ) { while (Count--) @@ -387,9 +387,9 @@ VOID FASTCALL PhxpfAddInt32Fallback( * \param Count The number of elements. */ VOID FASTCALL PhxfAddInt32( - __inout __needsAlign(16) PLONG A, - __in __needsAlign(16) PLONG B, - __in ULONG Count + _Inout_ _Needs_align_(16) PLONG A, + _In_ _Needs_align_(16) PLONG B, + _In_ ULONG Count ) { if (!USER_SHARED_DATA->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE]) @@ -436,9 +436,9 @@ VOID FASTCALL PhxfAddInt32( * \param Count The number of elements. */ VOID FASTCALL PhxfAddInt32U( - __inout PLONG A, - __in PLONG B, - __in ULONG Count + _Inout_ PLONG A, + _In_ PLONG B, + _In_ ULONG Count ) { if (!USER_SHARED_DATA->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE]) @@ -505,9 +505,9 @@ VOID FASTCALL PhxfAddInt32U( } VOID FASTCALL PhxpfDivideSingleFallback( - __inout PFLOAT A, - __in PFLOAT B, - __in ULONG Count + _Inout_ PFLOAT A, + _In_ PFLOAT B, + _In_ ULONG Count ) { while (Count--) @@ -523,9 +523,9 @@ VOID FASTCALL PhxpfDivideSingleFallback( * \param Count The number of elements. */ VOID FASTCALL PhxfDivideSingleU( - __inout PFLOAT A, - __in PFLOAT B, - __in ULONG Count + _Inout_ PFLOAT A, + _In_ PFLOAT B, + _In_ ULONG Count ) { if (!USER_SHARED_DATA->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE]) @@ -592,9 +592,9 @@ VOID FASTCALL PhxfDivideSingleU( } VOID FASTCALL PhxpfDivideSingle2Fallback( - __inout PFLOAT A, - __in FLOAT B, - __in ULONG Count + _Inout_ PFLOAT A, + _In_ FLOAT B, + _In_ ULONG Count ) { while (Count--) @@ -610,9 +610,9 @@ VOID FASTCALL PhxpfDivideSingle2Fallback( * \param Count The number of elements. */ VOID FASTCALL PhxfDivideSingle2U( - __inout PFLOAT A, - __in FLOAT B, - __in ULONG Count + _Inout_ PFLOAT A, + _In_ FLOAT B, + _In_ ULONG Count ) { PFLOAT endA; diff --git a/2.x/trunk/phlib/circbuf_i.h b/2.x/trunk/phlib/circbuf_i.h index 13fc044f8..c5e49b093 100644 --- a/2.x/trunk/phlib/circbuf_i.h +++ b/2.x/trunk/phlib/circbuf_i.h @@ -3,8 +3,8 @@ #include VOID T___(PhInitializeCircularBuffer, T)( - __out T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in ULONG Size + _Out_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ ULONG Size ) { #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE @@ -20,15 +20,15 @@ VOID T___(PhInitializeCircularBuffer, T)( } VOID T___(PhDeleteCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer ) { PhFree(Buffer->Data); } VOID T___(PhResizeCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in ULONG NewSize + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ ULONG NewSize ) { T *newData; @@ -83,7 +83,7 @@ VOID T___(PhResizeCircularBuffer, T)( } VOID T___(PhClearCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer ) { Buffer->Count = 0; @@ -91,9 +91,9 @@ VOID T___(PhClearCircularBuffer, T)( } VOID T___(PhCopyCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __out_ecount(Count) T *Destination, - __in ULONG Count + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _Out_writes_(Count) T *Destination, + _In_ ULONG Count ) { ULONG tailSize; diff --git a/2.x/trunk/phlib/collect.c b/2.x/trunk/phlib/collect.c index 144bbe73b..fa8e67ec4 100644 --- a/2.x/trunk/phlib/collect.c +++ b/2.x/trunk/phlib/collect.c @@ -29,8 +29,8 @@ * \param CompareFunction A function used to compare tree elements. */ VOID PhInitializeAvlTree( - __out PPH_AVL_TREE Tree, - __in PPH_AVL_TREE_COMPARE_FUNCTION CompareFunction + _Out_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_TREE_COMPARE_FUNCTION CompareFunction ) { Tree->Root.Parent = NULL; @@ -50,9 +50,9 @@ VOID PhInitializeAvlTree( * \param Result The result of the search. */ FORCEINLINE PPH_AVL_LINKS PhpFindElementAvlTree( - __in PPH_AVL_TREE Tree, - __in PPH_AVL_LINKS Element, - __out PLONG Result + _In_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_LINKS Element, + _Out_ PLONG Result ) { PPH_AVL_LINKS links; @@ -107,7 +107,7 @@ FORCEINLINE PPH_AVL_LINKS PhpFindElementAvlTree( } FORCEINLINE VOID PhpRotateLeftAvlLinks( - __deref_inout PPH_AVL_LINKS *Root + _Inout_ PPH_AVL_LINKS *Root ) { PPH_AVL_LINKS P; @@ -153,7 +153,7 @@ FORCEINLINE VOID PhpRotateLeftAvlLinks( } FORCEINLINE VOID PhpRotateLeftTwiceAvlLinks( - __deref_inout PPH_AVL_LINKS *Root + _Inout_ PPH_AVL_LINKS *Root ) { PPH_AVL_LINKS P; @@ -222,7 +222,7 @@ FORCEINLINE VOID PhpRotateLeftTwiceAvlLinks( } FORCEINLINE VOID PhpRotateRightAvlLinks( - __deref_inout PPH_AVL_LINKS *Root + _Inout_ PPH_AVL_LINKS *Root ) { PPH_AVL_LINKS Q; @@ -268,7 +268,7 @@ FORCEINLINE VOID PhpRotateRightAvlLinks( } FORCEINLINE VOID PhpRotateRightTwiceAvlLinks( - __deref_inout PPH_AVL_LINKS *Root + _Inout_ PPH_AVL_LINKS *Root ) { PPH_AVL_LINKS P; @@ -337,7 +337,7 @@ FORCEINLINE VOID PhpRotateRightTwiceAvlLinks( } ULONG PhpRebalanceAvlLinks( - __deref_inout PPH_AVL_LINKS *Root + _Inout_ PPH_AVL_LINKS *Root ) { PPH_AVL_LINKS P; @@ -490,8 +490,8 @@ ULONG PhpRebalanceAvlLinks( * element. */ PPH_AVL_LINKS PhAddElementAvlTree( - __inout PPH_AVL_TREE Tree, - __out PPH_AVL_LINKS Element + _Inout_ PPH_AVL_TREE Tree, + _Out_ PPH_AVL_LINKS Element ) { LONG result; @@ -575,8 +575,8 @@ PPH_AVL_LINKS PhAddElementAvlTree( * \param Element An element already present in the tree. */ VOID PhRemoveElementAvlTree( - __inout PPH_AVL_TREE Tree, - __inout PPH_AVL_LINKS Element + _Inout_ PPH_AVL_TREE Tree, + _Inout_ PPH_AVL_LINKS Element ) { PPH_AVL_LINKS newElement; @@ -704,8 +704,8 @@ VOID PhRemoveElementAvlTree( * \return The element, or NULL if it could not be found. */ PPH_AVL_LINKS PhFindElementAvlTree( - __in PPH_AVL_TREE Tree, - __in PPH_AVL_LINKS Element + _In_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_LINKS Element ) { PPH_AVL_LINKS links; @@ -729,9 +729,9 @@ PPH_AVL_LINKS PhFindElementAvlTree( * \return The closest element, or NULL if the tree is empty. */ PPH_AVL_LINKS PhFindElementAvlTree2( - __in PPH_AVL_TREE Tree, - __in PPH_AVL_LINKS Element, - __out PLONG Result + _In_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_LINKS Element, + _Out_ PLONG Result ) { PPH_AVL_LINKS links; @@ -755,7 +755,7 @@ PPH_AVL_LINKS PhFindElementAvlTree2( * \return An element, or NULL if the tree is empty. */ PPH_AVL_LINKS PhMinimumElementAvlTree( - __in PPH_AVL_TREE Tree + _In_ PPH_AVL_TREE Tree ) { PPH_AVL_LINKS links; @@ -779,7 +779,7 @@ PPH_AVL_LINKS PhMinimumElementAvlTree( * \return An element, or NULL if the tree is empty. */ PPH_AVL_LINKS PhMaximumElementAvlTree( - __in PPH_AVL_TREE Tree + _In_ PPH_AVL_TREE Tree ) { PPH_AVL_LINKS links; @@ -804,7 +804,7 @@ PPH_AVL_LINKS PhMaximumElementAvlTree( * more elements. */ PPH_AVL_LINKS PhSuccessorElementAvlTree( - __in PPH_AVL_LINKS Element + _In_ PPH_AVL_LINKS Element ) { PPH_AVL_LINKS links; @@ -846,7 +846,7 @@ PPH_AVL_LINKS PhSuccessorElementAvlTree( * more elements. */ PPH_AVL_LINKS PhPredecessorElementAvlTree( - __in PPH_AVL_LINKS Element + _In_ PPH_AVL_LINKS Element ) { PPH_AVL_LINKS links; @@ -892,10 +892,10 @@ PPH_AVL_LINKS PhPredecessorElementAvlTree( * function. */ VOID PhEnumAvlTree( - __in PPH_AVL_TREE Tree, - __in PH_TREE_ENUMERATION_ORDER Order, - __in PPH_ENUM_AVL_TREE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_AVL_TREE Tree, + _In_ PH_TREE_ENUMERATION_ORDER Order, + _In_ PPH_ENUM_AVL_TREE_CALLBACK Callback, + _In_opt_ PVOID Context ) { // The maximum height of an AVL tree is around 1.44 * log2(n). diff --git a/2.x/trunk/phlib/colorbox.c b/2.x/trunk/phlib/colorbox.c index bd2867668..4d534cb98 100644 --- a/2.x/trunk/phlib/colorbox.c +++ b/2.x/trunk/phlib/colorbox.c @@ -30,10 +30,10 @@ typedef struct _PHP_COLORBOX_CONTEXT } PHP_COLORBOX_CONTEXT, *PPHP_COLORBOX_CONTEXT; LRESULT CALLBACK PhpColorBoxWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); BOOLEAN PhColorBoxInitialization( @@ -61,7 +61,7 @@ BOOLEAN PhColorBoxInitialization( } VOID PhpCreateColorBoxContext( - __out PPHP_COLORBOX_CONTEXT *Context + _Out_ PPHP_COLORBOX_CONTEXT *Context ) { PPHP_COLORBOX_CONTEXT context; @@ -75,17 +75,17 @@ VOID PhpCreateColorBoxContext( } VOID PhpFreeColorBoxContext( - __in __post_invalid PPHP_COLORBOX_CONTEXT Context + _In_ _Post_invalid_ PPHP_COLORBOX_CONTEXT Context ) { PhFree(Context); } LRESULT CALLBACK PhpColorBoxWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPHP_COLORBOX_CONTEXT context; diff --git a/2.x/trunk/phlib/cpysave.c b/2.x/trunk/phlib/cpysave.c index 75b14e426..16bfd59cb 100644 --- a/2.x/trunk/phlib/cpysave.c +++ b/2.x/trunk/phlib/cpysave.c @@ -27,8 +27,8 @@ #define TAB_SIZE 8 VOID PhpEscapeStringForCsv( - __inout PPH_STRING_BUILDER StringBuilder, - __in PPH_STRING String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ PPH_STRING String ) { SIZE_T i; @@ -80,9 +80,9 @@ VOID PhpEscapeStringForCsv( * \param Columns The number of columns in the table. */ VOID PhaCreateTextTable( - __out PPH_STRING ***Table, - __in ULONG Rows, - __in ULONG Columns + _Out_ PPH_STRING ***Table, + _In_ ULONG Rows, + _In_ ULONG Columns ) { PPH_STRING **table; @@ -113,10 +113,10 @@ VOID PhaCreateTextTable( * string objects are not auto-dereferenced. */ PPH_LIST PhaFormatTextTable( - __in PPH_STRING **Table, - __in ULONG Rows, - __in ULONG Columns, - __in ULONG Mode + _In_ PPH_STRING **Table, + _In_ ULONG Rows, + _In_ ULONG Columns, + _In_ ULONG Mode ) { PPH_LIST lines; @@ -237,10 +237,10 @@ PPH_LIST PhaFormatTextTable( } VOID PhMapDisplayIndexTreeNew( - __in HWND TreeNewHandle, - __out_opt PULONG *DisplayToId, - __out_opt PWSTR **DisplayToText, - __out PULONG NumberOfColumns + _In_ HWND TreeNewHandle, + _Out_opt_ PULONG *DisplayToId, + _Out_opt_ PWSTR **DisplayToText, + _Out_ PULONG NumberOfColumns ) { PPH_TREENEW_COLUMN fixedColumn; @@ -289,8 +289,8 @@ VOID PhMapDisplayIndexTreeNew( } PPH_STRING PhGetTreeNewText( - __in HWND TreeNewHandle, - __reserved ULONG Reserved + _In_ HWND TreeNewHandle, + _Reserved_ ULONG Reserved ) { PH_STRING_BUILDER stringBuilder; @@ -338,8 +338,8 @@ PPH_STRING PhGetTreeNewText( } PPH_LIST PhGetGenericTreeNewLines( - __in HWND TreeNewHandle, - __in ULONG Mode + _In_ HWND TreeNewHandle, + _In_ ULONG Mode ) { PH_AUTO_POOL autoPool; @@ -405,11 +405,11 @@ PPH_LIST PhGetGenericTreeNewLines( } VOID PhaMapDisplayIndexListView( - __in HWND ListViewHandle, - __out_ecount(Count) PULONG DisplayToId, - __out_ecount_opt(Count) PPH_STRING *DisplayToText, - __in ULONG Count, - __out PULONG NumberOfColumns + _In_ HWND ListViewHandle, + _Out_writes_(Count) PULONG DisplayToId, + _Out_writes_opt_(Count) PPH_STRING *DisplayToText, + _In_ ULONG Count, + _Out_ PULONG NumberOfColumns ) { LVCOLUMN lvColumn; @@ -447,9 +447,9 @@ VOID PhaMapDisplayIndexListView( } PPH_STRING PhaGetListViewItemText( - __in HWND ListViewHandle, - __in INT Index, - __in INT SubItemIndex + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT SubItemIndex ) { PPH_STRING buffer; @@ -487,7 +487,7 @@ PPH_STRING PhaGetListViewItemText( } PPH_STRING PhGetListViewText( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ) { PH_AUTO_POOL autoPool; @@ -529,8 +529,8 @@ PPH_STRING PhGetListViewText( } PPH_LIST PhGetListViewLines( - __in HWND ListViewHandle, - __in ULONG Mode + _In_ HWND ListViewHandle, + _In_ ULONG Mode ) { PH_AUTO_POOL autoPool; diff --git a/2.x/trunk/phlib/data.c b/2.x/trunk/phlib/data.c index f0de53b85..7e50fd954 100644 --- a/2.x/trunk/phlib/data.c +++ b/2.x/trunk/phlib/data.c @@ -197,5 +197,7 @@ WCHAR *PhKWaitReasonNames[MaximumWaitReason] = L"WrYieldExecution", L"WrFastMutex", L"WrGuardedMutex", - L"WrRundown" + L"WrRundown", + L"WrAlertByThreadId", + L"WrDeferredPreempt" }; diff --git a/2.x/trunk/phlib/dspick.c b/2.x/trunk/phlib/dspick.c index c420e3da5..e562ad8b0 100644 --- a/2.x/trunk/phlib/dspick.c +++ b/2.x/trunk/phlib/dspick.c @@ -62,14 +62,14 @@ IDsObjectPicker *PhpCreateDsObjectPicker( } VOID PhFreeDsObjectPickerDialog( - __in PVOID PickerDialog + _In_ PVOID PickerDialog ) { IDsObjectPicker_Release((IDsObjectPicker *)PickerDialog); } PVOID PhCreateDsObjectPickerDialog( - __in ULONG Flags + _In_ ULONG Flags ) { IDsObjectPicker *picker; @@ -121,7 +121,7 @@ PVOID PhCreateDsObjectPickerDialog( } PDS_SELECTION_LIST PhpGetDsSelectionList( - __in IDataObject *Selections + _In_ IDataObject *Selections ) { FORMATETC format; @@ -147,9 +147,9 @@ PDS_SELECTION_LIST PhpGetDsSelectionList( } BOOLEAN PhShowDsObjectPickerDialog( - __in HWND hWnd, - __in PVOID PickerDialog, - __out PPH_DSPICK_OBJECTS *Objects + _In_ HWND hWnd, + _In_ PVOID PickerDialog, + _Out_ PPH_DSPICK_OBJECTS *Objects ) { IDsObjectPicker *picker; @@ -229,7 +229,7 @@ BOOLEAN PhShowDsObjectPickerDialog( } VOID PhFreeDsObjectPickerObjects( - __in PPH_DSPICK_OBJECTS Objects + _In_ PPH_DSPICK_OBJECTS Objects ) { ULONG i; diff --git a/2.x/trunk/phlib/emenu.c b/2.x/trunk/phlib/emenu.c index c5f16dc7d..8dba936e0 100644 --- a/2.x/trunk/phlib/emenu.c +++ b/2.x/trunk/phlib/emenu.c @@ -70,11 +70,11 @@ PPH_EMENU_ITEM PhAllocateEMenuItem( * \param Context A user-defined value. */ PPH_EMENU_ITEM PhCreateEMenuItem( - __in ULONG Flags, - __in ULONG Id, - __in PWSTR Text, - __in_opt PWSTR Bitmap, - __in_opt PVOID Context + _In_ ULONG Flags, + _In_ ULONG Id, + _In_ PWSTR Text, + _In_opt_ PWSTR Bitmap, + _In_opt_ PVOID Context ) { PPH_EMENU_ITEM item; @@ -104,7 +104,7 @@ PPH_EMENU_ITEM PhCreateEMenuItem( * It is safe to call this function while enumerating menu items. */ VOID PhpDestroyEMenuItem( - __in PPH_EMENU_ITEM Item + _In_ PPH_EMENU_ITEM Item ) { if (Item->DeleteFunction) @@ -138,7 +138,7 @@ VOID PhpDestroyEMenuItem( * \remarks The menu item is automatically removed from its parent. */ VOID PhDestroyEMenuItem( - __in PPH_EMENU_ITEM Item + _In_ PPH_EMENU_ITEM Item ) { // Remove the item from its parent, if it has one. @@ -168,10 +168,10 @@ VOID PhDestroyEMenuItem( * be found. */ PPH_EMENU_ITEM PhFindEMenuItem( - __in PPH_EMENU_ITEM Item, - __in ULONG Flags, - __in_opt PWSTR Text, - __in_opt ULONG Id + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Flags, + _In_opt_ PWSTR Text, + _In_opt_ ULONG Id ) { return PhFindEMenuItemEx(Item, Flags, Text, Id, NULL, NULL); @@ -201,12 +201,12 @@ PPH_EMENU_ITEM PhFindEMenuItem( * be found. */ PPH_EMENU_ITEM PhFindEMenuItemEx( - __in PPH_EMENU_ITEM Item, - __in ULONG Flags, - __in_opt PWSTR Text, - __in_opt ULONG Id, - __out_opt PPH_EMENU_ITEM *FoundParent, - __out_opt PULONG FoundIndex + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Flags, + _In_opt_ PWSTR Text, + _In_opt_ ULONG Id, + _Out_opt_ PPH_EMENU_ITEM *FoundParent, + _Out_opt_ PULONG FoundIndex ) { PH_STRINGREF searchText; @@ -294,8 +294,8 @@ PPH_EMENU_ITEM PhFindEMenuItemEx( * was not found in the parent menu item. */ ULONG PhIndexOfEMenuItem( - __in PPH_EMENU_ITEM Parent, - __in PPH_EMENU_ITEM Item + _In_ PPH_EMENU_ITEM Parent, + _In_ PPH_EMENU_ITEM Item ) { if (!Parent->Items) @@ -314,9 +314,9 @@ ULONG PhIndexOfEMenuItem( * at the last position. */ VOID PhInsertEMenuItem( - __inout PPH_EMENU_ITEM Parent, - __inout PPH_EMENU_ITEM Item, - __in ULONG Index + _Inout_ PPH_EMENU_ITEM Parent, + _Inout_ PPH_EMENU_ITEM Item, + _In_ ULONG Index ) { // Remove the item from its old parent if it has one. @@ -348,9 +348,9 @@ VOID PhInsertEMenuItem( * \a Item is specified, this parameter is ignored. */ BOOLEAN PhRemoveEMenuItem( - __inout_opt PPH_EMENU_ITEM Parent, - __in_opt PPH_EMENU_ITEM Item, - __in_opt ULONG Index + _Inout_opt_ PPH_EMENU_ITEM Parent, + _In_opt_ PPH_EMENU_ITEM Item, + _In_opt_ ULONG Index ) { if (Item) @@ -386,7 +386,7 @@ BOOLEAN PhRemoveEMenuItem( * \param Parent The parent menu item. */ VOID PhRemoveAllEMenuItems( - __inout PPH_EMENU_ITEM Parent + _Inout_ PPH_EMENU_ITEM Parent ) { ULONG i; @@ -424,7 +424,7 @@ PPH_EMENU PhCreateEMenu( * \param Menu A root menu. */ VOID PhDestroyEMenu( - __in PPH_EMENU Menu + _In_ PPH_EMENU Menu ) { ULONG i; @@ -443,7 +443,7 @@ VOID PhDestroyEMenu( * resulting from a call to PhEMenuToHMenu(). */ VOID PhInitializeEMenuData( - __out PPH_EMENU_DATA Data + _Out_ PPH_EMENU_DATA Data ) { Data->IdToItem = PhCreateList(16); @@ -454,7 +454,7 @@ VOID PhInitializeEMenuData( * PhInitializeEMenuData(). */ VOID PhDeleteEMenuData( - __inout PPH_EMENU_DATA Data + _Inout_ PPH_EMENU_DATA Data ) { PhDereferenceObject(Data->IdToItem); @@ -476,9 +476,9 @@ VOID PhDeleteEMenuData( * DestroyMenu() when it is no longer needed. */ HMENU PhEMenuToHMenu( - __in PPH_EMENU_ITEM Menu, - __in ULONG Flags, - __inout_opt PPH_EMENU_DATA Data + _In_ PPH_EMENU_ITEM Menu, + _In_ ULONG Flags, + _Inout_opt_ PPH_EMENU_DATA Data ) { HMENU menuHandle; @@ -508,10 +508,10 @@ HMENU PhEMenuToHMenu( * prior to calling this function. */ VOID PhEMenuToHMenu2( - __in HMENU MenuHandle, - __in PPH_EMENU_ITEM Menu, - __in ULONG Flags, - __inout_opt PPH_EMENU_DATA Data + _In_ HMENU MenuHandle, + _In_ PPH_EMENU_ITEM Menu, + _In_ ULONG Flags, + _Inout_opt_ PPH_EMENU_DATA Data ) { ULONG i; @@ -613,8 +613,8 @@ VOID PhEMenuToHMenu2( * \param MenuHandle A menu handle. */ VOID PhHMenuToEMenuItem( - __inout PPH_EMENU_ITEM MenuItem, - __in HMENU MenuHandle + _Inout_ PPH_EMENU_ITEM MenuItem, + _In_ HMENU MenuHandle ) { ULONG i; @@ -681,10 +681,10 @@ VOID PhHMenuToEMenuItem( * to use the root menu. */ VOID PhLoadResourceEMenuItem( - __inout PPH_EMENU_ITEM MenuItem, - __in HINSTANCE InstanceHandle, - __in PWSTR Resource, - __in ULONG SubMenuIndex + _Inout_ PPH_EMENU_ITEM MenuItem, + _In_ HINSTANCE InstanceHandle, + _In_ PWSTR Resource, + _In_ ULONG SubMenuIndex ) { HMENU menu; @@ -719,12 +719,12 @@ VOID PhLoadResourceEMenuItem( * \return The selected menu item, or NULL if the menu was cancelled. */ PPH_EMENU_ITEM PhShowEMenu( - __in PPH_EMENU Menu, - __in HWND WindowHandle, - __in ULONG Flags, - __in ULONG Align, - __in ULONG X, - __in ULONG Y + _In_ PPH_EMENU Menu, + _In_ HWND WindowHandle, + _In_ ULONG Flags, + _In_ ULONG Align, + _In_ ULONG X, + _In_ ULONG Y ) { PPH_EMENU_ITEM selectedItem; @@ -798,10 +798,10 @@ PPH_EMENU_ITEM PhShowEMenu( * \param Value The new value of the flags. */ BOOLEAN PhSetFlagsEMenuItem( - __in PPH_EMENU_ITEM Item, - __in ULONG Id, - __in ULONG Mask, - __in ULONG Value + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Id, + _In_ ULONG Mask, + _In_ ULONG Value ) { PPH_EMENU_ITEM item; @@ -829,9 +829,9 @@ BOOLEAN PhSetFlagsEMenuItem( * \param Value The new value of the flags. */ VOID PhSetFlagsAllEMenuItems( - __in PPH_EMENU_ITEM Item, - __in ULONG Mask, - __in ULONG Value + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Mask, + _In_ ULONG Value ) { ULONG i; diff --git a/2.x/trunk/phlib/error.c b/2.x/trunk/phlib/error.c index ae6d83d36..2594f5bfe 100644 --- a/2.x/trunk/phlib/error.c +++ b/2.x/trunk/phlib/error.c @@ -29,7 +29,7 @@ * properly, unlike RtlNtStatusToDosError. */ ULONG PhNtStatusToDosError( - __in NTSTATUS Status + _In_ NTSTATUS Status ) { if (NT_NTWIN32(Status)) // RtlNtStatusToDosError doesn't seem to handle these cases correctly @@ -45,7 +45,7 @@ ULONG PhNtStatusToDosError( * Other status values are wrapped using FACILITY_NTWIN32. */ NTSTATUS PhDosErrorToNtStatus( - __in ULONG DosError + _In_ ULONG DosError ) { switch (DosError) @@ -71,7 +71,7 @@ NTSTATUS PhDosErrorToNtStatus( * cannot be not found. */ BOOLEAN PhNtStatusFileNotFound( - __in NTSTATUS Status + _In_ NTSTATUS Status ) { switch (Status) diff --git a/2.x/trunk/phlib/extlv.c b/2.x/trunk/phlib/extlv.c index 5ecb58997..8d1fd6bbc 100644 --- a/2.x/trunk/phlib/extlv.c +++ b/2.x/trunk/phlib/extlv.c @@ -60,39 +60,39 @@ typedef struct _PH_EXTLV_CONTEXT } PH_EXTLV_CONTEXT, *PPH_EXTLV_CONTEXT; LRESULT CALLBACK PhpExtendedListViewWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT PhpExtendedListViewCompareFunc( - __in LPARAM lParam1, - __in LPARAM lParam2, - __in LPARAM lParamSort + _In_ LPARAM lParam1, + _In_ LPARAM lParam2, + _In_ LPARAM lParamSort ); INT PhpExtendedListViewCompareFastFunc( - __in LPARAM lParam1, - __in LPARAM lParam2, - __in LPARAM lParamSort + _In_ LPARAM lParam1, + _In_ LPARAM lParam2, + _In_ LPARAM lParamSort ); INT PhpCompareListViewItems( - __in PPH_EXTLV_CONTEXT Context, - __in INT X, - __in INT Y, - __in PVOID XParam, - __in PVOID YParam, - __in ULONG Column, - __in BOOLEAN EnableDefault + _In_ PPH_EXTLV_CONTEXT Context, + _In_ INT X, + _In_ INT Y, + _In_ PVOID XParam, + _In_ PVOID YParam, + _In_ ULONG Column, + _In_ BOOLEAN EnableDefault ); INT PhpDefaultCompareListViewItems( - __in PPH_EXTLV_CONTEXT Context, - __in INT X, - __in INT Y, - __in ULONG Column + _In_ PPH_EXTLV_CONTEXT Context, + _In_ INT X, + _In_ INT Y, + _In_ ULONG Column ); static PWSTR PhpMakeExtLvContextAtom( @@ -108,7 +108,7 @@ static PWSTR PhpMakeExtLvContextAtom( * \param hWnd A handle to the list view control. */ VOID PhSetExtendedListView( - __in HWND hWnd + _In_ HWND hWnd ) { WNDPROC oldWndProc; @@ -142,10 +142,10 @@ VOID PhSetExtendedListView( } LRESULT CALLBACK PhpExtendedListViewWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPH_EXTLV_CONTEXT context; @@ -491,9 +491,9 @@ LRESULT CALLBACK PhpExtendedListViewWndProc( * \param Order The sort order of the item. */ VOID PhSetHeaderSortIcon( - __in HWND hwnd, - __in INT Index, - __in PH_SORT_ORDER Order + _In_ HWND hwnd, + _In_ INT Index, + _In_ PH_SORT_ORDER Order ) { ULONG count; @@ -534,9 +534,9 @@ VOID PhSetHeaderSortIcon( } static INT PhpExtendedListViewCompareFunc( - __in LPARAM lParam1, - __in LPARAM lParam2, - __in LPARAM lParamSort + _In_ LPARAM lParam1, + _In_ LPARAM lParam2, + _In_ LPARAM lParamSort ) { PPH_EXTLV_CONTEXT context = (PPH_EXTLV_CONTEXT)lParamSort; @@ -611,9 +611,9 @@ static INT PhpExtendedListViewCompareFunc( } static INT PhpExtendedListViewCompareFastFunc( - __in LPARAM lParam1, - __in LPARAM lParam2, - __in LPARAM lParamSort + _In_ LPARAM lParam1, + _In_ LPARAM lParam2, + _In_ LPARAM lParamSort ) { PPH_EXTLV_CONTEXT context = (PPH_EXTLV_CONTEXT)lParamSort; @@ -668,13 +668,13 @@ static INT PhpExtendedListViewCompareFastFunc( } static FORCEINLINE INT PhpCompareListViewItems( - __in PPH_EXTLV_CONTEXT Context, - __in INT X, - __in INT Y, - __in PVOID XParam, - __in PVOID YParam, - __in ULONG Column, - __in BOOLEAN EnableDefault + _In_ PPH_EXTLV_CONTEXT Context, + _In_ INT X, + _In_ INT Y, + _In_ PVOID XParam, + _In_ PVOID YParam, + _In_ ULONG Column, + _In_ BOOLEAN EnableDefault ) { INT result = 0; @@ -707,10 +707,10 @@ static FORCEINLINE INT PhpCompareListViewItems( } static INT PhpDefaultCompareListViewItems( - __in PPH_EXTLV_CONTEXT Context, - __in INT X, - __in INT Y, - __in ULONG Column + _In_ PPH_EXTLV_CONTEXT Context, + _In_ INT X, + _In_ INT Y, + _In_ ULONG Column ) { WCHAR xText[261]; diff --git a/2.x/trunk/phlib/fastlock.c b/2.x/trunk/phlib/fastlock.c index ec5bd89e4..3b419d4f8 100644 --- a/2.x/trunk/phlib/fastlock.c +++ b/2.x/trunk/phlib/fastlock.c @@ -65,7 +65,7 @@ VOID PhFastLockInitialization( } VOID PhInitializeFastLock( - __out PPH_FAST_LOCK FastLock + _Out_ PPH_FAST_LOCK FastLock ) { FastLock->Value = 0; @@ -74,7 +74,7 @@ VOID PhInitializeFastLock( } VOID PhDeleteFastLock( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ) { if (FastLock->ExclusiveWakeEvent) @@ -91,7 +91,7 @@ VOID PhDeleteFastLock( } FORCEINLINE VOID PhpEnsureEventCreated( - __inout PHANDLE Handle + _Inout_ PHANDLE Handle ) { HANDLE handle; @@ -111,8 +111,8 @@ FORCEINLINE VOID PhpEnsureEventCreated( } } -__mayRaise VOID FASTCALL PhfAcquireFastLockExclusive( - __inout PPH_FAST_LOCK FastLock +_May_raise_ VOID FASTCALL PhfAcquireFastLockExclusive( + _Inout_ PPH_FAST_LOCK FastLock ) { ULONG value; @@ -166,8 +166,8 @@ __mayRaise VOID FASTCALL PhfAcquireFastLockExclusive( } } -__mayRaise VOID FASTCALL PhfAcquireFastLockShared( - __inout PPH_FAST_LOCK FastLock +_May_raise_ VOID FASTCALL PhfAcquireFastLockShared( + _Inout_ PPH_FAST_LOCK FastLock ) { ULONG value; @@ -230,7 +230,7 @@ __mayRaise VOID FASTCALL PhfAcquireFastLockShared( } VOID FASTCALL PhfReleaseFastLockExclusive( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ) { ULONG value; @@ -276,7 +276,7 @@ VOID FASTCALL PhfReleaseFastLockExclusive( } VOID FASTCALL PhfReleaseFastLockShared( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ) { ULONG value; @@ -323,7 +323,7 @@ VOID FASTCALL PhfReleaseFastLockShared( } BOOLEAN FASTCALL PhfTryAcquireFastLockExclusive( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ) { ULONG value; @@ -341,7 +341,7 @@ BOOLEAN FASTCALL PhfTryAcquireFastLockExclusive( } BOOLEAN FASTCALL PhfTryAcquireFastLockShared( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ) { ULONG value; diff --git a/2.x/trunk/phlib/filepool.c b/2.x/trunk/phlib/filepool.c index cab626d0f..01a8a5f38 100644 --- a/2.x/trunk/phlib/filepool.c +++ b/2.x/trunk/phlib/filepool.c @@ -91,10 +91,10 @@ * \param Parameters Parameters for on-disk and runtime structures. */ NTSTATUS PhCreateFilePool( - __out PPH_FILE_POOL *Pool, - __in HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __in_opt PPH_FILE_POOL_PARAMETERS Parameters + _Out_ PPH_FILE_POOL *Pool, + _In_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _In_opt_ PPH_FILE_POOL_PARAMETERS Parameters ) { NTSTATUS status; @@ -263,12 +263,12 @@ NTSTATUS PhCreateFilePool( * \param Parameters Parameters for on-disk and runtime structures. */ NTSTATUS PhCreateFilePool2( - __out PPH_FILE_POOL *Pool, - __in PWSTR FileName, - __in BOOLEAN ReadOnly, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in_opt PPH_FILE_POOL_PARAMETERS Parameters + _Out_ PPH_FILE_POOL *Pool, + _In_ PWSTR FileName, + _In_ BOOLEAN ReadOnly, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_opt_ PPH_FILE_POOL_PARAMETERS Parameters ) { NTSTATUS status; @@ -319,7 +319,7 @@ NTSTATUS PhCreateFilePool2( * \param Pool The file pool. */ VOID PhDestroyFilePool( - __in __post_invalid PPH_FILE_POOL Pool + _In_ _Post_invalid_ PPH_FILE_POOL Pool ) { ULONG i; @@ -364,7 +364,7 @@ VOID PhDestroyFilePool( * and modified if necessary. */ NTSTATUS PhpValidateFilePoolParameters( - __inout PPH_FILE_POOL_PARAMETERS Parameters + _Inout_ PPH_FILE_POOL_PARAMETERS Parameters ) { NTSTATUS status = STATUS_SUCCESS; @@ -393,7 +393,7 @@ NTSTATUS PhpValidateFilePoolParameters( * the default parameter values. */ VOID PhpSetDefaultFilePoolParameters( - __out PPH_FILE_POOL_PARAMETERS Parameters + _Out_ PPH_FILE_POOL_PARAMETERS Parameters ) { Parameters->SegmentShift = 18; // 256kB @@ -417,9 +417,9 @@ VOID PhpSetDefaultFilePoolParameters( * if you need a permanent reference to the allocated block. */ PVOID PhAllocateFilePool( - __inout PPH_FILE_POOL Pool, - __in ULONG Size, - __out_opt PULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Size, + _Out_opt_ PULONG Rva ) { PPH_FP_BLOCK_HEADER blockHeader; @@ -515,10 +515,10 @@ PVOID PhAllocateFilePool( * \param Block A pointer to the block. */ VOID PhpFreeFilePool( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex, - __in PPH_FP_BLOCK_HEADER FirstBlock, - __in PVOID Block + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex, + _In_ PPH_FP_BLOCK_HEADER FirstBlock, + _In_ PVOID Block ) { PPH_FP_SEGMENT_HEADER segmentHeader; @@ -547,8 +547,8 @@ VOID PhpFreeFilePool( * PhDereferenceFilePoolByRva(). */ VOID PhFreeFilePool( - __inout PPH_FILE_POOL Pool, - __in PVOID Block + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Block ) { PPH_FILE_POOL_VIEW view; @@ -571,8 +571,8 @@ VOID PhFreeFilePool( * \param Rva The relative virtual address of the block. */ BOOLEAN PhFreeFilePoolByRva( - __inout PPH_FILE_POOL Pool, - __in ULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Rva ) { ULONG segmentIndex; @@ -602,8 +602,8 @@ BOOLEAN PhFreeFilePoolByRva( * \param Address An address. */ VOID PhReferenceFilePool( - __inout PPH_FILE_POOL Pool, - __in PVOID Address + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Address ) { PhFppReferenceSegmentByBase(Pool, Address); @@ -616,8 +616,8 @@ VOID PhReferenceFilePool( * \param Address An address. */ VOID PhDereferenceFilePool( - __inout PPH_FILE_POOL Pool, - __in PVOID Address + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Address ) { PhFppDereferenceSegmentByBase(Pool, Address); @@ -631,8 +631,8 @@ VOID PhDereferenceFilePool( * \param Rva A relative virtual address. */ PVOID PhReferenceFilePoolByRva( - __inout PPH_FILE_POOL Pool, - __in ULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Rva ) { ULONG segmentIndex; @@ -662,8 +662,8 @@ PVOID PhReferenceFilePoolByRva( * \param Rva A relative virtual address. */ BOOLEAN PhDereferenceFilePoolByRva( - __inout PPH_FILE_POOL Pool, - __in ULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Rva ) { ULONG segmentIndex; @@ -690,8 +690,8 @@ BOOLEAN PhDereferenceFilePoolByRva( * \remarks No reference counts are changed. */ ULONG PhEncodeRvaFilePool( - __in PPH_FILE_POOL Pool, - __in PVOID Address + _In_ PPH_FILE_POOL Pool, + _In_ PVOID Address ) { PPH_FILE_POOL_VIEW view; @@ -714,8 +714,8 @@ ULONG PhEncodeRvaFilePool( * \param Context A variable which receives the user data. */ VOID PhGetUserContextFilePool( - __in PPH_FILE_POOL Pool, - __out PULONGLONG Context + _In_ PPH_FILE_POOL Pool, + _Out_ PULONGLONG Context ) { *Context = Pool->Header->UserContext; @@ -728,8 +728,8 @@ VOID PhGetUserContextFilePool( * \param Context A variable which contains the user data. */ VOID PhSetUserContextFilePool( - __inout PPH_FILE_POOL Pool, - __in PULONGLONG Context + _Inout_ PPH_FILE_POOL Pool, + _In_ PULONGLONG Context ) { Pool->Header->UserContext = *Context; @@ -742,8 +742,8 @@ VOID PhSetUserContextFilePool( * \param NewSize The new size of the file, in bytes. */ NTSTATUS PhFppExtendRange( - __inout PPH_FILE_POOL Pool, - __in ULONG NewSize + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG NewSize ) { LARGE_INTEGER newSectionSize; @@ -762,10 +762,10 @@ NTSTATUS PhFppExtendRange( * \param Base A variable which receives the base address of the view. */ NTSTATUS PhFppMapRange( - __inout PPH_FILE_POOL Pool, - __in ULONG Offset, - __in ULONG Size, - __out PVOID *Base + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Offset, + _In_ ULONG Size, + _Out_ PVOID *Base ) { NTSTATUS status; @@ -803,8 +803,8 @@ NTSTATUS PhFppMapRange( * \param Base The base address of the view. */ NTSTATUS PhFppUnmapRange( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ) { return NtUnmapViewOfSection(NtCurrentProcess(), Base); @@ -820,9 +820,9 @@ NTSTATUS PhFppUnmapRange( * from the segment, excluding the blocks comprising the segment header. */ VOID PhFppInitializeSegment( - __inout PPH_FILE_POOL Pool, - __out PPH_FP_BLOCK_HEADER BlockOfSegmentHeader, - __in ULONG AdditionalBlocksUsed + _Inout_ PPH_FILE_POOL Pool, + _Out_ PPH_FP_BLOCK_HEADER BlockOfSegmentHeader, + _In_ ULONG AdditionalBlocksUsed ) { PPH_FP_SEGMENT_HEADER segmentHeader; @@ -848,8 +848,8 @@ VOID PhFppInitializeSegment( * \return A pointer to the first block of the segment. */ PPH_FP_BLOCK_HEADER PhFppAllocateSegment( - __inout PPH_FILE_POOL Pool, - __out PULONG NewSegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _Out_ PULONG NewSegmentIndex ) { ULONG newSize; @@ -881,8 +881,8 @@ PPH_FP_BLOCK_HEADER PhFppAllocateSegment( * \param FirstBlock The first block of the segment. */ PPH_FP_SEGMENT_HEADER PhFppGetHeaderSegment( - __inout PPH_FILE_POOL Pool, - __in PPH_FP_BLOCK_HEADER FirstBlock + _Inout_ PPH_FILE_POOL Pool, + _In_ PPH_FP_BLOCK_HEADER FirstBlock ) { if (FirstBlock != Pool->FirstBlockOfFirstSegment) @@ -897,8 +897,8 @@ PPH_FP_SEGMENT_HEADER PhFppGetHeaderSegment( } VOID PhFppAddViewByIndex( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { ULONG index; @@ -919,8 +919,8 @@ VOID PhFppAddViewByIndex( } VOID PhFppRemoveViewByIndex( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { ULONG index; @@ -958,8 +958,8 @@ VOID PhFppRemoveViewByIndex( * present for the segment. */ PPH_FILE_POOL_VIEW PhFppFindViewByIndex( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ) { ULONG index; @@ -989,8 +989,8 @@ PPH_FILE_POOL_VIEW PhFppFindViewByIndex( } LONG NTAPI PhpFilePoolViewByBaseCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ) { PPH_FILE_POOL_VIEW view1 = CONTAINING_RECORD(Links1, PH_FILE_POOL_VIEW, ByBaseLinks); @@ -1000,16 +1000,16 @@ LONG NTAPI PhpFilePoolViewByBaseCompareFunction( } VOID PhFppAddViewByBase( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { PhAddElementAvlTree(&Pool->ByBaseSet, &View->ByBaseLinks); } VOID PhFppRemoveViewByBase( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { PhRemoveElementAvlTree(&Pool->ByBaseSet, &View->ByBaseLinks); @@ -1025,8 +1025,8 @@ VOID PhFppRemoveViewByBase( * is present for the address. */ PPH_FILE_POOL_VIEW PhFppFindViewByBase( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ) { PPH_FILE_POOL_VIEW view; @@ -1073,8 +1073,8 @@ PPH_FILE_POOL_VIEW PhFppFindViewByBase( } PPH_FILE_POOL_VIEW PhFppCreateView( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ) { PPH_FILE_POOL_VIEW view; @@ -1100,8 +1100,8 @@ PPH_FILE_POOL_VIEW PhFppCreateView( } VOID PhFppDestroyView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { PhFppUnmapRange(Pool, View->Base); @@ -1112,8 +1112,8 @@ VOID PhFppDestroyView( } VOID PhFppActivateView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { RemoveEntryList(&View->InactiveViewsListEntry); @@ -1121,8 +1121,8 @@ VOID PhFppActivateView( } VOID PhFppDeactivateView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { InsertHeadList(&Pool->InactiveViewsListHead, &View->InactiveViewsListEntry); @@ -1144,8 +1144,8 @@ VOID PhFppDeactivateView( } VOID PhFppReferenceView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { if (View->RefCount == 0) @@ -1158,8 +1158,8 @@ VOID PhFppReferenceView( } VOID PhFppDereferenceView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ) { if (--View->RefCount == 0) @@ -1172,8 +1172,8 @@ VOID PhFppDereferenceView( } PPH_FP_BLOCK_HEADER PhFppReferenceSegment( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ) { PPH_FILE_POOL_VIEW view; @@ -1204,8 +1204,8 @@ PPH_FP_BLOCK_HEADER PhFppReferenceSegment( } VOID PhFppDereferenceSegment( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ) { PPH_FILE_POOL_VIEW view; @@ -1219,8 +1219,8 @@ VOID PhFppDereferenceSegment( } VOID PhFppReferenceSegmentByBase( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ) { PPH_FILE_POOL_VIEW view; @@ -1234,8 +1234,8 @@ VOID PhFppReferenceSegmentByBase( } VOID PhFppDereferenceSegmentByBase( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ) { PPH_FILE_POOL_VIEW view; @@ -1260,10 +1260,10 @@ VOID PhFppDereferenceSegmentByBase( * an insufficient number of contiguous free blocks for the allocation. */ PPH_FP_BLOCK_HEADER PhFppAllocateBlocks( - __inout PPH_FILE_POOL Pool, - __in PPH_FP_BLOCK_HEADER FirstBlock, - __inout PPH_FP_SEGMENT_HEADER SegmentHeader, - __in ULONG NumberOfBlocks + _Inout_ PPH_FILE_POOL Pool, + _In_ PPH_FP_BLOCK_HEADER FirstBlock, + _Inout_ PPH_FP_SEGMENT_HEADER SegmentHeader, + _In_ ULONG NumberOfBlocks ) { RTL_BITMAP bitmap; @@ -1305,10 +1305,10 @@ PPH_FP_BLOCK_HEADER PhFppAllocateBlocks( * \param BlockHeader The header of the allocated span. */ VOID PhFppFreeBlocks( - __inout PPH_FILE_POOL Pool, - __in PPH_FP_BLOCK_HEADER FirstBlock, - __inout PPH_FP_SEGMENT_HEADER SegmentHeader, - __in PPH_FP_BLOCK_HEADER BlockHeader + _Inout_ PPH_FILE_POOL Pool, + _In_ PPH_FP_BLOCK_HEADER FirstBlock, + _Inout_ PPH_FP_SEGMENT_HEADER SegmentHeader, + _In_ PPH_FP_BLOCK_HEADER BlockHeader ) { RTL_BITMAP bitmap; @@ -1331,8 +1331,8 @@ VOID PhFppFreeBlocks( * \param NumberOfBlocks The number of free or required blocks. */ ULONG PhFppComputeFreeListIndex( - __in PPH_FILE_POOL Pool, - __in ULONG NumberOfBlocks + _In_ PPH_FILE_POOL Pool, + _In_ ULONG NumberOfBlocks ) { // Use a binary tree to speed up comparison. @@ -1382,10 +1382,10 @@ ULONG PhFppComputeFreeListIndex( * \param SegmentHeader The header of the segment. */ BOOLEAN PhFppInsertFreeList( - __inout PPH_FILE_POOL Pool, - __in ULONG FreeListIndex, - __in ULONG SegmentIndex, - __in PPH_FP_SEGMENT_HEADER SegmentHeader + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG FreeListIndex, + _In_ ULONG SegmentIndex, + _In_ PPH_FP_SEGMENT_HEADER SegmentHeader ) { ULONG oldSegmentIndex; @@ -1429,10 +1429,10 @@ BOOLEAN PhFppInsertFreeList( * \param SegmentHeader The header of the segment. */ BOOLEAN PhFppRemoveFreeList( - __inout PPH_FILE_POOL Pool, - __in ULONG FreeListIndex, - __in ULONG SegmentIndex, - __in PPH_FP_SEGMENT_HEADER SegmentHeader + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG FreeListIndex, + _In_ ULONG SegmentIndex, + _In_ PPH_FP_SEGMENT_HEADER SegmentHeader ) { ULONG flinkSegmentIndex; @@ -1499,8 +1499,8 @@ BOOLEAN PhFppRemoveFreeList( * \param Block A pointer to the body of the block. */ PPH_FP_BLOCK_HEADER PhFppGetHeaderBlock( - __in PPH_FILE_POOL Pool, - __in PVOID Block + _In_ PPH_FILE_POOL Pool, + _In_ PVOID Block ) { return CONTAINING_RECORD(Block, PH_FP_BLOCK_HEADER, Body); @@ -1515,10 +1515,10 @@ PPH_FP_BLOCK_HEADER PhFppGetHeaderBlock( * \param Address An address. */ ULONG PhFppEncodeRva( - __in PPH_FILE_POOL Pool, - __in ULONG SegmentIndex, - __in PPH_FP_BLOCK_HEADER FirstBlock, - __in PVOID Address + _In_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex, + _In_ PPH_FP_BLOCK_HEADER FirstBlock, + _In_ PVOID Address ) { return (SegmentIndex << Pool->SegmentShift) + (ULONG)((PCHAR)Address - (PCHAR)FirstBlock); @@ -1535,9 +1535,9 @@ ULONG PhFppEncodeRva( * if \a Rva is invalid. */ ULONG PhFppDecodeRva( - __in PPH_FILE_POOL Pool, - __in ULONG Rva, - __out PULONG SegmentIndex + _In_ PPH_FILE_POOL Pool, + _In_ ULONG Rva, + _Out_ PULONG SegmentIndex ) { ULONG segmentIndex; diff --git a/2.x/trunk/phlib/format.c b/2.x/trunk/phlib/format.c index 2d09c9711..47d90112c 100644 --- a/2.x/trunk/phlib/format.c +++ b/2.x/trunk/phlib/format.c @@ -78,9 +78,9 @@ static _locale_t PhpFormatUserLocale = NULL; * \param Output A buffer which will contain the converted string. */ VOID PhZeroExtendToUnicode( - __in_bcount(InputLength) PSTR Input, - __in ULONG InputLength, - __out_bcount(InputLength * 2) PWSTR Output + _In_reads_bytes_(InputLength) PSTR Input, + _In_ ULONG InputLength, + _Out_writes_bytes_(InputLength * 2) PWSTR Output ) { ULONG inputLength; @@ -113,10 +113,10 @@ VOID PhZeroExtendToUnicode( } PPH_STRING PhpResizeFormatBuffer( - __in PPH_STRING String, - __inout PSIZE_T AllocatedLength, - __in SIZE_T UsedLength, - __in SIZE_T NeededLength + _In_ PPH_STRING String, + _Inout_ PSIZE_T AllocatedLength, + _In_ SIZE_T UsedLength, + _In_ SIZE_T NeededLength ) { PPH_STRING newString; @@ -146,9 +146,9 @@ PPH_STRING PhpResizeFormatBuffer( * the string. If 0 is specified, a default value is used. */ PPH_STRING PhFormat( - __in_ecount(Count) PPH_FORMAT Format, - __in ULONG Count, - __in_opt SIZE_T InitialCapacity + _In_reads_(Count) PPH_FORMAT Format, + _In_ ULONG Count, + _In_opt_ SIZE_T InitialCapacity ) { PPH_STRING string; @@ -216,11 +216,11 @@ PPH_STRING PhFormat( * single null byte is written to the start of \a Buffer. */ BOOLEAN PhFormatToBuffer( - __in_ecount(Count) PPH_FORMAT Format, - __in ULONG Count, - __out_bcount_opt(BufferLength) PWSTR Buffer, - __in_opt SIZE_T BufferLength, - __out_opt PSIZE_T ReturnLength + _In_reads_(Count) PPH_FORMAT Format, + _In_ ULONG Count, + _Out_writes_bytes_opt_(BufferLength) PWSTR Buffer, + _In_opt_ SIZE_T BufferLength, + _Out_opt_ PSIZE_T ReturnLength ) { PWSTR buffer; diff --git a/2.x/trunk/phlib/global.c b/2.x/trunk/phlib/global.c index 522e2948b..0927e1c2b 100644 --- a/2.x/trunk/phlib/global.c +++ b/2.x/trunk/phlib/global.c @@ -2,7 +2,7 @@ * Process Hacker - * global variables and initialization functions * - * Copyright (C) 2010 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -24,11 +24,11 @@ #include VOID PhInitializeSecurity( - __in ULONG Flags + _In_ ULONG Flags ); BOOLEAN PhInitializeSystem( - __in ULONG Flags + _In_ ULONG Flags ); VOID PhInitializeSystemInformation( @@ -74,9 +74,9 @@ NTSTATUS PhInitializePhLib( } NTSTATUS PhInitializePhLibEx( - __in ULONG Flags, - __in_opt SIZE_T HeapReserveSize, - __in_opt SIZE_T HeapCommitSize + _In_ ULONG Flags, + _In_opt_ SIZE_T HeapReserveSize, + _In_opt_ SIZE_T HeapCommitSize ) { PhHeapHandle = RtlCreateHeap( @@ -123,7 +123,7 @@ NTSTATUS PhInitializePhLibEx( } static VOID PhInitializeSecurity( - __in ULONG Flags + _In_ ULONG Flags ) { HANDLE tokenHandle; @@ -152,7 +152,7 @@ static VOID PhInitializeSecurity( } static BOOLEAN PhInitializeSystem( - __in ULONG Flags + _In_ ULONG Flags ) { if (Flags & PHLIB_INIT_MODULE_IO_SUPPORT) @@ -172,10 +172,6 @@ static BOOLEAN PhInitializeSystem( PhHandleInfoInitialization(); } -#ifdef DEBUG - InitializeListHead(&PhDbgProviderListHead); -#endif - return TRUE; } @@ -253,7 +249,12 @@ static VOID PhInitializeWindowsVersion( { WindowsVersion = WINDOWS_8; } - else if (majorVersion == 6 && minorVersion > 2 || majorVersion > 6) + /* Windows 8.1 */ + else if (majorVersion == 6 && minorVersion == 3) + { + WindowsVersion = WINDOWS_81; + } + else if (majorVersion == 6 && minorVersion > 3 || majorVersion > 6) { WindowsVersion = WINDOWS_NEW; } diff --git a/2.x/trunk/phlib/graph.c b/2.x/trunk/phlib/graph.c index ba0e52df2..f428e26c3 100644 --- a/2.x/trunk/phlib/graph.c +++ b/2.x/trunk/phlib/graph.c @@ -24,7 +24,7 @@ #include #include -#define COLORREF_TO_BITS(Color) (_byteswap_ulong(Color) >> 8) +#define COLORREF_TO_BITS(Color) (_byteswap_ulong(Color) >> 8 | 0xff000000) typedef struct _PHP_GRAPH_CONTEXT { @@ -54,10 +54,10 @@ typedef struct _PHP_GRAPH_CONTEXT } PHP_GRAPH_CONTEXT, *PPHP_GRAPH_CONTEXT; LRESULT CALLBACK PhpGraphWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); RECT PhNormalGraphTextMargin = { 5, 5, 5, 5 }; @@ -97,8 +97,8 @@ BOOLEAN PhGraphControlInitialization( * whenever possible. */ VOID PhDrawGraph( - __in HDC hdc, - __in PPH_GRAPH_DRAW_INFO DrawInfo + _In_ HDC hdc, + _In_ PPH_GRAPH_DRAW_INFO DrawInfo ) { ULONG width; @@ -357,10 +357,10 @@ VOID PhDrawGraph( } FORCEINLINE VOID PhpGetGraphPoint( - __in PPH_GRAPH_DRAW_INFO DrawInfo, - __in ULONG Index, - __out PULONG H1, - __out PULONG H2 + _In_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ ULONG Index, + _Out_ PULONG H1, + _Out_ PULONG H2 ) { if (Index < DrawInfo->LineDataCount) @@ -411,9 +411,9 @@ FORCEINLINE VOID PhpGetGraphPoint( * is never used. */ VOID PhDrawGraphDirect( - __in HDC hdc, - __in PVOID Bits, - __in PPH_GRAPH_DRAW_INFO DrawInfo + _In_ HDC hdc, + _In_ PVOID Bits, + _In_ PPH_GRAPH_DRAW_INFO DrawInfo ) { PULONG bits; @@ -701,12 +701,12 @@ VOID PhDrawGraphDirect( * \param Align The alignment of the text box. */ VOID PhSetGraphText( - __in HDC hdc, - __inout PPH_GRAPH_DRAW_INFO DrawInfo, - __in PPH_STRINGREF Text, - __in PRECT Margin, - __in PRECT Padding, - __in ULONG Align + _In_ HDC hdc, + _Inout_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ PPH_STRINGREF Text, + _In_ PRECT Margin, + _In_ PRECT Padding, + _In_ ULONG Align ) { SIZE textSize; @@ -748,7 +748,7 @@ VOID PhSetGraphText( } VOID PhpCreateGraphContext( - __out PPHP_GRAPH_CONTEXT *Context + _Out_ PPHP_GRAPH_CONTEXT *Context ) { PPHP_GRAPH_CONTEXT context; @@ -782,7 +782,7 @@ VOID PhpCreateGraphContext( } VOID PhpFreeGraphContext( - __inout __post_invalid PPHP_GRAPH_CONTEXT Context + _Inout_ _Post_invalid_ PPHP_GRAPH_CONTEXT Context ) { PhFree(Context); @@ -796,7 +796,7 @@ static PWSTR PhpMakeGraphTooltipContextAtom( } static VOID PhpDeleteBufferedContext( - __in PPHP_GRAPH_CONTEXT Context + _In_ PPHP_GRAPH_CONTEXT Context ) { if (Context->BufferedContext) @@ -814,7 +814,7 @@ static VOID PhpDeleteBufferedContext( } static VOID PhpCreateBufferedContext( - __in PPHP_GRAPH_CONTEXT Context + _In_ PPHP_GRAPH_CONTEXT Context ) { HDC hdc; @@ -841,7 +841,7 @@ static VOID PhpCreateBufferedContext( } static VOID PhpDeleteFadeOutContext( - __in PPHP_GRAPH_CONTEXT Context + _In_ PPHP_GRAPH_CONTEXT Context ) { if (Context->FadeOutContext) @@ -857,7 +857,7 @@ static VOID PhpDeleteFadeOutContext( } static VOID PhpCreateFadeOutContext( - __in PPHP_GRAPH_CONTEXT Context + _In_ PPHP_GRAPH_CONTEXT Context ) { HDC hdc; @@ -916,8 +916,8 @@ static VOID PhpCreateFadeOutContext( } VOID PhpUpdateDrawInfo( - __in HWND hwnd, - __in PPHP_GRAPH_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_GRAPH_CONTEXT Context ) { PH_GRAPH_GETDRAWINFO getDrawInfo; @@ -934,8 +934,8 @@ VOID PhpUpdateDrawInfo( } VOID PhpDrawGraphControl( - __in HWND hwnd, - __in PPHP_GRAPH_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_GRAPH_CONTEXT Context ) { if (Context->BufferedBits) @@ -982,10 +982,10 @@ VOID PhpDrawGraphControl( } LRESULT CALLBACK PhpGraphWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPHP_GRAPH_CONTEXT context; @@ -1352,7 +1352,7 @@ LRESULT CALLBACK PhpGraphWndProc( * \param Buffers The buffer management structure. */ VOID PhInitializeGraphBuffers( - __out PPH_GRAPH_BUFFERS Buffers + _Out_ PPH_GRAPH_BUFFERS Buffers ) { Buffers->AllocatedCount = 0; @@ -1367,7 +1367,7 @@ VOID PhInitializeGraphBuffers( * \param Buffers The buffer management structure. */ VOID PhDeleteGraphBuffers( - __inout PPH_GRAPH_BUFFERS Buffers + _Inout_ PPH_GRAPH_BUFFERS Buffers ) { if (Buffers->Data1) PhFree(Buffers->Data1); @@ -1384,9 +1384,9 @@ VOID PhDeleteGraphBuffers( * The buffers are resized if needed. */ VOID PhGetDrawInfoGraphBuffers( - __inout PPH_GRAPH_BUFFERS Buffers, - __inout PPH_GRAPH_DRAW_INFO DrawInfo, - __in ULONG DataCount + _Inout_ PPH_GRAPH_BUFFERS Buffers, + _Inout_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ ULONG DataCount ) { DrawInfo->LineDataCount = min(DataCount, PH_GRAPH_DATA_COUNT(DrawInfo->Width, DrawInfo->Step)); @@ -1419,7 +1419,7 @@ VOID PhGetDrawInfoGraphBuffers( } VOID PhInitializeGraphState( - __out PPH_GRAPH_STATE State + _Out_ PPH_GRAPH_STATE State ) { PhInitializeGraphBuffers(&State->Buffers); @@ -1429,7 +1429,7 @@ VOID PhInitializeGraphState( } VOID PhDeleteGraphState( - __inout PPH_GRAPH_STATE State + _Inout_ PPH_GRAPH_STATE State ) { PhDeleteGraphBuffers(&State->Buffers); @@ -1438,9 +1438,9 @@ VOID PhDeleteGraphState( } VOID PhGraphStateGetDrawInfo( - __inout PPH_GRAPH_STATE State, - __in PPH_GRAPH_GETDRAWINFO GetDrawInfo, - __in ULONG DataCount + _Inout_ PPH_GRAPH_STATE State, + _In_ PPH_GRAPH_GETDRAWINFO GetDrawInfo, + _In_ ULONG DataCount ) { PhGetDrawInfoGraphBuffers(&State->Buffers, GetDrawInfo->DrawInfo, DataCount); diff --git a/2.x/trunk/phlib/guisup.c b/2.x/trunk/phlib/guisup.c index ea0baf5f9..33cb554b9 100644 --- a/2.x/trunk/phlib/guisup.c +++ b/2.x/trunk/phlib/guisup.c @@ -75,8 +75,8 @@ VOID PhGuiSupportInitialization( } VOID PhSetControlTheme( - __in HWND Handle, - __in PWSTR Theme + _In_ HWND Handle, + _In_ PWSTR Theme ) { if (WindowsVersion >= WINDOWS_VISTA) @@ -87,8 +87,8 @@ VOID PhSetControlTheme( } HWND PhCreateListViewControl( - __in HWND ParentHandle, - __in INT_PTR Id + _In_ HWND ParentHandle, + _In_ INT_PTR Id ) { return CreateWindow( @@ -107,13 +107,13 @@ HWND PhCreateListViewControl( } INT PhAddListViewColumn( - __in HWND ListViewHandle, - __in INT Index, - __in INT DisplayIndex, - __in INT SubItemIndex, - __in INT Format, - __in INT Width, - __in PWSTR Text + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT DisplayIndex, + _In_ INT SubItemIndex, + _In_ INT Format, + _In_ INT Width, + _In_ PWSTR Text ) { LVCOLUMN column; @@ -129,10 +129,10 @@ INT PhAddListViewColumn( } INT PhAddListViewItem( - __in HWND ListViewHandle, - __in INT Index, - __in PWSTR Text, - __in_opt PVOID Param + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ PWSTR Text, + _In_opt_ PVOID Param ) { LVITEM item; @@ -147,18 +147,18 @@ INT PhAddListViewItem( } INT PhFindListViewItemByFlags( - __in HWND ListViewHandle, - __in INT StartIndex, - __in ULONG Flags + _In_ HWND ListViewHandle, + _In_ INT StartIndex, + _In_ ULONG Flags ) { return ListView_GetNextItem(ListViewHandle, StartIndex, Flags); } INT PhFindListViewItemByParam( - __in HWND ListViewHandle, - __in INT StartIndex, - __in_opt PVOID Param + _In_ HWND ListViewHandle, + _In_ INT StartIndex, + _In_opt_ PVOID Param ) { LVFINDINFO findInfo; @@ -170,9 +170,9 @@ INT PhFindListViewItemByParam( } LOGICAL PhGetListViewItemImageIndex( - __in HWND ListViewHandle, - __in INT Index, - __out PINT ImageIndex + _In_ HWND ListViewHandle, + _In_ INT Index, + _Out_ PINT ImageIndex ) { LOGICAL result; @@ -193,9 +193,9 @@ LOGICAL PhGetListViewItemImageIndex( } LOGICAL PhGetListViewItemParam( - __in HWND ListViewHandle, - __in INT Index, - __out PVOID *Param + _In_ HWND ListViewHandle, + _In_ INT Index, + _Out_ PVOID *Param ) { LOGICAL result; @@ -216,17 +216,17 @@ LOGICAL PhGetListViewItemParam( } VOID PhRemoveListViewItem( - __in HWND ListViewHandle, - __in INT Index + _In_ HWND ListViewHandle, + _In_ INT Index ) { ListView_DeleteItem(ListViewHandle, Index); } VOID PhSetListViewItemImageIndex( - __in HWND ListViewHandle, - __in INT Index, - __in INT ImageIndex + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT ImageIndex ) { LVITEM item; @@ -240,9 +240,9 @@ VOID PhSetListViewItemImageIndex( } VOID PhSetListViewItemStateImage( - __in HWND ListViewHandle, - __in INT Index, - __in INT StateImage + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT StateImage ) { LVITEM item; @@ -257,10 +257,10 @@ VOID PhSetListViewItemStateImage( } VOID PhSetListViewSubItem( - __in HWND ListViewHandle, - __in INT Index, - __in INT SubItemIndex, - __in PWSTR Text + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT SubItemIndex, + _In_ PWSTR Text ) { LVITEM item; @@ -274,8 +274,8 @@ VOID PhSetListViewSubItem( } BOOLEAN PhLoadListViewColumnSettings( - __in HWND ListViewHandle, - __in PPH_STRING Settings + _In_ HWND ListViewHandle, + _In_ PPH_STRING Settings ) { #define ORDER_LIMIT 50 @@ -354,7 +354,7 @@ BOOLEAN PhLoadListViewColumnSettings( } PPH_STRING PhSaveListViewColumnSettings( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ) { PH_STRING_BUILDER stringBuilder; @@ -383,7 +383,7 @@ PPH_STRING PhSaveListViewColumnSettings( } HWND PhCreateTabControl( - __in HWND ParentHandle + _In_ HWND ParentHandle ) { HWND tabControlHandle; @@ -406,9 +406,9 @@ HWND PhCreateTabControl( } INT PhAddTabControlTab( - __in HWND TabControlHandle, - __in INT Index, - __in PWSTR Text + _In_ HWND TabControlHandle, + _In_ INT Index, + _In_ PWSTR Text ) { TCITEM item; @@ -420,7 +420,7 @@ INT PhAddTabControlTab( } PPH_STRING PhGetWindowText( - __in HWND hwnd + _In_ HWND hwnd ) { PPH_STRING string; @@ -445,9 +445,9 @@ PPH_STRING PhGetWindowText( } VOID PhAddComboBoxStrings( - __in HWND hWnd, - __in PWSTR *Strings, - __in ULONG NumberOfStrings + _In_ HWND hWnd, + _In_ PWSTR *Strings, + _In_ ULONG NumberOfStrings ) { ULONG i; @@ -457,8 +457,8 @@ VOID PhAddComboBoxStrings( } PPH_STRING PhGetComboBoxString( - __in HWND hwnd, - __in INT Index + _In_ HWND hwnd, + _In_ INT Index ) { PPH_STRING string; @@ -493,9 +493,9 @@ PPH_STRING PhGetComboBoxString( } INT PhSelectComboBoxString( - __in HWND hwnd, - __in PWSTR String, - __in BOOLEAN Partial + _In_ HWND hwnd, + _In_ PWSTR String, + _In_ BOOLEAN Partial ) { if (Partial) @@ -518,8 +518,8 @@ INT PhSelectComboBoxString( } PPH_STRING PhGetListBoxString( - __in HWND hwnd, - __in INT Index + _In_ HWND hwnd, + _In_ INT Index ) { PPH_STRING string; @@ -554,10 +554,10 @@ PPH_STRING PhGetListBoxString( } VOID PhShowContextMenu( - __in HWND hwnd, - __in HWND subHwnd, - __in HMENU menu, - __in POINT point + _In_ HWND hwnd, + _In_ HWND subHwnd, + _In_ HMENU menu, + _In_ POINT point ) { TrackPopupMenu( @@ -572,10 +572,10 @@ VOID PhShowContextMenu( } UINT PhShowContextMenu2( - __in HWND hwnd, - __in HWND subHwnd, - __in HMENU menu, - __in POINT point + _In_ HWND hwnd, + _In_ HWND subHwnd, + _In_ HMENU menu, + _In_ POINT point ) { return (UINT)TrackPopupMenu( @@ -590,10 +590,10 @@ UINT PhShowContextMenu2( } VOID PhSetMenuItemBitmap( - __in HMENU Menu, - __in ULONG Item, - __in BOOLEAN ByPosition, - __in HBITMAP Bitmap + _In_ HMENU Menu, + _In_ ULONG Item, + _In_ BOOLEAN ByPosition, + _In_ HBITMAP Bitmap ) { MENUITEMINFO info = { sizeof(info) }; @@ -605,9 +605,9 @@ VOID PhSetMenuItemBitmap( } VOID PhSetRadioCheckMenuItem( - __in HMENU Menu, - __in ULONG Id, - __in BOOLEAN RadioCheck + _In_ HMENU Menu, + _In_ ULONG Id, + _In_ BOOLEAN RadioCheck ) { MENUITEMINFO info = { sizeof(info) }; @@ -624,17 +624,17 @@ VOID PhSetRadioCheckMenuItem( } VOID PhEnableMenuItem( - __in HMENU Menu, - __in ULONG Id, - __in BOOLEAN Enable + _In_ HMENU Menu, + _In_ ULONG Id, + _In_ BOOLEAN Enable ) { EnableMenuItem(Menu, Id, Enable ? MF_ENABLED : (MF_DISABLED | MF_GRAYED)); } VOID PhEnableAllMenuItems( - __in HMENU Menu, - __in BOOLEAN Enable + _In_ HMENU Menu, + _In_ BOOLEAN Enable ) { ULONG i; @@ -660,9 +660,9 @@ VOID PhEnableAllMenuItems( } VOID PhSetStateAllListViewItems( - __in HWND hWnd, - __in ULONG State, - __in ULONG Mask + _In_ HWND hWnd, + _In_ ULONG State, + _In_ ULONG Mask ) { ULONG i; @@ -680,7 +680,7 @@ VOID PhSetStateAllListViewItems( } PVOID PhGetSelectedListViewItemParam( - __in HWND hWnd + _In_ HWND hWnd ) { INT index; @@ -708,9 +708,9 @@ PVOID PhGetSelectedListViewItemParam( } VOID PhGetSelectedListViewItemParams( - __in HWND hWnd, - __out PVOID **Items, - __out PULONG NumberOfItems + _In_ HWND hWnd, + _Out_ PVOID **Items, + _Out_ PULONG NumberOfItems ) { PPH_LIST list; @@ -743,10 +743,10 @@ VOID PhGetSelectedListViewItemParams( } VOID PhSetImageListBitmap( - __in HIMAGELIST ImageList, - __in INT Index, - __in HINSTANCE InstanceHandle, - __in LPCWSTR BitmapName + _In_ HIMAGELIST ImageList, + _In_ INT Index, + _In_ HINSTANCE InstanceHandle, + _In_ LPCWSTR BitmapName ) { HBITMAP bitmap; @@ -769,8 +769,8 @@ VOID PhSetImageListBitmap( * Do not destroy the icon using DestroyIcon(); it is shared between callers. */ VOID PhGetStockApplicationIcon( - __out_opt HICON *SmallIcon, - __out_opt HICON *LargeIcon + _Out_opt_ HICON *SmallIcon, + _Out_opt_ HICON *LargeIcon ) { static PH_INITONCE initOnce = PH_INITONCE_INIT; @@ -833,9 +833,9 @@ VOID PhGetStockApplicationIcon( } HICON PhGetFileShellIcon( - __in_opt PWSTR FileName, - __in_opt PWSTR DefaultExtension, - __in BOOLEAN LargeIcon + _In_opt_ PWSTR FileName, + _In_opt_ PWSTR DefaultExtension, + _In_ BOOLEAN LargeIcon ) { SHFILEINFO fileInfo; @@ -903,9 +903,9 @@ HICON PhGetFileShellIcon( } VOID PhpSetClipboardData( - __in HWND hWnd, - __in ULONG Format, - __in HANDLE Data + _In_ HWND hWnd, + _In_ ULONG Format, + _In_ HANDLE Data ) { if (OpenClipboard(hWnd)) @@ -926,17 +926,17 @@ VOID PhpSetClipboardData( } VOID PhSetClipboardString( - __in HWND hWnd, - __in PPH_STRINGREF String + _In_ HWND hWnd, + _In_ PPH_STRINGREF String ) { PhSetClipboardStringEx(hWnd, String->Buffer, String->Length); } VOID PhSetClipboardStringEx( - __in HWND hWnd, - __in PWSTR Buffer, - __in SIZE_T Length + _In_ HWND hWnd, + _In_ PWSTR Buffer, + _In_ SIZE_T Length ) { HANDLE data; @@ -954,8 +954,8 @@ VOID PhSetClipboardStringEx( } VOID PhInitializeLayoutManager( - __out PPH_LAYOUT_MANAGER Manager, - __in HWND RootWindowHandle + _Out_ PPH_LAYOUT_MANAGER Manager, + _In_ HWND RootWindowHandle ) { Manager->List = PhCreateList(4); @@ -972,7 +972,7 @@ VOID PhInitializeLayoutManager( } VOID PhDeleteLayoutManager( - __inout PPH_LAYOUT_MANAGER Manager + _Inout_ PPH_LAYOUT_MANAGER Manager ) { ULONG i; @@ -987,10 +987,10 @@ VOID PhDeleteLayoutManager( // controls. PPH_LAYOUT_ITEM PhAddLayoutItem( - __inout PPH_LAYOUT_MANAGER Manager, - __in HWND Handle, - __in_opt PPH_LAYOUT_ITEM ParentItem, - __in ULONG Anchor + _Inout_ PPH_LAYOUT_MANAGER Manager, + _In_ HWND Handle, + _In_opt_ PPH_LAYOUT_ITEM ParentItem, + _In_ ULONG Anchor ) { PPH_LAYOUT_ITEM layoutItem; @@ -1021,11 +1021,11 @@ PPH_LAYOUT_ITEM PhAddLayoutItem( } PPH_LAYOUT_ITEM PhAddLayoutItemEx( - __inout PPH_LAYOUT_MANAGER Manager, - __in HWND Handle, - __in_opt PPH_LAYOUT_ITEM ParentItem, - __in ULONG Anchor, - __in RECT Margin + _Inout_ PPH_LAYOUT_MANAGER Manager, + _In_ HWND Handle, + _In_opt_ PPH_LAYOUT_ITEM ParentItem, + _In_ ULONG Anchor, + _In_ RECT Margin ) { PPH_LAYOUT_ITEM item; @@ -1070,8 +1070,8 @@ PPH_LAYOUT_ITEM PhAddLayoutItemEx( } VOID PhpLayoutItemLayout( - __inout PPH_LAYOUT_MANAGER Manager, - __inout PPH_LAYOUT_ITEM Item + _Inout_ PPH_LAYOUT_MANAGER Manager, + _Inout_ PPH_LAYOUT_ITEM Item ) { RECT rect; @@ -1187,7 +1187,7 @@ VOID PhpLayoutItemLayout( } VOID PhLayoutManagerLayout( - __inout PPH_LAYOUT_MANAGER Manager + _Inout_ PPH_LAYOUT_MANAGER Manager ) { ULONG i; diff --git a/2.x/trunk/phlib/handle.c b/2.x/trunk/phlib/handle.c index ae110f98f..ff502a65c 100644 --- a/2.x/trunk/phlib/handle.c +++ b/2.x/trunk/phlib/handle.c @@ -94,7 +94,7 @@ PPH_HANDLE_TABLE PhCreateHandleTable( } VOID PhDestroyHandleTable( - __in __post_invalid PPH_HANDLE_TABLE HandleTable + _In_ _Post_invalid_ PPH_HANDLE_TABLE HandleTable ) { ULONG_PTR tableValue; @@ -164,8 +164,8 @@ VOID PhDestroyHandleTable( } VOID PhpBlockOnLockedHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __in PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ) { PH_QUEUED_WAIT_BLOCK waitBlock; @@ -190,8 +190,8 @@ VOID PhpBlockOnLockedHandleTableEntry( } BOOLEAN PhLockHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __inout PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _Inout_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ) { ULONG_PTR value; @@ -220,8 +220,8 @@ BOOLEAN PhLockHandleTableEntry( } VOID PhUnlockHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __inout PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _Inout_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ) { _interlockedbittestandset( @@ -232,8 +232,8 @@ VOID PhUnlockHandleTableEntry( } HANDLE PhCreateHandle( - __inout PPH_HANDLE_TABLE HandleTable, - __in PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ) { PPH_HANDLE_TABLE_ENTRY entry; @@ -261,9 +261,9 @@ HANDLE PhCreateHandle( } BOOLEAN PhDestroyHandle( - __inout PPH_HANDLE_TABLE HandleTable, - __in HANDLE Handle, - __in_opt __assumeLocked PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ HANDLE Handle, + _In_opt_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ) { ULONG handleValue; @@ -297,8 +297,8 @@ BOOLEAN PhDestroyHandle( } PPH_HANDLE_TABLE_ENTRY PhLookupHandleTableEntry( - __in PPH_HANDLE_TABLE HandleTable, - __in HANDLE Handle + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ HANDLE Handle ) { PPH_HANDLE_TABLE_ENTRY entry; @@ -315,9 +315,9 @@ PPH_HANDLE_TABLE_ENTRY PhLookupHandleTableEntry( } VOID PhEnumHandleTable( - __in PPH_HANDLE_TABLE HandleTable, - __in PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, + _In_opt_ PVOID Context ) { ULONG handleValue; @@ -347,9 +347,9 @@ VOID PhEnumHandleTable( } VOID PhSweepHandleTable( - __in PPH_HANDLE_TABLE HandleTable, - __in PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, + _In_opt_ PVOID Context ) { ULONG handleValue; @@ -378,11 +378,11 @@ VOID PhSweepHandleTable( } NTSTATUS PhQueryInformationHandleTable( - __in PPH_HANDLE_TABLE HandleTable, - __in PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, - __out_bcount_opt(BufferLength) PVOID Buffer, - __in ULONG BufferLength, - __out_opt PULONG ReturnLength + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, + _Out_writes_bytes_opt_(BufferLength) PVOID Buffer, + _In_ ULONG BufferLength, + _Out_opt_ PULONG ReturnLength ) { NTSTATUS status = STATUS_SUCCESS; @@ -437,10 +437,10 @@ NTSTATUS PhQueryInformationHandleTable( } NTSTATUS PhSetInformationHandleTable( - __inout PPH_HANDLE_TABLE HandleTable, - __in PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, - __in_bcount(BufferLength) PVOID Buffer, - __in ULONG BufferLength + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, + _In_reads_bytes_(BufferLength) PVOID Buffer, + _In_ ULONG BufferLength ) { NTSTATUS status = STATUS_SUCCESS; @@ -475,8 +475,8 @@ NTSTATUS PhSetInformationHandleTable( } PPH_HANDLE_TABLE_ENTRY PhpAllocateHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __out PULONG HandleValue + _Inout_ PPH_HANDLE_TABLE HandleTable, + _Out_ PULONG HandleValue ) { PPH_HANDLE_TABLE_ENTRY entry; @@ -594,9 +594,9 @@ PPH_HANDLE_TABLE_ENTRY PhpAllocateHandleTableEntry( } VOID PhpFreeHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __in ULONG HandleValue, - __inout PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ ULONG HandleValue, + _Inout_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ) { PULONG freeList; @@ -639,8 +639,8 @@ VOID PhpFreeHandleTableEntry( } BOOLEAN PhpAllocateMoreHandleTableEntries( - __in __assumeLocked PPH_HANDLE_TABLE HandleTable, - __in BOOLEAN Initialize + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ BOOLEAN Initialize ) { ULONG_PTR tableValue; @@ -856,8 +856,8 @@ BOOLEAN PhpAllocateMoreHandleTableEntries( } PPH_HANDLE_TABLE_ENTRY PhpLookupHandleTableEntry( - __in PPH_HANDLE_TABLE HandleTable, - __in ULONG HandleValue + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ ULONG HandleValue ) { ULONG_PTR tableValue; @@ -910,7 +910,7 @@ PPH_HANDLE_TABLE_ENTRY PhpLookupHandleTableEntry( } ULONG PhpMoveFreeHandleTableEntries( - __inout __assumeLocked PPH_HANDLE_TABLE HandleTable + _Inout_ PPH_HANDLE_TABLE HandleTable ) { ULONG freeValueAlt; @@ -1012,8 +1012,8 @@ ULONG PhpMoveFreeHandleTableEntries( } PPH_HANDLE_TABLE_ENTRY PhpCreateHandleTableLevel0( - __in PPH_HANDLE_TABLE HandleTable, - __in BOOLEAN Initialize + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ BOOLEAN Initialize ) { PPH_HANDLE_TABLE_ENTRY table; @@ -1054,14 +1054,14 @@ PPH_HANDLE_TABLE_ENTRY PhpCreateHandleTableLevel0( } VOID PhpFreeHandleTableLevel0( - __in PPH_HANDLE_TABLE_ENTRY Table + _In_ PPH_HANDLE_TABLE_ENTRY Table ) { PhFreeToFreeList(&PhHandleTableLevel0FreeList, Table); } PPH_HANDLE_TABLE_ENTRY *PhpCreateHandleTableLevel1( - __in PPH_HANDLE_TABLE HandleTable + _In_ PPH_HANDLE_TABLE HandleTable ) { PPH_HANDLE_TABLE_ENTRY *table; @@ -1085,14 +1085,14 @@ PPH_HANDLE_TABLE_ENTRY *PhpCreateHandleTableLevel1( } VOID PhpFreeHandleTableLevel1( - __in PPH_HANDLE_TABLE_ENTRY *Table + _In_ PPH_HANDLE_TABLE_ENTRY *Table ) { PhFreeToFreeList(&PhHandleTableLevel1FreeList, Table); } PPH_HANDLE_TABLE_ENTRY **PhpCreateHandleTableLevel2( - __in PPH_HANDLE_TABLE HandleTable + _In_ PPH_HANDLE_TABLE HandleTable ) { PPH_HANDLE_TABLE_ENTRY **table; @@ -1112,7 +1112,7 @@ PPH_HANDLE_TABLE_ENTRY **PhpCreateHandleTableLevel2( } VOID PhpFreeHandleTableLevel2( - __in PPH_HANDLE_TABLE_ENTRY **Table + _In_ PPH_HANDLE_TABLE_ENTRY **Table ) { PhFree(Table); diff --git a/2.x/trunk/phlib/hexedit.c b/2.x/trunk/phlib/hexedit.c index 2f28cb23a..0adcd98a2 100644 --- a/2.x/trunk/phlib/hexedit.c +++ b/2.x/trunk/phlib/hexedit.c @@ -51,7 +51,7 @@ BOOLEAN PhHexEditInitialization( } VOID PhpCreateHexEditContext( - __out PPHP_HEXEDIT_CONTEXT *Context + _Out_ PPHP_HEXEDIT_CONTEXT *Context ) { PPHP_HEXEDIT_CONTEXT context; @@ -91,7 +91,7 @@ VOID PhpCreateHexEditContext( } VOID PhpFreeHexEditContext( - __in __post_invalid PPHP_HEXEDIT_CONTEXT Context + _In_ _Post_invalid_ PPHP_HEXEDIT_CONTEXT Context ) { if (!Context->UserBuffer && Context->Data) @@ -102,10 +102,10 @@ VOID PhpFreeHexEditContext( } LRESULT CALLBACK PhpHexEditWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPHP_HEXEDIT_CONTEXT context; @@ -848,13 +848,13 @@ LRESULT CALLBACK PhpHexEditWndProc( } FORCEINLINE VOID PhpPrintHex( - __in HDC hdc, - __in PPHP_HEXEDIT_CONTEXT Context, - __inout PWCHAR Buffer, - __in UCHAR Byte, - __inout PLONG X, - __inout PLONG Y, - __inout PULONG N + _In_ HDC hdc, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _Inout_ PWCHAR Buffer, + _In_ UCHAR Byte, + _Inout_ PLONG X, + _Inout_ PLONG Y, + _Inout_ PULONG N ) { PWCHAR p = Buffer; @@ -874,12 +874,12 @@ FORCEINLINE VOID PhpPrintHex( } FORCEINLINE VOID PhpPrintAscii( - __in HDC hdc, - __in PPHP_HEXEDIT_CONTEXT Context, - __in UCHAR Byte, - __inout PLONG X, - __inout PLONG Y, - __inout PULONG N + _In_ HDC hdc, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ UCHAR Byte, + _Inout_ PLONG X, + _Inout_ PLONG Y, + _Inout_ PULONG N ) { WCHAR c; @@ -930,10 +930,10 @@ FORCEINLINE COLORREF GetLighterHighlightColor( } VOID PhpHexEditOnPaint( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in PAINTSTRUCT *PaintStruct, - __in HDC hdc + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ PAINTSTRUCT *PaintStruct, + _In_ HDC hdc ) { RECT clientRect; @@ -1208,8 +1208,8 @@ VOID PhpHexEditOnPaint( } VOID PhpHexEditUpdateScrollbars( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { SCROLLINFO si = { sizeof(si) }; @@ -1235,8 +1235,8 @@ VOID PhpHexEditUpdateScrollbars( } VOID PhpHexEditCreateAddressCaret( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { DestroyCaret(); @@ -1244,8 +1244,8 @@ VOID PhpHexEditCreateAddressCaret( } VOID PhpHexEditCreateEditCaret( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { DestroyCaret(); @@ -1253,9 +1253,9 @@ VOID PhpHexEditCreateEditCaret( } VOID PhpHexEditRepositionCaret( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG Position + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG Position ) { ULONG x; @@ -1302,11 +1302,11 @@ VOID PhpHexEditRepositionCaret( } VOID PhpHexEditCalculatePosition( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG X, - __in LONG Y, - __out POINT *Point + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG X, + _In_ LONG Y, + _Out_ POINT *Point ) { LONG xp; @@ -1378,10 +1378,10 @@ VOID PhpHexEditCalculatePosition( } VOID PhpHexEditMove( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG X, - __in LONG Y + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG X, + _In_ LONG Y ) { switch (Context->CurrentMode) @@ -1430,10 +1430,10 @@ VOID PhpHexEditMove( } VOID PhpHexEditSetSel( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG S, - __in LONG E + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG S, + _In_ LONG E ) { DestroyCaret(); @@ -1458,9 +1458,9 @@ VOID PhpHexEditSetSel( } VOID PhpHexEditScrollTo( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG Position + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG Position ) { if (Position < Context->TopIndex || Position > Context->TopIndex + Context->LinesPerPage * Context->BytesPerRow) @@ -1483,8 +1483,8 @@ VOID PhpHexEditScrollTo( } VOID PhpHexEditClearEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { if (Context->AllowLengthChange) @@ -1497,8 +1497,8 @@ VOID PhpHexEditClearEdit( } VOID PhpHexEditCopyEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { if (OpenClipboard(hwnd)) @@ -1584,8 +1584,8 @@ VOID PhpHexEditCopyEdit( } VOID PhpHexEditCutEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { if (Context->AllowLengthChange) @@ -1597,8 +1597,8 @@ VOID PhpHexEditCutEdit( } VOID PhpHexEditPasteEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { if (OpenClipboard(hwnd)) @@ -1667,8 +1667,8 @@ VOID PhpHexEditPasteEdit( } VOID PhpHexEditSelectAll( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { Context->SelStart = 0; @@ -1678,16 +1678,16 @@ VOID PhpHexEditSelectAll( } VOID PhpHexEditUndoEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { // TODO } VOID PhpHexEditNormalizeSel( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ) { if (Context->SelStart > Context->SelEnd) @@ -1701,10 +1701,10 @@ VOID PhpHexEditNormalizeSel( } VOID PhpHexEditSelDelete( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG S, - __in LONG E + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG S, + _In_ LONG E ) { if (Context->AllowLengthChange) @@ -1732,10 +1732,10 @@ VOID PhpHexEditSelDelete( } VOID PhpHexEditSelInsert( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG S, - __in LONG L + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG S, + _In_ LONG L ) { if (Context->AllowLengthChange) @@ -1756,10 +1756,10 @@ VOID PhpHexEditSelInsert( } VOID PhpHexEditSetBuffer( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in PUCHAR Data, - __in ULONG Length + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ PUCHAR Data, + _In_ ULONG Length ) { Context->Data = Data; @@ -1776,10 +1776,10 @@ VOID PhpHexEditSetBuffer( } VOID PhpHexEditSetData( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in PUCHAR Data, - __in ULONG Length + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ PUCHAR Data, + _In_ ULONG Length ) { PhFree(Context->Data); diff --git a/2.x/trunk/phlib/hndlinfo.c b/2.x/trunk/phlib/hndlinfo.c index 032f483ac..bf6e18d02 100644 --- a/2.x/trunk/phlib/hndlinfo.c +++ b/2.x/trunk/phlib/hndlinfo.c @@ -45,7 +45,7 @@ typedef struct _PH_QUERY_OBJECT_CONTEXT } PH_QUERY_OBJECT_CONTEXT, *PPH_QUERY_OBJECT_CONTEXT; NTSTATUS PhpQueryObjectThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); static HANDLE PhQueryObjectThreadHandle = NULL; @@ -66,7 +66,7 @@ VOID PhHandleInfoInitialization( } PPH_GET_CLIENT_ID_NAME PhSetHandleClientIdFunction( - __in PPH_GET_CLIENT_ID_NAME GetClientIdName + _In_ PPH_GET_CLIENT_ID_NAME GetClientIdName ) { return _InterlockedExchangePointer( @@ -76,9 +76,9 @@ PPH_GET_CLIENT_ID_NAME PhSetHandleClientIdFunction( } NTSTATUS PhpGetObjectBasicInformation( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __out POBJECT_BASIC_INFORMATION BasicInformation + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _Out_ POBJECT_BASIC_INFORMATION BasicInformation ) { NTSTATUS status; @@ -126,10 +126,10 @@ NTSTATUS PhpGetObjectBasicInformation( } NTSTATUS PhpGetObjectTypeName( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in ULONG ObjectTypeNumber, - __out PPH_STRING *TypeName + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ ULONG ObjectTypeNumber, + _Out_ PPH_STRING *TypeName ) { NTSTATUS status = STATUS_SUCCESS; @@ -237,9 +237,9 @@ NTSTATUS PhpGetObjectTypeName( } NTSTATUS PhpGetObjectName( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __out PPH_STRING *ObjectName + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _Out_ PPH_STRING *ObjectName ) { NTSTATUS status; @@ -298,7 +298,7 @@ NTSTATUS PhpGetObjectName( } PPH_STRING PhFormatNativeKeyName( - __in PPH_STRING Name + _In_ PPH_STRING Name ) { static PH_STRINGREF hklmPrefix = PH_STRINGREF_INIT(L"\\Registry\\Machine"); @@ -395,8 +395,8 @@ PPH_STRING PhFormatNativeKeyName( return newName; } -__callback PPH_STRING PhStdGetClientIdName( - __in PCLIENT_ID ClientId +_Callback_ PPH_STRING PhStdGetClientIdName( + _In_ PCLIENT_ID ClientId ) { static PH_QUEUED_LOCK cachedProcessesLock = PH_QUEUED_LOCK_INIT; @@ -490,11 +490,11 @@ __callback PPH_STRING PhStdGetClientIdName( } NTSTATUS PhpGetBestObjectName( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in PPH_STRING ObjectName, - __in PPH_STRING TypeName, - __out PPH_STRING *BestObjectName + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ PPH_STRING ObjectName, + _In_ PPH_STRING TypeName, + _Out_ PPH_STRING *BestObjectName ) { NTSTATUS status; @@ -932,13 +932,13 @@ NTSTATUS PhpGetBestObjectName( * \c ObjectTypeNumber is invalid. */ NTSTATUS PhGetHandleInformation( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in ULONG ObjectTypeNumber, - __out_opt POBJECT_BASIC_INFORMATION BasicInformation, - __out_opt PPH_STRING *TypeName, - __out_opt PPH_STRING *ObjectName, - __out_opt PPH_STRING *BestObjectName + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ ULONG ObjectTypeNumber, + _Out_opt_ POBJECT_BASIC_INFORMATION BasicInformation, + _Out_opt_ PPH_STRING *TypeName, + _Out_opt_ PPH_STRING *ObjectName, + _Out_opt_ PPH_STRING *BestObjectName ) { NTSTATUS status; @@ -1000,16 +1000,16 @@ NTSTATUS PhGetHandleInformation( * cannot be queried. */ NTSTATUS PhGetHandleInformationEx( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in ULONG ObjectTypeNumber, - __reserved ULONG Flags, - __out_opt PNTSTATUS SubStatus, - __out_opt POBJECT_BASIC_INFORMATION BasicInformation, - __out_opt PPH_STRING *TypeName, - __out_opt PPH_STRING *ObjectName, - __out_opt PPH_STRING *BestObjectName, - __reserved PVOID *ExtraInformation + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ ULONG ObjectTypeNumber, + _Reserved_ ULONG Flags, + _Out_opt_ PNTSTATUS SubStatus, + _Out_opt_ POBJECT_BASIC_INFORMATION BasicInformation, + _Out_opt_ PPH_STRING *TypeName, + _Out_opt_ PPH_STRING *ObjectName, + _Out_opt_ PPH_STRING *BestObjectName, + _Reserved_ PVOID *ExtraInformation ) { NTSTATUS status = STATUS_SUCCESS; @@ -1260,7 +1260,7 @@ BOOLEAN PhpHeadQueryObjectHack( } NTSTATUS PhpTailQueryObjectHack( - __out_opt PULONG ReturnLength + _Out_opt_ PULONG ReturnLength ) { NTSTATUS status; @@ -1312,10 +1312,10 @@ NTSTATUS PhpTailQueryObjectHack( } NTSTATUS PhQueryObjectNameHack( - __in HANDLE Handle, - __out_bcount(ObjectNameInformationLength) POBJECT_NAME_INFORMATION ObjectNameInformation, - __in ULONG ObjectNameInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE Handle, + _Out_writes_bytes_(ObjectNameInformationLength) POBJECT_NAME_INFORMATION ObjectNameInformation, + _In_ ULONG ObjectNameInformationLength, + _Out_opt_ PULONG ReturnLength ) { if (!PhpHeadQueryObjectHack()) @@ -1330,11 +1330,11 @@ NTSTATUS PhQueryObjectNameHack( } NTSTATUS PhQueryObjectSecurityHack( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ) { if (!PhpHeadQueryObjectHack()) @@ -1350,9 +1350,9 @@ NTSTATUS PhQueryObjectSecurityHack( } NTSTATUS PhSetObjectSecurityHack( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __in PVOID Buffer + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PVOID Buffer ) { if (!PhpHeadQueryObjectHack()) @@ -1367,7 +1367,7 @@ NTSTATUS PhSetObjectSecurityHack( } NTSTATUS PhpQueryObjectThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PhQueryObjectFiber = ConvertThreadToFiber(Parameter); diff --git a/2.x/trunk/phlib/icotobmp.c b/2.x/trunk/phlib/icotobmp.c index 4ef47d4f0..8beb54b84 100644 --- a/2.x/trunk/phlib/icotobmp.c +++ b/2.x/trunk/phlib/icotobmp.c @@ -4,22 +4,22 @@ // code from http://msdn.microsoft.com/en-us/library/bb757020.aspx typedef HPAINTBUFFER (*_BeginBufferedPaint)( - __in HDC hdcTarget, - __in const RECT *prcTarget, - __in BP_BUFFERFORMAT dwFormat, - __in BP_PAINTPARAMS *pPaintParams, - __out HDC *phdc + _In_ HDC hdcTarget, + _In_ const RECT *prcTarget, + _In_ BP_BUFFERFORMAT dwFormat, + _In_ BP_PAINTPARAMS *pPaintParams, + _Out_ HDC *phdc ); typedef HRESULT (*_EndBufferedPaint)( - __in HPAINTBUFFER hBufferedPaint, - __in BOOL fUpdateTarget + _In_ HPAINTBUFFER hBufferedPaint, + _In_ BOOL fUpdateTarget ); typedef HRESULT (*_GetBufferedPaintBits)( - __in HPAINTBUFFER hBufferedPaint, - __out RGBQUAD **ppbBuffer, - __out int *pcxRow + _In_ HPAINTBUFFER hBufferedPaint, + _Out_ RGBQUAD **ppbBuffer, + _Out_ int *pcxRow ); static BOOLEAN ImportsInitialized = FALSE; @@ -28,10 +28,10 @@ static _EndBufferedPaint EndBufferedPaint_I = NULL; static _GetBufferedPaintBits GetBufferedPaintBits_I = NULL; static HBITMAP PhpCreateBitmap32( - __in HDC hdc, - __in ULONG Width, - __in ULONG Height, - __deref_opt_out PVOID *Bits + _In_ HDC hdc, + _In_ ULONG Width, + _In_ ULONG Height, + _Outptr_opt_ PVOID *Bits ) { BITMAPINFO bitmapInfo; @@ -49,10 +49,10 @@ static HBITMAP PhpCreateBitmap32( } static BOOLEAN PhpHasAlpha( - __in PULONG Argb, - __in ULONG Width, - __in ULONG Height, - __in ULONG RowWidth + _In_ PULONG Argb, + _In_ ULONG Width, + _In_ ULONG Height, + _In_ ULONG RowWidth ) { ULONG delta; @@ -76,12 +76,12 @@ static BOOLEAN PhpHasAlpha( } static VOID PhpConvertToPArgb32( - __in HDC hdc, - __inout PULONG Argb, - __in HBITMAP Bitmap, - __in ULONG Width, - __in ULONG Height, - __in ULONG RowWidth + _In_ HDC hdc, + _Inout_ PULONG Argb, + _In_ HBITMAP Bitmap, + _In_ ULONG Width, + _In_ ULONG Height, + _In_ ULONG RowWidth ) { BITMAPINFO bitmapInfo; @@ -130,11 +130,11 @@ static VOID PhpConvertToPArgb32( } static VOID PhpConvertToPArgb32IfNeeded( - __in HPAINTBUFFER PaintBuffer, - __in HDC hdc, - __in HICON Icon, - __in ULONG Width, - __in ULONG Height + _In_ HPAINTBUFFER PaintBuffer, + _In_ HDC hdc, + _In_ HICON Icon, + _In_ ULONG Width, + _In_ ULONG Height ) { RGBQUAD *quad; @@ -163,9 +163,9 @@ static VOID PhpConvertToPArgb32IfNeeded( } HBITMAP PhIconToBitmap( - __in HICON Icon, - __in ULONG Width, - __in ULONG Height + _In_ HICON Icon, + _In_ ULONG Width, + _In_ ULONG Height ) { HBITMAP bitmap; diff --git a/2.x/trunk/phlib/include/circbuf_h.h b/2.x/trunk/phlib/include/circbuf_h.h index 65d4726f1..065fb8029 100644 --- a/2.x/trunk/phlib/include/circbuf_h.h +++ b/2.x/trunk/phlib/include/circbuf_h.h @@ -17,44 +17,44 @@ PHLIBAPI VOID NTAPI T___(PhInitializeCircularBuffer, T)( - __out T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in ULONG Size + _Out_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ ULONG Size ); PHLIBAPI VOID NTAPI T___(PhDeleteCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer ); PHLIBAPI VOID NTAPI T___(PhResizeCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in ULONG NewSize + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ ULONG NewSize ); PHLIBAPI VOID NTAPI T___(PhClearCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer ); PHLIBAPI VOID NTAPI T___(PhCopyCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __out_ecount(Count) T *Destination, - __in ULONG Count + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _Out_writes_(Count) T *Destination, + _In_ ULONG Count ); FORCEINLINE T T___(PhGetItemCircularBuffer, T)( - __in T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in LONG Index + _In_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ LONG Index ) { #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE @@ -69,9 +69,9 @@ FORCEINLINE T T___(PhGetItemCircularBuffer, T)( } FORCEINLINE VOID T___(PhSetItemCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in LONG Index, - __in T Value + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ LONG Index, + _In_ T Value ) { #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE @@ -85,8 +85,8 @@ FORCEINLINE VOID T___(PhSetItemCircularBuffer, T)( } FORCEINLINE VOID T___(PhAddItemCircularBuffer, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in T Value + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ T Value ) { #ifdef PH_CIRCULAR_BUFFER_POWER_OF_TWO_SIZE @@ -103,8 +103,8 @@ FORCEINLINE VOID T___(PhAddItemCircularBuffer, T)( } FORCEINLINE T T___(PhAddItemCircularBuffer2, T)( - __inout T___(PPH_CIRCULAR_BUFFER, T) Buffer, - __in T Value + _Inout_ T___(PPH_CIRCULAR_BUFFER, T) Buffer, + _In_ T Value ) { LONG index; diff --git a/2.x/trunk/phlib/include/cpysave.h b/2.x/trunk/phlib/include/cpysave.h index c5d9e319a..faa846343 100644 --- a/2.x/trunk/phlib/include/cpysave.h +++ b/2.x/trunk/phlib/include/cpysave.h @@ -6,58 +6,58 @@ #define PH_EXPORT_MODE_CSV 2 VOID PhaCreateTextTable( - __out PPH_STRING ***Table, - __in ULONG Rows, - __in ULONG Columns + _Out_ PPH_STRING ***Table, + _In_ ULONG Rows, + _In_ ULONG Columns ); PPH_LIST PhaFormatTextTable( - __in PPH_STRING **Table, - __in ULONG Rows, - __in ULONG Columns, - __in ULONG Mode + _In_ PPH_STRING **Table, + _In_ ULONG Rows, + _In_ ULONG Columns, + _In_ ULONG Mode ); VOID PhMapDisplayIndexTreeNew( - __in HWND TreeNewHandle, - __out_opt PULONG *DisplayToId, - __out_opt PWSTR **DisplayToText, - __out PULONG NumberOfColumns + _In_ HWND TreeNewHandle, + _Out_opt_ PULONG *DisplayToId, + _Out_opt_ PWSTR **DisplayToText, + _Out_ PULONG NumberOfColumns ); PHLIBAPI PPH_STRING PhGetTreeNewText( - __in HWND TreeNewHandle, - __reserved ULONG Reserved + _In_ HWND TreeNewHandle, + _Reserved_ ULONG Reserved ); PHLIBAPI PPH_LIST PhGetGenericTreeNewLines( - __in HWND TreeNewHandle, - __in ULONG Mode + _In_ HWND TreeNewHandle, + _In_ ULONG Mode ); VOID PhaMapDisplayIndexListView( - __in HWND ListViewHandle, - __out_ecount(Count) PULONG DisplayToId, - __out_ecount_opt(Count) PPH_STRING *DisplayToText, - __in ULONG Count, - __out PULONG NumberOfColumns + _In_ HWND ListViewHandle, + _Out_writes_(Count) PULONG DisplayToId, + _Out_writes_opt_(Count) PPH_STRING *DisplayToText, + _In_ ULONG Count, + _Out_ PULONG NumberOfColumns ); PPH_STRING PhaGetListViewItemText( - __in HWND ListViewHandle, - __in INT Index, - __in INT SubItemIndex + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT SubItemIndex ); PPH_STRING PhGetListViewText( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ); PPH_LIST PhGetListViewLines( - __in HWND ListViewHandle, - __in ULONG Mode + _In_ HWND ListViewHandle, + _In_ ULONG Mode ); #endif diff --git a/2.x/trunk/phlib/include/dspick.h b/2.x/trunk/phlib/include/dspick.h index 34f2ce8dd..f7a92243c 100644 --- a/2.x/trunk/phlib/include/dspick.h +++ b/2.x/trunk/phlib/include/dspick.h @@ -17,24 +17,24 @@ typedef struct _PH_DSPICK_OBJECTS PHLIBAPI VOID PhFreeDsObjectPickerDialog( - __in PVOID PickerDialog + _In_ PVOID PickerDialog ); PHLIBAPI PVOID PhCreateDsObjectPickerDialog( - __in ULONG Flags + _In_ ULONG Flags ); PHLIBAPI BOOLEAN PhShowDsObjectPickerDialog( - __in HWND hWnd, - __in PVOID PickerDialog, - __out PPH_DSPICK_OBJECTS *Objects + _In_ HWND hWnd, + _In_ PVOID PickerDialog, + _Out_ PPH_DSPICK_OBJECTS *Objects ); PHLIBAPI VOID PhFreeDsObjectPickerObjects( - __in PPH_DSPICK_OBJECTS Objects + _In_ PPH_DSPICK_OBJECTS Objects ); #endif diff --git a/2.x/trunk/phlib/include/emenu.h b/2.x/trunk/phlib/include/emenu.h index 4ffc56abb..555484ea7 100644 --- a/2.x/trunk/phlib/include/emenu.h +++ b/2.x/trunk/phlib/include/emenu.h @@ -19,7 +19,7 @@ struct _PH_EMENU_ITEM; typedef VOID (NTAPI *PPH_EMENU_ITEM_DELETE_FUNCTION)( - __in struct _PH_EMENU_ITEM *Item + _In_ struct _PH_EMENU_ITEM *Item ); typedef struct _PH_EMENU_ITEM @@ -42,16 +42,16 @@ typedef struct _PH_EMENU_ITEM PH_EMENU, *PPH_EMENU; PHLIBAPI PPH_EMENU_ITEM PhCreateEMenuItem( - __in ULONG Flags, - __in ULONG Id, - __in PWSTR Text, - __in_opt PWSTR Bitmap, - __in_opt PVOID Context + _In_ ULONG Flags, + _In_ ULONG Id, + _In_ PWSTR Text, + _In_opt_ PWSTR Bitmap, + _In_opt_ PVOID Context ); PHLIBAPI VOID PhDestroyEMenuItem( - __in PPH_EMENU_ITEM Item + _In_ PPH_EMENU_ITEM Item ); #define PH_EMENU_FIND_DESCEND 0x1 @@ -60,44 +60,44 @@ VOID PhDestroyEMenuItem( PHLIBAPI PPH_EMENU_ITEM PhFindEMenuItem( - __in PPH_EMENU_ITEM Item, - __in ULONG Flags, - __in_opt PWSTR Text, - __in_opt ULONG Id + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Flags, + _In_opt_ PWSTR Text, + _In_opt_ ULONG Id ); PPH_EMENU_ITEM PhFindEMenuItemEx( - __in PPH_EMENU_ITEM Item, - __in ULONG Flags, - __in_opt PWSTR Text, - __in_opt ULONG Id, - __out_opt PPH_EMENU_ITEM *FoundParent, - __out_opt PULONG FoundIndex + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Flags, + _In_opt_ PWSTR Text, + _In_opt_ ULONG Id, + _Out_opt_ PPH_EMENU_ITEM *FoundParent, + _Out_opt_ PULONG FoundIndex ); PHLIBAPI ULONG PhIndexOfEMenuItem( - __in PPH_EMENU_ITEM Parent, - __in PPH_EMENU_ITEM Item + _In_ PPH_EMENU_ITEM Parent, + _In_ PPH_EMENU_ITEM Item ); PHLIBAPI VOID PhInsertEMenuItem( - __inout PPH_EMENU_ITEM Parent, - __inout PPH_EMENU_ITEM Item, - __in ULONG Index + _Inout_ PPH_EMENU_ITEM Parent, + _Inout_ PPH_EMENU_ITEM Item, + _In_ ULONG Index ); PHLIBAPI BOOLEAN PhRemoveEMenuItem( - __inout_opt PPH_EMENU_ITEM Parent, - __in_opt PPH_EMENU_ITEM Item, - __in_opt ULONG Index + _Inout_opt_ PPH_EMENU_ITEM Parent, + _In_opt_ PPH_EMENU_ITEM Item, + _In_opt_ ULONG Index ); PHLIBAPI VOID PhRemoveAllEMenuItems( - __inout PPH_EMENU_ITEM Parent + _Inout_ PPH_EMENU_ITEM Parent ); PHLIBAPI @@ -107,7 +107,7 @@ PPH_EMENU PhCreateEMenu( PHLIBAPI VOID PhDestroyEMenu( - __in PPH_EMENU Menu + _In_ PPH_EMENU Menu ); #define PH_EMENU_CONVERT_ID 0x1 @@ -118,37 +118,37 @@ typedef struct _PH_EMENU_DATA } PH_EMENU_DATA, *PPH_EMENU_DATA; VOID PhInitializeEMenuData( - __out PPH_EMENU_DATA Data + _Out_ PPH_EMENU_DATA Data ); VOID PhDeleteEMenuData( - __inout PPH_EMENU_DATA Data + _Inout_ PPH_EMENU_DATA Data ); HMENU PhEMenuToHMenu( - __in PPH_EMENU_ITEM Menu, - __in ULONG Flags, - __inout_opt PPH_EMENU_DATA Data + _In_ PPH_EMENU_ITEM Menu, + _In_ ULONG Flags, + _Inout_opt_ PPH_EMENU_DATA Data ); VOID PhEMenuToHMenu2( - __in HMENU MenuHandle, - __in PPH_EMENU_ITEM Menu, - __in ULONG Flags, - __inout_opt PPH_EMENU_DATA Data + _In_ HMENU MenuHandle, + _In_ PPH_EMENU_ITEM Menu, + _In_ ULONG Flags, + _Inout_opt_ PPH_EMENU_DATA Data ); VOID PhHMenuToEMenuItem( - __inout PPH_EMENU_ITEM MenuItem, - __in HMENU MenuHandle + _Inout_ PPH_EMENU_ITEM MenuItem, + _In_ HMENU MenuHandle ); PHLIBAPI VOID PhLoadResourceEMenuItem( - __inout PPH_EMENU_ITEM MenuItem, - __in HINSTANCE InstanceHandle, - __in PWSTR Resource, - __in ULONG SubMenuIndex + _Inout_ PPH_EMENU_ITEM MenuItem, + _In_ HINSTANCE InstanceHandle, + _In_ PWSTR Resource, + _In_ ULONG SubMenuIndex ); #define PH_EMENU_SHOW_NONOTIFY 0x1 @@ -156,28 +156,28 @@ VOID PhLoadResourceEMenuItem( PHLIBAPI PPH_EMENU_ITEM PhShowEMenu( - __in PPH_EMENU Menu, - __in HWND WindowHandle, - __in ULONG Flags, - __in ULONG Align, - __in ULONG X, - __in ULONG Y + _In_ PPH_EMENU Menu, + _In_ HWND WindowHandle, + _In_ ULONG Flags, + _In_ ULONG Align, + _In_ ULONG X, + _In_ ULONG Y ); // Convenience functions PHLIBAPI BOOLEAN PhSetFlagsEMenuItem( - __in PPH_EMENU_ITEM Item, - __in ULONG Id, - __in ULONG Mask, - __in ULONG Value + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Id, + _In_ ULONG Mask, + _In_ ULONG Value ); FORCEINLINE BOOLEAN PhEnableEMenuItem( - __in PPH_EMENU_ITEM Item, - __in ULONG Id, - __in BOOLEAN Enable + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Id, + _In_ BOOLEAN Enable ) { return PhSetFlagsEMenuItem(Item, Id, PH_EMENU_DISABLED, Enable ? 0 : PH_EMENU_DISABLED); @@ -185,9 +185,9 @@ FORCEINLINE BOOLEAN PhEnableEMenuItem( PHLIBAPI VOID PhSetFlagsAllEMenuItems( - __in PPH_EMENU_ITEM Item, - __in ULONG Mask, - __in ULONG Value + _In_ PPH_EMENU_ITEM Item, + _In_ ULONG Mask, + _In_ ULONG Value ); #endif diff --git a/2.x/trunk/phlib/include/fastlock.h b/2.x/trunk/phlib/include/fastlock.h index 86da45c62..356d6958c 100644 --- a/2.x/trunk/phlib/include/fastlock.h +++ b/2.x/trunk/phlib/include/fastlock.h @@ -24,64 +24,70 @@ PHLIBAPI VOID NTAPI PhInitializeFastLock( - __out PPH_FAST_LOCK FastLock + _Out_ PPH_FAST_LOCK FastLock ); PHLIBAPI VOID NTAPI PhDeleteFastLock( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ); #define PhAcquireFastLockExclusive PhfAcquireFastLockExclusive -__mayRaise +_May_raise_ +_Acquires_exclusive_lock_(*FastLock) PHLIBAPI VOID FASTCALL PhfAcquireFastLockExclusive( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ); #define PhAcquireFastLockShared PhfAcquireFastLockShared -__mayRaise +_May_raise_ +_Acquires_shared_lock_(*FastLock) PHLIBAPI VOID FASTCALL PhfAcquireFastLockShared( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ); #define PhReleaseFastLockExclusive PhfReleaseFastLockExclusive +_Releases_exclusive_lock_(*FastLock) PHLIBAPI VOID FASTCALL PhfReleaseFastLockExclusive( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ); #define PhReleaseFastLockShared PhfReleaseFastLockShared +_Releases_shared_lock_(*FastLock) PHLIBAPI VOID FASTCALL PhfReleaseFastLockShared( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ); #define PhTryAcquireFastLockExclusive PhfTryAcquireFastLockExclusive +_When_(return != 0, _Acquires_exclusive_lock_(*FastLock)) PHLIBAPI BOOLEAN FASTCALL PhfTryAcquireFastLockExclusive( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ); #define PhTryAcquireFastLockShared PhfTryAcquireFastLockShared +_When_(return != 0, _Acquires_shared_lock_(*FastLock)) PHLIBAPI BOOLEAN FASTCALL PhfTryAcquireFastLockShared( - __inout PPH_FAST_LOCK FastLock + _Inout_ PPH_FAST_LOCK FastLock ); #ifdef __cplusplus diff --git a/2.x/trunk/phlib/include/filepool.h b/2.x/trunk/phlib/include/filepool.h index 609f9bbe6..b8e6690da 100644 --- a/2.x/trunk/phlib/include/filepool.h +++ b/2.x/trunk/phlib/include/filepool.h @@ -102,74 +102,74 @@ typedef struct _PH_FILE_POOL } PH_FILE_POOL, *PPH_FILE_POOL; NTSTATUS PhCreateFilePool( - __out PPH_FILE_POOL *Pool, - __in HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __in_opt PPH_FILE_POOL_PARAMETERS Parameters + _Out_ PPH_FILE_POOL *Pool, + _In_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _In_opt_ PPH_FILE_POOL_PARAMETERS Parameters ); NTSTATUS PhCreateFilePool2( - __out PPH_FILE_POOL *Pool, - __in PWSTR FileName, - __in BOOLEAN ReadOnly, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in_opt PPH_FILE_POOL_PARAMETERS Parameters + _Out_ PPH_FILE_POOL *Pool, + _In_ PWSTR FileName, + _In_ BOOLEAN ReadOnly, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_opt_ PPH_FILE_POOL_PARAMETERS Parameters ); VOID PhDestroyFilePool( - __in __post_invalid PPH_FILE_POOL Pool + _In_ _Post_invalid_ PPH_FILE_POOL Pool ); PVOID PhAllocateFilePool( - __inout PPH_FILE_POOL Pool, - __in ULONG Size, - __out_opt PULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Size, + _Out_opt_ PULONG Rva ); VOID PhFreeFilePool( - __inout PPH_FILE_POOL Pool, - __in PVOID Block + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Block ); BOOLEAN PhFreeFilePoolByRva( - __inout PPH_FILE_POOL Pool, - __in ULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Rva ); VOID PhReferenceFilePool( - __inout PPH_FILE_POOL Pool, - __in PVOID Address + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Address ); VOID PhDereferenceFilePool( - __inout PPH_FILE_POOL Pool, - __in PVOID Address + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Address ); PVOID PhReferenceFilePoolByRva( - __inout PPH_FILE_POOL Pool, - __in ULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Rva ); BOOLEAN PhDereferenceFilePoolByRva( - __inout PPH_FILE_POOL Pool, - __in ULONG Rva + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Rva ); ULONG PhEncodeRvaFilePool( - __in PPH_FILE_POOL Pool, - __in PVOID Address + _In_ PPH_FILE_POOL Pool, + _In_ PVOID Address ); VOID PhGetUserContextFilePool( - __in PPH_FILE_POOL Pool, - __out PULONGLONG Context + _In_ PPH_FILE_POOL Pool, + _Out_ PULONGLONG Context ); VOID PhSetUserContextFilePool( - __inout PPH_FILE_POOL Pool, - __in PULONGLONG Context + _Inout_ PPH_FILE_POOL Pool, + _In_ PULONGLONG Context ); #endif diff --git a/2.x/trunk/phlib/include/filepoolp.h b/2.x/trunk/phlib/include/filepoolp.h index 0e315d044..0a823ea60 100644 --- a/2.x/trunk/phlib/include/filepoolp.h +++ b/2.x/trunk/phlib/include/filepoolp.h @@ -13,192 +13,192 @@ typedef struct _PH_FILE_POOL_VIEW } PH_FILE_POOL_VIEW, *PPH_FILE_POOL_VIEW; NTSTATUS PhpValidateFilePoolParameters( - __inout PPH_FILE_POOL_PARAMETERS Parameters + _Inout_ PPH_FILE_POOL_PARAMETERS Parameters ); VOID PhpSetDefaultFilePoolParameters( - __out PPH_FILE_POOL_PARAMETERS Parameters + _Out_ PPH_FILE_POOL_PARAMETERS Parameters ); // Range mapping NTSTATUS PhFppExtendRange( - __inout PPH_FILE_POOL Pool, - __in ULONG NewSize + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG NewSize ); NTSTATUS PhFppMapRange( - __inout PPH_FILE_POOL Pool, - __in ULONG Offset, - __in ULONG Size, - __out PVOID *Base + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG Offset, + _In_ ULONG Size, + _Out_ PVOID *Base ); NTSTATUS PhFppUnmapRange( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ); // Segments VOID PhFppInitializeSegment( - __inout PPH_FILE_POOL Pool, - __out PPH_FP_BLOCK_HEADER BlockOfSegmentHeader, - __in ULONG AdditionalBlocksUsed + _Inout_ PPH_FILE_POOL Pool, + _Out_ PPH_FP_BLOCK_HEADER BlockOfSegmentHeader, + _In_ ULONG AdditionalBlocksUsed ); PPH_FP_BLOCK_HEADER PhFppAllocateSegment( - __inout PPH_FILE_POOL Pool, - __out PULONG NewSegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _Out_ PULONG NewSegmentIndex ); PPH_FP_SEGMENT_HEADER PhFppGetHeaderSegment( - __inout PPH_FILE_POOL Pool, - __in PPH_FP_BLOCK_HEADER FirstBlock + _Inout_ PPH_FILE_POOL Pool, + _In_ PPH_FP_BLOCK_HEADER FirstBlock ); // Views VOID PhFppAddViewByIndex( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); VOID PhFppRemoveViewByIndex( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); PPH_FILE_POOL_VIEW PhFppFindViewByIndex( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ); LONG NTAPI PhpFilePoolViewByBaseCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ); VOID PhFppAddViewByBase( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); VOID PhFppRemoveViewByBase( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); PPH_FILE_POOL_VIEW PhFppFindViewByBase( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ); PPH_FILE_POOL_VIEW PhFppCreateView( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ); VOID PhFppDestroyView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); VOID PhFppActivateView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); VOID PhFppDeactivateView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); VOID PhFppReferenceView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); VOID PhFppDereferenceView( - __inout PPH_FILE_POOL Pool, - __inout PPH_FILE_POOL_VIEW View + _Inout_ PPH_FILE_POOL Pool, + _Inout_ PPH_FILE_POOL_VIEW View ); PPH_FP_BLOCK_HEADER PhFppReferenceSegment( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ); VOID PhFppDereferenceSegment( - __inout PPH_FILE_POOL Pool, - __in ULONG SegmentIndex + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex ); VOID PhFppReferenceSegmentByBase( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ); VOID PhFppDereferenceSegmentByBase( - __inout PPH_FILE_POOL Pool, - __in PVOID Base + _Inout_ PPH_FILE_POOL Pool, + _In_ PVOID Base ); // Bitmap allocation PPH_FP_BLOCK_HEADER PhFppAllocateBlocks( - __inout PPH_FILE_POOL Pool, - __in PPH_FP_BLOCK_HEADER FirstBlock, - __inout PPH_FP_SEGMENT_HEADER SegmentHeader, - __in ULONG NumberOfBlocks + _Inout_ PPH_FILE_POOL Pool, + _In_ PPH_FP_BLOCK_HEADER FirstBlock, + _Inout_ PPH_FP_SEGMENT_HEADER SegmentHeader, + _In_ ULONG NumberOfBlocks ); VOID PhFppFreeBlocks( - __inout PPH_FILE_POOL Pool, - __in PPH_FP_BLOCK_HEADER FirstBlock, - __inout PPH_FP_SEGMENT_HEADER SegmentHeader, - __in PPH_FP_BLOCK_HEADER BlockHeader + _Inout_ PPH_FILE_POOL Pool, + _In_ PPH_FP_BLOCK_HEADER FirstBlock, + _Inout_ PPH_FP_SEGMENT_HEADER SegmentHeader, + _In_ PPH_FP_BLOCK_HEADER BlockHeader ); // Free list ULONG PhFppComputeFreeListIndex( - __in PPH_FILE_POOL Pool, - __in ULONG NumberOfBlocks + _In_ PPH_FILE_POOL Pool, + _In_ ULONG NumberOfBlocks ); BOOLEAN PhFppInsertFreeList( - __inout PPH_FILE_POOL Pool, - __in ULONG FreeListIndex, - __in ULONG SegmentIndex, - __in PPH_FP_SEGMENT_HEADER SegmentHeader + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG FreeListIndex, + _In_ ULONG SegmentIndex, + _In_ PPH_FP_SEGMENT_HEADER SegmentHeader ); BOOLEAN PhFppRemoveFreeList( - __inout PPH_FILE_POOL Pool, - __in ULONG FreeListIndex, - __in ULONG SegmentIndex, - __in PPH_FP_SEGMENT_HEADER SegmentHeader + _Inout_ PPH_FILE_POOL Pool, + _In_ ULONG FreeListIndex, + _In_ ULONG SegmentIndex, + _In_ PPH_FP_SEGMENT_HEADER SegmentHeader ); // Misc. PPH_FP_BLOCK_HEADER PhFppGetHeaderBlock( - __in PPH_FILE_POOL Pool, - __in PVOID Block + _In_ PPH_FILE_POOL Pool, + _In_ PVOID Block ); ULONG PhFppEncodeRva( - __in PPH_FILE_POOL Pool, - __in ULONG SegmentIndex, - __in PPH_FP_BLOCK_HEADER FirstBlock, - __in PVOID Address + _In_ PPH_FILE_POOL Pool, + _In_ ULONG SegmentIndex, + _In_ PPH_FP_BLOCK_HEADER FirstBlock, + _In_ PVOID Address ); ULONG PhFppDecodeRva( - __in PPH_FILE_POOL Pool, - __in ULONG Rva, - __out PULONG SegmentIndex + _In_ PPH_FILE_POOL Pool, + _In_ ULONG Rva, + _Out_ PULONG SegmentIndex ); #endif diff --git a/2.x/trunk/phlib/include/graph.h b/2.x/trunk/phlib/include/graph.h index f48374f3c..d4ccf7eeb 100644 --- a/2.x/trunk/phlib/include/graph.h +++ b/2.x/trunk/phlib/include/graph.h @@ -54,25 +54,25 @@ BOOLEAN PhGraphControlInitialization( PHLIBAPI VOID PhDrawGraph( - __in HDC hdc, - __in PPH_GRAPH_DRAW_INFO DrawInfo + _In_ HDC hdc, + _In_ PPH_GRAPH_DRAW_INFO DrawInfo ); PHLIBAPI VOID PhDrawGraphDirect( - __in HDC hdc, - __in PVOID Bits, - __in PPH_GRAPH_DRAW_INFO DrawInfo + _In_ HDC hdc, + _In_ PVOID Bits, + _In_ PPH_GRAPH_DRAW_INFO DrawInfo ); PHLIBAPI VOID PhSetGraphText( - __in HDC hdc, - __inout PPH_GRAPH_DRAW_INFO DrawInfo, - __in PPH_STRINGREF Text, - __in PRECT Margin, - __in PRECT Padding, - __in ULONG Align + _In_ HDC hdc, + _Inout_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ PPH_STRINGREF Text, + _In_ PRECT Margin, + _In_ PRECT Padding, + _In_ ULONG Align ); // Configuration @@ -173,18 +173,18 @@ typedef struct _PH_GRAPH_BUFFERS } PH_GRAPH_BUFFERS, *PPH_GRAPH_BUFFERS; VOID PhInitializeGraphBuffers( - __out PPH_GRAPH_BUFFERS Buffers + _Out_ PPH_GRAPH_BUFFERS Buffers ); VOID PhDeleteGraphBuffers( - __inout PPH_GRAPH_BUFFERS Buffers + _Inout_ PPH_GRAPH_BUFFERS Buffers ); PHLIBAPI VOID PhGetDrawInfoGraphBuffers( - __inout PPH_GRAPH_BUFFERS Buffers, - __inout PPH_GRAPH_DRAW_INFO DrawInfo, - __in ULONG DataCount + _Inout_ PPH_GRAPH_BUFFERS Buffers, + _Inout_ PPH_GRAPH_DRAW_INFO DrawInfo, + _In_ ULONG DataCount ); // Graph control state @@ -214,19 +214,19 @@ typedef struct _PH_GRAPH_STATE PHLIBAPI VOID PhInitializeGraphState( - __out PPH_GRAPH_STATE State + _Out_ PPH_GRAPH_STATE State ); PHLIBAPI VOID PhDeleteGraphState( - __inout PPH_GRAPH_STATE State + _Inout_ PPH_GRAPH_STATE State ); PHLIBAPI VOID PhGraphStateGetDrawInfo( - __inout PPH_GRAPH_STATE State, - __in PPH_GRAPH_GETDRAWINFO GetDrawInfo, - __in ULONG DataCount + _Inout_ PPH_GRAPH_STATE State, + _In_ PPH_GRAPH_GETDRAWINFO GetDrawInfo, + _In_ ULONG DataCount ); #endif diff --git a/2.x/trunk/phlib/include/guisupp.h b/2.x/trunk/phlib/include/guisupp.h index 721173c07..a2c76bb90 100644 --- a/2.x/trunk/phlib/include/guisupp.h +++ b/2.x/trunk/phlib/include/guisupp.h @@ -8,31 +8,31 @@ #undef COBJMACROS typedef HRESULT (WINAPI *_SetWindowTheme)( - __in HWND hwnd, - __in LPCWSTR pszSubAppName, - __in LPCWSTR pszSubIdList + _In_ HWND hwnd, + _In_ LPCWSTR pszSubAppName, + _In_ LPCWSTR pszSubIdList ); typedef HRESULT (WINAPI *_SHCreateShellItem)( - __in_opt PCIDLIST_ABSOLUTE pidlParent, - __in_opt IShellFolder *psfParent, - __in PCUITEMID_CHILD pidl, - __out IShellItem **ppsi + _In_opt_ PCIDLIST_ABSOLUTE pidlParent, + _In_opt_ IShellFolder *psfParent, + _In_ PCUITEMID_CHILD pidl, + _Out_ IShellItem **ppsi ); typedef HRESULT (WINAPI *_SHOpenFolderAndSelectItems)( - __in PCIDLIST_ABSOLUTE pidlFolder, - __in UINT cidl, - __in_ecount_opt(cidl) PCUITEMID_CHILD_ARRAY *apidl, - __in DWORD dwFlags + _In_ PCIDLIST_ABSOLUTE pidlFolder, + _In_ UINT cidl, + _In_reads_opt_(cidl) PCUITEMID_CHILD_ARRAY *apidl, + _In_ DWORD dwFlags ); typedef HRESULT (WINAPI *_SHParseDisplayName)( - __in LPCWSTR pszName, - __in_opt IBindCtx *pbc, - __out PIDLIST_ABSOLUTE *ppidl, - __in SFGAOF sfgaoIn, - __out SFGAOF *psfgaoOut + _In_ LPCWSTR pszName, + _In_opt_ IBindCtx *pbc, + _Out_ PIDLIST_ABSOLUTE *ppidl, + _In_ SFGAOF sfgaoIn, + _Out_ SFGAOF *psfgaoOut ); #ifndef _PH_GUISUP_PRIVATE diff --git a/2.x/trunk/phlib/include/handlep.h b/2.x/trunk/phlib/include/handlep.h index 28fb9d10c..916dae357 100644 --- a/2.x/trunk/phlib/include/handlep.h +++ b/2.x/trunk/phlib/include/handlep.h @@ -45,16 +45,16 @@ typedef struct _PH_HANDLE_TABLE } PH_HANDLE_TABLE, *PPH_HANDLE_TABLE; FORCEINLINE VOID PhpLockHandleTableShared( - __inout PPH_HANDLE_TABLE HandleTable, - __in ULONG Index + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ ULONG Index ) { PhAcquireQueuedLockShared(&HandleTable->Locks[Index]); } FORCEINLINE VOID PhpUnlockHandleTableShared( - __inout PPH_HANDLE_TABLE HandleTable, - __in ULONG Index + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ ULONG Index ) { PhReleaseQueuedLockShared(&HandleTable->Locks[Index]); @@ -80,72 +80,72 @@ FORCEINLINE VOID PhpUnlockHandleTableShared( #define PH_HANDLE_VALUE_IS_INVALID(HandleValue) (((HandleValue) >> 24) != 0) FORCEINLINE HANDLE PhpEncodeHandle( - __in ULONG HandleValue + _In_ ULONG HandleValue ) { return (HANDLE)((HandleValue << PH_HANDLE_VALUE_SHIFT) + PH_HANDLE_VALUE_BIAS); } FORCEINLINE ULONG PhpDecodeHandle( - __in HANDLE Handle + _In_ HANDLE Handle ) { return ((ULONG)Handle - PH_HANDLE_VALUE_BIAS) >> PH_HANDLE_VALUE_SHIFT; } VOID PhpBlockOnLockedHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __in PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ); PPH_HANDLE_TABLE_ENTRY PhpAllocateHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __out PULONG HandleValue + _Inout_ PPH_HANDLE_TABLE HandleTable, + _Out_ PULONG HandleValue ); VOID PhpFreeHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __in ULONG HandleValue, - __inout PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ ULONG HandleValue, + _Inout_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ); BOOLEAN PhpAllocateMoreHandleTableEntries( - __in __assumeLocked PPH_HANDLE_TABLE HandleTable, - __in BOOLEAN Initialize + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ BOOLEAN Initialize ); PPH_HANDLE_TABLE_ENTRY PhpLookupHandleTableEntry( - __in PPH_HANDLE_TABLE HandleTable, - __in ULONG HandleValue + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ ULONG HandleValue ); ULONG PhpMoveFreeHandleTableEntries( - __inout __assumeLocked PPH_HANDLE_TABLE HandleTable + _Inout_ PPH_HANDLE_TABLE HandleTable ); PPH_HANDLE_TABLE_ENTRY PhpCreateHandleTableLevel0( - __in PPH_HANDLE_TABLE HandleTable, - __in BOOLEAN Initialize + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ BOOLEAN Initialize ); VOID PhpFreeHandleTableLevel0( - __in PPH_HANDLE_TABLE_ENTRY Table + _In_ PPH_HANDLE_TABLE_ENTRY Table ); PPH_HANDLE_TABLE_ENTRY *PhpCreateHandleTableLevel1( - __in PPH_HANDLE_TABLE HandleTable + _In_ PPH_HANDLE_TABLE HandleTable ); VOID PhpFreeHandleTableLevel1( - __in PPH_HANDLE_TABLE_ENTRY *Table + _In_ PPH_HANDLE_TABLE_ENTRY *Table ); PPH_HANDLE_TABLE_ENTRY **PhpCreateHandleTableLevel2( - __in PPH_HANDLE_TABLE HandleTable + _In_ PPH_HANDLE_TABLE HandleTable ); VOID PhpFreeHandleTableLevel2( - __in PPH_HANDLE_TABLE_ENTRY **Table + _In_ PPH_HANDLE_TABLE_ENTRY **Table ); #endif diff --git a/2.x/trunk/phlib/include/hexeditp.h b/2.x/trunk/phlib/include/hexeditp.h index 866d39e6d..2aa1f688b 100644 --- a/2.x/trunk/phlib/include/hexeditp.h +++ b/2.x/trunk/phlib/include/hexeditp.h @@ -49,144 +49,144 @@ typedef struct _PHP_HEXEDIT_CONTEXT RedrawWindow((hwnd), NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE) VOID PhpCreateHexEditContext( - __out PPHP_HEXEDIT_CONTEXT *Context + _Out_ PPHP_HEXEDIT_CONTEXT *Context ); VOID PhpFreeHexEditContext( - __in __post_invalid PPHP_HEXEDIT_CONTEXT Context + _In_ _Post_invalid_ PPHP_HEXEDIT_CONTEXT Context ); LRESULT CALLBACK PhpHexEditWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID PhpHexEditOnPaint( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in PAINTSTRUCT *PaintStruct, - __in HDC hdc + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ PAINTSTRUCT *PaintStruct, + _In_ HDC hdc ); VOID PhpHexEditUpdateScrollbars( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); FORCEINLINE BOOLEAN PhpHexEditHasSelected( - __in PPHP_HEXEDIT_CONTEXT Context + _In_ PPHP_HEXEDIT_CONTEXT Context ) { return Context->SelStart != -1; } VOID PhpHexEditCreateAddressCaret( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditCreateEditCaret( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditRepositionCaret( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG Position + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG Position ); VOID PhpHexEditCalculatePosition( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG X, - __in LONG Y, - __out POINT *Point + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG X, + _In_ LONG Y, + _Out_ POINT *Point ); VOID PhpHexEditMove( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG X, - __in LONG Y + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG X, + _In_ LONG Y ); VOID PhpHexEditSetSel( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG S, - __in LONG E + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG S, + _In_ LONG E ); VOID PhpHexEditScrollTo( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG Position + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG Position ); VOID PhpHexEditClearEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditCopyEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditCutEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditPasteEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditSelectAll( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditUndoEdit( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditNormalizeSel( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context ); VOID PhpHexEditSelDelete( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG S, - __in LONG E + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG S, + _In_ LONG E ); VOID PhpHexEditSelInsert( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in LONG S, - __in LONG L + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ LONG S, + _In_ LONG L ); VOID PhpHexEditSetBuffer( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in PUCHAR Data, - __in ULONG Length + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ PUCHAR Data, + _In_ ULONG Length ); VOID PhpHexEditSetData( - __in HWND hwnd, - __in PPHP_HEXEDIT_CONTEXT Context, - __in PUCHAR Data, - __in ULONG Length + _In_ HWND hwnd, + _In_ PPHP_HEXEDIT_CONTEXT Context, + _In_ PUCHAR Data, + _In_ ULONG Length ); #endif diff --git a/2.x/trunk/phlib/include/iosupp.h b/2.x/trunk/phlib/include/iosupp.h index b13dceb1b..d6c2a0087 100644 --- a/2.x/trunk/phlib/include/iosupp.h +++ b/2.x/trunk/phlib/include/iosupp.h @@ -2,39 +2,39 @@ #define _PH_IOSUPP_H VOID NTAPI PhpFileStreamDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); NTSTATUS PhpAllocateBufferFileStream( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ); NTSTATUS PhpReadFileStream( - __inout PPH_FILE_STREAM FileStream, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG ReadLength + _Inout_ PPH_FILE_STREAM FileStream, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReadLength ); NTSTATUS PhpWriteFileStream( - __inout PPH_FILE_STREAM FileStream, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ); NTSTATUS PhpFlushReadFileStream( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ); NTSTATUS PhpFlushWriteFileStream( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ); NTSTATUS PhpSeekFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Offset, - __in PH_SEEK_ORIGIN Origin + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Offset, + _In_ PH_SEEK_ORIGIN Origin ); #endif diff --git a/2.x/trunk/phlib/include/kphapi.h b/2.x/trunk/phlib/include/kphapi.h index 3264fa94e..64ef14e2c 100644 --- a/2.x/trunk/phlib/include/kphapi.h +++ b/2.x/trunk/phlib/include/kphapi.h @@ -8,7 +8,7 @@ typedef enum _KPH_PROCESS_INFORMATION_CLASS { - KphProcessProtectionInformation = 1, // qs: KPH_PROCESS_PROTECTION_INFORMATION + KphProcessProtectionInformation = 1, // q: KPH_PROCESS_PROTECTION_INFORMATION KphProcessExecuteFlags = 2, // s: ULONG KphProcessIoPriority = 3, // qs: ULONG MaxKphProcessInfoClass @@ -131,13 +131,15 @@ typedef struct _KPH_DYN_STRUCT_DATA { SHORT EgeGuid; SHORT EpObjectTable; - SHORT EpProtectedProcessOff; - SHORT EpProtectedProcessBit; + SHORT Reserved0; + SHORT Reserved1; SHORT EpRundownProtect; SHORT EreGuidEntry; SHORT HtHandleContentionEvent; SHORT OtName; SHORT OtIndex; + SHORT ObDecodeShift; + SHORT ObAttributesShift; } KPH_DYN_STRUCT_DATA, *PKPH_DYN_STRUCT_DATA; typedef struct _KPH_DYN_PACKAGE @@ -150,7 +152,7 @@ typedef struct _KPH_DYN_PACKAGE KPH_DYN_STRUCT_DATA StructData; } KPH_DYN_PACKAGE, *PKPH_DYN_PACKAGE; -#define KPH_DYN_CONFIGURATION_VERSION 1 +#define KPH_DYN_CONFIGURATION_VERSION 2 #define KPH_DYN_MAXIMUM_PACKAGES 64 typedef struct _KPH_DYN_CONFIGURATION diff --git a/2.x/trunk/phlib/include/kphuser.h b/2.x/trunk/phlib/include/kphuser.h index 5b89b9d32..f5f3f7260 100644 --- a/2.x/trunk/phlib/include/kphuser.h +++ b/2.x/trunk/phlib/include/kphuser.h @@ -13,24 +13,24 @@ PHLIBAPI NTSTATUS NTAPI KphConnect( - __in_opt PWSTR DeviceName + _In_opt_ PWSTR DeviceName ); PHLIBAPI NTSTATUS NTAPI KphConnect2( - __in_opt PWSTR DeviceName, - __in PWSTR FileName + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName ); PHLIBAPI NTSTATUS NTAPI KphConnect2Ex( - __in_opt PWSTR DeviceName, - __in PWSTR FileName, - __in_opt PKPH_PARAMETERS Parameters + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName, + _In_opt_ PKPH_PARAMETERS Parameters ); PHLIBAPI @@ -51,296 +51,296 @@ PHLIBAPI NTSTATUS NTAPI KphSetParameters( - __in_opt PWSTR DeviceName, - __in PKPH_PARAMETERS Parameters + _In_opt_ PWSTR DeviceName, + _In_ PKPH_PARAMETERS Parameters ); PHLIBAPI NTSTATUS NTAPI KphInstall( - __in_opt PWSTR DeviceName, - __in PWSTR FileName + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName ); PHLIBAPI NTSTATUS NTAPI KphInstallEx( - __in_opt PWSTR DeviceName, - __in PWSTR FileName, - __in_opt PKPH_PARAMETERS Parameters + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName, + _In_opt_ PKPH_PARAMETERS Parameters ); PHLIBAPI NTSTATUS NTAPI KphUninstall( - __in_opt PWSTR DeviceName + _In_opt_ PWSTR DeviceName ); PHLIBAPI NTSTATUS NTAPI KphGetFeatures( - __out PULONG Features + _Out_ PULONG Features ); PHLIBAPI NTSTATUS NTAPI KphOpenProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in PCLIENT_ID ClientId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PCLIENT_ID ClientId ); PHLIBAPI NTSTATUS NTAPI KphOpenProcessToken( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE TokenHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE TokenHandle ); PHLIBAPI NTSTATUS NTAPI KphOpenProcessJob( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE JobHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE JobHandle ); PHLIBAPI NTSTATUS NTAPI KphSuspendProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); PHLIBAPI NTSTATUS NTAPI KphResumeProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); PHLIBAPI NTSTATUS NTAPI KphTerminateProcess( - __in HANDLE ProcessHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ProcessHandle, + _In_ NTSTATUS ExitStatus ); PHLIBAPI NTSTATUS NTAPI KphReadVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ); PHLIBAPI NTSTATUS NTAPI KphWriteVirtualMemory( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ); PHLIBAPI NTSTATUS NTAPI KphReadVirtualMemoryUnsafe( - __in_opt HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_opt_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationProcess( - __in HANDLE ProcessHandle, - __in KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, - __out_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _In_ KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, + _Out_writes_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength, + _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphSetInformationProcess( - __in HANDLE ProcessHandle, - __in KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, - __in_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength + _In_ HANDLE ProcessHandle, + _In_ KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, + _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength ); PHLIBAPI NTSTATUS NTAPI KphOpenThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in PCLIENT_ID ClientId + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PCLIENT_ID ClientId ); PHLIBAPI NTSTATUS NTAPI KphOpenThreadProcess( - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE ProcessHandle + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE ProcessHandle ); PHLIBAPI NTSTATUS NTAPI KphTerminateThread( - __in HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ); PHLIBAPI NTSTATUS NTAPI KphTerminateThreadUnsafe( - __in HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ); PHLIBAPI NTSTATUS NTAPI KphGetContextThread( - __in HANDLE ThreadHandle, - __inout PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _Inout_ PCONTEXT ThreadContext ); PHLIBAPI NTSTATUS NTAPI KphSetContextThread( - __in HANDLE ThreadHandle, - __in PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _In_ PCONTEXT ThreadContext ); PHLIBAPI NTSTATUS NTAPI KphCaptureStackBackTraceThread( - __in HANDLE ThreadHandle, - __in ULONG FramesToSkip, - __in ULONG FramesToCapture, - __out_ecount(FramesToCapture) PVOID *BackTrace, - __out_opt PULONG CapturedFrames, - __out_opt PULONG BackTraceHash + _In_ HANDLE ThreadHandle, + _In_ ULONG FramesToSkip, + _In_ ULONG FramesToCapture, + _Out_writes_(FramesToCapture) PVOID *BackTrace, + _Out_opt_ PULONG CapturedFrames, + _Out_opt_ PULONG BackTraceHash ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationThread( - __in HANDLE ThreadHandle, - __in KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, - __out_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ThreadHandle, + _In_ KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, + _Out_writes_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength, + _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphSetInformationThread( - __in HANDLE ThreadHandle, - __in KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, - __in_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength + _In_ HANDLE ThreadHandle, + _In_ KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, + _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength ); PHLIBAPI NTSTATUS NTAPI KphEnumerateProcessHandles( - __in HANDLE ProcessHandle, - __out_bcount(BufferLength) PVOID Buffer, - __in_opt ULONG BufferLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _Out_writes_bytes_(BufferLength) PVOID Buffer, + _In_opt_ ULONG BufferLength, + _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationObject( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, - __out_bcount(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, + _Out_writes_bytes_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength, + _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI KphSetInformationObject( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, - __in_bcount(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, + _In_reads_bytes_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength ); PHLIBAPI NTSTATUS NTAPI KphDuplicateObject( - __in HANDLE SourceProcessHandle, - __in HANDLE SourceHandle, - __in_opt HANDLE TargetProcessHandle, - __out_opt PHANDLE TargetHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Options + _In_ HANDLE SourceProcessHandle, + _In_ HANDLE SourceHandle, + _In_opt_ HANDLE TargetProcessHandle, + _Out_opt_ PHANDLE TargetHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Options ); PHLIBAPI NTSTATUS NTAPI KphOpenDriver( - __out PHANDLE DriverHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE DriverHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); PHLIBAPI NTSTATUS NTAPI KphQueryInformationDriver( - __in HANDLE DriverHandle, - __in DRIVER_INFORMATION_CLASS DriverInformationClass, - __out_bcount(DriverInformationLength) PVOID DriverInformation, - __in ULONG DriverInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE DriverHandle, + _In_ DRIVER_INFORMATION_CLASS DriverInformationClass, + _Out_writes_bytes_(DriverInformationLength) PVOID DriverInformation, + _In_ ULONG DriverInformationLength, + _Out_opt_ PULONG ReturnLength ); // kphdata NTSTATUS KphInitializeDynamicPackage( - __out PKPH_DYN_PACKAGE Package + _Out_ PKPH_DYN_PACKAGE Package ); #endif diff --git a/2.x/trunk/phlib/include/md5.h b/2.x/trunk/phlib/include/md5.h index b60557ae9..b3cbe23fe 100644 --- a/2.x/trunk/phlib/include/md5.h +++ b/2.x/trunk/phlib/include/md5.h @@ -10,17 +10,17 @@ typedef struct } MD5_CTX; VOID MD5Init( - __out MD5_CTX *Context + _Out_ MD5_CTX *Context ); VOID MD5Update( - __inout MD5_CTX *Context, - __in_bcount(Length) UCHAR *Input, - __in ULONG Length + _Inout_ MD5_CTX *Context, + _In_reads_bytes_(Length) UCHAR *Input, + _In_ ULONG Length ); VOID MD5Final( - __inout MD5_CTX *Context + _Inout_ MD5_CTX *Context ); #endif diff --git a/2.x/trunk/phlib/include/ntbasic.h b/2.x/trunk/phlib/include/ntbasic.h index 528d02b2b..34c650430 100644 --- a/2.x/trunk/phlib/include/ntbasic.h +++ b/2.x/trunk/phlib/include/ntbasic.h @@ -28,7 +28,7 @@ typedef PVOID *PPVOID; typedef ULONG LOGICAL; typedef ULONG *PLOGICAL; -typedef __success(return >= 0) LONG NTSTATUS; +typedef _Success_(return >= 0) LONG NTSTATUS; typedef NTSTATUS *PNTSTATUS; // Cardinal types @@ -97,7 +97,7 @@ typedef struct _STRING { USHORT Length; USHORT MaximumLength; - __field_bcount_part_opt(MaximumLength, Length) PCHAR Buffer; + _Field_size_bytes_part_opt_(MaximumLength, Length) PCHAR Buffer; } STRING, *PSTRING, ANSI_STRING, *PANSI_STRING, OEM_STRING, *POEM_STRING; typedef const STRING *PCSTRING; @@ -108,7 +108,7 @@ typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; - __field_bcount_part(MaximumLength, Length) PWCH Buffer; + _Field_size_bytes_part_(MaximumLength, Length) PWCH Buffer; } UNICODE_STRING, *PUNICODE_STRING; typedef const UNICODE_STRING *PCUNICODE_STRING; diff --git a/2.x/trunk/phlib/include/ntdbg.h b/2.x/trunk/phlib/include/ntdbg.h index cc6083744..ca4e51c53 100644 --- a/2.x/trunk/phlib/include/ntdbg.h +++ b/2.x/trunk/phlib/include/ntdbg.h @@ -115,56 +115,56 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateDebugObject( - __out PHANDLE DebugObjectHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG Flags + _Out_ PHANDLE DebugObjectHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI NtDebugActiveProcess( - __in HANDLE ProcessHandle, - __in HANDLE DebugObjectHandle + _In_ HANDLE ProcessHandle, + _In_ HANDLE DebugObjectHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtDebugContinue( - __in HANDLE DebugObjectHandle, - __in PCLIENT_ID ClientId, - __in NTSTATUS ContinueStatus + _In_ HANDLE DebugObjectHandle, + _In_ PCLIENT_ID ClientId, + _In_ NTSTATUS ContinueStatus ); NTSYSCALLAPI NTSTATUS NTAPI NtRemoveProcessDebug( - __in HANDLE ProcessHandle, - __in HANDLE DebugObjectHandle + _In_ HANDLE ProcessHandle, + _In_ HANDLE DebugObjectHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationDebugObject( - __in HANDLE DebugObjectHandle, - __in DEBUGOBJECTINFOCLASS DebugObjectInformationClass, - __in PVOID DebugInformation, - __in ULONG DebugInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE DebugObjectHandle, + _In_ DEBUGOBJECTINFOCLASS DebugObjectInformationClass, + _In_ PVOID DebugInformation, + _In_ ULONG DebugInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtWaitForDebugEvent( - __in HANDLE DebugObjectHandle, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout, - __out PVOID WaitStateChange + _In_ HANDLE DebugObjectHandle, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout, + _Out_ PVOID WaitStateChange ); // Debugging UI @@ -187,51 +187,51 @@ NTSYSAPI VOID NTAPI DbgUiSetThreadDebugObject( - __in HANDLE DebugObject + _In_ HANDLE DebugObject ); NTSYSAPI NTSTATUS NTAPI DbgUiWaitStateChange( - __out PDBGUI_WAIT_STATE_CHANGE StateChange, - __in_opt PLARGE_INTEGER Timeout + _Out_ PDBGUI_WAIT_STATE_CHANGE StateChange, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSAPI NTSTATUS NTAPI DbgUiContinue( - __in PCLIENT_ID AppClientId, - __in NTSTATUS ContinueStatus + _In_ PCLIENT_ID AppClientId, + _In_ NTSTATUS ContinueStatus ); NTSYSAPI NTSTATUS NTAPI DbgUiStopDebugging( - __in HANDLE Process + _In_ HANDLE Process ); NTSYSAPI NTSTATUS NTAPI DbgUiDebugActiveProcess( - __in HANDLE Process + _In_ HANDLE Process ); NTSYSAPI VOID NTAPI DbgUiRemoteBreakin( - __in PVOID Context + _In_ PVOID Context ); NTSYSAPI NTSTATUS NTAPI DbgUiIssueRemoteBreakin( - __in HANDLE Process + _In_ HANDLE Process ); struct _DEBUG_EVENT; @@ -240,8 +240,8 @@ NTSYSAPI NTSTATUS NTAPI DbgUiConvertStateChangeStructure( - __in PDBGUI_WAIT_STATE_CHANGE StateChange, - __out struct _DEBUG_EVENT *DebugEvent + _In_ PDBGUI_WAIT_STATE_CHANGE StateChange, + _Out_ struct _DEBUG_EVENT *DebugEvent ); #endif diff --git a/2.x/trunk/phlib/include/ntexapi.h b/2.x/trunk/phlib/include/ntexapi.h index 21c01d4a1..891b5ecea 100644 --- a/2.x/trunk/phlib/include/ntexapi.h +++ b/2.x/trunk/phlib/include/ntexapi.h @@ -11,8 +11,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtDelayExecution( - __in BOOLEAN Alertable, - __in PLARGE_INTEGER DelayInterval + _In_ BOOLEAN Alertable, + _In_ PLARGE_INTEGER DelayInterval ); // Environment values @@ -21,18 +21,18 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQuerySystemEnvironmentValue( - __in PUNICODE_STRING VariableName, - __out_bcount(ValueLength) PWSTR VariableValue, - __in USHORT ValueLength, - __out_opt PUSHORT ReturnLength + _In_ PUNICODE_STRING VariableName, + _Out_writes_bytes_(ValueLength) PWSTR VariableValue, + _In_ USHORT ValueLength, + _Out_opt_ PUSHORT ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetSystemEnvironmentValue( - __in PUNICODE_STRING VariableName, - __in PUNICODE_STRING VariableValue + _In_ PUNICODE_STRING VariableName, + _In_ PUNICODE_STRING VariableValue ); // Event @@ -56,69 +56,69 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateEvent( - __out PHANDLE EventHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in EVENT_TYPE EventType, - __in BOOLEAN InitialState + _Out_ PHANDLE EventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ EVENT_TYPE EventType, + _In_ BOOLEAN InitialState ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenEvent( - __out PHANDLE EventHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtSetEvent( - __in HANDLE EventHandle, - __out_opt PLONG PreviousState + _In_ HANDLE EventHandle, + _Out_opt_ PLONG PreviousState ); NTSYSCALLAPI NTSTATUS NTAPI NtSetEventBoostPriority( - __in HANDLE EventHandle + _In_ HANDLE EventHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtClearEvent( - __in HANDLE EventHandle + _In_ HANDLE EventHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtResetEvent( - __in HANDLE EventHandle, - __out_opt PLONG PreviousState + _In_ HANDLE EventHandle, + _Out_opt_ PLONG PreviousState ); NTSYSCALLAPI NTSTATUS NTAPI NtPulseEvent( - __in HANDLE EventHandle, - __out_opt PLONG PreviousState + _In_ HANDLE EventHandle, + _Out_opt_ PLONG PreviousState ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryEvent( - __in HANDLE EventHandle, - __in EVENT_INFORMATION_CLASS EventInformationClass, - __out_bcount(EventInformationLength) PVOID EventInformation, - __in ULONG EventInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE EventHandle, + _In_ EVENT_INFORMATION_CLASS EventInformationClass, + _Out_writes_bytes_(EventInformationLength) PVOID EventInformation, + _In_ ULONG EventInformationLength, + _Out_opt_ PULONG ReturnLength ); // Event Pair @@ -129,60 +129,60 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateEventPair( - __out PHANDLE EventPairHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EventPairHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenEventPair( - __out PHANDLE EventPairHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EventPairHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtSetLowEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtSetHighEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtWaitLowEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtWaitHighEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtSetLowWaitHighEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtSetHighWaitLowEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); // Mutant @@ -209,38 +209,38 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateMutant( - __out PHANDLE MutantHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in BOOLEAN InitialOwner + _Out_ PHANDLE MutantHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ BOOLEAN InitialOwner ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenMutant( - __out PHANDLE MutantHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE MutantHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtReleaseMutant( - __in HANDLE MutantHandle, - __out_opt PLONG PreviousCount + _In_ HANDLE MutantHandle, + _Out_opt_ PLONG PreviousCount ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryMutant( - __in HANDLE MutantHandle, - __in MUTANT_INFORMATION_CLASS MutantInformationClass, - __out_bcount(MutantInformationLength) PVOID MutantInformation, - __in ULONG MutantInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE MutantHandle, + _In_ MUTANT_INFORMATION_CLASS MutantInformationClass, + _Out_writes_bytes_(MutantInformationLength) PVOID MutantInformation, + _In_ ULONG MutantInformationLength, + _Out_opt_ PULONG ReturnLength ); // Semaphore @@ -264,40 +264,40 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateSemaphore( - __out PHANDLE SemaphoreHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in LONG InitialCount, - __in LONG MaximumCount + _Out_ PHANDLE SemaphoreHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ LONG InitialCount, + _In_ LONG MaximumCount ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenSemaphore( - __out PHANDLE SemaphoreHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE SemaphoreHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtReleaseSemaphore( - __in HANDLE SemaphoreHandle, - __in LONG ReleaseCount, - __out_opt PLONG PreviousCount + _In_ HANDLE SemaphoreHandle, + _In_ LONG ReleaseCount, + _Out_opt_ PLONG PreviousCount ); NTSYSCALLAPI NTSTATUS NTAPI NtQuerySemaphore( - __in HANDLE SemaphoreHandle, - __in SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass, - __out_bcount(SemaphoreInformationLength) PVOID SemaphoreInformation, - __in ULONG SemaphoreInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE SemaphoreHandle, + _In_ SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass, + _Out_writes_bytes_(SemaphoreInformationLength) PVOID SemaphoreInformation, + _In_ ULONG SemaphoreInformationLength, + _Out_opt_ PULONG ReturnLength ); // Timer @@ -314,9 +314,9 @@ typedef struct _TIMER_BASIC_INFORMATION } TIMER_BASIC_INFORMATION, *PTIMER_BASIC_INFORMATION; typedef VOID (NTAPI *PTIMER_APC_ROUTINE)( - __in PVOID TimerContext, - __in ULONG TimerLowValue, - __in LONG TimerHighValue + _In_ PVOID TimerContext, + _In_ ULONG TimerLowValue, + _In_ LONG TimerHighValue ); typedef enum _TIMER_SET_INFORMATION_CLASS @@ -330,13 +330,13 @@ struct _COUNTED_REASON_CONTEXT; typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO { - __in LARGE_INTEGER DueTime; - __in_opt PTIMER_APC_ROUTINE TimerApcRoutine; - __in_opt PVOID TimerContext; - __in_opt struct _COUNTED_REASON_CONTEXT *WakeContext; - __in_opt ULONG Period; - __in ULONG TolerableDelay; - __out_opt PBOOLEAN PreviousState; + _In_ LARGE_INTEGER DueTime; + _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine; + _In_opt_ PVOID TimerContext; + _In_opt_ struct _COUNTED_REASON_CONTEXT *WakeContext; + _In_opt_ ULONG Period; + _In_ ULONG TolerableDelay; + _Out_opt_ PBOOLEAN PreviousState; } TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO; #endif @@ -344,32 +344,32 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateTimer( - __out PHANDLE TimerHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in TIMER_TYPE TimerType + _Out_ PHANDLE TimerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ TIMER_TYPE TimerType ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenTimer( - __out PHANDLE TimerHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE TimerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtSetTimer( - __in HANDLE TimerHandle, - __in PLARGE_INTEGER DueTime, - __in_opt PTIMER_APC_ROUTINE TimerApcRoutine, - __in_opt PVOID TimerContext, - __in BOOLEAN ResumeTimer, - __in_opt LONG Period, - __out_opt PBOOLEAN PreviousState + _In_ HANDLE TimerHandle, + _In_ PLARGE_INTEGER DueTime, + _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine, + _In_opt_ PVOID TimerContext, + _In_ BOOLEAN ResumeTimer, + _In_opt_ LONG Period, + _Out_opt_ PBOOLEAN PreviousState ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -377,10 +377,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetTimerEx( - __in HANDLE TimerHandle, - __in TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, - __inout_bcount_opt(TimerSetInformationLength) PVOID TimerSetInformation, - __in ULONG TimerSetInformationLength + _In_ HANDLE TimerHandle, + _In_ TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, + _Inout_updates_bytes_opt_(TimerSetInformationLength) PVOID TimerSetInformation, + _In_ ULONG TimerSetInformationLength ); #endif @@ -388,19 +388,19 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCancelTimer( - __in HANDLE TimerHandle, - __out_opt PBOOLEAN CurrentState + _In_ HANDLE TimerHandle, + _Out_opt_ PBOOLEAN CurrentState ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryTimer( - __in HANDLE TimerHandle, - __in TIMER_INFORMATION_CLASS TimerInformationClass, - __out_bcount(TimerInformationLength) PVOID TimerInformation, - __in ULONG TimerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TimerHandle, + _In_ TIMER_INFORMATION_CLASS TimerInformationClass, + _Out_writes_bytes_(TimerInformationLength) PVOID TimerInformation, + _In_ ULONG TimerInformationLength, + _Out_opt_ PULONG ReturnLength ); // Profile @@ -412,15 +412,15 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateProfile( - __out PHANDLE ProfileHandle, - __in_opt HANDLE Process, - __in PVOID ProfileBase, - __in SIZE_T ProfileSize, - __in ULONG BucketSize, - __in PULONG Buffer, - __in ULONG BufferSize, - __in KPROFILE_SOURCE ProfileSource, - __in KAFFINITY Affinity + _Out_ PHANDLE ProfileHandle, + _In_opt_ HANDLE Process, + _In_ PVOID ProfileBase, + _In_ SIZE_T ProfileSize, + _In_ ULONG BucketSize, + _In_ PULONG Buffer, + _In_ ULONG BufferSize, + _In_ KPROFILE_SOURCE ProfileSource, + _In_ KAFFINITY Affinity ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -429,16 +429,16 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateProfileEx( - __out PHANDLE ProfileHandle, - __in_opt HANDLE Process, - __in PVOID ProfileBase, - __in SIZE_T ProfileSize, - __in ULONG BucketSize, - __in PULONG Buffer, - __in ULONG BufferSize, - __in KPROFILE_SOURCE ProfileSource, - __in ULONG GroupAffinityCount, - __in_opt PGROUP_AFFINITY GroupAffinity + _Out_ PHANDLE ProfileHandle, + _In_opt_ HANDLE Process, + _In_ PVOID ProfileBase, + _In_ SIZE_T ProfileSize, + _In_ ULONG BucketSize, + _In_ PULONG Buffer, + _In_ ULONG BufferSize, + _In_ KPROFILE_SOURCE ProfileSource, + _In_ ULONG GroupAffinityCount, + _In_opt_ PGROUP_AFFINITY GroupAffinity ); #endif @@ -446,30 +446,30 @@ NTSYSCALLAPI NTSTATUS NTAPI NtStartProfile( - __in HANDLE ProfileHandle + _In_ HANDLE ProfileHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtStopProfile( - __in HANDLE ProfileHandle + _In_ HANDLE ProfileHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryIntervalProfile( - __in KPROFILE_SOURCE ProfileSource, - __out PULONG Interval + _In_ KPROFILE_SOURCE ProfileSource, + _Out_ PULONG Interval ); NTSYSCALLAPI NTSTATUS NTAPI NtSetIntervalProfile( - __in ULONG Interval, - __in KPROFILE_SOURCE Source + _In_ ULONG Interval, + _In_ KPROFILE_SOURCE Source ); // Keyed Event @@ -483,39 +483,39 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateKeyedEvent( - __out PHANDLE KeyedEventHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG Flags + _Out_ PHANDLE KeyedEventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenKeyedEvent( - __out PHANDLE KeyedEventHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE KeyedEventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtReleaseKeyedEvent( - __in HANDLE KeyedEventHandle, - __in PVOID KeyValue, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE KeyedEventHandle, + _In_ PVOID KeyValue, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI NtWaitForKeyedEvent( - __in HANDLE KeyedEventHandle, - __in PVOID KeyValue, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE KeyedEventHandle, + _In_ PVOID KeyValue, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); // Worker factory @@ -552,10 +552,11 @@ typedef enum _WORKERFACTORYINFOCLASS WorkerFactoryThreadMinimum, WorkerFactoryThreadMaximum, WorkerFactoryPaused, - WorkerFactoryBasicInformation, // name:wow64:whNtQueryInformationWorkerFactory_WorkerFactoryBasicInformation + WorkerFactoryBasicInformation, WorkerFactoryAdjustThreadGoal, WorkerFactoryCallbackType, - WorkerFactoryStackInformation, // name:wow64:whNtQueryInformationWorkerFactory_WorkerFactoryStackInformation + WorkerFactoryStackInformation, + WorkerFactoryThreadBasePriority, MaxWorkerFactoryInfoClass } WORKERFACTORYINFOCLASS, *PWORKERFACTORYINFOCLASS; @@ -593,59 +594,59 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateWorkerFactory( - __out PHANDLE WorkerFactoryHandleReturn, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE CompletionPortHandle, - __in HANDLE WorkerProcessHandle, - __in PVOID StartRoutine, - __in_opt PVOID StartParameter, - __in_opt ULONG MaxThreadCount, - __in_opt SIZE_T StackReserve, - __in_opt SIZE_T StackCommit + _Out_ PHANDLE WorkerFactoryHandleReturn, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE CompletionPortHandle, + _In_ HANDLE WorkerProcessHandle, + _In_ PVOID StartRoutine, + _In_opt_ PVOID StartParameter, + _In_opt_ ULONG MaxThreadCount, + _In_opt_ SIZE_T StackReserve, + _In_opt_ SIZE_T StackCommit ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __in WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, - __out_bcount(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, - __in ULONG WorkerFactoryInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE WorkerFactoryHandle, + _In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, + _Out_writes_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, + _In_ ULONG WorkerFactoryInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __in WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, - __in_bcount(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, - __in ULONG WorkerFactoryInformationLength + _In_ HANDLE WorkerFactoryHandle, + _In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, + _In_reads_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, + _In_ ULONG WorkerFactoryInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI NtShutdownWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __inout volatile LONG *PendingWorkerCount + _In_ HANDLE WorkerFactoryHandle, + _Inout_ volatile LONG *PendingWorkerCount ); NTSYSCALLAPI NTSTATUS NTAPI NtReleaseWorkerFactoryWorker( - __in HANDLE WorkerFactoryHandle + _In_ HANDLE WorkerFactoryHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtWorkerFactoryWorkerReady( - __in HANDLE WorkerFactoryHandle + _In_ HANDLE WorkerFactoryHandle ); struct _FILE_IO_COMPLETION_INFORMATION; @@ -654,8 +655,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtWaitForWorkViaWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __out struct _FILE_IO_COMPLETION_INFORMATION *MiniPacket + _In_ HANDLE WorkerFactoryHandle, + _Out_ struct _FILE_IO_COMPLETION_INFORMATION *MiniPacket ); #endif @@ -668,33 +669,33 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQuerySystemTime( - __out PLARGE_INTEGER SystemTime + _Out_ PLARGE_INTEGER SystemTime ); NTSYSCALLAPI NTSTATUS NTAPI NtSetSystemTime( - __in_opt PLARGE_INTEGER SystemTime, - __out_opt PLARGE_INTEGER PreviousTime + _In_opt_ PLARGE_INTEGER SystemTime, + _Out_opt_ PLARGE_INTEGER PreviousTime ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryTimerResolution( - __out PULONG MaximumTime, - __out PULONG MinimumTime, - __out PULONG CurrentTime + _Out_ PULONG MaximumTime, + _Out_ PULONG MinimumTime, + _Out_ PULONG CurrentTime ); NTSYSCALLAPI NTSTATUS NTAPI NtSetTimerResolution( - __in ULONG DesiredTime, - __in BOOLEAN SetResolution, - __out PULONG ActualTime + _In_ ULONG DesiredTime, + _In_ BOOLEAN SetResolution, + _Out_ PULONG ActualTime ); // Performance Counter @@ -703,8 +704,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryPerformanceCounter( - __out PLARGE_INTEGER PerformanceCounter, - __out_opt PLARGE_INTEGER PerformanceFrequency + _Out_ PLARGE_INTEGER PerformanceCounter, + _Out_opt_ PLARGE_INTEGER PerformanceFrequency ); // LUIDs @@ -713,7 +714,7 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAllocateLocallyUniqueId( - __out PLUID Luid + _Out_ PLUID Luid ); // UUIDs @@ -722,17 +723,17 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetUuidSeed( - __in PCHAR Seed + _In_ PCHAR Seed ); NTSYSCALLAPI NTSTATUS NTAPI NtAllocateUuids( - __out PULARGE_INTEGER Time, - __out PULONG Range, - __out PULONG Sequence, - __out PCHAR Seed + _Out_ PULARGE_INTEGER Time, + _Out_ PULONG Range, + _Out_ PULONG Sequence, + _Out_ PCHAR Seed ); // System Information @@ -874,7 +875,7 @@ typedef enum _SYSTEM_INFORMATION_CLASS SystemScrubPhysicalMemoryInformation, SystemBadPageInformation, SystemProcessorProfileControlArea, - SystemCombinePhysicalMemoryInformation, + SystemCombinePhysicalMemoryInformation, // 130 SystemEntropyInterruptTimingCallback, SystemConsoleInformation, SystemPlatformBinaryInformation, @@ -884,7 +885,23 @@ typedef enum _SYSTEM_INFORMATION_CLASS SystemDeviceDataEnumerationInformation, SystemMemoryTopologyInformation, SystemMemoryChannelInformation, - SystemBootLogoInformation, + SystemBootLogoInformation, // 140 + SystemProcessorPerformanceInformationEx, // since WINBLUE + SystemSpare0, + SystemSecureBootPolicyInformation, + SystemPageFileInformationEx, + SystemSecureBootInformation, + SystemEntropyInterruptTimingRawInformation, + SystemPortableWorkspaceEfiLauncherInformation, + SystemFullProcessInformation, // q: SYSTEM_PROCESS_INFORMATION with SYSTEM_PROCESS_INFORMATION_EXTENSION (requires admin) + SystemKernelDebuggerInformationEx, + SystemBootMetadataInformation, // 150 + SystemSoftRebootInformation, + SystemElamCertificateInformation, + SystemOfflineDumpConfigInformation, + SystemProcessorFeaturesInformation, + SystemRegistryReconciliationInformation, + SystemEdidInformation, MaxSystemInfoClass } SYSTEM_INFORMATION_CLASS; @@ -1545,7 +1562,7 @@ typedef struct _SYSTEM_SYSTEM_DISK_INFORMATION // private typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT { - ULONG Hits; + LARGE_INTEGER Hits; // ULONG in WIN8 UCHAR PercentFrequency; } SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT, *PSYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT; @@ -1711,16 +1728,43 @@ typedef struct _SYSTEM_QUERY_PERFORMANCE_COUNTER_INFORMATION // end_msdn +// private +typedef struct _PROCESS_DISK_COUNTERS +{ + ULONGLONG BytesRead; + ULONGLONG BytesWritten; + ULONGLONG ReadOperationCount; + ULONGLONG WriteOperationCount; + ULONGLONG FlushOperationCount; +} PROCESS_DISK_COUNTERS, *PPROCESS_DISK_COUNTERS; + +// private +typedef struct _SYSTEM_PROCESS_INFORMATION_EXTENSION +{ + PROCESS_DISK_COUNTERS DiskCounters; + ULONGLONG ContextSwitches; + union + { + ULONG Flags; + struct + { + ULONG HasStrongId : 1; + ULONG Spare : 31; + }; + }; + ULONG UserSidOffset; +} SYSTEM_PROCESS_INFORMATION_EXTENSION, *PSYSTEM_PROCESS_INFORMATION_EXTENSION; + #if (PHNT_MODE != PHNT_MODE_KERNEL) NTSYSCALLAPI NTSTATUS NTAPI NtQuerySystemInformation( - __in SYSTEM_INFORMATION_CLASS SystemInformationClass, - __out_bcount_opt(SystemInformationLength) PVOID SystemInformation, - __in ULONG SystemInformationLength, - __out_opt PULONG ReturnLength + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, + _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation, + _In_ ULONG SystemInformationLength, + _Out_opt_ PULONG ReturnLength ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -1729,12 +1773,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQuerySystemInformationEx( - __in SYSTEM_INFORMATION_CLASS SystemInformationClass, - __in_bcount(QueryInformationLength) PVOID QueryInformation, - __in ULONG QueryInformationLength, - __out_bcount_opt(SystemInformationLength) PVOID SystemInformation, - __in ULONG SystemInformationLength, - __out_opt PULONG ReturnLength + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, + _In_reads_bytes_(QueryInformationLength) PVOID QueryInformation, + _In_ ULONG QueryInformationLength, + _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation, + _In_ ULONG SystemInformationLength, + _Out_opt_ PULONG ReturnLength ); #endif @@ -1742,9 +1786,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetSystemInformation( - __in SYSTEM_INFORMATION_CLASS SystemInformationClass, - __in_bcount_opt(SystemInformationLength) PVOID SystemInformation, - __in ULONG SystemInformationLength + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, + _In_reads_bytes_opt_(SystemInformationLength) PVOID SystemInformation, + _In_ ULONG SystemInformationLength ); // SysDbg APIs @@ -1861,12 +1905,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSystemDebugControl( - __in SYSDBG_COMMAND Command, - __inout_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength, - __out_opt PULONG ReturnLength + _In_ SYSDBG_COMMAND Command, + _Inout_updates_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength, + _Out_opt_ PULONG ReturnLength ); // Hard errors @@ -1905,12 +1949,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRaiseHardError( - __in NTSTATUS ErrorStatus, - __in ULONG NumberOfParameters, - __in ULONG UnicodeStringParameterMask, - __in_ecount(NumberOfParameters) PULONG_PTR Parameters, - __in ULONG ValidResponseOptions, - __out PULONG Response + _In_ NTSTATUS ErrorStatus, + _In_ ULONG NumberOfParameters, + _In_ ULONG UnicodeStringParameterMask, + _In_reads_(NumberOfParameters) PULONG_PTR Parameters, + _In_ ULONG ValidResponseOptions, + _Out_ PULONG Response ); // Kernel-user shared data @@ -2113,20 +2157,6 @@ C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TestRetInstruction) == 0x2f8); C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCallPad) == 0x308); C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TickCount) == 0x320); C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TickCountQuad) == 0x320); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, Cookie) == 0x330); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ConsoleSessionForegroundProcessId) == 0x338); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, UserModeGlobalLogger) == 0x380); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ImageFileExecutionOptions) == 0x3a0); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, LangGenerationCount) == 0x3a4); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, InterruptTimeBias) == 0x3b0); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, UserModeGlobalLogger) == 0x380); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ImageFileExecutionOptions) == 0x3a0); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, LangGenerationCount) == 0x3a4); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, InterruptTimeBias) == 0x3b0); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, TscQpcBias) == 0x3b8); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ActiveProcessorCount) == 0x3c0); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, ActiveGroupCount) == 0x3c4); -C_ASSERT(FIELD_OFFSET(KUSER_SHARED_DATA, XState) == 0x3d8); #ifdef _M_IX86 #define USER_SHARED_DATA ((KUSER_SHARED_DATA * const)0x7ffe0000) @@ -2200,23 +2230,23 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryDefaultLocale( - __in BOOLEAN UserProfile, - __out PLCID DefaultLocaleId + _In_ BOOLEAN UserProfile, + _Out_ PLCID DefaultLocaleId ); NTSYSCALLAPI NTSTATUS NTAPI NtSetDefaultLocale( - __in BOOLEAN UserProfile, - __in LCID DefaultLocaleId + _In_ BOOLEAN UserProfile, + _In_ LCID DefaultLocaleId ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryInstallUILanguage( - __out LANGID *InstallUILanguageId + _Out_ LANGID *InstallUILanguageId ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -2225,8 +2255,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtFlushInstallUILanguage( - __in LANGID InstallUILanguage, - __in ULONG SetComittedFlag + _In_ LANGID InstallUILanguage, + _In_ ULONG SetComittedFlag ); #endif @@ -2234,14 +2264,14 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryDefaultUILanguage( - __out LANGID *DefaultUILanguageId + _Out_ LANGID *DefaultUILanguageId ); NTSYSCALLAPI NTSTATUS NTAPI NtSetDefaultUILanguage( - __in LANGID DefaultUILanguageId + _In_ LANGID DefaultUILanguageId ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -2265,19 +2295,19 @@ NTSYSCALLAPI NTSTATUS NTAPI NtInitializeNlsFiles( - __out PVOID *BaseAddress, - __out PLCID DefaultLocaleId, - __out PLARGE_INTEGER DefaultCasingTableSize + _Out_ PVOID *BaseAddress, + _Out_ PLCID DefaultLocaleId, + _Out_ PLARGE_INTEGER DefaultCasingTableSize ); #else NTSYSCALLAPI NTSTATUS NTAPI NtInitializeNlsFiles( - __out PVOID *BaseAddress, - __out PLCID DefaultLocaleId, - __out PLARGE_INTEGER DefaultCasingTableSize, - __out_opt PULONG CurrentNLSVersion + _Out_ PVOID *BaseAddress, + _Out_ PLCID DefaultLocaleId, + _Out_ PLARGE_INTEGER DefaultCasingTableSize, + _Out_opt_ PULONG CurrentNLSVersion ); #endif @@ -2285,11 +2315,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtGetNlsSectionPtr( - __in ULONG SectionType, - __in ULONG SectionData, - __in PVOID ContextData, - __out PVOID *SectionPointer, - __out PULONG SectionSize + _In_ ULONG SectionType, + _In_ ULONG SectionData, + _In_ PVOID ContextData, + _Out_ PVOID *SectionPointer, + _Out_ PULONG SectionSize ); #if (PHNT_VERSION < PHNT_WIN7) @@ -2298,9 +2328,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAcquireCMFViewOwnership( - __out PULONGLONG TimeStamp, - __out PBOOLEAN tokenTaken, - __in BOOLEAN replaceExisting + _Out_ PULONGLONG TimeStamp, + _Out_ PBOOLEAN tokenTaken, + _In_ BOOLEAN replaceExisting ); NTSYSCALLAPI @@ -2316,21 +2346,21 @@ NTSYSCALLAPI NTSTATUS NTAPI NtMapCMFModule( - __in ULONG What, - __in ULONG Index, - __out_opt PULONG CacheIndexOut, - __out_opt PULONG CacheFlagsOut, - __out_opt PULONG ViewSizeOut, - __out_opt PVOID *BaseAddress + _In_ ULONG What, + _In_ ULONG Index, + _Out_opt_ PULONG CacheIndexOut, + _Out_opt_ PULONG CacheFlagsOut, + _Out_opt_ PULONG ViewSizeOut, + _Out_opt_ PVOID *BaseAddress ); NTSYSCALLAPI NTSTATUS NTAPI NtGetMUIRegistryInfo( - __in ULONG Flags, - __inout PULONG DataSize, - __out PVOID Data + _In_ ULONG Flags, + _Inout_ PULONG DataSize, + _Out_ PVOID Data ); #endif @@ -2343,25 +2373,25 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAddAtom( - __in_bcount_opt(Length) PWSTR AtomName, - __in ULONG Length, - __out_opt PRTL_ATOM Atom + _In_reads_bytes_opt_(Length) PWSTR AtomName, + _In_ ULONG Length, + _Out_opt_ PRTL_ATOM Atom ); NTSYSCALLAPI NTSTATUS NTAPI NtFindAtom( - __in_bcount_opt(Length) PWSTR AtomName, - __in ULONG Length, - __out_opt PRTL_ATOM Atom + _In_reads_bytes_opt_(Length) PWSTR AtomName, + _In_ ULONG Length, + _Out_opt_ PRTL_ATOM Atom ); NTSYSCALLAPI NTSTATUS NTAPI NtDeleteAtom( - __in RTL_ATOM Atom + _In_ RTL_ATOM Atom ); typedef enum _ATOM_INFORMATION_CLASS @@ -2388,11 +2418,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationAtom( - __in RTL_ATOM Atom, - __in ATOM_INFORMATION_CLASS AtomInformationClass, - __out_bcount(AtomInformationLength) PVOID AtomInformation, - __in ULONG AtomInformationLength, - __out_opt PULONG ReturnLength + _In_ RTL_ATOM Atom, + _In_ ATOM_INFORMATION_CLASS AtomInformationClass, + _Out_writes_bytes_(AtomInformationLength) PVOID AtomInformation, + _In_ ULONG AtomInformationLength, + _Out_opt_ PULONG ReturnLength ); // Global flags @@ -2480,7 +2510,7 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetDefaultHardErrorPort( - __in HANDLE DefaultHardErrorPort + _In_ HANDLE DefaultHardErrorPort ); typedef enum _SHUTDOWN_ACTION @@ -2494,14 +2524,14 @@ NTSYSCALLAPI NTSTATUS NTAPI NtShutdownSystem( - __in SHUTDOWN_ACTION Action + _In_ SHUTDOWN_ACTION Action ); NTSYSCALLAPI NTSTATUS NTAPI NtDisplayString( - __in PUNICODE_STRING String + _In_ PUNICODE_STRING String ); #endif // (PHNT_MODE != PHNT_MODE_KERNEL) diff --git a/2.x/trunk/phlib/include/ntimport.h b/2.x/trunk/phlib/include/ntimport.h index 3a862fc27..78990a68c 100644 --- a/2.x/trunk/phlib/include/ntimport.h +++ b/2.x/trunk/phlib/include/ntimport.h @@ -13,20 +13,20 @@ #if !(PHNT_VERSION >= PHNT_WS03) typedef NTSTATUS (NTAPI *_NtGetNextProcess)( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Flags, - __out PHANDLE NewProcessHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Flags, + _Out_ PHANDLE NewProcessHandle ); typedef NTSTATUS (NTAPI *_NtGetNextThread)( - __in HANDLE ProcessHandle, - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Flags, - __out PHANDLE NewThreadHandle + _In_ HANDLE ProcessHandle, + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Flags, + _Out_ PHANDLE NewThreadHandle ); EXT _NtGetNextProcess NtGetNextProcess; @@ -36,35 +36,35 @@ EXT _NtGetNextThread NtGetNextThread; #if !(PHNT_VERSION >= PHNT_VISTA) typedef NTSTATUS (NTAPI *_NtQueryInformationEnlistment)( - __in HANDLE EnlistmentHandle, - __in ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, - __out_bcount(EnlistmentInformationLength) PVOID EnlistmentInformation, - __in ULONG EnlistmentInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE EnlistmentHandle, + _In_ ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + _Out_writes_bytes_(EnlistmentInformationLength) PVOID EnlistmentInformation, + _In_ ULONG EnlistmentInformationLength, + _Out_opt_ PULONG ReturnLength ); typedef NTSTATUS (NTAPI *_NtQueryInformationResourceManager)( - __in HANDLE ResourceManagerHandle, - __in RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - __out_bcount(ResourceManagerInformationLength) PVOID ResourceManagerInformation, - __in ULONG ResourceManagerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ResourceManagerHandle, + _In_ RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + _Out_writes_bytes_(ResourceManagerInformationLength) PVOID ResourceManagerInformation, + _In_ ULONG ResourceManagerInformationLength, + _Out_opt_ PULONG ReturnLength ); typedef NTSTATUS (NTAPI *_NtQueryInformationTransaction)( - __in HANDLE TransactionHandle, - __in TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - __out_bcount(TransactionInformationLength) PVOID TransactionInformation, - __in ULONG TransactionInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TransactionHandle, + _In_ TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + _Out_writes_bytes_(TransactionInformationLength) PVOID TransactionInformation, + _In_ ULONG TransactionInformationLength, + _Out_opt_ PULONG ReturnLength ); typedef NTSTATUS (NTAPI *_NtQueryInformationTransactionManager)( - __in HANDLE TransactionManagerHandle, - __in TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - __out_bcount(TransactionManagerInformationLength) PVOID TransactionManagerInformation, - __in ULONG TransactionManagerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TransactionManagerHandle, + _In_ TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + _Out_writes_bytes_(TransactionManagerInformationLength) PVOID TransactionManagerInformation, + _In_ ULONG TransactionManagerInformationLength, + _Out_opt_ PULONG ReturnLength ); EXT _NtQueryInformationEnlistment NtQueryInformationEnlistment; diff --git a/2.x/trunk/phlib/include/ntioapi.h b/2.x/trunk/phlib/include/ntioapi.h index b4d0d1a43..65d6d7d0a 100644 --- a/2.x/trunk/phlib/include/ntioapi.h +++ b/2.x/trunk/phlib/include/ntioapi.h @@ -156,9 +156,9 @@ typedef struct _IO_STATUS_BLOCK } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; typedef VOID (NTAPI *PIO_APC_ROUTINE)( - __in PVOID ApcContext, - __in PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG Reserved + _In_ PVOID ApcContext, + _In_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG Reserved ); // private @@ -232,6 +232,8 @@ typedef enum _FILE_INFORMATION_CLASS FileVolumeNameInformation, FileIdInformation, FileIdExtdDirectoryInformation, + FileReplaceCompletionInformation, // since WINBLUE + FileHardLinkFullIdInformation, FileMaximumInformation } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; @@ -871,78 +873,78 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateFile( - __out PHANDLE FileHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_opt PLARGE_INTEGER AllocationSize, - __in ULONG FileAttributes, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions, - __in_bcount_opt(EaLength) PVOID EaBuffer, - __in ULONG EaLength + _Out_ PHANDLE FileHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_opt_ PLARGE_INTEGER AllocationSize, + _In_ ULONG FileAttributes, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions, + _In_reads_bytes_opt_(EaLength) PVOID EaBuffer, + _In_ ULONG EaLength ); NTSYSCALLAPI NTSTATUS NTAPI NtCreateNamedPipeFile( - __out PHANDLE FileHandle, - __in ULONG DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions, - __in ULONG NamedPipeType, - __in ULONG ReadMode, - __in ULONG CompletionMode, - __in ULONG MaximumInstances, - __in ULONG InboundQuota, - __in ULONG OutboundQuota, - __in_opt PLARGE_INTEGER DefaultTimeout + _Out_ PHANDLE FileHandle, + _In_ ULONG DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions, + _In_ ULONG NamedPipeType, + _In_ ULONG ReadMode, + _In_ ULONG CompletionMode, + _In_ ULONG MaximumInstances, + _In_ ULONG InboundQuota, + _In_ ULONG OutboundQuota, + _In_opt_ PLARGE_INTEGER DefaultTimeout ); NTSYSCALLAPI NTSTATUS NTAPI NtCreateMailslotFile( - __out PHANDLE FileHandle, - __in ULONG DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG CreateOptions, - __in ULONG MailslotQuota, - __in ULONG MaximumMessageSize, - __in PLARGE_INTEGER ReadTimeout + _Out_ PHANDLE FileHandle, + _In_ ULONG DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG CreateOptions, + _In_ ULONG MailslotQuota, + _In_ ULONG MaximumMessageSize, + _In_ PLARGE_INTEGER ReadTimeout ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenFile( - __out PHANDLE FileHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG ShareAccess, - __in ULONG OpenOptions + _Out_ PHANDLE FileHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG ShareAccess, + _In_ ULONG OpenOptions ); NTSYSCALLAPI NTSTATUS NTAPI NtDeleteFile( - __in POBJECT_ATTRIBUTES ObjectAttributes + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtFlushBuffersFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); #define FLUSH_FLAGS_FILE_DATA_ONLY 0x00000001 @@ -952,9 +954,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtFlushBuffersFileEx( - __in HANDLE FileHandle, - __in ULONG Flags, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _In_ ULONG Flags, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); #endif @@ -962,119 +964,119 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID FileInformation, - __in ULONG Length, - __in FILE_INFORMATION_CLASS FileInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID FileInformation, + _In_ ULONG Length, + _In_ FILE_INFORMATION_CLASS FileInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID FileInformation, - __in ULONG Length, - __in FILE_INFORMATION_CLASS FileInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID FileInformation, + _In_ ULONG Length, + _In_ FILE_INFORMATION_CLASS FileInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryDirectoryFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID FileInformation, - __in ULONG Length, - __in FILE_INFORMATION_CLASS FileInformationClass, - __in BOOLEAN ReturnSingleEntry, - __in_opt PUNICODE_STRING FileName, - __in BOOLEAN RestartScan + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID FileInformation, + _In_ ULONG Length, + _In_ FILE_INFORMATION_CLASS FileInformationClass, + _In_ BOOLEAN ReturnSingleEntry, + _In_opt_ PUNICODE_STRING FileName, + _In_ BOOLEAN RestartScan ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryEaFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in BOOLEAN ReturnSingleEntry, - __in_bcount_opt(EaListLength) PVOID EaList, - __in ULONG EaListLength, - __in_opt PULONG EaIndex OPTIONAL, - __in BOOLEAN RestartScan + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_ BOOLEAN ReturnSingleEntry, + _In_reads_bytes_opt_(EaListLength) PVOID EaList, + _In_ ULONG EaListLength, + _In_opt_ PULONG EaIndex OPTIONAL, + _In_ BOOLEAN RestartScan ); NTSYSCALLAPI NTSTATUS NTAPI NtSetEaFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryQuotaInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in BOOLEAN ReturnSingleEntry, - __in_bcount_opt(SidListLength) PVOID SidList, - __in ULONG SidListLength, - __in_opt PSID StartSid, - __in BOOLEAN RestartScan + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_ BOOLEAN ReturnSingleEntry, + _In_reads_bytes_opt_(SidListLength) PVOID SidList, + _In_ ULONG SidListLength, + _In_opt_ PSID StartSid, + _In_ BOOLEAN RestartScan ); NTSYSCALLAPI NTSTATUS NTAPI NtSetQuotaInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryVolumeInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID FsInformation, - __in ULONG Length, - __in FSINFOCLASS FsInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID FsInformation, + _In_ ULONG Length, + _In_ FSINFOCLASS FsInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI NtSetVolumeInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID FsInformation, - __in ULONG Length, - __in FSINFOCLASS FsInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID FsInformation, + _In_ ULONG Length, + _In_ FSINFOCLASS FsInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI NtCancelIoFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -1083,9 +1085,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCancelIoFileEx( - __in HANDLE FileHandle, - __in_opt PIO_STATUS_BLOCK IoRequestToCancel, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _In_opt_ PIO_STATUS_BLOCK IoRequestToCancel, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); #endif @@ -1095,9 +1097,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCancelSynchronousIoFile( - __in HANDLE ThreadHandle, - __in_opt PIO_STATUS_BLOCK IoRequestToCancel, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE ThreadHandle, + _In_opt_ PIO_STATUS_BLOCK IoRequestToCancel, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); #endif @@ -1105,164 +1107,164 @@ NTSYSCALLAPI NTSTATUS NTAPI NtDeviceIoControlFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG IoControlCode, - __in_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG IoControlCode, + _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ); NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG FsControlCode, - __in_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG FsControlCode, + _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ); NTSYSCALLAPI NTSTATUS NTAPI NtReadFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI NtWriteFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI NtReadFileScatter( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PFILE_SEGMENT_ELEMENT SegmentArray, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PFILE_SEGMENT_ELEMENT SegmentArray, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI NtWriteFileGather( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PFILE_SEGMENT_ELEMENT SegmentArray, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PFILE_SEGMENT_ELEMENT SegmentArray, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI NtLockFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PLARGE_INTEGER ByteOffset, - __in PLARGE_INTEGER Length, - __in ULONG Key, - __in BOOLEAN FailImmediately, - __in BOOLEAN ExclusiveLock + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PLARGE_INTEGER ByteOffset, + _In_ PLARGE_INTEGER Length, + _In_ ULONG Key, + _In_ BOOLEAN FailImmediately, + _In_ BOOLEAN ExclusiveLock ); NTSYSCALLAPI NTSTATUS NTAPI NtUnlockFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PLARGE_INTEGER ByteOffset, - __in PLARGE_INTEGER Length, - __in ULONG Key + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PLARGE_INTEGER ByteOffset, + _In_ PLARGE_INTEGER Length, + _In_ ULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryAttributesFile( - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PFILE_BASIC_INFORMATION FileInformation + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PFILE_BASIC_INFORMATION FileInformation ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryFullAttributesFile( - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PFILE_NETWORK_OPEN_INFORMATION FileInformation + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PFILE_NETWORK_OPEN_INFORMATION FileInformation ); NTSYSCALLAPI NTSTATUS NTAPI NtNotifyChangeDirectoryFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in ULONG CompletionFilter, - __in BOOLEAN WatchTree + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_ ULONG CompletionFilter, + _In_ BOOLEAN WatchTree ); NTSYSCALLAPI NTSTATUS NTAPI NtLoadDriver( - __in PUNICODE_STRING DriverServiceName + _In_ PUNICODE_STRING DriverServiceName ); NTSYSCALLAPI NTSTATUS NTAPI NtUnloadDriver( - __in PUNICODE_STRING DriverServiceName + _In_ PUNICODE_STRING DriverServiceName ); // I/O completion port @@ -1285,41 +1287,41 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateIoCompletion( - __out PHANDLE IoCompletionHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt ULONG Count + _Out_ PHANDLE IoCompletionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ ULONG Count ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenIoCompletion( - __out PHANDLE IoCompletionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE IoCompletionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryIoCompletion( - __in HANDLE IoCompletionHandle, - __in IO_COMPLETION_INFORMATION_CLASS IoCompletionInformationClass, - __out_bcount(IoCompletionInformation) PVOID IoCompletionInformation, - __in ULONG IoCompletionInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE IoCompletionHandle, + _In_ IO_COMPLETION_INFORMATION_CLASS IoCompletionInformationClass, + _Out_writes_bytes_(IoCompletionInformation) PVOID IoCompletionInformation, + _In_ ULONG IoCompletionInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetIoCompletion( - __in HANDLE IoCompletionHandle, - __in PVOID KeyContext, - __in_opt PVOID ApcContext, - __in NTSTATUS IoStatus, - __in ULONG_PTR IoStatusInformation + _In_ HANDLE IoCompletionHandle, + _In_ PVOID KeyContext, + _In_opt_ PVOID ApcContext, + _In_ NTSTATUS IoStatus, + _In_ ULONG_PTR IoStatusInformation ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -1328,12 +1330,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetIoCompletionEx( - __in HANDLE IoCompletionHandle, - __in HANDLE IoCompletionReserveHandle, - __in PVOID KeyContext, - __in_opt PVOID ApcContext, - __in NTSTATUS IoStatus, - __in ULONG_PTR IoStatusInformation + _In_ HANDLE IoCompletionHandle, + _In_ HANDLE IoCompletionReserveHandle, + _In_ PVOID KeyContext, + _In_opt_ PVOID ApcContext, + _In_ NTSTATUS IoStatus, + _In_ ULONG_PTR IoStatusInformation ); #endif @@ -1341,11 +1343,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRemoveIoCompletion( - __in HANDLE IoCompletionHandle, - __out PVOID *KeyContext, - __out PVOID *ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE IoCompletionHandle, + _Out_ PVOID *KeyContext, + _Out_ PVOID *ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_opt_ PLARGE_INTEGER Timeout ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -1354,12 +1356,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRemoveIoCompletionEx( - __in HANDLE IoCompletionHandle, - __out_ecount(Count) PFILE_IO_COMPLETION_INFORMATION IoCompletionInformation, - __in ULONG Count, - __out PULONG NumEntriesRemoved, - __in_opt PLARGE_INTEGER Timeout, - __in BOOLEAN Alertable + _In_ HANDLE IoCompletionHandle, + _Out_writes_(Count) PFILE_IO_COMPLETION_INFORMATION IoCompletionInformation, + _In_ ULONG Count, + _Out_ PULONG NumEntriesRemoved, + _In_opt_ PLARGE_INTEGER Timeout, + _In_ BOOLEAN Alertable ); #endif diff --git a/2.x/trunk/phlib/include/ntkeapi.h b/2.x/trunk/phlib/include/ntkeapi.h index 64d1ecd91..1aeff5459 100644 --- a/2.x/trunk/phlib/include/ntkeapi.h +++ b/2.x/trunk/phlib/include/ntkeapi.h @@ -63,6 +63,8 @@ typedef enum _KWAIT_REASON WrFastMutex, WrGuardedMutex, WrRundown, + WrAlertByThreadId, + WrDeferredPreempt, MaximumWaitReason } KWAIT_REASON, *PKWAIT_REASON; @@ -103,26 +105,26 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCallbackReturn( - __in_bcount_opt(OutputLength) PVOID OutputBuffer, - __in ULONG OutputLength, - __in NTSTATUS Status + _In_reads_bytes_opt_(OutputLength) PVOID OutputBuffer, + _In_ ULONG OutputLength, + _In_ NTSTATUS Status ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryDebugFilterState( - __in ULONG ComponentId, - __in ULONG Level + _In_ ULONG ComponentId, + _In_ ULONG Level ); NTSYSCALLAPI NTSTATUS NTAPI NtSetDebugFilterState( - __in ULONG ComponentId, - __in ULONG Level, - __in BOOLEAN State + _In_ ULONG ComponentId, + _In_ ULONG Level, + _In_ BOOLEAN State ); NTSYSCALLAPI diff --git a/2.x/trunk/phlib/include/ntldr.h b/2.x/trunk/phlib/include/ntldr.h index cc1dc6416..2af2fddb5 100644 --- a/2.x/trunk/phlib/include/ntldr.h +++ b/2.x/trunk/phlib/include/ntldr.h @@ -172,39 +172,40 @@ typedef struct _LDR_DATA_TABLE_ENTRY LARGE_INTEGER LoadTime; ULONG BaseNameHashValue; LDR_DLL_LOAD_REASON LoadReason; + ULONG ImplicitPathOptions; } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY; typedef BOOLEAN (NTAPI *PDLL_INIT_ROUTINE)( - __in PVOID DllHandle, - __in ULONG Reason, - __in_opt PCONTEXT Context + _In_ PVOID DllHandle, + _In_ ULONG Reason, + _In_opt_ PCONTEXT Context ); NTSYSAPI NTSTATUS NTAPI LdrLoadDll( - __in_opt PWSTR DllPath, - __in_opt PULONG DllCharacteristics, - __in PUNICODE_STRING DllName, - __out PVOID *DllHandle + _In_opt_ PWSTR DllPath, + _In_opt_ PULONG DllCharacteristics, + _In_ PUNICODE_STRING DllName, + _Out_ PVOID *DllHandle ); NTSYSAPI NTSTATUS NTAPI LdrUnloadDll( - __in PVOID DllHandle + _In_ PVOID DllHandle ); NTSYSAPI NTSTATUS NTAPI LdrGetDllHandle( - __in_opt PWSTR DllPath, - __in_opt PULONG DllCharacteristics, - __in PUNICODE_STRING DllName, - __out PVOID *DllHandle + _In_opt_ PWSTR DllPath, + _In_opt_ PULONG DllCharacteristics, + _In_ PUNICODE_STRING DllName, + _Out_ PVOID *DllHandle ); #define LDR_GET_DLL_HANDLE_EX_UNCHANGED_REFCOUNT 0x00000001 @@ -214,11 +215,11 @@ NTSYSAPI NTSTATUS NTAPI LdrGetDllHandleEx( - __in ULONG Flags, - __in_opt PCWSTR DllPath, - __in_opt PULONG DllCharacteristics, - __in PUNICODE_STRING DllName, - __out_opt PVOID *DllHandle + _In_ ULONG Flags, + _In_opt_ PCWSTR DllPath, + _In_opt_ PULONG DllCharacteristics, + _In_ PUNICODE_STRING DllName, + _Out_opt_ PVOID *DllHandle ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -227,8 +228,8 @@ NTSYSAPI NTSTATUS NTAPI LdrGetDllHandleByMapping( - __in PVOID Base, - __out PVOID *DllHandle + _In_ PVOID Base, + _Out_ PVOID *DllHandle ); #endif @@ -238,9 +239,9 @@ NTSYSAPI NTSTATUS NTAPI LdrGetDllHandleByName( - __in_opt PUNICODE_STRING BaseDllName, - __in_opt PUNICODE_STRING FullDllName, - __out PVOID *DllHandle + _In_opt_ PUNICODE_STRING BaseDllName, + _In_opt_ PUNICODE_STRING FullDllName, + _Out_ PVOID *DllHandle ); #endif @@ -250,18 +251,18 @@ NTSYSAPI NTSTATUS NTAPI LdrAddRefDll( - __in ULONG Flags, - __in PVOID DllHandle + _In_ ULONG Flags, + _In_ PVOID DllHandle ); NTSYSAPI NTSTATUS NTAPI LdrGetProcedureAddress( - __in PVOID DllHandle, - __in_opt PANSI_STRING ProcedureName, - __in_opt ULONG ProcedureNumber, - __out PVOID *ProcedureAddress + _In_ PVOID DllHandle, + _In_opt_ PANSI_STRING ProcedureName, + _In_opt_ ULONG ProcedureNumber, + _Out_ PVOID *ProcedureAddress ); // rev @@ -273,11 +274,11 @@ NTSYSAPI NTSTATUS NTAPI LdrGetProcedureAddressEx( - __in PVOID DllHandle, - __in_opt PANSI_STRING ProcedureName, - __in_opt ULONG ProcedureNumber, - __out PVOID *ProcedureAddress, - __in ULONG Flags + _In_ PVOID DllHandle, + _In_opt_ PANSI_STRING ProcedureName, + _In_opt_ ULONG ProcedureNumber, + _Out_ PVOID *ProcedureAddress, + _In_ ULONG Flags ); #endif @@ -292,9 +293,9 @@ NTSYSAPI NTSTATUS NTAPI LdrLockLoaderLock( - __in ULONG Flags, - __out_opt ULONG *Disposition, - __out PVOID *Cookie + _In_ ULONG Flags, + _Out_opt_ ULONG *Disposition, + _Out_ PVOID *Cookie ); #define LDR_UNLOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS 0x00000001 @@ -303,65 +304,65 @@ NTSYSAPI NTSTATUS NTAPI LdrUnlockLoaderLock( - __in ULONG Flags, - __inout PVOID Cookie + _In_ ULONG Flags, + _Inout_ PVOID Cookie ); NTSYSAPI NTSTATUS NTAPI LdrRelocateImage( - __in PVOID NewBase, - __in PSTR LoaderName, - __in NTSTATUS Success, - __in NTSTATUS Conflict, - __in NTSTATUS Invalid + _In_ PVOID NewBase, + _In_ PSTR LoaderName, + _In_ NTSTATUS Success, + _In_ NTSTATUS Conflict, + _In_ NTSTATUS Invalid ); NTSYSAPI NTSTATUS NTAPI LdrRelocateImageWithBias( - __in PVOID NewBase, - __in LONGLONG Bias, - __in PSTR LoaderName, - __in NTSTATUS Success, - __in NTSTATUS Conflict, - __in NTSTATUS Invalid + _In_ PVOID NewBase, + _In_ LONGLONG Bias, + _In_ PSTR LoaderName, + _In_ NTSTATUS Success, + _In_ NTSTATUS Conflict, + _In_ NTSTATUS Invalid ); NTSYSAPI PIMAGE_BASE_RELOCATION NTAPI LdrProcessRelocationBlock( - __in ULONG_PTR VA, - __in ULONG SizeOfBlock, - __in PUSHORT NextOffset, - __in LONG_PTR Diff + _In_ ULONG_PTR VA, + _In_ ULONG SizeOfBlock, + _In_ PUSHORT NextOffset, + _In_ LONG_PTR Diff ); NTSYSAPI BOOLEAN NTAPI LdrVerifyMappedImageMatchesChecksum( - __in PVOID BaseAddress, - __in SIZE_T NumberOfBytes, - __in ULONG FileLength + _In_ PVOID BaseAddress, + _In_ SIZE_T NumberOfBytes, + _In_ ULONG FileLength ); typedef VOID (NTAPI *PLDR_IMPORT_MODULE_CALLBACK)( - __in PVOID Parameter, - __in PSTR ModuleName + _In_ PVOID Parameter, + _In_ PSTR ModuleName ); NTSYSAPI NTSTATUS NTAPI LdrVerifyImageMatchesChecksum( - __in HANDLE ImageFileHandle, - __in_opt PLDR_IMPORT_MODULE_CALLBACK ImportCallbackRoutine, - __in PVOID ImportCallbackParameter, - __out_opt PUSHORT ImageCharacteristics + _In_ HANDLE ImageFileHandle, + _In_opt_ PLDR_IMPORT_MODULE_CALLBACK ImportCallbackRoutine, + _In_ PVOID ImportCallbackParameter, + _Out_opt_ PUSHORT ImageCharacteristics ); // private @@ -397,8 +398,8 @@ NTSYSAPI NTSTATUS NTAPI LdrVerifyImageMatchesChecksumEx( - __in HANDLE ImageFileHandle, - __inout PLDR_VERIFY_IMAGE_INFO VerifyInfo + _In_ HANDLE ImageFileHandle, + _Inout_ PLDR_VERIFY_IMAGE_INFO VerifyInfo ); #endif @@ -408,9 +409,9 @@ NTSYSAPI NTSTATUS NTAPI LdrQueryModuleServiceTags( - __in PVOID DllHandle, - __out_ecount(*BufferSize) PULONG ServiceTagBuffer, - __inout PULONG BufferSize + _In_ PVOID DllHandle, + _Out_writes_(*BufferSize) PULONG ServiceTagBuffer, + _Inout_ PULONG BufferSize ); #endif @@ -444,9 +445,9 @@ typedef union _LDR_DLL_NOTIFICATION_DATA } LDR_DLL_NOTIFICATION_DATA, *PLDR_DLL_NOTIFICATION_DATA; typedef VOID (NTAPI *PLDR_DLL_NOTIFICATION_FUNCTION)( - __in ULONG NotificationReason, - __in PLDR_DLL_NOTIFICATION_DATA NotificationData, - __in_opt PVOID Context + _In_ ULONG NotificationReason, + _In_ PLDR_DLL_NOTIFICATION_DATA NotificationData, + _In_opt_ PVOID Context ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -455,17 +456,17 @@ NTSYSAPI NTSTATUS NTAPI LdrRegisterDllNotification( - __in ULONG Flags, - __in PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction, - __in PVOID Context, - __out PVOID *Cookie + _In_ ULONG Flags, + _In_ PLDR_DLL_NOTIFICATION_FUNCTION NotificationFunction, + _In_ PVOID Context, + _Out_ PVOID *Cookie ); NTSYSAPI NTSTATUS NTAPI LdrUnregisterDllNotification( - __in PVOID Cookie + _In_ PVOID Cookie ); #endif @@ -481,10 +482,10 @@ NTSYSAPI NTSTATUS NTAPI LdrAddLoadAsDataTable( - __in PVOID Module, - __in PWSTR FilePath, - __in SIZE_T Size, - __in HANDLE Handle + _In_ PVOID Module, + _In_ PWSTR FilePath, + _In_ SIZE_T Size, + _In_ HANDLE Handle ); // private @@ -492,10 +493,10 @@ NTSYSAPI NTSTATUS NTAPI LdrRemoveLoadAsDataTable( - __in PVOID InitModule, - __out_opt PVOID *BaseModule, - __out_opt PSIZE_T Size, - __in ULONG Flags + _In_ PVOID InitModule, + _Out_opt_ PVOID *BaseModule, + _Out_opt_ PSIZE_T Size, + _In_ ULONG Flags ); // private @@ -503,8 +504,8 @@ NTSYSAPI NTSTATUS NTAPI LdrGetFileNameFromLoadAsDataTable( - __in PVOID Module, - __out PVOID *pFileNamePrt + _In_ PVOID Module, + _Out_ PVOID *pFileNamePrt ); #endif diff --git a/2.x/trunk/phlib/include/ntlpcapi.h b/2.x/trunk/phlib/include/ntlpcapi.h index fbe1afcc2..8794bfa86 100644 --- a/2.x/trunk/phlib/include/ntlpcapi.h +++ b/2.x/trunk/phlib/include/ntlpcapi.h @@ -107,22 +107,22 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreatePort( - __out PHANDLE PortHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG MaxConnectionInfoLength, - __in ULONG MaxMessageLength, - __in_opt ULONG MaxPoolUsage + _Out_ PHANDLE PortHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG MaxConnectionInfoLength, + _In_ ULONG MaxMessageLength, + _In_opt_ ULONG MaxPoolUsage ); NTSYSCALLAPI NTSTATUS NTAPI NtCreateWaitablePort( - __out PHANDLE PortHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG MaxConnectionInfoLength, - __in ULONG MaxMessageLength, - __in_opt ULONG MaxPoolUsage + _Out_ PHANDLE PortHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG MaxConnectionInfoLength, + _In_ ULONG MaxMessageLength, + _In_opt_ ULONG MaxPoolUsage ); // Port connection (client) @@ -131,29 +131,29 @@ NTSYSCALLAPI NTSTATUS NTAPI NtConnectPort( - __out PHANDLE PortHandle, - __in PUNICODE_STRING PortName, - __in PSECURITY_QUALITY_OF_SERVICE SecurityQos, - __inout_opt PPORT_VIEW ClientView, - __inout_opt PREMOTE_PORT_VIEW ServerView, - __out_opt PULONG MaxMessageLength, - __inout_opt PVOID ConnectionInformation, - __inout_opt PULONG ConnectionInformationLength + _Out_ PHANDLE PortHandle, + _In_ PUNICODE_STRING PortName, + _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos, + _Inout_opt_ PPORT_VIEW ClientView, + _Inout_opt_ PREMOTE_PORT_VIEW ServerView, + _Out_opt_ PULONG MaxMessageLength, + _Inout_opt_ PVOID ConnectionInformation, + _Inout_opt_ PULONG ConnectionInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSecureConnectPort( - __out PHANDLE PortHandle, - __in PUNICODE_STRING PortName, - __in PSECURITY_QUALITY_OF_SERVICE SecurityQos, - __inout_opt PPORT_VIEW ClientView, - __in_opt PSID RequiredServerSid, - __inout_opt PREMOTE_PORT_VIEW ServerView, - __out_opt PULONG MaxMessageLength, - __inout_opt PVOID ConnectionInformation, - __inout_opt PULONG ConnectionInformationLength + _Out_ PHANDLE PortHandle, + _In_ PUNICODE_STRING PortName, + _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos, + _Inout_opt_ PPORT_VIEW ClientView, + _In_opt_ PSID RequiredServerSid, + _Inout_opt_ PREMOTE_PORT_VIEW ServerView, + _Out_opt_ PULONG MaxMessageLength, + _Inout_opt_ PVOID ConnectionInformation, + _Inout_opt_ PULONG ConnectionInformationLength ); // Port connection (server) @@ -162,27 +162,27 @@ NTSYSCALLAPI NTSTATUS NTAPI NtListenPort( - __in HANDLE PortHandle, - __out PPORT_MESSAGE ConnectionRequest + _In_ HANDLE PortHandle, + _Out_ PPORT_MESSAGE ConnectionRequest ); NTSYSCALLAPI NTSTATUS NTAPI NtAcceptConnectPort( - __out PHANDLE PortHandle, - __in_opt PVOID PortContext, - __in PPORT_MESSAGE ConnectionRequest, - __in BOOLEAN AcceptConnection, - __inout_opt PPORT_VIEW ServerView, - __out_opt PREMOTE_PORT_VIEW ClientView + _Out_ PHANDLE PortHandle, + _In_opt_ PVOID PortContext, + _In_ PPORT_MESSAGE ConnectionRequest, + _In_ BOOLEAN AcceptConnection, + _Inout_opt_ PPORT_VIEW ServerView, + _Out_opt_ PREMOTE_PORT_VIEW ClientView ); NTSYSCALLAPI NTSTATUS NTAPI NtCompleteConnectPort( - __in HANDLE PortHandle + _In_ HANDLE PortHandle ); // General @@ -191,86 +191,86 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRequestPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE RequestMessage + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE RequestMessage ); NTSYSCALLAPI NTSTATUS NTAPI NtRequestWaitReplyPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE RequestMessage, - __out PPORT_MESSAGE ReplyMessage + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE RequestMessage, + _Out_ PPORT_MESSAGE ReplyMessage ); NTSYSCALLAPI NTSTATUS NTAPI NtReplyPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE ReplyMessage + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE ReplyMessage ); NTSYSCALLAPI NTSTATUS NTAPI NtReplyWaitReplyPort( - __in HANDLE PortHandle, - __inout PPORT_MESSAGE ReplyMessage + _In_ HANDLE PortHandle, + _Inout_ PPORT_MESSAGE ReplyMessage ); NTSYSCALLAPI NTSTATUS NTAPI NtReplyWaitReceivePort( - __in HANDLE PortHandle, - __out_opt PVOID *PortContext, - __in_opt PPORT_MESSAGE ReplyMessage, - __out PPORT_MESSAGE ReceiveMessage + _In_ HANDLE PortHandle, + _Out_opt_ PVOID *PortContext, + _In_opt_ PPORT_MESSAGE ReplyMessage, + _Out_ PPORT_MESSAGE ReceiveMessage ); NTSYSCALLAPI NTSTATUS NTAPI NtReplyWaitReceivePortEx( - __in HANDLE PortHandle, - __out_opt PVOID *PortContext, - __in_opt PPORT_MESSAGE ReplyMessage, - __out PPORT_MESSAGE ReceiveMessage, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE PortHandle, + _Out_opt_ PVOID *PortContext, + _In_opt_ PPORT_MESSAGE ReplyMessage, + _Out_ PPORT_MESSAGE ReceiveMessage, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI NtImpersonateClientOfPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE Message + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE Message ); NTSYSCALLAPI NTSTATUS NTAPI NtReadRequestData( - __in HANDLE PortHandle, - __in PPORT_MESSAGE Message, - __in ULONG DataEntryIndex, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE Message, + _In_ ULONG DataEntryIndex, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ); NTSYSCALLAPI NTSTATUS NTAPI NtWriteRequestData( - __in HANDLE PortHandle, - __in PPORT_MESSAGE Message, - __in ULONG DataEntryIndex, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE Message, + _In_ ULONG DataEntryIndex, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ); typedef enum _PORT_INFORMATION_CLASS @@ -283,11 +283,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationPort( - __in HANDLE PortHandle, - __in PORT_INFORMATION_CLASS PortInformationClass, - __out_bcount(Length) PVOID PortInformation, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE PortHandle, + _In_ PORT_INFORMATION_CLASS PortInformationClass, + _Out_writes_bytes_(Length) PVOID PortInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); // Asynchronous Local Inter-process Communication @@ -440,6 +440,7 @@ typedef enum _ALPC_PORT_INFORMATION_CLASS AlpcAdjustCompletionListConcurrencyCountInformation, // s: in ULONG AlpcRegisterCallbackInformation, // kernel-mode only AlpcCompletionListRundownInformation, // s: VOID + AlpcWaitForPortReferences, MaxAlpcPortInfoClass } ALPC_PORT_INFORMATION_CLASS; @@ -510,135 +511,135 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAlpcCreatePort( - __out PHANDLE PortHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PALPC_PORT_ATTRIBUTES PortAttributes + _Out_ PHANDLE PortHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PALPC_PORT_ATTRIBUTES PortAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcDisconnectPort( - __in HANDLE PortHandle, - __in ULONG Flags + _In_ HANDLE PortHandle, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcQueryInformation( - __in HANDLE PortHandle, - __in ALPC_PORT_INFORMATION_CLASS PortInformationClass, - __out_bcount(Length) PVOID PortInformation, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE PortHandle, + _In_ ALPC_PORT_INFORMATION_CLASS PortInformationClass, + _Out_writes_bytes_(Length) PVOID PortInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcSetInformation( - __in HANDLE PortHandle, - __in ALPC_PORT_INFORMATION_CLASS PortInformationClass, - __in_bcount(Length) PVOID PortInformation, - __in ULONG Length + _In_ HANDLE PortHandle, + _In_ ALPC_PORT_INFORMATION_CLASS PortInformationClass, + _In_reads_bytes_(Length) PVOID PortInformation, + _In_ ULONG Length ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcCreatePortSection( - __in HANDLE PortHandle, - __in ULONG Flags, - __in_opt HANDLE SectionHandle, - __in SIZE_T SectionSize, - __out PALPC_HANDLE AlpcSectionHandle, - __out PSIZE_T ActualSectionSize + _In_ HANDLE PortHandle, + _In_ ULONG Flags, + _In_opt_ HANDLE SectionHandle, + _In_ SIZE_T SectionSize, + _Out_ PALPC_HANDLE AlpcSectionHandle, + _Out_ PSIZE_T ActualSectionSize ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcDeletePortSection( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE SectionHandle + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE SectionHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcCreateResourceReserve( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in SIZE_T MessageSize, - __out PALPC_HANDLE ResourceId + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ SIZE_T MessageSize, + _Out_ PALPC_HANDLE ResourceId ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcDeleteResourceReserve( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE ResourceId + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ResourceId ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcCreateSectionView( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __inout PALPC_DATA_VIEW_ATTR ViewAttributes + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _Inout_ PALPC_DATA_VIEW_ATTR ViewAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcDeleteSectionView( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in PVOID ViewBase + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ PVOID ViewBase ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcCreateSecurityContext( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __inout PALPC_SECURITY_ATTR SecurityAttribute + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _Inout_ PALPC_SECURITY_ATTR SecurityAttribute ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcDeleteSecurityContext( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE ContextHandle + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ContextHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcRevokeSecurityContext( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE ContextHandle + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ContextHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcQueryInformationMessage( - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __in ALPC_MESSAGE_INFORMATION_CLASS MessageInformationClass, - __out_bcount(Length) PVOID MessageInformation, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _In_ ALPC_MESSAGE_INFORMATION_CLASS MessageInformationClass, + _Out_writes_bytes_(Length) PVOID MessageInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); #define ALPC_MSGFLG_REPLY_MESSAGE 0x1 @@ -653,46 +654,46 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAlpcConnectPort( - __out PHANDLE PortHandle, - __in PUNICODE_STRING PortName, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PALPC_PORT_ATTRIBUTES PortAttributes, - __in ULONG Flags, - __in_opt PSID RequiredServerSid, - __inout PPORT_MESSAGE ConnectionMessage, - __inout_opt PULONG BufferLength, - __inout_opt PALPC_MESSAGE_ATTRIBUTES OutMessageAttributes, - __inout_opt PALPC_MESSAGE_ATTRIBUTES InMessageAttributes, - __in_opt PLARGE_INTEGER Timeout + _Out_ PHANDLE PortHandle, + _In_ PUNICODE_STRING PortName, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PALPC_PORT_ATTRIBUTES PortAttributes, + _In_ ULONG Flags, + _In_opt_ PSID RequiredServerSid, + _Inout_ PPORT_MESSAGE ConnectionMessage, + _Inout_opt_ PULONG BufferLength, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES OutMessageAttributes, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES InMessageAttributes, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcAcceptConnectPort( - __out PHANDLE PortHandle, - __in HANDLE ConnectionPortHandle, - __in ULONG Flags, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in PALPC_PORT_ATTRIBUTES PortAttributes, - __in_opt PVOID PortContext, - __in PPORT_MESSAGE ConnectionRequest, - __inout_opt PALPC_MESSAGE_ATTRIBUTES ConnectionMessageAttributes, - __in BOOLEAN AcceptConnection + _Out_ PHANDLE PortHandle, + _In_ HANDLE ConnectionPortHandle, + _In_ ULONG Flags, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PALPC_PORT_ATTRIBUTES PortAttributes, + _In_opt_ PVOID PortContext, + _In_ PPORT_MESSAGE ConnectionRequest, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES ConnectionMessageAttributes, + _In_ BOOLEAN AcceptConnection ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcSendWaitReceivePort( - __in HANDLE PortHandle, - __in ULONG Flags, - __in_opt PPORT_MESSAGE SendMessage, - __in_opt PALPC_MESSAGE_ATTRIBUTES SendMessageAttributes, - __inout_opt PPORT_MESSAGE ReceiveMessage, - __inout_opt PULONG BufferLength, - __inout_opt PALPC_MESSAGE_ATTRIBUTES ReceiveMessageAttributes, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE PortHandle, + _In_ ULONG Flags, + _In_opt_ PPORT_MESSAGE SendMessage, + _In_opt_ PALPC_MESSAGE_ATTRIBUTES SendMessageAttributes, + _Inout_opt_ PPORT_MESSAGE ReceiveMessage, + _Inout_opt_ PULONG BufferLength, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES ReceiveMessageAttributes, + _In_opt_ PLARGE_INTEGER Timeout ); #define ALPC_CANCELFLG_TRY_CANCEL 0x1 // dbg @@ -703,42 +704,42 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAlpcCancelMessage( - __in HANDLE PortHandle, - __in ULONG Flags, - __in PALPC_CONTEXT_ATTR MessageContext + _In_ HANDLE PortHandle, + _In_ ULONG Flags, + _In_ PALPC_CONTEXT_ATTR MessageContext ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcImpersonateClientOfPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __reserved PVOID Reserved + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _Reserved_ PVOID Reserved ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcOpenSenderProcess( - __out PHANDLE ProcessHandle, - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __reserved ULONG Flags, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE ProcessHandle, + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _Reserved_ ULONG Flags, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtAlpcOpenSenderThread( - __out PHANDLE ThreadHandle, - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __reserved ULONG Flags, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE ThreadHandle, + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _Reserved_ ULONG Flags, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); // Support functions @@ -754,43 +755,43 @@ NTSYSAPI ULONG NTAPI AlpcGetHeaderSize( - __in ULONG Flags + _In_ ULONG Flags ); NTSYSAPI NTSTATUS NTAPI AlpcInitializeMessageAttribute( - __in ULONG AttributeFlags, - __out_opt PALPC_MESSAGE_ATTRIBUTES Buffer, - __in ULONG BufferSize, - __out PULONG RequiredBufferSize + _In_ ULONG AttributeFlags, + _Out_opt_ PALPC_MESSAGE_ATTRIBUTES Buffer, + _In_ ULONG BufferSize, + _Out_ PULONG RequiredBufferSize ); NTSYSAPI PVOID NTAPI AlpcGetMessageAttribute( - __in PALPC_MESSAGE_ATTRIBUTES Buffer, - __in ULONG AttributeFlag + _In_ PALPC_MESSAGE_ATTRIBUTES Buffer, + _In_ ULONG AttributeFlag ); NTSYSAPI NTSTATUS NTAPI AlpcRegisterCompletionList( - __in HANDLE PortHandle, - __out PALPC_COMPLETION_LIST_HEADER Buffer, - __in ULONG Size, - __in ULONG ConcurrencyCount, - __in ULONG AttributeFlags + _In_ HANDLE PortHandle, + _Out_ PALPC_COMPLETION_LIST_HEADER Buffer, + _In_ ULONG Size, + _In_ ULONG ConcurrencyCount, + _In_ ULONG AttributeFlags ); NTSYSAPI NTSTATUS NTAPI AlpcUnregisterCompletionList( - __in HANDLE PortHandle + _In_ HANDLE PortHandle ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -799,7 +800,7 @@ NTSYSAPI NTSTATUS NTAPI AlpcRundownCompletionList( - __in HANDLE PortHandle + _In_ HANDLE PortHandle ); #endif @@ -807,62 +808,62 @@ NTSYSAPI NTSTATUS NTAPI AlpcAdjustCompletionListConcurrencyCount( - __in HANDLE PortHandle, - __in ULONG ConcurrencyCount + _In_ HANDLE PortHandle, + _In_ ULONG ConcurrencyCount ); NTSYSAPI BOOLEAN NTAPI AlpcRegisterCompletionListWorkerThread( - __inout PVOID CompletionList + _Inout_ PVOID CompletionList ); NTSYSAPI BOOLEAN NTAPI AlpcUnregisterCompletionListWorkerThread( - __inout PVOID CompletionList + _Inout_ PVOID CompletionList ); NTSYSAPI VOID NTAPI AlpcGetCompletionListLastMessageInformation( - __in PVOID CompletionList, - __out PULONG LastMessageId, - __out PULONG LastCallbackId + _In_ PVOID CompletionList, + _Out_ PULONG LastMessageId, + _Out_ PULONG LastCallbackId ); NTSYSAPI ULONG NTAPI AlpcGetOutstandingCompletionListMessageCount( - __in PVOID CompletionList + _In_ PVOID CompletionList ); NTSYSAPI PPORT_MESSAGE NTAPI AlpcGetMessageFromCompletionList( - __in PVOID CompletionList, - __out_opt PALPC_MESSAGE_ATTRIBUTES *MessageAttributes + _In_ PVOID CompletionList, + _Out_opt_ PALPC_MESSAGE_ATTRIBUTES *MessageAttributes ); NTSYSAPI VOID NTAPI AlpcFreeCompletionListMessage( - __inout PVOID CompletionList, - __in PPORT_MESSAGE Message + _Inout_ PVOID CompletionList, + _In_ PPORT_MESSAGE Message ); NTSYSAPI PALPC_MESSAGE_ATTRIBUTES NTAPI AlpcGetCompletionListMessageAttributes( - __in PVOID CompletionList, - __in PPORT_MESSAGE Message + _In_ PVOID CompletionList, + _In_ PPORT_MESSAGE Message ); #endif diff --git a/2.x/trunk/phlib/include/ntlsa.h b/2.x/trunk/phlib/include/ntlsa.h index ebe6c85b3..e50249338 100644 --- a/2.x/trunk/phlib/include/ntlsa.h +++ b/2.x/trunk/phlib/include/ntlsa.h @@ -10,19 +10,19 @@ // Basic NTSTATUS NTAPI LsaDelete( - __in LSA_HANDLE ObjectHandle + _In_ LSA_HANDLE ObjectHandle ); NTSTATUS NTAPI LsaQuerySecurityObject( - __in LSA_HANDLE ObjectHandle, - __in SECURITY_INFORMATION SecurityInformation, - __out PSECURITY_DESCRIPTOR *SecurityDescriptor + _In_ LSA_HANDLE ObjectHandle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor ); NTSTATUS NTAPI LsaSetSecurityObject( - __in LSA_HANDLE ObjectHandle, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ LSA_HANDLE ObjectHandle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); // System access @@ -76,22 +76,22 @@ typedef struct _POLICY_PRIVILEGE_DEFINITION } POLICY_PRIVILEGE_DEFINITION, *PPOLICY_PRIVILEGE_DEFINITION; NTSTATUS NTAPI LsaOpenPolicySce( - __in_opt PLSA_UNICODE_STRING SystemName, - __in PLSA_OBJECT_ATTRIBUTES ObjectAttributes, - __in ACCESS_MASK DesiredAccess, - __out PLSA_HANDLE PolicyHandle + _In_opt_ PLSA_UNICODE_STRING SystemName, + _In_ PLSA_OBJECT_ATTRIBUTES ObjectAttributes, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PLSA_HANDLE PolicyHandle ); NTSTATUS NTAPI LsaClearAuditLog( - __in LSA_HANDLE PolicyHandle + _In_ LSA_HANDLE PolicyHandle ); NTSTATUS NTAPI LsaEnumeratePrivileges( - __in LSA_HANDLE PolicyHandle, - __inout PLSA_ENUMERATION_HANDLE EnumerationContext, - __out PVOID *Buffer, // PPOLICY_PRIVILEGE_DEFINITION *Buffer - __in ULONG PreferedMaximumLength, - __out PULONG CountReturned + _In_ LSA_HANDLE PolicyHandle, + _Inout_ PLSA_ENUMERATION_HANDLE EnumerationContext, + _Out_ PVOID *Buffer, // PPOLICY_PRIVILEGE_DEFINITION *Buffer + _In_ ULONG PreferedMaximumLength, + _Out_ PULONG CountReturned ); #define LSA_LOOKUP_ISOLATED_AS_LOCAL 0x80000000 @@ -115,61 +115,61 @@ NTSTATUS NTAPI LsaEnumeratePrivileges( #define ACCOUNT_EXECUTE (STANDARD_RIGHTS_EXECUTE) NTSTATUS NTAPI LsaCreateAccount( - __in LSA_HANDLE PolicyHandle, - __in PSID AccountSid, - __in ACCESS_MASK DesiredAccess, - __out PLSA_HANDLE AccountHandle + _In_ LSA_HANDLE PolicyHandle, + _In_ PSID AccountSid, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PLSA_HANDLE AccountHandle ); NTSTATUS NTAPI LsaOpenAccount( - __in LSA_HANDLE PolicyHandle, - __in PSID AccountSid, - __in ACCESS_MASK DesiredAccess, - __out PLSA_HANDLE AccountHandle + _In_ LSA_HANDLE PolicyHandle, + _In_ PSID AccountSid, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PLSA_HANDLE AccountHandle ); NTSTATUS NTAPI LsaEnumerateAccounts( - __in LSA_HANDLE PolicyHandle, - __inout PLSA_ENUMERATION_HANDLE EnumerationContext, - __out PVOID *Buffer, // PSID **Buffer - __in ULONG PreferedMaximumLength, - __out PULONG CountReturned + _In_ LSA_HANDLE PolicyHandle, + _Inout_ PLSA_ENUMERATION_HANDLE EnumerationContext, + _Out_ PVOID *Buffer, // PSID **Buffer + _In_ ULONG PreferedMaximumLength, + _Out_ PULONG CountReturned ); NTSTATUS NTAPI LsaAddPrivilegesToAccount( - __in LSA_HANDLE AccountHandle, - __in PPRIVILEGE_SET Privileges + _In_ LSA_HANDLE AccountHandle, + _In_ PPRIVILEGE_SET Privileges ); NTSTATUS NTAPI LsaRemovePrivilegesFromAccount( - __in LSA_HANDLE AccountHandle, - __in BOOLEAN AllPrivileges, - __in_opt PPRIVILEGE_SET Privileges + _In_ LSA_HANDLE AccountHandle, + _In_ BOOLEAN AllPrivileges, + _In_opt_ PPRIVILEGE_SET Privileges ); NTSTATUS NTAPI LsaEnumeratePrivilegesOfAccount( - __in LSA_HANDLE AccountHandle, - __out PPRIVILEGE_SET *Privileges + _In_ LSA_HANDLE AccountHandle, + _Out_ PPRIVILEGE_SET *Privileges ); NTSTATUS NTAPI LsaGetQuotasForAccount( - __in LSA_HANDLE AccountHandle, - __out PQUOTA_LIMITS QuotaLimits + _In_ LSA_HANDLE AccountHandle, + _Out_ PQUOTA_LIMITS QuotaLimits ); NTSTATUS NTAPI LsaSetQuotasForAccount( - __in LSA_HANDLE AccountHandle, - __in PQUOTA_LIMITS QuotaLimits + _In_ LSA_HANDLE AccountHandle, + _In_ PQUOTA_LIMITS QuotaLimits ); NTSTATUS NTAPI LsaGetSystemAccessAccount( - __in LSA_HANDLE AccountHandle, - __out PULONG SystemAccess + _In_ LSA_HANDLE AccountHandle, + _Out_ PULONG SystemAccess ); NTSTATUS NTAPI LsaSetSystemAccessAccount( - __in LSA_HANDLE AccountHandle, - __in ULONG SystemAccess + _In_ LSA_HANDLE AccountHandle, + _In_ ULONG SystemAccess ); // Trusted Domain @@ -200,29 +200,29 @@ NTSTATUS NTAPI LsaSetSystemAccessAccount( TRUSTED_QUERY_POSIX) NTSTATUS NTAPI LsaCreateTrustedDomain( - __in LSA_HANDLE PolicyHandle, - __in PLSA_TRUST_INFORMATION TrustedDomainInformation, - __in ACCESS_MASK DesiredAccess, - __out PLSA_HANDLE TrustedDomainHandle + _In_ LSA_HANDLE PolicyHandle, + _In_ PLSA_TRUST_INFORMATION TrustedDomainInformation, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PLSA_HANDLE TrustedDomainHandle ); NTSTATUS NTAPI LsaOpenTrustedDomain( - __in LSA_HANDLE PolicyHandle, - __in PSID TrustedDomainSid, - __in ACCESS_MASK DesiredAccess, - __out PLSA_HANDLE TrustedDomainHandle + _In_ LSA_HANDLE PolicyHandle, + _In_ PSID TrustedDomainSid, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PLSA_HANDLE TrustedDomainHandle ); NTSTATUS NTAPI LsaQueryInfoTrustedDomain( - __in LSA_HANDLE TrustedDomainHandle, - __in TRUSTED_INFORMATION_CLASS InformationClass, - __out PVOID *Buffer + _In_ LSA_HANDLE TrustedDomainHandle, + _In_ TRUSTED_INFORMATION_CLASS InformationClass, + _Out_ PVOID *Buffer ); NTSTATUS NTAPI LsaSetInformationTrustedDomain( - __in LSA_HANDLE TrustedDomainHandle, - __in TRUSTED_INFORMATION_CLASS InformationClass, - __in PVOID Buffer + _In_ LSA_HANDLE TrustedDomainHandle, + _In_ TRUSTED_INFORMATION_CLASS InformationClass, + _In_ PVOID Buffer ); // Secret @@ -252,73 +252,73 @@ NTSTATUS NTAPI LsaSetInformationTrustedDomain( #define LSA_SECRET_MAXIMUM_LENGTH 0x00000200L NTSTATUS NTAPI LsaCreateSecret( - __in LSA_HANDLE PolicyHandle, - __in PLSA_UNICODE_STRING SecretName, - __in ACCESS_MASK DesiredAccess, - __out PLSA_HANDLE SecretHandle + _In_ LSA_HANDLE PolicyHandle, + _In_ PLSA_UNICODE_STRING SecretName, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PLSA_HANDLE SecretHandle ); NTSTATUS NTAPI LsaOpenSecret( - __in LSA_HANDLE PolicyHandle, - __in PLSA_UNICODE_STRING SecretName, - __in ACCESS_MASK DesiredAccess, - __out PLSA_HANDLE SecretHandle + _In_ LSA_HANDLE PolicyHandle, + _In_ PLSA_UNICODE_STRING SecretName, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PLSA_HANDLE SecretHandle ); NTSTATUS NTAPI LsaSetSecret( - __in LSA_HANDLE SecretHandle, - __in_opt PLSA_UNICODE_STRING CurrentValue, - __in_opt PLSA_UNICODE_STRING OldValue + _In_ LSA_HANDLE SecretHandle, + _In_opt_ PLSA_UNICODE_STRING CurrentValue, + _In_opt_ PLSA_UNICODE_STRING OldValue ); NTSTATUS NTAPI LsaQuerySecret( - __in LSA_HANDLE SecretHandle, - __out_opt OPTIONAL PLSA_UNICODE_STRING *CurrentValue, - __out_opt PLARGE_INTEGER CurrentValueSetTime, - __out_opt PLSA_UNICODE_STRING *OldValue, - __out_opt PLARGE_INTEGER OldValueSetTime + _In_ LSA_HANDLE SecretHandle, + _Out_opt_ OPTIONAL PLSA_UNICODE_STRING *CurrentValue, + _Out_opt_ PLARGE_INTEGER CurrentValueSetTime, + _Out_opt_ PLSA_UNICODE_STRING *OldValue, + _Out_opt_ PLARGE_INTEGER OldValueSetTime ); // Privilege NTSTATUS NTAPI LsaLookupPrivilegeValue( - __in LSA_HANDLE PolicyHandle, - __in PLSA_UNICODE_STRING Name, - __out PLUID Value + _In_ LSA_HANDLE PolicyHandle, + _In_ PLSA_UNICODE_STRING Name, + _Out_ PLUID Value ); NTSTATUS NTAPI LsaLookupPrivilegeName( - __in LSA_HANDLE PolicyHandle, - __in PLUID Value, - __out PLSA_UNICODE_STRING *Name + _In_ LSA_HANDLE PolicyHandle, + _In_ PLUID Value, + _Out_ PLSA_UNICODE_STRING *Name ); NTSTATUS NTAPI LsaLookupPrivilegeDisplayName( - __in LSA_HANDLE PolicyHandle, - __in PLSA_UNICODE_STRING Name, - __out PLSA_UNICODE_STRING *DisplayName, - __out PSHORT LanguageReturned + _In_ LSA_HANDLE PolicyHandle, + _In_ PLSA_UNICODE_STRING Name, + _Out_ PLSA_UNICODE_STRING *DisplayName, + _Out_ PSHORT LanguageReturned ); // Misc. NTSTATUS NTAPI LsaChangePassword( - __in PLSA_UNICODE_STRING ServerName, - __in PLSA_UNICODE_STRING DomainName, - __in PLSA_UNICODE_STRING AccountName, - __in PLSA_UNICODE_STRING OldPassword, - __in PLSA_UNICODE_STRING NewPassword + _In_ PLSA_UNICODE_STRING ServerName, + _In_ PLSA_UNICODE_STRING DomainName, + _In_ PLSA_UNICODE_STRING AccountName, + _In_ PLSA_UNICODE_STRING OldPassword, + _In_ PLSA_UNICODE_STRING NewPassword ); NTSTATUS NTAPI LsaGetUserName( - __deref_out PLSA_UNICODE_STRING *UserName, - __deref_opt_out PLSA_UNICODE_STRING *DomainName + _Outptr_ PLSA_UNICODE_STRING *UserName, + _Outptr_opt_ PLSA_UNICODE_STRING *DomainName ); NTSTATUS NTAPI LsaGetRemoteUserName( - __in_opt PLSA_UNICODE_STRING SystemName, - __deref_out PLSA_UNICODE_STRING *UserName, - __deref_opt_out PLSA_UNICODE_STRING *DomainName + _In_opt_ PLSA_UNICODE_STRING SystemName, + _Outptr_ PLSA_UNICODE_STRING *UserName, + _Outptr_opt_ PLSA_UNICODE_STRING *DomainName ); #endif diff --git a/2.x/trunk/phlib/include/ntmisc.h b/2.x/trunk/phlib/include/ntmisc.h index fd9f52b3e..b82665ae8 100644 --- a/2.x/trunk/phlib/include/ntmisc.h +++ b/2.x/trunk/phlib/include/ntmisc.h @@ -9,7 +9,7 @@ NTSYSCALLAPI NTSTATUS NTAPI NtDrawText( - __in PUNICODE_STRING Text + _In_ PUNICODE_STRING Text ); #endif @@ -43,8 +43,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtVdmControl( - __in VDMSERVICECLASS Service, - __inout PVOID ServiceData + _In_ VDMSERVICECLASS Service, + _Inout_ PVOID ServiceData ); // WMI/ETW @@ -53,10 +53,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtTraceEvent( - __in HANDLE TraceHandle, - __in ULONG Flags, - __in ULONG FieldSize, - __in PVOID Fields + _In_ HANDLE TraceHandle, + _In_ ULONG Flags, + _In_ ULONG FieldSize, + _In_ PVOID Fields ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -65,12 +65,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtTraceControl( - __in ULONG FunctionCode, - __in_bcount_opt(InBufferLen) PVOID InBuffer, - __in ULONG InBufferLen, - __out_bcount_opt(OutBufferLen) PVOID OutBuffer, - __in ULONG OutBufferLen, - __out PULONG ReturnLength + _In_ ULONG FunctionCode, + _In_reads_bytes_opt_(InBufferLen) PVOID InBuffer, + _In_ ULONG InBufferLen, + _Out_writes_bytes_opt_(OutBufferLen) PVOID OutBuffer, + _In_ ULONG OutBufferLen, + _Out_ PULONG ReturnLength ); #endif diff --git a/2.x/trunk/phlib/include/ntmmapi.h b/2.x/trunk/phlib/include/ntmmapi.h index 50192d30e..12d543771 100644 --- a/2.x/trunk/phlib/include/ntmmapi.h +++ b/2.x/trunk/phlib/include/ntmmapi.h @@ -1,13 +1,15 @@ #ifndef _NTMMAPI_H #define _NTMMAPI_H +// private typedef enum _MEMORY_INFORMATION_CLASS { MemoryBasicInformation, MemoryWorkingSetInformation, MemoryMappedFilenameInformation, MemoryRegionInformation, - MemoryWorkingSetExInformation + MemoryWorkingSetExInformation, + MemorySharedCommitInformation } MEMORY_INFORMATION_CLASS; typedef struct _MEMORY_WORKING_SET_BLOCK @@ -87,6 +89,12 @@ typedef struct _MEMORY_WORKING_SET_EX_INFORMATION } u1; } MEMORY_WORKING_SET_EX_INFORMATION, *PMEMORY_WORKING_SET_EX_INFORMATION; +// private +typedef struct _MEMORY_SHARED_COMMIT_INFORMATION +{ + SIZE_T CommitSize; +} MEMORY_SHARED_COMMIT_INFORMATION, *PMEMORY_SHARED_COMMIT_INFORMATION; + #define MMPFNLIST_ZERO 0 #define MMPFNLIST_FREE 1 #define MMPFNLIST_STANDBY 2 @@ -234,87 +242,87 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAllocateVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __in ULONG_PTR ZeroBits, - __inout PSIZE_T RegionSize, - __in ULONG AllocationType, - __in ULONG Protect + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _In_ ULONG_PTR ZeroBits, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG AllocationType, + _In_ ULONG Protect ); NTSYSCALLAPI NTSTATUS NTAPI NtFreeVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG FreeType + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG FreeType ); NTSYSCALLAPI NTSTATUS NTAPI NtReadVirtualMemory( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ); NTSYSCALLAPI NTSTATUS NTAPI NtWriteVirtualMemory( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ); NTSYSCALLAPI NTSTATUS NTAPI NtProtectVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG NewProtect, - __out PULONG OldProtect + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG NewProtect, + _Out_ PULONG OldProtect ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in MEMORY_INFORMATION_CLASS MemoryInformationClass, - __out_bcount(MemoryInformationLength) PVOID MemoryInformation, - __in SIZE_T MemoryInformationLength, - __out_opt PSIZE_T ReturnLength + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ MEMORY_INFORMATION_CLASS MemoryInformationClass, + _Out_writes_bytes_(MemoryInformationLength) PVOID MemoryInformation, + _In_ SIZE_T MemoryInformationLength, + _Out_opt_ PSIZE_T ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtLockVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG MapType + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG MapType ); NTSYSCALLAPI NTSTATUS NTAPI NtUnlockVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG MapType + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG MapType ); // Sections @@ -323,73 +331,73 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateSection( - __out PHANDLE SectionHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PLARGE_INTEGER MaximumSize, - __in ULONG SectionPageProtection, - __in ULONG AllocationAttributes, - __in_opt HANDLE FileHandle + _Out_ PHANDLE SectionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PLARGE_INTEGER MaximumSize, + _In_ ULONG SectionPageProtection, + _In_ ULONG AllocationAttributes, + _In_opt_ HANDLE FileHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenSection( - __out PHANDLE SectionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE SectionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtMapViewOfSection( - __in HANDLE SectionHandle, - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __in ULONG_PTR ZeroBits, - __in SIZE_T CommitSize, - __inout_opt PLARGE_INTEGER SectionOffset, - __inout PSIZE_T ViewSize, - __in SECTION_INHERIT InheritDisposition, - __in ULONG AllocationType, - __in ULONG Win32Protect + _In_ HANDLE SectionHandle, + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _In_ ULONG_PTR ZeroBits, + _In_ SIZE_T CommitSize, + _Inout_opt_ PLARGE_INTEGER SectionOffset, + _Inout_ PSIZE_T ViewSize, + _In_ SECTION_INHERIT InheritDisposition, + _In_ ULONG AllocationType, + _In_ ULONG Win32Protect ); NTSYSCALLAPI NTSTATUS NTAPI NtUnmapViewOfSection( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress ); NTSYSCALLAPI NTSTATUS NTAPI NtExtendSection( - __in HANDLE SectionHandle, - __inout PLARGE_INTEGER NewSectionSize + _In_ HANDLE SectionHandle, + _Inout_ PLARGE_INTEGER NewSectionSize ); NTSYSCALLAPI NTSTATUS NTAPI NtQuerySection( - __in HANDLE SectionHandle, - __in SECTION_INFORMATION_CLASS SectionInformationClass, - __out_bcount(SectionInformationLength) PVOID SectionInformation, - __in SIZE_T SectionInformationLength, - __out_opt PSIZE_T ReturnLength + _In_ HANDLE SectionHandle, + _In_ SECTION_INFORMATION_CLASS SectionInformationClass, + _Out_writes_bytes_(SectionInformationLength) PVOID SectionInformation, + _In_ SIZE_T SectionInformationLength, + _Out_opt_ PSIZE_T ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtAreMappedFilesTheSame( - __in PVOID File1MappedAsAnImage, - __in PVOID File2MappedAsFile + _In_ PVOID File1MappedAsAnImage, + _In_ PVOID File2MappedAsFile ); // User physical pages @@ -398,36 +406,36 @@ NTSYSCALLAPI NTSTATUS NTAPI NtMapUserPhysicalPages( - __in PVOID VirtualAddress, - __in ULONG_PTR NumberOfPages, - __in_ecount_opt(NumberOfPages) PULONG_PTR UserPfnArray + _In_ PVOID VirtualAddress, + _In_ ULONG_PTR NumberOfPages, + _In_reads_opt_(NumberOfPages) PULONG_PTR UserPfnArray ); NTSYSCALLAPI NTSTATUS NTAPI NtMapUserPhysicalPagesScatter( - __in_ecount(NumberOfPages) PVOID *VirtualAddresses, - __in ULONG_PTR NumberOfPages, - __in_ecount_opt(NumberOfPages) PULONG_PTR UserPfnArray + _In_reads_(NumberOfPages) PVOID *VirtualAddresses, + _In_ ULONG_PTR NumberOfPages, + _In_reads_opt_(NumberOfPages) PULONG_PTR UserPfnArray ); NTSYSCALLAPI NTSTATUS NTAPI NtAllocateUserPhysicalPages( - __in HANDLE ProcessHandle, - __inout PULONG_PTR NumberOfPages, - __out_ecount(*NumberOfPages) PULONG_PTR UserPfnArray + _In_ HANDLE ProcessHandle, + _Inout_ PULONG_PTR NumberOfPages, + _Out_writes_(*NumberOfPages) PULONG_PTR UserPfnArray ); NTSYSCALLAPI NTSTATUS NTAPI NtFreeUserPhysicalPages( - __in HANDLE ProcessHandle, - __inout PULONG_PTR NumberOfPages, - __in_ecount(*NumberOfPages) PULONG_PTR UserPfnArray + _In_ HANDLE ProcessHandle, + _Inout_ PULONG_PTR NumberOfPages, + _In_reads_(*NumberOfPages) PULONG_PTR UserPfnArray ); // Sessions @@ -438,9 +446,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenSession( - __out PHANDLE SessionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE SessionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); #endif @@ -452,41 +460,41 @@ NTSYSCALLAPI NTSTATUS NTAPI NtGetWriteWatch( - __in HANDLE ProcessHandle, - __in ULONG Flags, - __in PVOID BaseAddress, - __in SIZE_T RegionSize, - __out_ecount(*EntriesInUserAddressArray) PVOID *UserAddressArray, - __inout PULONG_PTR EntriesInUserAddressArray, - __out PULONG Granularity + _In_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress, + _In_ SIZE_T RegionSize, + _Out_writes_(*EntriesInUserAddressArray) PVOID *UserAddressArray, + _Inout_ PULONG_PTR EntriesInUserAddressArray, + _Out_ PULONG Granularity ); NTSYSCALLAPI NTSTATUS NTAPI NtResetWriteWatch( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in SIZE_T RegionSize + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ SIZE_T RegionSize ); NTSYSCALLAPI NTSTATUS NTAPI NtCreatePagingFile( - __in PUNICODE_STRING PageFileName, - __in PLARGE_INTEGER MinimumSize, - __in PLARGE_INTEGER MaximumSize, - __in ULONG Priority + _In_ PUNICODE_STRING PageFileName, + _In_ PLARGE_INTEGER MinimumSize, + _In_ PLARGE_INTEGER MaximumSize, + _In_ ULONG Priority ); NTSYSCALLAPI NTSTATUS NTAPI NtFlushInstructionCache( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __in SIZE_T Length + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _In_ SIZE_T Length ); NTSYSCALLAPI diff --git a/2.x/trunk/phlib/include/ntobapi.h b/2.x/trunk/phlib/include/ntobapi.h index dabbe4f6d..2a205da2f 100644 --- a/2.x/trunk/phlib/include/ntobapi.h +++ b/2.x/trunk/phlib/include/ntobapi.h @@ -110,21 +110,21 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryObject( - __in HANDLE Handle, - __in OBJECT_INFORMATION_CLASS ObjectInformationClass, - __out_bcount_opt(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE Handle, + _In_ OBJECT_INFORMATION_CLASS ObjectInformationClass, + _Out_writes_bytes_opt_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationObject( - __in HANDLE Handle, - __in OBJECT_INFORMATION_CLASS ObjectInformationClass, - __in_bcount(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength + _In_ HANDLE Handle, + _In_ OBJECT_INFORMATION_CLASS ObjectInformationClass, + _In_reads_bytes_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength ); #define DUPLICATE_CLOSE_SOURCE 0x00000001 @@ -135,81 +135,81 @@ NTSYSCALLAPI NTSTATUS NTAPI NtDuplicateObject( - __in HANDLE SourceProcessHandle, - __in HANDLE SourceHandle, - __in_opt HANDLE TargetProcessHandle, - __out_opt PHANDLE TargetHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Options + _In_ HANDLE SourceProcessHandle, + _In_ HANDLE SourceHandle, + _In_opt_ HANDLE TargetProcessHandle, + _Out_opt_ PHANDLE TargetHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Options ); NTSYSCALLAPI NTSTATUS NTAPI NtMakeTemporaryObject( - __in HANDLE Handle + _In_ HANDLE Handle ); typedef NTSTATUS (NTAPI *_NtMakePermanentObject)( - __in HANDLE Handle + _In_ HANDLE Handle ); NTSYSCALLAPI NTSTATUS NTAPI NtSignalAndWaitForSingleObject( - __in HANDLE SignalHandle, - __in HANDLE WaitHandle, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE SignalHandle, + _In_ HANDLE WaitHandle, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI NtWaitForSingleObject( - __in HANDLE Handle, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE Handle, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI NtWaitForMultipleObjects( - __in ULONG Count, - __in_ecount(Count) PHANDLE Handles, - __in WAIT_TYPE WaitType, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ ULONG Count, + _In_reads_(Count) PHANDLE Handles, + _In_ WAIT_TYPE WaitType, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI NtSetSecurityObject( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); NTSYSCALLAPI NTSTATUS NTAPI NtQuerySecurityObject( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __out_bcount_opt(Length) PSECURITY_DESCRIPTOR SecurityDescriptor, - __in ULONG Length, - __out PULONG LengthNeeded + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_writes_bytes_opt_(Length) PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ ULONG Length, + _Out_ PULONG LengthNeeded ); NTSYSCALLAPI NTSTATUS NTAPI NtClose( - __in HANDLE Handle + _In_ HANDLE Handle ); #endif @@ -222,18 +222,18 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateDirectoryObject( - __out PHANDLE DirectoryHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE DirectoryHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenDirectoryObject( - __out PHANDLE DirectoryHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE DirectoryHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); typedef struct _OBJECT_DIRECTORY_INFORMATION @@ -246,13 +246,13 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryDirectoryObject( - __in HANDLE DirectoryHandle, - __out_bcount_opt(Length) PVOID Buffer, - __in ULONG Length, - __in BOOLEAN ReturnSingleEntry, - __in BOOLEAN RestartScan, - __inout PULONG Context, - __out_opt PULONG ReturnLength + _In_ HANDLE DirectoryHandle, + _Out_writes_bytes_opt_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_ BOOLEAN ReturnSingleEntry, + _In_ BOOLEAN RestartScan, + _Inout_ PULONG Context, + _Out_opt_ PULONG ReturnLength ); #endif @@ -269,27 +269,27 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreatePrivateNamespace( - __out PHANDLE NamespaceHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in PVOID BoundaryDescriptor + _Out_ PHANDLE NamespaceHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PVOID BoundaryDescriptor ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenPrivateNamespace( - __out PHANDLE NamespaceHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in PVOID BoundaryDescriptor + _Out_ PHANDLE NamespaceHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PVOID BoundaryDescriptor ); NTSYSCALLAPI NTSTATUS NTAPI NtDeletePrivateNamespace( - __in HANDLE NamespaceHandle + _In_ HANDLE NamespaceHandle ); // end_private @@ -306,28 +306,28 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateSymbolicLinkObject( - __out PHANDLE LinkHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in PUNICODE_STRING LinkTarget + _Out_ PHANDLE LinkHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PUNICODE_STRING LinkTarget ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenSymbolicLinkObject( - __out PHANDLE LinkHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE LinkHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtQuerySymbolicLinkObject( - __in HANDLE LinkHandle, - __inout PUNICODE_STRING LinkTarget, - __out_opt PULONG ReturnedLength + _In_ HANDLE LinkHandle, + _Inout_ PUNICODE_STRING LinkTarget, + _Out_opt_ PULONG ReturnedLength ); #endif diff --git a/2.x/trunk/phlib/include/ntpebteb.h b/2.x/trunk/phlib/include/ntpebteb.h index 19f70b1e2..0d904a80c 100644 --- a/2.x/trunk/phlib/include/ntpebteb.h +++ b/2.x/trunk/phlib/include/ntpebteb.h @@ -21,11 +21,11 @@ typedef struct _PEB { BOOLEAN ImageUsesLargePages : 1; BOOLEAN IsProtectedProcess : 1; - BOOLEAN IsLegacyProcess : 1; BOOLEAN IsImageDynamicallyRelocated : 1; BOOLEAN SkipPatchingUser32Forwarders : 1; BOOLEAN IsPackagedProcess : 1; BOOLEAN IsAppContainer : 1; + BOOLEAN IsProtectedProcessLight : 1; BOOLEAN SpareBits : 1; }; }; diff --git a/2.x/trunk/phlib/include/ntpnpapi.h b/2.x/trunk/phlib/include/ntpnpapi.h index 927d98e96..50c62a6c1 100644 --- a/2.x/trunk/phlib/include/ntpnpapi.h +++ b/2.x/trunk/phlib/include/ntpnpapi.h @@ -102,19 +102,19 @@ NTSYSCALLAPI NTSTATUS NTAPI NtGetPlugPlayEvent( - __in HANDLE EventHandle, - __in_opt PVOID Context, - __out_bcount(EventBufferSize) PPLUGPLAY_EVENT_BLOCK EventBlock, - __in ULONG EventBufferSize + _In_ HANDLE EventHandle, + _In_opt_ PVOID Context, + _Out_writes_bytes_(EventBufferSize) PPLUGPLAY_EVENT_BLOCK EventBlock, + _In_ ULONG EventBufferSize ); NTSYSCALLAPI NTSTATUS NTAPI NtPlugPlayControl( - __in PLUGPLAY_CONTROL_CLASS PnPControlClass, - __inout_bcount(PnPControlDataLength) PVOID PnPControlData, - __in ULONG PnPControlDataLength + _In_ PLUGPLAY_CONTROL_CLASS PnPControlClass, + _Inout_updates_bytes_(PnPControlDataLength) PVOID PnPControlData, + _In_ ULONG PnPControlDataLength ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -133,9 +133,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtReplacePartitionUnit( - __in PUNICODE_STRING TargetInstancePath, - __in PUNICODE_STRING SpareInstancePath, - __in ULONG Flags + _In_ PUNICODE_STRING TargetInstancePath, + _In_ PUNICODE_STRING SpareInstancePath, + _In_ ULONG Flags ); #endif diff --git a/2.x/trunk/phlib/include/ntpoapi.h b/2.x/trunk/phlib/include/ntpoapi.h index 147090d4f..fe5a2ab54 100644 --- a/2.x/trunk/phlib/include/ntpoapi.h +++ b/2.x/trunk/phlib/include/ntpoapi.h @@ -48,7 +48,7 @@ typedef struct _COUNTED_REASON_CONTEXT UNICODE_STRING ResourceFileName; USHORT ResourceReasonId; ULONG StringCount; - PUNICODE_STRING __field_ecount(StringCount) ReasonStrings; + PUNICODE_STRING _Field_size_(StringCount) ReasonStrings; }; UNICODE_STRING SimpleString; }; @@ -69,15 +69,15 @@ typedef enum } POWER_STATE_HANDLER_TYPE, *PPOWER_STATE_HANDLER_TYPE; typedef NTSTATUS (NTAPI *PENTER_STATE_SYSTEM_HANDLER)( - __in PVOID SystemContext + _In_ PVOID SystemContext ); typedef NTSTATUS (NTAPI *PENTER_STATE_HANDLER)( - __in PVOID Context, - __in_opt PENTER_STATE_SYSTEM_HANDLER SystemHandler, - __in PVOID SystemContext, - __in LONG NumberProcessors, - __in volatile PLONG Number + _In_ PVOID Context, + _In_opt_ PENTER_STATE_SYSTEM_HANDLER SystemHandler, + _In_ PVOID SystemContext, + _In_ LONG NumberProcessors, + _In_ volatile PLONG Number ); typedef struct _POWER_STATE_HANDLER @@ -90,9 +90,9 @@ typedef struct _POWER_STATE_HANDLER } POWER_STATE_HANDLER, *PPOWER_STATE_HANDLER; typedef NTSTATUS (NTAPI *PENTER_STATE_NOTIFY_HANDLER)( - __in POWER_STATE_HANDLER_TYPE State, - __in PVOID Context, - __in BOOLEAN Entering + _In_ POWER_STATE_HANDLER_TYPE State, + _In_ PVOID Context, + _In_ BOOLEAN Entering ); typedef struct _POWER_STATE_NOTIFY_HANDLER @@ -123,53 +123,53 @@ NTSYSCALLAPI NTSTATUS NTAPI NtPowerInformation( - __in POWER_INFORMATION_LEVEL InformationLevel, - __in_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ POWER_INFORMATION_LEVEL InformationLevel, + _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetThreadExecutionState( - __in EXECUTION_STATE NewFlags, // ES_* flags - __out EXECUTION_STATE *PreviousFlags + _In_ EXECUTION_STATE NewFlags, // ES_* flags + _Out_ EXECUTION_STATE *PreviousFlags ); NTSYSCALLAPI NTSTATUS NTAPI NtRequestWakeupLatency( - __in LATENCY_TIME latency + _In_ LATENCY_TIME latency ); NTSYSCALLAPI NTSTATUS NTAPI NtInitiatePowerAction( - __in POWER_ACTION SystemAction, - __in SYSTEM_POWER_STATE LightestSystemState, - __in ULONG Flags, // POWER_ACTION_* flags - __in BOOLEAN Asynchronous + _In_ POWER_ACTION SystemAction, + _In_ SYSTEM_POWER_STATE LightestSystemState, + _In_ ULONG Flags, // POWER_ACTION_* flags + _In_ BOOLEAN Asynchronous ); NTSYSCALLAPI NTSTATUS NTAPI NtSetSystemPowerState( - __in POWER_ACTION SystemAction, - __in SYSTEM_POWER_STATE LightestSystemState, - __in ULONG Flags // POWER_ACTION_* flags + _In_ POWER_ACTION SystemAction, + _In_ SYSTEM_POWER_STATE LightestSystemState, + _In_ ULONG Flags // POWER_ACTION_* flags ); NTSYSCALLAPI NTSTATUS NTAPI NtGetDevicePowerState( - __in HANDLE Device, - __out PDEVICE_POWER_STATE State + _In_ HANDLE Device, + _Out_ PDEVICE_POWER_STATE State ); NTSYSCALLAPI diff --git a/2.x/trunk/phlib/include/ntpsapi.h b/2.x/trunk/phlib/include/ntpsapi.h index dd4af7337..23f098b5f 100644 --- a/2.x/trunk/phlib/include/ntpsapi.h +++ b/2.x/trunk/phlib/include/ntpsapi.h @@ -135,7 +135,7 @@ typedef enum _PROCESSINFOCLASS ProcessResourceManagement, ProcessCookie, // q: ULONG ProcessImageInformation, // q: SECTION_IMAGE_INFORMATION - ProcessCycleTime, // q: PROCESS_CYCLE_TIME_INFORMATION + ProcessCycleTime, // q: PROCESS_CYCLE_TIME_INFORMATION // since VISTA ProcessPagePriority, // q: ULONG ProcessInstrumentationCallback, // 40 ProcessThreadStackAllocation, // s: PROCESS_STACK_ALLOCATION_INFORMATION, PROCESS_STACK_ALLOCATION_INFORMATION_EX @@ -154,7 +154,11 @@ typedef enum _PROCESSINFOCLASS ProcessHandleCheckingMode, ProcessKeepAliveCount, // q: PROCESS_KEEPALIVE_COUNT_INFORMATION ProcessRevokeFileHandles, // s: PROCESS_REVOKE_FILE_HANDLES_INFORMATION - ProcessWorkingSetControl, + ProcessWorkingSetControl, // s: PROCESS_WORKING_SET_CONTROL + ProcessHandleTable, // since WINBLUE + ProcessCheckStackExtentsMode, + ProcessCommandLineInformation, // 60, q: UNICODE_STRING + ProcessProtectionInformation, // q: PS_PROTECTION MaxProcessInfoClass } PROCESSINFOCLASS; #endif @@ -197,6 +201,7 @@ typedef enum _THREADINFOCLASS ThreadCounterProfiling, ThreadIdealProcessorEx, // q: PROCESSOR_NUMBER ThreadCpuAccountingInformation, // since WIN8 + ThreadSuspendCount, // since WINBLUE MaxThreadInfoClass } THREADINFOCLASS; #endif @@ -497,23 +502,40 @@ typedef struct _PROCESS_HANDLE_SNAPSHOT_INFORMATION #if (PHNT_MODE != PHNT_MODE_KERNEL) +// private +typedef struct _PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY +{ + union + { + ULONG Flags; + struct + { + ULONG EnableControlFlowGuard : 1; + ULONG ReservedFlags : 31; + }; + }; +} PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY, *PPROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY; + // private typedef struct _PROCESS_MITIGATION_POLICY_INFORMATION { PROCESS_MITIGATION_POLICY Policy; union { - //PROCESS_MITIGATION_DEP_POLICY DEPPolicy; PROCESS_MITIGATION_ASLR_POLICY ASLRPolicy; PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY StrictHandleCheckPolicy; PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY SystemCallDisablePolicy; PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY ExtensionPointDisablePolicy; + PROCESS_MITIGATION_DYNAMIC_CODE_POLICY DynamicCodePolicy; + PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY ControlFlowGuardPolicy; + PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY SignaturePolicy; }; } PROCESS_MITIGATION_POLICY_INFORMATION, *PPROCESS_MITIGATION_POLICY_INFORMATION; typedef struct _PROCESS_KEEPALIVE_COUNT_INFORMATION { - ULONG Count; + ULONG WakeCount; + ULONG NoWakeCount; } PROCESS_KEEPALIVE_COUNT_INFORMATION, *PPROCESS_KEEPALIVE_COUNT_INFORMATION; typedef struct _PROCESS_REVOKE_FILE_HANDLES_INFORMATION @@ -521,6 +543,58 @@ typedef struct _PROCESS_REVOKE_FILE_HANDLES_INFORMATION UNICODE_STRING TargetDevicePath; } PROCESS_REVOKE_FILE_HANDLES_INFORMATION, *PPROCESS_REVOKE_FILE_HANDLES_INFORMATION; +// begin_private + +typedef enum _PROCESS_WORKING_SET_OPERATION +{ + ProcessWorkingSetSwap, + ProcessWorkingSetEmpty, + ProcessWorkingSetOperationMax +} PROCESS_WORKING_SET_OPERATION; + +typedef struct _PROCESS_WORKING_SET_CONTROL +{ + ULONG Version; + PROCESS_WORKING_SET_OPERATION Operation; + ULONG Flags; +} PROCESS_WORKING_SET_CONTROL, *PPROCESS_WORKING_SET_CONTROL; + +typedef enum _PS_PROTECTED_TYPE +{ + PsProtectedTypeNone, + PsProtectedTypeProtectedLight, + PsProtectedTypeProtected, + PsProtectedTypeMax +} PS_PROTECTED_TYPE; + +typedef enum _PS_PROTECTED_SIGNER +{ + PsProtectedSignerNone, + PsProtectedSignerAuthenticode, + PsProtectedSignerCodeGen, + PsProtectedSignerAntimalware, + PsProtectedSignerLsa, + PsProtectedSignerWindows, + PsProtectedSignerWinTcb, + PsProtectedSignerMax +} PS_PROTECTED_SIGNER; + +typedef struct _PS_PROTECTION +{ + union + { + UCHAR Level; + struct + { + UCHAR Type : 3; + UCHAR Audit : 1; + UCHAR Signer : 4; + }; + }; +} PS_PROTECTION, *PPS_PROTECTION; + +// end_private + #endif // Thread information structures @@ -600,14 +674,14 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ParentProcess, - __in BOOLEAN InheritObjectTable, - __in_opt HANDLE SectionHandle, - __in_opt HANDLE DebugPort, - __in_opt HANDLE ExceptionPort + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ParentProcess, + _In_ BOOLEAN InheritObjectTable, + _In_opt_ HANDLE SectionHandle, + _In_opt_ HANDLE DebugPort, + _In_opt_ HANDLE ExceptionPort ); #define PROCESS_CREATE_FLAGS_BREAKAWAY 0x00000001 @@ -620,47 +694,47 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateProcessEx( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ParentProcess, - __in ULONG Flags, - __in_opt HANDLE SectionHandle, - __in_opt HANDLE DebugPort, - __in_opt HANDLE ExceptionPort, - __in ULONG JobMemberLevel + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ParentProcess, + _In_ ULONG Flags, + _In_opt_ HANDLE SectionHandle, + _In_opt_ HANDLE DebugPort, + _In_opt_ HANDLE ExceptionPort, + _In_ ULONG JobMemberLevel ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PCLIENT_ID ClientId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PCLIENT_ID ClientId ); NTSYSCALLAPI NTSTATUS NTAPI NtTerminateProcess( - __in_opt HANDLE ProcessHandle, - __in NTSTATUS ExitStatus + _In_opt_ HANDLE ProcessHandle, + _In_ NTSTATUS ExitStatus ); NTSYSCALLAPI NTSTATUS NTAPI NtSuspendProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtResumeProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); #define NtCurrentProcess() ((HANDLE)(LONG_PTR)-1) @@ -678,11 +752,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationProcess( - __in HANDLE ProcessHandle, - __in PROCESSINFOCLASS ProcessInformationClass, - __out_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _In_ PROCESSINFOCLASS ProcessInformationClass, + _Out_writes_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength, + _Out_opt_ PULONG ReturnLength ); #if (PHNT_VERSION >= PHNT_WS03) @@ -690,11 +764,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtGetNextProcess( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Flags, - __out PHANDLE NewProcessHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Flags, + _Out_ PHANDLE NewProcessHandle ); #endif @@ -703,12 +777,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtGetNextThread( - __in HANDLE ProcessHandle, - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Flags, - __out PHANDLE NewThreadHandle + _In_ HANDLE ProcessHandle, + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Flags, + _Out_ PHANDLE NewThreadHandle ); #endif @@ -716,10 +790,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationProcess( - __in HANDLE ProcessHandle, - __in PROCESSINFOCLASS ProcessInformationClass, - __in_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength + _In_ HANDLE ProcessHandle, + _In_ PROCESSINFOCLASS ProcessInformationClass, + _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength ); NTSYSCALLAPI @@ -739,48 +813,48 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ProcessHandle, - __out PCLIENT_ID ClientId, - __in PCONTEXT ThreadContext, - __in PINITIAL_TEB InitialTeb, - __in BOOLEAN CreateSuspended + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ProcessHandle, + _Out_ PCLIENT_ID ClientId, + _In_ PCONTEXT ThreadContext, + _In_ PINITIAL_TEB InitialTeb, + _In_ BOOLEAN CreateSuspended ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PCLIENT_ID ClientId + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PCLIENT_ID ClientId ); NTSYSCALLAPI NTSTATUS NTAPI NtTerminateThread( - __in_opt HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_opt_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ); NTSYSCALLAPI NTSTATUS NTAPI NtSuspendThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); NTSYSCALLAPI NTSTATUS NTAPI NtResumeThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); NTSYSCALLAPI @@ -794,52 +868,52 @@ NTSYSCALLAPI NTSTATUS NTAPI NtGetContextThread( - __in HANDLE ThreadHandle, - __inout PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _Inout_ PCONTEXT ThreadContext ); NTSYSCALLAPI NTSTATUS NTAPI NtSetContextThread( - __in HANDLE ThreadHandle, - __in PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _In_ PCONTEXT ThreadContext ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationThread( - __in HANDLE ThreadHandle, - __in THREADINFOCLASS ThreadInformationClass, - __out_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ThreadHandle, + _In_ THREADINFOCLASS ThreadInformationClass, + _Out_writes_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationThread( - __in HANDLE ThreadHandle, - __in THREADINFOCLASS ThreadInformationClass, - __in_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength + _In_ HANDLE ThreadHandle, + _In_ THREADINFOCLASS ThreadInformationClass, + _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI NtAlertThread( - __in HANDLE ThreadHandle + _In_ HANDLE ThreadHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtAlertResumeThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); NTSYSCALLAPI @@ -853,45 +927,45 @@ NTSYSCALLAPI NTSTATUS NTAPI NtImpersonateThread( - __in HANDLE ServerThreadHandle, - __in HANDLE ClientThreadHandle, - __in PSECURITY_QUALITY_OF_SERVICE SecurityQos + _In_ HANDLE ServerThreadHandle, + _In_ HANDLE ClientThreadHandle, + _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos ); NTSYSCALLAPI NTSTATUS NTAPI NtRegisterThreadTerminatePort( - __in HANDLE PortHandle + _In_ HANDLE PortHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtSetLdtEntries( - __in ULONG Selector0, - __in ULONG Entry0Low, - __in ULONG Entry0Hi, - __in ULONG Selector1, - __in ULONG Entry1Low, - __in ULONG Entry1Hi + _In_ ULONG Selector0, + _In_ ULONG Entry0Low, + _In_ ULONG Entry0Hi, + _In_ ULONG Selector1, + _In_ ULONG Entry1Low, + _In_ ULONG Entry1Hi ); typedef VOID (*PPS_APC_ROUTINE)( - __in_opt PVOID ApcArgument1, - __in_opt PVOID ApcArgument2, - __in_opt PVOID ApcArgument3 + _In_opt_ PVOID ApcArgument1, + _In_opt_ PVOID ApcArgument2, + _In_opt_ PVOID ApcArgument3 ); NTSYSCALLAPI NTSTATUS NTAPI NtQueueApcThread( - __in HANDLE ThreadHandle, - __in PPS_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcArgument1, - __in_opt PVOID ApcArgument2, - __in_opt PVOID ApcArgument3 + _In_ HANDLE ThreadHandle, + _In_ PPS_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcArgument1, + _In_opt_ PVOID ApcArgument2, + _In_opt_ PVOID ApcArgument3 ); #endif @@ -929,7 +1003,7 @@ typedef enum _PS_ATTRIBUTE_NUM PsAttributeIdealProcessor, // in PPROCESSOR_NUMBER PsAttributeUmsThread, // ? in PUMS_CREATE_THREAD_ATTRIBUTES PsAttributeMitigationOptions, // in UCHAR - PsAttributeSecurityCapabilities, + PsAttributeProtectionLevel, PsAttributeMax } PS_ATTRIBUTE_NUM; @@ -1134,17 +1208,17 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateUserProcess( - __out PHANDLE ProcessHandle, - __out PHANDLE ThreadHandle, - __in ACCESS_MASK ProcessDesiredAccess, - __in ACCESS_MASK ThreadDesiredAccess, - __in_opt POBJECT_ATTRIBUTES ProcessObjectAttributes, - __in_opt POBJECT_ATTRIBUTES ThreadObjectAttributes, - __in ULONG ProcessFlags, // PROCESS_CREATE_FLAGS_* - __in ULONG ThreadFlags, // THREAD_CREATE_FLAGS_* - __in_opt PVOID ProcessParameters, - __inout PPS_CREATE_INFO CreateInfo, - __in_opt PPS_ATTRIBUTE_LIST AttributeList + _Out_ PHANDLE ProcessHandle, + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK ProcessDesiredAccess, + _In_ ACCESS_MASK ThreadDesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ProcessObjectAttributes, + _In_opt_ POBJECT_ATTRIBUTES ThreadObjectAttributes, + _In_ ULONG ProcessFlags, // PROCESS_CREATE_FLAGS_* + _In_ ULONG ThreadFlags, // THREAD_CREATE_FLAGS_* + _In_opt_ PVOID ProcessParameters, + _Inout_ PPS_CREATE_INFO CreateInfo, + _In_opt_ PPS_ATTRIBUTE_LIST AttributeList ); #endif @@ -1163,17 +1237,17 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateThreadEx( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ProcessHandle, - __in PVOID StartRoutine, - __in_opt PVOID Argument, - __in ULONG CreateFlags, // THREAD_CREATE_FLAGS_* - __in_opt ULONG_PTR ZeroBits, - __in_opt SIZE_T StackSize, - __in_opt SIZE_T MaximumStackSize, - __in_opt PPS_ATTRIBUTE_LIST AttributeList + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ProcessHandle, + _In_ PVOID StartRoutine, + _In_opt_ PVOID Argument, + _In_ ULONG CreateFlags, // THREAD_CREATE_FLAGS_* + _In_opt_ ULONG_PTR ZeroBits, + _In_opt_ SIZE_T StackSize, + _In_opt_ SIZE_T MaximumStackSize, + _In_opt_ PPS_ATTRIBUTE_LIST AttributeList ); #endif @@ -1198,9 +1272,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAllocateReserveObject( - __out PHANDLE MemoryReserveHandle, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in MEMORY_RESERVE_TYPE Type + _Out_ PHANDLE MemoryReserveHandle, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ MEMORY_RESERVE_TYPE Type ); #endif @@ -1209,12 +1283,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueueApcThreadEx( - __in HANDLE ThreadHandle, - __in_opt HANDLE UserApcReserveHandle, - __in PPS_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcArgument1, - __in_opt PVOID ApcArgument2, - __in_opt PVOID ApcArgument3 + _In_ HANDLE ThreadHandle, + _In_opt_ HANDLE UserApcReserveHandle, + _In_ PPS_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcArgument1, + _In_opt_ PVOID ApcArgument2, + _In_opt_ PVOID ApcArgument3 ); #endif @@ -1230,72 +1304,72 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateJobObject( - __out PHANDLE JobHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE JobHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenJobObject( - __out PHANDLE JobHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE JobHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI NtAssignProcessToJobObject( - __in HANDLE JobHandle, - __in HANDLE ProcessHandle + _In_ HANDLE JobHandle, + _In_ HANDLE ProcessHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtTerminateJobObject( - __in HANDLE JobHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE JobHandle, + _In_ NTSTATUS ExitStatus ); NTSYSCALLAPI NTSTATUS NTAPI NtIsProcessInJob( - __in HANDLE ProcessHandle, - __in_opt HANDLE JobHandle + _In_ HANDLE ProcessHandle, + _In_opt_ HANDLE JobHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationJobObject( - __in_opt HANDLE JobHandle, - __in JOBOBJECTINFOCLASS JobObjectInformationClass, - __out_bcount(JobObjectInformationLength) PVOID JobObjectInformation, - __in ULONG JobObjectInformationLength, - __out_opt PULONG ReturnLength + _In_opt_ HANDLE JobHandle, + _In_ JOBOBJECTINFOCLASS JobObjectInformationClass, + _Out_writes_bytes_(JobObjectInformationLength) PVOID JobObjectInformation, + _In_ ULONG JobObjectInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationJobObject( - __in HANDLE JobHandle, - __in JOBOBJECTINFOCLASS JobObjectInformationClass, - __in_bcount(JobObjectInformationLength) PVOID JobObjectInformation, - __in ULONG JobObjectInformationLength + _In_ HANDLE JobHandle, + _In_ JOBOBJECTINFOCLASS JobObjectInformationClass, + _In_reads_bytes_(JobObjectInformationLength) PVOID JobObjectInformation, + _In_ ULONG JobObjectInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI NtCreateJobSet( - __in ULONG NumJob, - __in_ecount(NumJob) PJOB_SET_ARRAY UserJobSet, - __in ULONG Flags + _In_ ULONG NumJob, + _In_reads_(NumJob) PJOB_SET_ARRAY UserJobSet, + _In_ ULONG Flags ); #endif diff --git a/2.x/trunk/phlib/include/ntregapi.h b/2.x/trunk/phlib/include/ntregapi.h index 682de309f..63e8f8c12 100644 --- a/2.x/trunk/phlib/include/ntregapi.h +++ b/2.x/trunk/phlib/include/ntregapi.h @@ -21,6 +21,7 @@ typedef enum _KEY_INFORMATION_CLASS KeyFlagsInformation, KeyVirtualizationInformation, KeyHandleTagsInformation, + KeyTrustInformation, MaxKeyInfoClass } KEY_INFORMATION_CLASS; @@ -93,6 +94,13 @@ typedef struct _KEY_VIRTUALIZATION_INFORMATION ULONG Reserved : 27; } KEY_VIRTUALIZATION_INFORMATION, *PKEY_VIRTUALIZATION_INFORMATION; +// private +typedef struct _KEY_TRUST_INFORMATION +{ + ULONG TrustedKey : 1; + ULONG Reserved : 31; +} KEY_TRUST_INFORMATION, *PKEY_TRUST_INFORMATION; + typedef enum _KEY_SET_INFORMATION_CLASS { KeyWriteTimeInformation, @@ -218,13 +226,13 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __reserved ULONG TitleIndex, - __in_opt PUNICODE_STRING Class, - __in ULONG CreateOptions, - __out_opt PULONG Disposition + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Reserved_ ULONG TitleIndex, + _In_opt_ PUNICODE_STRING Class, + _In_ ULONG CreateOptions, + _Out_opt_ PULONG Disposition ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -232,14 +240,14 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateKeyTransacted( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __reserved ULONG TitleIndex, - __in_opt PUNICODE_STRING Class, - __in ULONG CreateOptions, - __in HANDLE TransactionHandle, - __out_opt PULONG Disposition + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Reserved_ ULONG TitleIndex, + _In_opt_ PUNICODE_STRING Class, + _In_ ULONG CreateOptions, + _In_ HANDLE TransactionHandle, + _Out_opt_ PULONG Disposition ); #endif @@ -247,9 +255,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -257,10 +265,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenKeyTransacted( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE TransactionHandle + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE TransactionHandle ); #endif @@ -269,10 +277,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenKeyEx( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG OpenOptions + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG OpenOptions ); #endif @@ -281,11 +289,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenKeyTransactedEx( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG OpenOptions, - __in HANDLE TransactionHandle + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG OpenOptions, + _In_ HANDLE TransactionHandle ); #endif @@ -293,294 +301,294 @@ NTSYSCALLAPI NTSTATUS NTAPI NtDeleteKey( - __in HANDLE KeyHandle + _In_ HANDLE KeyHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtRenameKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING NewName + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING NewName ); NTSYSCALLAPI NTSTATUS NTAPI NtDeleteValueKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING ValueName + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING ValueName ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryKey( - __in HANDLE KeyHandle, - __in KEY_INFORMATION_CLASS KeyInformationClass, - __out_bcount_opt(Length) PVOID KeyInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ KEY_INFORMATION_CLASS KeyInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationKey( - __in HANDLE KeyHandle, - __in KEY_SET_INFORMATION_CLASS KeySetInformationClass, - __in_bcount(KeySetInformationLength) PVOID KeySetInformation, - __in ULONG KeySetInformationLength + _In_ HANDLE KeyHandle, + _In_ KEY_SET_INFORMATION_CLASS KeySetInformationClass, + _In_reads_bytes_(KeySetInformationLength) PVOID KeySetInformation, + _In_ ULONG KeySetInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryValueKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING ValueName, - __in KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, - __out_bcount_opt(Length) PVOID KeyValueInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING ValueName, + _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyValueInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetValueKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING ValueName, - __in_opt ULONG TitleIndex, - __in ULONG Type, - __in_bcount_opt(DataSize) PVOID Data, - __in ULONG DataSize + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING ValueName, + _In_opt_ ULONG TitleIndex, + _In_ ULONG Type, + _In_reads_bytes_opt_(DataSize) PVOID Data, + _In_ ULONG DataSize ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryMultipleValueKey( - __in HANDLE KeyHandle, - __inout_ecount(EntryCount) PKEY_VALUE_ENTRY ValueEntries, - __in ULONG EntryCount, - __out_bcount(*BufferLength) PVOID ValueBuffer, - __inout PULONG BufferLength, - __out_opt PULONG RequiredBufferLength + _In_ HANDLE KeyHandle, + _Inout_updates_(EntryCount) PKEY_VALUE_ENTRY ValueEntries, + _In_ ULONG EntryCount, + _Out_writes_bytes_(*BufferLength) PVOID ValueBuffer, + _Inout_ PULONG BufferLength, + _Out_opt_ PULONG RequiredBufferLength ); NTSYSCALLAPI NTSTATUS NTAPI NtEnumerateKey( - __in HANDLE KeyHandle, - __in ULONG Index, - __in KEY_INFORMATION_CLASS KeyInformationClass, - __out_bcount_opt(Length) PVOID KeyInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ ULONG Index, + _In_ KEY_INFORMATION_CLASS KeyInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI NtEnumerateValueKey( - __in HANDLE KeyHandle, - __in ULONG Index, - __in KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, - __out_bcount_opt(Length) PVOID KeyValueInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ ULONG Index, + _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyValueInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI NtFlushKey( - __in HANDLE KeyHandle + _In_ HANDLE KeyHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtCompactKeys( - __in ULONG Count, - __in_ecount(Count) HANDLE KeyArray[] + _In_ ULONG Count, + _In_reads_(Count) HANDLE KeyArray[] ); NTSYSCALLAPI NTSTATUS NTAPI NtCompressKey( - __in HANDLE Key + _In_ HANDLE Key ); NTSYSCALLAPI NTSTATUS NTAPI NtLoadKey( - __in POBJECT_ATTRIBUTES TargetKey, - __in POBJECT_ATTRIBUTES SourceFile + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ POBJECT_ATTRIBUTES SourceFile ); NTSYSCALLAPI NTSTATUS NTAPI NtLoadKey2( - __in POBJECT_ATTRIBUTES TargetKey, - __in POBJECT_ATTRIBUTES SourceFile, - __in ULONG Flags + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ POBJECT_ATTRIBUTES SourceFile, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI NtLoadKeyEx( - __in POBJECT_ATTRIBUTES TargetKey, - __in POBJECT_ATTRIBUTES SourceFile, - __in ULONG Flags, - __in_opt HANDLE TrustClassKey + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ POBJECT_ATTRIBUTES SourceFile, + _In_ ULONG Flags, + _In_opt_ HANDLE TrustClassKey ); NTSYSCALLAPI NTSTATUS NTAPI NtReplaceKey( - __in POBJECT_ATTRIBUTES NewFile, - __in HANDLE TargetHandle, - __in POBJECT_ATTRIBUTES OldFile + _In_ POBJECT_ATTRIBUTES NewFile, + _In_ HANDLE TargetHandle, + _In_ POBJECT_ATTRIBUTES OldFile ); NTSYSCALLAPI NTSTATUS NTAPI NtSaveKey( - __in HANDLE KeyHandle, - __in HANDLE FileHandle + _In_ HANDLE KeyHandle, + _In_ HANDLE FileHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtSaveKeyEx( - __in HANDLE KeyHandle, - __in HANDLE FileHandle, - __in ULONG Format + _In_ HANDLE KeyHandle, + _In_ HANDLE FileHandle, + _In_ ULONG Format ); NTSYSCALLAPI NTSTATUS NTAPI NtSaveMergedKeys( - __in HANDLE HighPrecedenceKeyHandle, - __in HANDLE LowPrecedenceKeyHandle, - __in HANDLE FileHandle + _In_ HANDLE HighPrecedenceKeyHandle, + _In_ HANDLE LowPrecedenceKeyHandle, + _In_ HANDLE FileHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtRestoreKey( - __in HANDLE KeyHandle, - __in HANDLE FileHandle, - __in ULONG Flags + _In_ HANDLE KeyHandle, + _In_ HANDLE FileHandle, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI NtUnloadKey( - __in POBJECT_ATTRIBUTES TargetKey + _In_ POBJECT_ATTRIBUTES TargetKey ); NTSYSCALLAPI NTSTATUS NTAPI NtUnloadKey2( - __in POBJECT_ATTRIBUTES TargetKey, - __in ULONG Flags + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI NtUnloadKeyEx( - __in POBJECT_ATTRIBUTES TargetKey, - __in_opt HANDLE Event + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_opt_ HANDLE Event ); NTSYSCALLAPI NTSTATUS NTAPI NtNotifyChangeKey( - __in HANDLE KeyHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG CompletionFilter, - __in BOOLEAN WatchTree, - __out_bcount_opt(BufferSize) PVOID Buffer, - __in ULONG BufferSize, - __in BOOLEAN Asynchronous + _In_ HANDLE KeyHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG CompletionFilter, + _In_ BOOLEAN WatchTree, + _Out_writes_bytes_opt_(BufferSize) PVOID Buffer, + _In_ ULONG BufferSize, + _In_ BOOLEAN Asynchronous ); NTSYSCALLAPI NTSTATUS NTAPI NtNotifyChangeMultipleKeys( - __in HANDLE MasterKeyHandle, - __in_opt ULONG Count, - __in_ecount_opt(Count) OBJECT_ATTRIBUTES SlaveObjects[], - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG CompletionFilter, - __in BOOLEAN WatchTree, - __out_bcount_opt(BufferSize) PVOID Buffer, - __in ULONG BufferSize, - __in BOOLEAN Asynchronous + _In_ HANDLE MasterKeyHandle, + _In_opt_ ULONG Count, + _In_reads_opt_(Count) OBJECT_ATTRIBUTES SlaveObjects[], + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG CompletionFilter, + _In_ BOOLEAN WatchTree, + _Out_writes_bytes_opt_(BufferSize) PVOID Buffer, + _In_ ULONG BufferSize, + _In_ BOOLEAN Asynchronous ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryOpenSubKeys( - __in POBJECT_ATTRIBUTES TargetKey, - __out PULONG HandleCount + _In_ POBJECT_ATTRIBUTES TargetKey, + _Out_ PULONG HandleCount ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryOpenSubKeysEx( - __in POBJECT_ATTRIBUTES TargetKey, - __in ULONG BufferLength, - __out_bcount(BufferLength) PVOID Buffer, - __out PULONG RequiredSize + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ ULONG BufferLength, + _Out_writes_bytes_(BufferLength) PVOID Buffer, + _Out_ PULONG RequiredSize ); NTSYSCALLAPI NTSTATUS NTAPI NtInitializeRegistry( - __in USHORT BootCondition + _In_ USHORT BootCondition ); NTSYSCALLAPI NTSTATUS NTAPI NtLockRegistryKey( - __in HANDLE KeyHandle + _In_ HANDLE KeyHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtLockProductActivationKeys( - __inout_opt ULONG *pPrivateVer, - __out_opt ULONG *pSafeMode + _Inout_opt_ ULONG *pPrivateVer, + _Out_opt_ ULONG *pSafeMode ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -589,7 +597,7 @@ NTSYSCALLAPI NTSTATUS NTAPI NtFreezeRegistry( - __in ULONG TimeOutInSeconds + _In_ ULONG TimeOutInSeconds ); #endif diff --git a/2.x/trunk/phlib/include/ntrtl.h b/2.x/trunk/phlib/include/ntrtl.h index a0b061efd..bf8168912 100644 --- a/2.x/trunk/phlib/include/ntrtl.h +++ b/2.x/trunk/phlib/include/ntrtl.h @@ -4,21 +4,21 @@ // Linked lists FORCEINLINE VOID InitializeListHead( - __out PLIST_ENTRY ListHead + _Out_ PLIST_ENTRY ListHead ) { ListHead->Flink = ListHead->Blink = ListHead; } -__checkReturn FORCEINLINE BOOLEAN IsListEmpty( - __in PLIST_ENTRY ListHead +_Check_return_ FORCEINLINE BOOLEAN IsListEmpty( + _In_ PLIST_ENTRY ListHead ) { return ListHead->Flink == ListHead; } FORCEINLINE BOOLEAN RemoveEntryList( - __in PLIST_ENTRY Entry + _In_ PLIST_ENTRY Entry ) { PLIST_ENTRY Blink; @@ -33,7 +33,7 @@ FORCEINLINE BOOLEAN RemoveEntryList( } FORCEINLINE PLIST_ENTRY RemoveHeadList( - __inout PLIST_ENTRY ListHead + _Inout_ PLIST_ENTRY ListHead ) { PLIST_ENTRY Flink; @@ -48,7 +48,7 @@ FORCEINLINE PLIST_ENTRY RemoveHeadList( } FORCEINLINE PLIST_ENTRY RemoveTailList( - __inout PLIST_ENTRY ListHead + _Inout_ PLIST_ENTRY ListHead ) { PLIST_ENTRY Blink; @@ -63,8 +63,8 @@ FORCEINLINE PLIST_ENTRY RemoveTailList( } FORCEINLINE VOID InsertTailList( - __inout PLIST_ENTRY ListHead, - __inout PLIST_ENTRY Entry + _Inout_ PLIST_ENTRY ListHead, + _Inout_ PLIST_ENTRY Entry ) { PLIST_ENTRY Blink; @@ -77,8 +77,8 @@ FORCEINLINE VOID InsertTailList( } FORCEINLINE VOID InsertHeadList( - __inout PLIST_ENTRY ListHead, - __inout PLIST_ENTRY Entry + _Inout_ PLIST_ENTRY ListHead, + _Inout_ PLIST_ENTRY Entry ) { PLIST_ENTRY Flink; @@ -91,8 +91,8 @@ FORCEINLINE VOID InsertHeadList( } FORCEINLINE VOID AppendTailList( - __inout PLIST_ENTRY ListHead, - __inout PLIST_ENTRY ListToAppend + _Inout_ PLIST_ENTRY ListHead, + _Inout_ PLIST_ENTRY ListToAppend ) { PLIST_ENTRY ListEnd = ListHead->Blink; @@ -104,7 +104,7 @@ FORCEINLINE VOID AppendTailList( } FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList( - __inout PSINGLE_LIST_ENTRY ListHead + _Inout_ PSINGLE_LIST_ENTRY ListHead ) { PSINGLE_LIST_ENTRY FirstEntry; @@ -118,8 +118,8 @@ FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList( } FORCEINLINE VOID PushEntryList( - __inout PSINGLE_LIST_ENTRY ListHead, - __inout PSINGLE_LIST_ENTRY Entry + _Inout_ PSINGLE_LIST_ENTRY ListHead, + _Inout_ PSINGLE_LIST_ENTRY Entry ) { Entry->Next = ListHead->Next; @@ -144,25 +144,25 @@ typedef enum _RTL_GENERIC_COMPARE_RESULTS } RTL_GENERIC_COMPARE_RESULTS; typedef RTL_GENERIC_COMPARE_RESULTS (NTAPI *PRTL_AVL_COMPARE_ROUTINE)( - __in struct _RTL_AVL_TABLE *Table, - __in PVOID FirstStruct, - __in PVOID SecondStruct + _In_ struct _RTL_AVL_TABLE *Table, + _In_ PVOID FirstStruct, + _In_ PVOID SecondStruct ); typedef PVOID (NTAPI *PRTL_AVL_ALLOCATE_ROUTINE)( - __in struct _RTL_AVL_TABLE *Table, - __in CLONG ByteSize + _In_ struct _RTL_AVL_TABLE *Table, + _In_ CLONG ByteSize ); typedef VOID (NTAPI *PRTL_AVL_FREE_ROUTINE)( - __in struct _RTL_AVL_TABLE *Table, - __in __post_invalid PVOID Buffer + _In_ struct _RTL_AVL_TABLE *Table, + _In_ _Post_invalid_ PVOID Buffer ); typedef NTSTATUS (NTAPI *PRTL_AVL_MATCH_FUNCTION)( - __in struct _RTL_AVL_TABLE *Table, - __in PVOID UserData, - __in PVOID MatchData + _In_ struct _RTL_AVL_TABLE *Table, + _In_ PVOID UserData, + _In_ PVOID MatchData ); typedef struct _RTL_BALANCED_LINKS @@ -193,126 +193,126 @@ NTSYSAPI VOID NTAPI RtlInitializeGenericTableAvl( - __out PRTL_AVL_TABLE Table, - __in PRTL_AVL_COMPARE_ROUTINE CompareRoutine, - __in PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, - __in PRTL_AVL_FREE_ROUTINE FreeRoutine, - __in_opt PVOID TableContext + _Out_ PRTL_AVL_TABLE Table, + _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine, + _In_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, + _In_ PRTL_AVL_FREE_ROUTINE FreeRoutine, + _In_opt_ PVOID TableContext ); NTSYSAPI PVOID NTAPI RtlInsertElementGenericTableAvl( - __in PRTL_AVL_TABLE Table, - __in_bcount(BufferSize) PVOID Buffer, - __in CLONG BufferSize, - __out_opt PBOOLEAN NewElement + _In_ PRTL_AVL_TABLE Table, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ CLONG BufferSize, + _Out_opt_ PBOOLEAN NewElement ); NTSYSAPI PVOID NTAPI RtlInsertElementGenericTableFullAvl( - __in PRTL_AVL_TABLE Table, - __in_bcount(BufferSize) PVOID Buffer, - __in CLONG BufferSize, - __out_opt PBOOLEAN NewElement, - __in PVOID NodeOrParent, - __in TABLE_SEARCH_RESULT SearchResult + _In_ PRTL_AVL_TABLE Table, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ CLONG BufferSize, + _Out_opt_ PBOOLEAN NewElement, + _In_ PVOID NodeOrParent, + _In_ TABLE_SEARCH_RESULT SearchResult ); NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTableAvl( - __in PRTL_AVL_TABLE Table, - __in PVOID Buffer + _In_ PRTL_AVL_TABLE Table, + _In_ PVOID Buffer ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTableAvl( - __in PRTL_AVL_TABLE Table, - __in PVOID Buffer + _In_ PRTL_AVL_TABLE Table, + _In_ PVOID Buffer ); NTSYSAPI PVOID NTAPI RtlLookupElementGenericTableFullAvl( - __in PRTL_AVL_TABLE Table, - __in PVOID Buffer, - __out PVOID *NodeOrParent, - __out TABLE_SEARCH_RESULT *SearchResult + _In_ PRTL_AVL_TABLE Table, + _In_ PVOID Buffer, + _Out_ PVOID *NodeOrParent, + _Out_ TABLE_SEARCH_RESULT *SearchResult ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTableAvl( - __in PRTL_AVL_TABLE Table, - __in BOOLEAN Restart + _In_ PRTL_AVL_TABLE Table, + _In_ BOOLEAN Restart ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTableWithoutSplayingAvl( - __in PRTL_AVL_TABLE Table, - __inout PVOID *RestartKey + _In_ PRTL_AVL_TABLE Table, + _Inout_ PVOID *RestartKey ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlLookupFirstMatchingElementGenericTableAvl( - __in PRTL_AVL_TABLE Table, - __in PVOID Buffer, - __out PVOID *RestartKey + _In_ PRTL_AVL_TABLE Table, + _In_ PVOID Buffer, + _Out_ PVOID *RestartKey ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTableLikeADirectory( - __in PRTL_AVL_TABLE Table, - __in_opt PRTL_AVL_MATCH_FUNCTION MatchFunction, - __in_opt PVOID MatchData, - __in ULONG NextFlag, - __inout PVOID *RestartKey, - __inout PULONG DeleteCount, - __in PVOID Buffer + _In_ PRTL_AVL_TABLE Table, + _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction, + _In_opt_ PVOID MatchData, + _In_ ULONG NextFlag, + _Inout_ PVOID *RestartKey, + _Inout_ PULONG DeleteCount, + _In_ PVOID Buffer ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlGetElementGenericTableAvl( - __in PRTL_AVL_TABLE Table, - __in ULONG I + _In_ PRTL_AVL_TABLE Table, + _In_ ULONG I ); NTSYSAPI ULONG NTAPI RtlNumberGenericTableElementsAvl( - __in PRTL_AVL_TABLE Table + _In_ PRTL_AVL_TABLE Table ); -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlIsGenericTableEmptyAvl( - __in PRTL_AVL_TABLE Table + _In_ PRTL_AVL_TABLE Table ); typedef struct _RTL_SPLAY_LINKS @@ -362,72 +362,72 @@ NTSYSAPI PRTL_SPLAY_LINKS NTAPI RtlSplay( - __inout PRTL_SPLAY_LINKS Links + _Inout_ PRTL_SPLAY_LINKS Links ); NTSYSAPI PRTL_SPLAY_LINKS NTAPI RtlDelete( - __in PRTL_SPLAY_LINKS Links + _In_ PRTL_SPLAY_LINKS Links ); NTSYSAPI VOID NTAPI RtlDeleteNoSplay( - __in PRTL_SPLAY_LINKS Links, - __inout PRTL_SPLAY_LINKS *Root + _In_ PRTL_SPLAY_LINKS Links, + _Inout_ PRTL_SPLAY_LINKS *Root ); -__checkReturn +_Check_return_ NTSYSAPI PRTL_SPLAY_LINKS NTAPI RtlSubtreeSuccessor( - __in PRTL_SPLAY_LINKS Links + _In_ PRTL_SPLAY_LINKS Links ); -__checkReturn +_Check_return_ NTSYSAPI PRTL_SPLAY_LINKS NTAPI RtlSubtreePredecessor( - __in PRTL_SPLAY_LINKS Links + _In_ PRTL_SPLAY_LINKS Links ); -__checkReturn +_Check_return_ NTSYSAPI PRTL_SPLAY_LINKS NTAPI RtlRealSuccessor( - __in PRTL_SPLAY_LINKS Links + _In_ PRTL_SPLAY_LINKS Links ); -__checkReturn +_Check_return_ NTSYSAPI PRTL_SPLAY_LINKS NTAPI RtlRealPredecessor( - __in PRTL_SPLAY_LINKS Links + _In_ PRTL_SPLAY_LINKS Links ); struct _RTL_GENERIC_TABLE; typedef RTL_GENERIC_COMPARE_RESULTS (NTAPI *PRTL_GENERIC_COMPARE_ROUTINE)( - __in struct _RTL_GENERIC_TABLE *Table, - __in PVOID FirstStruct, - __in PVOID SecondStruct + _In_ struct _RTL_GENERIC_TABLE *Table, + _In_ PVOID FirstStruct, + _In_ PVOID SecondStruct ); typedef PVOID (NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE)( - __in struct _RTL_GENERIC_TABLE *Table, - __in CLONG ByteSize + _In_ struct _RTL_GENERIC_TABLE *Table, + _In_ CLONG ByteSize ); typedef VOID (NTAPI *PRTL_GENERIC_FREE_ROUTINE)( - __in struct _RTL_GENERIC_TABLE *Table, - __in __post_invalid PVOID Buffer + _In_ struct _RTL_GENERIC_TABLE *Table, + _In_ _Post_invalid_ PVOID Buffer ); typedef struct _RTL_GENERIC_TABLE @@ -447,102 +447,102 @@ NTSYSAPI VOID NTAPI RtlInitializeGenericTable( - __out PRTL_GENERIC_TABLE Table, - __in PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, - __in PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, - __in PRTL_GENERIC_FREE_ROUTINE FreeRoutine, - __in_opt PVOID TableContext + _Out_ PRTL_GENERIC_TABLE Table, + _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, + _In_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, + _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine, + _In_opt_ PVOID TableContext ); NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable( - __in PRTL_GENERIC_TABLE Table, - __in_bcount(BufferSize) PVOID Buffer, - __in CLONG BufferSize, - __out_opt PBOOLEAN NewElement + _In_ PRTL_GENERIC_TABLE Table, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ CLONG BufferSize, + _Out_opt_ PBOOLEAN NewElement ); NTSYSAPI PVOID NTAPI RtlInsertElementGenericTableFull( - __in PRTL_GENERIC_TABLE Table, - __in_bcount(BufferSize) PVOID Buffer, - __in CLONG BufferSize, - __out_opt PBOOLEAN NewElement, - __in PVOID NodeOrParent, - __in TABLE_SEARCH_RESULT SearchResult + _In_ PRTL_GENERIC_TABLE Table, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ CLONG BufferSize, + _Out_opt_ PBOOLEAN NewElement, + _In_ PVOID NodeOrParent, + _In_ TABLE_SEARCH_RESULT SearchResult ); NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable( - __in PRTL_GENERIC_TABLE Table, - __in PVOID Buffer + _In_ PRTL_GENERIC_TABLE Table, + _In_ PVOID Buffer ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable( - __in PRTL_GENERIC_TABLE Table, - __in PVOID Buffer + _In_ PRTL_GENERIC_TABLE Table, + _In_ PVOID Buffer ); NTSYSAPI PVOID NTAPI RtlLookupElementGenericTableFull( - __in PRTL_GENERIC_TABLE Table, - __in PVOID Buffer, - __out PVOID *NodeOrParent, - __out TABLE_SEARCH_RESULT *SearchResult + _In_ PRTL_GENERIC_TABLE Table, + _In_ PVOID Buffer, + _Out_ PVOID *NodeOrParent, + _Out_ TABLE_SEARCH_RESULT *SearchResult ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTable( - __in PRTL_GENERIC_TABLE Table, - __in BOOLEAN Restart + _In_ PRTL_GENERIC_TABLE Table, + _In_ BOOLEAN Restart ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTableWithoutSplaying( - __in PRTL_GENERIC_TABLE Table, - __inout PVOID *RestartKey + _In_ PRTL_GENERIC_TABLE Table, + _Inout_ PVOID *RestartKey ); -__checkReturn +_Check_return_ NTSYSAPI PVOID NTAPI RtlGetElementGenericTable( - __in PRTL_GENERIC_TABLE Table, - __in ULONG I + _In_ PRTL_GENERIC_TABLE Table, + _In_ ULONG I ); NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements( - __in PRTL_GENERIC_TABLE Table + _In_ PRTL_GENERIC_TABLE Table ); -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlIsGenericTableEmpty( - __in PRTL_GENERIC_TABLE Table + _In_ PRTL_GENERIC_TABLE Table ); // RB trees @@ -560,10 +560,10 @@ NTSYSAPI VOID NTAPI RtlRbInsertNodeEx( - __in PRTL_RB_TREE Tree, - __in_opt PRTL_BALANCED_NODE Parent, - __in BOOLEAN Right, - __out PRTL_BALANCED_NODE Node + _In_ PRTL_RB_TREE Tree, + _In_opt_ PRTL_BALANCED_NODE Parent, + _In_ BOOLEAN Right, + _Out_ PRTL_BALANCED_NODE Node ); // rev @@ -571,8 +571,8 @@ NTSYSAPI VOID NTAPI RtlRbRemoveNode( - __in PRTL_RB_TREE Tree, - __in PRTL_BALANCED_NODE Node + _In_ PRTL_RB_TREE Tree, + _In_ PRTL_BALANCED_NODE Node ); #endif @@ -631,7 +631,7 @@ typedef struct _RTL_DYNAMIC_HASH_TABLE FORCEINLINE VOID RtlInitHashTableContext( - __inout PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context + _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context ) { Context->ChainHead = NULL; @@ -641,8 +641,8 @@ RtlInitHashTableContext( FORCEINLINE VOID RtlInitHashTableContextFromEnumerator( - __inout PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, - __in PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator + _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, + _In_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator ) { Context->ChainHead = Enumerator->ChainHead; @@ -652,7 +652,7 @@ RtlInitHashTableContextFromEnumerator( FORCEINLINE VOID RtlReleaseHashTableContext( - __inout PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context + _Inout_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context ) { UNREFERENCED_PARAMETER(Context); @@ -662,7 +662,7 @@ RtlReleaseHashTableContext( FORCEINLINE ULONG RtlTotalBucketsHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ) { return HashTable->TableSize; @@ -671,7 +671,7 @@ RtlTotalBucketsHashTable( FORCEINLINE ULONG RtlNonEmptyBucketsHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ) { return HashTable->NonEmptyBuckets; @@ -680,7 +680,7 @@ RtlNonEmptyBucketsHashTable( FORCEINLINE ULONG RtlEmptyBucketsHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ) { return HashTable->TableSize - HashTable->NonEmptyBuckets; @@ -689,7 +689,7 @@ RtlEmptyBucketsHashTable( FORCEINLINE ULONG RtlTotalEntriesHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ) { return HashTable->NumEntries; @@ -698,129 +698,129 @@ RtlTotalEntriesHashTable( FORCEINLINE ULONG RtlActiveEnumeratorsHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ) { return HashTable->NumEnumerators; } -__checkReturn +_Must_inspect_result_ NTSYSAPI BOOLEAN NTAPI RtlCreateHashTable( - __deref_inout_opt PRTL_DYNAMIC_HASH_TABLE *HashTable, - __in ULONG Shift, - __in __reserved ULONG Flags + _Inout_ _When_(*HashTable == NULL, __drv_allocatesMem(Mem)) PRTL_DYNAMIC_HASH_TABLE *HashTable, + _In_ ULONG Shift, + _In_ _Reserved_ ULONG Flags ); NTSYSAPI VOID NTAPI RtlDeleteHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ); NTSYSAPI BOOLEAN NTAPI RtlInsertEntryHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __in PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, - __in ULONG_PTR Signature, - __inout_opt PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + _In_ ULONG_PTR Signature, + _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context ); NTSYSAPI BOOLEAN NTAPI RtlRemoveEntryHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __in PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, - __inout_opt PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _In_ PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + _Inout_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context ); -__checkReturn +_Must_inspect_result_ NTSYSAPI PRTL_DYNAMIC_HASH_TABLE_ENTRY NTAPI RtlLookupEntryHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __in ULONG_PTR Signature, - __out_opt PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _In_ ULONG_PTR Signature, + _Out_opt_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context ); -__checkReturn +_Must_inspect_result_ NTSYSAPI PRTL_DYNAMIC_HASH_TABLE_ENTRY NTAPI RtlGetNextEntryHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __in PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _In_ PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context ); NTSYSAPI BOOLEAN NTAPI RtlInitEnumerationHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __out PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator ); -__checkReturn +_Must_inspect_result_ NTSYSAPI PRTL_DYNAMIC_HASH_TABLE_ENTRY NTAPI RtlEnumerateEntryHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __inout PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator ); NTSYSAPI VOID NTAPI RtlEndEnumerationHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __inout PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator ); NTSYSAPI BOOLEAN NTAPI RtlInitWeakEnumerationHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __out PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _Out_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator ); -__checkReturn +_Must_inspect_result_ NTSYSAPI PRTL_DYNAMIC_HASH_TABLE_ENTRY NTAPI RtlWeaklyEnumerateEntryHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __inout PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator ); NTSYSAPI VOID NTAPI RtlEndWeakEnumerationHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable, - __inout PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable, + _Inout_ PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator ); NTSYSAPI BOOLEAN NTAPI RtlExpandHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ); NTSYSAPI BOOLEAN NTAPI RtlContractHashTable( - __in PRTL_DYNAMIC_HASH_TABLE HashTable + _In_ PRTL_DYNAMIC_HASH_TABLE HashTable ); #endif @@ -833,72 +833,72 @@ NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection( - __out PRTL_CRITICAL_SECTION CriticalSection + _Out_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSectionAndSpinCount( - __inout PRTL_CRITICAL_SECTION CriticalSection, - __in ULONG SpinCount + _Inout_ PRTL_CRITICAL_SECTION CriticalSection, + _In_ ULONG SpinCount ); NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection( - __inout PRTL_CRITICAL_SECTION CriticalSection + _Inout_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection( - __inout PRTL_CRITICAL_SECTION CriticalSection + _Inout_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection( - __inout PRTL_CRITICAL_SECTION CriticalSection + _Inout_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI LOGICAL NTAPI RtlTryEnterCriticalSection( - __inout PRTL_CRITICAL_SECTION CriticalSection + _Inout_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI LOGICAL NTAPI RtlIsCriticalSectionLocked( - __in PRTL_CRITICAL_SECTION CriticalSection + _In_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI LOGICAL NTAPI RtlIsCriticalSectionLockedByThread( - __in PRTL_CRITICAL_SECTION CriticalSection + _In_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI ULONG NTAPI RtlGetCriticalSectionRecursionCount( - __in PRTL_CRITICAL_SECTION CriticalSection + _In_ PRTL_CRITICAL_SECTION CriticalSection ); NTSYSAPI ULONG NTAPI RtlSetCriticalSectionSpinCount( - __inout PRTL_CRITICAL_SECTION CriticalSection, - __in ULONG SpinCount + _Inout_ PRTL_CRITICAL_SECTION CriticalSection, + _In_ ULONG SpinCount ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -907,7 +907,7 @@ NTSYSAPI HANDLE NTAPI RtlQueryCriticalSectionOwner( - __in HANDLE EventHandle + _In_ HANDLE EventHandle ); #endif @@ -915,7 +915,7 @@ NTSYSAPI VOID NTAPI RtlCheckForOrphanedCriticalSections( - __in HANDLE hThread + _In_ HANDLE hThread ); // Resources @@ -943,51 +943,51 @@ NTSYSAPI VOID NTAPI RtlInitializeResource( - __out PRTL_RESOURCE Resource + _Out_ PRTL_RESOURCE Resource ); NTSYSAPI VOID NTAPI RtlDeleteResource( - __inout PRTL_RESOURCE Resource + _Inout_ PRTL_RESOURCE Resource ); NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared( - __inout PRTL_RESOURCE Resource, - __in BOOLEAN Wait + _Inout_ PRTL_RESOURCE Resource, + _In_ BOOLEAN Wait ); NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive( - __inout PRTL_RESOURCE Resource, - __in BOOLEAN Wait + _Inout_ PRTL_RESOURCE Resource, + _In_ BOOLEAN Wait ); NTSYSAPI VOID NTAPI RtlReleaseResource( - __inout PRTL_RESOURCE Resource + _Inout_ PRTL_RESOURCE Resource ); NTSYSAPI VOID NTAPI RtlConvertSharedToExclusive( - __inout PRTL_RESOURCE Resource + _Inout_ PRTL_RESOURCE Resource ); NTSYSAPI VOID NTAPI RtlConvertExclusiveToShared( - __inout PRTL_RESOURCE Resource + _Inout_ PRTL_RESOURCE Resource ); // Slim reader-writer locks, condition variables, and barriers @@ -999,7 +999,7 @@ NTSYSAPI VOID NTAPI RtlInitializeSRWLock( - __out PRTL_SRWLOCK SRWLock + _Out_ PRTL_SRWLOCK SRWLock ); // winbase:AcquireSRWLockExclusive @@ -1007,7 +1007,7 @@ NTSYSAPI VOID NTAPI RtlAcquireSRWLockExclusive( - __inout PRTL_SRWLOCK SRWLock + _Inout_ PRTL_SRWLOCK SRWLock ); // winbase:AcquireSRWLockShared @@ -1015,7 +1015,7 @@ NTSYSAPI VOID NTAPI RtlAcquireSRWLockShared( - __inout PRTL_SRWLOCK SRWLock + _Inout_ PRTL_SRWLOCK SRWLock ); // winbase:ReleaseSRWLockExclusive @@ -1023,7 +1023,7 @@ NTSYSAPI VOID NTAPI RtlReleaseSRWLockExclusive( - __inout PRTL_SRWLOCK SRWLock + _Inout_ PRTL_SRWLOCK SRWLock ); // winbase:ReleaseSRWLockShared @@ -1031,7 +1031,7 @@ NTSYSAPI VOID NTAPI RtlReleaseSRWLockShared( - __inout PRTL_SRWLOCK SRWLock + _Inout_ PRTL_SRWLOCK SRWLock ); // winbase:TryAcquireSRWLockExclusive @@ -1039,7 +1039,7 @@ NTSYSAPI BOOLEAN NTAPI RtlTryAcquireSRWLockExclusive( - __inout PRTL_SRWLOCK SRWLock + _Inout_ PRTL_SRWLOCK SRWLock ); // winbase:TryAcquireSRWLockShared @@ -1047,7 +1047,7 @@ NTSYSAPI BOOLEAN NTAPI RtlTryAcquireSRWLockShared( - __inout PRTL_SRWLOCK SRWLock + _Inout_ PRTL_SRWLOCK SRWLock ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -1056,7 +1056,7 @@ NTSYSAPI VOID NTAPI RtlAcquireReleaseSRWLockExclusive( - __inout PRTL_SRWLOCK SRWLock + _Inout_ PRTL_SRWLOCK SRWLock ); #endif @@ -1069,7 +1069,7 @@ NTSYSAPI VOID NTAPI RtlInitializeConditionVariable( - __out PRTL_CONDITION_VARIABLE ConditionVariable + _Out_ PRTL_CONDITION_VARIABLE ConditionVariable ); // private @@ -1077,9 +1077,9 @@ NTSYSAPI NTSTATUS NTAPI RtlSleepConditionVariableCS( - __inout PRTL_CONDITION_VARIABLE ConditionVariable, - __inout PRTL_CRITICAL_SECTION CriticalSection, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable, + _Inout_ PRTL_CRITICAL_SECTION CriticalSection, + _In_opt_ PLARGE_INTEGER Timeout ); // private @@ -1087,10 +1087,10 @@ NTSYSAPI NTSTATUS NTAPI RtlSleepConditionVariableSRW( - __inout PRTL_CONDITION_VARIABLE ConditionVariable, - __inout PRTL_SRWLOCK SRWLock, - __in_opt PLARGE_INTEGER Timeout, - __in ULONG Flags + _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable, + _Inout_ PRTL_SRWLOCK SRWLock, + _In_opt_ PLARGE_INTEGER Timeout, + _In_ ULONG Flags ); // winbase:WakeConditionVariable @@ -1098,7 +1098,7 @@ NTSYSAPI VOID NTAPI RtlWakeConditionVariable( - __inout PRTL_CONDITION_VARIABLE ConditionVariable + _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable ); // winbase:WakeAllConditionVariable @@ -1106,7 +1106,7 @@ NTSYSAPI VOID NTAPI RtlWakeAllConditionVariable( - __inout PRTL_CONDITION_VARIABLE ConditionVariable + _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable ); #endif @@ -1125,32 +1125,32 @@ NTSYSAPI NTSTATUS NTAPI RtlInitBarrier( - __out PRTL_BARRIER Barrier, - __in ULONG TotalThreads, - __in ULONG SpinCount + _Out_ PRTL_BARRIER Barrier, + _In_ ULONG TotalThreads, + _In_ ULONG SpinCount ); NTSYSAPI NTSTATUS NTAPI RtlDeleteBarrier( - __in PRTL_BARRIER Barrier + _In_ PRTL_BARRIER Barrier ); NTSYSAPI BOOLEAN NTAPI RtlBarrier( - __inout PRTL_BARRIER Barrier, - __in ULONG Flags + _Inout_ PRTL_BARRIER Barrier, + _In_ ULONG Flags ); NTSYSAPI BOOLEAN NTAPI RtlBarrierForDelete( - __inout PRTL_BARRIER Barrier, - __in ULONG Flags + _Inout_ PRTL_BARRIER Barrier, + _In_ ULONG Flags ); #endif @@ -1161,8 +1161,8 @@ RtlBarrierForDelete( #ifndef PHNT_NO_INLINE_INIT_STRING FORCEINLINE VOID RtlInitString( - __out PSTRING DestinationString, - __in_opt PSTR SourceString + _Out_ PSTRING DestinationString, + _In_opt_ PSTR SourceString ) { if (SourceString) @@ -1177,15 +1177,15 @@ NTSYSAPI VOID NTAPI RtlInitString( - __out PSTRING DestinationString, - __in_opt PSTR SourceString + _Out_ PSTRING DestinationString, + _In_opt_ PSTR SourceString ); #endif #ifndef PHNT_NO_INLINE_INIT_STRING FORCEINLINE VOID RtlInitAnsiString( - __out PANSI_STRING DestinationString, - __in_opt PSTR SourceString + _Out_ PANSI_STRING DestinationString, + _In_opt_ PSTR SourceString ) { if (SourceString) @@ -1200,8 +1200,8 @@ NTSYSAPI VOID NTAPI RtlInitAnsiString( - __out PANSI_STRING DestinationString, - __in_opt PSTR SourceString + _Out_ PANSI_STRING DestinationString, + _In_opt_ PSTR SourceString ); #endif @@ -1209,94 +1209,94 @@ NTSYSAPI NTSTATUS NTAPI RtlInitAnsiStringEx( - __out PANSI_STRING DestinationString, - __in_opt PSTR SourceString + _Out_ PANSI_STRING DestinationString, + _In_opt_ PSTR SourceString ); NTSYSAPI VOID NTAPI RtlFreeAnsiString( - __in PANSI_STRING AnsiString + _In_ PANSI_STRING AnsiString ); NTSYSAPI VOID NTAPI RtlFreeOemString( - __in POEM_STRING OemString + _In_ POEM_STRING OemString ); NTSYSAPI VOID NTAPI RtlCopyString( - __in PSTRING DestinationString, - __in_opt PSTRING SourceString + _In_ PSTRING DestinationString, + _In_opt_ PSTRING SourceString ); NTSYSAPI CHAR NTAPI RtlUpperChar( - __in CHAR Character + _In_ CHAR Character ); NTSYSAPI LONG NTAPI RtlCompareString( - __in PSTRING String1, - __in PSTRING String2, - __in BOOLEAN CaseInSensitive + _In_ PSTRING String1, + _In_ PSTRING String2, + _In_ BOOLEAN CaseInSensitive ); NTSYSAPI BOOLEAN NTAPI RtlEqualString( - __in PSTRING String1, - __in PSTRING String2, - __in BOOLEAN CaseInSensitive + _In_ PSTRING String1, + _In_ PSTRING String2, + _In_ BOOLEAN CaseInSensitive ); NTSYSAPI BOOLEAN NTAPI RtlPrefixString( - __in PSTRING String1, - __in PSTRING String2, - __in BOOLEAN CaseInSensitive + _In_ PSTRING String1, + _In_ PSTRING String2, + _In_ BOOLEAN CaseInSensitive ); NTSYSAPI NTSTATUS NTAPI RtlAppendStringToString( - __in PSTRING Destination, - __in PSTRING Source + _In_ PSTRING Destination, + _In_ PSTRING Source ); NTSYSAPI NTSTATUS NTAPI RtlAppendAsciizToString( - __in PSTRING Destination, - __in_opt PSTR Source + _In_ PSTRING Destination, + _In_opt_ PSTR Source ); NTSYSAPI VOID NTAPI RtlUpperString( - __in PSTRING DestinationString, - __in PSTRING SourceString + _In_ PSTRING DestinationString, + _In_ PSTRING SourceString ); #ifndef PHNT_NO_INLINE_INIT_STRING FORCEINLINE VOID RtlInitUnicodeString( - __out PUNICODE_STRING DestinationString, - __in_opt PWSTR SourceString + _Out_ PUNICODE_STRING DestinationString, + _In_opt_ PWSTR SourceString ) { if (SourceString) @@ -1311,8 +1311,8 @@ NTSYSAPI VOID NTAPI RtlInitUnicodeString( - __out PUNICODE_STRING DestinationString, - __in_opt PWSTR SourceString + _Out_ PUNICODE_STRING DestinationString, + _In_opt_ PWSTR SourceString ); #endif @@ -1320,31 +1320,31 @@ NTSYSAPI NTSTATUS NTAPI RtlInitUnicodeStringEx( - __out PUNICODE_STRING DestinationString, - __in_opt PWSTR SourceString + _Out_ PUNICODE_STRING DestinationString, + _In_opt_ PWSTR SourceString ); NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString( - __out PUNICODE_STRING DestinationString, - __in PWSTR SourceString + _Out_ PUNICODE_STRING DestinationString, + _In_ PWSTR SourceString ); NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz( - __out PUNICODE_STRING DestinationString, - __in PSTR SourceString + _Out_ PUNICODE_STRING DestinationString, + _In_ PSTR SourceString ); NTSYSAPI VOID NTAPI RtlFreeUnicodeString( - __in PUNICODE_STRING UnicodeString + _In_ PUNICODE_STRING UnicodeString ); #define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE (0x00000001) @@ -1354,40 +1354,40 @@ NTSYSAPI NTSTATUS NTAPI RtlDuplicateUnicodeString( - __in ULONG Flags, - __in PUNICODE_STRING StringIn, - __out PUNICODE_STRING StringOut + _In_ ULONG Flags, + _In_ PUNICODE_STRING StringIn, + _Out_ PUNICODE_STRING StringOut ); NTSYSAPI VOID NTAPI RtlCopyUnicodeString( - __in PUNICODE_STRING DestinationString, - __in PUNICODE_STRING SourceString + _In_ PUNICODE_STRING DestinationString, + _In_ PUNICODE_STRING SourceString ); NTSYSAPI WCHAR NTAPI RtlUpcaseUnicodeChar( - __in WCHAR SourceCharacter + _In_ WCHAR SourceCharacter ); NTSYSAPI WCHAR NTAPI RtlDowncaseUnicodeChar( - __in WCHAR SourceCharacter + _In_ WCHAR SourceCharacter ); NTSYSAPI LONG NTAPI RtlCompareUnicodeString( - __in PUNICODE_STRING String1, - __in PUNICODE_STRING String2, - __in BOOLEAN CaseInSensitive + _In_ PUNICODE_STRING String1, + _In_ PUNICODE_STRING String2, + _In_ BOOLEAN CaseInSensitive ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -1395,11 +1395,11 @@ NTSYSAPI LONG NTAPI RtlCompareUnicodeStrings( - __in_ecount(String1Length) PWCH String1, - __in SIZE_T String1Length, - __in_ecount(String2Length) PWCH String2, - __in SIZE_T String2Length, - __in BOOLEAN CaseInSensitive + _In_reads_(String1Length) PWCH String1, + _In_ SIZE_T String1Length, + _In_reads_(String2Length) PWCH String2, + _In_ SIZE_T String2Length, + _In_ BOOLEAN CaseInSensitive ); #endif @@ -1407,9 +1407,9 @@ NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString( - __in PUNICODE_STRING String1, - __in PUNICODE_STRING String2, - __in BOOLEAN CaseInSensitive + _In_ PUNICODE_STRING String1, + _In_ PUNICODE_STRING String2, + _In_ BOOLEAN CaseInSensitive ); #define HASH_STRING_ALGORITHM_DEFAULT 0 @@ -1420,27 +1420,27 @@ NTSYSAPI NTSTATUS NTAPI RtlHashUnicodeString( - __in PUNICODE_STRING String, - __in BOOLEAN CaseInSensitive, - __in ULONG HashAlgorithm, - __out PULONG HashValue + _In_ PUNICODE_STRING String, + _In_ BOOLEAN CaseInSensitive, + _In_ ULONG HashAlgorithm, + _Out_ PULONG HashValue ); NTSYSAPI NTSTATUS NTAPI RtlValidateUnicodeString( - __in ULONG Flags, - __in PUNICODE_STRING String + _In_ ULONG Flags, + _In_ PUNICODE_STRING String ); NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString( - __in PUNICODE_STRING String1, - __in PUNICODE_STRING String2, - __in BOOLEAN CaseInSensitive + _In_ PUNICODE_STRING String1, + _In_ PUNICODE_STRING String2, + _In_ BOOLEAN CaseInSensitive ); #define RTL_FIND_CHAR_IN_UNICODE_STRING_START_AT_END 0x00000001 @@ -1451,226 +1451,226 @@ NTSYSAPI NTSTATUS NTAPI RtlFindCharInUnicodeString( - __in ULONG Flags, - __in PUNICODE_STRING StringToSearch, - __in PUNICODE_STRING CharSet, - __out PUSHORT NonInclusivePrefixLength + _In_ ULONG Flags, + _In_ PUNICODE_STRING StringToSearch, + _In_ PUNICODE_STRING CharSet, + _Out_ PUSHORT NonInclusivePrefixLength ); NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString( - __in PUNICODE_STRING Destination, - __in PUNICODE_STRING Source + _In_ PUNICODE_STRING Destination, + _In_ PUNICODE_STRING Source ); NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeToString( - __in PUNICODE_STRING Destination, - __in_opt PWSTR Source + _In_ PUNICODE_STRING Destination, + _In_opt_ PWSTR Source ); NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeString( - __inout PUNICODE_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ PUNICODE_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlDowncaseUnicodeString( - __inout PUNICODE_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ PUNICODE_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI VOID NTAPI RtlEraseUnicodeString( - __inout PUNICODE_STRING String + _Inout_ PUNICODE_STRING String ); NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString( - __inout PUNICODE_STRING DestinationString, - __in PANSI_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ PUNICODE_STRING DestinationString, + _In_ PANSI_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString( - __inout PANSI_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ PANSI_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI WCHAR NTAPI RtlAnsiCharToUnicodeChar( - __inout PUCHAR *SourceCharacter + _Inout_ PUCHAR *SourceCharacter ); NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeStringToAnsiString( - __inout PANSI_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ PANSI_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString( - __inout PUNICODE_STRING DestinationString, - __in POEM_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ PUNICODE_STRING DestinationString, + _In_ POEM_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString( - __inout POEM_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ POEM_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeStringToOemString( - __inout POEM_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ POEM_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToCountedOemString( - __inout POEM_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ POEM_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeStringToCountedOemString( - __inout POEM_STRING DestinationString, - __in PUNICODE_STRING SourceString, - __in BOOLEAN AllocateDestinationString + _Inout_ POEM_STRING DestinationString, + _In_ PUNICODE_STRING SourceString, + _In_ BOOLEAN AllocateDestinationString ); NTSYSAPI NTSTATUS NTAPI RtlMultiByteToUnicodeN( - __out_bcount_part(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, - __in ULONG MaxBytesInUnicodeString, - __out_opt PULONG BytesInUnicodeString, - __in_bcount(BytesInMultiByteString) PSTR MultiByteString, - __in ULONG BytesInMultiByteString + _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG MaxBytesInUnicodeString, + _Out_opt_ PULONG BytesInUnicodeString, + _In_reads_bytes_(BytesInMultiByteString) PSTR MultiByteString, + _In_ ULONG BytesInMultiByteString ); NTSYSAPI NTSTATUS NTAPI RtlMultiByteToUnicodeSize( - __out PULONG BytesInUnicodeString, - __in_bcount(BytesInMultiByteString) PSTR MultiByteString, - __in ULONG BytesInMultiByteString + _Out_ PULONG BytesInUnicodeString, + _In_reads_bytes_(BytesInMultiByteString) PSTR MultiByteString, + _In_ ULONG BytesInMultiByteString ); NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN( - __out_bcount_part(MaxBytesInMultiByteString, *BytesInMultiByteString) PCHAR MultiByteString, - __in ULONG MaxBytesInMultiByteString, - __out_opt PULONG BytesInMultiByteString, - __in_bcount(BytesInUnicodeString) PWCH UnicodeString, - __in ULONG BytesInUnicodeString + _Out_writes_bytes_to_(MaxBytesInMultiByteString, *BytesInMultiByteString) PCHAR MultiByteString, + _In_ ULONG MaxBytesInMultiByteString, + _Out_opt_ PULONG BytesInMultiByteString, + _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG BytesInUnicodeString ); NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteSize( - __out PULONG BytesInMultiByteString, - __in_bcount(BytesInUnicodeString) PWCH UnicodeString, - __in ULONG BytesInUnicodeString + _Out_ PULONG BytesInMultiByteString, + _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG BytesInUnicodeString ); NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToMultiByteN( - __out_bcount_part(MaxBytesInMultiByteString, *BytesInMultiByteString) PCHAR MultiByteString, - __in ULONG MaxBytesInMultiByteString, - __out_opt PULONG BytesInMultiByteString, - __in_bcount(BytesInUnicodeString) PWCH UnicodeString, - __in ULONG BytesInUnicodeString + _Out_writes_bytes_to_(MaxBytesInMultiByteString, *BytesInMultiByteString) PCHAR MultiByteString, + _In_ ULONG MaxBytesInMultiByteString, + _Out_opt_ PULONG BytesInMultiByteString, + _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG BytesInUnicodeString ); NTSYSAPI NTSTATUS NTAPI RtlOemToUnicodeN( - __out_bcount_part(MaxBytesInUnicodeString, *BytesInUnicodeString) PWSTR UnicodeString, - __in ULONG MaxBytesInUnicodeString, - __out_opt PULONG BytesInUnicodeString, - __in_bcount(BytesInOemString) PCH OemString, - __in ULONG BytesInOemString + _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWSTR UnicodeString, + _In_ ULONG MaxBytesInUnicodeString, + _Out_opt_ PULONG BytesInUnicodeString, + _In_reads_bytes_(BytesInOemString) PCH OemString, + _In_ ULONG BytesInOemString ); NTSYSAPI NTSTATUS NTAPI RtlUnicodeToOemN( - __out_bcount_part(MaxBytesInOemString, *BytesInOemString) PCHAR OemString, - __in ULONG MaxBytesInOemString, - __out_opt PULONG BytesInOemString, - __in_bcount(BytesInUnicodeString) PWCH UnicodeString, - __in ULONG BytesInUnicodeString + _Out_writes_bytes_to_(MaxBytesInOemString, *BytesInOemString) PCHAR OemString, + _In_ ULONG MaxBytesInOemString, + _Out_opt_ PULONG BytesInOemString, + _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG BytesInUnicodeString ); NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToOemN( - __out_bcount_part(MaxBytesInOemString, *BytesInOemString) PCHAR OemString, - __in ULONG MaxBytesInOemString, - __out_opt PULONG BytesInOemString, - __in_bcount(BytesInUnicodeString) PWCH UnicodeString, - __in ULONG BytesInUnicodeString + _Out_writes_bytes_to_(MaxBytesInOemString, *BytesInOemString) PCHAR OemString, + _In_ ULONG MaxBytesInOemString, + _Out_opt_ PULONG BytesInOemString, + _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG BytesInUnicodeString ); NTSYSAPI NTSTATUS NTAPI RtlConsoleMultiByteToUnicodeN( - __out_bcount_part(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, - __in ULONG MaxBytesInUnicodeString, - __out_opt PULONG BytesInUnicodeString, - __in_bcount(BytesInMultiByteString) PCH MultiByteString, - __in ULONG BytesInMultiByteString, - __out PULONG pdwSpecialChar + _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG MaxBytesInUnicodeString, + _Out_opt_ PULONG BytesInUnicodeString, + _In_reads_bytes_(BytesInMultiByteString) PCH MultiByteString, + _In_ ULONG BytesInMultiByteString, + _Out_ PULONG pdwSpecialChar ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -1678,11 +1678,11 @@ NTSYSAPI NTSTATUS NTAPI RtlUTF8ToUnicodeN( - __out_bcount_part(UnicodeStringMaxByteCount, *UnicodeStringActualByteCount) PWSTR UnicodeStringDestination, - __in ULONG UnicodeStringMaxByteCount, - __out PULONG UnicodeStringActualByteCount, - __in_bcount(UTF8StringByteCount) PCH UTF8StringSource, - __in ULONG UTF8StringByteCount + _Out_writes_bytes_to_(UnicodeStringMaxByteCount, *UnicodeStringActualByteCount) PWSTR UnicodeStringDestination, + _In_ ULONG UnicodeStringMaxByteCount, + _Out_ PULONG UnicodeStringActualByteCount, + _In_reads_bytes_(UTF8StringByteCount) PCH UTF8StringSource, + _In_ ULONG UTF8StringByteCount ); #endif @@ -1691,11 +1691,11 @@ NTSYSAPI NTSTATUS NTAPI RtlUnicodeToUTF8N( - __out_bcount_part(UTF8StringMaxByteCount, *UTF8StringActualByteCount) PCHAR UTF8StringDestination, - __in ULONG UTF8StringMaxByteCount, - __out PULONG UTF8StringActualByteCount, - __in_bcount(UnicodeStringByteCount) PWCH UnicodeStringSource, - __in ULONG UnicodeStringByteCount + _Out_writes_bytes_to_(UTF8StringMaxByteCount, *UTF8StringActualByteCount) PCHAR UTF8StringDestination, + _In_ ULONG UTF8StringMaxByteCount, + _Out_ PULONG UTF8StringActualByteCount, + _In_reads_bytes_(UnicodeStringByteCount) PWCH UnicodeStringSource, + _In_ ULONG UnicodeStringByteCount ); #endif @@ -1703,70 +1703,70 @@ NTSYSAPI NTSTATUS NTAPI RtlCustomCPToUnicodeN( - __in PCPTABLEINFO CustomCP, - __out_bcount_part(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, - __in ULONG MaxBytesInUnicodeString, - __out_opt PULONG BytesInUnicodeString, - __in_bcount(BytesInCustomCPString) PCH CustomCPString, - __in ULONG BytesInCustomCPString + _In_ PCPTABLEINFO CustomCP, + _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG MaxBytesInUnicodeString, + _Out_opt_ PULONG BytesInUnicodeString, + _In_reads_bytes_(BytesInCustomCPString) PCH CustomCPString, + _In_ ULONG BytesInCustomCPString ); NTSYSAPI NTSTATUS NTAPI RtlUnicodeToCustomCPN( - __in PCPTABLEINFO CustomCP, - __out_bcount_part(MaxBytesInCustomCPString, *BytesInCustomCPString) PCH CustomCPString, - __in ULONG MaxBytesInCustomCPString, - __out_opt PULONG BytesInCustomCPString, - __in_bcount(BytesInUnicodeString) PWCH UnicodeString, - __in ULONG BytesInUnicodeString + _In_ PCPTABLEINFO CustomCP, + _Out_writes_bytes_to_(MaxBytesInCustomCPString, *BytesInCustomCPString) PCH CustomCPString, + _In_ ULONG MaxBytesInCustomCPString, + _Out_opt_ PULONG BytesInCustomCPString, + _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG BytesInUnicodeString ); NTSYSAPI NTSTATUS NTAPI RtlUpcaseUnicodeToCustomCPN( - __in PCPTABLEINFO CustomCP, - __out_bcount_part(MaxBytesInCustomCPString, *BytesInCustomCPString) PCH CustomCPString, - __in ULONG MaxBytesInCustomCPString, - __out_opt PULONG BytesInCustomCPString, - __in_bcount(BytesInUnicodeString) PWCH UnicodeString, - __in ULONG BytesInUnicodeString + _In_ PCPTABLEINFO CustomCP, + _Out_writes_bytes_to_(MaxBytesInCustomCPString, *BytesInCustomCPString) PCH CustomCPString, + _In_ ULONG MaxBytesInCustomCPString, + _Out_opt_ PULONG BytesInCustomCPString, + _In_reads_bytes_(BytesInUnicodeString) PWCH UnicodeString, + _In_ ULONG BytesInUnicodeString ); NTSYSAPI VOID NTAPI RtlInitCodePageTable( - __in PUSHORT TableBase, - __out PCPTABLEINFO CodePageTable + _In_ PUSHORT TableBase, + _Out_ PCPTABLEINFO CodePageTable ); NTSYSAPI VOID NTAPI RtlInitNlsTables( - __in PUSHORT AnsiNlsBase, - __in PUSHORT OemNlsBase, - __in PUSHORT LanguageNlsBase, - __out PNLSTABLEINFO TableInfo + _In_ PUSHORT AnsiNlsBase, + _In_ PUSHORT OemNlsBase, + _In_ PUSHORT LanguageNlsBase, + _Out_ PNLSTABLEINFO TableInfo ); NTSYSAPI VOID NTAPI RtlResetRtlTranslations( - __in PNLSTABLEINFO TableInfo + _In_ PNLSTABLEINFO TableInfo ); NTSYSAPI BOOLEAN NTAPI RtlIsTextUnicode( - __in PVOID Buffer, - __in ULONG Size, - __inout_opt PULONG Result + _In_ PVOID Buffer, + _In_ ULONG Size, + _Inout_opt_ PULONG Result ); typedef enum _RTL_NORM_FORM @@ -1790,11 +1790,11 @@ NTSYSAPI NTSTATUS NTAPI RtlNormalizeString( - __in ULONG NormForm, // RTL_NORM_FORM - __in PCWSTR SourceString, - __in LONG SourceStringLength, - __out_ecount_part(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString, - __inout PLONG DestinationStringLength + _In_ ULONG NormForm, // RTL_NORM_FORM + _In_ PCWSTR SourceString, + _In_ LONG SourceStringLength, + _Out_writes_to_(*DestinationStringLength, *DestinationStringLength) PWSTR DestinationString, + _Inout_ PLONG DestinationStringLength ); #endif @@ -1803,10 +1803,10 @@ NTSYSAPI NTSTATUS NTAPI RtlIsNormalizedString( - __in ULONG NormForm, // RTL_NORM_FORM - __in PCWSTR SourceString, - __in LONG SourceStringLength, - __out PBOOLEAN Normalized + _In_ ULONG NormForm, // RTL_NORM_FORM + _In_ PCWSTR SourceString, + _In_ LONG SourceStringLength, + _Out_ PBOOLEAN Normalized ); #endif @@ -1816,10 +1816,10 @@ NTSYSAPI BOOLEAN NTAPI RtlIsNameInExpression( - __in PUNICODE_STRING Expression, - __in PUNICODE_STRING Name, - __in BOOLEAN IgnoreCase, - __in_opt PWCH UpcaseTable + _In_ PUNICODE_STRING Expression, + _In_ PUNICODE_STRING Name, + _In_ BOOLEAN IgnoreCase, + _In_opt_ PWCH UpcaseTable ); #endif @@ -1827,41 +1827,41 @@ NTSYSAPI BOOLEAN NTAPI RtlEqualDomainName( - __in PUNICODE_STRING String1, - __in PUNICODE_STRING String2 + _In_ PUNICODE_STRING String1, + _In_ PUNICODE_STRING String2 ); NTSYSAPI BOOLEAN NTAPI RtlEqualComputerName( - __in PUNICODE_STRING String1, - __in PUNICODE_STRING String2 + _In_ PUNICODE_STRING String1, + _In_ PUNICODE_STRING String2 ); NTSYSAPI NTSTATUS NTAPI RtlDnsHostNameToComputerName( - __out PUNICODE_STRING ComputerNameString, - __in PCUNICODE_STRING DnsHostNameString, - __in BOOLEAN AllocateComputerNameString + _Out_ PUNICODE_STRING ComputerNameString, + _In_ PCUNICODE_STRING DnsHostNameString, + _In_ BOOLEAN AllocateComputerNameString ); NTSYSAPI NTSTATUS NTAPI RtlStringFromGUID( - __in PGUID Guid, - __out PUNICODE_STRING GuidString + _In_ PGUID Guid, + _Out_ PUNICODE_STRING GuidString ); NTSYSAPI NTSTATUS NTAPI RtlGUIDFromString( - __in PUNICODE_STRING GuidString, - __out PGUID Guid + _In_ PUNICODE_STRING GuidString, + _Out_ PGUID Guid ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -1869,8 +1869,8 @@ NTSYSAPI LONG NTAPI RtlCompareAltitudes( - __in PUNICODE_STRING Altitude1, - __in PUNICODE_STRING Altitude2 + _In_ PUNICODE_STRING Altitude1, + _In_ PUNICODE_STRING Altitude2 ); #endif @@ -1896,32 +1896,32 @@ NTSYSAPI VOID NTAPI PfxInitialize( - __out PPREFIX_TABLE PrefixTable + _Out_ PPREFIX_TABLE PrefixTable ); NTSYSAPI BOOLEAN NTAPI PfxInsertPrefix( - __in PPREFIX_TABLE PrefixTable, - __in PSTRING Prefix, - __out PPREFIX_TABLE_ENTRY PrefixTableEntry + _In_ PPREFIX_TABLE PrefixTable, + _In_ PSTRING Prefix, + _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry ); NTSYSAPI VOID NTAPI PfxRemovePrefix( - __in PPREFIX_TABLE PrefixTable, - __in PPREFIX_TABLE_ENTRY PrefixTableEntry + _In_ PPREFIX_TABLE PrefixTable, + _In_ PPREFIX_TABLE_ENTRY PrefixTableEntry ); NTSYSAPI PPREFIX_TABLE_ENTRY NTAPI PfxFindPrefix( - __in PPREFIX_TABLE PrefixTable, - __in PSTRING FullName + _In_ PPREFIX_TABLE PrefixTable, + _In_ PSTRING FullName ); typedef struct _UNICODE_PREFIX_TABLE_ENTRY @@ -1946,41 +1946,41 @@ NTSYSAPI VOID NTAPI RtlInitializeUnicodePrefix( - __out PUNICODE_PREFIX_TABLE PrefixTable + _Out_ PUNICODE_PREFIX_TABLE PrefixTable ); NTSYSAPI BOOLEAN NTAPI RtlInsertUnicodePrefix( - __in PUNICODE_PREFIX_TABLE PrefixTable, - __in PUNICODE_STRING Prefix, - __out PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry + _In_ PUNICODE_PREFIX_TABLE PrefixTable, + _In_ PUNICODE_STRING Prefix, + _Out_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry ); NTSYSAPI VOID NTAPI RtlRemoveUnicodePrefix( - __in PUNICODE_PREFIX_TABLE PrefixTable, - __in PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry + _In_ PUNICODE_PREFIX_TABLE PrefixTable, + _In_ PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry ); NTSYSAPI PUNICODE_PREFIX_TABLE_ENTRY NTAPI RtlFindUnicodePrefix( - __in PUNICODE_PREFIX_TABLE PrefixTable, - __in PUNICODE_STRING FullName, - __in ULONG CaseInsensitiveIndex + _In_ PUNICODE_PREFIX_TABLE PrefixTable, + _In_ PUNICODE_STRING FullName, + _In_ ULONG CaseInsensitiveIndex ); NTSYSAPI PUNICODE_PREFIX_TABLE_ENTRY NTAPI RtlNextUnicodePrefix( - __in PUNICODE_PREFIX_TABLE PrefixTable, - __in BOOLEAN Restart + _In_ PUNICODE_PREFIX_TABLE PrefixTable, + _In_ BOOLEAN Restart ); // Compression @@ -2003,35 +2003,35 @@ NTSYSAPI NTSTATUS NTAPI RtlGetCompressionWorkSpaceSize( - __in USHORT CompressionFormatAndEngine, - __out PULONG CompressBufferWorkSpaceSize, - __out PULONG CompressFragmentWorkSpaceSize + _In_ USHORT CompressionFormatAndEngine, + _Out_ PULONG CompressBufferWorkSpaceSize, + _Out_ PULONG CompressFragmentWorkSpaceSize ); NTSYSAPI NTSTATUS NTAPI RtlCompressBuffer( - __in USHORT CompressionFormatAndEngine, - __in_bcount(UncompressedBufferSize) PUCHAR UncompressedBuffer, - __in ULONG UncompressedBufferSize, - __out_bcount_part(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer, - __in ULONG CompressedBufferSize, - __in ULONG UncompressedChunkSize, - __out PULONG FinalCompressedSize, - __in PVOID WorkSpace + _In_ USHORT CompressionFormatAndEngine, + _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer, + _In_ ULONG UncompressedBufferSize, + _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer, + _In_ ULONG CompressedBufferSize, + _In_ ULONG UncompressedChunkSize, + _Out_ PULONG FinalCompressedSize, + _In_ PVOID WorkSpace ); NTSYSAPI NTSTATUS NTAPI RtlDecompressBuffer( - __in USHORT CompressionFormat, - __out_bcount_part(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer, - __in ULONG UncompressedBufferSize, - __in_bcount(CompressedBufferSize) PUCHAR CompressedBuffer, - __in ULONG CompressedBufferSize, - __out PULONG FinalUncompressedSize + _In_ USHORT CompressionFormat, + _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer, + _In_ ULONG UncompressedBufferSize, + _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, + _In_ ULONG CompressedBufferSize, + _Out_ PULONG FinalUncompressedSize ); #if (PHNT_VERSION >= PHNT_WIN8) @@ -2039,13 +2039,13 @@ NTSYSAPI NTSTATUS NTAPI RtlDecompressBufferEx( - __in USHORT CompressionFormat, - __out_bcount_part(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer, - __in ULONG UncompressedBufferSize, - __in_bcount(CompressedBufferSize) PUCHAR CompressedBuffer, - __in ULONG CompressedBufferSize, - __out PULONG FinalUncompressedSize, - __in PVOID WorkSpace + _In_ USHORT CompressionFormat, + _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer, + _In_ ULONG UncompressedBufferSize, + _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, + _In_ ULONG CompressedBufferSize, + _Out_ PULONG FinalUncompressedSize, + _In_ PVOID WorkSpace ); #endif @@ -2053,62 +2053,62 @@ NTSYSAPI NTSTATUS NTAPI RtlDecompressFragment( - __in USHORT CompressionFormat, - __out_bcount_part(UncompressedFragmentSize, *FinalUncompressedSize) PUCHAR UncompressedFragment, - __in ULONG UncompressedFragmentSize, - __in_bcount(CompressedBufferSize) PUCHAR CompressedBuffer, - __in ULONG CompressedBufferSize, - __in_range(<, CompressedBufferSize) ULONG FragmentOffset, - __out PULONG FinalUncompressedSize, - __in PVOID WorkSpace + _In_ USHORT CompressionFormat, + _Out_writes_bytes_to_(UncompressedFragmentSize, *FinalUncompressedSize) PUCHAR UncompressedFragment, + _In_ ULONG UncompressedFragmentSize, + _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, + _In_ ULONG CompressedBufferSize, + _In_range_(<, CompressedBufferSize) ULONG FragmentOffset, + _Out_ PULONG FinalUncompressedSize, + _In_ PVOID WorkSpace ); NTSYSAPI NTSTATUS NTAPI RtlDescribeChunk( - __in USHORT CompressionFormat, - __inout PUCHAR *CompressedBuffer, - __in PUCHAR EndOfCompressedBufferPlus1, - __out PUCHAR *ChunkBuffer, - __out PULONG ChunkSize + _In_ USHORT CompressionFormat, + _Inout_ PUCHAR *CompressedBuffer, + _In_ PUCHAR EndOfCompressedBufferPlus1, + _Out_ PUCHAR *ChunkBuffer, + _Out_ PULONG ChunkSize ); NTSYSAPI NTSTATUS NTAPI RtlReserveChunk( - __in USHORT CompressionFormat, - __inout PUCHAR *CompressedBuffer, - __in PUCHAR EndOfCompressedBufferPlus1, - __out PUCHAR *ChunkBuffer, - __in ULONG ChunkSize + _In_ USHORT CompressionFormat, + _Inout_ PUCHAR *CompressedBuffer, + _In_ PUCHAR EndOfCompressedBufferPlus1, + _Out_ PUCHAR *ChunkBuffer, + _In_ ULONG ChunkSize ); NTSYSAPI NTSTATUS NTAPI RtlDecompressChunks( - __out_bcount(UncompressedBufferSize) PUCHAR UncompressedBuffer, - __in ULONG UncompressedBufferSize, - __in_bcount(CompressedBufferSize) PUCHAR CompressedBuffer, - __in ULONG CompressedBufferSize, - __in_bcount(CompressedTailSize) PUCHAR CompressedTail, - __in ULONG CompressedTailSize, - __in PCOMPRESSED_DATA_INFO CompressedDataInfo + _Out_writes_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer, + _In_ ULONG UncompressedBufferSize, + _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, + _In_ ULONG CompressedBufferSize, + _In_reads_bytes_(CompressedTailSize) PUCHAR CompressedTail, + _In_ ULONG CompressedTailSize, + _In_ PCOMPRESSED_DATA_INFO CompressedDataInfo ); NTSYSAPI NTSTATUS NTAPI RtlCompressChunks( - __in_bcount(UncompressedBufferSize) PUCHAR UncompressedBuffer, - __in ULONG UncompressedBufferSize, - __out_bcount(CompressedBufferSize) PUCHAR CompressedBuffer, - __in_range(>=, (UncompressedBufferSize - (UncompressedBufferSize / 16))) ULONG CompressedBufferSize, - __inout_bcount(CompressedDataInfoLength) PCOMPRESSED_DATA_INFO CompressedDataInfo, - __in_range(>, sizeof(COMPRESSED_DATA_INFO)) ULONG CompressedDataInfoLength, - __in PVOID WorkSpace + _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer, + _In_ ULONG UncompressedBufferSize, + _Out_writes_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer, + _In_range_(>=, (UncompressedBufferSize - (UncompressedBufferSize / 16))) ULONG CompressedBufferSize, + _Inout_updates_bytes_(CompressedDataInfoLength) PCOMPRESSED_DATA_INFO CompressedDataInfo, + _In_range_(>, sizeof(COMPRESSED_DATA_INFO)) ULONG CompressedDataInfoLength, + _In_ PVOID WorkSpace ); // Locale @@ -2120,11 +2120,11 @@ NTSYSAPI NTSTATUS NTAPI RtlConvertLCIDToString( - __in LCID LcidValue, - __in ULONG Base, - __in ULONG Padding, // string is padded to this width - __out_ecount(Size) PWSTR pResultBuf, - __in ULONG Size + _In_ LCID LcidValue, + _In_ ULONG Base, + _In_ ULONG Padding, // string is padded to this width + _Out_writes_(Size) PWSTR pResultBuf, + _In_ ULONG Size ); // private @@ -2132,8 +2132,8 @@ NTSYSAPI BOOLEAN NTAPI RtlIsValidLocaleName( - __in PWSTR LocaleName, - __in ULONG Flags + _In_ PWSTR LocaleName, + _In_ ULONG Flags ); // private @@ -2141,10 +2141,10 @@ NTSYSAPI NTSTATUS NTAPI RtlGetParentLocaleName( - __in PWSTR LocaleName, - __inout PUNICODE_STRING ParentLocaleName, - __in ULONG Flags, - __in BOOLEAN AllocateDestinationString + _In_ PWSTR LocaleName, + _Inout_ PUNICODE_STRING ParentLocaleName, + _In_ ULONG Flags, + _In_ BOOLEAN AllocateDestinationString ); // private @@ -2152,10 +2152,10 @@ NTSYSAPI NTSTATUS NTAPI RtlLcidToLocaleName( - __in LCID lcid, // sic - __inout PUNICODE_STRING LocaleName, - __in ULONG Flags, - __in BOOLEAN AllocateDestinationString + _In_ LCID lcid, // sic + _Inout_ PUNICODE_STRING LocaleName, + _In_ ULONG Flags, + _In_ BOOLEAN AllocateDestinationString ); // private @@ -2163,9 +2163,9 @@ NTSYSAPI NTSTATUS NTAPI RtlLocaleNameToLcid( - __in PWSTR LocaleName, - __out PLCID lcid, - __in ULONG Flags + _In_ PWSTR LocaleName, + _Out_ PLCID lcid, + _In_ ULONG Flags ); // private @@ -2173,8 +2173,8 @@ NTSYSAPI BOOLEAN NTAPI RtlLCIDToCultureName( - __in LCID Lcid, - __inout PUNICODE_STRING String + _In_ LCID Lcid, + _Inout_ PUNICODE_STRING String ); // private @@ -2182,8 +2182,8 @@ NTSYSAPI BOOLEAN NTAPI RtlCultureNameToLCID( - __in PUNICODE_STRING String, - __out PLCID Lcid + _In_ PUNICODE_STRING String, + _Out_ PLCID Lcid ); // private @@ -2203,9 +2203,9 @@ NTSYSAPI NTSTATUS NTAPI RtlGetLocaleFileMappingAddress( - __out PVOID *BaseAddress, - __out PLCID DefaultLocaleId, - __out PLARGE_INTEGER DefaultCasingTableSize + _Out_ PVOID *BaseAddress, + _Out_ PLCID DefaultLocaleId, + _Out_ PLARGE_INTEGER DefaultCasingTableSize ); #endif @@ -2240,16 +2240,16 @@ NTSYSAPI NTSTATUS NTAPI RtlAllocateFromPeb( - __in ULONG Size, - __out PVOID *Block + _In_ ULONG Size, + _Out_ PVOID *Block ); NTSYSAPI NTSTATUS NTAPI RtlFreeToPeb( - __in PVOID Block, - __in ULONG Size + _In_ PVOID Block, + _In_ ULONG Size ); // Processes @@ -2336,16 +2336,16 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateProcessParameters( - __out PRTL_USER_PROCESS_PARAMETERS *pProcessParameters, - __in PUNICODE_STRING ImagePathName, - __in_opt PUNICODE_STRING DllPath, - __in_opt PUNICODE_STRING CurrentDirectory, - __in_opt PUNICODE_STRING CommandLine, - __in_opt PVOID Environment, - __in_opt PUNICODE_STRING WindowTitle, - __in_opt PUNICODE_STRING DesktopInfo, - __in_opt PUNICODE_STRING ShellInfo, - __in_opt PUNICODE_STRING RuntimeData + _Out_ PRTL_USER_PROCESS_PARAMETERS *pProcessParameters, + _In_ PUNICODE_STRING ImagePathName, + _In_opt_ PUNICODE_STRING DllPath, + _In_opt_ PUNICODE_STRING CurrentDirectory, + _In_opt_ PUNICODE_STRING CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PUNICODE_STRING WindowTitle, + _In_opt_ PUNICODE_STRING DesktopInfo, + _In_opt_ PUNICODE_STRING ShellInfo, + _In_opt_ PUNICODE_STRING RuntimeData ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -2354,17 +2354,17 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateProcessParametersEx( - __out PRTL_USER_PROCESS_PARAMETERS *pProcessParameters, - __in PUNICODE_STRING ImagePathName, - __in_opt PUNICODE_STRING DllPath, - __in_opt PUNICODE_STRING CurrentDirectory, - __in_opt PUNICODE_STRING CommandLine, - __in_opt PVOID Environment, - __in_opt PUNICODE_STRING WindowTitle, - __in_opt PUNICODE_STRING DesktopInfo, - __in_opt PUNICODE_STRING ShellInfo, - __in_opt PUNICODE_STRING RuntimeData, - __in ULONG Flags // pass RTL_USER_PROC_PARAMS_NORMALIZED to keep parameters normalized + _Out_ PRTL_USER_PROCESS_PARAMETERS *pProcessParameters, + _In_ PUNICODE_STRING ImagePathName, + _In_opt_ PUNICODE_STRING DllPath, + _In_opt_ PUNICODE_STRING CurrentDirectory, + _In_opt_ PUNICODE_STRING CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PUNICODE_STRING WindowTitle, + _In_opt_ PUNICODE_STRING DesktopInfo, + _In_opt_ PUNICODE_STRING ShellInfo, + _In_opt_ PUNICODE_STRING RuntimeData, + _In_ ULONG Flags // pass RTL_USER_PROC_PARAMS_NORMALIZED to keep parameters normalized ); #endif @@ -2372,21 +2372,21 @@ NTSYSAPI NTSTATUS NTAPI RtlDestroyProcessParameters( - __in __post_invalid PRTL_USER_PROCESS_PARAMETERS ProcessParameters + _In_ _Post_invalid_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters ); NTSYSAPI PRTL_USER_PROCESS_PARAMETERS NTAPI RtlNormalizeProcessParams( - __inout PRTL_USER_PROCESS_PARAMETERS ProcessParameters + _Inout_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters ); NTSYSAPI PRTL_USER_PROCESS_PARAMETERS NTAPI RtlDeNormalizeProcessParams( - __inout PRTL_USER_PROCESS_PARAMETERS ProcessParameters + _Inout_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters ); typedef struct _RTL_USER_PROCESS_INFORMATION @@ -2403,16 +2403,16 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateUserProcess( - __in PUNICODE_STRING NtImagePathName, - __in ULONG AttributesDeprecated, - __in PRTL_USER_PROCESS_PARAMETERS ProcessParameters, - __in_opt PSECURITY_DESCRIPTOR ProcessSecurityDescriptor, - __in_opt PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, - __in_opt HANDLE ParentProcess, - __in BOOLEAN InheritHandles, - __in_opt HANDLE DebugPort, - __in_opt HANDLE TokenHandle, // used to be ExceptionPort - __out PRTL_USER_PROCESS_INFORMATION ProcessInformation + _In_ PUNICODE_STRING NtImagePathName, + _In_ ULONG AttributesDeprecated, + _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters, + _In_opt_ PSECURITY_DESCRIPTOR ProcessSecurityDescriptor, + _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, + _In_opt_ HANDLE ParentProcess, + _In_ BOOLEAN InheritHandles, + _In_opt_ HANDLE DebugPort, + _In_opt_ HANDLE TokenHandle, // used to be ExceptionPort + _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInformation ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -2421,7 +2421,7 @@ NTSYSAPI VOID NTAPI RtlExitUserProcess( - __in NTSTATUS ExitStatus + _In_ NTSTATUS ExitStatus ); #else @@ -2429,7 +2429,7 @@ RtlExitUserProcess( DECLSPEC_NORETURN FORCEINLINE VOID RtlExitUserProcess_R( - __in NTSTATUS ExitStatus + _In_ NTSTATUS ExitStatus ) { ExitProcess(ExitStatus); @@ -2450,11 +2450,11 @@ NTSYSAPI NTSTATUS NTAPI RtlCloneUserProcess( - __in ULONG ProcessFlags, - __in_opt PSECURITY_DESCRIPTOR ProcessSecurityDescriptor, - __in_opt PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, - __in_opt HANDLE DebugPort, - __out PRTL_USER_PROCESS_INFORMATION ProcessInformation + _In_ ULONG ProcessFlags, + _In_opt_ PSECURITY_DESCRIPTOR ProcessSecurityDescriptor, + _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, + _In_opt_ HANDLE DebugPort, + _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInformation ); // private @@ -2462,7 +2462,7 @@ NTSYSAPI VOID NTAPI RtlUpdateClonedCriticalSection( - __inout PRTL_CRITICAL_SECTION CriticalSection + _Inout_ PRTL_CRITICAL_SECTION CriticalSection ); // private @@ -2470,8 +2470,8 @@ NTSYSAPI VOID NTAPI RtlUpdateClonedSRWLock( - __inout PRTL_SRWLOCK SRWLock, - __in LOGICAL Shared // TRUE to set to shared acquire + _Inout_ PRTL_SRWLOCK SRWLock, + _In_ LOGICAL Shared // TRUE to set to shared acquire ); // private @@ -2488,12 +2488,12 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateProcessReflection( - __in HANDLE ProcessHandle, - __in ULONG Flags, - __in_opt PVOID StartRoutine, - __in_opt PVOID StartContext, - __in_opt HANDLE EventHandle, - __out_opt PRTLP_PROCESS_REFLECTION_REFLECTION_INFORMATION ReflectionInformation + _In_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _In_opt_ PVOID StartRoutine, + _In_opt_ PVOID StartContext, + _In_opt_ HANDLE EventHandle, + _Out_opt_ PRTLP_PROCESS_REFLECTION_REFLECTION_INFORMATION ReflectionInformation ); #endif @@ -2503,40 +2503,40 @@ NTSYSAPI NTSTATUS STDAPIVCALLTYPE RtlSetProcessIsCritical( - __in BOOLEAN NewValue, - __out_opt PBOOLEAN OldValue, - __in BOOLEAN CheckFlag + _In_ BOOLEAN NewValue, + _Out_opt_ PBOOLEAN OldValue, + _In_ BOOLEAN CheckFlag ); NTSYSAPI NTSTATUS STDAPIVCALLTYPE RtlSetThreadIsCritical( - __in BOOLEAN NewValue, - __out_opt PBOOLEAN OldValue, - __in BOOLEAN CheckFlag + _In_ BOOLEAN NewValue, + _Out_opt_ PBOOLEAN OldValue, + _In_ BOOLEAN CheckFlag ); // Threads typedef NTSTATUS (NTAPI *PUSER_THREAD_START_ROUTINE)( - __in PVOID ThreadParameter + _In_ PVOID ThreadParameter ); NTSYSAPI NTSTATUS NTAPI RtlCreateUserThread( - __in HANDLE Process, - __in_opt PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, - __in BOOLEAN CreateSuspended, - __in_opt ULONG ZeroBits, - __in_opt SIZE_T MaximumStackSize, - __in_opt SIZE_T CommittedStackSize, - __in PUSER_THREAD_START_ROUTINE StartAddress, - __in_opt PVOID Parameter, - __out_opt PHANDLE Thread, - __out_opt PCLIENT_ID ClientId + _In_ HANDLE Process, + _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, + _In_ BOOLEAN CreateSuspended, + _In_opt_ ULONG ZeroBits, + _In_opt_ SIZE_T MaximumStackSize, + _In_opt_ SIZE_T CommittedStackSize, + _In_ PUSER_THREAD_START_ROUTINE StartAddress, + _In_opt_ PVOID Parameter, + _Out_opt_ PHANDLE Thread, + _Out_opt_ PCLIENT_ID ClientId ); #if (PHNT_VERSION >= PHNT_VISTA) // should be PHNT_WINXP, but is PHNT_VISTA for consistency with RtlExitUserProcess @@ -2545,7 +2545,7 @@ NTSYSAPI VOID NTAPI RtlExitUserThread( - __in NTSTATUS ExitStatus + _In_ NTSTATUS ExitStatus ); #else @@ -2553,7 +2553,7 @@ RtlExitUserThread( DECLSPEC_NORETURN FORCEINLINE VOID RtlExitUserThread_R( - __in NTSTATUS ExitStatus + _In_ NTSTATUS ExitStatus ) { ExitThread(ExitStatus); @@ -2567,12 +2567,12 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateUserStack( - __in_opt SIZE_T CommittedStackSize, - __in_opt SIZE_T MaximumStackSize, - __in_opt ULONG_PTR ZeroBits, - __in SIZE_T PageSize, - __in ULONG_PTR ReserveAlignment, - __out PINITIAL_TEB InitialTeb + _In_opt_ SIZE_T CommittedStackSize, + _In_opt_ SIZE_T MaximumStackSize, + _In_opt_ ULONG_PTR ZeroBits, + _In_ SIZE_T PageSize, + _In_ ULONG_PTR ReserveAlignment, + _Out_ PINITIAL_TEB InitialTeb ); #endif @@ -2580,24 +2580,24 @@ NTSYSAPI VOID NTAPI RtlInitializeContext( - __in HANDLE Process, - __out PCONTEXT Context, - __in_opt PVOID Parameter, - __in_opt PVOID InitialPc, - __in_opt PVOID InitialSp + _In_ HANDLE Process, + _Out_ PCONTEXT Context, + _In_opt_ PVOID Parameter, + _In_opt_ PVOID InitialPc, + _In_opt_ PVOID InitialSp ); NTSYSAPI NTSTATUS NTAPI RtlRemoteCall( - __in HANDLE Process, - __in HANDLE Thread, - __in PVOID CallSite, - __in ULONG ArgumentCount, - __in_opt PULONG_PTR Arguments, - __in BOOLEAN PassContext, - __in BOOLEAN AlreadySuspended + _In_ HANDLE Process, + _In_ HANDLE Thread, + _In_ PVOID CallSite, + _In_ ULONG ArgumentCount, + _In_opt_ PULONG_PTR Arguments, + _In_ BOOLEAN PassContext, + _In_ BOOLEAN AlreadySuspended ); #ifdef _M_X64 @@ -2606,8 +2606,8 @@ NTSYSAPI NTSTATUS NTAPI RtlWow64GetThreadContext( - __in HANDLE ThreadHandle, - __inout PWOW64_CONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _Inout_ PWOW64_CONTEXT ThreadContext ); #endif @@ -2617,8 +2617,8 @@ NTSYSAPI NTSTATUS NTAPI RtlWow64SetThreadContext( - __in HANDLE ThreadHandle, - __in PWOW64_CONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _In_ PWOW64_CONTEXT ThreadContext ); #endif @@ -2667,15 +2667,15 @@ NTSYSAPI PVOID NTAPI RtlPcToFileHeader( - __in PVOID PcValue, - __out PVOID *BaseOfImage + _In_ PVOID PcValue, + _Out_ PVOID *BaseOfImage ); NTSYSAPI PIMAGE_NT_HEADERS NTAPI RtlImageNtHeader( - __in PVOID Base + _In_ PVOID Base ); #define RTL_IMAGE_NT_HEADER_EX_FLAG_NO_RANGE_CHECK 0x00000001 @@ -2684,57 +2684,57 @@ NTSYSAPI NTSTATUS NTAPI RtlImageNtHeaderEx( - __in ULONG Flags, - __in PVOID Base, - __in ULONG64 Size, - __out PIMAGE_NT_HEADERS *OutHeaders + _In_ ULONG Flags, + _In_ PVOID Base, + _In_ ULONG64 Size, + _Out_ PIMAGE_NT_HEADERS *OutHeaders ); NTSYSAPI PVOID NTAPI RtlAddressInSectionTable( - __in PIMAGE_NT_HEADERS NtHeaders, - __in PVOID BaseOfImage, - __in ULONG VirtualAddress + _In_ PIMAGE_NT_HEADERS NtHeaders, + _In_ PVOID BaseOfImage, + _In_ ULONG VirtualAddress ); NTSYSAPI PIMAGE_SECTION_HEADER NTAPI RtlSectionTableFromVirtualAddress( - __in PIMAGE_NT_HEADERS NtHeaders, - __in PVOID BaseOfImage, - __in ULONG VirtualAddress + _In_ PIMAGE_NT_HEADERS NtHeaders, + _In_ PVOID BaseOfImage, + _In_ ULONG VirtualAddress ); NTSYSAPI PVOID NTAPI RtlImageDirectoryEntryToData( - __in PVOID BaseOfImage, - __in BOOLEAN MappedAsImage, - __in USHORT DirectoryEntry, - __out PULONG Size + _In_ PVOID BaseOfImage, + _In_ BOOLEAN MappedAsImage, + _In_ USHORT DirectoryEntry, + _Out_ PULONG Size ); NTSYSAPI PIMAGE_SECTION_HEADER NTAPI RtlImageRvaToSection( - __in PIMAGE_NT_HEADERS NtHeaders, - __in PVOID Base, - __in ULONG Rva + _In_ PIMAGE_NT_HEADERS NtHeaders, + _In_ PVOID Base, + _In_ ULONG Rva ); NTSYSAPI PVOID NTAPI RtlImageRvaToVa( - __in PIMAGE_NT_HEADERS NtHeaders, - __in PVOID Base, - __in ULONG Rva, - __inout_opt PIMAGE_SECTION_HEADER *LastRvaSection + _In_ PIMAGE_NT_HEADERS NtHeaders, + _In_ PVOID Base, + _In_ ULONG Rva, + _Inout_opt_ PIMAGE_SECTION_HEADER *LastRvaSection ); // Memory @@ -2743,27 +2743,27 @@ NTSYSAPI SIZE_T NTAPI RtlCompareMemoryUlong( - __in PVOID Source, - __in SIZE_T Length, - __in ULONG Pattern + _In_ PVOID Source, + _In_ SIZE_T Length, + _In_ ULONG Pattern ); NTSYSAPI VOID NTAPI RtlFillMemoryUlong( - __out PVOID Destination, - __in SIZE_T Length, - __in ULONG Pattern + _Out_ PVOID Destination, + _In_ SIZE_T Length, + _In_ ULONG Pattern ); NTSYSAPI VOID NTAPI RtlFillMemoryUlonglong( - __out PVOID Destination, - __in SIZE_T Length, - __in ULONGLONG Pattern + _Out_ PVOID Destination, + _In_ SIZE_T Length, + _In_ ULONGLONG Pattern ); // Environment @@ -2772,8 +2772,8 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateEnvironment( - __in BOOLEAN CloneCurrentEnvironment, - __out PVOID *Environment + _In_ BOOLEAN CloneCurrentEnvironment, + _Out_ PVOID *Environment ); // begin_rev @@ -2788,9 +2788,9 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateEnvironmentEx( - __in PVOID SourceEnv, - __out PVOID *Environment, - __in ULONG Flags + _In_ PVOID SourceEnv, + _Out_ PVOID *Environment, + _In_ ULONG Flags ); #endif @@ -2798,15 +2798,15 @@ NTSYSAPI NTSTATUS NTAPI RtlDestroyEnvironment( - __in PVOID Environment + _In_ PVOID Environment ); NTSYSAPI NTSTATUS NTAPI RtlSetCurrentEnvironment( - __in PVOID Environment, - __out_opt PVOID *PreviousEnvironment + _In_ PVOID Environment, + _Out_opt_ PVOID *PreviousEnvironment ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -2815,11 +2815,11 @@ NTSYSAPI NTSTATUS NTAPI RtlSetEnvironmentVar( - __in_opt PWSTR *Environment, - __in_ecount(NameLength) PWSTR Name, - __in SIZE_T NameLength, - __in_ecount(ValueLength) PWSTR Value, - __in SIZE_T ValueLength + _In_opt_ PWSTR *Environment, + _In_reads_(NameLength) PWSTR Name, + _In_ SIZE_T NameLength, + _In_reads_(ValueLength) PWSTR Value, + _In_ SIZE_T ValueLength ); #endif @@ -2827,9 +2827,9 @@ NTSYSAPI NTSTATUS NTAPI RtlSetEnvironmentVariable( - __in_opt PVOID *Environment, - __in PUNICODE_STRING Name, - __in PUNICODE_STRING Value + _In_opt_ PVOID *Environment, + _In_ PUNICODE_STRING Name, + _In_ PUNICODE_STRING Value ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -2838,12 +2838,12 @@ NTSYSAPI NTSTATUS NTAPI RtlQueryEnvironmentVariable( - __in_opt PVOID Environment, - __in_ecount(NameLength) PWSTR Name, - __in SIZE_T NameLength, - __out_ecount(ValueLength) PWSTR Value, - __in SIZE_T ValueLength, - __out PSIZE_T ReturnLength + _In_opt_ PVOID Environment, + _In_reads_(NameLength) PWSTR Name, + _In_ SIZE_T NameLength, + _Out_writes_(ValueLength) PWSTR Value, + _In_ SIZE_T ValueLength, + _Out_ PSIZE_T ReturnLength ); #endif @@ -2851,9 +2851,9 @@ NTSYSAPI NTSTATUS NTAPI RtlQueryEnvironmentVariable_U( - __in_opt PVOID Environment, - __in PUNICODE_STRING Name, - __out PUNICODE_STRING Value + _In_opt_ PVOID Environment, + _In_ PUNICODE_STRING Name, + _Out_ PUNICODE_STRING Value ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -2862,12 +2862,12 @@ NTSYSAPI NTSTATUS NTAPI RtlExpandEnvironmentStrings( - __in_opt PVOID Environment, - __in_ecount(SrcLength) PWSTR Src, - __in SIZE_T SrcLength, - __out_ecount(DstLength) PWSTR Dst, - __in SIZE_T DstLength, - __out_opt PSIZE_T ReturnLength + _In_opt_ PVOID Environment, + _In_reads_(SrcLength) PWSTR Src, + _In_ SIZE_T SrcLength, + _Out_writes_(DstLength) PWSTR Dst, + _In_ SIZE_T DstLength, + _Out_opt_ PSIZE_T ReturnLength ); #endif @@ -2875,18 +2875,18 @@ NTSYSAPI NTSTATUS NTAPI RtlExpandEnvironmentStrings_U( - __in_opt PVOID Environment, - __in PUNICODE_STRING Source, - __out PUNICODE_STRING Destination, - __out_opt PULONG ReturnedLength + _In_opt_ PVOID Environment, + _In_ PUNICODE_STRING Source, + _Out_ PUNICODE_STRING Destination, + _Out_opt_ PULONG ReturnedLength ); NTSYSAPI NTSTATUS NTAPI RtlSetEnvironmentStrings( - __in PWCHAR NewEnvironment, - __in SIZE_T NewEnvironmentSize + _In_ PWCHAR NewEnvironment, + _In_ SIZE_T NewEnvironmentSize ); // Current directory and paths @@ -2916,24 +2916,24 @@ NTSYSAPI RTL_PATH_TYPE NTAPI RtlDetermineDosPathNameType_U( - __in PWSTR DosFileName + _In_ PWSTR DosFileName ); NTSYSAPI ULONG NTAPI RtlIsDosDeviceName_U( - __in PWSTR DosFileName + _In_ PWSTR DosFileName ); NTSYSAPI ULONG NTAPI RtlGetFullPathName_U( - __in PWSTR FileName, - __in ULONG BufferLength, - __out_bcount(BufferLength) PWSTR Buffer, - __out_opt PWSTR *FilePart + _In_ PWSTR FileName, + _In_ ULONG BufferLength, + _Out_writes_bytes_(BufferLength) PWSTR Buffer, + _Out_opt_ PWSTR *FilePart ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -2942,11 +2942,11 @@ NTSYSAPI NTSTATUS NTAPI RtlGetFullPathName_UEx( - __in PWSTR FileName, - __in ULONG BufferLength, - __out_bcount(BufferLength) PWSTR Buffer, - __out_opt PWSTR *FilePart, - __out_opt RTL_PATH_TYPE *InputPathType + _In_ PWSTR FileName, + _In_ ULONG BufferLength, + _Out_writes_bytes_(BufferLength) PWSTR Buffer, + _Out_opt_ PWSTR *FilePart, + _Out_opt_ RTL_PATH_TYPE *InputPathType ); #endif @@ -2955,14 +2955,14 @@ NTSYSAPI NTSTATUS NTAPI RtlGetFullPathName_UstrEx( - __in PUNICODE_STRING FileName, - __inout PUNICODE_STRING StaticString, - __out_opt PUNICODE_STRING DynamicString, - __out_opt PUNICODE_STRING *StringUsed, - __out_opt SIZE_T *FilePartPrefixCch, - __out_opt PBOOLEAN NameInvalid, - __out RTL_PATH_TYPE *InputPathType, - __out_opt SIZE_T *BytesRequired + _In_ PUNICODE_STRING FileName, + _Inout_ PUNICODE_STRING StaticString, + _Out_opt_ PUNICODE_STRING DynamicString, + _Out_opt_ PUNICODE_STRING *StringUsed, + _Out_opt_ SIZE_T *FilePartPrefixCch, + _Out_opt_ PBOOLEAN NameInvalid, + _Out_ RTL_PATH_TYPE *InputPathType, + _Out_opt_ SIZE_T *BytesRequired ); #endif @@ -2970,15 +2970,15 @@ NTSYSAPI ULONG NTAPI RtlGetCurrentDirectory_U( - __in ULONG BufferLength, - __out_bcount(BufferLength) PWSTR Buffer + _In_ ULONG BufferLength, + _Out_writes_bytes_(BufferLength) PWSTR Buffer ); NTSYSAPI NTSTATUS NTAPI RtlSetCurrentDirectory_U( - __in PUNICODE_STRING PathName + _In_ PUNICODE_STRING PathName ); NTSYSAPI @@ -2992,10 +2992,10 @@ NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U( - __in PWSTR DosFileName, - __out PUNICODE_STRING NtFileName, - __out_opt PWSTR *FilePart, - __out_opt PRTL_RELATIVE_NAME_U RelativeName + _In_ PWSTR DosFileName, + _Out_ PUNICODE_STRING NtFileName, + _Out_opt_ PWSTR *FilePart, + _Out_opt_ PRTL_RELATIVE_NAME_U RelativeName ); #if (PHNT_VERSION >= PHNT_WS03) @@ -3003,10 +3003,10 @@ NTSYSAPI NTSTATUS NTAPI RtlDosPathNameToNtPathName_U_WithStatus( - __in PWSTR DosFileName, - __out PUNICODE_STRING NtFileName, - __out_opt PWSTR *FilePart, - __out_opt PRTL_RELATIVE_NAME_U RelativeName + _In_ PWSTR DosFileName, + _Out_ PUNICODE_STRING NtFileName, + _Out_opt_ PWSTR *FilePart, + _Out_opt_ PRTL_RELATIVE_NAME_U RelativeName ); #endif @@ -3015,10 +3015,10 @@ NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToRelativeNtPathName_U( - __in PWSTR DosFileName, - __out PUNICODE_STRING NtFileName, - __out_opt PWSTR *FilePart, - __out_opt PRTL_RELATIVE_NAME_U RelativeName + _In_ PWSTR DosFileName, + _Out_ PUNICODE_STRING NtFileName, + _Out_opt_ PWSTR *FilePart, + _Out_opt_ PRTL_RELATIVE_NAME_U RelativeName ); #endif @@ -3027,10 +3027,10 @@ NTSYSAPI NTSTATUS NTAPI RtlDosPathNameToRelativeNtPathName_U_WithStatus( - __in PWSTR DosFileName, - __out PUNICODE_STRING NtFileName, - __out_opt PWSTR *FilePart, - __out_opt PRTL_RELATIVE_NAME_U RelativeName + _In_ PWSTR DosFileName, + _Out_ PUNICODE_STRING NtFileName, + _Out_opt_ PWSTR *FilePart, + _Out_opt_ PRTL_RELATIVE_NAME_U RelativeName ); #endif @@ -3039,7 +3039,7 @@ NTSYSAPI VOID NTAPI RtlReleaseRelativeName( - __inout PRTL_RELATIVE_NAME_U RelativeName + _Inout_ PRTL_RELATIVE_NAME_U RelativeName ); #endif @@ -3047,12 +3047,12 @@ NTSYSAPI ULONG NTAPI RtlDosSearchPath_U( - __in PWSTR Path, - __in PWSTR FileName, - __in_opt PWSTR Extension, - __in ULONG BufferLength, - __out_bcount(BufferLength) PWSTR Buffer, - __out_opt PWSTR *FilePart + _In_ PWSTR Path, + _In_ PWSTR FileName, + _In_opt_ PWSTR Extension, + _In_ ULONG BufferLength, + _Out_writes_bytes_(BufferLength) PWSTR Buffer, + _Out_opt_ PWSTR *FilePart ); #define RTL_DOS_SEARCH_PATH_FLAG_APPLY_ISOLATION_REDIRECTION 0x00000001 @@ -3063,22 +3063,22 @@ NTSYSAPI NTSTATUS NTAPI RtlDosSearchPath_Ustr( - __in ULONG Flags, - __in PUNICODE_STRING Path, - __in PUNICODE_STRING FileName, - __in_opt PUNICODE_STRING DefaultExtension, - __out_opt PUNICODE_STRING StaticString, - __out_opt PUNICODE_STRING DynamicString, - __out_opt PCUNICODE_STRING *FullFileNameOut, - __out_opt SIZE_T *FilePartPrefixCch, - __out_opt SIZE_T *BytesRequired + _In_ ULONG Flags, + _In_ PUNICODE_STRING Path, + _In_ PUNICODE_STRING FileName, + _In_opt_ PUNICODE_STRING DefaultExtension, + _Out_opt_ PUNICODE_STRING StaticString, + _Out_opt_ PUNICODE_STRING DynamicString, + _Out_opt_ PCUNICODE_STRING *FullFileNameOut, + _Out_opt_ SIZE_T *FilePartPrefixCch, + _Out_opt_ SIZE_T *BytesRequired ); NTSYSAPI BOOLEAN NTAPI RtlDoesFileExists_U( - __in PWSTR FileName + _In_ PWSTR FileName ); // Heaps @@ -3147,9 +3147,9 @@ typedef struct _RTL_PROCESS_HEAPS } RTL_PROCESS_HEAPS, *PRTL_PROCESS_HEAPS; typedef NTSTATUS (NTAPI *PRTL_HEAP_COMMIT_ROUTINE)( - __in PVOID Base, - __inout PVOID *CommitAddress, - __inout PSIZE_T CommitSize + _In_ PVOID Base, + _Inout_ PVOID *CommitAddress, + _Inout_ PSIZE_T CommitSize ); typedef struct _RTL_HEAP_PARAMETERS @@ -3188,62 +3188,62 @@ NTSYSAPI PVOID NTAPI RtlCreateHeap( - __in ULONG Flags, - __in_opt PVOID HeapBase, - __in_opt SIZE_T ReserveSize, - __in_opt SIZE_T CommitSize, - __in_opt PVOID Lock, - __in_opt PRTL_HEAP_PARAMETERS Parameters + _In_ ULONG Flags, + _In_opt_ PVOID HeapBase, + _In_opt_ SIZE_T ReserveSize, + _In_opt_ SIZE_T CommitSize, + _In_opt_ PVOID Lock, + _In_opt_ PRTL_HEAP_PARAMETERS Parameters ); NTSYSAPI PVOID NTAPI RtlDestroyHeap( - __in __post_invalid PVOID HeapHandle + _In_ _Post_invalid_ PVOID HeapHandle ); NTSYSAPI PVOID NTAPI RtlAllocateHeap( - __in PVOID HeapHandle, - __in_opt ULONG Flags, - __in SIZE_T Size + _In_ PVOID HeapHandle, + _In_opt_ ULONG Flags, + _In_ SIZE_T Size ); NTSYSAPI BOOLEAN NTAPI RtlFreeHeap( - __in PVOID HeapHandle, - __in_opt ULONG Flags, - __in __post_invalid PVOID BaseAddress + _In_ PVOID HeapHandle, + _In_opt_ ULONG Flags, + _In_ _Post_invalid_ PVOID BaseAddress ); NTSYSAPI SIZE_T NTAPI RtlSizeHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in PVOID BaseAddress + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress ); NTSYSAPI NTSTATUS NTAPI RtlZeroHeap( - __in PVOID HeapHandle, - __in ULONG Flags + _In_ PVOID HeapHandle, + _In_ ULONG Flags ); NTSYSAPI VOID NTAPI RtlProtectHeap( - __in PVOID HeapHandle, - __in BOOLEAN MakeReadOnly + _In_ PVOID HeapHandle, + _In_ BOOLEAN MakeReadOnly ); #define RtlProcessHeap() (NtCurrentPeb()->ProcessHeap) @@ -3252,56 +3252,56 @@ NTSYSAPI BOOLEAN NTAPI RtlLockHeap( - __in PVOID HeapHandle + _In_ PVOID HeapHandle ); NTSYSAPI BOOLEAN NTAPI RtlUnlockHeap( - __in PVOID HeapHandle + _In_ PVOID HeapHandle ); NTSYSAPI PVOID NTAPI RtlReAllocateHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in PVOID BaseAddress, - __in SIZE_T Size + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress, + _In_ SIZE_T Size ); NTSYSAPI BOOLEAN NTAPI RtlGetUserInfoHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in PVOID BaseAddress, - __out_opt PVOID *UserValue, - __out_opt PULONG UserFlags + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress, + _Out_opt_ PVOID *UserValue, + _Out_opt_ PULONG UserFlags ); NTSYSAPI BOOLEAN NTAPI RtlSetUserValueHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in PVOID BaseAddress, - __in PVOID UserValue + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress, + _In_ PVOID UserValue ); NTSYSAPI BOOLEAN NTAPI RtlSetUserFlagsHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in PVOID BaseAddress, - __in ULONG UserFlagsReset, - __in ULONG UserFlagsSet + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress, + _In_ ULONG UserFlagsReset, + _In_ ULONG UserFlagsSet ); typedef struct _RTL_HEAP_TAG_INFO @@ -3317,48 +3317,48 @@ NTSYSAPI ULONG NTAPI RtlCreateTagHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in_opt PWSTR TagPrefix, - __in PWSTR TagNames + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_opt_ PWSTR TagPrefix, + _In_ PWSTR TagNames ); NTSYSAPI PWSTR NTAPI RtlQueryTagHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in USHORT TagIndex, - __in BOOLEAN ResetCounters, - __out_opt PRTL_HEAP_TAG_INFO TagInfo + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ USHORT TagIndex, + _In_ BOOLEAN ResetCounters, + _Out_opt_ PRTL_HEAP_TAG_INFO TagInfo ); NTSYSAPI NTSTATUS NTAPI RtlExtendHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in PVOID Base, - __in SIZE_T Size + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ PVOID Base, + _In_ SIZE_T Size ); NTSYSAPI SIZE_T NTAPI RtlCompactHeap( - __in PVOID HeapHandle, - __in ULONG Flags + _In_ PVOID HeapHandle, + _In_ ULONG Flags ); NTSYSAPI BOOLEAN NTAPI RtlValidateHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in PVOID BaseAddress + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress ); NTSYSAPI @@ -3372,21 +3372,21 @@ NTSYSAPI ULONG NTAPI RtlGetProcessHeaps( - __in ULONG NumberOfHeaps, - __out PVOID *ProcessHeaps + _In_ ULONG NumberOfHeaps, + _Out_ PVOID *ProcessHeaps ); typedef NTSTATUS (NTAPI *PRTL_ENUM_HEAPS_ROUTINE)( - __in PVOID HeapHandle, - __in PVOID Parameter + _In_ PVOID HeapHandle, + _In_ PVOID Parameter ); NTSYSAPI NTSTATUS NTAPI RtlEnumProcessHeaps( - __in PRTL_ENUM_HEAPS_ROUTINE EnumRoutine, - __in PVOID Parameter + _In_ PRTL_ENUM_HEAPS_ROUTINE EnumRoutine, + _In_ PVOID Parameter ); typedef struct _RTL_HEAP_USAGE_ENTRY @@ -3418,9 +3418,9 @@ NTSYSAPI NTSTATUS NTAPI RtlUsageHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __inout PRTL_HEAP_USAGE Usage + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _Inout_ PRTL_HEAP_USAGE Usage ); typedef struct _RTL_HEAP_WALK_ENTRY @@ -3453,8 +3453,8 @@ NTSYSAPI NTSTATUS NTAPI RtlWalkHeap( - __in PVOID HeapHandle, - __inout PRTL_HEAP_WALK_ENTRY Entry + _In_ PVOID HeapHandle, + _Inout_ PRTL_HEAP_WALK_ENTRY Entry ); // rev @@ -3462,12 +3462,12 @@ RtlWalkHeap( // rev typedef NTSTATUS (NTAPI *PRTL_HEAP_LEAK_ENUMERATION_ROUTINE)( - __in LONG Reserved, - __in PVOID HeapHandle, - __in PVOID BaseAddress, - __in SIZE_T BlockSize, - __in ULONG StackTraceDepth, - __in PVOID *StackTrace + _In_ LONG Reserved, + _In_ PVOID HeapHandle, + _In_ PVOID BaseAddress, + _In_ SIZE_T BlockSize, + _In_ ULONG StackTraceDepth, + _In_ PVOID *StackTrace ); // symbols @@ -3486,42 +3486,42 @@ NTSYSAPI NTSTATUS NTAPI RtlQueryHeapInformation( - __in PVOID HeapHandle, - __in HEAP_INFORMATION_CLASS HeapInformationClass, - __out_opt PVOID HeapInformation, - __in_opt SIZE_T HeapInformationLength, - __out_opt PSIZE_T ReturnLength + _In_ PVOID HeapHandle, + _In_ HEAP_INFORMATION_CLASS HeapInformationClass, + _Out_opt_ PVOID HeapInformation, + _In_opt_ SIZE_T HeapInformationLength, + _Out_opt_ PSIZE_T ReturnLength ); NTSYSAPI NTSTATUS NTAPI RtlSetHeapInformation( - __in PVOID HeapHandle, - __in HEAP_INFORMATION_CLASS HeapInformationClass, - __in_opt PVOID HeapInformation, - __in_opt SIZE_T HeapInformationLength + _In_ PVOID HeapHandle, + _In_ HEAP_INFORMATION_CLASS HeapInformationClass, + _In_opt_ PVOID HeapInformation, + _In_opt_ SIZE_T HeapInformationLength ); NTSYSAPI ULONG NTAPI RtlMultipleAllocateHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in SIZE_T Size, - __in ULONG Count, - __out PVOID *Array + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ SIZE_T Size, + _In_ ULONG Count, + _Out_ PVOID *Array ); NTSYSAPI ULONG NTAPI RtlMultipleFreeHeap( - __in PVOID HeapHandle, - __in ULONG Flags, - __in ULONG Count, - __in PVOID *Array + _In_ PVOID HeapHandle, + _In_ ULONG Flags, + _In_ ULONG Count, + _In_ PVOID *Array ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -3559,46 +3559,46 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateMemoryZone( - __out PVOID *MemoryZone, - __in SIZE_T InitialSize, - __reserved ULONG Flags + _Out_ PVOID *MemoryZone, + _In_ SIZE_T InitialSize, + _Reserved_ ULONG Flags ); NTSYSAPI NTSTATUS NTAPI RtlDestroyMemoryZone( - __in __post_invalid PVOID MemoryZone + _In_ _Post_invalid_ PVOID MemoryZone ); NTSYSAPI NTSTATUS NTAPI RtlAllocateMemoryZone( - __in PVOID MemoryZone, - __in SIZE_T BlockSize, - __out PVOID *Block + _In_ PVOID MemoryZone, + _In_ SIZE_T BlockSize, + _Out_ PVOID *Block ); NTSYSAPI NTSTATUS NTAPI RtlResetMemoryZone( - __in PVOID MemoryZone + _In_ PVOID MemoryZone ); NTSYSAPI NTSTATUS NTAPI RtlLockMemoryZone( - __in PVOID MemoryZone + _In_ PVOID MemoryZone ); NTSYSAPI NTSTATUS NTAPI RtlUnlockMemoryZone( - __in PVOID MemoryZone + _In_ PVOID MemoryZone ); #endif @@ -3615,64 +3615,64 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateMemoryBlockLookaside( - __out PVOID *MemoryBlockLookaside, - __reserved ULONG Flags, - __in ULONG InitialSize, - __in ULONG MinimumBlockSize, - __in ULONG MaximumBlockSize + _Out_ PVOID *MemoryBlockLookaside, + _Reserved_ ULONG Flags, + _In_ ULONG InitialSize, + _In_ ULONG MinimumBlockSize, + _In_ ULONG MaximumBlockSize ); NTSYSAPI NTSTATUS NTAPI RtlDestroyMemoryBlockLookaside( - __in PVOID MemoryBlockLookaside + _In_ PVOID MemoryBlockLookaside ); NTSYSAPI NTSTATUS NTAPI RtlAllocateMemoryBlockLookaside( - __in PVOID MemoryBlockLookaside, - __in ULONG BlockSize, - __out PVOID *Block + _In_ PVOID MemoryBlockLookaside, + _In_ ULONG BlockSize, + _Out_ PVOID *Block ); NTSYSAPI NTSTATUS NTAPI RtlFreeMemoryBlockLookaside( - __in PVOID MemoryBlockLookaside, - __in PVOID Block + _In_ PVOID MemoryBlockLookaside, + _In_ PVOID Block ); NTSYSAPI NTSTATUS NTAPI RtlExtendMemoryBlockLookaside( - __in PVOID MemoryBlockLookaside, - __in ULONG Increment + _In_ PVOID MemoryBlockLookaside, + _In_ ULONG Increment ); NTSYSAPI NTSTATUS NTAPI RtlResetMemoryBlockLookaside( - __in PVOID MemoryBlockLookaside + _In_ PVOID MemoryBlockLookaside ); NTSYSAPI NTSTATUS NTAPI RtlLockMemoryBlockLookaside( - __in PVOID MemoryBlockLookaside + _In_ PVOID MemoryBlockLookaside ); NTSYSAPI NTSTATUS NTAPI RtlUnlockMemoryBlockLookaside( - __in PVOID MemoryBlockLookaside + _In_ PVOID MemoryBlockLookaside ); #endif @@ -3697,15 +3697,15 @@ NTSYSAPI LOGICAL NTAPI RtlSetCurrentTransaction( - __in HANDLE TransactionHandle + _In_ HANDLE TransactionHandle ); #endif // LUIDs FORCEINLINE BOOLEAN RtlIsEqualLuid( - __in PLUID L1, - __in PLUID L2 + _In_ PLUID L1, + _In_ PLUID L2 ) { return L1->LowPart == L2->LowPart && @@ -3713,14 +3713,14 @@ FORCEINLINE BOOLEAN RtlIsEqualLuid( } FORCEINLINE BOOLEAN RtlIsZeroLuid( - __in PLUID L1 + _In_ PLUID L1 ) { return (L1->LowPart | L1->HighPart) == 0; } FORCEINLINE LUID RtlConvertLongToLuid( - __in LONG Long + _In_ LONG Long ) { LUID tempLuid; @@ -3734,7 +3734,7 @@ FORCEINLINE LUID RtlConvertLongToLuid( } FORCEINLINE LUID RtlConvertUlongToLuid( - __in ULONG Ulong + _In_ ULONG Ulong ) { LUID tempLuid; @@ -3749,8 +3749,8 @@ NTSYSAPI VOID NTAPI RtlCopyLuid( - __out PLUID DestinationLuid, - __in PLUID SourceLuid + _Out_ PLUID DestinationLuid, + _In_ PLUID SourceLuid ); // Debugging @@ -3799,15 +3799,15 @@ NTSYSAPI PRTL_DEBUG_INFORMATION NTAPI RtlCreateQueryDebugBuffer( - __in_opt ULONG MaximumCommit, - __in BOOLEAN UseEventPair + _In_opt_ ULONG MaximumCommit, + _In_ BOOLEAN UseEventPair ); NTSYSAPI NTSTATUS NTAPI RtlDestroyQueryDebugBuffer( - __in PRTL_DEBUG_INFORMATION Buffer + _In_ PRTL_DEBUG_INFORMATION Buffer ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -3817,8 +3817,8 @@ NTSYSAPI PVOID NTAPI RtlCommitDebugInfo( - __inout PRTL_DEBUG_INFORMATION Buffer, - __in SIZE_T Size + _Inout_ PRTL_DEBUG_INFORMATION Buffer, + _In_ SIZE_T Size ); // private @@ -3826,9 +3826,9 @@ NTSYSAPI VOID NTAPI RtlDeCommitDebugInfo( - __inout PRTL_DEBUG_INFORMATION Buffer, - __in PVOID p, - __in SIZE_T Size + _Inout_ PRTL_DEBUG_INFORMATION Buffer, + _In_ PVOID p, + _In_ SIZE_T Size ); #endif @@ -3850,9 +3850,9 @@ NTSYSAPI NTSTATUS NTAPI RtlQueryProcessDebugInformation( - __in HANDLE UniqueProcessId, - __in ULONG Flags, - __inout PRTL_DEBUG_INFORMATION Buffer + _In_ HANDLE UniqueProcessId, + _In_ ULONG Flags, + _Inout_ PRTL_DEBUG_INFORMATION Buffer ); // Messages @@ -3861,26 +3861,26 @@ NTSYSAPI NTSTATUS NTAPI RtlFindMessage( - __in PVOID DllHandle, - __in ULONG MessageTableId, - __in ULONG MessageLanguageId, - __in ULONG MessageId, - __out PMESSAGE_RESOURCE_ENTRY *MessageEntry + _In_ PVOID DllHandle, + _In_ ULONG MessageTableId, + _In_ ULONG MessageLanguageId, + _In_ ULONG MessageId, + _Out_ PMESSAGE_RESOURCE_ENTRY *MessageEntry ); NTSYSAPI NTSTATUS NTAPI RtlFormatMessage( - __in PWSTR MessageFormat, - __in ULONG MaximumWidth, - __in BOOLEAN IgnoreInserts, - __in BOOLEAN ArgumentsAreAnsi, - __in BOOLEAN ArgumentsAreAnArray, - __in va_list *Arguments, - __out_bcount_part(Length, *ReturnLength) PWSTR Buffer, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ PWSTR MessageFormat, + _In_ ULONG MaximumWidth, + _In_ BOOLEAN IgnoreInserts, + _In_ BOOLEAN ArgumentsAreAnsi, + _In_ BOOLEAN ArgumentsAreAnArray, + _In_ va_list *Arguments, + _Out_writes_bytes_to_(Length, *ReturnLength) PWSTR Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); typedef struct _PARSE_MESSAGE_CONTEXT @@ -3906,16 +3906,16 @@ NTSYSAPI NTSTATUS NTAPI RtlFormatMessageEx( - __in PWSTR MessageFormat, - __in ULONG MaximumWidth, - __in BOOLEAN IgnoreInserts, - __in BOOLEAN ArgumentsAreAnsi, - __in BOOLEAN ArgumentsAreAnArray, - __in va_list *Arguments, - __out_bcount_part(Length, *ReturnLength) PWSTR Buffer, - __in ULONG Length, - __out_opt PULONG ReturnLength, - __out_opt PPARSE_MESSAGE_CONTEXT ParseContext + _In_ PWSTR MessageFormat, + _In_ ULONG MaximumWidth, + _In_ BOOLEAN IgnoreInserts, + _In_ BOOLEAN ArgumentsAreAnsi, + _In_ BOOLEAN ArgumentsAreAnArray, + _In_ va_list *Arguments, + _Out_writes_bytes_to_(Length, *ReturnLength) PWSTR Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength, + _Out_opt_ PPARSE_MESSAGE_CONTEXT ParseContext ); // Errors @@ -3924,14 +3924,14 @@ NTSYSAPI ULONG NTAPI RtlNtStatusToDosError( - __in NTSTATUS Status + _In_ NTSTATUS Status ); NTSYSAPI ULONG NTAPI RtlNtStatusToDosErrorNoTeb( - __in NTSTATUS Status + _In_ NTSTATUS Status ); NTSYSAPI @@ -3952,21 +3952,21 @@ NTSYSAPI VOID NTAPI RtlSetLastWin32ErrorAndNtStatusFromNtStatus( - __in NTSTATUS Status + _In_ NTSTATUS Status ); NTSYSAPI VOID NTAPI RtlSetLastWin32Error( - __in LONG Win32Error + _In_ LONG Win32Error ); NTSYSAPI VOID NTAPI RtlRestoreLastWin32Error( - __in LONG Win32Error + _In_ LONG Win32Error ); #define RTL_ERRORMODE_NOGPFAULTERRORBOX 0x0020 @@ -3983,8 +3983,8 @@ NTSYSAPI NTSTATUS NTAPI RtlSetThreadErrorMode( - __in ULONG NewMode, - __out_opt PULONG OldMode + _In_ ULONG NewMode, + _Out_opt_ PULONG OldMode ); // Windows Error Reporting @@ -3995,9 +3995,9 @@ NTSYSAPI NTSTATUS NTAPI RtlReportException( - __in PEXCEPTION_RECORD ExceptionRecord, - __in PCONTEXT ContextRecord, - __in ULONG Flags + _In_ PEXCEPTION_RECORD ExceptionRecord, + _In_ PCONTEXT ContextRecord, + _In_ ULONG Flags ); #endif @@ -4007,10 +4007,10 @@ NTSYSAPI NTSTATUS NTAPI RtlWerpReportException( - __in ULONG ProcessId, - __in HANDLE CrashReportSharedMem, - __in ULONG Flags, - __out PHANDLE CrashVerticalProcessHandle + _In_ ULONG ProcessId, + _In_ HANDLE CrashReportSharedMem, + _In_ ULONG Flags, + _Out_ PHANDLE CrashVerticalProcessHandle ); #endif @@ -4020,8 +4020,8 @@ NTSYSAPI NTSTATUS NTAPI RtlReportSilentProcessExit( - __in HANDLE ProcessHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ProcessHandle, + _In_ NTSTATUS ExitStatus ); #endif @@ -4031,30 +4031,30 @@ NTSYSAPI PVOID NTAPI RtlAddVectoredExceptionHandler( - __in ULONG First, - __in PVECTORED_EXCEPTION_HANDLER Handler + _In_ ULONG First, + _In_ PVECTORED_EXCEPTION_HANDLER Handler ); NTSYSAPI ULONG NTAPI RtlRemoveVectoredExceptionHandler( - __in PVOID Handle + _In_ PVOID Handle ); NTSYSAPI PVOID NTAPI RtlAddVectoredContinueHandler( - __in ULONG First, - __in PVECTORED_EXCEPTION_HANDLER Handler + _In_ ULONG First, + _In_ PVECTORED_EXCEPTION_HANDLER Handler ); NTSYSAPI ULONG NTAPI RtlRemoveVectoredContinueHandler( - __in PVOID Handle + _In_ PVOID Handle ); // Random @@ -4063,30 +4063,30 @@ NTSYSAPI ULONG NTAPI RtlUniform( - __inout PULONG Seed + _Inout_ PULONG Seed ); NTSYSAPI ULONG NTAPI RtlRandom( - __inout PULONG Seed + _Inout_ PULONG Seed ); NTSYSAPI ULONG NTAPI RtlRandomEx( - __inout PULONG Seed + _Inout_ PULONG Seed ); NTSYSAPI NTSTATUS NTAPI RtlComputeImportTableHash( - __in HANDLE hFile, - __out_bcount(16) PCHAR Hash, - __in ULONG ImportTableHashRevision // must be 1 + _In_ HANDLE hFile, + _Out_writes_bytes_(16) PCHAR Hash, + _In_ ULONG ImportTableHashRevision // must be 1 ); // Integer conversion @@ -4095,47 +4095,47 @@ NTSYSAPI NTSTATUS NTAPI RtlIntegerToChar( - __in ULONG Value, - __in_opt ULONG Base, - __in LONG OutputLength, // negative to pad to width - __out PSTR String + _In_ ULONG Value, + _In_opt_ ULONG Base, + _In_ LONG OutputLength, // negative to pad to width + _Out_ PSTR String ); NTSYSAPI NTSTATUS NTAPI RtlCharToInteger( - __in PSTR String, - __in_opt ULONG Base, - __out PULONG Value + _In_ PSTR String, + _In_opt_ ULONG Base, + _Out_ PULONG Value ); NTSYSAPI NTSTATUS NTAPI RtlLargeIntegerToChar( - __in PLARGE_INTEGER Value, - __in_opt ULONG Base, - __in LONG OutputLength, - __out PSTR String + _In_ PLARGE_INTEGER Value, + _In_opt_ ULONG Base, + _In_ LONG OutputLength, + _Out_ PSTR String ); NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString( - __in ULONG Value, - __in_opt ULONG Base, - __inout PUNICODE_STRING String + _In_ ULONG Value, + _In_opt_ ULONG Base, + _Inout_ PUNICODE_STRING String ); NTSYSAPI NTSTATUS NTAPI RtlInt64ToUnicodeString( - __in ULONGLONG Value, - __in_opt ULONG Base, - __inout PUNICODE_STRING String + _In_ ULONGLONG Value, + _In_opt_ ULONG Base, + _Inout_ PUNICODE_STRING String ); #ifdef _M_X64 @@ -4148,9 +4148,9 @@ NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger( - __in PUNICODE_STRING String, - __in_opt ULONG Base, - __out PULONG Value + _In_ PUNICODE_STRING String, + _In_opt_ ULONG Base, + _Out_ PULONG Value ); // IPv4/6 conversion @@ -4162,76 +4162,76 @@ NTSYSAPI PWSTR NTAPI RtlIpv4AddressToStringW( - __in struct in_addr *Addr, - __out_ecount(16) PWSTR S + _In_ struct in_addr *Addr, + _Out_writes_(16) PWSTR S ); NTSYSAPI NTSTATUS NTAPI RtlIpv4AddressToStringExW( - __in struct in_addr *Address, - __in USHORT Port, - __out_ecount_part(*AddressStringLength, *AddressStringLength) PWSTR AddressString, - __inout PULONG AddressStringLength + _In_ struct in_addr *Address, + _In_ USHORT Port, + _Out_writes_to_(*AddressStringLength, *AddressStringLength) PWSTR AddressString, + _Inout_ PULONG AddressStringLength ); NTSYSAPI PWSTR NTAPI RtlIpv6AddressToStringW( - __in struct in6_addr *Addr, - __out_ecount(65) PWSTR S + _In_ struct in6_addr *Addr, + _Out_writes_(65) PWSTR S ); NTSYSAPI NTSTATUS NTAPI RtlIpv6AddressToStringExW( - __in struct in6_addr *Address, - __in ULONG ScopeId, - __in USHORT Port, - __out_ecount_part(*AddressStringLength, *AddressStringLength) PWSTR AddressString, - __inout PULONG AddressStringLength + _In_ struct in6_addr *Address, + _In_ ULONG ScopeId, + _In_ USHORT Port, + _Out_writes_to_(*AddressStringLength, *AddressStringLength) PWSTR AddressString, + _Inout_ PULONG AddressStringLength ); NTSYSAPI NTSTATUS NTAPI RtlIpv4StringToAddressW( - __in PWSTR S, - __in BOOLEAN Strict, - __out PWSTR *Terminator, - __out struct in_addr *Addr + _In_ PWSTR S, + _In_ BOOLEAN Strict, + _Out_ PWSTR *Terminator, + _Out_ struct in_addr *Addr ); NTSYSAPI NTSTATUS NTAPI RtlIpv4StringToAddressExW( - __in PWSTR AddressString, - __in BOOLEAN Strict, - __out struct in_addr *Address, - __out PUSHORT Port + _In_ PWSTR AddressString, + _In_ BOOLEAN Strict, + _Out_ struct in_addr *Address, + _Out_ PUSHORT Port ); NTSYSAPI NTSTATUS NTAPI RtlIpv6StringToAddressW( - __in PWSTR S, - __out PWSTR *Terminator, - __out struct in6_addr *Addr + _In_ PWSTR S, + _Out_ PWSTR *Terminator, + _Out_ struct in6_addr *Addr ); NTSYSAPI NTSTATUS NTAPI RtlIpv6StringToAddressExW( - __in PWSTR AddressString, - __out struct in6_addr *Address, - __out PULONG ScopeId, - __out PUSHORT Port + _In_ PWSTR AddressString, + _Out_ struct in6_addr *Address, + _Out_ PULONG ScopeId, + _Out_ PUSHORT Port ); #define RtlIpv4AddressToString RtlIpv4AddressToStringW @@ -4261,82 +4261,82 @@ NTSYSAPI BOOLEAN NTAPI RtlCutoverTimeToSystemTime( - __in PTIME_FIELDS CutoverTime, - __out PLARGE_INTEGER SystemTime, - __in PLARGE_INTEGER CurrentSystemTime, - __in BOOLEAN ThisYear + _In_ PTIME_FIELDS CutoverTime, + _Out_ PLARGE_INTEGER SystemTime, + _In_ PLARGE_INTEGER CurrentSystemTime, + _In_ BOOLEAN ThisYear ); NTSYSAPI NTSTATUS NTAPI RtlSystemTimeToLocalTime( - __in PLARGE_INTEGER SystemTime, - __out PLARGE_INTEGER LocalTime + _In_ PLARGE_INTEGER SystemTime, + _Out_ PLARGE_INTEGER LocalTime ); NTSYSAPI NTSTATUS NTAPI RtlLocalTimeToSystemTime( - __in PLARGE_INTEGER LocalTime, - __out PLARGE_INTEGER SystemTime + _In_ PLARGE_INTEGER LocalTime, + _Out_ PLARGE_INTEGER SystemTime ); NTSYSAPI VOID NTAPI RtlTimeToElapsedTimeFields( - __in PLARGE_INTEGER Time, - __out PTIME_FIELDS TimeFields + _In_ PLARGE_INTEGER Time, + _Out_ PTIME_FIELDS TimeFields ); NTSYSAPI VOID NTAPI RtlTimeToTimeFields( - __in PLARGE_INTEGER Time, - __out PTIME_FIELDS TimeFields + _In_ PLARGE_INTEGER Time, + _Out_ PTIME_FIELDS TimeFields ); NTSYSAPI BOOLEAN NTAPI RtlTimeFieldsToTime( - __in PTIME_FIELDS TimeFields, // Weekday is ignored - __out PLARGE_INTEGER Time + _In_ PTIME_FIELDS TimeFields, // Weekday is ignored + _Out_ PLARGE_INTEGER Time ); NTSYSAPI BOOLEAN NTAPI RtlTimeToSecondsSince1980( - __in PLARGE_INTEGER Time, - __out PULONG ElapsedSeconds + _In_ PLARGE_INTEGER Time, + _Out_ PULONG ElapsedSeconds ); NTSYSAPI VOID NTAPI RtlSecondsSince1980ToTime( - __in ULONG ElapsedSeconds, - __out PLARGE_INTEGER Time + _In_ ULONG ElapsedSeconds, + _Out_ PLARGE_INTEGER Time ); NTSYSAPI BOOLEAN NTAPI RtlTimeToSecondsSince1970( - __in PLARGE_INTEGER Time, - __out PULONG ElapsedSeconds + _In_ PLARGE_INTEGER Time, + _Out_ PULONG ElapsedSeconds ); NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime( - __in ULONG ElapsedSeconds, - __out PLARGE_INTEGER Time + _In_ ULONG ElapsedSeconds, + _Out_ PLARGE_INTEGER Time ); // Time zones @@ -4356,14 +4356,14 @@ NTSYSAPI NTSTATUS NTAPI RtlQueryTimeZoneInformation( - __out PRTL_TIME_ZONE_INFORMATION TimeZoneInformation + _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation ); NTSYSAPI NTSTATUS NTAPI RtlSetTimeZoneInformation( - __in PRTL_TIME_ZONE_INFORMATION TimeZoneInformation + _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation ); // Bitmaps @@ -4378,9 +4378,9 @@ NTSYSAPI VOID NTAPI RtlInitializeBitMap( - __out PRTL_BITMAP BitMapHeader, - __in PULONG BitMapBuffer, - __in ULONG SizeOfBitMap + _Out_ PRTL_BITMAP BitMapHeader, + _In_ PULONG BitMapBuffer, + _In_ ULONG SizeOfBitMap ); #if (PHNT_MODE == PHNT_MODE_KERNEL) @@ -4388,8 +4388,8 @@ NTSYSAPI VOID NTAPI RtlClearBit( - __in PRTL_BITMAP BitMapHeader, - __in_range(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber ); #endif @@ -4398,92 +4398,92 @@ NTSYSAPI VOID NTAPI RtlSetBit( - __in PRTL_BITMAP BitMapHeader, - __in_range(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber ); #endif -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlTestBit( - __in PRTL_BITMAP BitMapHeader, - __in_range(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber ); NTSYSAPI VOID NTAPI RtlClearAllBits( - __in PRTL_BITMAP BitMapHeader + _In_ PRTL_BITMAP BitMapHeader ); NTSYSAPI VOID NTAPI RtlSetAllBits( - __in PRTL_BITMAP BitMapHeader + _In_ PRTL_BITMAP BitMapHeader ); -__success(return != -1) -__checkReturn +_Success_(return != -1) +_Check_return_ NTSYSAPI ULONG NTAPI RtlFindClearBits( - __in PRTL_BITMAP BitMapHeader, - __in ULONG NumberToFind, - __in ULONG HintIndex + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG NumberToFind, + _In_ ULONG HintIndex ); -__success(return != -1) -__checkReturn +_Success_(return != -1) +_Check_return_ NTSYSAPI ULONG NTAPI RtlFindSetBits( - __in PRTL_BITMAP BitMapHeader, - __in ULONG NumberToFind, - __in ULONG HintIndex + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG NumberToFind, + _In_ ULONG HintIndex ); -__success(return != -1) +_Success_(return != -1) NTSYSAPI ULONG NTAPI RtlFindClearBitsAndSet( - __in PRTL_BITMAP BitMapHeader, - __in ULONG NumberToFind, - __in ULONG HintIndex + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG NumberToFind, + _In_ ULONG HintIndex ); -__success(return != -1) +_Success_(return != -1) NTSYSAPI ULONG NTAPI RtlFindSetBitsAndClear( - __in PRTL_BITMAP BitMapHeader, - __in ULONG NumberToFind, - __in ULONG HintIndex + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG NumberToFind, + _In_ ULONG HintIndex ); NTSYSAPI VOID NTAPI RtlClearBits( - __in PRTL_BITMAP BitMapHeader, - __in_range(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex, - __in_range(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex, + _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear ); NTSYSAPI VOID NTAPI RtlSetBits( - __in PRTL_BITMAP BitMapHeader, - __in_range(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex, - __in_range(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex, + _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet ); typedef struct _RTL_BITMAP_RUN @@ -4496,34 +4496,34 @@ NTSYSAPI ULONG NTAPI RtlFindClearRuns( - __in PRTL_BITMAP BitMapHeader, - __out_ecount_part(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray, - __in_range(>, 0) ULONG SizeOfRunArray, - __in BOOLEAN LocateLongestRuns + _In_ PRTL_BITMAP BitMapHeader, + _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray, + _In_range_(>, 0) ULONG SizeOfRunArray, + _In_ BOOLEAN LocateLongestRuns ); NTSYSAPI ULONG NTAPI RtlFindLongestRunClear( - __in PRTL_BITMAP BitMapHeader, - __out PULONG StartingIndex + _In_ PRTL_BITMAP BitMapHeader, + _Out_ PULONG StartingIndex ); NTSYSAPI ULONG NTAPI RtlFindFirstRunClear( - __in PRTL_BITMAP BitMapHeader, - __out PULONG StartingIndex + _In_ PRTL_BITMAP BitMapHeader, + _Out_ PULONG StartingIndex ); -__checkReturn +_Check_return_ FORCEINLINE BOOLEAN RtlCheckBit( - __in PRTL_BITMAP BitMapHeader, - __in_range(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition ) { #ifdef _M_IX86 @@ -4537,52 +4537,52 @@ NTSYSAPI ULONG NTAPI RtlNumberOfClearBits( - __in PRTL_BITMAP BitMapHeader + _In_ PRTL_BITMAP BitMapHeader ); NTSYSAPI ULONG NTAPI RtlNumberOfSetBits( - __in PRTL_BITMAP BitMapHeader + _In_ PRTL_BITMAP BitMapHeader ); -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlAreBitsClear( - __in PRTL_BITMAP BitMapHeader, - __in ULONG StartingIndex, - __in ULONG Length + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG StartingIndex, + _In_ ULONG Length ); -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlAreBitsSet( - __in PRTL_BITMAP BitMapHeader, - __in ULONG StartingIndex, - __in ULONG Length + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG StartingIndex, + _In_ ULONG Length ); NTSYSAPI ULONG NTAPI RtlFindNextForwardRunClear( - __in PRTL_BITMAP BitMapHeader, - __in ULONG FromIndex, - __out PULONG StartingRunIndex + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG FromIndex, + _Out_ PULONG StartingRunIndex ); NTSYSAPI ULONG NTAPI RtlFindLastBackwardRunClear( - __in PRTL_BITMAP BitMapHeader, - __in ULONG FromIndex, - __out PULONG StartingRunIndex + _In_ PRTL_BITMAP BitMapHeader, + _In_ ULONG FromIndex, + _Out_ PULONG StartingRunIndex ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -4592,9 +4592,9 @@ NTSYSAPI VOID NTAPI RtlInterlockedClearBitRun( - __in PRTL_BITMAP BitMapHeader, - __in_range(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex, - __in_range(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex, + _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear ); // rev @@ -4602,9 +4602,9 @@ NTSYSAPI VOID NTAPI RtlInterlockedSetBitRun( - __in PRTL_BITMAP BitMapHeader, - __in_range(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex, - __in_range(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet + _In_ PRTL_BITMAP BitMapHeader, + _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex, + _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet ); #endif @@ -4637,49 +4637,49 @@ NTSYSAPI VOID NTAPI RtlInitializeHandleTable( - __in ULONG MaximumNumberOfHandles, - __in ULONG SizeOfHandleTableEntry, - __out PRTL_HANDLE_TABLE HandleTable + _In_ ULONG MaximumNumberOfHandles, + _In_ ULONG SizeOfHandleTableEntry, + _Out_ PRTL_HANDLE_TABLE HandleTable ); NTSYSAPI NTSTATUS NTAPI RtlDestroyHandleTable( - __inout PRTL_HANDLE_TABLE HandleTable + _Inout_ PRTL_HANDLE_TABLE HandleTable ); NTSYSAPI PRTL_HANDLE_TABLE_ENTRY NTAPI RtlAllocateHandle( - __in PRTL_HANDLE_TABLE HandleTable, - __out_opt PULONG HandleIndex + _In_ PRTL_HANDLE_TABLE HandleTable, + _Out_opt_ PULONG HandleIndex ); NTSYSAPI BOOLEAN NTAPI RtlFreeHandle( - __in PRTL_HANDLE_TABLE HandleTable, - __in PRTL_HANDLE_TABLE_ENTRY Handle + _In_ PRTL_HANDLE_TABLE HandleTable, + _In_ PRTL_HANDLE_TABLE_ENTRY Handle ); NTSYSAPI BOOLEAN NTAPI RtlIsValidHandle( - __in PRTL_HANDLE_TABLE HandleTable, - __in PRTL_HANDLE_TABLE_ENTRY Handle + _In_ PRTL_HANDLE_TABLE HandleTable, + _In_ PRTL_HANDLE_TABLE_ENTRY Handle ); NTSYSAPI BOOLEAN NTAPI RtlIsValidIndexHandle( - __in PRTL_HANDLE_TABLE HandleTable, - __in ULONG HandleIndex, - __out PRTL_HANDLE_TABLE_ENTRY *Handle + _In_ PRTL_HANDLE_TABLE HandleTable, + _In_ ULONG HandleIndex, + _Out_ PRTL_HANDLE_TABLE_ENTRY *Handle ); // Atom tables @@ -4694,69 +4694,69 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateAtomTable( - __in ULONG NumberOfBuckets, - __out PVOID *AtomTableHandle + _In_ ULONG NumberOfBuckets, + _Out_ PVOID *AtomTableHandle ); NTSYSAPI NTSTATUS NTAPI RtlDestroyAtomTable( - __in __post_invalid PVOID AtomTableHandle + _In_ _Post_invalid_ PVOID AtomTableHandle ); NTSYSAPI NTSTATUS NTAPI RtlEmptyAtomTable( - __in PVOID AtomTableHandle, - __in BOOLEAN IncludePinnedAtoms + _In_ PVOID AtomTableHandle, + _In_ BOOLEAN IncludePinnedAtoms ); NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable( - __in PVOID AtomTableHandle, - __in PWSTR AtomName, - __inout_opt PRTL_ATOM Atom + _In_ PVOID AtomTableHandle, + _In_ PWSTR AtomName, + _Inout_opt_ PRTL_ATOM Atom ); NTSYSAPI NTSTATUS NTAPI RtlLookupAtomInAtomTable( - __in PVOID AtomTableHandle, - __in PWSTR AtomName, - __out_opt PRTL_ATOM Atom + _In_ PVOID AtomTableHandle, + _In_ PWSTR AtomName, + _Out_opt_ PRTL_ATOM Atom ); NTSYSAPI NTSTATUS NTAPI RtlDeleteAtomFromAtomTable( - __in PVOID AtomTableHandle, - __in RTL_ATOM Atom + _In_ PVOID AtomTableHandle, + _In_ RTL_ATOM Atom ); NTSYSAPI NTSTATUS NTAPI RtlPinAtomInAtomTable( - __in PVOID AtomTableHandle, - __in RTL_ATOM Atom + _In_ PVOID AtomTableHandle, + _In_ RTL_ATOM Atom ); NTSYSAPI NTSTATUS NTAPI RtlQueryAtomInAtomTable( - __in PVOID AtomTableHandle, - __in RTL_ATOM Atom, - __out_opt PULONG AtomUsage, - __out_opt PULONG AtomFlags, - __inout_bcount_part_opt(*AtomNameLength, *AtomNameLength) PWSTR AtomName, - __inout_opt PULONG AtomNameLength + _In_ PVOID AtomTableHandle, + _In_ RTL_ATOM Atom, + _Out_opt_ PULONG AtomUsage, + _Out_opt_ PULONG AtomFlags, + _Inout_updates_bytes_to_opt_(*AtomNameLength, *AtomNameLength) PWSTR AtomName, + _Inout_opt_ PULONG AtomNameLength ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -4765,107 +4765,107 @@ NTSYSAPI BOOLEAN NTAPI RtlGetIntegerAtom( - __in PWSTR AtomName, - __out_opt PUSHORT IntegerAtom + _In_ PWSTR AtomName, + _Out_opt_ PUSHORT IntegerAtom ); #endif // SIDs -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlValidSid( - __in PSID Sid + _In_ PSID Sid ); -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlEqualSid( - __in PSID Sid1, - __in PSID Sid2 + _In_ PSID Sid1, + _In_ PSID Sid2 ); NTSYSAPI ULONG NTAPI RtlLengthRequiredSid( - __in ULONG SubAuthorityCount + _In_ ULONG SubAuthorityCount ); NTSYSAPI PVOID NTAPI RtlFreeSid( - __in __post_invalid PSID Sid + _In_ _Post_invalid_ PSID Sid ); -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid( - __in PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, - __in UCHAR SubAuthorityCount, - __in ULONG SubAuthority0, - __in ULONG SubAuthority1, - __in ULONG SubAuthority2, - __in ULONG SubAuthority3, - __in ULONG SubAuthority4, - __in ULONG SubAuthority5, - __in ULONG SubAuthority6, - __in ULONG SubAuthority7, - __deref_out PSID *Sid + _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, + _In_ UCHAR SubAuthorityCount, + _In_ ULONG SubAuthority0, + _In_ ULONG SubAuthority1, + _In_ ULONG SubAuthority2, + _In_ ULONG SubAuthority3, + _In_ ULONG SubAuthority4, + _In_ ULONG SubAuthority5, + _In_ ULONG SubAuthority6, + _In_ ULONG SubAuthority7, + _Outptr_ PSID *Sid ); NTSYSAPI NTSTATUS NTAPI RtlInitializeSid( - __out PSID Sid, - __in PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, - __in UCHAR SubAuthorityCount + _Out_ PSID Sid, + _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, + _In_ UCHAR SubAuthorityCount ); NTSYSAPI PSID_IDENTIFIER_AUTHORITY NTAPI RtlIdentifierAuthoritySid( - __in PSID Sid + _In_ PSID Sid ); NTSYSAPI PULONG NTAPI RtlSubAuthoritySid( - __in PSID Sid, - __in ULONG SubAuthority + _In_ PSID Sid, + _In_ ULONG SubAuthority ); NTSYSAPI PUCHAR NTAPI RtlSubAuthorityCountSid( - __in PSID Sid + _In_ PSID Sid ); NTSYSAPI ULONG NTAPI RtlLengthSid( - __in PSID Sid + _In_ PSID Sid ); NTSYSAPI NTSTATUS NTAPI RtlCopySid( - __in ULONG DestinationSidLength, - __in_bcount(DestinationSidLength) PSID DestinationSid, - __in PSID SourceSid + _In_ ULONG DestinationSidLength, + _In_reads_bytes_(DestinationSidLength) PSID DestinationSid, + _In_ PSID SourceSid ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -4873,9 +4873,9 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateServiceSid( - __in PUNICODE_STRING ServiceName, - __out_bcount(*ServiceSidLength) PSID ServiceSid, - __inout PULONG ServiceSidLength + _In_ PUNICODE_STRING ServiceName, + _Out_writes_bytes_(*ServiceSidLength) PSID ServiceSid, + _Inout_ PULONG ServiceSidLength ); #endif @@ -4885,9 +4885,9 @@ NTSYSAPI NTSTATUS NTAPI RtlSidDominates( - __in PSID Sid1, - __in PSID Sid2, - __out PBOOLEAN pbDominate + _In_ PSID Sid1, + _In_ PSID Sid2, + _Out_ PBOOLEAN pbDominate ); #endif @@ -4897,9 +4897,9 @@ NTSYSAPI NTSTATUS NTAPI RtlSidEqualLevel( - __in PSID Sid1, - __in PSID Sid2, - __out PBOOLEAN pbEqual + _In_ PSID Sid1, + _In_ PSID Sid2, + _Out_ PBOOLEAN pbEqual ); #endif @@ -4909,9 +4909,9 @@ NTSYSAPI NTSTATUS NTAPI RtlSidIsHigherLevel( - __in PSID Sid1, - __in PSID Sid2, - __out PBOOLEAN pbHigher + _In_ PSID Sid1, + _In_ PSID Sid2, + _Out_ PBOOLEAN pbHigher ); #endif @@ -4920,10 +4920,10 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateVirtualAccountSid( - __in PUNICODE_STRING Name, - __in ULONG BaseSubAuthority, - __out_bcount(*SidLength) PSID Sid, - __inout PULONG SidLength + _In_ PUNICODE_STRING Name, + _In_ ULONG BaseSubAuthority, + _Out_writes_bytes_(*SidLength) PSID Sid, + _Inout_ PULONG SidLength ); #endif @@ -4932,10 +4932,10 @@ NTSYSAPI NTSTATUS NTAPI RtlReplaceSidInSd( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in PSID OldSid, - __in PSID NewSid, - __out ULONG *NumChanges + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ PSID OldSid, + _In_ PSID NewSid, + _Out_ ULONG *NumChanges ); #endif @@ -4945,9 +4945,9 @@ NTSYSAPI NTSTATUS NTAPI RtlConvertSidToUnicodeString( - __inout PUNICODE_STRING UnicodeString, - __in PSID Sid, - __in BOOLEAN AllocateDestinationString + _Inout_ PUNICODE_STRING UnicodeString, + _In_ PSID Sid, + _In_ BOOLEAN AllocateDestinationString ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -4956,9 +4956,9 @@ NTSYSAPI NTSTATUS NTAPI RtlSidHashInitialize( - __in_ecount(SidCount) PSID_AND_ATTRIBUTES SidAttr, - __in ULONG SidCount, - __out PSID_AND_ATTRIBUTES_HASH SidAttrHash + _In_reads_(SidCount) PSID_AND_ATTRIBUTES SidAttr, + _In_ ULONG SidCount, + _Out_ PSID_AND_ATTRIBUTES_HASH SidAttrHash ); #endif @@ -4968,8 +4968,8 @@ NTSYSAPI PSID_AND_ATTRIBUTES NTAPI RtlSidHashLookup( - __in PSID_AND_ATTRIBUTES_HASH SidAttrHash, - __in PSID Sid + _In_ PSID_AND_ATTRIBUTES_HASH SidAttrHash, + _In_ PSID Sid ); #endif @@ -4979,197 +4979,197 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor( - __out PSECURITY_DESCRIPTOR SecurityDescriptor, - __in ULONG Revision + _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ ULONG Revision ); -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlValidSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); NTSYSAPI ULONG NTAPI RtlLengthSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); -__checkReturn +_Check_return_ NTSYSAPI BOOLEAN NTAPI RtlValidRelativeSecurityDescriptor( - __in_bcount(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput, - __in ULONG SecurityDescriptorLength, - __in SECURITY_INFORMATION RequiredInformation + _In_reads_bytes_(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput, + _In_ ULONG SecurityDescriptorLength, + _In_ SECURITY_INFORMATION RequiredInformation ); NTSYSAPI NTSTATUS NTAPI RtlGetControlSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __out PSECURITY_DESCRIPTOR_CONTROL Control, - __out PULONG Revision + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _Out_ PSECURITY_DESCRIPTOR_CONTROL Control, + _Out_ PULONG Revision ); NTSYSAPI NTSTATUS NTAPI RtlSetControlSecurityDescriptor( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, - __in SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, + _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet ); NTSYSAPI NTSTATUS NTAPI RtlSetAttributesSecurityDescriptor( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in SECURITY_DESCRIPTOR_CONTROL Control, - __out PULONG Revision + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ SECURITY_DESCRIPTOR_CONTROL Control, + _Out_ PULONG Revision ); NTSYSAPI BOOLEAN NTAPI RtlGetSecurityDescriptorRMControl( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __out PUCHAR RMControl + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _Out_ PUCHAR RMControl ); NTSYSAPI VOID NTAPI RtlSetSecurityDescriptorRMControl( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PUCHAR RMControl + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PUCHAR RMControl ); NTSYSAPI NTSTATUS NTAPI RtlSetDaclSecurityDescriptor( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in BOOLEAN DaclPresent, - __in_opt PACL Dacl, - __in_opt BOOLEAN DaclDefaulted + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ BOOLEAN DaclPresent, + _In_opt_ PACL Dacl, + _In_opt_ BOOLEAN DaclDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlGetDaclSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __out PBOOLEAN DaclPresent, - __out PACL *Dacl, - __out PBOOLEAN DaclDefaulted + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _Out_ PBOOLEAN DaclPresent, + _Out_ PACL *Dacl, + _Out_ PBOOLEAN DaclDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlSetSaclSecurityDescriptor( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in BOOLEAN SaclPresent, - __in_opt PACL Sacl, - __in_opt BOOLEAN SaclDefaulted + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ BOOLEAN SaclPresent, + _In_opt_ PACL Sacl, + _In_opt_ BOOLEAN SaclDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlGetSaclSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __out PBOOLEAN SaclPresent, - __out PACL *Sacl, - __out PBOOLEAN SaclDefaulted + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _Out_ PBOOLEAN SaclPresent, + _Out_ PACL *Sacl, + _Out_ PBOOLEAN SaclDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlGetSaclSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __out PBOOLEAN SaclPresent, - __out PACL *Sacl, - __out PBOOLEAN SaclDefaulted + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _Out_ PBOOLEAN SaclPresent, + _Out_ PACL *Sacl, + _Out_ PBOOLEAN SaclDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlSetOwnerSecurityDescriptor( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID Owner, - __in_opt BOOLEAN OwnerDefaulted + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID Owner, + _In_opt_ BOOLEAN OwnerDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlGetOwnerSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __out PSID *Owner, - __out PBOOLEAN OwnerDefaulted + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _Out_ PSID *Owner, + _Out_ PBOOLEAN OwnerDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlSetGroupSecurityDescriptor( - __inout PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID Group, - __in_opt BOOLEAN GroupDefaulted + _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID Group, + _In_opt_ BOOLEAN GroupDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlGetGroupSecurityDescriptor( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __out PSID *Group, - __out PBOOLEAN GroupDefaulted + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _Out_ PSID *Group, + _Out_ PBOOLEAN GroupDefaulted ); NTSYSAPI NTSTATUS NTAPI RtlMakeSelfRelativeSD( - __in PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, - __out_bcount(*BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, - __inout PULONG BufferLength + _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, + _Out_writes_bytes_(*BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, + _Inout_ PULONG BufferLength ); NTSYSAPI NTSTATUS NTAPI RtlAbsoluteToSelfRelativeSD( - __in PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, - __out_bcount_part_opt(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, - __inout PULONG BufferLength + _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, + _Out_writes_bytes_to_opt_(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, + _Inout_ PULONG BufferLength ); NTSYSAPI NTSTATUS NTAPI RtlSelfRelativeToAbsoluteSD( - __in PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, - __out_bcount_part_opt(*AbsoluteSecurityDescriptorSize, *AbsoluteSecurityDescriptorSize) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, - __inout PULONG AbsoluteSecurityDescriptorSize, - __out_bcount_part_opt(*DaclSize, *DaclSize) PACL Dacl, - __inout PULONG DaclSize, - __out_bcount_part_opt(*SaclSize, *SaclSize) PACL Sacl, - __inout PULONG SaclSize, - __out_bcount_part_opt(*OwnerSize, *OwnerSize) PSID Owner, - __inout PULONG OwnerSize, - __out_bcount_part_opt(*PrimaryGroupSize, *PrimaryGroupSize) PSID PrimaryGroup, - __inout PULONG PrimaryGroupSize + _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor, + _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize, *AbsoluteSecurityDescriptorSize) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor, + _Inout_ PULONG AbsoluteSecurityDescriptorSize, + _Out_writes_bytes_to_opt_(*DaclSize, *DaclSize) PACL Dacl, + _Inout_ PULONG DaclSize, + _Out_writes_bytes_to_opt_(*SaclSize, *SaclSize) PACL Sacl, + _Inout_ PULONG SaclSize, + _Out_writes_bytes_to_opt_(*OwnerSize, *OwnerSize) PSID Owner, + _Inout_ PULONG OwnerSize, + _Out_writes_bytes_to_opt_(*PrimaryGroupSize, *PrimaryGroupSize) PSID PrimaryGroup, + _Inout_ PULONG PrimaryGroupSize ); // private @@ -5177,8 +5177,8 @@ NTSYSAPI NTSTATUS NTAPI RtlSelfRelativeToAbsoluteSD2( - __inout PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, - __inout PULONG pBufferSize + _Inout_ PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, + _Inout_ PULONG pBufferSize ); // Access masks @@ -5187,24 +5187,24 @@ NTSYSAPI BOOLEAN NTAPI RtlAreAllAccessesGranted( - __in ACCESS_MASK GrantedAccess, - __in ACCESS_MASK DesiredAccess + _In_ ACCESS_MASK GrantedAccess, + _In_ ACCESS_MASK DesiredAccess ); NTSYSAPI BOOLEAN NTAPI RtlAreAnyAccessesGranted( - __in ACCESS_MASK GrantedAccess, - __in ACCESS_MASK DesiredAccess + _In_ ACCESS_MASK GrantedAccess, + _In_ ACCESS_MASK DesiredAccess ); NTSYSAPI VOID NTAPI RtlMapGenericMask( - __inout PACCESS_MASK AccessMask, - __in PGENERIC_MAPPING GenericMapping + _Inout_ PACCESS_MASK AccessMask, + _In_ PGENERIC_MAPPING GenericMapping ); // ACLs @@ -5213,72 +5213,72 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateAcl( - __out_bcount(AclLength) PACL Acl, - __in ULONG AclLength, - __in ULONG AclRevision + _Out_writes_bytes_(AclLength) PACL Acl, + _In_ ULONG AclLength, + _In_ ULONG AclRevision ); NTSYSAPI BOOLEAN NTAPI RtlValidAcl( - __in PACL Acl + _In_ PACL Acl ); NTSYSAPI NTSTATUS NTAPI RtlQueryInformationAcl( - __in PACL Acl, - __out_bcount(AclInformationLength) PVOID AclInformation, - __in ULONG AclInformationLength, - __in ACL_INFORMATION_CLASS AclInformationClass + _In_ PACL Acl, + _Out_writes_bytes_(AclInformationLength) PVOID AclInformation, + _In_ ULONG AclInformationLength, + _In_ ACL_INFORMATION_CLASS AclInformationClass ); NTSYSAPI NTSTATUS NTAPI RtlSetInformationAcl( - __inout PACL Acl, - __in_bcount(AclInformationLength) PVOID AclInformation, - __in ULONG AclInformationLength, - __in ACL_INFORMATION_CLASS AclInformationClass + _Inout_ PACL Acl, + _In_reads_bytes_(AclInformationLength) PVOID AclInformation, + _In_ ULONG AclInformationLength, + _In_ ACL_INFORMATION_CLASS AclInformationClass ); NTSYSAPI NTSTATUS NTAPI RtlAddAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG StartingAceIndex, - __in_bcount(AceListLength) PVOID AceList, - __in ULONG AceListLength + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG StartingAceIndex, + _In_reads_bytes_(AceListLength) PVOID AceList, + _In_ ULONG AceListLength ); NTSYSAPI NTSTATUS NTAPI RtlDeleteAce( - __inout PACL Acl, - __in ULONG AceIndex + _Inout_ PACL Acl, + _In_ ULONG AceIndex ); NTSYSAPI NTSTATUS NTAPI RtlGetAce( - __in PACL Acl, - __in ULONG AceIndex, - __deref_out PVOID *Ace + _In_ PACL Acl, + _In_ ULONG AceIndex, + _Outptr_ PVOID *Ace ); NTSYSAPI BOOLEAN NTAPI RtlFirstFreeAce( - __in PACL Acl, - __out PVOID *FirstFree + _In_ PACL Acl, + _Out_ PVOID *FirstFree ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -5287,9 +5287,9 @@ NTSYSAPI PVOID NTAPI RtlFindAceByType( - __in PACL pAcl, - __in UCHAR AceType, - __out_opt PULONG pIndex + _In_ PACL pAcl, + _In_ UCHAR AceType, + _Out_opt_ PULONG pIndex ); #endif @@ -5299,7 +5299,7 @@ NTSYSAPI BOOLEAN NTAPI RtlOwnerAcesPresent( - __in PACL pAcl + _In_ PACL pAcl ); #endif @@ -5307,120 +5307,120 @@ NTSYSAPI NTSTATUS NTAPI RtlAddAccessAllowedAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ACCESS_MASK AccessMask, - __in PSID Sid + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ACCESS_MASK AccessMask, + _In_ PSID Sid ); NTSYSAPI NTSTATUS NTAPI RtlAddAccessAllowedAceEx( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG AceFlags, - __in ACCESS_MASK AccessMask, - __in PSID Sid + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG AceFlags, + _In_ ACCESS_MASK AccessMask, + _In_ PSID Sid ); NTSYSAPI NTSTATUS NTAPI RtlAddAccessDeniedAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ACCESS_MASK AccessMask, - __in PSID Sid + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ACCESS_MASK AccessMask, + _In_ PSID Sid ); NTSYSAPI NTSTATUS NTAPI RtlAddAccessDeniedAceEx( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG AceFlags, - __in ACCESS_MASK AccessMask, - __in PSID Sid + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG AceFlags, + _In_ ACCESS_MASK AccessMask, + _In_ PSID Sid ); NTSYSAPI NTSTATUS NTAPI RtlAddAuditAccessAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ACCESS_MASK AccessMask, - __in PSID Sid, - __in BOOLEAN AuditSuccess, - __in BOOLEAN AuditFailure + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ACCESS_MASK AccessMask, + _In_ PSID Sid, + _In_ BOOLEAN AuditSuccess, + _In_ BOOLEAN AuditFailure ); NTSYSAPI NTSTATUS NTAPI RtlAddAuditAccessAceEx( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG AceFlags, - __in ACCESS_MASK AccessMask, - __in PSID Sid, - __in BOOLEAN AuditSuccess, - __in BOOLEAN AuditFailure + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG AceFlags, + _In_ ACCESS_MASK AccessMask, + _In_ PSID Sid, + _In_ BOOLEAN AuditSuccess, + _In_ BOOLEAN AuditFailure ); NTSYSAPI NTSTATUS NTAPI RtlAddAccessAllowedObjectAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG AceFlags, - __in ACCESS_MASK AccessMask, - __in_opt PGUID ObjectTypeGuid, - __in_opt PGUID InheritedObjectTypeGuid, - __in PSID Sid + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG AceFlags, + _In_ ACCESS_MASK AccessMask, + _In_opt_ PGUID ObjectTypeGuid, + _In_opt_ PGUID InheritedObjectTypeGuid, + _In_ PSID Sid ); NTSYSAPI NTSTATUS NTAPI RtlAddAccessDeniedObjectAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG AceFlags, - __in ACCESS_MASK AccessMask, - __in_opt PGUID ObjectTypeGuid, - __in_opt PGUID InheritedObjectTypeGuid, - __in PSID Sid + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG AceFlags, + _In_ ACCESS_MASK AccessMask, + _In_opt_ PGUID ObjectTypeGuid, + _In_opt_ PGUID InheritedObjectTypeGuid, + _In_ PSID Sid ); NTSYSAPI NTSTATUS NTAPI RtlAddAuditAccessObjectAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG AceFlags, - __in ACCESS_MASK AccessMask, - __in_opt PGUID ObjectTypeGuid, - __in_opt PGUID InheritedObjectTypeGuid, - __in PSID Sid, - __in BOOLEAN AuditSuccess, - __in BOOLEAN AuditFailure + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG AceFlags, + _In_ ACCESS_MASK AccessMask, + _In_opt_ PGUID ObjectTypeGuid, + _In_opt_ PGUID InheritedObjectTypeGuid, + _In_ PSID Sid, + _In_ BOOLEAN AuditSuccess, + _In_ BOOLEAN AuditFailure ); NTSYSAPI NTSTATUS NTAPI RtlAddCompoundAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in UCHAR AceType, - __in ACCESS_MASK AccessMask, - __in PSID ServerSid, - __in PSID ClientSid + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ UCHAR AceType, + _In_ ACCESS_MASK AccessMask, + _In_ PSID ServerSid, + _In_ PSID ClientSid ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -5429,12 +5429,12 @@ NTSYSAPI NTSTATUS NTAPI RtlAddMandatoryAce( - __inout PACL Acl, - __in ULONG AceRevision, - __in ULONG AceFlags, - __in PSID Sid, - __in UCHAR AceType, - __in ACCESS_MASK AccessMask + _Inout_ PACL Acl, + _In_ ULONG AceRevision, + _In_ ULONG AceFlags, + _In_ PSID Sid, + _In_ UCHAR AceType, + _In_ ACCESS_MASK AccessMask ); #endif @@ -5444,118 +5444,118 @@ NTSYSAPI NTSTATUS NTAPI RtlNewSecurityObject( - __in_opt PSECURITY_DESCRIPTOR ParentDescriptor, - __in_opt PSECURITY_DESCRIPTOR CreatorDescriptor, - __out PSECURITY_DESCRIPTOR *NewDescriptor, - __in BOOLEAN IsDirectoryObject, - __in_opt HANDLE Token, - __in PGENERIC_MAPPING GenericMapping + _In_opt_ PSECURITY_DESCRIPTOR ParentDescriptor, + _In_opt_ PSECURITY_DESCRIPTOR CreatorDescriptor, + _Out_ PSECURITY_DESCRIPTOR *NewDescriptor, + _In_ BOOLEAN IsDirectoryObject, + _In_opt_ HANDLE Token, + _In_ PGENERIC_MAPPING GenericMapping ); NTSYSAPI NTSTATUS NTAPI RtlNewSecurityObjectEx( - __in_opt PSECURITY_DESCRIPTOR ParentDescriptor, - __in_opt PSECURITY_DESCRIPTOR CreatorDescriptor, - __out PSECURITY_DESCRIPTOR *NewDescriptor, - __in_opt GUID *ObjectType, - __in BOOLEAN IsDirectoryObject, - __in ULONG AutoInheritFlags, // SEF_* - __in_opt HANDLE Token, - __in PGENERIC_MAPPING GenericMapping + _In_opt_ PSECURITY_DESCRIPTOR ParentDescriptor, + _In_opt_ PSECURITY_DESCRIPTOR CreatorDescriptor, + _Out_ PSECURITY_DESCRIPTOR *NewDescriptor, + _In_opt_ GUID *ObjectType, + _In_ BOOLEAN IsDirectoryObject, + _In_ ULONG AutoInheritFlags, // SEF_* + _In_opt_ HANDLE Token, + _In_ PGENERIC_MAPPING GenericMapping ); NTSYSAPI NTSTATUS NTAPI RtlNewSecurityObjectWithMultipleInheritance( - __in_opt PSECURITY_DESCRIPTOR ParentDescriptor, - __in_opt PSECURITY_DESCRIPTOR CreatorDescriptor, - __out PSECURITY_DESCRIPTOR *NewDescriptor, - __in_opt GUID **ObjectType, - __in ULONG GuidCount, - __in BOOLEAN IsDirectoryObject, - __in ULONG AutoInheritFlags, // SEF_* - __in_opt HANDLE Token, - __in PGENERIC_MAPPING GenericMapping + _In_opt_ PSECURITY_DESCRIPTOR ParentDescriptor, + _In_opt_ PSECURITY_DESCRIPTOR CreatorDescriptor, + _Out_ PSECURITY_DESCRIPTOR *NewDescriptor, + _In_opt_ GUID **ObjectType, + _In_ ULONG GuidCount, + _In_ BOOLEAN IsDirectoryObject, + _In_ ULONG AutoInheritFlags, // SEF_* + _In_opt_ HANDLE Token, + _In_ PGENERIC_MAPPING GenericMapping ); NTSYSAPI NTSTATUS NTAPI RtlDeleteSecurityObject( - __inout PSECURITY_DESCRIPTOR *ObjectDescriptor + _Inout_ PSECURITY_DESCRIPTOR *ObjectDescriptor ); NTSYSAPI NTSTATUS NTAPI RtlQuerySecurityObject( - __in PSECURITY_DESCRIPTOR ObjectDescriptor, - __in SECURITY_INFORMATION SecurityInformation, - __out_opt PSECURITY_DESCRIPTOR ResultantDescriptor, - __in ULONG DescriptorLength, - __out PULONG ReturnLength + _In_ PSECURITY_DESCRIPTOR ObjectDescriptor, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_opt_ PSECURITY_DESCRIPTOR ResultantDescriptor, + _In_ ULONG DescriptorLength, + _Out_ PULONG ReturnLength ); NTSYSAPI NTSTATUS NTAPI RtlSetSecurityObject( - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR ModificationDescriptor, - __inout PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, - __in PGENERIC_MAPPING GenericMapping, - __in_opt HANDLE Token + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR ModificationDescriptor, + _Inout_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, + _In_ PGENERIC_MAPPING GenericMapping, + _In_opt_ HANDLE Token ); NTSYSAPI NTSTATUS NTAPI RtlSetSecurityObjectEx( - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR ModificationDescriptor, - __inout PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, - __in ULONG AutoInheritFlags, // SEF_* - __in PGENERIC_MAPPING GenericMapping, - __in_opt HANDLE Token + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR ModificationDescriptor, + _Inout_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, + _In_ ULONG AutoInheritFlags, // SEF_* + _In_ PGENERIC_MAPPING GenericMapping, + _In_opt_ HANDLE Token ); NTSYSAPI NTSTATUS NTAPI RtlConvertToAutoInheritSecurityObject( - __in_opt PSECURITY_DESCRIPTOR ParentDescriptor, - __in PSECURITY_DESCRIPTOR CurrentSecurityDescriptor, - __out PSECURITY_DESCRIPTOR *NewSecurityDescriptor, - __in_opt GUID *ObjectType, - __in BOOLEAN IsDirectoryObject, - __in PGENERIC_MAPPING GenericMapping + _In_opt_ PSECURITY_DESCRIPTOR ParentDescriptor, + _In_ PSECURITY_DESCRIPTOR CurrentSecurityDescriptor, + _Out_ PSECURITY_DESCRIPTOR *NewSecurityDescriptor, + _In_opt_ GUID *ObjectType, + _In_ BOOLEAN IsDirectoryObject, + _In_ PGENERIC_MAPPING GenericMapping ); NTSYSAPI NTSTATUS NTAPI RtlNewInstanceSecurityObject( - __in BOOLEAN ParentDescriptorChanged, - __in BOOLEAN CreatorDescriptorChanged, - __in PLUID OldClientTokenModifiedId, - __out PLUID NewClientTokenModifiedId, - __in_opt PSECURITY_DESCRIPTOR ParentDescriptor, - __in_opt PSECURITY_DESCRIPTOR CreatorDescriptor, - __out PSECURITY_DESCRIPTOR *NewDescriptor, - __in BOOLEAN IsDirectoryObject, - __in HANDLE Token, - __in PGENERIC_MAPPING GenericMapping + _In_ BOOLEAN ParentDescriptorChanged, + _In_ BOOLEAN CreatorDescriptorChanged, + _In_ PLUID OldClientTokenModifiedId, + _Out_ PLUID NewClientTokenModifiedId, + _In_opt_ PSECURITY_DESCRIPTOR ParentDescriptor, + _In_opt_ PSECURITY_DESCRIPTOR CreatorDescriptor, + _Out_ PSECURITY_DESCRIPTOR *NewDescriptor, + _In_ BOOLEAN IsDirectoryObject, + _In_ HANDLE Token, + _In_ PGENERIC_MAPPING GenericMapping ); NTSYSAPI NTSTATUS NTAPI RtlCopySecurityDescriptor( - __in PSECURITY_DESCRIPTOR InputSecurityDescriptor, - __out PSECURITY_DESCRIPTOR *OutputSecurityDescriptor + _In_ PSECURITY_DESCRIPTOR InputSecurityDescriptor, + _Out_ PSECURITY_DESCRIPTOR *OutputSecurityDescriptor ); // Misc. security @@ -5564,23 +5564,23 @@ NTSYSAPI VOID NTAPI RtlRunEncodeUnicodeString( - __inout PUCHAR Seed, - __in PUNICODE_STRING String + _Inout_ PUCHAR Seed, + _In_ PUNICODE_STRING String ); NTSYSAPI VOID NTAPI RtlRunDecodeUnicodeString( - __in UCHAR Seed, - __in PUNICODE_STRING String + _In_ UCHAR Seed, + _In_ PUNICODE_STRING String ); NTSYSAPI NTSTATUS NTAPI RtlImpersonateSelf( - __in SECURITY_IMPERSONATION_LEVEL ImpersonationLevel + _In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -5589,9 +5589,9 @@ NTSYSAPI NTSTATUS NTAPI RtlImpersonateSelfEx( - __in SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, - __in_opt ACCESS_MASK AdditionalAccess, - __out_opt PHANDLE ThreadToken + _In_ SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, + _In_opt_ ACCESS_MASK AdditionalAccess, + _Out_opt_ PHANDLE ThreadToken ); #endif @@ -5599,10 +5599,10 @@ NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege( - __in ULONG Privilege, - __in BOOLEAN Enable, - __in BOOLEAN Client, - __out PBOOLEAN WasEnabled + _In_ ULONG Privilege, + _In_ BOOLEAN Enable, + _In_ BOOLEAN Client, + _Out_ PBOOLEAN WasEnabled ); #define RTL_ACQUIRE_PRIVILEGE_REVERT 0x00000001 @@ -5612,17 +5612,17 @@ NTSYSAPI NTSTATUS NTAPI RtlAcquirePrivilege( - __in PULONG Privilege, - __in ULONG NumPriv, - __in ULONG Flags, - __out PVOID *ReturnedState + _In_ PULONG Privilege, + _In_ ULONG NumPriv, + _In_ ULONG Flags, + _Out_ PVOID *ReturnedState ); NTSYSAPI VOID NTAPI RtlReleasePrivilege( - __in PVOID StatePointer + _In_ PVOID StatePointer ); #if (PHNT_VERSION >= PHNT_VISTA) @@ -5631,9 +5631,9 @@ NTSYSAPI NTSTATUS NTAPI RtlRemovePrivileges( - __in HANDLE hToken, - __in PULONG PrivilegesToKeep, - __in ULONG PrivilegeCount + _In_ HANDLE hToken, + _In_ PULONG PrivilegesToKeep, + _In_ ULONG PrivilegeCount ); #endif @@ -5647,23 +5647,23 @@ NTSYSAPI PVOID NTAPI RtlCreateBoundaryDescriptor( - __in PUNICODE_STRING Name, - __in ULONG Flags + _In_ PUNICODE_STRING Name, + _In_ ULONG Flags ); NTSYSAPI VOID NTAPI RtlDeleteBoundaryDescriptor( - __in PVOID BoundaryDescriptor + _In_ PVOID BoundaryDescriptor ); NTSYSAPI NTSTATUS NTAPI RtlAddSIDToBoundaryDescriptor( - __inout PVOID *BoundaryDescriptor, - __in PSID RequiredSid + _Inout_ PVOID *BoundaryDescriptor, + _In_ PSID RequiredSid ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -5672,8 +5672,8 @@ NTSYSAPI NTSTATUS NTAPI RtlAddIntegrityLabelToBoundaryDescriptor( - __inout PVOID *BoundaryDescriptor, - __in PSID IntegrityLabel + _Inout_ PVOID *BoundaryDescriptor, + _In_ PSID IntegrityLabel ); #endif @@ -5687,16 +5687,16 @@ NTSYSAPI NTSTATUS NTAPI RtlGetVersion( - __out PRTL_OSVERSIONINFOW lpVersionInformation + _Out_ PRTL_OSVERSIONINFOW lpVersionInformation ); NTSYSAPI NTSTATUS NTAPI RtlVerifyVersionInfo( - __in PRTL_OSVERSIONINFOEXW VersionInfo, - __in ULONG TypeMask, - __in ULONGLONG ConditionMask + _In_ PRTL_OSVERSIONINFOEXW VersionInfo, + _In_ ULONG TypeMask, + _In_ ULONGLONG ConditionMask ); // System information @@ -5712,7 +5712,7 @@ NTSYSAPI BOOLEAN NTAPI RtlGetNtProductType( - __out PNT_PRODUCT_TYPE NtProductType + _Out_ PNT_PRODUCT_TYPE NtProductType ); // rev @@ -5720,9 +5720,9 @@ NTSYSAPI VOID NTAPI RtlGetNtVersionNumbers( - __out_opt PULONG pNtMajorVersion, - __out_opt PULONG pNtMinorVersion, - __out_opt PULONG pNtBuildNumber + _Out_opt_ PULONG pNtMajorVersion, + _Out_opt_ PULONG pNtMinorVersion, + _Out_opt_ PULONG pNtBuildNumber ); // Thread pool (old) @@ -5731,99 +5731,99 @@ NTSYSAPI NTSTATUS NTAPI RtlRegisterWait( - __out PHANDLE WaitHandle, - __in HANDLE Handle, - __in WAITORTIMERCALLBACKFUNC Function, - __in PVOID Context, - __in ULONG Milliseconds, - __in ULONG Flags + _Out_ PHANDLE WaitHandle, + _In_ HANDLE Handle, + _In_ WAITORTIMERCALLBACKFUNC Function, + _In_ PVOID Context, + _In_ ULONG Milliseconds, + _In_ ULONG Flags ); NTSYSAPI NTSTATUS NTAPI RtlDeregisterWait( - __in HANDLE WaitHandle + _In_ HANDLE WaitHandle ); NTSYSAPI NTSTATUS NTAPI RtlDeregisterWaitEx( - __in HANDLE WaitHandle, - __in HANDLE Event + _In_ HANDLE WaitHandle, + _In_ HANDLE Event ); NTSYSAPI NTSTATUS NTAPI RtlQueueWorkItem( - __in WORKERCALLBACKFUNC Function, - __in PVOID Context, - __in ULONG Flags + _In_ WORKERCALLBACKFUNC Function, + _In_ PVOID Context, + _In_ ULONG Flags ); NTSYSAPI NTSTATUS NTAPI RtlSetIoCompletionCallback( - __in HANDLE FileHandle, - __in APC_CALLBACK_FUNCTION CompletionProc, - __in ULONG Flags + _In_ HANDLE FileHandle, + _In_ APC_CALLBACK_FUNCTION CompletionProc, + _In_ ULONG Flags ); NTSYSAPI NTSTATUS NTAPI RtlCreateTimerQueue( - __out PHANDLE TimerQueueHandle + _Out_ PHANDLE TimerQueueHandle ); NTSYSAPI NTSTATUS NTAPI RtlCreateTimer( - __in HANDLE TimerQueueHandle, - __out PHANDLE Handle, - __in WAITORTIMERCALLBACKFUNC Function, - __in PVOID Context, - __in ULONG DueTime, - __in ULONG Period, - __in ULONG Flags + _In_ HANDLE TimerQueueHandle, + _Out_ PHANDLE Handle, + _In_ WAITORTIMERCALLBACKFUNC Function, + _In_ PVOID Context, + _In_ ULONG DueTime, + _In_ ULONG Period, + _In_ ULONG Flags ); NTSYSAPI NTSTATUS NTAPI RtlUpdateTimer( - __in HANDLE TimerQueueHandle, - __in HANDLE TimerHandle, - __in ULONG DueTime, - __in ULONG Period + _In_ HANDLE TimerQueueHandle, + _In_ HANDLE TimerHandle, + _In_ ULONG DueTime, + _In_ ULONG Period ); NTSYSAPI NTSTATUS NTAPI RtlDeleteTimer( - __in HANDLE TimerQueueHandle, - __in HANDLE TimerToCancel, - __in HANDLE Event + _In_ HANDLE TimerQueueHandle, + _In_ HANDLE TimerToCancel, + _In_ HANDLE Event ); NTSYSAPI NTSTATUS NTAPI RtlDeleteTimerQueue( - __in HANDLE TimerQueueHandle + _In_ HANDLE TimerQueueHandle ); NTSYSAPI NTSTATUS NTAPI RtlDeleteTimerQueueEx( - __in HANDLE TimerQueueHandle, - __in HANDLE Event + _In_ HANDLE TimerQueueHandle, + _In_ HANDLE Event ); // Registry access @@ -5832,15 +5832,15 @@ NTSYSAPI NTSTATUS NTAPI RtlFormatCurrentUserKeyPath( - __out PUNICODE_STRING CurrentUserKeyPath + _Out_ PUNICODE_STRING CurrentUserKeyPath ); NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser( - __in ACCESS_MASK DesiredAccess, - __out PHANDLE CurrentUserKey + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE CurrentUserKey ); #define RTL_REGISTRY_ABSOLUTE 0 @@ -5857,25 +5857,25 @@ NTSYSAPI NTSTATUS NTAPI RtlCreateRegistryKey( - __in ULONG RelativeTo, - __in PWSTR Path + _In_ ULONG RelativeTo, + _In_ PWSTR Path ); NTSYSAPI NTSTATUS NTAPI RtlCheckRegistryKey( - __in ULONG RelativeTo, - __in PWSTR Path + _In_ ULONG RelativeTo, + _In_ PWSTR Path ); typedef NTSTATUS (NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( - __in PWSTR ValueName, - __in ULONG ValueType, - __in PVOID ValueData, - __in ULONG ValueLength, - __in PVOID Context, - __in PVOID EntryContext + _In_ PWSTR ValueName, + _In_ ULONG ValueType, + _In_ PVOID ValueData, + _In_ ULONG ValueLength, + _In_ PVOID Context, + _In_ PVOID EntryContext ); typedef struct _RTL_QUERY_REGISTRY_TABLE @@ -5901,32 +5901,32 @@ NTSYSAPI NTSTATUS NTAPI RtlQueryRegistryValues( - __in ULONG RelativeTo, - __in PWSTR Path, - __in PRTL_QUERY_REGISTRY_TABLE QueryTable, - __in PVOID Context, - __in_opt PVOID Environment + _In_ ULONG RelativeTo, + _In_ PWSTR Path, + _In_ PRTL_QUERY_REGISTRY_TABLE QueryTable, + _In_ PVOID Context, + _In_opt_ PVOID Environment ); NTSYSAPI NTSTATUS NTAPI RtlWriteRegistryValue( - __in ULONG RelativeTo, - __in PWSTR Path, - __in PWSTR ValueName, - __in ULONG ValueType, - __in PVOID ValueData, - __in ULONG ValueLength + _In_ ULONG RelativeTo, + _In_ PWSTR Path, + _In_ PWSTR ValueName, + _In_ ULONG ValueType, + _In_ PVOID ValueData, + _In_ ULONG ValueLength ); NTSYSAPI NTSTATUS NTAPI RtlDeleteRegistryValue( - __in ULONG RelativeTo, - __in PWSTR Path, - __in PWSTR ValueName + _In_ ULONG RelativeTo, + _In_ PWSTR Path, + _In_ PWSTR ValueName ); // Debugging @@ -5949,7 +5949,7 @@ NTSYSAPI VOID NTAPI DbgBreakPointWithStatus( - __in ULONG Status + _In_ ULONG Status ); #define DBG_STATUS_CONTROL_C 1 @@ -5964,7 +5964,7 @@ NTSYSAPI ULONG __cdecl DbgPrint( - __in_z __format_string PSTR Format, + _In_z_ _Printf_format_string_ PSTR Format, ... ); @@ -5972,9 +5972,9 @@ NTSYSAPI ULONG __cdecl DbgPrintEx( - __in ULONG ComponentId, - __in ULONG Level, - __in_z __format_string PSTR Format, + _In_ ULONG ComponentId, + _In_ ULONG Level, + _In_z_ _Printf_format_string_ PSTR Format, ... ); @@ -5982,47 +5982,47 @@ NTSYSAPI ULONG NTAPI vDbgPrintEx( - __in ULONG ComponentId, - __in ULONG Level, - __in_z PCH Format, - __in va_list arglist + _In_ ULONG ComponentId, + _In_ ULONG Level, + _In_z_ PCH Format, + _In_ va_list arglist ); NTSYSAPI ULONG NTAPI vDbgPrintExWithPrefix( - __in_z PCH Prefix, - __in ULONG ComponentId, - __in ULONG Level, - __in_z PCH Format, - __in va_list arglist + _In_z_ PCH Prefix, + _In_ ULONG ComponentId, + _In_ ULONG Level, + _In_z_ PCH Format, + _In_ va_list arglist ); NTSYSAPI NTSTATUS NTAPI DbgQueryDebugFilterState( - __in ULONG ComponentId, - __in ULONG Level + _In_ ULONG ComponentId, + _In_ ULONG Level ); NTSYSAPI NTSTATUS NTAPI DbgSetDebugFilterState( - __in ULONG ComponentId, - __in ULONG Level, - __in BOOLEAN State + _In_ ULONG ComponentId, + _In_ ULONG Level, + _In_ BOOLEAN State ); NTSYSAPI ULONG NTAPI DbgPrompt( - __in PCH Prompt, - __out_bcount(Length) PCH Response, - __in ULONG Length + _In_ PCH Prompt, + _Out_writes_bytes_(Length) PCH Response, + _In_ ULONG Length ); // Thread profiling @@ -6035,34 +6035,34 @@ NTSYSAPI NTSTATUS NTAPI RtlEnableThreadProfiling( - __in HANDLE ThreadHandle, - __in ULONG Flags, - __in ULONG64 HardwareCounters, - __out PVOID *PerformanceDataHandle + _In_ HANDLE ThreadHandle, + _In_ ULONG Flags, + _In_ ULONG64 HardwareCounters, + _Out_ PVOID *PerformanceDataHandle ); NTSYSAPI NTSTATUS NTAPI RtlDisableThreadProfiling( - __in PVOID PerformanceDataHandle + _In_ PVOID PerformanceDataHandle ); NTSYSAPI NTSTATUS NTAPI RtlQueryThreadProfiling( - __in HANDLE ThreadHandle, - __out PBOOLEAN Enabled + _In_ HANDLE ThreadHandle, + _Out_ PBOOLEAN Enabled ); NTSYSAPI NTSTATUS NTAPI RtlReadThreadProfilingData( - __in HANDLE PerformanceDataHandle, - __in ULONG Flags, - __out PPERFORMANCE_DATA PerformanceData + _In_ HANDLE PerformanceDataHandle, + _In_ ULONG Flags, + _Out_ PPERFORMANCE_DATA PerformanceData ); // end_rev @@ -6082,37 +6082,37 @@ NTSYSAPI ULONG32 NTAPI RtlComputeCrc32( - __in ULONG32 PartialCrc, - __in PVOID Buffer, - __in ULONG Length + _In_ ULONG32 PartialCrc, + _In_ PVOID Buffer, + _In_ ULONG Length ); NTSYSAPI PVOID NTAPI RtlEncodePointer( - __in PVOID Ptr + _In_ PVOID Ptr ); NTSYSAPI PVOID NTAPI RtlDecodePointer( - __in PVOID Ptr + _In_ PVOID Ptr ); NTSYSAPI PVOID NTAPI RtlEncodeSystemPointer( - __in PVOID Ptr + _In_ PVOID Ptr ); NTSYSAPI PVOID NTAPI RtlDecodeSystemPointer( - __in PVOID Ptr + _In_ PVOID Ptr ); NTSYSAPI @@ -6141,7 +6141,7 @@ NTSYSAPI NTSTATUS NTAPI RtlQueryElevationFlags( - __out PRTL_ELEVATION_FLAGS Flags + _Out_ PRTL_ELEVATION_FLAGS Flags ); #endif @@ -6183,7 +6183,7 @@ NTSYSAPI NTSTATUS NTAPI RtlLockModuleSection( - __in PVOID Address + _In_ PVOID Address ); #endif @@ -6193,7 +6193,7 @@ NTSYSAPI NTSTATUS NTAPI RtlUnlockModuleSection( - __in PVOID Address + _In_ PVOID Address ); #endif @@ -6201,6 +6201,7 @@ RtlUnlockModuleSection( #define RTL_UNLOAD_EVENT_TRACE_NUMBER 64 +// private typedef struct _RTL_UNLOAD_EVENT_TRACE { PVOID BaseAddress; @@ -6209,6 +6210,7 @@ typedef struct _RTL_UNLOAD_EVENT_TRACE ULONG TimeDateStamp; ULONG CheckSum; WCHAR ImageName[32]; + ULONG Version[2]; } RTL_UNLOAD_EVENT_TRACE, *PRTL_UNLOAD_EVENT_TRACE; NTSYSAPI @@ -6223,9 +6225,9 @@ NTSYSAPI VOID NTAPI RtlGetUnloadEventTraceEx( - __out PULONG *ElementSize, - __out PULONG *ElementCount, - __out PVOID *EventTrace // works across all processes + _Out_ PULONG *ElementSize, + _Out_ PULONG *ElementCount, + _Out_ PVOID *EventTrace // works across all processes ); #endif @@ -6237,7 +6239,7 @@ NTSYSAPI LOGICAL NTAPI RtlQueryPerformanceCounter( - __out PLARGE_INTEGER PerformanceCounter + _Out_ PLARGE_INTEGER PerformanceCounter ); #endif @@ -6247,7 +6249,7 @@ NTSYSAPI LOGICAL NTAPI RtlQueryPerformanceFrequency( - __out PLARGE_INTEGER PerformanceFrequency + _Out_ PLARGE_INTEGER PerformanceFrequency ); #endif diff --git a/2.x/trunk/phlib/include/ntsam.h b/2.x/trunk/phlib/include/ntsam.h index 60a5c0f01..07aa29ec0 100644 --- a/2.x/trunk/phlib/include/ntsam.h +++ b/2.x/trunk/phlib/include/ntsam.h @@ -24,13 +24,13 @@ typedef struct _SAM_SID_ENUMERATION typedef struct _SAM_BYTE_ARRAY { ULONG Size; - __bcount(Size) PUCHAR Data; + _Field_size_bytes_(Size) PUCHAR Data; } SAM_BYTE_ARRAY, *PSAM_BYTE_ARRAY; typedef struct _SAM_BYTE_ARRAY_32K { ULONG Size; - __bcount(Size) PUCHAR Data; + _Field_size_bytes_(Size) PUCHAR Data; } SAM_BYTE_ARRAY_32K, *PSAM_BYTE_ARRAY_32K; typedef SAM_BYTE_ARRAY_32K SAM_SHELL_OBJECT_PROPERTIES, *PSAM_SHELL_OBJECT_PROPERTIES; @@ -38,32 +38,32 @@ typedef SAM_BYTE_ARRAY_32K SAM_SHELL_OBJECT_PROPERTIES, *PSAM_SHELL_OBJECT_PROPE // Basic NTSTATUS NTAPI SamFreeMemory( - __in PVOID Buffer + _In_ PVOID Buffer ); NTSTATUS NTAPI SamCloseHandle( - __in SAM_HANDLE SamHandle + _In_ SAM_HANDLE SamHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamSetSecurityObject( - __in SAM_HANDLE ObjectHandle, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ SAM_HANDLE ObjectHandle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamQuerySecurityObject( - __in SAM_HANDLE ObjectHandle, - __in SECURITY_INFORMATION SecurityInformation, - __deref_out PSECURITY_DESCRIPTOR *SecurityDescriptor + _In_ SAM_HANDLE ObjectHandle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Outptr_ PSECURITY_DESCRIPTOR *SecurityDescriptor ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamRidToSid( - __in SAM_HANDLE ObjectHandle, - __in ULONG Rid, - __deref_out PSID *Sid + _In_ SAM_HANDLE ObjectHandle, + _In_ ULONG Rid, + _Outptr_ PSID *Sid ); // Server @@ -97,17 +97,17 @@ NTSTATUS NTAPI SamRidToSid( // Functions -__checkReturn +_Check_return_ NTSTATUS NTAPI SamConnect( - __in_opt PUNICODE_STRING ServerName, - __out PSAM_HANDLE ServerHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _In_opt_ PUNICODE_STRING ServerName, + _Out_ PSAM_HANDLE ServerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamShutdownSamServer( - __in SAM_HANDLE ServerHandle + _In_ SAM_HANDLE ServerHandle ); // Domain @@ -370,7 +370,7 @@ typedef struct _DOMAIN_LOCALIZABLE_ACCOUNTS_ENTRY typedef struct _DOMAIN_LOCALIZABLE_ACCOUNTS { ULONG Count; - __ecount(Count) DOMAIN_LOCALIZABLE_ACCOUNT_ENTRY *Entries; + _Field_size_(Count) DOMAIN_LOCALIZABLE_ACCOUNT_ENTRY *Entries; } DOMAIN_LOCALIZABLE_ACCOUNTS_BASIC, *PDOMAIN_LOCALIZABLE_ACCOUNTS_BASIC; typedef union _DOMAIN_LOCALIZABLE_INFO_BUFFER @@ -380,75 +380,75 @@ typedef union _DOMAIN_LOCALIZABLE_INFO_BUFFER // Functions -__checkReturn +_Check_return_ NTSTATUS NTAPI SamLookupDomainInSamServer( - __in SAM_HANDLE ServerHandle, - __in PUNICODE_STRING Name, - __deref_out PSID *DomainId + _In_ SAM_HANDLE ServerHandle, + _In_ PUNICODE_STRING Name, + _Outptr_ PSID *DomainId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamEnumerateDomainsInSamServer( - __in SAM_HANDLE ServerHandle, - __inout PSAM_ENUMERATE_HANDLE EnumerationContext, - __deref_out PVOID *Buffer, // PSAM_SID_ENUMERATION *Buffer - __in ULONG PreferedMaximumLength, - __out PULONG CountReturned + _In_ SAM_HANDLE ServerHandle, + _Inout_ PSAM_ENUMERATE_HANDLE EnumerationContext, + _Outptr_ PVOID *Buffer, // PSAM_SID_ENUMERATION *Buffer + _In_ ULONG PreferedMaximumLength, + _Out_ PULONG CountReturned ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamOpenDomain( - __in SAM_HANDLE ServerHandle, - __in ACCESS_MASK DesiredAccess, - __in PSID DomainId, - __out PSAM_HANDLE DomainHandle + _In_ SAM_HANDLE ServerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PSID DomainId, + _Out_ PSAM_HANDLE DomainHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamQueryInformationDomain( - __in SAM_HANDLE DomainHandle, - __in DOMAIN_INFORMATION_CLASS DomainInformationClass, - __deref_out PVOID *Buffer + _In_ SAM_HANDLE DomainHandle, + _In_ DOMAIN_INFORMATION_CLASS DomainInformationClass, + _Outptr_ PVOID *Buffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamSetInformationDomain( - __in SAM_HANDLE DomainHandle, - __in DOMAIN_INFORMATION_CLASS DomainInformationClass, - __in PVOID DomainInformation + _In_ SAM_HANDLE DomainHandle, + _In_ DOMAIN_INFORMATION_CLASS DomainInformationClass, + _In_ PVOID DomainInformation ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamLookupNamesInDomain( - __in SAM_HANDLE DomainHandle, - __in ULONG Count, - __in_ecount(Count) PUNICODE_STRING Names, - __deref_out_ecount(Count) PULONG *RelativeIds, - __deref_out_ecount(Count) PSID_NAME_USE *Use + _In_ SAM_HANDLE DomainHandle, + _In_ ULONG Count, + _In_reads_(Count) PUNICODE_STRING Names, + _Out_ _Deref_post_count_(Count) PULONG *RelativeIds, + _Out_ _Deref_post_count_(Count) PSID_NAME_USE *Use ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamLookupIdsInDomain( - __in SAM_HANDLE DomainHandle, - __in ULONG Count, - __in_ecount(Count) PULONG RelativeIds, - __deref_out_ecount(Count) PUNICODE_STRING *Names, - __deref_opt_out_ecount(Count) PSID_NAME_USE *Use + _In_ SAM_HANDLE DomainHandle, + _In_ ULONG Count, + _In_reads_(Count) PULONG RelativeIds, + _Out_ _Deref_post_count_(Count) PUNICODE_STRING *Names, + _Out_ _Deref_post_opt_count_(Count) PSID_NAME_USE *Use ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamRemoveMemberFromForeignDomain( - __in SAM_HANDLE DomainHandle, - __in PSID MemberId + _In_ SAM_HANDLE DomainHandle, + _In_ PSID MemberId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamQueryLocalizableAccountsInDomain( - __in SAM_HANDLE Domain, - __in ULONG Flags, - __in ULONG LanguageId, - __in DOMAIN_LOCALIZABLE_ACCOUNTS_INFORMATION Class, - __deref_out PVOID *Buffer + _In_ SAM_HANDLE Domain, + _In_ ULONG Flags, + _In_ ULONG LanguageId, + _In_ DOMAIN_LOCALIZABLE_ACCOUNTS_INFORMATION Class, + _Outptr_ PVOID *Buffer ); // Group @@ -519,77 +519,77 @@ typedef struct _GROUP_ADM_COMMENT_INFORMATION // Functions -__checkReturn +_Check_return_ NTSTATUS NTAPI SamEnumerateGroupsInDomain( - __in SAM_HANDLE DomainHandle, - __inout PSAM_ENUMERATE_HANDLE EnumerationContext, - __deref_out PVOID *Buffer, // PSAM_RID_ENUMERATION * - __in ULONG PreferedMaximumLength, - __out PULONG CountReturned + _In_ SAM_HANDLE DomainHandle, + _Inout_ PSAM_ENUMERATE_HANDLE EnumerationContext, + _Outptr_ PVOID *Buffer, // PSAM_RID_ENUMERATION * + _In_ ULONG PreferedMaximumLength, + _Out_ PULONG CountReturned ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamCreateGroupInDomain( - __in SAM_HANDLE DomainHandle, - __in PUNICODE_STRING AccountName, - __in ACCESS_MASK DesiredAccess, - __out PSAM_HANDLE GroupHandle, - __out PULONG RelativeId + _In_ SAM_HANDLE DomainHandle, + _In_ PUNICODE_STRING AccountName, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PSAM_HANDLE GroupHandle, + _Out_ PULONG RelativeId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamOpenGroup( - __in SAM_HANDLE DomainHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG GroupId, - __out PSAM_HANDLE GroupHandle + _In_ SAM_HANDLE DomainHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG GroupId, + _Out_ PSAM_HANDLE GroupHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamDeleteGroup( - __in SAM_HANDLE GroupHandle + _In_ SAM_HANDLE GroupHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamQueryInformationGroup( - __in SAM_HANDLE GroupHandle, - __in GROUP_INFORMATION_CLASS GroupInformationClass, - __deref_out PVOID *Buffer + _In_ SAM_HANDLE GroupHandle, + _In_ GROUP_INFORMATION_CLASS GroupInformationClass, + _Outptr_ PVOID *Buffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamSetInformationGroup( - __in SAM_HANDLE GroupHandle, - __in GROUP_INFORMATION_CLASS GroupInformationClass, - __in PVOID Buffer + _In_ SAM_HANDLE GroupHandle, + _In_ GROUP_INFORMATION_CLASS GroupInformationClass, + _In_ PVOID Buffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamAddMemberToGroup( - __in SAM_HANDLE GroupHandle, - __in ULONG MemberId, - __in ULONG Attributes + _In_ SAM_HANDLE GroupHandle, + _In_ ULONG MemberId, + _In_ ULONG Attributes ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamRemoveMemberFromGroup( - __in SAM_HANDLE GroupHandle, - __in ULONG MemberId + _In_ SAM_HANDLE GroupHandle, + _In_ ULONG MemberId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamGetMembersInGroup( - __in SAM_HANDLE GroupHandle, - __deref_out_ecount(*MemberCount) PULONG *MemberIds, - __deref_out_ecount(*MemberCount) PULONG *Attributes, - __out PULONG MemberCount + _In_ SAM_HANDLE GroupHandle, + _Out_ _Deref_post_count_(*MemberCount) PULONG *MemberIds, + _Out_ _Deref_post_count_(*MemberCount) PULONG *Attributes, + _Out_ PULONG MemberCount ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamSetMemberAttributesOfGroup( - __in SAM_HANDLE GroupHandle, - __in ULONG MemberId, - __in ULONG Attributes + _In_ SAM_HANDLE GroupHandle, + _In_ ULONG MemberId, + _In_ ULONG Attributes ); // Alias @@ -659,91 +659,91 @@ typedef struct _ALIAS_EXTENDED_INFORMATION // Functions -__checkReturn +_Check_return_ NTSTATUS NTAPI SamEnumerateAliasesInDomain( - __in SAM_HANDLE DomainHandle, - __inout PSAM_ENUMERATE_HANDLE EnumerationContext, - __deref_out PVOID *Buffer, // PSAM_RID_ENUMERATION *Buffer - __in ULONG PreferedMaximumLength, - __out PULONG CountReturned + _In_ SAM_HANDLE DomainHandle, + _Inout_ PSAM_ENUMERATE_HANDLE EnumerationContext, + _Outptr_ PVOID *Buffer, // PSAM_RID_ENUMERATION *Buffer + _In_ ULONG PreferedMaximumLength, + _Out_ PULONG CountReturned ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamCreateAliasInDomain( - __in SAM_HANDLE DomainHandle, - __in PUNICODE_STRING AccountName, - __in ACCESS_MASK DesiredAccess, - __out PSAM_HANDLE AliasHandle, - __out PULONG RelativeId + _In_ SAM_HANDLE DomainHandle, + _In_ PUNICODE_STRING AccountName, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PSAM_HANDLE AliasHandle, + _Out_ PULONG RelativeId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamOpenAlias( - __in SAM_HANDLE DomainHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG AliasId, - __out PSAM_HANDLE AliasHandle + _In_ SAM_HANDLE DomainHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG AliasId, + _Out_ PSAM_HANDLE AliasHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamDeleteAlias( - __in SAM_HANDLE AliasHandle + _In_ SAM_HANDLE AliasHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamQueryInformationAlias( - __in SAM_HANDLE AliasHandle, - __in ALIAS_INFORMATION_CLASS AliasInformationClass, - __deref_out PVOID *Buffer + _In_ SAM_HANDLE AliasHandle, + _In_ ALIAS_INFORMATION_CLASS AliasInformationClass, + _Outptr_ PVOID *Buffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamSetInformationAlias( - __in SAM_HANDLE AliasHandle, - __in ALIAS_INFORMATION_CLASS AliasInformationClass, - __in PVOID Buffer + _In_ SAM_HANDLE AliasHandle, + _In_ ALIAS_INFORMATION_CLASS AliasInformationClass, + _In_ PVOID Buffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamAddMemberToAlias( - __in SAM_HANDLE AliasHandle, - __in PSID MemberId + _In_ SAM_HANDLE AliasHandle, + _In_ PSID MemberId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamAddMultipleMembersToAlias( - __in SAM_HANDLE AliasHandle, - __in_ecount(MemberCount) PSID *MemberIds, - __in ULONG MemberCount + _In_ SAM_HANDLE AliasHandle, + _In_reads_(MemberCount) PSID *MemberIds, + _In_ ULONG MemberCount ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamRemoveMemberFromAlias( - __in SAM_HANDLE AliasHandle, - __in PSID MemberId + _In_ SAM_HANDLE AliasHandle, + _In_ PSID MemberId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamRemoveMultipleMembersFromAlias( - __in SAM_HANDLE AliasHandle, - __in_ecount(MemberCount) PSID *MemberIds, - __in ULONG MemberCount + _In_ SAM_HANDLE AliasHandle, + _In_reads_(MemberCount) PSID *MemberIds, + _In_ ULONG MemberCount ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamGetMembersInAlias( - __in SAM_HANDLE AliasHandle, - __deref_out_ecount(*MemberCount) PSID **MemberIds, - __out PULONG MemberCount + _In_ SAM_HANDLE AliasHandle, + _Out_ _Deref_post_count_(*MemberCount) PSID **MemberIds, + _Out_ PULONG MemberCount ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamGetAliasMembership( - __in SAM_HANDLE DomainHandle, - __in ULONG PassedCount, - __in_ecount(PassedCount) PSID *Sids, - __out PULONG MembershipCount, - __deref_out_ecount(*MembershipCount) PULONG *Aliases + _In_ SAM_HANDLE DomainHandle, + _In_ ULONG PassedCount, + _In_reads_(PassedCount) PSID *Sids, + _Out_ PULONG MembershipCount, + _Out_ _Deref_post_count_(*MembershipCount) PULONG *Aliases ); // Group types @@ -1280,114 +1280,114 @@ typedef struct _USER_PWD_CHANGE_FAILURE_INFORMATION // Functions -__checkReturn +_Check_return_ NTSTATUS NTAPI SamEnumerateUsersInDomain( - __in SAM_HANDLE DomainHandle, - __inout PSAM_ENUMERATE_HANDLE EnumerationContext, - __in ULONG UserAccountControl, - __deref_out PVOID *Buffer, // PSAM_RID_ENUMERATION * - __in ULONG PreferedMaximumLength, - __out PULONG CountReturned + _In_ SAM_HANDLE DomainHandle, + _Inout_ PSAM_ENUMERATE_HANDLE EnumerationContext, + _In_ ULONG UserAccountControl, + _Outptr_ PVOID *Buffer, // PSAM_RID_ENUMERATION * + _In_ ULONG PreferedMaximumLength, + _Out_ PULONG CountReturned ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamCreateUserInDomain( - __in SAM_HANDLE DomainHandle, - __in PUNICODE_STRING AccountName, - __in ACCESS_MASK DesiredAccess, - __out PSAM_HANDLE UserHandle, - __out PULONG RelativeId + _In_ SAM_HANDLE DomainHandle, + _In_ PUNICODE_STRING AccountName, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PSAM_HANDLE UserHandle, + _Out_ PULONG RelativeId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamCreateUser2InDomain( - __in SAM_HANDLE DomainHandle, - __in PUNICODE_STRING AccountName, - __in ULONG AccountType, - __in ACCESS_MASK DesiredAccess, - __out PSAM_HANDLE UserHandle, - __out PULONG GrantedAccess, - __out PULONG RelativeId + _In_ SAM_HANDLE DomainHandle, + _In_ PUNICODE_STRING AccountName, + _In_ ULONG AccountType, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PSAM_HANDLE UserHandle, + _Out_ PULONG GrantedAccess, + _Out_ PULONG RelativeId ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamOpenUser( - __in SAM_HANDLE DomainHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG UserId, - __out PSAM_HANDLE UserHandle + _In_ SAM_HANDLE DomainHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG UserId, + _Out_ PSAM_HANDLE UserHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamDeleteUser( - __in SAM_HANDLE UserHandle + _In_ SAM_HANDLE UserHandle ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamQueryInformationUser( - __in SAM_HANDLE UserHandle, - __in USER_INFORMATION_CLASS UserInformationClass, - __deref_out PVOID *Buffer + _In_ SAM_HANDLE UserHandle, + _In_ USER_INFORMATION_CLASS UserInformationClass, + _Outptr_ PVOID *Buffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamSetInformationUser( - __in SAM_HANDLE UserHandle, - __in USER_INFORMATION_CLASS UserInformationClass, - __in PVOID Buffer + _In_ SAM_HANDLE UserHandle, + _In_ USER_INFORMATION_CLASS UserInformationClass, + _In_ PVOID Buffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamGetGroupsForUser( - __in SAM_HANDLE UserHandle, - __deref_out_ecount(*MembershipCount) PGROUP_MEMBERSHIP *Groups, - __out PULONG MembershipCount + _In_ SAM_HANDLE UserHandle, + _Out_ _Deref_post_count_(*MembershipCount) PGROUP_MEMBERSHIP *Groups, + _Out_ PULONG MembershipCount ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamChangePasswordUser( - __in SAM_HANDLE UserHandle, - __in PUNICODE_STRING OldPassword, - __in PUNICODE_STRING NewPassword + _In_ SAM_HANDLE UserHandle, + _In_ PUNICODE_STRING OldPassword, + _In_ PUNICODE_STRING NewPassword ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamChangePasswordUser2( - __in PUNICODE_STRING ServerName, - __in PUNICODE_STRING UserName, - __in PUNICODE_STRING OldPassword, - __in PUNICODE_STRING NewPassword + _In_ PUNICODE_STRING ServerName, + _In_ PUNICODE_STRING UserName, + _In_ PUNICODE_STRING OldPassword, + _In_ PUNICODE_STRING NewPassword ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamChangePasswordUser3( - __in PUNICODE_STRING ServerName, - __in PUNICODE_STRING UserName, - __in PUNICODE_STRING OldPassword, - __in PUNICODE_STRING NewPassword, - __deref_out PDOMAIN_PASSWORD_INFORMATION *EffectivePasswordPolicy, - __deref_out PUSER_PWD_CHANGE_FAILURE_INFORMATION *PasswordChangeFailureInfo + _In_ PUNICODE_STRING ServerName, + _In_ PUNICODE_STRING UserName, + _In_ PUNICODE_STRING OldPassword, + _In_ PUNICODE_STRING NewPassword, + _Outptr_ PDOMAIN_PASSWORD_INFORMATION *EffectivePasswordPolicy, + _Outptr_ PUSER_PWD_CHANGE_FAILURE_INFORMATION *PasswordChangeFailureInfo ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamQueryDisplayInformation( - __in SAM_HANDLE DomainHandle, - __in DOMAIN_DISPLAY_INFORMATION DisplayInformation, - __in ULONG Index, - __in ULONG EntryCount, - __in ULONG PreferredMaximumLength, - __in PULONG TotalAvailable, - __out PULONG TotalReturned, - __out PULONG ReturnedEntryCount, - __deref_out PVOID *SortedBuffer + _In_ SAM_HANDLE DomainHandle, + _In_ DOMAIN_DISPLAY_INFORMATION DisplayInformation, + _In_ ULONG Index, + _In_ ULONG EntryCount, + _In_ ULONG PreferredMaximumLength, + _In_ PULONG TotalAvailable, + _Out_ PULONG TotalReturned, + _Out_ PULONG ReturnedEntryCount, + _Outptr_ PVOID *SortedBuffer ); -__checkReturn +_Check_return_ NTSTATUS NTAPI SamGetDisplayEnumerationIndex( - __in SAM_HANDLE DomainHandle, - __in DOMAIN_DISPLAY_INFORMATION DisplayInformation, - __in PUNICODE_STRING Prefix, - __out PULONG Index + _In_ SAM_HANDLE DomainHandle, + _In_ DOMAIN_DISPLAY_INFORMATION DisplayInformation, + _In_ PUNICODE_STRING Prefix, + _Out_ PULONG Index ); // Database replication @@ -1445,26 +1445,26 @@ typedef union _SAM_DELTA_DATA } SAM_DELTA_DATA, *PSAM_DELTA_DATA; typedef NTSTATUS (NTAPI *PSAM_DELTA_NOTIFICATION_ROUTINE)( - __in PSID DomainSid, - __in SECURITY_DB_DELTA_TYPE DeltaType, - __in SECURITY_DB_OBJECT_TYPE ObjectType, - __in ULONG ObjectRid, - __in_opt PUNICODE_STRING ObjectName, - __in PLARGE_INTEGER ModifiedCount, - __in_opt PSAM_DELTA_DATA DeltaData + _In_ PSID DomainSid, + _In_ SECURITY_DB_DELTA_TYPE DeltaType, + _In_ SECURITY_DB_OBJECT_TYPE ObjectType, + _In_ ULONG ObjectRid, + _In_opt_ PUNICODE_STRING ObjectName, + _In_ PLARGE_INTEGER ModifiedCount, + _In_opt_ PSAM_DELTA_DATA DeltaData ); #define SAM_DELTA_NOTIFY_ROUTINE "DeltaNotify" -__checkReturn +_Check_return_ NTSTATUS NTAPI SamRegisterObjectChangeNotification( - __in SECURITY_DB_OBJECT_TYPE ObjectType, - __in HANDLE NotificationEventHandle + _In_ SECURITY_DB_OBJECT_TYPE ObjectType, + _In_ HANDLE NotificationEventHandle ); NTSTATUS NTAPI SamUnregisterObjectChangeNotification( - __in SECURITY_DB_OBJECT_TYPE ObjectType, - __in HANDLE NotificationEventHandle + _In_ SECURITY_DB_OBJECT_TYPE ObjectType, + _In_ HANDLE NotificationEventHandle ); // Compatibility mode @@ -1473,10 +1473,10 @@ NTSTATUS NTAPI SamUnregisterObjectChangeNotification( #define SAM_SID_COMPATIBILITY_LAX 1 #define SAM_SID_COMPATIBILITY_STRICT 2 -__checkReturn +_Check_return_ NTSTATUS NTAPI SamGetCompatibilityMode( - __in SAM_HANDLE ObjectHandle, - __out ULONG *Mode + _In_ SAM_HANDLE ObjectHandle, + _Out_ ULONG *Mode ); // Password validation @@ -1491,7 +1491,7 @@ typedef enum _PASSWORD_POLICY_VALIDATION_TYPE typedef struct _SAM_VALIDATE_PASSWORD_HASH { ULONG Length; - __bcount(Length) PUCHAR Hash; + _Field_size_bytes_(Length) PUCHAR Hash; } SAM_VALIDATE_PASSWORD_HASH, *PSAM_VALIDATE_PASSWORD_HASH; // Flags for PresentFields in SAM_VALIDATE_PERSISTED_FIELDS @@ -1511,7 +1511,7 @@ typedef struct _SAM_VALIDATE_PERSISTED_FIELDS LARGE_INTEGER LockoutTime; ULONG BadPasswordCount; ULONG PasswordHistoryLength; - __bcount(PasswordHistoryLength) PSAM_VALIDATE_PASSWORD_HASH PasswordHistory; + _Field_size_bytes_(PasswordHistoryLength) PSAM_VALIDATE_PASSWORD_HASH PasswordHistory; } SAM_VALIDATE_PERSISTED_FIELDS, *PSAM_VALIDATE_PERSISTED_FIELDS; typedef enum _SAM_VALIDATE_VALIDATION_STATUS @@ -1574,12 +1574,12 @@ typedef union _SAM_VALIDATE_OUTPUT_ARG SAM_VALIDATE_STANDARD_OUTPUT_ARG ValidatePasswordResetOutput; } SAM_VALIDATE_OUTPUT_ARG, *PSAM_VALIDATE_OUTPUT_ARG; -__checkReturn +_Check_return_ NTSTATUS NTAPI SamValidatePassword( - __in_opt PUNICODE_STRING ServerName, - __in PASSWORD_POLICY_VALIDATION_TYPE ValidationType, - __in PSAM_VALIDATE_INPUT_ARG InputArg, - __out PSAM_VALIDATE_OUTPUT_ARG *OutputArg + _In_opt_ PUNICODE_STRING ServerName, + _In_ PASSWORD_POLICY_VALIDATION_TYPE ValidationType, + _In_ PSAM_VALIDATE_INPUT_ARG InputArg, + _Out_ PSAM_VALIDATE_OUTPUT_ARG *OutputArg ); // Generic operation @@ -1612,12 +1612,12 @@ typedef union _SAM_GENERIC_OPERATION_OUTPUT SAM_OPERATION_OBJCHG_OUTPUT ObjChangeOut; } SAM_GENERIC_OPERATION_OUTPUT, *PSAM_GENERIC_OPERATION_OUTPUT; -__checkReturn +_Check_return_ NTSTATUS NTAPI SamPerformGenericOperation( - __in_opt PWSTR ServerName, - __in SAM_GENERIC_OPERATION_TYPE OperationType, - __in PSAM_GENERIC_OPERATION_INPUT OperationIn, - __out PSAM_GENERIC_OPERATION_OUTPUT *OperationOut + _In_opt_ PWSTR ServerName, + _In_ SAM_GENERIC_OPERATION_TYPE OperationType, + _In_ PSAM_GENERIC_OPERATION_INPUT OperationIn, + _Out_ PSAM_GENERIC_OPERATION_OUTPUT *OperationOut ); #endif diff --git a/2.x/trunk/phlib/include/ntseapi.h b/2.x/trunk/phlib/include/ntseapi.h index f6c8e27b7..9227568b7 100644 --- a/2.x/trunk/phlib/include/ntseapi.h +++ b/2.x/trunk/phlib/include/ntseapi.h @@ -47,153 +47,153 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateToken( - __out PHANDLE TokenHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in TOKEN_TYPE TokenType, - __in PLUID AuthenticationId, - __in PLARGE_INTEGER ExpirationTime, - __in PTOKEN_USER User, - __in PTOKEN_GROUPS Groups, - __in PTOKEN_PRIVILEGES Privileges, - __in_opt PTOKEN_OWNER Owner, - __in PTOKEN_PRIMARY_GROUP PrimaryGroup, - __in_opt PTOKEN_DEFAULT_DACL DefaultDacl, - __in PTOKEN_SOURCE TokenSource + _Out_ PHANDLE TokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ TOKEN_TYPE TokenType, + _In_ PLUID AuthenticationId, + _In_ PLARGE_INTEGER ExpirationTime, + _In_ PTOKEN_USER User, + _In_ PTOKEN_GROUPS Groups, + _In_ PTOKEN_PRIVILEGES Privileges, + _In_opt_ PTOKEN_OWNER Owner, + _In_ PTOKEN_PRIMARY_GROUP PrimaryGroup, + _In_opt_ PTOKEN_DEFAULT_DACL DefaultDacl, + _In_ PTOKEN_SOURCE TokenSource ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenProcessToken( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE TokenHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenProcessTokenEx( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __out PHANDLE TokenHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenThreadToken( - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in BOOLEAN OpenAsSelf, - __out PHANDLE TokenHandle + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ BOOLEAN OpenAsSelf, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenThreadTokenEx( - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in BOOLEAN OpenAsSelf, - __in ULONG HandleAttributes, - __out PHANDLE TokenHandle + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ BOOLEAN OpenAsSelf, + _In_ ULONG HandleAttributes, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtDuplicateToken( - __in HANDLE ExistingTokenHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in BOOLEAN EffectiveOnly, - __in TOKEN_TYPE TokenType, - __out PHANDLE NewTokenHandle + _In_ HANDLE ExistingTokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ BOOLEAN EffectiveOnly, + _In_ TOKEN_TYPE TokenType, + _Out_ PHANDLE NewTokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationToken( - __in HANDLE TokenHandle, - __in TOKEN_INFORMATION_CLASS TokenInformationClass, - __out_bcount(TokenInformationLength) PVOID TokenInformation, - __in ULONG TokenInformationLength, - __out PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, + _Out_writes_bytes_(TokenInformationLength) PVOID TokenInformation, + _In_ ULONG TokenInformationLength, + _Out_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationToken( - __in HANDLE TokenHandle, - __in TOKEN_INFORMATION_CLASS TokenInformationClass, - __in_bcount(TokenInformationLength) PVOID TokenInformation, - __in ULONG TokenInformationLength + _In_ HANDLE TokenHandle, + _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, + _In_reads_bytes_(TokenInformationLength) PVOID TokenInformation, + _In_ ULONG TokenInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI NtAdjustPrivilegesToken( - __in HANDLE TokenHandle, - __in BOOLEAN DisableAllPrivileges, - __in_opt PTOKEN_PRIVILEGES NewState, - __in ULONG BufferLength, - __out_bcount_part_opt(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, - __out __drv_when(PreviousState == NULL, __out_opt) PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_ BOOLEAN DisableAllPrivileges, + _In_opt_ PTOKEN_PRIVILEGES NewState, + _In_ ULONG BufferLength, + _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, + _Out_ _When_(PreviousState == NULL, _Out_opt_) PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtAdjustGroupsToken( - __in HANDLE TokenHandle, - __in BOOLEAN ResetToDefault, - __in_opt PTOKEN_GROUPS NewState, - __in_opt ULONG BufferLength, - __out_bcount_part_opt(BufferLength, *ReturnLength) PTOKEN_GROUPS PreviousState, - __out PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_ BOOLEAN ResetToDefault, + _In_opt_ PTOKEN_GROUPS NewState, + _In_opt_ ULONG BufferLength, + _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_GROUPS PreviousState, + _Out_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI NtFilterToken( - __in HANDLE ExistingTokenHandle, - __in ULONG Flags, - __in_opt PTOKEN_GROUPS SidsToDisable, - __in_opt PTOKEN_PRIVILEGES PrivilegesToDelete, - __in_opt PTOKEN_GROUPS RestrictedSids, - __out PHANDLE NewTokenHandle + _In_ HANDLE ExistingTokenHandle, + _In_ ULONG Flags, + _In_opt_ PTOKEN_GROUPS SidsToDisable, + _In_opt_ PTOKEN_PRIVILEGES PrivilegesToDelete, + _In_opt_ PTOKEN_GROUPS RestrictedSids, + _Out_ PHANDLE NewTokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI NtCompareTokens( - __in HANDLE FirstTokenHandle, - __in HANDLE SecondTokenHandle, - __out PBOOLEAN Equal + _In_ HANDLE FirstTokenHandle, + _In_ HANDLE SecondTokenHandle, + _Out_ PBOOLEAN Equal ); NTSYSCALLAPI NTSTATUS NTAPI NtPrivilegeCheck( - __in HANDLE ClientToken, - __inout PPRIVILEGE_SET RequiredPrivileges, - __out PBOOLEAN Result + _In_ HANDLE ClientToken, + _Inout_ PPRIVILEGE_SET RequiredPrivileges, + _Out_ PBOOLEAN Result ); NTSYSCALLAPI NTSTATUS NTAPI NtImpersonateAnonymousToken( - __in HANDLE ThreadHandle + _In_ HANDLE ThreadHandle ); // Access checking @@ -202,48 +202,48 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheck( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in PGENERIC_MAPPING GenericMapping, - __out_bcount(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, - __inout PULONG PrivilegeSetLength, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_ PGENERIC_MAPPING GenericMapping, + _Out_writes_bytes_(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, + _Inout_ PULONG PrivilegeSetLength, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus ); NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheckByType( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in_ecount(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __out_bcount(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, - __inout PULONG PrivilegeSetLength, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_reads_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _Out_writes_bytes_(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, + _Inout_ PULONG PrivilegeSetLength, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus ); NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheckByTypeResultList( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in_ecount(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __out_bcount(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, - __inout PULONG PrivilegeSetLength, - __out_ecount(ObjectTypeListLength) PACCESS_MASK GrantedAccess, - __out_ecount(ObjectTypeListLength) PNTSTATUS AccessStatus + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_reads_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _Out_writes_bytes_(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, + _Inout_ PULONG PrivilegeSetLength, + _Out_writes_(ObjectTypeListLength) PACCESS_MASK GrantedAccess, + _Out_writes_(ObjectTypeListLength) PNTSTATUS AccessStatus ); // Audit alarm @@ -252,143 +252,143 @@ NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheckAndAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in ACCESS_MASK DesiredAccess, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ ACCESS_MASK DesiredAccess, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheckByTypeAndAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in ACCESS_MASK DesiredAccess, - __in AUDIT_EVENT_TYPE AuditType, - __in ULONG Flags, - __in_ecount_opt(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ ACCESS_MASK DesiredAccess, + _In_ AUDIT_EVENT_TYPE AuditType, + _In_ ULONG Flags, + _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheckByTypeResultListAndAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in ACCESS_MASK DesiredAccess, - __in AUDIT_EVENT_TYPE AuditType, - __in ULONG Flags, - __in_ecount_opt(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out_ecount(ObjectTypeListLength) PACCESS_MASK GrantedAccess, - __out_ecount(ObjectTypeListLength) PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ ACCESS_MASK DesiredAccess, + _In_ AUDIT_EVENT_TYPE AuditType, + _In_ ULONG Flags, + _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_writes_(ObjectTypeListLength) PACCESS_MASK GrantedAccess, + _Out_writes_(ObjectTypeListLength) PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheckByTypeResultListAndAuditAlarmByHandle( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in HANDLE ClientToken, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in ACCESS_MASK DesiredAccess, - __in AUDIT_EVENT_TYPE AuditType, - __in ULONG Flags, - __in_ecount_opt(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out_ecount(ObjectTypeListLength) PACCESS_MASK GrantedAccess, - __out_ecount(ObjectTypeListLength) PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ HANDLE ClientToken, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ ACCESS_MASK DesiredAccess, + _In_ AUDIT_EVENT_TYPE AuditType, + _In_ ULONG Flags, + _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_writes_(ObjectTypeListLength) PACCESS_MASK GrantedAccess, + _Out_writes_(ObjectTypeListLength) PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI NtOpenObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in_opt PSECURITY_DESCRIPTOR SecurityDescriptor, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in ACCESS_MASK GrantedAccess, - __in_opt PPRIVILEGE_SET Privileges, - __in BOOLEAN ObjectCreation, - __in BOOLEAN AccessGranted, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_ ACCESS_MASK GrantedAccess, + _In_opt_ PPRIVILEGE_SET Privileges, + _In_ BOOLEAN ObjectCreation, + _In_ BOOLEAN AccessGranted, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI NtPrivilegeObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in PPRIVILEGE_SET Privileges, - __in BOOLEAN AccessGranted + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_ PPRIVILEGE_SET Privileges, + _In_ BOOLEAN AccessGranted ); NTSYSCALLAPI NTSTATUS NTAPI NtCloseObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in BOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ BOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI NtDeleteObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in BOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ BOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI NtPrivilegedServiceAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in PUNICODE_STRING ServiceName, - __in HANDLE ClientToken, - __in PPRIVILEGE_SET Privileges, - __in BOOLEAN AccessGranted + _In_ PUNICODE_STRING SubsystemName, + _In_ PUNICODE_STRING ServiceName, + _In_ HANDLE ClientToken, + _In_ PPRIVILEGE_SET Privileges, + _In_ BOOLEAN AccessGranted ); // Authz @@ -482,12 +482,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQuerySecurityAttributesToken( - __in HANDLE TokenHandle, - __in_ecount_opt(NumberOfAttributes) PUNICODE_STRING Attributes, - __in ULONG NumberOfAttributes, - __out_bcount(Length) PVOID Buffer, // PTOKEN_SECURITY_ATTRIBUTES_INFORMATION - __in ULONG Length, - __out PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_reads_opt_(NumberOfAttributes) PUNICODE_STRING Attributes, + _In_ ULONG NumberOfAttributes, + _Out_writes_bytes_(Length) PVOID Buffer, // PTOKEN_SECURITY_ATTRIBUTES_INFORMATION + _In_ ULONG Length, + _Out_ PULONG ReturnLength ); #endif diff --git a/2.x/trunk/phlib/include/nttmapi.h b/2.x/trunk/phlib/include/nttmapi.h index 87d19a865..e024f0d7c 100644 --- a/2.x/trunk/phlib/include/nttmapi.h +++ b/2.x/trunk/phlib/include/nttmapi.h @@ -6,12 +6,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateTransactionManager( - __out PHANDLE TmHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PUNICODE_STRING LogFileName, - __in_opt ULONG CreateOptions, - __in_opt ULONG CommitStrength + _Out_ PHANDLE TmHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PUNICODE_STRING LogFileName, + _In_opt_ ULONG CreateOptions, + _In_opt_ ULONG CommitStrength ); #endif @@ -20,12 +20,12 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenTransactionManager( - __out PHANDLE TmHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PUNICODE_STRING LogFileName, - __in_opt LPGUID TmIdentity, - __in_opt ULONG OpenOptions + _Out_ PHANDLE TmHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PUNICODE_STRING LogFileName, + _In_opt_ LPGUID TmIdentity, + _In_opt_ ULONG OpenOptions ); #endif @@ -34,8 +34,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRenameTransactionManager( - __in PUNICODE_STRING LogFileName, - __in LPGUID ExistingTransactionManagerGuid + _In_ PUNICODE_STRING LogFileName, + _In_ LPGUID ExistingTransactionManagerGuid ); #endif @@ -44,8 +44,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRollforwardTransactionManager( - __in HANDLE TransactionManagerHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE TransactionManagerHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -54,7 +54,7 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRecoverTransactionManager( - __in HANDLE TransactionManagerHandle + _In_ HANDLE TransactionManagerHandle ); #endif @@ -63,11 +63,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationTransactionManager( - __in HANDLE TransactionManagerHandle, - __in TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - __out_bcount(TransactionManagerInformationLength) PVOID TransactionManagerInformation, - __in ULONG TransactionManagerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TransactionManagerHandle, + _In_ TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + _Out_writes_bytes_(TransactionManagerInformationLength) PVOID TransactionManagerInformation, + _In_ ULONG TransactionManagerInformationLength, + _Out_opt_ PULONG ReturnLength ); #endif @@ -76,10 +76,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationTransactionManager( - __in_opt HANDLE TmHandle, - __in TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - __in_bcount(TransactionManagerInformationLength) PVOID TransactionManagerInformation, - __in ULONG TransactionManagerInformationLength + _In_opt_ HANDLE TmHandle, + _In_ TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + _In_reads_bytes_(TransactionManagerInformationLength) PVOID TransactionManagerInformation, + _In_ ULONG TransactionManagerInformationLength ); #endif @@ -88,11 +88,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtEnumerateTransactionObject( - __in_opt HANDLE RootObjectHandle, - __in KTMOBJECT_TYPE QueryType, - __inout_bcount(ObjectCursorLength) PKTMOBJECT_CURSOR ObjectCursor, - __in ULONG ObjectCursorLength, - __out PULONG ReturnLength + _In_opt_ HANDLE RootObjectHandle, + _In_ KTMOBJECT_TYPE QueryType, + _Inout_updates_bytes_(ObjectCursorLength) PKTMOBJECT_CURSOR ObjectCursor, + _In_ ULONG ObjectCursorLength, + _Out_ PULONG ReturnLength ); #endif @@ -101,16 +101,16 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateTransaction( - __out PHANDLE TransactionHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt LPGUID Uow, - __in_opt HANDLE TmHandle, - __in_opt ULONG CreateOptions, - __in_opt ULONG IsolationLevel, - __in_opt ULONG IsolationFlags, - __in_opt PLARGE_INTEGER Timeout, - __in_opt PUNICODE_STRING Description + _Out_ PHANDLE TransactionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ LPGUID Uow, + _In_opt_ HANDLE TmHandle, + _In_opt_ ULONG CreateOptions, + _In_opt_ ULONG IsolationLevel, + _In_opt_ ULONG IsolationFlags, + _In_opt_ PLARGE_INTEGER Timeout, + _In_opt_ PUNICODE_STRING Description ); #endif @@ -119,11 +119,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenTransaction( - __out PHANDLE TransactionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in LPGUID Uow, - __in_opt HANDLE TmHandle + _Out_ PHANDLE TransactionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ LPGUID Uow, + _In_opt_ HANDLE TmHandle ); #endif @@ -132,11 +132,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationTransaction( - __in HANDLE TransactionHandle, - __in TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - __out_bcount(TransactionInformationLength) PVOID TransactionInformation, - __in ULONG TransactionInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TransactionHandle, + _In_ TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + _Out_writes_bytes_(TransactionInformationLength) PVOID TransactionInformation, + _In_ ULONG TransactionInformationLength, + _Out_opt_ PULONG ReturnLength ); #endif @@ -145,10 +145,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationTransaction( - __in HANDLE TransactionHandle, - __in TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - __in_bcount(TransactionInformationLength) PVOID TransactionInformation, - __in ULONG TransactionInformationLength + _In_ HANDLE TransactionHandle, + _In_ TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + _In_reads_bytes_(TransactionInformationLength) PVOID TransactionInformation, + _In_ ULONG TransactionInformationLength ); #endif @@ -157,8 +157,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCommitTransaction( - __in HANDLE TransactionHandle, - __in BOOLEAN Wait + _In_ HANDLE TransactionHandle, + _In_ BOOLEAN Wait ); #endif @@ -167,8 +167,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRollbackTransaction( - __in HANDLE TransactionHandle, - __in BOOLEAN Wait + _In_ HANDLE TransactionHandle, + _In_ BOOLEAN Wait ); #endif @@ -177,14 +177,14 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateEnlistment( - __out PHANDLE EnlistmentHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ResourceManagerHandle, - __in HANDLE TransactionHandle, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt ULONG CreateOptions, - __in NOTIFICATION_MASK NotificationMask, - __in_opt PVOID EnlistmentKey + _Out_ PHANDLE EnlistmentHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ResourceManagerHandle, + _In_ HANDLE TransactionHandle, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ ULONG CreateOptions, + _In_ NOTIFICATION_MASK NotificationMask, + _In_opt_ PVOID EnlistmentKey ); #endif @@ -193,11 +193,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenEnlistment( - __out PHANDLE EnlistmentHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ResourceManagerHandle, - __in LPGUID EnlistmentGuid, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EnlistmentHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ResourceManagerHandle, + _In_ LPGUID EnlistmentGuid, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); #endif @@ -206,11 +206,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationEnlistment( - __in HANDLE EnlistmentHandle, - __in ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, - __out_bcount(EnlistmentInformationLength) PVOID EnlistmentInformation, - __in ULONG EnlistmentInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE EnlistmentHandle, + _In_ ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + _Out_writes_bytes_(EnlistmentInformationLength) PVOID EnlistmentInformation, + _In_ ULONG EnlistmentInformationLength, + _Out_opt_ PULONG ReturnLength ); #endif @@ -219,10 +219,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationEnlistment( - __in_opt HANDLE EnlistmentHandle, - __in ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, - __in_bcount(EnlistmentInformationLength) PVOID EnlistmentInformation, - __in ULONG EnlistmentInformationLength + _In_opt_ HANDLE EnlistmentHandle, + _In_ ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + _In_reads_bytes_(EnlistmentInformationLength) PVOID EnlistmentInformation, + _In_ ULONG EnlistmentInformationLength ); #endif @@ -231,8 +231,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRecoverEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PVOID EnlistmentKey + _In_ HANDLE EnlistmentHandle, + _In_opt_ PVOID EnlistmentKey ); #endif @@ -241,8 +241,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtPrePrepareEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -251,8 +251,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtPrepareEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -261,8 +261,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCommitEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -271,8 +271,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRollbackEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -281,8 +281,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtPrePrepareComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -291,8 +291,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtPrepareComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -301,8 +301,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCommitComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -311,8 +311,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtReadOnlyEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -321,8 +321,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRollbackComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -331,8 +331,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSinglePhaseReject( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); #endif @@ -341,13 +341,13 @@ NTSYSCALLAPI NTSTATUS NTAPI NtCreateResourceManager( - __out PHANDLE ResourceManagerHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE TmHandle, - __in LPGUID RmGuid, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt ULONG CreateOptions, - __in_opt PUNICODE_STRING Description + _Out_ PHANDLE ResourceManagerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE TmHandle, + _In_ LPGUID RmGuid, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ ULONG CreateOptions, + _In_opt_ PUNICODE_STRING Description ); #endif @@ -356,11 +356,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtOpenResourceManager( - __out PHANDLE ResourceManagerHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE TmHandle, - __in_opt LPGUID ResourceManagerGuid, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE ResourceManagerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE TmHandle, + _In_opt_ LPGUID ResourceManagerGuid, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); #endif @@ -369,7 +369,7 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRecoverResourceManager( - __in HANDLE ResourceManagerHandle + _In_ HANDLE ResourceManagerHandle ); #endif @@ -378,13 +378,13 @@ NTSYSCALLAPI NTSTATUS NTAPI NtGetNotificationResourceManager( - __in HANDLE ResourceManagerHandle, - __out PTRANSACTION_NOTIFICATION TransactionNotification, - __in ULONG NotificationLength, - __in_opt PLARGE_INTEGER Timeout, - __out_opt PULONG ReturnLength, - __in ULONG Asynchronous, - __in_opt ULONG_PTR AsynchronousContext + _In_ HANDLE ResourceManagerHandle, + _Out_ PTRANSACTION_NOTIFICATION TransactionNotification, + _In_ ULONG NotificationLength, + _In_opt_ PLARGE_INTEGER Timeout, + _Out_opt_ PULONG ReturnLength, + _In_ ULONG Asynchronous, + _In_opt_ ULONG_PTR AsynchronousContext ); #endif @@ -393,11 +393,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtQueryInformationResourceManager( - __in HANDLE ResourceManagerHandle, - __in RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - __out_bcount(ResourceManagerInformationLength) PVOID ResourceManagerInformation, - __in ULONG ResourceManagerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ResourceManagerHandle, + _In_ RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + _Out_writes_bytes_(ResourceManagerInformationLength) PVOID ResourceManagerInformation, + _In_ ULONG ResourceManagerInformationLength, + _Out_opt_ PULONG ReturnLength ); #endif @@ -406,10 +406,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtSetInformationResourceManager( - __in HANDLE ResourceManagerHandle, - __in RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - __in_bcount(ResourceManagerInformationLength) PVOID ResourceManagerInformation, - __in ULONG ResourceManagerInformationLength + _In_ HANDLE ResourceManagerHandle, + _In_ RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + _In_reads_bytes_(ResourceManagerInformationLength) PVOID ResourceManagerInformation, + _In_ ULONG ResourceManagerInformationLength ); #endif @@ -418,11 +418,11 @@ NTSYSCALLAPI NTSTATUS NTAPI NtRegisterProtocolAddressInformation( - __in HANDLE ResourceManager, - __in PCRM_PROTOCOL_ID ProtocolId, - __in ULONG ProtocolInformationSize, - __in PVOID ProtocolInformation, - __in_opt ULONG CreateOptions + _In_ HANDLE ResourceManager, + _In_ PCRM_PROTOCOL_ID ProtocolId, + _In_ ULONG ProtocolInformationSize, + _In_ PVOID ProtocolInformation, + _In_opt_ ULONG CreateOptions ); #endif @@ -431,10 +431,10 @@ NTSYSCALLAPI NTSTATUS NTAPI NtPropagationComplete( - __in HANDLE ResourceManagerHandle, - __in ULONG RequestCookie, - __in ULONG BufferLength, - __in PVOID Buffer + _In_ HANDLE ResourceManagerHandle, + _In_ ULONG RequestCookie, + _In_ ULONG BufferLength, + _In_ PVOID Buffer ); #endif @@ -443,9 +443,9 @@ NTSYSCALLAPI NTSTATUS NTAPI NtPropagationFailed( - __in HANDLE ResourceManagerHandle, - __in ULONG RequestCookie, - __in NTSTATUS PropStatus + _In_ HANDLE ResourceManagerHandle, + _In_ ULONG RequestCookie, + _In_ NTSTATUS PropStatus ); #endif @@ -455,8 +455,8 @@ NTSYSCALLAPI NTSTATUS NTAPI NtFreezeTransactions( - __in PLARGE_INTEGER FreezeTimeout, - __in PLARGE_INTEGER ThawTimeout + _In_ PLARGE_INTEGER FreezeTimeout, + _In_ PLARGE_INTEGER ThawTimeout ); #endif diff --git a/2.x/trunk/phlib/include/nttp.h b/2.x/trunk/phlib/include/nttp.h index 0360a5eb9..2e62cb8f4 100644 --- a/2.x/trunk/phlib/include/nttp.h +++ b/2.x/trunk/phlib/include/nttp.h @@ -7,29 +7,29 @@ typedef struct _TP_ALPC TP_ALPC, *PTP_ALPC; // private typedef VOID (NTAPI *PTP_ALPC_CALLBACK)( - __inout PTP_CALLBACK_INSTANCE Instance, - __inout_opt PVOID Context, - __in PTP_ALPC Alpc + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _Inout_opt_ PVOID Context, + _In_ PTP_ALPC Alpc ); // rev typedef VOID (NTAPI *PTP_ALPC_CALLBACK_EX)( - __inout PTP_CALLBACK_INSTANCE Instance, - __inout_opt PVOID Context, - __in PTP_ALPC Alpc, - __in PVOID ApcContext + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _Inout_opt_ PVOID Context, + _In_ PTP_ALPC Alpc, + _In_ PVOID ApcContext ); #if (PHNT_VERSION >= PHNT_VISTA) // private -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI TpAllocPool( - __out PTP_POOL *PoolReturn, - __reserved PVOID Reserved + _Out_ PTP_POOL *PoolReturn, + _Reserved_ PVOID Reserved ); // winbase:CloseThreadpool @@ -37,7 +37,7 @@ NTSYSAPI VOID NTAPI TpReleasePool( - __inout PTP_POOL Pool + _Inout_ PTP_POOL Pool ); // winbase:SetThreadpoolThreadMaximum @@ -45,8 +45,8 @@ NTSYSAPI VOID NTAPI TpSetPoolMaxThreads( - __inout PTP_POOL Pool, - __in LONG MaxThreads + _Inout_ PTP_POOL Pool, + _In_ LONG MaxThreads ); // private @@ -54,8 +54,8 @@ NTSYSAPI NTSTATUS NTAPI TpSetPoolMinThreads( - __inout PTP_POOL Pool, - __in LONG MinThreads + _Inout_ PTP_POOL Pool, + _In_ LONG MinThreads ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -64,8 +64,8 @@ NTSYSAPI NTSTATUS NTAPI TpQueryPoolStackInformation( - __in PTP_POOL Pool, - __out PTP_POOL_STACK_INFORMATION PoolStackInformation + _In_ PTP_POOL Pool, + _Out_ PTP_POOL_STACK_INFORMATION PoolStackInformation ); #endif @@ -75,18 +75,18 @@ NTSYSAPI NTSTATUS NTAPI TpSetPoolStackInformation( - __inout PTP_POOL Pool, - __in PTP_POOL_STACK_INFORMATION PoolStackInformation + _Inout_ PTP_POOL Pool, + _In_ PTP_POOL_STACK_INFORMATION PoolStackInformation ); #endif // private -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI TpAllocCleanupGroup( - __out PTP_CLEANUP_GROUP *CleanupGroupReturn + _Out_ PTP_CLEANUP_GROUP *CleanupGroupReturn ); // winbase:CloseThreadpoolCleanupGroup @@ -94,7 +94,7 @@ NTSYSAPI VOID NTAPI TpReleaseCleanupGroup( - __inout PTP_CLEANUP_GROUP CleanupGroup + _Inout_ PTP_CLEANUP_GROUP CleanupGroup ); // winbase:CloseThreadpoolCleanupGroupMembers @@ -102,9 +102,9 @@ NTSYSAPI VOID NTAPI TpReleaseCleanupGroupMembers( - __inout PTP_CLEANUP_GROUP CleanupGroup, - __in LOGICAL CancelPendingCallbacks, - __inout_opt PVOID CleanupParameter + _Inout_ PTP_CLEANUP_GROUP CleanupGroup, + _In_ LOGICAL CancelPendingCallbacks, + _Inout_opt_ PVOID CleanupParameter ); // winbase:SetEventWhenCallbackReturns @@ -112,8 +112,8 @@ NTSYSAPI VOID NTAPI TpCallbackSetEventOnCompletion( - __inout PTP_CALLBACK_INSTANCE Instance, - __in HANDLE Event + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _In_ HANDLE Event ); // winbase:ReleaseSemaphoreWhenCallbackReturns @@ -121,9 +121,9 @@ NTSYSAPI VOID NTAPI TpCallbackReleaseSemaphoreOnCompletion( - __inout PTP_CALLBACK_INSTANCE Instance, - __in HANDLE Semaphore, - __in LONG ReleaseCount + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _In_ HANDLE Semaphore, + _In_ LONG ReleaseCount ); // winbase:ReleaseMutexWhenCallbackReturns @@ -131,8 +131,8 @@ NTSYSAPI VOID NTAPI TpCallbackReleaseMutexOnCompletion( - __inout PTP_CALLBACK_INSTANCE Instance, - __in HANDLE Mutex + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _In_ HANDLE Mutex ); // winbase:LeaveCriticalSectionWhenCallbackReturns @@ -140,8 +140,8 @@ NTSYSAPI VOID NTAPI TpCallbackLeaveCriticalSectionOnCompletion( - __inout PTP_CALLBACK_INSTANCE Instance, - __inout PRTL_CRITICAL_SECTION CriticalSection + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _Inout_ PRTL_CRITICAL_SECTION CriticalSection ); // winbase:FreeLibraryWhenCallbackReturns @@ -149,8 +149,8 @@ NTSYSAPI VOID NTAPI TpCallbackUnloadDllOnCompletion( - __inout PTP_CALLBACK_INSTANCE Instance, - __in PVOID DllHandle + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _In_ PVOID DllHandle ); // winbase:CallbackMayRunLong @@ -158,7 +158,7 @@ NTSYSAPI NTSTATUS NTAPI TpCallbackMayRunLong( - __inout PTP_CALLBACK_INSTANCE Instance + _Inout_ PTP_CALLBACK_INSTANCE Instance ); // winbase:DisassociateCurrentThreadFromCallback @@ -166,30 +166,30 @@ NTSYSAPI VOID NTAPI TpDisassociateCallback( - __inout PTP_CALLBACK_INSTANCE Instance + _Inout_ PTP_CALLBACK_INSTANCE Instance ); // winbase:TrySubmitThreadpoolCallback -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI TpSimpleTryPost( - __in PTP_SIMPLE_CALLBACK Callback, - __inout_opt PVOID Context, - __in_opt PTP_CALLBACK_ENVIRON CallbackEnviron + _In_ PTP_SIMPLE_CALLBACK Callback, + _Inout_opt_ PVOID Context, + _In_opt_ PTP_CALLBACK_ENVIRON CallbackEnviron ); // private -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI TpAllocWork( - __out PTP_WORK *WorkReturn, - __in PTP_WORK_CALLBACK Callback, - __inout_opt PVOID Context, - __in_opt PTP_CALLBACK_ENVIRON CallbackEnviron + _Out_ PTP_WORK *WorkReturn, + _In_ PTP_WORK_CALLBACK Callback, + _Inout_opt_ PVOID Context, + _In_opt_ PTP_CALLBACK_ENVIRON CallbackEnviron ); // winbase:CloseThreadpoolWork @@ -197,7 +197,7 @@ NTSYSAPI VOID NTAPI TpReleaseWork( - __inout PTP_WORK Work + _Inout_ PTP_WORK Work ); // winbase:SubmitThreadpoolWork @@ -205,7 +205,7 @@ NTSYSAPI VOID NTAPI TpPostWork( - __inout PTP_WORK Work + _Inout_ PTP_WORK Work ); // winbase:WaitForThreadpoolWorkCallbacks @@ -213,20 +213,20 @@ NTSYSAPI VOID NTAPI TpWaitForWork( - __inout PTP_WORK Work, - __in LOGICAL CancelPendingCallbacks + _Inout_ PTP_WORK Work, + _In_ LOGICAL CancelPendingCallbacks ); // private -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI TpAllocTimer( - __out PTP_TIMER *Timer, - __in PTP_TIMER_CALLBACK Callback, - __inout_opt PVOID Context, - __in_opt PTP_CALLBACK_ENVIRON CallbackEnviron + _Out_ PTP_TIMER *Timer, + _In_ PTP_TIMER_CALLBACK Callback, + _Inout_opt_ PVOID Context, + _In_opt_ PTP_CALLBACK_ENVIRON CallbackEnviron ); // winbase:CloseThreadpoolTimer @@ -234,7 +234,7 @@ NTSYSAPI VOID NTAPI TpReleaseTimer( - __inout PTP_TIMER Timer + _Inout_ PTP_TIMER Timer ); // winbase:SetThreadpoolTimer @@ -242,10 +242,10 @@ NTSYSAPI VOID NTAPI TpSetTimer( - __inout PTP_TIMER Timer, - __in_opt PLARGE_INTEGER DueTime, - __in LONG Period, - __in_opt LONG WindowLength + _Inout_ PTP_TIMER Timer, + _In_opt_ PLARGE_INTEGER DueTime, + _In_ LONG Period, + _In_opt_ LONG WindowLength ); // winbase:IsThreadpoolTimerSet @@ -253,7 +253,7 @@ NTSYSAPI LOGICAL NTAPI TpIsTimerSet( - __in PTP_TIMER Timer + _In_ PTP_TIMER Timer ); // winbase:WaitForThreadpoolTimerCallbacks @@ -261,20 +261,20 @@ NTSYSAPI VOID NTAPI TpWaitForTimer( - __inout PTP_TIMER Timer, - __in LOGICAL CancelPendingCallbacks + _Inout_ PTP_TIMER Timer, + _In_ LOGICAL CancelPendingCallbacks ); // private -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI TpAllocWait( - __out PTP_WAIT *WaitReturn, - __in PTP_WAIT_CALLBACK Callback, - __inout_opt PVOID Context, - __in_opt PTP_CALLBACK_ENVIRON CallbackEnviron + _Out_ PTP_WAIT *WaitReturn, + _In_ PTP_WAIT_CALLBACK Callback, + _Inout_opt_ PVOID Context, + _In_opt_ PTP_CALLBACK_ENVIRON CallbackEnviron ); // winbase:CloseThreadpoolWait @@ -282,7 +282,7 @@ NTSYSAPI VOID NTAPI TpReleaseWait( - __inout PTP_WAIT Wait + _Inout_ PTP_WAIT Wait ); // winbase:SetThreadpoolWait @@ -290,9 +290,9 @@ NTSYSAPI VOID NTAPI TpSetWait( - __inout PTP_WAIT Wait, - __in_opt HANDLE Handle, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PTP_WAIT Wait, + _In_opt_ HANDLE Handle, + _In_opt_ PLARGE_INTEGER Timeout ); // winbase:WaitForThreadpoolWaitCallbacks @@ -300,30 +300,30 @@ NTSYSAPI VOID NTAPI TpWaitForWait( - __inout PTP_WAIT Wait, - __in LOGICAL CancelPendingCallbacks + _Inout_ PTP_WAIT Wait, + _In_ LOGICAL CancelPendingCallbacks ); // private typedef VOID (NTAPI *PTP_IO_CALLBACK)( - __inout PTP_CALLBACK_INSTANCE Instance, - __inout_opt PVOID Context, - __in PVOID ApcContext, - __in PIO_STATUS_BLOCK IoSB, - __in PTP_IO Io + _Inout_ PTP_CALLBACK_INSTANCE Instance, + _Inout_opt_ PVOID Context, + _In_ PVOID ApcContext, + _In_ PIO_STATUS_BLOCK IoSB, + _In_ PTP_IO Io ); // private -__checkReturn +_Check_return_ NTSYSAPI NTSTATUS NTAPI TpAllocIoCompletion( - __out PTP_IO *IoReturn, - __in HANDLE File, - __in PTP_IO_CALLBACK Callback, - __inout_opt PVOID Context, - __in_opt PTP_CALLBACK_ENVIRON CallbackEnviron + _Out_ PTP_IO *IoReturn, + _In_ HANDLE File, + _In_ PTP_IO_CALLBACK Callback, + _Inout_opt_ PVOID Context, + _In_opt_ PTP_CALLBACK_ENVIRON CallbackEnviron ); // winbase:CloseThreadpoolIo @@ -331,7 +331,7 @@ NTSYSAPI VOID NTAPI TpReleaseIoCompletion( - __inout PTP_IO Io + _Inout_ PTP_IO Io ); // winbase:StartThreadpoolIo @@ -339,7 +339,7 @@ NTSYSAPI VOID NTAPI TpStartAsyncIoOperation( - __inout PTP_IO Io + _Inout_ PTP_IO Io ); // winbase:CancelThreadpoolIo @@ -347,7 +347,7 @@ NTSYSAPI VOID NTAPI TpCancelAsyncIoOperation( - __inout PTP_IO Io + _Inout_ PTP_IO Io ); // winbase:WaitForThreadpoolIoCallbacks @@ -355,8 +355,8 @@ NTSYSAPI VOID NTAPI TpWaitForIoCompletion( - __inout PTP_IO Io, - __in LOGICAL CancelPendingCallbacks + _Inout_ PTP_IO Io, + _In_ LOGICAL CancelPendingCallbacks ); // private @@ -364,11 +364,11 @@ NTSYSAPI NTSTATUS NTAPI TpAllocAlpcCompletion( - __out PTP_ALPC *AlpcReturn, - __in HANDLE AlpcPort, - __in PTP_ALPC_CALLBACK Callback, - __inout_opt PVOID Context, - __in_opt PTP_CALLBACK_ENVIRON CallbackEnviron + _Out_ PTP_ALPC *AlpcReturn, + _In_ HANDLE AlpcPort, + _In_ PTP_ALPC_CALLBACK Callback, + _Inout_opt_ PVOID Context, + _In_opt_ PTP_CALLBACK_ENVIRON CallbackEnviron ); #if (PHNT_VERSION >= PHNT_WIN7) @@ -377,11 +377,11 @@ NTSYSAPI NTSTATUS NTAPI TpAllocAlpcCompletionEx( - __out PTP_ALPC *AlpcReturn, - __in HANDLE AlpcPort, - __in PTP_ALPC_CALLBACK_EX Callback, - __inout_opt PVOID Context, - __in_opt PTP_CALLBACK_ENVIRON CallbackEnviron + _Out_ PTP_ALPC *AlpcReturn, + _In_ HANDLE AlpcPort, + _In_ PTP_ALPC_CALLBACK_EX Callback, + _Inout_opt_ PVOID Context, + _In_opt_ PTP_CALLBACK_ENVIRON CallbackEnviron ); #endif @@ -390,7 +390,7 @@ NTSYSAPI VOID NTAPI TpReleaseAlpcCompletion( - __inout PTP_ALPC Alpc + _Inout_ PTP_ALPC Alpc ); // private @@ -398,7 +398,7 @@ NTSYSAPI VOID NTAPI TpWaitForAlpcCompletion( - __inout PTP_ALPC Alpc + _Inout_ PTP_ALPC Alpc ); // private @@ -414,7 +414,7 @@ NTSYSAPI VOID NTAPI TpCaptureCaller( - __in TP_TRACE_TYPE Type + _In_ TP_TRACE_TYPE Type ); // private @@ -422,7 +422,7 @@ NTSYSAPI VOID NTAPI TpCheckTerminateWorker( - __in HANDLE Thread + _In_ HANDLE Thread ); #endif diff --git a/2.x/trunk/phlib/include/ntwow64.h b/2.x/trunk/phlib/include/ntwow64.h index 65c1aac63..a83c666e8 100644 --- a/2.x/trunk/phlib/include/ntwow64.h +++ b/2.x/trunk/phlib/include/ntwow64.h @@ -421,8 +421,8 @@ typedef struct _TEB32 // Conversion FORCEINLINE VOID UStr32ToUStr( - __out PUNICODE_STRING Destination, - __in PUNICODE_STRING32 Source + _Out_ PUNICODE_STRING Destination, + _In_ PUNICODE_STRING32 Source ) { Destination->Length = Source->Length; @@ -431,8 +431,8 @@ FORCEINLINE VOID UStr32ToUStr( } FORCEINLINE VOID UStrToUStr32( - __out PUNICODE_STRING32 Destination, - __in PUNICODE_STRING Source + _Out_ PUNICODE_STRING32 Destination, + _In_ PUNICODE_STRING Source ) { Destination->Length = Source->Length; diff --git a/2.x/trunk/phlib/include/ntxcapi.h b/2.x/trunk/phlib/include/ntxcapi.h index ef63699e0..c270799ef 100644 --- a/2.x/trunk/phlib/include/ntxcapi.h +++ b/2.x/trunk/phlib/include/ntxcapi.h @@ -5,8 +5,8 @@ NTSYSAPI BOOLEAN NTAPI RtlDispatchException( - __in PEXCEPTION_RECORD ExceptionRecord, - __in PCONTEXT ContextRecord + _In_ PEXCEPTION_RECORD ExceptionRecord, + _In_ PCONTEXT ContextRecord ); NTSYSAPI @@ -14,31 +14,31 @@ DECLSPEC_NORETURN VOID NTAPI RtlRaiseStatus( - __in NTSTATUS Status + _In_ NTSTATUS Status ); NTSYSAPI VOID NTAPI RtlRaiseException( - __in PEXCEPTION_RECORD ExceptionRecord + _In_ PEXCEPTION_RECORD ExceptionRecord ); NTSYSCALLAPI NTSTATUS NTAPI NtContinue( - __in PCONTEXT ContextRecord, - __in BOOLEAN TestAlert + _In_ PCONTEXT ContextRecord, + _In_ BOOLEAN TestAlert ); NTSYSCALLAPI NTSTATUS NTAPI NtRaiseException( - __in PEXCEPTION_RECORD ExceptionRecord, - __in PCONTEXT ContextRecord, - __in BOOLEAN FirstChance + _In_ PEXCEPTION_RECORD ExceptionRecord, + _In_ PCONTEXT ContextRecord, + _In_ BOOLEAN FirstChance ); #endif diff --git a/2.x/trunk/phlib/include/ntzwapi.h b/2.x/trunk/phlib/include/ntzwapi.h index 4b7ae03a1..2f5c5a044 100644 --- a/2.x/trunk/phlib/include/ntzwapi.h +++ b/2.x/trunk/phlib/include/ntzwapi.h @@ -7,1165 +7,1165 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwAcceptConnectPort( - __out PHANDLE PortHandle, - __in_opt PVOID PortContext, - __in PPORT_MESSAGE ConnectionRequest, - __in BOOLEAN AcceptConnection, - __inout_opt PPORT_VIEW ServerView, - __out_opt PREMOTE_PORT_VIEW ClientView + _Out_ PHANDLE PortHandle, + _In_opt_ PVOID PortContext, + _In_ PPORT_MESSAGE ConnectionRequest, + _In_ BOOLEAN AcceptConnection, + _Inout_opt_ PPORT_VIEW ServerView, + _Out_opt_ PREMOTE_PORT_VIEW ClientView ); NTSYSCALLAPI NTSTATUS NTAPI ZwAccessCheck( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in PGENERIC_MAPPING GenericMapping, - __out_bcount(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, - __inout PULONG PrivilegeSetLength, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_ PGENERIC_MAPPING GenericMapping, + _Out_writes_bytes_(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, + _Inout_ PULONG PrivilegeSetLength, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus ); NTSYSCALLAPI NTSTATUS NTAPI ZwAccessCheckAndAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in ACCESS_MASK DesiredAccess, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ ACCESS_MASK DesiredAccess, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI ZwAccessCheckByType( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in_ecount(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __out_bcount(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, - __inout PULONG PrivilegeSetLength, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_reads_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _Out_writes_bytes_(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, + _Inout_ PULONG PrivilegeSetLength, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus ); NTSYSCALLAPI NTSTATUS NTAPI ZwAccessCheckByTypeAndAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in ACCESS_MASK DesiredAccess, - __in AUDIT_EVENT_TYPE AuditType, - __in ULONG Flags, - __in_ecount_opt(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out PACCESS_MASK GrantedAccess, - __out PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ ACCESS_MASK DesiredAccess, + _In_ AUDIT_EVENT_TYPE AuditType, + _In_ ULONG Flags, + _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_ PACCESS_MASK GrantedAccess, + _Out_ PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI ZwAccessCheckByTypeResultList( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in_ecount(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __out_bcount(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, - __inout PULONG PrivilegeSetLength, - __out_ecount(ObjectTypeListLength) PACCESS_MASK GrantedAccess, - __out_ecount(ObjectTypeListLength) PNTSTATUS AccessStatus + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_reads_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _Out_writes_bytes_(*PrivilegeSetLength) PPRIVILEGE_SET PrivilegeSet, + _Inout_ PULONG PrivilegeSetLength, + _Out_writes_(ObjectTypeListLength) PACCESS_MASK GrantedAccess, + _Out_writes_(ObjectTypeListLength) PNTSTATUS AccessStatus ); NTSYSCALLAPI NTSTATUS NTAPI ZwAccessCheckByTypeResultListAndAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in ACCESS_MASK DesiredAccess, - __in AUDIT_EVENT_TYPE AuditType, - __in ULONG Flags, - __in_ecount_opt(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out_ecount(ObjectTypeListLength) PACCESS_MASK GrantedAccess, - __out_ecount(ObjectTypeListLength) PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ ACCESS_MASK DesiredAccess, + _In_ AUDIT_EVENT_TYPE AuditType, + _In_ ULONG Flags, + _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_writes_(ObjectTypeListLength) PACCESS_MASK GrantedAccess, + _Out_writes_(ObjectTypeListLength) PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI ZwAccessCheckByTypeResultListAndAuditAlarmByHandle( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in HANDLE ClientToken, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in_opt PSID PrincipalSelfSid, - __in ACCESS_MASK DesiredAccess, - __in AUDIT_EVENT_TYPE AuditType, - __in ULONG Flags, - __in_ecount_opt(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, - __in ULONG ObjectTypeListLength, - __in PGENERIC_MAPPING GenericMapping, - __in BOOLEAN ObjectCreation, - __out_ecount(ObjectTypeListLength) PACCESS_MASK GrantedAccess, - __out_ecount(ObjectTypeListLength) PNTSTATUS AccessStatus, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ HANDLE ClientToken, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_opt_ PSID PrincipalSelfSid, + _In_ ACCESS_MASK DesiredAccess, + _In_ AUDIT_EVENT_TYPE AuditType, + _In_ ULONG Flags, + _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList, + _In_ ULONG ObjectTypeListLength, + _In_ PGENERIC_MAPPING GenericMapping, + _In_ BOOLEAN ObjectCreation, + _Out_writes_(ObjectTypeListLength) PACCESS_MASK GrantedAccess, + _Out_writes_(ObjectTypeListLength) PNTSTATUS AccessStatus, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI ZwAcquireCMFViewOwnership( - __out PULONGLONG TimeStamp, - __out PBOOLEAN tokenTaken, - __in BOOLEAN replaceExisting + _Out_ PULONGLONG TimeStamp, + _Out_ PBOOLEAN tokenTaken, + _In_ BOOLEAN replaceExisting ); NTSYSCALLAPI NTSTATUS NTAPI ZwAddAtom( - __in_bcount_opt(Length) PWSTR AtomName, - __in ULONG Length, - __out_opt PRTL_ATOM Atom + _In_reads_bytes_opt_(Length) PWSTR AtomName, + _In_ ULONG Length, + _Out_opt_ PRTL_ATOM Atom ); NTSYSCALLAPI NTSTATUS NTAPI ZwAdjustGroupsToken( - __in HANDLE TokenHandle, - __in BOOLEAN ResetToDefault, - __in_opt PTOKEN_GROUPS NewState, - __in_opt ULONG BufferLength, - __out_bcount_part_opt(BufferLength, *ReturnLength) PTOKEN_GROUPS PreviousState, - __out PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_ BOOLEAN ResetToDefault, + _In_opt_ PTOKEN_GROUPS NewState, + _In_opt_ ULONG BufferLength, + _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_GROUPS PreviousState, + _Out_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwAdjustPrivilegesToken( - __in HANDLE TokenHandle, - __in BOOLEAN DisableAllPrivileges, - __in_opt PTOKEN_PRIVILEGES NewState, - __in ULONG BufferLength, - __out_bcount_part_opt(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, - __out __drv_when(PreviousState == NULL, __out_opt) PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_ BOOLEAN DisableAllPrivileges, + _In_opt_ PTOKEN_PRIVILEGES NewState, + _In_ ULONG BufferLength, + _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, + _Out_ _When_(PreviousState == NULL, _Out_opt_) PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlertResumeThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlertThread( - __in HANDLE ThreadHandle + _In_ HANDLE ThreadHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwAllocateLocallyUniqueId( - __out PLUID Luid + _Out_ PLUID Luid ); NTSYSCALLAPI NTSTATUS NTAPI ZwAllocateReserveObject( - __out PHANDLE MemoryReserveHandle, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in MEMORY_RESERVE_TYPE Type + _Out_ PHANDLE MemoryReserveHandle, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ MEMORY_RESERVE_TYPE Type ); NTSYSCALLAPI NTSTATUS NTAPI ZwAllocateUserPhysicalPages( - __in HANDLE ProcessHandle, - __inout PULONG_PTR NumberOfPages, - __out_ecount(*NumberOfPages) PULONG_PTR UserPfnArray + _In_ HANDLE ProcessHandle, + _Inout_ PULONG_PTR NumberOfPages, + _Out_writes_(*NumberOfPages) PULONG_PTR UserPfnArray ); NTSYSCALLAPI NTSTATUS NTAPI ZwAllocateUuids( - __out PULARGE_INTEGER Time, - __out PULONG Range, - __out PULONG Sequence, - __out PCHAR Seed + _Out_ PULARGE_INTEGER Time, + _Out_ PULONG Range, + _Out_ PULONG Sequence, + _Out_ PCHAR Seed ); NTSYSCALLAPI NTSTATUS NTAPI ZwAllocateVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __in ULONG_PTR ZeroBits, - __inout PSIZE_T RegionSize, - __in ULONG AllocationType, - __in ULONG Protect + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _In_ ULONG_PTR ZeroBits, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG AllocationType, + _In_ ULONG Protect ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcAcceptConnectPort( - __out PHANDLE PortHandle, - __in HANDLE ConnectionPortHandle, - __in ULONG Flags, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in PALPC_PORT_ATTRIBUTES PortAttributes, - __in_opt PVOID PortContext, - __in PPORT_MESSAGE ConnectionRequest, - __inout_opt PALPC_MESSAGE_ATTRIBUTES ConnectionMessageAttributes, - __in BOOLEAN AcceptConnection + _Out_ PHANDLE PortHandle, + _In_ HANDLE ConnectionPortHandle, + _In_ ULONG Flags, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PALPC_PORT_ATTRIBUTES PortAttributes, + _In_opt_ PVOID PortContext, + _In_ PPORT_MESSAGE ConnectionRequest, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES ConnectionMessageAttributes, + _In_ BOOLEAN AcceptConnection ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcCancelMessage( - __in HANDLE PortHandle, - __in ULONG Flags, - __in PALPC_CONTEXT_ATTR MessageContext + _In_ HANDLE PortHandle, + _In_ ULONG Flags, + _In_ PALPC_CONTEXT_ATTR MessageContext ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcConnectPort( - __out PHANDLE PortHandle, - __in PUNICODE_STRING PortName, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PALPC_PORT_ATTRIBUTES PortAttributes, - __in ULONG Flags, - __in_opt PSID RequiredServerSid, - __inout PPORT_MESSAGE ConnectionMessage, - __inout_opt PULONG BufferLength, - __inout_opt PALPC_MESSAGE_ATTRIBUTES OutMessageAttributes, - __inout_opt PALPC_MESSAGE_ATTRIBUTES InMessageAttributes, - __in_opt PLARGE_INTEGER Timeout + _Out_ PHANDLE PortHandle, + _In_ PUNICODE_STRING PortName, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PALPC_PORT_ATTRIBUTES PortAttributes, + _In_ ULONG Flags, + _In_opt_ PSID RequiredServerSid, + _Inout_ PPORT_MESSAGE ConnectionMessage, + _Inout_opt_ PULONG BufferLength, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES OutMessageAttributes, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES InMessageAttributes, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcCreatePort( - __out PHANDLE PortHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PALPC_PORT_ATTRIBUTES PortAttributes + _Out_ PHANDLE PortHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PALPC_PORT_ATTRIBUTES PortAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcCreatePortSection( - __in HANDLE PortHandle, - __in ULONG Flags, - __in_opt HANDLE SectionHandle, - __in SIZE_T SectionSize, - __out PALPC_HANDLE AlpcSectionHandle, - __out PSIZE_T ActualSectionSize + _In_ HANDLE PortHandle, + _In_ ULONG Flags, + _In_opt_ HANDLE SectionHandle, + _In_ SIZE_T SectionSize, + _Out_ PALPC_HANDLE AlpcSectionHandle, + _Out_ PSIZE_T ActualSectionSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcCreateResourceReserve( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in SIZE_T MessageSize, - __out PALPC_HANDLE ResourceId + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ SIZE_T MessageSize, + _Out_ PALPC_HANDLE ResourceId ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcCreateSectionView( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __inout PALPC_DATA_VIEW_ATTR ViewAttributes + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _Inout_ PALPC_DATA_VIEW_ATTR ViewAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcCreateSecurityContext( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __inout PALPC_SECURITY_ATTR SecurityAttribute + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _Inout_ PALPC_SECURITY_ATTR SecurityAttribute ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcDeletePortSection( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE SectionHandle + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE SectionHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcDeleteResourceReserve( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE ResourceId + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ResourceId ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcDeleteSectionView( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in PVOID ViewBase + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ PVOID ViewBase ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcDeleteSecurityContext( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE ContextHandle + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ContextHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcDisconnectPort( - __in HANDLE PortHandle, - __in ULONG Flags + _In_ HANDLE PortHandle, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcImpersonateClientOfPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __reserved PVOID Reserved + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _Reserved_ PVOID Reserved ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcOpenSenderProcess( - __out PHANDLE ProcessHandle, - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __reserved ULONG Flags, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE ProcessHandle, + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _Reserved_ ULONG Flags, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcOpenSenderThread( - __out PHANDLE ThreadHandle, - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __reserved ULONG Flags, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE ThreadHandle, + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _Reserved_ ULONG Flags, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcQueryInformation( - __in HANDLE PortHandle, - __in ALPC_PORT_INFORMATION_CLASS PortInformationClass, - __out_bcount(Length) PVOID PortInformation, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE PortHandle, + _In_ ALPC_PORT_INFORMATION_CLASS PortInformationClass, + _Out_writes_bytes_(Length) PVOID PortInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcQueryInformationMessage( - __in HANDLE PortHandle, - __in PPORT_MESSAGE PortMessage, - __in ALPC_MESSAGE_INFORMATION_CLASS MessageInformationClass, - __out_bcount(Length) PVOID MessageInformation, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE PortMessage, + _In_ ALPC_MESSAGE_INFORMATION_CLASS MessageInformationClass, + _Out_writes_bytes_(Length) PVOID MessageInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcRevokeSecurityContext( - __in HANDLE PortHandle, - __reserved ULONG Flags, - __in ALPC_HANDLE ContextHandle + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ContextHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcSendWaitReceivePort( - __in HANDLE PortHandle, - __in ULONG Flags, - __in_opt PPORT_MESSAGE SendMessage, - __in_opt PALPC_MESSAGE_ATTRIBUTES SendMessageAttributes, - __inout_opt PPORT_MESSAGE ReceiveMessage, - __inout_opt PULONG BufferLength, - __inout_opt PALPC_MESSAGE_ATTRIBUTES ReceiveMessageAttributes, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE PortHandle, + _In_ ULONG Flags, + _In_opt_ PPORT_MESSAGE SendMessage, + _In_opt_ PALPC_MESSAGE_ATTRIBUTES SendMessageAttributes, + _Inout_opt_ PPORT_MESSAGE ReceiveMessage, + _Inout_opt_ PULONG BufferLength, + _Inout_opt_ PALPC_MESSAGE_ATTRIBUTES ReceiveMessageAttributes, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwAlpcSetInformation( - __in HANDLE PortHandle, - __in ALPC_PORT_INFORMATION_CLASS PortInformationClass, - __in_bcount(Length) PVOID PortInformation, - __in ULONG Length + _In_ HANDLE PortHandle, + _In_ ALPC_PORT_INFORMATION_CLASS PortInformationClass, + _In_reads_bytes_(Length) PVOID PortInformation, + _In_ ULONG Length ); NTSYSCALLAPI NTSTATUS NTAPI ZwAreMappedFilesTheSame( - __in PVOID File1MappedAsAnImage, - __in PVOID File2MappedAsFile + _In_ PVOID File1MappedAsAnImage, + _In_ PVOID File2MappedAsFile ); NTSYSCALLAPI NTSTATUS NTAPI ZwAssignProcessToJobObject( - __in HANDLE JobHandle, - __in HANDLE ProcessHandle + _In_ HANDLE JobHandle, + _In_ HANDLE ProcessHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwCallbackReturn( - __in_bcount_opt(OutputLength) PVOID OutputBuffer, - __in ULONG OutputLength, - __in NTSTATUS Status + _In_reads_bytes_opt_(OutputLength) PVOID OutputBuffer, + _In_ ULONG OutputLength, + _In_ NTSTATUS Status ); NTSYSCALLAPI NTSTATUS NTAPI ZwCancelIoFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); NTSYSCALLAPI NTSTATUS NTAPI ZwCancelIoFileEx( - __in HANDLE FileHandle, - __in_opt PIO_STATUS_BLOCK IoRequestToCancel, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _In_opt_ PIO_STATUS_BLOCK IoRequestToCancel, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); NTSYSCALLAPI NTSTATUS NTAPI ZwCancelSynchronousIoFile( - __in HANDLE ThreadHandle, - __in_opt PIO_STATUS_BLOCK IoRequestToCancel, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE ThreadHandle, + _In_opt_ PIO_STATUS_BLOCK IoRequestToCancel, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); NTSYSCALLAPI NTSTATUS NTAPI ZwCancelTimer( - __in HANDLE TimerHandle, - __out_opt PBOOLEAN CurrentState + _In_ HANDLE TimerHandle, + _Out_opt_ PBOOLEAN CurrentState ); NTSYSCALLAPI NTSTATUS NTAPI ZwClearEvent( - __in HANDLE EventHandle + _In_ HANDLE EventHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwClose( - __in HANDLE Handle + _In_ HANDLE Handle ); NTSYSCALLAPI NTSTATUS NTAPI ZwCloseObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in BOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ BOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI ZwCommitComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwCommitEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwCommitTransaction( - __in HANDLE TransactionHandle, - __in BOOLEAN Wait + _In_ HANDLE TransactionHandle, + _In_ BOOLEAN Wait ); NTSYSCALLAPI NTSTATUS NTAPI ZwCompactKeys( - __in ULONG Count, - __in_ecount(Count) HANDLE KeyArray[] + _In_ ULONG Count, + _In_reads_(Count) HANDLE KeyArray[] ); NTSYSCALLAPI NTSTATUS NTAPI ZwCompareTokens( - __in HANDLE FirstTokenHandle, - __in HANDLE SecondTokenHandle, - __out PBOOLEAN Equal + _In_ HANDLE FirstTokenHandle, + _In_ HANDLE SecondTokenHandle, + _Out_ PBOOLEAN Equal ); NTSYSCALLAPI NTSTATUS NTAPI ZwCompleteConnectPort( - __in HANDLE PortHandle + _In_ HANDLE PortHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwCompressKey( - __in HANDLE Key + _In_ HANDLE Key ); NTSYSCALLAPI NTSTATUS NTAPI ZwConnectPort( - __out PHANDLE PortHandle, - __in PUNICODE_STRING PortName, - __in PSECURITY_QUALITY_OF_SERVICE SecurityQos, - __inout_opt PPORT_VIEW ClientView, - __inout_opt PREMOTE_PORT_VIEW ServerView, - __out_opt PULONG MaxMessageLength, - __inout_opt PVOID ConnectionInformation, - __inout_opt PULONG ConnectionInformationLength + _Out_ PHANDLE PortHandle, + _In_ PUNICODE_STRING PortName, + _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos, + _Inout_opt_ PPORT_VIEW ClientView, + _Inout_opt_ PREMOTE_PORT_VIEW ServerView, + _Out_opt_ PULONG MaxMessageLength, + _Inout_opt_ PVOID ConnectionInformation, + _Inout_opt_ PULONG ConnectionInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwContinue( - __in PCONTEXT ContextRecord, - __in BOOLEAN TestAlert + _In_ PCONTEXT ContextRecord, + _In_ BOOLEAN TestAlert ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateDebugObject( - __out PHANDLE DebugObjectHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG Flags + _Out_ PHANDLE DebugObjectHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateDirectoryObject( - __out PHANDLE DirectoryHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE DirectoryHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateEnlistment( - __out PHANDLE EnlistmentHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ResourceManagerHandle, - __in HANDLE TransactionHandle, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt ULONG CreateOptions, - __in NOTIFICATION_MASK NotificationMask, - __in_opt PVOID EnlistmentKey + _Out_ PHANDLE EnlistmentHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ResourceManagerHandle, + _In_ HANDLE TransactionHandle, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ ULONG CreateOptions, + _In_ NOTIFICATION_MASK NotificationMask, + _In_opt_ PVOID EnlistmentKey ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateEvent( - __out PHANDLE EventHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in EVENT_TYPE EventType, - __in BOOLEAN InitialState + _Out_ PHANDLE EventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ EVENT_TYPE EventType, + _In_ BOOLEAN InitialState ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateEventPair( - __out PHANDLE EventPairHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EventPairHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateFile( - __out PHANDLE FileHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_opt PLARGE_INTEGER AllocationSize, - __in ULONG FileAttributes, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions, - __in_bcount_opt(EaLength) PVOID EaBuffer, - __in ULONG EaLength + _Out_ PHANDLE FileHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_opt_ PLARGE_INTEGER AllocationSize, + _In_ ULONG FileAttributes, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions, + _In_reads_bytes_opt_(EaLength) PVOID EaBuffer, + _In_ ULONG EaLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateIoCompletion( - __out PHANDLE IoCompletionHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt ULONG Count + _Out_ PHANDLE IoCompletionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ ULONG Count ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateJobObject( - __out PHANDLE JobHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE JobHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateJobSet( - __in ULONG NumJob, - __in_ecount(NumJob) PJOB_SET_ARRAY UserJobSet, - __in ULONG Flags + _In_ ULONG NumJob, + _In_reads_(NumJob) PJOB_SET_ARRAY UserJobSet, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __reserved ULONG TitleIndex, - __in_opt PUNICODE_STRING Class, - __in ULONG CreateOptions, - __out_opt PULONG Disposition + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Reserved_ ULONG TitleIndex, + _In_opt_ PUNICODE_STRING Class, + _In_ ULONG CreateOptions, + _Out_opt_ PULONG Disposition ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateKeyTransacted( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __reserved ULONG TitleIndex, - __in_opt PUNICODE_STRING Class, - __in ULONG CreateOptions, - __in HANDLE TransactionHandle, - __out_opt PULONG Disposition + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Reserved_ ULONG TitleIndex, + _In_opt_ PUNICODE_STRING Class, + _In_ ULONG CreateOptions, + _In_ HANDLE TransactionHandle, + _Out_opt_ PULONG Disposition ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateKeyedEvent( - __out PHANDLE KeyedEventHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG Flags + _Out_ PHANDLE KeyedEventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateMailslotFile( - __out PHANDLE FileHandle, - __in ULONG DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG CreateOptions, - __in ULONG MailslotQuota, - __in ULONG MaximumMessageSize, - __in PLARGE_INTEGER ReadTimeout + _Out_ PHANDLE FileHandle, + _In_ ULONG DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG CreateOptions, + _In_ ULONG MailslotQuota, + _In_ ULONG MaximumMessageSize, + _In_ PLARGE_INTEGER ReadTimeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateMutant( - __out PHANDLE MutantHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in BOOLEAN InitialOwner + _Out_ PHANDLE MutantHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ BOOLEAN InitialOwner ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateNamedPipeFile( - __out PHANDLE FileHandle, - __in ULONG DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions, - __in ULONG NamedPipeType, - __in ULONG ReadMode, - __in ULONG CompletionMode, - __in ULONG MaximumInstances, - __in ULONG InboundQuota, - __in ULONG OutboundQuota, - __in_opt PLARGE_INTEGER DefaultTimeout + _Out_ PHANDLE FileHandle, + _In_ ULONG DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions, + _In_ ULONG NamedPipeType, + _In_ ULONG ReadMode, + _In_ ULONG CompletionMode, + _In_ ULONG MaximumInstances, + _In_ ULONG InboundQuota, + _In_ ULONG OutboundQuota, + _In_opt_ PLARGE_INTEGER DefaultTimeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreatePagingFile( - __in PUNICODE_STRING PageFileName, - __in PLARGE_INTEGER MinimumSize, - __in PLARGE_INTEGER MaximumSize, - __in ULONG Priority + _In_ PUNICODE_STRING PageFileName, + _In_ PLARGE_INTEGER MinimumSize, + _In_ PLARGE_INTEGER MaximumSize, + _In_ ULONG Priority ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreatePort( - __out PHANDLE PortHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG MaxConnectionInfoLength, - __in ULONG MaxMessageLength, - __in_opt ULONG MaxPoolUsage + _Out_ PHANDLE PortHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG MaxConnectionInfoLength, + _In_ ULONG MaxMessageLength, + _In_opt_ ULONG MaxPoolUsage ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreatePrivateNamespace( - __out PHANDLE NamespaceHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in PVOID BoundaryDescriptor + _Out_ PHANDLE NamespaceHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PVOID BoundaryDescriptor ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ParentProcess, - __in BOOLEAN InheritObjectTable, - __in_opt HANDLE SectionHandle, - __in_opt HANDLE DebugPort, - __in_opt HANDLE ExceptionPort + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ParentProcess, + _In_ BOOLEAN InheritObjectTable, + _In_opt_ HANDLE SectionHandle, + _In_opt_ HANDLE DebugPort, + _In_opt_ HANDLE ExceptionPort ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateProcessEx( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ParentProcess, - __in ULONG Flags, - __in_opt HANDLE SectionHandle, - __in_opt HANDLE DebugPort, - __in_opt HANDLE ExceptionPort, - __in ULONG JobMemberLevel + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ParentProcess, + _In_ ULONG Flags, + _In_opt_ HANDLE SectionHandle, + _In_opt_ HANDLE DebugPort, + _In_opt_ HANDLE ExceptionPort, + _In_ ULONG JobMemberLevel ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateProfile( - __out PHANDLE ProfileHandle, - __in_opt HANDLE Process, - __in PVOID ProfileBase, - __in SIZE_T ProfileSize, - __in ULONG BucketSize, - __in PULONG Buffer, - __in ULONG BufferSize, - __in KPROFILE_SOURCE ProfileSource, - __in KAFFINITY Affinity + _Out_ PHANDLE ProfileHandle, + _In_opt_ HANDLE Process, + _In_ PVOID ProfileBase, + _In_ SIZE_T ProfileSize, + _In_ ULONG BucketSize, + _In_ PULONG Buffer, + _In_ ULONG BufferSize, + _In_ KPROFILE_SOURCE ProfileSource, + _In_ KAFFINITY Affinity ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateProfileEx( - __out PHANDLE ProfileHandle, - __in_opt HANDLE Process, - __in PVOID ProfileBase, - __in SIZE_T ProfileSize, - __in ULONG BucketSize, - __in PULONG Buffer, - __in ULONG BufferSize, - __in KPROFILE_SOURCE ProfileSource, - __in ULONG GroupAffinityCount, - __in_opt PGROUP_AFFINITY GroupAffinity + _Out_ PHANDLE ProfileHandle, + _In_opt_ HANDLE Process, + _In_ PVOID ProfileBase, + _In_ SIZE_T ProfileSize, + _In_ ULONG BucketSize, + _In_ PULONG Buffer, + _In_ ULONG BufferSize, + _In_ KPROFILE_SOURCE ProfileSource, + _In_ ULONG GroupAffinityCount, + _In_opt_ PGROUP_AFFINITY GroupAffinity ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateResourceManager( - __out PHANDLE ResourceManagerHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE TmHandle, - __in LPGUID RmGuid, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt ULONG CreateOptions, - __in_opt PUNICODE_STRING Description + _Out_ PHANDLE ResourceManagerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE TmHandle, + _In_ LPGUID RmGuid, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ ULONG CreateOptions, + _In_opt_ PUNICODE_STRING Description ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateSection( - __out PHANDLE SectionHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PLARGE_INTEGER MaximumSize, - __in ULONG SectionPageProtection, - __in ULONG AllocationAttributes, - __in_opt HANDLE FileHandle + _Out_ PHANDLE SectionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PLARGE_INTEGER MaximumSize, + _In_ ULONG SectionPageProtection, + _In_ ULONG AllocationAttributes, + _In_opt_ HANDLE FileHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateSemaphore( - __out PHANDLE SemaphoreHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in LONG InitialCount, - __in LONG MaximumCount + _Out_ PHANDLE SemaphoreHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ LONG InitialCount, + _In_ LONG MaximumCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateSymbolicLinkObject( - __out PHANDLE LinkHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in PUNICODE_STRING LinkTarget + _Out_ PHANDLE LinkHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PUNICODE_STRING LinkTarget ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ProcessHandle, - __out PCLIENT_ID ClientId, - __in PCONTEXT ThreadContext, - __in PINITIAL_TEB InitialTeb, - __in BOOLEAN CreateSuspended + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ProcessHandle, + _Out_ PCLIENT_ID ClientId, + _In_ PCONTEXT ThreadContext, + _In_ PINITIAL_TEB InitialTeb, + _In_ BOOLEAN CreateSuspended ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateThreadEx( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE ProcessHandle, - __in PVOID StartRoutine, - __in_opt PVOID Argument, - __in ULONG CreateFlags, // THREAD_CREATE_FLAGS_* - __in_opt ULONG_PTR ZeroBits, - __in_opt SIZE_T StackSize, - __in_opt SIZE_T MaximumStackSize, - __in_opt PPS_ATTRIBUTE_LIST AttributeList + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE ProcessHandle, + _In_ PVOID StartRoutine, + _In_opt_ PVOID Argument, + _In_ ULONG CreateFlags, // THREAD_CREATE_FLAGS_* + _In_opt_ ULONG_PTR ZeroBits, + _In_opt_ SIZE_T StackSize, + _In_opt_ SIZE_T MaximumStackSize, + _In_opt_ PPS_ATTRIBUTE_LIST AttributeList ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateTimer( - __out PHANDLE TimerHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in TIMER_TYPE TimerType + _Out_ PHANDLE TimerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ TIMER_TYPE TimerType ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateToken( - __out PHANDLE TokenHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in TOKEN_TYPE TokenType, - __in PLUID AuthenticationId, - __in PLARGE_INTEGER ExpirationTime, - __in PTOKEN_USER User, - __in PTOKEN_GROUPS Groups, - __in PTOKEN_PRIVILEGES Privileges, - __in_opt PTOKEN_OWNER Owner, - __in PTOKEN_PRIMARY_GROUP PrimaryGroup, - __in_opt PTOKEN_DEFAULT_DACL DefaultDacl, - __in PTOKEN_SOURCE TokenSource + _Out_ PHANDLE TokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ TOKEN_TYPE TokenType, + _In_ PLUID AuthenticationId, + _In_ PLARGE_INTEGER ExpirationTime, + _In_ PTOKEN_USER User, + _In_ PTOKEN_GROUPS Groups, + _In_ PTOKEN_PRIVILEGES Privileges, + _In_opt_ PTOKEN_OWNER Owner, + _In_ PTOKEN_PRIMARY_GROUP PrimaryGroup, + _In_opt_ PTOKEN_DEFAULT_DACL DefaultDacl, + _In_ PTOKEN_SOURCE TokenSource ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateTransaction( - __out PHANDLE TransactionHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt LPGUID Uow, - __in_opt HANDLE TmHandle, - __in_opt ULONG CreateOptions, - __in_opt ULONG IsolationLevel, - __in_opt ULONG IsolationFlags, - __in_opt PLARGE_INTEGER Timeout, - __in_opt PUNICODE_STRING Description + _Out_ PHANDLE TransactionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ LPGUID Uow, + _In_opt_ HANDLE TmHandle, + _In_opt_ ULONG CreateOptions, + _In_opt_ ULONG IsolationLevel, + _In_opt_ ULONG IsolationFlags, + _In_opt_ PLARGE_INTEGER Timeout, + _In_opt_ PUNICODE_STRING Description ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateTransactionManager( - __out PHANDLE TmHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PUNICODE_STRING LogFileName, - __in_opt ULONG CreateOptions, - __in_opt ULONG CommitStrength + _Out_ PHANDLE TmHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PUNICODE_STRING LogFileName, + _In_opt_ ULONG CreateOptions, + _In_opt_ ULONG CommitStrength ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateUserProcess( - __out PHANDLE ProcessHandle, - __out PHANDLE ThreadHandle, - __in ACCESS_MASK ProcessDesiredAccess, - __in ACCESS_MASK ThreadDesiredAccess, - __in_opt POBJECT_ATTRIBUTES ProcessObjectAttributes, - __in_opt POBJECT_ATTRIBUTES ThreadObjectAttributes, - __in ULONG ProcessFlags, // PROCESS_CREATE_FLAGS_* - __in ULONG ThreadFlags, // THREAD_CREATE_FLAGS_* - __in_opt PVOID ProcessParameters, - __inout PPS_CREATE_INFO CreateInfo, - __in_opt PPS_ATTRIBUTE_LIST AttributeList + _Out_ PHANDLE ProcessHandle, + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK ProcessDesiredAccess, + _In_ ACCESS_MASK ThreadDesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ProcessObjectAttributes, + _In_opt_ POBJECT_ATTRIBUTES ThreadObjectAttributes, + _In_ ULONG ProcessFlags, // PROCESS_CREATE_FLAGS_* + _In_ ULONG ThreadFlags, // THREAD_CREATE_FLAGS_* + _In_opt_ PVOID ProcessParameters, + _Inout_ PPS_CREATE_INFO CreateInfo, + _In_opt_ PPS_ATTRIBUTE_LIST AttributeList ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateWaitablePort( - __out PHANDLE PortHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG MaxConnectionInfoLength, - __in ULONG MaxMessageLength, - __in_opt ULONG MaxPoolUsage + _Out_ PHANDLE PortHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG MaxConnectionInfoLength, + _In_ ULONG MaxMessageLength, + _In_opt_ ULONG MaxPoolUsage ); NTSYSCALLAPI NTSTATUS NTAPI ZwCreateWorkerFactory( - __out PHANDLE WorkerFactoryHandleReturn, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE CompletionPortHandle, - __in HANDLE WorkerProcessHandle, - __in PVOID StartRoutine, - __in_opt PVOID StartParameter, - __in_opt ULONG MaxThreadCount, - __in_opt SIZE_T StackReserve, - __in_opt SIZE_T StackCommit + _Out_ PHANDLE WorkerFactoryHandleReturn, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE CompletionPortHandle, + _In_ HANDLE WorkerProcessHandle, + _In_ PVOID StartRoutine, + _In_opt_ PVOID StartParameter, + _In_opt_ ULONG MaxThreadCount, + _In_opt_ SIZE_T StackReserve, + _In_opt_ SIZE_T StackCommit ); NTSYSCALLAPI NTSTATUS NTAPI ZwDebugActiveProcess( - __in HANDLE ProcessHandle, - __in HANDLE DebugObjectHandle + _In_ HANDLE ProcessHandle, + _In_ HANDLE DebugObjectHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwDebugContinue( - __in HANDLE DebugObjectHandle, - __in PCLIENT_ID ClientId, - __in NTSTATUS ContinueStatus + _In_ HANDLE DebugObjectHandle, + _In_ PCLIENT_ID ClientId, + _In_ NTSTATUS ContinueStatus ); NTSYSCALLAPI NTSTATUS NTAPI ZwDelayExecution( - __in BOOLEAN Alertable, - __in PLARGE_INTEGER DelayInterval + _In_ BOOLEAN Alertable, + _In_ PLARGE_INTEGER DelayInterval ); NTSYSCALLAPI NTSTATUS NTAPI ZwDeleteAtom( - __in RTL_ATOM Atom + _In_ RTL_ATOM Atom ); NTSYSCALLAPI NTSTATUS NTAPI ZwDeleteFile( - __in POBJECT_ATTRIBUTES ObjectAttributes + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwDeleteKey( - __in HANDLE KeyHandle + _In_ HANDLE KeyHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwDeleteObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in BOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ BOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI ZwDeletePrivateNamespace( - __in HANDLE NamespaceHandle + _In_ HANDLE NamespaceHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwDeleteValueKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING ValueName + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING ValueName ); NTSYSCALLAPI NTSTATUS NTAPI ZwDeviceIoControlFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG IoControlCode, - __in_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG IoControlCode, + _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ); NTSYSCALLAPI @@ -1179,39 +1179,39 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwDisplayString( - __in PUNICODE_STRING String + _In_ PUNICODE_STRING String ); NTSYSCALLAPI NTSTATUS NTAPI ZwDrawText( - __in PUNICODE_STRING Text + _In_ PUNICODE_STRING Text ); NTSYSCALLAPI NTSTATUS NTAPI ZwDuplicateObject( - __in HANDLE SourceProcessHandle, - __in HANDLE SourceHandle, - __in_opt HANDLE TargetProcessHandle, - __out_opt PHANDLE TargetHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Options + _In_ HANDLE SourceProcessHandle, + _In_ HANDLE SourceHandle, + _In_opt_ HANDLE TargetProcessHandle, + _Out_opt_ PHANDLE TargetHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Options ); NTSYSCALLAPI NTSTATUS NTAPI ZwDuplicateToken( - __in HANDLE ExistingTokenHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in BOOLEAN EffectiveOnly, - __in TOKEN_TYPE TokenType, - __out PHANDLE NewTokenHandle + _In_ HANDLE ExistingTokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ BOOLEAN EffectiveOnly, + _In_ TOKEN_TYPE TokenType, + _Out_ PHANDLE NewTokenHandle ); NTSYSCALLAPI @@ -1225,105 +1225,105 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwEnumerateKey( - __in HANDLE KeyHandle, - __in ULONG Index, - __in KEY_INFORMATION_CLASS KeyInformationClass, - __out_bcount_opt(Length) PVOID KeyInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ ULONG Index, + _In_ KEY_INFORMATION_CLASS KeyInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwEnumerateTransactionObject( - __in_opt HANDLE RootObjectHandle, - __in KTMOBJECT_TYPE QueryType, - __inout_bcount(ObjectCursorLength) PKTMOBJECT_CURSOR ObjectCursor, - __in ULONG ObjectCursorLength, - __out PULONG ReturnLength + _In_opt_ HANDLE RootObjectHandle, + _In_ KTMOBJECT_TYPE QueryType, + _Inout_updates_bytes_(ObjectCursorLength) PKTMOBJECT_CURSOR ObjectCursor, + _In_ ULONG ObjectCursorLength, + _Out_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwEnumerateValueKey( - __in HANDLE KeyHandle, - __in ULONG Index, - __in KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, - __out_bcount_opt(Length) PVOID KeyValueInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ ULONG Index, + _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyValueInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwExtendSection( - __in HANDLE SectionHandle, - __inout PLARGE_INTEGER NewSectionSize + _In_ HANDLE SectionHandle, + _Inout_ PLARGE_INTEGER NewSectionSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwFilterToken( - __in HANDLE ExistingTokenHandle, - __in ULONG Flags, - __in_opt PTOKEN_GROUPS SidsToDisable, - __in_opt PTOKEN_PRIVILEGES PrivilegesToDelete, - __in_opt PTOKEN_GROUPS RestrictedSids, - __out PHANDLE NewTokenHandle + _In_ HANDLE ExistingTokenHandle, + _In_ ULONG Flags, + _In_opt_ PTOKEN_GROUPS SidsToDisable, + _In_opt_ PTOKEN_PRIVILEGES PrivilegesToDelete, + _In_opt_ PTOKEN_GROUPS RestrictedSids, + _Out_ PHANDLE NewTokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwFindAtom( - __in_bcount_opt(Length) PWSTR AtomName, - __in ULONG Length, - __out_opt PRTL_ATOM Atom + _In_reads_bytes_opt_(Length) PWSTR AtomName, + _In_ ULONG Length, + _Out_opt_ PRTL_ATOM Atom ); NTSYSCALLAPI NTSTATUS NTAPI ZwFlushBuffersFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); NTSYSCALLAPI NTSTATUS NTAPI ZwFlushBuffersFileEx( - __in HANDLE FileHandle, - __in ULONG Flags, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _In_ ULONG Flags, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); NTSYSCALLAPI NTSTATUS NTAPI ZwFlushInstallUILanguage( - __in LANGID InstallUILanguage, - __in ULONG SetComittedFlag + _In_ LANGID InstallUILanguage, + _In_ ULONG SetComittedFlag ); NTSYSCALLAPI NTSTATUS NTAPI ZwFlushInstructionCache( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __in SIZE_T Length + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _In_ SIZE_T Length ); NTSYSCALLAPI NTSTATUS NTAPI ZwFlushKey( - __in HANDLE KeyHandle + _In_ HANDLE KeyHandle ); NTSYSCALLAPI @@ -1344,58 +1344,58 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwFreeUserPhysicalPages( - __in HANDLE ProcessHandle, - __inout PULONG_PTR NumberOfPages, - __in_ecount(*NumberOfPages) PULONG_PTR UserPfnArray + _In_ HANDLE ProcessHandle, + _Inout_ PULONG_PTR NumberOfPages, + _In_reads_(*NumberOfPages) PULONG_PTR UserPfnArray ); NTSYSCALLAPI NTSTATUS NTAPI ZwFreeVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG FreeType + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG FreeType ); NTSYSCALLAPI NTSTATUS NTAPI ZwFreezeRegistry( - __in ULONG TimeOutInSeconds + _In_ ULONG TimeOutInSeconds ); NTSYSCALLAPI NTSTATUS NTAPI ZwFreezeTransactions( - __in PLARGE_INTEGER FreezeTimeout, - __in PLARGE_INTEGER ThawTimeout + _In_ PLARGE_INTEGER FreezeTimeout, + _In_ PLARGE_INTEGER ThawTimeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwFsControlFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG FsControlCode, - __in_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG FsControlCode, + _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetContextThread( - __in HANDLE ThreadHandle, - __inout PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _Inout_ PCONTEXT ThreadContext ); NTSYSCALLAPI @@ -1409,145 +1409,145 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwGetDevicePowerState( - __in HANDLE Device, - __out PDEVICE_POWER_STATE State + _In_ HANDLE Device, + _Out_ PDEVICE_POWER_STATE State ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetMUIRegistryInfo( - __in ULONG Flags, - __inout PULONG DataSize, - __out PVOID Data + _In_ ULONG Flags, + _Inout_ PULONG DataSize, + _Out_ PVOID Data ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetNextProcess( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Flags, - __out PHANDLE NewProcessHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Flags, + _Out_ PHANDLE NewProcessHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetNextThread( - __in HANDLE ProcessHandle, - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Flags, - __out PHANDLE NewThreadHandle + _In_ HANDLE ProcessHandle, + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Flags, + _Out_ PHANDLE NewThreadHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetNlsSectionPtr( - __in ULONG SectionType, - __in ULONG SectionData, - __in PVOID ContextData, - __out PVOID *SectionPointer, - __out PULONG SectionSize + _In_ ULONG SectionType, + _In_ ULONG SectionData, + _In_ PVOID ContextData, + _Out_ PVOID *SectionPointer, + _Out_ PULONG SectionSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetNotificationResourceManager( - __in HANDLE ResourceManagerHandle, - __out PTRANSACTION_NOTIFICATION TransactionNotification, - __in ULONG NotificationLength, - __in_opt PLARGE_INTEGER Timeout, - __out_opt PULONG ReturnLength, - __in ULONG Asynchronous, - __in_opt ULONG_PTR AsynchronousContext + _In_ HANDLE ResourceManagerHandle, + _Out_ PTRANSACTION_NOTIFICATION TransactionNotification, + _In_ ULONG NotificationLength, + _In_opt_ PLARGE_INTEGER Timeout, + _Out_opt_ PULONG ReturnLength, + _In_ ULONG Asynchronous, + _In_opt_ ULONG_PTR AsynchronousContext ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetPlugPlayEvent( - __in HANDLE EventHandle, - __in_opt PVOID Context, - __out_bcount(EventBufferSize) PPLUGPLAY_EVENT_BLOCK EventBlock, - __in ULONG EventBufferSize + _In_ HANDLE EventHandle, + _In_opt_ PVOID Context, + _Out_writes_bytes_(EventBufferSize) PPLUGPLAY_EVENT_BLOCK EventBlock, + _In_ ULONG EventBufferSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwGetWriteWatch( - __in HANDLE ProcessHandle, - __in ULONG Flags, - __in PVOID BaseAddress, - __in SIZE_T RegionSize, - __out_ecount(*EntriesInUserAddressArray) PVOID *UserAddressArray, - __inout PULONG_PTR EntriesInUserAddressArray, - __out PULONG Granularity + _In_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _In_ PVOID BaseAddress, + _In_ SIZE_T RegionSize, + _Out_writes_(*EntriesInUserAddressArray) PVOID *UserAddressArray, + _Inout_ PULONG_PTR EntriesInUserAddressArray, + _Out_ PULONG Granularity ); NTSYSCALLAPI NTSTATUS NTAPI ZwImpersonateAnonymousToken( - __in HANDLE ThreadHandle + _In_ HANDLE ThreadHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwImpersonateClientOfPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE Message + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE Message ); NTSYSCALLAPI NTSTATUS NTAPI ZwImpersonateThread( - __in HANDLE ServerThreadHandle, - __in HANDLE ClientThreadHandle, - __in PSECURITY_QUALITY_OF_SERVICE SecurityQos + _In_ HANDLE ServerThreadHandle, + _In_ HANDLE ClientThreadHandle, + _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos ); NTSYSCALLAPI NTSTATUS NTAPI ZwInitializeNlsFiles( - __out PVOID *BaseAddress, - __out PLCID DefaultLocaleId, - __out PLARGE_INTEGER DefaultCasingTableSize + _Out_ PVOID *BaseAddress, + _Out_ PLCID DefaultLocaleId, + _Out_ PLARGE_INTEGER DefaultCasingTableSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwInitializeRegistry( - __in USHORT BootCondition + _In_ USHORT BootCondition ); NTSYSCALLAPI NTSTATUS NTAPI ZwInitiatePowerAction( - __in POWER_ACTION SystemAction, - __in SYSTEM_POWER_STATE LightestSystemState, - __in ULONG Flags, // POWER_ACTION_* flags - __in BOOLEAN Asynchronous + _In_ POWER_ACTION SystemAction, + _In_ SYSTEM_POWER_STATE LightestSystemState, + _In_ ULONG Flags, // POWER_ACTION_* flags + _In_ BOOLEAN Asynchronous ); NTSYSCALLAPI NTSTATUS NTAPI ZwIsProcessInJob( - __in HANDLE ProcessHandle, - __in_opt HANDLE JobHandle + _In_ HANDLE ProcessHandle, + _In_opt_ HANDLE JobHandle ); NTSYSCALLAPI @@ -1568,924 +1568,924 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwListenPort( - __in HANDLE PortHandle, - __out PPORT_MESSAGE ConnectionRequest + _In_ HANDLE PortHandle, + _Out_ PPORT_MESSAGE ConnectionRequest ); NTSYSCALLAPI NTSTATUS NTAPI ZwLoadDriver( - __in PUNICODE_STRING DriverServiceName + _In_ PUNICODE_STRING DriverServiceName ); NTSYSCALLAPI NTSTATUS NTAPI ZwLoadKey( - __in POBJECT_ATTRIBUTES TargetKey, - __in POBJECT_ATTRIBUTES SourceFile + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ POBJECT_ATTRIBUTES SourceFile ); NTSYSCALLAPI NTSTATUS NTAPI ZwLoadKey2( - __in POBJECT_ATTRIBUTES TargetKey, - __in POBJECT_ATTRIBUTES SourceFile, - __in ULONG Flags + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ POBJECT_ATTRIBUTES SourceFile, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwLoadKeyEx( - __in POBJECT_ATTRIBUTES TargetKey, - __in POBJECT_ATTRIBUTES SourceFile, - __in ULONG Flags, - __in_opt HANDLE TrustClassKey + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ POBJECT_ATTRIBUTES SourceFile, + _In_ ULONG Flags, + _In_opt_ HANDLE TrustClassKey ); NTSYSCALLAPI NTSTATUS NTAPI ZwLockFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PLARGE_INTEGER ByteOffset, - __in PLARGE_INTEGER Length, - __in ULONG Key, - __in BOOLEAN FailImmediately, - __in BOOLEAN ExclusiveLock + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PLARGE_INTEGER ByteOffset, + _In_ PLARGE_INTEGER Length, + _In_ ULONG Key, + _In_ BOOLEAN FailImmediately, + _In_ BOOLEAN ExclusiveLock ); NTSYSCALLAPI NTSTATUS NTAPI ZwLockProductActivationKeys( - __inout_opt ULONG *pPrivateVer, - __out_opt ULONG *pSafeMode + _Inout_opt_ ULONG *pPrivateVer, + _Out_opt_ ULONG *pSafeMode ); NTSYSCALLAPI NTSTATUS NTAPI ZwLockRegistryKey( - __in HANDLE KeyHandle + _In_ HANDLE KeyHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwLockVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG MapType + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG MapType ); NTSYSCALLAPI NTSTATUS NTAPI ZwMakeTemporaryObject( - __in HANDLE Handle + _In_ HANDLE Handle ); NTSYSCALLAPI NTSTATUS NTAPI ZwMapCMFModule( - __in ULONG What, - __in ULONG Index, - __out_opt PULONG CacheIndexOut, - __out_opt PULONG CacheFlagsOut, - __out_opt PULONG ViewSizeOut, - __out_opt PVOID *BaseAddress + _In_ ULONG What, + _In_ ULONG Index, + _Out_opt_ PULONG CacheIndexOut, + _Out_opt_ PULONG CacheFlagsOut, + _Out_opt_ PULONG ViewSizeOut, + _Out_opt_ PVOID *BaseAddress ); NTSYSCALLAPI NTSTATUS NTAPI ZwMapUserPhysicalPages( - __in PVOID VirtualAddress, - __in ULONG_PTR NumberOfPages, - __in_ecount_opt(NumberOfPages) PULONG_PTR UserPfnArray + _In_ PVOID VirtualAddress, + _In_ ULONG_PTR NumberOfPages, + _In_reads_opt_(NumberOfPages) PULONG_PTR UserPfnArray ); NTSYSCALLAPI NTSTATUS NTAPI ZwMapUserPhysicalPagesScatter( - __in_ecount(NumberOfPages) PVOID *VirtualAddresses, - __in ULONG_PTR NumberOfPages, - __in_ecount_opt(NumberOfPages) PULONG_PTR UserPfnArray + _In_reads_(NumberOfPages) PVOID *VirtualAddresses, + _In_ ULONG_PTR NumberOfPages, + _In_reads_opt_(NumberOfPages) PULONG_PTR UserPfnArray ); NTSYSCALLAPI NTSTATUS NTAPI ZwMapViewOfSection( - __in HANDLE SectionHandle, - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __in ULONG_PTR ZeroBits, - __in SIZE_T CommitSize, - __inout_opt PLARGE_INTEGER SectionOffset, - __inout PSIZE_T ViewSize, - __in SECTION_INHERIT InheritDisposition, - __in ULONG AllocationType, - __in ULONG Win32Protect + _In_ HANDLE SectionHandle, + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _In_ ULONG_PTR ZeroBits, + _In_ SIZE_T CommitSize, + _Inout_opt_ PLARGE_INTEGER SectionOffset, + _Inout_ PSIZE_T ViewSize, + _In_ SECTION_INHERIT InheritDisposition, + _In_ ULONG AllocationType, + _In_ ULONG Win32Protect ); NTSYSCALLAPI NTSTATUS NTAPI ZwNotifyChangeDirectoryFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in ULONG CompletionFilter, - __in BOOLEAN WatchTree + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_ ULONG CompletionFilter, + _In_ BOOLEAN WatchTree ); NTSYSCALLAPI NTSTATUS NTAPI ZwNotifyChangeKey( - __in HANDLE KeyHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG CompletionFilter, - __in BOOLEAN WatchTree, - __out_bcount_opt(BufferSize) PVOID Buffer, - __in ULONG BufferSize, - __in BOOLEAN Asynchronous + _In_ HANDLE KeyHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG CompletionFilter, + _In_ BOOLEAN WatchTree, + _Out_writes_bytes_opt_(BufferSize) PVOID Buffer, + _In_ ULONG BufferSize, + _In_ BOOLEAN Asynchronous ); NTSYSCALLAPI NTSTATUS NTAPI ZwNotifyChangeMultipleKeys( - __in HANDLE MasterKeyHandle, - __in_opt ULONG Count, - __in_ecount_opt(Count) OBJECT_ATTRIBUTES SlaveObjects[], - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG CompletionFilter, - __in BOOLEAN WatchTree, - __out_bcount_opt(BufferSize) PVOID Buffer, - __in ULONG BufferSize, - __in BOOLEAN Asynchronous + _In_ HANDLE MasterKeyHandle, + _In_opt_ ULONG Count, + _In_reads_opt_(Count) OBJECT_ATTRIBUTES SlaveObjects[], + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG CompletionFilter, + _In_ BOOLEAN WatchTree, + _Out_writes_bytes_opt_(BufferSize) PVOID Buffer, + _In_ ULONG BufferSize, + _In_ BOOLEAN Asynchronous ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenDirectoryObject( - __out PHANDLE DirectoryHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE DirectoryHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenEnlistment( - __out PHANDLE EnlistmentHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ResourceManagerHandle, - __in LPGUID EnlistmentGuid, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EnlistmentHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ResourceManagerHandle, + _In_ LPGUID EnlistmentGuid, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenEvent( - __out PHANDLE EventHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenEventPair( - __out PHANDLE EventPairHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE EventPairHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenFile( - __out PHANDLE FileHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG ShareAccess, - __in ULONG OpenOptions + _Out_ PHANDLE FileHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ ULONG ShareAccess, + _In_ ULONG OpenOptions ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenIoCompletion( - __out PHANDLE IoCompletionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE IoCompletionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenJobObject( - __out PHANDLE JobHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE JobHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenKeyEx( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG OpenOptions + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG OpenOptions ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenKeyTransacted( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in HANDLE TransactionHandle + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ HANDLE TransactionHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenKeyTransactedEx( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in ULONG OpenOptions, - __in HANDLE TransactionHandle + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ ULONG OpenOptions, + _In_ HANDLE TransactionHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenKeyedEvent( - __out PHANDLE KeyedEventHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE KeyedEventHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenMutant( - __out PHANDLE MutantHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE MutantHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in PUNICODE_STRING ObjectTypeName, - __in PUNICODE_STRING ObjectName, - __in_opt PSECURITY_DESCRIPTOR SecurityDescriptor, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in ACCESS_MASK GrantedAccess, - __in_opt PPRIVILEGE_SET Privileges, - __in BOOLEAN ObjectCreation, - __in BOOLEAN AccessGranted, - __out PBOOLEAN GenerateOnClose + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ PUNICODE_STRING ObjectTypeName, + _In_ PUNICODE_STRING ObjectName, + _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_ ACCESS_MASK GrantedAccess, + _In_opt_ PPRIVILEGE_SET Privileges, + _In_ BOOLEAN ObjectCreation, + _In_ BOOLEAN AccessGranted, + _Out_ PBOOLEAN GenerateOnClose ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenPrivateNamespace( - __out PHANDLE NamespaceHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in PVOID BoundaryDescriptor + _Out_ PHANDLE NamespaceHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ PVOID BoundaryDescriptor ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PCLIENT_ID ClientId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PCLIENT_ID ClientId ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenProcessToken( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE TokenHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenProcessTokenEx( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __out PHANDLE TokenHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenResourceManager( - __out PHANDLE ResourceManagerHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE TmHandle, - __in_opt LPGUID ResourceManagerGuid, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE ResourceManagerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE TmHandle, + _In_opt_ LPGUID ResourceManagerGuid, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenSection( - __out PHANDLE SectionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE SectionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenSemaphore( - __out PHANDLE SemaphoreHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE SemaphoreHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenSession( - __out PHANDLE SessionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE SessionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject( - __out PHANDLE LinkHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE LinkHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PCLIENT_ID ClientId + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PCLIENT_ID ClientId ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenThreadToken( - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in BOOLEAN OpenAsSelf, - __out PHANDLE TokenHandle + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ BOOLEAN OpenAsSelf, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenThreadTokenEx( - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in BOOLEAN OpenAsSelf, - __in ULONG HandleAttributes, - __out PHANDLE TokenHandle + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ BOOLEAN OpenAsSelf, + _In_ ULONG HandleAttributes, + _Out_ PHANDLE TokenHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenTimer( - __out PHANDLE TimerHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE TimerHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenTransaction( - __out PHANDLE TransactionHandle, - __in ACCESS_MASK DesiredAccess, - __in POBJECT_ATTRIBUTES ObjectAttributes, - __in LPGUID Uow, - __in_opt HANDLE TmHandle + _Out_ PHANDLE TransactionHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_ LPGUID Uow, + _In_opt_ HANDLE TmHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwOpenTransactionManager( - __out PHANDLE TmHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt POBJECT_ATTRIBUTES ObjectAttributes, - __in_opt PUNICODE_STRING LogFileName, - __in_opt LPGUID TmIdentity, - __in_opt ULONG OpenOptions + _Out_ PHANDLE TmHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, + _In_opt_ PUNICODE_STRING LogFileName, + _In_opt_ LPGUID TmIdentity, + _In_opt_ ULONG OpenOptions ); NTSYSCALLAPI NTSTATUS NTAPI ZwPlugPlayControl( - __in PLUGPLAY_CONTROL_CLASS PnPControlClass, - __inout_bcount(PnPControlDataLength) PVOID PnPControlData, - __in ULONG PnPControlDataLength + _In_ PLUGPLAY_CONTROL_CLASS PnPControlClass, + _Inout_updates_bytes_(PnPControlDataLength) PVOID PnPControlData, + _In_ ULONG PnPControlDataLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwPowerInformation( - __in POWER_INFORMATION_LEVEL InformationLevel, - __in_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ POWER_INFORMATION_LEVEL InformationLevel, + _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwPrePrepareComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwPrePrepareEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwPrepareComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwPrepareEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwPrivilegeCheck( - __in HANDLE ClientToken, - __inout PPRIVILEGE_SET RequiredPrivileges, - __out PBOOLEAN Result + _In_ HANDLE ClientToken, + _Inout_ PPRIVILEGE_SET RequiredPrivileges, + _Out_ PBOOLEAN Result ); NTSYSCALLAPI NTSTATUS NTAPI ZwPrivilegeObjectAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in_opt PVOID HandleId, - __in HANDLE ClientToken, - __in ACCESS_MASK DesiredAccess, - __in PPRIVILEGE_SET Privileges, - __in BOOLEAN AccessGranted + _In_ PUNICODE_STRING SubsystemName, + _In_opt_ PVOID HandleId, + _In_ HANDLE ClientToken, + _In_ ACCESS_MASK DesiredAccess, + _In_ PPRIVILEGE_SET Privileges, + _In_ BOOLEAN AccessGranted ); NTSYSCALLAPI NTSTATUS NTAPI ZwPrivilegedServiceAuditAlarm( - __in PUNICODE_STRING SubsystemName, - __in PUNICODE_STRING ServiceName, - __in HANDLE ClientToken, - __in PPRIVILEGE_SET Privileges, - __in BOOLEAN AccessGranted + _In_ PUNICODE_STRING SubsystemName, + _In_ PUNICODE_STRING ServiceName, + _In_ HANDLE ClientToken, + _In_ PPRIVILEGE_SET Privileges, + _In_ BOOLEAN AccessGranted ); NTSYSCALLAPI NTSTATUS NTAPI ZwPropagationComplete( - __in HANDLE ResourceManagerHandle, - __in ULONG RequestCookie, - __in ULONG BufferLength, - __in PVOID Buffer + _In_ HANDLE ResourceManagerHandle, + _In_ ULONG RequestCookie, + _In_ ULONG BufferLength, + _In_ PVOID Buffer ); NTSYSCALLAPI NTSTATUS NTAPI ZwPropagationFailed( - __in HANDLE ResourceManagerHandle, - __in ULONG RequestCookie, - __in NTSTATUS PropStatus + _In_ HANDLE ResourceManagerHandle, + _In_ ULONG RequestCookie, + _In_ NTSTATUS PropStatus ); NTSYSCALLAPI NTSTATUS NTAPI ZwProtectVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG NewProtect, - __out PULONG OldProtect + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG NewProtect, + _Out_ PULONG OldProtect ); NTSYSCALLAPI NTSTATUS NTAPI ZwPulseEvent( - __in HANDLE EventHandle, - __out_opt PLONG PreviousState + _In_ HANDLE EventHandle, + _Out_opt_ PLONG PreviousState ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryAttributesFile( - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PFILE_BASIC_INFORMATION FileInformation + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PFILE_BASIC_INFORMATION FileInformation ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryDebugFilterState( - __in ULONG ComponentId, - __in ULONG Level + _In_ ULONG ComponentId, + _In_ ULONG Level ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryDefaultLocale( - __in BOOLEAN UserProfile, - __out PLCID DefaultLocaleId + _In_ BOOLEAN UserProfile, + _Out_ PLCID DefaultLocaleId ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryDefaultUILanguage( - __out LANGID *DefaultUILanguageId + _Out_ LANGID *DefaultUILanguageId ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryDirectoryFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID FileInformation, - __in ULONG Length, - __in FILE_INFORMATION_CLASS FileInformationClass, - __in BOOLEAN ReturnSingleEntry, - __in_opt PUNICODE_STRING FileName, - __in BOOLEAN RestartScan + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID FileInformation, + _In_ ULONG Length, + _In_ FILE_INFORMATION_CLASS FileInformationClass, + _In_ BOOLEAN ReturnSingleEntry, + _In_opt_ PUNICODE_STRING FileName, + _In_ BOOLEAN RestartScan ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryDirectoryObject( - __in HANDLE DirectoryHandle, - __out_bcount_opt(BufferLength) PVOID Buffer, - __in ULONG Length, - __in BOOLEAN ReturnSingleEntry, - __in BOOLEAN RestartScan, - __inout PULONG Context, - __out_opt PULONG ReturnLength + _In_ HANDLE DirectoryHandle, + _Out_writes_bytes_opt_(BufferLength) PVOID Buffer, + _In_ ULONG Length, + _In_ BOOLEAN ReturnSingleEntry, + _In_ BOOLEAN RestartScan, + _Inout_ PULONG Context, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryEaFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in BOOLEAN ReturnSingleEntry, - __in_bcount_opt(EaListLength) PVOID EaList, - __in ULONG EaListLength, - __in_opt PULONG EaIndex OPTIONAL, - __in BOOLEAN RestartScan + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_ BOOLEAN ReturnSingleEntry, + _In_reads_bytes_opt_(EaListLength) PVOID EaList, + _In_ ULONG EaListLength, + _In_opt_ PULONG EaIndex OPTIONAL, + _In_ BOOLEAN RestartScan ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryEvent( - __in HANDLE EventHandle, - __in EVENT_INFORMATION_CLASS EventInformationClass, - __out_bcount(EventInformationLength) PVOID EventInformation, - __in ULONG EventInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE EventHandle, + _In_ EVENT_INFORMATION_CLASS EventInformationClass, + _Out_writes_bytes_(EventInformationLength) PVOID EventInformation, + _In_ ULONG EventInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryFullAttributesFile( - __in POBJECT_ATTRIBUTES ObjectAttributes, - __out PFILE_NETWORK_OPEN_INFORMATION FileInformation + _In_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PFILE_NETWORK_OPEN_INFORMATION FileInformation ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationAtom( - __in RTL_ATOM Atom, - __in ATOM_INFORMATION_CLASS AtomInformationClass, - __out_bcount(AtomInformationLength) PVOID AtomInformation, - __in ULONG AtomInformationLength, - __out_opt PULONG ReturnLength + _In_ RTL_ATOM Atom, + _In_ ATOM_INFORMATION_CLASS AtomInformationClass, + _Out_writes_bytes_(AtomInformationLength) PVOID AtomInformation, + _In_ ULONG AtomInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationEnlistment( - __in HANDLE EnlistmentHandle, - __in ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, - __out_bcount(EnlistmentInformationLength) PVOID EnlistmentInformation, - __in ULONG EnlistmentInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE EnlistmentHandle, + _In_ ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + _Out_writes_bytes_(EnlistmentInformationLength) PVOID EnlistmentInformation, + _In_ ULONG EnlistmentInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID FileInformation, - __in ULONG Length, - __in FILE_INFORMATION_CLASS FileInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID FileInformation, + _In_ ULONG Length, + _In_ FILE_INFORMATION_CLASS FileInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationJobObject( - __in_opt HANDLE JobHandle, - __in JOBOBJECTINFOCLASS JobObjectInformationClass, - __out_bcount(JobObjectInformationLength) PVOID JobObjectInformation, - __in ULONG JobObjectInformationLength, - __out_opt PULONG ReturnLength + _In_opt_ HANDLE JobHandle, + _In_ JOBOBJECTINFOCLASS JobObjectInformationClass, + _Out_writes_bytes_(JobObjectInformationLength) PVOID JobObjectInformation, + _In_ ULONG JobObjectInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationPort( - __in HANDLE PortHandle, - __in PORT_INFORMATION_CLASS PortInformationClass, - __out_bcount(Length) PVOID PortInformation, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE PortHandle, + _In_ PORT_INFORMATION_CLASS PortInformationClass, + _Out_writes_bytes_(Length) PVOID PortInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationProcess( - __in HANDLE ProcessHandle, - __in PROCESSINFOCLASS ProcessInformationClass, - __out_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _In_ PROCESSINFOCLASS ProcessInformationClass, + _Out_writes_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationResourceManager( - __in HANDLE ResourceManagerHandle, - __in RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - __out_bcount(ResourceManagerInformationLength) PVOID ResourceManagerInformation, - __in ULONG ResourceManagerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ResourceManagerHandle, + _In_ RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + _Out_writes_bytes_(ResourceManagerInformationLength) PVOID ResourceManagerInformation, + _In_ ULONG ResourceManagerInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationThread( - __in HANDLE ThreadHandle, - __in THREADINFOCLASS ThreadInformationClass, - __out_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ThreadHandle, + _In_ THREADINFOCLASS ThreadInformationClass, + _Out_writes_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationToken( - __in HANDLE TokenHandle, - __in TOKEN_INFORMATION_CLASS TokenInformationClass, - __out_bcount(TokenInformationLength) PVOID TokenInformation, - __in ULONG TokenInformationLength, - __out PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, + _Out_writes_bytes_(TokenInformationLength) PVOID TokenInformation, + _In_ ULONG TokenInformationLength, + _Out_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationTransaction( - __in HANDLE TransactionHandle, - __in TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - __out_bcount(TransactionInformationLength) PVOID TransactionInformation, - __in ULONG TransactionInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TransactionHandle, + _In_ TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + _Out_writes_bytes_(TransactionInformationLength) PVOID TransactionInformation, + _In_ ULONG TransactionInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationTransactionManager( - __in HANDLE TransactionManagerHandle, - __in TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - __out_bcount(TransactionManagerInformationLength) PVOID TransactionManagerInformation, - __in ULONG TransactionManagerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TransactionManagerHandle, + _In_ TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + _Out_writes_bytes_(TransactionManagerInformationLength) PVOID TransactionManagerInformation, + _In_ ULONG TransactionManagerInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInformationWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __in WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, - __out_bcount(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, - __in ULONG WorkerFactoryInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE WorkerFactoryHandle, + _In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, + _Out_writes_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, + _In_ ULONG WorkerFactoryInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryInstallUILanguage( - __out LANGID *InstallUILanguageId + _Out_ LANGID *InstallUILanguageId ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryIntervalProfile( - __in KPROFILE_SOURCE ProfileSource, - __out PULONG Interval + _In_ KPROFILE_SOURCE ProfileSource, + _Out_ PULONG Interval ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryIoCompletion( - __in HANDLE IoCompletionHandle, - __in IO_COMPLETION_INFORMATION_CLASS IoCompletionInformationClass, - __out_bcount(IoCompletionInformation) PVOID IoCompletionInformation, - __in ULONG IoCompletionInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE IoCompletionHandle, + _In_ IO_COMPLETION_INFORMATION_CLASS IoCompletionInformationClass, + _Out_writes_bytes_(IoCompletionInformation) PVOID IoCompletionInformation, + _In_ ULONG IoCompletionInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryKey( - __in HANDLE KeyHandle, - __in KEY_INFORMATION_CLASS KeyInformationClass, - __out_bcount_opt(Length) PVOID KeyInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ KEY_INFORMATION_CLASS KeyInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryMultipleValueKey( - __in HANDLE KeyHandle, - __inout_ecount(EntryCount) PKEY_VALUE_ENTRY ValueEntries, - __in ULONG EntryCount, - __out_bcount(*BufferLength) PVOID ValueBuffer, - __inout PULONG BufferLength, - __out_opt PULONG RequiredBufferLength + _In_ HANDLE KeyHandle, + _Inout_updates_(EntryCount) PKEY_VALUE_ENTRY ValueEntries, + _In_ ULONG EntryCount, + _Out_writes_bytes_(*BufferLength) PVOID ValueBuffer, + _Inout_ PULONG BufferLength, + _Out_opt_ PULONG RequiredBufferLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryMutant( - __in HANDLE MutantHandle, - __in MUTANT_INFORMATION_CLASS MutantInformationClass, - __out_bcount(MutantInformationLength) PVOID MutantInformation, - __in ULONG MutantInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE MutantHandle, + _In_ MUTANT_INFORMATION_CLASS MutantInformationClass, + _Out_writes_bytes_(MutantInformationLength) PVOID MutantInformation, + _In_ ULONG MutantInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryObject( - __in HANDLE Handle, - __in OBJECT_INFORMATION_CLASS ObjectInformationClass, - __out_bcount_opt(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE Handle, + _In_ OBJECT_INFORMATION_CLASS ObjectInformationClass, + _Out_writes_bytes_opt_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryOpenSubKeys( - __in POBJECT_ATTRIBUTES TargetKey, - __out PULONG HandleCount + _In_ POBJECT_ATTRIBUTES TargetKey, + _Out_ PULONG HandleCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryOpenSubKeysEx( - __in POBJECT_ATTRIBUTES TargetKey, - __in ULONG BufferLength, - __out_bcount(BufferLength) PVOID Buffer, - __out PULONG RequiredSize + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ ULONG BufferLength, + _Out_writes_bytes_(BufferLength) PVOID Buffer, + _Out_ PULONG RequiredSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryPerformanceCounter( - __out PLARGE_INTEGER PerformanceCounter, - __out_opt PLARGE_INTEGER PerformanceFrequency + _Out_ PLARGE_INTEGER PerformanceCounter, + _Out_opt_ PLARGE_INTEGER PerformanceFrequency ); NTSYSCALLAPI @@ -2499,308 +2499,308 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwQueryQuotaInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in BOOLEAN ReturnSingleEntry, - __in_bcount_opt(SidListLength) PVOID SidList, - __in ULONG SidListLength, - __in_opt PSID StartSid, - __in BOOLEAN RestartScan + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_ BOOLEAN ReturnSingleEntry, + _In_reads_bytes_opt_(SidListLength) PVOID SidList, + _In_ ULONG SidListLength, + _In_opt_ PSID StartSid, + _In_ BOOLEAN RestartScan ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySection( - __in HANDLE SectionHandle, - __in SECTION_INFORMATION_CLASS SectionInformationClass, - __out_bcount(SectionInformationLength) PVOID SectionInformation, - __in SIZE_T SectionInformationLength, - __out_opt PSIZE_T ReturnLength + _In_ HANDLE SectionHandle, + _In_ SECTION_INFORMATION_CLASS SectionInformationClass, + _Out_writes_bytes_(SectionInformationLength) PVOID SectionInformation, + _In_ SIZE_T SectionInformationLength, + _Out_opt_ PSIZE_T ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySecurityAttributesToken( - __in HANDLE TokenHandle, - __in_ecount_opt(NumberOfAttributes) PUNICODE_STRING Attributes, - __in ULONG NumberOfAttributes, - __out_bcount(Length) PVOID Buffer, // PTOKEN_SECURITY_ATTRIBUTES_INFORMATION - __in ULONG Length, - __out PULONG ReturnLength + _In_ HANDLE TokenHandle, + _In_reads_opt_(NumberOfAttributes) PUNICODE_STRING Attributes, + _In_ ULONG NumberOfAttributes, + _Out_writes_bytes_(Length) PVOID Buffer, // PTOKEN_SECURITY_ATTRIBUTES_INFORMATION + _In_ ULONG Length, + _Out_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySecurityObject( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __out_bcount_opt(Length) PSECURITY_DESCRIPTOR SecurityDescriptor, - __in ULONG Length, - __out PULONG LengthNeeded + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_writes_bytes_opt_(Length) PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ ULONG Length, + _Out_ PULONG LengthNeeded ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySemaphore( - __in HANDLE SemaphoreHandle, - __in SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass, - __out_bcount(SemaphoreInformationLength) PVOID SemaphoreInformation, - __in ULONG SemaphoreInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE SemaphoreHandle, + _In_ SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass, + _Out_writes_bytes_(SemaphoreInformationLength) PVOID SemaphoreInformation, + _In_ ULONG SemaphoreInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySymbolicLinkObject( - __in HANDLE LinkHandle, - __inout PUNICODE_STRING LinkTarget, - __out_opt PULONG ReturnedLength + _In_ HANDLE LinkHandle, + _Inout_ PUNICODE_STRING LinkTarget, + _Out_opt_ PULONG ReturnedLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySystemEnvironmentValue( - __in PUNICODE_STRING VariableName, - __out_bcount(ValueLength) PWSTR VariableValue, - __in USHORT ValueLength, - __out_opt PUSHORT ReturnLength + _In_ PUNICODE_STRING VariableName, + _Out_writes_bytes_(ValueLength) PWSTR VariableValue, + _In_ USHORT ValueLength, + _Out_opt_ PUSHORT ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySystemInformation( - __in SYSTEM_INFORMATION_CLASS SystemInformationClass, - __out_bcount_opt(SystemInformationLength) PVOID SystemInformation, - __in ULONG SystemInformationLength, - __out_opt PULONG ReturnLength + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, + _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation, + _In_ ULONG SystemInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySystemInformationEx( - __in SYSTEM_INFORMATION_CLASS SystemInformationClass, - __in_bcount(QueryInformationLength) PVOID QueryInformation, - __in ULONG QueryInformationLength, - __out_bcount_opt(SystemInformationLength) PVOID SystemInformation, - __in ULONG SystemInformationLength, - __out_opt PULONG ReturnLength + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, + _In_reads_bytes_(QueryInformationLength) PVOID QueryInformation, + _In_ ULONG QueryInformationLength, + _Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation, + _In_ ULONG SystemInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQuerySystemTime( - __out PLARGE_INTEGER SystemTime + _Out_ PLARGE_INTEGER SystemTime ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryTimer( - __in HANDLE TimerHandle, - __in TIMER_INFORMATION_CLASS TimerInformationClass, - __out_bcount(TimerInformationLength) PVOID TimerInformation, - __in ULONG TimerInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE TimerHandle, + _In_ TIMER_INFORMATION_CLASS TimerInformationClass, + _Out_writes_bytes_(TimerInformationLength) PVOID TimerInformation, + _In_ ULONG TimerInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryTimerResolution( - __out PULONG MaximumTime, - __out PULONG MinimumTime, - __out PULONG CurrentTime + _Out_ PULONG MaximumTime, + _Out_ PULONG MinimumTime, + _Out_ PULONG CurrentTime ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryValueKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING ValueName, - __in KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, - __out_bcount_opt(Length) PVOID KeyValueInformation, - __in ULONG Length, - __out PULONG ResultLength + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING ValueName, + _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + _Out_writes_bytes_opt_(Length) PVOID KeyValueInformation, + _In_ ULONG Length, + _Out_ PULONG ResultLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in MEMORY_INFORMATION_CLASS MemoryInformationClass, - __out_bcount(MemoryInformationLength) PVOID MemoryInformation, - __in SIZE_T MemoryInformationLength, - __out_opt PSIZE_T ReturnLength + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ MEMORY_INFORMATION_CLASS MemoryInformationClass, + _Out_writes_bytes_(MemoryInformationLength) PVOID MemoryInformation, + _In_ SIZE_T MemoryInformationLength, + _Out_opt_ PSIZE_T ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueryVolumeInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID FsInformation, - __in ULONG Length, - __in FSINFOCLASS FsInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID FsInformation, + _In_ ULONG Length, + _In_ FSINFOCLASS FsInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueueApcThread( - __in HANDLE ThreadHandle, - __in PPS_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcArgument1, - __in_opt PVOID ApcArgument2, - __in_opt PVOID ApcArgument3 + _In_ HANDLE ThreadHandle, + _In_ PPS_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcArgument1, + _In_opt_ PVOID ApcArgument2, + _In_opt_ PVOID ApcArgument3 ); NTSYSCALLAPI NTSTATUS NTAPI ZwQueueApcThreadEx( - __in HANDLE ThreadHandle, - __in_opt HANDLE UserApcReserveHandle, - __in PPS_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcArgument1, - __in_opt PVOID ApcArgument2, - __in_opt PVOID ApcArgument3 + _In_ HANDLE ThreadHandle, + _In_opt_ HANDLE UserApcReserveHandle, + _In_ PPS_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcArgument1, + _In_opt_ PVOID ApcArgument2, + _In_opt_ PVOID ApcArgument3 ); NTSYSCALLAPI NTSTATUS NTAPI ZwRaiseException( - __in PEXCEPTION_RECORD ExceptionRecord, - __in PCONTEXT ContextRecord, - __in BOOLEAN FirstChance + _In_ PEXCEPTION_RECORD ExceptionRecord, + _In_ PCONTEXT ContextRecord, + _In_ BOOLEAN FirstChance ); NTSYSCALLAPI NTSTATUS NTAPI ZwRaiseHardError( - __in NTSTATUS ErrorStatus, - __in ULONG NumberOfParameters, - __in ULONG UnicodeStringParameterMask, - __in_ecount(NumberOfParameters) PULONG_PTR Parameters, - __in ULONG ValidResponseOptions, - __out PULONG Response + _In_ NTSTATUS ErrorStatus, + _In_ ULONG NumberOfParameters, + _In_ ULONG UnicodeStringParameterMask, + _In_reads_(NumberOfParameters) PULONG_PTR Parameters, + _In_ ULONG ValidResponseOptions, + _Out_ PULONG Response ); NTSYSCALLAPI NTSTATUS NTAPI ZwReadFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI ZwReadFileScatter( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PFILE_SEGMENT_ELEMENT SegmentArray, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PFILE_SEGMENT_ELEMENT SegmentArray, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI ZwReadOnlyEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwReadRequestData( - __in HANDLE PortHandle, - __in PPORT_MESSAGE Message, - __in ULONG DataEntryIndex, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE Message, + _In_ ULONG DataEntryIndex, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ); NTSYSCALLAPI NTSTATUS NTAPI ZwReadVirtualMemory( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ); NTSYSCALLAPI NTSTATUS NTAPI ZwRecoverEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PVOID EnlistmentKey + _In_ HANDLE EnlistmentHandle, + _In_opt_ PVOID EnlistmentKey ); NTSYSCALLAPI NTSTATUS NTAPI ZwRecoverResourceManager( - __in HANDLE ResourceManagerHandle + _In_ HANDLE ResourceManagerHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwRecoverTransactionManager( - __in HANDLE TransactionManagerHandle + _In_ HANDLE TransactionManagerHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwRegisterProtocolAddressInformation( - __in HANDLE ResourceManager, - __in PCRM_PROTOCOL_ID ProtocolId, - __in ULONG ProtocolInformationSize, - __in PVOID ProtocolInformation, - __in_opt ULONG CreateOptions + _In_ HANDLE ResourceManager, + _In_ PCRM_PROTOCOL_ID ProtocolId, + _In_ ULONG ProtocolInformationSize, + _In_ PVOID ProtocolInformation, + _In_opt_ ULONG CreateOptions ); NTSYSCALLAPI NTSTATUS NTAPI ZwRegisterThreadTerminatePort( - __in HANDLE PortHandle + _In_ HANDLE PortHandle ); NTSYSCALLAPI @@ -2814,274 +2814,274 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwReleaseKeyedEvent( - __in HANDLE KeyedEventHandle, - __in PVOID KeyValue, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE KeyedEventHandle, + _In_ PVOID KeyValue, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwReleaseMutant( - __in HANDLE MutantHandle, - __out_opt PLONG PreviousCount + _In_ HANDLE MutantHandle, + _Out_opt_ PLONG PreviousCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwReleaseSemaphore( - __in HANDLE SemaphoreHandle, - __in LONG ReleaseCount, - __out_opt PLONG PreviousCount + _In_ HANDLE SemaphoreHandle, + _In_ LONG ReleaseCount, + _Out_opt_ PLONG PreviousCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwReleaseWorkerFactoryWorker( - __in HANDLE WorkerFactoryHandle + _In_ HANDLE WorkerFactoryHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwRemoveIoCompletion( - __in HANDLE IoCompletionHandle, - __out PVOID *KeyContext, - __out PVOID *ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE IoCompletionHandle, + _Out_ PVOID *KeyContext, + _Out_ PVOID *ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwRemoveIoCompletionEx( - __in HANDLE IoCompletionHandle, - __out_ecount(Count) PFILE_IO_COMPLETION_INFORMATION IoCompletionInformation, - __in ULONG Count, - __out PULONG NumEntriesRemoved, - __in_opt PLARGE_INTEGER Timeout, - __in BOOLEAN Alertable + _In_ HANDLE IoCompletionHandle, + _Out_writes_(Count) PFILE_IO_COMPLETION_INFORMATION IoCompletionInformation, + _In_ ULONG Count, + _Out_ PULONG NumEntriesRemoved, + _In_opt_ PLARGE_INTEGER Timeout, + _In_ BOOLEAN Alertable ); NTSYSCALLAPI NTSTATUS NTAPI ZwRemoveProcessDebug( - __in HANDLE ProcessHandle, - __in HANDLE DebugObjectHandle + _In_ HANDLE ProcessHandle, + _In_ HANDLE DebugObjectHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwRenameKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING NewName + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING NewName ); NTSYSCALLAPI NTSTATUS NTAPI ZwRenameTransactionManager( - __in PUNICODE_STRING LogFileName, - __in LPGUID ExistingTransactionManagerGuid + _In_ PUNICODE_STRING LogFileName, + _In_ LPGUID ExistingTransactionManagerGuid ); NTSYSCALLAPI NTSTATUS NTAPI ZwReplaceKey( - __in POBJECT_ATTRIBUTES NewFile, - __in HANDLE TargetHandle, - __in POBJECT_ATTRIBUTES OldFile + _In_ POBJECT_ATTRIBUTES NewFile, + _In_ HANDLE TargetHandle, + _In_ POBJECT_ATTRIBUTES OldFile ); NTSYSCALLAPI NTSTATUS NTAPI ZwReplacePartitionUnit( - __in PUNICODE_STRING TargetInstancePath, - __in PUNICODE_STRING SpareInstancePath, - __in ULONG Flags + _In_ PUNICODE_STRING TargetInstancePath, + _In_ PUNICODE_STRING SpareInstancePath, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwReplyPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE ReplyMessage + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE ReplyMessage ); NTSYSCALLAPI NTSTATUS NTAPI ZwReplyWaitReceivePort( - __in HANDLE PortHandle, - __out_opt PVOID *PortContext, - __in_opt PPORT_MESSAGE ReplyMessage, - __out PPORT_MESSAGE ReceiveMessage + _In_ HANDLE PortHandle, + _Out_opt_ PVOID *PortContext, + _In_opt_ PPORT_MESSAGE ReplyMessage, + _Out_ PPORT_MESSAGE ReceiveMessage ); NTSYSCALLAPI NTSTATUS NTAPI ZwReplyWaitReceivePortEx( - __in HANDLE PortHandle, - __out_opt PVOID *PortContext, - __in_opt PPORT_MESSAGE ReplyMessage, - __out PPORT_MESSAGE ReceiveMessage, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE PortHandle, + _Out_opt_ PVOID *PortContext, + _In_opt_ PPORT_MESSAGE ReplyMessage, + _Out_ PPORT_MESSAGE ReceiveMessage, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwReplyWaitReplyPort( - __in HANDLE PortHandle, - __inout PPORT_MESSAGE ReplyMessage + _In_ HANDLE PortHandle, + _Inout_ PPORT_MESSAGE ReplyMessage ); NTSYSCALLAPI NTSTATUS NTAPI ZwRequestPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE RequestMessage + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE RequestMessage ); NTSYSCALLAPI NTSTATUS NTAPI ZwRequestWaitReplyPort( - __in HANDLE PortHandle, - __in PPORT_MESSAGE RequestMessage, - __out PPORT_MESSAGE ReplyMessage + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE RequestMessage, + _Out_ PPORT_MESSAGE ReplyMessage ); NTSYSCALLAPI NTSTATUS NTAPI ZwRequestWakeupLatency( - __in LATENCY_TIME latency + _In_ LATENCY_TIME latency ); NTSYSCALLAPI NTSTATUS NTAPI ZwResetEvent( - __in HANDLE EventHandle, - __out_opt PLONG PreviousState + _In_ HANDLE EventHandle, + _Out_opt_ PLONG PreviousState ); NTSYSCALLAPI NTSTATUS NTAPI ZwResetWriteWatch( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in SIZE_T RegionSize + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ SIZE_T RegionSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwRestoreKey( - __in HANDLE KeyHandle, - __in HANDLE FileHandle, - __in ULONG Flags + _In_ HANDLE KeyHandle, + _In_ HANDLE FileHandle, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwResumeProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwResumeThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwRollbackComplete( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwRollbackEnlistment( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwRollbackTransaction( - __in HANDLE TransactionHandle, - __in BOOLEAN Wait + _In_ HANDLE TransactionHandle, + _In_ BOOLEAN Wait ); NTSYSCALLAPI NTSTATUS NTAPI ZwRollforwardTransactionManager( - __in HANDLE TransactionManagerHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE TransactionManagerHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwSaveKey( - __in HANDLE KeyHandle, - __in HANDLE FileHandle + _In_ HANDLE KeyHandle, + _In_ HANDLE FileHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSaveKeyEx( - __in HANDLE KeyHandle, - __in HANDLE FileHandle, - __in ULONG Format + _In_ HANDLE KeyHandle, + _In_ HANDLE FileHandle, + _In_ ULONG Format ); NTSYSCALLAPI NTSTATUS NTAPI ZwSaveMergedKeys( - __in HANDLE HighPrecedenceKeyHandle, - __in HANDLE LowPrecedenceKeyHandle, - __in HANDLE FileHandle + _In_ HANDLE HighPrecedenceKeyHandle, + _In_ HANDLE LowPrecedenceKeyHandle, + _In_ HANDLE FileHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSecureConnectPort( - __out PHANDLE PortHandle, - __in PUNICODE_STRING PortName, - __in PSECURITY_QUALITY_OF_SERVICE SecurityQos, - __inout_opt PPORT_VIEW ClientView, - __in_opt PSID RequiredServerSid, - __inout_opt PREMOTE_PORT_VIEW ServerView, - __out_opt PULONG MaxMessageLength, - __inout_opt PVOID ConnectionInformation, - __inout_opt PULONG ConnectionInformationLength + _Out_ PHANDLE PortHandle, + _In_ PUNICODE_STRING PortName, + _In_ PSECURITY_QUALITY_OF_SERVICE SecurityQos, + _Inout_opt_ PPORT_VIEW ClientView, + _In_opt_ PSID RequiredServerSid, + _Inout_opt_ PREMOTE_PORT_VIEW ServerView, + _Out_opt_ PULONG MaxMessageLength, + _Inout_opt_ PVOID ConnectionInformation, + _Inout_opt_ PULONG ConnectionInformationLength ); NTSYSCALLAPI @@ -3095,488 +3095,488 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwSetContextThread( - __in HANDLE ThreadHandle, - __in PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _In_ PCONTEXT ThreadContext ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetDebugFilterState( - __in ULONG ComponentId, - __in ULONG Level, - __in BOOLEAN State + _In_ ULONG ComponentId, + _In_ ULONG Level, + _In_ BOOLEAN State ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetDefaultHardErrorPort( - __in HANDLE DefaultHardErrorPort + _In_ HANDLE DefaultHardErrorPort ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetDefaultLocale( - __in BOOLEAN UserProfile, - __in LCID DefaultLocaleId + _In_ BOOLEAN UserProfile, + _In_ LCID DefaultLocaleId ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetDefaultUILanguage( - __in LANGID DefaultUILanguageId + _In_ LANGID DefaultUILanguageId ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetEaFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetEvent( - __in HANDLE EventHandle, - __out_opt PLONG PreviousState + _In_ HANDLE EventHandle, + _Out_opt_ PLONG PreviousState ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetEventBoostPriority( - __in HANDLE EventHandle + _In_ HANDLE EventHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetHighEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetHighWaitLowEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationDebugObject( - __in HANDLE DebugObjectHandle, - __in DEBUGOBJECTINFOCLASS DebugObjectInformationClass, - __in PVOID DebugInformation, - __in ULONG DebugInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE DebugObjectHandle, + _In_ DEBUGOBJECTINFOCLASS DebugObjectInformationClass, + _In_ PVOID DebugInformation, + _In_ ULONG DebugInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationEnlistment( - __in_opt HANDLE EnlistmentHandle, - __in ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, - __in_bcount(EnlistmentInformationLength) PVOID EnlistmentInformation, - __in ULONG EnlistmentInformationLength + _In_opt_ HANDLE EnlistmentHandle, + _In_ ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + _In_reads_bytes_(EnlistmentInformationLength) PVOID EnlistmentInformation, + _In_ ULONG EnlistmentInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID FileInformation, - __in ULONG Length, - __in FILE_INFORMATION_CLASS FileInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID FileInformation, + _In_ ULONG Length, + _In_ FILE_INFORMATION_CLASS FileInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationJobObject( - __in HANDLE JobHandle, - __in JOBOBJECTINFOCLASS JobObjectInformationClass, - __in_bcount(JobObjectInformationLength) PVOID JobObjectInformation, - __in ULONG JobObjectInformationLength + _In_ HANDLE JobHandle, + _In_ JOBOBJECTINFOCLASS JobObjectInformationClass, + _In_reads_bytes_(JobObjectInformationLength) PVOID JobObjectInformation, + _In_ ULONG JobObjectInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationKey( - __in HANDLE KeyHandle, - __in KEY_SET_INFORMATION_CLASS KeySetInformationClass, - __in_bcount(KeySetInformationLength) PVOID KeySetInformation, - __in ULONG KeySetInformationLength + _In_ HANDLE KeyHandle, + _In_ KEY_SET_INFORMATION_CLASS KeySetInformationClass, + _In_reads_bytes_(KeySetInformationLength) PVOID KeySetInformation, + _In_ ULONG KeySetInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationObject( - __in HANDLE Handle, - __in OBJECT_INFORMATION_CLASS ObjectInformationClass, - __in_bcount(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength + _In_ HANDLE Handle, + _In_ OBJECT_INFORMATION_CLASS ObjectInformationClass, + _In_reads_bytes_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationProcess( - __in HANDLE ProcessHandle, - __in PROCESSINFOCLASS ProcessInformationClass, - __in_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength + _In_ HANDLE ProcessHandle, + _In_ PROCESSINFOCLASS ProcessInformationClass, + _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationResourceManager( - __in HANDLE ResourceManagerHandle, - __in RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - __in_bcount(ResourceManagerInformationLength) PVOID ResourceManagerInformation, - __in ULONG ResourceManagerInformationLength + _In_ HANDLE ResourceManagerHandle, + _In_ RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + _In_reads_bytes_(ResourceManagerInformationLength) PVOID ResourceManagerInformation, + _In_ ULONG ResourceManagerInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationThread( - __in HANDLE ThreadHandle, - __in THREADINFOCLASS ThreadInformationClass, - __in_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength + _In_ HANDLE ThreadHandle, + _In_ THREADINFOCLASS ThreadInformationClass, + _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationToken( - __in HANDLE TokenHandle, - __in TOKEN_INFORMATION_CLASS TokenInformationClass, - __in_bcount(TokenInformationLength) PVOID TokenInformation, - __in ULONG TokenInformationLength + _In_ HANDLE TokenHandle, + _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, + _In_reads_bytes_(TokenInformationLength) PVOID TokenInformation, + _In_ ULONG TokenInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationTransaction( - __in HANDLE TransactionHandle, - __in TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - __in_bcount(TransactionInformationLength) PVOID TransactionInformation, - __in ULONG TransactionInformationLength + _In_ HANDLE TransactionHandle, + _In_ TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + _In_reads_bytes_(TransactionInformationLength) PVOID TransactionInformation, + _In_ ULONG TransactionInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationTransactionManager( - __in_opt HANDLE TmHandle, - __in TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - __in_bcount(TransactionManagerInformationLength) PVOID TransactionManagerInformation, - __in ULONG TransactionManagerInformationLength + _In_opt_ HANDLE TmHandle, + _In_ TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + _In_reads_bytes_(TransactionManagerInformationLength) PVOID TransactionManagerInformation, + _In_ ULONG TransactionManagerInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetInformationWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __in WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, - __in_bcount(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, - __in ULONG WorkerFactoryInformationLength + _In_ HANDLE WorkerFactoryHandle, + _In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass, + _In_reads_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation, + _In_ ULONG WorkerFactoryInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetIntervalProfile( - __in ULONG Interval, - __in KPROFILE_SOURCE Source + _In_ ULONG Interval, + _In_ KPROFILE_SOURCE Source ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetIoCompletion( - __in HANDLE IoCompletionHandle, - __in PVOID KeyContext, - __in_opt PVOID ApcContext, - __in NTSTATUS IoStatus, - __in ULONG_PTR IoStatusInformation + _In_ HANDLE IoCompletionHandle, + _In_ PVOID KeyContext, + _In_opt_ PVOID ApcContext, + _In_ NTSTATUS IoStatus, + _In_ ULONG_PTR IoStatusInformation ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetIoCompletionEx( - __in HANDLE IoCompletionHandle, - __in HANDLE IoCompletionReserveHandle, - __in PVOID KeyContext, - __in_opt PVOID ApcContext, - __in NTSTATUS IoStatus, - __in ULONG_PTR IoStatusInformation + _In_ HANDLE IoCompletionHandle, + _In_ HANDLE IoCompletionReserveHandle, + _In_ PVOID KeyContext, + _In_opt_ PVOID ApcContext, + _In_ NTSTATUS IoStatus, + _In_ ULONG_PTR IoStatusInformation ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetLdtEntries( - __in ULONG Selector0, - __in ULONG Entry0Low, - __in ULONG Entry0Hi, - __in ULONG Selector1, - __in ULONG Entry1Low, - __in ULONG Entry1Hi + _In_ ULONG Selector0, + _In_ ULONG Entry0Low, + _In_ ULONG Entry0Hi, + _In_ ULONG Selector1, + _In_ ULONG Entry1Low, + _In_ ULONG Entry1Hi ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetLowEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetLowWaitHighEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetQuotaInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetSecurityObject( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetSystemEnvironmentValue( - __in PUNICODE_STRING VariableName, - __in PUNICODE_STRING VariableValue + _In_ PUNICODE_STRING VariableName, + _In_ PUNICODE_STRING VariableValue ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetSystemInformation( - __in SYSTEM_INFORMATION_CLASS SystemInformationClass, - __in_bcount_opt(SystemInformationLength) PVOID SystemInformation, - __in ULONG SystemInformationLength + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, + _In_reads_bytes_opt_(SystemInformationLength) PVOID SystemInformation, + _In_ ULONG SystemInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetSystemPowerState( - __in POWER_ACTION SystemAction, - __in SYSTEM_POWER_STATE LightestSystemState, - __in ULONG Flags // POWER_ACTION_* flags + _In_ POWER_ACTION SystemAction, + _In_ SYSTEM_POWER_STATE LightestSystemState, + _In_ ULONG Flags // POWER_ACTION_* flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetSystemTime( - __in_opt PLARGE_INTEGER SystemTime, - __out_opt PLARGE_INTEGER PreviousTime + _In_opt_ PLARGE_INTEGER SystemTime, + _Out_opt_ PLARGE_INTEGER PreviousTime ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetThreadExecutionState( - __in EXECUTION_STATE NewFlags, // ES_* flags - __out EXECUTION_STATE *PreviousFlags + _In_ EXECUTION_STATE NewFlags, // ES_* flags + _Out_ EXECUTION_STATE *PreviousFlags ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetTimer( - __in HANDLE TimerHandle, - __in PLARGE_INTEGER DueTime, - __in_opt PTIMER_APC_ROUTINE TimerApcRoutine, - __in_opt PVOID TimerContext, - __in BOOLEAN ResumeTimer, - __in_opt LONG Period, - __out_opt PBOOLEAN PreviousState + _In_ HANDLE TimerHandle, + _In_ PLARGE_INTEGER DueTime, + _In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine, + _In_opt_ PVOID TimerContext, + _In_ BOOLEAN ResumeTimer, + _In_opt_ LONG Period, + _Out_opt_ PBOOLEAN PreviousState ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetTimerEx( - __in HANDLE TimerHandle, - __in TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, - __inout_bcount_opt(TimerSetInformationLength) PVOID TimerSetInformation, - __in ULONG TimerSetInformationLength + _In_ HANDLE TimerHandle, + _In_ TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, + _Inout_updates_bytes_opt_(TimerSetInformationLength) PVOID TimerSetInformation, + _In_ ULONG TimerSetInformationLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetTimerResolution( - __in ULONG DesiredTime, - __in BOOLEAN SetResolution, - __out PULONG ActualTime + _In_ ULONG DesiredTime, + _In_ BOOLEAN SetResolution, + _Out_ PULONG ActualTime ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetUuidSeed( - __in PCHAR Seed + _In_ PCHAR Seed ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetValueKey( - __in HANDLE KeyHandle, - __in PUNICODE_STRING ValueName, - __in_opt ULONG TitleIndex, - __in ULONG Type, - __in_bcount_opt(DataSize) PVOID Data, - __in ULONG DataSize + _In_ HANDLE KeyHandle, + _In_ PUNICODE_STRING ValueName, + _In_opt_ ULONG TitleIndex, + _In_ ULONG Type, + _In_reads_bytes_opt_(DataSize) PVOID Data, + _In_ ULONG DataSize ); NTSYSCALLAPI NTSTATUS NTAPI ZwSetVolumeInformationFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID FsInformation, - __in ULONG Length, - __in FSINFOCLASS FsInformationClass + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID FsInformation, + _In_ ULONG Length, + _In_ FSINFOCLASS FsInformationClass ); NTSYSCALLAPI NTSTATUS NTAPI ZwShutdownSystem( - __in SHUTDOWN_ACTION Action + _In_ SHUTDOWN_ACTION Action ); NTSYSCALLAPI NTSTATUS NTAPI ZwShutdownWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __inout volatile LONG *PendingWorkerCount + _In_ HANDLE WorkerFactoryHandle, + _Inout_ volatile LONG *PendingWorkerCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwSignalAndWaitForSingleObject( - __in HANDLE SignalHandle, - __in HANDLE WaitHandle, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE SignalHandle, + _In_ HANDLE WaitHandle, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwSinglePhaseReject( - __in HANDLE EnlistmentHandle, - __in_opt PLARGE_INTEGER TmVirtualClock + _In_ HANDLE EnlistmentHandle, + _In_opt_ PLARGE_INTEGER TmVirtualClock ); NTSYSCALLAPI NTSTATUS NTAPI ZwStartProfile( - __in HANDLE ProfileHandle + _In_ HANDLE ProfileHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwStopProfile( - __in HANDLE ProfileHandle + _In_ HANDLE ProfileHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSuspendProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwSuspendThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); NTSYSCALLAPI NTSTATUS NTAPI ZwSystemDebugControl( - __in SYSDBG_COMMAND Command, - __inout_bcount_opt(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount_opt(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength, - __out_opt PULONG ReturnLength + _In_ SYSDBG_COMMAND Command, + _Inout_updates_bytes_opt_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength, + _Out_opt_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwTerminateJobObject( - __in HANDLE JobHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE JobHandle, + _In_ NTSTATUS ExitStatus ); NTSYSCALLAPI NTSTATUS NTAPI ZwTerminateProcess( - __in_opt HANDLE ProcessHandle, - __in NTSTATUS ExitStatus + _In_opt_ HANDLE ProcessHandle, + _In_ NTSTATUS ExitStatus ); NTSYSCALLAPI NTSTATUS NTAPI ZwTerminateThread( - __in_opt HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_opt_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ); NTSYSCALLAPI @@ -3604,211 +3604,211 @@ NTSYSCALLAPI NTSTATUS NTAPI ZwTraceControl( - __in ULONG FunctionCode, - __in_bcount_opt(InBufferLen) PVOID InBuffer, - __in ULONG InBufferLen, - __out_bcount_opt(OutBufferLen) PVOID OutBuffer, - __in ULONG OutBufferLen, - __out PULONG ReturnLength + _In_ ULONG FunctionCode, + _In_reads_bytes_opt_(InBufferLen) PVOID InBuffer, + _In_ ULONG InBufferLen, + _Out_writes_bytes_opt_(OutBufferLen) PVOID OutBuffer, + _In_ ULONG OutBufferLen, + _Out_ PULONG ReturnLength ); NTSYSCALLAPI NTSTATUS NTAPI ZwTraceEvent( - __in HANDLE TraceHandle, - __in ULONG Flags, - __in ULONG FieldSize, - __in PVOID Fields + _In_ HANDLE TraceHandle, + _In_ ULONG Flags, + _In_ ULONG FieldSize, + _In_ PVOID Fields ); NTSYSCALLAPI NTSTATUS NTAPI ZwUnloadDriver( - __in PUNICODE_STRING DriverServiceName + _In_ PUNICODE_STRING DriverServiceName ); NTSYSCALLAPI NTSTATUS NTAPI ZwUnloadKey( - __in POBJECT_ATTRIBUTES TargetKey + _In_ POBJECT_ATTRIBUTES TargetKey ); NTSYSCALLAPI NTSTATUS NTAPI ZwUnloadKey2( - __in POBJECT_ATTRIBUTES TargetKey, - __in ULONG Flags + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_ ULONG Flags ); NTSYSCALLAPI NTSTATUS NTAPI ZwUnloadKeyEx( - __in POBJECT_ATTRIBUTES TargetKey, - __in_opt HANDLE Event + _In_ POBJECT_ATTRIBUTES TargetKey, + _In_opt_ HANDLE Event ); NTSYSCALLAPI NTSTATUS NTAPI ZwUnlockFile( - __in HANDLE FileHandle, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PLARGE_INTEGER ByteOffset, - __in PLARGE_INTEGER Length, - __in ULONG Key + _In_ HANDLE FileHandle, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PLARGE_INTEGER ByteOffset, + _In_ PLARGE_INTEGER Length, + _In_ ULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI ZwUnlockVirtualMemory( - __in HANDLE ProcessHandle, - __inout PVOID *BaseAddress, - __inout PSIZE_T RegionSize, - __in ULONG MapType + _In_ HANDLE ProcessHandle, + _Inout_ PVOID *BaseAddress, + _Inout_ PSIZE_T RegionSize, + _In_ ULONG MapType ); NTSYSCALLAPI NTSTATUS NTAPI ZwUnmapViewOfSection( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress ); NTSYSCALLAPI NTSTATUS NTAPI ZwVdmControl( - __in VDMSERVICECLASS Service, - __inout PVOID ServiceData + _In_ VDMSERVICECLASS Service, + _Inout_ PVOID ServiceData ); NTSYSCALLAPI NTSTATUS NTAPI ZwWaitForDebugEvent( - __in HANDLE DebugObjectHandle, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout, - __out PVOID WaitStateChange + _In_ HANDLE DebugObjectHandle, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout, + _Out_ PVOID WaitStateChange ); NTSYSCALLAPI NTSTATUS NTAPI ZwWaitForKeyedEvent( - __in HANDLE KeyedEventHandle, - __in PVOID KeyValue, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE KeyedEventHandle, + _In_ PVOID KeyValue, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwWaitForMultipleObjects( - __in ULONG Count, - __in_ecount(Count) PHANDLE Handles, - __in WAIT_TYPE WaitType, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ ULONG Count, + _In_reads_(Count) PHANDLE Handles, + _In_ WAIT_TYPE WaitType, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwWaitForSingleObject( - __in HANDLE Handle, - __in BOOLEAN Alertable, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE Handle, + _In_ BOOLEAN Alertable, + _In_opt_ PLARGE_INTEGER Timeout ); NTSYSCALLAPI NTSTATUS NTAPI ZwWaitForWorkViaWorkerFactory( - __in HANDLE WorkerFactoryHandle, - __out struct _FILE_IO_COMPLETION_INFORMATION *MiniPacket + _In_ HANDLE WorkerFactoryHandle, + _Out_ struct _FILE_IO_COMPLETION_INFORMATION *MiniPacket ); NTSYSCALLAPI NTSTATUS NTAPI ZwWaitHighEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwWaitLowEventPair( - __in HANDLE EventPairHandle + _In_ HANDLE EventPairHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwWorkerFactoryWorkerReady( - __in HANDLE WorkerFactoryHandle + _In_ HANDLE WorkerFactoryHandle ); NTSYSCALLAPI NTSTATUS NTAPI ZwWriteFile( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI ZwWriteFileGather( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in PFILE_SEGMENT_ELEMENT SegmentArray, - __in ULONG Length, - __in_opt PLARGE_INTEGER ByteOffset, - __in_opt PULONG Key + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_ PFILE_SEGMENT_ELEMENT SegmentArray, + _In_ ULONG Length, + _In_opt_ PLARGE_INTEGER ByteOffset, + _In_opt_ PULONG Key ); NTSYSCALLAPI NTSTATUS NTAPI ZwWriteRequestData( - __in HANDLE PortHandle, - __in PPORT_MESSAGE Message, - __in ULONG DataEntryIndex, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE PortHandle, + _In_ PPORT_MESSAGE Message, + _In_ ULONG DataEntryIndex, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ); NTSYSCALLAPI NTSTATUS NTAPI ZwWriteVirtualMemory( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ); NTSYSCALLAPI diff --git a/2.x/trunk/phlib/include/ph.h b/2.x/trunk/phlib/include/ph.h index bad78ba5b..7cd1b9d1a 100644 --- a/2.x/trunk/phlib/include/ph.h +++ b/2.x/trunk/phlib/include/ph.h @@ -23,128 +23,128 @@ extern "C" { PHLIBAPI NTSTATUS PhOpenProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ProcessId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ProcessId ); PHLIBAPI NTSTATUS PhOpenThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ThreadId + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ThreadId ); PHLIBAPI NTSTATUS PhOpenThreadProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ThreadHandle + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ThreadHandle ); PHLIBAPI NTSTATUS PhOpenProcessToken( - __out PHANDLE TokenHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ProcessHandle + _Out_ PHANDLE TokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ProcessHandle ); PHLIBAPI NTSTATUS PhOpenThreadToken( - __out PHANDLE TokenHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ThreadHandle, - __in BOOLEAN OpenAsSelf + _Out_ PHANDLE TokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ThreadHandle, + _In_ BOOLEAN OpenAsSelf ); PHLIBAPI NTSTATUS PhGetObjectSecurity( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __out PSECURITY_DESCRIPTOR *SecurityDescriptor + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor ); PHLIBAPI NTSTATUS PhSetObjectSecurity( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); PHLIBAPI NTSTATUS PhTerminateProcess( - __in HANDLE ProcessHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ProcessHandle, + _In_ NTSTATUS ExitStatus ); PHLIBAPI NTSTATUS PhSuspendProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); PHLIBAPI NTSTATUS PhResumeProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ); PHLIBAPI NTSTATUS PhTerminateThread( - __in HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ); PHLIBAPI NTSTATUS PhSuspendThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); PHLIBAPI NTSTATUS PhResumeThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ); PHLIBAPI NTSTATUS PhGetThreadContext( - __in HANDLE ThreadHandle, - __inout PCONTEXT Context + _In_ HANDLE ThreadHandle, + _Inout_ PCONTEXT Context ); PHLIBAPI NTSTATUS PhSetThreadContext( - __in HANDLE ThreadHandle, - __in PCONTEXT Context + _In_ HANDLE ThreadHandle, + _In_ PCONTEXT Context ); PHLIBAPI NTSTATUS PhReadVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ); PHLIBAPI NTSTATUS PhWriteVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ); PHLIBAPI NTSTATUS PhGetProcessImageFileName( - __in HANDLE ProcessHandle, - __out PPH_STRING *FileName + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *FileName ); PHLIBAPI NTSTATUS PhGetProcessImageFileNameWin32( - __in HANDLE ProcessHandle, - __out PPH_STRING *FileName + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *FileName ); /** Specifies a PEB string. */ @@ -165,41 +165,34 @@ typedef enum _PH_PEB_OFFSET PHLIBAPI NTSTATUS PhGetProcessPebString( - __in HANDLE ProcessHandle, - __in PH_PEB_OFFSET Offset, - __out PPH_STRING *String + _In_ HANDLE ProcessHandle, + _In_ PH_PEB_OFFSET Offset, + _Out_ PPH_STRING *String ); -/** - * Gets a process' command line. - * - * \param ProcessHandle A handle to a process. The handle must - * have PROCESS_QUERY_LIMITED_INFORMATION and PROCESS_VM_READ - * access. - * \param String A variable which receives a pointer to a - * string containing the command line. You must free the string - * using PhDereferenceObject() when you no longer need it. - */ -#define PhGetProcessCommandLine(ProcessHandle, String) \ - PhGetProcessPebString(ProcessHandle, PhpoCommandLine, String) +PHLIBAPI +NTSTATUS PhGetProcessCommandLine( + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *CommandLine + ); PHLIBAPI NTSTATUS PhGetProcessWindowTitle( - __in HANDLE ProcessHandle, - __out PULONG WindowFlags, - __out PPH_STRING *WindowTitle + _In_ HANDLE ProcessHandle, + _Out_ PULONG WindowFlags, + _Out_ PPH_STRING *WindowTitle ); PHLIBAPI NTSTATUS PhGetProcessIsPosix( - __in HANDLE ProcessHandle, - __out PBOOLEAN IsPosix + _In_ HANDLE ProcessHandle, + _Out_ PBOOLEAN IsPosix ); PHLIBAPI NTSTATUS PhGetProcessExecuteFlags( - __in HANDLE ProcessHandle, - __out PULONG ExecuteFlags + _In_ HANDLE ProcessHandle, + _Out_ PULONG ExecuteFlags ); #define PH_PROCESS_DEP_ENABLED 0x1 @@ -208,24 +201,24 @@ NTSTATUS PhGetProcessExecuteFlags( PHLIBAPI NTSTATUS PhGetProcessDepStatus( - __in HANDLE ProcessHandle, - __out PULONG DepStatus + _In_ HANDLE ProcessHandle, + _Out_ PULONG DepStatus ); PHLIBAPI NTSTATUS PhGetProcessPosixCommandLine( - __in HANDLE ProcessHandle, - __out PPH_STRING *CommandLine + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *CommandLine ); #define PH_GET_PROCESS_ENVIRONMENT_WOW64 0x1 // retrieve the WOW64 environment PHLIBAPI NTSTATUS PhGetProcessEnvironment( - __in HANDLE ProcessHandle, - __in ULONG Flags, - __out PVOID *Environment, - __out PULONG EnvironmentLength + _In_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _Out_ PVOID *Environment, + _Out_ PULONG EnvironmentLength ); typedef struct _PH_ENVIRONMENT_VARIABLE @@ -236,23 +229,23 @@ typedef struct _PH_ENVIRONMENT_VARIABLE PHLIBAPI BOOLEAN PhEnumProcessEnvironmentVariables( - __in PVOID Environment, - __in ULONG EnvironmentLength, - __inout PULONG EnumerationKey, - __out PPH_ENVIRONMENT_VARIABLE Variable + _In_ PVOID Environment, + _In_ ULONG EnvironmentLength, + _Inout_ PULONG EnumerationKey, + _Out_ PPH_ENVIRONMENT_VARIABLE Variable ); PHLIBAPI NTSTATUS PhGetProcessMappedFileName( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out PPH_STRING *FileName + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_ PPH_STRING *FileName ); PHLIBAPI NTSTATUS PhGetProcessWorkingSetInformation( - __in HANDLE ProcessHandle, - __out PMEMORY_WORKING_SET_INFORMATION *WorkingSetInformation + _In_ HANDLE ProcessHandle, + _Out_ PMEMORY_WORKING_SET_INFORMATION *WorkingSetInformation ); typedef struct _PH_PROCESS_WS_COUNTERS @@ -265,73 +258,73 @@ typedef struct _PH_PROCESS_WS_COUNTERS PHLIBAPI NTSTATUS PhGetProcessWsCounters( - __in HANDLE ProcessHandle, - __out PPH_PROCESS_WS_COUNTERS WsCounters + _In_ HANDLE ProcessHandle, + _Out_ PPH_PROCESS_WS_COUNTERS WsCounters ); typedef struct _KPH_PROCESS_HANDLE_INFORMATION *PKPH_PROCESS_HANDLE_INFORMATION; PHLIBAPI NTSTATUS PhEnumProcessHandles( - __in HANDLE ProcessHandle, - __out PKPH_PROCESS_HANDLE_INFORMATION *Handles + _In_ HANDLE ProcessHandle, + _Out_ PKPH_PROCESS_HANDLE_INFORMATION *Handles ); PHLIBAPI NTSTATUS PhSetProcessAffinityMask( - __in HANDLE ProcessHandle, - __in ULONG_PTR AffinityMask + _In_ HANDLE ProcessHandle, + _In_ ULONG_PTR AffinityMask ); PHLIBAPI NTSTATUS PhSetProcessIoPriority( - __in HANDLE ProcessHandle, - __in ULONG IoPriority + _In_ HANDLE ProcessHandle, + _In_ ULONG IoPriority ); PHLIBAPI NTSTATUS PhSetProcessExecuteFlags( - __in HANDLE ProcessHandle, - __in ULONG ExecuteFlags + _In_ HANDLE ProcessHandle, + _In_ ULONG ExecuteFlags ); PHLIBAPI NTSTATUS PhSetProcessDepStatus( - __in HANDLE ProcessHandle, - __in ULONG DepStatus + _In_ HANDLE ProcessHandle, + _In_ ULONG DepStatus ); PHLIBAPI NTSTATUS PhSetProcessDepStatusInvasive( - __in HANDLE ProcessHandle, - __in ULONG DepStatus, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE ProcessHandle, + _In_ ULONG DepStatus, + _In_opt_ PLARGE_INTEGER Timeout ); PHLIBAPI NTSTATUS PhInjectDllProcess( - __in HANDLE ProcessHandle, - __in PWSTR FileName, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE ProcessHandle, + _In_ PWSTR FileName, + _In_opt_ PLARGE_INTEGER Timeout ); PHLIBAPI NTSTATUS PhUnloadDllProcess( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_opt_ PLARGE_INTEGER Timeout ); PHLIBAPI NTSTATUS PhSetThreadAffinityMask( - __in HANDLE ThreadHandle, - __in ULONG_PTR AffinityMask + _In_ HANDLE ThreadHandle, + _In_ ULONG_PTR AffinityMask ); PHLIBAPI NTSTATUS PhSetThreadIoPriority( - __in HANDLE ThreadHandle, - __in ULONG IoPriority + _In_ HANDLE ThreadHandle, + _In_ ULONG IoPriority ); /** Contains information about a thread stack frame. */ @@ -362,174 +355,174 @@ typedef struct _PH_THREAD_STACK_FRAME * stop. */ typedef BOOLEAN (NTAPI *PPH_WALK_THREAD_STACK_CALLBACK)( - __in PPH_THREAD_STACK_FRAME StackFrame, - __in_opt PVOID Context + _In_ PPH_THREAD_STACK_FRAME StackFrame, + _In_opt_ PVOID Context ); PHLIBAPI NTSTATUS PhWalkThreadStack( - __in HANDLE ThreadHandle, - __in_opt HANDLE ProcessHandle, - __in_opt PCLIENT_ID ClientId, - __in ULONG Flags, - __in PPH_WALK_THREAD_STACK_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ThreadHandle, + _In_opt_ HANDLE ProcessHandle, + _In_opt_ PCLIENT_ID ClientId, + _In_ ULONG Flags, + _In_ PPH_WALK_THREAD_STACK_CALLBACK Callback, + _In_opt_ PVOID Context ); PHLIBAPI NTSTATUS PhGetJobProcessIdList( - __in HANDLE JobHandle, - __out PJOBOBJECT_BASIC_PROCESS_ID_LIST *ProcessIdList + _In_ HANDLE JobHandle, + _Out_ PJOBOBJECT_BASIC_PROCESS_ID_LIST *ProcessIdList ); NTSTATUS PhQueryTokenVariableSize( - __in HANDLE TokenHandle, - __in TOKEN_INFORMATION_CLASS TokenInformationClass, - __out PVOID *Buffer + _In_ HANDLE TokenHandle, + _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, + _Out_ PVOID *Buffer ); PHLIBAPI NTSTATUS PhGetTokenUser( - __in HANDLE TokenHandle, - __out PTOKEN_USER *User + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_USER *User ); PHLIBAPI NTSTATUS PhGetTokenOwner( - __in HANDLE TokenHandle, - __out PTOKEN_OWNER *Owner + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_OWNER *Owner ); PHLIBAPI NTSTATUS PhGetTokenPrimaryGroup( - __in HANDLE TokenHandle, - __out PTOKEN_PRIMARY_GROUP *PrimaryGroup + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_PRIMARY_GROUP *PrimaryGroup ); PHLIBAPI NTSTATUS PhGetTokenGroups( - __in HANDLE TokenHandle, - __out PTOKEN_GROUPS *Groups + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_GROUPS *Groups ); PHLIBAPI NTSTATUS PhGetTokenPrivileges( - __in HANDLE TokenHandle, - __out PTOKEN_PRIVILEGES *Privileges + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_PRIVILEGES *Privileges ); PHLIBAPI NTSTATUS PhSetTokenSessionId( - __in HANDLE TokenHandle, - __in ULONG SessionId + _In_ HANDLE TokenHandle, + _In_ ULONG SessionId ); PHLIBAPI BOOLEAN PhSetTokenPrivilege( - __in HANDLE TokenHandle, - __in_opt PWSTR PrivilegeName, - __in_opt PLUID PrivilegeLuid, - __in ULONG Attributes + _In_ HANDLE TokenHandle, + _In_opt_ PWSTR PrivilegeName, + _In_opt_ PLUID PrivilegeLuid, + _In_ ULONG Attributes ); PHLIBAPI BOOLEAN PhSetTokenPrivilege2( - __in HANDLE TokenHandle, - __in LONG Privilege, - __in ULONG Attributes + _In_ HANDLE TokenHandle, + _In_ LONG Privilege, + _In_ ULONG Attributes ); PHLIBAPI NTSTATUS PhSetTokenIsVirtualizationEnabled( - __in HANDLE TokenHandle, - __in BOOLEAN IsVirtualizationEnabled + _In_ HANDLE TokenHandle, + _In_ BOOLEAN IsVirtualizationEnabled ); PHLIBAPI NTSTATUS PhGetTokenIntegrityLevel( - __in HANDLE TokenHandle, - __out_opt PMANDATORY_LEVEL IntegrityLevel, - __out_opt PWSTR *IntegrityString + _In_ HANDLE TokenHandle, + _Out_opt_ PMANDATORY_LEVEL IntegrityLevel, + _Out_opt_ PWSTR *IntegrityString ); PHLIBAPI NTSTATUS PhGetFileSize( - __in HANDLE FileHandle, - __out PLARGE_INTEGER Size + _In_ HANDLE FileHandle, + _Out_ PLARGE_INTEGER Size ); PHLIBAPI NTSTATUS PhSetFileSize( - __in HANDLE FileHandle, - __in PLARGE_INTEGER Size + _In_ HANDLE FileHandle, + _In_ PLARGE_INTEGER Size ); PHLIBAPI NTSTATUS PhGetTransactionManagerBasicInformation( - __in HANDLE TransactionManagerHandle, - __out PTRANSACTIONMANAGER_BASIC_INFORMATION BasicInformation + _In_ HANDLE TransactionManagerHandle, + _Out_ PTRANSACTIONMANAGER_BASIC_INFORMATION BasicInformation ); PHLIBAPI NTSTATUS PhGetTransactionManagerLogFileName( - __in HANDLE TransactionManagerHandle, - __out PPH_STRING *LogFileName + _In_ HANDLE TransactionManagerHandle, + _Out_ PPH_STRING *LogFileName ); PHLIBAPI NTSTATUS PhGetTransactionBasicInformation( - __in HANDLE TransactionHandle, - __out PTRANSACTION_BASIC_INFORMATION BasicInformation + _In_ HANDLE TransactionHandle, + _Out_ PTRANSACTION_BASIC_INFORMATION BasicInformation ); PHLIBAPI NTSTATUS PhGetTransactionPropertiesInformation( - __in HANDLE TransactionHandle, - __out_opt PLARGE_INTEGER Timeout, - __out_opt TRANSACTION_OUTCOME *Outcome, - __out_opt PPH_STRING *Description + _In_ HANDLE TransactionHandle, + _Out_opt_ PLARGE_INTEGER Timeout, + _Out_opt_ TRANSACTION_OUTCOME *Outcome, + _Out_opt_ PPH_STRING *Description ); PHLIBAPI NTSTATUS PhGetResourceManagerBasicInformation( - __in HANDLE ResourceManagerHandle, - __out_opt PGUID Guid, - __out_opt PPH_STRING *Description + _In_ HANDLE ResourceManagerHandle, + _Out_opt_ PGUID Guid, + _Out_opt_ PPH_STRING *Description ); PHLIBAPI NTSTATUS PhGetEnlistmentBasicInformation( - __in HANDLE EnlistmentHandle, - __out PENLISTMENT_BASIC_INFORMATION BasicInformation + _In_ HANDLE EnlistmentHandle, + _Out_ PENLISTMENT_BASIC_INFORMATION BasicInformation ); PHLIBAPI NTSTATUS PhOpenDriverByBaseAddress( - __out PHANDLE DriverHandle, - __in PVOID BaseAddress + _Out_ PHANDLE DriverHandle, + _In_ PVOID BaseAddress ); PHLIBAPI NTSTATUS PhGetDriverServiceKeyName( - __in HANDLE DriverHandle, - __out PPH_STRING *ServiceKeyName + _In_ HANDLE DriverHandle, + _Out_ PPH_STRING *ServiceKeyName ); PHLIBAPI NTSTATUS PhUnloadDriver( - __in_opt PVOID BaseAddress, - __in_opt PWSTR Name + _In_opt_ PVOID BaseAddress, + _In_opt_ PWSTR Name ); PHLIBAPI NTSTATUS PhDuplicateObject( - __in HANDLE SourceProcessHandle, - __in HANDLE SourceHandle, - __in_opt HANDLE TargetProcessHandle, - __out_opt PHANDLE TargetHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Options + _In_ HANDLE SourceProcessHandle, + _In_ HANDLE SourceHandle, + _In_opt_ HANDLE TargetProcessHandle, + _Out_opt_ PHANDLE TargetHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Options ); #define PH_ENUM_PROCESS_MODULES_LIMIT 0x800 @@ -547,8 +540,8 @@ NTSTATUS PhDuplicateObject( * stop. */ typedef BOOLEAN (NTAPI *PPH_ENUM_PROCESS_MODULES_CALLBACK)( - __in PLDR_DATA_TABLE_ENTRY Module, - __in_opt PVOID Context + _In_ PLDR_DATA_TABLE_ENTRY Module, + _In_opt_ PVOID Context ); #define PH_ENUM_PROCESS_MODULES_DONT_RESOLVE_WOW64_FS 0x1 @@ -563,61 +556,61 @@ typedef struct _PH_ENUM_PROCESS_MODULES_PARAMETERS PHLIBAPI NTSTATUS PhEnumProcessModules( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context ); PHLIBAPI NTSTATUS PhEnumProcessModulesEx( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters ); PHLIBAPI NTSTATUS PhSetProcessModuleLoadCount( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in ULONG LoadCount + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ ULONG LoadCount ); PHLIBAPI NTSTATUS PhEnumProcessModules32( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context ); PHLIBAPI NTSTATUS PhEnumProcessModules32Ex( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters ); PHLIBAPI NTSTATUS PhSetProcessModuleLoadCount32( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in ULONG LoadCount + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ ULONG LoadCount ); PHLIBAPI NTSTATUS PhGetProcedureAddressRemote( - __in HANDLE ProcessHandle, - __in PWSTR FileName, - __in_opt PSTR ProcedureName, - __in_opt ULONG ProcedureNumber, - __out PVOID *ProcedureAddress, - __out_opt PVOID *DllBase + _In_ HANDLE ProcessHandle, + _In_ PWSTR FileName, + _In_opt_ PSTR ProcedureName, + _In_opt_ ULONG ProcedureNumber, + _Out_ PVOID *ProcedureAddress, + _Out_opt_ PVOID *DllBase ); PHLIBAPI NTSTATUS PhEnumKernelModules( - __out PRTL_PROCESS_MODULES *Modules + _Out_ PRTL_PROCESS_MODULES *Modules ); NTSTATUS PhEnumKernelModulesEx( - __out PRTL_PROCESS_MODULE_INFORMATION_EX *Modules + _Out_ PRTL_PROCESS_MODULE_INFORMATION_EX *Modules ); PHLIBAPI @@ -653,40 +646,41 @@ PPH_STRING PhGetKernelFileName( PHLIBAPI NTSTATUS PhEnumProcesses( - __out PVOID *Processes + _Out_ PVOID *Processes ); PHLIBAPI -NTSTATUS PhEnumProcessesForSession( - __out PVOID *Processes, - __in ULONG SessionId +NTSTATUS PhEnumProcessesEx( + _Out_ PVOID *Processes, + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass ); PHLIBAPI -NTSTATUS PhEnumProcessesEx( - __out PVOID *Processes +NTSTATUS PhEnumProcessesForSession( + _Out_ PVOID *Processes, + _In_ ULONG SessionId ); PHLIBAPI PSYSTEM_PROCESS_INFORMATION PhFindProcessInformation( - __in PVOID Processes, - __in HANDLE ProcessId + _In_ PVOID Processes, + _In_ HANDLE ProcessId ); PHLIBAPI PSYSTEM_PROCESS_INFORMATION PhFindProcessInformationByImageName( - __in PVOID Processes, - __in PPH_STRINGREF ImageName + _In_ PVOID Processes, + _In_ PPH_STRINGREF ImageName ); PHLIBAPI NTSTATUS PhEnumHandles( - __out PSYSTEM_HANDLE_INFORMATION *Handles + _Out_ PSYSTEM_HANDLE_INFORMATION *Handles ); PHLIBAPI NTSTATUS PhEnumHandlesEx( - __out PSYSTEM_HANDLE_INFORMATION_EX *Handles + _Out_ PSYSTEM_HANDLE_INFORMATION_EX *Handles ); #define PH_FIRST_PAGEFILE(Pagefiles) ( \ @@ -705,19 +699,19 @@ NTSTATUS PhEnumHandlesEx( PHLIBAPI NTSTATUS PhEnumPagefiles( - __out PVOID *Pagefiles + _Out_ PVOID *Pagefiles ); PHLIBAPI NTSTATUS PhGetProcessImageFileNameByProcessId( - __in HANDLE ProcessId, - __out PPH_STRING *FileName + _In_ HANDLE ProcessId, + _Out_ PPH_STRING *FileName ); PHLIBAPI NTSTATUS PhGetProcessIsDotNet( - __in HANDLE ProcessId, - __out PBOOLEAN IsDotNet + _In_ HANDLE ProcessId, + _Out_ PBOOLEAN IsDotNet ); #define PH_CLR_USE_SECTION_CHECK 0x1 @@ -734,11 +728,11 @@ NTSTATUS PhGetProcessIsDotNet( PHLIBAPI NTSTATUS PhGetProcessIsDotNetEx( - __in HANDLE ProcessId, - __in_opt HANDLE ProcessHandle, - __in ULONG InFlags, - __out_opt PBOOLEAN IsDotNet, - __out_opt PULONG Flags + _In_ HANDLE ProcessId, + _In_opt_ HANDLE ProcessHandle, + _In_ ULONG InFlags, + _Out_opt_ PBOOLEAN IsDotNet, + _Out_opt_ PULONG Flags ); /** @@ -754,29 +748,29 @@ NTSTATUS PhGetProcessIsDotNetEx( * stop. */ typedef BOOLEAN (NTAPI *PPH_ENUM_DIRECTORY_OBJECTS)( - __in PPH_STRING Name, - __in PPH_STRING TypeName, - __in_opt PVOID Context + _In_ PPH_STRING Name, + _In_ PPH_STRING TypeName, + _In_opt_ PVOID Context ); PHLIBAPI NTSTATUS PhEnumDirectoryObjects( - __in HANDLE DirectoryHandle, - __in PPH_ENUM_DIRECTORY_OBJECTS Callback, - __in_opt PVOID Context + _In_ HANDLE DirectoryHandle, + _In_ PPH_ENUM_DIRECTORY_OBJECTS Callback, + _In_opt_ PVOID Context ); typedef BOOLEAN (NTAPI *PPH_ENUM_DIRECTORY_FILE)( - __in PFILE_DIRECTORY_INFORMATION Information, - __in_opt PVOID Context + _In_ PFILE_DIRECTORY_INFORMATION Information, + _In_opt_ PVOID Context ); PHLIBAPI NTSTATUS PhEnumDirectoryFile( - __in HANDLE FileHandle, - __in_opt PUNICODE_STRING SearchPattern, - __in PPH_ENUM_DIRECTORY_FILE Callback, - __in_opt PVOID Context + _In_ HANDLE FileHandle, + _In_opt_ PUNICODE_STRING SearchPattern, + _In_ PPH_ENUM_DIRECTORY_FILE Callback, + _In_opt_ PVOID Context ); #define PH_FIRST_STREAM(Streams) ((PFILE_STREAM_INFORMATION)(Streams)) @@ -789,8 +783,8 @@ NTSTATUS PhEnumDirectoryFile( PHLIBAPI NTSTATUS PhEnumFileStreams( - __in HANDLE FileHandle, - __out PVOID *Streams + _In_ HANDLE FileHandle, + _Out_ PVOID *Streams ); VOID PhInitializeDevicePrefixes( @@ -809,12 +803,12 @@ VOID PhUpdateDosDevicePrefixes( PHLIBAPI PPH_STRING PhResolveDevicePrefix( - __in PPH_STRING Name + _In_ PPH_STRING Name ); PHLIBAPI PPH_STRING PhGetFileName( - __in PPH_STRING FileName + _In_ PPH_STRING FileName ); #define PH_MODULE_TYPE_MODULE 1 @@ -850,8 +844,8 @@ typedef struct _PH_MODULE_INFO * stop. */ typedef BOOLEAN (NTAPI *PPH_ENUM_GENERIC_MODULES_CALLBACK)( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ); #define PH_ENUM_GENERIC_MAPPED_FILES 0x1 @@ -859,11 +853,11 @@ typedef BOOLEAN (NTAPI *PPH_ENUM_GENERIC_MODULES_CALLBACK)( PHLIBAPI NTSTATUS PhEnumGenericModules( - __in HANDLE ProcessId, - __in_opt HANDLE ProcessHandle, - __in ULONG Flags, - __in PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ProcessId, + _In_opt_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _In_ PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context ); #define PH_KEY_PREDEFINE(Number) ((HANDLE)(LONG_PTR)(-3 - (Number) * 2)) @@ -879,31 +873,31 @@ NTSTATUS PhEnumGenericModules( PHLIBAPI NTSTATUS PhCreateKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt HANDLE RootDirectory, - __in PPH_STRINGREF ObjectName, - __in ULONG Attributes, - __in ULONG CreateOptions, - __out_opt PULONG Disposition + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ HANDLE RootDirectory, + _In_ PPH_STRINGREF ObjectName, + _In_ ULONG Attributes, + _In_ ULONG CreateOptions, + _Out_opt_ PULONG Disposition ); PHLIBAPI NTSTATUS PhOpenKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt HANDLE RootDirectory, - __in PPH_STRINGREF ObjectName, - __in ULONG Attributes + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ HANDLE RootDirectory, + _In_ PPH_STRINGREF ObjectName, + _In_ ULONG Attributes ); // lsa PHLIBAPI NTSTATUS PhOpenLsaPolicy( - __out PLSA_HANDLE PolicyHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt PUNICODE_STRING SystemName + _Out_ PLSA_HANDLE PolicyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PUNICODE_STRING SystemName ); LSA_HANDLE PhGetLookupPolicyHandle( @@ -912,48 +906,48 @@ LSA_HANDLE PhGetLookupPolicyHandle( PHLIBAPI BOOLEAN PhLookupPrivilegeName( - __in PLUID PrivilegeValue, - __out PPH_STRING *PrivilegeName + _In_ PLUID PrivilegeValue, + _Out_ PPH_STRING *PrivilegeName ); PHLIBAPI BOOLEAN PhLookupPrivilegeDisplayName( - __in PPH_STRINGREF PrivilegeName, - __out PPH_STRING *PrivilegeDisplayName + _In_ PPH_STRINGREF PrivilegeName, + _Out_ PPH_STRING *PrivilegeDisplayName ); PHLIBAPI BOOLEAN PhLookupPrivilegeValue( - __in PPH_STRINGREF PrivilegeName, - __out PLUID PrivilegeValue + _In_ PPH_STRINGREF PrivilegeName, + _Out_ PLUID PrivilegeValue ); PHLIBAPI NTSTATUS PhLookupSid( - __in PSID Sid, - __out_opt PPH_STRING *Name, - __out_opt PPH_STRING *DomainName, - __out_opt PSID_NAME_USE NameUse + _In_ PSID Sid, + _Out_opt_ PPH_STRING *Name, + _Out_opt_ PPH_STRING *DomainName, + _Out_opt_ PSID_NAME_USE NameUse ); PHLIBAPI NTSTATUS PhLookupName( - __in PPH_STRINGREF Name, - __out_opt PSID *Sid, - __out_opt PPH_STRING *DomainName, - __out_opt PSID_NAME_USE NameUse + _In_ PPH_STRINGREF Name, + _Out_opt_ PSID *Sid, + _Out_opt_ PPH_STRING *DomainName, + _Out_opt_ PSID_NAME_USE NameUse ); PHLIBAPI PPH_STRING PhGetSidFullName( - __in PSID Sid, - __in BOOLEAN IncludeDomain, - __out_opt PSID_NAME_USE NameUse + _In_ PSID Sid, + _In_ BOOLEAN IncludeDomain, + _Out_opt_ PSID_NAME_USE NameUse ); PHLIBAPI PPH_STRING PhSidToStringSid( - __in PSID Sid + _In_ PSID Sid ); // hndlinfo @@ -965,67 +959,67 @@ VOID PhHandleInfoInitialization( ); typedef PPH_STRING (NTAPI *PPH_GET_CLIENT_ID_NAME)( - __in PCLIENT_ID ClientId + _In_ PCLIENT_ID ClientId ); PPH_GET_CLIENT_ID_NAME PhSetHandleClientIdFunction( - __in PPH_GET_CLIENT_ID_NAME GetClientIdName + _In_ PPH_GET_CLIENT_ID_NAME GetClientIdName ); PHLIBAPI PPH_STRING PhFormatNativeKeyName( - __in PPH_STRING Name + _In_ PPH_STRING Name ); PHLIBAPI -__callback PPH_STRING PhStdGetClientIdName( - __in PCLIENT_ID ClientId +_Callback_ PPH_STRING PhStdGetClientIdName( + _In_ PCLIENT_ID ClientId ); PHLIBAPI NTSTATUS PhGetHandleInformation( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in ULONG ObjectTypeNumber, - __out_opt POBJECT_BASIC_INFORMATION BasicInformation, - __out_opt PPH_STRING *TypeName, - __out_opt PPH_STRING *ObjectName, - __out_opt PPH_STRING *BestObjectName + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ ULONG ObjectTypeNumber, + _Out_opt_ POBJECT_BASIC_INFORMATION BasicInformation, + _Out_opt_ PPH_STRING *TypeName, + _Out_opt_ PPH_STRING *ObjectName, + _Out_opt_ PPH_STRING *BestObjectName ); PHLIBAPI NTSTATUS PhGetHandleInformationEx( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in ULONG ObjectTypeNumber, - __reserved ULONG Flags, - __out_opt PNTSTATUS SubStatus, - __out_opt POBJECT_BASIC_INFORMATION BasicInformation, - __out_opt PPH_STRING *TypeName, - __out_opt PPH_STRING *ObjectName, - __out_opt PPH_STRING *BestObjectName, - __reserved PVOID *ExtraInformation + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ ULONG ObjectTypeNumber, + _Reserved_ ULONG Flags, + _Out_opt_ PNTSTATUS SubStatus, + _Out_opt_ POBJECT_BASIC_INFORMATION BasicInformation, + _Out_opt_ PPH_STRING *TypeName, + _Out_opt_ PPH_STRING *ObjectName, + _Out_opt_ PPH_STRING *BestObjectName, + _Reserved_ PVOID *ExtraInformation ); NTSTATUS PhQueryObjectNameHack( - __in HANDLE Handle, - __out_bcount(ObjectNameInformationLength) POBJECT_NAME_INFORMATION ObjectNameInformation, - __in ULONG ObjectNameInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE Handle, + _Out_writes_bytes_(ObjectNameInformationLength) POBJECT_NAME_INFORMATION ObjectNameInformation, + _In_ ULONG ObjectNameInformationLength, + _Out_opt_ PULONG ReturnLength ); NTSTATUS PhQueryObjectSecurityHack( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG ReturnLength + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength ); NTSTATUS PhSetObjectSecurityHack( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __in PVOID Buffer + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PVOID Buffer ); // mapimg @@ -1043,71 +1037,71 @@ typedef struct _PH_MAPPED_IMAGE PHLIBAPI NTSTATUS PhInitializeMappedImage( - __out PPH_MAPPED_IMAGE MappedImage, - __in PVOID ViewBase, - __in SIZE_T Size + _Out_ PPH_MAPPED_IMAGE MappedImage, + _In_ PVOID ViewBase, + _In_ SIZE_T Size ); PHLIBAPI NTSTATUS PhLoadMappedImage( - __in_opt PWSTR FileName, - __in_opt HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __out PPH_MAPPED_IMAGE MappedImage + _In_opt_ PWSTR FileName, + _In_opt_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _Out_ PPH_MAPPED_IMAGE MappedImage ); PHLIBAPI NTSTATUS PhUnloadMappedImage( - __inout PPH_MAPPED_IMAGE MappedImage + _Inout_ PPH_MAPPED_IMAGE MappedImage ); PHLIBAPI NTSTATUS PhMapViewOfEntireFile( - __in_opt PWSTR FileName, - __in_opt HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __out PVOID *ViewBase, - __out PSIZE_T Size + _In_opt_ PWSTR FileName, + _In_opt_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _Out_ PVOID *ViewBase, + _Out_ PSIZE_T Size ); PHLIBAPI PIMAGE_SECTION_HEADER PhMappedImageRvaToSection( - __in PPH_MAPPED_IMAGE MappedImage, - __in ULONG Rva + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ ULONG Rva ); PHLIBAPI PVOID PhMappedImageRvaToVa( - __in PPH_MAPPED_IMAGE MappedImage, - __in ULONG Rva, - __out_opt PIMAGE_SECTION_HEADER *Section + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ ULONG Rva, + _Out_opt_ PIMAGE_SECTION_HEADER *Section ); PHLIBAPI BOOLEAN PhGetMappedImageSectionName( - __in PIMAGE_SECTION_HEADER Section, - __out_ecount_z_opt(Count) PSTR Buffer, - __in ULONG Count, - __out_opt PULONG ReturnCount + _In_ PIMAGE_SECTION_HEADER Section, + _Out_writes_opt_z_(Count) PSTR Buffer, + _In_ ULONG Count, + _Out_opt_ PULONG ReturnCount ); PHLIBAPI NTSTATUS PhGetMappedImageDataEntry( - __in PPH_MAPPED_IMAGE MappedImage, - __in ULONG Index, - __out PIMAGE_DATA_DIRECTORY *Entry + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ ULONG Index, + _Out_ PIMAGE_DATA_DIRECTORY *Entry ); PHLIBAPI NTSTATUS PhGetMappedImageLoadConfig32( - __in PPH_MAPPED_IMAGE MappedImage, - __out PIMAGE_LOAD_CONFIG_DIRECTORY32 *LoadConfig + _In_ PPH_MAPPED_IMAGE MappedImage, + _Out_ PIMAGE_LOAD_CONFIG_DIRECTORY32 *LoadConfig ); PHLIBAPI NTSTATUS PhGetMappedImageLoadConfig64( - __in PPH_MAPPED_IMAGE MappedImage, - __out PIMAGE_LOAD_CONFIG_DIRECTORY64 *LoadConfig + _In_ PPH_MAPPED_IMAGE MappedImage, + _Out_ PIMAGE_LOAD_CONFIG_DIRECTORY64 *LoadConfig ); typedef struct _PH_REMOTE_MAPPED_IMAGE @@ -1121,13 +1115,13 @@ typedef struct _PH_REMOTE_MAPPED_IMAGE } PH_REMOTE_MAPPED_IMAGE, *PPH_REMOTE_MAPPED_IMAGE; NTSTATUS PhLoadRemoteMappedImage( - __in HANDLE ProcessHandle, - __in PVOID ViewBase, - __out PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage + _In_ HANDLE ProcessHandle, + _In_ PVOID ViewBase, + _Out_ PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage ); NTSTATUS PhUnloadRemoteMappedImage( - __inout PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage + _Inout_ PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage ); typedef struct _PH_MAPPED_IMAGE_EXPORTS @@ -1156,32 +1150,32 @@ typedef struct _PH_MAPPED_IMAGE_EXPORT_FUNCTION PHLIBAPI NTSTATUS PhGetMappedImageExports( - __out PPH_MAPPED_IMAGE_EXPORTS Exports, - __in PPH_MAPPED_IMAGE MappedImage + _Out_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_ PPH_MAPPED_IMAGE MappedImage ); PHLIBAPI NTSTATUS PhGetMappedImageExportEntry( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in ULONG Index, - __out PPH_MAPPED_IMAGE_EXPORT_ENTRY Entry + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_ ULONG Index, + _Out_ PPH_MAPPED_IMAGE_EXPORT_ENTRY Entry ); PHLIBAPI NTSTATUS PhGetMappedImageExportFunction( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in_opt PSTR Name, - __in_opt USHORT Ordinal, - __out PPH_MAPPED_IMAGE_EXPORT_FUNCTION Function + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_opt_ PSTR Name, + _In_opt_ USHORT Ordinal, + _Out_ PPH_MAPPED_IMAGE_EXPORT_FUNCTION Function ); PHLIBAPI NTSTATUS PhGetMappedImageExportFunctionRemote( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in_opt PSTR Name, - __in_opt USHORT Ordinal, - __in PVOID RemoteBase, - __out PVOID *Function + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_opt_ PSTR Name, + _In_opt_ USHORT Ordinal, + _In_ PVOID RemoteBase, + _Out_ PVOID *Function ); #define PH_MAPPED_IMAGE_DELAY_IMPORTS 0x1 @@ -1226,33 +1220,33 @@ typedef struct _PH_MAPPED_IMAGE_IMPORT_ENTRY PHLIBAPI NTSTATUS PhGetMappedImageImports( - __out PPH_MAPPED_IMAGE_IMPORTS Imports, - __in PPH_MAPPED_IMAGE MappedImage + _Out_ PPH_MAPPED_IMAGE_IMPORTS Imports, + _In_ PPH_MAPPED_IMAGE MappedImage ); PHLIBAPI NTSTATUS PhGetMappedImageImportDll( - __in PPH_MAPPED_IMAGE_IMPORTS Imports, - __in ULONG Index, - __out PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll + _In_ PPH_MAPPED_IMAGE_IMPORTS Imports, + _In_ ULONG Index, + _Out_ PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll ); PHLIBAPI NTSTATUS PhGetMappedImageImportEntry( - __in PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll, - __in ULONG Index, - __out PPH_MAPPED_IMAGE_IMPORT_ENTRY Entry + _In_ PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll, + _In_ ULONG Index, + _Out_ PPH_MAPPED_IMAGE_IMPORT_ENTRY Entry ); PHLIBAPI NTSTATUS PhGetMappedImageDelayImports( - __out PPH_MAPPED_IMAGE_IMPORTS Imports, - __in PPH_MAPPED_IMAGE MappedImage + _Out_ PPH_MAPPED_IMAGE_IMPORTS Imports, + _In_ PPH_MAPPED_IMAGE MappedImage ); PHLIBAPI ULONG PhCheckSumMappedImage( - __in PPH_MAPPED_IMAGE MappedImage + _In_ PPH_MAPPED_IMAGE MappedImage ); // maplib @@ -1309,39 +1303,39 @@ typedef struct _PH_MAPPED_ARCHIVE_IMPORT_ENTRY PHLIBAPI NTSTATUS PhInitializeMappedArchive( - __out PPH_MAPPED_ARCHIVE MappedArchive, - __in PVOID ViewBase, - __in SIZE_T Size + _Out_ PPH_MAPPED_ARCHIVE MappedArchive, + _In_ PVOID ViewBase, + _In_ SIZE_T Size ); PHLIBAPI NTSTATUS PhLoadMappedArchive( - __in_opt PWSTR FileName, - __in_opt HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __out PPH_MAPPED_ARCHIVE MappedArchive + _In_opt_ PWSTR FileName, + _In_opt_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _Out_ PPH_MAPPED_ARCHIVE MappedArchive ); PHLIBAPI NTSTATUS PhUnloadMappedArchive( - __inout PPH_MAPPED_ARCHIVE MappedArchive + _Inout_ PPH_MAPPED_ARCHIVE MappedArchive ); PHLIBAPI NTSTATUS PhGetNextMappedArchiveMember( - __in PPH_MAPPED_ARCHIVE_MEMBER Member, - __out PPH_MAPPED_ARCHIVE_MEMBER NextMember + _In_ PPH_MAPPED_ARCHIVE_MEMBER Member, + _Out_ PPH_MAPPED_ARCHIVE_MEMBER NextMember ); PHLIBAPI BOOLEAN PhIsMappedArchiveMemberShortFormat( - __in PPH_MAPPED_ARCHIVE_MEMBER Member + _In_ PPH_MAPPED_ARCHIVE_MEMBER Member ); PHLIBAPI NTSTATUS PhGetMappedArchiveImportEntry( - __in PPH_MAPPED_ARCHIVE_MEMBER Member, - __out PPH_MAPPED_ARCHIVE_IMPORT_ENTRY Entry + _In_ PPH_MAPPED_ARCHIVE_MEMBER Member, + _Out_ PPH_MAPPED_ARCHIVE_IMPORT_ENTRY Entry ); // iosup @@ -1354,86 +1348,86 @@ BOOLEAN PhIoSupportInitialization( PHLIBAPI NTSTATUS PhCreateFileWin32( - __out PHANDLE FileHandle, - __in PWSTR FileName, - __in ACCESS_MASK DesiredAccess, - __in_opt ULONG FileAttributes, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions + _Out_ PHANDLE FileHandle, + _In_ PWSTR FileName, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ ULONG FileAttributes, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions ); PHLIBAPI NTSTATUS PhCreateFileWin32Ex( - __out PHANDLE FileHandle, - __in PWSTR FileName, - __in ACCESS_MASK DesiredAccess, - __in_opt ULONG FileAttributes, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions, - __out_opt PULONG CreateStatus + _Out_ PHANDLE FileHandle, + _In_ PWSTR FileName, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ ULONG FileAttributes, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions, + _Out_opt_ PULONG CreateStatus ); PHLIBAPI NTSTATUS PhQueryFullAttributesFileWin32( - __in PWSTR FileName, - __out PFILE_NETWORK_OPEN_INFORMATION FileInformation + _In_ PWSTR FileName, + _Out_ PFILE_NETWORK_OPEN_INFORMATION FileInformation ); PHLIBAPI NTSTATUS PhDeleteFileWin32( - __in PWSTR FileName + _In_ PWSTR FileName ); PHLIBAPI NTSTATUS PhListenNamedPipe( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ); PHLIBAPI NTSTATUS PhDisconnectNamedPipe( - __in HANDLE FileHandle + _In_ HANDLE FileHandle ); PHLIBAPI NTSTATUS PhPeekNamedPipe( - __in HANDLE FileHandle, - __out_bcount_opt(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG NumberOfBytesRead, - __out_opt PULONG NumberOfBytesAvailable, - __out_opt PULONG NumberOfBytesLeftInMessage + _In_ HANDLE FileHandle, + _Out_writes_bytes_opt_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG NumberOfBytesRead, + _Out_opt_ PULONG NumberOfBytesAvailable, + _Out_opt_ PULONG NumberOfBytesLeftInMessage ); PHLIBAPI NTSTATUS PhTransceiveNamedPipe( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ); PHLIBAPI NTSTATUS PhWaitForNamedPipe( - __in_opt PUNICODE_STRING FileSystemName, - __in PUNICODE_STRING Name, - __in_opt PLARGE_INTEGER Timeout, - __in BOOLEAN UseDefaultTimeout + _In_opt_ PUNICODE_STRING FileSystemName, + _In_ PUNICODE_STRING Name, + _In_opt_ PLARGE_INTEGER Timeout, + _In_ BOOLEAN UseDefaultTimeout ); PHLIBAPI NTSTATUS PhImpersonateClientOfNamedPipe( - __in HANDLE FileHandle + _In_ HANDLE FileHandle ); // Core flags (PhCreateFileStream2) @@ -1482,109 +1476,109 @@ typedef struct _PH_FILE_STREAM PHLIBAPI NTSTATUS PhCreateFileStream( - __out PPH_FILE_STREAM *FileStream, - __in PWSTR FileName, - __in ACCESS_MASK DesiredAccess, - __in ULONG ShareMode, - __in ULONG CreateDisposition, - __in ULONG Flags + _Out_ PPH_FILE_STREAM *FileStream, + _In_ PWSTR FileName, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG ShareMode, + _In_ ULONG CreateDisposition, + _In_ ULONG Flags ); PHLIBAPI NTSTATUS PhCreateFileStream2( - __out PPH_FILE_STREAM *FileStream, - __in HANDLE FileHandle, - __in ULONG Flags, - __in ULONG BufferLength + _Out_ PPH_FILE_STREAM *FileStream, + _In_ HANDLE FileHandle, + _In_ ULONG Flags, + _In_ ULONG BufferLength ); PHLIBAPI VOID PhVerifyFileStream( - __in PPH_FILE_STREAM FileStream + _In_ PPH_FILE_STREAM FileStream ); PHLIBAPI NTSTATUS PhReadFileStream( - __inout PPH_FILE_STREAM FileStream, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG ReadLength + _Inout_ PPH_FILE_STREAM FileStream, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReadLength ); PHLIBAPI NTSTATUS PhWriteFileStream( - __inout PPH_FILE_STREAM FileStream, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ); PHLIBAPI NTSTATUS PhFlushFileStream( - __inout PPH_FILE_STREAM FileStream, - __in BOOLEAN Full + _Inout_ PPH_FILE_STREAM FileStream, + _In_ BOOLEAN Full ); PHLIBAPI VOID PhGetPositionFileStream( - __in PPH_FILE_STREAM FileStream, - __out PLARGE_INTEGER Position + _In_ PPH_FILE_STREAM FileStream, + _Out_ PLARGE_INTEGER Position ); PHLIBAPI NTSTATUS PhSeekFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Offset, - __in PH_SEEK_ORIGIN Origin + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Offset, + _In_ PH_SEEK_ORIGIN Origin ); PHLIBAPI NTSTATUS PhLockFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Position, - __in PLARGE_INTEGER Length, - __in BOOLEAN Wait, - __in BOOLEAN Shared + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Position, + _In_ PLARGE_INTEGER Length, + _In_ BOOLEAN Wait, + _In_ BOOLEAN Shared ); PHLIBAPI NTSTATUS PhUnlockFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Position, - __in PLARGE_INTEGER Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Position, + _In_ PLARGE_INTEGER Length ); #define PH_FILE_STREAM_STRING_BLOCK_SIZE (PAGE_SIZE / 2) PHLIBAPI NTSTATUS PhWriteStringAsAnsiFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PPH_STRINGREF String + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PPH_STRINGREF String ); PHLIBAPI NTSTATUS PhWriteStringAsAnsiFileStream2( - __inout PPH_FILE_STREAM FileStream, - __in PWSTR String + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PWSTR String ); PHLIBAPI NTSTATUS PhWriteStringAsAnsiFileStreamEx( - __inout PPH_FILE_STREAM FileStream, - __in PWSTR Buffer, - __in SIZE_T Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PWSTR Buffer, + _In_ SIZE_T Length ); PHLIBAPI NTSTATUS PhWriteStringFormatFileStream_V( - __inout PPH_FILE_STREAM FileStream, - __in __format_string PWSTR Format, - __in va_list ArgPtr + _Inout_ PPH_FILE_STREAM FileStream, + _In_ _Printf_format_string_ PWSTR Format, + _In_ va_list ArgPtr ); PHLIBAPI NTSTATUS PhWriteStringFormatFileStream( - __inout PPH_FILE_STREAM FileStream, - __in __format_string PWSTR Format, + _Inout_ PPH_FILE_STREAM FileStream, + _In_ _Printf_format_string_ PWSTR Format, ... ); @@ -1604,14 +1598,14 @@ typedef enum _VERIFY_RESULT PHLIBAPI VERIFY_RESULT PhVerifyFile( - __in PWSTR FileName, - __out_opt PPH_STRING *SignerName + _In_ PWSTR FileName, + _Out_opt_ PPH_STRING *SignerName ); // provider #if defined(DEBUG) -extern LIST_ENTRY PhDbgProviderListHead; +extern PPH_LIST PhDbgProviderList; extern PH_QUEUED_LOCK PhDbgProviderListLock; #endif @@ -1623,7 +1617,7 @@ typedef enum _PH_PROVIDER_THREAD_STATE } PH_PROVIDER_THREAD_STATE; typedef VOID (NTAPI *PPH_PROVIDER_FUNCTION)( - __in PVOID Object + _In_ PVOID Object ); struct _PH_PROVIDER_THREAD; @@ -1643,9 +1637,6 @@ typedef struct _PH_PROVIDER_REGISTRATION typedef struct _PH_PROVIDER_THREAD { -#ifdef DEBUG - LIST_ENTRY DbgListEntry; -#endif HANDLE ThreadHandle; HANDLE TimerHandle; ULONG Interval; @@ -1658,64 +1649,64 @@ typedef struct _PH_PROVIDER_THREAD PHLIBAPI VOID PhInitializeProviderThread( - __out PPH_PROVIDER_THREAD ProviderThread, - __in ULONG Interval + _Out_ PPH_PROVIDER_THREAD ProviderThread, + _In_ ULONG Interval ); PHLIBAPI VOID PhDeleteProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread + _Inout_ PPH_PROVIDER_THREAD ProviderThread ); PHLIBAPI VOID PhStartProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread + _Inout_ PPH_PROVIDER_THREAD ProviderThread ); PHLIBAPI VOID PhStopProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread + _Inout_ PPH_PROVIDER_THREAD ProviderThread ); PHLIBAPI VOID PhSetIntervalProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread, - __in ULONG Interval + _Inout_ PPH_PROVIDER_THREAD ProviderThread, + _In_ ULONG Interval ); PHLIBAPI VOID PhRegisterProvider( - __inout PPH_PROVIDER_THREAD ProviderThread, - __in PPH_PROVIDER_FUNCTION Function, - __in_opt PVOID Object, - __out PPH_PROVIDER_REGISTRATION Registration + _Inout_ PPH_PROVIDER_THREAD ProviderThread, + _In_ PPH_PROVIDER_FUNCTION Function, + _In_opt_ PVOID Object, + _Out_ PPH_PROVIDER_REGISTRATION Registration ); PHLIBAPI VOID PhUnregisterProvider( - __inout PPH_PROVIDER_REGISTRATION Registration + _Inout_ PPH_PROVIDER_REGISTRATION Registration ); PHLIBAPI BOOLEAN PhBoostProvider( - __inout PPH_PROVIDER_REGISTRATION Registration, - __out_opt PULONG FutureRunId + _Inout_ PPH_PROVIDER_REGISTRATION Registration, + _Out_opt_ PULONG FutureRunId ); PHLIBAPI ULONG PhGetRunIdProvider( - __in PPH_PROVIDER_REGISTRATION Registration + _In_ PPH_PROVIDER_REGISTRATION Registration ); PHLIBAPI BOOLEAN PhGetEnabledProvider( - __in PPH_PROVIDER_REGISTRATION Registration + _In_ PPH_PROVIDER_REGISTRATION Registration ); PHLIBAPI VOID PhSetEnabledProvider( - __inout PPH_PROVIDER_REGISTRATION Registration, - __in BOOLEAN Enabled + _Inout_ PPH_PROVIDER_REGISTRATION Registration, + _In_ BOOLEAN Enabled ); // symprv @@ -1737,6 +1728,7 @@ typedef struct _PH_SYMBOL_PROVIDER PH_INITONCE InitOnce; #endif PH_AVL_TREE ModulesSet; + PH_CALLBACK EventCallback; } PH_SYMBOL_PROVIDER, *PPH_SYMBOL_PROVIDER; typedef enum _PH_SYMBOL_RESOLVE_LEVEL @@ -1761,6 +1753,26 @@ typedef struct _PH_SYMBOL_LINE_INFORMATION ULONG64 Address; } PH_SYMBOL_LINE_INFORMATION, *PPH_SYMBOL_LINE_INFORMATION; +typedef enum _PH_SYMBOL_EVENT_TYPE +{ + SymbolDeferredSymbolLoadStart = 1, + SymbolDeferredSymbolLoadComplete = 2, + SymbolDeferredSymbolLoadFailure = 3, + SymbolSymbolsUnloaded = 4, + SymbolDeferredSymbolLoadCancel = 7 +} PH_SYMBOL_EVENT_TYPE; + +typedef struct _PH_SYMBOL_EVENT_DATA +{ + PPH_SYMBOL_PROVIDER SymbolProvider; + PH_SYMBOL_EVENT_TYPE Type; + + ULONG64 BaseAddress; + ULONG CheckSum; + ULONG TimeStamp; + PPH_STRING FileName; +} PH_SYMBOL_EVENT_DATA, *PPH_SYMBOL_EVENT_DATA; + BOOLEAN PhSymbolProviderInitialization( VOID ); @@ -1771,60 +1783,60 @@ VOID PhSymbolProviderDynamicImport( PHLIBAPI PPH_SYMBOL_PROVIDER PhCreateSymbolProvider( - __in_opt HANDLE ProcessId + _In_opt_ HANDLE ProcessId ); PHLIBAPI BOOLEAN PhGetLineFromAddress( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in ULONG64 Address, - __out PPH_STRING *FileName, - __out_opt PULONG Displacement, - __out_opt PPH_SYMBOL_LINE_INFORMATION Information + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ ULONG64 Address, + _Out_ PPH_STRING *FileName, + _Out_opt_ PULONG Displacement, + _Out_opt_ PPH_SYMBOL_LINE_INFORMATION Information ); PHLIBAPI ULONG64 PhGetModuleFromAddress( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in ULONG64 Address, - __out_opt PPH_STRING *FileName + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ ULONG64 Address, + _Out_opt_ PPH_STRING *FileName ); PHLIBAPI PPH_STRING PhGetSymbolFromAddress( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in ULONG64 Address, - __out_opt PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel, - __out_opt PPH_STRING *FileName, - __out_opt PPH_STRING *SymbolName, - __out_opt PULONG64 Displacement + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ ULONG64 Address, + _Out_opt_ PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel, + _Out_opt_ PPH_STRING *FileName, + _Out_opt_ PPH_STRING *SymbolName, + _Out_opt_ PULONG64 Displacement ); PHLIBAPI BOOLEAN PhGetSymbolFromName( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in PWSTR Name, - __out PPH_SYMBOL_INFORMATION Information + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ PWSTR Name, + _Out_ PPH_SYMBOL_INFORMATION Information ); PHLIBAPI BOOLEAN PhLoadModuleSymbolProvider( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in PWSTR FileName, - __in ULONG64 BaseAddress, - __in ULONG Size + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ PWSTR FileName, + _In_ ULONG64 BaseAddress, + _In_ ULONG Size ); PHLIBAPI VOID PhSetOptionsSymbolProvider( - __in ULONG Mask, - __in ULONG Value + _In_ ULONG Mask, + _In_ ULONG Value ); PHLIBAPI VOID PhSetSearchPathSymbolProvider( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in PWSTR Path + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ PWSTR Path ); // svcsup @@ -1835,92 +1847,92 @@ extern WCHAR *PhServiceErrorControlStrings[4]; PHLIBAPI PVOID PhEnumServices( - __in SC_HANDLE ScManagerHandle, - __in_opt ULONG Type, - __in_opt ULONG State, - __out PULONG Count + _In_ SC_HANDLE ScManagerHandle, + _In_opt_ ULONG Type, + _In_opt_ ULONG State, + _Out_ PULONG Count ); PHLIBAPI SC_HANDLE PhOpenService( - __in PWSTR ServiceName, - __in ACCESS_MASK DesiredAccess + _In_ PWSTR ServiceName, + _In_ ACCESS_MASK DesiredAccess ); PHLIBAPI PVOID PhGetServiceConfig( - __in SC_HANDLE ServiceHandle + _In_ SC_HANDLE ServiceHandle ); PHLIBAPI PVOID PhQueryServiceVariableSize( - __in SC_HANDLE ServiceHandle, - __in ULONG InfoLevel + _In_ SC_HANDLE ServiceHandle, + _In_ ULONG InfoLevel ); PHLIBAPI PPH_STRING PhGetServiceDescription( - __in SC_HANDLE ServiceHandle + _In_ SC_HANDLE ServiceHandle ); PHLIBAPI BOOLEAN PhGetServiceDelayedAutoStart( - __in SC_HANDLE ServiceHandle, - __out PBOOLEAN DelayedAutoStart + _In_ SC_HANDLE ServiceHandle, + _Out_ PBOOLEAN DelayedAutoStart ); PHLIBAPI BOOLEAN PhSetServiceDelayedAutoStart( - __in SC_HANDLE ServiceHandle, - __in BOOLEAN DelayedAutoStart + _In_ SC_HANDLE ServiceHandle, + _In_ BOOLEAN DelayedAutoStart ); PHLIBAPI PWSTR PhGetServiceStateString( - __in ULONG ServiceState + _In_ ULONG ServiceState ); PHLIBAPI PWSTR PhGetServiceTypeString( - __in ULONG ServiceType + _In_ ULONG ServiceType ); PHLIBAPI ULONG PhGetServiceTypeInteger( - __in PWSTR ServiceType + _In_ PWSTR ServiceType ); PHLIBAPI PWSTR PhGetServiceStartTypeString( - __in ULONG ServiceStartType + _In_ ULONG ServiceStartType ); PHLIBAPI ULONG PhGetServiceStartTypeInteger( - __in PWSTR ServiceStartType + _In_ PWSTR ServiceStartType ); PHLIBAPI PWSTR PhGetServiceErrorControlString( - __in ULONG ServiceErrorControl + _In_ ULONG ServiceErrorControl ); PHLIBAPI ULONG PhGetServiceErrorControlInteger( - __in PWSTR ServiceErrorControl + _In_ PWSTR ServiceErrorControl ); PHLIBAPI PPH_STRING PhGetServiceNameFromTag( - __in HANDLE ProcessId, - __in PVOID ServiceTag + _In_ HANDLE ProcessId, + _In_ PVOID ServiceTag ); PHLIBAPI NTSTATUS PhGetThreadServiceTag( - __in HANDLE ThreadHandle, - __in_opt HANDLE ProcessHandle, - __out PVOID *ServiceTag + _In_ HANDLE ThreadHandle, + _In_opt_ HANDLE ProcessHandle, + _Out_ PVOID *ServiceTag ); // support @@ -1957,7 +1969,7 @@ typedef struct _PH_RECTANGLE } PH_RECTANGLE, *PPH_RECTANGLE; FORCEINLINE PH_RECTANGLE PhRectToRectangle( - __in RECT Rect + _In_ RECT Rect ) { PH_RECTANGLE rectangle; @@ -1971,7 +1983,7 @@ FORCEINLINE PH_RECTANGLE PhRectToRectangle( } FORCEINLINE RECT PhRectangleToRect( - __in PH_RECTANGLE Rectangle + _In_ PH_RECTANGLE Rectangle ) { RECT rect; @@ -1985,8 +1997,8 @@ FORCEINLINE RECT PhRectangleToRect( } FORCEINLINE VOID PhConvertRect( - __inout PRECT Rect, - __in PRECT ParentRect + _Inout_ PRECT Rect, + _In_ PRECT ParentRect ) { Rect->right = ParentRect->right - ParentRect->left - Rect->right; @@ -1994,8 +2006,8 @@ FORCEINLINE VOID PhConvertRect( } FORCEINLINE RECT PhMapRect( - __in RECT InnerRect, - __in RECT OuterRect + _In_ RECT InnerRect, + _In_ RECT OuterRect ) { RECT rect; @@ -2010,31 +2022,31 @@ FORCEINLINE RECT PhMapRect( PHLIBAPI VOID PhAdjustRectangleToBounds( - __inout PPH_RECTANGLE Rectangle, - __in PPH_RECTANGLE Bounds + _Inout_ PPH_RECTANGLE Rectangle, + _In_ PPH_RECTANGLE Bounds ); PHLIBAPI VOID PhCenterRectangle( - __inout PPH_RECTANGLE Rectangle, - __in PPH_RECTANGLE Bounds + _Inout_ PPH_RECTANGLE Rectangle, + _In_ PPH_RECTANGLE Bounds ); PHLIBAPI VOID PhAdjustRectangleToWorkingArea( - __in HWND hWnd, - __inout PPH_RECTANGLE Rectangle + _In_ HWND hWnd, + _Inout_ PPH_RECTANGLE Rectangle ); PHLIBAPI VOID PhCenterWindow( - __in HWND WindowHandle, - __in_opt HWND ParentWindowHandle + _In_ HWND WindowHandle, + _In_opt_ HWND ParentWindowHandle ); FORCEINLINE VOID PhLargeIntegerToSystemTime( - __out PSYSTEMTIME SystemTime, - __in PLARGE_INTEGER LargeInteger + _Out_ PSYSTEMTIME SystemTime, + _In_ PLARGE_INTEGER LargeInteger ) { FILETIME fileTime; @@ -2045,8 +2057,8 @@ FORCEINLINE VOID PhLargeIntegerToSystemTime( } FORCEINLINE VOID PhLargeIntegerToLocalSystemTime( - __out PSYSTEMTIME SystemTime, - __in PLARGE_INTEGER LargeInteger + _Out_ PSYSTEMTIME SystemTime, + _In_ PLARGE_INTEGER LargeInteger ) { FILETIME fileTime; @@ -2059,8 +2071,8 @@ FORCEINLINE VOID PhLargeIntegerToLocalSystemTime( } FORCEINLINE FILETIME PhSubtractFileTime( - __inout FILETIME Value1, - __in FILETIME Value2 + _Inout_ FILETIME Value1, + _In_ FILETIME Value2 ) { ULARGE_INTEGER value1; @@ -2082,95 +2094,100 @@ FORCEINLINE FILETIME PhSubtractFileTime( PHLIBAPI VOID PhReferenceObjects( - __in_ecount(NumberOfObjects) PVOID *Objects, - __in ULONG NumberOfObjects + _In_reads_(NumberOfObjects) PVOID *Objects, + _In_ ULONG NumberOfObjects ); PHLIBAPI VOID PhDereferenceObjects( - __in_ecount(NumberOfObjects) PVOID *Objects, - __in ULONG NumberOfObjects + _In_reads_(NumberOfObjects) PVOID *Objects, + _In_ ULONG NumberOfObjects ); PHLIBAPI PPH_STRING PhGetMessage( - __in PVOID DllHandle, - __in ULONG MessageTableId, - __in ULONG MessageLanguageId, - __in ULONG MessageId + _In_ PVOID DllHandle, + _In_ ULONG MessageTableId, + _In_ ULONG MessageLanguageId, + _In_ ULONG MessageId ); PHLIBAPI PPH_STRING PhGetNtMessage( - __in NTSTATUS Status + _In_ NTSTATUS Status ); PHLIBAPI PPH_STRING PhGetWin32Message( - __in ULONG Result + _In_ ULONG Result ); #define PH_MAX_MESSAGE_SIZE 800 PHLIBAPI INT PhShowMessage( - __in HWND hWnd, - __in ULONG Type, - __in PWSTR Format, + _In_ HWND hWnd, + _In_ ULONG Type, + _In_ PWSTR Format, ... ); PHLIBAPI INT PhShowMessage_V( - __in HWND hWnd, - __in ULONG Type, - __in PWSTR Format, - __in va_list ArgPtr + _In_ HWND hWnd, + _In_ ULONG Type, + _In_ PWSTR Format, + _In_ va_list ArgPtr ); #define PhShowError(hWnd, Format, ...) PhShowMessage(hWnd, MB_OK | MB_ICONERROR, Format, __VA_ARGS__) #define PhShowWarning(hWnd, Format, ...) PhShowMessage(hWnd, MB_OK | MB_ICONWARNING, Format, __VA_ARGS__) #define PhShowInformation(hWnd, Format, ...) PhShowMessage(hWnd, MB_OK | MB_ICONINFORMATION, Format, __VA_ARGS__) +PPH_STRING PhGetStatusMessage( + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result + ); + PHLIBAPI VOID PhShowStatus( - __in HWND hWnd, - __in_opt PWSTR Message, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_opt_ PWSTR Message, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ); PHLIBAPI BOOLEAN PhShowContinueStatus( - __in HWND hWnd, - __in_opt PWSTR Message, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_opt_ PWSTR Message, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ); PHLIBAPI BOOLEAN PhShowConfirmMessage( - __in HWND hWnd, - __in PWSTR Verb, - __in PWSTR Object, - __in_opt PWSTR Message, - __in BOOLEAN Warning + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_ PWSTR Object, + _In_opt_ PWSTR Message, + _In_ BOOLEAN Warning ); PHLIBAPI BOOLEAN PhFindIntegerSiKeyValuePairs( - __in PPH_KEY_VALUE_PAIR KeyValuePairs, - __in ULONG SizeOfKeyValuePairs, - __in PWSTR String, - __out PULONG Integer + _In_ PPH_KEY_VALUE_PAIR KeyValuePairs, + _In_ ULONG SizeOfKeyValuePairs, + _In_ PWSTR String, + _Out_ PULONG Integer ); PHLIBAPI BOOLEAN PhFindStringSiKeyValuePairs( - __in PPH_KEY_VALUE_PAIR KeyValuePairs, - __in ULONG SizeOfKeyValuePairs, - __in ULONG Integer, - __out PWSTR *String + _In_ PPH_KEY_VALUE_PAIR KeyValuePairs, + _In_ ULONG SizeOfKeyValuePairs, + _In_ ULONG Integer, + _Out_ PWSTR *String ); #define GUID_VERSION_MAC 1 @@ -2217,75 +2234,75 @@ typedef union _GUID_EX PHLIBAPI VOID PhGenerateGuid( - __out PGUID Guid + _Out_ PGUID Guid ); PHLIBAPI VOID PhGenerateGuidFromName( - __out PGUID Guid, - __in PGUID Namespace, - __in PCHAR Name, - __in ULONG NameLength, - __in UCHAR Version + _Out_ PGUID Guid, + _In_ PGUID Namespace, + _In_ PCHAR Name, + _In_ ULONG NameLength, + _In_ UCHAR Version ); PHLIBAPI VOID PhGenerateRandomAlphaString( - __out_ecount_z(Count) PWSTR Buffer, - __in ULONG Count + _Out_writes_z_(Count) PWSTR Buffer, + _In_ ULONG Count ); PHLIBAPI PPH_STRING PhEllipsisString( - __in PPH_STRING String, - __in ULONG DesiredCount + _In_ PPH_STRING String, + _In_ ULONG DesiredCount ); PHLIBAPI PPH_STRING PhEllipsisStringPath( - __in PPH_STRING String, - __in ULONG DesiredCount + _In_ PPH_STRING String, + _In_ ULONG DesiredCount ); PHLIBAPI BOOLEAN PhMatchWildcards( - __in PWSTR Pattern, - __in PWSTR String, - __in BOOLEAN IgnoreCase + _In_ PWSTR Pattern, + _In_ PWSTR String, + _In_ BOOLEAN IgnoreCase ); PHLIBAPI PPH_STRING PhEscapeStringForMenuPrefix( - __in PPH_STRINGREF String + _In_ PPH_STRINGREF String ); PHLIBAPI LONG PhCompareUnicodeStringZIgnoreMenuPrefix( - __in PWSTR A, - __in PWSTR B, - __in BOOLEAN IgnoreCase, - __in BOOLEAN MatchIfPrefix + _In_ PWSTR A, + _In_ PWSTR B, + _In_ BOOLEAN IgnoreCase, + _In_ BOOLEAN MatchIfPrefix ); PHLIBAPI PPH_STRING PhFormatDate( - __in_opt PSYSTEMTIME Date, - __in_opt PWSTR Format + _In_opt_ PSYSTEMTIME Date, + _In_opt_ PWSTR Format ); PHLIBAPI PPH_STRING PhFormatTime( - __in_opt PSYSTEMTIME Time, - __in_opt PWSTR Format + _In_opt_ PSYSTEMTIME Time, + _In_opt_ PWSTR Format ); PHLIBAPI PPH_STRING PhFormatDateTime( - __in_opt PSYSTEMTIME DateTime + _In_opt_ PSYSTEMTIME DateTime ); FORCEINLINE PPH_STRING PhaFormatDateTime( - __in_opt PSYSTEMTIME DateTime + _In_opt_ PSYSTEMTIME DateTime ) { return (PPH_STRING)PHA_DEREFERENCE(PhFormatDateTime(DateTime)); @@ -2293,13 +2310,13 @@ FORCEINLINE PPH_STRING PhaFormatDateTime( PHLIBAPI PPH_STRING PhFormatTimeSpanRelative( - __in ULONG64 TimeSpan + _In_ ULONG64 TimeSpan ); PHLIBAPI PPH_STRING PhFormatUInt64( - __in ULONG64 Value, - __in BOOLEAN GroupDigits + _In_ ULONG64 Value, + _In_ BOOLEAN GroupDigits ); #define PhaFormatUInt64(Value, GroupDigits) \ @@ -2307,9 +2324,9 @@ PPH_STRING PhFormatUInt64( PHLIBAPI PPH_STRING PhFormatDecimal( - __in PWSTR Value, - __in ULONG FractionalDigits, - __in BOOLEAN GroupDigits + _In_ PWSTR Value, + _In_ ULONG FractionalDigits, + _In_ BOOLEAN GroupDigits ); #define PhaFormatDecimal(Value, FractionalDigits, GroupDigits) \ @@ -2317,8 +2334,8 @@ PPH_STRING PhFormatDecimal( PHLIBAPI PPH_STRING PhFormatSize( - __in ULONG64 Size, - __in ULONG MaxSizeUnit + _In_ ULONG64 Size, + _In_ ULONG MaxSizeUnit ); #define PhaFormatSize(Size, MaxSizeUnit) \ @@ -2326,30 +2343,30 @@ PPH_STRING PhFormatSize( PHLIBAPI PPH_STRING PhFormatGuid( - __in PGUID Guid + _In_ PGUID Guid ); PHLIBAPI PVOID PhGetFileVersionInfo( - __in PWSTR FileName + _In_ PWSTR FileName ); PHLIBAPI ULONG PhGetFileVersionInfoLangCodePage( - __in PVOID VersionInfo + _In_ PVOID VersionInfo ); PHLIBAPI PPH_STRING PhGetFileVersionInfoString( - __in PVOID VersionInfo, - __in PWSTR SubBlock + _In_ PVOID VersionInfo, + _In_ PWSTR SubBlock ); PHLIBAPI PPH_STRING PhGetFileVersionInfoString2( - __in PVOID VersionInfo, - __in ULONG LangCodePage, - __in PWSTR StringName + _In_ PVOID VersionInfo, + _In_ ULONG LangCodePage, + _In_ PWSTR StringName ); typedef struct _PH_IMAGE_VERSION_INFO @@ -2362,37 +2379,37 @@ typedef struct _PH_IMAGE_VERSION_INFO PHLIBAPI BOOLEAN PhInitializeImageVersionInfo( - __out PPH_IMAGE_VERSION_INFO ImageVersionInfo, - __in PWSTR FileName + _Out_ PPH_IMAGE_VERSION_INFO ImageVersionInfo, + _In_ PWSTR FileName ); PHLIBAPI VOID PhDeleteImageVersionInfo( - __inout PPH_IMAGE_VERSION_INFO ImageVersionInfo + _Inout_ PPH_IMAGE_VERSION_INFO ImageVersionInfo ); PHLIBAPI PPH_STRING PhFormatImageVersionInfo( - __in_opt PPH_STRING FileName, - __in PPH_IMAGE_VERSION_INFO ImageVersionInfo, - __in_opt PWSTR Indent, - __in_opt ULONG LineLimit + _In_opt_ PPH_STRING FileName, + _In_ PPH_IMAGE_VERSION_INFO ImageVersionInfo, + _In_opt_ PWSTR Indent, + _In_opt_ ULONG LineLimit ); PHLIBAPI PPH_STRING PhGetFullPath( - __in PWSTR FileName, - __out_opt PULONG IndexOfFileName + _In_ PWSTR FileName, + _Out_opt_ PULONG IndexOfFileName ); PHLIBAPI PPH_STRING PhExpandEnvironmentStrings( - __in PPH_STRINGREF String + _In_ PPH_STRINGREF String ); PHLIBAPI PPH_STRING PhGetBaseName( - __in PPH_STRING FileName + _In_ PPH_STRING FileName ); PHLIBAPI @@ -2402,20 +2419,20 @@ PPH_STRING PhGetSystemDirectory( PHLIBAPI VOID PhGetSystemRoot( - __out PPH_STRINGREF SystemRoot + _Out_ PPH_STRINGREF SystemRoot ); PHLIBAPI PLDR_DATA_TABLE_ENTRY PhFindLoaderEntry( - __in_opt PVOID DllBase, - __in_opt PPH_STRINGREF FullDllName, - __in_opt PPH_STRINGREF BaseDllName + _In_opt_ PVOID DllBase, + _In_opt_ PPH_STRINGREF FullDllName, + _In_opt_ PPH_STRINGREF BaseDllName ); PHLIBAPI PPH_STRING PhGetDllFileName( - __in PVOID DllHandle, - __out_opt PULONG IndexOfFileName + _In_ PVOID DllHandle, + _Out_opt_ PULONG IndexOfFileName ); PHLIBAPI @@ -2430,16 +2447,16 @@ PPH_STRING PhGetApplicationDirectory( PHLIBAPI PPH_STRING PhGetKnownLocation( - __in ULONG Folder, - __in_opt PWSTR AppendPath + _In_ ULONG Folder, + _In_opt_ PWSTR AppendPath ); PHLIBAPI NTSTATUS PhWaitForMultipleObjectsAndPump( - __in_opt HWND hWnd, - __in ULONG NumberOfHandles, - __in PHANDLE Handles, - __in ULONG Timeout + _In_opt_ HWND hWnd, + _In_ ULONG NumberOfHandles, + _In_ PHANDLE Handles, + _In_ ULONG Timeout ); typedef struct _PH_CREATE_PROCESS_INFO @@ -2459,63 +2476,63 @@ typedef struct _PH_CREATE_PROCESS_INFO PHLIBAPI NTSTATUS PhCreateProcess( - __in PWSTR FileName, - __in_opt PPH_STRINGREF CommandLine, - __in_opt PVOID Environment, - __in_opt PPH_STRINGREF CurrentDirectory, - __in_opt PPH_CREATE_PROCESS_INFO Information, - __in ULONG Flags, - __in_opt HANDLE ParentProcessHandle, - __out_opt PCLIENT_ID ClientId, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_ PWSTR FileName, + _In_opt_ PPH_STRINGREF CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PPH_STRINGREF CurrentDirectory, + _In_opt_ PPH_CREATE_PROCESS_INFO Information, + _In_ ULONG Flags, + _In_opt_ HANDLE ParentProcessHandle, + _Out_opt_ PCLIENT_ID ClientId, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ); PHLIBAPI NTSTATUS PhCreateProcessWin32( - __in_opt PWSTR FileName, - __in_opt PWSTR CommandLine, - __in_opt PVOID Environment, - __in_opt PWSTR CurrentDirectory, - __in ULONG Flags, - __in_opt HANDLE TokenHandle, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_opt_ PWSTR FileName, + _In_opt_ PWSTR CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PWSTR CurrentDirectory, + _In_ ULONG Flags, + _In_opt_ HANDLE TokenHandle, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ); PHLIBAPI NTSTATUS PhCreateProcessWin32Ex( - __in_opt PWSTR FileName, - __in_opt PWSTR CommandLine, - __in_opt PVOID Environment, - __in_opt PWSTR CurrentDirectory, - __in_opt STARTUPINFO *StartupInfo, - __in ULONG Flags, - __in_opt HANDLE TokenHandle, - __out_opt PCLIENT_ID ClientId, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_opt_ PWSTR FileName, + _In_opt_ PWSTR CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PWSTR CurrentDirectory, + _In_opt_ STARTUPINFO *StartupInfo, + _In_ ULONG Flags, + _In_opt_ HANDLE TokenHandle, + _Out_opt_ PCLIENT_ID ClientId, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ); typedef struct _PH_CREATE_PROCESS_AS_USER_INFO { - __in_opt PWSTR ApplicationName; - __in_opt PWSTR CommandLine; - __in_opt PWSTR CurrentDirectory; - __in_opt PVOID Environment; - __in_opt PWSTR DesktopName; - __in_opt ULONG SessionId; // use PH_CREATE_PROCESS_SET_SESSION_ID + _In_opt_ PWSTR ApplicationName; + _In_opt_ PWSTR CommandLine; + _In_opt_ PWSTR CurrentDirectory; + _In_opt_ PVOID Environment; + _In_opt_ PWSTR DesktopName; + _In_opt_ ULONG SessionId; // use PH_CREATE_PROCESS_SET_SESSION_ID union { struct { - __in PWSTR DomainName; - __in PWSTR UserName; - __in PWSTR Password; - __in_opt ULONG LogonType; + _In_ PWSTR DomainName; + _In_ PWSTR UserName; + _In_ PWSTR Password; + _In_opt_ ULONG LogonType; }; - __in HANDLE ProcessIdWithToken; // use PH_CREATE_PROCESS_USE_PROCESS_TOKEN - __in ULONG SessionIdWithToken; // use PH_CREATE_PROCESS_USE_SESSION_TOKEN + _In_ HANDLE ProcessIdWithToken; // use PH_CREATE_PROCESS_USE_PROCESS_TOKEN + _In_ ULONG SessionIdWithToken; // use PH_CREATE_PROCESS_USE_SESSION_TOKEN }; } PH_CREATE_PROCESS_AS_USER_INFO, *PPH_CREATE_PROCESS_AS_USER_INFO; @@ -2527,23 +2544,23 @@ typedef struct _PH_CREATE_PROCESS_AS_USER_INFO PHLIBAPI NTSTATUS PhCreateProcessAsUser( - __in PPH_CREATE_PROCESS_AS_USER_INFO Information, - __in ULONG Flags, - __out_opt PCLIENT_ID ClientId, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_ PPH_CREATE_PROCESS_AS_USER_INFO Information, + _In_ ULONG Flags, + _Out_opt_ PCLIENT_ID ClientId, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ); NTSTATUS PhFilterTokenForLimitedUser( - __in HANDLE TokenHandle, - __out PHANDLE NewTokenHandle + _In_ HANDLE TokenHandle, + _Out_ PHANDLE NewTokenHandle ); PHLIBAPI VOID PhShellExecute( - __in HWND hWnd, - __in PWSTR FileName, - __in_opt PWSTR Parameters + _In_ HWND hWnd, + _In_ PWSTR FileName, + _In_opt_ PWSTR Parameters ); #define PH_SHELL_EXECUTE_ADMIN 0x1 @@ -2551,42 +2568,47 @@ VOID PhShellExecute( PHLIBAPI BOOLEAN PhShellExecuteEx( - __in HWND hWnd, - __in PWSTR FileName, - __in_opt PWSTR Parameters, - __in ULONG ShowWindowType, - __in ULONG Flags, - __in_opt ULONG Timeout, - __out_opt PHANDLE ProcessHandle + _In_ HWND hWnd, + _In_ PWSTR FileName, + _In_opt_ PWSTR Parameters, + _In_ ULONG ShowWindowType, + _In_ ULONG Flags, + _In_opt_ ULONG Timeout, + _Out_opt_ PHANDLE ProcessHandle ); PHLIBAPI VOID PhShellExploreFile( - __in HWND hWnd, - __in PWSTR FileName + _In_ HWND hWnd, + _In_ PWSTR FileName ); PHLIBAPI VOID PhShellProperties( - __in HWND hWnd, - __in PWSTR FileName + _In_ HWND hWnd, + _In_ PWSTR FileName + ); + +PPH_STRING PhExpandKeyName( + _In_ PPH_STRING KeyName, + _In_ BOOLEAN Computer ); PHLIBAPI VOID PhShellOpenKey( - __in HWND hWnd, - __in PPH_STRING KeyName + _In_ HWND hWnd, + _In_ PPH_STRING KeyName ); PKEY_VALUE_PARTIAL_INFORMATION PhQueryRegistryValue( - __in HANDLE KeyHandle, - __in_opt PWSTR ValueName + _In_ HANDLE KeyHandle, + _In_opt_ PWSTR ValueName ); PHLIBAPI PPH_STRING PhQueryRegistryString( - __in HANDLE KeyHandle, - __in_opt PWSTR ValueName + _In_ HANDLE KeyHandle, + _In_opt_ PWSTR ValueName ); typedef struct _PH_FLAG_MAPPING @@ -2597,18 +2619,18 @@ typedef struct _PH_FLAG_MAPPING PHLIBAPI VOID PhMapFlags1( - __inout PULONG Value2, - __in ULONG Value1, - __in const PH_FLAG_MAPPING *Mappings, - __in ULONG NumberOfMappings + _Inout_ PULONG Value2, + _In_ ULONG Value1, + _In_ const PH_FLAG_MAPPING *Mappings, + _In_ ULONG NumberOfMappings ); PHLIBAPI VOID PhMapFlags2( - __inout PULONG Value1, - __in ULONG Value2, - __in const PH_FLAG_MAPPING *Mappings, - __in ULONG NumberOfMappings + _Inout_ PULONG Value1, + _In_ ULONG Value2, + _In_ const PH_FLAG_MAPPING *Mappings, + _In_ ULONG NumberOfMappings ); PHLIBAPI @@ -2623,13 +2645,13 @@ PVOID PhCreateSaveFileDialog( PHLIBAPI VOID PhFreeFileDialog( - __in PVOID FileDialog + _In_ PVOID FileDialog ); PHLIBAPI BOOLEAN PhShowFileDialog( - __in HWND hWnd, - __in PVOID FileDialog + _In_ HWND hWnd, + _In_ PVOID FileDialog ); #define PH_FILEDIALOG_CREATEPROMPT 0x1 @@ -2644,18 +2666,18 @@ BOOLEAN PhShowFileDialog( PHLIBAPI ULONG PhGetFileDialogOptions( - __in PVOID FileDialog + _In_ PVOID FileDialog ); PHLIBAPI VOID PhSetFileDialogOptions( - __in PVOID FileDialog, - __in ULONG Options + _In_ PVOID FileDialog, + _In_ ULONG Options ); PHLIBAPI ULONG PhGetFileDialogFilterIndex( - __in PVOID FileDialog + _In_ PVOID FileDialog ); typedef struct _PH_FILETYPE_FILTER @@ -2666,28 +2688,28 @@ typedef struct _PH_FILETYPE_FILTER PHLIBAPI VOID PhSetFileDialogFilter( - __in PVOID FileDialog, - __in PPH_FILETYPE_FILTER Filters, - __in ULONG NumberOfFilters + _In_ PVOID FileDialog, + _In_ PPH_FILETYPE_FILTER Filters, + _In_ ULONG NumberOfFilters ); PHLIBAPI PPH_STRING PhGetFileDialogFileName( - __in PVOID FileDialog + _In_ PVOID FileDialog ); PHLIBAPI VOID PhSetFileDialogFileName( - __in PVOID FileDialog, - __in PWSTR FileName + _In_ PVOID FileDialog, + _In_ PWSTR FileName ); PHLIBAPI NTSTATUS PhIsExecutablePacked( - __in PWSTR FileName, - __out PBOOLEAN IsPacked, - __out_opt PULONG NumberOfModules, - __out_opt PULONG NumberOfFunctions + _In_ PWSTR FileName, + _Out_ PBOOLEAN IsPacked, + _Out_opt_ PULONG NumberOfModules, + _Out_opt_ PULONG NumberOfFunctions ); typedef enum _PH_HASH_ALGORITHM @@ -2705,23 +2727,23 @@ typedef struct _PH_HASH_CONTEXT PHLIBAPI VOID PhInitializeHash( - __out PPH_HASH_CONTEXT Context, - __in PH_HASH_ALGORITHM Algorithm + _Out_ PPH_HASH_CONTEXT Context, + _In_ PH_HASH_ALGORITHM Algorithm ); PHLIBAPI VOID PhUpdateHash( - __inout PPH_HASH_CONTEXT Context, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _Inout_ PPH_HASH_CONTEXT Context, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ); PHLIBAPI BOOLEAN PhFinalHash( - __inout PPH_HASH_CONTEXT Context, - __out_bcount(HashLength) PVOID Hash, - __in ULONG HashLength, - __out_opt PULONG ReturnLength + _Inout_ PPH_HASH_CONTEXT Context, + _Out_writes_bytes_(HashLength) PVOID Hash, + _In_ ULONG HashLength, + _Out_opt_ PULONG ReturnLength ); typedef enum _PH_COMMAND_LINE_OPTION_TYPE @@ -2739,9 +2761,9 @@ typedef struct _PH_COMMAND_LINE_OPTION } PH_COMMAND_LINE_OPTION, *PPH_COMMAND_LINE_OPTION; typedef BOOLEAN (NTAPI *PPH_COMMAND_LINE_CALLBACK)( - __in_opt PPH_COMMAND_LINE_OPTION Option, - __in_opt PPH_STRING Value, - __in_opt PVOID Context + _In_opt_ PPH_COMMAND_LINE_OPTION Option, + _In_opt_ PPH_STRING Value, + _In_opt_ PVOID Context ); #define PH_COMMAND_LINE_IGNORE_UNKNOWN_OPTIONS 0x1 @@ -2749,31 +2771,31 @@ typedef BOOLEAN (NTAPI *PPH_COMMAND_LINE_CALLBACK)( PHLIBAPI PPH_STRING PhParseCommandLinePart( - __in PPH_STRINGREF CommandLine, - __inout PULONG_PTR Index + _In_ PPH_STRINGREF CommandLine, + _Inout_ PULONG_PTR Index ); PHLIBAPI BOOLEAN PhParseCommandLine( - __in PPH_STRINGREF CommandLine, - __in_opt PPH_COMMAND_LINE_OPTION Options, - __in ULONG NumberOfOptions, - __in ULONG Flags, - __in PPH_COMMAND_LINE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_STRINGREF CommandLine, + _In_opt_ PPH_COMMAND_LINE_OPTION Options, + _In_ ULONG NumberOfOptions, + _In_ ULONG Flags, + _In_ PPH_COMMAND_LINE_CALLBACK Callback, + _In_opt_ PVOID Context ); PHLIBAPI PPH_STRING PhEscapeCommandLinePart( - __in PPH_STRINGREF String + _In_ PPH_STRINGREF String ); PHLIBAPI BOOLEAN PhParseCommandLineFuzzy( - __in PPH_STRINGREF CommandLine, - __out PPH_STRINGREF FileName, - __out PPH_STRINGREF Arguments, - __out_opt PPH_STRING *FullFileName + _In_ PPH_STRINGREF CommandLine, + _Out_ PPH_STRINGREF FileName, + _Out_ PPH_STRINGREF Arguments, + _Out_opt_ PPH_STRING *FullFileName ); #ifdef __cplusplus diff --git a/2.x/trunk/phlib/include/phbase.h b/2.x/trunk/phlib/include/phbase.h index 501f88219..164f77b43 100644 --- a/2.x/trunk/phlib/include/phbase.h +++ b/2.x/trunk/phlib/include/phbase.h @@ -53,11 +53,11 @@ typedef struct _PH_PROVIDER_THREAD PH_PROVIDER_THREAD; struct _PH_STARTUP_PARAMETERS; typedef struct _PH_STARTUP_PARAMETERS PH_STARTUP_PARAMETERS; -#define __userSet +#define _User_set_ -PHLIBAPI extern __userSet PVOID PhLibImageBase; +PHLIBAPI extern _User_set_ PVOID PhLibImageBase; -PHLIBAPI extern __userSet PWSTR PhApplicationName; +PHLIBAPI extern _User_set_ PWSTR PhApplicationName; PHLIBAPI extern ULONG PhCurrentSessionId; PHLIBAPI extern HANDLE PhCurrentTokenQueryHandle; PHLIBAPI extern BOOLEAN PhElevated; @@ -79,6 +79,7 @@ PHLIBAPI extern ACCESS_MASK ThreadAllAccess; #define WINDOWS_VISTA 60 #define WINDOWS_7 61 #define WINDOWS_8 62 +#define WINDOWS_81 63 #define WINDOWS_NEW MAXLONG #define WINDOWS_HAS_CONSOLE_HOST (WindowsVersion >= WINDOWS_7) @@ -176,9 +177,9 @@ NTSTATUS PhInitializePhLib( ); NTSTATUS PhInitializePhLibEx( - __in ULONG Flags, - __in_opt SIZE_T HeapReserveSize, - __in_opt SIZE_T HeapCommitSize + _In_ ULONG Flags, + _In_opt_ SIZE_T HeapReserveSize, + _In_opt_ SIZE_T HeapCommitSize ); // basesup @@ -187,7 +188,7 @@ struct _PH_OBJECT_TYPE; typedef struct _PH_OBJECT_TYPE *PPH_OBJECT_TYPE; BOOLEAN PhInitializeBase( - __in ULONG Flags + _In_ ULONG Flags ); // threads @@ -215,15 +216,15 @@ PHLIBAPI HANDLE NTAPI PhCreateThread( - __in_opt SIZE_T StackSize, - __in PUSER_THREAD_START_ROUTINE StartAddress, - __in_opt PVOID Parameter + _In_opt_ SIZE_T StackSize, + _In_ PUSER_THREAD_START_ROUTINE StartAddress, + _In_opt_ PVOID Parameter ); // DLLs FORCEINLINE PVOID PhGetDllHandle( - __in PWSTR DllName + _In_ PWSTR DllName ) { UNICODE_STRING dllName; @@ -238,9 +239,9 @@ FORCEINLINE PVOID PhGetDllHandle( } FORCEINLINE PVOID PhGetProcedureAddress( - __in PVOID DllHandle, - __in_opt PSTR ProcedureName, - __in_opt ULONG ProcedureNumber + _In_ PVOID DllHandle, + _In_opt_ PSTR ProcedureName, + _In_opt_ ULONG ProcedureNumber ) { NTSTATUS status; @@ -279,105 +280,106 @@ PHLIBAPI VOID NTAPI PhQuerySystemTime( - __out PLARGE_INTEGER SystemTime + _Out_ PLARGE_INTEGER SystemTime ); PHLIBAPI VOID NTAPI PhQueryTimeZoneBias( - __out PLARGE_INTEGER TimeZoneBias + _Out_ PLARGE_INTEGER TimeZoneBias ); PHLIBAPI VOID NTAPI PhSystemTimeToLocalTime( - __in PLARGE_INTEGER SystemTime, - __out PLARGE_INTEGER LocalTime + _In_ PLARGE_INTEGER SystemTime, + _Out_ PLARGE_INTEGER LocalTime ); PHLIBAPI VOID NTAPI PhLocalTimeToSystemTime( - __in PLARGE_INTEGER LocalTime, - __out PLARGE_INTEGER SystemTime + _In_ PLARGE_INTEGER LocalTime, + _Out_ PLARGE_INTEGER SystemTime ); // heap -__mayRaise -__checkReturn -__notnull -__bcount(Size) +_May_raise_ +_Check_return_ +_Ret_notnull_ +_Post_writable_byte_size_(Size) PHLIBAPI PVOID NTAPI PhAllocate( - __in SIZE_T Size + _In_ SIZE_T Size ); PHLIBAPI PVOID NTAPI PhAllocateSafe( - __in SIZE_T Size + _In_ SIZE_T Size ); PHLIBAPI PVOID NTAPI PhAllocateExSafe( - __in SIZE_T Size, - __in ULONG Flags + _In_ SIZE_T Size, + _In_ ULONG Flags ); PHLIBAPI VOID NTAPI PhFree( - __in __post_invalid PVOID Memory + _Frees_ptr_opt_ PVOID Memory ); -__mayRaise +_May_raise_ +_Post_writable_byte_size_(Size) PHLIBAPI PVOID NTAPI PhReAllocate( - __in PVOID Memory, - __in SIZE_T Size + _Frees_ptr_opt_ PVOID Memory, + _In_ SIZE_T Size ); PHLIBAPI PVOID NTAPI PhReAllocateSafe( - __in PVOID Memory, - __in SIZE_T Size + _In_ PVOID Memory, + _In_ SIZE_T Size ); -__checkReturn -__maybenull +_Check_return_ +_Ret_maybenull_ PHLIBAPI PVOID NTAPI PhAllocatePage( - __in SIZE_T Size, - __out_opt PSIZE_T NewSize + _In_ SIZE_T Size, + _Out_opt_ PSIZE_T NewSize ); PHLIBAPI VOID NTAPI PhFreePage( - __in __post_invalid PVOID Memory + _Frees_ptr_opt_ PVOID Memory ); FORCEINLINE PVOID PhAllocateAligned( - __in SIZE_T Size, - __in ULONG Align, - __in SIZE_T AllocationBaseOffset + _In_ SIZE_T Size, + _In_ ULONG Align, + _In_ SIZE_T AllocationBaseOffset ) { PVOID memory; @@ -391,16 +393,16 @@ FORCEINLINE PVOID PhAllocateAligned( } FORCEINLINE VOID PhFreeAligned( - __in __post_invalid PVOID Memory, - __in SIZE_T AllocationBaseOffset + _In_ _Post_invalid_ PVOID Memory, + _In_ SIZE_T AllocationBaseOffset ) { PhFree(*(PVOID *)PTR_ADD_OFFSET(Memory, AllocationBaseOffset)); } FORCEINLINE PVOID PhAllocateCopy( - __in PVOID Data, - __in SIZE_T Size + _In_ PVOID Data, + _In_ SIZE_T Size ) { PVOID copy; @@ -454,7 +456,7 @@ PHLIBAPI VOID FASTCALL PhfInitializeEvent( - __out PPH_EVENT Event + _Out_ PPH_EVENT Event ); #define PhSetEvent PhfSetEvent @@ -462,7 +464,7 @@ PHLIBAPI VOID FASTCALL PhfSetEvent( - __inout PPH_EVENT Event + _Inout_ PPH_EVENT Event ); #define PhWaitForEvent PhfWaitForEvent @@ -470,8 +472,8 @@ PHLIBAPI BOOLEAN FASTCALL PhfWaitForEvent( - __inout PPH_EVENT Event, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_EVENT Event, + _In_opt_ PLARGE_INTEGER Timeout ); #define PhResetEvent PhfResetEvent @@ -479,11 +481,11 @@ PHLIBAPI VOID FASTCALL PhfResetEvent( - __inout PPH_EVENT Event + _Inout_ PPH_EVENT Event ); FORCEINLINE VOID PhInitializeEvent( - __out PPH_EVENT Event + _Out_ PPH_EVENT Event ) { Event->Value = PH_EVENT_REFCOUNT_INC; @@ -499,7 +501,7 @@ FORCEINLINE VOID PhInitializeEvent( * otherwise FALSE. */ FORCEINLINE BOOLEAN PhTestEvent( - __in PPH_EVENT Event + _In_ PPH_EVENT Event ) { return !!(Event->Value & PH_EVENT_SET); @@ -531,8 +533,8 @@ PHLIBAPI VOID FASTCALL PhfInitializeBarrier( - __out PPH_BARRIER Barrier, - __in ULONG_PTR Target + _Out_ PPH_BARRIER Barrier, + _In_ ULONG_PTR Target ); #define PhWaitForBarrier PhfWaitForBarrier @@ -540,13 +542,13 @@ PHLIBAPI BOOLEAN FASTCALL PhfWaitForBarrier( - __inout PPH_BARRIER Barrier, - __in BOOLEAN Spin + _Inout_ PPH_BARRIER Barrier, + _In_ BOOLEAN Spin ); FORCEINLINE VOID PhInitializeBarrier( - __out PPH_BARRIER Barrier, - __in ULONG_PTR Target + _Out_ PPH_BARRIER Barrier, + _In_ ULONG_PTR Target ) { Barrier->Value = Target << PH_BARRIER_TARGET_SHIFT; @@ -576,39 +578,39 @@ PHLIBAPI VOID FASTCALL PhfInitializeRundownProtection( - __out PPH_RUNDOWN_PROTECT Protection + _Out_ PPH_RUNDOWN_PROTECT Protection ); PHLIBAPI BOOLEAN FASTCALL PhfAcquireRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ); PHLIBAPI VOID FASTCALL PhfReleaseRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ); PHLIBAPI VOID FASTCALL PhfWaitForRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ); FORCEINLINE VOID PhInitializeRundownProtection( - __out PPH_RUNDOWN_PROTECT Protection + _Out_ PPH_RUNDOWN_PROTECT Protection ) { Protection->Value = 0; } FORCEINLINE BOOLEAN PhAcquireRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ) { ULONG_PTR value; @@ -630,7 +632,7 @@ FORCEINLINE BOOLEAN PhAcquireRundownProtection( } FORCEINLINE VOID PhReleaseRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ) { ULONG_PTR value; @@ -648,7 +650,7 @@ FORCEINLINE VOID PhReleaseRundownProtection( } FORCEINLINE VOID PhWaitForRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ) { ULONG_PTR value; @@ -682,14 +684,14 @@ PHLIBAPI VOID FASTCALL PhfInitializeInitOnce( - __out PPH_INITONCE InitOnce + _Out_ PPH_INITONCE InitOnce ); PHLIBAPI BOOLEAN FASTCALL PhfBeginInitOnce( - __inout PPH_INITONCE InitOnce + _Inout_ PPH_INITONCE InitOnce ); #define PhEndInitOnce PhfEndInitOnce @@ -697,11 +699,11 @@ PHLIBAPI VOID FASTCALL PhfEndInitOnce( - __inout PPH_INITONCE InitOnce + _Inout_ PPH_INITONCE InitOnce ); FORCEINLINE BOOLEAN PhBeginInitOnce( - __inout PPH_INITONCE InitOnce + _Inout_ PPH_INITONCE InitOnce ) { if (InitOnce->State == PH_INITONCE_INITIALIZED) @@ -711,7 +713,7 @@ FORCEINLINE BOOLEAN PhBeginInitOnce( } FORCEINLINE BOOLEAN PhTestInitOnce( - __in PPH_INITONCE InitOnce + _In_ PPH_INITONCE InitOnce ) { return InitOnce->State == PH_INITONCE_INITIALIZED; @@ -723,68 +725,68 @@ PHLIBAPI PSTR NTAPI PhDuplicateAnsiStringZ( - __in PSTR String + _In_ PSTR String ); PHLIBAPI PSTR NTAPI PhDuplicateAnsiStringZSafe( - __in PSTR String + _In_ PSTR String ); PHLIBAPI PWSTR NTAPI PhDuplicateUnicodeStringZ( - __in PWSTR String + _In_ PWSTR String ); PHLIBAPI BOOLEAN NTAPI PhCopyAnsiStringZ( - __in PSTR InputBuffer, - __in ULONG InputCount, - __out_ecount_z_opt(OutputCount) PSTR OutputBuffer, - __in ULONG OutputCount, - __out_opt PULONG ReturnCount + _In_ PSTR InputBuffer, + _In_ ULONG InputCount, + _Out_writes_opt_z_(OutputCount) PSTR OutputBuffer, + _In_ ULONG OutputCount, + _Out_opt_ PULONG ReturnCount ); PHLIBAPI BOOLEAN NTAPI PhCopyUnicodeStringZ( - __in PWSTR InputBuffer, - __in ULONG InputCount, - __out_ecount_z_opt(OutputCount) PWSTR OutputBuffer, - __in ULONG OutputCount, - __out_opt PULONG ReturnCount + _In_ PWSTR InputBuffer, + _In_ ULONG InputCount, + _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer, + _In_ ULONG OutputCount, + _Out_opt_ PULONG ReturnCount ); PHLIBAPI BOOLEAN NTAPI PhCopyUnicodeStringZFromAnsi( - __in PSTR InputBuffer, - __in ULONG InputCount, - __out_ecount_z_opt(OutputCount) PWSTR OutputBuffer, - __in ULONG OutputCount, - __out_opt PULONG ReturnCount + _In_ PSTR InputBuffer, + _In_ ULONG InputCount, + _Out_writes_opt_z_(OutputCount) PWSTR OutputBuffer, + _In_ ULONG OutputCount, + _Out_opt_ PULONG ReturnCount ); PHLIBAPI LONG NTAPI PhCompareUnicodeStringZNatural( - __in PWSTR A, - __in PWSTR B, - __in BOOLEAN IgnoreCase + _In_ PWSTR A, + _In_ PWSTR B, + _In_ BOOLEAN IgnoreCase ); FORCEINLINE BOOLEAN PhAreCharactersDifferent( - __in WCHAR Char1, - __in WCHAR Char2 + _In_ WCHAR Char1, + _In_ WCHAR Char2 ) { WCHAR d; @@ -800,16 +802,16 @@ FORCEINLINE BOOLEAN PhAreCharactersDifferent( } FORCEINLINE BOOLEAN PhIsDigitCharacter( - __in WCHAR Char + _In_ WCHAR Char ) { return (USHORT)(Char - '0') < 10; } FORCEINLINE LONG PhCompareStringZ( - __in PWSTR String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PWSTR String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { if (!IgnoreCase) @@ -819,9 +821,9 @@ FORCEINLINE LONG PhCompareStringZ( } FORCEINLINE BOOLEAN PhEqualStringZ( - __in PWSTR String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PWSTR String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { if (!IgnoreCase) @@ -845,7 +847,7 @@ typedef struct _PH_STRINGREF /** The length, in bytes, of the string. */ SIZE_T Length; /** The buffer containing the contents of the string. */ - PWSTR Buffer; + PWCH Buffer; } PH_STRINGREF, *PPH_STRINGREF; typedef struct _PH_ANSI_STRINGREF @@ -859,7 +861,7 @@ typedef struct _PH_ANSI_STRINGREF /** Unused and of an undefined value. */ USHORT Reserved; /** The buffer containing the contents of the string. */ - PSTR Buffer; + PCHAR Buffer; }; ANSI_STRING as; }; @@ -876,8 +878,8 @@ typedef struct _PH_RELATIVE_STRINGREF #define PH_STRINGREF_INIT(String) { sizeof(String) - sizeof(WCHAR), (String) } FORCEINLINE VOID PhInitializeStringRef( - __out PPH_STRINGREF String, - __in PWSTR Buffer + _Out_ PPH_STRINGREF String, + _In_ PWSTR Buffer ) { String->Length = wcslen(Buffer) * sizeof(WCHAR); @@ -885,7 +887,7 @@ FORCEINLINE VOID PhInitializeStringRef( } FORCEINLINE VOID PhInitializeEmptyStringRef( - __out PPH_STRINGREF String + _Out_ PPH_STRINGREF String ) { String->Length = 0; @@ -893,15 +895,15 @@ FORCEINLINE VOID PhInitializeEmptyStringRef( } FORCEINLINE BOOLEAN PhIsNullOrEmptyStringRef( - __in_opt PPH_STRINGREF String + _In_opt_ PPH_STRINGREF String ) { return !String || String->Length == 0; } FORCEINLINE BOOLEAN PhStringRefToUnicodeString( - __in PPH_STRINGREF String, - __out PUNICODE_STRING UnicodeString + _In_ PPH_STRINGREF String, + _Out_ PUNICODE_STRING UnicodeString ) { UnicodeString->Length = (USHORT)String->Length; @@ -912,8 +914,8 @@ FORCEINLINE BOOLEAN PhStringRefToUnicodeString( } FORCEINLINE VOID PhUnicodeStringToStringRef( - __in PUNICODE_STRING UnicodeString, - __out PPH_STRINGREF String + _In_ PUNICODE_STRING UnicodeString, + _Out_ PPH_STRINGREF String ) { String->Length = UnicodeString->Length; @@ -924,76 +926,76 @@ PHLIBAPI LONG NTAPI PhCompareStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ); PHLIBAPI BOOLEAN NTAPI PhEqualStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ); PHLIBAPI ULONG_PTR NTAPI PhFindCharInStringRef( - __in PPH_STRINGREF String, - __in WCHAR Character, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String, + _In_ WCHAR Character, + _In_ BOOLEAN IgnoreCase ); PHLIBAPI ULONG_PTR NTAPI PhFindLastCharInStringRef( - __in PPH_STRINGREF String, - __in WCHAR Character, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String, + _In_ WCHAR Character, + _In_ BOOLEAN IgnoreCase ); PHLIBAPI ULONG_PTR NTAPI PhFindStringInStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ); PHLIBAPI BOOLEAN NTAPI PhSplitStringRefAtChar( - __in PPH_STRINGREF Input, - __in WCHAR Separator, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart + _In_ PPH_STRINGREF Input, + _In_ WCHAR Separator, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart ); PHLIBAPI BOOLEAN NTAPI PhSplitStringRefAtLastChar( - __in PPH_STRINGREF Input, - __in WCHAR Separator, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart + _In_ PPH_STRINGREF Input, + _In_ WCHAR Separator, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart ); PHLIBAPI BOOLEAN NTAPI PhSplitStringRefAtString( - __in PPH_STRINGREF Input, - __in PPH_STRINGREF Separator, - __in BOOLEAN IgnoreCase, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart + _In_ PPH_STRINGREF Input, + _In_ PPH_STRINGREF Separator, + _In_ BOOLEAN IgnoreCase, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart ); #define PH_SPLIT_AT_CHAR_SET 0x0 // default @@ -1008,18 +1010,18 @@ PHLIBAPI BOOLEAN NTAPI PhSplitStringRefEx( - __in PPH_STRINGREF Input, - __in PPH_STRINGREF Separator, - __in ULONG Flags, - __out PPH_STRINGREF FirstPart, - __out PPH_STRINGREF SecondPart, - __out_opt PPH_STRINGREF SeparatorPart + _In_ PPH_STRINGREF Input, + _In_ PPH_STRINGREF Separator, + _In_ ULONG Flags, + _Out_ PPH_STRINGREF FirstPart, + _Out_ PPH_STRINGREF SecondPart, + _Out_opt_ PPH_STRINGREF SeparatorPart ); FORCEINLINE LONG PhCompareStringRef2( - __in PPH_STRINGREF String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr2; @@ -1030,9 +1032,9 @@ FORCEINLINE LONG PhCompareStringRef2( } FORCEINLINE BOOLEAN PhEqualStringRef2( - __in PPH_STRINGREF String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr2; @@ -1043,9 +1045,9 @@ FORCEINLINE BOOLEAN PhEqualStringRef2( } FORCEINLINE BOOLEAN PhStartsWithStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr1; @@ -1060,9 +1062,9 @@ FORCEINLINE BOOLEAN PhStartsWithStringRef( } FORCEINLINE BOOLEAN PhStartsWithStringRef2( - __in PPH_STRINGREF String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr2; @@ -1073,9 +1075,9 @@ FORCEINLINE BOOLEAN PhStartsWithStringRef2( } FORCEINLINE BOOLEAN PhEndsWithStringRef( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr1; @@ -1083,16 +1085,16 @@ FORCEINLINE BOOLEAN PhEndsWithStringRef( if (String2->Length > String1->Length) return FALSE; - sr1.Buffer = (PWSTR)((PCHAR)String1->Buffer + String1->Length - String2->Length); + sr1.Buffer = (PWCHAR)((PCHAR)String1->Buffer + String1->Length - String2->Length); sr1.Length = String2->Length; return PhEqualStringRef(&sr1, String2, IgnoreCase); } FORCEINLINE BOOLEAN PhEndsWithStringRef2( - __in PPH_STRINGREF String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRINGREF String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr2; @@ -1103,7 +1105,7 @@ FORCEINLINE BOOLEAN PhEndsWithStringRef2( } FORCEINLINE VOID PhReverseStringRef( - __in PPH_STRINGREF String + _In_ PPH_STRINGREF String ) { SIZE_T i; @@ -1139,7 +1141,7 @@ typedef struct _PH_STRING /** The length, in bytes, of the string. */ SIZE_T Length; /** The buffer containing the contents of the string. */ - PWSTR Buffer; + PWCH Buffer; }; }; @@ -1161,30 +1163,30 @@ PHLIBAPI PPH_STRING NTAPI PhCreateString( - __in PWSTR Buffer + _In_ PWSTR Buffer ); PHLIBAPI PPH_STRING NTAPI PhCreateStringEx( - __in_opt PWSTR Buffer, - __in SIZE_T Length + _In_opt_ PWCHAR Buffer, + _In_ SIZE_T Length ); PHLIBAPI PPH_STRING NTAPI PhCreateStringFromAnsi( - __in PSTR Buffer + _In_ PSTR Buffer ); PHLIBAPI PPH_STRING NTAPI PhCreateStringFromAnsiEx( - __in PSTR Buffer, - __in SIZE_T Length + _In_ PCHAR Buffer, + _In_ SIZE_T Length ); PHLIBAPI @@ -1198,7 +1200,7 @@ PHLIBAPI PPH_STRING NTAPI PhConcatStrings( - __in ULONG Count, + _In_ ULONG Count, ... ); @@ -1208,39 +1210,39 @@ PHLIBAPI PPH_STRING NTAPI PhConcatStrings_V( - __in ULONG Count, - __in va_list ArgPtr + _In_ ULONG Count, + _In_ va_list ArgPtr ); PHLIBAPI PPH_STRING NTAPI PhConcatStrings2( - __in PWSTR String1, - __in PWSTR String2 + _In_ PWSTR String1, + _In_ PWSTR String2 ); PHLIBAPI PPH_STRING NTAPI PhConcatStringRef2( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2 + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2 ); PPH_STRING NTAPI PhConcatStringRef3( - __in PPH_STRINGREF String1, - __in PPH_STRINGREF String2, - __in PPH_STRINGREF String3 + _In_ PPH_STRINGREF String1, + _In_ PPH_STRINGREF String2, + _In_ PPH_STRINGREF String3 ); PHLIBAPI PPH_STRING NTAPI PhFormatString( - __in __format_string PWSTR Format, + _In_ _Printf_format_string_ PWSTR Format, ... ); @@ -1248,8 +1250,8 @@ PHLIBAPI PPH_STRING NTAPI PhFormatString_V( - __in __format_string PWSTR Format, - __in va_list ArgPtr + _In_ _Printf_format_string_ PWSTR Format, + _In_ va_list ArgPtr ); /** @@ -1263,7 +1265,7 @@ PhFormatString_V( * NULL. */ FORCEINLINE PWSTR PhGetString( - __in_opt PPH_STRING String + _In_opt_ PPH_STRING String ) { if (String) @@ -1273,7 +1275,7 @@ FORCEINLINE PWSTR PhGetString( } FORCEINLINE PH_STRINGREF PhGetStringRef( - __in_opt PPH_STRING String + _In_opt_ PPH_STRING String ) { PH_STRINGREF sr; @@ -1301,7 +1303,7 @@ FORCEINLINE PH_STRINGREF PhGetStringRef( * an empty string. */ FORCEINLINE PWSTR PhGetStringOrEmpty( - __in_opt PPH_STRING String + _In_opt_ PPH_STRING String ) { if (String) @@ -1311,7 +1313,7 @@ FORCEINLINE PWSTR PhGetStringOrEmpty( } FORCEINLINE PH_STRINGREF PhGetStringRefOrEmpty( - __in_opt PPH_STRING String + _In_opt_ PPH_STRING String ) { PH_STRINGREF sr; @@ -1341,8 +1343,8 @@ FORCEINLINE PH_STRINGREF PhGetStringRefOrEmpty( * the specified alternative string. */ FORCEINLINE PWSTR PhGetStringOrDefault( - __in_opt PPH_STRING String, - __in PWSTR DefaultString + _In_opt_ PPH_STRING String, + _In_ PWSTR DefaultString ) { if (String) @@ -1357,7 +1359,7 @@ FORCEINLINE PWSTR PhGetStringOrDefault( * \param String A pointer to a string object. */ FORCEINLINE BOOLEAN PhIsNullOrEmptyString( - __in_opt PPH_STRING String + _In_opt_ PPH_STRING String ) { return !String || String->Length == 0; @@ -1369,7 +1371,7 @@ FORCEINLINE BOOLEAN PhIsNullOrEmptyString( * \param String A string to duplicate. */ FORCEINLINE PPH_STRING PhDuplicateString( - __in PPH_STRING String + _In_ PPH_STRING String ) { return PhCreateStringEx(String->Buffer, String->Length); @@ -1383,9 +1385,9 @@ FORCEINLINE PPH_STRING PhDuplicateString( * \param IgnoreCase Whether to ignore character cases. */ FORCEINLINE LONG PhCompareString( - __in PPH_STRING String1, - __in PPH_STRING String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PPH_STRING String2, + _In_ BOOLEAN IgnoreCase ) { if (!IgnoreCase) @@ -1402,9 +1404,9 @@ FORCEINLINE LONG PhCompareString( * \param IgnoreCase Whether to ignore character cases. */ FORCEINLINE LONG PhCompareString2( - __in PPH_STRING String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { if (!IgnoreCase) @@ -1425,9 +1427,9 @@ FORCEINLINE LONG PhCompareString2( * \param IgnoreCase Whether to ignore character cases. */ FORCEINLINE LONG PhCompareStringWithNull( - __in_opt PPH_STRING String1, - __in_opt PPH_STRING String2, - __in BOOLEAN IgnoreCase + _In_opt_ PPH_STRING String1, + _In_opt_ PPH_STRING String2, + _In_ BOOLEAN IgnoreCase ) { if (String1 && String2) @@ -1452,9 +1454,9 @@ FORCEINLINE LONG PhCompareStringWithNull( * \param IgnoreCase Whether to ignore character cases. */ FORCEINLINE BOOLEAN PhEqualString( - __in PPH_STRING String1, - __in PPH_STRING String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PPH_STRING String2, + _In_ BOOLEAN IgnoreCase ) { return PhEqualStringRef(&String1->sr, &String2->sr, IgnoreCase); @@ -1468,9 +1470,9 @@ FORCEINLINE BOOLEAN PhEqualString( * \param IgnoreCase Whether to ignore character cases. */ FORCEINLINE BOOLEAN PhEqualString2( - __in PPH_STRING String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { if (!IgnoreCase) @@ -1494,9 +1496,9 @@ FORCEINLINE BOOLEAN PhEqualString2( * otherwise FALSE. */ FORCEINLINE BOOLEAN PhStartsWithString( - __in PPH_STRING String1, - __in PPH_STRING String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PPH_STRING String2, + _In_ BOOLEAN IgnoreCase ) { return PhStartsWithStringRef(&String1->sr, &String2->sr, IgnoreCase); @@ -1513,9 +1515,9 @@ FORCEINLINE BOOLEAN PhStartsWithString( * otherwise FALSE. */ FORCEINLINE BOOLEAN PhStartsWithString2( - __in PPH_STRING String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr2; @@ -1536,9 +1538,9 @@ FORCEINLINE BOOLEAN PhStartsWithString2( * otherwise FALSE. */ FORCEINLINE BOOLEAN PhEndsWithString( - __in PPH_STRING String1, - __in PPH_STRING String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PPH_STRING String2, + _In_ BOOLEAN IgnoreCase ) { return PhEndsWithStringRef(&String1->sr, &String2->sr, IgnoreCase); @@ -1555,9 +1557,9 @@ FORCEINLINE BOOLEAN PhEndsWithString( * otherwise FALSE. */ FORCEINLINE BOOLEAN PhEndsWithString2( - __in PPH_STRING String1, - __in PWSTR String2, - __in BOOLEAN IgnoreCase + _In_ PPH_STRING String1, + _In_ PWSTR String2, + _In_ BOOLEAN IgnoreCase ) { PH_STRINGREF sr2; @@ -1579,9 +1581,9 @@ FORCEINLINE BOOLEAN PhEndsWithString2( * found, -1 is returned. */ FORCEINLINE ULONG_PTR PhFindCharInString( - __in PPH_STRING String, - __in SIZE_T StartIndex, - __in WCHAR Char + _In_ PPH_STRING String, + _In_ SIZE_T StartIndex, + _In_ WCHAR Char ) { if (StartIndex != 0) @@ -1619,9 +1621,9 @@ FORCEINLINE ULONG_PTR PhFindCharInString( * found, -1 is returned. */ FORCEINLINE ULONG_PTR PhFindLastCharInString( - __in PPH_STRING String, - __in SIZE_T StartIndex, - __in WCHAR Char + _In_ PPH_STRING String, + _In_ SIZE_T StartIndex, + _In_ WCHAR Char ) { if (StartIndex != 0) @@ -1659,9 +1661,9 @@ FORCEINLINE ULONG_PTR PhFindLastCharInString( * found, -1 is returned. */ FORCEINLINE ULONG_PTR PhFindStringInString( - __in PPH_STRING String1, - __in SIZE_T StartIndex, - __in PWSTR String2 + _In_ PPH_STRING String1, + _In_ SIZE_T StartIndex, + _In_ PWSTR String2 ) { PH_STRINGREF sr2; @@ -1697,7 +1699,7 @@ FORCEINLINE ULONG_PTR PhFindStringInString( * \param String The string to convert. */ FORCEINLINE VOID PhLowerString( - __inout PPH_STRING String + _Inout_ PPH_STRING String ) { _wcslwr(String->Buffer); @@ -1709,7 +1711,7 @@ FORCEINLINE VOID PhLowerString( * \param String The string to convert. */ FORCEINLINE VOID PhUpperString( - __inout PPH_STRING String + _Inout_ PPH_STRING String ) { _wcsupr(String->Buffer); @@ -1723,9 +1725,9 @@ FORCEINLINE VOID PhUpperString( * \param Count The number of characters to use. */ FORCEINLINE PPH_STRING PhSubstring( - __in PPH_STRING String, - __in SIZE_T StartIndex, - __in SIZE_T Count + _In_ PPH_STRING String, + _In_ SIZE_T StartIndex, + _In_ SIZE_T Count ) { return PhCreateStringEx(&String->Buffer[StartIndex], Count * sizeof(WCHAR)); @@ -1742,7 +1744,7 @@ FORCEINLINE PPH_STRING PhSubstring( * object's buffer manually. */ FORCEINLINE VOID PhTrimToNullTerminatorString( - __inout PPH_STRING String + _Inout_ PPH_STRING String ) { String->Length = wcslen(String->Buffer) * sizeof(WCHAR); @@ -1780,30 +1782,30 @@ PHLIBAPI PPH_ANSI_STRING NTAPI PhCreateAnsiString( - __in PSTR Buffer + _In_ PSTR Buffer ); PHLIBAPI PPH_ANSI_STRING NTAPI PhCreateAnsiStringEx( - __in_opt PSTR Buffer, - __in SIZE_T Length + _In_opt_ PCHAR Buffer, + _In_ SIZE_T Length ); PHLIBAPI PPH_ANSI_STRING NTAPI PhCreateAnsiStringFromUnicode( - __in PWSTR Buffer + _In_ PWSTR Buffer ); PHLIBAPI PPH_ANSI_STRING NTAPI PhCreateAnsiStringFromUnicodeEx( - __in PWSTR Buffer, - __in SIZE_T Length + _In_ PWCHAR Buffer, + _In_ SIZE_T Length ); // stringbuilder @@ -1831,125 +1833,125 @@ PHLIBAPI VOID NTAPI PhInitializeStringBuilder( - __out PPH_STRING_BUILDER StringBuilder, - __in SIZE_T InitialCapacity + _Out_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T InitialCapacity ); PHLIBAPI VOID NTAPI PhDeleteStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder + _Inout_ PPH_STRING_BUILDER StringBuilder ); PHLIBAPI PPH_STRING NTAPI PhReferenceStringBuilderString( - __in PPH_STRING_BUILDER StringBuilder + _In_ PPH_STRING_BUILDER StringBuilder ); PHLIBAPI PPH_STRING NTAPI PhFinalStringBuilderString( - __inout PPH_STRING_BUILDER StringBuilder + _Inout_ PPH_STRING_BUILDER StringBuilder ); PHLIBAPI VOID NTAPI PhAppendStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in PPH_STRING String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ PPH_STRING String ); PHLIBAPI VOID NTAPI PhAppendStringBuilder2( - __inout PPH_STRING_BUILDER StringBuilder, - __in PWSTR String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ PWSTR String ); PHLIBAPI VOID NTAPI PhAppendStringBuilderEx( - __inout PPH_STRING_BUILDER StringBuilder, - __in_opt PWSTR String, - __in SIZE_T Length + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_opt_ PWCHAR String, + _In_ SIZE_T Length ); PHLIBAPI VOID NTAPI PhAppendCharStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in WCHAR Character + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ WCHAR Character ); PHLIBAPI VOID NTAPI PhAppendCharStringBuilder2( - __inout PPH_STRING_BUILDER StringBuilder, - __in WCHAR Character, - __in SIZE_T Count + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ WCHAR Character, + _In_ SIZE_T Count ); PHLIBAPI VOID NTAPI PhAppendFormatStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in __format_string PWSTR Format, + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ _Printf_format_string_ PWSTR Format, ... ); VOID NTAPI PhAppendFormatStringBuilder_V( - __inout PPH_STRING_BUILDER StringBuilder, - __in __format_string PWSTR Format, - __in va_list ArgPtr + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ _Printf_format_string_ PWSTR Format, + _In_ va_list ArgPtr ); PHLIBAPI VOID NTAPI PhInsertStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T Index, - __in PPH_STRING String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T Index, + _In_ PPH_STRING String ); PHLIBAPI VOID NTAPI PhInsertStringBuilder2( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T Index, - __in PWSTR String + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T Index, + _In_ PWSTR String ); PHLIBAPI VOID NTAPI PhInsertStringBuilderEx( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T Index, - __in_opt PWSTR String, - __in SIZE_T Length + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T Index, + _In_opt_ PWCHAR String, + _In_ SIZE_T Length ); PHLIBAPI VOID NTAPI PhRemoveStringBuilder( - __inout PPH_STRING_BUILDER StringBuilder, - __in SIZE_T StartIndex, - __in SIZE_T Count + _Inout_ PPH_STRING_BUILDER StringBuilder, + _In_ SIZE_T StartIndex, + _In_ SIZE_T Count ); // list @@ -1975,84 +1977,84 @@ PHLIBAPI PPH_LIST NTAPI PhCreateList( - __in ULONG InitialCapacity + _In_ ULONG InitialCapacity ); PHLIBAPI VOID NTAPI PhResizeList( - __inout PPH_LIST List, - __in ULONG NewCapacity + _Inout_ PPH_LIST List, + _In_ ULONG NewCapacity ); PHLIBAPI VOID NTAPI PhAddItemList( - __inout PPH_LIST List, - __in PVOID Item + _Inout_ PPH_LIST List, + _In_ PVOID Item ); PHLIBAPI VOID NTAPI PhAddItemsList( - __inout PPH_LIST List, - __in PVOID *Items, - __in ULONG Count + _Inout_ PPH_LIST List, + _In_ PVOID *Items, + _In_ ULONG Count ); PHLIBAPI VOID NTAPI PhClearList( - __inout PPH_LIST List + _Inout_ PPH_LIST List ); -__success(return != -1) +_Success_(return != -1) PHLIBAPI ULONG NTAPI PhFindItemList( - __in PPH_LIST List, - __in PVOID Item + _In_ PPH_LIST List, + _In_ PVOID Item ); PHLIBAPI VOID NTAPI PhInsertItemList( - __inout PPH_LIST List, - __in ULONG Index, - __in PVOID Item + _Inout_ PPH_LIST List, + _In_ ULONG Index, + _In_ PVOID Item ); PHLIBAPI VOID NTAPI PhInsertItemsList( - __inout PPH_LIST List, - __in ULONG Index, - __in PVOID *Items, - __in ULONG Count + _Inout_ PPH_LIST List, + _In_ ULONG Index, + _In_ PVOID *Items, + _In_ ULONG Count ); PHLIBAPI VOID NTAPI PhRemoveItemList( - __inout PPH_LIST List, - __in ULONG Index + _Inout_ PPH_LIST List, + _In_ ULONG Index ); PHLIBAPI VOID NTAPI PhRemoveItemsList( - __inout PPH_LIST List, - __in ULONG StartIndex, - __in ULONG Count + _Inout_ PPH_LIST List, + _In_ ULONG StartIndex, + _In_ ULONG Count ); /** @@ -2068,9 +2070,9 @@ PhRemoveItemsList( * \li 0 if \a Item1 = \a Item2. */ typedef LONG (NTAPI *PPH_COMPARE_FUNCTION)( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ); // pointer list @@ -2103,47 +2105,47 @@ PHLIBAPI PPH_POINTER_LIST NTAPI PhCreatePointerList( - __in ULONG InitialCapacity + _In_ ULONG InitialCapacity ); PHLIBAPI HANDLE NTAPI PhAddItemPointerList( - __inout PPH_POINTER_LIST PointerList, - __in PVOID Pointer + _Inout_ PPH_POINTER_LIST PointerList, + _In_ PVOID Pointer ); PHLIBAPI BOOLEAN NTAPI PhEnumPointerListEx( - __in PPH_POINTER_LIST PointerList, - __inout PULONG EnumerationKey, - __out PVOID *Pointer, - __out PHANDLE PointerHandle + _In_ PPH_POINTER_LIST PointerList, + _Inout_ PULONG EnumerationKey, + _Out_ PVOID *Pointer, + _Out_ PHANDLE PointerHandle ); PHLIBAPI HANDLE NTAPI PhFindItemPointerList( - __in PPH_POINTER_LIST PointerList, - __in PVOID Pointer + _In_ PPH_POINTER_LIST PointerList, + _In_ PVOID Pointer ); PHLIBAPI VOID NTAPI PhRemoveItemPointerList( - __inout PPH_POINTER_LIST PointerList, - __in HANDLE PointerHandle + _Inout_ PPH_POINTER_LIST PointerList, + _In_ HANDLE PointerHandle ); FORCEINLINE BOOLEAN PhEnumPointerList( - __in PPH_POINTER_LIST PointerList, - __inout PULONG EnumerationKey, - __out PVOID *Pointer + _In_ PPH_POINTER_LIST PointerList, + _Inout_ PULONG EnumerationKey, + _Out_ PVOID *Pointer ) { while (*EnumerationKey < PointerList->NextEntry) @@ -2180,8 +2182,8 @@ typedef struct _PH_HASH_ENTRY * \param NumberOfBuckets The number of buckets. */ FORCEINLINE VOID PhInitializeHashSet( - __out PPH_HASH_ENTRY *Buckets, - __in ULONG NumberOfBuckets + _Out_ PPH_HASH_ENTRY *Buckets, + _In_ ULONG NumberOfBuckets ) { memset(Buckets, 0, sizeof(PPH_HASH_ENTRY) * NumberOfBuckets); @@ -2196,7 +2198,7 @@ FORCEINLINE VOID PhInitializeHashSet( * PhFree() when you no longer need it. */ FORCEINLINE PPH_HASH_ENTRY *PhCreateHashSet( - __in ULONG NumberOfBuckets + _In_ ULONG NumberOfBuckets ) { PPH_HASH_ENTRY *buckets; @@ -2216,8 +2218,8 @@ FORCEINLINE PPH_HASH_ENTRY *PhCreateHashSet( * \return The number of entries in the hash set. */ FORCEINLINE ULONG PhCountHashSet( - __in PPH_HASH_ENTRY *Buckets, - __in ULONG NumberOfBuckets + _In_ PPH_HASH_ENTRY *Buckets, + _In_ ULONG NumberOfBuckets ) { ULONG i; @@ -2246,10 +2248,10 @@ FORCEINLINE ULONG PhCountHashSet( * \remarks \a NewBuckets and \a OldBuckets must be different. */ FORCEINLINE VOID PhDistributeHashSet( - __inout PPH_HASH_ENTRY *NewBuckets, - __in ULONG NumberOfNewBuckets, - __in PPH_HASH_ENTRY *OldBuckets, - __in ULONG NumberOfOldBuckets + _Inout_ PPH_HASH_ENTRY *NewBuckets, + _In_ ULONG NumberOfNewBuckets, + _In_ PPH_HASH_ENTRY *OldBuckets, + _In_ ULONG NumberOfOldBuckets ) { ULONG i; @@ -2285,10 +2287,10 @@ FORCEINLINE VOID PhDistributeHashSet( * \remarks This function does not check for duplicates. */ FORCEINLINE VOID PhAddEntryHashSet( - __inout PPH_HASH_ENTRY *Buckets, - __in ULONG NumberOfBuckets, - __out PPH_HASH_ENTRY Entry, - __in ULONG Hash + _Inout_ PPH_HASH_ENTRY *Buckets, + _In_ ULONG NumberOfBuckets, + _Out_ PPH_HASH_ENTRY Entry, + _In_ ULONG Hash ) { ULONG index; @@ -2313,9 +2315,9 @@ FORCEINLINE VOID PhAddEntryHashSet( * does not exist in the hash set. */ FORCEINLINE PPH_HASH_ENTRY PhFindEntryHashSet( - __in PPH_HASH_ENTRY *Buckets, - __in ULONG NumberOfBuckets, - __in ULONG Hash + _In_ PPH_HASH_ENTRY *Buckets, + _In_ ULONG NumberOfBuckets, + _In_ ULONG Hash ) { return Buckets[Hash & (NumberOfBuckets - 1)]; @@ -2329,9 +2331,9 @@ FORCEINLINE PPH_HASH_ENTRY PhFindEntryHashSet( * \param Entry An entry present in the hash set. */ FORCEINLINE VOID PhRemoveEntryHashSet( - __inout PPH_HASH_ENTRY *Buckets, - __in ULONG NumberOfBuckets, - __inout PPH_HASH_ENTRY Entry + _Inout_ PPH_HASH_ENTRY *Buckets, + _In_ ULONG NumberOfBuckets, + _Inout_ PPH_HASH_ENTRY Entry ) { ULONG index; @@ -2373,9 +2375,9 @@ FORCEINLINE VOID PhRemoveEntryHashSet( * \param NewNumberOfBuckets The new number of buckets. */ FORCEINLINE VOID PhResizeHashSet( - __inout PPH_HASH_ENTRY **Buckets, - __inout PULONG NumberOfBuckets, - __in ULONG NewNumberOfBuckets + _Inout_ PPH_HASH_ENTRY **Buckets, + _Inout_ PULONG NumberOfBuckets, + _In_ ULONG NewNumberOfBuckets ) { PPH_HASH_ENTRY *newBuckets; @@ -2414,8 +2416,8 @@ typedef struct _PH_HASHTABLE_ENTRY * FALSE. */ typedef BOOLEAN (NTAPI *PPH_HASHTABLE_COMPARE_FUNCTION)( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); /** @@ -2433,7 +2435,7 @@ typedef BOOLEAN (NTAPI *PPH_HASHTABLE_COMPARE_FUNCTION)( * different hash codes. */ typedef ULONG (NTAPI *PPH_HASHTABLE_HASH_FUNCTION)( - __in PVOID Entry + _In_ PVOID Entry ); // Use power-of-two sizes instead of primes @@ -2485,59 +2487,59 @@ PHLIBAPI PPH_HASHTABLE NTAPI PhCreateHashtable( - __in ULONG EntrySize, - __in PPH_HASHTABLE_COMPARE_FUNCTION CompareFunction, - __in PPH_HASHTABLE_HASH_FUNCTION HashFunction, - __in ULONG InitialCapacity + _In_ ULONG EntrySize, + _In_ PPH_HASHTABLE_COMPARE_FUNCTION CompareFunction, + _In_ PPH_HASHTABLE_HASH_FUNCTION HashFunction, + _In_ ULONG InitialCapacity ); PHLIBAPI PVOID NTAPI PhAddEntryHashtable( - __inout PPH_HASHTABLE Hashtable, - __in PVOID Entry + _Inout_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry ); PHLIBAPI PVOID NTAPI PhAddEntryHashtableEx( - __inout PPH_HASHTABLE Hashtable, - __in PVOID Entry, - __out_opt PBOOLEAN Added + _Inout_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry, + _Out_opt_ PBOOLEAN Added ); PHLIBAPI VOID NTAPI PhClearHashtable( - __inout PPH_HASHTABLE Hashtable + _Inout_ PPH_HASHTABLE Hashtable ); PHLIBAPI BOOLEAN NTAPI PhEnumHashtable( - __in PPH_HASHTABLE Hashtable, - __out PVOID *Entry, - __inout PULONG EnumerationKey + _In_ PPH_HASHTABLE Hashtable, + _Out_ PVOID *Entry, + _Inout_ PULONG EnumerationKey ); PHLIBAPI PVOID NTAPI PhFindEntryHashtable( - __in PPH_HASHTABLE Hashtable, - __in PVOID Entry + _In_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry ); PHLIBAPI BOOLEAN NTAPI PhRemoveEntryHashtable( - __inout PPH_HASHTABLE Hashtable, - __in PVOID Entry + _Inout_ PPH_HASHTABLE Hashtable, + _In_ PVOID Entry ); // New faster enumeration method @@ -2550,8 +2552,8 @@ typedef struct _PH_HASHTABLE_ENUM_CONTEXT } PH_HASHTABLE_ENUM_CONTEXT, *PPH_HASHTABLE_ENUM_CONTEXT; FORCEINLINE VOID PhBeginEnumHashtable( - __in PPH_HASHTABLE Hashtable, - __out PPH_HASHTABLE_ENUM_CONTEXT Context + _In_ PPH_HASHTABLE Hashtable, + _Out_ PPH_HASHTABLE_ENUM_CONTEXT Context ) { Context->Current = (ULONG_PTR)Hashtable->Entries; @@ -2560,7 +2562,7 @@ FORCEINLINE VOID PhBeginEnumHashtable( } FORCEINLINE PVOID PhNextEnumHashtable( - __inout PPH_HASHTABLE_ENUM_CONTEXT Context + _Inout_ PPH_HASHTABLE_ENUM_CONTEXT Context ) { PPH_HASHTABLE_ENTRY entry; @@ -2584,8 +2586,8 @@ PHLIBAPI ULONG FASTCALL PhfHashBytesHsieh( - __in PUCHAR Bytes, - __in SIZE_T Length + _In_ PUCHAR Bytes, + _In_ SIZE_T Length ); #define PhHashBytesMurmur PhfHashBytesMurmur @@ -2593,8 +2595,8 @@ PHLIBAPI ULONG FASTCALL PhfHashBytesMurmur( - __in PUCHAR Bytes, - __in SIZE_T Length + _In_ PUCHAR Bytes, + _In_ SIZE_T Length ); #define PhHashBytesSdbm PhfHashBytesSdbm @@ -2602,12 +2604,12 @@ PHLIBAPI ULONG FASTCALL PhfHashBytesSdbm( - __in PUCHAR Bytes, - __in SIZE_T Length + _In_ PUCHAR Bytes, + _In_ SIZE_T Length ); FORCEINLINE ULONG PhHashInt32( - __in ULONG Value + _In_ ULONG Value ) { // Java style. @@ -2616,7 +2618,7 @@ FORCEINLINE ULONG PhHashInt32( } FORCEINLINE ULONG PhHashInt64( - __in ULONG64 Value + _In_ ULONG64 Value ) { // http://www.concentric.net/~Ttwang/tech/inthash.htm @@ -2643,32 +2645,32 @@ PHLIBAPI PPH_HASHTABLE NTAPI PhCreateSimpleHashtable( - __in ULONG InitialCapacity + _In_ ULONG InitialCapacity ); PHLIBAPI PVOID NTAPI PhAddItemSimpleHashtable( - __inout PPH_HASHTABLE SimpleHashtable, - __in_opt PVOID Key, - __in_opt PVOID Value + _Inout_ PPH_HASHTABLE SimpleHashtable, + _In_opt_ PVOID Key, + _In_opt_ PVOID Value ); PHLIBAPI PVOID * NTAPI PhFindItemSimpleHashtable( - __in PPH_HASHTABLE SimpleHashtable, - __in_opt PVOID Key + _In_ PPH_HASHTABLE SimpleHashtable, + _In_opt_ PVOID Key ); PHLIBAPI BOOLEAN NTAPI PhRemoveItemSimpleHashtable( - __inout PPH_HASHTABLE SimpleHashtable, - __in_opt PVOID Key + _Inout_ PPH_HASHTABLE SimpleHashtable, + _In_opt_ PVOID Key ); // free list @@ -2700,31 +2702,31 @@ PHLIBAPI VOID NTAPI PhInitializeFreeList( - __out PPH_FREE_LIST FreeList, - __in SIZE_T Size, - __in ULONG MaximumCount + _Out_ PPH_FREE_LIST FreeList, + _In_ SIZE_T Size, + _In_ ULONG MaximumCount ); PHLIBAPI VOID NTAPI PhDeleteFreeList( - __inout PPH_FREE_LIST FreeList + _Inout_ PPH_FREE_LIST FreeList ); PHLIBAPI PVOID NTAPI PhAllocateFromFreeList( - __inout PPH_FREE_LIST FreeList + _Inout_ PPH_FREE_LIST FreeList ); PHLIBAPI VOID NTAPI PhFreeToFreeList( - __inout PPH_FREE_LIST FreeList, - __in PVOID Memory + _Inout_ PPH_FREE_LIST FreeList, + _In_ PVOID Memory ); // callback @@ -2738,8 +2740,8 @@ PhFreeToFreeList( * to PhRegisterCallback(). */ typedef VOID (NTAPI *PPH_CALLBACK_FUNCTION)( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); /** @@ -2788,51 +2790,51 @@ PHLIBAPI VOID NTAPI PhInitializeCallback( - __out PPH_CALLBACK Callback + _Out_ PPH_CALLBACK Callback ); PHLIBAPI VOID NTAPI PhDeleteCallback( - __inout PPH_CALLBACK Callback + _Inout_ PPH_CALLBACK Callback ); PHLIBAPI VOID NTAPI PhRegisterCallback( - __inout PPH_CALLBACK Callback, - __in PPH_CALLBACK_FUNCTION Function, - __in_opt PVOID Context, - __out PPH_CALLBACK_REGISTRATION Registration + _Inout_ PPH_CALLBACK Callback, + _In_ PPH_CALLBACK_FUNCTION Function, + _In_opt_ PVOID Context, + _Out_ PPH_CALLBACK_REGISTRATION Registration ); PHLIBAPI VOID NTAPI PhRegisterCallbackEx( - __inout PPH_CALLBACK Callback, - __in PPH_CALLBACK_FUNCTION Function, - __in_opt PVOID Context, - __in USHORT Flags, - __out PPH_CALLBACK_REGISTRATION Registration + _Inout_ PPH_CALLBACK Callback, + _In_ PPH_CALLBACK_FUNCTION Function, + _In_opt_ PVOID Context, + _In_ USHORT Flags, + _Out_ PPH_CALLBACK_REGISTRATION Registration ); PHLIBAPI VOID NTAPI PhUnregisterCallback( - __inout PPH_CALLBACK Callback, - __inout PPH_CALLBACK_REGISTRATION Registration + _Inout_ PPH_CALLBACK Callback, + _Inout_ PPH_CALLBACK_REGISTRATION Registration ); PHLIBAPI VOID NTAPI PhInvokeCallback( - __in PPH_CALLBACK Callback, - __in_opt PVOID Parameter + _In_ PPH_CALLBACK Callback, + _In_opt_ PVOID Parameter ); // general @@ -2841,71 +2843,79 @@ PHLIBAPI ULONG NTAPI PhGetPrimeNumber( - __in ULONG Minimum + _In_ ULONG Minimum ); PHLIBAPI ULONG NTAPI PhRoundUpToPowerOfTwo( - __in ULONG Number + _In_ ULONG Number ); PHLIBAPI ULONG NTAPI PhExponentiate( - __in ULONG Base, - __in ULONG Exponent + _In_ ULONG Base, + _In_ ULONG Exponent ); PHLIBAPI ULONG64 NTAPI PhExponentiate64( - __in ULONG64 Base, - __in ULONG Exponent + _In_ ULONG64 Base, + _In_ ULONG Exponent ); PHLIBAPI ULONG NTAPI PhLog2( - __in ULONG Exponent + _In_ ULONG Exponent ); PHLIBAPI BOOLEAN NTAPI PhHexStringToBuffer( - __in PPH_STRINGREF String, - __out_bcount(String->Length / sizeof(WCHAR) / 2) PUCHAR Buffer + _In_ PPH_STRINGREF String, + _Out_writes_bytes_(String->Length / sizeof(WCHAR) / 2) PUCHAR Buffer ); PHLIBAPI PPH_STRING NTAPI PhBufferToHexString( - __in PUCHAR Buffer, - __in ULONG Length + _In_reads_bytes_(Length) PUCHAR Buffer, + _In_ ULONG Length + ); + +PPH_STRING +NTAPI +PhBufferToHexStringEx( + _In_reads_bytes_(Length) PUCHAR Buffer, + _In_ ULONG Length, + _In_ BOOLEAN UpperCase ); PHLIBAPI BOOLEAN NTAPI PhStringToInteger64( - __in PPH_STRINGREF String, - __in_opt ULONG Base, - __out_opt PLONG64 Integer + _In_ PPH_STRINGREF String, + _In_opt_ ULONG Base, + _Out_opt_ PLONG64 Integer ); PHLIBAPI PPH_STRING NTAPI PhIntegerToString64( - __in LONG64 Integer, - __in_opt ULONG Base, - __in BOOLEAN Signed + _In_ LONG64 Integer, + _In_opt_ ULONG Base, + _In_ BOOLEAN Signed ); #define PH_TIMESPAN_STR_LEN 30 @@ -2919,18 +2929,18 @@ PHLIBAPI VOID NTAPI PhPrintTimeSpan( - __out_ecount(PH_TIMESPAN_STR_LEN_1) PWSTR Destination, - __in ULONG64 Ticks, - __in_opt ULONG Mode + _Out_writes_(PH_TIMESPAN_STR_LEN_1) PWSTR Destination, + _In_ ULONG64 Ticks, + _In_opt_ ULONG Mode ); // format VOID PhZeroExtendToUnicode( - __in_bcount(InputLength) PSTR Input, - __in ULONG InputLength, - __out_bcount(InputLength * 2) PWSTR Output + _In_reads_bytes_(InputLength) PSTR Input, + _In_ ULONG InputLength, + _Out_writes_bytes_(InputLength * 2) PWSTR Output ); typedef enum _PH_FORMAT_TYPE @@ -3053,20 +3063,20 @@ PHLIBAPI PPH_STRING NTAPI PhFormat( - __in_ecount(Count) PPH_FORMAT Format, - __in ULONG Count, - __in_opt SIZE_T InitialCapacity + _In_reads_(Count) PPH_FORMAT Format, + _In_ ULONG Count, + _In_opt_ SIZE_T InitialCapacity ); PHLIBAPI BOOLEAN NTAPI PhFormatToBuffer( - __in_ecount(Count) PPH_FORMAT Format, - __in ULONG Count, - __out_bcount_opt(BufferLength) PWSTR Buffer, - __in_opt SIZE_T BufferLength, - __out_opt PSIZE_T ReturnLength + _In_reads_(Count) PPH_FORMAT Format, + _In_ ULONG Count, + _Out_writes_bytes_opt_(BufferLength) PWSTR Buffer, + _In_opt_ SIZE_T BufferLength, + _Out_opt_ PSIZE_T ReturnLength ); // basesupa @@ -3075,29 +3085,29 @@ PHLIBAPI PPH_STRING NTAPI PhaCreateString( - __in PWSTR Buffer + _In_ PWSTR Buffer ); PHLIBAPI PPH_STRING NTAPI PhaCreateStringEx( - __in_opt PWSTR Buffer, - __in SIZE_T Length + _In_opt_ PWSTR Buffer, + _In_ SIZE_T Length ); PHLIBAPI PPH_STRING NTAPI PhaDuplicateString( - __in PPH_STRING String + _In_ PPH_STRING String ); PHLIBAPI PPH_STRING NTAPI PhaConcatStrings( - __in ULONG Count, + _In_ ULONG Count, ... ); @@ -3105,15 +3115,15 @@ PHLIBAPI PPH_STRING NTAPI PhaConcatStrings2( - __in PWSTR String1, - __in PWSTR String2 + _In_ PWSTR String1, + _In_ PWSTR String2 ); PHLIBAPI PPH_STRING NTAPI PhaFormatString( - __in __format_string PWSTR Format, + _In_ _Printf_format_string_ PWSTR Format, ... ); @@ -3121,23 +3131,23 @@ PHLIBAPI PPH_STRING NTAPI PhaLowerString( - __in PPH_STRING String + _In_ PPH_STRING String ); PHLIBAPI PPH_STRING NTAPI PhaUpperString( - __in PPH_STRING String + _In_ PPH_STRING String ); PHLIBAPI PPH_STRING NTAPI PhaSubstring( - __in PPH_STRING String, - __in SIZE_T StartIndex, - __in SIZE_T Count + _In_ PPH_STRING String, + _In_ SIZE_T StartIndex, + _In_ SIZE_T Count ); // basesupx (extra) @@ -3146,45 +3156,45 @@ PHLIBAPI VOID FASTCALL PhxfFillMemoryUlong( - __inout PULONG Memory, - __in ULONG Value, - __in ULONG Count + _Inout_ PULONG Memory, + _In_ ULONG Value, + _In_ ULONG Count ); PHLIBAPI VOID FASTCALL PhxfAddInt32( - __inout __needsAlign(16) PLONG A, - __in __needsAlign(16) PLONG B, - __in ULONG Count + _Inout_ _Needs_align_(16) PLONG A, + _In_ _Needs_align_(16) PLONG B, + _In_ ULONG Count ); PHLIBAPI VOID FASTCALL PhxfAddInt32U( - __inout PLONG A, - __in PLONG B, - __in ULONG Count + _Inout_ PLONG A, + _In_ PLONG B, + _In_ ULONG Count ); PHLIBAPI VOID FASTCALL PhxfDivideSingleU( - __inout PFLOAT A, - __in PFLOAT B, - __in ULONG Count + _Inout_ PFLOAT A, + _In_ PFLOAT B, + _In_ ULONG Count ); PHLIBAPI VOID FASTCALL PhxfDivideSingle2U( - __inout PFLOAT A, - __in FLOAT B, - __in ULONG Count + _Inout_ PFLOAT A, + _In_ FLOAT B, + _In_ ULONG Count ); // error @@ -3193,21 +3203,21 @@ PHLIBAPI ULONG NTAPI PhNtStatusToDosError( - __in NTSTATUS Status + _In_ NTSTATUS Status ); PHLIBAPI NTSTATUS NTAPI PhDosErrorToNtStatus( - __in ULONG DosError + _In_ ULONG DosError ); PHLIBAPI BOOLEAN NTAPI PhNtStatusFileNotFound( - __in NTSTATUS Status + _In_ NTSTATUS Status ); // collect @@ -3236,8 +3246,8 @@ typedef struct _PH_AVL_LINKS struct _PH_AVL_TREE; typedef LONG (NTAPI *PPH_AVL_TREE_COMPARE_FUNCTION)( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ); typedef struct _PH_AVL_TREE @@ -3256,85 +3266,85 @@ PHLIBAPI VOID NTAPI PhInitializeAvlTree( - __out PPH_AVL_TREE Tree, - __in PPH_AVL_TREE_COMPARE_FUNCTION CompareFunction + _Out_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_TREE_COMPARE_FUNCTION CompareFunction ); PHLIBAPI PPH_AVL_LINKS NTAPI PhAddElementAvlTree( - __inout PPH_AVL_TREE Tree, - __out PPH_AVL_LINKS Element + _Inout_ PPH_AVL_TREE Tree, + _Out_ PPH_AVL_LINKS Element ); PHLIBAPI VOID NTAPI PhRemoveElementAvlTree( - __inout PPH_AVL_TREE Tree, - __inout PPH_AVL_LINKS Element + _Inout_ PPH_AVL_TREE Tree, + _Inout_ PPH_AVL_LINKS Element ); PHLIBAPI PPH_AVL_LINKS NTAPI PhFindElementAvlTree( - __in PPH_AVL_TREE Tree, - __in PPH_AVL_LINKS Element + _In_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_LINKS Element ); PHLIBAPI PPH_AVL_LINKS NTAPI PhFindElementAvlTree2( - __in PPH_AVL_TREE Tree, - __in PPH_AVL_LINKS Element, - __out PLONG Result + _In_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_LINKS Element, + _Out_ PLONG Result ); PHLIBAPI PPH_AVL_LINKS NTAPI PhMinimumElementAvlTree( - __in PPH_AVL_TREE Tree + _In_ PPH_AVL_TREE Tree ); PHLIBAPI PPH_AVL_LINKS NTAPI PhMaximumElementAvlTree( - __in PPH_AVL_TREE Tree + _In_ PPH_AVL_TREE Tree ); PHLIBAPI PPH_AVL_LINKS NTAPI PhSuccessorElementAvlTree( - __in PPH_AVL_LINKS Element + _In_ PPH_AVL_LINKS Element ); PHLIBAPI PPH_AVL_LINKS NTAPI PhPredecessorElementAvlTree( - __in PPH_AVL_LINKS Element + _In_ PPH_AVL_LINKS Element ); typedef BOOLEAN (NTAPI *PPH_ENUM_AVL_TREE_CALLBACK)( - __in PPH_AVL_TREE Tree, - __in PPH_AVL_LINKS Element, - __in_opt PVOID Context + _In_ PPH_AVL_TREE Tree, + _In_ PPH_AVL_LINKS Element, + _In_opt_ PVOID Context ); PHLIBAPI VOID NTAPI PhEnumAvlTree( - __in PPH_AVL_TREE Tree, - __in PH_TREE_ENUMERATION_ORDER Order, - __in PPH_ENUM_AVL_TREE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_AVL_TREE Tree, + _In_ PH_TREE_ENUMERATION_ORDER Order, + _In_ PPH_ENUM_AVL_TREE_CALLBACK Callback, + _In_opt_ PVOID Context ); // handle @@ -3390,73 +3400,73 @@ PHLIBAPI VOID NTAPI PhDestroyHandleTable( - __in __post_invalid PPH_HANDLE_TABLE HandleTable + _In_ _Post_invalid_ PPH_HANDLE_TABLE HandleTable ); PHLIBAPI BOOLEAN NTAPI PhLockHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __inout PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _Inout_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ); PHLIBAPI VOID NTAPI PhUnlockHandleTableEntry( - __inout PPH_HANDLE_TABLE HandleTable, - __inout PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _Inout_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ); PHLIBAPI HANDLE NTAPI PhCreateHandle( - __inout PPH_HANDLE_TABLE HandleTable, - __in PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ); PHLIBAPI BOOLEAN NTAPI PhDestroyHandle( - __inout PPH_HANDLE_TABLE HandleTable, - __in HANDLE Handle, - __in_opt __assumeLocked PPH_HANDLE_TABLE_ENTRY HandleTableEntry + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ HANDLE Handle, + _In_opt_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry ); PHLIBAPI PPH_HANDLE_TABLE_ENTRY NTAPI PhLookupHandleTableEntry( - __in PPH_HANDLE_TABLE HandleTable, - __in HANDLE Handle + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ HANDLE Handle ); typedef BOOLEAN (NTAPI *PPH_ENUM_HANDLE_TABLE_CALLBACK)( - __in PPH_HANDLE_TABLE HandleTable, - __in HANDLE Handle, - __in PPH_HANDLE_TABLE_ENTRY HandleTableEntry, - __in_opt PVOID Context + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ HANDLE Handle, + _In_ PPH_HANDLE_TABLE_ENTRY HandleTableEntry, + _In_opt_ PVOID Context ); PHLIBAPI VOID NTAPI PhEnumHandleTable( - __in PPH_HANDLE_TABLE HandleTable, - __in PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, + _In_opt_ PVOID Context ); PHLIBAPI VOID NTAPI PhSweepHandleTable( - __in PPH_HANDLE_TABLE HandleTable, - __in PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ PPH_ENUM_HANDLE_TABLE_CALLBACK Callback, + _In_opt_ PVOID Context ); typedef enum _PH_HANDLE_TABLE_INFORMATION_CLASS @@ -3482,35 +3492,32 @@ PHLIBAPI NTSTATUS NTAPI PhQueryInformationHandleTable( - __in PPH_HANDLE_TABLE HandleTable, - __in PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, - __out_bcount_opt(BufferLength) PVOID Buffer, - __in ULONG BufferLength, - __out_opt PULONG ReturnLength + _In_ PPH_HANDLE_TABLE HandleTable, + _In_ PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, + _Out_writes_bytes_opt_(BufferLength) PVOID Buffer, + _In_ ULONG BufferLength, + _Out_opt_ PULONG ReturnLength ); PHLIBAPI NTSTATUS NTAPI PhSetInformationHandleTable( - __inout PPH_HANDLE_TABLE HandleTable, - __in PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, - __in_bcount(BufferLength) PVOID Buffer, - __in ULONG BufferLength + _Inout_ PPH_HANDLE_TABLE HandleTable, + _In_ PH_HANDLE_TABLE_INFORMATION_CLASS InformationClass, + _In_reads_bytes_(BufferLength) PVOID Buffer, + _In_ ULONG BufferLength ); // workqueue #if !defined(_PH_WORKQUEUE_PRIVATE) && defined(DEBUG) -extern LIST_ENTRY PhDbgWorkQueueListHead; +extern PPH_LIST PhDbgWorkQueueList; extern PH_QUEUED_LOCK PhDbgWorkQueueListLock; #endif typedef struct _PH_WORK_QUEUE { -#ifdef DEBUG - LIST_ENTRY DbgListEntry; -#endif PH_RUNDOWN_PROTECT RundownProtect; BOOLEAN Terminating; @@ -3542,34 +3549,34 @@ PHLIBAPI VOID NTAPI PhInitializeWorkQueue( - __out PPH_WORK_QUEUE WorkQueue, - __in ULONG MinimumThreads, - __in ULONG MaximumThreads, - __in ULONG NoWorkTimeout + _Out_ PPH_WORK_QUEUE WorkQueue, + _In_ ULONG MinimumThreads, + _In_ ULONG MaximumThreads, + _In_ ULONG NoWorkTimeout ); PHLIBAPI VOID NTAPI PhDeleteWorkQueue( - __inout PPH_WORK_QUEUE WorkQueue + _Inout_ PPH_WORK_QUEUE WorkQueue ); PHLIBAPI VOID NTAPI PhQueueItemWorkQueue( - __inout PPH_WORK_QUEUE WorkQueue, - __in PTHREAD_START_ROUTINE Function, - __in_opt PVOID Context + _Inout_ PPH_WORK_QUEUE WorkQueue, + _In_ PTHREAD_START_ROUTINE Function, + _In_opt_ PVOID Context ); PHLIBAPI VOID NTAPI PhQueueItemGlobalWorkQueue( - __in PTHREAD_START_ROUTINE Function, - __in_opt PVOID Context + _In_ PTHREAD_START_ROUTINE Function, + _In_opt_ PVOID Context ); #ifdef __cplusplus diff --git a/2.x/trunk/phlib/include/phgui.h b/2.x/trunk/phlib/include/phgui.h index 8982374c3..ff7e4955c 100644 --- a/2.x/trunk/phlib/include/phgui.h +++ b/2.x/trunk/phlib/include/phgui.h @@ -13,12 +13,12 @@ extern "C" { // guisup typedef BOOL (WINAPI *_ChangeWindowMessageFilter)( - __in UINT message, - __in DWORD dwFlag + _In_ UINT message, + _In_ DWORD dwFlag ); typedef BOOL (WINAPI *_IsImmersiveProcess)( - __in HANDLE hProcess + _In_ HANDLE hProcess ); #define RFF_NOBROWSE 0x0001 @@ -48,12 +48,12 @@ typedef LPNMRUNFILEDLGW LPNMRUNFILEDLG; typedef HANDLE HTHEME; typedef BOOL (WINAPI *_RunFileDlg)( - __in HWND hwndOwner, - __in_opt HICON hIcon, - __in_opt LPCWSTR lpszDirectory, - __in_opt LPCWSTR lpszTitle, - __in_opt LPCWSTR lpszDescription, - __in ULONG uFlags + _In_ HWND hwndOwner, + _In_opt_ HICON hIcon, + _In_opt_ LPCWSTR lpszDirectory, + _In_opt_ LPCWSTR lpszTitle, + _In_opt_ LPCWSTR lpszDescription, + _In_ ULONG uFlags ); typedef BOOL (WINAPI *_IsThemeActive)( @@ -61,59 +61,59 @@ typedef BOOL (WINAPI *_IsThemeActive)( ); typedef HTHEME (WINAPI *_OpenThemeData)( - __in HWND hwnd, - __in LPCWSTR pszClassList + _In_ HWND hwnd, + _In_ LPCWSTR pszClassList ); typedef HRESULT (WINAPI *_CloseThemeData)( - __in HTHEME hTheme + _In_ HTHEME hTheme ); typedef BOOL (WINAPI *_IsThemePartDefined)( - __in HTHEME hTheme, - __in int iPartId, - __in int iStateId + _In_ HTHEME hTheme, + _In_ int iPartId, + _In_ int iStateId ); typedef HRESULT (WINAPI *_DrawThemeBackground)( - __in HTHEME hTheme, - __in HDC hdc, - __in int iPartId, - __in int iStateId, - __in const RECT *pRect, - __in const RECT *pClipRect + _In_ HTHEME hTheme, + _In_ HDC hdc, + _In_ int iPartId, + _In_ int iStateId, + _In_ const RECT *pRect, + _In_ const RECT *pClipRect ); typedef HRESULT (WINAPI *_DrawThemeText)( - __in HTHEME hTheme, - __in HDC hdc, - __in int iPartId, - __in int iStateId, - __in_ecount(cchText) LPCWSTR pszText, - __in int cchText, - __in DWORD dwTextFlags, - __reserved DWORD dwTextFlags2, - __in LPCRECT pRect + _In_ HTHEME hTheme, + _In_ HDC hdc, + _In_ int iPartId, + _In_ int iStateId, + _In_reads_(cchText) LPCWSTR pszText, + _In_ int cchText, + _In_ DWORD dwTextFlags, + _Reserved_ DWORD dwTextFlags2, + _In_ LPCRECT pRect ); typedef HRESULT (WINAPI *_GetThemeInt)( - __in HTHEME hTheme, - __in int iPartId, - __in int iStateId, - __in int iPropId, - __out int *piVal + _In_ HTHEME hTheme, + _In_ int iPartId, + _In_ int iStateId, + _In_ int iPropId, + _Out_ int *piVal ); typedef HRESULT (WINAPI *_SHAutoComplete)( - __in HWND hwndEdit, - __in DWORD dwFlags + _In_ HWND hwndEdit, + _In_ DWORD dwFlags ); typedef HRESULT (WINAPI *_TaskDialogIndirect)( - __in const TASKDIALOGCONFIG *pTaskConfig, - __in int *pnButton, - __in int *pnRadioButton, - __in BOOL *pfVerificationFlagChecked + _In_ const TASKDIALOGCONFIG *pTaskConfig, + _In_ int *pnButton, + _In_ int *pnRadioButton, + _In_ BOOL *pfVerificationFlagChecked ); #ifndef _PH_GUISUP_PRIVATE @@ -137,14 +137,14 @@ VOID PhGuiSupportInitialization( PHLIBAPI VOID PhSetControlTheme( - __in HWND Handle, - __in PWSTR Theme + _In_ HWND Handle, + _In_ PWSTR Theme ); FORCEINLINE VOID PhSetWindowStyle( - __in HWND Handle, - __in LONG_PTR Mask, - __in LONG_PTR Value + _In_ HWND Handle, + _In_ LONG_PTR Mask, + _In_ LONG_PTR Value ) { LONG_PTR style; @@ -155,9 +155,9 @@ FORCEINLINE VOID PhSetWindowStyle( } FORCEINLINE VOID PhSetWindowExStyle( - __in HWND Handle, - __in LONG_PTR Mask, - __in LONG_PTR Value + _In_ HWND Handle, + _In_ LONG_PTR Mask, + _In_ LONG_PTR Value ) { LONG_PTR style; @@ -191,10 +191,10 @@ FORCEINLINE VOID PhSetWindowExStyle( } FORCEINLINE LRESULT PhReflectMessage( - __in HWND Handle, - __in UINT Message, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND Handle, + _In_ UINT Message, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { if (Message == WM_NOTIFY) @@ -227,14 +227,14 @@ do { \ } while (0) HWND PhCreateListViewControl( - __in HWND ParentHandle, - __in INT_PTR Id + _In_ HWND ParentHandle, + _In_ INT_PTR Id ); FORCEINLINE VOID PhSetListViewStyle( - __in HWND Handle, - __in BOOLEAN AllowDragDrop, - __in BOOLEAN ShowLabelTips + _In_ HWND Handle, + _In_ BOOLEAN AllowDragDrop, + _In_ BOOLEAN ShowLabelTips ) { ULONG style; @@ -255,99 +255,99 @@ FORCEINLINE VOID PhSetListViewStyle( PHLIBAPI INT PhAddListViewColumn( - __in HWND ListViewHandle, - __in INT Index, - __in INT DisplayIndex, - __in INT SubItemIndex, - __in INT Format, - __in INT Width, - __in PWSTR Text + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT DisplayIndex, + _In_ INT SubItemIndex, + _In_ INT Format, + _In_ INT Width, + _In_ PWSTR Text ); PHLIBAPI INT PhAddListViewItem( - __in HWND ListViewHandle, - __in INT Index, - __in PWSTR Text, - __in_opt PVOID Param + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ PWSTR Text, + _In_opt_ PVOID Param ); PHLIBAPI INT PhFindListViewItemByFlags( - __in HWND ListViewHandle, - __in INT StartIndex, - __in ULONG Flags + _In_ HWND ListViewHandle, + _In_ INT StartIndex, + _In_ ULONG Flags ); PHLIBAPI INT PhFindListViewItemByParam( - __in HWND ListViewHandle, - __in INT StartIndex, - __in_opt PVOID Param + _In_ HWND ListViewHandle, + _In_ INT StartIndex, + _In_opt_ PVOID Param ); PHLIBAPI LOGICAL PhGetListViewItemImageIndex( - __in HWND ListViewHandle, - __in INT Index, - __out PINT ImageIndex + _In_ HWND ListViewHandle, + _In_ INT Index, + _Out_ PINT ImageIndex ); PHLIBAPI LOGICAL PhGetListViewItemParam( - __in HWND ListViewHandle, - __in INT Index, - __out PVOID *Param + _In_ HWND ListViewHandle, + _In_ INT Index, + _Out_ PVOID *Param ); PHLIBAPI VOID PhRemoveListViewItem( - __in HWND ListViewHandle, - __in INT Index + _In_ HWND ListViewHandle, + _In_ INT Index ); PHLIBAPI VOID PhSetListViewItemImageIndex( - __in HWND ListViewHandle, - __in INT Index, - __in INT ImageIndex + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT ImageIndex ); PHLIBAPI VOID PhSetListViewItemStateImage( - __in HWND ListViewHandle, - __in INT Index, - __in INT StateImage + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT StateImage ); PHLIBAPI VOID PhSetListViewSubItem( - __in HWND ListViewHandle, - __in INT Index, - __in INT SubItemIndex, - __in PWSTR Text + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ INT SubItemIndex, + _In_ PWSTR Text ); PHLIBAPI BOOLEAN PhLoadListViewColumnSettings( - __in HWND ListViewHandle, - __in PPH_STRING Settings + _In_ HWND ListViewHandle, + _In_ PPH_STRING Settings ); PHLIBAPI PPH_STRING PhSaveListViewColumnSettings( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ); HWND PhCreateTabControl( - __in HWND ParentHandle + _In_ HWND ParentHandle ); PHLIBAPI INT PhAddTabControlTab( - __in HWND TabControlHandle, - __in INT Index, - __in PWSTR Text + _In_ HWND TabControlHandle, + _In_ INT Index, + _In_ PWSTR Text ); #define PHA_GET_DLGITEM_TEXT(hwndDlg, id) \ @@ -355,130 +355,130 @@ INT PhAddTabControlTab( PHLIBAPI PPH_STRING PhGetWindowText( - __in HWND hwnd + _In_ HWND hwnd ); PHLIBAPI VOID PhAddComboBoxStrings( - __in HWND hWnd, - __in PWSTR *Strings, - __in ULONG NumberOfStrings + _In_ HWND hWnd, + _In_ PWSTR *Strings, + _In_ ULONG NumberOfStrings ); PHLIBAPI PPH_STRING PhGetComboBoxString( - __in HWND hwnd, - __in INT Index + _In_ HWND hwnd, + _In_ INT Index ); PHLIBAPI INT PhSelectComboBoxString( - __in HWND hwnd, - __in PWSTR String, - __in BOOLEAN Partial + _In_ HWND hwnd, + _In_ PWSTR String, + _In_ BOOLEAN Partial ); PHLIBAPI PPH_STRING PhGetListBoxString( - __in HWND hwnd, - __in INT Index + _In_ HWND hwnd, + _In_ INT Index ); PHLIBAPI VOID PhShowContextMenu( - __in HWND hwnd, - __in HWND subHwnd, - __in HMENU menu, - __in POINT point + _In_ HWND hwnd, + _In_ HWND subHwnd, + _In_ HMENU menu, + _In_ POINT point ); PHLIBAPI UINT PhShowContextMenu2( - __in HWND hwnd, - __in HWND subHwnd, - __in HMENU menu, - __in POINT point + _In_ HWND hwnd, + _In_ HWND subHwnd, + _In_ HMENU menu, + _In_ POINT point ); PHLIBAPI VOID PhSetMenuItemBitmap( - __in HMENU Menu, - __in ULONG Item, - __in BOOLEAN ByPosition, - __in HBITMAP Bitmap + _In_ HMENU Menu, + _In_ ULONG Item, + _In_ BOOLEAN ByPosition, + _In_ HBITMAP Bitmap ); PHLIBAPI VOID PhSetRadioCheckMenuItem( - __in HMENU Menu, - __in ULONG Id, - __in BOOLEAN RadioCheck + _In_ HMENU Menu, + _In_ ULONG Id, + _In_ BOOLEAN RadioCheck ); PHLIBAPI VOID PhEnableMenuItem( - __in HMENU Menu, - __in ULONG Id, - __in BOOLEAN Enable + _In_ HMENU Menu, + _In_ ULONG Id, + _In_ BOOLEAN Enable ); PHLIBAPI VOID PhEnableAllMenuItems( - __in HMENU Menu, - __in BOOLEAN Enable + _In_ HMENU Menu, + _In_ BOOLEAN Enable ); PHLIBAPI VOID PhSetStateAllListViewItems( - __in HWND hWnd, - __in ULONG State, - __in ULONG Mask + _In_ HWND hWnd, + _In_ ULONG State, + _In_ ULONG Mask ); PHLIBAPI PVOID PhGetSelectedListViewItemParam( - __in HWND hWnd + _In_ HWND hWnd ); PHLIBAPI VOID PhGetSelectedListViewItemParams( - __in HWND hWnd, - __out PVOID **Items, - __out PULONG NumberOfItems + _In_ HWND hWnd, + _Out_ PVOID **Items, + _Out_ PULONG NumberOfItems ); PHLIBAPI VOID PhSetImageListBitmap( - __in HIMAGELIST ImageList, - __in INT Index, - __in HINSTANCE InstanceHandle, - __in LPCWSTR BitmapName + _In_ HIMAGELIST ImageList, + _In_ INT Index, + _In_ HINSTANCE InstanceHandle, + _In_ LPCWSTR BitmapName ); PHLIBAPI VOID PhGetStockApplicationIcon( - __out_opt HICON *SmallIcon, - __out_opt HICON *LargeIcon + _Out_opt_ HICON *SmallIcon, + _Out_opt_ HICON *LargeIcon ); PHLIBAPI HICON PhGetFileShellIcon( - __in_opt PWSTR FileName, - __in_opt PWSTR DefaultExtension, - __in BOOLEAN LargeIcon + _In_opt_ PWSTR FileName, + _In_opt_ PWSTR DefaultExtension, + _In_ BOOLEAN LargeIcon ); PHLIBAPI VOID PhSetClipboardString( - __in HWND hWnd, - __in PPH_STRINGREF String + _In_ HWND hWnd, + _In_ PPH_STRINGREF String ); PHLIBAPI VOID PhSetClipboardStringEx( - __in HWND hWnd, - __in PWSTR Buffer, - __in SIZE_T Length + _In_ HWND hWnd, + _In_ PWSTR Buffer, + _In_ SIZE_T Length ); #define PH_ANCHOR_LEFT 0x1 @@ -518,42 +518,42 @@ typedef struct _PH_LAYOUT_MANAGER PHLIBAPI VOID PhInitializeLayoutManager( - __out PPH_LAYOUT_MANAGER Manager, - __in HWND RootWindowHandle + _Out_ PPH_LAYOUT_MANAGER Manager, + _In_ HWND RootWindowHandle ); PHLIBAPI VOID PhDeleteLayoutManager( - __inout PPH_LAYOUT_MANAGER Manager + _Inout_ PPH_LAYOUT_MANAGER Manager ); PHLIBAPI PPH_LAYOUT_ITEM PhAddLayoutItem( - __inout PPH_LAYOUT_MANAGER Manager, - __in HWND Handle, - __in_opt PPH_LAYOUT_ITEM ParentItem, - __in ULONG Anchor + _Inout_ PPH_LAYOUT_MANAGER Manager, + _In_ HWND Handle, + _In_opt_ PPH_LAYOUT_ITEM ParentItem, + _In_ ULONG Anchor ); PHLIBAPI PPH_LAYOUT_ITEM PhAddLayoutItemEx( - __inout PPH_LAYOUT_MANAGER Manager, - __in HWND Handle, - __in_opt PPH_LAYOUT_ITEM ParentItem, - __in ULONG Anchor, - __in RECT Margin + _Inout_ PPH_LAYOUT_MANAGER Manager, + _In_ HWND Handle, + _In_opt_ PPH_LAYOUT_ITEM ParentItem, + _In_ ULONG Anchor, + _In_ RECT Margin ); PHLIBAPI VOID PhLayoutManagerLayout( - __inout PPH_LAYOUT_MANAGER Manager + _Inout_ PPH_LAYOUT_MANAGER Manager ); FORCEINLINE VOID PhResizingMinimumSize( - __inout PRECT Rect, - __in WPARAM Edge, - __in LONG MinimumWidth, - __in LONG MinimumHeight + _Inout_ PRECT Rect, + _In_ WPARAM Edge, + _In_ LONG MinimumWidth, + _In_ LONG MinimumHeight ) { if (Edge == WMSZ_BOTTOMRIGHT || Edge == WMSZ_RIGHT || Edge == WMSZ_TOPRIGHT) @@ -580,9 +580,9 @@ FORCEINLINE VOID PhResizingMinimumSize( } FORCEINLINE VOID PhCopyControlRectangle( - __in HWND ParentWindowHandle, - __in HWND FromControlHandle, - __in HWND ToControlHandle + _In_ HWND ParentWindowHandle, + _In_ HWND FromControlHandle, + _In_ HWND ToControlHandle ) { RECT windowRect; @@ -599,9 +599,9 @@ PHLIBAPI HBITMAP NTAPI PhIconToBitmap( - __in HICON Icon, - __in ULONG Width, - __in ULONG Height + _In_ HICON Icon, + _In_ ULONG Width, + _In_ ULONG Height ); // extlv @@ -628,31 +628,31 @@ typedef enum _PH_ITEM_STATE } PH_ITEM_STATE; typedef COLORREF (NTAPI *PPH_EXTLV_GET_ITEM_COLOR)( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ); typedef HFONT (NTAPI *PPH_EXTLV_GET_ITEM_FONT)( - __in INT Index, - __in PVOID Param, - __in_opt PVOID Context + _In_ INT Index, + _In_ PVOID Param, + _In_opt_ PVOID Context ); PHLIBAPI VOID NTAPI PhSetExtendedListView( - __in HWND hWnd + _In_ HWND hWnd ); PHLIBAPI VOID NTAPI PhSetHeaderSortIcon( - __in HWND hwnd, - __in INT Index, - __in PH_SORT_ORDER Order + _In_ HWND hwnd, + _In_ INT Index, + _In_ PH_SORT_ORDER Order ); // next 1122 @@ -723,7 +723,7 @@ PhSetHeaderSortIcon( * indicating the brightness of the color. */ FORCEINLINE ULONG PhGetColorBrightness( - __in COLORREF Color + _In_ COLORREF Color ) { ULONG r = Color & 0xff; @@ -744,7 +744,7 @@ FORCEINLINE ULONG PhGetColorBrightness( } FORCEINLINE COLORREF PhHalveColorBrightness( - __in COLORREF Color + _In_ COLORREF Color ) { /*return RGB( @@ -761,8 +761,8 @@ FORCEINLINE COLORREF PhHalveColorBrightness( } FORCEINLINE COLORREF PhMakeColorBrighter( - __in COLORREF Color, - __in UCHAR Increment + _In_ COLORREF Color, + _In_ UCHAR Increment ) { UCHAR r; @@ -794,15 +794,15 @@ FORCEINLINE COLORREF PhMakeColorBrighter( // secedit typedef NTSTATUS (NTAPI *PPH_GET_OBJECT_SECURITY)( - __out PSECURITY_DESCRIPTOR *SecurityDescriptor, - __in SECURITY_INFORMATION SecurityInformation, - __in_opt PVOID Context + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_opt_ PVOID Context ); typedef NTSTATUS (NTAPI *PPH_SET_OBJECT_SECURITY)( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in SECURITY_INFORMATION SecurityInformation, - __in_opt PVOID Context + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_opt_ PVOID Context ); typedef struct _PH_ACCESS_ENTRY @@ -818,31 +818,31 @@ PHLIBAPI HPROPSHEETPAGE NTAPI PhCreateSecurityPage( - __in PWSTR ObjectName, - __in PPH_GET_OBJECT_SECURITY GetObjectSecurity, - __in PPH_SET_OBJECT_SECURITY SetObjectSecurity, - __in_opt PVOID Context, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ PWSTR ObjectName, + _In_ PPH_GET_OBJECT_SECURITY GetObjectSecurity, + _In_ PPH_SET_OBJECT_SECURITY SetObjectSecurity, + _In_opt_ PVOID Context, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ); PHLIBAPI VOID NTAPI PhEditSecurity( - __in HWND hWnd, - __in PWSTR ObjectName, - __in PPH_GET_OBJECT_SECURITY GetObjectSecurity, - __in PPH_SET_OBJECT_SECURITY SetObjectSecurity, - __in_opt PVOID Context, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ HWND hWnd, + _In_ PWSTR ObjectName, + _In_ PPH_GET_OBJECT_SECURITY GetObjectSecurity, + _In_ PPH_SET_OBJECT_SECURITY SetObjectSecurity, + _In_opt_ PVOID Context, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ); typedef NTSTATUS (NTAPI *PPH_OPEN_OBJECT)( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in_opt PVOID Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PVOID Context ); typedef struct _PH_STD_OBJECT_SECURITY @@ -853,7 +853,7 @@ typedef struct _PH_STD_OBJECT_SECURITY } PH_STD_OBJECT_SECURITY, *PPH_STD_OBJECT_SECURITY; FORCEINLINE ACCESS_MASK PhGetAccessForGetSecurity( - __in SECURITY_INFORMATION SecurityInformation + _In_ SECURITY_INFORMATION SecurityInformation ) { ACCESS_MASK access = 0; @@ -876,7 +876,7 @@ FORCEINLINE ACCESS_MASK PhGetAccessForGetSecurity( } FORCEINLINE ACCESS_MASK PhGetAccessForSetSecurity( - __in SECURITY_INFORMATION SecurityInformation + _In_ SECURITY_INFORMATION SecurityInformation ) { ACCESS_MASK access = 0; @@ -903,41 +903,41 @@ FORCEINLINE ACCESS_MASK PhGetAccessForSetSecurity( } PHLIBAPI -__callback NTSTATUS +_Callback_ NTSTATUS NTAPI PhStdGetObjectSecurity( - __out PSECURITY_DESCRIPTOR *SecurityDescriptor, - __in SECURITY_INFORMATION SecurityInformation, - __in_opt PVOID Context + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_opt_ PVOID Context ); PHLIBAPI -__callback NTSTATUS +_Callback_ NTSTATUS NTAPI PhStdSetObjectSecurity( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in SECURITY_INFORMATION SecurityInformation, - __in_opt PVOID Context + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_opt_ PVOID Context ); PHLIBAPI NTSTATUS NTAPI PhGetSeObjectSecurity( - __in HANDLE Handle, - __in ULONG ObjectType, - __in SECURITY_INFORMATION SecurityInformation, - __out PSECURITY_DESCRIPTOR *SecurityDescriptor + _In_ HANDLE Handle, + _In_ ULONG ObjectType, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor ); PHLIBAPI NTSTATUS NTAPI PhSetSeObjectSecurity( - __in HANDLE Handle, - __in ULONG ObjectType, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ HANDLE Handle, + _In_ ULONG ObjectType, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); // secdata @@ -946,18 +946,18 @@ PHLIBAPI BOOLEAN NTAPI PhGetAccessEntries( - __in PWSTR Type, - __out PPH_ACCESS_ENTRY *AccessEntries, - __out PULONG NumberOfAccessEntries + _In_ PWSTR Type, + _Out_ PPH_ACCESS_ENTRY *AccessEntries, + _Out_ PULONG NumberOfAccessEntries ); PHLIBAPI PPH_STRING NTAPI PhGetAccessString( - __in ACCESS_MASK Access, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ ACCESS_MASK Access, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ); #ifdef __cplusplus diff --git a/2.x/trunk/phlib/include/phnatinl.h b/2.x/trunk/phlib/include/phnatinl.h index 2ae81c1e1..3a928c685 100644 --- a/2.x/trunk/phlib/include/phnatinl.h +++ b/2.x/trunk/phlib/include/phnatinl.h @@ -16,8 +16,8 @@ * \param BasicInformation A variable which receives the information. */ FORCEINLINE NTSTATUS PhGetProcessBasicInformation( - __in HANDLE ProcessHandle, - __out PPROCESS_BASIC_INFORMATION BasicInformation + _In_ HANDLE ProcessHandle, + _Out_ PPROCESS_BASIC_INFORMATION BasicInformation ) { return NtQueryInformationProcess( @@ -37,8 +37,8 @@ FORCEINLINE NTSTATUS PhGetProcessBasicInformation( * \param ExtendedBasicInformation A variable which receives the information. */ FORCEINLINE NTSTATUS PhGetProcessExtendedBasicInformation( - __in HANDLE ProcessHandle, - __out PPROCESS_EXTENDED_BASIC_INFORMATION ExtendedBasicInformation + _In_ HANDLE ProcessHandle, + _Out_ PPROCESS_EXTENDED_BASIC_INFORMATION ExtendedBasicInformation ) { ExtendedBasicInformation->Size = sizeof(PROCESS_EXTENDED_BASIC_INFORMATION); @@ -60,8 +60,8 @@ FORCEINLINE NTSTATUS PhGetProcessExtendedBasicInformation( * \param Times A variable which receives the information. */ FORCEINLINE NTSTATUS PhGetProcessTimes( - __in HANDLE ProcessHandle, - __out PKERNEL_USER_TIMES Times + _In_ HANDLE ProcessHandle, + _Out_ PKERNEL_USER_TIMES Times ) { return NtQueryInformationProcess( @@ -82,8 +82,8 @@ FORCEINLINE NTSTATUS PhGetProcessTimes( * process' session ID. */ FORCEINLINE NTSTATUS PhGetProcessSessionId( - __in HANDLE ProcessHandle, - __out PULONG SessionId + _In_ HANDLE ProcessHandle, + _Out_ PULONG SessionId ) { NTSTATUS status; @@ -118,8 +118,8 @@ FORCEINLINE NTSTATUS PhGetProcessSessionId( * environment. */ FORCEINLINE NTSTATUS PhGetProcessIsWow64( - __in HANDLE ProcessHandle, - __out PBOOLEAN IsWow64 + _In_ HANDLE ProcessHandle, + _Out_ PBOOLEAN IsWow64 ) { NTSTATUS status; @@ -154,8 +154,8 @@ FORCEINLINE NTSTATUS PhGetProcessIsWow64( * environment. */ FORCEINLINE NTSTATUS PhGetProcessPeb32( - __in HANDLE ProcessHandle, - __out PVOID *Peb32 + _In_ HANDLE ProcessHandle, + _Out_ PVOID *Peb32 ) { NTSTATUS status; @@ -186,8 +186,8 @@ FORCEINLINE NTSTATUS PhGetProcessPeb32( * indicating whether the process is being debugged. */ FORCEINLINE NTSTATUS PhGetProcessIsBeingDebugged( - __in HANDLE ProcessHandle, - __out PBOOLEAN IsBeingDebugged + _In_ HANDLE ProcessHandle, + _Out_ PBOOLEAN IsBeingDebugged ) { NTSTATUS status; @@ -222,8 +222,8 @@ FORCEINLINE NTSTATUS PhGetProcessIsBeingDebugged( * debugged and has no associated debug object. */ FORCEINLINE NTSTATUS PhGetProcessDebugObject( - __in HANDLE ProcessHandle, - __out PHANDLE DebugObjectHandle + _In_ HANDLE ProcessHandle, + _Out_ PHANDLE DebugObjectHandle ) { return NtQueryInformationProcess( @@ -244,8 +244,8 @@ FORCEINLINE NTSTATUS PhGetProcessDebugObject( * priority of the process. */ FORCEINLINE NTSTATUS PhGetProcessIoPriority( - __in HANDLE ProcessHandle, - __out PULONG IoPriority + _In_ HANDLE ProcessHandle, + _Out_ PULONG IoPriority ) { return NtQueryInformationProcess( @@ -266,8 +266,8 @@ FORCEINLINE NTSTATUS PhGetProcessIoPriority( * priority of the process. */ FORCEINLINE NTSTATUS PhGetProcessPagePriority( - __in HANDLE ProcessHandle, - __out PULONG PagePriority + _In_ HANDLE ProcessHandle, + _Out_ PULONG PagePriority ) { NTSTATUS status; @@ -298,8 +298,8 @@ FORCEINLINE NTSTATUS PhGetProcessPagePriority( * time. */ FORCEINLINE NTSTATUS PhGetProcessCycleTime( - __in HANDLE ProcessHandle, - __out PULONG64 CycleTime + _In_ HANDLE ProcessHandle, + _Out_ PULONG64 CycleTime ) { NTSTATUS status; @@ -322,8 +322,8 @@ FORCEINLINE NTSTATUS PhGetProcessCycleTime( } FORCEINLINE NTSTATUS PhGetProcessConsoleHostProcessId( - __in HANDLE ProcessHandle, - __out PHANDLE ConsoleHostProcessId + _In_ HANDLE ProcessHandle, + _Out_ PHANDLE ConsoleHostProcessId ) { NTSTATUS status; @@ -353,8 +353,8 @@ FORCEINLINE NTSTATUS PhGetProcessConsoleHostProcessId( * \param BasicInformation A variable which receives the information. */ FORCEINLINE NTSTATUS PhGetThreadBasicInformation( - __in HANDLE ThreadHandle, - __out PTHREAD_BASIC_INFORMATION BasicInformation + _In_ HANDLE ThreadHandle, + _Out_ PTHREAD_BASIC_INFORMATION BasicInformation ) { return NtQueryInformationThread( @@ -375,8 +375,8 @@ FORCEINLINE NTSTATUS PhGetThreadBasicInformation( * priority of the thread. */ FORCEINLINE NTSTATUS PhGetThreadIoPriority( - __in HANDLE ThreadHandle, - __out PULONG IoPriority + _In_ HANDLE ThreadHandle, + _Out_ PULONG IoPriority ) { return NtQueryInformationThread( @@ -397,8 +397,8 @@ FORCEINLINE NTSTATUS PhGetThreadIoPriority( * priority of the thread. */ FORCEINLINE NTSTATUS PhGetThreadPagePriority( - __in HANDLE ThreadHandle, - __out PULONG PagePriority + _In_ HANDLE ThreadHandle, + _Out_ PULONG PagePriority ) { NTSTATUS status; @@ -429,8 +429,8 @@ FORCEINLINE NTSTATUS PhGetThreadPagePriority( * time. */ FORCEINLINE NTSTATUS PhGetThreadCycleTime( - __in HANDLE ThreadHandle, - __out PULONG64 CycleTime + _In_ HANDLE ThreadHandle, + _Out_ PULONG64 CycleTime ) { NTSTATUS status; @@ -453,8 +453,8 @@ FORCEINLINE NTSTATUS PhGetThreadCycleTime( } FORCEINLINE NTSTATUS PhGetJobBasicAndIoAccounting( - __in HANDLE JobHandle, - __out PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION BasicAndIoAccounting + _In_ HANDLE JobHandle, + _Out_ PJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION BasicAndIoAccounting ) { return NtQueryInformationJobObject( @@ -467,8 +467,8 @@ FORCEINLINE NTSTATUS PhGetJobBasicAndIoAccounting( } FORCEINLINE NTSTATUS PhGetJobBasicLimits( - __in HANDLE JobHandle, - __out PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimits + _In_ HANDLE JobHandle, + _Out_ PJOBOBJECT_BASIC_LIMIT_INFORMATION BasicLimits ) { return NtQueryInformationJobObject( @@ -481,8 +481,8 @@ FORCEINLINE NTSTATUS PhGetJobBasicLimits( } FORCEINLINE NTSTATUS PhGetJobExtendedLimits( - __in HANDLE JobHandle, - __out PJOBOBJECT_EXTENDED_LIMIT_INFORMATION ExtendedLimits + _In_ HANDLE JobHandle, + _Out_ PJOBOBJECT_EXTENDED_LIMIT_INFORMATION ExtendedLimits ) { return NtQueryInformationJobObject( @@ -495,8 +495,8 @@ FORCEINLINE NTSTATUS PhGetJobExtendedLimits( } FORCEINLINE NTSTATUS PhGetJobBasicUiRestrictions( - __in HANDLE JobHandle, - __out PJOBOBJECT_BASIC_UI_RESTRICTIONS BasicUiRestrictions + _In_ HANDLE JobHandle, + _Out_ PJOBOBJECT_BASIC_UI_RESTRICTIONS BasicUiRestrictions ) { return NtQueryInformationJobObject( @@ -517,8 +517,8 @@ FORCEINLINE NTSTATUS PhGetJobBasicUiRestrictions( * session ID. */ FORCEINLINE NTSTATUS PhGetTokenSessionId( - __in HANDLE TokenHandle, - __out PULONG SessionId + _In_ HANDLE TokenHandle, + _Out_ PULONG SessionId ) { ULONG returnLength; @@ -541,8 +541,8 @@ FORCEINLINE NTSTATUS PhGetTokenSessionId( * elevation type. */ FORCEINLINE NTSTATUS PhGetTokenElevationType( - __in HANDLE TokenHandle, - __out PTOKEN_ELEVATION_TYPE ElevationType + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_ELEVATION_TYPE ElevationType ) { ULONG returnLength; @@ -565,8 +565,8 @@ FORCEINLINE NTSTATUS PhGetTokenElevationType( * boolean indicating whether the token is elevated. */ FORCEINLINE NTSTATUS PhGetTokenIsElevated( - __in HANDLE TokenHandle, - __out PBOOLEAN Elevated + _In_ HANDLE TokenHandle, + _Out_ PBOOLEAN Elevated ) { NTSTATUS status; @@ -598,8 +598,8 @@ FORCEINLINE NTSTATUS PhGetTokenIsElevated( * token's statistics. */ FORCEINLINE NTSTATUS PhGetTokenStatistics( - __in HANDLE TokenHandle, - __out PTOKEN_STATISTICS Statistics + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_STATISTICS Statistics ) { ULONG returnLength; @@ -622,8 +622,8 @@ FORCEINLINE NTSTATUS PhGetTokenStatistics( * token's source. */ FORCEINLINE NTSTATUS PhGetTokenSource( - __in HANDLE TokenHandle, - __out PTOKEN_SOURCE Source + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_SOURCE Source ) { ULONG returnLength; @@ -647,8 +647,8 @@ FORCEINLINE NTSTATUS PhGetTokenSource( * using NtClose() when you no longer need it. */ FORCEINLINE NTSTATUS PhGetTokenLinkedToken( - __in HANDLE TokenHandle, - __out PHANDLE LinkedTokenHandle + _In_ HANDLE TokenHandle, + _Out_ PHANDLE LinkedTokenHandle ) { NTSTATUS status; @@ -681,8 +681,8 @@ FORCEINLINE NTSTATUS PhGetTokenLinkedToken( * for the token. */ FORCEINLINE NTSTATUS PhGetTokenIsVirtualizationAllowed( - __in HANDLE TokenHandle, - __out PBOOLEAN IsVirtualizationAllowed + _In_ HANDLE TokenHandle, + _Out_ PBOOLEAN IsVirtualizationAllowed ) { NTSTATUS status; @@ -715,8 +715,8 @@ FORCEINLINE NTSTATUS PhGetTokenIsVirtualizationAllowed( * for the token. */ FORCEINLINE NTSTATUS PhGetTokenIsVirtualizationEnabled( - __in HANDLE TokenHandle, - __out PBOOLEAN IsVirtualizationEnabled + _In_ HANDLE TokenHandle, + _Out_ PBOOLEAN IsVirtualizationEnabled ) { NTSTATUS status; @@ -740,8 +740,8 @@ FORCEINLINE NTSTATUS PhGetTokenIsVirtualizationEnabled( } FORCEINLINE NTSTATUS PhGetEventBasicInformation( - __in HANDLE EventHandle, - __out PEVENT_BASIC_INFORMATION BasicInformation + _In_ HANDLE EventHandle, + _Out_ PEVENT_BASIC_INFORMATION BasicInformation ) { return NtQueryEvent( @@ -754,8 +754,8 @@ FORCEINLINE NTSTATUS PhGetEventBasicInformation( } FORCEINLINE NTSTATUS PhGetMutantBasicInformation( - __in HANDLE MutantHandle, - __out PMUTANT_BASIC_INFORMATION BasicInformation + _In_ HANDLE MutantHandle, + _Out_ PMUTANT_BASIC_INFORMATION BasicInformation ) { return NtQueryMutant( @@ -768,8 +768,8 @@ FORCEINLINE NTSTATUS PhGetMutantBasicInformation( } FORCEINLINE NTSTATUS PhGetMutantOwnerInformation( - __in HANDLE MutantHandle, - __out PMUTANT_OWNER_INFORMATION OwnerInformation + _In_ HANDLE MutantHandle, + _Out_ PMUTANT_OWNER_INFORMATION OwnerInformation ) { return NtQueryMutant( @@ -782,8 +782,8 @@ FORCEINLINE NTSTATUS PhGetMutantOwnerInformation( } FORCEINLINE NTSTATUS PhGetSectionBasicInformation( - __in HANDLE SectionHandle, - __out PSECTION_BASIC_INFORMATION BasicInformation + _In_ HANDLE SectionHandle, + _Out_ PSECTION_BASIC_INFORMATION BasicInformation ) { return NtQuerySection( @@ -796,8 +796,8 @@ FORCEINLINE NTSTATUS PhGetSectionBasicInformation( } FORCEINLINE NTSTATUS PhGetSemaphoreBasicInformation( - __in HANDLE SemaphoreHandle, - __out PSEMAPHORE_BASIC_INFORMATION BasicInformation + _In_ HANDLE SemaphoreHandle, + _Out_ PSEMAPHORE_BASIC_INFORMATION BasicInformation ) { return NtQuerySemaphore( @@ -810,8 +810,8 @@ FORCEINLINE NTSTATUS PhGetSemaphoreBasicInformation( } FORCEINLINE NTSTATUS PhGetTimerBasicInformation( - __in HANDLE TimerHandle, - __out PTIMER_BASIC_INFORMATION BasicInformation + _In_ HANDLE TimerHandle, + _Out_ PTIMER_BASIC_INFORMATION BasicInformation ) { return NtQueryTimer( diff --git a/2.x/trunk/phlib/include/phnet.h b/2.x/trunk/phlib/include/phnet.h index 245698824..7dd1564bb 100644 --- a/2.x/trunk/phlib/include/phnet.h +++ b/2.x/trunk/phlib/include/phnet.h @@ -31,8 +31,8 @@ typedef struct _PH_IP_ADDRESS } PH_IP_ADDRESS, *PPH_IP_ADDRESS; FORCEINLINE BOOLEAN PhEqualIpAddress( - __in PPH_IP_ADDRESS Address1, - __in PPH_IP_ADDRESS Address2 + _In_ PPH_IP_ADDRESS Address1, + _In_ PPH_IP_ADDRESS Address2 ) { if ((Address1->Type | Address2->Type) == 0) // don't check addresses if both are invalid @@ -61,7 +61,7 @@ FORCEINLINE BOOLEAN PhEqualIpAddress( } FORCEINLINE ULONG PhHashIpAddress( - __in PPH_IP_ADDRESS Address + _In_ PPH_IP_ADDRESS Address ) { ULONG hash = 0; @@ -87,7 +87,7 @@ FORCEINLINE ULONG PhHashIpAddress( } FORCEINLINE BOOLEAN PhIsNullIpAddress( - __in PPH_IP_ADDRESS Address + _In_ PPH_IP_ADDRESS Address ) { if (Address->Type == 0) @@ -120,8 +120,8 @@ typedef struct _PH_IP_ENDPOINT } PH_IP_ENDPOINT, *PPH_IP_ENDPOINT; FORCEINLINE BOOLEAN PhEqualIpEndpoint( - __in PPH_IP_ENDPOINT Endpoint1, - __in PPH_IP_ENDPOINT Endpoint2 + _In_ PPH_IP_ENDPOINT Endpoint1, + _In_ PPH_IP_ENDPOINT Endpoint2 ) { return @@ -130,7 +130,7 @@ FORCEINLINE BOOLEAN PhEqualIpEndpoint( } FORCEINLINE ULONG PhHashIpEndpoint( - __in PPH_IP_ENDPOINT Endpoint + _In_ PPH_IP_ENDPOINT Endpoint ) { return PhHashIpAddress(&Endpoint->Address) ^ Endpoint->Port; diff --git a/2.x/trunk/phlib/include/phnt.h b/2.x/trunk/phlib/include/phnt.h index 52782f101..54b38a988 100644 --- a/2.x/trunk/phlib/include/phnt.h +++ b/2.x/trunk/phlib/include/phnt.h @@ -31,6 +31,7 @@ #define PHNT_VISTA 60 #define PHNT_WIN7 61 #define PHNT_WIN8 62 +#define PHNT_WINBLUE 63 #ifndef PHNT_MODE #define PHNT_MODE PHNT_MODE_USER diff --git a/2.x/trunk/phlib/include/phsup.h b/2.x/trunk/phlib/include/phsup.h index ed5050635..a582242a1 100644 --- a/2.x/trunk/phlib/include/phsup.h +++ b/2.x/trunk/phlib/include/phsup.h @@ -57,12 +57,6 @@ // Annotations -/** - * Indicates that a function assumes the relevant - * locks have been acquired. - */ -#define __assumeLocked - /** * Indicates that a function assumes the specified * number of references are available for the object. @@ -73,10 +67,12 @@ * itself. In effect these references are "transferred" * to the function and must not be used. E.g. if you * create an object and immediately call a function - * with __assumeRefs(1), you may no longer use the object + * with _Assume_refs_(1), you may no longer use the object * since that one reference you held is no longer yours. */ -#define __assumeRefs(count) +#define _Assume_refs_(count) + +#define _Callback_ /** * Indicates that a function may raise a software @@ -86,13 +82,13 @@ * temporary usages of exceptions, e.g. unimplemented * functions. */ -#define __mayRaise +#define _May_raise_ /** * Indicates that a function requires the specified * value to be aligned at the specified number of bytes. */ -#define __needsAlign(align) +#define _Needs_align_(align) // Casts @@ -116,8 +112,8 @@ typedef enum _PH_SORT_ORDER } PH_SORT_ORDER, *PPH_SORT_ORDER; FORCEINLINE LONG PhModifySort( - __in LONG Result, - __in PH_SORT_ORDER Order + _In_ LONG Result, + _In_ PH_SORT_ORDER Order ) { if (Order == AscendingSortOrder) @@ -137,104 +133,104 @@ FORCEINLINE LONG PhModifySort( return 0 FORCEINLINE int charcmp( - __in signed char value1, - __in signed char value2 + _In_ signed char value1, + _In_ signed char value2 ) { return C_1sTo4(value1 - value2); } FORCEINLINE int ucharcmp( - __in unsigned char value1, - __in unsigned char value2 + _In_ unsigned char value1, + _In_ unsigned char value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int shortcmp( - __in signed short value1, - __in signed short value2 + _In_ signed short value1, + _In_ signed short value2 ) { return C_2sTo4(value1 - value2); } FORCEINLINE int ushortcmp( - __in unsigned short value1, - __in unsigned short value2 + _In_ unsigned short value1, + _In_ unsigned short value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int intcmp( - __in int value1, - __in int value2 + _In_ int value1, + _In_ int value2 ) { return value1 - value2; } FORCEINLINE int uintcmp( - __in unsigned int value1, - __in unsigned int value2 + _In_ unsigned int value1, + _In_ unsigned int value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int int64cmp( - __in __int64 value1, - __in __int64 value2 + _In_ __int64 value1, + _In_ __int64 value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int uint64cmp( - __in unsigned __int64 value1, - __in unsigned __int64 value2 + _In_ unsigned __int64 value1, + _In_ unsigned __int64 value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int intptrcmp( - __in LONG_PTR value1, - __in LONG_PTR value2 + _In_ LONG_PTR value1, + _In_ LONG_PTR value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int uintptrcmp( - __in ULONG_PTR value1, - __in ULONG_PTR value2 + _In_ ULONG_PTR value1, + _In_ ULONG_PTR value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int singlecmp( - __in float value1, - __in float value2 + _In_ float value1, + _In_ float value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int doublecmp( - __in double value1, - __in double value2 + _In_ double value1, + _In_ double value2 ) { PH_BUILTIN_COMPARE(value1, value2); } FORCEINLINE int wcsicmp2( - __in_opt PWSTR Value1, - __in_opt PWSTR Value2 + _In_opt_ PWSTR Value1, + _In_opt_ PWSTR Value2 ) { if (Value1 && Value2) @@ -273,8 +269,8 @@ FORCEINLINE void *_InterlockedExchangePointer( #endif FORCEINLINE LONG_PTR _InterlockedExchangeAddPointer( - __inout LONG_PTR volatile *Addend, - __in LONG_PTR Value + _Inout_ _Interlocked_operand_ LONG_PTR volatile *Addend, + _In_ LONG_PTR Value ) { #ifdef _M_IX86 @@ -285,7 +281,7 @@ FORCEINLINE LONG_PTR _InterlockedExchangeAddPointer( } FORCEINLINE LONG_PTR _InterlockedIncrementPointer( - __inout LONG_PTR volatile *Addend + _Inout_ _Interlocked_operand_ LONG_PTR volatile *Addend ) { #ifdef _M_IX86 @@ -296,7 +292,7 @@ FORCEINLINE LONG_PTR _InterlockedIncrementPointer( } FORCEINLINE LONG_PTR _InterlockedDecrementPointer( - __inout LONG_PTR volatile *Addend + _Inout_ _Interlocked_operand_ LONG_PTR volatile *Addend ) { #ifdef _M_IX86 @@ -307,8 +303,8 @@ FORCEINLINE LONG_PTR _InterlockedDecrementPointer( } FORCEINLINE BOOLEAN _InterlockedBitTestAndResetPointer( - __inout LONG_PTR volatile *Base, - __in LONG_PTR Bit + _Inout_ _Interlocked_operand_ LONG_PTR volatile *Base, + _In_ LONG_PTR Bit ) { #ifdef _M_IX86 @@ -319,8 +315,8 @@ FORCEINLINE BOOLEAN _InterlockedBitTestAndResetPointer( } FORCEINLINE BOOLEAN _InterlockedBitTestAndSetPointer( - __inout LONG_PTR volatile *Base, - __in LONG_PTR Bit + _Inout_ _Interlocked_operand_ LONG_PTR volatile *Base, + _In_ LONG_PTR Bit ) { #ifdef _M_IX86 @@ -331,7 +327,7 @@ FORCEINLINE BOOLEAN _InterlockedBitTestAndSetPointer( } FORCEINLINE BOOLEAN _InterlockedIncrementNoZero( - __inout LONG volatile *Addend + _Inout_ _Interlocked_operand_ LONG volatile *Addend ) { LONG value; @@ -375,40 +371,40 @@ FORCEINLINE BOOLEAN _InterlockedIncrementNoZero( #define WSTR_IEQUAL(Str1, Str2) (wcsicmp(Str1, Str2) == 0) FORCEINLINE VOID PhPrintInt32( - __out_ecount(PH_INT32_STR_LEN_1) PWSTR Destination, - __in LONG Int32 + _Out_writes_(PH_INT32_STR_LEN_1) PWSTR Destination, + _In_ LONG Int32 ) { _ltow(Int32, Destination, 10); } FORCEINLINE VOID PhPrintUInt32( - __out_ecount(PH_INT32_STR_LEN_1) PWSTR Destination, - __in ULONG UInt32 + _Out_writes_(PH_INT32_STR_LEN_1) PWSTR Destination, + _In_ ULONG UInt32 ) { _ultow(UInt32, Destination, 10); } FORCEINLINE VOID PhPrintInt64( - __out_ecount(PH_INT64_STR_LEN_1) PWSTR Destination, - __in LONG64 Int64 + _Out_writes_(PH_INT64_STR_LEN_1) PWSTR Destination, + _In_ LONG64 Int64 ) { _i64tow(Int64, Destination, 10); } FORCEINLINE VOID PhPrintUInt64( - __out_ecount(PH_INT64_STR_LEN_1) PWSTR Destination, - __in ULONG64 UInt64 + _Out_writes_(PH_INT64_STR_LEN_1) PWSTR Destination, + _In_ ULONG64 UInt64 ) { _ui64tow(UInt64, Destination, 10); } FORCEINLINE VOID PhPrintPointer( - __out_ecount(PH_PTR_STR_LEN_1) PWSTR Destination, - __in PVOID Pointer + _Out_writes_(PH_PTR_STR_LEN_1) PWSTR Destination, + _In_ PVOID Pointer ) { Destination[0] = '0'; @@ -433,7 +429,7 @@ FORCEINLINE NTSTATUS PhGetLastWin32ErrorAsNtStatus() } FORCEINLINE ULONG PhCountBits( - __in ULONG Value + _In_ ULONG Value ) { ULONG count = 0; @@ -448,8 +444,8 @@ FORCEINLINE ULONG PhCountBits( } FORCEINLINE ULONG PhRoundNumber( - __in ULONG Value, - __in ULONG Multiplier + _In_ ULONG Value, + _In_ ULONG Multiplier ) { ULONG newValue; @@ -473,8 +469,8 @@ FORCEINLINE ULONG PhRoundNumber( } FORCEINLINE PVOID PhGetProcAddress( - __in PWSTR LibraryName, - __in PSTR ProcName + _In_ PWSTR LibraryName, + _In_ PSTR ProcName ) { HMODULE module; @@ -488,11 +484,11 @@ FORCEINLINE PVOID PhGetProcAddress( } FORCEINLINE VOID PhProbeAddress( - __in PVOID UserAddress, - __in SIZE_T UserLength, - __in PVOID BufferAddress, - __in SIZE_T BufferLength, - __in ULONG Alignment + _In_ PVOID UserAddress, + _In_ SIZE_T UserLength, + _In_ PVOID BufferAddress, + _In_ SIZE_T BufferLength, + _In_ ULONG Alignment ) { if (UserLength != 0) @@ -510,8 +506,8 @@ FORCEINLINE VOID PhProbeAddress( } FORCEINLINE PLARGE_INTEGER PhTimeoutFromMilliseconds( - __out PLARGE_INTEGER Timeout, - __in ULONG Milliseconds + _Out_ PLARGE_INTEGER Timeout, + _In_ ULONG Milliseconds ) { if (Milliseconds == INFINITE) diff --git a/2.x/trunk/phlib/include/queuedlock.h b/2.x/trunk/phlib/include/queuedlock.h index 668faa827..5353c9f8a 100644 --- a/2.x/trunk/phlib/include/queuedlock.h +++ b/2.x/trunk/phlib/include/queuedlock.h @@ -61,7 +61,7 @@ BOOLEAN PhQueuedLockInitialization( ); FORCEINLINE VOID PhInitializeQueuedLock( - __out PPH_QUEUED_LOCK QueuedLock + _Out_ PPH_QUEUED_LOCK QueuedLock ) { QueuedLock->Value = 0; @@ -71,43 +71,43 @@ PHLIBAPI VOID FASTCALL PhfAcquireQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ); PHLIBAPI VOID FASTCALL PhfAcquireQueuedLockShared( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ); PHLIBAPI VOID FASTCALL PhfReleaseQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ); PHLIBAPI VOID FASTCALL PhfReleaseQueuedLockShared( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ); PHLIBAPI VOID FASTCALL PhfTryWakeQueuedLock( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ); PHLIBAPI VOID FASTCALL PhfWakeForReleaseQueuedLock( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value ); #define PhPulseCondition PhfPulseCondition @@ -115,7 +115,7 @@ PHLIBAPI VOID FASTCALL PhfPulseCondition( - __inout PPH_QUEUED_LOCK Condition + _Inout_ PPH_QUEUED_LOCK Condition ); #define PhPulseAllCondition PhfPulseAllCondition @@ -123,7 +123,7 @@ PHLIBAPI VOID FASTCALL PhfPulseAllCondition( - __inout PPH_QUEUED_LOCK Condition + _Inout_ PPH_QUEUED_LOCK Condition ); #define PhWaitForCondition PhfWaitForCondition @@ -131,9 +131,9 @@ PHLIBAPI VOID FASTCALL PhfWaitForCondition( - __inout PPH_QUEUED_LOCK Condition, - __inout PPH_QUEUED_LOCK Lock, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_QUEUED_LOCK Condition, + _Inout_ PPH_QUEUED_LOCK Lock, + _In_opt_ PLARGE_INTEGER Timeout ); #define PH_CONDITION_WAIT_QUEUED_LOCK 0x1 @@ -149,10 +149,10 @@ PHLIBAPI VOID FASTCALL PhfWaitForConditionEx( - __inout PPH_QUEUED_LOCK Condition, - __inout PVOID Lock, - __in ULONG Flags, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_QUEUED_LOCK Condition, + _Inout_ PVOID Lock, + _In_ ULONG Flags, + _In_opt_ PLARGE_INTEGER Timeout ); #define PhQueueWakeEvent PhfQueueWakeEvent @@ -160,16 +160,16 @@ PHLIBAPI VOID FASTCALL PhfQueueWakeEvent( - __inout PPH_QUEUED_LOCK WakeEvent, - __out PPH_QUEUED_WAIT_BLOCK WaitBlock + _Inout_ PPH_QUEUED_LOCK WakeEvent, + _Out_ PPH_QUEUED_WAIT_BLOCK WaitBlock ); PHLIBAPI VOID FASTCALL PhfSetWakeEvent( - __inout PPH_QUEUED_LOCK WakeEvent, - __inout_opt PPH_QUEUED_WAIT_BLOCK WaitBlock + _Inout_ PPH_QUEUED_LOCK WakeEvent, + _Inout_opt_ PPH_QUEUED_WAIT_BLOCK WaitBlock ); #define PhWaitForWakeEvent PhfWaitForWakeEvent @@ -177,16 +177,17 @@ PHLIBAPI NTSTATUS FASTCALL PhfWaitForWakeEvent( - __inout PPH_QUEUED_LOCK WakeEvent, - __inout PPH_QUEUED_WAIT_BLOCK WaitBlock, - __in BOOLEAN Spin, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_QUEUED_LOCK WakeEvent, + _Inout_ PPH_QUEUED_WAIT_BLOCK WaitBlock, + _In_ BOOLEAN Spin, + _In_opt_ PLARGE_INTEGER Timeout ); // Inline functions +_Acquires_exclusive_lock_(*QueuedLock) FORCEINLINE VOID PhAcquireQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { if (_InterlockedBitTestAndSetPointer((PLONG_PTR)&QueuedLock->Value, PH_QUEUED_LOCK_OWNED_SHIFT)) @@ -196,8 +197,9 @@ FORCEINLINE VOID PhAcquireQueuedLockExclusive( } } +_Acquires_shared_lock_(*QueuedLock) FORCEINLINE VOID PhAcquireQueuedLockShared( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { if ((ULONG_PTR)_InterlockedCompareExchangePointer( @@ -210,8 +212,9 @@ FORCEINLINE VOID PhAcquireQueuedLockShared( } } +_When_(return != 0, _Acquires_exclusive_lock_(*QueuedLock)) FORCEINLINE BOOLEAN PhTryAcquireQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { if (!_InterlockedBitTestAndSetPointer((PLONG_PTR)&QueuedLock->Value, PH_QUEUED_LOCK_OWNED_SHIFT)) @@ -224,8 +227,9 @@ FORCEINLINE BOOLEAN PhTryAcquireQueuedLockExclusive( } } +_Releases_exclusive_lock_(*QueuedLock) FORCEINLINE VOID PhReleaseQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { ULONG_PTR value; @@ -238,8 +242,9 @@ FORCEINLINE VOID PhReleaseQueuedLockExclusive( } } +_Releases_shared_lock_(*QueuedLock) FORCEINLINE VOID PhReleaseQueuedLockShared( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { ULONG_PTR value; @@ -257,7 +262,7 @@ FORCEINLINE VOID PhReleaseQueuedLockShared( } FORCEINLINE VOID PhAcquireReleaseQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { BOOLEAN owned; @@ -274,7 +279,7 @@ FORCEINLINE VOID PhAcquireReleaseQueuedLockExclusive( } FORCEINLINE BOOLEAN PhTryAcquireReleaseQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { BOOLEAN owned; @@ -290,8 +295,8 @@ FORCEINLINE BOOLEAN PhTryAcquireReleaseQueuedLockExclusive( } FORCEINLINE VOID PhSetWakeEvent( - __inout PPH_QUEUED_LOCK WakeEvent, - __inout_opt PPH_QUEUED_WAIT_BLOCK WaitBlock + _Inout_ PPH_QUEUED_LOCK WakeEvent, + _Inout_opt_ PPH_QUEUED_WAIT_BLOCK WaitBlock ) { // The wake event is similar to a synchronization event diff --git a/2.x/trunk/phlib/include/ref.h b/2.x/trunk/phlib/include/ref.h index 6ef33b9fa..fd2216456 100644 --- a/2.x/trunk/phlib/include/ref.h +++ b/2.x/trunk/phlib/include/ref.h @@ -53,8 +53,8 @@ extern "C" { * \param Flags Reserved. */ typedef VOID (NTAPI *PPH_TYPE_DELETE_PROCEDURE)( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); struct _PH_OBJECT_TYPE; @@ -65,10 +65,10 @@ typedef struct _PH_QUEUED_LOCK PH_QUEUED_LOCK, *PPH_QUEUED_LOCK; #ifdef DEBUG typedef VOID (NTAPI *PPH_CREATE_OBJECT_HOOK)( - __in PVOID Object, - __in SIZE_T Size, - __in ULONG Flags, - __in PPH_OBJECT_TYPE ObjectType + _In_ PVOID Object, + _In_ SIZE_T Size, + _In_ ULONG Flags, + _In_ PPH_OBJECT_TYPE ObjectType ); #endif @@ -105,103 +105,103 @@ NTSTATUS PhInitializeRef( VOID ); -__mayRaise +_May_raise_ PHLIBAPI NTSTATUS NTAPI PhCreateObject( - __out PVOID *Object, - __in SIZE_T ObjectSize, - __in ULONG Flags, - __in PPH_OBJECT_TYPE ObjectType + _Out_ PVOID *Object, + _In_ SIZE_T ObjectSize, + _In_ ULONG Flags, + _In_ PPH_OBJECT_TYPE ObjectType ); PHLIBAPI VOID NTAPI PhReferenceObject( - __in PVOID Object + _In_ PVOID Object ); -__mayRaise +_May_raise_ PHLIBAPI LONG NTAPI PhReferenceObjectEx( - __in PVOID Object, - __in LONG RefCount + _In_ PVOID Object, + _In_ LONG RefCount ); PHLIBAPI BOOLEAN NTAPI PhReferenceObjectSafe( - __in PVOID Object + _In_ PVOID Object ); PHLIBAPI VOID NTAPI PhDereferenceObject( - __in PVOID Object + _In_ PVOID Object ); PHLIBAPI BOOLEAN NTAPI PhDereferenceObjectDeferDelete( - __in PVOID Object + _In_ PVOID Object ); -__mayRaise +_May_raise_ PHLIBAPI LONG NTAPI PhDereferenceObjectEx( - __in PVOID Object, - __in LONG RefCount, - __in BOOLEAN DeferDelete + _In_ PVOID Object, + _In_ LONG RefCount, + _In_ BOOLEAN DeferDelete ); PHLIBAPI PPH_OBJECT_TYPE NTAPI PhGetObjectType( - __in PVOID Object + _In_ PVOID Object ); PHLIBAPI NTSTATUS NTAPI PhCreateObjectType( - __out PPH_OBJECT_TYPE *ObjectType, - __in PWSTR Name, - __in ULONG Flags, - __in_opt PPH_TYPE_DELETE_PROCEDURE DeleteProcedure + _Out_ PPH_OBJECT_TYPE *ObjectType, + _In_ PWSTR Name, + _In_ ULONG Flags, + _In_opt_ PPH_TYPE_DELETE_PROCEDURE DeleteProcedure ); PHLIBAPI NTSTATUS NTAPI PhCreateObjectTypeEx( - __out PPH_OBJECT_TYPE *ObjectType, - __in PWSTR Name, - __in ULONG Flags, - __in_opt PPH_TYPE_DELETE_PROCEDURE DeleteProcedure, - __in_opt PPH_OBJECT_TYPE_PARAMETERS Parameters + _Out_ PPH_OBJECT_TYPE *ObjectType, + _In_ PWSTR Name, + _In_ ULONG Flags, + _In_opt_ PPH_TYPE_DELETE_PROCEDURE DeleteProcedure, + _In_opt_ PPH_OBJECT_TYPE_PARAMETERS Parameters ); PHLIBAPI VOID NTAPI PhGetObjectTypeInformation( - __in PPH_OBJECT_TYPE ObjectType, - __out PPH_OBJECT_TYPE_INFORMATION Information + _In_ PPH_OBJECT_TYPE ObjectType, + _Out_ PPH_OBJECT_TYPE_INFORMATION Information ); FORCEINLINE VOID PhSwapReference( - __inout PVOID *ObjectReference, - __in_opt PVOID NewObject + _Inout_ PVOID *ObjectReference, + _In_opt_ PVOID NewObject ) { PVOID oldObject; @@ -214,8 +214,8 @@ FORCEINLINE VOID PhSwapReference( } FORCEINLINE VOID PhSwapReference2( - __inout PVOID *ObjectReference, - __in_opt __assumeRefs(1) PVOID NewObject + _Inout_ PVOID *ObjectReference, + _In_opt_ _Assume_refs_(1) PVOID NewObject ) { PVOID oldObject; @@ -230,8 +230,8 @@ PHLIBAPI NTSTATUS NTAPI PhCreateAlloc( - __out PVOID *Alloc, - __in SIZE_T Size + _Out_ PVOID *Alloc, + _In_ SIZE_T Size ); /** The size of the static array in an auto-release pool. */ @@ -265,30 +265,30 @@ PHLIBAPI VOID NTAPI PhInitializeAutoPool( - __out PPH_AUTO_POOL AutoPool + _Out_ PPH_AUTO_POOL AutoPool ); -__mayRaise +_May_raise_ PHLIBAPI VOID NTAPI PhDeleteAutoPool( - __inout PPH_AUTO_POOL AutoPool + _Inout_ PPH_AUTO_POOL AutoPool ); -__mayRaise +_May_raise_ PHLIBAPI VOID NTAPI PhaDereferenceObject( - __in PVOID Object + _In_ PVOID Object ); PHLIBAPI VOID NTAPI PhDrainAutoPool( - __in PPH_AUTO_POOL AutoPool + _In_ PPH_AUTO_POOL AutoPool ); /** @@ -300,7 +300,7 @@ PhDrainAutoPool( * \return The value of \a Object. */ FORCEINLINE PVOID PHA_DEREFERENCE( - __in PVOID Object + _In_ PVOID Object ) { if (Object) diff --git a/2.x/trunk/phlib/include/refp.h b/2.x/trunk/phlib/include/refp.h index ce1d6553c..68b000656 100644 --- a/2.x/trunk/phlib/include/refp.h +++ b/2.x/trunk/phlib/include/refp.h @@ -139,7 +139,7 @@ typedef struct _PH_OBJECT_TYPE * \param RefCount A pointer to a reference count. */ FORCEINLINE BOOLEAN PhpInterlockedIncrementSafe( - __inout PLONG RefCount + _Inout_ PLONG RefCount ) { /* Here we will attempt to increment the reference count, @@ -149,21 +149,21 @@ FORCEINLINE BOOLEAN PhpInterlockedIncrementSafe( } PPH_OBJECT_HEADER PhpAllocateObject( - __in PPH_OBJECT_TYPE ObjectType, - __in SIZE_T ObjectSize, - __in ULONG Flags + _In_ PPH_OBJECT_TYPE ObjectType, + _In_ SIZE_T ObjectSize, + _In_ ULONG Flags ); VOID PhpFreeObject( - __in PPH_OBJECT_HEADER ObjectHeader + _In_ PPH_OBJECT_HEADER ObjectHeader ); VOID PhpDeferDeleteObject( - __in PPH_OBJECT_HEADER ObjectHeader + _In_ PPH_OBJECT_HEADER ObjectHeader ); NTSTATUS PhpDeferDeleteObjectRoutine( - __in PVOID Parameter + _In_ PVOID Parameter ); #endif diff --git a/2.x/trunk/phlib/include/seceditp.h b/2.x/trunk/phlib/include/seceditp.h index a2c98e258..2b51e5fe3 100644 --- a/2.x/trunk/phlib/include/seceditp.h +++ b/2.x/trunk/phlib/include/seceditp.h @@ -19,82 +19,82 @@ typedef struct } PhSecurityInformation; ISecurityInformation *PhSecurityInformation_Create( - __in PWSTR ObjectName, - __in PPH_GET_OBJECT_SECURITY GetObjectSecurity, - __in PPH_SET_OBJECT_SECURITY SetObjectSecurity, - __in_opt PVOID Context, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ PWSTR ObjectName, + _In_ PPH_GET_OBJECT_SECURITY GetObjectSecurity, + _In_ PPH_SET_OBJECT_SECURITY SetObjectSecurity, + _In_opt_ PVOID Context, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_QueryInterface( - __in ISecurityInformation *This, - __in REFIID Riid, - __out PVOID *Object + _In_ ISecurityInformation *This, + _In_ REFIID Riid, + _Out_ PVOID *Object ); ULONG STDMETHODCALLTYPE PhSecurityInformation_AddRef( - __in ISecurityInformation *This + _In_ ISecurityInformation *This ); ULONG STDMETHODCALLTYPE PhSecurityInformation_Release( - __in ISecurityInformation *This + _In_ ISecurityInformation *This ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetObjectInformation( - __in ISecurityInformation *This, - __out PSI_OBJECT_INFO ObjectInfo + _In_ ISecurityInformation *This, + _Out_ PSI_OBJECT_INFO ObjectInfo ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetSecurity( - __in ISecurityInformation *This, - __in SECURITY_INFORMATION RequestedInformation, - __out PSECURITY_DESCRIPTOR *SecurityDescriptor, - __in BOOL Default + _In_ ISecurityInformation *This, + _In_ SECURITY_INFORMATION RequestedInformation, + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor, + _In_ BOOL Default ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_SetSecurity( - __in ISecurityInformation *This, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ ISecurityInformation *This, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetAccessRights( - __in ISecurityInformation *This, - __in const GUID *ObjectType, - __in ULONG Flags, - __out PSI_ACCESS *Access, - __out PULONG Accesses, - __out PULONG DefaultAccess + _In_ ISecurityInformation *This, + _In_ const GUID *ObjectType, + _In_ ULONG Flags, + _Out_ PSI_ACCESS *Access, + _Out_ PULONG Accesses, + _Out_ PULONG DefaultAccess ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_MapGeneric( - __in ISecurityInformation *This, - __in const GUID *ObjectType, - __in PUCHAR AceFlags, - __inout PACCESS_MASK Mask + _In_ ISecurityInformation *This, + _In_ const GUID *ObjectType, + _In_ PUCHAR AceFlags, + _Inout_ PACCESS_MASK Mask ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetInheritTypes( - __in ISecurityInformation *This, - __out PSI_INHERIT_TYPE *InheritTypes, - __out PULONG InheritTypesCount + _In_ ISecurityInformation *This, + _Out_ PSI_INHERIT_TYPE *InheritTypes, + _Out_ PULONG InheritTypesCount ); HRESULT STDMETHODCALLTYPE PhSecurityInformation_PropertySheetPageCallback( - __in ISecurityInformation *This, - __in HWND hwnd, - __in UINT uMsg, - __in SI_PAGE_TYPE uPage + _In_ ISecurityInformation *This, + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ SI_PAGE_TYPE uPage ); typedef HPROPSHEETPAGE (WINAPI *_CreateSecurityPage)( - __in LPSECURITYINFO psi + _In_ LPSECURITYINFO psi ); typedef BOOL (WINAPI *_EditSecurity)( - __in HWND hwndOwner, - __in LPSECURITYINFO psi + _In_ HWND hwndOwner, + _In_ LPSECURITYINFO psi ); #endif diff --git a/2.x/trunk/phlib/include/sha.h b/2.x/trunk/phlib/include/sha.h index ca3623c28..7572a4692 100644 --- a/2.x/trunk/phlib/include/sha.h +++ b/2.x/trunk/phlib/include/sha.h @@ -11,18 +11,18 @@ typedef struct } A_SHA_CTX; VOID A_SHAInit( - __out A_SHA_CTX *Context + _Out_ A_SHA_CTX *Context ); VOID A_SHAUpdate( - __inout A_SHA_CTX *Context, - __in_bcount(Length) UCHAR *Input, - __in ULONG Length + _Inout_ A_SHA_CTX *Context, + _In_reads_bytes_(Length) UCHAR *Input, + _In_ ULONG Length ); VOID A_SHAFinal( - __inout A_SHA_CTX *Context, - __out_bcount(20) UCHAR *Hash + _Inout_ A_SHA_CTX *Context, + _Out_writes_bytes_(20) UCHAR *Hash ); #endif diff --git a/2.x/trunk/phlib/include/symprv.h b/2.x/trunk/phlib/include/symprv.h index 6b4902866..f6b213d1a 100644 --- a/2.x/trunk/phlib/include/symprv.h +++ b/2.x/trunk/phlib/include/symprv.h @@ -4,200 +4,207 @@ #include typedef BOOL (WINAPI *_SymInitialize)( - __in HANDLE hProcess, - __in_opt PCSTR UserSearchPath, - __in BOOL fInvadeProcess + _In_ HANDLE hProcess, + _In_opt_ PCSTR UserSearchPath, + _In_ BOOL fInvadeProcess ); typedef BOOL (WINAPI *_SymCleanup)( - __in HANDLE hProcess + _In_ HANDLE hProcess ); typedef BOOL (WINAPI *_SymEnumSymbols)( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCSTR Mask, - __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt const PVOID UserContext + _In_ HANDLE hProcess, + _In_ ULONG64 BaseOfDll, + _In_opt_ PCSTR Mask, + _In_ PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + _In_opt_ const PVOID UserContext ); typedef BOOL (WINAPI *_SymEnumSymbolsW)( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCWSTR Mask, - __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, - __in_opt const PVOID UserContext + _In_ HANDLE hProcess, + _In_ ULONG64 BaseOfDll, + _In_opt_ PCWSTR Mask, + _In_ PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, + _In_opt_ const PVOID UserContext ); typedef BOOL (WINAPI *_SymFromAddr)( - __in HANDLE hProcess, - __in DWORD64 Address, - __out_opt PDWORD64 Displacement, - __inout PSYMBOL_INFO Symbol + _In_ HANDLE hProcess, + _In_ DWORD64 Address, + _Out_opt_ PDWORD64 Displacement, + _Inout_ PSYMBOL_INFO Symbol ); typedef BOOL (WINAPI *_SymFromAddrW)( - __in HANDLE hProcess, - __in DWORD64 Address, - __out_opt PDWORD64 Displacement, - __inout PSYMBOL_INFOW Symbol + _In_ HANDLE hProcess, + _In_ DWORD64 Address, + _Out_opt_ PDWORD64 Displacement, + _Inout_ PSYMBOL_INFOW Symbol ); typedef BOOL (WINAPI *_SymFromName)( - __in HANDLE hProcess, - __in PCSTR Name, - __inout PSYMBOL_INFO Symbol + _In_ HANDLE hProcess, + _In_ PCSTR Name, + _Inout_ PSYMBOL_INFO Symbol ); typedef BOOL (WINAPI *_SymFromNameW)( - __in HANDLE hProcess, - __in PCWSTR Name, - __inout PSYMBOL_INFOW Symbol + _In_ HANDLE hProcess, + _In_ PCWSTR Name, + _Inout_ PSYMBOL_INFOW Symbol ); typedef BOOL (WINAPI *_SymGetLineFromAddr64)( - __in HANDLE hProcess, - __in DWORD64 dwAddr, - __out PDWORD pdwDisplacement, - __out PIMAGEHLP_LINE64 Line + _In_ HANDLE hProcess, + _In_ DWORD64 dwAddr, + _Out_ PDWORD pdwDisplacement, + _Out_ PIMAGEHLP_LINE64 Line ); typedef BOOL (WINAPI *_SymGetLineFromAddrW64)( - __in HANDLE hProcess, - __in DWORD64 dwAddr, - __out PDWORD pdwDisplacement, - __out PIMAGEHLP_LINEW64 Line + _In_ HANDLE hProcess, + _In_ DWORD64 dwAddr, + _Out_ PDWORD pdwDisplacement, + _Out_ PIMAGEHLP_LINEW64 Line ); typedef DWORD64 (WINAPI *_SymLoadModule64)( - __in HANDLE hProcess, - __in_opt HANDLE hFile, - __in_opt PCSTR ImageName, - __in_opt PCSTR ModuleName, - __in DWORD64 BaseOfDll, - __in DWORD SizeOfDll + _In_ HANDLE hProcess, + _In_opt_ HANDLE hFile, + _In_opt_ PCSTR ImageName, + _In_opt_ PCSTR ModuleName, + _In_ DWORD64 BaseOfDll, + _In_ DWORD SizeOfDll ); typedef DWORD (WINAPI *_SymGetOptions)(); typedef DWORD (WINAPI *_SymSetOptions)( - __in DWORD SymOptions + _In_ DWORD SymOptions ); typedef BOOL (WINAPI *_SymGetSearchPath)( - __in HANDLE hProcess, - __out PSTR SearchPath, - __in DWORD SearchPathLength + _In_ HANDLE hProcess, + _Out_ PSTR SearchPath, + _In_ DWORD SearchPathLength ); typedef BOOL (WINAPI *_SymGetSearchPathW)( - __in HANDLE hProcess, - __out PWSTR SearchPath, - __in DWORD SearchPathLength + _In_ HANDLE hProcess, + _Out_ PWSTR SearchPath, + _In_ DWORD SearchPathLength ); typedef BOOL (WINAPI *_SymSetSearchPath)( - __in HANDLE hProcess, - __in_opt PCSTR SearchPath + _In_ HANDLE hProcess, + _In_opt_ PCSTR SearchPath ); typedef BOOL (WINAPI *_SymSetSearchPathW)( - __in HANDLE hProcess, - __in_opt PCWSTR SearchPath + _In_ HANDLE hProcess, + _In_opt_ PCWSTR SearchPath ); typedef BOOL (WINAPI *_SymUnloadModule64)( - __in HANDLE hProcess, - __in DWORD64 BaseOfDll + _In_ HANDLE hProcess, + _In_ DWORD64 BaseOfDll ); typedef PVOID (WINAPI *_SymFunctionTableAccess64)( - __in HANDLE hProcess, - __in DWORD64 AddrBase + _In_ HANDLE hProcess, + _In_ DWORD64 AddrBase ); typedef DWORD64 (WINAPI *_SymGetModuleBase64)( - __in HANDLE hProcess, - __in DWORD64 dwAddr + _In_ HANDLE hProcess, + _In_ DWORD64 dwAddr + ); + +typedef BOOL (WINAPI *_SymRegisterCallbackW64)( + _In_ HANDLE hProcess, + _In_ PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, + _In_ ULONG64 UserContext ); typedef BOOL (WINAPI *_StackWalk64)( - __in DWORD MachineType, - __in HANDLE hProcess, - __in HANDLE hThread, - __inout LPSTACKFRAME64 StackFrame, - __inout PVOID ContextRecord, - __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, - __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, - __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, - __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress + _In_ DWORD MachineType, + _In_ HANDLE hProcess, + _In_ HANDLE hThread, + _Inout_ LPSTACKFRAME64 StackFrame, + _Inout_ PVOID ContextRecord, + _In_opt_ PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, + _In_opt_ PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, + _In_opt_ PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, + _In_opt_ PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress ); typedef BOOL (WINAPI *_MiniDumpWriteDump)( - __in HANDLE hProcess, - __in DWORD ProcessId, - __in HANDLE hFile, - __in MINIDUMP_TYPE DumpType, - __in PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, - __in PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, - __in PMINIDUMP_CALLBACK_INFORMATION CallbackParam + _In_ HANDLE hProcess, + _In_ DWORD ProcessId, + _In_ HANDLE hFile, + _In_ MINIDUMP_TYPE DumpType, + _In_ PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, + _In_ PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, + _In_ PMINIDUMP_CALLBACK_INFORMATION CallbackParam ); typedef UINT_PTR (CALLBACK *_SymbolServerGetOptions)(); typedef BOOL (CALLBACK *_SymbolServerSetOptions)( - __in UINT_PTR options, - __in ULONG64 data + _In_ UINT_PTR options, + _In_ ULONG64 data ); #ifdef _M_X64 NTSTATUS PhAccessOutOfProcessFunctionEntry( - __in HANDLE ProcessHandle, - __in ULONG64 ControlPc, - __out PRUNTIME_FUNCTION Function + _In_ HANDLE ProcessHandle, + _In_ ULONG64 ControlPc, + _Out_ PRUNTIME_FUNCTION Function ); #endif ULONG64 __stdcall PhGetModuleBase64( - __in HANDLE hProcess, - __in DWORD64 dwAddr + _In_ HANDLE hProcess, + _In_ DWORD64 dwAddr ); PVOID __stdcall PhFunctionTableAccess64( - __in HANDLE hProcess, - __in DWORD64 AddrBase + _In_ HANDLE hProcess, + _In_ DWORD64 AddrBase ); PHLIBAPI BOOLEAN NTAPI PhStackWalk( - __in ULONG MachineType, - __in HANDLE ProcessHandle, - __in HANDLE ThreadHandle, - __inout STACKFRAME64 *StackFrame, - __inout PVOID ContextRecord, - __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, - __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, - __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, - __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress + _In_ ULONG MachineType, + _In_ HANDLE ProcessHandle, + _In_ HANDLE ThreadHandle, + _Inout_ STACKFRAME64 *StackFrame, + _Inout_ PVOID ContextRecord, + _In_opt_ PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, + _In_opt_ PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, + _In_opt_ PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, + _In_opt_ PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress ); PHLIBAPI BOOLEAN NTAPI PhWriteMiniDumpProcess( - __in HANDLE ProcessHandle, - __in HANDLE ProcessId, - __in HANDLE FileHandle, - __in MINIDUMP_TYPE DumpType, - __in_opt PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, - __in_opt PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, - __in_opt PMINIDUMP_CALLBACK_INFORMATION CallbackParam + _In_ HANDLE ProcessHandle, + _In_ HANDLE ProcessId, + _In_ HANDLE FileHandle, + _In_ MINIDUMP_TYPE DumpType, + _In_opt_ PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, + _In_opt_ PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, + _In_opt_ PMINIDUMP_CALLBACK_INFORMATION CallbackParam ); #ifndef _PH_SYMPRV_PRIVATE extern PH_CALLBACK PhSymInitCallback; +extern PVOID PhSymPreferredDbgHelpBase; #endif #endif diff --git a/2.x/trunk/phlib/include/treenew.h b/2.x/trunk/phlib/include/treenew.h index b02953849..b5e092841 100644 --- a/2.x/trunk/phlib/include/treenew.h +++ b/2.x/trunk/phlib/include/treenew.h @@ -211,11 +211,11 @@ typedef enum _PH_TREENEW_MESSAGE } PH_TREENEW_MESSAGE; typedef BOOLEAN (NTAPI *PPH_TREENEW_CALLBACK)( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); typedef struct _PH_TREENEW_GET_CHILDREN @@ -381,7 +381,8 @@ typedef struct _PH_TREENEW_SEARCH_EVENT #define TNM_HITTEST (WM_USER + 40) #define TNM_GETVISIBLECOLUMNCOUNT (WM_USER + 41) #define TNM_AUTOSIZECOLUMN (WM_USER + 42) -#define TNM_LAST (WM_USER + 42) +#define TNM_SETEMPTYTEXT (WM_USER + 43) +#define TNM_LAST (WM_USER + 43) #define TreeNew_SetCallback(hWnd, Callback, Context) \ SendMessage((hWnd), TNM_SETCALLBACK, (WPARAM)(Context), (LPARAM)(Callback)) @@ -503,6 +504,9 @@ typedef struct _PH_TREENEW_SEARCH_EVENT #define TreeNew_AutoSizeColumn(hWnd, Id) \ SendMessage((hWnd), TNM_AUTOSIZECOLUMN, (WPARAM)(Id), 0) +#define TreeNew_SetEmptyText(hWnd, Text, Flags) \ + SendMessage((hWnd), TNM_SETEMPTYTEXT, (WPARAM)(Flags), (LPARAM)(Text)) + typedef struct _PH_TREENEW_VIEW_PARTS { RECT ClientRect; @@ -522,7 +526,7 @@ BOOLEAN PhTreeNewInitialization( ); FORCEINLINE VOID PhInitializeTreeNewNode( - __in PPH_TREENEW_NODE Node + _In_ PPH_TREENEW_NODE Node ) { memset(Node, 0, sizeof(PH_TREENEW_NODE)); @@ -532,8 +536,8 @@ FORCEINLINE VOID PhInitializeTreeNewNode( } FORCEINLINE VOID PhInvalidateTreeNewNode( - __inout PPH_TREENEW_NODE Node, - __in ULONG Flags + _Inout_ PPH_TREENEW_NODE Node, + _In_ ULONG Flags ) { if (Flags & TN_CACHE_COLOR) @@ -545,14 +549,14 @@ FORCEINLINE VOID PhInvalidateTreeNewNode( } FORCEINLINE BOOLEAN PhAddTreeNewColumn( - __in HWND hwnd, - __in ULONG Id, - __in BOOLEAN Visible, - __in PWSTR Text, - __in ULONG Width, - __in ULONG Alignment, - __in ULONG DisplayIndex, - __in ULONG TextFlags + _In_ HWND hwnd, + _In_ ULONG Id, + _In_ BOOLEAN Visible, + _In_ PWSTR Text, + _In_ ULONG Width, + _In_ ULONG Alignment, + _In_ ULONG DisplayIndex, + _In_ ULONG TextFlags ) { PH_TREENEW_COLUMN column; @@ -573,15 +577,15 @@ FORCEINLINE BOOLEAN PhAddTreeNewColumn( } FORCEINLINE BOOLEAN PhAddTreeNewColumnEx( - __in HWND hwnd, - __in ULONG Id, - __in BOOLEAN Visible, - __in PWSTR Text, - __in ULONG Width, - __in ULONG Alignment, - __in ULONG DisplayIndex, - __in ULONG TextFlags, - __in BOOLEAN SortDescending + _In_ HWND hwnd, + _In_ ULONG Id, + _In_ BOOLEAN Visible, + _In_ PWSTR Text, + _In_ ULONG Width, + _In_ ULONG Alignment, + _In_ ULONG DisplayIndex, + _In_ ULONG TextFlags, + _In_ BOOLEAN SortDescending ) { PH_TREENEW_COLUMN column; diff --git a/2.x/trunk/phlib/include/treenewp.h b/2.x/trunk/phlib/include/treenewp.h index 264f239b0..bf5b398fc 100644 --- a/2.x/trunk/phlib/include/treenewp.h +++ b/2.x/trunk/phlib/include/treenewp.h @@ -150,571 +150,573 @@ typedef struct _PH_TREENEW_CONTEXT LONG EnableRedraw; HRGN SuspendUpdateRegion; + + PH_STRINGREF EmptyText; } PH_TREENEW_CONTEXT, *PPH_TREENEW_CONTEXT; LRESULT CALLBACK PhTnpWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); BOOLEAN NTAPI PhTnpNullCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); VOID PhTnpCreateTreeNewContext( - __out PPH_TREENEW_CONTEXT *Context + _Out_ PPH_TREENEW_CONTEXT *Context ); VOID PhTnpDestroyTreeNewContext( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); // Event handlers BOOLEAN PhTnpOnCreate( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in CREATESTRUCT *CreateStruct + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ CREATESTRUCT *CreateStruct ); VOID PhTnpOnSize( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpOnSetFont( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in_opt HFONT Font, - __in LOGICAL Redraw + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ HFONT Font, + _In_ LOGICAL Redraw ); VOID PhTnpOnStyleChanged( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG Type, - __in STYLESTRUCT *StyleStruct + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Type, + _In_ STYLESTRUCT *StyleStruct ); VOID PhTnpOnSettingChange( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpOnThemeChanged( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ); ULONG PhTnpOnGetDlgCode( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey, - __in_opt PMSG Message + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey, + _In_opt_ PMSG Message ); VOID PhTnpOnPaint( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpOnPrintClient( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in ULONG Flags + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ ULONG Flags ); BOOLEAN PhTnpOnNcPaint( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in_opt HRGN UpdateRegion + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ HRGN UpdateRegion ); BOOLEAN PhTnpOnSetCursor( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in HWND CursorWindowHandle + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HWND CursorWindowHandle ); VOID PhTnpOnTimer( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id ); VOID PhTnpOnMouseMove( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ); VOID PhTnpOnMouseLeave( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpOnXxxButtonXxx( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Message, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Message, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ); VOID PhTnpOnCaptureChanged( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpOnKeyDown( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey, - __in ULONG Data + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey, + _In_ ULONG Data ); VOID PhTnpOnChar( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Character, - __in ULONG Data + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Character, + _In_ ULONG Data ); VOID PhTnpOnMouseWheel( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ); VOID PhTnpOnMouseHWheel( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ); VOID PhTnpOnContextMenu( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorScreenX, - __in LONG CursorScreenY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorScreenX, + _In_ LONG CursorScreenY ); VOID PhTnpOnVScroll( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Request + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Request ); VOID PhTnpOnHScroll( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Request + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Request ); BOOLEAN PhTnpOnNotify( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in NMHDR *Header, - __out LRESULT *Result + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ NMHDR *Header, + _Out_ LRESULT *Result ); ULONG_PTR PhTnpOnUserMessage( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Message, - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Message, + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ); // Misc. VOID PhTnpSetFont( - __in PPH_TREENEW_CONTEXT Context, - __in_opt HFONT Font, - __in BOOLEAN Redraw + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ HFONT Font, + _In_ BOOLEAN Redraw ); VOID PhTnpUpdateSystemMetrics( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpUpdateTextMetrics( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpUpdateThemeData( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpInitializeThemeData( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpCancelTrack( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpLayout( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpLayoutHeader( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpSetFixedWidth( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG FixedWidth + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG FixedWidth ); VOID PhTnpSetRedraw( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Redraw + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Redraw ); VOID PhTnpSendMouseEvent( - __in PPH_TREENEW_CONTEXT Context, - __in PH_TREENEW_MESSAGE Message, - __in LONG CursorX, - __in LONG CursorY, - __in PPH_TREENEW_NODE Node, - __in PPH_TREENEW_COLUMN Column, - __in ULONG VirtualKeys + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PH_TREENEW_MESSAGE Message, + _In_ LONG CursorX, + _In_ LONG CursorY, + _In_ PPH_TREENEW_NODE Node, + _In_ PPH_TREENEW_COLUMN Column, + _In_ ULONG VirtualKeys ); // Columns PPH_TREENEW_COLUMN PhTnpLookupColumnById( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id ); BOOLEAN PhTnpAddColumn( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN Column ); BOOLEAN PhTnpRemoveColumn( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id ); BOOLEAN PhTnpCopyColumn( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id, - __out PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id, + _Out_ PPH_TREENEW_COLUMN Column ); BOOLEAN PhTnpChangeColumn( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Mask, - __in ULONG Id, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Mask, + _In_ ULONG Id, + _In_ PPH_TREENEW_COLUMN Column ); VOID PhTnpExpandAllocatedColumns( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpUpdateColumnMaps( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); // Columns (header control) LONG PhTnpInsertColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN Column ); VOID PhTnpChangeColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Mask, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Mask, + _In_ PPH_TREENEW_COLUMN Column ); VOID PhTnpDeleteColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __inout PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _Inout_ PPH_TREENEW_COLUMN Column ); VOID PhTnpUpdateColumnHeaders( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpProcessResizeColumn( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN Column, - __in LONG Delta + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN Column, + _In_ LONG Delta ); VOID PhTnpProcessSortColumn( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN NewColumn + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN NewColumn ); BOOLEAN PhTnpSetColumnHeaderSortIcon( - __in PPH_TREENEW_CONTEXT Context, - __in_opt PPH_TREENEW_COLUMN SortColumnPointer + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ PPH_TREENEW_COLUMN SortColumnPointer ); VOID PhTnpAutoSizeColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __in HWND HeaderHandle, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HWND HeaderHandle, + _In_ PPH_TREENEW_COLUMN Column ); // Nodes BOOLEAN PhTnpGetNodeChildren( - __in PPH_TREENEW_CONTEXT Context, - __in_opt PPH_TREENEW_NODE Node, - __out PPH_TREENEW_NODE **Children, - __out PULONG NumberOfChildren + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ PPH_TREENEW_NODE Node, + _Out_ PPH_TREENEW_NODE **Children, + _Out_ PULONG NumberOfChildren ); BOOLEAN PhTnpIsNodeLeaf( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node ); BOOLEAN PhTnpGetCellText( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in ULONG Id, - __out PPH_STRINGREF Text + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ ULONG Id, + _Out_ PPH_STRINGREF Text ); VOID PhTnpRestructureNodes( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpInsertNodeChildren( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in ULONG Level + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ ULONG Level ); VOID PhTnpSetExpandedNode( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in BOOLEAN Expanded + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ BOOLEAN Expanded ); BOOLEAN PhTnpGetCellParts( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Index, - __in_opt PPH_TREENEW_COLUMN Column, - __in ULONG Flags, - __out PPH_TREENEW_CELL_PARTS Parts + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Index, + _In_opt_ PPH_TREENEW_COLUMN Column, + _In_ ULONG Flags, + _Out_ PPH_TREENEW_CELL_PARTS Parts ); BOOLEAN PhTnpGetRowRects( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Start, - __in ULONG End, - __in BOOLEAN Clip, - __out PRECT Rect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Start, + _In_ ULONG End, + _In_ BOOLEAN Clip, + _Out_ PRECT Rect ); VOID PhTnpHitTest( - __in PPH_TREENEW_CONTEXT Context, - __inout PPH_TREENEW_HIT_TEST HitTest + _In_ PPH_TREENEW_CONTEXT Context, + _Inout_ PPH_TREENEW_HIT_TEST HitTest ); VOID PhTnpSelectRange( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Start, - __in ULONG End, - __in ULONG Flags, - __out_opt PULONG ChangedStart, - __out_opt PULONG ChangedEnd + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Start, + _In_ ULONG End, + _In_ ULONG Flags, + _Out_opt_ PULONG ChangedStart, + _Out_opt_ PULONG ChangedEnd ); VOID PhTnpSetHotNode( - __in PPH_TREENEW_CONTEXT Context, - __in_opt PPH_TREENEW_NODE NewHotNode, - __in BOOLEAN NewPlusMinusHot + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ PPH_TREENEW_NODE NewHotNode, + _In_ BOOLEAN NewPlusMinusHot ); VOID PhTnpProcessSelectNode( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in LOGICAL ControlKey, - __in LOGICAL ShiftKey, - __in LOGICAL RightButton + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ LOGICAL ControlKey, + _In_ LOGICAL ShiftKey, + _In_ LOGICAL RightButton ); BOOLEAN PhTnpEnsureVisibleNode( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Index + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Index ); // Mouse VOID PhTnpProcessMoveMouse( - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorX, - __in LONG CursorY + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorX, + _In_ LONG CursorY ); VOID PhTnpProcessMouseVWheel( - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance ); VOID PhTnpProcessMouseHWheel( - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance ); // Keyboard BOOLEAN PhTnpProcessFocusKey( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey ); BOOLEAN PhTnpProcessNodeKey( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey ); VOID PhTnpProcessSearchKey( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Character + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Character ); BOOLEAN PhTnpDefaultIncrementalSearch( - __in PPH_TREENEW_CONTEXT Context, - __inout PPH_TREENEW_SEARCH_EVENT SearchEvent, - __in BOOLEAN Partial, - __in BOOLEAN Wrap + _In_ PPH_TREENEW_CONTEXT Context, + _Inout_ PPH_TREENEW_SEARCH_EVENT SearchEvent, + _In_ BOOLEAN Partial, + _In_ BOOLEAN Wrap ); // Scrolling VOID PhTnpUpdateScrollBars( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpScroll( - __in PPH_TREENEW_CONTEXT Context, - __in LONG DeltaRows, - __in LONG DeltaX + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG DeltaRows, + _In_ LONG DeltaX ); VOID PhTnpProcessScroll( - __in PPH_TREENEW_CONTEXT Context, - __in LONG DeltaRows, - __in LONG DeltaX + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG DeltaRows, + _In_ LONG DeltaX ); BOOLEAN PhTnpCanScroll( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Horizontal, - __in BOOLEAN Positive + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Horizontal, + _In_ BOOLEAN Positive ); // Drawing VOID PhTnpPaint( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in PRECT PaintRect + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ PRECT PaintRect ); VOID PhTnpPrepareRowForDraw( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __inout PPH_TREENEW_NODE Node + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _Inout_ PPH_TREENEW_NODE Node ); VOID PhTnpDrawCell( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in PRECT CellRect, - __in PPH_TREENEW_NODE Node, - __in PPH_TREENEW_COLUMN Column, - __in LONG RowIndex, - __in LONG ColumnIndex + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ PRECT CellRect, + _In_ PPH_TREENEW_NODE Node, + _In_ PPH_TREENEW_COLUMN Column, + _In_ LONG RowIndex, + _In_ LONG ColumnIndex ); VOID PhTnpDrawDivider( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc ); VOID PhTnpDrawPlusMinusGlyph( - __in HDC hdc, - __in PRECT Rect, - __in BOOLEAN Plus + _In_ HDC hdc, + _In_ PRECT Rect, + _In_ BOOLEAN Plus ); VOID PhTnpDrawSelectionRectangle( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in PRECT Rect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ PRECT Rect ); VOID PhTnpDrawThemedBorder( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc ); // Tooltips VOID PhTnpInitializeTooltips( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpGetTooltipText( - __in PPH_TREENEW_CONTEXT Context, - __in PPOINT Point, - __out PWSTR *Text + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPOINT Point, + _Out_ PWSTR *Text ); BOOLEAN PhTnpPrepareTooltipShow( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpPrepareTooltipPop( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpPopTooltip( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); PPH_TREENEW_COLUMN PhTnpHitTestHeader( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Fixed, - __in PPOINT Point, - __out_opt PRECT ItemRect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Fixed, + _In_ PPOINT Point, + _Out_opt_ PRECT ItemRect ); VOID PhTnpGetHeaderTooltipText( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Fixed, - __in PPOINT Point, - __out PWSTR *Text + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Fixed, + _In_ PPOINT Point, + _Out_ PWSTR *Text ); PWSTR PhTnpMakeContextAtom( @@ -722,51 +724,51 @@ PWSTR PhTnpMakeContextAtom( ); LRESULT CALLBACK PhTnpHeaderHookWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // Drag selection BOOLEAN PhTnpDetectDrag( - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorX, - __in LONG CursorY, - __in BOOLEAN DispatchMessages, - __out_opt PULONG CancelledByMessage + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorX, + _In_ LONG CursorY, + _In_ BOOLEAN DispatchMessages, + _Out_opt_ PULONG CancelledByMessage ); VOID PhTnpDragSelect( - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorX, - __in LONG CursorY + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorX, + _In_ LONG CursorY ); VOID PhTnpProcessDragSelect( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKeys, - __in PRECT OldRect, - __in PRECT NewRect, - __in PRECT TotalRect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKeys, + _In_ PRECT OldRect, + _In_ PRECT NewRect, + _In_ PRECT TotalRect ); // Double buffering VOID PhTnpCreateBufferedContext( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); VOID PhTnpDestroyBufferedContext( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ); // Support functions VOID PhTnpGetMessagePos( - __in HWND hwnd, - __out PPOINT ClientPoint + _In_ HWND hwnd, + _Out_ PPOINT ClientPoint ); // Macros diff --git a/2.x/trunk/phlib/include/verify.h b/2.x/trunk/phlib/include/verify.h new file mode 100644 index 000000000..bc6c74416 --- /dev/null +++ b/2.x/trunk/phlib/include/verify.h @@ -0,0 +1,40 @@ +#ifndef _PH_VERIFY_H +#define _PH_VERIFY_H + +#include +#include + +#define PH_VERIFY_DEFAULT_SIZE_LIMIT (32 * 1024 * 1024) + +#define PH_VERIFY_PREVENT_NETWORK_ACCESS 0x1 +#define PH_VERIFY_VIEW_PROPERTIES 0x2 + +typedef struct _PH_VERIFY_FILE_INFO +{ + PWSTR FileName; + ULONG Flags; + + ULONG FileSizeLimitForHash; // 0 for PH_VERIFY_DEFAULT_SIZE_LIMIT, -1 for unlimited + ULONG NumberOfCatalogFileNames; + PWSTR *CatalogFileNames; + + HWND hWnd; // for PH_VERIFY_VIEW_PROPERTIES +} PH_VERIFY_FILE_INFO, *PPH_VERIFY_FILE_INFO; + +NTSTATUS PhVerifyFileEx( + _In_ PPH_VERIFY_FILE_INFO Information, + _Out_ VERIFY_RESULT *VerifyResult, + _Out_opt_ PCERT_CONTEXT **Signatures, + _Out_opt_ PULONG NumberOfSignatures + ); + +VOID PhFreeVerifySignatures( + _In_ PCERT_CONTEXT *Signatures, + _In_ ULONG NumberOfSignatures + ); + +PPH_STRING PhGetSignerNameFromCertificate( + _In_ PCERT_CONTEXT Certificate + ); + +#endif diff --git a/2.x/trunk/phlib/include/verifyp.h b/2.x/trunk/phlib/include/verifyp.h index f5d725b64..e934d4fb0 100644 --- a/2.x/trunk/phlib/include/verifyp.h +++ b/2.x/trunk/phlib/include/verifyp.h @@ -1,15 +1,27 @@ #ifndef _PH_VERIFYP_H #define _PH_VERIFYP_H -#include -#include - typedef struct _CATALOG_INFO { DWORD cbStruct; WCHAR wszCatalogFile[MAX_PATH]; } CATALOG_INFO, *PCATALOG_INFO; +typedef struct tagCRYPTUI_VIEWSIGNERINFO_STRUCT { + DWORD dwSize; + HWND hwndParent; + DWORD dwFlags; + LPCTSTR szTitle; + CMSG_SIGNER_INFO *pSignerInfo; + HCRYPTMSG hMsg; + LPCSTR pszOID; + DWORD_PTR dwReserved; + DWORD cStores; + HCERTSTORE *rghStores; + DWORD cPropSheetPages; + LPCPROPSHEETPAGE rgPropSheetPages; +} CRYPTUI_VIEWSIGNERINFO_STRUCT, *PCRYPTUI_VIEWSIGNERINFO_STRUCT; + typedef BOOL (WINAPI *_CryptCATAdminCalcHashFromFileHandle)( HANDLE hFile, DWORD *pcbHash, @@ -89,4 +101,16 @@ typedef DWORD (WINAPI *_CertNameToStr)( DWORD csz ); +typedef PCCERT_CONTEXT (WINAPI *_CertDuplicateCertificateContext)( + _In_ PCCERT_CONTEXT pCertContext + ); + +typedef BOOL (WINAPI *_CertFreeCertificateContext)( + _In_ PCCERT_CONTEXT pCertContext + ); + +typedef BOOL (WINAPI *_CryptUIDlgViewSignerInfo)( + _In_ CRYPTUI_VIEWSIGNERINFO_STRUCT *pcvsi + ); + #endif diff --git a/2.x/trunk/phlib/include/winmisc.h b/2.x/trunk/phlib/include/winmisc.h index 971a91f95..3a90ed4e9 100644 --- a/2.x/trunk/phlib/include/winmisc.h +++ b/2.x/trunk/phlib/include/winmisc.h @@ -86,9 +86,9 @@ typedef struct _TAG_INFO_NAME_TAG_MAPPING // rev typedef ULONG (WINAPI *PQUERY_TAG_INFORMATION)( - __in PCWSTR Reserved, // ? - __in TAG_INFO_LEVEL InfoLevel, - __inout PVOID Data + _In_ PCWSTR Reserved, // ? + _In_ TAG_INFO_LEVEL InfoLevel, + _Inout_ PVOID Data ); #endif diff --git a/2.x/trunk/phlib/include/winsta.h b/2.x/trunk/phlib/include/winsta.h index 20dee018a..2737cf5c3 100644 --- a/2.x/trunk/phlib/include/winsta.h +++ b/2.x/trunk/phlib/include/winsta.h @@ -495,70 +495,70 @@ typedef struct _TS_COUNTER BOOLEAN WINAPI WinStationFreeMemory( - __in PVOID Buffer + _In_ PVOID Buffer ); // rev HANDLE WINAPI WinStationOpenServerW( - __in PWSTR ServerName + _In_ PWSTR ServerName ); // rev BOOLEAN WINAPI WinStationCloseServer( - __in HANDLE hServer + _In_ HANDLE hServer ); // rev BOOLEAN WINAPI WinStationServerPing( - __in_opt HANDLE hServer + _In_opt_ HANDLE hServer ); // rev BOOLEAN WINAPI WinStationGetTermSrvCountersValue( - __in_opt HANDLE hServer, - __in ULONG Count, - __inout PTS_COUNTER Counters // set counter IDs before calling + _In_opt_ HANDLE hServer, + _In_ ULONG Count, + _Inout_ PTS_COUNTER Counters // set counter IDs before calling ); BOOLEAN WINAPI WinStationShutdownSystem( - __in_opt HANDLE hServer, - __in ULONG ShutdownFlags // WSD_* + _In_opt_ HANDLE hServer, + _In_ ULONG ShutdownFlags // WSD_* ); // rev BOOLEAN WINAPI WinStationWaitSystemEvent( - __in_opt HANDLE hServer, - __in ULONG EventMask, // WEVENT_* - __out PULONG EventFlags + _In_opt_ HANDLE hServer, + _In_ ULONG EventMask, // WEVENT_* + _Out_ PULONG EventFlags ); // rev BOOLEAN WINAPI WinStationRegisterConsoleNotification( - __in_opt HANDLE hServer, - __in HWND WindowHandle, - __in ULONG Flags + _In_opt_ HANDLE hServer, + _In_ HWND WindowHandle, + _In_ ULONG Flags ); // rev BOOLEAN WINAPI WinStationUnRegisterConsoleNotification( - __in_opt HANDLE hServer, - __in HWND WindowHandle + _In_opt_ HANDLE hServer, + _In_ HWND WindowHandle ); // Sessions @@ -567,102 +567,102 @@ WinStationUnRegisterConsoleNotification( BOOLEAN WINAPI WinStationEnumerateW( - __in_opt HANDLE hServer, - __out PSESSIONIDW *SessionIds, - __out PULONG Count + _In_opt_ HANDLE hServer, + _Out_ PSESSIONIDW *SessionIds, + _Out_ PULONG Count ); BOOLEAN WINAPI WinStationQueryInformationW( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __in WINSTATIONINFOCLASS WinStationInformationClass, - __out_bcount(WinStationInformationLength) PVOID pWinStationInformation, - __in ULONG WinStationInformationLength, - __out PULONG pReturnLength + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _In_ WINSTATIONINFOCLASS WinStationInformationClass, + _Out_writes_bytes_(WinStationInformationLength) PVOID pWinStationInformation, + _In_ ULONG WinStationInformationLength, + _Out_ PULONG pReturnLength ); // rev BOOLEAN WINAPI WinStationSetInformationW( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __in WINSTATIONINFOCLASS WinStationInformationClass, - __in_bcount(WinStationInformationLength) PVOID pWinStationInformation, - __in ULONG WinStationInformationLength + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _In_ WINSTATIONINFOCLASS WinStationInformationClass, + _In_reads_bytes_(WinStationInformationLength) PVOID pWinStationInformation, + _In_ ULONG WinStationInformationLength ); BOOLEAN WINAPI WinStationNameFromLogonIdW( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __out_ecount(WINSTATIONNAME_LENGTH + 1) PWSTR pWinStationName + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _Out_writes_(WINSTATIONNAME_LENGTH + 1) PWSTR pWinStationName ); // rev BOOLEAN WINAPI WinStationSendMessageW( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __in PWSTR Title, - __in ULONG TitleLength, - __in PWSTR Message, - __in ULONG MessageLength, - __in ULONG Style, - __in ULONG Timeout, - __out PULONG Response, - __in BOOLEAN DoNotWait + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _In_ PWSTR Title, + _In_ ULONG TitleLength, + _In_ PWSTR Message, + _In_ ULONG MessageLength, + _In_ ULONG Style, + _In_ ULONG Timeout, + _Out_ PULONG Response, + _In_ BOOLEAN DoNotWait ); BOOLEAN WINAPI WinStationConnectW( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __in ULONG TargetSessionId, - __in_opt PWSTR pPassword, - __in BOOLEAN bWait + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _In_ ULONG TargetSessionId, + _In_opt_ PWSTR pPassword, + _In_ BOOLEAN bWait ); BOOLEAN WINAPI WinStationDisconnect( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __in BOOLEAN bWait + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _In_ BOOLEAN bWait ); // rev BOOLEAN WINAPI WinStationReset( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __in BOOLEAN bWait + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _In_ BOOLEAN bWait ); // rev BOOLEAN WINAPI WinStationShadow( - __in_opt HANDLE hServer, - __in PWSTR TargetServerName, - __in ULONG TargetSessionId, - __in UCHAR HotKeyVk, - __in USHORT HotkeyModifiers // KBD* + _In_opt_ HANDLE hServer, + _In_ PWSTR TargetServerName, + _In_ ULONG TargetSessionId, + _In_ UCHAR HotKeyVk, + _In_ USHORT HotkeyModifiers // KBD* ); // rev BOOLEAN WINAPI WinStationShadowStop( - __in_opt HANDLE hServer, - __in ULONG SessionId, - __in BOOLEAN bWait // ignored + _In_opt_ HANDLE hServer, + _In_ ULONG SessionId, + _In_ BOOLEAN bWait // ignored ); // Processes @@ -671,46 +671,46 @@ WinStationShadowStop( BOOLEAN WINAPI WinStationEnumerateProcesses( - __in_opt HANDLE hServer, - __out PVOID *Processes + _In_opt_ HANDLE hServer, + _Out_ PVOID *Processes ); // rev BOOLEAN WINAPI WinStationGetAllProcesses( - __in_opt HANDLE hServer, - __in ULONG Level, - __out PULONG NumberOfProcesses, - __out PTS_ALL_PROCESSES_INFO *Processes + _In_opt_ HANDLE hServer, + _In_ ULONG Level, + _Out_ PULONG NumberOfProcesses, + _Out_ PTS_ALL_PROCESSES_INFO *Processes ); // rev BOOLEAN WINAPI WinStationFreeGAPMemory( - __in ULONG Level, - __in PTS_ALL_PROCESSES_INFO Processes, - __in ULONG NumberOfProcesses + _In_ ULONG Level, + _In_ PTS_ALL_PROCESSES_INFO Processes, + _In_ ULONG NumberOfProcesses ); // rev BOOLEAN WINAPI WinStationTerminateProcess( - __in_opt HANDLE hServer, - __in ULONG ProcessId, - __in ULONG ExitCode + _In_opt_ HANDLE hServer, + _In_ ULONG ProcessId, + _In_ ULONG ExitCode ); BOOLEAN WINAPI WinStationGetProcessSid( - __in_opt HANDLE hServer, - __in ULONG ProcessId, - __in FILETIME ProcessStartTime, - __out PVOID pProcessUserSid, - __inout PULONG dwSidSize + _In_opt_ HANDLE hServer, + _In_ ULONG ProcessId, + _In_ FILETIME ProcessStartTime, + _Out_ PVOID pProcessUserSid, + _Inout_ PULONG dwSidSize ); // Services isolation diff --git a/2.x/trunk/phlib/iosup.c b/2.x/trunk/phlib/iosup.c index 05b88cc50..ac941e93e 100644 --- a/2.x/trunk/phlib/iosup.c +++ b/2.x/trunk/phlib/iosup.c @@ -70,13 +70,13 @@ BOOLEAN PhIoSupportInitialization( * \param CreateOptions The options to apply when the file is opened or created. */ NTSTATUS PhCreateFileWin32( - __out PHANDLE FileHandle, - __in PWSTR FileName, - __in ACCESS_MASK DesiredAccess, - __in_opt ULONG FileAttributes, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions + _Out_ PHANDLE FileHandle, + _In_ PWSTR FileName, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ ULONG FileAttributes, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions ) { return PhCreateFileWin32Ex( @@ -127,14 +127,14 @@ NTSTATUS PhCreateFileWin32( * \c FILE_OVERWRITE was specified in \a CreateDisposition. */ NTSTATUS PhCreateFileWin32Ex( - __out PHANDLE FileHandle, - __in PWSTR FileName, - __in ACCESS_MASK DesiredAccess, - __in_opt ULONG FileAttributes, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG CreateOptions, - __out_opt PULONG CreateStatus + _Out_ PHANDLE FileHandle, + _In_ PWSTR FileName, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ ULONG FileAttributes, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG CreateOptions, + _Out_opt_ PULONG CreateStatus ) { NTSTATUS status; @@ -196,8 +196,8 @@ NTSTATUS PhCreateFileWin32Ex( * \param FileInformation A variable that receives the file information. */ NTSTATUS PhQueryFullAttributesFileWin32( - __in PWSTR FileName, - __out PFILE_NETWORK_OPEN_INFORMATION FileInformation + _In_ PWSTR FileName, + _Out_ PFILE_NETWORK_OPEN_INFORMATION FileInformation ) { NTSTATUS status; @@ -232,7 +232,7 @@ NTSTATUS PhQueryFullAttributesFileWin32( * \param FileName The Win32 file name. */ NTSTATUS PhDeleteFileWin32( - __in PWSTR FileName + _In_ PWSTR FileName ) { NTSTATUS status; @@ -257,11 +257,11 @@ NTSTATUS PhDeleteFileWin32( } NTSTATUS PhListenNamedPipe( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock ) { return NtFsControlFile( @@ -279,7 +279,7 @@ NTSTATUS PhListenNamedPipe( } NTSTATUS PhDisconnectNamedPipe( - __in HANDLE FileHandle + _In_ HANDLE FileHandle ) { NTSTATUS status; @@ -310,12 +310,12 @@ NTSTATUS PhDisconnectNamedPipe( } NTSTATUS PhPeekNamedPipe( - __in HANDLE FileHandle, - __out_bcount_opt(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG NumberOfBytesRead, - __out_opt PULONG NumberOfBytesAvailable, - __out_opt PULONG NumberOfBytesLeftInMessage + _In_ HANDLE FileHandle, + _Out_writes_bytes_opt_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG NumberOfBytesRead, + _Out_opt_ PULONG NumberOfBytesAvailable, + _Out_opt_ PULONG NumberOfBytesLeftInMessage ) { NTSTATUS status; @@ -377,15 +377,15 @@ NTSTATUS PhPeekNamedPipe( } NTSTATUS PhTransceiveNamedPipe( - __in HANDLE FileHandle, - __in_opt HANDLE Event, - __in_opt PIO_APC_ROUTINE ApcRoutine, - __in_opt PVOID ApcContext, - __out PIO_STATUS_BLOCK IoStatusBlock, - __in_bcount(InputBufferLength) PVOID InputBuffer, - __in ULONG InputBufferLength, - __out_bcount(OutputBufferLength) PVOID OutputBuffer, - __in ULONG OutputBufferLength + _In_ HANDLE FileHandle, + _In_opt_ HANDLE Event, + _In_opt_ PIO_APC_ROUTINE ApcRoutine, + _In_opt_ PVOID ApcContext, + _Out_ PIO_STATUS_BLOCK IoStatusBlock, + _In_reads_bytes_(InputBufferLength) PVOID InputBuffer, + _In_ ULONG InputBufferLength, + _Out_writes_bytes_(OutputBufferLength) PVOID OutputBuffer, + _In_ ULONG OutputBufferLength ) { return NtFsControlFile( @@ -403,10 +403,10 @@ NTSTATUS PhTransceiveNamedPipe( } NTSTATUS PhWaitForNamedPipe( - __in_opt PUNICODE_STRING FileSystemName, - __in PUNICODE_STRING Name, - __in_opt PLARGE_INTEGER Timeout, - __in BOOLEAN UseDefaultTimeout + _In_opt_ PUNICODE_STRING FileSystemName, + _In_ PUNICODE_STRING Name, + _In_opt_ PLARGE_INTEGER Timeout, + _In_ BOOLEAN UseDefaultTimeout ) { NTSTATUS status; @@ -488,7 +488,7 @@ NTSTATUS PhWaitForNamedPipe( } NTSTATUS PhImpersonateClientOfNamedPipe( - __in HANDLE FileHandle + _In_ HANDLE FileHandle ) { NTSTATUS status; @@ -511,12 +511,12 @@ NTSTATUS PhImpersonateClientOfNamedPipe( } NTSTATUS PhCreateFileStream( - __out PPH_FILE_STREAM *FileStream, - __in PWSTR FileName, - __in ACCESS_MASK DesiredAccess, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in ULONG Flags + _Out_ PPH_FILE_STREAM *FileStream, + _In_ PWSTR FileName, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_ ULONG Flags ) { NTSTATUS status; @@ -574,10 +574,10 @@ NTSTATUS PhCreateFileStream( } NTSTATUS PhCreateFileStream2( - __out PPH_FILE_STREAM *FileStream, - __in HANDLE FileHandle, - __in ULONG Flags, - __in ULONG BufferLength + _Out_ PPH_FILE_STREAM *FileStream, + _In_ HANDLE FileHandle, + _In_ ULONG Flags, + _In_ ULONG BufferLength ) { NTSTATUS status; @@ -616,8 +616,8 @@ NTSTATUS PhCreateFileStream2( } VOID NTAPI PhpFileStreamDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_FILE_STREAM fileStream = (PPH_FILE_STREAM)Object; @@ -636,7 +636,7 @@ VOID NTAPI PhpFileStreamDeleteProcedure( * the position held by the file object. */ VOID PhVerifyFileStream( - __in PPH_FILE_STREAM FileStream + _In_ PPH_FILE_STREAM FileStream ) { NTSTATUS status; @@ -666,7 +666,7 @@ VOID PhVerifyFileStream( } NTSTATUS PhpAllocateBufferFileStream( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ) { FileStream->Buffer = PhAllocatePage(FileStream->BufferLength, NULL); @@ -678,10 +678,10 @@ NTSTATUS PhpAllocateBufferFileStream( } NTSTATUS PhpReadFileStream( - __inout PPH_FILE_STREAM FileStream, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG ReadLength + _Inout_ PPH_FILE_STREAM FileStream, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReadLength ) { NTSTATUS status; @@ -727,10 +727,10 @@ NTSTATUS PhpReadFileStream( } NTSTATUS PhReadFileStream( - __inout PPH_FILE_STREAM FileStream, - __out_bcount(Length) PVOID Buffer, - __in ULONG Length, - __out_opt PULONG ReadLength + _Inout_ PPH_FILE_STREAM FileStream, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Length, + _Out_opt_ PULONG ReadLength ) { NTSTATUS status = STATUS_SUCCESS; @@ -851,9 +851,9 @@ NTSTATUS PhReadFileStream( } NTSTATUS PhpWriteFileStream( - __inout PPH_FILE_STREAM FileStream, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ) { NTSTATUS status; @@ -897,9 +897,9 @@ NTSTATUS PhpWriteFileStream( } NTSTATUS PhWriteFileStream( - __inout PPH_FILE_STREAM FileStream, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ) { NTSTATUS status = STATUS_SUCCESS; @@ -994,7 +994,7 @@ NTSTATUS PhWriteFileStream( } NTSTATUS PhpFlushReadFileStream( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ) { NTSTATUS status = STATUS_SUCCESS; @@ -1023,7 +1023,7 @@ NTSTATUS PhpFlushReadFileStream( } NTSTATUS PhpFlushWriteFileStream( - __inout PPH_FILE_STREAM FileStream + _Inout_ PPH_FILE_STREAM FileStream ) { NTSTATUS status = STATUS_SUCCESS; @@ -1049,8 +1049,8 @@ NTSTATUS PhpFlushWriteFileStream( * is flushed to the operating system. */ NTSTATUS PhFlushFileStream( - __inout PPH_FILE_STREAM FileStream, - __in BOOLEAN Full + _Inout_ PPH_FILE_STREAM FileStream, + _In_ BOOLEAN Full ) { NTSTATUS status = STATUS_SUCCESS; @@ -1082,8 +1082,8 @@ NTSTATUS PhFlushFileStream( } VOID PhGetPositionFileStream( - __in PPH_FILE_STREAM FileStream, - __out PLARGE_INTEGER Position + _In_ PPH_FILE_STREAM FileStream, + _Out_ PLARGE_INTEGER Position ) { Position->QuadPart = @@ -1093,9 +1093,9 @@ VOID PhGetPositionFileStream( } NTSTATUS PhpSeekFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Offset, - __in PH_SEEK_ORIGIN Origin + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Offset, + _In_ PH_SEEK_ORIGIN Origin ) { NTSTATUS status = STATUS_SUCCESS; @@ -1146,9 +1146,9 @@ NTSTATUS PhpSeekFileStream( } NTSTATUS PhSeekFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Offset, - __in PH_SEEK_ORIGIN Origin + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Offset, + _In_ PH_SEEK_ORIGIN Origin ) { NTSTATUS status = STATUS_SUCCESS; @@ -1187,11 +1187,11 @@ NTSTATUS PhSeekFileStream( } NTSTATUS PhLockFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Position, - __in PLARGE_INTEGER Length, - __in BOOLEAN Wait, - __in BOOLEAN Shared + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Position, + _In_ PLARGE_INTEGER Length, + _In_ BOOLEAN Wait, + _In_ BOOLEAN Shared ) { NTSTATUS status; @@ -1222,9 +1222,9 @@ NTSTATUS PhLockFileStream( } NTSTATUS PhUnlockFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PLARGE_INTEGER Position, - __in PLARGE_INTEGER Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PLARGE_INTEGER Position, + _In_ PLARGE_INTEGER Length ) { IO_STATUS_BLOCK isb; @@ -1239,16 +1239,16 @@ NTSTATUS PhUnlockFileStream( } NTSTATUS PhWriteStringAsAnsiFileStream( - __inout PPH_FILE_STREAM FileStream, - __in PPH_STRINGREF String + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PPH_STRINGREF String ) { return PhWriteStringAsAnsiFileStreamEx(FileStream, String->Buffer, String->Length); } NTSTATUS PhWriteStringAsAnsiFileStream2( - __inout PPH_FILE_STREAM FileStream, - __in PWSTR String + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PWSTR String ) { PH_STRINGREF string; @@ -1259,9 +1259,9 @@ NTSTATUS PhWriteStringAsAnsiFileStream2( } NTSTATUS PhWriteStringAsAnsiFileStreamEx( - __inout PPH_FILE_STREAM FileStream, - __in PWSTR Buffer, - __in SIZE_T Length + _Inout_ PPH_FILE_STREAM FileStream, + _In_ PWSTR Buffer, + _In_ SIZE_T Length ) { NTSTATUS status = STATUS_SUCCESS; @@ -1299,9 +1299,9 @@ NTSTATUS PhWriteStringAsAnsiFileStreamEx( } NTSTATUS PhWriteStringFormatFileStream_V( - __inout PPH_FILE_STREAM FileStream, - __in __format_string PWSTR Format, - __in va_list ArgPtr + _Inout_ PPH_FILE_STREAM FileStream, + _In_ _Printf_format_string_ PWSTR Format, + _In_ va_list ArgPtr ) { NTSTATUS status; @@ -1315,8 +1315,8 @@ NTSTATUS PhWriteStringFormatFileStream_V( } NTSTATUS PhWriteStringFormatFileStream( - __inout PPH_FILE_STREAM FileStream, - __in __format_string PWSTR Format, + _Inout_ PPH_FILE_STREAM FileStream, + _In_ _Printf_format_string_ PWSTR Format, ... ) { diff --git a/2.x/trunk/phlib/kph.c b/2.x/trunk/phlib/kph.c index 4e6064e52..f7fcfb6a8 100644 --- a/2.x/trunk/phlib/kph.c +++ b/2.x/trunk/phlib/kph.c @@ -24,15 +24,15 @@ #include NTSTATUS KphpDeviceIoControl( - __in ULONG KphControlCode, - __in PVOID InBuffer, - __in ULONG InBufferLength + _In_ ULONG KphControlCode, + _In_ PVOID InBuffer, + _In_ ULONG InBufferLength ); HANDLE PhKphHandle = NULL; NTSTATUS KphConnect( - __in_opt PWSTR DeviceName + _In_opt_ PWSTR DeviceName ) { NTSTATUS status; @@ -88,17 +88,17 @@ NTSTATUS KphConnect( } NTSTATUS KphConnect2( - __in_opt PWSTR DeviceName, - __in PWSTR FileName + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName ) { return KphConnect2Ex(DeviceName, FileName, NULL); } NTSTATUS KphConnect2Ex( - __in_opt PWSTR DeviceName, - __in PWSTR FileName, - __in_opt PKPH_PARAMETERS Parameters + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName, + _In_opt_ PKPH_PARAMETERS Parameters ) { NTSTATUS status; @@ -261,8 +261,8 @@ BOOLEAN KphIsConnected( } NTSTATUS KphSetParameters( - __in_opt PWSTR DeviceName, - __in PKPH_PARAMETERS Parameters + _In_opt_ PWSTR DeviceName, + _In_ PKPH_PARAMETERS Parameters ) { NTSTATUS status; @@ -334,17 +334,17 @@ NTSTATUS KphSetParameters( } NTSTATUS KphInstall( - __in_opt PWSTR DeviceName, - __in PWSTR FileName + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName ) { return KphInstallEx(DeviceName, FileName, NULL); } NTSTATUS KphInstallEx( - __in_opt PWSTR DeviceName, - __in PWSTR FileName, - __in_opt PKPH_PARAMETERS Parameters + _In_opt_ PWSTR DeviceName, + _In_ PWSTR FileName, + _In_opt_ PKPH_PARAMETERS Parameters ) { NTSTATUS status = STATUS_SUCCESS; @@ -406,7 +406,7 @@ NTSTATUS KphInstallEx( } NTSTATUS KphUninstall( - __in_opt PWSTR DeviceName + _In_opt_ PWSTR DeviceName ) { NTSTATUS status = STATUS_SUCCESS; @@ -445,9 +445,9 @@ NTSTATUS KphUninstall( } NTSTATUS KphpDeviceIoControl( - __in ULONG KphControlCode, - __in PVOID InBuffer, - __in ULONG InBufferLength + _In_ ULONG KphControlCode, + _In_ PVOID InBuffer, + _In_ ULONG InBufferLength ) { IO_STATUS_BLOCK isb; @@ -467,7 +467,7 @@ NTSTATUS KphpDeviceIoControl( } NTSTATUS KphGetFeatures( - __out PULONG Features + _Out_ PULONG Features ) { struct @@ -483,9 +483,9 @@ NTSTATUS KphGetFeatures( } NTSTATUS KphOpenProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in PCLIENT_ID ClientId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PCLIENT_ID ClientId ) { struct @@ -503,9 +503,9 @@ NTSTATUS KphOpenProcess( } NTSTATUS KphOpenProcessToken( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE TokenHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE TokenHandle ) { struct @@ -523,9 +523,9 @@ NTSTATUS KphOpenProcessToken( } NTSTATUS KphOpenProcessJob( - __in HANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE JobHandle + _In_ HANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE JobHandle ) { struct @@ -543,7 +543,7 @@ NTSTATUS KphOpenProcessJob( } NTSTATUS KphSuspendProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ) { struct @@ -559,7 +559,7 @@ NTSTATUS KphSuspendProcess( } NTSTATUS KphResumeProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ) { struct @@ -575,8 +575,8 @@ NTSTATUS KphResumeProcess( } NTSTATUS KphTerminateProcess( - __in HANDLE ProcessHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ProcessHandle, + _In_ NTSTATUS ExitStatus ) { NTSTATUS status; @@ -603,11 +603,11 @@ NTSTATUS KphTerminateProcess( } NTSTATUS KphReadVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ) { struct @@ -627,11 +627,11 @@ NTSTATUS KphReadVirtualMemory( } NTSTATUS KphWriteVirtualMemory( - __in HANDLE ProcessHandle, - __in_opt PVOID BaseAddress, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE ProcessHandle, + _In_opt_ PVOID BaseAddress, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ) { struct @@ -651,11 +651,11 @@ NTSTATUS KphWriteVirtualMemory( } NTSTATUS KphReadVirtualMemoryUnsafe( - __in_opt HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_opt_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ) { struct @@ -675,11 +675,11 @@ NTSTATUS KphReadVirtualMemoryUnsafe( } NTSTATUS KphQueryInformationProcess( - __in HANDLE ProcessHandle, - __in KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, - __out_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _In_ KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, + _Out_writes_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength, + _Out_opt_ PULONG ReturnLength ) { struct @@ -699,10 +699,10 @@ NTSTATUS KphQueryInformationProcess( } NTSTATUS KphSetInformationProcess( - __in HANDLE ProcessHandle, - __in KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, - __in_bcount(ProcessInformationLength) PVOID ProcessInformation, - __in ULONG ProcessInformationLength + _In_ HANDLE ProcessHandle, + _In_ KPH_PROCESS_INFORMATION_CLASS ProcessInformationClass, + _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, + _In_ ULONG ProcessInformationLength ) { struct @@ -721,9 +721,9 @@ NTSTATUS KphSetInformationProcess( } NTSTATUS KphOpenThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in PCLIENT_ID ClientId + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PCLIENT_ID ClientId ) { struct @@ -741,9 +741,9 @@ NTSTATUS KphOpenThread( } NTSTATUS KphOpenThreadProcess( - __in HANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __out PHANDLE ProcessHandle + _In_ HANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _Out_ PHANDLE ProcessHandle ) { struct @@ -761,8 +761,8 @@ NTSTATUS KphOpenThreadProcess( } NTSTATUS KphTerminateThread( - __in HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ) { NTSTATUS status; @@ -787,8 +787,8 @@ NTSTATUS KphTerminateThread( } NTSTATUS KphTerminateThreadUnsafe( - __in HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ) { struct @@ -805,8 +805,8 @@ NTSTATUS KphTerminateThreadUnsafe( } NTSTATUS KphGetContextThread( - __in HANDLE ThreadHandle, - __inout PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _Inout_ PCONTEXT ThreadContext ) { struct @@ -823,8 +823,8 @@ NTSTATUS KphGetContextThread( } NTSTATUS KphSetContextThread( - __in HANDLE ThreadHandle, - __in PCONTEXT ThreadContext + _In_ HANDLE ThreadHandle, + _In_ PCONTEXT ThreadContext ) { struct @@ -841,12 +841,12 @@ NTSTATUS KphSetContextThread( } NTSTATUS KphCaptureStackBackTraceThread( - __in HANDLE ThreadHandle, - __in ULONG FramesToSkip, - __in ULONG FramesToCapture, - __out_ecount(FramesToCapture) PVOID *BackTrace, - __out_opt PULONG CapturedFrames, - __out_opt PULONG BackTraceHash + _In_ HANDLE ThreadHandle, + _In_ ULONG FramesToSkip, + _In_ ULONG FramesToCapture, + _Out_writes_(FramesToCapture) PVOID *BackTrace, + _Out_opt_ PULONG CapturedFrames, + _Out_opt_ PULONG BackTraceHash ) { struct @@ -867,11 +867,11 @@ NTSTATUS KphCaptureStackBackTraceThread( } NTSTATUS KphQueryInformationThread( - __in HANDLE ThreadHandle, - __in KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, - __out_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ThreadHandle, + _In_ KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, + _Out_writes_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength, + _Out_opt_ PULONG ReturnLength ) { struct @@ -891,10 +891,10 @@ NTSTATUS KphQueryInformationThread( } NTSTATUS KphSetInformationThread( - __in HANDLE ThreadHandle, - __in KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, - __in_bcount(ThreadInformationLength) PVOID ThreadInformation, - __in ULONG ThreadInformationLength + _In_ HANDLE ThreadHandle, + _In_ KPH_THREAD_INFORMATION_CLASS ThreadInformationClass, + _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, + _In_ ULONG ThreadInformationLength ) { struct @@ -913,10 +913,10 @@ NTSTATUS KphSetInformationThread( } NTSTATUS KphEnumerateProcessHandles( - __in HANDLE ProcessHandle, - __out_bcount(BufferLength) PVOID Buffer, - __in_opt ULONG BufferLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _Out_writes_bytes_(BufferLength) PVOID Buffer, + _In_opt_ ULONG BufferLength, + _Out_opt_ PULONG ReturnLength ) { struct @@ -935,12 +935,12 @@ NTSTATUS KphEnumerateProcessHandles( } NTSTATUS KphQueryInformationObject( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, - __out_bcount(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, + _Out_writes_bytes_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength, + _Out_opt_ PULONG ReturnLength ) { struct @@ -961,11 +961,11 @@ NTSTATUS KphQueryInformationObject( } NTSTATUS KphSetInformationObject( - __in HANDLE ProcessHandle, - __in HANDLE Handle, - __in KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, - __in_bcount(ObjectInformationLength) PVOID ObjectInformation, - __in ULONG ObjectInformationLength + _In_ HANDLE ProcessHandle, + _In_ HANDLE Handle, + _In_ KPH_OBJECT_INFORMATION_CLASS ObjectInformationClass, + _In_reads_bytes_(ObjectInformationLength) PVOID ObjectInformation, + _In_ ULONG ObjectInformationLength ) { struct @@ -985,13 +985,13 @@ NTSTATUS KphSetInformationObject( } NTSTATUS KphDuplicateObject( - __in HANDLE SourceProcessHandle, - __in HANDLE SourceHandle, - __in_opt HANDLE TargetProcessHandle, - __out_opt PHANDLE TargetHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Options + _In_ HANDLE SourceProcessHandle, + _In_ HANDLE SourceHandle, + _In_opt_ HANDLE TargetProcessHandle, + _Out_opt_ PHANDLE TargetHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Options ) { NTSTATUS status; @@ -1023,8 +1023,8 @@ NTSTATUS KphDuplicateObject( } NTSTATUS KphOpenDriver( - __out PHANDLE DriverHandle, - __in POBJECT_ATTRIBUTES ObjectAttributes + _Out_ PHANDLE DriverHandle, + _In_ POBJECT_ATTRIBUTES ObjectAttributes ) { struct @@ -1041,11 +1041,11 @@ NTSTATUS KphOpenDriver( } NTSTATUS KphQueryInformationDriver( - __in HANDLE DriverHandle, - __in DRIVER_INFORMATION_CLASS DriverInformationClass, - __out_bcount(DriverInformationLength) PVOID DriverInformation, - __in ULONG DriverInformationLength, - __out_opt PULONG ReturnLength + _In_ HANDLE DriverHandle, + _In_ DRIVER_INFORMATION_CLASS DriverInformationClass, + _Out_writes_bytes_(DriverInformationLength) PVOID DriverInformation, + _In_ ULONG DriverInformationLength, + _Out_opt_ PULONG ReturnLength ) { struct diff --git a/2.x/trunk/phlib/kphdata.c b/2.x/trunk/phlib/kphdata.c index 66ac7e07c..cb098dc85 100644 --- a/2.x/trunk/phlib/kphdata.c +++ b/2.x/trunk/phlib/kphdata.c @@ -2,7 +2,7 @@ * Process Hacker - * KProcessHacker dynamic data definitions * - * Copyright (C) 2011-2012 wj32 + * Copyright (C) 2011-2013 wj32 * * This file is part of Process Hacker. * @@ -26,7 +26,7 @@ #ifdef _M_X64 NTSTATUS KphInitializeDynamicPackage( - __out PKPH_DYN_PACKAGE Package + _Out_ PKPH_DYN_PACKAGE Package ) { ULONG majorVersion, minorVersion, servicePack, buildNumber; @@ -70,8 +70,6 @@ NTSTATUS KphInitializeDynamicPackage( Package->StructData.EgeGuid = 0x14; Package->StructData.EpObjectTable = 0x160; - Package->StructData.EpProtectedProcessOff = 0x36c; - Package->StructData.EpProtectedProcessBit = 0xb; Package->StructData.EpRundownProtect = 0xd8; Package->StructData.EreGuidEntry = 0x10; } @@ -93,14 +91,12 @@ NTSTATUS KphInitializeDynamicPackage( Package->StructData.EgeGuid = 0x14; Package->StructData.EpObjectTable = 0x200; - Package->StructData.EpProtectedProcessOff = 0x43c; - Package->StructData.EpProtectedProcessBit = 0xb; Package->StructData.EpRundownProtect = 0x178; Package->StructData.EreGuidEntry = 0x10; Package->StructData.OtName = 0x10; Package->StructData.OtIndex = 0x28; // now only a UCHAR, not a ULONG } - // Windows 8 + // Windows 8, Windows Server 2012 else if (majorVersion == 6 && minorVersion == 2 && buildNumber == 9200) { Package->BuildNumber = 9200; @@ -108,13 +104,29 @@ NTSTATUS KphInitializeDynamicPackage( Package->StructData.EgeGuid = 0x14; Package->StructData.EpObjectTable = 0x408; - Package->StructData.EpProtectedProcessOff = -1; // now SE_SIGNING_LEVEL, no longer relevant - Package->StructData.EpProtectedProcessBit = -1; Package->StructData.EpRundownProtect = 0x2d8; Package->StructData.EreGuidEntry = 0x10; Package->StructData.HtHandleContentionEvent = 0x30; Package->StructData.OtName = 0x10; Package->StructData.OtIndex = 0x28; + Package->StructData.ObDecodeShift = 19; + Package->StructData.ObAttributesShift = 20; + } + // Windows 8.1, Windows Server 2012 R2 + else if (majorVersion == 6 && minorVersion == 3 && buildNumber == 9600) + { + Package->BuildNumber = 9600; + Package->ResultingNtVersion = PHNT_WINBLUE; + + Package->StructData.EgeGuid = 0x18; + Package->StructData.EpObjectTable = 0x408; + Package->StructData.EpRundownProtect = 0x2d8; + Package->StructData.EreGuidEntry = 0x10; + Package->StructData.HtHandleContentionEvent = 0x30; + Package->StructData.OtName = 0x10; + Package->StructData.OtIndex = 0x28; + Package->StructData.ObDecodeShift = 16; + Package->StructData.ObAttributesShift = 17; } else { @@ -127,7 +139,7 @@ NTSTATUS KphInitializeDynamicPackage( #else NTSTATUS KphInitializeDynamicPackage( - __out PKPH_DYN_PACKAGE Package + _Out_ PKPH_DYN_PACKAGE Package ) { ULONG majorVersion, minorVersion, servicePack, buildNumber; diff --git a/2.x/trunk/phlib/lsa.c b/2.x/trunk/phlib/lsa.c index 400992c28..5cae7b164 100644 --- a/2.x/trunk/phlib/lsa.c +++ b/2.x/trunk/phlib/lsa.c @@ -34,9 +34,9 @@ static LSA_HANDLE PhLookupPolicyHandle = NULL; NTSTATUS PhOpenLsaPolicy( - __out PLSA_HANDLE PolicyHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt PUNICODE_STRING SystemName + _Out_ PLSA_HANDLE PolicyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ PUNICODE_STRING SystemName ) { OBJECT_ATTRIBUTES oa = { 0 }; @@ -112,8 +112,8 @@ LSA_HANDLE PhGetLookupPolicyHandle( * PhDereferenceObject() when you no longer need it. */ BOOLEAN PhLookupPrivilegeName( - __in PLUID PrivilegeValue, - __out PPH_STRING *PrivilegeName + _In_ PLUID PrivilegeValue, + _Out_ PPH_STRING *PrivilegeName ) { NTSTATUS status; @@ -144,8 +144,8 @@ BOOLEAN PhLookupPrivilegeName( * PhDereferenceObject() when you no longer need it. */ BOOLEAN PhLookupPrivilegeDisplayName( - __in PPH_STRINGREF PrivilegeName, - __out PPH_STRING *PrivilegeDisplayName + _In_ PPH_STRINGREF PrivilegeName, + _Out_ PPH_STRING *PrivilegeDisplayName ) { NTSTATUS status; @@ -179,8 +179,8 @@ BOOLEAN PhLookupPrivilegeDisplayName( * the LUID of the privilege. */ BOOLEAN PhLookupPrivilegeValue( - __in PPH_STRINGREF PrivilegeName, - __out PLUID PrivilegeValue + _In_ PPH_STRINGREF PrivilegeName, + _Out_ PLUID PrivilegeValue ) { UNICODE_STRING privilegeName; @@ -210,10 +210,10 @@ BOOLEAN PhLookupPrivilegeValue( * SID's usage. */ NTSTATUS PhLookupSid( - __in PSID Sid, - __out_opt PPH_STRING *Name, - __out_opt PPH_STRING *DomainName, - __out_opt PSID_NAME_USE NameUse + _In_ PSID Sid, + _Out_opt_ PPH_STRING *Name, + _Out_opt_ PPH_STRING *DomainName, + _Out_opt_ PSID_NAME_USE NameUse ) { NTSTATUS status; @@ -291,10 +291,10 @@ NTSTATUS PhLookupSid( * SID's usage. */ NTSTATUS PhLookupName( - __in PPH_STRINGREF Name, - __out_opt PSID *Sid, - __out_opt PPH_STRING *DomainName, - __out_opt PSID_NAME_USE NameUse + _In_ PPH_STRINGREF Name, + _Out_opt_ PSID *Sid, + _Out_opt_ PPH_STRING *DomainName, + _Out_opt_ PSID_NAME_USE NameUse ) { NTSTATUS status; @@ -385,9 +385,9 @@ NTSTATUS PhLookupName( * returns NULL. */ PPH_STRING PhGetSidFullName( - __in PSID Sid, - __in BOOLEAN IncludeDomain, - __out_opt PSID_NAME_USE NameUse + _In_ PSID Sid, + _In_ BOOLEAN IncludeDomain, + _Out_opt_ PSID_NAME_USE NameUse ) { NTSTATUS status; @@ -475,7 +475,7 @@ PPH_STRING PhGetSidFullName( * the function returns NULL. */ PPH_STRING PhSidToStringSid( - __in PSID Sid + _In_ PSID Sid ) { PPH_STRING string; diff --git a/2.x/trunk/phlib/mapimg.c b/2.x/trunk/phlib/mapimg.c index 5a210a9ae..67b505577 100644 --- a/2.x/trunk/phlib/mapimg.c +++ b/2.x/trunk/phlib/mapimg.c @@ -32,20 +32,20 @@ #include VOID PhpMappedImageProbe( - __in PPH_MAPPED_IMAGE MappedImage, - __in PVOID Address, - __in SIZE_T Length + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ PVOID Address, + _In_ SIZE_T Length ); ULONG PhpLookupMappedImageExportName( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in PSTR Name + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_ PSTR Name ); NTSTATUS PhInitializeMappedImage( - __out PPH_MAPPED_IMAGE MappedImage, - __in PVOID ViewBase, - __in SIZE_T Size + _Out_ PPH_MAPPED_IMAGE MappedImage, + _In_ PVOID ViewBase, + _In_ SIZE_T Size ) { PIMAGE_DOS_HEADER dosHeader; @@ -127,10 +127,10 @@ NTSTATUS PhInitializeMappedImage( } NTSTATUS PhLoadMappedImage( - __in_opt PWSTR FileName, - __in_opt HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __out PPH_MAPPED_IMAGE MappedImage + _In_opt_ PWSTR FileName, + _In_opt_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _Out_ PPH_MAPPED_IMAGE MappedImage ) { NTSTATUS status; @@ -161,7 +161,7 @@ NTSTATUS PhLoadMappedImage( } NTSTATUS PhUnloadMappedImage( - __inout PPH_MAPPED_IMAGE MappedImage + _Inout_ PPH_MAPPED_IMAGE MappedImage ) { return NtUnmapViewOfSection( @@ -171,11 +171,11 @@ NTSTATUS PhUnloadMappedImage( } NTSTATUS PhMapViewOfEntireFile( - __in_opt PWSTR FileName, - __in_opt HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __out PVOID *ViewBase, - __out PSIZE_T Size + _In_opt_ PWSTR FileName, + _In_opt_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _Out_ PVOID *ViewBase, + _Out_ PSIZE_T Size ) { NTSTATUS status; @@ -262,17 +262,17 @@ NTSTATUS PhMapViewOfEntireFile( } VOID PhpMappedImageProbe( - __in PPH_MAPPED_IMAGE MappedImage, - __in PVOID Address, - __in SIZE_T Length + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ PVOID Address, + _In_ SIZE_T Length ) { PhProbeAddress(Address, Length, MappedImage->ViewBase, MappedImage->Size, 1); } PIMAGE_SECTION_HEADER PhMappedImageRvaToSection( - __in PPH_MAPPED_IMAGE MappedImage, - __in ULONG Rva + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ ULONG Rva ) { ULONG i; @@ -292,9 +292,9 @@ PIMAGE_SECTION_HEADER PhMappedImageRvaToSection( } PVOID PhMappedImageRvaToVa( - __in PPH_MAPPED_IMAGE MappedImage, - __in ULONG Rva, - __out_opt PIMAGE_SECTION_HEADER *Section + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ ULONG Rva, + _Out_opt_ PIMAGE_SECTION_HEADER *Section ) { PIMAGE_SECTION_HEADER section; @@ -315,10 +315,10 @@ PVOID PhMappedImageRvaToVa( } BOOLEAN PhGetMappedImageSectionName( - __in PIMAGE_SECTION_HEADER Section, - __out_ecount_z_opt(Count) PSTR Buffer, - __in ULONG Count, - __out_opt PULONG ReturnCount + _In_ PIMAGE_SECTION_HEADER Section, + _Out_writes_opt_z_(Count) PSTR Buffer, + _In_ ULONG Count, + _Out_opt_ PULONG ReturnCount ) { return PhCopyAnsiStringZ( @@ -331,9 +331,9 @@ BOOLEAN PhGetMappedImageSectionName( } NTSTATUS PhGetMappedImageDataEntry( - __in PPH_MAPPED_IMAGE MappedImage, - __in ULONG Index, - __out PIMAGE_DATA_DIRECTORY *Entry + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ ULONG Index, + _Out_ PIMAGE_DATA_DIRECTORY *Entry ) { if (MappedImage->Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) @@ -367,10 +367,10 @@ NTSTATUS PhGetMappedImageDataEntry( } FORCEINLINE NTSTATUS PhpGetMappedImageLoadConfig( - __in PPH_MAPPED_IMAGE MappedImage, - __in USHORT Magic, - __in ULONG ProbeLength, - __out PVOID *LoadConfig + _In_ PPH_MAPPED_IMAGE MappedImage, + _In_ USHORT Magic, + _In_ ULONG ProbeLength, + _Out_ PVOID *LoadConfig ) { NTSTATUS status; @@ -405,8 +405,8 @@ FORCEINLINE NTSTATUS PhpGetMappedImageLoadConfig( } NTSTATUS PhGetMappedImageLoadConfig32( - __in PPH_MAPPED_IMAGE MappedImage, - __out PIMAGE_LOAD_CONFIG_DIRECTORY32 *LoadConfig + _In_ PPH_MAPPED_IMAGE MappedImage, + _Out_ PIMAGE_LOAD_CONFIG_DIRECTORY32 *LoadConfig ) { return PhpGetMappedImageLoadConfig( @@ -418,8 +418,8 @@ NTSTATUS PhGetMappedImageLoadConfig32( } NTSTATUS PhGetMappedImageLoadConfig64( - __in PPH_MAPPED_IMAGE MappedImage, - __out PIMAGE_LOAD_CONFIG_DIRECTORY64 *LoadConfig + _In_ PPH_MAPPED_IMAGE MappedImage, + _Out_ PIMAGE_LOAD_CONFIG_DIRECTORY64 *LoadConfig ) { return PhpGetMappedImageLoadConfig( @@ -431,9 +431,9 @@ NTSTATUS PhGetMappedImageLoadConfig64( } NTSTATUS PhLoadRemoteMappedImage( - __in HANDLE ProcessHandle, - __in PVOID ViewBase, - __out PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage + _In_ HANDLE ProcessHandle, + _In_ PVOID ViewBase, + _Out_ PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage ) { NTSTATUS status; @@ -526,7 +526,7 @@ NTSTATUS PhLoadRemoteMappedImage( } NTSTATUS PhUnloadRemoteMappedImage( - __inout PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage + _Inout_ PPH_REMOTE_MAPPED_IMAGE RemoteMappedImage ) { PhFree(RemoteMappedImage->NtHeaders); @@ -535,8 +535,8 @@ NTSTATUS PhUnloadRemoteMappedImage( } NTSTATUS PhGetMappedImageExports( - __out PPH_MAPPED_IMAGE_EXPORTS Exports, - __in PPH_MAPPED_IMAGE MappedImage + _Out_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_ PPH_MAPPED_IMAGE MappedImage ) { NTSTATUS status; @@ -634,9 +634,9 @@ NTSTATUS PhGetMappedImageExports( } NTSTATUS PhGetMappedImageExportEntry( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in ULONG Index, - __out PPH_MAPPED_IMAGE_EXPORT_ENTRY Entry + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_ ULONG Index, + _Out_ PPH_MAPPED_IMAGE_EXPORT_ENTRY Entry ) { PSTR name; @@ -670,10 +670,10 @@ NTSTATUS PhGetMappedImageExportEntry( } NTSTATUS PhGetMappedImageExportFunction( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in_opt PSTR Name, - __in_opt USHORT Ordinal, - __out PPH_MAPPED_IMAGE_EXPORT_FUNCTION Function + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_opt_ PSTR Name, + _In_opt_ USHORT Ordinal, + _Out_ PPH_MAPPED_IMAGE_EXPORT_FUNCTION Function ) { ULONG rva; @@ -731,11 +731,11 @@ NTSTATUS PhGetMappedImageExportFunction( } NTSTATUS PhGetMappedImageExportFunctionRemote( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in_opt PSTR Name, - __in_opt USHORT Ordinal, - __in PVOID RemoteBase, - __out PVOID *Function + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_opt_ PSTR Name, + _In_opt_ USHORT Ordinal, + _In_ PVOID RemoteBase, + _Out_ PVOID *Function ) { ULONG rva; @@ -776,8 +776,8 @@ NTSTATUS PhGetMappedImageExportFunctionRemote( } ULONG PhpLookupMappedImageExportName( - __in PPH_MAPPED_IMAGE_EXPORTS Exports, - __in PSTR Name + _In_ PPH_MAPPED_IMAGE_EXPORTS Exports, + _In_ PSTR Name ) { LONG low; @@ -822,8 +822,8 @@ ULONG PhpLookupMappedImageExportName( } NTSTATUS PhGetMappedImageImports( - __out PPH_MAPPED_IMAGE_IMPORTS Imports, - __in PPH_MAPPED_IMAGE MappedImage + _Out_ PPH_MAPPED_IMAGE_IMPORTS Imports, + _In_ PPH_MAPPED_IMAGE MappedImage ) { NTSTATUS status; @@ -882,9 +882,9 @@ NTSTATUS PhGetMappedImageImports( } NTSTATUS PhGetMappedImageImportDll( - __in PPH_MAPPED_IMAGE_IMPORTS Imports, - __in ULONG Index, - __out PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll + _In_ PPH_MAPPED_IMAGE_IMPORTS Imports, + _In_ ULONG Index, + _Out_ PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll ) { ULONG i; @@ -1023,9 +1023,9 @@ NTSTATUS PhGetMappedImageImportDll( } NTSTATUS PhGetMappedImageImportEntry( - __in PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll, - __in ULONG Index, - __out PPH_MAPPED_IMAGE_IMPORT_ENTRY Entry + _In_ PPH_MAPPED_IMAGE_IMPORT_DLL ImportDll, + _In_ ULONG Index, + _Out_ PPH_MAPPED_IMAGE_IMPORT_ENTRY Entry ) { PIMAGE_IMPORT_BY_NAME importByName; @@ -1109,8 +1109,8 @@ NTSTATUS PhGetMappedImageImportEntry( } NTSTATUS PhGetMappedImageDelayImports( - __out PPH_MAPPED_IMAGE_IMPORTS Imports, - __in PPH_MAPPED_IMAGE MappedImage + _Out_ PPH_MAPPED_IMAGE_IMPORTS Imports, + _In_ PPH_MAPPED_IMAGE MappedImage ) { NTSTATUS status; @@ -1169,7 +1169,7 @@ NTSTATUS PhGetMappedImageDelayImports( } ULONG PhCheckSumMappedImage( - __in PPH_MAPPED_IMAGE MappedImage + _In_ PPH_MAPPED_IMAGE MappedImage ) { ULONG checkSum; diff --git a/2.x/trunk/phlib/maplib.c b/2.x/trunk/phlib/maplib.c index d3034fd47..4891ade8b 100644 --- a/2.x/trunk/phlib/maplib.c +++ b/2.x/trunk/phlib/maplib.c @@ -31,21 +31,21 @@ #include VOID PhpMappedArchiveProbe( - __in PPH_MAPPED_ARCHIVE MappedArchive, - __in PVOID Address, - __in SIZE_T Length + _In_ PPH_MAPPED_ARCHIVE MappedArchive, + _In_ PVOID Address, + _In_ SIZE_T Length ); NTSTATUS PhpGetMappedArchiveMemberFromHeader( - __in PPH_MAPPED_ARCHIVE MappedArchive, - __in PIMAGE_ARCHIVE_MEMBER_HEADER Header, - __out PPH_MAPPED_ARCHIVE_MEMBER Member + _In_ PPH_MAPPED_ARCHIVE MappedArchive, + _In_ PIMAGE_ARCHIVE_MEMBER_HEADER Header, + _Out_ PPH_MAPPED_ARCHIVE_MEMBER Member ); NTSTATUS PhInitializeMappedArchive( - __out PPH_MAPPED_ARCHIVE MappedArchive, - __in PVOID ViewBase, - __in SIZE_T Size + _Out_ PPH_MAPPED_ARCHIVE MappedArchive, + _In_ PVOID ViewBase, + _In_ SIZE_T Size ) { NTSTATUS status; @@ -130,10 +130,10 @@ NTSTATUS PhInitializeMappedArchive( } NTSTATUS PhLoadMappedArchive( - __in_opt PWSTR FileName, - __in_opt HANDLE FileHandle, - __in BOOLEAN ReadOnly, - __out PPH_MAPPED_ARCHIVE MappedArchive + _In_opt_ PWSTR FileName, + _In_opt_ HANDLE FileHandle, + _In_ BOOLEAN ReadOnly, + _Out_ PPH_MAPPED_ARCHIVE MappedArchive ) { NTSTATUS status; @@ -164,7 +164,7 @@ NTSTATUS PhLoadMappedArchive( } NTSTATUS PhUnloadMappedArchive( - __inout PPH_MAPPED_ARCHIVE MappedArchive + _Inout_ PPH_MAPPED_ARCHIVE MappedArchive ) { return NtUnmapViewOfSection( @@ -174,9 +174,9 @@ NTSTATUS PhUnloadMappedArchive( } VOID PhpMappedArchiveProbe( - __in PPH_MAPPED_ARCHIVE MappedArchive, - __in PVOID Address, - __in SIZE_T Length + _In_ PPH_MAPPED_ARCHIVE MappedArchive, + _In_ PVOID Address, + _In_ SIZE_T Length ) { PhProbeAddress(Address, Length, MappedArchive->ViewBase, MappedArchive->Size, 1); @@ -191,8 +191,8 @@ VOID PhpMappedArchiveProbe( * the same as the pointer specified in \a Member. */ NTSTATUS PhGetNextMappedArchiveMember( - __in PPH_MAPPED_ARCHIVE_MEMBER Member, - __out PPH_MAPPED_ARCHIVE_MEMBER NextMember + _In_ PPH_MAPPED_ARCHIVE_MEMBER Member, + _Out_ PPH_MAPPED_ARCHIVE_MEMBER NextMember ) { PIMAGE_ARCHIVE_MEMBER_HEADER nextHeader; @@ -214,9 +214,9 @@ NTSTATUS PhGetNextMappedArchiveMember( } NTSTATUS PhpGetMappedArchiveMemberFromHeader( - __in PPH_MAPPED_ARCHIVE MappedArchive, - __in PIMAGE_ARCHIVE_MEMBER_HEADER Header, - __out PPH_MAPPED_ARCHIVE_MEMBER Member + _In_ PPH_MAPPED_ARCHIVE MappedArchive, + _In_ PIMAGE_ARCHIVE_MEMBER_HEADER Header, + _Out_ PPH_MAPPED_ARCHIVE_MEMBER Member ) { WCHAR integerString[11]; @@ -356,7 +356,7 @@ NTSTATUS PhpGetMappedArchiveMemberFromHeader( } BOOLEAN PhIsMappedArchiveMemberShortFormat( - __in PPH_MAPPED_ARCHIVE_MEMBER Member + _In_ PPH_MAPPED_ARCHIVE_MEMBER Member ) { PIMAGE_FILE_HEADER header; @@ -367,8 +367,8 @@ BOOLEAN PhIsMappedArchiveMemberShortFormat( } NTSTATUS PhGetMappedArchiveImportEntry( - __in PPH_MAPPED_ARCHIVE_MEMBER Member, - __out PPH_MAPPED_ARCHIVE_IMPORT_ENTRY Entry + _In_ PPH_MAPPED_ARCHIVE_MEMBER Member, + _Out_ PPH_MAPPED_ARCHIVE_IMPORT_ENTRY Entry ) { IMPORT_OBJECT_HEADER *importHeader; diff --git a/2.x/trunk/phlib/md5.c b/2.x/trunk/phlib/md5.c index 3b0540fcd..6563e9dbb 100644 --- a/2.x/trunk/phlib/md5.c +++ b/2.x/trunk/phlib/md5.c @@ -19,7 +19,7 @@ void MD5Transform(ULONG buf[4], ULONG in[16]); * initialization constants. */ VOID MD5Init( - __out MD5_CTX *Context + _Out_ MD5_CTX *Context ) { Context->buf[0] = 0x67452301; @@ -36,9 +36,9 @@ VOID MD5Init( * of bytes. */ VOID MD5Update( - __inout MD5_CTX *Context, - __in_bcount(Length) UCHAR *Input, - __in ULONG Length + _Inout_ MD5_CTX *Context, + _In_reads_bytes_(Length) UCHAR *Input, + _In_ ULONG Length ) { ULONG t; @@ -86,7 +86,7 @@ VOID MD5Update( * 1 0* (64-bit count of bits processed, MSB-first) */ VOID MD5Final( - __inout MD5_CTX *Context + _Inout_ MD5_CTX *Context ) { unsigned int count; diff --git a/2.x/trunk/phlib/native.c b/2.x/trunk/phlib/native.c index 1033c19e1..95fd55749 100644 --- a/2.x/trunk/phlib/native.c +++ b/2.x/trunk/phlib/native.c @@ -28,19 +28,19 @@ #define PH_DEVICE_MUP_PREFIX_MAX_COUNT 16 typedef BOOLEAN (NTAPI *PPHP_ENUM_PROCESS_MODULES_CALLBACK)( - __in HANDLE ProcessHandle, - __in PLDR_DATA_TABLE_ENTRY Entry, - __in PVOID AddressOfEntry, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PLDR_DATA_TABLE_ENTRY Entry, + _In_ PVOID AddressOfEntry, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ); typedef BOOLEAN (NTAPI *PPHP_ENUM_PROCESS_MODULES32_CALLBACK)( - __in HANDLE ProcessHandle, - __in PLDR_DATA_TABLE_ENTRY32 Entry, - __in ULONG AddressOfEntry, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PLDR_DATA_TABLE_ENTRY32 Entry, + _In_ ULONG AddressOfEntry, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ); static PH_INITONCE PhDevicePrefixesInitOnce = PH_INITONCE_INIT; @@ -70,9 +70,9 @@ static HANDLE PhPredefineKeyHandles[PH_KEY_MAXIMUM_PREDEFINE] = { 0 }; * \param ProcessId The ID of the process. */ NTSTATUS PhOpenProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ProcessId + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ProcessId ) { OBJECT_ATTRIBUTES objectAttributes; @@ -110,9 +110,9 @@ NTSTATUS PhOpenProcess( * \param ThreadId The ID of the thread. */ NTSTATUS PhOpenThread( - __out PHANDLE ThreadHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ThreadId + _Out_ PHANDLE ThreadHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ThreadId ) { OBJECT_ATTRIBUTES objectAttributes; @@ -143,9 +143,9 @@ NTSTATUS PhOpenThread( } NTSTATUS PhOpenThreadProcess( - __out PHANDLE ProcessHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ThreadHandle + _Out_ PHANDLE ProcessHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ThreadHandle ) { if (KphIsConnected()) @@ -183,9 +183,9 @@ NTSTATUS PhOpenThreadProcess( * \param ProcessHandle A handle to a process. */ NTSTATUS PhOpenProcessToken( - __out PHANDLE TokenHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ProcessHandle + _Out_ PHANDLE TokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ProcessHandle ) { if (KphIsConnected()) @@ -216,10 +216,10 @@ NTSTATUS PhOpenProcessToken( * FALSE to use the impersonation token. */ NTSTATUS PhOpenThreadToken( - __out PHANDLE TokenHandle, - __in ACCESS_MASK DesiredAccess, - __in HANDLE ThreadHandle, - __in BOOLEAN OpenAsSelf + _Out_ PHANDLE TokenHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ HANDLE ThreadHandle, + _In_ BOOLEAN OpenAsSelf ) { return NtOpenThreadToken( @@ -231,9 +231,9 @@ NTSTATUS PhOpenThreadToken( } NTSTATUS PhGetObjectSecurity( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __out PSECURITY_DESCRIPTOR *SecurityDescriptor + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor ) { NTSTATUS status; @@ -277,9 +277,9 @@ NTSTATUS PhGetObjectSecurity( } NTSTATUS PhSetObjectSecurity( - __in HANDLE Handle, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ HANDLE Handle, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ) { return NtSetSecurityObject( @@ -298,8 +298,8 @@ NTSTATUS PhSetObjectSecurity( * process is being terminated. */ NTSTATUS PhTerminateProcess( - __in HANDLE ProcessHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ProcessHandle, + _In_ NTSTATUS ExitStatus ) { NTSTATUS status; @@ -328,7 +328,7 @@ NTSTATUS PhTerminateProcess( * have PROCESS_SUSPEND_RESUME access. */ NTSTATUS PhSuspendProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ) { if (KphIsConnected() && WINDOWS_HAS_PSSUSPENDRESUMEPROCESS) @@ -348,7 +348,7 @@ NTSTATUS PhSuspendProcess( * have PROCESS_SUSPEND_RESUME access. */ NTSTATUS PhResumeProcess( - __in HANDLE ProcessHandle + _In_ HANDLE ProcessHandle ) { if (KphIsConnected() && WINDOWS_HAS_PSSUSPENDRESUMEPROCESS) @@ -370,8 +370,8 @@ NTSTATUS PhResumeProcess( * thread is being terminated. */ NTSTATUS PhTerminateThread( - __in HANDLE ThreadHandle, - __in NTSTATUS ExitStatus + _In_ HANDLE ThreadHandle, + _In_ NTSTATUS ExitStatus ) { #ifndef _M_X64 @@ -404,8 +404,8 @@ NTSTATUS PhTerminateThread( * number of times the thread had been suspended. */ NTSTATUS PhSuspendThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ) { return NtSuspendThread(ThreadHandle, PreviousSuspendCount); @@ -420,8 +420,8 @@ NTSTATUS PhSuspendThread( * number of times the thread had been suspended. */ NTSTATUS PhResumeThread( - __in HANDLE ThreadHandle, - __out_opt PULONG PreviousSuspendCount + _In_ HANDLE ThreadHandle, + _Out_opt_ PULONG PreviousSuspendCount ) { return NtResumeThread(ThreadHandle, PreviousSuspendCount); @@ -436,8 +436,8 @@ NTSTATUS PhResumeThread( * structure. */ NTSTATUS PhGetThreadContext( - __in HANDLE ThreadHandle, - __inout PCONTEXT Context + _In_ HANDLE ThreadHandle, + _Inout_ PCONTEXT Context ) { if (KphIsConnected()) @@ -458,8 +458,8 @@ NTSTATUS PhGetThreadContext( * \param Context The new context structure. */ NTSTATUS PhSetThreadContext( - __in HANDLE ThreadHandle, - __in PCONTEXT Context + _In_ HANDLE ThreadHandle, + _In_ PCONTEXT Context ) { if (KphIsConnected()) @@ -484,11 +484,11 @@ NTSTATUS PhSetThreadContext( * of bytes copied to the buffer. */ NTSTATUS PhReadVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesRead + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_writes_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesRead ) { NTSTATUS status; @@ -531,11 +531,11 @@ NTSTATUS PhReadVirtualMemory( * of bytes copied from the buffer. */ NTSTATUS PhWriteVirtualMemory( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in_bcount(BufferSize) PVOID Buffer, - __in SIZE_T BufferSize, - __out_opt PSIZE_T NumberOfBytesWritten + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_reads_bytes_(BufferSize) PVOID Buffer, + _In_ SIZE_T BufferSize, + _Out_opt_ PSIZE_T NumberOfBytesWritten ) { NTSTATUS status; @@ -574,9 +574,9 @@ NTSTATUS PhWriteVirtualMemory( * PhFree() when you no longer need it. */ NTSTATUS PhpQueryProcessVariableSize( - __in HANDLE ProcessHandle, - __in PROCESSINFOCLASS ProcessInformationClass, - __out PVOID *Buffer + _In_ HANDLE ProcessHandle, + _In_ PROCESSINFOCLASS ProcessInformationClass, + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -621,8 +621,8 @@ NTSTATUS PhpQueryProcessVariableSize( * using PhDereferenceObject() when you no longer need it. */ NTSTATUS PhGetProcessImageFileName( - __in HANDLE ProcessHandle, - __out PPH_STRING *FileName + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *FileName ) { NTSTATUS status; @@ -656,8 +656,8 @@ NTSTATUS PhGetProcessImageFileName( * and above. */ NTSTATUS PhGetProcessImageFileNameWin32( - __in HANDLE ProcessHandle, - __out PPH_STRING *FileName + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *FileName ) { NTSTATUS status; @@ -693,9 +693,9 @@ NTSTATUS PhGetProcessImageFileNameWin32( * specified in the Offset parameter. */ NTSTATUS PhGetProcessPebString( - __in HANDLE ProcessHandle, - __in PH_PEB_OFFSET Offset, - __out PPH_STRING *String + _In_ HANDLE ProcessHandle, + _In_ PH_PEB_OFFSET Offset, + _Out_ PPH_STRING *String ) { NTSTATUS status; @@ -813,12 +813,51 @@ NTSTATUS PhGetProcessPebString( return status; } +/** + * Gets a process' command line. + * + * \param ProcessHandle A handle to a process. The handle must + * have PROCESS_QUERY_LIMITED_INFORMATION. Before Windows 8.1, + * the handle must also have PROCESS_VM_READ access. + * \param String A variable which receives a pointer to a + * string containing the command line. You must free the string + * using PhDereferenceObject() when you no longer need it. + */ +NTSTATUS PhGetProcessCommandLine( + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *CommandLine + ) +{ + NTSTATUS status; + + if (WindowsVersion >= WINDOWS_81) + { + PUNICODE_STRING commandLine; + + status = PhpQueryProcessVariableSize( + ProcessHandle, + ProcessCommandLineInformation, + &commandLine + ); + + if (NT_SUCCESS(status)) + { + *CommandLine = PhCreateStringEx(commandLine->Buffer, commandLine->Length); + PhFree(commandLine); + + return status; + } + } + + return PhGetProcessPebString(ProcessHandle, PhpoCommandLine, CommandLine); +} + /** * Gets the window flags and window title of a process. * - * \param ProcessHandle A handle to a process. The handle - * must have PROCESS_QUERY_LIMITED_INFORMATION. Before - * Windows 7 SP1, the handle must also have PROCESS_VM_READ access. + * \param ProcessHandle A handle to a process. The handle must + * have PROCESS_QUERY_LIMITED_INFORMATION. Before Windows 7 SP1, + * the handle must also have PROCESS_VM_READ access. * \param WindowFlags A variable which receives the window * flags. * \param WindowTitle A variable which receives a pointer to the @@ -826,9 +865,9 @@ NTSTATUS PhGetProcessPebString( * PhDereferenceObject() when you no longer need it. */ NTSTATUS PhGetProcessWindowTitle( - __in HANDLE ProcessHandle, - __out PULONG WindowFlags, - __out PPH_STRING *WindowTitle + _In_ HANDLE ProcessHandle, + _Out_ PULONG WindowFlags, + _Out_ PPH_STRING *WindowTitle ) { NTSTATUS status; @@ -943,8 +982,8 @@ NTSTATUS PhGetProcessWindowTitle( * POSIX subsystem. */ NTSTATUS PhGetProcessIsPosix( - __in HANDLE ProcessHandle, - __out PBOOLEAN IsPosix + _In_ HANDLE ProcessHandle, + _Out_ PBOOLEAN IsPosix ) { NTSTATUS status; @@ -985,8 +1024,8 @@ NTSTATUS PhGetProcessIsPosix( * no-execute flags. */ NTSTATUS PhGetProcessExecuteFlags( - __in HANDLE ProcessHandle, - __out PULONG ExecuteFlags + _In_ HANDLE ProcessHandle, + _Out_ PULONG ExecuteFlags ) { if (KphIsConnected()) @@ -1012,8 +1051,8 @@ NTSTATUS PhGetProcessExecuteFlags( } NTSTATUS PhGetProcessDepStatus( - __in HANDLE ProcessHandle, - __out PULONG DepStatus + _In_ HANDLE ProcessHandle, + _Out_ PULONG DepStatus ) { NTSTATUS status; @@ -1061,8 +1100,8 @@ NTSTATUS PhGetProcessDepStatus( * whether a process is running under the POSIX subsystem. */ NTSTATUS PhGetProcessPosixCommandLine( - __in HANDLE ProcessHandle, - __out PPH_STRING *CommandLine + _In_ HANDLE ProcessHandle, + _Out_ PPH_STRING *CommandLine ) { NTSTATUS status; @@ -1195,10 +1234,10 @@ NTSTATUS PhGetProcessPosixCommandLine( * the length of the environment block, in bytes. */ NTSTATUS PhGetProcessEnvironment( - __in HANDLE ProcessHandle, - __in ULONG Flags, - __out PVOID *Environment, - __out PULONG EnvironmentLength + _In_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _Out_ PVOID *Environment, + _Out_ PULONG EnvironmentLength ) { NTSTATUS status; @@ -1308,10 +1347,10 @@ NTSTATUS PhGetProcessEnvironment( } BOOLEAN PhEnumProcessEnvironmentVariables( - __in PVOID Environment, - __in ULONG EnvironmentLength, - __inout PULONG EnumerationKey, - __out PPH_ENVIRONMENT_VARIABLE Variable + _In_ PVOID Environment, + _In_ ULONG EnvironmentLength, + _Inout_ PULONG EnumerationKey, + _Out_ PPH_ENVIRONMENT_VARIABLE Variable ) { ULONG length; @@ -1388,9 +1427,9 @@ BOOLEAN PhEnumProcessEnvironmentVariables( * you no longer need it. */ NTSTATUS PhGetProcessMappedFileName( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __out PPH_STRING *FileName + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _Out_ PPH_STRING *FileName ) { NTSTATUS status; @@ -1453,8 +1492,8 @@ NTSTATUS PhGetProcessMappedFileName( * PhFree() when you no longer need it. */ NTSTATUS PhGetProcessWorkingSetInformation( - __in HANDLE ProcessHandle, - __out PMEMORY_WORKING_SET_INFORMATION *WorkingSetInformation + _In_ HANDLE ProcessHandle, + _Out_ PMEMORY_WORKING_SET_INFORMATION *WorkingSetInformation ) { NTSTATUS status; @@ -1504,8 +1543,8 @@ NTSTATUS PhGetProcessWorkingSetInformation( * counters. */ NTSTATUS PhGetProcessWsCounters( - __in HANDLE ProcessHandle, - __out PPH_PROCESS_WS_COUNTERS WsCounters + _In_ HANDLE ProcessHandle, + _Out_ PPH_PROCESS_WS_COUNTERS WsCounters ) { NTSTATUS status; @@ -1553,8 +1592,8 @@ NTSTATUS PhGetProcessWsCounters( * handle. */ NTSTATUS PhEnumProcessHandles( - __in HANDLE ProcessHandle, - __out PKPH_PROCESS_HANDLE_INFORMATION *Handles + _In_ HANDLE ProcessHandle, + _Out_ PKPH_PROCESS_HANDLE_INFORMATION *Handles ) { NTSTATUS status; @@ -1602,8 +1641,8 @@ NTSTATUS PhEnumProcessHandles( * \param AffinityMask The new affinity mask. */ NTSTATUS PhSetProcessAffinityMask( - __in HANDLE ProcessHandle, - __in ULONG_PTR AffinityMask + _In_ HANDLE ProcessHandle, + _In_ ULONG_PTR AffinityMask ) { return NtSetInformationProcess( @@ -1622,8 +1661,8 @@ NTSTATUS PhSetProcessAffinityMask( * \param IoPriority The new I/O priority. */ NTSTATUS PhSetProcessIoPriority( - __in HANDLE ProcessHandle, - __in ULONG IoPriority + _In_ HANDLE ProcessHandle, + _In_ ULONG IoPriority ) { if (KphIsConnected()) @@ -1656,8 +1695,8 @@ NTSTATUS PhSetProcessIoPriority( * handle. */ NTSTATUS PhSetProcessExecuteFlags( - __in HANDLE ProcessHandle, - __in ULONG ExecuteFlags + _In_ HANDLE ProcessHandle, + _In_ ULONG ExecuteFlags ) { return KphSetInformationProcess( @@ -1669,8 +1708,8 @@ NTSTATUS PhSetProcessExecuteFlags( } NTSTATUS PhSetProcessDepStatus( - __in HANDLE ProcessHandle, - __in ULONG DepStatus + _In_ HANDLE ProcessHandle, + _In_ ULONG DepStatus ) { ULONG executeFlags; @@ -1689,9 +1728,9 @@ NTSTATUS PhSetProcessDepStatus( } NTSTATUS PhSetProcessDepStatusInvasive( - __in HANDLE ProcessHandle, - __in ULONG DepStatus, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE ProcessHandle, + _In_ ULONG DepStatus, + _In_opt_ PLARGE_INTEGER Timeout ) { NTSTATUS status; @@ -1771,9 +1810,9 @@ NTSTATUS PhSetProcessDepStatusInvasive( * value carefully. */ NTSTATUS PhInjectDllProcess( - __in HANDLE ProcessHandle, - __in PWSTR FileName, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE ProcessHandle, + _In_ PWSTR FileName, + _In_opt_ PLARGE_INTEGER Timeout ) { #ifdef _M_X64 @@ -1921,9 +1960,9 @@ NTSTATUS PhInjectDllProcess( * process to unload the DLL. */ NTSTATUS PhUnloadDllProcess( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in_opt PLARGE_INTEGER Timeout + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_opt_ PLARGE_INTEGER Timeout ) { #ifdef _M_X64 @@ -2063,8 +2102,8 @@ NTSTATUS PhUnloadDllProcess( * \param AffinityMask The new affinity mask. */ NTSTATUS PhSetThreadAffinityMask( - __in HANDLE ThreadHandle, - __in ULONG_PTR AffinityMask + _In_ HANDLE ThreadHandle, + _In_ ULONG_PTR AffinityMask ) { return NtSetInformationThread( @@ -2083,8 +2122,8 @@ NTSTATUS PhSetThreadAffinityMask( * \param IoPriority The new I/O priority. */ NTSTATUS PhSetThreadIoPriority( - __in HANDLE ThreadHandle, - __in ULONG IoPriority + _In_ HANDLE ThreadHandle, + _In_ ULONG IoPriority ) { if (KphIsConnected()) @@ -2117,8 +2156,8 @@ NTSTATUS PhSetThreadIoPriority( * PH_THREAD_STACK_FRAME structure. */ VOID PhpConvertStackFrame( - __in STACKFRAME64 *StackFrame64, - __out PPH_THREAD_STACK_FRAME ThreadStackFrame + _In_ STACKFRAME64 *StackFrame64, + _Out_ PPH_THREAD_STACK_FRAME ThreadStackFrame ) { ULONG i; @@ -2160,12 +2199,12 @@ VOID PhpConvertStackFrame( * callback function. */ NTSTATUS PhWalkThreadStack( - __in HANDLE ThreadHandle, - __in_opt HANDLE ProcessHandle, - __in_opt PCLIENT_ID ClientId, - __in ULONG Flags, - __in PPH_WALK_THREAD_STACK_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ThreadHandle, + _In_opt_ HANDLE ProcessHandle, + _In_opt_ PCLIENT_ID ClientId, + _In_ ULONG Flags, + _In_ PPH_WALK_THREAD_STACK_CALLBACK Callback, + _In_opt_ PVOID Context ) { NTSTATUS status = STATUS_SUCCESS; @@ -2405,8 +2444,8 @@ NTSTATUS PhWalkThreadStack( } NTSTATUS PhGetJobProcessIdList( - __in HANDLE JobHandle, - __out PJOBOBJECT_BASIC_PROCESS_ID_LIST *ProcessIdList + _In_ HANDLE JobHandle, + _Out_ PJOBOBJECT_BASIC_PROCESS_ID_LIST *ProcessIdList ) { NTSTATUS status; @@ -2461,9 +2500,9 @@ NTSTATUS PhGetJobProcessIdList( * PhFree() when you no longer need it. */ NTSTATUS PhpQueryTokenVariableSize( - __in HANDLE TokenHandle, - __in TOKEN_INFORMATION_CLASS TokenInformationClass, - __out PVOID *Buffer + _In_ HANDLE TokenHandle, + _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -2510,9 +2549,9 @@ NTSTATUS PhpQueryTokenVariableSize( * PhFree() when you no longer need it. */ NTSTATUS PhQueryTokenVariableSize( - __in HANDLE TokenHandle, - __in TOKEN_INFORMATION_CLASS TokenInformationClass, - __out PVOID *Buffer + _In_ HANDLE TokenHandle, + _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, + _Out_ PVOID *Buffer ) { return PhpQueryTokenVariableSize( @@ -2533,8 +2572,8 @@ NTSTATUS PhQueryTokenVariableSize( * need it. */ NTSTATUS PhGetTokenUser( - __in HANDLE TokenHandle, - __out PTOKEN_USER *User + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_USER *User ) { return PhpQueryTokenVariableSize( @@ -2555,8 +2594,8 @@ NTSTATUS PhGetTokenUser( * need it. */ NTSTATUS PhGetTokenOwner( - __in HANDLE TokenHandle, - __out PTOKEN_OWNER *Owner + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_OWNER *Owner ) { return PhpQueryTokenVariableSize( @@ -2577,8 +2616,8 @@ NTSTATUS PhGetTokenOwner( * need it. */ NTSTATUS PhGetTokenPrimaryGroup( - __in HANDLE TokenHandle, - __out PTOKEN_PRIMARY_GROUP *PrimaryGroup + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_PRIMARY_GROUP *PrimaryGroup ) { return PhpQueryTokenVariableSize( @@ -2599,8 +2638,8 @@ NTSTATUS PhGetTokenPrimaryGroup( * need it. */ NTSTATUS PhGetTokenGroups( - __in HANDLE TokenHandle, - __out PTOKEN_GROUPS *Groups + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_GROUPS *Groups ) { return PhpQueryTokenVariableSize( @@ -2621,8 +2660,8 @@ NTSTATUS PhGetTokenGroups( * need it. */ NTSTATUS PhGetTokenPrivileges( - __in HANDLE TokenHandle, - __out PTOKEN_PRIVILEGES *Privileges + _In_ HANDLE TokenHandle, + _Out_ PTOKEN_PRIVILEGES *Privileges ) { return PhpQueryTokenVariableSize( @@ -2633,8 +2672,8 @@ NTSTATUS PhGetTokenPrivileges( } NTSTATUS PhSetTokenSessionId( - __in HANDLE TokenHandle, - __in ULONG SessionId + _In_ HANDLE TokenHandle, + _In_ ULONG SessionId ) { return NtSetInformationToken( @@ -2659,10 +2698,10 @@ NTSTATUS PhSetTokenSessionId( * \param Attributes The new attributes of the privilege. */ BOOLEAN PhSetTokenPrivilege( - __in HANDLE TokenHandle, - __in_opt PWSTR PrivilegeName, - __in_opt PLUID PrivilegeLuid, - __in ULONG Attributes + _In_ HANDLE TokenHandle, + _In_opt_ PWSTR PrivilegeName, + _In_opt_ PLUID PrivilegeLuid, + _In_ ULONG Attributes ) { NTSTATUS status; @@ -2709,9 +2748,9 @@ BOOLEAN PhSetTokenPrivilege( } BOOLEAN PhSetTokenPrivilege2( - __in HANDLE TokenHandle, - __in LONG Privilege, - __in ULONG Attributes + _In_ HANDLE TokenHandle, + _In_ LONG Privilege, + _In_ ULONG Attributes ) { LUID privilegeLuid; @@ -2730,8 +2769,8 @@ BOOLEAN PhSetTokenPrivilege2( * whether virtualization is to be enabled for the token. */ NTSTATUS PhSetTokenIsVirtualizationEnabled( - __in HANDLE TokenHandle, - __in BOOLEAN IsVirtualizationEnabled + _In_ HANDLE TokenHandle, + _In_ BOOLEAN IsVirtualizationEnabled ) { ULONG virtualizationEnabled; @@ -2758,9 +2797,9 @@ NTSTATUS PhSetTokenIsVirtualizationEnabled( * of the integrity level. */ NTSTATUS PhGetTokenIntegrityLevel( - __in HANDLE TokenHandle, - __out_opt PMANDATORY_LEVEL IntegrityLevel, - __out_opt PWSTR *IntegrityString + _In_ HANDLE TokenHandle, + _Out_opt_ PMANDATORY_LEVEL IntegrityLevel, + _Out_opt_ PWSTR *IntegrityString ) { NTSTATUS status; @@ -2816,9 +2855,9 @@ NTSTATUS PhGetTokenIntegrityLevel( } NTSTATUS PhpQueryFileVariableSize( - __in HANDLE FileHandle, - __in FILE_INFORMATION_CLASS FileInformationClass, - __out PVOID *Buffer + _In_ HANDLE FileHandle, + _In_ FILE_INFORMATION_CLASS FileInformationClass, + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -2867,8 +2906,8 @@ NTSTATUS PhpQueryFileVariableSize( } NTSTATUS PhGetFileSize( - __in HANDLE FileHandle, - __out PLARGE_INTEGER Size + _In_ HANDLE FileHandle, + _Out_ PLARGE_INTEGER Size ) { NTSTATUS status; @@ -2892,8 +2931,8 @@ NTSTATUS PhGetFileSize( } NTSTATUS PhSetFileSize( - __in HANDLE FileHandle, - __in PLARGE_INTEGER Size + _In_ HANDLE FileHandle, + _In_ PLARGE_INTEGER Size ) { FILE_END_OF_FILE_INFORMATION endOfFileInfo; @@ -2911,9 +2950,9 @@ NTSTATUS PhSetFileSize( } NTSTATUS PhpQueryTransactionManagerVariableSize( - __in HANDLE TransactionManagerHandle, - __in TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - __out PVOID *Buffer + _In_ HANDLE TransactionManagerHandle, + _In_ TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -2964,8 +3003,8 @@ NTSTATUS PhpQueryTransactionManagerVariableSize( } NTSTATUS PhGetTransactionManagerBasicInformation( - __in HANDLE TransactionManagerHandle, - __out PTRANSACTIONMANAGER_BASIC_INFORMATION BasicInformation + _In_ HANDLE TransactionManagerHandle, + _Out_ PTRANSACTIONMANAGER_BASIC_INFORMATION BasicInformation ) { if (NtQueryInformationTransactionManager) @@ -2985,8 +3024,8 @@ NTSTATUS PhGetTransactionManagerBasicInformation( } NTSTATUS PhGetTransactionManagerLogFileName( - __in HANDLE TransactionManagerHandle, - __out PPH_STRING *LogFileName + _In_ HANDLE TransactionManagerHandle, + _Out_ PPH_STRING *LogFileName ) { NTSTATUS status; @@ -3011,9 +3050,9 @@ NTSTATUS PhGetTransactionManagerLogFileName( } NTSTATUS PhpQueryTransactionVariableSize( - __in HANDLE TransactionHandle, - __in TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - __out PVOID *Buffer + _In_ HANDLE TransactionHandle, + _In_ TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -3064,8 +3103,8 @@ NTSTATUS PhpQueryTransactionVariableSize( } NTSTATUS PhGetTransactionBasicInformation( - __in HANDLE TransactionHandle, - __out PTRANSACTION_BASIC_INFORMATION BasicInformation + _In_ HANDLE TransactionHandle, + _Out_ PTRANSACTION_BASIC_INFORMATION BasicInformation ) { if (NtQueryInformationTransaction) @@ -3085,10 +3124,10 @@ NTSTATUS PhGetTransactionBasicInformation( } NTSTATUS PhGetTransactionPropertiesInformation( - __in HANDLE TransactionHandle, - __out_opt PLARGE_INTEGER Timeout, - __out_opt TRANSACTION_OUTCOME *Outcome, - __out_opt PPH_STRING *Description + _In_ HANDLE TransactionHandle, + _Out_opt_ PLARGE_INTEGER Timeout, + _Out_opt_ TRANSACTION_OUTCOME *Outcome, + _Out_opt_ PPH_STRING *Description ) { NTSTATUS status; @@ -3127,9 +3166,9 @@ NTSTATUS PhGetTransactionPropertiesInformation( } NTSTATUS PhpQueryResourceManagerVariableSize( - __in HANDLE ResourceManagerHandle, - __in RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - __out PVOID *Buffer + _In_ HANDLE ResourceManagerHandle, + _In_ RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -3180,9 +3219,9 @@ NTSTATUS PhpQueryResourceManagerVariableSize( } NTSTATUS PhGetResourceManagerBasicInformation( - __in HANDLE ResourceManagerHandle, - __out_opt PGUID Guid, - __out_opt PPH_STRING *Description + _In_ HANDLE ResourceManagerHandle, + _Out_opt_ PGUID Guid, + _Out_opt_ PPH_STRING *Description ) { NTSTATUS status; @@ -3216,8 +3255,8 @@ NTSTATUS PhGetResourceManagerBasicInformation( } NTSTATUS PhGetEnlistmentBasicInformation( - __in HANDLE EnlistmentHandle, - __out PENLISTMENT_BASIC_INFORMATION BasicInformation + _In_ HANDLE EnlistmentHandle, + _Out_ PENLISTMENT_BASIC_INFORMATION BasicInformation ) { if (NtQueryInformationEnlistment) @@ -3244,9 +3283,9 @@ typedef struct _OPEN_DRIVER_BY_BASE_ADDRESS_CONTEXT } OPEN_DRIVER_BY_BASE_ADDRESS_CONTEXT, *POPEN_DRIVER_BY_BASE_ADDRESS_CONTEXT; BOOLEAN NTAPI PhpOpenDriverByBaseAddressCallback( - __in PPH_STRING Name, - __in PPH_STRING TypeName, - __in_opt PVOID Context + _In_ PPH_STRING Name, + _In_ PPH_STRING TypeName, + _In_opt_ PVOID Context ) { static PH_STRINGREF driverDirectoryName = PH_STRINGREF_INIT(L"\\Driver\\"); @@ -3320,8 +3359,8 @@ BOOLEAN NTAPI PhpOpenDriverByBaseAddressCallback( * handle. */ NTSTATUS PhOpenDriverByBaseAddress( - __out PHANDLE DriverHandle, - __in PVOID BaseAddress + _Out_ PHANDLE DriverHandle, + _In_ PVOID BaseAddress ) { NTSTATUS status; @@ -3385,9 +3424,9 @@ NTSTATUS PhOpenDriverByBaseAddress( * handle. */ NTSTATUS PhpQueryDriverVariableSize( - __in HANDLE DriverHandle, - __in DRIVER_INFORMATION_CLASS DriverInformationClass, - __out PVOID *Buffer + _In_ HANDLE DriverHandle, + _In_ DRIVER_INFORMATION_CLASS DriverInformationClass, + _Out_ PVOID *Buffer ) { NTSTATUS status; @@ -3435,8 +3474,8 @@ NTSTATUS PhpQueryDriverVariableSize( * handle. */ NTSTATUS PhGetDriverServiceKeyName( - __in HANDLE DriverHandle, - __out PPH_STRING *ServiceKeyName + _In_ HANDLE DriverHandle, + _Out_ PPH_STRING *ServiceKeyName ) { NTSTATUS status; @@ -3459,7 +3498,7 @@ NTSTATUS PhGetDriverServiceKeyName( } NTSTATUS PhpUnloadDriver( - __in PPH_STRING ServiceKeyName + _In_ PPH_STRING ServiceKeyName ) { static PH_STRINGREF fullServicesKeyName = PH_STRINGREF_INIT(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"); @@ -3542,8 +3581,8 @@ NTSTATUS PhpUnloadDriver( * could not be found. */ NTSTATUS PhUnloadDriver( - __in_opt PVOID BaseAddress, - __in_opt PWSTR Name + _In_opt_ PVOID BaseAddress, + _In_opt_ PWSTR Name ) { NTSTATUS status; @@ -3624,13 +3663,13 @@ NTSTATUS PhUnloadDriver( * the handle. */ NTSTATUS PhDuplicateObject( - __in HANDLE SourceProcessHandle, - __in HANDLE SourceHandle, - __in_opt HANDLE TargetProcessHandle, - __out_opt PHANDLE TargetHandle, - __in ACCESS_MASK DesiredAccess, - __in ULONG HandleAttributes, - __in ULONG Options + _In_ HANDLE SourceProcessHandle, + _In_ HANDLE SourceHandle, + _In_opt_ HANDLE TargetProcessHandle, + _Out_opt_ PHANDLE TargetHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ ULONG HandleAttributes, + _In_ ULONG Options ) { NTSTATUS status; @@ -3665,10 +3704,10 @@ NTSTATUS PhDuplicateObject( } NTSTATUS PhpEnumProcessModules( - __in HANDLE ProcessHandle, - __in PPHP_ENUM_PROCESS_MODULES_CALLBACK Callback, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PPHP_ENUM_PROCESS_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ) { NTSTATUS status; @@ -3766,11 +3805,11 @@ NTSTATUS PhpEnumProcessModules( } BOOLEAN NTAPI PhpEnumProcessModulesCallback( - __in HANDLE ProcessHandle, - __in PLDR_DATA_TABLE_ENTRY Entry, - __in PVOID AddressOfEntry, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PLDR_DATA_TABLE_ENTRY Entry, + _In_ PVOID AddressOfEntry, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ) { NTSTATUS status; @@ -3844,7 +3883,7 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback( { baseDllNameBuffer = NULL; - Entry->BaseDllName.Buffer = (PWSTR)((ULONG_PTR)Entry->FullDllName.Buffer + + Entry->BaseDllName.Buffer = (PWCHAR)((ULONG_PTR)Entry->FullDllName.Buffer + ((ULONG_PTR)baseDllNameOriginal - (ULONG_PTR)fullDllNameOriginal)); } else @@ -3902,9 +3941,9 @@ BOOLEAN NTAPI PhpEnumProcessModulesCallback( * callback function. */ NTSTATUS PhEnumProcessModules( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context ) { PH_ENUM_PROCESS_MODULES_PARAMETERS parameters; @@ -3927,8 +3966,8 @@ NTSTATUS PhEnumProcessModules( * \param Parameters The enumeration parameters. */ NTSTATUS PhEnumProcessModulesEx( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters ) { return PhpEnumProcessModules( @@ -3947,11 +3986,11 @@ typedef struct _SET_PROCESS_MODULE_LOAD_COUNT_CONTEXT } SET_PROCESS_MODULE_LOAD_COUNT_CONTEXT, *PSET_PROCESS_MODULE_LOAD_COUNT_CONTEXT; BOOLEAN NTAPI PhpSetProcessModuleLoadCountCallback( - __in HANDLE ProcessHandle, - __in PLDR_DATA_TABLE_ENTRY Entry, - __in PVOID AddressOfEntry, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PLDR_DATA_TABLE_ENTRY Entry, + _In_ PVOID AddressOfEntry, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ) { PSET_PROCESS_MODULE_LOAD_COUNT_CONTEXT context = Context1; @@ -3984,9 +4023,9 @@ BOOLEAN NTAPI PhpSetProcessModuleLoadCountCallback( * \retval STATUS_DLL_NOT_FOUND The module was not found. */ NTSTATUS PhSetProcessModuleLoadCount( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in ULONG LoadCount + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ ULONG LoadCount ) { NTSTATUS status; @@ -4010,10 +4049,10 @@ NTSTATUS PhSetProcessModuleLoadCount( } NTSTATUS PhpEnumProcessModules32( - __in HANDLE ProcessHandle, - __in PPHP_ENUM_PROCESS_MODULES32_CALLBACK Callback, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PPHP_ENUM_PROCESS_MODULES32_CALLBACK Callback, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ) { NTSTATUS status; @@ -4108,11 +4147,11 @@ NTSTATUS PhpEnumProcessModules32( } BOOLEAN NTAPI PhpEnumProcessModules32Callback( - __in HANDLE ProcessHandle, - __in PLDR_DATA_TABLE_ENTRY32 Entry, - __in ULONG AddressOfEntry, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PLDR_DATA_TABLE_ENTRY32 Entry, + _In_ ULONG AddressOfEntry, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ) { static PH_STRINGREF system32String = PH_STRINGREF_INIT(L"\\system32\\"); @@ -4215,7 +4254,7 @@ BOOLEAN NTAPI PhpEnumProcessModules32Callback( if (PhStartsWithStringRef(&fullDllName, &systemRootString, TRUE)) { - fullDllName.Buffer = (PWSTR)((PCHAR)fullDllName.Buffer + systemRootString.Length); + fullDllName.Buffer = (PWCHAR)((PCHAR)fullDllName.Buffer + systemRootString.Length); fullDllName.Length -= systemRootString.Length; if (PhStartsWithStringRef(&fullDllName, &system32String, TRUE)) @@ -4274,9 +4313,9 @@ BOOLEAN NTAPI PhpEnumProcessModules32Callback( * environment. */ NTSTATUS PhEnumProcessModules32( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context ) { PH_ENUM_PROCESS_MODULES_PARAMETERS parameters; @@ -4305,8 +4344,8 @@ NTSTATUS PhEnumProcessModules32( * environment. */ NTSTATUS PhEnumProcessModules32Ex( - __in HANDLE ProcessHandle, - __in PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters + _In_ HANDLE ProcessHandle, + _In_ PPH_ENUM_PROCESS_MODULES_PARAMETERS Parameters ) { return PhpEnumProcessModules32( @@ -4318,11 +4357,11 @@ NTSTATUS PhEnumProcessModules32Ex( } BOOLEAN NTAPI PhpSetProcessModuleLoadCount32Callback( - __in HANDLE ProcessHandle, - __in PLDR_DATA_TABLE_ENTRY32 Entry, - __in ULONG AddressOfEntry, - __in_opt PVOID Context1, - __in_opt PVOID Context2 + _In_ HANDLE ProcessHandle, + _In_ PLDR_DATA_TABLE_ENTRY32 Entry, + _In_ ULONG AddressOfEntry, + _In_opt_ PVOID Context1, + _In_opt_ PVOID Context2 ) { PSET_PROCESS_MODULE_LOAD_COUNT_CONTEXT context = Context1; @@ -4360,9 +4399,9 @@ BOOLEAN NTAPI PhpSetProcessModuleLoadCount32Callback( * environment. */ NTSTATUS PhSetProcessModuleLoadCount32( - __in HANDLE ProcessHandle, - __in PVOID BaseAddress, - __in ULONG LoadCount + _In_ HANDLE ProcessHandle, + _In_ PVOID BaseAddress, + _In_ ULONG LoadCount ) { NTSTATUS status; @@ -4392,8 +4431,8 @@ typedef struct _GET_PROCEDURE_ADDRESS_REMOTE_CONTEXT } GET_PROCEDURE_ADDRESS_REMOTE_CONTEXT, *PGET_PROCEDURE_ADDRESS_REMOTE_CONTEXT; static BOOLEAN PhpGetProcedureAddressRemoteCallback( - __in PLDR_DATA_TABLE_ENTRY Module, - __in_opt PVOID Context + _In_ PLDR_DATA_TABLE_ENTRY Module, + _In_opt_ PVOID Context ) { PGET_PROCEDURE_ADDRESS_REMOTE_CONTEXT context = Context; @@ -4427,12 +4466,12 @@ static BOOLEAN PhpGetProcedureAddressRemoteCallback( * address of the DLL containing the procedure. */ NTSTATUS PhGetProcedureAddressRemote( - __in HANDLE ProcessHandle, - __in PWSTR FileName, - __in_opt PSTR ProcedureName, - __in_opt ULONG ProcedureNumber, - __out PVOID *ProcedureAddress, - __out_opt PVOID *DllBase + _In_ HANDLE ProcessHandle, + _In_ PWSTR FileName, + _In_opt_ PSTR ProcedureName, + _In_opt_ ULONG ProcedureNumber, + _Out_ PVOID *ProcedureAddress, + _Out_opt_ PVOID *DllBase ) { NTSTATUS status; @@ -4498,7 +4537,7 @@ NTSTATUS PhGetProcedureAddressRemote( * using PhFree() when you no longer need it. */ NTSTATUS PhEnumKernelModules( - __out PRTL_PROCESS_MODULES *Modules + _Out_ PRTL_PROCESS_MODULES *Modules ) { NTSTATUS status; @@ -4544,7 +4583,7 @@ NTSTATUS PhEnumKernelModules( * using PhFree() when you no longer need it. */ NTSTATUS PhEnumKernelModulesEx( - __out PRTL_PROCESS_MODULE_INFORMATION_EX *Modules + _Out_ PRTL_PROCESS_MODULE_INFORMATION_EX *Modules ) { NTSTATUS status; @@ -4622,21 +4661,57 @@ PPH_STRING PhGetKernelFileName( * information contained in the buffer. */ NTSTATUS PhEnumProcesses( - __out PVOID *Processes + _Out_ PVOID *Processes ) { - static ULONG initialBufferSize = 0x4000; + return PhEnumProcessesEx(Processes, SystemProcessInformation); +} + +/** + * Enumerates the running processes. + * + * \param Processes A variable which receives a + * pointer to a buffer containing process + * information. You must free the buffer using + * PhFree() when you no longer need it. + * + * \remarks You can use the \ref PH_FIRST_PROCESS + * and \ref PH_NEXT_PROCESS macros to process the + * information contained in the buffer. + */ +NTSTATUS PhEnumProcessesEx( + _Out_ PVOID *Processes, + _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass + ) +{ + static ULONG initialBufferSize[3] = { 0x4000, 0x4000, 0x4000 }; NTSTATUS status; + ULONG classIndex; PVOID buffer; ULONG bufferSize; - bufferSize = initialBufferSize; + switch (SystemInformationClass) + { + case SystemProcessInformation: + classIndex = 0; + break; + case SystemExtendedProcessInformation: + classIndex = 1; + break; + case SystemFullProcessInformation: + classIndex = 2; + break; + default: + return STATUS_INVALID_INFO_CLASS; + } + + bufferSize = initialBufferSize[classIndex]; buffer = PhAllocate(bufferSize); while (TRUE) { status = NtQuerySystemInformation( - SystemProcessInformation, + SystemInformationClass, buffer, bufferSize, &bufferSize @@ -4659,7 +4734,7 @@ NTSTATUS PhEnumProcesses( return status; } - if (bufferSize <= 0x20000) initialBufferSize = bufferSize; + if (bufferSize <= 0x40000) initialBufferSize[classIndex] = bufferSize; *Processes = buffer; return status; @@ -4679,8 +4754,8 @@ NTSTATUS PhEnumProcesses( * information contained in the buffer. */ NTSTATUS PhEnumProcessesForSession( - __out PVOID *Processes, - __in ULONG SessionId + _Out_ PVOID *Processes, + _In_ ULONG SessionId ) { static ULONG initialBufferSize = 0x4000; @@ -4729,62 +4804,6 @@ NTSTATUS PhEnumProcessesForSession( return status; } -/** - * Enumerates the running processes. - * - * \param Processes A variable which receives a - * pointer to a buffer containing process - * information. You must free the buffer using - * PhFree() when you no longer need it. - * - * \remarks You can use the \ref PH_FIRST_PROCESS - * and \ref PH_NEXT_PROCESS macros to process the - * information contained in the buffer. - */ -NTSTATUS PhEnumProcessesEx( - __out PVOID *Processes - ) -{ - static ULONG initialBufferSize = 0x4000; - NTSTATUS status; - PVOID buffer; - ULONG bufferSize; - - bufferSize = initialBufferSize; - buffer = PhAllocate(bufferSize); - - while (TRUE) - { - status = NtQuerySystemInformation( - SystemExtendedProcessInformation, - buffer, - bufferSize, - &bufferSize - ); - - if (status == STATUS_BUFFER_TOO_SMALL || status == STATUS_INFO_LENGTH_MISMATCH) - { - PhFree(buffer); - buffer = PhAllocate(bufferSize); - } - else - { - break; - } - } - - if (!NT_SUCCESS(status)) - { - PhFree(buffer); - return status; - } - - if (bufferSize <= 0x20000) initialBufferSize = bufferSize; - *Processes = buffer; - - return status; -} - /** * Finds the process information structure for a * specific process. @@ -4798,8 +4817,8 @@ NTSTATUS PhEnumProcessesEx( * the structure could not be found. */ PSYSTEM_PROCESS_INFORMATION PhFindProcessInformation( - __in PVOID Processes, - __in HANDLE ProcessId + _In_ PVOID Processes, + _In_ HANDLE ProcessId ) { PSYSTEM_PROCESS_INFORMATION process; @@ -4828,8 +4847,8 @@ PSYSTEM_PROCESS_INFORMATION PhFindProcessInformation( * the structure could not be found. */ PSYSTEM_PROCESS_INFORMATION PhFindProcessInformationByImageName( - __in PVOID Processes, - __in PPH_STRINGREF ImageName + _In_ PVOID Processes, + _In_ PPH_STRINGREF ImageName ) { PSYSTEM_PROCESS_INFORMATION process; @@ -4861,7 +4880,7 @@ PSYSTEM_PROCESS_INFORMATION PhFindProcessInformationByImageName( * large. */ NTSTATUS PhEnumHandles( - __out PSYSTEM_HANDLE_INFORMATION *Handles + _Out_ PSYSTEM_HANDLE_INFORMATION *Handles ) { static ULONG initialBufferSize = 0x4000; @@ -4918,7 +4937,7 @@ NTSTATUS PhEnumHandles( * with Windows XP. */ NTSTATUS PhEnumHandlesEx( - __out PSYSTEM_HANDLE_INFORMATION_EX *Handles + _Out_ PSYSTEM_HANDLE_INFORMATION_EX *Handles ) { static ULONG initialBufferSize = 0x10000; @@ -4972,7 +4991,7 @@ NTSTATUS PhEnumHandlesEx( * large. */ NTSTATUS PhEnumPagefiles( - __out PVOID *Pagefiles + _Out_ PVOID *Pagefiles ) { NTSTATUS status; @@ -5023,8 +5042,8 @@ NTSTATUS PhEnumPagefiles( * performed by the kernel for this. */ NTSTATUS PhGetProcessImageFileNameByProcessId( - __in HANDLE ProcessId, - __out PPH_STRING *FileName + _In_ HANDLE ProcessId, + _Out_ PPH_STRING *FileName ) { NTSTATUS status; @@ -5082,16 +5101,16 @@ NTSTATUS PhGetProcessImageFileNameByProcessId( * whether the process is managed. */ NTSTATUS PhGetProcessIsDotNet( - __in HANDLE ProcessId, - __out PBOOLEAN IsDotNet + _In_ HANDLE ProcessId, + _Out_ PBOOLEAN IsDotNet ) { return PhGetProcessIsDotNetEx(ProcessId, NULL, 0, IsDotNet, NULL); } BOOLEAN NTAPI PhpIsDotNetEnumProcessModulesCallback( - __in PLDR_DATA_TABLE_ENTRY Module, - __in_opt PVOID Context + _In_ PLDR_DATA_TABLE_ENTRY Module, + _In_opt_ PVOID Context ) { static UNICODE_STRING clrString = RTL_CONSTANT_STRING(L"clr.dll"); @@ -5132,12 +5151,12 @@ BOOLEAN NTAPI PhpIsDotNetEnumProcessModulesCallback( if (RtlPrefixUnicodeString(&systemRoot, &fileName, TRUE)) { - fileName.Buffer = (PWSTR)((PCHAR)fileName.Buffer + systemRoot.Length); + fileName.Buffer = (PWCHAR)((PCHAR)fileName.Buffer + systemRoot.Length); fileName.Length -= systemRoot.Length; if (RtlPrefixUnicodeString(frameworkPart, &fileName, TRUE)) { - fileName.Buffer = (PWSTR)((PCHAR)fileName.Buffer + frameworkPart->Length); + fileName.Buffer = (PWCHAR)((PCHAR)fileName.Buffer + frameworkPart->Length); fileName.Length -= frameworkPart->Length; if (fileName.Length >= 4 * sizeof(WCHAR)) // vx.x @@ -5192,11 +5211,11 @@ BOOLEAN NTAPI PhpIsDotNetEnumProcessModulesCallback( * \param Flags A variable which receives additional flags. */ NTSTATUS PhGetProcessIsDotNetEx( - __in HANDLE ProcessId, - __in_opt HANDLE ProcessHandle, - __in ULONG InFlags, - __out_opt PBOOLEAN IsDotNet, - __out_opt PULONG Flags + _In_ HANDLE ProcessId, + _In_opt_ HANDLE ProcessHandle, + _In_ ULONG InFlags, + _Out_opt_ PBOOLEAN IsDotNet, + _Out_opt_ PULONG Flags ) { NTSTATUS status = STATUS_SUCCESS; @@ -5352,9 +5371,9 @@ NTSTATUS PhGetProcessIsDotNetEx( * callback function. */ NTSTATUS PhEnumDirectoryObjects( - __in HANDLE DirectoryHandle, - __in PPH_ENUM_DIRECTORY_OBJECTS Callback, - __in_opt PVOID Context + _In_ HANDLE DirectoryHandle, + _In_ PPH_ENUM_DIRECTORY_OBJECTS Callback, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -5451,10 +5470,10 @@ NTSTATUS PhEnumDirectoryObjects( } NTSTATUS PhEnumDirectoryFile( - __in HANDLE FileHandle, - __in_opt PUNICODE_STRING SearchPattern, - __in PPH_ENUM_DIRECTORY_FILE Callback, - __in_opt PVOID Context + _In_ HANDLE FileHandle, + _In_opt_ PUNICODE_STRING SearchPattern, + _In_ PPH_ENUM_DIRECTORY_FILE Callback, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -5558,8 +5577,8 @@ NTSTATUS PhEnumDirectoryFile( } NTSTATUS PhEnumFileStreams( - __in HANDLE FileHandle, - __out PVOID *Streams + _In_ HANDLE FileHandle, + _Out_ PVOID *Streams ) { return PhpQueryFileVariableSize( @@ -5586,7 +5605,7 @@ VOID PhInitializeDevicePrefixes( { PhDevicePrefixes[i].Length = 0; PhDevicePrefixes[i].MaximumLength = PH_DEVICE_PREFIX_LENGTH * sizeof(WCHAR); - PhDevicePrefixes[i].Buffer = (PWSTR)buffer; + PhDevicePrefixes[i].Buffer = (PWCHAR)buffer; buffer += PH_DEVICE_PREFIX_LENGTH * sizeof(WCHAR); } } @@ -5755,7 +5774,7 @@ VOID PhUpdateDosDevicePrefixes( * when you no longer need it. */ PPH_STRING PhResolveDevicePrefix( - __in PPH_STRING Name + _In_ PPH_STRING Name ) { ULONG i; @@ -5874,7 +5893,7 @@ PPH_STRING PhResolveDevicePrefix( * PhResolveDevicePrefix(). */ PPH_STRING PhGetFileName( - __in PPH_STRING FileName + _In_ PPH_STRING FileName ) { PPH_STRING newFileName; @@ -5945,8 +5964,8 @@ typedef struct _ENUM_GENERIC_PROCESS_MODULES_CONTEXT } ENUM_GENERIC_PROCESS_MODULES_CONTEXT, *PENUM_GENERIC_PROCESS_MODULES_CONTEXT; static BOOLEAN EnumGenericProcessModulesCallback( - __in PLDR_DATA_TABLE_ENTRY Module, - __in_opt PVOID Context + _In_ PLDR_DATA_TABLE_ENTRY Module, + _In_opt_ PVOID Context ) { PENUM_GENERIC_PROCESS_MODULES_CONTEXT context; @@ -5989,10 +6008,10 @@ static BOOLEAN EnumGenericProcessModulesCallback( } VOID PhpRtlModulesToGenericModules( - __in PRTL_PROCESS_MODULES Modules, - __in PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, - __in_opt PVOID Context, - __in PPH_HASHTABLE BaseAddressHashtable + _In_ PRTL_PROCESS_MODULES Modules, + _In_ PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context, + _In_ PPH_HASHTABLE BaseAddressHashtable ) { PRTL_PROCESS_MODULE_INFORMATION module; @@ -6059,10 +6078,10 @@ VOID PhpRtlModulesToGenericModules( } VOID PhpRtlModulesExToGenericModules( - __in PRTL_PROCESS_MODULE_INFORMATION_EX Modules, - __in PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, - __in_opt PVOID Context, - __in PPH_HASHTABLE BaseAddressHashtable + _In_ PRTL_PROCESS_MODULE_INFORMATION_EX Modules, + _In_ PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context, + _In_ PPH_HASHTABLE BaseAddressHashtable ) { PRTL_PROCESS_MODULE_INFORMATION_EX module; @@ -6116,13 +6135,13 @@ VOID PhpRtlModulesExToGenericModules( } BOOLEAN PhpCallbackMappedFileOrImage( - __in PVOID AllocationBase, - __in SIZE_T AllocationSize, - __in ULONG Type, - __in PPH_STRING FileName, - __in PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, - __in_opt PVOID Context, - __in PPH_HASHTABLE BaseAddressHashtable + _In_ PVOID AllocationBase, + _In_ SIZE_T AllocationSize, + _In_ ULONG Type, + _In_ PPH_STRING FileName, + _In_ PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context, + _In_ PPH_HASHTABLE BaseAddressHashtable ) { PH_MODULE_INFO moduleInfo; @@ -6147,11 +6166,11 @@ BOOLEAN PhpCallbackMappedFileOrImage( } VOID PhpEnumGenericMappedFilesAndImages( - __in HANDLE ProcessHandle, - __in ULONG Flags, - __in PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, - __in_opt PVOID Context, - __in PPH_HASHTABLE BaseAddressHashtable + _In_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _In_ PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context, + _In_ PPH_HASHTABLE BaseAddressHashtable ) { BOOLEAN querySucceeded; @@ -6272,15 +6291,15 @@ VOID PhpEnumGenericMappedFilesAndImages( } BOOLEAN NTAPI PhpBaseAddressHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { return *(PVOID *)Entry1 == *(PVOID *)Entry2; } ULONG NTAPI PhpBaseAddressHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { #ifdef _M_IX86 @@ -6309,11 +6328,11 @@ ULONG NTAPI PhpBaseAddressHashtableHashFunction( * to the callback function. */ NTSTATUS PhEnumGenericModules( - __in HANDLE ProcessId, - __in_opt HANDLE ProcessHandle, - __in ULONG Flags, - __in PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, - __in_opt PVOID Context + _In_ HANDLE ProcessId, + _In_opt_ HANDLE ProcessHandle, + _In_ ULONG Flags, + _In_ PPH_ENUM_GENERIC_MODULES_CALLBACK Callback, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -6493,11 +6512,11 @@ VOID PhpInitializePredefineKeys( * be set to NULL if no handle needs to be closed. */ NTSTATUS PhpInitializeKeyObjectAttributes( - __in_opt HANDLE RootDirectory, - __in PUNICODE_STRING ObjectName, - __in ULONG Attributes, - __out POBJECT_ATTRIBUTES ObjectAttributes, - __out PHANDLE NeedsClose + _In_opt_ HANDLE RootDirectory, + _In_ PUNICODE_STRING ObjectName, + _In_ ULONG Attributes, + _Out_ POBJECT_ATTRIBUTES ObjectAttributes, + _Out_ PHANDLE NeedsClose ) { NTSTATUS status; @@ -6592,13 +6611,13 @@ NTSTATUS PhpInitializeKeyObjectAttributes( * \li \c REG_OPENED_EXISTING_KEY An existing key was opened. */ NTSTATUS PhCreateKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt HANDLE RootDirectory, - __in PPH_STRINGREF ObjectName, - __in ULONG Attributes, - __in ULONG CreateOptions, - __out_opt PULONG Disposition + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ HANDLE RootDirectory, + _In_ PPH_STRINGREF ObjectName, + _In_ ULONG Attributes, + _In_ ULONG CreateOptions, + _Out_opt_ PULONG Disposition ) { NTSTATUS status; @@ -6647,11 +6666,11 @@ NTSTATUS PhCreateKey( * \param Attributes Additional object flags. */ NTSTATUS PhOpenKey( - __out PHANDLE KeyHandle, - __in ACCESS_MASK DesiredAccess, - __in_opt HANDLE RootDirectory, - __in PPH_STRINGREF ObjectName, - __in ULONG Attributes + _Out_ PHANDLE KeyHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_opt_ HANDLE RootDirectory, + _In_ PPH_STRINGREF ObjectName, + _In_ ULONG Attributes ) { NTSTATUS status; diff --git a/2.x/trunk/phlib/phlib.vcxproj b/2.x/trunk/phlib/phlib.vcxproj index baac3308d..298228eaa 100644 --- a/2.x/trunk/phlib/phlib.vcxproj +++ b/2.x/trunk/phlib/phlib.vcxproj @@ -63,7 +63,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(ProjectDir)bin\$(Configuration)$(PlatformArchitecture)\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ $(ProjectDir)bin\$(Configuration)$(PlatformArchitecture)\ @@ -75,7 +74,6 @@ - /MP %(AdditionalOptions) Disabled include;%(AdditionalIncludeDirectories) DEBUG;%(PreprocessorDefinitions) @@ -87,16 +85,9 @@ StdCall true true - StreamingSIMDExtensions - - %(AdditionalLibraryDirectories) - - - X64 - Disabled include;%(AdditionalIncludeDirectories) @@ -109,7 +100,6 @@ StdCall true true - NotSet @@ -129,14 +119,8 @@ true StreamingSIMDExtensions - - %(AdditionalLibraryDirectories) - - - X64 - MaxSpeed true @@ -151,7 +135,6 @@ StdCall true true - NotSet @@ -216,6 +199,7 @@ + diff --git a/2.x/trunk/phlib/phlib.vcxproj.filters b/2.x/trunk/phlib/phlib.vcxproj.filters index 338abfb40..56217a98c 100644 --- a/2.x/trunk/phlib/phlib.vcxproj.filters +++ b/2.x/trunk/phlib/phlib.vcxproj.filters @@ -9,10 +9,6 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - @@ -371,5 +367,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/2.x/trunk/phlib/provider.c b/2.x/trunk/phlib/provider.c index a3d8a0453..8c2cf939e 100644 --- a/2.x/trunk/phlib/provider.c +++ b/2.x/trunk/phlib/provider.c @@ -46,7 +46,7 @@ #include #ifdef DEBUG -LIST_ENTRY PhDbgProviderListHead; +PPH_LIST PhDbgProviderList; PH_QUEUED_LOCK PhDbgProviderListLock = PH_QUEUED_LOCK_INIT; #endif @@ -57,8 +57,8 @@ PH_QUEUED_LOCK PhDbgProviderListLock = PH_QUEUED_LOCK_INIT; * \param Interval The interval between each run, in milliseconds. */ VOID PhInitializeProviderThread( - __out PPH_PROVIDER_THREAD ProviderThread, - __in ULONG Interval + _Out_ PPH_PROVIDER_THREAD ProviderThread, + _In_ ULONG Interval ) { ProviderThread->ThreadHandle = NULL; @@ -72,7 +72,9 @@ VOID PhInitializeProviderThread( #ifdef DEBUG PhAcquireQueuedLockExclusive(&PhDbgProviderListLock); - InsertTailList(&PhDbgProviderListHead, &ProviderThread->DbgListEntry); + if (!PhDbgProviderList) + PhDbgProviderList = PhCreateList(4); + PhAddItemList(PhDbgProviderList, ProviderThread); PhReleaseQueuedLockExclusive(&PhDbgProviderListLock); #endif } @@ -83,20 +85,24 @@ VOID PhInitializeProviderThread( * \param ProviderThread A pointer to a provider thread object. */ VOID PhDeleteProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread + _Inout_ PPH_PROVIDER_THREAD ProviderThread ) { +#ifdef DEBUG + ULONG index; +#endif // Nothing #ifdef DEBUG PhAcquireQueuedLockExclusive(&PhDbgProviderListLock); - RemoveEntryList(&ProviderThread->DbgListEntry); + if ((index = PhFindItemList(PhDbgProviderList, ProviderThread)) != -1) + PhRemoveItemList(PhDbgProviderList, index); PhReleaseQueuedLockExclusive(&PhDbgProviderListLock); #endif } NTSTATUS NTAPI PhpProviderThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PROVIDER_THREAD providerThread = (PPH_PROVIDER_THREAD)Parameter; @@ -236,7 +242,7 @@ NTSTATUS NTAPI PhpProviderThreadStart( * \param ProviderThread A pointer to a provider thread object. */ VOID PhStartProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread + _Inout_ PPH_PROVIDER_THREAD ProviderThread ) { if (ProviderThread->State != ProviderThreadStopped) @@ -262,7 +268,7 @@ VOID PhStartProviderThread( * \param ProviderThread A pointer to a provider thread object. */ VOID PhStopProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread + _Inout_ PPH_PROVIDER_THREAD ProviderThread ) { if (ProviderThread->State != ProviderThreadRunning) @@ -290,8 +296,8 @@ VOID PhStopProviderThread( * \param Interval The interval between each run, in milliseconds. */ VOID PhSetIntervalProviderThread( - __inout PPH_PROVIDER_THREAD ProviderThread, - __in ULONG Interval + _Inout_ PPH_PROVIDER_THREAD ProviderThread, + _In_ ULONG Interval ) { ProviderThread->Interval = Interval; @@ -320,10 +326,10 @@ VOID PhSetIntervalProviderThread( * PhSetEnabledProvider() to enable it. */ VOID PhRegisterProvider( - __inout PPH_PROVIDER_THREAD ProviderThread, - __in PPH_PROVIDER_FUNCTION Function, - __in_opt PVOID Object, - __out PPH_PROVIDER_REGISTRATION Registration + _Inout_ PPH_PROVIDER_THREAD ProviderThread, + _In_ PPH_PROVIDER_FUNCTION Function, + _In_opt_ PVOID Object, + _Out_ PPH_PROVIDER_REGISTRATION Registration ) { Registration->ProviderThread = ProviderThread; @@ -352,7 +358,7 @@ VOID PhRegisterProvider( * once this function returns. */ VOID PhUnregisterProvider( - __inout PPH_PROVIDER_REGISTRATION Registration + _Inout_ PPH_PROVIDER_REGISTRATION Registration ) { PPH_PROVIDER_THREAD providerThread; @@ -402,8 +408,8 @@ VOID PhUnregisterProvider( * runs. */ BOOLEAN PhBoostProvider( - __inout PPH_PROVIDER_REGISTRATION Registration, - __out_opt PULONG FutureRunId + _Inout_ PPH_PROVIDER_REGISTRATION Registration, + _Out_opt_ PULONG FutureRunId ) { PPH_PROVIDER_THREAD providerThread; @@ -453,7 +459,7 @@ BOOLEAN PhBoostProvider( * a provider. */ ULONG PhGetRunIdProvider( - __in PPH_PROVIDER_REGISTRATION Registration + _In_ PPH_PROVIDER_REGISTRATION Registration ) { return Registration->RunId; @@ -466,7 +472,7 @@ ULONG PhGetRunIdProvider( * a provider. */ BOOLEAN PhGetEnabledProvider( - __in PPH_PROVIDER_REGISTRATION Registration + _In_ PPH_PROVIDER_REGISTRATION Registration ) { return Registration->Enabled; @@ -481,8 +487,8 @@ BOOLEAN PhGetEnabledProvider( * FALSE. */ VOID PhSetEnabledProvider( - __inout PPH_PROVIDER_REGISTRATION Registration, - __in BOOLEAN Enabled + _Inout_ PPH_PROVIDER_REGISTRATION Registration, + _In_ BOOLEAN Enabled ) { Registration->Enabled = Enabled; diff --git a/2.x/trunk/phlib/queuedlock.c b/2.x/trunk/phlib/queuedlock.c index a29addfa2..911cf03b3 100644 --- a/2.x/trunk/phlib/queuedlock.c +++ b/2.x/trunk/phlib/queuedlock.c @@ -88,20 +88,20 @@ #include VOID FASTCALL PhpfOptimizeQueuedLockList( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value ); VOID FASTCALL PhpfWakeQueuedLock( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value ); VOID FASTCALL PhpfWakeQueuedLockEx( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value, - __in BOOLEAN IgnoreOwned, - __in BOOLEAN WakeAll + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value, + _In_ BOOLEAN IgnoreOwned, + _In_ BOOLEAN WakeAll ); static HANDLE PhQueuedLockKeyedEventHandle; @@ -158,13 +158,13 @@ BOOLEAN PhQueuedLockInitialization( * block to be unblocked. */ FORCEINLINE BOOLEAN PhpPushQueuedWaitBlock( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value, - __in BOOLEAN Exclusive, - __out PPH_QUEUED_WAIT_BLOCK WaitBlock, - __out PBOOLEAN Optimize, - __out PULONG_PTR NewValue, - __out PULONG_PTR CurrentValue + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value, + _In_ BOOLEAN Exclusive, + _Out_ PPH_QUEUED_WAIT_BLOCK WaitBlock, + _Out_ PBOOLEAN Optimize, + _Out_ PULONG_PTR NewValue, + _Out_ PULONG_PTR CurrentValue ) { ULONG_PTR newValue; @@ -256,7 +256,7 @@ FORCEINLINE BOOLEAN PhpPushQueuedWaitBlock( * \ref PH_QUEUED_LOCK_TRAVERSING. */ FORCEINLINE PPH_QUEUED_WAIT_BLOCK PhpFindLastQueuedWaitBlock( - __in ULONG_PTR Value + _In_ ULONG_PTR Value ) { PPH_QUEUED_WAIT_BLOCK waitBlock; @@ -295,10 +295,10 @@ FORCEINLINE PPH_QUEUED_WAIT_BLOCK PhpFindLastQueuedWaitBlock( * \param Spin TRUE to spin, FALSE to block immediately. * \param Timeout A timeout value. */ -__mayRaise FORCEINLINE NTSTATUS PhpBlockOnQueuedWaitBlock( - __inout PPH_QUEUED_WAIT_BLOCK WaitBlock, - __in BOOLEAN Spin, - __in_opt PLARGE_INTEGER Timeout +_May_raise_ FORCEINLINE NTSTATUS PhpBlockOnQueuedWaitBlock( + _Inout_ PPH_QUEUED_WAIT_BLOCK WaitBlock, + _In_ BOOLEAN Spin, + _In_opt_ PLARGE_INTEGER Timeout ) { NTSTATUS status; @@ -350,8 +350,8 @@ __mayRaise FORCEINLINE NTSTATUS PhpBlockOnQueuedWaitBlock( * unblocked. Do not attempt to read any values from it. All relevant * information should be saved before unblocking the wait block. */ -__mayRaise FORCEINLINE VOID PhpUnblockQueuedWaitBlock( - __inout PPH_QUEUED_WAIT_BLOCK WaitBlock +_May_raise_ FORCEINLINE VOID PhpUnblockQueuedWaitBlock( + _Inout_ PPH_QUEUED_WAIT_BLOCK WaitBlock ) { NTSTATUS status; @@ -380,9 +380,9 @@ __mayRaise FORCEINLINE VOID PhpUnblockQueuedWaitBlock( * \ref PH_QUEUED_LOCK_WAITERS, \ref PH_QUEUED_LOCK_TRAVERSING. */ FORCEINLINE VOID PhpOptimizeQueuedLockListEx( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value, - __in BOOLEAN IgnoreOwned + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value, + _In_ BOOLEAN IgnoreOwned ) { ULONG_PTR value; @@ -461,8 +461,8 @@ FORCEINLINE VOID PhpOptimizeQueuedLockListEx( * \ref PH_QUEUED_LOCK_WAITERS, \ref PH_QUEUED_LOCK_TRAVERSING. */ VOID FASTCALL PhpfOptimizeQueuedLockList( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value ) { PhpOptimizeQueuedLockListEx(QueuedLock, Value, FALSE); @@ -480,10 +480,10 @@ VOID FASTCALL PhpfOptimizeQueuedLockList( * to decide based on the wait block type. */ FORCEINLINE PPH_QUEUED_WAIT_BLOCK PhpPrepareToWakeQueuedLock( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value, - __in BOOLEAN IgnoreOwned, - __in BOOLEAN WakeAll + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value, + _In_ BOOLEAN IgnoreOwned, + _In_ BOOLEAN WakeAll ) { ULONG_PTR value; @@ -614,8 +614,8 @@ FORCEINLINE PPH_QUEUED_WAIT_BLOCK PhpPrepareToWakeQueuedLock( * \ref PH_QUEUED_LOCK_MULTIPLE_SHARED. */ VOID FASTCALL PhpfWakeQueuedLock( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value ) { PPH_QUEUED_WAIT_BLOCK waitBlock; @@ -649,10 +649,10 @@ VOID FASTCALL PhpfWakeQueuedLock( * \ref PH_QUEUED_LOCK_MULTIPLE_SHARED. */ VOID FASTCALL PhpfWakeQueuedLockEx( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value, - __in BOOLEAN IgnoreOwned, - __in BOOLEAN WakeAll + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value, + _In_ BOOLEAN IgnoreOwned, + _In_ BOOLEAN WakeAll ) { PPH_QUEUED_WAIT_BLOCK waitBlock; @@ -676,7 +676,7 @@ VOID FASTCALL PhpfWakeQueuedLockEx( * \param QueuedLock A queued lock. */ VOID FASTCALL PhfAcquireQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { ULONG_PTR value; @@ -728,7 +728,7 @@ VOID FASTCALL PhfAcquireQueuedLockExclusive( * \param QueuedLock A queued lock. */ VOID FASTCALL PhfAcquireQueuedLockShared( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { ULONG_PTR value; @@ -790,7 +790,7 @@ VOID FASTCALL PhfAcquireQueuedLockShared( * \param QueuedLock A queued lock. */ VOID FASTCALL PhfReleaseQueuedLockExclusive( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { ULONG_PTR value; @@ -850,7 +850,7 @@ VOID FASTCALL PhfReleaseQueuedLockExclusive( * \param QueuedLock A queued lock. */ VOID FASTCALL PhfReleaseQueuedLockShared( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { ULONG_PTR value; @@ -933,7 +933,7 @@ VOID FASTCALL PhfReleaseQueuedLockShared( * \remarks This function exists only for compatibility reasons. */ VOID FASTCALL PhfTryWakeQueuedLock( - __inout PPH_QUEUED_LOCK QueuedLock + _Inout_ PPH_QUEUED_LOCK QueuedLock ) { ULONG_PTR value; @@ -972,8 +972,8 @@ VOID FASTCALL PhfTryWakeQueuedLock( * \ref PH_QUEUED_LOCK_MULTIPLE_SHARED, \ref PH_QUEUED_LOCK_TRAVERSING. */ VOID FASTCALL PhfWakeForReleaseQueuedLock( - __inout PPH_QUEUED_LOCK QueuedLock, - __in ULONG_PTR Value + _Inout_ PPH_QUEUED_LOCK QueuedLock, + _In_ ULONG_PTR Value ) { ULONG_PTR newValue; @@ -999,7 +999,7 @@ VOID FASTCALL PhfWakeForReleaseQueuedLock( * the function. */ VOID FASTCALL PhfPulseCondition( - __inout PPH_QUEUED_LOCK Condition + _Inout_ PPH_QUEUED_LOCK Condition ) { if (Condition->Value & PH_QUEUED_LOCK_WAITERS) @@ -1015,7 +1015,7 @@ VOID FASTCALL PhfPulseCondition( * the function. */ VOID FASTCALL PhfPulseAllCondition( - __inout PPH_QUEUED_LOCK Condition + _Inout_ PPH_QUEUED_LOCK Condition ) { if (Condition->Value & PH_QUEUED_LOCK_WAITERS) @@ -1033,9 +1033,9 @@ VOID FASTCALL PhfPulseAllCondition( * the function. */ VOID FASTCALL PhfWaitForCondition( - __inout PPH_QUEUED_LOCK Condition, - __inout PPH_QUEUED_LOCK Lock, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_QUEUED_LOCK Condition, + _Inout_ PPH_QUEUED_LOCK Lock, + _In_opt_ PLARGE_INTEGER Timeout ) { ULONG_PTR value; @@ -1084,10 +1084,10 @@ VOID FASTCALL PhfWaitForCondition( * \param Timeout Not implemented. */ VOID FASTCALL PhfWaitForConditionEx( - __inout PPH_QUEUED_LOCK Condition, - __inout PVOID Lock, - __in ULONG Flags, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_QUEUED_LOCK Condition, + _Inout_ PVOID Lock, + _In_ ULONG Flags, + _In_opt_ PLARGE_INTEGER Timeout ) { ULONG_PTR value; @@ -1177,8 +1177,8 @@ VOID FASTCALL PhfWaitForConditionEx( * the wait block. */ VOID FASTCALL PhfQueueWakeEvent( - __inout PPH_QUEUED_LOCK WakeEvent, - __out PPH_QUEUED_WAIT_BLOCK WaitBlock + _Inout_ PPH_QUEUED_LOCK WakeEvent, + _Out_ PPH_QUEUED_WAIT_BLOCK WaitBlock ) { PPH_QUEUED_WAIT_BLOCK value; @@ -1211,8 +1211,8 @@ VOID FASTCALL PhfQueueWakeEvent( * NULL. */ VOID FASTCALL PhfSetWakeEvent( - __inout PPH_QUEUED_LOCK WakeEvent, - __inout_opt PPH_QUEUED_WAIT_BLOCK WaitBlock + _Inout_ PPH_QUEUED_LOCK WakeEvent, + _Inout_opt_ PPH_QUEUED_WAIT_BLOCK WaitBlock ) { PPH_QUEUED_WAIT_BLOCK waitBlock; @@ -1272,10 +1272,10 @@ VOID FASTCALL PhfSetWakeEvent( * predicate. */ NTSTATUS FASTCALL PhfWaitForWakeEvent( - __inout PPH_QUEUED_LOCK WakeEvent, - __inout PPH_QUEUED_WAIT_BLOCK WaitBlock, - __in BOOLEAN Spin, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_QUEUED_LOCK WakeEvent, + _Inout_ PPH_QUEUED_WAIT_BLOCK WaitBlock, + _In_ BOOLEAN Spin, + _In_opt_ PLARGE_INTEGER Timeout ) { NTSTATUS status; diff --git a/2.x/trunk/phlib/ref.c b/2.x/trunk/phlib/ref.c index f1d9434b6..32a4d70fb 100644 --- a/2.x/trunk/phlib/ref.c +++ b/2.x/trunk/phlib/ref.c @@ -116,11 +116,11 @@ NTSTATUS PhInitializeRef( * allocated. * \param ObjectType The type of the object. */ -__mayRaise NTSTATUS PhCreateObject( - __out PVOID *Object, - __in SIZE_T ObjectSize, - __in ULONG Flags, - __in PPH_OBJECT_TYPE ObjectType +_May_raise_ NTSTATUS PhCreateObject( + _Out_ PVOID *Object, + _In_ SIZE_T ObjectSize, + _In_ ULONG Flags, + _In_ PPH_OBJECT_TYPE ObjectType ) { NTSTATUS status = STATUS_SUCCESS; @@ -218,7 +218,7 @@ __mayRaise NTSTATUS PhCreateObject( * \param Object A pointer to the object to reference. */ VOID PhReferenceObject( - __in PVOID Object + _In_ PVOID Object ) { PPH_OBJECT_HEADER objectHeader; @@ -236,9 +236,9 @@ VOID PhReferenceObject( * * \return The new reference count of the object. */ -__mayRaise LONG PhReferenceObjectEx( - __in PVOID Object, - __in LONG RefCount +_May_raise_ LONG PhReferenceObjectEx( + _In_ PVOID Object, + _In_ LONG RefCount ) { PPH_OBJECT_HEADER objectHeader; @@ -276,7 +276,7 @@ __mayRaise LONG PhReferenceObjectEx( * avoid referencing an object that is being destroyed. */ BOOLEAN PhReferenceObjectSafe( - __in PVOID Object + _In_ PVOID Object ) { PPH_OBJECT_HEADER objectHeader; @@ -298,7 +298,7 @@ BOOLEAN PhReferenceObjectSafe( * \return TRUE if the object was freed, otherwise FALSE. */ VOID PhDereferenceObject( - __in PVOID Object + _In_ PVOID Object ) { PPH_OBJECT_HEADER objectHeader; @@ -326,7 +326,7 @@ VOID PhDereferenceObject( * \return TRUE if the object was freed, otherwise FALSE. */ BOOLEAN PhDereferenceObjectDeferDelete( - __in PVOID Object + _In_ PVOID Object ) { return PhDereferenceObjectEx(Object, 1, TRUE) == 0; @@ -342,10 +342,10 @@ BOOLEAN PhDereferenceObjectDeferDelete( * * \return The new reference count of the object. */ -__mayRaise LONG PhDereferenceObjectEx( - __in PVOID Object, - __in LONG RefCount, - __in BOOLEAN DeferDelete +_May_raise_ LONG PhDereferenceObjectEx( + _In_ PVOID Object, + _In_ LONG RefCount, + _In_ BOOLEAN DeferDelete ) { PPH_OBJECT_HEADER objectHeader; @@ -395,7 +395,7 @@ __mayRaise LONG PhDereferenceObjectEx( * \return A pointer to a type object. */ PPH_OBJECT_TYPE PhGetObjectType( - __in PVOID Object + _In_ PVOID Object ) { return PhObjectToObjectHeader(Object)->Type; @@ -417,10 +417,10 @@ PPH_OBJECT_TYPE PhGetObjectType( * is created. */ NTSTATUS PhCreateObjectType( - __out PPH_OBJECT_TYPE *ObjectType, - __in PWSTR Name, - __in ULONG Flags, - __in_opt PPH_TYPE_DELETE_PROCEDURE DeleteProcedure + _Out_ PPH_OBJECT_TYPE *ObjectType, + _In_ PWSTR Name, + _In_ ULONG Flags, + _In_opt_ PPH_TYPE_DELETE_PROCEDURE DeleteProcedure ) { return PhCreateObjectTypeEx( @@ -450,11 +450,11 @@ NTSTATUS PhCreateObjectType( * is created. */ NTSTATUS PhCreateObjectTypeEx( - __out PPH_OBJECT_TYPE *ObjectType, - __in PWSTR Name, - __in ULONG Flags, - __in_opt PPH_TYPE_DELETE_PROCEDURE DeleteProcedure, - __in_opt PPH_OBJECT_TYPE_PARAMETERS Parameters + _Out_ PPH_OBJECT_TYPE *ObjectType, + _In_ PWSTR Name, + _In_ ULONG Flags, + _In_opt_ PPH_TYPE_DELETE_PROCEDURE DeleteProcedure, + _In_opt_ PPH_OBJECT_TYPE_PARAMETERS Parameters ) { NTSTATUS status = STATUS_SUCCESS; @@ -508,8 +508,8 @@ NTSTATUS PhCreateObjectTypeEx( * information about the object type. */ VOID PhGetObjectTypeInformation( - __in PPH_OBJECT_TYPE ObjectType, - __out PPH_OBJECT_TYPE_INFORMATION Information + _In_ PPH_OBJECT_TYPE ObjectType, + _Out_ PPH_OBJECT_TYPE_INFORMATION Information ) { Information->Name = ObjectType->Name; @@ -524,9 +524,9 @@ VOID PhGetObjectTypeInformation( * \param Flags A combination of flags specifying how the object is to be allocated. */ PPH_OBJECT_HEADER PhpAllocateObject( - __in PPH_OBJECT_TYPE ObjectType, - __in SIZE_T ObjectSize, - __in ULONG Flags + _In_ PPH_OBJECT_TYPE ObjectType, + _In_ SIZE_T ObjectSize, + _In_ ULONG Flags ) { PPH_OBJECT_HEADER objectHeader; @@ -567,7 +567,7 @@ PPH_OBJECT_HEADER PhpAllocateObject( * \param ObjectHeader A pointer to the object header of an allocated object. */ VOID PhpFreeObject( - __in PPH_OBJECT_HEADER ObjectHeader + _In_ PPH_OBJECT_HEADER ObjectHeader ) { /* Object type statistics. */ @@ -614,7 +614,7 @@ VOID PhpFreeObject( * to delete. */ VOID PhpDeferDeleteObject( - __in PPH_OBJECT_HEADER ObjectHeader + _In_ PPH_OBJECT_HEADER ObjectHeader ) { PPH_OBJECT_HEADER nextToFree; @@ -658,7 +658,7 @@ VOID PhpDeferDeleteObject( * Removes and frees objects from the to-free list. */ NTSTATUS PhpDeferDeleteObjectRoutine( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_OBJECT_HEADER objectHeader; @@ -685,8 +685,8 @@ NTSTATUS PhpDeferDeleteObjectRoutine( * \param Size The number of bytes to allocate. */ NTSTATUS PhCreateAlloc( - __out PVOID *Alloc, - __in SIZE_T Size + _Out_ PVOID *Alloc, + _In_ SIZE_T Size ) { return PhCreateObject( @@ -712,8 +712,8 @@ FORCEINLINE PPH_AUTO_POOL PhpGetCurrentAutoPool( * Sets the current auto-dereference pool for the * current thread. */ -__mayRaise FORCEINLINE VOID PhpSetCurrentAutoPool( - __in PPH_AUTO_POOL AutoPool +_May_raise_ FORCEINLINE VOID PhpSetCurrentAutoPool( + _In_ PPH_AUTO_POOL AutoPool ) { if (!TlsSetValue(PhpAutoPoolTlsIndex, AutoPool)) @@ -744,7 +744,7 @@ __mayRaise FORCEINLINE VOID PhpSetCurrentAutoPool( * functions. */ VOID PhInitializeAutoPool( - __out PPH_AUTO_POOL AutoPool + _Out_ PPH_AUTO_POOL AutoPool ) { AutoPool->StaticCount = 0; @@ -768,8 +768,8 @@ VOID PhInitializeAutoPool( * * \param AutoPool The auto-dereference pool to delete. */ -__mayRaise VOID PhDeleteAutoPool( - __inout PPH_AUTO_POOL AutoPool +_May_raise_ VOID PhDeleteAutoPool( + _Inout_ PPH_AUTO_POOL AutoPool ) { PhDrainAutoPool(AutoPool); @@ -797,8 +797,8 @@ __mayRaise VOID PhDeleteAutoPool( * will be dereferenced when the current auto-dereference * pool is drained or freed. */ -__mayRaise VOID PhaDereferenceObject( - __in PVOID Object +_May_raise_ VOID PhaDereferenceObject( + _In_ PVOID Object ) { PPH_AUTO_POOL autoPool = PhpGetCurrentAutoPool(); @@ -851,7 +851,7 @@ __mayRaise VOID PhaDereferenceObject( * \param AutoPool The auto-release pool to drain. */ VOID PhDrainAutoPool( - __in PPH_AUTO_POOL AutoPool + _In_ PPH_AUTO_POOL AutoPool ) { ULONG i; diff --git a/2.x/trunk/phlib/secdata.c b/2.x/trunk/phlib/secdata.c index b15f5ba17..cb0561a90 100644 --- a/2.x/trunk/phlib/secdata.c +++ b/2.x/trunk/phlib/secdata.c @@ -609,9 +609,9 @@ static PH_SPECIFIC_TYPE PhSpecificTypes[] = * \a AccessEntries. */ BOOLEAN PhGetAccessEntries( - __in PWSTR Type, - __out PPH_ACCESS_ENTRY *AccessEntries, - __out PULONG NumberOfAccessEntries + _In_ PWSTR Type, + _Out_ PPH_ACCESS_ENTRY *AccessEntries, + _Out_ PULONG NumberOfAccessEntries ) { ULONG i; @@ -698,8 +698,8 @@ BOOLEAN PhGetAccessEntries( } static int __cdecl PhpAccessEntryCompare( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PPH_ACCESS_ENTRY entry1 = (PPH_ACCESS_ENTRY)elem1; @@ -720,9 +720,9 @@ static int __cdecl PhpAccessEntryCompare( * \return The string representation of \a Access. */ PPH_STRING PhGetAccessString( - __in ACCESS_MASK Access, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ ACCESS_MASK Access, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ) { PH_STRING_BUILDER stringBuilder; diff --git a/2.x/trunk/phlib/secedit.c b/2.x/trunk/phlib/secedit.c index 82679105f..7db4e8897 100644 --- a/2.x/trunk/phlib/secedit.c +++ b/2.x/trunk/phlib/secedit.c @@ -70,12 +70,12 @@ FORCEINLINE VOID PhpSecurityEditorInitialization( * \param NumberOfAccessEntries The number of elements in \a AccessEntries. */ HPROPSHEETPAGE PhCreateSecurityPage( - __in PWSTR ObjectName, - __in PPH_GET_OBJECT_SECURITY GetObjectSecurity, - __in PPH_SET_OBJECT_SECURITY SetObjectSecurity, - __in_opt PVOID Context, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ PWSTR ObjectName, + _In_ PPH_GET_OBJECT_SECURITY GetObjectSecurity, + _In_ PPH_SET_OBJECT_SECURITY SetObjectSecurity, + _In_opt_ PVOID Context, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ) { ISecurityInformation *info; @@ -116,13 +116,13 @@ HPROPSHEETPAGE PhCreateSecurityPage( * \param NumberOfAccessEntries The number of elements in \a AccessEntries. */ VOID PhEditSecurity( - __in HWND hWnd, - __in PWSTR ObjectName, - __in PPH_GET_OBJECT_SECURITY GetObjectSecurity, - __in PPH_SET_OBJECT_SECURITY SetObjectSecurity, - __in_opt PVOID Context, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ HWND hWnd, + _In_ PWSTR ObjectName, + _In_ PPH_GET_OBJECT_SECURITY GetObjectSecurity, + _In_ PPH_SET_OBJECT_SECURITY SetObjectSecurity, + _In_opt_ PVOID Context, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ) { ISecurityInformation *info; @@ -147,12 +147,12 @@ VOID PhEditSecurity( } ISecurityInformation *PhSecurityInformation_Create( - __in PWSTR ObjectName, - __in PPH_GET_OBJECT_SECURITY GetObjectSecurity, - __in PPH_SET_OBJECT_SECURITY SetObjectSecurity, - __in_opt PVOID Context, - __in PPH_ACCESS_ENTRY AccessEntries, - __in ULONG NumberOfAccessEntries + _In_ PWSTR ObjectName, + _In_ PPH_GET_OBJECT_SECURITY GetObjectSecurity, + _In_ PPH_SET_OBJECT_SECURITY SetObjectSecurity, + _In_opt_ PVOID Context, + _In_ PPH_ACCESS_ENTRY AccessEntries, + _In_ ULONG NumberOfAccessEntries ) { PhSecurityInformation *info; @@ -185,9 +185,9 @@ ISecurityInformation *PhSecurityInformation_Create( } HRESULT STDMETHODCALLTYPE PhSecurityInformation_QueryInterface( - __in ISecurityInformation *This, - __in REFIID Riid, - __out PVOID *Object + _In_ ISecurityInformation *This, + _In_ REFIID Riid, + _Out_ PVOID *Object ) { if ( @@ -205,7 +205,7 @@ HRESULT STDMETHODCALLTYPE PhSecurityInformation_QueryInterface( } ULONG STDMETHODCALLTYPE PhSecurityInformation_AddRef( - __in ISecurityInformation *This + _In_ ISecurityInformation *This ) { PhSecurityInformation *this = (PhSecurityInformation *)This; @@ -216,7 +216,7 @@ ULONG STDMETHODCALLTYPE PhSecurityInformation_AddRef( } ULONG STDMETHODCALLTYPE PhSecurityInformation_Release( - __in ISecurityInformation *This + _In_ ISecurityInformation *This ) { PhSecurityInformation *this = (PhSecurityInformation *)This; @@ -237,8 +237,8 @@ ULONG STDMETHODCALLTYPE PhSecurityInformation_Release( } HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetObjectInformation( - __in ISecurityInformation *This, - __out PSI_OBJECT_INFO ObjectInfo + _In_ ISecurityInformation *This, + _Out_ PSI_OBJECT_INFO ObjectInfo ) { PhSecurityInformation *this = (PhSecurityInformation *)This; @@ -258,10 +258,10 @@ HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetObjectInformation( } HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetSecurity( - __in ISecurityInformation *This, - __in SECURITY_INFORMATION RequestedInformation, - __out PSECURITY_DESCRIPTOR *SecurityDescriptor, - __in BOOL Default + _In_ ISecurityInformation *This, + _In_ SECURITY_INFORMATION RequestedInformation, + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor, + _In_ BOOL Default ) { PhSecurityInformation *this = (PhSecurityInformation *)This; @@ -290,9 +290,9 @@ HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetSecurity( } HRESULT STDMETHODCALLTYPE PhSecurityInformation_SetSecurity( - __in ISecurityInformation *This, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ ISecurityInformation *This, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ) { PhSecurityInformation *this = (PhSecurityInformation *)This; @@ -311,12 +311,12 @@ HRESULT STDMETHODCALLTYPE PhSecurityInformation_SetSecurity( } HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetAccessRights( - __in ISecurityInformation *This, - __in const GUID *ObjectType, - __in ULONG Flags, - __out PSI_ACCESS *Access, - __out PULONG Accesses, - __out PULONG DefaultAccess + _In_ ISecurityInformation *This, + _In_ const GUID *ObjectType, + _In_ ULONG Flags, + _Out_ PSI_ACCESS *Access, + _Out_ PULONG Accesses, + _Out_ PULONG DefaultAccess ) { PhSecurityInformation *this = (PhSecurityInformation *)This; @@ -329,29 +329,29 @@ HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetAccessRights( } HRESULT STDMETHODCALLTYPE PhSecurityInformation_MapGeneric( - __in ISecurityInformation *This, - __in const GUID *ObjectType, - __in PUCHAR AceFlags, - __inout PACCESS_MASK Mask + _In_ ISecurityInformation *This, + _In_ const GUID *ObjectType, + _In_ PUCHAR AceFlags, + _Inout_ PACCESS_MASK Mask ) { return S_OK; } HRESULT STDMETHODCALLTYPE PhSecurityInformation_GetInheritTypes( - __in ISecurityInformation *This, - __out PSI_INHERIT_TYPE *InheritTypes, - __out PULONG InheritTypesCount + _In_ ISecurityInformation *This, + _Out_ PSI_INHERIT_TYPE *InheritTypes, + _Out_ PULONG InheritTypesCount ) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE PhSecurityInformation_PropertySheetPageCallback( - __in ISecurityInformation *This, - __in HWND hwnd, - __in UINT uMsg, - __in SI_PAGE_TYPE uPage + _In_ ISecurityInformation *This, + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ SI_PAGE_TYPE uPage ) { return E_NOTIMPL; @@ -370,10 +370,10 @@ HRESULT STDMETHODCALLTYPE PhSecurityInformation_PropertySheetPageCallback( * \remarks This function may be used for the \a GetObjectSecurity * callback in PhCreateSecurityPage() or PhEditSecurity(). */ -__callback NTSTATUS PhStdGetObjectSecurity( - __out PSECURITY_DESCRIPTOR *SecurityDescriptor, - __in SECURITY_INFORMATION SecurityInformation, - __in_opt PVOID Context +_Callback_ NTSTATUS PhStdGetObjectSecurity( + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -417,10 +417,10 @@ __callback NTSTATUS PhStdGetObjectSecurity( * \remarks This function may be used for the \a SetObjectSecurity * callback in PhCreateSecurityPage() or PhEditSecurity(). */ -__callback NTSTATUS PhStdSetObjectSecurity( - __in PSECURITY_DESCRIPTOR SecurityDescriptor, - __in SECURITY_INFORMATION SecurityInformation, - __in_opt PVOID Context +_Callback_ NTSTATUS PhStdSetObjectSecurity( + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_opt_ PVOID Context ) { NTSTATUS status; @@ -453,10 +453,10 @@ __callback NTSTATUS PhStdSetObjectSecurity( } NTSTATUS PhGetSeObjectSecurity( - __in HANDLE Handle, - __in ULONG ObjectType, - __in SECURITY_INFORMATION SecurityInformation, - __out PSECURITY_DESCRIPTOR *SecurityDescriptor + _In_ HANDLE Handle, + _In_ ULONG ObjectType, + _In_ SECURITY_INFORMATION SecurityInformation, + _Out_ PSECURITY_DESCRIPTOR *SecurityDescriptor ) { ULONG win32Result; @@ -486,10 +486,10 @@ NTSTATUS PhGetSeObjectSecurity( } NTSTATUS PhSetSeObjectSecurity( - __in HANDLE Handle, - __in ULONG ObjectType, - __in SECURITY_INFORMATION SecurityInformation, - __in PSECURITY_DESCRIPTOR SecurityDescriptor + _In_ HANDLE Handle, + _In_ ULONG ObjectType, + _In_ SECURITY_INFORMATION SecurityInformation, + _In_ PSECURITY_DESCRIPTOR SecurityDescriptor ) { ULONG win32Result; diff --git a/2.x/trunk/phlib/sha.c b/2.x/trunk/phlib/sha.c index b43508f4b..bd0b4794b 100644 --- a/2.x/trunk/phlib/sha.c +++ b/2.x/trunk/phlib/sha.c @@ -89,7 +89,7 @@ static void SHATransform(ULONG State[5], UCHAR Buffer[64]) } VOID A_SHAInit( - __out A_SHA_CTX *Context + _Out_ A_SHA_CTX *Context ) { /* SHA1 initialization constants */ @@ -103,9 +103,9 @@ VOID A_SHAInit( } VOID A_SHAUpdate( - __inout A_SHA_CTX *Context, - __in_bcount(Length) UCHAR *Input, - __in ULONG Length + _Inout_ A_SHA_CTX *Context, + _In_reads_bytes_(Length) UCHAR *Input, + _In_ ULONG Length ) { ULONG InputContentSize; @@ -137,8 +137,8 @@ VOID A_SHAUpdate( } VOID A_SHAFinal( - __inout A_SHA_CTX *Context, - __out_bcount(20) UCHAR *Hash + _Inout_ A_SHA_CTX *Context, + _Out_writes_bytes_(20) UCHAR *Hash ) { INT Pad, Index; diff --git a/2.x/trunk/phlib/support.c b/2.x/trunk/phlib/support.c index 94daf4425..401cdf188 100644 --- a/2.x/trunk/phlib/support.c +++ b/2.x/trunk/phlib/support.c @@ -2,7 +2,7 @@ * Process Hacker - * general support functions * - * Copyright (C) 2009-2012 wj32 + * Copyright (C) 2009-2013 wj32 * * This file is part of Process Hacker. * @@ -30,22 +30,22 @@ #define PHP_USE_IFILEDIALOG (WINDOWS_HAS_IFILEDIALOG) typedef BOOLEAN (NTAPI *_WinStationQueryInformationW)( - __in_opt HANDLE ServerHandle, - __in ULONG LogonId, - __in WINSTATIONINFOCLASS WinStationInformationClass, - __out_bcount(WinStationInformationLength) PVOID WinStationInformation, - __in ULONG WinStationInformationLength, - __out PULONG ReturnLength + _In_opt_ HANDLE ServerHandle, + _In_ ULONG LogonId, + _In_ WINSTATIONINFOCLASS WinStationInformationClass, + _Out_writes_bytes_(WinStationInformationLength) PVOID WinStationInformation, + _In_ ULONG WinStationInformationLength, + _Out_ PULONG ReturnLength ); typedef BOOL (WINAPI *_CreateEnvironmentBlock)( - __out LPVOID *lpEnvironment, - __in_opt HANDLE hToken, - __in BOOL bInherit + _Out_ LPVOID *lpEnvironment, + _In_opt_ HANDLE hToken, + _In_ BOOL bInherit ); typedef BOOL (WINAPI *_DestroyEnvironmentBlock)( - __in LPVOID lpEnvironment + _In_ LPVOID lpEnvironment ); DECLSPEC_SELECTANY WCHAR *PhSizeUnitNames[7] = { L"B", L"kB", L"MB", L"GB", L"TB", L"PB", L"EB" }; @@ -63,8 +63,8 @@ DECLSPEC_SELECTANY ULONG PhMaxSizeUnit = MAXULONG32; * top-left of the bounds. */ VOID PhAdjustRectangleToBounds( - __inout PPH_RECTANGLE Rectangle, - __in PPH_RECTANGLE Bounds + _Inout_ PPH_RECTANGLE Rectangle, + _In_ PPH_RECTANGLE Bounds ) { if (Rectangle->Left + Rectangle->Width > Bounds->Left + Bounds->Width) @@ -86,8 +86,8 @@ VOID PhAdjustRectangleToBounds( * \param Bounds The bounds. */ VOID PhCenterRectangle( - __inout PPH_RECTANGLE Rectangle, - __in PPH_RECTANGLE Bounds + _Inout_ PPH_RECTANGLE Rectangle, + _In_ PPH_RECTANGLE Bounds ) { Rectangle->Left = Bounds->Left + (Bounds->Width - Rectangle->Width) / 2; @@ -102,8 +102,8 @@ VOID PhCenterRectangle( * \param Rectangle The rectangle to be adjusted. */ VOID PhAdjustRectangleToWorkingArea( - __in HWND hWnd, - __inout PPH_RECTANGLE Rectangle + _In_ HWND hWnd, + _Inout_ PPH_RECTANGLE Rectangle ) { MONITORINFO monitorInfo = { sizeof(monitorInfo) }; @@ -129,8 +129,8 @@ VOID PhAdjustRectangleToWorkingArea( * at the center of the monitor. */ VOID PhCenterWindow( - __in HWND WindowHandle, - __in_opt HWND ParentWindowHandle + _In_ HWND WindowHandle, + _In_opt_ HWND ParentWindowHandle ) { if (ParentWindowHandle) @@ -179,8 +179,8 @@ VOID PhCenterWindow( * \param NumberOfObjects The number of elements in \a Objects. */ VOID PhReferenceObjects( - __in_ecount(NumberOfObjects) PVOID *Objects, - __in ULONG NumberOfObjects + _In_reads_(NumberOfObjects) PVOID *Objects, + _In_ ULONG NumberOfObjects ) { ULONG i; @@ -196,8 +196,8 @@ VOID PhReferenceObjects( * \param NumberOfObjects The number of elements in \a Objects. */ VOID PhDereferenceObjects( - __in_ecount(NumberOfObjects) PVOID *Objects, - __in ULONG NumberOfObjects + _In_reads_(NumberOfObjects) PVOID *Objects, + _In_ ULONG NumberOfObjects ) { ULONG i; @@ -219,10 +219,10 @@ VOID PhDereferenceObjects( * when you no longer need it. */ PPH_STRING PhGetMessage( - __in PVOID DllHandle, - __in ULONG MessageTableId, - __in ULONG MessageLanguageId, - __in ULONG MessageId + _In_ PVOID DllHandle, + _In_ ULONG MessageTableId, + _In_ ULONG MessageLanguageId, + _In_ ULONG MessageId ) { NTSTATUS status; @@ -265,11 +265,11 @@ PPH_STRING PhGetMessage( if (messageEntry->Flags & MESSAGE_RESOURCE_UNICODE) { - return PhCreateStringEx((PWSTR)messageEntry->Text, messageEntry->Length); + return PhCreateStringEx((PWCHAR)messageEntry->Text, messageEntry->Length); } else { - return PhCreateStringFromAnsiEx((PSTR)messageEntry->Text, messageEntry->Length); + return PhCreateStringFromAnsiEx((PCHAR)messageEntry->Text, messageEntry->Length); } } @@ -279,7 +279,7 @@ PPH_STRING PhGetMessage( * \param Status The NT status value. */ PPH_STRING PhGetNtMessage( - __in NTSTATUS Status + _In_ NTSTATUS Status ) { PPH_STRING message; @@ -324,7 +324,7 @@ PPH_STRING PhGetNtMessage( * \param Result The Win32 error code. */ PPH_STRING PhGetWin32Message( - __in ULONG Result + _In_ ULONG Result ) { return PhGetMessage(GetModuleHandle(L"kernel32.dll"), 0xb, GetUserDefaultLangID(), Result); @@ -340,9 +340,9 @@ PPH_STRING PhGetWin32Message( * \return The user's response. */ INT PhShowMessage( - __in HWND hWnd, - __in ULONG Type, - __in PWSTR Format, + _In_ HWND hWnd, + _In_ ULONG Type, + _In_ PWSTR Format, ... ) { @@ -354,10 +354,10 @@ INT PhShowMessage( } INT PhShowMessage_V( - __in HWND hWnd, - __in ULONG Type, - __in PWSTR Format, - __in va_list ArgPtr + _In_ HWND hWnd, + _In_ ULONG Type, + _In_ PWSTR Format, + _In_ va_list ArgPtr ) { INT result; @@ -371,9 +371,9 @@ INT PhShowMessage_V( return MessageBox(hWnd, message, PhApplicationName, Type); } -PPH_STRING PhpGetStatusMessage( - __in NTSTATUS Status, - __in_opt ULONG Win32Result +PPH_STRING PhGetStatusMessage( + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ) { if (!Win32Result) @@ -408,15 +408,15 @@ PPH_STRING PhpGetStatusMessage( * \param Win32Result A Win32 error code, or 0 if there is none. */ VOID PhShowStatus( - __in HWND hWnd, - __in_opt PWSTR Message, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_opt_ PWSTR Message, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ) { PPH_STRING statusMessage; - statusMessage = PhpGetStatusMessage(Status, Win32Result); + statusMessage = PhGetStatusMessage(Status, Win32Result); if (!statusMessage) { @@ -457,16 +457,16 @@ VOID PhShowStatus( * otherwise FALSE. */ BOOLEAN PhShowContinueStatus( - __in HWND hWnd, - __in_opt PWSTR Message, - __in NTSTATUS Status, - __in_opt ULONG Win32Result + _In_ HWND hWnd, + _In_opt_ PWSTR Message, + _In_ NTSTATUS Status, + _In_opt_ ULONG Win32Result ) { PPH_STRING statusMessage; INT result; - statusMessage = PhpGetStatusMessage(Status, Win32Result); + statusMessage = PhGetStatusMessage(Status, Win32Result); if (!statusMessage) { @@ -509,11 +509,11 @@ BOOLEAN PhShowContinueStatus( * \return TRUE if the user wishes to continue, otherwise FALSE. */ BOOLEAN PhShowConfirmMessage( - __in HWND hWnd, - __in PWSTR Verb, - __in PWSTR Object, - __in_opt PWSTR Message, - __in BOOLEAN Warning + _In_ HWND hWnd, + _In_ PWSTR Verb, + _In_ PWSTR Object, + _In_opt_ PWSTR Message, + _In_ BOOLEAN Warning ) { PPH_STRING verb; @@ -593,10 +593,10 @@ BOOLEAN PhShowConfirmMessage( * \remarks The search is case-sensitive. */ BOOLEAN PhFindIntegerSiKeyValuePairs( - __in PPH_KEY_VALUE_PAIR KeyValuePairs, - __in ULONG SizeOfKeyValuePairs, - __in PWSTR String, - __out PULONG Integer + _In_ PPH_KEY_VALUE_PAIR KeyValuePairs, + _In_ ULONG SizeOfKeyValuePairs, + _In_ PWSTR String, + _Out_ PULONG Integer ) { ULONG i; @@ -624,10 +624,10 @@ BOOLEAN PhFindIntegerSiKeyValuePairs( * \return TRUE if the integer was found, otherwise FALSE. */ BOOLEAN PhFindStringSiKeyValuePairs( - __in PPH_KEY_VALUE_PAIR KeyValuePairs, - __in ULONG SizeOfKeyValuePairs, - __in ULONG Integer, - __out PWSTR *String + _In_ PPH_KEY_VALUE_PAIR KeyValuePairs, + _In_ ULONG SizeOfKeyValuePairs, + _In_ ULONG Integer, + _Out_ PWSTR *String ) { ULONG i; @@ -650,7 +650,7 @@ BOOLEAN PhFindStringSiKeyValuePairs( * \param Guid The destination UUID. */ VOID PhGenerateGuid( - __out PGUID Guid + _Out_ PGUID Guid ) { static ULONG seed = 0; @@ -687,7 +687,7 @@ VOID PhGenerateGuid( } FORCEINLINE VOID PhpReverseGuid( - __inout PGUID Guid + _Inout_ PGUID Guid ) { Guid->Data1 = _byteswap_ulong(Guid->Data1); @@ -708,11 +708,11 @@ FORCEINLINE VOID PhpReverseGuid( * \li \c GUID_VERSION_SHA1 Creates a type 5, SHA1-based UUID. */ VOID PhGenerateGuidFromName( - __out PGUID Guid, - __in PGUID Namespace, - __in PCHAR Name, - __in ULONG NameLength, - __in UCHAR Version + _Out_ PGUID Guid, + _In_ PGUID Namespace, + _In_ PCHAR Name, + _In_ ULONG NameLength, + _In_ UCHAR Version ) { PGUID_EX guid; @@ -773,8 +773,8 @@ VOID PhGenerateGuidFromName( * including space for the null terminator. */ VOID PhGenerateRandomAlphaString( - __out_ecount_z(Count) PWSTR Buffer, - __in ULONG Count + _Out_writes_z_(Count) PWSTR Buffer, + _In_ ULONG Count ) { static ULONG seed = 0; @@ -802,8 +802,8 @@ VOID PhGenerateRandomAlphaString( * \return The new string. */ PPH_STRING PhEllipsisString( - __in PPH_STRING String, - __in ULONG DesiredCount + _In_ PPH_STRING String, + _In_ ULONG DesiredCount ) { if ( @@ -838,8 +838,8 @@ PPH_STRING PhEllipsisString( * \return The new string. */ PPH_STRING PhEllipsisStringPath( - __in PPH_STRING String, - __in ULONG DesiredCount + _In_ PPH_STRING String, + _In_ ULONG DesiredCount ) { ULONG_PTR secondPartIndex; @@ -904,9 +904,9 @@ PPH_STRING PhEllipsisStringPath( } FORCEINLINE BOOLEAN PhpMatchWildcards( - __in PWSTR Pattern, - __in PWSTR String, - __in BOOLEAN IgnoreCase + _In_ PWSTR Pattern, + _In_ PWSTR String, + _In_ BOOLEAN IgnoreCase ) { PWCHAR s, p; @@ -972,9 +972,9 @@ FORCEINLINE BOOLEAN PhpMatchWildcards( * \param IgnoreCase Whether to ignore character cases. */ BOOLEAN PhMatchWildcards( - __in PWSTR Pattern, - __in PWSTR String, - __in BOOLEAN IgnoreCase + _In_ PWSTR Pattern, + _In_ PWSTR String, + _In_ BOOLEAN IgnoreCase ) { if (!IgnoreCase) @@ -992,7 +992,7 @@ BOOLEAN PhMatchWildcards( * 2 ampersands. */ PPH_STRING PhEscapeStringForMenuPrefix( - __in PPH_STRINGREF String + _In_ PPH_STRINGREF String ) { PH_STRING_BUILDER stringBuilder; @@ -1051,10 +1051,10 @@ PPH_STRING PhEscapeStringForMenuPrefix( * prefix of \a B. */ LONG PhCompareUnicodeStringZIgnoreMenuPrefix( - __in PWSTR A, - __in PWSTR B, - __in BOOLEAN IgnoreCase, - __in BOOLEAN MatchIfPrefix + _In_ PWSTR A, + _In_ PWSTR B, + _In_ BOOLEAN IgnoreCase, + _In_ BOOLEAN MatchIfPrefix ) { WCHAR t; @@ -1127,8 +1127,8 @@ LONG PhCompareUnicodeStringZIgnoreMenuPrefix( * to the user's locale is used. */ PPH_STRING PhFormatDate( - __in_opt PSYSTEMTIME Date, - __in_opt PWSTR Format + _In_opt_ PSYSTEMTIME Date, + _In_opt_ PWSTR Format ) { PPH_STRING string; @@ -1156,8 +1156,8 @@ PPH_STRING PhFormatDate( * to the user's locale is used. */ PPH_STRING PhFormatTime( - __in_opt PSYSTEMTIME Time, - __in_opt PWSTR Format + _In_opt_ PSYSTEMTIME Time, + _In_opt_ PWSTR Format ) { PPH_STRING string; @@ -1185,7 +1185,7 @@ PPH_STRING PhFormatTime( * \return A string containing the time, a space character, then the date. */ PPH_STRING PhFormatDateTime( - __in_opt PSYSTEMTIME DateTime + _In_opt_ PSYSTEMTIME DateTime ) { PPH_STRING string; @@ -1224,7 +1224,7 @@ PPH_STRING PhFormatDateTime( * \param TimeSpan The time span, in ticks. */ PPH_STRING PhFormatTimeSpanRelative( - __in ULONG64 TimeSpan + _In_ ULONG64 TimeSpan ) { PH_AUTO_POOL autoPool; @@ -1348,8 +1348,8 @@ PPH_STRING PhFormatTimeSpanRelative( * \param GroupDigits TRUE to group digits, otherwise FALSE. */ PPH_STRING PhFormatUInt64( - __in ULONG64 Value, - __in BOOLEAN GroupDigits + _In_ ULONG64 Value, + _In_ BOOLEAN GroupDigits ) { PH_FORMAT format; @@ -1361,9 +1361,9 @@ PPH_STRING PhFormatUInt64( } PPH_STRING PhFormatDecimal( - __in PWSTR Value, - __in ULONG FractionalDigits, - __in BOOLEAN GroupDigits + _In_ PWSTR Value, + _In_ ULONG FractionalDigits, + _In_ BOOLEAN GroupDigits ) { static PH_INITONCE initOnce = PH_INITONCE_INIT; @@ -1427,8 +1427,8 @@ PPH_STRING PhFormatDecimal( * \li \c 6 Exabytes. */ PPH_STRING PhFormatSize( - __in ULONG64 Size, - __in ULONG MaxSizeUnit + _In_ ULONG64 Size, + _In_ ULONG MaxSizeUnit ) { PH_FORMAT format; @@ -1448,7 +1448,7 @@ PPH_STRING PhFormatSize( * \param Guid A UUID. */ PPH_STRING PhFormatGuid( - __in PGUID Guid + _In_ PGUID Guid ) { PPH_STRING string; @@ -1472,7 +1472,7 @@ PPH_STRING PhFormatGuid( * free this using PhFree() when you no longer need it. */ PVOID PhGetFileVersionInfo( - __in PWSTR FileName + _In_ PWSTR FileName ) { ULONG versionInfoSize; @@ -1515,7 +1515,7 @@ PVOID PhGetFileVersionInfo( * \param VersionInfo The version information block. */ ULONG PhGetFileVersionInfoLangCodePage( - __in PVOID VersionInfo + _In_ PVOID VersionInfo ) { PVOID buffer; @@ -1539,8 +1539,8 @@ ULONG PhGetFileVersionInfoLangCodePage( * \param SubBlock The path to the sub-block. */ PPH_STRING PhGetFileVersionInfoString( - __in PVOID VersionInfo, - __in PWSTR SubBlock + _In_ PVOID VersionInfo, + _In_ PWSTR SubBlock ) { PVOID buffer; @@ -1550,7 +1550,7 @@ PPH_STRING PhGetFileVersionInfoString( { PPH_STRING string; - string = PhCreateStringEx((PWSTR)buffer, length * sizeof(WCHAR)); + string = PhCreateStringEx((PWCHAR)buffer, length * sizeof(WCHAR)); // length may include the null terminator. PhTrimToNullTerminatorString(string); @@ -1570,9 +1570,9 @@ PPH_STRING PhGetFileVersionInfoString( * \param StringName The name of the string. */ PPH_STRING PhGetFileVersionInfoString2( - __in PVOID VersionInfo, - __in ULONG LangCodePage, - __in PWSTR StringName + _In_ PVOID VersionInfo, + _In_ ULONG LangCodePage, + _In_ PWSTR StringName ) { WCHAR subBlock[65]; @@ -1592,9 +1592,9 @@ PPH_STRING PhGetFileVersionInfoString2( } VOID PhpGetImageVersionInfoFields( - __out PPH_IMAGE_VERSION_INFO ImageVersionInfo, - __in PVOID VersionInfo, - __in ULONG LangCodePage + _Out_ PPH_IMAGE_VERSION_INFO ImageVersionInfo, + _In_ PVOID VersionInfo, + _In_ ULONG LangCodePage ) { ImageVersionInfo->CompanyName = PhGetFileVersionInfoString2(VersionInfo, LangCodePage, L"CompanyName"); @@ -1609,8 +1609,8 @@ VOID PhpGetImageVersionInfoFields( * \param FileName The file name of an image. */ BOOLEAN PhInitializeImageVersionInfo( - __out PPH_IMAGE_VERSION_INFO ImageVersionInfo, - __in PWSTR FileName + _Out_ PPH_IMAGE_VERSION_INFO ImageVersionInfo, + _In_ PWSTR FileName ) { PVOID versionInfo; @@ -1672,7 +1672,7 @@ BOOLEAN PhInitializeImageVersionInfo( * \param ImageVersionInfo The version information structure. */ VOID PhDeleteImageVersionInfo( - __inout PPH_IMAGE_VERSION_INFO ImageVersionInfo + _Inout_ PPH_IMAGE_VERSION_INFO ImageVersionInfo ) { if (ImageVersionInfo->CompanyName) PhDereferenceObject(ImageVersionInfo->CompanyName); @@ -1682,10 +1682,10 @@ VOID PhDeleteImageVersionInfo( } PPH_STRING PhFormatImageVersionInfo( - __in_opt PPH_STRING FileName, - __in PPH_IMAGE_VERSION_INFO ImageVersionInfo, - __in_opt PWSTR Indent, - __in_opt ULONG LineLimit + _In_opt_ PPH_STRING FileName, + _In_ PPH_IMAGE_VERSION_INFO ImageVersionInfo, + _In_opt_ PWSTR Indent, + _In_opt_ ULONG LineLimit ) { PH_STRING_BUILDER stringBuilder; @@ -1812,8 +1812,8 @@ PPH_STRING PhFormatImageVersionInfo( * \return An absolute file name, or NULL if the function failed. */ PPH_STRING PhGetFullPath( - __in PWSTR FileName, - __out_opt PULONG IndexOfFileName + _In_ PWSTR FileName, + _Out_opt_ PULONG IndexOfFileName ) { PPH_STRING fullPath; @@ -1866,7 +1866,7 @@ PPH_STRING PhGetFullPath( * \param String The string. */ PPH_STRING PhExpandEnvironmentStrings( - __in PPH_STRINGREF String + _In_ PPH_STRINGREF String ) { NTSTATUS status; @@ -1925,7 +1925,7 @@ PPH_STRING PhExpandEnvironmentStrings( * \param FileName The file name. */ PPH_STRING PhGetBaseName( - __in PPH_STRING FileName + _In_ PPH_STRING FileName ) { ULONG_PTR lastIndexOfBackslash; @@ -2008,7 +2008,7 @@ PPH_STRING PhGetSystemDirectory( * Retrieves the Windows directory path. */ VOID PhGetSystemRoot( - __out PPH_STRINGREF SystemRoot + _Out_ PPH_STRINGREF SystemRoot ) { static PH_STRINGREF systemRoot; @@ -2052,9 +2052,9 @@ VOID PhGetSystemRoot( * values is returned. */ PLDR_DATA_TABLE_ENTRY PhFindLoaderEntry( - __in_opt PVOID DllBase, - __in_opt PPH_STRINGREF FullDllName, - __in_opt PPH_STRINGREF BaseDllName + _In_opt_ PVOID DllBase, + _In_opt_ PPH_STRINGREF FullDllName, + _In_opt_ PPH_STRINGREF BaseDllName ) { PLDR_DATA_TABLE_ENTRY result = NULL; @@ -2100,8 +2100,8 @@ PLDR_DATA_TABLE_ENTRY PhFindLoaderEntry( * be found. */ PPH_STRING PhGetDllFileName( - __in PVOID DllHandle, - __out_opt PULONG IndexOfFileName + _In_ PVOID DllHandle, + _Out_opt_ PULONG IndexOfFileName ) { PLDR_DATA_TABLE_ENTRY entry; @@ -2186,8 +2186,8 @@ PPH_STRING PhGetApplicationDirectory( * \param AppendPath A string to append to the folder path. */ PPH_STRING PhGetKnownLocation( - __in ULONG Folder, - __in_opt PWSTR AppendPath + _In_ ULONG Folder, + _In_opt_ PWSTR AppendPath ) { PPH_STRING path; @@ -2238,10 +2238,10 @@ PPH_STRING PhGetKnownLocation( * \remarks The wait is always in WaitAny mode. */ NTSTATUS PhWaitForMultipleObjectsAndPump( - __in_opt HWND hWnd, - __in ULONG NumberOfHandles, - __in PHANDLE Handles, - __in ULONG Timeout + _In_opt_ HWND hWnd, + _In_ ULONG NumberOfHandles, + _In_ PHANDLE Handles, + _In_ ULONG Timeout ) { NTSTATUS status; @@ -2324,16 +2324,16 @@ NTSTATUS PhWaitForMultipleObjectsAndPump( * \param ThreadHandle A variable which receives a handle to the initial thread. */ NTSTATUS PhCreateProcess( - __in PWSTR FileName, - __in_opt PPH_STRINGREF CommandLine, - __in_opt PVOID Environment, - __in_opt PPH_STRINGREF CurrentDirectory, - __in_opt PPH_CREATE_PROCESS_INFO Information, - __in ULONG Flags, - __in_opt HANDLE ParentProcessHandle, - __out_opt PCLIENT_ID ClientId, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_ PWSTR FileName, + _In_opt_ PPH_STRINGREF CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PPH_STRINGREF CurrentDirectory, + _In_opt_ PPH_CREATE_PROCESS_INFO Information, + _In_ ULONG Flags, + _In_opt_ HANDLE ParentProcessHandle, + _Out_opt_ PCLIENT_ID ClientId, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ) { NTSTATUS status; @@ -2453,14 +2453,14 @@ NTSTATUS PhCreateProcess( * \param ThreadHandle A variable which receives a handle to the initial thread. */ NTSTATUS PhCreateProcessWin32( - __in_opt PWSTR FileName, - __in_opt PWSTR CommandLine, - __in_opt PVOID Environment, - __in_opt PWSTR CurrentDirectory, - __in ULONG Flags, - __in_opt HANDLE TokenHandle, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_opt_ PWSTR FileName, + _In_opt_ PWSTR CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PWSTR CurrentDirectory, + _In_ ULONG Flags, + _In_opt_ HANDLE TokenHandle, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ) { return PhCreateProcessWin32Ex( @@ -2486,10 +2486,10 @@ static const PH_FLAG_MAPPING PhpCreateProcessMappings[] = }; FORCEINLINE VOID PhpConvertProcessInformation( - __in PPROCESS_INFORMATION ProcessInfo, - __out_opt PCLIENT_ID ClientId, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_ PPROCESS_INFORMATION ProcessInfo, + _Out_opt_ PCLIENT_ID ClientId, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ) { if (ClientId) @@ -2530,16 +2530,16 @@ FORCEINLINE VOID PhpConvertProcessInformation( * \param ThreadHandle A variable which receives a handle to the initial thread. */ NTSTATUS PhCreateProcessWin32Ex( - __in_opt PWSTR FileName, - __in_opt PWSTR CommandLine, - __in_opt PVOID Environment, - __in_opt PWSTR CurrentDirectory, - __in_opt STARTUPINFO *StartupInfo, - __in ULONG Flags, - __in_opt HANDLE TokenHandle, - __out_opt PCLIENT_ID ClientId, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_opt_ PWSTR FileName, + _In_opt_ PWSTR CommandLine, + _In_opt_ PVOID Environment, + _In_opt_ PWSTR CurrentDirectory, + _In_opt_ STARTUPINFO *StartupInfo, + _In_ ULONG Flags, + _In_opt_ HANDLE TokenHandle, + _Out_opt_ PCLIENT_ID ClientId, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ) { NTSTATUS status; @@ -2634,11 +2634,11 @@ NTSTATUS PhCreateProcessWin32Ex( * \param ThreadHandle A variable which receives a handle to the initial thread. */ NTSTATUS PhCreateProcessAsUser( - __in PPH_CREATE_PROCESS_AS_USER_INFO Information, - __in ULONG Flags, - __out_opt PCLIENT_ID ClientId, - __out_opt PHANDLE ProcessHandle, - __out_opt PHANDLE ThreadHandle + _In_ PPH_CREATE_PROCESS_AS_USER_INFO Information, + _In_ ULONG Flags, + _Out_opt_ PCLIENT_ID ClientId, + _Out_opt_ PHANDLE ProcessHandle, + _Out_opt_ PHANDLE ThreadHandle ) { static PH_INITONCE initOnce = PH_INITONCE_INIT; @@ -2949,8 +2949,8 @@ NTSTATUS PhCreateProcessAsUser( } NTSTATUS PhpGetAccountPrivileges( - __in PSID AccountSid, - __out PTOKEN_PRIVILEGES *Privileges + _In_ PSID AccountSid, + _Out_ PTOKEN_PRIVILEGES *Privileges ) { NTSTATUS status; @@ -2990,8 +2990,8 @@ NTSTATUS PhpGetAccountPrivileges( * token. The handle will have the same granted access as \a TokenHandle. */ NTSTATUS PhFilterTokenForLimitedUser( - __in HANDLE TokenHandle, - __out PHANDLE NewTokenHandle + _In_ HANDLE TokenHandle, + _Out_ PHANDLE NewTokenHandle ) { static SID_IDENTIFIER_AUTHORITY ntAuthority = SECURITY_NT_AUTHORITY; @@ -3198,9 +3198,9 @@ NTSTATUS PhFilterTokenForLimitedUser( * \param Parameters The parameters to pass to the executed application. */ VOID PhShellExecute( - __in HWND hWnd, - __in PWSTR FileName, - __in_opt PWSTR Parameters + _In_ HWND hWnd, + _In_ PWSTR FileName, + _In_opt_ PWSTR Parameters ) { SHELLEXECUTEINFO info = { sizeof(info) }; @@ -3233,13 +3233,13 @@ VOID PhShellExecute( * \param ProcessHandle A variable which receives a handle to the new process. */ BOOLEAN PhShellExecuteEx( - __in HWND hWnd, - __in PWSTR FileName, - __in_opt PWSTR Parameters, - __in ULONG ShowWindowType, - __in ULONG Flags, - __in_opt ULONG Timeout, - __out_opt PHANDLE ProcessHandle + _In_ HWND hWnd, + _In_ PWSTR FileName, + _In_opt_ PWSTR Parameters, + _In_ ULONG ShowWindowType, + _In_ ULONG Flags, + _In_opt_ ULONG Timeout, + _Out_opt_ PHANDLE ProcessHandle ) { SHELLEXECUTEINFO info = { sizeof(info) }; @@ -3289,8 +3289,8 @@ BOOLEAN PhShellExecuteEx( * \param FileName A file name. */ VOID PhShellExploreFile( - __in HWND hWnd, - __in PWSTR FileName + _In_ HWND hWnd, + _In_ PWSTR FileName ) { if (SHOpenFolderAndSelectItems_I && SHParseDisplayName_I) @@ -3325,8 +3325,8 @@ VOID PhShellExploreFile( * \param FileName A file name. */ VOID PhShellProperties( - __in HWND hWnd, - __in PWSTR FileName + _In_ HWND hWnd, + _In_ PWSTR FileName ) { SHELLEXECUTEINFO info = { sizeof(info) }; @@ -3345,72 +3345,90 @@ VOID PhShellProperties( } /** - * Opens a key in the Registry Editor. + * Expands registry name abbreviations. * - * \param hWnd A handle to the parent window. - * \param KeyName The key name to open. + * \param KeyName The key name. + * \param Computer TRUE to prepend "Computer" or "My Computer" for use with + * the Registry Editor. */ -VOID PhShellOpenKey( - __in HWND hWnd, - __in PPH_STRING KeyName +PPH_STRING PhExpandKeyName( + _In_ PPH_STRING KeyName, + _In_ BOOLEAN Computer ) { - PPH_STRING lastKey; + PPH_STRING keyName; PPH_STRING tempString; - HANDLE regeditKeyHandle; - PH_STRINGREF regeditKeyName; - UNICODE_STRING valueName; - PPH_STRING regeditFileName; - - PhInitializeStringRef(®editKeyName, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit"); - - if (!NT_SUCCESS(PhCreateKey( - ®editKeyHandle, - KEY_WRITE, - PH_KEY_CURRENT_USER, - ®editKeyName, - 0, - 0, - NULL - ))) - return; - // Expand the abbreviations. if (PhStartsWithString2(KeyName, L"HKCU", TRUE)) { - lastKey = PhConcatStrings2(L"HKEY_CURRENT_USER", &KeyName->Buffer[4]); + keyName = PhConcatStrings2(L"HKEY_CURRENT_USER", &KeyName->Buffer[4]); } else if (PhStartsWithString2(KeyName, L"HKU", TRUE)) { - lastKey = PhConcatStrings2(L"HKEY_USERS", &KeyName->Buffer[3]); + keyName = PhConcatStrings2(L"HKEY_USERS", &KeyName->Buffer[3]); } else if (PhStartsWithString2(KeyName, L"HKCR", TRUE)) { - lastKey = PhConcatStrings2(L"HKEY_CLASSES_ROOT", &KeyName->Buffer[4]); + keyName = PhConcatStrings2(L"HKEY_CLASSES_ROOT", &KeyName->Buffer[4]); } else if (PhStartsWithString2(KeyName, L"HKLM", TRUE)) { - lastKey = PhConcatStrings2(L"HKEY_LOCAL_MACHINE", &KeyName->Buffer[4]); + keyName = PhConcatStrings2(L"HKEY_LOCAL_MACHINE", &KeyName->Buffer[4]); } else { - lastKey = KeyName; + keyName = KeyName; PhReferenceObject(KeyName); } - // Set the last opened key in regedit's configuration. Note that - // if we are on Vista, we need to prepend "Computer\". - - if (WindowsVersion >= WINDOWS_VISTA) + if (Computer) { - tempString = PhConcatStrings2(L"Computer\\", lastKey->Buffer); - PhDereferenceObject(lastKey); - lastKey = tempString; + if (WindowsVersion >= WINDOWS_VISTA) + tempString = PhConcatStrings2(L"Computer\\", keyName->Buffer); + else + tempString = PhConcatStrings2(L"My Computer\\", keyName->Buffer); + + PhDereferenceObject(keyName); + keyName = tempString; } + return keyName; +} + +/** + * Opens a key in the Registry Editor. + * + * \param hWnd A handle to the parent window. + * \param KeyName The key name to open. + */ +VOID PhShellOpenKey( + _In_ HWND hWnd, + _In_ PPH_STRING KeyName + ) +{ + static PH_STRINGREF regeditKeyName = PH_STRINGREF_INIT(L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit"); + + PPH_STRING lastKey; + HANDLE regeditKeyHandle; + UNICODE_STRING valueName; + PPH_STRING regeditFileName; + + if (!NT_SUCCESS(PhCreateKey( + ®editKeyHandle, + KEY_WRITE, + PH_KEY_CURRENT_USER, + ®editKeyName, + 0, + 0, + NULL + ))) + return; + RtlInitUnicodeString(&valueName, L"LastKey"); + lastKey = PhExpandKeyName(KeyName, TRUE); NtSetValueKey(regeditKeyHandle, &valueName, 0, REG_SZ, lastKey->Buffer, (ULONG)lastKey->Length + 2); PhDereferenceObject(lastKey); + NtClose(regeditKeyHandle); // Start regedit. @@ -3447,8 +3465,8 @@ VOID PhShellOpenKey( * need it. */ PKEY_VALUE_PARTIAL_INFORMATION PhQueryRegistryValue( - __in HANDLE KeyHandle, - __in_opt PWSTR ValueName + _In_ HANDLE KeyHandle, + _In_opt_ PWSTR ValueName ) { NTSTATUS status; @@ -3503,8 +3521,8 @@ PKEY_VALUE_PARTIAL_INFORMATION PhQueryRegistryValue( * you no longer need it. */ PPH_STRING PhQueryRegistryString( - __in HANDLE KeyHandle, - __in_opt PWSTR ValueName + _In_ HANDLE KeyHandle, + _In_opt_ PWSTR ValueName ) { PPH_STRING string = NULL; @@ -3521,7 +3539,7 @@ PPH_STRING PhQueryRegistryString( ) { if (buffer->DataLength >= sizeof(WCHAR)) - string = PhCreateStringEx((PWSTR)buffer->Data, buffer->DataLength - sizeof(WCHAR)); + string = PhCreateStringEx((PWCHAR)buffer->Data, buffer->DataLength - sizeof(WCHAR)); else string = PhReferenceEmptyString(); } @@ -3533,10 +3551,10 @@ PPH_STRING PhQueryRegistryString( } VOID PhMapFlags1( - __inout PULONG Value2, - __in ULONG Value1, - __in const PH_FLAG_MAPPING *Mappings, - __in ULONG NumberOfMappings + _Inout_ PULONG Value2, + _In_ ULONG Value1, + _In_ const PH_FLAG_MAPPING *Mappings, + _In_ ULONG NumberOfMappings ) { ULONG i; @@ -3575,10 +3593,10 @@ VOID PhMapFlags1( } VOID PhMapFlags2( - __inout PULONG Value1, - __in ULONG Value2, - __in const PH_FLAG_MAPPING *Mappings, - __in ULONG NumberOfMappings + _Inout_ PULONG Value1, + _In_ ULONG Value2, + _In_ const PH_FLAG_MAPPING *Mappings, + _In_ ULONG NumberOfMappings ) { ULONG i; @@ -3609,10 +3627,10 @@ VOID PhMapFlags2( } UINT_PTR CALLBACK PhpOpenFileNameHookProc( - __in HWND hdlg, - __in UINT uiMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hdlg, + _In_ UINT uiMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uiMsg) @@ -3659,7 +3677,7 @@ UINT_PTR CALLBACK PhpOpenFileNameHookProc( } OPENFILENAME *PhpCreateOpenFileName( - __in ULONG Type + _In_ ULONG Type ) { OPENFILENAME *ofn; @@ -3681,7 +3699,7 @@ OPENFILENAME *PhpCreateOpenFileName( } VOID PhpFreeOpenFileName( - __in OPENFILENAME *OpenFileName + _In_ OPENFILENAME *OpenFileName ) { if (OpenFileName->lpstrFilter) PhFree((PVOID)OpenFileName->lpstrFilter); @@ -3782,7 +3800,7 @@ PVOID PhCreateSaveFileDialog( * \param FileDialog The file dialog. */ VOID PhFreeFileDialog( - __in PVOID FileDialog + _In_ PVOID FileDialog ) { if (PHP_USE_IFILEDIALOG) @@ -3806,8 +3824,8 @@ VOID PhFreeFileDialog( * occurred. */ BOOLEAN PhShowFileDialog( - __in HWND hWnd, - __in PVOID FileDialog + _In_ HWND hWnd, + _In_ PVOID FileDialog ) { if (PHP_USE_IFILEDIALOG) @@ -3870,7 +3888,7 @@ static const PH_FLAG_MAPPING PhpFileDialogOfnMappings[] = * documentation for PhSetFileDialogOptions() for details. */ ULONG PhGetFileDialogOptions( - __in PVOID FileDialog + _In_ PVOID FileDialog ) { if (PHP_USE_IFILEDIALOG) @@ -3938,8 +3956,8 @@ ULONG PhGetFileDialogOptions( * This is only valid for Save dialogs. */ VOID PhSetFileDialogOptions( - __in PVOID FileDialog, - __in ULONG Options + _In_ PVOID FileDialog, + _In_ ULONG Options ) { if (PHP_USE_IFILEDIALOG) @@ -3981,7 +3999,7 @@ VOID PhSetFileDialogOptions( * error occurred. */ ULONG PhGetFileDialogFilterIndex( - __in PVOID FileDialog + _In_ PVOID FileDialog ) { if (PHP_USE_IFILEDIALOG) @@ -4014,9 +4032,9 @@ ULONG PhGetFileDialogFilterIndex( * \param NumberOfFilters The number of file types. */ VOID PhSetFileDialogFilter( - __in PVOID FileDialog, - __in PPH_FILETYPE_FILTER Filters, - __in ULONG NumberOfFilters + _In_ PVOID FileDialog, + _In_ PPH_FILETYPE_FILTER Filters, + _In_ ULONG NumberOfFilters ) { if (PHP_USE_IFILEDIALOG) @@ -4065,7 +4083,7 @@ VOID PhSetFileDialogFilter( * it. */ PPH_STRING PhGetFileDialogFileName( - __in PVOID FileDialog + _In_ PVOID FileDialog ) { if (PHP_USE_IFILEDIALOG) @@ -4112,8 +4130,8 @@ PPH_STRING PhGetFileDialogFileName( * \param FileName The new file name. */ VOID PhSetFileDialogFileName( - __in PVOID FileDialog, - __in PWSTR FileName + _In_ PVOID FileDialog, + _In_ PWSTR FileName ) { if (PHP_USE_IFILEDIALOG) @@ -4184,10 +4202,10 @@ VOID PhSetFileDialogFileName( * that the image imports. */ NTSTATUS PhIsExecutablePacked( - __in PWSTR FileName, - __out PBOOLEAN IsPacked, - __out_opt PULONG NumberOfModules, - __out_opt PULONG NumberOfFunctions + _In_ PWSTR FileName, + _Out_ PBOOLEAN IsPacked, + _Out_opt_ PULONG NumberOfModules, + _Out_opt_ PULONG NumberOfFunctions ) { // An image is packed if: @@ -4350,8 +4368,8 @@ C_ASSERT(RTL_FIELD_SIZE(PH_HASH_CONTEXT, Context) >= sizeof(A_SHA_CTX)); * \li \c Crc32HashAlgorithm CRC-32-IEEE 802.3 (32 bits) */ VOID PhInitializeHash( - __out PPH_HASH_CONTEXT Context, - __in PH_HASH_ALGORITHM Algorithm + _Out_ PPH_HASH_CONTEXT Context, + _In_ PH_HASH_ALGORITHM Algorithm ) { Context->Algorithm = Algorithm; @@ -4381,9 +4399,9 @@ VOID PhInitializeHash( * \param Length The number of bytes in the block. */ VOID PhUpdateHash( - __inout PPH_HASH_CONTEXT Context, - __in_bcount(Length) PVOID Buffer, - __in ULONG Length + _Inout_ PPH_HASH_CONTEXT Context, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length ) { switch (Context->Algorithm) @@ -4412,10 +4430,10 @@ VOID PhUpdateHash( * the buffer, in bytes. */ BOOLEAN PhFinalHash( - __inout PPH_HASH_CONTEXT Context, - __out_bcount(HashLength) PVOID Hash, - __in ULONG HashLength, - __out_opt PULONG ReturnLength + _Inout_ PPH_HASH_CONTEXT Context, + _Out_writes_bytes_(HashLength) PVOID Hash, + _In_ ULONG HashLength, + _Out_opt_ PULONG ReturnLength ) { BOOLEAN result; @@ -4476,8 +4494,8 @@ BOOLEAN PhFinalHash( * index is updated to point to the end of the command line part. */ PPH_STRING PhParseCommandLinePart( - __in PPH_STRINGREF CommandLine, - __inout PULONG_PTR Index + _In_ PPH_STRINGREF CommandLine, + _Inout_ PULONG_PTR Index ) { PH_STRING_BUILDER stringBuilder; @@ -4585,12 +4603,12 @@ PPH_STRING PhParseCommandLinePart( * \param Context A user-defined value to pass to \a Callback. */ BOOLEAN PhParseCommandLine( - __in PPH_STRINGREF CommandLine, - __in_opt PPH_COMMAND_LINE_OPTION Options, - __in ULONG NumberOfOptions, - __in ULONG Flags, - __in PPH_COMMAND_LINE_CALLBACK Callback, - __in_opt PVOID Context + _In_ PPH_STRINGREF CommandLine, + _In_opt_ PPH_COMMAND_LINE_OPTION Options, + _In_ ULONG NumberOfOptions, + _In_ ULONG Flags, + _In_ PPH_COMMAND_LINE_CALLBACK Callback, + _In_opt_ PVOID Context ) { SIZE_T i; @@ -4723,7 +4741,7 @@ BOOLEAN PhParseCommandLine( * \remarks Only the double quotation mark is escaped. */ PPH_STRING PhEscapeCommandLinePart( - __in PPH_STRINGREF String + _In_ PPH_STRINGREF String ) { static WCHAR backslashAndQuote[2] = { '\\', '\"' }; @@ -4775,7 +4793,7 @@ PPH_STRING PhEscapeCommandLinePart( } VOID PhpSkipWhitespaceStringRef( - __inout PPH_STRINGREF String + _Inout_ PPH_STRINGREF String ) { WCHAR c; @@ -4793,9 +4811,9 @@ VOID PhpSkipWhitespaceStringRef( } BOOLEAN PhpSearchFilePath( - __in PWSTR FileName, - __in_opt PWSTR Extension, - __out_ecount(MAX_PATH) PWSTR Buffer + _In_ PWSTR FileName, + _In_opt_ PWSTR Extension, + _Out_writes_(MAX_PATH) PWSTR Buffer ) { NTSTATUS status; @@ -4859,10 +4877,10 @@ BOOLEAN PhpSearchFilePath( * and file name. This may be NULL if the file was not found. */ BOOLEAN PhParseCommandLineFuzzy( - __in PPH_STRINGREF CommandLine, - __out PPH_STRINGREF FileName, - __out PPH_STRINGREF Arguments, - __out_opt PPH_STRING *FullFileName + _In_ PPH_STRINGREF CommandLine, + _Out_ PPH_STRINGREF FileName, + _Out_ PPH_STRINGREF Arguments, + _Out_opt_ PPH_STRING *FullFileName ) { PH_STRINGREF commandLine; diff --git a/2.x/trunk/phlib/svcsup.c b/2.x/trunk/phlib/svcsup.c index abba2f7f6..5a9b9c986 100644 --- a/2.x/trunk/phlib/svcsup.c +++ b/2.x/trunk/phlib/svcsup.c @@ -70,10 +70,10 @@ WCHAR *PhServiceStartTypeStrings[5] = { L"Disabled", L"Boot Start", L"System Sta WCHAR *PhServiceErrorControlStrings[4] = { L"Ignore", L"Normal", L"Severe", L"Critical" }; PVOID PhEnumServices( - __in SC_HANDLE ScManagerHandle, - __in_opt ULONG Type, - __in_opt ULONG State, - __out PULONG Count + _In_ SC_HANDLE ScManagerHandle, + _In_opt_ ULONG Type, + _In_opt_ ULONG State, + _Out_ PULONG Count ) { static ULONG initialBufferSize = 0x8000; @@ -138,8 +138,8 @@ PVOID PhEnumServices( } SC_HANDLE PhOpenService( - __in PWSTR ServiceName, - __in ACCESS_MASK DesiredAccess + _In_ PWSTR ServiceName, + _In_ ACCESS_MASK DesiredAccess ) { SC_HANDLE scManagerHandle; @@ -157,7 +157,7 @@ SC_HANDLE PhOpenService( } PVOID PhGetServiceConfig( - __in SC_HANDLE ServiceHandle + _In_ SC_HANDLE ServiceHandle ) { PVOID buffer; @@ -181,8 +181,8 @@ PVOID PhGetServiceConfig( } PVOID PhQueryServiceVariableSize( - __in SC_HANDLE ServiceHandle, - __in ULONG InfoLevel + _In_ SC_HANDLE ServiceHandle, + _In_ ULONG InfoLevel ) { PVOID buffer; @@ -218,7 +218,7 @@ PVOID PhQueryServiceVariableSize( } PPH_STRING PhGetServiceDescription( - __in SC_HANDLE ServiceHandle + _In_ SC_HANDLE ServiceHandle ) { PPH_STRING description = NULL; @@ -242,8 +242,8 @@ PPH_STRING PhGetServiceDescription( } BOOLEAN PhGetServiceDelayedAutoStart( - __in SC_HANDLE ServiceHandle, - __out PBOOLEAN DelayedAutoStart + _In_ SC_HANDLE ServiceHandle, + _Out_ PBOOLEAN DelayedAutoStart ) { SERVICE_DELAYED_AUTO_START_INFO delayedAutoStartInfo; @@ -267,8 +267,8 @@ BOOLEAN PhGetServiceDelayedAutoStart( } BOOLEAN PhSetServiceDelayedAutoStart( - __in SC_HANDLE ServiceHandle, - __in BOOLEAN DelayedAutoStart + _In_ SC_HANDLE ServiceHandle, + _In_ BOOLEAN DelayedAutoStart ) { SERVICE_DELAYED_AUTO_START_INFO delayedAutoStartInfo; @@ -283,7 +283,7 @@ BOOLEAN PhSetServiceDelayedAutoStart( } PWSTR PhGetServiceStateString( - __in ULONG ServiceState + _In_ ULONG ServiceState ) { PWSTR string; @@ -300,7 +300,7 @@ PWSTR PhGetServiceStateString( } PWSTR PhGetServiceTypeString( - __in ULONG ServiceType + _In_ ULONG ServiceType ) { PWSTR string; @@ -317,7 +317,7 @@ PWSTR PhGetServiceTypeString( } ULONG PhGetServiceTypeInteger( - __in PWSTR ServiceType + _In_ PWSTR ServiceType ) { ULONG integer; @@ -334,7 +334,7 @@ ULONG PhGetServiceTypeInteger( } PWSTR PhGetServiceStartTypeString( - __in ULONG ServiceStartType + _In_ ULONG ServiceStartType ) { PWSTR string; @@ -351,7 +351,7 @@ PWSTR PhGetServiceStartTypeString( } ULONG PhGetServiceStartTypeInteger( - __in PWSTR ServiceStartType + _In_ PWSTR ServiceStartType ) { ULONG integer; @@ -368,7 +368,7 @@ ULONG PhGetServiceStartTypeInteger( } PWSTR PhGetServiceErrorControlString( - __in ULONG ServiceErrorControl + _In_ ULONG ServiceErrorControl ) { PWSTR string; @@ -385,7 +385,7 @@ PWSTR PhGetServiceErrorControlString( } ULONG PhGetServiceErrorControlInteger( - __in PWSTR ServiceErrorControl + _In_ PWSTR ServiceErrorControl ) { ULONG integer; @@ -402,8 +402,8 @@ ULONG PhGetServiceErrorControlInteger( } PPH_STRING PhGetServiceNameFromTag( - __in HANDLE ProcessId, - __in PVOID ServiceTag + _In_ HANDLE ProcessId, + _In_ PVOID ServiceTag ) { static PQUERY_TAG_INFORMATION I_QueryTagInformation = NULL; @@ -434,9 +434,9 @@ PPH_STRING PhGetServiceNameFromTag( } NTSTATUS PhGetThreadServiceTag( - __in HANDLE ThreadHandle, - __in_opt HANDLE ProcessHandle, - __out PVOID *ServiceTag + _In_ HANDLE ThreadHandle, + _In_opt_ HANDLE ProcessHandle, + _Out_ PVOID *ServiceTag ) { NTSTATUS status; diff --git a/2.x/trunk/phlib/symprv.c b/2.x/trunk/phlib/symprv.c index 05e2ac31d..350cbb2fb 100644 --- a/2.x/trunk/phlib/symprv.c +++ b/2.x/trunk/phlib/symprv.c @@ -2,7 +2,7 @@ * Process Hacker - * symbol provider * - * Copyright (C) 2010-2012 wj32 + * Copyright (C) 2010-2013 wj32 * * This file is part of Process Hacker. * @@ -34,27 +34,28 @@ typedef struct _PH_SYMBOL_MODULE } PH_SYMBOL_MODULE, *PPH_SYMBOL_MODULE; VOID NTAPI PhpSymbolProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); VOID PhpRegisterSymbolProvider( - __in_opt PPH_SYMBOL_PROVIDER SymbolProvider + _In_opt_ PPH_SYMBOL_PROVIDER SymbolProvider ); VOID PhpFreeSymbolModule( - __in PPH_SYMBOL_MODULE SymbolModule + _In_ PPH_SYMBOL_MODULE SymbolModule ); LONG NTAPI PhpSymbolModuleCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ); PPH_OBJECT_TYPE PhSymbolProviderType; static PH_INITONCE PhSymInitOnce = PH_INITONCE_INIT; DECLSPEC_SELECTANY PH_CALLBACK_DECLARE(PhSymInitCallback); +PVOID PhSymPreferredDbgHelpBase; static HANDLE PhNextFakeHandle = (HANDLE)0; static PH_FAST_LOCK PhSymMutex = PH_FAST_LOCK_INIT; @@ -82,6 +83,7 @@ _SymSetSearchPathW SymSetSearchPathW_I; _SymUnloadModule64 SymUnloadModule64_I; _SymFunctionTableAccess64 SymFunctionTableAccess64_I; _SymGetModuleBase64 SymGetModuleBase64_I; +_SymRegisterCallbackW64 SymRegisterCallbackW64_I; _StackWalk64 StackWalk64_I; _MiniDumpWriteDump MiniDumpWriteDump_I; _SymbolServerGetOptions SymbolServerGetOptions; @@ -115,7 +117,11 @@ VOID PhSymbolProviderDynamicImport( HMODULE dbghelpHandle; HMODULE symsrvHandle; - dbghelpHandle = GetModuleHandle(L"dbghelp.dll"); + if (PhSymPreferredDbgHelpBase) + dbghelpHandle = PhSymPreferredDbgHelpBase; + else + dbghelpHandle = GetModuleHandle(L"dbghelp.dll"); + symsrvHandle = GetModuleHandle(L"symsrv.dll"); SymInitialize_I = (PVOID)GetProcAddress(dbghelpHandle, "SymInitialize"); @@ -138,6 +144,7 @@ VOID PhSymbolProviderDynamicImport( SymUnloadModule64_I = (PVOID)GetProcAddress(dbghelpHandle, "SymUnloadModule64"); SymFunctionTableAccess64_I = (PVOID)GetProcAddress(dbghelpHandle, "SymFunctionTableAccess64"); SymGetModuleBase64_I = (PVOID)GetProcAddress(dbghelpHandle, "SymGetModuleBase64"); + SymRegisterCallbackW64_I = (PVOID)GetProcAddress(dbghelpHandle, "SymRegisterCallbackW64"); StackWalk64_I = (PVOID)GetProcAddress(dbghelpHandle, "StackWalk64"); MiniDumpWriteDump_I = (PVOID)GetProcAddress(dbghelpHandle, "MiniDumpWriteDump"); SymbolServerGetOptions = (PVOID)GetProcAddress(symsrvHandle, "SymbolServerGetOptions"); @@ -148,7 +155,7 @@ VOID PhSymbolProviderDynamicImport( } PPH_SYMBOL_PROVIDER PhCreateSymbolProvider( - __in_opt HANDLE ProcessId + _In_opt_ HANDLE ProcessId ) { PPH_SYMBOL_PROVIDER symbolProvider; @@ -164,6 +171,7 @@ PPH_SYMBOL_PROVIDER PhCreateSymbolProvider( InitializeListHead(&symbolProvider->ModulesListHead); PhInitializeQueuedLock(&symbolProvider->ModulesListLock); PhInitializeAvlTree(&symbolProvider->ModulesSet, PhpSymbolModuleCompareFunction); + PhInitializeCallback(&symbolProvider->EventCallback); if (ProcessId) { @@ -223,13 +231,15 @@ PPH_SYMBOL_PROVIDER PhCreateSymbolProvider( } VOID NTAPI PhpSymbolProviderDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PPH_SYMBOL_PROVIDER symbolProvider = (PPH_SYMBOL_PROVIDER)Object; PLIST_ENTRY listEntry; + PhDeleteCallback(&symbolProvider->EventCallback); + if (SymCleanup_I) { PH_LOCK_SYMBOLS(); @@ -255,8 +265,65 @@ VOID NTAPI PhpSymbolProviderDeleteProcedure( if (symbolProvider->IsRealHandle) NtClose(symbolProvider->ProcessHandle); } +NTSTATUS PhpSymbolCallbackWorker( + _In_ PVOID Parameter + ) +{ + PPH_SYMBOL_EVENT_DATA data = Parameter; + + dprintf("symbol event %d: %S\n", data->Type, data->FileName->Buffer); + PhInvokeCallback(&data->SymbolProvider->EventCallback, data); + PhSwapReference(&data->FileName, NULL); + PhDereferenceObject(data); + + return STATUS_SUCCESS; +} + +BOOL CALLBACK PhpSymbolCallbackFunction( + _In_ HANDLE hProcess, + _In_ ULONG ActionCode, + _In_opt_ ULONG64 CallbackData, + _In_opt_ ULONG64 UserContext + ) +{ + PPH_SYMBOL_PROVIDER symbolProvider = (PPH_SYMBOL_PROVIDER)UserContext; + PPH_SYMBOL_EVENT_DATA data; + PIMAGEHLP_DEFERRED_SYMBOL_LOADW64 callbackData; + + if (!IsListEmpty(&symbolProvider->EventCallback.ListHead)) + { + switch (ActionCode) + { + case SymbolDeferredSymbolLoadStart: + case SymbolDeferredSymbolLoadComplete: + case SymbolDeferredSymbolLoadFailure: + case SymbolSymbolsUnloaded: + case SymbolDeferredSymbolLoadCancel: + PhCreateAlloc((PVOID *)&data, sizeof(PH_SYMBOL_EVENT_DATA)); + memset(data, 0, sizeof(PH_SYMBOL_EVENT_DATA)); + data->SymbolProvider = symbolProvider; + data->Type = ActionCode; + + if (ActionCode != SymbolSymbolsUnloaded) + { + callbackData = (PIMAGEHLP_DEFERRED_SYMBOL_LOADW64)CallbackData; + data->BaseAddress = callbackData->BaseOfImage; + data->CheckSum = callbackData->CheckSum; + data->TimeStamp = callbackData->TimeDateStamp; + data->FileName = PhCreateString(callbackData->FileName); + } + + PhQueueItemGlobalWorkQueue(PhpSymbolCallbackWorker, data); + + break; + } + } + + return FALSE; +} + VOID PhpRegisterSymbolProvider( - __in_opt PPH_SYMBOL_PROVIDER SymbolProvider + _In_opt_ PPH_SYMBOL_PROVIDER SymbolProvider ) { if (PhBeginInitOnce(&PhSymInitOnce)) @@ -276,6 +343,10 @@ VOID PhpRegisterSymbolProvider( { PH_LOCK_SYMBOLS(); SymInitialize_I(SymbolProvider->ProcessHandle, NULL, FALSE); + + if (SymRegisterCallbackW64_I) + SymRegisterCallbackW64_I(SymbolProvider->ProcessHandle, PhpSymbolCallbackFunction, (ULONG64)SymbolProvider); + PH_UNLOCK_SYMBOLS(); SymbolProvider->IsRegistered = TRUE; @@ -288,7 +359,7 @@ VOID PhpRegisterSymbolProvider( } VOID PhpFreeSymbolModule( - __in PPH_SYMBOL_MODULE SymbolModule + _In_ PPH_SYMBOL_MODULE SymbolModule ) { if (SymbolModule->FileName) PhDereferenceObject(SymbolModule->FileName); @@ -297,8 +368,8 @@ VOID PhpFreeSymbolModule( } static LONG NTAPI PhpSymbolModuleCompareFunction( - __in PPH_AVL_LINKS Links1, - __in PPH_AVL_LINKS Links2 + _In_ PPH_AVL_LINKS Links1, + _In_ PPH_AVL_LINKS Links2 ) { PPH_SYMBOL_MODULE symbolModule1 = CONTAINING_RECORD(Links1, PH_SYMBOL_MODULE, Links); @@ -308,11 +379,11 @@ static LONG NTAPI PhpSymbolModuleCompareFunction( } BOOLEAN PhGetLineFromAddress( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in ULONG64 Address, - __out PPH_STRING *FileName, - __out_opt PULONG Displacement, - __out_opt PPH_SYMBOL_LINE_INFORMATION Information + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ ULONG64 Address, + _Out_ PPH_STRING *FileName, + _Out_opt_ PULONG Displacement, + _Out_opt_ PPH_SYMBOL_LINE_INFORMATION Information ) { IMAGEHLP_LINEW64 line; @@ -384,9 +455,9 @@ BOOLEAN PhGetLineFromAddress( } ULONG64 PhGetModuleFromAddress( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in ULONG64 Address, - __out_opt PPH_STRING *FileName + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ ULONG64 Address, + _Out_opt_ PPH_STRING *FileName ) { PH_SYMBOL_MODULE lookupModule; @@ -463,8 +534,8 @@ ULONG64 PhGetModuleFromAddress( } VOID PhpSymbolInfoAnsiToUnicode( - __out PSYMBOL_INFOW SymbolInfoW, - __in PSYMBOL_INFO SymbolInfoA + _Out_ PSYMBOL_INFOW SymbolInfoW, + _In_ PSYMBOL_INFO SymbolInfoA ) { SymbolInfoW->TypeIndex = SymbolInfoA->TypeIndex; @@ -499,16 +570,16 @@ VOID PhpSymbolInfoAnsiToUnicode( } PPH_STRING PhGetSymbolFromAddress( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in ULONG64 Address, - __out_opt PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel, - __out_opt PPH_STRING *FileName, - __out_opt PPH_STRING *SymbolName, - __out_opt PULONG64 Displacement + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ ULONG64 Address, + _Out_opt_ PPH_SYMBOL_RESOLVE_LEVEL ResolveLevel, + _Out_opt_ PPH_STRING *FileName, + _Out_opt_ PPH_STRING *SymbolName, + _Out_opt_ PULONG64 Displacement ) { PSYMBOL_INFOW symbolInfo; - UCHAR symbolInfoBuffer[FIELD_OFFSET(SYMBOL_INFOW, Name) + PH_MAX_SYMBOL_NAME_LEN * 2]; + ULONG nameLength; PPH_STRING symbol = NULL; PH_SYMBOL_RESOLVE_LEVEL resolveLevel; ULONG64 displacement; @@ -534,10 +605,10 @@ PPH_STRING PhGetSymbolFromAddress( PhpRegisterSymbolProvider(SymbolProvider); #endif - symbolInfo = (PSYMBOL_INFOW)symbolInfoBuffer; + symbolInfo = PhAllocate(FIELD_OFFSET(SYMBOL_INFOW, Name) + PH_MAX_SYMBOL_NAME_LEN * 2); memset(symbolInfo, 0, sizeof(SYMBOL_INFOW)); symbolInfo->SizeOfStruct = sizeof(SYMBOL_INFOW); - symbolInfo->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN - 1; + symbolInfo->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN; // Get the symbol name. @@ -557,16 +628,32 @@ PPH_STRING PhGetSymbolFromAddress( &displacement, symbolInfo ); + nameLength = symbolInfo->NameLen; + + if (nameLength + 1 > PH_MAX_SYMBOL_NAME_LEN) + { + PhFree(symbolInfo); + symbolInfo = PhAllocate(FIELD_OFFSET(SYMBOL_INFOW, Name) + nameLength * 2 + 2); + memset(symbolInfo, 0, sizeof(SYMBOL_INFOW)); + symbolInfo->SizeOfStruct = sizeof(SYMBOL_INFOW); + symbolInfo->MaxNameLen = nameLength + 1; + + SymFromAddrW_I( + SymbolProvider->ProcessHandle, + Address, + &displacement, + symbolInfo + ); + } } else if (SymFromAddr_I) { - UCHAR buffer[FIELD_OFFSET(SYMBOL_INFO, Name) + PH_MAX_SYMBOL_NAME_LEN]; PSYMBOL_INFO symbolInfoA; - symbolInfoA = (PSYMBOL_INFO)buffer; + symbolInfoA = PhAllocate(FIELD_OFFSET(SYMBOL_INFO, Name) + PH_MAX_SYMBOL_NAME_LEN); memset(symbolInfoA, 0, sizeof(SYMBOL_INFO)); symbolInfoA->SizeOfStruct = sizeof(SYMBOL_INFO); - symbolInfoA->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN - 1; + symbolInfoA->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN; SymFromAddr_I( SymbolProvider->ProcessHandle, @@ -574,7 +661,33 @@ PPH_STRING PhGetSymbolFromAddress( &displacement, symbolInfoA ); + nameLength = symbolInfoA->NameLen; + + if (nameLength + 1 > PH_MAX_SYMBOL_NAME_LEN) + { + PhFree(symbolInfoA); + symbolInfoA = PhAllocate(FIELD_OFFSET(SYMBOL_INFO, Name) + nameLength + 1); + memset(symbolInfoA, 0, sizeof(SYMBOL_INFO)); + symbolInfoA->SizeOfStruct = sizeof(SYMBOL_INFO); + symbolInfoA->MaxNameLen = nameLength + 1; + + SymFromAddr_I( + SymbolProvider->ProcessHandle, + Address, + &displacement, + symbolInfoA + ); + + // Also reallocate the Unicode-based buffer. + PhFree(symbolInfo); + symbolInfo = PhAllocate(FIELD_OFFSET(SYMBOL_INFOW, Name) + nameLength * 2 + 2); + memset(symbolInfo, 0, sizeof(SYMBOL_INFOW)); + symbolInfo->SizeOfStruct = sizeof(SYMBOL_INFOW); + symbolInfo->MaxNameLen = nameLength + 1; + } + PhpSymbolInfoAnsiToUnicode(symbolInfo, symbolInfoA); + PhFree(symbolInfoA); } PH_UNLOCK_SYMBOLS(); @@ -702,13 +815,15 @@ PPH_STRING PhGetSymbolFromAddress( if (symbolName) PhDereferenceObject(symbolName); + PhFree(symbolInfo); + return symbol; } BOOLEAN PhGetSymbolFromName( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in PWSTR Name, - __out PPH_SYMBOL_INFORMATION Information + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ PWSTR Name, + _Out_ PPH_SYMBOL_INFORMATION Information ) { PSYMBOL_INFOW symbolInfo; @@ -725,7 +840,7 @@ BOOLEAN PhGetSymbolFromName( symbolInfo = (PSYMBOL_INFOW)symbolInfoBuffer; memset(symbolInfo, 0, sizeof(SYMBOL_INFOW)); symbolInfo->SizeOfStruct = sizeof(SYMBOL_INFOW); - symbolInfo->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN - 1; + symbolInfo->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN; // Get the symbol information. @@ -748,7 +863,7 @@ BOOLEAN PhGetSymbolFromName( symbolInfoA = (PSYMBOL_INFO)buffer; memset(symbolInfoA, 0, sizeof(SYMBOL_INFO)); symbolInfoA->SizeOfStruct = sizeof(SYMBOL_INFO); - symbolInfoA->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN - 1; + symbolInfoA->MaxNameLen = PH_MAX_SYMBOL_NAME_LEN; name = PhCreateAnsiStringFromUnicode(Name); @@ -782,10 +897,10 @@ BOOLEAN PhGetSymbolFromName( } BOOLEAN PhLoadModuleSymbolProvider( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in PWSTR FileName, - __in ULONG64 BaseAddress, - __in ULONG Size + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ PWSTR FileName, + _In_ ULONG64 BaseAddress, + _In_ ULONG Size ) { PPH_ANSI_STRING fileName; @@ -856,8 +971,8 @@ BOOLEAN PhLoadModuleSymbolProvider( } VOID PhSetOptionsSymbolProvider( - __in ULONG Mask, - __in ULONG Value + _In_ ULONG Mask, + _In_ ULONG Value ) { ULONG options; @@ -880,8 +995,8 @@ VOID PhSetOptionsSymbolProvider( } VOID PhSetSearchPathSymbolProvider( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in PWSTR Path + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ PWSTR Path ) { if (!SymSetSearchPathW_I && !SymSetSearchPath_I) @@ -912,13 +1027,13 @@ VOID PhSetSearchPathSymbolProvider( #ifdef _M_X64 NTSTATUS PhpLookupDynamicFunctionTable( - __in HANDLE ProcessHandle, - __in ULONG64 Address, - __out_opt PDYNAMIC_FUNCTION_TABLE *FunctionTableAddress, - __out_opt PDYNAMIC_FUNCTION_TABLE FunctionTable, - __out_bcount_opt(OutOfProcessCallbackDllBufferSize) PWCHAR OutOfProcessCallbackDllBuffer, - __in ULONG OutOfProcessCallbackDllBufferSize, - __out_opt PUNICODE_STRING OutOfProcessCallbackDllString + _In_ HANDLE ProcessHandle, + _In_ ULONG64 Address, + _Out_opt_ PDYNAMIC_FUNCTION_TABLE *FunctionTableAddress, + _Out_opt_ PDYNAMIC_FUNCTION_TABLE FunctionTable, + _Out_writes_bytes_opt_(OutOfProcessCallbackDllBufferSize) PWCHAR OutOfProcessCallbackDllBuffer, + _In_ ULONG OutOfProcessCallbackDllBufferSize, + _Out_opt_ PUNICODE_STRING OutOfProcessCallbackDllString ) { NTSTATUS status; @@ -1042,10 +1157,10 @@ NTSTATUS PhpLookupDynamicFunctionTable( } PRUNTIME_FUNCTION PhpLookupFunctionEntry( - __in PRUNTIME_FUNCTION Functions, - __in ULONG NumberOfFunctions, - __in BOOLEAN Sorted, - __in ULONG64 RelativeControlPc + _In_ PRUNTIME_FUNCTION Functions, + _In_ ULONG NumberOfFunctions, + _In_ BOOLEAN Sorted, + _In_ ULONG64 RelativeControlPc ) { LONG low; @@ -1085,11 +1200,11 @@ PRUNTIME_FUNCTION PhpLookupFunctionEntry( } NTSTATUS PhpAccessCallbackFunctionTable( - __in HANDLE ProcessHandle, - __in PVOID FunctionTableAddress, - __in PUNICODE_STRING OutOfProcessCallbackDllString, - __out PRUNTIME_FUNCTION *Functions, - __out PULONG NumberOfFunctions + _In_ HANDLE ProcessHandle, + _In_ PVOID FunctionTableAddress, + _In_ PUNICODE_STRING OutOfProcessCallbackDllString, + _Out_ PRUNTIME_FUNCTION *Functions, + _Out_ PULONG NumberOfFunctions ) { static PH_STRINGREF knownFunctionTableDllsKeyName = PH_STRINGREF_INIT(L"Software\\Microsoft\\Windows NT\\CurrentVersion\\KnownFunctionTableDlls"); @@ -1145,10 +1260,10 @@ NTSTATUS PhpAccessCallbackFunctionTable( } NTSTATUS PhpAccessNormalFunctionTable( - __in HANDLE ProcessHandle, - __in PDYNAMIC_FUNCTION_TABLE FunctionTable, - __out PRUNTIME_FUNCTION *Functions, - __out PULONG NumberOfFunctions + _In_ HANDLE ProcessHandle, + _In_ PDYNAMIC_FUNCTION_TABLE FunctionTable, + _Out_ PRUNTIME_FUNCTION *Functions, + _Out_ PULONG NumberOfFunctions ) { NTSTATUS status; @@ -1181,9 +1296,9 @@ NTSTATUS PhpAccessNormalFunctionTable( } NTSTATUS PhAccessOutOfProcessFunctionEntry( - __in HANDLE ProcessHandle, - __in ULONG64 ControlPc, - __out PRUNTIME_FUNCTION Function + _In_ HANDLE ProcessHandle, + _In_ ULONG64 ControlPc, + _Out_ PRUNTIME_FUNCTION Function ) { NTSTATUS status; @@ -1258,8 +1373,8 @@ NTSTATUS PhAccessOutOfProcessFunctionEntry( #endif ULONG64 __stdcall PhGetModuleBase64( - __in HANDLE hProcess, - __in DWORD64 dwAddr + _In_ HANDLE hProcess, + _In_ DWORD64 dwAddr ) { ULONG64 base; @@ -1295,8 +1410,8 @@ ULONG64 __stdcall PhGetModuleBase64( } PVOID __stdcall PhFunctionTableAccess64( - __in HANDLE hProcess, - __in DWORD64 AddrBase + _In_ HANDLE hProcess, + _In_ DWORD64 AddrBase ) { #ifdef _M_X64 @@ -1321,15 +1436,15 @@ PVOID __stdcall PhFunctionTableAccess64( } BOOLEAN PhStackWalk( - __in ULONG MachineType, - __in HANDLE ProcessHandle, - __in HANDLE ThreadHandle, - __inout STACKFRAME64 *StackFrame, - __inout PVOID ContextRecord, - __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, - __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, - __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, - __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress + _In_ ULONG MachineType, + _In_ HANDLE ProcessHandle, + _In_ HANDLE ThreadHandle, + _Inout_ STACKFRAME64 *StackFrame, + _Inout_ PVOID ContextRecord, + _In_opt_ PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, + _In_opt_ PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, + _In_opt_ PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, + _In_opt_ PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress ) { BOOLEAN result; @@ -1373,13 +1488,13 @@ BOOLEAN PhStackWalk( } BOOLEAN PhWriteMiniDumpProcess( - __in HANDLE ProcessHandle, - __in HANDLE ProcessId, - __in HANDLE FileHandle, - __in MINIDUMP_TYPE DumpType, - __in_opt PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, - __in_opt PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, - __in_opt PMINIDUMP_CALLBACK_INFORMATION CallbackParam + _In_ HANDLE ProcessHandle, + _In_ HANDLE ProcessId, + _In_ HANDLE FileHandle, + _In_ MINIDUMP_TYPE DumpType, + _In_opt_ PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, + _In_opt_ PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, + _In_opt_ PMINIDUMP_CALLBACK_INFORMATION CallbackParam ) { PhpRegisterSymbolProvider(NULL); diff --git a/2.x/trunk/phlib/sync.c b/2.x/trunk/phlib/sync.c index dd71a7b5e..461400f69 100644 --- a/2.x/trunk/phlib/sync.c +++ b/2.x/trunk/phlib/sync.c @@ -56,7 +56,7 @@ * \param Event A pointer to an event object. */ VOID FASTCALL PhfInitializeEvent( - __out PPH_EVENT Event + _Out_ PPH_EVENT Event ) { Event->Value = PH_EVENT_REFCOUNT_INC; @@ -70,8 +70,8 @@ VOID FASTCALL PhfInitializeEvent( * \param EventHandle The current value of the event object. */ FORCEINLINE VOID PhpDereferenceEvent( - __inout PPH_EVENT Event, - __in_opt HANDLE EventHandle + _Inout_ PPH_EVENT Event, + _In_opt_ HANDLE EventHandle ) { ULONG_PTR value; @@ -95,7 +95,7 @@ FORCEINLINE VOID PhpDereferenceEvent( * \param Event A pointer to an event object. */ FORCEINLINE VOID PhpReferenceEvent( - __inout PPH_EVENT Event + _Inout_ PPH_EVENT Event ) { _InterlockedExchangeAddPointer((PLONG_PTR)&Event->Value, PH_EVENT_REFCOUNT_INC); @@ -108,7 +108,7 @@ FORCEINLINE VOID PhpReferenceEvent( * \param Event A pointer to an event object. */ VOID FASTCALL PhfSetEvent( - __inout PPH_EVENT Event + _Inout_ PPH_EVENT Event ) { HANDLE eventHandle; @@ -140,8 +140,8 @@ VOID FASTCALL PhfSetEvent( * of using a timeout of zero. */ BOOLEAN FASTCALL PhfWaitForEvent( - __inout PPH_EVENT Event, - __in_opt PLARGE_INTEGER Timeout + _Inout_ PPH_EVENT Event, + _In_opt_ PLARGE_INTEGER Timeout ) { BOOLEAN result; @@ -208,7 +208,7 @@ BOOLEAN FASTCALL PhfWaitForEvent( * event when you call this function. */ VOID FASTCALL PhfResetEvent( - __inout PPH_EVENT Event + _Inout_ PPH_EVENT Event ) { assert(!Event->EventHandle); @@ -218,8 +218,8 @@ VOID FASTCALL PhfResetEvent( } VOID FASTCALL PhfInitializeBarrier( - __out PPH_BARRIER Barrier, - __in ULONG_PTR Target + _Out_ PPH_BARRIER Barrier, + _In_ ULONG_PTR Target ) { Barrier->Value = Target << PH_BARRIER_TARGET_SHIFT; @@ -227,9 +227,9 @@ VOID FASTCALL PhfInitializeBarrier( } FORCEINLINE VOID PhpBlockOnBarrier( - __inout PPH_BARRIER Barrier, - __in ULONG Role, - __in BOOLEAN Spin + _Inout_ PPH_BARRIER Barrier, + _In_ ULONG Role, + _In_ BOOLEAN Spin ) { PH_QUEUED_WAIT_BLOCK waitBlock; @@ -279,8 +279,8 @@ FORCEINLINE VOID PhpBlockOnBarrier( * example, involve merging the results of calculations. */ BOOLEAN FASTCALL PhfWaitForBarrier( - __inout PPH_BARRIER Barrier, - __in BOOLEAN Spin + _Inout_ PPH_BARRIER Barrier, + _In_ BOOLEAN Spin ) { ULONG_PTR value; @@ -364,14 +364,14 @@ BOOLEAN FASTCALL PhfWaitForBarrier( } VOID FASTCALL PhfInitializeRundownProtection( - __out PPH_RUNDOWN_PROTECT Protection + _Out_ PPH_RUNDOWN_PROTECT Protection ) { Protection->Value = 0; } BOOLEAN FASTCALL PhfAcquireRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ) { ULONG_PTR value; @@ -396,7 +396,7 @@ BOOLEAN FASTCALL PhfAcquireRundownProtection( } VOID FASTCALL PhfReleaseRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ) { ULONG_PTR value; @@ -437,7 +437,7 @@ VOID FASTCALL PhfReleaseRundownProtection( } VOID FASTCALL PhfWaitForRundownProtection( - __inout PPH_RUNDOWN_PROTECT Protection + _Inout_ PPH_RUNDOWN_PROTECT Protection ) { ULONG_PTR value; @@ -488,7 +488,7 @@ VOID FASTCALL PhfWaitForRundownProtection( } VOID FASTCALL PhfInitializeInitOnce( - __out PPH_INITONCE InitOnce + _Out_ PPH_INITONCE InitOnce ) { InitOnce->State = PH_INITONCE_UNINITIALIZED; @@ -496,7 +496,7 @@ VOID FASTCALL PhfInitializeInitOnce( } BOOLEAN FASTCALL PhfBeginInitOnce( - __inout PPH_INITONCE InitOnce + _Inout_ PPH_INITONCE InitOnce ) { LONG oldState; @@ -523,7 +523,7 @@ BOOLEAN FASTCALL PhfBeginInitOnce( } VOID FASTCALL PhfEndInitOnce( - __inout PPH_INITONCE InitOnce + _Inout_ PPH_INITONCE InitOnce ) { InitOnce->State = PH_INITONCE_INITIALIZED; diff --git a/2.x/trunk/phlib/treenew.c b/2.x/trunk/phlib/treenew.c index 12059df82..684e2faa1 100644 --- a/2.x/trunk/phlib/treenew.c +++ b/2.x/trunk/phlib/treenew.c @@ -83,10 +83,10 @@ BOOLEAN PhTreeNewInitialization( } LRESULT CALLBACK PhTnpWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPH_TREENEW_CONTEXT context; @@ -308,18 +308,18 @@ LRESULT CALLBACK PhTnpWndProc( } BOOLEAN NTAPI PhTnpNullCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { return FALSE; } VOID PhTnpCreateTreeNewContext( - __out PPH_TREENEW_CONTEXT *Context + _Out_ PPH_TREENEW_CONTEXT *Context ) { PPH_TREENEW_CONTEXT context; @@ -341,7 +341,7 @@ VOID PhTnpCreateTreeNewContext( } VOID PhTnpDestroyTreeNewContext( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { ULONG i; @@ -384,9 +384,9 @@ VOID PhTnpDestroyTreeNewContext( } BOOLEAN PhTnpOnCreate( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in CREATESTRUCT *CreateStruct + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ CREATESTRUCT *CreateStruct ) { ULONG headerStyle; @@ -502,8 +502,8 @@ BOOLEAN PhTnpOnCreate( } VOID PhTnpOnSize( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ) { GetClientRect(hwnd, &Context->ClientRect); @@ -532,10 +532,10 @@ VOID PhTnpOnSize( } VOID PhTnpOnSetFont( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in_opt HFONT Font, - __in LOGICAL Redraw + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ HFONT Font, + _In_ LOGICAL Redraw ) { PhTnpSetFont(Context, Font, !!Redraw); @@ -543,10 +543,10 @@ VOID PhTnpOnSetFont( } VOID PhTnpOnStyleChanged( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG Type, - __in STYLESTRUCT *StyleStruct + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Type, + _In_ STYLESTRUCT *StyleStruct ) { if (Type == GWL_EXSTYLE) @@ -554,8 +554,8 @@ VOID PhTnpOnStyleChanged( } VOID PhTnpOnSettingChange( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ) { PhTnpUpdateSystemMetrics(Context); @@ -564,18 +564,18 @@ VOID PhTnpOnSettingChange( } VOID PhTnpOnThemeChanged( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ) { PhTnpUpdateThemeData(Context); } ULONG PhTnpOnGetDlgCode( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey, - __in_opt PMSG Message + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey, + _In_opt_ PMSG Message ) { ULONG code; @@ -589,8 +589,8 @@ ULONG PhTnpOnGetDlgCode( } VOID PhTnpOnPaint( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ) { RECT updateRect; @@ -661,19 +661,19 @@ VOID PhTnpOnPaint( } VOID PhTnpOnPrintClient( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in ULONG Flags + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ ULONG Flags ) { PhTnpPaint(hwnd, Context, hdc, &Context->ClientRect); } BOOLEAN PhTnpOnNcPaint( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in_opt HRGN UpdateRegion + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ HRGN UpdateRegion ) { PhTnpInitializeThemeData(Context); @@ -706,9 +706,9 @@ BOOLEAN PhTnpOnNcPaint( } BOOLEAN PhTnpOnSetCursor( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in HWND CursorWindowHandle + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HWND CursorWindowHandle ) { POINT point; @@ -734,9 +734,9 @@ BOOLEAN PhTnpOnSetCursor( } VOID PhTnpOnTimer( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id ) { if (Id == TNP_TIMER_ANIMATE_DIVIDER) @@ -780,11 +780,11 @@ VOID PhTnpOnTimer( } VOID PhTnpOnMouseMove( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ) { TRACKMOUSEEVENT trackMouseEvent; @@ -807,8 +807,8 @@ VOID PhTnpOnMouseMove( } VOID PhTnpOnMouseLeave( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ) { RECT rect; @@ -837,12 +837,12 @@ VOID PhTnpOnMouseLeave( } VOID PhTnpOnXxxButtonXxx( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Message, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Message, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ) { BOOLEAN startingTracking; @@ -920,49 +920,46 @@ VOID PhTnpOnXxxButtonXxx( if (!(hitTest.Flags & TN_HIT_ITEM_PLUSMINUS) && (Message == WM_LBUTTONDOWN || Message == WM_RBUTTONDOWN)) { - LOGICAL realHitItem; + LOGICAL allowDragSelect; PH_TREENEW_CELL_PARTS parts; PhTnpPopTooltip(Context); + allowDragSelect = TRUE; if (hitTest.Flags & TN_HIT_ITEM) { + allowDragSelect = FALSE; Context->FocusNode = hitTest.Node; - } - - realHitItem = hitTest.Flags & TN_HIT_ITEM; - - if (realHitItem && (Context->ExtendedFlags & TN_FLAG_ITEM_DRAG_SELECT)) - { - // To allow drag selection to begin even if the cursor is on an item, - // we check if the cursor is on the item icon or text. If it isn't, then - // don't count that as a hit. Exceptions are: - // * When the item is already selected - // * When user is beginning to drag the divider - if (!hitTest.Node->Selected && !startingTracking) + if (Context->ExtendedFlags & TN_FLAG_ITEM_DRAG_SELECT) { - if (PhTnpGetCellParts(Context, hitTest.Node->Index, hitTest.Column, TN_MEASURE_TEXT, &parts)) + // To allow drag selection to begin even if the cursor is on an item, + // we check if the cursor is on the item icon or text. Exceptions are: + // * When the item is already selected + // * When user is beginning to drag the divider + + if (!hitTest.Node->Selected && !startingTracking) { - realHitItem = FALSE; + if (PhTnpGetCellParts(Context, hitTest.Node->Index, hitTest.Column, TN_MEASURE_TEXT, &parts)) + { + allowDragSelect = TRUE; - if ((parts.Flags & TN_PART_ICON) && CursorX >= parts.IconRect.left && CursorX < parts.IconRect.right) - realHitItem = TRUE; + if ((parts.Flags & TN_PART_ICON) && CursorX >= parts.IconRect.left && CursorX < parts.IconRect.right) + allowDragSelect = FALSE; - if ((parts.Flags & TN_PART_CONTENT) && (parts.Flags & TN_PART_TEXT)) - { - if (CursorX >= parts.TextRect.left && CursorX < parts.TextRect.right) - realHitItem = TRUE; + if ((parts.Flags & TN_PART_CONTENT) && (parts.Flags & TN_PART_TEXT)) + { + if (CursorX >= parts.TextRect.left && CursorX < parts.TextRect.right) + allowDragSelect = FALSE; + } } } } - } - if (realHitItem) - { PhTnpProcessSelectNode(Context, hitTest.Node, controlKey, shiftKey, Message == WM_RBUTTONDOWN); } - else + + if (allowDragSelect) { BOOLEAN dragSelect; ULONG indexToSelect; @@ -1029,9 +1026,7 @@ VOID PhTnpOnXxxButtonXxx( if ((hitTest.Flags & TN_HIT_ITEM) && (Context->ExtendedFlags & TN_FLAG_ITEM_DRAG_SELECT)) { - // The user isn't performing a drag selection, but we didn't count this as a hit earlier. - // It's a hit now. - PhTnpProcessSelectNode(Context, hitTest.Node, controlKey, shiftKey, Message == WM_RBUTTONDOWN); + // The user isn't performing a drag selection, so prevent deselection. selectionProcessed = TRUE; } @@ -1138,8 +1133,8 @@ VOID PhTnpOnXxxButtonXxx( } VOID PhTnpOnCaptureChanged( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context ) { Context->Tracking = FALSE; @@ -1147,10 +1142,10 @@ VOID PhTnpOnCaptureChanged( } VOID PhTnpOnKeyDown( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey, - __in ULONG Data + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey, + _In_ ULONG Data ) { PH_TREENEW_KEY_EVENT keyEvent; @@ -1170,10 +1165,10 @@ VOID PhTnpOnKeyDown( } VOID PhTnpOnChar( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Character, - __in ULONG Data + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Character, + _In_ ULONG Data ) { // Make sure the character is printable. @@ -1184,12 +1179,12 @@ VOID PhTnpOnChar( } VOID PhTnpOnMouseWheel( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ) { // The normal mouse wheel can affect both the vertical scrollbar and the horizontal scrollbar, @@ -1205,22 +1200,22 @@ VOID PhTnpOnMouseWheel( } VOID PhTnpOnMouseHWheel( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance, - __in ULONG VirtualKeys, - __in LONG CursorX, - __in LONG CursorY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance, + _In_ ULONG VirtualKeys, + _In_ LONG CursorX, + _In_ LONG CursorY ) { PhTnpProcessMouseHWheel(Context, Distance); } VOID PhTnpOnContextMenu( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorScreenX, - __in LONG CursorScreenY + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorScreenX, + _In_ LONG CursorScreenY ) { POINT clientPoint; @@ -1296,9 +1291,9 @@ VOID PhTnpOnContextMenu( } VOID PhTnpOnVScroll( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Request + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Request ) { SCROLLINFO scrollInfo; @@ -1346,9 +1341,9 @@ VOID PhTnpOnVScroll( } VOID PhTnpOnHScroll( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Request + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Request ) { SCROLLINFO scrollInfo; @@ -1396,10 +1391,10 @@ VOID PhTnpOnHScroll( } BOOLEAN PhTnpOnNotify( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in NMHDR *Header, - __out LRESULT *Result + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ NMHDR *Header, + _Out_ LRESULT *Result ) { switch (Header->code) @@ -1471,6 +1466,10 @@ BOOLEAN PhTnpOnNotify( } Context->ResizingColumn = NULL; + + // Redraw the entire window if we are displaying empty text. + if (Context->FlatList->Count == 0 && Context->EmptyText.Length != 0) + InvalidateRect(Context->Handle, NULL, FALSE); } else { @@ -1595,11 +1594,11 @@ BOOLEAN PhTnpOnNotify( } ULONG_PTR PhTnpOnUserMessage( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Message, - __in ULONG_PTR WParam, - __in ULONG_PTR LParam + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Message, + _In_ ULONG_PTR WParam, + _In_ ULONG_PTR LParam ) { switch (Message) @@ -1908,15 +1907,23 @@ ULONG_PTR PhTnpOnUserMessage( PhTnpAutoSizeColumnHeader(Context, column->Fixed ? Context->FixedHeaderHandle : Context->HeaderHandle, column); } return TRUE; + case TNM_SETEMPTYTEXT: + { + PPH_STRINGREF text = (PPH_STRINGREF)LParam; + ULONG flags = (ULONG)WParam; + + Context->EmptyText = *text; + } + return TRUE; } return 0; } VOID PhTnpSetFont( - __in PPH_TREENEW_CONTEXT Context, - __in_opt HFONT Font, - __in BOOLEAN Redraw + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ HFONT Font, + _In_ BOOLEAN Redraw ) { if (Context->FontOwned) @@ -1951,7 +1958,7 @@ VOID PhTnpSetFont( } VOID PhTnpUpdateSystemMetrics( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { Context->VScrollWidth = GetSystemMetrics(SM_CXVSCROLL); @@ -1970,7 +1977,7 @@ VOID PhTnpUpdateSystemMetrics( } VOID PhTnpUpdateTextMetrics( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { HDC hdc; @@ -2007,7 +2014,7 @@ VOID PhTnpUpdateTextMetrics( } VOID PhTnpUpdateThemeData( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { if ( @@ -2053,7 +2060,7 @@ VOID PhTnpUpdateThemeData( } VOID PhTnpInitializeThemeData( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { if (!Context->ThemeInitialized) @@ -2064,7 +2071,7 @@ VOID PhTnpInitializeThemeData( } VOID PhTnpCancelTrack( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { PhTnpSetFixedWidth(Context, Context->TrackOldFixedWidth); @@ -2072,7 +2079,7 @@ VOID PhTnpCancelTrack( } VOID PhTnpLayout( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { RECT clientRect; @@ -2127,10 +2134,14 @@ VOID PhTnpLayout( } PhTnpLayoutHeader(Context); + + // Redraw the entire window if we are displaying empty text. + if (Context->FlatList->Count == 0 && Context->EmptyText.Length != 0) + InvalidateRect(Context->Handle, NULL, FALSE); } VOID PhTnpLayoutHeader( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { RECT rect; @@ -2176,8 +2187,8 @@ VOID PhTnpLayoutHeader( } VOID PhTnpSetFixedWidth( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG FixedWidth + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG FixedWidth ) { HDITEM item; @@ -2203,8 +2214,8 @@ VOID PhTnpSetFixedWidth( } VOID PhTnpSetRedraw( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Redraw + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Redraw ) { if (Redraw) @@ -2246,13 +2257,13 @@ VOID PhTnpSetRedraw( } VOID PhTnpSendMouseEvent( - __in PPH_TREENEW_CONTEXT Context, - __in PH_TREENEW_MESSAGE Message, - __in LONG CursorX, - __in LONG CursorY, - __in PPH_TREENEW_NODE Node, - __in PPH_TREENEW_COLUMN Column, - __in ULONG VirtualKeys + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PH_TREENEW_MESSAGE Message, + _In_ LONG CursorX, + _In_ LONG CursorY, + _In_ PPH_TREENEW_NODE Node, + _In_ PPH_TREENEW_COLUMN Column, + _In_ ULONG VirtualKeys ) { PH_TREENEW_MOUSE_EVENT mouseEvent; @@ -2266,8 +2277,8 @@ VOID PhTnpSendMouseEvent( } PPH_TREENEW_COLUMN PhTnpLookupColumnById( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id ) { if (Id >= Context->AllocatedColumns) @@ -2277,8 +2288,8 @@ PPH_TREENEW_COLUMN PhTnpLookupColumnById( } BOOLEAN PhTnpAddColumn( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN Column ) { PPH_TREENEW_COLUMN realColumn; @@ -2344,8 +2355,8 @@ BOOLEAN PhTnpAddColumn( } BOOLEAN PhTnpRemoveColumn( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id ) { PPH_TREENEW_COLUMN realColumn; @@ -2373,9 +2384,9 @@ BOOLEAN PhTnpRemoveColumn( } BOOLEAN PhTnpCopyColumn( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Id, - __out PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Id, + _Out_ PPH_TREENEW_COLUMN Column ) { PPH_TREENEW_COLUMN realColumn; @@ -2389,10 +2400,10 @@ BOOLEAN PhTnpCopyColumn( } BOOLEAN PhTnpChangeColumn( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Mask, - __in ULONG Id, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Mask, + _In_ ULONG Id, + _In_ PPH_TREENEW_COLUMN Column ) { PPH_TREENEW_COLUMN realColumn; @@ -2516,7 +2527,7 @@ BOOLEAN PhTnpChangeColumn( } VOID PhTnpExpandAllocatedColumns( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { if (Context->Columns) @@ -2556,7 +2567,7 @@ VOID PhTnpExpandAllocatedColumns( } VOID PhTnpUpdateColumnMaps( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { ULONG i; @@ -2616,8 +2627,8 @@ VOID PhTnpUpdateColumnMaps( } LONG PhTnpInsertColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN Column ) { HDITEM item; @@ -2674,9 +2685,9 @@ LONG PhTnpInsertColumnHeader( } VOID PhTnpChangeColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Mask, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Mask, + _In_ PPH_TREENEW_COLUMN Column ) { HDITEM item; @@ -2737,8 +2748,8 @@ VOID PhTnpChangeColumnHeader( } VOID PhTnpDeleteColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __inout PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _Inout_ PPH_TREENEW_COLUMN Column ) { if (Column->Fixed) @@ -2761,7 +2772,7 @@ VOID PhTnpDeleteColumnHeader( } VOID PhTnpUpdateColumnHeaders( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { ULONG count; @@ -2799,9 +2810,9 @@ VOID PhTnpUpdateColumnHeaders( } VOID PhTnpProcessResizeColumn( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN Column, - __in LONG Delta + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN Column, + _In_ LONG Delta ) { RECT rect; @@ -2861,8 +2872,8 @@ VOID PhTnpProcessResizeColumn( } VOID PhTnpProcessSortColumn( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_COLUMN NewColumn + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_COLUMN NewColumn ) { if (NewColumn->Id == Context->SortColumn) @@ -2916,8 +2927,8 @@ VOID PhTnpProcessSortColumn( } BOOLEAN PhTnpSetColumnHeaderSortIcon( - __in PPH_TREENEW_CONTEXT Context, - __in_opt PPH_TREENEW_COLUMN SortColumnPointer + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ PPH_TREENEW_COLUMN SortColumnPointer ) { if (Context->SortOrder == NoSortOrder) @@ -2973,9 +2984,9 @@ BOOLEAN PhTnpSetColumnHeaderSortIcon( } VOID PhTnpAutoSizeColumnHeader( - __in PPH_TREENEW_CONTEXT Context, - __in HWND HeaderHandle, - __in PPH_TREENEW_COLUMN Column + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HWND HeaderHandle, + _In_ PPH_TREENEW_COLUMN Column ) { ULONG i; @@ -3014,10 +3025,10 @@ VOID PhTnpAutoSizeColumnHeader( } BOOLEAN PhTnpGetNodeChildren( - __in PPH_TREENEW_CONTEXT Context, - __in_opt PPH_TREENEW_NODE Node, - __out PPH_TREENEW_NODE **Children, - __out PULONG NumberOfChildren + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ PPH_TREENEW_NODE Node, + _Out_ PPH_TREENEW_NODE **Children, + _Out_ PULONG NumberOfChildren ) { PH_TREENEW_GET_CHILDREN getChildren; @@ -3045,8 +3056,8 @@ BOOLEAN PhTnpGetNodeChildren( } BOOLEAN PhTnpIsNodeLeaf( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node ) { PH_TREENEW_IS_LEAF isLeaf; @@ -3071,10 +3082,10 @@ BOOLEAN PhTnpIsNodeLeaf( } BOOLEAN PhTnpGetCellText( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in ULONG Id, - __out PPH_STRINGREF Text + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ ULONG Id, + _Out_ PPH_STRINGREF Text ) { PH_TREENEW_GET_CELL_TEXT getCellText; @@ -3110,7 +3121,7 @@ BOOLEAN PhTnpGetCellText( } VOID PhTnpRestructureNodes( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { PPH_TREENEW_NODE *children; @@ -3145,9 +3156,9 @@ VOID PhTnpRestructureNodes( } VOID PhTnpInsertNodeChildren( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in ULONG Level + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ ULONG Level ) { PPH_TREENEW_NODE *children; @@ -3193,9 +3204,9 @@ VOID PhTnpInsertNodeChildren( } VOID PhTnpSetExpandedNode( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in BOOLEAN Expanded + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ BOOLEAN Expanded ) { if (Node->Expanded != Expanded) @@ -3251,11 +3262,11 @@ VOID PhTnpSetExpandedNode( } BOOLEAN PhTnpGetCellParts( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Index, - __in_opt PPH_TREENEW_COLUMN Column, - __in ULONG Flags, - __out PPH_TREENEW_CELL_PARTS Parts + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Index, + _In_opt_ PPH_TREENEW_COLUMN Column, + _In_ ULONG Flags, + _Out_ PPH_TREENEW_CELL_PARTS Parts ) { PPH_TREENEW_NODE node; @@ -3393,11 +3404,11 @@ BOOLEAN PhTnpGetCellParts( } BOOLEAN PhTnpGetRowRects( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Start, - __in ULONG End, - __in BOOLEAN Clip, - __out PRECT Rect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Start, + _In_ ULONG End, + _In_ BOOLEAN Clip, + _Out_ PRECT Rect ) { LONG startY; @@ -3434,8 +3445,8 @@ BOOLEAN PhTnpGetRowRects( } VOID PhTnpHitTest( - __in PPH_TREENEW_CONTEXT Context, - __inout PPH_TREENEW_HIT_TEST HitTest + _In_ PPH_TREENEW_CONTEXT Context, + _Inout_ PPH_TREENEW_HIT_TEST HitTest ) { RECT clientRect; @@ -3558,12 +3569,12 @@ VOID PhTnpHitTest( } VOID PhTnpSelectRange( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Start, - __in ULONG End, - __in ULONG Flags, - __out_opt PULONG ChangedStart, - __out_opt PULONG ChangedEnd + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Start, + _In_ ULONG End, + _In_ ULONG Flags, + _Out_opt_ PULONG ChangedStart, + _Out_opt_ PULONG ChangedEnd ) { ULONG maximum; @@ -3658,9 +3669,9 @@ VOID PhTnpSelectRange( } VOID PhTnpSetHotNode( - __in PPH_TREENEW_CONTEXT Context, - __in_opt PPH_TREENEW_NODE NewHotNode, - __in BOOLEAN NewPlusMinusHot + _In_ PPH_TREENEW_CONTEXT Context, + _In_opt_ PPH_TREENEW_NODE NewHotNode, + _In_ BOOLEAN NewPlusMinusHot ) { ULONG newHotNodeIndex; @@ -3709,11 +3720,11 @@ VOID PhTnpSetHotNode( } VOID PhTnpProcessSelectNode( - __in PPH_TREENEW_CONTEXT Context, - __in PPH_TREENEW_NODE Node, - __in LOGICAL ControlKey, - __in LOGICAL ShiftKey, - __in LOGICAL RightButton + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPH_TREENEW_NODE Node, + _In_ LOGICAL ControlKey, + _In_ LOGICAL ShiftKey, + _In_ LOGICAL RightButton ) { ULONG changedStart; @@ -3790,8 +3801,8 @@ VOID PhTnpProcessSelectNode( } BOOLEAN PhTnpEnsureVisibleNode( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Index + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Index ) { LONG viewTop; @@ -3833,9 +3844,9 @@ BOOLEAN PhTnpEnsureVisibleNode( } VOID PhTnpProcessMoveMouse( - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorX, - __in LONG CursorY + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorX, + _In_ LONG CursorY ) { PH_TREENEW_HIT_TEST hitTest; @@ -3904,8 +3915,8 @@ VOID PhTnpProcessMoveMouse( } VOID PhTnpProcessMouseVWheel( - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance ) { ULONG wheelScrollLines; @@ -3967,8 +3978,8 @@ VOID PhTnpProcessMouseVWheel( } VOID PhTnpProcessMouseHWheel( - __in PPH_TREENEW_CONTEXT Context, - __in LONG Distance + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG Distance ) { ULONG wheelScrollChars; @@ -4007,8 +4018,8 @@ VOID PhTnpProcessMouseHWheel( } BOOLEAN PhTnpProcessFocusKey( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey ) { ULONG count; @@ -4181,8 +4192,8 @@ BOOLEAN PhTnpProcessFocusKey( } BOOLEAN PhTnpProcessNodeKey( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKey + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKey ) { BOOLEAN controlKey; @@ -4332,8 +4343,8 @@ BOOLEAN PhTnpProcessNodeKey( } VOID PhTnpProcessSearchKey( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG Character + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG Character ) { LONG messageTime; @@ -4465,10 +4476,10 @@ VOID PhTnpProcessSearchKey( } BOOLEAN PhTnpDefaultIncrementalSearch( - __in PPH_TREENEW_CONTEXT Context, - __inout PPH_TREENEW_SEARCH_EVENT SearchEvent, - __in BOOLEAN Partial, - __in BOOLEAN Wrap + _In_ PPH_TREENEW_CONTEXT Context, + _Inout_ PPH_TREENEW_SEARCH_EVENT SearchEvent, + _In_ BOOLEAN Partial, + _In_ BOOLEAN Wrap ) { LONG startIndex; @@ -4536,7 +4547,7 @@ BOOLEAN PhTnpDefaultIncrementalSearch( } VOID PhTnpUpdateScrollBars( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { RECT clientRect; @@ -4649,9 +4660,9 @@ VOID PhTnpUpdateScrollBars( } VOID PhTnpScroll( - __in PPH_TREENEW_CONTEXT Context, - __in LONG DeltaRows, - __in LONG DeltaX + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG DeltaRows, + _In_ LONG DeltaX ) { SCROLLINFO scrollInfo; @@ -4706,9 +4717,9 @@ VOID PhTnpScroll( } VOID PhTnpProcessScroll( - __in PPH_TREENEW_CONTEXT Context, - __in LONG DeltaRows, - __in LONG DeltaX + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG DeltaRows, + _In_ LONG DeltaX ) { RECT rect; @@ -4734,18 +4745,35 @@ VOID PhTnpProcessScroll( } else { - deltaY = DeltaRows * Context->RowHeight; + // Don't scroll if there are no rows. This is especially important if the user wants us to display empty text. + if (Context->FlatList->Count != 0) + { + deltaY = DeltaRows * Context->RowHeight; - // If we're scrolling vertically as well, we need to scroll the fixed part and the normal part - // separately. + // If we're scrolling vertically as well, we need to scroll the fixed part and the normal part + // separately. - if (DeltaRows != 0) - { - rect.left = 0; - rect.right = Context->NormalLeft; + if (DeltaRows != 0) + { + rect.left = 0; + rect.right = Context->NormalLeft; + ScrollWindowEx( + Context->Handle, + 0, + -deltaY, + &rect, + &rect, + NULL, + NULL, + SW_INVALIDATE + ); + } + + rect.left = Context->NormalLeft; + rect.right = Context->ClientRect.right - (Context->VScrollVisible ? Context->VScrollWidth : 0); ScrollWindowEx( Context->Handle, - 0, + -DeltaX, -deltaY, &rect, &rect, @@ -4755,27 +4783,14 @@ VOID PhTnpProcessScroll( ); } - rect.left = Context->NormalLeft; - rect.right = Context->ClientRect.right - (Context->VScrollVisible ? Context->VScrollWidth : 0); - ScrollWindowEx( - Context->Handle, - -DeltaX, - -deltaY, - &rect, - &rect, - NULL, - NULL, - SW_INVALIDATE - ); - PhTnpLayoutHeader(Context); } } BOOLEAN PhTnpCanScroll( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Horizontal, - __in BOOLEAN Positive + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Horizontal, + _In_ BOOLEAN Positive ) { SCROLLINFO scrollInfo; @@ -4802,10 +4817,10 @@ BOOLEAN PhTnpCanScroll( } VOID PhTnpPaint( - __in HWND hwnd, - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in PRECT PaintRect + _In_ HWND hwnd, + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ PRECT PaintRect ) { RECT viewRect; @@ -5044,6 +5059,25 @@ VOID PhTnpPaint( FillRect(hdc, &rowRect, GetSysColorBrush(COLOR_WINDOW)); } + if (Context->FlatList->Count == 0 && Context->EmptyText.Length != 0) + { + RECT textRect; + + textRect.left = 20; + textRect.top = Context->HeaderHeight + 10; + textRect.right = viewRect.right - 20; + textRect.bottom = viewRect.bottom - 5; + + SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); + DrawText( + hdc, + Context->EmptyText.Buffer, + (ULONG)Context->EmptyText.Length / 2, + &textRect, + DT_NOPREFIX | DT_CENTER | DT_END_ELLIPSIS + ); + } + if (Context->FixedDividerVisible && Context->FixedWidth >= PaintRect->left && Context->FixedWidth < PaintRect->right) { PhTnpDrawDivider(Context, hdc); @@ -5056,9 +5090,9 @@ VOID PhTnpPaint( } VOID PhTnpPrepareRowForDraw( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __inout PPH_TREENEW_NODE Node + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _Inout_ PPH_TREENEW_NODE Node ) { if (!Node->s.CachedColorValid) @@ -5163,13 +5197,13 @@ VOID PhTnpPrepareRowForDraw( } VOID PhTnpDrawCell( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in PRECT CellRect, - __in PPH_TREENEW_NODE Node, - __in PPH_TREENEW_COLUMN Column, - __in LONG RowIndex, - __in LONG ColumnIndex + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ PRECT CellRect, + _In_ PPH_TREENEW_NODE Node, + _In_ PPH_TREENEW_COLUMN Column, + _In_ LONG RowIndex, + _In_ LONG ColumnIndex ) { HFONT font; // font to use @@ -5355,8 +5389,8 @@ VOID PhTnpDrawCell( } VOID PhTnpDrawDivider( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc ) { POINT points[2]; @@ -5421,9 +5455,9 @@ VOID PhTnpDrawDivider( } VOID PhTnpDrawPlusMinusGlyph( - __in HDC hdc, - __in PRECT Rect, - __in BOOLEAN Plus + _In_ HDC hdc, + _In_ PRECT Rect, + _In_ BOOLEAN Plus ) { INT savedDc; @@ -5467,9 +5501,9 @@ VOID PhTnpDrawPlusMinusGlyph( } VOID PhTnpDrawSelectionRectangle( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc, - __in PRECT Rect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc, + _In_ PRECT Rect ) { RECT rect; @@ -5556,8 +5590,8 @@ VOID PhTnpDrawSelectionRectangle( } VOID PhTnpDrawThemedBorder( - __in PPH_TREENEW_CONTEXT Context, - __in HDC hdc + _In_ PPH_TREENEW_CONTEXT Context, + _In_ HDC hdc ) { RECT windowRect; @@ -5608,7 +5642,7 @@ VOID PhTnpDrawThemedBorder( } VOID PhTnpInitializeTooltips( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { TOOLINFO toolInfo; @@ -5672,9 +5706,9 @@ VOID PhTnpInitializeTooltips( } VOID PhTnpGetTooltipText( - __in PPH_TREENEW_CONTEXT Context, - __in PPOINT Point, - __out PWSTR *Text + _In_ PPH_TREENEW_CONTEXT Context, + _In_ PPOINT Point, + _Out_ PWSTR *Text ) { PH_TREENEW_HIT_TEST hitTest; @@ -5782,7 +5816,7 @@ VOID PhTnpGetTooltipText( } BOOLEAN PhTnpPrepareTooltipShow( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { RECT rect; @@ -5825,7 +5859,7 @@ BOOLEAN PhTnpPrepareTooltipShow( } VOID PhTnpPrepareTooltipPop( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { Context->TooltipIndex = -1; @@ -5834,7 +5868,7 @@ VOID PhTnpPrepareTooltipPop( } VOID PhTnpPopTooltip( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { if (Context->TooltipsHandle) @@ -5845,10 +5879,10 @@ VOID PhTnpPopTooltip( } PPH_TREENEW_COLUMN PhTnpHitTestHeader( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Fixed, - __in PPOINT Point, - __out_opt PRECT ItemRect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Fixed, + _In_ PPOINT Point, + _Out_opt_ PRECT ItemRect ) { PPH_TREENEW_COLUMN column; @@ -5899,10 +5933,10 @@ PPH_TREENEW_COLUMN PhTnpHitTestHeader( } VOID PhTnpGetHeaderTooltipText( - __in PPH_TREENEW_CONTEXT Context, - __in BOOLEAN Fixed, - __in PPOINT Point, - __out PWSTR *Text + _In_ PPH_TREENEW_CONTEXT Context, + _In_ BOOLEAN Fixed, + _In_ PPOINT Point, + _Out_ PWSTR *Text ) { LOGICAL result; @@ -5959,10 +5993,10 @@ PWSTR PhTnpMakeContextAtom( } LRESULT CALLBACK PhTnpHeaderHookWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPH_TREENEW_CONTEXT context; @@ -6072,11 +6106,11 @@ LRESULT CALLBACK PhTnpHeaderHookWndProc( } BOOLEAN PhTnpDetectDrag( - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorX, - __in LONG CursorY, - __in BOOLEAN DispatchMessages, - __out_opt PULONG CancelledByMessage + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorX, + _In_ LONG CursorY, + _In_ BOOLEAN DispatchMessages, + _Out_opt_ PULONG CancelledByMessage ) { RECT dragRect; @@ -6142,9 +6176,9 @@ BOOLEAN PhTnpDetectDrag( } VOID PhTnpDragSelect( - __in PPH_TREENEW_CONTEXT Context, - __in LONG CursorX, - __in LONG CursorY + _In_ PPH_TREENEW_CONTEXT Context, + _In_ LONG CursorX, + _In_ LONG CursorY ) { MSG msg; @@ -6398,11 +6432,11 @@ VOID PhTnpDragSelect( } VOID PhTnpProcessDragSelect( - __in PPH_TREENEW_CONTEXT Context, - __in ULONG VirtualKeys, - __in PRECT OldRect, - __in PRECT NewRect, - __in PRECT TotalRect + _In_ PPH_TREENEW_CONTEXT Context, + _In_ ULONG VirtualKeys, + _In_ PRECT OldRect, + _In_ PRECT NewRect, + _In_ PRECT TotalRect ) { LONG firstRow; @@ -6486,7 +6520,7 @@ VOID PhTnpProcessDragSelect( } VOID PhTnpCreateBufferedContext( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { HDC hdc; @@ -6518,7 +6552,7 @@ VOID PhTnpCreateBufferedContext( } VOID PhTnpDestroyBufferedContext( - __in PPH_TREENEW_CONTEXT Context + _In_ PPH_TREENEW_CONTEXT Context ) { // The original bitmap must be selected back into the context, otherwise @@ -6532,8 +6566,8 @@ VOID PhTnpDestroyBufferedContext( } VOID PhTnpGetMessagePos( - __in HWND hwnd, - __out PPOINT ClientPoint + _In_ HWND hwnd, + _Out_ PPOINT ClientPoint ) { ULONG position; diff --git a/2.x/trunk/phlib/verify.c b/2.x/trunk/phlib/verify.c index d15816561..0b6339a90 100644 --- a/2.x/trunk/phlib/verify.c +++ b/2.x/trunk/phlib/verify.c @@ -2,7 +2,7 @@ * Process Hacker - * image verification * - * Copyright (C) 2009-2010 wj32 + * Copyright (C) 2009-2013 wj32 * * This file is part of Process Hacker. * @@ -21,6 +21,7 @@ */ #include +#include #include _CryptCATAdminCalcHashFromFileHandle CryptCATAdminCalcHashFromFileHandle; @@ -35,8 +36,13 @@ _WTHelperProvDataFromStateData WTHelperProvDataFromStateData_I; _WTHelperGetProvSignerFromChain WTHelperGetProvSignerFromChain_I; _WinVerifyTrust WinVerifyTrust_I; _CertNameToStr CertNameToStr_I; +_CertDuplicateCertificateContext CertDuplicateCertificateContext_I; +_CertFreeCertificateContext CertFreeCertificateContext_I; static PH_INITONCE PhpVerifyInitOnce = PH_INITONCE_INIT; +static GUID WinTrustActionGenericVerifyV2 = WINTRUST_ACTION_GENERIC_VERIFY_V2; +static GUID DriverActionVerify = DRIVER_ACTION_VERIFY; + static VOID PhpVerifyInitialization( VOID ) @@ -59,10 +65,12 @@ static VOID PhpVerifyInitialization( WTHelperGetProvSignerFromChain_I = (PVOID)GetProcAddress(wintrust, "WTHelperGetProvSignerFromChain"); WinVerifyTrust_I = (PVOID)GetProcAddress(wintrust, "WinVerifyTrust"); CertNameToStr_I = (PVOID)GetProcAddress(crypt32, "CertNameToStrW"); + CertDuplicateCertificateContext_I = (PVOID)GetProcAddress(crypt32, "CertDuplicateCertificateContext"); + CertFreeCertificateContext_I = (PVOID)GetProcAddress(crypt32, "CertFreeCertificateContext"); } VERIFY_RESULT PhpStatusToVerifyResult( - __in LONG Status + _In_ LONG Status ) { switch (Status) @@ -86,8 +94,429 @@ VERIFY_RESULT PhpStatusToVerifyResult( } } +BOOLEAN PhpGetSignaturesFromStateData( + _In_ HANDLE StateData, + _Out_ PCERT_CONTEXT **Signatures, + _Out_ PULONG NumberOfSignatures + ) +{ + PCRYPT_PROVIDER_DATA provData; + PCRYPT_PROVIDER_SGNR sgnr; + PCERT_CONTEXT *signatures; + ULONG i; + ULONG numberOfSignatures; + ULONG index; + + provData = WTHelperProvDataFromStateData_I(StateData); + + if (!provData) + { + *Signatures = NULL; + *NumberOfSignatures = 0; + return FALSE; + } + + i = 0; + numberOfSignatures = 0; + + while (sgnr = WTHelperGetProvSignerFromChain_I(provData, i, FALSE, 0)) + { + if (sgnr->csCertChain != 0) + numberOfSignatures++; + + i++; + } + + if (numberOfSignatures != 0) + { + signatures = PhAllocate(numberOfSignatures * sizeof(PCERT_CONTEXT)); + i = 0; + index = 0; + + while (sgnr = WTHelperGetProvSignerFromChain_I(provData, i, FALSE, 0)) + { + if (sgnr->csCertChain != 0) + signatures[index++] = (PCERT_CONTEXT)CertDuplicateCertificateContext_I(sgnr->pasCertChain[0].pCert); + + i++; + } + } + else + { + signatures = NULL; + } + + *Signatures = signatures; + *NumberOfSignatures = numberOfSignatures; + + return TRUE; +} + +VOID PhpViewSignerInfo( + _In_ PPH_VERIFY_FILE_INFO Information, + _In_ HANDLE StateData + ) +{ + static PH_INITONCE initOnce = PH_INITONCE_INIT; + static _CryptUIDlgViewSignerInfo cryptUIDlgViewSignerInfo; + + if (PhBeginInitOnce(&initOnce)) + { + HMODULE cryptui = LoadLibrary(L"cryptui.dll"); + + cryptUIDlgViewSignerInfo = (PVOID)GetProcAddress(cryptui, "CryptUIDlgViewSignerInfoW"); + PhEndInitOnce(&initOnce); + } + + if (cryptUIDlgViewSignerInfo) + { + CRYPTUI_VIEWSIGNERINFO_STRUCT viewSignerInfo = { sizeof(CRYPTUI_VIEWSIGNERINFO_STRUCT) }; + PCRYPT_PROVIDER_DATA provData; + PCRYPT_PROVIDER_SGNR sgnr; + + if (!(provData = WTHelperProvDataFromStateData_I(StateData))) + return; + if (!(sgnr = WTHelperGetProvSignerFromChain_I(provData, 0, FALSE, 0))) + return; + + viewSignerInfo.hwndParent = Information->hWnd; + viewSignerInfo.pSignerInfo = sgnr->psSigner; + viewSignerInfo.hMsg = provData->hMsg; + viewSignerInfo.pszOID = szOID_PKIX_KP_CODE_SIGNING; + cryptUIDlgViewSignerInfo(&viewSignerInfo); + } +} + +VERIFY_RESULT PhpVerifyFile( + _In_ PPH_VERIFY_FILE_INFO Information, + _In_ HANDLE FileHandle, + _In_ ULONG UnionChoice, + _In_ PVOID UnionData, + _In_ PGUID ActionId, + _In_opt_ PVOID PolicyCallbackData, + _Out_ PCERT_CONTEXT **Signatures, + _Out_ PULONG NumberOfSignatures + ) +{ + LONG status; + WINTRUST_DATA trustData = { 0 }; + + trustData.cbStruct = sizeof(WINTRUST_DATA); + trustData.pPolicyCallbackData = PolicyCallbackData; + trustData.dwUIChoice = WTD_UI_NONE; + trustData.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN; + trustData.dwUnionChoice = UnionChoice; + trustData.dwStateAction = WTD_STATEACTION_VERIFY; + trustData.dwProvFlags = WTD_SAFER_FLAG; + + trustData.pFile = UnionData; + + if (UnionChoice == WTD_CHOICE_CATALOG) + trustData.pCatalog = UnionData; + + if (Information->Flags & PH_VERIFY_PREVENT_NETWORK_ACCESS) + { + trustData.fdwRevocationChecks = WTD_REVOKE_NONE; + + if (WindowsVersion >= WINDOWS_VISTA) + trustData.dwProvFlags |= WTD_CACHE_ONLY_URL_RETRIEVAL; + else + trustData.dwProvFlags |= WTD_REVOCATION_CHECK_NONE; + } + + status = WinVerifyTrust_I(NULL, ActionId, &trustData); + PhpGetSignaturesFromStateData(trustData.hWVTStateData, Signatures, NumberOfSignatures); + + if (status == 0 && (Information->Flags & PH_VERIFY_VIEW_PROPERTIES)) + PhpViewSignerInfo(Information, trustData.hWVTStateData); + + // Close the state data. + trustData.dwStateAction = WTD_STATEACTION_CLOSE; + WinVerifyTrust_I(NULL, ActionId, &trustData); + + return PhpStatusToVerifyResult(status); +} + +BOOLEAN PhpCalculateFileHash( + _In_ HANDLE FileHandle, + _In_ PWSTR HashAlgorithm, + _Out_ PUCHAR *FileHash, + _Out_ PULONG FileHashLength, + _Out_ HANDLE *CatAdminHandle + ) +{ + HANDLE catAdminHandle; + PUCHAR fileHash; + ULONG fileHashLength; + + if (CryptCATAdminAcquireContext2) + { + if (!CryptCATAdminAcquireContext2(&catAdminHandle, &DriverActionVerify, HashAlgorithm, NULL, 0)) + return FALSE; + } + else + { + if (!CryptCATAdminAcquireContext(&catAdminHandle, &DriverActionVerify, 0)) + return FALSE; + } + + fileHashLength = 32; + fileHash = PhAllocate(fileHashLength); + + if (CryptCATAdminCalcHashFromFileHandle2) + { + if (!CryptCATAdminCalcHashFromFileHandle2(catAdminHandle, FileHandle, &fileHashLength, fileHash, 0)) + { + PhFree(fileHash); + fileHash = PhAllocate(fileHashLength); + + if (!CryptCATAdminCalcHashFromFileHandle2(catAdminHandle, FileHandle, &fileHashLength, fileHash, 0)) + { + CryptCATAdminReleaseContext(catAdminHandle, 0); + PhFree(fileHash); + return FALSE; + } + } + } + else + { + if (!CryptCATAdminCalcHashFromFileHandle(FileHandle, &fileHashLength, fileHash, 0)) + { + PhFree(fileHash); + fileHash = PhAllocate(fileHashLength); + + if (!CryptCATAdminCalcHashFromFileHandle(FileHandle, &fileHashLength, fileHash, 0)) + { + CryptCATAdminReleaseContext(catAdminHandle, 0); + PhFree(fileHash); + return FALSE; + } + } + } + + *FileHash = fileHash; + *FileHashLength = fileHashLength; + *CatAdminHandle = catAdminHandle; + + return TRUE; +} + +VERIFY_RESULT PhpVerifyFileFromCatalog( + _In_ PPH_VERIFY_FILE_INFO Information, + _In_ HANDLE FileHandle, + _In_opt_ PWSTR HashAlgorithm, + _Out_ PCERT_CONTEXT **Signatures, + _Out_ PULONG NumberOfSignatures + ) +{ + VERIFY_RESULT verifyResult = VrNoSignature; + PCERT_CONTEXT *signatures; + ULONG numberOfSignatures; + WINTRUST_CATALOG_INFO catalogInfo = { 0 }; + LARGE_INTEGER fileSize; + ULONG fileSizeLimit; + PUCHAR fileHash; + ULONG fileHashLength; + PPH_STRING fileHashTag; + HANDLE catAdminHandle; + HANDLE catInfoHandle; + ULONG i; + + *Signatures = NULL; + *NumberOfSignatures = 0; + + if (!NT_SUCCESS(PhGetFileSize(FileHandle, &fileSize))) + return VrNoSignature; + + signatures = NULL; + numberOfSignatures = 0; + + if (Information->FileSizeLimitForHash != -1) + { + fileSizeLimit = PH_VERIFY_DEFAULT_SIZE_LIMIT; + + if (Information->FileSizeLimitForHash != 0) + fileSizeLimit = Information->FileSizeLimitForHash; + + if (fileSize.QuadPart > fileSizeLimit) + return VrNoSignature; + } + + if (PhpCalculateFileHash(FileHandle, HashAlgorithm, &fileHash, &fileHashLength, &catAdminHandle)) + { + fileHashTag = PhBufferToHexStringEx(fileHash, fileHashLength, TRUE); + + // Search the system catalogs. + + catInfoHandle = CryptCATAdminEnumCatalogFromHash( + catAdminHandle, + fileHash, + fileHashLength, + 0, + NULL + ); + + if (catInfoHandle) + { + CATALOG_INFO ci = { 0 }; + DRIVER_VER_INFO verInfo = { 0 }; + + if (CryptCATCatalogInfoFromContext(catInfoHandle, &ci, 0)) + { + // Disable OS version checking by passing in a DRIVER_VER_INFO structure. + verInfo.cbStruct = sizeof(DRIVER_VER_INFO); + + catalogInfo.cbStruct = sizeof(catalogInfo); + catalogInfo.pcwszCatalogFilePath = ci.wszCatalogFile; + catalogInfo.pcwszMemberFilePath = Information->FileName; + catalogInfo.pcwszMemberTag = fileHashTag->Buffer; + catalogInfo.pbCalculatedFileHash = fileHash; + catalogInfo.cbCalculatedFileHash = fileHashLength; + catalogInfo.hCatAdmin = catAdminHandle; + verifyResult = PhpVerifyFile(Information, FileHandle, WTD_CHOICE_CATALOG, &catalogInfo, &DriverActionVerify, &verInfo, &signatures, &numberOfSignatures); + + if (verInfo.pcSignerCertContext) + CertFreeCertificateContext_I(verInfo.pcSignerCertContext); + } + + CryptCATAdminReleaseCatalogContext(catAdminHandle, catInfoHandle, 0); + } + else + { + // Search any user-supplied catalogs. + + for (i = 0; i < Information->NumberOfCatalogFileNames; i++) + { + PhFreeVerifySignatures(signatures, numberOfSignatures); + + catalogInfo.cbStruct = sizeof(catalogInfo); + catalogInfo.pcwszCatalogFilePath = Information->CatalogFileNames[i]; + catalogInfo.pcwszMemberFilePath = Information->FileName; + catalogInfo.pcwszMemberTag = fileHashTag->Buffer; + catalogInfo.pbCalculatedFileHash = fileHash; + catalogInfo.cbCalculatedFileHash = fileHashLength; + catalogInfo.hCatAdmin = catAdminHandle; + verifyResult = PhpVerifyFile(Information, FileHandle, WTD_CHOICE_CATALOG, &catalogInfo, &WinTrustActionGenericVerifyV2, NULL, &signatures, &numberOfSignatures); + + if (verifyResult == VrTrusted) + break; + } + } + + PhDereferenceObject(fileHashTag); + PhFree(fileHash); + CryptCATAdminReleaseContext(catAdminHandle, 0); + } + + *Signatures = signatures; + *NumberOfSignatures = numberOfSignatures; + + return verifyResult; +} + +NTSTATUS PhVerifyFileEx( + _In_ PPH_VERIFY_FILE_INFO Information, + _Out_ VERIFY_RESULT *VerifyResult, + _Out_opt_ PCERT_CONTEXT **Signatures, + _Out_opt_ PULONG NumberOfSignatures + ) +{ + NTSTATUS status; + HANDLE fileHandle; + VERIFY_RESULT verifyResult; + PCERT_CONTEXT *signatures; + ULONG numberOfSignatures; + WINTRUST_FILE_INFO fileInfo = { 0 }; + + if (PhBeginInitOnce(&PhpVerifyInitOnce)) + { + PhpVerifyInitialization(); + PhEndInitOnce(&PhpVerifyInitOnce); + } + + // Make sure we have successfully imported + // the required functions. + if ( + !CryptCATAdminCalcHashFromFileHandle || + !CryptCATAdminAcquireContext || + !CryptCATAdminEnumCatalogFromHash || + !CryptCATCatalogInfoFromContext || + !CryptCATAdminReleaseCatalogContext || + !CryptCATAdminReleaseContext || + !WinVerifyTrust_I || + !WTHelperProvDataFromStateData_I || + !WTHelperGetProvSignerFromChain_I || + !CertNameToStr_I || + !CertDuplicateCertificateContext_I || + !CertFreeCertificateContext_I + ) + return STATUS_NOT_SUPPORTED; + + if (!NT_SUCCESS(status = PhCreateFileWin32( + &fileHandle, + Information->FileName, + FILE_GENERIC_READ, + 0, + FILE_SHARE_READ | FILE_SHARE_DELETE, + FILE_OPEN, + FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT + ))) + return status; + + fileInfo.cbStruct = sizeof(WINTRUST_FILE_INFO); + fileInfo.pcwszFilePath = Information->FileName; + fileInfo.hFile = fileHandle; + + verifyResult = PhpVerifyFile(Information, fileHandle, WTD_CHOICE_FILE, &fileInfo, &WinTrustActionGenericVerifyV2, NULL, &signatures, &numberOfSignatures); + + if (verifyResult == VrNoSignature) + { + if (CryptCATAdminAcquireContext2 && CryptCATAdminCalcHashFromFileHandle2) + { + PhFreeVerifySignatures(signatures, numberOfSignatures); + verifyResult = PhpVerifyFileFromCatalog(Information, fileHandle, BCRYPT_SHA256_ALGORITHM, &signatures, &numberOfSignatures); + } + + if (verifyResult != VrTrusted) + { + PhFreeVerifySignatures(signatures, numberOfSignatures); + verifyResult = PhpVerifyFileFromCatalog(Information, fileHandle, NULL, &signatures, &numberOfSignatures); + } + } + + *VerifyResult = verifyResult; + + if (Signatures) + *Signatures = signatures; + else + PhFreeVerifySignatures(signatures, numberOfSignatures); + + if (NumberOfSignatures) + *NumberOfSignatures = numberOfSignatures; + + NtClose(fileHandle); + + return STATUS_SUCCESS; +} + +VOID PhFreeVerifySignatures( + _In_ PCERT_CONTEXT *Signatures, + _In_ ULONG NumberOfSignatures + ) +{ + ULONG i; + + if (Signatures) + { + for (i = 0; i < NumberOfSignatures; i++) + CertFreeCertificateContext_I(Signatures[i]); + + PhFree(Signatures); + } +} + PPH_STRING PhpGetCertNameString( - __in PCERT_NAME_BLOB Blob + _In_ PCERT_NAME_BLOB Blob ) { PPH_STRING string; @@ -118,8 +547,8 @@ PPH_STRING PhpGetCertNameString( } PPH_STRING PhpGetX500Value( - __in PPH_STRING String, - __in PPH_STRINGREF KeyName + _In_ PPH_STRING String, + _In_ PPH_STRINGREF KeyName ) { WCHAR keyNamePlusEquals[10]; @@ -172,60 +601,27 @@ PPH_STRING PhpGetX500Value( return PhSubstring(String, startIndex, endIndex - startIndex); } -PPH_STRING PhpGetSignerNameFromStateData( - __in HANDLE StateData +PPH_STRING PhGetSignerNameFromCertificate( + _In_ PCERT_CONTEXT Certificate ) { - PCRYPT_PROVIDER_DATA provData; - PCRYPT_PROVIDER_SGNR sgnr; - PCRYPT_PROVIDER_CERT cert; - PCCERT_CONTEXT certContext; PCERT_INFO certInfo; PH_STRINGREF keyName; PPH_STRING name; PPH_STRING value; - // 1. State data -> provider data. - - provData = WTHelperProvDataFromStateData_I(StateData); - - if (!provData) - return NULL; - - // 2. Provider data -> Provider signer - - sgnr = WTHelperGetProvSignerFromChain_I(provData, 0, FALSE, 0); - - if (!sgnr) - return NULL; - if (!sgnr->pasCertChain) - return NULL; - if (sgnr->csCertChain == 0) - return NULL; + // Cert context -> Cert info - // 3. Provider signer -> Provider cert - - cert = &sgnr->pasCertChain[0]; - - // 4. Provider cert -> Cert context - - certContext = cert->pCert; - - if (!certContext) - return NULL; - - // 5. Cert context -> Cert info - - certInfo = certContext->pCertInfo; + certInfo = Certificate->pCertInfo; if (!certInfo) return NULL; - // 6. Cert info subject -> Subject X.500 string + // Cert info subject -> Subject X.500 string name = PhpGetCertNameString(&certInfo->Subject); - // 7. Subject X.500 string -> CN or OU value + // Subject X.500 string -> CN or OU value PhInitializeStringRef(&keyName, L"CN"); value = PhpGetX500Value(name, &keyName); @@ -241,209 +637,6 @@ PPH_STRING PhpGetSignerNameFromStateData( return value; } -VERIFY_RESULT PhpVerifyFileBasic( - __in PWSTR FileName, - __out_opt PPH_STRING *SignerName - ) -{ - LONG status; - WINTRUST_DATA trustData = { 0 }; - WINTRUST_FILE_INFO fileInfo = { 0 }; - GUID actionGenericVerifyV2 = WINTRUST_ACTION_GENERIC_VERIFY_V2; - - fileInfo.cbStruct = sizeof(WINTRUST_FILE_INFO); - fileInfo.pcwszFilePath = FileName; - - trustData.cbStruct = sizeof(WINTRUST_DATA); - trustData.dwUIChoice = WTD_UI_NONE; - trustData.dwProvFlags = WTD_SAFER_FLAG; - trustData.dwUnionChoice = WTD_CHOICE_FILE; - trustData.dwStateAction = WTD_STATEACTION_VERIFY; - trustData.pFile = &fileInfo; - - if (WindowsVersion >= WINDOWS_VISTA) - trustData.dwProvFlags |= WTD_CACHE_ONLY_URL_RETRIEVAL; - else - trustData.dwProvFlags |= WTD_REVOCATION_CHECK_NONE; - - status = WinVerifyTrust_I(NULL, &actionGenericVerifyV2, &trustData); - - if (SignerName) - { - if (status != TRUST_E_NOSIGNATURE) - *SignerName = PhpGetSignerNameFromStateData(trustData.hWVTStateData); - else - *SignerName = NULL; - } - - // Close the state data. - trustData.dwStateAction = WTD_STATEACTION_CLOSE; - WinVerifyTrust_I(NULL, &actionGenericVerifyV2, &trustData); - - return PhpStatusToVerifyResult(status); -} - -VERIFY_RESULT PhpVerifyFileFromCatalog( - __in PWSTR FileName, - __in_opt PWSTR HashAlgorithm, - __out_opt PPH_STRING *SignerName - ) -{ - LONG status = TRUST_E_NOSIGNATURE; - WINTRUST_DATA trustData = { 0 }; - WINTRUST_CATALOG_INFO catalogInfo = { 0 }; - GUID driverActionVerify = DRIVER_ACTION_VERIFY; - HANDLE fileHandle; - LARGE_INTEGER fileSize; - PUCHAR fileHash = NULL; - ULONG fileHashLength; - PWSTR fileHashTag = NULL; - HANDLE catAdminHandle = NULL; - HANDLE catInfoHandle = NULL; - ULONG i; - - if (!NT_SUCCESS(PhCreateFileWin32( - &fileHandle, - FileName, - FILE_GENERIC_READ, - 0, - FILE_SHARE_READ | FILE_SHARE_DELETE, - FILE_OPEN, - FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT - ))) - return VrNoSignature; - - // Don't try to hash files over 32 MB in size. - if (!NT_SUCCESS(PhGetFileSize(fileHandle, &fileSize)) || - (fileSize.QuadPart > 32 * 1024 * 1024)) - { - NtClose(fileHandle); - return VrNoSignature; - } - - if (CryptCATAdminAcquireContext2) - { - if (!CryptCATAdminAcquireContext2(&catAdminHandle, &driverActionVerify, HashAlgorithm, NULL, 0)) - { - NtClose(fileHandle); - return VrNoSignature; - } - } - else - { - if (!CryptCATAdminAcquireContext(&catAdminHandle, &driverActionVerify, 0)) - { - NtClose(fileHandle); - return VrNoSignature; - } - } - - fileHashLength = 16; - fileHash = PhAllocate(fileHashLength); - - if (CryptCATAdminCalcHashFromFileHandle2) - { - if (!CryptCATAdminCalcHashFromFileHandle2(catAdminHandle, fileHandle, &fileHashLength, fileHash, 0)) - { - PhFree(fileHash); - fileHash = PhAllocate(fileHashLength); - - if (!CryptCATAdminCalcHashFromFileHandle2(catAdminHandle, fileHandle, &fileHashLength, fileHash, 0)) - { - CryptCATAdminReleaseContext(catAdminHandle, 0); - NtClose(fileHandle); - PhFree(fileHash); - return VrNoSignature; - } - } - } - else - { - if (!CryptCATAdminCalcHashFromFileHandle(fileHandle, &fileHashLength, fileHash, 0)) - { - PhFree(fileHash); - fileHash = PhAllocate(fileHashLength); - - if (!CryptCATAdminCalcHashFromFileHandle(fileHandle, &fileHashLength, fileHash, 0)) - { - CryptCATAdminReleaseContext(catAdminHandle, 0); - NtClose(fileHandle); - PhFree(fileHash); - return VrNoSignature; - } - } - } - - NtClose(fileHandle); - - fileHashTag = PhAllocate((fileHashLength * 2 + 1) * sizeof(WCHAR)); - - for (i = 0; i < fileHashLength; i++) - { - fileHashTag[i * 2] = PhIntegerToCharUpper[fileHash[i] >> 4]; - fileHashTag[i * 2 + 1] = PhIntegerToCharUpper[fileHash[i] & 0xf]; - } - - fileHashTag[fileHashLength * 2] = 0; - - catInfoHandle = CryptCATAdminEnumCatalogFromHash( - catAdminHandle, - fileHash, - fileHashLength, - 0, - NULL - ); - - PhFree(fileHash); - - if (catInfoHandle) - { - CATALOG_INFO ci = { 0 }; - - if (CryptCATCatalogInfoFromContext(catInfoHandle, &ci, 0)) - { - catalogInfo.cbStruct = sizeof(catalogInfo); - catalogInfo.pcwszCatalogFilePath = ci.wszCatalogFile; - catalogInfo.pcwszMemberFilePath = FileName; - catalogInfo.pcwszMemberTag = fileHashTag; - catalogInfo.hCatAdmin = catAdminHandle; - - trustData.cbStruct = sizeof(trustData); - trustData.dwUIChoice = WTD_UI_NONE; - trustData.fdwRevocationChecks = WTD_STATEACTION_VERIFY; - trustData.dwUnionChoice = WTD_CHOICE_CATALOG; - trustData.dwStateAction = WTD_STATEACTION_VERIFY; - trustData.pCatalog = &catalogInfo; - - if (WindowsVersion >= WINDOWS_VISTA) - trustData.dwProvFlags |= WTD_CACHE_ONLY_URL_RETRIEVAL; - else - trustData.dwProvFlags |= WTD_REVOCATION_CHECK_NONE; - - status = WinVerifyTrust_I(NULL, &driverActionVerify, &trustData); - - if (SignerName) - { - if (status != TRUST_E_NOSIGNATURE) - *SignerName = PhpGetSignerNameFromStateData(trustData.hWVTStateData); - else - *SignerName = NULL; - } - - // Close the state data. - trustData.dwStateAction = WTD_STATEACTION_CLOSE; - WinVerifyTrust_I(NULL, &driverActionVerify, &trustData); - } - - CryptCATAdminReleaseCatalogContext(catAdminHandle, catInfoHandle, 0); - } - - PhFree(fileHashTag); - CryptCATAdminReleaseContext(catAdminHandle, 0); - - return PhpStatusToVerifyResult(status); -} - /** * Verifies a file's digital signature. * @@ -457,43 +650,36 @@ VERIFY_RESULT PhpVerifyFileFromCatalog( * \return A VERIFY_RESULT value. */ VERIFY_RESULT PhVerifyFile( - __in PWSTR FileName, - __out_opt PPH_STRING *SignerName + _In_ PWSTR FileName, + _Out_opt_ PPH_STRING *SignerName ) { - VERIFY_RESULT result; + PH_VERIFY_FILE_INFO info = { 0 }; + VERIFY_RESULT verifyResult; + PCERT_CONTEXT *signatures; + ULONG numberOfSignatures; - if (PhBeginInitOnce(&PhpVerifyInitOnce)) - { - PhpVerifyInitialization(); - PhEndInitOnce(&PhpVerifyInitOnce); - } + info.FileName = FileName; + info.Flags = PH_VERIFY_PREVENT_NETWORK_ACCESS; - // Make sure we have successfully imported - // the required functions. - if ( - !CryptCATAdminCalcHashFromFileHandle || - !CryptCATAdminAcquireContext || - !CryptCATAdminEnumCatalogFromHash || - !CryptCATCatalogInfoFromContext || - !CryptCATAdminReleaseCatalogContext || - !CryptCATAdminReleaseContext || - !WinVerifyTrust_I || - !WTHelperProvDataFromStateData_I || - !WTHelperGetProvSignerFromChain_I || - !CertNameToStr_I - ) - return VrUnknown; + if (NT_SUCCESS(PhVerifyFileEx(&info, &verifyResult, &signatures, &numberOfSignatures))) + { + if (SignerName) + { + *SignerName = NULL; - result = PhpVerifyFileBasic(FileName, SignerName); + if (numberOfSignatures != 0) + *SignerName = PhGetSignerNameFromCertificate(signatures[0]); + } - if (result == VrNoSignature) + PhFreeVerifySignatures(signatures, numberOfSignatures); + return verifyResult; + } + else { - result = PhpVerifyFileFromCatalog(FileName, L"SHA256", SignerName); // for Windows 8 + if (SignerName) + *SignerName = NULL; - if (result != VrTrusted) - result = PhpVerifyFileFromCatalog(FileName, NULL, SignerName); + return VrNoSignature; } - - return result; } diff --git a/2.x/trunk/phlib/workqueue.c b/2.x/trunk/phlib/workqueue.c index f96a0ac1a..e3c55c41e 100644 --- a/2.x/trunk/phlib/workqueue.c +++ b/2.x/trunk/phlib/workqueue.c @@ -25,14 +25,14 @@ #include NTSTATUS PhpWorkQueueThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); static PH_FREE_LIST PhWorkQueueItemFreeList; static PH_WORK_QUEUE PhGlobalWorkQueue; static PH_INITONCE PhGlobalWorkQueueInitOnce = PH_INITONCE_INIT; #ifdef DEBUG -LIST_ENTRY PhDbgWorkQueueListHead; +PPH_LIST PhDbgWorkQueueList; PH_QUEUED_LOCK PhDbgWorkQueueListLock = PH_QUEUED_LOCK_INIT; #endif @@ -43,7 +43,7 @@ VOID PhWorkQueueInitialization( PhInitializeFreeList(&PhWorkQueueItemFreeList, sizeof(PH_WORK_QUEUE_ITEM), 32); #ifdef DEBUG - InitializeListHead(&PhDbgWorkQueueListHead); + PhDbgWorkQueueList = PhCreateList(4); #endif } @@ -58,10 +58,10 @@ VOID PhWorkQueueInitialization( * will terminate. */ VOID PhInitializeWorkQueue( - __out PPH_WORK_QUEUE WorkQueue, - __in ULONG MinimumThreads, - __in ULONG MaximumThreads, - __in ULONG NoWorkTimeout + _Out_ PPH_WORK_QUEUE WorkQueue, + _In_ ULONG MinimumThreads, + _In_ ULONG MaximumThreads, + _In_ ULONG NoWorkTimeout ) { PhInitializeRundownProtection(&WorkQueue->RundownProtect); @@ -82,7 +82,7 @@ VOID PhInitializeWorkQueue( #ifdef DEBUG PhAcquireQueuedLockExclusive(&PhDbgWorkQueueListLock); - InsertTailList(&PhDbgWorkQueueListHead, &WorkQueue->DbgListEntry); + PhAddItemList(PhDbgWorkQueueList, WorkQueue); PhReleaseQueuedLockExclusive(&PhDbgWorkQueueListLock); #endif } @@ -93,15 +93,19 @@ VOID PhInitializeWorkQueue( * \param WorkQueue A work queue object. */ VOID PhDeleteWorkQueue( - __inout PPH_WORK_QUEUE WorkQueue + _Inout_ PPH_WORK_QUEUE WorkQueue ) { PLIST_ENTRY listEntry; PPH_WORK_QUEUE_ITEM workQueueItem; +#ifdef DEBUG + ULONG index; +#endif #ifdef DEBUG PhAcquireQueuedLockExclusive(&PhDbgWorkQueueListLock); - RemoveEntryList(&WorkQueue->DbgListEntry); + if ((index = PhFindItemList(PhDbgWorkQueueList, WorkQueue)) != -1) + PhRemoveItemList(PhDbgWorkQueueList, index); PhReleaseQueuedLockExclusive(&PhDbgWorkQueueListLock); #endif @@ -125,9 +129,9 @@ VOID PhDeleteWorkQueue( } FORCEINLINE VOID PhpInitializeWorkQueueItem( - __out PPH_WORK_QUEUE_ITEM WorkQueueItem, - __in PTHREAD_START_ROUTINE Function, - __in_opt PVOID Context + _Out_ PPH_WORK_QUEUE_ITEM WorkQueueItem, + _In_ PTHREAD_START_ROUTINE Function, + _In_opt_ PVOID Context ) { WorkQueueItem->Function = Function; @@ -135,14 +139,14 @@ FORCEINLINE VOID PhpInitializeWorkQueueItem( } FORCEINLINE VOID PhpExecuteWorkQueueItem( - __inout PPH_WORK_QUEUE_ITEM WorkQueueItem + _Inout_ PPH_WORK_QUEUE_ITEM WorkQueueItem ) { WorkQueueItem->Function(WorkQueueItem->Context); } BOOLEAN PhpCreateWorkQueueThread( - __inout PPH_WORK_QUEUE WorkQueue + _Inout_ PPH_WORK_QUEUE WorkQueue ) { HANDLE threadHandle; @@ -170,7 +174,7 @@ BOOLEAN PhpCreateWorkQueueThread( } NTSTATUS PhpWorkQueueThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_WORK_QUEUE workQueue = (PPH_WORK_QUEUE)Parameter; @@ -279,9 +283,9 @@ NTSTATUS PhpWorkQueueThreadStart( * \param Context A user-defined value to pass to the function. */ VOID PhQueueItemWorkQueue( - __inout PPH_WORK_QUEUE WorkQueue, - __in PTHREAD_START_ROUTINE Function, - __in_opt PVOID Context + _Inout_ PPH_WORK_QUEUE WorkQueue, + _In_ PTHREAD_START_ROUTINE Function, + _In_opt_ PVOID Context ) { PPH_WORK_QUEUE_ITEM workQueueItem; @@ -324,8 +328,8 @@ VOID PhQueueItemWorkQueue( * \param Context A user-defined value to pass to the function. */ VOID PhQueueItemGlobalWorkQueue( - __in PTHREAD_START_ROUTINE Function, - __in_opt PVOID Context + _In_ PTHREAD_START_ROUTINE Function, + _In_opt_ PVOID Context ) { if (PhBeginInitOnce(&PhGlobalWorkQueueInitOnce)) diff --git a/2.x/trunk/plugins-extra/AtomTablePlugin/AtomTablePlugin.vcxproj b/2.x/trunk/plugins-extra/AtomTablePlugin/AtomTablePlugin.vcxproj index 0d2f8c95f..235a7856d 100644 --- a/2.x/trunk/plugins-extra/AtomTablePlugin/AtomTablePlugin.vcxproj +++ b/2.x/trunk/plugins-extra/AtomTablePlugin/AtomTablePlugin.vcxproj @@ -64,7 +64,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true @@ -78,7 +77,7 @@ $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ AllRules.ruleset - AllRules.ruleset + NativeRecommendedRules.ruleset @@ -90,7 +89,6 @@ ProgramDatabase StdCall true - StreamingSIMDExtensions ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) @@ -111,7 +109,6 @@ ProgramDatabase StdCall true - NotSet ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) @@ -158,7 +155,6 @@ ProgramDatabase StdCall true - NotSet ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) diff --git a/2.x/trunk/plugins-extra/AtomTablePlugin/main.c b/2.x/trunk/plugins-extra/AtomTablePlugin/main.c index 0bc4f075a..a92bd8d52 100644 --- a/2.x/trunk/plugins-extra/AtomTablePlugin/main.c +++ b/2.x/trunk/plugins-extra/AtomTablePlugin/main.c @@ -26,6 +26,10 @@ #include "resource.h" #define ATOM_TABLE_MENUITEM 1000 +#define SETTING_PREFIX L"dmex.AtomTablePlugin" +#define SETTING_NAME_TREE_LIST_COLUMNS (SETTING_PREFIX L".TreeListColumns") +#define SETTING_NAME_WINDOW_POSITION (SETTING_PREFIX L".WindowPosition") +#define SETTING_NAME_WINDOW_SIZE (SETTING_PREFIX L".WindowSize") VOID NTAPI MenuItemCallback( __in_opt PVOID Parameter, @@ -61,7 +65,7 @@ LOGICAL DllMain( { PPH_PLUGIN_INFORMATION info; - PluginInstance = PhRegisterPlugin(L"dmex.AtomTablePlugin", Instance, &info); + PluginInstance = PhRegisterPlugin(SETTING_PREFIX, Instance, &info); if (!PluginInstance) return FALSE; @@ -87,9 +91,9 @@ LOGICAL DllMain( { static PH_SETTING_CREATE settings[] = { - { IntegerPairSettingType, L"AtomTableWindowPosition", L"350,350" }, - { IntegerPairSettingType, L"AtomTableWindowSize", L"510,380" }, - { StringSettingType, L"AtomTableListViewColumns", L"" } + { IntegerPairSettingType, SETTING_NAME_WINDOW_POSITION, L"350,350" }, + { IntegerPairSettingType, SETTING_NAME_WINDOW_SIZE, L"510,380" }, + { StringSettingType, SETTING_NAME_TREE_LIST_COLUMNS, L"" } }; PhAddSettings(settings, _countof(settings)); @@ -192,13 +196,12 @@ static VOID LoadAtomTable( VOID ) { - ULONG i = 0; PATOM_TABLE_INFORMATION atomTable = NULL; if (!NT_SUCCESS(PhEnumAtomTable(&atomTable))) return; - for (i = 0; i < atomTable->NumberOfAtoms; i++) + for (ULONG i = 0; i < atomTable->NumberOfAtoms; i++) { PATOM_BASIC_INFORMATION atomInfo = NULL; @@ -396,14 +399,14 @@ INT_PTR CALLBACK MainWindowDlgProc( PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); PhRegisterDialog(hwndDlg); - PhLoadWindowPlacementFromSetting(L"AtomTableWindowPosition", L"AtomTableWindowSize", hwndDlg); + PhLoadWindowPlacementFromSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); PhSetListViewStyle(ListViewWndHandle, FALSE, TRUE); PhSetControlTheme(ListViewWndHandle, L"explorer"); PhAddListViewColumn(ListViewWndHandle, 0, 0, 0, LVCFMT_LEFT, 370, L"Atom Name"); PhAddListViewColumn(ListViewWndHandle, 1, 1, 1, LVCFMT_LEFT, 70, L"Ref Count"); PhSetExtendedListView(ListViewWndHandle); - PhLoadListViewColumnsFromSetting(L"AtomTableListViewColumns", ListViewWndHandle); + PhLoadListViewColumnsFromSetting(SETTING_NAME_TREE_LIST_COLUMNS, ListViewWndHandle); LoadAtomTable(); } @@ -412,8 +415,8 @@ INT_PTR CALLBACK MainWindowDlgProc( PhLayoutManagerLayout(&LayoutManager); break; case WM_DESTROY: - PhSaveWindowPlacementToSetting(L"AtomTableWindowPosition", L"AtomTableWindowSize", hwndDlg); - PhSaveListViewColumnsToSetting(L"AtomTableListViewColumns", ListViewWndHandle); + PhSaveWindowPlacementToSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); + PhSaveListViewColumnsToSetting(SETTING_NAME_TREE_LIST_COLUMNS, ListViewWndHandle); PhDeleteLayoutManager(&LayoutManager); PhUnregisterDialog(hwndDlg); break; diff --git a/2.x/trunk/plugins-extra/AvgCpuPlugin/AvgCpuPlugin.vcxproj b/2.x/trunk/plugins-extra/AvgCpuPlugin/AvgCpuPlugin.vcxproj index 773e7655f..970b4f2bc 100644 --- a/2.x/trunk/plugins-extra/AvgCpuPlugin/AvgCpuPlugin.vcxproj +++ b/2.x/trunk/plugins-extra/AvgCpuPlugin/AvgCpuPlugin.vcxproj @@ -95,7 +95,6 @@ Disabled MultiThreadedDebugDLL StdCall - StreamingSIMDExtensions ../../sdk/include;%(AdditionalIncludeDirectories) @@ -111,7 +110,6 @@ ../../sdk/include MultiThreadedDebug StdCall - NotSet true diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc index b851a4f82..8598b70f0 100644 --- a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.rc @@ -69,8 +69,9 @@ CAPTION "DNS Resolver Cache" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Close",IDOK,269,160,50,14 - CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,5,312,152 - PUSHBUTTON "Flush",IDC_DNSCLEAR,7,160,50,14 + CONTROL "",IDC_DNSLIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,5,312,152 + PUSHBUTTON "Refresh",IDC_DNS_REFRESH,7,160,50,14 + PUSHBUTTON "Flush",IDC_DNS_CLEAR,62,160,50,14 END diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj index 6b596bebe..6c662adf1 100644 --- a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj @@ -64,7 +64,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true @@ -78,7 +77,7 @@ $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ AllRules.ruleset - AllRules.ruleset + NativeRecommendedRules.ruleset @@ -90,7 +89,6 @@ ProgramDatabase StdCall true - StreamingSIMDExtensions ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) @@ -111,7 +109,6 @@ ProgramDatabase StdCall true - NotSet ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) @@ -158,7 +155,6 @@ ProgramDatabase StdCall true - NotSet ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) @@ -175,6 +171,7 @@ + diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj.filters b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj.filters index 20f0eafe2..8ad7489c0 100644 --- a/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj.filters +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/DnsCachePlugin.vcxproj.filters @@ -18,6 +18,7 @@ Header Files + diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/main.c b/2.x/trunk/plugins-extra/DnsCachePlugin/main.c index 1fd1a2a9d..ee1cff536 100644 --- a/2.x/trunk/plugins-extra/DnsCachePlugin/main.c +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/main.c @@ -1,7 +1,8 @@ /* - * Dns Cache Plugin + * Process Hacker Extra Plugins - + * DNS Cache Plugin * - * Copyright (C) 2013 dmex + * Copyright (C) 2014 dmex * * This file is part of Process Hacker. * @@ -19,63 +20,7 @@ * along with Process Hacker. If not, see . */ -#define UPDATE_MENUITEM 1000 -#define INET_ADDRSTRLEN 22 -#define INET6_ADDRSTRLEN 65 - -#include -#include -#include "resource.h" - -#pragma comment(lib, "Ws2_32.lib") -#include -#include - -typedef struct _DNS_CACHE_ENTRY -{ - struct _DNS_CACHE_ENTRY* Next; // Pointer to next entry - LPCWSTR Name; // DNS Record Name - WORD Type; // DNS Record Type - WORD DataLength; // Not referenced - ULONG Flags; // DNS Record Flags -} DNS_CACHE_ENTRY, *PDNS_CACHE_ENTRY; - -typedef DNS_STATUS (WINAPI* _DnsGetCacheDataTable)( - __inout PDNS_CACHE_ENTRY* DnsCacheEntry - ); -typedef BOOL (WINAPI* _DnsFlushResolverCache)( - VOID - ); -typedef BOOL (WINAPI* _DnsFlushResolverCacheEntry)( - __in LPCWSTR Name - ); -typedef DNS_STATUS (WINAPI* _DnsQuery_W)( - __in LPCWSTR Name, - __in WORD Type, - __in DWORD Options, - __inout_opt PVOID Extra, - __out __maybenull PDNS_RECORD* QueryResults, - __out_opt __maybenull PVOID* Reserved - ); -typedef VOID (WINAPI* _DnsFree)( - __inout PVOID Data, - __in DNS_FREE_TYPE FreeType - ); - -VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ); -VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ); -INT_PTR CALLBACK DnsCacheDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam - ); +#include "main.h" static HINSTANCE DnsApiHandle; static _DnsQuery_W DnsQuery_I; @@ -91,110 +36,24 @@ static PH_CALLBACK_REGISTRATION PluginMenuItemCallbackRegistration; static PH_CALLBACK_REGISTRATION MainWindowShowingCallbackRegistration; static PH_CALLBACK_REGISTRATION PluginShowOptionsCallbackRegistration; -LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved - ) -{ - switch (Reason) - { - case DLL_PROCESS_ATTACH: - { - PPH_PLUGIN_INFORMATION info; - - PluginInstance = PhRegisterPlugin(L"ProcessHacker.DnsCachePlugin", Instance, &info); - - if (!PluginInstance) - return FALSE; - - info->DisplayName = L"DNS Cache Viewer"; - info->Author = L"dmex"; - info->Description = L"Plugin for viewing the DNS Resolver Cache via the Tools menu"; - info->HasOptions = FALSE; - - PhRegisterCallback( - PhGetGeneralCallback(GeneralCallbackMainWindowShowing), - MainWindowShowingCallback, - NULL, - &MainWindowShowingCallbackRegistration - ); - PhRegisterCallback( - PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem), - MenuItemCallback, - NULL, - &PluginMenuItemCallbackRegistration - ); - - { - static PH_SETTING_CREATE settings[] = - { - { IntegerPairSettingType, L"DnsCacheWindowPosition", L"350,350" }, - { IntegerPairSettingType, L"DnsCacheWindowSize", L"510,380" }, - { StringSettingType, L"DnsCacheListViewColumns", L"" } - }; - - PhAddSettings(settings, _countof(settings)); - } - } - break; - } - - return TRUE; -} - -static VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ) -{ - PhPluginAddMenuItem(PluginInstance, PH_MENU_ITEM_LOCATION_TOOLS, L"$", UPDATE_MENUITEM, L"Resolver Cache", NULL); -} - -static VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ) -{ - PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter; - - switch (menuItem->Id) - { - case UPDATE_MENUITEM: - { - DialogBox( - (HINSTANCE)PluginInstance->DllBase, - MAKEINTRESOURCE(IDD_DNSVIEW), - NULL, - DnsCacheDlgProc - ); - } - break; - } -} - static VOID EnumDnsCacheTable( __in HWND hwndDlg ) { - WSADATA wsaData; - PDNS_CACHE_ENTRY dnsCacheRecordPtr = NULL; + PDNS_CACHE_ENTRY dnsCacheDataTable = NULL; __try { - // Start Winsock (required for WSAAddressToString) - WSAStartup(WINSOCK_VERSION, &wsaData); - - if (!DnsGetCacheDataTable_I(&dnsCacheRecordPtr)) + if (!DnsGetCacheDataTable_I(&dnsCacheDataTable)) __leave; - while (dnsCacheRecordPtr) + while (dnsCacheDataTable) { PDNS_RECORD dnsQueryResultPtr = NULL; DNS_STATUS dnsStatus = DnsQuery_I( - dnsCacheRecordPtr->Name, - dnsCacheRecordPtr->Type, + dnsCacheDataTable->Name, + dnsCacheDataTable->Type, DNS_QUERY_NO_WIRE_QUERY | 32768, // Undocumented flags NULL, &dnsQueryResultPtr, @@ -203,67 +62,79 @@ static VOID EnumDnsCacheTable( if (dnsStatus == ERROR_SUCCESS) { - ULONG dnsRecordCount = 0; PDNS_RECORD dnsRecordPtr = dnsQueryResultPtr; while (dnsRecordPtr) { - INT itemIndex = 0; - SOCKADDR_IN sockaddr; - TCHAR ipAddrString[INET6_ADDRSTRLEN]; + INT itemIndex = MAXINT; ULONG ipAddrStringLength = INET6_ADDRSTRLEN; + TCHAR ipAddrString[INET6_ADDRSTRLEN] = { '\0' }; + + itemIndex = PhAddListViewItem(hwndDlg, MAXINT, + PhaFormatString(L"%s", dnsCacheDataTable->Name)->Buffer, + NULL + ); + + if (dnsRecordPtr->wType == DNS_TYPE_A) + { + IN_ADDR ipv4Address = { 0 }; - // Convert the Internet network address into a string in Internet standard dotted format. - sockaddr.sin_family = AF_INET; - sockaddr.sin_addr.s_addr = dnsRecordPtr->Data.A.IpAddress; - sockaddr.sin_port = htons(0); + ipv4Address.s_addr = dnsRecordPtr->Data.A.IpAddress; - // Add the item to the listview (it might be nameless)... - if (dnsRecordCount) - { - itemIndex = PhAddListViewItem(hwndDlg, MAXINT, - PhaFormatString(L"%s [%d]", dnsCacheRecordPtr->Name, dnsRecordCount)->Buffer, - NULL - ); + RtlIpv4AddressToString(&ipv4Address, ipAddrString); + + PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"A")->Buffer); + PhSetListViewSubItem(hwndDlg, itemIndex, 2, PhaFormatString(L"%s", ipAddrString)->Buffer); } - else + else if (dnsRecordPtr->wType == DNS_TYPE_AAAA) { - itemIndex = PhAddListViewItem(hwndDlg, MAXINT, - PhaFormatString(L"%s", dnsCacheRecordPtr->Name)->Buffer, - NULL + IN6_ADDR ipv6Address = { 0 }; + + memcpy_s( + ipv6Address.s6_addr, + sizeof(ipv6Address.s6_addr), + dnsRecordPtr->Data.AAAA.Ip6Address.IP6Byte, + sizeof(dnsRecordPtr->Data.AAAA.Ip6Address.IP6Byte) ); - } - PhSetListViewSubItem(hwndDlg, itemIndex, 2, PhaFormatString(L"%d", dnsRecordPtr->dwTtl)->Buffer); + RtlIpv6AddressToString(&ipv6Address, ipAddrString); - if (WSAAddressToString((SOCKADDR*)&sockaddr, sizeof(SOCKADDR_IN), NULL, ipAddrString, &ipAddrStringLength) != SOCKET_ERROR) + PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"AAAA")->Buffer); + PhSetListViewSubItem(hwndDlg, itemIndex, 2, PhaFormatString(L"%s", ipAddrString)->Buffer); + } + else if (dnsRecordPtr->wType == DNS_TYPE_PTR) { - PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"%s", ipAddrString)->Buffer); + PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"PTR")->Buffer); + PhSetListViewSubItem(hwndDlg, itemIndex, 2, PhaFormatString(L"%s", dnsRecordPtr->Data.PTR.pNameHost)->Buffer); } - else + else if (dnsRecordPtr->wType == DNS_TYPE_CNAME) { - //inet_ntoa(ipaddr)); - PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"Error %d", WSAGetLastError())->Buffer); + PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"CNAME")->Buffer); + PhSetListViewSubItem(hwndDlg, itemIndex, 2, PhaFormatString(L"%s", dnsRecordPtr->Data.CNAME.pNameHost)->Buffer); } + else + { + PhSetListViewSubItem(hwndDlg, itemIndex, 1, PhaFormatString(L"UNKNOWN")->Buffer); + PhSetListViewSubItem(hwndDlg, itemIndex, 2, PhaFormatString(L"")); + } + + PhSetListViewSubItem(hwndDlg, itemIndex, 3, PhaFormatString(L"%d", dnsRecordPtr->dwTtl)->Buffer); - dnsRecordCount++; dnsRecordPtr = dnsRecordPtr->pNext; } DnsFree_I(dnsQueryResultPtr, DnsFreeRecordList); } - dnsCacheRecordPtr = dnsCacheRecordPtr->Next; + dnsCacheDataTable = dnsCacheDataTable->Next; } } __finally { - if (dnsCacheRecordPtr) + if (dnsCacheDataTable) { - DnsFree_I(dnsCacheRecordPtr, DnsFreeRecordList); + DnsFree_I(dnsCacheDataTable, DnsFreeRecordList); } - - WSACleanup(); } } @@ -279,7 +150,7 @@ static PPH_STRING PhGetSelectedListViewItemText( if (index != -1) { - WCHAR textBuffer[MAX_PATH + 1]; + WCHAR textBuffer[MAX_PATH + 1] = { '\0' }; LVITEM item; item.mask = LVIF_TEXT; @@ -332,30 +203,30 @@ static VOID ShowStatusMenu( switch (id) { case ID_DNSENTRY_FLUSH: - { - INT lvItemIndex = PhFindListViewItemByFlags( - ListViewWndHandle, - -1, - LVNI_SELECTED - ); + { + INT lvItemIndex = PhFindListViewItemByFlags( + ListViewWndHandle, + -1, + LVNI_SELECTED + ); - if (lvItemIndex != -1) + if (lvItemIndex != -1) + { + if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage( + hwndDlg, + L"remove", + cacheEntryName->Buffer, + NULL, + FALSE + )) { - if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage( - hwndDlg, - L"remove", - cacheEntryName->Buffer, - NULL, - FALSE - )) + if (DnsFlushResolverCacheEntry_I(cacheEntryName->Buffer)) { - if (DnsFlushResolverCacheEntry_I(cacheEntryName->Buffer)) - { - ListView_DeleteItem(ListViewWndHandle, lvItemIndex); - } + ListView_DeleteItem(ListViewWndHandle, lvItemIndex); } } } + } break; } @@ -363,7 +234,7 @@ static VOID ShowStatusMenu( } } -INT_PTR CALLBACK DnsCacheDlgProc( +static INT_PTR CALLBACK DnsCacheDlgProc( __in HWND hwndDlg, __in UINT uMsg, __in WPARAM wParam, @@ -375,34 +246,35 @@ INT_PTR CALLBACK DnsCacheDlgProc( case WM_INITDIALOG: { PhCenterWindow(hwndDlg, PhMainWndHandle); - ListViewWndHandle = GetDlgItem(hwndDlg, IDC_LIST1); - - PhInitializeLayoutManager(&LayoutManager, hwndDlg); - PhAddLayoutItem(&LayoutManager, ListViewWndHandle, NULL, PH_ANCHOR_ALL); - PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_DNSCLEAR), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); - PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); - - PhRegisterDialog(hwndDlg); - PhLoadWindowPlacementFromSetting(L"DnsCacheWindowPosition", L"DnsCacheWindowSize", hwndDlg); - + ListViewWndHandle = GetDlgItem(hwndDlg, IDC_DNSLIST); + + PhRegisterDialog(hwndDlg); PhSetListViewStyle(ListViewWndHandle, FALSE, TRUE); PhSetControlTheme(ListViewWndHandle, L"explorer"); - PhAddListViewColumn(ListViewWndHandle, 0, 0, 0, LVCFMT_LEFT, 280, L"Name"); - PhAddListViewColumn(ListViewWndHandle, 1, 1, 1, LVCFMT_LEFT, 100, L"IP Address"); - PhAddListViewColumn(ListViewWndHandle, 2, 2, 2, LVCFMT_LEFT, 50, L"TTL"); + PhAddListViewColumn(ListViewWndHandle, 0, 0, 0, LVCFMT_LEFT, 280, L"Host Name"); + PhAddListViewColumn(ListViewWndHandle, 1, 1, 1, LVCFMT_LEFT, 70, L"Type"); + PhAddListViewColumn(ListViewWndHandle, 2, 2, 2, LVCFMT_LEFT, 100, L"IP Address"); + PhAddListViewColumn(ListViewWndHandle, 3, 3, 3, LVCFMT_LEFT, 50, L"TTL"); PhSetExtendedListView(ListViewWndHandle); - PhLoadListViewColumnsFromSetting(L"DnsCacheListViewColumns", ListViewWndHandle); - DnsApiHandle = LoadLibrary(TEXT("dnsapi.dll")); + PhInitializeLayoutManager(&LayoutManager, hwndDlg); + PhAddLayoutItem(&LayoutManager, ListViewWndHandle, NULL, PH_ANCHOR_ALL); + PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_DNS_REFRESH), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); + PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_DNS_CLEAR), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); + PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); + PhLoadWindowPlacementFromSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); + PhLoadListViewColumnsFromSetting(SETTING_NAME_COLUMNS, ListViewWndHandle); + + DnsApiHandle = LoadLibrary(L"dnsapi.dll"); if (DnsApiHandle) { DnsQuery_I = (_DnsQuery_W)GetProcAddress(DnsApiHandle, "DnsQuery_W"); DnsFree_I = (_DnsFree)GetProcAddress(DnsApiHandle, "DnsFree"); DnsGetCacheDataTable_I = (_DnsGetCacheDataTable)GetProcAddress(DnsApiHandle, "DnsGetCacheDataTable"); DnsFlushResolverCache_I = (_DnsFlushResolverCache)GetProcAddress(DnsApiHandle, "DnsFlushResolverCache"); - DnsFlushResolverCacheEntry_I = (_DnsFlushResolverCacheEntry)GetProcAddress(DnsApiHandle, "DnsFlushResolverCacheEntry_W"); + DnsFlushResolverCacheEntry_I = (_DnsFlushResolverCacheEntry)GetProcAddress(DnsApiHandle, "DnsFlushResolverCacheEntry_W"); } - + EnumDnsCacheTable(ListViewWndHandle); } break; @@ -414,8 +286,8 @@ INT_PTR CALLBACK DnsCacheDlgProc( DnsApiHandle = NULL; } - PhSaveWindowPlacementToSetting(L"DnsCacheWindowPosition", L"DnsCacheWindowSize", hwndDlg); - PhSaveListViewColumnsToSetting(L"DnsCacheListViewColumns", ListViewWndHandle); + PhSaveWindowPlacementToSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); + PhSaveListViewColumnsToSetting(SETTING_NAME_COLUMNS, ListViewWndHandle); PhDeleteLayoutManager(&LayoutManager); } break; @@ -428,7 +300,7 @@ INT_PTR CALLBACK DnsCacheDlgProc( { switch (LOWORD(wParam)) { - case IDC_DNSCLEAR: + case IDC_DNS_CLEAR: { if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage( hwndDlg, @@ -446,6 +318,10 @@ INT_PTR CALLBACK DnsCacheDlgProc( } } break; + case IDC_DNS_REFRESH: + ListView_DeleteAllItems(ListViewWndHandle); + EnumDnsCacheTable(ListViewWndHandle); + break; case IDCANCEL: case IDOK: EndDialog(hwndDlg, IDOK); @@ -471,4 +347,83 @@ INT_PTR CALLBACK DnsCacheDlgProc( } return FALSE; +} + +static VOID NTAPI MainWindowShowingCallback( + __in_opt PVOID Parameter, + __in_opt PVOID Context + ) +{ + PhPluginAddMenuItem(PluginInstance, PH_MENU_ITEM_LOCATION_TOOLS, L"$", DNSCACHE_MENUITEM, L"DNS Resolver Cache", NULL); +} + +static VOID NTAPI MenuItemCallback( + __in_opt PVOID Parameter, + __in_opt PVOID Context + ) +{ + PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter; + + switch (menuItem->Id) + { + case DNSCACHE_MENUITEM: + { + DialogBox( + (HINSTANCE)PluginInstance->DllBase, + MAKEINTRESOURCE(IDD_DNSVIEW), + NULL, + DnsCacheDlgProc + ); + } + break; + } +} + +LOGICAL DllMain( + __in HINSTANCE Instance, + __in ULONG Reason, + __reserved PVOID Reserved + ) +{ + switch (Reason) + { + case DLL_PROCESS_ATTACH: + { + PPH_PLUGIN_INFORMATION info; + PH_SETTING_CREATE settings[] = + { + { IntegerPairSettingType, SETTING_NAME_WINDOW_POSITION, L"350,350" }, + { IntegerPairSettingType, SETTING_NAME_WINDOW_SIZE, L"510,380" }, + { StringSettingType, SETTING_NAME_COLUMNS, L"" } + }; + + PluginInstance = PhRegisterPlugin(SETTING_PREFIX, Instance, &info); + + if (!PluginInstance) + return FALSE; + + info->DisplayName = L"DNS Cache Viewer"; + info->Author = L"dmex"; + info->Description = L"Plugin for viewing the DNS Resolver Cache via the Tools menu"; + info->HasOptions = FALSE; + + PhRegisterCallback( + PhGetGeneralCallback(GeneralCallbackMainWindowShowing), + MainWindowShowingCallback, + NULL, + &MainWindowShowingCallbackRegistration + ); + PhRegisterCallback( + PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem), + MenuItemCallback, + NULL, + &PluginMenuItemCallbackRegistration + ); + + PhAddSettings(settings, _countof(settings)); + } + break; + } + + return TRUE; } \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/main.h b/2.x/trunk/plugins-extra/DnsCachePlugin/main.h new file mode 100644 index 000000000..c6a3db448 --- /dev/null +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/main.h @@ -0,0 +1,84 @@ +/* + * Process Hacker Extra Plugins - + * DNS Cache Plugin + * + * Copyright (C) 2014 dmex + * + * This file is part of Process Hacker. + * + * Process Hacker is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Process Hacker is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Process Hacker. If not, see . + */ + +#ifndef _DNS_H_ +#define _DNS_H_ + +#define SETTING_PREFIX L"dmex.DnsCachePlugin" +#define SETTING_NAME_WINDOW_POSITION (SETTING_PREFIX L".WindowPosition") +#define SETTING_NAME_WINDOW_SIZE (SETTING_PREFIX L".WindowSize") +#define SETTING_NAME_COLUMNS (SETTING_PREFIX L".WindowColumns") + +#define DNSCACHE_MENUITEM 1000 +#define INET_ADDRSTRLEN 22 +#define INET6_ADDRSTRLEN 65 + +#define CINTERFACE +#define COBJMACROS +#include +#include +#include +#include "resource.h" + +#include +#include +#include +#include + +#pragma comment(lib, "Ws2_32.lib") + +typedef struct _DNS_CACHE_ENTRY +{ + struct _DNS_CACHE_ENTRY* Next; // Pointer to next entry + PCWSTR Name; // DNS Record Name + WORD Type; // DNS Record Type + WORD DataLength; // Not referenced + ULONG Flags; // DNS Record Flags +} DNS_CACHE_ENTRY, *PDNS_CACHE_ENTRY; + +typedef DNS_STATUS (WINAPI* _DnsGetCacheDataTable)( + __inout PDNS_CACHE_ENTRY* DnsCacheEntry + ); + +typedef BOOL (WINAPI* _DnsFlushResolverCache)( + VOID + ); + +typedef BOOL (WINAPI* _DnsFlushResolverCacheEntry)( + _In_ LPCWSTR Name + ); + +typedef DNS_STATUS (WINAPI* _DnsQuery_W)( + _In_ LPCWSTR Name, + _In_ WORD Type, + _In_ DWORD Options, + _Inout_opt_ PVOID Extra, + _Out_ _Maybenull_ PDNS_RECORD* QueryResults, + _Out_opt_ _Maybenull_ PVOID* Reserved + ); + +typedef VOID (WINAPI* _DnsFree)( + __inout PVOID Data, + _In_ _Deref_out_ DNS_FREE_TYPE FreeType + ); + +#endif \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/DnsCachePlugin/resource.h b/2.x/trunk/plugins-extra/DnsCachePlugin/resource.h index c9da9f35f..1285b9b16 100644 --- a/2.x/trunk/plugins-extra/DnsCachePlugin/resource.h +++ b/2.x/trunk/plugins-extra/DnsCachePlugin/resource.h @@ -4,13 +4,13 @@ // #define IDD_DNSVIEW 101 #define IDR_MAIN_MENU 111 -#define IDC_LIST1 1021 -#define IDC_DNSCLEAR 4355 +#define IDC_DNSLIST 1021 +#define IDC_DNS_REFRESH 4355 +#define IDC_DNS_CLEAR 4356 #define ID_DNSENTRY_FLUSH 40004 -#define ID_DNSENTRY_PROPERTIES 40005 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 112 diff --git a/2.x/trunk/plugins-extra/ExtraPlugins.sln b/2.x/trunk/plugins-extra/ExtraPlugins.sln index 24995d377..919fe5ef2 100644 --- a/2.x/trunk/plugins-extra/ExtraPlugins.sln +++ b/2.x/trunk/plugins-extra/ExtraPlugins.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HexPidPlugin", "HexPidPlugin\HexPidPlugin.vcxproj", "{50691784-4EB0-4B5E-B428-BD37E52F8D2E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AvgCpuPlugin", "AvgCpuPlugin\AvgCpuPlugin.vcxproj", "{A68DC3E8-5E2E-4883-A2A4-81F921458A9C}" @@ -13,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DnsCachePlugin", "DnsCacheP EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AtomTablePlugin", "AtomTablePlugin\AtomTablePlugin.vcxproj", "{12390643-F40D-411F-A2E8-BF85F90223DF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WaitChainPlugin", "WaitChainPlugin\WaitChainPlugin.vcxproj", "{D6EA1C23-4CBC-4CD5-931C-38C984722510}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -73,6 +77,14 @@ Global {12390643-F40D-411F-A2E8-BF85F90223DF}.Release|x64.ActiveCfg = Release|x64 {12390643-F40D-411F-A2E8-BF85F90223DF}.Release|x64.Build.0 = Release|x64 {12390643-F40D-411F-A2E8-BF85F90223DF}.Release|x64.Deploy.0 = Release|x64 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Debug|Win32.ActiveCfg = Debug|Win32 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Debug|Win32.Build.0 = Debug|Win32 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Debug|x64.ActiveCfg = Debug|x64 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Debug|x64.Build.0 = Debug|x64 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Release|Win32.ActiveCfg = Release|Win32 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Release|Win32.Build.0 = Release|Win32 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Release|x64.ActiveCfg = Release|x64 + {D6EA1C23-4CBC-4CD5-931C-38C984722510}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/2.x/trunk/plugins-extra/HexPidPlugin/HexPidPlugin.vcxproj b/2.x/trunk/plugins-extra/HexPidPlugin/HexPidPlugin.vcxproj index a6d7530b0..b802cf5c0 100644 --- a/2.x/trunk/plugins-extra/HexPidPlugin/HexPidPlugin.vcxproj +++ b/2.x/trunk/plugins-extra/HexPidPlugin/HexPidPlugin.vcxproj @@ -96,7 +96,6 @@ ../../sdk/include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL StdCall - StreamingSIMDExtensions true @@ -147,7 +146,6 @@ ../../sdk/include MultiThreaded StdCall - NotSet true diff --git a/2.x/trunk/plugins-extra/ROTViewerPlugin/ROTViewerPlugin.vcxproj b/2.x/trunk/plugins-extra/ROTViewerPlugin/ROTViewerPlugin.vcxproj index c8eae28b0..f959222c6 100644 --- a/2.x/trunk/plugins-extra/ROTViewerPlugin/ROTViewerPlugin.vcxproj +++ b/2.x/trunk/plugins-extra/ROTViewerPlugin/ROTViewerPlugin.vcxproj @@ -64,7 +64,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true @@ -78,7 +77,7 @@ $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ AllRules.ruleset - AllRules.ruleset + NativeRecommendedRules.ruleset @@ -90,7 +89,6 @@ ProgramDatabase StdCall true - StreamingSIMDExtensions ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) @@ -111,7 +109,6 @@ ProgramDatabase StdCall true - NotSet ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) @@ -158,7 +155,6 @@ ProgramDatabase StdCall true - NotSet ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) diff --git a/2.x/trunk/plugins-extra/ROTViewerPlugin/main.c b/2.x/trunk/plugins-extra/ROTViewerPlugin/main.c index 6b6c4f337..93f5870ea 100644 --- a/2.x/trunk/plugins-extra/ROTViewerPlugin/main.c +++ b/2.x/trunk/plugins-extra/ROTViewerPlugin/main.c @@ -1,7 +1,7 @@ /* * Running Object Table Plugin * - * Copyright (C) 2012 dmex + * Copyright (C) 2014 dmex * * This file is part of Process Hacker. * @@ -21,187 +21,124 @@ #include "main.h" -VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ); -VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ); -INT_PTR CALLBACK RotViewDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam - ); - -static HWND ListViewWndHandle; -static PH_LAYOUT_MANAGER LayoutManager; static PPH_PLUGIN PluginInstance; static PH_CALLBACK_REGISTRATION PluginMenuItemCallbackRegistration; static PH_CALLBACK_REGISTRATION MainWindowShowingCallbackRegistration; static PH_CALLBACK_REGISTRATION PluginShowOptionsCallbackRegistration; -LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved - ) -{ - switch (Reason) - { - case DLL_PROCESS_ATTACH: - { - PPH_PLUGIN_INFORMATION info; - - PluginInstance = PhRegisterPlugin(L"ProcessHacker.RunningObjectTable", Instance, &info); - - if (!PluginInstance) - return FALSE; - - info->DisplayName = L"RunningObjectTable Viewer"; - info->Author = L"dmex"; - info->Description = L"Plugin for viewing the RunningObjectTable via the Tools menu"; - info->HasOptions = FALSE; - - PhRegisterCallback( - PhGetGeneralCallback(GeneralCallbackMainWindowShowing), - MainWindowShowingCallback, - NULL, - &MainWindowShowingCallbackRegistration - ); - PhRegisterCallback( - PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem), - MenuItemCallback, - NULL, - &PluginMenuItemCallbackRegistration - ); - } - break; - } - - return TRUE; -} - -static VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ) -{ - PhPluginAddMenuItem(PluginInstance, PH_MENU_ITEM_LOCATION_TOOLS, L"$", ROT_TABLE_MENUITEM, L"Running Object Table", NULL); -} - -static VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context - ) -{ - PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter; - - switch (menuItem->Id) - { - case ROT_TABLE_MENUITEM: - { - DialogBox( - (HINSTANCE)PluginInstance->DllBase, - MAKEINTRESOURCE(IDD_ROTVIEW), - NULL, - RotViewDlgProc - ); - } - break; - } -} - -static VOID EnumRunningObjectTable( - __in HWND hwndDlg +static NTSTATUS EnumRunningObjectTable( + __in PVOID ThreadParam ) { - IRunningObjectTable* table = NULL; - IEnumMoniker* moniker = NULL; - IMoniker* pmkObjectNames = NULL; - IBindCtx* ctx = NULL; + IRunningObjectTable* iRunningObjectTable = NULL; + IEnumMoniker* iEnumMoniker = NULL; + IMoniker* iMoniker = NULL; + IBindCtx* iBindCtx = NULL; IMalloc* iMalloc = NULL; ULONG count = 0; - CoGetMalloc(1, &iMalloc); + HWND listViewHandle = (HWND)ThreadParam; + + if (!SUCCEEDED(CoGetMalloc(1, &iMalloc))) + return STATUS_INSUFFICIENT_RESOURCES; // Query the running object table address - if (SUCCEEDED(GetRunningObjectTable(0, &table))) + if (SUCCEEDED(GetRunningObjectTable(0, &iRunningObjectTable))) { // Enum the objects registered - if (SUCCEEDED(IRunningObjectTable_EnumRunning(table, &moniker))) + if (SUCCEEDED(IRunningObjectTable_EnumRunning(iRunningObjectTable, &iEnumMoniker))) { - while (IEnumMoniker_Next(moniker, 1, &pmkObjectNames, &count) == S_OK) + while (IEnumMoniker_Next(iEnumMoniker, 1, &iMoniker, &count) == S_OK) { - if (SUCCEEDED(CreateBindCtx(0, &ctx))) + if (SUCCEEDED(CreateBindCtx(0, &iBindCtx))) { - OLECHAR* name = NULL; + OLECHAR* displayName = NULL; // Query the object name - if (SUCCEEDED(IMoniker_GetDisplayName(pmkObjectNames, ctx, NULL, &name))) + if (SUCCEEDED(IMoniker_GetDisplayName(iMoniker, iBindCtx, NULL, &displayName))) { // Set the items name column - PhAddListViewItem(hwndDlg, MAXINT, name, NULL); + PhAddListViewItem(listViewHandle, MAXINT, displayName, NULL); // Free the object name - IMalloc_Free(iMalloc, name); + IMalloc_Free(iMalloc, displayName); } - IBindCtx_Release(ctx); - ctx = NULL; + IBindCtx_Release(iBindCtx); } - IEnumMoniker_Release(pmkObjectNames); - pmkObjectNames = NULL; + IEnumMoniker_Release(iMoniker); } - IEnumMoniker_Release(moniker); - moniker = NULL; + IEnumMoniker_Release(iEnumMoniker); } - IRunningObjectTable_Release(table); - table = NULL; + IRunningObjectTable_Release(iRunningObjectTable); } - IMalloc_Release(iMalloc); - iMalloc = NULL; + IMalloc_Release(iMalloc); + + return STATUS_SUCCESS; } -INT_PTR CALLBACK RotViewDlgProc( +static INT_PTR CALLBACK RotViewDlgProc( __in HWND hwndDlg, __in UINT uMsg, __in WPARAM wParam, __in LPARAM lParam ) { + PROT_WINDOW_CONTEXT context; + + if (uMsg == WM_INITDIALOG) + { + context = (PROT_WINDOW_CONTEXT)PhAllocate(sizeof(ROT_WINDOW_CONTEXT)); + SetProp(hwndDlg, L"Context", (HANDLE)context); + } + else + { + context = (PROT_WINDOW_CONTEXT)GetProp(hwndDlg, L"Context"); + + if (uMsg == WM_DESTROY) + { + PhSaveWindowPlacementToSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); + PhDeleteLayoutManager(&context->LayoutManager); + PhUnregisterDialog(hwndDlg); + RemoveProp(hwndDlg, L"Context"); + PhFree(context); + } + } + + if (!context) + return FALSE; + switch (uMsg) { case WM_INITDIALOG: { - ListViewWndHandle = GetDlgItem(hwndDlg, IDC_LIST1); - - PhCenterWindow(hwndDlg, PhMainWndHandle); - - PhSetListViewStyle(ListViewWndHandle, FALSE, TRUE); - PhSetControlTheme(ListViewWndHandle, L"explorer"); - PhAddListViewColumn(ListViewWndHandle, 0, 0, 0, LVCFMT_LEFT, 420, L"Display Name"); - PhSetExtendedListView(ListViewWndHandle); - - PhInitializeLayoutManager(&LayoutManager, hwndDlg); - PhAddLayoutItem(&LayoutManager, ListViewWndHandle, NULL, PH_ANCHOR_ALL); - PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDC_ROTREFRESH), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); - PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); - - EnumRunningObjectTable(ListViewWndHandle); + context->ListViewHandle = GetDlgItem(hwndDlg, IDC_LIST1); + + PhRegisterDialog(hwndDlg); + PhSetListViewStyle(context->ListViewHandle, FALSE, TRUE); + PhSetControlTheme(context->ListViewHandle, L"explorer"); + PhAddListViewColumn(context->ListViewHandle, 0, 0, 0, LVCFMT_LEFT, 420, L"Display Name"); + PhSetExtendedListView(context->ListViewHandle); + + PhInitializeLayoutManager(&context->LayoutManager, hwndDlg); + PhAddLayoutItem(&context->LayoutManager, context->ListViewHandle, NULL, PH_ANCHOR_ALL); + PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_ROTREFRESH), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); + PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); + PhLoadWindowPlacementFromSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); + + HANDLE threadHandle = PhCreateThread(0, EnumRunningObjectTable, context->ListViewHandle); + if (threadHandle) + { + NtClose(threadHandle); + } } break; case WM_SIZE: - PhLayoutManagerLayout(&LayoutManager); - break; - case WM_DESTROY: - PhDeleteLayoutManager(&LayoutManager); + PhLayoutManagerLayout(&context->LayoutManager); break; case WM_COMMAND: { @@ -209,8 +146,13 @@ INT_PTR CALLBACK RotViewDlgProc( { case IDC_ROTREFRESH: { - ListView_DeleteAllItems(ListViewWndHandle); - EnumRunningObjectTable(ListViewWndHandle); + ListView_DeleteAllItems(context->ListViewHandle); + + HANDLE threadHandle = PhCreateThread(0, EnumRunningObjectTable, context->ListViewHandle); + if (threadHandle) + { + NtClose(threadHandle); + } } break; case IDCANCEL: @@ -223,4 +165,85 @@ INT_PTR CALLBACK RotViewDlgProc( } return FALSE; +} + +static VOID NTAPI MenuItemCallback( + __in_opt PVOID Parameter, + __in_opt PVOID Context + ) +{ + PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter; + + switch (menuItem->Id) + { + case ROT_TABLE_MENUITEM: + { + DialogBox( + (HINSTANCE)PluginInstance->DllBase, + MAKEINTRESOURCE(IDD_ROTVIEW), + NULL, + RotViewDlgProc + ); + } + break; + } +} + +static VOID NTAPI MainWindowShowingCallback( + __in_opt PVOID Parameter, + __in_opt PVOID Context + ) +{ + PhPluginAddMenuItem(PluginInstance, PH_MENU_ITEM_LOCATION_TOOLS, L"$", ROT_TABLE_MENUITEM, L"Running Object Table", NULL); +} + +LOGICAL DllMain( + __in HINSTANCE Instance, + __in ULONG Reason, + __reserved PVOID Reserved + ) +{ + switch (Reason) + { + case DLL_PROCESS_ATTACH: + ; + { + PPH_PLUGIN_INFORMATION info; + + PluginInstance = PhRegisterPlugin(SETTING_PREFIX, Instance, &info); + + if (!PluginInstance) + return FALSE; + + info->DisplayName = L"RunningObjectTable Viewer"; + info->Author = L"dmex"; + info->Description = L"Plugin for viewing the RunningObjectTable via the Tools menu"; + info->HasOptions = FALSE; + + PhRegisterCallback( + PhGetGeneralCallback(GeneralCallbackMainWindowShowing), + MainWindowShowingCallback, + NULL, + &MainWindowShowingCallbackRegistration + ); + PhRegisterCallback( + PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem), + MenuItemCallback, + NULL, + &PluginMenuItemCallbackRegistration + ); + { + PH_SETTING_CREATE settings[] = + { + { IntegerPairSettingType, SETTING_NAME_WINDOW_POSITION, L"100,100" }, + { IntegerPairSettingType, SETTING_NAME_WINDOW_SIZE, L"490,340" } + }; + + PhAddSettings(settings, _countof(settings)); + } + } + break; + } + + return TRUE; } \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/ROTViewerPlugin/main.h b/2.x/trunk/plugins-extra/ROTViewerPlugin/main.h index c4a93b8e4..c569fa90d 100644 --- a/2.x/trunk/plugins-extra/ROTViewerPlugin/main.h +++ b/2.x/trunk/plugins-extra/ROTViewerPlugin/main.h @@ -19,23 +19,24 @@ * along with Process Hacker. If not, see . */ -#ifndef _ROTHEADER_ -#define _ROTHEADER_ - -#define CINTERFACE -#define COBJMACROS +#ifndef _ROT_H_ +#define _ROT_H_ #define ROT_TABLE_MENUITEM 1000 +#define SETTING_PREFIX L"dmex.RunningObjectTable" +#define SETTING_NAME_WINDOW_POSITION (SETTING_PREFIX L".WindowPosition") +#define SETTING_NAME_WINDOW_SIZE (SETTING_PREFIX L".WindowSize") +#define CINTERFACE +#define COBJMACROS #include "phdk.h" #include "phappresource.h" #include "resource.h" -INT_PTR CALLBACK PropDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam - ); +typedef struct _ROT_WINDOW_CONTEXT +{ + HWND ListViewHandle; + PH_LAYOUT_MANAGER LayoutManager; +} ROT_WINDOW_CONTEXT, *PROT_WINDOW_CONTEXT; -#endif _ROTHEADER_ \ No newline at end of file +#endif _ROT_H_ \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/SetCriticalPlugin/SetCriticalPlugin.vcxproj b/2.x/trunk/plugins-extra/SetCriticalPlugin/SetCriticalPlugin.vcxproj index c90e6e38c..0b869d7b6 100644 --- a/2.x/trunk/plugins-extra/SetCriticalPlugin/SetCriticalPlugin.vcxproj +++ b/2.x/trunk/plugins-extra/SetCriticalPlugin/SetCriticalPlugin.vcxproj @@ -111,7 +111,6 @@ ../../sdk/include MultiThreadedDebug StdCall - NotSet true diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/CHANGELOG.txt b/2.x/trunk/plugins-extra/WaitChainPlugin/CHANGELOG.txt new file mode 100644 index 000000000..46727fa1a --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/CHANGELOG.txt @@ -0,0 +1,4 @@ +1.0 + * Initial release + + diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.rc b/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.rc new file mode 100644 index 000000000..ba5c00d76 --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.rc @@ -0,0 +1,146 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000904b0" + BEGIN + VALUE "CompanyName", "dmex" + VALUE "FileDescription", "Wait Chain Traversal plugin for Process Hacker" + VALUE "FileVersion", "1.0.0.0" + VALUE "InternalName", "WaitChainPlugin" + VALUE "LegalCopyright", "Licensed under the GNU GPL, v3." + VALUE "OriginalFilename", "WaitChainPlugin.dll" + VALUE "ProductName", "Wait Chain Traversal plugin for Process Hacker" + VALUE "ProductVersion", "1.0.0.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_WCT_DIALOG DIALOGEX 0, 0, 333, 180 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_APPWINDOW +CAPTION "Wait Chain Traversal" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Windows",IDC_CUSTOM1,"PhTreeNew",WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 0x2,7,5,319,150,WS_EX_CLIENTEDGE + DEFPUSHBUTTON "Close",IDOK,277,160,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_WCT_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 326 + TOPMARGIN, 5 + BOTTOMMARGIN, 173 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAIN_MENU MENU +BEGIN + POPUP "Menu" + BEGIN + MENUITEM "Go to Process...", ID_MENU_GOTOPROCESS + MENUITEM "Go to Thread...", ID_MENU_GOTOTHREAD + END +END + +#endif // English resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (Australia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\0" +END + +3 TEXTINCLUDE +BEGIN + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (Australia) resources +///////////////////////////////////////////////////////////////////////////// + + diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.vcxproj b/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.vcxproj new file mode 100644 index 000000000..91c321180 --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + {D6EA1C23-4CBC-4CD5-931C-38C984722510} + WaitChainPlugin + Win32Proj + WaitChainPlugin + + + + DynamicLibrary + Unicode + true + v120 + + + DynamicLibrary + Unicode + v120 + + + DynamicLibrary + Unicode + true + v120 + + + DynamicLibrary + Unicode + v120 + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ + $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ + true + true + $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ + $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ + false + $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ + $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ + false + $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ + $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ + AllRules.ruleset + NativeRecommendedRules.ruleset + + + + Disabled + ../../sdk/include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + ProgramDatabase + StdCall + true + + + ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + ../../sdk/lib/i386;%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + + + + + Disabled + ../../sdk/include;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Level3 + ProgramDatabase + StdCall + true + + + ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + ../../sdk/lib/amd64;%(AdditionalLibraryDirectories) + true + Windows + MachineX64 + + + + + MaxSpeed + true + ../../sdk/include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreaded + true + Level3 + ProgramDatabase + StdCall + true + StreamingSIMDExtensions + + + ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + ../../sdk/lib/i386;%(AdditionalLibraryDirectories) + true + Windows + true + true + MachineX86 + true + + + + + MaxSpeed + true + ../../sdk/include;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreaded + true + Level3 + ProgramDatabase + StdCall + true + + + ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + ../../sdk/lib/amd64;%(AdditionalLibraryDirectories) + true + Windows + true + true + MachineX64 + true + + + + + + \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.vcxproj.filters b/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.vcxproj.filters new file mode 100644 index 000000000..455308113 --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/WaitChainPlugin.vcxproj.filters @@ -0,0 +1,43 @@ + + + + + {802108be-ae96-47c3-8d93-884ed6dd096a} + + + {3e65ffb8-3f3e-40d7-b3ca-d55cae8edb16} + + + {b98dd849-bbfe-4b41-8c48-f65680da5c00} + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/main.c b/2.x/trunk/plugins-extra/WaitChainPlugin/main.c new file mode 100644 index 000000000..f357140df --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/main.c @@ -0,0 +1,524 @@ +/* + * Process Hacker Extra Plugins - + * Wait Chain Traversal (WCT) Plugin + * + * Copyright (C) 2013 dmex + * + * This file is part of Process Hacker. + * + * Process Hacker is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Process Hacker is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Process Hacker. If not, see . + */ + +#include "main.h" + +// Wait Chain Traversal Documentation: +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms681622.aspx + +static PPH_PLUGIN PluginInstance; +static PH_CALLBACK_REGISTRATION PluginMenuItemCallbackRegistration; +static PH_CALLBACK_REGISTRATION ProcessMenuInitializingCallbackRegistration; +static PH_CALLBACK_REGISTRATION ThreadMenuInitializingCallbackRegistration; + +static BOOLEAN WaitChainRegisterCallbacks( + __inout PWCT_CONTEXT Context + ) +{ + PCOGETCALLSTATE coGetCallStateCallback = NULL; + PCOGETACTIVATIONSTATE coGetActivationStateCallback = NULL; + + Context->Ole32ModuleHandle = LoadLibrary(L"ole32.dll"); + if (!Context->Ole32ModuleHandle) + return FALSE; + + coGetCallStateCallback = (PCOGETCALLSTATE)GetProcAddress(Context->Ole32ModuleHandle, "CoGetCallState"); + if (!coGetCallStateCallback) + return FALSE; + + coGetActivationStateCallback = (PCOGETACTIVATIONSTATE)GetProcAddress(Context->Ole32ModuleHandle, "CoGetActivationState"); + if (!coGetActivationStateCallback) + return FALSE; + + RegisterWaitChainCOMCallback(coGetCallStateCallback, coGetActivationStateCallback); + return TRUE; +} + +static VOID WaitChainCheckThread( + __inout PWCT_CONTEXT Context, + __in HANDLE ThreadId + ) +{ + BOOL isDeadLocked = FALSE; + ULONG nodeInfoLength = WCT_MAX_NODE_COUNT; + WAITCHAIN_NODE_INFO nodeInfoArray[WCT_MAX_NODE_COUNT]; + PWCT_ROOT_NODE rootNode = NULL; + + memset(nodeInfoArray, 0, sizeof(nodeInfoArray)); + + // Retrieve the thread wait chain. + if (!GetThreadWaitChain( + Context->WctSessionHandle, + 0, + WCT_GETINFO_ALL_FLAGS, + HandleToUlong(ThreadId), + &nodeInfoLength, + nodeInfoArray, + &isDeadLocked + )) + { + return; + } + + // Check if the wait chain is too big for the array we passed in. + if (nodeInfoLength > WCT_MAX_NODE_COUNT) + nodeInfoLength = WCT_MAX_NODE_COUNT; + + TreeNew_SetRedraw(Context->TreeNewHandle, FALSE); + TreeNew_NodesStructured(Context->TreeNewHandle); + + for (ULONG i = 0; i < nodeInfoLength; i++) + { + WAITCHAIN_NODE_INFO wctNode = nodeInfoArray[i]; + + if (wctNode.ObjectType == WctThreadType) + { + rootNode = WeAddWindowNode(&Context->TreeContext); + + rootNode->WctInfo = wctNode; + rootNode->ThreadId = UlongToHandle(wctNode.ThreadObject.ThreadId); + rootNode->ThreadIdString = PhFormatString(L"%u", wctNode.ThreadObject.ThreadId); + rootNode->ProcessIdString = PhFormatString(L"%u", wctNode.ThreadObject.ProcessId); + rootNode->WaitTimeString = PhFormatString(L"%u", wctNode.ThreadObject.WaitTime); + rootNode->ContextSwitchesString = PhFormatString(L"%u", wctNode.ThreadObject.ContextSwitches); + rootNode->TimeoutString = PhFormatString(L"%I64d", wctNode.LockObject.Timeout.QuadPart); + + if (wctNode.LockObject.ObjectName[0] != '\0') + { + // -- ProcessID -- + //wctNode.LockObject.ObjectName[0] + // -- ThreadID -- + //wctNode.LockObject.ObjectName[2] + // -- Unknown -- + //wctNode.LockObject.ObjectName[4] + + if (PhIsDigitCharacter(wctNode.LockObject.ObjectName[0])) + { + rootNode->ObjectNameString = PhFormatString(L"%s", wctNode.LockObject.ObjectName); + } + //else + //{ + // rootNode->ObjectNameString = PhFormatString(L"[%u, %u]", + // wctNode.LockObject.ObjectName[0], + // wctNode.LockObject.ObjectName[2] + // ); + //} + } + + rootNode->Node.Expanded = TRUE; + rootNode->HasChildren = TRUE; + + // This is a root node. + PhAddItemList(Context->TreeContext.NodeRootList, rootNode); + } + else + { + WctAddChildWindowNode(&Context->TreeContext, rootNode, wctNode, isDeadLocked); + } + } + + TreeNew_SetRedraw(Context->TreeNewHandle, TRUE); + TreeNew_NodesStructured(Context->TreeNewHandle); +} + +static NTSTATUS WaitChainCallbackThread( + __in PVOID Parameter + ) +{ + NTSTATUS status = STATUS_SUCCESS; + PWCT_CONTEXT context = (PWCT_CONTEXT)Parameter; + + if (!WaitChainRegisterCallbacks(context)) + return NTSTATUS_FROM_WIN32(GetLastError()); + + // Synchronous WCT session + context->WctSessionHandle = OpenThreadWaitChainSession(0, NULL); + + if (context->WctSessionHandle == NULL) + return NTSTATUS_FROM_WIN32(GetLastError()); + + if (context->IsProcessItem) + { + PVOID processes = NULL; + PSYSTEM_PROCESS_INFORMATION process = NULL; + + if (!NT_SUCCESS(status = PhEnumProcesses(&processes))) + return status; + + process = PH_FIRST_PROCESS(processes); + + do + { + if (process->UniqueProcessId == context->ProcessItem->ProcessId) + { + for (ULONG i = 0; i < process->NumberOfThreads; i++) + { + WaitChainCheckThread(context, process->Threads[i].ClientId.UniqueThread); + } + } + } while (process = PH_NEXT_PROCESS(process)); + } + else + { + WaitChainCheckThread(context, context->ThreadItem->ThreadId); + } + + if (context->WctSessionHandle) + { + CloseThreadWaitChainSession(context->WctSessionHandle); + } + + if (context->Ole32ModuleHandle) + { + FreeLibrary(context->Ole32ModuleHandle); + } + + return status; +} + +static INT_PTR CALLBACK WaitChainDlgProc( + __in HWND hwndDlg, + __in UINT uMsg, + __in WPARAM wParam, + __in LPARAM lParam + ) +{ + PWCT_CONTEXT context = NULL; + + if (uMsg == WM_INITDIALOG) + { + context = (PWCT_CONTEXT)lParam; + SetProp(hwndDlg, L"Context", (HANDLE)context); + } + else + { + context = (PWCT_CONTEXT)GetProp(hwndDlg, L"Context"); + + if (uMsg == WM_DESTROY) + { + PhUnregisterDialog(hwndDlg); + PhSaveWindowPlacementToSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); + PhDeleteLayoutManager(&context->LayoutManager); + WtcDeleteWindowTree(&context->TreeContext); + + RemoveProp(hwndDlg, L"Context"); + PhFree(context); + } + } + + if (context == NULL) + return FALSE; + + switch (uMsg) + { + case WM_INITDIALOG: + { + HANDLE threadHandle = INVALID_HANDLE_VALUE; + + context->TreeNewHandle = GetDlgItem(hwndDlg, IDC_CUSTOM1); + + PhRegisterDialog(hwndDlg); + WtcInitializeWindowTree(hwndDlg, context->TreeNewHandle, &context->TreeContext); + PhInitializeLayoutManager(&context->LayoutManager, hwndDlg); + PhAddLayoutItem(&context->LayoutManager, context->TreeNewHandle, NULL, PH_ANCHOR_ALL); + PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); + PhLoadWindowPlacementFromSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg); + + if (threadHandle = PhCreateThread(0, (PUSER_THREAD_START_ROUTINE)WaitChainCallbackThread, (PVOID)context)) + NtClose(threadHandle); + } + break; + case WM_SIZE: + PhLayoutManagerLayout(&context->LayoutManager); + break; + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDCANCEL: + case IDOK: + EndDialog(hwndDlg, IDOK); + break; + case ID_WCTSHOWCONTEXTMENU: + { + POINT point; + HMENU menu; + HMENU subMenu; + PWCT_ROOT_NODE selectedNode = NULL; + PPH_PROCESS_NODE processNode = NULL; + + point.x = (SHORT)LOWORD(lParam); + point.y = (SHORT)HIWORD(lParam); + + if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) + { + menu = LoadMenu((HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDR_MAIN_MENU)); + subMenu = GetSubMenu(menu, 0); + SetMenuDefaultItem(subMenu, ID_MENU_PROPERTIES, FALSE); + + if (selectedNode->ThreadId > 0) + { + PhEnableMenuItem(subMenu, ID_MENU_GOTOTHREAD, TRUE); + PhEnableMenuItem(subMenu, ID_MENU_GOTOPROCESS, TRUE); + } + else + { + PhEnableMenuItem(subMenu, ID_MENU_GOTOTHREAD, FALSE); + PhEnableMenuItem(subMenu, ID_MENU_GOTOPROCESS, FALSE); + } + + TrackPopupMenu( + subMenu, + TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, + point.x, + point.y, + 0, + hwndDlg, + NULL + ); + + DestroyMenu(menu); + } + } + break; + case ID_MENU_GOTOPROCESS: + { + PWCT_ROOT_NODE selectedNode = NULL; + PPH_PROCESS_NODE processNode = NULL; + + if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) + { + ULONG processID = _wtol(selectedNode->ProcessIdString->Buffer); + + if (processNode = PhFindProcessNode(UlongToHandle(processID))) + { + ProcessHacker_SelectTabPage(PhMainWndHandle, 0); + PhSelectAndEnsureVisibleProcessNode(processNode); + } + } + } + break; + case ID_MENU_GOTOTHREAD: + { + PWCT_ROOT_NODE selectedNode = NULL; + PPH_PROCESS_ITEM processItem = NULL; + PPH_PROCESS_PROPCONTEXT propContext = NULL; + + if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) + { + ULONG processID = _wtol(selectedNode->ProcessIdString->Buffer); + + if (processItem = PhReferenceProcessItem(UlongToHandle(processID))) + { + if (propContext = PhCreateProcessPropContext(NULL, processItem)) + { + if (selectedNode->ThreadId) + { + PhSetSelectThreadIdProcessPropContext(propContext, selectedNode->ThreadId); + } + + PhShowProcessProperties(propContext); + PhDereferenceObject(propContext); + } + + PhDereferenceObject(processItem); + } + else + { + PhShowError(hwndDlg, L"The process does not exist."); + } + } + } + break; + case ID_MENU_COPY: + { + PPH_STRING text; + + text = PhGetTreeNewText(context->TreeNewHandle, 0); + PhSetClipboardStringEx(hwndDlg, text->Buffer, text->Length); + PhDereferenceObject(text); + } + break; + } + } + break; + } + + return FALSE; +} + +static VOID NTAPI MenuItemCallback( + __in_opt PVOID Parameter, + __in_opt PVOID Context + ) +{ + PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter; + + switch (menuItem->Id) + { + case IDD_WCT_MENUITEM: + { + DialogBoxParam( + (HINSTANCE)PluginInstance->DllBase, + MAKEINTRESOURCE(IDD_WCT_DIALOG), + NULL, + WaitChainDlgProc, + (LPARAM)menuItem->Context + ); + } + break; + } +} + +static VOID NTAPI ProcessMenuInitializingCallback( + __in_opt PVOID Parameter, + __in_opt PVOID Context + ) +{ + ULONG insertIndex = 0; + PWCT_CONTEXT context = NULL; + PPH_PLUGIN_MENU_INFORMATION menuInfo = NULL; + PPH_PROCESS_ITEM processItem = NULL; + PPH_EMENU_ITEM menuItem = NULL; + PPH_EMENU_ITEM miscMenuItem = NULL; + PPH_EMENU_ITEM wsMenuItem = NULL; + + menuInfo = (PPH_PLUGIN_MENU_INFORMATION)Parameter; + + if (menuInfo->u.Process.NumberOfProcesses == 1) + processItem = menuInfo->u.Process.Processes[0]; + else + { + processItem = NULL; + } + + if (processItem == NULL) + return; + + context = (PWCT_CONTEXT)PhAllocate(sizeof(WCT_CONTEXT)); + memset(context, 0, sizeof(WCT_CONTEXT)); + + context->IsProcessItem = TRUE; + context->ProcessItem = processItem; + + miscMenuItem = PhFindEMenuItem(menuInfo->Menu, 0, L"Miscellaneous", 0); + if (miscMenuItem) + { + menuItem = PhPluginCreateEMenuItem(PluginInstance, 0, IDD_WCT_MENUITEM, L"Wait Chain Traversal", context); + PhInsertEMenuItem(miscMenuItem, menuItem, -1); + + // Disable menu if current process selected. + if (processItem == NULL || processItem->ProcessId == NtCurrentProcessId()) + menuItem->Flags |= PH_EMENU_DISABLED; + } +} + +static VOID NTAPI ThreadMenuInitializingCallback( + __in_opt PVOID Parameter, + __in_opt PVOID Context + ) +{ + PWCT_CONTEXT context = NULL; + PPH_PLUGIN_MENU_INFORMATION menuInfo = NULL; + PPH_THREAD_ITEM threadItem = NULL; + PPH_EMENU_ITEM menuItem = NULL; + PPH_EMENU_ITEM miscMenuItem = NULL; + + menuInfo = (PPH_PLUGIN_MENU_INFORMATION)Parameter; + + if (menuInfo->u.Thread.NumberOfThreads == 1) + threadItem = menuInfo->u.Thread.Threads[0]; + else + threadItem = NULL; + + context = (PWCT_CONTEXT)PhAllocate(sizeof(WCT_CONTEXT)); + memset(context, 0, sizeof(WCT_CONTEXT)); + + context->IsProcessItem = FALSE; + context->ThreadItem = threadItem; + + miscMenuItem = PhFindEMenuItem(menuInfo->Menu, 0, L"Analyze", 0); + menuItem = PhPluginCreateEMenuItem(PluginInstance, 0, IDD_WCT_MENUITEM, L"Wait Chain Traversal", context); + PhInsertEMenuItem(miscMenuItem, menuItem, -1); + + // Disable menu if current process selected. + if (threadItem == NULL || menuInfo->u.Thread.ProcessId == NtCurrentProcessId()) + menuItem->Flags |= PH_EMENU_DISABLED; +} + +LOGICAL DllMain( + __in HINSTANCE Instance, + __in ULONG Reason, + __reserved PVOID Reserved + ) +{ + switch (Reason) + { + case DLL_PROCESS_ATTACH: + { + PPH_PLUGIN_INFORMATION info; + + PluginInstance = PhRegisterPlugin(SETTING_PREFIX, Instance, &info); + + if (!PluginInstance) + return FALSE; + + info->DisplayName = L"Wait Chain Traversal"; + info->Author = L"dmex"; + info->Description = L"Plugin for viewing the current thread or process Wait Chain"; + info->HasOptions = FALSE; + + PhRegisterCallback( + PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem), + MenuItemCallback, + NULL, + &PluginMenuItemCallbackRegistration + ); + PhRegisterCallback( + PhGetGeneralCallback(GeneralCallbackProcessMenuInitializing), + ProcessMenuInitializingCallback, + NULL, + &ProcessMenuInitializingCallbackRegistration + ); + PhRegisterCallback( + PhGetGeneralCallback(GeneralCallbackThreadMenuInitializing), + ThreadMenuInitializingCallback, + NULL, + &ThreadMenuInitializingCallbackRegistration + ); + + { + PH_SETTING_CREATE settings[] = + { + { StringSettingType, SETTING_NAME_TREE_LIST_COLUMNS, L"" }, + { IntegerPairSettingType, SETTING_NAME_WINDOW_POSITION, L"100,100" }, + { IntegerPairSettingType, SETTING_NAME_WINDOW_SIZE, L"690,540" } + }; + + PhAddSettings(settings, _countof(settings)); + } + } + break; + } + + return TRUE; +} \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/main.h b/2.x/trunk/plugins-extra/WaitChainPlugin/main.h new file mode 100644 index 000000000..19c9ac43c --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/main.h @@ -0,0 +1,66 @@ +/* + * Process Hacker Extra Plugins - + * Wait Chain Traversal (WCT) Plugin + * + * Copyright (C) 2014 dmex + * + * This file is part of Process Hacker. + * + * Process Hacker is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Process Hacker is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Process Hacker. If not, see . + */ + +#ifndef _WCT_H_ +#define _WCT_H_ + +#define CINTERFACE +#define COBJMACROS +#include +#include +#include +#include +#include +#include "resource.h" +#include "wndtree.h" + +#define IDD_WCT_MENUITEM 1000 +#define WCT_GETINFO_ALL_FLAGS (WCT_OUT_OF_PROC_FLAG|WCT_OUT_OF_PROC_COM_FLAG|WCT_OUT_OF_PROC_CS_FLAG|WCT_NETWORK_IO_FLAG) + +typedef struct _WCT_CONTEXT +{ + HWND DialogHandle; + HWND TreeNewHandle; + + HWND HighlightingWindow; + ULONG HighlightingWindowCount; + WCT_TREE_CONTEXT TreeContext; + PH_LAYOUT_MANAGER LayoutManager; + + BOOLEAN IsProcessItem; + PPH_THREAD_ITEM ThreadItem; + PPH_PROCESS_ITEM ProcessItem; + + HWCT WctSessionHandle; + HMODULE Ole32ModuleHandle; +} WCT_CONTEXT, *PWCT_CONTEXT; + +BOOLEAN WaitChainRegisterCallbacks( + __inout PWCT_CONTEXT Context + ); + +VOID WaitChainCheckThread( + __inout PWCT_CONTEXT Context, + __in HANDLE ThreadId + ); + +#endif \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/resource.h b/2.x/trunk/plugins-extra/WaitChainPlugin/resource.h new file mode 100644 index 000000000..2e9de5d16 --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/resource.h @@ -0,0 +1,23 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by WaitChainPlugin.rc +// +#define IDD_WCT_DIALOG 101 +#define IDR_MAIN_MENU 111 +#define IDC_CUSTOM1 1023 +#define ID_DNSENTRY_FLUSH 40004 +#define ID_MENU_GOTOTHREAD 40006 +#define ID_MENU_PROPERTIES 40007 +#define ID_MENU_COPY 40008 +#define ID_MENU_GOTOPROCESS 40009 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 112 +#define _APS_NEXT_COMMAND_VALUE 40010 +#define _APS_NEXT_CONTROL_VALUE 1024 +#define _APS_NEXT_SYMED_VALUE 108 +#endif +#endif diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/wndtree.c b/2.x/trunk/plugins-extra/WaitChainPlugin/wndtree.c new file mode 100644 index 000000000..3532a444d --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/wndtree.c @@ -0,0 +1,582 @@ +/* +* Process Hacker Extra Plugins - +* Wait Chain Traversal (WCT) Plugin +* +* Copyright (C) 2014 dmex +* +* This file is part of Process Hacker. +* +* Process Hacker is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Process Hacker is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Process Hacker. If not, see . +*/ + +#include "main.h" + +BOOLEAN WepWindowNodeHashtableCompareFunction( + __in PVOID Entry1, + __in PVOID Entry2 + ); + +ULONG WepWindowNodeHashtableHashFunction( + __in PVOID Entry + ); + +VOID WepDestroyWindowNode( + __in PWCT_ROOT_NODE WindowNode + ); + +BOOLEAN NTAPI WepWindowTreeNewCallback( + __in HWND hwnd, + __in PH_TREENEW_MESSAGE Message, + __in_opt PVOID Parameter1, + __in_opt PVOID Parameter2, + __in_opt PVOID Context + ); + +VOID WtcInitializeWindowTree( + __in HWND ParentWindowHandle, + __in HWND TreeNewHandle, + __out PWCT_TREE_CONTEXT Context + ) +{ + HWND hwnd; + PPH_STRING settings; + + memset(Context, 0, sizeof(WCT_TREE_CONTEXT)); + + Context->NodeHashtable = PhCreateHashtable( + sizeof(PWCT_ROOT_NODE), + (PPH_HASHTABLE_COMPARE_FUNCTION)WepWindowNodeHashtableCompareFunction, + (PPH_HASHTABLE_HASH_FUNCTION)WepWindowNodeHashtableHashFunction, + 100 + ); + Context->NodeList = PhCreateList(100); + Context->NodeRootList = PhCreateList(30); + + Context->ParentWindowHandle = ParentWindowHandle; + Context->TreeNewHandle = TreeNewHandle; + hwnd = TreeNewHandle; + PhSetControlTheme(hwnd, L"explorer"); + + TreeNew_SetCallback(hwnd, WepWindowTreeNewCallback, Context); + + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_TYPE, TRUE, L"Type", 80, PH_ALIGN_LEFT, 0, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_THREADID, TRUE, L"ThreadId", 50, PH_ALIGN_LEFT, 1, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_PROCESSID, TRUE, L"ProcessId", 50, PH_ALIGN_LEFT, 2, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_STATUS, TRUE, L"Status", 80, PH_ALIGN_LEFT, 3, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_CONTEXTSWITCH, TRUE, L"Context Switches", 70, PH_ALIGN_LEFT, 4, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_WAITTIME, TRUE, L"WaitTime", 60, PH_ALIGN_LEFT, 5, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_TIMEOUT, TRUE, L"Timeout", 60, PH_ALIGN_LEFT, 6, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_ALERTABLE, TRUE, L"Alertable", 50, PH_ALIGN_LEFT, 7, 0); + PhAddTreeNewColumn(hwnd, TREE_COLUMN_ITEM_NAME, TRUE, L"Name", 100, PH_ALIGN_LEFT, 8, 0); + + TreeNew_SetTriState(hwnd, TRUE); + TreeNew_SetSort(hwnd, 0, NoSortOrder); + + settings = PhGetStringSetting(SETTING_NAME_TREE_LIST_COLUMNS); + PhCmLoadSettings(hwnd, &settings->sr); + PhDereferenceObject(settings); +} + +VOID WtcDeleteWindowTree( + __in PWCT_TREE_CONTEXT Context + ) +{ + PPH_STRING settings; + + settings = PhCmSaveSettings(Context->TreeNewHandle); + PhSetStringSetting2(SETTING_NAME_TREE_LIST_COLUMNS, &settings->sr); + PhDereferenceObject(settings); + + for (ULONG i = 0; i < Context->NodeList->Count; i++) + { + WepDestroyWindowNode(Context->NodeList->Items[i]); + } + + PhDereferenceObject(Context->NodeHashtable); + PhDereferenceObject(Context->NodeList); + PhDereferenceObject(Context->NodeRootList); +} + +BOOLEAN WepWindowNodeHashtableCompareFunction( + __in PVOID Entry1, + __in PVOID Entry2 + ) +{ + PWCT_ROOT_NODE windowNode1 = *(PWCT_ROOT_NODE *)Entry1; + PWCT_ROOT_NODE windowNode2 = *(PWCT_ROOT_NODE *)Entry2; + + return windowNode1->Node.Index == windowNode2->Node.Index; +} + +ULONG WepWindowNodeHashtableHashFunction( + __in PVOID Entry + ) +{ + return (*(PWCT_ROOT_NODE*)Entry)->Node.Index; +} + +PWCT_ROOT_NODE WeAddWindowNode( + __inout PWCT_TREE_CONTEXT Context + ) +{ + PWCT_ROOT_NODE windowNode; + + windowNode = PhAllocate(sizeof(WCT_ROOT_NODE)); + memset(windowNode, 0, sizeof(WCT_ROOT_NODE)); + PhInitializeTreeNewNode(&windowNode->Node); + + memset(windowNode->TextCache, 0, sizeof(PH_STRINGREF) * TREE_COLUMN_ITEM_MAXIMUM); + windowNode->Node.TextCache = windowNode->TextCache; + windowNode->Node.TextCacheSize = TREE_COLUMN_ITEM_MAXIMUM; + + windowNode->Children = PhCreateList(1); + + PhAddEntryHashtable(Context->NodeHashtable, &windowNode); + PhAddItemList(Context->NodeList, windowNode); + + TreeNew_NodesStructured(Context->TreeNewHandle); + + return windowNode; +} + +VOID WctAddChildWindowNode( + __in PWCT_TREE_CONTEXT Context, + __in_opt PWCT_ROOT_NODE ParentNode, + __in WAITCHAIN_NODE_INFO WctNode, + __in BOOLEAN IsDeadLocked + ) +{ + PWCT_ROOT_NODE childNode = NULL; + + childNode = WeAddWindowNode(Context); + + childNode->WctInfo = WctNode; + childNode->IsDeadLocked = TRUE; + + childNode->ThreadId = UlongToHandle(WctNode.ThreadObject.ThreadId); + childNode->ProcessIdString = PhFormatString(L"%u", WctNode.ThreadObject.ProcessId); + childNode->ThreadIdString = PhFormatString(L"%u", WctNode.ThreadObject.ThreadId); + childNode->WaitTimeString = PhFormatString(L"%u", WctNode.ThreadObject.WaitTime); + childNode->ContextSwitchesString = PhFormatString(L"%u", WctNode.ThreadObject.ContextSwitches); + + if (WctNode.LockObject.ObjectName[0] != L'\0') + childNode->ObjectNameString = PhFormatString(L"%s", WctNode.LockObject.ObjectName); + + if (WctNode.LockObject.Timeout.QuadPart > 0) + { + SYSTEMTIME systemTime; + PPH_STRING dateString = NULL; + PPH_STRING timeString = NULL; + + PhLargeIntegerToLocalSystemTime(&systemTime, &WctNode.LockObject.Timeout); + + dateString = PhFormatDate(&systemTime, NULL); + timeString = PhFormatTime(&systemTime, NULL); + + childNode->TimeoutString = PhFormatString(L"%s %s", dateString->Buffer, timeString->Buffer); + + PhDereferenceObject(dateString); + PhDereferenceObject(timeString); + } + + if (ParentNode) + { + childNode->HasChildren = FALSE; + + // This is a child node. + childNode->Parent = ParentNode; + PhAddItemList(ParentNode->Children, childNode); + } + else + { + childNode->HasChildren = TRUE; + childNode->Node.Expanded = TRUE; + + // This is a root node. + PhAddItemList(Context->NodeRootList, childNode); + } +} + +PWCT_ROOT_NODE WeFindWindowNode( + __in PWCT_TREE_CONTEXT Context, + __in HWND WindowHandle + ) +{ + WCT_ROOT_NODE lookupWindowNode; + PWCT_ROOT_NODE lookupWindowNodePtr = &lookupWindowNode; + PWCT_ROOT_NODE *windowNode; + + lookupWindowNode.Node.Index = HandleToUlong(WindowHandle); + + windowNode = (PWCT_ROOT_NODE*)PhFindEntryHashtable( + Context->NodeHashtable, + &lookupWindowNodePtr + ); + + if (windowNode) + return *windowNode; + else + return NULL; +} + +VOID WeRemoveWindowNode( + __in PWCT_TREE_CONTEXT Context, + __in PWCT_ROOT_NODE WindowNode + ) +{ + ULONG index = 0; + + // Remove from hashtable/list and cleanup. + PhRemoveEntryHashtable(Context->NodeHashtable, &WindowNode); + + if ((index = PhFindItemList(Context->NodeList, WindowNode)) != -1) + { + PhRemoveItemList(Context->NodeList, index); + } + + WepDestroyWindowNode(WindowNode); + + TreeNew_NodesStructured(Context->TreeNewHandle); +} + +VOID WepDestroyWindowNode( + __in PWCT_ROOT_NODE WindowNode + ) +{ + PhDereferenceObject(WindowNode->Children); + + //if (WindowNode->TypeString) + // PhDereferenceObject(WindowNode->TypeString); + + //if (WindowNode->ThreadString) + // PhDereferenceObject(WindowNode->ThreadString); + + PhFree(WindowNode); +} + +BOOLEAN NTAPI WepWindowTreeNewCallback( + __in HWND hwnd, + __in PH_TREENEW_MESSAGE Message, + __in_opt PVOID Parameter1, + __in_opt PVOID Parameter2, + __in_opt PVOID Context + ) +{ + PWCT_TREE_CONTEXT context; + PWCT_ROOT_NODE node; + + context = Context; + + switch (Message) + { + case TreeNewGetChildren: + { + PPH_TREENEW_GET_CHILDREN getChildren = Parameter1; + + node = (PWCT_ROOT_NODE)getChildren->Node; + + if (context->TreeNewSortOrder == NoSortOrder) + { + if (!node) + { + getChildren->Children = (PPH_TREENEW_NODE *)context->NodeRootList->Items; + getChildren->NumberOfChildren = context->NodeRootList->Count; + } + else + { + getChildren->Children = (PPH_TREENEW_NODE *)node->Children->Items; + getChildren->NumberOfChildren = node->Children->Count; + } + } + else + { + if (!node) + { + getChildren->Children = (PPH_TREENEW_NODE *)context->NodeList->Items; + getChildren->NumberOfChildren = context->NodeList->Count; + } + } + } + return TRUE; + case TreeNewIsLeaf: + { + PPH_TREENEW_IS_LEAF isLeaf = (PPH_TREENEW_IS_LEAF)Parameter1; + + node = (PWCT_ROOT_NODE)isLeaf->Node; + + if (context->TreeNewSortOrder == NoSortOrder) + isLeaf->IsLeaf = !node->HasChildren; + else + isLeaf->IsLeaf = TRUE; + } + return TRUE; + case TreeNewGetCellText: + { + PPH_TREENEW_GET_CELL_TEXT getCellText = (PPH_TREENEW_GET_CELL_TEXT)Parameter1; + + node = (PWCT_ROOT_NODE)getCellText->Node; + + switch (getCellText->Id) + { + case TREE_COLUMN_ITEM_TYPE: + { + switch (node->WctInfo.ObjectType) + { + case WctCriticalSectionType: + PhInitializeStringRef(&getCellText->Text, L"CriticalSection"); + break; + case WctSendMessageType: + PhInitializeStringRef(&getCellText->Text, L"SendMessage"); + break; + case WctMutexType: + PhInitializeStringRef(&getCellText->Text, L"Mutex"); + break; + case WctAlpcType: + PhInitializeStringRef(&getCellText->Text, L"Alpc"); + break; + case WctComType: + PhInitializeStringRef(&getCellText->Text, L"Com"); + break; + case WctComActivationType: + PhInitializeStringRef(&getCellText->Text, L"ComActivation"); + break; + case WctProcessWaitType: + PhInitializeStringRef(&getCellText->Text, L"ProcWait"); + break; + case WctThreadType: + PhInitializeStringRef(&getCellText->Text, L"Thread"); + break; + case WctThreadWaitType: + PhInitializeStringRef(&getCellText->Text, L"ThreadWait"); + break; + case WctSocketIoType: + PhInitializeStringRef(&getCellText->Text, L"Socket I/O"); + break; + case WctSmbIoType: + PhInitializeStringRef(&getCellText->Text, L"SMB I/O"); + break; + case WctUnknownType: + case WctMaxType: + default: + PhInitializeStringRef(&getCellText->Text, L"Unknown"); + break; + } + } + break; + case TREE_COLUMN_ITEM_STATUS: + { + switch (node->WctInfo.ObjectStatus) + { + case WctStatusNoAccess: + PhInitializeStringRef(&getCellText->Text, L"No Access"); + break; + case WctStatusRunning: + PhInitializeStringRef(&getCellText->Text, L"Running"); + break; + case WctStatusBlocked: + PhInitializeStringRef(&getCellText->Text, L"Blocked"); + break; + case WctStatusPidOnly: + PhInitializeStringRef(&getCellText->Text, L"Pid Only"); + break; + case WctStatusPidOnlyRpcss: + PhInitializeStringRef(&getCellText->Text, L"Pid Only (Rpcss)"); + break; + case WctStatusOwned: + PhInitializeStringRef(&getCellText->Text, L"Owned"); + break; + case WctStatusNotOwned: + PhInitializeStringRef(&getCellText->Text, L"Not Owned"); + break; + case WctStatusAbandoned: + PhInitializeStringRef(&getCellText->Text, L"Abandoned"); + break; + case WctStatusError: + PhInitializeStringRef(&getCellText->Text, L"Error"); + break; + case WctStatusUnknown: + case WctStatusMax: + default: + PhInitializeStringRef(&getCellText->Text, L"Unknown"); + break; + } + } + break; + case TREE_COLUMN_ITEM_NAME: + getCellText->Text = PhGetStringRef(node->ObjectNameString); + break; + case TREE_COLUMN_ITEM_TIMEOUT: + getCellText->Text = PhGetStringRef(node->TimeoutString); + break; + case TREE_COLUMN_ITEM_ALERTABLE: + { + if (node->WctInfo.LockObject.Alertable) + { + PhInitializeStringRef(&getCellText->Text, L"true"); + } + else + { + PhInitializeStringRef(&getCellText->Text, L"false"); + } + } + break; + case TREE_COLUMN_ITEM_PROCESSID: + { + if (node->WctInfo.ObjectType == WctThreadType) + { + getCellText->Text = PhGetStringRef(node->ProcessIdString); + } + } + break; + case TREE_COLUMN_ITEM_THREADID: + { + if (node->WctInfo.ObjectType == WctThreadType) + { + getCellText->Text = PhGetStringRef(node->ThreadIdString); + } + } + break; + case TREE_COLUMN_ITEM_WAITTIME: + { + if (node->WctInfo.ObjectType == WctThreadType) + { + getCellText->Text = PhGetStringRef(node->WaitTimeString); + } + } + break; + case TREE_COLUMN_ITEM_CONTEXTSWITCH: + { + if (node->WctInfo.ObjectType == WctThreadType) + { + getCellText->Text = PhGetStringRef(node->ContextSwitchesString); + } + } + break; + default: + return FALSE; + } + + getCellText->Flags = TN_CACHE; + } + return TRUE; + case TreeNewGetNodeColor: + { + PPH_TREENEW_GET_NODE_COLOR getNodeColor = (PPH_TREENEW_GET_NODE_COLOR)Parameter1; + node = (PWCT_ROOT_NODE)getNodeColor->Node; + + if (node->IsDeadLocked) + { + getNodeColor->ForeColor = RGB(255, 0, 0); + } + + getNodeColor->Flags = TN_CACHE; + } + return TRUE; + case TreeNewSortChanged: + { + TreeNew_GetSort(hwnd, &context->TreeNewSortColumn, &context->TreeNewSortOrder); + // Force a rebuild to sort the items. + TreeNew_NodesStructured(hwnd); + } + return TRUE; + case TreeNewKeyDown: + case TreeNewLeftDoubleClick: + case TreeNewNodeExpanding: + return TRUE; + case TreeNewContextMenu: + { + PPH_TREENEW_MOUSE_EVENT mouseEvent = (PPH_TREENEW_MOUSE_EVENT)Parameter1; + + SendMessage(context->ParentWindowHandle, WM_COMMAND, ID_WCTSHOWCONTEXTMENU, MAKELONG(mouseEvent->Location.x, mouseEvent->Location.y)); + } + return TRUE; + case TreeNewHeaderRightClick: + { + PH_TN_COLUMN_MENU_DATA data; + + data.TreeNewHandle = hwnd; + data.MouseEvent = Parameter1; + data.DefaultSortColumn = 0; + data.DefaultSortOrder = AscendingSortOrder; + PhInitializeTreeNewColumnMenu(&data); + + data.Selection = PhShowEMenu(data.Menu, hwnd, PH_EMENU_SHOW_LEFTRIGHT | PH_EMENU_SHOW_NONOTIFY, + PH_ALIGN_LEFT | PH_ALIGN_TOP, data.MouseEvent->ScreenLocation.x, data.MouseEvent->ScreenLocation.y); + PhHandleTreeNewColumnMenu(&data); + PhDeleteTreeNewColumnMenu(&data); + } + return TRUE; + } + + return FALSE; +} + +VOID WeClearWindowTree( + __in PWCT_TREE_CONTEXT Context + ) +{ + ULONG i; + + for (i = 0; i < Context->NodeList->Count; i++) + WepDestroyWindowNode(Context->NodeList->Items[i]); + + PhClearHashtable(Context->NodeHashtable); + PhClearList(Context->NodeList); + PhClearList(Context->NodeRootList); +} + +PWCT_ROOT_NODE WeGetSelectedWindowNode( + __in PWCT_TREE_CONTEXT Context + ) +{ + PWCT_ROOT_NODE windowNode = NULL; + ULONG i; + + for (i = 0; i < Context->NodeList->Count; i++) + { + windowNode = Context->NodeList->Items[i]; + + if (windowNode->Node.Selected) + return windowNode; + } + + return NULL; +} + +VOID WeGetSelectedWindowNodes( + __in PWCT_TREE_CONTEXT Context, + __out PWCT_ROOT_NODE **Windows, + __out PULONG NumberOfWindows + ) +{ + PPH_LIST list; + ULONG i; + + list = PhCreateList(2); + + for (i = 0; i < Context->NodeList->Count; i++) + { + PWCT_ROOT_NODE node = (PWCT_ROOT_NODE)Context->NodeList->Items[i]; + + if (node->Node.Selected) + { + PhAddItemList(list, node); + } + } + + *Windows = PhAllocateCopy(list->Items, sizeof(PVOID) * list->Count); + *NumberOfWindows = list->Count; + + PhDereferenceObject(list); +} \ No newline at end of file diff --git a/2.x/trunk/plugins-extra/WaitChainPlugin/wndtree.h b/2.x/trunk/plugins-extra/WaitChainPlugin/wndtree.h new file mode 100644 index 000000000..e1cfb2ef1 --- /dev/null +++ b/2.x/trunk/plugins-extra/WaitChainPlugin/wndtree.h @@ -0,0 +1,126 @@ +/* +* Process Hacker Extra Plugins - +* Wait Chain Traversal (WCT) Plugin +* +* Copyright (C) 2014 dmex +* +* This file is part of Process Hacker. +* +* Process Hacker is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Process Hacker is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Process Hacker. If not, see . +*/ + +#ifndef WNDTREE_H +#define WNDTREE_H + +#define ID_WCTSHOWCONTEXTMENU 19000 +#define SETTING_PREFIX L"dmex.WaitChainPlugin" +#define SETTING_NAME_TREE_LIST_COLUMNS (SETTING_PREFIX L".TreeListColumns") +#define SETTING_NAME_WINDOW_POSITION (SETTING_PREFIX L".WindowPosition") +#define SETTING_NAME_WINDOW_SIZE (SETTING_PREFIX L".WindowSize") + +typedef enum _WCT_TREE_COLUMN_ITEM_NAME +{ + TREE_COLUMN_ITEM_TYPE = 0, + TREE_COLUMN_ITEM_STATUS = 1, + TREE_COLUMN_ITEM_NAME = 2, + TREE_COLUMN_ITEM_TIMEOUT = 3, + TREE_COLUMN_ITEM_ALERTABLE = 4, + TREE_COLUMN_ITEM_PROCESSID = 5, + TREE_COLUMN_ITEM_THREADID = 6, + TREE_COLUMN_ITEM_WAITTIME = 7, + TREE_COLUMN_ITEM_CONTEXTSWITCH = 8, + TREE_COLUMN_ITEM_MAXIMUM +} WCT_TREE_COLUMN_ITEM_NAME; + +typedef struct _WCT_ROOT_NODE +{ + PH_TREENEW_NODE Node; + struct _WCT_ROOT_NODE* Parent; + PPH_LIST Children; + BOOLEAN HasChildren; + + WAITCHAIN_NODE_INFO WctInfo; + PPH_STRING TimeoutString; + PPH_STRING ProcessIdString; + PPH_STRING ThreadIdString; + PPH_STRING WaitTimeString; + PPH_STRING ContextSwitchesString; + PPH_STRING ObjectNameString; + + BOOLEAN IsDeadLocked; + + HANDLE ThreadId; + + PH_STRINGREF TextCache[TREE_COLUMN_ITEM_MAXIMUM]; + WCHAR WindowHandleString[PH_PTR_STR_LEN_1]; +} WCT_ROOT_NODE, *PWCT_ROOT_NODE; + +typedef struct _WCT_TREE_CONTEXT +{ + HWND ParentWindowHandle; + HWND TreeNewHandle; + ULONG TreeNewSortColumn; + PH_SORT_ORDER TreeNewSortOrder; + + PPH_HASHTABLE NodeHashtable; + PPH_LIST NodeList; + PPH_LIST NodeRootList; +} WCT_TREE_CONTEXT, *PWCT_TREE_CONTEXT; + +VOID WtcInitializeWindowTree( + __in HWND ParentWindowHandle, + __in HWND TreeNewHandle, + __out PWCT_TREE_CONTEXT Context + ); + +VOID WtcDeleteWindowTree( + __in PWCT_TREE_CONTEXT Context + ); + +VOID WctAddChildWindowNode( + __in PWCT_TREE_CONTEXT Context, + __in_opt PWCT_ROOT_NODE ParentNode, + __in WAITCHAIN_NODE_INFO WctNode, + __in BOOLEAN IsDeadLocked + ); + +PWCT_ROOT_NODE WeAddWindowNode( + __inout PWCT_TREE_CONTEXT Context + ); + +PWCT_ROOT_NODE WeFindWindowNode( + __in PWCT_TREE_CONTEXT Context, + __in HWND WindowHandle + ); + +VOID WeRemoveWindowNode( + __in PWCT_TREE_CONTEXT Context, + __in PWCT_ROOT_NODE WindowNode + ); + +VOID WeClearWindowTree( + __in PWCT_TREE_CONTEXT Context + ); + +PWCT_ROOT_NODE WeGetSelectedWindowNode( + __in PWCT_TREE_CONTEXT Context + ); + +VOID WeGetSelectedWindowNodes( + __in PWCT_TREE_CONTEXT Context, + __out PWCT_ROOT_NODE **Windows, + __out PULONG NumberOfWindows + ); + +#endif diff --git a/2.x/trunk/plugins/DotNetTools/CHANGELOG.txt b/2.x/trunk/plugins/DotNetTools/CHANGELOG.txt index 3ad266b8a..286e06181 100644 --- a/2.x/trunk/plugins/DotNetTools/CHANGELOG.txt +++ b/2.x/trunk/plugins/DotNetTools/CHANGELOG.txt @@ -1,3 +1,6 @@ +1.3 + * Improved .NET assembly enumeration timeout handling + 1.2 * Fixed inaccurate stack traces for certain .NET programs diff --git a/2.x/trunk/plugins/DotNetTools/DotNetTools.rc b/2.x/trunk/plugins/DotNetTools/DotNetTools.rc index db1b5a118..62310515f 100644 Binary files a/2.x/trunk/plugins/DotNetTools/DotNetTools.rc and b/2.x/trunk/plugins/DotNetTools/DotNetTools.rc differ diff --git a/2.x/trunk/plugins/DotNetTools/DotNetTools.vcxproj b/2.x/trunk/plugins/DotNetTools/DotNetTools.vcxproj index 43289c465..afe3448e4 100644 --- a/2.x/trunk/plugins/DotNetTools/DotNetTools.vcxproj +++ b/2.x/trunk/plugins/DotNetTools/DotNetTools.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/DotNetTools/asmpage.c b/2.x/trunk/plugins/DotNetTools/asmpage.c index fbb5a2701..143a72940 100644 --- a/2.x/trunk/plugins/DotNetTools/asmpage.c +++ b/2.x/trunk/plugins/DotNetTools/asmpage.c @@ -100,22 +100,22 @@ typedef struct _FLAG_DEFINITION } FLAG_DEFINITION, *PFLAG_DEFINITION; typedef ULONG (__stdcall *_EnableTraceEx)( - __in LPCGUID ProviderId, - __in_opt LPCGUID SourceId, - __in TRACEHANDLE TraceHandle, - __in ULONG IsEnabled, - __in UCHAR Level, - __in ULONGLONG MatchAnyKeyword, - __in ULONGLONG MatchAllKeyword, - __in ULONG EnableProperty, - __in_opt PEVENT_FILTER_DESCRIPTOR EnableFilterDesc + _In_ LPCGUID ProviderId, + _In_opt_ LPCGUID SourceId, + _In_ TRACEHANDLE TraceHandle, + _In_ ULONG IsEnabled, + _In_ UCHAR Level, + _In_ ULONGLONG MatchAnyKeyword, + _In_ ULONGLONG MatchAllKeyword, + _In_ ULONG EnableProperty, + _In_opt_ PEVENT_FILTER_DESCRIPTOR EnableFilterDesc ); INT_PTR CALLBACK DotNetAsmPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static UNICODE_STRING DotNetLoggerName = RTL_CONSTANT_STRING(L"PhDnLogger"); @@ -174,7 +174,7 @@ static FLAG_DEFINITION StartupFlagsMap[] = }; VOID AddAsmPageToPropContext( - __in PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext + _In_ PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext ) { PhAddProcessPropPage( @@ -184,9 +184,9 @@ VOID AddAsmPageToPropContext( } PPH_STRING FlagsToString( - __in ULONG Flags, - __in PFLAG_DEFINITION Map, - __in ULONG SizeOfMap + _In_ ULONG Flags, + _In_ PFLAG_DEFINITION Map, + _In_ ULONG SizeOfMap ) { PH_STRING_BUILDER sb; @@ -210,7 +210,7 @@ PPH_STRING FlagsToString( } PDNA_NODE AddNode( - __inout PASMPAGE_CONTEXT Context + _Inout_ PASMPAGE_CONTEXT Context ) { PDNA_NODE node; @@ -231,7 +231,7 @@ PDNA_NODE AddNode( } VOID DestroyNode( - __in PDNA_NODE Node + _In_ PDNA_NODE Node ) { PhDereferenceObject(Node->Children); @@ -258,8 +258,8 @@ VOID DestroyNode( } PDNA_NODE AddFakeClrNode( - __in PASMPAGE_CONTEXT Context, - __in PWSTR DisplayName + _In_ PASMPAGE_CONTEXT Context, + _In_ PWSTR DisplayName ) { PDNA_NODE node; @@ -277,8 +277,8 @@ PDNA_NODE AddFakeClrNode( } PDNA_NODE FindClrNode( - __in PASMPAGE_CONTEXT Context, - __in USHORT ClrInstanceID + _In_ PASMPAGE_CONTEXT Context, + _In_ USHORT ClrInstanceID ) { ULONG i; @@ -295,8 +295,8 @@ PDNA_NODE FindClrNode( } PDNA_NODE FindAppDomainNode( - __in PDNA_NODE ClrNode, - __in ULONG64 AppDomainID + _In_ PDNA_NODE ClrNode, + _In_ ULONG64 AppDomainID ) { ULONG i; @@ -313,8 +313,8 @@ PDNA_NODE FindAppDomainNode( } PDNA_NODE FindAssemblyNode( - __in PDNA_NODE AppDomainNode, - __in ULONG64 AssemblyID + _In_ PDNA_NODE AppDomainNode, + _In_ ULONG64 AssemblyID ) { ULONG i; @@ -331,8 +331,8 @@ PDNA_NODE FindAssemblyNode( } PDNA_NODE FindAssemblyNode2( - __in PDNA_NODE ClrNode, - __in ULONG64 AssemblyID + _In_ PDNA_NODE ClrNode, + _In_ ULONG64 AssemblyID ) { ULONG i; @@ -355,8 +355,8 @@ PDNA_NODE FindAssemblyNode2( } static int __cdecl AssemblyNodeNameCompareFunction( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PDNA_NODE node1 = *(PDNA_NODE *)elem1; @@ -366,11 +366,11 @@ static int __cdecl AssemblyNodeNameCompareFunction( } BOOLEAN NTAPI DotNetAsmTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PASMPAGE_CONTEXT context; @@ -482,9 +482,9 @@ BOOLEAN NTAPI DotNetAsmTreeNewCallback( } ULONG StartDotNetTrace( - __in PASMPAGE_CONTEXT Context, - __out PTRACEHANDLE SessionHandle, - __out PEVENT_TRACE_PROPERTIES *Properties + _In_ PASMPAGE_CONTEXT Context, + _Out_ PTRACEHANDLE SessionHandle, + _Out_ PEVENT_TRACE_PROPERTIES *Properties ) { ULONG result; @@ -538,14 +538,14 @@ ULONG StartDotNetTrace( } ULONG NTAPI DotNetBufferCallback( - __in PEVENT_TRACE_LOGFILE Buffer + _In_ PEVENT_TRACE_LOGFILE Buffer ) { return TRUE; } VOID NTAPI DotNetEventCallback( - __in PEVENT_RECORD EventRecord + _In_ PEVENT_RECORD EventRecord ) { PASMPAGE_CONTEXT context = EventRecord->UserContext; @@ -791,7 +791,7 @@ VOID NTAPI DotNetEventCallback( } ULONG ProcessDotNetTrace( - __in PASMPAGE_CONTEXT Context + _In_ PASMPAGE_CONTEXT Context ) { ULONG result; @@ -823,8 +823,8 @@ ULONG ProcessDotNetTrace( } ULONG UpdateDotNetTraceInfo( - __in PASMPAGE_CONTEXT Context, - __in BOOLEAN ClrV2 + _In_ PASMPAGE_CONTEXT Context, + _In_ BOOLEAN ClrV2 ) { static _EnableTraceEx EnableTraceEx_I = NULL; @@ -870,7 +870,7 @@ ULONG UpdateDotNetTraceInfo( } NTSTATUS UpdateDotNetTraceInfoThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PASMPAGE_CONTEXT context = Parameter; @@ -881,12 +881,13 @@ NTSTATUS UpdateDotNetTraceInfoThreadStart( } ULONG UpdateDotNetTraceInfoWithTimeout( - __in PASMPAGE_CONTEXT Context, - __in BOOLEAN ClrV2, - __in_opt PLARGE_INTEGER Timeout + _In_ PASMPAGE_CONTEXT Context, + _In_ BOOLEAN ClrV2, + _In_opt_ PLARGE_INTEGER Timeout ) { HANDLE threadHandle; + BOOLEAN timeout = FALSE; // ProcessDotNetTrace is not guaranteed to complete within any period of time, because // the target process might terminate before it writes the DCStartComplete_V1 event. @@ -908,6 +909,7 @@ ULONG UpdateDotNetTraceInfoWithTimeout( if (_InterlockedExchange(&Context->TraceHandleActive, 0) == 1) { CloseTrace(Context->TraceHandle); + timeout = TRUE; } NtWaitForSingleObject(threadHandle, FALSE, NULL); @@ -915,14 +917,35 @@ ULONG UpdateDotNetTraceInfoWithTimeout( NtClose(threadHandle); + if (timeout) + return ERROR_TIMEOUT; + return Context->TraceResult; } +BOOLEAN IsProcessSuspended( + _In_ HANDLE ProcessId + ) +{ + PVOID processes; + PSYSTEM_PROCESS_INFORMATION process; + + if (NT_SUCCESS(PhEnumProcesses(&processes))) + { + if (process = PhFindProcessInformation(processes, ProcessId)) + return PhGetProcessIsSuspended(process); + + PhFree(processes); + } + + return FALSE; +} + INT_PTR CALLBACK DotNetAsmPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -981,31 +1004,75 @@ INT_PTR CALLBACK DotNetAsmPageDlgProc( SetCursor(LoadCursor(NULL, IDC_WAIT)); - if (context->ClrVersions & PH_CLR_VERSION_1_0) + if ( + !IsProcessSuspended(processItem->ProcessId) || + PhShowMessage(hwndDlg, MB_ICONWARNING | MB_YESNO, L".NET assembly enumeration may not work properly because the process is currently suspended. Do you want to continue?") == IDYES + ) { - AddFakeClrNode(context, L"CLR v1.0.3705"); // what PE displays - } + BOOLEAN timeoutReached = FALSE; + BOOLEAN nonClrNode = FALSE; + ULONG i; - if (context->ClrVersions & PH_CLR_VERSION_1_1) - { - AddFakeClrNode(context, L"CLR v1.1.4322"); - } + if (context->ClrVersions & PH_CLR_VERSION_1_0) + { + AddFakeClrNode(context, L"CLR v1.0.3705"); // what PE displays + } + + if (context->ClrVersions & PH_CLR_VERSION_1_1) + { + AddFakeClrNode(context, L"CLR v1.1.4322"); + } - timeout.QuadPart = -10 * PH_TIMEOUT_SEC; + timeout.QuadPart = -10 * PH_TIMEOUT_SEC; - if (context->ClrVersions & PH_CLR_VERSION_2_0) - { - context->ClrV2Node = AddFakeClrNode(context, L"CLR v2.0.50727"); - result = UpdateDotNetTraceInfoWithTimeout(context, TRUE, &timeout); - } + if (context->ClrVersions & PH_CLR_VERSION_2_0) + { + context->ClrV2Node = AddFakeClrNode(context, L"CLR v2.0.50727"); + result = UpdateDotNetTraceInfoWithTimeout(context, TRUE, &timeout); + + if (result == ERROR_TIMEOUT) + { + timeoutReached = TRUE; + result = ERROR_SUCCESS; + } + } + + if (context->ClrVersions & PH_CLR_VERSION_4_ABOVE) + { + result = UpdateDotNetTraceInfoWithTimeout(context, FALSE, &timeout); + + if (result == ERROR_TIMEOUT) + { + timeoutReached = TRUE; + result = ERROR_SUCCESS; + } + } + + TreeNew_NodesStructured(tnHandle); + + // If we reached the timeout, check whether we got any data back. + if (timeoutReached) + { + for (i = 0; i < context->NodeList->Count; i++) + { + PDNA_NODE node = context->NodeList->Items[i]; - if (context->ClrVersions & PH_CLR_VERSION_4_ABOVE) + if (node->Type != DNA_TYPE_CLR) + { + nonClrNode = TRUE; + break; + } + } + + if (!nonClrNode) + result = ERROR_TIMEOUT; + } + } + else { - result = UpdateDotNetTraceInfoWithTimeout(context, FALSE, &timeout); + result = ERROR_INSTALL_SUSPEND; } - TreeNew_NodesStructured(tnHandle); - TreeNew_SetRedraw(tnHandle, TRUE); SetCursor(LoadCursor(NULL, IDC_ARROW)); @@ -1018,6 +1085,14 @@ INT_PTR CALLBACK DotNetAsmPageDlgProc( { SetDlgItemText(hwndDlg, IDC_ERROR, L"Unable to start the event tracing session. Make sure Process Hacker is running with administrative privileges."); } + else if (result == ERROR_INSTALL_SUSPEND) + { + SetDlgItemText(hwndDlg, IDC_ERROR, L"Unable to start the event tracing session because the process is suspended."); + } + else if (result == ERROR_TIMEOUT) + { + SetDlgItemText(hwndDlg, IDC_ERROR, L"The event tracing session timed out."); + } else { SetDlgItemText(hwndDlg, IDC_ERROR, diff --git a/2.x/trunk/plugins/DotNetTools/clrsup.c b/2.x/trunk/plugins/DotNetTools/clrsup.c index e0b126411..08514f56a 100644 --- a/2.x/trunk/plugins/DotNetTools/clrsup.c +++ b/2.x/trunk/plugins/DotNetTools/clrsup.c @@ -45,7 +45,7 @@ static ICLRDataTargetVtbl DnCLRDataTarget_VTable = }; PCLR_PROCESS_SUPPORT CreateClrProcessSupport( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { PCLR_PROCESS_SUPPORT support; @@ -71,7 +71,7 @@ PCLR_PROCESS_SUPPORT CreateClrProcessSupport( } VOID FreeClrProcessSupport( - __in PCLR_PROCESS_SUPPORT Support + _In_ PCLR_PROCESS_SUPPORT Support ) { IXCLRDataProcess_Release(Support->DataProcess); @@ -79,9 +79,9 @@ VOID FreeClrProcessSupport( } PPH_STRING GetRuntimeNameByAddressClrProcess( - __in PCLR_PROCESS_SUPPORT Support, - __in ULONG64 Address, - __out_opt PULONG64 Displacement + _In_ PCLR_PROCESS_SUPPORT Support, + _In_ ULONG64 Address, + _Out_opt_ PULONG64 Displacement ) { PPH_STRING buffer; @@ -139,7 +139,7 @@ PPH_STRING GetRuntimeNameByAddressClrProcess( } PPH_STRING GetNameXClrDataAppDomain( - __in PVOID AppDomain + _In_ PVOID AppDomain ) { IXCLRDataAppDomain *appDomain; @@ -180,7 +180,7 @@ PPH_STRING GetNameXClrDataAppDomain( } PVOID LoadMscordacwks( - __in BOOLEAN IsClrV4 + _In_ BOOLEAN IsClrV4 ) { PVOID dllBase; @@ -217,9 +217,9 @@ PVOID LoadMscordacwks( } HRESULT CreateXCLRDataProcess( - __in HANDLE ProcessId, - __in ICLRDataTarget *Target, - __out struct IXCLRDataProcess **DataProcess + _In_ HANDLE ProcessId, + _In_ ICLRDataTarget *Target, + _Out_ struct IXCLRDataProcess **DataProcess ) { ULONG flags; @@ -276,7 +276,7 @@ HRESULT CreateXCLRDataProcess( } ICLRDataTarget *DnCLRDataTarget_Create( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ) { DnCLRDataTarget *dataTarget; @@ -308,9 +308,9 @@ ICLRDataTarget *DnCLRDataTarget_Create( } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_QueryInterface( - __in ICLRDataTarget *This, - __in REFIID Riid, - __out PVOID *Object + _In_ ICLRDataTarget *This, + _In_ REFIID Riid, + _Out_ PVOID *Object ) { if ( @@ -328,7 +328,7 @@ HRESULT STDMETHODCALLTYPE DnCLRDataTarget_QueryInterface( } ULONG STDMETHODCALLTYPE DnCLRDataTarget_AddRef( - __in ICLRDataTarget *This + _In_ ICLRDataTarget *This ) { DnCLRDataTarget *this = (DnCLRDataTarget *)This; @@ -339,7 +339,7 @@ ULONG STDMETHODCALLTYPE DnCLRDataTarget_AddRef( } ULONG STDMETHODCALLTYPE DnCLRDataTarget_Release( - __in ICLRDataTarget *This + _In_ ICLRDataTarget *This ) { DnCLRDataTarget *this = (DnCLRDataTarget *)This; @@ -359,8 +359,8 @@ ULONG STDMETHODCALLTYPE DnCLRDataTarget_Release( } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetMachineType( - __in ICLRDataTarget *This, - __out ULONG32 *machineType + _In_ ICLRDataTarget *This, + _Out_ ULONG32 *machineType ) { DnCLRDataTarget *this = (DnCLRDataTarget *)This; @@ -378,8 +378,8 @@ HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetMachineType( } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetPointerSize( - __in ICLRDataTarget *This, - __out ULONG32 *pointerSize + _In_ ICLRDataTarget *This, + _Out_ ULONG32 *pointerSize ) { DnCLRDataTarget *this = (DnCLRDataTarget *)This; @@ -397,8 +397,8 @@ HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetPointerSize( } BOOLEAN NTAPI PhpGetImageBaseCallback( - __in PLDR_DATA_TABLE_ENTRY Module, - __in_opt PVOID Context + _In_ PLDR_DATA_TABLE_ENTRY Module, + _In_opt_ PVOID Context ) { PPHP_GET_IMAGE_BASE_CONTEXT context = Context; @@ -414,9 +414,9 @@ BOOLEAN NTAPI PhpGetImageBaseCallback( } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetImageBase( - __in ICLRDataTarget *This, - __in LPCWSTR imagePath, - __out CLRDATA_ADDRESS *baseAddress + _In_ ICLRDataTarget *This, + _In_ LPCWSTR imagePath, + _Out_ CLRDATA_ADDRESS *baseAddress ) { DnCLRDataTarget *this = (DnCLRDataTarget *)This; @@ -444,11 +444,11 @@ HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetImageBase( } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_ReadVirtual( - __in ICLRDataTarget *This, - __in CLRDATA_ADDRESS address, - __out BYTE *buffer, - __in ULONG32 bytesRequested, - __out ULONG32 *bytesRead + _In_ ICLRDataTarget *This, + _In_ CLRDATA_ADDRESS address, + _Out_ BYTE *buffer, + _In_ ULONG32 bytesRequested, + _Out_ ULONG32 *bytesRead ) { DnCLRDataTarget *this = (DnCLRDataTarget *)This; @@ -478,50 +478,50 @@ HRESULT STDMETHODCALLTYPE DnCLRDataTarget_ReadVirtual( } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_WriteVirtual( - __in ICLRDataTarget *This, - __in CLRDATA_ADDRESS address, - __in BYTE *buffer, - __in ULONG32 bytesRequested, - __out ULONG32 *bytesWritten + _In_ ICLRDataTarget *This, + _In_ CLRDATA_ADDRESS address, + _In_ BYTE *buffer, + _In_ ULONG32 bytesRequested, + _Out_ ULONG32 *bytesWritten ) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetTLSValue( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 index, - __out CLRDATA_ADDRESS *value + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 index, + _Out_ CLRDATA_ADDRESS *value ) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_SetTLSValue( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 index, - __in CLRDATA_ADDRESS value + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 index, + _In_ CLRDATA_ADDRESS value ) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetCurrentThreadID( - __in ICLRDataTarget *This, - __out ULONG32 *threadID + _In_ ICLRDataTarget *This, + _Out_ ULONG32 *threadID ) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetThreadContext( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 contextFlags, - __in ULONG32 contextSize, - __out BYTE *context + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 contextFlags, + _In_ ULONG32 contextSize, + _Out_ BYTE *context ) { NTSTATUS status; @@ -553,22 +553,22 @@ HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetThreadContext( } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_SetThreadContext( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 contextSize, - __in BYTE *context + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 contextSize, + _In_ BYTE *context ) { return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE DnCLRDataTarget_Request( - __in ICLRDataTarget *This, - __in ULONG32 reqCode, - __in ULONG32 inBufferSize, - __in BYTE *inBuffer, - __in ULONG32 outBufferSize, - __out BYTE *outBuffer + _In_ ICLRDataTarget *This, + _In_ ULONG32 reqCode, + _In_ ULONG32 inBufferSize, + _In_ BYTE *inBuffer, + _In_ ULONG32 outBufferSize, + _Out_ BYTE *outBuffer ) { return E_NOTIMPL; diff --git a/2.x/trunk/plugins/DotNetTools/clrsup.h b/2.x/trunk/plugins/DotNetTools/clrsup.h index c41d805aa..bba5a5f72 100644 --- a/2.x/trunk/plugins/DotNetTools/clrsup.h +++ b/2.x/trunk/plugins/DotNetTools/clrsup.h @@ -15,31 +15,31 @@ typedef struct _CLR_PROCESS_SUPPORT } CLR_PROCESS_SUPPORT, *PCLR_PROCESS_SUPPORT; PCLR_PROCESS_SUPPORT CreateClrProcessSupport( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); VOID FreeClrProcessSupport( - __in PCLR_PROCESS_SUPPORT Support + _In_ PCLR_PROCESS_SUPPORT Support ); PPH_STRING GetRuntimeNameByAddressClrProcess( - __in PCLR_PROCESS_SUPPORT Support, - __in ULONG64 Address, - __out_opt PULONG64 Displacement + _In_ PCLR_PROCESS_SUPPORT Support, + _In_ ULONG64 Address, + _Out_opt_ PULONG64 Displacement ); PPH_STRING GetNameXClrDataAppDomain( - __in PVOID AppDomain + _In_ PVOID AppDomain ); PVOID LoadMscordacwks( - __in BOOLEAN IsClrV4 + _In_ BOOLEAN IsClrV4 ); HRESULT CreateXCLRDataProcess( - __in HANDLE ProcessId, - __in ICLRDataTarget *Target, - __out struct IXCLRDataProcess **DataProcess + _In_ HANDLE ProcessId, + _In_ ICLRDataTarget *Target, + _Out_ struct IXCLRDataProcess **DataProcess ); // xclrdata @@ -55,43 +55,43 @@ typedef struct IXCLRDataFrame IXCLRDataFrame; typedef struct IXCLRDataProcessVtbl { HRESULT (STDMETHODCALLTYPE *QueryInterface)( - __in IXCLRDataProcess *This, - __in REFIID riid, - __deref_out void **ppvObject + _In_ IXCLRDataProcess *This, + _In_ REFIID riid, + _Outptr_ void **ppvObject ); ULONG (STDMETHODCALLTYPE *AddRef)( - __in IXCLRDataProcess *This + _In_ IXCLRDataProcess *This ); ULONG (STDMETHODCALLTYPE *Release)( - __in IXCLRDataProcess *This + _In_ IXCLRDataProcess *This ); HRESULT (STDMETHODCALLTYPE *Flush)( - __in IXCLRDataProcess *This + _In_ IXCLRDataProcess *This ); HRESULT (STDMETHODCALLTYPE *StartEnumTasks)( - __in IXCLRDataProcess *This, - __out CLRDATA_ENUM *handle + _In_ IXCLRDataProcess *This, + _Out_ CLRDATA_ENUM *handle ); HRESULT (STDMETHODCALLTYPE *EnumTask)( - __in IXCLRDataProcess *This, - __inout CLRDATA_ENUM *handle, - __out IXCLRDataTask **task + _In_ IXCLRDataProcess *This, + _Inout_ CLRDATA_ENUM *handle, + _Out_ IXCLRDataTask **task ); HRESULT (STDMETHODCALLTYPE *EndEnumTasks)( - __in IXCLRDataProcess *This, - __in CLRDATA_ENUM handle + _In_ IXCLRDataProcess *This, + _In_ CLRDATA_ENUM handle ); HRESULT (STDMETHODCALLTYPE *GetTaskByOSThreadID)( - __in IXCLRDataProcess *This, - __in ULONG32 osThreadID, - __out IXCLRDataTask **task + _In_ IXCLRDataProcess *This, + _In_ ULONG32 osThreadID, + _Out_ IXCLRDataTask **task ); PVOID GetTaskByUniqueID; @@ -103,13 +103,13 @@ typedef struct IXCLRDataProcessVtbl PVOID GetAddressType; HRESULT (STDMETHODCALLTYPE *GetRuntimeNameByAddress)( - __in IXCLRDataProcess *This, - __in CLRDATA_ADDRESS address, - __in ULONG32 flags, - __in ULONG32 bufLen, - __out ULONG32 *nameLen, - __out WCHAR *nameBuf, - __out CLRDATA_ADDRESS *displacement + _In_ IXCLRDataProcess *This, + _In_ CLRDATA_ADDRESS address, + _In_ ULONG32 flags, + _In_ ULONG32 bufLen, + _Out_ ULONG32 *nameLen, + _Out_ WCHAR *nameBuf, + _Out_ CLRDATA_ADDRESS *displacement ); // ... @@ -150,34 +150,34 @@ typedef struct IXCLRDataProcess typedef struct IXCLRDataAppDomainVtbl { HRESULT (STDMETHODCALLTYPE *QueryInterface)( - __in IXCLRDataAppDomain *This, - __in REFIID riid, - __deref_out void **ppvObject + _In_ IXCLRDataAppDomain *This, + _In_ REFIID riid, + _Outptr_ void **ppvObject ); ULONG (STDMETHODCALLTYPE *AddRef)( - __in IXCLRDataAppDomain *This + _In_ IXCLRDataAppDomain *This ); ULONG (STDMETHODCALLTYPE *Release)( - __in IXCLRDataAppDomain *This + _In_ IXCLRDataAppDomain *This ); HRESULT (STDMETHODCALLTYPE *GetProcess)( - __in IXCLRDataAppDomain *This, - __out IXCLRDataProcess **process + _In_ IXCLRDataAppDomain *This, + _Out_ IXCLRDataProcess **process ); HRESULT (STDMETHODCALLTYPE *GetName)( - __in IXCLRDataAppDomain *This, - __in ULONG32 bufLen, - __out ULONG32 *nameLen, - __out WCHAR *name + _In_ IXCLRDataAppDomain *This, + _In_ ULONG32 bufLen, + _Out_ ULONG32 *nameLen, + _Out_ WCHAR *name ); HRESULT (STDMETHODCALLTYPE *GetUniqueID)( - __in IXCLRDataAppDomain *This, - __out ULONG64 *id + _In_ IXCLRDataAppDomain *This, + _Out_ ULONG64 *id ); // ... @@ -209,37 +209,37 @@ typedef struct IXCLRDataAppDomain typedef struct IXCLRDataTaskVtbl { HRESULT (STDMETHODCALLTYPE *QueryInterface)( - __in IXCLRDataTask *This, - __in REFIID riid, - __deref_out void **ppvObject + _In_ IXCLRDataTask *This, + _In_ REFIID riid, + _Outptr_ void **ppvObject ); ULONG (STDMETHODCALLTYPE *AddRef)( - __in IXCLRDataTask *This + _In_ IXCLRDataTask *This ); ULONG (STDMETHODCALLTYPE *Release)( - __in IXCLRDataTask *This + _In_ IXCLRDataTask *This ); HRESULT (STDMETHODCALLTYPE *GetProcess)( - __in IXCLRDataTask *This, - __out IXCLRDataProcess **process + _In_ IXCLRDataTask *This, + _Out_ IXCLRDataProcess **process ); HRESULT (STDMETHODCALLTYPE *GetCurrentAppDomain)( - __in IXCLRDataTask *This, - __out IXCLRDataAppDomain **appDomain + _In_ IXCLRDataTask *This, + _Out_ IXCLRDataAppDomain **appDomain ); HRESULT (STDMETHODCALLTYPE *GetUniqueID)( - __in IXCLRDataTask *This, - __out ULONG64 *id + _In_ IXCLRDataTask *This, + _Out_ ULONG64 *id ); HRESULT (STDMETHODCALLTYPE *GetFlags)( - __in IXCLRDataTask *This, - __out ULONG32 *flags + _In_ IXCLRDataTask *This, + _Out_ ULONG32 *flags ); PVOID IsSameObject; @@ -248,14 +248,14 @@ typedef struct IXCLRDataTaskVtbl PVOID SetDesiredExecutionState; HRESULT (STDMETHODCALLTYPE *CreateStackWalk)( - __in IXCLRDataTask *This, - __in ULONG32 flags, - __out IXCLRDataStackWalk **stackWalk + _In_ IXCLRDataTask *This, + _In_ ULONG32 flags, + _Out_ IXCLRDataStackWalk **stackWalk ); HRESULT (STDMETHODCALLTYPE *GetOSThreadID)( - __in IXCLRDataTask *This, - __out ULONG32 *id + _In_ IXCLRDataTask *This, + _Out_ ULONG32 *id ); PVOID GetContext; @@ -264,10 +264,10 @@ typedef struct IXCLRDataTaskVtbl PVOID Request; HRESULT (STDMETHODCALLTYPE *GetName)( - __in IXCLRDataTask *This, - __in ULONG32 bufLen, - __out ULONG32 *nameLen, - __out WCHAR *name + _In_ IXCLRDataTask *This, + _In_ ULONG32 bufLen, + _Out_ ULONG32 *nameLen, + _Out_ WCHAR *name ); PVOID GetLastExceptionState; @@ -345,63 +345,63 @@ typedef enum typedef struct IXCLRDataStackWalkVtbl { HRESULT (STDMETHODCALLTYPE *QueryInterface)( - __in IXCLRDataStackWalk *This, - __in REFIID riid, - __deref_out void **ppvObject + _In_ IXCLRDataStackWalk *This, + _In_ REFIID riid, + _Outptr_ void **ppvObject ); ULONG (STDMETHODCALLTYPE *AddRef)( - __in IXCLRDataStackWalk *This + _In_ IXCLRDataStackWalk *This ); ULONG (STDMETHODCALLTYPE *Release)( - __in IXCLRDataStackWalk *This + _In_ IXCLRDataStackWalk *This ); HRESULT (STDMETHODCALLTYPE *GetContext)( - __in IXCLRDataStackWalk *This, - __in ULONG32 contextFlags, - __in ULONG32 contextBufSize, - __out ULONG32 *contextSize, - __out BYTE *contextBuf + _In_ IXCLRDataStackWalk *This, + _In_ ULONG32 contextFlags, + _In_ ULONG32 contextBufSize, + _Out_ ULONG32 *contextSize, + _Out_ BYTE *contextBuf ); PVOID SetContext; HRESULT (STDMETHODCALLTYPE *Next)( - __in IXCLRDataStackWalk *This + _In_ IXCLRDataStackWalk *This ); HRESULT (STDMETHODCALLTYPE *GetStackSizeSkipped)( - __in IXCLRDataStackWalk *This, - __out ULONG64 *stackSizeSkipped + _In_ IXCLRDataStackWalk *This, + _Out_ ULONG64 *stackSizeSkipped ); HRESULT (STDMETHODCALLTYPE *GetFrameType)( - __in IXCLRDataStackWalk *This, - __out CLRDataSimpleFrameType *simpleType, - __out CLRDataDetailedFrameType *detailedType + _In_ IXCLRDataStackWalk *This, + _Out_ CLRDataSimpleFrameType *simpleType, + _Out_ CLRDataDetailedFrameType *detailedType ); HRESULT (STDMETHODCALLTYPE *GetFrame)( - __in IXCLRDataStackWalk *This, - __out PVOID *frame + _In_ IXCLRDataStackWalk *This, + _Out_ PVOID *frame ); HRESULT (STDMETHODCALLTYPE *Request)( - __in IXCLRDataStackWalk *This, - __in ULONG32 reqCode, - __in ULONG32 inBufferSize, - __in BYTE *inBuffer, - __in ULONG32 outBufferSize, - __out BYTE *outBuffer + _In_ IXCLRDataStackWalk *This, + _In_ ULONG32 reqCode, + _In_ ULONG32 inBufferSize, + _In_ BYTE *inBuffer, + _In_ ULONG32 outBufferSize, + _Out_ BYTE *outBuffer ); HRESULT (STDMETHODCALLTYPE *SetContext2)( - __in IXCLRDataStackWalk *This, - __in ULONG32 flags, - __in ULONG32 contextSize, - __in BYTE *context + _In_ IXCLRDataStackWalk *This, + _In_ ULONG32 flags, + _In_ ULONG32 contextSize, + _In_ BYTE *context ); } IXCLRDataStackWalkVtbl; @@ -443,31 +443,31 @@ typedef struct IXCLRDataStackWalk typedef struct IXCLRDataFrameVtbl { HRESULT (STDMETHODCALLTYPE *QueryInterface)( - __in IXCLRDataFrame *This, - __in REFIID riid, - __deref_out void **ppvObject + _In_ IXCLRDataFrame *This, + _In_ REFIID riid, + _Outptr_ void **ppvObject ); ULONG (STDMETHODCALLTYPE *AddRef)( - __in IXCLRDataFrame *This + _In_ IXCLRDataFrame *This ); ULONG (STDMETHODCALLTYPE *Release)( - __in IXCLRDataFrame *This + _In_ IXCLRDataFrame *This ); HRESULT (STDMETHODCALLTYPE *GetFrameType)( - __in IXCLRDataFrame *This, - __out CLRDataSimpleFrameType *simpleType, - __out CLRDataDetailedFrameType *detailedType + _In_ IXCLRDataFrame *This, + _Out_ CLRDataSimpleFrameType *simpleType, + _Out_ CLRDataDetailedFrameType *detailedType ); HRESULT (STDMETHODCALLTYPE *GetContext)( - __in IXCLRDataFrame *This, - __in ULONG32 contextFlags, - __in ULONG32 contextBufSize, - __out ULONG32 *contextSize, - __out BYTE *contextBuf + _In_ IXCLRDataFrame *This, + _In_ ULONG32 contextFlags, + _In_ ULONG32 contextBufSize, + _Out_ ULONG32 *contextSize, + _Out_ BYTE *contextBuf ); PVOID GetAppDomain; @@ -477,11 +477,11 @@ typedef struct IXCLRDataFrameVtbl PVOID GetLocalVariableByIndex; HRESULT (STDMETHODCALLTYPE *GetCodeName)( - __in IXCLRDataFrame *This, - __in ULONG32 *flags, - __in ULONG32 *bufLen, - __out ULONG32 *nameLen, - __out WCHAR *nameBuf + _In_ IXCLRDataFrame *This, + _In_ ULONG32 *flags, + _In_ ULONG32 *bufLen, + _Out_ ULONG32 *nameLen, + _Out_ WCHAR *nameBuf ); } IXCLRDataFrameVtbl; @@ -522,96 +522,96 @@ typedef struct } DnCLRDataTarget; ICLRDataTarget *DnCLRDataTarget_Create( - __in HANDLE ProcessId + _In_ HANDLE ProcessId ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_QueryInterface( - __in ICLRDataTarget *This, - __in REFIID Riid, - __out PVOID *Object + _In_ ICLRDataTarget *This, + _In_ REFIID Riid, + _Out_ PVOID *Object ); ULONG STDMETHODCALLTYPE DnCLRDataTarget_AddRef( - __in ICLRDataTarget *This + _In_ ICLRDataTarget *This ); ULONG STDMETHODCALLTYPE DnCLRDataTarget_Release( - __in ICLRDataTarget *This + _In_ ICLRDataTarget *This ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetMachineType( - __in ICLRDataTarget *This, - __out ULONG32 *machineType + _In_ ICLRDataTarget *This, + _Out_ ULONG32 *machineType ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetPointerSize( - __in ICLRDataTarget *This, - __out ULONG32 *pointerSize + _In_ ICLRDataTarget *This, + _Out_ ULONG32 *pointerSize ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetImageBase( - __in ICLRDataTarget *This, - __in LPCWSTR imagePath, - __out CLRDATA_ADDRESS *baseAddress + _In_ ICLRDataTarget *This, + _In_ LPCWSTR imagePath, + _Out_ CLRDATA_ADDRESS *baseAddress ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_ReadVirtual( - __in ICLRDataTarget *This, - __in CLRDATA_ADDRESS address, - __out BYTE *buffer, - __in ULONG32 bytesRequested, - __out ULONG32 *bytesRead + _In_ ICLRDataTarget *This, + _In_ CLRDATA_ADDRESS address, + _Out_ BYTE *buffer, + _In_ ULONG32 bytesRequested, + _Out_ ULONG32 *bytesRead ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_WriteVirtual( - __in ICLRDataTarget *This, - __in CLRDATA_ADDRESS address, - __in BYTE *buffer, - __in ULONG32 bytesRequested, - __out ULONG32 *bytesWritten + _In_ ICLRDataTarget *This, + _In_ CLRDATA_ADDRESS address, + _In_ BYTE *buffer, + _In_ ULONG32 bytesRequested, + _Out_ ULONG32 *bytesWritten ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetTLSValue( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 index, - __out CLRDATA_ADDRESS *value + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 index, + _Out_ CLRDATA_ADDRESS *value ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_SetTLSValue( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 index, - __in CLRDATA_ADDRESS value + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 index, + _In_ CLRDATA_ADDRESS value ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetCurrentThreadID( - __in ICLRDataTarget *This, - __out ULONG32 *threadID + _In_ ICLRDataTarget *This, + _Out_ ULONG32 *threadID ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_GetThreadContext( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 contextFlags, - __in ULONG32 contextSize, - __out BYTE *context + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 contextFlags, + _In_ ULONG32 contextSize, + _Out_ BYTE *context ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_SetThreadContext( - __in ICLRDataTarget *This, - __in ULONG32 threadID, - __in ULONG32 contextSize, - __in BYTE *context + _In_ ICLRDataTarget *This, + _In_ ULONG32 threadID, + _In_ ULONG32 contextSize, + _In_ BYTE *context ); HRESULT STDMETHODCALLTYPE DnCLRDataTarget_Request( - __in ICLRDataTarget *This, - __in ULONG32 reqCode, - __in ULONG32 inBufferSize, - __in BYTE *inBuffer, - __in ULONG32 outBufferSize, - __out BYTE *outBuffer + _In_ ICLRDataTarget *This, + _In_ ULONG32 reqCode, + _In_ ULONG32 inBufferSize, + _In_ BYTE *inBuffer, + _In_ ULONG32 outBufferSize, + _Out_ BYTE *outBuffer ); typedef struct _PHP_GET_IMAGE_BASE_CONTEXT diff --git a/2.x/trunk/plugins/DotNetTools/counters.c b/2.x/trunk/plugins/DotNetTools/counters.c index c00cad9cb..429a3d97c 100644 --- a/2.x/trunk/plugins/DotNetTools/counters.c +++ b/2.x/trunk/plugins/DotNetTools/counters.c @@ -23,10 +23,10 @@ #include "dn.h" BOOLEAN QueryPerfInfoVariableSize( - __in HKEY Key, - __in PWSTR ValueName, - __out PVOID *Data, - __out_opt PULONG DataSize + _In_ HKEY Key, + _In_ PWSTR ValueName, + _Out_ PVOID *Data, + _Out_opt_ PULONG DataSize ) { LONG result; @@ -70,8 +70,8 @@ BOOLEAN QueryPerfInfoVariableSize( } PWSTR FindPerfTextInTextData( - __in PVOID TextData, - __in ULONG Index + _In_ PVOID TextData, + _In_ ULONG Index ) { PWSTR textData; @@ -101,8 +101,8 @@ PWSTR FindPerfTextInTextData( } ULONG FindPerfIndexInTextData( - __in PVOID TextData, - __in PPH_STRINGREF Text + _In_ PVOID TextData, + _In_ PPH_STRINGREF Text ) { PWSTR textData; @@ -138,9 +138,9 @@ ULONG FindPerfIndexInTextData( } BOOLEAN GetPerfObjectTypeInfo( - __in_opt PPH_STRINGREF Filter, - __out PPERF_OBJECT_TYPE_INFO *Info, - __out PULONG Count + _In_opt_ PPH_STRINGREF Filter, + _Out_ PPERF_OBJECT_TYPE_INFO *Info, + _Out_ PULONG Count ) { BOOLEAN result; @@ -222,10 +222,10 @@ BOOLEAN GetPerfObjectTypeInfo( } BOOLEAN GetPerfObjectTypeInfo2( - __in PPH_STRINGREF NameList, - __out PPERF_OBJECT_TYPE_INFO *Info, - __out PULONG Count, - __out_opt PVOID *TextData + _In_ PPH_STRINGREF NameList, + _Out_ PPERF_OBJECT_TYPE_INFO *Info, + _Out_ PULONG Count, + _Out_opt_ PVOID *TextData ) { BOOLEAN result; diff --git a/2.x/trunk/plugins/DotNetTools/dn.h b/2.x/trunk/plugins/DotNetTools/dn.h index fa1c33d65..41a471cd5 100644 --- a/2.x/trunk/plugins/DotNetTools/dn.h +++ b/2.x/trunk/plugins/DotNetTools/dn.h @@ -19,51 +19,51 @@ typedef struct _PERF_OBJECT_TYPE_INFO } PERF_OBJECT_TYPE_INFO, *PPERF_OBJECT_TYPE_INFO; BOOLEAN QueryPerfInfoVariableSize( - __in HKEY Key, - __in PWSTR ValueName, - __out PVOID *Data, - __out_opt PULONG DataSize + _In_ HKEY Key, + _In_ PWSTR ValueName, + _Out_ PVOID *Data, + _Out_opt_ PULONG DataSize ); PWSTR FindPerfTextInTextData( - __in PVOID TextData, - __in ULONG Index + _In_ PVOID TextData, + _In_ ULONG Index ); ULONG FindPerfIndexInTextData( - __in PVOID TextData, - __in PPH_STRINGREF Text + _In_ PVOID TextData, + _In_ PPH_STRINGREF Text ); BOOLEAN GetPerfObjectTypeInfo( - __in_opt PPH_STRINGREF Filter, - __out PPERF_OBJECT_TYPE_INFO *Info, - __out PULONG Count + _In_opt_ PPH_STRINGREF Filter, + _Out_ PPERF_OBJECT_TYPE_INFO *Info, + _Out_ PULONG Count ); BOOLEAN GetPerfObjectTypeInfo2( - __in PPH_STRINGREF NameList, - __out PPERF_OBJECT_TYPE_INFO *Info, - __out PULONG Count, - __out_opt PVOID *TextData + _In_ PPH_STRINGREF NameList, + _Out_ PPERF_OBJECT_TYPE_INFO *Info, + _Out_ PULONG Count, + _Out_opt_ PVOID *TextData ); // asmpage VOID AddAsmPageToPropContext( - __in PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext + _In_ PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext ); // perfpage VOID AddPerfPageToPropContext( - __in PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext + _In_ PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext ); // stackext VOID ProcessThreadStackControl( - __in PPH_PLUGIN_THREAD_STACK_CONTROL Control + _In_ PPH_PLUGIN_THREAD_STACK_CONTROL Control ); #endif diff --git a/2.x/trunk/plugins/DotNetTools/main.c b/2.x/trunk/plugins/DotNetTools/main.c index 470a7e775..1123bcfa5 100644 --- a/2.x/trunk/plugins/DotNetTools/main.c +++ b/2.x/trunk/plugins/DotNetTools/main.c @@ -24,63 +24,63 @@ #include "resource.h" VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI UnloadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI TreeNewMessageCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessPropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ThreadMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ModuleMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ThreadStackControlCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); PPH_PLUGIN PluginInstance; @@ -98,9 +98,9 @@ PH_CALLBACK_REGISTRATION ProcessTreeNewInitializingCallbackRegistration; PH_CALLBACK_REGISTRATION ThreadStackControlCallbackRegistration; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -209,32 +209,32 @@ LOGICAL DllMain( } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI UnloadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; @@ -248,8 +248,8 @@ VOID NTAPI MenuItemCallback( } VOID NTAPI TreeNewMessageCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_TREENEW_MESSAGE message = Parameter; @@ -258,16 +258,16 @@ VOID NTAPI TreeNewMessageCallback( } VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI ProcessPropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_PROCESS_PROPCONTEXT propContext = Parameter; @@ -288,40 +288,40 @@ VOID NTAPI ProcessPropertiesInitializingCallback( } VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI ThreadMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI ModuleMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI ProcessTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI ThreadStackControlCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { ProcessThreadStackControl(Parameter); diff --git a/2.x/trunk/plugins/DotNetTools/perfpage.c b/2.x/trunk/plugins/DotNetTools/perfpage.c index 3cd39d232..099199dae 100644 --- a/2.x/trunk/plugins/DotNetTools/perfpage.c +++ b/2.x/trunk/plugins/DotNetTools/perfpage.c @@ -36,10 +36,10 @@ typedef struct _PERFPAGE_CONTEXT } PERFPAGE_CONTEXT, *PPERFPAGE_CONTEXT; INT_PTR CALLBACK DotNetPerfPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static GUID CLSID_CorpubPublish_I = { 0x047a9a40, 0x657e, 0x11d3, { 0x8d, 0x5b, 0x00, 0x10, 0x4b, 0x35, 0xe7, 0xef } }; @@ -51,7 +51,7 @@ static ULONG DotNetObjectTypeInfoCount = 0; static PVOID PerfInfoTextData = NULL; VOID AddPerfPageToPropContext( - __in PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext + _In_ PPH_PLUGIN_PROCESS_PROPCONTEXT PropContext ) { PhAddProcessPropPage( @@ -61,8 +61,8 @@ VOID AddPerfPageToPropContext( } HRESULT CreateCorpubPublish( - __in HANDLE ProcessId, - __out ICorPublish **Publish + _In_ HANDLE ProcessId, + _Out_ ICorPublish **Publish ) { HRESULT result; @@ -132,8 +132,8 @@ HRESULT CreateCorpubPublish( } HRESULT GetCorPublishProcess( - __in HANDLE ProcessId, - __out ICorPublishProcess **PublishProcess + _In_ HANDLE ProcessId, + _Out_ ICorPublishProcess **PublishProcess ) { HRESULT result; @@ -176,8 +176,8 @@ VOID InitializeDotNetObjectTypeInfo( } VOID AddProcessAppDomains( - __in HWND hwndDlg, - __in PPERFPAGE_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PPERFPAGE_CONTEXT Context ) { HWND appDomainsLv; @@ -222,8 +222,8 @@ VOID AddProcessAppDomains( } PPERF_OBJECT_TYPE_INFO GetSelectedObjectTypeInfo( - __in HWND hwndDlg, - __in PPERFPAGE_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PPERFPAGE_CONTEXT Context ) { PPH_STRING selectedText; @@ -243,9 +243,9 @@ PPERF_OBJECT_TYPE_INFO GetSelectedObjectTypeInfo( } VOID UpdateCounterData( - __in HWND hwndDlg, - __in PPERFPAGE_CONTEXT Context, - __in BOOLEAN RefreshCategory + _In_ HWND hwndDlg, + _In_ PPERFPAGE_CONTEXT Context, + _In_ BOOLEAN RefreshCategory ) { HWND countersLv; @@ -411,10 +411,10 @@ VOID UpdateCounterData( } INT_PTR CALLBACK DotNetPerfPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; diff --git a/2.x/trunk/plugins/DotNetTools/stackext.c b/2.x/trunk/plugins/DotNetTools/stackext.c index 8acfe0660..439f4d1d6 100644 --- a/2.x/trunk/plugins/DotNetTools/stackext.c +++ b/2.x/trunk/plugins/DotNetTools/stackext.c @@ -37,11 +37,11 @@ typedef struct _THREAD_STACK_CONTEXT } THREAD_STACK_CONTEXT, *PTHREAD_STACK_CONTEXT; VOID PredictAddressesFromClrData( - __in PTHREAD_STACK_CONTEXT Context, - __in PPH_THREAD_STACK_FRAME Frame, - __out PVOID *PredictedEip, - __out PVOID *PredictedEbp, - __out PVOID *PredictedEsp + _In_ PTHREAD_STACK_CONTEXT Context, + _In_ PPH_THREAD_STACK_FRAME Frame, + _Out_ PVOID *PredictedEip, + _Out_ PVOID *PredictedEbp, + _Out_ PVOID *PredictedEsp ); static PPH_HASHTABLE ContextHashtable; @@ -49,7 +49,7 @@ static PH_QUEUED_LOCK ContextHashtableLock = PH_QUEUED_LOCK_INIT; static PH_INITONCE ContextHashtableInitOnce = PH_INITONCE_INIT; VOID ProcessThreadStackControl( - __in PPH_PLUGIN_THREAD_STACK_CONTROL Control + _In_ PPH_PLUGIN_THREAD_STACK_CONTROL Control ) { if (PhBeginInitOnce(&ContextHashtableInitOnce)) @@ -181,11 +181,11 @@ VOID ProcessThreadStackControl( } VOID PredictAddressesFromClrData( - __in PTHREAD_STACK_CONTEXT Context, - __in PPH_THREAD_STACK_FRAME Frame, - __out PVOID *PredictedEip, - __out PVOID *PredictedEbp, - __out PVOID *PredictedEsp + _In_ PTHREAD_STACK_CONTEXT Context, + _In_ PPH_THREAD_STACK_FRAME Frame, + _Out_ PVOID *PredictedEip, + _Out_ PVOID *PredictedEbp, + _Out_ PVOID *PredictedEsp ) { #ifdef _M_X64 diff --git a/2.x/trunk/plugins/ExtendedNotifications/ExtendedNotifications.vcxproj b/2.x/trunk/plugins/ExtendedNotifications/ExtendedNotifications.vcxproj index 2c037807d..be9dac4ff 100644 --- a/2.x/trunk/plugins/ExtendedNotifications/ExtendedNotifications.vcxproj +++ b/2.x/trunk/plugins/ExtendedNotifications/ExtendedNotifications.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/ExtendedNotifications/filelog.c b/2.x/trunk/plugins/ExtendedNotifications/filelog.c index af30c322d..56dc52db5 100644 --- a/2.x/trunk/plugins/ExtendedNotifications/filelog.c +++ b/2.x/trunk/plugins/ExtendedNotifications/filelog.c @@ -24,8 +24,8 @@ #include "extnoti.h" VOID NTAPI LoggedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); PPH_FILE_STREAM LogFileStream = NULL; @@ -66,8 +66,8 @@ VOID FileLogInitialization( } VOID NTAPI LoggedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_LOG_ENTRY logEntry = Parameter; diff --git a/2.x/trunk/plugins/ExtendedNotifications/main.c b/2.x/trunk/plugins/ExtendedNotifications/main.c index d488c4cca..7ef53df07 100644 --- a/2.x/trunk/plugins/ExtendedNotifications/main.c +++ b/2.x/trunk/plugins/ExtendedNotifications/main.c @@ -27,58 +27,58 @@ #include "gntp-send/growl.h" VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI NotifyEventCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID RegisterGrowl( - __in BOOLEAN Force + _In_ BOOLEAN Force ); VOID NotifyGrowl( - __in PPH_PLUGIN_NOTIFY_EVENT NotifyEvent + _In_ PPH_PLUGIN_NOTIFY_EVENT NotifyEvent ); NTSTATUS NTAPI RegisterGrowlCallback( - __in PVOID Parameter + _In_ PVOID Parameter ); INT_PTR CALLBACK ProcessesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK ServicesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK LoggingDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK GrowlDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); PPH_PLUGIN PluginInstance; @@ -100,9 +100,9 @@ PSTR GrowlNotifications[] = }; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -163,7 +163,7 @@ LOGICAL DllMain( } VOID FreeFilterEntry( - __in PFILTER_ENTRY Entry + _In_ PFILTER_ENTRY Entry ) { PhDereferenceObject(Entry->Filter); @@ -171,7 +171,7 @@ VOID FreeFilterEntry( } VOID ClearFilterList( - __inout PPH_LIST FilterList + _Inout_ PPH_LIST FilterList ) { ULONG i; @@ -183,8 +183,8 @@ VOID ClearFilterList( } VOID CopyFilterList( - __inout PPH_LIST Destination, - __in PPH_LIST Source + _Inout_ PPH_LIST Destination, + _In_ PPH_LIST Source ) { ULONG i; @@ -204,8 +204,8 @@ VOID CopyFilterList( } VOID LoadFilterList( - __inout PPH_LIST FilterList, - __in PPH_STRING String + _Inout_ PPH_LIST FilterList, + _In_ PPH_STRING String ) { PH_STRING_BUILDER stringBuilder; @@ -271,7 +271,7 @@ VOID LoadFilterList( } PPH_STRING SaveFilterList( - __inout PPH_LIST FilterList + _Inout_ PPH_LIST FilterList ) { PH_STRING_BUILDER stringBuilder; @@ -316,8 +316,8 @@ PPH_STRING SaveFilterList( } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_STRING string; @@ -339,8 +339,8 @@ VOID NTAPI LoadCallback( } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -393,9 +393,9 @@ VOID NTAPI ShowOptionsCallback( } BOOLEAN MatchFilterList( - __in PPH_LIST FilterList, - __in PPH_STRING String, - __out FILTER_TYPE *FilterType + _In_ PPH_LIST FilterList, + _In_ PPH_STRING String, + _Out_ FILTER_TYPE *FilterType ) { ULONG i; @@ -427,8 +427,8 @@ BOOLEAN MatchFilterList( } VOID NTAPI NotifyEventCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_NOTIFY_EVENT notifyEvent = Parameter; @@ -472,7 +472,7 @@ VOID NTAPI NotifyEventCallback( } VOID RegisterGrowl( - __in BOOLEAN Force + _In_ BOOLEAN Force ) { static BOOLEAN registered = FALSE; @@ -486,7 +486,7 @@ VOID RegisterGrowl( } VOID NotifyGrowl( - __in PPH_PLUGIN_NOTIFY_EVENT NotifyEvent + _In_ PPH_PLUGIN_NOTIFY_EVENT NotifyEvent ) { PSTR notification; @@ -605,7 +605,7 @@ VOID NotifyGrowl( } NTSTATUS NTAPI RegisterGrowlCallback( - __in PVOID Parameter + _In_ PVOID Parameter ) { RegisterGrowl(FALSE); @@ -614,15 +614,15 @@ NTSTATUS NTAPI RegisterGrowlCallback( } PPH_STRING FormatFilterEntry( - __in PFILTER_ENTRY Entry + _In_ PFILTER_ENTRY Entry ) { return PhConcatStrings2(Entry->Type == FilterInclude ? L"[Include] " : L"[Exclude] ", Entry->Filter->Buffer); } VOID AddEntriesToListBox( - __in HWND ListBox, - __in PPH_LIST FilterList + _In_ HWND ListBox, + _In_ PPH_LIST FilterList ) { ULONG i; @@ -642,10 +642,10 @@ PPH_LIST EditingProcessFilterList; PPH_LIST EditingServiceFilterList; static LRESULT CALLBACK TextBoxWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { WNDPROC oldWndProc; @@ -680,8 +680,8 @@ static LRESULT CALLBACK TextBoxWndProc( } VOID FixControlStates( - __in HWND hwndDlg, - __in HWND ListBox + _In_ HWND hwndDlg, + _In_ HWND ListBox ) { ULONG i; @@ -696,12 +696,12 @@ VOID FixControlStates( } INT_PTR HandleCommonMessages( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __in HWND ListBox, - __in PPH_LIST FilterList + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ HWND ListBox, + _In_ PPH_LIST FilterList ) { switch (uMsg) @@ -897,10 +897,10 @@ INT_PTR HandleCommonMessages( } INT_PTR CALLBACK ProcessesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { INT_PTR result; @@ -963,10 +963,10 @@ INT_PTR CALLBACK ProcessesDlgProc( } INT_PTR CALLBACK ServicesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { if (HandleCommonMessages(hwndDlg, uMsg, wParam, lParam, @@ -1027,10 +1027,10 @@ INT_PTR CALLBACK ServicesDlgProc( } INT_PTR CALLBACK LoggingDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -1096,10 +1096,10 @@ INT_PTR CALLBACK LoggingDlgProc( } INT_PTR CALLBACK GrowlDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ExtendedServices/CHANGELOG.txt b/2.x/trunk/plugins/ExtendedServices/CHANGELOG.txt index 85a8703b3..018c3a805 100644 --- a/2.x/trunk/plugins/ExtendedServices/CHANGELOG.txt +++ b/2.x/trunk/plugins/ExtendedServices/CHANGELOG.txt @@ -1,3 +1,6 @@ +1.9 + * Added new trigger data types + 1.8 * Fixed some bugs relating to Windows 8 diff --git a/2.x/trunk/plugins/ExtendedServices/ExtendedServices.rc b/2.x/trunk/plugins/ExtendedServices/ExtendedServices.rc index 8a634ec7c..0580d3c88 100644 --- a/2.x/trunk/plugins/ExtendedServices/ExtendedServices.rc +++ b/2.x/trunk/plugins/ExtendedServices/ExtendedServices.rc @@ -49,8 +49,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,8,0,0 - PRODUCTVERSION 1,8,0,0 + FILEVERSION 1,9,0,0 + PRODUCTVERSION 1,9,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -67,12 +67,12 @@ BEGIN BEGIN VALUE "CompanyName", "wj32" VALUE "FileDescription", "Extended Services for Process Hacker" - VALUE "FileVersion", "1.8" + VALUE "FileVersion", "1.9" VALUE "InternalName", "ExtendedServices" VALUE "LegalCopyright", "Licensed under the GNU GPL, v3." VALUE "OriginalFilename", "ExtendedServices.dll" VALUE "ProductName", "Extended Services for Process Hacker" - VALUE "ProductVersion", "1.8" + VALUE "ProductVersion", "1.9" END END BLOCK "VarFileInfo" diff --git a/2.x/trunk/plugins/ExtendedServices/ExtendedServices.vcxproj b/2.x/trunk/plugins/ExtendedServices/ExtendedServices.vcxproj index 1c26ec1d9..ec1baf18c 100644 --- a/2.x/trunk/plugins/ExtendedServices/ExtendedServices.vcxproj +++ b/2.x/trunk/plugins/ExtendedServices/ExtendedServices.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/ExtendedServices/depend.c b/2.x/trunk/plugins/ExtendedServices/depend.c index e9633036a..84b73e77c 100644 --- a/2.x/trunk/plugins/ExtendedServices/depend.c +++ b/2.x/trunk/plugins/ExtendedServices/depend.c @@ -32,9 +32,9 @@ typedef struct _SERVICE_LIST_CONTEXT } SERVICE_LIST_CONTEXT, *PSERVICE_LIST_CONTEXT; LPENUM_SERVICE_STATUS EsEnumDependentServices( - __in SC_HANDLE ServiceHandle, - __in_opt ULONG State, - __out PULONG Count + _In_ SC_HANDLE ServiceHandle, + _In_opt_ ULONG State, + _Out_ PULONG Count ) { LOGICAL result; @@ -87,8 +87,8 @@ LPENUM_SERVICE_STATUS EsEnumDependentServices( } static VOID EspLayoutServiceListControl( - __in HWND hwndDlg, - __in HWND ServiceListHandle + _In_ HWND hwndDlg, + _In_ HWND ServiceListHandle ) { RECT rect; @@ -107,10 +107,10 @@ static VOID EspLayoutServiceListControl( } INT_PTR CALLBACK EspServiceDependenciesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PSERVICE_LIST_CONTEXT context; @@ -236,10 +236,10 @@ INT_PTR CALLBACK EspServiceDependenciesDlgProc( } INT_PTR CALLBACK EspServiceDependentsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PSERVICE_LIST_CONTEXT context; diff --git a/2.x/trunk/plugins/ExtendedServices/extsrv.h b/2.x/trunk/plugins/ExtendedServices/extsrv.h index d9dc9081b..44d3ef5bf 100644 --- a/2.x/trunk/plugins/ExtendedServices/extsrv.h +++ b/2.x/trunk/plugins/ExtendedServices/extsrv.h @@ -13,62 +13,62 @@ extern PPH_PLUGIN PluginInstance; // depend LPENUM_SERVICE_STATUS EsEnumDependentServices( - __in SC_HANDLE ServiceHandle, - __in_opt ULONG State, - __out PULONG Count + _In_ SC_HANDLE ServiceHandle, + _In_opt_ ULONG State, + _Out_ PULONG Count ); INT_PTR CALLBACK EspServiceDependenciesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK EspServiceDependentsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // options VOID EsShowOptionsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ); // other INT_PTR CALLBACK EspServiceOtherDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // recovery INT_PTR CALLBACK EspServiceRecoveryDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK EspServiceRecovery2DlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // srvprgrs VOID EsRestartServiceWithProgress( - __in HWND hWnd, - __in PPH_SERVICE_ITEM ServiceItem, - __in SC_HANDLE ServiceHandle + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM ServiceItem, + _In_ SC_HANDLE ServiceHandle ); // trigger @@ -76,23 +76,23 @@ VOID EsRestartServiceWithProgress( struct _ES_TRIGGER_CONTEXT; struct _ES_TRIGGER_CONTEXT *EsCreateServiceTriggerContext( - __in PPH_SERVICE_ITEM ServiceItem, - __in HWND WindowHandle, - __in HWND TriggersLv + _In_ PPH_SERVICE_ITEM ServiceItem, + _In_ HWND WindowHandle, + _In_ HWND TriggersLv ); VOID EsDestroyServiceTriggerContext( - __in struct _ES_TRIGGER_CONTEXT *Context + _In_ struct _ES_TRIGGER_CONTEXT *Context ); VOID EsLoadServiceTriggerInfo( - __in struct _ES_TRIGGER_CONTEXT *Context, - __in SC_HANDLE ServiceHandle + _In_ struct _ES_TRIGGER_CONTEXT *Context, + _In_ SC_HANDLE ServiceHandle ); BOOLEAN EsSaveServiceTriggerInfo( - __in struct _ES_TRIGGER_CONTEXT *Context, - __out PULONG Win32Result + _In_ struct _ES_TRIGGER_CONTEXT *Context, + _Out_ PULONG Win32Result ); #define ES_TRIGGER_EVENT_NEW 1 @@ -101,8 +101,8 @@ BOOLEAN EsSaveServiceTriggerInfo( #define ES_TRIGGER_EVENT_SELECTIONCHANGED 4 VOID EsHandleEventServiceTrigger( - __in struct _ES_TRIGGER_CONTEXT *Context, - __in ULONG Event + _In_ struct _ES_TRIGGER_CONTEXT *Context, + _In_ ULONG Event ); #endif diff --git a/2.x/trunk/plugins/ExtendedServices/main.c b/2.x/trunk/plugins/ExtendedServices/main.c index 58279ba20..401e1a5e6 100644 --- a/2.x/trunk/plugins/ExtendedServices/main.c +++ b/2.x/trunk/plugins/ExtendedServices/main.c @@ -26,33 +26,33 @@ #include "resource.h" VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ServicePropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ServiceMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); PPH_PLUGIN PluginInstance; @@ -64,9 +64,9 @@ PH_CALLBACK_REGISTRATION ServicePropertiesInitializingCallbackRegistration; PH_CALLBACK_REGISTRATION ServiceMenuInitializingCallbackRegistration; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -139,24 +139,24 @@ LOGICAL DllMain( } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { // Nothing } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { EsShowOptionsDialog((HWND)Parameter); } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; @@ -220,8 +220,8 @@ VOID NTAPI MenuItemCallback( } static int __cdecl ServiceForServicesMenuCompare( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PPH_SERVICE_ITEM serviceItem1 = *(PPH_SERVICE_ITEM *)elem1; @@ -231,8 +231,8 @@ static int __cdecl ServiceForServicesMenuCompare( } VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; @@ -394,8 +394,8 @@ VOID NTAPI ProcessMenuInitializingCallback( } VOID NTAPI ServicePropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_OBJECT_PROPERTIES objectProperties = Parameter; @@ -472,8 +472,8 @@ VOID NTAPI ServicePropertiesInitializingCallback( } VOID NTAPI ServiceMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; diff --git a/2.x/trunk/plugins/ExtendedServices/options.c b/2.x/trunk/plugins/ExtendedServices/options.c index 346bfaaeb..fd935209d 100644 --- a/2.x/trunk/plugins/ExtendedServices/options.c +++ b/2.x/trunk/plugins/ExtendedServices/options.c @@ -26,14 +26,14 @@ #include "resource.h" INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EsShowOptionsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ) { DialogBox( @@ -45,10 +45,10 @@ VOID EsShowOptionsDialog( } INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ExtendedServices/other.c b/2.x/trunk/plugins/ExtendedServices/other.c index 53362a06c..4786b8f1a 100644 --- a/2.x/trunk/plugins/ExtendedServices/other.c +++ b/2.x/trunk/plugins/ExtendedServices/other.c @@ -40,8 +40,8 @@ typedef struct _SERVICE_OTHER_CONTEXT } SERVICE_OTHER_CONTEXT, *PSERVICE_OTHER_CONTEXT; NTSTATUS EspLoadOtherInfo( - __in HWND hwndDlg, - __in PSERVICE_OTHER_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PSERVICE_OTHER_CONTEXT Context ) { NTSTATUS status = STATUS_SUCCESS; @@ -124,8 +124,8 @@ NTSTATUS EspLoadOtherInfo( } static int __cdecl PrivilegeNameCompareFunction( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PWSTR string1 = *(PWSTR *)elem1; @@ -135,10 +135,10 @@ static int __cdecl PrivilegeNameCompareFunction( } INT_PTR CALLBACK EspServiceOtherDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PSERVICE_OTHER_CONTEXT context; diff --git a/2.x/trunk/plugins/ExtendedServices/recovery.c b/2.x/trunk/plugins/ExtendedServices/recovery.c index 2e7a57dfc..c7ecd8745 100644 --- a/2.x/trunk/plugins/ExtendedServices/recovery.c +++ b/2.x/trunk/plugins/ExtendedServices/recovery.c @@ -49,14 +49,14 @@ static PH_KEY_VALUE_PAIR ServiceActionPairs[] = }; INT_PTR CALLBACK RestartComputerDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EspAddServiceActionStrings( - __in HWND ComboBoxHandle + _In_ HWND ComboBoxHandle ) { ULONG i; @@ -68,7 +68,7 @@ VOID EspAddServiceActionStrings( } SC_ACTION_TYPE EspStringToServiceAction( - __in PWSTR String + _In_ PWSTR String ) { ULONG integer; @@ -80,7 +80,7 @@ SC_ACTION_TYPE EspStringToServiceAction( } PWSTR EspServiceActionToString( - __in SC_ACTION_TYPE ActionType + _In_ SC_ACTION_TYPE ActionType ) { PWSTR string; @@ -92,7 +92,7 @@ PWSTR EspServiceActionToString( } static SC_ACTION_TYPE ComboBoxToServiceAction( - __in HWND ComboBoxHandle + _In_ HWND ComboBoxHandle ) { SC_ACTION_TYPE actionType; @@ -110,8 +110,8 @@ static SC_ACTION_TYPE ComboBoxToServiceAction( } static VOID ServiceActionToComboBox( - __in HWND ComboBoxHandle, - __in SC_ACTION_TYPE ActionType + _In_ HWND ComboBoxHandle, + _In_ SC_ACTION_TYPE ActionType ) { PWSTR string; @@ -123,8 +123,8 @@ static VOID ServiceActionToComboBox( } static VOID EspFixControls( - __in HWND hwndDlg, - __in PSERVICE_RECOVERY_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PSERVICE_RECOVERY_CONTEXT Context ) { SC_ACTION_TYPE action1; @@ -158,8 +158,8 @@ static VOID EspFixControls( } NTSTATUS EspLoadRecoveryInfo( - __in HWND hwndDlg, - __in PSERVICE_RECOVERY_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PSERVICE_RECOVERY_CONTEXT Context ) { NTSTATUS status = STATUS_SUCCESS; @@ -271,10 +271,10 @@ NTSTATUS EspLoadRecoveryInfo( } INT_PTR CALLBACK EspServiceRecoveryDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PSERVICE_RECOVERY_CONTEXT context; @@ -543,20 +543,20 @@ INT_PTR CALLBACK EspServiceRecoveryDlgProc( } INT_PTR CALLBACK EspServiceRecovery2DlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { return FALSE; } static INT_PTR CALLBACK RestartComputerDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PSERVICE_RECOVERY_CONTEXT context; diff --git a/2.x/trunk/plugins/ExtendedServices/srvprgrs.c b/2.x/trunk/plugins/ExtendedServices/srvprgrs.c index 9479ec46a..2dced287b 100644 --- a/2.x/trunk/plugins/ExtendedServices/srvprgrs.c +++ b/2.x/trunk/plugins/ExtendedServices/srvprgrs.c @@ -34,16 +34,16 @@ typedef struct _RESTART_SERVICE_CONTEXT } RESTART_SERVICE_CONTEXT, *PRESTART_SERVICE_CONTEXT; INT_PTR CALLBACK EspRestartServiceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EsRestartServiceWithProgress( - __in HWND hWnd, - __in PPH_SERVICE_ITEM ServiceItem, - __in SC_HANDLE ServiceHandle + _In_ HWND hWnd, + _In_ PPH_SERVICE_ITEM ServiceItem, + _In_ SC_HANDLE ServiceHandle ) { RESTART_SERVICE_CONTEXT context; @@ -63,10 +63,10 @@ VOID EsRestartServiceWithProgress( } INT_PTR CALLBACK EspRestartServiceDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PRESTART_SERVICE_CONTEXT context; diff --git a/2.x/trunk/plugins/ExtendedServices/trigger.c b/2.x/trunk/plugins/ExtendedServices/trigger.c index 95e43d803..d63dfb212 100644 --- a/2.x/trunk/plugins/ExtendedServices/trigger.c +++ b/2.x/trunk/plugins/ExtendedServices/trigger.c @@ -36,6 +36,8 @@ typedef struct _ES_TRIGGER_DATA PVOID Binary; ULONG BinaryLength; }; + UCHAR Byte; + ULONG64 UInt64; }; } ES_TRIGGER_DATA, *PES_TRIGGER_DATA; @@ -86,17 +88,17 @@ typedef struct _ETW_PUBLISHER_ENTRY } ETW_PUBLISHER_ENTRY, *PETW_PUBLISHER_ENTRY; INT_PTR CALLBACK EspServiceTriggerDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK ValueDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static GUID NetworkManagerFirstIpAddressArrivalGuid = { 0x4f27f2de, 0x14e2, 0x430b, { 0xa5, 0x49, 0x7c, 0xd4, 0x8c, 0xbc, 0x82, 0x45 } }; @@ -150,7 +152,7 @@ static SUBTYPE_ENTRY SubTypeEntries[] = static PH_STRINGREF PublishersKeyName = PH_STRINGREF_INIT(L"Software\\Microsoft\\Windows\\CurrentVersion\\WINEVT\\Publishers\\"); PES_TRIGGER_DATA EspCreateTriggerData( - __in_opt PSERVICE_TRIGGER_SPECIFIC_DATA_ITEM DataItem + _In_opt_ PSERVICE_TRIGGER_SPECIFIC_DATA_ITEM DataItem ) { PES_TRIGGER_DATA data; @@ -174,13 +176,23 @@ PES_TRIGGER_DATA EspCreateTriggerData( data->BinaryLength = DataItem->cbData; data->Binary = PhAllocateCopy(DataItem->pData, DataItem->cbData); } + else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_LEVEL) + { + if (DataItem->cbData == sizeof(UCHAR)) + data->Byte = *(PUCHAR)DataItem->pData; + } + else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY || data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL) + { + if (DataItem->cbData == sizeof(ULONG64)) + data->UInt64 = *(PULONG64)DataItem->pData; + } } return data; } PES_TRIGGER_DATA EspCloneTriggerData( - __in PES_TRIGGER_DATA Data + _In_ PES_TRIGGER_DATA Data ) { PES_TRIGGER_DATA newData; @@ -202,7 +214,7 @@ PES_TRIGGER_DATA EspCloneTriggerData( } VOID EspDestroyTriggerData( - __in PES_TRIGGER_DATA Data + _In_ PES_TRIGGER_DATA Data ) { if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING) @@ -220,7 +232,7 @@ VOID EspDestroyTriggerData( } PES_TRIGGER_INFO EspCreateTriggerInfo( - __in_opt PSERVICE_TRIGGER Trigger + _In_opt_ PSERVICE_TRIGGER Trigger ) { PES_TRIGGER_INFO info; @@ -262,7 +274,7 @@ PES_TRIGGER_INFO EspCreateTriggerInfo( } PES_TRIGGER_INFO EspCloneTriggerInfo( - __in PES_TRIGGER_INFO Info + _In_ PES_TRIGGER_INFO Info ) { PES_TRIGGER_INFO newInfo; @@ -287,7 +299,7 @@ PES_TRIGGER_INFO EspCloneTriggerInfo( } VOID EspDestroyTriggerInfo( - __in PES_TRIGGER_INFO Info + _In_ PES_TRIGGER_INFO Info ) { if (Info->DataList) @@ -306,7 +318,7 @@ VOID EspDestroyTriggerInfo( } VOID EspClearTriggerInfoList( - __in PPH_LIST List + _In_ PPH_LIST List ) { ULONG i; @@ -320,9 +332,9 @@ VOID EspClearTriggerInfoList( } struct _ES_TRIGGER_CONTEXT *EsCreateServiceTriggerContext( - __in PPH_SERVICE_ITEM ServiceItem, - __in HWND WindowHandle, - __in HWND TriggersLv + _In_ PPH_SERVICE_ITEM ServiceItem, + _In_ HWND WindowHandle, + _In_ HWND TriggersLv ) { PES_TRIGGER_CONTEXT context; @@ -347,7 +359,7 @@ struct _ES_TRIGGER_CONTEXT *EsCreateServiceTriggerContext( } VOID EsDestroyServiceTriggerContext( - __in struct _ES_TRIGGER_CONTEXT *Context + _In_ struct _ES_TRIGGER_CONTEXT *Context ) { ULONG i; @@ -362,7 +374,7 @@ VOID EsDestroyServiceTriggerContext( } PPH_STRING EspLookupEtwPublisherName( - __in PGUID Guid + _In_ PGUID Guid ) { PPH_STRING guidString; @@ -409,8 +421,8 @@ PPH_STRING EspLookupEtwPublisherName( } BOOLEAN EspEnumerateEtwPublishers( - __out PETW_PUBLISHER_ENTRY *Entries, - __out PULONG NumberOfEntries + _Out_ PETW_PUBLISHER_ENTRY *Entries, + _Out_ PULONG NumberOfEntries ) { NTSTATUS status; @@ -531,8 +543,8 @@ BOOLEAN EspEnumerateEtwPublishers( } BOOLEAN EspLookupEtwPublisherGuid( - __in PPH_STRINGREF PublisherName, - __out PGUID Guid + _In_ PPH_STRINGREF PublisherName, + _Out_ PGUID Guid ) { BOOLEAN result; @@ -562,10 +574,10 @@ BOOLEAN EspLookupEtwPublisherGuid( } VOID EspFormatTriggerInfo( - __in PES_TRIGGER_INFO Info, - __out PWSTR *TriggerString, - __out PWSTR *ActionString, - __out PPH_STRING *StringUsed + _In_ PES_TRIGGER_INFO Info, + _Out_ PWSTR *TriggerString, + _Out_ PWSTR *ActionString, + _Out_ PPH_STRING *StringUsed ) { PPH_STRING stringUsed = NULL; @@ -685,8 +697,8 @@ VOID EspFormatTriggerInfo( } VOID EsLoadServiceTriggerInfo( - __in struct _ES_TRIGGER_CONTEXT *Context, - __in SC_HANDLE ServiceHandle + _In_ struct _ES_TRIGGER_CONTEXT *Context, + _In_ SC_HANDLE ServiceHandle ) { PSERVICE_TRIGGER_INFO triggerInfo; @@ -726,8 +738,8 @@ VOID EsLoadServiceTriggerInfo( } BOOLEAN EsSaveServiceTriggerInfo( - __in struct _ES_TRIGGER_CONTEXT *Context, - __out PULONG Win32Result + _In_ struct _ES_TRIGGER_CONTEXT *Context, + _Out_ PULONG Win32Result ) { BOOLEAN result = TRUE; @@ -795,6 +807,16 @@ BOOLEAN EsSaveServiceTriggerInfo( dataItem->cbData = data->BinaryLength; dataItem->pData = data->Binary; } + else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_LEVEL) + { + dataItem->cbData = sizeof(UCHAR); + dataItem->pData = (PBYTE)&data->Byte; + } + else if (data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY || data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL) + { + dataItem->cbData = sizeof(ULONG64); + dataItem->pData = (PBYTE)&data->UInt64; + } } } } @@ -814,9 +836,9 @@ BOOLEAN EsSaveServiceTriggerInfo( } LOGICAL EspSetListViewItemParam( - __in HWND ListViewHandle, - __in INT Index, - __in PVOID Param + _In_ HWND ListViewHandle, + _In_ INT Index, + _In_ PVOID Param ) { LVITEM item; @@ -830,8 +852,8 @@ LOGICAL EspSetListViewItemParam( } VOID EsHandleEventServiceTrigger( - __in struct _ES_TRIGGER_CONTEXT *Context, - __in ULONG Event + _In_ struct _ES_TRIGGER_CONTEXT *Context, + _In_ ULONG Event ) { switch (Event) @@ -964,7 +986,7 @@ VOID EsHandleEventServiceTrigger( } static ULONG EspTriggerTypeStringToInteger( - __in PWSTR String + _In_ PWSTR String ) { ULONG i; @@ -979,8 +1001,8 @@ static ULONG EspTriggerTypeStringToInteger( } static int __cdecl EtwPublisherByNameCompareFunction( - __in const void *elem1, - __in const void *elem2 + _In_ const void *elem1, + _In_ const void *elem2 ) { PETW_PUBLISHER_ENTRY entry1 = (PETW_PUBLISHER_ENTRY)elem1; @@ -990,8 +1012,8 @@ static int __cdecl EtwPublisherByNameCompareFunction( } static VOID EspFixServiceTriggerControls( - __in HWND hwndDlg, - __in PES_TRIGGER_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PES_TRIGGER_CONTEXT Context ) { HWND typeComboBox; @@ -1087,7 +1109,7 @@ static VOID EspFixServiceTriggerControls( } PPH_STRING EspConvertNullsToNewLines( - __in PPH_STRING String + _In_ PPH_STRING String ) { PH_STRING_BUILDER sb; @@ -1110,7 +1132,7 @@ PPH_STRING EspConvertNullsToNewLines( } PPH_STRING EspConvertNewLinesToNulls( - __in PPH_STRING String + _In_ PPH_STRING String ) { PPH_STRING text; @@ -1151,7 +1173,7 @@ PPH_STRING EspConvertNewLinesToNulls( } PPH_STRING EspConvertNullsToSpaces( - __in PPH_STRING String + _In_ PPH_STRING String ) { PPH_STRING text; @@ -1169,8 +1191,8 @@ PPH_STRING EspConvertNullsToSpaces( } VOID EspFormatTriggerData( - __in PES_TRIGGER_DATA Data, - __out PPH_STRING *Text + _In_ PES_TRIGGER_DATA Data, + _Out_ PPH_STRING *Text ) { if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_STRING) @@ -1190,6 +1212,18 @@ VOID EspFormatTriggerData( { *Text = PhCreateString(L"(binary data)"); } + else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_LEVEL) + { + *Text = PhFormatString(L"(level) %u", Data->Byte); + } + else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ANY) + { + *Text = PhFormatString(L"(keyword any) 0x%I64x", Data->UInt64); + } + else if (Data->Type == SERVICE_TRIGGER_DATA_TYPE_KEYWORD_ALL) + { + *Text = PhFormatString(L"(keyword all) 0x%I64x", Data->UInt64); + } else { *Text = PhCreateString(L"(unknown type)"); @@ -1197,10 +1231,10 @@ VOID EspFormatTriggerData( } INT_PTR CALLBACK EspServiceTriggerDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PES_TRIGGER_CONTEXT context; @@ -1611,10 +1645,10 @@ INT_PTR CALLBACK EspServiceTriggerDlgProc( } static INT_PTR CALLBACK ValueDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PES_TRIGGER_CONTEXT context; diff --git a/2.x/trunk/plugins/ExtendedTools/ExtendedTools.vcxproj b/2.x/trunk/plugins/ExtendedTools/ExtendedTools.vcxproj index e47299e84..18ff9929c 100644 --- a/2.x/trunk/plugins/ExtendedTools/ExtendedTools.vcxproj +++ b/2.x/trunk/plugins/ExtendedTools/ExtendedTools.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/ExtendedTools/d3dkmt.h b/2.x/trunk/plugins/ExtendedTools/d3dkmt.h index 39b1f1a4f..f1f714b7e 100644 --- a/2.x/trunk/plugins/ExtendedTools/d3dkmt.h +++ b/2.x/trunk/plugins/ExtendedTools/d3dkmt.h @@ -7,14 +7,14 @@ typedef ULONG D3DKMT_HANDLE; typedef struct _D3DKMT_OPENADAPTERFROMDEVICENAME { - __in PCWSTR pDeviceName; - __out D3DKMT_HANDLE hAdapter; - __out LUID AdapterLuid; + _In_ PCWSTR pDeviceName; + _Out_ D3DKMT_HANDLE hAdapter; + _Out_ LUID AdapterLuid; } D3DKMT_OPENADAPTERFROMDEVICENAME; typedef struct _D3DKMT_CLOSEADAPTER { - __in D3DKMT_HANDLE hAdapter; + _In_ D3DKMT_HANDLE hAdapter; } D3DKMT_CLOSEADAPTER; typedef enum _D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT @@ -457,26 +457,26 @@ typedef union _D3DKMT_QUERYSTATISTICS_RESULT typedef struct _D3DKMT_QUERYSTATISTICS { - __in D3DKMT_QUERYSTATISTICS_TYPE Type; - __in LUID AdapterLuid; - __in_opt HANDLE hProcess; - __out D3DKMT_QUERYSTATISTICS_RESULT QueryResult; + _In_ D3DKMT_QUERYSTATISTICS_TYPE Type; + _In_ LUID AdapterLuid; + _In_opt_ HANDLE hProcess; + _Out_ D3DKMT_QUERYSTATISTICS_RESULT QueryResult; union { - __in D3DKMT_QUERYSTATISTICS_QUERY_SEGMENT QuerySegment; - __in D3DKMT_QUERYSTATISTICS_QUERY_SEGMENT QueryProcessSegment; - __in D3DKMT_QUERYSTATISTICS_QUERY_NODE QueryNode; - __in D3DKMT_QUERYSTATISTICS_QUERY_NODE QueryProcessNode; - __in D3DKMT_QUERYSTATISTICS_QUERY_VIDPNSOURCE QueryVidPnSource; - __in D3DKMT_QUERYSTATISTICS_QUERY_VIDPNSOURCE QueryProcessVidPnSource; + _In_ D3DKMT_QUERYSTATISTICS_QUERY_SEGMENT QuerySegment; + _In_ D3DKMT_QUERYSTATISTICS_QUERY_SEGMENT QueryProcessSegment; + _In_ D3DKMT_QUERYSTATISTICS_QUERY_NODE QueryNode; + _In_ D3DKMT_QUERYSTATISTICS_QUERY_NODE QueryProcessNode; + _In_ D3DKMT_QUERYSTATISTICS_QUERY_VIDPNSOURCE QueryVidPnSource; + _In_ D3DKMT_QUERYSTATISTICS_QUERY_VIDPNSOURCE QueryProcessVidPnSource; }; } D3DKMT_QUERYSTATISTICS; // Function pointers -typedef __checkReturn NTSTATUS (APIENTRY *PFND3DKMT_OPENADAPTERFROMDEVICENAME)(__inout D3DKMT_OPENADAPTERFROMDEVICENAME *); -typedef __checkReturn NTSTATUS (APIENTRY *PFND3DKMT_CLOSEADAPTER)(__in const D3DKMT_CLOSEADAPTER *); -typedef __checkReturn NTSTATUS (APIENTRY *PFND3DKMT_QUERYSTATISTICS)(__in const D3DKMT_QUERYSTATISTICS *); +typedef _Check_return_ NTSTATUS (APIENTRY *PFND3DKMT_OPENADAPTERFROMDEVICENAME)(_Inout_ D3DKMT_OPENADAPTERFROMDEVICENAME *); +typedef _Check_return_ NTSTATUS (APIENTRY *PFND3DKMT_CLOSEADAPTER)(_In_ const D3DKMT_CLOSEADAPTER *); +typedef _Check_return_ NTSTATUS (APIENTRY *PFND3DKMT_QUERYSTATISTICS)(_In_ const D3DKMT_QUERYSTATISTICS *); #endif diff --git a/2.x/trunk/plugins/ExtendedTools/disktab.c b/2.x/trunk/plugins/ExtendedTools/disktab.c index 66b933adb..52126f498 100644 --- a/2.x/trunk/plugins/ExtendedTools/disktab.c +++ b/2.x/trunk/plugins/ExtendedTools/disktab.c @@ -57,7 +57,7 @@ VOID EtInitializeDiskTab( } HWND NTAPI EtpDiskTabCreateFunction( - __in PVOID Context + _In_ PVOID Context ) { HWND hwnd; @@ -124,10 +124,10 @@ HWND NTAPI EtpDiskTabCreateFunction( } VOID NTAPI EtpDiskTabSelectionChangedCallback( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ) { if ((BOOLEAN)Parameter1) @@ -137,10 +137,10 @@ VOID NTAPI EtpDiskTabSelectionChangedCallback( } VOID NTAPI EtpDiskTabSaveContentCallback( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ) { PPH_FILE_STREAM fileStream = Parameter1; @@ -150,10 +150,10 @@ VOID NTAPI EtpDiskTabSaveContentCallback( } VOID NTAPI EtpDiskTabFontChangedCallback( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ) { if (DiskTreeNewHandle) @@ -161,8 +161,8 @@ VOID NTAPI EtpDiskTabFontChangedCallback( } BOOLEAN EtpDiskNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PET_DISK_NODE diskNode1 = *(PET_DISK_NODE *)Entry1; @@ -172,7 +172,7 @@ BOOLEAN EtpDiskNodeHashtableCompareFunction( } ULONG EtpDiskNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { #ifdef _M_IX86 @@ -183,7 +183,7 @@ ULONG EtpDiskNodeHashtableHashFunction( } VOID EtInitializeDiskTreeList( - __in HWND hwnd + _In_ HWND hwnd ) { DiskTreeNewHandle = hwnd; @@ -248,7 +248,7 @@ VOID EtSaveSettingsDiskTreeList( } PET_DISK_NODE EtAddDiskNode( - __in PET_DISK_ITEM DiskItem + _In_ PET_DISK_ITEM DiskItem ) { PET_DISK_NODE diskNode; @@ -275,7 +275,7 @@ PET_DISK_NODE EtAddDiskNode( } PET_DISK_NODE EtFindDiskNode( - __in PET_DISK_ITEM DiskItem + _In_ PET_DISK_ITEM DiskItem ) { ET_DISK_NODE lookupDiskNode; @@ -296,7 +296,7 @@ PET_DISK_NODE EtFindDiskNode( } VOID EtRemoveDiskNode( - __in PET_DISK_NODE DiskNode + _In_ PET_DISK_NODE DiskNode ) { ULONG index; @@ -323,7 +323,7 @@ VOID EtRemoveDiskNode( } VOID EtUpdateDiskNode( - __in PET_DISK_NODE DiskNode + _In_ PET_DISK_NODE DiskNode ) { memset(DiskNode->TextCache, 0, sizeof(PH_STRINGREF) * ETDSTNC_MAXIMUM); @@ -335,8 +335,8 @@ VOID EtUpdateDiskNode( #define SORT_FUNCTION(Column) EtpDiskTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl EtpDiskTreeNewCompare##Column( \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PET_DISK_NODE node1 = *(PET_DISK_NODE *)_elem1; \ @@ -395,11 +395,11 @@ BEGIN_SORT_FUNCTION(ResponseTime) END_SORT_FUNCTION BOOLEAN NTAPI EtpDiskTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PET_DISK_NODE node; @@ -645,7 +645,7 @@ BOOLEAN NTAPI EtpDiskTreeNewCallback( } PPH_STRING EtpGetDiskItemProcessName( - __in PET_DISK_ITEM DiskItem + _In_ PET_DISK_ITEM DiskItem ) { PH_FORMAT format[4]; @@ -687,8 +687,8 @@ PET_DISK_ITEM EtGetSelectedDiskItem( } VOID EtGetSelectedDiskItems( - __out PET_DISK_ITEM **DiskItems, - __out PULONG NumberOfDiskItems + _Out_ PET_DISK_ITEM **DiskItems, + _Out_ PULONG NumberOfDiskItems ) { PPH_LIST list; @@ -720,7 +720,7 @@ VOID EtDeselectAllDiskNodes( } VOID EtSelectAndEnsureVisibleDiskNode( - __in PET_DISK_NODE DiskNode + _In_ PET_DISK_NODE DiskNode ) { EtDeselectAllDiskNodes(); @@ -746,8 +746,8 @@ VOID EtCopyDiskList( } VOID EtWriteDiskList( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ) { PPH_LIST lines; @@ -769,7 +769,7 @@ VOID EtWriteDiskList( } VOID EtHandleDiskCommand( - __in ULONG Id + _In_ ULONG Id ) { switch (Id) @@ -835,9 +835,9 @@ VOID EtHandleDiskCommand( } VOID EtpInitializeDiskMenu( - __in PPH_EMENU Menu, - __in PET_DISK_ITEM *DiskItems, - __in ULONG NumberOfDiskItems + _In_ PPH_EMENU Menu, + _In_ PET_DISK_ITEM *DiskItems, + _In_ ULONG NumberOfDiskItems ) { PPH_EMENU_ITEM item; @@ -876,7 +876,7 @@ VOID EtpInitializeDiskMenu( } VOID EtShowDiskContextMenu( - __in POINT Location + _In_ POINT Location ) { PET_DISK_ITEM *diskItems; @@ -916,8 +916,8 @@ VOID EtShowDiskContextMenu( } static VOID NTAPI EtpDiskItemAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PET_DISK_ITEM diskItem = (PET_DISK_ITEM)Parameter; @@ -927,31 +927,31 @@ static VOID NTAPI EtpDiskItemAddedHandler( } static VOID NTAPI EtpDiskItemModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { ProcessHacker_Invoke(PhMainWndHandle, EtpOnDiskItemModified, (PET_DISK_ITEM)Parameter); } static VOID NTAPI EtpDiskItemRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { ProcessHacker_Invoke(PhMainWndHandle, EtpOnDiskItemRemoved, (PET_DISK_ITEM)Parameter); } static VOID NTAPI EtpDiskItemsUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { ProcessHacker_Invoke(PhMainWndHandle, EtpOnDiskItemsUpdated, NULL); } static VOID NTAPI EtpOnDiskItemAdded( - __in PVOID Parameter + _In_ PVOID Parameter ) { PET_DISK_ITEM diskItem = Parameter; @@ -968,7 +968,7 @@ static VOID NTAPI EtpOnDiskItemAdded( } static VOID NTAPI EtpOnDiskItemModified( - __in PVOID Parameter + _In_ PVOID Parameter ) { PET_DISK_ITEM diskItem = Parameter; @@ -977,7 +977,7 @@ static VOID NTAPI EtpOnDiskItemModified( } static VOID NTAPI EtpOnDiskItemRemoved( - __in PVOID Parameter + _In_ PVOID Parameter ) { PET_DISK_ITEM diskItem = Parameter; @@ -992,7 +992,7 @@ static VOID NTAPI EtpOnDiskItemRemoved( } static VOID NTAPI EtpOnDiskItemsUpdated( - __in PVOID Parameter + _In_ PVOID Parameter ) { ULONG i; diff --git a/2.x/trunk/plugins/ExtendedTools/disktabp.h b/2.x/trunk/plugins/ExtendedTools/disktabp.h index 6a04efef3..64f1254e4 100644 --- a/2.x/trunk/plugins/ExtendedTools/disktabp.h +++ b/2.x/trunk/plugins/ExtendedTools/disktabp.h @@ -2,69 +2,69 @@ #define DISKTABP_H HWND NTAPI EtpDiskTabCreateFunction( - __in PVOID Context + _In_ PVOID Context ); VOID NTAPI EtpDiskTabSelectionChangedCallback( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ); VOID NTAPI EtpDiskTabSaveContentCallback( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ); VOID NTAPI EtpDiskTabFontChangedCallback( - __in PVOID Parameter1, - __in PVOID Parameter2, - __in PVOID Parameter3, - __in PVOID Context + _In_ PVOID Parameter1, + _In_ PVOID Parameter2, + _In_ PVOID Parameter3, + _In_ PVOID Context ); BOOLEAN EtpDiskNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG EtpDiskNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID EtInitializeDiskTreeList( - __in HWND hwnd + _In_ HWND hwnd ); PET_DISK_NODE EtAddDiskNode( - __in PET_DISK_ITEM DiskItem + _In_ PET_DISK_ITEM DiskItem ); PET_DISK_NODE EtFindDiskNode( - __in PET_DISK_ITEM DiskItem + _In_ PET_DISK_ITEM DiskItem ); VOID EtRemoveDiskNode( - __in PET_DISK_NODE DiskNode + _In_ PET_DISK_NODE DiskNode ); VOID EtUpdateDiskNode( - __in PET_DISK_NODE DiskNode + _In_ PET_DISK_NODE DiskNode ); BOOLEAN NTAPI EtpDiskTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); PPH_STRING EtpGetDiskItemProcessName( - __in PET_DISK_ITEM DiskItem + _In_ PET_DISK_ITEM DiskItem ); PET_DISK_ITEM EtGetSelectedDiskItem( @@ -72,8 +72,8 @@ PET_DISK_ITEM EtGetSelectedDiskItem( ); VOID EtGetSelectedDiskItems( - __out PET_DISK_ITEM **DiskItems, - __out PULONG NumberOfDiskItems + _Out_ PET_DISK_ITEM **DiskItems, + _Out_ PULONG NumberOfDiskItems ); VOID EtDeselectAllDiskNodes( @@ -81,7 +81,7 @@ VOID EtDeselectAllDiskNodes( ); VOID EtSelectAndEnsureVisibleDiskNode( - __in PET_DISK_NODE DiskNode + _In_ PET_DISK_NODE DiskNode ); VOID EtCopyDiskList( @@ -89,58 +89,58 @@ VOID EtCopyDiskList( ); VOID EtWriteDiskList( - __inout PPH_FILE_STREAM FileStream, - __in ULONG Mode + _Inout_ PPH_FILE_STREAM FileStream, + _In_ ULONG Mode ); VOID EtHandleDiskCommand( - __in ULONG Id + _In_ ULONG Id ); VOID EtpInitializeDiskMenu( - __in PPH_EMENU Menu, - __in PET_DISK_ITEM *DiskItems, - __in ULONG NumberOfDiskItems + _In_ PPH_EMENU Menu, + _In_ PET_DISK_ITEM *DiskItems, + _In_ ULONG NumberOfDiskItems ); VOID EtShowDiskContextMenu( - __in POINT Location + _In_ POINT Location ); VOID NTAPI EtpDiskItemAddedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI EtpDiskItemModifiedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI EtpDiskItemRemovedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI EtpDiskItemsUpdatedHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI EtpOnDiskItemAdded( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID NTAPI EtpOnDiskItemModified( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID NTAPI EtpOnDiskItemRemoved( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID NTAPI EtpOnDiskItemsUpdated( - __in PVOID Parameter + _In_ PVOID Parameter ); #endif diff --git a/2.x/trunk/plugins/ExtendedTools/etwdisk.c b/2.x/trunk/plugins/ExtendedTools/etwdisk.c index 6f8c94cba..720ad79f5 100644 --- a/2.x/trunk/plugins/ExtendedTools/etwdisk.c +++ b/2.x/trunk/plugins/ExtendedTools/etwdisk.c @@ -31,22 +31,22 @@ typedef struct _ETP_DISK_PACKET } ETP_DISK_PACKET, *PETP_DISK_PACKET; VOID NTAPI EtpDiskItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ); BOOLEAN NTAPI EtpDiskHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI EtpDiskHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); BOOLEAN EtDiskEnabled = FALSE; @@ -130,8 +130,8 @@ PET_DISK_ITEM EtCreateDiskItem( } VOID NTAPI EtpDiskItemDeleteProcedure( - __in PVOID Object, - __in ULONG Flags + _In_ PVOID Object, + _In_ ULONG Flags ) { PET_DISK_ITEM diskItem = Object; @@ -151,8 +151,8 @@ VOID NTAPI EtpDiskItemDeleteProcedure( * \param Count The number of characters to hash. */ FORCEINLINE ULONG EtpHashStringIgnoreCase( - __in PWSTR String, - __in SIZE_T Count + _In_ PWSTR String, + _In_ SIZE_T Count ) { ULONG hash = (ULONG)Count; @@ -170,8 +170,8 @@ FORCEINLINE ULONG EtpHashStringIgnoreCase( } BOOLEAN NTAPI EtpDiskHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PET_DISK_ITEM diskItem1 = *(PET_DISK_ITEM *)Entry1; @@ -181,7 +181,7 @@ BOOLEAN NTAPI EtpDiskHashtableCompareFunction( } ULONG NTAPI EtpDiskHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PET_DISK_ITEM diskItem = *(PET_DISK_ITEM *)Entry; @@ -190,8 +190,8 @@ ULONG NTAPI EtpDiskHashtableHashFunction( } PET_DISK_ITEM EtReferenceDiskItem( - __in HANDLE ProcessId, - __in PPH_STRING FileName + _In_ HANDLE ProcessId, + _In_ PPH_STRING FileName ) { ET_DISK_ITEM lookupDiskItem; @@ -224,8 +224,8 @@ PET_DISK_ITEM EtReferenceDiskItem( return diskItem; } -__assumeLocked VOID EtpRemoveDiskItem( - __in PET_DISK_ITEM DiskItem +VOID EtpRemoveDiskItem( + _In_ PET_DISK_ITEM DiskItem ) { RemoveEntryList(&DiskItem->AgeListEntry); @@ -234,7 +234,7 @@ __assumeLocked VOID EtpRemoveDiskItem( } VOID EtDiskProcessDiskEvent( - __in PET_ETW_DISK_EVENT Event + _In_ PET_ETW_DISK_EVENT Event ) { PETP_DISK_PACKET packet; @@ -249,7 +249,7 @@ VOID EtDiskProcessDiskEvent( } VOID EtDiskProcessFileEvent( - __in PET_ETW_FILE_EVENT Event + _In_ PET_ETW_FILE_EVENT Event ) { PH_KEY_VALUE_PAIR pair; @@ -289,7 +289,7 @@ VOID EtDiskProcessFileEvent( } PPH_STRING EtFileObjectToFileName( - __in PVOID FileObject + _In_ PVOID FileObject ) { PH_KEY_VALUE_PAIR pair; @@ -315,8 +315,8 @@ PPH_STRING EtFileObjectToFileName( } VOID EtpProcessDiskPacket( - __in PETP_DISK_PACKET Packet, - __in ULONG RunId + _In_ PETP_DISK_PACKET Packet, + _In_ ULONG RunId ) { PET_ETW_DISK_EVENT diskEvent; @@ -414,11 +414,11 @@ VOID EtpProcessDiskPacket( } ULONG64 EtpCalculateAverage( - __in PULONG64 Buffer, - __in ULONG BufferSize, - __in ULONG BufferPosition, - __in ULONG BufferCount, - __in ULONG NumberToConsider + _In_ PULONG64 Buffer, + _In_ ULONG BufferSize, + _In_ ULONG BufferPosition, + _In_ ULONG BufferCount, + _In_ ULONG NumberToConsider ) { ULONG64 sum; @@ -449,8 +449,8 @@ ULONG64 EtpCalculateAverage( } static VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { static ULONG runCount = 0; diff --git a/2.x/trunk/plugins/ExtendedTools/etwmon.c b/2.x/trunk/plugins/ExtendedTools/etwmon.c index cca29b4ea..bae113def 100644 --- a/2.x/trunk/plugins/ExtendedTools/etwmon.c +++ b/2.x/trunk/plugins/ExtendedTools/etwmon.c @@ -24,27 +24,27 @@ #include "etwmon.h" ULONG NTAPI EtpEtwBufferCallback( - __in PEVENT_TRACE_LOGFILE Buffer + _In_ PEVENT_TRACE_LOGFILE Buffer ); VOID NTAPI EtpEtwEventCallback( - __in PEVENT_TRACE EventTrace + _In_ PEVENT_TRACE EventTrace ); NTSTATUS EtpEtwMonitorThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); ULONG NTAPI EtpRundownEtwBufferCallback( - __in PEVENT_TRACE_LOGFILE Buffer + _In_ PEVENT_TRACE_LOGFILE Buffer ); VOID NTAPI EtpRundownEtwEventCallback( - __in PEVENT_RECORD EventRecord + _In_ PEVENT_RECORD EventRecord ); NTSTATUS EtpRundownEtwMonitorThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); static GUID SystemTraceControlGuid_I = { 0x9e814aad, 0x3204, 0x11d2, { 0x9a, 0x82, 0x00, 0x60, 0x08, 0xa8, 0x69, 0x39 } }; @@ -152,7 +152,7 @@ VOID EtStartEtwSession( } ULONG EtpControlEtwSession( - __in ULONG ControlCode + _In_ ULONG ControlCode ) { // If we have a session handle, we use that instead of the logger name. @@ -184,14 +184,14 @@ VOID EtFlushEtwSession( } ULONG NTAPI EtpEtwBufferCallback( - __in PEVENT_TRACE_LOGFILE Buffer + _In_ PEVENT_TRACE_LOGFILE Buffer ) { return !EtpEtwExiting; } VOID NTAPI EtpEtwEventCallback( - __in PEVENT_TRACE EventTrace + _In_ PEVENT_TRACE EventTrace ) { if (memcmp(&EventTrace->Header.Guid, &DiskIoGuid_I, sizeof(GUID)) == 0) @@ -358,7 +358,7 @@ VOID NTAPI EtpEtwEventCallback( } NTSTATUS EtpEtwMonitorThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { ULONG result; @@ -456,14 +456,14 @@ ULONG EtStartEtwRundown( } ULONG NTAPI EtpRundownEtwBufferCallback( - __in PEVENT_TRACE_LOGFILE Buffer + _In_ PEVENT_TRACE_LOGFILE Buffer ) { return !EtpEtwExiting; } VOID NTAPI EtpRundownEtwEventCallback( - __in PEVENT_RECORD EventRecord + _In_ PEVENT_RECORD EventRecord ) { // TODO: Find a way to call CloseTrace when the enumeration finishes so we can @@ -500,7 +500,7 @@ VOID NTAPI EtpRundownEtwEventCallback( } NTSTATUS EtpRundownEtwMonitorThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { EVENT_TRACE_LOGFILE logFile; diff --git a/2.x/trunk/plugins/ExtendedTools/etwmon.h b/2.x/trunk/plugins/ExtendedTools/etwmon.h index f69a98797..efbab8740 100644 --- a/2.x/trunk/plugins/ExtendedTools/etwmon.h +++ b/2.x/trunk/plugins/ExtendedTools/etwmon.h @@ -112,25 +112,25 @@ typedef struct _ET_ETW_NETWORK_EVENT // etwstat VOID EtProcessDiskEvent( - __in PET_ETW_DISK_EVENT Event + _In_ PET_ETW_DISK_EVENT Event ); VOID EtProcessNetworkEvent( - __in PET_ETW_NETWORK_EVENT Event + _In_ PET_ETW_NETWORK_EVENT Event ); HANDLE EtThreadIdToProcessId( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ); // etwdisk VOID EtDiskProcessDiskEvent( - __in PET_ETW_DISK_EVENT Event + _In_ PET_ETW_DISK_EVENT Event ); VOID EtDiskProcessFileEvent( - __in PET_ETW_FILE_EVENT Event + _In_ PET_ETW_FILE_EVENT Event ); #endif diff --git a/2.x/trunk/plugins/ExtendedTools/etwprprp.c b/2.x/trunk/plugins/ExtendedTools/etwprprp.c index c83b20ed8..5f214399d 100644 --- a/2.x/trunk/plugins/ExtendedTools/etwprprp.c +++ b/2.x/trunk/plugins/ExtendedTools/etwprprp.c @@ -34,19 +34,19 @@ typedef struct _ET_DISKNET_CONTEXT } ET_DISKNET_CONTEXT, *PET_DISKNET_CONTEXT; VOID NTAPI DiskNetworkUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); INT_PTR CALLBACK EtpDiskNetworkPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtProcessEtwPropertiesInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PLUGIN_PROCESS_PROPCONTEXT propContext = Parameter; @@ -61,8 +61,8 @@ VOID EtProcessEtwPropertiesInitializing( } VOID NTAPI DiskNetworkUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PET_DISKNET_CONTEXT context = Context; @@ -72,8 +72,8 @@ VOID NTAPI DiskNetworkUpdateHandler( } VOID EtpUpdateDiskNetworkInfo( - __in HWND hwndDlg, - __in PET_DISKNET_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PET_DISKNET_CONTEXT Context ) { PET_PROCESS_BLOCK block = Context->Block; @@ -94,10 +94,10 @@ VOID EtpUpdateDiskNetworkInfo( } INT_PTR CALLBACK EtpDiskNetworkPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; diff --git a/2.x/trunk/plugins/ExtendedTools/etwstat.c b/2.x/trunk/plugins/ExtendedTools/etwstat.c index 7d5fea162..155677e46 100644 --- a/2.x/trunk/plugins/ExtendedTools/etwstat.c +++ b/2.x/trunk/plugins/ExtendedTools/etwstat.c @@ -24,13 +24,13 @@ #include "etwmon.h" VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI NetworkItemsUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID EtpUpdateProcessInformation( @@ -111,7 +111,7 @@ VOID EtEtwStatisticsUninitialization( } VOID EtProcessDiskEvent( - __in PET_ETW_DISK_EVENT Event + _In_ PET_ETW_DISK_EVENT Event ) { PPH_PROCESS_ITEM processItem; @@ -148,7 +148,7 @@ VOID EtProcessDiskEvent( } VOID EtProcessNetworkEvent( - __in PET_ETW_NETWORK_EVENT Event + _In_ PET_ETW_NETWORK_EVENT Event ) { PPH_PROCESS_ITEM processItem; @@ -213,8 +213,8 @@ VOID EtProcessNetworkEvent( } static VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { static ULONG runCount = 0; // MUST keep in sync with runCount in process provider @@ -316,7 +316,7 @@ static VOID NTAPI ProcessesUpdatedCallback( } static VOID NTAPI EtpInvalidateNetworkNode( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_NETWORK_ITEM networkItem = Parameter; @@ -329,8 +329,8 @@ static VOID NTAPI EtpInvalidateNetworkNode( } static VOID NTAPI NetworkItemsUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PLIST_ENTRY listEntry; @@ -386,7 +386,7 @@ VOID EtpUpdateProcessInformation( } HANDLE EtThreadIdToProcessId( - __in HANDLE ThreadId + _In_ HANDLE ThreadId ) { PSYSTEM_PROCESS_INFORMATION process; diff --git a/2.x/trunk/plugins/ExtendedTools/etwsys.c b/2.x/trunk/plugins/ExtendedTools/etwsys.c index 78f5272cc..fd44f4f04 100644 --- a/2.x/trunk/plugins/ExtendedTools/etwsys.c +++ b/2.x/trunk/plugins/ExtendedTools/etwsys.c @@ -40,7 +40,7 @@ static PH_GRAPH_STATE NetworkGraphState; static HWND NetworkPanel; VOID EtEtwSystemInformationInitializing( - __in PPH_PLUGIN_SYSINFO_POINTERS Pointers + _In_ PPH_PLUGIN_SYSINFO_POINTERS Pointers ) { PH_SYSINFO_SECTION section; @@ -61,10 +61,10 @@ VOID EtEtwSystemInformationInitializing( } BOOLEAN EtpDiskSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ) { switch (Message) @@ -181,10 +181,10 @@ BOOLEAN EtpDiskSectionCallback( } INT_PTR CALLBACK EtpDiskDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -254,17 +254,17 @@ INT_PTR CALLBACK EtpDiskDialogProc( } INT_PTR CALLBACK EtpDiskPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { return FALSE; } VOID EtpNotifyDiskGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -395,7 +395,7 @@ VOID EtpUpdateDiskPanel( } PPH_PROCESS_RECORD EtpReferenceMaxDiskRecord( - __in LONG Index + _In_ LONG Index ) { LARGE_INTEGER time; @@ -413,7 +413,7 @@ PPH_PROCESS_RECORD EtpReferenceMaxDiskRecord( } PPH_STRING EtpGetMaxDiskString( - __in LONG Index + _In_ LONG Index ) { PPH_PROCESS_RECORD maxProcessRecord; @@ -433,10 +433,10 @@ PPH_STRING EtpGetMaxDiskString( } BOOLEAN EtpNetworkSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ) { switch (Message) @@ -553,10 +553,10 @@ BOOLEAN EtpNetworkSectionCallback( } INT_PTR CALLBACK EtpNetworkDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -626,17 +626,17 @@ INT_PTR CALLBACK EtpNetworkDialogProc( } INT_PTR CALLBACK EtpNetworkPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { return FALSE; } VOID EtpNotifyNetworkGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -767,7 +767,7 @@ VOID EtpUpdateNetworkPanel( } PPH_PROCESS_RECORD EtpReferenceMaxNetworkRecord( - __in LONG Index + _In_ LONG Index ) { LARGE_INTEGER time; @@ -785,7 +785,7 @@ PPH_PROCESS_RECORD EtpReferenceMaxNetworkRecord( } PPH_STRING EtpGetMaxNetworkString( - __in LONG Index + _In_ LONG Index ) { PPH_PROCESS_RECORD maxProcessRecord; diff --git a/2.x/trunk/plugins/ExtendedTools/etwsys.h b/2.x/trunk/plugins/ExtendedTools/etwsys.h index fbccbed4d..6909c0b82 100644 --- a/2.x/trunk/plugins/ExtendedTools/etwsys.h +++ b/2.x/trunk/plugins/ExtendedTools/etwsys.h @@ -4,28 +4,28 @@ // Disk section BOOLEAN EtpDiskSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); INT_PTR CALLBACK EtpDiskDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK EtpDiskPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtpNotifyDiskGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID EtpUpdateDiskGraph( @@ -37,38 +37,38 @@ VOID EtpUpdateDiskPanel( ); PPH_PROCESS_RECORD EtpReferenceMaxDiskRecord( - __in LONG Index + _In_ LONG Index ); PPH_STRING EtpGetMaxDiskString( - __in LONG Index + _In_ LONG Index ); // Network section BOOLEAN EtpNetworkSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); INT_PTR CALLBACK EtpNetworkDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK EtpNetworkPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtpNotifyNetworkGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID EtpUpdateNetworkGraph( @@ -80,11 +80,11 @@ VOID EtpUpdateNetworkPanel( ); PPH_PROCESS_RECORD EtpReferenceMaxNetworkRecord( - __in LONG Index + _In_ LONG Index ); PPH_STRING EtpGetMaxNetworkString( - __in LONG Index + _In_ LONG Index ); #endif diff --git a/2.x/trunk/plugins/ExtendedTools/exttools.h b/2.x/trunk/plugins/ExtendedTools/exttools.h index f578aace1..92882ef64 100644 --- a/2.x/trunk/plugins/ExtendedTools/exttools.h +++ b/2.x/trunk/plugins/ExtendedTools/exttools.h @@ -228,19 +228,19 @@ typedef struct _ET_NETWORK_BLOCK // main PET_PROCESS_BLOCK EtGetProcessBlock( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ); PET_NETWORK_BLOCK EtGetNetworkBlock( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ); // utils VOID EtFormatRate( - __in ULONG64 ValuePerPeriod, - __inout PPH_STRING *Buffer, - __out_opt PPH_STRINGREF String + _In_ ULONG64 ValuePerPeriod, + _Inout_ PPH_STRING *Buffer, + _Out_opt_ PPH_STRINGREF String ); // etwmon @@ -298,40 +298,40 @@ PET_DISK_ITEM EtCreateDiskItem( ); PET_DISK_ITEM EtReferenceDiskItem( - __in HANDLE ProcessId, - __in PPH_STRING FileName + _In_ HANDLE ProcessId, + _In_ PPH_STRING FileName ); PPH_STRING EtFileObjectToFileName( - __in PVOID FileObject + _In_ PVOID FileObject ); // procicon PET_PROCESS_ICON EtProcIconCreateProcessIcon( - __in HICON Icon + _In_ HICON Icon ); VOID EtProcIconReferenceProcessIcon( - __inout PET_PROCESS_ICON ProcessIcon + _Inout_ PET_PROCESS_ICON ProcessIcon ); VOID EtProcIconDereferenceProcessIcon( - __inout PET_PROCESS_ICON ProcessIcon + _Inout_ PET_PROCESS_ICON ProcessIcon ); PET_PROCESS_ICON EtProcIconReferenceSmallProcessIcon( - __inout PET_PROCESS_BLOCK Block + _Inout_ PET_PROCESS_BLOCK Block ); VOID EtProcIconNotifyProcessDelete( - __inout PET_PROCESS_BLOCK Block + _Inout_ PET_PROCESS_BLOCK Block ); // etwprprp VOID EtProcessEtwPropertiesInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ); // disktab @@ -409,71 +409,71 @@ ULONG EtGetGpuAdapterCount( ); ULONG EtGetGpuAdapterIndexFromNodeIndex( - __in ULONG NodeIndex + _In_ ULONG NodeIndex ); PPH_STRING EtGetGpuAdapterDescription( - __in ULONG Index + _In_ ULONG Index ); VOID EtAllocateGpuNodeBitMap( - __out PRTL_BITMAP BitMap + _Out_ PRTL_BITMAP BitMap ); VOID EtUpdateGpuNodeBitMap( - __in PRTL_BITMAP NewBitMap + _In_ PRTL_BITMAP NewBitMap ); VOID EtQueryProcessGpuStatistics( - __in HANDLE ProcessHandle, - __out PET_PROCESS_GPU_STATISTICS Statistics + _In_ HANDLE ProcessHandle, + _Out_ PET_PROCESS_GPU_STATISTICS Statistics ); // gpuprprp VOID EtProcessGpuPropertiesInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ); // treeext VOID EtProcessTreeNewInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID EtProcessTreeNewMessage( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID EtNetworkTreeNewInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID EtNetworkTreeNewMessage( - __in PVOID Parameter + _In_ PVOID Parameter ); ET_FIREWALL_STATUS EtQueryFirewallStatus( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ); // etwsys VOID EtEtwSystemInformationInitializing( - __in PPH_PLUGIN_SYSINFO_POINTERS Pointers + _In_ PPH_PLUGIN_SYSINFO_POINTERS Pointers ); // gpunodes VOID EtShowGpuNodesDialog( - __in HWND ParentWindowHandle, - __in PPH_SYSINFO_PARAMETERS Parameters + _In_ HWND ParentWindowHandle, + _In_ PPH_SYSINFO_PARAMETERS Parameters ); // gpusys VOID EtGpuSystemInformationInitializing( - __in PPH_PLUGIN_SYSINFO_POINTERS Pointers + _In_ PPH_PLUGIN_SYSINFO_POINTERS Pointers ); // iconext @@ -485,42 +485,42 @@ VOID EtRegisterNotifyIcons( // modsrv VOID EtShowModuleServicesDialog( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId, - __in PWSTR ModuleName + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId, + _In_ PWSTR ModuleName ); // objprp VOID EtHandlePropertiesInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ); // options VOID EtShowOptionsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ); // thrdact BOOLEAN EtUiCancelIoThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread ); // unldll VOID EtShowUnloadedDllsDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); // wswatch VOID EtShowWsWatchDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ); #endif diff --git a/2.x/trunk/plugins/ExtendedTools/gpumon.c b/2.x/trunk/plugins/ExtendedTools/gpumon.c index 06f5f126a..7ad6ede5a 100644 --- a/2.x/trunk/plugins/ExtendedTools/gpumon.c +++ b/2.x/trunk/plugins/ExtendedTools/gpumon.c @@ -312,7 +312,7 @@ BOOLEAN EtpInitializeD3DStatistics( } PETP_GPU_ADAPTER EtpAllocateGpuAdapter( - __in ULONG NumberOfSegments + _In_ ULONG NumberOfSegments ) { PETP_GPU_ADAPTER adapter; @@ -328,8 +328,8 @@ PETP_GPU_ADAPTER EtpAllocateGpuAdapter( } PPH_STRING EtpQueryDeviceDescription( - __in HDEVINFO DeviceInfoSet, - __in PSP_DEVINFO_DATA DeviceInfoData + _In_ HDEVINFO DeviceInfoSet, + _In_ PSP_DEVINFO_DATA DeviceInfoData ) { LOGICAL result; @@ -378,7 +378,7 @@ PPH_STRING EtpQueryDeviceDescription( } static VOID EtpUpdateSegmentInformation( - __in_opt PET_PROCESS_BLOCK Block + _In_opt_ PET_PROCESS_BLOCK Block ) { ULONG i; @@ -474,7 +474,7 @@ static VOID EtpUpdateSegmentInformation( } static VOID EtpUpdateNodeInformation( - __in_opt PET_PROCESS_BLOCK Block + _In_opt_ PET_PROCESS_BLOCK Block ) { ULONG i; @@ -558,8 +558,8 @@ static VOID EtpUpdateNodeInformation( } static VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { static ULONG runCount = 0; // MUST keep in sync with runCount in process provider @@ -688,7 +688,7 @@ ULONG EtGetGpuAdapterCount( } ULONG EtGetGpuAdapterIndexFromNodeIndex( - __in ULONG NodeIndex + _In_ ULONG NodeIndex ) { ULONG i; @@ -706,7 +706,7 @@ ULONG EtGetGpuAdapterIndexFromNodeIndex( } PPH_STRING EtGetGpuAdapterDescription( - __in ULONG Index + _In_ ULONG Index ) { PPH_STRING description; @@ -728,7 +728,7 @@ PPH_STRING EtGetGpuAdapterDescription( } VOID EtAllocateGpuNodeBitMap( - __out PRTL_BITMAP BitMap + _Out_ PRTL_BITMAP BitMap ) { SIZE_T numberOfBytes; @@ -741,7 +741,7 @@ VOID EtAllocateGpuNodeBitMap( } VOID EtUpdateGpuNodeBitMap( - __in PRTL_BITMAP NewBitMap + _In_ PRTL_BITMAP NewBitMap ) { PULONG buffer; @@ -753,8 +753,8 @@ VOID EtUpdateGpuNodeBitMap( } VOID EtQueryProcessGpuStatistics( - __in HANDLE ProcessHandle, - __out PET_PROCESS_GPU_STATISTICS Statistics + _In_ HANDLE ProcessHandle, + _Out_ PET_PROCESS_GPU_STATISTICS Statistics ) { NTSTATUS status; diff --git a/2.x/trunk/plugins/ExtendedTools/gpumon.h b/2.x/trunk/plugins/ExtendedTools/gpumon.h index 79b2632d5..799c11aab 100644 --- a/2.x/trunk/plugins/ExtendedTools/gpumon.h +++ b/2.x/trunk/plugins/ExtendedTools/gpumon.h @@ -3,42 +3,42 @@ // setupapi definitions -typedef __checkReturn HDEVINFO (WINAPI *_SetupDiGetClassDevsW)( - __in_opt CONST GUID *ClassGuid, - __in_opt PCWSTR Enumerator, - __in_opt HWND hwndParent, - __in DWORD Flags +typedef _Check_return_ HDEVINFO (WINAPI *_SetupDiGetClassDevsW)( + _In_opt_ CONST GUID *ClassGuid, + _In_opt_ PCWSTR Enumerator, + _In_opt_ HWND hwndParent, + _In_ DWORD Flags ); typedef BOOL (WINAPI *_SetupDiDestroyDeviceInfoList)( - __in HDEVINFO DeviceInfoSet + _In_ HDEVINFO DeviceInfoSet ); typedef BOOL (WINAPI *_SetupDiEnumDeviceInterfaces)( - __in HDEVINFO DeviceInfoSet, - __in_opt PSP_DEVINFO_DATA DeviceInfoData, - __in CONST GUID *InterfaceClassGuid, - __in DWORD MemberIndex, - __out PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData + _In_ HDEVINFO DeviceInfoSet, + _In_opt_ PSP_DEVINFO_DATA DeviceInfoData, + _In_ CONST GUID *InterfaceClassGuid, + _In_ DWORD MemberIndex, + _Out_ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData ); typedef BOOL (WINAPI *_SetupDiGetDeviceInterfaceDetailW)( - __in HDEVINFO DeviceInfoSet, - __in PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, - __out_bcount_opt(DeviceInterfaceDetailDataSize) PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, - __in DWORD DeviceInterfaceDetailDataSize, - __out_opt PDWORD RequiredSize, - __out_opt PSP_DEVINFO_DATA DeviceInfoData + _In_ HDEVINFO DeviceInfoSet, + _In_ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData, + _Out_writes_bytes_opt_(DeviceInterfaceDetailDataSize) PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData, + _In_ DWORD DeviceInterfaceDetailDataSize, + _Out_opt_ PDWORD RequiredSize, + _Out_opt_ PSP_DEVINFO_DATA DeviceInfoData ); typedef BOOL (WINAPI *_SetupDiGetDeviceRegistryPropertyW)( - __in HDEVINFO DeviceInfoSet, - __in PSP_DEVINFO_DATA DeviceInfoData, - __in DWORD Property, - __out_opt PDWORD PropertyRegDataType, - __out_opt PBYTE PropertyBuffer, - __in DWORD PropertyBufferSize, - __out_opt PDWORD RequiredSize + _In_ HDEVINFO DeviceInfoSet, + _In_ PSP_DEVINFO_DATA DeviceInfoData, + _In_ DWORD Property, + _Out_opt_ PDWORD PropertyRegDataType, + _Out_opt_ PBYTE PropertyBuffer, + _In_ DWORD PropertyBufferSize, + _Out_opt_ PDWORD RequiredSize ); // Macros @@ -66,17 +66,17 @@ BOOLEAN EtpInitializeD3DStatistics( ); PETP_GPU_ADAPTER EtpAllocateGpuAdapter( - __in ULONG NumberOfSegments + _In_ ULONG NumberOfSegments ); PPH_STRING EtpQueryDeviceDescription( - __in HDEVINFO DeviceInfoSet, - __in PSP_DEVINFO_DATA DeviceInfoData + _In_ HDEVINFO DeviceInfoSet, + _In_ PSP_DEVINFO_DATA DeviceInfoData ); VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); #endif diff --git a/2.x/trunk/plugins/ExtendedTools/gpunodes.c b/2.x/trunk/plugins/ExtendedTools/gpunodes.c index d5e5ead5c..48af8e5f8 100644 --- a/2.x/trunk/plugins/ExtendedTools/gpunodes.c +++ b/2.x/trunk/plugins/ExtendedTools/gpunodes.c @@ -29,10 +29,10 @@ #define CHECKBOX_PADDING 3 INT_PTR CALLBACK EtpGpuNodesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static HWND WindowHandle; @@ -46,8 +46,8 @@ static PPH_SYSINFO_PARAMETERS SysInfoParameters; static PH_CALLBACK_REGISTRATION ProcessesUpdatedCallbackRegistration; VOID EtShowGpuNodesDialog( - __in HWND ParentWindowHandle, - __in PPH_SYSINFO_PARAMETERS Parameters + _In_ HWND ParentWindowHandle, + _In_ PPH_SYSINFO_PARAMETERS Parameters ) { SysInfoParameters = Parameters; @@ -60,8 +60,8 @@ VOID EtShowGpuNodesDialog( } static VOID ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PostMessage(WindowHandle, UPDATE_MSG, 0, 0); @@ -104,10 +104,10 @@ VOID EtpSaveNodeBitMap( } INT_PTR CALLBACK EtpGpuNodesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ExtendedTools/gpuprprp.c b/2.x/trunk/plugins/ExtendedTools/gpuprprp.c index a930b5d6d..989c56204 100644 --- a/2.x/trunk/plugins/ExtendedTools/gpuprprp.c +++ b/2.x/trunk/plugins/ExtendedTools/gpuprprp.c @@ -34,19 +34,19 @@ typedef struct _ET_GPU_CONTEXT } ET_GPU_CONTEXT, *PET_GPU_CONTEXT; VOID NTAPI GpuUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); INT_PTR CALLBACK EtpGpuPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtProcessGpuPropertiesInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PLUGIN_PROCESS_PROPCONTEXT propContext = Parameter; @@ -61,8 +61,8 @@ VOID EtProcessGpuPropertiesInitializing( } VOID NTAPI GpuUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PET_GPU_CONTEXT context = Context; @@ -72,8 +72,8 @@ VOID NTAPI GpuUpdateHandler( } VOID EtpUpdateGpuInfo( - __in HWND hwndDlg, - __in PET_GPU_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PET_GPU_CONTEXT Context ) { PET_PROCESS_BLOCK block = Context->Block; @@ -106,10 +106,10 @@ VOID EtpUpdateGpuInfo( } INT_PTR CALLBACK EtpGpuPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; diff --git a/2.x/trunk/plugins/ExtendedTools/gpusys.c b/2.x/trunk/plugins/ExtendedTools/gpusys.c index b675b35bd..b918e4459 100644 --- a/2.x/trunk/plugins/ExtendedTools/gpusys.c +++ b/2.x/trunk/plugins/ExtendedTools/gpusys.c @@ -38,7 +38,7 @@ static PH_GRAPH_STATE SharedGraphState; static HWND GpuPanel; VOID EtGpuSystemInformationInitializing( - __in PPH_PLUGIN_SYSINFO_POINTERS Pointers + _In_ PPH_PLUGIN_SYSINFO_POINTERS Pointers ) { PH_SYSINFO_SECTION section; @@ -52,10 +52,10 @@ VOID EtGpuSystemInformationInitializing( } BOOLEAN EtpGpuSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ) { switch (Message) @@ -157,10 +157,10 @@ VOID EtpTickGpuDialog( } INT_PTR CALLBACK EtpGpuDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -228,10 +228,10 @@ INT_PTR CALLBACK EtpGpuDialogProc( } INT_PTR CALLBACK EtpGpuPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -395,7 +395,7 @@ VOID EtpLayoutGpuGraphs( } VOID EtpNotifyGpuGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -468,7 +468,7 @@ VOID EtpNotifyGpuGraph( } VOID EtpNotifyDedicatedGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -537,7 +537,7 @@ VOID EtpNotifyDedicatedGraph( } VOID EtpNotifySharedGraph( - __in NMHDR *Header + _In_ NMHDR *Header ) { switch (Header->code) @@ -643,7 +643,7 @@ VOID EtpUpdateGpuPanel( } PPH_PROCESS_RECORD EtpReferenceMaxNodeRecord( - __in LONG Index + _In_ LONG Index ) { LARGE_INTEGER time; @@ -661,7 +661,7 @@ PPH_PROCESS_RECORD EtpReferenceMaxNodeRecord( } PPH_STRING EtpGetMaxNodeString( - __in LONG Index + _In_ LONG Index ) { PPH_PROCESS_RECORD maxProcessRecord; diff --git a/2.x/trunk/plugins/ExtendedTools/gpusys.h b/2.x/trunk/plugins/ExtendedTools/gpusys.h index 39752944d..92770fb9c 100644 --- a/2.x/trunk/plugins/ExtendedTools/gpusys.h +++ b/2.x/trunk/plugins/ExtendedTools/gpusys.h @@ -4,10 +4,10 @@ #define ET_GPU_PADDING 3 BOOLEAN EtpGpuSectionCallback( - __in PPH_SYSINFO_SECTION Section, - __in PH_SYSINFO_SECTION_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2 + _In_ PPH_SYSINFO_SECTION Section, + _In_ PH_SYSINFO_SECTION_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2 ); VOID EtpInitializeGpuDialog( @@ -23,17 +23,17 @@ VOID EtpTickGpuDialog( ); INT_PTR CALLBACK EtpGpuDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK EtpGpuPanelDialogProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtpCreateGpuGraphs( @@ -45,15 +45,15 @@ VOID EtpLayoutGpuGraphs( ); VOID EtpNotifyGpuGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID EtpNotifyDedicatedGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID EtpNotifySharedGraph( - __in NMHDR *Header + _In_ NMHDR *Header ); VOID EtpUpdateGpuGraphs( @@ -65,11 +65,11 @@ VOID EtpUpdateGpuPanel( ); PPH_PROCESS_RECORD EtpReferenceMaxNodeRecord( - __in LONG Index + _In_ LONG Index ); PPH_STRING EtpGetMaxNodeString( - __in LONG Index + _In_ LONG Index ); PPH_STRING EtpGetGpuNameString( diff --git a/2.x/trunk/plugins/ExtendedTools/iconext.c b/2.x/trunk/plugins/ExtendedTools/iconext.c index 4f0aa9792..230510ee1 100644 --- a/2.x/trunk/plugins/ExtendedTools/iconext.c +++ b/2.x/trunk/plugins/ExtendedTools/iconext.c @@ -28,27 +28,27 @@ #define NETWORK_ICON_ID 3 VOID EtpGpuIconUpdateCallback( - __in struct _PH_NF_ICON *Icon, - __out PVOID *NewIconOrBitmap, - __out PULONG Flags, - __out PPH_STRING *NewText, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _Out_ PVOID *NewIconOrBitmap, + _Out_ PULONG Flags, + _Out_ PPH_STRING *NewText, + _In_opt_ PVOID Context ); VOID EtpDiskIconUpdateCallback( - __in struct _PH_NF_ICON *Icon, - __out PVOID *NewIconOrBitmap, - __out PULONG Flags, - __out PPH_STRING *NewText, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _Out_ PVOID *NewIconOrBitmap, + _Out_ PULONG Flags, + _Out_ PPH_STRING *NewText, + _In_opt_ PVOID Context ); VOID EtpNetworkIconUpdateCallback( - __in struct _PH_NF_ICON *Icon, - __out PVOID *NewIconOrBitmap, - __out PULONG Flags, - __out PPH_STRING *NewText, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _Out_ PVOID *NewIconOrBitmap, + _Out_ PULONG Flags, + _Out_ PPH_STRING *NewText, + _In_opt_ PVOID Context ); VOID EtRegisterNotifyIcons( @@ -91,11 +91,11 @@ VOID EtRegisterNotifyIcons( } VOID EtpGpuIconUpdateCallback( - __in struct _PH_NF_ICON *Icon, - __out PVOID *NewIconOrBitmap, - __out PULONG Flags, - __out PPH_STRING *NewText, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _Out_ PVOID *NewIconOrBitmap, + _Out_ PULONG Flags, + _Out_ PPH_STRING *NewText, + _In_opt_ PVOID Context ) { static PH_GRAPH_DRAW_INFO drawInfo = @@ -176,11 +176,11 @@ VOID EtpGpuIconUpdateCallback( } VOID EtpDiskIconUpdateCallback( - __in struct _PH_NF_ICON *Icon, - __out PVOID *NewIconOrBitmap, - __out PULONG Flags, - __out PPH_STRING *NewText, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _Out_ PVOID *NewIconOrBitmap, + _Out_ PULONG Flags, + _Out_ PPH_STRING *NewText, + _In_opt_ PVOID Context ) { static PH_GRAPH_DRAW_INFO drawInfo = @@ -278,11 +278,11 @@ VOID EtpDiskIconUpdateCallback( } VOID EtpNetworkIconUpdateCallback( - __in struct _PH_NF_ICON *Icon, - __out PVOID *NewIconOrBitmap, - __out PULONG Flags, - __out PPH_STRING *NewText, - __in_opt PVOID Context + _In_ struct _PH_NF_ICON *Icon, + _Out_ PVOID *NewIconOrBitmap, + _Out_ PULONG Flags, + _Out_ PPH_STRING *NewText, + _In_opt_ PVOID Context ) { static PH_GRAPH_DRAW_INFO drawInfo = diff --git a/2.x/trunk/plugins/ExtendedTools/main.c b/2.x/trunk/plugins/ExtendedTools/main.c index d839f5dbe..44f708122 100644 --- a/2.x/trunk/plugins/ExtendedTools/main.c +++ b/2.x/trunk/plugins/ExtendedTools/main.c @@ -24,107 +24,107 @@ #include "resource.h" VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI UnloadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI TreeNewMessageCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessPropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI HandlePropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ThreadMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ModuleMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI NetworkTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI SystemInformationInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI NetworkItemsUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessItemCreateCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ); VOID NTAPI ProcessItemDeleteCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ); VOID NTAPI NetworkItemCreateCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ); VOID NTAPI NetworkItemDeleteCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ); PPH_PLUGIN PluginInstance; @@ -152,9 +152,9 @@ PH_CALLBACK_REGISTRATION NetworkItemsUpdatedCallbackRegistration; static HANDLE ModuleProcessId; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -310,8 +310,8 @@ LOGICAL DllMain( } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { EtEtwStatisticsInitialization(); @@ -321,8 +321,8 @@ VOID NTAPI LoadCallback( } VOID NTAPI UnloadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { EtSaveSettingsDiskTreeList(); @@ -330,16 +330,16 @@ VOID NTAPI UnloadCallback( } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { EtShowOptionsDialog((HWND)Parameter); } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; @@ -374,8 +374,8 @@ VOID NTAPI MenuItemCallback( } VOID NTAPI TreeNewMessageCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_TREENEW_MESSAGE message = Parameter; @@ -387,8 +387,8 @@ VOID NTAPI TreeNewMessageCallback( } VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { if (EtEtwEnabled) @@ -398,8 +398,8 @@ VOID NTAPI MainWindowShowingCallback( } VOID NTAPI ProcessPropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { EtProcessGpuPropertiesInitializing(Parameter); @@ -407,16 +407,16 @@ VOID NTAPI ProcessPropertiesInitializingCallback( } VOID NTAPI HandlePropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { EtHandlePropertiesInitializing(Parameter); } VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; @@ -444,8 +444,8 @@ VOID NTAPI ProcessMenuInitializingCallback( } VOID NTAPI ThreadMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; @@ -470,8 +470,8 @@ VOID NTAPI ThreadMenuInitializingCallback( } VOID NTAPI ModuleMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; @@ -499,7 +499,7 @@ VOID NTAPI ModuleMenuInitializingCallback( else moduleItem = NULL; - if (menuItem = PhFindEMenuItem(menuInfo->Menu, 0, L"Inspect", 0)) + if (menuItem = PhFindEMenuItem(menuInfo->Menu, PH_EMENU_FIND_STARTSWITH, L"Inspect", 0)) insertIndex = PhIndexOfEMenuItem(menuInfo->Menu, menuItem) + 1; else insertIndex = 0; @@ -513,8 +513,8 @@ VOID NTAPI ModuleMenuInitializingCallback( } VOID NTAPI ProcessTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_TREENEW_INFORMATION treeNewInfo = Parameter; @@ -524,8 +524,8 @@ VOID NTAPI ProcessTreeNewInitializingCallback( } VOID NTAPI NetworkTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_TREENEW_INFORMATION treeNewInfo = Parameter; @@ -535,8 +535,8 @@ VOID NTAPI NetworkTreeNewInitializingCallback( } VOID NTAPI SystemInformationInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { if (EtGpuEnabled) @@ -546,8 +546,8 @@ VOID NTAPI SystemInformationInitializingCallback( } static VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PLIST_ENTRY listEntry; @@ -575,8 +575,8 @@ static VOID NTAPI ProcessesUpdatedCallback( } static VOID NTAPI NetworkItemsUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PLIST_ENTRY listEntry; @@ -602,22 +602,22 @@ static VOID NTAPI NetworkItemsUpdatedCallback( } PET_PROCESS_BLOCK EtGetProcessBlock( - __in PPH_PROCESS_ITEM ProcessItem + _In_ PPH_PROCESS_ITEM ProcessItem ) { return PhPluginGetObjectExtension(PluginInstance, ProcessItem, EmProcessItemType); } PET_NETWORK_BLOCK EtGetNetworkBlock( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ) { return PhPluginGetObjectExtension(PluginInstance, NetworkItem, EmNetworkItemType); } VOID EtInitializeProcessBlock( - __out PET_PROCESS_BLOCK Block, - __in PPH_PROCESS_ITEM ProcessItem + _Out_ PET_PROCESS_BLOCK Block, + _In_ PPH_PROCESS_ITEM ProcessItem ) { memset(Block, 0, sizeof(ET_PROCESS_BLOCK)); @@ -627,7 +627,7 @@ VOID EtInitializeProcessBlock( } VOID EtDeleteProcessBlock( - __in PET_PROCESS_BLOCK Block + _In_ PET_PROCESS_BLOCK Block ) { ULONG i; @@ -643,8 +643,8 @@ VOID EtDeleteProcessBlock( } VOID EtInitializeNetworkBlock( - __out PET_NETWORK_BLOCK Block, - __in PPH_NETWORK_ITEM NetworkItem + _Out_ PET_NETWORK_BLOCK Block, + _In_ PPH_NETWORK_ITEM NetworkItem ) { memset(Block, 0, sizeof(ET_NETWORK_BLOCK)); @@ -654,7 +654,7 @@ VOID EtInitializeNetworkBlock( } VOID EtDeleteNetworkBlock( - __in PET_NETWORK_BLOCK Block + _In_ PET_NETWORK_BLOCK Block ) { ULONG i; @@ -668,36 +668,36 @@ VOID EtDeleteNetworkBlock( } VOID NTAPI ProcessItemCreateCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { EtInitializeProcessBlock(Extension, Object); } VOID NTAPI ProcessItemDeleteCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { EtDeleteProcessBlock(Extension); } VOID NTAPI NetworkItemCreateCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { EtInitializeNetworkBlock(Extension, Object); } VOID NTAPI NetworkItemDeleteCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { EtDeleteNetworkBlock(Extension); diff --git a/2.x/trunk/plugins/ExtendedTools/modsrv.c b/2.x/trunk/plugins/ExtendedTools/modsrv.c index a89e955b2..b4e6f57f1 100644 --- a/2.x/trunk/plugins/ExtendedTools/modsrv.c +++ b/2.x/trunk/plugins/ExtendedTools/modsrv.c @@ -31,16 +31,16 @@ typedef struct _MODULE_SERVICES_CONTEXT } MODULE_SERVICES_CONTEXT, *PMODULE_SERVICES_CONTEXT; INT_PTR CALLBACK EtpModuleServicesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtShowModuleServicesDialog( - __in HWND ParentWindowHandle, - __in HANDLE ProcessId, - __in PWSTR ModuleName + _In_ HWND ParentWindowHandle, + _In_ HANDLE ProcessId, + _In_ PWSTR ModuleName ) { MODULE_SERVICES_CONTEXT context; @@ -58,10 +58,10 @@ VOID EtShowModuleServicesDialog( } INT_PTR CALLBACK EtpModuleServicesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ExtendedTools/objprp.c b/2.x/trunk/plugins/ExtendedTools/objprp.c index 1ae95ed08..27e3348af 100644 --- a/2.x/trunk/plugins/ExtendedTools/objprp.c +++ b/2.x/trunk/plugins/ExtendedTools/objprp.c @@ -30,33 +30,33 @@ typedef struct _COMMON_PAGE_CONTEXT } COMMON_PAGE_CONTEXT, *PCOMMON_PAGE_CONTEXT; HPROPSHEETPAGE EtpCommonCreatePage( - __in PPH_PLUGIN_HANDLE_PROPERTIES_CONTEXT Context, - __in PWSTR Template, - __in DLGPROC DlgProc + _In_ PPH_PLUGIN_HANDLE_PROPERTIES_CONTEXT Context, + _In_ PWSTR Template, + _In_ DLGPROC DlgProc ); INT CALLBACK EtpCommonPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ); INT_PTR CALLBACK EtpAlpcPortPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK EtpTpWorkerFactoryPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtHandlePropertiesInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PLUGIN_OBJECT_PROPERTIES objectProperties = Parameter; @@ -100,9 +100,9 @@ VOID EtHandlePropertiesInitializing( } static HPROPSHEETPAGE EtpCommonCreatePage( - __in PPH_PLUGIN_HANDLE_PROPERTIES_CONTEXT Context, - __in PWSTR Template, - __in DLGPROC DlgProc + _In_ PPH_PLUGIN_HANDLE_PROPERTIES_CONTEXT Context, + _In_ PWSTR Template, + _In_ DLGPROC DlgProc ) { HPROPSHEETPAGE propSheetPageHandle; @@ -132,9 +132,9 @@ static HPROPSHEETPAGE EtpCommonCreatePage( } INT CALLBACK EtpCommonPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ) { PCOMMON_PAGE_CONTEXT pageContext; @@ -150,9 +150,9 @@ INT CALLBACK EtpCommonPropPageProc( } static NTSTATUS EtpDuplicateHandleFromProcess( - __out PHANDLE Handle, - __in ACCESS_MASK DesiredAccess, - __in PCOMMON_PAGE_CONTEXT Context + _Out_ PHANDLE Handle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PCOMMON_PAGE_CONTEXT Context ) { NTSTATUS status; @@ -180,10 +180,10 @@ static NTSTATUS EtpDuplicateHandleFromProcess( } INT_PTR CALLBACK EtpAlpcPortPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -231,8 +231,8 @@ INT_PTR CALLBACK EtpAlpcPortPageDlgProc( } static BOOLEAN NTAPI EnumGenericModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { if (Module->Type == PH_MODULE_TYPE_MODULE || Module->Type == PH_MODULE_TYPE_WOW64_MODULE) @@ -245,10 +245,10 @@ static BOOLEAN NTAPI EnumGenericModulesCallback( } INT_PTR CALLBACK EtpTpWorkerFactoryPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ExtendedTools/options.c b/2.x/trunk/plugins/ExtendedTools/options.c index 41e29d17f..18429fc39 100644 --- a/2.x/trunk/plugins/ExtendedTools/options.c +++ b/2.x/trunk/plugins/ExtendedTools/options.c @@ -25,14 +25,14 @@ #include INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtShowOptionsDialog( - __in HWND ParentWindowHandle + _In_ HWND ParentWindowHandle ) { DialogBox( @@ -44,10 +44,10 @@ VOID EtShowOptionsDialog( } INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ExtendedTools/procicon.c b/2.x/trunk/plugins/ExtendedTools/procicon.c index 5ce92fd46..b964813c9 100644 --- a/2.x/trunk/plugins/ExtendedTools/procicon.c +++ b/2.x/trunk/plugins/ExtendedTools/procicon.c @@ -23,7 +23,7 @@ #include "exttools.h" PET_PROCESS_ICON EtProcIconCreateProcessIcon( - __in HICON Icon + _In_ HICON Icon ) { PET_PROCESS_ICON processIcon; @@ -36,14 +36,14 @@ PET_PROCESS_ICON EtProcIconCreateProcessIcon( } VOID EtProcIconReferenceProcessIcon( - __inout PET_PROCESS_ICON ProcessIcon + _Inout_ PET_PROCESS_ICON ProcessIcon ) { _InterlockedIncrement(&ProcessIcon->RefCount); } VOID EtProcIconDereferenceProcessIcon( - __inout PET_PROCESS_ICON ProcessIcon + _Inout_ PET_PROCESS_ICON ProcessIcon ) { if (_InterlockedDecrement(&ProcessIcon->RefCount) == 0) @@ -54,7 +54,7 @@ VOID EtProcIconDereferenceProcessIcon( } PET_PROCESS_ICON EtProcIconReferenceSmallProcessIcon( - __inout PET_PROCESS_BLOCK Block + _Inout_ PET_PROCESS_BLOCK Block ) { PET_PROCESS_ICON smallProcessIcon; @@ -85,7 +85,7 @@ PET_PROCESS_ICON EtProcIconReferenceSmallProcessIcon( } VOID EtProcIconNotifyProcessDelete( - __inout PET_PROCESS_BLOCK Block + _Inout_ PET_PROCESS_BLOCK Block ) { if (Block->SmallProcessIcon) diff --git a/2.x/trunk/plugins/ExtendedTools/thrdact.c b/2.x/trunk/plugins/ExtendedTools/thrdact.c index 2bad91d32..8b818d513 100644 --- a/2.x/trunk/plugins/ExtendedTools/thrdact.c +++ b/2.x/trunk/plugins/ExtendedTools/thrdact.c @@ -24,8 +24,8 @@ #include "resource.h" BOOLEAN EtUiCancelIoThread( - __in HWND hWnd, - __in PPH_THREAD_ITEM Thread + _In_ HWND hWnd, + _In_ PPH_THREAD_ITEM Thread ) { NTSTATUS status; diff --git a/2.x/trunk/plugins/ExtendedTools/treeext.c b/2.x/trunk/plugins/ExtendedTools/treeext.c index b6f2e6fdc..58e40033e 100644 --- a/2.x/trunk/plugins/ExtendedTools/treeext.c +++ b/2.x/trunk/plugins/ExtendedTools/treeext.c @@ -26,17 +26,17 @@ #include LONG EtpProcessTreeNewSortFunction( - __in PVOID Node1, - __in PVOID Node2, - __in ULONG SubId, - __in PVOID Context + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ ULONG SubId, + _In_ PVOID Context ); LONG EtpNetworkTreeNewSortFunction( - __in PVOID Node1, - __in PVOID Node2, - __in ULONG SubId, - __in PVOID Context + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ ULONG SubId, + _In_ PVOID Context ); typedef struct _COLUMN_INFO @@ -56,14 +56,14 @@ static GUID IID_INetFwMgr_I = { 0xf7898af5, 0xcac4, 0x4632, { 0xa2, 0xec, 0xda, static GUID CLSID_NetFwMgr_I = { 0x304ce942, 0x6e39, 0x40d8, { 0x94, 0x3a, 0xb9, 0x13, 0xc4, 0x0c, 0x9c, 0xd4 } }; VOID EtpAddTreeNewColumn( - __in PPH_PLUGIN_TREENEW_INFORMATION TreeNewInfo, - __in ULONG SubId, - __in PWSTR Text, - __in ULONG Width, - __in ULONG Alignment, - __in ULONG TextFlags, - __in BOOLEAN SortDescending, - __in PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction + _In_ PPH_PLUGIN_TREENEW_INFORMATION TreeNewInfo, + _In_ ULONG SubId, + _In_ PWSTR Text, + _In_ ULONG Width, + _In_ ULONG Alignment, + _In_ ULONG TextFlags, + _In_ BOOLEAN SortDescending, + _In_ PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction ) { PH_TREENEW_COLUMN column; @@ -86,7 +86,7 @@ VOID EtpAddTreeNewColumn( } VOID EtProcessTreeNewInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ) { static COLUMN_INFO columns[] = @@ -138,7 +138,7 @@ VOID EtProcessTreeNewInitializing( } static FLOAT EtpCalculateInclusiveGpuUsage( - __in PPH_PROCESS_NODE ProcessNode + _In_ PPH_PROCESS_NODE ProcessNode ) { FLOAT gpuUsage; @@ -155,7 +155,7 @@ static FLOAT EtpCalculateInclusiveGpuUsage( } VOID EtProcessTreeNewMessage( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PLUGIN_TREENEW_MESSAGE message = Parameter; @@ -355,10 +355,10 @@ VOID EtProcessTreeNewMessage( } LONG EtpProcessTreeNewSortFunction( - __in PVOID Node1, - __in PVOID Node2, - __in ULONG SubId, - __in PVOID Context + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ ULONG SubId, + _In_ PVOID Context ) { LONG result; @@ -476,7 +476,7 @@ LONG EtpProcessTreeNewSortFunction( } VOID EtNetworkTreeNewInitializing( - __in PVOID Parameter + _In_ PVOID Parameter ) { static COLUMN_INFO columns[] = @@ -508,7 +508,7 @@ VOID EtNetworkTreeNewInitializing( } VOID EtpUpdateFirewallStatus( - __inout PET_NETWORK_BLOCK Block + _Inout_ PET_NETWORK_BLOCK Block ) { if (!Block->FirewallStatusValid) @@ -519,7 +519,7 @@ VOID EtpUpdateFirewallStatus( } VOID EtNetworkTreeNewMessage( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_PLUGIN_TREENEW_MESSAGE message = Parameter; @@ -640,10 +640,10 @@ VOID EtNetworkTreeNewMessage( } LONG EtpNetworkTreeNewSortFunction( - __in PVOID Node1, - __in PVOID Node2, - __in ULONG SubId, - __in PVOID Context + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ ULONG SubId, + _In_ PVOID Context ) { LONG result; @@ -709,7 +709,7 @@ LONG EtpNetworkTreeNewSortFunction( } ET_FIREWALL_STATUS EtQueryFirewallStatus( - __in PPH_NETWORK_ITEM NetworkItem + _In_ PPH_NETWORK_ITEM NetworkItem ) { static INetFwMgr* manager = NULL; diff --git a/2.x/trunk/plugins/ExtendedTools/unldll.c b/2.x/trunk/plugins/ExtendedTools/unldll.c index 5be63b7ea..f5ffa4313 100644 --- a/2.x/trunk/plugins/ExtendedTools/unldll.c +++ b/2.x/trunk/plugins/ExtendedTools/unldll.c @@ -31,15 +31,15 @@ typedef struct _UNLOADED_DLLS_CONTEXT } UNLOADED_DLLS_CONTEXT, *PUNLOADED_DLLS_CONTEXT; INT_PTR CALLBACK EtpUnloadedDllsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtShowUnloadedDllsDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ) { UNLOADED_DLLS_CONTEXT context; @@ -60,8 +60,8 @@ VOID EtShowUnloadedDllsDialog( } BOOLEAN EtpRefreshUnloadedDlls( - __in HWND hwndDlg, - __in PUNLOADED_DLLS_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PUNLOADED_DLLS_CONTEXT Context ) { NTSTATUS status; @@ -216,9 +216,9 @@ BOOLEAN EtpRefreshUnloadedDlls( } static INT NTAPI EtpNumberCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_UNLOAD_EVENT_TRACE item1 = Item1; @@ -228,9 +228,9 @@ static INT NTAPI EtpNumberCompareFunction( } static INT NTAPI EtpBaseAddressCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_UNLOAD_EVENT_TRACE item1 = Item1; @@ -240,9 +240,9 @@ static INT NTAPI EtpBaseAddressCompareFunction( } static INT NTAPI EtpSizeCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_UNLOAD_EVENT_TRACE item1 = Item1; @@ -252,9 +252,9 @@ static INT NTAPI EtpSizeCompareFunction( } static INT NTAPI EtpTimeStampCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_UNLOAD_EVENT_TRACE item1 = Item1; @@ -264,9 +264,9 @@ static INT NTAPI EtpTimeStampCompareFunction( } static INT NTAPI EtpCheckSumCompareFunction( - __in PVOID Item1, - __in PVOID Item2, - __in_opt PVOID Context + _In_ PVOID Item1, + _In_ PVOID Item2, + _In_opt_ PVOID Context ) { PRTL_UNLOAD_EVENT_TRACE item1 = Item1; @@ -276,10 +276,10 @@ static INT NTAPI EtpCheckSumCompareFunction( } INT_PTR CALLBACK EtpUnloadedDllsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PUNLOADED_DLLS_CONTEXT context; diff --git a/2.x/trunk/plugins/ExtendedTools/utils.c b/2.x/trunk/plugins/ExtendedTools/utils.c index df76516e7..07bc45a1c 100644 --- a/2.x/trunk/plugins/ExtendedTools/utils.c +++ b/2.x/trunk/plugins/ExtendedTools/utils.c @@ -23,9 +23,9 @@ #include "exttools.h" VOID EtFormatRate( - __in ULONG64 ValuePerPeriod, - __inout PPH_STRING *Buffer, - __out_opt PPH_STRINGREF String + _In_ ULONG64 ValuePerPeriod, + _Inout_ PPH_STRING *Buffer, + _Out_opt_ PPH_STRINGREF String ) { ULONG64 number; diff --git a/2.x/trunk/plugins/ExtendedTools/wswatch.c b/2.x/trunk/plugins/ExtendedTools/wswatch.c index 3e82fc499..510d7a966 100644 --- a/2.x/trunk/plugins/ExtendedTools/wswatch.c +++ b/2.x/trunk/plugins/ExtendedTools/wswatch.c @@ -52,23 +52,23 @@ typedef struct _SYMBOL_LOOKUP_RESULT } SYMBOL_LOOKUP_RESULT, *PSYMBOL_LOOKUP_RESULT; VOID EtpReferenceWsWatchContext( - __inout PWS_WATCH_CONTEXT Context + _Inout_ PWS_WATCH_CONTEXT Context ); VOID EtpDereferenceWsWatchContext( - __inout PWS_WATCH_CONTEXT Context + _Inout_ PWS_WATCH_CONTEXT Context ); INT_PTR CALLBACK EtpWsWatchDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); VOID EtShowWsWatchDialog( - __in HWND ParentWindowHandle, - __in PPH_PROCESS_ITEM ProcessItem + _In_ HWND ParentWindowHandle, + _In_ PPH_PROCESS_ITEM ProcessItem ) { PWS_WATCH_CONTEXT context; @@ -89,14 +89,14 @@ VOID EtShowWsWatchDialog( } static VOID EtpReferenceWsWatchContext( - __inout PWS_WATCH_CONTEXT Context + _Inout_ PWS_WATCH_CONTEXT Context ) { _InterlockedIncrement(&Context->RefCount); } static VOID EtpDereferenceWsWatchContext( - __inout PWS_WATCH_CONTEXT Context + _Inout_ PWS_WATCH_CONTEXT Context ) { if (_InterlockedDecrement(&Context->RefCount) == 0) @@ -129,7 +129,7 @@ static VOID EtpDereferenceWsWatchContext( } static NTSTATUS EtpSymbolLookupFunction( - __in PVOID Parameter + _In_ PVOID Parameter ) { PSYMBOL_LOOKUP_RESULT result; @@ -170,8 +170,8 @@ static NTSTATUS EtpSymbolLookupFunction( } static VOID EtpQueueSymbolLookup( - __in PWS_WATCH_CONTEXT Context, - __in PVOID Address + _In_ PWS_WATCH_CONTEXT Context, + _In_ PVOID Address ) { PSYMBOL_LOOKUP_RESULT result; @@ -185,8 +185,8 @@ static VOID EtpQueueSymbolLookup( } static PPH_STRING EtpGetBasicSymbol( - __in PPH_SYMBOL_PROVIDER SymbolProvider, - __in ULONG64 Address + _In_ PPH_SYMBOL_PROVIDER SymbolProvider, + _In_ ULONG64 Address ) { ULONG64 modBase; @@ -224,8 +224,8 @@ static PPH_STRING EtpGetBasicSymbol( } static VOID EtpProcessSymbolLookupResults( - __in HWND hwndDlg, - __in PWS_WATCH_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PWS_WATCH_CONTEXT Context ) { PSINGLE_LIST_ENTRY listEntry; @@ -257,8 +257,8 @@ static VOID EtpProcessSymbolLookupResults( } static BOOLEAN EtpUpdateWsWatch( - __in HWND hwndDlg, - __in PWS_WATCH_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PWS_WATCH_CONTEXT Context ) { NTSTATUS status; @@ -377,8 +377,8 @@ static BOOLEAN EtpUpdateWsWatch( } static BOOLEAN NTAPI EnumGenericModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PWS_WATCH_CONTEXT context = Context; @@ -399,10 +399,10 @@ static BOOLEAN NTAPI EnumGenericModulesCallback( } INT_PTR CALLBACK EtpWsWatchDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PWS_WATCH_CONTEXT context; diff --git a/2.x/trunk/plugins/NetworkTools/CHANGELOG.txt b/2.x/trunk/plugins/NetworkTools/CHANGELOG.txt index b95c2d19e..4886334f6 100644 --- a/2.x/trunk/plugins/NetworkTools/CHANGELOG.txt +++ b/2.x/trunk/plugins/NetworkTools/CHANGELOG.txt @@ -1,3 +1,8 @@ +1.4 + * Fixed whois scrolling issue + * Fixed ping threading issues + * Fixed various memory leaks + 1.3 * Added plugin options for ping/tracert/whois * Added native pint/tracert/whois support diff --git a/2.x/trunk/plugins/NetworkTools/NetworkTools.rc b/2.x/trunk/plugins/NetworkTools/NetworkTools.rc index 9c5b85a28..0bd812e1f 100644 --- a/2.x/trunk/plugins/NetworkTools/NetworkTools.rc +++ b/2.x/trunk/plugins/NetworkTools/NetworkTools.rc @@ -49,8 +49,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,0,0 - PRODUCTVERSION 1,3,0,0 + FILEVERSION 1,5,0,0 + PRODUCTVERSION 1,5,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -67,12 +67,12 @@ BEGIN BEGIN VALUE "CompanyName", "dmex" VALUE "FileDescription", "Network Tools plugin for Process Hacker" - VALUE "FileVersion", "1.3.0.0" + VALUE "FileVersion", "1.5.0.0" VALUE "InternalName", "NetworkTools" VALUE "LegalCopyright", "Licensed under the GNU GPL, v3." VALUE "OriginalFilename", "NetworkTools.dll" VALUE "ProductName", "Network Tools plugin for Process Hacker" - VALUE "ProductVersion", "1.3.0.0" + VALUE "ProductVersion", "1.5.0.0" END END BLOCK "VarFileInfo" @@ -94,37 +94,37 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "Close",IDOK,263,162,50,14 EDITTEXT IDC_NETOUTPUTEDIT,7,7,305,152,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL,WS_EX_CLIENTEDGE - PUSHBUTTON "Retry",IDC_NETRETRY,210,162,50,14,WS_DISABLED + CONTROL "APNIC Whois Database",IDC_MORE_INFO,"SysLink",NOT WS_VISIBLE | WS_TABSTOP,7,163,77,12 END -IDD_OPTIONS DIALOGEX 0, 0, 215, 55 +IDD_OPTIONS DIALOGEX 0, 0, 215, 79 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Options" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,104,34,50,14 - PUSHBUTTON "Cancel",IDCANCEL,158,34,50,14 + DEFPUSHBUTTON "OK",IDOK,104,58,50,14 + PUSHBUTTON "Cancel",IDCANCEL,158,58,50,14 EDITTEXT IDC_MAXTIMEOUTTEXT,7,17,79,14,ES_AUTOHSCROLL | ES_NUMBER LTEXT "Timeout (milliseconds):",IDC_STATIC,9,7,73,8 + LTEXT "Ping Size (bytes):",IDC_STATIC,7,34,57,8 + EDITTEXT IDC_ICMP_BYTE_SIZE,7,45,79,14,ES_AUTOHSCROLL | ES_NUMBER END -IDD_PINGDIALOG DIALOGEX 0, 0, 269, 130 +IDD_PINGDIALOG DIALOGEX 0, 0, 323, 115 STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME EXSTYLE WS_EX_APPWINDOW CAPTION "Dialog" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,213,109,50,14 - LTEXT "Pinging X with X bytes of data:",IDC_MAINTEXT,7,7,255,16 - GROUPBOX "Ping statistics",IDC_ICMP_PANEL,7,58,255,49,0,WS_EX_TRANSPARENT - LTEXT "Pings Lost: 0 (0%)",IDC_PINGS_LOST,95,81,73,8 + DEFPUSHBUTTON "Close",IDOK,266,94,50,14 + LTEXT "Pinging X with X bytes of data:",IDC_MAINTEXT,7,7,309,16 + GROUPBOX "Ping statistics",IDC_ICMP_PANEL,7,56,185,52,0,WS_EX_TRANSPARENT + LTEXT "Pings Lost: 0 (0%)",IDC_PINGS_LOST,92,81,89,8 LTEXT "Minimum: 0ms",IDC_ICMP_MIN,13,81,73,8 LTEXT "Maximum: 0ms",IDC_ICMP_MAX,13,93,73,8 LTEXT "Average: 0ms",IDC_ICMP_AVG,13,69,73,8 - LTEXT "PingGraphLayout",IDC_PING_LAYOUT,7,26,255,27,NOT WS_VISIBLE | WS_BORDER - LTEXT "Bad Hashes: 0",IDC_BAD_HASH,177,69,73,8 - LTEXT "Anon Replies: 0",IDC_ANON_ADDR,177,81,73,8 - LTEXT "Pings Sent: 0",IDC_PINGS_SENT,95,69,73,8 + LTEXT "PingGraphLayout",IDC_PING_LAYOUT,7,26,309,27,NOT WS_VISIBLE | WS_BORDER + LTEXT "Pings Sent: 0",IDC_PINGS_SENT,92,69,89,8 END @@ -149,15 +149,15 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 208 TOPMARGIN, 7 - BOTTOMMARGIN, 48 + BOTTOMMARGIN, 72 END IDD_PINGDIALOG, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 262 + RIGHTMARGIN, 316 TOPMARGIN, 7 - BOTTOMMARGIN, 123 + BOTTOMMARGIN, 108 END END #endif // APSTUDIO_INVOKED diff --git a/2.x/trunk/plugins/NetworkTools/NetworkTools.vcxproj b/2.x/trunk/plugins/NetworkTools/NetworkTools.vcxproj index 108c6e244..b95537b23 100644 --- a/2.x/trunk/plugins/NetworkTools/NetworkTools.vcxproj +++ b/2.x/trunk/plugins/NetworkTools/NetworkTools.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/NetworkTools/main.c b/2.x/trunk/plugins/NetworkTools/main.c index e20bb1527..50e874946 100644 --- a/2.x/trunk/plugins/NetworkTools/main.c +++ b/2.x/trunk/plugins/NetworkTools/main.c @@ -30,8 +30,8 @@ PH_CALLBACK_REGISTRATION PluginMenuItemCallbackRegistration; PH_CALLBACK_REGISTRATION NetworkMenuInitializingCallbackRegistration; VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { DialogBox( @@ -43,8 +43,8 @@ VOID NTAPI ShowOptionsCallback( } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter; @@ -65,8 +65,8 @@ VOID NTAPI MenuItemCallback( } VOID NTAPI NetworkMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = (PPH_PLUGIN_MENU_INFORMATION)Parameter; @@ -99,9 +99,9 @@ VOID NTAPI NetworkMenuInitializingCallback( } LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -154,7 +154,4 @@ LOGICAL DllMain( } return TRUE; -} - - - +} \ No newline at end of file diff --git a/2.x/trunk/plugins/NetworkTools/nettools.h b/2.x/trunk/plugins/NetworkTools/nettools.h index f31682ceb..677e58608 100644 --- a/2.x/trunk/plugins/NetworkTools/nettools.h +++ b/2.x/trunk/plugins/NetworkTools/nettools.h @@ -24,6 +24,9 @@ #ifndef NETTOOLS_H #define NETTOOLS_H +#pragma comment(lib, "iphlpapi.lib") +#pragma comment(lib, "ws2_32.lib") + #define CINTERFACE #define COBJMACROS #include @@ -32,34 +35,47 @@ #include #include #include +#include +#include +#include +#include #include "resource.h" -#define SETTING_PREFIX L"ProcessHacker.NetworkTools." -#define SETTING_NAME_TRACERT_WINDOW_POSITION (SETTING_PREFIX L"WindowPosition") -#define SETTING_NAME_TRACERT_WINDOW_SIZE (SETTING_PREFIX L"WindowSize") -#define SETTING_NAME_PING_WINDOW_POSITION (SETTING_PREFIX L"PingWindowPosition") -#define SETTING_NAME_PING_WINDOW_SIZE (SETTING_PREFIX L"PingWindowSize") -#define SETTING_NAME_PING_TIMEOUT (SETTING_PREFIX L"PingMaxTimeout") +#define SETTING_PREFIX L"ProcessHacker.NetworkTools" +#define SETTING_NAME_TRACERT_WINDOW_POSITION (SETTING_PREFIX L".WindowPosition") +#define SETTING_NAME_TRACERT_WINDOW_SIZE (SETTING_PREFIX L".WindowSize") +#define SETTING_NAME_PING_WINDOW_POSITION (SETTING_PREFIX L".PingWindowPosition") +#define SETTING_NAME_PING_WINDOW_SIZE (SETTING_PREFIX L".PingWindowSize") +#define SETTING_NAME_PING_TIMEOUT (SETTING_PREFIX L".PingMaxTimeout") + +// ICMP Packet Length: (msdn: IcmpSendEcho2/Icmp6SendEcho2) +// The buffer must be large enough to hold at least one ICMP_ECHO_REPLY or ICMPV6_ECHO_REPLY structure +// + the number of bytes of data specified in the RequestSize parameter. +// This buffer should also be large enough to also hold 8 more bytes of data (the size of an ICMP error message) +// + space for an IO_STATUS_BLOCK structure. +#define ICMP_BUFFER_SIZE(Length, Buffer) ((Length + icmpEchoBuffer->MaximumLength) + 8 + sizeof(IO_STATUS_BLOCK)) extern PPH_PLUGIN PluginInstance; typedef enum _PH_NETWORK_ACTION { - NETWORK_ACTION_PING = 1, - NETWORK_ACTION_TRACEROUTE = 2, - NETWORK_ACTION_WHOIS = 3 + NETWORK_ACTION_PING, + NETWORK_ACTION_TRACEROUTE, + NETWORK_ACTION_WHOIS, + NETWORK_ACTION_FINISH } PH_NETWORK_ACTION; // output -#define NTM_RECEIVEDPING (WM_APP + NETWORK_ACTION_PING) #define NTM_RECEIVEDTRACE (WM_APP + NETWORK_ACTION_TRACEROUTE) #define NTM_RECEIVEDWHOIS (WM_APP + NETWORK_ACTION_WHOIS) +#define NTM_RECEIVEDFINISH (WM_APP + NETWORK_ACTION_FINISH) typedef struct _NETWORK_OUTPUT_CONTEXT { PH_NETWORK_ACTION Action; PH_LAYOUT_MANAGER LayoutManager; + PH_WORK_QUEUE PingWorkQueue; PH_GRAPH_STATE PingGraphState; PH_CIRCULAR_BUFFER_ULONG PingHistory; PH_CALLBACK_REGISTRATION ProcessesUpdatedRegistration; @@ -68,6 +84,7 @@ typedef struct _NETWORK_OUTPUT_CONTEXT HWND ParentHandle; HWND StatusHandle; HWND PingGraphHandle; + HWND OutputHandle; HANDLE ThreadHandle; HANDLE PipeReadHandle; HANDLE ProcessHandle; @@ -83,51 +100,50 @@ typedef struct _NETWORK_OUTPUT_CONTEXT ULONG PingSentCount; ULONG PingRecvCount; ULONG PingLossCount; - + PPH_NETWORK_ITEM NetworkItem; PH_IP_ADDRESS IpAddress; - PH_STRING_BUILDER ReceivedString; WCHAR addressString[65]; } NETWORK_OUTPUT_CONTEXT, *PNETWORK_OUTPUT_CONTEXT; NTSTATUS PhNetworkPingDialogThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID PerformNetworkAction( - __in PH_NETWORK_ACTION Action, - __in PPH_NETWORK_ITEM NetworkItem + _In_ PH_NETWORK_ACTION Action, + _In_ PPH_NETWORK_ITEM NetworkItem ); NTSTATUS NetworkPingThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); NTSTATUS NetworkTracertThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); NTSTATUS NetworkWhoisThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); INT_PTR CALLBACK NetworkOutputDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); #endif diff --git a/2.x/trunk/plugins/NetworkTools/options.c b/2.x/trunk/plugins/NetworkTools/options.c index 126641439..bb609b314 100644 --- a/2.x/trunk/plugins/NetworkTools/options.c +++ b/2.x/trunk/plugins/NetworkTools/options.c @@ -24,10 +24,10 @@ #include "nettools.h" INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/NetworkTools/output.c b/2.x/trunk/plugins/NetworkTools/output.c index 63ef21b55..f261e14da 100644 --- a/2.x/trunk/plugins/NetworkTools/output.c +++ b/2.x/trunk/plugins/NetworkTools/output.c @@ -26,10 +26,10 @@ static RECT MinimumSize = { -1, -1, -1, -1 }; static INT_PTR CALLBACK NetworkOutputDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PNETWORK_OUTPUT_CONTEXT context; @@ -45,9 +45,29 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( if (uMsg == WM_DESTROY) { - PhSaveWindowPlacementToSetting(SETTING_NAME_TRACERT_WINDOW_POSITION, SETTING_NAME_TRACERT_WINDOW_SIZE, hwndDlg); - PhDeleteStringBuilder(&context->ReceivedString); - RemoveProp(hwndDlg, L"Context"); + PhSaveWindowPlacementToSetting(SETTING_NAME_TRACERT_WINDOW_POSITION, SETTING_NAME_TRACERT_WINDOW_SIZE, hwndDlg); + PhDeleteLayoutManager(&context->LayoutManager); + + if (context->ProcessHandle) + { + // Terminate the child process. + PhTerminateProcess(context->ProcessHandle, STATUS_SUCCESS); + + // Close the child process handle. + NtClose(context->ProcessHandle); + } + + // Close the pipe handle. + if (context->PipeReadHandle) + NtClose(context->PipeReadHandle); + + // Close the pipe output thread. + if (context->ThreadHandle) + NtClose(context->ThreadHandle); + + RemoveProp(hwndDlg, L"Context"); + PhFree(context); + context = NULL; } } @@ -59,12 +79,13 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( case WM_INITDIALOG: { PH_RECTANGLE windowRectangle; - HANDLE dialogThread = INVALID_HANDLE_VALUE; - PhInitializeStringBuilder(&context->ReceivedString, PAGE_SIZE); + context->WindowHandle = hwndDlg; + context->OutputHandle = GetDlgItem(hwndDlg, IDC_NETOUTPUTEDIT); + PhInitializeLayoutManager(&context->LayoutManager, hwndDlg); - PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_NETOUTPUTEDIT), NULL, PH_ANCHOR_ALL); - PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_NETRETRY), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); + PhAddLayoutItem(&context->LayoutManager, context->OutputHandle, NULL, PH_ANCHOR_ALL); + PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_MORE_INFO), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); windowRectangle.Position = PhGetIntegerPairSetting(SETTING_NAME_TRACERT_WINDOW_POSITION); @@ -106,12 +127,26 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( { case NETWORK_ACTION_TRACEROUTE: { + HANDLE dialogThread = INVALID_HANDLE_VALUE; + + Static_SetText(context->WindowHandle, + PhaFormatString(L"Tracing route to %s...", context->addressString)->Buffer + ); + if (dialogThread = PhCreateThread(0, (PUSER_THREAD_START_ROUTINE)NetworkTracertThreadStart, (PVOID)context)) NtClose(dialogThread); } break; case NETWORK_ACTION_WHOIS: { + HANDLE dialogThread = INVALID_HANDLE_VALUE; + + Static_SetText(context->WindowHandle, + PhaFormatString(L"Whois %s...", context->addressString)->Buffer + ); + + ShowWindow(GetDlgItem(hwndDlg, IDC_MORE_INFO), SW_SHOW); + if (dialogThread = PhCreateThread(0, (PUSER_THREAD_START_ROUTINE)NetworkWhoisThreadStart, (PVOID)context)) NtClose(dialogThread); } @@ -123,9 +158,6 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( { switch (LOWORD(wParam)) { - case IDC_NETRETRY: - Button_Enable(GetDlgItem(hwndDlg, IDC_NETRETRY), FALSE); - break; case IDCANCEL: case IDOK: PostQuitMessage(0); @@ -139,25 +171,21 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( case WM_SIZING: PhResizingMinimumSize((PRECT)lParam, wParam, MinimumSize.right, MinimumSize.bottom); break; - case WM_CTLCOLORDLG: - case WM_CTLCOLORSTATIC: + case WM_CTLCOLORDLG: + case WM_CTLCOLORSTATIC: { HDC hDC = (HDC)wParam; HWND hwndChild = (HWND)lParam; - ULONG hwndChildID = 0; // Check if old graph colors are enabled. if (!PhGetIntegerSetting(L"GraphColorMode")) break; - // Get the control ID. - hwndChildID = GetDlgCtrlID(hwndChild); - // Set a transparent background for the control backcolor. SetBkMode(hDC, TRANSPARENT); // Check for our edit control and change the color. - if (hwndChildID == IDC_NETOUTPUTEDIT) + if (hwndChild == context->OutputHandle) { // Set text color as the Green PH graph text color. SetTextColor(hDC, RGB(124, 252, 0)); @@ -167,10 +195,33 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( } } break; + case WM_NOTIFY: + { + switch (((LPNMHDR)lParam)->code) + { + case NM_CLICK: + case NM_RETURN: + { + PNMLINK syslink = (PNMLINK)lParam; + + if (syslink->hdr.idFrom == IDC_MORE_INFO) + { + PhShellExecute( + PhMainWndHandle, + PhaConcatStrings2(L"http://wq.apnic.net/apnic-bin/whois.pl?searchtext=", context->addressString)->Buffer, + NULL + ); + } + } + break; + } + } + break; case NTM_RECEIVEDTRACE: { OEM_STRING inputString; UNICODE_STRING convertedString; + PH_STRING_BUILDER receivedString; if (wParam != 0) { @@ -179,25 +230,52 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( if (NT_SUCCESS(RtlOemStringToUnicodeString(&convertedString, &inputString, TRUE))) { - PhAppendStringBuilderEx(&context->ReceivedString, convertedString.Buffer, convertedString.Length); - RtlFreeUnicodeString(&convertedString); + USHORT i; + PPH_STRING windowText = NULL; + + PhInitializeStringBuilder(&receivedString, PAGE_SIZE); + + // Get the current output text. + windowText = PhGetWindowText(context->OutputHandle); + + // Append the current output text to the New string. + if (!PhIsNullOrEmptyString(windowText)) + PhAppendStringBuilder(&receivedString, windowText); + + PhDereferenceObject(windowText); + + // Skip unwanted characters + for (i = 0; i < inputString.Length; i++) + { + if (inputString.Buffer[i] == '#') + { + // Skip + } + else + { + PhAppendCharStringBuilder(&receivedString, inputString.Buffer[i]); + } + } // Remove leading newlines. - if (context->ReceivedString.String->Length >= 2 * 2 && - context->ReceivedString.String->Buffer[0] == '\r' && - context->ReceivedString.String->Buffer[1] == '\n') + if (receivedString.String->Length >= 2 * 2 && + receivedString.String->Buffer[0] == '\r' && + receivedString.String->Buffer[1] == '\n') { - PhRemoveStringBuilder(&context->ReceivedString, 0, 2); + PhRemoveStringBuilder(&receivedString, 0, 2); } - SetDlgItemText(hwndDlg, IDC_NETOUTPUTEDIT, context->ReceivedString.String->Buffer); + SetWindowText(context->OutputHandle, receivedString.String->Buffer); SendMessage( - GetDlgItem(hwndDlg, IDC_NETOUTPUTEDIT), + context->OutputHandle, EM_SETSEL, - context->ReceivedString.String->Length / 2 - 1, - context->ReceivedString.String->Length / 2 - 1 + receivedString.String->Length / 2 - 1, + receivedString.String->Length / 2 - 1 ); - SendMessage(GetDlgItem(hwndDlg, IDC_NETOUTPUTEDIT), WM_VSCROLL, SB_BOTTOM, 0); + SendMessage(context->OutputHandle, WM_VSCROLL, SB_BOTTOM, 0); + + PhDeleteStringBuilder(&receivedString); + RtlFreeUnicodeString(&convertedString); return TRUE; } } @@ -214,11 +292,11 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( inputString.Buffer = (PCHAR)lParam; inputString.Length = (USHORT)wParam; - PhInitializeStringBuilder(&receivedString, PAGE_SIZE); - if (NT_SUCCESS(RtlOemStringToUnicodeString(&convertedString, &inputString, TRUE))) { - SIZE_T i; + USHORT i; + + PhInitializeStringBuilder(&receivedString, PAGE_SIZE); // Remove leading newlines. for (i = 0; i < inputString.Length; i++) @@ -227,16 +305,13 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( { PhAppendStringBuilder(&receivedString, PhaCreateString(L"\r\n")); } - else if (inputString.Buffer[i] == '#') - { - // Skip - } else { PhAppendCharStringBuilder(&receivedString, inputString.Buffer[i]); } } + // Remove leading newlines. if (receivedString.String->Length >= 2 * 2 && receivedString.String->Buffer[0] == '\r' && receivedString.String->Buffer[1] == '\n') @@ -244,38 +319,54 @@ static INT_PTR CALLBACK NetworkOutputDlgProc( PhRemoveStringBuilder(&receivedString, 0, 4); } - SetDlgItemText(hwndDlg, IDC_NETOUTPUTEDIT, receivedString.String->Buffer); + SetWindowText(context->OutputHandle, receivedString.String->Buffer); SendMessage( - GetDlgItem(hwndDlg, IDC_NETOUTPUTEDIT), + context->OutputHandle, EM_SETSEL, receivedString.String->Length / 2 - 1, receivedString.String->Length / 2 - 1 ); - SendMessage(GetDlgItem(hwndDlg, IDC_NETOUTPUTEDIT), WM_VSCROLL, SB_BOTTOM, 0); + SendMessage(context->OutputHandle, WM_VSCROLL, SB_TOP, 0); PhDeleteStringBuilder(&receivedString); + RtlFreeUnicodeString(&convertedString); return TRUE; } } } break; + case NTM_RECEIVEDFINISH: + { + PPH_STRING windowText = PhGetWindowText(context->WindowHandle); + + if (windowText) + { + Static_SetText( + context->WindowHandle, + PhaFormatString(L"%s Finished.", windowText->Buffer)->Buffer + ); + PhDereferenceObject(windowText); + } + } + break; } return FALSE; } static NTSTATUS PhNetworkOutputDialogThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { BOOL result; MSG message; + HWND windowHandle; PH_AUTO_POOL autoPool; PNETWORK_OUTPUT_CONTEXT context = (PNETWORK_OUTPUT_CONTEXT)Parameter; PhInitializeAutoPool(&autoPool); - context->WindowHandle = CreateDialogParam( + windowHandle = CreateDialogParam( (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDD_OUTPUT), PhMainWndHandle, @@ -283,8 +374,8 @@ static NTSTATUS PhNetworkOutputDialogThreadStart( (LPARAM)Parameter ); - ShowWindow(context->WindowHandle, SW_SHOW); - SetForegroundWindow(context->WindowHandle); + ShowWindow(windowHandle, SW_SHOW); + SetForegroundWindow(windowHandle); while (result = GetMessage(&message, NULL, 0, 0)) { @@ -301,13 +392,13 @@ static NTSTATUS PhNetworkOutputDialogThreadStart( } PhDeleteAutoPool(&autoPool); - DestroyWindow(context->WindowHandle); - PhFree(context); + DestroyWindow(windowHandle); + return STATUS_SUCCESS; } static HFONT InitializeFont( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { LOGFONT logFont = { 0 }; @@ -330,8 +421,8 @@ static HFONT InitializeFont( } VOID PerformNetworkAction( - __in PH_NETWORK_ACTION Action, - __in PPH_NETWORK_ITEM NetworkItem + _In_ PH_NETWORK_ACTION Action, + _In_ PPH_NETWORK_ITEM NetworkItem ) { HANDLE dialogThread = INVALID_HANDLE_VALUE; diff --git a/2.x/trunk/plugins/NetworkTools/ping.c b/2.x/trunk/plugins/NetworkTools/ping.c index da8eee31f..3c08b1fd7 100644 --- a/2.x/trunk/plugins/NetworkTools/ping.c +++ b/2.x/trunk/plugins/NetworkTools/ping.c @@ -22,29 +22,12 @@ #include "nettools.h" -#include -#include -#include -#include - -#pragma comment(lib, "iphlpapi.lib") -#pragma comment(lib, "ws2_32.lib") - -// ICMP Packet Length: (msdn: IcmpSendEcho2/Icmp6SendEcho2) -// The buffer must be large enough to hold at least one ICMP_ECHO_REPLY or ICMPV6_ECHO_REPLY structure -// + the number of bytes of data specified in the RequestSize parameter. -// This buffer should also be large enough to also hold 8 more bytes of data (the size of an ICMP error message) -// + space for an IO_STATUS_BLOCK structure. -#define ICMP_IPv4_BUFFER_SIZE(icmpEchoBuffer) ((sizeof(ICMP_ECHO_REPLY) + icmpEchoBuffer->MaximumLength) + 8 + sizeof(IO_STATUS_BLOCK)) -#define ICMP_IPv6_BUFFER_SIZE(icmpEchoBuffer) ((sizeof(ICMPV6_ECHO_REPLY) + icmpEchoBuffer->MaximumLength) + 8 + sizeof(IO_STATUS_BLOCK)) - #define WM_PING_UPDATE (WM_APP + 151) -#define IDC_PING_GRAPH (55050) static RECT NormalGraphTextMargin = { 5, 5, 5, 5 }; static RECT NormalGraphTextPadding = { 3, 3, 3, 3 }; static HFONT InitializeFont( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { LOGFONT logFont = { 0 }; @@ -70,7 +53,7 @@ static HFONT InitializeFont( } static VOID PhNetworkPingUpdateGraph( - __in PNETWORK_OUTPUT_CONTEXT Context + _In_ PNETWORK_OUTPUT_CONTEXT Context ) { Context->PingGraphState.Valid = FALSE; @@ -88,8 +71,8 @@ static VOID PhNetworkPingUpdateGraph( * \param ArgPtr A pointer to the list of arguments. */ static PPH_ANSI_STRING PhFormatAnsiString_V( - __in __format_string PSTR Format, - __in va_list ArgPtr + _In_ _Printf_format_string_ PSTR Format, + _In_ va_list ArgPtr ) { PPH_ANSI_STRING string; @@ -117,7 +100,7 @@ static PPH_ANSI_STRING PhFormatAnsiString_V( * \param Format The format-control string. */ static PPH_ANSI_STRING PhFormatAnsiString( - __in __format_string PSTR Format, + _In_ _Printf_format_string_ PSTR Format, ... ) { @@ -128,8 +111,8 @@ static PPH_ANSI_STRING PhFormatAnsiString( return PhFormatAnsiString_V(Format, argptr); } -static NTSTATUS PhNetworkPingThreadStart( - __in PVOID Parameter +static ULONG PhNetworkPingThreadStart( + _In_ PVOID Parameter ) { HANDLE icmpHandle = INVALID_HANDLE_VALUE; @@ -140,24 +123,24 @@ static NTSTATUS PhNetworkPingThreadStart( PVOID icmpReplyBuffer = NULL; PPH_STRING phVersion = NULL; PPH_ANSI_STRING icmpEchoBuffer = NULL; - PNETWORK_OUTPUT_CONTEXT context = NULL; - static IP_OPTION_INFORMATION pingOptions = - { + IP_OPTION_INFORMATION pingOptions = + { 255, // Time To Live 0, // Type Of Service IP_FLAG_DF, // IP header flags 0 // Size of options data }; + PNETWORK_OUTPUT_CONTEXT context = (PNETWORK_OUTPUT_CONTEXT)Parameter; + __try - { - phVersion = PhGetPhVersion(); - icmpEchoBuffer = PhFormatAnsiString("processhacker_%S_0x0D06F00D_x1", phVersion->Buffer); - if (icmpEchoBuffer == NULL) + { + // Query PH version. + if ((phVersion = PhGetPhVersion()) == NULL) __leave; - context = (PNETWORK_OUTPUT_CONTEXT)Parameter; - if (context == NULL) + // Create ICMP echo buffer. + if ((icmpEchoBuffer = PhFormatAnsiString("processhacker_%S_0x0D06F00D_x1", phVersion->Buffer)) == NULL) __leave; if (context->IpAddress.Type == PH_IPV6_NETWORK_TYPE) @@ -179,7 +162,7 @@ static NTSTATUS PhNetworkPingThreadStart( icmp6RemoteAddr.sin6_port = _byteswap_ushort((USHORT)context->NetworkItem->RemoteEndpoint.Port); // Allocate ICMPv6 message. - icmpReplyLength = ICMP_IPv6_BUFFER_SIZE(icmpEchoBuffer); + icmpReplyLength = ICMP_BUFFER_SIZE(sizeof(ICMPV6_ECHO_REPLY), icmpEchoBuffer); icmpReplyBuffer = PhAllocate(icmpReplyLength); memset(icmpReplyBuffer, 0, icmpReplyLength); @@ -211,10 +194,15 @@ static NTSTATUS PhNetworkPingThreadStart( InterlockedIncrement(&context->PingLossCount); } - //if (icmp6ReplyStruct->Address.sin6_addr != context->IpAddress.In6Addr.u.Word) - //{ - // InterlockedIncrement(&context->UnknownAddrCount); - //} + if (_memicmp( + icmp6ReplyStruct->Address.sin6_addr, + context->IpAddress.In6Addr.u.Word, + sizeof(icmp6ReplyStruct->Address.sin6_addr) + ) != 0) + { + InterlockedIncrement(&context->UnknownAddrCount); + } + //if (icmp6ReplyStruct->DataSize == icmpEchoBuffer->MaximumLength) //{ // icmpPacketSignature = (_memicmp( @@ -223,6 +211,7 @@ static NTSTATUS PhNetworkPingThreadStart( // icmp6ReplyStruct->DataSize // ) == 0); //} + //if (icmpPacketSignature != TRUE) //{ // InterlockedIncrement(&context->HashFailCount); @@ -230,86 +219,10 @@ static NTSTATUS PhNetworkPingThreadStart( icmpCurrentPingMs = icmp6ReplyStruct->RoundTripTime; //icmpCurrentPingTtl = icmp6ReplyStruct->Options.Ttl; - - switch (icmp6ReplyStruct->Status) - { - case IP_DEST_HOST_UNREACHABLE: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp destination host unreachable. ErrCode: %u [%s]", - icmp6ReplyStruct->Status, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - case IP_DEST_NET_UNREACHABLE: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp destination network unreachable. ErrCode: %u [%s]", - icmp6ReplyStruct->Status, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - case IP_REQ_TIMED_OUT: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp request timed-out. ErrCode: %u [%s]", - icmp6ReplyStruct->Status, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - } } else { - ULONG icmpErrorCode = GetLastError(); - InterlockedIncrement(&context->PingLossCount); - - switch (icmpErrorCode) - { - case IP_BUF_TOO_SMALL: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp reply buffer too small. ErrCode: %u [%s]", - icmpErrorCode, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - case IP_REQ_TIMED_OUT: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp request timed-out. ErrCode: %u [%s]", - icmpErrorCode, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - default: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp generic failure. ErrCode: %u [%s]", - icmpErrorCode, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - } } } else @@ -329,49 +242,51 @@ static NTSTATUS PhNetworkPingThreadStart( icmpRemoteAddr = context->IpAddress.InAddr.S_un.S_addr; // Allocate ICMPv4 message. - icmpReplyLength = ICMP_IPv4_BUFFER_SIZE(icmpEchoBuffer); + icmpReplyLength = ICMP_BUFFER_SIZE(sizeof(ICMP_ECHO_REPLY), icmpEchoBuffer); icmpReplyBuffer = PhAllocate(icmpReplyLength); memset(icmpReplyBuffer, 0, icmpReplyLength); InterlockedIncrement(&context->PingSentCount); // Send ICMPv4 ping... - //if (WindowsVersion > WINDOWS_VISTA) - //{ - // // Vista SP1 and up we can specify the source address: - // icmpReplyCount = IcmpSendEcho2Ex( - // icmpHandle, - // NULL, - // NULL, - // NULL, - // icmpLocalAddr, - // icmpRemoteAddr, - // icmpEchoBuffer->Buffer, - // icmpEchoBuffer->MaximumLength, - // &pingOptions, - // icmpReplyBuffer, - // icmpReplyLength, - // context->MaxPingTimeout - // ); - //} - //else - - icmpReplyCount = IcmpSendEcho2( - icmpHandle, - NULL, - NULL, - NULL, - icmpRemoteAddr, - icmpEchoBuffer->Buffer, - icmpEchoBuffer->MaximumLength, - &pingOptions, - icmpReplyBuffer, - icmpReplyLength, - context->MaxPingTimeout - ); + if (WindowsVersion > WINDOWS_VISTA) + { + // Vista SP1 and up we can specify the source address: + icmpReplyCount = IcmpSendEcho2Ex( + icmpHandle, + NULL, + NULL, + NULL, + icmpLocalAddr, + icmpRemoteAddr, + icmpEchoBuffer->Buffer, + icmpEchoBuffer->MaximumLength, + &pingOptions, + icmpReplyBuffer, + icmpReplyLength, + context->MaxPingTimeout + ); + } + else + { + icmpReplyCount = IcmpSendEcho2( + icmpHandle, + NULL, + NULL, + NULL, + icmpRemoteAddr, + icmpEchoBuffer->Buffer, + icmpEchoBuffer->MaximumLength, + &pingOptions, + icmpReplyBuffer, + icmpReplyLength, + context->MaxPingTimeout + ); + } icmpReplyStruct = (PICMP_ECHO_REPLY)icmpReplyBuffer; - if (icmpReplyCount > 0 && icmpReplyStruct) + + if (icmpReplyStruct && icmpReplyCount > 0) { BOOLEAN icmpPacketSignature = FALSE; @@ -394,93 +309,17 @@ static NTSTATUS PhNetworkPingThreadStart( ) == 0); } - if (icmpPacketSignature != TRUE) - { - InterlockedIncrement(&context->HashFailCount); - } - icmpCurrentPingMs = icmpReplyStruct->RoundTripTime; icmpCurrentPingTtl = icmpReplyStruct->Options.Ttl; - switch (icmpReplyStruct->Status) + if (!icmpPacketSignature) { - case IP_DEST_HOST_UNREACHABLE: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp destination host unreachable. ErrCode: %u [%s]", - icmpReplyStruct->Status, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - case IP_DEST_NET_UNREACHABLE: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp destination network unreachable. ErrCode: %u [%s]", - icmpReplyStruct->Status, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - case IP_REQ_TIMED_OUT: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp request timed-out. ErrCode: %u [%s]", - icmpReplyStruct->Status, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; + InterlockedIncrement(&context->HashFailCount); } } else { - ULONG icmpErrorCode = GetLastError(); - InterlockedIncrement(&context->PingLossCount); - - switch (icmpErrorCode) - { - case IP_BUF_TOO_SMALL: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp reply buffer too small. ErrCode: %u [%s]", - icmpErrorCode, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - case IP_REQ_TIMED_OUT: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp request timed-out. ErrCode: %u [%s]", - icmpErrorCode, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - default: - { - PPH_STRING errorMessage = PhFormatString( - L"Icmp generic failure. ErrCode: %u [%s]", - icmpErrorCode, - context->addressString - ); - PhLogMessageEntry(PH_LOG_ENTRY_MESSAGE, errorMessage); - PhDereferenceObject(errorMessage); - } - break; - } } } @@ -497,51 +336,47 @@ static NTSTATUS PhNetworkPingThreadStart( } __finally { - if (phVersion); + if (phVersion) { PhDereferenceObject(phVersion); } - if (icmpEchoBuffer); + if (icmpEchoBuffer) { PhDereferenceObject(icmpEchoBuffer); } - if (icmpReplyBuffer) - { - PhFree(icmpReplyBuffer); - } - - if (icmpHandle) + if (icmpHandle != INVALID_HANDLE_VALUE) { IcmpCloseHandle(icmpHandle); } } + PostMessage(context->WindowHandle, WM_PING_UPDATE, 0, 0); + return STATUS_SUCCESS; } static VOID NTAPI NetworkPingUpdateHandler( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PNETWORK_OUTPUT_CONTEXT context = (PNETWORK_OUTPUT_CONTEXT)Context; - HANDLE dialogThread = INVALID_HANDLE_VALUE; - - // Queue up the next ping... - // This needs to be done to prevent slow-links from blocking the interval update. - if (dialogThread = PhCreateThread(0, (PUSER_THREAD_START_ROUTINE)PhNetworkPingThreadStart, (PVOID)context)) - NtClose(dialogThread); - PostMessage(context->WindowHandle, WM_PING_UPDATE, 0, 0); + // Queue up the next ping into our work queue... + PhQueueItemWorkQueue( + &context->PingWorkQueue, + PhNetworkPingThreadStart, + (PVOID)context + ); } static INT_PTR CALLBACK NetworkPingWndProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PNETWORK_OUTPUT_CONTEXT context = NULL; @@ -554,37 +389,6 @@ static INT_PTR CALLBACK NetworkPingWndProc( else { context = (PNETWORK_OUTPUT_CONTEXT)GetProp(hwndDlg, L"Context"); - if (uMsg == WM_NCDESTROY) - { - if (context->PingGraphHandle) - { - DestroyWindow(context->PingGraphHandle); - context->PingGraphHandle = NULL; - } - - PhSaveWindowPlacementToSetting( - SETTING_NAME_PING_WINDOW_POSITION, - SETTING_NAME_PING_WINDOW_SIZE, - hwndDlg - ); - - if (context->IconHandle) - { - DestroyIcon(context->IconHandle); - context->IconHandle = NULL; - } - - if (context->FontHandle) - { - DeleteObject(context->FontHandle); - context->FontHandle = NULL; - } - - PhDeleteGraphState(&context->PingGraphState); - PhDeleteLayoutManager(&context->LayoutManager); - RemoveProp(hwndDlg, L"Context"); - context = NULL; - } } if (context == NULL) @@ -603,6 +407,7 @@ static INT_PTR CALLBACK NetworkPingWndProc( // It's a good tradeoff since no one stares at the group boxes. PhSetWindowStyle(hwndDlg, WS_CLIPCHILDREN, WS_CLIPCHILDREN); + context->WindowHandle = hwndDlg; context->ParentHandle = GetParent(hwndDlg); context->StatusHandle = GetDlgItem(hwndDlg, IDC_MAINTEXT); context->MaxPingTimeout = PhGetIntegerSetting(SETTING_NAME_PING_TIMEOUT); @@ -617,13 +422,13 @@ static INT_PTR CALLBACK NetworkPingWndProc( context->PingGraphHandle = CreateWindow( PH_GRAPH_CLASSNAME, NULL, - WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP | GC_STYLE_DRAW_PANEL, // GC_STYLE_FADEOUT + WS_CLIPSIBLINGS | WS_VISIBLE | WS_CHILD | WS_BORDER | GC_STYLE_DRAW_PANEL, 0, 0, 3, 3, hwndDlg, - (HMENU)IDC_PING_GRAPH, + NULL, (HINSTANCE)PluginInstance->DllBase, NULL ); @@ -640,7 +445,9 @@ static INT_PTR CALLBACK NetworkPingWndProc( // Set window icon. if (context->IconHandle) SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)context->IconHandle); - + + // Initialize the WorkQueue with a maximum of 20 threads (fix pinging slow-links with a high interval update). + PhInitializeWorkQueue(&context->PingWorkQueue, 0, 20, 5000); PhInitializeGraphState(&context->PingGraphState); PhInitializeLayoutManager(&context->LayoutManager, hwndDlg); PhInitializeCircularBuffer_ULONG(&context->PingHistory, PhGetIntegerSetting(L"SampleCount")); @@ -651,8 +458,8 @@ static INT_PTR CALLBACK NetworkPingWndProc( PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_ICMP_MAX), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_PINGS_SENT), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_PINGS_LOST), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); - PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_BAD_HASH), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); - PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_ANON_ADDR), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); + //PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_BAD_HASH), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); + //PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_ANON_ADDR), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT); PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT); panelItem = PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_PING_LAYOUT), NULL, PH_ANCHOR_ALL); PhAddLayoutItemEx(&context->LayoutManager, context->PingGraphHandle, NULL, PH_ANCHOR_ALL, panelItem->Margin); @@ -664,7 +471,10 @@ static INT_PTR CALLBACK NetworkPingWndProc( { PhLoadWindowPlacementFromSetting(SETTING_NAME_PING_WINDOW_POSITION, SETTING_NAME_PING_WINDOW_SIZE, hwndDlg); } - + + // Initialize window layout. + PhLayoutManagerLayout(&context->LayoutManager); + // Convert IP Address to string format. if (context->IpAddress.Type == PH_IPV4_NETWORK_TYPE) { @@ -707,9 +517,31 @@ static INT_PTR CALLBACK NetworkPingWndProc( case WM_DESTROY: { PhUnregisterCallback( - PhGetGeneralCallback(GeneralCallbackProcessesUpdated), + PhGetGeneralCallback(GeneralCallbackProcessesUpdated), &context->ProcessesUpdatedRegistration + ); + + PhSaveWindowPlacementToSetting( + SETTING_NAME_PING_WINDOW_POSITION, + SETTING_NAME_PING_WINDOW_SIZE, + hwndDlg ); + + if (context->PingGraphHandle) + DestroyWindow(context->PingGraphHandle); + + if (context->IconHandle) + DestroyIcon(context->IconHandle); + + if (context->FontHandle) + DeleteObject(context->FontHandle); + + PhDeleteWorkQueue(&context->PingWorkQueue); + PhDeleteGraphState(&context->PingGraphState); + PhDeleteLayoutManager(&context->LayoutManager); + + RemoveProp(hwndDlg, L"Context"); + PhFree(context); } break; case WM_SIZE: @@ -753,21 +585,23 @@ static INT_PTR CALLBACK NetworkPingWndProc( } SetDlgItemText(hwndDlg, IDC_ICMP_AVG, PhaFormatString( - L"Average: %ums", pingAvgValue)->Buffer); + L"Average: %lums", pingAvgValue)->Buffer); SetDlgItemText(hwndDlg, IDC_ICMP_MIN, PhaFormatString( - L"Minimum: %ums", context->PingMinMs)->Buffer); + L"Minimum: %lums", context->PingMinMs)->Buffer); SetDlgItemText(hwndDlg, IDC_ICMP_MAX, PhaFormatString( - L"Maximum: %ums", context->PingMaxMs)->Buffer); + L"Maximum: %lums", context->PingMaxMs)->Buffer); SetDlgItemText(hwndDlg, IDC_PINGS_SENT, PhaFormatString( - L"Pings Sent: %u", context->PingSentCount)->Buffer); + L"Pings Sent: %lu", context->PingSentCount)->Buffer); SetDlgItemText(hwndDlg, IDC_PINGS_LOST, PhaFormatString( - L"Pings Lost: %u (0%%)", context->PingLossCount)->Buffer); - - SetDlgItemText(hwndDlg, IDC_BAD_HASH, PhaFormatString( - L"Bad Hashes: %u", context->HashFailCount)->Buffer); - SetDlgItemText(hwndDlg, IDC_ANON_ADDR, PhaFormatString( - L"Anon Replies: %u", context->UnknownAddrCount)->Buffer); + L"Pings Lost: %lu (%.0f%%)", context->PingLossCount, + ((FLOAT)context->PingLossCount / context->PingSentCount * 100) + )->Buffer); + + //SetDlgItemText(hwndDlg, IDC_BAD_HASH, PhaFormatString( + // L"Bad Hashes: %lu", context->HashFailCount)->Buffer); + //SetDlgItemText(hwndDlg, IDC_ANON_ADDR, PhaFormatString( + // L"Anon Replies: %lu", context->UnknownAddrCount)->Buffer); } break; case WM_NOTIFY: @@ -780,30 +614,8 @@ static INT_PTR CALLBACK NetworkPingWndProc( { PPH_GRAPH_GETDRAWINFO getDrawInfo = (PPH_GRAPH_GETDRAWINFO)header; PPH_GRAPH_DRAW_INFO drawInfo = getDrawInfo->DrawInfo; - - // Check if old graph colors are enabled. - if (PhGetIntegerSetting(L"GraphColorMode")) - { - drawInfo->BackColor = RGB(0x00, 0x00, 0x00); - drawInfo->LineColor1 = PhGetIntegerSetting(L"ColorCpuKernel"); - drawInfo->LineBackColor1 = PhHalveColorBrightness(drawInfo->LineColor1); - drawInfo->LineColor2 = PhGetIntegerSetting(L"ColorCpuUser"); - drawInfo->LineBackColor2 = PhHalveColorBrightness(drawInfo->LineColor2); - drawInfo->GridColor = RGB(0x00, 0x57, 0x00); - drawInfo->TextColor = RGB(0x00, 0xff, 0x00); - drawInfo->TextBoxColor = RGB(0x00, 0x22, 0x00); - } - else - { - drawInfo->BackColor = RGB(0xef, 0xef, 0xef); - drawInfo->LineColor1 = PhHalveColorBrightness(PhGetIntegerSetting(L"ColorCpuKernel")); - drawInfo->LineBackColor1 = PhMakeColorBrighter(drawInfo->LineColor1, 125); - drawInfo->LineColor2 = PhHalveColorBrightness(PhGetIntegerSetting(L"ColorCpuUser")); - drawInfo->LineBackColor2 = PhMakeColorBrighter(drawInfo->LineColor2, 125); - drawInfo->GridColor = RGB(0xc7, 0xc7, 0xc7); - drawInfo->TextColor = RGB(0x00, 0x00, 0x00); - drawInfo->TextBoxColor = RGB(0xe7, 0xe7, 0xe7); - } + + PhSiSetColorsGraphDrawInfo(drawInfo, PhGetIntegerSetting(L"ColorCpuKernel"), PhGetIntegerSetting(L"ColorCpuUser")); if (header->hwndFrom == context->PingGraphHandle) { @@ -848,7 +660,7 @@ static INT_PTR CALLBACK NetworkPingWndProc( // Scale the data. PhxfDivideSingle2U( context->PingGraphState.Data1, - (FLOAT)context->MaxPingTimeout, + (FLOAT)context->MaxPingTimeout, // maxGraphHeight drawInfo->LineDataCount ); @@ -888,17 +700,18 @@ static INT_PTR CALLBACK NetworkPingWndProc( } NTSTATUS PhNetworkPingDialogThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { BOOL result; MSG message; + HWND windowHandle; PH_AUTO_POOL autoPool; PNETWORK_OUTPUT_CONTEXT context = (PNETWORK_OUTPUT_CONTEXT)Parameter; PhInitializeAutoPool(&autoPool); - context->WindowHandle = CreateDialogParam( + windowHandle = CreateDialogParam( (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDD_PINGDIALOG), PhMainWndHandle, @@ -906,17 +719,15 @@ NTSTATUS PhNetworkPingDialogThreadStart( (LPARAM)Parameter ); - ShowWindow(context->WindowHandle, SW_SHOW); - SetForegroundWindow(context->WindowHandle); - - PostMessage(context->WindowHandle, WM_SIZE, 0, 0); + ShowWindow(windowHandle, SW_SHOW); + SetForegroundWindow(windowHandle); while (result = GetMessage(&message, NULL, 0, 0)) { if (result == -1) break; - if (!IsDialogMessage(context->WindowHandle, &message)) + if (!IsDialogMessage(windowHandle, &message)) { TranslateMessage(&message); DispatchMessage(&message); @@ -926,9 +737,7 @@ NTSTATUS PhNetworkPingDialogThreadStart( } PhDeleteAutoPool(&autoPool); - DestroyWindow(context->WindowHandle); - - PhFree(context); + DestroyWindow(windowHandle); return STATUS_SUCCESS; } \ No newline at end of file diff --git a/2.x/trunk/plugins/NetworkTools/resource.h b/2.x/trunk/plugins/NetworkTools/resource.h index bd8d555eb..699ee7eba 100644 --- a/2.x/trunk/plugins/NetworkTools/resource.h +++ b/2.x/trunk/plugins/NetworkTools/resource.h @@ -4,29 +4,27 @@ // #define IDD_OUTPUT 101 #define IDD_PINGDIALOG 102 -#define IDD_OPTIONS 109 -#define IDC_NETRESOLVECHECK 1001 -#define IDC_NETRETRY 1004 +#define IDD_OPTIONS 103 #define IDC_MAXTIMEOUTTEXT 1008 -#define IDC_NETOUTPUTEDIT 1008 -#define IDC_ICMP_PANEL 1012 -#define IDC_PINGS_LOST 1014 -#define IDC_ICMP_MIN 1015 -#define IDC_ICMP_MAX 1016 -#define IDC_ICMP_AVG 1017 -#define IDC_MAINTEXT 1018 -#define IDC_BAD_HASH 1019 -#define IDC_ANON_ADDR 1020 -#define IDC_PINGS_SENT 1021 -#define IDC_PING_LAYOUT 1076 +#define IDC_NETOUTPUTEDIT 1009 +#define IDC_ICMP_BYTE_SIZE 1010 +#define IDC_ICMP_PANEL 1011 +#define IDC_PINGS_LOST 1012 +#define IDC_ICMP_MIN 1013 +#define IDC_ICMP_MAX 1014 +#define IDC_ICMP_AVG 1015 +#define IDC_MAINTEXT 1016 +#define IDC_MORE_INFO 1019 +#define IDC_PINGS_SENT 1020 +#define IDC_PING_LAYOUT 1021 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_RESOURCE_VALUE 104 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1020 +#define _APS_NEXT_CONTROL_VALUE 1022 #define _APS_NEXT_SYMED_VALUE 104 #endif #endif diff --git a/2.x/trunk/plugins/NetworkTools/tracert.c b/2.x/trunk/plugins/NetworkTools/tracert.c index f7b7b60ee..49b15d95d 100644 --- a/2.x/trunk/plugins/NetworkTools/tracert.c +++ b/2.x/trunk/plugins/NetworkTools/tracert.c @@ -23,7 +23,7 @@ #include "nettools.h" static NTSTATUS StdOutNetworkTracertThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { NTSTATUS status; @@ -46,36 +46,22 @@ static NTSTATUS StdOutNetworkTracertThreadStart( ); if (!NT_SUCCESS(status)) - { - PPH_STRING windowText = PhGetWindowText(context->WindowHandle); - - if (windowText) - { - Static_SetText(context->WindowHandle, PhFormatString(L"%s Finished.", windowText->Buffer)->Buffer); - PhDereferenceObject(windowText); - } - - goto ExitCleanup; - } + break; SendMessage(context->WindowHandle, NTM_RECEIVEDTRACE, (WPARAM)isb.Information, (LPARAM)buffer); } -ExitCleanup: - NtClose(context->PipeReadHandle); + SendMessage(context->WindowHandle, NTM_RECEIVEDFINISH, 0, 0); return STATUS_SUCCESS; } NTSTATUS NetworkTracertThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { HANDLE pipeWriteHandle = INVALID_HANDLE_VALUE; PNETWORK_OUTPUT_CONTEXT context = (PNETWORK_OUTPUT_CONTEXT)Parameter; - - Static_SetText(context->WindowHandle, - PhFormatString(L"Tracing route to %s...", context->addressString)->Buffer); if (CreatePipe(&context->PipeReadHandle, &pipeWriteHandle, NULL, 0)) { diff --git a/2.x/trunk/plugins/NetworkTools/whois.c b/2.x/trunk/plugins/NetworkTools/whois.c index f31fecdeb..84eaf2f36 100644 --- a/2.x/trunk/plugins/NetworkTools/whois.c +++ b/2.x/trunk/plugins/NetworkTools/whois.c @@ -27,16 +27,16 @@ #include static BOOLEAN ReadRequestString( - __in HINTERNET Handle, - __out_z PSTR* Data, - __out ULONG* DataLength + _In_ HINTERNET Handle, + _Out_ _Deref_post_z_cap_(*DataLength) PSTR *Data, + _Out_ ULONG *DataLength ) { - BYTE buffer[PAGE_SIZE]; PSTR data; ULONG allocatedLength; ULONG dataLength; ULONG returnLength; + BYTE buffer[PAGE_SIZE]; allocatedLength = sizeof(buffer); data = (PSTR)PhAllocate(allocatedLength); @@ -80,7 +80,7 @@ static BOOLEAN ReadRequestString( } NTSTATUS NetworkWhoisThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { BOOLEAN isSuccess = FALSE; @@ -93,26 +93,28 @@ NTSTATUS NetworkWhoisThreadStart( HINTERNET requestHandle = NULL; HINTERNET sessionHandle = NULL; mxml_node_t* xmlNode = NULL; + PNETWORK_OUTPUT_CONTEXT context = NULL; WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig = { 0 }; - PNETWORK_OUTPUT_CONTEXT context = (PNETWORK_OUTPUT_CONTEXT)Parameter; - - Static_SetText(context->WindowHandle, - PhFormatString(L"Whois %s...", context->addressString)->Buffer); - //4.4.3. IP Addresses and Networks // https://www.arin.net/resources/whoisrws/whois_api.html //TODO: use REF string from /rest/ip/ lookup for querying the IP network: "/rest/net/NET-74-125-0-0-1?showDetails=true" // or use CIDR string from /rest/ip/ lookup for querying the IP network: "/rest/cidr/216.34.181.0/24?showDetails=true //WinHttpAddRequestHeaders(requestHandle, L"application/arin.whoisrws-v1+xml", -1L, 0); - whoisHttpGetString = PhFormatString(L"/rest/ip/%s.txt", context->addressString); - __try { + // Query thread context. + if ((context = (PNETWORK_OUTPUT_CONTEXT)Parameter) == NULL) + __leave; + + // Query PH version. + if ((phVersion = PhGetPhVersion()) == NULL) + __leave; + // Create a user agent string. - phVersion = PhGetPhVersion(); - userAgent = PhConcatStrings2(L"Process Hacker ", phVersion->Buffer); + if ((userAgent = PhConcatStrings2(L"Process Hacker ", phVersion->Buffer)) == NULL) + __leave; // Query the current system proxy WinHttpGetIEProxyConfigForCurrentUser(&proxyConfig); @@ -139,20 +141,24 @@ NTSTATUS NetworkWhoisThreadStart( __leave; } + if (!(whoisHttpGetString = PhFormatString(L"/rest/ip/%s", context->addressString))) + __leave; + if (!(requestHandle = WinHttpOpenRequest( connectionHandle, - NULL, // GET + NULL, whoisHttpGetString->Buffer, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, - 0 // WINHTTP_FLAG_REFRESH + WINHTTP_FLAG_REFRESH ))) { __leave; } - //WinHttpAddRequestHeaders(requestHandle, L"Accept: text/plain", -1L, 0); + if (!WinHttpAddRequestHeaders(requestHandle, L"Accept: text/plain", -1L, 0)) + __leave; if (!WinHttpSendRequest( requestHandle, @@ -170,15 +176,21 @@ NTSTATUS NetworkWhoisThreadStart( if (!ReadRequestString(requestHandle, &xmlBuffer, &xmlLength)) __leave; - SendMessage(context->WindowHandle, NTM_RECEIVEDWHOIS, (WPARAM)xmlLength, (LPARAM)xmlBuffer); + PostMessage(context->WindowHandle, NTM_RECEIVEDWHOIS, (WPARAM)xmlLength, (LPARAM)xmlBuffer); + PostMessage(context->WindowHandle, NTM_RECEIVEDFINISH, 0, 0); isSuccess = TRUE; } __finally - { - PhSwapReference2(&phVersion, NULL); - PhSwapReference2(&userAgent, NULL); - PhSwapReference2(&whoisHttpGetString, NULL); + { + if (phVersion) + PhDereferenceObject(phVersion); + + if (userAgent) + PhDereferenceObject(userAgent); + + if (whoisHttpGetString) + PhDereferenceObject(whoisHttpGetString); if (requestHandle) WinHttpCloseHandle(requestHandle); diff --git a/2.x/trunk/plugins/OnlineChecks/CHANGELOG.txt b/2.x/trunk/plugins/OnlineChecks/CHANGELOG.txt index 8c3e388f9..4cb689529 100644 --- a/2.x/trunk/plugins/OnlineChecks/CHANGELOG.txt +++ b/2.x/trunk/plugins/OnlineChecks/CHANGELOG.txt @@ -1,6 +1,6 @@ 1.5 * Added CIMA hash checking - * Added file analysed prompt + * Added file analyzed prompt 1.4 * 2013-07-16: Added upload progress diff --git a/2.x/trunk/plugins/OnlineChecks/OnlineChecks.vcxproj b/2.x/trunk/plugins/OnlineChecks/OnlineChecks.vcxproj index b74f0ed85..394b6b50e 100644 --- a/2.x/trunk/plugins/OnlineChecks/OnlineChecks.vcxproj +++ b/2.x/trunk/plugins/OnlineChecks/OnlineChecks.vcxproj @@ -68,7 +68,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/OnlineChecks/main.c b/2.x/trunk/plugins/OnlineChecks/main.c index 312f8121c..369eae158 100644 --- a/2.x/trunk/plugins/OnlineChecks/main.c +++ b/2.x/trunk/plugins/OnlineChecks/main.c @@ -26,28 +26,28 @@ #include "resource.h" VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ModuleMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); PPH_PLUGIN PluginInstance; @@ -58,9 +58,9 @@ PH_CALLBACK_REGISTRATION ProcessMenuInitializingCallbackRegistration; PH_CALLBACK_REGISTRATION ModuleMenuInitializingCallbackRegistration; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -118,24 +118,24 @@ LOGICAL DllMain( } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { // Nothing } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { // Nothing } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; @@ -159,9 +159,9 @@ VOID NTAPI MenuItemCallback( } PPH_EMENU_ITEM CreateSendToMenu( - __in PPH_EMENU_ITEM Parent, - __in PWSTR InsertAfter, - __in PPH_STRING FileName + _In_ PPH_EMENU_ITEM Parent, + _In_ PWSTR InsertAfter, + _In_ PPH_STRING FileName ) { PPH_EMENU_ITEM sendToMenu; @@ -187,8 +187,8 @@ PPH_EMENU_ITEM CreateSendToMenu( } VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; @@ -211,8 +211,8 @@ VOID NTAPI ProcessMenuInitializingCallback( } VOID NTAPI ModuleMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; diff --git a/2.x/trunk/plugins/OnlineChecks/onlnchk.h b/2.x/trunk/plugins/OnlineChecks/onlnchk.h index ae693553b..0a3b7bff9 100644 --- a/2.x/trunk/plugins/OnlineChecks/onlnchk.h +++ b/2.x/trunk/plugins/OnlineChecks/onlnchk.h @@ -81,15 +81,15 @@ extern PPH_PLUGIN PluginInstance; #define UPLOAD_SERVICE_CIMA 103 VOID UploadToOnlineService( - __in PPH_STRING FileName, - __in ULONG Service + _In_ PPH_STRING FileName, + _In_ ULONG Service ); INT_PTR CALLBACK UploadDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); #endif diff --git a/2.x/trunk/plugins/OnlineChecks/upload.c b/2.x/trunk/plugins/OnlineChecks/upload.c index 3486b6c09..e672ca9c7 100644 --- a/2.x/trunk/plugins/OnlineChecks/upload.c +++ b/2.x/trunk/plugins/OnlineChecks/upload.c @@ -31,24 +31,25 @@ static SERVICE_INFO UploadServiceInfo[] = }; static PPH_STRING PhGetWinHttpMessage( - __in ULONG Result + _In_ ULONG Result ) { return PhGetMessage(GetModuleHandle(L"winhttp.dll"), 0xb, GetUserDefaultLangID(), Result); } static NTSTATUS PhUploadToDialogThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { BOOL result; MSG message; + HWND dialogHandle; PH_AUTO_POOL autoPool; PUPLOAD_CONTEXT context = (PUPLOAD_CONTEXT)Parameter; PhInitializeAutoPool(&autoPool); - context->DialogHandle = CreateDialogParam( + dialogHandle = CreateDialogParam( (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDD_PROGRESS), PhMainWndHandle, @@ -56,15 +57,15 @@ static NTSTATUS PhUploadToDialogThreadStart( (LPARAM)Parameter ); - ShowWindow(context->DialogHandle, SW_SHOW); - SetForegroundWindow(context->DialogHandle); + ShowWindow(dialogHandle, SW_SHOW); + SetForegroundWindow(dialogHandle); while (result = GetMessage(&message, NULL, 0, 0)) { if (result == -1) break; - if (!IsDialogMessage(context->DialogHandle, &message)) + if (!IsDialogMessage(dialogHandle, &message)) { TranslateMessage(&message); DispatchMessage(&message); @@ -74,13 +75,13 @@ static NTSTATUS PhUploadToDialogThreadStart( } PhDeleteAutoPool(&autoPool); - DestroyWindow(context->DialogHandle); + DestroyWindow(dialogHandle); PhFree(context); return STATUS_SUCCESS; } static HFONT InitializeFont( - __in HWND hwndDlg + _In_ HWND hwndDlg ) { LOGFONT logFont = { 0 }; @@ -106,9 +107,9 @@ static HFONT InitializeFont( } static BOOL ReadRequestString( - __in HINTERNET Handle, - __out_z PSTR* Data, - __out ULONG* DataLength + _In_ HINTERNET Handle, + _Out_ _Deref_post_z_cap_(*DataLength) PSTR *Data, + _Out_ ULONG *DataLength ) { BYTE buffer[PAGE_SIZE]; @@ -159,9 +160,9 @@ static BOOL ReadRequestString( } static VOID RaiseUploadError( - __in PUPLOAD_CONTEXT Context, - __in PWSTR Error, - __in ULONG ErrorCode + _In_ PUPLOAD_CONTEXT Context, + _In_ PWSTR Error, + _In_ ULONG ErrorCode ) { PhSwapReference(&Context->ErrorMessage, NULL); @@ -177,7 +178,7 @@ static VOID RaiseUploadError( } static PSERVICE_INFO GetUploadServiceInfo( - __in ULONG Id + _In_ ULONG Id ) { ULONG i; @@ -192,11 +193,11 @@ static PSERVICE_INFO GetUploadServiceInfo( } static BOOLEAN PerformSubRequest( - __in PUPLOAD_CONTEXT Context, - __in PWSTR HostName, - __in PWSTR ObjectName, - __out_bcount(DataLength) PSTR* Data, - __out_opt PULONG DataLength + _In_ PUPLOAD_CONTEXT Context, + _In_ PWSTR HostName, + _In_ PWSTR ObjectName, + _Out_ _Deref_post_z_cap_(*DataLength) PSTR *Data, + _Out_opt_ PULONG DataLength ) { BOOLEAN result = FALSE; @@ -303,19 +304,19 @@ static BOOLEAN PerformSubRequest( } static NTSTATUS HashFileAndResetPosition( - __in HANDLE FileHandle, - __in PLARGE_INTEGER FileSize, - __in ULONG Algorithm, - __out PVOID Hash + _In_ HANDLE FileHandle, + _In_ PLARGE_INTEGER FileSize, + _In_ ULONG Algorithm, + _Out_ PVOID Hash ) { NTSTATUS status; - UCHAR buffer[PAGE_SIZE * 4]; IO_STATUS_BLOCK iosb; PH_HASH_CONTEXT hashContext; sha256_context sha256; ULONG64 bytesRemaining; FILE_POSITION_INFORMATION positionInfo; + UCHAR buffer[PAGE_SIZE]; bytesRemaining = FileSize->QuadPart; @@ -382,7 +383,7 @@ static NTSTATUS HashFileAndResetPosition( } static NTSTATUS UploadFileThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { time_t timeStart = 0; @@ -781,7 +782,7 @@ static NTSTATUS UploadFileThreadStart( } static NTSTATUS UploadCheckThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { NTSTATUS status = STATUS_SUCCESS; @@ -1068,10 +1069,10 @@ static NTSTATUS UploadCheckThreadStart( } INT_PTR CALLBACK UploadDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PUPLOAD_CONTEXT context = NULL; @@ -1087,44 +1088,29 @@ INT_PTR CALLBACK UploadDlgProc( if (uMsg == WM_NCDESTROY) { - //if (!PhIsNullOrEmptyString(context->FileName)) - //{ - // PhDereferenceObject(context->FileName); - // context->FileName = NULL; - //} + if (context->FileName) + PhDereferenceObject(context->FileName); + + if (context->BaseFileName) + PhDereferenceObject(context->BaseFileName); + + if (context->WindowFileName) + PhDereferenceObject(context->WindowFileName); if (context->MessageFont) - { DeleteObject(context->MessageFont); - context->MessageFont = NULL; - } if (context->HttpHandle) - { WinHttpCloseHandle(context->HttpHandle); - context->HttpHandle = NULL; - } - //if (context->ObjectName) - //{ - // PhDereferenceObject(context->ObjectName); - //} - //if (context->FileHandle) - //{ - // NtClose(context->FileHandle); - //} - - //if (!context->LaunchCommand) - //{ - // PhDereferenceObject(context->LaunchCommand); - // context->LaunchCommand = NULL; - //} - - //if (!context->ErrorMessage) - //{ - // PhDereferenceObject(context->ErrorMessage); - // context->ErrorMessage = NULL; - //} + if (context->ObjectName) + PhDereferenceObject(context->ObjectName); + + if (context->FileHandle) + NtClose(context->FileHandle); + + if (context->LaunchCommand) + PhDereferenceObject(context->LaunchCommand); RemoveProp(hwndDlg, L"Context"); } @@ -1269,14 +1255,16 @@ INT_PTR CALLBACK UploadDlgProc( Static_SetText(GetDlgItem(hwndDlg, IDNO), L"Close"); - if (!PhIsNullOrEmptyString(context->ErrorMessage)) + if (context->ErrorMessage) { Static_SetText(context->MessageHandle, context->ErrorMessage->Buffer); + PhDereferenceObject(context->ErrorMessage); } - if (!PhIsNullOrEmptyString(context->ErrorStatusMessage)) + if (context->ErrorStatusMessage) { Static_SetText(context->StatusHandle, context->ErrorStatusMessage->Buffer); + PhDereferenceObject(context->ErrorStatusMessage); } else { @@ -1290,8 +1278,8 @@ INT_PTR CALLBACK UploadDlgProc( } VOID UploadToOnlineService( - __in PPH_STRING FileName, - __in ULONG Service + _In_ PPH_STRING FileName, + _In_ ULONG Service ) { HANDLE dialogThread = NULL; diff --git a/2.x/trunk/plugins/Plugins.props b/2.x/trunk/plugins/Plugins.props index 37d1aa4a2..814d77288 100644 --- a/2.x/trunk/plugins/Plugins.props +++ b/2.x/trunk/plugins/Plugins.props @@ -1,11 +1,13 @@ - + - + + $(WindowsSDK_IncludePath);$(IncludePath) + - ../../sdk/include;%(AdditionalIncludeDirectories) + ../../sdk/include;include;resources;$(SolutionDir)..\ProcessHacker\sdk;$(SolutionDir)..\ProcessHacker\include;$(SolutionDir)..\phlib\include;$(SolutionDir)..\ProcessHacker\mxml;%(AdditionalIncludeDirectories) true @@ -14,15 +16,15 @@ StreamingSIMDExtensions - ../../sdk/lib/i386;%(AdditionalLibraryDirectories) - /SUBSYSTEM:WINDOWS,5.01 %(AdditionalOptions) + $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture);$(SolutionDir)..\ProcessHacker\sdk\lib\i386;%(AdditionalLibraryDirectories) + 5.01 - ../../sdk/lib/amd64;%(AdditionalLibraryDirectories) - /SUBSYSTEM:WINDOWS,5.02 %(AdditionalOptions) + $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture);$(SolutionDir)..\ProcessHacker\sdk\lib\amd64;%(AdditionalLibraryDirectories) + 5.02 - + \ No newline at end of file diff --git a/2.x/trunk/plugins/Plugins.sln b/2.x/trunk/plugins/Plugins.sln index 473560eab..b1d77c6a9 100644 --- a/2.x/trunk/plugins/Plugins.sln +++ b/2.x/trunk/plugins/Plugins.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SbieSupport", "SbieSupport\SbieSupport.vcxproj", "{EEF1E81D-D286-422A-89E6-C6C8F3BE648A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExtendedNotifications", "ExtendedNotifications\ExtendedNotifications.vcxproj", "{80E791B8-AC98-407E-8FF9-5154AF50E887}" diff --git a/2.x/trunk/plugins/SamplePlugin/SamplePlugin.sln b/2.x/trunk/plugins/SamplePlugin/SamplePlugin.sln index 9ced22f59..6b056c7da 100644 --- a/2.x/trunk/plugins/SamplePlugin/SamplePlugin.sln +++ b/2.x/trunk/plugins/SamplePlugin/SamplePlugin.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SamplePlugin", "SamplePlugin.vcxproj", "{C74D269B-3FCC-4C3E-93C7-1B4A94E7BBEE}" EndProject Global diff --git a/2.x/trunk/plugins/SamplePlugin/SamplePlugin.vcxproj b/2.x/trunk/plugins/SamplePlugin/SamplePlugin.vcxproj index 247038d71..84f383ea4 100644 --- a/2.x/trunk/plugins/SamplePlugin/SamplePlugin.vcxproj +++ b/2.x/trunk/plugins/SamplePlugin/SamplePlugin.vcxproj @@ -28,23 +28,23 @@ DynamicLibrary Unicode true - v110 + v120 DynamicLibrary Unicode - v110 + v120 DynamicLibrary Unicode true - v110 + v120 DynamicLibrary Unicode - v110 + v120 @@ -63,7 +63,6 @@ - <_ProjectFileVersion>10.0.40219.1 $(ProjectDir)\bin\$(Configuration)32\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/SbieSupport/SbieSupport.vcxproj b/2.x/trunk/plugins/SbieSupport/SbieSupport.vcxproj index dc65e33c6..d5bbc1c91 100644 --- a/2.x/trunk/plugins/SbieSupport/SbieSupport.vcxproj +++ b/2.x/trunk/plugins/SbieSupport/SbieSupport.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/SbieSupport/main.c b/2.x/trunk/plugins/SbieSupport/main.c index d309fda45..903916249 100644 --- a/2.x/trunk/plugins/SbieSupport/main.c +++ b/2.x/trunk/plugins/SbieSupport/main.c @@ -38,55 +38,55 @@ typedef struct _BOXED_PROCESS } BOXED_PROCESS, *PBOXED_PROCESS; VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI GetProcessHighlightingColorCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI GetProcessTooltipTextCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI GetIsDotNetDirectoryNamesCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI RefreshSandboxieInfo( - __in_opt PVOID Context, - __in BOOLEAN TimerOrWaitFired + _In_opt_ PVOID Context, + _In_ BOOLEAN TimerOrWaitFired ); INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); PPH_PLUGIN PluginInstance; @@ -111,9 +111,9 @@ BOX_INFO BoxInfo[16]; ULONG BoxInfoCount; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -192,23 +192,23 @@ LOGICAL DllMain( } BOOLEAN NTAPI BoxedProcessesCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { return ((PBOXED_PROCESS)Entry1)->ProcessId == ((PBOXED_PROCESS)Entry2)->ProcessId; } ULONG NTAPI BoxedProcessesHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { return (ULONG)((PBOXED_PROCESS)Entry)->ProcessId / 4; } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_STRING sbieDllPath; @@ -239,8 +239,8 @@ VOID NTAPI LoadCallback( } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { DialogBox( @@ -252,8 +252,8 @@ VOID NTAPI ShowOptionsCallback( } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; @@ -297,8 +297,8 @@ VOID NTAPI MenuItemCallback( } VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PhPluginAddMenuItem(PluginInstance, PH_MENU_ITEM_LOCATION_TOOLS, L"$", @@ -308,8 +308,8 @@ VOID NTAPI MainWindowShowingCallback( } VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PBOXED_PROCESS boxedProcess; @@ -339,8 +339,8 @@ VOID NTAPI ProcessesUpdatedCallback( } VOID NTAPI GetProcessHighlightingColorCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_GET_HIGHLIGHTING_COLOR getHighlightingColor = Parameter; @@ -362,8 +362,8 @@ VOID NTAPI GetProcessHighlightingColorCallback( } VOID NTAPI GetProcessTooltipTextCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_GET_TOOLTIP_TEXT getTooltipText = Parameter; @@ -383,8 +383,8 @@ VOID NTAPI GetProcessTooltipTextCallback( } VOID NTAPI RefreshSandboxieInfo( - __in_opt PVOID Context, - __in BOOLEAN TimerOrWaitFired + _In_opt_ PVOID Context, + _In_ BOOLEAN TimerOrWaitFired ) { LONG index; @@ -481,10 +481,10 @@ VOID NTAPI RefreshSandboxieInfo( } INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ToolStatus/ToolStatus.rc b/2.x/trunk/plugins/ToolStatus/ToolStatus.rc index ba901f521..6f72b228e 100644 --- a/2.x/trunk/plugins/ToolStatus/ToolStatus.rc +++ b/2.x/trunk/plugins/ToolStatus/ToolStatus.rc @@ -49,8 +49,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,9,0,0 - PRODUCTVERSION 1,9,0,0 + FILEVERSION 2,0,0,0 + PRODUCTVERSION 2,0,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -67,12 +67,12 @@ BEGIN BEGIN VALUE "CompanyName", "dmex" VALUE "FileDescription", "ToolStatus plugin for Process Hacker" - VALUE "FileVersion", "1.9" + VALUE "FileVersion", "2.0.0.0" VALUE "InternalName", "ToolStatus" VALUE "LegalCopyright", "Licensed under the GNU GPL, v3." VALUE "OriginalFilename", "ToolStatus.dll" VALUE "ProductName", "ToolStatus plugin for Process Hacker" - VALUE "ProductVersion", "1.9" + VALUE "ProductVersion", "2.0.0.0" END END BLOCK "VarFileInfo" @@ -117,13 +117,13 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "OK",IDOK,126,61,50,14 PUSHBUTTON "Cancel",IDCANCEL,181,61,50,14 - CONTROL "Enable Toolbar",IDC_ENABLE_TOOLBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,63,10 - CONTROL "Enable SearchBox",IDC_ENABLE_SEARCHBOX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,20,73,10 + CONTROL "Enable toolbar",IDC_ENABLE_TOOLBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,62,10 + CONTROL "Enable search box",IDC_ENABLE_SEARCHBOX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,20,75,10 CONTROL "Resolve ghost windows to hung windows",IDC_RESOLVEGHOSTWINDOWS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,46,147,10 COMBOBOX IDC_DISPLAYSTYLECOMBO,162,18,68,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP RTEXT "Toolbar display style:",IDC_DISPLAYSTYLETEXT,160,7,70,8 - CONTROL "Enable Status Bar",IDC_ENABLE_STATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,33,73,10 + CONTROL "Enable status bar",IDC_ENABLE_STATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,33,72,10 END diff --git a/2.x/trunk/plugins/ToolStatus/ToolStatus.vcxproj b/2.x/trunk/plugins/ToolStatus/ToolStatus.vcxproj index 2689d4040..9dbeb6218 100644 --- a/2.x/trunk/plugins/ToolStatus/ToolStatus.vcxproj +++ b/2.x/trunk/plugins/ToolStatus/ToolStatus.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/ToolStatus/filter.c b/2.x/trunk/plugins/ToolStatus/filter.c index 856ef654f..da7a850a2 100644 --- a/2.x/trunk/plugins/ToolStatus/filter.c +++ b/2.x/trunk/plugins/ToolStatus/filter.c @@ -24,7 +24,7 @@ #include "toolstatus.h" static BOOLEAN WordMatchStringRef( - __in PPH_STRINGREF Text + _In_ PPH_STRINGREF Text ) { PH_STRINGREF part; @@ -47,7 +47,7 @@ static BOOLEAN WordMatchStringRef( } static BOOLEAN WordMatchString( - __in PWSTR Text + _In_ PWSTR Text ) { PH_STRINGREF text; @@ -73,8 +73,8 @@ static BOOLEAN WordMatchString( } BOOLEAN ProcessTreeFilterCallback( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { BOOLEAN showItem = FALSE; @@ -289,12 +289,76 @@ BOOLEAN ProcessTreeFilterCallback( showItem = TRUE; } + if (processNode->ProcessItem->ServiceList && processNode->ProcessItem->ServiceList->Count != 0) + { + ULONG enumerationKey = 0; + PPH_SERVICE_ITEM serviceItem; + PPH_LIST serviceList; + ULONG i; + + // Copy the service list so we can search it. + serviceList = PhCreateList(processNode->ProcessItem->ServiceList->Count); + + PhAcquireQueuedLockShared(&processNode->ProcessItem->ServiceListLock); + + while (PhEnumPointerList( + processNode->ProcessItem->ServiceList, + &enumerationKey, + &serviceItem + )) + { + PhReferenceObject(serviceItem); + PhAddItemList(serviceList, serviceItem); + } + + PhReleaseQueuedLockShared(&processNode->ProcessItem->ServiceListLock); + + // Add the services. + for (i = 0; i < serviceList->Count; i++) + { + serviceItem = serviceList->Items[i]; + + if (WordMatchString(PhGetServiceTypeString(serviceItem->Type))) + showItem = TRUE; + + if (WordMatchString(PhGetServiceStateString(serviceItem->State))) + showItem = TRUE; + + if (WordMatchString(PhGetServiceStartTypeString(serviceItem->StartType))) + showItem = TRUE; + + if (WordMatchString(PhGetServiceErrorControlString(serviceItem->ErrorControl))) + showItem = TRUE; + + if (serviceItem->Name) + { + if (WordMatchStringRef(&serviceItem->Name->sr)) + showItem = TRUE; + } + + if (serviceItem->DisplayName) + { + if (WordMatchStringRef(&serviceItem->DisplayName->sr)) + showItem = TRUE; + } + + if (serviceItem->ProcessIdString) + { + if (WordMatchString(serviceItem->ProcessIdString)) + showItem = TRUE; + } + } + + PhDereferenceObjects(serviceList->Items, serviceList->Count); + PhDereferenceObject(serviceList); + } + return showItem; } BOOLEAN ServiceTreeFilterCallback( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { BOOLEAN showItem = FALSE; @@ -337,8 +401,8 @@ BOOLEAN ServiceTreeFilterCallback( } BOOLEAN NetworkTreeFilterCallback( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ) { BOOLEAN showItem = FALSE; diff --git a/2.x/trunk/plugins/ToolStatus/main.c b/2.x/trunk/plugins/ToolStatus/main.c index b909d8b42..a1200685b 100644 --- a/2.x/trunk/plugins/ToolStatus/main.c +++ b/2.x/trunk/plugins/ToolStatus/main.c @@ -27,7 +27,7 @@ BOOLEAN EnableToolBar = FALSE; BOOLEAN EnableSearchBox = FALSE; BOOLEAN EnableStatusBar = FALSE; BOOLEAN EnableWicImaging = FALSE; -TOOLBAR_DISPLAY_STYLE DisplayStyle = SelectiveText; +TOOLBAR_DISPLAY_STYLE DisplayStyle = ToolbarDisplaySelectiveText; HWND ReBarHandle = NULL; HWND ToolBarHandle = NULL; HWND TextboxHandle = NULL; @@ -52,8 +52,8 @@ static PH_CALLBACK_REGISTRATION LayoutPaddingCallbackRegistration; static PH_CALLBACK_REGISTRATION TabPageCallbackRegistration; static VOID NTAPI ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { ProcessesUpdatedCount++; @@ -63,8 +63,8 @@ static VOID NTAPI ProcessesUpdatedCallback( } static VOID NTAPI TabPageUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { INT tabIndex = (INT)Parameter; @@ -91,37 +91,40 @@ static VOID NTAPI TabPageUpdatedCallback( } static VOID NTAPI LayoutPaddingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_LAYOUT_PADDING_DATA data = (PPH_LAYOUT_PADDING_DATA)Parameter; - - static RECT rbRect = { 0, 0, 0, 0 }; - static RECT sbRect = { 0, 0, 0, 0 }; - if (EnableToolBar && ReBarHandle) + if (ReBarHandle) { + RECT rebarRect = { 0 }; + SendMessage(ReBarHandle, WM_SIZE, 0, 0); - GetClientRect(ReBarHandle, &rbRect); + + GetClientRect(ReBarHandle, &rebarRect); // Adjust the PH client area and exclude the rebar width. - data->Padding.top += rbRect.bottom; + data->Padding.top += rebarRect.bottom; } - if (EnableStatusBar && StatusBarHandle) + if (StatusBarHandle) { + RECT statusBarRect = { 0 }; + SendMessage(StatusBarHandle, WM_SIZE, 0, 0); - GetClientRect(StatusBarHandle, &sbRect); + + GetClientRect(StatusBarHandle, &statusBarRect); // Adjust the PH client area and exclude the StatusBar width. - data->Padding.bottom += sbRect.bottom; + data->Padding.bottom += statusBarRect.bottom; } } static BOOLEAN NTAPI MessageLoopFilter( - __in PMSG Message, - __in PVOID Context + _In_ PMSG Message, + _In_ PVOID Context ) { if ( @@ -137,7 +140,7 @@ static BOOLEAN NTAPI MessageLoopFilter( } static VOID DrawWindowBorderForTargeting( - __in HWND hWnd + _In_ HWND hWnd ) { RECT rect; @@ -176,12 +179,12 @@ static VOID DrawWindowBorderForTargeting( } static LRESULT CALLBACK MainWndSubclassProc( - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __in UINT_PTR uIdSubclass, - __in DWORD_PTR dwRefData + _In_ HWND hWnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ UINT_PTR uIdSubclass, + _In_ DWORD_PTR dwRefData ) { switch (uMsg) @@ -226,9 +229,9 @@ static LRESULT CALLBACK MainWndSubclassProc( case ID_SEARCH: { // handle keybind Ctrl + K - if (EnableToolBar) + if (EnableToolBar && EnableSearchBox) { - // Remove searchbox text... + SetFocus(TextboxHandle); Edit_SetSel(TextboxHandle, 0, -1); } @@ -236,9 +239,12 @@ static LRESULT CALLBACK MainWndSubclassProc( } break; case ID_SEARCH_CLEAR: - { - SetFocus(TextboxHandle); - Static_SetText(TextboxHandle, L""); + { + if (EnableToolBar && EnableSearchBox) + { + SetFocus(TextboxHandle); + Static_SetText(TextboxHandle, L""); + } goto DefaultWndProc; } @@ -386,7 +392,7 @@ static LRESULT CALLBACK MainWndSubclassProc( // This is an undocumented function exported by user32.dll that // retrieves the hung window represented by a ghost window. static HWND (WINAPI *HungWindowFromGhostWindow_I)( - __in HWND hWnd + _In_ HWND hWnd ); if (!HungWindowFromGhostWindow_I) @@ -502,8 +508,8 @@ static LRESULT CALLBACK MainWndSubclassProc( } static VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PhRegisterMessageLoopFilter(MessageLoopFilter, NULL); @@ -519,8 +525,8 @@ static VOID NTAPI MainWindowShowingCallback( } static VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { EnableToolBar = !!PhGetIntegerSetting(L"ProcessHacker.ToolStatus.EnableToolBar"); @@ -533,8 +539,8 @@ static VOID NTAPI LoadCallback( } static VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { DialogBox( @@ -546,9 +552,9 @@ static VOID NTAPI ShowOptionsCallback( } LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -573,8 +579,9 @@ LOGICAL DllMain( return FALSE; info->DisplayName = L"Toolbar and Status Bar"; - info->Author = L"dmex & wj32"; + info->Author = L"dmex, wj32"; info->Description = L"Adds a toolbar and a status bar."; + info->Url = L"http://processhacker.sf.net/forums/viewtopic.php?f=18&t=1119"; info->HasOptions = TRUE; PhRegisterCallback( diff --git a/2.x/trunk/plugins/ToolStatus/options.c b/2.x/trunk/plugins/ToolStatus/options.c index 1aae42ec6..4ccb69755 100644 --- a/2.x/trunk/plugins/ToolStatus/options.c +++ b/2.x/trunk/plugins/ToolStatus/options.c @@ -24,10 +24,10 @@ #include "toolstatus.h" INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/ToolStatus/searchbox.c b/2.x/trunk/plugins/ToolStatus/searchbox.c index 0865d3e66..971bf686b 100644 --- a/2.x/trunk/plugins/ToolStatus/searchbox.c +++ b/2.x/trunk/plugins/ToolStatus/searchbox.c @@ -1,37 +1,86 @@ /* -* Process Hacker - -* Subclassed Edit control -* -* Copyright (C) 2012-2013 dmex -* -* This file is part of Process Hacker. -* -* Process Hacker is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Process Hacker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Process Hacker. If not, see . -*/ - -// dmex: The non-client area subclassing code has been modified based on the following guide: -// http://www.catch22.net/tuts/insert-buttons-edit-control + * Process Hacker - + * Subclassed Edit control + * + * Copyright (C) 2012-2013 dmex + * + * This file is part of Process Hacker. + * + * Process Hacker is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Process Hacker is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Process Hacker. If not, see . + * + */ + #include "toolstatus.h" -#include +//NONCLIENTMETRICS metrics = { sizeof(NONCLIENTMETRICS) }; +//metrics.lfMenuFont.lfHeight = 14; +//metrics.lfMenuFont.lfWeight = FW_NORMAL; +//metrics.lfMenuFont.lfQuality = CLEARTYPE_QUALITY | ANTIALIASED_QUALITY; + +#ifdef _UXTHEME_ENABLED_ #include #include #include -#pragma comment(lib, "windowscodecs.lib") - -#define HRGN_FULL ((HRGN)1) // passed by WM_NCPAINT even though it's completely undocumented +typedef HRESULT (WINAPI *_GetThemeColor)( + _In_ HTHEME hTheme, + _In_ INT iPartId, + _In_ INT iStateId, + _In_ INT iPropId, + _Out_ COLORREF *pColor + ); +typedef HRESULT (WINAPI *_SetWindowTheme)( + _In_ HWND hwnd, + _In_ LPCWSTR pszSubAppName, + _In_ LPCWSTR pszSubIdList + ); + +typedef HRESULT (WINAPI *_GetThemeFont)( + _In_ HTHEME hTheme, + _In_ HDC hdc, + _In_ INT iPartId, + _In_ INT iStateId, + _In_ INT iPropId, + _Out_ LOGFONTW *pFont + ); + +typedef HRESULT (WINAPI *_GetThemeSysFont)( + _In_ HTHEME hTheme, + _In_ INT iFontId, + _Out_ LOGFONTW *plf + ); + +typedef BOOL (WINAPI *_IsThemeBackgroundPartiallyTransparent)( + _In_ HTHEME hTheme, + _In_ INT iPartId, + _In_ INT iStateId + ); + +typedef HRESULT (WINAPI *_DrawThemeParentBackground)( + _In_ HWND hwnd, + _In_ HDC hdc, + _In_opt_ const RECT* prc + ); + +typedef HRESULT (WINAPI *_GetThemeBackgroundContentRect)( + _In_ HTHEME hTheme, + _In_ HDC hdc, + _In_ INT iPartId, + _In_ INT iStateId, + _Inout_ LPCRECT pBoundingRect, + _Out_ LPRECT pContentRect + ); static _IsThemeActive IsThemeActive_I; static _OpenThemeData OpenThemeData_I; @@ -39,12 +88,13 @@ static _SetWindowTheme SetWindowTheme_I; static _CloseThemeData CloseThemeData_I; static _IsThemePartDefined IsThemePartDefined_I; static _DrawThemeBackground DrawThemeBackground_I; +static _DrawThemeParentBackground DrawThemeParentBackground_I; static _IsThemeBackgroundPartiallyTransparent IsThemeBackgroundPartiallyTransparent_I; static _GetThemeColor GetThemeColor_I; static VOID NcAreaInitializeUxTheme( - __inout NC_CONTEXT* Context, - __in HWND hwndDlg + _Inout_ NC_CONTEXT* Context, + _In_ HWND hwndDlg ) { if (!Context->UxThemeModule) @@ -59,35 +109,18 @@ static VOID NcAreaInitializeUxTheme( GetThemeColor_I = (_GetThemeColor)GetProcAddress(Context->UxThemeModule, "GetThemeColor"); IsThemePartDefined_I = (_IsThemePartDefined)GetProcAddress(Context->UxThemeModule, "IsThemePartDefined"); DrawThemeBackground_I = (_DrawThemeBackground)GetProcAddress(Context->UxThemeModule, "DrawThemeBackground"); + DrawThemeParentBackground_I = (_DrawThemeParentBackground)GetProcAddress(Context->UxThemeModule, "DrawThemeParentBackground"); IsThemeBackgroundPartiallyTransparent_I = (_IsThemeBackgroundPartiallyTransparent)GetProcAddress(Context->UxThemeModule, "IsThemeBackgroundPartiallyTransparent"); } if (IsThemeActive_I && OpenThemeData_I && CloseThemeData_I && IsThemePartDefined_I && DrawThemeBackground_I) { - // UxTheme classes and themes (not all listed): - // OpenThemeData_I: - // SearchBox - // SearchEditBox, - // Edit::SearchBox - // Edit::SearchEditBox if (Context->UxThemeHandle) CloseThemeData_I(Context->UxThemeHandle); Context->IsThemeActive = IsThemeActive_I(); Context->UxThemeHandle = OpenThemeData_I(hwndDlg, VSCLASS_EDIT); - // Edit control classes and themes (not all listed): - // SetWindowTheme_I: - // InactiveSearchBoxEdit - // InactiveSearchBoxEditComposited - // MaxInactiveSearchBoxEdit - // MaxInactiveSearchBoxEditComposited - // MaxSearchBoxEdit - // MaxSearchBoxEditComposited - // SearchBoxEdit - // SearchBoxEditComposited - //SetWindowTheme_I(hwndDlg, L"SearchBoxEdit", NULL); - if (Context->UxThemeHandle) { Context->IsThemeBackgroundActive = IsThemePartDefined_I( @@ -95,22 +128,6 @@ static VOID NcAreaInitializeUxTheme( EP_EDITBORDER_NOSCROLL, 0 ); - - GetThemeColor_I( - Context->UxThemeHandle, - EP_EDITBORDER_NOSCROLL, - EPSN_NORMAL, - TMT_FILLCOLOR, - &Context->clrUxThemeFillRef - ); - - GetThemeColor_I( - Context->UxThemeHandle, - EP_EDITBORDER_NOSCROLL, - EPSN_NORMAL, - TMT_BORDERCOLOR, - &Context->clrUxThemeBackgroundRef - ); } else { @@ -124,107 +141,157 @@ static VOID NcAreaInitializeUxTheme( Context->IsThemeBackgroundActive = FALSE; } } +#endif _UXTHEME_ENABLED_ + +static VOID NcAreaFreeGdiTheme( + _Inout_ PEDIT_CONTEXT Context + ) +{ + if (Context->BrushNormal) + DeleteObject(Context->BrushNormal); + + if (Context->BrushHot) + DeleteObject(Context->BrushHot); + + if (Context->BrushFocused) + DeleteObject(Context->BrushFocused); + + if (Context->BrushBackground) + DeleteObject(Context->BrushBackground); +} + +static VOID NcAreaInitializeGdiTheme( + _Inout_ PEDIT_CONTEXT Context + ) +{ + Context->CXBorder = GetSystemMetrics(SM_CXBORDER) * 2; + Context->CYBorder = GetSystemMetrics(SM_CYBORDER) * 2; + + Context->BackgroundColorRef = GetSysColor(COLOR_WINDOW); + Context->BrushNormal = GetSysColorBrush(COLOR_GRAYTEXT); + Context->BrushHot = WindowsVersion < WINDOWS_VISTA ? CreateSolidBrush(RGB(50, 150, 255)) : GetSysColorBrush(COLOR_HIGHLIGHT); + Context->BrushFocused = Context->BrushHot; + Context->BrushBackground = GetSysColorBrush(Context->BackgroundColorRef); +} + +static VOID NcAreaInitializeImageList( + _Inout_ PEDIT_CONTEXT Context + ) +{ + HBITMAP bitmapActive = NULL; + HBITMAP bitmapInactive = NULL; + + Context->ImageList = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0); + + ImageList_SetBkColor(Context->ImageList, Context->BackgroundColorRef); + ImageList_SetImageCount(Context->ImageList, 2); + + // Add the images to the imagelist + if (bitmapActive = LoadImageFromResources(23, 20, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE))) + { + ImageList_Replace(Context->ImageList, 0, bitmapActive, NULL); + DeleteObject(bitmapActive); + } + else + { + PhSetImageListBitmap(Context->ImageList, 0, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE_BMP)); + } + + if (bitmapInactive = LoadImageFromResources(23, 20, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE))) + { + ImageList_Replace(Context->ImageList, 1, bitmapInactive, NULL); + DeleteObject(bitmapInactive); + } + else + { + PhSetImageListBitmap(Context->ImageList, 1, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE_BMP)); + } +} static VOID NcAreaGetButtonRect( - __inout NC_CONTEXT* Context, - __in RECT* rect + _Inout_ PEDIT_CONTEXT Context, + _In_ RECT* rect ) { - // retrieve the coordinates of an inserted button, given the specified window rectangle. - rect->right -= Context->cxRightEdge; - rect->top += Context->cyTopEdge; // GetSystemMetrics(SM_CYBORDER); - rect->bottom -= Context->cyBottomEdge; rect->left = rect->right - Context->cxImgSize; // GetSystemMetrics(SM_CXBORDER) - - if (Context->cxRightEdge > Context->cxLeftEdge) - OffsetRect(rect, Context->cxRightEdge - Context->cxLeftEdge, 0); } static LRESULT CALLBACK NcAreaWndSubclassProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __in UINT_PTR uIdSubclass, - __in DWORD_PTR dwRefData + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ UINT_PTR uIdSubclass, + _In_ DWORD_PTR dwRefData ) { - NC_CONTEXT* context = (NC_CONTEXT*)GetProp(hwndDlg, L"Context"); - + PEDIT_CONTEXT context = (PEDIT_CONTEXT)GetProp(hwndDlg, L"Context"); + if (context == NULL) - return FALSE; + return DefSubclassProc(hwndDlg, uMsg, wParam, lParam); if (uMsg == WM_NCDESTROY) { - // Cleanup the subclass data... + NcAreaFreeGdiTheme(context); if (context->ImageList) - { ImageList_Destroy(context->ImageList); - context->ImageList = NULL; - } - if (context->UxThemeHandle) - { - if (CloseThemeData_I) - { - CloseThemeData_I(context->UxThemeHandle); - context->UxThemeHandle = NULL; - } - } +#ifdef _UXTHEME_ENABLED_ + if (CloseThemeData_I && context->UxThemeHandle) + CloseThemeData_I(context->UxThemeHandle); if (context->UxThemeModule) - { FreeLibrary(context->UxThemeModule); - context->UxThemeModule = NULL; - } +#endif RemoveWindowSubclass(hwndDlg, NcAreaWndSubclassProc, 0); - RemoveProp(hwndDlg, L"Context"); PhFree(context); - return FALSE; } switch (uMsg) - { - case WM_ERASEBKGND: - return 1; + { +#ifdef _UXTHEME_ENABLED_ case WM_STYLECHANGED: case WM_THEMECHANGED: - NcAreaInitializeUxTheme(context, hwndDlg); + NcAreaFreeGdiTheme(context); + NcAreaInitializeGdiTheme(context); + NcAreaInitializeUxTheme(context); + break; +#endif + case WM_ERASEBKGND: + return TRUE; + case WM_SYSCOLORCHANGE: + NcAreaFreeGdiTheme(context); + NcAreaInitializeGdiTheme(context); break; case WM_NCCALCSIZE: { - RECT* newClientRect = NULL; - RECT oldClientRect = { 0, 0, 0, 0 }; - - newClientRect = (RECT*)lParam; - oldClientRect = *newClientRect; + PRECT clientRect = (PRECT)lParam; - // calculate what the size of each window border is, so we can position the button... - context->cxLeftEdge = newClientRect->left - oldClientRect.left; - context->cxRightEdge = oldClientRect.right - newClientRect->right; - context->cyTopEdge = newClientRect->top - oldClientRect.top; - context->cyBottomEdge = oldClientRect.bottom - newClientRect->bottom; - - // allocate space for the image by deflating the client window rectangle. - newClientRect->right -= context->cxImgSize; + clientRect->right -= context->cxImgSize; } break; case WM_NCPAINT: { HDC hdc = NULL; - RECT clientRect = { 0, 0, 0, 0 }; - RECT windowRect = { 0, 0, 0, 0 }; + RECT clientRect = { 0 }; + RECT windowRect = { 0 }; + + BOOL isFocused = (GetFocus() == hwndDlg); if (!(hdc = GetWindowDC(hwndDlg))) return FALSE; + SetBkMode(hdc, TRANSPARENT); + // Get the screen coordinates of the client window. GetClientRect(hwndDlg, &clientRect); // Get the screen coordinates of the window. GetWindowRect(hwndDlg, &windowRect); + // Adjust the coordinates (start from border edge). + OffsetRect(&clientRect, context->CXBorder, context->CYBorder); // Adjust the coordinates (start from 0,0). OffsetRect(&windowRect, -windowRect.left, -windowRect.top); @@ -237,13 +304,20 @@ static LRESULT CALLBACK NcAreaWndSubclassProc( clientRect.bottom ); - // Draw the themed background. + // Draw the themed background. +#ifdef _UXTHEME_ENABLED_ if (context->IsThemeActive && context->IsThemeBackgroundActive) { - BOOL isFocused = (GetFocus() == hwndDlg); - if (isFocused) { + if (IsThemeBackgroundPartiallyTransparent_I( + context->UxThemeHandle, + EP_EDITBORDER_NOSCROLL, + EPSN_FOCUSED + )) + { + DrawThemeParentBackground_I(hwndDlg, hdc, NULL); + } DrawThemeBackground_I( context->UxThemeHandle, hdc, @@ -253,8 +327,37 @@ static LRESULT CALLBACK NcAreaWndSubclassProc( NULL ); } +#ifdef _HOTTRACK_ENABLED_ + else if (context->MouseInClient) + { + if (IsThemeBackgroundPartiallyTransparent_I( + context->UxThemeHandle, + EP_EDITBORDER_NOSCROLL, + EPSN_HOT + )) + { + DrawThemeParentBackground_I(hwndDlg, hdc, NULL); + } + DrawThemeBackground_I( + context->UxThemeHandle, + hdc, + EP_EDITBORDER_NOSCROLL, + EPSN_HOT, + &windowRect, + NULL + ); + } +#endif _HOTTRACK_ENABLED_ else { + if (IsThemeBackgroundPartiallyTransparent_I( + context->UxThemeHandle, + EP_EDITBORDER_NOSCROLL, + EPSN_NORMAL + )) + { + DrawThemeParentBackground_I(hwndDlg, hdc, NULL); + } DrawThemeBackground_I( context->UxThemeHandle, hdc, @@ -266,40 +369,61 @@ static LRESULT CALLBACK NcAreaWndSubclassProc( } } else +#endif _UXTHEME_ENABLED_ { - // Fill in the text box. - //SetDCBrushColor(hdc, RGB(0xff, 0xff, 0xff)); - FillRect(hdc, &windowRect, GetStockBrush(DC_BRUSH)); - SetBkMode(hdc, TRANSPARENT); + FillRect(hdc, &windowRect, context->BrushBackground); + + if (isFocused) + { + FrameRect(hdc, &windowRect, context->BrushFocused); + } +#ifdef _HOTTRACK_ENABLED_ + else if (context->MouseInClient) + { + FrameRect(hdc, &windowRect, context->BrushHot); + } +#endif + else + { + FrameRect(hdc, &windowRect, context->BrushNormal); + } } // Get the position of the inserted button. NcAreaGetButtonRect(context, &windowRect); // Draw the button. - if (GetWindowTextLength(hwndDlg) > 0) + if (SearchboxText->Length > 0) { - ImageList_Draw( + ImageList_DrawEx( context->ImageList, 0, hdc, windowRect.left, windowRect.top, - ILD_TRANSPARENT + 0, + 0, + context->BackgroundColorRef, + context->BackgroundColorRef, + ILD_NORMAL | ILD_TRANSPARENT ); } else { - ImageList_Draw( + ImageList_DrawEx( context->ImageList, 1, hdc, windowRect.left, windowRect.top + 1, - ILD_TRANSPARENT + 0, + 0, + context->BackgroundColorRef, + context->BackgroundColorRef, + ILD_NORMAL | ILD_TRANSPARENT ); } - + // Restore the the client area. IntersectClipRect( hdc, @@ -311,11 +435,11 @@ static LRESULT CALLBACK NcAreaWndSubclassProc( ReleaseDC(hwndDlg, hdc); } - break; + return FALSE; case WM_NCHITTEST: { - POINT windowPoint = { 0, 0 }; - RECT windowRect = { 0, 0, 0, 0 }; + POINT windowPoint = { 0 }; + RECT windowRect = { 0 }; // Get the screen coordinates of the mouse. windowPoint.x = GET_X_LPARAM(lParam); @@ -332,8 +456,8 @@ static LRESULT CALLBACK NcAreaWndSubclassProc( break; case WM_NCLBUTTONDOWN: { - POINT windowPoint = { 0, 0 }; - RECT windowRect = { 0, 0, 0, 0 }; + POINT windowPoint = { 0 }; + RECT windowRect = { 0 }; // Get the screen coordinates of the mouse. windowPoint.x = GET_X_LPARAM(lParam); @@ -346,18 +470,11 @@ static LRESULT CALLBACK NcAreaWndSubclassProc( // Check that the mouse is within the button rect. if (PtInRect(&windowRect, windowPoint)) { - context->HasCapture = TRUE; SetCapture(hwndDlg); - // Send the click notification to the parent window. - PostMessage( - context->ParentWindow, - WM_COMMAND, - MAKEWPARAM(context->CommandID, BN_CLICKED), - 0 - ); + // Send click notification + SendMessage(PhMainWndHandle, WM_COMMAND, MAKEWPARAM(context->CommandID, BN_CLICKED), 0); - // Invalidate the nonclient area. RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); return FALSE; } @@ -365,135 +482,206 @@ static LRESULT CALLBACK NcAreaWndSubclassProc( break; case WM_LBUTTONUP: { - if (context->HasCapture) + if (GetCapture() == hwndDlg) { ReleaseCapture(); - context->HasCapture = FALSE; - // Invalidate the nonclient area. RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); return FALSE; } } break; + case WM_KEYDOWN: + { + if (WindowsVersion < WINDOWS_VISTA) + { + // Handle CTRL+A below Vista. + if (GetKeyState(VK_CONTROL) & VK_LCONTROL && wParam == 'A') + { + Edit_SetSel(hwndDlg, 0, -1); + return FALSE; + } + } + } + break; case WM_CUT: - case WM_CLEAR: - case WM_PASTE: + case WM_CLEAR: + case WM_PASTE: case WM_UNDO: - RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); - break; case WM_KEYUP: + case WM_SETTEXT: + case WM_SETFOCUS: + case WM_KILLFOCUS: RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); - return FALSE; + break; +#ifdef _HOTTRACK_ENABLED_ + case WM_MOUSELEAVE: + { + context->MouseInClient = FALSE; + + RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + } + break; + case WM_MOUSEMOVE: + { + POINT windowPoint = { 0 }; + RECT windowRect = { 0 }; + + // Get the screen coordinates of the mouse. + windowPoint.x = GET_X_LPARAM(lParam); + windowPoint.y = GET_Y_LPARAM(lParam); + + GetWindowRect(hwndDlg, &windowRect); + OffsetRect(&windowRect, -windowRect.left, -windowRect.top); + + if (PtInRect(&windowRect, windowPoint)) + { + TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) }; + tme.dwFlags = TME_LEAVE;// | TME_NONCLIENT; + tme.hwndTrack = hwndDlg; + + context->MouseInClient = TRUE; + RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + + TrackMouseEvent(&tme); + } + else + { + //context->MouseInClient = FALSE; + //RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + } + } + break; +#endif _HOTTRACK_ENABLED_ } return DefSubclassProc(hwndDlg, uMsg, wParam, lParam); } HBITMAP LoadImageFromResources( - __in UINT Width, - __in UINT Height, - __in LPCTSTR Name + _In_ UINT Width, + _In_ UINT Height, + _In_ PCWSTR Name ) { UINT width = 0; UINT height = 0; UINT frameCount = 0; - ULONG resLength = 0; - HRSRC resHandleSrc = NULL; - HGLOBAL resHandle = NULL; - WICInProcPointer resBuffer = NULL; + BOOLEAN isSuccess = FALSE; + ULONG resourceLength = 0; + HGLOBAL resourceHandle = NULL; + HRSRC resourceHandleSource = NULL; + WICInProcPointer resourceBuffer = NULL; + BITMAPINFO bitmapInfo = { 0 }; HBITMAP bitmapHandle = NULL; - BYTE* bitmapBuffer = NULL; + PBYTE bitmapBuffer = NULL; IWICStream* wicStream = NULL; IWICBitmapSource* wicBitmapSource = NULL; IWICBitmapDecoder* wicDecoder = NULL; IWICBitmapFrameDecode* wicFrame = NULL; - IWICImagingFactory* wicFactory = NULL; + IWICBitmapScaler* wicScaler = NULL; WICPixelFormatGUID pixelFormat; - HDC hdcScreen = GetDC(NULL); + WICRect rect = { 0, 0, Width, Height }; + + static PH_INITONCE initOnce = PH_INITONCE_INIT; + static IWICImagingFactory* wicFactory = NULL; __try - { - // Create the ImagingFactory. - if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory1, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (PVOID*)&wicFactory))) - __leave; - // Create the PNG decoder. - if (FAILED(CoCreateInstance(&CLSID_WICPngDecoder1, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapDecoder, (PVOID*)&wicDecoder))) - __leave; + { + if (PhBeginInitOnce(&initOnce)) + { + // Create the ImagingFactory + if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory1, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (PVOID*)&wicFactory))) + { + PhEndInitOnce(&initOnce); + __leave; + } + + PhEndInitOnce(&initOnce); + } - // Find the resource. - if ((resHandleSrc = FindResource((HINSTANCE)PluginInstance->DllBase, Name, L"PNG")) == NULL) + // Find the resource + if ((resourceHandleSource = FindResource(PluginInstance->DllBase, Name, L"PNG")) == NULL) __leave; - // Get the resource length. - resLength = SizeofResource((HINSTANCE)PluginInstance->DllBase, resHandleSrc); - // Load the resource. - if ((resHandle = LoadResource((HINSTANCE)PluginInstance->DllBase, resHandleSrc)) == NULL) + + // Get the resource length + resourceLength = SizeofResource(PluginInstance->DllBase, resourceHandleSource); + + // Load the resource + if ((resourceHandle = LoadResource(PluginInstance->DllBase, resourceHandleSource)) == NULL) __leave; - if ((resBuffer = (WICInProcPointer)LockResource(resHandle)) == NULL) + + if ((resourceBuffer = (WICInProcPointer)LockResource(resourceHandle)) == NULL) __leave; - // Create the Stream. + // Create the Stream if (FAILED(IWICImagingFactory_CreateStream(wicFactory, &wicStream))) __leave; - // Initialize the Stream from Memory. - if (FAILED(IWICStream_InitializeFromMemory(wicStream, resBuffer, resLength))) + + // Initialize the Stream from Memory + if (FAILED(IWICStream_InitializeFromMemory(wicStream, resourceBuffer, resourceLength))) + __leave; + + if (FAILED(IWICImagingFactory_CreateDecoder(wicFactory, &GUID_ContainerFormatPng, NULL, &wicDecoder))) __leave; + if (FAILED(IWICBitmapDecoder_Initialize(wicDecoder, (IStream*)wicStream, WICDecodeMetadataCacheOnLoad))) __leave; - // Get the Frame count. + + // Get the Frame count if (FAILED(IWICBitmapDecoder_GetFrameCount(wicDecoder, &frameCount)) || frameCount < 1) __leave; - // Get the Frame. + + // Get the Frame if (FAILED(IWICBitmapDecoder_GetFrame(wicDecoder, 0, &wicFrame))) __leave; - // Get the WicFrame width and height. - if (FAILED(IWICBitmapFrameDecode_GetSize(wicFrame, &width, &height)) || width == 0 || height == 0) - __leave; - // Get the WicFrame image format. + + // Get the WicFrame image format if (FAILED(IWICBitmapFrameDecode_GetPixelFormat(wicFrame, &pixelFormat))) __leave; + // Check if the image format is supported: - if (!IsEqualGUID(&pixelFormat, &GUID_WICPixelFormat32bppBGRA)) + if (IsEqualGUID(&pixelFormat, &GUID_WICPixelFormat32bppPBGRA)) // GUID_WICPixelFormat32bppRGB + { + wicBitmapSource = (IWICBitmapSource*)wicFrame; + } + else { // Convert the image to the correct format: - if (FAILED(WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)wicFrame, &wicBitmapSource))) + if (FAILED(WICConvertBitmapSource(&GUID_WICPixelFormat32bppPBGRA, (IWICBitmapSource*)wicFrame, &wicBitmapSource))) __leave; IWICBitmapFrameDecode_Release(wicFrame); } - else - { - wicBitmapSource = (IWICBitmapSource*)wicFrame; - } bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = Width; - bitmapInfo.bmiHeader.biHeight = -((LONG)Height); + bitmapInfo.bmiHeader.biWidth = rect.Width; + bitmapInfo.bmiHeader.biHeight = -((LONG)rect.Height); bitmapInfo.bmiHeader.biPlanes = 1; bitmapInfo.bmiHeader.biBitCount = 32; bitmapInfo.bmiHeader.biCompression = BI_RGB; - if ((bitmapHandle = CreateDIBSection(hdcScreen, &bitmapInfo, DIB_RGB_COLORS, (PVOID*)&bitmapBuffer, NULL, 0)) != NULL) - { - WICRect rect = { 0, 0, Width, Height }; + HDC hdc = CreateCompatibleDC(NULL); + bitmapHandle = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, (PVOID*)&bitmapBuffer, NULL, 0); + ReleaseDC(NULL, hdc); - if (FAILED(IWICImagingFactory_CreateBitmapScaler(wicFactory, &wicScaler))) - __leave; - if (FAILED(IWICBitmapScaler_Initialize(wicScaler, wicBitmapSource, Width, Height, WICBitmapInterpolationModeFant))) - __leave; - if (FAILED(IWICBitmapScaler_CopyPixels(wicScaler, &rect, Width * 4, Width * Height * 4, bitmapBuffer))) - __leave; - } + // Check if it's the same rect as the requested size. + //if (width != rect.Width || height != rect.Height) + if (FAILED(IWICImagingFactory_CreateBitmapScaler(wicFactory, &wicScaler))) + __leave; + if (FAILED(IWICBitmapScaler_Initialize(wicScaler, wicBitmapSource, rect.Width, rect.Height, WICBitmapInterpolationModeFant))) + __leave; + if (FAILED(IWICBitmapScaler_CopyPixels(wicScaler, &rect, rect.Width * 4, rect.Width * rect.Height * 4, bitmapBuffer))) + __leave; + + isSuccess = TRUE; } __finally { - ReleaseDC(NULL, hdcScreen); - if (wicScaler) { IWICBitmapScaler_Release(wicScaler); @@ -516,84 +704,42 @@ HBITMAP LoadImageFromResources( if (wicFactory) { - IWICImagingFactory_Release(wicFactory); + // IWICImagingFactory_Release(wicFactory); } - - if (resHandle) + + if (resourceHandle) { - FreeResource(resHandle); + FreeResource(resourceHandle); } } return bitmapHandle; } -static HFONT InitializeFont( - __in HWND hwndDlg - ) -{ - LOGFONT logFont = { 0 }; - HFONT fontHandle = NULL; - - logFont.lfHeight = 14; - logFont.lfWeight = FW_NORMAL; - logFont.lfQuality = CLEARTYPE_QUALITY | ANTIALIASED_QUALITY; - - // GDI uses the first font that matches the above attributes. - fontHandle = CreateFontIndirect(&logFont); - - if (fontHandle) - { - SendMessage(hwndDlg, WM_SETFONT, (WPARAM)fontHandle, FALSE); - return fontHandle; - } - - return NULL; -} - BOOLEAN InsertButton( - __in HWND hwndDlg, - __in UINT CommandID + _In_ HWND hwndDlg, + _In_ UINT CommandID ) { - NC_CONTEXT* context = (NC_CONTEXT*)PhAllocate(sizeof(NC_CONTEXT)); - memset(context, 0, sizeof(NC_CONTEXT)); + PEDIT_CONTEXT context = (PEDIT_CONTEXT)PhAllocate(sizeof(EDIT_CONTEXT)); + memset(context, 0, sizeof(EDIT_CONTEXT)); context->cxImgSize = 22; context->CommandID = CommandID; - context->ParentWindow = GetParent(hwndDlg); - context->ImageList = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0); - ImageList_SetImageCount(context->ImageList, 2); - - // Add the images to the imagelist - if (context->ActiveBitmap = LoadImageFromResources(23, 20, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE))) - { - ImageList_Replace(context->ImageList, 0, context->ActiveBitmap, NULL); - } - else - { - PhSetImageListBitmap(context->ImageList, 0, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_ACTIVE_BMP)); - } - if (context->InactiveBitmap = LoadImageFromResources(23, 20, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE))) - { - ImageList_Replace(context->ImageList, 1, context->InactiveBitmap, NULL); - } - else - { - PhSetImageListBitmap(context->ImageList, 1, (HINSTANCE)PluginInstance->DllBase, MAKEINTRESOURCE(IDB_SEARCH_INACTIVE_BMP)); - } - - // Initialize the window UxTheme data. - NcAreaInitializeUxTheme(context, hwndDlg); + context->WindowHandle = hwndDlg; - // Set Searchbox control font - SearchboxFontHandle = InitializeFont(hwndDlg); + NcAreaInitializeGdiTheme(context); + NcAreaInitializeImageList(context); // Set our window context data. SetProp(hwndDlg, L"Context", (HANDLE)context); // Subclass the Edit control window procedure. - SetWindowSubclass(hwndDlg, NcAreaWndSubclassProc, 0, (DWORD_PTR)context); + SetWindowSubclass(hwndDlg, NcAreaWndSubclassProc, 0, (ULONG_PTR)context); + +#ifdef _UXTHEME_ENABLED_ + SendMessage(hwndDlg, WM_THEMECHANGED, 0, 0); +#endif _UXTHEME_ENABLED_ // Force the edit control to update its non-client area. RedrawWindow(hwndDlg, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); diff --git a/2.x/trunk/plugins/ToolStatus/statusbar.c b/2.x/trunk/plugins/ToolStatus/statusbar.c index 997742b34..60db159d1 100644 --- a/2.x/trunk/plugins/ToolStatus/statusbar.c +++ b/2.x/trunk/plugins/ToolStatus/statusbar.c @@ -29,7 +29,7 @@ ULONG ProcessesUpdatedCount; static ULONG StatusBarMaxWidths[STATUS_COUNT]; VOID ShowStatusMenu( - __in PPOINT Point + _In_ PPOINT Point ) { HMENU menu; diff --git a/2.x/trunk/plugins/ToolStatus/toolbar.c b/2.x/trunk/plugins/ToolStatus/toolbar.c index 469c58c44..6d42b34aa 100644 --- a/2.x/trunk/plugins/ToolStatus/toolbar.c +++ b/2.x/trunk/plugins/ToolStatus/toolbar.c @@ -37,18 +37,19 @@ static TBBUTTON ButtonArray[9] = }; static VOID RebarAddMenuItem( - __in HWND WindowHandle, - __in HWND HwndHandle, - __in UINT BandID, - __in UINT cyMinChild, - __in UINT cxMinChild + _In_ HWND WindowHandle, + _In_ HWND HwndHandle, + _In_ UINT cyMinChild, + _In_ UINT cxMinChild ) { + static UINT bandID = 0; + REBARBANDINFO rebarBandInfo = { REBARBANDINFO_V6_SIZE }; rebarBandInfo.fMask = RBBIM_STYLE | RBBIM_ID | RBBIM_CHILD | RBBIM_CHILDSIZE; rebarBandInfo.fStyle = RBBS_NOGRIPPER | RBBS_FIXEDSIZE; - rebarBandInfo.wID = BandID; + rebarBandInfo.wID = bandID++; rebarBandInfo.hwndChild = HwndHandle; rebarBandInfo.cyMinChild = cyMinChild; rebarBandInfo.cxMinChild = cxMinChild; @@ -57,8 +58,8 @@ static VOID RebarAddMenuItem( } static VOID RebarRemoveMenuItem( - __in HWND WindowHandle, - __in UINT ID + _In_ HWND WindowHandle, + _In_ UINT ID ) { INT bandId = (INT)SendMessage(WindowHandle, RB_IDTOINDEX, (WPARAM)ID, 0); @@ -89,6 +90,7 @@ static VOID RebarLoadSettings( if (arrowIconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_ARROW_REFRESH))) { ImageList_Replace(ToolBarImageList, 0, arrowIconBitmap, NULL); + DeleteObject(arrowIconBitmap); } else { @@ -98,6 +100,7 @@ static VOID RebarLoadSettings( if (cogIconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_COG_EDIT))) { ImageList_Replace(ToolBarImageList, 1, cogIconBitmap, NULL); + DeleteObject(cogIconBitmap); } else { @@ -107,6 +110,7 @@ static VOID RebarLoadSettings( if (findIconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_FIND))) { ImageList_Replace(ToolBarImageList, 2, findIconBitmap, NULL); + DeleteObject(findIconBitmap); } else { @@ -116,6 +120,7 @@ static VOID RebarLoadSettings( if (chartIconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_CHART_LINE))) { ImageList_Replace(ToolBarImageList, 3, chartIconBitmap, NULL); + DeleteObject(chartIconBitmap); } else { @@ -125,6 +130,7 @@ static VOID RebarLoadSettings( if (appIconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION))) { ImageList_Replace(ToolBarImageList, 4, appIconBitmap, NULL); + DeleteObject(appIconBitmap); } else { @@ -134,6 +140,7 @@ static VOID RebarLoadSettings( if (goIconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_APPLICATION_GO))) { ImageList_Replace(ToolBarImageList, 5, goIconBitmap, NULL); + DeleteObject(goIconBitmap); } else { @@ -143,6 +150,7 @@ static VOID RebarLoadSettings( if (crossIconBitmap = LoadImageFromResources(16, 16, MAKEINTRESOURCE(IDB_CROSS))) { ImageList_Replace(ToolBarImageList, 6, crossIconBitmap, NULL); + DeleteObject(crossIconBitmap); } else { @@ -160,10 +168,10 @@ static VOID RebarLoadSettings( WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, - WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NODIVIDER | CCS_TOP | RBS_FIXEDORDER | RBS_VARHEIGHT, // | RBS_DBLCLKTOGGLE + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NODIVIDER | CCS_TOP | RBS_VARHEIGHT, //RBS_FIXEDORDER | RBS_DBLCLKTOGGLE CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, PhMainWndHandle, - (HMENU)IDC_MENU_REBAR, + NULL, (HINSTANCE)PluginInstance->DllBase, NULL ); @@ -173,23 +181,10 @@ static VOID RebarLoadSettings( 0, TOOLBARCLASSNAME, NULL, - WS_CHILD | WS_VISIBLE | CCS_NORESIZE | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS, + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NORESIZE | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, ReBarHandle, - (HMENU)IDC_MENU_REBAR_TOOLBAR, - (HINSTANCE)PluginInstance->DllBase, - NULL - ); - - // Create the SearchBox window. - TextboxHandle = CreateWindowEx( - WS_EX_CLIENTEDGE, - WC_EDIT, NULL, - WS_CHILD | WS_VISIBLE | ES_LEFT, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - ReBarHandle, - (HMENU)IDC_MENU_REBAR_SEARCH, (HINSTANCE)PluginInstance->DllBase, NULL ); @@ -205,26 +200,55 @@ static VOID RebarLoadSettings( SendMessage(ToolBarHandle, TB_SETIMAGELIST, 0, (LPARAM)ToolBarImageList); // Add the buttons to the toolbar. SendMessage(ToolBarHandle, TB_ADDBUTTONS, _countof(ButtonArray), (LPARAM)ButtonArray); - - // Insert a paint region into the edit control NC window area - InsertButton(TextboxHandle, ID_SEARCH_CLEAR); - // Reset the client area margins. - SendMessage(TextboxHandle, EM_SETMARGINS, EC_LEFTMARGIN, MAKELONG(0, 0)); - // Set initial text - SendMessage(TextboxHandle, EM_SETCUEBANNER, 0, (LPARAM)L"Search Processes (Ctrl+K)"); - // Enable theming: //SendMessage(ReBarHandle, RB_SETWINDOWTHEME, 0, (LPARAM)L"Communications"); //Media/Communications/BrowserTabBar/Help //SendMessage(ToolBarHandle, TB_SETWINDOWTHEME, 0, (LPARAM)L"Communications"); //Media/Communications/BrowserTabBar/Help - // Inset the toolbar into the rebar control - RebarAddMenuItem(ReBarHandle, ToolBarHandle, IDC_MENU_REBAR_TOOLBAR, 23, 0); // Toolbar width 400 - // Insert the edit control into the rebar control - RebarAddMenuItem(ReBarHandle, TextboxHandle, IDC_MENU_REBAR_SEARCH, 20, 180); + // HACK: Query the toolbar width/height. + ULONG_PTR toolbarButtonSize = SendMessage(ToolBarHandle, TB_GETBUTTONSIZE, 0, 0); + + // Inset the toolbar into the rebar control. + RebarAddMenuItem( + ReBarHandle, + ToolBarHandle, + HIWORD(toolbarButtonSize), + LOWORD(toolbarButtonSize) + ); - ProcessTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportProcessTreeList(), (PPH_TN_FILTER_FUNCTION)ProcessTreeFilterCallback, NULL); - ServiceTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportServiceTreeList(), (PPH_TN_FILTER_FUNCTION)ServiceTreeFilterCallback, NULL); - NetworkTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportNetworkTreeList(), (PPH_TN_FILTER_FUNCTION)NetworkTreeFilterCallback, NULL); + if (EnableSearchBox && !TextboxHandle) + { + ProcessTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportProcessTreeList(), (PPH_TN_FILTER_FUNCTION)ProcessTreeFilterCallback, NULL); + ServiceTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportServiceTreeList(), (PPH_TN_FILTER_FUNCTION)ServiceTreeFilterCallback, NULL); + NetworkTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportNetworkTreeList(), (PPH_TN_FILTER_FUNCTION)NetworkTreeFilterCallback, NULL); + + // Create the SearchBox window. + TextboxHandle = CreateWindowEx( + WS_EX_CLIENTEDGE, + WC_EDIT, + NULL, + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | ES_LEFT, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + ReBarHandle, + NULL, + (HINSTANCE)PluginInstance->DllBase, + NULL + ); + + SearchboxText = PhReferenceEmptyString(); + + // Insert a paint region into the edit control NC window area + InsertButton(TextboxHandle, ID_SEARCH_CLEAR); + + // Set font + SendMessage(TextboxHandle, WM_SETFONT, (WPARAM)PhApplicationFont, FALSE); + // Reset the client area margins. + SendMessage(TextboxHandle, EM_SETMARGINS, EC_LEFTMARGIN, MAKELPARAM(0, 0)); + // Set initial text + Edit_SetCueBannerText(TextboxHandle, L"Search Processes (Ctrl+K)"); + + // Insert the edit control into the rebar control + RebarAddMenuItem(ReBarHandle, TextboxHandle, 20, 180); + } } // Load the Statusbar control. @@ -243,7 +267,7 @@ static VOID RebarLoadSettings( NULL ); } - + // Hide or show controls (Note: don't unload or remove at runtime). if (EnableToolBar) { @@ -256,6 +280,24 @@ static VOID RebarLoadSettings( ShowWindow(ReBarHandle, SW_HIDE); } + if (EnableSearchBox) + { + if (TextboxHandle && !IsWindowVisible(TextboxHandle)) + ShowWindow(TextboxHandle, SW_SHOW); + } + else + { + if (TextboxHandle) + { + // Clear search text and reset search filters. + SetFocus(TextboxHandle); + Static_SetText(TextboxHandle, L""); + + if (IsWindowVisible(TextboxHandle)) + ShowWindow(TextboxHandle, SW_HIDE); + } + } + if (EnableStatusBar) { if (StatusBarHandle && !IsWindowVisible(StatusBarHandle)) @@ -287,7 +329,8 @@ VOID LoadToolbarSettings( button.dwMask = TBIF_BYINDEX | TBIF_STYLE | TBIF_COMMAND | TBIF_TEXT; // Get settings for first button - SendMessage(ToolBarHandle, TB_GETBUTTONINFO, index, (LPARAM)&button); + if (SendMessage(ToolBarHandle, TB_GETBUTTONINFO, index, (LPARAM)&button) == -1) + break; // Skip separator buttons if (button.fsStyle == BTNS_SEP) @@ -320,10 +363,10 @@ VOID LoadToolbarSettings( switch (DisplayStyle) { - case ImageOnly: + case ToolbarDisplayImageOnly: button.fsStyle = BTNS_AUTOSIZE; break; - case SelectiveText: + case ToolbarDisplaySelectiveText: { switch (button.idCommand) { @@ -331,7 +374,7 @@ VOID LoadToolbarSettings( case PHAPP_ID_HACKER_OPTIONS: case PHAPP_ID_HACKER_FINDHANDLESORDLLS: case PHAPP_ID_VIEW_SYSTEMINFORMATION: - button.fsStyle = BTNS_SHOWTEXT; + button.fsStyle = BTNS_AUTOSIZE | BTNS_SHOWTEXT; break; default: button.fsStyle = BTNS_AUTOSIZE; @@ -340,7 +383,7 @@ VOID LoadToolbarSettings( } break; default: - button.fsStyle = BTNS_SHOWTEXT; + button.fsStyle = BTNS_AUTOSIZE | BTNS_SHOWTEXT; break; } diff --git a/2.x/trunk/plugins/ToolStatus/toolstatus.h b/2.x/trunk/plugins/ToolStatus/toolstatus.h index 4725adbfe..0bc536d91 100644 --- a/2.x/trunk/plugins/ToolStatus/toolstatus.h +++ b/2.x/trunk/plugins/ToolStatus/toolstatus.h @@ -21,8 +21,10 @@ * along with Process Hacker. If not, see . */ -#ifndef TOOLSTATUS_H -#define TOOLSTATUS_H +#ifndef _TOOLSTATUS_H +#define _TOOLSTATUS_H + +#pragma comment(lib, "WindowsCodecs.lib") #define CINTERFACE #define COBJMACROS @@ -32,24 +34,20 @@ #include #include #include +#include +#include #include "resource.h" -typedef enum _TOOLBAR_DISPLAY_STYLE -{ - ImageOnly = 0, - SelectiveText = 1, - AllText = 2 -} TOOLBAR_DISPLAY_STYLE; +// Enable Searchbox HotTracking +#define _HOTTRACK_ENABLED_ +// Enable Searchbox UxTheme drawing +//#define _UXTHEME_ENABLED_ -#define IDC_MENU_REBAR 55400 -#define IDC_MENU_REBAR_TOOLBAR 55401 -#define IDC_MENU_REBAR_SEARCH 55402 #define ID_SEARCH_CLEAR (WM_USER + 1) - -#define TIDC_FINDWINDOW (WM_USER + 1) -#define TIDC_FINDWINDOWTHREAD (WM_USER + 2) -#define TIDC_FINDWINDOWKILL (WM_USER + 3) +#define TIDC_FINDWINDOW (WM_USER + 2) +#define TIDC_FINDWINDOWTHREAD (WM_USER + 3) +#define TIDC_FINDWINDOWKILL (WM_USER + 4) #define STATUS_COUNT 10 #define STATUS_MINIMUM 0x1 @@ -65,132 +63,98 @@ typedef enum _TOOLBAR_DISPLAY_STYLE #define STATUS_MAXIOPROCESS 0x200 #define STATUS_MAXIMUM 0x400 +typedef enum _TOOLBAR_DISPLAY_STYLE +{ + ToolbarDisplayImageOnly, + ToolbarDisplaySelectiveText, + ToolbarDisplayAllText +} TOOLBAR_DISPLAY_STYLE; + extern BOOLEAN EnableToolBar; extern BOOLEAN EnableSearchBox; extern BOOLEAN EnableStatusBar; extern TOOLBAR_DISPLAY_STYLE DisplayStyle; +extern ULONG StatusMask; +extern ULONG ProcessesUpdatedCount; + extern HWND ReBarHandle; extern HWND ToolBarHandle; extern HWND TextboxHandle; +extern HWND StatusBarHandle; extern HACCEL AcceleratorTable; extern PPH_STRING SearchboxText; -extern HFONT SearchboxFontHandle; + +extern PPH_PLUGIN PluginInstance; extern PPH_TN_FILTER_ENTRY ProcessTreeFilterEntry; extern PPH_TN_FILTER_ENTRY ServiceTreeFilterEntry; extern PPH_TN_FILTER_ENTRY NetworkTreeFilterEntry; -extern PPH_PLUGIN PluginInstance; - -extern HWND StatusBarHandle; -extern ULONG StatusMask; -extern ULONG ProcessesUpdatedCount; VOID UpdateStatusBar( VOID ); VOID ShowStatusMenu( - __in PPOINT Point + _In_ PPOINT Point ); VOID LoadToolbarSettings( VOID ); INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); BOOLEAN ProcessTreeFilterCallback( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); BOOLEAN ServiceTreeFilterCallback( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); BOOLEAN NetworkTreeFilterCallback( - __in PPH_TREENEW_NODE Node, - __in_opt PVOID Context + _In_ PPH_TREENEW_NODE Node, + _In_opt_ PVOID Context ); BOOLEAN InsertButton( - __in HWND WindowHandle, - __in UINT CmdId - ); - -typedef HRESULT (WINAPI *_GetThemeColor)( - __in HTHEME hTheme, - __in INT iPartId, - __in INT iStateId, - __in INT iPropId, - __out COLORREF *pColor - ); -typedef HRESULT (WINAPI *_SetWindowTheme)( - __in HWND hwnd, - __in LPCWSTR pszSubAppName, - __in LPCWSTR pszSubIdList - ); - -typedef HRESULT (WINAPI *_GetThemeFont)( - __in HTHEME hTheme, - __in HDC hdc, - __in INT iPartId, - __in INT iStateId, - __in INT iPropId, - __out LOGFONTW *pFont - ); - -typedef HRESULT (WINAPI *_GetThemeSysFont)( - __in HTHEME hTheme, - __in INT iFontId, - __out LOGFONTW *plf - ); - -typedef BOOL (WINAPI *_IsThemeBackgroundPartiallyTransparent)( - __in HTHEME hTheme, - __in INT iPartId, - __in INT iStateId - ); - -typedef HRESULT (WINAPI *_GetThemeBackgroundContentRect)( - __in HTHEME hTheme, - __in HDC hdc, - __in INT iPartId, - __in INT iStateId, - __inout LPCRECT pBoundingRect, - __out LPRECT pContentRect + _In_ HWND WindowHandle, + _In_ UINT CmdId ); -typedef struct _NC_CONTEXT +typedef struct _EDIT_CONTEXT { - UINT CommandID; // sent in a WM_COMMAND message - - INT cxLeftEdge; // size of the current window borders. - INT cxRightEdge; // size of the current window borders. - INT cyTopEdge; - INT cyBottomEdge; + UINT CommandID; + INT CXBorder; + INT CYBorder; LONG cxImgSize; - HBITMAP ActiveBitmap; - HBITMAP InactiveBitmap; - BOOLEAN HasCapture; + HWND WindowHandle; + HIMAGELIST ImageList; + + HBRUSH BrushNormal; + HBRUSH BrushFocused; + HBRUSH BrushHot; + HBRUSH BrushBackground; + COLORREF BackgroundColorRef; + +#ifdef _HOTTRACK_ENABLED_ + BOOLEAN MouseInClient; +#endif +#ifdef _UXTHEME_ENABLED_ BOOL IsThemeActive; BOOL IsThemeBackgroundActive; HTHEME UxThemeHandle; HMODULE UxThemeModule; - COLORREF clrUxThemeFillRef; - COLORREF clrUxThemeBackgroundRef; - - HIMAGELIST ImageList; - HWND ParentWindow; - HWND HwndWindow; -} NC_CONTEXT; +#endif +} EDIT_CONTEXT, *PEDIT_CONTEXT; HBITMAP LoadImageFromResources( - __in UINT Width, - __in UINT Height, - __in LPCTSTR Name + _In_ UINT Width, + _In_ UINT Height, + _In_ LPCTSTR Name ); #endif \ No newline at end of file diff --git a/2.x/trunk/plugins/Updater/CHANGELOG.txt b/2.x/trunk/plugins/Updater/CHANGELOG.txt index a308dbb77..2082f570c 100644 --- a/2.x/trunk/plugins/Updater/CHANGELOG.txt +++ b/2.x/trunk/plugins/Updater/CHANGELOG.txt @@ -1,3 +1,6 @@ +1.5 + * Added dynamic URL support + 1.4 * Added PNG images * Fixed offline crash diff --git a/2.x/trunk/plugins/Updater/Updater.rc b/2.x/trunk/plugins/Updater/Updater.rc index 1f238e710..ad532e750 100644 --- a/2.x/trunk/plugins/Updater/Updater.rc +++ b/2.x/trunk/plugins/Updater/Updater.rc @@ -24,8 +24,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,0,0 - PRODUCTVERSION 1,4,0,0 + FILEVERSION 1,5,0,0 + PRODUCTVERSION 1,5,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -42,12 +42,12 @@ BEGIN BEGIN VALUE "CompanyName", "dmex" VALUE "FileDescription", "Update Checker plugin for Process Hacker" - VALUE "FileVersion", "1.4.0.0" + VALUE "FileVersion", "1.5.0.0" VALUE "InternalName", "UpdateChecker" VALUE "LegalCopyright", "Licensed under the GNU GPL, v3." VALUE "OriginalFilename", "Updater.dll" VALUE "ProductName", "Update Checker plugin for Process Hacker" - VALUE "ProductVersion", "1.4.0.0" + VALUE "ProductVersion", "1.5.0.0" END END BLOCK "VarFileInfo" diff --git a/2.x/trunk/plugins/Updater/Updater.vcxproj b/2.x/trunk/plugins/Updater/Updater.vcxproj index 2d6a28ba1..e70f79aea 100644 --- a/2.x/trunk/plugins/Updater/Updater.vcxproj +++ b/2.x/trunk/plugins/Updater/Updater.vcxproj @@ -68,7 +68,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true @@ -81,8 +80,8 @@ false $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ - AllRules.ruleset - AllRules.ruleset + NativeRecommendedRules.ruleset + NativeRecommendedRules.ruleset diff --git a/2.x/trunk/plugins/Updater/main.c b/2.x/trunk/plugins/Updater/main.c index 07d1c11eb..05d59dd52 100644 --- a/2.x/trunk/plugins/Updater/main.c +++ b/2.x/trunk/plugins/Updater/main.c @@ -23,20 +23,20 @@ #include "updater.h" VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); PPH_PLUGIN PluginInstance; @@ -45,9 +45,9 @@ static PH_CALLBACK_REGISTRATION MainWindowShowingCallbackRegistration; static PH_CALLBACK_REGISTRATION PluginShowOptionsCallbackRegistration; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -101,8 +101,8 @@ LOGICAL DllMain( } static VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { // Add our menu item, 4 = Help menu. @@ -117,8 +117,8 @@ static VOID NTAPI MainWindowShowingCallback( } static VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter; @@ -130,8 +130,8 @@ static VOID NTAPI MenuItemCallback( } static VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { DialogBox( @@ -143,7 +143,7 @@ static VOID NTAPI ShowOptionsCallback( } PPH_STRING PhGetOpaqueXmlNodeText( - __in mxml_node_t *xmlNode + _In_ mxml_node_t *xmlNode ) { if (xmlNode && xmlNode->child && xmlNode->child->type == MXML_OPAQUE && xmlNode->child->value.opaque) @@ -176,58 +176,4 @@ BOOL PhInstalledUsingSetup( } return FALSE; -} - -BOOL ConnectionAvailable( - VOID - ) -{ - BOOLEAN isSuccess = FALSE; - HMODULE libraryHandle = NULL; - INetworkListManager* networkListPtr = NULL; - - __try - { - if (WindowsVersion < WINDOWS_VISTA) - { - ULONG inetState = 0; - _InternetGetConnectedState inetGetConnectedState_I = NULL; - - if (!(libraryHandle = LoadLibrary(L"wininet.dll"))) - __leave; - - if (!(inetGetConnectedState_I = (_InternetGetConnectedState)GetProcAddress(libraryHandle, "InternetGetConnectedState"))) - __leave; - - if (inetGetConnectedState_I(&inetState, 0)) - isSuccess = TRUE; - } - else - { - VARIANT_BOOL isConnected = VARIANT_FALSE; - VARIANT_BOOL isConnectedInternet = VARIANT_FALSE; - - // Create an instance of the INetworkListManger COM object. - if (FAILED(CoCreateInstance(&CLSID_NetworkListManager, NULL, CLSCTX_ALL, &IID_INetworkListManager, &networkListPtr))) - __leave; - - // Query the relevant properties. - INetworkListManager_get_IsConnected(networkListPtr, &isConnected); - INetworkListManager_get_IsConnectedToInternet(networkListPtr, &isConnectedInternet); - - // Check if Windows is connected to a network and it's connected to the internet. - if (isConnected == VARIANT_TRUE && isConnectedInternet == VARIANT_TRUE) - isSuccess = TRUE; - } - } - __finally - { - if (libraryHandle) - FreeLibrary(libraryHandle); - - if (networkListPtr) - INetworkListManager_Release(networkListPtr); - } - - return isSuccess; } \ No newline at end of file diff --git a/2.x/trunk/plugins/Updater/options.c b/2.x/trunk/plugins/Updater/options.c index 498262817..8513cd2fc 100644 --- a/2.x/trunk/plugins/Updater/options.c +++ b/2.x/trunk/plugins/Updater/options.c @@ -23,10 +23,10 @@ #include "updater.h" INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/plugins/Updater/updater.c b/2.x/trunk/plugins/Updater/updater.c index 1840256fa..cd9857824 100644 --- a/2.x/trunk/plugins/Updater/updater.c +++ b/2.x/trunk/plugins/Updater/updater.c @@ -2,7 +2,7 @@ * Process Hacker Update Checker - * Update Window * - * Copyright (C) 2011-2013 dmex + * Copyright (C) 2011-2014 dmex * * This file is part of Process Hacker. * @@ -22,38 +22,28 @@ #include "updater.h" -// Force update checks to succeed with debug builds -//#define DEBUG_UPDATE - -#define PH_UPDATEISERRORED (WM_APP + 101) -#define PH_UPDATEAVAILABLE (WM_APP + 102) -#define PH_UPDATEISCURRENT (WM_APP + 103) -#define PH_UPDATENEWER (WM_APP + 104) -#define PH_HASHSUCCESS (WM_APP + 105) -#define PH_HASHFAILURE (WM_APP + 106) -#define PH_INETFAILURE (WM_APP + 107) -#define WM_SHOWDIALOG (WM_APP + 150) - static HANDLE UpdateDialogThreadHandle = NULL; static HWND UpdateDialogHandle = NULL; static PH_EVENT InitializedEvent = PH_EVENT_INIT; static HBITMAP LoadImageFromResources( - __in UINT Width, - __in UINT Height, - __in LPCTSTR Name + _In_ UINT Width, + _In_ UINT Height, + _In_ PCWSTR Name ) { UINT width = 0; UINT height = 0; UINT frameCount = 0; - ULONG resLength = 0; - HRSRC resHandleSrc = NULL; - HGLOBAL resHandle = NULL; - WICInProcPointer resBuffer = NULL; + BOOLEAN isSuccess = FALSE; + ULONG resourceLength = 0; + HGLOBAL resourceHandle = NULL; + HRSRC resourceHandleSource = NULL; + WICInProcPointer resourceBuffer = NULL; + BITMAPINFO bitmapInfo = { 0 }; HBITMAP bitmapHandle = NULL; - BYTE* bitmapBuffer = NULL; + PBYTE bitmapBuffer = NULL; IWICStream* wicStream = NULL; IWICBitmapSource* wicBitmapSource = NULL; @@ -63,85 +53,92 @@ static HBITMAP LoadImageFromResources( IWICBitmapScaler* wicScaler = NULL; WICPixelFormatGUID pixelFormat; - HDC hdcScreen = GetDC(NULL); + WICRect rect = { 0, 0, Width, Height }; __try - { - // Create the ImagingFactory. + { + // Create the ImagingFactory if (FAILED(CoCreateInstance(&CLSID_WICImagingFactory1, NULL, CLSCTX_INPROC_SERVER, &IID_IWICImagingFactory, (PVOID*)&wicFactory))) __leave; - // Create the PNG decoder. - if (FAILED(CoCreateInstance(&CLSID_WICPngDecoder1, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapDecoder, (PVOID*)&wicDecoder))) - __leave; - // Find the resource. - if ((resHandleSrc = FindResource((HINSTANCE)PluginInstance->DllBase, Name, L"PNG")) == NULL) + // Find the resource + if ((resourceHandleSource = FindResource(PluginInstance->DllBase, Name, L"PNG")) == NULL) __leave; - // Get the resource length. - resLength = SizeofResource((HINSTANCE)PluginInstance->DllBase, resHandleSrc); - // Load the resource. - if ((resHandle = LoadResource((HINSTANCE)PluginInstance->DllBase, resHandleSrc)) == NULL) + + // Get the resource length + resourceLength = SizeofResource(PluginInstance->DllBase, resourceHandleSource); + + // Load the resource + if ((resourceHandle = LoadResource(PluginInstance->DllBase, resourceHandleSource)) == NULL) __leave; - if ((resBuffer = (WICInProcPointer)LockResource(resHandle)) == NULL) + + if ((resourceBuffer = (WICInProcPointer)LockResource(resourceHandle)) == NULL) __leave; - // Create the Stream. + // Create the Stream if (FAILED(IWICImagingFactory_CreateStream(wicFactory, &wicStream))) __leave; - // Initialize the Stream from Memory. - if (FAILED(IWICStream_InitializeFromMemory(wicStream, resBuffer, resLength))) + + // Initialize the Stream from Memory + if (FAILED(IWICStream_InitializeFromMemory(wicStream, resourceBuffer, resourceLength))) + __leave; + + if (FAILED(IWICImagingFactory_CreateDecoder(wicFactory, &GUID_ContainerFormatPng, NULL, &wicDecoder))) __leave; + if (FAILED(IWICBitmapDecoder_Initialize(wicDecoder, (IStream*)wicStream, WICDecodeMetadataCacheOnLoad))) __leave; - // Get the Frame count. + + // Get the Frame count if (FAILED(IWICBitmapDecoder_GetFrameCount(wicDecoder, &frameCount)) || frameCount < 1) __leave; - // Get the Frame. + + // Get the Frame if (FAILED(IWICBitmapDecoder_GetFrame(wicDecoder, 0, &wicFrame))) __leave; - // Get the WicFrame width and height. - if (FAILED(IWICBitmapSource_GetSize((IWICBitmapSource*)wicFrame, &width, &height)) || width == 0 || height == 0) - __leave; - // Get the WicFrame image format. - if (FAILED(IWICBitmapSource_GetPixelFormat((IWICBitmapSource*)wicFrame, &pixelFormat))) - __leave; - // Check if the image format is supported: - if (!IsEqualGUID(&pixelFormat, &GUID_WICPixelFormat32bppBGRA)) - { - // Convert the image to the correct format: - if (FAILED(WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGRA, (IWICBitmapSource*)wicFrame, &wicBitmapSource))) - __leave; - IWICBitmapFrameDecode_Release(wicFrame); - } - else + // Get the WicFrame image format + if (SUCCEEDED(IWICBitmapFrameDecode_GetPixelFormat(wicFrame, &pixelFormat))) { - wicBitmapSource = (IWICBitmapSource*)wicFrame; + // Check if the image format is supported: + if (IsEqualGUID(&pixelFormat, &GUID_WICPixelFormat32bppBGR)) + { + wicBitmapSource = (IWICBitmapSource*)wicFrame; + } + else + { + // Convert the image to the correct format: + if (FAILED(WICConvertBitmapSource(&GUID_WICPixelFormat32bppBGR, (IWICBitmapSource*)wicFrame, &wicBitmapSource))) + __leave; + + IWICBitmapFrameDecode_Release(wicFrame); + } } bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapInfo.bmiHeader.biWidth = Width; - bitmapInfo.bmiHeader.biHeight = -((LONG)Height); + bitmapInfo.bmiHeader.biWidth = rect.Width; + bitmapInfo.bmiHeader.biHeight = -((LONG)rect.Height); bitmapInfo.bmiHeader.biPlanes = 1; bitmapInfo.bmiHeader.biBitCount = 32; bitmapInfo.bmiHeader.biCompression = BI_RGB; - if ((bitmapHandle = CreateDIBSection(hdcScreen, &bitmapInfo, DIB_RGB_COLORS, (PVOID*)&bitmapBuffer, NULL, 0)) != NULL) - { - WICRect rect = { 0, 0, Width, Height }; + HDC hdc = CreateCompatibleDC(NULL); + bitmapHandle = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, (PVOID*)&bitmapBuffer, NULL, 0); + ReleaseDC(NULL, hdc); - if (FAILED(IWICImagingFactory_CreateBitmapScaler(wicFactory, &wicScaler))) - __leave; - if (FAILED(IWICBitmapScaler_Initialize(wicScaler, wicBitmapSource, Width, Height, WICBitmapInterpolationModeFant))) - __leave; - if (FAILED(IWICBitmapScaler_CopyPixels(wicScaler, &rect, Width * 4, Width * Height * 4, bitmapBuffer))) - __leave; - } + // Check if it's the same rect as the requested size. + //if (width != rect.Width || height != rect.Height) + if (FAILED(IWICImagingFactory_CreateBitmapScaler(wicFactory, &wicScaler))) + __leave; + if (FAILED(IWICBitmapScaler_Initialize(wicScaler, wicBitmapSource, rect.Width, rect.Height, WICBitmapInterpolationModeFant))) + __leave; + if (FAILED(IWICBitmapScaler_CopyPixels(wicScaler, &rect, rect.Width * 4, rect.Width * rect.Height * 4, bitmapBuffer))) + __leave; + + isSuccess = TRUE; } __finally { - ReleaseDC(NULL, hdcScreen); - if (wicScaler) { IWICBitmapScaler_Release(wicScaler); @@ -166,10 +163,10 @@ static HBITMAP LoadImageFromResources( { IWICImagingFactory_Release(wicFactory); } - - if (resHandle) + + if (resourceHandle) { - FreeResource(resHandle); + FreeResource(resourceHandle); } } @@ -177,18 +174,18 @@ static HBITMAP LoadImageFromResources( } static mxml_type_t QueryXmlDataCallback( - __in mxml_node_t *node + _In_ mxml_node_t *node ) { return MXML_OPAQUE; } static BOOLEAN ParseVersionString( - __inout PPH_UPDATER_CONTEXT Context + _Inout_ PPH_UPDATER_CONTEXT Context ) { PH_STRINGREF sr, majorPart, minorPart, revisionPart; - ULONG64 majorInteger = 0, minorInteger = 0, revisionInteger; + ULONG64 majorInteger = 0, minorInteger = 0, revisionInteger = 0; PhInitializeStringRef(&sr, Context->Version->Buffer); PhInitializeStringRef(&revisionPart, Context->RevVersion->Buffer); @@ -211,9 +208,9 @@ static BOOLEAN ParseVersionString( } static BOOLEAN ReadRequestString( - __in HINTERNET Handle, - __out_z PSTR* Data, - __out ULONG* DataLength + _In_ HINTERNET Handle, + _Out_ _Deref_post_z_cap_(*DataLength) PSTR *Data, + _Out_ ULONG *DataLength ) { BYTE buffer[PAGE_SIZE]; @@ -277,7 +274,7 @@ static PPH_UPDATER_CONTEXT CreateUpdateContext( } static VOID FreeUpdateContext( - __in __post_invalid PPH_UPDATER_CONTEXT Context + _In_ _Post_invalid_ PPH_UPDATER_CONTEXT Context ) { if (!Context) @@ -293,6 +290,7 @@ static VOID FreeUpdateContext( Context->CurrentMajorVersion = 0; Context->CurrentRevisionVersion = 0; + PhSwapReference(&Context->UserAgent, NULL); PhSwapReference(&Context->Version, NULL); PhSwapReference(&Context->RevVersion, NULL); PhSwapReference(&Context->RelDate, NULL); @@ -300,12 +298,7 @@ static VOID FreeUpdateContext( PhSwapReference(&Context->Hash, NULL); PhSwapReference(&Context->ReleaseNotesUrl, NULL); PhSwapReference(&Context->SetupFilePath, NULL); - - if (Context->HttpSessionHandle) - { - WinHttpCloseHandle(Context->HttpSessionHandle); - Context->HttpSessionHandle = NULL; - } + PhSwapReference(&Context->SetupFileDownloadUrl, NULL); if (Context->IconHandle) { @@ -329,15 +322,17 @@ static VOID FreeUpdateContext( } static BOOLEAN QueryUpdateData( - __inout PPH_UPDATER_CONTEXT Context + _Inout_ PPH_UPDATER_CONTEXT Context ) { BOOLEAN isSuccess = FALSE; + HINTERNET httpSessionHandle = NULL; + HINTERNET httpConnectionHandle = NULL; + HINTERNET httpRequestHandle = NULL; + WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig = { 0 }; mxml_node_t* xmlNode = NULL; ULONG xmlStringBufferLength = 0; PSTR xmlStringBuffer = NULL; - HINTERNET connectionHandle = NULL; - HINTERNET requestHandle = NULL; // Get the current Process Hacker version PhGetPhVersionNumbers( @@ -349,38 +344,33 @@ static BOOLEAN QueryUpdateData( __try { - // Reuse existing session? - if (!Context->HttpSessionHandle) - { - PPH_STRING phVersion = NULL; - PPH_STRING userAgent = NULL; - WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig = { 0 }; - - // Create a user agent string. - phVersion = PhGetPhVersion(); - userAgent = PhConcatStrings2(L"PH_", phVersion->Buffer); - - // Query the current system proxy - WinHttpGetIEProxyConfigForCurrentUser(&proxyConfig); - - // Open the HTTP session with the system proxy configuration if available - Context->HttpSessionHandle = WinHttpOpen( - userAgent->Buffer, - proxyConfig.lpszProxy != NULL ? WINHTTP_ACCESS_TYPE_NAMED_PROXY : WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, - proxyConfig.lpszProxy, - proxyConfig.lpszProxyBypass, - 0 - ); + // Create a user agent string. + Context->UserAgent = PhFormatString( + L"PH_%lu.%lu_%lu", + Context->CurrentMajorVersion, + Context->CurrentMinorVersion, + Context->CurrentRevisionVersion + ); + if (PhIsNullOrEmptyString(Context->UserAgent)) + __leave; - PhSwapReference(&phVersion, NULL); - PhSwapReference(&userAgent, NULL); + // Query the current system proxy + WinHttpGetIEProxyConfigForCurrentUser(&proxyConfig); - if (!Context->HttpSessionHandle) - __leave; + // Open the HTTP session with the system proxy configuration if available + if (!(httpSessionHandle = WinHttpOpen( + Context->UserAgent->Buffer, + proxyConfig.lpszProxy != NULL ? WINHTTP_ACCESS_TYPE_NAMED_PROXY : WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, + proxyConfig.lpszProxy, + proxyConfig.lpszProxyBypass, + 0 + ))) + { + __leave; } - if (!(connectionHandle = WinHttpConnect( - Context->HttpSessionHandle, + if (!(httpConnectionHandle = WinHttpConnect( + httpSessionHandle, L"processhacker.sourceforge.net", INTERNET_DEFAULT_HTTP_PORT, 0 @@ -389,8 +379,8 @@ static BOOLEAN QueryUpdateData( __leave; } - if (!(requestHandle = WinHttpOpenRequest( - connectionHandle, + if (!(httpRequestHandle = WinHttpOpenRequest( + httpConnectionHandle, L"GET", L"/update.php", NULL, @@ -403,7 +393,7 @@ static BOOLEAN QueryUpdateData( } if (!WinHttpSendRequest( - requestHandle, + httpRequestHandle, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0 @@ -412,13 +402,14 @@ static BOOLEAN QueryUpdateData( __leave; } - if (!WinHttpReceiveResponse(requestHandle, NULL)) + if (!WinHttpReceiveResponse(httpRequestHandle, NULL)) __leave; // Read the resulting xml into our buffer. - if (!ReadRequestString(requestHandle, &xmlStringBuffer, &xmlStringBufferLength)) + if (!ReadRequestString(httpRequestHandle, &xmlStringBuffer, &xmlStringBufferLength)) __leave; - // Check the buffer for any data + + // Check the buffer for valid data. if (xmlStringBuffer == NULL || xmlStringBuffer[0] == '\0') __leave; @@ -469,6 +460,13 @@ static BOOLEAN QueryUpdateData( if (PhIsNullOrEmptyString(Context->ReleaseNotesUrl)) __leave; + // Find the installer download URL + Context->SetupFileDownloadUrl = PhGetOpaqueXmlNodeText( + mxmlFindElement(xmlNode->child, xmlNode, "setupurl", NULL, NULL, MXML_DESCEND) + ); + if (PhIsNullOrEmptyString(Context->SetupFileDownloadUrl)) + __leave; + if (!ParseVersionString(Context)) __leave; @@ -476,11 +474,14 @@ static BOOLEAN QueryUpdateData( } __finally { - if (requestHandle) - WinHttpCloseHandle(requestHandle); + if (httpRequestHandle) + WinHttpCloseHandle(httpRequestHandle); + + if (httpConnectionHandle) + WinHttpCloseHandle(httpConnectionHandle); - if (connectionHandle) - WinHttpCloseHandle(connectionHandle); + if (httpSessionHandle) + WinHttpCloseHandle(httpSessionHandle); if (xmlNode) mxmlDelete(xmlNode); @@ -493,19 +494,17 @@ static BOOLEAN QueryUpdateData( } static NTSTATUS UpdateCheckSilentThread( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_UPDATER_CONTEXT context = NULL; ULONGLONG currentVersion = 0; ULONGLONG latestVersion = 0; + context = CreateUpdateContext(); + __try { - if (!ConnectionAvailable()) - __leave; - - context = CreateUpdateContext(); if (!QueryUpdateData(context)) __leave; @@ -551,7 +550,7 @@ static NTSTATUS UpdateCheckSilentThread( __finally { // Check the dialog doesn't own the window context... - if (context && !context->HaveData) + if (context->HaveData == FALSE) FreeUpdateContext(context); } @@ -559,21 +558,15 @@ static NTSTATUS UpdateCheckSilentThread( } static NTSTATUS UpdateCheckThread( - __in PVOID Parameter + _In_ PVOID Parameter ) { PPH_UPDATER_CONTEXT context = NULL; ULONGLONG currentVersion = 0; ULONGLONG latestVersion = 0; - if (!ConnectionAvailable()) - { - PostMessage(UpdateDialogHandle, PH_INETFAILURE, 0, 0); - return STATUS_SUCCESS; - } - context = (PPH_UPDATER_CONTEXT)Parameter; - + // Check if we have cached update data if (!context->HaveData) context->HaveData = QueryUpdateData(context); @@ -581,7 +574,7 @@ static NTSTATUS UpdateCheckThread( // sanity check if (!context->HaveData) { - PostMessage(UpdateDialogHandle, PH_UPDATEISERRORED, 0, 0); + PostMessage(context->DialogHandle, PH_UPDATEISERRORED, 0, 0); return STATUS_SUCCESS; } @@ -611,57 +604,48 @@ static NTSTATUS UpdateCheckThread( if (currentVersion == latestVersion) { // User is running the latest version - PostMessage(UpdateDialogHandle, PH_UPDATEISCURRENT, 0, 0); + PostMessage(context->DialogHandle, PH_UPDATEISCURRENT, 0, 0); } else if (currentVersion > latestVersion) { // User is running a newer version - PostMessage(UpdateDialogHandle, PH_UPDATENEWER, 0, 0); + PostMessage(context->DialogHandle, PH_UPDATENEWER, 0, 0); } else { // User is running an older version - PostMessage(UpdateDialogHandle, PH_UPDATEAVAILABLE, 0, 0); + PostMessage(context->DialogHandle, PH_UPDATEAVAILABLE, 0, 0); } return STATUS_SUCCESS; } static NTSTATUS UpdateDownloadThread( - __in PVOID Parameter + _In_ PVOID Parameter ) { - PPH_UPDATER_CONTEXT context; + BOOLEAN isSuccess = FALSE; + HANDLE tempFileHandle = NULL; + HINTERNET httpSessionHandle = NULL; + HINTERNET httpConnectionHandle = NULL; + HINTERNET httpRequestHandle = NULL; PPH_STRING setupTempPath = NULL; + PPH_STRING downloadHostPath = NULL; PPH_STRING downloadUrlPath = NULL; - HINTERNET connectionHandle = NULL; - HINTERNET requestHandle = NULL; - HANDLE tempFileHandle = NULL; - BOOLEAN isSuccess = FALSE; + URL_COMPONENTS httpUrlComponents = { sizeof(URL_COMPONENTS) }; + WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig = { 0 }; - context = (PPH_UPDATER_CONTEXT)Parameter; + PPH_UPDATER_CONTEXT context = (PPH_UPDATER_CONTEXT)Parameter; __try { - if (context == NULL) - __leave; - - // create the download path string. - downloadUrlPath = PhFormatString( - L"/projects/processhacker/files/processhacker2/processhacker-%lu.%lu-setup.exe/download?use_mirror=autoselect", /* ?use_mirror=waix" */ - context->MajorVersion, - context->MinorVersion - ); - if (PhIsNullOrEmptyString(downloadUrlPath)) - __leave; - // Allocate the GetTempPath buffer setupTempPath = PhCreateStringEx(NULL, GetTempPath(0, NULL) * sizeof(WCHAR)); if (PhIsNullOrEmptyString(setupTempPath)) __leave; // Get the temp path - if (GetTempPath((DWORD)setupTempPath->Length / sizeof(WCHAR), setupTempPath->Buffer) == 0) + if (GetTempPath((ULONG)setupTempPath->Length / sizeof(WCHAR), setupTempPath->Buffer) == 0) __leave; if (PhIsNullOrEmptyString(setupTempPath)) __leave; @@ -674,7 +658,6 @@ static NTSTATUS UpdateDownloadThread( context->MajorVersion, context->MinorVersion ); - if (PhIsNullOrEmptyString(context->SetupFilePath)) __leave; @@ -692,11 +675,57 @@ static NTSTATUS UpdateDownloadThread( __leave; } - SetDlgItemText(UpdateDialogHandle, IDC_STATUS, L"Connecting..."); + // Set lengths to non-zero enabling these params to be cracked. + httpUrlComponents.dwSchemeLength = (ULONG)-1; + httpUrlComponents.dwHostNameLength = (ULONG)-1; + httpUrlComponents.dwUrlPathLength = (ULONG)-1; - if (!(connectionHandle = WinHttpConnect( - context->HttpSessionHandle, - L"sourceforge.net", + if (!WinHttpCrackUrl( + context->SetupFileDownloadUrl->Buffer, + (ULONG)context->SetupFileDownloadUrl->Length, + 0, + &httpUrlComponents + )) + { + __leave; + } + + // Create the Host string. + downloadHostPath = PhCreateStringEx( + httpUrlComponents.lpszHostName, + httpUrlComponents.dwHostNameLength * sizeof(WCHAR) + ); + if (PhIsNullOrEmptyString(downloadHostPath)) + __leave; + + // Create the Path string. + downloadUrlPath = PhCreateStringEx( + httpUrlComponents.lpszUrlPath, + httpUrlComponents.dwUrlPathLength * sizeof(WCHAR) + ); + if (PhIsNullOrEmptyString(downloadUrlPath)) + __leave; + + SetDlgItemText(context->DialogHandle, IDC_STATUS, L"Connecting..."); + + // Query the current system proxy + WinHttpGetIEProxyConfigForCurrentUser(&proxyConfig); + + // Open the HTTP session with the system proxy configuration if available + if (!(httpSessionHandle = WinHttpOpen( + context->UserAgent->Buffer, + proxyConfig.lpszProxy != NULL ? WINHTTP_ACCESS_TYPE_NAMED_PROXY : WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, + proxyConfig.lpszProxy, + proxyConfig.lpszProxyBypass, + 0 + ))) + { + __leave; + } + + if (!(httpConnectionHandle = WinHttpConnect( + httpSessionHandle, + downloadHostPath->Buffer, INTERNET_DEFAULT_HTTP_PORT, 0 ))) @@ -704,23 +733,23 @@ static NTSTATUS UpdateDownloadThread( __leave; } - if (!(requestHandle = WinHttpOpenRequest( - connectionHandle, + if (!(httpRequestHandle = WinHttpOpenRequest( + httpConnectionHandle, L"GET", downloadUrlPath->Buffer, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, - 0 // WINHTTP_FLAG_REFRESH + WINHTTP_FLAG_REFRESH ))) { __leave; } - SetDlgItemText(UpdateDialogHandle, IDC_STATUS, L"Sending request..."); + SetDlgItemText(context->DialogHandle, IDC_STATUS, L"Sending request..."); if (!WinHttpSendRequest( - requestHandle, + httpRequestHandle, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, @@ -732,9 +761,9 @@ static NTSTATUS UpdateDownloadThread( __leave; } - SetDlgItemText(UpdateDialogHandle, IDC_STATUS, L"Waiting for response..."); + SetDlgItemText(context->DialogHandle, IDC_STATUS, L"Waiting for response..."); - if (WinHttpReceiveResponse(requestHandle, NULL)) + if (WinHttpReceiveResponse(httpRequestHandle, NULL)) { BYTE buffer[PAGE_SIZE]; BYTE hashBuffer[20]; @@ -747,7 +776,7 @@ static NTSTATUS UpdateDownloadThread( IO_STATUS_BLOCK isb; if (!WinHttpQueryHeaders( - requestHandle, + httpRequestHandle, WINHTTP_QUERY_CONTENT_LENGTH | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &contentLength, @@ -765,7 +794,7 @@ static NTSTATUS UpdateDownloadThread( memset(buffer, 0, PAGE_SIZE); // Download the data. - while (WinHttpReadData(requestHandle, buffer, PAGE_SIZE, &bytesDownloaded)) + while (WinHttpReadData(httpRequestHandle, buffer, PAGE_SIZE, &bytesDownloaded)) { // If we get zero bytes, the file was uploaded or there was an error if (bytesDownloaded == 0) @@ -801,22 +830,23 @@ static NTSTATUS UpdateDownloadThread( if (bytesDownloaded != isb.Information) __leave; - //Update the GUI progress. + // Update the GUI progress. + // TODO: Update on GUI thread. { - int percent = MulDiv(100, downloadedBytes, contentLength); - - PPH_STRING totalLength = PhFormatSize(contentLength, -1); + //int percent = MulDiv(100, downloadedBytes, contentLength); + FLOAT percent = ((FLOAT)downloadedBytes / contentLength * 100); PPH_STRING totalDownloaded = PhFormatSize(downloadedBytes, -1); + PPH_STRING totalLength = PhFormatSize(contentLength, -1); PPH_STRING dlLengthString = PhFormatString( - L"%s of %s (%d%%)", + L"%s of %s (%.0f%%)", totalDownloaded->Buffer, totalLength->Buffer, percent ); // Update the progress bar position - SendMessage(context->ProgressHandle, PBM_SETPOS, percent, 0); + SendMessage(context->ProgressHandle, PBM_SETPOS, (ULONG)percent, 0); Static_SetText(context->StatusHandle, dlLengthString->Buffer); PhDereferenceObject(dlLengthString); @@ -825,10 +855,7 @@ static NTSTATUS UpdateDownloadThread( } } - // Check if we downloaded the entire file. - //assert(downloadedBytes == contentLength); - - // Compute our hash result. + // Compute hash result (will fail if file not downloaded correctly). if (PhFinalHash(&hashContext, &hashBuffer, 20, NULL)) { // Allocate our hash string, hex the final hash result in our hashBuffer. @@ -836,18 +863,18 @@ static NTSTATUS UpdateDownloadThread( if (PhEqualString(hexString, context->Hash, TRUE)) { - PostMessage(UpdateDialogHandle, PH_HASHSUCCESS, 0, 0); + PostMessage(context->DialogHandle, PH_HASHSUCCESS, 0, 0); } else { - PostMessage(UpdateDialogHandle, PH_HASHFAILURE, 0, 0); + PostMessage(context->DialogHandle, PH_HASHFAILURE, 0, 0); } PhDereferenceObject(hexString); } else { - PostMessage(UpdateDialogHandle, PH_HASHFAILURE, 0, 0); + PostMessage(context->DialogHandle, PH_HASHFAILURE, 0, 0); } } @@ -858,27 +885,31 @@ static NTSTATUS UpdateDownloadThread( if (tempFileHandle) NtClose(tempFileHandle); - if (requestHandle) - WinHttpCloseHandle(requestHandle); + if (httpRequestHandle) + WinHttpCloseHandle(httpRequestHandle); - if (connectionHandle) - WinHttpCloseHandle(connectionHandle); + if (httpConnectionHandle) + WinHttpCloseHandle(httpConnectionHandle); + + if (httpSessionHandle) + WinHttpCloseHandle(httpSessionHandle); PhSwapReference(&setupTempPath, NULL); + PhSwapReference(&downloadHostPath, NULL); PhSwapReference(&downloadUrlPath, NULL); } if (!isSuccess) // Display error info - PostMessage(UpdateDialogHandle, PH_UPDATEISERRORED, 0, 0); + PostMessage(context->DialogHandle, PH_UPDATEISERRORED, 0, 0); return STATUS_SUCCESS; } static INT_PTR CALLBACK UpdaterWndProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PPH_UPDATER_CONTEXT context = NULL; @@ -915,6 +946,7 @@ static INT_PTR CALLBACK UpdaterWndProc( headerFont.lfWeight = FW_MEDIUM; headerFont.lfQuality = CLEARTYPE_QUALITY | ANTIALIASED_QUALITY; + context->DialogHandle = hwndDlg; context->StatusHandle = GetDlgItem(hwndDlg, IDC_STATUS); context->ProgressHandle = GetDlgItem(hwndDlg, IDC_PROGRESS); @@ -1204,17 +1236,6 @@ static INT_PTR CALLBACK UpdaterWndProc( // Hash failed, reset state to downloading so user can redownload the file. } break; - case PH_INETFAILURE: - { - context->UpdaterState = PhUpdateDefault; - - SetDlgItemText(hwndDlg, IDC_MESSAGE, L"Please check for updates again..."); - SetDlgItemText(hwndDlg, IDC_RELDATE, L"No internet connection detected."); - - Button_SetText(GetDlgItem(hwndDlg, IDC_DOWNLOAD), L"Retry"); - Button_Enable(GetDlgItem(hwndDlg, IDC_DOWNLOAD), TRUE); - } - break; case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) @@ -1236,7 +1257,7 @@ static INT_PTR CALLBACK UpdaterWndProc( } static NTSTATUS ShowUpdateDialogThread( - __in PVOID Parameter + _In_ PVOID Parameter ) { BOOL result; @@ -1244,7 +1265,7 @@ static NTSTATUS ShowUpdateDialogThread( PH_AUTO_POOL autoPool; PPH_UPDATER_CONTEXT context = NULL; - if (Parameter != NULL) + if (Parameter) context = (PPH_UPDATER_CONTEXT)Parameter; else context = CreateUpdateContext(); @@ -1294,7 +1315,7 @@ static NTSTATUS ShowUpdateDialogThread( } VOID ShowUpdateDialog( - __in_opt PPH_UPDATER_CONTEXT Context + _In_opt_ PPH_UPDATER_CONTEXT Context ) { if (!UpdateDialogThreadHandle) @@ -1308,7 +1329,7 @@ VOID ShowUpdateDialog( PhWaitForEvent(&InitializedEvent, NULL); } - SendMessage(UpdateDialogHandle, WM_SHOWDIALOG, 0, 0); + PostMessage(UpdateDialogHandle, WM_SHOWDIALOG, 0, 0); } VOID StartInitialCheck( diff --git a/2.x/trunk/plugins/Updater/updater.h b/2.x/trunk/plugins/Updater/updater.h index 203a80522..2c2dc047c 100644 --- a/2.x/trunk/plugins/Updater/updater.h +++ b/2.x/trunk/plugins/Updater/updater.h @@ -4,11 +4,12 @@ #pragma comment(lib, "Winhttp.lib") #pragma comment(lib, "WindowsCodecs.lib") +#define CINTERFACE +#define COBJMACROS +#define INITGUID #include #include #include -#define CINTERFACE -#define COBJMACROS #include #include #include @@ -16,16 +17,28 @@ #include "resource.h" -#define Control_Visible(hWnd, visible) \ - ShowWindow(hWnd, visible ? SW_SHOW : SW_HIDE); +// Force update checks to succeed with debug builds +//#define DEBUG_UPDATE +#define UPDATE_MENUITEM 1001 +#define PH_UPDATEISERRORED (WM_APP + 101) +#define PH_UPDATEAVAILABLE (WM_APP + 102) +#define PH_UPDATEISCURRENT (WM_APP + 103) +#define PH_UPDATENEWER (WM_APP + 104) +#define PH_HASHSUCCESS (WM_APP + 105) +#define PH_HASHFAILURE (WM_APP + 106) +#define WM_SHOWDIALOG (WM_APP + 150) + +DEFINE_GUID(IID_IWICImagingFactory, 0xec5ec8a9, 0xc395, 0x4314, 0x9c, 0x77, 0x54, 0xd7, 0xa9, 0x35, 0xff, 0x70); -#define UPDATE_MENUITEM 101 #define SETTING_AUTO_CHECK L"ProcessHacker.Updater.PromptStart" -#define MAKEDLLVERULL(major, minor, build, sp) \ +#define MAKEDLLVERULL(major, minor, build, revision) \ (((ULONGLONG)(major) << 48) | \ ((ULONGLONG)(minor) << 32) | \ ((ULONGLONG)(build) << 16) | \ - ((ULONGLONG)(sp) << 0)) + ((ULONGLONG)(revision) << 0)) + +#define Control_Visible(hWnd, visible) \ + ShowWindow(hWnd, visible ? SW_SHOW : SW_HIDE); extern PPH_PLUGIN PluginInstance; @@ -40,6 +53,13 @@ typedef enum _PH_UPDATER_STATE typedef struct _PH_UPDATER_CONTEXT { BOOLEAN HaveData; + PH_UPDATER_STATE UpdaterState; + HBITMAP SourceforgeBitmap; + HICON IconHandle; + HFONT FontHandle; + HWND StatusHandle; + HWND ProgressHandle; + HWND DialogHandle; ULONG MinorVersion; ULONG MajorVersion; @@ -47,25 +67,19 @@ typedef struct _PH_UPDATER_CONTEXT ULONG CurrentMinorVersion; ULONG CurrentMajorVersion; ULONG CurrentRevisionVersion; + PPH_STRING UserAgent; PPH_STRING Version; PPH_STRING RevVersion; PPH_STRING RelDate; PPH_STRING Size; PPH_STRING Hash; PPH_STRING ReleaseNotesUrl; + PPH_STRING SetupFileDownloadUrl; PPH_STRING SetupFilePath; - - PH_UPDATER_STATE UpdaterState; - HINTERNET HttpSessionHandle; - HBITMAP SourceforgeBitmap; - HICON IconHandle; - HFONT FontHandle; - HWND StatusHandle; - HWND ProgressHandle; } PH_UPDATER_CONTEXT, *PPH_UPDATER_CONTEXT; VOID ShowUpdateDialog( - __in_opt PPH_UPDATER_CONTEXT Context + _In_opt_ PPH_UPDATER_CONTEXT Context ); VOID StartInitialCheck( @@ -73,34 +87,25 @@ VOID StartInitialCheck( ); PPH_STRING PhGetOpaqueXmlNodeText( - __in mxml_node_t *xmlNode + _In_ mxml_node_t *xmlNode ); BOOL PhInstalledUsingSetup( VOID ); -BOOL ConnectionAvailable( - VOID - ); - INT_PTR CALLBACK UpdaterWndProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam - ); - -typedef BOOL (WINAPI *_InternetGetConnectedState)( - __out PULONG Flags, - __reserved ULONG Reserved + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); #endif \ No newline at end of file diff --git a/2.x/trunk/plugins/UserNotes/UserNotes.vcxproj b/2.x/trunk/plugins/UserNotes/UserNotes.vcxproj index 1cd64ae91..10b9b95ca 100644 --- a/2.x/trunk/plugins/UserNotes/UserNotes.vcxproj +++ b/2.x/trunk/plugins/UserNotes/UserNotes.vcxproj @@ -106,6 +106,7 @@ true ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + Windows @@ -120,6 +121,7 @@ true ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + Windows @@ -138,6 +140,7 @@ true true ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + Windows @@ -156,6 +159,7 @@ true true ProcessHacker.lib;ntdll.lib;%(AdditionalDependencies) + Windows diff --git a/2.x/trunk/plugins/UserNotes/db.c b/2.x/trunk/plugins/UserNotes/db.c index 760000dc1..29047f393 100644 --- a/2.x/trunk/plugins/UserNotes/db.c +++ b/2.x/trunk/plugins/UserNotes/db.c @@ -4,12 +4,12 @@ #include "db.h" BOOLEAN NTAPI ObjectDbCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG NTAPI ObjectDbHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); PPH_HASHTABLE ObjectDb; @@ -36,8 +36,8 @@ VOID InitializeDb( * \param Count The number of characters to hash. */ FORCEINLINE ULONG HashStringIgnoreCase( - __in PWSTR String, - __in SIZE_T Count + _In_ PWSTR String, + _In_ SIZE_T Count ) { ULONG hash = (ULONG)Count; @@ -55,8 +55,8 @@ FORCEINLINE ULONG HashStringIgnoreCase( } BOOLEAN NTAPI ObjectDbCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PDB_OBJECT object1 = *(PDB_OBJECT *)Entry1; @@ -66,7 +66,7 @@ BOOLEAN NTAPI ObjectDbCompareFunction( } ULONG NTAPI ObjectDbHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { PDB_OBJECT object = *(PDB_OBJECT *)Entry; @@ -96,8 +96,8 @@ VOID UnlockDb( } PDB_OBJECT FindDbObject( - __in ULONG Tag, - __in PPH_STRINGREF Name + _In_ ULONG Tag, + _In_ PPH_STRINGREF Name ) { DB_OBJECT lookupObject; @@ -117,9 +117,9 @@ PDB_OBJECT FindDbObject( } PDB_OBJECT CreateDbObject( - __in ULONG Tag, - __in PPH_STRINGREF Name, - __in_opt PPH_STRING Comment + _In_ ULONG Tag, + _In_ PPH_STRINGREF Name, + _In_opt_ PPH_STRING Comment ) { PDB_OBJECT object; @@ -161,7 +161,7 @@ PDB_OBJECT CreateDbObject( } VOID DeleteDbObject( - __in PDB_OBJECT Object + _In_ PDB_OBJECT Object ) { PhRemoveEntryHashtable(ObjectDb, &Object); @@ -172,21 +172,21 @@ VOID DeleteDbObject( } VOID SetDbPath( - __in PPH_STRING Path + _In_ PPH_STRING Path ) { PhSwapReference(&ObjectDbPath, Path); } mxml_type_t MxmlLoadCallback( - __in mxml_node_t *node + _In_ mxml_node_t *node ) { return MXML_OPAQUE; } PPH_STRING GetOpaqueXmlNodeText( - __in mxml_node_t *node + _In_ mxml_node_t *node ) { if (node->child && node->child->type == MXML_OPAQUE && node->child->value.opaque) @@ -301,8 +301,8 @@ NTSTATUS LoadDb( } char *MxmlSaveCallback( - __in mxml_node_t *node, - __in int position + _In_ mxml_node_t *node, + _In_ int position ) { if (STR_IEQUAL(node->value.element.name, "object")) @@ -322,11 +322,11 @@ char *MxmlSaveCallback( } mxml_node_t *CreateObjectElement( - __inout mxml_node_t *ParentNode, - __in PPH_STRINGREF Tag, - __in PPH_STRINGREF Name, - __in PPH_STRINGREF PriorityClass, - __in PPH_STRINGREF Comment + _Inout_ mxml_node_t *ParentNode, + _In_ PPH_STRINGREF Tag, + _In_ PPH_STRINGREF Name, + _In_ PPH_STRINGREF PriorityClass, + _In_ PPH_STRINGREF Comment ) { mxml_node_t *objectNode; diff --git a/2.x/trunk/plugins/UserNotes/db.h b/2.x/trunk/plugins/UserNotes/db.h index a6ee4b361..e6588c36e 100644 --- a/2.x/trunk/plugins/UserNotes/db.h +++ b/2.x/trunk/plugins/UserNotes/db.h @@ -32,22 +32,22 @@ VOID UnlockDb( ); PDB_OBJECT FindDbObject( - __in ULONG Tag, - __in PPH_STRINGREF Name + _In_ ULONG Tag, + _In_ PPH_STRINGREF Name ); PDB_OBJECT CreateDbObject( - __in ULONG Tag, - __in PPH_STRINGREF Name, - __in_opt PPH_STRING Comment + _In_ ULONG Tag, + _In_ PPH_STRINGREF Name, + _In_opt_ PPH_STRING Comment ); VOID DeleteDbObject( - __in PDB_OBJECT Object + _In_ PDB_OBJECT Object ); VOID SetDbPath( - __in PPH_STRING Path + _In_ PPH_STRING Path ); NTSTATUS LoadDb( diff --git a/2.x/trunk/plugins/UserNotes/main.c b/2.x/trunk/plugins/UserNotes/main.c index f196cd092..bfe229c33 100644 --- a/2.x/trunk/plugins/UserNotes/main.c +++ b/2.x/trunk/plugins/UserNotes/main.c @@ -39,33 +39,33 @@ typedef struct _SERVICE_COMMENT_PAGE_CONTEXT } SERVICE_COMMENT_PAGE_CONTEXT, *PSERVICE_COMMENT_PAGE_CONTEXT; INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK ProcessCommentPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK ServiceCommentPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); LRESULT CALLBACK MainWndSubclassProc( - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __in UINT_PTR uIdSubclass, - __in DWORD_PTR dwRefData + _In_ HWND hWnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ UINT_PTR uIdSubclass, + _In_ DWORD_PTR dwRefData ); PPH_PLUGIN PluginInstance; @@ -92,8 +92,8 @@ LIST_ENTRY ServiceListHead = { &ServiceListHead, &ServiceListHead }; PH_QUEUED_LOCK ServiceListLock = PH_QUEUED_LOCK_INIT; BOOLEAN MatchDbObjectIntent( - __in PDB_OBJECT Object, - __in ULONG Intent + _In_ PDB_OBJECT Object, + _In_ ULONG Intent ) { return (!(Intent & INTENT_PROCESS_COMMENT) || Object->Comment->Length != 0) && @@ -101,8 +101,8 @@ BOOLEAN MatchDbObjectIntent( } PDB_OBJECT FindDbObjectForProcess( - __in PPH_PROCESS_ITEM ProcessItem, - __in ULONG Intent + _In_ PPH_PROCESS_ITEM ProcessItem, + _In_ ULONG Intent ) { PDB_OBJECT object; @@ -120,7 +120,7 @@ PDB_OBJECT FindDbObjectForProcess( } VOID DeleteDbObjectForProcessIfUnused( - __in PDB_OBJECT Object + _In_ PDB_OBJECT Object ) { if (Object->Comment->Length == 0 && Object->PriorityClass == 0) @@ -130,8 +130,8 @@ VOID DeleteDbObjectForProcessIfUnused( } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_STRING path; @@ -160,16 +160,16 @@ VOID NTAPI LoadCallback( } VOID NTAPI UnloadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { SaveDb(); } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { DialogBox( @@ -181,8 +181,8 @@ VOID NTAPI ShowOptionsCallback( } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; @@ -263,8 +263,8 @@ VOID InvalidateProcessComments( } VOID UpdateProcessComment( - __in PPH_PROCESS_NODE Node, - __in PPROCESS_EXTENSION Extension + _In_ PPH_PROCESS_NODE Node, + _In_ PPROCESS_EXTENSION Extension ) { if (!Extension->Valid) @@ -313,8 +313,8 @@ VOID InvalidateServiceComments( } VOID UpdateServiceComment( - __in PPH_SERVICE_NODE Node, - __in PSERVICE_EXTENSION Extension + _In_ PPH_SERVICE_NODE Node, + _In_ PSERVICE_EXTENSION Extension ) { if (!Extension->Valid) @@ -339,8 +339,8 @@ VOID UpdateServiceComment( } VOID TreeNewMessageCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_TREENEW_MESSAGE message = Parameter; @@ -395,16 +395,16 @@ VOID TreeNewMessageCallback( } VOID MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { SetWindowSubclass(PhMainWndHandle, MainWndSubclassProc, 0, 0); } VOID ProcessPropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_PROCESS_PROPCONTEXT propContext = Parameter; @@ -416,8 +416,8 @@ VOID ProcessPropertiesInitializingCallback( } VOID ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; @@ -451,10 +451,10 @@ VOID ProcessMenuInitializingCallback( } LONG NTAPI ProcessCommentSortFunction( - __in PVOID Node1, - __in PVOID Node2, - __in ULONG SubId, - __in PVOID Context + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ ULONG SubId, + _In_ PVOID Context ) { PPH_PROCESS_NODE node1 = Node1; @@ -469,8 +469,8 @@ LONG NTAPI ProcessCommentSortFunction( } VOID ProcessTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_TREENEW_INFORMATION info = Parameter; @@ -487,8 +487,8 @@ VOID ProcessTreeNewInitializingCallback( } VOID ServicePropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_OBJECT_PROPERTIES objectProperties = Parameter; @@ -509,10 +509,10 @@ VOID ServicePropertiesInitializingCallback( } LONG NTAPI ServiceCommentSortFunction( - __in PVOID Node1, - __in PVOID Node2, - __in ULONG SubId, - __in PVOID Context + _In_ PVOID Node1, + _In_ PVOID Node2, + _In_ ULONG SubId, + _In_ PVOID Context ) { PPH_SERVICE_NODE node1 = Node1; @@ -527,8 +527,8 @@ LONG NTAPI ServiceCommentSortFunction( } VOID ServiceTreeNewInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_TREENEW_INFORMATION info = Parameter; @@ -545,8 +545,8 @@ VOID ServiceTreeNewInitializingCallback( } VOID ProcessModifiedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PROCESS_ITEM processItem = Parameter; @@ -556,8 +556,8 @@ VOID ProcessModifiedCallback( } VOID ProcessesUpdatedCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PLIST_ENTRY listEntry; @@ -606,9 +606,9 @@ VOID ProcessesUpdatedCallback( } VOID ProcessItemCreateCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { PPH_PROCESS_ITEM processItem = Object; @@ -623,9 +623,9 @@ VOID ProcessItemCreateCallback( } VOID ProcessItemDeleteCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { PPH_PROCESS_ITEM processItem = Object; @@ -638,9 +638,9 @@ VOID ProcessItemDeleteCallback( } VOID ServiceItemCreateCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { PPH_SERVICE_ITEM processItem = Object; @@ -653,9 +653,9 @@ VOID ServiceItemCreateCallback( } VOID ServiceItemDeleteCallback( - __in PVOID Object, - __in PH_EM_OBJECT_TYPE ObjectType, - __in PVOID Extension + _In_ PVOID Object, + _In_ PH_EM_OBJECT_TYPE ObjectType, + _In_ PVOID Extension ) { PPH_SERVICE_ITEM processItem = Object; @@ -668,9 +668,9 @@ VOID ServiceItemDeleteCallback( } LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { if (Reason == DLL_PROCESS_ATTACH) @@ -735,10 +735,10 @@ LOGICAL DllMain( } INT_PTR CALLBACK OptionsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -803,10 +803,10 @@ INT_PTR CALLBACK OptionsDlgProc( } INT_PTR CALLBACK ProcessCommentPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; @@ -988,10 +988,10 @@ INT_PTR CALLBACK ProcessCommentPageDlgProc( } INT_PTR CALLBACK ServiceCommentPageDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PSERVICE_COMMENT_PAGE_CONTEXT context; @@ -1123,7 +1123,7 @@ INT_PTR CALLBACK ServiceCommentPageDlgProc( } ULONG GetPriorityClassFromId( - __in ULONG Id + _In_ ULONG Id ) { switch (Id) @@ -1146,12 +1146,12 @@ ULONG GetPriorityClassFromId( } LRESULT CALLBACK MainWndSubclassProc( - __in HWND hWnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam, - __in UINT_PTR uIdSubclass, - __in DWORD_PTR dwRefData + _In_ HWND hWnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam, + _In_ UINT_PTR uIdSubclass, + _In_ DWORD_PTR dwRefData ) { switch (uMsg) diff --git a/2.x/trunk/plugins/WindowExplorer/WindowExplorer.vcxproj b/2.x/trunk/plugins/WindowExplorer/WindowExplorer.vcxproj index 05396c882..ee1ee972d 100644 --- a/2.x/trunk/plugins/WindowExplorer/WindowExplorer.vcxproj +++ b/2.x/trunk/plugins/WindowExplorer/WindowExplorer.vcxproj @@ -67,7 +67,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\plugins\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true diff --git a/2.x/trunk/plugins/WindowExplorer/hook.c b/2.x/trunk/plugins/WindowExplorer/hook.c index 04a559950..75d6861b8 100644 --- a/2.x/trunk/plugins/WindowExplorer/hook.c +++ b/2.x/trunk/plugins/WindowExplorer/hook.c @@ -45,13 +45,13 @@ VOID WepCloseServerObjects( ); VOID WepWriteClientData( - __in HWND hwnd + _In_ HWND hwnd ); LRESULT CALLBACK WepCallWndProc( - __in int nCode, - __in WPARAM wParam, - __in LPARAM lParam + _In_ int nCode, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); // Shared @@ -358,7 +358,7 @@ BOOLEAN WeIsServerActive( } BOOLEAN WeLockServerSharedData( - __out PWE_HOOK_SHARED_DATA *Data + _Out_ PWE_HOOK_SHARED_DATA *Data ) { LARGE_INTEGER timeout; @@ -384,7 +384,7 @@ VOID WeUnlockServerSharedData( } BOOLEAN WeSendServerRequest( - __in HWND hWnd + _In_ HWND hWnd ) { ULONG threadId; @@ -437,7 +437,7 @@ VOID WeHookClientUninitialization( } VOID WepWriteClientData( - __in HWND hwnd + _In_ HWND hwnd ) { WCHAR className[256]; @@ -470,9 +470,9 @@ VOID WepWriteClientData( } LRESULT CALLBACK WepCallWndProc( - __in int nCode, - __in WPARAM wParam, - __in LPARAM lParam + _In_ int nCode, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { LRESULT result; diff --git a/2.x/trunk/plugins/WindowExplorer/main.c b/2.x/trunk/plugins/WindowExplorer/main.c index 826959906..d55ec74c6 100644 --- a/2.x/trunk/plugins/WindowExplorer/main.c +++ b/2.x/trunk/plugins/WindowExplorer/main.c @@ -24,43 +24,43 @@ #include "resource.h" VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI UnloadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessPropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); VOID NTAPI ThreadMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ); BOOLEAN IsHookClient; @@ -75,9 +75,9 @@ PH_CALLBACK_REGISTRATION ProcessMenuInitializingCallbackRegistration; PH_CALLBACK_REGISTRATION ThreadMenuInitializingCallbackRegistration; LOGICAL DllMain( - __in HINSTANCE Instance, - __in ULONG Reason, - __reserved PVOID Reserved + _In_ HINSTANCE Instance, + _In_ ULONG Reason, + _Reserved_ PVOID Reserved ) { switch (Reason) @@ -199,32 +199,32 @@ LOGICAL DllMain( } VOID NTAPI LoadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI UnloadCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { WeHookServerUninitialization(); } VOID NTAPI ShowOptionsCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } BOOL CALLBACK WepEnumDesktopProc( - __in LPTSTR lpszDesktop, - __in LPARAM lParam + _In_ LPTSTR lpszDesktop, + _In_ LPARAM lParam ) { PhAddItemList((PPH_LIST)lParam, PhaCreateString(lpszDesktop)->Buffer); @@ -233,8 +233,8 @@ BOOL CALLBACK WepEnumDesktopProc( } VOID NTAPI MenuItemCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_ITEM menuItem = Parameter; @@ -303,8 +303,8 @@ VOID NTAPI MenuItemCallback( } VOID NTAPI MainWindowShowingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PhPluginAddMenuItem(PluginInstance, PH_MENU_ITEM_LOCATION_VIEW, L"System Information", ID_VIEW_WINDOWS, L"Windows", NULL); @@ -314,16 +314,16 @@ VOID NTAPI MainWindowShowingCallback( } VOID NTAPI ProcessPropertiesInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { NOTHING; } VOID NTAPI ProcessMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; @@ -350,8 +350,8 @@ VOID NTAPI ProcessMenuInitializingCallback( } VOID NTAPI ThreadMenuInitializingCallback( - __in_opt PVOID Parameter, - __in_opt PVOID Context + _In_opt_ PVOID Parameter, + _In_opt_ PVOID Context ) { PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter; diff --git a/2.x/trunk/plugins/WindowExplorer/utils.c b/2.x/trunk/plugins/WindowExplorer/utils.c index 6ac76011b..89e2bc060 100644 --- a/2.x/trunk/plugins/WindowExplorer/utils.c +++ b/2.x/trunk/plugins/WindowExplorer/utils.c @@ -23,7 +23,7 @@ #include "wndexp.h" PVOID WeGetProcedureAddress( - __in PSTR Name + _In_ PSTR Name ) { static PVOID imageBase = NULL; @@ -35,9 +35,9 @@ PVOID WeGetProcedureAddress( } VOID WeFormatLocalObjectName( - __in PWSTR OriginalName, - __inout_ecount(256) PWCHAR Buffer, - __out PUNICODE_STRING ObjectName + _In_ PWSTR OriginalName, + _Inout_updates_(256) PWCHAR Buffer, + _Out_ PUNICODE_STRING ObjectName ) { SIZE_T length; @@ -63,7 +63,7 @@ VOID WeFormatLocalObjectName( } VOID WeInvertWindowBorder( - __in HWND hWnd + _In_ HWND hWnd ) { RECT rect; diff --git a/2.x/trunk/plugins/WindowExplorer/wnddlg.c b/2.x/trunk/plugins/WindowExplorer/wnddlg.c index 8e543215e..37d525a65 100644 --- a/2.x/trunk/plugins/WindowExplorer/wnddlg.c +++ b/2.x/trunk/plugins/WindowExplorer/wnddlg.c @@ -37,21 +37,21 @@ typedef struct _WINDOWS_CONTEXT } WINDOWS_CONTEXT, *PWINDOWS_CONTEXT; VOID WepShowWindowsDialogCallback( - __in PVOID Parameter + _In_ PVOID Parameter ); INT_PTR CALLBACK WepWindowsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); static RECT MinimumSize = { -1, -1, -1, -1 }; VOID WeShowWindowsDialog( - __in HWND ParentWindowHandle, - __in PWE_WINDOW_SELECTOR Selector + _In_ HWND ParentWindowHandle, + _In_ PWE_WINDOW_SELECTOR Selector ) { PWINDOWS_CONTEXT context; @@ -64,7 +64,7 @@ VOID WeShowWindowsDialog( } VOID WepShowWindowsDialogCallback( - __in PVOID Parameter + _In_ PVOID Parameter ) { HWND hwnd; @@ -81,7 +81,7 @@ VOID WepShowWindowsDialogCallback( } VOID WepDeleteWindowSelector( - __in PWE_WINDOW_SELECTOR Selector + _In_ PWE_WINDOW_SELECTOR Selector ) { switch (Selector->Type) @@ -93,7 +93,7 @@ VOID WepDeleteWindowSelector( } VOID WepFillWindowInfo( - __in PWE_WINDOW_NODE Node + _In_ PWE_WINDOW_NODE Node ) { HWND hwnd; @@ -117,9 +117,9 @@ VOID WepFillWindowInfo( } VOID WepAddChildWindowNode( - __in PWE_WINDOW_TREE_CONTEXT Context, - __in_opt PWE_WINDOW_NODE ParentNode, - __in HWND hwnd + _In_ PWE_WINDOW_TREE_CONTEXT Context, + _In_opt_ PWE_WINDOW_NODE ParentNode, + _In_ HWND hwnd ) { PWE_WINDOW_NODE childNode; @@ -144,11 +144,11 @@ VOID WepAddChildWindowNode( } VOID WepAddChildWindows( - __in PWINDOWS_CONTEXT Context, - __in_opt PWE_WINDOW_NODE ParentNode, - __in HWND hwnd, - __in_opt HANDLE FilterProcessId, - __in_opt HANDLE FilterThreadId + _In_ PWINDOWS_CONTEXT Context, + _In_opt_ PWE_WINDOW_NODE ParentNode, + _In_ HWND hwnd, + _In_opt_ HANDLE FilterProcessId, + _In_opt_ HANDLE FilterThreadId ) { HWND childWindow = NULL; @@ -176,8 +176,8 @@ VOID WepAddChildWindows( } BOOL CALLBACK WepEnumDesktopWindowsProc( - __in HWND hwnd, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ LPARAM lParam ) { PWINDOWS_CONTEXT context = (PWINDOWS_CONTEXT)lParam; @@ -188,8 +188,8 @@ BOOL CALLBACK WepEnumDesktopWindowsProc( } VOID WepAddDesktopWindows( - __in PWINDOWS_CONTEXT Context, - __in PWSTR DesktopName + _In_ PWINDOWS_CONTEXT Context, + _In_ PWSTR DesktopName ) { HDESK desktopHandle; @@ -202,7 +202,7 @@ VOID WepAddDesktopWindows( } VOID WepRefreshWindows( - __in PWINDOWS_CONTEXT Context + _In_ PWINDOWS_CONTEXT Context ) { TreeNew_SetRedraw(Context->TreeNewHandle, FALSE); @@ -248,7 +248,7 @@ VOID WepRefreshWindows( } PPH_STRING WepGetWindowTitleForSelector( - __in PWE_WINDOW_SELECTOR Selector + _In_ PWE_WINDOW_SELECTOR Selector ) { PPH_STRING title; @@ -290,10 +290,10 @@ PPH_STRING WepGetWindowTitleForSelector( } INT_PTR CALLBACK WepWindowsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PWINDOWS_CONTEXT context; diff --git a/2.x/trunk/plugins/WindowExplorer/wndexp.h b/2.x/trunk/plugins/WindowExplorer/wndexp.h index 0c9e8e766..f7cdfce3f 100644 --- a/2.x/trunk/plugins/WindowExplorer/wndexp.h +++ b/2.x/trunk/plugins/WindowExplorer/wndexp.h @@ -46,7 +46,7 @@ BOOLEAN WeIsServerActive( ); BOOLEAN WeLockServerSharedData( - __out PWE_HOOK_SHARED_DATA *Data + _Out_ PWE_HOOK_SHARED_DATA *Data ); VOID WeUnlockServerSharedData( @@ -54,7 +54,7 @@ VOID WeUnlockServerSharedData( ); BOOLEAN WeSendServerRequest( - __in HWND hWnd + _In_ HWND hWnd ); VOID WeHookClientInitialization( @@ -96,8 +96,8 @@ typedef struct _WE_WINDOW_SELECTOR } WE_WINDOW_SELECTOR, *PWE_WINDOW_SELECTOR; VOID WeShowWindowsDialog( - __in HWND ParentWindowHandle, - __in PWE_WINDOW_SELECTOR Selector + _In_ HWND ParentWindowHandle, + _In_ PWE_WINDOW_SELECTOR Selector ); #define WM_WE_PLUSMINUS (WM_APP + 1) @@ -105,8 +105,8 @@ VOID WeShowWindowsDialog( // wndprp VOID WeShowWindowProperties( - __in HWND ParentWindowHandle, - __in HWND WindowHandle + _In_ HWND ParentWindowHandle, + _In_ HWND WindowHandle ); // utils @@ -115,17 +115,17 @@ VOID WeShowWindowProperties( #define WE_WindowsVersion (*(ULONG *)WeGetProcedureAddress("WindowsVersion")) PVOID WeGetProcedureAddress( - __in PSTR Name + _In_ PSTR Name ); VOID WeFormatLocalObjectName( - __in PWSTR OriginalName, - __inout_ecount(256) PWCHAR Buffer, - __out PUNICODE_STRING ObjectName + _In_ PWSTR OriginalName, + _Inout_updates_(256) PWCHAR Buffer, + _Out_ PUNICODE_STRING ObjectName ); VOID WeInvertWindowBorder( - __in HWND hWnd + _In_ HWND hWnd ); #endif diff --git a/2.x/trunk/plugins/WindowExplorer/wndprp.c b/2.x/trunk/plugins/WindowExplorer/wndprp.c index 2c545e72c..f7a39b71d 100644 --- a/2.x/trunk/plugins/WindowExplorer/wndprp.c +++ b/2.x/trunk/plugins/WindowExplorer/wndprp.c @@ -75,72 +75,72 @@ typedef struct _STRING_INTEGER_PAIR } STRING_INTEGER_PAIR, *PSTRING_INTEGER_PAIR; VOID WepReferenceWindowPropertiesContext( - __inout PWINDOW_PROPERTIES_CONTEXT Context + _Inout_ PWINDOW_PROPERTIES_CONTEXT Context ); VOID WepDereferenceWindowPropertiesContext( - __inout PWINDOW_PROPERTIES_CONTEXT Context + _Inout_ PWINDOW_PROPERTIES_CONTEXT Context ); HWND WepCreateWindowProperties( - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ PWINDOW_PROPERTIES_CONTEXT Context ); INT CALLBACK WepPropSheetProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam ); LRESULT CALLBACK WepPropSheetWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); HPROPSHEETPAGE WepCommonCreatePage( - __in PWINDOW_PROPERTIES_CONTEXT Context, - __in PWSTR Template, - __in DLGPROC DlgProc + _In_ PWINDOW_PROPERTIES_CONTEXT Context, + _In_ PWSTR Template, + _In_ DLGPROC DlgProc ); INT CALLBACK WepCommonPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ); NTSTATUS WepPropertiesThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ); INT_PTR CALLBACK WepWindowGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK WepWindowStylesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK WepWindowClassDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK WepWindowPropertiesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); #define DEFINE_PAIR(Symbol) { L#Symbol, Symbol } @@ -217,8 +217,8 @@ PPH_LIST WePropertiesWindowList; PH_QUEUED_LOCK WePropertiesCreateLock = PH_QUEUED_LOCK_INIT; VOID WeShowWindowProperties( - __in HWND ParentWindowHandle, - __in HWND WindowHandle + _In_ HWND ParentWindowHandle, + _In_ HWND WindowHandle ) { PWINDOW_PROPERTIES_CONTEXT context; @@ -258,14 +258,14 @@ VOID WeShowWindowProperties( } VOID WepReferenceWindowPropertiesContext( - __inout PWINDOW_PROPERTIES_CONTEXT Context + _Inout_ PWINDOW_PROPERTIES_CONTEXT Context ) { _InterlockedIncrement(&Context->RefCount); } VOID WepDereferenceWindowPropertiesContext( - __inout PWINDOW_PROPERTIES_CONTEXT Context + _Inout_ PWINDOW_PROPERTIES_CONTEXT Context ) { if (_InterlockedDecrement(&Context->RefCount) == 0) @@ -298,7 +298,7 @@ VOID WepDereferenceWindowPropertiesContext( } static HWND WepCreateWindowProperties( - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { PROPSHEETHEADER propSheetHeader = { sizeof(propSheetHeader) }; @@ -346,9 +346,9 @@ static HWND WepCreateWindowProperties( } static INT CALLBACK WepPropSheetProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam ) { switch (uMsg) @@ -378,10 +378,10 @@ static INT CALLBACK WepPropSheetProc( } LRESULT CALLBACK WepPropSheetWndProc( - __in HWND hwnd, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { WNDPROC oldWndProc = (WNDPROC)GetProp(hwnd, L"OldWndProc"); @@ -435,9 +435,9 @@ LRESULT CALLBACK WepPropSheetWndProc( } static HPROPSHEETPAGE WepCommonCreatePage( - __in PWINDOW_PROPERTIES_CONTEXT Context, - __in PWSTR Template, - __in DLGPROC DlgProc + _In_ PWINDOW_PROPERTIES_CONTEXT Context, + _In_ PWSTR Template, + _In_ DLGPROC DlgProc ) { HPROPSHEETPAGE propSheetPageHandle; @@ -458,9 +458,9 @@ static HPROPSHEETPAGE WepCommonCreatePage( } static INT CALLBACK WepCommonPropPageProc( - __in HWND hwnd, - __in UINT uMsg, - __in LPPROPSHEETPAGE ppsp + _In_ HWND hwnd, + _In_ UINT uMsg, + _In_ LPPROPSHEETPAGE ppsp ) { PWINDOW_PROPERTIES_CONTEXT context; @@ -476,7 +476,7 @@ static INT CALLBACK WepCommonPropPageProc( } NTSTATUS WepPropertiesThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { PH_AUTO_POOL autoPool; @@ -554,11 +554,11 @@ NTSTATUS WepPropertiesThreadStart( } FORCEINLINE BOOLEAN WepPropPageDlgProcHeader( - __in HWND hwndDlg, - __in UINT uMsg, - __in LPARAM lParam, - __out_opt LPPROPSHEETPAGE *PropSheetPage, - __out_opt PWINDOW_PROPERTIES_CONTEXT *Context + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ LPARAM lParam, + _Out_opt_ LPPROPSHEETPAGE *PropSheetPage, + _Out_opt_ PWINDOW_PROPERTIES_CONTEXT *Context ) { LPPROPSHEETPAGE propSheetPage; @@ -589,7 +589,7 @@ FORCEINLINE BOOLEAN WepPropPageDlgProcHeader( } static VOID WepEnsureHookDataValid( - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { if (!Context->HookDataValid) @@ -641,8 +641,8 @@ static VOID WepEnsureHookDataValid( } static BOOLEAN NTAPI EnumGenericModulesCallback( - __in PPH_MODULE_INFO Module, - __in_opt PVOID Context + _In_ PPH_MODULE_INFO Module, + _In_opt_ PVOID Context ) { PWINDOW_PROPERTIES_CONTEXT context = Context; @@ -654,7 +654,7 @@ static BOOLEAN NTAPI EnumGenericModulesCallback( } static NTSTATUS WepResolveSymbolFunction( - __in PVOID Parameter + _In_ PVOID Parameter ) { PSYMBOL_RESOLVE_CONTEXT context = Parameter; @@ -694,10 +694,10 @@ static NTSTATUS WepResolveSymbolFunction( } static VOID WepQueueResolveSymbol( - __in PWINDOW_PROPERTIES_CONTEXT Context, - __in HWND NotifyWindow, - __in ULONG64 Address, - __in ULONG Id + _In_ PWINDOW_PROPERTIES_CONTEXT Context, + _In_ HWND NotifyWindow, + _In_ ULONG64 Address, + _In_ ULONG Id ) { PSYMBOL_RESOLVE_CONTEXT resolveContext; @@ -721,7 +721,7 @@ static VOID WepQueueResolveSymbol( } static PPH_STRING WepFormatRect( - __in PRECT Rect + _In_ PRECT Rect ) { return PhaFormatString(L"(%d, %d) - (%d, %d) [%dx%d]", @@ -730,8 +730,8 @@ static PPH_STRING WepFormatRect( } static VOID WepRefreshWindowGeneralInfoSymbols( - __in HWND hwndDlg, - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { if (Context->WndProcResolving != 0) @@ -756,8 +756,8 @@ static VOID WepRefreshWindowGeneralInfoSymbols( } static VOID WepRefreshWindowGeneralInfo( - __in HWND hwndDlg, - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { PPH_STRING windowText; @@ -825,10 +825,10 @@ static VOID WepRefreshWindowGeneralInfo( } INT_PTR CALLBACK WepWindowGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PWINDOW_PROPERTIES_CONTEXT context; @@ -897,8 +897,8 @@ INT_PTR CALLBACK WepWindowGeneralDlgProc( } static VOID WepRefreshWindowStyles( - __in HWND hwndDlg, - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { WINDOWINFO windowInfo = { sizeof(WINDOWINFO) }; @@ -957,10 +957,10 @@ static VOID WepRefreshWindowStyles( } INT_PTR CALLBACK WepWindowStylesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PWINDOW_PROPERTIES_CONTEXT context; @@ -991,8 +991,8 @@ INT_PTR CALLBACK WepWindowStylesDlgProc( } static VOID WepRefreshWindowClassInfoSymbols( - __in HWND hwndDlg, - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { if (Context->ClassWndProcResolving != 0) @@ -1006,8 +1006,8 @@ static VOID WepRefreshWindowClassInfoSymbols( } static VOID WepRefreshWindowClassInfo( - __in HWND hwndDlg, - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ HWND hwndDlg, + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { WCHAR className[256]; @@ -1072,10 +1072,10 @@ static VOID WepRefreshWindowClassInfo( } INT_PTR CALLBACK WepWindowClassDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PWINDOW_PROPERTIES_CONTEXT context; @@ -1126,10 +1126,10 @@ INT_PTR CALLBACK WepWindowClassDlgProc( } static BOOL CALLBACK EnumPropsExCallback( - __in HWND hwnd, - __in LPTSTR lpszString, - __in HANDLE hData, - __in ULONG_PTR dwData + _In_ HWND hwnd, + _In_ LPTSTR lpszString, + _In_ HANDLE hData, + _In_ ULONG_PTR dwData ) { INT lvItemIndex; @@ -1153,9 +1153,9 @@ static BOOL CALLBACK EnumPropsExCallback( } static VOID WepRefreshWindowProps( - __in HWND hwndDlg, - __in HWND ListViewHandle, - __in PWINDOW_PROPERTIES_CONTEXT Context + _In_ HWND hwndDlg, + _In_ HWND ListViewHandle, + _In_ PWINDOW_PROPERTIES_CONTEXT Context ) { ExtendedListView_SetRedraw(ListViewHandle, FALSE); @@ -1166,10 +1166,10 @@ static VOID WepRefreshWindowProps( } INT_PTR CALLBACK WepWindowPropertiesDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { PWINDOW_PROPERTIES_CONTEXT context; diff --git a/2.x/trunk/plugins/WindowExplorer/wndtree.c b/2.x/trunk/plugins/WindowExplorer/wndtree.c index 73e118267..346c41530 100644 --- a/2.x/trunk/plugins/WindowExplorer/wndtree.c +++ b/2.x/trunk/plugins/WindowExplorer/wndtree.c @@ -25,30 +25,30 @@ #include "resource.h" BOOLEAN WepWindowNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ); ULONG WepWindowNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ); VOID WepDestroyWindowNode( - __in PWE_WINDOW_NODE WindowNode + _In_ PWE_WINDOW_NODE WindowNode ); BOOLEAN NTAPI WepWindowTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ); VOID WeInitializeWindowTree( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __out PWE_WINDOW_TREE_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _Out_ PWE_WINDOW_TREE_CONTEXT Context ) { HWND hwnd; @@ -86,7 +86,7 @@ VOID WeInitializeWindowTree( } VOID WeDeleteWindowTree( - __in PWE_WINDOW_TREE_CONTEXT Context + _In_ PWE_WINDOW_TREE_CONTEXT Context ) { PPH_STRING settings; @@ -105,8 +105,8 @@ VOID WeDeleteWindowTree( } BOOLEAN WepWindowNodeHashtableCompareFunction( - __in PVOID Entry1, - __in PVOID Entry2 + _In_ PVOID Entry1, + _In_ PVOID Entry2 ) { PWE_WINDOW_NODE windowNode1 = *(PWE_WINDOW_NODE *)Entry1; @@ -116,7 +116,7 @@ BOOLEAN WepWindowNodeHashtableCompareFunction( } ULONG WepWindowNodeHashtableHashFunction( - __in PVOID Entry + _In_ PVOID Entry ) { #ifdef _M_IX86 @@ -127,7 +127,7 @@ ULONG WepWindowNodeHashtableHashFunction( } PWE_WINDOW_NODE WeAddWindowNode( - __inout PWE_WINDOW_TREE_CONTEXT Context + _Inout_ PWE_WINDOW_TREE_CONTEXT Context ) { PWE_WINDOW_NODE windowNode; @@ -151,8 +151,8 @@ PWE_WINDOW_NODE WeAddWindowNode( } PWE_WINDOW_NODE WeFindWindowNode( - __in PWE_WINDOW_TREE_CONTEXT Context, - __in HWND WindowHandle + _In_ PWE_WINDOW_TREE_CONTEXT Context, + _In_ HWND WindowHandle ) { WE_WINDOW_NODE lookupWindowNode; @@ -173,8 +173,8 @@ PWE_WINDOW_NODE WeFindWindowNode( } VOID WeRemoveWindowNode( - __in PWE_WINDOW_TREE_CONTEXT Context, - __in PWE_WINDOW_NODE WindowNode + _In_ PWE_WINDOW_TREE_CONTEXT Context, + _In_ PWE_WINDOW_NODE WindowNode ) { ULONG index; @@ -192,7 +192,7 @@ VOID WeRemoveWindowNode( } VOID WepDestroyWindowNode( - __in PWE_WINDOW_NODE WindowNode + _In_ PWE_WINDOW_NODE WindowNode ) { PhDereferenceObject(WindowNode->Children); @@ -207,9 +207,9 @@ VOID WepDestroyWindowNode( #define SORT_FUNCTION(Column) WepWindowTreeNewCompare##Column #define BEGIN_SORT_FUNCTION(Column) static int __cdecl WepWindowTreeNewCompare##Column( \ - __in void *_context, \ - __in const void *_elem1, \ - __in const void *_elem2 \ + _In_ void *_context, \ + _In_ const void *_elem1, \ + _In_ const void *_elem2 \ ) \ { \ PWE_WINDOW_NODE node1 = *(PWE_WINDOW_NODE *)_elem1; \ @@ -248,11 +248,11 @@ BEGIN_SORT_FUNCTION(Thread) END_SORT_FUNCTION BOOLEAN NTAPI WepWindowTreeNewCallback( - __in HWND hwnd, - __in PH_TREENEW_MESSAGE Message, - __in_opt PVOID Parameter1, - __in_opt PVOID Parameter2, - __in_opt PVOID Context + _In_ HWND hwnd, + _In_ PH_TREENEW_MESSAGE Message, + _In_opt_ PVOID Parameter1, + _In_opt_ PVOID Parameter2, + _In_opt_ PVOID Context ) { PWE_WINDOW_TREE_CONTEXT context; @@ -407,7 +407,7 @@ BOOLEAN NTAPI WepWindowTreeNewCallback( } VOID WeClearWindowTree( - __in PWE_WINDOW_TREE_CONTEXT Context + _In_ PWE_WINDOW_TREE_CONTEXT Context ) { ULONG i; @@ -421,7 +421,7 @@ VOID WeClearWindowTree( } PWE_WINDOW_NODE WeGetSelectedWindowNode( - __in PWE_WINDOW_TREE_CONTEXT Context + _In_ PWE_WINDOW_TREE_CONTEXT Context ) { PWE_WINDOW_NODE windowNode = NULL; @@ -439,9 +439,9 @@ PWE_WINDOW_NODE WeGetSelectedWindowNode( } VOID WeGetSelectedWindowNodes( - __in PWE_WINDOW_TREE_CONTEXT Context, - __out PWE_WINDOW_NODE **Windows, - __out PULONG NumberOfWindows + _In_ PWE_WINDOW_TREE_CONTEXT Context, + _Out_ PWE_WINDOW_NODE **Windows, + _Out_ PULONG NumberOfWindows ) { PPH_LIST list; diff --git a/2.x/trunk/plugins/WindowExplorer/wndtree.h b/2.x/trunk/plugins/WindowExplorer/wndtree.h index 65740af07..856ef1a1b 100644 --- a/2.x/trunk/plugins/WindowExplorer/wndtree.h +++ b/2.x/trunk/plugins/WindowExplorer/wndtree.h @@ -41,41 +41,41 @@ typedef struct _WE_WINDOW_TREE_CONTEXT } WE_WINDOW_TREE_CONTEXT, *PWE_WINDOW_TREE_CONTEXT; VOID WeInitializeWindowTree( - __in HWND ParentWindowHandle, - __in HWND TreeNewHandle, - __out PWE_WINDOW_TREE_CONTEXT Context + _In_ HWND ParentWindowHandle, + _In_ HWND TreeNewHandle, + _Out_ PWE_WINDOW_TREE_CONTEXT Context ); VOID WeDeleteWindowTree( - __in PWE_WINDOW_TREE_CONTEXT Context + _In_ PWE_WINDOW_TREE_CONTEXT Context ); PWE_WINDOW_NODE WeAddWindowNode( - __inout PWE_WINDOW_TREE_CONTEXT Context + _Inout_ PWE_WINDOW_TREE_CONTEXT Context ); PWE_WINDOW_NODE WeFindWindowNode( - __in PWE_WINDOW_TREE_CONTEXT Context, - __in HWND WindowHandle + _In_ PWE_WINDOW_TREE_CONTEXT Context, + _In_ HWND WindowHandle ); VOID WeRemoveWindowNode( - __in PWE_WINDOW_TREE_CONTEXT Context, - __in PWE_WINDOW_NODE WindowNode + _In_ PWE_WINDOW_TREE_CONTEXT Context, + _In_ PWE_WINDOW_NODE WindowNode ); VOID WeClearWindowTree( - __in PWE_WINDOW_TREE_CONTEXT Context + _In_ PWE_WINDOW_TREE_CONTEXT Context ); PWE_WINDOW_NODE WeGetSelectedWindowNode( - __in PWE_WINDOW_TREE_CONTEXT Context + _In_ PWE_WINDOW_TREE_CONTEXT Context ); VOID WeGetSelectedWindowNodes( - __in PWE_WINDOW_TREE_CONTEXT Context, - __out PWE_WINDOW_NODE **Windows, - __out PULONG NumberOfWindows + _In_ PWE_WINDOW_TREE_CONTEXT Context, + _Out_ PWE_WINDOW_NODE **Windows, + _Out_ PULONG NumberOfWindows ); #endif diff --git a/2.x/trunk/tests/phlib-test/phlib-test.vcxproj b/2.x/trunk/tests/phlib-test/phlib-test.vcxproj index 6735022be..2a73ce043 100644 --- a/2.x/trunk/tests/phlib-test/phlib-test.vcxproj +++ b/2.x/trunk/tests/phlib-test/phlib-test.vcxproj @@ -38,7 +38,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(ProjectDir)bin\$(Configuration)\ $(ProjectDir)obj\$(Configuration)\ true @@ -65,7 +64,7 @@ true Console MachineX86 - /SUBSYSTEM:CONSOLE,5.01 %(AdditionalOptions) + 5.01 @@ -91,7 +90,7 @@ true MachineX86 true - /SUBSYSTEM:CONSOLE,5.01 %(AdditionalOptions) + 5.01 diff --git a/2.x/trunk/tests/phlib-test/phlib-test.vcxproj.filters b/2.x/trunk/tests/phlib-test/phlib-test.vcxproj.filters index 273a566f0..3d15d25f5 100644 --- a/2.x/trunk/tests/phlib-test/phlib-test.vcxproj.filters +++ b/2.x/trunk/tests/phlib-test/phlib-test.vcxproj.filters @@ -9,10 +9,6 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - diff --git a/2.x/trunk/tests/phlib-test/t_support.c b/2.x/trunk/tests/phlib-test/t_support.c index 479027f2f..d739a5cf9 100644 --- a/2.x/trunk/tests/phlib-test/t_support.c +++ b/2.x/trunk/tests/phlib-test/t_support.c @@ -30,8 +30,8 @@ static VOID Test_rectangle( } static BOOLEAN AreGuidsEqual( - __in PGUID Guid1, - __in PWSTR Guid2 + _In_ PGUID Guid1, + _In_ PWSTR Guid2 ) { GUID guid2; diff --git a/2.x/trunk/tools/GenerateZw/GenerateZw.sln b/2.x/trunk/tools/GenerateZw/GenerateZw.sln index 489afaf62..dcf933149 100644 --- a/2.x/trunk/tools/GenerateZw/GenerateZw.sln +++ b/2.x/trunk/tools/GenerateZw/GenerateZw.sln @@ -1,6 +1,6 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerateZw", "GenerateZw\GenerateZw.csproj", "{10589240-84D9-4935-9868-7FFADB6545F9}" EndProject Global diff --git a/2.x/trunk/tools/fiin/fiin.vcxproj b/2.x/trunk/tools/fiin/fiin.vcxproj index f092a6f7c..9ef97951b 100644 --- a/2.x/trunk/tools/fiin/fiin.vcxproj +++ b/2.x/trunk/tools/fiin/fiin.vcxproj @@ -63,7 +63,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(ProjectDir)bin\$(Configuration)$(PlatformArchitecture)\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true @@ -95,13 +94,10 @@ true Console MachineX86 - /SUBSYSTEM:CONSOLE,5.01 %(AdditionalOptions) + 5.01 - - X64 - Disabled ../../phlib/include;include;%(AdditionalIncludeDirectories) @@ -119,6 +115,7 @@ true Console MachineX64 + 5.02 @@ -143,13 +140,10 @@ true MachineX86 true - /SUBSYSTEM:CONSOLE,5.01 %(AdditionalOptions) + 5.01 - - X64 - MaxSpeed true @@ -171,6 +165,7 @@ true MachineX64 true + 5.02 diff --git a/2.x/trunk/tools/fiin/main.c b/2.x/trunk/tools/fiin/main.c index 7c3f4b8b1..e7e594d64 100644 --- a/2.x/trunk/tools/fiin/main.c +++ b/2.x/trunk/tools/fiin/main.c @@ -53,9 +53,9 @@ ULONG64 FipDirTotalSize; ULONG64 FipDirTotalAllocSize; static BOOLEAN NTAPI FiCommandLineCallback( - __in_opt PPH_COMMAND_LINE_OPTION Option, - __in_opt PPH_STRING Value, - __in_opt PVOID Context + _In_opt_ PPH_COMMAND_LINE_OPTION Option, + _In_opt_ PPH_STRING Value, + _In_opt_ PVOID Context ) { if (Option) @@ -129,7 +129,7 @@ VOID FiPrintHelp( } PPH_STRING FiFormatFileName( - __in PPH_STRING FileName + _In_ PPH_STRING FileName ) { if (!FiArgNative) @@ -200,13 +200,13 @@ PPH_STRING FiFormatFileName( } BOOLEAN FiCreateFile( - __out PHANDLE FileHandle, - __in ACCESS_MASK DesiredAccess, - __in PPH_STRING FileName, - __in_opt ULONG FileAttributes, - __in ULONG ShareAccess, - __in ULONG CreateDisposition, - __in_opt ULONG Options + _Out_ PHANDLE FileHandle, + _In_ ACCESS_MASK DesiredAccess, + _In_ PPH_STRING FileName, + _In_opt_ ULONG FileAttributes, + _In_ ULONG ShareAccess, + _In_ ULONG CreateDisposition, + _In_opt_ ULONG Options ) { NTSTATUS status; @@ -285,8 +285,8 @@ BOOLEAN FiCreateFile( } BOOLEAN NTAPI FipEnumDirectoryFileForDir( - __in PFILE_DIRECTORY_INFORMATION Information, - __in_opt PVOID Context + _In_ PFILE_DIRECTORY_INFORMATION Information, + _In_opt_ PVOID Context ) { PPH_STRING date, time, size; diff --git a/2.x/trunk/tools/fixlib/fixlib.c b/2.x/trunk/tools/fixlib/fixlib.c index 8f2e6003f..9bae4b0a0 100644 --- a/2.x/trunk/tools/fixlib/fixlib.c +++ b/2.x/trunk/tools/fixlib/fixlib.c @@ -6,9 +6,9 @@ PPH_STRING inFile = NULL; PPH_STRING outFile = NULL; BOOLEAN NTAPI CommandLineCallback( - __in_opt PPH_COMMAND_LINE_OPTION Option, - __in_opt PPH_STRING Value, - __in_opt PVOID Context + _In_opt_ PPH_COMMAND_LINE_OPTION Option, + _In_opt_ PPH_STRING Value, + _In_opt_ PVOID Context ) { if (Option) @@ -45,7 +45,7 @@ int __cdecl main(int argc, char *argv[]) if (!NT_SUCCESS(PhInitializePhLib())) return 1; - commandLine.us = NtCurrentPeb()->ProcessParameters->CommandLine; + PhUnicodeStringToStringRef(&NtCurrentPeb()->ProcessParameters->CommandLine, &commandLine); if (!PhParseCommandLine( &commandLine, diff --git a/2.x/trunk/tools/fixlib/fixlib.vcxproj b/2.x/trunk/tools/fixlib/fixlib.vcxproj index 82e47b888..73fdc3a0a 100644 --- a/2.x/trunk/tools/fixlib/fixlib.vcxproj +++ b/2.x/trunk/tools/fixlib/fixlib.vcxproj @@ -38,7 +38,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(ProjectDir)bin\$(Configuration)\ $(ProjectDir)obj\$(Configuration)\ true @@ -64,7 +63,7 @@ true Console MachineX86 - /SUBSYSTEM:CONSOLE,5.01 %(AdditionalOptions) + 5.01 @@ -89,7 +88,7 @@ true MachineX86 true - /SUBSYSTEM:CONSOLE,5.01 %(AdditionalOptions) + 5.01 diff --git a/2.x/trunk/tools/fixlib/fixlib.vcxproj.filters b/2.x/trunk/tools/fixlib/fixlib.vcxproj.filters index d34a8e5b8..397708432 100644 --- a/2.x/trunk/tools/fixlib/fixlib.vcxproj.filters +++ b/2.x/trunk/tools/fixlib/fixlib.vcxproj.filters @@ -5,14 +5,6 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - diff --git a/2.x/trunk/tools/peview/include/peview.h b/2.x/trunk/tools/peview/include/peview.h index 31f487c63..717acc808 100644 --- a/2.x/trunk/tools/peview/include/peview.h +++ b/2.x/trunk/tools/peview/include/peview.h @@ -24,16 +24,16 @@ VOID PvLibProperties( // misc PPH_STRING PvResolveShortcutTarget( - __in PPH_STRING ShortcutFileName + _In_ PPH_STRING ShortcutFileName ); VOID PvCopyListView( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ); VOID PvHandleListViewNotifyForCopy( - __in LPARAM lParam, - __in HWND ListViewHandle + _In_ LPARAM lParam, + _In_ HWND ListViewHandle ); #endif diff --git a/2.x/trunk/tools/peview/libprp.c b/2.x/trunk/tools/peview/libprp.c index 111d6bed0..6d07d08dd 100644 --- a/2.x/trunk/tools/peview/libprp.c +++ b/2.x/trunk/tools/peview/libprp.c @@ -23,10 +23,10 @@ #include INT_PTR CALLBACK PvpLibExportsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); PH_MAPPED_ARCHIVE PvMappedArchive; @@ -71,10 +71,10 @@ VOID PvLibProperties( } INT_PTR CALLBACK PvpLibExportsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/tools/peview/main.c b/2.x/trunk/tools/peview/main.c index a19a1a9eb..74fc72eb6 100644 --- a/2.x/trunk/tools/peview/main.c +++ b/2.x/trunk/tools/peview/main.c @@ -26,9 +26,9 @@ PPH_STRING PvFileName = NULL; static BOOLEAN NTAPI PvCommandLineCallback( - __in_opt PPH_COMMAND_LINE_OPTION Option, - __in_opt PPH_STRING Value, - __in_opt PVOID Context + _In_opt_ PPH_COMMAND_LINE_OPTION Option, + _In_opt_ PPH_STRING Value, + _In_opt_ PVOID Context ) { if (!Option) @@ -37,11 +37,11 @@ static BOOLEAN NTAPI PvCommandLineCallback( return TRUE; } -INT WINAPI WinMain( - __in HINSTANCE hInstance, - __in_opt HINSTANCE hPrevInstance, - __in LPSTR lpCmdLine, - __in INT nCmdShow +INT WINAPI wWinMain( + _In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ PWSTR lpCmdLine, + _In_ INT nCmdShow ) { static PH_COMMAND_LINE_OPTION options[] = diff --git a/2.x/trunk/tools/peview/misc.c b/2.x/trunk/tools/peview/misc.c index 516ffb9a6..efc56f89b 100644 --- a/2.x/trunk/tools/peview/misc.c +++ b/2.x/trunk/tools/peview/misc.c @@ -33,7 +33,7 @@ static GUID IID_IShellLinkW_I = { 0x000214f9, 0x0000, 0x0000, { 0xc0, 0x00, 0x00 static GUID IID_IPersistFile_I = { 0x0000010b, 0x0000, 0x0000, { 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }; PPH_STRING PvResolveShortcutTarget( - __in PPH_STRING ShortcutFileName + _In_ PPH_STRING ShortcutFileName ) { PPH_STRING targetFileName; @@ -68,7 +68,7 @@ PPH_STRING PvResolveShortcutTarget( // Copied from appsup.c VOID PvCopyListView( - __in HWND ListViewHandle + _In_ HWND ListViewHandle ) { PPH_STRING text; @@ -79,8 +79,8 @@ VOID PvCopyListView( } VOID PvHandleListViewNotifyForCopy( - __in LPARAM lParam, - __in HWND ListViewHandle + _In_ LPARAM lParam, + _In_ HWND ListViewHandle ) { if (((LPNMHDR)lParam)->hwndFrom == ListViewHandle) diff --git a/2.x/trunk/tools/peview/peprp.c b/2.x/trunk/tools/peview/peprp.c index a1ab6a222..6dbb6ec47 100644 --- a/2.x/trunk/tools/peview/peprp.c +++ b/2.x/trunk/tools/peview/peprp.c @@ -22,47 +22,55 @@ #include #include +#include +#include #define PVM_CHECKSUM_DONE (WM_APP + 1) +#define PVM_VERIFY_DONE (WM_APP + 2) INT_PTR CALLBACK PvpPeGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PvpPeImportsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PvpPeExportsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PvpPeLoadConfigDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); INT_PTR CALLBACK PvpPeClrDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ); PH_MAPPED_IMAGE PvMappedImage; PIMAGE_COR20_HEADER PvImageCor20Header; +HICON PvImageLargeIcon; +PH_IMAGE_VERSION_INFO PvImageVersionInfo; +VERIFY_RESULT PvImageVerifyResult; +PPH_STRING PvImageSignerName; + VOID PvPeProperties( VOID ) @@ -164,7 +172,7 @@ VOID PvPeProperties( } static NTSTATUS CheckSumImageThreadStart( - __in PVOID Parameter + _In_ PVOID Parameter ) { HWND windowHandle; @@ -183,11 +191,110 @@ static NTSTATUS CheckSumImageThreadStart( return STATUS_SUCCESS; } +VERIFY_RESULT PvpVerifyFileWithAdditionalCatalog( + _In_ PPH_STRING FileName, + _In_ ULONG Flags, + _In_opt_ HWND hWnd, + _Out_opt_ PPH_STRING *SignerName + ) +{ + static PH_STRINGREF codeIntegrityFileName = PH_STRINGREF_INIT(L"\\AppxMetadata\\CodeIntegrity.cat"); + + VERIFY_RESULT result; + PH_VERIFY_FILE_INFO info; + PPH_STRING windowsAppsPath; + PPH_STRING additionalCatalogFileName = NULL; + PCERT_CONTEXT *signatures; + ULONG numberOfSignatures; + + memset(&info, 0, sizeof(PH_VERIFY_FILE_INFO)); + info.FileName = FileName->Buffer; + info.Flags = Flags; + info.hWnd = hWnd; + + windowsAppsPath = PhGetKnownLocation(CSIDL_PROGRAM_FILES, L"\\WindowsApps\\"); + + if (windowsAppsPath) + { + if (PhStartsWithStringRef(&FileName->sr, &windowsAppsPath->sr, TRUE)) + { + PH_STRINGREF remainingFileName; + ULONG_PTR indexOfBackslash; + PH_STRINGREF baseFileName; + + remainingFileName = FileName->sr; + remainingFileName.Buffer = (PWCHAR)((PCHAR)remainingFileName.Buffer + windowsAppsPath->Length); + remainingFileName.Length -= windowsAppsPath->Length; + indexOfBackslash = PhFindCharInStringRef(&remainingFileName, '\\', FALSE); + + if (indexOfBackslash != -1) + { + baseFileName.Buffer = FileName->Buffer; + baseFileName.Length = windowsAppsPath->Length + indexOfBackslash * sizeof(WCHAR); + additionalCatalogFileName = PhConcatStringRef2(&baseFileName, &codeIntegrityFileName); + } + } + + PhDereferenceObject(windowsAppsPath); + } + + if (additionalCatalogFileName) + { + info.NumberOfCatalogFileNames = 1; + info.CatalogFileNames = &additionalCatalogFileName->Buffer; + } + + if (!NT_SUCCESS(PhVerifyFileEx(&info, &result, &signatures, &numberOfSignatures))) + { + result = VrNoSignature; + signatures = NULL; + numberOfSignatures = 0; + } + + if (additionalCatalogFileName) + PhDereferenceObject(additionalCatalogFileName); + + if (SignerName) + { + if (numberOfSignatures != 0) + *SignerName = PhGetSignerNameFromCertificate(signatures[0]); + else + *SignerName = NULL; + } + + PhFreeVerifySignatures(signatures, numberOfSignatures); + + return result; +} + +static NTSTATUS VerifyImageThreadStart( + _In_ PVOID Parameter + ) +{ + HWND windowHandle; + + windowHandle = Parameter; + PvImageVerifyResult = PvpVerifyFileWithAdditionalCatalog(PvFileName, PH_VERIFY_PREVENT_NETWORK_ACCESS, NULL, &PvImageSignerName); + PostMessage(windowHandle, PVM_VERIFY_DONE, 0, 0); + + return STATUS_SUCCESS; +} + +FORCEINLINE PWSTR PvpGetStringOrNa( + _In_ PPH_STRING String + ) +{ + if (String) + return String->Buffer; + else + return L"N/A"; +} + INT_PTR CALLBACK PvpPeGeneralDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -202,6 +309,35 @@ INT_PTR CALLBACK PvpPeGeneralDlgProc( PhCenterWindow(GetParent(hwndDlg), NULL); + // File version information + + { + PhInitializeImageVersionInfo(&PvImageVersionInfo, PvFileName->Buffer); + + if (ExtractIconEx( + PvFileName->Buffer, + 0, + &PvImageLargeIcon, + NULL, + 1 + ) == 0) + { + PvImageLargeIcon = PhGetFileShellIcon(PvFileName->Buffer, NULL, TRUE); + } + + SendMessage(GetDlgItem(hwndDlg, IDC_FILEICON), STM_SETICON, (WPARAM)PvImageLargeIcon, 0); + + SetDlgItemText(hwndDlg, IDC_NAME, PvpGetStringOrNa(PvImageVersionInfo.FileDescription)); + string = PhConcatStrings2(L"(Verifying...) ", PvpGetStringOrNa(PvImageVersionInfo.CompanyName)); + SetDlgItemText(hwndDlg, IDC_COMPANYNAME, string->Buffer); + PhDereferenceObject(string); + SetDlgItemText(hwndDlg, IDC_VERSION, PvpGetStringOrNa(PvImageVersionInfo.FileVersion)); + + PhQueueItemGlobalWorkQueue(VerifyImageThreadStart, hwndDlg); + } + + // PE properties + switch (PvMappedImage.NtHeaders->FileHeader.Machine) { case IMAGE_FILE_MACHINE_I386: @@ -213,6 +349,9 @@ INT_PTR CALLBACK PvpPeGeneralDlgProc( case IMAGE_FILE_MACHINE_IA64: type = L"IA64"; break; + case IMAGE_FILE_MACHINE_ARMNT: + type = L"ARM Thumb-2"; + break; default: type = L"Unknown"; break; @@ -394,8 +533,59 @@ INT_PTR CALLBACK PvpPeGeneralDlgProc( } } break; + case PVM_VERIFY_DONE: + { + PPH_STRING string; + + if (PvImageVerifyResult == VrTrusted) + { + if (PvImageSignerName) + { + string = PhFormatString(L"(Verified) %s", PvImageSignerName->Buffer); + SetDlgItemText(hwndDlg, IDC_COMPANYNAME_LINK, string->Buffer); + PhDereferenceObject(string); + ShowWindow(GetDlgItem(hwndDlg, IDC_COMPANYNAME), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_COMPANYNAME_LINK), SW_SHOW); + } + else + { + string = PhConcatStrings2(L"(Verified) ", PhGetStringOrEmpty(PvImageVersionInfo.CompanyName)); + SetDlgItemText(hwndDlg, IDC_COMPANYNAME, string->Buffer); + PhDereferenceObject(string); + } + } + else if (PvImageVerifyResult != VrUnknown) + { + string = PhConcatStrings2(L"(UNVERIFIED) ", PhGetStringOrEmpty(PvImageVersionInfo.CompanyName)); + SetDlgItemText(hwndDlg, IDC_COMPANYNAME, string->Buffer); + PhDereferenceObject(string); + } + else + { + SetDlgItemText(hwndDlg, IDC_COMPANYNAME, PvpGetStringOrNa(PvImageVersionInfo.CompanyName)); + } + } + break; case WM_NOTIFY: { + LPNMHDR header = (LPNMHDR)lParam; + + switch (header->code) + { + case NM_CLICK: + { + switch (header->idFrom) + { + case IDC_COMPANYNAME_LINK: + { + PvpVerifyFileWithAdditionalCatalog(PvFileName, PH_VERIFY_VIEW_PROPERTIES, hwndDlg, NULL); + } + break; + } + } + break; + } + PvHandleListViewNotifyForCopy(lParam, GetDlgItem(hwndDlg, IDC_LIST)); } break; @@ -405,9 +595,9 @@ INT_PTR CALLBACK PvpPeGeneralDlgProc( } VOID PvpProcessImports( - __in HWND ListViewHandle, - __in PPH_MAPPED_IMAGE_IMPORTS Imports, - __in BOOLEAN DelayImports + _In_ HWND ListViewHandle, + _In_ PPH_MAPPED_IMAGE_IMPORTS Imports, + _In_ BOOLEAN DelayImports ) { PH_MAPPED_IMAGE_IMPORT_DLL importDll; @@ -457,10 +647,10 @@ VOID PvpProcessImports( } INT_PTR CALLBACK PvpPeImportsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -504,10 +694,10 @@ INT_PTR CALLBACK PvpPeImportsDlgProc( } INT_PTR CALLBACK PvpPeExportsDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -589,10 +779,10 @@ INT_PTR CALLBACK PvpPeExportsDlgProc( } INT_PTR CALLBACK PvpPeLoadConfigDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) @@ -682,10 +872,10 @@ INT_PTR CALLBACK PvpPeLoadConfigDlgProc( } INT_PTR CALLBACK PvpPeClrDlgProc( - __in HWND hwndDlg, - __in UINT uMsg, - __in WPARAM wParam, - __in LPARAM lParam + _In_ HWND hwndDlg, + _In_ UINT uMsg, + _In_ WPARAM wParam, + _In_ LPARAM lParam ) { switch (uMsg) diff --git a/2.x/trunk/tools/peview/peview.manifest b/2.x/trunk/tools/peview/peview.manifest new file mode 100644 index 000000000..b7b5d71e5 --- /dev/null +++ b/2.x/trunk/tools/peview/peview.manifest @@ -0,0 +1,42 @@ + + + + PE Viewer + + + + + + + + + + + + + + + + + + + + + + + true + + + \ No newline at end of file diff --git a/2.x/trunk/tools/peview/peview.rc b/2.x/trunk/tools/peview/peview.rc index 208ff918b..707f4d32a 100644 --- a/2.x/trunk/tools/peview/peview.rc +++ b/2.x/trunk/tools/peview/peview.rc @@ -114,22 +114,29 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "General" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - LTEXT "Target machine:",IDC_STATIC,7,7,53,8 - LTEXT "Static",IDC_TARGETMACHINE,78,7,215,8 - LTEXT "Checksum:",IDC_STATIC,7,40,36,8 - LTEXT "Static",IDC_CHECKSUM,78,40,215,8 - LTEXT "Subsystem:",IDC_STATIC,7,51,38,8 - LTEXT "Subsystem version:",IDC_STATIC,7,62,64,8 - LTEXT "Characteristics:",IDC_STATIC,7,73,51,8 - LTEXT "Static",IDC_SUBSYSTEM,78,51,215,8 - LTEXT "Static",IDC_SUBSYSTEMVERSION,78,62,215,8 - CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,99,286,174 - LTEXT "Sections:",IDC_STATIC,7,88,30,8 - EDITTEXT IDC_CHARACTERISTICS,76,73,217,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Time stamp:",IDC_STATIC,7,18,40,8 - LTEXT "Static",IDC_TIMESTAMP,78,18,215,8 - LTEXT "Image base:",IDC_STATIC,7,29,41,8 - LTEXT "Static",IDC_IMAGEBASE,78,29,215,8 + LTEXT "Target machine:",IDC_STATIC,7,62,53,8 + LTEXT "Static",IDC_TARGETMACHINE,78,62,215,8 + LTEXT "Checksum:",IDC_STATIC,7,95,36,8 + LTEXT "Static",IDC_CHECKSUM,78,95,215,8 + LTEXT "Subsystem:",IDC_STATIC,7,106,38,8 + LTEXT "Subsystem version:",IDC_STATIC,7,117,64,8 + LTEXT "Characteristics:",IDC_STATIC,7,129,51,8 + LTEXT "Static",IDC_SUBSYSTEM,78,106,215,8 + LTEXT "Static",IDC_SUBSYSTEMVERSION,78,117,215,8 + CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,153,286,119 + LTEXT "Sections:",IDC_STATIC,7,143,30,8 + EDITTEXT IDC_CHARACTERISTICS,76,129,217,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Time stamp:",IDC_STATIC,7,73,40,8 + LTEXT "Static",IDC_TIMESTAMP,78,73,215,8 + LTEXT "Image base:",IDC_STATIC,7,84,41,8 + LTEXT "Static",IDC_IMAGEBASE,78,84,215,8 + ICON "",IDC_FILEICON,14,18,20,20 + GROUPBOX "File",IDC_FILE,7,7,286,51 + EDITTEXT IDC_NAME,44,17,242,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_COMPANYNAME,44,29,242,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Version:",IDC_STATIC,15,41,27,8 + EDITTEXT IDC_VERSION,44,41,242,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + CONTROL "Company Name Link",IDC_COMPANYNAME_LINK,"SysLink",LWS_NOPREFIX | NOT WS_VISIBLE | WS_TABSTOP,46,29,240,9 END IDD_PEIMPORTS DIALOGEX 0, 0, 300, 280 @@ -177,6 +184,13 @@ BEGIN CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,286,266 END + +///////////////////////////////////////////////////////////////////////////// +// +// RT_MANIFEST +// + +IDR_RT_MANIFEST RT_MANIFEST "peview.manifest" #endif // English (Australia) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/2.x/trunk/tools/peview/peview.vcxproj b/2.x/trunk/tools/peview/peview.vcxproj index 4ff3d2f96..827b76829 100644 --- a/2.x/trunk/tools/peview/peview.vcxproj +++ b/2.x/trunk/tools/peview/peview.vcxproj @@ -63,7 +63,6 @@ - <_ProjectFileVersion>10.0.30319.1 $(SolutionDir)bin\$(Configuration)$(PlatformArchitecture)\ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ true @@ -77,6 +76,18 @@ $(ProjectDir)obj\$(Configuration)$(PlatformArchitecture)\ false + + false + + + false + + + false + + + false + Disabled @@ -87,22 +98,19 @@ Level3 ProgramDatabase StdCall - StreamingSIMDExtensions noarg.obj;noenv.obj;phlib.lib;ntdll.lib;%(AdditionalDependencies) ../../phlib/bin/$(Configuration)32;../../lib/lib32;%(AdditionalLibraryDirectories) - type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27x86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) + + true Windows MachineX86 - /SUBSYSTEM:WINDOWS,5.01 %(AdditionalOptions) + 5.01 - - X64 - Disabled ../../phlib/include;include;%(AdditionalIncludeDirectories) @@ -112,16 +120,16 @@ Level3 ProgramDatabase StdCall - NotSet noarg.obj;noenv.obj;phlib.lib;ntdll.lib;%(AdditionalDependencies) ../../phlib/bin/$(Configuration)64;../../lib/lib64;%(AdditionalLibraryDirectories) - type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27amd64%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) + + true Windows MachineX64 - /SUBSYSTEM:WINDOWS,5.02 %(AdditionalOptions) + 5.02 @@ -141,20 +149,18 @@ noarg.obj;noenv.obj;phlib.lib;ntdll.lib;%(AdditionalDependencies) ../../phlib/bin/$(Configuration)32;../../lib/lib32;%(AdditionalLibraryDirectories) - type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27x86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) + + true Windows true true MachineX86 true - /SUBSYSTEM:WINDOWS,5.01 %(AdditionalOptions) + 5.01 - - X64 - MaxSpeed true @@ -166,19 +172,19 @@ ProgramDatabase StdCall true - NotSet noarg.obj;noenv.obj;phlib.lib;ntdll.lib;%(AdditionalDependencies) ../../phlib/bin/$(Configuration)64;../../lib/lib64;%(AdditionalLibraryDirectories) - type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27amd64%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) + + true Windows true true MachineX64 true - /SUBSYSTEM:WINDOWS,5.02 %(AdditionalOptions) + 5.02 @@ -201,6 +207,9 @@ false + + + diff --git a/2.x/trunk/tools/peview/peview.vcxproj.filters b/2.x/trunk/tools/peview/peview.vcxproj.filters index 54ab0d75a..d9daae49b 100644 --- a/2.x/trunk/tools/peview/peview.vcxproj.filters +++ b/2.x/trunk/tools/peview/peview.vcxproj.filters @@ -44,4 +44,9 @@ Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/2.x/trunk/tools/peview/resource.h b/2.x/trunk/tools/peview/resource.h index a0c8ceaa8..dea91ace8 100644 --- a/2.x/trunk/tools/peview/resource.h +++ b/2.x/trunk/tools/peview/resource.h @@ -2,6 +2,7 @@ // Microsoft Visual C++ generated include file. // Used by peview.rc // +#define IDR_RT_MANIFEST 1 #define IDD_PEGENERAL 102 #define IDD_PEIMPORTS 103 #define IDD_PEEXPORTS 104 @@ -15,18 +16,24 @@ #define IDC_SUBSYSTEMVERSION 1006 #define IDC_CHARACTERISTICS 1007 #define IDC_LIST 1008 +#define IDC_FILEICON 1009 #define IDC_TIMESTAMP 1010 #define IDC_RUNTIMEVERSION 1011 +#define IDC_FILE 1011 #define IDC_FLAGS 1012 +#define IDC_COMPANYNAME 1012 #define IDC_EDIT1 1013 +#define IDC_VERSION 1013 #define IDC_VERSIONSTRING 1014 #define IDC_IMAGEBASE 1015 +#define IDC_NAME 1044 +#define IDC_COMPANYNAME_LINK 1279 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_RESOURCE_VALUE 108 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1016 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/misc/website/websitev2/.htaccess b/misc/website/websitev2/.htaccess index ae3131618..3b146eebd 100644 --- a/misc/website/websitev2/.htaccess +++ b/misc/website/websitev2/.htaccess @@ -1,4 +1,5 @@ -# Apache Configuration File +# Apache Server Configs v2.2.0 | MIT License +# https://github.com/h5bp/server-configs-apache # (!) Using `.htaccess` files slows down Apache, therefore, if you have access # to the main server config file (usually called `httpd.conf`), you should add @@ -12,7 +13,7 @@ # | Cross-domain AJAX requests | # ------------------------------------------------------------------------------ -# Enable cross-origin AJAX requests. +# Allow cross-origin AJAX requests. # http://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity # http://enable-cors.org/ @@ -25,13 +26,13 @@ # ------------------------------------------------------------------------------ # Send the CORS header for images when browsers request it. -# https://developer.mozilla.org/en/CORS_Enabled_Image +# https://developer.mozilla.org/en-US/docs/HTML/CORS_Enabled_Image # http://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html # http://hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/ - + SetEnvIf Origin ":" IS_CORS Header set Access-Control-Allow-Origin "*" env=IS_CORS @@ -42,10 +43,10 @@ # | Web fonts access | # ------------------------------------------------------------------------------ -# Allow access from all domains for web fonts +# Allow access to web fonts from all domains. - + Header set Access-Control-Allow-Origin "*" @@ -59,8 +60,8 @@ # | 404 error prevention for non-existing redirected folders | # ------------------------------------------------------------------------------ -# Prevent Apache from returning a 404 error for a rewrite if a directory -# with the same name does not exist. +# Prevent Apache from returning a 404 error as the result of a rewrite +# when the directory with the same name does not exist. # http://httpd.apache.org/docs/current/content-negotiation.html#multiviews # http://www.webmasterworld.com/apache/3808792.htm @@ -70,11 +71,12 @@ Options -MultiViews # | Custom error messages / pages | # ------------------------------------------------------------------------------ -# You can customize what Apache returns to the client in case of an error (see -# http://httpd.apache.org/docs/current/mod/core.html#errordocument), e.g.: +# Customize what Apache returns to the client in case of an error. +# http://httpd.apache.org/docs/current/mod/core.html#errordocument #ErrorDocument 404 /404.html +# custom PH code ErrorDocument 400 /error.php ErrorDocument 401 /error.php ErrorDocument 403 /error.php @@ -90,14 +92,15 @@ ErrorDocument 500 /error.php # | Better website experience | # ------------------------------------------------------------------------------ -# Force IE to render pages in the highest available mode in the various -# cases when it may not: http://hsivonen.iki.fi/doctype/ie-mode.pdf. +# Force Internet Explorer to render pages in the highest available mode +# in the various cases when it may not. +# http://hsivonen.iki.fi/doctype/ie-mode.pdf Header set X-UA-Compatible "IE=edge" - # `mod_headers` can't match based on the content-type, however, we only - # want to send this header for HTML pages and not for the other resources - + # `mod_headers` cannot match based on the content-type, however, this + # header should be send only for HTML pages and not for the other resources + Header unset X-UA-Compatible @@ -106,24 +109,14 @@ ErrorDocument 500 /error.php # | Cookie setting from iframes | # ------------------------------------------------------------------------------ -# Allow cookies to be set from iframes in IE. +# Allow cookies to be set from iframes in Internet Explorer. +# http://msdn.microsoft.com/en-us/library/ms537343.aspx +# http://www.w3.org/TR/2000/CR-P3P-20001215/ # # Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"" # -# ------------------------------------------------------------------------------ -# | Screen flicker | -# ------------------------------------------------------------------------------ - -# Stop screen flicker in IE on CSS rollovers (this only works in -# combination with the `ExpiresByType` directives for images from below). - -# BrowserMatch "MSIE" brokenvary=1 -# BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1 -# BrowserMatch "Opera" !brokenvary -# SetEnvIf brokenvary 1 force-no-vary - # ############################################################################## # # MIME TYPES AND ENCODING # @@ -137,16 +130,19 @@ ErrorDocument 500 /error.php # Audio AddType audio/mp4 m4a f4a f4b - AddType audio/ogg oga ogg + AddType audio/ogg oga ogg opus + + # Data interchange + AddType application/json json map + AddType application/ld+json jsonld # JavaScript - # Normalize to standard type (it's sniffed in IE anyways): + # Normalize to standard type. # http://tools.ietf.org/html/rfc4329#section-7.2 - AddType application/javascript js jsonp - AddType application/json json + AddType application/javascript js # Video - AddType video/mp4 mp4 m4v f4v f4p + AddType video/mp4 f4v f4p m4v mp4 AddType video/ogg ogv AddType video/webm webm AddType video/x-flv flv @@ -155,27 +151,30 @@ ErrorDocument 500 /error.php AddType application/font-woff woff AddType application/vnd.ms-fontobject eot - # Browsers usually ignore the font MIME types and sniff the content, - # however, Chrome shows a warning if other MIME types are used for the - # following fonts. + # Browsers usually ignore the font MIME types and simply sniff the bytes + # to figure out the font type. + # http://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern + + # Chrome however, shows a warning if any other MIME types are used for + # the following fonts. + AddType application/x-font-ttf ttc ttf AddType font/opentype otf - # Make SVGZ fonts work on iPad: + # Make SVGZ fonts work on the iPad. # https://twitter.com/FontSquirrel/status/14855840545 - AddType image/svg+xml svg svgz + AddType image/svg+xml svgz AddEncoding gzip svgz # Other AddType application/octet-stream safariextz AddType application/x-chrome-extension crx AddType application/x-opera-extension oex - AddType application/x-shockwave-flash swf AddType application/x-web-app-manifest+json webapp AddType application/x-xpinstall xpi AddType application/xml atom rdf rss xml AddType image/webp webp - AddType image/x-icon ico + AddType image/x-icon cur AddType text/cache-manifest appcache manifest AddType text/vtt vtt AddType text/x-component htc @@ -192,7 +191,7 @@ AddDefaultCharset utf-8 # Force UTF-8 for certain file formats. - AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml + AddCharset utf-8 .atom .css .js .json .jsonld .rss .vtt .webapp .xml @@ -204,14 +203,15 @@ AddDefaultCharset utf-8 # | Rewrite engine | # ------------------------------------------------------------------------------ -# Turning on the rewrite engine and enabling the `FollowSymLinks` option is -# necessary for the following directives to work. +# Turn on the rewrite engine and enable the `FollowSymLinks` option (this is +# necessary in order for the following directives to work). # If your web host doesn't allow the `FollowSymlinks` option, you may need to -# comment it out and use `Options +SymLinksIfOwnerMatch` but, be aware of the -# performance impact: http://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks +# comment it out and use `Options +SymLinksIfOwnerMatch`, but be aware of the +# performance impact. +# http://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks -# Also, some cloud hosting services require `RewriteBase` to be set: +# Also, some cloud hosting services require `RewriteBase` to be set. # http://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-mod-rewrite-not-working-on-my-site @@ -222,19 +222,19 @@ AddDefaultCharset utf-8 # ------------------------------------------------------------------------------ -# | Suppressing / Forcing the "www." at the beginning of URLs | +# | Suppressing / Forcing the `www.` at the beginning of URLs | # ------------------------------------------------------------------------------ -# The same content should never be available under two different URLs especially -# not with and without "www." at the beginning. This can cause SEO problems -# (duplicate content), therefore, you should choose one of the alternatives and -# redirect the other one. +# The same content should never be available under two different URLs, +# especially not with and without `www.` at the beginning. This can cause +# SEO problems (duplicate content), and therefore, you should choose one +# of the alternatives and redirect the other one. -# By default option 1 (no "www.") is activated: +# By default `Option 1` (no `www.`) is activated. # http://no-www.org/faq.php?q=class_b -# If you'd prefer to use option 2, just comment out all the lines from option 1 -# and uncomment the ones from option 2. +# If you would prefer to use `Option 2`, just comment out all the lines +# from `Option 1` and uncomment the ones from `Option 2`. # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME! @@ -257,7 +257,9 @@ AddDefaultCharset utf-8 # # RewriteCond %{HTTPS} !=on -# RewriteCond %{HTTP_HOST} !^www\..+$ [NC] +# RewriteCond %{HTTP_HOST} !^www\. [NC] +# RewriteCond %{SERVER_ADDR} !=127.0.0.1 +# RewriteCond %{SERVER_ADDR} !=::1 # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # @@ -266,27 +268,66 @@ AddDefaultCharset utf-8 # # SECURITY # # ############################################################################## +# ------------------------------------------------------------------------------ +# | Clickjacking | +# ------------------------------------------------------------------------------ + +# Protect website against clickjacking. + +# The example below sends the `X-Frame-Options` response header with the value +# `DENY`, informing browsers not to display the web page content in any frame. + +# This might not be the best setting for everyone. You should read about the +# other two possible values for `X-Frame-Options`: `SAMEORIGIN` & `ALLOW-FROM`. +# http://tools.ietf.org/html/rfc7034#section-2.1 + +# Keep in mind that while you could send the `X-Frame-Options` header for all +# of your site’s pages, this has the potential downside that it forbids even +# non-malicious framing of your content (e.g.: when users visit your site using +# a Google Image Search results page). + +# Nonetheless, you should ensure that you send the `X-Frame-Options` header for +# all pages that allow a user to make a state changing operation (e.g: pages +# that contain one-click purchase links, checkout or bank-transfer confirmation +# pages, pages that make permanent configuration changes, etc.). + +# Sending the `X-Frame-Options` header can also protect your website against +# more than just clickjacking attacks: https://cure53.de/xfo-clickjacking.pdf. + +# http://tools.ietf.org/html/rfc7034 +# http://blogs.msdn.com/b/ieinternals/archive/2010/03/30/combating-clickjacking-with-x-frame-options.aspx +# https://www.owasp.org/index.php/Clickjacking + +# +# Header set X-Frame-Options "DENY" +# +# Header unset X-Frame-Options +# +# + # ------------------------------------------------------------------------------ # | Content Security Policy (CSP) | # ------------------------------------------------------------------------------ -# You can mitigate the risk of cross-site scripting and other content-injection -# attacks by setting a Content Security Policy which whitelists trusted sources -# of content for your site. +# Mitigate the risk of cross-site scripting and other content-injection attacks. + +# This can be done by setting a `Content Security Policy` which whitelists +# trusted sources of content for your website. # The example header below allows ONLY scripts that are loaded from the current # site's origin (no inline scripts, no CDN, etc). This almost certainly won't # work as-is for your site! -# To get all the details you'll need to craft a reasonable policy for your site, -# read: http://html5rocks.com/en/tutorials/security/content-security-policy (or -# see the specification: http://w3.org/TR/CSP). +# For more details on how to craft a reasonable policy for your site, read: +# http://html5rocks.com/en/tutorials/security/content-security-policy (or the +# specification: http://w3.org/TR/CSP). Also, to make things easier, you can +# use an online CSP header generator such as: http://cspisawesome.com/. # -# Header set Content-Security-Policy "script-src 'self'; object-src 'self'" -# -# Header unset Content-Security-Policy -# +# Header set Content-Security-Policy "script-src 'self'; object-src 'self'" +# +# Header unset Content-Security-Policy +# # # ------------------------------------------------------------------------------ @@ -294,9 +335,9 @@ AddDefaultCharset utf-8 # ------------------------------------------------------------------------------ # Block access to directories without a default document. -# Usually you should leave this uncommented because you shouldn't allow anyone -# to surf through every directory on your server (which may includes rather -# private places like the CMS's directories). +# You should leave the following uncommented, as you shouldn't allow anyone to +# surf through every directory on your server (which may includes rather private +# places such as the CMS's directories). Options -Indexes @@ -315,22 +356,100 @@ AddDefaultCharset utf-8 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Block access to backup and source files. -# These files may be left by some text editors and can pose a great security -# danger when anyone has access to them. +# Block access to files that can expose sensitive information. + +# By default, block access to backup and source files that may be left by some +# text editors and can pose a security risk when anyone has access to them. +# http://feross.org/cmsploit/ + +# IMPORTANT: Update the `` regular expression from below to include +# any files that might end up on your production server and can expose sensitive +# information about your website. These files may include: configuration files, +# files that contain metadata about the project (e.g.: project dependencies), +# build scripts, etc.. + + + + # Apache < 2.3 + + Order allow,deny + Deny from all + Satisfy All + + + # Apache ≥ 2.3 + + Require all denied + - - Order allow,deny - Deny from all - Satisfy All +# ------------------------------------------------------------------------------ +# | Reducing MIME-type security risks | +# ------------------------------------------------------------------------------ + +# Prevent some browsers from MIME-sniffing the response. + +# This reduces exposure to drive-by download attacks and should be enable +# especially if the web server is serving user uploaded content, content +# that could potentially be treated by the browser as executable. + +# http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx +# http://msdn.microsoft.com/en-us/library/ie/gg622941.aspx +# http://mimesniff.spec.whatwg.org/ + +# +# Header set X-Content-Type-Options "nosniff" +# + +# ------------------------------------------------------------------------------ +# | Reflected Cross-Site Scripting (XSS) attacks | +# ------------------------------------------------------------------------------ + +# (1) Try to re-enable the Cross-Site Scripting (XSS) filter built into the +# most recent web browsers. +# +# The filter is usually enabled by default, but in some cases it may be +# disabled by the user. However, in Internet Explorer for example, it can +# be re-enabled just by sending the `X-XSS-Protection` header with the +# value of `1`. +# +# (2) Prevent web browsers from rendering the web page if a potential reflected +# (a.k.a non-persistent) XSS attack is detected by the filter. +# +# By default, if the filter is enabled and browsers detect a reflected +# XSS attack, they will attempt to block the attack by making the smallest +# possible modifications to the returned web page. +# +# Unfortunately, in some browsers (e.g.: Internet Explorer), this default +# behavior may allow the XSS filter to be exploited, thereby, it's better +# to tell browsers to prevent the rendering of the page altogether, instead +# of attempting to modify it. +# +# http://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities +# +# IMPORTANT: Do not rely on the XSS filter to prevent XSS attacks! Ensure that +# you are taking all possible measures to prevent XSS attacks, the most obvious +# being: validating and sanitizing your site's inputs. +# +# http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx +# http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx +# https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29 + +# +# # (1) (2) +# Header set X-XSS-Protection "1; mode=block" +# +# Header unset X-XSS-Protection +# +# + # ------------------------------------------------------------------------------ # | Secure Sockets Layer (SSL) | # ------------------------------------------------------------------------------ -# Rewrite secure requests properly to prevent SSL certificate warnings, e.g.: -# prevent `https://www.example.com` when your certificate only allows +# Rewrite secure requests properly in order to prevent SSL certificate warnings. +# E.g.: prevent `https://www.example.com` when your certificate only allows # `https://secure.example.com`. # @@ -338,19 +457,28 @@ AddDefaultCharset utf-8 # RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L] # -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# ------------------------------------------------------------------------------ +# | HTTP Strict Transport Security (HSTS) | +# ------------------------------------------------------------------------------ # Force client-side SSL redirection. -# If a user types "example.com" in his browser, the above rule will redirect him -# to the secure version of the site. That still leaves a window of opportunity -# (the initial HTTP connection) for an attacker to downgrade or redirect the -# request. The following header ensures that browser will ONLY connect to your -# server via HTTPS, regardless of what the users type in the address bar. +# If a user types `example.com` in his browser, the above rule will redirect +# him to the secure version of the site. That still leaves a window of +# opportunity (the initial HTTP connection) for an attacker to downgrade or +# redirect the request. + +# The following header ensures that browser will ONLY connect to your server +# via HTTPS, regardless of what the users type in the address bar. + +# http://tools.ietf.org/html/draft-ietf-websec-strict-transport-sec-14#section-6.1 # http://www.html5rocks.com/en/tutorials/security/transport-layer-security/ +# IMPORTANT: Remove the `includeSubDomains` optional directive if the subdomains +# are not using HTTPS. + # -# Header set Strict-Transport-Security max-age=16070400; +# Header set Strict-Transport-Security "max-age=16070400; includeSubDomains" # # ------------------------------------------------------------------------------ @@ -392,6 +520,7 @@ AddDefaultCharset utf-8 AddOutputFilterByType DEFLATE application/atom+xml \ application/javascript \ application/json \ + application/ld+json \ application/rss+xml \ application/vnd.ms-fontobject \ application/x-font-ttf \ @@ -414,21 +543,21 @@ AddDefaultCharset utf-8 # | Content transformations | # ------------------------------------------------------------------------------ -# Prevent some of the mobile network providers from modifying the content of -# your site: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5. +# Prevent mobile network providers from modifying the website's content. +# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5. # # Header set Cache-Control "no-transform" # # ------------------------------------------------------------------------------ -# | ETag removal | +# | ETags | # ------------------------------------------------------------------------------ -# Since we're sending far-future expires headers (see below), ETags can -# be removed: http://developer.yahoo.com/performance/rules.html#etags. +# Remove `ETags` as resources are sent with far-future expires headers. +# http://developer.yahoo.com/performance/rules.html#etags. -# `FileETag None` is not enough for every server. +# `FileETag None` doesn't work in all cases. Header unset ETag @@ -436,12 +565,13 @@ AddDefaultCharset utf-8 FileETag None # ------------------------------------------------------------------------------ -# | Expires headers (for better cache control) | +# | Expires headers | # ------------------------------------------------------------------------------ -# The following expires headers are set pretty far in the future. If you don't -# control versioning with filename-based cache busting, consider lowering the -# cache time for resources like CSS and JS to something like 1 week. +# The following expires headers are set pretty far in the future. If you +# don't control versioning with filename-based cache busting, consider +# lowering the cache time for resources such as style sheets and JavaScript +# files to something like one week. @@ -453,10 +583,11 @@ FileETag None # Data interchange ExpiresByType application/json "access plus 0 seconds" + ExpiresByType application/ld+json "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType text/xml "access plus 0 seconds" - # Favicon (cannot be renamed!) + # Favicon (cannot be renamed!) and cursor images ExpiresByType image/x-icon "access plus 1 week" # HTML components (HTCs) @@ -507,19 +638,23 @@ FileETag None # # RewriteCond %{REQUEST_FILENAME} !-f -# RewriteCond %{REQUEST_FILENAME} !-d -# RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] +# RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpe?g|gif)$ $1.$3 [L] # # ------------------------------------------------------------------------------ # | File concatenation | # ------------------------------------------------------------------------------ -# Allow concatenation from within specific CSS and JS files, e.g.: -# Inside of `script.combined.js` you could have -# -# -# and they would be included into this single file. +# Allow concatenation from within specific style sheets and JavaScript files. + +# e.g.: +# +# If you have the following content in a file +# +# +# +# +# Apache will replace it with the content from the specified files. # # @@ -534,20 +669,6 @@ FileETag None # # -# ------------------------------------------------------------------------------ -# | Persistent connections | -# ------------------------------------------------------------------------------ - -# Allow multiple requests to be sent over the same TCP connection: -# http://httpd.apache.org/docs/current/en/mod/core.html#keepalive. - -# Enable if you serve a lot of static content but, be aware of the -# possible disadvantages! - -# -# Header set Connection Keep-Alive -# - # custom PH code Order Allow,Deny diff --git a/misc/website/websitev2/about.php b/misc/website/websitev2/about.php index 6a9820165..6cd46928b 100644 --- a/misc/website/websitev2/about.php +++ b/misc/website/websitev2/about.php @@ -28,7 +28,7 @@
  • Registered: 16-10-2008
  • Licence: GNU General Public License version 3.0 - GPLv3
  • + GPLv3
  • Language: English
  • Intended Audience: Advanced End Users, Developers
  • Programming Language: C, C#
  • @@ -50,7 +50,7 @@

    User avatar - wj32 + Wen Jia Liu (wj32)

    • Project Founder
    • diff --git a/misc/website/websitev2/changelog.php b/misc/website/websitev2/changelog.php index 97e41232b..b82336090 100644 --- a/misc/website/websitev2/changelog.php +++ b/misc/website/websitev2/changelog.php @@ -2,26 +2,29 @@
      - +
      + - +
      +

      This is the changelog from Process Hacker's SVN repository. As such it may contain information about unreleased versions of Process Hacker.

      + +
      +
      diff --git a/misc/website/websitev2/config.php b/misc/website/websitev2/config.php index f3f26fa4b..c6cbaa172 100644 --- a/misc/website/websitev2/config.php +++ b/misc/website/websitev2/config.php @@ -1,19 +1,22 @@ diff --git a/misc/website/websitev2/css/normalize.css b/misc/website/websitev2/css/normalize.css index 44df23d67..fe2d0924e 100644 --- a/misc/website/websitev2/css/normalize.css +++ b/misc/website/websitev2/css/normalize.css @@ -1,44 +1,81 @@ -/*! normalize.css v2.1.2 | MIT License | git.io/normalize */ +/*! normalize.css v3.0.0 | MIT License | git.io/normalize */ -/* ========================================================================== - HTML5 display definitions +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions ========================================================================== */ /** * Correct `block` display not defined in IE 8/9. */ +article, +aside, +details, +figcaption, +figure, footer, header, +hgroup, +main, nav, -section { - display: block; +section, +summary { + display: block; } /** - * Address `[hidden]` styling not present in IE 8/9. + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. */ -[hidden] { - display: none; +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ } -/* ========================================================================== - Base - ========================================================================== */ +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} /** - * 2. Prevent iOS text size adjust after orientation change, without disabling - * user zoom. + * Address `[hidden]` styling not present in IE 8/9. + * Hide the `template` element in IE, Safari, and Firefox < 22. */ -html { - -ms-text-size-adjust: 100%; /* 2 */ - -webkit-text-size-adjust: 100%; /* 2 */ +[hidden], +template { + display: none; } -/* ========================================================================== - Links +/* Links ========================================================================== */ /** @@ -46,22 +83,341 @@ html { */ a { - background: transparent; + background: transparent; } /** - * Address `outline` inconsistency between Chrome and other browsers. + * Improve readability when focused and also mouse hovered in all browsers. */ -a:focus { - outline: thin dotted; +a:active, +a:hover { + outline: 0; } +/* Text-level semantics + ========================================================================== */ + /** - * Improve readability when focused and also mouse hovered in all browsers. + * Address styling not present in IE 8/9, Safari 5, and Chrome. */ -a:active, -a:hover { - outline: 0; +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari 5 and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari 5, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9. + */ + +img { + border: 0; +} + +/** + * Correct overflow displayed oddly in IE 9. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari 5. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8+, and Opera + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; } diff --git a/misc/website/websitev2/css/pack.css b/misc/website/websitev2/css/pack.css index f5831acfa..7ec0a2580 100644 --- a/misc/website/websitev2/css/pack.css +++ b/misc/website/websitev2/css/pack.css @@ -1 +1 @@ -body{color:#000;font:400 14px 'Segoe UI',Segoe,'Helvetica Neue',Helvetica,Roboto,Arial,FreeSans,sans-serif;margin:0}a:link,a:visited{color:#03A;text-decoration:none}a:link:hover,a:visited:hover{text-decoration:underline}strong{font-weight:700}code{background-color:#F7F7F9;border:1px solid #E1E1E8;color:#D14;font-family:monospace,serif;font-size:1em;padding:.5px 4px}code,.side .portlet{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}dd{margin-left:10px}dt{font-weight:700;margin:15px auto 5px}footer{margin:10px auto;text-align:center}footer ul{list-style-type:none}footer ul,footer li{margin:0;padding:0}h1{font-size:20px;font-weight:700;text-align:center}h2{font-size:18px}h3{line-height:20px;margin:16px auto 8px}h3,.side h2{font-size:16px}img{border:0}li{margin-left:12px;padding-bottom:.5em}nav a{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;margin-right:.4em;padding:.3em .5em}nav .active a{background-color:Gainsboro;font-weight:700}nav a:link,nav a:visited{color:#000;text-decoration:none}nav a:hover{background-color:lightgray}nav h2{clear:none;color:#000;font-size:30px;font-weight:700;line-height:34px;margin:0 auto}nav li{display:inline-block;margin:0}nav li:first-child{margin-left:-.5em}nav li,.dev ul,.portlet li{list-style-type:none}ul{padding:0}.center{text-align:center}.changelog{border:2px solid #000;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;overflow:scroll;width:800px;height:600px}.ft{font-size:12px}.forumdate{color:silver}.forumdate>.author{color:#A00}.about-li{list-style-type:none;margin-left:0;padding-top:4px}.coder{color:#A00!important}.dev{position:relative}.ohloh-kudos{position:absolute;right:0;top:10px}.ohloh-commits{bottom:0;position:absolute;right:0}.user-avatar{background:#fff;border:1px solid #E5DFC7;display:block;float:left;margin:0 10px 0 0;padding:4px}.xhmikosr{color:#00f}.page{margin:0 auto;max-width:90em;padding:0 10px 5px;position:relative}.pre-section{width:700px;margin:-20px auto 0}.main-section{clear:both;margin:auto;padding-top:1px;text-align:center;width:700px}.main-section-2{margin:auto;width:700px}.section-header{border-top:dotted 1px;font-weight:700;margin-top:40px;text-transform:uppercase}.headline{font-size:18px;margin-top:20px;text-align:center}.main-headline{margin-bottom:40px}.main-section .headline{text-align:left}.bottom-download{font-size:20px;text-align:center!important}.tip{font-size:12px;font-style:italic;margin-top:5px;text-align:left}.normal{text-align:left}.yui-d0{margin:auto;width:auto}.yui-t4{margin:auto;width:700px}.yui-b{position:relative}.yui-t4 .yui-b{float:right;width:20em}.yui-g .yui-u,.yui-g .yui-g{float:right}.yui-g .first{float:left}.yui-g .yui-u,.yui-g .yui-g{width:49.1%}.yui-g:after,.yui-t4:after{clear:both;content:".";display:block;height:0;visibility:hidden}.portlet{clear:both;padding:0 0 1em}.portlet>h2:first-child{margin:0}.portlet p{margin:5px 0}.flowed-block{display:inline-block;padding:0 0 0 10px;vertical-align:top}.facetmenu{width:100%}.quick-links{width:250px}.downloads{width:250px}.downloads li{font-weight:700;margin:0;padding:2px 0 0}.downloads li>a{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 0 #BBDAF7;-moz-box-shadow:inset 0 1px 0 0 #BBDAF7;box-shadow:inset 0 1px 0 0 #BBDAF7;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#1C8D2E),color-stop(1,#629D4F));background-image:-webkit-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:-moz-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:-ms-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:-o-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:linear-gradient(to bottom,#1C8D2E 5%,#629D4F 100%);background-color:#1C8D2E;border:1px solid #1C8D2E;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;color:#fff;display:inline-block;font-weight:700;padding:.7em 1em;text-align:center;text-decoration:none;text-shadow:1px 1px 0 #528ecc;width:87%}.downloads li>a:hover{background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#629D4F),color-stop(1,#1C8D2E));background-image:-webkit-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:-moz-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:-ms-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:-o-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:linear-gradient(to bottom,#629D4F 5%,#1C8D2E 100%);background-color:#629D4F;text-decoration:none}.downloads ul{margin:0}.version{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0;color:#000}.donate{margin-top:5px}.all-downloads{padding:.2em 1em;text-align:center}.side .portlet{background:none repeat scroll 0 0 #FBFBFB;border:1px solid #DEDEDE;margin:0 auto 1em;padding:.5em}.involvement a{background:url(../img/answers-arrow-right.png) no-repeat scroll right center transparent;display:block;padding:.1em}.involvement li{font-weight:700;list-style-type:none;margin-left:0;padding:0}.involvement a:hover,.involvement li:hover{background-color:lightgray;text-decoration:none;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.author{color:silver}.logo a{float:left}.logo a:hover{background-color:inherit;text-decoration:none}::-moz-selection{background-color:#B3D4FC;text-shadow:none}::selection{background-color:#B3D4FC;text-shadow:none}footer,header,nav,section{display:block}[hidden]{display:none}html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}a{background:transparent}a:focus{outline:thin dotted}a:active,a:hover{outline:0} \ No newline at end of file +html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:0 0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}body{color:#000;font:400 14px 'Segoe UI',Segoe,'Helvetica Neue',Helvetica,Roboto,Arial,FreeSans,sans-serif}a:link,a:visited{color:#03A;text-decoration:none}a:link:hover,a:visited:hover{text-decoration:underline}code{background-color:#F7F7F9;border:1px solid #E1E1E8;color:#D14;font-family:monospace,serif;font-size:1em;padding:.5px 4px}.side .portlet,code{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}dd{margin-left:10px}dt{font-weight:700;margin:15px auto 5px}footer{margin:10px auto;text-align:center}footer ul{list-style-type:none}footer li,footer ul{margin:0;padding:0}h1{font-size:20px;font-weight:700;text-align:center}h2{font-size:18px}h3{line-height:20px;margin:16px auto 8px}.side h2,h3{font-size:16px}li{margin-left:12px;padding-bottom:.5em}nav a{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;margin-right:.4em;padding:.3em .5em}nav .active a{background-color:#dcdcdc;font-weight:700}nav a:link,nav a:visited{color:#000;text-decoration:none}nav a:hover{background-color:#d3d3d3}nav h2{clear:none;color:#000;font-size:30px;font-weight:700;line-height:34px;margin:0 auto}nav li{display:inline-block;margin:0}nav li:first-child{margin-left:-.5em}.dev ul,.portlet li,nav li{list-style-type:none}ul{padding:0}.center{text-align:center}.changelog{border:2px solid #000;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;overflow:scroll;width:800px;height:600px}.ft{font-size:12px}.forumdate{color:silver}.forumdate>.author{color:#A00}.about-li{list-style-type:none;margin-left:0;padding-top:4px}.coder{color:#A00!important}.dev{position:relative}.ohloh-kudos{position:absolute;right:0;top:10px}.ohloh-commits{bottom:0;position:absolute;right:0}.user-avatar{background:#fff;border:1px solid #E5DFC7;display:block;float:left;margin:0 10px 0 0;padding:4px}.xhmikosr{color:#00f}.page{margin:0 auto;max-width:90em;padding:0 10px 5px;position:relative}.pre-section{width:700px;margin:-20px auto 0}.main-section{clear:both;margin:auto;padding-top:1px;text-align:center;width:700px}.main-section-2{margin:auto;width:700px}.section-header{border-top:dotted 1px;font-weight:700;margin-top:40px;text-transform:uppercase}.headline{font-size:18px;margin-top:20px;text-align:center}.main-headline{margin-bottom:40px}.main-section .headline{text-align:left}.bottom-download{font-size:20px;text-align:center!important}.tip{font-size:12px;font-style:italic;margin-top:5px;text-align:left}.normal{text-align:left}.yui-d0{margin:auto;width:auto}.yui-t4{margin:auto;width:700px}.yui-b{position:relative}.yui-t4 .yui-b{float:right;width:20em}.yui-g .yui-g,.yui-g .yui-u{float:right}.yui-g .first{float:left}.yui-g .yui-g,.yui-g .yui-u{width:49.1%}.yui-g:after,.yui-t4:after{clear:both;content:".";display:block;height:0;visibility:hidden}.portlet{clear:both;padding:0 0 1em}.portlet>h2:first-child{margin:0}.portlet p{margin:5px 0}.flowed-block{display:inline-block;padding:0 0 0 10px;vertical-align:top}.facetmenu{width:100%}.downloads,.quick-links{width:250px}.downloads li{font-weight:700;margin:0;padding:2px 0 0}.downloads li>a{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 0 #BBDAF7;-moz-box-shadow:inset 0 1px 0 0 #BBDAF7;box-shadow:inset 0 1px 0 0 #BBDAF7;background-color:#1C8D2E;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#1C8D2E),color-stop(1,#629D4F));background-image:-webkit-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:-moz-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:-ms-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:-o-linear-gradient(center top,#1C8D2E 5%,#629D4F 100%);background-image:linear-gradient(to bottom,#1C8D2E 5%,#629D4F 100%);border:1px solid #1C8D2E;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;color:#fff;display:inline-block;font-weight:700;padding:.7em 1em;text-align:center;text-decoration:none;text-shadow:1px 1px 0 #528ecc;width:87%}.downloads li>a:hover{background-color:#629D4F;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#629D4F),color-stop(1,#1C8D2E));background-image:-webkit-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:-moz-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:-ms-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:-o-linear-gradient(center top,#629D4F 5%,#1C8D2E 100%);background-image:linear-gradient(to bottom,#629D4F 5%,#1C8D2E 100%);text-decoration:none}.downloads ul{margin:0}.version{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0;color:#000}.donate{margin-top:5px}.all-downloads{padding:.2em 1em;text-align:center}.side .portlet{background:none repeat scroll 0 0 #FBFBFB;border:1px solid #DEDEDE;margin:0 auto 1em;padding:.5em}.involvement a{background:url(../img/answers-arrow-right.png) no-repeat scroll right center transparent;display:block;padding:.1em}.involvement li{font-weight:700;list-style-type:none;margin-left:0;padding:0}.involvement a:hover,.involvement li:hover{background-color:#d3d3d3;text-decoration:none;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.author{color:silver}.logo a{float:left}.logo a:hover{background-color:inherit;text-decoration:none}::-moz-selection{background-color:#B3D4FC;text-shadow:none}::selection{background-color:#B3D4FC;text-shadow:none} \ No newline at end of file diff --git a/misc/website/websitev2/css/stylesheet.css b/misc/website/websitev2/css/stylesheet.css index 66651adfe..45a4ba96b 100644 --- a/misc/website/websitev2/css/stylesheet.css +++ b/misc/website/websitev2/css/stylesheet.css @@ -4,7 +4,6 @@ body { color: black; font: normal 14px 'Segoe UI', Segoe, 'Helvetica Neue', Helvetica, Roboto, Arial, FreeSans, sans-serif; - margin: 0; } a:link, @@ -18,10 +17,6 @@ a:visited:hover { text-decoration: underline; } -strong { - font-weight: bold; -} - code { background-color: #F7F7F9; border: 1px solid #E1E1E8; @@ -82,10 +77,6 @@ h3, font-size: 16px; } -img { - border: 0; -} - li { margin-left: 12px; padding-bottom: 0.5em; @@ -355,13 +346,13 @@ ul { -webkit-box-shadow: inset 0 1px 0 0 #BBDAF7; -moz-box-shadow: inset 0 1px 0 0 #BBDAF7; box-shadow: inset 0 1px 0 0 #BBDAF7; + background-color: #1C8D2E; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1C8D2E), color-stop(1, #629D4F)); /* Chrome, Safari4+ */ background-image: -webkit-linear-gradient(center top, #1C8D2E 5%, #629D4F 100%); /* Chrome10+, Safari5.1+ */ background-image: -moz-linear-gradient(center top, #1C8D2E 5%, #629D4F 100%); /* FF3.6+ */ background-image: -ms-linear-gradient(center top, #1C8D2E 5%, #629D4F 100%); /* IE10+ */ background-image: -o-linear-gradient(center top, #1C8D2E 5%, #629D4F 100%); /* Opera 11.10+ */ background-image: linear-gradient(to bottom, #1C8D2E 5%, #629D4F 100%); /* W3C */ - background-color: #1C8D2E; border: 1px solid #1C8D2E; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; @@ -377,13 +368,13 @@ ul { } .downloads li > a:hover { + background-color: #629D4F; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #629D4F), color-stop(1, #1C8D2E)); /* Chrome, Safari4+ */ background-image: -webkit-linear-gradient(center top, #629D4F 5%, #1C8D2E 100%); /* Chrome10+, Safari5.1+ */ background-image: -moz-linear-gradient(center top, #629D4F 5%, #1C8D2E 100%); /* FF3.6+ */ background-image: -ms-linear-gradient(center top, #629D4F 5%, #1C8D2E 100%); /* IE10+ */ background-image: -o-linear-gradient(center top, #629D4F 5%, #1C8D2E 100%); /* Opera 11.10+ */ background-image: linear-gradient(to bottom, #629D4F 5%, #1C8D2E 100%); /* W3C */ - background-color: #629D4F; text-decoration: none; } diff --git a/misc/website/websitev2/downloads.php b/misc/website/websitev2/downloads.php index 1d1e6dc28..4baa3148b 100644 --- a/misc/website/websitev2/downloads.php +++ b/misc/website/websitev2/downloads.php @@ -38,7 +38,6 @@

      The latest stable version of Process Hacker is . - The ReactOS Foundation has very kindly signed the driver for 64-bit systems.

      diff --git a/misc/website/websitev2/error.php b/misc/website/websitev2/error.php index 069c0f30b..7a717f646 100644 --- a/misc/website/websitev2/error.php +++ b/misc/website/websitev2/error.php @@ -56,7 +56,7 @@ function curPageURL()
    - +

    ERROR :

    Please notify the team about this error or try again later.

    diff --git a/misc/website/websitev2/faq.php b/misc/website/websitev2/faq.php index c3ab008a6..8fb9543f9 100644 --- a/misc/website/websitev2/faq.php +++ b/misc/website/websitev2/faq.php @@ -12,7 +12,6 @@ -

    Process Hacker

      @@ -102,46 +101,49 @@
      No. Please read about the correct definition of "hacker".
      Why is Process Hacker able to kill processes that no other tools can kill?
      -
      Process Hacker loads a driver that searches memory for an internal kernel function and calls it. This special function is not known to be hooked by +
      Process Hacker loads a driver that searches memory for an internal Microsoft kernel function and calls it. This special function is not known to be hooked by any malware and security software.
      +
      Process Hacker can kill my anti-virus software! Is this a bug in the anti-virus software?
      +
      No. Please do not report these incidents as bugs because you will be wasting their time.
      +
      Symbols don't work properly!
      Firstly, you need the latest dbghelp.dll version:

      1) Install the latest Windows SDK. (links are below)
      2) Open Process Hacker options via the main menu: Hacker > Options
      - 3) Click Symbols, and locatedbghelp.dll
      + 3) Click Symbols, and locate dbghelp.dll
      - It is usually in C:\Program Files\Debugging Tools for Windows (x86)\ - or if you're using the Windows 8 SDK it'll be located at \Program Files (x86)\Windows Kits\8.0\Debuggers\x86\ for 32bit users - or at \Program Files (x86)\Windows Kits\8.0\Debuggers\x64\ for 64bit users.
      + Windows XP, Vista and Windows 7 SDK:
      + C:\Program Files\Debugging Tools for Windows (x86)\

      + Windows 8 or above SDK:
      + 32bit: \Program Files (x86)\Windows Kits\8.x\Debuggers\x86\
      + 64bit: \Program Files (x86)\Windows Kits\8.x\Debuggers\x64\
      - Secondly, you need to configure the search path:
      - If you don't know what to do, enter SRV*SOME_FOLDER*http://msdl.microsoft.com/download/symbols. + Secondly, you need to configure the search path. If you don't know what to do, enter:
      + SRV*SOME_FOLDER*http://msdl.microsoft.com/download/symbols

      Replace SOME_FOLDER with any folder you can write to, like D:\Symbols. Now you can restart Process Hacker and view full symbols.
      -
      Process Hacker can kill my anti-virus software! Is this a bug in the anti-virus software?
      -
      No. Please do not report these incidents as bugs because you will be wasting their time.
      - -
      Anti-cheat software reports Process Hacker as a game cheating tool!
      -
      Unfortunately there is nothing much that can be done about this.
      -
      Why can't I build Process Hacker?
      The most likely problem is that you do not have the latest Windows SDK installed.
      - For Windows XP, Vista and Windows 7 you'll need the - Windows SDK for Windows 7 and .NET Framework 4.
      - For Windows Vista, Windows 7 and Windows 8 you'll need the - Windows 8 SDK. + Windows XP, Vista and Windows 7 SDK: Windows SDK
      + Windows 7, Windows 8 SDK: Windows 8 SDK
      + Windows 7, Windows 8 and 8.1 SDK: Windows 8.1 SDK
      + +
      Anti-cheat software reports Process Hacker as a game cheating tool!
      +
      Unfortunately there is nothing much that can be done about this.
      + +
      How do I report issues with Anti-cheat software?
      +
      Contact dmex
    -
    diff --git a/misc/website/websitev2/footer.php b/misc/website/websitev2/footer.php index a5bfa33d9..42658b09f 100644 --- a/misc/website/websitev2/footer.php +++ b/misc/website/websitev2/footer.php @@ -6,7 +6,7 @@
  • Privacy Policy
  • -
  • Copyright © 2008-2013 wj32
  • +
  • Copyright © 2008-2013 Wen Jia Liu (wj32)
= 0 ? '+' : '-'; + return sign + leftZeroFill(Math.abs(y), 6); + }, gg : function () { return leftZeroFill(this.weekYear() % 100, 2); }, gggg : function () { - return this.weekYear(); + return leftZeroFill(this.weekYear(), 4); }, ggggg : function () { return leftZeroFill(this.weekYear(), 5); @@ -140,7 +204,7 @@ return leftZeroFill(this.isoWeekYear() % 100, 2); }, GGGG : function () { - return this.isoWeekYear(); + return leftZeroFill(this.isoWeekYear(), 4); }, GGGGG : function () { return leftZeroFill(this.isoWeekYear(), 5); @@ -170,14 +234,17 @@ return this.seconds(); }, S : function () { - return ~~(this.milliseconds() / 100); + return toInt(this.milliseconds() / 100); }, SS : function () { - return leftZeroFill(~~(this.milliseconds() / 10), 2); + return leftZeroFill(toInt(this.milliseconds() / 10), 2); }, SSS : function () { return leftZeroFill(this.milliseconds(), 3); }, + SSSS : function () { + return leftZeroFill(this.milliseconds(), 3); + }, Z : function () { var a = -this.zone(), b = "+"; @@ -185,7 +252,7 @@ a = -a; b = "-"; } - return b + leftZeroFill(~~(a / 60), 2) + ":" + leftZeroFill(~~a % 60, 2); + return b + leftZeroFill(toInt(a / 60), 2) + ":" + leftZeroFill(toInt(a) % 60, 2); }, ZZ : function () { var a = -this.zone(), @@ -194,7 +261,7 @@ a = -a; b = "-"; } - return b + leftZeroFill(~~(10 * a / 6), 4); + return b + leftZeroFill(toInt(a / 60), 2) + leftZeroFill(toInt(a) % 60, 2); }, z : function () { return this.zoneAbbr(); @@ -204,8 +271,30 @@ }, X : function () { return this.unix(); + }, + Q : function () { + return this.quarter(); } + }, + + lists = ['months', 'monthsShort', 'weekdays', 'weekdaysShort', 'weekdaysMin']; + + function defaultParsingFlags() { + // We need to deep clone this object, and es5 standard is not very + // helpful. + return { + empty : false, + unusedTokens : [], + unusedInput : [], + overflow : -2, + charsLeftOver : 0, + nullInput : false, + invalidMonth : null, + invalidFormat : false, + userInvalidated : false, + iso: false }; + } function padToken(func, count) { return function (a) { @@ -239,36 +328,35 @@ // Moment prototype object function Moment(config) { + checkOverflow(config); extend(this, config); } // Duration Constructor function Duration(duration) { - var years = duration.years || duration.year || duration.y || 0, - months = duration.months || duration.month || duration.M || 0, - weeks = duration.weeks || duration.week || duration.w || 0, - days = duration.days || duration.day || duration.d || 0, - hours = duration.hours || duration.hour || duration.h || 0, - minutes = duration.minutes || duration.minute || duration.m || 0, - seconds = duration.seconds || duration.second || duration.s || 0, - milliseconds = duration.milliseconds || duration.millisecond || duration.ms || 0; - - // store reference to input for deterministic cloning - this._input = duration; + var normalizedInput = normalizeObjectUnits(duration), + years = normalizedInput.year || 0, + months = normalizedInput.month || 0, + weeks = normalizedInput.week || 0, + days = normalizedInput.day || 0, + hours = normalizedInput.hour || 0, + minutes = normalizedInput.minute || 0, + seconds = normalizedInput.second || 0, + milliseconds = normalizedInput.millisecond || 0; // representation for dateAddRemove - this._milliseconds = milliseconds + + this._milliseconds = +milliseconds + seconds * 1e3 + // 1000 minutes * 6e4 + // 1000 * 60 hours * 36e5; // 1000 * 60 * 60 // Because of dateAddRemove treats 24 hours as different from a // day when working around DST, we need to store them separately - this._days = days + + this._days = +days + weeks * 7; // It is impossible translate months into days without knowing // which months you are are talking about, so we have to store // it separately. - this._months = months + + this._months = +months + years * 12; this._data = {}; @@ -276,7 +364,6 @@ this._bubble(); } - /************************************ Helpers ************************************/ @@ -288,9 +375,29 @@ a[i] = b[i]; } } + + if (b.hasOwnProperty("toString")) { + a.toString = b.toString; + } + + if (b.hasOwnProperty("valueOf")) { + a.valueOf = b.valueOf; + } + return a; } + function cloneMoment(m) { + var result = {}, i; + for (i in m) { + if (m.hasOwnProperty(i) && momentProperties.hasOwnProperty(i)) { + result[i] = m[i]; + } + } + + return result; + } + function absRound(number) { if (number < 0) { return Math.ceil(number); @@ -301,12 +408,14 @@ // left zero fill a number // see http://jsperf.com/left-zero-filling for performance comparison - function leftZeroFill(number, targetLength) { - var output = number + ''; + function leftZeroFill(number, targetLength, forceSign) { + var output = '' + Math.abs(number), + sign = number >= 0; + while (output.length < targetLength) { output = '0' + output; } - return output; + return (sign ? (forceSign ? '+' : '') : '-') + output; } // helper function for _.addTime and _.subtractTime @@ -315,8 +424,7 @@ days = duration._days, months = duration._months, minutes, - hours, - currentDate; + hours; if (milliseconds) { mom._d.setTime(+mom._d + milliseconds * isAdding); @@ -347,14 +455,20 @@ return Object.prototype.toString.call(input) === '[object Array]'; } + function isDate(input) { + return Object.prototype.toString.call(input) === '[object Date]' || + input instanceof Date; + } + // compare two arrays, return the number of differences - function compareArrays(array1, array2) { + function compareArrays(array1, array2, dontConvert) { var len = Math.min(array1.length, array2.length), lengthDiff = Math.abs(array1.length - array2.length), diffs = 0, i; for (i = 0; i < len; i++) { - if (~~array1[i] !== ~~array2[i]) { + if ((dontConvert && array1[i] !== array2[i]) || + (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { diffs++; } } @@ -362,16 +476,155 @@ } function normalizeUnits(units) { - return units ? unitAliases[units] || units.toLowerCase().replace(/(.)s$/, '$1') : units; + if (units) { + var lowered = units.toLowerCase().replace(/(.)s$/, '$1'); + units = unitAliases[units] || camelFunctions[lowered] || lowered; + } + return units; } + function normalizeObjectUnits(inputObject) { + var normalizedInput = {}, + normalizedProp, + prop; + + for (prop in inputObject) { + if (inputObject.hasOwnProperty(prop)) { + normalizedProp = normalizeUnits(prop); + if (normalizedProp) { + normalizedInput[normalizedProp] = inputObject[prop]; + } + } + } + + return normalizedInput; + } + + function makeList(field) { + var count, setter; + + if (field.indexOf('week') === 0) { + count = 7; + setter = 'day'; + } + else if (field.indexOf('month') === 0) { + count = 12; + setter = 'month'; + } + else { + return; + } + + moment[field] = function (format, index) { + var i, getter, + method = moment.fn._lang[field], + results = []; + + if (typeof format === 'number') { + index = format; + format = undefined; + } + + getter = function (i) { + var m = moment().utc().set(setter, i); + return method.call(moment.fn._lang, m, format || ''); + }; + + if (index != null) { + return getter(index); + } + else { + for (i = 0; i < count; i++) { + results.push(getter(i)); + } + return results; + } + }; + } + + function toInt(argumentForCoercion) { + var coercedNumber = +argumentForCoercion, + value = 0; + + if (coercedNumber !== 0 && isFinite(coercedNumber)) { + if (coercedNumber >= 0) { + value = Math.floor(coercedNumber); + } else { + value = Math.ceil(coercedNumber); + } + } + + return value; + } + + function daysInMonth(year, month) { + return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); + } + + function daysInYear(year) { + return isLeapYear(year) ? 366 : 365; + } + + function isLeapYear(year) { + return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + } + + function checkOverflow(m) { + var overflow; + if (m._a && m._pf.overflow === -2) { + overflow = + m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH : + m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE : + m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR : + m._a[MINUTE] < 0 || m._a[MINUTE] > 59 ? MINUTE : + m._a[SECOND] < 0 || m._a[SECOND] > 59 ? SECOND : + m._a[MILLISECOND] < 0 || m._a[MILLISECOND] > 999 ? MILLISECOND : + -1; + + if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { + overflow = DATE; + } + + m._pf.overflow = overflow; + } + } + + function isValid(m) { + if (m._isValid == null) { + m._isValid = !isNaN(m._d.getTime()) && + m._pf.overflow < 0 && + !m._pf.empty && + !m._pf.invalidMonth && + !m._pf.nullInput && + !m._pf.invalidFormat && + !m._pf.userInvalidated; + + if (m._strict) { + m._isValid = m._isValid && + m._pf.charsLeftOver === 0 && + m._pf.unusedTokens.length === 0; + } + } + return m._isValid; + } + + function normalizeLanguage(key) { + return key ? key.toLowerCase().replace('_', '-') : key; + } + + // Return a moment from input, that is local/utc/zone equivalent to model. + function makeAs(input, model) { + return model._isUTC ? moment(input).zone(model._offset || 0) : + moment(input).local(); + } /************************************ Languages ************************************/ - Language.prototype = { + extend(Language.prototype, { + set : function (config) { var prop, i; for (i in config) { @@ -404,7 +657,7 @@ for (i = 0; i < 12; i++) { // make the regex if we don't have it already if (!this._monthsParse[i]) { - mom = moment([2000, i]); + mom = moment.utc([2000, i]); regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); } @@ -470,7 +723,9 @@ }, isPM : function (input) { - return ((input + '').toLowerCase()[0] === 'p'); + // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays + // Using charAt should be more compatible. + return ((input + '').toLowerCase().charAt(0) === 'p'); }, _meridiemParse : /[ap]\.?m?\.?/i, @@ -537,11 +792,17 @@ week : function (mom) { return weekOfYear(mom, this._week.dow, this._week.doy).week; }, + _week : { dow : 0, // Sunday is the first day of the week. doy : 6 // The week that contains Jan 1st is the first week of the year. + }, + + _invalidDate: 'Invalid date', + invalidDate: function () { + return this._invalidDate; } - }; + }); // Loads a language definition into the `languages` cache. The function // takes a key and optionally values. If not in the browser and no values @@ -556,6 +817,11 @@ return languages[key]; } + // Remove a language from the `languages` cache. Mostly useful in tests. + function unloadLang(key) { + delete languages[key]; + } + // Determines which language definition to use and returns it. // // With no parameters, it will return the global language. If you @@ -563,20 +829,52 @@ // definition for 'en', so long as 'en' has already been loaded using // moment.lang. function getLangDefinition(key) { + var i = 0, j, lang, next, split, + get = function (k) { + if (!languages[k] && hasModule) { + try { + require('./lang/' + k); + } catch (e) { } + } + return languages[k]; + }; + if (!key) { return moment.fn._lang; } - if (!languages[key] && hasModule) { - try { - require('./lang/' + key); - } catch (e) { - // call with no params to set to default - return moment.fn._lang; + + if (!isArray(key)) { + //short-circuit everything else + lang = get(key); + if (lang) { + return lang; } + key = [key]; } - return languages[key]; - } + //pick the language from the array + //try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each + //substring from most specific to least, but move to the next array item if it's a more specific variant than the current root + while (i < key.length) { + split = normalizeLanguage(key[i]).split('-'); + j = split.length; + next = normalizeLanguage(key[i + 1]); + next = next ? next.split('-') : null; + while (j > 0) { + lang = get(split.slice(0, j).join('-')); + if (lang) { + return lang; + } + if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { + //the next array item is better than a shallower substring of this one + break; + } + j--; + } + i++; + } + return moment.fn._lang; + } /************************************ Formatting @@ -584,7 +882,7 @@ function removeFormattingTokens(input) { - if (input.match(/\[.*\]/)) { + if (input.match(/\[[\s\S]/)) { return input.replace(/^\[|\]$/g, ""); } return input.replace(/\\/g, ""); @@ -612,15 +910,12 @@ // format date using native date object function formatMoment(m, format) { - var i = 5; - function replaceLongDateFormatTokens(input) { - return m.lang().longDateFormat(input) || input; + if (!m.isValid()) { + return m.lang().invalidDate(); } - while (i-- && localFormattingTokens.test(format)) { - format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); - } + format = expandFormat(format, m.lang()); if (!formatFunctions[format]) { formatFunctions[format] = makeFormatFunction(format); @@ -629,6 +924,23 @@ return formatFunctions[format](m); } + function expandFormat(format, lang) { + var i = 5; + + function replaceLongDateFormatTokens(input) { + return lang.longDateFormat(input) || input; + } + + localFormattingTokens.lastIndex = 0; + while (i >= 0 && localFormattingTokens.test(format)) { + format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); + localFormattingTokens.lastIndex = 0; + i -= 1; + } + + return format; + } + /************************************ Parsing @@ -637,16 +949,32 @@ // get the regex to find the next token function getParseRegexForToken(token, config) { + var a, strict = config._strict; switch (token) { case 'DDDD': return parseTokenThreeDigits; case 'YYYY': - return parseTokenFourDigits; + case 'GGGG': + case 'gggg': + return strict ? parseTokenFourDigits : parseTokenOneToFourDigits; + case 'Y': + case 'G': + case 'g': + return parseTokenSignedNumber; + case 'YYYYYY': case 'YYYYY': - return parseTokenSixDigits; + case 'GGGGG': + case 'ggggg': + return strict ? parseTokenSixDigits : parseTokenOneToSixDigits; case 'S': + if (strict) { return parseTokenOneDigit; } + /* falls through */ case 'SS': + if (strict) { return parseTokenTwoDigits; } + /* falls through */ case 'SSS': + if (strict) { return parseTokenThreeDigits; } + /* falls through */ case 'DDD': return parseTokenOneToThreeDigits; case 'MMM': @@ -665,13 +993,20 @@ return parseTokenTimezone; case 'T': return parseTokenT; + case 'SSSS': + return parseTokenDigits; case 'MM': case 'DD': case 'YY': + case 'GG': + case 'gg': case 'HH': case 'hh': case 'mm': case 'ss': + case 'ww': + case 'WW': + return strict ? parseTokenTwoDigits : parseTokenOneOrTwoDigits; case 'M': case 'D': case 'd': @@ -679,16 +1014,23 @@ case 'h': case 'm': case 's': + case 'w': + case 'W': + case 'e': + case 'E': return parseTokenOneOrTwoDigits; default : - return new RegExp(token.replace('\\', '')); + a = new RegExp(regexpEscape(unescapeFormat(token.replace('\\', '')), "i")); + return a; } } function timezoneMinutesFromString(string) { - var tzchunk = (parseTokenTimezone.exec(string) || [])[0], - parts = (tzchunk + '').match(parseTimezoneChunker) || ['-', 0, 0], - minutes = +(parts[1] * 60) + ~~parts[2]; + string = string || ""; + var possibleTzMatches = (string.match(parseTokenTimezone) || []), + tzChunk = possibleTzMatches[possibleTzMatches.length - 1] || [], + parts = (tzChunk + '').match(parseTimezoneChunker) || ['-', 0, 0], + minutes = +(parts[1] * 60) + toInt(parts[2]); return parts[0] === '+' ? -minutes : minutes; } @@ -701,34 +1043,43 @@ // MONTH case 'M' : // fall through to MM case 'MM' : - datePartArray[1] = (input == null) ? 0 : ~~input - 1; + if (input != null) { + datePartArray[MONTH] = toInt(input) - 1; + } break; case 'MMM' : // fall through to MMMM case 'MMMM' : a = getLangDefinition(config._l).monthsParse(input); // if we didn't find a month name, mark the date as invalid. if (a != null) { - datePartArray[1] = a; + datePartArray[MONTH] = a; } else { - config._isValid = false; + config._pf.invalidMonth = input; } break; // DAY OF MONTH - case 'D' : // fall through to DDDD - case 'DD' : // fall through to DDDD + case 'D' : // fall through to DD + case 'DD' : + if (input != null) { + datePartArray[DATE] = toInt(input); + } + break; + // DAY OF YEAR case 'DDD' : // fall through to DDDD case 'DDDD' : if (input != null) { - datePartArray[2] = ~~input; + config._dayOfYear = toInt(input); } + break; // YEAR case 'YY' : - datePartArray[0] = ~~input + (~~input > 68 ? 1900 : 2000); + datePartArray[YEAR] = toInt(input) + (toInt(input) > 68 ? 1900 : 2000); break; case 'YYYY' : case 'YYYYY' : - datePartArray[0] = ~~input; + case 'YYYYYY' : + datePartArray[YEAR] = toInt(input); break; // AM / PM case 'a' : // fall through to A @@ -740,23 +1091,24 @@ case 'HH' : // fall through to hh case 'h' : // fall through to hh case 'hh' : - datePartArray[3] = ~~input; + datePartArray[HOUR] = toInt(input); break; // MINUTE case 'm' : // fall through to mm case 'mm' : - datePartArray[4] = ~~input; + datePartArray[MINUTE] = toInt(input); break; // SECOND case 's' : // fall through to ss case 'ss' : - datePartArray[5] = ~~input; + datePartArray[SECOND] = toInt(input); break; // MILLISECOND case 'S' : case 'SS' : case 'SSS' : - datePartArray[6] = ~~ (('0.' + input) * 1000); + case 'SSSS' : + datePartArray[MILLISECOND] = toInt(('0.' + input) * 1000); break; // UNIX TIMESTAMP WITH MS case 'X': @@ -768,11 +1120,29 @@ config._useUTC = true; config._tzm = timezoneMinutesFromString(input); break; - } - - // if the input is null, the date is not valid - if (input == null) { - config._isValid = false; + case 'w': + case 'ww': + case 'W': + case 'WW': + case 'd': + case 'dd': + case 'ddd': + case 'dddd': + case 'e': + case 'E': + token = token.substr(0, 1); + /* falls through */ + case 'gg': + case 'gggg': + case 'GG': + case 'GGGG': + case 'GGGGG': + token = token.substr(0, 2); + if (input) { + config._w = config._w || {}; + config._w[token] = input; + } + break; } } @@ -780,124 +1150,257 @@ // the array should mirror the parameters below // note: all values past the year are optional and will default to the lowest possible value. // [year, month, day , hour, minute, second, millisecond] - function dateFromArray(config) { - var i, date, input = []; + function dateFromConfig(config) { + var i, date, input = [], currentDate, + yearToUse, fixYear, w, temp, lang, weekday, week; if (config._d) { return; } - for (i = 0; i < 7; i++) { + currentDate = currentDateArray(config); + + //compute day of the year from weeks and weekdays + if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { + fixYear = function (val) { + var int_val = parseInt(val, 10); + return val ? + (val.length < 3 ? (int_val > 68 ? 1900 + int_val : 2000 + int_val) : int_val) : + (config._a[YEAR] == null ? moment().weekYear() : config._a[YEAR]); + }; + + w = config._w; + if (w.GG != null || w.W != null || w.E != null) { + temp = dayOfYearFromWeeks(fixYear(w.GG), w.W || 1, w.E, 4, 1); + } + else { + lang = getLangDefinition(config._l); + weekday = w.d != null ? parseWeekday(w.d, lang) : + (w.e != null ? parseInt(w.e, 10) + lang._week.dow : 0); + + week = parseInt(w.w, 10) || 1; + + //if we're parsing 'd', then the low day numbers may be next week + if (w.d != null && weekday < lang._week.dow) { + week++; + } + + temp = dayOfYearFromWeeks(fixYear(w.gg), week, weekday, lang._week.doy, lang._week.dow); + } + + config._a[YEAR] = temp.year; + config._dayOfYear = temp.dayOfYear; + } + + //if the day of the year is set, figure out what it is + if (config._dayOfYear) { + yearToUse = config._a[YEAR] == null ? currentDate[YEAR] : config._a[YEAR]; + + if (config._dayOfYear > daysInYear(yearToUse)) { + config._pf._overflowDayOfYear = true; + } + + date = makeUTCDate(yearToUse, 0, config._dayOfYear); + config._a[MONTH] = date.getUTCMonth(); + config._a[DATE] = date.getUTCDate(); + } + + // Default to current date. + // * if no year, month, day of month are given, default to today + // * if day of month is given, default month and year + // * if month is given, default only year + // * if year is given, don't default anything + for (i = 0; i < 3 && config._a[i] == null; ++i) { + config._a[i] = input[i] = currentDate[i]; + } + + // Zero out whatever was not defaulted, including time + for (; i < 7; i++) { config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; } // add the offsets to the time to be parsed so that we can have a clean array for checking isValid - input[3] += ~~((config._tzm || 0) / 60); - input[4] += ~~((config._tzm || 0) % 60); + input[HOUR] += toInt((config._tzm || 0) / 60); + input[MINUTE] += toInt((config._tzm || 0) % 60); + + config._d = (config._useUTC ? makeUTCDate : makeDate).apply(null, input); + } - date = new Date(0); + function dateFromObject(config) { + var normalizedInput; + if (config._d) { + return; + } + + normalizedInput = normalizeObjectUnits(config._i); + config._a = [ + normalizedInput.year, + normalizedInput.month, + normalizedInput.day, + normalizedInput.hour, + normalizedInput.minute, + normalizedInput.second, + normalizedInput.millisecond + ]; + + dateFromConfig(config); + } + + function currentDateArray(config) { + var now = new Date(); if (config._useUTC) { - date.setUTCFullYear(input[0], input[1], input[2]); - date.setUTCHours(input[3], input[4], input[5], input[6]); + return [ + now.getUTCFullYear(), + now.getUTCMonth(), + now.getUTCDate() + ]; } else { - date.setFullYear(input[0], input[1], input[2]); - date.setHours(input[3], input[4], input[5], input[6]); + return [now.getFullYear(), now.getMonth(), now.getDate()]; } - - config._d = date; } // date from string and format string function makeDateFromStringAndFormat(config) { - // This array is used to make a Date, either with `new Date` or `Date.UTC` - var tokens = config._f.match(formattingTokens), - string = config._i, - i, parsedInput; config._a = []; + config._pf.empty = true; + + // This array is used to make a Date, either with `new Date` or `Date.UTC` + var lang = getLangDefinition(config._l), + string = '' + config._i, + i, parsedInput, tokens, token, skipped, + stringLength = string.length, + totalParsedInputLength = 0; + + tokens = expandFormat(config._f, lang).match(formattingTokens) || []; for (i = 0; i < tokens.length; i++) { - parsedInput = (getParseRegexForToken(tokens[i], config).exec(string) || [])[0]; + token = tokens[i]; + parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; if (parsedInput) { + skipped = string.substr(0, string.indexOf(parsedInput)); + if (skipped.length > 0) { + config._pf.unusedInput.push(skipped); + } string = string.slice(string.indexOf(parsedInput) + parsedInput.length); + totalParsedInputLength += parsedInput.length; } - // don't parse if its not a known token - if (formatTokenFunctions[tokens[i]]) { - addTimeToArrayFromToken(tokens[i], parsedInput, config); + // don't parse if it's not a known token + if (formatTokenFunctions[token]) { + if (parsedInput) { + config._pf.empty = false; + } + else { + config._pf.unusedTokens.push(token); + } + addTimeToArrayFromToken(token, parsedInput, config); + } + else if (config._strict && !parsedInput) { + config._pf.unusedTokens.push(token); } } - // add remaining unparsed input to the string - if (string) { - config._il = string; + // add remaining unparsed input length to the string + config._pf.charsLeftOver = stringLength - totalParsedInputLength; + if (string.length > 0) { + config._pf.unusedInput.push(string); } // handle am pm - if (config._isPm && config._a[3] < 12) { - config._a[3] += 12; + if (config._isPm && config._a[HOUR] < 12) { + config._a[HOUR] += 12; } // if is 12 am, change hours to 0 - if (config._isPm === false && config._a[3] === 12) { - config._a[3] = 0; + if (config._isPm === false && config._a[HOUR] === 12) { + config._a[HOUR] = 0; } - // return - dateFromArray(config); + + dateFromConfig(config); + checkOverflow(config); + } + + function unescapeFormat(s) { + return s.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { + return p1 || p2 || p3 || p4; + }); + } + + // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript + function regexpEscape(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } // date from string and array of format strings function makeDateFromStringAndArray(config) { var tempConfig, - tempMoment, bestMoment, - scoreToBeat = 99, + scoreToBeat, i, currentScore; + if (config._f.length === 0) { + config._pf.invalidFormat = true; + config._d = new Date(NaN); + return; + } + for (i = 0; i < config._f.length; i++) { + currentScore = 0; tempConfig = extend({}, config); + tempConfig._pf = defaultParsingFlags(); tempConfig._f = config._f[i]; makeDateFromStringAndFormat(tempConfig); - tempMoment = new Moment(tempConfig); - - currentScore = compareArrays(tempConfig._a, tempMoment.toArray()); - // if there is any input that was not parsed - // add a penalty for that format - if (tempMoment._il) { - currentScore += tempMoment._il.length; + if (!isValid(tempConfig)) { + continue; } - if (currentScore < scoreToBeat) { + // if there is any input that was not parsed add a penalty for that format + currentScore += tempConfig._pf.charsLeftOver; + + //or tokens + currentScore += tempConfig._pf.unusedTokens.length * 10; + + tempConfig._pf.score = currentScore; + + if (scoreToBeat == null || currentScore < scoreToBeat) { scoreToBeat = currentScore; - bestMoment = tempMoment; + bestMoment = tempConfig; } } - extend(config, bestMoment); + extend(config, bestMoment || tempConfig); } // date from iso format function makeDateFromString(config) { - var i, + var i, l, string = config._i, match = isoRegex.exec(string); if (match) { - // match[2] should be "T" or undefined - config._f = 'YYYY-MM-DD' + (match[2] || " "); - for (i = 0; i < 4; i++) { + config._pf.iso = true; + for (i = 0, l = isoDates.length; i < l; i++) { + if (isoDates[i][1].exec(string)) { + // match[5] should be "T" or undefined + config._f = isoDates[i][0] + (match[6] || " "); + break; + } + } + for (i = 0, l = isoTimes.length; i < l; i++) { if (isoTimes[i][1].exec(string)) { config._f += isoTimes[i][0]; break; } } - if (parseTokenTimezone.exec(string)) { - config._f += " Z"; + if (string.match(parseTokenTimezone)) { + config._f += "Z"; } makeDateFromStringAndFormat(config); - } else { + } + else { config._d = new Date(string); } } @@ -914,12 +1417,50 @@ makeDateFromString(config); } else if (isArray(input)) { config._a = input.slice(0); - dateFromArray(config); + dateFromConfig(config); + } else if (isDate(input)) { + config._d = new Date(+input); + } else if (typeof(input) === 'object') { + dateFromObject(config); } else { - config._d = input instanceof Date ? new Date(+input) : new Date(input); + config._d = new Date(input); + } + } + + function makeDate(y, m, d, h, M, s, ms) { + //can't just apply() to create a date: + //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply + var date = new Date(y, m, d, h, M, s, ms); + + //the date constructor doesn't accept years < 1970 + if (y < 1970) { + date.setFullYear(y); } + return date; } + function makeUTCDate(y) { + var date = new Date(Date.UTC.apply(null, arguments)); + if (y < 1970) { + date.setUTCFullYear(y); + } + return date; + } + + function parseWeekday(input, language) { + if (typeof input === 'string') { + if (!isNaN(input)) { + input = parseInt(input, 10); + } + else { + input = language.weekdaysParse(input); + if (typeof input !== 'number') { + return null; + } + } + } + return input; + } /************************************ Relative Time @@ -987,6 +1528,19 @@ }; } + //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday + function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) { + var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear; + + weekday = weekday != null ? weekday : firstDayOfWeek; + daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0); + dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1; + + return { + year: dayOfYear > 0 ? year : year - 1, + dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear + }; + } /************************************ Top Level Functions @@ -996,8 +1550,8 @@ var input = config._i, format = config._f; - if (input === null || input === '') { - return null; + if (input === null) { + return moment.invalid({nullInput: true}); } if (typeof input === 'string') { @@ -1005,7 +1559,8 @@ } if (moment.isMoment(input)) { - config = extend({}, input); + config = cloneMoment(input); + config._d = new Date(+input._d); } else if (format) { if (isArray(format)) { @@ -1020,24 +1575,48 @@ return new Moment(config); } - moment = function (input, format, lang) { - return makeMoment({ - _i : input, - _f : format, - _l : lang, - _isUTC : false - }); + moment = function (input, format, lang, strict) { + var c; + + if (typeof(lang) === "boolean") { + strict = lang; + lang = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._i = input; + c._f = format; + c._l = lang; + c._strict = strict; + c._isUTC = false; + c._pf = defaultParsingFlags(); + + return makeMoment(c); }; // creating with utc - moment.utc = function (input, format, lang) { - return makeMoment({ - _useUTC : true, - _isUTC : true, - _l : lang, - _i : input, - _f : format - }); + moment.utc = function (input, format, lang, strict) { + var c; + + if (typeof(lang) === "boolean") { + strict = lang; + lang = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c = {}; + c._isAMomentObject = true; + c._useUTC = true; + c._isUTC = true; + c._l = lang; + c._i = input; + c._f = format; + c._strict = strict; + c._pf = defaultParsingFlags(); + + return makeMoment(c).utc(); }; // creating with unix timestamp (in seconds) @@ -1047,34 +1626,60 @@ // duration moment.duration = function (input, key) { - var isDuration = moment.isDuration(input), - isNumber = (typeof input === 'number'), - duration = (isDuration ? input._input : (isNumber ? {} : input)), - matched = aspNetTimeSpanJsonRegex.exec(input), + var duration = input, + // matching against regexp is expensive, do it on demand + match = null, sign, - ret; + ret, + parseIso; - if (isNumber) { + if (moment.isDuration(input)) { + duration = { + ms: input._milliseconds, + d: input._days, + M: input._months + }; + } else if (typeof input === 'number') { + duration = {}; if (key) { duration[key] = input; } else { duration.milliseconds = input; } - } else if (matched) { - sign = (matched[1] === "-") ? -1 : 1; + } else if (!!(match = aspNetTimeSpanJsonRegex.exec(input))) { + sign = (match[1] === "-") ? -1 : 1; duration = { y: 0, - d: ~~matched[2] * sign, - h: ~~matched[3] * sign, - m: ~~matched[4] * sign, - s: ~~matched[5] * sign, - ms: ~~matched[6] * sign + d: toInt(match[DATE]) * sign, + h: toInt(match[HOUR]) * sign, + m: toInt(match[MINUTE]) * sign, + s: toInt(match[SECOND]) * sign, + ms: toInt(match[MILLISECOND]) * sign + }; + } else if (!!(match = isoDurationRegex.exec(input))) { + sign = (match[1] === "-") ? -1 : 1; + parseIso = function (inp) { + // We'd normally use ~~inp for this, but unfortunately it also + // converts floats to ints. + // inp may be undefined, so careful calling replace on it. + var res = inp && parseFloat(inp.replace(',', '.')); + // apply sign while we're at it + return (isNaN(res) ? 0 : res) * sign; + }; + duration = { + y: parseIso(match[2]), + M: parseIso(match[3]), + d: parseIso(match[4]), + h: parseIso(match[5]), + m: parseIso(match[6]), + s: parseIso(match[7]), + w: parseIso(match[8]) }; } ret = new Duration(duration); - if (isDuration && input.hasOwnProperty('_lang')) { + if (moment.isDuration(input) && input.hasOwnProperty('_lang')) { ret._lang = input._lang; } @@ -1095,15 +1700,20 @@ // no arguments are passed in, it will simply return the current global // language key. moment.lang = function (key, values) { + var r; if (!key) { return moment.fn._lang._abbr; } if (values) { - loadLang(key, values); + loadLang(normalizeLanguage(key), values); + } else if (values === null) { + unloadLang(key); + key = 'en'; } else if (!languages[key]) { getLangDefinition(key); } - moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key); + r = moment.duration.fn._lang = moment.fn._lang = getLangDefinition(key); + return r._abbr; }; // returns language data @@ -1116,7 +1726,8 @@ // compare moment object moment.isMoment = function (obj) { - return obj instanceof Moment; + return obj instanceof Moment || + (obj != null && obj.hasOwnProperty('_isAMomentObject')); }; // for typechecking Duration objects @@ -1124,13 +1735,36 @@ return obj instanceof Duration; }; + for (i = lists.length - 1; i >= 0; --i) { + makeList(lists[i]); + } + + moment.normalizeUnits = function (units) { + return normalizeUnits(units); + }; + + moment.invalid = function (flags) { + var m = moment.utc(NaN); + if (flags != null) { + extend(m._pf, flags); + } + else { + m._pf.userInvalidated = true; + } + + return m; + }; + + moment.parseZone = function (input) { + return moment(input).parseZone(); + }; /************************************ Moment Prototype ************************************/ - moment.fn = Moment.prototype = { + extend(moment.fn = Moment.prototype, { clone : function () { return moment(this); @@ -1145,7 +1779,7 @@ }, toString : function () { - return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ"); + return this.clone().lang('en').format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ"); }, toDate : function () { @@ -1153,7 +1787,12 @@ }, toISOString : function () { - return formatMoment(moment(this).utc(), 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + var m = moment(this).utc(); + if (0 < m.year() && m.year() <= 9999) { + return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } else { + return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); + } }, toArray : function () { @@ -1170,14 +1809,24 @@ }, isValid : function () { - if (this._isValid == null) { - if (this._a) { - this._isValid = !compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()); - } else { - this._isValid = !isNaN(this._d.getTime()); - } + return isValid(this); + }, + + isDSTShifted : function () { + + if (this._a) { + return this.isValid() && compareArrays(this._a, (this._isUTC ? moment.utc(this._a) : moment(this._a)).toArray()) > 0; } - return !!this._isValid; + + return false; + }, + + parsingFlags : function () { + return extend({}, this._pf); + }, + + invalidAt: function () { + return this._pf.overflow; }, utc : function () { @@ -1220,7 +1869,7 @@ }, diff : function (input, units, asFloat) { - var that = this._isUTC ? moment(input).zone(this._offset || 0) : moment(input).local(), + var that = makeAs(input, this), zoneDiff = (this.zone() - that.zone()) * 6e4, diff, output; @@ -1262,19 +1911,21 @@ }, calendar : function () { - var diff = this.diff(moment().startOf('day'), 'days', true), + // We want to compare the start of today, vs this. + // Getting start-of-today depends on whether we're zone'd or not. + var sod = makeAs(moment(), this).startOf('day'), + diff = this.diff(sod, 'days', true), format = diff < -6 ? 'sameElse' : - diff < -1 ? 'lastWeek' : - diff < 0 ? 'lastDay' : - diff < 1 ? 'sameDay' : - diff < 2 ? 'nextDay' : - diff < 7 ? 'nextWeek' : 'sameElse'; + diff < -1 ? 'lastWeek' : + diff < 0 ? 'lastDay' : + diff < 1 ? 'sameDay' : + diff < 2 ? 'nextDay' : + diff < 7 ? 'nextWeek' : 'sameElse'; return this.format(this.lang().calendar(format, this)); }, isLeapYear : function () { - var year = this.year(); - return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + return isLeapYear(this.year()); }, isDST : function () { @@ -1285,12 +1936,7 @@ day : function (input) { var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); if (input != null) { - if (typeof input === 'string') { - input = this.lang().weekdaysParse(input); - if (typeof input !== 'number') { - return this; - } - } + input = parseWeekday(input, this.lang()); return this.add({ d : input - day }); } else { return day; @@ -1299,8 +1945,7 @@ month : function (input) { var utc = this._isUTC ? 'UTC' : '', - dayOfMonth, - daysInMonth; + dayOfMonth; if (input != null) { if (typeof input === 'string') { @@ -1334,6 +1979,7 @@ this.date(1); /* falls through */ case 'week': + case 'isoWeek': case 'day': this.hours(0); /* falls through */ @@ -1351,13 +1997,16 @@ // weeks are a special case if (units === 'week') { this.weekday(0); + } else if (units === 'isoWeek') { + this.isoWeekday(1); } return this; }, endOf: function (units) { - return this.startOf(units).add(units, 1).subtract('ms', 1); + units = normalizeUnits(units); + return this.startOf(units).add((units === 'isoWeek' ? 'week' : units), 1).subtract('ms', 1); }, isAfter: function (input, units) { @@ -1371,8 +2020,8 @@ }, isSame: function (input, units) { - units = typeof units !== 'undefined' ? units : 'millisecond'; - return +this.clone().startOf(units) === +moment(input).startOf(units); + units = units || 'ms'; + return +this.clone().startOf(units) === +makeAs(input, this).startOf(units); }, min: function (other) { @@ -1413,8 +2062,28 @@ return this._isUTC ? "Coordinated Universal Time" : ""; }, + parseZone : function () { + if (this._tzm) { + this.zone(this._tzm); + } else if (typeof this._i === 'string') { + this.zone(this._i); + } + return this; + }, + + hasAlignedHourOffset : function (input) { + if (!input) { + input = 0; + } + else { + input = moment(input).zone(); + } + + return (this.zone() - input) % 60 === 0; + }, + daysInMonth : function () { - return moment.utc([this.year(), this.month() + 1, 0]).date(); + return daysInMonth(this.year(), this.month()); }, dayOfYear : function (input) { @@ -1422,6 +2091,10 @@ return input == null ? dayOfYear : this.add("d", (input - dayOfYear)); }, + quarter : function () { + return Math.ceil((this.month() + 1.0) / 3.0); + }, + weekYear : function (input) { var year = weekOfYear(this, this.lang()._week.dow, this.lang()._week.doy).year; return input == null ? year : this.add("y", (input - year)); @@ -1443,7 +2116,7 @@ }, weekday : function (input) { - var weekday = (this._d.getDay() + 7 - this.lang()._week.dow) % 7; + var weekday = (this.day() + 7 - this.lang()._week.dow) % 7; return input == null ? weekday : this.add("d", input - weekday); }, @@ -1454,6 +2127,19 @@ return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7); }, + get : function (units) { + units = normalizeUnits(units); + return this[units](); + }, + + set : function (units, value) { + units = normalizeUnits(units); + if (typeof this[units] === 'function') { + this[units](value); + } + return this; + }, + // If passed a language key, it will set the language for this // instance. Otherwise, it will return the language configuration // variables for this instance. @@ -1465,7 +2151,7 @@ return this; } } - }; + }); // helper for adding shortcuts function makeGetterAndSetter(name, key) { @@ -1503,7 +2189,8 @@ ************************************/ - moment.duration.fn = Duration.prototype = { + extend(moment.duration.fn = Duration.prototype, { + _bubble : function () { var milliseconds = this._milliseconds, days = this._days, @@ -1542,7 +2229,7 @@ return this._milliseconds + this._days * 864e5 + (this._months % 12) * 2592e6 + - ~~(this._months / 12) * 31536e6; + toInt(this._months / 12) * 31536e6; }, humanize : function (withSuffix) { @@ -1591,8 +2278,34 @@ return this['as' + units.charAt(0).toUpperCase() + units.slice(1) + 's'](); }, - lang : moment.fn.lang - }; + lang : moment.fn.lang, + + toIsoString : function () { + // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js + var years = Math.abs(this.years()), + months = Math.abs(this.months()), + days = Math.abs(this.days()), + hours = Math.abs(this.hours()), + minutes = Math.abs(this.minutes()), + seconds = Math.abs(this.seconds() + this.milliseconds() / 1000); + + if (!this.asSeconds()) { + // this is the same as C#'s (Noda) and python (isodate)... + // but not other JS (goog.date) + return 'P0D'; + } + + return (this.asSeconds() < 0 ? '-' : '') + + 'P' + + (years ? years + 'Y' : '') + + (months ? months + 'M' : '') + + (days ? days + 'D' : '') + + ((hours || minutes || seconds) ? 'T' : '') + + (hours ? hours + 'H' : '') + + (minutes ? minutes + 'M' : '') + + (seconds ? seconds + 'S' : ''); + } + }); function makeDurationGetter(name) { moment.duration.fn[name] = function () { @@ -1628,7 +2341,7 @@ moment.lang('en', { ordinal : function (number) { var b = number % 10, - output = (~~ (number % 100 / 10) === 1) ? 'th' : + output = (toInt(number % 100 / 10) === 1) ? 'th' : (b === 1) ? 'st' : (b === 2) ? 'nd' : (b === 3) ? 'rd' : 'th'; @@ -1636,27 +2349,52 @@ } }); + /* EMBED_LANGUAGES */ /************************************ Exposing Moment ************************************/ - - // CommonJS module is defined - if (hasModule) { - module.exports = moment; - } - /*global ender:false */ - if (typeof ender === 'undefined') { + function makeGlobal(deprecate) { + var warned = false, local_moment = moment; + /*global ender:false */ + if (typeof ender !== 'undefined') { + return; + } // here, `this` means `window` in the browser, or `global` on the server // add `moment` as a global object via a string identifier, // for Closure Compiler "advanced" mode - this['moment'] = moment; + if (deprecate) { + global.moment = function () { + if (!warned && console && console.warn) { + warned = true; + console.warn( + "Accessing Moment through the global scope is " + + "deprecated, and will be removed in an upcoming " + + "release."); + } + return local_moment.apply(null, arguments); + }; + extend(global.moment, local_moment); + } else { + global['moment'] = moment; + } } - /*global define:false */ - if (typeof define === "function" && define.amd) { - define("moment", [], function () { + + // CommonJS module is defined + if (hasModule) { + module.exports = moment; + makeGlobal(true); + } else if (typeof define === "function" && define.amd) { + define("moment", function (require, exports, module) { + if (module.config && module.config() && module.config().noGlobal !== true) { + // If user provided noGlobal, he is aware of global + makeGlobal(module.config().noGlobal === undefined); + } + return moment; }); + } else { + makeGlobal(); } }).call(this); diff --git a/misc/website/websitev2/js/pack.js b/misc/website/websitev2/js/pack.js index b36b2f744..e245d4156 100644 --- a/misc/website/websitev2/js/pack.js +++ b/misc/website/websitev2/js/pack.js @@ -1 +1 @@ -function rssfeedsetup(){var t=new google.feeds.Feed("http://sourceforge.net/p/processhacker/code/feed");t.setNumEntries(5),t.load(displayfeed)}function displayfeed(t){if(t.error)feedcontainer.innerHTML="Error fetching feeds!";else{for(var e="",n=t.feed.entries,s=0;s",e+=''+n[s].title.replace("/p/processhacker/code/","http://sourceforge.net/p/processhacker/code/")+"",e+=' by '+n[s].author+"",e+='
'+moment(n[s].publishedDate).fromNow()+" - "+new Date(n[s].publishedDate).toLocaleString()+"
",e+="";feedcontainer.innerHTML=e}}!function(t){function e(t,e){return function(n){return u(t.call(this,n),e)}}function n(t,e){return function(n){return this.lang().ordinal(t.call(this,n),e)}}function s(){}function i(t){a(this,t)}function r(t){var e=t.years||t.year||t.y||0,n=t.months||t.month||t.M||0,s=t.weeks||t.week||t.w||0,i=t.days||t.day||t.d||0,r=t.hours||t.hour||t.h||0,a=t.minutes||t.minute||t.m||0,o=t.seconds||t.second||t.s||0,u=t.milliseconds||t.millisecond||t.ms||0;this._input=t,this._milliseconds=u+1e3*o+6e4*a+36e5*r,this._days=i+7*s,this._months=n+12*e,this._data={},this._bubble()}function a(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function o(t){return 0>t?Math.ceil(t):Math.floor(t)}function u(t,e){for(var n=t+"";n.lengthn;n++)~~t[n]!==~~e[n]&&r++;return r+i}function f(t){return t?ie[t]||t.toLowerCase().replace(/(.)s$/,"$1"):t}function l(t,e){return e.abbr=t,x[t]||(x[t]=new s),x[t].set(e),x[t]}function _(t){if(!t)return H.fn._lang;if(!x[t]&&A)try{require("./lang/"+t)}catch(e){return H.fn._lang}return x[t]}function m(t){return t.match(/\[.*\]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function y(t){var e,n,s=t.match(E);for(e=0,n=s.length;n>e;e++)s[e]=ue[s[e]]?ue[s[e]]:m(s[e]);return function(i){var r="";for(e=0;n>e;e++)r+=s[e]instanceof Function?s[e].call(i,t):s[e];return r}}function g(t,e){function n(e){return t.lang().longDateFormat(e)||e}for(var s=5;s--&&N.test(e);)e=e.replace(N,n);return re[e]||(re[e]=y(e)),re[e](t)}function p(t,e){switch(t){case"DDDD":return V;case"YYYY":return X;case"YYYYY":return $;case"S":case"SS":case"SSS":case"DDD":return J;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return R;case"a":case"A":return _(e._l)._meridiemParse;case"X":return q;case"Z":case"ZZ":return j;case"T":return B;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return I;default:return new RegExp(t.replace("\\",""))}}function M(t){var e=(j.exec(t)||[])[0],n=(e+"").match(ee)||["-",0,0],s=+(60*n[1])+~~n[2];return"+"===n[0]?-s:s}function D(t,e,n){var s,i=n._a;switch(t){case"M":case"MM":i[1]=null==e?0:~~e-1;break;case"MMM":case"MMMM":s=_(n._l).monthsParse(e),null!=s?i[1]=s:n._isValid=!1;break;case"D":case"DD":case"DDD":case"DDDD":null!=e&&(i[2]=~~e);break;case"YY":i[0]=~~e+(~~e>68?1900:2e3);break;case"YYYY":case"YYYYY":i[0]=~~e;break;case"a":case"A":n._isPm=_(n._l).isPM(e);break;case"H":case"HH":case"h":case"hh":i[3]=~~e;break;case"m":case"mm":i[4]=~~e;break;case"s":case"ss":i[5]=~~e;break;case"S":case"SS":case"SSS":i[6]=~~(1e3*("0."+e));break;case"X":n._d=new Date(1e3*parseFloat(e));break;case"Z":case"ZZ":n._useUTC=!0,n._tzm=M(e)}null==e&&(n._isValid=!1)}function w(t){var e,n,s=[];if(!t._d){for(e=0;7>e;e++)t._a[e]=s[e]=null==t._a[e]?2===e?1:0:t._a[e];s[3]+=~~((t._tzm||0)/60),s[4]+=~~((t._tzm||0)%60),n=new Date(0),t._useUTC?(n.setUTCFullYear(s[0],s[1],s[2]),n.setUTCHours(s[3],s[4],s[5],s[6])):(n.setFullYear(s[0],s[1],s[2]),n.setHours(s[3],s[4],s[5],s[6])),t._d=n}}function Y(t){var e,n,s=t._f.match(E),i=t._i;for(t._a=[],e=0;eo&&(u=o,s=n);a(t,s)}function v(t){var e,n=t._i,s=K.exec(n);if(s){for(t._f="YYYY-MM-DD"+(s[2]||" "),e=0;4>e;e++)if(te[e][1].exec(n)){t._f+=te[e][0];break}j.exec(n)&&(t._f+=" Z"),Y(t)}else t._d=new Date(n)}function T(e){var n=e._i,s=G.exec(n);n===t?e._d=new Date:s?e._d=new Date(+s[1]):"string"==typeof n?v(e):h(n)?(e._a=n.slice(0),w(e)):e._d=n instanceof Date?new Date(+n):new Date(n)}function b(t,e,n,s,i){return i.relativeTime(e||1,!!n,t,s)}function S(t,e,n){var s=W(Math.abs(t)/1e3),i=W(s/60),r=W(i/60),a=W(r/24),o=W(a/365),u=45>s&&["s",s]||1===i&&["m"]||45>i&&["mm",i]||1===r&&["h"]||22>r&&["hh",r]||1===a&&["d"]||25>=a&&["dd",a]||45>=a&&["M"]||345>a&&["MM",W(a/30)]||1===o&&["y"]||["yy",o];return u[2]=e,u[3]=t>0,u[4]=n,b.apply({},u)}function F(t,e,n){var s,i=n-e,r=n-t.day();return r>i&&(r-=7),i-7>r&&(r+=7),s=H(t).add("d",r),{week:Math.ceil(s.dayOfYear()/7),year:s.year()}}function L(t){var e=t._i,n=t._f;return null===e||""===e?null:("string"==typeof e&&(t._i=e=_().preparse(e)),H.isMoment(e)?(t=a({},e),t._d=new Date(+e._d)):n?h(n)?k(t):Y(t):T(t),new i(t))}function O(t,e){H.fn[t]=H.fn[t+"s"]=function(t){var n=this._isUTC?"UTC":"";return null!=t?(this._d["set"+n+e](t),H.updateOffset(this),this):this._d["get"+n+e]()}}function z(t){H.duration.fn[t]=function(){return this._data[t]}}function C(t,e){H.duration.fn["as"+t]=function(){return+this/e}}for(var H,P,U="2.1.0",W=Math.round,x={},A="undefined"!=typeof module&&module.exports,G=/^\/?Date\((\-?\d+)/i,Z=/(\-)?(\d*)?\.?(\d+)\:(\d+)\:(\d+)\.?(\d{3})?/,E=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,N=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,I=/\d\d?/,J=/\d{1,3}/,V=/\d{3}/,X=/\d{1,4}/,$=/[+\-]?\d{1,6}/,R=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,j=/Z|[\+\-]\d\d:?\d\d/i,B=/T/i,q=/[\+\-]?\d+(\.\d{1,3})?/,K=/^\s*\d{4}-\d\d-\d\d((T| )(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,Q="YYYY-MM-DDTHH:mm:ssZ",te=[["HH:mm:ss.S",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],ee=/([\+\-]|\d\d)/gi,ne="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),se={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},ie={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",w:"week",M:"month",y:"year"},re={},ae="DDD w W M D d".split(" "),oe="M D H h m s w W".split(" "),ue={M:function(){return this.month()+1},MMM:function(t){return this.lang().monthsShort(this,t)},MMMM:function(t){return this.lang().months(this,t)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(t){return this.lang().weekdaysMin(this,t)},ddd:function(t){return this.lang().weekdaysShort(this,t)},dddd:function(t){return this.lang().weekdays(this,t)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return u(this.year()%100,2)},YYYY:function(){return u(this.year(),4)},YYYYY:function(){return u(this.year(),5)},gg:function(){return u(this.weekYear()%100,2)},gggg:function(){return this.weekYear()},ggggg:function(){return u(this.weekYear(),5)},GG:function(){return u(this.isoWeekYear()%100,2)},GGGG:function(){return this.isoWeekYear()},GGGGG:function(){return u(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return~~(this.milliseconds()/100)},SS:function(){return u(~~(this.milliseconds()/10),2)},SSS:function(){return u(this.milliseconds(),3)},Z:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+u(~~(t/60),2)+":"+u(~~t%60,2)},ZZ:function(){var t=-this.zone(),e="+";return 0>t&&(t=-t,e="-"),e+u(~~(10*t/6),4)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()}};ae.length;)P=ae.pop(),ue[P+"o"]=n(ue[P],P);for(;oe.length;)P=oe.pop(),ue[P+P]=e(ue[P],2);for(ue.DDDD=e(ue.DDD,3),s.prototype={set:function(t){var e,n;for(n in t)e=t[n],"function"==typeof e?this[n]=e:this["_"+n]=e},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(t){return this._months[t.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(t){return this._monthsShort[t.month()]},monthsParse:function(t){var e,n,s;for(this._monthsParse||(this._monthsParse=[]),e=0;12>e;e++)if(this._monthsParse[e]||(n=H([2e3,e]),s="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[e]=new RegExp(s.replace(".",""),"i")),this._monthsParse[e].test(t))return e},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(t){return this._weekdays[t.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(t){return this._weekdaysShort[t.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(t){return this._weekdaysMin[t.day()]},weekdaysParse:function(t){var e,n,s;for(this._weekdaysParse||(this._weekdaysParse=[]),e=0;7>e;e++)if(this._weekdaysParse[e]||(n=H([2e3,1]).day(e),s="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[e]=new RegExp(s.replace(".",""),"i")),this._weekdaysParse[e].test(t))return e},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(t){var e=this._longDateFormat[t];return!e&&this._longDateFormat[t.toUpperCase()]&&(e=this._longDateFormat[t.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t]=e),e},isPM:function(t){return"p"===(t+"").toLowerCase()[0]},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(t,e){var n=this._calendar[t];return"function"==typeof n?n.apply(e):n},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(t,e,n,s){var i=this._relativeTime[n];return"function"==typeof i?i(t,e,n,s):i.replace(/%d/i,t)},pastFuture:function(t,e){var n=this._relativeTime[t>0?"future":"past"];return"function"==typeof n?n(e):n.replace(/%s/i,e)},ordinal:function(t){return this._ordinal.replace("%d",t)},_ordinal:"%d",preparse:function(t){return t},postformat:function(t){return t},week:function(t){return F(t,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6}},H=function(t,e,n){return L({_i:t,_f:e,_l:n,_isUTC:!1})},H.utc=function(t,e,n){return L({_useUTC:!0,_isUTC:!0,_l:n,_i:t,_f:e})},H.unix=function(t){return H(1e3*t)},H.duration=function(t,e){var n,s,i=H.isDuration(t),a="number"==typeof t,o=i?t._input:a?{}:t,u=Z.exec(t);return a?e?o[e]=t:o.milliseconds=t:u&&(n="-"===u[1]?-1:1,o={y:0,d:~~u[2]*n,h:~~u[3]*n,m:~~u[4]*n,s:~~u[5]*n,ms:~~u[6]*n}),s=new r(o),i&&t.hasOwnProperty("_lang")&&(s._lang=t._lang),s},H.version=U,H.defaultFormat=Q,H.updateOffset=function(){},H.lang=function(t,e){return t?(e?l(t,e):x[t]||_(t),H.duration.fn._lang=H.fn._lang=_(t),void 0):H.fn._lang._abbr},H.langData=function(t){return t&&t._lang&&t._lang._abbr&&(t=t._lang._abbr),_(t)},H.isMoment=function(t){return t instanceof i},H.isDuration=function(t){return t instanceof r},H.fn=i.prototype={clone:function(){return H(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){return g(H(this).utc(),"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){var t=this;return[t.year(),t.month(),t.date(),t.hours(),t.minutes(),t.seconds(),t.milliseconds()]},isValid:function(){return null==this._isValid&&(this._isValid=this._a?!c(this._a,(this._isUTC?H.utc(this._a):H(this._a)).toArray()):!isNaN(this._d.getTime())),!!this._isValid},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(t){var e=g(this,t||H.defaultFormat);return this.lang().postformat(e)},add:function(t,e){var n;return n="string"==typeof t?H.duration(+e,t):H.duration(t,e),d(this,n,1),this},subtract:function(t,e){var n;return n="string"==typeof t?H.duration(+e,t):H.duration(t,e),d(this,n,-1),this},diff:function(t,e,n){var s,i,r=this._isUTC?H(t).zone(this._offset||0):H(t).local(),a=6e4*(this.zone()-r.zone());return e=f(e),"year"===e||"month"===e?(s=432e5*(this.daysInMonth()+r.daysInMonth()),i=12*(this.year()-r.year())+(this.month()-r.month()),i+=(this-H(this).startOf("month")-(r-H(r).startOf("month")))/s,i-=6e4*(this.zone()-H(this).startOf("month").zone()-(r.zone()-H(r).startOf("month").zone()))/s,"year"===e&&(i/=12)):(s=this-r,i="second"===e?s/1e3:"minute"===e?s/6e4:"hour"===e?s/36e5:"day"===e?(s-a)/864e5:"week"===e?(s-a)/6048e5:s),n?i:o(i)},from:function(t,e){return H.duration(this.diff(t)).lang(this.lang()._abbr).humanize(!e)},fromNow:function(t){return this.from(H(),t)},calendar:function(){var t=this.diff(H().startOf("day"),"days",!0),e=-6>t?"sameElse":-1>t?"lastWeek":0>t?"lastDay":1>t?"sameDay":2>t?"nextDay":7>t?"nextWeek":"sameElse";return this.format(this.lang().calendar(e,this))},isLeapYear:function(){var t=this.year();return 0===t%4&&0!==t%100||0===t%400},isDST:function(){return this.zone()+H(t).startOf(e)},isBefore:function(t,e){return e="undefined"!=typeof e?e:"millisecond",+this.clone().startOf(e)<+H(t).startOf(e)},isSame:function(t,e){return e="undefined"!=typeof e?e:"millisecond",+this.clone().startOf(e)===+H(t).startOf(e)},min:function(t){return t=H.apply(null,arguments),this>t?this:t},max:function(t){return t=H.apply(null,arguments),t>this?this:t},zone:function(t){var e=this._offset||0;return null==t?this._isUTC?e:this._d.getTimezoneOffset():("string"==typeof t&&(t=M(t)),Math.abs(t)<16&&(t=60*t),this._offset=t,this._isUTC=!0,e!==t&&d(this,H.duration(e-t,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},daysInMonth:function(){return H.utc([this.year(),this.month()+1,0]).date()},dayOfYear:function(t){var e=W((H(this).startOf("day")-H(this).startOf("year"))/864e5)+1;return null==t?e:this.add("d",t-e)},weekYear:function(t){var e=F(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==t?e:this.add("y",t-e)},isoWeekYear:function(t){var e=F(this,1,4).year;return null==t?e:this.add("y",t-e)},week:function(t){var e=this.lang().week(this);return null==t?e:this.add("d",7*(t-e))},isoWeek:function(t){var e=F(this,1,4).week;return null==t?e:this.add("d",7*(t-e))},weekday:function(t){var e=(this._d.getDay()+7-this.lang()._week.dow)%7;return null==t?e:this.add("d",t-e)},isoWeekday:function(t){return null==t?this.day()||7:this.day(this.day()%7?t:t-7)},lang:function(e){return e===t?this._lang:(this._lang=_(e),this)}},P=0;PLoading commit history...",window.onload=function(){rssfeedsetup()}; \ No newline at end of file +function rssfeedsetup(){var e=new google.feeds.Feed("http://sourceforge.net/p/processhacker/code/feed");e.setNumEntries(5),e.load(displayfeed)}function displayfeed(e){if(e.error)feedcontainer.innerHTML="Error fetching feeds!";else{for(var t="",n=e.feed.entries,r=0;r",t+=''+n[r].title.replace("/p/processhacker/code/","http://sourceforge.net/p/processhacker/code/")+"",t+=' by '+n[r].author+"",t+='
'+moment(n[r].publishedDate).fromNow()+" - "+new Date(n[r].publishedDate).toLocaleString()+"
",t+="";feedcontainer.innerHTML=t}}(function(e){function t(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function n(e,t){return function(n){return h(e.call(this,n),t)}}function r(e,t){return function(n){return this.lang().ordinal(e.call(this,n),t)}}function s(){}function a(e){D(e),o(this,e)}function i(e){var t=y(e),n=t.year||0,r=t.month||0,s=t.week||0,a=t.day||0,i=t.hour||0,o=t.minute||0,u=t.second||0,d=t.millisecond||0;this._milliseconds=+d+1e3*u+6e4*o+36e5*i,this._days=+a+7*s,this._months=+r+12*n,this._data={},this._bubble()}function o(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return t.hasOwnProperty("toString")&&(e.toString=t.toString),t.hasOwnProperty("valueOf")&&(e.valueOf=t.valueOf),e}function u(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&yt.hasOwnProperty(t)&&(n[t]=e[t]);return n}function d(e){return 0>e?Math.ceil(e):Math.floor(e)}function h(e,t,n){for(var r=""+Math.abs(e),s=e>=0;r.lengthr;r++)(n&&e[r]!==t[r]||!n&&g(e[r])!==g(t[r]))&&i++;return i+a}function m(e){if(e){var t=e.toLowerCase().replace(/(.)s$/,"$1");e=$t[e]||Vt[t]||t}return e}function y(e){var t,n,r={};for(n in e)e.hasOwnProperty(n)&&(t=m(n),t&&(r[t]=e[n]));return r}function p(t){var n,r;if(0===t.indexOf("week"))n=7,r="day";else{if(0!==t.indexOf("month"))return;n=12,r="month"}rt[t]=function(s,a){var i,o,u=rt.fn._lang[t],d=[];if("number"==typeof s&&(a=s,s=e),o=function(e){var t=rt().utc().set(r,e);return u.call(rt.fn._lang,t,s||"")},null!=a)return o(a);for(i=0;n>i;i++)d.push(o(i));return d}}function g(e){var t=+e,n=0;return 0!==t&&isFinite(t)&&(n=t>=0?Math.floor(t):Math.ceil(t)),n}function Y(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}function w(e){return M(e)?366:365}function M(e){return e%4===0&&e%100!==0||e%400===0}function D(e){var t;e._a&&-2===e._pf.overflow&&(t=e._a[dt]<0||e._a[dt]>11?dt:e._a[ht]<1||e._a[ht]>Y(e._a[ut],e._a[dt])?ht:e._a[ft]<0||e._a[ft]>23?ft:e._a[ct]<0||e._a[ct]>59?ct:e._a[lt]<0||e._a[lt]>59?lt:e._a[_t]<0||e._a[_t]>999?_t:-1,e._pf._overflowDayOfYear&&(ut>t||t>ht)&&(t=ht),e._pf.overflow=t)}function v(e){return null==e._isValid&&(e._isValid=!isNaN(e._d.getTime())&&e._pf.overflow<0&&!e._pf.empty&&!e._pf.invalidMonth&&!e._pf.nullInput&&!e._pf.invalidFormat&&!e._pf.userInvalidated,e._strict&&(e._isValid=e._isValid&&0===e._pf.charsLeftOver&&0===e._pf.unusedTokens.length)),e._isValid}function k(e){return e?e.toLowerCase().replace("_","-"):e}function b(e,t){return t._isUTC?rt(e).zone(t._offset||0):rt(e).local()}function S(e,t){return t.abbr=e,mt[e]||(mt[e]=new s),mt[e].set(t),mt[e]}function T(e){delete mt[e]}function O(e){var t,n,r,s,a=0,i=function(e){if(!mt[e]&&pt)try{require("./lang/"+e)}catch(t){}return mt[e]};if(!e)return rt.fn._lang;if(!c(e)){if(n=i(e))return n;e=[e]}for(;a0;){if(n=i(s.slice(0,t).join("-")))return n;if(r&&r.length>=t&&_(s,r,!0)>=t-1)break;t--}a++}return rt.fn._lang}function G(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.replace(/\\/g,"")}function W(e){var t,n,r=e.match(Mt);for(t=0,n=r.length;n>t;t++)r[t]=Rt[r[t]]?Rt[r[t]]:G(r[t]);return function(s){var a="";for(t=0;n>t;t++)a+=r[t]instanceof Function?r[t].call(s,e):r[t];return a}}function F(e,t){return e.isValid()?(t=C(t,e.lang()),Jt[t]||(Jt[t]=W(t)),Jt[t](e)):e.lang().invalidDate()}function C(e,t){function n(e){return t.longDateFormat(e)||e}var r=5;for(Dt.lastIndex=0;r>=0&&Dt.test(e);)e=e.replace(Dt,n),Dt.lastIndex=0,r-=1;return e}function L(e,t){var n,r=t._strict;switch(e){case"DDDD":return zt;case"YYYY":case"GGGG":case"gggg":return r?Ut:bt;case"Y":case"G":case"g":return Ht;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return r?Pt:St;case"S":if(r)return Ct;case"SS":if(r)return Lt;case"SSS":if(r)return zt;case"DDD":return kt;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Ot;case"a":case"A":return O(t._l)._meridiemParse;case"X":return Ft;case"Z":case"ZZ":return Gt;case"T":return Wt;case"SSSS":return Tt;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return r?Lt:vt;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return vt;default:return n=new RegExp(Z(I(e.replace("\\","")),"i"))}}function z(e){e=e||"";var t=e.match(Gt)||[],n=t[t.length-1]||[],r=(n+"").match(Et)||["-",0,0],s=+(60*r[1])+g(r[2]);return"+"===r[0]?-s:s}function U(e,t,n){var r,s=n._a;switch(e){case"M":case"MM":null!=t&&(s[dt]=g(t)-1);break;case"MMM":case"MMMM":r=O(n._l).monthsParse(t),null!=r?s[dt]=r:n._pf.invalidMonth=t;break;case"D":case"DD":null!=t&&(s[ht]=g(t));break;case"DDD":case"DDDD":null!=t&&(n._dayOfYear=g(t));break;case"YY":s[ut]=g(t)+(g(t)>68?1900:2e3);break;case"YYYY":case"YYYYY":case"YYYYYY":s[ut]=g(t);break;case"a":case"A":n._isPm=O(n._l).isPM(t);break;case"H":case"HH":case"h":case"hh":s[ft]=g(t);break;case"m":case"mm":s[ct]=g(t);break;case"s":case"ss":s[lt]=g(t);break;case"S":case"SS":case"SSS":case"SSSS":s[_t]=g(1e3*("0."+t));break;case"X":n._d=new Date(1e3*parseFloat(t));break;case"Z":case"ZZ":n._useUTC=!0,n._tzm=z(t);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":e=e.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":e=e.substr(0,2),t&&(n._w=n._w||{},n._w[e]=t)}}function P(e){var t,n,r,s,a,i,o,u,d,h,f=[];if(!e._d){for(r=A(e),e._w&&null==e._a[ht]&&null==e._a[dt]&&(a=function(t){var n=parseInt(t,10);return t?t.length<3?n>68?1900+n:2e3+n:n:null==e._a[ut]?rt().weekYear():e._a[ut]},i=e._w,null!=i.GG||null!=i.W||null!=i.E?o=B(a(i.GG),i.W||1,i.E,4,1):(u=O(e._l),d=null!=i.d?J(i.d,u):null!=i.e?parseInt(i.e,10)+u._week.dow:0,h=parseInt(i.w,10)||1,null!=i.d&&dw(s)&&(e._pf._overflowDayOfYear=!0),n=V(s,0,e._dayOfYear),e._a[dt]=n.getUTCMonth(),e._a[ht]=n.getUTCDate()),t=0;3>t&&null==e._a[t];++t)e._a[t]=f[t]=r[t];for(;7>t;t++)e._a[t]=f[t]=null==e._a[t]?2===t?1:0:e._a[t];f[ft]+=g((e._tzm||0)/60),f[ct]+=g((e._tzm||0)%60),e._d=(e._useUTC?V:$).apply(null,f)}}function H(e){var t;e._d||(t=y(e._i),e._a=[t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond],P(e))}function A(e){var t=new Date;return e._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function x(e){e._a=[],e._pf.empty=!0;var t,n,r,s,a,i=O(e._l),o=""+e._i,u=o.length,d=0;for(r=C(e._f,i).match(Mt)||[],t=0;t0&&e._pf.unusedInput.push(a),o=o.slice(o.indexOf(n)+n.length),d+=n.length),Rt[s]?(n?e._pf.empty=!1:e._pf.unusedTokens.push(s),U(s,n,e)):e._strict&&!n&&e._pf.unusedTokens.push(s);e._pf.charsLeftOver=u-d,o.length>0&&e._pf.unusedInput.push(o),e._isPm&&e._a[ft]<12&&(e._a[ft]+=12),e._isPm===!1&&12===e._a[ft]&&(e._a[ft]=0),P(e),D(e)}function I(e){return e.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(e,t,n,r,s){return t||n||r||s})}function Z(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function E(e){var n,r,s,a,i;if(0===e._f.length)return e._pf.invalidFormat=!0,void(e._d=new Date(0/0));for(a=0;ai)&&(s=i,r=n));o(e,r||n)}function N(e){var t,n,r=e._i,s=At.exec(r);if(s){for(e._pf.iso=!0,t=0,n=It.length;n>t;t++)if(It[t][1].exec(r)){e._f=It[t][0]+(s[6]||" ");break}for(t=0,n=Zt.length;n>t;t++)if(Zt[t][1].exec(r)){e._f+=Zt[t][0];break}r.match(Gt)&&(e._f+="Z"),x(e)}else e._d=new Date(r)}function j(t){var n=t._i,r=gt.exec(n);n===e?t._d=new Date:r?t._d=new Date(+r[1]):"string"==typeof n?N(t):c(n)?(t._a=n.slice(0),P(t)):l(n)?t._d=new Date(+n):"object"==typeof n?H(t):t._d=new Date(n)}function $(e,t,n,r,s,a,i){var o=new Date(e,t,n,r,s,a,i);return 1970>e&&o.setFullYear(e),o}function V(e){var t=new Date(Date.UTC.apply(null,arguments));return 1970>e&&t.setUTCFullYear(e),t}function J(e,t){if("string"==typeof e)if(isNaN(e)){if(e=t.weekdaysParse(e),"number"!=typeof e)return null}else e=parseInt(e,10);return e}function q(e,t,n,r,s){return s.relativeTime(t||1,!!n,e,r)}function X(e,t,n){var r=ot(Math.abs(e)/1e3),s=ot(r/60),a=ot(s/60),i=ot(a/24),o=ot(i/365),u=45>r&&["s",r]||1===s&&["m"]||45>s&&["mm",s]||1===a&&["h"]||22>a&&["hh",a]||1===i&&["d"]||25>=i&&["dd",i]||45>=i&&["M"]||345>i&&["MM",ot(i/30)]||1===o&&["y"]||["yy",o];return u[2]=t,u[3]=e>0,u[4]=n,q.apply({},u)}function R(e,t,n){var r,s=n-t,a=n-e.day();return a>s&&(a-=7),s-7>a&&(a+=7),r=rt(e).add("d",a),{week:Math.ceil(r.dayOfYear()/7),year:r.year()}}function B(e,t,n,r,s){var a,i,o=V(e,0,1).getUTCDay();return n=null!=n?n:s,a=s-o+(o>r?7:0)-(s>o?7:0),i=7*(t-1)+(n-s)+a+1,{year:i>0?e:e-1,dayOfYear:i>0?i:w(e-1)+i}}function Q(e){var t=e._i,n=e._f;return null===t?rt.invalid({nullInput:!0}):("string"==typeof t&&(e._i=t=O().preparse(t)),rt.isMoment(t)?(e=u(t),e._d=new Date(+t._d)):n?c(n)?E(e):x(e):j(e),new a(e))}function K(e,t){rt.fn[e]=rt.fn[e+"s"]=function(e){var n=this._isUTC?"UTC":"";return null!=e?(this._d["set"+n+t](e),rt.updateOffset(this),this):this._d["get"+n+t]()}}function et(e){rt.duration.fn[e]=function(){return this._data[e]}}function tt(e,t){rt.duration.fn["as"+e]=function(){return+this/t}}function nt(e){var t=!1,n=rt;"undefined"==typeof ender&&(e?(it.moment=function(){return!t&&console&&console.warn&&(t=!0,console.warn("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.")),n.apply(null,arguments)},o(it.moment,n)):it.moment=rt)}for(var rt,st,at="2.5.1",it=this,ot=Math.round,ut=0,dt=1,ht=2,ft=3,ct=4,lt=5,_t=6,mt={},yt={_isAMomentObject:null,_i:null,_f:null,_l:null,_strict:null,_isUTC:null,_offset:null,_pf:null,_lang:null},pt="undefined"!=typeof module&&module.exports&&"undefined"!=typeof require,gt=/^\/?Date\((\-?\d+)/i,Yt=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,wt=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,Mt=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,Dt=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,vt=/\d\d?/,kt=/\d{1,3}/,bt=/\d{1,4}/,St=/[+\-]?\d{1,6}/,Tt=/\d+/,Ot=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Gt=/Z|[\+\-]\d\d:?\d\d/gi,Wt=/T/i,Ft=/[\+\-]?\d+(\.\d{1,3})?/,Ct=/\d/,Lt=/\d\d/,zt=/\d{3}/,Ut=/\d{4}/,Pt=/[+-]?\d{6}/,Ht=/[+-]?\d+/,At=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,xt="YYYY-MM-DDTHH:mm:ssZ",It=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],Zt=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Et=/([\+\-]|\d\d)/gi,Nt="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),jt={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},$t={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},Vt={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},Jt={},qt="DDD w W M D d".split(" "),Xt="M D H h m s w W".split(" "),Rt={M:function(){return this.month()+1},MMM:function(e){return this.lang().monthsShort(this,e)},MMMM:function(e){return this.lang().months(this,e)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(e){return this.lang().weekdaysMin(this,e)},ddd:function(e){return this.lang().weekdaysShort(this,e)},dddd:function(e){return this.lang().weekdays(this,e)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return h(this.year()%100,2)},YYYY:function(){return h(this.year(),4)},YYYYY:function(){return h(this.year(),5)},YYYYYY:function(){var e=this.year(),t=e>=0?"+":"-";return t+h(Math.abs(e),6)},gg:function(){return h(this.weekYear()%100,2)},gggg:function(){return h(this.weekYear(),4)},ggggg:function(){return h(this.weekYear(),5)},GG:function(){return h(this.isoWeekYear()%100,2)},GGGG:function(){return h(this.isoWeekYear(),4)},GGGGG:function(){return h(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return g(this.milliseconds()/100)},SS:function(){return h(g(this.milliseconds()/10),2)},SSS:function(){return h(this.milliseconds(),3)},SSSS:function(){return h(this.milliseconds(),3)},Z:function(){var e=-this.zone(),t="+";return 0>e&&(e=-e,t="-"),t+h(g(e/60),2)+":"+h(g(e)%60,2)},ZZ:function(){var e=-this.zone(),t="+";return 0>e&&(e=-e,t="-"),t+h(g(e/60),2)+h(g(e)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},Bt=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];qt.length;)st=qt.pop(),Rt[st+"o"]=r(Rt[st],st);for(;Xt.length;)st=Xt.pop(),Rt[st+st]=n(Rt[st],2);for(Rt.DDDD=n(Rt.DDD,3),o(s.prototype,{set:function(e){var t,n;for(n in e)t=e[n],"function"==typeof t?this[n]=t:this["_"+n]=t},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(e){return this._months[e.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(e){return this._monthsShort[e.month()]},monthsParse:function(e){var t,n,r;for(this._monthsParse||(this._monthsParse=[]),t=0;12>t;t++)if(this._monthsParse[t]||(n=rt.utc([2e3,t]),r="^"+this.months(n,"")+"|^"+this.monthsShort(n,""),this._monthsParse[t]=new RegExp(r.replace(".",""),"i")),this._monthsParse[t].test(e))return t},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(e){return this._weekdays[e.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(e){return this._weekdaysShort[e.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(e){return this._weekdaysMin[e.day()]},weekdaysParse:function(e){var t,n,r;for(this._weekdaysParse||(this._weekdaysParse=[]),t=0;7>t;t++)if(this._weekdaysParse[t]||(n=rt([2e3,1]).day(t),r="^"+this.weekdays(n,"")+"|^"+this.weekdaysShort(n,"")+"|^"+this.weekdaysMin(n,""),this._weekdaysParse[t]=new RegExp(r.replace(".",""),"i")),this._weekdaysParse[t].test(e))return t},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(e){var t=this._longDateFormat[e];return!t&&this._longDateFormat[e.toUpperCase()]&&(t=this._longDateFormat[e.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(e){return e.slice(1)}),this._longDateFormat[e]=t),t},isPM:function(e){return"p"===(e+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(e,t,n){return e>11?n?"pm":"PM":n?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(e,t){var n=this._calendar[e];return"function"==typeof n?n.apply(t):n},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(e,t,n,r){var s=this._relativeTime[n];return"function"==typeof s?s(e,t,n,r):s.replace(/%d/i,e)},pastFuture:function(e,t){var n=this._relativeTime[e>0?"future":"past"];return"function"==typeof n?n(t):n.replace(/%s/i,t)},ordinal:function(e){return this._ordinal.replace("%d",e)},_ordinal:"%d",preparse:function(e){return e},postformat:function(e){return e},week:function(e){return R(e,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),rt=function(n,r,s,a){var i;return"boolean"==typeof s&&(a=s,s=e),i={},i._isAMomentObject=!0,i._i=n,i._f=r,i._l=s,i._strict=a,i._isUTC=!1,i._pf=t(),Q(i)},rt.utc=function(n,r,s,a){var i;return"boolean"==typeof s&&(a=s,s=e),i={},i._isAMomentObject=!0,i._useUTC=!0,i._isUTC=!0,i._l=s,i._i=n,i._f=r,i._strict=a,i._pf=t(),Q(i).utc()},rt.unix=function(e){return rt(1e3*e)},rt.duration=function(e,t){var n,r,s,a=e,o=null;return rt.isDuration(e)?a={ms:e._milliseconds,d:e._days,M:e._months}:"number"==typeof e?(a={},t?a[t]=e:a.milliseconds=e):(o=Yt.exec(e))?(n="-"===o[1]?-1:1,a={y:0,d:g(o[ht])*n,h:g(o[ft])*n,m:g(o[ct])*n,s:g(o[lt])*n,ms:g(o[_t])*n}):(o=wt.exec(e))&&(n="-"===o[1]?-1:1,s=function(e){var t=e&&parseFloat(e.replace(",","."));return(isNaN(t)?0:t)*n},a={y:s(o[2]),M:s(o[3]),d:s(o[4]),h:s(o[5]),m:s(o[6]),s:s(o[7]),w:s(o[8])}),r=new i(a),rt.isDuration(e)&&e.hasOwnProperty("_lang")&&(r._lang=e._lang),r},rt.version=at,rt.defaultFormat=xt,rt.updateOffset=function(){},rt.lang=function(e,t){var n;return e?(t?S(k(e),t):null===t?(T(e),e="en"):mt[e]||O(e),n=rt.duration.fn._lang=rt.fn._lang=O(e),n._abbr):rt.fn._lang._abbr},rt.langData=function(e){return e&&e._lang&&e._lang._abbr&&(e=e._lang._abbr),O(e)},rt.isMoment=function(e){return e instanceof a||null!=e&&e.hasOwnProperty("_isAMomentObject")},rt.isDuration=function(e){return e instanceof i},st=Bt.length-1;st>=0;--st)p(Bt[st]);for(rt.normalizeUnits=function(e){return m(e)},rt.invalid=function(e){var t=rt.utc(0/0);return null!=e?o(t._pf,e):t._pf.userInvalidated=!0,t},rt.parseZone=function(e){return rt(e).parseZone()},o(rt.fn=a.prototype,{clone:function(){return rt(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var e=rt(this).utc();return 00:!1},parsingFlags:function(){return o({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(e){var t=F(this,e||rt.defaultFormat);return this.lang().postformat(t)},add:function(e,t){var n;return n="string"==typeof e?rt.duration(+t,e):rt.duration(e,t),f(this,n,1),this},subtract:function(e,t){var n;return n="string"==typeof e?rt.duration(+t,e):rt.duration(e,t),f(this,n,-1),this},diff:function(e,t,n){var r,s,a=b(e,this),i=6e4*(this.zone()-a.zone());return t=m(t),"year"===t||"month"===t?(r=432e5*(this.daysInMonth()+a.daysInMonth()),s=12*(this.year()-a.year())+(this.month()-a.month()),s+=(this-rt(this).startOf("month")-(a-rt(a).startOf("month")))/r,s-=6e4*(this.zone()-rt(this).startOf("month").zone()-(a.zone()-rt(a).startOf("month").zone()))/r,"year"===t&&(s/=12)):(r=this-a,s="second"===t?r/1e3:"minute"===t?r/6e4:"hour"===t?r/36e5:"day"===t?(r-i)/864e5:"week"===t?(r-i)/6048e5:r),n?s:d(s)},from:function(e,t){return rt.duration(this.diff(e)).lang(this.lang()._abbr).humanize(!t)},fromNow:function(e){return this.from(rt(),e)},calendar:function(){var e=b(rt(),this).startOf("day"),t=this.diff(e,"days",!0),n=-6>t?"sameElse":-1>t?"lastWeek":0>t?"lastDay":1>t?"sameDay":2>t?"nextDay":7>t?"nextWeek":"sameElse";return this.format(this.lang().calendar(n,this))},isLeapYear:function(){return M(this.year())},isDST:function(){return this.zone()+rt(e).startOf(t)},isBefore:function(e,t){return t="undefined"!=typeof t?t:"millisecond",+this.clone().startOf(t)<+rt(e).startOf(t)},isSame:function(e,t){return t=t||"ms",+this.clone().startOf(t)===+b(e,this).startOf(t)},min:function(e){return e=rt.apply(null,arguments),this>e?this:e},max:function(e){return e=rt.apply(null,arguments),e>this?this:e},zone:function(e){var t=this._offset||0;return null==e?this._isUTC?t:this._d.getTimezoneOffset():("string"==typeof e&&(e=z(e)),Math.abs(e)<16&&(e=60*e),this._offset=e,this._isUTC=!0,t!==e&&f(this,rt.duration(t-e,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(e){return e=e?rt(e).zone():0,(this.zone()-e)%60===0},daysInMonth:function(){return Y(this.year(),this.month())},dayOfYear:function(e){var t=ot((rt(this).startOf("day")-rt(this).startOf("year"))/864e5)+1;return null==e?t:this.add("d",e-t)},quarter:function(){return Math.ceil((this.month()+1)/3)},weekYear:function(e){var t=R(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==e?t:this.add("y",e-t)},isoWeekYear:function(e){var t=R(this,1,4).year;return null==e?t:this.add("y",e-t)},week:function(e){var t=this.lang().week(this);return null==e?t:this.add("d",7*(e-t))},isoWeek:function(e){var t=R(this,1,4).week;return null==e?t:this.add("d",7*(e-t))},weekday:function(e){var t=(this.day()+7-this.lang()._week.dow)%7;return null==e?t:this.add("d",e-t)},isoWeekday:function(e){return null==e?this.day()||7:this.day(this.day()%7?e:e-7)},get:function(e){return e=m(e),this[e]()},set:function(e,t){return e=m(e),"function"==typeof this[e]&&this[e](t),this},lang:function(t){return t===e?this._lang:(this._lang=O(t),this)}}),st=0;stLoading commit history...",window.onload=function(){rssfeedsetup()}; \ No newline at end of file diff --git a/misc/website/websitev2/minify.bat b/misc/website/websitev2/minify.bat index ca473f684..4aeb37941 100644 --- a/misc/website/websitev2/minify.bat +++ b/misc/website/websitev2/minify.bat @@ -6,7 +6,7 @@ rem npm install -g uglify-js pushd %~dp0 echo minifying and combining css files... -type css\stylesheet.css css\normalize.css | cleancss --s0 --remove-empty -o css\pack.css +type css\normalize.css css\stylesheet.css | cleancss --s0 --compatibility ie8 --debug -o css\pack.css cmd /c uglifyjs js\moment.js js\feed.js --compress --mangle -o js\pack.js popd diff --git a/misc/website/websitev2/update.php b/misc/website/websitev2/update.php index 73b6a473e..a947a4371 100644 --- a/misc/website/websitev2/update.php +++ b/misc/website/websitev2/update.php @@ -4,12 +4,12 @@ echo "".PHP_EOL; echo "".PHP_EOL; -echo "".htmlspecialchars($LATEST_PH_VERSION)."".PHP_EOL; -echo "".htmlspecialchars($LATEST_PH_BUILD)."".PHP_EOL; -echo "".htmlspecialchars($LATEST_PH_RELEASE_DATE)."".PHP_EOL; -echo "".htmlspecialchars($LATEST_PH_SETUP_SIZE)."".PHP_EOL; +echo "".$LATEST_PH_VERSION."".PHP_EOL; +echo "".$LATEST_PH_BUILD."".PHP_EOL; echo "".$LATEST_PH_SETUP_SHA1."".PHP_EOL; +echo "".$LATEST_PH_RELEASE_DATE."".PHP_EOL; +echo "".$LATEST_PH_SETUP_SIZE."".PHP_EOL; echo "".htmlspecialchars($LATEST_PH_RELEASE_NEWS)."".PHP_EOL; +echo "".htmlspecialchars($LATEST_PH_RELEASE_URL)."".PHP_EOL; echo ""; - ?> \ No newline at end of file diff --git a/misc/website/websitev3/.htaccess b/misc/website/websitev3/.htaccess new file mode 100644 index 000000000..00ca592d2 --- /dev/null +++ b/misc/website/websitev3/.htaccess @@ -0,0 +1,569 @@ +# Apache Server Configs v1.1.0 | MIT License +# https://github.com/h5bp/server-configs-apache + +# (!) Using `.htaccess` files slows down Apache, therefore, if you have access +# to the main server config file (usually called `httpd.conf`), you should add +# this logic there: http://httpd.apache.org/docs/current/howto/htaccess.html. + +# ############################################################################## +# # CROSS-ORIGIN RESOURCE SHARING (CORS) # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Cross-domain AJAX requests | +# ------------------------------------------------------------------------------ + +# Enable cross-origin AJAX requests. +# http://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity +# http://enable-cors.org/ + +# +# Header set Access-Control-Allow-Origin "*" +# + +# ------------------------------------------------------------------------------ +# | CORS-enabled images | +# ------------------------------------------------------------------------------ + +# Send the CORS header for images when browsers request it. +# https://developer.mozilla.org/en/CORS_Enabled_Image +# http://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html +# http://hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/ + + + + + SetEnvIf Origin ":" IS_CORS + Header set Access-Control-Allow-Origin "*" env=IS_CORS + + + + +# ------------------------------------------------------------------------------ +# | Web fonts access | +# ------------------------------------------------------------------------------ + +# Allow access from all domains for web fonts + + + + Header set Access-Control-Allow-Origin "*" + + + + +# ############################################################################## +# # ERRORS # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | 404 error prevention for non-existing redirected folders | +# ------------------------------------------------------------------------------ + +# Prevent Apache from returning a 404 error for a rewrite if a directory +# with the same name does not exist. +# http://httpd.apache.org/docs/current/content-negotiation.html#multiviews +# http://www.webmasterworld.com/apache/3808792.htm + +Options -MultiViews + +# ------------------------------------------------------------------------------ +# | Custom error messages / pages | +# ------------------------------------------------------------------------------ + +# You can customize what Apache returns to the client in case of an error (see +# http://httpd.apache.org/docs/current/mod/core.html#errordocument), e.g.: + +#ErrorDocument 404 /404.html + +ErrorDocument 400 /error.php +ErrorDocument 401 /error.php +ErrorDocument 403 /error.php +ErrorDocument 404 /error.php +ErrorDocument 405 /error.php +ErrorDocument 500 /error.php + +# ############################################################################## +# # INTERNET EXPLORER # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Better website experience | +# ------------------------------------------------------------------------------ + +# Force IE to render pages in the highest available mode in the various +# cases when it may not: http://hsivonen.iki.fi/doctype/ie-mode.pdf. + + + Header set X-UA-Compatible "IE=edge" + # `mod_headers` can't match based on the content-type, however, we only + # want to send this header for HTML pages and not for the other resources + + Header unset X-UA-Compatible + + + +# ------------------------------------------------------------------------------ +# | Cookie setting from iframes | +# ------------------------------------------------------------------------------ + +# Allow cookies to be set from iframes in IE. + +# +# Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"" +# + +# ------------------------------------------------------------------------------ +# | Screen flicker | +# ------------------------------------------------------------------------------ + +# Stop screen flicker in IE on CSS rollovers (this only works in +# combination with the `ExpiresByType` directives for images from below). + +# BrowserMatch "MSIE" brokenvary=1 +# BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1 +# BrowserMatch "Opera" !brokenvary +# SetEnvIf brokenvary 1 force-no-vary + + +# ############################################################################## +# # MIME TYPES AND ENCODING # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Proper MIME types for all files | +# ------------------------------------------------------------------------------ + + + + # Audio + AddType audio/mp4 m4a f4a f4b + AddType audio/ogg oga ogg + + # JavaScript + # Normalize to standard type (it's sniffed in IE anyways): + # http://tools.ietf.org/html/rfc4329#section-7.2 + AddType application/javascript js + AddType application/json json + + # Video + AddType video/mp4 mp4 m4v f4v f4p + AddType video/ogg ogv + AddType video/webm webm + AddType video/x-flv flv + + # Web fonts + AddType application/font-woff woff + AddType application/vnd.ms-fontobject eot + + # Browsers usually ignore the font MIME types and sniff the content, + # however, Chrome shows a warning if other MIME types are used for the + # following fonts. + AddType application/x-font-ttf ttc ttf + AddType font/opentype otf + + # Make SVGZ fonts work on iPad: + # https://twitter.com/FontSquirrel/status/14855840545 + AddType image/svg+xml svg svgz + AddEncoding gzip svgz + + # Other + AddType application/octet-stream safariextz + AddType application/x-chrome-extension crx + AddType application/x-opera-extension oex + AddType application/x-shockwave-flash swf + AddType application/x-web-app-manifest+json webapp + AddType application/x-xpinstall xpi + AddType application/xml atom rdf rss xml + AddType image/webp webp + AddType image/x-icon ico + AddType text/cache-manifest appcache manifest + AddType text/vtt vtt + AddType text/x-component htc + AddType text/x-vcard vcf + + + +# ------------------------------------------------------------------------------ +# | UTF-8 encoding | +# ------------------------------------------------------------------------------ + +# Use UTF-8 encoding for anything served as `text/html` or `text/plain`. +AddDefaultCharset utf-8 + +# Force UTF-8 for certain file formats. + + AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml + + + +# ############################################################################## +# # URL REWRITES # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Rewrite engine | +# ------------------------------------------------------------------------------ + +# Turning on the rewrite engine and enabling the `FollowSymLinks` option is +# necessary for the following directives to work. + +# If your web host doesn't allow the `FollowSymlinks` option, you may need to +# comment it out and use `Options +SymLinksIfOwnerMatch` but, be aware of the +# performance impact: http://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks + +# Also, some cloud hosting services require `RewriteBase` to be set: +# http://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-mod-rewrite-not-working-on-my-site + + + Options +FollowSymlinks + # Options +SymLinksIfOwnerMatch + RewriteEngine On + # RewriteBase / + + +# ------------------------------------------------------------------------------ +# | Suppressing / Forcing the "www." at the beginning of URLs | +# ------------------------------------------------------------------------------ + +# The same content should never be available under two different URLs especially +# not with and without "www." at the beginning. This can cause SEO problems +# (duplicate content), therefore, you should choose one of the alternatives and +# redirect the other one. + +# By default option 1 (no "www.") is activated: +# http://no-www.org/faq.php?q=class_b + +# If you'd prefer to use option 2, just comment out all the lines from option 1 +# and uncomment the ones from option 2. + +# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME! + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Option 1: rewrite www.example.com → example.com + + + RewriteCond %{HTTPS} !=on + RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] + RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Option 2: rewrite example.com → www.example.com + +# Be aware that the following might not be a good idea if you use "real" +# subdomains for certain parts of your website. + +# +# RewriteCond %{HTTPS} !=on +# RewriteCond %{HTTP_HOST} !^www\..+$ [NC] +# RewriteCond %{HTTP_HOST} !=localhost [NC] +# RewriteCond %{HTTP_HOST} !=127.0.0.1 +# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] +# + + +# ############################################################################## +# # SECURITY # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Content Security Policy (CSP) | +# ------------------------------------------------------------------------------ + +# You can mitigate the risk of cross-site scripting and other content-injection +# attacks by setting a Content Security Policy which whitelists trusted sources +# of content for your site. + +# The example header below allows ONLY scripts that are loaded from the current +# site's origin (no inline scripts, no CDN, etc). This almost certainly won't +# work as-is for your site! + +# To get all the details you'll need to craft a reasonable policy for your site, +# read: http://html5rocks.com/en/tutorials/security/content-security-policy (or +# see the specification: http://w3.org/TR/CSP). + +# +# Header set Content-Security-Policy "script-src 'self'; object-src 'self'" +# +# Header unset Content-Security-Policy +# +# + +# ------------------------------------------------------------------------------ +# | File access | +# ------------------------------------------------------------------------------ + +# Block access to directories without a default document. +# Usually you should leave this uncommented because you shouldn't allow anyone +# to surf through every directory on your server (which may includes rather +# private places like the CMS's directories). + + + Options -Indexes + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Block access to hidden files and directories. +# This includes directories used by version control systems such as Git and SVN. + + + RewriteCond %{SCRIPT_FILENAME} -d [OR] + RewriteCond %{SCRIPT_FILENAME} -f + RewriteRule "(^|/)\." - [F] + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Block access to backup and source files. +# These files may be left by some text editors and can pose a great security +# danger when anyone has access to them. + + + Order allow,deny + Deny from all + Satisfy All + + +# ------------------------------------------------------------------------------ +# | Secure Sockets Layer (SSL) | +# ------------------------------------------------------------------------------ + +# Rewrite secure requests properly to prevent SSL certificate warnings, e.g.: +# prevent `https://www.example.com` when your certificate only allows +# `https://secure.example.com`. + +# +# RewriteCond %{SERVER_PORT} !^443 +# RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L] +# + +# ------------------------------------------------------------------------------ +# | HTTP Strict Transport Security (HSTS) | +# ------------------------------------------------------------------------------ + +# Force client-side SSL redirection. + +# If a user types "example.com" in his browser, the above rule will redirect +# him to the secure version of the site. That still leaves a window of oppor- +# tunity (the initial HTTP connection) for an attacker to downgrade or redirect +# the request. The following header ensures that browser will ONLY connect to +# your server via HTTPS, regardless of what the users type in the address bar. +# http://tools.ietf.org/html/draft-ietf-websec-strict-transport-sec-14#section-6.1 +# http://www.html5rocks.com/en/tutorials/security/transport-layer-security/ + +# (!) Remove the `includeSubDomains` optional directive if the subdomains are +# not using HTTPS. + +# +# Header set Strict-Transport-Security "max-age=16070400; includeSubDomains" +# + +# ------------------------------------------------------------------------------ +# | Server software information | +# ------------------------------------------------------------------------------ + +# Avoid displaying the exact Apache version number, the description of the +# generic OS-type and the information about Apache's compiled-in modules. + +# ADD THIS DIRECTIVE IN THE `httpd.conf` AS IT WILL NOT WORK IN THE `.htaccess`! + +# ServerTokens Prod + + +# ############################################################################## +# # WEB PERFORMANCE # +# ############################################################################## + +# ------------------------------------------------------------------------------ +# | Compression | +# ------------------------------------------------------------------------------ + + + + # Force compression for mangled headers. + # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping + + + SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding + RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding + + + + # Compress all output labeled with one of the following MIME-types + # (for Apache versions below 2.3.7, you don't need to enable `mod_filter` + # and can remove the `` and `` lines + # as `AddOutputFilterByType` is still in the core directives). +# + AddOutputFilterByType DEFLATE application/atom+xml \ + application/javascript \ + application/json \ + application/rss+xml \ + application/vnd.ms-fontobject \ + application/x-font-ttf \ + application/x-web-app-manifest+json \ + application/xhtml+xml \ + application/xml \ + font/opentype \ + image/svg+xml \ + image/x-icon \ + text/css \ + text/html \ + text/plain \ + text/x-component \ + text/xml +# + + + +# ------------------------------------------------------------------------------ +# | Content transformations | +# ------------------------------------------------------------------------------ + +# Prevent some of the mobile network providers from modifying the content of +# your site: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5. + +# +# Header set Cache-Control "no-transform" +# + +# ------------------------------------------------------------------------------ +# | ETag removal | +# ------------------------------------------------------------------------------ + +# Since we're sending far-future expires headers (see below), ETags can +# be removed: http://developer.yahoo.com/performance/rules.html#etags. + +# `FileETag None` is not enough for every server. + + Header unset ETag + + +FileETag None + +# ------------------------------------------------------------------------------ +# | Expires headers (for better cache control) | +# ------------------------------------------------------------------------------ + +# The following expires headers are set pretty far in the future. If you don't +# control versioning with filename-based cache busting, consider lowering the +# cache time for resources like CSS and JS to something like 1 week. + + + + ExpiresActive on + ExpiresDefault "access plus 1 month" + + # CSS + ExpiresByType text/css "access plus 1 week" + + # Data interchange + ExpiresByType application/json "access plus 0 seconds" + ExpiresByType application/xml "access plus 0 seconds" + ExpiresByType text/xml "access plus 0 seconds" + + # Favicon (cannot be renamed!) + ExpiresByType image/x-icon "access plus 1 week" + + # HTML components (HTCs) + ExpiresByType text/x-component "access plus 1 month" + + # HTML + ExpiresByType text/html "access plus 0 seconds" + + # JavaScript + ExpiresByType application/javascript "access plus 1 week" + + # Manifest files + ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" + ExpiresByType text/cache-manifest "access plus 0 seconds" + + # Media + ExpiresByType audio/ogg "access plus 1 month" + ExpiresByType image/gif "access plus 1 month" + ExpiresByType image/jpeg "access plus 1 month" + ExpiresByType image/png "access plus 1 month" + ExpiresByType video/mp4 "access plus 1 month" + ExpiresByType video/ogg "access plus 1 month" + ExpiresByType video/webm "access plus 1 month" + + # Web feeds + ExpiresByType application/atom+xml "access plus 1 hour" + ExpiresByType application/rss+xml "access plus 1 hour" + + # Web fonts + ExpiresByType application/font-woff "access plus 1 month" + ExpiresByType application/vnd.ms-fontobject "access plus 1 month" + ExpiresByType application/x-font-ttf "access plus 1 month" + ExpiresByType font/opentype "access plus 1 month" + ExpiresByType image/svg+xml "access plus 1 month" + + + +# ------------------------------------------------------------------------------ +# | Filename-based cache busting | +# ------------------------------------------------------------------------------ + +# If you're not using a build process to manage your filename version revving, +# you might want to consider enabling the following directives to route all +# requests such as `/css/style.12345.css` to `/css/style.css`. + +# To understand why this is important and a better idea than `*.css?v231`, read: +# http://stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring + +# +# RewriteCond %{REQUEST_FILENAME} !-f +# RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] +# + +# ------------------------------------------------------------------------------ +# | File concatenation | +# ------------------------------------------------------------------------------ + +# Allow concatenation from within specific CSS and JS files, e.g.: +# Inside of `script.combined.js` you could have +# +# +# and they would be included into this single file. + +# +# +# Options +Includes +# AddOutputFilterByType INCLUDES application/javascript application/json +# SetOutputFilter INCLUDES +# +# +# Options +Includes +# AddOutputFilterByType INCLUDES text/css +# SetOutputFilter INCLUDES +# +# + +# ------------------------------------------------------------------------------ +# | Persistent connections | +# ------------------------------------------------------------------------------ + +# Allow multiple requests to be sent over the same TCP connection: +# http://httpd.apache.org/docs/current/en/mod/core.html#keepalive. + +# Enable if you serve a lot of static content but, be aware of the +# possible disadvantages! + +# +# Header set Connection Keep-Alive +# + +# custom PH code + +Order Allow,Deny +Deny from All + + + +allow from all + + +php_value memory_limit 32M diff --git a/misc/website/websitev3/about.php b/misc/website/websitev3/about.php new file mode 100644 index 000000000..0d6dd71a8 --- /dev/null +++ b/misc/website/websitev3/about.php @@ -0,0 +1,102 @@ + + +
+
+
+
+ Basic panel +
+
+
+
Panel heading
+
+ Panel content +
+
+
+
+ Panel content +
+ +
+
+
+
+
+

Panel primary

+
+
+ Panel content +
+
+
+
+

Panel success

+
+
+ Panel content +
+
+
+
+

Panel warning

+
+
+ Panel content +
+
+
+
+
+
+

Panel danger

+
+
+ Panel content +
+
+
+
+

Panel info

+
+
+ Panel content +
+
+
+
+ +
+
+

About

+
+

Process Hacker was started in 2008 as an open source alternative to programs such as Task Manager and Process Explorer.

+
    +
  • Registered: 16-10-2008
  • +
  • Licence: GNU General Public License version 3.0 GPLv3
  • +
  • Language: English
  • +
  • Intended Audience: Advanced End Users, Developers
  • +
  • Programming Language: C, C#
  • +
+
+
+
+

Ohloh Stats

+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/misc/website/websitev3/changelog.php b/misc/website/websitev3/changelog.php new file mode 100644 index 000000000..bbaf9612b --- /dev/null +++ b/misc/website/websitev3/changelog.php @@ -0,0 +1,9 @@ + + +
+

Changelog

+

This is the changelog from Process Hacker's SVN repository and may contain information from nightly builds.

+ +
+ + diff --git a/misc/website/websitev3/css/custom.css b/misc/website/websitev3/css/custom.css new file mode 100644 index 000000000..48f69c71a --- /dev/null +++ b/misc/website/websitev3/css/custom.css @@ -0,0 +1,103 @@ +html { + overflow-y: scroll; +} + +body { + /*color: #FFFFFF; + background-color: #222222;*/ + padding-top:65px; +} + +p { + margin: 0 0 5px; +} + +#forumitem { + font-size: 12px; + font-family: 'Open Sans', sans-serif; +} + +#forumitem img { + width: 16px; + height: 16px; +} + +.footer { + color: silver; +} + +#author { + color:#A00 +} + +.panel-index { + padding: 0; +} + +.well-sm { + padding: 9px 0; +} + +.container hr { + margin: 20px 0 5px 0; +} + +.page-header { + margin: 0 0 20px; + padding-bottom: 2px; +} + +.nav-header { + color: #999; +} + +.splash-cover { + background: #363b48; + width: 100%; + height: 100%; + top: 0; + position: absolute; + z-index: 2; + opacity: 0.85; + filter: alpha(opacity=85); +} + +.splash-block { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + z-index: 100; +} + +.splash-block:before { + content: ''; + display: inline-block; + height: 100%; + vertical-align: middle; + margin-right: -0.25em; + /* Adjusts for spacing */ +} + +.centered { + display: inline-block; + vertical-align: middle; + width: 100%; + padding: 100px 0; +} + +.changelog { + border: 2px solid #000; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; + overflow: scroll; + width: 100%; + height: 600px; +} + +.navbar-collapse { + padding-right: 0px; + padding-left: 0px; +} \ No newline at end of file diff --git a/misc/website/websitev3/downloads.php b/misc/website/websitev3/downloads.php new file mode 100644 index 000000000..011a4c2d1 --- /dev/null +++ b/misc/website/websitev3/downloads.php @@ -0,0 +1,102 @@ + + +
+

Process Hacker

+

+ Released +

+
+ +
+
+
+
+
+
+

Installer (recommended)

+
+ + + + +
+
+ +
+ +
+
+
+ +
+

Binaries (portable)

+ processhacker--bin.zip +

+
+
+
+
+ +
+
+
+
+ +
+

Source code

+ processhacker--src.zip +

+
+
+
+ +
+ +
+
+
+ +
+

Plugin SDK

+ processhacker--sdk.zip +

+
+
+
+
+
+ + + \ No newline at end of file diff --git a/misc/website/websitev3/faq.php b/misc/website/websitev3/faq.php new file mode 100644 index 000000000..c69bd8b8c --- /dev/null +++ b/misc/website/websitev3/faq.php @@ -0,0 +1,114 @@ + + +
+

Frequently Asked Questions

+ +

Is "Process Hacker" a dangerous "hacking" tool?

+ No. Please read about the correct definition of "hacker". + +
+

Is Process Hacker a portable application?

+ Yes. In the same directory as ProcessHacker.exe, create a file named ProcessHacker.exe.settings.xml, settings will then be automatically saved here. + +
+

Process Hacker can kill my anti-virus software! Is this a bug in the anti-virus software?

+ No. Please do not report these incidents as bugs because you will be wasting their time. + +
+

Why is Process Hacker able to kill processes that no other tools can kill?

+ Process Hacker loads a driver that searches for an internal Microsoft kernel function and uses it for process termination. + This function is not known to be hooked by malware or security software. + +
+

Why is there annoying bug X in Process Hacker? Why is Process Hacker missing feature Y?

+ Please report any bugs or feature requests in the forums. + +
+

Why can't I build Process Hacker?

+ The most likely problem is that you do not have the latest Windows SDK installed.
+ Windows XP, Vista and Windows 7 SDK: Windows SDK
+ Windows 7, Windows 8 SDK: Windows 8 SDK
+ Windows 7, Windows 8 and 8.1 SDK: Windows 8.1 SDK + +
+

Symbols don't work properly!

+ Firstly, you need the latest dbghelp.dll version:
+
+ 1) Install the latest Windows SDK. (links are below)
+ 2) Open Process Hacker options via the main menu: Hacker > Options
+ 3) Click Symbols, and locate dbghelp.dll
+
+
+ Windows XP, Vista and Windows 7 SDK:
+ C:\Program Files\Debugging Tools for Windows (x86)\

+ Windows 8 or above SDK:
+ 32bit: \Program Files (x86)\Windows Kits\8.x\Debuggers\x86\
+ 64bit: \Program Files (x86)\Windows Kits\8.x\Debuggers\x64\
+
+
+ Secondly, you need to configure the search path. If you don't know what to do, enter:
+ SRV*SOME_FOLDER*http://msdl.microsoft.com/download/symbols

+ Replace SOME_FOLDER with any folder you can write to, like D:\Symbols. + Now you can restart Process Hacker and view full symbols. + +
+

Why can't I debug my plugin?

+ The most likely problem is that you have not configured the plugin Solution properties > Debugger options.
+
+ For example; Debugging current plugins can be configured using the following settings:
+ Debugger Command: $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\ProcessHacker.exe
+ Working Directory: $(SolutionDir)..\bin\$(Configuration)$(PlatformArchitecture)\ + +
+

Anti-cheat software reports Process Hacker as a game cheating tool!

+ Unfortunately there is nothing much that can be done about this. Report issues with Anti-cheat software to dmex. +
+ +
+
+ +
+
+ + \ No newline at end of file diff --git a/misc/website/websitev3/favicon.ico b/misc/website/websitev3/favicon.ico new file mode 100644 index 000000000..295d4206d Binary files /dev/null and b/misc/website/websitev3/favicon.ico differ diff --git a/misc/website/websitev3/features.php b/misc/website/websitev3/features.php new file mode 100644 index 000000000..cb945f54a --- /dev/null +++ b/misc/website/websitev3/features.php @@ -0,0 +1,88 @@ + + +
+

Features

+
+
+
+

A detailed overview of system activity with highlighting.

A detailed overview of system activity with highlighting.

+
+ +
+ +
+

Graphs and statistics allow you quickly to track down resource hogs and runaway processes.

+

Tip: Use Ctrl+I to view system performance information. + Move your cursor over a graph to get a tooltip with information about the data point under your cursor. + You can double-click the graph to see information about the process at that data point, even if the process is no longer running.

+
+
+ +
+ +
+
+

Can't edit or delete a file? Discover which processes are using that file.

+

Tip: Use Ctrl+F to search for a handle or DLL. + If all else fails, you can right-click an entry and close the handle associated with the file. However, this + should only be used as a last resort and can lead to data loss and corruption.

+
+ +
+ +
+
+

See what programs have active network connections, and close them if necessary.

+
+
+ +
+
+ +
+ +
+
+ +
+

Get real-time information on disk access.

+

Tip: This may look very similar to the Disk Activity feature in Resource Monitor, but Process Hacker has a few more features!

+
+
+ +
+ +
+
+

View detailed stack traces with kernel-mode, WOW64 and .NET support.

+

Tip: Hover your cursor over the first column (with the numbers) to view parameter and line number information when available.

+
+
+
+ +
+ +
+
+ +
+
+

Go beyond services.msc: create, edit and control services.

+

Tip: By default, Process Hacker shows entries for drivers in addition to normal user-mode services. You can turn this off by checking View > Hide Driver Services.

+
+
+ +
+ +
+
+

And much more!

+
+ +
+
+
+ + \ No newline at end of file diff --git a/misc/website/websitev3/img/donate.png b/misc/website/websitev3/img/donate.png new file mode 100644 index 000000000..395004c6f Binary files /dev/null and b/misc/website/websitev3/img/donate.png differ diff --git a/misc/website/websitev3/img/logo_64x64.png b/misc/website/websitev3/img/logo_64x64.png new file mode 100644 index 000000000..03528b066 Binary files /dev/null and b/misc/website/websitev3/img/logo_64x64.png differ diff --git a/misc/website/websitev3/img/screenshots/disk_tab.png b/misc/website/websitev3/img/screenshots/disk_tab.png new file mode 100644 index 000000000..fbe861480 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/disk_tab.png differ diff --git a/misc/website/websitev3/img/screenshots/find_handles.png b/misc/website/websitev3/img/screenshots/find_handles.png new file mode 100644 index 000000000..5b69474c0 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/find_handles.png differ diff --git a/misc/website/websitev3/img/screenshots/main_window.png b/misc/website/websitev3/img/screenshots/main_window.png new file mode 100644 index 000000000..b403f72b4 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/main_window.png differ diff --git a/misc/website/websitev3/img/screenshots/menu.png b/misc/website/websitev3/img/screenshots/menu.png new file mode 100644 index 000000000..434438ab8 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/menu.png differ diff --git a/misc/website/websitev3/img/screenshots/network.png b/misc/website/websitev3/img/screenshots/network.png new file mode 100644 index 000000000..8c777a4c4 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/network.png differ diff --git a/misc/website/websitev3/img/screenshots/services.png b/misc/website/websitev3/img/screenshots/services.png new file mode 100644 index 000000000..b7f95fbe6 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/services.png differ diff --git a/misc/website/websitev3/img/screenshots/stats.png b/misc/website/websitev3/img/screenshots/stats.png new file mode 100644 index 000000000..34f477cb3 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/stats.png differ diff --git a/misc/website/websitev3/img/screenshots/sysinfo.png b/misc/website/websitev3/img/screenshots/sysinfo.png new file mode 100644 index 000000000..6db5e5b29 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/sysinfo.png differ diff --git a/misc/website/websitev3/img/screenshots/sysinfo_cpu.png b/misc/website/websitev3/img/screenshots/sysinfo_cpu.png new file mode 100644 index 000000000..fe6c0a004 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/sysinfo_cpu.png differ diff --git a/misc/website/websitev3/img/screenshots/sysinfo_memory.png b/misc/website/websitev3/img/screenshots/sysinfo_memory.png new file mode 100644 index 000000000..5e8c31e03 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/sysinfo_memory.png differ diff --git a/misc/website/websitev3/img/screenshots/sysinfo_trimmed.png b/misc/website/websitev3/img/screenshots/sysinfo_trimmed.png new file mode 100644 index 000000000..6db5e5b29 Binary files /dev/null and b/misc/website/websitev3/img/screenshots/sysinfo_trimmed.png differ diff --git a/misc/website/websitev3/img/screenshots/sysinfo_trimmed_1.png b/misc/website/websitev3/img/screenshots/sysinfo_trimmed_1.png new file mode 100644 index 000000000..bb453528e Binary files /dev/null and b/misc/website/websitev3/img/screenshots/sysinfo_trimmed_1.png differ diff --git a/misc/website/websitev3/img/screenshots/thread_stack.png b/misc/website/websitev3/img/screenshots/thread_stack.png new file mode 100644 index 000000000..484fc5d6b Binary files /dev/null and b/misc/website/websitev3/img/screenshots/thread_stack.png differ diff --git a/misc/website/websitev3/img/sflogo.png b/misc/website/websitev3/img/sflogo.png new file mode 100644 index 000000000..1f3d77c50 Binary files /dev/null and b/misc/website/websitev3/img/sflogo.png differ diff --git a/misc/website/websitev3/include/.htaccess b/misc/website/websitev3/include/.htaccess new file mode 100644 index 000000000..3418e55a6 --- /dev/null +++ b/misc/website/websitev3/include/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/misc/website/websitev3/include/config.php b/misc/website/websitev3/include/config.php new file mode 100644 index 000000000..5707bd687 --- /dev/null +++ b/misc/website/websitev3/include/config.php @@ -0,0 +1,108 @@ += 60 * 60 * 24 * 365.242199) + { + /* + * 60 seconds/minute * 60 minutes/hour * 24 hours/day * 365.242199 days/year + * This means that the time difference is 1 year or more + */ + return get_time_ago_string($time_stamp, 60 * 60 * 24 * 365.242199, 'year'); + } + elseif ($time_difference >= 60 * 60 * 24 * 30.4368499) + { + /* + * 60 seconds/minute * 60 minutes/hour * 24 hours/day * 30.4368499 days/month + * This means that the time difference is 1 month or more + */ + return get_time_ago_string($time_stamp, 60 * 60 * 24 * 30.4368499, 'month'); + } + elseif ($time_difference >= 60 * 60 * 24 * 7) + { + /* + * 60 seconds/minute * 60 minutes/hour * 24 hours/day * 7 days/week + * This means that the time difference is 1 week or more + */ + return get_time_ago_string($time_stamp, 60 * 60 * 24 * 7, 'week'); + } + elseif ($time_difference >= 60 * 60 * 24) + { + /* + * 60 seconds/minute * 60 minutes/hour * 24 hours/day + * This means that the time difference is 1 day or more + */ + return get_time_ago_string($time_stamp, 60 * 60 * 24, 'day'); + } + elseif ($time_difference >= 60 * 60) + { + /* + * 60 seconds/minute * 60 minutes/hour + * This means that the time difference is 1 hour or more + */ + return get_time_ago_string($time_stamp, 60 * 60, 'hour'); + } + else + { + /* + * 60 seconds/minute + * This means that the time difference is a matter of minutes + */ + return get_time_ago_string($time_stamp, 60, 'minute'); + } +} + +function get_time_ago_string($time_stamp, $divisor, $time_unit) +{ + $time_difference = strtotime("now") - $time_stamp; + $time_units = floor($time_difference / $divisor); + + settype($time_units, 'string'); + + if ($time_units === '0') { + return 'less than 1 ' . $time_unit . ' ago'; + } elseif ($time_units === '1') { + return '1 ' . $time_unit . ' ago'; + } else { + /* + * More than "1" $time_unit. This is the "plural" message. + */ + // TODO: This pluralizes the time unit, which is done by adding "s" at the end; this will not work for i18n! + return $time_units . ' ' . $time_unit . 's ago'; + } +} +?> diff --git a/misc/website/websitev3/include/footer.php b/misc/website/websitev3/include/footer.php new file mode 100644 index 000000000..b4846d6e5 --- /dev/null +++ b/misc/website/websitev3/include/footer.php @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/misc/website/websitev3/include/header.php b/misc/website/websitev3/include/header.php new file mode 100644 index 000000000..01ad5ee90 --- /dev/null +++ b/misc/website/websitev3/include/header.php @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + "; + } ?> + <?php echo $pagetitle ?> - Process Hacker + + + + + +
\ No newline at end of file diff --git a/misc/website/websitev3/include/phpbb.php b/misc/website/websitev3/include/phpbb.php new file mode 100644 index 000000000..bbc790ca2 --- /dev/null +++ b/misc/website/websitev3/include/phpbb.php @@ -0,0 +1,44 @@ +session_begin(); + $auth->acl($user->data); + $user->setup(); +} + + +// This function summarizes posts to max. 1200 characters +function summary($str, $limit = 1200, $strip = false) { + $str = ($strip == true)?strip_tags($str):$str; + if (strlen ($str) > $limit) { + $str = substr ($str, 0, $limit - 3); + return trim(substr ($str, 0, strrpos ($str, ' ')).'...'); + } + return trim($str); +} +?> \ No newline at end of file diff --git a/misc/website/websitev3/index.php b/misc/website/websitev3/index.php new file mode 100644 index 000000000..a76d4e81c --- /dev/null +++ b/misc/website/websitev3/index.php @@ -0,0 +1,168 @@ + + +
+
+
+
+

Process Hacker

+

+ A free, powerful, multi-purpose tool that helps you monitor system resources, debug software and detect malware. +

+

Learn more »

+
+
+
+
+ +
+
+
+

Latest Posts

+
+
+ Failed to connect to MySQL: ".mysqli_connect_error()."

"; + } + else + { + $sql = "SELECT + t.topic_id, + t.topic_title, + t.topic_views, + t.topic_last_post_id, + t.forum_id, + p.post_id, + p.poster_id, + p.post_time, + u.user_id, + u.username, + u.user_colour + FROM $table_topics t, $table_forums f, $table_posts p, $table_users u + WHERE t.topic_id = p.topic_id AND + t.topic_approved = 1 AND + f.forum_id = t.forum_id AND + t.forum_id != 1 AND + t.forum_id != 7 AND + t.topic_status <> 2 AND + p.post_approved = 1 AND + p.post_id = t.topic_last_post_id AND + p.poster_id = u.user_id + ORDER BY p.post_id DESC LIMIT $topicnumber"; + + if ($result = mysqli_query($conn, $sql)) + { + while ($row = mysqli_fetch_array($result)) + { + // Query fields + $topic_title = $row["topic_title"]; + $topic_views = $row["topic_views"]; + $author_name = $row["username"]; + $author_colour = $row["user_colour"]; + $post_time = $row["post_time"]; + $post_id = $row["post_id"]; + $author_link = $row["user_id"]; + + // Convert values + $post_local_time = date("F jS, Y, g:i a", $post_time); + $post_date = get_time_ago($post_time); + $post_link = "http://processhacker.sourceforge.net/forums/viewtopic.php?p=".$post_id."#p".$post_id; + $author_link = "http://processhacker.sourceforge.net/forums/memberlist.php?mode=viewprofile&u=".$author_link; + + echo + "{$topic_views} +

{$topic_title}

+

+ ".$post_date.", ".$post_local_time." by ".$author_name." +

+
"; + } + + mysqli_free_result($result); + } + } + ?> +
+
+
+ +
+
+
+

Latest News

+
+
+ Failed to connect to MySQL: " . mysqli_connect_error()."

"; + } + else + { + $sql = "SELECT + t.topic_id, + t.topic_title, + t.topic_views, + t.topic_last_post_id, + t.forum_id, + p.post_id, + p.poster_id, + p.post_time, + u.user_id, + u.username, + u.user_colour + FROM $table_topics t, $table_forums f, $table_posts p, $table_users u + WHERE t.topic_id = p.topic_id AND + f.forum_id = t.forum_id AND + t.forum_id = 1 AND + t.topic_status <> 2 AND + p.post_id = t.topic_last_post_id AND + p.poster_id = u.user_id + ORDER BY p.post_id DESC LIMIT $topicnumber"; + + if ($result = mysqli_query($conn, $sql)) + { + while ($row = mysqli_fetch_array($result)) + { + // Query fields + $topic_title = $row["topic_title"]; + $topic_views = $row["topic_views"]; + $author_name = $row["username"]; + $author_colour = $row["user_colour"]; + $post_time = $row["post_time"]; + $post_id = $row["post_id"]; + $author_link = $row["user_id"]; + + // Convert values + $post_local_time = date("F jS, Y", $post_time); + $post_link = "http://processhacker.sourceforge.net/forums/viewtopic.php?p=".$post_id."#p".$post_id; + $author_link = "http://processhacker.sourceforge.net/forums/memberlist.php?mode=viewprofile&u=".$author_link; + + echo + "{$topic_views} +

".$topic_title."

+

+ ".$post_local_time." by ".$author_name." +

+
"; + } + + mysqli_free_result($result); + } + } + ?> +
+
+
+ +
+
+ +
+
+ + \ No newline at end of file diff --git a/misc/website/websitev3/js/bootstrap.js b/misc/website/websitev3/js/bootstrap.js new file mode 100644 index 000000000..2c6425714 --- /dev/null +++ b/misc/website/websitev3/js/bootstrap.js @@ -0,0 +1,1999 @@ +/** +* bootstrap.js v3.0.0 by @fat and @mdo +* Copyright 2013 Twitter Inc. +* http://www.apache.org/licenses/LICENSE-2.0 +*/ +if (!jQuery) { throw new Error("Bootstrap requires jQuery") } + +/* ======================================================================== + * Bootstrap: transition.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#transitions + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) + // ============================================================ + + function transitionEnd() { + var el = document.createElement('bootstrap') + + var transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + } + + for (var name in transEndEventNames) { + if (el.style[name] !== undefined) { + return { end: transEndEventNames[name] } + } + } + } + + // http://blog.alexmaccaw.com/css-transitions + $.fn.emulateTransitionEnd = function (duration) { + var called = false, $el = this + $(this).one($.support.transition.end, function () { called = true }) + var callback = function () { if (!called) $($el).trigger($.support.transition.end) } + setTimeout(callback, duration) + return this + } + + $(function () { + $.support.transition = transitionEnd() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: alert.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#alerts + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // ALERT CLASS DEFINITION + // ====================== + + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } + + var $parent = $(selector) + + if (e) e.preventDefault() + + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } + + $parent.trigger(e = $.Event('close.bs.alert')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent.trigger('closed.bs.alert').remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : + removeElement() + } + + + // ALERT PLUGIN DEFINITION + // ======================= + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') + + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + // ALERT NO CONFLICT + // ================= + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + // ALERT DATA-API + // ============== + + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: button.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#buttons + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // BUTTON PUBLIC CLASS DEFINITION + // ============================== + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() + + state = state + 'Text' + + if (!data.resetText) $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d); + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + .prop('checked', !this.$element.hasClass('active')) + .trigger('change') + if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + } + + this.$element.toggleClass('active') + } + + + // BUTTON PLUGIN DEFINITION + // ======================== + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.Constructor = Button + + + // BUTTON NO CONFLICT + // ================== + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + // BUTTON DATA-API + // =============== + + $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + e.preventDefault() + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: carousel.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#carousel + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.DEFAULTS = { + interval: 5000 + , pause: 'hover' + , wrap: true + } + + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) + + this.interval && clearInterval(this.interval) + + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + + return this + } + + Carousel.prototype.getActiveIndex = function () { + this.$active = this.$element.find('.item.active') + this.$items = this.$active.parent().children() + + return this.$items.index(this.$active) + } + + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getActiveIndex() + + if (pos > (this.$items.length - 1) || pos < 0) return + + if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } + + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle(true) + } + + this.interval = clearInterval(this.interval) + + return this + } + + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } + + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } + + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this + + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() + } + + this.sliding = true + + isCycling && this.pause() + + var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + + if ($next.hasClass('active')) return + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + this.$element.one('slid', function () { + var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) + $nextIndicator && $nextIndicator.addClass('active') + }) + } + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + .emulateTransitionEnd(600) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') + } + + isCycling && this.cycle() + + return this + } + + + // CAROUSEL PLUGIN DEFINITION + // ========================== + + var old = $.fn.carousel + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } + + $.fn.carousel.Constructor = Carousel + + + // CAROUSEL NO CONFLICT + // ==================== + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + + + // CAROUSEL DATA-API + // ================= + + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var $this = $(this), href + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false + + $target.carousel(options) + + if (slideIndex = $this.attr('data-slide-to')) { + $target.data('bs.carousel').to(slideIndex) + } + + e.preventDefault() + }) + + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + $carousel.carousel($carousel.data()) + }) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: collapse.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#collapse + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // COLLAPSE PUBLIC CLASS DEFINITION + // ================================ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Collapse.DEFAULTS, options) + this.transitioning = null + + if (this.options.parent) this.$parent = $(this.options.parent) + if (this.options.toggle) this.toggle() + } + + Collapse.DEFAULTS = { + toggle: true + } + + Collapse.prototype.dimension = function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + Collapse.prototype.show = function () { + if (this.transitioning || this.$element.hasClass('in')) return + + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var actives = this.$parent && this.$parent.find('> .panel > .in') + + if (actives && actives.length) { + var hasData = actives.data('bs.collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('bs.collapse', null) + } + + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + .addClass('collapsing') + [dimension](0) + + this.transitioning = 1 + + var complete = function () { + this.$element + .removeClass('collapsing') + .addClass('in') + [dimension]('auto') + this.transitioning = 0 + this.$element.trigger('shown.bs.collapse') + } + + if (!$.support.transition) return complete.call(this) + + var scrollSize = $.camelCase(['scroll', dimension].join('-')) + + this.$element + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + [dimension](this.$element[0][scrollSize]) + } + + Collapse.prototype.hide = function () { + if (this.transitioning || !this.$element.hasClass('in')) return + + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var dimension = this.dimension() + + this.$element + [dimension](this.$element[dimension]()) + [0].offsetHeight + + this.$element + .addClass('collapsing') + .removeClass('collapse') + .removeClass('in') + + this.transitioning = 1 + + var complete = function () { + this.transitioning = 0 + this.$element + .trigger('hidden.bs.collapse') + .removeClass('collapsing') + .addClass('collapse') + } + + if (!$.support.transition) return complete.call(this) + + this.$element + [dimension](0) + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + } + + Collapse.prototype.toggle = function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + + // COLLAPSE PLUGIN DEFINITION + // ========================== + + var old = $.fn.collapse + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.collapse') + var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.Constructor = Collapse + + + // COLLAPSE NO CONFLICT + // ==================== + + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + // COLLAPSE DATA-API + // ================= + + $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + var target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + var $target = $(target) + var data = $target.data('bs.collapse') + var option = data ? 'toggle' : $this.data() + var parent = $this.attr('data-parent') + var $parent = parent && $(parent) + + if (!data || !data.transitioning) { + if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') + $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + } + + $target.collapse(option) + }) + +}(window.jQuery); + +/* ======================================================================== + * Bootstrap: dropdown.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + var $el = $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we we use a backdrop because click events don't delegate + $('