Changeset 1614


Ignore:
Timestamp:
01/19/10 08:31:55 (5 years ago)
Author:
lowjoel
Message:

Split the Eraser.Util.BlackBox?.NativeMethods? class to the Eraser.Util.NativeMethods? partial class. Addresses #317: Merge the BlackBox? branch

Location:
branches/eraser6/CodeReview/Eraser.Util
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview/Eraser.Util/BlackBox.cs

    r1613 r1614  
    2323using System.Collections.Generic; 
    2424using System.Text; 
     25 
    2526using System.Windows.Forms; 
    2627using System.IO; 
    2728using System.Runtime.InteropServices; 
     29using System.Diagnostics; 
     30using System.Reflection; 
    2831using Microsoft.Win32.SafeHandles; 
    29 using System.Diagnostics; 
    30 using System.Threading; 
     32 
    3133using System.Drawing; 
    3234using System.Drawing.Imaging; 
    33 using System.Reflection; 
    34 using System.Collections.ObjectModel; 
    3535using System.Globalization; 
    3636 
     
    4343    public class BlackBox 
    4444    { 
    45         /// <summary> 
    46         /// Stores DLL references for this class. 
    47         /// </summary> 
    48         private static class NativeMethods 
    49         { 
    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 information 
    54             /// is to be generated.</param> 
    55             /// <param name="ProcessId">The identifier of the process for which the information 
    56             /// is to be generated.</param> 
    57             /// <param name="hFile">A handle to the file in which the information is to be 
    58             /// written.</param> 
    59             /// <param name="DumpType">The type of information to be generated. This parameter 
    60             /// can be one or more of the values from the MINIDUMP_TYPE enumeration.</param> 
    61             /// <param name="ExceptionParam">A pointer to a MiniDumpExceptionInfo structure 
    62             /// describing the client exception that caused the minidump to be generated. 
    63             /// If the value of this parameter is NULL, no exception information is included 
    64             /// 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, the 
    68             /// 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 file 
    79             /// by the MiniDumpWriteDump function. 
    80             /// </summary> 
    81             public enum MiniDumpType 
    82             { 
    83                 /// <summary> 
    84                 /// Include just the information necessary to capture stack traces for all 
    85                 /// 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 the 
    91                 /// inclusion of global variables, which can make the minidump file significantly 
    92                 /// larger. For per-module control, use the ModuleWriteDataSeg enumeration 
    93                 /// 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 is 
    99                 /// included at the end, so that the initial structures can be mapped directly 
    100                 /// without the raw memory information. This option can result in a very large 
    101                 /// file. 
    102                 /// </summary> 
    103                 MiniDumpWithFullMemory = 0x00000002, 
    104  
    105                 /// <summary> 
    106                 /// Include high-level information about the operating system handles that are 
    107                 /// 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 be 
    113                 /// filtered to remove all but the pointer values necessary to reconstruct a 
    114                 /// 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 references 
    120                 /// to modules in the module list. If a module is referenced by stack or backing 
    121                 /// store memory, the ModuleWriteFlags member of the MINIDUMP_CALLBACK_OUTPUT 
    122                 /// 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 important 
    140                 /// directories. This option may prevent the system from locating the image 
    141                 /// 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 operating 
    147                 /// 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 not 
    158                 /// essential to meet criteria specified for the dump. This can avoid dumping 
    159                 /// memory that may contain data that is private to the user. However, it is 
    160                 /// 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, see 
    166                 /// MINIDUMP_MEMORY_INFO_LIST. 
    167                 /// </summary> 
    168                 MiniDumpWithFullMemoryInfo = 0x00000800, 
    169  
    170                 /// <summary> 
    171                 /// Include thread state information. For more information, see 
    172                 /// MINIDUMP_THREAD_INFO_LIST. 
    173                 /// </summary> 
    174                 MiniDumpWithThreadInfo = 0x00001000, 
    175  
    176                 /// <summary> 
    177                 /// Include all code and code-related sections from loaded modules to capture 
    178                 /// executable content. For per-module control, use the ModuleWriteCodeSegs 
    179                 /// 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 dump 
    190                 /// image; the state data that is included is provider dependent. This option 
    191                 /// 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 will 
    202                 /// fail if the function cannot read the memory regions; however, if you include 
    203                 /// MiniDumpIgnoreInaccessibleMemory, the MiniDumpWriteDump function will 
    204                 /// ignore the memory read failures and continue to generate the dump. Note that 
    205                 /// 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 work 
    211                 /// when processing a user-mode dump.  
    212                 /// </summary> 
    213                 MiniDumpWithTokenInformation = 0x00040000 
    214             } 
    215  
    216             /// <summary> 
    217             /// Contains the exception information written to the minidump file by the 
    218             /// MiniDumpWriteDump function. 
    219             /// </summary> 
    220             [StructLayout(LayoutKind.Sequential, Pack = 4)] 
    221             public struct MiniDumpExceptionInfo 
    222             { 
    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 a 
    230                 ///  computer-independent description of the exception and the processor 
    231                 ///  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 the 
    237                 /// ExceptionPointers member. Set to TRUE if the memory resides in the 
    238                 /// process being debugged (the target process of the debugger). Otherwise, 
    239                 /// set to FALSE if the memory resides in the address space of the calling 
    240                 /// program (the debugger process). If you are accessing local memory (in 
    241                 /// the calling process) you should not set this member to TRUE. 
    242                 /// </summary> 
    243                 [MarshalAs(UnmanagedType.Bool)] 
    244                 public bool ClientPointers; 
    245             } 
    246         } 
    247  
    24845        /// <summary> 
    24946        /// Initialises the BlackBox handler. Call this initialiser once throughout 
  • branches/eraser6/CodeReview/Eraser.Util/Eraser.Util.csproj

    r1613 r1614  
    9999  <ItemGroup> 
    100100    <Compile Include="ConsoleWindow.cs" /> 
     101    <Compile Include="NativeMethods\DbgHelp.cs" /> 
    101102    <Compile Include="Power.cs" /> 
    102103    <Compile Include="NativeMethods\Gdi.cs" /> 
Note: See TracChangeset for help on using the changeset viewer.