PageRenderTime 38ms CodeModel.GetById 19ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

/reporting/crashrpt/SharedMem.h

http://crashrpt.googlecode.com/
C++ Header | 165 lines | 112 code | 22 blank | 31 comment | 0 complexity | bfb5e458c5e5ba025799f665c284cd5b MD5 | raw file
  1/************************************************************************************* 
  2This file is a part of CrashRpt library.
  3Copyright (c) 2003-2013 The CrashRpt project authors. All Rights Reserved.
  4
  5Use of this source code is governed by a BSD-style license
  6that can be found in the License.txt file in the root of the source
  7tree. All contributing project authors may
  8be found in the Authors.txt file in the root of the source tree.
  9***************************************************************************************/
 10
 11// File: SharedMem.h
 12// Description: Shared memory class. Used for transferring data from crashed app to crash sender process.
 13// Authors: zexspectrum
 14// Date: 2010
 15
 16#pragma once
 17#include "stdafx.h"
 18#include "CritSec.h"
 19
 20// Generic block header.
 21struct GENERIC_HEADER
 22{
 23    BYTE m_uchMagic[3]; // Magic sequence.
 24    WORD m_wSize;       // Total bytes occupied by this block.
 25};
 26
 27// String block description.
 28struct STRING_DESC
 29{
 30    BYTE m_uchMagic[3]; // Magic sequence "STR".  
 31    WORD m_wSize;       // Total bytes occupied by this block.
 32    // This structure is followed by (m_wSize-sizeof(STRING_DESC) bytes of string data.
 33};
 34
 35// File item entry.
 36struct FILE_ITEM
 37{
 38    BYTE m_uchMagic[3]; // Magic sequence "FIL"
 39    WORD m_wSize;       // Total bytes occupied by this block.
 40    DWORD m_dwSrcFilePathOffs; // Path to the original file.
 41    DWORD m_dwDstFileNameOffs; // Name of the destination file.
 42    DWORD m_dwDescriptionOffs; // File description.
 43    BOOL  m_bMakeCopy;         // Should we make a copy of this file on crash?
 44	BOOL  m_bAllowDelete;      // Should allow user to delete the file from crash report?
 45};
 46
 47// Registry key entry.
 48struct REG_KEY
 49{
 50    BYTE m_uchMagic[3];        // Magic sequence "REG"
 51    WORD m_wSize;              // Total bytes occupied by this block.
 52	BOOL m_bAllowDelete;       // Should allow user to delete the file from crash report?
 53    DWORD m_dwRegKeyNameOffs;  // Registry key name.
 54    DWORD m_dwDstFileNameOffs; // Destination file name.
 55};
 56
 57// User-defined property.
 58struct CUSTOM_PROP
 59{
 60    BYTE m_uchMagic[3];  // Magic sequence "CPR"
 61    WORD m_wSize;        // Total bytes occupied by this block.
 62    DWORD m_dwNameOffs;  // Property name.
 63    DWORD m_dwValueOffs; // Property value.
 64};
 65
 66// Crash description. 
 67struct CRASH_DESCRIPTION
 68{  
 69    BYTE m_uchMagic[3];  // Magic sequence "CRD"
 70    WORD m_wSize;        // Total bytes occupied by this block.
 71    DWORD m_dwTotalSize; // Total size of the whole used shared mem.
 72    DWORD m_dwCrashRptVer;         // Version of CrashRpt.
 73    UINT m_uFileItems;             // Count of file item records.
 74    UINT m_uRegKeyEntries;         // Count of registry key entries.
 75    UINT m_uCustomProps;           // Count of user-defined properties.  
 76    DWORD m_dwInstallFlags;        // Flags passed to crInstall() function.
 77    int m_nSmtpPort;               // Smtp port.
 78    int m_nSmtpProxyPort;          // Smtp proxy port.
 79    UINT m_uPriorities[3];         // Delivery priorities.
 80    MINIDUMP_TYPE m_MinidumpType;  // Minidump type.
 81    //BOOL m_bAppRestart;            // Packed into flags
 82    BOOL  m_bAddScreenshot;        // Add screenshot?
 83    DWORD m_dwScreenshotFlags;     // Screenshot flags.
 84    int m_nJpegQuality;            // Jpeg image quality.
 85    DWORD m_dwUrlOffs;             // Offset of recipient URL.
 86    DWORD m_dwAppNameOffs;         // Offset of application name.
 87    DWORD m_dwAppVersionOffs;      // Offset of app version.
 88    DWORD m_dwLangFileNameOffs;    // Offset of language INI file name.
 89    DWORD m_dwRestartCmdLineOffs;  // Offset of app restart command line.
 90	int m_nRestartTimeout;         // Restart timeout
 91    DWORD m_dwEmailToOffs;         // Offset to E-mail recipient.
 92    DWORD m_dwCrashGUIDOffs;       // Offset to crash GUID.
 93    DWORD m_dwUnsentCrashReportsFolderOffs;  // Offset of folder name where error reports are stored.
 94    DWORD m_dwPrivacyPolicyURLOffs; // Offset of privacy policy URL.
 95    DWORD m_dwEmailSubjectOffs;    // Offset of E-mail subject.
 96    DWORD m_dwEmailTextOffs;       // Offset of E-mail text.
 97    DWORD m_dwSmtpProxyServerOffs; // Offset of SMTP proxy server name.
 98    DWORD m_dwPathToDebugHelpDllOffs; // Offset of dbghelp path.
 99    DWORD m_dwCustomSenderIconOffs; // Offset of custom Error Report dialog icon resource name.
100    DWORD m_dwImageNameOffs;       // Offset to image name.
101    DWORD m_dwProcessId;           // Process ID.
102    DWORD m_dwThreadId;            // Thread ID.
103    int m_nExceptionType;          // Exception type.
104    DWORD m_dwExceptionCode;       // SEH exception code.
105    DWORD m_dwInvParamExprOffs;    // Invalid parameter expression.
106    DWORD m_dwInvParamFunctionOffs; // Invalid parameter function.
107    DWORD m_dwInvParamFileOffs;    // Invalid parameter file.
108    UINT  m_uInvParamLine;         // Invalid parameter line.
109    UINT m_uFPESubcode;            // FPE subcode.
110    PEXCEPTION_POINTERS m_pExceptionPtrs; // Exception pointers.
111    BOOL m_bSendRecentReports;     // If TRUE, CrashSender.exe needs to send queued error reports.
112								   // If FALSE, CrashSender.exe needs to send single report.
113	DWORD m_dwSmtpLoginOffs;       // Offset of SMTP login name.
114	DWORD m_dwSmtpPasswordOffs;    // Offset of SMTP login name. 
115	BOOL  m_bAddVideo;             // Wether to add video recording.
116	DWORD m_dwVideoFlags;          // Flags for video recording.
117	int   m_nVideoDuration;        // Video duration.
118	int   m_nVideoFrameInterval;   // Video frame interval.
119	SIZE  m_DesiredFrameSize;      // Video frame size.
120	HWND m_hWndVideoParent;        // Parent window for video recording dialog.
121	BOOL m_bClientAppCrashed;      // If TRUE, the client app has crashed; otherwise the client has exited without crash.          
122};
123
124#define SHARED_MEM_MAX_SIZE 10*1024*1024   /* 10 MB */
125
126// Used to share memory between CrashRpt.dll and CrashSender.exe
127class CSharedMem
128{
129public:
130
131    // Construction/destruction
132    CSharedMem();  
133    ~CSharedMem();  
134
135    // Initializes shared memory
136    BOOL Init(LPCTSTR szName, BOOL bOpenExisting, ULONG64 uSize);
137
138	// Whether initialized or not
139	BOOL IsInitialized();
140
141    // Destroys the object
142    BOOL Destroy();
143
144    // Returns file mapping name
145    CString GetName(); 
146
147    // Returns file mapping size
148    ULONG64 GetSize();
149
150    // Creates a view and returns its start pointer
151    LPBYTE CreateView(DWORD dwOffset, DWORD dwLength);
152
153    // Destroys a view
154    void DestroyView(LPBYTE pViewPtr);
155
156private:
157
158    CString m_sName;            // Name of the file mapping.
159    HANDLE m_hFileMapping;		// Memory mapped object
160    DWORD m_dwAllocGranularity; // System allocation granularity  	  
161    ULONG64 m_uSize;	      	// Size of the file mapping.		  
162    std::map<LPBYTE, LPBYTE> m_aViewStartPtrs; // Base of the view of the file mapping.    
163};
164
165