├── .gitattributes ├── .gitignore ├── CPL.TXT ├── FilterExample.jpeg ├── ProcMonShowingTracing.jpeg ├── ReadMe.md └── Source ├── Include └── ProcMonDebugOutput.h ├── ManagedTest ├── App.config ├── ManagedTest.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── NativeTest ├── NativeTest.cpp ├── NativeTest.vcxproj ├── NativeTest.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── ProcMonDebugOutput.sln ├── ProcMonDebugOutput ├── ProcMonDebugOutput.cpp ├── ProcMonDebugOutput.rc ├── ProcMonDebugOutput.vcxproj ├── ProcMonDebugOutput.vcxproj.filters ├── ProcMonDebugOutputWIN32.def ├── resource.h ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── PythonExamples ├── HelloProcMon.ctypes.py ├── HelloProcMon.py ├── HelloProcMon27.ctypes.py ├── HelloProcMon27.py └── PythonExamples.pyproj ├── Sysinternals.Debug ├── AllCodeAnalysisRulesAsErrors.ruleset ├── CodeAnalysisDictionary.xml ├── GlobalSuppressions.cs ├── NativeMethods.cs ├── ProcessMonitorTraceListerner.cs ├── Properties │ └── AssemblyInfo.cs └── Sysinternals.Debug.csproj ├── Sysinternals.log4net ├── GlobalSuppressions.cs ├── ProcMonAppender.cs ├── Properties │ └── AssemblyInfo.cs ├── Sysinternals.log4net.csproj └── packages.config └── VBA └── ProcMon.bas /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | DebugWin32/ 53 | Debugx64/ 54 | 55 | # MSTest test Results 56 | [Tt]est[Rr]esult*/ 57 | [Bb]uild[Ll]og.* 58 | 59 | *_i.c 60 | *_p.c 61 | *.ilk 62 | *.meta 63 | *.obj 64 | *.pch 65 | *.pdb 66 | *.pgc 67 | *.pgd 68 | *.rsp 69 | *.sbr 70 | *.tlb 71 | *.tli 72 | *.tlh 73 | *.tmp 74 | *.tmp_proj 75 | *.log 76 | *.vspscc 77 | *.vssscc 78 | .builds 79 | *.pidb 80 | *.log 81 | *.scc 82 | 83 | # Visual C++ cache files 84 | ipch/ 85 | *.aps 86 | *.ncb 87 | *.opensdf 88 | *.sdf 89 | *.cachefile 90 | 91 | # Visual Studio profiler 92 | *.psess 93 | *.vsp 94 | *.vspx 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | *.ncrunch* 111 | .*crunch*.local.xml 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.Publish.xml 131 | *.pubxml 132 | 133 | # NuGet Packages Directory 134 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 135 | packages/ 136 | 137 | # Windows Azure Build Output 138 | csx 139 | *.build.csdef 140 | 141 | # Windows Store app package directory 142 | AppPackages/ 143 | 144 | # Others 145 | sql/ 146 | *.Cache 147 | ClientBin/ 148 | [Ss]tyle[Cc]op.* 149 | ~$* 150 | *~ 151 | *.dbmdl 152 | *.[Pp]ublish.xml 153 | *.pfx 154 | *.publishsettings 155 | 156 | # RIA/Silverlight projects 157 | Generated_Code/ 158 | 159 | # Backup & report files from converting an old project file to a newer 160 | # Visual Studio version. Backup files are not needed, because we have git ;-) 161 | _UpgradeReport_Files/ 162 | Backup*/ 163 | UpgradeLog*.XML 164 | UpgradeLog*.htm 165 | 166 | # SQL Server files 167 | App_Data/*.mdf 168 | App_Data/*.ldf 169 | 170 | ############# 171 | ## Windows detritus 172 | ############# 173 | 174 | # Windows image file caches 175 | Thumbs.db 176 | ehthumbs.db 177 | 178 | # Folder config file 179 | Desktop.ini 180 | 181 | # Recycle Bin used on file shares 182 | $RECYCLE.BIN/ 183 | 184 | # Mac crap 185 | .DS_Store 186 | 187 | 188 | ############# 189 | ## Python 190 | ############# 191 | 192 | *.py[co] 193 | 194 | # Packages 195 | *.egg 196 | *.egg-info 197 | dist/ 198 | build/ 199 | eggs/ 200 | parts/ 201 | var/ 202 | sdist/ 203 | develop-eggs/ 204 | .installed.cfg 205 | 206 | # Installer logs 207 | pip-log.txt 208 | 209 | # Unit test / coverage reports 210 | .coverage 211 | .tox 212 | 213 | #Translations 214 | *.mo 215 | 216 | #Mr Developer 217 | .mr.developer.cfg 218 | -------------------------------------------------------------------------------- /CPL.TXT: -------------------------------------------------------------------------------- 1 | Common Public License Version 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 6 | 1. DEFINITIONS 7 | 8 | "Contribution" means: 9 | 10 | a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. 19 | 20 | "Contributor" means any person or entity that distributes the Program. 21 | 22 | "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. 23 | 24 | "Program" means the Contributions distributed in accordance with this Agreement. 25 | 26 | "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 27 | 28 | 29 | 2. GRANT OF RIGHTS 30 | 31 | a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. 32 | 33 | b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. 34 | 35 | c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. 36 | 37 | d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 38 | 39 | 40 | 3. REQUIREMENTS 41 | 42 | A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: 43 | 44 | a) it complies with the terms and conditions of this Agreement; and 45 | 46 | b) its license agreement: 47 | 48 | i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; 49 | 50 | ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; 51 | 52 | iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and 53 | 54 | iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. 55 | 56 | When the Program is made available in source code form: 57 | 58 | a) it must be made available under this Agreement; and 59 | 60 | b) a copy of this Agreement must be included with each copy of the Program. 61 | 62 | Contributors may not remove or alter any copyright notices contained within the Program. 63 | 64 | Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 65 | 66 | 67 | 4. COMMERCIAL DISTRIBUTION 68 | 69 | Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. 70 | 71 | For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 72 | 73 | 74 | 5. NO WARRANTY 75 | 76 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 77 | 78 | 79 | 6. DISCLAIMER OF LIABILITY 80 | 81 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 82 | 83 | 84 | 7. GENERAL 85 | 86 | If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 87 | 88 | If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. 89 | 90 | All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. 91 | 92 | Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. 93 | 94 | This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. 95 | -------------------------------------------------------------------------------- /FilterExample.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wintellect/ProcMonDebugOutput/b9594c00122d3e78a588b77ec445f6261a5a916c/FilterExample.jpeg -------------------------------------------------------------------------------- /ProcMonShowingTracing.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wintellect/ProcMonDebugOutput/b9594c00122d3e78a588b77ec445f6261a5a916c/ProcMonShowingTracing.jpeg -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # See Your Trace Statements in Process Monitor! # 2 | A few years ago I got together with Mark Russinovich and we implemented a technique to enable developers to push tracing statements to Process Monitor so you can more easily see where you are causing I/O operations. You can read about the initial release of the code [here](http://www.wintellect.com/blogs/jrobbins/see-the-i-o-you-caused-by-getting-your-diagnostic-tracing-into-process-monitor). I'm moving the code to GitHub as that's where all open source code should be. :) 3 | 4 | The ProcMonDebugOutput library supports both native C++ and managed .NET languages as well as 32-bit and 64-bit. 5 | 6 | ## Building The Code ## 7 | All the projects are in Visual Studio 2013 format. I'm not using any advanced Premium or Ultimate features so everything should compile even with Visual Studio Express, but I have not tried. 8 | 9 | 1. Open up ProcMonDebugOutput.SLN 10 | 2. Select the Build, Batch Build menu 11 | 3. In the Batch Build dialog, click Select All button 12 | 4. Click the Build button 13 | 14 | The 32-bit binaries build to .\Source\ReleaseWin32 and .\Source\DebugWin32. 15 | The 64-bit binaries build to .\Source\Releasex64 and .\Source\Debugx64. 16 | 17 | ## Using with C++ Native Applications ## 18 | For native code, you’ll need to include the header file ProcMonDebugOutput.h and link against ProcMonDebugOutputx86.lib or ProcMonDebugOutputx64.lib as appropriate. The API you’ll call is, appropriately named, *ProcMonDebugOutput* which takes a single parameter of a UNICODE string. Obviously, you’ll need to add ProcMonDebugOutputx86.DLL or ProcMonDebugOutputx64.DLL as part of your distribution. See the .\Source\NativeTest application for an example. 19 | 20 | ## Using with .NET Applications ## 21 | For managed code, the API is wrapped up into a That means you can add ProcessMonitorTraceListener through [configuration files](http://msdn.microsoft.com/en-us/library/sk36c28t.aspx) like any TraceListener you’ve ever used. With your application you’ll only need to include Sysinternals.Debug.DLL as that's a complete managed implementation of the native API. 22 | 23 | If you are an aficionado of Log4Net, [Justin Dearing](https://github.com/zippy1981), did the Log4Net appender so you can include Sysinternals.log4net.dll and do all your usual log4net configuration to get it working. 24 | 25 | See the .\Source\ManagedTest application for a complete example showing both the TraceListener and Log4Net implementations 26 | 27 | ## Seeing Your Tracing in Process Monitor ## 28 | The tracing statements are reported as Profiling Events so to see them, add ensure the "Show Profiling Events" button is selected (the last one on the toolbar). These events are of Operation type "Debug Output Profiling". 29 | 30 | The following screen shot shows the tracing of the two sample programs with the filter set to only show tracing events. 31 | ![](ProcMonShowingTracing.jpeg) 32 | 33 | To filter and see only your tracing statements, set the Process Monitor filtering to "Operation = Debug Output Profiling". Here's an example. 34 | 35 | ![](FilterExample.jpeg) 36 | 37 | ## But I Want to See All OutputDebug/Debug.WriteLine calls in Process Monitor ## 38 | That's not going to happen. When Mark and I discussed adding tracing to Process Monitor, we talked about combining both Process Monitor and Debug View. It was far easier to add the custom interface presented here that to do the major engineering effort to combine the tools. Remember, shipping is a feature! 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Source/Include/ProcMonDebugOutput.h: -------------------------------------------------------------------------------- 1 | /*////////////////////////////////////////////////////////////////////////////// 2 | // Process Monitor Debug Output Header File 3 | // 4 | // History: 5 | // - April 1, 2010 - Version 1.0 - John Robbins/Wintellect 6 | // - Initial release 7 | // - March 1, 2014 - Version 1.1 - John Robbins/Wintellect 8 | // - Fixed an issue in DLL main where the handle could get close too 9 | // soon. 10 | // - Moved the project to VS 2013. 11 | // 12 | //////////////////////////////////////////////////////////////////////////////*/ 13 | 14 | #pragma once 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /*////////////////////////////////////////////////////////////////////////////// 21 | // The defines that set up how the functions or classes are exported or 22 | // imported. 23 | //////////////////////////////////////////////////////////////////////////////*/ 24 | #ifndef PROCMONDEBUGOUTPUT_DLLINTERFACE 25 | #ifdef PROCMONDEBUGOUTPUT_EXPORTS 26 | #define PROCMONDEBUGOUTPUT_DLLINTERFACE __declspec ( dllexport ) 27 | #else 28 | #define PROCMONDEBUGOUTPUT_DLLINTERFACE __declspec ( dllimport ) 29 | #endif 30 | #endif 31 | 32 | 33 | /*////////////////////////////////////////////////////////////////////////////// 34 | // ProcMonDebugOutput 35 | // Sends a string to Process Monitor for display. 36 | // 37 | // Parameters: 38 | // pszOutputString 39 | // The null-terminated wide character string to be displayed. 40 | // 41 | // Return Values: 42 | // TRUE - The string was sent to Process Monitor. 43 | // FALSE - There was a problem sending the string to Process Monitor. To get 44 | // extended error information, call GetLastError to determine the 45 | // exact failure. 46 | // 47 | // Last Error Codes: 48 | // ERROR_INVALID_PARAMETER - The pszOutputString parameter is NULL. 49 | // ERROR_WRITE_FAULT - The Process Monitor driver is loaded but the 50 | // Process Monitor user mode portion is not running. 51 | // ERROR_BAD_DRIVER - The Process Monitor driver is not loaded. 52 | //////////////////////////////////////////////////////////////////////////////*/ 53 | PROCMONDEBUGOUTPUT_DLLINTERFACE 54 | _Success_(return == TRUE) 55 | BOOL __stdcall ProcMonDebugOutput(_In_z_ LPCWSTR pszOutputString); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | -------------------------------------------------------------------------------- /Source/ManagedTest/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Source/ManagedTest/ManagedTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8D834016-ED7D-416C-B894-259F5BDF6CC6} 8 | Exe 9 | Properties 10 | ManagedTest 11 | ManagedTest 12 | v2.0 13 | 512 14 | true 15 | 16 | 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | false 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | false 38 | 39 | 40 | true 41 | ..\Debugx64\ 42 | DEBUG;TRACE 43 | full 44 | x64 45 | prompt 46 | MinimumRecommendedRules.ruleset 47 | true 48 | false 49 | 50 | 51 | ..\Releasex64\ 52 | TRACE 53 | true 54 | pdbonly 55 | x64 56 | prompt 57 | MinimumRecommendedRules.ruleset 58 | true 59 | false 60 | 61 | 62 | true 63 | ..\DebugWin32\ 64 | DEBUG;TRACE 65 | full 66 | x86 67 | prompt 68 | MinimumRecommendedRules.ruleset 69 | true 70 | false 71 | 72 | 73 | ..\ReleaseWin32\ 74 | TRACE 75 | true 76 | pdbonly 77 | x86 78 | prompt 79 | MinimumRecommendedRules.ruleset 80 | true 81 | false 82 | 83 | 84 | 85 | False 86 | ..\packages\log4net.2.0.3\lib\net20-full\log4net.dll 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | {b276cb46-42a1-4cf8-a0bd-7de40230764e} 101 | Sysinternals.log4net 102 | 103 | 104 | 105 | 106 | {fb1d522e-1acb-49dd-93d4-123e6ea13aed} 107 | Sysinternals.Debug 108 | 109 | 110 | 111 | 118 | -------------------------------------------------------------------------------- /Source/ManagedTest/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using System.Text; 5 | using System.Diagnostics; 6 | 7 | using log4net; 8 | using log4net.Appender; 9 | using log4net.Core; 10 | using log4net.Repository.Hierarchy; 11 | using Sysinternals.log4net; 12 | 13 | namespace ManagedTest 14 | { 15 | class Program 16 | { 17 | static void Main(string[] args) 18 | { 19 | /* 20 | Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository(); 21 | hierarchy.Root.AddAppender(new ColoredConsoleAppender()); 22 | hierarchy.Root.AddAppender(new ProcMonAppender()); 23 | hierarchy.Root.Level = Level.Debug; 24 | hierarchy.Configured = true; 25 | */ 26 | ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 27 | Debug.Listeners.Remove("Default"); 28 | 29 | StringBuilder sb = new StringBuilder(100); 30 | for (int i = 0; i < 20; i++) 31 | { 32 | sb.Length = 0; 33 | sb.AppendFormat("ProcMon Debug Out Test # {0}", i); 34 | Trace.Write(sb.ToString()); 35 | 36 | if (i%2 == 0) 37 | { 38 | _logger.DebugFormat("ProcMon log4net Out Test # {0}", i); 39 | } 40 | else if (i%3 == 0) 41 | { 42 | _logger.InfoFormat("ProcMon log4net Out Test # {0}", i); 43 | } 44 | else if (i%5 == 0) 45 | { 46 | _logger.WarnFormat("ProcMon log4net Out Test # {0}", i); 47 | } 48 | else 49 | { 50 | _logger.ErrorFormat("ProcMon log4net Out Test # {0}", i); 51 | } 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Source/ManagedTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | using log4net.Config; 9 | 10 | [assembly: AssemblyTitle("ManagedTest")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("ManagedTest")] 15 | [assembly: AssemblyCopyright("Copyright © 2014")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | // The following GUID is for the ID of the typelib if this project is exposed to COM 25 | [assembly: Guid("e41f259c-3367-451c-a0cf-a92809991f37")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | [assembly: AssemblyVersion("1.0.0.0")] 38 | [assembly: AssemblyFileVersion("1.0.0.0")] 39 | 40 | // Read the log4net config from the app.config 41 | [assembly:XmlConfigurator(Watch = false)] -------------------------------------------------------------------------------- /Source/ManagedTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Source/NativeTest/NativeTest.cpp: -------------------------------------------------------------------------------- 1 | // NativeTest.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ProcMonDebugOutput.h" 6 | 7 | 8 | int _tmain(void) 9 | { 10 | WCHAR szText[100]; 11 | for (int i = 0; i < 20; i++) 12 | { 13 | _stprintf_s(szText, 14 | _countof(szText), 15 | L"ProcMon Debug Out Test # %d", 16 | i); 17 | BOOL bRet = ProcMonDebugOutput(szText); 18 | if (TRUE == bRet) 19 | { 20 | _tprintf(L"Wrote %d\n", i); 21 | } 22 | else 23 | { 24 | _tprintf(L"error 0x%x\n", GetLastError()); 25 | } 26 | ::Sleep(500); 27 | } 28 | return (0); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Source/NativeTest/NativeTest.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {C2944A24-633E-4006-8000-CA00A47737DE} 23 | Win32Proj 24 | NativeTest 25 | 26 | 27 | 28 | Application 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | Application 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | Application 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | Application 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | ..\$(Configuration)$(Platform)\ 72 | $(Configuration)$(Platform)\ 73 | AllRules.ruleset 74 | true 75 | 76 | 77 | true 78 | ..\$(Configuration)$(Platform)\ 79 | $(Configuration)$(Platform)\ 80 | AllRules.ruleset 81 | true 82 | 83 | 84 | false 85 | ..\$(Configuration)$(Platform)\ 86 | $(Configuration)$(Platform)\ 87 | AllRules.ruleset 88 | true 89 | 90 | 91 | false 92 | ..\$(Configuration)$(Platform)\ 93 | $(Configuration)$(Platform)\ 94 | AllRules.ruleset 95 | true 96 | 97 | 98 | 99 | Use 100 | Level4 101 | Disabled 102 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 103 | true 104 | ..\Include 105 | ProgramDatabase 106 | true 107 | true 108 | 109 | 110 | Console 111 | true 112 | $(OutDir) 113 | ProcMonDebugOutput$(Platform).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 114 | 115 | 116 | 117 | 118 | Use 119 | Level4 120 | Disabled 121 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 122 | true 123 | ..\Include 124 | true 125 | true 126 | 127 | 128 | Console 129 | true 130 | $(OutDir) 131 | ProcMonDebugOutput$(Platform).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 132 | 133 | 134 | 135 | 136 | Level4 137 | Use 138 | MaxSpeed 139 | true 140 | true 141 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 142 | true 143 | ..\Include 144 | true 145 | true 146 | 147 | 148 | Console 149 | true 150 | true 151 | true 152 | $(OutDir) 153 | ProcMonDebugOutput$(Platform).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 154 | 155 | 156 | 157 | 158 | Level4 159 | Use 160 | MaxSpeed 161 | true 162 | true 163 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 164 | true 165 | ..\Include 166 | true 167 | true 168 | 169 | 170 | Console 171 | true 172 | true 173 | true 174 | $(OutDir) 175 | ProcMonDebugOutput$(Platform).lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | Create 189 | Create 190 | Create 191 | Create 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /Source/NativeTest/NativeTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /Source/NativeTest/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // NativeTest.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Source/NativeTest/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | 16 | // TODO: reference additional headers your program requires here 17 | -------------------------------------------------------------------------------- /Source/NativeTest/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProcMonDebugOutput", "ProcMonDebugOutput\ProcMonDebugOutput.vcxproj", "{67431913-19A9-4C9E-8DE4-C56939F8324B}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NativeTest", "NativeTest\NativeTest.vcxproj", "{C2944A24-633E-4006-8000-CA00A47737DE}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {67431913-19A9-4C9E-8DE4-C56939F8324B} = {67431913-19A9-4C9E-8DE4-C56939F8324B} 11 | EndProjectSection 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sysinternals.Debug", "Sysinternals.Debug\Sysinternals.Debug.csproj", "{FB1D522E-1ACB-49DD-93D4-123E6EA13AED}" 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagedTest", "ManagedTest\ManagedTest.csproj", "{8D834016-ED7D-416C-B894-259F5BDF6CC6}" 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sysinternals.log4net", "Sysinternals.log4net\Sysinternals.log4net.csproj", "{B276CB46-42A1-4CF8-A0BD-7DE40230764E}" 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Debug|Mixed Platforms = Debug|Mixed Platforms 23 | Debug|Win32 = Debug|Win32 24 | Debug|x64 = Debug|x64 25 | Debug|x86 = Debug|x86 26 | Release|Any CPU = Release|Any CPU 27 | Release|Mixed Platforms = Release|Mixed Platforms 28 | Release|Win32 = Release|Win32 29 | Release|x64 = Release|x64 30 | Release|x86 = Release|x86 31 | EndGlobalSection 32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 33 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|Any CPU.ActiveCfg = Debug|Win32 34 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 35 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 36 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|Win32.Build.0 = Debug|Win32 38 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|x64.ActiveCfg = Debug|x64 39 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|x64.Build.0 = Debug|x64 40 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|x86.ActiveCfg = Debug|Win32 41 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Debug|x86.Build.0 = Debug|Win32 42 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|Any CPU.ActiveCfg = Release|Win32 43 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 44 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|Mixed Platforms.Build.0 = Release|Win32 45 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|Win32.ActiveCfg = Release|Win32 46 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|Win32.Build.0 = Release|Win32 47 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|x64.ActiveCfg = Release|x64 48 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|x64.Build.0 = Release|x64 49 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|x86.ActiveCfg = Release|Win32 50 | {67431913-19A9-4C9E-8DE4-C56939F8324B}.Release|x86.Build.0 = Release|Win32 51 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|Any CPU.ActiveCfg = Debug|Win32 52 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 53 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|Mixed Platforms.Build.0 = Debug|Win32 54 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|Win32.ActiveCfg = Debug|Win32 55 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|Win32.Build.0 = Debug|Win32 56 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|x64.ActiveCfg = Debug|x64 57 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|x64.Build.0 = Debug|x64 58 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|x86.ActiveCfg = Debug|Win32 59 | {C2944A24-633E-4006-8000-CA00A47737DE}.Debug|x86.Build.0 = Debug|Win32 60 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|Any CPU.ActiveCfg = Release|Win32 61 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|Mixed Platforms.ActiveCfg = Release|Win32 62 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|Mixed Platforms.Build.0 = Release|Win32 63 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|Win32.ActiveCfg = Release|Win32 64 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|Win32.Build.0 = Release|Win32 65 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|x64.ActiveCfg = Release|x64 66 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|x64.Build.0 = Release|x64 67 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|x86.ActiveCfg = Release|Win32 68 | {C2944A24-633E-4006-8000-CA00A47737DE}.Release|x86.Build.0 = Release|Win32 69 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 70 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|Any CPU.Build.0 = Debug|Any CPU 71 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 72 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 73 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|Win32.ActiveCfg = Debug|Any CPU 74 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|Win32.Build.0 = Debug|Any CPU 75 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|x64.ActiveCfg = Debug|Any CPU 76 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|x64.Build.0 = Debug|Any CPU 77 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Debug|x86.ActiveCfg = Debug|Any CPU 78 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|Any CPU.ActiveCfg = Release|Any CPU 79 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|Any CPU.Build.0 = Release|Any CPU 80 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 81 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|Mixed Platforms.Build.0 = Release|Any CPU 82 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|Win32.ActiveCfg = Release|Any CPU 83 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|Win32.Build.0 = Release|Any CPU 84 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|x64.ActiveCfg = Release|Any CPU 85 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|x64.Build.0 = Release|Any CPU 86 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED}.Release|x86.ActiveCfg = Release|Any CPU 87 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 88 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU 89 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 90 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|Mixed Platforms.Build.0 = Debug|x86 91 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|Win32.ActiveCfg = Debug|x86 92 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|Win32.Build.0 = Debug|x86 93 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|x64.ActiveCfg = Debug|x64 94 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|x64.Build.0 = Debug|x64 95 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|x86.ActiveCfg = Debug|x86 96 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Debug|x86.Build.0 = Debug|x86 97 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU 98 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|Any CPU.Build.0 = Release|Any CPU 99 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|Mixed Platforms.ActiveCfg = Release|x86 100 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|Mixed Platforms.Build.0 = Release|x86 101 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|Win32.ActiveCfg = Release|x86 102 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|Win32.Build.0 = Release|x86 103 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|x64.ActiveCfg = Release|x64 104 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|x64.Build.0 = Release|x64 105 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|x86.ActiveCfg = Release|x86 106 | {8D834016-ED7D-416C-B894-259F5BDF6CC6}.Release|x86.Build.0 = Release|x86 107 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 108 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Debug|Any CPU.Build.0 = Debug|Any CPU 109 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 110 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 111 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Debug|Win32.ActiveCfg = Debug|Any CPU 112 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Debug|x64.ActiveCfg = Debug|Any CPU 113 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Debug|x86.ActiveCfg = Debug|Any CPU 114 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Release|Any CPU.ActiveCfg = Release|Any CPU 115 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Release|Any CPU.Build.0 = Release|Any CPU 116 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 117 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Release|Mixed Platforms.Build.0 = Release|Any CPU 118 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Release|Win32.ActiveCfg = Release|Any CPU 119 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Release|x64.ActiveCfg = Release|Any CPU 120 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E}.Release|x86.ActiveCfg = Release|Any CPU 121 | EndGlobalSection 122 | GlobalSection(SolutionProperties) = preSolution 123 | HideSolutionNode = FALSE 124 | EndGlobalSection 125 | EndGlobal 126 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/ProcMonDebugOutput.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "stdafx.h" 3 | #include "ProcMonDebugOutput.h" 4 | 5 | #define FILE_DEVICE_PROCMON_LOG 0x00009535 6 | #define IOCTL_EXTERNAL_LOG_DEBUGOUT (ULONG) CTL_CODE(FILE_DEVICE_PROCMON_LOG ,\ 7 | 0x81 ,\ 8 | METHOD_BUFFERED ,\ 9 | FILE_WRITE_ACCESS ) 10 | 11 | // The global file handle to the Process Monitor device. 12 | static HANDLE g_hDevice = INVALID_HANDLE_VALUE; 13 | 14 | // Anonymous namespace for private helpers 15 | namespace { 16 | 17 | HANDLE OpenProcessMonitorLogger() 18 | { 19 | if (INVALID_HANDLE_VALUE == g_hDevice) 20 | { 21 | // I'm attempting the open every time because the user could start 22 | // Process Monitor after their process. 23 | g_hDevice = ::CreateFile(L"\\\\.\\Global\\ProcmonDebugLogger", 24 | GENERIC_WRITE, 25 | FILE_SHARE_WRITE, 26 | nullptr, 27 | OPEN_EXISTING, 28 | FILE_ATTRIBUTE_NORMAL, 29 | nullptr); 30 | } 31 | return g_hDevice; 32 | } 33 | 34 | void CloseProcessMonitorLogger() 35 | { 36 | if (INVALID_HANDLE_VALUE != g_hDevice) 37 | { 38 | ::CloseHandle(g_hDevice); 39 | g_hDevice = INVALID_HANDLE_VALUE; 40 | } 41 | } 42 | 43 | // Used to pass strings to legacy C APIs expecting a raw void* pointer. 44 | inline void* StringToPVoid(PCWSTR psz) 45 | { 46 | return reinterpret_cast(const_cast(psz)); 47 | } 48 | 49 | } // anonymous namespace 50 | 51 | 52 | PROCMONDEBUGOUTPUT_DLLINTERFACE _Success_(return == TRUE) 53 | BOOL __stdcall ProcMonDebugOutput(_In_z_ LPCWSTR pszOutputString) 54 | { 55 | BOOL bRet = FALSE; 56 | 57 | if (nullptr == pszOutputString) 58 | { 59 | ::SetLastError(ERROR_INVALID_PARAMETER); 60 | bRet = FALSE; 61 | } 62 | else 63 | { 64 | HANDLE hProcMon = OpenProcessMonitorLogger(); 65 | if (INVALID_HANDLE_VALUE != hProcMon) 66 | { 67 | DWORD iLen = static_cast(wcslen(pszOutputString) * sizeof (WCHAR)); 68 | DWORD iOutLen = 0; 69 | bRet = ::DeviceIoControl(hProcMon, 70 | IOCTL_EXTERNAL_LOG_DEBUGOUT, 71 | StringToPVoid(pszOutputString), 72 | iLen, 73 | nullptr, 74 | 0, 75 | &iOutLen, 76 | nullptr); 77 | if (FALSE == bRet) 78 | { 79 | DWORD dwLastError = ::GetLastError(); 80 | if (ERROR_INVALID_PARAMETER == dwLastError) 81 | { 82 | // The driver is loaded but the user mode Process Monitor 83 | // program is not running so turn the last error into a 84 | // write failure. 85 | ::SetLastError(ERROR_WRITE_FAULT); 86 | } 87 | } 88 | } 89 | else 90 | { 91 | // Process Monitor isn't loaded. 92 | ::SetLastError(ERROR_BAD_DRIVER); 93 | bRet = FALSE; 94 | } 95 | } 96 | return bRet; 97 | } 98 | 99 | BOOL APIENTRY DllMain(HMODULE /*hModule*/, 100 | DWORD ul_reason_for_call, 101 | LPVOID /*lpReserved*/) 102 | { 103 | switch (ul_reason_for_call) 104 | { 105 | case DLL_PROCESS_ATTACH: 106 | case DLL_THREAD_ATTACH: 107 | case DLL_THREAD_DETACH: 108 | break; 109 | case DLL_PROCESS_DETACH: 110 | // Close the handle to the driver. 111 | CloseProcessMonitorLogger(); 112 | break; 113 | } 114 | return TRUE; 115 | } 116 | 117 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/ProcMonDebugOutput.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wintellect/ProcMonDebugOutput/b9594c00122d3e78a588b77ec445f6261a5a916c/Source/ProcMonDebugOutput/ProcMonDebugOutput.rc -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/ProcMonDebugOutput.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {67431913-19A9-4C9E-8DE4-C56939F8324B} 23 | Win32Proj 24 | ProcMonDebugOutput 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | v120 31 | Unicode 32 | 33 | 34 | DynamicLibrary 35 | true 36 | v120 37 | Unicode 38 | 39 | 40 | DynamicLibrary 41 | false 42 | v120 43 | true 44 | Unicode 45 | 46 | 47 | DynamicLibrary 48 | false 49 | v120 50 | true 51 | Unicode 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | true 71 | ..\$(Configuration)$(Platform)\ 72 | $(Configuration)$(Platform)\ 73 | $(ProjectName)$(Platform) 74 | AllRules.ruleset 75 | true 76 | 77 | 78 | true 79 | ..\$(Configuration)$(Platform)\ 80 | $(Configuration)$(Platform)\ 81 | $(ProjectName)$(Platform) 82 | AllRules.ruleset 83 | true 84 | 85 | 86 | false 87 | ..\$(Configuration)$(Platform)\ 88 | $(Configuration)$(Platform)\ 89 | $(ProjectName)$(Platform) 90 | AllRules.ruleset 91 | true 92 | 93 | 94 | false 95 | ..\$(Configuration)$(Platform)\ 96 | $(Configuration)$(Platform)\ 97 | $(ProjectName)$(Platform) 98 | AllRules.ruleset 99 | true 100 | 101 | 102 | 103 | Use 104 | Level4 105 | Disabled 106 | WIN32;_DEBUG;_WINDOWS;_USRDLL;PROCMONDEBUGOUTPUT_EXPORTS;%(PreprocessorDefinitions) 107 | true 108 | ..\Include 109 | ProgramDatabase 110 | true 111 | true 112 | 113 | 114 | Windows 115 | true 116 | ProcMonDebugOutputWIN32.def 117 | 118 | 119 | 120 | 121 | Use 122 | Level4 123 | Disabled 124 | WIN32;_DEBUG;_WINDOWS;_USRDLL;PROCMONDEBUGOUTPUT_EXPORTS;%(PreprocessorDefinitions) 125 | true 126 | ..\Include 127 | true 128 | true 129 | 130 | 131 | Windows 132 | true 133 | 134 | 135 | 136 | 137 | 138 | 139 | Level4 140 | Use 141 | MaxSpeed 142 | true 143 | true 144 | WIN32;NDEBUG;_WINDOWS;_USRDLL;PROCMONDEBUGOUTPUT_EXPORTS;%(PreprocessorDefinitions) 145 | true 146 | ..\Include 147 | true 148 | true 149 | 150 | 151 | Windows 152 | true 153 | true 154 | true 155 | ProcMonDebugOutputWIN32.def 156 | 157 | 158 | 159 | 160 | Level4 161 | Use 162 | MaxSpeed 163 | true 164 | true 165 | WIN32;NDEBUG;_WINDOWS;_USRDLL;PROCMONDEBUGOUTPUT_EXPORTS;%(PreprocessorDefinitions) 166 | true 167 | ..\Include 168 | true 169 | true 170 | 171 | 172 | Windows 173 | true 174 | true 175 | true 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | Create 190 | Create 191 | Create 192 | Create 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/ProcMonDebugOutput.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | 40 | 41 | Resource Files 42 | 43 | 44 | 45 | 46 | Source Files 47 | 48 | 49 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/ProcMonDebugOutputWIN32.def: -------------------------------------------------------------------------------- 1 | LIBRARY "ProcMonDebugOutputWin32" 2 | 3 | EXPORTS 4 | 5 | ProcMonDebugOutput 6 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by ProcMonDebugOutput.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ProcMonDebugOutput.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | #include 14 | 15 | 16 | 17 | // TODO: reference additional headers your program requires here 18 | -------------------------------------------------------------------------------- /Source/ProcMonDebugOutput/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Source/PythonExamples/HelloProcMon.ctypes.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Justin Dearing ' 2 | __copyright__ = "Copyright 2014, Justin Dearing" 3 | __credits__ = ["Justin Dearing", "John Robbins", "Mark Russinovich"] 4 | __version__ = "1.0.0" 5 | __status__ = "Prototype" 6 | 7 | import ctypes 8 | from ctypes import windll, c_void_p 9 | from ctypes import c_uint32 10 | from ctypes import c_wchar_p 11 | from ctypes import byref 12 | 13 | 14 | GENERIC_WRITE = 0x40000000 15 | OPEN_EXISTING = 3 16 | FILE_WRITE_ACCESS = 0x0002 17 | FILE_SHARE_WRITE = 0x00000002 18 | FILE_ATTRIBUTE_NORMAL = 0x00000080 19 | METHOD_BUFFERED = 0 20 | FILE_DEVICE_PROCMON_LOG = 0x00009535 21 | PROCMON_DEBUGGER_HANDLER = c_wchar_p(r"\\.\Global\ProcmonDebugLogger") 22 | DW_IO_CONTROL_CODE = 2503311876 23 | 24 | k32 = windll.kernel32 25 | 26 | msg = bytes("Hello ProcMon from python with ctypes!", 'UTF-16') 27 | 28 | handle = k32.CreateFileW( 29 | PROCMON_DEBUGGER_HANDLER, 30 | GENERIC_WRITE, 31 | FILE_SHARE_WRITE, 32 | 0, 33 | OPEN_EXISTING, 34 | FILE_ATTRIBUTE_NORMAL, 35 | 0 36 | ) 37 | if handle == -1: raise RuntimeWarning("ProcMon doesn't appear to be running") 38 | 39 | print ("Handle: %d" % handle) 40 | 41 | k32.DeviceIoControl( 42 | handle, 43 | DW_IO_CONTROL_CODE, 44 | msg, 45 | len(msg) * 2, 46 | 0, 47 | 0, 48 | byref(c_void_p()), # So quoth the MSDN: If lpOverlapped is NULL, lpBytesReturned cannot be NULL. http://msdn.microsoft.com/en-us/library/windows/desktop/aa363216.aspx 49 | None 50 | ) -------------------------------------------------------------------------------- /Source/PythonExamples/HelloProcMon.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Justin Dearing ' 2 | __copyright__ = "Copyright 2014, Justin Dearing" 3 | __credits__ = ["Justin Dearing", "John Robbins", "Mark Russinovich"] 4 | __version__ = "1.0.0" 5 | __status__ = "Prototype" 6 | 7 | # Tested on Python 3.4 8 | 9 | import win32file 10 | import pywintypes 11 | 12 | GENERIC_WRITE = 0x40000000 13 | OPEN_EXISTING = 3 14 | FILE_WRITE_ACCESS = 0x0002 15 | FILE_SHARE_WRITE = 0x00000002 16 | FILE_ATTRIBUTE_NORMAL = 0x00000080 17 | METHOD_BUFFERED = 0 18 | FILE_DEVICE_PROCMON_LOG = 0x00009535 19 | PROCMON_DEBUGGER_HANDLER = r"\\.\Global\ProcmonDebugLogger" 20 | IOCTL_EXTERNAL_LOG_DEBUGOUT = 2503311876 # Why: https://github.com/zippy1981/ProcMon.LINQpad/blob/master/ProcMonDebugOutput.linq 21 | 22 | msg = bytes("Hello ProcMon from python with pywin32!", 'UTF-16') 23 | msgLen = len(msg) 24 | handle = win32file.CreateFile(PROCMON_DEBUGGER_HANDLER, GENERIC_WRITE, FILE_SHARE_WRITE, None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0) 25 | if handle == -1: raise RuntimeWarning("ProcMon doesn't appear to be running") 26 | else: 27 | try: 28 | win32file.DeviceIoControl(handle, IOCTL_EXTERNAL_LOG_DEBUGOUT, msg, None) 29 | except pywintypes.error as e: 30 | if (e.winerror != 87): raise # Error 87 means ProcMon simply isn't running 31 | 32 | win32file.CloseHandle(handle) 33 | -------------------------------------------------------------------------------- /Source/PythonExamples/HelloProcMon27.ctypes.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Justin Dearing ' 2 | __copyright__ = "Copyright 2014, Justin Dearing" 3 | __credits__ = ["Justin Dearing", "John Robbins", "Mark Russinovich"] 4 | __version__ = "1.0.0" 5 | __status__ = "Prototype" 6 | 7 | import ctypes 8 | from ctypes import windll, c_void_p 9 | from ctypes import c_uint32 10 | from ctypes import c_wchar_p 11 | from ctypes import byref 12 | 13 | 14 | GENERIC_WRITE = 0x40000000 15 | OPEN_EXISTING = 3 16 | FILE_WRITE_ACCESS = 0x0002 17 | FILE_SHARE_WRITE = 0x00000002 18 | FILE_ATTRIBUTE_NORMAL = 0x00000080 19 | METHOD_BUFFERED = 0 20 | FILE_DEVICE_PROCMON_LOG = 0x00009535 21 | PROCMON_DEBUGGER_HANDLER = c_wchar_p(r"\\.\Global\ProcmonDebugLogger") 22 | DW_IO_CONTROL_CODE = 2503311876 23 | 24 | k32 = windll.kernel32 25 | 26 | msg = "Hello ProcMon from python 2.7 with ctypes!".encode('UTF-16') 27 | 28 | handle = k32.CreateFileW( 29 | PROCMON_DEBUGGER_HANDLER, 30 | GENERIC_WRITE, 31 | FILE_SHARE_WRITE, 32 | 0, 33 | OPEN_EXISTING, 34 | FILE_ATTRIBUTE_NORMAL, 35 | 0 36 | ) 37 | if handle == -1: raise RuntimeWarning("ProcMon doesn't appear to be running") 38 | 39 | print ("Handle: %d" % handle) 40 | 41 | k32.DeviceIoControl( 42 | handle, 43 | DW_IO_CONTROL_CODE, 44 | msg, 45 | len(msg) * 2, 46 | 0, 47 | 0, 48 | byref(c_void_p()), # So quoth the MSDN: If lpOverlapped is NULL, lpBytesReturned cannot be NULL. http://msdn.microsoft.com/en-us/library/windows/desktop/aa363216.aspx 49 | None 50 | ) -------------------------------------------------------------------------------- /Source/PythonExamples/HelloProcMon27.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Justin Dearing ' 2 | __copyright__ = "Copyright 2014, Justin Dearing" 3 | __credits__ = ["Justin Dearing", "John Robbins", "Mark Russinovich"] 4 | __version__ = "1.0.0" 5 | __status__ = "Prototype" 6 | # Tested on Python 3.4 7 | 8 | import win32file 9 | import pywintypes 10 | 11 | GENERIC_WRITE = 0x40000000 12 | OPEN_EXISTING = 3 13 | FILE_WRITE_ACCESS = 0x0002 14 | FILE_SHARE_WRITE = 0x00000002 15 | FILE_ATTRIBUTE_NORMAL = 0x00000080 16 | METHOD_BUFFERED = 0 17 | FILE_DEVICE_PROCMON_LOG = 0x00009535 18 | PROCMON_DEBUGGER_HANDLER = r"\\.\Global\ProcmonDebugLogger" 19 | IOCTL_EXTERNAL_LOG_DEBUGOUT = 2503311876 # Why: https://github.com/zippy1981/ProcMon.LINQpad/blob/master/ProcMonDebugOutput.linq 20 | 21 | msg = "Hello ProcMon from python 2.7 with pywin32!".encode('UTF-16') 22 | msgLen = len(msg) 23 | handle = win32file.CreateFile(PROCMON_DEBUGGER_HANDLER, GENERIC_WRITE, FILE_SHARE_WRITE, None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0) 24 | if handle == -1: raise RuntimeWarning("ProcMon doesn't appear to be running") 25 | else: 26 | try: 27 | win32file.DeviceIoControl(handle, IOCTL_EXTERNAL_LOG_DEBUGOUT, msg, None) 28 | except pywintypes.error as e: 29 | if (e.winerror != 87): raise # Error 87 means ProcMon simply isn't running 30 | 31 | win32file.CloseHandle(handle) 32 | -------------------------------------------------------------------------------- /Source/PythonExamples/PythonExamples.pyproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | 2.0 6 | 23ac83c8-22b4-4184-ad60-bf09a435c3e6 7 | . 8 | HelloProcMon27.ctypes.py 9 | 10 | 11 | . 12 | . 13 | PythonExamples 14 | PythonExamples 15 | {2af0f10d-7135-4994-9156-5d01c9c11b7e} 16 | 2.7 17 | 18 | 19 | true 20 | false 21 | 22 | 23 | true 24 | false 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 10.0 38 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Source/Sysinternals.Debug/AllCodeAnalysisRulesAsErrors.ruleset: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | -------------------------------------------------------------------------------- /Source/Sysinternals.Debug/CodeAnalysisDictionary.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Wintellect 8 | Sysinternals 9 | 10 | 11 | 12 | 13 | 14 | 15 | ListView 16 | RegEx 17 | 18 | 19 | 20 | 21 | WiX 22 | log 23 | net 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Source/Sysinternals.Debug/GlobalSuppressions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wintellect/ProcMonDebugOutput/b9594c00122d3e78a588b77ec445f6261a5a916c/Source/Sysinternals.Debug/GlobalSuppressions.cs -------------------------------------------------------------------------------- /Source/Sysinternals.Debug/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | /*////////////////////////////////////////////////////////////////////////////// 2 | // ProcessMonitorTraceListener 3 | // 4 | // History: 5 | // - April 1, 2010 - Version 1.0 - John Robbins/Wintellect 6 | // - Initial release. 7 | // - March 1, 2014 - Version 1.1 - John Robbins/Wintellect 8 | // - Moved to VS 2013 and .NET 4.5.1 9 | //////////////////////////////////////////////////////////////////////////////*/ 10 | 11 | namespace Sysinternals.Debug 12 | { 13 | using Microsoft.Win32.SafeHandles; 14 | using System; 15 | using System.Diagnostics; 16 | using System.Diagnostics.CodeAnalysis; 17 | using System.Globalization; 18 | using System.Runtime.InteropServices; 19 | using System.Security; 20 | using System.Text; 21 | 22 | /// 23 | /// A class to wrap all the native code needed by this assembly. 24 | /// 25 | [SuppressMessage("Microsoft.Portability", 26 | "CA1903:UseOnlyApiFromTargetedFramework", 27 | MessageId = "System.Security.SecuritySafeCriticalAttribute", 28 | Justification = "Everyone is running .NET 2.0 SP2 so they have SecuritySafeCritical")] 29 | [SecuritySafeCritical] 30 | internal static class NativeMethods 31 | { 32 | // Constants to represent C preprocessor macros for PInvokes 33 | private const uint GENERIC_WRITE = 0x40000000; 34 | private const uint OPEN_EXISTING = 3; 35 | private const uint FILE_WRITE_ACCESS = 0x0002; 36 | private const uint FILE_SHARE_WRITE = 0x00000002; 37 | private const uint FILE_ATTRIBUTE_NORMAL = 0x00000080; 38 | private const uint METHOD_BUFFERED = 0; 39 | 40 | // Process Monitor Constants 41 | private const uint FILE_DEVICE_PROCMON_LOG = 0x00009535; 42 | private const string PROCMON_DEBUGGER_HANDLER = "\\\\.\\Global\\ProcmonDebugLogger"; 43 | 44 | /// 45 | /// The handle to the Process Monitor log device. 46 | /// 47 | private static SafeFileHandle hProcMon; 48 | 49 | /// 50 | /// Gets the IO Control code for the ProcMon log. 51 | /// 52 | private static uint IOCTL_EXTERNAL_LOG_DEBUGOUT { get { return CTL_CODE(); } } 53 | 54 | /// 55 | /// Builds the control code for the Process Monitor driver access. 56 | /// 57 | /// 58 | private static uint CTL_CODE(uint DeviceType = FILE_DEVICE_PROCMON_LOG, 59 | uint Function = 0x81, 60 | uint Method = METHOD_BUFFERED, 61 | uint Access = FILE_WRITE_ACCESS) 62 | { 63 | return ((DeviceType << 16) | (Access << 14) | (Function << 2) | Method); 64 | } 65 | 66 | /// 67 | /// Handles calling CreateFile. 68 | /// 69 | /// 70 | /// This is only used for opening the Process Monitor log handle, hence the default parameters. 71 | /// 72 | /// 73 | [SuppressMessage("Microsoft.Security", 74 | "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule", 75 | Justification = "This is a bug in Code Analysis on pre-4.0 assemblies: http://connect.microsoft.com/VisualStudio/feedback/details/729254/bogus-ca5122-warning-about-p-invoke-declarations-should-not-be-safe-critical")] 76 | [DllImport("kernel32.dll", 77 | SetLastError = true, 78 | CharSet = CharSet.Unicode)] 79 | private static extern SafeFileHandle CreateFile(string lpFileName = PROCMON_DEBUGGER_HANDLER, 80 | uint dwDesiredAccess = GENERIC_WRITE, 81 | uint dwShareMode = FILE_SHARE_WRITE, 82 | IntPtr lpSecurityAttributes = default(IntPtr), 83 | uint dwCreationDisposition = OPEN_EXISTING, 84 | uint dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL, 85 | IntPtr hTemplateFile = default(IntPtr)); 86 | 87 | [SuppressMessage("Microsoft.Security", 88 | "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule", 89 | Justification = "This is a bug in Code Analysis on pre-4.0 assemblies: http://connect.microsoft.com/VisualStudio/feedback/details/729254/bogus-ca5122-warning-about-p-invoke-declarations-should-not-be-safe-critical")] 90 | [DllImport("kernel32.dll", 91 | ExactSpelling = true, 92 | SetLastError = true, 93 | CharSet = CharSet.Unicode)] 94 | [return: MarshalAs(UnmanagedType.Bool)] 95 | private static extern bool DeviceIoControl(SafeFileHandle hDevice, 96 | uint dwIoControlCode, 97 | StringBuilder lpInBuffer, 98 | uint nInBufferSize, 99 | IntPtr lpOutBuffer, 100 | uint nOutBufferSize, 101 | out uint lpBytesReturned, 102 | IntPtr lpOverlapped); 103 | 104 | [SuppressMessage("Microsoft.Performance", 105 | "CA1810:InitializeReferenceTypeStaticFieldsInline", 106 | Justification = "How else are you going to set up a static event? (http://social.msdn.microsoft.com/Forums/en-US/d11fe313-278c-4cae-bfcc-b119204866c7/ca1810-incorrect?forum=vstscode)")] 107 | static NativeMethods() 108 | { 109 | AppDomain.CurrentDomain.ProcessExit += (sender, args) => 110 | { 111 | if (!hProcMon.IsInvalid) 112 | { 113 | hProcMon.Close(); 114 | } 115 | }; 116 | } 117 | 118 | /// 119 | /// Does the actual tracing to Process Monitor. 120 | /// 121 | /// 122 | /// The message to display. 123 | /// 124 | /// 125 | /// The formatting arguments for the message 126 | /// 127 | /// 128 | /// True if the trace succeeded, false otherwise. 129 | /// 130 | public static bool ProcMonDebugOutput(string message, params object[] args) 131 | { 132 | bool returnValue = false; 133 | StringBuilder renderedMessage = new StringBuilder(); 134 | renderedMessage.AppendFormat(CultureInfo.CurrentCulture, message, args); 135 | uint outLen; 136 | 137 | if (hProcMon == null || hProcMon.IsInvalid) 138 | { 139 | hProcMon = CreateFile(); 140 | } 141 | 142 | returnValue = DeviceIoControl(hProcMon, 143 | IOCTL_EXTERNAL_LOG_DEBUGOUT, 144 | renderedMessage, 145 | (uint)(renderedMessage.Length * sizeof(System.Char)), 146 | IntPtr.Zero, 147 | 0, 148 | out outLen, 149 | IntPtr.Zero); 150 | return returnValue; 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /Source/Sysinternals.Debug/ProcessMonitorTraceListerner.cs: -------------------------------------------------------------------------------- 1 | /*////////////////////////////////////////////////////////////////////////////// 2 | // ProcessMonitorTraceListener 3 | // 4 | // History: 5 | // - April 1, 2010 - Version 1.0 - John Robbins/Wintellect 6 | // - Initial release. 7 | // - March 1, 2014 - Version 1.1 - John Robbins/Wintellect 8 | // - Moved to VS 2013 and .NET 4.5.1 9 | //////////////////////////////////////////////////////////////////////////////*/ 10 | 11 | namespace Sysinternals.Debug 12 | { 13 | using System; 14 | using System.Diagnostics; 15 | 16 | /// 17 | /// Implements a that redirects output to 18 | /// Sysinternal's Process Monitor program. 19 | /// 20 | public class ProcessMonitorTraceListener : TraceListener 21 | { 22 | /// 23 | /// Writes a trace message to Process Monitor. 24 | /// 25 | /// 26 | /// A message to write. 27 | /// 28 | public override void Write(string message) 29 | { 30 | NativeMethods.ProcMonDebugOutput(message); 31 | } 32 | 33 | /// 34 | /// Writes a trace message to Process Monitor. 35 | /// 36 | /// 37 | /// A message to write. 38 | /// 39 | public override void WriteLine(string message) 40 | { 41 | NativeMethods.ProcMonDebugOutput(message); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Sysinternals.Debug/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Security; 6 | 7 | [assembly: CLSCompliant(true)] 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyTitle("Sysinternals.Debug")] 12 | [assembly: AssemblyDescription("Send Trace output to Process Monitor")] 13 | [assembly: AssemblyConfiguration("")] 14 | [assembly: AssemblyCompany("Wintellect")] 15 | [assembly: AssemblyProduct("Sysinternals.Debug")] 16 | [assembly: AssemblyCopyright("Copyright 2014 John Robbins/Wintellect")] 17 | [assembly: AssemblyTrademark("")] 18 | [assembly: AssemblyCulture("")] 19 | 20 | [assembly: SecurityCritical] 21 | 22 | 23 | 24 | // Setting ComVisible to false makes the types in this assembly not visible 25 | // to COM components. If you need to access a type in this assembly from 26 | // COM, set the ComVisible attribute to true on that type. 27 | [assembly: ComVisible(false)] 28 | 29 | // The following GUID is for the ID of the typelib if this project is exposed to COM 30 | [assembly: Guid("c8467a9a-9e22-41cf-aaf1-114c9ee949b6")] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Build and Revision Numbers 40 | // by using the '*' as shown below: 41 | // [assembly: AssemblyVersion("1.0.*")] 42 | [assembly: AssemblyVersion("1.1.0.0")] 43 | [assembly: AssemblyFileVersion("1.1.0.0")] 44 | -------------------------------------------------------------------------------- /Source/Sysinternals.Debug/Sysinternals.Debug.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {FB1D522E-1ACB-49DD-93D4-123E6EA13AED} 8 | Library 9 | Properties 10 | Sysinternals.Debug 11 | Sysinternals.Debug 12 | v2.0 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | ..\Debugx64\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | true 26 | AllCodeAnalysisRulesAsErrors.ruleset 27 | true 28 | ..\Debugx64\Sysinternals.Debug.XML 29 | true 30 | 31 | 32 | pdbonly 33 | true 34 | ..\Releasex64\ 35 | TRACE 36 | prompt 37 | 4 38 | true 39 | AllCodeAnalysisRulesAsErrors.ruleset 40 | true 41 | ..\Releasex64\Sysinternals.Debug.XML 42 | true 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | copy $(OutDir)\$(TargetFileName) ..\$(ConfigurationName)Win32\ 61 | copy $(OutDir)\$(ProjectName).xml ..\$(ConfigurationName)Win32\ 62 | 63 | 70 | -------------------------------------------------------------------------------- /Source/Sysinternals.log4net/GlobalSuppressions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wintellect/ProcMonDebugOutput/b9594c00122d3e78a588b77ec445f6261a5a916c/Source/Sysinternals.log4net/GlobalSuppressions.cs -------------------------------------------------------------------------------- /Source/Sysinternals.log4net/ProcMonAppender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using log4net.Appender; 3 | using log4net.Core; 4 | using log4net.Layout; 5 | using Sysinternals.Debug; 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | namespace Sysinternals.log4net 9 | { 10 | /// 11 | /// A log4net appender for ProcMonDebugOutput. 12 | /// 13 | [SuppressMessage("Microsoft.Naming", 14 | "CA1704:IdentifiersShouldBeSpelledCorrectly", 15 | MessageId = "Proc", 16 | Justification="Naming conforms to the rest of the project")] 17 | [SuppressMessage("Microsoft.Naming", 18 | "CA1704:IdentifiersShouldBeSpelledCorrectly", 19 | MessageId = "Appender", 20 | Justification = "Naming conforms the log4net project")] 21 | public class ProcMonAppender : AppenderSkeleton 22 | { 23 | /// 24 | /// Default constructor. 25 | /// 26 | /// 27 | /// Sets the default layout. 28 | /// 29 | [SuppressMessage("Microsoft.Usage", 30 | "CA2214:DoNotCallOverridableMethodsInConstructors", 31 | Justification="Justin put this in and as I don't use log4net, I'm afraid to touch it.")] 32 | public ProcMonAppender() 33 | { 34 | // Although it breaks convention set by the built-in appenders, this is more forgiving. 35 | Layout = new PatternLayout("%-5p %m"); 36 | } 37 | /// 38 | /// This appender requires a to be set. 39 | /// 40 | /// true 41 | override protected bool RequiresLayout 42 | { 43 | get { return true; } 44 | } 45 | 46 | /// 47 | /// 48 | /// 49 | /// 50 | protected override void Append(LoggingEvent loggingEvent) 51 | { 52 | NativeMethods.ProcMonDebugOutput(RenderLoggingEvent(loggingEvent)); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Source/Sysinternals.log4net/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Security; 6 | 7 | [assembly:CLSCompliant(true)] 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyTitle("Sysinternals.log4net")] 12 | [assembly: AssemblyDescription("The log4net version of the Process Monitor tracing tool")] 13 | [assembly: AssemblyConfiguration("")] 14 | [assembly: AssemblyCompany("Wintellect")] 15 | [assembly: AssemblyProduct("Sysinternals.log4net")] 16 | [assembly: AssemblyCopyright("Copyright © Wintellect 2014")] 17 | [assembly: AssemblyTrademark("")] 18 | [assembly: AssemblyCulture("")] 19 | 20 | // Setting ComVisible to false makes the types in this assembly not visible 21 | // to COM components. If you need to access a type in this assembly from 22 | // COM, set the ComVisible attribute to true on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | [assembly: SecurityCritical] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | [assembly: Guid("d8560003-f6b2-40b4-989f-ff24d28a8eb4")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // 32 | // Major Version 33 | // Minor Version 34 | // Build Number 35 | // Revision 36 | // 37 | // You can specify all the values or you can default the Build and Revision Numbers 38 | // by using the '*' as shown below: 39 | // [assembly: AssemblyVersion("1.0.*")] 40 | [assembly: AssemblyVersion("1.0.0.0")] 41 | [assembly: AssemblyFileVersion("1.0.0.0")] 42 | -------------------------------------------------------------------------------- /Source/Sysinternals.log4net/Sysinternals.log4net.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B276CB46-42A1-4CF8-A0BD-7DE40230764E} 8 | Library 9 | Properties 10 | Sysinternals.log4net 11 | Sysinternals.log4net 12 | v2.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | ..\Debugx64\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | true 25 | ..\Sysinternals.Debug\AllCodeAnalysisRulesAsErrors.ruleset 26 | true 27 | ..\Debugx64\Sysinternals.log4net.XML 28 | true 29 | 30 | 31 | pdbonly 32 | true 33 | ..\Releasex64\ 34 | TRACE 35 | prompt 36 | 4 37 | true 38 | ..\Sysinternals.Debug\AllCodeAnalysisRulesAsErrors.ruleset 39 | true 40 | ..\Releasex64\Sysinternals.log4net.XML 41 | true 42 | 43 | 44 | 45 | False 46 | ..\packages\log4net.2.0.3\lib\net20-full\log4net.dll 47 | 48 | 49 | 50 | 51 | 52 | NativeMethods.cs 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | CodeAnalysisDictionary.xml 64 | 65 | 66 | 67 | 74 | -------------------------------------------------------------------------------- /Source/Sysinternals.log4net/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Source/VBA/ProcMon.bas: -------------------------------------------------------------------------------- 1 | Option Explicit 2 | 3 | ' Win32 API Constants 4 | Private Const GENERIC_WRITE As Long = &H40000000 5 | Private Const OPEN_EXISTING As Long = 3 6 | Private Const FILE_WRITE_ACCESS As Long = &H2 7 | Private Const FILE_SHARE_WRITE As Long = &H2 8 | Private Const FILE_ATTRIBUTE_NORMAL As Long = &H80 9 | Private Const METHOD_BUFFERED As Long = 0 10 | Private Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000 11 | Private Const LANG_NEUTRAL = &H0 12 | 13 | 14 | ' Process Monitor Constants 15 | Private Const FILE_DEVICE_PROCMON_LOG As Long = &H9535 16 | Private Const PROCMON_DEBUGGER_HANDLER As String = "\\.\Global\ProcmonDebugLogger" 17 | Private Const IOCTL_EXTERNAL_LOG_DEBUGOUT As Long = -1791655420 18 | 19 | Dim hProcMon As LongPtr 20 | 21 | Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileW" _ 22 | (ByVal lpFileName As LongPtr, _ 23 | Optional ByVal dwDesiredAccess As Long = GENERIC_WRITE, _ 24 | Optional ByVal dwShareMode As Long = FILE_SHARE_WRITE, _ 25 | Optional lpSecurityAttributes As LongPtr = 0, _ 26 | Optional ByVal dwCreationDisposition As Long = OPEN_EXISTING, _ 27 | Optional ByVal dwFlagsAndAttributes As Long = FILE_ATTRIBUTE_NORMAL, _ 28 | Optional ByVal hTemplateFile As LongPtr = 0) As LongPtr 29 | 30 | Private Declare Function DeviceIoControl Lib "kernel32" _ 31 | (ByVal hDevice As LongPtr, _ 32 | ByVal dwIoControlCode As Long, _ 33 | ByVal lpInBuffer As LongPtr, _ 34 | ByVal nInBufferSize As Long, _ 35 | Optional lpOutBuffer As LongPtr, _ 36 | Optional ByVal nOutBufferSize As Long, _ 37 | Optional lpBytesReturned As Long, _ 38 | Optional ByVal lpOverlapped As LongPtr) As Boolean 39 | 40 | Private Declare Function GetLastError Lib "kernel32" () As LongPtr 41 | Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As LongPtr) 42 | Private Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" _ 43 | (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, _ 44 | ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, _ 45 | Arguments As Long) As Long 46 | 47 | 48 | Public Function ProcMonDebugOutput(message As String) As Boolean 49 | If hProcMon = 0 Or hProcMon = 0 Then 50 | hProcMon = CreateFile(StrPtr(PROCMON_DEBUGGER_HANDLER)) 51 | End If 52 | If hProcMon = -1 Then 53 | Err.Raise Err.LastDllError 54 | End If 55 | 56 | ProcMonDebugOutput = DeviceIoControl _ 57 | (hProcMon, IOCTL_EXTERNAL_LOG_DEBUGOUT, _ 58 | StrPtr(message), Len(message) * 2) 59 | End Function 60 | 61 | --------------------------------------------------------------------------------