Changeset 1614 for branches/eraser6/CodeReview/Eraser.Util/BlackBox.cs
- Timestamp:
- 1/19/2010 8:31:55 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/CodeReview/Eraser.Util/BlackBox.cs
r1613 r1614 23 23 using System.Collections.Generic; 24 24 using System.Text; 25 25 26 using System.Windows.Forms; 26 27 using System.IO; 27 28 using System.Runtime.InteropServices; 29 using System.Diagnostics; 30 using System.Reflection; 28 31 using Microsoft.Win32.SafeHandles; 29 using System.Diagnostics; 30 using System.Threading; 32 31 33 using System.Drawing; 32 34 using System.Drawing.Imaging; 33 using System.Reflection;34 using System.Collections.ObjectModel;35 35 using System.Globalization; 36 36 … … 43 43 public class BlackBox 44 44 { 45 /// <summary>46 /// Stores DLL references for this class.47 /// </summary>48 private static class NativeMethods49 {50 /// <summary>51 /// Writes user-mode minidump information to the specified file.52 /// </summary>53 /// <param name="hProcess">A handle to the process for which the information54 /// is to be generated.</param>55 /// <param name="ProcessId">The identifier of the process for which the information56 /// is to be generated.</param>57 /// <param name="hFile">A handle to the file in which the information is to be58 /// written.</param>59 /// <param name="DumpType">The type of information to be generated. This parameter60 /// can be one or more of the values from the MINIDUMP_TYPE enumeration.</param>61 /// <param name="ExceptionParam">A pointer to a MiniDumpExceptionInfo structure62 /// describing the client exception that caused the minidump to be generated.63 /// If the value of this parameter is NULL, no exception information is included64 /// in the minidump file.</param>65 /// <param name="UserStreamParam">Not supported. Use IntPtr.Zero</param>66 /// <param name="CallbackParam">Not supported. Use IntPtr.Zero</param>67 /// <returns>If the function succeeds, the return value is true; otherwise, the68 /// return value is false. To retrieve extended error information, call GetLastError.69 /// Note that the last error will be an HRESULT value.</returns>70 [DllImport("dbghelp.dll", SetLastError = true)]71 [return: MarshalAs(UnmanagedType.Bool)]72 public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId,73 SafeFileHandle hFile, MiniDumpType DumpType,74 ref MiniDumpExceptionInfo ExceptionParam, IntPtr UserStreamParam,75 IntPtr CallbackParam);76 77 /// <summary>78 /// Identifies the type of information that will be written to the minidump file79 /// by the MiniDumpWriteDump function.80 /// </summary>81 public enum MiniDumpType82 {83 /// <summary>84 /// Include just the information necessary to capture stack traces for all85 /// existing threads in a process.86 /// </summary>87 MiniDumpNormal = 0x00000000,88 89 /// <summary>90 /// Include the data sections from all loaded modules. This results in the91 /// inclusion of global variables, which can make the minidump file significantly92 /// larger. For per-module control, use the ModuleWriteDataSeg enumeration93 /// value from MODULE_WRITE_FLAGS.94 /// </summary>95 MiniDumpWithDataSegs = 0x00000001,96 97 /// <summary>98 /// Include all accessible memory in the process. The raw memory data is99 /// included at the end, so that the initial structures can be mapped directly100 /// without the raw memory information. This option can result in a very large101 /// file.102 /// </summary>103 MiniDumpWithFullMemory = 0x00000002,104 105 /// <summary>106 /// Include high-level information about the operating system handles that are107 /// active when the minidump is made.108 /// </summary>109 MiniDumpWithHandleData = 0x00000004,110 111 /// <summary>112 /// Stack and backing store memory written to the minidump file should be113 /// filtered to remove all but the pointer values necessary to reconstruct a114 /// stack trace. Typically, this removes any private information.115 /// </summary>116 MiniDumpFilterMemory = 0x00000008,117 118 /// <summary>119 /// Stack and backing store memory should be scanned for pointer references120 /// to modules in the module list. If a module is referenced by stack or backing121 /// store memory, the ModuleWriteFlags member of the MINIDUMP_CALLBACK_OUTPUT122 /// structure is set to ModuleReferencedByMemory.123 /// </summary>124 MiniDumpScanMemory = 0x00000010,125 126 /// <summary>127 /// Include information from the list of modules that were recently unloaded,128 /// if this information is maintained by the operating system.129 /// </summary>130 MiniDumpWithUnloadedModules = 0x00000020,131 132 /// <summary>133 /// Include pages with data referenced by locals or other stack memory.134 /// This option can increase the size of the minidump file significantly.135 /// </summary>136 MiniDumpWithIndirectlyReferencedMemory = 0x00000040,137 138 /// <summary>139 /// Filter module paths for information such as user names or important140 /// directories. This option may prevent the system from locating the image141 /// file and should be used only in special situations.142 /// </summary>143 MiniDumpFilterModulePaths = 0x00000080,144 145 /// <summary>146 /// Include complete per-process and per-thread information from the operating147 /// system.148 /// </summary>149 MiniDumpWithProcessThreadData = 0x00000100,150 151 /// <summary>152 /// Scan the virtual address space for PAGE_READWRITE memory to be included.153 /// </summary>154 MiniDumpWithPrivateReadWriteMemory = 0x00000200,155 156 /// <summary>157 /// Reduce the data that is dumped by eliminating memory regions that are not158 /// essential to meet criteria specified for the dump. This can avoid dumping159 /// memory that may contain data that is private to the user. However, it is160 /// not a guarantee that no private information will be present.161 /// </summary>162 MiniDumpWithoutOptionalData = 0x00000400,163 164 /// <summary>165 /// Include memory region information. For more information, see166 /// MINIDUMP_MEMORY_INFO_LIST.167 /// </summary>168 MiniDumpWithFullMemoryInfo = 0x00000800,169 170 /// <summary>171 /// Include thread state information. For more information, see172 /// MINIDUMP_THREAD_INFO_LIST.173 /// </summary>174 MiniDumpWithThreadInfo = 0x00001000,175 176 /// <summary>177 /// Include all code and code-related sections from loaded modules to capture178 /// executable content. For per-module control, use the ModuleWriteCodeSegs179 /// enumeration value from MODULE_WRITE_FLAGS.180 /// </summary>181 MiniDumpWithCodeSegs = 0x00002000,182 183 /// <summary>184 /// Turns off secondary auxiliary-supported memory gathering.185 /// </summary>186 MiniDumpWithoutAuxiliaryState = 0x00004000,187 188 /// <summary>189 /// Requests that auxiliary data providers include their state in the dump190 /// image; the state data that is included is provider dependent. This option191 /// can result in a large dump image.192 /// </summary>193 MiniDumpWithFullAuxiliaryState = 0x00008000,194 195 /// <summary>196 /// Scans the virtual address space for PAGE_WRITECOPY memory to be included.197 /// </summary>198 MiniDumpWithPrivateWriteCopyMemory = 0x00010000,199 200 /// <summary>201 /// If you specify MiniDumpWithFullMemory, the MiniDumpWriteDump function will202 /// fail if the function cannot read the memory regions; however, if you include203 /// MiniDumpIgnoreInaccessibleMemory, the MiniDumpWriteDump function will204 /// ignore the memory read failures and continue to generate the dump. Note that205 /// the inaccessible memory regions are not included in the dump.206 /// </summary>207 MiniDumpIgnoreInaccessibleMemory = 0x00020000,208 209 /// <summary>210 /// Adds security token related data. This will make the "!token" extension work211 /// when processing a user-mode dump.212 /// </summary>213 MiniDumpWithTokenInformation = 0x00040000214 }215 216 /// <summary>217 /// Contains the exception information written to the minidump file by the218 /// MiniDumpWriteDump function.219 /// </summary>220 [StructLayout(LayoutKind.Sequential, Pack = 4)]221 public struct MiniDumpExceptionInfo222 {223 /// <summary>224 /// The identifier of the thread throwing the exception.225 /// </summary>226 public uint ThreadId;227 228 /// <summary>229 /// A pointer to an EXCEPTION_POINTERS structure specifying a230 /// computer-independent description of the exception and the processor231 /// context at the time of the exception.232 /// </summary>233 public IntPtr ExceptionPointers;234 235 /// <summary>236 /// Determines where to get the memory regions pointed to by the237 /// ExceptionPointers member. Set to TRUE if the memory resides in the238 /// process being debugged (the target process of the debugger). Otherwise,239 /// set to FALSE if the memory resides in the address space of the calling240 /// program (the debugger process). If you are accessing local memory (in241 /// the calling process) you should not set this member to TRUE.242 /// </summary>243 [MarshalAs(UnmanagedType.Bool)]244 public bool ClientPointers;245 }246 }247 248 45 /// <summary> 249 46 /// Initialises the BlackBox handler. Call this initialiser once throughout
Note: See TracChangeset
for help on using the changeset viewer.
