From 7337b0229192edec6fe51b2db37536509bf409c7 Mon Sep 17 00:00:00 2001 From: wj32 Date: Mon, 27 Apr 2009 07:37:45 +0000 Subject: [PATCH] * fixed Start hidden * fixed GC.AddMemoryPressure and RemoveMemoryPressure bugs git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1168 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- trunk/ProcessHacker.Native/Api/Enums.cs | 28 +++++++++++++++++++ trunk/ProcessHacker.Native/Api/Structs.cs | 6 ++-- trunk/ProcessHacker.Native/Cryptography.cs | 10 ++++++- .../Memory/MemoryAlloc.cs | 13 ++++++--- trunk/ProcessHacker/Forms/HackerWindow.cs | 4 +-- trunk/ProcessHacker/Program/Program.cs | 2 +- 6 files changed, 52 insertions(+), 11 deletions(-) diff --git a/trunk/ProcessHacker.Native/Api/Enums.cs b/trunk/ProcessHacker.Native/Api/Enums.cs index 92e294d48..cb08c8532 100644 --- a/trunk/ProcessHacker.Native/Api/Enums.cs +++ b/trunk/ProcessHacker.Native/Api/Enums.cs @@ -1067,6 +1067,34 @@ namespace ProcessHacker.Native.Api MaximizeBox = 0x00010000 } + [Flags] + public enum WtProvFlags : int + { + RevocationCheckNone = 0x10, + RevocationCheckEndCert = 0x20, + RevocationCheckChain = 0x40, + RevocationCheckChainExcludeRoot = 0x80, + Safer = 0x100, + HashOnly = 0x200, + UseDefaultOsVerCheck = 0x800, + CacheOnlyUrlRetrieval = 0x1000 + } + + public enum WtRevocationChecks : int + { + None = 0, + WholeChain = 1 + } + + public enum WtStateAction + { + Ignore = 0, + Verify = 1, + Close = 2, + AutoCache = 3, + AutoCacheFlush = 4 + } + public enum WtsConnectStateClass : int { Active, diff --git a/trunk/ProcessHacker.Native/Api/Structs.cs b/trunk/ProcessHacker.Native/Api/Structs.cs index 1b793be5b..dce95e359 100644 --- a/trunk/ProcessHacker.Native/Api/Structs.cs +++ b/trunk/ProcessHacker.Native/Api/Structs.cs @@ -1440,13 +1440,13 @@ namespace ProcessHacker.Native.Api public int PolicyCallbackData; public int SIPClientData; public int UIChoice; - public int RevocationChecks; + public WtRevocationChecks RevocationChecks; public int UnionChoice; public IntPtr UnionData; - public int StateAction; + public WtStateAction StateAction; public int StateData; public int URLReference; - public int ProvFlags; + public WtProvFlags ProvFlags; public int UIContext; } diff --git a/trunk/ProcessHacker.Native/Cryptography.cs b/trunk/ProcessHacker.Native/Cryptography.cs index a5ea461c6..f4d7521bf 100644 --- a/trunk/ProcessHacker.Native/Cryptography.cs +++ b/trunk/ProcessHacker.Native/Cryptography.cs @@ -94,7 +94,11 @@ namespace ProcessHacker.Native trustData.Size = 12 * 4; trustData.UIChoice = 2; // WTD_UI_NONE trustData.UnionChoice = 1; // WTD_CHOICE_FILE - trustData.ProvFlags = 0x100; // WTD_SAFER_FLAG + trustData.RevocationChecks = WtRevocationChecks.None; + trustData.ProvFlags = WtProvFlags.Safer; + + if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) + trustData.ProvFlags |= WtProvFlags.CacheOnlyUrlRetrieval; using (MemoryAlloc mem = new MemoryAlloc(fileInfo.Size)) { @@ -163,6 +167,10 @@ namespace ProcessHacker.Native trustData.Size = 12 * 4; trustData.UIChoice = 1; trustData.UnionChoice = 2; + trustData.RevocationChecks = WtRevocationChecks.None; + + if (OSVersion.IsAboveOrEqual(WindowsVersion.Vista)) + trustData.ProvFlags = WtProvFlags.CacheOnlyUrlRetrieval; using (MemoryAlloc mem = new MemoryAlloc(wci.Size)) { diff --git a/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs b/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs index bb4a3f17c..b947715cf 100644 --- a/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs +++ b/trunk/ProcessHacker.Native/Memory/MemoryAlloc.cs @@ -91,7 +91,9 @@ namespace ProcessHacker.Native { _memory = Marshal.AllocHGlobal(size); _size = size; - GC.AddMemoryPressure(size); + + if (size > 0) + GC.AddMemoryPressure(size); } ~MemoryAlloc() @@ -187,10 +189,12 @@ namespace ProcessHacker.Native /// The new size of the allocation. public virtual void Resize(int newSize) { - GC.RemoveMemoryPressure(_size); + if (_size > 0) + GC.RemoveMemoryPressure(_size); _memory = Marshal.ReAllocHGlobal(_memory, new IntPtr(newSize)); _size = newSize; - GC.AddMemoryPressure(_size); + if (_size > 0) + GC.AddMemoryPressure(_size); } /// @@ -247,7 +251,8 @@ namespace ProcessHacker.Native protected virtual void Free() { Marshal.FreeHGlobal(this); - GC.RemoveMemoryPressure(_size); + if (_size > 0) + GC.RemoveMemoryPressure(_size); } private void Dispose(bool disposing) diff --git a/trunk/ProcessHacker/Forms/HackerWindow.cs b/trunk/ProcessHacker/Forms/HackerWindow.cs index 49785072d..138dc4dcc 100644 --- a/trunk/ProcessHacker/Forms/HackerWindow.cs +++ b/trunk/ProcessHacker/Forms/HackerWindow.cs @@ -2433,6 +2433,8 @@ namespace ProcessHacker { var handle = this.Handle; } this.LoadWindowSettings(); + this.LoadControls(); + this.LoadNotificationIcons(); if ((!Properties.Settings.Default.StartHidden && !Program.StartHidden) || Program.StartVisible) @@ -2525,8 +2527,6 @@ namespace ProcessHacker vistaMenu.DelaySetImageCalls = false; vistaMenu.PerformPendingSetImageCalls(); this.LoadOtherSettings(); - this.LoadControls(); - this.LoadNotificationIcons(); this.CreateShutdownMenuItems(); this.LoadFixMenuItems(); this.LoadUac(); diff --git a/trunk/ProcessHacker/Program/Program.cs b/trunk/ProcessHacker/Program/Program.cs index 6ff49f56d..48f45583d 100644 --- a/trunk/ProcessHacker/Program/Program.cs +++ b/trunk/ProcessHacker/Program/Program.cs @@ -180,7 +180,7 @@ namespace ProcessHacker Application.Exit(); } - ThreadPool.SetMaxThreads(10, 20); + ThreadPool.SetMaxThreads(10, 10); Win32.CreateMutex(0, false, "Global\\ProcessHackerMutex");