third-party libs
This commit is contained in:
parent
f836927d3a
commit
b154ee9266
3667 changed files with 854591 additions and 0 deletions
105
third-party/BugTrap-1.3-57bd515/source/AboutDlg.cpp
vendored
Normal file
105
third-party/BugTrap-1.3-57bd515/source/AboutDlg.cpp
vendored
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: About dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "AboutDlg.h"
|
||||
#include "BugTrapUI.h"
|
||||
#include "BugTrapUtils.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUI BugTrap Graphical User Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// E-mail hyper-link control.
|
||||
static CHyperLink g_hlURL;
|
||||
|
||||
/**
|
||||
* @brief WM_COMMAND handler of About dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param id - control ID.
|
||||
* @param hwndCtl - control handle.
|
||||
* @param codeNotify - notification code.
|
||||
*/
|
||||
static void AboutDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
codeNotify; hwndCtl;
|
||||
switch (id)
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_INITDIALOG handler of About dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hwndFocus - system-defined focus window.
|
||||
* @param lParam - user-defined parameter.
|
||||
* @return true to setup focus to system-defined control.
|
||||
*/
|
||||
static BOOL AboutDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
lParam; hwndFocus;
|
||||
|
||||
CenterWindow(hwnd, GetParent(hwnd));
|
||||
HWND hwndCtl = GetDlgItem(hwnd, IDCANCEL);
|
||||
SetFocus(hwndCtl);
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_URL);
|
||||
TCHAR szLinkURL[MAX_PATH];
|
||||
GetWindowText(hwndCtl, szLinkURL, countof(szLinkURL));
|
||||
g_hlURL.SetLinkURL(szLinkURL);
|
||||
g_hlURL.Attach(hwndCtl);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_DESTROY handler of About dialog.
|
||||
* @param hwnd - window handle.
|
||||
*/
|
||||
static void AboutDlg_OnDestroy(HWND hwnd)
|
||||
{
|
||||
hwnd;
|
||||
g_hlURL.Detach();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dialog procedure of About dialog.
|
||||
* @param hwndDlg - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - 1st message parameter.
|
||||
* @param lParam - 2nd message parameter.
|
||||
* @return message result.
|
||||
*/
|
||||
INT_PTR CALLBACK AboutDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
HANDLE_MSG(hwndDlg, WM_INITDIALOG, AboutDlg_OnInitDialog);
|
||||
HANDLE_MSG(hwndDlg, WM_COMMAND, AboutDlg_OnCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_DESTROY, AboutDlg_OnDestroy);
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
17
third-party/BugTrap-1.3-57bd515/source/AboutDlg.h
vendored
Normal file
17
third-party/BugTrap-1.3-57bd515/source/AboutDlg.h
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: About dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
INT_PTR CALLBACK AboutDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
249
third-party/BugTrap-1.3-57bd515/source/AnimProgressBar.cpp
vendored
Normal file
249
third-party/BugTrap-1.3-57bd515/source/AnimProgressBar.cpp
vendored
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Animated progress bar control.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "AnimProgressBar.h"
|
||||
#include "ThemeXP.h"
|
||||
|
||||
#define USE_MEM_DC
|
||||
|
||||
#define TIMER_ID 101
|
||||
#define DEFAULT_TIMEOUT 5
|
||||
#define DEFAULT_NUM_CHUNKS 5
|
||||
|
||||
CAnimProgressBar::CAnimProgressBar(void)
|
||||
{
|
||||
m_bActive = FALSE;
|
||||
m_dwTimeout = DEFAULT_TIMEOUT;
|
||||
m_dwNumChunks = DEFAULT_NUM_CHUNKS;
|
||||
m_dwPosition = 0;
|
||||
m_hwnd = NULL;
|
||||
m_pfnAnimProgressBarWndProc = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - progress bar window handle.
|
||||
*/
|
||||
void CAnimProgressBar::Attach(HWND hwnd)
|
||||
{
|
||||
_ASSERTE(hwnd != NULL);
|
||||
_ASSERTE(m_hwnd == NULL);
|
||||
m_hwnd = hwnd;
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this);
|
||||
m_pfnAnimProgressBarWndProc = SubclassWindow(hwnd, AnimProgressBarWndProc);
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
|
||||
void CAnimProgressBar::Detach(void)
|
||||
{
|
||||
if (m_pfnAnimProgressBarWndProc)
|
||||
{
|
||||
Stop();
|
||||
SubclassWindow(m_hwnd, m_pfnAnimProgressBarWndProc);
|
||||
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, NULL);
|
||||
InvalidateRect(m_hwnd, NULL, TRUE);
|
||||
m_pfnAnimProgressBarWndProc = NULL;
|
||||
m_hwnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimProgressBar::Play()
|
||||
{
|
||||
if (m_bActive)
|
||||
return;
|
||||
m_bActive = TRUE;
|
||||
SetTimer(m_hwnd, TIMER_ID, m_dwTimeout, NULL);
|
||||
}
|
||||
|
||||
void CAnimProgressBar::Stop()
|
||||
{
|
||||
if (! m_bActive)
|
||||
return;
|
||||
m_bActive = FALSE;
|
||||
KillTimer(m_hwnd, TIMER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwTimeout - new update timeout.
|
||||
*/
|
||||
void CAnimProgressBar::SetTimeout(DWORD dwTimeout)
|
||||
{
|
||||
m_dwTimeout = dwTimeout;
|
||||
if (m_bActive)
|
||||
SetTimer(m_hwnd, TIMER_ID, dwTimeout, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hdc - drawing context.
|
||||
* @param prcPaint - the rectangle where the painting is requested.
|
||||
*/
|
||||
void CAnimProgressBar::DrawAnimProgressBar(HDC hdc, const RECT* prcPaint) const
|
||||
{
|
||||
if (prcPaint == NULL)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
prcPaint = &rcClient;
|
||||
}
|
||||
if (IsRectEmpty(prcPaint))
|
||||
return;
|
||||
|
||||
#ifdef USE_MEM_DC
|
||||
int nClientWidth = prcPaint->right - prcPaint->left;
|
||||
int nClientHeight = prcPaint->bottom - prcPaint->top;
|
||||
HBITMAP hbmpMem;
|
||||
hbmpMem = CreateCompatibleBitmap(hdc, nClientWidth, nClientHeight);
|
||||
if (hbmpMem == NULL)
|
||||
return;
|
||||
HDC hdcMem;
|
||||
hdcMem = CreateCompatibleDC(hdc);
|
||||
if (hdcMem == NULL)
|
||||
{
|
||||
DeleteBitmap(hbmpMem);
|
||||
return;
|
||||
}
|
||||
SetViewportOrgEx(hdcMem, -prcPaint->left, -prcPaint->top, NULL);
|
||||
HBITMAP hbmpSafe = SelectBitmap(hdcMem, hbmpMem);
|
||||
#else
|
||||
// CS_PARENTDC sets the clipping rectangle of the child window to that of the parent window
|
||||
// so that the child can draw on the parent. Progress bar inherits this style from sub-classed
|
||||
// static control. This causes problems with unclipped output.
|
||||
HRGN hrgn = CreateRectRgnIndirect(prcPaint);
|
||||
SelectClipRgn(hdc, hrgn);
|
||||
DeleteRgn(hrgn);
|
||||
HDC hdcMem = hdc;
|
||||
#endif
|
||||
|
||||
CThemeXP themeXP;
|
||||
BOOL bAppThemed = themeXP.IsAppThemed();
|
||||
if (bAppThemed)
|
||||
{
|
||||
if (! themeXP.OpenTheme(m_hwnd, L"PROGRESS"))
|
||||
bAppThemed = FALSE;
|
||||
}
|
||||
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
RECT rcClip;
|
||||
GetClipBox(hdc, &rcClip);
|
||||
|
||||
if (bAppThemed)
|
||||
{
|
||||
themeXP.DrawThemeBackground(hdcMem, PP_BAR, 0, &rcClient, &rcClip);
|
||||
RECT rcContent;
|
||||
themeXP.GetThemeBackgroundContentRect(hdcMem, PP_BAR, 0, &rcClient, &rcContent);
|
||||
SIZE szChunk;
|
||||
themeXP.GetThemePartSize(hdcMem, PP_CHUNK, 0, &rcContent, TS_TRUE, &szChunk);
|
||||
if (szChunk.cx <= 1)
|
||||
szChunk.cx = szChunk.cy * 3 / 4;
|
||||
DWORD dwChunksWidth = m_dwNumChunks * szChunk.cx;
|
||||
DWORD dwPosition = m_dwPosition % (rcContent.right - rcContent.left + dwChunksWidth);
|
||||
int nPosition = (int)dwPosition - (int)dwChunksWidth;
|
||||
RECT rcChunk;
|
||||
rcChunk.left = rcContent.left + nPosition;
|
||||
rcChunk.top = rcContent.top;
|
||||
rcChunk.bottom = rcContent.bottom;
|
||||
for (DWORD dwChunkNum = 0; dwChunkNum < m_dwNumChunks; ++dwChunkNum)
|
||||
{
|
||||
rcChunk.right = rcChunk.left + szChunk.cx;
|
||||
if (rcClip.left <= rcChunk.right && rcChunk.left < rcClip.right)
|
||||
themeXP.DrawThemeBackground(hdcMem, PP_CHUNK, 0, &rcChunk, &rcClip);
|
||||
rcChunk.left = rcChunk.right;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HBRUSH brushBtnFace = GetSysColorBrush(COLOR_BTNFACE);
|
||||
FillRect(hdcMem, &rcClip, brushBtnFace);
|
||||
HBRUSH brushHighlight = GetSysColorBrush(COLOR_HIGHLIGHT);
|
||||
int nCXEdge = GetSystemMetrics(SM_CXEDGE);
|
||||
int nCYEdge = GetSystemMetrics(SM_CYEDGE);
|
||||
SIZE szChunk;
|
||||
szChunk.cy = rcClient.bottom - rcClient.top;
|
||||
szChunk.cx = szChunk.cy * 3 / 4;
|
||||
DWORD dwChunksWidth = m_dwNumChunks * szChunk.cx;
|
||||
DWORD dwPosition = m_dwPosition % (rcClient.right - rcClient.left + dwChunksWidth);
|
||||
int nPosition = (int)dwPosition - (int)dwChunksWidth;
|
||||
RECT rcChunk;
|
||||
rcChunk.left = rcClient.left + nPosition + nCXEdge;
|
||||
rcChunk.top = rcClient.top + nCYEdge;
|
||||
rcChunk.bottom = rcClient.bottom - nCYEdge;
|
||||
szChunk.cx -= 2 * nCXEdge;
|
||||
for (DWORD dwChunkNum = 0; dwChunkNum < m_dwNumChunks; ++dwChunkNum)
|
||||
{
|
||||
rcChunk.right = rcChunk.left + szChunk.cx;
|
||||
if (rcClip.left <= rcChunk.right && rcChunk.left < rcClip.right)
|
||||
FillRect(hdcMem, &rcChunk, brushHighlight);
|
||||
rcChunk.left = rcChunk.right + nCXEdge;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_MEM_DC
|
||||
BitBlt(hdc, prcPaint->left, prcPaint->top, nClientWidth, nClientHeight, hdcMem, prcPaint->left, prcPaint->top, SRCCOPY);
|
||||
SelectBitmap(hdcMem, hbmpSafe);
|
||||
DeleteDC(hdcMem);
|
||||
DeleteBitmap(hbmpMem);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - first message parameter.
|
||||
* @param lParam - second message parameter.
|
||||
*/
|
||||
LRESULT CALLBACK CAnimProgressBar::AnimProgressBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
CAnimProgressBar* _this = (CAnimProgressBar*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
_ASSERTE(_this != NULL);
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_ERASEBKGND:
|
||||
return TRUE;
|
||||
case WM_PAINT:
|
||||
hdc = (HDC)wParam;
|
||||
if (! hdc)
|
||||
{
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
if (hdc)
|
||||
{
|
||||
_this->DrawAnimProgressBar(hdc, &ps.rcPaint);
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
}
|
||||
else
|
||||
_this->DrawAnimProgressBar(hdc, NULL);
|
||||
return 0;
|
||||
case WM_PRINTCLIENT:
|
||||
hdc = (HDC)wParam;
|
||||
_this->DrawAnimProgressBar(hdc, NULL);
|
||||
return 0;
|
||||
case WM_TIMER:
|
||||
if (! _this->m_bActive)
|
||||
return 0;
|
||||
++_this->m_dwPosition;
|
||||
RedrawWindow(_this->m_hwnd, NULL, NULL, RDW_INVALIDATE);
|
||||
return 0;
|
||||
case WM_DESTROY:
|
||||
_this->Stop();
|
||||
return 0;
|
||||
case WM_NCHITTEST:
|
||||
return HTTRANSPARENT;
|
||||
default:
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
95
third-party/BugTrap-1.3-57bd515/source/AnimProgressBar.h
vendored
Normal file
95
third-party/BugTrap-1.3-57bd515/source/AnimProgressBar.h
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Animated progress bar control.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class CAnimProgressBar
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CAnimProgressBar(void);
|
||||
/// Attach progress bar object to window handle.
|
||||
void Attach(HWND hwnd);
|
||||
/// Detach progress bar object to window handle.
|
||||
void Detach(void);
|
||||
/// Start animation.
|
||||
void Play();
|
||||
/// Stop animation.
|
||||
void Stop();
|
||||
/// Return true if animation is active.
|
||||
BOOL IsActive() const;
|
||||
/// Get update timeout.
|
||||
DWORD GetTimeout() const;
|
||||
/// Set update timeout.
|
||||
void SetTimeout(DWORD dwTimeout);
|
||||
/// Get number of visible chunks.
|
||||
DWORD GetNumChunks() const;
|
||||
/// Set number of visible chunks.
|
||||
void SetNumChunks(DWORD dwNumChunks);
|
||||
|
||||
private:
|
||||
/// Protect the class from being accidentally copied.
|
||||
CAnimProgressBar(const CAnimProgressBar& rAnimProgressBar);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CAnimProgressBar& operator=(const CAnimProgressBar& rAnimProgressBar);
|
||||
/// Window procedure of progress bar window.
|
||||
static LRESULT CALLBACK AnimProgressBarWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Draw window client area.
|
||||
void DrawAnimProgressBar(HDC hdc, const RECT* prcPaint) const;
|
||||
|
||||
/// Window handle.
|
||||
HWND m_hwnd;
|
||||
/// True if animation is active.
|
||||
BOOL m_bActive;
|
||||
/// Update timeout.
|
||||
DWORD m_dwTimeout;
|
||||
/// Number of visible chunks.
|
||||
DWORD m_dwNumChunks;
|
||||
/// Current position.
|
||||
DWORD m_dwPosition;
|
||||
/// Old static window procedure.
|
||||
WNDPROC m_pfnAnimProgressBarWndProc;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return true if animation is active.
|
||||
*/
|
||||
inline BOOL CAnimProgressBar::IsActive() const
|
||||
{
|
||||
return m_bActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current update timeout.
|
||||
*/
|
||||
inline DWORD CAnimProgressBar::GetTimeout() const
|
||||
{
|
||||
return m_dwTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of visible chunks.
|
||||
*/
|
||||
inline DWORD CAnimProgressBar::GetNumChunks() const
|
||||
{
|
||||
return m_dwNumChunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwNumChunks - number of visible chunks.
|
||||
*/
|
||||
inline void CAnimProgressBar::SetNumChunks(DWORD dwNumChunks)
|
||||
{
|
||||
m_dwNumChunks = dwNumChunks;
|
||||
}
|
||||
552
third-party/BugTrap-1.3-57bd515/source/Array.h
vendored
Normal file
552
third-party/BugTrap-1.3-57bd515/source/Array.h
vendored
Normal file
|
|
@ -0,0 +1,552 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009ß IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Simple dynamic array.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ColHelper.h"
|
||||
|
||||
/// Simple dynamic array.
|
||||
template
|
||||
<
|
||||
typename DATA_TYPE,
|
||||
class INSTANCE_TRAITS = CObjectTraits<DATA_TYPE>,
|
||||
class COMPARE_TRAITS = CCompareTraits<DATA_TYPE>
|
||||
>
|
||||
class CArray
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
/// Default array size.
|
||||
DEFAULT_SIZE = 10
|
||||
};
|
||||
|
||||
/// Initialize the object.
|
||||
explicit CArray(size_t nSize = DEFAULT_SIZE);
|
||||
/// Destroy the object.
|
||||
~CArray(void);
|
||||
/// Makes a copy of array.
|
||||
CArray(const CArray& rArray);
|
||||
/// Makes a copy of array.
|
||||
CArray& operator=(const CArray& rArray);
|
||||
/// Append another array.
|
||||
void Append(const CArray& rArray);
|
||||
/// Ensures that the array has enough space.
|
||||
void EnsureSize(size_t nSize, bool bAdaptiveGrowth = true);
|
||||
/// Set number of array item.
|
||||
void SetCount(size_t nCount);
|
||||
/// Get number of items in the array.
|
||||
size_t GetCount(void) const;
|
||||
/// Get buffer size (in elements).
|
||||
size_t GetSize(void) const;
|
||||
/// Add new item.
|
||||
DATA_TYPE& AddItem(void);
|
||||
/// Add new item.
|
||||
void AddItem(const DATA_TYPE& rItem);
|
||||
/// Insert an element at a specified index; grow the array if necessary.
|
||||
void InsertItem(size_t nItemPos, const DATA_TYPE& rItem);
|
||||
/// Insert an element at a specified index; grow the array if necessary.
|
||||
DATA_TYPE& InsertItem(size_t nItemPos);
|
||||
/// Insert an element according to the array sort order; grow the array if necessary.
|
||||
size_t InsertOrderedItem(const DATA_TYPE& rItem, bool bAscending = true, bool bAllowDuplicates = true);
|
||||
/// Delete the item.
|
||||
void DeleteItem(size_t nItemPos);
|
||||
/// Delete all items.
|
||||
void DeleteAll(bool bFree = false);
|
||||
/// Sets an element at a given position.
|
||||
void SetAt(size_t nItemPos, const DATA_TYPE& rItem);
|
||||
/// Returns element at a given position.
|
||||
const DATA_TYPE& GetAt(size_t nItemPos) const;
|
||||
/// Return true if array contains no elements.
|
||||
bool IsEmpty(void) const;
|
||||
/// Sort the contents of the array.
|
||||
void QSort(bool bAscending = true);
|
||||
/// Search elements in a sorted array for the specified data.
|
||||
size_t BSearch(const DATA_TYPE& rKey, bool bAscending = true) const;
|
||||
/// Search elements in an unsorted array for the specified data.
|
||||
size_t LSearch(const DATA_TYPE& rKey) const;
|
||||
/// Set or get the element.
|
||||
DATA_TYPE& operator[](size_t nItemPos);
|
||||
/// Get the element.
|
||||
const DATA_TYPE& operator[](size_t nItemPos) const;
|
||||
/// Get array buffer.
|
||||
operator DATA_TYPE*(void);
|
||||
/// Get array buffer.
|
||||
operator const DATA_TYPE*(void) const;
|
||||
|
||||
private:
|
||||
/// Validate item index.
|
||||
void ValidateIndex(size_t nItemPos) const;
|
||||
/// Compare two elements.
|
||||
typedef int (*TCompareFunc)(const DATA_TYPE& rData1, const DATA_TYPE& rData2);
|
||||
/// Compare two elements.
|
||||
static int CompareAsc(const DATA_TYPE& rData1, const DATA_TYPE& rData2);
|
||||
/// Compare two elements.
|
||||
static int CompareDesc(const DATA_TYPE& rData1, const DATA_TYPE& rData2);
|
||||
/// Sort the contents of the array.
|
||||
static void PrivQSort(DATA_TYPE* arrData, TCompareFunc pfnCompare, size_t nLowPos, size_t nHighPos);
|
||||
|
||||
/// Array data.
|
||||
DATA_TYPE* m_arrData;
|
||||
/// Number of items in the array.
|
||||
size_t m_nCount;
|
||||
/// Size of array.
|
||||
size_t m_nSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param nSize - the number of initially allocated elements.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::CArray(size_t nSize)
|
||||
{
|
||||
m_nSize = nSize;
|
||||
m_nCount = 0;
|
||||
if (nSize > 0)
|
||||
{
|
||||
m_arrData = (DATA_TYPE*)new BYTE[nSize * sizeof(DATA_TYPE)];
|
||||
if (m_arrData == NULL)
|
||||
{
|
||||
m_nSize = 0;
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_arrData = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rArray - object to be copied.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::CArray(const CArray& rArray)
|
||||
{
|
||||
m_nSize = m_nCount = rArray.m_nCount;
|
||||
if (m_nSize)
|
||||
{
|
||||
m_arrData = (DATA_TYPE*)new BYTE[m_nSize * sizeof(DATA_TYPE)];
|
||||
if (m_arrData == NULL)
|
||||
{
|
||||
m_nSize = m_nCount = 0;
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
for (size_t i = 0; i < m_nCount; ++i)
|
||||
{
|
||||
INSTANCE_TRAITS::Constructor(m_arrData[i]);
|
||||
INSTANCE_TRAITS::Assignment(m_arrData[i], rArray.m_arrData[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_arrData = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rArray - object to be copied.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>& CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::operator=(const CArray& rArray)
|
||||
{
|
||||
if (this != &rArray)
|
||||
{
|
||||
SetCount(rArray.m_nCount);
|
||||
for (size_t i = 0; i < m_nCount; ++i)
|
||||
INSTANCE_TRAITS::Assignment(m_arrData[i], rArray.m_arrData[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::~CArray(void)
|
||||
{
|
||||
DeleteAll(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rArray - another array.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::Append(const CArray& rArray)
|
||||
{
|
||||
size_t nTotalCount = m_nCount + rArray.m_nCount;
|
||||
EnsureSize(nTotalCount, false);
|
||||
for (size_t nSrcPos = 0, nDstPos = m_nCount; nDstPos < nTotalCount; ++nSrcPos, ++nDstPos)
|
||||
{
|
||||
INSTANCE_TRAITS::Constructor(m_arrData[nDstPos]);
|
||||
INSTANCE_TRAITS::Assignment(m_arrData[nDstPos], rArray.m_arrData[nSrcPos]);
|
||||
}
|
||||
m_nCount = nTotalCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSize - checked array size.
|
||||
* @param bAdaptiveGrowth - true for adaptive growth.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::EnsureSize(size_t nSize, bool bAdaptiveGrowth)
|
||||
{
|
||||
if (m_nSize < nSize)
|
||||
{
|
||||
if (bAdaptiveGrowth)
|
||||
{
|
||||
if (nSize <= 10)
|
||||
nSize = 10;
|
||||
else if (nSize <= 100)
|
||||
nSize += nSize;
|
||||
else
|
||||
nSize += nSize / 2;
|
||||
}
|
||||
DATA_TYPE* arrData = (DATA_TYPE*)new BYTE[nSize * sizeof(DATA_TYPE)];
|
||||
if (arrData == NULL)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
if (m_arrData)
|
||||
{
|
||||
CopyMemory(arrData, m_arrData, m_nCount * sizeof(DATA_TYPE));
|
||||
delete[] (PBYTE)m_arrData;
|
||||
}
|
||||
m_arrData = arrData;
|
||||
m_nSize = nSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nCount - the new array size (number of elements).
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::SetCount(size_t nCount)
|
||||
{
|
||||
EnsureSize(nCount, false);
|
||||
if (nCount < m_nCount)
|
||||
{
|
||||
for (size_t i = nCount; i < m_nCount; ++i)
|
||||
INSTANCE_TRAITS::Destructor(m_arrData[i]);
|
||||
}
|
||||
else if (nCount > m_nCount)
|
||||
{
|
||||
for (size_t i = m_nCount; i < nCount; ++i)
|
||||
INSTANCE_TRAITS::Constructor(m_arrData[i]);
|
||||
}
|
||||
m_nCount = nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rItem - the element to be added to this array.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::AddItem(const DATA_TYPE& rItem)
|
||||
{
|
||||
INSTANCE_TRAITS::Assignment(AddItem(), rItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - index of an element.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::ValidateIndex(size_t nItemPos) const
|
||||
{
|
||||
_ASSERTE(nItemPos < m_nCount);
|
||||
if (nItemPos >= m_nCount)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a reference to newly inserted element.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
DATA_TYPE& CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::AddItem(void)
|
||||
{
|
||||
EnsureSize(m_nCount + 1, true);
|
||||
INSTANCE_TRAITS::Constructor(m_arrData[m_nCount]);
|
||||
return m_arrData[m_nCount++];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - an integer index of deleted element.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::DeleteItem(size_t nItemPos)
|
||||
{
|
||||
ValidateIndex(nItemPos);
|
||||
INSTANCE_TRAITS::Destructor(m_arrData[nItemPos]);
|
||||
MoveMemory(m_arrData + nItemPos, m_arrData + nItemPos + 1, (--m_nCount - nItemPos) * sizeof(DATA_TYPE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bFree - pass true of release array memory.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::DeleteAll(bool bFree)
|
||||
{
|
||||
SetCount(0);
|
||||
if (bFree)
|
||||
{
|
||||
delete[] (PBYTE)m_arrData;
|
||||
m_arrData = NULL;
|
||||
m_nSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - an integer index of the insertion point.
|
||||
* @param rItem - the element to be placed in this array.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::InsertItem(size_t nItemPos, const DATA_TYPE& rItem)
|
||||
{
|
||||
INSTANCE_TRAITS::Assignment(InsertItem(nItemPos), rItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rItem - the element to be placed in this array.
|
||||
* @param bAscending - sort direction.
|
||||
* @param bAllowDuplicates - true if duplicates are allowed.
|
||||
* @return position of the inserted item.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline size_t CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::InsertOrderedItem(const DATA_TYPE& rItem, bool bAscending, bool bAllowDuplicates)
|
||||
{
|
||||
size_t nInsertPos = BSearch(rItem, bAscending);
|
||||
if (nInsertPos & ~MAXSSIZE_T)
|
||||
nInsertPos = ~nInsertPos;
|
||||
else if (! bAllowDuplicates)
|
||||
return nInsertPos;
|
||||
InsertItem(nInsertPos, rItem);
|
||||
return nInsertPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - an integer index of the insertion point.
|
||||
* @return a reference to newly inserted element.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
DATA_TYPE& CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::InsertItem(size_t nItemPos)
|
||||
{
|
||||
_ASSERTE(nItemPos <= m_nCount);
|
||||
if (nItemPos >= m_nCount + 1)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
size_t nSize = m_nCount + 1;
|
||||
if (m_nSize < nSize)
|
||||
{
|
||||
nSize += nSize / 2;
|
||||
DATA_TYPE* arrData = (DATA_TYPE*)new BYTE[nSize * sizeof(DATA_TYPE)];
|
||||
if (arrData == NULL)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
CopyMemory(arrData, m_arrData, nItemPos * sizeof(DATA_TYPE));
|
||||
CopyMemory(arrData + nItemPos + 1, m_arrData + nItemPos, (m_nCount - nItemPos) * sizeof(DATA_TYPE));
|
||||
delete[] (PBYTE)m_arrData;
|
||||
m_arrData = arrData;
|
||||
m_nSize = nSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveMemory(m_arrData + nItemPos + 1, m_arrData + nItemPos, (m_nCount - nItemPos) * sizeof(DATA_TYPE));
|
||||
}
|
||||
++m_nCount;
|
||||
INSTANCE_TRAITS::Constructor(m_arrData[nItemPos]);
|
||||
return m_arrData[nItemPos];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - the index of an element.
|
||||
* @return the reference of an element at the specified position.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline DATA_TYPE& CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::operator[](size_t nItemPos)
|
||||
{
|
||||
ValidateIndex(nItemPos);
|
||||
return m_arrData[nItemPos];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - the index of an element.
|
||||
* @return the constant reference of an element at the specified position.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline const DATA_TYPE& CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::operator[](size_t nItemPos) const
|
||||
{
|
||||
ValidateIndex(nItemPos);
|
||||
return m_arrData[nItemPos];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of elements in the array.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline size_t CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetCount(void) const
|
||||
{
|
||||
return m_nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return allocated size of the array.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline size_t CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetSize(void) const
|
||||
{
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to the address of the first element.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::operator DATA_TYPE*(void)
|
||||
{
|
||||
return m_arrData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to the address of the first element.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::operator const DATA_TYPE*(void) const
|
||||
{
|
||||
return m_arrData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the array contains no elements.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline bool CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::IsEmpty(void) const
|
||||
{
|
||||
return (m_nCount == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - position of the element.
|
||||
* @param rItem - new data value.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::SetAt(size_t nItemPos, const DATA_TYPE& rItem)
|
||||
{
|
||||
ValidateIndex(nItemPos);
|
||||
INSTANCE_TRAITS::Assignment(m_arrData[nItemPos], rItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nItemPos - position of the element.
|
||||
* @return element value.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline const DATA_TYPE& CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetAt(size_t nItemPos) const
|
||||
{
|
||||
ValidateIndex(nItemPos);
|
||||
return m_arrData[nItemPos];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData1 - pointer to the first compared element.
|
||||
* @param rData2 - pointer to the second compared element.
|
||||
* @return comparison result.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline int CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::CompareAsc(const DATA_TYPE& rData1, const DATA_TYPE& rData2)
|
||||
{
|
||||
return COMPARE_TRAITS::OrderedCompare(rData1, rData2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData1 - pointer to the first compared element.
|
||||
* @param rData2 - pointer to the second compared element.
|
||||
* @return comparison result.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline int CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::CompareDesc(const DATA_TYPE& rData1, const DATA_TYPE& rData2)
|
||||
{
|
||||
return COMPARE_TRAITS::OrderedCompare(rData2, rData1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bAscending - sort direction.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::QSort(bool bAscending)
|
||||
{
|
||||
TCompareFunc pfnCompare = bAscending ? &CompareAsc : &CompareDesc;
|
||||
PrivQSort(m_arrData, pfnCompare, 0, m_nCount - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param arrData - array data.
|
||||
* @param pfnCompare - pointer to comparison function.
|
||||
* @param nLowPos - leftmost array index.
|
||||
* @param nHighPos - rightmost array index.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::PrivQSort(DATA_TYPE* arrData, TCompareFunc pfnCompare, size_t nLowPos, size_t nHighPos)
|
||||
{
|
||||
if (nLowPos < nHighPos)
|
||||
{
|
||||
size_t nLeft = nLowPos;
|
||||
size_t nRight = nHighPos;
|
||||
DATA_TYPE& DataPivot = arrData[nLowPos];
|
||||
while (nLeft <= nRight)
|
||||
{
|
||||
while ((*pfnCompare)(DataPivot, arrData[nLeft]) > 0 && nLeft <= nRight)
|
||||
++nLeft;
|
||||
while ((*pfnCompare)(DataPivot, arrData[nRight]) < 0 && nLeft <= nRight)
|
||||
--nRight;
|
||||
if (nLeft > nRight)
|
||||
break;
|
||||
DATA_TYPE DataTemp;
|
||||
INSTANCE_TRAITS::Assignment(DataTemp, arrData[nLeft]);
|
||||
INSTANCE_TRAITS::Assignment(arrData[nLeft], arrData[nRight]);
|
||||
INSTANCE_TRAITS::Assignment(arrData[nRight], DataTemp);
|
||||
++nLeft;
|
||||
--nRight;
|
||||
}
|
||||
PrivQSort(arrData, pfnCompare, nLowPos, nRight);
|
||||
PrivQSort(arrData, pfnCompare, nLeft, nHighPos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - data to search for.
|
||||
* @param bAscending - sort direction.
|
||||
* @return element number where the data was found or negative index if no data found.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
size_t CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::BSearch(const DATA_TYPE& rKey, bool bAscending) const
|
||||
{
|
||||
TCompareFunc pfnCompare = bAscending ? &CompareAsc : &CompareDesc;
|
||||
size_t nLowPos = 0, nHighPos = 0, nMiddlePos = 0;
|
||||
while (nLowPos <= nHighPos)
|
||||
{
|
||||
nMiddlePos = (nLowPos + nHighPos) / 2;
|
||||
int nResult = (*pfnCompare)(m_arrData[nMiddlePos], rKey);
|
||||
if (nResult < 0)
|
||||
nLowPos = ++nMiddlePos;
|
||||
else if (nResult > 0)
|
||||
nHighPos = nMiddlePos - 1;
|
||||
else
|
||||
return nMiddlePos;
|
||||
}
|
||||
return ~nMiddlePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - data to search for.
|
||||
* @return element number where the data was found or -1 if no data found.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
size_t CArray<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::LSearch(const DATA_TYPE& rKey) const
|
||||
{
|
||||
for (size_t i = 0; i < m_nCount; ++i)
|
||||
{
|
||||
if (COMPARE_TRAITS::Compare(m_arrData[i], rKey))
|
||||
return i;
|
||||
}
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
47
third-party/BugTrap-1.3-57bd515/source/AssemblyInfo.cpp
vendored
Normal file
47
third-party/BugTrap-1.3-57bd515/source/AssemblyInfo.cpp
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
#pragma managed
|
||||
|
||||
using namespace System::Reflection;
|
||||
using namespace System::Runtime::CompilerServices;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("BugTrap dynamic link library")];
|
||||
[assembly: AssemblyDescription("BugTrap - software error reporting tool")];
|
||||
[assembly: AssemblyConfiguration("")];
|
||||
[assembly: AssemblyCompany("IntelleSoft")];
|
||||
[assembly: AssemblyProduct("BugTrap")];
|
||||
[assembly: AssemblyCopyright("Copyright © 2005-2009 IntelleSoft")];
|
||||
[assembly: AssemblyTrademark("")];
|
||||
[assembly: AssemblyCulture("")];
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)];
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("B3DB7206-529E-4000-B549-CA23E08A37F0")];
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.3.3718.38316")];
|
||||
[assembly: AssemblyFileVersion("1.3.3718.38316")];
|
||||
|
||||
using namespace System::Security::Permissions;
|
||||
|
||||
[assembly: SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];
|
||||
|
||||
#pragma unmanaged
|
||||
|
||||
#endif // _MANAGED
|
||||
359
third-party/BugTrap-1.3-57bd515/source/BTAtlWindow.h
vendored
Normal file
359
third-party/BugTrap-1.3-57bd515/source/BTAtlWindow.h
vendored
Normal file
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: This class provides better error handling for ATL/WTL windows.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#ifndef _BTATLWINDOW_H_
|
||||
#define _BTATLWINDOW_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _BUGTRAP_H_
|
||||
#error Include BugTrap.h first
|
||||
#endif // _BUGTRAP_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error C++ compiler is required
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifndef __ATLWIN_H__
|
||||
#error This class cannot be used in non ATL applications
|
||||
#endif // __ATLWIN_H__
|
||||
|
||||
namespace ATL
|
||||
{
|
||||
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
#define _BTWND_INITIALIZER_ : m_pfnFilter(&BT_SehFilter), m_pfnBaseWndProc(BASE_CLASS::GetWindowProc()), BASE_CLASS
|
||||
#else
|
||||
#define _BTWND_INITIALIZER_ : m_pfnBaseWndProc(BASE_CLASS::GetWindowProc()), BASE_CLASS
|
||||
#endif // _ATL_NO_EXCEPTIONS && ! _EXCEPTION_
|
||||
|
||||
/// This class adds error handling to ATL/WTL windows.
|
||||
/// Only one form of exception handling is permitted per function,
|
||||
/// therefore this class uses two functions to catch C++ and Windows errors.
|
||||
template <class BASE_CLASS>
|
||||
class BTWindow : public BASE_CLASS {
|
||||
protected:
|
||||
/// Object initialization (0 parameters).
|
||||
BTWindow(void) _BTWND_INITIALIZER_ () { }
|
||||
/// Object initialization (1 parameter).
|
||||
template <typename T1>
|
||||
explicit BTWindow(T1 param1) _BTWND_INITIALIZER_ (param1) { }
|
||||
/// Object initialization (2 parameters)
|
||||
template <typename T1, typename T2>
|
||||
BTWindow(T1 param1, T2 param2) _BTWND_INITIALIZER_ (param1, param2) { }
|
||||
/// Object initialization (3 parameters).
|
||||
template <typename T1, typename T2, typename T3>
|
||||
BTWindow(T1 param1, T2 param2, T3 param3) _BTWND_INITIALIZER_ (param1, param2, param3) { }
|
||||
/// Object initialization (4 parameters).
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
BTWindow(T1 param1, T2 param2, T3 param3, T4 param4) _BTWND_INITIALIZER_ (param1, param2, param3, param4) { }
|
||||
/// Object initialization (5 parameters).
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
BTWindow(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5) _BTWND_INITIALIZER_ (param1, param2, param3, param4, param5) { }
|
||||
/// This window procedure uses SEH to intercept all unhandled exceptions.
|
||||
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Overridden to return address of custom window procedure.
|
||||
virtual WNDPROC GetWindowProc(void);
|
||||
|
||||
private:
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
/// This window procedure intercepts C++ exceptions.
|
||||
LRESULT CppExceptionHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Exception filter.
|
||||
LONG (CALLBACK * m_pfnFilter)(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
#ifdef _M_X64
|
||||
/// This window procedure saves exception context.
|
||||
LRESULT SaveExceptionContext(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Exception context.
|
||||
EXCEPTION_POINTERS m_ExceptionPointers;
|
||||
#endif // _M_X64
|
||||
#endif // _ATL_NO_EXCEPTIONS && ! _EXCEPTION_
|
||||
/// Cached address of base window procedure.
|
||||
WNDPROC m_pfnBaseWndProc;
|
||||
};
|
||||
|
||||
#undef _BTWND_INITIALIZER_
|
||||
|
||||
/**
|
||||
* @return address of window procedure.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
inline WNDPROC BTWindow<BASE_CLASS>::GetWindowProc()
|
||||
{
|
||||
return &WindowProc;
|
||||
}
|
||||
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
#ifdef _M_X64
|
||||
/**
|
||||
* @param hWnd - window handle.
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
LRESULT BTWindow<BASE_CLASS>::SaveExceptionContext(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
__try {
|
||||
return (*m_pfnBaseWndProc)(hWnd, uMsg, wParam, lParam);
|
||||
} __except (CopyMemory(&m_ExceptionPointers, GetExceptionInformation(), sizeof(m_ExceptionPointers)), EXCEPTION_CONTINUE_SEARCH) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif // _M_X64
|
||||
|
||||
/**
|
||||
* @param hWnd - window handle.
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
LRESULT BTWindow<BASE_CLASS>::CppExceptionHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
try {
|
||||
#ifdef _M_X64
|
||||
return SaveExceptionContext(hWnd, uMsg, wParam, lParam);
|
||||
#else
|
||||
return (*m_pfnBaseWndProc)(hWnd, uMsg, wParam, lParam);
|
||||
#endif// ! _M_X64
|
||||
}
|
||||
#ifndef _ATL_NO_EXCEPTIONS
|
||||
catch (CAtlException& rException) {
|
||||
BT_SetUserMessageFromCode(rException.m_hr);
|
||||
// an exception will be caught by SEH handler
|
||||
throw;
|
||||
}
|
||||
#endif // _ATL_NO_EXCEPTIONS
|
||||
#ifdef _EXCEPTION_
|
||||
catch (std::exception& rException) {
|
||||
// extract error message
|
||||
const CHAR* pszErrorMessageA = rException.what();
|
||||
if (pszErrorMessageA != NULL && *pszErrorMessageA != '\0') {
|
||||
#ifdef _UNICODE
|
||||
DWORD dwErrorMessageSizeW = MultiByteToWideChar(CP_ACP, 0, pszErrorMessageA, -1, NULL, 0);
|
||||
// alloca() cannot be used in catch block
|
||||
WCHAR* pszErrorMessageW = (WCHAR*)malloc(dwErrorMessageSizeW * sizeof(WCHAR));
|
||||
if (pszErrorMessageW != NULL) {
|
||||
MultiByteToWideChar(CP_ACP, 0, pszErrorMessageA, -1, pszErrorMessageW, dwErrorMessageSizeW);
|
||||
BT_SetUserMessage(pszErrorMessageW);
|
||||
free(pszErrorMessageW);
|
||||
}
|
||||
#else
|
||||
BT_SetUserMessage(pszErrorMessageA);
|
||||
#endif // ! _UNICODE
|
||||
}
|
||||
m_pfnFilter = &BT_CppFilter;
|
||||
// an exception will be caught by SEH handler
|
||||
throw;
|
||||
}
|
||||
#endif // _EXCEPTION_
|
||||
}
|
||||
#endif // ! _ATL_NO_EXCEPTIONS || _EXCEPTION_
|
||||
|
||||
/**
|
||||
* @param hWnd - window handle.
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
LRESULT BTWindow<BASE_CLASS>::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
// This cast requires direct inheritance from CWindowImplBase, i.e.
|
||||
// CWindowImplBase descendant should be declared first in the list of base classes.
|
||||
// More generic solution would require additional template arguments.
|
||||
BTWindow* pThis = (BTWindow*)hWnd;
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
__try {
|
||||
return pThis->CppExceptionHandler(hWnd, uMsg, wParam, lParam);
|
||||
} __except ((*pThis->m_pfnFilter)(GetExceptionInformation())) {
|
||||
pThis->m_pfnFilter = &BT_SehFilter;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
__try {
|
||||
return (*pThis->m_pfnBaseWndProc)(hWnd, uMsg, wParam, lParam);
|
||||
} __except (BT_SehFilter(GetExceptionInformation())) {
|
||||
return 0;
|
||||
}
|
||||
#endif // _ATL_NO_EXCEPTIONS && ! _EXCEPTION_
|
||||
}
|
||||
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
#define _BTDLG_INITIALIZER_ : m_pfnFilter(&BT_SehFilter), m_pfnBaseDlgProc(BASE_CLASS::GetDialogProc()), BASE_CLASS
|
||||
#else
|
||||
#define _BTDLG_INITIALIZER_ : m_pfnBaseDlgProc(BASE_CLASS::GetDialogProc()), BASE_CLASS
|
||||
#endif // _ATL_NO_EXCEPTIONS && ! _EXCEPTION_
|
||||
|
||||
/// This class adds error handling to ATL/WTL dialogs.
|
||||
/// Only one form of exception handling is permitted per function,
|
||||
/// therefore this class uses two functions to catch C++ and Windows errors.
|
||||
template <class BASE_CLASS>
|
||||
class BTDialog : public BASE_CLASS {
|
||||
protected:
|
||||
/// Object initialization (0 parameters).
|
||||
BTDialog(void) _BTDLG_INITIALIZER_ () { }
|
||||
/// Object initialization (1 parameter).
|
||||
template <typename T1>
|
||||
explicit BTDialog(T1 param1) _BTDLG_INITIALIZER_ (param1) { }
|
||||
/// Object initialization (2 parameters)
|
||||
template <typename T1, typename T2>
|
||||
BTDialog(T1 param1, T2 param2) _BTDLG_INITIALIZER_ (param1, param2) { }
|
||||
/// Object initialization (3 parameters).
|
||||
template <typename T1, typename T2, typename T3>
|
||||
BTDialog(T1 param1, T2 param2, T3 param3) _BTDLG_INITIALIZER_ (param1, param2, param3) { }
|
||||
/// Object initialization (4 parameters).
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
BTDialog(T1 param1, T2 param2, T3 param3, T4 param4) _BTDLG_INITIALIZER_ (param1, param2, param3, param4) { }
|
||||
/// Object initialization (5 parameters).
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
BTDialog(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5) _BTDLG_INITIALIZER_ (param1, param2, param3, param4, param5) { }
|
||||
/// This dialog procedure uses SEH to intercept all unhandled exceptions.
|
||||
static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Overridden to return address of custom dialog procedure.
|
||||
virtual DLGPROC GetDialogProc(void);
|
||||
|
||||
private:
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
/// This dialog procedure intercepts C++ exceptions.
|
||||
INT_PTR CppExceptionHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Exception filter.
|
||||
LONG (CALLBACK * m_pfnFilter)(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
#ifdef _M_X64
|
||||
/// This window procedure saves exception context.
|
||||
INT_PTR SaveExceptionContext(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Exception context.
|
||||
EXCEPTION_POINTERS m_ExceptionPointers;
|
||||
#endif // _M_X64
|
||||
#endif // _ATL_NO_EXCEPTIONS && ! _EXCEPTION_
|
||||
/// Cached address of base dialog procedure.
|
||||
DLGPROC m_pfnBaseDlgProc;
|
||||
};
|
||||
|
||||
#undef _BTDLG_INITIALIZER_
|
||||
|
||||
/**
|
||||
* @return address of dialog procedure.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
inline DLGPROC BTDialog<BASE_CLASS>::GetDialogProc()
|
||||
{
|
||||
return &DialogProc;
|
||||
}
|
||||
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
#ifdef _M_X64
|
||||
/**
|
||||
* @param hWnd - window handle.
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
INT_PTR BTDialog<BASE_CLASS>::SaveExceptionContext(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
__try {
|
||||
return (*m_pfnBaseDlgProc)(hWnd, uMsg, wParam, lParam);
|
||||
} __except (CopyMemory(&m_ExceptionPointers, GetExceptionInformation(), sizeof(m_ExceptionPointers)), EXCEPTION_CONTINUE_SEARCH) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif // _M_X64
|
||||
|
||||
/**
|
||||
* @param hWnd - window handle.
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
INT_PTR BTDialog<BASE_CLASS>::CppExceptionHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
try {
|
||||
#ifdef _M_X64
|
||||
return SaveExceptionContext(hWnd, uMsg, wParam, lParam);
|
||||
#else
|
||||
return (*m_pfnBaseDlgProc)(hWnd, uMsg, wParam, lParam);
|
||||
#endif// ! _M_X64
|
||||
}
|
||||
#ifndef _ATL_NO_EXCEPTIONS
|
||||
catch (CAtlException& rException) {
|
||||
BT_SetUserMessageFromCode(rException.m_hr);
|
||||
// an exception will be caught by SEH handler
|
||||
throw;
|
||||
}
|
||||
#endif // _ATL_NO_EXCEPTIONS
|
||||
#ifdef _EXCEPTION_
|
||||
catch (std::exception& rException) {
|
||||
// extract error message
|
||||
const CHAR* pszErrorMessageA = rException.what();
|
||||
if (pszErrorMessageA != NULL && *pszErrorMessageA != '\0') {
|
||||
#ifdef _UNICODE
|
||||
DWORD dwErrorMessageSizeW = MultiByteToWideChar(CP_ACP, 0, pszErrorMessageA, -1, NULL, 0);
|
||||
// alloca() cannot be used in catch block
|
||||
WCHAR* pszErrorMessageW = (WCHAR*)malloc(dwErrorMessageSizeW * sizeof(WCHAR));
|
||||
if (pszErrorMessageW != NULL) {
|
||||
MultiByteToWideChar(CP_ACP, 0, pszErrorMessageA, -1, pszErrorMessageW, dwErrorMessageSizeW);
|
||||
BT_SetUserMessage(pszErrorMessageW);
|
||||
free(pszErrorMessageW);
|
||||
}
|
||||
#else
|
||||
BT_SetUserMessage(pszErrorMessageA);
|
||||
#endif // ! _UNICODE
|
||||
}
|
||||
m_pfnFilter = &BT_CppFilter;
|
||||
// an exception will be caught by SEH handler
|
||||
throw;
|
||||
}
|
||||
#endif // _EXCEPTION_
|
||||
}
|
||||
#endif // ! _ATL_NO_EXCEPTIONS || _EXCEPTION_
|
||||
|
||||
/**
|
||||
* @param hWnd - window handle.
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
INT_PTR BTDialog<BASE_CLASS>::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
// This cast requires direct inheritance from CDialogImplBase, i.e.
|
||||
// CDialogImplBase descendant should be declared first in the list of base classes.
|
||||
// More generic solution would require additional template arguments.
|
||||
BTDialog* pThis = (BTDialog*)hWnd;
|
||||
#if ! defined _ATL_NO_EXCEPTIONS || defined _EXCEPTION_
|
||||
__try {
|
||||
return pThis->CppExceptionHandler(hWnd, uMsg, wParam, lParam);
|
||||
} __except ((*pThis->m_pfnFilter)(GetExceptionInformation())) {
|
||||
pThis->m_pfnFilter = &BT_SehFilter;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
__try {
|
||||
return (*pThis->m_pfnBaseDlgProc)(hWnd, uMsg, wParam, lParam);
|
||||
} __except (BT_SehFilter(GetExceptionInformation())) {
|
||||
return 0;
|
||||
}
|
||||
#endif // _ATL_NO_EXCEPTIONS && ! _EXCEPTION_
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef BT_DO_NOT_USE_DEFAULT_NAMESPACES
|
||||
using namespace ATL;
|
||||
#endif // BT_DO_NOT_USE_DEFAULT_NAMESPACES
|
||||
|
||||
#endif // _BTATLWINDOW_H_
|
||||
171
third-party/BugTrap-1.3-57bd515/source/BTMfcWindow.h
vendored
Normal file
171
third-party/BugTrap-1.3-57bd515/source/BTMfcWindow.h
vendored
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: This class provides better error handling for MFC windows.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#ifndef _BTMFCWINDOW_H_
|
||||
#define _BTMFCWINDOW_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _BUGTRAP_H_
|
||||
#error Include BugTrap.h first
|
||||
#endif // _BUGTRAP_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error C++ compiler is required
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifndef __AFX_H__
|
||||
#error This class cannot be used in non MFC applications
|
||||
#endif // __AFX_H__
|
||||
|
||||
namespace MFC
|
||||
{
|
||||
|
||||
#define _BTWND_INITIALIZER_ : m_pfnFilter(&BT_SehFilter), BASE_CLASS
|
||||
|
||||
/// This class substitutes default MFC error handling.
|
||||
/// Only one form of exception handling is permitted per function,
|
||||
/// therefore this class uses two functions to catch C++ and Windows errors.
|
||||
template <class BASE_CLASS>
|
||||
class BTWindow : public BASE_CLASS {
|
||||
protected:
|
||||
/// Object initialization (0 parameters).
|
||||
BTWindow(void) _BTWND_INITIALIZER_ () { }
|
||||
/// Object initialization (1 parameter).
|
||||
template <typename T1>
|
||||
explicit BTWindow(T1 param1) _BTWND_INITIALIZER_ (param1) { }
|
||||
/// Object initialization (2 parameters)
|
||||
template <typename T1, typename T2>
|
||||
BTWindow(T1 param1, T2 param2) _BTWND_INITIALIZER_ (param1, param2) { }
|
||||
/// Object initialization (3 parameters).
|
||||
template <typename T1, typename T2, typename T3>
|
||||
BTWindow(T1 param1, T2 param2, T3 param3) _BTWND_INITIALIZER_ (param1, param2, param3) { }
|
||||
/// Object initialization (4 parameters).
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
BTWindow(T1 param1, T2 param2, T3 param3, T4 param4) _BTWND_INITIALIZER_ (param1, param2, param3, param4) { }
|
||||
/// Object initialization (5 parameters).
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
BTWindow(T1 param1, T2 param2, T3 param3, T4 param4, T5 param5) _BTWND_INITIALIZER_ (param1, param2, param3, param4, param5) { }
|
||||
/// This window procedure uses SEH to intercept all unhandled exceptions.
|
||||
virtual LRESULT WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
/// This window procedure intercepts MFC exceptions.
|
||||
LRESULT CppExceptionHandler(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Exception filter.
|
||||
LONG (CALLBACK * m_pfnFilter)(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
#ifdef _M_X64
|
||||
/// This window procedure saves exception context.
|
||||
LRESULT SaveExceptionContext(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Exception context.
|
||||
EXCEPTION_POINTERS m_ExceptionPointers;
|
||||
#endif // _M_X64
|
||||
};
|
||||
|
||||
#undef _BTWND_INITIALIZER_
|
||||
|
||||
#ifdef _M_X64
|
||||
/**
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
LRESULT BTWindow<BASE_CLASS>::SaveExceptionContext(UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
__try {
|
||||
return BASE_CLASS::WindowProc(uMsg, wParam, lParam);
|
||||
} __except (CopyMemory(&m_ExceptionPointers, GetExceptionInformation(), sizeof(m_ExceptionPointers)), EXCEPTION_CONTINUE_SEARCH) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif // _M_X64
|
||||
|
||||
/**
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
LRESULT BTWindow<BASE_CLASS>::CppExceptionHandler(UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
try {
|
||||
#ifdef _M_X64
|
||||
return SaveExceptionContext(uMsg, wParam, lParam);
|
||||
#else
|
||||
return BASE_CLASS::WindowProc(uMsg, wParam, lParam);
|
||||
#endif// ! _M_X64
|
||||
} catch (CException* pException) {
|
||||
ASSERT(pException->IsKindOf(RUNTIME_CLASS(CException)));
|
||||
// extract error message
|
||||
TCHAR szErrorMessage[512];
|
||||
if (pException->GetErrorMessage(szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR)))
|
||||
BT_SetUserMessage(szErrorMessage);
|
||||
pException->Delete();
|
||||
m_pfnFilter = &BT_CppFilter;
|
||||
// an exception will be caught by SEH handler
|
||||
throw;
|
||||
}
|
||||
#ifdef _EXCEPTION_
|
||||
catch (std::exception& rException) {
|
||||
// extract error message
|
||||
const CHAR* pszErrorMessageA = rException.what();
|
||||
if (pszErrorMessageA != NULL && *pszErrorMessageA != '\0') {
|
||||
#ifdef _UNICODE
|
||||
DWORD dwErrorMessageSizeW = MultiByteToWideChar(CP_ACP, 0, pszErrorMessageA, -1, NULL, 0);
|
||||
// alloca() cannot be used in catch block
|
||||
WCHAR* pszErrorMessageW = (WCHAR*)malloc(dwErrorMessageSizeW * sizeof(WCHAR));
|
||||
if (pszErrorMessageW != NULL) {
|
||||
MultiByteToWideChar(CP_ACP, 0, pszErrorMessageA, -1, pszErrorMessageW, dwErrorMessageSizeW);
|
||||
BT_SetUserMessage(pszErrorMessageW);
|
||||
free(pszErrorMessageW);
|
||||
}
|
||||
#else
|
||||
BT_SetUserMessage(pszErrorMessageA);
|
||||
#endif // ! _UNICODE
|
||||
}
|
||||
m_pfnFilter = &BT_CppFilter;
|
||||
// an exception will be caught by SEH handler
|
||||
throw;
|
||||
}
|
||||
#endif // _EXCEPTION_
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uMsg - specifies the Windows message to be processed.
|
||||
* @param wParam - provides additional information used in message processing.
|
||||
* @param lParam - provides additional information used in message processing.
|
||||
* @return the return value depends on the message.
|
||||
*/
|
||||
template <class BASE_CLASS>
|
||||
LRESULT BTWindow<BASE_CLASS>::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
__try {
|
||||
return CppExceptionHandler(uMsg, wParam, lParam);
|
||||
#ifdef _M_X64
|
||||
} __except ((*m_pfnFilter)(&m_ExceptionPointers)) {
|
||||
#else
|
||||
} __except ((*m_pfnFilter)(GetExceptionInformation())) {
|
||||
#endif// ! _M_X64
|
||||
m_pfnFilter = &BT_SehFilter;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef BT_DO_NOT_USE_DEFAULT_NAMESPACES
|
||||
using namespace MFC;
|
||||
#endif // BT_DO_NOT_USE_DEFAULT_NAMESPACES
|
||||
|
||||
#endif // _BTMFCWINDOW_H_
|
||||
250
third-party/BugTrap-1.3-57bd515/source/BTTrace.h
vendored
Normal file
250
third-party/BugTrap-1.3-57bd515/source/BTTrace.h
vendored
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: C++ wrapper for tracing functions.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#ifndef _BTTRACE_H_
|
||||
#define _BTTRACE_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _BUGTRAP_H_
|
||||
#error Include BugTrap.h first
|
||||
#endif // _BUGTRAP_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error C++ compiler is required
|
||||
#endif // __cplusplus
|
||||
|
||||
/// C++ wrapper for tracing API.
|
||||
class BTTrace {
|
||||
public:
|
||||
/// Initialize the object.
|
||||
BTTrace(void) {
|
||||
Detach();
|
||||
}
|
||||
|
||||
/// Initialize the object.
|
||||
BTTrace(INT_PTR iHandle) {
|
||||
m_eDefaultLogLevel = BTLL_INFO;
|
||||
m_iHandle = iHandle;
|
||||
}
|
||||
|
||||
/// Initialize the object.
|
||||
BTTrace(LPCTSTR pszLogFileName, BUGTRAP_LOGFORMAT eLogFormat) {
|
||||
m_eDefaultLogLevel = BTLL_INFO;
|
||||
m_iHandle = BT_OpenLogFile(pszLogFileName, eLogFormat);
|
||||
}
|
||||
|
||||
/// Destroy the object.
|
||||
~BTTrace(void) {
|
||||
Close();
|
||||
}
|
||||
|
||||
/// Open log file.
|
||||
INT_PTR Open(LPCTSTR pszLogFileName, BUGTRAP_LOGFORMAT eLogFormat) {
|
||||
Close();
|
||||
return (m_iHandle = BT_OpenLogFile(pszLogFileName, eLogFormat));
|
||||
}
|
||||
|
||||
/// Attach log file handle.
|
||||
void Attach(INT_PTR iHandle) {
|
||||
m_iHandle = iHandle;
|
||||
}
|
||||
|
||||
/// Detach log file handle.
|
||||
void Detach(void) {
|
||||
m_eDefaultLogLevel = BTLL_INFO;
|
||||
m_iHandle = NULL;
|
||||
}
|
||||
|
||||
/// Close log file.
|
||||
BOOL Close(void) {
|
||||
BOOL bResult;
|
||||
if (m_iHandle != NULL) {
|
||||
bResult = BT_CloseLogFile(m_iHandle);
|
||||
Detach();
|
||||
} else {
|
||||
bResult = FALSE;
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/// Get default log level.
|
||||
BUGTRAP_LOGLEVEL GetDefaultLogLevel(void) const {
|
||||
return m_eDefaultLogLevel;
|
||||
}
|
||||
|
||||
/// Set default log level.
|
||||
void SetDefaultLogLevel(BUGTRAP_LOGLEVEL eDefaultLogLevel) {
|
||||
m_eDefaultLogLevel = eDefaultLogLevel;
|
||||
}
|
||||
|
||||
/// Flush contents of the log file.
|
||||
BOOL Flush(void) const {
|
||||
return BT_FlushLogFile(m_iHandle);
|
||||
}
|
||||
|
||||
/// Get custom log file handle.
|
||||
INT_PTR GetHandle(void) const {
|
||||
return m_iHandle;
|
||||
}
|
||||
|
||||
/// Get custom log file name.
|
||||
LPCTSTR GetFileName(void) const {
|
||||
return BT_GetLogFileName(m_iHandle);
|
||||
}
|
||||
|
||||
/// Get custom log file size in records.
|
||||
DWORD GetLogSizeInEntries(void) const {
|
||||
return BT_GetLogSizeInEntries(m_iHandle);
|
||||
}
|
||||
|
||||
/// Set custom log file size in records.
|
||||
BOOL SetLogSizeInEntries(DWORD dwSize) const {
|
||||
return BT_SetLogSizeInEntries(m_iHandle, dwSize);
|
||||
}
|
||||
|
||||
/// Get custom log file size in bytes.
|
||||
DWORD GetLogSizeInBytes(void) const {
|
||||
return BT_GetLogSizeInBytes(m_iHandle);
|
||||
}
|
||||
|
||||
/// Set custom log file size in bytes.
|
||||
BOOL SetLogSizeInBytes(DWORD dwSize) const {
|
||||
return BT_SetLogSizeInBytes(m_iHandle, dwSize);
|
||||
}
|
||||
|
||||
/// Return current set of log flags.
|
||||
DWORD GetLogFlags(void) const {
|
||||
return BT_GetLogFlags(m_iHandle);
|
||||
}
|
||||
|
||||
/// Set new set of log flags.
|
||||
BOOL SetLogFlags(DWORD dwLogFlags) const {
|
||||
return BT_SetLogFlags(m_iHandle, dwLogFlags);
|
||||
}
|
||||
|
||||
/// Return minimal log level accepted by tracing functions.
|
||||
BUGTRAP_LOGLEVEL GetLogLevel(void) const {
|
||||
return BT_GetLogLevel(m_iHandle);
|
||||
}
|
||||
|
||||
/// Set minimal log level accepted by tracing functions.
|
||||
BOOL SetLogLevel(BUGTRAP_LOGLEVEL eLogLevel) const {
|
||||
return BT_SetLogLevel(m_iHandle, eLogLevel);
|
||||
}
|
||||
|
||||
/// Get log echo mode.
|
||||
DWORD GetLogEchoMode(void) const {
|
||||
return BT_GetLogEchoMode(m_iHandle);
|
||||
}
|
||||
|
||||
/// Set log echo mode.
|
||||
BOOL SetLogEchoMode(DWORD dwLogEchoMode) const {
|
||||
return BT_SetLogEchoMode(m_iHandle, dwLogEchoMode);
|
||||
}
|
||||
|
||||
/// Clear log file.
|
||||
BOOL Clear(void) const {
|
||||
return BT_ClearLog(m_iHandle);
|
||||
}
|
||||
|
||||
/// Insert entry into the beginning of custom log file.
|
||||
BOOL InsertF(BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, ...) const {
|
||||
va_list argList;
|
||||
va_start(argList, pszFormat);
|
||||
BOOL bResult = BT_InsLogEntryV(m_iHandle, eLogLevel, pszFormat, argList);
|
||||
va_end(argList);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/// Insert entry into the beginning of custom log file.
|
||||
BOOL InsertF(LPCTSTR pszFormat, ...) const {
|
||||
va_list argList;
|
||||
va_start(argList, pszFormat);
|
||||
BOOL bResult = BT_InsLogEntryV(m_iHandle, m_eDefaultLogLevel, pszFormat, argList);
|
||||
va_end(argList);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/// Insert entry into the beginning of custom log file.
|
||||
BOOL InsertV(BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, va_list argList) const {
|
||||
return BT_InsLogEntryV(m_iHandle, eLogLevel, pszFormat, argList);
|
||||
}
|
||||
|
||||
/// Insert entry into the beginning of custom log file.
|
||||
BOOL InsertV(LPCTSTR pszFormat, va_list argList) const {
|
||||
return BT_InsLogEntryV(m_iHandle, m_eDefaultLogLevel, pszFormat, argList);
|
||||
}
|
||||
|
||||
/// Insert entry into the beginning of custom log file.
|
||||
BOOL Insert(BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszEntry) const {
|
||||
return BT_InsLogEntry(m_iHandle, eLogLevel, pszEntry);
|
||||
}
|
||||
|
||||
/// Insert entry into the beginning of custom log file.
|
||||
BOOL Insert(LPCTSTR pszEntry) const {
|
||||
return BT_InsLogEntry(m_iHandle, m_eDefaultLogLevel, pszEntry);
|
||||
}
|
||||
|
||||
/// Append entry to the end of custom log file.
|
||||
BOOL AppendF(BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, ...) const {
|
||||
va_list argList;
|
||||
va_start(argList, pszFormat);
|
||||
BOOL bResult = BT_AppLogEntryV(m_iHandle, eLogLevel, pszFormat, argList);
|
||||
va_end(argList);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/// Append entry to the end of custom log file.
|
||||
BOOL AppendF(LPCTSTR pszFormat, ...) const {
|
||||
va_list argList;
|
||||
va_start(argList, pszFormat);
|
||||
BOOL bResult = BT_AppLogEntryV(m_iHandle, m_eDefaultLogLevel, pszFormat, argList);
|
||||
va_end(argList);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/// Append entry to the end of custom log file.
|
||||
BOOL AppendV(BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, va_list argList) const {
|
||||
return BT_AppLogEntryV(m_iHandle, eLogLevel, pszFormat, argList);
|
||||
}
|
||||
|
||||
/// Append entry to the end of custom log file.
|
||||
BOOL AppendV(LPCTSTR pszFormat, va_list argList) const {
|
||||
return BT_AppLogEntryV(m_iHandle, m_eDefaultLogLevel, pszFormat, argList);
|
||||
}
|
||||
|
||||
/// Append entry to the end of custom log file.
|
||||
BOOL Append(BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszEntry) const {
|
||||
return BT_AppLogEntry(m_iHandle, eLogLevel, pszEntry);
|
||||
}
|
||||
|
||||
/// Append entry to the end of custom log file.
|
||||
BOOL Append(LPCTSTR pszEntry) const {
|
||||
return BT_AppLogEntry(m_iHandle, m_eDefaultLogLevel, pszEntry);
|
||||
}
|
||||
|
||||
private:
|
||||
/// Prevent object from being accidentally copied.
|
||||
BTTrace(const BTTrace& rTrace);
|
||||
/// Prevent object from being accidentally copied.
|
||||
BTTrace& operator=(const BTTrace& rTrace);
|
||||
|
||||
/// Log file handle.
|
||||
INT_PTR m_iHandle;
|
||||
/// Default log level.
|
||||
BUGTRAP_LOGLEVEL m_eDefaultLogLevel;
|
||||
};
|
||||
|
||||
#endif // _BTTRACE_H_
|
||||
131
third-party/BugTrap-1.3-57bd515/source/BaseStream.h
vendored
Normal file
131
third-party/BugTrap-1.3-57bd515/source/BaseStream.h
vendored
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Base stream interface.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class CBaseStream
|
||||
{
|
||||
public:
|
||||
/// List of optional, but supported features.
|
||||
enum STREAM_FEATURES
|
||||
{
|
||||
/// Optional functions are not supported.
|
||||
SF_NONE = 0x00,
|
||||
/// IsOpen() is supported.
|
||||
SF_ISOPEN = 0x01,
|
||||
/// Close() is supported.
|
||||
SF_CLOSE = 0x02,
|
||||
/// GetName() is supported.
|
||||
SF_GETNAME = 0x04,
|
||||
/// GetLastError() is supported.
|
||||
SF_GETLASTERROR = 0x08,
|
||||
/// GetLength() is supported.
|
||||
SF_GETLENGTH = 0x10,
|
||||
/// SetLength() is supported.
|
||||
SF_SETLENGTH = 0x20,
|
||||
/// GetPosition() is supported.
|
||||
SF_GETPOSITION = 0x40,
|
||||
/// SetPosition() is supported.
|
||||
SF_SETPOSITION = 0x80
|
||||
};
|
||||
|
||||
/// Destroy the object.
|
||||
virtual ~CBaseStream(void);
|
||||
/// Get list of supported features. This function is required.
|
||||
virtual unsigned GetFeatures(void) const;
|
||||
/// Return true if stream is open.
|
||||
virtual bool IsOpen(void) const;
|
||||
/// Closes the stream. This function is optional.
|
||||
virtual void Close(void);
|
||||
/// Get stream name. This function is optional.
|
||||
virtual bool GetName(PTSTR pszName, size_t nNameSize) const;
|
||||
/// Get last IO error code. This function is optional.
|
||||
virtual long GetLastError(void) const;
|
||||
/// Return number of bytes in the stream. This function is optional.
|
||||
virtual size_t GetLength(void) const;
|
||||
/// Get current position. This function is optional.
|
||||
virtual size_t GetPosition(void) const;
|
||||
/// Set current position. This function is optional.
|
||||
virtual size_t SetPosition(ptrdiff_t nOffset, int nMoveMethod);
|
||||
};
|
||||
|
||||
inline CBaseStream::~CBaseStream(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if stream is open.
|
||||
*/
|
||||
inline bool CBaseStream::IsOpen(void) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bit mask of supported features.
|
||||
*/
|
||||
inline unsigned CBaseStream::GetFeatures(void) const
|
||||
{
|
||||
return SF_NONE;
|
||||
}
|
||||
|
||||
inline void CBaseStream::Close(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszName - stream name buffer.
|
||||
* @param nNameSize - size of stream name buffer.
|
||||
* @return true if name was retrieved.
|
||||
*/
|
||||
inline bool CBaseStream::GetName(PTSTR pszName, size_t nNameSize) const
|
||||
{
|
||||
if (nNameSize > 0)
|
||||
*pszName = _T('0');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of bytes in the stream.
|
||||
*/
|
||||
inline size_t CBaseStream::GetLength(void) const
|
||||
{
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current stream position.
|
||||
*/
|
||||
inline size_t CBaseStream::GetPosition(void) const
|
||||
{
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nOffset - offset from start point.
|
||||
* @param nMoveMethod - start point.
|
||||
* @return new position value.
|
||||
*/
|
||||
inline size_t CBaseStream::SetPosition(ptrdiff_t /*nOffset*/, int /*nMoveMethod*/)
|
||||
{
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return latest IO error code.
|
||||
*/
|
||||
inline long CBaseStream::GetLastError(void) const
|
||||
{
|
||||
return NOERROR;
|
||||
}
|
||||
255
third-party/BugTrap-1.3-57bd515/source/Buffer.h
vendored
Normal file
255
third-party/BugTrap-1.3-57bd515/source/Buffer.h
vendored
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Dynamic buffer.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Structure holds either dynamically allocated or static buffer.
|
||||
template <typename TYPE, DWORD dwStatBufferSize = 256>
|
||||
class CMixedBuffer
|
||||
{
|
||||
public:
|
||||
/// Initialize structure elements.
|
||||
CMixedBuffer(void);
|
||||
/// Deallocate dynamic buffer if necessary.
|
||||
~CMixedBuffer(void);
|
||||
/// Allocate dynamic buffer.
|
||||
BOOL SetSize(DWORD dwBufferSize);
|
||||
/// Get buffer data.
|
||||
TYPE* GetData(void);
|
||||
/// Get buffer data.
|
||||
const TYPE* GetData(void) const;
|
||||
/// Get buffer size.
|
||||
DWORD GetSize(void) const;
|
||||
|
||||
private:
|
||||
/// Protect object from being accidentally copied.
|
||||
CMixedBuffer(const CMixedBuffer& rBuffer);
|
||||
/// Protect object from being accidentally copied.
|
||||
CMixedBuffer& operator=(const CMixedBuffer& rBuffer);
|
||||
|
||||
/// Initialize static buffer.
|
||||
void InitStatBuffer(void);
|
||||
/// Static buffer.
|
||||
TYPE m_arrStatBuffer[dwStatBufferSize];
|
||||
/// Pointer to dynamic buffer.
|
||||
TYPE* m_pDynBuffer;
|
||||
/// Size of dynamic buffer.
|
||||
DWORD m_dwDynBufferSize;
|
||||
};
|
||||
|
||||
template <typename TYPE, DWORD dwStatBufferSize>
|
||||
inline CMixedBuffer<TYPE, dwStatBufferSize>::CMixedBuffer(void)
|
||||
{
|
||||
InitStatBuffer();
|
||||
}
|
||||
|
||||
template <typename TYPE, DWORD dwStatBufferSize>
|
||||
inline CMixedBuffer<TYPE, dwStatBufferSize>::~CMixedBuffer(void)
|
||||
{
|
||||
delete[] m_pDynBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to buffer data.
|
||||
*/
|
||||
template <typename TYPE, DWORD dwStatBufferSize>
|
||||
inline TYPE* CMixedBuffer<TYPE, dwStatBufferSize>::GetData(void)
|
||||
{
|
||||
return (m_pDynBuffer != NULL ? m_pDynBuffer : m_arrStatBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to buffer data.
|
||||
*/
|
||||
template <typename TYPE, DWORD dwStatBufferSize>
|
||||
inline const TYPE* CMixedBuffer<TYPE, dwStatBufferSize>::GetData(void) const
|
||||
{
|
||||
return (m_pDynBuffer != NULL ? m_pDynBuffer : m_arrStatBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return buffer size.
|
||||
*/
|
||||
template <typename TYPE, DWORD dwStatBufferSize>
|
||||
inline DWORD CMixedBuffer<TYPE, dwStatBufferSize>::GetSize(void) const
|
||||
{
|
||||
return (m_pDynBuffer != NULL ? m_dwDynBufferSize : countof(m_arrStatBuffer));
|
||||
}
|
||||
|
||||
template <typename TYPE, DWORD dwStatBufferSize>
|
||||
inline void CMixedBuffer<TYPE, dwStatBufferSize>::InitStatBuffer(void)
|
||||
{
|
||||
m_pDynBuffer = NULL;
|
||||
m_dwDynBufferSize = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwBufferSize - allocate size of buffer.
|
||||
* @return true if dynamic buffer was successfully allocated.
|
||||
*/
|
||||
template <typename TYPE, DWORD dwStatBufferSize>
|
||||
BOOL CMixedBuffer<TYPE, dwStatBufferSize>::SetSize(DWORD dwBufferSize)
|
||||
{
|
||||
if (dwBufferSize == 0)
|
||||
{
|
||||
delete[] m_pDynBuffer;
|
||||
InitStatBuffer();
|
||||
return TRUE;
|
||||
}
|
||||
if (m_pDynBuffer != NULL)
|
||||
{
|
||||
if (m_dwDynBufferSize >= dwBufferSize)
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (countof(m_arrStatBuffer) >= dwBufferSize)
|
||||
return TRUE;
|
||||
}
|
||||
TYPE* pDynBuffer = new TYPE[dwBufferSize];
|
||||
if (pDynBuffer == NULL)
|
||||
return FALSE;
|
||||
delete[] m_pDynBuffer;
|
||||
m_pDynBuffer = pDynBuffer;
|
||||
m_dwDynBufferSize = dwBufferSize;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/// Dynamically allocated buffer.
|
||||
template <typename TYPE>
|
||||
class CDynamicBuffer
|
||||
{
|
||||
public:
|
||||
/// Initialize structure elements.
|
||||
CDynamicBuffer(void);
|
||||
/// Initialize structure elements.
|
||||
CDynamicBuffer(DWORD dwBufferSize);
|
||||
/// Deallocate dynamic buffer if necessary.
|
||||
~CDynamicBuffer(void);
|
||||
/// Allocate dynamic buffer.
|
||||
BOOL SetSize(DWORD dwBufferSize);
|
||||
/// Get buffer data.
|
||||
TYPE* GetData(void);
|
||||
/// Get buffer data.
|
||||
const TYPE* GetData(void) const;
|
||||
/// Get buffer size.
|
||||
DWORD GetSize(void) const;
|
||||
|
||||
private:
|
||||
/// Protect object from being accidentally copied.
|
||||
CDynamicBuffer(const CDynamicBuffer& rBuffer);
|
||||
/// Protect object from being accidentally copied.
|
||||
CDynamicBuffer& operator=(const CDynamicBuffer& rBuffer);
|
||||
/// Allocate buffer.
|
||||
BOOL AllocBuffer(DWORD dwBufferSize);
|
||||
/// Initialize empty buffer.
|
||||
void InitBuffer(void);
|
||||
/// Free buffer.
|
||||
void FreeBuffer(void);
|
||||
|
||||
/// Pointer to dynamic buffer.
|
||||
TYPE* m_pBuffer;
|
||||
/// Size of dynamic buffer.
|
||||
DWORD m_dwBufferSize;
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
void CDynamicBuffer<TYPE>::InitBuffer(void)
|
||||
{
|
||||
m_pBuffer = NULL;
|
||||
m_dwBufferSize = 0;
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
void CDynamicBuffer<TYPE>::FreeBuffer(void)
|
||||
{
|
||||
delete[] m_pBuffer;
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
BOOL CDynamicBuffer<TYPE>::AllocBuffer(DWORD dwBufferSize)
|
||||
{
|
||||
TYPE* pBuffer = new TYPE[dwBufferSize];
|
||||
if (pBuffer == NULL)
|
||||
return FALSE;
|
||||
delete[] m_pBuffer;
|
||||
m_pBuffer = pBuffer;
|
||||
m_dwBufferSize = dwBufferSize;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
inline CDynamicBuffer<TYPE>::CDynamicBuffer(void)
|
||||
{
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
inline CDynamicBuffer<TYPE>::CDynamicBuffer(DWORD dwBufferSize)
|
||||
{
|
||||
InitBuffer();
|
||||
if (dwBufferSize > 0)
|
||||
AllocBuffer(dwBufferSize);
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
inline CDynamicBuffer<TYPE>::~CDynamicBuffer(void)
|
||||
{
|
||||
delete[] m_pBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to buffer data.
|
||||
*/
|
||||
template <typename TYPE>
|
||||
inline TYPE* CDynamicBuffer<TYPE>::GetData(void)
|
||||
{
|
||||
return m_pBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to buffer data.
|
||||
*/
|
||||
template <typename TYPE>
|
||||
inline const TYPE* CDynamicBuffer<TYPE>::GetData(void) const
|
||||
{
|
||||
return m_pBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return buffer size.
|
||||
*/
|
||||
template <typename TYPE>
|
||||
inline DWORD CDynamicBuffer<TYPE>::GetSize(void) const
|
||||
{
|
||||
return m_dwBufferSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwBufferSize - size of dynamic buffer.
|
||||
* @return true if dynamic buffer was successfully allocated.
|
||||
*/
|
||||
template <typename TYPE>
|
||||
BOOL CDynamicBuffer<TYPE>::SetSize(DWORD dwBufferSize)
|
||||
{
|
||||
if (dwBufferSize == 0)
|
||||
{
|
||||
FreeBuffer();
|
||||
return TRUE;
|
||||
}
|
||||
if (m_dwBufferSize >= dwBufferSize)
|
||||
return TRUE;
|
||||
return AllocBuffer(dwBufferSize);
|
||||
}
|
||||
50
third-party/BugTrap-1.3-57bd515/source/BugTrap.8.sln
vendored
Normal file
50
third-party/BugTrap-1.3-57bd515/source/BugTrap.8.sln
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BugTrap", "BugTrap.2005.vcproj", "{E8CF1ADA-264A-4127-86C2-FD7057D3792C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
.NET Debug|Win32 = .NET Debug|Win32
|
||||
.NET Debug|x64 = .NET Debug|x64
|
||||
.NET Release|Win32 = .NET Release|Win32
|
||||
.NET Release|x64 = .NET Release|x64
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
Unicode Debug|Win32 = Unicode Debug|Win32
|
||||
Unicode Debug|x64 = Unicode Debug|x64
|
||||
Unicode Release|Win32 = Unicode Release|Win32
|
||||
Unicode Release|x64 = Unicode Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|Win32.ActiveCfg = .NET Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|Win32.Build.0 = .NET Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|x64.ActiveCfg = .NET Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|x64.Build.0 = .NET Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|Win32.ActiveCfg = .NET Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|Win32.Build.0 = .NET Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|x64.ActiveCfg = .NET Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|x64.Build.0 = .NET Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|x64.Build.0 = Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|Win32.Build.0 = Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|x64.ActiveCfg = Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|x64.Build.0 = Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|x64.ActiveCfg = Unicode Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|x64.Build.0 = Unicode Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|Win32.ActiveCfg = Unicode Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|Win32.Build.0 = Unicode Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|x64.ActiveCfg = Unicode Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|x64.Build.0 = Unicode Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
1858
third-party/BugTrap-1.3-57bd515/source/BugTrap.8.vcproj
vendored
Normal file
1858
third-party/BugTrap-1.3-57bd515/source/BugTrap.8.vcproj
vendored
Normal file
File diff suppressed because it is too large
Load diff
240
third-party/BugTrap-1.3-57bd515/source/BugTrap.cfg
vendored
Normal file
240
third-party/BugTrap-1.3-57bd515/source/BugTrap.cfg
vendored
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
# Doxyfile 1.4.4
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = BugTrap
|
||||
PROJECT_NUMBER = 1.0
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = YES
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = NO
|
||||
INLINE_INFO = NO
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = YES
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = NO
|
||||
GENERATE_TESTLIST = NO
|
||||
GENERATE_BUGLIST = NO
|
||||
GENERATE_DEPRECATEDLIST= NO
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = NO
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE = mkdoc.log
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = BTTrace.h \
|
||||
BugTrap.h \
|
||||
BTAtlWindow.h \
|
||||
BTMfcWindow.h
|
||||
FILE_PATTERNS =
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 2
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = HTML
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = YES
|
||||
CHM_FILE = BugTrap.chm
|
||||
HHC_LOCATION = "C:\Program Files\HTML Help Workshop\hhc.exe"
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 200
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT =
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT =
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT =
|
||||
MAN_EXTENSION =
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
SEARCH_INCLUDES = NO
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = __cplusplus \
|
||||
_BTWND_INITIALIZER_() \
|
||||
_BTDLG_INITIALIZER_() \
|
||||
__AFX_H__ \
|
||||
__ATLWIN_H__ \
|
||||
_EXCEPTION_
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = NO
|
||||
PERL_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
2240
third-party/BugTrap-1.3-57bd515/source/BugTrap.cpp
vendored
Normal file
2240
third-party/BugTrap-1.3-57bd515/source/BugTrap.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
104
third-party/BugTrap-1.3-57bd515/source/BugTrap.def
vendored
Normal file
104
third-party/BugTrap-1.3-57bd515/source/BugTrap.def
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
; Override names for external functions
|
||||
EXPORTS
|
||||
|
||||
; Application title management
|
||||
BT_GetAppName
|
||||
BT_SetAppName
|
||||
BT_GetAppVersion
|
||||
BT_SetAppVersion
|
||||
BT_ReadVersionInfo
|
||||
|
||||
; User interface customization.
|
||||
BT_GetDialogMessage
|
||||
BT_SetDialogMessage
|
||||
|
||||
; Support URL management
|
||||
BT_GetSupportURL
|
||||
BT_SetSupportURL
|
||||
BT_GetSupportEMail
|
||||
BT_SetSupportEMail
|
||||
|
||||
; Server configuration
|
||||
BT_GetSupportHost
|
||||
BT_SetSupportHost
|
||||
BT_GetSupportPort
|
||||
BT_SetSupportPort
|
||||
BT_SetSupportServer
|
||||
BT_GetNotificationEMail
|
||||
BT_SetNotificationEMail
|
||||
|
||||
; Report customization
|
||||
BT_GetFlags
|
||||
BT_SetFlags
|
||||
BT_GetDumpType
|
||||
BT_SetDumpType
|
||||
BT_GetReportFormat
|
||||
BT_SetReportFormat
|
||||
BT_GetUserMessage
|
||||
BT_SetUserMessage
|
||||
BT_SetUserMessageFromCode
|
||||
|
||||
; Silent mode configuration
|
||||
BT_GetActivityType
|
||||
BT_SetActivityType
|
||||
BT_GetExitMode
|
||||
BT_SetExitMode
|
||||
BT_GetReportFilePath
|
||||
BT_SetReportFilePath
|
||||
BT_GetMailProfile
|
||||
BT_SetMailProfile
|
||||
|
||||
; Custom log files management
|
||||
BT_ExportRegistryKey
|
||||
BT_AddLogFile
|
||||
BT_AddRegFile
|
||||
BT_DeleteLogFile
|
||||
BT_ClearLogFiles
|
||||
BT_GetLogFilesCount
|
||||
BT_GetLogFileEntry
|
||||
|
||||
; Custom error handlers
|
||||
BT_GetPreErrHandler
|
||||
BT_SetPreErrHandler
|
||||
BT_GetPostErrHandler
|
||||
BT_SetPostErrHandler
|
||||
|
||||
; Tracing functions
|
||||
BT_OpenLogFile
|
||||
BT_CloseLogFile
|
||||
BT_FlushLogFile
|
||||
BT_GetLogFileName
|
||||
BT_GetLogSizeInBytes
|
||||
BT_SetLogSizeInBytes
|
||||
BT_GetLogSizeInEntries
|
||||
BT_SetLogSizeInEntries
|
||||
BT_GetLogFlags
|
||||
BT_SetLogFlags
|
||||
BT_GetLogLevel
|
||||
BT_SetLogLevel
|
||||
BT_GetLogEchoMode
|
||||
BT_SetLogEchoMode
|
||||
BT_ClearLog
|
||||
BT_InsLogEntryF
|
||||
BT_AppLogEntryF
|
||||
BT_InsLogEntryV
|
||||
BT_AppLogEntryV
|
||||
BT_InsLogEntry
|
||||
BT_AppLogEntry
|
||||
|
||||
; Internal functions
|
||||
BT_InstallSehFilter
|
||||
BT_UninstallSehFilter
|
||||
BT_InterceptSUEF
|
||||
BT_SaveSnapshot
|
||||
BT_SaveSnapshotEx
|
||||
BT_SendSnapshot
|
||||
BT_SendSnapshotEx
|
||||
BT_MailSnapshot
|
||||
BT_MailSnapshotEx
|
||||
BT_SehFilter
|
||||
BT_CallSehFilter
|
||||
BT_CppFilter
|
||||
BT_CallCppFilter
|
||||
BT_NetFilter
|
||||
BT_CallNetFilter
|
||||
839
third-party/BugTrap-1.3-57bd515/source/BugTrap.h
vendored
Normal file
839
third-party/BugTrap-1.3-57bd515/source/BugTrap.h
vendored
Normal file
|
|
@ -0,0 +1,839 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Definitions of external functions.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#ifndef _BUGTRAP_H_
|
||||
#define _BUGTRAP_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined _MANAGED && ! defined _UNICODE
|
||||
#error Managed version of BugTrap requires Unicode character set
|
||||
#endif // _MANAGED && ! _UNICODE
|
||||
|
||||
/*
|
||||
* The following ifdef block is the standard way of creating macros which make exporting
|
||||
* from a DLL simpler. All files within this DLL are compiled with the BUGTRAP_EXPORTS
|
||||
* symbol defined on the command line. this symbol should not be defined on any project
|
||||
* that uses this DLL. This way any other project whose source files include this file see
|
||||
* BUGTRAP_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
* defined with this macro as being exported.
|
||||
*/
|
||||
#ifdef BUGTRAP_EXPORTS
|
||||
#define BUGTRAP_API __declspec(dllexport)
|
||||
#else
|
||||
#define BUGTRAP_API __declspec(dllimport)
|
||||
#endif // ! BUGTRAP_EXPORTS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
* @defgroup TypeDef Common type definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Type of action which is performed in response to the error.
|
||||
*/
|
||||
typedef enum BUGTRAP_ACTIVITY_tag
|
||||
{
|
||||
/**
|
||||
* @brief Display BugTrap dialog to allow user selecting desirable
|
||||
* option. This is the default option.
|
||||
*/
|
||||
BTA_SHOWUI = 1,
|
||||
/**
|
||||
* @brief Automatically save error report to file.
|
||||
* Use BT_SetReportFilePath() to specify report path.
|
||||
*/
|
||||
BTA_SAVEREPORT = 2,
|
||||
/**
|
||||
* @brief Automatically send error report by e-mail.
|
||||
*/
|
||||
BTA_MAILREPORT = 3,
|
||||
/**
|
||||
* @brief Automatically send bug report to support server.
|
||||
*/
|
||||
BTA_SENDREPORT = 4
|
||||
}
|
||||
BUGTRAP_ACTIVITY;
|
||||
|
||||
/**
|
||||
* @brief Different BugTrap options. You can use any combinations
|
||||
* of these flags.
|
||||
*/
|
||||
typedef enum BUGTRAP_FLAGS_tag
|
||||
{
|
||||
/**
|
||||
* @brief Equivalent of no options.
|
||||
*/
|
||||
BTF_NONE = 0x000,
|
||||
/**
|
||||
* @brief In detailed mode BugTrap generates mini-dump and
|
||||
* packs custom log files within the report.
|
||||
*/
|
||||
BTF_DETAILEDMODE = 0x001,
|
||||
/**
|
||||
* @brief BugTrap may open its own editor for e-mail messages
|
||||
* instead of the editor used by the system. Use this
|
||||
* option if you aren't aware of the type of e-mail
|
||||
* client installed on user computers.
|
||||
*/
|
||||
BTF_EDITMAIL = 0x002,
|
||||
/**
|
||||
* @brief Specify this option to attach bug report to e-mail
|
||||
* messages. Be careful with this option. It's potentially
|
||||
* dangerous for the detailed mode because of even zipped
|
||||
* mini-dump may require huge size. It may exceed the
|
||||
* maximum size of e-mail message supported by Internet
|
||||
* provider.
|
||||
*/
|
||||
BTF_ATTACHREPORT = 0x004,
|
||||
/**
|
||||
* @brief Set this flag to add list of all processes and loaded
|
||||
* modules to the report. Disable this option to speedup report
|
||||
* generation.
|
||||
*/
|
||||
BTF_LISTPROCESSES = 0x008,
|
||||
/**
|
||||
* @brief By default BugTrap displays simplified dialog on the
|
||||
* screen allowing user to perform only common actions. Enable
|
||||
* this flag to immediately display dialog with advanced error
|
||||
* information.
|
||||
*/
|
||||
BTF_SHOWADVANCEDUI = 0x010,
|
||||
/**
|
||||
* @brief Bug report in detailed error mode may also include a
|
||||
* screen shot automatically captured by BugTrap. By default this
|
||||
* option is disabled to minimize report size, but it may be useful
|
||||
* if you want to know which dialogs were shown on the screen.
|
||||
*/
|
||||
BTF_SCREENCAPTURE = 0x020,
|
||||
#ifdef _MANAGED
|
||||
/**
|
||||
* @brief Generate native stack trace and modules information along
|
||||
* with managed exception information. Disable this option to speedup
|
||||
* report generation.
|
||||
*/
|
||||
BTF_NATIVEINFO = 0x040,
|
||||
#endif // _MANAGED
|
||||
/**
|
||||
* @brief When enabled, BugTrap injects fake SetUnhandledExceptionFilter()
|
||||
* to handle the most severe C runtime errors. Usually such errors
|
||||
* are not being reported to custom unhandled exception filters. This
|
||||
* flag vanishes any attempts of C runtime library to override
|
||||
* unhandled exception filter defined in BugTrap. This option should
|
||||
* be used with caution, because such technique may be incompatible
|
||||
* with future Windows versions.
|
||||
*/
|
||||
BTF_INTERCEPTSUEF = 0x080,
|
||||
/**
|
||||
* @brief When report is being sent over TCP/HTTP protocol, BugTrap could
|
||||
* ask user to provide verbal description of the problem if this option is
|
||||
* enabled. BugTrap always prompts user to describe error for reports
|
||||
* transmitted over email regardless this option.
|
||||
*/
|
||||
BTF_DESCRIBEERROR = 0x100,
|
||||
/**
|
||||
* @brief Automatically restart the application after the crash has been
|
||||
* handled.
|
||||
*/
|
||||
BTF_RESTARTAPP = 0x200
|
||||
}
|
||||
BUGTRAP_FLAGS;
|
||||
|
||||
/**
|
||||
* @brief These flags control application termination mode:
|
||||
* whatever the application needs to be terminated after error handling,
|
||||
* control should passed to another exception handler.
|
||||
*/
|
||||
typedef enum BUGTRAP_EXITMODE_tag
|
||||
{
|
||||
/**
|
||||
* @brief BugTrap executes desirable action (usually displays the dialog).
|
||||
* The application is being terminated when user closes the dialog. This is default action.
|
||||
*/
|
||||
BTEM_TERMINATEAPP,
|
||||
/**
|
||||
* @brief BugTrap executes desirable action and continues to search up the stack for a handler.
|
||||
*/
|
||||
BTEM_CONTINUESEARCH,
|
||||
/**
|
||||
* @brief BugTrap executes desirable action and transfers control to the exception handlers.
|
||||
*/
|
||||
BTEM_EXECUTEHANDLER
|
||||
}
|
||||
BUGTRAP_EXITMODE;
|
||||
|
||||
/**
|
||||
* @brief Set of available log levels.
|
||||
*/
|
||||
typedef enum BUGTRAP_LOGLEVEL_tag
|
||||
{
|
||||
/**
|
||||
* @brief All message levels are prohibited.
|
||||
*/
|
||||
BTLL_NONE = 0,
|
||||
/**
|
||||
* @brief Error message.
|
||||
*/
|
||||
BTLL_ERROR = 1,
|
||||
/**
|
||||
* @brief Waning message.
|
||||
*/
|
||||
BTLL_WARNING = 2,
|
||||
/**
|
||||
* @brief Important information message.
|
||||
*/
|
||||
BTLL_IMPORTANT = 3,
|
||||
/**
|
||||
* @brief Regular information message.
|
||||
*/
|
||||
BTLL_INFO = 4,
|
||||
/**
|
||||
* @brief Verbose information message.
|
||||
*/
|
||||
BTLL_VERBOSE = 5,
|
||||
/**
|
||||
* @brief All levels of messages are accepted.
|
||||
*/
|
||||
BTLL_ALL = BTLL_INFO
|
||||
}
|
||||
BUGTRAP_LOGLEVEL;
|
||||
|
||||
/**
|
||||
* @brief Type of log echo mode.
|
||||
*/
|
||||
typedef enum BUGTRAP_LOGECHOTYPE_tag
|
||||
{
|
||||
/**
|
||||
* @brief Do not duplicate log output to file.
|
||||
*/
|
||||
BTLE_NONE = 0x00,
|
||||
/**
|
||||
* @brief Send a copy of log output to STDOUT (mutually exclusive with STDERR mode).
|
||||
*/
|
||||
BTLE_STDOUT = 0x01,
|
||||
/**
|
||||
* @brief Send a copy of log output to STDERR (mutually exclusive with STDOUT mode).
|
||||
*/
|
||||
BTLE_STDERR = 0x02,
|
||||
/**
|
||||
* @brief Send a copy of log output to the debugger (can accompany STDOUT or STDERR mode).
|
||||
*/
|
||||
BTLE_DBGOUT = 0x04
|
||||
}
|
||||
BUGTRAP_LOGECHOTYPE;
|
||||
|
||||
/**
|
||||
* @brief Set of log file options.
|
||||
*/
|
||||
typedef enum BUGTRAP_LOGFLAGS_tag
|
||||
{
|
||||
/**
|
||||
* @brief Do not show any additional entries in the log.
|
||||
*/
|
||||
BTLF_NONE = 0x00,
|
||||
/**
|
||||
* @brief Use this option if you want to store message levels in a file.
|
||||
*/
|
||||
BTLF_SHOWLOGLEVEL = 0x01,
|
||||
/**
|
||||
* @brief Use this option if you want to store message timestamps in a file.
|
||||
* Timestamps are stored in universal (locale independent) format: YYYY/MM/DD HH:MM:SS
|
||||
*/
|
||||
BTLF_SHOWTIMESTAMP = 0x02
|
||||
}
|
||||
BUGTRAP_LOGFLAGS;
|
||||
|
||||
/**
|
||||
* @brief Format of error report.
|
||||
*/
|
||||
typedef enum BUGTRAP_REPORTFORMAT_tag
|
||||
{
|
||||
/**
|
||||
* @brief Report stored in structured XML format.
|
||||
*/
|
||||
BTRF_XML = 1,
|
||||
/**
|
||||
* @brief Report stored in plain text format.
|
||||
*/
|
||||
BTRF_TEXT = 2
|
||||
}
|
||||
BUGTRAP_REPORTFORMAT;
|
||||
|
||||
/**
|
||||
* @brief Format of log file.
|
||||
*/
|
||||
typedef enum BUGTRAP_LOGFORMAT_tag
|
||||
{
|
||||
/**
|
||||
* @brief Log stored in structured XML format.
|
||||
* Log data is entirely stored in memory until application exists or crashes.
|
||||
* It is designed for fast IO and it cannot handle large logs.
|
||||
*/
|
||||
BTLF_XML = 1,
|
||||
/**
|
||||
* @brief Log stored in plain text format.
|
||||
* Log data is entirely stored in memory until application exists or crashes.
|
||||
* It is designed for fast IO and it cannot handle large logs.
|
||||
*/
|
||||
BTLF_TEXT = 2,
|
||||
/**
|
||||
* @brief Log stored in plain text format.
|
||||
* Unlike @a BTLF_XML and @a BTLF_TEXT log data is not cached in memory.
|
||||
* This type of log is optimized for large logs.
|
||||
*/
|
||||
BTLF_STREAM = 3
|
||||
}
|
||||
BUGTRAP_LOGFORMAT;
|
||||
|
||||
/**
|
||||
* @brief Type of user defined message displayed on the screen.
|
||||
*/
|
||||
typedef enum BUGTRAP_DIALOGMESSAGE_tag
|
||||
{
|
||||
/**
|
||||
* @brief 1st line of introduction message.
|
||||
*/
|
||||
BTDM_INTRO1 = 1,
|
||||
/**
|
||||
* @brief A bunch of lines of introduction message.
|
||||
*/
|
||||
BTDM_INTRO2 = 2
|
||||
}
|
||||
BUGTRAP_DIALOGMESSAGE;
|
||||
|
||||
/**
|
||||
* @brief Type of log file attached to the report.
|
||||
*/
|
||||
typedef enum BUGTRAP_LOGTYPE_tag
|
||||
{
|
||||
/**
|
||||
* @brief Regular log file maintained by the user.
|
||||
*/
|
||||
BTLT_LOGFILE,
|
||||
/**
|
||||
* @brief Log file that's exported from the registry.
|
||||
*/
|
||||
BTLT_REGEXPORT
|
||||
}
|
||||
BUGTRAP_LOGTYPE;
|
||||
|
||||
/**
|
||||
* @brief Log file entry structure return by BT_GetLogFileEntry() for regular log files.
|
||||
*/
|
||||
typedef struct BUGTRAP_LOGFILEENTRY_tag
|
||||
{
|
||||
/**
|
||||
* @brief Log file name.
|
||||
*/
|
||||
TCHAR szLogFileName[MAX_PATH];
|
||||
}
|
||||
BUGTRAP_LOGFILEENTRY;
|
||||
|
||||
/**
|
||||
* @brief Log file entry structure return by BT_GetLogFileEntry() for log files exported from the registry.
|
||||
*/
|
||||
typedef struct BUGTRAP_REGEXPORTENTRY_tag
|
||||
{
|
||||
/**
|
||||
* @brief Log file name.
|
||||
*/
|
||||
TCHAR szLogFileName[MAX_PATH];
|
||||
/**
|
||||
* @brief Exported registry key.
|
||||
*/
|
||||
TCHAR szRegKey[MAX_PATH];
|
||||
}
|
||||
BUGTRAP_REGEXPORTENTRY;
|
||||
|
||||
/**
|
||||
* @brief Type definition of user-defined error handler that's called before and after main BugTrap dialog.
|
||||
*/
|
||||
typedef void (CALLBACK * BT_ErrHandler)(INT_PTR nErrHandlerParam);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup AppTitle Application title management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get application name.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetAppName(void);
|
||||
/**
|
||||
* @brief Set application name of the project where BugTrap is used.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetAppName(LPCTSTR pszAppName);
|
||||
/**
|
||||
* @brief Get application version number.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetAppVersion(void);
|
||||
/**
|
||||
* @brief Set application version number.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetAppVersion(LPCTSTR pszAppVersion);
|
||||
/**
|
||||
* @brief Read application name and version number from version info block.
|
||||
* @note @a hModule can be set to NULL for the main executable.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_ReadVersionInfo(HMODULE hModule);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup UserInterface User interface customization.
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Get user defined message displayed on the screen.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetDialogMessage(BUGTRAP_DIALOGMESSAGE eDialogMessage);
|
||||
/**
|
||||
* @brief Set user defined message displayed on the screen.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetDialogMessage(BUGTRAP_DIALOGMESSAGE eDialogMessage, LPCTSTR pszMessage);
|
||||
/** @} */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup SupportURL Support URL management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get HTTP address of product support site.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetSupportURL(void);
|
||||
/**
|
||||
* @brief Set HTTP address of product support site.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetSupportURL(LPCTSTR pszSupportURL);
|
||||
/**
|
||||
* @brief Get product support e-mail address.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetSupportEMail(void);
|
||||
/**
|
||||
* @brief Set product support e-mail address.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetSupportEMail(LPCTSTR pszSupportEMail);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup SrvConfig Server configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Use this port for HTTP protocol.
|
||||
#define BUGTRAP_HTTP_PORT 80
|
||||
|
||||
/**
|
||||
* @brief Get host name of BugTrap Server. This server can automatically
|
||||
* gather bug reports for the application.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetSupportHost(void);
|
||||
/**
|
||||
* @brief Set host name (address) of BugTrap Server. This server
|
||||
* can automatically gather bug reports for the application.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetSupportHost(LPCTSTR pszSupportHost);
|
||||
/**
|
||||
* @brief Get port number of BugTrap Server. This server can automatically
|
||||
* gather bug reports for the application.
|
||||
*/
|
||||
BUGTRAP_API SHORT APIENTRY BT_GetSupportPort(void);
|
||||
/**
|
||||
* @brief Set port number of BugTrap Server. This server
|
||||
* can automatically gather bug reports for the application.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetSupportPort(SHORT nSupportPort);
|
||||
/**
|
||||
* @brief Set host name (address) and port number of BugTrap Server. This server
|
||||
* can automatically gather bug reports for the application.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetSupportServer(LPCTSTR pszSupportHost, SHORT nSupportPort);
|
||||
/**
|
||||
* @brief Get error notification e-mail address.
|
||||
* BugTrap Server may automatically notify product support by e-mail about new bug reports.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetNotificationEMail(void);
|
||||
/**
|
||||
* @brief Set error notification e-mail address.
|
||||
* BugTrap Server may automatically notify product support by e-mail about new bug reports.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetNotificationEMail(LPCTSTR pszNotificationEMail);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup CustomReport Report customization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Disables mini-dump generation in detailed mode.
|
||||
#define MiniDumpNoDump MAXDWORD
|
||||
|
||||
/**
|
||||
* @brief Get current BugTrap options.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetFlags(void);
|
||||
/**
|
||||
* @brief Set various BugTrap options.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetFlags(DWORD dwFlags);
|
||||
/**
|
||||
* @brief Get the type of produced mini-dump in detailed mode.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetDumpType(void);
|
||||
/**
|
||||
* @brief Set the type of produced mini-dump in detailed mode.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetDumpType(DWORD dwDumpType);
|
||||
/**
|
||||
* @brief Get format of error report.
|
||||
*/
|
||||
BUGTRAP_API BUGTRAP_REPORTFORMAT APIENTRY BT_GetReportFormat(void);
|
||||
/**
|
||||
* @brief Set format of error report.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetReportFormat(BUGTRAP_REPORTFORMAT eReportFormat);
|
||||
/**
|
||||
* @brief Get user defined message. This message may be printed to a log file.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetUserMessage(void);
|
||||
/**
|
||||
* @brief Set user defined message. This message may be printed to a log file.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetUserMessage(LPCTSTR pszUserMessage);
|
||||
/**
|
||||
* @brief Set user defined message. This message may be printed to a log file.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetUserMessageFromCode(DWORD dwErrorCode);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup SilentFunc Silent mode configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get the type of action which is performed in response to the error.
|
||||
*/
|
||||
BUGTRAP_API BUGTRAP_ACTIVITY APIENTRY BT_GetActivityType(void);
|
||||
/**
|
||||
* @brief Set the type of action which is performed in response to the error.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetActivityType(BUGTRAP_ACTIVITY eActivityType);
|
||||
/**
|
||||
* @brief Get application termination mode.
|
||||
*/
|
||||
BUGTRAP_API BUGTRAP_EXITMODE APIENTRY BT_GetExitMode(void);
|
||||
/**
|
||||
* @brief Set application termination mode.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetExitMode(BUGTRAP_EXITMODE eExitMode);
|
||||
/**
|
||||
* @brief Get the path of error report.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetReportFilePath(void);
|
||||
/**
|
||||
* @brief Set the path of error report.
|
||||
* This function has effect only for @a BTA_SAVEREPORT activity.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetReportFilePath(LPCTSTR pszReportFilePath);
|
||||
/**
|
||||
* @brief Get the name of MAPI profile.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetMailProfile(void);
|
||||
/**
|
||||
* @brief Set the name and password of MAPI profile.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetMailProfile(LPCTSTR pszMailProfile, LPCTSTR pszMailPassword);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup LogFiles Custom log files management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Export registry key to the file.
|
||||
*/
|
||||
BUGTRAP_API int APIENTRY BT_ExportRegistryKey(LPCTSTR pszRegFile, LPCTSTR pszRegKey);
|
||||
/**
|
||||
* @brief Add custom log entry to the list of custom log files
|
||||
* attached to bug report.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_AddLogFile(LPCTSTR pszLogFile);
|
||||
/**
|
||||
* @brief Add custom log entry to the list of custom log files
|
||||
* attached to bug report.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_AddRegFile(LPCTSTR pszRegFile, LPCTSTR pszRegKey);
|
||||
/**
|
||||
* @brief Delete custom log entry from the list of custom log files
|
||||
* attached to bug report.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_DeleteLogFile(LPCTSTR pszLogFile);
|
||||
/**
|
||||
* @brief Clear the list of custom log files attached to bug report.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_ClearLogFiles(void);
|
||||
/**
|
||||
* @brief Get number of log files attached to the report.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetLogFilesCount(void);
|
||||
/**
|
||||
* @brief This function enumerates log file entries that will be attached to the report.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetLogFileEntry(INT_PTR nLogFileIndexOrName, BOOL bGetByIndex, BUGTRAP_LOGTYPE* peLogType, PDWORD pdwLogEntrySize, PVOID pLogEntry);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup CustomErrHandlers Custom error handlers
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get address of error handler called before BugTrap dialog.
|
||||
*/
|
||||
BUGTRAP_API BT_ErrHandler APIENTRY BT_GetPreErrHandler(void);
|
||||
/**
|
||||
* @brief Set address of error handler called before BugTrap dialog.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetPreErrHandler(BT_ErrHandler pfnPreErrHandler, INT_PTR nPreErrHandlerParam);
|
||||
/**
|
||||
* @brief Get address of error handler called after BugTrap dialog.
|
||||
*/
|
||||
BUGTRAP_API BT_ErrHandler APIENTRY BT_GetPostErrHandler(void);
|
||||
/**
|
||||
* @brief Set address of error handler called after BugTrap dialog.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_SetPostErrHandler(BT_ErrHandler pfnPostErrHandler, INT_PTR nPostErrHandlerParam);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup TracingFunc Tracing functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Open custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API INT_PTR APIENTRY BT_OpenLogFile(LPCTSTR pszLogFileName, BUGTRAP_LOGFORMAT eLogFormat);
|
||||
/**
|
||||
* @brief Close custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_CloseLogFile(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Flush contents of the log file.
|
||||
* @note This function is optional and not required in normal conditions.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_FlushLogFile(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Get custom log file name. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API LPCTSTR APIENTRY BT_GetLogFileName(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Get maximum log file size in records. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetLogSizeInEntries(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Set maximum log file size in records. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SetLogSizeInEntries(INT_PTR iHandle, DWORD dwLogSizeInEntries);
|
||||
/**
|
||||
* @brief Get maximum log file size in bytes. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetLogSizeInBytes(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Set maximum log file size in bytes. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SetLogSizeInBytes(INT_PTR iHandle, DWORD dwLogSizeInEntries);
|
||||
/**
|
||||
* @brief Return true if time stamp is added to every log entry.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetLogFlags(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Set true if time stamp is added to every log entry.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SetLogFlags(INT_PTR iHandle, DWORD dwLogFlags);
|
||||
/**
|
||||
* @brief Return minimal log level accepted by tracing functions.
|
||||
*/
|
||||
BUGTRAP_API BUGTRAP_LOGLEVEL APIENTRY BT_GetLogLevel(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Set minimal log level accepted by tracing functions.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SetLogLevel(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel);
|
||||
/**
|
||||
* @brief Get echo mode.
|
||||
*/
|
||||
BUGTRAP_API DWORD APIENTRY BT_GetLogEchoMode(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Set echo mode.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SetLogEchoMode(INT_PTR iHandle, DWORD dwLogEchoMode);
|
||||
/**
|
||||
* @brief Clear log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_ClearLog(INT_PTR iHandle);
|
||||
/**
|
||||
* @brief Insert entry into the beginning of custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL CDECL BT_InsLogEntryF(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, ...);
|
||||
/**
|
||||
* @brief Append entry to the end of custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL CDECL BT_AppLogEntryF(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, ...);
|
||||
/**
|
||||
* @brief Insert entry into the beginning of custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_InsLogEntryV(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, va_list argList);
|
||||
/**
|
||||
* @brief Append entry to the end of custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_AppLogEntryV(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszFormat, va_list argList);
|
||||
/**
|
||||
* @brief Insert entry into the beginning of custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_InsLogEntry(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszEntry);
|
||||
/**
|
||||
* @brief Append entry to the end of custom log file. This function is thread safe.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_AppLogEntry(INT_PTR iHandle, BUGTRAP_LOGLEVEL eLogLevel, LPCTSTR pszEntry);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup InternalFunc Internal functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Explicitly installs BugTrap exception filter.
|
||||
* @note Normally you should not call this function.
|
||||
*/
|
||||
BUGTRAP_API LPTOP_LEVEL_EXCEPTION_FILTER APIENTRY BT_InstallSehFilter(void);
|
||||
/**
|
||||
* Explicitly uninstalls BugTrap exception filter and restores the previous exception filter.
|
||||
* @note Normally you should not call this function.
|
||||
*/
|
||||
BUGTRAP_API void APIENTRY BT_UninstallSehFilter(void);
|
||||
/**
|
||||
* @brief Explicitly intercepts SetUnhandledExceptionFilter() in a module.
|
||||
* This function could be useful for dynamically loaded modules.
|
||||
*/
|
||||
BUGTRAP_API void BT_InterceptSUEF(HMODULE hModule, BOOL bOverride);
|
||||
/**
|
||||
* @brief Take a snapshot of program memory and save it to a file.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SaveSnapshot(PCTSTR pszFileName);
|
||||
/**
|
||||
* @brief Take a snapshot of program memory and save it to a file.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SaveSnapshotEx(PEXCEPTION_POINTERS pExceptionPointers, PCTSTR pszFileName);
|
||||
/**
|
||||
* @brief Take a snapshot of program memory and send over network.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SendSnapshot(void);
|
||||
/**
|
||||
* @brief Take a snapshot of program memory and send over network.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_SendSnapshotEx(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
/**
|
||||
* @brief Take a snapshot of program memory and e-mail it.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_MailSnapshot(void);
|
||||
/**
|
||||
* @brief Take a snapshot of program memory and e-mail it.
|
||||
*/
|
||||
BUGTRAP_API BOOL APIENTRY BT_MailSnapshotEx(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
/**
|
||||
* @brief Executes structured exception filter.
|
||||
* @note Don't call this function directly in your code.
|
||||
*/
|
||||
BUGTRAP_API LONG CALLBACK BT_SehFilter(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
/**
|
||||
* @brief Simulates access violation in C++ application. Used by set_terminate().
|
||||
* @note Don't call this function directly in your code.
|
||||
*/
|
||||
BUGTRAP_API void CDECL BT_CallSehFilter(void);
|
||||
/**
|
||||
* @brief Executes C++ exception filter.
|
||||
* @note Don't call this function directly in your code.
|
||||
*/
|
||||
BUGTRAP_API LONG CALLBACK BT_CppFilter(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
/**
|
||||
* @brief Simulates access violation in C++ application. Used by set_terminate().
|
||||
* @note Don't call this function directly in your code.
|
||||
*/
|
||||
BUGTRAP_API void CDECL BT_CallCppFilter(void);
|
||||
|
||||
#ifdef _MANAGED
|
||||
/**
|
||||
* @brief Executes .NET exception filter.
|
||||
* @note Don't call this function directly in your code.
|
||||
*/
|
||||
BUGTRAP_API LONG CALLBACK BT_NetFilter(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
/**
|
||||
* @brief Simulates access violation in .NET application. Used by set_terminate().
|
||||
* @note Don't call this function directly in your code.
|
||||
*/
|
||||
BUGTRAP_API void CDECL BT_CallNetFilter(void);
|
||||
#endif // _MANAGED
|
||||
|
||||
/**
|
||||
* Installs BugTrap handler to be called by the runtime in response to
|
||||
* unhandled C++ exception.
|
||||
*/
|
||||
#if defined __cplusplus && defined _INC_EH
|
||||
#define BT_SetTerminate() set_terminate(BT_CallCppFilter)
|
||||
#else
|
||||
#define BT_SetTerminate()
|
||||
#endif // __cplusplus && _INC_EH
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "BTTrace.h"
|
||||
|
||||
#if defined __ATLWIN_H__ && defined __AFX_H__
|
||||
#define BT_DO_NOT_USE_DEFAULT_NAMESPACES
|
||||
#endif // __ATLWIN_H__ && __AFX_H__
|
||||
|
||||
#ifdef __ATLWIN_H__
|
||||
#include "BTAtlWindow.h"
|
||||
#endif // __ATLWIN_H__
|
||||
|
||||
#ifdef __AFX_H__
|
||||
#include "BTMfcWindow.h"
|
||||
#endif // __AFX_H__
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _BUGTRAP_H_
|
||||
922
third-party/BugTrap-1.3-57bd515/source/BugTrap.rc
vendored
Normal file
922
third-party/BugTrap-1.3-57bd515/source/BugTrap.rc
vendored
Normal file
|
|
@ -0,0 +1,922 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Neutral resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_BUG ICON "res\\Bug.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
IDB_CHECKMARK BITMAP "res\\Checkmark.bmp"
|
||||
IDB_SORTARROWS BITMAP "res\\SortArrows.bmp"
|
||||
IDB_IMAGETOOLBAR BITMAP "res\\ImageToolbar.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AVI
|
||||
//
|
||||
|
||||
IDR_UPLOAD_ANIMATION AVI "res\\Upload.avi"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_TRANSFERPROGRESS_DLG DIALOGEX 0, 0, 198, 86
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP
|
||||
EXSTYLE WS_EX_CONTROLPARENT
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_TRANSFERPROGRESS_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 191
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 79
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Neutral resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// German (Neutral) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUT_BUGTRAP_DLG DIALOGEX 0, 0, 242, 76
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Über BugTrap"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
ICON IDI_BUG,IDC_STATIC,7,7,20,20,WS_GROUP
|
||||
LTEXT "BugTrap - softwarefehler berichterstattung\nVersion 1.3",IDC_VERSION_STRING,34,7,146,16
|
||||
LTEXT "Copyright © 2005-2009 IntelleSoft",IDC_STATIC,7,32,113,8
|
||||
LTEXT "http://www.intellesoft.net",IDC_URL,7,42,72,10,WS_TABSTOP
|
||||
LTEXT " GUI design basierend auf Jim Crafton's BlackBox library",IDC_PORTIONS_COPYRIGHT,7,59,228,10,SS_NOPREFIX | SS_SUNKEN
|
||||
DEFPUSHBUTTON "Schließen",IDCANCEL,195,7,40,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_MACHINE_INFO_DLG DIALOGEX 0, 0, 340, 260
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Computerdaten"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Betriebssystem",IDC_STATIC,7,7,269,43,WS_GROUP
|
||||
EDITTEXT IDC_OS_TEXT,12,16,259,30,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "CPU",IDC_STATIC,7,50,269,52,WS_GROUP
|
||||
EDITTEXT IDC_CPU_TEXT,12,58,259,40,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Speicher",IDC_STATIC,7,103,269,62,WS_GROUP
|
||||
EDITTEXT IDC_MEM_TEXT,12,112,259,48,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Umgebungsvariablen",IDC_STATIC,7,165,269,88,WS_GROUP
|
||||
EDITTEXT IDC_ENVIRONMENT,12,174,259,75,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL | NOT WS_TABSTOP,WS_EX_STATICEDGE
|
||||
DEFPUSHBUTTON "Schließen",IDCANCEL,283,10,50,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_MACHINE_STATE_DLG DIALOGEX 0, 0, 322, 222
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Computerstatus"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Laufende Prozesse beim Absturz",IDC_PROCESS_LIST_FRAME,7,7,250,97,WS_GROUP,WS_EX_TRANSPARENT
|
||||
CONTROL "",IDC_PROCESS_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,12,17,239,80
|
||||
GROUPBOX "Vom Gewählten Prozess Geladene Module",IDC_PROCESS_MODULES_LIST_FRAME,7,107,250,108,WS_GROUP,WS_EX_TRANSPARENT
|
||||
CONTROL "",IDC_PROCESS_MODULES_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,12,117,239,92
|
||||
DEFPUSHBUTTON "Schließen",IDCANCEL,264,11,51,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_WAIT_DLG DIALOGEX 0, 0, 83, 26
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP
|
||||
EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW
|
||||
FONT 10, "MS Shell Dlg", 400, 0, 0xCC
|
||||
BEGIN
|
||||
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,1,1,81,17
|
||||
LTEXT "Bitte Warten...",IDC_STATIC,18,5,48,8
|
||||
CONTROL "",IDC_PROGRESS_BAR,"Static",SS_GRAYRECT | WS_GROUP | WS_TABSTOP,1,19,81,7,WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
IDD_SEND_MAIL_DLG DIALOGEX 0, 0, 316, 196
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "EMail senden"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
LTEXT "&Empfänger:",IDC_STATIC,7,8,38,8
|
||||
EDITTEXT IDC_RECIPIENT,63,7,246,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE
|
||||
LTEXT "&Anhang:",IDC_STATIC,7,24,28,8
|
||||
EDITTEXT IDC_ATTACHMENT,63,23,246,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE
|
||||
LTEXT "&Betreff:",IDC_STATIC,7,41,26,8
|
||||
EDITTEXT IDC_SUBJECT,63,39,246,14,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_BODY,7,57,302,109,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
|
||||
DEFPUSHBUTTON "Senden",IDOK,203,175,50,14,WS_GROUP
|
||||
PUSHBUTTON "Schließen",IDCANCEL,259,175,50,14
|
||||
END
|
||||
|
||||
IDD_SIMPLE_DLG DIALOGEX 0, 0, 330, 94
|
||||
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "BugTrap"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "",IDC_INTRO_BKGND,0,0,330,53,SS_NOPREFIX
|
||||
CONTROL 112,IDC_DIALOG_ICON,"Static",SS_BITMAP | WS_GROUP,7,7,15,13
|
||||
LTEXT "BugTrap hat einen absturz festgestellt",IDC_INTRO1,35,7,288,8
|
||||
LTEXT "Um den entwicklungsprozess zu unterstützen wird dieses programm alle nötigen informationen über den absturz sammeln. Diese daten können dann an den produktsupport übertragen, oder gespeichert werden.",IDC_INTRO2,35,19,288,26,SS_NOPREFIX
|
||||
CONTROL "",-1,"Static",SS_ETCHEDHORZ | WS_GROUP,0,52,330,1
|
||||
LTEXT "Produktsupport:",IDC_URL_PREFIX,7,59,71,8
|
||||
LTEXT "",IDC_URL,78,59,245,10,WS_TABSTOP
|
||||
DEFPUSHBUTTON "Info senden",IDC_SUBMIT_BUG,7,73,52,14,WS_GROUP
|
||||
LTEXT "email an...",IDC_MAILTO,78,75,35,8,NOT WS_GROUP | WS_TABSTOP
|
||||
PUSHBUTTON "Erweitert...",IDC_MORE,208,73,52,14
|
||||
PUSHBUTTON "Schließen",IDCANCEL,271,73,52,14
|
||||
END
|
||||
|
||||
IDD_TRANSFERPROGRESS_PANE DIALOGEX 0, 0, 184, 72
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_UPLOAD_ANIMATION,"SysAnimate32",ACS_TRANSPARENT | WS_GROUP,7,7,62,17
|
||||
CONTROL "",IDC_CONNECTINGTOSERVER_CMARK,"Static",SS_BITMAP | NOT WS_VISIBLE | WS_GROUP,80,9,15,13
|
||||
LTEXT "Verbindung herstellen...",IDC_CONNECTINGTOSERVER_LBL,90,7,78,8
|
||||
CONTROL "",IDC_SENDINGREPORT_CMARK,"Static",SS_BITMAP | NOT WS_VISIBLE | WS_GROUP,80,22,15,13
|
||||
LTEXT "Report senden...",IDC_SENDINGREPORT_LBL,90,20,56,8
|
||||
CONTROL "",IDC_CHECKINGERRORSTATUS_CMARK,"Static",SS_BITMAP | NOT WS_VISIBLE | WS_GROUP,80,35,15,13
|
||||
LTEXT "Fehlerstatus prüfen...",IDC_CHECKINGERRORSTATUS_LBL,90,33,72,8
|
||||
DEFPUSHBUTTON "Abbrechen",IDCANCEL,127,51,50,14
|
||||
END
|
||||
|
||||
IDD_TRANSFERSTATUS_PANE DIALOGEX 0, 0, 184, 72
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
ICON "",IDC_STATUSICON,10,13,20,20,NOT WS_VISIBLE | WS_GROUP
|
||||
LTEXT "",IDC_STATUSMESSAGE,40,7,137,36,NOT WS_VISIBLE
|
||||
DEFPUSHBUTTON "Schließen",IDCANCEL,127,51,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ABOUT_BUGTRAP_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 235
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 69
|
||||
HORZGUIDE, 59
|
||||
HORZGUIDE, 69
|
||||
END
|
||||
|
||||
IDD_MACHINE_INFO_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 333
|
||||
VERTGUIDE, 12
|
||||
VERTGUIDE, 271
|
||||
VERTGUIDE, 276
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 253
|
||||
END
|
||||
|
||||
IDD_MACHINE_STATE_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 315
|
||||
VERTGUIDE, 12
|
||||
VERTGUIDE, 251
|
||||
VERTGUIDE, 257
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 215
|
||||
HORZGUIDE, 17
|
||||
HORZGUIDE, 97
|
||||
HORZGUIDE, 117
|
||||
HORZGUIDE, 209
|
||||
END
|
||||
|
||||
IDD_WAIT_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 3
|
||||
RIGHTMARGIN, 80
|
||||
TOPMARGIN, 3
|
||||
BOTTOMMARGIN, 23
|
||||
END
|
||||
|
||||
IDD_SEND_MAIL_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 309
|
||||
VERTGUIDE, 63
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 189
|
||||
HORZGUIDE, 23
|
||||
HORZGUIDE, 39
|
||||
HORZGUIDE, 166
|
||||
END
|
||||
|
||||
IDD_SIMPLE_DLG, DIALOG
|
||||
BEGIN
|
||||
VERTGUIDE, 7
|
||||
VERTGUIDE, 35
|
||||
VERTGUIDE, 78
|
||||
VERTGUIDE, 260
|
||||
VERTGUIDE, 323
|
||||
BOTTOMMARGIN, 87
|
||||
HORZGUIDE, 7
|
||||
HORZGUIDE, 19
|
||||
HORZGUIDE, 45
|
||||
HORZGUIDE, 53
|
||||
HORZGUIDE, 59
|
||||
END
|
||||
|
||||
IDD_TRANSFERPROGRESS_PANE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 177
|
||||
VERTGUIDE, 80
|
||||
VERTGUIDE, 90
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 65
|
||||
HORZGUIDE, 20
|
||||
HORZGUIDE, 33
|
||||
END
|
||||
|
||||
IDD_TRANSFERSTATUS_PANE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 177
|
||||
VERTGUIDE, 40
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 65
|
||||
HORZGUIDE, 43
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_BUGTRAP_NAME "BugTrap"
|
||||
IDS_CLOSE_TIP "Beende die unterbrochene anwendung."
|
||||
IDS_PREVIEW_REPORT_TIP "Vorschau der reportdateien."
|
||||
IDS_SAVE_REPORT_TIP "Fehlerinformationen in eine datei speichern."
|
||||
IDS_MAILTO_TIP "Eine email an den produktsupport versenden."
|
||||
IDS_SUBMIT_BUG_TIP "Einen automatisch generierten report an den produktsupport versenden."
|
||||
IDS_MACHINE_INFO_TIP "Informationen über das betriebssystem anzeigen."
|
||||
IDS_MACHINE_STATE_TIP "Alle laufenden prozesse und geladenen module anzeigen."
|
||||
IDS_PLEASE_WAIT "Bitte warten..."
|
||||
IDS_ZOOMIN "Zoom vergrößern"
|
||||
IDS_MORE_TIP "Fehlerinformationen anzeigen."
|
||||
IDS_COLUMN_ASSEMBLY "Assembly"
|
||||
IDS_COLUMN_METHOD "Methode"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_STATUS_REPORTSENT "Vielen dank für ihre geduld!\nFehlerbericht fertig."
|
||||
IDS_ERROR_TRANSFERFAILED
|
||||
"Fehler: konnte den report nicht an den server versenden"
|
||||
IDS_COLUMN_FUNCTION "Funktion"
|
||||
IDS_UNDEFINED_ERROR_EX "Unbekannter fehler (0x%08lX)"
|
||||
IDS_ADDITIONAL_INFORMATION "\nZusatzinformation:\n"
|
||||
IDS_COLUMN_ADDRESS "Addresse"
|
||||
IDS_COLUMN_FILE "Datei"
|
||||
IDS_COLUMN_LINE "Zeile"
|
||||
IDS_COLUMN_MODULE "Modul"
|
||||
IDS_COLUMN_PID "PID"
|
||||
IDS_COLUMN_PROCESS "Prozess"
|
||||
IDS_COLUMN_VERSION "Version"
|
||||
IDS_COLUMN_BASE "Basis"
|
||||
IDS_COLUMN_TYPE "Typ"
|
||||
IDS_COLUMN_SIZE "Größe"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_ABOUT_ITEM "Über BugTrap..."
|
||||
IDS_ERROR_NOT_AVAILABLE "N/A (fehler)"
|
||||
IDS_ZOOMOUT "Zoom verkleinern"
|
||||
IDS_RESETSIZE "Größe zurücksetzen"
|
||||
IDS_FITIMAGE "Bild einpassen"
|
||||
IDS_UNDEFINED_ERROR "Unbekannter fehler"
|
||||
END
|
||||
|
||||
#endif // German (Neutral) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// German (Germany) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_MAIN_DLG DIALOGEX 0, 0, 354, 298
|
||||
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "BugTrap"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "",IDC_INTRO_BKGND,0,0,354,59,SS_NOPREFIX
|
||||
CONTROL 112,IDC_DIALOG_ICON,"Static",SS_BITMAP | WS_GROUP,7,7,15,13
|
||||
LTEXT "BugTrap hat einen absturz festgestellt",IDC_INTRO1,35,7,312,8
|
||||
LTEXT "Um den entwicklungsprozess zu unterstützen wird dieses programm alle nötigen informationen über den absturz sammeln. Diese daten können dann an den produktsupport übertragen, oder gespeichert werden.",IDC_INTRO2,35,19,312,28,SS_NOPREFIX
|
||||
LTEXT "Produktsupport:",IDC_URL_PREFIX,35,47,71,8
|
||||
LTEXT "",IDC_URL,106,47,241,10,WS_TABSTOP
|
||||
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ | WS_GROUP,0,59,354,1
|
||||
GROUPBOX "Grund des Ausnahmefehlers",IDC_STATIC,7,62,281,64,WS_GROUP
|
||||
EDITTEXT IDC_EXCEPTION,14,71,268,49,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Register",IDC_STATIC,7,128,281,58,WS_GROUP
|
||||
EDITTEXT IDC_REGISTER,14,138,268,43,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Stack Trace",IDC_STATIC,7,188,281,103,WS_GROUP
|
||||
CONTROL "",IDC_STACKTRACE,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,14,199,268,87
|
||||
PUSHBUTTON "Schließen",IDCANCEL,295,66,52,14,WS_GROUP
|
||||
DEFPUSHBUTTON "Info senden",IDC_SUBMIT_BUG,295,96,52,14
|
||||
PUSHBUTTON "EMail...",IDC_MAILTO,295,116,52,14
|
||||
PUSHBUTTON "Vorschau...",IDC_PREVIEW_REPORT,295,146,52,14
|
||||
PUSHBUTTON "Speichern...",IDC_SAVE_REPORT,295,166,52,14
|
||||
PUSHBUTTON "Information...",IDC_MACHINE_INFO,295,196,52,14
|
||||
PUSHBUTTON "Status...",IDC_MACHINE_STATE,295,216,52,14
|
||||
END
|
||||
|
||||
IDD_PREVIEW_DLG DIALOGEX 0, 0, 342, 213
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Vorschau der Reportdateien"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_SPLITTER,"Static",SS_BLACKRECT | WS_GROUP,3,3,336,182
|
||||
CONTROL "",IDC_FILESLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,3,3,336,55
|
||||
CONTROL "",IDC_FILEVIEW,"Static",SS_GRAYRECT | WS_BORDER | WS_GROUP | WS_TABSTOP,3,61,336,125
|
||||
CONTROL "",IDC_FILEFORMAT_FRAME,"Static",SS_ETCHEDFRAME | NOT WS_VISIBLE | WS_GROUP,3,190,122,18,WS_EX_TRANSPARENT
|
||||
CONTROL "&Textblick",IDC_TEXTVIEW,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,13,194,44,10
|
||||
CONTROL "&Hexblick",IDC_HEXVIEW,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,68,194,42,10
|
||||
CONTROL "",IDC_IMAGE_COMMANDS,"ToolbarWindow32",NOT WS_VISIBLE | 0x4c,3,191,121,16
|
||||
DEFPUSHBUTTON "Close",IDCANCEL,284,192,50,14,WS_GROUP
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_MAIN_DLG, DIALOG
|
||||
BEGIN
|
||||
VERTGUIDE, 7
|
||||
VERTGUIDE, 14
|
||||
VERTGUIDE, 35
|
||||
VERTGUIDE, 106
|
||||
VERTGUIDE, 282
|
||||
VERTGUIDE, 288
|
||||
VERTGUIDE, 347
|
||||
BOTTOMMARGIN, 291
|
||||
HORZGUIDE, 7
|
||||
HORZGUIDE, 19
|
||||
HORZGUIDE, 47
|
||||
HORZGUIDE, 59
|
||||
HORZGUIDE, 66
|
||||
END
|
||||
|
||||
IDD_PREVIEW_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 3
|
||||
RIGHTMARGIN, 339
|
||||
TOPMARGIN, 3
|
||||
BOTTOMMARGIN, 210
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // German (Germany) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_MAIN_DLG DIALOGEX 0, 0, 354, 298
|
||||
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "BugTrap"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "",IDC_INTRO_BKGND,0,0,354,59,SS_NOPREFIX
|
||||
CONTROL 112,IDC_DIALOG_ICON,"Static",SS_BITMAP | WS_GROUP,7,7,15,13
|
||||
LTEXT "A crash has been detected by BugTrap",IDC_INTRO1,35,7,312,8
|
||||
LTEXT "To help the development process, this program will try and gather the information about the crash, and the state of your machine at the time of the crash. This data can then be submitted to product support or saved to a file.",IDC_INTRO2,35,19,312,28,SS_NOPREFIX
|
||||
LTEXT "Product support site:",IDC_URL_PREFIX,35,47,71,8
|
||||
LTEXT "",IDC_URL,106,47,241,10,WS_TABSTOP
|
||||
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ | WS_GROUP,0,59,354,1
|
||||
GROUPBOX "Exception Reason",IDC_STATIC,7,62,281,64,WS_GROUP
|
||||
EDITTEXT IDC_EXCEPTION,14,71,268,49,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Registers",IDC_STATIC,7,128,281,58,WS_GROUP
|
||||
EDITTEXT IDC_REGISTER,14,138,268,43,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Stack Trace",IDC_STATIC,7,188,281,103,WS_GROUP
|
||||
CONTROL "",IDC_STACKTRACE,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,14,199,268,87
|
||||
PUSHBUTTON "Close",IDCANCEL,295,66,52,14,WS_GROUP
|
||||
DEFPUSHBUTTON "Submit Bug",IDC_SUBMIT_BUG,295,96,52,14
|
||||
PUSHBUTTON "Mail To...",IDC_MAILTO,295,116,52,14
|
||||
PUSHBUTTON "Preview...",IDC_PREVIEW_REPORT,295,146,52,14
|
||||
PUSHBUTTON "Save...",IDC_SAVE_REPORT,295,166,52,14
|
||||
PUSHBUTTON "Information...",IDC_MACHINE_INFO,295,196,52,14
|
||||
PUSHBUTTON "State...",IDC_MACHINE_STATE,295,216,52,14
|
||||
END
|
||||
|
||||
IDD_ABOUT_BUGTRAP_DLG DIALOGEX 0, 0, 242, 76
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About BugTrap"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
ICON IDI_BUG,IDC_STATIC,7,7,20,20,WS_GROUP
|
||||
LTEXT "BugTrap - software error reporting tool\nVersion 1.2",IDC_VERSION_STRING,34,7,128,16
|
||||
LTEXT "Copyright © 2005-2009 IntelleSoft",IDC_STATIC,7,32,113,8
|
||||
LTEXT "http://www.intellesoft.net",IDC_URL,7,42,72,10,WS_TABSTOP
|
||||
LTEXT " GUI design based on Jim Crafton's BlackBox library",IDC_PORTIONS_COPYRIGHT,7,59,228,10,SS_NOPREFIX | SS_SUNKEN
|
||||
DEFPUSHBUTTON "Close",IDCANCEL,195,7,40,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_MACHINE_INFO_DLG DIALOGEX 0, 0, 340, 260
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Machine Information"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Operating System",IDC_STATIC,7,7,269,43,WS_GROUP
|
||||
EDITTEXT IDC_OS_TEXT,12,16,259,30,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "CPU",IDC_STATIC,7,50,269,52,WS_GROUP
|
||||
EDITTEXT IDC_CPU_TEXT,12,58,259,40,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Memory",IDC_STATIC,7,103,269,62,WS_GROUP
|
||||
EDITTEXT IDC_MEM_TEXT,12,112,259,48,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
|
||||
GROUPBOX "Environment Variables",IDC_STATIC,7,165,269,88,WS_GROUP
|
||||
EDITTEXT IDC_ENVIRONMENT,12,174,259,75,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL | WS_HSCROLL | NOT WS_TABSTOP,WS_EX_STATICEDGE
|
||||
DEFPUSHBUTTON "Close",IDCANCEL,283,10,50,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_MACHINE_STATE_DLG DIALOGEX 0, 0, 322, 222
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Machine State"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "Running Processes at Crash",IDC_PROCESS_LIST_FRAME,7,7,250,97,WS_GROUP,WS_EX_TRANSPARENT
|
||||
CONTROL "",IDC_PROCESS_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,12,17,239,80
|
||||
GROUPBOX "Modules Loaded by Selected Process",IDC_PROCESS_MODULES_LIST_FRAME,7,107,250,108,WS_GROUP,WS_EX_TRANSPARENT
|
||||
CONTROL "",IDC_PROCESS_MODULES_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,12,117,239,92
|
||||
DEFPUSHBUTTON "Close",IDCANCEL,264,11,51,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_WAIT_DLG DIALOGEX 0, 0, 83, 26
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP
|
||||
EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW
|
||||
FONT 10, "MS Shell Dlg", 400, 0, 0xCC
|
||||
BEGIN
|
||||
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,1,1,81,17
|
||||
LTEXT "Please Wait...",IDC_STATIC,18,5,46,8
|
||||
CONTROL "",IDC_PROGRESS_BAR,"Static",SS_GRAYRECT | WS_GROUP | WS_TABSTOP,1,19,81,7,WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
IDD_SEND_MAIL_DLG DIALOGEX 0, 0, 316, 196
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Send Mail"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
LTEXT "&Recipient:",IDC_STATIC,7,8,33,8
|
||||
EDITTEXT IDC_RECIPIENT,63,7,246,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE
|
||||
LTEXT "&Attachment:",IDC_STATIC,7,24,41,8
|
||||
EDITTEXT IDC_ATTACHMENT,63,23,246,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE
|
||||
LTEXT "&Subject:",IDC_STATIC,7,41,28,8
|
||||
EDITTEXT IDC_SUBJECT,63,39,246,14,ES_AUTOHSCROLL
|
||||
EDITTEXT IDC_BODY,7,57,302,109,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
|
||||
DEFPUSHBUTTON "Send",IDOK,203,175,50,14,WS_GROUP
|
||||
PUSHBUTTON "Close",IDCANCEL,259,175,50,14
|
||||
END
|
||||
|
||||
IDD_SIMPLE_DLG DIALOGEX 0, 0, 330, 94
|
||||
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "BugTrap"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "",IDC_INTRO_BKGND,0,0,330,53,SS_NOPREFIX
|
||||
CONTROL 112,IDC_DIALOG_ICON,"Static",SS_BITMAP | WS_GROUP,7,7,15,13
|
||||
LTEXT "A crash has been detected by BugTrap",IDC_INTRO1,35,7,288,8
|
||||
LTEXT "To help the development process, this program will try and gather the information about the crash, and the state of your machine at the time of the crash. This data can then be submitted to product support or saved to a file.",IDC_INTRO2,35,19,288,26,SS_NOPREFIX
|
||||
CONTROL "",-1,"Static",SS_ETCHEDHORZ | WS_GROUP,0,52,330,1
|
||||
LTEXT "Product support site:",IDC_URL_PREFIX,7,59,71,8
|
||||
LTEXT "",IDC_URL,78,59,245,10,WS_TABSTOP
|
||||
DEFPUSHBUTTON "Submit Bug",IDC_SUBMIT_BUG,7,73,52,14,WS_GROUP
|
||||
LTEXT "mail to...",IDC_MAILTO,78,75,30,12,NOT WS_GROUP | WS_TABSTOP
|
||||
PUSHBUTTON "More...",IDC_MORE,208,73,52,14
|
||||
PUSHBUTTON "Close",IDCANCEL,271,73,52,14
|
||||
END
|
||||
|
||||
IDD_PREVIEW_DLG DIALOGEX 0, 0, 342, 213
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Preview Report Files"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_SPLITTER,"Static",SS_BLACKRECT | WS_GROUP,3,3,336,182
|
||||
CONTROL "",IDC_FILESLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,3,3,336,55
|
||||
CONTROL "",IDC_FILEVIEW,"Static",SS_GRAYRECT | WS_BORDER | WS_GROUP | WS_TABSTOP,3,61,336,125
|
||||
CONTROL "",IDC_FILEFORMAT_FRAME,"Static",SS_ETCHEDFRAME | NOT WS_VISIBLE | WS_GROUP,3,190,122,18,WS_EX_TRANSPARENT
|
||||
CONTROL "&Text View",IDC_TEXTVIEW,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,13,194,47,10
|
||||
CONTROL "&Hex View",IDC_HEXVIEW,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE,68,194,45,10
|
||||
CONTROL "",IDC_IMAGE_COMMANDS,"ToolbarWindow32",NOT WS_VISIBLE | 0x4c,3,191,121,16
|
||||
DEFPUSHBUTTON "Close",IDCANCEL,284,192,50,14,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_TRANSFERPROGRESS_PANE DIALOGEX 0, 0, 184, 72
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
CONTROL "",IDC_UPLOAD_ANIMATION,"SysAnimate32",ACS_TRANSPARENT | WS_GROUP,7,7,62,17
|
||||
CONTROL "",IDC_CONNECTINGTOSERVER_CMARK,"Static",SS_BITMAP | NOT WS_VISIBLE | WS_GROUP,80,9,15,13
|
||||
LTEXT "Connecting to the server",IDC_CONNECTINGTOSERVER_LBL,90,7,81,8
|
||||
CONTROL "",IDC_SENDINGREPORT_CMARK,"Static",SS_BITMAP | NOT WS_VISIBLE | WS_GROUP,80,22,15,13
|
||||
LTEXT "Sending error report",IDC_SENDINGREPORT_LBL,90,20,66,8
|
||||
CONTROL "",IDC_CHECKINGERRORSTATUS_CMARK,"Static",SS_BITMAP | NOT WS_VISIBLE | WS_GROUP,80,35,15,13
|
||||
LTEXT "Checking error status",IDC_CHECKINGERRORSTATUS_LBL,90,33,70,8
|
||||
DEFPUSHBUTTON "Cancel",IDCANCEL,127,51,50,14
|
||||
END
|
||||
|
||||
IDD_TRANSFERSTATUS_PANE DIALOGEX 0, 0, 184, 72
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
ICON "",IDC_STATUSICON,10,13,20,20,NOT WS_VISIBLE | WS_GROUP
|
||||
LTEXT "",IDC_STATUSMESSAGE,40,7,137,36,NOT WS_VISIBLE
|
||||
DEFPUSHBUTTON "Close",IDCANCEL,127,51,50,14
|
||||
END
|
||||
|
||||
IDD_DESCRIBE_ERROR_DLG DIALOGEX 0, 0, 316, 196
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MAXIMIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Describe Error"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
LTEXT "Please feel free to describe the nature of the problem and if possible the steps taken to reproduce it:",-1,7,7,302,22
|
||||
EDITTEXT IDC_DETAILS,7,29,302,137,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
|
||||
DEFPUSHBUTTON "Send",IDOK,203,175,50,14,WS_GROUP
|
||||
PUSHBUTTON "Close",IDCANCEL,259,175,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_MAIN_DLG, DIALOG
|
||||
BEGIN
|
||||
VERTGUIDE, 7
|
||||
VERTGUIDE, 14
|
||||
VERTGUIDE, 35
|
||||
VERTGUIDE, 106
|
||||
VERTGUIDE, 282
|
||||
VERTGUIDE, 288
|
||||
VERTGUIDE, 347
|
||||
BOTTOMMARGIN, 291
|
||||
HORZGUIDE, 7
|
||||
HORZGUIDE, 19
|
||||
HORZGUIDE, 47
|
||||
HORZGUIDE, 59
|
||||
HORZGUIDE, 66
|
||||
END
|
||||
|
||||
IDD_ABOUT_BUGTRAP_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 235
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 69
|
||||
HORZGUIDE, 59
|
||||
HORZGUIDE, 69
|
||||
END
|
||||
|
||||
IDD_MACHINE_INFO_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 333
|
||||
VERTGUIDE, 12
|
||||
VERTGUIDE, 271
|
||||
VERTGUIDE, 276
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 253
|
||||
END
|
||||
|
||||
IDD_MACHINE_STATE_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 315
|
||||
VERTGUIDE, 12
|
||||
VERTGUIDE, 251
|
||||
VERTGUIDE, 257
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 215
|
||||
HORZGUIDE, 17
|
||||
HORZGUIDE, 97
|
||||
HORZGUIDE, 117
|
||||
HORZGUIDE, 209
|
||||
END
|
||||
|
||||
IDD_WAIT_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 3
|
||||
RIGHTMARGIN, 80
|
||||
TOPMARGIN, 3
|
||||
BOTTOMMARGIN, 23
|
||||
END
|
||||
|
||||
IDD_SEND_MAIL_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 309
|
||||
VERTGUIDE, 63
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 189
|
||||
HORZGUIDE, 23
|
||||
HORZGUIDE, 39
|
||||
HORZGUIDE, 166
|
||||
END
|
||||
|
||||
IDD_SIMPLE_DLG, DIALOG
|
||||
BEGIN
|
||||
VERTGUIDE, 7
|
||||
VERTGUIDE, 35
|
||||
VERTGUIDE, 78
|
||||
VERTGUIDE, 260
|
||||
VERTGUIDE, 323
|
||||
BOTTOMMARGIN, 87
|
||||
HORZGUIDE, 7
|
||||
HORZGUIDE, 19
|
||||
HORZGUIDE, 45
|
||||
HORZGUIDE, 53
|
||||
HORZGUIDE, 59
|
||||
END
|
||||
|
||||
IDD_PREVIEW_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 3
|
||||
RIGHTMARGIN, 339
|
||||
TOPMARGIN, 3
|
||||
BOTTOMMARGIN, 210
|
||||
END
|
||||
|
||||
IDD_TRANSFERPROGRESS_PANE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 177
|
||||
VERTGUIDE, 80
|
||||
VERTGUIDE, 90
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 65
|
||||
HORZGUIDE, 20
|
||||
HORZGUIDE, 33
|
||||
END
|
||||
|
||||
IDD_TRANSFERSTATUS_PANE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 177
|
||||
VERTGUIDE, 40
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 65
|
||||
HORZGUIDE, 43
|
||||
END
|
||||
|
||||
IDD_DESCRIBE_ERROR_DLG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 309
|
||||
VERTGUIDE, 63
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 189
|
||||
HORZGUIDE, 29
|
||||
HORZGUIDE, 166
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1, 3, 3718, 38316
|
||||
PRODUCTVERSION 1, 3, 3718, 38316
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000704b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "BugTrap - softwarefehler berichterstattung"
|
||||
VALUE "CompanyName", "IntelleSoft"
|
||||
VALUE "FileDescription", "BugTrap dynamic link library"
|
||||
VALUE "FileVersion", "1.3.3718.38316"
|
||||
VALUE "InternalName", "BugTrap"
|
||||
VALUE "LegalCopyright", "Copyright © 2005-2009 IntelleSoft"
|
||||
VALUE "OriginalFilename", "BugTrap.dll"
|
||||
VALUE "ProductName", "BugTrap"
|
||||
VALUE "ProductVersion", "1.3.3718.38316"
|
||||
END
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "BugTrap - software error reporting tool"
|
||||
VALUE "CompanyName", "IntelleSoft"
|
||||
VALUE "FileDescription", "BugTrap dynamic link library"
|
||||
VALUE "FileVersion", "1.3.3718.38316"
|
||||
VALUE "InternalName", "BugTrap"
|
||||
VALUE "LegalCopyright", "Copyright © 2005-2009 IntelleSoft"
|
||||
VALUE "OriginalFilename", "BugTrap.dll"
|
||||
VALUE "ProductName", "BugTrap"
|
||||
VALUE "ProductVersion", "1.3.3718.38316"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x7, 1200, 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_BUGTRAP_NAME "BugTrap"
|
||||
IDS_CLOSE_TIP "Terminate interrupted application."
|
||||
IDS_PREVIEW_REPORT_TIP "Preview contents of report files."
|
||||
IDS_SAVE_REPORT_TIP "Save detailed error information to file."
|
||||
IDS_MAILTO_TIP "Send custom e-mail message to product support."
|
||||
IDS_SUBMIT_BUG_TIP "Send automatically generated bug report to product support."
|
||||
IDS_MACHINE_INFO_TIP "Display information about operating system."
|
||||
IDS_MACHINE_STATE_TIP "List running processes and loaded modules."
|
||||
IDS_PLEASE_WAIT "Please wait..."
|
||||
IDS_ZOOMIN "Zoom In"
|
||||
IDS_MORE_TIP "Display detailed error information."
|
||||
IDS_COLUMN_ASSEMBLY "Assembly"
|
||||
IDS_COLUMN_METHOD "Method"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_STATUS_REPORTSENT "Thank you for your patience!\nError report complete."
|
||||
IDS_ERROR_TRANSFERFAILED "Error: can't send error report to the server"
|
||||
IDS_COLUMN_FUNCTION "Function"
|
||||
IDS_UNDEFINED_ERROR_EX "Undefined error (0x%08lX)"
|
||||
IDS_ADDITIONAL_INFORMATION "\nAdditional information:\n"
|
||||
IDS_COLUMN_ADDRESS "Address"
|
||||
IDS_COLUMN_FILE "File"
|
||||
IDS_COLUMN_LINE "Line"
|
||||
IDS_COLUMN_MODULE "Module"
|
||||
IDS_COLUMN_PID "PID"
|
||||
IDS_COLUMN_PROCESS "Process"
|
||||
IDS_COLUMN_VERSION "Version"
|
||||
IDS_COLUMN_BASE "Base"
|
||||
IDS_COLUMN_TYPE "Type"
|
||||
IDS_COLUMN_SIZE "Size"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_ABOUT_ITEM "About BugTrap..."
|
||||
IDS_ERROR_NOT_AVAILABLE "N/A (error)"
|
||||
IDS_ZOOMOUT "Zoom Out"
|
||||
IDS_RESETSIZE "Reset Size"
|
||||
IDS_FITIMAGE "Fit Image"
|
||||
IDS_UNDEFINED_ERROR "Undefined error"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
52
third-party/BugTrap-1.3-57bd515/source/BugTrap.sln
vendored
Normal file
52
third-party/BugTrap-1.3-57bd515/source/BugTrap.sln
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BugTrap", "BugTrap.vcproj", "{E8CF1ADA-264A-4127-86C2-FD7057D3792C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
.NET Debug|Win32 = .NET Debug|Win32
|
||||
.NET Debug|x64 = .NET Debug|x64
|
||||
.NET Release|Win32 = .NET Release|Win32
|
||||
.NET Release|x64 = .NET Release|x64
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
Unicode Debug|Win32 = Unicode Debug|Win32
|
||||
Unicode Debug|x64 = Unicode Debug|x64
|
||||
Unicode Release|Win32 = Unicode Release|Win32
|
||||
Unicode Release|x64 = Unicode Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|Win32.ActiveCfg = .NET Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|Win32.Build.0 = .NET Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|x64.ActiveCfg = .NET Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Debug|x64.Build.0 = .NET Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|Win32.ActiveCfg = .NET Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|Win32.Build.0 = .NET Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|x64.ActiveCfg = .NET Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}..NET Release|x64.Build.0 = .NET Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Debug|x64.Build.0 = Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|Win32.Build.0 = Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|x64.ActiveCfg = Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Release|x64.Build.0 = Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|x64.ActiveCfg = Unicode Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Debug|x64.Build.0 = Unicode Debug|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|Win32.ActiveCfg = Unicode Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|Win32.Build.0 = Unicode Release|Win32
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|x64.ActiveCfg = Unicode Release|x64
|
||||
{E8CF1ADA-264A-4127-86C2-FD7057D3792C}.Unicode Release|x64.Build.0 = Unicode Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
1860
third-party/BugTrap-1.3-57bd515/source/BugTrap.vcproj
vendored
Normal file
1860
third-party/BugTrap-1.3-57bd515/source/BugTrap.vcproj
vendored
Normal file
File diff suppressed because it is too large
Load diff
891
third-party/BugTrap-1.3-57bd515/source/BugTrap.vcxproj
vendored
Normal file
891
third-party/BugTrap-1.3-57bd515/source/BugTrap.vcxproj
vendored
Normal file
|
|
@ -0,0 +1,891 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include=".NET Debug|Win32">
|
||||
<Configuration>.NET Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include=".NET Debug|x64">
|
||||
<Configuration>.NET Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include=".NET Release|Win32">
|
||||
<Configuration>.NET Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include=".NET Release|x64">
|
||||
<Configuration>.NET Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Unicode Debug|Win32">
|
||||
<Configuration>Unicode Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Unicode Debug|x64">
|
||||
<Configuration>Unicode Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Unicode Release|Win32">
|
||||
<Configuration>Unicode Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Unicode Release|x64">
|
||||
<Configuration>Unicode Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E8CF1ADA-264A-4127-86C2-FD7057D3792C}</ProjectGuid>
|
||||
<RootNamespace>BugTrap</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<CLRSupport>true</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Debug-x64\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Release-x64\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">UDebug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">UDebug-x64\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'">URelease\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'">URelease-x64\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'">NDebug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'">NDebug-x64\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'">NRelease\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'">..\Bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'">NRelease-x64\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)D.dll</OutputFile>
|
||||
<ModuleDefinitionFile>BugTrap.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)D-x64.dll</OutputFile>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
|
||||
<ModuleDefinitionFile>BugTrap.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)-x64.dll</OutputFile>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)UD.dll</OutputFile>
|
||||
<ModuleDefinitionFile>BugTrap.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)UD-x64.dll</OutputFile>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)U.dll</OutputFile>
|
||||
<ModuleDefinitionFile>BugTrap.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)U-x64.dll</OutputFile>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)ND.dll</OutputFile>
|
||||
<ModuleDefinitionFile>BugTrap.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<KeyFile>"$(ProjectDir)res\KeyPair.snk"</KeyFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)ND-x64.dll</OutputFile>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<KeyFile>"$(ProjectDir)res\KeyPair.snk"</KeyFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)N.dll</OutputFile>
|
||||
<ModuleDefinitionFile>BugTrap.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;BUGTRAP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<ResourceOutputFileName>$(IntDir)$(TargetName).res</ResourceOutputFileName>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>ws2_32.lib;comctl32.lib;shlwapi.lib;version.lib;wininet.lib;nothrownew.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)N-x64.dll</OutputFile>
|
||||
<ModuleDefinitionFile>
|
||||
</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<MapExports>false</MapExports>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<KeyFile>"$(ProjectDir)res\KeyPair.snk"</KeyFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms">
|
||||
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AboutDlg.cpp" />
|
||||
<ClCompile Include="DescribeErrorDlg.cpp" />
|
||||
<ClCompile Include="MachineInfoDlg.cpp" />
|
||||
<ClCompile Include="MachineStateDlg.cpp" />
|
||||
<ClCompile Include="MainDlg.cpp" />
|
||||
<ClCompile Include="PreviewDlg.cpp" />
|
||||
<ClCompile Include="SendMailDlg.cpp" />
|
||||
<ClCompile Include="SimpleDlg.cpp" />
|
||||
<ClCompile Include="TransferProgressDlg.cpp" />
|
||||
<ClCompile Include="WaitDlg.cpp" />
|
||||
<ClCompile Include="ColHelper.cpp" />
|
||||
<ClCompile Include="StrHolder.cpp" />
|
||||
<ClCompile Include="AnimProgressBar.cpp" />
|
||||
<ClCompile Include="HexView.cpp" />
|
||||
<ClCompile Include="HyperLink.cpp" />
|
||||
<ClCompile Include="ImageView.cpp" />
|
||||
<ClCompile Include="LayoutManager.cpp" />
|
||||
<ClCompile Include="Splitter.cpp" />
|
||||
<ClCompile Include="TextView.cpp" />
|
||||
<ClCompile Include="WaitCursor.cpp" />
|
||||
<ClCompile Include="CMapi.cpp" />
|
||||
<ClCompile Include="EnumProcess.cpp" />
|
||||
<ClCompile Include="InMemLogFile.cpp" />
|
||||
<ClCompile Include="LogFile.cpp" />
|
||||
<ClCompile Include="LogStream.cpp" />
|
||||
<ClCompile Include="ModuleImportTable.cpp" />
|
||||
<ClCompile Include="NetThunks.cpp" />
|
||||
<ClCompile Include="SymEngine.cpp" />
|
||||
<ClCompile Include="SymEngineNet.cpp" />
|
||||
<ClCompile Include="TextLogFile.cpp" />
|
||||
<ClCompile Include="ThemeXP.cpp" />
|
||||
<ClCompile Include="XmlLogFile.cpp" />
|
||||
<ClCompile Include="BugTrap.cpp" />
|
||||
<ClCompile Include="BugTrapNet.cpp" />
|
||||
<ClCompile Include="BugTrapUI.cpp" />
|
||||
<ClCompile Include="BugTrapUtils.cpp" />
|
||||
<ClCompile Include="ResManager.cpp" />
|
||||
<ClCompile Include="AssemblyInfo.cpp" />
|
||||
<ClCompile Include="Globals.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='.NET Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='.NET Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='.NET Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='.NET Release|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Unicode Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Unicode Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Unicode Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Encoding.cpp" />
|
||||
<ClCompile Include="TextFormat.cpp" />
|
||||
<ClCompile Include="XmlReader.cpp" />
|
||||
<ClCompile Include="XmlWriter.cpp" />
|
||||
<ClCompile Include="FileStream.cpp" />
|
||||
<ClCompile Include="InputStream.cpp" />
|
||||
<ClCompile Include="MemStream.cpp" />
|
||||
<ClCompile Include="OutputStream.cpp" />
|
||||
<ClCompile Include="StrStream.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AboutDlg.h" />
|
||||
<ClInclude Include="DescribeErrorDlg.h" />
|
||||
<ClInclude Include="MachineInfoDlg.h" />
|
||||
<ClInclude Include="MachineStateDlg.h" />
|
||||
<ClInclude Include="MainDlg.h" />
|
||||
<ClInclude Include="PreviewDlg.h" />
|
||||
<ClInclude Include="SendMailDlg.h" />
|
||||
<ClInclude Include="SimpleDlg.h" />
|
||||
<ClInclude Include="TransferProgressDlg.h" />
|
||||
<ClInclude Include="WaitDlg.h" />
|
||||
<ClInclude Include="Array.h" />
|
||||
<ClInclude Include="Buffer.h" />
|
||||
<ClInclude Include="ColHelper.h" />
|
||||
<ClInclude Include="Hash.h" />
|
||||
<ClInclude Include="InterfacePtr.h" />
|
||||
<ClInclude Include="List.h" />
|
||||
<ClInclude Include="SmartPtr.h" />
|
||||
<ClInclude Include="StrHolder.h" />
|
||||
<ClInclude Include="AnimProgressBar.h" />
|
||||
<ClInclude Include="HexView.h" />
|
||||
<ClInclude Include="HyperLink.h" />
|
||||
<ClInclude Include="ImageView.h" />
|
||||
<ClInclude Include="LayoutManager.h" />
|
||||
<ClInclude Include="Splitter.h" />
|
||||
<ClInclude Include="TextView.h" />
|
||||
<ClInclude Include="WaitCursor.h" />
|
||||
<ClInclude Include="CMapi.h" />
|
||||
<ClInclude Include="EnumProcess.h" />
|
||||
<ClInclude Include="InMemLogFile.h" />
|
||||
<ClInclude Include="LogFile.h" />
|
||||
<ClInclude Include="LogLink.h" />
|
||||
<ClInclude Include="LogStream.h" />
|
||||
<ClInclude Include="ModuleImportTable.h" />
|
||||
<ClInclude Include="NetThunks.h" />
|
||||
<ClInclude Include="SymEngine.h" />
|
||||
<ClInclude Include="SymEngineNet.h" />
|
||||
<ClInclude Include="TextLogFile.h" />
|
||||
<ClInclude Include="ThemeXP.h" />
|
||||
<ClInclude Include="XmlLogFile.h" />
|
||||
<ClInclude Include="BTAtlWindow.h" />
|
||||
<ClInclude Include="BTMfcWindow.h" />
|
||||
<ClInclude Include="BTTrace.h" />
|
||||
<ClInclude Include="BugTrap.h" />
|
||||
<ClInclude Include="BugTrapNet.h" />
|
||||
<ClInclude Include="BugTrapUI.h" />
|
||||
<ClInclude Include="BugTrapUtils.h" />
|
||||
<ClInclude Include="ResManager.h" />
|
||||
<ClInclude Include="Globals.h" />
|
||||
<ClInclude Include="LeakWatcher.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="VersionInfo.h" />
|
||||
<ClInclude Include="Encoding.h" />
|
||||
<ClInclude Include="TextFormat.h" />
|
||||
<ClInclude Include="XmlReader.h" />
|
||||
<ClInclude Include="XmlWriter.h" />
|
||||
<ClInclude Include="BaseStream.h" />
|
||||
<ClInclude Include="FileStream.h" />
|
||||
<ClInclude Include="InputStream.h" />
|
||||
<ClInclude Include="MemStream.h" />
|
||||
<ClInclude Include="OutputStream.h" />
|
||||
<ClInclude Include="Stream.h" />
|
||||
<ClInclude Include="StrStream.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\Bug.ico" />
|
||||
<None Include="BugTrap.def" />
|
||||
<None Include="res\CheckMark.bmp" />
|
||||
<None Include="res\ImageToolbar.bmp" />
|
||||
<None Include="res\KeyPair.snk" />
|
||||
<None Include="res\SortArrows.bmp" />
|
||||
<None Include="res\Upload.avi" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="BugTrap.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
476
third-party/BugTrap-1.3-57bd515/source/BugTrap.vcxproj.filters
vendored
Normal file
476
third-party/BugTrap-1.3-57bd515/source/BugTrap.vcxproj.filters
vendored
Normal file
|
|
@ -0,0 +1,476 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Dialogs">
|
||||
<UniqueIdentifier>{abfe17a9-bc26-482a-9fdb-e3a8dbb7ab36}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Dialogs\Source Files">
|
||||
<UniqueIdentifier>{58192bc1-ce4f-4731-955d-d0f73b272682}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Dialogs\Header Files">
|
||||
<UniqueIdentifier>{434166ec-8cb3-44c8-880a-6d43c5800194}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Collections">
|
||||
<UniqueIdentifier>{64d07bc4-5326-4453-9770-bf66a24f5f4b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Collections\Source Files">
|
||||
<UniqueIdentifier>{2af5af35-9ef2-4b0d-bb85-dfd48a8b824b}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Collections\Header Files">
|
||||
<UniqueIdentifier>{e9aa1277-165e-4dcd-b0b5-67c621f9c9fa}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Controls">
|
||||
<UniqueIdentifier>{151704cd-5646-41e4-bdbd-e05ae05855f4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Controls\Source Files">
|
||||
<UniqueIdentifier>{e34a6198-a7f7-4f89-a19f-c54e74f84fe7}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Controls\Header Files">
|
||||
<UniqueIdentifier>{1340d1c6-38af-4672-9962-ab0e4dece5dd}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="System">
|
||||
<UniqueIdentifier>{2408d194-feab-4642-a254-94b2ad2e0c8f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="System\Source Files">
|
||||
<UniqueIdentifier>{45c62ad2-1328-42c7-8182-defc31c5808c}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="System\Header Files">
|
||||
<UniqueIdentifier>{dd440d12-1e24-4ac2-b977-82d8495e5754}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Main">
|
||||
<UniqueIdentifier>{3fc7613e-0551-449e-8e0d-76c6a13de4d6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Main\Source Files">
|
||||
<UniqueIdentifier>{01464f84-3c34-47f0-a1b8-7ef813b7082e}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Main\Header Files">
|
||||
<UniqueIdentifier>{1b4812d8-efbf-4371-b29d-9818782829bb}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Accessories">
|
||||
<UniqueIdentifier>{955249cd-1d5b-404d-9262-ecc078969658}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Accessories\Source Files">
|
||||
<UniqueIdentifier>{2d2ec992-ca50-4ee4-94ea-6395457b8297}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Accessories\Header Files">
|
||||
<UniqueIdentifier>{08d34c8c-4435-4346-b72d-7650bbaa282a}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Accessories\Resource Files">
|
||||
<UniqueIdentifier>{7d08c357-7058-48da-bf7f-3972267571ef}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Encodings">
|
||||
<UniqueIdentifier>{1a985d3c-df87-45b2-82de-7dc7a87ee3ee}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Encodings\Source Files">
|
||||
<UniqueIdentifier>{76e579f3-747a-4a3e-8d19-a462d6ef5fb9}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Encodings\Header Files">
|
||||
<UniqueIdentifier>{0f604217-7905-40b3-bb94-2b7f37dbcd29}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="XML">
|
||||
<UniqueIdentifier>{6797dac5-c23c-437b-958d-20097f96f04b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="XML\Source Files">
|
||||
<UniqueIdentifier>{cc355b88-50ca-45b8-8f97-2743d121738c}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="XML\Header Files">
|
||||
<UniqueIdentifier>{0172fcfb-57f2-4e9f-8b25-d2b13833c9c2}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Streams">
|
||||
<UniqueIdentifier>{025fe417-b07c-457e-ba8a-9c6c58ece1fc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Streams\Source Files">
|
||||
<UniqueIdentifier>{c2c1904e-3e10-4381-8214-c8c15fb3ac33}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Streams\Header Files">
|
||||
<UniqueIdentifier>{a02d4066-bfbf-4e9b-8148-10a58852a3d8}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AboutDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DescribeErrorDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MachineInfoDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MachineStateDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MainDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PreviewDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SendMailDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TransferProgressDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WaitDlg.cpp">
|
||||
<Filter>Dialogs\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ColHelper.cpp">
|
||||
<Filter>Collections\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StrHolder.cpp">
|
||||
<Filter>Collections\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AnimProgressBar.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HexView.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HyperLink.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImageView.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LayoutManager.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Splitter.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TextView.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WaitCursor.cpp">
|
||||
<Filter>Controls\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CMapi.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EnumProcess.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InMemLogFile.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LogFile.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LogStream.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModuleImportTable.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetThunks.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SymEngine.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SymEngineNet.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TextLogFile.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ThemeXP.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="XmlLogFile.cpp">
|
||||
<Filter>System\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BugTrap.cpp">
|
||||
<Filter>Main\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BugTrapNet.cpp">
|
||||
<Filter>Main\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BugTrapUI.cpp">
|
||||
<Filter>Main\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BugTrapUtils.cpp">
|
||||
<Filter>Main\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ResManager.cpp">
|
||||
<Filter>Main\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AssemblyInfo.cpp">
|
||||
<Filter>Accessories\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Globals.cpp">
|
||||
<Filter>Accessories\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Accessories\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Encoding.cpp">
|
||||
<Filter>Encodings\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TextFormat.cpp">
|
||||
<Filter>Encodings\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="XmlReader.cpp">
|
||||
<Filter>XML\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="XmlWriter.cpp">
|
||||
<Filter>XML\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileStream.cpp">
|
||||
<Filter>Streams\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InputStream.cpp">
|
||||
<Filter>Streams\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MemStream.cpp">
|
||||
<Filter>Streams\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OutputStream.cpp">
|
||||
<Filter>Streams\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StrStream.cpp">
|
||||
<Filter>Streams\Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AboutDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DescribeErrorDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MachineInfoDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MachineStateDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MainDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PreviewDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SendMailDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SimpleDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TransferProgressDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="WaitDlg.h">
|
||||
<Filter>Dialogs\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Array.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Buffer.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ColHelper.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Hash.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InterfacePtr.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="List.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SmartPtr.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StrHolder.h">
|
||||
<Filter>Collections\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AnimProgressBar.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HexView.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HyperLink.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ImageView.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LayoutManager.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Splitter.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TextView.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="WaitCursor.h">
|
||||
<Filter>Controls\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CMapi.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EnumProcess.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InMemLogFile.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LogFile.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LogLink.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LogStream.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ModuleImportTable.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetThunks.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SymEngine.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SymEngineNet.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TextLogFile.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ThemeXP.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="XmlLogFile.h">
|
||||
<Filter>System\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BTAtlWindow.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BTMfcWindow.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BTTrace.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BugTrap.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BugTrapNet.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BugTrapUI.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BugTrapUtils.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ResManager.h">
|
||||
<Filter>Main\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Globals.h">
|
||||
<Filter>Accessories\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LeakWatcher.h">
|
||||
<Filter>Accessories\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Accessories\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Accessories\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VersionInfo.h">
|
||||
<Filter>Accessories\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Encoding.h">
|
||||
<Filter>Encodings\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TextFormat.h">
|
||||
<Filter>Encodings\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="XmlReader.h">
|
||||
<Filter>XML\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="XmlWriter.h">
|
||||
<Filter>XML\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BaseStream.h">
|
||||
<Filter>Streams\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileStream.h">
|
||||
<Filter>Streams\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InputStream.h">
|
||||
<Filter>Streams\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MemStream.h">
|
||||
<Filter>Streams\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OutputStream.h">
|
||||
<Filter>Streams\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Stream.h">
|
||||
<Filter>Streams\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StrStream.h">
|
||||
<Filter>Streams\Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\Bug.ico">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="BugTrap.def">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="res\CheckMark.bmp">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="res\ImageToolbar.bmp">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="res\KeyPair.snk">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="res\SortArrows.bmp">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="res\Upload.avi">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="BugTrap.rc">
|
||||
<Filter>Accessories\Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
297
third-party/BugTrap-1.3-57bd515/source/BugTrapNet.cpp
vendored
Normal file
297
third-party/BugTrap-1.3-57bd515/source/BugTrapNet.cpp
vendored
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: .NET interface to BugTrap.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "BugTrapNet.h"
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
#pragma managed
|
||||
|
||||
using namespace System::Text;
|
||||
|
||||
namespace IntelleSoft
|
||||
{
|
||||
namespace BugTrap
|
||||
{
|
||||
Object^ LogFilesEnumerator::Current::get(void)
|
||||
{
|
||||
if (this->index < 0 || this->index >= LogFiles::Count)
|
||||
throw gcnew InvalidOperationException();
|
||||
return LogFiles::GetEntry(this->index);
|
||||
}
|
||||
|
||||
bool LogFilesEnumerator::MoveNext(void)
|
||||
{
|
||||
int count = LogFiles::Count;
|
||||
if (this->index >= count)
|
||||
return false;
|
||||
return (++this->index < count);
|
||||
}
|
||||
|
||||
Object^ LogFiles::GetLogFileEntry(INT_PTR index, bool getByIndex)
|
||||
{
|
||||
BUGTRAP_LOGTYPE type;
|
||||
DWORD size, result;
|
||||
result = BT_GetLogFileEntry(index, getByIndex, &type, NULL, NULL);
|
||||
if (result != ERROR_SUCCESS)
|
||||
throw gcnew Win32Exception(result);
|
||||
switch (type)
|
||||
{
|
||||
case BTLT_LOGFILE:
|
||||
{
|
||||
BUGTRAP_LOGFILEENTRY entry;
|
||||
size = sizeof(entry);
|
||||
result = BT_GetLogFileEntry(index, getByIndex, &type, &size, &entry);
|
||||
if (result != ERROR_SUCCESS)
|
||||
throw gcnew Win32Exception(result);
|
||||
return gcnew LogFileEntry(gcnew String(entry.szLogFileName));
|
||||
}
|
||||
case BTLT_REGEXPORT:
|
||||
{
|
||||
BUGTRAP_REGEXPORTENTRY entry;
|
||||
size = sizeof(entry);
|
||||
result = BT_GetLogFileEntry(index, getByIndex, &type, &size, &entry);
|
||||
if (result != ERROR_SUCCESS)
|
||||
throw gcnew Win32Exception(result);
|
||||
return gcnew RegExportEntry(gcnew String(entry.szLogFileName), gcnew String(entry.szRegKey));
|
||||
}
|
||||
default:
|
||||
throw gcnew InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
void ExceptionHandler::HandleException(System::Exception^ exception, Object^ sender, UnhandledExceptionEventArgs^ args)
|
||||
{
|
||||
Monitor::Enter(syncObj);
|
||||
try
|
||||
{
|
||||
Exception = exception;
|
||||
Sender = sender;
|
||||
Arguments = args;
|
||||
BT_CallNetFilter();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Exception = nullptr;
|
||||
Sender = nullptr;
|
||||
Arguments = nullptr;
|
||||
Monitor::Exit(syncObj);
|
||||
}
|
||||
}
|
||||
|
||||
void ExceptionHandler::HandleException(System::Exception^ exception)
|
||||
{
|
||||
UnhandledExceptionEventArgs^ args = gcnew UnhandledExceptionEventArgs(exception, ExceptionType::DomainException);
|
||||
HandleException(exception, nullptr, args);
|
||||
}
|
||||
|
||||
void ExceptionHandler::ReadVersionInfo(AssemblyName^ assemblyName)
|
||||
{
|
||||
ExceptionHandler::AppName = assemblyName->Name;
|
||||
Version^ version = assemblyName->Version;
|
||||
ExceptionHandler::AppVersion = version != nullptr ? version->ToString() : nullptr;
|
||||
}
|
||||
|
||||
void ExceptionHandler::InstallHandler(void)
|
||||
{
|
||||
BT_InstallSehFilter();
|
||||
AppDomain::CurrentDomain->UnhandledException += gcnew UnhandledExceptionEventHandler(OnUnhandledException);
|
||||
Application::ThreadException += gcnew ThreadExceptionEventHandler(OnThreadException);
|
||||
}
|
||||
|
||||
void ExceptionHandler::UninstallHandler(void)
|
||||
{
|
||||
AppDomain::CurrentDomain->UnhandledException -= gcnew UnhandledExceptionEventHandler(OnUnhandledException);
|
||||
Application::ThreadException -= gcnew ThreadExceptionEventHandler(OnThreadException);
|
||||
BT_UninstallSehFilter();
|
||||
}
|
||||
|
||||
void ExceptionHandler::SaveSnapshot(System::Exception^ exception, String^ fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Exception = exception;
|
||||
SaveSnapshot(fileName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Exception = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ExceptionHandler::SendSnapshot(System::Exception^ exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
Exception = exception;
|
||||
SendSnapshot();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Exception = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ExceptionHandler::MailSnapshot(System::Exception^ exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
Exception = exception;
|
||||
MailSnapshot();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Exception = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LogFile::PrvOpen(String^ fileName, LogFormatType logFormat)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFileName(PtrToStringChars(fileName));
|
||||
this->handle = (IntPtr)BT_OpenLogFile(wstrFileName, (BUGTRAP_LOGFORMAT)logFormat);
|
||||
if (this->handle == IntPtr::Zero)
|
||||
throw gcnew IOException();
|
||||
}
|
||||
|
||||
void LogFile::Close(void)
|
||||
{
|
||||
if (this->handle != IntPtr::Zero)
|
||||
{
|
||||
ValidateIoResult(BT_CloseLogFile((INT_PTR)this->handle));
|
||||
Detach();
|
||||
}
|
||||
}
|
||||
|
||||
void LogFile::Attach(IntPtr handle)
|
||||
{
|
||||
ValidateHandle();
|
||||
this->handle = handle;
|
||||
}
|
||||
|
||||
void LogFile::Flush(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
ValidateIoResult(BT_FlushLogFile((INT_PTR)this->handle));
|
||||
}
|
||||
|
||||
String^ LogFile::FileName::get(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
return gcnew String(BT_GetLogFileName((INT_PTR)this->handle));
|
||||
}
|
||||
|
||||
int LogFile::LogSizeInEntries::get(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
return BT_GetLogSizeInEntries((INT_PTR)this->handle);
|
||||
}
|
||||
|
||||
void LogFile::LogSizeInEntries::set(int value)
|
||||
{
|
||||
ValidateHandle();
|
||||
ValidateIoResult(BT_SetLogSizeInEntries((INT_PTR)this->handle, value));
|
||||
}
|
||||
|
||||
int LogFile::LogSizeInBytes::get(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
return BT_GetLogSizeInBytes((INT_PTR)this->handle);
|
||||
}
|
||||
|
||||
void LogFile::LogSizeInBytes::set(int value)
|
||||
{
|
||||
ValidateHandle();
|
||||
ValidateIoResult(BT_SetLogSizeInBytes((INT_PTR)this->handle, value));
|
||||
}
|
||||
|
||||
LogFlagsType LogFile::LogFlags::get(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
return (LogFlagsType)BT_GetLogFlags((INT_PTR)this->handle);
|
||||
}
|
||||
|
||||
void LogFile::LogFlags::set(LogFlagsType value)
|
||||
{
|
||||
ValidateHandle();
|
||||
ValidateIoResult(BT_SetLogFlags((INT_PTR)this->handle, (DWORD)value));
|
||||
}
|
||||
|
||||
LogLevelType LogFile::LogLevel::get(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
return (LogLevelType)BT_GetLogLevel((INT_PTR)this->handle);
|
||||
}
|
||||
|
||||
void LogFile::LogLevel::set(LogLevelType value)
|
||||
{
|
||||
ValidateHandle();
|
||||
ValidateIoResult(BT_SetLogLevel((INT_PTR)this->handle, (BUGTRAP_LOGLEVEL)value));
|
||||
}
|
||||
|
||||
LogEchoType LogFile::LogEchoMode::get(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
return (LogEchoType)BT_GetLogEchoMode((INT_PTR)this->handle);
|
||||
}
|
||||
|
||||
void LogFile::LogEchoMode::set(LogEchoType value)
|
||||
{
|
||||
ValidateHandle();
|
||||
ValidateIoResult(BT_SetLogEchoMode((INT_PTR)this->handle, (DWORD)value));
|
||||
}
|
||||
|
||||
void LogFile::Clear(void)
|
||||
{
|
||||
ValidateHandle();
|
||||
ValidateIoResult(BT_ClearLog((INT_PTR)this->handle));
|
||||
}
|
||||
|
||||
void LogFile::Insert(LogLevelType logLevel, String^ entry)
|
||||
{
|
||||
ValidateHandle();
|
||||
pin_ptr<const wchar_t> wstrEntry(PtrToStringChars(entry));
|
||||
ValidateIoResult(BT_InsLogEntry((INT_PTR)this->handle, (BUGTRAP_LOGLEVEL)logLevel, wstrEntry));
|
||||
}
|
||||
|
||||
void LogFile::Insert(LogLevelType logLevel, String^ format, ... array<Object^>^ args)
|
||||
{
|
||||
ValidateHandle();
|
||||
StringBuilder^ entry = gcnew StringBuilder();
|
||||
entry->AppendFormat(format, args);
|
||||
pin_ptr<const wchar_t> wstrEntry(PtrToStringChars(entry->ToString()));
|
||||
ValidateIoResult(BT_InsLogEntry((INT_PTR)this->handle, (BUGTRAP_LOGLEVEL)logLevel, wstrEntry));
|
||||
}
|
||||
|
||||
void LogFile::Append(LogLevelType logLevel, String^ entry)
|
||||
{
|
||||
ValidateHandle();
|
||||
pin_ptr<const wchar_t> wstrEntry(PtrToStringChars(entry));
|
||||
ValidateIoResult(BT_AppLogEntry((INT_PTR)this->handle, (BUGTRAP_LOGLEVEL)logLevel, wstrEntry));
|
||||
}
|
||||
|
||||
void LogFile::Append(LogLevelType logLevel, String^ format, ... array<Object^>^ args)
|
||||
{
|
||||
ValidateHandle();
|
||||
StringBuilder^ entry = gcnew StringBuilder();
|
||||
entry->AppendFormat(format, args);
|
||||
pin_ptr<const wchar_t> wstrEntry(PtrToStringChars(entry->ToString()));
|
||||
ValidateIoResult(BT_AppLogEntry((INT_PTR)this->handle, (BUGTRAP_LOGLEVEL)logLevel, wstrEntry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unmanaged
|
||||
|
||||
#endif // _MANAGED
|
||||
920
third-party/BugTrap-1.3-57bd515/source/BugTrapNet.h
vendored
Normal file
920
third-party/BugTrap-1.3-57bd515/source/BugTrapNet.h
vendored
Normal file
|
|
@ -0,0 +1,920 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: .NET interface to BugTrap.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
#include "BugTrap.h"
|
||||
|
||||
#pragma managed
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Windows::Forms;
|
||||
using namespace System::Reflection;
|
||||
using namespace System::ComponentModel;
|
||||
using namespace System::Collections;
|
||||
using namespace System::Diagnostics;
|
||||
using namespace System::IO;
|
||||
|
||||
#include <vcclr.h>
|
||||
|
||||
namespace IntelleSoft
|
||||
{
|
||||
namespace BugTrap
|
||||
{
|
||||
public enum class ExceptionType
|
||||
{
|
||||
NativeException,
|
||||
DomainException,
|
||||
ThreadException
|
||||
};
|
||||
|
||||
public enum class ActivityType
|
||||
{
|
||||
ShowUI = BTA_SHOWUI,
|
||||
SaveReport = BTA_SAVEREPORT,
|
||||
MailReport = BTA_MAILREPORT,
|
||||
SendReport = BTA_SENDREPORT
|
||||
};
|
||||
|
||||
[Flags]
|
||||
public enum class FlagsType
|
||||
{
|
||||
None = BTF_NONE,
|
||||
DetailedMode = BTF_DETAILEDMODE,
|
||||
EditMail = BTF_EDITMAIL,
|
||||
AttachReport = BTF_ATTACHREPORT,
|
||||
ListProcesses = BTF_LISTPROCESSES,
|
||||
ShowAdvancedUI = BTF_SHOWADVANCEDUI,
|
||||
ScreenCapture = BTF_SCREENCAPTURE,
|
||||
NativeInfo = BTF_NATIVEINFO,
|
||||
InterceptSUEF = BTF_INTERCEPTSUEF,
|
||||
DescribeError = BTF_DESCRIBEERROR,
|
||||
RestartApp = BTF_RESTARTAPP
|
||||
};
|
||||
|
||||
public enum class LogLevelType
|
||||
{
|
||||
None = BTLL_NONE,
|
||||
Error = BTLL_ERROR,
|
||||
Warning = BTLL_WARNING,
|
||||
Important = BTLL_IMPORTANT,
|
||||
Info = BTLL_INFO,
|
||||
Verbose = BTLL_VERBOSE,
|
||||
All = BTLL_ALL
|
||||
};
|
||||
|
||||
[Flags]
|
||||
public enum class LogEchoType
|
||||
{
|
||||
None = BTLE_NONE,
|
||||
StdOut = BTLE_STDOUT,
|
||||
StdErr = BTLE_STDERR,
|
||||
DbgOut = BTLE_DBGOUT
|
||||
};
|
||||
|
||||
[Flags]
|
||||
public enum class LogFlagsType
|
||||
{
|
||||
None = BTLF_NONE,
|
||||
ShowLogLevel = BTLF_SHOWLOGLEVEL,
|
||||
ShowTimeStamp = BTLF_SHOWTIMESTAMP
|
||||
};
|
||||
|
||||
public enum class ReportFormatType
|
||||
{
|
||||
Xml = BTRF_XML,
|
||||
Text = BTRF_TEXT
|
||||
};
|
||||
|
||||
public enum class LogFormatType
|
||||
{
|
||||
Xml = BTLF_XML,
|
||||
Text = BTLF_TEXT,
|
||||
Stream = BTLF_STREAM
|
||||
};
|
||||
|
||||
public enum class DialogMessageType
|
||||
{
|
||||
Intro1 = BTDM_INTRO1,
|
||||
Intro2 = BTDM_INTRO2
|
||||
};
|
||||
|
||||
public enum class LogType
|
||||
{
|
||||
LogFile = BTLT_LOGFILE,
|
||||
RegExport = BTLT_REGEXPORT
|
||||
};
|
||||
|
||||
[Flags]
|
||||
public enum class MinidumpType
|
||||
{
|
||||
Normal = MiniDumpNormal,
|
||||
WithDataSegs = MiniDumpWithDataSegs,
|
||||
WithFullMemory = MiniDumpWithFullMemory,
|
||||
WithHandleData = MiniDumpWithHandleData,
|
||||
FilterMemory = MiniDumpFilterMemory,
|
||||
ScanMemory = MiniDumpScanMemory,
|
||||
WithUnloadedModules = MiniDumpWithUnloadedModules,
|
||||
WithIndirectlyReferencedMemory = MiniDumpWithIndirectlyReferencedMemory,
|
||||
FilterModulePaths = MiniDumpFilterModulePaths,
|
||||
WithProcessThreadData = MiniDumpWithProcessThreadData,
|
||||
WithPrivateReadWriteMemory = MiniDumpWithPrivateReadWriteMemory,
|
||||
WithoutOptionalData = MiniDumpWithoutOptionalData,
|
||||
NoDump = MiniDumpNoDump
|
||||
};
|
||||
|
||||
public ref class BaseLogFileEntry
|
||||
{
|
||||
public:
|
||||
inline BaseLogFileEntry() { }
|
||||
inline BaseLogFileEntry(String^ fileName) : LogFileName(fileName) { }
|
||||
virtual String^ ToString(void) override { return LogFileName; }
|
||||
String^ LogFileName;
|
||||
};
|
||||
|
||||
public ref class LogFileEntry : public BaseLogFileEntry
|
||||
{
|
||||
public:
|
||||
inline LogFileEntry() { }
|
||||
inline LogFileEntry(String^ fileName) : BaseLogFileEntry(fileName) { }
|
||||
};
|
||||
|
||||
public ref class RegExportEntry : public BaseLogFileEntry
|
||||
{
|
||||
public:
|
||||
inline RegExportEntry() { }
|
||||
inline RegExportEntry(String^ fileName, String^ regKey) : BaseLogFileEntry(fileName), RegKey(regKey) { }
|
||||
String^ RegKey;
|
||||
};
|
||||
|
||||
private ref class LogFilesEnumerator sealed : public IEnumerator
|
||||
{
|
||||
public:
|
||||
LogFilesEnumerator(void);
|
||||
virtual bool MoveNext(void) sealed;
|
||||
virtual void Reset(void) sealed;
|
||||
virtual property Object^ Current
|
||||
{
|
||||
Object^ get() sealed;
|
||||
}
|
||||
|
||||
private:
|
||||
int index;
|
||||
};
|
||||
|
||||
inline LogFilesEnumerator::LogFilesEnumerator(void)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
inline void LogFilesEnumerator::Reset(void)
|
||||
{
|
||||
this->index = -1;
|
||||
}
|
||||
|
||||
private ref class LogFilesEnumerable sealed : public IEnumerable
|
||||
{
|
||||
public:
|
||||
virtual IEnumerator^ GetEnumerator(void) sealed;
|
||||
};
|
||||
|
||||
inline IEnumerator^ LogFilesEnumerable::GetEnumerator(void)
|
||||
{
|
||||
return gcnew LogFilesEnumerator();
|
||||
}
|
||||
|
||||
public ref class LogFiles
|
||||
{
|
||||
public:
|
||||
static void Add(LogFileEntry^ entry);
|
||||
static void Add(RegExportEntry^ entry);
|
||||
static void Delete(String^ fileName);
|
||||
static void Clear(void);
|
||||
static property int Count
|
||||
{
|
||||
int get(void);
|
||||
}
|
||||
static Object^ GetEntry(int index);
|
||||
static Object^ GetEntry(String^ fileName);
|
||||
static property IEnumerable^ Entries
|
||||
{
|
||||
IEnumerable^ get(void);
|
||||
}
|
||||
|
||||
private:
|
||||
static Object^ GetLogFileEntry(INT_PTR index, bool getByIndex);
|
||||
};
|
||||
|
||||
inline void LogFiles::Add(LogFileEntry^ entry)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFile(PtrToStringChars(entry->LogFileName));
|
||||
BT_AddLogFile(wstrFile);
|
||||
}
|
||||
|
||||
inline void LogFiles::Add(RegExportEntry^ entry)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFile(PtrToStringChars(entry->LogFileName));
|
||||
pin_ptr<const wchar_t> wstrKey(PtrToStringChars(entry->RegKey));
|
||||
BT_AddRegFile(wstrFile, wstrKey);
|
||||
}
|
||||
|
||||
inline void LogFiles::Delete(String^ fileName)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFileName(PtrToStringChars(fileName));
|
||||
BT_DeleteLogFile(wstrFileName);
|
||||
}
|
||||
|
||||
inline void LogFiles::Clear(void)
|
||||
{
|
||||
BT_ClearLogFiles();
|
||||
}
|
||||
|
||||
inline int LogFiles::Count::get(void)
|
||||
{
|
||||
return BT_GetLogFilesCount();
|
||||
}
|
||||
|
||||
inline Object^ LogFiles::GetEntry(int index)
|
||||
{
|
||||
return GetLogFileEntry(index, true);
|
||||
}
|
||||
|
||||
inline Object^ LogFiles::GetEntry(String^ fileName)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFileName(PtrToStringChars(fileName));
|
||||
return GetLogFileEntry((INT_PTR)wstrFileName, false);
|
||||
}
|
||||
|
||||
inline IEnumerable^ LogFiles::Entries::get(void)
|
||||
{
|
||||
return gcnew LogFilesEnumerable();
|
||||
}
|
||||
|
||||
public ref class UnhandledExceptionEventArgs : public System::UnhandledExceptionEventArgs
|
||||
{
|
||||
public:
|
||||
UnhandledExceptionEventArgs(Exception^ exception, BugTrap::ExceptionType type);
|
||||
UnhandledExceptionEventArgs(System::UnhandledExceptionEventArgs^ args);
|
||||
UnhandledExceptionEventArgs(System::Threading::ThreadExceptionEventArgs^ args);
|
||||
property BugTrap::ExceptionType ExceptionType
|
||||
{
|
||||
BugTrap::ExceptionType get(void);
|
||||
}
|
||||
|
||||
private:
|
||||
BugTrap::ExceptionType type;
|
||||
};
|
||||
|
||||
inline UnhandledExceptionEventArgs::UnhandledExceptionEventArgs(Exception^ exception, BugTrap::ExceptionType type)
|
||||
: System::UnhandledExceptionEventArgs(exception, true)
|
||||
{
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
inline UnhandledExceptionEventArgs::UnhandledExceptionEventArgs(System::UnhandledExceptionEventArgs^ args) : System::UnhandledExceptionEventArgs(args->ExceptionObject, true)
|
||||
{
|
||||
this->type = BugTrap::ExceptionType::DomainException;
|
||||
}
|
||||
|
||||
inline UnhandledExceptionEventArgs::UnhandledExceptionEventArgs(System::Threading::ThreadExceptionEventArgs^ args) : System::UnhandledExceptionEventArgs(args->Exception, true)
|
||||
{
|
||||
this->type = BugTrap::ExceptionType::ThreadException;
|
||||
}
|
||||
|
||||
inline BugTrap::ExceptionType UnhandledExceptionEventArgs::ExceptionType::get(void)
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
|
||||
public ref class LogFile
|
||||
{
|
||||
public:
|
||||
LogFile(void);
|
||||
LogFile(String^ fileName, LogFormatType logFormat);
|
||||
LogFile(IntPtr handle);
|
||||
~LogFile(); // Dispose()
|
||||
!LogFile(); // Finalize()
|
||||
void Open(String^ fileName, LogFormatType logFormat);
|
||||
void Attach(IntPtr handle);
|
||||
void Detach(void);
|
||||
void Close(void);
|
||||
property LogLevelType DefaultLogLevel
|
||||
{
|
||||
LogLevelType get(void);
|
||||
void set(LogLevelType value);
|
||||
}
|
||||
void Flush(void);
|
||||
property IntPtr Handle
|
||||
{
|
||||
IntPtr get(void);
|
||||
}
|
||||
property String^ FileName
|
||||
{
|
||||
String^ get(void);
|
||||
}
|
||||
property int LogSizeInEntries
|
||||
{
|
||||
int get(void);
|
||||
void set(int value);
|
||||
}
|
||||
property int LogSizeInBytes
|
||||
{
|
||||
int get(void);
|
||||
void set(int value);
|
||||
}
|
||||
property LogFlagsType LogFlags
|
||||
{
|
||||
LogFlagsType get(void);
|
||||
void set(LogFlagsType value);
|
||||
}
|
||||
property LogLevelType LogLevel
|
||||
{
|
||||
LogLevelType get(void);
|
||||
void set(LogLevelType value);
|
||||
}
|
||||
property LogEchoType LogEchoMode
|
||||
{
|
||||
LogEchoType get(void);
|
||||
void set(LogEchoType value);
|
||||
}
|
||||
void Clear(void);
|
||||
void Insert(String^ entry);
|
||||
void Insert(String^ format, ... array<Object^>^ args);
|
||||
void Insert(LogLevelType logLevel, String^ entry);
|
||||
void Insert(LogLevelType logLevel, String^ format, ... array<Object^>^ args);
|
||||
void Append(String^ entry);
|
||||
void Append(String^ format, ... array<Object^>^ args);
|
||||
void Append(LogLevelType logLevel, String^ entry);
|
||||
void Append(LogLevelType logLevel, String^ format, ... array<Object^>^ args);
|
||||
virtual String^ ToString(void) override { return FileName; }
|
||||
|
||||
private:
|
||||
void PrvOpen(String^ fileName, LogFormatType logFormat);
|
||||
void ValidateHandle(void);
|
||||
static void ValidateIoResult(BOOL bResult);
|
||||
|
||||
IntPtr handle;
|
||||
LogLevelType defaultLogLevel;
|
||||
};
|
||||
|
||||
public delegate void UnhandledExceptionDelegate(Object^ sender, UnhandledExceptionEventArgs^ args);
|
||||
|
||||
public ref class ExceptionHandler
|
||||
{
|
||||
private:
|
||||
static ExceptionHandler(void);
|
||||
static void OnUnhandledException(Object^ sender, System::UnhandledExceptionEventArgs^ args);
|
||||
static void OnThreadException(Object^ sender, System::Threading::ThreadExceptionEventArgs^ args);
|
||||
|
||||
initonly static Object^ syncObj = gcnew Object();
|
||||
static System::Exception^ exception;
|
||||
static UnhandledExceptionEventArgs^ args;
|
||||
static Object^ sender;
|
||||
|
||||
static event UnhandledExceptionDelegate^ beforeUnhandledExceptionEvent;
|
||||
static event UnhandledExceptionDelegate^ afterUnhandledExceptionEvent;
|
||||
static void HandleException(System::Exception^ exception, Object^ sender, UnhandledExceptionEventArgs^ args);
|
||||
|
||||
static void ValidateIoResult(BOOL bResult);
|
||||
|
||||
internal:
|
||||
static property System::Exception^ Exception
|
||||
{
|
||||
internal:
|
||||
System::Exception^ get(void);
|
||||
private:
|
||||
void set(System::Exception^ value);
|
||||
}
|
||||
|
||||
static property Object^ Sender
|
||||
{
|
||||
internal:
|
||||
Object^ get(void);
|
||||
private:
|
||||
void set(Object^ value);
|
||||
}
|
||||
|
||||
static property UnhandledExceptionEventArgs^ Arguments
|
||||
{
|
||||
internal:
|
||||
UnhandledExceptionEventArgs^ get(void);
|
||||
private:
|
||||
void set(UnhandledExceptionEventArgs^ value);
|
||||
}
|
||||
|
||||
static void FireBeforeUnhandledExceptionEvent(void);
|
||||
static void FireAfterUnhandledExceptionEvent(void);
|
||||
|
||||
public:
|
||||
static const int HttpPort = BUGTRAP_HTTP_PORT;
|
||||
|
||||
static event UnhandledExceptionDelegate^ BeforeUnhandledException
|
||||
{
|
||||
void add(UnhandledExceptionDelegate^ value);
|
||||
void remove(UnhandledExceptionDelegate^ value);
|
||||
}
|
||||
|
||||
static event UnhandledExceptionDelegate^ AfterUnhandledException
|
||||
{
|
||||
void add(UnhandledExceptionDelegate^ value);
|
||||
void remove(UnhandledExceptionDelegate^ value);
|
||||
}
|
||||
|
||||
static property String^ AppName
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static property String^ AppVersion
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static void ReadVersionInfo(AssemblyName^ assemblyName);
|
||||
static void ReadVersionInfo(Assembly^ assembly);
|
||||
static void ReadVersionInfo(void);
|
||||
String^ GetDialogMessage(DialogMessageType dlgMsg);
|
||||
void SetDialogMessage(DialogMessageType dlgMsg, String^ value);
|
||||
|
||||
static property String^ SupportURL
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static property String^ SupportEMail
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static property String^ SupportHost
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static property short SupportPort
|
||||
{
|
||||
short get(void);
|
||||
void set(short value);
|
||||
}
|
||||
|
||||
static property String^ NotificationEMail
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static property FlagsType Flags
|
||||
{
|
||||
FlagsType get(void);
|
||||
void set(FlagsType value);
|
||||
}
|
||||
|
||||
static property MinidumpType DumpType
|
||||
{
|
||||
MinidumpType get(void);
|
||||
void set(MinidumpType value);
|
||||
}
|
||||
|
||||
static property ReportFormatType ReportFormat
|
||||
{
|
||||
ReportFormatType get(void);
|
||||
void set(ReportFormatType value);
|
||||
}
|
||||
|
||||
static property String^ UserMessage
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static property ActivityType Activity
|
||||
{
|
||||
ActivityType get(void);
|
||||
void set(ActivityType value);
|
||||
}
|
||||
|
||||
static property String^ ReportFilePath
|
||||
{
|
||||
String^ get(void);
|
||||
void set(String^ value);
|
||||
}
|
||||
|
||||
static property String^ MailProfile
|
||||
{
|
||||
String^ get(void);
|
||||
}
|
||||
|
||||
static void SetMailProfile(String^ profile, String^ password);
|
||||
static void ExportRegKey(String^ fileName, String^ key);
|
||||
static void SaveSnapshot(String^ fileName);
|
||||
static void SaveSnapshot(System::Exception^ exception, String^ fileName);
|
||||
static void SendSnapshot(void);
|
||||
static void SendSnapshot(System::Exception^ exception);
|
||||
static void MailSnapshot(void);
|
||||
static void MailSnapshot(System::Exception^ exception);
|
||||
static void InstallHandler(void);
|
||||
static void UninstallHandler(void);
|
||||
static void HandleException(System::Exception^ exception);
|
||||
static void InstallSehFilter(void);
|
||||
static void UninstallSehFilter(void);
|
||||
};
|
||||
|
||||
static inline ExceptionHandler::ExceptionHandler(void)
|
||||
{
|
||||
InstallHandler();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::OnUnhandledException(Object^ sender, System::UnhandledExceptionEventArgs^ args)
|
||||
{
|
||||
HandleException(dynamic_cast<System::Exception^>(args->ExceptionObject), sender, gcnew UnhandledExceptionEventArgs(args));
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::OnThreadException(Object^ sender, System::Threading::ThreadExceptionEventArgs^ args)
|
||||
{
|
||||
HandleException(args->Exception, sender, gcnew UnhandledExceptionEventArgs(args));
|
||||
}
|
||||
|
||||
inline System::Exception^ ExceptionHandler::Exception::get(void)
|
||||
{
|
||||
return exception;
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::Exception::set(System::Exception^ value)
|
||||
{
|
||||
Debug::Assert(value == nullptr || exception == nullptr);
|
||||
exception = value;
|
||||
}
|
||||
|
||||
inline Object^ ExceptionHandler::Sender::get(void)
|
||||
{
|
||||
return sender;
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::Sender::set(Object^ value)
|
||||
{
|
||||
Debug::Assert(value == nullptr || sender == nullptr);
|
||||
sender = value;
|
||||
}
|
||||
|
||||
inline UnhandledExceptionEventArgs^ ExceptionHandler::Arguments::get(void)
|
||||
{
|
||||
return args;
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::Arguments::set(UnhandledExceptionEventArgs^ value)
|
||||
{
|
||||
Debug::Assert(value == nullptr || args == nullptr);
|
||||
args = value;
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::FireBeforeUnhandledExceptionEvent(void)
|
||||
{
|
||||
beforeUnhandledExceptionEvent(Sender, Arguments);
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::FireAfterUnhandledExceptionEvent(void)
|
||||
{
|
||||
afterUnhandledExceptionEvent(Sender, Arguments);
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::BeforeUnhandledException::add(UnhandledExceptionDelegate^ value)
|
||||
{
|
||||
beforeUnhandledExceptionEvent += value;
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::BeforeUnhandledException::remove(UnhandledExceptionDelegate^ value)
|
||||
{
|
||||
beforeUnhandledExceptionEvent -= value;
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::AfterUnhandledException::add(UnhandledExceptionDelegate^ value)
|
||||
{
|
||||
afterUnhandledExceptionEvent += value;
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::AfterUnhandledException::remove(UnhandledExceptionDelegate^ value)
|
||||
{
|
||||
afterUnhandledExceptionEvent -= value;
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::AppName::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetAppName());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::AppName::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrAppName(PtrToStringChars(value));
|
||||
BT_SetAppName(wstrAppName);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::AppVersion::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetAppVersion());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::AppVersion::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrAppVersion(PtrToStringChars(value));
|
||||
BT_SetAppVersion(wstrAppVersion);
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::ReadVersionInfo(Assembly^ assembly)
|
||||
{
|
||||
ReadVersionInfo(assembly->GetName());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::ReadVersionInfo(void)
|
||||
{
|
||||
ReadVersionInfo(Assembly::GetEntryAssembly());
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::GetDialogMessage(DialogMessageType dlgMsg)
|
||||
{
|
||||
return gcnew String(BT_GetDialogMessage((BUGTRAP_DIALOGMESSAGE)dlgMsg));
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SetDialogMessage(DialogMessageType dlgMsg, String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrMessage(PtrToStringChars(value));
|
||||
BT_SetDialogMessage((BUGTRAP_DIALOGMESSAGE)dlgMsg, wstrMessage);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::SupportURL::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetSupportURL());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SupportURL::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrURL(PtrToStringChars(value));
|
||||
BT_SetSupportURL(wstrURL);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::SupportEMail::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetSupportEMail());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SupportEMail::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrEMail(PtrToStringChars(value));
|
||||
BT_SetSupportEMail(wstrEMail);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::SupportHost::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetSupportHost());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SupportHost::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrHost(PtrToStringChars(value));
|
||||
BT_SetSupportHost(wstrHost);
|
||||
}
|
||||
|
||||
inline short ExceptionHandler::SupportPort::get(void)
|
||||
{
|
||||
return BT_GetSupportPort();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SupportPort::set(short value)
|
||||
{
|
||||
BT_SetSupportPort(value);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::NotificationEMail::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetNotificationEMail());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::NotificationEMail::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrEMail(PtrToStringChars(value));
|
||||
BT_SetNotificationEMail(wstrEMail);
|
||||
}
|
||||
|
||||
inline FlagsType ExceptionHandler::Flags::get(void)
|
||||
{
|
||||
return (FlagsType)BT_GetFlags();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::Flags::set(FlagsType value)
|
||||
{
|
||||
BT_SetFlags((DWORD)value);
|
||||
}
|
||||
|
||||
inline MinidumpType ExceptionHandler::DumpType::get(void)
|
||||
{
|
||||
return (MinidumpType)BT_GetDumpType();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::DumpType::set(MinidumpType value)
|
||||
{
|
||||
BT_SetDumpType((DWORD)value);
|
||||
}
|
||||
|
||||
inline ReportFormatType ExceptionHandler::ReportFormat::get(void)
|
||||
{
|
||||
return (ReportFormatType)BT_GetReportFormat();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::ReportFormat::set(ReportFormatType value)
|
||||
{
|
||||
BT_SetReportFormat((BUGTRAP_REPORTFORMAT)value);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::UserMessage::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetUserMessage());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::UserMessage::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrMessage(PtrToStringChars(value));
|
||||
BT_SetUserMessage(wstrMessage);
|
||||
}
|
||||
|
||||
inline ActivityType ExceptionHandler::Activity::get(void)
|
||||
{
|
||||
return (ActivityType)BT_GetActivityType();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::Activity::set(ActivityType value)
|
||||
{
|
||||
BT_SetActivityType((BUGTRAP_ACTIVITY)value);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::ReportFilePath::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetReportFilePath());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::ReportFilePath::set(String^ value)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrPath(PtrToStringChars(value));
|
||||
BT_SetReportFilePath(wstrPath);
|
||||
}
|
||||
|
||||
inline String^ ExceptionHandler::MailProfile::get(void)
|
||||
{
|
||||
return gcnew String(BT_GetMailProfile());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SetMailProfile(String^ profile, String^ password)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrProfile(PtrToStringChars(profile));
|
||||
pin_ptr<const wchar_t> wstrPassword(PtrToStringChars(password));
|
||||
BT_SetMailProfile(wstrProfile, wstrPassword);
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::ExportRegKey(String^ fileName, String^ key)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFileName(PtrToStringChars(fileName));
|
||||
pin_ptr<const wchar_t> wstrKey(PtrToStringChars(key));
|
||||
if (! BT_ExportRegistryKey(wstrFileName, wstrKey))
|
||||
throw gcnew Win32Exception();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SaveSnapshot(String^ fileName)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFileName(PtrToStringChars(fileName));
|
||||
ValidateIoResult(BT_SaveSnapshot(wstrFileName));
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::SendSnapshot(void)
|
||||
{
|
||||
ValidateIoResult(BT_SendSnapshot());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::MailSnapshot(void)
|
||||
{
|
||||
ValidateIoResult(BT_MailSnapshot());
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::ValidateIoResult(BOOL bResult)
|
||||
{
|
||||
if (! bResult)
|
||||
throw gcnew IOException();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::InstallSehFilter(void)
|
||||
{
|
||||
BT_InstallSehFilter();
|
||||
}
|
||||
|
||||
inline void ExceptionHandler::UninstallSehFilter(void)
|
||||
{
|
||||
BT_UninstallSehFilter();
|
||||
}
|
||||
|
||||
inline LogFile::LogFile(void)
|
||||
{
|
||||
Detach();
|
||||
}
|
||||
|
||||
inline LogFile::LogFile(IntPtr handle)
|
||||
{
|
||||
this->defaultLogLevel = LogLevelType::Info;
|
||||
this->handle = handle;
|
||||
}
|
||||
|
||||
inline LogFile::LogFile(String^ fileName, LogFormatType logFormat)
|
||||
{
|
||||
this->defaultLogLevel = LogLevelType::Info;
|
||||
PrvOpen(fileName, logFormat);
|
||||
}
|
||||
|
||||
inline LogFile::~LogFile()
|
||||
{
|
||||
this->!LogFile();
|
||||
}
|
||||
|
||||
inline LogFile::!LogFile()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
inline void LogFile::Open(String^ fileName, LogFormatType logFormat)
|
||||
{
|
||||
Close();
|
||||
PrvOpen(fileName, logFormat);
|
||||
}
|
||||
|
||||
inline void LogFile::Detach(void)
|
||||
{
|
||||
this->defaultLogLevel = LogLevelType::Info;
|
||||
this->handle = IntPtr::Zero;
|
||||
}
|
||||
|
||||
inline LogLevelType LogFile::DefaultLogLevel::get(void)
|
||||
{
|
||||
return this->defaultLogLevel;
|
||||
}
|
||||
|
||||
inline void LogFile::DefaultLogLevel::set(LogLevelType value)
|
||||
{
|
||||
this->defaultLogLevel = value;
|
||||
}
|
||||
|
||||
inline IntPtr LogFile::Handle::get(void)
|
||||
{
|
||||
return this->handle;
|
||||
}
|
||||
|
||||
inline void LogFile::Insert(String^ entry)
|
||||
{
|
||||
Insert(this->defaultLogLevel, entry);
|
||||
}
|
||||
|
||||
inline void LogFile::Insert(String^ format, ... array<Object^>^ args)
|
||||
{
|
||||
Insert(this->defaultLogLevel, format, args);
|
||||
}
|
||||
|
||||
inline void LogFile::Append(String^ entry)
|
||||
{
|
||||
Append(this->defaultLogLevel, entry);
|
||||
}
|
||||
|
||||
inline void LogFile::Append(String^ format, ... array<Object^>^ args)
|
||||
{
|
||||
Append(this->defaultLogLevel, format, args);
|
||||
}
|
||||
|
||||
inline void LogFile::ValidateHandle(void)
|
||||
{
|
||||
if (this->handle == IntPtr::Zero)
|
||||
throw gcnew InvalidOperationException();
|
||||
}
|
||||
|
||||
inline void LogFile::ValidateIoResult(BOOL bResult)
|
||||
{
|
||||
if (! bResult)
|
||||
throw gcnew IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unmanaged
|
||||
|
||||
#endif // _MANAGED
|
||||
1515
third-party/BugTrap-1.3-57bd515/source/BugTrapUI.cpp
vendored
Normal file
1515
third-party/BugTrap-1.3-57bd515/source/BugTrapUI.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
205
third-party/BugTrap-1.3-57bd515/source/BugTrapUI.h
vendored
Normal file
205
third-party/BugTrap-1.3-57bd515/source/BugTrapUI.h
vendored
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Common BugTrap UI routines.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "HyperLink.h"
|
||||
#include "TransferProgressDlg.h"
|
||||
|
||||
/// Transfer thread parameters.
|
||||
class CTransferThreadParams
|
||||
{
|
||||
public:
|
||||
/// Current context.
|
||||
enum INTERNET_CONTEXT
|
||||
{
|
||||
/// Unexpected error.
|
||||
IC_ERROR = -1,
|
||||
/// Undefined context.
|
||||
IC_UNDEFINED = 0,
|
||||
/// InternetConnect() call.
|
||||
IC_INTERNETCONNECT = +1,
|
||||
/// HttpOpenRequest() call.
|
||||
IC_OPENREQUEST = +2,
|
||||
/// HttpSendRequestEx() call.
|
||||
IC_SENDREQUEST = +3,
|
||||
/// InternetWriteFile() call.
|
||||
IC_WRITEFILE = +4,
|
||||
/// HttpEndRequest() call.
|
||||
IC_ENDREQUEST = +5,
|
||||
/// Receiving response.
|
||||
IC_RECEIVINGRESPONSE = +6,
|
||||
/// InternetCloseHandle() call.
|
||||
IC_CLOSEHANDLE = +7
|
||||
};
|
||||
|
||||
|
||||
/// Initialize the object.
|
||||
CTransferThreadParams(HWND hwndSink = NULL);
|
||||
/// Destroy the object.
|
||||
~CTransferThreadParams(void);
|
||||
/// Get sink window handle.
|
||||
HWND GetSinkWnd(void) const;
|
||||
/// Set sink window handle.
|
||||
void SetSinkWnd(HWND hwndSink);
|
||||
/// Get current context.
|
||||
INTERNET_CONTEXT GetContext(void) const;
|
||||
/// Set current context.
|
||||
void SetContext(INTERNET_CONTEXT eContext);
|
||||
/// Get callback result.
|
||||
DWORD GetCallbackResult(void) const;
|
||||
/// Set callback result.
|
||||
void SetCallbackResult(DWORD dwCallbackResult);
|
||||
/// Get cancellation event handle.
|
||||
HANDLE GetCancellationEvent(void) const;
|
||||
/// Get completion event handle.
|
||||
HANDLE GetCompletionEvent(void) const;
|
||||
/// Set error code and error message to the default.
|
||||
void SetErrorCode(DWORD dwErrorCode);
|
||||
/// Set error code and error message to the default.
|
||||
void SetErrorCode(DWORD dwErrorCode, PTSTR pszMessageBuffer);
|
||||
/// Get error code.
|
||||
DWORD GetErrorCode(void) const;
|
||||
/// Get error message.
|
||||
PCTSTR GetErrorMessage(void) const;
|
||||
/// Post completion message to the sink window.
|
||||
void PostCompletionMessage(void);
|
||||
|
||||
private:
|
||||
/// Protect the class from being accidentally copied.
|
||||
CTransferThreadParams(const CTransferThreadParams& rParams);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CTransferThreadParams& operator=(const CTransferThreadParams& rParams);
|
||||
|
||||
/// Event handle used to cancel pending IO operation.
|
||||
HANDLE m_hCancellationEvent;
|
||||
/// Event handle used inform waiting thread about completion.
|
||||
HANDLE m_hCompletionEvent;
|
||||
/// Window handler of sink event.
|
||||
HWND m_hwndSink;
|
||||
/// Error message text.
|
||||
PTSTR m_pszMessageBuffer;
|
||||
/// Error code.
|
||||
DWORD m_dwErrorCode;
|
||||
/// Current context.
|
||||
INTERNET_CONTEXT m_eContext;
|
||||
/// Callback result.
|
||||
DWORD m_dwCallbackResult;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @return current context.
|
||||
*/
|
||||
inline CTransferThreadParams::INTERNET_CONTEXT CTransferThreadParams::GetContext(void) const
|
||||
{
|
||||
return m_eContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eContext - current context.
|
||||
*/
|
||||
inline void CTransferThreadParams::SetContext(CTransferThreadParams::INTERNET_CONTEXT eContext)
|
||||
{
|
||||
m_eContext = eContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return callback result.
|
||||
*/
|
||||
inline DWORD CTransferThreadParams::GetCallbackResult(void) const
|
||||
{
|
||||
return m_dwCallbackResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwCallbackResult - callback result.
|
||||
*/
|
||||
inline void CTransferThreadParams::SetCallbackResult(DWORD dwCallbackResult)
|
||||
{
|
||||
m_dwCallbackResult = dwCallbackResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return sink window handle.
|
||||
*/
|
||||
inline HWND CTransferThreadParams::GetSinkWnd(void) const
|
||||
{
|
||||
return m_hwndSink;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwndSink - sink window handle.
|
||||
*/
|
||||
inline void CTransferThreadParams::SetSinkWnd(HWND hwndSink)
|
||||
{
|
||||
m_hwndSink = hwndSink;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return cancellation event handle.
|
||||
*/
|
||||
inline HANDLE CTransferThreadParams::GetCancellationEvent(void) const
|
||||
{
|
||||
return m_hCancellationEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return completion event handle.
|
||||
*/
|
||||
inline HANDLE CTransferThreadParams::GetCompletionEvent(void) const
|
||||
{
|
||||
return m_hCompletionEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return error code.
|
||||
*/
|
||||
inline DWORD CTransferThreadParams::GetErrorCode(void) const
|
||||
{
|
||||
return m_dwErrorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return error message.
|
||||
*/
|
||||
inline PCTSTR CTransferThreadParams::GetErrorMessage(void) const
|
||||
{
|
||||
return m_pszMessageBuffer;
|
||||
}
|
||||
|
||||
inline void CTransferThreadParams::PostCompletionMessage(void)
|
||||
{
|
||||
if (m_hwndSink)
|
||||
PostMessage(m_hwndSink, UM_TRANSFERCOMPLETE, m_dwErrorCode, 0);
|
||||
}
|
||||
|
||||
HANDLE StartTransferThread(CTransferThreadParams* pTransferThreadParams);
|
||||
DWORD CloseTransferThread(HANDLE hTransferThread);
|
||||
|
||||
#define IDM_ABOUTBOX 0x0010
|
||||
|
||||
void GetDefaultMailSubject(PTSTR pszSubject, DWORD dwSubjectSize);
|
||||
void GetDefaultMailURL(PTSTR pszURLString, DWORD dwURLSize);
|
||||
BOOL SendEMail(HWND hwndParent, PCTSTR pszSubject, PCTSTR pszMessage);
|
||||
BOOL MailTempReportEx(HWND hwndParent);
|
||||
BOOL SendTempReport(HWND hwndParent);
|
||||
BOOL SubmitTempReport(HWND hwndParent);
|
||||
BOOL SendReport(void);
|
||||
BOOL MailReport(void);
|
||||
BOOL SaveReport(PCTSTR pszFileName);
|
||||
void InitIntro(HWND hwnd, CHyperLink& hlURL);
|
||||
void InitAbout(HWND hwnd);
|
||||
void StartHandlerThread(void);
|
||||
LONG InternalFilter(PEXCEPTION_POINTERS pExceptionPointers);
|
||||
467
third-party/BugTrap-1.3-57bd515/source/BugTrapUtils.cpp
vendored
Normal file
467
third-party/BugTrap-1.3-57bd515/source/BugTrapUtils.cpp
vendored
Normal file
|
|
@ -0,0 +1,467 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: BugTrap utilities.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUtils Internal BugTrap Utilities
|
||||
* @{
|
||||
*/
|
||||
|
||||
// Windows processing.
|
||||
|
||||
/**
|
||||
* @brief Center window according to the desktop or another window.
|
||||
* @param hwnd - window handle to center.
|
||||
* @param hwndCenter - relative window handle or zero for desktop.
|
||||
*/
|
||||
void CenterWindow(HWND hwnd, HWND hwndCenter)
|
||||
{
|
||||
// Determine owner window to center against.
|
||||
DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE);
|
||||
if (hwndCenter == NULL)
|
||||
{
|
||||
if(dwStyle & WS_CHILD)
|
||||
hwndCenter = GetParent(hwnd);
|
||||
else
|
||||
hwndCenter = GetWindow(hwnd, GW_OWNER);
|
||||
}
|
||||
|
||||
// Get coordinates of the window relative to its parent.
|
||||
RECT rcDlg;
|
||||
GetWindowRect(hwnd, &rcDlg);
|
||||
RECT rcArea;
|
||||
RECT rcCenter;
|
||||
HWND hwndParent;
|
||||
if ((dwStyle & WS_CHILD) == 0)
|
||||
{
|
||||
// Don't center against invisible or minimized windows.
|
||||
if (hwndCenter != NULL)
|
||||
{
|
||||
DWORD dwStyleCenter = GetWindowLong(hwndCenter, GWL_STYLE);
|
||||
if (! (dwStyleCenter & WS_VISIBLE) || (dwStyleCenter & WS_MINIMIZE))
|
||||
hwndCenter = NULL;
|
||||
}
|
||||
|
||||
// Center within screen coordinates.
|
||||
SystemParametersInfo(SPI_GETWORKAREA, NULL, &rcArea, NULL);
|
||||
if(hwndCenter == NULL)
|
||||
rcCenter = rcArea;
|
||||
else
|
||||
GetWindowRect(hwndCenter, &rcCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Center within parent client coordinates.
|
||||
hwndParent = GetParent(hwnd);
|
||||
GetClientRect(hwndParent, &rcArea);
|
||||
GetClientRect(hwndCenter, &rcCenter);
|
||||
MapWindowPoints(hwndCenter, hwndParent, (POINT*)&rcCenter, 2);
|
||||
}
|
||||
|
||||
int nDlgWidth = rcDlg.right - rcDlg.left;
|
||||
int nDlgHeight = rcDlg.bottom - rcDlg.top;
|
||||
|
||||
// Find dialog's upper left based on rcCenter.
|
||||
int xLeft = (rcCenter.left + rcCenter.right) / 2 - nDlgWidth / 2;
|
||||
int yTop = (rcCenter.top + rcCenter.bottom) / 2 - nDlgHeight / 2;
|
||||
|
||||
// If the dialog is outside the screen, move it inside.
|
||||
if (xLeft < rcArea.left)
|
||||
xLeft = rcArea.left;
|
||||
else if (xLeft + nDlgWidth > rcArea.right)
|
||||
xLeft = rcArea.right - nDlgWidth;
|
||||
|
||||
if (yTop < rcArea.top)
|
||||
yTop = rcArea.top;
|
||||
else if (yTop + nDlgHeight > rcArea.bottom)
|
||||
yTop = rcArea.bottom - nDlgHeight;
|
||||
|
||||
// Map screen coordinates to child coordinates.
|
||||
SetWindowPos(hwnd, NULL, xLeft, yTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Display wait message on the screen.
|
||||
* @param hwnd - window handle.
|
||||
*/
|
||||
void DisplayWaitBanner(HWND hwnd)
|
||||
{
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
TCHAR szMessage[100];
|
||||
LoadString(g_hInstance, IDS_PLEASE_WAIT, szMessage, countof(szMessage));
|
||||
RECT rect;
|
||||
GetClientRect(hwnd, &rect);
|
||||
HDC hdc = GetDC(hwnd);
|
||||
FillRect(hdc, &rect, g_pResManager->m_hbrWindowBrush);
|
||||
HFONT hOldFont = SelectFont(hdc, g_pResManager->m_hDialogFont);
|
||||
DrawText(hdc, szMessage, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_NOPREFIX);
|
||||
SelectFont(hdc, hOldFont);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Validate scrollbar metrics.
|
||||
* @param pSInfo - pointer to scrollbar info.
|
||||
*/
|
||||
void ValidateScrollInfo(SCROLLINFO* pSInfo)
|
||||
{
|
||||
_ASSERTE(pSInfo->nMax >= 0 && pSInfo->nPage >= 0);
|
||||
if ((UINT)pSInfo->nMax + 1 <= pSInfo->nPage)
|
||||
pSInfo->nMax = pSInfo->nPage = 0;
|
||||
if (pSInfo->nPos < 0)
|
||||
{
|
||||
pSInfo->nPos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nMaxScrollPos = pSInfo->nMax - (pSInfo->nPage > 0 ? pSInfo->nPage - 1 : 0);
|
||||
if (pSInfo->nPos > nMaxScrollPos)
|
||||
pSInfo->nPos = nMaxScrollPos;
|
||||
}
|
||||
}
|
||||
|
||||
// Folders processing.
|
||||
|
||||
/**
|
||||
* @brief Delete folder and recursively removes its contents.
|
||||
* @param pszFolder - folder name.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL DeleteFolder(PCTSTR pszFolder)
|
||||
{
|
||||
TCHAR szFindFileTemplate[MAX_PATH];
|
||||
PathCombine(szFindFileTemplate, pszFolder, _T("*"));
|
||||
|
||||
WIN32_FIND_DATA FindData;
|
||||
HANDLE hFindFile = FindFirstFile(szFindFileTemplate, &FindData);
|
||||
if (hFindFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
BOOL bMore = TRUE;
|
||||
while (bMore)
|
||||
{
|
||||
TCHAR szFileName[MAX_PATH];
|
||||
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (_tcscmp(FindData.cFileName, _T(".")) != 0 && _tcscmp(FindData.cFileName, _T("..")) != 0)
|
||||
{
|
||||
PathCombine(szFileName, pszFolder, FindData.cFileName);
|
||||
if (! DeleteFolder(szFileName))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PathCombine(szFileName, pszFolder, FindData.cFileName);
|
||||
if (! DeleteFile(szFileName))
|
||||
break;
|
||||
}
|
||||
bMore = FindNextFile(hFindFile, &FindData);
|
||||
}
|
||||
FindClose(hFindFile);
|
||||
}
|
||||
return RemoveDirectory(pszFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates folder even if parent folder doesn't exist.
|
||||
* @param pszFolder - folder name.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CreateFolder(PCTSTR pszFolder)
|
||||
{
|
||||
PCTSTR pszOldSegment = PathSkipRoot(pszFolder);
|
||||
_ASSERTE(pszOldSegment != NULL);
|
||||
if (pszOldSegment == NULL)
|
||||
return FALSE;
|
||||
TCHAR szFolderPath[MAX_PATH];
|
||||
_tcsncpy_s(szFolderPath, countof(szFolderPath), pszFolder, pszOldSegment - pszFolder);
|
||||
while (*pszOldSegment)
|
||||
{
|
||||
PCTSTR pszSegment = PathFindNextComponent(pszOldSegment);
|
||||
_tcsncat_s(szFolderPath, countof(szFolderPath), pszOldSegment, pszSegment - pszOldSegment);
|
||||
if (! CreateDirectory(szFolderPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
return FALSE;
|
||||
pszOldSegment = pszSegment;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates parent folder for specified file.
|
||||
* @param pszFileName - file name.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CreateParentFolder(PCTSTR pszFileName)
|
||||
{
|
||||
TCHAR szFolderPath[MAX_PATH];
|
||||
_tcscpy_s(szFolderPath, countof(szFolderPath), pszFileName);
|
||||
PathRemoveFileSpec(szFolderPath);
|
||||
return CreateFolder(szFolderPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generate temporary folder name and creates it.
|
||||
* @param pszTempPath - generated temporary path name.
|
||||
* @param nTempPathSize - size of path buffer in characters.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CreateTempFolder(PTSTR pszTempPath, size_t nTempPathSize)
|
||||
{
|
||||
TCHAR szSysTempPath[MAX_PATH];
|
||||
GetTempPath(countof(szSysTempPath), szSysTempPath);
|
||||
PathRemoveBackslash(szSysTempPath);
|
||||
DWORD dwTicks = GetTickCount();
|
||||
for (;;)
|
||||
{
|
||||
_stprintf_s(pszTempPath, nTempPathSize, _T("%s\\TEMP%lu"), szSysTempPath, dwTicks);
|
||||
if (CreateDirectory(pszTempPath, NULL))
|
||||
return TRUE;
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
return FALSE;
|
||||
++dwTicks;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get canonical application name (all non-alphanumeric characters are stripped).
|
||||
* @param pszAppName - buffer for resulting application name.
|
||||
* @param nBufferSize - size of file name buffer.
|
||||
* @param bAllowSpaces - true if spaces are allowed.
|
||||
* @return length of the name.
|
||||
*/
|
||||
size_t GetCanonicalAppName(PTSTR pszAppName, size_t nBufferSize, BOOL bAllowSpaces)
|
||||
{
|
||||
if (nBufferSize == 0)
|
||||
return 0;
|
||||
if (*g_szAppName != _T('\0'))
|
||||
{
|
||||
--nBufferSize;
|
||||
size_t nStrLength = _tcslen(g_szAppName);
|
||||
if (nStrLength > nBufferSize)
|
||||
nStrLength = nBufferSize;
|
||||
size_t nSrcPos = 0, nDstPos = 0;
|
||||
WORD wCharMask = C1_ALPHA | C1_DIGIT;
|
||||
if (bAllowSpaces)
|
||||
wCharMask |= C1_SPACE;
|
||||
while (nSrcPos < nStrLength)
|
||||
{
|
||||
WORD arrCharType[2];
|
||||
#ifdef _UNICODE
|
||||
size_t nCharSize = GetUnicodeCharSize((const BYTE*)(g_szAppName + nSrcPos)) / sizeof(WCHAR);
|
||||
GetStringTypeW(CT_CTYPE1, g_szAppName + nSrcPos, (int)nCharSize, arrCharType);
|
||||
#else
|
||||
size_t nCharSize = IsDBCSLeadByte(g_szAppName[nSrcPos]) ? 2 : 1;
|
||||
GetStringTypeA(LOCALE_USER_DEFAULT, CT_CTYPE1, g_szAppName + nSrcPos, (int)nCharSize, arrCharType);
|
||||
#endif
|
||||
if (*arrCharType & wCharMask)
|
||||
{
|
||||
pszAppName[nDstPos++] = g_szAppName[nSrcPos++];
|
||||
if (nCharSize > 1)
|
||||
pszAppName[nDstPos++] = g_szAppName[nSrcPos++];
|
||||
}
|
||||
else
|
||||
{
|
||||
/*if (*arrCharType & C1_SPACE)
|
||||
pszAppName[nDstPos++] = _T('_');*/
|
||||
nSrcPos += (DWORD)nCharSize;
|
||||
}
|
||||
}
|
||||
pszAppName[nDstPos] = _T('\0');
|
||||
return nDstPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
TCHAR szAppFileName[MAX_PATH];
|
||||
if (! GetModuleFileName(NULL, szAppFileName, countof(szAppFileName)))
|
||||
return FALSE;
|
||||
PTSTR pszFileName = PathFindFileName(szAppFileName);
|
||||
PathRemoveExtension(pszFileName);
|
||||
_tcscpy_s(pszAppName, nBufferSize, pszFileName);
|
||||
return _tcslen(pszAppName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create complete log file name.
|
||||
* @param pszCompleteLogFileName - output complete file name.
|
||||
* @param pszLogFileName - base log file name.
|
||||
* @param pszDefFileExtension - default extension.
|
||||
* @return true if log file name was created and false otherwise.
|
||||
*/
|
||||
BOOL GetCompleteLogFileName(PTSTR pszCompleteLogFileName, PCTSTR pszLogFileName, PCTSTR pszDefFileExtension)
|
||||
{
|
||||
if (pszLogFileName && *pszLogFileName && PathIsRoot(pszLogFileName))
|
||||
{
|
||||
_tcscpy_s(pszCompleteLogFileName, MAX_PATH, pszLogFileName);
|
||||
return TRUE;
|
||||
}
|
||||
TCHAR szAppDataPath[MAX_PATH];
|
||||
if (! SHGetSpecialFolderPath(NULL, szAppDataPath, CSIDL_APPDATA, TRUE))
|
||||
return FALSE;
|
||||
TCHAR szAppName[MAX_PATH];
|
||||
if (! GetCanonicalAppName(szAppName, countof(szAppName), TRUE))
|
||||
return FALSE;
|
||||
TCHAR szAppFileName[MAX_PATH];
|
||||
if (! GetModuleFileName(NULL, szAppFileName, countof(szAppFileName)))
|
||||
return FALSE;
|
||||
PTSTR pszFileName = PathFindFileName(szAppFileName);
|
||||
PathRemoveExtension(pszFileName);
|
||||
PTSTR pszAppName = *szAppName ? szAppName : pszFileName;
|
||||
PathCombine(pszCompleteLogFileName, szAppDataPath, pszAppName);
|
||||
if (pszLogFileName == NULL || *pszLogFileName == _T('\0'))
|
||||
{
|
||||
if (pszDefFileExtension == NULL || *pszDefFileExtension != _T('.'))
|
||||
return FALSE;
|
||||
PathAppend(pszCompleteLogFileName, pszFileName);
|
||||
PathAddExtension(pszCompleteLogFileName, pszDefFileExtension);
|
||||
}
|
||||
else
|
||||
PathAppend(pszCompleteLogFileName, pszLogFileName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// List controls utilities.
|
||||
|
||||
/**
|
||||
* @param hwndList - list view control.
|
||||
*/
|
||||
|
||||
void CListViewOrder::InitList(HWND hwndList)
|
||||
{
|
||||
m_iColumnNumber = -1;
|
||||
m_bAscending = TRUE;
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
HWND hwndHeader = ListView_GetHeader(hwndList);
|
||||
Header_SetImageList(hwndHeader, g_pResManager->m_hSortArrows);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwndList - list view control.
|
||||
* @param iImage - image index.
|
||||
*/
|
||||
void CListViewOrder::SetSortImage(HWND hwndList, int iImage)
|
||||
{
|
||||
_ASSERTE(m_iColumnNumber >= 0);
|
||||
HWND hwndHeader = ListView_GetHeader(hwndList);
|
||||
HDITEM hdi;
|
||||
ZeroMemory(&hdi, sizeof(hdi));
|
||||
if (iImage >= 0)
|
||||
{
|
||||
hdi.mask = HDI_FORMAT | HDI_IMAGE;
|
||||
hdi.iImage = iImage;
|
||||
hdi.fmt = HDF_LEFT | HDF_STRING | HDF_IMAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
hdi.mask = HDI_FORMAT;
|
||||
hdi.fmt = HDF_LEFT | HDF_STRING;
|
||||
}
|
||||
Header_SetItem(hwndHeader, m_iColumnNumber, &hdi);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwndList - list view control.
|
||||
*/
|
||||
void CListViewOrder::ClearSortParams(HWND hwndList)
|
||||
{
|
||||
SetSortImage(hwndList, -1);
|
||||
m_iColumnNumber = -1;
|
||||
m_bAscending = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwndList - list view control.
|
||||
* @param iColumnNumber - active column number.
|
||||
* @param bAscending - ascending/descending sort order.
|
||||
*/
|
||||
void CListViewOrder::SetSortParams(HWND hwndList, int iColumnNumber, BOOL bAscending)
|
||||
{
|
||||
if (m_iColumnNumber != iColumnNumber &&
|
||||
m_iColumnNumber >= 0)
|
||||
{
|
||||
SetSortImage(hwndList, -1);
|
||||
}
|
||||
_ASSERTE(iColumnNumber >= 0);
|
||||
m_iColumnNumber = iColumnNumber;
|
||||
m_bAscending = bAscending;
|
||||
SetSortImage(hwndList, bAscending ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param hwndList - list view control.
|
||||
* @param iColumnNumber - active column number.
|
||||
*/
|
||||
void CListViewOrder::ToggleSortParams(HWND hwndList, int iColumnNumber)
|
||||
{
|
||||
_ASSERTE(iColumnNumber >= 0);
|
||||
if (m_iColumnNumber == iColumnNumber)
|
||||
{
|
||||
m_bAscending = ! m_bAscending;
|
||||
SetSortImage(hwndList, m_bAscending ? 0 : 1);
|
||||
}
|
||||
else
|
||||
SetSortParams(hwndList, iColumnNumber, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compare two list view items.
|
||||
* @param lParam1 - 1st item index.
|
||||
* @param lParam2 - 2nd item index.
|
||||
* @param lParamSort - sort argument.
|
||||
* @return comparison result.
|
||||
*/
|
||||
int CALLBACK ListViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
||||
{
|
||||
LISTVIEW_SORT_PARAMS* pLVSortParams = (LISTVIEW_SORT_PARAMS*)lParamSort;
|
||||
TCHAR szItem1Text[256];
|
||||
ListView_GetItemText(pLVSortParams->hwndList, lParam1, pLVSortParams->iColumnNumber, szItem1Text, countof(szItem1Text));
|
||||
TCHAR szItem2Text[256];
|
||||
ListView_GetItemText(pLVSortParams->hwndList, lParam2, pLVSortParams->iColumnNumber, szItem2Text, countof(szItem2Text));
|
||||
int iResult;
|
||||
switch (pLVSortParams->eCompareType)
|
||||
{
|
||||
case LISTVIEW_SORT_PARAMS::ICT_STRING:
|
||||
iResult = _tcscmp(szItem1Text, szItem2Text);
|
||||
break;
|
||||
case LISTVIEW_SORT_PARAMS::ICT_INTEGER:
|
||||
{
|
||||
int iItemValue1 = _ttoi(szItem1Text);
|
||||
int iItemValue2 = _ttoi(szItem2Text);
|
||||
iResult = Comparator(iItemValue1, iItemValue2);
|
||||
}
|
||||
break;
|
||||
case LISTVIEW_SORT_PARAMS::ICT_HEXADECIMAL:
|
||||
{
|
||||
unsigned uItemValue1 = _tcstoul(szItem1Text, NULL, 16);
|
||||
unsigned uItemValue2 = _tcstoul(szItem2Text, NULL, 16);
|
||||
iResult = Comparator(uItemValue1, uItemValue2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
iResult = 0;
|
||||
break;
|
||||
}
|
||||
return (pLVSortParams->bAscending ? iResult : -iResult);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
164
third-party/BugTrap-1.3-57bd515/source/BugTrapUtils.h
vendored
Normal file
164
third-party/BugTrap-1.3-57bd515/source/BugTrapUtils.h
vendored
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: BugTrap utilities.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Generic functions.
|
||||
|
||||
/**
|
||||
* @brief Compare two values.
|
||||
* @param val1 - 1st value.
|
||||
* @param val2 - 2nd value.
|
||||
* @return comparison result.
|
||||
*/
|
||||
template <typename TYPE>
|
||||
inline int Comparator(const TYPE& val1, const TYPE& val2)
|
||||
{
|
||||
if (val1 < val2)
|
||||
return -1;
|
||||
else if (val2 < val1)
|
||||
return +1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swap bytes in 16-bit value.
|
||||
* @param value - integer value.
|
||||
* @return swapped value.
|
||||
*/
|
||||
inline WORD SWAP16(WORD value)
|
||||
{
|
||||
return (
|
||||
(((WORD)(value) & 0xFF00) >> 8) |
|
||||
(((WORD)(value) & 0x00FF) << 8)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swap bytes in 32-bit value.
|
||||
* @param value - integer value.
|
||||
* @return swapped value.
|
||||
*/
|
||||
inline DWORD SWAP32(DWORD value)
|
||||
{
|
||||
return (
|
||||
(((DWORD)(value) & 0xFF000000) >> 24) |
|
||||
(((DWORD)(value) & 0x00FF0000) >> 8) |
|
||||
(((DWORD)(value) & 0x000000FF) << 24) |
|
||||
(((DWORD)(value) & 0x0000FF00) << 8)
|
||||
);
|
||||
}
|
||||
|
||||
// Windows processing.
|
||||
void CenterWindow(HWND hwnd, HWND hwndCenter = NULL);
|
||||
void DisplayWaitBanner(HWND hwnd);
|
||||
void ValidateScrollInfo(SCROLLINFO* pSInfo);
|
||||
|
||||
// Folders processing.
|
||||
BOOL DeleteFolder(PCTSTR pszFolder);
|
||||
BOOL CreateFolder(PCTSTR pszFolder);
|
||||
BOOL CreateParentFolder(PCTSTR pszFileName);
|
||||
BOOL CreateTempFolder(PTSTR pszTempPath, size_t nTempPathSize);
|
||||
size_t GetCanonicalAppName(PTSTR pszAppName, size_t nBufferSize, BOOL bAllowSpaces);
|
||||
BOOL GetCompleteLogFileName(PTSTR pszCompleteLogFileName, PCTSTR pszLogFileName, PCTSTR pszDefFileExtension);
|
||||
|
||||
// Strings processing.
|
||||
#define TrimSpaces(str) StrTrim(str, _T(" \t\r\n"))
|
||||
#define TrimSpacesA(str) StrTrimA(str, " \t\r\n")
|
||||
#define TrimSpacesW(str) StrTrimW(str, L" \t\r\n")
|
||||
|
||||
#define IsSpace(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
|
||||
#define IsAlpha(ch) (((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z'))
|
||||
#define IsNumber(ch) ((ch) >= '0' && (ch) <= '9')
|
||||
#define IsAlphaNum(ch) (IsAlpha(ch) || IsNumber(ch))
|
||||
#define IsQuotation(ch) ((ch) == '\"' || (ch) == '\'')
|
||||
|
||||
// List controls utilities.
|
||||
|
||||
/// List view sort parameters.
|
||||
struct LISTVIEW_SORT_PARAMS
|
||||
{
|
||||
/// Comparison type.
|
||||
enum ITEM_COMPARE_TYPE
|
||||
{
|
||||
/// String comparison.
|
||||
ICT_STRING,
|
||||
/// Integer comparison.
|
||||
ICT_INTEGER,
|
||||
/// Hexadecimal comparison.
|
||||
ICT_HEXADECIMAL
|
||||
};
|
||||
|
||||
/// List control window handle.
|
||||
HWND hwndList;
|
||||
/// Sorted column number.
|
||||
int iColumnNumber;
|
||||
/// Type of item comparison.
|
||||
ITEM_COMPARE_TYPE eCompareType;
|
||||
/// Ascending/desceinding sort order.
|
||||
BOOL bAscending;
|
||||
};
|
||||
|
||||
/// Store list view order information.
|
||||
class CListViewOrder
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CListViewOrder(void);
|
||||
/// Initialize list view control.
|
||||
void InitList(HWND hwndList);
|
||||
/// Get active column number.
|
||||
int GetActiveColumn(void) const;
|
||||
/// Get ascending/desceinding sort order.
|
||||
BOOL GetSortOrder(void) const;
|
||||
/// Clear sort parameters.
|
||||
void ClearSortParams(HWND hwndList);
|
||||
/// Set sort parameters.
|
||||
void SetSortParams(HWND hwndList, int iColumnNumber, BOOL bAscending);
|
||||
/// Toggle active sort parameters.
|
||||
void ToggleSortParams(HWND hwndList, int iColumnNumber);
|
||||
|
||||
private:
|
||||
/// Set sort marker of the list.
|
||||
void SetSortImage(HWND hwndList, int iImage);
|
||||
/// Active column number.
|
||||
int m_iColumnNumber;
|
||||
/// Ascending/desceinding sort order.
|
||||
BOOL m_bAscending;
|
||||
};
|
||||
|
||||
inline CListViewOrder::CListViewOrder(void)
|
||||
{
|
||||
m_iColumnNumber = -1;
|
||||
m_bAscending = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return active column number.
|
||||
*/
|
||||
inline int CListViewOrder::GetActiveColumn(void) const
|
||||
{
|
||||
return m_iColumnNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ascending/descending sort order.
|
||||
*/
|
||||
inline BOOL CListViewOrder::GetSortOrder(void) const
|
||||
{
|
||||
return m_bAscending;
|
||||
}
|
||||
|
||||
int CALLBACK ListViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
|
||||
538
third-party/BugTrap-1.3-57bd515/source/CMapi.cpp
vendored
Normal file
538
third-party/BugTrap-1.3-57bd515/source/CMapi.cpp
vendored
Normal file
|
|
@ -0,0 +1,538 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 1999 by PJ Naughter.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Defines the wrapper class for sending an email using simple MAPI
|
||||
* Updated by: Maksim Pyatkovskiy.
|
||||
* Note: Based on code developed by PJ Naughter.
|
||||
* Downloaded from: http://www.codeproject.com/internet/cmapi.asp
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "CMapi.h"
|
||||
#include "BugTrapUtils.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
CMapiSession::CMapiSession(void)
|
||||
{
|
||||
ZeroMemory(this, sizeof(*this));
|
||||
Initialise();
|
||||
}
|
||||
|
||||
CMapiSession::~CMapiSession(void)
|
||||
{
|
||||
// Logoff if logged on
|
||||
Logoff();
|
||||
// Unload the MAPI dll
|
||||
Deinitialise();
|
||||
}
|
||||
|
||||
void CMapiSession::Initialise(void)
|
||||
{
|
||||
// First make sure the "WIN.INI" entry for MAPI is present as well
|
||||
// as the MAPI32 dll being present on the system
|
||||
if (GetProfileInt(_T("MAIL"), _T("MAPI"), 0) != 0)
|
||||
{
|
||||
// Load up the MAPI dll and get the function pointers we are interested in
|
||||
m_hMapi = LoadLibrary(_T("MAPI32.DLL"));
|
||||
if (m_hMapi)
|
||||
{
|
||||
m_pfnMAPILogon = (LPMAPILOGON) GetProcAddress(m_hMapi, "MAPILogon");
|
||||
m_pfnMAPILogoff = (LPMAPILOGOFF) GetProcAddress(m_hMapi, "MAPILogoff");
|
||||
m_pfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress(m_hMapi, "MAPISendMail");
|
||||
m_pfnMAPIResolveName = (LPMAPIRESOLVENAME) GetProcAddress(m_hMapi, "MAPIResolveName");
|
||||
m_pfnMAPIFreeBuffer = (LPMAPIFREEBUFFER) GetProcAddress(m_hMapi, "MAPIFreeBuffer");
|
||||
|
||||
// If any of the functions are not installed then fail the load
|
||||
if (m_pfnMAPILogon == NULL ||
|
||||
m_pfnMAPILogoff == NULL ||
|
||||
m_pfnMAPISendMail == NULL ||
|
||||
m_pfnMAPIResolveName == NULL ||
|
||||
m_pfnMAPIFreeBuffer == NULL)
|
||||
Deinitialise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMapiSession::Deinitialise(void)
|
||||
{
|
||||
if (m_hMapi)
|
||||
{
|
||||
// Unload the MAPI dll and reset the function pointers to NULL
|
||||
FreeLibrary(m_hMapi);
|
||||
ZeroMemory(this, sizeof(*this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
BOOL CMapiSession::Logon(void)
|
||||
{
|
||||
if (! MapiInstalled())
|
||||
return FALSE;
|
||||
|
||||
// Just in case we are already logged in
|
||||
Logoff();
|
||||
|
||||
// First try to acquire a new MAPI session using the supplied settings using the MAPILogon() function
|
||||
m_ulLastError = m_pfnMAPILogon(0, NULL, NULL, 0, 0, &m_hSession);
|
||||
_ASSERTE(m_ulLastError == SUCCESS_SUCCESS);
|
||||
return (m_ulLastError == SUCCESS_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszProfileName - profile name.
|
||||
* @param pszPassword - profile password.
|
||||
* @param bNewSession - pass true to open new session instead of attempting to re-use existing shared session.
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
BOOL CMapiSession::Logon(PCTSTR pszProfileName, PCTSTR pszPassword, BOOL bNewSession)
|
||||
{
|
||||
if (! MapiInstalled() || pszProfileName == NULL || *pszProfileName == _T('\0'))
|
||||
return FALSE;
|
||||
|
||||
// Just in case we are already logged in
|
||||
Logoff();
|
||||
|
||||
// Initialize flags parameter used in the MAPILogon() call
|
||||
FLAGS flags = 0;
|
||||
if (bNewSession)
|
||||
flags |= MAPI_NEW_SESSION;
|
||||
|
||||
// Get the ASCII versions of the profile name and password
|
||||
PCSTR pszProfileName2, pszPassword2;
|
||||
#ifdef _UNICODE
|
||||
CHAR szProfileNameA[MAX_PATH], szPasswordA[MAX_PATH];
|
||||
if (pszProfileName)
|
||||
WideCharToMultiByte(CP_ACP, 0, pszProfileName, -1, szProfileNameA, countof(szProfileNameA), NULL, NULL);
|
||||
else
|
||||
*szProfileNameA = '\0';
|
||||
if (pszPassword)
|
||||
WideCharToMultiByte(CP_ACP, 0, pszPassword, -1, szPasswordA, countof(szPasswordA), NULL, NULL);
|
||||
else
|
||||
*szPasswordA = '\0';
|
||||
pszProfileName2 = szProfileNameA;
|
||||
pszPassword2 = szPasswordA;
|
||||
#else
|
||||
pszProfileName2 = pszProfileName;
|
||||
pszPassword2 = pszPassword;
|
||||
#endif
|
||||
|
||||
// First try to acquire a new MAPI session using the supplied settings using the MAPILogon() function
|
||||
m_ulLastError = m_pfnMAPILogon(0, (PSTR)pszProfileName2, (PSTR)pszPassword2, flags, 0, &m_hSession);
|
||||
_ASSERTE(m_ulLastError == SUCCESS_SUCCESS);
|
||||
return (m_ulLastError == SUCCESS_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwndParent - parent window if you want to show the UI.
|
||||
* @param bNewSession - pass true to open new session instead of attempting to re-use existing shared session.
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
BOOL CMapiSession::Logon(HWND hwndParent, BOOL bNewSession)
|
||||
{
|
||||
if (! MapiInstalled())
|
||||
return FALSE;
|
||||
|
||||
// Just in case we are already logged in
|
||||
Logoff();
|
||||
|
||||
// Initialize flags parameter used in the MAPILogon() call
|
||||
FLAGS flags = MAPI_LOGON_UI;
|
||||
if (bNewSession)
|
||||
flags |= MAPI_NEW_SESSION;
|
||||
|
||||
// First try to acquire a new MAPI session using the supplied settings using the MAPILogon() function
|
||||
m_ulLastError = m_pfnMAPILogon((ULONG)hwndParent, NULL, NULL, flags, 0, &m_hSession);
|
||||
_ASSERTE(m_ulLastError == SUCCESS_SUCCESS);
|
||||
return (m_ulLastError == SUCCESS_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
BOOL CMapiSession::Logoff(void)
|
||||
{
|
||||
if (! MapiInstalled())
|
||||
return FALSE;
|
||||
|
||||
if (m_hSession)
|
||||
{
|
||||
// Call the MAPILogoff() function
|
||||
m_ulLastError = m_pfnMAPILogoff(m_hSession, 0, 0, 0);
|
||||
_ASSERTE(m_ulLastError == SUCCESS_SUCCESS);
|
||||
m_hSession = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strName - resolved name.
|
||||
* @param lpRecip - recipient information.
|
||||
* @return true if operation has been complete successfully.
|
||||
*/
|
||||
BOOL CMapiSession::Resolve(const CStrHolder& strName, lpMapiRecipDesc& lpRecip)
|
||||
{
|
||||
if (! MapiInstalled() || ! LoggedOn() || strName.IsEmpty())
|
||||
return FALSE;
|
||||
|
||||
#ifdef _UNICODE
|
||||
CHAR szNameA[MAX_PATH];
|
||||
WideCharToMultiByte(CP_ACP, 0, strName, -1, szNameA, countof(szNameA), NULL, NULL);
|
||||
PCSTR pszName = szNameA;
|
||||
#else
|
||||
PCSTR pszName = strName;
|
||||
#endif
|
||||
|
||||
m_ulLastError = m_pfnMAPIResolveName(m_hSession, 0, (PSTR)pszName, 0, 0, &lpRecip);
|
||||
_ASSERTE(m_ulLastError == SUCCESS_SUCCESS);
|
||||
return (m_ulLastError == SUCCESS_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pBuffer - pointer to de-allocated buffer.
|
||||
* @return true if operation has been complete successfully.
|
||||
*/
|
||||
BOOL CMapiSession::FreeBuffer(PVOID pBuffer)
|
||||
{
|
||||
if (! MapiInstalled())
|
||||
return FALSE;
|
||||
if (pBuffer == NULL)
|
||||
return TRUE;
|
||||
m_ulLastError = m_pfnMAPIFreeBuffer(pBuffer);
|
||||
_ASSERTE(m_ulLastError == SUCCESS_SUCCESS);
|
||||
return (m_ulLastError == SUCCESS_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ulRecipClass - kind of recipient.
|
||||
* @param rRecipDesc - recipient information.
|
||||
* @param strName - recipient name.
|
||||
*/
|
||||
void CMapiSession::InitRecipient(ULONG ulRecipClass, MapiRecipDesc& rRecipDesc, const CStrHolder& strName)
|
||||
{
|
||||
PCTSTR pszName = strName;
|
||||
// Set recipient type
|
||||
rRecipDesc.ulRecipClass = ulRecipClass;
|
||||
PCTSTR pszBracket1, pszBracket2;
|
||||
// John Smith <jsmith@aol.com>
|
||||
if ((pszBracket1 = _tcschr(pszName, _T('<'))) != NULL &&
|
||||
(pszBracket2 = _tcschr(pszBracket1 + 1, _T('>'))) != NULL)
|
||||
{
|
||||
// Copy name
|
||||
size_t nLength = pszBracket1 - pszName;
|
||||
#ifdef _UNICODE
|
||||
int nLengthA = WideCharToMultiByte(CP_ACP, 0, pszName, (int)nLength, NULL, 0, NULL, NULL);
|
||||
rRecipDesc.lpszName = new CHAR[nLengthA + 1];
|
||||
#else
|
||||
rRecipDesc.lpszName = new CHAR[nLength + 1];
|
||||
#endif
|
||||
if (rRecipDesc.lpszName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WideCharToMultiByte(CP_ACP, 0, pszName, (int)nLength, rRecipDesc.lpszName, nLengthA, NULL, NULL);
|
||||
rRecipDesc.lpszName[nLengthA] = '\0';
|
||||
#else
|
||||
strcpy_s(rRecipDesc.lpszName, nLength + 1, pszName);
|
||||
#endif
|
||||
TrimSpacesA(rRecipDesc.lpszName);
|
||||
}
|
||||
// Copy address
|
||||
PCTSTR pszAddress = pszBracket1 + 1;
|
||||
nLength = pszBracket2 - pszAddress;
|
||||
#ifdef _UNICODE
|
||||
nLengthA = WideCharToMultiByte(CP_ACP, 0, pszAddress, (int)nLength, NULL, 0, NULL, NULL);
|
||||
rRecipDesc.lpszAddress = new CHAR[nLengthA + 1];
|
||||
#else
|
||||
rRecipDesc.lpszAddress = new CHAR[nLength + 1];
|
||||
#endif
|
||||
if (rRecipDesc.lpszAddress)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WideCharToMultiByte(CP_ACP, 0, pszAddress, (int)nLength, rRecipDesc.lpszAddress, nLengthA, NULL, NULL);
|
||||
rRecipDesc.lpszAddress[nLengthA] = '\0';
|
||||
#else
|
||||
strcpy_s(rRecipDesc.lpszAddress, nLength + 1, pszAddress);
|
||||
#endif
|
||||
TrimSpacesA(rRecipDesc.lpszAddress);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t nSize;
|
||||
// Try to resolve the name
|
||||
lpMapiRecipDesc lpTempRecip = NULL;
|
||||
if (_tcschr(pszName, _T('@')) == NULL &&
|
||||
Resolve(strName, lpTempRecip))
|
||||
{
|
||||
// Resolve worked, put the resolved name/address back into the array
|
||||
if (lpTempRecip->lpszName)
|
||||
{
|
||||
nSize = strlen(lpTempRecip->lpszName) + 1;
|
||||
rRecipDesc.lpszName = new CHAR[nSize];
|
||||
if (rRecipDesc.lpszName)
|
||||
strcpy_s(rRecipDesc.lpszName, nSize, lpTempRecip->lpszName);
|
||||
}
|
||||
if (lpTempRecip->lpszAddress)
|
||||
{
|
||||
nSize = strlen(lpTempRecip->lpszAddress) + 1;
|
||||
rRecipDesc.lpszAddress = new CHAR[nSize];
|
||||
if (rRecipDesc.lpszAddress)
|
||||
strcpy_s(rRecipDesc.lpszAddress, nSize, lpTempRecip->lpszAddress);
|
||||
}
|
||||
// Don't forget to free up the memory MAPI allocated for us
|
||||
FreeBuffer(lpTempRecip);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
nSize = WideCharToMultiByte(CP_ACP, 0, pszName, -1, NULL, 0, NULL, NULL);
|
||||
#else
|
||||
nSize = strName.GetLength() + 1;
|
||||
#endif
|
||||
rRecipDesc.lpszName = new CHAR[nSize];
|
||||
if (rRecipDesc.lpszName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WideCharToMultiByte(CP_ACP, 0, pszName, -1, rRecipDesc.lpszName, (int)nSize, NULL, NULL);
|
||||
#else
|
||||
strcpy_s(rRecipDesc.lpszName, nSize, pszName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ulRecipClass - kind of recipients.
|
||||
* @param lpRecips - array of recipient descriptors.
|
||||
* @param nRecipIndex - current position of initialized recipient descriptor in the array.
|
||||
* @param arrRecipients - recipient names.
|
||||
*/
|
||||
void CMapiSession::InitRecipients(ULONG ulRecipClass, lpMapiRecipDesc lpRecips, size_t& nRecipIndex, const CArray<CStrHolder>& arrRecipients)
|
||||
{
|
||||
size_t nNumRecipients = arrRecipients.GetCount();
|
||||
for (size_t i = 0; i < nNumRecipients; ++i, ++nRecipIndex)
|
||||
InitRecipient(ulRecipClass, lpRecips[nRecipIndex + i], arrRecipients[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rMessage - message object.
|
||||
* @param bShowMessageEditor - true if you wan to show message editor.
|
||||
* @param hwndParent - parent window for the UI.
|
||||
* @param bNewSession - pass true to open new session instead of attempting to re-use existing shared session.
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
BOOL CMapiSession::Send(const CMapiMessage& rMessage, BOOL bShowMessageEditor, HWND hwndParent, BOOL bNewSession)
|
||||
{
|
||||
if (! MapiInstalled() || (bNewSession ? LoggedOn() : ! LoggedOn()))
|
||||
return FALSE;
|
||||
|
||||
const CArray<CStrHolder>& arrAttachments = rMessage.GetAttachments();
|
||||
size_t nNumAttachments = arrAttachments.GetCount();
|
||||
const CArray<CStrHolder>& arrAttachmentTitles = rMessage.GetAttachmentTitles();
|
||||
size_t nNumAttachmentTitles = arrAttachmentTitles.GetCount();
|
||||
if (nNumAttachments != nNumAttachmentTitles && nNumAttachmentTitles != 0)
|
||||
return FALSE;
|
||||
|
||||
// Create the MapiMessage structure to match the message parameter send into us
|
||||
const CArray<CStrHolder>& arrTo = rMessage.GetTo();
|
||||
const CArray<CStrHolder>& arrCC = rMessage.GetCC();
|
||||
const CArray<CStrHolder>& arrBCC = rMessage.GetBCC();
|
||||
MapiMessage mapiMessage;
|
||||
ZeroMemory(&mapiMessage, sizeof(mapiMessage));
|
||||
size_t nRecipCount = arrTo.GetCount() + arrCC.GetCount() + arrBCC.GetCount();
|
||||
|
||||
size_t nFileIndex, nRecipIndex;
|
||||
if (nRecipCount > 0)
|
||||
{
|
||||
mapiMessage.nRecipCount = (ULONG)nRecipCount;
|
||||
// Allocate the recipients array
|
||||
mapiMessage.lpRecips = new MapiRecipDesc[nRecipCount];
|
||||
if (mapiMessage.lpRecips)
|
||||
{
|
||||
ZeroMemory(mapiMessage.lpRecips, sizeof(*mapiMessage.lpRecips) * nRecipCount);
|
||||
nRecipIndex = 0;
|
||||
|
||||
// Setup the "To" recipients
|
||||
InitRecipients(MAPI_TO, mapiMessage.lpRecips, nRecipIndex, arrTo);
|
||||
// Setup the "CC" recipients
|
||||
InitRecipients(MAPI_CC, mapiMessage.lpRecips, nRecipIndex, arrCC);
|
||||
// Setup the "BCC" recipients
|
||||
InitRecipients(MAPI_BCC, mapiMessage.lpRecips, nRecipIndex, arrBCC);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the sender
|
||||
const CStrHolder& strFrom = rMessage.GetFrom();
|
||||
if (! strFrom.IsEmpty())
|
||||
{
|
||||
MapiRecipDesc recipOrigin;
|
||||
ZeroMemory(&recipOrigin, sizeof(recipOrigin));
|
||||
InitRecipient(MAPI_ORIG, recipOrigin, strFrom);
|
||||
mapiMessage.lpOriginator = &recipOrigin;
|
||||
}
|
||||
|
||||
// Setup the attachments
|
||||
if (nNumAttachments)
|
||||
{
|
||||
mapiMessage.nFileCount = (ULONG)nNumAttachments;
|
||||
mapiMessage.lpFiles = new MapiFileDesc[nNumAttachments];
|
||||
if (mapiMessage.lpFiles)
|
||||
{
|
||||
ZeroMemory(mapiMessage.lpFiles, sizeof(*mapiMessage.lpFiles) * nNumAttachments);
|
||||
for (nFileIndex = 0; nFileIndex < nNumAttachments; ++nFileIndex)
|
||||
{
|
||||
MapiFileDesc& file = mapiMessage.lpFiles[nFileIndex];
|
||||
file.nPosition = MAXUINT;
|
||||
PCTSTR pszFileName = arrAttachments[nFileIndex];
|
||||
#ifdef _UNICODE
|
||||
size_t nSize = WideCharToMultiByte(CP_ACP, 0, pszFileName, -1, NULL, 0, NULL, NULL);
|
||||
#else
|
||||
size_t nSize = strlen(pszFileName) + 1;
|
||||
#endif
|
||||
file.lpszPathName = new CHAR[nSize];
|
||||
if (file.lpszPathName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WideCharToMultiByte(CP_ACP, 0, pszFileName, -1, file.lpszPathName, (int)nSize, NULL, NULL);
|
||||
#else
|
||||
strcpy_s(file.lpszPathName, nSize, pszFileName);
|
||||
#endif
|
||||
}
|
||||
if (nNumAttachmentTitles)
|
||||
{
|
||||
PCTSTR pszTitle = arrAttachmentTitles[nFileIndex];
|
||||
#ifdef _UNICODE
|
||||
nSize = WideCharToMultiByte(CP_ACP, 0, pszTitle, -1, NULL, 0, NULL, NULL);
|
||||
#else
|
||||
nSize = strlen(pszTitle) + 1;
|
||||
#endif
|
||||
file.lpszFileName = new CHAR[nSize];
|
||||
if (file.lpszFileName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WideCharToMultiByte(CP_ACP, 0, pszTitle, -1, file.lpszFileName, (int)nSize, NULL, NULL);
|
||||
#else
|
||||
strcpy_s(file.lpszFileName, nSize, pszTitle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
file.lpszFileName = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CStrHolder& strSubject = rMessage.GetSubject();
|
||||
const CStrHolder& strBody = rMessage.GetBody();
|
||||
#ifdef _UNICODE
|
||||
PCWSTR pszSubject = strSubject;
|
||||
PSTR pszSubjectA;
|
||||
if (pszSubject)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
size_t nSubjectSize = WideCharToMultiByte(CP_ACP, 0, pszSubject, -1, NULL, 0, NULL, NULL);
|
||||
#else
|
||||
size_t nSubjectSize = strSubject.GetLength() + 1;
|
||||
#endif
|
||||
pszSubjectA = new CHAR[nSubjectSize];
|
||||
if (pszSubjectA)
|
||||
{
|
||||
// Perform Unicode to ANSI conversion
|
||||
WideCharToMultiByte(CP_ACP, 0, pszSubject, -1, pszSubjectA, (int)nSubjectSize, NULL, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
pszSubjectA = NULL;
|
||||
mapiMessage.lpszSubject = pszSubjectA;
|
||||
|
||||
PCWSTR pszBody = strBody;
|
||||
PSTR pszBodyA;
|
||||
if (pszBody)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
size_t nBodySize = WideCharToMultiByte(CP_ACP, 0, pszBody, -1, NULL, 0, NULL, NULL);
|
||||
#else
|
||||
size_t nBodySize = strBody.GetLength() + 1;
|
||||
#endif
|
||||
pszBodyA = new CHAR[nBodySize];
|
||||
if (pszBodyA)
|
||||
{
|
||||
// Perform Unicode to ANSI conversion
|
||||
WideCharToMultiByte(CP_ACP, 0, pszBody, -1, pszBodyA, (int)nBodySize, NULL, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
pszBodyA = NULL;
|
||||
mapiMessage.lpszNoteText = pszBodyA;
|
||||
#else
|
||||
mapiMessage.lpszSubject = (PSTR)(PCSTR)strSubject;
|
||||
mapiMessage.lpszNoteText = (PSTR)(PCSTR)strBody;
|
||||
#endif
|
||||
|
||||
// Initialize flags and UIParam parameters used in the MAPISendMail() call
|
||||
FLAGS flags = 0;
|
||||
|
||||
// Force user to interactively input recipients list and other info.
|
||||
if (bShowMessageEditor)
|
||||
{
|
||||
flags |= MAPI_DIALOG;
|
||||
if (! m_hSession)
|
||||
{
|
||||
flags |= MAPI_LOGON_UI;
|
||||
if (bNewSession)
|
||||
flags |= MAPI_NEW_SESSION;
|
||||
}
|
||||
}
|
||||
|
||||
// Do the actual send using MAPISendMail()
|
||||
m_ulLastError = m_pfnMAPISendMail(m_hSession, (ULONG)hwndParent, &mapiMessage, flags, 0);
|
||||
_ASSERTE(m_ulLastError == SUCCESS_SUCCESS);
|
||||
|
||||
// Tidy up the attachments
|
||||
if (nNumAttachments)
|
||||
{
|
||||
for (nFileIndex = 0; nFileIndex < nNumAttachments; ++nFileIndex)
|
||||
{
|
||||
MapiFileDesc& file = mapiMessage.lpFiles[nFileIndex];
|
||||
delete[] file.lpszPathName;
|
||||
delete[] file.lpszFileName;
|
||||
}
|
||||
delete [] mapiMessage.lpFiles;
|
||||
}
|
||||
|
||||
// Free up the recipients memory
|
||||
if (nRecipCount > 0)
|
||||
{
|
||||
for (nRecipIndex = 0; nRecipIndex < nRecipCount; ++nRecipIndex)
|
||||
{
|
||||
delete[] mapiMessage.lpRecips[nRecipIndex].lpszName;
|
||||
delete[] mapiMessage.lpRecips[nRecipIndex].lpszAddress;
|
||||
}
|
||||
delete [] mapiMessage.lpRecips;
|
||||
if (mapiMessage.lpOriginator)
|
||||
{
|
||||
delete[] mapiMessage.lpOriginator->lpszName;
|
||||
delete[] mapiMessage.lpOriginator->lpszAddress;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _UNICODE
|
||||
delete[] pszSubjectA;
|
||||
delete[] pszBodyA;
|
||||
#endif
|
||||
|
||||
return (m_ulLastError == SUCCESS_SUCCESS);
|
||||
}
|
||||
293
third-party/BugTrap-1.3-57bd515/source/CMapi.h
vendored
Normal file
293
third-party/BugTrap-1.3-57bd515/source/CMapi.h
vendored
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 1999 by PJ Naughter.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Defines the wrapper class for sending an email using simple MAPI
|
||||
* Updated by: Maksim Pyatkovskiy.
|
||||
* Note: Based on code developed by PJ Naughter.
|
||||
* Downloaded from: http://www.codeproject.com/internet/cmapi.asp
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Array.h"
|
||||
#include "StrHolder.h"
|
||||
|
||||
/// Class which encapsulates a MAPI mail message.
|
||||
class CMapiMessage
|
||||
{
|
||||
public:
|
||||
/// Get message subject.
|
||||
const CStrHolder& GetSubject(void) const;
|
||||
/// Set message subject.
|
||||
void SetSubject(PCTSTR pszSubject);
|
||||
/// Get message body.
|
||||
const CStrHolder& GetBody(void) const;
|
||||
/// Set message body.
|
||||
void SetBody(PCTSTR pszBody);
|
||||
/// Get message sender.
|
||||
const CStrHolder& GetFrom(void) const;
|
||||
/// Set message sender.
|
||||
void SetFrom(PCTSTR pszFrom);
|
||||
/// Get message recipients.
|
||||
CArray<CStrHolder>& GetTo(void);
|
||||
/// Get message recipients.
|
||||
const CArray<CStrHolder>& GetTo(void) const;
|
||||
/// Get message carbon copies.
|
||||
CArray<CStrHolder>& GetCC(void);
|
||||
/// Get message carbon copies.
|
||||
const CArray<CStrHolder>& GetCC(void) const;
|
||||
/// Get message blind carbon copies.
|
||||
CArray<CStrHolder>& GetBCC(void);
|
||||
/// Get message blind carbon copies.
|
||||
const CArray<CStrHolder>& GetBCC(void) const;
|
||||
/// Get message attachments.
|
||||
CArray<CStrHolder>& GetAttachments(void);
|
||||
/// Get message attachments.
|
||||
const CArray<CStrHolder>& GetAttachments(void) const;
|
||||
/// Get message attachment titles.
|
||||
CArray<CStrHolder>& GetAttachmentTitles(void);
|
||||
/// Get message attachment titles.
|
||||
const CArray<CStrHolder>& GetAttachmentTitles(void) const;
|
||||
|
||||
private:
|
||||
/// The Subject of the message.
|
||||
CStrHolder m_pszSubject;
|
||||
/// The Body of the message.
|
||||
CStrHolder m_pszBody;
|
||||
/// The From sender.
|
||||
CStrHolder m_pszFrom;
|
||||
/// The To recipients.
|
||||
CArray<CStrHolder> m_arrTo;
|
||||
/// The CC recipients.
|
||||
CArray<CStrHolder> m_arrCC;
|
||||
/// The BCC recipients.
|
||||
CArray<CStrHolder> m_arrBCC;
|
||||
/// Files to attach to the email.
|
||||
CArray<CStrHolder> m_arrAttachments;
|
||||
/// Titles to use for the email file attachments.
|
||||
CArray<CStrHolder> m_arrAttachmentTitles;
|
||||
};
|
||||
|
||||
/// The class which encapsulates the MAPI connection.
|
||||
class CMapiSession
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CMapiSession(void);
|
||||
/// Destroy the object.
|
||||
~CMapiSession(void);
|
||||
|
||||
/// Begin a Simple MAPI session and load the default message store and address book providers.
|
||||
BOOL Logon(void);
|
||||
/// Begin a Simple MAPI session and load the default message store and address book providers.
|
||||
BOOL Logon(PCTSTR pszProfileName, PCTSTR pszPassword = NULL, BOOL bNewSession = FALSE);
|
||||
/// Begin a Simple MAPI session and load the default message store and address book providers.
|
||||
BOOL Logon(HWND hwndParent, BOOL bNewSession = FALSE);
|
||||
/// End a session with the messaging system.
|
||||
BOOL Logoff(void);
|
||||
/// Check if Simple MAPI session is already loaded.
|
||||
BOOL LoggedOn(void) const;
|
||||
|
||||
/// Send a message.
|
||||
BOOL Send(const CMapiMessage& rMessage, BOOL bShowMessageEditor, HWND hwndParent = NULL, BOOL bNewSession = FALSE);
|
||||
/// Check if Simple MAPI is installed on user computer.
|
||||
BOOL MapiInstalled(void) const;
|
||||
|
||||
/// Get recent error code.
|
||||
ULONG GetLastError(void) const;
|
||||
|
||||
private:
|
||||
/// Protect the class from being accidentally copied.
|
||||
CMapiSession(const CMapiSession& rMapiSession);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CMapiSession& operator=(const CMapiSession& rMapiSession);
|
||||
|
||||
/// Initialize internal object structures.
|
||||
void Initialise(void);
|
||||
/// De-initialize internal object structures.
|
||||
void Deinitialise(void);
|
||||
/// Transforms a message recipient's name as entered by a user to an unambiguous address list entry.
|
||||
BOOL Resolve(const CStrHolder& strName, lpMapiRecipDesc& lpRecip);
|
||||
/// Free memory allocated by MAPI calls.
|
||||
BOOL FreeBuffer(PVOID pBuffer);
|
||||
/// Initialize particular recipient record.
|
||||
void InitRecipient(ULONG ulRecipClass, MapiRecipDesc& rRecipDesc, const CStrHolder& strName);
|
||||
/// Initialize recipients list.
|
||||
void InitRecipients(ULONG ulRecipClass, lpMapiRecipDesc lpRecips, size_t& nRecipIndex, const CArray<CStrHolder>& arrRecipients);
|
||||
|
||||
/// Mapi session handle.
|
||||
LHANDLE m_hSession;
|
||||
/// Last Mapi error value.
|
||||
ULONG m_ulLastError;
|
||||
/// Instance handle of the Mapi dll.
|
||||
HINSTANCE m_hMapi;
|
||||
/// MAPILogon() function pointer.
|
||||
LPMAPILOGON m_pfnMAPILogon;
|
||||
/// MAPILogoff() function pointer.
|
||||
LPMAPILOGOFF m_pfnMAPILogoff;
|
||||
/// MAPISendMail() function pointer.
|
||||
LPMAPISENDMAIL m_pfnMAPISendMail;
|
||||
/// MAPIResolveName() function pointer.
|
||||
LPMAPIRESOLVENAME m_pfnMAPIResolveName;
|
||||
/// MAPIFreeBuffer() function pointer.
|
||||
LPMAPIFREEBUFFER m_pfnMAPIFreeBuffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return message subject.
|
||||
*/
|
||||
inline const CStrHolder& CMapiMessage::GetSubject(void) const
|
||||
{
|
||||
return m_pszSubject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszSubject - message subject.
|
||||
*/
|
||||
inline void CMapiMessage::SetSubject(PCTSTR pszSubject)
|
||||
{
|
||||
m_pszSubject = pszSubject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message body.
|
||||
*/
|
||||
inline const CStrHolder& CMapiMessage::GetBody(void) const
|
||||
{
|
||||
return m_pszBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszBody - message body.
|
||||
*/
|
||||
inline void CMapiMessage::SetBody(PCTSTR pszBody)
|
||||
{
|
||||
m_pszBody = pszBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message sender.
|
||||
*/
|
||||
inline const CStrHolder& CMapiMessage::GetFrom(void) const
|
||||
{
|
||||
return m_pszFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszFrom - message sender.
|
||||
*/
|
||||
inline void CMapiMessage::SetFrom(PCTSTR pszFrom)
|
||||
{
|
||||
m_pszFrom = pszFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message recipients.
|
||||
*/
|
||||
inline CArray<CStrHolder>& CMapiMessage::GetTo(void)
|
||||
{
|
||||
return m_arrTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message recipients.
|
||||
*/
|
||||
inline const CArray<CStrHolder>& CMapiMessage::GetTo(void) const
|
||||
{
|
||||
return m_arrTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message carbon copies.
|
||||
*/
|
||||
inline CArray<CStrHolder>& CMapiMessage::GetCC(void)
|
||||
{
|
||||
return m_arrCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message carbon copies.
|
||||
*/
|
||||
inline const CArray<CStrHolder>& CMapiMessage::GetCC(void) const
|
||||
{
|
||||
return m_arrCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message blind carbon copies.
|
||||
*/
|
||||
inline CArray<CStrHolder>& CMapiMessage::GetBCC(void)
|
||||
{
|
||||
return m_arrBCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message blind carbon copies.
|
||||
*/
|
||||
inline const CArray<CStrHolder>& CMapiMessage::GetBCC(void) const
|
||||
{
|
||||
return m_arrBCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message attachments.
|
||||
*/
|
||||
inline CArray<CStrHolder>& CMapiMessage::GetAttachments(void)
|
||||
{
|
||||
return m_arrAttachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message attachments.
|
||||
*/
|
||||
inline const CArray<CStrHolder>& CMapiMessage::GetAttachments(void) const
|
||||
{
|
||||
return m_arrAttachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message attachment titles.
|
||||
*/
|
||||
inline CArray<CStrHolder>& CMapiMessage::GetAttachmentTitles(void)
|
||||
{
|
||||
return m_arrAttachmentTitles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return message attachment titles.
|
||||
*/
|
||||
inline const CArray<CStrHolder>& CMapiMessage::GetAttachmentTitles(void) const
|
||||
{
|
||||
return m_arrAttachmentTitles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if user already logged.
|
||||
*/
|
||||
inline BOOL CMapiSession::LoggedOn(void) const
|
||||
{
|
||||
return (m_hSession != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if Mapi is present on user computer.
|
||||
*/
|
||||
inline BOOL CMapiSession::MapiInstalled(void) const
|
||||
{
|
||||
return (m_hMapi != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return error code of recent operation.
|
||||
*/
|
||||
inline ULONG CMapiSession::GetLastError(void) const
|
||||
{
|
||||
return m_ulLastError;
|
||||
}
|
||||
36
third-party/BugTrap-1.3-57bd515/source/ColHelper.cpp
vendored
Normal file
36
third-party/BugTrap-1.3-57bd515/source/ColHelper.cpp
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Implementation of collection helpers.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "ColHelper.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Compute CRC hash value for null terminated string.
|
||||
* @param pszKey - hash value must be generated for this object.
|
||||
* @return hash value of the given object.
|
||||
*/
|
||||
unsigned GetStringHashValue(const TCHAR* pszKey)
|
||||
{
|
||||
TCHAR chCRC = 0;
|
||||
while (*pszKey)
|
||||
{
|
||||
chCRC <<= 1;
|
||||
chCRC ^= *pszKey++;
|
||||
}
|
||||
return chCRC;
|
||||
}
|
||||
377
third-party/BugTrap-1.3-57bd515/source/ColHelper.h
vendored
Normal file
377
third-party/BugTrap-1.3-57bd515/source/ColHelper.h
vendored
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Prototypes of collection helpers.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "StrHolder.h"
|
||||
#include "StrStream.h"
|
||||
|
||||
/// Object instantiation traits.
|
||||
template <typename DATA_TYPE>
|
||||
class CObjectTraits
|
||||
{
|
||||
public:
|
||||
/// Calls the constructor of @a DATA_TYPE class by default.
|
||||
static void Constructor(DATA_TYPE& rData);
|
||||
/// Calls the destructor of @a DATA_TYPE class by default.
|
||||
static void Destructor(DATA_TYPE& rData);
|
||||
/// Calls the assignment operator of @a DATA_TYPE class by default.
|
||||
static void Assignment(DATA_TYPE& rDstData, const DATA_TYPE& rSrcData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rData - reference to the memory placement of new object.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline void CObjectTraits<DATA_TYPE>::Constructor(DATA_TYPE& rData)
|
||||
{
|
||||
::new((void*)&rData) DATA_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData - reference to the memory placement of deleted object.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline void CObjectTraits<DATA_TYPE>::Destructor(DATA_TYPE& rData)
|
||||
{
|
||||
rData; rData.~DATA_TYPE();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rDstData - reference to the memory placement of destination object.
|
||||
* @param rSrcData - reference to the memory placement of source object.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline void CObjectTraits<DATA_TYPE>::Assignment(DATA_TYPE& rDstData, const DATA_TYPE& rSrcData)
|
||||
{
|
||||
rDstData = rSrcData;
|
||||
}
|
||||
|
||||
/// Value initialization traits.
|
||||
template <typename DATA_TYPE, DATA_TYPE value = 0>
|
||||
class CValueTraits
|
||||
{
|
||||
public:
|
||||
/// Calls the constructor of @a DATA_TYPE by default.
|
||||
static void Constructor(DATA_TYPE& rData);
|
||||
/// Calls the destructor of @a DATA_TYPE by default
|
||||
static void Destructor(DATA_TYPE& rData);
|
||||
/// Calls the assignment operator of @a DATA_TYPE by default.
|
||||
static void Assignment(DATA_TYPE& rDstData, const DATA_TYPE& rSrcData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rData - reference to the memory placement of new object.
|
||||
*/
|
||||
template <typename DATA_TYPE, DATA_TYPE value>
|
||||
inline void CValueTraits<DATA_TYPE, value>::Constructor(DATA_TYPE& rData)
|
||||
{
|
||||
rData = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData - reference to the memory placement of deleted object.
|
||||
*/
|
||||
template <typename DATA_TYPE, DATA_TYPE value>
|
||||
inline void CValueTraits<DATA_TYPE, value>::Destructor(DATA_TYPE& /*rData*/)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rDstData - reference to the memory placement of destination object.
|
||||
* @param rSrcData - reference to the memory placement of source object.
|
||||
*/
|
||||
template <typename DATA_TYPE, DATA_TYPE value>
|
||||
inline void CValueTraits<DATA_TYPE, value>::Assignment(DATA_TYPE& rDstData, const DATA_TYPE& rSrcData)
|
||||
{
|
||||
rDstData = rSrcData;
|
||||
}
|
||||
|
||||
/// Dynamic instantiation traits.
|
||||
template <typename DATA_TYPE>
|
||||
class CDynamicTraits
|
||||
{
|
||||
public:
|
||||
/// Calls the constructor of @a DATA_TYPE class by default.
|
||||
static void Constructor(DATA_TYPE& rData);
|
||||
/// Calls the destructor of @a DATA_TYPE class by default.
|
||||
static void Destructor(DATA_TYPE& rData);
|
||||
/// Calls the assignment operator of @a DATA_TYPE class by default.
|
||||
static void Assignment(DATA_TYPE& rDstData, const DATA_TYPE& rSrcData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rData - reference to the memory placement of new object.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline void CDynamicTraits<DATA_TYPE>::Constructor(DATA_TYPE& rData)
|
||||
{
|
||||
rData = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData - reference to the memory placement of deleted object.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline void CDynamicTraits<DATA_TYPE>::Destructor(DATA_TYPE& rData)
|
||||
{
|
||||
delete rData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rDstData - reference to the memory placement of destination object.
|
||||
* @param rSrcData - reference to the memory placement of source object.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline void CDynamicTraits<DATA_TYPE>::Assignment(DATA_TYPE& rDstData, const DATA_TYPE& rSrcData)
|
||||
{
|
||||
delete rDstData;
|
||||
rDstData = rSrcData;
|
||||
}
|
||||
|
||||
/// Data comparator traits.
|
||||
template <typename DATA_TYPE>
|
||||
class CCompareTraits
|
||||
{
|
||||
public:
|
||||
/// Determines whatever two elements are equal to each other.
|
||||
static bool Compare(const DATA_TYPE& rData1, const DATA_TYPE& rData2);
|
||||
/// Compares two elements according to their order.
|
||||
static int OrderedCompare(const DATA_TYPE& rData1, const DATA_TYPE& rData2);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return true if elements are equal.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline bool CCompareTraits<DATA_TYPE>::Compare(const DATA_TYPE& rData1, const DATA_TYPE& rData2)
|
||||
{
|
||||
return (rData1 == rData2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return comparison result:
|
||||
* - < 0 if first element is less than second element;
|
||||
* - = 0 if first element is equal to the second element;
|
||||
* - > 0 if first element is greater than second element.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
int CCompareTraits<DATA_TYPE>::OrderedCompare(const DATA_TYPE& rData1, const DATA_TYPE& rData2)
|
||||
{
|
||||
if (rData1 < rData2)
|
||||
return -1;
|
||||
else if (rData2 < rData1)
|
||||
return +1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Explicit template specialization for strings.
|
||||
template <> class CCompareTraits<TCHAR*>
|
||||
{
|
||||
public:
|
||||
/// Determines whatever two elements are equal to each other.
|
||||
static bool Compare(TCHAR * const & rData1, TCHAR * const & rData2);
|
||||
/// Compares two elements according to their order.
|
||||
static int OrderedCompare(TCHAR * const & rData1, TCHAR * const & rData2);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return true if elements are equal.
|
||||
*/
|
||||
inline bool CCompareTraits<TCHAR*>::Compare(TCHAR * const & rData1, TCHAR * const & rData2)
|
||||
{
|
||||
return (_tcscmp(rData1, rData2) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return comparison result:
|
||||
* - < 0 if first element is less than second element;
|
||||
* - = 0 if first element is equal to the second element;
|
||||
* - > 0 if first element is greater than second element.
|
||||
*/
|
||||
inline int CCompareTraits<TCHAR*>::OrderedCompare(TCHAR * const & rData1, TCHAR * const & rData2)
|
||||
{
|
||||
return _tcscmp(rData1, rData2);
|
||||
}
|
||||
|
||||
/// Explicit template specialization for strings.
|
||||
template <> class CCompareTraits<const TCHAR*>
|
||||
{
|
||||
public:
|
||||
/// Determines whatever two elements are equal to each other.
|
||||
static bool Compare(TCHAR const * const & rData1, TCHAR const * const & rData2);
|
||||
/// Compares two elements according to their order.
|
||||
static int OrderedCompare(TCHAR const * const & rData1, TCHAR const * const & rData2);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return true if elements are equal.
|
||||
*/
|
||||
inline bool CCompareTraits<const TCHAR*>::Compare(TCHAR const * const & rData1, TCHAR const * const & rData2)
|
||||
{
|
||||
return (_tcscmp(rData1, rData2) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return comparison result:
|
||||
* - < 0 if first element is less than second element;
|
||||
* - = 0 if first element is equal to the second element;
|
||||
* - > 0 if first element is greater than second element.
|
||||
*/
|
||||
inline int CCompareTraits<const TCHAR*>::OrderedCompare(TCHAR const * const & rData1, TCHAR const * const & rData2)
|
||||
{
|
||||
return _tcscmp(rData1, rData2);
|
||||
}
|
||||
|
||||
/// Comparator traits used for incomparable objects.
|
||||
template <typename DATA_TYPE>
|
||||
class CIncomparableTraits
|
||||
{
|
||||
public:
|
||||
/// Determines whatever two elements are equal to each other.
|
||||
static bool Compare(const DATA_TYPE& rData1, const DATA_TYPE& rData2);
|
||||
/// Compares two elements according to their order.
|
||||
static int OrderedCompare(const DATA_TYPE& rData1, const DATA_TYPE& rData2);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return true if elements are equal.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
inline bool CIncomparableTraits<DATA_TYPE>::Compare(const DATA_TYPE& /*rData1*/, const DATA_TYPE& /*rData2*/)
|
||||
{
|
||||
_ASSERT(FALSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData1 - reference to the first element.
|
||||
* @param rData2 - reference to the second element.
|
||||
* @return comparison result:
|
||||
* - < 0 if first element is less than second element;
|
||||
* - = 0 if first element is equal to the second element;
|
||||
* - > 0 if first element is greater than second element.
|
||||
*/
|
||||
template <typename DATA_TYPE>
|
||||
int CIncomparableTraits<DATA_TYPE>::OrderedCompare(const DATA_TYPE& /*rData1*/, const DATA_TYPE& /*rData2*/)
|
||||
{
|
||||
_ASSERT(FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Hash key traits.
|
||||
template <typename KEY_TYPE>
|
||||
class CHashTraits
|
||||
{
|
||||
public:
|
||||
/// Computes the hash value for the given object instance.
|
||||
static unsigned HashKey(const KEY_TYPE& key);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param key - hash value must be generated for this object.
|
||||
* @return hash value of the given object.
|
||||
*/
|
||||
template <typename KEY_TYPE>
|
||||
inline unsigned CHashTraits<KEY_TYPE>::HashKey(const KEY_TYPE& key)
|
||||
{
|
||||
return ((unsigned)key >> 4);
|
||||
}
|
||||
|
||||
/// Explicit template specialization for string hash tables.
|
||||
template <> class CHashTraits<CStrHolder>
|
||||
{
|
||||
public:
|
||||
/// Computes the hash value for the given object instance.
|
||||
static unsigned HashKey(const CStrHolder& strKey);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param strKey - hash value must be generated for this string.
|
||||
* @return hash value of the given object.
|
||||
*/
|
||||
inline unsigned CHashTraits<CStrHolder>::HashKey(const CStrHolder& strKey)
|
||||
{
|
||||
extern unsigned GetStringHashValue(const TCHAR* pszKey);
|
||||
return GetStringHashValue((PCTSTR)strKey);
|
||||
}
|
||||
|
||||
/// Explicit template specialization for string hash tables.
|
||||
template <> class CHashTraits<CStrStream>
|
||||
{
|
||||
public:
|
||||
/// Computes the hash value for the given object instance.
|
||||
static unsigned HashKey(const CStrStream& strKey);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param strKey - hash value must be generated for this string.
|
||||
* @return hash value of the given object.
|
||||
*/
|
||||
inline unsigned CHashTraits<CStrStream>::HashKey(const CStrStream& strKey)
|
||||
{
|
||||
extern unsigned GetStringHashValue(const TCHAR* pszKey);
|
||||
return GetStringHashValue((PCTSTR)strKey);
|
||||
}
|
||||
|
||||
/// Explicit template specialization for string hash tables.
|
||||
template <> class CHashTraits<TCHAR*>
|
||||
{
|
||||
public:
|
||||
/// Computes the hash value for the given object instance.
|
||||
static unsigned HashKey(TCHAR * const & pszKey);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param pszKey - hash value must be generated for this string.
|
||||
* @return hash value of the given object.
|
||||
*/
|
||||
inline unsigned CHashTraits<TCHAR*>::HashKey(TCHAR * const & pszKey)
|
||||
{
|
||||
extern unsigned GetStringHashValue(const TCHAR* pszKey);
|
||||
return GetStringHashValue(pszKey);
|
||||
}
|
||||
|
||||
/// Explicit template specialization for string hash tables.
|
||||
template <> class CHashTraits<const TCHAR*>
|
||||
{
|
||||
public:
|
||||
/// Computes the hash value for the given object instance.
|
||||
static unsigned HashKey(TCHAR const * const & pszKey);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param pszKey - hash value must be generated for this string.
|
||||
* @return hash value of the given object.
|
||||
*/
|
||||
inline unsigned CHashTraits<const TCHAR*>::HashKey(TCHAR const * const & pszKey)
|
||||
{
|
||||
extern unsigned GetStringHashValue(const TCHAR* pszKey);
|
||||
return GetStringHashValue(pszKey);
|
||||
}
|
||||
238
third-party/BugTrap-1.3-57bd515/source/CompleteBugTrap.cfg
vendored
Normal file
238
third-party/BugTrap-1.3-57bd515/source/CompleteBugTrap.cfg
vendored
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
# Doxyfile 1.4.4
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = BugTrap
|
||||
PROJECT_NUMBER = 1.0
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = YES
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = NO
|
||||
INLINE_INFO = NO
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = YES
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = NO
|
||||
GENERATE_TESTLIST = NO
|
||||
GENERATE_BUGLIST = NO
|
||||
GENERATE_DEPRECATEDLIST= NO
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = NO
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE = mkdoc.log
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT =
|
||||
FILE_PATTERNS = *.h \
|
||||
*.cpp
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 2
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = HTML
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = YES
|
||||
CHM_FILE = CompleteBugTrap.chm
|
||||
HHC_LOCATION = "C:\Program Files\HTML Help Workshop\hhc.exe"
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 200
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT =
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT =
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT =
|
||||
MAN_EXTENSION =
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
SEARCH_INCLUDES = NO
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = __cplusplus \
|
||||
_BTWND_INITIALIZER_() \
|
||||
_BTDLG_INITIALIZER_() \
|
||||
__AFX_H__ \
|
||||
__ATLWIN_H__ \
|
||||
_EXCEPTION_
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = NO
|
||||
PERL_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
168
third-party/BugTrap-1.3-57bd515/source/DescribeErrorDlg.cpp
vendored
Normal file
168
third-party/BugTrap-1.3-57bd515/source/DescribeErrorDlg.cpp
vendored
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Describe Error dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "DescribeErrorDlg.h"
|
||||
#include "BugTrapUI.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "WaitCursor.h"
|
||||
#include "LayoutManager.h"
|
||||
#include "Globals.h"
|
||||
#include "MemStream.h"
|
||||
#include "Encoding.h"
|
||||
#include "textFormat.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUI BugTrap Graphical User Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Control layouts for Send Mail dialog.
|
||||
static LAYOUT_INFO g_arrDescribeErrorLayout[] =
|
||||
{
|
||||
LAYOUT_INFO(IDC_DETAILS, ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_BOTTOM),
|
||||
LAYOUT_INFO(IDOK, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_RIGHT, ALIGN_BOTTOM),
|
||||
LAYOUT_INFO(IDCANCEL, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_RIGHT, ALIGN_BOTTOM)
|
||||
};
|
||||
|
||||
/// Dialog layout manager.
|
||||
static CLayoutManager g_LayoutMgr;
|
||||
|
||||
/**
|
||||
* @brief WM_COMMAND handler of Send Mail dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param id - control ID.
|
||||
* @param hwndCtl - control handle.
|
||||
* @param codeNotify - notification code.
|
||||
*/
|
||||
static void DescribeErrorDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
switch (codeNotify)
|
||||
{
|
||||
case BN_CLICKED:
|
||||
switch (id)
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
CWaitCursor wait(true);
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_DETAILS);
|
||||
int nTextLength = GetWindowTextLength(hwndCtl) + 1;
|
||||
PTSTR pszMessage = new TCHAR[nTextLength];
|
||||
if (! pszMessage)
|
||||
return;
|
||||
GetWindowText(hwndCtl, pszMessage, nTextLength);
|
||||
if (*pszMessage)
|
||||
{
|
||||
TCHAR szFileName[MAX_PATH];
|
||||
PathCombine(szFileName, g_szInternalReportFolder, _T("message.txt"));
|
||||
HANDLE hFile = CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
WriteFile(hFile, g_arrUTF8Preamble, sizeof(g_arrUTF8Preamble), &dwWritten, NULL);
|
||||
CMemStream MemStream(nTextLength);
|
||||
CUTF8EncStream EncStream(&MemStream);
|
||||
EncStream.WriteUTF8Bin(pszMessage);
|
||||
DWORD dwMessageLength = (DWORD)MemStream.GetLength();
|
||||
WriteFile(hFile, MemStream.GetBuffer(), dwMessageLength, &dwWritten, NULL);
|
||||
CloseHandle(hFile);
|
||||
g_pSymEngine->AppendFileToReport(g_szInternalReportFilePath, szFileName);
|
||||
}
|
||||
}
|
||||
delete[] pszMessage;
|
||||
EndDialog(hwnd, TRUE);
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, FALSE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_INITDIALOG handler of Send Mail dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hwndFocus - system-defined focus window.
|
||||
* @param lParam - user-defined parameter.
|
||||
* @return true to setup focus to system-defined control.
|
||||
*/
|
||||
static BOOL DescribeErrorDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
lParam; hwndFocus;
|
||||
HWND hwndCtl;
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hBigAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)g_pResManager->m_hBigAppIcon);
|
||||
if (g_pResManager->m_hSmallAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_pResManager->m_hSmallAppIcon);
|
||||
CenterWindow(hwnd, GetParent(hwnd));
|
||||
g_LayoutMgr.InitLayout(hwnd, g_arrDescribeErrorLayout, countof(g_arrDescribeErrorLayout));
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_DETAILS);
|
||||
SetFocus(hwndCtl);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_SIZE handler of Send Mail dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param state - window state.
|
||||
* @param cx - window width.
|
||||
* @param cy - window height.
|
||||
*/
|
||||
static void DescribeErrorDlg_OnSize(HWND hwnd, UINT state, int cx, int cy)
|
||||
{
|
||||
hwnd; cx; cy; state;
|
||||
g_LayoutMgr.ApplyLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_GETMINMAXINFO handler of Send Mail State dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param pMinMaxInfo - window min-max info.
|
||||
*/
|
||||
static void DescribeErrorDlg_OnGetMinMaxInfo(HWND hwnd, PMINMAXINFO pMinMaxInfo)
|
||||
{
|
||||
hwnd;
|
||||
pMinMaxInfo->ptMinTrackSize = g_LayoutMgr.GetMinTrackSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dialog procedure of Send Mail dialog.
|
||||
* @param hwndDlg - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - 1st message parameter.
|
||||
* @param lParam - 2nd message parameter.
|
||||
* @return message result.
|
||||
*/
|
||||
INT_PTR CALLBACK DescribeErrorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
HANDLE_MSG(hwndDlg, WM_INITDIALOG, DescribeErrorDlg_OnInitDialog);
|
||||
HANDLE_MSG(hwndDlg, WM_COMMAND, DescribeErrorDlg_OnCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_SIZE, DescribeErrorDlg_OnSize);
|
||||
HANDLE_MSG(hwndDlg, WM_GETMINMAXINFO, DescribeErrorDlg_OnGetMinMaxInfo);
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
17
third-party/BugTrap-1.3-57bd515/source/DescribeErrorDlg.h
vendored
Normal file
17
third-party/BugTrap-1.3-57bd515/source/DescribeErrorDlg.h
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Describe Error dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
INT_PTR CALLBACK DescribeErrorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
896
third-party/BugTrap-1.3-57bd515/source/Encoding.cpp
vendored
Normal file
896
third-party/BugTrap-1.3-57bd515/source/Encoding.cpp
vendored
Normal file
|
|
@ -0,0 +1,896 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Text encoding/decoding.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "Encoding.h"
|
||||
#include "MemStream.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "TextFormat.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/// Maximal 7-bit ASCII value.
|
||||
#define ASCII_MAX 0x007F
|
||||
/// Non-ASCII character value.
|
||||
#define NON_ASCII_CHAR 0x80
|
||||
/// Maximal UTF-8 2-byte sequence (32 * 64 = 2048).
|
||||
#define UTF8_2_MAX 0x07FF
|
||||
/// Maximal UTF-8 3-byte sequence (16 * 64 * 64 = 2048).
|
||||
#define UTF8_3_MAX 0xFFFF
|
||||
/// Prefix of UTF-8 2-byte sequence.
|
||||
#define UTF8_1ST_OF_2 0xC0 // 110xxxxx
|
||||
/// Prefix of UTF-8 3-byte sequence.
|
||||
#define UTF8_1ST_OF_3 0xE0 // 1110xxxx
|
||||
/// Prefix of UTF-8 4-byte sequence.
|
||||
#define UTF8_1ST_OF_4 0xF0 // 11110xxx
|
||||
/// Prefix of UTF-8 bytes from sequence.
|
||||
#define UTF8_TRAIL 0x80 // 10xxxxxx
|
||||
|
||||
/// Single object instance.
|
||||
CUTF8Decoder CUTF8Decoder::m_instance;
|
||||
/// Single object instance.
|
||||
CUTF16LeDecoder CUTF16LeDecoder::m_instance;
|
||||
/// Single object instance.
|
||||
CUTF16BeDecoder CUTF16BeDecoder::m_instance;
|
||||
/// Single object instance.
|
||||
CAnsiDecoder CAnsiDecoder::m_instance;
|
||||
|
||||
/**
|
||||
* @param pchValue - pointer to the character normally stored in the string.
|
||||
* @param nCharSize - upon return keeps character size.
|
||||
* @return Unicode character value.
|
||||
*/
|
||||
static DWORD GetUnicodeValue(const TCHAR* pchValue, size_t& nCharSize)
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
WCHAR arrUnicodeChar[2];
|
||||
arrUnicodeChar[0] = arrUnicodeChar[1] = 0;
|
||||
nCharSize = IsDBCSLeadByte(*pchValue) ? 2 : 1;
|
||||
MultiByteToWideChar(CP_ACP, 0, pchValue, (int)nCharSize, arrUnicodeChar, countof(arrUnicodeChar));
|
||||
#else
|
||||
const WCHAR* arrUnicodeChar = pchValue;
|
||||
#endif
|
||||
DWORD dwUnicodeChar;
|
||||
if ((HIGH_SURROGATE_START <= arrUnicodeChar[0] && arrUnicodeChar[0] <= HIGH_SURROGATE_END) &&
|
||||
(LOW_SURROGATE_START <= arrUnicodeChar[1] && arrUnicodeChar[1] <= LOW_SURROGATE_END))
|
||||
{
|
||||
dwUnicodeChar = ((arrUnicodeChar[0] - HIGH_SURROGATE_START) << 10) + (arrUnicodeChar[1] - LOW_SURROGATE_START) + 0x10000;
|
||||
#ifdef _UNICODE
|
||||
nCharSize = 2;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef _UNICODE
|
||||
_ASSERTE(arrUnicodeChar[1] == 0);
|
||||
#endif
|
||||
dwUnicodeChar = arrUnicodeChar[0];
|
||||
#ifdef _UNICODE
|
||||
nCharSize = 1;
|
||||
#endif
|
||||
}
|
||||
return dwUnicodeChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwUnicodeChar - Unicode character value.
|
||||
* @return true if data has been successfully written.
|
||||
*/
|
||||
bool CUTF8EncStream::WriteUTF8Bin(DWORD dwUnicodeChar)
|
||||
{
|
||||
_ASSERTE(m_pOutputStream != NULL);
|
||||
if (dwUnicodeChar <= ASCII_MAX)
|
||||
{
|
||||
// 7-bit ASCII data is stored as-is
|
||||
if (! m_pOutputStream->WriteByte((BYTE)dwUnicodeChar))
|
||||
return false;
|
||||
}
|
||||
else if (dwUnicodeChar <= UTF8_2_MAX)
|
||||
{
|
||||
// Use upper 5 bits in first byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_1ST_OF_2 | ((dwUnicodeChar >> 6) & 0x1F))))
|
||||
return false;
|
||||
// Use lower 6 bits in second byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_TRAIL | (dwUnicodeChar & 0x3F))))
|
||||
return false;
|
||||
}
|
||||
else if (dwUnicodeChar <= UTF8_3_MAX)
|
||||
{
|
||||
// Use upper 4 bits in first byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_1ST_OF_3 | ((dwUnicodeChar >> 12) & 0x0F))))
|
||||
return false;
|
||||
// Use middle 6 bits in second byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_TRAIL | ((dwUnicodeChar >> 6) & 0x3F))))
|
||||
return false;
|
||||
// Use lower 6 bits in third byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_TRAIL | (dwUnicodeChar & 0x3F))))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use upper 3 bits in first byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_1ST_OF_4 | ((dwUnicodeChar >> 18) & 0x07))))
|
||||
return false;
|
||||
// Use middle 6 bits in second byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_TRAIL | ((dwUnicodeChar >> 12) & 0x3F))))
|
||||
return false;
|
||||
// Use middle 6 bits in third byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_TRAIL | ((dwUnicodeChar >> 6) & 0x3F))))
|
||||
return false;
|
||||
// Use lower 6 bits in fourth byte
|
||||
if (! m_pOutputStream->WriteByte((BYTE)(UTF8_TRAIL | (dwUnicodeChar & 0x3F))))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwUnicodeChar - Unicode character value.
|
||||
* @return true if data has been successfully written.
|
||||
*/
|
||||
bool CUTF8EncStream::WriteUTF8Hex(DWORD dwUnicodeChar)
|
||||
{
|
||||
_ASSERTE(m_pOutputStream != NULL);
|
||||
CHAR szHexValue[16];
|
||||
size_t nLength;
|
||||
if (dwUnicodeChar <= ASCII_MAX)
|
||||
{
|
||||
if (! m_pOutputStream->WriteByte((BYTE)dwUnicodeChar))
|
||||
return false;
|
||||
}
|
||||
else if (dwUnicodeChar <= UTF8_3_MAX)
|
||||
{
|
||||
nLength = sprintf_s(szHexValue, countof(szHexValue), "&#x%04lX;", dwUnicodeChar);
|
||||
if (! m_pOutputStream->WriteBytes((const BYTE*)szHexValue, nLength))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
nLength = sprintf_s(szHexValue, countof(szHexValue), "&#x%06lX;", dwUnicodeChar);
|
||||
if (! m_pOutputStream->WriteBytes((const BYTE*)szHexValue, nLength))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszString - string to be written.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
bool CUTF8EncStream::WriteUTF8Bin(PCTSTR pszString)
|
||||
{
|
||||
size_t nPosition = 0;
|
||||
while (pszString[nPosition] != _T('\0'))
|
||||
{
|
||||
size_t nCharSize;
|
||||
if (! WriteUTF8Bin(pszString + nPosition, nCharSize))
|
||||
return false;
|
||||
nPosition += nCharSize;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszString - string to be written.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
bool CUTF8EncStream::WriteUTF8Hex(PCTSTR pszString)
|
||||
{
|
||||
size_t nPosition = 0;
|
||||
while (pszString[nPosition] != _T('\0'))
|
||||
{
|
||||
size_t nCharSize;
|
||||
if (! WriteUTF8Hex(pszString + nPosition, nCharSize))
|
||||
return false;
|
||||
nPosition += nCharSize;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pchValue - pointer to the character normally stored in the string.
|
||||
* @param nCharSize - upon return keeps character size.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
bool CUTF8EncStream::WriteUTF8Bin(const TCHAR* pchValue, size_t& nCharSize)
|
||||
{
|
||||
DWORD dwUnicodeChar = GetUnicodeValue(pchValue, nCharSize);
|
||||
return WriteUTF8Bin(dwUnicodeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pchValue - pointer to the character normally stored in the string.
|
||||
* @param nCharSize - upon return keeps number of bytes in character.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
bool CUTF8EncStream::WriteUTF8Hex(const TCHAR* pchValue, size_t& nCharSize)
|
||||
{
|
||||
DWORD dwUnicodeChar = GetUnicodeValue(pchValue, nCharSize);
|
||||
return WriteUTF8Hex(dwUnicodeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a 32-bit integer in a compressed format to the buffer.
|
||||
* @param nValue - integer value.
|
||||
* @param pBuffer - pointer to the buffer.
|
||||
* @param nPosition - position in the buffer.
|
||||
* @param nBufferSize - size of output buffer.
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
bool Write7BitEncodedInt(size_t nValue, PBYTE pBuffer, size_t& nPosition, size_t nBufferSize)
|
||||
{
|
||||
size_t nOldPosition = nPosition;
|
||||
while (nValue >= 0x80)
|
||||
{
|
||||
if (nPosition >= nBufferSize)
|
||||
goto error;
|
||||
pBuffer[nPosition++] = (BYTE)(nValue | 0x80);
|
||||
nValue >>= 7;
|
||||
}
|
||||
if (nPosition < nBufferSize)
|
||||
{
|
||||
pBuffer[nPosition++] = (BYTE)nValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
error:
|
||||
nPosition = nOldPosition;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read a 32-bit integer in a compressed format to the buffer.
|
||||
* @param pBuffer - pointer to the buffer.
|
||||
* @param nPosition - position in the buffer.
|
||||
* @param nBufferSize - size of output buffer.
|
||||
* @return decoded integer value.
|
||||
*/
|
||||
size_t Read7BitEncodedInt(PBYTE pBuffer, size_t& nPosition, size_t nBufferSize)
|
||||
{
|
||||
size_t nValue = 0, nShift = 0;
|
||||
for (;;)
|
||||
{
|
||||
if (nPosition >= nBufferSize)
|
||||
break;
|
||||
BYTE bTempValue = pBuffer[nPosition++];
|
||||
nValue |= (bTempValue & 0x7F) << (nShift & 0x1F);
|
||||
nShift += 7;
|
||||
if ((bTempValue & 0x80) == 0)
|
||||
break;
|
||||
}
|
||||
return nValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write length prefixed Unicode string to the buffer.
|
||||
* @param rEncStream - shared encoder.
|
||||
* @param pszString - string value.
|
||||
* @param pBuffer - pointer to the buffer.
|
||||
* @param nPosition - position in the buffer.
|
||||
* @param nBufferSize - size of output buffer.
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
bool WriteBinaryString(CUTF8EncStream& rEncStream, PCTSTR pszString, PBYTE pBuffer, size_t& nPosition, size_t nBufferSize)
|
||||
{
|
||||
CStream* pStream = rEncStream.GetStream();
|
||||
_ASSERTE(pStream != NULL);
|
||||
if (pStream == NULL)
|
||||
return false;
|
||||
unsigned uStreamFeatures = pStream->GetFeatures();
|
||||
_ASSERTE((uStreamFeatures & (CStream::SF_GETLENGTH | CStream::SF_SETPOSITION)) == (CStream::SF_GETLENGTH | CStream::SF_SETPOSITION));
|
||||
if ((uStreamFeatures & (CStream::SF_GETLENGTH | CStream::SF_SETPOSITION)) != (CStream::SF_GETLENGTH | CStream::SF_SETPOSITION))
|
||||
return false;
|
||||
size_t nOldPosition = nPosition;
|
||||
rEncStream.Reset();
|
||||
rEncStream.WriteUTF8Bin(pszString);
|
||||
pStream->SetPosition(0, FILE_BEGIN);
|
||||
size_t nLength = pStream->GetLength();
|
||||
if (! Write7BitEncodedInt(nLength, pBuffer, nPosition, nBufferSize))
|
||||
return false;
|
||||
if (nBufferSize - nPosition >= nLength)
|
||||
{
|
||||
size_t nNumRead = pStream->ReadBytes(pBuffer + nPosition, nLength);
|
||||
_ASSERTE(nNumRead == nLength);
|
||||
if (nNumRead == nLength)
|
||||
{
|
||||
nPosition += nLength;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
nPosition = nOldPosition;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write length prefixed Unicode string to the buffer.
|
||||
* @param pszString - string value.
|
||||
* @param pBuffer - pointer to the buffer.
|
||||
* @param nPosition - position in the buffer.
|
||||
* @param nBufferSize - size of output buffer.
|
||||
* @return true if operation has been completed successfully.
|
||||
*/
|
||||
bool WriteBinaryString(PCTSTR pszString, PBYTE pBuffer, size_t& nPosition, size_t nBufferSize)
|
||||
{
|
||||
CMemStream MemStream;
|
||||
CUTF8EncStream EncStream(&MemStream);
|
||||
return WriteBinaryString(EncStream, pszString, pBuffer, nPosition, nBufferSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode UTF-8 character to normal character.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param arrChar - output buffer for the character.
|
||||
* @param nCharSize - number of symbols in one character.
|
||||
* @return number of bytes in one character.
|
||||
*/
|
||||
size_t UTF8DecodeChar(const BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{
|
||||
nCharSize = MAXSIZE_T;
|
||||
if (nNumBytes == 0)
|
||||
return 0;
|
||||
BYTE bValue = pBytes[0];
|
||||
DWORD dwUnicodeChar;
|
||||
size_t nNumBytesInChar;
|
||||
if ((bValue & UTF8_1ST_OF_4) == UTF8_1ST_OF_4)
|
||||
{
|
||||
if (4 > nNumBytes)
|
||||
return 0;
|
||||
nNumBytesInChar = 4;
|
||||
dwUnicodeChar = ((DWORD)pBytes[0] & ~UTF8_1ST_OF_4 & 0x07) << 18;
|
||||
dwUnicodeChar |= ((DWORD)pBytes[1] & ~UTF8_TRAIL & 0x3F) << 12;
|
||||
dwUnicodeChar |= ((DWORD)pBytes[2] & ~UTF8_TRAIL & 0x3F) << 6;
|
||||
dwUnicodeChar |= (DWORD)pBytes[3] & ~UTF8_TRAIL;
|
||||
}
|
||||
else if ((bValue & UTF8_1ST_OF_3) == UTF8_1ST_OF_3)
|
||||
{
|
||||
if (3 > nNumBytes)
|
||||
return 0;
|
||||
nNumBytesInChar = 3;
|
||||
dwUnicodeChar = ((DWORD)pBytes[0] & ~UTF8_1ST_OF_3 & 0x0F) << 12;
|
||||
dwUnicodeChar |= ((DWORD)pBytes[1] & ~UTF8_TRAIL & 0x3F) << 6;
|
||||
dwUnicodeChar |= (DWORD)pBytes[2] & ~UTF8_TRAIL;
|
||||
}
|
||||
else if ((bValue & UTF8_1ST_OF_2) == UTF8_1ST_OF_2)
|
||||
{
|
||||
if (2 > nNumBytes)
|
||||
return 0;
|
||||
nNumBytesInChar = 2;
|
||||
dwUnicodeChar = ((DWORD)pBytes[0] & ~UTF8_1ST_OF_2 & 0x1F) << 6;
|
||||
dwUnicodeChar |= (DWORD)pBytes[1] & ~UTF8_TRAIL;
|
||||
}
|
||||
else if ((bValue & NON_ASCII_CHAR) == 0)
|
||||
{
|
||||
if (1 > nNumBytes)
|
||||
return 0;
|
||||
nNumBytesInChar = 1;
|
||||
dwUnicodeChar = (DWORD)pBytes[0];
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
const WCHAR* arrUnicodeChar = (const WCHAR*)&dwUnicodeChar;
|
||||
#ifdef _UNICODE
|
||||
if ((HIGH_SURROGATE_START <= arrUnicodeChar[0] && arrUnicodeChar[0] <= HIGH_SURROGATE_END) &&
|
||||
(LOW_SURROGATE_START <= arrUnicodeChar[1] && arrUnicodeChar[1] <= LOW_SURROGATE_END))
|
||||
{
|
||||
nCharSize = 2;
|
||||
arrChar[0] = arrUnicodeChar[0];
|
||||
arrChar[1] = arrUnicodeChar[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
nCharSize = 1;
|
||||
arrChar[0] = arrUnicodeChar[0];
|
||||
_ASSERTE(arrUnicodeChar[1] == 0);
|
||||
}
|
||||
#else
|
||||
size_t nWordsInChar;
|
||||
if ((HIGH_SURROGATE_START <= arrUnicodeChar[0] && arrUnicodeChar[0] <= HIGH_SURROGATE_END) &&
|
||||
(LOW_SURROGATE_START <= arrUnicodeChar[1] && arrUnicodeChar[1] <= LOW_SURROGATE_END))
|
||||
{
|
||||
nWordsInChar = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
nWordsInChar = 1;
|
||||
}
|
||||
nCharSize = WideCharToMultiByte(CP_ACP, 0, arrUnicodeChar, (int)nWordsInChar, arrChar, countof(arrChar), NULL, NULL);
|
||||
#endif
|
||||
return nNumBytesInChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode UTF-16 character to normal character.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param arrChar - output buffer for the character.
|
||||
* @param nCharSize - number of symbols in one character.
|
||||
* @return number of bytes in one character.
|
||||
*/
|
||||
size_t UTF16BeDecodeChar(BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{
|
||||
if (UTF16BeToLeChar(pBytes, nNumBytes) < 0)
|
||||
{
|
||||
nCharSize = MAXSIZE_T;
|
||||
return 0;
|
||||
}
|
||||
return UTF16LeDecodeChar(pBytes, nNumBytes, arrChar, nCharSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode UTF-16 character to normal character.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param arrChar - output buffer for the character.
|
||||
* @param nCharSize - number of symbols in one character.
|
||||
* @return number of bytes in one character.
|
||||
*/
|
||||
size_t UTF16LeDecodeChar(const BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{
|
||||
size_t nNumBytesInChar = GetUnicodeCharSize(pBytes);
|
||||
if (nNumBytes >= nNumBytesInChar)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
_ASSERTE(nNumBytesInChar == sizeof(WCHAR) || nNumBytesInChar == 2 * sizeof(WCHAR));
|
||||
arrChar[0] = *(const WCHAR*)pBytes;
|
||||
if (nNumBytesInChar == 2 * sizeof(WCHAR))
|
||||
arrChar[1] = *((const WCHAR*)pBytes + 1);
|
||||
nCharSize = nNumBytesInChar / sizeof(WCHAR);
|
||||
#else
|
||||
nCharSize = WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)pBytes, (int)nNumBytesInChar, arrChar, countof(arrChar), NULL, NULL) / sizeof(WCHAR);
|
||||
if (nCharSize == 0)
|
||||
nNumBytesInChar = 0;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
nCharSize = MAXSIZE_T;
|
||||
return nNumBytesInChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode Ansi character to normal character.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param arrChar - output buffer for the character.
|
||||
* @param nCharSize - number of symbols in one character.
|
||||
* @return number of bytes in one character.
|
||||
*/
|
||||
size_t AnsiDecodeChar(const BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{
|
||||
int nNumBytesInChar = IsDBCSLeadByte(*pBytes) ? 2 : 1;
|
||||
if (nNumBytes >= (size_t)nNumBytesInChar)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
nCharSize = MultiByteToWideChar(CP_ACP, 0, (const CHAR*)pBytes, nNumBytesInChar, arrChar, countof(arrChar));
|
||||
if (nCharSize == 0)
|
||||
nNumBytesInChar = 0;
|
||||
#else
|
||||
arrChar[0] = *(const CHAR*)pBytes;
|
||||
if (nNumBytesInChar == 2)
|
||||
arrChar[1] = *((const CHAR*)pBytes + 1);
|
||||
nCharSize = nNumBytesInChar;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
nCharSize = MAXSIZE_T;
|
||||
return nNumBytesInChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode UTF-8 string to normal text.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param pszString - decoded string.
|
||||
* @param nBufferSize - size of output buffer (in characters).
|
||||
* @return number of characters in resulting string including null-terminator.
|
||||
*/
|
||||
size_t UTF8DecodeString(const BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{
|
||||
if (! nBufferSize)
|
||||
return 0;
|
||||
bool bAddNullTerminator;
|
||||
if (nNumBytes == MAXSIZE_T)
|
||||
{
|
||||
nNumBytes = strlen((PCSTR)pBytes);
|
||||
--nBufferSize;
|
||||
bAddNullTerminator = true;
|
||||
}
|
||||
else
|
||||
bAddNullTerminator = false;
|
||||
size_t nBytePos = 0, nCharPos = 0;
|
||||
while (nBytePos < nNumBytes)
|
||||
{
|
||||
TCHAR arrChar[2];
|
||||
size_t nCharSize;
|
||||
size_t nNumBytesInChar = UTF8DecodeChar(pBytes + nBytePos, nNumBytes - nBytePos, arrChar, nCharSize);
|
||||
if (nNumBytesInChar == 0 || nCharPos + nCharSize > nBufferSize)
|
||||
break;
|
||||
nBytePos += nNumBytesInChar;
|
||||
pszString[nCharPos++] = arrChar[0];
|
||||
if (nCharSize > 1)
|
||||
pszString[nCharPos++] = arrChar[1];
|
||||
}
|
||||
if (bAddNullTerminator)
|
||||
pszString[nCharPos++] = _T('\0');
|
||||
return nCharPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode UTF-16 string to normal text.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param pszString - decoded string.
|
||||
* @param nBufferSize - size of output buffer (in characters).
|
||||
* @return number of characters in resulting string including null-terminator.
|
||||
*/
|
||||
size_t UTF16BeDecodeString(BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{
|
||||
if (UTF16BeToLeString(pBytes, nNumBytes) == 0)
|
||||
return 0;
|
||||
return UTF8DecodeString(pBytes, nNumBytes, pszString, nBufferSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode UTF-16 string to normal text.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param pszString - decoded string.
|
||||
* @param nBufferSize - size of output buffer (in characters).
|
||||
* @return number of characters in resulting string including null-terminator.
|
||||
*/
|
||||
size_t UTF16LeDecodeString(const BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
if (nNumBytes == MAXSIZE_T)
|
||||
nNumBytes = (wcslen((const WCHAR*)pBytes) + 1) * sizeof(WCHAR);
|
||||
if (nNumBytes > nBufferSize)
|
||||
nNumBytes = nBufferSize;
|
||||
CopyMemory(pszString, pBytes, nNumBytes);
|
||||
return nNumBytes;
|
||||
#else
|
||||
return WideCharToMultiByte(CP_ACP, 0, (const WCHAR*)pBytes, (int)(nNumBytes / sizeof(WCHAR)), pszString, (int)nBufferSize, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Decode Ansi string to normal text.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - number of bytes in the array.
|
||||
* @param pszString - decoded string.
|
||||
* @param nBufferSize - size of output buffer (in characters).
|
||||
* @return number of characters in resulting string including null-terminator.
|
||||
*/
|
||||
size_t AnsiDecodeString(const BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
return MultiByteToWideChar(CP_ACP, 0, (const CHAR*)pBytes, (int)nNumBytes, pszString, (int)nBufferSize);
|
||||
#else
|
||||
if (nNumBytes == MAXSIZE_T)
|
||||
nNumBytes = strlen((const CHAR*)pBytes) + 1;
|
||||
if (nNumBytes > nBufferSize)
|
||||
nNumBytes = nBufferSize;
|
||||
CopyMemory(pszString, pBytes, nNumBytes);
|
||||
return nNumBytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get number of bytes representing one character.
|
||||
* @param pBytes - array of bytes.
|
||||
* @return number of bytes in one character.
|
||||
*/
|
||||
size_t GetUTF8CharSize(const BYTE* pBytes)
|
||||
{
|
||||
BYTE bValue = *pBytes;
|
||||
if ((bValue & UTF8_1ST_OF_4) == UTF8_1ST_OF_4)
|
||||
return 4;
|
||||
else if ((bValue & UTF8_1ST_OF_3) == UTF8_1ST_OF_3)
|
||||
return 3;
|
||||
else if ((bValue & UTF8_1ST_OF_2) == UTF8_1ST_OF_2)
|
||||
return 2;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Used to check if next character starts surrogate pair.
|
||||
* @param pBytes - array of bytes.
|
||||
* @return true if next character is high surrogate character.
|
||||
*/
|
||||
bool IsUnicodeLeadChar(const BYTE* pBytes)
|
||||
{
|
||||
WCHAR chValue = *((const WCHAR*)pBytes);
|
||||
return (HIGH_SURROGATE_START <= chValue && chValue <= HIGH_SURROGATE_END);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get number of bytes representing one character.
|
||||
* @param pBytes - array of bytes.
|
||||
* @return number of bytes in one character.
|
||||
*/
|
||||
size_t GetUnicodeCharSize(const BYTE* pBytes)
|
||||
{
|
||||
WCHAR chValue1 = ((const WCHAR*)pBytes)[0];
|
||||
if (HIGH_SURROGATE_START <= chValue1 && chValue1 <= HIGH_SURROGATE_END)
|
||||
{
|
||||
WCHAR chValue2 = ((const WCHAR*)pBytes)[1];
|
||||
if (LOW_SURROGATE_START <= chValue2 && chValue2 <= LOW_SURROGATE_END)
|
||||
return (2 * sizeof(WCHAR));
|
||||
}
|
||||
return (sizeof(WCHAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert UTF-16 value from big-endian to low-endian format.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - buffer size in bytes.
|
||||
* @return number of bytes in one character.
|
||||
*/
|
||||
size_t UTF16BeToLeChar(BYTE* pBytes, size_t nNumBytes)
|
||||
{
|
||||
if (nNumBytes < 1)
|
||||
return MAXSIZE_T;
|
||||
WCHAR chValue1 = SWAP16(((WCHAR*)pBytes)[0]);
|
||||
if (LOW_SURROGATE_START <= chValue1 && chValue1 <= LOW_SURROGATE_END)
|
||||
{
|
||||
if (nNumBytes < 2)
|
||||
return MAXSIZE_T;
|
||||
WCHAR chValue2 = SWAP16(((WCHAR*)pBytes)[1]);
|
||||
if (HIGH_SURROGATE_START <= chValue2 && chValue2 <= HIGH_SURROGATE_END)
|
||||
{
|
||||
((WCHAR*)pBytes)[0] = chValue2;
|
||||
((WCHAR*)pBytes)[1] = chValue1;
|
||||
return (2 * sizeof(WCHAR));
|
||||
}
|
||||
}
|
||||
*(WCHAR*)pBytes = chValue1;
|
||||
return (sizeof(WCHAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert UTF-16 value from big-endian to low-endian format.
|
||||
* @param pBytes - array of bytes.
|
||||
* @param nNumBytes - buffer size in bytes.
|
||||
* @return number of processed bytes.
|
||||
*/
|
||||
size_t UTF16BeToLeString(BYTE* pBytes, size_t nNumBytes)
|
||||
{
|
||||
size_t nBytePos = 0;
|
||||
while (nBytePos < nNumBytes)
|
||||
{
|
||||
size_t nResult = UTF16BeToLeChar(pBytes + nBytePos, nNumBytes - nBytePos);
|
||||
if (nResult == MAXSIZE_T)
|
||||
break;
|
||||
nBytePos += nResult;
|
||||
}
|
||||
return nBytePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pchValue - pointer to the character normally stored in the string.
|
||||
* @param nCharSize - upon return keeps character size.
|
||||
* @return size of the character after UTF-8 encoding.
|
||||
*/
|
||||
size_t GetCharSizeInUTF8(const TCHAR* pchValue, size_t& nCharSize)
|
||||
{
|
||||
DWORD dwUnicodeChar = GetUnicodeValue(pchValue, nCharSize);
|
||||
if (dwUnicodeChar <= ASCII_MAX)
|
||||
return 1;
|
||||
else if (dwUnicodeChar <= UTF8_2_MAX)
|
||||
return 2;
|
||||
else if (dwUnicodeChar <= UTF8_3_MAX)
|
||||
return 3;
|
||||
else
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszString - input string that needs to be encoded in UTF-8 format.
|
||||
* @return size of the character encoded in UTF-8 format.
|
||||
*/
|
||||
size_t GetStringSizeInUTF8(PCTSTR pszString)
|
||||
{
|
||||
_ASSERTE(pszString != NULL);
|
||||
size_t nUTF8StringSize = 0;
|
||||
while (*pszString)
|
||||
{
|
||||
size_t nCharSize;
|
||||
nUTF8StringSize += GetCharSizeInUTF8(pszString, nCharSize);
|
||||
pszString += nCharSize;
|
||||
}
|
||||
return nUTF8StringSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eEncoding - text encoding.
|
||||
* @return pointer to corresponding decoder object.
|
||||
*/
|
||||
CBaseDecoder* CBaseDecoder::GetDecoder(TEXT_ENCODING eEncoding)
|
||||
{
|
||||
switch (eEncoding)
|
||||
{
|
||||
case TXTENC_UTF8:
|
||||
return &CUTF8Decoder::GetInstance();
|
||||
case TXTENC_UTF16LE:
|
||||
return &CUTF16LeDecoder::GetInstance();
|
||||
case TXTENC_UTF16BE:
|
||||
return &CUTF16BeDecoder::GetInstance();
|
||||
case TXTENC_ANSI:
|
||||
return &CAnsiDecoder::GetInstance();
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszEncoding - text encoding.
|
||||
* @return pointer to corresponding decoder object.
|
||||
*/
|
||||
CBaseDecoder* CBaseDecoder::GetDecoder(PCTSTR pszEncoding)
|
||||
{
|
||||
if (_tcsicmp(pszEncoding, _T("UTF-8")) == 0)
|
||||
return &CUTF8Decoder::GetInstance();
|
||||
else if (_tcsicmp(pszEncoding, _T("UTF-16")) == 0)
|
||||
return &CUTF16LeDecoder::GetInstance();
|
||||
else
|
||||
return &CAnsiDecoder::GetInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pInputStream - input stream.
|
||||
*/
|
||||
void CDecInputStream::SetInputStream(CInputStream* pInputStream)
|
||||
{
|
||||
m_pInputStream = pInputStream;
|
||||
m_nInputBufferPos = 0;
|
||||
m_nInputBufferLength = 0;
|
||||
m_bEndOfFile = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nNumBytes - number of bytes to read.
|
||||
* @return number of bytes available in a buffer.
|
||||
*/
|
||||
size_t CDecInputStream::FillBuffer(size_t nNumBytes)
|
||||
{
|
||||
_ASSERTE(m_pInputStream != NULL);
|
||||
size_t nBytesLeft = m_nInputBufferLength - m_nInputBufferPos;
|
||||
if (nBytesLeft < nNumBytes && ! m_bEndOfFile)
|
||||
{
|
||||
MoveMemory(m_arrInputBuffer, m_arrInputBuffer + m_nInputBufferPos, nBytesLeft);
|
||||
m_nInputBufferPos = 0;
|
||||
size_t nFreeSize = sizeof(m_arrInputBuffer) - nBytesLeft;
|
||||
size_t nBytesRead = m_pInputStream->ReadBytes(m_arrInputBuffer + nBytesLeft, nFreeSize);
|
||||
if (nBytesRead == MAXSIZE_T)
|
||||
return MAXSIZE_T;
|
||||
m_nInputBufferLength = nBytesLeft + nBytesRead;
|
||||
m_bEndOfFile = nBytesRead < nFreeSize;
|
||||
nBytesLeft = m_nInputBufferLength;
|
||||
}
|
||||
return nBytesLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param arrChar - character data.
|
||||
* @return number of characters in one symbol.
|
||||
*/
|
||||
size_t CDecInputStream::ReadChar(TCHAR arrChar[2])
|
||||
{
|
||||
// one character in UTF-16 encoding may require up to 4 bytes
|
||||
// one character in UTF-8 encoding may require up to 4 bytes
|
||||
// one character in ANSI encoding may require up to 2 bytes
|
||||
// make sure at least one character can be read from the buffer
|
||||
// (i.e. at least 4 bytes should be available)
|
||||
size_t nBytesLeft = FillBuffer(4);
|
||||
if (nBytesLeft == 0 || nBytesLeft == MAXSIZE_T)
|
||||
return nBytesLeft;
|
||||
size_t nNumBytesInChar, nCharSize;
|
||||
_ASSERTE(m_pDecoder != NULL);
|
||||
nNumBytesInChar = m_pDecoder->DecodeChar(m_arrInputBuffer + m_nInputBufferPos, nBytesLeft, arrChar, nCharSize);
|
||||
if (nCharSize > 0)
|
||||
m_nInputBufferPos += nNumBytesInChar;
|
||||
else
|
||||
++m_nInputBufferPos;
|
||||
return nCharSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eEncoding - stream encoding.
|
||||
* @return true if stream encoding has been read from the stream.
|
||||
*/
|
||||
bool CDecInputStream::ReadPreamble(TEXT_ENCODING& eEncoding)
|
||||
{
|
||||
// make sure at least 4 bytes are available in a buffer;
|
||||
// this should be enough for any preamble.
|
||||
size_t nBytesLeft = FillBuffer(4);
|
||||
if (nBytesLeft == 0 || nBytesLeft == MAXSIZE_T)
|
||||
return false;
|
||||
PBYTE pBytes = m_arrInputBuffer + m_nInputBufferPos;
|
||||
if (nBytesLeft >= sizeof(g_arrUTF16LEPreamble) &&
|
||||
memcmp(pBytes, g_arrUTF16LEPreamble, sizeof(g_arrUTF16LEPreamble)) == 0)
|
||||
{
|
||||
eEncoding = TXTENC_UTF16LE;
|
||||
m_nInputBufferPos += sizeof(g_arrUTF16LEPreamble);
|
||||
return true;
|
||||
}
|
||||
else if (nBytesLeft >= sizeof(g_arrUTF16BEPreamble) &&
|
||||
memcmp(pBytes, g_arrUTF16BEPreamble, sizeof(g_arrUTF16BEPreamble)) == 0)
|
||||
{
|
||||
eEncoding = TXTENC_UTF16BE;
|
||||
m_nInputBufferPos += sizeof(g_arrUTF16BEPreamble);
|
||||
return true;
|
||||
}
|
||||
else if (nBytesLeft >= sizeof(g_arrUTF8Preamble) &&
|
||||
memcmp(pBytes, g_arrUTF8Preamble, sizeof(g_arrUTF8Preamble)) == 0)
|
||||
{
|
||||
eEncoding = TXTENC_UTF8;
|
||||
m_nInputBufferPos += sizeof(g_arrUTF8Preamble);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param arrChar - character data.
|
||||
* @return number of characters in one symbol.
|
||||
*/
|
||||
size_t CStrInputStream::ReadChar(TCHAR arrChar[2])
|
||||
{
|
||||
_ASSERTE(m_pStrStream != NULL);
|
||||
size_t nLength = m_pStrStream->GetLength();
|
||||
if (m_nPosition >= nLength)
|
||||
return 0;
|
||||
arrChar[0] = ((PCTSTR)m_pStrStream)[m_nPosition++];
|
||||
#ifdef _UNICODE
|
||||
if (IsUnicodeLeadChar((const BYTE*)arrChar))
|
||||
#else
|
||||
if (IsDBCSLeadByte(*arrChar))
|
||||
#endif
|
||||
{
|
||||
if (m_nPosition >= nLength)
|
||||
{
|
||||
_ASSERT(FALSE);
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
arrChar[1] = ((PCTSTR)m_pStrStream)[m_nPosition++];
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if byte order mark has been read from the stream.
|
||||
*/
|
||||
bool CCharInputStream::CheckEncoding(void)
|
||||
{
|
||||
TEXT_ENCODING eEncoding;
|
||||
if (! ReadPreamble(eEncoding))
|
||||
return false;
|
||||
return SetDecoder(CBaseDecoder::GetDecoder(eEncoding));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eDefaultEncoding - default encoding.
|
||||
* @return true if byte order mark has been read from the stream.
|
||||
*/
|
||||
bool CCharInputStream::CheckEncoding(TEXT_ENCODING eDefaultEncoding)
|
||||
{
|
||||
TEXT_ENCODING eEncoding;
|
||||
bool bResult = ReadPreamble(eEncoding);
|
||||
if (! bResult)
|
||||
eEncoding = eDefaultEncoding;
|
||||
return SetDecoder(CBaseDecoder::GetDecoder(eEncoding));
|
||||
}
|
||||
534
third-party/BugTrap-1.3-57bd515/source/Encoding.h
vendored
Normal file
534
third-party/BugTrap-1.3-57bd515/source/Encoding.h
vendored
Normal file
|
|
@ -0,0 +1,534 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Text encoding/decoding.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Stream.h"
|
||||
#include "StrStream.h"
|
||||
|
||||
#ifndef HIGH_SURROGATE_START
|
||||
/// Lower value of Unicode high-surrogate character.
|
||||
#define HIGH_SURROGATE_START 0xD800
|
||||
/// Higher value of Unicode high-surrogate character.
|
||||
#define HIGH_SURROGATE_END 0xDBFF
|
||||
/// Lower value of Unicode low-surrogate character.
|
||||
#define LOW_SURROGATE_START 0xDC00
|
||||
/// Higher value of Unicode low-surrogate character.
|
||||
#define LOW_SURROGATE_END 0xDFFF
|
||||
#endif
|
||||
|
||||
/// Text encoding.
|
||||
enum TEXT_ENCODING
|
||||
{
|
||||
/// Ansi code page.
|
||||
TXTENC_ANSI,
|
||||
/// UTF-8 encoding.
|
||||
TXTENC_UTF8,
|
||||
/// UTF-16/UCS-2, little-endian encoding.
|
||||
TXTENC_UTF16LE,
|
||||
/// UTF-16/UCS-2, big-endian encoding.
|
||||
TXTENC_UTF16BE
|
||||
};
|
||||
|
||||
/// UTF-8 encoder.
|
||||
class CUTF8EncStream
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CUTF8EncStream(void);
|
||||
/// Initialize the object.
|
||||
explicit CUTF8EncStream(CStream* pStream);
|
||||
/// Initialize the object.
|
||||
explicit CUTF8EncStream(COutputStream* pOutputStream);
|
||||
/// Get data stream.
|
||||
CStream* GetStream(void) const;
|
||||
/// Get data stream.
|
||||
COutputStream* GetOutputStream(void) const;
|
||||
/// Set data stream.
|
||||
void SetStream(CStream* pStream);
|
||||
/// Set data stream.
|
||||
void SetOutputStream(COutputStream* pOutputStream);
|
||||
/// Write data to the buffer.
|
||||
bool WriteByte(BYTE bValue);
|
||||
/// Write data to the buffer.
|
||||
bool WriteByte(BYTE bValue, size_t nCount);
|
||||
/// Write data to the buffer.
|
||||
bool WriteBytes(const BYTE* pBytes, size_t nCount);
|
||||
/// Write data to the buffer.
|
||||
bool WriteAscii(PCSTR pszString);
|
||||
/// Write data to the buffer.
|
||||
bool WriteUTF8Bin(const TCHAR* pchValue, size_t& nCharSize);
|
||||
/// Write data to the buffer.
|
||||
bool WriteUTF8Bin(PCTSTR pszString);
|
||||
/// Write data to the buffer.
|
||||
bool WriteUTF8Hex(const TCHAR* pchValue, size_t& nCharSize);
|
||||
/// Write data to the buffer.
|
||||
bool WriteUTF8Hex(PCTSTR pszString);
|
||||
/// Write other pre-encoded data to the buffer.
|
||||
bool Write(const CUTF8EncStream& rEncStream);
|
||||
/// Clear data in the buffer.
|
||||
void Reset(void);
|
||||
|
||||
private:
|
||||
/// Object can't be copied.
|
||||
CUTF8EncStream(const CUTF8EncStream& rStream);
|
||||
/// Object can't be copied.
|
||||
CUTF8EncStream& operator=(const CUTF8EncStream& rStream);
|
||||
|
||||
/// Write Unicode character value in UTF-8 encoding.
|
||||
bool WriteUTF8Bin(DWORD dwUnicodeChar);
|
||||
/// Write Unicode character value in UTF-8 encoding.
|
||||
bool WriteUTF8Hex(DWORD dwUnicodeChar);
|
||||
|
||||
/// Data stream.
|
||||
CStream* m_pStream;
|
||||
/// Data stream.
|
||||
COutputStream* m_pOutputStream;
|
||||
};
|
||||
|
||||
inline CUTF8EncStream::CUTF8EncStream(void) : m_pStream(NULL), m_pOutputStream(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pStream - data stream.
|
||||
*/
|
||||
inline CUTF8EncStream::CUTF8EncStream(CStream* pStream) : m_pStream(pStream), m_pOutputStream(pStream)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pOutputStream - data stream.
|
||||
*/
|
||||
inline CUTF8EncStream::CUTF8EncStream(COutputStream* pOutputStream) : m_pStream(NULL), m_pOutputStream(pOutputStream)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return data stream.
|
||||
*/
|
||||
inline CStream* CUTF8EncStream::GetStream(void) const
|
||||
{
|
||||
return m_pStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return data stream.
|
||||
*/
|
||||
inline COutputStream* CUTF8EncStream::GetOutputStream(void) const
|
||||
{
|
||||
return m_pOutputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pStream - data stream.
|
||||
*/
|
||||
inline void CUTF8EncStream::SetStream(CStream* pStream)
|
||||
{
|
||||
m_pStream = pStream;
|
||||
m_pOutputStream = pStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pOutputStream - data stream.
|
||||
*/
|
||||
inline void CUTF8EncStream::SetOutputStream(COutputStream* pOutputStream)
|
||||
{
|
||||
m_pStream = NULL;
|
||||
m_pOutputStream = pOutputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszString - string to be written.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
inline bool CUTF8EncStream::WriteAscii(PCSTR pszString)
|
||||
{
|
||||
_ASSERTE(m_pOutputStream != NULL);
|
||||
size_t nLength = strlen(pszString);
|
||||
return (m_pOutputStream->WriteBytes((const BYTE*)pszString, nLength) == nLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pBytes - bytes array to be written.
|
||||
* @param nCount - number of bytes to be added.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
inline bool CUTF8EncStream::WriteBytes(const BYTE* pBytes, size_t nCount)
|
||||
{
|
||||
_ASSERTE(m_pOutputStream != NULL);
|
||||
return (m_pOutputStream->WriteBytes(pBytes, nCount) == nCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bValue - byte value to be written.
|
||||
* @param nCount - number of bytes to be added.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
inline bool CUTF8EncStream::WriteByte(BYTE bValue, size_t nCount)
|
||||
{
|
||||
_ASSERTE(m_pOutputStream != NULL);
|
||||
return (m_pOutputStream->WriteByte(bValue, nCount) == nCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bValue - byte value to be written.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
inline bool CUTF8EncStream::WriteByte(BYTE bValue)
|
||||
{
|
||||
_ASSERTE(m_pOutputStream != NULL);
|
||||
return m_pOutputStream->WriteByte(bValue);
|
||||
}
|
||||
|
||||
inline void CUTF8EncStream::Reset(void)
|
||||
{
|
||||
if (m_pOutputStream != NULL)
|
||||
{
|
||||
_ASSERTE((m_pOutputStream->GetFeatures() & COutputStream::SF_SETLENGTH) != 0);
|
||||
m_pOutputStream->SetLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEncStream - another encoder object.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
inline bool CUTF8EncStream::Write(const CUTF8EncStream& rEncStream)
|
||||
{
|
||||
_ASSERTE(m_pOutputStream != NULL);
|
||||
_ASSERTE(rEncStream.m_pStream != NULL);
|
||||
return (m_pOutputStream->WriteStream(rEncStream.m_pStream) >= 0);
|
||||
}
|
||||
|
||||
// Other encoding/decoding functions.
|
||||
size_t Read7BitEncodedInt(PBYTE pBuffer, size_t& nPosition, size_t nBufferSize);
|
||||
bool Write7BitEncodedInt(size_t nValue, PBYTE pBuffer, size_t& nPosition, size_t nBufferSize);
|
||||
bool WriteBinaryString(CUTF8EncStream& rEncStream, PCTSTR pszString, PBYTE pBuffer, size_t& nPosition, size_t nBufferSize);
|
||||
bool WriteBinaryString(PCTSTR pszString, PBYTE pBuffer, size_t& nPosition, size_t nBufferSize);
|
||||
size_t UTF8DecodeChar(const BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize);
|
||||
size_t UTF16BeDecodeChar(BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize);
|
||||
size_t UTF16LeDecodeChar(const BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize);
|
||||
size_t AnsiDecodeChar(const BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize);
|
||||
size_t UTF8DecodeString(const BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize);
|
||||
size_t UTF16BeDecodeString(BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize);
|
||||
size_t UTF16LeDecodeString(const BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize);
|
||||
size_t AnsiDecodeString(const BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize);
|
||||
size_t GetUTF8CharSize(const BYTE* pBytes);
|
||||
size_t GetUnicodeCharSize(const BYTE* pBytes);
|
||||
bool IsUnicodeLeadChar(const BYTE* pBytes);
|
||||
size_t UTF16BeToLeChar(BYTE* pBytes, size_t nNumBytes);
|
||||
size_t UTF16BeToLeString(BYTE* pBytes, size_t nNumBytes);
|
||||
size_t GetCharSizeInUTF8(const TCHAR* pchValue, size_t& nCharSize);
|
||||
size_t GetStringSizeInUTF8(PCTSTR pszString);
|
||||
|
||||
/// Base decoder interface.
|
||||
class CBaseDecoder
|
||||
{
|
||||
public:
|
||||
/// Object destructor.
|
||||
virtual ~CBaseDecoder(void) { }
|
||||
/// Return current encoding.
|
||||
virtual TEXT_ENCODING GetEncoding(void) = 0;
|
||||
/// Decode single character.
|
||||
virtual size_t DecodeChar(BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize) = 0;
|
||||
/// Decode string of characters.
|
||||
virtual size_t DecodeString(BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize) = 0;
|
||||
/// Get appropriate decoder base.
|
||||
static CBaseDecoder* GetDecoder(TEXT_ENCODING eEncoding);
|
||||
/// Get appropriate decoder base.
|
||||
static CBaseDecoder* GetDecoder(PCTSTR pszEncoding);
|
||||
};
|
||||
|
||||
/// UTF-8 decoder.
|
||||
class CUTF8Decoder : public CBaseDecoder
|
||||
{
|
||||
public:
|
||||
/// Return current encoding.
|
||||
virtual TEXT_ENCODING GetEncoding(void)
|
||||
{ return TXTENC_UTF8; }
|
||||
/// Decode single character.
|
||||
virtual size_t DecodeChar(BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{ return UTF8DecodeChar(pBytes, nNumBytes, arrChar, nCharSize); }
|
||||
/// Decode string of characters.
|
||||
virtual size_t DecodeString(BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{ return UTF8DecodeString(pBytes, nNumBytes, pszString, nBufferSize); }
|
||||
/// Get single object instance.
|
||||
static CUTF8Decoder& GetInstance(void)
|
||||
{ return m_instance; }
|
||||
|
||||
private:
|
||||
/// Hides object constructor.
|
||||
CUTF8Decoder(void) { }
|
||||
/// Object can't be copied.
|
||||
CUTF8Decoder(const CUTF8Decoder& rDecoder);
|
||||
/// Object can't be copied.
|
||||
CUTF8Decoder& operator=(const CUTF8Decoder& rDecoder);
|
||||
|
||||
/// Single object instance.
|
||||
static CUTF8Decoder m_instance;
|
||||
};
|
||||
|
||||
/// UTF-16 decoder.
|
||||
class CUTF16LeDecoder : public CBaseDecoder
|
||||
{
|
||||
public:
|
||||
/// Return current encoding.
|
||||
virtual TEXT_ENCODING GetEncoding(void)
|
||||
{ return TXTENC_UTF16LE; }
|
||||
/// Decode single character.
|
||||
virtual size_t DecodeChar(BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{ return UTF16LeDecodeChar(pBytes, nNumBytes, arrChar, nCharSize); }
|
||||
/// Decode string of characters.
|
||||
virtual size_t DecodeString(BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{ return UTF16LeDecodeString(pBytes, nNumBytes, pszString, nBufferSize); }
|
||||
/// Get single object instance.
|
||||
static CUTF16LeDecoder& GetInstance(void)
|
||||
{ return m_instance; }
|
||||
|
||||
private:
|
||||
/// Hides object constructor.
|
||||
CUTF16LeDecoder(void) { }
|
||||
/// Object can't be copied.
|
||||
CUTF16LeDecoder(const CUTF16LeDecoder& rDecoder);
|
||||
/// Object can't be copied.
|
||||
CUTF16LeDecoder& operator=(const CUTF16LeDecoder& rDecoder);
|
||||
|
||||
/// Single object instance.
|
||||
static CUTF16LeDecoder m_instance;
|
||||
};
|
||||
|
||||
/// UTF-16 decoder.
|
||||
class CUTF16BeDecoder : public CBaseDecoder
|
||||
{
|
||||
public:
|
||||
/// Return current encoding.
|
||||
virtual TEXT_ENCODING GetEncoding(void)
|
||||
{ return TXTENC_UTF16BE; }
|
||||
/// Decode single character.
|
||||
virtual size_t DecodeChar(BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{ return UTF16BeDecodeChar(pBytes, nNumBytes, arrChar, nCharSize); }
|
||||
/// Decode string of characters.
|
||||
virtual size_t DecodeString(BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{ return UTF16BeDecodeString(pBytes, nNumBytes, pszString, nBufferSize); }
|
||||
/// Get single object instance.
|
||||
static CUTF16BeDecoder& GetInstance(void)
|
||||
{ return m_instance; }
|
||||
|
||||
private:
|
||||
/// Hides object constructor.
|
||||
CUTF16BeDecoder(void) { }
|
||||
/// Object can't be copied.
|
||||
CUTF16BeDecoder(const CUTF16BeDecoder& rDecoder);
|
||||
/// Object can't be copied.
|
||||
CUTF16BeDecoder& operator=(const CUTF16BeDecoder& rDecoder);
|
||||
|
||||
/// Single object instance.
|
||||
static CUTF16BeDecoder m_instance;
|
||||
};
|
||||
|
||||
/// Ansi decoder.
|
||||
class CAnsiDecoder : public CBaseDecoder
|
||||
{
|
||||
public:
|
||||
/// Return current encoding.
|
||||
virtual TEXT_ENCODING GetEncoding(void)
|
||||
{ return TXTENC_ANSI; }
|
||||
/// Decode single character.
|
||||
virtual size_t DecodeChar(BYTE* pBytes, size_t nNumBytes, TCHAR arrChar[2], size_t& nCharSize)
|
||||
{ return AnsiDecodeChar(pBytes, nNumBytes, arrChar, nCharSize); }
|
||||
/// Decode string of characters.
|
||||
virtual size_t DecodeString(BYTE* pBytes, size_t nNumBytes, PTSTR pszString, size_t nBufferSize)
|
||||
{ return AnsiDecodeString(pBytes, nNumBytes, pszString, nBufferSize); }
|
||||
/// Get single object instance.
|
||||
static CAnsiDecoder& GetInstance(void)
|
||||
{ return m_instance; }
|
||||
|
||||
private:
|
||||
/// Hides object constructor.
|
||||
CAnsiDecoder(void) { }
|
||||
/// Object can't be copied.
|
||||
CAnsiDecoder(const CAnsiDecoder& rDecoder);
|
||||
/// Object can't be copied.
|
||||
CAnsiDecoder& operator=(const CAnsiDecoder& rDecoder);
|
||||
|
||||
/// Single object instance.
|
||||
static CAnsiDecoder m_instance;
|
||||
};
|
||||
|
||||
/// Text input stream.
|
||||
class CCharInputStream
|
||||
{
|
||||
public:
|
||||
/// Object destructor.
|
||||
virtual ~CCharInputStream(void) { }
|
||||
/// Read character from the stream.
|
||||
virtual size_t ReadChar(TCHAR arrChar[2]) = 0;
|
||||
/// Get byte order mark. This function is optional.
|
||||
virtual bool ReadPreamble(TEXT_ENCODING& /*eEncoding*/)
|
||||
{ return false; }
|
||||
/// Get text decoder. This function is optional.
|
||||
virtual CBaseDecoder* GetDecoder(void) const
|
||||
{ return NULL; }
|
||||
/// Set text decoder. This function is optional.
|
||||
virtual bool SetDecoder(CBaseDecoder* /*pDecoder*/)
|
||||
{ return false; }
|
||||
/// Get stream name. This function is optional.
|
||||
virtual bool GetName(PTSTR pszName, size_t nNameSize) const
|
||||
{ if (nNameSize > 0) *pszName = _T('0'); return false; }
|
||||
/// Read and apply byte order mark.
|
||||
bool CheckEncoding(void);
|
||||
/// Read and apply byte order mark.
|
||||
bool CheckEncoding(TEXT_ENCODING eDefaultEncoding);
|
||||
};
|
||||
|
||||
/// Decoding input stream.
|
||||
class CDecInputStream : public CCharInputStream
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
explicit CDecInputStream(CInputStream* pInputStream = NULL);
|
||||
/// Read character from the stream.
|
||||
virtual size_t ReadChar(TCHAR arrChar[2]);
|
||||
/// Get byte order mark. This function is optional.
|
||||
virtual bool ReadPreamble(TEXT_ENCODING& eEncoding);
|
||||
/// Get text decoder.
|
||||
virtual CBaseDecoder* GetDecoder(void) const;
|
||||
/// Set text decoder.
|
||||
virtual bool SetDecoder(CBaseDecoder* pDecoder);
|
||||
/// Get stream name.
|
||||
virtual bool GetName(PTSTR pszName, size_t nNameSize) const;
|
||||
/// Attach input stream to the object.
|
||||
void SetInputStream(CInputStream* pInputStream);
|
||||
/// Get pointer to the input stream.
|
||||
CInputStream* GetInputStream(void) const;
|
||||
|
||||
private:
|
||||
/// Object can't be copied.
|
||||
CDecInputStream(const CDecInputStream& rStream);
|
||||
/// Object can't be copied.
|
||||
CDecInputStream& operator=(const CDecInputStream& rStream);
|
||||
/// Fill buffer with bytes.
|
||||
size_t FillBuffer(size_t nNumBytes);
|
||||
|
||||
/// Input stream attached to the object.
|
||||
CInputStream* m_pInputStream;
|
||||
/// Text decoder.
|
||||
CBaseDecoder* m_pDecoder;
|
||||
/// Binary buffer for encoded data.
|
||||
BYTE m_arrInputBuffer[1024];
|
||||
/// Position in the buffer.
|
||||
size_t m_nInputBufferPos;
|
||||
/// Number of bytes in the buffer.
|
||||
size_t m_nInputBufferLength;
|
||||
/// True after reaching end of file.
|
||||
bool m_bEndOfFile;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param pInputStream - input stream.
|
||||
*/
|
||||
inline CDecInputStream::CDecInputStream(CInputStream* pInputStream)
|
||||
{
|
||||
SetDecoder(&CAnsiDecoder::GetInstance());
|
||||
SetInputStream(pInputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to input stream.
|
||||
*/
|
||||
inline CInputStream* CDecInputStream::GetInputStream(void) const
|
||||
{
|
||||
return m_pInputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to current decoder or @a NULL.
|
||||
*/
|
||||
inline CBaseDecoder* CDecInputStream::GetDecoder(void) const
|
||||
{
|
||||
return m_pDecoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pDecoder - pointer to the decoder or @a NULL.
|
||||
* @return true if decoding was successfully applied.
|
||||
*/
|
||||
inline bool CDecInputStream::SetDecoder(CBaseDecoder* pDecoder)
|
||||
{
|
||||
_ASSERTE(pDecoder != NULL);
|
||||
m_pDecoder = pDecoder;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszName - stream name buffer.
|
||||
* @param nNameSize - size of stream name buffer.
|
||||
* @return true if name was retrieved.
|
||||
*/
|
||||
inline bool CDecInputStream::GetName(PTSTR pszName, size_t nNameSize) const
|
||||
{
|
||||
_ASSERTE(m_pInputStream != NULL);
|
||||
return m_pInputStream->GetName(pszName, nNameSize);
|
||||
}
|
||||
|
||||
/// String input stream.
|
||||
class CStrInputStream : public CCharInputStream
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
explicit CStrInputStream(const CStrStream* pStrStream = NULL);
|
||||
/// Read character from the stream.
|
||||
virtual size_t ReadChar(TCHAR arrChar[2]);
|
||||
/// Attach input stream to the object.
|
||||
void SetStrStream(const CStrStream* pStrStream);
|
||||
/// Get pointer to the input stream.
|
||||
const CStrStream* GetStrStream(void) const;
|
||||
|
||||
private:
|
||||
/// Object can't be copied.
|
||||
CStrInputStream(const CStrInputStream& rStream);
|
||||
/// Object can't be copied.
|
||||
CStrInputStream& operator=(const CStrInputStream& rStream);
|
||||
|
||||
/// Stream attached to the object.
|
||||
const CStrStream* m_pStrStream;
|
||||
/// Current position in the stream.
|
||||
size_t m_nPosition;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param pStrStream - input stream.
|
||||
*/
|
||||
inline CStrInputStream::CStrInputStream(const CStrStream* pStrStream)
|
||||
{
|
||||
SetStrStream(pStrStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to input stream.
|
||||
*/
|
||||
inline const CStrStream* CStrInputStream::GetStrStream(void) const
|
||||
{
|
||||
return m_pStrStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pStrStream - input stream.
|
||||
*/
|
||||
inline void CStrInputStream::SetStrStream(const CStrStream* pStrStream)
|
||||
{
|
||||
m_pStrStream = pStrStream;
|
||||
m_nPosition = 0;
|
||||
}
|
||||
647
third-party/BugTrap-1.3-57bd515/source/EnumProcess.cpp
vendored
Normal file
647
third-party/BugTrap-1.3-57bd515/source/EnumProcess.cpp
vendored
Normal file
|
|
@ -0,0 +1,647 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Process enumerator.
|
||||
* Updated by: Maksim Pyatkovskiy.
|
||||
* Note: Based on code developed by Moliate.
|
||||
* Downloaded from: http://www.codeproject.com/threads/enumprocess.asp
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "EnumProcess.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/// Template for the error message.
|
||||
static const TCHAR szNAError[] = _T("N/A (%lu error)");
|
||||
|
||||
/// Custom parameter for Enum16Proc() function.
|
||||
struct CEnum16Param
|
||||
{
|
||||
/// Pointer to enumerator object.
|
||||
CEnumProcess* _this;
|
||||
/// NTVDM process ID.
|
||||
DWORD dwProcessID;
|
||||
};
|
||||
|
||||
|
||||
CEnumProcess::CModuleEntry::CModuleEntry(void)
|
||||
{
|
||||
*m_szModuleName = _T('\0');
|
||||
m_pLoadBase = NULL;
|
||||
m_dwModuleSize = 0;
|
||||
#ifdef READ_IMAGEHEADER
|
||||
m_pPreferredBase = NULL;
|
||||
m_dwPreferredSize = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
CEnumProcess::CProcessEntry::CProcessEntry(void)
|
||||
{
|
||||
m_dwProcessID = 0;
|
||||
m_hTask16 = 0;
|
||||
*m_szProcessName = _T('\0');
|
||||
}
|
||||
|
||||
CEnumProcess::CEnumProcess(void) :
|
||||
m_arrProcesses(0),
|
||||
#ifdef USE_VDMDBG
|
||||
m_arrProcesses16(0),
|
||||
#endif
|
||||
m_arrModules(0)
|
||||
{
|
||||
m_hPsApiDll = LoadLibrary(_T("PSAPI.DLL"));
|
||||
if (m_hPsApiDll)
|
||||
{
|
||||
// Setup variables
|
||||
m_arrProcesses.EnsureSize(256, false);
|
||||
m_dwCurrentProcess = 0;
|
||||
m_arrModules.EnsureSize(256, false);
|
||||
m_dwCurrentModule = 0;
|
||||
|
||||
// Find PSAPI functions
|
||||
FEnumProcesses = (PFEnumProcesses)GetProcAddress(m_hPsApiDll, "EnumProcesses");
|
||||
FEnumProcessModules = (PFEnumProcessModules)GetProcAddress(m_hPsApiDll, "EnumProcessModules");
|
||||
#ifdef _UNICODE
|
||||
FGetModuleFileNameEx = (PFGetModuleFileNameEx)GetProcAddress(m_hPsApiDll, "GetModuleFileNameExW");
|
||||
#else
|
||||
FGetModuleFileNameEx = (PFGetModuleFileNameEx)GetProcAddress(m_hPsApiDll, "GetModuleFileNameExA");
|
||||
#endif
|
||||
|
||||
OSVERSIONINFO osvi;
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
GetVersionEx(&osvi);
|
||||
if (osvi.dwMajorVersion >= 5) // Windows 2000 and newer
|
||||
if (osvi.dwMinorVersion == 0)
|
||||
m_dwSystemID = 2; // Windows 2000
|
||||
else
|
||||
m_dwSystemID = 4; // Windows XP and newer
|
||||
else
|
||||
m_dwSystemID = 8; // Windows NT
|
||||
}
|
||||
|
||||
m_hKernelDll = GetModuleHandle(_T("KERNEL32.DLL"));
|
||||
if (m_hKernelDll)
|
||||
{
|
||||
// Setup variables
|
||||
m_hProcessSnap = INVALID_HANDLE_VALUE;
|
||||
m_hModuleSnap = INVALID_HANDLE_VALUE;
|
||||
m_hThreadSnap = INVALID_HANDLE_VALUE;
|
||||
|
||||
// Find ToolHelp functions
|
||||
FCreateToolhelp32Snapshot = (PFCreateToolhelp32Snapshot)GetProcAddress(m_hKernelDll, "CreateToolhelp32Snapshot");
|
||||
FThread32First = (PFThread32First)GetProcAddress(m_hKernelDll, "Thread32First");
|
||||
FThread32Next = (PFThread32Next)GetProcAddress(m_hKernelDll, "Thread32Next");
|
||||
#ifdef _UNICODE
|
||||
FProcess32First = (PFProcess32First)GetProcAddress(m_hKernelDll, "Process32FirstW");
|
||||
FProcess32Next = (PFProcess32Next)GetProcAddress(m_hKernelDll, "Process32NextW");
|
||||
FModule32First = (PFModule32First)GetProcAddress(m_hKernelDll, "Module32FirstW");
|
||||
FModule32Next = (PFModule32Next)GetProcAddress(m_hKernelDll, "Module32NextW");
|
||||
#else
|
||||
FProcess32First = (PFProcess32First)GetProcAddress(m_hKernelDll, "Process32First");
|
||||
FProcess32Next = (PFProcess32Next)GetProcAddress(m_hKernelDll, "Process32Next");
|
||||
FModule32First = (PFModule32First)GetProcAddress(m_hKernelDll, "Module32First");
|
||||
FModule32Next = (PFModule32Next)GetProcAddress(m_hKernelDll, "Module32Next");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
m_hVmDbgDll = LoadLibrary(_T("VDMDBG.DLL"));
|
||||
if (m_hVmDbgDll)
|
||||
{
|
||||
// Find VDMdbg functions
|
||||
FVDMEnumTaskWOWEx = (PFVDMEnumTaskWOWEx)GetProcAddress(m_hVmDbgDll, "VDMEnumTaskWOWEx");
|
||||
m_arrProcesses16.EnsureSize(256, false);
|
||||
m_dwCurrentProcess16 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_dwAvailMethods = EM_NONE;
|
||||
// Does all PSAPI functions exist?
|
||||
if (m_hPsApiDll &&
|
||||
FEnumProcesses &&
|
||||
FEnumProcessModules &&
|
||||
FGetModuleFileNameEx)
|
||||
{
|
||||
m_dwAvailMethods |= EM_PSAPI;
|
||||
}
|
||||
|
||||
// How about ToolHelp?
|
||||
if (m_hKernelDll &&
|
||||
FCreateToolhelp32Snapshot &&
|
||||
FProcess32Next && FProcess32Next &&
|
||||
FModule32First && FModule32Next &&
|
||||
FThread32First && FThread32Next)
|
||||
{
|
||||
m_dwAvailMethods |= EM_TOOLHELP;
|
||||
}
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
// And 16-bit enumeration?
|
||||
if (m_hVmDbgDll &&
|
||||
FVDMEnumTaskWOWEx &&
|
||||
m_dwAvailMethods != EM_NONE)
|
||||
{
|
||||
m_dwAvailMethods |= EM_PROC16;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Find the preferred method of enumeration
|
||||
m_dwMethod = EM_NONE;
|
||||
if (m_dwAvailMethods & EM_TOOLHELP)
|
||||
m_dwMethod = EM_TOOLHELP;
|
||||
else if (m_dwAvailMethods & EM_PSAPI)
|
||||
m_dwMethod = EM_PSAPI;
|
||||
#ifdef USE_VDMDBG
|
||||
if (m_dwAvailMethods & EM_PROC16)
|
||||
m_dwMethod |= EM_PROC16;
|
||||
#endif
|
||||
}
|
||||
|
||||
CEnumProcess::~CEnumProcess(void)
|
||||
{
|
||||
Close();
|
||||
|
||||
if (m_hPsApiDll)
|
||||
FreeLibrary(m_hPsApiDll);
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
if (m_hVmDbgDll)
|
||||
FreeLibrary(m_hVmDbgDll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CEnumProcess::Close(void)
|
||||
{
|
||||
if (m_hKernelDll)
|
||||
{
|
||||
if (m_hThreadSnap != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(m_hThreadSnap);
|
||||
m_hThreadSnap = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if (m_hModuleSnap != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(m_hModuleSnap);
|
||||
m_hModuleSnap = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if (m_hProcessSnap != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(m_hProcessSnap);
|
||||
m_hProcessSnap = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
m_arrModules.DeleteAll(true);
|
||||
#ifdef USE_VDMDBG
|
||||
m_arrProcesses16.DeleteAll(true);
|
||||
#endif
|
||||
m_arrProcesses.DeleteAll(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwMethod - desirable enumeration method.
|
||||
*/
|
||||
void CEnumProcess::SetMethod(DWORD dwMethod)
|
||||
{
|
||||
if ((m_dwAvailMethods & dwMethod) == dwMethod)
|
||||
#ifdef USE_VDMDBG
|
||||
if (dwMethod != EM_PROC16)
|
||||
#endif
|
||||
m_dwMethod = dwMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEntry - process description entry.
|
||||
* @return true if there is information about process.
|
||||
*/
|
||||
BOOL CEnumProcess::GetCurrentProcess(CProcessEntry& rEntry)
|
||||
{
|
||||
m_arrProcesses.DeleteAll();
|
||||
m_dwCurrentProcess = 0;
|
||||
rEntry.m_hTask16 = NULL;
|
||||
rEntry.m_dwProcessID = GetCurrentProcessId();
|
||||
GetModuleFileName(NULL, rEntry.m_szProcessName, countof(rEntry.m_szProcessName));
|
||||
PCTSTR pszProcessName = PathFindFileName(rEntry.m_szProcessName);
|
||||
size_t nProcessName = _tcslen(pszProcessName);
|
||||
MoveMemory(rEntry.m_szProcessName, pszProcessName, (nProcessName + 1) * sizeof(TCHAR));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEntry - process description entry.
|
||||
* @return true if there is information about process.
|
||||
*/
|
||||
BOOL CEnumProcess::GetProcessFirst(CEnumProcess::CProcessEntry& rEntry)
|
||||
{
|
||||
if (m_dwMethod == EM_NONE)
|
||||
return FALSE;
|
||||
if (m_dwMethod & EM_TOOLHELP)
|
||||
{
|
||||
// Use ToolHelp functions
|
||||
if (m_hProcessSnap != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(m_hProcessSnap);
|
||||
m_hProcessSnap = FCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
if (m_hProcessSnap == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
m_pe.dwSize = sizeof(m_pe);
|
||||
if (! FProcess32First(m_hProcessSnap, &m_pe))
|
||||
return FALSE;
|
||||
rEntry.m_dwProcessID = m_pe.th32ProcessID;
|
||||
_tcscpy_s(rEntry.m_szProcessName, countof(rEntry.m_szProcessName), m_pe.szExeFile);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use PSAPI functions
|
||||
BOOL bResult;
|
||||
DWORD cbNeeded;
|
||||
DWORD dwArraySize = (DWORD)m_arrProcesses.GetSize();
|
||||
m_arrProcesses.SetCount(dwArraySize);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
cbNeeded = 0;
|
||||
dwArraySize = (DWORD)m_arrProcesses.GetCount();
|
||||
DWORD dwBufferSize = dwArraySize * sizeof(DWORD);
|
||||
bResult = FEnumProcesses(m_arrProcesses, dwBufferSize, &cbNeeded);
|
||||
|
||||
// We might need more memory here
|
||||
if (cbNeeded <= dwBufferSize)
|
||||
break;
|
||||
// Try again
|
||||
m_arrProcesses.SetCount(dwArraySize + dwArraySize);
|
||||
if (dwArraySize == (DWORD)m_arrProcesses.GetCount())
|
||||
break;
|
||||
}
|
||||
|
||||
m_dwCurrentProcess = 0;
|
||||
if (! bResult)
|
||||
return FALSE;
|
||||
m_arrProcesses.SetCount(cbNeeded / sizeof(DWORD));
|
||||
return FillPStructPSAPI(m_arrProcesses[(size_t)(m_dwCurrentProcess++)], rEntry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEntry - process description entry.
|
||||
* @return true if there is information about process.
|
||||
*/
|
||||
BOOL CEnumProcess::GetProcessNext(CEnumProcess::CProcessEntry& rEntry)
|
||||
{
|
||||
if (m_dwMethod == EM_NONE)
|
||||
return FALSE;
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
// We have some 16-bit processes to get
|
||||
if (m_dwCurrentProcess16 < m_arrProcesses16.GetCount())
|
||||
{
|
||||
rEntry = m_arrProcesses16[m_dwCurrentProcess16++];
|
||||
return TRUE;
|
||||
}
|
||||
rEntry.m_hTask16 = 0;
|
||||
#endif
|
||||
|
||||
if (m_dwMethod & EM_TOOLHELP)
|
||||
{
|
||||
// Use ToolHelp functions
|
||||
m_pe.dwSize = sizeof(m_pe);
|
||||
if (! FProcess32Next(m_hProcessSnap, &m_pe))
|
||||
return FALSE;
|
||||
rEntry.m_dwProcessID = m_pe.th32ProcessID;
|
||||
_tcscpy_s(rEntry.m_szProcessName, countof(rEntry.m_szProcessName), m_pe.szExeFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use PSAPI functions
|
||||
if (m_dwCurrentProcess >= (DWORD)m_arrProcesses.GetCount())
|
||||
return FALSE;
|
||||
if (! FillPStructPSAPI(m_arrProcesses[(size_t)(m_dwCurrentProcess++)], rEntry))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
// Check for 16-bit processes?
|
||||
if (EM_PROC16 & m_dwMethod)
|
||||
{
|
||||
// Is this a NTVDM?
|
||||
static const TCHAR szNTVDM[] = _T("NTVDM.EXE");
|
||||
static const DWORD dwNTVDMLen = countof(szNTVDM) - 1;
|
||||
DWORD dwProcessName = _tcslen(rEntry.m_szProcessName);
|
||||
if (dwProcessName >= dwNTVDMLen &&
|
||||
! _tcsicmp(rEntry.m_szProcessName + (dwProcessName - dwNTVDMLen), szNTVDM))
|
||||
{
|
||||
m_arrProcesses16.DeleteAll();
|
||||
CEnum16Param param;
|
||||
param._this = this;
|
||||
param.dwProcessID = rEntry.m_dwProcessID;
|
||||
FVDMEnumTaskWOWEx(rEntry.m_dwProcessID, (TASKENUMPROCEX)Enum16Proc, (LPARAM)¶m);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwProcessID - process ID.
|
||||
* @param rEntry - module description entry.
|
||||
* @return true if there is information about module.
|
||||
*/
|
||||
BOOL CEnumProcess::GetModuleFirst(DWORD dwProcessID, CEnumProcess::CModuleEntry& rEntry)
|
||||
{
|
||||
if (m_dwMethod == EM_NONE)
|
||||
return FALSE;
|
||||
if (m_dwMethod & EM_TOOLHELP)
|
||||
{
|
||||
// Use ToolHelp functions
|
||||
if (m_hModuleSnap != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(m_hModuleSnap);
|
||||
m_hModuleSnap = FCreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessID);
|
||||
if (m_hModuleSnap == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
m_me.dwSize = sizeof(m_me);
|
||||
if(! FModule32First(m_hModuleSnap, &m_me))
|
||||
return FALSE;
|
||||
_tcscpy_s(rEntry.m_szModuleName, countof(rEntry.m_szModuleName), m_me.szExePath);
|
||||
rEntry.m_pLoadBase = m_me.modBaseAddr;
|
||||
rEntry.m_dwModuleSize = m_me.modBaseSize;
|
||||
#ifdef READ_IMAGEHEADER
|
||||
GetPreferredModuleLocation(dwProcessID, m_me.modBaseAddr, rEntry.m_pPreferredBase, rEntry.m_dwPreferredSize);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use PSAPI functions
|
||||
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcessID);
|
||||
if (hProcess != NULL)
|
||||
{
|
||||
BOOL bResult;
|
||||
DWORD cbNeeded;
|
||||
DWORD dwArraySize = (DWORD)m_arrModules.GetSize();
|
||||
m_arrModules.SetCount(dwArraySize);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
cbNeeded = 0;
|
||||
dwArraySize = (DWORD)m_arrModules.GetCount();
|
||||
DWORD dwBufferSize = dwArraySize * sizeof(HMODULE);
|
||||
bResult = FEnumProcessModules(hProcess, m_arrModules, dwBufferSize, &cbNeeded);
|
||||
|
||||
// We might need more memory here
|
||||
if (cbNeeded <= dwBufferSize)
|
||||
break;
|
||||
// Try again
|
||||
m_arrModules.SetCount(dwArraySize + dwArraySize);
|
||||
if (dwArraySize == (DWORD)m_arrModules.GetCount())
|
||||
break;
|
||||
}
|
||||
|
||||
CloseHandle(hProcess);
|
||||
m_dwCurrentModule = 0;
|
||||
if (! bResult)
|
||||
return FALSE;
|
||||
m_arrModules.SetCount(cbNeeded / sizeof(HMODULE));
|
||||
return FillMStructPSAPI(dwProcessID, m_arrModules[(size_t)(m_dwCurrentModule++)], rEntry);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwProcessID - process ID.
|
||||
* @param rEntry - module description entry.
|
||||
* @return true if there is information about module.
|
||||
*/
|
||||
BOOL CEnumProcess::GetModuleNext(DWORD dwProcessID, CEnumProcess::CModuleEntry& rEntry)
|
||||
{
|
||||
if (m_dwMethod == EM_NONE)
|
||||
return FALSE;
|
||||
if (m_dwMethod & EM_TOOLHELP)
|
||||
{
|
||||
// Use ToolHelp functions
|
||||
m_me.dwSize = sizeof(m_me);
|
||||
if(! FModule32Next(m_hModuleSnap, &m_me))
|
||||
return FALSE;
|
||||
_tcscpy_s(rEntry.m_szModuleName, countof(rEntry.m_szModuleName), m_me.szExePath);
|
||||
rEntry.m_pLoadBase = m_me.modBaseAddr;
|
||||
rEntry.m_dwModuleSize = m_me.modBaseSize;
|
||||
#ifdef READ_IMAGEHEADER
|
||||
GetPreferredModuleLocation(dwProcessID, m_me.modBaseAddr, rEntry.m_pPreferredBase, rEntry.m_dwPreferredSize);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use PSAPI functions
|
||||
if (m_dwCurrentModule >= m_arrModules.GetCount())
|
||||
return FALSE;
|
||||
return FillMStructPSAPI(dwProcessID, m_arrModules[(size_t)(m_dwCurrentModule++)], rEntry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwProcessID - process ID.
|
||||
* @param rEntry - thread description entry.
|
||||
* @return true if there is information about thread.
|
||||
*/
|
||||
BOOL CEnumProcess::GetThreadFirst(DWORD dwProcessID, CEnumProcess::CThreadEntry& rEntry)
|
||||
{
|
||||
if (m_dwMethod == EM_NONE)
|
||||
return FALSE;
|
||||
if (m_dwMethod & EM_TOOLHELP)
|
||||
{
|
||||
// Use ToolHelp functions
|
||||
if (m_hThreadSnap != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(m_hThreadSnap);
|
||||
m_hThreadSnap = FCreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||
if (m_hThreadSnap == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
m_te.dwSize = sizeof(m_te);
|
||||
if(! FThread32First(m_hThreadSnap, &m_te))
|
||||
return FALSE;
|
||||
while (m_te.th32OwnerProcessID != dwProcessID)
|
||||
{
|
||||
m_te.dwSize = sizeof(m_te);
|
||||
if(! FThread32Next(m_hThreadSnap, &m_te))
|
||||
return FALSE;
|
||||
}
|
||||
rEntry.m_dwThreadID = m_te.th32ThreadID;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// PSAPI functions don't support threads enumeration.
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwProcessID - process ID.
|
||||
* @param rEntry - thread description entry.
|
||||
* @return true if there is information about thread.
|
||||
*/
|
||||
BOOL CEnumProcess::GetThreadNext(DWORD dwProcessID, CEnumProcess::CThreadEntry& rEntry)
|
||||
{
|
||||
if (m_dwMethod == EM_NONE)
|
||||
return FALSE;
|
||||
if (m_dwMethod & EM_TOOLHELP)
|
||||
{
|
||||
// Use ToolHelp functions
|
||||
do
|
||||
{
|
||||
m_te.dwSize = sizeof(m_te);
|
||||
if(! FThread32Next(m_hThreadSnap, &m_te))
|
||||
return FALSE;
|
||||
}
|
||||
while (m_te.th32OwnerProcessID != dwProcessID);
|
||||
rEntry.m_dwThreadID = m_te.th32ThreadID;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// PSAPI functions don't support threads enumeration.
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwProcessID - process ID.
|
||||
* @param rEntry - process description entry.
|
||||
* @return true if there is information about process.
|
||||
*/
|
||||
BOOL CEnumProcess::FillPStructPSAPI(DWORD dwProcessID, CEnumProcess::CProcessEntry& rEntry)
|
||||
{
|
||||
rEntry.m_dwProcessID = dwProcessID;
|
||||
// Open process to get file name
|
||||
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcessID);
|
||||
if (hProcess != NULL)
|
||||
{
|
||||
HMODULE hModule;
|
||||
DWORD dwSize = 0;
|
||||
// Get the first module (the process itself)
|
||||
if ((FEnumProcessModules(hProcess, &hModule, sizeof(hModule), &dwSize) || dwSize > 0) &&
|
||||
FGetModuleFileNameEx(hProcess, hModule, rEntry.m_szProcessName, countof(rEntry.m_szProcessName)))
|
||||
{
|
||||
PCTSTR pszProcessName = PathFindFileName(rEntry.m_szProcessName);
|
||||
size_t nProcessName = _tcslen(pszProcessName);
|
||||
MoveMemory(rEntry.m_szProcessName, pszProcessName, (nProcessName + 1) * sizeof(TCHAR));
|
||||
CloseHandle(hProcess);
|
||||
return TRUE;
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
}
|
||||
if (dwProcessID == 0)
|
||||
_tcscpy_s(rEntry.m_szProcessName, countof(rEntry.m_szProcessName), _T("System Idle Process"));
|
||||
else if (dwProcessID == m_dwSystemID)
|
||||
_tcscpy_s(rEntry.m_szProcessName, countof(rEntry.m_szProcessName), _T("System"));
|
||||
else
|
||||
_stprintf_s(rEntry.m_szProcessName, countof(rEntry.m_szProcessName), szNAError, GetLastError());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwProcessID - process ID.
|
||||
* @param hModule - module handle.
|
||||
* @param rEntry - process description module.
|
||||
* @return true if there is information about module.
|
||||
*/
|
||||
BOOL CEnumProcess::FillMStructPSAPI(DWORD dwProcessID, HMODULE hModule, CEnumProcess::CModuleEntry& rEntry)
|
||||
{
|
||||
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcessID);
|
||||
if (hProcess != NULL)
|
||||
{
|
||||
if (! FGetModuleFileNameEx(hProcess, hModule, rEntry.m_szModuleName, countof(rEntry.m_szModuleName)))
|
||||
_stprintf_s(rEntry.m_szModuleName, countof(rEntry.m_szModuleName), szNAError, GetLastError());
|
||||
rEntry.m_pLoadBase = (PVOID)hModule;
|
||||
rEntry.m_dwModuleSize = 0;
|
||||
#ifdef READ_IMAGEHEADER
|
||||
GetPreferredModuleLocation(dwProcessID, (PVOID)hModule, rEntry.m_pPreferredBase, rEntry.m_dwPreferredSize);
|
||||
#endif
|
||||
CloseHandle(hProcess);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef READ_IMAGEHEADER
|
||||
|
||||
/**
|
||||
* @param dwProcessID - process ID.
|
||||
* @param pModBase - base module address.
|
||||
* @param pPreferredBase - pointer to preferred module load address.
|
||||
* @param dwPreferredSize - preferred module size.
|
||||
* @return true if operation has been successful.
|
||||
*/
|
||||
BOOL CEnumProcess::GetPreferredModuleLocation(DWORD dwProcessID, PVOID pModBase, PVOID& pPreferredBase, DWORD& dwPreferredSize)
|
||||
{
|
||||
pPreferredBase = NULL;
|
||||
dwPreferredSize = 0;
|
||||
if (m_dwMethod == EM_NONE)
|
||||
return FALSE;
|
||||
HANDLE hProcess = OpenProcess(PROCESS_VM_READ, FALSE, dwProcessID);
|
||||
if (hProcess == NULL)
|
||||
return FALSE;
|
||||
IMAGE_DOS_HEADER idh;
|
||||
BOOL bResult = FALSE;
|
||||
// Read DOS header
|
||||
ReadProcessMemory(hProcess, pModBase, &idh, sizeof(idh), NULL);
|
||||
if (idh.e_magic == IMAGE_DOS_SIGNATURE) // DOS header OK?
|
||||
{
|
||||
IMAGE_NT_HEADERS inh;
|
||||
// Read NT headers at offset e_lfanew
|
||||
ReadProcessMemory(hProcess, (PBYTE)pModBase + idh.e_lfanew, &inh, sizeof(inh), NULL);
|
||||
// NT signature OK?
|
||||
if (inh.Signature == IMAGE_NT_SIGNATURE)
|
||||
{
|
||||
bResult = TRUE;
|
||||
// Get the preferred base & size
|
||||
pPreferredBase = (PVOID)inh.OptionalHeader.ImageBase;
|
||||
dwPreferredSize = inh.OptionalHeader.SizeOfImage;
|
||||
}
|
||||
}
|
||||
CloseHandle(hProcess);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
|
||||
/**
|
||||
* @param dwThreadId - thread ID.
|
||||
* @param hModule16 - module handle.
|
||||
* @param hTask16 - 16-bit task handle.
|
||||
* @param pszModuleName - module name.
|
||||
* @param pszProcessName - process name.
|
||||
* @param lpUserDefined - user-defined parameter.
|
||||
* @return false to keep enumerating.
|
||||
*/
|
||||
BOOL CALLBACK CEnumProcess::Enum16Proc(DWORD dwThreadId, WORD hModule16, WORD hTask16, PSZ pszModuleName, PSZ pszProcessName, LPARAM lpUserDefined)
|
||||
{
|
||||
dwThreadId; pszModuleName; hModule16;
|
||||
CEnum16Param* pParam = (CEnum16Param*)lpUserDefined;
|
||||
CEnumProcess* _this = pParam->_this;
|
||||
|
||||
CEnumProcess::CProcessEntry& rEntry = _this->m_arrProcesses16.AddItem();
|
||||
#ifdef _UNICODE
|
||||
MultiByteToWideChar(CP_ACP, 0, pszProcessName, -1, rEntry.m_szProcessName, countof(rEntry.m_szProcessName));
|
||||
#else
|
||||
_tcscpy_s(rEntry.m_szProcessName, countof(rEntry.m_szProcessName), pszProcessName);
|
||||
#endif
|
||||
rEntry.m_dwProcessID = pParam->dwProcessID;
|
||||
rEntry.m_hTask16 = hTask16;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
245
third-party/BugTrap-1.3-57bd515/source/EnumProcess.h
vendored
Normal file
245
third-party/BugTrap-1.3-57bd515/source/EnumProcess.h
vendored
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Process enumerator.
|
||||
* Updated by: Maksim Pyatkovskiy.
|
||||
* Note: Based on code developed by Moliate.
|
||||
* Downloaded from: http://www.codeproject.com/threads/enumprocess.asp
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Array.h"
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
/// 16-bit enumeration functions loaded from VDMDBG.DLL.
|
||||
typedef INT (WINAPI *PFVDMEnumTaskWOWEx)(DWORD dwProcessId, TASKENUMPROCEX fp, LPARAM lParam);
|
||||
#endif
|
||||
|
||||
// Functions loaded from PSAPI.DLL.
|
||||
|
||||
/// Type definition of pointer to EnumProcesses() function.
|
||||
typedef BOOL (WINAPI *PFEnumProcesses)(PDWORD pidProcess, DWORD cb, PDWORD pcbNeeded);
|
||||
/// Type definition of pointer to EnumProcessModules() function.
|
||||
typedef BOOL (WINAPI *PFEnumProcessModules)(HANDLE hProcess, HMODULE* phModule, DWORD cb, PDWORD pcbNeeded);
|
||||
/// Type definition of pointer to GetModuleFileNameEx() function.
|
||||
typedef DWORD (WINAPI *PFGetModuleFileNameEx)(HANDLE hProcess, HMODULE hModule, PTSTR pszFileName, DWORD nSize);
|
||||
|
||||
// Functions loaded from KERNEL32.DLL.
|
||||
|
||||
/// Type definition of pointer to CreateToolhelp32Snapshot() function.
|
||||
typedef HANDLE (WINAPI *PFCreateToolhelp32Snapshot)(DWORD dwFlags, DWORD th32ProcessID);
|
||||
/// Type definition of pointer to Process32First() function.
|
||||
typedef BOOL (WINAPI *PFProcess32First)(HANDLE hSnapshot, PPROCESSENTRY32 ppe);
|
||||
/// Type definition of pointer to Process32Next() function.
|
||||
typedef BOOL (WINAPI *PFProcess32Next)(HANDLE hSnapshot, PPROCESSENTRY32 ppe);
|
||||
/// Type definition of pointer to Module32First() function.
|
||||
typedef BOOL (WINAPI *PFModule32First)(HANDLE hSnapshot, PMODULEENTRY32 pme);
|
||||
/// Type definition of pointer to Module32Next() function.
|
||||
typedef BOOL (WINAPI *PFModule32Next)(HANDLE hSnapshot, PMODULEENTRY32 pme);
|
||||
/// Type definition of pointer to Thread32First() function.
|
||||
typedef BOOL (WINAPI *PFThread32First)(HANDLE hSnapshot, PTHREADENTRY32 pte);
|
||||
/// Type definition of pointer to Thread32Next() function.
|
||||
typedef BOOL (WINAPI *PFThread32Next)(HANDLE hSnapshot, PTHREADENTRY32 pte);
|
||||
|
||||
/// Enumerates processes in a system.
|
||||
class CEnumProcess
|
||||
{
|
||||
public:
|
||||
/// Possible enumeration methods.
|
||||
enum ENUM_METHOD
|
||||
{
|
||||
/// No methods are defined.
|
||||
EM_NONE = 0x00,
|
||||
#ifdef USE_VDMDBG
|
||||
/// PROC16 method (Windows NT and Windows 2000).
|
||||
EM_PROC16 = 0x01,
|
||||
#endif
|
||||
/// PSAPI method (Windows NT and Windows 2000).
|
||||
EM_PSAPI = 0x02,
|
||||
/// Tool Help (Windows 9x and Windows 2000).
|
||||
EM_TOOLHELP = 0x04
|
||||
};
|
||||
|
||||
/// Stores process information.
|
||||
struct CProcessEntry
|
||||
{
|
||||
/// Process name (file name of main module).
|
||||
TCHAR m_szProcessName[MAX_PATH];
|
||||
/// Process ID.
|
||||
DWORD m_dwProcessID;
|
||||
/// Task handle for 16-bit process.
|
||||
WORD m_hTask16;
|
||||
/// Initialize the object.
|
||||
CProcessEntry(void);
|
||||
};
|
||||
|
||||
/// Stores thread information.
|
||||
struct CThreadEntry
|
||||
{
|
||||
/// Thread ID.
|
||||
DWORD m_dwThreadID;
|
||||
/// Initialize the object.
|
||||
CThreadEntry(void);
|
||||
};
|
||||
|
||||
/// Stores module information.
|
||||
struct CModuleEntry
|
||||
{
|
||||
/// Module file name.
|
||||
TCHAR m_szModuleName[MAX_PATH];
|
||||
/// Module base address.
|
||||
PVOID m_pLoadBase;
|
||||
/// Module size.
|
||||
DWORD m_dwModuleSize;
|
||||
#ifdef READ_IMAGEHEADER
|
||||
/// Preferred base address.
|
||||
PVOID m_pPreferredBase;
|
||||
/// Preferred module size.
|
||||
DWORD m_dwPreferredSize;
|
||||
#endif
|
||||
/// Initialize the object.
|
||||
CModuleEntry(void);
|
||||
};
|
||||
|
||||
/// Initialize the object.
|
||||
CEnumProcess(void);
|
||||
/// Destroy the object.
|
||||
~CEnumProcess(void);
|
||||
/// Free used memory.
|
||||
void Close(void);
|
||||
|
||||
/// Get first module for the process. Should obviously be called before GetModuleNext().
|
||||
BOOL GetModuleFirst(DWORD dwProcessID, CModuleEntry& rEntry);
|
||||
/// Get next module for the process.
|
||||
BOOL GetModuleNext(DWORD dwProcessID, CModuleEntry& rEntry);
|
||||
/// Get first thread for the process.
|
||||
BOOL GetThreadFirst(DWORD dwProcessID, CThreadEntry& rEntry);
|
||||
/// Get next thread for the process.
|
||||
BOOL GetThreadNext(DWORD dwProcessID, CThreadEntry& rEntry);
|
||||
/// Retrieves current process information.
|
||||
BOOL GetCurrentProcess(CProcessEntry& rEntry);
|
||||
/// Retrieves the first process in the enumeration. Should obviously be called before GetProcessNext().
|
||||
BOOL GetProcessFirst(CProcessEntry& rEntry);
|
||||
/// Returns the following process.
|
||||
BOOL GetProcessNext(CProcessEntry& rEntry);
|
||||
|
||||
/// Get available enumeration methods.
|
||||
DWORD GetAvailableMethods(void) const;
|
||||
/// Get suggested enumeration method.
|
||||
DWORD GetSuggestedMethod(void) const;
|
||||
/// Set enumeration method.
|
||||
void SetMethod(DWORD dwMethod);
|
||||
|
||||
private:
|
||||
/// Protects object from being accidentally copied.
|
||||
CEnumProcess(const CEnumProcess& rEnumProcess);
|
||||
/// Protects object from being accidentally copied.
|
||||
CEnumProcess& operator=(const CEnumProcess& rEnumProcess);
|
||||
|
||||
#ifdef READ_IMAGEHEADER
|
||||
/// Get preferred base address of the module.
|
||||
BOOL GetPreferredModuleLocation(DWORD dwProcessID, PVOID pModBase, PVOID& pPreferredBase, DWORD& dwPreferredSize);
|
||||
#endif
|
||||
|
||||
/// Enumeration method.
|
||||
DWORD m_dwMethod;
|
||||
/// Bit-mask of available enumeration methods.
|
||||
DWORD m_dwAvailMethods;
|
||||
|
||||
/// Handle to the module (PSAPI.DLL).
|
||||
HMODULE m_hPsApiDll;
|
||||
/// Array of process IDs.
|
||||
CArray<DWORD> m_arrProcesses;
|
||||
/// Pointer to current process identifier.
|
||||
DWORD m_dwCurrentProcess;
|
||||
/// Array of module handles.
|
||||
CArray<HMODULE> m_arrModules;
|
||||
/// Pointer to current module handle.
|
||||
DWORD m_dwCurrentModule;
|
||||
/// PID of system process.
|
||||
DWORD m_dwSystemID;
|
||||
|
||||
/// Pointer to EnumProcess() function.
|
||||
PFEnumProcesses FEnumProcesses;
|
||||
/// Pointer to EnumProcessModules() function.
|
||||
PFEnumProcessModules FEnumProcessModules;
|
||||
/// Pointer to GetModuleFileNameEx() function.
|
||||
PFGetModuleFileNameEx FGetModuleFileNameEx;
|
||||
/// Fill in information about the process.
|
||||
BOOL FillPStructPSAPI(DWORD dwProcessID, CProcessEntry& rEntry);
|
||||
/// Fill in information about the module.
|
||||
BOOL FillMStructPSAPI(DWORD dwProcessID, HMODULE hModule, CModuleEntry& rEntry);
|
||||
|
||||
/// Handle to the module (KERNEL32.DLL).
|
||||
HMODULE m_hKernelDll;
|
||||
/// Process snapshot handles.
|
||||
HANDLE m_hProcessSnap;
|
||||
/// Module snapshot handles.
|
||||
HANDLE m_hModuleSnap;
|
||||
/// Thread snapshot handles.
|
||||
HANDLE m_hThreadSnap;
|
||||
/// Process information.
|
||||
PROCESSENTRY32 m_pe;
|
||||
/// Module information.
|
||||
MODULEENTRY32 m_me;
|
||||
/// Thread information.
|
||||
THREADENTRY32 m_te;
|
||||
|
||||
/// Pointer to CreateToolhelp32Snapshot() function.
|
||||
PFCreateToolhelp32Snapshot FCreateToolhelp32Snapshot;
|
||||
/// Pointer to Process32First() function.
|
||||
PFProcess32First FProcess32First;
|
||||
/// Pointer to Process32Next() function.
|
||||
PFProcess32Next FProcess32Next;
|
||||
/// Pointer to Module32First() function.
|
||||
PFModule32First FModule32First;
|
||||
/// Pointer to Module32Next() function.
|
||||
PFModule32Next FModule32Next;
|
||||
/// Pointer to Thread32First() function.
|
||||
PFThread32First FThread32First;
|
||||
/// Pointer to Thread32Next() function.
|
||||
PFThread32Next FThread32Next;
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
/// List of 16-bit processes.
|
||||
CArray<CProcessEntry> m_arrProcesses16;
|
||||
/// Pointer to current 16-bit process.
|
||||
DWORD m_dwCurrentProcess16;
|
||||
/// Handle to module VDMDBG.DLL.
|
||||
HMODULE m_hVmDbgDll;
|
||||
/// 16-bit enumeration.
|
||||
PFVDMEnumTaskWOWEx FVDMEnumTaskWOWEx;
|
||||
|
||||
/// Enumerator for 16-bit processes.
|
||||
static BOOL CALLBACK Enum16Proc(DWORD dwThreadId, WORD hModule16, WORD hTask16, PSZ pszModuleName, PSZ pszProcessName, LPARAM lpUserDefined);
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @return preferred enumeration method for current system.
|
||||
*/
|
||||
inline DWORD CEnumProcess::GetSuggestedMethod(void) const
|
||||
{
|
||||
return m_dwMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bit-mask of available enumeration methods.
|
||||
*/
|
||||
inline DWORD CEnumProcess::GetAvailableMethods(void) const
|
||||
{
|
||||
return m_dwAvailMethods;
|
||||
}
|
||||
|
||||
inline CEnumProcess::CThreadEntry::CThreadEntry(void)
|
||||
{
|
||||
m_dwThreadID = 0;
|
||||
}
|
||||
357
third-party/BugTrap-1.3-57bd515/source/FileStream.cpp
vendored
Normal file
357
third-party/BugTrap-1.3-57bd515/source/FileStream.cpp
vendored
Normal file
|
|
@ -0,0 +1,357 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: File stream class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "FileStream.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#define CHECK_FILE_HANDLE(eResult) \
|
||||
_ASSERTE(m_hFile != INVALID_HANDLE_VALUE); \
|
||||
if (m_hFile == INVALID_HANDLE_VALUE) \
|
||||
{ \
|
||||
m_lLastError = ERROR_INVALID_HANDLE_STATE; \
|
||||
return eResult; \
|
||||
}
|
||||
|
||||
#define CHECK_LAST_ERROR(eResult) \
|
||||
m_lLastError = GetLastError(); \
|
||||
if (m_lLastError != NOERROR) \
|
||||
return eResult;
|
||||
|
||||
/**
|
||||
* @param lLastError - last error code.
|
||||
*/
|
||||
void CFileStream::ResetFile(LONG lLastError)
|
||||
{
|
||||
m_hFile = INVALID_HANDLE_VALUE;
|
||||
*m_szFileName = _T('\0');
|
||||
m_bEndOfFile = false;
|
||||
m_lLastError = lLastError;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nBufferSize - buffer size.
|
||||
*/
|
||||
void CFileStream::InitBuffer(size_t nBufferSize)
|
||||
{
|
||||
ResetBuffer();
|
||||
m_nBufferSize = nBufferSize;
|
||||
if (nBufferSize > 0)
|
||||
{
|
||||
m_pBuffer = new BYTE[nBufferSize];
|
||||
if (m_pBuffer == NULL)
|
||||
{
|
||||
m_nBufferSize = 0;
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_pBuffer = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszFileName - file name.
|
||||
* @param dwCreationDisposition - an action to take on files that exist and do not exist.
|
||||
* @param dwDesiredAccess - the access to the object, which can be read, write, or both.
|
||||
* @param dwShareMode - the sharing mode of an object, which can be read, write, both, or none.
|
||||
* @param dwFlagsAndAttributes - the file attributes and flags.
|
||||
*/
|
||||
bool CFileStream::Open(PCTSTR pszFileName, DWORD dwCreationDisposition, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwFlagsAndAttributes)
|
||||
{
|
||||
_ASSERTE(m_hFile == INVALID_HANDLE_VALUE);
|
||||
if (m_hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_lLastError = ERROR_INVALID_HANDLE_STATE;
|
||||
return false;
|
||||
}
|
||||
m_hFile = CreateFile(pszFileName, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
m_lLastError = GetLastError();
|
||||
if (m_hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_bEndOfFile = false;
|
||||
_tcscpy_s(m_szFileName, countof(m_szFileName), pszFileName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CFileStream::Close(void)
|
||||
{
|
||||
if (m_hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FlushBuffer();
|
||||
CloseHandle(m_hFile);
|
||||
ResetFile(GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszName - stream name buffer.
|
||||
* @param nNameSize - size of stream name buffer.
|
||||
* @return true if name was retrieved.
|
||||
*/
|
||||
bool CFileStream::GetName(PTSTR pszName, size_t nNameSize) const
|
||||
{
|
||||
_tcscpy_s(pszName, nNameSize, m_szFileName);
|
||||
m_lLastError = NOERROR;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of bytes in the stream.
|
||||
*/
|
||||
size_t CFileStream::GetLength(void) const
|
||||
{
|
||||
CHECK_FILE_HANDLE(MAXSIZE_T);
|
||||
DWORD dwFileSize = GetFileSize(m_hFile, NULL);
|
||||
CHECK_LAST_ERROR(MAXSIZE_T);
|
||||
_ASSERTE((INT)dwFileSize >= 0); // check 2GB limit
|
||||
return dwFileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nOffset - offset from start point.
|
||||
* @param nMoveMethod - start point.
|
||||
* @return new position value.
|
||||
*/
|
||||
size_t CFileStream::SetPosition(ptrdiff_t nOffset, int nMoveMethod)
|
||||
{
|
||||
CHECK_FILE_HANDLE(MAXSIZE_T);
|
||||
m_bEndOfFile = false;
|
||||
size_t nDeltaPos = 0;
|
||||
if (m_eBufferType == BT_READ)
|
||||
{
|
||||
if (nMoveMethod == FILE_CURRENT)
|
||||
nDeltaPos = m_nBufferLength - m_nBufferPos;
|
||||
ResetBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! FlushBuffer())
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
DWORD dwFilePos = SetFilePointer(m_hFile, (LONG)(nOffset - nDeltaPos), NULL, nMoveMethod);
|
||||
CHECK_LAST_ERROR(MAXSIZE_T);
|
||||
_ASSERTE((INT)dwFilePos >= 0); // check 2GB limit
|
||||
return dwFilePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current stream position.
|
||||
*/
|
||||
size_t CFileStream::GetPosition(void) const
|
||||
{
|
||||
CHECK_FILE_HANDLE(MAXSIZE_T);
|
||||
DWORD dwFilePos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
|
||||
CHECK_LAST_ERROR(MAXSIZE_T);
|
||||
_ASSERTE((INT)dwFilePos >= 0); // check 2GB limit
|
||||
size_t nDeltaPos = m_nBufferLength - m_nBufferPos;
|
||||
return (dwFilePos - nDeltaPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nLength - new stream length.
|
||||
* @return new file length.
|
||||
*/
|
||||
size_t CFileStream::SetLength(size_t nLength)
|
||||
{
|
||||
CHECK_FILE_HANDLE(MAXSIZE_T);
|
||||
size_t nDeltaPos;
|
||||
if (m_eBufferType == BT_READ)
|
||||
{
|
||||
nDeltaPos = m_nBufferLength - m_nBufferPos;
|
||||
ResetBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
nDeltaPos = 0;
|
||||
if (! FlushBuffer())
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
m_bEndOfFile = false;
|
||||
DWORD dwFilePos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
|
||||
CHECK_LAST_ERROR(MAXSIZE_T);
|
||||
dwFilePos -= (DWORD)nDeltaPos;
|
||||
_ASSERTE((INT)dwFilePos >= 0); // check 2GB limit
|
||||
DWORD dwLength = (LONG)nLength;
|
||||
_ASSERTE(dwLength == nLength);
|
||||
SetFilePointer(m_hFile, dwLength, NULL, FILE_BEGIN);
|
||||
CHECK_LAST_ERROR(MAXSIZE_T);
|
||||
SetEndOfFile(m_hFile);
|
||||
CHECK_LAST_ERROR(MAXSIZE_T);
|
||||
if (dwFilePos > dwLength)
|
||||
dwFilePos = dwLength;
|
||||
SetFilePointer(m_hFile, dwFilePos, NULL, FILE_BEGIN);
|
||||
CHECK_LAST_ERROR(MAXSIZE_T);
|
||||
return nLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param arrBytes - array of bytes.
|
||||
* @param nCount - size of the array.
|
||||
* @return number of retrieved bytes.
|
||||
*/
|
||||
size_t CFileStream::ReadBytes(unsigned char* arrBytes, size_t nCount)
|
||||
{
|
||||
CHECK_FILE_HANDLE(MAXSIZE_T);
|
||||
if (m_pBuffer != NULL)
|
||||
{
|
||||
if (! FlushBuffer())
|
||||
return MAXSIZE_T;
|
||||
size_t nTotalLength = 0;
|
||||
for (;;)
|
||||
{
|
||||
size_t nNumBytes = m_nBufferLength - m_nBufferPos;
|
||||
if (nNumBytes > nCount)
|
||||
nNumBytes = nCount;
|
||||
if (nNumBytes > 0)
|
||||
{
|
||||
CopyMemory(arrBytes, m_pBuffer + m_nBufferPos, nNumBytes);
|
||||
arrBytes += nNumBytes;
|
||||
nTotalLength += nNumBytes;
|
||||
nCount -= nNumBytes;
|
||||
m_nBufferPos += nNumBytes;
|
||||
}
|
||||
if (nCount == 0 || m_bEndOfFile)
|
||||
break;
|
||||
_ASSERTE(m_nBufferPos == m_nBufferLength);
|
||||
DWORD dwNumRead = 0;
|
||||
ReadFile(m_hFile, m_pBuffer, (DWORD)m_nBufferSize, &dwNumRead, NULL);
|
||||
m_lLastError = GetLastError();
|
||||
m_nBufferPos = 0;
|
||||
m_nBufferLength = dwNumRead;
|
||||
m_eBufferType = m_nBufferLength > 0 ? BT_READ : BT_EMPTY;
|
||||
m_bEndOfFile = m_nBufferLength < m_nBufferSize;
|
||||
if (m_lLastError != NOERROR)
|
||||
break;
|
||||
}
|
||||
return nTotalLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD dwNumRead = 0;
|
||||
ReadFile(m_hFile, arrBytes, (DWORD)nCount, &dwNumRead, NULL);
|
||||
m_lLastError = GetLastError();
|
||||
return dwNumRead;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param arrBytes - array of bytes.
|
||||
* @param nCount - size of the array.
|
||||
* @return number of written bytes.
|
||||
*/
|
||||
size_t CFileStream::WriteBytes(const unsigned char* arrBytes, size_t nCount)
|
||||
{
|
||||
CHECK_FILE_HANDLE(MAXSIZE_T);
|
||||
if (m_pBuffer != NULL)
|
||||
{
|
||||
if (! SynchronizeBuffer())
|
||||
return MAXSIZE_T;
|
||||
size_t nTotalLength = 0;
|
||||
for (;;)
|
||||
{
|
||||
size_t nNumBytes = m_nBufferSize - m_nBufferLength;
|
||||
if (nNumBytes > nCount)
|
||||
nNumBytes = nCount;
|
||||
if (nNumBytes > 0)
|
||||
{
|
||||
m_eBufferType = BT_WRITE;
|
||||
CopyMemory(m_pBuffer + m_nBufferLength, arrBytes, nNumBytes);
|
||||
arrBytes += nNumBytes;
|
||||
nTotalLength += nNumBytes;
|
||||
nCount -= nNumBytes;
|
||||
m_nBufferLength += nNumBytes;
|
||||
}
|
||||
if (nCount == 0)
|
||||
break;
|
||||
_ASSERTE(m_nBufferLength == m_nBufferSize);
|
||||
DWORD dwNumWritten = 0;
|
||||
WriteFile(m_hFile, m_pBuffer, (DWORD)m_nBufferSize, &dwNumWritten, NULL);
|
||||
m_lLastError = GetLastError();
|
||||
ResetBuffer();
|
||||
if (m_lLastError != NOERROR)
|
||||
break;
|
||||
}
|
||||
return nTotalLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD dwNumWritten = 0;
|
||||
WriteFile(m_hFile, arrBytes, (DWORD)nCount, &dwNumWritten, NULL);
|
||||
m_lLastError = GetLastError();
|
||||
return dwNumWritten;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nBufferSize - buffer size.
|
||||
*/
|
||||
void CFileStream::SetBufferSize(size_t nBufferSize)
|
||||
{
|
||||
if (m_nBufferSize != nBufferSize)
|
||||
{
|
||||
if (! FlushBuffer())
|
||||
return;
|
||||
delete[] m_pBuffer;
|
||||
InitBuffer(nBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
void CFileStream::ResetBuffer(void)
|
||||
{
|
||||
m_eBufferType = BT_EMPTY;
|
||||
m_nBufferPos = 0;
|
||||
m_nBufferLength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if file pointer has been synchronized.
|
||||
*/
|
||||
bool CFileStream::SynchronizeBuffer(void)
|
||||
{
|
||||
if (m_eBufferType == BT_READ)
|
||||
{
|
||||
_ASSERTE(m_hFile != INVALID_HANDLE_VALUE);
|
||||
if (m_nBufferPos < m_nBufferLength)
|
||||
{
|
||||
SetFilePointer(m_hFile, (LONG)(m_nBufferPos - m_nBufferLength), NULL, FILE_CURRENT);
|
||||
CHECK_LAST_ERROR(false);
|
||||
}
|
||||
ResetBuffer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if buffer has been be flushed.
|
||||
*/
|
||||
bool CFileStream::FlushBuffer(void)
|
||||
{
|
||||
if (m_eBufferType == BT_WRITE)
|
||||
{
|
||||
_ASSERTE(m_hFile != INVALID_HANDLE_VALUE);
|
||||
if (m_nBufferLength > 0)
|
||||
{
|
||||
DWORD dwNumWritten = 0;
|
||||
WriteFile(m_hFile, m_pBuffer, (DWORD)m_nBufferLength, &dwNumWritten, NULL);
|
||||
CHECK_LAST_ERROR(false);
|
||||
}
|
||||
ResetBuffer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
219
third-party/BugTrap-1.3-57bd515/source/FileStream.h
vendored
Normal file
219
third-party/BugTrap-1.3-57bd515/source/FileStream.h
vendored
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: File stream class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Stream.h"
|
||||
|
||||
/// File stream class.
|
||||
class CFileStream : public CStream
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
explicit CFileStream(size_t nBufferSize = 1024);
|
||||
/// Initialize the object.
|
||||
CFileStream(PCTSTR pszFileName, DWORD dwCreationDisposition, DWORD dwDesiredAccess = GENERIC_READ | GENERIC_WRITE, DWORD dwShareMode = 0, DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL, size_t nBufferSize = 1024);
|
||||
/// Initialize the object.
|
||||
CFileStream(HANDLE hFile, size_t nBufferSize = 1024);
|
||||
/// Destroy the object.
|
||||
virtual ~CFileStream(void);
|
||||
/// Get list of supported features.
|
||||
virtual unsigned GetFeatures(void) const;
|
||||
/// Open a file.
|
||||
bool Open(PCTSTR pszFileName, DWORD dwCreationDisposition, DWORD dwDesiredAccess = GENERIC_READ | GENERIC_WRITE, DWORD dwShareMode = 0, DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL);
|
||||
/// Return true if stream is open.
|
||||
virtual bool IsOpen(void) const;
|
||||
/// Closes the stream.
|
||||
virtual void Close(void);
|
||||
/// Get stream name.
|
||||
virtual bool GetName(PTSTR pszName, size_t nNameSize) const;
|
||||
/// Get last IO error code.
|
||||
virtual long GetLastError(void) const;
|
||||
/// Return number of bytes in the stream.
|
||||
virtual size_t GetLength(void) const;
|
||||
/// Get current position.
|
||||
virtual size_t GetPosition(void) const;
|
||||
/// Set current position.
|
||||
virtual size_t SetPosition(ptrdiff_t nOffset, int nMoveMethod);
|
||||
/// Return true if end of stream has been reached.
|
||||
virtual bool IsEndOfStream(void) const;
|
||||
/// Read one byte from the stream.
|
||||
virtual bool ReadByte(unsigned char& bValue);
|
||||
/// Read array of bytes from the stream.
|
||||
virtual size_t ReadBytes(unsigned char* arrBytes, size_t nCount);
|
||||
/// Move the end-of-file position for the specified stream to the current position of the stream pointer.
|
||||
virtual size_t SetLength(size_t nLength);
|
||||
/// Write one byte to the stream.
|
||||
virtual bool WriteByte(unsigned char bValue);
|
||||
/// Write array of bytes to the stream.
|
||||
virtual size_t WriteBytes(const unsigned char* arrBytes, size_t nCount);
|
||||
/// Set buffer size.
|
||||
void SetBufferSize(size_t nBufferSize);
|
||||
/// Get buffer size.
|
||||
size_t GetBufferSize(void) const;
|
||||
|
||||
private:
|
||||
/// Object can't be copied.
|
||||
CFileStream(const CFileStream& rStream);
|
||||
/// Object can't be copied.
|
||||
CFileStream& operator=(const CFileStream& rStream);
|
||||
/// Initialize member variables.
|
||||
void InitVars(size_t nBufferSize);
|
||||
/// Initialize input/output buffer.
|
||||
void InitBuffer(size_t nBufferSize);
|
||||
/// Reset file handle.
|
||||
void ResetFile(LONG lLastError);
|
||||
/// Clear buffer contents.
|
||||
void ResetBuffer(void);
|
||||
/// Synchronize buffer with current file position.
|
||||
bool SynchronizeBuffer(void);
|
||||
/// Flush buffer to the disk.
|
||||
bool FlushBuffer(void);
|
||||
|
||||
/// Type of data in a buffer.
|
||||
enum BUFFER_TYPE
|
||||
{
|
||||
/// Buffer is empty.
|
||||
BT_EMPTY,
|
||||
/// Buffer keeps input data.
|
||||
BT_READ,
|
||||
/// Buffer keeps output data.
|
||||
BT_WRITE
|
||||
};
|
||||
|
||||
/// File name.
|
||||
TCHAR m_szFileName[MAX_PATH];
|
||||
/// File handle.
|
||||
HANDLE m_hFile;
|
||||
/// Last error code.
|
||||
mutable LONG m_lLastError;
|
||||
/// End of file state.
|
||||
bool m_bEndOfFile;
|
||||
/// Input/output buffer.
|
||||
PBYTE m_pBuffer;
|
||||
/// Buffer size.
|
||||
size_t m_nBufferSize;
|
||||
/// Number of bytes stored in a buffer.
|
||||
size_t m_nBufferLength;
|
||||
/// Buffer read/write position.
|
||||
size_t m_nBufferPos;
|
||||
/// Type of data in a buffer.
|
||||
BUFFER_TYPE m_eBufferType;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param nBufferSize - buffer size.
|
||||
*/
|
||||
inline CFileStream::CFileStream(size_t nBufferSize)
|
||||
{
|
||||
InitVars(nBufferSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszFileName - file name.
|
||||
* @param dwCreationDisposition - an action to take on files that exist and do not exist.
|
||||
* @param dwDesiredAccess - the access to the object, which can be read, write, or both.
|
||||
* @param dwShareMode - the sharing mode of an object, which can be read, write, both, or none.
|
||||
* @param dwFlagsAndAttributes - the file attributes and flags.
|
||||
* @param nBufferSize - buffer size.
|
||||
*/
|
||||
inline CFileStream::CFileStream(PCTSTR pszFileName, DWORD dwCreationDisposition, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwFlagsAndAttributes, size_t nBufferSize)
|
||||
{
|
||||
InitVars(nBufferSize);
|
||||
Open(pszFileName, dwCreationDisposition, dwDesiredAccess, dwShareMode, dwFlagsAndAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hFile - existing file handle.
|
||||
* @param nBufferSize - buffer size.
|
||||
*/
|
||||
inline CFileStream::CFileStream(HANDLE hFile, size_t nBufferSize)
|
||||
{
|
||||
_ASSERTE(hFile != INVALID_HANDLE_VALUE);
|
||||
InitVars(nBufferSize);
|
||||
m_hFile = hFile;
|
||||
}
|
||||
|
||||
inline CFileStream::~CFileStream(void)
|
||||
{
|
||||
Close();
|
||||
delete[] m_pBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nBufferSize - buffer size.
|
||||
*/
|
||||
inline void CFileStream::InitVars(size_t nBufferSize)
|
||||
{
|
||||
ResetFile(NOERROR);
|
||||
InitBuffer(nBufferSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bit mask of supported features.
|
||||
*/
|
||||
inline unsigned CFileStream::GetFeatures(void) const
|
||||
{
|
||||
return (SF_ISOPEN | SF_CLOSE | SF_GETNAME | SF_GETLASTERROR | SF_GETLENGTH | SF_SETLENGTH | SF_GETPOSITION | SF_SETPOSITION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if stream is open.
|
||||
*/
|
||||
inline bool CFileStream::IsOpen(void) const
|
||||
{
|
||||
return (m_hFile != INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return latest IO error code.
|
||||
*/
|
||||
inline long CFileStream::GetLastError(void) const
|
||||
{
|
||||
return m_lLastError;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return size of buffer.
|
||||
*/
|
||||
inline size_t CFileStream::GetBufferSize(void) const
|
||||
{
|
||||
return m_nBufferSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if end of stream has been reached.
|
||||
*/
|
||||
inline bool CFileStream::IsEndOfStream(void) const
|
||||
{
|
||||
return (m_bEndOfFile && (m_eBufferType != BT_READ || m_nBufferPos == m_nBufferLength));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bValue - output byte value.
|
||||
* @return true if byte has been successfully retrieved.
|
||||
*/
|
||||
inline bool CFileStream::ReadByte(unsigned char& bValue)
|
||||
{
|
||||
return (ReadBytes(&bValue, sizeof(bValue)) == sizeof(bValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bValue - input byte value.
|
||||
* @return true if byte has been successfully retrieved.
|
||||
*/
|
||||
inline bool CFileStream::WriteByte(unsigned char bValue)
|
||||
{
|
||||
return (WriteBytes(&bValue, sizeof(bValue)) == sizeof(bValue));
|
||||
}
|
||||
97
third-party/BugTrap-1.3-57bd515/source/Globals.cpp
vendored
Normal file
97
third-party/BugTrap-1.3-57bd515/source/Globals.cpp
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Global variables definitions.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the type of current platform.
|
||||
* @return true for Windows NT platform and false for Windows 9x platform.
|
||||
*/
|
||||
static BOOL IsNT(void)
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
GetVersionEx(&osvi);
|
||||
return (osvi.dwPlatformId >= VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
|
||||
/// BugTrap module handle.
|
||||
HINSTANCE g_hInstance = NULL;
|
||||
/// Application name.
|
||||
TCHAR g_szAppName[MAX_PATH] = _T("");
|
||||
/// Application version number.
|
||||
TCHAR g_szAppVersion[MAX_PATH] = _T("");
|
||||
/// Web address of product support site.
|
||||
TCHAR g_szSupportURL[MAX_PATH] = _T("");
|
||||
/// E-mail address of product support.
|
||||
TCHAR g_szSupportEMail[MAX_PATH] = _T("");
|
||||
/// Host name of product support server where BugTrapServer is installed.
|
||||
TCHAR g_szSupportHost[MAX_PATH] = _T("");
|
||||
/// E-mail address of error notification service.
|
||||
TCHAR g_szNotificationEMail[MAX_PATH] = _T("");
|
||||
/// Name of MAPI profile.
|
||||
TCHAR g_szMailProfile[MAX_PATH] = _T("");
|
||||
/// Password of MAPI profile.
|
||||
TCHAR g_szMailPassword[MAX_PATH] = _T("");
|
||||
/// Port number of product support server where BugTrapServer is installed.
|
||||
SHORT g_nSupportPort = 0;
|
||||
/// Path to error report specified by user.
|
||||
TCHAR g_szReportFilePath[MAX_PATH] = _T("");
|
||||
/// Internal path to a folder with report files.
|
||||
TCHAR g_szInternalReportFolder[MAX_PATH] = _T("");
|
||||
/// Internal path to single report file.
|
||||
TCHAR g_szInternalReportFilePath[MAX_PATH] = _T("");
|
||||
/// BugTrap configuration flags.
|
||||
DWORD g_dwFlags = BTF_NONE;
|
||||
/// Type of action which is performed in response to the error.
|
||||
BUGTRAP_ACTIVITY g_eActivityType = BTA_SHOWUI;
|
||||
/// Application terminaation mode.
|
||||
BUGTRAP_EXITMODE g_eExitMode = BTEM_TERMINATEAPP;
|
||||
/// Type of produced mini-dump. See @a MINIDUMP_TYPE for details.
|
||||
MINIDUMP_TYPE g_eDumpType = MiniDumpWithDataSegs;
|
||||
/// Format of error report.
|
||||
BUGTRAP_REPORTFORMAT g_eReportFormat = BTRF_XML;
|
||||
/// Address of error handler called before BugTrap dialog.
|
||||
BT_ErrHandler g_pfnPreErrHandler = NULL;
|
||||
/// User-defined parameter of error handler called before BugTrap dialog.
|
||||
INT_PTR g_nPreErrHandlerParam = 0;
|
||||
/// Address of error handler called after BugTrap dialog.
|
||||
BT_ErrHandler g_pfnPostErrHandler = NULL;
|
||||
/// User-defined parameter of error handler called after BugTrap dialog.
|
||||
INT_PTR g_nPostErrHandlerParam = 0;
|
||||
/// Pointer to the exception information.
|
||||
PEXCEPTION_POINTERS g_pExceptionPointers = NULL;
|
||||
/// True if application runs on Windows NT platform.
|
||||
BOOL g_bWinNT = IsNT();
|
||||
/// Custom resources manager.
|
||||
CResManager* g_pResManager = NULL;
|
||||
/// Pointer to Simple MAPI session object.
|
||||
CMapiSession* g_pMapiSession = NULL;
|
||||
/// Pointer to symbolic engine.
|
||||
CSymEngine* g_pSymEngine = NULL;
|
||||
/// Pointer to process enumerator.
|
||||
CEnumProcess* g_pEnumProc = NULL;
|
||||
/// Array of custom log file names attached to the report.
|
||||
CArray<CLogLink*, CDynamicTraits<CLogLink*> > g_arrLogLinks;
|
||||
/// User defined message printed to the log file.
|
||||
CStrHolder g_strUserMessage;
|
||||
/// 1st introduction message displayed on the dialog.
|
||||
CStrHolder g_strFirstIntroMesage;
|
||||
/// 2nd introduction message displayed on the dialog.
|
||||
CStrHolder g_strSecondIntroMesage;
|
||||
118
third-party/BugTrap-1.3-57bd515/source/Globals.h
vendored
Normal file
118
third-party/BugTrap-1.3-57bd515/source/Globals.h
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Global variables definitions.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BugTrap.h"
|
||||
#include "ResManager.h"
|
||||
#include "Array.h"
|
||||
#include "LogFile.h"
|
||||
#include "CMapi.h"
|
||||
#include "SymEngine.h"
|
||||
#include "EnumProcess.h"
|
||||
#include "LogLink.h"
|
||||
#include "VersionInfo.h"
|
||||
|
||||
#if defined _MANAGED
|
||||
#if defined _M_IX86
|
||||
#define BUGTRAP_PLATFORM _T(".NET-x86")
|
||||
#elif defined _M_X64
|
||||
#define BUGTRAP_PLATFORM _T(".NET-x64")
|
||||
#else
|
||||
#error CPU architecture is not supported.
|
||||
#endif
|
||||
#else
|
||||
#if defined _M_IX86
|
||||
#define BUGTRAP_PLATFORM _T("Win32-x86")
|
||||
#elif defined _M_X64
|
||||
#define BUGTRAP_PLATFORM _T("Win64-x64")
|
||||
#else
|
||||
#error CPU architecture is not supported.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BUGTRAP_TITLE _T("BugTrap for ") BUGTRAP_PLATFORM
|
||||
|
||||
#define _TOSTR(value) _T(#value)
|
||||
#define TOSTR(value) _TOSTR(value)
|
||||
|
||||
/// Maximum size of memory buffer (100K).
|
||||
const DWORD g_dwMaxBufferSize = 100 * 1024;
|
||||
/// Protocol signature.
|
||||
const DWORD g_dwProtocolSignature = (('B' << 0) | ('T' << 8) | ('0' << 16) | ('1' << 24));
|
||||
|
||||
/// BugTrap module handle.
|
||||
extern HINSTANCE g_hInstance;
|
||||
/// Application name.
|
||||
extern TCHAR g_szAppName[MAX_PATH];
|
||||
/// Application version number.
|
||||
extern TCHAR g_szAppVersion[MAX_PATH];
|
||||
/// Web address of product support site.
|
||||
extern TCHAR g_szSupportURL[MAX_PATH];
|
||||
/// E-mail address of product support.
|
||||
extern TCHAR g_szSupportEMail[MAX_PATH];
|
||||
/// Host name of product support server where BugTrapServer is installed.
|
||||
extern TCHAR g_szSupportHost[MAX_PATH];
|
||||
/// E-mail address of error notification service.
|
||||
extern TCHAR g_szNotificationEMail[MAX_PATH];
|
||||
/// Name of MAPI profile.
|
||||
extern TCHAR g_szMailProfile[MAX_PATH];
|
||||
/// Password of MAPI profile.
|
||||
extern TCHAR g_szMailPassword[MAX_PATH];
|
||||
/// Port number of product support server where BugTrapServer is installed.
|
||||
extern SHORT g_nSupportPort;
|
||||
/// Path to error report specified by user.
|
||||
extern TCHAR g_szReportFilePath[MAX_PATH];
|
||||
/// Internal path to a folder with report files.
|
||||
extern TCHAR g_szInternalReportFolder[MAX_PATH];
|
||||
/// Internal path to single report file.
|
||||
extern TCHAR g_szInternalReportFilePath[MAX_PATH];
|
||||
/// BugTrap configuration flags.
|
||||
extern DWORD g_dwFlags;
|
||||
/// Type of action which is performed in response to the error.
|
||||
extern BUGTRAP_ACTIVITY g_eActivityType;
|
||||
/// Application terminaation mode.
|
||||
extern BUGTRAP_EXITMODE g_eExitMode;
|
||||
/// Type of produced mini-dump. See @a MINIDUMP_TYPE for details.
|
||||
extern MINIDUMP_TYPE g_eDumpType;
|
||||
/// Format of error report.
|
||||
extern BUGTRAP_REPORTFORMAT g_eReportFormat;
|
||||
/// Address of error handler called before BugTrap dialog.
|
||||
extern BT_ErrHandler g_pfnPreErrHandler;
|
||||
/// User-defined parameter of error handler called before BugTrap dialog.
|
||||
extern INT_PTR g_nPreErrHandlerParam;
|
||||
/// Address of error handler called after BugTrap dialog.
|
||||
extern BT_ErrHandler g_pfnPostErrHandler;
|
||||
/// User-defined parameter of error handler called after BugTrap dialog.
|
||||
extern INT_PTR g_nPostErrHandlerParam;
|
||||
/// Pointer to the exception information.
|
||||
extern PEXCEPTION_POINTERS g_pExceptionPointers;
|
||||
/// True if application runs on Windows NT platform.
|
||||
extern BOOL g_bWinNT;
|
||||
/// Custom resources manager.
|
||||
extern CResManager* g_pResManager;
|
||||
/// Pointer to Simple MAPI session object.
|
||||
extern CMapiSession* g_pMapiSession;
|
||||
/// Pointer to symbolic engine.
|
||||
extern CSymEngine* g_pSymEngine;
|
||||
/// Pointer to process enumerator.
|
||||
extern CEnumProcess* g_pEnumProc;
|
||||
/// Array of custom log file names attached to the report.
|
||||
extern CArray<CLogLink*, CDynamicTraits<CLogLink*> > g_arrLogLinks;
|
||||
/// User defined message printed to the log file.
|
||||
extern CStrHolder g_strUserMessage;
|
||||
/// 1st introduction message displayed on the dialog.
|
||||
extern CStrHolder g_strFirstIntroMesage;
|
||||
/// 2nd introduction message displayed on the dialog.
|
||||
extern CStrHolder g_strSecondIntroMesage;
|
||||
519
third-party/BugTrap-1.3-57bd515/source/Hash.h
vendored
Normal file
519
third-party/BugTrap-1.3-57bd515/source/Hash.h
vendored
Normal file
|
|
@ -0,0 +1,519 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Hash table.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ColHelper.h"
|
||||
|
||||
/// Hash table.
|
||||
template
|
||||
<
|
||||
typename KEY_TYPE,
|
||||
typename DATA_TYPE,
|
||||
class KEY_INSTANCE_TRAITS = CObjectTraits<KEY_TYPE>,
|
||||
class DATA_INSTANCE_TRAITS = CObjectTraits<DATA_TYPE>,
|
||||
class COMPARE_TRAITS = CCompareTraits<KEY_TYPE>,
|
||||
class HASH_TRAITS = CHashTraits<KEY_TYPE>
|
||||
>
|
||||
class CHash
|
||||
{
|
||||
private:
|
||||
/// Hash item.
|
||||
class CHashItem
|
||||
{
|
||||
/// Hash table.
|
||||
friend class CHash;
|
||||
|
||||
private:
|
||||
/// Contains key value.
|
||||
KEY_TYPE m_Key;
|
||||
/// Contains data value.
|
||||
DATA_TYPE m_Data;
|
||||
/// Pointer to the next hash item.
|
||||
CHashItem* m_pNext;
|
||||
};
|
||||
|
||||
/// Hash iterator.
|
||||
class CHashIterator
|
||||
{
|
||||
/// Hash table.
|
||||
friend class CHash;
|
||||
|
||||
private:
|
||||
/// Pointer to current hash item.
|
||||
CHashItem* m_pItem;
|
||||
/// Index in the internal array containing current hash items.
|
||||
size_t m_nIndex;
|
||||
|
||||
public:
|
||||
/// Return true if iterator points to valid value.
|
||||
operator bool(void) const { return (m_pItem != NULL); }
|
||||
/// Return false if iterator points to valid value.
|
||||
bool operator!(void) const { return (m_pItem == NULL); }
|
||||
};
|
||||
|
||||
/// Dynamic array of hash items arranged as list.
|
||||
CHashItem** m_pHash;
|
||||
/// List of deleted hash items. These items can be reused in future allocations.
|
||||
CHashItem* m_pGarbage;
|
||||
/// Size of dynamic array.
|
||||
size_t m_nHashSize;
|
||||
/// Number of items in collection.
|
||||
size_t m_nCount;
|
||||
|
||||
public:
|
||||
/// Synonym of hash iterator type.
|
||||
typedef CHashIterator POSITION;
|
||||
|
||||
enum
|
||||
{
|
||||
/// Default hash table size.
|
||||
DEFAULT_SIZE = 11
|
||||
};
|
||||
|
||||
/// Initialize a hash table object with specified size.
|
||||
explicit CHash(size_t nHashSize = DEFAULT_SIZE);
|
||||
/// Makes a copy of a hash table.
|
||||
CHash(const CHash& rHash);
|
||||
/// Makes a copy of a hash table.
|
||||
const CHash& operator=(const CHash& rHash);
|
||||
/// Destroy a hash table object and free allocated memory.
|
||||
~CHash(void);
|
||||
/// Return the size of dictionary.
|
||||
size_t GetSize(void) const;
|
||||
/// Return number of items in collection.
|
||||
size_t GetCount(void) const;
|
||||
/// Tests for the empty-hash condition (no elements).
|
||||
bool IsEmpty(void) const;
|
||||
/// Search for data mapped to a given key. Returns true if the key was found.
|
||||
bool Lookup(const KEY_TYPE& rKey, DATA_TYPE& rData);
|
||||
/// Search for data mapped to a given key. Returns pointer to founded data or NULL if a matching key is not found.
|
||||
DATA_TYPE* Lookup(const KEY_TYPE& rKey);
|
||||
/// Search for data mapped to a given key. Returns pointer to founded data or NULL if a matching key is not found.
|
||||
const DATA_TYPE* Lookup(const KEY_TYPE& rKey) const;
|
||||
/// Insert an element into the dictionary; replace an existing element if a matching key is found.
|
||||
void SetAt(const KEY_TYPE& rKey, const DATA_TYPE& rData);
|
||||
/// Insert an element into the dictionary - operator substitution for SetAt.
|
||||
DATA_TYPE& GetAt(const KEY_TYPE& rKey);
|
||||
/// Insert an element into the dictionary - operator substitution for SetAt.
|
||||
DATA_TYPE& operator[](const KEY_TYPE& rKey);
|
||||
/// Remove an element specified by a key.
|
||||
void Delete(const typename KEY_TYPE& rKey);
|
||||
/// Remove an element specified by a position.
|
||||
void DeleteAt(const typename POSITION& pos);
|
||||
/// Remove all the elements from this dictionary.
|
||||
void DeleteAll(bool bFree = false);
|
||||
/// Returns the position of the first element.
|
||||
POSITION GetStartPosition(void) const;
|
||||
/// Gets the next element for iterating.
|
||||
POSITION GetNextPosition(const typename POSITION& pos) const;
|
||||
/// Get the key at a given position.
|
||||
static const KEY_TYPE& GetKeyAt(const typename POSITION& pos);
|
||||
/// Get the data at a given position.
|
||||
static DATA_TYPE& GetDataAt(const typename POSITION& pos);
|
||||
|
||||
private:
|
||||
/// Look for hash item by the specified key.
|
||||
CHashItem* InternalLookup(const typename KEY_TYPE& rKey, size_t& rIndex) const;
|
||||
/// Delete hash item from the hash table.
|
||||
void InternalDelete(CHashItem* pDelItem, size_t nIndex);
|
||||
/// Initialize hash table.
|
||||
void InitHashTable(size_t nHashSize);
|
||||
/// Throw an exception if position is not valid.
|
||||
static void ValidatePosition(const typename POSITION& pos);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param nHashSize - hash table size.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
void CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::InitHashTable(size_t nHashSize)
|
||||
{
|
||||
m_pGarbage = NULL;
|
||||
m_nHashSize = nHashSize;
|
||||
m_nCount = 0;
|
||||
m_pHash = new CHashItem*[nHashSize];
|
||||
if (! m_pHash)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nHashSize - hash table size.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::CHash(size_t nHashSize)
|
||||
{
|
||||
InitHashTable(nHashSize);
|
||||
for (size_t nIndex = 0; nIndex < nHashSize; ++nIndex)
|
||||
m_pHash[nIndex] = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - validated position.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline void CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::ValidatePosition(const typename CHash::POSITION& pos)
|
||||
{
|
||||
_ASSERTE(pos);
|
||||
if (! pos)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rHash - object to be copied.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::CHash(const CHash& rHash)
|
||||
{
|
||||
InitHashTable(rHash.m_nHashSize);
|
||||
for (size_t nIndex = 0; nIndex < m_nHashSize; ++nIndex)
|
||||
{
|
||||
m_pHash[nIndex] = NULL;
|
||||
CHashItem* pItem = rHash.m_pHash[nIndex];
|
||||
while (pItem)
|
||||
{
|
||||
SetAt(pItem->m_Key, pItem->m_Data);
|
||||
pItem = pItem->m_pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rHash - object to be copied.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
const CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>& CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::operator=(const CHash& rHash)
|
||||
{
|
||||
if (this != &rHash)
|
||||
{
|
||||
DeleteAll();
|
||||
for (size_t nIndex = 0; nIndex < rHash.m_nHashSize; ++nIndex)
|
||||
{
|
||||
CHashItem* pItem = rHash.m_pHash[nIndex];
|
||||
while (pItem)
|
||||
{
|
||||
SetAt(pItem->m_Key, pItem->m_Data);
|
||||
pItem = pItem->m_pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::~CHash(void)
|
||||
{
|
||||
DeleteAll(true);
|
||||
delete[] m_pHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return size of hash table.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline size_t CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::GetSize(void) const
|
||||
{
|
||||
return m_nHashSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of elements.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline size_t CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::GetCount(void) const
|
||||
{
|
||||
return m_nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this hash contains no elements; otherwise false.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline bool CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::IsEmpty(void) const
|
||||
{
|
||||
return (m_nCount == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - specifies the key that identifies the element to be looked up.
|
||||
* @param rIndex - index in array of obtained item.
|
||||
* @return pointer to obtained hash item or NULL.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
typename CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::CHashItem* CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::InternalLookup(const typename KEY_TYPE& rKey, size_t& rIndex) const
|
||||
{
|
||||
rIndex = HASH_TRAITS::HashKey(rKey) % m_nHashSize;
|
||||
CHashItem* pItem = m_pHash[rIndex];
|
||||
while (pItem)
|
||||
{
|
||||
if (COMPARE_TRAITS::Compare(pItem->m_Key, rKey))
|
||||
return pItem;
|
||||
pItem = pItem->m_pNext;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - specifies the key that identifies the element to be looked up.
|
||||
* @param rData - data variable that is being set to found value.
|
||||
* @return true if the key was found.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline bool CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::Lookup(const KEY_TYPE& rKey, DATA_TYPE& rData)
|
||||
{
|
||||
size_t nIndex;
|
||||
CHashItem* pItem = InternalLookup(rKey, nIndex);
|
||||
if (pItem)
|
||||
{
|
||||
rData = pItem->m_Data;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - specifies the key that identifies the element to be looked up.
|
||||
* @return pointer to obtained hash item or NULL.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline DATA_TYPE* CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::Lookup(const KEY_TYPE& rKey)
|
||||
{
|
||||
size_t nIndex;
|
||||
CHashItem* pItem = InternalLookup(rKey, nIndex);
|
||||
return (pItem ? &pItem->m_Data : NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - specifies the key that identifies the element to be looked up.
|
||||
* @return pointer to obtained hash item or NULL.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline const DATA_TYPE* CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::Lookup(const KEY_TYPE& rKey) const
|
||||
{
|
||||
size_t nIndex;
|
||||
CHashItem* pItem = InternalLookup(rKey, nIndex);
|
||||
return (pItem ? &pItem->m_Data : NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - specifies the key of the new element.
|
||||
* @param rData - specifies the value of the new element.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline void CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::SetAt(const KEY_TYPE& rKey, const DATA_TYPE& rData)
|
||||
{
|
||||
DATA_INSTANCE_TRAITS::Assignment(GetAt(rKey), rData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - the key used to retrieve the value from the hash.
|
||||
* @return reference to the item.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
DATA_TYPE& CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::GetAt(const KEY_TYPE& rKey)
|
||||
{
|
||||
size_t nIndex;
|
||||
CHashItem* pItem = InternalLookup(rKey, nIndex);
|
||||
if (pItem == NULL)
|
||||
{
|
||||
if (m_pGarbage)
|
||||
{
|
||||
pItem = m_pGarbage;
|
||||
m_pGarbage = m_pGarbage->m_pNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem = (CHashItem*)new BYTE[sizeof(CHashItem)];
|
||||
if (! pItem)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
KEY_INSTANCE_TRAITS::Constructor(pItem->m_Key);
|
||||
KEY_INSTANCE_TRAITS::Assignment(pItem->m_Key, rKey);
|
||||
DATA_INSTANCE_TRAITS::Constructor(pItem->m_Data);
|
||||
pItem->m_pNext = m_pHash[nIndex];
|
||||
m_pHash[nIndex] = pItem;
|
||||
++m_nCount;
|
||||
}
|
||||
return pItem->m_Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - the key used to retrieve the value from the hash.
|
||||
* @return reference to the item.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline DATA_TYPE& CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::operator[](const KEY_TYPE& rKey)
|
||||
{
|
||||
return GetAt(rKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pDelItem - pointer to deleted hash item.
|
||||
* @param nIndex - index of array there deleted item can be found.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
void CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::InternalDelete(typename CHash::CHashItem* pDelItem, size_t nIndex)
|
||||
{
|
||||
CHashItem* pPrev = NULL;
|
||||
CHashItem* pItem = m_pHash[nIndex];
|
||||
while (pItem)
|
||||
{
|
||||
if (pItem == pDelItem)
|
||||
{
|
||||
if (pPrev)
|
||||
pPrev->m_pNext = pItem->m_pNext;
|
||||
else
|
||||
m_pHash[nIndex] = pItem->m_pNext;
|
||||
KEY_INSTANCE_TRAITS::Destructor(pItem->m_Key);
|
||||
DATA_INSTANCE_TRAITS::Destructor(pItem->m_Data);
|
||||
pItem->m_pNext = m_pGarbage;
|
||||
m_pGarbage = pItem;
|
||||
--m_nCount;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPrev = pItem;
|
||||
pItem = pItem->m_pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rKey - key for the element to be removed.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline void CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::Delete(const typename KEY_TYPE& rKey)
|
||||
{
|
||||
size_t nIndex;
|
||||
CHashItem* pItem = InternalLookup(rKey, nIndex);
|
||||
if (! pItem)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
InternalDelete(pItem, nIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bFree - pass true of release array memory.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
void CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::DeleteAll(bool bFree)
|
||||
{
|
||||
if (bFree)
|
||||
{
|
||||
CHashItem* pNext;
|
||||
while (m_pGarbage)
|
||||
{
|
||||
pNext = m_pGarbage->m_pNext;
|
||||
delete[] (PBYTE)m_pGarbage;
|
||||
m_pGarbage = pNext;
|
||||
}
|
||||
for (size_t nIndex = 0; nIndex < m_nHashSize; ++nIndex)
|
||||
{
|
||||
CHashItem* pItem = m_pHash[nIndex];
|
||||
while (pItem)
|
||||
{
|
||||
pNext = pItem->m_pNext;
|
||||
KEY_INSTANCE_TRAITS::Destructor(pItem->m_Key);
|
||||
DATA_INSTANCE_TRAITS::Destructor(pItem->m_Data);
|
||||
delete[] (PBYTE)pItem;
|
||||
pItem = pNext;
|
||||
}
|
||||
m_pHash[nIndex] = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t nIndex = 0; nIndex < m_nHashSize; ++nIndex)
|
||||
{
|
||||
CHashItem* pItem = m_pHash[nIndex];
|
||||
while (pItem)
|
||||
{
|
||||
CHashItem* pNext = pItem->m_pNext;
|
||||
KEY_INSTANCE_TRAITS::Destructor(pItem->m_Key);
|
||||
DATA_INSTANCE_TRAITS::Destructor(pItem->m_Data);
|
||||
pItem->m_pNext = m_pGarbage;
|
||||
m_pGarbage = pItem;
|
||||
pItem = pNext;
|
||||
}
|
||||
m_pHash[nIndex] = NULL;
|
||||
}
|
||||
}
|
||||
m_nCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a @a POSITION value that indicates a starting position for iterating the hash; or NULL if the hash is empty.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
typename CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::POSITION CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::GetStartPosition(void) const
|
||||
{
|
||||
POSITION posStart;
|
||||
size_t nIndex = 0;
|
||||
while (nIndex < m_nHashSize && m_pHash[nIndex] == NULL)
|
||||
++nIndex;
|
||||
posStart.m_pItem = nIndex == m_nHashSize ? NULL : m_pHash[nIndex];
|
||||
posStart.m_nIndex = nIndex;
|
||||
return posStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - previous position.
|
||||
* @return a @a POSITION value that indicates the next position for iterating the hash; or NULL if it's a last position.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
typename CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::POSITION CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::GetNextPosition(const typename CHash::POSITION& pos) const
|
||||
{
|
||||
ValidatePosition(pos);
|
||||
CHashItem* pItem = pos.m_pItem->m_pNext;
|
||||
size_t nIndex = pos.m_nIndex;
|
||||
while (pItem == NULL && ++nIndex < m_nHashSize)
|
||||
pItem = m_pHash[nIndex];
|
||||
POSITION posNext;
|
||||
posNext.m_pItem = pItem;
|
||||
posNext.m_nIndex = nIndex;
|
||||
return posNext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - hash item position.
|
||||
* @return reference to key at specified position.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline const KEY_TYPE& CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::GetKeyAt(const typename CHash::POSITION& pos)
|
||||
{
|
||||
ValidatePosition(pos);
|
||||
return pos.m_pItem->m_Key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - hash item position.
|
||||
* @return reference to data at specified position.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
inline DATA_TYPE& CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::GetDataAt(const typename CHash::POSITION& pos)
|
||||
{
|
||||
ValidatePosition(pos);
|
||||
return pos.m_pItem->m_Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - hash item position.
|
||||
*/
|
||||
template <typename KEY_TYPE, typename DATA_TYPE, class KEY_INSTANCE_TRAITS, class DATA_INSTANCE_TRAITS, class COMPARE_TRAITS, class HASH_TRAITS>
|
||||
void CHash<KEY_TYPE, DATA_TYPE, KEY_INSTANCE_TRAITS, DATA_INSTANCE_TRAITS, COMPARE_TRAITS, HASH_TRAITS>::DeleteAt(const typename CHash::POSITION& pos)
|
||||
{
|
||||
ValidatePosition(pos);
|
||||
InternalDelete(pos.m_pItem, pos.m_nIndex);
|
||||
}
|
||||
581
third-party/BugTrap-1.3-57bd515/source/HexView.cpp
vendored
Normal file
581
third-party/BugTrap-1.3-57bd515/source/HexView.cpp
vendored
Normal file
|
|
@ -0,0 +1,581 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Hex view control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "HexView.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#define USE_MEM_DC
|
||||
|
||||
#ifndef SPI_GETWHEELSCROLLLINES
|
||||
#define SPI_GETWHEELSCROLLLINES 0x0068
|
||||
#endif
|
||||
|
||||
#ifndef SPI_SETWHEELSCROLLLINES
|
||||
#define SPI_SETWHEELSCROLLLINES 0x0069
|
||||
#endif
|
||||
|
||||
/// Default number of wheel lines.
|
||||
static const DWORD g_dwDefaultNumWheels = 3;
|
||||
|
||||
void CHexView::InitVars(void)
|
||||
{
|
||||
m_hwnd = NULL;
|
||||
m_pfnOldHexViewWndProc = NULL;
|
||||
m_lOldStyle = 0;
|
||||
m_nWheelLines = g_dwDefaultNumWheels;
|
||||
ResetFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hdc - drawing conHex.
|
||||
* @param prcPaint - the rectangle where the painting is requested.
|
||||
*/
|
||||
void CHexView::DrawHexView(HDC hdc, const RECT* prcPaint)
|
||||
{
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (prcPaint == NULL)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
prcPaint = &rcClient;
|
||||
}
|
||||
if (IsRectEmpty(prcPaint))
|
||||
return;
|
||||
|
||||
#ifdef USE_MEM_DC
|
||||
int nClientWidth = prcPaint->right - prcPaint->left;
|
||||
int nClientHeight = prcPaint->bottom - prcPaint->top;
|
||||
HBITMAP hbmpMem;
|
||||
hbmpMem = CreateCompatibleBitmap(hdc, nClientWidth, nClientHeight);
|
||||
if (hbmpMem == NULL)
|
||||
return;
|
||||
HDC hdcMem;
|
||||
hdcMem = CreateCompatibleDC(hdc);
|
||||
if (hdcMem == NULL)
|
||||
{
|
||||
DeleteBitmap(hbmpMem);
|
||||
return;
|
||||
}
|
||||
SetViewportOrgEx(hdcMem, -prcPaint->left, -prcPaint->top, NULL);
|
||||
HBITMAP hbmpSafe = SelectBitmap(hdcMem, hbmpMem);
|
||||
#else
|
||||
// CS_PARENTDC sets the clipping rectangle of the child window to that of the parent window
|
||||
// so that the child can draw on the parent. Text view inherits this style from sub-classed
|
||||
// static control. This causes problems with unclipped TabbedTextOut() output.
|
||||
HRGN hrgn = CreateRectRgnIndirect(prcPaint);
|
||||
SelectClipRgn(hdc, hrgn);
|
||||
DeleteRgn(hrgn);
|
||||
HDC hdcMem = hdc;
|
||||
#endif
|
||||
|
||||
FillRect(hdcMem, prcPaint, g_pResManager->m_hbrWindowBrush);
|
||||
|
||||
COLORREF rgbOldTextColor = SetTextColor(hdcMem, GetSysColor(COLOR_WINDOWTEXT));
|
||||
COLORREF rgbOldBackground = SetBkColor(hdcMem, GetSysColor(COLOR_WINDOW));
|
||||
HFONT hOldFont = g_pResManager->m_hFixedFont ? SelectFont(hdcMem, g_pResManager->m_hFixedFont) : NULL;
|
||||
TEXTMETRIC tmetr;
|
||||
::GetTextMetrics(hdcMem, &tmetr);
|
||||
|
||||
DWORD dwNumLines = m_dwFileSize / LINE_WIDTH;
|
||||
if (m_dwFileSize % LINE_WIDTH)
|
||||
++dwNumLines;
|
||||
DWORD dwTopLineNum = GetScrollPos(m_hwnd, SB_VERT);
|
||||
DWORD dwTopVisLineNum = dwTopLineNum + prcPaint->top / tmetr.tmHeight;
|
||||
|
||||
if (dwTopVisLineNum < dwNumLines)
|
||||
{
|
||||
int nHorPos = tmetr.tmAveCharWidth - GetScrollPos(m_hwnd, SB_HORZ);
|
||||
int nVertPos = prcPaint->top - prcPaint->top % tmetr.tmHeight, nTopPos = nVertPos;
|
||||
DWORD dwNumVisLines = prcPaint->bottom / tmetr.tmHeight;
|
||||
if (prcPaint->bottom % tmetr.tmHeight)
|
||||
++dwNumVisLines;
|
||||
DWORD dwBottomVisLineNum = dwTopLineNum + dwNumVisLines - 1;
|
||||
if (dwBottomVisLineNum >= dwNumLines)
|
||||
dwBottomVisLineNum = dwNumLines - 1;
|
||||
int nBottomPos = nVertPos + (dwBottomVisLineNum - dwTopVisLineNum + 1) * tmetr.tmHeight;
|
||||
|
||||
int nOffsetWidth = 10 * tmetr.tmAveCharWidth;
|
||||
int nLineWidth = (3 * LINE_WIDTH + 2) * tmetr.tmAveCharWidth;
|
||||
int nLinePos = nOffsetWidth + nLineWidth - tmetr.tmAveCharWidth * 3 / 2;
|
||||
|
||||
for (DWORD dwLineNum = dwTopVisLineNum; dwLineNum <= dwBottomVisLineNum; ++dwLineNum)
|
||||
{
|
||||
CacheLine(dwLineNum);
|
||||
TCHAR szHexLine[3 * LINE_WIDTH], szTextLine[2 * LINE_WIDTH];
|
||||
PBYTE pbLine = m_pbCache + (dwLineNum - m_dwFirstCachedLine) * LINE_WIDTH;
|
||||
DWORD dwOffset = dwLineNum * LINE_WIDTH, dwNumBytes = m_dwFileSize - dwOffset;
|
||||
if (dwNumBytes > LINE_WIDTH)
|
||||
dwNumBytes = LINE_WIDTH;
|
||||
DWORD dwLinePos = 0, dwCharPos = 0;
|
||||
for (DWORD dwBytePos = 0; dwBytePos < dwNumBytes; ++dwBytePos)
|
||||
{
|
||||
BYTE bValue = pbLine[dwBytePos];
|
||||
BYTE bDigit = (bValue >> 4) & 0x0F;
|
||||
szHexLine[dwLinePos++] = bDigit < 0x0A ? bDigit + _T('0') : bDigit - 0x0A + _T('A');
|
||||
bDigit = bValue & 0x0F;
|
||||
szHexLine[dwLinePos++] = bDigit < 0x0A ? bDigit + _T('0') : bDigit - 0x0A + _T('A');
|
||||
szHexLine[dwLinePos++] = _T(' ');
|
||||
WORD wCharType = 0;
|
||||
GetStringTypeA(LOCALE_USER_DEFAULT, CT_CTYPE1, (PCSTR)&bValue, 1, &wCharType);
|
||||
if (wCharType & (C1_ALPHA | C1_DIGIT | C1_PUNCT) || bValue == ' ')
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
dwCharPos += MultiByteToWideChar(CP_ACP, 0, (PCSTR)&bValue, 1, szTextLine + dwCharPos, 2);
|
||||
#else
|
||||
szTextLine[dwCharPos++] = bValue;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
szTextLine[dwCharPos++] = _T('.');
|
||||
}
|
||||
|
||||
TCHAR szOffset[11];
|
||||
_stprintf_s(szOffset, countof(szOffset), _T("%08X: "), dwOffset);
|
||||
int nPosition = nHorPos;
|
||||
TextOut(hdcMem, nPosition, nVertPos, szOffset, 10);
|
||||
nPosition += nOffsetWidth;
|
||||
TextOut(hdcMem, nPosition, nVertPos, szHexLine, dwLinePos);
|
||||
nPosition += nLineWidth;
|
||||
TextOut(hdcMem, nPosition, nVertPos, szTextLine, dwCharPos);
|
||||
nVertPos += tmetr.tmHeight;
|
||||
}
|
||||
|
||||
int nPosition = nHorPos + nLinePos;
|
||||
MoveToEx(hdcMem, nPosition, nTopPos, NULL);
|
||||
LineTo(hdcMem, nPosition, nBottomPos);
|
||||
}
|
||||
|
||||
SetTextColor(hdcMem, rgbOldTextColor);
|
||||
SetBkColor(hdcMem, rgbOldBackground);
|
||||
if (hOldFont)
|
||||
SelectFont(hdcMem, hOldFont);
|
||||
|
||||
#ifdef USE_MEM_DC
|
||||
BitBlt(hdc, prcPaint->left, prcPaint->top, nClientWidth, nClientHeight, hdcMem, prcPaint->left, prcPaint->top, SRCCOPY);
|
||||
SelectBitmap(hdcMem, hbmpSafe);
|
||||
DeleteDC(hdcMem);
|
||||
DeleteBitmap(hbmpMem);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bIgnoreScrollPos - pass true to disregard any existing scrollbar styles.
|
||||
*/
|
||||
void CHexView::ResizeHexView(BOOL bIgnoreScrollPos)
|
||||
{
|
||||
TEXTMETRIC tmetr;
|
||||
GetTextMetrics(&tmetr);
|
||||
SCROLLINFO sinfo;
|
||||
RECT rcClient;
|
||||
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
sinfo.fMask = SIF_POS | SIF_RANGE;
|
||||
GetScrollInfo(m_hwnd, SB_HORZ, &sinfo);
|
||||
int nOldHorPos = ! bIgnoreScrollPos ? sinfo.nPos : 0;
|
||||
int nWidth = (10 + 3 * LINE_WIDTH + 2 + LINE_WIDTH) * tmetr.tmAveCharWidth;
|
||||
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
sinfo.nMin = 0;
|
||||
if (sinfo.nMax < nWidth - 1)
|
||||
sinfo.nMax = nWidth - 1;
|
||||
sinfo.nPage = rcClient.right;
|
||||
ValidateScrollInfo(&sinfo);
|
||||
int nHorOffset = nOldHorPos - sinfo.nPos;
|
||||
SetScrollInfo(m_hwnd, SB_HORZ, &sinfo, TRUE);
|
||||
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
int nOldVertPos;
|
||||
if (! bIgnoreScrollPos)
|
||||
{
|
||||
sinfo.fMask = SIF_POS;
|
||||
GetScrollInfo(m_hwnd, SB_VERT, &sinfo);
|
||||
nOldVertPos = sinfo.nPos;
|
||||
}
|
||||
else
|
||||
nOldVertPos = sinfo.nPos = 0;
|
||||
int nNumLines = m_dwFileSize / LINE_WIDTH;
|
||||
if (m_dwFileSize % LINE_WIDTH)
|
||||
++nNumLines;
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
sinfo.nMin = 0;
|
||||
sinfo.nMax = nNumLines > 0 ? nNumLines - 1 : 0;
|
||||
sinfo.nPage = rcClient.bottom / tmetr.tmHeight;
|
||||
ValidateScrollInfo(&sinfo);
|
||||
int nVertOffset = (nOldVertPos - sinfo.nPos) * tmetr.tmHeight;
|
||||
SetScrollInfo(m_hwnd, SB_VERT, &sinfo, TRUE);
|
||||
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
// Explicitly clip output to override style CS_PARENTDC.
|
||||
ScrollWindowEx(m_hwnd, nHorOffset, nVertOffset, &rcClient, &rcClient, NULL, NULL, SW_INVALIDATE);
|
||||
UpdateWindow(m_hwnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pTextMetric - pointer to Hex metric structure.
|
||||
*/
|
||||
void CHexView::GetTextMetrics(PTEXTMETRIC pTextMetric)
|
||||
{
|
||||
HDC hdc = GetDC(m_hwnd);
|
||||
HFONT hOldFont = g_pResManager->m_hFixedFont ? SelectFont(hdc, g_pResManager->m_hFixedFont) : NULL;
|
||||
::GetTextMetrics(hdc, pTextMetric);
|
||||
if (hOldFont)
|
||||
SelectFont(hdc, hOldFont);
|
||||
ReleaseDC(m_hwnd, hdc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nScrollBarType - scrollbar type.
|
||||
* @param nScrollCode - scroll code.
|
||||
*/
|
||||
void CHexView::ScrollHexView(int nScrollBarType, int nScrollCode)
|
||||
{
|
||||
_ASSERTE(nScrollBarType == SB_HORZ || nScrollBarType == SB_VERT);
|
||||
|
||||
SCROLLINFO sinfo;
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
if (nScrollCode == SB_THUMBTRACK)
|
||||
sinfo.fMask |= SIF_TRACKPOS;
|
||||
GetScrollInfo(m_hwnd, nScrollBarType, &sinfo);
|
||||
int nOldPos = sinfo.nPos;
|
||||
|
||||
TEXTMETRIC tmetr;
|
||||
GetTextMetrics(&tmetr);
|
||||
int nLineOffset = nScrollBarType == SB_HORZ ? tmetr.tmAveCharWidth : 1;
|
||||
|
||||
switch (nScrollCode)
|
||||
{
|
||||
case SB_LINEUP:
|
||||
//case SB_LINELEFT:
|
||||
sinfo.nPos -= nLineOffset;
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
//case SB_LINERIGHT:
|
||||
sinfo.nPos += nLineOffset;
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
//case SB_PAGELEFT:
|
||||
sinfo.nPos -= sinfo.nPage;
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
//case SB_PAGERIGHT:
|
||||
sinfo.nPos += sinfo.nPage;
|
||||
break;
|
||||
case SB_THUMBTRACK:
|
||||
sinfo.nPos = sinfo.nTrackPos;
|
||||
break;
|
||||
case SB_TOP:
|
||||
//case SB_LEFT:
|
||||
sinfo.nPos = 0;
|
||||
break;
|
||||
case SB_BOTTOM:
|
||||
//case SB_RIGHT:
|
||||
sinfo.nPos = sinfo.nMax;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
ValidateScrollInfo(&sinfo);
|
||||
sinfo.fMask = SIF_POS;
|
||||
SetScrollInfo(m_hwnd, nScrollBarType, &sinfo, TRUE);
|
||||
|
||||
if (sinfo.nPos != nOldPos)
|
||||
{
|
||||
int nHorOffset, nVertOffset;
|
||||
if (nScrollBarType == SB_HORZ)
|
||||
{
|
||||
nHorOffset = nOldPos - sinfo.nPos;
|
||||
nVertOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nHorOffset = 0;
|
||||
nVertOffset = (nOldPos - sinfo.nPos) * tmetr.tmHeight;
|
||||
}
|
||||
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
// Explicitly clip output to override style CS_PARENTDC.
|
||||
ScrollWindowEx(m_hwnd, nHorOffset, nVertOffset, &rcClient, &rcClient, NULL, NULL, SW_INVALIDATE);
|
||||
UpdateWindow(m_hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - first message parameter.
|
||||
* @param lParam - second message parameter.
|
||||
*/
|
||||
LRESULT CALLBACK CHexView::HexViewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
int zDelta, zTotal, nScrollCode, nScrollBarType;
|
||||
LONG lWindowStyle;
|
||||
|
||||
CHexView* _this = (CHexView*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
_ASSERTE(_this != NULL);
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
SetFocus(hwnd);
|
||||
return 0;
|
||||
case WM_ERASEBKGND:
|
||||
return TRUE;
|
||||
case WM_PAINT:
|
||||
hdc = (HDC)wParam;
|
||||
if (! hdc)
|
||||
{
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
if (hdc)
|
||||
{
|
||||
_this->DrawHexView(hdc, &ps.rcPaint);
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
}
|
||||
else
|
||||
_this->DrawHexView(hdc, NULL);
|
||||
return 0;
|
||||
case WM_PRINTCLIENT:
|
||||
hdc = (HDC)wParam;
|
||||
_this->DrawHexView(hdc, NULL);
|
||||
return 0;
|
||||
case WM_SIZE:
|
||||
_this->ResizeHexView(FALSE);
|
||||
return 0;
|
||||
case WM_KEYDOWN:
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_LEFT:
|
||||
_this->ScrollHexView(SB_HORZ, SB_LINELEFT);
|
||||
break;
|
||||
case VK_UP:
|
||||
_this->ScrollHexView(SB_VERT, SB_LINEUP);
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
_this->ScrollHexView(SB_HORZ, SB_LINERIGHT);
|
||||
break;
|
||||
case VK_DOWN:
|
||||
_this->ScrollHexView(SB_VERT, SB_LINEDOWN);
|
||||
break;
|
||||
case VK_HOME:
|
||||
if (GetKeyState(VK_CONTROL) < 0)
|
||||
_this->ScrollHexView(SB_VERT, SB_TOP);
|
||||
else
|
||||
_this->ScrollHexView(SB_HORZ, SB_LEFT);
|
||||
break;
|
||||
case VK_END:
|
||||
if (GetKeyState(VK_CONTROL) < 0)
|
||||
_this->ScrollHexView(SB_VERT, SB_BOTTOM);
|
||||
else
|
||||
_this->ScrollHexView(SB_HORZ, SB_RIGHT);
|
||||
break;
|
||||
case VK_PRIOR:
|
||||
_this->ScrollHexView(SB_VERT, SB_PAGEUP);
|
||||
break;
|
||||
case VK_NEXT:
|
||||
_this->ScrollHexView(SB_VERT, SB_PAGEDOWN);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
case WM_HSCROLL:
|
||||
_this->ScrollHexView(SB_HORZ, LOWORD(wParam));
|
||||
return 0;
|
||||
case WM_VSCROLL:
|
||||
_this->ScrollHexView(SB_VERT, LOWORD(wParam));
|
||||
return 0;
|
||||
case WM_MOUSEWHEEL:
|
||||
zDelta = (int)(short)HIWORD(wParam);
|
||||
if (_this->m_nWheelLines == WHEEL_PAGESCROLL)
|
||||
nScrollCode = zDelta > 0 ? SB_PAGEUP : SB_PAGEDOWN;
|
||||
else
|
||||
nScrollCode = zDelta > 0 ? SB_LINEUP : SB_LINEDOWN;
|
||||
zTotal = abs(zDelta) / WHEEL_DELTA;
|
||||
if (_this->m_nWheelLines != WHEEL_PAGESCROLL)
|
||||
zTotal *= _this->m_nWheelLines;
|
||||
lWindowStyle = GetWindowLong(hwnd, GWL_STYLE);
|
||||
|
||||
if (lWindowStyle & WS_VSCROLL)
|
||||
nScrollBarType = SB_VERT;
|
||||
else if (lWindowStyle & WS_HSCROLL)
|
||||
nScrollBarType = SB_HORZ;
|
||||
else
|
||||
return 0;
|
||||
for (int i = 0; i < zTotal; ++i)
|
||||
_this->ScrollHexView(nScrollBarType, nScrollCode);
|
||||
return 0;
|
||||
case WM_SETTINGCHANGE:
|
||||
if (wParam == SPI_SETWHEELSCROLLLINES)
|
||||
{
|
||||
if (! SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &_this->m_nWheelLines, 0))
|
||||
_this->m_nWheelLines = g_dwDefaultNumWheels;
|
||||
}
|
||||
return 0;
|
||||
case WM_GETDLGCODE:
|
||||
return DLGC_WANTARROWS;
|
||||
default:
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - hex view window handle.
|
||||
*/
|
||||
void CHexView::Attach(HWND hwnd)
|
||||
{
|
||||
_ASSERTE(hwnd != NULL);
|
||||
_ASSERTE(m_hwnd == NULL);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
|
||||
if (! SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &m_nWheelLines, 0))
|
||||
m_nWheelLines = g_dwDefaultNumWheels;
|
||||
|
||||
m_hwnd = hwnd;
|
||||
m_pfnOldHexViewWndProc = SubclassWindow(hwnd, HexViewWndProc);
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this);
|
||||
// Preserve original window styles that could be modified by SetScrollInfo().
|
||||
m_lOldStyle = GetWindowLong(hwnd, GWL_STYLE);
|
||||
ResizeHexView(TRUE);
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
void CHexView::Detach(void)
|
||||
{
|
||||
if (m_pfnOldHexViewWndProc)
|
||||
{
|
||||
SubclassWindow(m_hwnd, m_pfnOldHexViewWndProc);
|
||||
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, NULL);
|
||||
|
||||
SCROLLINFO sinfo;
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
SetScrollInfo(m_hwnd, SB_HORZ, &sinfo, FALSE);
|
||||
SetScrollInfo(m_hwnd, SB_VERT, &sinfo, FALSE);
|
||||
SetWindowLong(m_hwnd, GWL_STYLE, m_lOldStyle);
|
||||
|
||||
InvalidateRect(m_hwnd, NULL, TRUE);
|
||||
InitVars();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hFile - file handle.
|
||||
*/
|
||||
void CHexView::SetFile(HANDLE hFile)
|
||||
{
|
||||
_ASSERTE(hFile != INVALID_HANDLE_VALUE);
|
||||
_ASSERTE(m_hFile == INVALID_HANDLE_VALUE);
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
m_hFile = hFile;
|
||||
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
|
||||
LoadCache();
|
||||
ResizeHexView(TRUE);
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
void CHexView::ResetFile(void)
|
||||
{
|
||||
m_hFile = INVALID_HANDLE_VALUE;
|
||||
m_dwFirstCachedLine = m_dwFileSize = 0;
|
||||
delete[] m_pbCache;
|
||||
m_pbCache = NULL;
|
||||
}
|
||||
|
||||
void CHexView::LoadCache(void)
|
||||
{
|
||||
_ASSERTE(m_hFile != INVALID_HANDLE_VALUE);
|
||||
m_dwFileSize = GetFileSize(m_hFile, NULL);
|
||||
m_dwFirstCachedLine = 0;
|
||||
DWORD dwCacheSize = min(m_dwFileSize, CACHE_SIZE);
|
||||
m_pbCache = new BYTE[dwCacheSize];
|
||||
if (m_pbCache == NULL)
|
||||
{
|
||||
ResetFile();
|
||||
goto end;
|
||||
}
|
||||
DWORD dwNumRead = 0;
|
||||
ReadFile(m_hFile, m_pbCache, dwCacheSize, &dwNumRead, NULL);
|
||||
|
||||
end:
|
||||
ResizeHexView(TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwCachedLineNum - index of cached line.
|
||||
*/
|
||||
void CHexView::CacheLine(DWORD dwCachedLineNum)
|
||||
{
|
||||
DWORD dwCacheSize = min(m_dwFileSize, CACHE_SIZE);
|
||||
DWORD dwNumCachedLines = dwCacheSize / LINE_WIDTH;
|
||||
if (dwCacheSize % LINE_WIDTH)
|
||||
++dwNumCachedLines;
|
||||
if (dwCachedLineNum >= m_dwFirstCachedLine && dwCachedLineNum < m_dwFirstCachedLine + dwNumCachedLines)
|
||||
return;
|
||||
|
||||
DWORD dwFirstCachedLine = dwCachedLineNum > NUMBER_OF_CACHED_LINES / 2 ? dwCachedLineNum - NUMBER_OF_CACHED_LINES / 2 : 0;
|
||||
DWORD dwFirstMappedLine, dwNumMappedLines, dwFirstLoadedLine, dwNumLoadedLines, dwFromMemOffset, dwToMemOffset, dwLoadOffset;
|
||||
if (m_dwFirstCachedLine <= dwFirstCachedLine && dwFirstCachedLine < m_dwFirstCachedLine + dwNumCachedLines)
|
||||
{
|
||||
dwFirstMappedLine = dwFirstCachedLine;
|
||||
dwNumMappedLines = dwNumCachedLines - (dwFirstCachedLine - m_dwFirstCachedLine);
|
||||
dwFirstLoadedLine = dwFirstMappedLine + dwNumMappedLines;
|
||||
dwNumLoadedLines = dwNumCachedLines - dwNumMappedLines;
|
||||
dwFromMemOffset = (dwFirstMappedLine - m_dwFirstCachedLine) * LINE_WIDTH;
|
||||
dwToMemOffset = 0;
|
||||
dwLoadOffset = dwNumMappedLines * LINE_WIDTH;
|
||||
}
|
||||
else if (dwFirstCachedLine <= m_dwFirstCachedLine && m_dwFirstCachedLine < dwFirstCachedLine + dwNumCachedLines)
|
||||
{
|
||||
dwFirstMappedLine = m_dwFirstCachedLine;
|
||||
dwNumMappedLines = dwNumCachedLines - (m_dwFirstCachedLine - dwFirstCachedLine);
|
||||
dwFirstLoadedLine = dwFirstCachedLine;
|
||||
dwNumLoadedLines = dwNumCachedLines - dwNumMappedLines;
|
||||
dwFromMemOffset = (dwFirstMappedLine - m_dwFirstCachedLine) * LINE_WIDTH;
|
||||
dwToMemOffset = dwNumLoadedLines * LINE_WIDTH;
|
||||
dwLoadOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwFirstMappedLine = dwNumMappedLines = dwFromMemOffset = dwToMemOffset = 0;
|
||||
dwFirstLoadedLine = dwFirstCachedLine;
|
||||
dwNumLoadedLines = dwNumCachedLines;
|
||||
dwLoadOffset = 0;
|
||||
}
|
||||
|
||||
_ASSERTE(m_pbCache != NULL);
|
||||
if (dwNumMappedLines > 0)
|
||||
MoveMemory(m_pbCache + dwToMemOffset, m_pbCache + dwFromMemOffset, dwNumMappedLines * LINE_WIDTH);
|
||||
|
||||
if (dwNumLoadedLines > 0)
|
||||
{
|
||||
SetFilePointer(m_hFile, dwFirstLoadedLine * LINE_WIDTH, NULL, FILE_BEGIN);
|
||||
DWORD dwNumRead = 0;
|
||||
ReadFile(m_hFile, m_pbCache + dwLoadOffset, dwNumLoadedLines * LINE_WIDTH, &dwNumRead, NULL);
|
||||
}
|
||||
|
||||
m_dwFirstCachedLine = dwFirstCachedLine;
|
||||
}
|
||||
102
third-party/BugTrap-1.3-57bd515/source/HexView.h
vendored
Normal file
102
third-party/BugTrap-1.3-57bd515/source/HexView.h
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Hex view control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Hex view control class.
|
||||
class CHexView
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CHexView(void);
|
||||
/// De-initialize the object.
|
||||
~CHexView(void);
|
||||
/// Attach hex view object to window handle.
|
||||
void Attach(HWND hwnd);
|
||||
/// Detach hex view object to window handle.
|
||||
void Detach(void);
|
||||
/// Set file information.
|
||||
void SetFile(HANDLE hFile);
|
||||
/// Reset file information.
|
||||
void ResetFile(void);
|
||||
/// Get file handle.
|
||||
HANDLE GetFileHandle(void) const;
|
||||
|
||||
enum
|
||||
{
|
||||
/// Number of symbols in one line.
|
||||
LINE_WIDTH = 16,
|
||||
/// Number of cached lines.
|
||||
NUMBER_OF_CACHED_LINES = 2000,
|
||||
/// Size of cache.
|
||||
CACHE_SIZE = LINE_WIDTH * NUMBER_OF_CACHED_LINES
|
||||
};
|
||||
|
||||
private:
|
||||
/// Protect the class from being accidentally copied.
|
||||
CHexView(const CHexView& rHexView);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CHexView& operator=(const CHexView& rHexView);
|
||||
/// Window procedure of hex view window.
|
||||
static LRESULT CALLBACK HexViewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Draw window client area.
|
||||
void DrawHexView(HDC hdc, const RECT* prcPaint);
|
||||
/// Resize hex view client area.
|
||||
void ResizeHexView(BOOL bIgnoreScrollPos);
|
||||
/// Scroll hex view client area.
|
||||
void ScrollHexView(int nScrollBarType, int nScrollCode);
|
||||
/// Initialize variables.
|
||||
void InitVars(void);
|
||||
/// Load cache from file.
|
||||
void LoadCache(void);
|
||||
/// Load line to the cache.
|
||||
void CacheLine(DWORD dwÑachedLineNum);
|
||||
/// Get current font metrics.
|
||||
void GetTextMetrics(PTEXTMETRIC pTextMetric);
|
||||
|
||||
/// File cache.
|
||||
PBYTE m_pbCache;
|
||||
/// File size.
|
||||
DWORD m_dwFileSize;
|
||||
/// File handle.
|
||||
HANDLE m_hFile;
|
||||
/// Window handle.
|
||||
HWND m_hwnd;
|
||||
/// Old static window procedure.
|
||||
WNDPROC m_pfnOldHexViewWndProc;
|
||||
/// Number of first cache lined.
|
||||
DWORD m_dwFirstCachedLine;
|
||||
/// Old window style.
|
||||
LONG m_lOldStyle;
|
||||
/// Number of wheel lines.
|
||||
int m_nWheelLines;
|
||||
};
|
||||
|
||||
inline CHexView::CHexView(void) : m_pbCache(NULL)
|
||||
{
|
||||
InitVars();
|
||||
}
|
||||
|
||||
inline CHexView::~CHexView(void)
|
||||
{
|
||||
ResetFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return file handle.
|
||||
*/
|
||||
inline HANDLE CHexView::GetFileHandle(void) const
|
||||
{
|
||||
return m_hFile;
|
||||
}
|
||||
379
third-party/BugTrap-1.3-57bd515/source/HyperLink.cpp
vendored
Normal file
379
third-party/BugTrap-1.3-57bd515/source/HyperLink.cpp
vendored
Normal file
|
|
@ -0,0 +1,379 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Hyper-link control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "HyperLink.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
const COLORREF CHyperLink::m_rgbBlueColor = RGB(0x00, 0x00, 0xDD);
|
||||
const COLORREF CHyperLink::m_rgbRedColor = RGB(0xDD, 0x00, 0x00);
|
||||
|
||||
CHyperLink::CHyperLink(void)
|
||||
{
|
||||
m_rgbCurrentColor = m_rgbBlueColor;
|
||||
*m_szLinkURL = _T('\0');
|
||||
m_hwnd = NULL;
|
||||
m_pfnOldHyperLinkWndProc = NULL;
|
||||
m_nPrevDefButtonID = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszLinkURL - new link URL.
|
||||
*/
|
||||
void CHyperLink::SetLinkURL(PCTSTR pszLinkURL)
|
||||
{
|
||||
if (pszLinkURL)
|
||||
_tcscpy_s(m_szLinkURL, countof(m_szLinkURL), pszLinkURL);
|
||||
else
|
||||
*m_szLinkURL = _T('\0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param point - point coordinates.
|
||||
* @return true if point appears in boundaries of hyper-link text.
|
||||
*/
|
||||
BOOL CHyperLink::HitTest(const POINT& point) const
|
||||
{
|
||||
RECT rect;
|
||||
GetHyperLinkRect(rect);
|
||||
return PtInRect(&rect, point);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x - point x-coordinate.
|
||||
* @param y - point y-coordinate.
|
||||
* @return true if point appears in boundaries of hyper-link text.
|
||||
*/
|
||||
BOOL CHyperLink::HitTest(int x, int y) const
|
||||
{
|
||||
POINT point;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
return HitTest(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hdc - drawing context.
|
||||
*/
|
||||
void CHyperLink::DrawHyperLink(HDC hdc) const
|
||||
{
|
||||
TCHAR szLinkText[MAX_PATH];
|
||||
GetWindowText(m_hwnd, szLinkText, countof(szLinkText));
|
||||
SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
HFONT hOldFont = g_pResManager->m_hUnderlinedFont ? SelectFont(hdc, g_pResManager->m_hUnderlinedFont) : NULL;
|
||||
HWND hwndParent = GetParent(m_hwnd);
|
||||
HBRUSH hBrush = hwndParent ? FORWARD_WM_CTLCOLORSTATIC(hwndParent, hdc, m_hwnd, SendMessage) : NULL;
|
||||
if (! hBrush)
|
||||
hBrush = g_pResManager->m_hbrButtonFaceBrush;
|
||||
if (hBrush)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
FillRect(hdc, &rcClient, hBrush);
|
||||
}
|
||||
SetTextColor(hdc, m_rgbCurrentColor);
|
||||
TextOut(hdc, 1, 1, szLinkText, (int)_tcslen(szLinkText));
|
||||
SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
|
||||
if (hOldFont)
|
||||
SelectFont(hdc, hOldFont);
|
||||
if (GetFocus() == m_hwnd)
|
||||
{
|
||||
RECT rect;
|
||||
GetHyperLinkRect(rect);
|
||||
DrawFocusRect(hdc, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
void CHyperLink::DoAction(void) const
|
||||
{
|
||||
if (*m_szLinkURL)
|
||||
{
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hAppStartingCursor)
|
||||
SetCursor(g_pResManager->m_hAppStartingCursor);
|
||||
ShellExecute(NULL, _T("open"), m_szLinkURL, NULL, NULL, SW_SHOWDEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
HWND hwndParent = GetParent(m_hwnd);
|
||||
if (hwndParent)
|
||||
{
|
||||
int nCtrlID = GetDlgCtrlID(m_hwnd);
|
||||
FORWARD_WM_COMMAND(hwndParent, nCtrlID, m_hwnd, BN_CLICKED, PostMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - first message parameter.
|
||||
* @param lParam - second message parameter.
|
||||
*/
|
||||
LRESULT CALLBACK CHyperLink::HyperLinkWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int x, y, nCtrlID;
|
||||
POINT point;
|
||||
HCURSOR hCursor;
|
||||
COLORREF rgbNewColor;
|
||||
PAINTSTRUCT ps;
|
||||
HWND hwndParent, hwndCtrl;
|
||||
LRESULT lResult;
|
||||
DWORD dwResult;
|
||||
HDC hdc;
|
||||
|
||||
CHyperLink* _this = (CHyperLink*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
_ASSERTE(_this != NULL);
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_NCHITTEST:
|
||||
return HTCLIENT;
|
||||
case WM_SETCURSOR:
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
hCursor = g_pResManager->m_hArrowCursor;
|
||||
if (g_pResManager->m_hHandCursor)
|
||||
{
|
||||
dwResult = GetMessagePos();
|
||||
point.x = GET_X_LPARAM(dwResult);
|
||||
point.y = GET_Y_LPARAM(dwResult);
|
||||
ScreenToClient(hwnd, &point);
|
||||
if (_this->HitTest(point))
|
||||
hCursor = g_pResManager->m_hHandCursor;
|
||||
}
|
||||
if (hCursor)
|
||||
{
|
||||
SetCursor(hCursor);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
case WM_LBUTTONDOWN:
|
||||
if (GetCapture() != hwnd)
|
||||
{
|
||||
x = GET_X_LPARAM(lParam);
|
||||
y = GET_Y_LPARAM(lParam);
|
||||
if (_this->HitTest(x, y))
|
||||
{
|
||||
_this->m_rgbCurrentColor = m_rgbRedColor;
|
||||
SetCapture(hwnd);
|
||||
if (GetFocus() == hwnd)
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
else
|
||||
SetFocus(hwnd);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_MOUSEMOVE:
|
||||
if (GetCapture() == hwnd)
|
||||
{
|
||||
x = GET_X_LPARAM(lParam);
|
||||
y = GET_Y_LPARAM(lParam);
|
||||
rgbNewColor = _this->HitTest(x, y) ? m_rgbRedColor : m_rgbBlueColor;
|
||||
if (_this->m_rgbCurrentColor != rgbNewColor)
|
||||
{
|
||||
_this->m_rgbCurrentColor = rgbNewColor;
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_LBUTTONUP:
|
||||
if (GetCapture() == hwnd)
|
||||
{
|
||||
ReleaseCapture();
|
||||
x = GET_X_LPARAM(lParam);
|
||||
y = GET_Y_LPARAM(lParam);
|
||||
if (_this->HitTest(x, y))
|
||||
_this->DoAction();
|
||||
}
|
||||
return 0;
|
||||
case WM_SETFOCUS:
|
||||
hwndParent = GetParent(hwnd);
|
||||
if (hwndParent)
|
||||
{
|
||||
nCtrlID = GetDlgCtrlID(hwnd);
|
||||
if (_this->m_nPrevDefButtonID < 0)
|
||||
{
|
||||
lResult = SendMessage(hwndParent, DM_GETDEFID, 0, 0);
|
||||
_this->m_nPrevDefButtonID = HIWORD(lResult) == DC_HASDEFID && LOWORD(lResult) != nCtrlID ? LOWORD(lResult) : -1;
|
||||
}
|
||||
SendMessage(hwndParent, DM_SETDEFID, nCtrlID, 0);
|
||||
if (_this->m_nPrevDefButtonID > 0)
|
||||
{
|
||||
// Sending a DM_SETDEFID message to change the default button will not always
|
||||
// remove the default state border from the first push button. In these cases,
|
||||
// the application should send a BM_SETSTYLE message to change the first push
|
||||
// button border style.
|
||||
hwndCtrl = GetDlgItem(hwndParent, _this->m_nPrevDefButtonID);
|
||||
if (SendMessage(hwndCtrl, WM_GETDLGCODE, 0, 0) & DLGC_DEFPUSHBUTTON)
|
||||
SendMessage(hwndCtrl, BM_SETSTYLE, BS_PUSHBUTTON, TRUE);
|
||||
}
|
||||
}
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
return 0;
|
||||
case WM_KILLFOCUS:
|
||||
hwndParent = GetParent(hwnd);
|
||||
if (hwndParent && wParam && IsChild(hwndParent, (HWND)wParam))
|
||||
{
|
||||
if (! (SendMessage((HWND)wParam, WM_GETDLGCODE, 0, 0) & (DLGC_DEFPUSHBUTTON | DLGC_UNDEFPUSHBUTTON)))
|
||||
{
|
||||
if (_this->m_nPrevDefButtonID > 0)
|
||||
{
|
||||
nCtrlID = _this->m_nPrevDefButtonID;
|
||||
_this->m_nPrevDefButtonID = -1;
|
||||
}
|
||||
else
|
||||
nCtrlID = IDOK;
|
||||
hwndCtrl = GetDlgItem(hwndParent, nCtrlID);
|
||||
if (hwndCtrl && IsWindowEnabled(hwndCtrl))
|
||||
SendMessage(hwndParent, DM_SETDEFID, nCtrlID, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->m_nPrevDefButtonID = -1;
|
||||
nCtrlID = GetDlgCtrlID((HWND)wParam);
|
||||
SendMessage(hwndParent, DM_SETDEFID, nCtrlID, 0);
|
||||
}
|
||||
}
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
return 0;
|
||||
case WM_CAPTURECHANGED:
|
||||
_this->m_rgbCurrentColor = m_rgbBlueColor;
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
return 0;
|
||||
case WM_ERASEBKGND:
|
||||
return TRUE;
|
||||
case WM_PAINT:
|
||||
hdc = (HDC)wParam;
|
||||
if (! hdc)
|
||||
{
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
if (hdc)
|
||||
{
|
||||
_this->DrawHyperLink(hdc);
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
}
|
||||
else
|
||||
_this->DrawHyperLink(hdc);
|
||||
return 0;
|
||||
case WM_PRINTCLIENT:
|
||||
hdc = (HDC)wParam;
|
||||
_this->DrawHyperLink(hdc);
|
||||
return 0;
|
||||
case WM_KEYDOWN:
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_RETURN:
|
||||
_this->DoAction();
|
||||
break;
|
||||
case VK_TAB:
|
||||
hwndParent = GetParent(hwnd);
|
||||
if (hwndParent)
|
||||
{
|
||||
BOOL bPrevCtrl = GetKeyState(VK_SHIFT) < 0;
|
||||
FORWARD_WM_NEXTDLGCTL(hwndParent, bPrevCtrl, FALSE, PostMessage);
|
||||
}
|
||||
break;
|
||||
case VK_LEFT:
|
||||
case VK_UP:
|
||||
hwndParent = GetParent(hwnd);
|
||||
if (hwndParent)
|
||||
FORWARD_WM_NEXTDLGCTL(hwndParent, TRUE, FALSE, PostMessage);
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
case VK_DOWN:
|
||||
hwndParent = GetParent(hwnd);
|
||||
if (hwndParent)
|
||||
FORWARD_WM_NEXTDLGCTL(hwndParent, FALSE, FALSE, PostMessage);
|
||||
break;
|
||||
case VK_ESCAPE:
|
||||
hwndParent = GetParent(hwnd);
|
||||
if (hwndParent)
|
||||
{
|
||||
HWND hwndCtl = GetDlgItem(hwndParent, IDCANCEL);
|
||||
if (! hwndCtl || IsWindowEnabled(hwndCtl))
|
||||
FORWARD_WM_COMMAND(hwndParent, IDCANCEL, hwndCtl, BN_CLICKED, PostMessage);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
case WM_GETDLGCODE:
|
||||
return ((GetFocus() == hwnd ? DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON) | DLGC_WANTALLKEYS);
|
||||
case BM_SETSTYLE:
|
||||
return 0;
|
||||
default:
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - hyper-link window handle.
|
||||
*/
|
||||
void CHyperLink::Attach(HWND hwnd)
|
||||
{
|
||||
_ASSERTE(hwnd != NULL);
|
||||
_ASSERTE(m_hwnd == NULL);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
m_hwnd = hwnd;
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this);
|
||||
m_pfnOldHyperLinkWndProc = SubclassWindow(hwnd, HyperLinkWndProc);
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
|
||||
void CHyperLink::Detach(void)
|
||||
{
|
||||
if (m_pfnOldHyperLinkWndProc)
|
||||
{
|
||||
SubclassWindow(m_hwnd, m_pfnOldHyperLinkWndProc);
|
||||
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, NULL);
|
||||
InvalidateRect(m_hwnd, NULL, TRUE);
|
||||
m_pfnOldHyperLinkWndProc = NULL;
|
||||
m_hwnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size - hyper-link size.
|
||||
*/
|
||||
void CHyperLink::GetHyperLinkSize(SIZE& size) const
|
||||
{
|
||||
HDC hdc = GetDC(m_hwnd);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
HFONT hOldFont = NULL;
|
||||
if (g_pResManager->m_hUnderlinedFont)
|
||||
hOldFont = SelectFont(hdc, g_pResManager->m_hUnderlinedFont);
|
||||
TCHAR szLinkText[MAX_PATH];
|
||||
GetWindowText(m_hwnd, szLinkText, countof(szLinkText));
|
||||
GetTextExtentPoint32(hdc, szLinkText, (int)_tcslen(szLinkText), &size);
|
||||
if (hOldFont)
|
||||
SelectFont(hdc, hOldFont);
|
||||
ReleaseDC(m_hwnd, hdc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rect - hyper-link rectangle.
|
||||
*/
|
||||
void CHyperLink::GetHyperLinkRect(RECT& rect) const
|
||||
{
|
||||
SIZE size;
|
||||
GetHyperLinkSize(size);
|
||||
rect.left = rect.top = 0;
|
||||
rect.right = size.cx + 3;
|
||||
rect.bottom = size.cy + 3;
|
||||
}
|
||||
75
third-party/BugTrap-1.3-57bd515/source/HyperLink.h
vendored
Normal file
75
third-party/BugTrap-1.3-57bd515/source/HyperLink.h
vendored
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Hyper-link control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Hyper-link control class.
|
||||
class CHyperLink
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CHyperLink(void);
|
||||
/// Get link URL.
|
||||
PCTSTR GetLinkURL(void) const;
|
||||
/// Set link URL.
|
||||
void SetLinkURL(PCTSTR pszLinkURL);
|
||||
/// Attach hyper-link object to window handle.
|
||||
void Attach(HWND hwnd);
|
||||
/// Detach hyper-link object to window handle.
|
||||
void Detach(void);
|
||||
|
||||
private:
|
||||
/// Protect the class from being accidentally copied.
|
||||
CHyperLink(const CHyperLink& rHyperLink);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CHyperLink& operator=(const CHyperLink& rHyperLink);
|
||||
/// Window procedure of hyper-link window.
|
||||
static LRESULT CALLBACK HyperLinkWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Calculates hyper-link size.
|
||||
void GetHyperLinkSize(SIZE& size) const;
|
||||
/// Calculates hyper-link rectangle.
|
||||
void GetHyperLinkRect(RECT& rect) const;
|
||||
/// Check if point appears within hyper-link text.
|
||||
BOOL HitTest(const POINT& point) const;
|
||||
/// Check if point appears within hyper-link text.
|
||||
BOOL HitTest(int x, int y) const;
|
||||
/// Draw window client area.
|
||||
void DrawHyperLink(HDC hdc) const;
|
||||
/// Do hyper-link action.
|
||||
void DoAction(void) const;
|
||||
|
||||
/// Blue color.
|
||||
static const COLORREF m_rgbBlueColor;
|
||||
/// Red color.
|
||||
static const COLORREF m_rgbRedColor;
|
||||
|
||||
/// Window handle.
|
||||
HWND m_hwnd;
|
||||
/// Old static window procedure.
|
||||
WNDPROC m_pfnOldHyperLinkWndProc;
|
||||
/// Link URL.
|
||||
TCHAR m_szLinkURL[MAX_PATH];
|
||||
/// Current hyper-link color.
|
||||
COLORREF m_rgbCurrentColor;
|
||||
/// Previous default button ID.
|
||||
int m_nPrevDefButtonID;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return current link URL.
|
||||
*/
|
||||
inline PCTSTR CHyperLink::GetLinkURL(void) const
|
||||
{
|
||||
return m_szLinkURL;
|
||||
}
|
||||
572
third-party/BugTrap-1.3-57bd515/source/ImageView.cpp
vendored
Normal file
572
third-party/BugTrap-1.3-57bd515/source/ImageView.cpp
vendored
Normal file
|
|
@ -0,0 +1,572 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Image view control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "ImageView.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#define USE_MEM_DC
|
||||
|
||||
#ifndef SPI_GETWHEELSCROLLLINES
|
||||
#define SPI_GETWHEELSCROLLLINES 0x0068
|
||||
#endif
|
||||
|
||||
#ifndef SPI_SETWHEELSCROLLLINES
|
||||
#define SPI_SETWHEELSCROLLLINES 0x0069
|
||||
#endif
|
||||
|
||||
/// Default number of wheel lines.
|
||||
static const DWORD g_dwDefaultNumWheels = 3;
|
||||
|
||||
void CImageView::InitVars(void)
|
||||
{
|
||||
m_hwnd = NULL;
|
||||
m_pfnOldImageViewWndProc = NULL;
|
||||
m_lOldStyle = 0;
|
||||
m_nWheelLines = g_dwDefaultNumWheels;
|
||||
ResetImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hdc - drawing conImage.
|
||||
* @param prcPaint - the rectangle where the painting is requested.
|
||||
*/
|
||||
void CImageView::DrawImageView(HDC hdc, const RECT* prcPaint)
|
||||
{
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
if (prcPaint == NULL)
|
||||
prcPaint = &rcClient;
|
||||
if (IsRectEmpty(prcPaint))
|
||||
return;
|
||||
|
||||
#ifdef USE_MEM_DC
|
||||
int nClientWidth = prcPaint->right - prcPaint->left;
|
||||
int nClientHeight = prcPaint->bottom - prcPaint->top;
|
||||
HBITMAP hbmpMem;
|
||||
hbmpMem = CreateCompatibleBitmap(hdc, nClientWidth, nClientHeight);
|
||||
if (hbmpMem == NULL)
|
||||
return;
|
||||
HDC hdcMem;
|
||||
hdcMem = CreateCompatibleDC(hdc);
|
||||
if (hdcMem == NULL)
|
||||
{
|
||||
DeleteBitmap(hbmpMem);
|
||||
return;
|
||||
}
|
||||
SetViewportOrgEx(hdcMem, -prcPaint->left, -prcPaint->top, NULL);
|
||||
HBITMAP hbmpSafe = SelectBitmap(hdcMem, hbmpMem);
|
||||
#else
|
||||
// CS_PARENTDC sets the clipping rectangle of the child window to that of the parent window
|
||||
// so that the child can draw on the parent. Text view inherits this style from sub-classed
|
||||
// static control. This causes problems with unclipped TabbedTextOut() output.
|
||||
HRGN hrgn = CreateRectRgnIndirect(prcPaint);
|
||||
SelectClipRgn(hdc, hrgn);
|
||||
DeleteRgn(hrgn);
|
||||
HDC hdcMem = hdc;
|
||||
#endif
|
||||
|
||||
FillRect(hdcMem, prcPaint, g_pResManager->m_hbrWindowBrush);
|
||||
HDC hdcTemp = CreateCompatibleDC(hdc);
|
||||
if (hdcTemp)
|
||||
{
|
||||
HBITMAP hbmpSafe2 = SelectBitmap(hdcTemp, m_hAdjustedBitmap);
|
||||
int nHorPos = GetScrollPos(m_hwnd, SB_HORZ);
|
||||
int nVertPos = GetScrollPos(m_hwnd, SB_VERT);
|
||||
int nImageLeft = rcClient.right > m_szAjustedBitmapSize.cx ? (rcClient.right - m_szAjustedBitmapSize.cx) / 2 : -nHorPos;
|
||||
int nImageTop = rcClient.bottom > m_szAjustedBitmapSize.cy ? (rcClient.bottom - m_szAjustedBitmapSize.cy) / 2 : -nVertPos;
|
||||
BitBlt(hdcMem, nImageLeft, nImageTop, m_szAjustedBitmapSize.cx, m_szAjustedBitmapSize.cy, hdcTemp, 0, 0, SRCCOPY);
|
||||
SelectBitmap(hdcTemp, hbmpSafe2);
|
||||
DeleteDC(hdcTemp);
|
||||
}
|
||||
|
||||
#ifdef USE_MEM_DC
|
||||
BitBlt(hdc, prcPaint->left, prcPaint->top, nClientWidth, nClientHeight, hdcMem, prcPaint->left, prcPaint->top, SRCCOPY);
|
||||
SelectBitmap(hdcMem, hbmpSafe);
|
||||
DeleteDC(hdcMem);
|
||||
DeleteBitmap(hbmpMem);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bIgnoreScrollPos - pass true to disregard any existing scrollbar styles.
|
||||
*/
|
||||
void CImageView::ResizeImageView(BOOL bIgnoreScrollPos)
|
||||
{
|
||||
SCROLLINFO sinfo;
|
||||
RECT rcClient;
|
||||
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
if (! bIgnoreScrollPos)
|
||||
{
|
||||
sinfo.fMask = SIF_POS;
|
||||
GetScrollInfo(m_hwnd, SB_HORZ, &sinfo);
|
||||
}
|
||||
else
|
||||
sinfo.nPos = 0;
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
sinfo.nMin = 0;
|
||||
sinfo.nMax = m_szAjustedBitmapSize.cx > 0 ? m_szAjustedBitmapSize.cx - 1 : 0;
|
||||
sinfo.nPage = rcClient.right;
|
||||
ValidateScrollInfo(&sinfo);
|
||||
SetScrollInfo(m_hwnd, SB_HORZ, &sinfo, TRUE);
|
||||
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
if (! bIgnoreScrollPos)
|
||||
{
|
||||
sinfo.fMask = SIF_POS;
|
||||
GetScrollInfo(m_hwnd, SB_VERT, &sinfo);
|
||||
}
|
||||
else
|
||||
sinfo.nPos = 0;
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
sinfo.nMin = 0;
|
||||
sinfo.nMax = m_szAjustedBitmapSize.cy > 0 ? m_szAjustedBitmapSize.cy - 1 : 0;
|
||||
sinfo.nPage = rcClient.bottom;
|
||||
ValidateScrollInfo(&sinfo);
|
||||
SetScrollInfo(m_hwnd, SB_VERT, &sinfo, TRUE);
|
||||
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nScrollBarType - scrollbar type.
|
||||
* @param nScrollCode - scroll code.
|
||||
*/
|
||||
void CImageView::ScrollImageView(int nScrollBarType, int nScrollCode)
|
||||
{
|
||||
_ASSERTE(nScrollBarType == SB_HORZ || nScrollBarType == SB_VERT);
|
||||
|
||||
SCROLLINFO sinfo;
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
if (nScrollCode == SB_THUMBTRACK)
|
||||
sinfo.fMask |= SIF_TRACKPOS;
|
||||
GetScrollInfo(m_hwnd, nScrollBarType, &sinfo);
|
||||
int nOldPos = sinfo.nPos;
|
||||
|
||||
int nLineOffset = LOWORD(GetDialogBaseUnits());
|
||||
|
||||
switch (nScrollCode)
|
||||
{
|
||||
case SB_LINEUP:
|
||||
//case SB_LINELEFT:
|
||||
sinfo.nPos -= nLineOffset;
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
//case SB_LINERIGHT:
|
||||
sinfo.nPos += nLineOffset;
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
//case SB_PAGELEFT:
|
||||
sinfo.nPos -= sinfo.nPage;
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
//case SB_PAGERIGHT:
|
||||
sinfo.nPos += sinfo.nPage;
|
||||
break;
|
||||
case SB_THUMBTRACK:
|
||||
sinfo.nPos = sinfo.nTrackPos;
|
||||
break;
|
||||
case SB_TOP:
|
||||
//case SB_LEFT:
|
||||
sinfo.nPos = 0;
|
||||
break;
|
||||
case SB_BOTTOM:
|
||||
//case SB_RIGHT:
|
||||
sinfo.nPos = sinfo.nMax;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
ValidateScrollInfo(&sinfo);
|
||||
sinfo.fMask = SIF_POS;
|
||||
SetScrollInfo(m_hwnd, nScrollBarType, &sinfo, TRUE);
|
||||
|
||||
if (sinfo.nPos != nOldPos)
|
||||
{
|
||||
int nHorOffset, nVertOffset;
|
||||
if (nScrollBarType == SB_HORZ)
|
||||
{
|
||||
nHorOffset = nOldPos - sinfo.nPos;
|
||||
nVertOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nHorOffset = 0;
|
||||
nVertOffset = nOldPos - sinfo.nPos;
|
||||
}
|
||||
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwnd, &rcClient);
|
||||
// Explicitly clip output to override style CS_PARENTDC.
|
||||
ScrollWindowEx(m_hwnd, nHorOffset, nVertOffset, &rcClient, &rcClient, NULL, NULL, SW_INVALIDATE);
|
||||
UpdateWindow(m_hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - first message parameter.
|
||||
* @param lParam - second message parameter.
|
||||
*/
|
||||
LRESULT CALLBACK CImageView::ImageViewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
int zDelta, zTotal, nScrollCode, nScrollBarType;
|
||||
LONG lWindowStyle;
|
||||
|
||||
CImageView* _this = (CImageView*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
_ASSERTE(_this != NULL);
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
SetFocus(hwnd);
|
||||
return 0;
|
||||
case WM_ERASEBKGND:
|
||||
return TRUE;
|
||||
case WM_PAINT:
|
||||
hdc = (HDC)wParam;
|
||||
if (! hdc)
|
||||
{
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
if (hdc)
|
||||
{
|
||||
_this->DrawImageView(hdc, &ps.rcPaint);
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
}
|
||||
else
|
||||
_this->DrawImageView(hdc, NULL);
|
||||
return 0;
|
||||
case WM_PRINTCLIENT:
|
||||
hdc = (HDC)wParam;
|
||||
_this->DrawImageView(hdc, NULL);
|
||||
return 0;
|
||||
case WM_SIZE:
|
||||
_this->ResizeImageView(FALSE);
|
||||
return 0;
|
||||
case WM_KEYDOWN:
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_LEFT:
|
||||
_this->ScrollImageView(SB_HORZ, SB_LINELEFT);
|
||||
break;
|
||||
case VK_UP:
|
||||
_this->ScrollImageView(SB_VERT, SB_LINEUP);
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
_this->ScrollImageView(SB_HORZ, SB_LINERIGHT);
|
||||
break;
|
||||
case VK_DOWN:
|
||||
_this->ScrollImageView(SB_VERT, SB_LINEDOWN);
|
||||
break;
|
||||
case VK_HOME:
|
||||
if (GetKeyState(VK_CONTROL) < 0)
|
||||
_this->ScrollImageView(SB_VERT, SB_TOP);
|
||||
else
|
||||
_this->ScrollImageView(SB_HORZ, SB_LEFT);
|
||||
break;
|
||||
case VK_END:
|
||||
if (GetKeyState(VK_CONTROL) < 0)
|
||||
_this->ScrollImageView(SB_VERT, SB_BOTTOM);
|
||||
else
|
||||
_this->ScrollImageView(SB_HORZ, SB_RIGHT);
|
||||
break;
|
||||
case VK_PRIOR:
|
||||
_this->ScrollImageView(SB_VERT, SB_PAGEUP);
|
||||
break;
|
||||
case VK_NEXT:
|
||||
_this->ScrollImageView(SB_VERT, SB_PAGEDOWN);
|
||||
break;
|
||||
case VK_ADD:
|
||||
_this->ZoomIn();
|
||||
break;
|
||||
case VK_SUBTRACT:
|
||||
_this->ZoomOut();
|
||||
break;
|
||||
case VK_MULTIPLY:
|
||||
_this->FitImage();
|
||||
break;
|
||||
case VK_DIVIDE:
|
||||
case VK_NUMPAD0:
|
||||
case _T('0'):
|
||||
_this->ResetSize();
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
case WM_HSCROLL:
|
||||
_this->ScrollImageView(SB_HORZ, LOWORD(wParam));
|
||||
return 0;
|
||||
case WM_VSCROLL:
|
||||
_this->ScrollImageView(SB_VERT, LOWORD(wParam));
|
||||
return 0;
|
||||
case WM_MOUSEWHEEL:
|
||||
zDelta = (int)(short)HIWORD(wParam);
|
||||
if (_this->m_nWheelLines == WHEEL_PAGESCROLL)
|
||||
nScrollCode = zDelta > 0 ? SB_PAGEUP : SB_PAGEDOWN;
|
||||
else
|
||||
nScrollCode = zDelta > 0 ? SB_LINEUP : SB_LINEDOWN;
|
||||
zTotal = abs(zDelta) / WHEEL_DELTA;
|
||||
if (_this->m_nWheelLines != WHEEL_PAGESCROLL)
|
||||
zTotal *= _this->m_nWheelLines;
|
||||
lWindowStyle = GetWindowLong(hwnd, GWL_STYLE);
|
||||
|
||||
if (lWindowStyle & WS_VSCROLL)
|
||||
nScrollBarType = SB_VERT;
|
||||
else if (lWindowStyle & WS_HSCROLL)
|
||||
nScrollBarType = SB_HORZ;
|
||||
else
|
||||
return 0;
|
||||
for (int i = 0; i < zTotal; ++i)
|
||||
_this->ScrollImageView(nScrollBarType, nScrollCode);
|
||||
return 0;
|
||||
case WM_SETTINGCHANGE:
|
||||
if (wParam == SPI_SETWHEELSCROLLLINES)
|
||||
{
|
||||
if (! SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &_this->m_nWheelLines, 0))
|
||||
_this->m_nWheelLines = g_dwDefaultNumWheels;
|
||||
}
|
||||
return 0;
|
||||
case WM_GETDLGCODE:
|
||||
return DLGC_WANTARROWS;
|
||||
default:
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - image view window handle.
|
||||
*/
|
||||
void CImageView::Attach(HWND hwnd)
|
||||
{
|
||||
_ASSERTE(hwnd != NULL);
|
||||
_ASSERTE(m_hwnd == NULL);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
|
||||
if (! SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &m_nWheelLines, 0))
|
||||
m_nWheelLines = g_dwDefaultNumWheels;
|
||||
|
||||
m_hwnd = hwnd;
|
||||
m_pfnOldImageViewWndProc = SubclassWindow(hwnd, ImageViewWndProc);
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this);
|
||||
// Preserve original window styles that could be modified by SetScrollInfo().
|
||||
m_lOldStyle = GetWindowLong(hwnd, GWL_STYLE);
|
||||
ResizeImageView(TRUE);
|
||||
}
|
||||
|
||||
void CImageView::Detach(void)
|
||||
{
|
||||
if (m_pfnOldImageViewWndProc)
|
||||
{
|
||||
SubclassWindow(m_hwnd, m_pfnOldImageViewWndProc);
|
||||
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, NULL);
|
||||
|
||||
SCROLLINFO sinfo;
|
||||
ZeroMemory(&sinfo, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
sinfo.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
|
||||
SetScrollInfo(m_hwnd, SB_HORZ, &sinfo, FALSE);
|
||||
SetScrollInfo(m_hwnd, SB_VERT, &sinfo, FALSE);
|
||||
SetWindowLong(m_hwnd, GWL_STYLE, m_lOldStyle);
|
||||
|
||||
InvalidateRect(m_hwnd, NULL, TRUE);
|
||||
InitVars();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hBitmap - image handle.
|
||||
*/
|
||||
void CImageView::SetImage(HBITMAP hBitmap)
|
||||
{
|
||||
_ASSERTE(hBitmap != NULL);
|
||||
_ASSERTE(m_hBitmap == NULL);
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
m_hBitmap = hBitmap;
|
||||
BITMAP bmpInfo;
|
||||
GetObject(hBitmap, sizeof(bmpInfo), &bmpInfo);
|
||||
m_szBitmapSize.cx = bmpInfo.bmWidth;
|
||||
m_szBitmapSize.cy = bmpInfo.bmHeight;
|
||||
FitImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prcClient - pointer to client rectangle.
|
||||
*/
|
||||
void CImageView::GetBiggestClientRect(RECT* prcClient)
|
||||
{
|
||||
GetWindowRect(m_hwnd, prcClient);
|
||||
|
||||
prcClient->right -= prcClient->left;
|
||||
prcClient->left = 0;
|
||||
int nCXEdge = GetSystemMetrics(SM_CXEDGE) * 2;
|
||||
if (prcClient->right >= nCXEdge)
|
||||
prcClient->right -= nCXEdge;
|
||||
else
|
||||
prcClient->right = 0;
|
||||
|
||||
prcClient->bottom -= prcClient->top;
|
||||
prcClient->top = 0;
|
||||
int nCYEdge = GetSystemMetrics(SM_CYEDGE) * 2;
|
||||
if (prcClient->bottom >= nCYEdge)
|
||||
prcClient->bottom -= nCYEdge;
|
||||
else
|
||||
prcClient->bottom = 0;
|
||||
}
|
||||
|
||||
void CImageView::FitImage(void)
|
||||
{
|
||||
RECT rcClient;
|
||||
GetBiggestClientRect(&rcClient);
|
||||
|
||||
if (rcClient.right < m_szBitmapSize.cx || rcClient.bottom < m_szBitmapSize.cy)
|
||||
{
|
||||
int nProduct1 = rcClient.right * m_szBitmapSize.cy;
|
||||
int nProduct2 = rcClient.bottom * m_szBitmapSize.cx;
|
||||
if (nProduct1 < nProduct2)
|
||||
{
|
||||
m_szAjustedBitmapSize.cx = rcClient.right;
|
||||
m_szAjustedBitmapSize.cy = nProduct1 / m_szBitmapSize.cx;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szAjustedBitmapSize.cx = nProduct2 / m_szBitmapSize.cy;
|
||||
m_szAjustedBitmapSize.cy = rcClient.bottom;
|
||||
}
|
||||
}
|
||||
else
|
||||
m_szAjustedBitmapSize = m_szBitmapSize;
|
||||
ResizeImage();
|
||||
ResizeImageView(TRUE);
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
void CImageView::ResetSize(void)
|
||||
{
|
||||
m_szAjustedBitmapSize = m_szBitmapSize;
|
||||
ResizeImage();
|
||||
ResizeImageView(TRUE);
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
void CImageView::ResetImage(void)
|
||||
{
|
||||
if (m_hAdjustedBitmap)
|
||||
{
|
||||
DeleteBitmap(m_hAdjustedBitmap);
|
||||
m_hAdjustedBitmap = NULL;
|
||||
}
|
||||
m_hBitmap = NULL;
|
||||
}
|
||||
|
||||
void CImageView::ResizeImage(void)
|
||||
{
|
||||
if (m_hAdjustedBitmap)
|
||||
{
|
||||
DeleteBitmap(m_hAdjustedBitmap);
|
||||
m_hAdjustedBitmap = NULL;
|
||||
}
|
||||
HDC hdc = GetDC(m_hwnd);
|
||||
if (hdc)
|
||||
{
|
||||
HDC hdcSrc = CreateCompatibleDC(hdc);
|
||||
if (hdcSrc)
|
||||
{
|
||||
HBITMAP hbmpSafe = SelectBitmap(hdcSrc, m_hBitmap);
|
||||
m_hAdjustedBitmap = CreateCompatibleBitmap(hdc, m_szAjustedBitmapSize.cx, m_szAjustedBitmapSize.cy);
|
||||
if (m_hAdjustedBitmap)
|
||||
{
|
||||
HDC hdcDest = CreateCompatibleDC(hdc);
|
||||
if (hdcDest)
|
||||
{
|
||||
HBITMAP hbmpSafe2 = SelectBitmap(hdcDest, m_hAdjustedBitmap);
|
||||
StretchBlt(hdcDest, 0, 0, m_szAjustedBitmapSize.cx, m_szAjustedBitmapSize.cy, hdcSrc, 0, 0, m_szBitmapSize.cx, m_szBitmapSize.cy, SRCCOPY);
|
||||
SelectBitmap(hdcDest, hbmpSafe2);
|
||||
DeleteDC(hdcDest);
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteBitmap(m_hAdjustedBitmap);
|
||||
m_hAdjustedBitmap = NULL;
|
||||
}
|
||||
}
|
||||
SelectBitmap(hdcSrc, hbmpSafe);
|
||||
DeleteDC(hdcSrc);
|
||||
}
|
||||
ReleaseDC(m_hwnd, hdc);
|
||||
}
|
||||
}
|
||||
|
||||
void CImageView::ZoomIn(void)
|
||||
{
|
||||
int nHorPos = GetScrollPos(m_hwnd, SB_HORZ);
|
||||
int nVertPos = GetScrollPos(m_hwnd, SB_VERT);
|
||||
float fltRatio = (float)m_szAjustedBitmapSize.cx / (float)m_szBitmapSize.cx * 3.0f / 2.0f;
|
||||
SIZE szOldAjustedBitmapSize = m_szAjustedBitmapSize;
|
||||
m_szAjustedBitmapSize.cx = (int)((float)m_szBitmapSize.cx * fltRatio);
|
||||
m_szAjustedBitmapSize.cy = (int)((float)m_szBitmapSize.cy * fltRatio);
|
||||
ResizeImage();
|
||||
if (m_hAdjustedBitmap != NULL)
|
||||
{
|
||||
ResizeImageView(FALSE);
|
||||
SetScrollPos(m_hwnd, SB_HORZ, nHorPos * 3 / 2, TRUE);
|
||||
SetScrollPos(m_hwnd, SB_VERT, nVertPos * 3 / 2, TRUE);
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szAjustedBitmapSize = szOldAjustedBitmapSize;
|
||||
ResizeImage();
|
||||
}
|
||||
}
|
||||
|
||||
void CImageView::ZoomOut(void)
|
||||
{
|
||||
if (m_szAjustedBitmapSize.cx > 3 && m_szAjustedBitmapSize.cy > 3)
|
||||
{
|
||||
int nHorPos = GetScrollPos(m_hwnd, SB_HORZ);
|
||||
int nVertPos = GetScrollPos(m_hwnd, SB_VERT);
|
||||
float fltRatio = (float)m_szAjustedBitmapSize.cx / (float)m_szBitmapSize.cx * 2.0f / 3.0f;
|
||||
SIZE szOldAjustedBitmapSize = m_szAjustedBitmapSize;
|
||||
m_szAjustedBitmapSize.cx = (int)((float)m_szBitmapSize.cx * fltRatio);
|
||||
m_szAjustedBitmapSize.cy = (int)((float)m_szBitmapSize.cy * fltRatio);
|
||||
ResizeImage();
|
||||
if (m_hAdjustedBitmap != NULL)
|
||||
{
|
||||
ResizeImageView(FALSE);
|
||||
SetScrollPos(m_hwnd, SB_HORZ, nHorPos * 2 / 3, TRUE);
|
||||
SetScrollPos(m_hwnd, SB_VERT, nVertPos * 2 / 3, TRUE);
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szAjustedBitmapSize = szOldAjustedBitmapSize;
|
||||
ResizeImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
110
third-party/BugTrap-1.3-57bd515/source/ImageView.h
vendored
Normal file
110
third-party/BugTrap-1.3-57bd515/source/ImageView.h
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Image view control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Image view control class.
|
||||
class CImageView
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CImageView(void);
|
||||
/// De-initialize the object.
|
||||
~CImageView(void);
|
||||
/// Attach image view object to window handle.
|
||||
void Attach(HWND hwnd);
|
||||
/// Detach image view object to window handle.
|
||||
void Detach(void);
|
||||
/// Set image information.
|
||||
void SetImage(HBITMAP hBitmap);
|
||||
/// Reset image information.
|
||||
void ResetImage(void);
|
||||
/// Get image handle.
|
||||
HBITMAP GetImageHandle(void) const;
|
||||
/// Fit image to actual window size.
|
||||
void FitImage(void);
|
||||
/// Reset image size.
|
||||
void ResetSize(void);
|
||||
/// Zoom in image.
|
||||
void ZoomIn(void);
|
||||
/// Zoom out image.
|
||||
void ZoomOut(void);
|
||||
|
||||
enum
|
||||
{
|
||||
/// Number of symbols in one line.
|
||||
LINE_WIDTH = 16,
|
||||
/// Number of cached lines.
|
||||
NUMBER_OF_CACHED_LINES = 2000,
|
||||
/// Size of cache.
|
||||
CACHE_SIZE = LINE_WIDTH * NUMBER_OF_CACHED_LINES
|
||||
};
|
||||
|
||||
private:
|
||||
/// Protect the class from being accidentally copied.
|
||||
CImageView(const CImageView& rImageView);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CImageView& operator=(const CImageView& rImageView);
|
||||
/// Window procedure of image view window.
|
||||
static LRESULT CALLBACK ImageViewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Draw window client area.
|
||||
void DrawImageView(HDC hdc, const RECT* prcPaint);
|
||||
/// Resize image view client area.
|
||||
void ResizeImageView(BOOL bIgnoreScrollPos);
|
||||
/// Scroll image view client area.
|
||||
void ScrollImageView(int nScrollBarType, int nScrollCode);
|
||||
/// Resize image.
|
||||
void ResizeImage(void);
|
||||
/// Initialize variables.
|
||||
void InitVars(void);
|
||||
/// Get client rectangle with no scrollbars.
|
||||
void GetBiggestClientRect(RECT* prcClient);
|
||||
|
||||
/// Initial image handle.
|
||||
HBITMAP m_hBitmap;
|
||||
/// Initial bitmap size.
|
||||
SIZE m_szBitmapSize;
|
||||
/// Image handle with adjusted size.
|
||||
HBITMAP m_hAdjustedBitmap;
|
||||
/// Adjusted bitmap size.
|
||||
SIZE m_szAjustedBitmapSize;
|
||||
/// Window handle.
|
||||
HWND m_hwnd;
|
||||
/// Old static window procedure.
|
||||
WNDPROC m_pfnOldImageViewWndProc;
|
||||
/// Number of first cache lined.
|
||||
DWORD m_dwFirstCachedLine;
|
||||
/// Old window style.
|
||||
LONG m_lOldStyle;
|
||||
/// Number of wheel lines.
|
||||
int m_nWheelLines;
|
||||
};
|
||||
|
||||
inline CImageView::CImageView(void) : m_hAdjustedBitmap(NULL)
|
||||
{
|
||||
InitVars();
|
||||
}
|
||||
|
||||
inline CImageView::~CImageView(void)
|
||||
{
|
||||
ResetImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return image handle.
|
||||
*/
|
||||
inline HBITMAP CImageView::GetImageHandle(void) const
|
||||
{
|
||||
return m_hBitmap;
|
||||
}
|
||||
139
third-party/BugTrap-1.3-57bd515/source/InMemLogFile.cpp
vendored
Normal file
139
third-party/BugTrap-1.3-57bd515/source/InMemLogFile.cpp
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Base class for in-memory log file.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "InMemLogFile.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param dwInitialLogSizeInBytes - initial log file size.
|
||||
*/
|
||||
CInMemLogFile::CInMemLogFile(DWORD dwInitialLogSizeInBytes)
|
||||
{
|
||||
m_dwLogSizeInEntries = MAXDWORD;
|
||||
m_dwLogSizeInBytes = MAXDWORD;
|
||||
m_dwNumEntries = 0;
|
||||
m_dwInitialLogSizeInBytes = dwInitialLogSizeInBytes;
|
||||
m_dwNumBytes = dwInitialLogSizeInBytes;
|
||||
m_pFirstEntry = NULL;
|
||||
m_pLastEntry = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pLogEntry - new log entry.
|
||||
*/
|
||||
void CInMemLogFile::AddToHead(CLogEntry* pLogEntry)
|
||||
{
|
||||
_ASSERTE(pLogEntry != NULL);
|
||||
pLogEntry->m_pPrevEntry = NULL;
|
||||
pLogEntry->m_pNextEntry = m_pFirstEntry;
|
||||
if (m_pFirstEntry)
|
||||
m_pFirstEntry->m_pPrevEntry = pLogEntry;
|
||||
else
|
||||
m_pLastEntry = pLogEntry;
|
||||
m_pFirstEntry = pLogEntry;
|
||||
m_dwNumBytes += pLogEntry->m_dwSize;
|
||||
++m_dwNumEntries;
|
||||
FreeTail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pLogEntry - new log entry.
|
||||
*/
|
||||
void CInMemLogFile::AddToTail(CLogEntry* pLogEntry)
|
||||
{
|
||||
_ASSERTE(pLogEntry != NULL);
|
||||
pLogEntry->m_pPrevEntry = m_pLastEntry;
|
||||
pLogEntry->m_pNextEntry = NULL;
|
||||
if (m_pLastEntry)
|
||||
m_pLastEntry->m_pNextEntry = pLogEntry;
|
||||
else
|
||||
m_pFirstEntry = pLogEntry;
|
||||
m_pLastEntry = pLogEntry;
|
||||
m_dwNumBytes += pLogEntry->m_dwSize;
|
||||
++m_dwNumEntries;
|
||||
FreeHead();
|
||||
}
|
||||
|
||||
void CInMemLogFile::DeleteHead(void)
|
||||
{
|
||||
_ASSERTE(m_pFirstEntry != NULL);
|
||||
CLogEntry* pLogEntry = m_pFirstEntry;
|
||||
m_pFirstEntry = pLogEntry->m_pNextEntry;
|
||||
if (m_pFirstEntry)
|
||||
m_pFirstEntry->m_pPrevEntry = NULL;
|
||||
else
|
||||
m_pLastEntry = NULL;
|
||||
m_dwNumBytes -= pLogEntry->m_dwSize;
|
||||
--m_dwNumEntries;
|
||||
delete[] (PBYTE)pLogEntry;
|
||||
}
|
||||
|
||||
void CInMemLogFile::DeleteTail(void)
|
||||
{
|
||||
_ASSERTE(m_pLastEntry != NULL);
|
||||
CLogEntry* pLogEntry = m_pLastEntry;
|
||||
m_pLastEntry = pLogEntry->m_pPrevEntry;
|
||||
if (m_pLastEntry)
|
||||
m_pLastEntry->m_pNextEntry = NULL;
|
||||
else
|
||||
m_pFirstEntry = NULL;
|
||||
m_dwNumBytes -= pLogEntry->m_dwSize;
|
||||
--m_dwNumEntries;
|
||||
delete[] (PBYTE)pLogEntry;
|
||||
}
|
||||
|
||||
void CInMemLogFile::FreeHead(void)
|
||||
{
|
||||
if (m_dwLogSizeInEntries != MAXDWORD)
|
||||
{
|
||||
while (m_dwNumEntries > m_dwLogSizeInEntries && m_dwNumEntries > 0)
|
||||
DeleteHead();
|
||||
}
|
||||
if (m_dwLogSizeInBytes != MAXDWORD)
|
||||
{
|
||||
while (m_dwNumBytes > m_dwLogSizeInBytes && m_dwNumEntries > 0)
|
||||
DeleteHead();
|
||||
}
|
||||
}
|
||||
|
||||
void CInMemLogFile::FreeTail(void)
|
||||
{
|
||||
if (m_dwLogSizeInEntries != MAXDWORD)
|
||||
{
|
||||
while (m_dwNumEntries > m_dwLogSizeInEntries && m_dwNumEntries > 0)
|
||||
DeleteTail();
|
||||
}
|
||||
if (m_dwLogSizeInBytes != MAXDWORD)
|
||||
{
|
||||
while (m_dwNumBytes > m_dwLogSizeInBytes && m_dwNumEntries > 0)
|
||||
DeleteTail();
|
||||
}
|
||||
}
|
||||
|
||||
void CInMemLogFile::FreeEntries(void)
|
||||
{
|
||||
while (m_pFirstEntry)
|
||||
{
|
||||
CLogEntry* pNextEntry = m_pFirstEntry->m_pNextEntry;
|
||||
delete[] (PBYTE)m_pFirstEntry;
|
||||
m_pFirstEntry = pNextEntry;
|
||||
}
|
||||
m_pLastEntry = NULL;
|
||||
m_dwNumEntries = 0;
|
||||
m_dwNumBytes = m_dwInitialLogSizeInBytes;
|
||||
}
|
||||
183
third-party/BugTrap-1.3-57bd515/source/InMemLogFile.h
vendored
Normal file
183
third-party/BugTrap-1.3-57bd515/source/InMemLogFile.h
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Base class for in-memory log file.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "LogFile.h"
|
||||
|
||||
/**
|
||||
* @brief Base class for in-memory log file.
|
||||
*/
|
||||
class CInMemLogFile : public CLogFile
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CInMemLogFile(DWORD dwInitialLogSizeInBytes);
|
||||
/// Destroy the object.
|
||||
virtual ~CInMemLogFile(void);
|
||||
/// Get number of records in custom log file.
|
||||
virtual DWORD GetLogSizeInEntries(void) const;
|
||||
/// Set number of records in custom log file.
|
||||
virtual BOOL SetLogSizeInEntries(DWORD dwLogSizeInEntries);
|
||||
/// Get maximum log file size in bytes.
|
||||
virtual DWORD GetLogSizeInBytes(void) const;
|
||||
/// Set maximum log file size in bytes.
|
||||
virtual BOOL SetLogSizeInBytes(DWORD dwLogSizeInBytes);
|
||||
/// Clear log entries.
|
||||
virtual BOOL ClearEntries(void);
|
||||
/// Close log file.
|
||||
virtual void Close(void);
|
||||
/// Get number of entries in a log.
|
||||
DWORD GetNumEntries(void) const;
|
||||
/// Get number of bytes in a log.
|
||||
DWORD GetNumBytes(void) const;
|
||||
|
||||
protected:
|
||||
/// Log entry data.
|
||||
struct CLogEntry
|
||||
{
|
||||
/// Pointer to the previous log entry.
|
||||
CLogEntry* m_pPrevEntry;
|
||||
/// Pointer to the next log entry.
|
||||
CLogEntry* m_pNextEntry;
|
||||
/// Buffer size in bytes.
|
||||
DWORD m_dwSize;
|
||||
};
|
||||
|
||||
/// Get pointer to the first log entry.
|
||||
CLogEntry* GetFirstEntry(void) const;
|
||||
/// Get pointer to the last log entry.
|
||||
CLogEntry* GetLastEntry(void) const;
|
||||
/// Add log entry to the head.
|
||||
void AddToHead(CLogEntry* pLogEntry);
|
||||
/// Add log entry to the tail.
|
||||
void AddToTail(CLogEntry* pLogEntry);
|
||||
/// Remove the entry from the head.
|
||||
void DeleteHead(void);
|
||||
/// Remove the entry from the tail.
|
||||
void DeleteTail(void);
|
||||
/// Remove extra head entries.
|
||||
void FreeHead(void);
|
||||
/// Remove extra tail entries.
|
||||
void FreeTail(void);
|
||||
/// Free log entries.
|
||||
void FreeEntries(void);
|
||||
|
||||
private:
|
||||
/// Protects the class from being accidentally copied.
|
||||
CInMemLogFile(const CInMemLogFile& rLogFile);
|
||||
/// Protects the class from being accidentally copied.
|
||||
CInMemLogFile& operator=(const CInMemLogFile& rLogFile);
|
||||
|
||||
/// Number of entries kept in memory.
|
||||
DWORD m_dwNumEntries;
|
||||
/// Size of log in bytes.
|
||||
DWORD m_dwNumBytes;
|
||||
/// Initial log size in bytes.
|
||||
DWORD m_dwInitialLogSizeInBytes;
|
||||
/// Maximum number of records in custom log file.
|
||||
DWORD m_dwLogSizeInEntries;
|
||||
/// Maximum log file size in bytes.
|
||||
DWORD m_dwLogSizeInBytes;
|
||||
/// Pointer to the first log entry.
|
||||
CLogEntry* m_pFirstEntry;
|
||||
/// Pointer to the last log entry.
|
||||
CLogEntry* m_pLastEntry;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return maximum number of records in log file.
|
||||
*/
|
||||
inline DWORD CInMemLogFile::GetLogSizeInEntries(void) const
|
||||
{
|
||||
return m_dwLogSizeInEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwLogSizeInEntries - maximum number of records in log file.
|
||||
* @return true if operation was accepted.
|
||||
*/
|
||||
inline BOOL CInMemLogFile::SetLogSizeInEntries(DWORD dwLogSizeInEntries)
|
||||
{
|
||||
m_dwLogSizeInEntries = dwLogSizeInEntries;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return maximum log file size in bytes.
|
||||
*/
|
||||
inline DWORD CInMemLogFile::GetLogSizeInBytes(void) const
|
||||
{
|
||||
return m_dwLogSizeInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwLogSizeInBytes - maximum log file size in bytes.
|
||||
* @return true if operation was accepted.
|
||||
*/
|
||||
inline BOOL CInMemLogFile::SetLogSizeInBytes(DWORD dwLogSizeInBytes)
|
||||
{
|
||||
m_dwLogSizeInBytes = dwLogSizeInBytes;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to the first log entry.
|
||||
*/
|
||||
inline CInMemLogFile::CLogEntry* CInMemLogFile::GetFirstEntry(void) const
|
||||
{
|
||||
return m_pFirstEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to the last log entry.
|
||||
*/
|
||||
inline CInMemLogFile::CLogEntry* CInMemLogFile::GetLastEntry(void) const
|
||||
{
|
||||
return m_pLastEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of entries in a log.
|
||||
*/
|
||||
inline DWORD CInMemLogFile::GetNumEntries(void) const
|
||||
{
|
||||
return m_dwNumEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of bytes in a log.
|
||||
*/
|
||||
inline DWORD CInMemLogFile::GetNumBytes(void) const
|
||||
{
|
||||
return m_dwNumBytes;
|
||||
}
|
||||
|
||||
inline CInMemLogFile::~CInMemLogFile(void)
|
||||
{
|
||||
FreeEntries();
|
||||
}
|
||||
|
||||
/*
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
inline BOOL CInMemLogFile::ClearEntries(void)
|
||||
{
|
||||
FreeEntries();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline void CInMemLogFile::Close(void)
|
||||
{
|
||||
}
|
||||
37
third-party/BugTrap-1.3-57bd515/source/InputStream.cpp
vendored
Normal file
37
third-party/BugTrap-1.3-57bd515/source/InputStream.cpp
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Input stream.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "InputStream.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param arrBytes - array of bytes.
|
||||
* @param nCount - size of the array.
|
||||
* @return number of retrieved bytes.
|
||||
*/
|
||||
size_t CInputStream::ReadBytes(unsigned char* arrBytes, size_t nCount)
|
||||
{
|
||||
size_t nNumRead = 0;
|
||||
while (nNumRead < nCount)
|
||||
{
|
||||
if (! ReadByte(arrBytes[nNumRead]))
|
||||
break;
|
||||
++nNumRead;
|
||||
}
|
||||
return nNumRead;
|
||||
}
|
||||
29
third-party/BugTrap-1.3-57bd515/source/InputStream.h
vendored
Normal file
29
third-party/BugTrap-1.3-57bd515/source/InputStream.h
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Input stream.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BaseStream.h"
|
||||
|
||||
/// Input stream.
|
||||
class CInputStream : public virtual CBaseStream
|
||||
{
|
||||
public:
|
||||
/// Return true if end of stream has been reached. This function is required.
|
||||
virtual bool IsEndOfStream(void) const = 0;
|
||||
/// Read one byte from the stream. This function is required.
|
||||
virtual bool ReadByte(unsigned char& bValue) = 0;
|
||||
/// Read array of bytes from the stream. This function is optional.
|
||||
virtual size_t ReadBytes(unsigned char* arrBytes, size_t nCount);
|
||||
};
|
||||
89
third-party/BugTrap-1.3-57bd515/source/InterfacePtr.h
vendored
Normal file
89
third-party/BugTrap-1.3-57bd515/source/InterfacePtr.h
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Smart pointer to COM interface.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
template <class INTERFACE>
|
||||
class CInterfacePtr
|
||||
{
|
||||
public:
|
||||
CInterfacePtr(void) { m_ptr = NULL; }
|
||||
CInterfacePtr(int iNull) { _ASSERTE(iNull == 0); iNull; m_ptr = NULL; }
|
||||
CInterfacePtr(INTERFACE* ptr) { Assign(ptr); }
|
||||
CInterfacePtr(const CInterfacePtr& iptr) { Assign(iptr.m_ptr); }
|
||||
~CInterfacePtr(void) { Free(); }
|
||||
const CInterfacePtr& operator=(INTERFACE* ptr) { Free(); Assign(ptr); return *this; }
|
||||
const CInterfacePtr& operator=(const CInterfacePtr& iptr) { Free(); Assign(iptr.m_ptr); return *this; }
|
||||
|
||||
INTERFACE** operator&(void) { _ASSERTE(m_ptr == NULL); return &m_ptr; }
|
||||
INTERFACE& operator*(void) const { _ASSERTE(m_ptr != NULL); return *m_ptr; }
|
||||
INTERFACE* operator->(void) const { _ASSERTE(m_ptr != NULL); return m_ptr; }
|
||||
bool operator!(void) const { return (m_ptr == NULL); }
|
||||
operator INTERFACE*(void) const { return m_ptr; }
|
||||
|
||||
friend bool operator==(const CInterfacePtr& iptr1, const CInterfacePtr& iptr2) { return iptr1.m_ptr == iptr2.m_ptr; }
|
||||
friend bool operator!=(const CInterfacePtr& iptr1, const CInterfacePtr& iptr2) { return iptr1.m_ptr != iptr2.m_ptr; }
|
||||
friend bool operator<(const CInterfacePtr& iptr1, const CInterfacePtr& iptr2) { return iptr1.m_ptr < iptr2.m_ptr; }
|
||||
friend bool operator<=(const CInterfacePtr& iptr1, const CInterfacePtr& iptr2) { return iptr1.m_ptr <= iptr2.m_ptr; }
|
||||
friend bool operator>(const CInterfacePtr& iptr1, const CInterfacePtr& iptr2) { return iptr1.m_ptr > iptr2.m_ptr; }
|
||||
friend bool operator>=(const CInterfacePtr& iptr1, const CInterfacePtr& iptr2) { return iptr1.m_ptr >= iptr2.m_ptr; }
|
||||
|
||||
template <class INTERFACE2>
|
||||
HRESULT QueryInterface(INTERFACE2*& ptr) const { _ASSERTE(m_ptr != NULL); m_ptr->QueryInterface(__uuidof(INTERFACE2), (void**)&ptr); }
|
||||
template <class INTERFACE2>
|
||||
HRESULT QueryInterface(CInterfacePtr<INTERFACE2>& iptr2) const { _ASSERTE(m_ptr != NULL); _ASSERTE(iptr2.m_ptr == NULL); m_ptr->QueryInterface(__uuidof(INTERFACE2), (void**)&iptr2.m_ptr); }
|
||||
|
||||
bool IsNull(void) const { return (m_ptr == NULL); }
|
||||
void Release(void) { Free(); m_ptr = NULL; }
|
||||
void Attach(INTERFACE* ptr) { Free(); m_ptr = ptr; }
|
||||
INTERFACE* Detach(void) { INTERFACE* ptr = m_ptr; m_ptr = NULL; return ptr; }
|
||||
|
||||
HRESULT CreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL) { _ASSERTE(m_ptr == NULL); return CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(INTERFACE), (void**)&m_ptr); }
|
||||
HRESULT CreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL);
|
||||
|
||||
template <class INTERFACE2>
|
||||
bool IsEqualObject(INTERFACE2* ptr2) const;
|
||||
template <class INTERFACE2>
|
||||
bool IsEqualObject(const CInterfacePtr<INTERFACE2>& iptr2) const { return IsEqualObject(iptr2.m_ptr); }
|
||||
|
||||
private:
|
||||
void Assign(INTERFACE* ptr) { if (ptr) ptr->AddRef(); m_ptr = ptr; }
|
||||
void Free(void) const { if (m_ptr) m_ptr->Release(); }
|
||||
INTERFACE* m_ptr;
|
||||
};
|
||||
|
||||
template <class INTERFACE>
|
||||
template <class INTERFACE2>
|
||||
bool CInterfacePtr<INTERFACE>::IsEqualObject(INTERFACE2* ptr2) const
|
||||
{
|
||||
if (m_ptr == NULL && ptr2 == NULL)
|
||||
return true;
|
||||
if (m_ptr == NULL || ptr2 == NULL)
|
||||
return false;
|
||||
CInterfacePtr<IUnknown> pUnk1;
|
||||
m_ptr->QueryInterface(__uuidof(IUnknown), (void**)&pUnk1);
|
||||
_ASSERTE(! pUnk1.IsNull());
|
||||
CInterfacePtr<IUnknown> pUnk2;
|
||||
ptr2->QueryInterface(__uuidof(IUnknown), (void**)&pUnk2);
|
||||
_ASSERTE(! pUnk2.IsNull());
|
||||
return (pUnk1 == pUnk2);
|
||||
}
|
||||
|
||||
template <class INTERFACE>
|
||||
HRESULT CInterfacePtr<INTERFACE>::CreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter, DWORD dwClsContext)
|
||||
{
|
||||
CLSID clsid;
|
||||
HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
|
||||
return (SUCCEEDED(hr) ? CreateInstance(clsid, pUnkOuter, dwClsContext) : hr);
|
||||
}
|
||||
160
third-party/BugTrap-1.3-57bd515/source/LayoutManager.cpp
vendored
Normal file
160
third-party/BugTrap-1.3-57bd515/source/LayoutManager.cpp
vendored
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Layout manager class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "LayoutManager.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param nCtlID - control ID.
|
||||
* @param nRatioX1 - left coordinate ratio.
|
||||
* @param nRatioY1 - top coordinate ratio.
|
||||
* @param nRatioX2 - right coordinate ratio.
|
||||
* @param nRatioY2 - bottom coordinate ratio.
|
||||
*/
|
||||
LAYOUT_INFO::LAYOUT_INFO(int nCtlID, int nRatioX1, int nRatioY1, int nRatioX2, int nRatioY2)
|
||||
{
|
||||
m_nCtlID = nCtlID;
|
||||
m_nRatioX1 = nRatioX1;
|
||||
m_nRatioY1 = nRatioY1;
|
||||
m_nRatioX2 = nRatioX2;
|
||||
m_nRatioY2 = nRatioY2;
|
||||
ZeroMemory(&m_rcOriginal, sizeof(m_rcOriginal));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwndParent - parent window handle.
|
||||
* @param arrLayout - array of control layout info blocks.
|
||||
* @param nItemCount - number of control layout info blocks.
|
||||
* @param bAddSizeBox - pass true if size box must be added to the dialog.
|
||||
*/
|
||||
void CLayoutManager::InitLayout(HWND hwndParent, LAYOUT_INFO arrLayout[], int nItemCount, bool bAddSizeBox)
|
||||
{
|
||||
LONG lStyle = GetWindowLong(hwndParent, GWL_STYLE);
|
||||
lStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
||||
SetWindowLong(hwndParent, GWL_STYLE, lStyle);
|
||||
|
||||
RECT rcWindow;
|
||||
GetWindowRect(hwndParent, &rcWindow);
|
||||
m_ptMinWindowSize.x = rcWindow.right - rcWindow.left;
|
||||
m_ptMinWindowSize.y = rcWindow.bottom - rcWindow.top;
|
||||
|
||||
RECT rcClient;
|
||||
GetClientRect(hwndParent, &rcClient);
|
||||
m_ptMinClientSize.x = rcClient.right;
|
||||
m_ptMinClientSize.y = rcClient.bottom;
|
||||
|
||||
m_hwndParent = hwndParent;
|
||||
m_arrLayout = arrLayout;
|
||||
m_nItemCount = nItemCount;
|
||||
|
||||
for (int iPos = 0; iPos < nItemCount; ++iPos)
|
||||
{
|
||||
LAYOUT_INFO& rLayoutInfo = arrLayout[iPos];
|
||||
HWND hwndCtl = GetDlgItem(hwndParent, rLayoutInfo.m_nCtlID);
|
||||
RECT& rcOriginal = rLayoutInfo.m_rcOriginal;
|
||||
GetWindowRect(hwndCtl, &rcOriginal);
|
||||
ScreenToClient(hwndParent, (PPOINT)&rcOriginal);
|
||||
ScreenToClient(hwndParent, (PPOINT)&rcOriginal + 1);
|
||||
}
|
||||
|
||||
m_hwndSizeBox = bAddSizeBox ?
|
||||
CreateWindow(WC_SCROLLBAR, NULL, WS_CHILD | WS_VISIBLE | WS_GROUP | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN | WS_CLIPSIBLINGS,
|
||||
rcClient.left, rcClient.top, rcClient.right, rcClient.bottom, hwndParent, NULL, g_hInstance, NULL) : NULL;
|
||||
}
|
||||
|
||||
void CLayoutManager::ApplyLayout(void)
|
||||
{
|
||||
if (! m_arrLayout)
|
||||
return;
|
||||
|
||||
RECT rcClient;
|
||||
GetClientRect(m_hwndParent, &rcClient);
|
||||
const int nWindowDeltaX = rcClient.right - m_ptMinClientSize.x;
|
||||
const int nWindowDeltaY = rcClient.bottom - m_ptMinClientSize.y;
|
||||
|
||||
BOOL bVisible = IsWindowVisible(m_hwndParent);
|
||||
if (bVisible)
|
||||
SendMessage(m_hwndParent, WM_SETREDRAW, FALSE, 0);
|
||||
|
||||
int iPos;
|
||||
for (iPos = 0; iPos < m_nItemCount; ++iPos)
|
||||
{
|
||||
const LAYOUT_INFO& rLayoutInfo = m_arrLayout[iPos];
|
||||
const RECT& rcOriginal = rLayoutInfo.m_rcOriginal;
|
||||
RECT rcCtl;
|
||||
|
||||
if (nWindowDeltaX > 0)
|
||||
{
|
||||
rcCtl.left = rcOriginal.left + nWindowDeltaX * rLayoutInfo.m_nRatioX1 / ALIGN_RANGE;
|
||||
rcCtl.right = rcOriginal.right + nWindowDeltaX * rLayoutInfo.m_nRatioX2 / ALIGN_RANGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
rcCtl.left = rcOriginal.left;
|
||||
rcCtl.right = rcOriginal.right;
|
||||
}
|
||||
|
||||
if (nWindowDeltaY > 0)
|
||||
{
|
||||
rcCtl.top = rcOriginal.top + nWindowDeltaY * rLayoutInfo.m_nRatioY1 / ALIGN_RANGE;
|
||||
rcCtl.bottom = rcOriginal.bottom + nWindowDeltaY * rLayoutInfo.m_nRatioY2 / ALIGN_RANGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
rcCtl.top = rcOriginal.top;
|
||||
rcCtl.bottom = rcOriginal.bottom;
|
||||
}
|
||||
|
||||
int nHorScrollVal = GetScrollPos(m_hwndParent, SB_HORZ);
|
||||
rcCtl.left -= nHorScrollVal;
|
||||
rcCtl.right -= nHorScrollVal;
|
||||
int nVertScrollVal = GetScrollPos(m_hwndParent, SB_VERT);
|
||||
rcCtl.top -= nVertScrollVal;
|
||||
rcCtl.bottom -= nVertScrollVal;
|
||||
|
||||
HWND hwndCtl = GetDlgItem(m_hwndParent, rLayoutInfo.m_nCtlID);
|
||||
SetWindowPos(hwndCtl,
|
||||
NULL,
|
||||
rcCtl.left,
|
||||
rcCtl.top,
|
||||
rcCtl.right - rcCtl.left,
|
||||
rcCtl.bottom - rcCtl.top,
|
||||
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOREDRAW);
|
||||
}
|
||||
|
||||
if (m_hwndSizeBox)
|
||||
{
|
||||
RECT rcCtl;
|
||||
GetWindowRect(m_hwndSizeBox, &rcCtl);
|
||||
SetWindowPos(m_hwndSizeBox,
|
||||
NULL,
|
||||
rcClient.right - (rcCtl.right - rcCtl.left),
|
||||
rcClient.bottom - (rcCtl.bottom - rcCtl.top),
|
||||
0,
|
||||
0,
|
||||
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOSIZE);
|
||||
ShowWindow(m_hwndSizeBox, IsMaximized(m_hwndParent) ? SW_HIDE : SW_SHOW);
|
||||
}
|
||||
|
||||
if (bVisible)
|
||||
{
|
||||
SendMessage(m_hwndParent, WM_SETREDRAW, TRUE, 0);
|
||||
RedrawWindow(m_hwndParent, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
|
||||
}
|
||||
}
|
||||
97
third-party/BugTrap-1.3-57bd515/source/LayoutManager.h
vendored
Normal file
97
third-party/BugTrap-1.3-57bd515/source/LayoutManager.h
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Layout manager class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Left-side alignment.
|
||||
const int ALIGN_LEFT = 0;
|
||||
/// Top-side alignment.
|
||||
const int ALIGN_TOP = 0;
|
||||
/// Center-side alignment.
|
||||
const int ALIGN_CENTER = 1;
|
||||
/// Right-side alignment.
|
||||
const int ALIGN_RIGHT = 2;
|
||||
/// Bottom-side alignment.
|
||||
const int ALIGN_BOTTOM = 2;
|
||||
/// Alignment range.
|
||||
const int ALIGN_RANGE = 2;
|
||||
|
||||
/// Layout info block.
|
||||
struct LAYOUT_INFO
|
||||
{
|
||||
/// Initialize the object.
|
||||
LAYOUT_INFO(int nCtlID, int nRatioX1, int nRatioY1, int nRatioX2, int nRatioY2);
|
||||
|
||||
/// Initialize the object.
|
||||
LAYOUT_INFO(void);
|
||||
|
||||
/// Control ID.
|
||||
int m_nCtlID;
|
||||
/// Left coordinate ratio.
|
||||
int m_nRatioX1;
|
||||
/// Top coordinate ratio.
|
||||
int m_nRatioY1;
|
||||
/// Right coordinate ratio.
|
||||
int m_nRatioX2;
|
||||
/// Bottom coordinate ratio.
|
||||
int m_nRatioY2;
|
||||
/// Original control coordinates.
|
||||
RECT m_rcOriginal;
|
||||
};
|
||||
|
||||
/// Window layout manager class.
|
||||
class CLayoutManager
|
||||
{
|
||||
private:
|
||||
/// Minimal acceptable window size.
|
||||
POINT m_ptMinWindowSize;
|
||||
/// Minimal window client size.
|
||||
POINT m_ptMinClientSize;
|
||||
/// Parent window handle.
|
||||
HWND m_hwndParent;
|
||||
/// Size-box window handle.
|
||||
HWND m_hwndSizeBox;
|
||||
/// Array of control layout information.
|
||||
LAYOUT_INFO* m_arrLayout;
|
||||
/// Number of items in control layouts array.
|
||||
int m_nItemCount;
|
||||
|
||||
/// Protect the class from being accidentally copied.
|
||||
CLayoutManager(const CLayoutManager& rLayoutManager);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CLayoutManager& operator=(const CLayoutManager& rLayoutManager);
|
||||
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CLayoutManager(void);
|
||||
/// Get minimal window size.
|
||||
const POINT& GetMinTrackSize(void) const;
|
||||
/// Initialize layout info blocks for child windows.
|
||||
void InitLayout(HWND hwndParent, LAYOUT_INFO arrLayout[], int nItemCount, bool bAddSizeBox = true);
|
||||
/// Apply layout information to the window.
|
||||
void ApplyLayout(void);
|
||||
};
|
||||
|
||||
inline CLayoutManager::CLayoutManager(void)
|
||||
{
|
||||
ZeroMemory(this, sizeof(*this));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return minimum window size.
|
||||
*/
|
||||
inline const POINT& CLayoutManager::GetMinTrackSize(void) const
|
||||
{
|
||||
return m_ptMinWindowSize;
|
||||
}
|
||||
24
third-party/BugTrap-1.3-57bd515/source/LeakWatcher.h
vendored
Normal file
24
third-party/BugTrap-1.3-57bd515/source/LeakWatcher.h
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Memory leak detection macros.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <crtdbg.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||
#else
|
||||
#define DEBUG_NEW new
|
||||
#endif
|
||||
562
third-party/BugTrap-1.3-57bd515/source/List.h
vendored
Normal file
562
third-party/BugTrap-1.3-57bd515/source/List.h
vendored
Normal file
|
|
@ -0,0 +1,562 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Doubly-linked list.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ColHelper.h"
|
||||
|
||||
/// Doubly-linked list
|
||||
template
|
||||
<
|
||||
typename DATA_TYPE,
|
||||
class INSTANCE_TRAITS = CObjectTraits<DATA_TYPE>,
|
||||
class COMPARE_TRAITS = CCompareTraits<DATA_TYPE>
|
||||
>
|
||||
class CList
|
||||
{
|
||||
private:
|
||||
/// List item.
|
||||
class CListItem
|
||||
{
|
||||
/// Doubly-linked list.
|
||||
friend class CList;
|
||||
|
||||
private:
|
||||
/// Contains data value.
|
||||
DATA_TYPE m_Data;
|
||||
/// Pointer to the previous item.
|
||||
CListItem* m_pPrev;
|
||||
/// Pointer to the next item.
|
||||
CListItem* m_pNext;
|
||||
};
|
||||
|
||||
/// Pointer to the first list item.
|
||||
CListItem* m_pFirst;
|
||||
/// Pointer to the last list item.
|
||||
CListItem* m_pLast;
|
||||
/// List of deleted items. These items can be reused in future allocations.
|
||||
CListItem* m_pGarbage;
|
||||
/// Number of items in collection.
|
||||
size_t m_nCount;
|
||||
|
||||
/// Initialize list variables.
|
||||
void InitList(void);
|
||||
/// Throw an exception if pointer to the item is not valid.
|
||||
static void ValidateItem(const CListItem* pItem);
|
||||
/// Allocate new list item.
|
||||
CListItem* AllocListItem(void);
|
||||
|
||||
public:
|
||||
/// Synonym of list iterator type.
|
||||
typedef CListItem* POSITION;
|
||||
|
||||
/// Initialize a list object.
|
||||
CList(void);
|
||||
/// Makes a copy of a list.
|
||||
CList(const CList& rList);
|
||||
/// Makes a copy of a list.
|
||||
const CList& operator=(const CList& rList);
|
||||
/// Destroy a list object and free allocated memory.
|
||||
~CList(void);
|
||||
/// Tests for the empty list condition (no elements).
|
||||
bool IsEmpty(void) const;
|
||||
/// Returns the number of elements in this list.
|
||||
size_t GetCount(void) const;
|
||||
/// Adds an element to the head of the list (makes a new head).
|
||||
POSITION AddToHead(const DATA_TYPE& rData);
|
||||
/// Adds an element to the tail of the list (makes a new tail).
|
||||
POSITION AddToTail(const DATA_TYPE& rData);
|
||||
/// Returns the head element of the list (cannot be empty).
|
||||
DATA_TYPE& GetHead(void);
|
||||
/// Returns the head element of the list (cannot be empty).
|
||||
const DATA_TYPE& GetHead(void) const;
|
||||
/// Returns the tail element of the list (cannot be empty).
|
||||
DATA_TYPE& GetTail(void);
|
||||
/// Returns the tail element of the list (cannot be empty).
|
||||
const DATA_TYPE& GetTail(void) const;
|
||||
/// Returns the position of the head element of the list.
|
||||
POSITION GetHeadPosition(void) const;
|
||||
/// Returns the position of the tail element of the list.
|
||||
POSITION GetTailPosition(void) const;
|
||||
/// Gets the next element for iterating.
|
||||
static POSITION GetNextPosition(POSITION pos);
|
||||
/// Gets the previous element for iterating.
|
||||
static POSITION GetPrevPosition(POSITION pos);
|
||||
/// Gets an element at a given position.
|
||||
static DATA_TYPE& GetAt(POSITION pos);
|
||||
/// Sets an element at a given position.
|
||||
static void SetAt(POSITION pos, const DATA_TYPE& rData);
|
||||
/// Removes an element from this list, specified by position.
|
||||
void DeleteAt(POSITION pos);
|
||||
/// Inserts a new element before a given position.
|
||||
POSITION InsertBefore(POSITION pos, const DATA_TYPE& rData);
|
||||
/// Inserts a new element after a given position.
|
||||
POSITION InsertAfter(POSITION pos, const DATA_TYPE& rData);
|
||||
/// Removes the element from the head of the list.
|
||||
void DeleteHead(void);
|
||||
/// Removes the element from the tail of the list.
|
||||
void DeleteTail(void);
|
||||
/// Removes all the elements from this list.
|
||||
void DeleteAll(bool bFree = false);
|
||||
/// Gets the position of an element specified by pointer value.
|
||||
POSITION Find(const DATA_TYPE& rSearchValue, POSITION startAfter = NULL) const;
|
||||
/// Gets the position of an element specified by a zero-based index.
|
||||
POSITION GetByIndex(size_t nIndex) const;
|
||||
};
|
||||
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::InitList(void)
|
||||
{
|
||||
m_pFirst = NULL;
|
||||
m_pLast = NULL;
|
||||
m_pGarbage = NULL;
|
||||
m_nCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pItem - validated item.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline void CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::ValidateItem(const CListItem* pItem)
|
||||
{
|
||||
_ASSERTE(pItem);
|
||||
if (! pItem)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
}
|
||||
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::CList(void)
|
||||
{
|
||||
InitList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rList - object to be copied.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::CList(const CList& rList)
|
||||
{
|
||||
InitList();
|
||||
|
||||
CListItem* pItem = rList.m_pFirst;
|
||||
while (m_nCount < rList.m_nCount)
|
||||
{
|
||||
AddToTail(pItem->m_Data);
|
||||
pItem = pItem->m_pNext;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rList - object to be copied.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
const CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>& CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::operator=(const CList& rList)
|
||||
{
|
||||
if (this != &rList)
|
||||
{
|
||||
CListItem* pSrcItem = rList.m_pFirst;
|
||||
CListItem* pDstItem = m_pFirst;
|
||||
if (m_nCount < rList.m_nCount)
|
||||
{
|
||||
if (m_pFirst == NULL)
|
||||
{
|
||||
while (m_nCount < rList.m_nCount)
|
||||
{
|
||||
AddToTail(pSrcItem->m_Data);
|
||||
pSrcItem = pSrcItem->m_pNext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_nCount < rList.m_nCount)
|
||||
{
|
||||
InsertBefore(pDstItem, pSrcItem->m_Data);
|
||||
pSrcItem = pSrcItem->m_pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_nCount > rList.m_nCount)
|
||||
{
|
||||
while (m_nCount > rList.m_nCount)
|
||||
DeleteTail();
|
||||
}
|
||||
while (pSrcItem != NULL)
|
||||
{
|
||||
INSTANCE_TRAITS::Assignment(pDstItem->m_Data, pSrcItem->m_Data);
|
||||
pSrcItem = pSrcItem->m_pNext;
|
||||
pDstItem = pDstItem->m_pNext;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::~CList(void)
|
||||
{
|
||||
DeleteAll(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return newly allocated list item.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::CListItem* CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::AllocListItem(void)
|
||||
{
|
||||
CListItem* pItem;
|
||||
if (m_pGarbage)
|
||||
{
|
||||
pItem = m_pGarbage;
|
||||
m_pGarbage = m_pGarbage->m_pNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem = (CListItem*)new BYTE[sizeof(CListItem)];
|
||||
if (! pItem)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
return pItem;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param rData - the new element.
|
||||
* @return the position of newly inserted value.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::AddToHead(const DATA_TYPE& rData)
|
||||
{
|
||||
CListItem* pFirst = AllocListItem();
|
||||
pFirst->m_pPrev = NULL;
|
||||
pFirst->m_pNext = m_pFirst;
|
||||
if (m_pFirst)
|
||||
m_pFirst->m_pPrev = pFirst;
|
||||
else
|
||||
m_pLast = pFirst;
|
||||
m_pFirst = pFirst;
|
||||
INSTANCE_TRAITS::Constructor(pFirst->m_Data);
|
||||
INSTANCE_TRAITS::Assignment(pFirst->m_Data, rData);
|
||||
++m_nCount;
|
||||
return pFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rData - the new element.
|
||||
* @return the position of newly inserted value.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::AddToTail(const DATA_TYPE& rData)
|
||||
{
|
||||
CListItem* pLast = AllocListItem();
|
||||
pLast->m_pPrev = m_pLast;
|
||||
pLast->m_pNext = NULL;
|
||||
if (m_pLast)
|
||||
m_pLast->m_pNext = pLast;
|
||||
else
|
||||
m_pFirst = pLast;
|
||||
m_pLast = pLast;
|
||||
INSTANCE_TRAITS::Constructor(pLast->m_Data);
|
||||
INSTANCE_TRAITS::Assignment(pLast->m_Data, rData);
|
||||
++m_nCount;
|
||||
return pLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a reference to an element of the list.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline DATA_TYPE& CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetHead(void)
|
||||
{
|
||||
ValidateItem(m_pFirst);
|
||||
return m_pFirst->m_Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a reference to an element of the list.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline const DATA_TYPE& CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetHead(void) const
|
||||
{
|
||||
ValidateItem(m_pFirst);
|
||||
return m_pFirst->m_Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a reference to an element of the list.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline DATA_TYPE& CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetTail(void)
|
||||
{
|
||||
ValidateItem(m_pLast);
|
||||
return m_pLast->m_Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a reference to an element of the list.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline const DATA_TYPE& CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetTail(void) const
|
||||
{
|
||||
ValidateItem(m_pLast);
|
||||
return m_pLast->m_Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a @a POSITION value that can be used for iteration or object pointer retrieval; NULL if the list is empty.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetHeadPosition(void) const
|
||||
{
|
||||
return m_pFirst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a @a POSITION value that can be used for iteration or object pointer retrieval; NULL if the list is empty.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetTailPosition(void) const
|
||||
{
|
||||
return m_pLast;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - a @a POSITION value returned by a previous GetPrevPosition(), GetTailPosition(), or other member function call.
|
||||
* @return the position of next element is the list or NULL.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetNextPosition(typename CList::POSITION pos)
|
||||
{
|
||||
ValidateItem(pos);
|
||||
return pos->m_pNext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - a @a POSITION value returned by a previous GetPrevPosition(), GetTailPosition(), or other member function call.
|
||||
* @return the position of next element is the list or NULL.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetPrevPosition(typename CList::POSITION pos)
|
||||
{
|
||||
ValidateItem(pos);
|
||||
return pos->m_pPrev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this list is empty; otherwise false.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline bool CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::IsEmpty(void) const
|
||||
{
|
||||
return (m_pFirst == NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an integer value containing the element count.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline size_t CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetCount(void) const
|
||||
{
|
||||
return m_nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - a @a POSITION value returned by a previous GetPrevPosition(), GetTailPosition(), or other member function call.
|
||||
* @return a reference to an element of the list.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline DATA_TYPE& CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetAt(typename CList::POSITION pos)
|
||||
{
|
||||
ValidateItem(pos);
|
||||
return pos->m_Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - the @a POSITION of the element to be set.
|
||||
* @param rData - the element to be added to the list.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
inline void CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::SetAt(typename CList::POSITION pos, const DATA_TYPE& rData)
|
||||
{
|
||||
ValidateItem(pos);
|
||||
INSTANCE_TRAITS::Assignment(pos->m_Data, rData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - the position of the element to be removed from the list.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::DeleteAt(typename CList::POSITION pos)
|
||||
{
|
||||
ValidateItem(pos);
|
||||
CListItem* pPrev = pos->m_pPrev;
|
||||
CListItem* pNext = pos->m_pNext;
|
||||
if (pPrev)
|
||||
pPrev->m_pNext = pNext;
|
||||
else
|
||||
m_pFirst = pNext;
|
||||
if (pNext)
|
||||
pNext->m_pPrev = pPrev;
|
||||
else
|
||||
m_pLast = pPrev;
|
||||
INSTANCE_TRAITS::Destructor(pos->m_Data);
|
||||
pos->m_pNext = m_pGarbage;
|
||||
m_pGarbage = pos;
|
||||
--m_nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - a @a POSITION value returned by a previous GetPrevPosition(), GetTailPosition(), or other member function call.
|
||||
* @param rData - the element to be added to this list.
|
||||
* @return the position of newly inserted value.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::InsertBefore(typename CList::POSITION pos, const DATA_TYPE& rData)
|
||||
{
|
||||
ValidateItem(pos);
|
||||
CListItem* pItem = AllocListItem();
|
||||
CListItem* pPrev = pos->m_pPrev;
|
||||
pItem->m_pPrev = pPrev;
|
||||
pItem->m_pNext = pos;
|
||||
if (pPrev)
|
||||
pPrev->m_pNext = pItem;
|
||||
else
|
||||
m_pFirst = pItem;
|
||||
pos->m_pPrev = pItem;
|
||||
INSTANCE_TRAITS::Constructor(pItem->m_Data);
|
||||
INSTANCE_TRAITS::Assignment(pItem->m_Data, rData);
|
||||
++m_nCount;
|
||||
return pItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos - a @a POSITION value returned by a previous GetPrevPosition(), GetTailPosition(), or other member function call.
|
||||
* @param rData - the element to be added to this list.
|
||||
* @return the position of newly inserted value.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::InsertAfter(typename CList::POSITION pos, const DATA_TYPE& rData)
|
||||
{
|
||||
ValidateItem(pos);
|
||||
CListItem* pItem = AllocListItem();
|
||||
CListItem* pNext = pos->m_pNext;
|
||||
pItem->m_pPrev = pos;
|
||||
pItem->m_pNext = pNext;
|
||||
if (pNext)
|
||||
pNext->m_pPrev = pItem;
|
||||
else
|
||||
m_pLast = pItem;
|
||||
pos->m_pNext = pItem;
|
||||
INSTANCE_TRAITS::Constructor(pItem->m_Data);
|
||||
INSTANCE_TRAITS::Assignment(pItem->m_Data, rData);
|
||||
++m_nCount;
|
||||
return pItem;
|
||||
}
|
||||
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::DeleteHead(void)
|
||||
{
|
||||
ValidateItem(m_pFirst);
|
||||
INSTANCE_TRAITS::Destructor(m_pFirst->m_Data);
|
||||
CListItem* pNext = m_pFirst->m_pNext;
|
||||
m_pFirst->m_pNext = m_pGarbage;
|
||||
m_pGarbage = m_pFirst;
|
||||
m_pFirst = pNext;
|
||||
if (pNext)
|
||||
pNext->m_pPrev = NULL;
|
||||
else
|
||||
m_pLast = NULL;
|
||||
--m_nCount;
|
||||
}
|
||||
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::DeleteTail(void)
|
||||
{
|
||||
ValidateItem(m_pLast);
|
||||
INSTANCE_TRAITS::Destructor(m_pLast->m_Data);
|
||||
CListItem* pPrev = m_pLast->m_pPrev;
|
||||
m_pLast->m_pNext = m_pGarbage;
|
||||
m_pGarbage = m_pLast;
|
||||
m_pLast = pPrev;
|
||||
if (pPrev)
|
||||
pPrev->m_pNext = NULL;
|
||||
else
|
||||
m_pFirst = NULL;
|
||||
--m_nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bFree - pass true of release array memory.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
void CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::DeleteAll(bool bFree)
|
||||
{
|
||||
if (bFree)
|
||||
{
|
||||
CListItem* pNext;
|
||||
while (m_pGarbage)
|
||||
{
|
||||
pNext = m_pGarbage->m_pNext;
|
||||
delete[] (PBYTE)m_pGarbage;
|
||||
m_pGarbage = pNext;
|
||||
}
|
||||
while (m_pFirst)
|
||||
{
|
||||
pNext = m_pFirst->m_pNext;
|
||||
INSTANCE_TRAITS::Destructor(m_pFirst->m_Data);
|
||||
delete[] (PBYTE)m_pFirst;
|
||||
m_pFirst = pNext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_pFirst)
|
||||
{
|
||||
CListItem* pNext = m_pFirst->m_pNext;
|
||||
INSTANCE_TRAITS::Destructor(m_pFirst->m_Data);
|
||||
m_pFirst->m_pNext = m_pGarbage;
|
||||
m_pGarbage = m_pFirst;
|
||||
m_pFirst = pNext;
|
||||
}
|
||||
}
|
||||
m_pLast = NULL;
|
||||
m_nCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rSearchValue - the value to be found in the list.
|
||||
* @param startAfter - the start position for the search.
|
||||
* @return a @a POSITION value that can be used for iteration or object pointer retrieval; NULL if the object is not found.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::Find(const DATA_TYPE& rSearchValue, typename CList::POSITION startAfter) const
|
||||
{
|
||||
if (startAfter == NULL)
|
||||
startAfter = m_pFirst;
|
||||
while (startAfter != NULL && ! COMPARE_TRAITS::Compare(startAfter->m_Data, rSearchValue))
|
||||
startAfter = startAfter->m_pNext;
|
||||
return startAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nIndex - the zero-based index of the list element to be found.
|
||||
* @return a @a POSITION value that can be used for iteration or object pointer retrieval; NULL if nIndex is negative or too large.
|
||||
*/
|
||||
template <typename DATA_TYPE, class INSTANCE_TRAITS, class COMPARE_TRAITS>
|
||||
typename CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::POSITION CList<DATA_TYPE, INSTANCE_TRAITS, COMPARE_TRAITS>::GetByIndex(size_t nIndex) const
|
||||
{
|
||||
CListItem* pItem = m_pFirst;
|
||||
while (nIndex-- && pItem)
|
||||
pItem = pItem->m_pNext;
|
||||
return pItem;
|
||||
}
|
||||
252
third-party/BugTrap-1.3-57bd515/source/LogFile.cpp
vendored
Normal file
252
third-party/BugTrap-1.3-57bd515/source/LogFile.cpp
vendored
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Base class for custom log file.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "LogFile.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param dwInitialLogSizeInBytes - initial log file size.
|
||||
*/
|
||||
CLogFile::CLogFile(void) : m_StrStream(1024)
|
||||
{
|
||||
*m_szLogFileName = _T('\0');
|
||||
m_dwLogEchoMode = BTLE_NONE;
|
||||
m_dwLogFlags = BTLF_NONE;
|
||||
m_eLogLevel = BTLL_ALL;
|
||||
InitializeCriticalSection(&m_csLogFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to custom log file name.
|
||||
*/
|
||||
PCTSTR CLogFile::GetLogFileName(void)
|
||||
{
|
||||
if (*m_szLogFileName == _T('\0'))
|
||||
CompleteLogFileName(NULL);
|
||||
return m_szLogFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eLogLevel - log level number.
|
||||
* @return log level prefix.
|
||||
*/
|
||||
PCTSTR CLogFile::GetLogLevelPrefix(BUGTRAP_LOGLEVEL eLogLevel)
|
||||
{
|
||||
switch (eLogLevel)
|
||||
{
|
||||
case BTLL_ERROR: return _T("ERROR");
|
||||
case BTLL_WARNING: return _T("WARNING");
|
||||
case BTLL_IMPORTANT: return _T("IMPORTANT");
|
||||
case BTLL_INFO: return _T("INFO");
|
||||
case BTLL_VERBOSE: return _T("VERBOSE");
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return output console handle.
|
||||
*/
|
||||
HANDLE CLogFile::GetConsoleHandle(void) const
|
||||
{
|
||||
HANDLE hConsole;
|
||||
if (m_dwLogEchoMode & BTLE_STDOUT)
|
||||
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
else if (m_dwLogEchoMode & BTLE_STDERR)
|
||||
hConsole = GetStdHandle(STD_ERROR_HANDLE);
|
||||
else
|
||||
hConsole = NULL;
|
||||
return hConsole;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hConsole - console handle.
|
||||
*/
|
||||
void CLogFile::WriteTextToConsole(HANDLE hConsole)
|
||||
{
|
||||
DWORD dwTextLength, dwWritten;
|
||||
PCTSTR pszText = m_StrStream;
|
||||
#ifndef _UNICODE
|
||||
UINT uConsoleCP = GetConsoleOutputCP();
|
||||
if (uConsoleCP != CP_ACP)
|
||||
{
|
||||
DWORD dwTextSizeW = MultiByteToWideChar(CP_ACP, 0, pszText, -1, NULL, 0);
|
||||
if (m_ConsoleBufferW.GetSize() < dwTextSizeW)
|
||||
{
|
||||
dwTextSizeW *= 2;
|
||||
if (! m_ConsoleBufferW.SetSize(dwTextSizeW))
|
||||
return;
|
||||
}
|
||||
MultiByteToWideChar(CP_ACP, 0, pszText, -1, m_ConsoleBufferW.GetData(), dwTextSizeW);
|
||||
DWORD dwTextSizeA = WideCharToMultiByte(uConsoleCP, 0, m_ConsoleBufferW.GetData(), -1, NULL, 0, NULL, NULL);
|
||||
if (m_ConsoleBufferA.GetSize() < dwTextSizeA)
|
||||
{
|
||||
dwTextSizeA *= 2;
|
||||
if (! m_ConsoleBufferA.SetSize(dwTextSizeA))
|
||||
return;
|
||||
}
|
||||
dwTextLength = WideCharToMultiByte(uConsoleCP, 0, m_ConsoleBufferW.GetData(), -1, m_ConsoleBufferA.GetData(), dwTextSizeA, NULL, NULL);
|
||||
WriteConsoleA(hConsole, m_ConsoleBufferA.GetData(), dwTextLength - 1, &dwWritten, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
dwTextLength = (DWORD)m_StrStream.GetLength();
|
||||
WriteConsoleA(hConsole, pszText, dwTextLength, &dwWritten, NULL);
|
||||
}
|
||||
#else
|
||||
dwTextLength = (DWORD)m_StrStream.GetLength();
|
||||
WriteConsole(hConsole, pszText, dwTextLength, &dwWritten, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pSystemTime - pointer to system time.
|
||||
* @param pszTimeStatistics - time statistics buffer.
|
||||
* @param dwTimeStatisticsSize - size of time statistics buffer.
|
||||
*/
|
||||
void CLogFile::GetTimeStatistics(const SYSTEMTIME* pSystemTime, PTSTR pszTimeStatistics, DWORD dwTimeStatisticsSize)
|
||||
{
|
||||
_stprintf_s(pszTimeStatistics, dwTimeStatisticsSize,
|
||||
_T("%04d/%02d/%02d %02d:%02d:%02d"),
|
||||
pSystemTime->wYear, pSystemTime->wMonth, pSystemTime->wDay, pSystemTime->wHour, pSystemTime->wMinute, pSystemTime->wSecond);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pSystemTime - pointer to system time.
|
||||
* @param eLogLevel - log level number.
|
||||
* @param pszEntry - log entry text.
|
||||
*/
|
||||
void CLogFile::FillEntryText(BUGTRAP_LOGLEVEL eLogLevel, const SYSTEMTIME* pSystemTime, PCTSTR pszEntry)
|
||||
{
|
||||
_ASSERTE(pszEntry != NULL);
|
||||
m_StrStream.Reset();
|
||||
if (m_dwLogFlags & BTLF_SHOWTIMESTAMP)
|
||||
{
|
||||
TCHAR szTimeStatistics[32];
|
||||
GetTimeStatistics(pSystemTime, szTimeStatistics, countof(szTimeStatistics));
|
||||
m_StrStream << _T('[') << szTimeStatistics << _T("] ");
|
||||
}
|
||||
if (m_dwLogFlags & BTLF_SHOWLOGLEVEL)
|
||||
{
|
||||
PCTSTR pszLogLevelPrefix = GetLogLevelPrefix(eLogLevel);
|
||||
if (pszLogLevelPrefix)
|
||||
m_StrStream << pszLogLevelPrefix << _T(": ");
|
||||
}
|
||||
m_StrStream << pszEntry << _T("\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszFormat - format expression.
|
||||
* @param argList - variable argument list.
|
||||
* @return true if string was formatted.
|
||||
*/
|
||||
BOOL CLogFile::FormatBufferV(PCTSTR pszFormat, va_list argList)
|
||||
{
|
||||
DWORD dwFormatBufferSize = m_FormatBuffer.GetSize();
|
||||
if (dwFormatBufferSize == 0)
|
||||
{
|
||||
dwFormatBufferSize = 256;
|
||||
if (! m_FormatBuffer.SetSize(dwFormatBufferSize))
|
||||
return FALSE;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
int iResult = _vsntprintf_s(m_FormatBuffer.GetData(), dwFormatBufferSize, _TRUNCATE, pszFormat, argList);
|
||||
if (iResult >= 0)
|
||||
return TRUE;
|
||||
dwFormatBufferSize *= 2;
|
||||
if (! m_FormatBuffer.SetSize(dwFormatBufferSize))
|
||||
return FALSE;
|
||||
_ASSERTE(m_FormatBuffer.GetSize() >= dwFormatBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszFormat - format expression.
|
||||
* @param argList - variable argument list.
|
||||
* @return true if string was formatted.
|
||||
*/
|
||||
BOOL CLogFile::FormatBufferF(PCTSTR pszFormat, ...)
|
||||
{
|
||||
va_list argList;
|
||||
va_start(argList, pszFormat);
|
||||
BOOL bResult = FormatBufferV(pszFormat, argList);
|
||||
va_end(argList);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eLogLevel - log level number.
|
||||
* @param eEntryMode - entry mode.
|
||||
* @param rcsConsoleAccess - provides synchronous access to the console.
|
||||
* @param pszFormat - format string.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CLogFile::WriteLogEntryF(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszFormat, ...)
|
||||
{
|
||||
va_list argList;
|
||||
va_start(argList, pszFormat);
|
||||
BOOL bResult = WriteLogEntryV(eLogLevel, eEntryMode, rcsConsoleAccess, pszFormat, argList);
|
||||
va_end(argList);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eLogLevel - log level number.
|
||||
* @param eEntryMode - entry mode.
|
||||
* @param rcsConsoleAccess - provides synchronous access to the console.
|
||||
* @param pszFormat - format string.
|
||||
* @param argList - variable argument list.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CLogFile::WriteLogEntryV(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszFormat, va_list argList)
|
||||
{
|
||||
BUGTRAP_LOGLEVEL eLogFileLevel = GetLogLevel();
|
||||
if (eLogLevel > eLogFileLevel)
|
||||
return TRUE;
|
||||
BOOL bResult = FormatBufferV(pszFormat, argList);
|
||||
if (bResult)
|
||||
bResult = WriteLogEntry(eLogLevel, eEntryMode, rcsConsoleAccess, m_FormatBuffer.GetData());
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eLogLevel - log level number.
|
||||
* @param pSystemTime - system time.
|
||||
* @param rcsConsoleAccess - provides synchronous access to the console.
|
||||
* @param pszEntry - log entry text.
|
||||
* @return true if text was written to console.
|
||||
*/
|
||||
BOOL CLogFile::WriteLogEntryToConsole(BUGTRAP_LOGLEVEL eLogLevel, const SYSTEMTIME* pSystemTime, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry)
|
||||
{
|
||||
DWORD dwLogEchoMode = GetLogEchoMode();
|
||||
HANDLE hConsole = GetConsoleHandle();
|
||||
BOOL bLogEcho = (dwLogEchoMode & BTLE_DBGOUT) != 0;
|
||||
if (hConsole || bLogEcho)
|
||||
{
|
||||
FillEntryText(eLogLevel, pSystemTime, pszEntry);
|
||||
EnterCriticalSection(&rcsConsoleAccess);
|
||||
if (hConsole)
|
||||
WriteTextToConsole(hConsole);
|
||||
if (bLogEcho)
|
||||
WriteTextToDebugConsole();
|
||||
LeaveCriticalSection(&rcsConsoleAccess);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
269
third-party/BugTrap-1.3-57bd515/source/LogFile.h
vendored
Normal file
269
third-party/BugTrap-1.3-57bd515/source/LogFile.h
vendored
Normal file
|
|
@ -0,0 +1,269 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Base class for custom log file.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BugTrap.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "StrStream.h"
|
||||
#include "Buffer.h"
|
||||
|
||||
/**
|
||||
* @brief Base class for custom log file.
|
||||
*/
|
||||
class CLogFile
|
||||
{
|
||||
public:
|
||||
/// Entry mode.
|
||||
enum ENTRY_MODE
|
||||
{
|
||||
/// Records are appended to the end of the file.
|
||||
EM_APPEND,
|
||||
/// Records are inserted at the beginning of the file.
|
||||
EM_INSERT
|
||||
};
|
||||
|
||||
/// Initialize the object.
|
||||
CLogFile(void);
|
||||
/// Destroy the object.
|
||||
virtual ~CLogFile(void);
|
||||
/// Get custom log file name.
|
||||
PCTSTR GetLogFileName(void);
|
||||
/// Set custom log file name.
|
||||
void SetLogFileName(PCTSTR pszLogFileName);
|
||||
/// Get number of records in custom log file.
|
||||
virtual DWORD GetLogSizeInEntries(void) const;
|
||||
/// Set number of records in custom log file.
|
||||
virtual BOOL SetLogSizeInEntries(DWORD dwLogSizeInEntries);
|
||||
/// Get maximum log file size in bytes.
|
||||
virtual DWORD GetLogSizeInBytes(void) const;
|
||||
/// Set maximum log file size in bytes.
|
||||
virtual BOOL SetLogSizeInBytes(DWORD dwLogSizeInBytes);
|
||||
/// Return true if time stamp is added to every log entry.
|
||||
DWORD GetLogFlags(void) const;
|
||||
/// Set true if time stamp is added to every log entry.
|
||||
BOOL SetLogFlags(DWORD dwLogFlags);
|
||||
/// Return minimal log level accepted by tracing functions.
|
||||
BUGTRAP_LOGLEVEL GetLogLevel(void) const;
|
||||
/// Set minimal log level accepted by tracing functions.
|
||||
BOOL SetLogLevel(BUGTRAP_LOGLEVEL eLogLevel);
|
||||
/// Get echo mode.
|
||||
DWORD GetLogEchoMode(void);
|
||||
/// Set echo mode.
|
||||
BOOL SetLogEchoMode(DWORD dwLogEchoMode);
|
||||
/// Take possession of the log file.
|
||||
void CaptureObject(void);
|
||||
/// Release possession of the log file.
|
||||
void ReleaseObject(void);
|
||||
/// Load Entries into memory.
|
||||
virtual BOOL LoadEntries(void) = 0;
|
||||
/// Save entries into disk.
|
||||
virtual BOOL SaveEntries(BOOL bCrash) = 0;
|
||||
/// Clear log entries.
|
||||
virtual BOOL ClearEntries(void) = 0;
|
||||
/// Close log file.
|
||||
virtual void Close(void) = 0;
|
||||
/// Add new log entry.
|
||||
virtual BOOL WriteLogEntry(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry) = 0;
|
||||
/// Add new log entry.
|
||||
BOOL WriteLogEntryF(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszFormat, ...);
|
||||
/// Add new log entry.
|
||||
BOOL WriteLogEntryV(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszFormat, va_list argList);
|
||||
|
||||
protected:
|
||||
/// Get default log file extension.
|
||||
virtual PCTSTR GetLogFileExtension(void) const = 0;
|
||||
/// Get last entry text.
|
||||
PCTSTR GetEntryText(void) const;
|
||||
/// Get log level prefix.
|
||||
static PCTSTR GetLogLevelPrefix(BUGTRAP_LOGLEVEL eLogLevel);
|
||||
/// Get time statistics.
|
||||
static void GetTimeStatistics(const SYSTEMTIME* pSystemTime, PTSTR pszTimeStatistics, DWORD dwTimeStatisticsSize);
|
||||
/// Fill entry text.
|
||||
void FillEntryText(BUGTRAP_LOGLEVEL eLogLevel, const SYSTEMTIME* pSystemTime, PCTSTR pszEntry);
|
||||
/// Write text to console.
|
||||
void WriteTextToConsole(HANDLE hConsole);
|
||||
/// Write text to debug console.
|
||||
void WriteTextToDebugConsole(void);
|
||||
/// Get output console handle.
|
||||
HANDLE GetConsoleHandle(void) const;
|
||||
/// Write log entry to the console.
|
||||
BOOL WriteLogEntryToConsole(BUGTRAP_LOGLEVEL eLogLevel, const SYSTEMTIME* pSystemTime, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry);
|
||||
|
||||
private:
|
||||
/// Protects the class from being accidentally copied.
|
||||
CLogFile(const CLogFile& rLogFile);
|
||||
/// Protects the class from being accidentally copied.
|
||||
CLogFile& operator=(const CLogFile& rLogFile);
|
||||
/// Set log file name to default value.
|
||||
BOOL CompleteLogFileName(PCTSTR pszLogFileName);
|
||||
/// Fill buffer with formatted string.
|
||||
BOOL FormatBufferV(PCTSTR pszFormat, va_list argList);
|
||||
/// Fill buffer with formatted string.
|
||||
BOOL FormatBufferF(PCTSTR pszFormat, ...);
|
||||
|
||||
/// Custom log file name.
|
||||
TCHAR m_szLogFileName[MAX_PATH];
|
||||
/// True if date and time stamp is added to every log entry.
|
||||
DWORD m_dwLogFlags;
|
||||
/// Echo mode.
|
||||
DWORD m_dwLogEchoMode;
|
||||
/// Minimal log level accepted by tracing functions.
|
||||
BUGTRAP_LOGLEVEL m_eLogLevel;
|
||||
/// Synchronization object.
|
||||
CRITICAL_SECTION m_csLogFile;
|
||||
/// Pre-allocated buffer for log entry text.
|
||||
CStrStream m_StrStream;
|
||||
/// Pre-allocated buffer for format string.
|
||||
CDynamicBuffer<TCHAR> m_FormatBuffer;
|
||||
#ifndef _UNICODE
|
||||
/// Pre-allocated buffer for encoded console message.
|
||||
CDynamicBuffer<CHAR> m_ConsoleBufferA;
|
||||
/// Pre-allocated buffer for encoded console message.
|
||||
CDynamicBuffer<WCHAR> m_ConsoleBufferW;
|
||||
#endif
|
||||
};
|
||||
|
||||
inline CLogFile::~CLogFile(void)
|
||||
{
|
||||
DeleteCriticalSection(&m_csLogFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return maximum number of records in log file.
|
||||
*/
|
||||
inline DWORD CLogFile::GetLogSizeInEntries(void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwLogSizeInEntries - maximum number of records in log file.
|
||||
* @return true if operation is accepted.
|
||||
*/
|
||||
inline BOOL CLogFile::SetLogSizeInEntries(DWORD /*dwLogSizeInEntries*/)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return maximum log file size in bytes.
|
||||
*/
|
||||
inline DWORD CLogFile::GetLogSizeInBytes(void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwLogSizeInBytes - maximum log file size in bytes.
|
||||
* @return true if operation is accepted.
|
||||
*/
|
||||
inline BOOL CLogFile::SetLogSizeInBytes(DWORD /*dwLogSizeInBytes*/)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline void CLogFile::CaptureObject(void)
|
||||
{
|
||||
EnterCriticalSection(&m_csLogFile);
|
||||
}
|
||||
|
||||
inline void CLogFile::ReleaseObject(void)
|
||||
{
|
||||
LeaveCriticalSection(&m_csLogFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current set of log flags.
|
||||
*/
|
||||
inline DWORD CLogFile::GetLogFlags(void) const
|
||||
{
|
||||
return m_dwLogFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwLogFlags - set of log flags.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
inline BOOL CLogFile::SetLogFlags(DWORD dwLogFlags)
|
||||
{
|
||||
m_dwLogFlags = dwLogFlags;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return minimal log level accepted by tracing functions.
|
||||
*/
|
||||
inline BUGTRAP_LOGLEVEL CLogFile::GetLogLevel(void) const
|
||||
{
|
||||
return m_eLogLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eLogLevel - minimal logl level accepted by tracing functions.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
inline BOOL CLogFile::SetLogLevel(BUGTRAP_LOGLEVEL eLogLevel)
|
||||
{
|
||||
m_eLogLevel = eLogLevel;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current echo mode.
|
||||
*/
|
||||
inline DWORD CLogFile::GetLogEchoMode(void)
|
||||
{
|
||||
return m_dwLogEchoMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dwLogEchoMode - new echo mode.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
inline BOOL CLogFile::SetLogEchoMode(DWORD dwLogEchoMode)
|
||||
{
|
||||
m_dwLogEchoMode = dwLogEchoMode;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline void CLogFile::WriteTextToDebugConsole(void)
|
||||
{
|
||||
OutputDebugString(m_StrStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return last entry text.
|
||||
*/
|
||||
inline PCTSTR CLogFile::GetEntryText(void) const
|
||||
{
|
||||
return (PCTSTR)m_StrStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszLogFileName - log file name.
|
||||
* @return true if log file name was created and false otherwise.
|
||||
*/
|
||||
inline BOOL CLogFile::CompleteLogFileName(PCTSTR pszLogFileName)
|
||||
{
|
||||
return GetCompleteLogFileName(m_szLogFileName, pszLogFileName, GetLogFileExtension());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszLogFileName - pointer to custom log file name.
|
||||
*/
|
||||
inline void CLogFile::SetLogFileName(PCTSTR pszLogFileName)
|
||||
{
|
||||
CompleteLogFileName(pszLogFileName);
|
||||
}
|
||||
193
third-party/BugTrap-1.3-57bd515/source/LogLink.h
vendored
Normal file
193
third-party/BugTrap-1.3-57bd515/source/LogLink.h
vendored
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Log file descriptor.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BugTrap.h"
|
||||
#include "BugTrapUtils.h"
|
||||
|
||||
/// Log file descriptor.
|
||||
class CLogLink
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CLogLink(void);
|
||||
/// Initialize the object.
|
||||
CLogLink(PCTSTR pszLogFileName);
|
||||
/// Destroy the object.
|
||||
virtual ~CLogLink(void);
|
||||
/// Get log type.
|
||||
virtual BUGTRAP_LOGTYPE GetLogType(void) const;
|
||||
/// Save log link entries.
|
||||
virtual void SaveEntries(bool bCrash);
|
||||
/// Get custom log file name.
|
||||
PCTSTR GetLogFileName(void) const;
|
||||
/// Set custom log file name.
|
||||
void SetLogFileName(PCTSTR pszLogFileName);
|
||||
/// Object comparison.
|
||||
friend bool operator==(const CLogLink& rLogLink1, const CLogLink& rLogLink2);
|
||||
/// Object comparison.
|
||||
friend bool operator!=(const CLogLink& rLogLink1, const CLogLink& rLogLink2);
|
||||
|
||||
protected:
|
||||
/// Custom log file name.
|
||||
TCHAR m_szLogFileName[MAX_PATH];
|
||||
};
|
||||
|
||||
inline CLogLink::CLogLink(void)
|
||||
{
|
||||
*m_szLogFileName = _T('\0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszLogFileName - pointer to custom log file name.
|
||||
*/
|
||||
inline CLogLink::CLogLink(PCTSTR pszLogFileName)
|
||||
{
|
||||
GetCompleteLogFileName(m_szLogFileName, pszLogFileName, NULL);
|
||||
}
|
||||
|
||||
inline CLogLink::~CLogLink(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to custom log file name.
|
||||
*/
|
||||
inline PCTSTR CLogLink::GetLogFileName(void) const
|
||||
{
|
||||
return m_szLogFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszLogFileName - pointer to custom log file name.
|
||||
*/
|
||||
inline void CLogLink::SetLogFileName(PCTSTR pszLogFileName)
|
||||
{
|
||||
GetCompleteLogFileName(m_szLogFileName, pszLogFileName, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of the log.
|
||||
*/
|
||||
inline BUGTRAP_LOGTYPE CLogLink::GetLogType(void) const
|
||||
{
|
||||
return BTLT_LOGFILE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bCrash - true if crash has occurred.
|
||||
*/
|
||||
inline void CLogLink::SaveEntries(bool /*bCrash*/)
|
||||
{
|
||||
}
|
||||
|
||||
/// Reg file descriptor.
|
||||
class CRegLink : public CLogLink
|
||||
{
|
||||
public:
|
||||
/// Object constructor.
|
||||
CRegLink(void);
|
||||
/// Object constructor.
|
||||
CRegLink(PCTSTR pszLogFileName);
|
||||
/// Object constructor.
|
||||
CRegLink(PCTSTR pszLogFileName, PCTSTR pszRegKey);
|
||||
/// Get log type.
|
||||
virtual BUGTRAP_LOGTYPE GetLogType(void) const;
|
||||
/// Save log link entries.
|
||||
virtual void SaveEntries(bool bCrash);
|
||||
/// Get registry key path.
|
||||
PCTSTR GetRegKey(void) const;
|
||||
/// Set registry key path.
|
||||
void SetRegKey(PCTSTR pszRegKey);
|
||||
|
||||
protected:
|
||||
/// Registry key path.
|
||||
TCHAR m_szRegKey[MAX_PATH];
|
||||
};
|
||||
|
||||
inline CRegLink::CRegLink(void)
|
||||
{
|
||||
*m_szRegKey = _T('\0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszLogFileName - pointer to custom log file name.
|
||||
*/
|
||||
inline CRegLink::CRegLink(PCTSTR pszLogFileName) : CLogLink(pszLogFileName)
|
||||
{
|
||||
*m_szRegKey = _T('\0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszLogFileName - pointer to custom log file name.
|
||||
* @param pszRegKey - registry key path
|
||||
*/
|
||||
inline CRegLink::CRegLink(PCTSTR pszLogFileName, PCTSTR pszRegKey) : CLogLink(pszLogFileName)
|
||||
{
|
||||
_tcscpy_s(m_szRegKey, countof(m_szRegKey), pszRegKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of the log.
|
||||
*/
|
||||
inline BUGTRAP_LOGTYPE CRegLink::GetLogType(void) const
|
||||
{
|
||||
return BTLT_REGEXPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bCrash - true if crash has occurred.
|
||||
*/
|
||||
inline void CRegLink::SaveEntries(bool bCrash)
|
||||
{
|
||||
if (bCrash)
|
||||
BT_ExportRegistryKey(m_szLogFileName, m_szRegKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszRegKey - registry key path
|
||||
*/
|
||||
inline void CRegLink::SetRegKey(PCTSTR pszRegKey)
|
||||
{
|
||||
_tcscpy_s(m_szRegKey, countof(m_szRegKey), pszRegKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return registry key path.
|
||||
*/
|
||||
inline PCTSTR CRegLink::GetRegKey(void) const
|
||||
{
|
||||
return m_szRegKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rLogLink1 - 1st object.
|
||||
* @param rLogLink2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator==(const CLogLink& rLogLink1, const CLogLink& rLogLink2)
|
||||
{
|
||||
return (_tcsicmp(rLogLink1.m_szLogFileName, rLogLink2.m_szLogFileName) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rLogLink1 - 1st object.
|
||||
* @param rLogLink2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator!=(const CLogLink& rLogLink1, const CLogLink& rLogLink2)
|
||||
{
|
||||
return (_tcsicmp(rLogLink1.m_szLogFileName, rLogLink2.m_szLogFileName) != 0);
|
||||
}
|
||||
106
third-party/BugTrap-1.3-57bd515/source/LogStream.cpp
vendored
Normal file
106
third-party/BugTrap-1.3-57bd515/source/LogStream.cpp
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Log stream class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "LogStream.h"
|
||||
#include "TextFormat.h"
|
||||
|
||||
/**
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CLogStream::LoadEntries(void)
|
||||
{
|
||||
_ASSERTE(m_hFile == INVALID_HANDLE_VALUE);
|
||||
if (m_hFile != INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
PCTSTR pszLogFileName = GetLogFileName();
|
||||
m_hFile = CreateFile(pszLogFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (m_hFile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
DWORD dwFileSize = GetFileSize(m_hFile, NULL);
|
||||
if (dwFileSize == 0)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
if (! WriteFile(m_hFile, g_arrUTF8Preamble, sizeof(g_arrUTF8Preamble), &dwWritten, NULL))
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SetFilePointer(m_hFile, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)
|
||||
goto error;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
Close();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CLogStream::ClearEntries(void)
|
||||
{
|
||||
_ASSERTE(m_hFile != INVALID_HANDLE_VALUE);
|
||||
if (m_hFile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
if (SetFilePointer(m_hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
return FALSE;
|
||||
if (! SetEndOfFile(m_hFile))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CLogStream::Close(void)
|
||||
{
|
||||
if (m_hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(m_hFile);
|
||||
m_hFile = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eLogLevel - log level number.
|
||||
* @param eEntryMode - entry mode.
|
||||
* @param rcsConsoleAccess - provides synchronous access to the console.
|
||||
* @param pszEntry - log entry text.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CLogStream::WriteLogEntry(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry)
|
||||
{
|
||||
_ASSERTE(m_hFile != INVALID_HANDLE_VALUE);
|
||||
if (m_hFile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
_ASSERTE(eEntryMode == EM_APPEND);
|
||||
if (eEntryMode != EM_APPEND)
|
||||
return FALSE;
|
||||
BUGTRAP_LOGLEVEL eLogFileLevel = GetLogLevel();
|
||||
if (eLogLevel <= eLogFileLevel)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime(&st);
|
||||
if (! WriteLogEntryToConsole(eLogLevel, &st, rcsConsoleAccess, pszEntry))
|
||||
FillEntryText(eLogLevel, &st, pszEntry);
|
||||
EncodeEntryText();
|
||||
const BYTE* pBuffer = m_MemStream.GetBuffer();
|
||||
if (pBuffer == NULL)
|
||||
return FALSE;
|
||||
DWORD dwLength = (DWORD)m_MemStream.GetLength();
|
||||
_ASSERTE(dwLength > 0);
|
||||
DWORD dwWritten;
|
||||
return WriteFile(m_hFile, pBuffer, dwLength, &dwWritten, NULL);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
95
third-party/BugTrap-1.3-57bd515/source/LogStream.h
vendored
Normal file
95
third-party/BugTrap-1.3-57bd515/source/LogStream.h
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Log stream class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "LogFile.h"
|
||||
#include "MemStream.h"
|
||||
#include "Encoding.h"
|
||||
|
||||
/**
|
||||
* Log stream class.
|
||||
*/
|
||||
class CLogStream : public CLogFile
|
||||
{
|
||||
public:
|
||||
/// Object constructor,
|
||||
CLogStream(void);
|
||||
/// Object destructor.
|
||||
virtual ~CLogStream(void);
|
||||
/// Load Entries into memory.
|
||||
virtual BOOL LoadEntries(void);
|
||||
/// Save entries into disk.
|
||||
virtual BOOL SaveEntries(BOOL bCrash);
|
||||
/// Clear log entries.
|
||||
virtual BOOL ClearEntries(void);
|
||||
/// Add new log entry.
|
||||
virtual BOOL WriteLogEntry(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry);
|
||||
/// Close log file.
|
||||
virtual void Close(void);
|
||||
|
||||
protected:
|
||||
/// Get default log file extension.
|
||||
virtual PCTSTR GetLogFileExtension(void) const;
|
||||
|
||||
private:
|
||||
/// Protects the class from being accidentally copied.
|
||||
CLogStream(const CLogStream& rLogFile);
|
||||
/// Protects the class from being accidentally copied.
|
||||
CLogStream& operator=(const CLogStream& rLogFile);
|
||||
|
||||
/// Encode entry text.
|
||||
void EncodeEntryText(void);
|
||||
|
||||
/// Log file handle.
|
||||
HANDLE m_hFile;
|
||||
/// Encoder object pre-allocated for the log.
|
||||
CUTF8EncStream m_EncStream;
|
||||
/// Pre-allocated buffer for encoded log entry text.
|
||||
CMemStream m_MemStream;
|
||||
};
|
||||
|
||||
inline CLogStream::CLogStream(void) : m_MemStream(1024), m_EncStream(&m_MemStream)
|
||||
{
|
||||
m_hFile = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
inline CLogStream::~CLogStream(void)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bCrash - true if the crash has been detected.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
inline BOOL CLogStream::SaveEntries(BOOL /*bCrash*/)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return log file extension.
|
||||
*/
|
||||
inline PCTSTR CLogStream::GetLogFileExtension(void) const
|
||||
{
|
||||
return _T(".txt");
|
||||
}
|
||||
|
||||
inline void CLogStream::EncodeEntryText(void)
|
||||
{
|
||||
m_EncStream.Reset();
|
||||
PCTSTR pszEntry = GetEntryText();
|
||||
m_EncStream.WriteUTF8Bin(pszEntry);
|
||||
}
|
||||
146
third-party/BugTrap-1.3-57bd515/source/MachineInfoDlg.cpp
vendored
Normal file
146
third-party/BugTrap-1.3-57bd515/source/MachineInfoDlg.cpp
vendored
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Machine Info dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "MachineInfoDlg.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "BugTrapUI.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUI BugTrap Graphical User Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief WM_COMMAND handler of Machine Info dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param id - control ID.
|
||||
* @param hwndCtl - control handle.
|
||||
* @param codeNotify - notification code.
|
||||
*/
|
||||
static void MachineInfoDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
codeNotify; hwndCtl;
|
||||
switch (id)
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_INITDIALOG handler of Machine Info dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hwndFocus - system-defined focus window.
|
||||
* @param lParam - user-defined parameter.
|
||||
* @return true to setup focus to system-defined control.
|
||||
*/
|
||||
static BOOL MachineInfoDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
lParam; hwndFocus;
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hBigAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)g_pResManager->m_hBigAppIcon);
|
||||
if (g_pResManager->m_hSmallAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_pResManager->m_hSmallAppIcon);
|
||||
CenterWindow(hwnd, GetParent(hwnd));
|
||||
|
||||
HWND hwndCtl;
|
||||
TCHAR szTempBuf[256];
|
||||
CStrStream Stream(8 * 1024);
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_CPU_TEXT);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hFixedFont)
|
||||
SetWindowFont(hwndCtl, g_pResManager->m_hFixedFont, FALSE);
|
||||
Stream.Reset();
|
||||
CSymEngine::GetCpuString(Stream);
|
||||
SetWindowText(hwndCtl, Stream);
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_OS_TEXT);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hFixedFont)
|
||||
SetWindowFont(hwndCtl, g_pResManager->m_hFixedFont, FALSE);
|
||||
CSymEngine::GetOsString(szTempBuf, countof(szTempBuf));
|
||||
SetWindowText(hwndCtl, szTempBuf);
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_MEM_TEXT);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hFixedFont)
|
||||
SetWindowFont(hwndCtl, g_pResManager->m_hFixedFont, FALSE);
|
||||
CSymEngine::GetMemString(szTempBuf, countof(szTempBuf));
|
||||
SetWindowText(hwndCtl, szTempBuf);
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_ENVIRONMENT);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hFixedFont)
|
||||
SetWindowFont(hwndCtl, g_pResManager->m_hFixedFont, FALSE);
|
||||
Stream.Reset();
|
||||
CSymEngine::GetEnvironmentStrings(Stream);
|
||||
SetWindowText(hwndCtl, Stream);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_CTLCOLORXXX handler of Machine Info dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hdc - device context.
|
||||
* @param hwndChild - child window handle.
|
||||
* @param type - message subtype.
|
||||
* @return brush handle.
|
||||
*/
|
||||
static HBRUSH MachineInfoDlg_OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type)
|
||||
{
|
||||
hwnd; hdc;
|
||||
if (type == CTLCOLOR_STATIC)
|
||||
{
|
||||
int nChildID = GetDlgCtrlID(hwndChild);
|
||||
if (nChildID == IDC_ENVIRONMENT)
|
||||
{
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
SetBkColor(hdc, GetSysColor(COLOR_BTNHIGHLIGHT));
|
||||
return g_pResManager->m_hbrControlLight;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dialog procedure of Machine Info dialog.
|
||||
* @param hwndDlg - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - 1st message parameter.
|
||||
* @param lParam - 2nd message parameter.
|
||||
* @return message result.
|
||||
*/
|
||||
INT_PTR CALLBACK MachineInfoDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
HANDLE_MSG(hwndDlg, WM_INITDIALOG, MachineInfoDlg_OnInitDialog);
|
||||
HANDLE_MSG(hwndDlg, WM_COMMAND, MachineInfoDlg_OnCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_CTLCOLORSTATIC, MachineInfoDlg_OnCtlColor);
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
17
third-party/BugTrap-1.3-57bd515/source/MachineInfoDlg.h
vendored
Normal file
17
third-party/BugTrap-1.3-57bd515/source/MachineInfoDlg.h
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Machine Info dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
INT_PTR CALLBACK MachineInfoDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
352
third-party/BugTrap-1.3-57bd515/source/MachineStateDlg.cpp
vendored
Normal file
352
third-party/BugTrap-1.3-57bd515/source/MachineStateDlg.cpp
vendored
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Machine State dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "BugTrapUI.h"
|
||||
#include "WaitCursor.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "MachineStateDlg.h"
|
||||
#include "LayoutManager.h"
|
||||
#include "TextView.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUI BugTrap Graphical User Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Process list column identifiers.
|
||||
enum PROCESS_LIST_COLUMN_ID
|
||||
{
|
||||
/// PID.
|
||||
CID_PROCESS_ID,
|
||||
/// Process name.
|
||||
CID_PROCESS_NAME
|
||||
};
|
||||
|
||||
/// Process list column identifiers.
|
||||
enum PROCESS_MODULES_LIST_COLUMN_ID
|
||||
{
|
||||
/// Module name.
|
||||
CID_MODULE_NAME,
|
||||
/// Module version.
|
||||
CID_MODULE_VERSION,
|
||||
/// Base address.
|
||||
CID_MODULE_BASE
|
||||
};
|
||||
|
||||
|
||||
/// Control layouts for Machine State dialog.
|
||||
static LAYOUT_INFO g_arrMachineStateLayout[] =
|
||||
{
|
||||
LAYOUT_INFO(IDC_PROCESS_LIST_FRAME, ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_CENTER),
|
||||
LAYOUT_INFO(IDC_PROCESS_LIST, ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_CENTER),
|
||||
LAYOUT_INFO(IDC_PROCESS_MODULES_LIST_FRAME, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_BOTTOM),
|
||||
LAYOUT_INFO(IDC_PROCESS_MODULES_LIST, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_BOTTOM),
|
||||
LAYOUT_INFO(IDCANCEL, ALIGN_RIGHT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_TOP)
|
||||
};
|
||||
|
||||
/// Dialog layout manager.
|
||||
static CLayoutManager g_LayoutMgr;
|
||||
/// Process list sort order.
|
||||
static CListViewOrder g_ProcessListOrder;
|
||||
/// Modules list sort order.
|
||||
static CListViewOrder g_ModulesListOrder;
|
||||
|
||||
/**
|
||||
* @brief WM_COMMAND handler of Machine State dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param id - control ID.
|
||||
* @param hwndCtl - control handle.
|
||||
* @param codeNotify - notification code.
|
||||
*/
|
||||
static void MachineStateDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
hwndCtl;
|
||||
switch (codeNotify)
|
||||
{
|
||||
case BN_CLICKED:
|
||||
switch (id)
|
||||
{
|
||||
case IDOK:
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, FALSE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_INITDIALOG handler of Machine State dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hwndFocus - system-defined focus window.
|
||||
* @param lParam - user-defined parameter.
|
||||
* @return true to setup focus to system-defined control.
|
||||
*/
|
||||
static BOOL MachineStateDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
lParam; hwndFocus;
|
||||
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hBigAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)g_pResManager->m_hBigAppIcon);
|
||||
if (g_pResManager->m_hSmallAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_pResManager->m_hSmallAppIcon);
|
||||
CenterWindow(hwnd, GetParent(hwnd));
|
||||
g_LayoutMgr.InitLayout(hwnd, g_arrMachineStateLayout, countof(g_arrMachineStateLayout));
|
||||
|
||||
HWND hwndProcessList = GetDlgItem(hwnd, IDC_PROCESS_LIST);
|
||||
ListView_SetExtendedListViewStyle(hwndProcessList, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
|
||||
|
||||
HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST);
|
||||
ListView_SetExtendedListViewStyle(hwndModuleList, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
|
||||
|
||||
RECT rcList;
|
||||
GetClientRect(hwndProcessList, &rcList);
|
||||
rcList.right -= GetSystemMetrics(SM_CXHSCROLL);
|
||||
|
||||
TCHAR szColumnTitle[64];
|
||||
LVCOLUMN lvc;
|
||||
ZeroMemory(&lvc, sizeof(lvc));
|
||||
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
|
||||
lvc.pszText = szColumnTitle;
|
||||
|
||||
lvc.cx = rcList.right / 5;
|
||||
LoadString(g_hInstance, IDS_COLUMN_PID, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndProcessList, CID_PROCESS_ID, &lvc);
|
||||
|
||||
lvc.cx = rcList.right * 4 / 5;
|
||||
LoadString(g_hInstance, IDS_COLUMN_PROCESS, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndProcessList, CID_PROCESS_NAME, &lvc);
|
||||
|
||||
lvc.cx = rcList.right / 2;
|
||||
LoadString(g_hInstance, IDS_COLUMN_MODULE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndModuleList, CID_MODULE_NAME, &lvc);
|
||||
|
||||
lvc.cx = rcList.right / 4;
|
||||
LoadString(g_hInstance, IDS_COLUMN_VERSION, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndModuleList, CID_MODULE_VERSION, &lvc);
|
||||
|
||||
lvc.cx = rcList.right / 4;
|
||||
LoadString(g_hInstance, IDS_COLUMN_BASE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndModuleList, CID_MODULE_BASE, &lvc);
|
||||
|
||||
CEnumProcess::CProcessEntry ProcEntry;
|
||||
if (g_pEnumProc->GetProcessFirst(ProcEntry))
|
||||
{
|
||||
LVITEM lvi;
|
||||
ZeroMemory(&lvi, sizeof(lvi));
|
||||
lvi.mask = LVIF_TEXT | LVIF_PARAM;
|
||||
int iItemPos = 0;
|
||||
do
|
||||
{
|
||||
TCHAR szProcessID[64];
|
||||
_ultot_s(ProcEntry.m_dwProcessID, szProcessID, countof(szProcessID), 10);
|
||||
lvi.iItem = iItemPos;
|
||||
lvi.pszText = szProcessID;
|
||||
lvi.lParam = ProcEntry.m_dwProcessID;
|
||||
ListView_InsertItem(hwndProcessList, &lvi);
|
||||
ListView_SetItemText(hwndProcessList, iItemPos, CID_PROCESS_NAME, ProcEntry.m_szProcessName);
|
||||
++iItemPos;
|
||||
}
|
||||
while (g_pEnumProc->GetProcessNext(ProcEntry));
|
||||
}
|
||||
|
||||
// LVM_SETIMAGELIST resets header control image list
|
||||
g_ProcessListOrder.InitList(hwndProcessList);
|
||||
g_ModulesListOrder.InitList(hwndModuleList);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_DESTROY handler of Machine State dialog.
|
||||
* @param hwnd - window handle.
|
||||
*/
|
||||
static void MachineStateDlg_OnDestroy(HWND hwnd)
|
||||
{
|
||||
hwnd;
|
||||
g_pEnumProc->Close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_SIZE handler of Machine State dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param state - window state.
|
||||
* @param cx - window width.
|
||||
* @param cy - window height.
|
||||
*/
|
||||
static void MachineStateDlg_OnSize(HWND hwnd, UINT state, int cx, int cy)
|
||||
{
|
||||
hwnd; cx; cy; state;
|
||||
g_LayoutMgr.ApplyLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_GETMINMAXINFO handler of Machine State dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param pMinMaxInfo - window min-max info.
|
||||
*/
|
||||
static void MachineStateDlg_OnGetMinMaxInfo(HWND hwnd, PMINMAXINFO pMinMaxInfo)
|
||||
{
|
||||
hwnd;
|
||||
pMinMaxInfo->ptMinTrackSize = g_LayoutMgr.GetMinTrackSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_NOTIFY handler of Machine State dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param idCtrl - identifier of the common control sending the message.
|
||||
* @param pnmh - pointer to an NMHDR structure that contains the notification code and additional information.
|
||||
*/
|
||||
static LRESULT MachineStateDlg_OnNotify(HWND hwnd, int idCtrl, LPNMHDR pnmh)
|
||||
{
|
||||
switch (pnmh->code)
|
||||
{
|
||||
case LVN_ITEMCHANGED:
|
||||
{
|
||||
if (idCtrl != IDC_PROCESS_LIST)
|
||||
break;
|
||||
LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh;
|
||||
if ((pnmv->uNewState & LVIS_SELECTED) != (pnmv->uOldState & LVIS_SELECTED))
|
||||
{
|
||||
if (pnmv->uNewState & LVIS_SELECTED)
|
||||
{
|
||||
CWaitCursor wait(true);
|
||||
HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST);
|
||||
SendMessage(hwndModuleList, WM_SETREDRAW, FALSE, 0);
|
||||
DisplayWaitBanner(hwndModuleList);
|
||||
|
||||
LVITEM lvi;
|
||||
ZeroMemory(&lvi, sizeof(lvi));
|
||||
lvi.mask = LVIF_TEXT;
|
||||
CEnumProcess::CModuleEntry module;
|
||||
if (g_pEnumProc->GetModuleFirst((DWORD)pnmv->lParam, module))
|
||||
{
|
||||
int iItemPos = 0;
|
||||
do
|
||||
{
|
||||
lvi.iItem = iItemPos;
|
||||
lvi.pszText = module.m_szModuleName;
|
||||
ListView_InsertItem(hwndModuleList, &lvi);
|
||||
TCHAR szVersionString[64];
|
||||
if (CSymEngine::GetVersionString(module.m_szModuleName, szVersionString, countof(szVersionString)))
|
||||
ListView_SetItemText(hwndModuleList, iItemPos, CID_MODULE_VERSION, szVersionString);
|
||||
TCHAR szTempBuf[32];
|
||||
#if defined _WIN64
|
||||
_stprintf_s(szTempBuf, countof(szTempBuf), _T("%016X"), (DWORD_PTR)module.m_pLoadBase);
|
||||
#elif defined _WIN32
|
||||
_stprintf_s(szTempBuf, countof(szTempBuf), _T("%08X"), (DWORD_PTR)module.m_pLoadBase);
|
||||
#endif
|
||||
ListView_SetItemText(hwndModuleList, iItemPos, CID_MODULE_BASE, szTempBuf);
|
||||
++iItemPos;
|
||||
}
|
||||
while (g_pEnumProc->GetModuleNext((DWORD)pnmv->lParam, module));
|
||||
}
|
||||
else
|
||||
{
|
||||
TCHAR szMessage[100];
|
||||
LoadString(g_hInstance, IDS_ERROR_NOT_AVAILABLE, szMessage, countof(szMessage));
|
||||
lvi.iItem = 0;
|
||||
lvi.pszText = szMessage;
|
||||
ListView_InsertItem(hwndModuleList, &lvi);
|
||||
}
|
||||
|
||||
SendMessage(hwndModuleList, WM_SETREDRAW, TRUE, 0);
|
||||
InvalidateRect(hwndModuleList, NULL, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST);
|
||||
ListView_DeleteAllItems(hwndModuleList);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LVN_COLUMNCLICK:
|
||||
{
|
||||
LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh;
|
||||
if (idCtrl == IDC_PROCESS_LIST)
|
||||
{
|
||||
HWND hwndProcessList = GetDlgItem(hwnd, IDC_PROCESS_LIST);
|
||||
g_ProcessListOrder.ToggleSortParams(hwndProcessList, pnmv->iSubItem);
|
||||
LISTVIEW_SORT_PARAMS lvSortParams;
|
||||
lvSortParams.hwndList = hwndProcessList;
|
||||
lvSortParams.iColumnNumber = pnmv->iSubItem;
|
||||
lvSortParams.bAscending = g_ProcessListOrder.GetSortOrder();
|
||||
switch (pnmv->iSubItem)
|
||||
{
|
||||
case CID_PROCESS_ID:
|
||||
lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_INTEGER;
|
||||
break;
|
||||
case CID_PROCESS_NAME:
|
||||
lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_STRING;
|
||||
break;
|
||||
}
|
||||
ListView_SortItemsEx(hwndProcessList, &ListViewCompareFunc, (LPARAM)&lvSortParams);
|
||||
}
|
||||
else if (idCtrl == IDC_PROCESS_MODULES_LIST)
|
||||
{
|
||||
HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST);
|
||||
g_ModulesListOrder.ToggleSortParams(hwndModuleList, pnmv->iSubItem);
|
||||
LISTVIEW_SORT_PARAMS lvSortParams;
|
||||
lvSortParams.hwndList = hwndModuleList;
|
||||
lvSortParams.iColumnNumber = pnmv->iSubItem;
|
||||
lvSortParams.bAscending = g_ModulesListOrder.GetSortOrder();
|
||||
switch (pnmv->iSubItem)
|
||||
{
|
||||
case CID_MODULE_NAME:
|
||||
case CID_MODULE_VERSION:
|
||||
lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_STRING;
|
||||
break;
|
||||
case CID_MODULE_BASE:
|
||||
lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_HEXADECIMAL;
|
||||
break;
|
||||
}
|
||||
ListView_SortItemsEx(hwndModuleList, &ListViewCompareFunc, (LPARAM)&lvSortParams);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dialog procedure of Machine State dialog.
|
||||
* @param hwndDlg - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - 1st message parameter.
|
||||
* @param lParam - 2nd message parameter.
|
||||
* @return message result.
|
||||
*/
|
||||
INT_PTR CALLBACK MachineStateDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
HANDLE_MSG(hwndDlg, WM_INITDIALOG, MachineStateDlg_OnInitDialog);
|
||||
HANDLE_MSG(hwndDlg, WM_DESTROY, MachineStateDlg_OnDestroy);
|
||||
HANDLE_MSG(hwndDlg, WM_COMMAND, MachineStateDlg_OnCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_SIZE, MachineStateDlg_OnSize);
|
||||
HANDLE_MSG(hwndDlg, WM_GETMINMAXINFO, MachineStateDlg_OnGetMinMaxInfo);
|
||||
HANDLE_MSG(hwndDlg, WM_NOTIFY, MachineStateDlg_OnNotify);
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
17
third-party/BugTrap-1.3-57bd515/source/MachineStateDlg.h
vendored
Normal file
17
third-party/BugTrap-1.3-57bd515/source/MachineStateDlg.h
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Machine State dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
INT_PTR CALLBACK MachineStateDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
472
third-party/BugTrap-1.3-57bd515/source/MainDlg.cpp
vendored
Normal file
472
third-party/BugTrap-1.3-57bd515/source/MainDlg.cpp
vendored
Normal file
|
|
@ -0,0 +1,472 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: BugTrap main dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "BugTrapUI.h"
|
||||
#include "WaitCursor.h"
|
||||
#include "MainDlg.h"
|
||||
#include "MachineStateDlg.h"
|
||||
#include "MachineInfoDlg.h"
|
||||
#include "PreviewDlg.h"
|
||||
#include "AboutDlg.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/// Stack trace list column identifiers.
|
||||
enum STACK_WIN32_COLUMN_ID
|
||||
{
|
||||
/// Stack frame address.
|
||||
CID_WIN32_ENTRY_ADDRESS,
|
||||
/// Function name.
|
||||
CID_WIN32_ENTRY_FUNCTION,
|
||||
/// Source file name.
|
||||
CID_WIN32_ENTRY_FILE,
|
||||
/// Entry line number.
|
||||
CID_WIN32_ENTRY_LINE,
|
||||
/// Module file name.
|
||||
CID_WIN32_ENTRY_MODULE
|
||||
};
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
/// Stack trace list column identifiers.
|
||||
enum STACK_NET_COLUMN_ID
|
||||
{
|
||||
/// Type name.
|
||||
CID_NET_ENTRY_TYPE,
|
||||
/// Method name.
|
||||
CID_NET_ENTRY_METHOD,
|
||||
/// Source file name.
|
||||
CID_NET_ENTRY_FILE,
|
||||
/// Entry line number.
|
||||
CID_NET_ENTRY_LINE,
|
||||
/// Assembly name.
|
||||
CID_NET_ENTRY_ASSEMBLY
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUI BugTrap Graphical User Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Tool-tip window handle.
|
||||
static HWND g_hwndToolTip = NULL;
|
||||
/// URL hyper-link control pointing to support site.
|
||||
static CHyperLink g_hlURL;
|
||||
|
||||
/**
|
||||
* @brief Save bug report on the disk.
|
||||
* @param hwndParent - parent window handle.
|
||||
*/
|
||||
static void SaveReport(HWND hwndParent)
|
||||
{
|
||||
TCHAR szFileName[MAX_PATH];
|
||||
OPENFILENAME ofn;
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hwndParent;
|
||||
ofn.lpstrFile = szFileName;
|
||||
ofn.nMaxFile = countof(szFileName);
|
||||
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
|
||||
if (g_dwFlags & BTF_DETAILEDMODE)
|
||||
{
|
||||
ofn.lpstrFilter = _T("Zip Archives\0*.zip\0All Files\0*.*\0");
|
||||
ofn.lpstrDefExt = _T("zip");
|
||||
}
|
||||
else if (g_eReportFormat == BTRF_TEXT)
|
||||
{
|
||||
ofn.lpstrFilter = _T("Log Files\0*.log\0Text Files\0*.txt\0All Files\0*.*\0");
|
||||
ofn.lpstrDefExt = _T("log");
|
||||
}
|
||||
else if (g_eReportFormat == BTRF_XML)
|
||||
{
|
||||
ofn.lpstrFilter = _T("Xml Files\0*.xml\0All Files\0*.*\0");
|
||||
ofn.lpstrDefExt = _T("xml");
|
||||
}
|
||||
else
|
||||
{
|
||||
_ASSERT(FALSE);
|
||||
return;
|
||||
}
|
||||
g_pSymEngine->GetReportFileName(ofn.lpstrDefExt, szFileName, countof(szFileName));
|
||||
if (GetSaveFileName(&ofn))
|
||||
{
|
||||
UpdateWindow(hwndParent);
|
||||
CWaitCursor wait(true);
|
||||
CopyFile(g_szInternalReportFilePath, szFileName, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize CPU registers message.
|
||||
* @param hwnd - parent window handle.
|
||||
*/
|
||||
static void InitReg(HWND hwnd)
|
||||
{
|
||||
HWND hwndReg = GetDlgItem(hwnd, IDC_REGISTER);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hFixedFont)
|
||||
SetWindowFont(hwndReg, g_pResManager->m_hFixedFont, FALSE);
|
||||
#if defined _WIN64
|
||||
TCHAR szRegString[512];
|
||||
#elif defined _WIN32
|
||||
TCHAR szRegString[256];
|
||||
#endif
|
||||
g_pSymEngine->GetRegistersString(szRegString, countof(szRegString));
|
||||
SetWindowText(hwndReg, szRegString);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize error reason message.
|
||||
* @param hwnd - parent window handle.
|
||||
*/
|
||||
static void InitErrorInfo(HWND hwnd)
|
||||
{
|
||||
HWND hwndError = GetDlgItem(hwnd, IDC_EXCEPTION);
|
||||
CStrStream Stream(1024);
|
||||
g_pSymEngine->GetErrorString(Stream);
|
||||
SetWindowText(hwndError, Stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize call stack message.
|
||||
* @param hwnd - parent window handle.
|
||||
*/
|
||||
static void InitStackTrace(HWND hwnd)
|
||||
{
|
||||
HWND hwndStack = GetDlgItem(hwnd, IDC_STACKTRACE);
|
||||
ListView_SetExtendedListViewStyle(hwndStack, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
|
||||
|
||||
TCHAR szColumnTitle[64];
|
||||
LVCOLUMN lvc;
|
||||
ZeroMemory(&lvc, sizeof(lvc));
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = szColumnTitle;
|
||||
|
||||
#ifdef _MANAGED
|
||||
if (NetThunks::IsNetException())
|
||||
{
|
||||
LoadString(g_hInstance, IDS_COLUMN_TYPE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_NET_ENTRY_TYPE, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_METHOD, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_NET_ENTRY_METHOD, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_FILE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_NET_ENTRY_FILE, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_LINE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_NET_ENTRY_LINE, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_ASSEMBLY, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_NET_ENTRY_ASSEMBLY, &lvc);
|
||||
|
||||
CNetStackTrace::CNetStackTraceEntry Entry;
|
||||
if (g_pSymEngine->GetFirstStackTraceEntry(Entry))
|
||||
{
|
||||
LVITEM lvi;
|
||||
ZeroMemory(&lvi, sizeof(lvi));
|
||||
lvi.mask = LVIF_TEXT;
|
||||
int iItemPos = 0;
|
||||
do
|
||||
{
|
||||
lvi.iItem = iItemPos;
|
||||
lvi.pszText = Entry.m_szType;
|
||||
ListView_InsertItem(hwndStack, &lvi);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_NET_ENTRY_METHOD, Entry.m_szMethod);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_NET_ENTRY_FILE, Entry.m_szSourceFile);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_NET_ENTRY_LINE, Entry.m_szLineInfo);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_NET_ENTRY_ASSEMBLY, Entry.m_szAssembly);
|
||||
++iItemPos;
|
||||
}
|
||||
while (g_pSymEngine->GetNextStackTraceEntry(Entry));
|
||||
}
|
||||
|
||||
ListView_SetColumnWidth(hwndStack, CID_NET_ENTRY_TYPE, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_NET_ENTRY_METHOD, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_NET_ENTRY_FILE, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_NET_ENTRY_LINE, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_NET_ENTRY_ASSEMBLY, LVSCW_AUTOSIZE_USEHEADER);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_ADDRESS, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_WIN32_ENTRY_ADDRESS, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_FUNCTION, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_WIN32_ENTRY_FUNCTION, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_FILE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_WIN32_ENTRY_FILE, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_LINE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_WIN32_ENTRY_LINE, &lvc);
|
||||
|
||||
LoadString(g_hInstance, IDS_COLUMN_MODULE, szColumnTitle, countof(szColumnTitle));
|
||||
ListView_InsertColumn(hwndStack, CID_WIN32_ENTRY_MODULE, &lvc);
|
||||
|
||||
CSymEngine::CStackTraceEntry Entry;
|
||||
if (g_pSymEngine->GetFirstStackTraceEntry(Entry))
|
||||
{
|
||||
LVITEM lvi;
|
||||
ZeroMemory(&lvi, sizeof(lvi));
|
||||
lvi.mask = LVIF_TEXT;
|
||||
int iItemPos = 0;
|
||||
do
|
||||
{
|
||||
lvi.iItem = iItemPos;
|
||||
lvi.pszText = Entry.m_szAddress;
|
||||
ListView_InsertItem(hwndStack, &lvi);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_WIN32_ENTRY_FUNCTION, Entry.m_szFunctionInfo);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_WIN32_ENTRY_FILE, Entry.m_szSourceFile);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_WIN32_ENTRY_LINE, Entry.m_szLineInfo);
|
||||
ListView_SetItemText(hwndStack, iItemPos, CID_WIN32_ENTRY_MODULE, Entry.m_szModule);
|
||||
++iItemPos;
|
||||
}
|
||||
while (g_pSymEngine->GetNextStackTraceEntry(Entry));
|
||||
}
|
||||
|
||||
ListView_SetColumnWidth(hwndStack, CID_WIN32_ENTRY_ADDRESS, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_WIN32_ENTRY_FUNCTION, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_WIN32_ENTRY_FILE, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_WIN32_ENTRY_LINE, LVSCW_AUTOSIZE_USEHEADER);
|
||||
ListView_SetColumnWidth(hwndStack, CID_WIN32_ENTRY_MODULE, LVSCW_AUTOSIZE_USEHEADER);
|
||||
#ifdef _MANAGED
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_COMMAND handler of main dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param id - control ID.
|
||||
* @param hwndCtl - control handle.
|
||||
* @param codeNotify - notification code.
|
||||
*/
|
||||
static void MainDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
codeNotify; hwndCtl;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case IDC_MACHINE_STATE:
|
||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_MACHINE_STATE_DLG), hwnd, MachineStateDlgProc);
|
||||
break;
|
||||
case IDC_MACHINE_INFO:
|
||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_MACHINE_INFO_DLG), hwnd, MachineInfoDlgProc);
|
||||
break;
|
||||
case IDC_PREVIEW_REPORT:
|
||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_PREVIEW_DLG), hwnd, PreviewDlgProc);
|
||||
break;
|
||||
case IDC_MAILTO:
|
||||
MailTempReportEx(hwnd);
|
||||
break;
|
||||
case IDC_SUBMIT_BUG:
|
||||
SubmitTempReport(hwnd);
|
||||
break;
|
||||
case IDC_SAVE_REPORT:
|
||||
SaveReport(hwnd);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize dialog controls.
|
||||
* @param hwnd - window handle.
|
||||
*/
|
||||
static void InitControls(HWND hwnd)
|
||||
{
|
||||
HWND hwndClose = GetDlgItem(hwnd, IDCANCEL);
|
||||
HWND hwndPreview = GetDlgItem(hwnd, IDC_PREVIEW_REPORT);
|
||||
HWND hwndSave = GetDlgItem(hwnd, IDC_SAVE_REPORT);
|
||||
HWND hwndMailTo = GetDlgItem(hwnd, IDC_MAILTO);
|
||||
HWND hwndSubmitBug = GetDlgItem(hwnd, IDC_SUBMIT_BUG);
|
||||
HWND hwndMachineInfo = GetDlgItem(hwnd, IDC_MACHINE_INFO);
|
||||
HWND hwndMachineState = GetDlgItem(hwnd, IDC_MACHINE_STATE);
|
||||
|
||||
g_hwndToolTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hwnd, NULL, g_hInstance, 0l);
|
||||
if (g_hwndToolTip)
|
||||
{
|
||||
RECT rcCtl;
|
||||
GetClientRect(hwndClose, &rcCtl);
|
||||
SendMessage(g_hwndToolTip, TTM_SETMAXTIPWIDTH, 0, rcCtl.right * 2);
|
||||
|
||||
TOOLINFO tinfo;
|
||||
ZeroMemory(&tinfo, sizeof(tinfo));
|
||||
tinfo.cbSize = sizeof(tinfo);
|
||||
tinfo.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
|
||||
tinfo.hinst = g_hInstance;
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndClose;
|
||||
tinfo.lpszText = (PTSTR)IDS_CLOSE_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndPreview;
|
||||
tinfo.lpszText = (PTSTR)IDS_PREVIEW_REPORT_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndSave;
|
||||
tinfo.lpszText = (PTSTR)IDS_SAVE_REPORT_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndMailTo;
|
||||
tinfo.lpszText = (PTSTR)IDS_MAILTO_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndSubmitBug;
|
||||
tinfo.lpszText = (PTSTR)IDS_SUBMIT_BUG_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndMachineInfo;
|
||||
tinfo.lpszText = (PTSTR)IDS_MACHINE_INFO_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndMachineState;
|
||||
tinfo.lpszText = (PTSTR)IDS_MACHINE_STATE_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
}
|
||||
|
||||
if (*g_szSupportHost == _T('\0') || g_nSupportPort == 0)
|
||||
{
|
||||
EnableWindow(hwndMailTo, FALSE);
|
||||
if (*g_szSupportEMail == _T('\0'))
|
||||
EnableWindow(hwndSubmitBug, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*g_szSupportEMail == _T('\0'))
|
||||
EnableWindow(hwndMailTo, FALSE);
|
||||
}
|
||||
|
||||
HWND hwndFocus = IsWindowEnabled(hwndSubmitBug) ? hwndSubmitBug : hwndClose;
|
||||
SetFocus(hwndFocus);
|
||||
SendMessage(hwnd, DM_SETDEFID, GetDlgCtrlID(hwndFocus), 0l);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_INITDIALOG handler of main dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hwndFocus - system-defined focus window.
|
||||
* @param lParam - user-defined parameter.
|
||||
* @return true to setup focus to system-defined control.
|
||||
*/
|
||||
static BOOL MainDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
lParam; hwndFocus;
|
||||
|
||||
InitControls(hwnd);
|
||||
InitIntro(hwnd, g_hlURL);
|
||||
InitReg(hwnd);
|
||||
InitErrorInfo(hwnd);
|
||||
InitStackTrace(hwnd);
|
||||
InitAbout(hwnd);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_CTLCOLORXXX handler of main dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hdc - device context.
|
||||
* @param hwndChild - child window handle.
|
||||
* @param type - message subtype.
|
||||
* @return brush handle.
|
||||
*/
|
||||
static HBRUSH MainDlg_OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type)
|
||||
{
|
||||
hwnd;
|
||||
if (type == CTLCOLOR_STATIC)
|
||||
{
|
||||
int nChildID = GetDlgCtrlID(hwndChild);
|
||||
if (nChildID == IDC_INTRO_BKGND ||
|
||||
nChildID == IDC_INTRO1 ||
|
||||
nChildID == IDC_INTRO2 ||
|
||||
nChildID == IDC_URL ||
|
||||
nChildID == IDC_URL_PREFIX)
|
||||
{
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
|
||||
return g_pResManager->m_hbrWindowBrush;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_DESTROY handler of main dialog.
|
||||
* @param hwnd - window handle.
|
||||
*/
|
||||
static void MainDlg_OnDestroy(HWND hwnd)
|
||||
{
|
||||
hwnd;
|
||||
|
||||
g_hlURL.Detach();
|
||||
|
||||
if (g_hwndToolTip)
|
||||
{
|
||||
DestroyWindow(g_hwndToolTip);
|
||||
g_hwndToolTip = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_SYSCOMMAND handler of main dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param cmd - specifies the type of system command requested.
|
||||
* @param x - horizontal position of the cursor, in screen coordinates.
|
||||
* @param y - vertical position of the cursor, in screen coordinates.
|
||||
*/
|
||||
void MainDlg_OnSysCommand(HWND hwnd, UINT cmd, int x, int y)
|
||||
{
|
||||
x; y;
|
||||
if ((cmd & 0xFFF0) == IDM_ABOUTBOX)
|
||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUT_BUGTRAP_DLG), hwnd, AboutDlgProc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dialog procedure of main dialog.
|
||||
* @param hwndDlg - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - 1st message parameter.
|
||||
* @param lParam - 2nd message parameter.
|
||||
* @return message result.
|
||||
*/
|
||||
INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
HANDLE_MSG(hwndDlg, WM_INITDIALOG, MainDlg_OnInitDialog);
|
||||
HANDLE_MSG(hwndDlg, WM_COMMAND, MainDlg_OnCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_SYSCOMMAND, MainDlg_OnSysCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_CTLCOLORSTATIC, MainDlg_OnCtlColor);
|
||||
HANDLE_MSG(hwndDlg, WM_DESTROY, MainDlg_OnDestroy);
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
17
third-party/BugTrap-1.3-57bd515/source/MainDlg.h
vendored
Normal file
17
third-party/BugTrap-1.3-57bd515/source/MainDlg.h
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: BugTrap main dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
244
third-party/BugTrap-1.3-57bd515/source/MemStream.cpp
vendored
Normal file
244
third-party/BugTrap-1.3-57bd515/source/MemStream.cpp
vendored
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: In-memory output stream.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "MemStream.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param rMemStream - another binary buffer.
|
||||
*/
|
||||
CMemStream::CMemStream(const CMemStream& rMemStream)
|
||||
{
|
||||
if (rMemStream.m_nPosition)
|
||||
{
|
||||
InitBuffer(rMemStream.m_nPosition);
|
||||
CopyData(rMemStream);
|
||||
}
|
||||
else
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rMemStream - another binary buffer.
|
||||
* @return reference to self.
|
||||
*/
|
||||
CMemStream& CMemStream::operator=(const CMemStream& rMemStream)
|
||||
{
|
||||
EnsureSize(rMemStream.m_nPosition, false);
|
||||
CopyData(rMemStream);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CMemStream::InitBuffer(void)
|
||||
{
|
||||
m_pBuffer = NULL;
|
||||
m_nSize = m_nLength = m_nPosition = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSize - initial buffer size.
|
||||
*/
|
||||
void CMemStream::InitBuffer(size_t nSize)
|
||||
{
|
||||
if (nSize)
|
||||
{
|
||||
m_nLength = m_nPosition = 0;
|
||||
m_pBuffer = new BYTE[nSize];
|
||||
if (m_pBuffer)
|
||||
{
|
||||
m_nSize = nSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nSize = 0;
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rMemStream - another binary buffer.
|
||||
*/
|
||||
void CMemStream::CopyData(const CMemStream& rMemStream)
|
||||
{
|
||||
m_nPosition = rMemStream.m_nPosition;
|
||||
m_nLength = rMemStream.m_nLength;
|
||||
CopyMemory(m_pBuffer, rMemStream.m_pBuffer, m_nPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSize - requested buffer size.
|
||||
* @param bAdaptiveGrowth - true for adaptive growth.
|
||||
*/
|
||||
void CMemStream::EnsureSize(size_t nSize, bool bAdaptiveGrowth)
|
||||
{
|
||||
if (m_nSize < nSize)
|
||||
{
|
||||
if (bAdaptiveGrowth)
|
||||
nSize *= 2;
|
||||
PBYTE pBuffer = new BYTE[nSize];
|
||||
if (! pBuffer)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
if (m_pBuffer)
|
||||
{
|
||||
CopyMemory(pBuffer, m_pBuffer, m_nPosition);
|
||||
delete[] m_pBuffer;
|
||||
}
|
||||
m_pBuffer = pBuffer;
|
||||
m_nSize = nSize;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pBytes - bytes array to be written.
|
||||
* @param nCount - number of characters to add.
|
||||
* @return number of successfully written bytes.
|
||||
*/
|
||||
size_t CMemStream::WriteBytes(const BYTE* pBytes, size_t nCount)
|
||||
{
|
||||
EnsureSize(m_nPosition + nCount, true);
|
||||
CopyMemory(m_pBuffer + m_nPosition, pBytes, nCount);
|
||||
m_nPosition += nCount;
|
||||
if (m_nPosition > m_nLength)
|
||||
m_nLength = m_nPosition;
|
||||
return nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bValue - byte value to be written.
|
||||
* @param nCount - number of characters to add.
|
||||
* @return number of written bytes.
|
||||
*/
|
||||
size_t CMemStream::WriteByte(BYTE bValue, size_t nCount)
|
||||
{
|
||||
EnsureSize(m_nPosition + nCount, true);
|
||||
FillMemory(m_pBuffer + m_nPosition, nCount, bValue);
|
||||
m_nPosition += nCount;
|
||||
if (m_nPosition > m_nLength)
|
||||
m_nLength = m_nPosition;
|
||||
return nCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bValue - byte value to be written.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
bool CMemStream::WriteByte(BYTE bValue)
|
||||
{
|
||||
EnsureSize(m_nPosition + 1, true);
|
||||
m_pBuffer[m_nPosition++] = bValue;
|
||||
if (m_nPosition > m_nLength)
|
||||
m_nLength = m_nPosition;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nLength - new stream length.
|
||||
* @return new file length.
|
||||
*/
|
||||
size_t CMemStream::SetLength(size_t nLength)
|
||||
{
|
||||
EnsureSize(nLength, false);
|
||||
if (m_nLength < nLength)
|
||||
ZeroMemory(m_pBuffer + m_nLength, nLength - m_nLength);
|
||||
m_nLength = nLength;
|
||||
if (m_nPosition > m_nLength)
|
||||
m_nPosition = m_nLength;
|
||||
return m_nLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nOffset - offset from start point.
|
||||
* @param nStartFrom - start point.
|
||||
*/
|
||||
void CMemStream::SetPositionPriv(ptrdiff_t nOffset, size_t nStartFrom)
|
||||
{
|
||||
if (nOffset < 0)
|
||||
{
|
||||
ptrdiff_t nNewPosition = nStartFrom + nOffset;
|
||||
if (nNewPosition < 0)
|
||||
m_nPosition = 0;
|
||||
else
|
||||
m_nPosition = nNewPosition;
|
||||
}
|
||||
else if (nOffset > 0)
|
||||
{
|
||||
size_t nNewPosition = nStartFrom + nOffset;
|
||||
if (nNewPosition > m_nLength)
|
||||
m_nPosition = m_nLength;
|
||||
else
|
||||
m_nPosition = nNewPosition;
|
||||
}
|
||||
else
|
||||
m_nPosition = nStartFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nOffset - offset from start point.
|
||||
* @param nMoveMethod - start point.
|
||||
* @return new position value.
|
||||
*/
|
||||
size_t CMemStream::SetPosition(ptrdiff_t nOffset, int nMoveMethod)
|
||||
{
|
||||
switch (nMoveMethod)
|
||||
{
|
||||
case FILE_BEGIN:
|
||||
SetPositionPriv(nOffset, 0);
|
||||
break;
|
||||
case FILE_CURRENT:
|
||||
SetPositionPriv(nOffset, m_nPosition);
|
||||
break;
|
||||
case FILE_END:
|
||||
SetPositionPriv(nOffset, m_nLength);
|
||||
break;
|
||||
default:
|
||||
return MAXSIZE_T;
|
||||
}
|
||||
return m_nPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bValue - output value.
|
||||
* @return true if byte has been retrieved from the stream.
|
||||
*/
|
||||
bool CMemStream::ReadByte(BYTE& bValue)
|
||||
{
|
||||
if (m_nPosition < m_nLength)
|
||||
{
|
||||
bValue = m_pBuffer[m_nPosition++];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param arrBytes - output array of bytes.
|
||||
* @param nCount - number of bytes in the array.
|
||||
* @return number of retrieved bytes.
|
||||
*/
|
||||
size_t CMemStream::ReadBytes(BYTE* arrBytes, size_t nCount)
|
||||
{
|
||||
size_t nMaxBytes = m_nLength - m_nPosition;
|
||||
if (nMaxBytes < nCount)
|
||||
nCount = nMaxBytes;
|
||||
CopyMemory(arrBytes, m_pBuffer + m_nPosition, nCount);
|
||||
m_nPosition += nCount;
|
||||
return nCount;
|
||||
}
|
||||
154
third-party/BugTrap-1.3-57bd515/source/MemStream.h
vendored
Normal file
154
third-party/BugTrap-1.3-57bd515/source/MemStream.h
vendored
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: In-memory stream.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Stream.h"
|
||||
|
||||
/// In-memory stream.
|
||||
class CMemStream : public CStream
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CMemStream(void);
|
||||
/// Initialize the object.
|
||||
explicit CMemStream(size_t nSize);
|
||||
/// Destroy the object.
|
||||
virtual ~CMemStream(void);
|
||||
/// Copy constructor.
|
||||
CMemStream(const CMemStream& rMemStream);
|
||||
/// Assignment operator.
|
||||
CMemStream& operator=(const CMemStream& rMemStream);
|
||||
/// Get list of supported features.
|
||||
virtual unsigned GetFeatures(void) const;
|
||||
/// Get pointer to the buffer.
|
||||
const BYTE* GetBuffer(void) const;
|
||||
/// Return true if end of stream has been reached.
|
||||
virtual bool IsEndOfStream(void) const;
|
||||
/// Get data length.
|
||||
virtual size_t GetLength(void) const;
|
||||
/// Set number of bytes in the stream.
|
||||
virtual size_t SetLength(size_t nLength);
|
||||
/// Get current position.
|
||||
virtual size_t GetPosition(void) const;
|
||||
/// Set current position.
|
||||
virtual size_t SetPosition(ptrdiff_t nOffset, int nMoveMethod);
|
||||
/// Write data to the buffer.
|
||||
virtual bool WriteByte(BYTE bValue);
|
||||
/// Write data to the buffer.
|
||||
virtual size_t WriteByte(BYTE bValue, size_t nCount);
|
||||
/// Write data to the buffer.
|
||||
virtual size_t WriteBytes(const BYTE* pBytes, size_t nCount);
|
||||
/// Write data to the buffer.
|
||||
size_t WriteStream(CMemStream* pMemStream);
|
||||
/// Clear data in the buffer.
|
||||
virtual void Close(void);
|
||||
/// Read one byte from the stream.
|
||||
virtual bool ReadByte(BYTE& bValue);
|
||||
/// Read array of bytes from the stream.
|
||||
virtual size_t ReadBytes(BYTE* arrBytes, size_t nNumBytes);
|
||||
|
||||
private:
|
||||
/// Initialize member variables.
|
||||
void InitBuffer(void);
|
||||
/// Initialize member variables.
|
||||
void InitBuffer(size_t nSize);
|
||||
/// Copy data from one buffer to another.
|
||||
void CopyData(const CMemStream& rMemStream);
|
||||
/// Ensures that the array has enough space.
|
||||
void EnsureSize(size_t nSize, bool bAdaptiveGrowth);
|
||||
/// Set current position.
|
||||
void SetPositionPriv(ptrdiff_t nOffset, size_t nStartFrom);
|
||||
|
||||
/// Data length.
|
||||
size_t m_nLength;
|
||||
/// Data position.
|
||||
size_t m_nPosition;
|
||||
/// Size of allocated buffer.
|
||||
size_t m_nSize;
|
||||
/// Pointer to the buffer.
|
||||
BYTE* m_pBuffer;
|
||||
};
|
||||
|
||||
inline CMemStream::CMemStream(void)
|
||||
{
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
inline CMemStream::~CMemStream(void)
|
||||
{
|
||||
delete[] m_pBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bit mask of supported features.
|
||||
*/
|
||||
inline unsigned CMemStream::GetFeatures(void) const
|
||||
{
|
||||
return (SF_CLOSE | SF_GETLENGTH | SF_SETLENGTH | SF_GETPOSITION | SF_SETPOSITION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to the buffer.
|
||||
*/
|
||||
inline const BYTE* CMemStream::GetBuffer(void) const
|
||||
{
|
||||
return m_pBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return length of the data.
|
||||
*/
|
||||
inline size_t CMemStream::GetLength(void) const
|
||||
{
|
||||
return m_nLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if end of stream has been reached.
|
||||
*/
|
||||
inline bool CMemStream::IsEndOfStream(void) const
|
||||
{
|
||||
return (m_nPosition >= m_nLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current stream position.
|
||||
*/
|
||||
inline size_t CMemStream::GetPosition(void) const
|
||||
{
|
||||
return m_nPosition;
|
||||
}
|
||||
|
||||
inline void CMemStream::Close(void)
|
||||
{
|
||||
m_nLength = m_nPosition = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pMemStream - another binary buffer.
|
||||
* @return true if data has been written.
|
||||
*/
|
||||
inline size_t CMemStream::WriteStream(CMemStream* pMemStream)
|
||||
{
|
||||
return WriteBytes(pMemStream->m_pBuffer + pMemStream->m_nPosition, pMemStream->m_nLength - pMemStream->m_nPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSize - initial buffer size.
|
||||
*/
|
||||
inline CMemStream::CMemStream(size_t nSize)
|
||||
{
|
||||
InitBuffer(nSize);
|
||||
}
|
||||
123
third-party/BugTrap-1.3-57bd515/source/ModuleImportTable.cpp
vendored
Normal file
123
third-party/BugTrap-1.3-57bd515/source/ModuleImportTable.cpp
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Table of modules that import SetUnhandledExceptionFilter() function.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "ModuleImportTable.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/// Macro for adding pointers/DWORDs together without C arithmetic interfering. Taken from Matt Pietrek's book.
|
||||
#define MakePtr(cast, ptr, offset) ((cast)((DWORD_PTR)(ptr) + (DWORD_PTR)(offset)))
|
||||
|
||||
/**
|
||||
* @param hModule - module handle.
|
||||
* @param bOverride - true if SetUnhandledExceptionFilter() must be overridden.
|
||||
* @param nNestedLevel - nested level (useful for debugging).
|
||||
*/
|
||||
void CModuleImportTable::TraverseImportTables(HMODULE hModule, BOOL bOverride, size_t nNestedLevel)
|
||||
{
|
||||
BOOL bCleanup = FALSE;
|
||||
if (nNestedLevel == 0)
|
||||
{
|
||||
if (! g_bWinNT)
|
||||
return;
|
||||
HMODULE hMainModule = GetModuleHandle(NULL);
|
||||
if (hModule == NULL)
|
||||
hModule = hMainModule;
|
||||
if (hModule == hMainModule && ! bOverride)
|
||||
bCleanup = TRUE;
|
||||
#ifdef _DEBUG
|
||||
if (bOverride)
|
||||
OutputDebugString(_T("Injecting fake SetUnhandledExceptionFilter() handler\n"));
|
||||
else
|
||||
OutputDebugString(_T("Restoring SetUnhandledExceptionFilter() handler\n"));
|
||||
#endif
|
||||
}
|
||||
PFSetUnhandledExceptionFilter pfnSavedSetUnhandledExceptionFilter;
|
||||
BOOL bFound = m_mapModuleEntries.Lookup(hModule, pfnSavedSetUnhandledExceptionFilter);
|
||||
if (bOverride ? bFound : ! bFound)
|
||||
return;
|
||||
PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER)hModule;
|
||||
if (pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
return;
|
||||
PIMAGE_NT_HEADERS pNTHeaders = MakePtr(PIMAGE_NT_HEADERS, pDOSHeader, pDOSHeader->e_lfanew);
|
||||
if (pNTHeaders->Signature != IMAGE_NT_SIGNATURE)
|
||||
return;
|
||||
DWORD dwImportRva = pNTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
|
||||
if (dwImportRva == 0)
|
||||
return;
|
||||
#ifdef _DEBUG
|
||||
TCHAR szModuleFileName[MAX_PATH];
|
||||
if (GetModuleFileName(hModule, szModuleFileName, countof(szModuleFileName)))
|
||||
{
|
||||
for (size_t i = 0; i < nNestedLevel; ++i)
|
||||
OutputDebugString(_T(" "));
|
||||
OutputDebugString(szModuleFileName);
|
||||
OutputDebugString(_T("\n"));
|
||||
}
|
||||
#endif
|
||||
if (bOverride)
|
||||
m_mapModuleEntries.SetAt(hModule, NULL);
|
||||
else
|
||||
m_mapModuleEntries.Delete(hModule);
|
||||
PIMAGE_IMPORT_DESCRIPTOR pImageImportDesc = MakePtr(PIMAGE_IMPORT_DESCRIPTOR, pDOSHeader, dwImportRva);
|
||||
while (pImageImportDesc->Name)
|
||||
{
|
||||
PCSTR pszModuleName = MakePtr(PCSTR, pDOSHeader, pImageImportDesc->Name);
|
||||
if (_strcmpi(pszModuleName, "KERNEL32.DLL") == 0)
|
||||
{
|
||||
PIMAGE_THUNK_DATA pOriginalThunk = MakePtr(PIMAGE_THUNK_DATA, pDOSHeader, pImageImportDesc->OriginalFirstThunk);
|
||||
PIMAGE_THUNK_DATA pActualThink = MakePtr(PIMAGE_THUNK_DATA, pDOSHeader, pImageImportDesc->FirstThunk);
|
||||
while (pOriginalThunk->u1.Function)
|
||||
{
|
||||
if ((pOriginalThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) == 0)
|
||||
{
|
||||
PIMAGE_IMPORT_BY_NAME pImageImportByName = MakePtr(PIMAGE_IMPORT_BY_NAME, pDOSHeader, pOriginalThunk->u1.AddressOfData);
|
||||
PCSTR pszFunctionName = (PCSTR)pImageImportByName->Name;
|
||||
if (strcmp(pszFunctionName, "SetUnhandledExceptionFilter") == 0)
|
||||
{
|
||||
PFSetUnhandledExceptionFilter pfnCurrentSetUnhandledExceptionFilter = (PFSetUnhandledExceptionFilter)pActualThink->u1.Function;
|
||||
if (bOverride ? pfnCurrentSetUnhandledExceptionFilter != &DummySetUnhandledExceptionFilter : TRUE)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION MemBasicInfo;
|
||||
VirtualQuery(pActualThink, &MemBasicInfo, sizeof(MemBasicInfo));
|
||||
DWORD dwOldProtect;
|
||||
if (VirtualProtect(MemBasicInfo.BaseAddress, MemBasicInfo.RegionSize, PAGE_READWRITE, &dwOldProtect))
|
||||
{
|
||||
pActualThink->u1.Function = (DWORD_PTR)(bOverride ? &DummySetUnhandledExceptionFilter : pfnSavedSetUnhandledExceptionFilter);
|
||||
VirtualProtect(MemBasicInfo.BaseAddress, MemBasicInfo.RegionSize, MemBasicInfo.Protect, &dwOldProtect);
|
||||
if (bOverride)
|
||||
m_mapModuleEntries.SetAt(hModule, pfnCurrentSetUnhandledExceptionFilter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++pOriginalThunk;
|
||||
++pActualThink;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HMODULE hNestedModule = GetModuleHandleA(pszModuleName);
|
||||
if (hNestedModule != NULL)
|
||||
TraverseImportTables(hNestedModule, bOverride, nNestedLevel + 1);
|
||||
}
|
||||
++pImageImportDesc;
|
||||
}
|
||||
if (bCleanup)
|
||||
Clear();
|
||||
}
|
||||
113
third-party/BugTrap-1.3-57bd515/source/ModuleImportTable.h
vendored
Normal file
113
third-party/BugTrap-1.3-57bd515/source/ModuleImportTable.h
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Table of modules that import SetUnhandledExceptionFilter() function.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Hash.h"
|
||||
#include "Globals.h"
|
||||
|
||||
/// Type definition of pointer to SetUnhandledExceptionFilter() function.
|
||||
typedef PTOP_LEVEL_EXCEPTION_FILTER (WINAPI *PFSetUnhandledExceptionFilter)(PTOP_LEVEL_EXCEPTION_FILTER pTopLevelExceptionFilter);
|
||||
|
||||
/// Table of modules that import SetUnhandledExceptionFilter() function.
|
||||
class CModuleImportTable
|
||||
{
|
||||
public:
|
||||
/// Object constructor.
|
||||
CModuleImportTable(void);
|
||||
/// Object destructor.
|
||||
~CModuleImportTable(void);
|
||||
/// Override SetUnhandledExceptionFilter().
|
||||
void Override(HMODULE hModule);
|
||||
/// Restore original function pointers.
|
||||
void Restore(HMODULE hModule);
|
||||
/// Override/restore original function pointers.
|
||||
void Intercept(HMODULE hModule, BOOL bOverride);
|
||||
/// Free module entries.
|
||||
void Clear(void);
|
||||
/// Return original address of SetUnhandledExceptionFilter().
|
||||
PFSetUnhandledExceptionFilter GetOriginalProcAddress(void) const;
|
||||
|
||||
private:
|
||||
/// Protects object from being accidentally copied.
|
||||
CModuleImportTable(const CModuleImportTable& rModuleImportTable);
|
||||
/// Protects object from being accidentally copied.
|
||||
CModuleImportTable& operator=(const CModuleImportTable& rModuleImportTable);
|
||||
|
||||
/// Dummy version of SetUnhandledExceptionFilter().
|
||||
static PTOP_LEVEL_EXCEPTION_FILTER WINAPI DummySetUnhandledExceptionFilter(PTOP_LEVEL_EXCEPTION_FILTER pTopLevelExceptionFilter);
|
||||
|
||||
/// Traverse import tables recurrently and replace SetUnhandledExceptionFilter().
|
||||
void TraverseImportTables(HMODULE hModule, BOOL bOverride, size_t nNestedLevel);
|
||||
|
||||
/// Map of module entries.
|
||||
CHash<HMODULE, PFSetUnhandledExceptionFilter> m_mapModuleEntries;
|
||||
};
|
||||
|
||||
inline CModuleImportTable::CModuleImportTable(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline CModuleImportTable::~CModuleImportTable(void)
|
||||
{
|
||||
Restore(NULL);
|
||||
}
|
||||
|
||||
inline void CModuleImportTable::Clear(void)
|
||||
{
|
||||
m_mapModuleEntries.DeleteAll(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hModule - module handle.
|
||||
*/
|
||||
inline void CModuleImportTable::Override(HMODULE hModule)
|
||||
{
|
||||
TraverseImportTables(hModule, TRUE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hModule - module handle.
|
||||
*/
|
||||
inline void CModuleImportTable::Restore(HMODULE hModule)
|
||||
{
|
||||
TraverseImportTables(hModule, FALSE, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hModule - module handle.
|
||||
* @param bOverride - true if SetUnhandledExceptionFilter() must be overridden.
|
||||
*/
|
||||
inline void CModuleImportTable::Intercept(HMODULE hModule, BOOL bOverride)
|
||||
{
|
||||
TraverseImportTables(hModule, bOverride, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pTopLevelExceptionFilter - not used.
|
||||
* @return NULL pointer.
|
||||
*/
|
||||
inline PTOP_LEVEL_EXCEPTION_FILTER WINAPI CModuleImportTable::DummySetUnhandledExceptionFilter(PTOP_LEVEL_EXCEPTION_FILTER /*pTopLevelExceptionFilter*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return original address of SetUnhandledExceptionFilter().
|
||||
*/
|
||||
inline PFSetUnhandledExceptionFilter CModuleImportTable::GetOriginalProcAddress(void) const
|
||||
{
|
||||
const PFSetUnhandledExceptionFilter* ppfnSetUnhandledExceptionFilter = m_mapModuleEntries.Lookup(g_hInstance);
|
||||
return (ppfnSetUnhandledExceptionFilter != NULL ? *ppfnSetUnhandledExceptionFilter : &SetUnhandledExceptionFilter);
|
||||
}
|
||||
711
third-party/BugTrap-1.3-57bd515/source/NetThunks.cpp
vendored
Normal file
711
third-party/BugTrap-1.3-57bd515/source/NetThunks.cpp
vendored
Normal file
|
|
@ -0,0 +1,711 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Managed to unmanaged code thunks.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "NetThunks.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
#pragma managed /////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using namespace System::IO;
|
||||
using namespace System::Reflection;
|
||||
|
||||
namespace NetThunks
|
||||
{
|
||||
|
||||
void GetThreadInfo(gcroot<Thread^> gcThread, DWORD& dwThreadID, PWSTR pszThreadName, DWORD dwThreadNameSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread^ thread = gcThread;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(thread != nullptr);
|
||||
#endif
|
||||
dwThreadID = thread->ManagedThreadId;
|
||||
if (dwThreadNameSize > 0)
|
||||
{
|
||||
String^ threadName = thread->Name;
|
||||
if (threadName != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrThreadName(PtrToStringChars(threadName));
|
||||
wcsncpy_s(pszThreadName, dwThreadNameSize, wstrThreadName, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*pszThreadName = L'\0';
|
||||
}
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
dwThreadID = MAXDWORD;
|
||||
if (dwThreadNameSize > 0)
|
||||
*pszThreadName = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
void GetAppDomainInfo(DWORD& dwAppDomainID, PWSTR pszAppDomainName, DWORD dwAppDomainSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
AppDomain^ appDomain = AppDomain::CurrentDomain;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(appDomain != nullptr);
|
||||
#endif
|
||||
dwAppDomainID = appDomain->Id;
|
||||
if (dwAppDomainSize > 0)
|
||||
{
|
||||
String^ appDomainName = appDomain->FriendlyName;
|
||||
if (appDomainName != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrAppDomainName(PtrToStringChars(appDomainName));
|
||||
wcsncpy_s(pszAppDomainName, dwAppDomainSize, wstrAppDomainName, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*pszAppDomainName = L'\0';
|
||||
}
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
dwAppDomainID = MAXDWORD;
|
||||
if (dwAppDomainSize > 0)
|
||||
*pszAppDomainName = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
static String^ GetMethodSignature(MethodBase^ method, bool addType)
|
||||
{
|
||||
MemberTypes memberType = method->MemberType;
|
||||
if ((unsigned)(memberType & (MemberTypes::Constructor | MemberTypes::Method)) == 0)
|
||||
return nullptr;
|
||||
StringBuilder^ signature = gcnew StringBuilder();
|
||||
if ((unsigned)(memberType & MemberTypes::Method) != 0)
|
||||
{
|
||||
signature->Append((safe_cast<MethodInfo^>(method))->ReturnType);
|
||||
signature->Append(L' ');
|
||||
}
|
||||
if (addType)
|
||||
{
|
||||
Type^ type = method->DeclaringType;
|
||||
if (type != nullptr)
|
||||
{
|
||||
signature->Append(type);
|
||||
signature->Append(L'.');
|
||||
}
|
||||
}
|
||||
signature->Append(method->Name);
|
||||
signature->Append(L'(');
|
||||
array<ParameterInfo^>^ parameters = method->GetParameters();
|
||||
int count = parameters->Length;
|
||||
for (int index = 0; index < count; ++index)
|
||||
{
|
||||
ParameterInfo^ parameter = parameters[index];
|
||||
if (index > 0)
|
||||
signature->Append(L", ");
|
||||
signature->Append(parameter->ParameterType);
|
||||
String^ paramName = parameter->Name;
|
||||
if (paramName != nullptr)
|
||||
{
|
||||
signature->Append(L' ');
|
||||
signature->Append(paramName);
|
||||
}
|
||||
}
|
||||
signature->Append(L')');
|
||||
return signature->ToString();
|
||||
}
|
||||
|
||||
static void GetStackTraceEntry(StackFrame^ stackFrame, CNetStackTrace::CNetStackTraceEntry& rEntry)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(stackFrame != nullptr);
|
||||
#endif
|
||||
MethodBase^ method = stackFrame->GetMethod();
|
||||
Module^ module = method->Module;
|
||||
Assembly^ assembly = module->Assembly;
|
||||
AssemblyName^ assemblyName = assembly != nullptr ? assembly->GetName() : nullptr;
|
||||
String^ assemblyNameString = assemblyName != nullptr ? assemblyName->Name : nullptr;
|
||||
if (assemblyNameString != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrAssembly(PtrToStringChars(assemblyNameString));
|
||||
wcsncpy_s(rEntry.m_szAssembly, countof(rEntry.m_szAssembly), wstrAssembly, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rEntry.m_szAssembly = L'\0';
|
||||
int ilOffset = stackFrame->GetILOffset();
|
||||
if (ilOffset != StackFrame::OFFSET_UNKNOWN)
|
||||
_ui64tow_s(ilOffset, rEntry.m_szILOffset, countof(rEntry.m_szILOffset), 10);
|
||||
else
|
||||
*rEntry.m_szILOffset = L'\0';
|
||||
int nativeOffset = stackFrame->GetNativeOffset();
|
||||
if (nativeOffset != StackFrame::OFFSET_UNKNOWN)
|
||||
_ui64tow_s(nativeOffset, rEntry.m_szNativeOffset, countof(rEntry.m_szNativeOffset), 10);
|
||||
else
|
||||
*rEntry.m_szNativeOffset = L'\0';
|
||||
Type^ type = method->DeclaringType;
|
||||
if (type != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrType(PtrToStringChars(type->ToString()));
|
||||
wcsncpy_s(rEntry.m_szType, countof(rEntry.m_szType), wstrType, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rEntry.m_szType = L'\0';
|
||||
String^ shortMethodSignature = GetMethodSignature(method, false);
|
||||
if (shortMethodSignature != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrMethod(PtrToStringChars(shortMethodSignature));
|
||||
wcsncpy_s(rEntry.m_szMethod, countof(rEntry.m_szMethod), wstrMethod, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rEntry.m_szMethod = L'\0';
|
||||
String^ fullMethodSignature = GetMethodSignature(method, true);
|
||||
if (fullMethodSignature != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrMethodSignature(PtrToStringChars(fullMethodSignature));
|
||||
wcsncpy_s(rEntry.m_szMethodSignature, countof(rEntry.m_szMethodSignature), wstrMethodSignature, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rEntry.m_szMethodSignature = L'\0';
|
||||
String^ fileName = stackFrame->GetFileName();
|
||||
if (fileName != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrSourceFile(PtrToStringChars(fileName));
|
||||
wcsncpy_s(rEntry.m_szSourceFile, countof(rEntry.m_szSourceFile), wstrSourceFile, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rEntry.m_szSourceFile = L'\0';
|
||||
int lineNumber = stackFrame->GetFileLineNumber();
|
||||
if (lineNumber != 0)
|
||||
_ultow_s(lineNumber, rEntry.m_szLineNumber, countof(rEntry.m_szLineNumber));
|
||||
else
|
||||
*rEntry.m_szLineNumber = L'\0';
|
||||
int columnNumber = stackFrame->GetFileColumnNumber();
|
||||
if (columnNumber != 0)
|
||||
_ultow_s(columnNumber, rEntry.m_szColumnNumber, countof(rEntry.m_szColumnNumber));
|
||||
else
|
||||
*rEntry.m_szColumnNumber = L'\0';
|
||||
if (lineNumber != 0)
|
||||
{
|
||||
if (columnNumber != 0)
|
||||
swprintf_s(rEntry.m_szLineInfo, countof(rEntry.m_szLineInfo), L"line %lu, column %lu", lineNumber, columnNumber);
|
||||
else
|
||||
swprintf_s(rEntry.m_szLineInfo, countof(rEntry.m_szLineInfo), L"line %lu", lineNumber);
|
||||
}
|
||||
else
|
||||
*rEntry.m_szLineInfo = L'\0';
|
||||
}
|
||||
|
||||
gcroot<StackFrameEnumerator^> EnumStackFrames(void)
|
||||
{
|
||||
if (IsNetException())
|
||||
return EnumStackFrames(ExceptionHandler::Exception);
|
||||
else
|
||||
return EnumStackFrames(Thread::CurrentThread);
|
||||
}
|
||||
|
||||
gcroot<StackFrameEnumerator^> EnumStackFrames(gcroot<Exception^> exception)
|
||||
{
|
||||
StackFrameEnumerator^ stackFrameEnumerator = nullptr;
|
||||
try
|
||||
{
|
||||
stackFrameEnumerator = gcnew StackFrameEnumerator(exception);
|
||||
}
|
||||
catch (Exception^ exception2)
|
||||
{
|
||||
Debug::WriteLine(exception2);
|
||||
}
|
||||
return gcroot<StackFrameEnumerator^>(stackFrameEnumerator);
|
||||
}
|
||||
|
||||
gcroot<StackFrameEnumerator^> EnumStackFrames(gcroot<Thread^> thread)
|
||||
{
|
||||
StackFrameEnumerator^ stackFrameEnumerator = nullptr;
|
||||
try
|
||||
{
|
||||
stackFrameEnumerator = gcnew StackFrameEnumerator(thread);
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
}
|
||||
return gcroot<StackFrameEnumerator^>(stackFrameEnumerator);
|
||||
}
|
||||
|
||||
void InitStackTrace(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator)
|
||||
{
|
||||
StackFrameEnumerator^ stackFrameEnumerator = gcStackFrameEnumerator;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(stackFrameEnumerator != nullptr);
|
||||
#endif
|
||||
stackFrameEnumerator->InitStackTrace();
|
||||
}
|
||||
|
||||
bool GetFirstStackTraceEntry(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator, CNetStackTrace::CNetStackTraceEntry& rEntry)
|
||||
{
|
||||
InitStackTrace(gcStackFrameEnumerator);
|
||||
return GetNextStackTraceEntry(gcStackFrameEnumerator, rEntry);
|
||||
}
|
||||
|
||||
bool GetNextStackTraceEntry(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator, CNetStackTrace::CNetStackTraceEntry& rEntry)
|
||||
{
|
||||
try
|
||||
{
|
||||
StackFrameEnumerator^ stackFrameEnumerator = gcStackFrameEnumerator;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(stackFrameEnumerator != nullptr);
|
||||
#endif
|
||||
StackFrame^ stackFrame = stackFrameEnumerator->GetNextStackTraceEntry();
|
||||
if (stackFrame == nullptr)
|
||||
return false;
|
||||
GetStackTraceEntry(stackFrame, rEntry);
|
||||
return true;
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool GetErrorInfo(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator, CNetStackTrace::CNetErrorInfo& rErrorInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (! GetFirstStackTraceEntry(gcStackFrameEnumerator, rErrorInfo))
|
||||
return false;
|
||||
StackFrameEnumerator^ stackFrameEnumerator = gcStackFrameEnumerator;
|
||||
Exception^ exception = stackFrameEnumerator->Exception;
|
||||
if (exception == nullptr)
|
||||
exception = ExceptionHandler::Exception;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(exception != nullptr);
|
||||
#endif
|
||||
Type^ type = exception->GetType();
|
||||
pin_ptr<const wchar_t> wstrException(PtrToStringChars(type->Name));
|
||||
wcsncpy_s(rErrorInfo.m_szException, countof(rErrorInfo.m_szException), wstrException, _TRUNCATE);
|
||||
String^ message = exception->Message;
|
||||
if (message != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrMessage(PtrToStringChars(message));
|
||||
wcsncpy_s(rErrorInfo.m_szMessage, countof(rErrorInfo.m_szMessage), wstrMessage, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rErrorInfo.m_szMessage = L'\0';
|
||||
Process^ process = Process::GetCurrentProcess();
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(process != nullptr);
|
||||
#endif
|
||||
_ultow_s(process->Id, rErrorInfo.m_szProcessID, countof(rErrorInfo.m_szProcessID));
|
||||
//String^ processName = process->ProcessName;
|
||||
String^ processName = Path::GetFileName(process->MainModule->ModuleName);
|
||||
if (processName != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrProcessName(PtrToStringChars(processName));
|
||||
wcsncpy_s(rErrorInfo.m_szProcessName, countof(rErrorInfo.m_szProcessName), wstrProcessName, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rErrorInfo.m_szProcessName = L'\0';
|
||||
AppDomain^ appDomain = AppDomain::CurrentDomain;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(appDomain != nullptr);
|
||||
#endif
|
||||
String^ appDomainName = appDomain->FriendlyName;
|
||||
if (appDomainName != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrAppDomainName(PtrToStringChars(appDomainName));
|
||||
wcsncpy_s(rErrorInfo.m_szAppDomainName, countof(rErrorInfo.m_szAppDomainName), wstrAppDomainName, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rErrorInfo.m_szAppDomainName = L'\0';
|
||||
_ultow_s(appDomain->Id, rErrorInfo.m_szAppDomainID, countof(rErrorInfo.m_szAppDomainID));
|
||||
return true;
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void GetNetVersion(PWSTR pszNetVersion, DWORD dwNetVersionSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dwNetVersionSize > 0)
|
||||
{
|
||||
Version^ version = Environment::Version;
|
||||
if (version != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrNetVersion(PtrToStringChars(version->ToString()));
|
||||
wcsncpy_s(pszNetVersion, dwNetVersionSize, wstrNetVersion, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*pszNetVersion = L'\0';
|
||||
}
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
if (dwNetVersionSize > 0)
|
||||
*pszNetVersion = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
gcroot<AssemblyEnumerator^> EnumAssemblies(void)
|
||||
{
|
||||
AssemblyEnumerator^ assemblyEnumerator = nullptr;
|
||||
try
|
||||
{
|
||||
assemblyEnumerator = gcnew AssemblyEnumerator();
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
}
|
||||
return gcroot<AssemblyEnumerator^>(assemblyEnumerator);
|
||||
}
|
||||
|
||||
static void GetAssemblyInfo(Assembly^ assembly, CNetAssemblies::CAssemblyInfo& rAssemblyInfo)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(assembly != nullptr);
|
||||
#endif
|
||||
AssemblyName^ assemblyName = assembly->GetName();
|
||||
String^ assemblyNameString = assemblyName != nullptr ? assemblyName->Name : nullptr;
|
||||
if (assemblyNameString != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrAssemblyName(PtrToStringChars(assemblyNameString));
|
||||
wcsncpy_s(rAssemblyInfo.m_szName, countof(rAssemblyInfo.m_szName), wstrAssemblyName, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rAssemblyInfo.m_szName = L'\0';
|
||||
Version^ version = assemblyName != nullptr ? assemblyName->Version : nullptr;
|
||||
if (version != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrAssemblyVersion(PtrToStringChars(version->ToString()));
|
||||
wcsncpy_s(rAssemblyInfo.m_szVersion, countof(rAssemblyInfo.m_szVersion), wstrAssemblyVersion, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rAssemblyInfo.m_szVersion = L'\0';
|
||||
String^ location;
|
||||
try
|
||||
{
|
||||
location = assembly->Location;
|
||||
}
|
||||
catch (NotSupportedException^)
|
||||
{
|
||||
location = nullptr;
|
||||
}
|
||||
FileVersionInfo^ fileVersion = String::IsNullOrEmpty(location) ? nullptr : FileVersionInfo::GetVersionInfo(location);
|
||||
String^ fileVersionString = fileVersion != nullptr ? fileVersion->FileVersion : nullptr;
|
||||
if (fileVersionString != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrFileVersion(PtrToStringChars(fileVersionString));
|
||||
wcsncpy_s(rAssemblyInfo.m_szFileVersion, countof(rAssemblyInfo.m_szFileVersion), wstrFileVersion, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rAssemblyInfo.m_szFileVersion = L'\0';
|
||||
String^ codeBase = assemblyName->CodeBase;
|
||||
if (codeBase != nullptr)
|
||||
{
|
||||
pin_ptr<const wchar_t> wstrCodeBase(PtrToStringChars(codeBase));
|
||||
wcsncpy_s(rAssemblyInfo.m_szCodeBase, countof(rAssemblyInfo.m_szCodeBase), wstrCodeBase, _TRUNCATE);
|
||||
}
|
||||
else
|
||||
*rAssemblyInfo.m_szCodeBase = L'\0';
|
||||
}
|
||||
|
||||
void InitAssemblies(gcroot<AssemblyEnumerator^> gcAssemblyEnumerator)
|
||||
{
|
||||
AssemblyEnumerator^ assemblyEnumerator = gcAssemblyEnumerator;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(assemblyEnumerator != nullptr);
|
||||
#endif
|
||||
assemblyEnumerator->InitAssemblies();
|
||||
}
|
||||
|
||||
bool GetFirstAssembly(gcroot<AssemblyEnumerator^> gcAssemblyEnumerator, CNetAssemblies::CAssemblyInfo& rAssemblyInfo)
|
||||
{
|
||||
InitAssemblies(gcAssemblyEnumerator);
|
||||
return GetNextAssembly(gcAssemblyEnumerator, rAssemblyInfo);
|
||||
}
|
||||
|
||||
bool GetNextAssembly(gcroot<AssemblyEnumerator^> gcAssemblyEnumerator, CNetAssemblies::CAssemblyInfo& rAssemblyInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
AssemblyEnumerator^ assemblyEnumerator = gcAssemblyEnumerator;
|
||||
#ifdef _DEBUG
|
||||
Debug::Assert(assemblyEnumerator != nullptr);
|
||||
#endif
|
||||
Assembly^ assembly = assemblyEnumerator->GetNextAssembly();
|
||||
if (assembly == nullptr)
|
||||
return false;
|
||||
GetAssemblyInfo(assembly, rAssemblyInfo);
|
||||
return true;
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ReadVersionInfo(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExceptionHandler::ReadVersionInfo();
|
||||
return true;
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void FireBeforeUnhandledExceptionEvent(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExceptionHandler::FireBeforeUnhandledExceptionEvent();
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
}
|
||||
}
|
||||
|
||||
void FireAfterUnhandledExceptionEvent(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExceptionHandler::FireAfterUnhandledExceptionEvent();
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
}
|
||||
}
|
||||
|
||||
void FlushTraceListeners(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
Trace::Close();
|
||||
Trace::Listeners->Clear();
|
||||
Debug::Close();
|
||||
Debug::Listeners->Clear();
|
||||
Debug::Listeners->Add(gcnew DefaultTraceListener());
|
||||
}
|
||||
catch (Exception^ exception)
|
||||
{
|
||||
Debug::WriteLine(exception);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNull(gcroot<Exception^> gcObject)
|
||||
{
|
||||
Exception^ object = gcObject;
|
||||
return (object == nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma unmanaged ///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CNetStackTrace::CNetStackTraceEntry::CNetStackTraceEntry(void)
|
||||
{
|
||||
*m_szAssembly = L'\0';
|
||||
*m_szILOffset = L'\0';
|
||||
*m_szNativeOffset = L'\0';
|
||||
*m_szType = L'\0';
|
||||
*m_szMethod = L'\0';
|
||||
*m_szMethodSignature = L'\0';
|
||||
*m_szSourceFile = L'\0';
|
||||
*m_szLineNumber = L'\0';
|
||||
*m_szColumnNumber = L'\0';
|
||||
*m_szLineInfo = L'\0';
|
||||
}
|
||||
|
||||
CNetStackTrace::CNetErrorInfo::CNetErrorInfo(void)
|
||||
{
|
||||
*m_szException = L'\0';
|
||||
*m_szMessage = L'\0';
|
||||
*m_szAppDomainName = L'\0';
|
||||
*m_szAppDomainID = L'\0';
|
||||
*m_szProcessName = L'\0';
|
||||
*m_szProcessID = L'\0';
|
||||
}
|
||||
|
||||
void CNetStackTrace::GetStackTraceString(const CNetStackTraceEntry& rEntry, CUTF8EncStream& rEncStream)
|
||||
{
|
||||
if (*rEntry.m_szAssembly)
|
||||
{
|
||||
rEncStream.WriteByte('\"');
|
||||
rEncStream.WriteUTF8Bin(rEntry.m_szAssembly);
|
||||
rEncStream.WriteByte('\"');
|
||||
}
|
||||
|
||||
if (*rEntry.m_szILOffset || *rEntry.m_szNativeOffset)
|
||||
{
|
||||
rEncStream.WriteAscii(" at");
|
||||
if (*rEntry.m_szILOffset)
|
||||
{
|
||||
rEncStream.WriteAscii(" IL:");
|
||||
rEncStream.WriteUTF8Bin(rEntry.m_szILOffset);
|
||||
}
|
||||
|
||||
if (*rEntry.m_szNativeOffset)
|
||||
{
|
||||
if (*rEntry.m_szILOffset)
|
||||
rEncStream.WriteByte(',');
|
||||
rEncStream.WriteAscii(" NATIVE:");
|
||||
rEncStream.WriteUTF8Bin(rEntry.m_szNativeOffset);
|
||||
}
|
||||
}
|
||||
|
||||
if (*rEntry.m_szMethodSignature)
|
||||
{
|
||||
rEncStream.WriteAscii(", ");
|
||||
rEncStream.WriteUTF8Bin(rEntry.m_szMethodSignature);
|
||||
}
|
||||
|
||||
if (*rEntry.m_szSourceFile)
|
||||
{
|
||||
rEncStream.WriteAscii(" in \"");
|
||||
rEncStream.WriteUTF8Bin(rEntry.m_szSourceFile);
|
||||
rEncStream.WriteByte('\"');
|
||||
}
|
||||
|
||||
if (*rEntry.m_szLineInfo)
|
||||
{
|
||||
rEncStream.WriteAscii(", ");
|
||||
rEncStream.WriteUTF8Bin(rEntry.m_szLineInfo);
|
||||
}
|
||||
}
|
||||
|
||||
bool CNetStackTrace::GetFirstStackTraceString(CUTF8EncStream& rEncStream)
|
||||
{
|
||||
InitStackTrace();
|
||||
return GetNextStackTraceString(rEncStream);
|
||||
}
|
||||
|
||||
bool CNetStackTrace::GetNextStackTraceString(CUTF8EncStream& rEncStream)
|
||||
{
|
||||
CNetStackTraceEntry Entry;
|
||||
if (! GetNextStackTraceEntry(Entry))
|
||||
return false;
|
||||
GetStackTraceString(Entry, rEncStream);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CNetStackTrace::GetErrorString(CStrStream& rStream)
|
||||
{
|
||||
CNetErrorInfo ErrorInfo;
|
||||
if (! GetErrorInfo(ErrorInfo))
|
||||
{
|
||||
rStream << L"Error information is not available";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*ErrorInfo.m_szAppDomainName && _wcsicmp(ErrorInfo.m_szAppDomainName, ErrorInfo.m_szProcessName) != 0)
|
||||
{
|
||||
rStream << L"domain ";
|
||||
rStream << ErrorInfo.m_szAppDomainName;
|
||||
rStream << L" of ";
|
||||
}
|
||||
|
||||
rStream << ErrorInfo.m_szProcessName;
|
||||
rStream << L" caused ";
|
||||
rStream << ErrorInfo.m_szException;
|
||||
|
||||
const WCHAR wszStandardExceptionPrefix[] = L"Exception of type ";
|
||||
const DWORD dwStandardExceptionPrefixLength = countof(wszStandardExceptionPrefix) - 1;
|
||||
if (*ErrorInfo.m_szMessage && wcsncmp(ErrorInfo.m_szMessage, wszStandardExceptionPrefix, dwStandardExceptionPrefixLength) != 0)
|
||||
{
|
||||
rStream << L" (";
|
||||
rStream << ErrorInfo.m_szMessage;
|
||||
rStream << L')';
|
||||
}
|
||||
|
||||
if (*ErrorInfo.m_szAssembly)
|
||||
{
|
||||
rStream << L" in assembly \"";
|
||||
rStream << ErrorInfo.m_szAssembly;
|
||||
rStream << L'\"';
|
||||
}
|
||||
|
||||
if (*ErrorInfo.m_szILOffset || *ErrorInfo.m_szNativeOffset)
|
||||
{
|
||||
rStream << L" at";
|
||||
if (*ErrorInfo.m_szILOffset)
|
||||
{
|
||||
rStream << L" IL:";
|
||||
rStream << ErrorInfo.m_szILOffset;
|
||||
}
|
||||
|
||||
if (*ErrorInfo.m_szNativeOffset)
|
||||
{
|
||||
if (*ErrorInfo.m_szILOffset)
|
||||
rStream << L',';
|
||||
rStream << L" NATIVE:";
|
||||
rStream << ErrorInfo.m_szNativeOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (*ErrorInfo.m_szMethodSignature)
|
||||
{
|
||||
rStream << _T(", ");
|
||||
rStream << ErrorInfo.m_szMethodSignature;
|
||||
}
|
||||
|
||||
if (*ErrorInfo.m_szSourceFile)
|
||||
{
|
||||
rStream << L" in \"";
|
||||
rStream << ErrorInfo.m_szSourceFile;
|
||||
rStream << L'\"';
|
||||
|
||||
if (*ErrorInfo.m_szLineInfo)
|
||||
{
|
||||
rStream << L", ";
|
||||
rStream << ErrorInfo.m_szLineInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CNetStackTrace::GetErrorString(CUTF8EncStream& rEncStream)
|
||||
{
|
||||
CStrStream Stream(1024);
|
||||
bool bResult = GetErrorString(Stream);
|
||||
rEncStream.WriteUTF8Bin(Stream);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
CNetAssemblies::CAssemblyInfo::CAssemblyInfo(void)
|
||||
{
|
||||
*m_szName = L'\0';
|
||||
*m_szVersion = L'\0';
|
||||
*m_szFileVersion = L'\0';
|
||||
*m_szCodeBase = L'\0';
|
||||
}
|
||||
|
||||
#endif // _MANAGED
|
||||
232
third-party/BugTrap-1.3-57bd515/source/NetThunks.h
vendored
Normal file
232
third-party/BugTrap-1.3-57bd515/source/NetThunks.h
vendored
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Managed to unmanaged code thunks.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
#include "Encoding.h"
|
||||
#include "SymEngineNet.h"
|
||||
|
||||
using namespace IntelleSoft::BugTrap;
|
||||
|
||||
class CNetStackTrace
|
||||
{
|
||||
public:
|
||||
struct CNetStackTraceEntry
|
||||
{
|
||||
CNetStackTraceEntry(void);
|
||||
WCHAR m_szAssembly[MAX_PATH];
|
||||
WCHAR m_szILOffset[32];
|
||||
WCHAR m_szNativeOffset[32];
|
||||
WCHAR m_szType[256];
|
||||
WCHAR m_szMethod[256];
|
||||
WCHAR m_szMethodSignature[256];
|
||||
WCHAR m_szSourceFile[MAX_PATH];
|
||||
WCHAR m_szLineNumber[16];
|
||||
WCHAR m_szColumnNumber[16];
|
||||
WCHAR m_szLineInfo[64];
|
||||
};
|
||||
|
||||
struct CNetErrorInfo : public CNetStackTraceEntry
|
||||
{
|
||||
CNetErrorInfo(void);
|
||||
WCHAR m_szException[128];
|
||||
WCHAR m_szMessage[256];
|
||||
WCHAR m_szAppDomainName[MAX_PATH];
|
||||
WCHAR m_szAppDomainID[16];
|
||||
WCHAR m_szProcessName[MAX_PATH];
|
||||
WCHAR m_szProcessID[16];
|
||||
};
|
||||
|
||||
CNetStackTrace(void);
|
||||
CNetStackTrace(gcroot<Exception^> exception);
|
||||
CNetStackTrace(gcroot<Thread^> thread);
|
||||
void InitStackTrace(void);
|
||||
bool GetFirstStackTraceEntry(CNetStackTraceEntry& rEntry);
|
||||
bool GetNextStackTraceEntry(CNetStackTraceEntry& rEntry);
|
||||
bool GetFirstStackTraceString(CUTF8EncStream& rEncStream);
|
||||
bool GetNextStackTraceString(CUTF8EncStream& rEncStream);
|
||||
bool GetErrorInfo(CNetErrorInfo& rErrorInfo);
|
||||
bool GetErrorString(CStrStream& rStream);
|
||||
bool GetErrorString(CUTF8EncStream& rEncStream);
|
||||
|
||||
private:
|
||||
CNetStackTrace(const CNetStackTrace& rStackTrace);
|
||||
CNetStackTrace& operator=(const CNetStackTrace& rStackTrace);
|
||||
void GetStackTraceString(const CNetStackTraceEntry& rEntry, CUTF8EncStream& rEncStream);
|
||||
|
||||
gcroot<StackFrameEnumerator^> m_gcStackFrameEnumerator;
|
||||
gcroot<Exception^> m_gcException;
|
||||
};
|
||||
|
||||
class CNetAssemblies
|
||||
{
|
||||
public:
|
||||
struct CAssemblyInfo
|
||||
{
|
||||
CAssemblyInfo(void);
|
||||
WCHAR m_szName[MAX_PATH];
|
||||
WCHAR m_szVersion[64];
|
||||
WCHAR m_szFileVersion[64];
|
||||
WCHAR m_szCodeBase[MAX_PATH];
|
||||
};
|
||||
|
||||
CNetAssemblies(void);
|
||||
void InitAssemblies(void);
|
||||
bool GetFirstAssembly(CNetAssemblies::CAssemblyInfo& rAssemblyInfo);
|
||||
bool GetNextAssembly(CNetAssemblies::CAssemblyInfo& rAssemblyInfo);
|
||||
|
||||
private:
|
||||
gcroot<AssemblyEnumerator^> m_gcAssemblyEnumerator;
|
||||
};
|
||||
|
||||
#pragma managed /////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace NetThunks
|
||||
{
|
||||
|
||||
inline bool IsNetException(void)
|
||||
{
|
||||
return (ExceptionHandler::Exception != nullptr);
|
||||
}
|
||||
|
||||
inline gcroot<Exception^> GetNetException(void)
|
||||
{
|
||||
return ExceptionHandler::Exception;
|
||||
}
|
||||
|
||||
void GetThreadInfo(gcroot<Thread^> gcThread, DWORD& dwThreadID, PWSTR pszThreadName, DWORD dwThreadNameSize);
|
||||
|
||||
void GetAppDomainInfo(DWORD& dwAppDomainID, PWSTR pszAppDomainName, DWORD dwAppDomainSize);
|
||||
|
||||
inline void GetThreadInfo(DWORD& dwThreadID, PWSTR pszThreadName, DWORD dwThreadNameSize)
|
||||
{
|
||||
GetThreadInfo(Thread::CurrentThread, dwThreadID, pszThreadName, dwThreadNameSize);
|
||||
}
|
||||
|
||||
gcroot<StackFrameEnumerator^> EnumStackFrames(void);
|
||||
|
||||
gcroot<StackFrameEnumerator^> EnumStackFrames(gcroot<Exception^> exception);
|
||||
|
||||
gcroot<StackFrameEnumerator^> EnumStackFrames(gcroot<Thread^> thread);
|
||||
|
||||
void InitStackTrace(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator);
|
||||
|
||||
bool GetFirstStackTraceEntry(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator, CNetStackTrace::CNetStackTraceEntry& rEntry);
|
||||
|
||||
bool GetNextStackTraceEntry(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator, CNetStackTrace::CNetStackTraceEntry& rEntry);
|
||||
|
||||
bool GetErrorInfo(gcroot<StackFrameEnumerator^> gcStackFrameEnumerator, CNetStackTrace::CNetErrorInfo& rErrorInfo);
|
||||
|
||||
void GetNetVersion(PWSTR pszNetVersion, DWORD dwNetVersionSize);
|
||||
|
||||
gcroot<AssemblyEnumerator^> EnumAssemblies(void);
|
||||
|
||||
void InitAssemblies(gcroot<AssemblyEnumerator^> gcAssemblyEnumerator);
|
||||
|
||||
bool GetFirstAssembly(gcroot<AssemblyEnumerator^> gcAssemblyEnumerator, CNetAssemblies::CAssemblyInfo& rAssemblyInfo);
|
||||
|
||||
bool GetNextAssembly(gcroot<AssemblyEnumerator^> gcAssemblyEnumerator, CNetAssemblies::CAssemblyInfo& rAssemblyInfo);
|
||||
|
||||
bool ReadVersionInfo(void);
|
||||
|
||||
void FireBeforeUnhandledExceptionEvent(void);
|
||||
|
||||
void FireAfterUnhandledExceptionEvent(void);
|
||||
|
||||
void FlushTraceListeners(void);
|
||||
|
||||
inline gcroot<Thread^> GetCurrentThread(void)
|
||||
{
|
||||
return gcroot<Thread^>(Thread::CurrentThread);
|
||||
}
|
||||
|
||||
inline gcroot<Exception^> GetInnerException(gcroot<Exception^> gcException)
|
||||
{
|
||||
Exception^ exception = gcException;
|
||||
return gcroot<Exception^>(exception->InnerException);
|
||||
}
|
||||
|
||||
#if 0
|
||||
template<class T> inline bool IsNull(gcroot<T^> gcObject)
|
||||
{
|
||||
T^ object = gcObject;
|
||||
return (object == nullptr);
|
||||
}
|
||||
#else
|
||||
bool IsNull(gcroot<Exception^> gcObject);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#pragma unmanaged ///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline CNetStackTrace::CNetStackTrace(void) :
|
||||
m_gcStackFrameEnumerator(NetThunks::EnumStackFrames())
|
||||
{
|
||||
}
|
||||
|
||||
inline CNetStackTrace::CNetStackTrace(gcroot<Exception^> exception) :
|
||||
m_gcStackFrameEnumerator(NetThunks::EnumStackFrames(exception)),
|
||||
m_gcException(exception)
|
||||
{
|
||||
}
|
||||
|
||||
inline CNetStackTrace::CNetStackTrace(gcroot<Thread^> thread) :
|
||||
m_gcStackFrameEnumerator(NetThunks::EnumStackFrames(thread))
|
||||
{
|
||||
}
|
||||
|
||||
inline void CNetStackTrace::InitStackTrace(void)
|
||||
{
|
||||
NetThunks::InitStackTrace(m_gcStackFrameEnumerator);
|
||||
}
|
||||
|
||||
inline bool CNetStackTrace::GetFirstStackTraceEntry(CNetStackTraceEntry& rEntry)
|
||||
{
|
||||
return NetThunks::GetFirstStackTraceEntry(m_gcStackFrameEnumerator, rEntry);
|
||||
}
|
||||
|
||||
inline bool CNetStackTrace::GetNextStackTraceEntry(CNetStackTraceEntry& rEntry)
|
||||
{
|
||||
return NetThunks::GetNextStackTraceEntry(m_gcStackFrameEnumerator, rEntry);
|
||||
}
|
||||
|
||||
inline bool CNetStackTrace::GetErrorInfo(CNetErrorInfo& rErrorInfo)
|
||||
{
|
||||
return NetThunks::GetErrorInfo(m_gcStackFrameEnumerator, rErrorInfo);
|
||||
}
|
||||
|
||||
inline CNetAssemblies::CNetAssemblies(void) :
|
||||
m_gcAssemblyEnumerator(NetThunks::EnumAssemblies())
|
||||
{
|
||||
}
|
||||
|
||||
inline void CNetAssemblies::InitAssemblies(void)
|
||||
{
|
||||
NetThunks::InitAssemblies(m_gcAssemblyEnumerator);
|
||||
}
|
||||
|
||||
inline bool CNetAssemblies::GetFirstAssembly(CNetAssemblies::CAssemblyInfo& rAssemblyInfo)
|
||||
{
|
||||
return NetThunks::GetFirstAssembly(m_gcAssemblyEnumerator, rAssemblyInfo);
|
||||
}
|
||||
|
||||
inline bool CNetAssemblies::GetNextAssembly(CNetAssemblies::CAssemblyInfo& rAssemblyInfo)
|
||||
{
|
||||
return NetThunks::GetNextAssembly(m_gcAssemblyEnumerator, rAssemblyInfo);
|
||||
}
|
||||
|
||||
#endif // _MANAGED
|
||||
189
third-party/BugTrap-1.3-57bd515/source/ResManager.cpp
vendored
Normal file
189
third-party/BugTrap-1.3-57bd515/source/ResManager.cpp
vendored
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Custom resources manager.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "ResManager.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#define FIXED_FONT_HEIGHT 90
|
||||
#define DIALOG_FONT_HEIGHT 60
|
||||
|
||||
/**
|
||||
* @addtogroup ResManager Custom resource manager.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param hwndParent - parent window handle.
|
||||
*/
|
||||
CResManager::CResManager(HWND hwndParent)
|
||||
{
|
||||
ZeroMemory(this, sizeof(*this));
|
||||
|
||||
HDC hDisplayDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
|
||||
if (hDisplayDC == NULL)
|
||||
return;
|
||||
LONG lLogPixelsY = GetDeviceCaps(hDisplayDC, LOGPIXELSY);
|
||||
|
||||
LOGFONT lf;
|
||||
ZeroMemory(&lf, sizeof(lf));
|
||||
lf.lfHeight = -MulDiv(FIXED_FONT_HEIGHT, lLogPixelsY, 720);
|
||||
lf.lfWeight = FW_NORMAL;
|
||||
lf.lfCharSet = ANSI_CHARSET;
|
||||
lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
|
||||
_tcscpy_s(lf.lfFaceName, countof(lf.lfFaceName), _T("Courier New"));
|
||||
m_hFixedFont = CreateFontIndirect(&lf);
|
||||
|
||||
ZeroMemory(&lf, sizeof(lf));
|
||||
lf.lfHeight = -MulDiv(DIALOG_FONT_HEIGHT, lLogPixelsY, 720);
|
||||
lf.lfWeight = FW_NORMAL;
|
||||
lf.lfCharSet = ANSI_CHARSET;
|
||||
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
|
||||
lf.lfUnderline = TRUE;
|
||||
_tcscpy_s(lf.lfFaceName, countof(lf.lfFaceName), _T("MS Sans Serif"));
|
||||
m_hUnderlinedFont = CreateFontIndirect(&lf);
|
||||
|
||||
ZeroMemory(&lf, sizeof(lf));
|
||||
lf.lfHeight = -MulDiv(DIALOG_FONT_HEIGHT, lLogPixelsY, 720);
|
||||
lf.lfWeight = FW_NORMAL;
|
||||
lf.lfCharSet = ANSI_CHARSET;
|
||||
lf.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
|
||||
_tcscpy_s(lf.lfFaceName, countof(lf.lfFaceName), _T("MS Sans Serif"));
|
||||
m_hDialogFont = CreateFontIndirect(&lf);
|
||||
|
||||
m_hHandCursor = LoadCursor(NULL, IDC_HAND);
|
||||
if (! m_hHandCursor)
|
||||
{
|
||||
// Thanks to Paul DiLascia.
|
||||
TCHAR szWinHelpPath[MAX_PATH];
|
||||
GetWindowsDirectory(szWinHelpPath, countof(szWinHelpPath));
|
||||
PathAppend(szWinHelpPath, _T("winhlp32.exe"));
|
||||
HMODULE hWinHelp = LoadLibrary(szWinHelpPath);
|
||||
if (hWinHelp)
|
||||
{
|
||||
HCURSOR hHandCursor = LoadCursor(hWinHelp, MAKEINTRESOURCE(106));
|
||||
if (hHandCursor)
|
||||
m_hHandCursor = CopyCursor(hHandCursor);
|
||||
FreeLibrary(hWinHelp);
|
||||
}
|
||||
}
|
||||
m_hArrowCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
m_hAppStartingCursor = LoadCursor(NULL, IDC_APPSTARTING);
|
||||
m_hWaitCursor = LoadCursor(NULL, IDC_WAIT);
|
||||
m_hUpDownCursor = LoadCursor(NULL, IDC_SIZENS);
|
||||
m_hLeftRightCursor = LoadCursor(NULL, IDC_SIZEWE);
|
||||
m_hIBeamCursor = LoadCursor(NULL, IDC_IBEAM);
|
||||
|
||||
m_hbrWindowBrush = GetSysColorBrush(COLOR_WINDOW);
|
||||
m_hbrButtonFaceBrush = GetSysColorBrush(COLOR_BTNFACE);
|
||||
m_hbrControlLight = GetSysColorBrush(COLOR_BTNHIGHLIGHT);
|
||||
m_hbrAppWorkspace = GetSysColorBrush(COLOR_APPWORKSPACE);
|
||||
|
||||
m_bDestroyBigAppIcon = false;
|
||||
m_bDestroySmallAppIcon = false;
|
||||
if (hwndParent != NULL)
|
||||
{
|
||||
__try {
|
||||
DWORD_PTR dwResult;
|
||||
if (SendMessageTimeout(hwndParent, WM_GETICON, ICON_BIG, 0l, SMTO_ABORTIFHUNG, SEND_MSG_TIMEOUT, &dwResult))
|
||||
m_hBigAppIcon = (HICON)dwResult;
|
||||
else
|
||||
m_hBigAppIcon = NULL;
|
||||
if (m_hBigAppIcon == NULL)
|
||||
m_hBigAppIcon = (HICON)GetClassLongPtr(hwndParent, GCLP_HICON);
|
||||
if (SendMessageTimeout(hwndParent, WM_GETICON, ICON_SMALL, 0l, SMTO_ABORTIFHUNG, SEND_MSG_TIMEOUT, &dwResult))
|
||||
m_hSmallAppIcon = (HICON)dwResult;
|
||||
else
|
||||
m_hSmallAppIcon = NULL;
|
||||
if (m_hSmallAppIcon == NULL)
|
||||
m_hSmallAppIcon = (HICON)GetClassLongPtr(hwndParent, GCLP_HICONSM);
|
||||
} __except (EXCEPTION_EXECUTE_HANDLER) {
|
||||
// ignore any exception in broken app...
|
||||
m_hBigAppIcon = NULL;
|
||||
m_hSmallAppIcon = NULL;
|
||||
}
|
||||
}
|
||||
int nCXSmallIcon = GetSystemMetrics(SM_CXSMICON);
|
||||
int nCYSmallIcon = GetSystemMetrics(SM_CYSMICON);
|
||||
if (m_hSmallAppIcon == NULL)
|
||||
{
|
||||
m_bDestroySmallAppIcon = true;;
|
||||
m_hSmallAppIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_BUG), IMAGE_ICON, nCXSmallIcon, nCYSmallIcon, LR_DEFAULTCOLOR);
|
||||
}
|
||||
int nCXIcon = GetSystemMetrics(SM_CXICON);
|
||||
int nCYIcon = GetSystemMetrics(SM_CYICON);
|
||||
if (m_hBigAppIcon == NULL)
|
||||
{
|
||||
m_bDestroyBigAppIcon = true;;
|
||||
m_hBigAppIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_BUG), IMAGE_ICON, nCXIcon, nCYIcon, LR_DEFAULTCOLOR);
|
||||
}
|
||||
if (m_hBigAppIcon != NULL)
|
||||
{
|
||||
m_hDialogIcon = CreateCompatibleBitmap(hDisplayDC, nCXIcon, nCYIcon);
|
||||
if (m_hDialogIcon != NULL)
|
||||
{
|
||||
HDC hMemDC = CreateCompatibleDC(hDisplayDC);
|
||||
if (hMemDC != NULL)
|
||||
{
|
||||
HBITMAP hbmpSafeBitmap = SelectBitmap(hMemDC, m_hDialogIcon);
|
||||
HBRUSH hbrSafeBrush = SelectBrush(hMemDC, m_hbrWindowBrush);
|
||||
PatBlt(hMemDC, 0, 0, nCXIcon, nCYIcon, PATCOPY);
|
||||
DrawIconEx(hMemDC, 0, 0, m_hBigAppIcon, nCXIcon, nCYIcon, 0, NULL, DI_NORMAL);
|
||||
SelectBrush(hMemDC, hbrSafeBrush);
|
||||
SelectBitmap(hMemDC, hbmpSafeBitmap);
|
||||
DeleteDC(hMemDC);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_hCheckMark = (HBITMAP)LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_CHECKMARK), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
|
||||
m_hSortArrows = ImageList_LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_SORTARROWS), 7, 0, RGB(0xFF, 0x00, 0xFF), IMAGE_BITMAP, LR_LOADMAP3DCOLORS);
|
||||
|
||||
DeleteDC(hDisplayDC);
|
||||
}
|
||||
|
||||
CResManager::~CResManager(void)
|
||||
{
|
||||
if (m_hFixedFont)
|
||||
DeleteFont(m_hFixedFont);
|
||||
if (m_hUnderlinedFont)
|
||||
DeleteFont(m_hUnderlinedFont);
|
||||
if (m_hDialogFont)
|
||||
DeleteFont(m_hDialogFont);
|
||||
/*
|
||||
// System color brushes are owned by the system and must not be destroyed.
|
||||
if (m_hbrWindowBrush)
|
||||
DeleteBrush(m_hbrWindowBrush);
|
||||
if (m_hbrButtonFaceBrush)
|
||||
DeleteBrush(m_hbrButtonFaceBrush);
|
||||
if (m_hbrControlLight)
|
||||
DeleteBrush(m_hbrControlLight);
|
||||
*/
|
||||
if (m_hBigAppIcon && m_bDestroyBigAppIcon)
|
||||
DestroyIcon(m_hBigAppIcon);
|
||||
if (m_hSmallAppIcon && m_bDestroySmallAppIcon)
|
||||
DestroyIcon(m_hSmallAppIcon);
|
||||
if (m_hDialogIcon)
|
||||
DeleteBitmap(m_hDialogIcon);
|
||||
if (m_hCheckMark)
|
||||
DeleteBitmap(m_hCheckMark);
|
||||
if (m_hSortArrows)
|
||||
ImageList_Destroy(m_hSortArrows);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
83
third-party/BugTrap-1.3-57bd515/source/ResManager.h
vendored
Normal file
83
third-party/BugTrap-1.3-57bd515/source/ResManager.h
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Custom resources manager.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define SEND_MSG_TIMEOUT 500
|
||||
|
||||
/**
|
||||
* @addtogroup ResManager Custom resource manager.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Custom resources manager.
|
||||
class CResManager
|
||||
{
|
||||
public:
|
||||
/// Initialize custom resources.
|
||||
explicit CResManager(HWND hwndParent);
|
||||
/// Free custom resources.
|
||||
~CResManager(void);
|
||||
|
||||
/// Fixed font handle.
|
||||
HFONT m_hFixedFont;
|
||||
/// Underlined font handle.
|
||||
HFONT m_hUnderlinedFont;
|
||||
/// Dialog font handle.
|
||||
HFONT m_hDialogFont;
|
||||
/// Hand cursor.
|
||||
HCURSOR m_hHandCursor;
|
||||
/// Arrow cursor.
|
||||
HCURSOR m_hArrowCursor;
|
||||
/// Arrow + hour-glass cursor.
|
||||
HCURSOR m_hAppStartingCursor;
|
||||
/// Double-pointed arrow pointing north and south.
|
||||
HCURSOR m_hUpDownCursor;
|
||||
/// Double-pointed arrow pointing west and east.
|
||||
HCURSOR m_hLeftRightCursor;
|
||||
/// Hour-glass cursor.
|
||||
HCURSOR m_hWaitCursor;
|
||||
/// I-beam cursor.
|
||||
HCURSOR m_hIBeamCursor;
|
||||
/// Window brush handle.
|
||||
HBRUSH m_hbrWindowBrush;
|
||||
/// Control light brush handle.
|
||||
HBRUSH m_hbrControlLight;
|
||||
/// Button-face brush handle.
|
||||
HBRUSH m_hbrButtonFaceBrush;
|
||||
/// Background brush handle.
|
||||
HBRUSH m_hbrAppWorkspace;
|
||||
/// Big application icon.
|
||||
HICON m_hBigAppIcon;
|
||||
/// Small application icon.
|
||||
HICON m_hSmallAppIcon;
|
||||
/// Transparent dialog icon.
|
||||
HBITMAP m_hDialogIcon;
|
||||
/// Check-mark bitmap.
|
||||
HBITMAP m_hCheckMark;
|
||||
/// Sort arrows bitmap.
|
||||
HIMAGELIST m_hSortArrows;
|
||||
|
||||
private:
|
||||
/// Protects the class from being accidentally copied.
|
||||
CResManager(const CResManager& rResManager);
|
||||
/// Protects the class from being accidentally copied.
|
||||
CResManager& operator=(const CResManager& rResManager);
|
||||
/// True if app icon was loaded from the resources and should be destroyed.
|
||||
bool m_bDestroyBigAppIcon;
|
||||
/// True if app icon was loaded from the resources and should be destroyed.
|
||||
bool m_bDestroySmallAppIcon;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
186
third-party/BugTrap-1.3-57bd515/source/SendMailDlg.cpp
vendored
Normal file
186
third-party/BugTrap-1.3-57bd515/source/SendMailDlg.cpp
vendored
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Send Mail dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "SendMailDlg.h"
|
||||
#include "BugTrapUI.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "WaitDlg.h"
|
||||
#include "LayoutManager.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUI BugTrap Graphical User Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Control layouts for Send Mail dialog.
|
||||
static LAYOUT_INFO g_arrSendMailLayout[] =
|
||||
{
|
||||
LAYOUT_INFO(IDC_RECIPIENT, ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_TOP),
|
||||
LAYOUT_INFO(IDC_ATTACHMENT, ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_TOP),
|
||||
LAYOUT_INFO(IDC_SUBJECT, ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_TOP),
|
||||
LAYOUT_INFO(IDC_BODY, ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_BOTTOM),
|
||||
LAYOUT_INFO(IDOK, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_RIGHT, ALIGN_BOTTOM),
|
||||
LAYOUT_INFO(IDCANCEL, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_RIGHT, ALIGN_BOTTOM)
|
||||
};
|
||||
|
||||
/// Dialog layout manager.
|
||||
static CLayoutManager g_LayoutMgr;
|
||||
|
||||
/**
|
||||
* @brief WM_COMMAND handler of Send Mail dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param id - control ID.
|
||||
* @param hwndCtl - control handle.
|
||||
* @param codeNotify - notification code.
|
||||
*/
|
||||
static void SendMailDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
int nTextLength;
|
||||
PTSTR pszSubject, pszMessage;
|
||||
switch (codeNotify)
|
||||
{
|
||||
case BN_CLICKED:
|
||||
switch (id)
|
||||
{
|
||||
case IDOK:
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_SUBJECT);
|
||||
nTextLength = GetWindowTextLength(hwndCtl) + 1;
|
||||
pszSubject = new TCHAR[nTextLength];
|
||||
if (! pszSubject)
|
||||
return;
|
||||
GetWindowText(hwndCtl, pszSubject, nTextLength);
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_BODY);
|
||||
nTextLength = GetWindowTextLength(hwndCtl) + 1;
|
||||
pszMessage = new TCHAR[nTextLength];
|
||||
if (! pszMessage)
|
||||
{
|
||||
delete[] pszSubject;
|
||||
return;
|
||||
}
|
||||
GetWindowText(hwndCtl, pszMessage, nTextLength);
|
||||
|
||||
if (! SendEMail(hwnd, pszSubject, pszMessage))
|
||||
{
|
||||
SetForegroundWindow(hwnd);
|
||||
TCHAR szProjectName[32], szMessageText[128];
|
||||
LoadString(g_hInstance, IDS_BUGTRAP_NAME, szProjectName, countof(szProjectName));
|
||||
LoadString(g_hInstance, IDS_ERROR_TRANSFERFAILED, szMessageText, countof(szMessageText));
|
||||
::MessageBox(hwnd, szMessageText, szProjectName, MB_ICONERROR | MB_OK);
|
||||
}
|
||||
else
|
||||
EndDialog(hwnd, TRUE);
|
||||
delete[] pszSubject;
|
||||
delete[] pszMessage;
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, FALSE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_INITDIALOG handler of Send Mail dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hwndFocus - system-defined focus window.
|
||||
* @param lParam - user-defined parameter.
|
||||
* @return true to setup focus to system-defined control.
|
||||
*/
|
||||
static BOOL SendMailDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
lParam; hwndFocus;
|
||||
HWND hwndCtl;
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (g_pResManager->m_hBigAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)g_pResManager->m_hBigAppIcon);
|
||||
if (g_pResManager->m_hSmallAppIcon)
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_pResManager->m_hSmallAppIcon);
|
||||
CenterWindow(hwnd, GetParent(hwnd));
|
||||
g_LayoutMgr.InitLayout(hwnd, g_arrSendMailLayout, countof(g_arrSendMailLayout));
|
||||
|
||||
if (g_dwFlags & BTF_ATTACHREPORT)
|
||||
{
|
||||
TCHAR szFileName[MAX_PATH];
|
||||
g_pSymEngine->GetReportFileName(szFileName, countof(szFileName));
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_ATTACHMENT);
|
||||
SetWindowText(hwndCtl, szFileName);
|
||||
}
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_RECIPIENT);
|
||||
SetWindowText(hwndCtl, g_szSupportEMail);
|
||||
|
||||
TCHAR szSubject[MAX_PATH];
|
||||
GetDefaultMailSubject(szSubject, countof(szSubject));
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_SUBJECT);
|
||||
SetWindowText(hwndCtl, szSubject);
|
||||
|
||||
hwndCtl = GetDlgItem(hwnd, IDC_BODY);
|
||||
SetFocus(hwndCtl);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_SIZE handler of Send Mail dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param state - window state.
|
||||
* @param cx - window width.
|
||||
* @param cy - window height.
|
||||
*/
|
||||
static void SendMailDlg_OnSize(HWND hwnd, UINT state, int cx, int cy)
|
||||
{
|
||||
hwnd; cx; cy; state;
|
||||
g_LayoutMgr.ApplyLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_GETMINMAXINFO handler of Send Mail State dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param pMinMaxInfo - window min-max info.
|
||||
*/
|
||||
static void SendMailDlg_OnGetMinMaxInfo(HWND hwnd, PMINMAXINFO pMinMaxInfo)
|
||||
{
|
||||
hwnd;
|
||||
pMinMaxInfo->ptMinTrackSize = g_LayoutMgr.GetMinTrackSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dialog procedure of Send Mail dialog.
|
||||
* @param hwndDlg - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - 1st message parameter.
|
||||
* @param lParam - 2nd message parameter.
|
||||
* @return message result.
|
||||
*/
|
||||
INT_PTR CALLBACK SendMailDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
HANDLE_MSG(hwndDlg, WM_INITDIALOG, SendMailDlg_OnInitDialog);
|
||||
HANDLE_MSG(hwndDlg, WM_COMMAND, SendMailDlg_OnCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_SIZE, SendMailDlg_OnSize);
|
||||
HANDLE_MSG(hwndDlg, WM_GETMINMAXINFO, SendMailDlg_OnGetMinMaxInfo);
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
17
third-party/BugTrap-1.3-57bd515/source/SendMailDlg.h
vendored
Normal file
17
third-party/BugTrap-1.3-57bd515/source/SendMailDlg.h
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Send Mail dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
INT_PTR CALLBACK SendMailDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
224
third-party/BugTrap-1.3-57bd515/source/SimpleDlg.cpp
vendored
Normal file
224
third-party/BugTrap-1.3-57bd515/source/SimpleDlg.cpp
vendored
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: BugTrap simplified dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "resource.h"
|
||||
#include "SimpleDlg.h"
|
||||
#include "BugTrapUI.h"
|
||||
#include "AboutDlg.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup BugTrapUI BugTrap Graphical User Interface
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// Tool-tip window handle.
|
||||
static HWND g_hwndToolTip = NULL;
|
||||
/// URL hyper-link control pointing to support site.
|
||||
static CHyperLink g_hlURL;
|
||||
/// URL hyper-link control pointing to support e-mail.
|
||||
static CHyperLink g_hlMailTo;
|
||||
|
||||
/**
|
||||
* @brief WM_COMMAND handler of simplified dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param id - control ID.
|
||||
* @param hwndCtl - control handle.
|
||||
* @param codeNotify - notification code.
|
||||
*/
|
||||
static void SimpleDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
codeNotify; hwndCtl;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case IDC_MAILTO:
|
||||
MailTempReportEx(hwnd);
|
||||
break;
|
||||
case IDC_SUBMIT_BUG:
|
||||
SubmitTempReport(hwnd);
|
||||
break;
|
||||
case IDC_MORE:
|
||||
EndDialog(hwnd, TRUE);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hwnd, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize dialog controls.
|
||||
* @param hwnd - window handle.
|
||||
*/
|
||||
static void InitControls(HWND hwnd)
|
||||
{
|
||||
HWND hwndMailTo = GetDlgItem(hwnd, IDC_MAILTO);
|
||||
HWND hwndSubmitBug = GetDlgItem(hwnd, IDC_SUBMIT_BUG);
|
||||
HWND hwndMore = GetDlgItem(hwnd, IDC_MORE);
|
||||
HWND hwndClose = GetDlgItem(hwnd, IDCANCEL);
|
||||
|
||||
g_hlMailTo.Attach(hwndMailTo);
|
||||
g_hwndToolTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hwnd, NULL, g_hInstance, 0l);
|
||||
if (g_hwndToolTip)
|
||||
{
|
||||
RECT rcCtl;
|
||||
GetClientRect(hwndClose, &rcCtl);
|
||||
SendMessage(g_hwndToolTip, TTM_SETMAXTIPWIDTH, 0, rcCtl.right * 2);
|
||||
|
||||
TOOLINFO tinfo;
|
||||
ZeroMemory(&tinfo, sizeof(tinfo));
|
||||
tinfo.cbSize = sizeof(tinfo);
|
||||
tinfo.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
|
||||
tinfo.hinst = g_hInstance;
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndMailTo;
|
||||
tinfo.lpszText = (PTSTR)IDS_MAILTO_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndSubmitBug;
|
||||
tinfo.lpszText = (PTSTR)IDS_SUBMIT_BUG_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndMore;
|
||||
tinfo.lpszText = (PTSTR)IDS_MORE_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
|
||||
tinfo.uId = (UINT_PTR)hwndClose;
|
||||
tinfo.lpszText = (PTSTR)IDS_CLOSE_TIP;
|
||||
SendMessage(g_hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&tinfo);
|
||||
}
|
||||
|
||||
if (*g_szSupportHost == _T('\0') || g_nSupportPort == 0)
|
||||
{
|
||||
ShowWindow(hwndMailTo, SW_HIDE);
|
||||
if (*g_szSupportEMail == _T('\0'))
|
||||
EnableWindow(hwndSubmitBug, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*g_szSupportEMail == _T('\0'))
|
||||
ShowWindow(hwndMailTo, SW_HIDE);
|
||||
}
|
||||
|
||||
HWND hwndFocus = IsWindowEnabled(hwndSubmitBug) ? hwndSubmitBug : hwndClose;
|
||||
SetFocus(hwndFocus);
|
||||
SendMessage(hwnd, DM_SETDEFID, GetDlgCtrlID(hwndFocus), 0l);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_INITDIALOG handler of simplified dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hwndFocus - system-defined focus window.
|
||||
* @param lParam - user-defined parameter.
|
||||
* @return true to setup focus to system-defined control.
|
||||
*/
|
||||
static BOOL SimpleDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
lParam; hwndFocus;
|
||||
|
||||
InitControls(hwnd);
|
||||
InitIntro(hwnd, g_hlURL);
|
||||
InitAbout(hwnd);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_CTLCOLORXXX handler of simplified dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param hdc - device context.
|
||||
* @param hwndChild - child window handle.
|
||||
* @param type - message subtype.
|
||||
* @return brush handle.
|
||||
*/
|
||||
static HBRUSH SimpleDlg_OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type)
|
||||
{
|
||||
hwnd;
|
||||
if (type == CTLCOLOR_STATIC)
|
||||
{
|
||||
int nChildID = GetDlgCtrlID(hwndChild);
|
||||
if (nChildID == IDC_INTRO_BKGND ||
|
||||
nChildID == IDC_INTRO1 ||
|
||||
nChildID == IDC_INTRO2)
|
||||
{
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
|
||||
return g_pResManager->m_hbrWindowBrush;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_DESTROY handler of simplified dialog.
|
||||
* @param hwnd - window handle.
|
||||
*/
|
||||
static void SimpleDlg_OnDestroy(HWND hwnd)
|
||||
{
|
||||
hwnd;
|
||||
|
||||
g_hlURL.Detach();
|
||||
g_hlMailTo.Detach();
|
||||
|
||||
if (g_hwndToolTip)
|
||||
{
|
||||
DestroyWindow(g_hwndToolTip);
|
||||
g_hwndToolTip = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WM_SYSCOMMAND handler of simplified dialog.
|
||||
* @param hwnd - window handle.
|
||||
* @param cmd - specifies the type of system command requested.
|
||||
* @param x - horizontal position of the cursor, in screen coordinates.
|
||||
* @param y - vertical position of the cursor, in screen coordinates.
|
||||
*/
|
||||
void SimpleDlg_OnSysCommand(HWND hwnd, UINT cmd, int x, int y)
|
||||
{
|
||||
x; y;
|
||||
if ((cmd & 0xFFF0) == IDM_ABOUTBOX)
|
||||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUT_BUGTRAP_DLG), hwnd, AboutDlgProc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dialog procedure of simplified dialog.
|
||||
* @param hwndDlg - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - 1st message parameter.
|
||||
* @param lParam - 2nd message parameter.
|
||||
* @return message result.
|
||||
*/
|
||||
INT_PTR CALLBACK SimpleDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
HANDLE_MSG(hwndDlg, WM_INITDIALOG, SimpleDlg_OnInitDialog);
|
||||
HANDLE_MSG(hwndDlg, WM_COMMAND, SimpleDlg_OnCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_SYSCOMMAND, SimpleDlg_OnSysCommand);
|
||||
HANDLE_MSG(hwndDlg, WM_CTLCOLORSTATIC, SimpleDlg_OnCtlColor);
|
||||
HANDLE_MSG(hwndDlg, WM_DESTROY, SimpleDlg_OnDestroy);
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
||||
17
third-party/BugTrap-1.3-57bd515/source/SimpleDlg.h
vendored
Normal file
17
third-party/BugTrap-1.3-57bd515/source/SimpleDlg.h
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: BugTrap simplified dialog.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
INT_PTR CALLBACK SimpleDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
218
third-party/BugTrap-1.3-57bd515/source/SmartPtr.h
vendored
Normal file
218
third-party/BugTrap-1.3-57bd515/source/SmartPtr.h
vendored
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Smart pointer class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
struct CPtrTraits
|
||||
{
|
||||
template <typename TYPE>
|
||||
static void Destroy(TYPE* ptr) { delete ptr; }
|
||||
};
|
||||
|
||||
struct CArrayTraits
|
||||
{
|
||||
template <typename TYPE>
|
||||
static void Destroy(TYPE* ptr) { delete[] ptr; }
|
||||
};
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
class CPtrLinkEngine
|
||||
{
|
||||
protected:
|
||||
TYPE* GetPtr(void) const { return m_ptr; }
|
||||
void Assign(TYPE* ptr);
|
||||
void Assign(const CPtrLinkEngine& sptr);
|
||||
void Release(void);
|
||||
|
||||
private:
|
||||
TYPE* m_ptr;
|
||||
mutable const CPtrLinkEngine* m_pPrev;
|
||||
mutable const CPtrLinkEngine* m_pNext;
|
||||
};
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
void CPtrLinkEngine<TYPE, TRAITS>::Assign(TYPE* ptr)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
m_pPrev = this;
|
||||
m_pNext = this;
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
void CPtrLinkEngine<TYPE, TRAITS>::Assign(const CPtrLinkEngine& sptr)
|
||||
{
|
||||
m_ptr = sptr.m_ptr;
|
||||
m_pPrev = sptr.m_pPrev;
|
||||
m_pNext = &sptr;
|
||||
sptr.m_pPrev = this;
|
||||
m_pPrev->m_pNext = this;
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
void CPtrLinkEngine<TYPE, TRAITS>::Release(void)
|
||||
{
|
||||
if (m_pNext == this)
|
||||
{
|
||||
TRAITS::Destroy(m_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pPrev->m_pNext = m_pNext;
|
||||
m_pNext->m_pPrev = m_pPrev;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
class CPtrRefEngine
|
||||
{
|
||||
protected:
|
||||
TYPE* GetPtr(void) const { _ASSERTE(m_pData != NULL); return m_pData->m_ptr; }
|
||||
void Assign(TYPE* ptr);
|
||||
void Assign(const CPtrRefEngine& sptr);
|
||||
void Release(void);
|
||||
|
||||
private:
|
||||
struct CPtrData
|
||||
{
|
||||
CPtrData(void);
|
||||
CPtrData(TYPE* ptr);
|
||||
unsigned m_uNumRefs;
|
||||
TYPE* m_ptr;
|
||||
};
|
||||
static CPtrData m_EmptyData;
|
||||
CPtrData* m_pData;
|
||||
};
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
inline CPtrRefEngine<TYPE, TRAITS>::CPtrData::CPtrData(void)
|
||||
{
|
||||
m_ptr = NULL;
|
||||
m_uNumRefs = 0;
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
inline CPtrRefEngine<TYPE, TRAITS>::CPtrData::CPtrData(TYPE* ptr)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
m_uNumRefs = 1;
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
typename CPtrRefEngine<TYPE, TRAITS>::CPtrData CPtrRefEngine<TYPE, TRAITS>::m_EmptyData;
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
void CPtrRefEngine<TYPE, TRAITS>::Assign(TYPE* ptr)
|
||||
{
|
||||
m_pData = ptr != NULL ? new CPtrData(ptr) : &m_EmptyData;
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
void CPtrRefEngine<TYPE, TRAITS>::Assign(const CPtrRefEngine& sptr)
|
||||
{
|
||||
_ASSERTE(sptr.m_pData != NULL);
|
||||
m_pData = sptr.m_pData;
|
||||
if (m_pData != &m_EmptyData)
|
||||
++m_pData->m_uNumRefs;
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS>
|
||||
void CPtrRefEngine<TYPE, TRAITS>::Release(void)
|
||||
{
|
||||
_ASSERTE(m_pData != NULL);
|
||||
if (m_pData != &m_EmptyData)
|
||||
{
|
||||
if (m_pData->m_uNumRefs == 1)
|
||||
{
|
||||
_ASSERTE(m_pData->m_ptr != NULL);
|
||||
TRAITS::Destroy(m_pData->m_ptr);
|
||||
delete m_pData;
|
||||
}
|
||||
else
|
||||
--m_pData->m_uNumRefs;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS, class ENGINE>
|
||||
class CBaseSmartPtr : protected ENGINE
|
||||
{
|
||||
public:
|
||||
CBaseSmartPtr(void) { Assign(NULL); }
|
||||
explicit CBaseSmartPtr(TYPE* ptr) { Assign(ptr); }
|
||||
CBaseSmartPtr(const CBaseSmartPtr& sptr) { Assign(sptr); }
|
||||
~CBaseSmartPtr(void) { Release(); }
|
||||
const CBaseSmartPtr& operator=(TYPE* ptr);
|
||||
const CBaseSmartPtr& operator=(const CBaseSmartPtr& sptr);
|
||||
|
||||
TYPE& operator*(void) const { _ASSERTE(GetPtr() != NULL); return *GetPtr(); }
|
||||
TYPE* operator->(void) const { _ASSERTE(GetPtr() != NULL); return GetPtr(); }
|
||||
bool operator!(void) const { return (GetPtr() == NULL); }
|
||||
operator TYPE*(void) const { return GetPtr(); }
|
||||
|
||||
friend bool operator==(const CBaseSmartPtr& sptr1, const CBaseSmartPtr& sptr2) { return sptr1.GetPtr() == sptr2.GetPtr(); }
|
||||
friend bool operator!=(const CBaseSmartPtr& sptr1, const CBaseSmartPtr& sptr2) { return sptr1.GetPtr() != sptr2.GetPtr(); }
|
||||
friend bool operator<(const CBaseSmartPtr& sptr1, const CBaseSmartPtr& sptr2) { return sptr1.GetPtr() < sptr2.GetPtr(); }
|
||||
friend bool operator<=(const CBaseSmartPtr& sptr1, const CBaseSmartPtr& sptr2) { return sptr1.GetPtr() <= sptr2.GetPtr(); }
|
||||
friend bool operator>(const CBaseSmartPtr& sptr1, const CBaseSmartPtr& sptr2) { return sptr1.GetPtr() > sptr2.GetPtr(); }
|
||||
friend bool operator>=(const CBaseSmartPtr& sptr1, const CBaseSmartPtr& sptr2) { return sptr1.GetPtr() >= sptr2.GetPtr(); }
|
||||
};
|
||||
|
||||
template <typename TYPE, class TRAITS, class ENGINE>
|
||||
const CBaseSmartPtr<TYPE, TRAITS, ENGINE>& CBaseSmartPtr<TYPE, TRAITS, ENGINE>::operator=(TYPE* ptr)
|
||||
{
|
||||
Release();
|
||||
Assign(ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename TYPE, class TRAITS, class ENGINE>
|
||||
const CBaseSmartPtr<TYPE, TRAITS, ENGINE>& CBaseSmartPtr<TYPE, TRAITS, ENGINE>::operator=(const CBaseSmartPtr& sptr)
|
||||
{
|
||||
if (this != &sptr)
|
||||
{
|
||||
Release();
|
||||
Assign(sptr);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#define CBaseClass CBaseSmartPtr<TYPE, CPtrTraits, ENGINE>
|
||||
|
||||
template <typename TYPE, class ENGINE = CPtrRefEngine<TYPE, CPtrTraits> >
|
||||
class CSmartPtr : public CBaseClass
|
||||
{
|
||||
public:
|
||||
CSmartPtr(void) : CBaseClass() { }
|
||||
explicit CSmartPtr(TYPE* ptr) : CBaseClass(ptr) { }
|
||||
CSmartPtr(const CSmartPtr& sptr) : CBaseClass(sptr) { }
|
||||
const CSmartPtr& operator=(TYPE* ptr) { CBaseClass::operator=(ptr); return *this; }
|
||||
const CSmartPtr& operator=(const CSmartPtr& sptr) { CBaseClass::operator=(sptr); return *this; }
|
||||
};
|
||||
|
||||
#undef CBaseClass
|
||||
|
||||
#define CBaseClass CBaseSmartPtr<TYPE, CArrayTraits, ENGINE>
|
||||
|
||||
template <typename TYPE, class ENGINE = CPtrRefEngine<TYPE, CArrayTraits> >
|
||||
class CSmartArray : public CBaseClass
|
||||
{
|
||||
public:
|
||||
CSmartArray(void) : CBaseClass() { }
|
||||
explicit CSmartArray(TYPE* ptr) : CBaseClass(ptr) { }
|
||||
CSmartArray(const CSmartArray& sptr) : CBaseClass(sptr) { }
|
||||
const CSmartArray& operator=(TYPE* ptr) { CBaseClass::operator=(ptr); return *this; }
|
||||
const CSmartArray& operator=(const CSmartArray& sptr) { CBaseClass::operator=(sptr); return *this; }
|
||||
TYPE& operator[](INT_PTR index) const { _ASSERTE(GetPtr() != NULL); _ASSERTE(index >= 0); return GetPtr()[index]; }
|
||||
};
|
||||
|
||||
#undef CBaseClass
|
||||
474
third-party/BugTrap-1.3-57bd515/source/Splitter.cpp
vendored
Normal file
474
third-party/BugTrap-1.3-57bd515/source/Splitter.cpp
vendored
Normal file
|
|
@ -0,0 +1,474 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Splitter control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "Splitter.h"
|
||||
#include "BugTrapUtils.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @param eDirection - splitter direction.
|
||||
* @param bProportionalMode - proportional mode.
|
||||
*/
|
||||
CSplitter::CSplitter(SPLITTER_DIRECTION eDirection, bool bProportionalMode)
|
||||
{
|
||||
ClearPanels();
|
||||
m_pfnOldSplitterWndProc = NULL;
|
||||
m_bProportionalMode = bProportionalMode;
|
||||
SetDirection(eDirection);
|
||||
m_nSplitterSize = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eDirection - new splitter direction.
|
||||
*/
|
||||
void CSplitter::SetDirection(SPLITTER_DIRECTION eDirection)
|
||||
{
|
||||
m_eDirection = eDirection;
|
||||
if (m_hwnd)
|
||||
ResetSplitterPos();
|
||||
else
|
||||
ClearSplitterPos();
|
||||
}
|
||||
|
||||
void CSplitter::ResetSplitterPos(void)
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
m_nSplitterSize = CalcSplitterSize();
|
||||
m_nSplitterPos = m_nIdealPos = m_nSplitterSize / 2;
|
||||
UpdateLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rect - splitter bar coordinates.
|
||||
*/
|
||||
void CSplitter::GetSplitterBarRect(RECT& rect) const
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
GetClientRect(m_hwnd, &rect);
|
||||
int nBarSize = GetSystemMetrics(m_eDirection == SD_VERTICAL ? SM_CYFRAME : SM_CXFRAME);
|
||||
int nSplitterBarEnd = m_nSplitterPos + nBarSize;
|
||||
if (m_eDirection == SD_VERTICAL)
|
||||
{
|
||||
rect.top = m_nSplitterPos;
|
||||
if (rect.bottom > nSplitterBarEnd)
|
||||
rect.bottom = nSplitterBarEnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.left = m_nSplitterPos;
|
||||
if (rect.right > nSplitterBarEnd)
|
||||
rect.right = nSplitterBarEnd;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param point - point coordinates.
|
||||
* @return true if point appears in boundaries of Splitter text.
|
||||
*/
|
||||
BOOL CSplitter::HitTest(const POINT& point) const
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
RECT rect;
|
||||
GetSplitterBarRect(rect);
|
||||
return PtInRect(&rect, point);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x - point x-coordinate.
|
||||
* @param y - point y-coordinate.
|
||||
* @return true if point appears in boundaries of Splitter text.
|
||||
*/
|
||||
BOOL CSplitter::HitTest(int x, int y) const
|
||||
{
|
||||
POINT point;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
return HitTest(point);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hdc - drawing context.
|
||||
* @param iPanel - panel number.
|
||||
* @return true if panel index is valid.
|
||||
*/
|
||||
BOOL CSplitter::DrawPanel(HDC hdc, int iPanel) const
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
if (iPanel >= 0 && iPanel < NUM_PANELS)
|
||||
{
|
||||
RECT rect;
|
||||
CalcPanelRect(iPanel, rect, false);
|
||||
HWND hwndPanel = m_arrPanels[iPanel];
|
||||
if (hwndPanel == NULL || (GetWindowLong(hwndPanel, GWL_EXSTYLE) & WS_EX_CLIENTEDGE) == 0)
|
||||
{
|
||||
int nCXEdge = GetSystemMetrics(SM_CXEDGE) * 2;
|
||||
int nCYEdge = GetSystemMetrics(SM_CYEDGE) * 2;
|
||||
if (rect.right - rect.left >= nCXEdge && rect.bottom - rect.top >= nCYEdge)
|
||||
DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
||||
}
|
||||
if (hwndPanel == NULL)
|
||||
FillRect(hdc, &rect, g_pResManager->m_hbrAppWorkspace);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hdc - drawing context.
|
||||
*/
|
||||
void CSplitter::DrawSplitter(HDC hdc) const
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
DrawSplitterBar(hdc);
|
||||
DrawPanel(hdc, 0);
|
||||
DrawPanel(hdc, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hdc - drawing context.
|
||||
*/
|
||||
void CSplitter::DrawSplitterBar(HDC hdc) const
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
RECT rect;
|
||||
GetSplitterBarRect(rect);
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
FillRect(hdc, &rect, g_pResManager->m_hbrButtonFaceBrush);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iPanel - panel number.
|
||||
* @param hwndPanel - panel window handle.
|
||||
* @return true if panel index is valid.
|
||||
*/
|
||||
BOOL CSplitter::SetPanel(int iPanel, HWND hwndPanel)
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
if (iPanel >= 0 && iPanel < NUM_PANELS)
|
||||
{
|
||||
m_arrPanels[iPanel] = hwndPanel;
|
||||
if (hwndPanel)
|
||||
{
|
||||
RECT rect;
|
||||
CalcPanelRect(iPanel, rect, true);
|
||||
HWND hwndPanelParent = GetParent(hwndPanel);
|
||||
MapWindowRect(m_hwnd, hwndPanelParent, &rect);
|
||||
SetWindowPos(hwndPanel, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iPanel - panel number.
|
||||
* @param rect - panel rectangle.
|
||||
* @param bShrinkRect - true if rectangle must be shrinked.
|
||||
* @return true if panel index is valid.
|
||||
*/
|
||||
BOOL CSplitter::CalcPanelRect(int iPanel, RECT& rect, bool bShrinkRect) const
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
if (iPanel >= 0 && iPanel < NUM_PANELS)
|
||||
{
|
||||
GetClientRect(m_hwnd, &rect);
|
||||
if (m_eDirection == SD_VERTICAL)
|
||||
{
|
||||
if (iPanel == 0)
|
||||
rect.bottom = m_nSplitterPos;
|
||||
else
|
||||
{
|
||||
int nBarSize = GetSystemMetrics(SM_CYFRAME);
|
||||
int nSplitterBarEnd = m_nSplitterPos + nBarSize;
|
||||
rect.top = rect.bottom > nSplitterBarEnd ? nSplitterBarEnd : rect.bottom;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iPanel == 0)
|
||||
rect.right = m_nSplitterPos;
|
||||
else
|
||||
{
|
||||
int nBarSize = GetSystemMetrics(SM_CXFRAME);
|
||||
int nSplitterBarEnd = m_nSplitterPos + nBarSize;
|
||||
rect.left = rect.right > nSplitterBarEnd ? nSplitterBarEnd : rect.right;
|
||||
}
|
||||
}
|
||||
if (bShrinkRect)
|
||||
{
|
||||
HWND hwndPanel = m_arrPanels[iPanel];
|
||||
if (hwndPanel == NULL || (GetWindowLong(hwndPanel, GWL_EXSTYLE) & WS_EX_CLIENTEDGE) == 0)
|
||||
{
|
||||
int nCXEdge = GetSystemMetrics(SM_CXEDGE);
|
||||
int nCYEdge = GetSystemMetrics(SM_CYEDGE);
|
||||
if (rect.right - rect.left >= nCXEdge * 2)
|
||||
{
|
||||
rect.left += nCXEdge;
|
||||
rect.right -= nCXEdge;
|
||||
}
|
||||
if (rect.bottom - rect.top >= nCYEdge * 2)
|
||||
{
|
||||
rect.top += nCYEdge;
|
||||
rect.bottom -= nCYEdge;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CSplitter::UpdateLayout(void)
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
InvalidateRect(m_hwnd, NULL, FALSE);
|
||||
HDWP hdwp = BeginDeferWindowPos(NUM_PANELS);
|
||||
if (hdwp)
|
||||
{
|
||||
for (int iPanel = 0; iPanel < NUM_PANELS; ++iPanel)
|
||||
{
|
||||
HWND hwndPanel = m_arrPanels[iPanel];
|
||||
if (hwndPanel)
|
||||
{
|
||||
RECT rect;
|
||||
CalcPanelRect(iPanel, rect, true);
|
||||
HWND hwndPanelParent = GetParent(hwndPanel);
|
||||
MapWindowRect(m_hwnd, hwndPanelParent, &rect);
|
||||
DeferWindowPos(hdwp, hwndPanel, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
|
||||
}
|
||||
}
|
||||
EndDeferWindowPos(hdwp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSplitterSize - new splitter size.
|
||||
*/
|
||||
void CSplitter::ResizeSplitter(int nSplitterSize)
|
||||
{
|
||||
int nEdgeType, nFrameType;
|
||||
if (m_eDirection == SD_VERTICAL)
|
||||
{
|
||||
nEdgeType = SM_CYEDGE;
|
||||
nFrameType = SM_CYFRAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
nEdgeType = SM_CXEDGE;
|
||||
nFrameType = SM_CXFRAME;
|
||||
}
|
||||
int nBarSize = GetSystemMetrics(nFrameType);
|
||||
int nEdgeSize = GetSystemMetrics(nEdgeType) * 2;
|
||||
nSplitterSize -= nBarSize;
|
||||
nSplitterSize -= nEdgeSize;
|
||||
if (nSplitterSize < 0)
|
||||
nSplitterSize = 0;
|
||||
if (m_bProportionalMode)
|
||||
m_nSplitterPos = m_nSplitterSize > 0 ? MulDiv(m_nIdealPos, nSplitterSize, m_nSplitterSize) : nSplitterSize / 2;
|
||||
if (m_nSplitterPos < nEdgeSize)
|
||||
m_nSplitterPos = nEdgeSize;
|
||||
if (m_nSplitterPos > nSplitterSize)
|
||||
m_nSplitterPos = nSplitterSize;
|
||||
UpdateLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSplitterPos - new splitter position.
|
||||
*/
|
||||
void CSplitter::SetSplitterPos(int nSplitterPos)
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
int nEdgeSize = GetSystemMetrics(m_eDirection == SD_VERTICAL ? SM_CYEDGE : SM_CXEDGE) * 2;
|
||||
int nSplitterSize = CalcSplitterSize();
|
||||
if (nSplitterPos < nEdgeSize)
|
||||
nSplitterPos = nEdgeSize;
|
||||
if (nSplitterPos > nSplitterSize)
|
||||
nSplitterPos = nSplitterSize;
|
||||
if (m_nSplitterPos != nSplitterPos)
|
||||
{
|
||||
m_nSplitterSize = nSplitterSize;
|
||||
m_nIdealPos = m_nSplitterPos = nSplitterPos;
|
||||
UpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - window handle.
|
||||
* @param uMsg - message identifier.
|
||||
* @param wParam - first message parameter.
|
||||
* @param lParam - second message parameter.
|
||||
*/
|
||||
LRESULT CALLBACK CSplitter::SplitterWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int x, y, nSplitterPos, nSplitterSize;
|
||||
POINT point;
|
||||
HCURSOR hCursor;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
DWORD dwResult;
|
||||
|
||||
CSplitter* _this = (CSplitter*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
_ASSERTE(_this != NULL);
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_NCHITTEST:
|
||||
if (GetCapture() == hwnd)
|
||||
return HTCLIENT;
|
||||
point.x = GET_X_LPARAM(lParam);
|
||||
point.y = GET_Y_LPARAM(lParam);
|
||||
ScreenToClient(hwnd, &point);
|
||||
return (_this->HitTest(point) ? HTCLIENT : HTTRANSPARENT);
|
||||
case WM_SETCURSOR:
|
||||
_ASSERTE(g_pResManager != NULL);
|
||||
dwResult = GetMessagePos();
|
||||
point.x = GET_X_LPARAM(dwResult);
|
||||
point.y = GET_Y_LPARAM(dwResult);
|
||||
ScreenToClient(hwnd, &point);
|
||||
if (_this->HitTest(point))
|
||||
hCursor = _this->m_eDirection == SD_VERTICAL ? g_pResManager->m_hUpDownCursor : g_pResManager->m_hLeftRightCursor;
|
||||
else
|
||||
hCursor = g_pResManager->m_hArrowCursor;
|
||||
if (hCursor)
|
||||
{
|
||||
SetCursor(hCursor);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
case WM_LBUTTONDOWN:
|
||||
if (GetCapture() != hwnd)
|
||||
{
|
||||
x = GET_X_LPARAM(lParam);
|
||||
y = GET_Y_LPARAM(lParam);
|
||||
if (_this->HitTest(x, y))
|
||||
SetCapture(hwnd);
|
||||
}
|
||||
return 0;
|
||||
case WM_MOUSEMOVE:
|
||||
if (GetCapture() == hwnd)
|
||||
{
|
||||
nSplitterPos = _this->m_eDirection == SD_VERTICAL ? GET_Y_LPARAM(lParam) : GET_X_LPARAM(lParam);
|
||||
_this->SetSplitterPos(nSplitterPos);
|
||||
}
|
||||
return 0;
|
||||
case WM_LBUTTONUP:
|
||||
if (GetCapture() == hwnd)
|
||||
ReleaseCapture();
|
||||
return 0;
|
||||
case WM_CAPTURECHANGED:
|
||||
return 0;
|
||||
case WM_ERASEBKGND:
|
||||
return TRUE;
|
||||
case WM_SIZE:
|
||||
nSplitterSize = _this->m_eDirection == SD_VERTICAL ? GET_Y_LPARAM(lParam) : GET_X_LPARAM(lParam);
|
||||
_this->ResizeSplitter(nSplitterSize);
|
||||
return 0;
|
||||
case WM_PAINT:
|
||||
hdc = (HDC)wParam;
|
||||
if (! hdc)
|
||||
{
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
if (hdc)
|
||||
{
|
||||
_this->DrawSplitter(hdc);
|
||||
EndPaint(hwnd, &ps);
|
||||
}
|
||||
}
|
||||
else
|
||||
_this->DrawSplitter(hdc);
|
||||
return 0;
|
||||
case WM_PRINTCLIENT:
|
||||
hdc = (HDC)wParam;
|
||||
_this->DrawSplitter(hdc);
|
||||
return 0;
|
||||
case WM_GETDLGCODE:
|
||||
return DLGC_STATIC;
|
||||
default:
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hwnd - splitter window handle.
|
||||
*/
|
||||
void CSplitter::Attach(HWND hwnd)
|
||||
{
|
||||
_ASSERTE(hwnd != NULL);
|
||||
_ASSERTE(m_hwnd == NULL);
|
||||
m_hwnd = hwnd;
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this);
|
||||
m_pfnOldSplitterWndProc = SubclassWindow(hwnd, SplitterWndProc);
|
||||
ResetSplitterPos();
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
|
||||
void CSplitter::Detach(void)
|
||||
{
|
||||
if (m_pfnOldSplitterWndProc)
|
||||
{
|
||||
SubclassWindow(m_hwnd, m_pfnOldSplitterWndProc);
|
||||
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, NULL);
|
||||
ClearSplitterPos();
|
||||
ClearPanels();
|
||||
InvalidateRect(m_hwnd, NULL, TRUE);
|
||||
m_pfnOldSplitterWndProc = NULL;
|
||||
m_hwnd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CSplitter::ClearSplitterPos(void)
|
||||
{
|
||||
m_nIdealPos = m_nSplitterPos = m_nSplitterSize = 0;
|
||||
}
|
||||
|
||||
void CSplitter::ClearPanels(void)
|
||||
{
|
||||
m_arrPanels[0] = NULL;
|
||||
m_arrPanels[1] = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return splitter size value.
|
||||
*/
|
||||
int CSplitter::CalcSplitterSize(void) const
|
||||
{
|
||||
_ASSERTE(m_hwnd != NULL);
|
||||
RECT rect;
|
||||
GetClientRect(m_hwnd, &rect);
|
||||
int nSplitterSize, nEdgeType, nFrameType;
|
||||
if (m_eDirection == SD_VERTICAL)
|
||||
{
|
||||
nSplitterSize = rect.bottom;
|
||||
nEdgeType = SM_CYEDGE;
|
||||
nFrameType = SM_CYFRAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
nSplitterSize = rect.right;
|
||||
nEdgeType = SM_CXEDGE;
|
||||
nFrameType = SM_CXFRAME;
|
||||
}
|
||||
int nEdgeSize = GetSystemMetrics(nEdgeType) * 2;
|
||||
int nBarSize = GetSystemMetrics(nFrameType);
|
||||
nSplitterSize -= nBarSize;
|
||||
nSplitterSize -= nEdgeSize;
|
||||
if (nSplitterSize < 0)
|
||||
nSplitterSize = 0;
|
||||
return nSplitterSize;
|
||||
}
|
||||
150
third-party/BugTrap-1.3-57bd515/source/Splitter.h
vendored
Normal file
150
third-party/BugTrap-1.3-57bd515/source/Splitter.h
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Splitter control class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Splitter control class.
|
||||
class CSplitter
|
||||
{
|
||||
public:
|
||||
/// Splitter direction.
|
||||
enum SPLITTER_DIRECTION
|
||||
{
|
||||
/// Vertical splitter.
|
||||
SD_VERTICAL = 0,
|
||||
/// Horizontal splitter.
|
||||
SD_HORIZONTAL = 1,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/// Number of panels.
|
||||
NUM_PANELS = 2
|
||||
};
|
||||
|
||||
/// Initialize the object.
|
||||
CSplitter(SPLITTER_DIRECTION eDirection = SD_VERTICAL, bool bProportionalMode = false);
|
||||
/// Attach splitter object to window handle.
|
||||
void Attach(HWND hwnd);
|
||||
/// Detach splitter object to window handle.
|
||||
void Detach(void);
|
||||
/// Get splitter direction.
|
||||
SPLITTER_DIRECTION GetDirection(void) const;
|
||||
/// Set splitter direction.
|
||||
void SetDirection(SPLITTER_DIRECTION eDirection);
|
||||
/// Get panel handle.
|
||||
HWND GetPanel(int iPanel) const;
|
||||
/// Set panel handle.
|
||||
BOOL SetPanel(int iPanel, HWND hwndPanel);
|
||||
/// Update panels layout.
|
||||
void UpdateLayout(void);
|
||||
/// Reset splitter position.
|
||||
void ResetSplitterPos(void);
|
||||
/// Set splitter position.
|
||||
void SetSplitterPos(int nSplitterPos);
|
||||
/// Get current splitter position.
|
||||
int GetSplitterPos(void) const;
|
||||
/// Set proportional mode.
|
||||
void SetProportionalMode(bool bProportionalMode);
|
||||
/// Get proportional mode.
|
||||
bool GetProportionalMode(void) const;
|
||||
|
||||
private:
|
||||
/// Protect the class from being accidentally copied.
|
||||
CSplitter(const CSplitter& rSplitter);
|
||||
/// Protect the class from being accidentally copied.
|
||||
CSplitter& operator=(const CSplitter& rSplitter);
|
||||
/// Window procedure of splitter window.
|
||||
static LRESULT CALLBACK SplitterWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
/// Draw splitter area.
|
||||
void DrawSplitter(HDC hdc) const;
|
||||
/// Draw splitter bar.
|
||||
void DrawSplitterBar(HDC hdc) const;
|
||||
/// Draw panel area.
|
||||
BOOL DrawPanel(HDC hdc, int iPanel) const;
|
||||
/// Check if point appears within splitter bar.
|
||||
BOOL HitTest(const POINT& point) const;
|
||||
/// Check if point appears within splitter bar.
|
||||
BOOL HitTest(int x, int y) const;
|
||||
/// Calculates splitter bar rectangle.
|
||||
void GetSplitterBarRect(RECT& rect) const;
|
||||
/// Calculate panel rectangle based on panel index.
|
||||
BOOL CalcPanelRect(int iPanel, RECT& rect, bool bShrinkRect) const;
|
||||
/// Resize splitter window and update panels layout.
|
||||
void ResizeSplitter(int nSplitterSize);
|
||||
/// Clear splitter size and position.
|
||||
void ClearSplitterPos(void);
|
||||
/// Clear panel windows.
|
||||
void ClearPanels(void);
|
||||
/// Calculate splitter size.
|
||||
int CalcSplitterSize(void) const;
|
||||
|
||||
/// Window handle.
|
||||
HWND m_hwnd;
|
||||
/// Old window procedure.
|
||||
WNDPROC m_pfnOldSplitterWndProc;
|
||||
/// Splitter direction.
|
||||
SPLITTER_DIRECTION m_eDirection;
|
||||
/// Splitter position.
|
||||
int m_nSplitterPos;
|
||||
/// Ideal slider position.
|
||||
int m_nIdealPos;
|
||||
/// Keeps ideal window size.
|
||||
int m_nSplitterSize;
|
||||
/// Proportional mode flag.
|
||||
bool m_bProportionalMode;
|
||||
/// Panel handles.
|
||||
HWND m_arrPanels[NUM_PANELS];
|
||||
};
|
||||
|
||||
/**
|
||||
* @return current splitter direction.
|
||||
*/
|
||||
inline CSplitter::SPLITTER_DIRECTION CSplitter::GetDirection(void) const
|
||||
{
|
||||
return m_eDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iPanel - panel number.
|
||||
* @return panel window handle.
|
||||
*/
|
||||
inline HWND CSplitter::GetPanel(int iPanel) const
|
||||
{
|
||||
return (iPanel >= 0 && iPanel < NUM_PANELS ? m_arrPanels[iPanel] : NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current splitter position.
|
||||
*/
|
||||
inline int CSplitter::GetSplitterPos(void) const
|
||||
{
|
||||
return m_nSplitterPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bProportionalMode - new proportional mode.
|
||||
*/
|
||||
inline void CSplitter::SetProportionalMode(bool bProportionalMode)
|
||||
{
|
||||
m_bProportionalMode = bProportionalMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return active proportional mode.
|
||||
*/
|
||||
inline bool CSplitter::GetProportionalMode(void) const
|
||||
{
|
||||
return m_bProportionalMode;
|
||||
}
|
||||
8
third-party/BugTrap-1.3-57bd515/source/StdAfx.cpp
vendored
Normal file
8
third-party/BugTrap-1.3-57bd515/source/StdAfx.cpp
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// BugTrap.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
130
third-party/BugTrap-1.3-57bd515/source/StdAfx.h
vendored
Normal file
130
third-party/BugTrap-1.3-57bd515/source/StdAfx.h
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Precomplied header file.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MANAGED
|
||||
#pragma unmanaged // Compile all code as unmanaged by default
|
||||
#endif
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
/// Comment out this if you don't want to use VDMDBG at all
|
||||
//#define USE_VDMDBG
|
||||
/// Comment out this if you don't want to read image header
|
||||
//#define READ_IMAGEHEADER
|
||||
|
||||
#ifdef _WIN64
|
||||
#undef USE_VDMDBG
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <tchar.h>
|
||||
#include <winsock2.h>
|
||||
#include <shellapi.h>
|
||||
#include <psapi.h>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <stdlib.h>
|
||||
#include <psapi.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <dbghelp.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#include <mapi.h>
|
||||
#include <lmcons.h>
|
||||
#include <wininet.h>
|
||||
#include <process.h>
|
||||
#include <zmouse.h>
|
||||
#include <limits.h>
|
||||
#include <zip.h>
|
||||
#include <stdio.h>
|
||||
#include <new.h>
|
||||
|
||||
#ifdef USE_VDMDBG
|
||||
#include <vdmdbg.h>
|
||||
#endif
|
||||
|
||||
struct _IMAGELIST { }; // unresolved typeref token
|
||||
|
||||
//#define DEBUG_WITH_BOUNDSCHECKER
|
||||
|
||||
#ifdef DEBUG_WITH_BOUNDSCHECKER
|
||||
#include <crtdbg.h>
|
||||
#pragma warning (disable : 4702) // unreachable code
|
||||
#define DEBUG_NEW new
|
||||
#else
|
||||
#include "LeakWatcher.h"
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
#ifndef MAXSIZE_T
|
||||
#define MAXSIZE_T ((SIZE_T)~((SIZE_T)0))
|
||||
#endif
|
||||
|
||||
#ifndef MAXSSIZE_T
|
||||
#define MAXSSIZE_T ((SSIZE_T)(MAXSIZE_T >> 1))
|
||||
#endif
|
||||
|
||||
#ifndef MINSSIZE_T
|
||||
#define MINSSIZE_T ((SSIZE_T)~MAXSSIZE_T)
|
||||
#endif
|
||||
|
||||
#ifndef MAXUINT
|
||||
#define MAXUINT ((UINT)~((UINT)0))
|
||||
#endif
|
||||
|
||||
#ifndef MAXINT
|
||||
#define MAXINT ((INT)(MAXUINT >> 1))
|
||||
#endif
|
||||
|
||||
#ifndef MININT
|
||||
#define MININT ((INT)~MAXINT)
|
||||
#endif
|
||||
|
||||
#define countof(array) (sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
#if defined _M_IX86
|
||||
#ifdef _MANAGED
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib, "zlibMSD.lib")
|
||||
#else
|
||||
#pragma comment(lib, "zlibMS.lib")
|
||||
#endif
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib, "zlibSD.lib")
|
||||
#else
|
||||
#pragma comment(lib, "zlibS.lib")
|
||||
#endif
|
||||
#endif
|
||||
#elif defined _M_X64
|
||||
#ifdef _MANAGED
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib, "zlibMSD-x64.lib")
|
||||
#else
|
||||
#pragma comment(lib, "zlibMS-x64.lib")
|
||||
#endif
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib, "zlibSD-x64.lib")
|
||||
#else
|
||||
#pragma comment(lib, "zlibS-x64.lib")
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#error CPU architecture is not supported.
|
||||
#endif
|
||||
137
third-party/BugTrap-1.3-57bd515/source/StrHolder.cpp
vendored
Normal file
137
third-party/BugTrap-1.3-57bd515/source/StrHolder.cpp
vendored
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Dynamic string holder.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "StrStream.h"
|
||||
#include "StrHolder.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/// Empty string data.
|
||||
CStrHolder::CStringData CStrHolder::m_sdEmptyData = { 0, 0, _T("") };
|
||||
|
||||
void CStrHolder::Release(void)
|
||||
{
|
||||
if (m_pData != &m_sdEmptyData)
|
||||
{
|
||||
if (m_pData->m_nUsageCount == 1)
|
||||
delete[] (PBYTE)m_pData;
|
||||
else
|
||||
--m_pData->m_nUsageCount;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
*/
|
||||
void CStrHolder::InitData(PCSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
int nSize = MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, NULL, 0);
|
||||
m_pData = (CStringData*)new BYTE[sizeof(CStringData) + sizeof(WCHAR) * nSize];
|
||||
if (! m_pData)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, m_pData->m_szData, nSize);
|
||||
m_pData->m_nLength = nSize - 1;
|
||||
m_pData->m_nUsageCount = 1;
|
||||
#else
|
||||
size_t nLength = strlen(pszStrData);
|
||||
size_t nSize = nLength + 1;
|
||||
m_pData = (CStringData*)new BYTE[sizeof(CStringData) + sizeof(CHAR) * nSize];
|
||||
if (! m_pData)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
strcpy_s(m_pData->m_szData, nSize, pszStrData);
|
||||
m_pData->m_nLength = nLength;
|
||||
m_pData->m_nUsageCount = 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
m_pData = &m_sdEmptyData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
*/
|
||||
void CStrHolder::InitData(PCWSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
size_t nLength = wcslen(pszStrData);
|
||||
size_t nSize = nLength + 1;
|
||||
m_pData = (CStringData*)new BYTE[sizeof(CStringData) + sizeof(WCHAR) * nSize];
|
||||
if (! m_pData)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
wcscpy_s(m_pData->m_szData, nSize, pszStrData);
|
||||
m_pData->m_nLength = nLength;
|
||||
m_pData->m_nUsageCount = 1;
|
||||
#else
|
||||
size_t nSize = WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, NULL, 0, NULL, NULL);
|
||||
m_pData = (CStringData*)new BYTE[sizeof(CStringData) + sizeof(CHAR) * nSize];
|
||||
if (! m_pData)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, m_pData->m_szData, (int)nSize, NULL, NULL);
|
||||
m_pData->m_nLength = nSize - 1;
|
||||
m_pData->m_nUsageCount = 1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
m_pData = &m_sdEmptyData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - another string object.
|
||||
*/
|
||||
void CStrHolder::InitData(const CStrHolder& rStrHolder)
|
||||
{
|
||||
m_pData = rStrHolder.m_pData;
|
||||
if (m_pData != &m_sdEmptyData)
|
||||
++m_pData->m_nUsageCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - another string object.
|
||||
*/
|
||||
void CStrHolder::InitData(const CStrStream& rStrStream)
|
||||
{
|
||||
if (! rStrStream.IsEmpty())
|
||||
{
|
||||
size_t nLength = rStrStream.GetLength();
|
||||
size_t nSize = nLength + 1;
|
||||
m_pData = (CStringData*)new BYTE[sizeof(CStringData) + sizeof(WCHAR) * nSize];
|
||||
if (! m_pData)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
_tcscpy_s(m_pData->m_szData, nSize, (PCTSTR)rStrStream);
|
||||
m_pData->m_nLength = nLength;
|
||||
m_pData->m_nUsageCount = 1;
|
||||
}
|
||||
else
|
||||
m_pData = &m_sdEmptyData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - another string object.
|
||||
*/
|
||||
void CStrHolder::CopyData(const CStrHolder& rStrHolder)
|
||||
{
|
||||
if (this != &rStrHolder)
|
||||
{
|
||||
Release();
|
||||
InitData(rStrHolder);
|
||||
}
|
||||
}
|
||||
333
third-party/BugTrap-1.3-57bd515/source/StrHolder.h
vendored
Normal file
333
third-party/BugTrap-1.3-57bd515/source/StrHolder.h
vendored
Normal file
|
|
@ -0,0 +1,333 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Dynamic string holder.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class CStrStream;
|
||||
|
||||
/// Dynamic string holder.
|
||||
class CStrHolder
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CStrHolder(void);
|
||||
/// Destroy the object.
|
||||
~CStrHolder(void);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder(PCSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder(PCWSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder(const CStrHolder& rStrHolder);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder(const CStrStream& rStrStream);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder& operator=(PCSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder& operator=(PCWSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder& operator=(const CStrHolder& rStrHolder);
|
||||
/// Makes a copy of string data.
|
||||
CStrHolder& operator=(const CStrStream& rStrStream);
|
||||
/// Get string data.
|
||||
operator PCTSTR(void) const;
|
||||
/// Free string data.
|
||||
void Free(void);
|
||||
/// Get string length.
|
||||
size_t GetLength(void) const;
|
||||
/// Return true if string is empty.
|
||||
BOOL IsEmpty(void) const;
|
||||
/// Get string character.
|
||||
TCHAR GetAt(size_t nPosition) const;
|
||||
/// Get string character.
|
||||
TCHAR operator[](size_t nPosition) const;
|
||||
/// Object comparison.
|
||||
friend bool operator==(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2);
|
||||
/// Object comparison.
|
||||
friend bool operator!=(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2);
|
||||
/// Object comparison.
|
||||
friend bool operator<(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2);
|
||||
/// Object comparison.
|
||||
friend bool operator<=(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2);
|
||||
/// Object comparison.
|
||||
friend bool operator>(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2);
|
||||
/// Object comparison.
|
||||
friend bool operator>=(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2);
|
||||
|
||||
private:
|
||||
/// Release string data.
|
||||
void Release(void);
|
||||
/// Initialize sting data.
|
||||
void InitData(PCSTR pszStrData);
|
||||
/// Initialize sting data.
|
||||
void InitData(PCWSTR pszStrData);
|
||||
/// Initialize sting data.
|
||||
void InitData(const CStrHolder& rStrHolder);
|
||||
/// Initialize sting data.
|
||||
void InitData(const CStrStream& rStrStream);
|
||||
/// Copy string into existing holder.
|
||||
void CopyData(PCSTR pszStrData);
|
||||
/// Copy string into existing holder.
|
||||
void CopyData(PCWSTR pszStrData);
|
||||
/// Copy string into existing holder.
|
||||
void CopyData(const CStrHolder& rStrHolder);
|
||||
/// Copy string into existing holder.
|
||||
void CopyData(const CStrStream& rStrStream);
|
||||
|
||||
/// Shared string data.
|
||||
struct CStringData
|
||||
{
|
||||
/// Usage counter.
|
||||
size_t m_nUsageCount;
|
||||
/// String length.
|
||||
size_t m_nLength;
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4200) // nonstandard extension used : zero-sized array in struct/union
|
||||
/// Pointer to the string.
|
||||
TCHAR m_szData[0];
|
||||
#pragma warning(pop)
|
||||
};
|
||||
|
||||
/// Pointer to string data.
|
||||
CStringData* m_pData;
|
||||
/// Empty string data.
|
||||
static CStringData m_sdEmptyData;
|
||||
};
|
||||
|
||||
inline CStrHolder::CStrHolder(void)
|
||||
{
|
||||
m_pData = &m_sdEmptyData;
|
||||
}
|
||||
|
||||
inline CStrHolder::~CStrHolder(void)
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string data.
|
||||
*/
|
||||
inline CStrHolder::operator PCTSTR(void) const
|
||||
{
|
||||
_ASSERTE(m_pData != NULL);
|
||||
return m_pData->m_szData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string length.
|
||||
*/
|
||||
inline size_t CStrHolder::GetLength(void) const
|
||||
{
|
||||
_ASSERTE(m_pData != NULL);
|
||||
return m_pData->m_nLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if string is empty.
|
||||
*/
|
||||
inline BOOL CStrHolder::IsEmpty(void) const
|
||||
{
|
||||
_ASSERTE(m_pData != NULL);
|
||||
return (m_pData->m_nLength == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
*/
|
||||
inline CStrHolder::CStrHolder(PCSTR pszStrData)
|
||||
{
|
||||
InitData(pszStrData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
*/
|
||||
inline CStrHolder::CStrHolder(PCWSTR pszStrData)
|
||||
{
|
||||
InitData(pszStrData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - another string data.
|
||||
*/
|
||||
inline CStrHolder::CStrHolder(const CStrHolder& rStrHolder)
|
||||
{
|
||||
InitData(rStrHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - another string data.
|
||||
*/
|
||||
inline CStrHolder::CStrHolder(const CStrStream& rStrStream)
|
||||
{
|
||||
InitData(rStrStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrHolder& CStrHolder::operator=(PCSTR pszStrData)
|
||||
{
|
||||
CopyData(pszStrData);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrHolder& CStrHolder::operator=(PCWSTR pszStrData)
|
||||
{
|
||||
CopyData(pszStrData);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - another string data.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrHolder& CStrHolder::operator=(const CStrHolder& rStrHolder)
|
||||
{
|
||||
if (this != &rStrHolder)
|
||||
CopyData(rStrHolder);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - another string data.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrHolder& CStrHolder::operator=(const CStrStream& rStrStream)
|
||||
{
|
||||
CopyData(rStrStream);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void CStrHolder::Free(void)
|
||||
{
|
||||
Release();
|
||||
m_pData = &m_sdEmptyData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
*/
|
||||
inline void CStrHolder::CopyData(PCSTR pszStrData)
|
||||
{
|
||||
Release();
|
||||
InitData(pszStrData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - another string data.
|
||||
*/
|
||||
inline void CStrHolder::CopyData(PCWSTR pszStrData)
|
||||
{
|
||||
Release();
|
||||
InitData(pszStrData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - another string object.
|
||||
*/
|
||||
inline void CStrHolder::CopyData(const CStrStream& rStrStream)
|
||||
{
|
||||
Release();
|
||||
InitData(rStrStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - character position within the string.
|
||||
* @return character value.
|
||||
*/
|
||||
inline TCHAR CStrHolder::GetAt(size_t nPosition) const
|
||||
{
|
||||
_ASSERTE(nPosition < m_pData->m_nLength);
|
||||
if (nPosition >= m_pData->m_nLength)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
return m_pData->m_szData[nPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - character position within the string.
|
||||
* @return character value.
|
||||
*/
|
||||
inline TCHAR CStrHolder::operator[](size_t nPosition) const
|
||||
{
|
||||
_ASSERTE(nPosition < m_pData->m_nLength);
|
||||
if (nPosition >= m_pData->m_nLength)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
return m_pData->m_szData[nPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder1 - 1st object.
|
||||
* @param rStrHolder2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator==(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2)
|
||||
{
|
||||
return (_tcscmp(rStrHolder1.m_pData->m_szData, rStrHolder2.m_pData->m_szData) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder1 - 1st object.
|
||||
* @param rStrHolder2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator!=(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2)
|
||||
{
|
||||
return (_tcscmp(rStrHolder1.m_pData->m_szData, rStrHolder2.m_pData->m_szData) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder1 - 1st object.
|
||||
* @param rStrHolder2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator<(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2)
|
||||
{
|
||||
return (_tcscmp(rStrHolder1.m_pData->m_szData, rStrHolder2.m_pData->m_szData) < 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder1 - 1st object.
|
||||
* @param rStrHolder2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator<=(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2)
|
||||
{
|
||||
return (_tcscmp(rStrHolder1.m_pData->m_szData, rStrHolder2.m_pData->m_szData) <= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder1 - 1st object.
|
||||
* @param rStrHolder2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator>(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2)
|
||||
{
|
||||
return (_tcscmp(rStrHolder1.m_pData->m_szData, rStrHolder2.m_pData->m_szData) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder1 - 1st object.
|
||||
* @param rStrHolder2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator>=(const CStrHolder& rStrHolder1, const CStrHolder& rStrHolder2)
|
||||
{
|
||||
return (_tcscmp(rStrHolder1.m_pData->m_szData, rStrHolder2.m_pData->m_szData) >= 0);
|
||||
}
|
||||
333
third-party/BugTrap-1.3-57bd515/source/StrStream.cpp
vendored
Normal file
333
third-party/BugTrap-1.3-57bd515/source/StrStream.cpp
vendored
Normal file
|
|
@ -0,0 +1,333 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: String (memory) stream class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "StrStream.h"
|
||||
#include "StrHolder.h"
|
||||
#include "BugTrapUtils.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
void CStrStream::InitBuffer(void)
|
||||
{
|
||||
m_pszData = NULL;
|
||||
m_nSize = m_nLength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSize - initial buffer size.
|
||||
*/
|
||||
void CStrStream::InitBuffer(size_t nSize)
|
||||
{
|
||||
if (nSize)
|
||||
{
|
||||
m_nLength = 0;
|
||||
m_pszData = new TCHAR[nSize];
|
||||
if (m_pszData)
|
||||
{
|
||||
*m_pszData = _T('\0');
|
||||
m_nSize = nSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nSize = 0;
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSize - requested buffer size.
|
||||
* @param bAdaptiveGrowth - true for adaptive growth.
|
||||
*/
|
||||
void CStrStream::EnsureSize(size_t nSize, bool bAdaptiveGrowth)
|
||||
{
|
||||
if (m_nSize < nSize)
|
||||
{
|
||||
if (bAdaptiveGrowth)
|
||||
nSize *= 2;
|
||||
PTSTR pszData = new TCHAR[nSize];
|
||||
if (! pszData)
|
||||
RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
|
||||
if (m_pszData)
|
||||
{
|
||||
_tcscpy_s(pszData, nSize, m_pszData);
|
||||
delete[] m_pszData;
|
||||
}
|
||||
m_pszData = pszData;
|
||||
m_nSize = nSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
* @param nLength - string length.
|
||||
*/
|
||||
void CStrStream::InitData(PCTSTR pszStrData, size_t nLength)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
size_t nSize = nLength + 1;
|
||||
InitBuffer(nSize);
|
||||
_tcsncpy_s(m_pszData, nSize, pszStrData, nLength);
|
||||
m_nLength = nLength;
|
||||
}
|
||||
else
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
* @param nLength - string length.
|
||||
*/
|
||||
void CStrStream::CopyData(PCTSTR pszStrData, size_t nLength)
|
||||
{
|
||||
if (m_pszData != pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
size_t nSize = nLength + 1;
|
||||
EnsureSize(nSize, false);
|
||||
_tcsncpy_s(m_pszData, nSize, pszStrData, nLength);
|
||||
m_nLength = nLength;
|
||||
}
|
||||
else
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
* @param nLength - string length.
|
||||
*/
|
||||
void CStrStream::AppendData(PCTSTR pszStrData, size_t nLength)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
size_t nNewLength = m_nLength + nLength;
|
||||
EnsureSize(nNewLength + 1, true);
|
||||
_tcsncpy_s(m_pszData + m_nLength, nLength + 1, pszStrData, nLength);
|
||||
m_nLength = nNewLength;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
*/
|
||||
void CStrStream::InitData(PCSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
int nSize = MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, NULL, 0);
|
||||
_ASSERTE(nSize > 0);
|
||||
InitBuffer(nSize);
|
||||
MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, m_pszData, nSize);
|
||||
m_nLength = nSize - 1;
|
||||
}
|
||||
else
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
*/
|
||||
void CStrStream::CopyData(PCSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
int nSize = MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, NULL, 0);
|
||||
_ASSERTE(nSize > 0);
|
||||
EnsureSize(nSize, false);
|
||||
MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, m_pszData, nSize);
|
||||
m_nLength = nSize - 1;
|
||||
}
|
||||
else
|
||||
Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
*/
|
||||
void CStrStream::AppendData(PCSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
int nSize = MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, NULL, 0);
|
||||
_ASSERTE(nSize > 0);
|
||||
size_t nNewSize = m_nLength + nSize;
|
||||
EnsureSize(nNewSize, true);
|
||||
MultiByteToWideChar(CP_ACP, 0, pszStrData, -1, m_pszData + m_nLength, nSize);
|
||||
m_nLength = nNewSize - 1;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
*/
|
||||
void CStrStream::InitData(PCWSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
size_t nSize = WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, NULL, 0, NULL, NULL);
|
||||
_ASSERTE(nSize > 0);
|
||||
InitBuffer(nSize);
|
||||
WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, m_pszData, (int)nSize, NULL, NULL);
|
||||
m_nLength = nSize - 1;
|
||||
}
|
||||
else
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
*/
|
||||
void CStrStream::CopyData(PCWSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
size_t nSize = WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, NULL, 0, NULL, NULL);
|
||||
_ASSERTE(nSize > 0);
|
||||
EnsureSize(nSize, false);
|
||||
WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, m_pszData, (int)nSize, NULL, NULL);
|
||||
m_nLength = nSize - 1;
|
||||
}
|
||||
else
|
||||
Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - data source.
|
||||
*/
|
||||
void CStrStream::AppendData(PCWSTR pszStrData)
|
||||
{
|
||||
if (pszStrData && *pszStrData)
|
||||
{
|
||||
size_t nSize = WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, NULL, 0, NULL, NULL);
|
||||
_ASSERTE(nSize > 0);
|
||||
size_t nNewSize = m_nLength + nSize;
|
||||
EnsureSize(nNewSize, true);
|
||||
WideCharToMultiByte(CP_ACP, 0, pszStrData, -1, m_pszData + m_nLength, (int)nSize, NULL, NULL);
|
||||
m_nLength = nNewSize - 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @return object string buffer.
|
||||
* @note The caller is responsible to free returned string buffer.
|
||||
*/
|
||||
PTSTR CStrStream::Detach(void)
|
||||
{
|
||||
PTSTR pszData = m_pszData;
|
||||
InitBuffer();
|
||||
return pszData;
|
||||
}
|
||||
|
||||
void CStrStream::Reset(void)
|
||||
{
|
||||
if (m_pszData)
|
||||
{
|
||||
*m_pszData = _T('\0');
|
||||
m_nLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CStrStream::Free(void)
|
||||
{
|
||||
if (m_pszData)
|
||||
{
|
||||
delete[] m_pszData;
|
||||
InitBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - start position.
|
||||
* @param nLength - length of the extracted string.
|
||||
*/
|
||||
void CStrStream::ValidateIndex(size_t nPosition, size_t& nLength) const
|
||||
{
|
||||
_ASSERTE(nPosition <= m_nLength);
|
||||
if (nPosition > m_nLength)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
size_t nMaxLength = m_nLength - nPosition;
|
||||
if (nLength == MAXSIZE_T)
|
||||
nLength = nMaxLength;
|
||||
else
|
||||
{
|
||||
_ASSERTE(nLength <= nMaxLength);
|
||||
if (nLength > nMaxLength)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - string buffer that receives the data.
|
||||
* @param nPosition - start position.
|
||||
* @param nLength - length of the extracted string.
|
||||
*/
|
||||
void CStrStream::Substring(CStrHolder& rStrHolder, size_t nPosition, size_t nLength) const
|
||||
{
|
||||
ValidateIndex(nPosition, nLength);
|
||||
size_t nEndPosition = nPosition + nLength;
|
||||
TCHAR chData = m_pszData[nEndPosition];
|
||||
m_pszData[nEndPosition] = _T('\0');
|
||||
rStrHolder = m_pszData + nPosition;
|
||||
m_pszData[nEndPosition] = chData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszSubstring - inserted string buffer.
|
||||
* @param nPosition - start position.
|
||||
* @param nLength - length of the inserted string.
|
||||
*/
|
||||
void CStrStream::Insert(PCTSTR pszSubstring, size_t nPosition, size_t nLength)
|
||||
{
|
||||
ValidateIndex(nPosition);
|
||||
size_t nNewLength = m_nLength + nLength;
|
||||
EnsureSize(nNewLength + 1, true);
|
||||
size_t nNextPosition = nPosition + nLength;
|
||||
size_t nNextLength = m_nLength - nPosition;
|
||||
MoveMemory(m_pszData + nNextPosition, m_pszData + nPosition, (nNextLength + 1) * sizeof(TCHAR));
|
||||
MoveMemory(m_pszData + nPosition, pszSubstring, nLength * sizeof(TCHAR));
|
||||
m_nLength = nNewLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - start position.
|
||||
* @param nLength - length of the extracted string.
|
||||
*/
|
||||
void CStrStream::Delete(size_t nPosition, size_t nLength)
|
||||
{
|
||||
ValidateIndex(nPosition, nLength);
|
||||
size_t nNewLength = m_nLength - nLength;
|
||||
MoveMemory(m_pszData + nPosition, m_pszData + nLength, (nNewLength + 1) * sizeof(TCHAR));
|
||||
m_nLength = nNewLength;
|
||||
}
|
||||
|
||||
void CStrStream::Trim(void)
|
||||
{
|
||||
TrimSpaces(m_pszData);
|
||||
m_nLength = _tcslen(m_pszData);
|
||||
}
|
||||
552
third-party/BugTrap-1.3-57bd515/source/StrStream.h
vendored
Normal file
552
third-party/BugTrap-1.3-57bd515/source/StrStream.h
vendored
Normal file
|
|
@ -0,0 +1,552 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: String (in-memory) stream class.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class CStrHolder;
|
||||
|
||||
/// Dynamic string builder.
|
||||
class CStrStream
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CStrStream(void);
|
||||
/// Initialize the object.
|
||||
explicit CStrStream(size_t nSize);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream(PCSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream(PCWSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream(const CStrHolder& rStrHolder);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream(const CStrStream& rStrStream);
|
||||
/// Destroy the object.
|
||||
~CStrStream(void);
|
||||
/// Get string data.
|
||||
operator PCTSTR(void) const;
|
||||
/// Get string length.
|
||||
size_t GetLength(void) const;
|
||||
/// Return true if string is empty.
|
||||
bool IsEmpty(void) const;
|
||||
/// Get string character.
|
||||
TCHAR operator[](size_t nPosition) const;
|
||||
/// Get/set string character.
|
||||
TCHAR& operator[](size_t nPosition);
|
||||
/// Get string character.
|
||||
TCHAR GetAt(size_t nPosition) const;
|
||||
/// Set string character.
|
||||
void SetAt(size_t nPosition, TCHAR chData);
|
||||
/// Extract substring from the stream.
|
||||
void Substring(CStrHolder& rStrHolder, size_t nPosition, size_t nLength = MAXSIZE_T) const;
|
||||
/// Extract substring from the stream.
|
||||
void Substring(CStrStream& rStrStream, size_t nPosition, size_t nLength = MAXSIZE_T) const;
|
||||
/// Insert single character to the stream.
|
||||
void Insert(TCHAR chData, size_t nPosition);
|
||||
/// Insert substring to the stream.
|
||||
void Insert(PCTSTR pszSubstring, size_t nPosition);
|
||||
/// Insert substring to the stream.
|
||||
void Insert(const CStrHolder& rStrHolder, size_t nPosition);
|
||||
/// Insert substring to the stream.
|
||||
void Insert(const CStrStream& rStrStream, size_t nPosition);
|
||||
/// Delete substring from the string.
|
||||
void Delete(size_t nPosition, size_t nLength = MAXSIZE_T);
|
||||
/// Trim a string.
|
||||
void Trim(void);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream& operator=(CHAR chData);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream& operator=(WCHAR chData);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream& operator=(PCSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream& operator=(PCWSTR pszStrData);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream& operator=(const CStrHolder& rStrHolder);
|
||||
/// Makes a copy of string data.
|
||||
CStrStream& operator=(const CStrStream& rStrStream);
|
||||
/// Appends data to stream.
|
||||
CStrStream& operator<<(CHAR chData);
|
||||
/// Appends data to stream.
|
||||
CStrStream& operator<<(WCHAR chData);
|
||||
/// Appends data to stream.
|
||||
CStrStream& operator<<(PCSTR pszStrData);
|
||||
/// Appends data to stream.
|
||||
CStrStream& operator<<(PCWSTR pszStrData);
|
||||
/// Appends data to stream.
|
||||
CStrStream& operator<<(const CStrHolder& rStrHolder);
|
||||
/// Appends data to stream.
|
||||
CStrStream& operator<<(const CStrStream& rStrStream);
|
||||
/// Detach string data from the object.
|
||||
PTSTR Detach(void);
|
||||
/// Reset stream contents.
|
||||
void Reset(void);
|
||||
/// Free stream object memory.
|
||||
void Free(void);
|
||||
/// Object comparison.
|
||||
friend bool operator==(const CStrStream& rStrStream1, const CStrStream& rStrStream2);
|
||||
/// Object comparison.
|
||||
friend bool operator!=(const CStrStream& rStrStream1, const CStrStream& rStrStream2);
|
||||
/// Object comparison.
|
||||
friend bool operator<(const CStrStream& rStrStream1, const CStrStream& rStrStream2);
|
||||
/// Object comparison.
|
||||
friend bool operator<=(const CStrStream& rStrStream1, const CStrStream& rStrStream2);
|
||||
/// Object comparison.
|
||||
friend bool operator>(const CStrStream& rStrStream1, const CStrStream& rStrStream2);
|
||||
/// Object comparison.
|
||||
friend bool operator>=(const CStrStream& rStrStream1, const CStrStream& rStrStream2);
|
||||
|
||||
private:
|
||||
/// Clear internal data.
|
||||
void InitBuffer(void);
|
||||
/// Initialize new string.
|
||||
void InitBuffer(size_t nSize);
|
||||
/// Reallocates string buffer if necessary.
|
||||
void EnsureSize(size_t nSize, bool bAdaptiveGrowth);
|
||||
/// Initialize new string.
|
||||
void InitData(PCTSTR pszStrData, size_t nLength);
|
||||
/// Copy string into the existing buffer.
|
||||
void CopyData(PCTSTR pszStrData, size_t nLength);
|
||||
/// Append string to the existing data.
|
||||
void AppendData(PCTSTR pszStrData, size_t nLength);
|
||||
#ifdef _UNICODE
|
||||
/// Initialize new string.
|
||||
void InitData(PCSTR pszStrData);
|
||||
/// Copy string into the existing buffer.
|
||||
void CopyData(PCSTR pszStrData);
|
||||
/// Append string to the existing data.
|
||||
void AppendData(PCSTR pszStrData);
|
||||
#else
|
||||
/// Initialize new string.
|
||||
void InitData(PCWSTR pszStrData);
|
||||
/// Copy string into existing buffer.
|
||||
void CopyData(PCWSTR pszStrData);
|
||||
/// Append string to existing data.
|
||||
void AppendData(PCWSTR pszStrData);
|
||||
#endif
|
||||
/// Insert substring to the stream.
|
||||
void Insert(PCTSTR pszSubstring, size_t nPosition, size_t nLength);
|
||||
/// Validate string position.
|
||||
void ValidateIndex(size_t nPosition) const;
|
||||
/// Validate string position and length.
|
||||
void ValidateIndex(size_t nPosition, size_t& nLength) const;
|
||||
|
||||
/// Stream data data.
|
||||
PTSTR m_pszData;
|
||||
/// String length.
|
||||
size_t m_nLength;
|
||||
/// Buffer size.
|
||||
size_t m_nSize;
|
||||
};
|
||||
|
||||
inline CStrStream::CStrStream(void)
|
||||
{
|
||||
InitBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nSize - initial buffer size.
|
||||
*/
|
||||
inline CStrStream::CStrStream(size_t nSize)
|
||||
{
|
||||
InitBuffer(nSize);
|
||||
}
|
||||
|
||||
inline CStrStream::~CStrStream(void)
|
||||
{
|
||||
delete[] m_pszData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return stream length.
|
||||
*/
|
||||
inline size_t CStrStream::GetLength(void) const
|
||||
{
|
||||
return m_nLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if string is empty.
|
||||
*/
|
||||
inline bool CStrStream::IsEmpty(void) const
|
||||
{
|
||||
return (m_nLength == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return pointer to stream buffer.
|
||||
*/
|
||||
inline CStrStream::operator PCTSTR(void) const
|
||||
{
|
||||
return (m_pszData ? m_pszData : _T(""));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - string data to copy.
|
||||
*/
|
||||
inline CStrStream::CStrStream(PCSTR pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
InitData(pszStrData);
|
||||
#else
|
||||
InitData(pszStrData, strlen(pszStrData));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - string data to copy.
|
||||
*/
|
||||
inline CStrStream::CStrStream(PCWSTR pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
InitData(pszStrData, wcslen(pszStrData));
|
||||
#else
|
||||
InitData(pszStrData);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - another stream object.
|
||||
*/
|
||||
inline CStrStream::CStrStream(const CStrStream& rStrStream)
|
||||
{
|
||||
InitData(rStrStream.m_pszData, rStrStream.m_nLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chData - character data to copy.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator=(CHAR chData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WCHAR chTemp;
|
||||
MultiByteToWideChar(CP_ACP, 0, &chData, 1, &chTemp, 1);
|
||||
CopyData(&chTemp, 1);
|
||||
#else
|
||||
CopyData(&chData, 1);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chData - character data to copy.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator=(WCHAR chData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
CopyData(&chData, 1);
|
||||
#else
|
||||
CHAR chTemp;
|
||||
WideCharToMultiByte(CP_ACP, 0, &chData, 1, &chTemp, 1, NULL, NULL);
|
||||
CopyData(&chTemp, 1);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @param pszStrData - string data to copy.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator=(PCSTR pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
CopyData(pszStrData);
|
||||
#else
|
||||
CopyData(pszStrData, strlen(pszStrData));
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - string data to copy.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator=(PCWSTR pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
CopyData(pszStrData, wcslen(pszStrData));
|
||||
#else
|
||||
CopyData(pszStrData);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - another stream object.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator=(const CStrStream& rStrStream)
|
||||
{
|
||||
if (this != &rStrStream)
|
||||
CopyData(rStrStream.m_pszData, rStrStream.m_nLength);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chData - character data to append.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator<<(CHAR chData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
WCHAR chTemp;
|
||||
MultiByteToWideChar(CP_ACP, 0, &chData, 1, &chTemp, 1);
|
||||
AppendData(&chTemp, 1);
|
||||
#else
|
||||
AppendData(&chData, 1);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chData - character data to append.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator<<(WCHAR chData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
AppendData(&chData, 1);
|
||||
#else
|
||||
CHAR chTemp;
|
||||
WideCharToMultiByte(CP_ACP, 0, &chData, 1, &chTemp, 1, NULL, NULL);
|
||||
AppendData(&chTemp, 1);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - string data to append.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator<<(PCSTR pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
AppendData(pszStrData);
|
||||
#else
|
||||
AppendData(pszStrData, strlen(pszStrData));
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszStrData - string data to append.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator<<(PCWSTR pszStrData)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
AppendData(pszStrData, wcslen(pszStrData));
|
||||
#else
|
||||
AppendData(pszStrData);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - another stream object.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator<<(const CStrStream& rStrStream)
|
||||
{
|
||||
AppendData(rStrStream.m_pszData, rStrStream.m_nLength);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - character position within the string.
|
||||
* @return character value.
|
||||
*/
|
||||
inline TCHAR CStrStream::GetAt(size_t nPosition) const
|
||||
{
|
||||
ValidateIndex(nPosition);
|
||||
return m_pszData[nPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - character position within the string.
|
||||
* @return character value.
|
||||
*/
|
||||
inline TCHAR CStrStream::operator[](size_t nPosition) const
|
||||
{
|
||||
ValidateIndex(nPosition);
|
||||
return m_pszData[nPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - character position within the string.
|
||||
* @param chData - character value.
|
||||
*/
|
||||
inline void CStrStream::SetAt(size_t nPosition, TCHAR chData)
|
||||
{
|
||||
ValidateIndex(nPosition);
|
||||
m_pszData[nPosition] = chData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - character position within the string.
|
||||
* @return reference to character value.
|
||||
*/
|
||||
inline TCHAR& CStrStream::operator[](size_t nPosition)
|
||||
{
|
||||
ValidateIndex(nPosition);
|
||||
return m_pszData[nPosition];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - string buffer that receives the data.
|
||||
* @param nPosition - start position.
|
||||
* @param nLength - length of the extracted string.
|
||||
*/
|
||||
inline void CStrStream::Substring(CStrStream& rStrStream, size_t nPosition, size_t nLength) const
|
||||
{
|
||||
ValidateIndex(nPosition, nLength);
|
||||
rStrStream.CopyData(m_pszData + nPosition, nLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nPosition - start position.
|
||||
*/
|
||||
inline void CStrStream::ValidateIndex(size_t nPosition) const
|
||||
{
|
||||
_ASSERTE(nPosition < m_nLength);
|
||||
if (nPosition >= m_nLength)
|
||||
RaiseException(STATUS_ARRAY_BOUNDS_EXCEEDED, 0, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chData - character value.
|
||||
* @param nPosition - start position.
|
||||
*/
|
||||
inline void CStrStream::Insert(TCHAR chData, size_t nPosition)
|
||||
{
|
||||
Insert(&chData, nPosition, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszSubstring - inserted string buffer.
|
||||
* @param nPosition - start position.
|
||||
*/
|
||||
inline void CStrStream::Insert(PCTSTR pszSubstring, size_t nPosition)
|
||||
{
|
||||
Insert(pszSubstring, nPosition, _tcslen(pszSubstring));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream - inserted string buffer.
|
||||
* @param nPosition - start position.
|
||||
*/
|
||||
inline void CStrStream::Insert(const CStrStream& rStrStream, size_t nPosition)
|
||||
{
|
||||
Insert(rStrStream.m_pszData, nPosition, rStrStream.m_nLength);
|
||||
}
|
||||
|
||||
#include "StrHolder.h"
|
||||
|
||||
/**
|
||||
* @param rStrHolder - string data to copy.
|
||||
*/
|
||||
inline CStrStream::CStrStream(const CStrHolder& rStrHolder)
|
||||
{
|
||||
InitData((PCTSTR)rStrHolder, rStrHolder.GetLength());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - string data to copy.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator=(const CStrHolder& rStrHolder)
|
||||
{
|
||||
CopyData((PCTSTR)rStrHolder, rStrHolder.GetLength());
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - string data to append.
|
||||
* @return reference to itself.
|
||||
*/
|
||||
inline CStrStream& CStrStream::operator<<(const CStrHolder& rStrHolder)
|
||||
{
|
||||
AppendData((PCTSTR)rStrHolder, rStrHolder.GetLength());
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrHolder - inserted string buffer.
|
||||
* @param nPosition - start position.
|
||||
*/
|
||||
inline void CStrStream::Insert(const CStrHolder& rStrHolder, size_t nPosition)
|
||||
{
|
||||
Insert((PCTSTR)rStrHolder, nPosition, rStrHolder.GetLength());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream1 - 1st object.
|
||||
* @param rStrStream2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator==(const CStrStream& rStrStream1, const CStrStream& rStrStream2)
|
||||
{
|
||||
return (_tcscmp(rStrStream1.m_pszData, rStrStream2.m_pszData) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream1 - 1st object.
|
||||
* @param rStrStream2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator!=(const CStrStream& rStrStream1, const CStrStream& rStrStream2)
|
||||
{
|
||||
return (_tcscmp(rStrStream1.m_pszData, rStrStream2.m_pszData) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream1 - 1st object.
|
||||
* @param rStrStream2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator<(const CStrStream& rStrStream1, const CStrStream& rStrStream2)
|
||||
{
|
||||
return (_tcscmp(rStrStream1.m_pszData, rStrStream2.m_pszData) < 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream1 - 1st object.
|
||||
* @param rStrStream2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator<=(const CStrStream& rStrStream1, const CStrStream& rStrStream2)
|
||||
{
|
||||
return (_tcscmp(rStrStream1.m_pszData, rStrStream2.m_pszData) <= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream1 - 1st object.
|
||||
* @param rStrStream2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator>(const CStrStream& rStrStream1, const CStrStream& rStrStream2)
|
||||
{
|
||||
return (_tcscmp(rStrStream1.m_pszData, rStrStream2.m_pszData) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rStrStream1 - 1st object.
|
||||
* @param rStrStream2 - 2nd object.
|
||||
* @return comparison result.
|
||||
*/
|
||||
inline bool operator>=(const CStrStream& rStrStream1, const CStrStream& rStrStream2)
|
||||
{
|
||||
return (_tcscmp(rStrStream1.m_pszData, rStrStream2.m_pszData) >= 0);
|
||||
}
|
||||
22
third-party/BugTrap-1.3-57bd515/source/Stream.h
vendored
Normal file
22
third-party/BugTrap-1.3-57bd515/source/Stream.h
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Input & output stream.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "InputStream.h"
|
||||
#include "OutputStream.h"
|
||||
|
||||
class CStream : public CInputStream, public COutputStream
|
||||
{
|
||||
};
|
||||
3271
third-party/BugTrap-1.3-57bd515/source/SymEngine.cpp
vendored
Normal file
3271
third-party/BugTrap-1.3-57bd515/source/SymEngine.cpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
826
third-party/BugTrap-1.3-57bd515/source/SymEngine.h
vendored
Normal file
826
third-party/BugTrap-1.3-57bd515/source/SymEngine.h
vendored
Normal file
|
|
@ -0,0 +1,826 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Low-level wrapper for Debug Help API.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
* Note: Portions of this code are based on Bugslayer code developed by John Robbins.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "EnumProcess.h"
|
||||
#include "StrStream.h"
|
||||
#include "Encoding.h"
|
||||
#include "XmlWriter.h"
|
||||
#include "SmartPtr.h"
|
||||
#include "InterfacePtr.h"
|
||||
|
||||
#ifdef _MANAGED
|
||||
#include "NetThunks.h"
|
||||
#endif
|
||||
|
||||
/// Type definition of pointer to SymGetOptions() function.
|
||||
typedef DWORD (WINAPI *PFSymGetOptions)(VOID);
|
||||
/// Type definition of pointer to SymSetOptions() function.
|
||||
typedef DWORD (WINAPI *PFSymSetOptions)(DWORD SymOptions);
|
||||
/// Type definition of pointer to SymInitialize() function.
|
||||
typedef BOOL (WINAPI *PFSymInitialize)(HANDLE hProcess, PSTR UserSearchPath, BOOL fInvadeProcess);
|
||||
/// Type definition of pointer to SymCleanup() function.
|
||||
typedef BOOL (WINAPI *PFSymCleanup)(HANDLE hProcess);
|
||||
/// Type definition of pointer to SymGetModuleBase64() function.
|
||||
typedef DWORD64 (WINAPI *PFSymGetModuleBase64)(HANDLE hProcess, DWORD64 dwAddr);
|
||||
/// Type definition of pointer to SymFromAddr() function.
|
||||
typedef BOOL (WINAPI *PFSymFromAddr)(HANDLE hProcess, DWORD64 dwAddr, PDWORD64 pdwDisplacement, PSYMBOL_INFO Symbol);
|
||||
/// Type definition of pointer to SymGetLineFromAddr64() function.
|
||||
typedef BOOL (WINAPI *PFSymGetLineFromAddr64)(HANDLE hProcess, DWORD64 dwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line);
|
||||
/// Type definition of pointer to StackWalk64() function.
|
||||
typedef BOOL (WINAPI *PFStackWalk64)(DWORD dwMachineType, HANDLE hProcess, HANDLE hThread, LPSTACKFRAME64 StackFrame, PVOID ContextRecord, PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
|
||||
/// Type definition of pointer to SymFunctionTableAccess64() function.
|
||||
typedef PVOID (WINAPI *PFSymFunctionTableAccess64)(HANDLE hProcess, DWORD64 AddrBase);
|
||||
/// Type definition of pointer to MiniDumpWriteDump() function.
|
||||
typedef BOOL (WINAPI *PFMiniDumpWriteDump)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserEncoderParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
/// Opens an existing thread object.
|
||||
typedef HANDLE (WINAPI *PFOpenThread)(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId);
|
||||
|
||||
/// Low-level wrapper for Debug Help API.
|
||||
class CSymEngine
|
||||
{
|
||||
public:
|
||||
/// Type of exception.
|
||||
enum EXCEPTION_TYPE
|
||||
{
|
||||
/// Not an exception.
|
||||
NO_EXCEPTION,
|
||||
/// Win32 exception.
|
||||
WIN32_EXCEPTION,
|
||||
/// C++ exception.
|
||||
CPP_EXCEPTION,
|
||||
#ifdef _MANAGED
|
||||
/// .NET exception.
|
||||
NET_EXCEPTION
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Screen-shot object.
|
||||
class CScreenShot
|
||||
{
|
||||
public:
|
||||
/// Create the object.
|
||||
CScreenShot(void);
|
||||
/// Destroy the object.
|
||||
~CScreenShot(void);
|
||||
/// Write screen-shot to file.
|
||||
BOOL WriteScreenShot(PCTSTR pszFileName);
|
||||
|
||||
private:
|
||||
/// Protects the class from being accidentally copied.
|
||||
CScreenShot(const CScreenShot& rScreenShot);
|
||||
/// Protects the class from being accidentally copied.
|
||||
CScreenShot& operator=(const CScreenShot& rScreenShot);
|
||||
|
||||
/// Per-monitor bitmap information.
|
||||
struct CBitmapInfo
|
||||
{
|
||||
public:
|
||||
/// Initialize an object.
|
||||
CBitmapInfo(void);
|
||||
/// De-initialize the object.
|
||||
~CBitmapInfo(void);
|
||||
/// Free allocated memory; reset all member variables.
|
||||
void Free(void);
|
||||
|
||||
/// Bitmap information.
|
||||
PBITMAPINFO m_pBmpInfo;
|
||||
/// Bitmap bits.
|
||||
PBYTE m_pBitsArray;
|
||||
/// Bitmap header size.
|
||||
DWORD m_dwBmpHdrSize;
|
||||
/// Image size.
|
||||
DWORD m_dwBitsArraySize;
|
||||
|
||||
private:
|
||||
/// Destroy allocated objects.
|
||||
void Destroy(void);
|
||||
};
|
||||
|
||||
/// An array of bitmaps.
|
||||
CBitmapInfo* m_arrBitmaps;
|
||||
/// Number of monitors.
|
||||
DWORD m_dwNumMonitors;
|
||||
};
|
||||
|
||||
/// Smart pointer to the screen-shot.
|
||||
typedef CSmartPtr<CScreenShot, CPtrLinkEngine<CScreenShot, CPtrTraits> > CScreenShotPtr;
|
||||
|
||||
/// Symbolic engine parameters.
|
||||
class CEngineParams
|
||||
{
|
||||
public:
|
||||
/// Initialize member variables.
|
||||
CEngineParams(void);
|
||||
/// Initialize member variables.
|
||||
CEngineParams(PEXCEPTION_POINTERS pExceptionPointers, EXCEPTION_TYPE eExceptionType);
|
||||
|
||||
/// Current exception information.
|
||||
PEXCEPTION_POINTERS m_pExceptionPointers;
|
||||
/// COM error information.
|
||||
CInterfacePtr<IErrorInfo> m_pErrorInfo;
|
||||
/// System error code.
|
||||
DWORD m_dwLastError;
|
||||
/// Type of the exception.
|
||||
EXCEPTION_TYPE m_eExceptionType;
|
||||
/// Date and time of the crash.
|
||||
SYSTEMTIME m_DateTime;
|
||||
/// Screen shot data.
|
||||
CScreenShotPtr m_pScreenShot;
|
||||
|
||||
private:
|
||||
/// Make a screen shot.
|
||||
void MakeScreenShot(void);
|
||||
};
|
||||
|
||||
/// Stack entry information.
|
||||
struct CStackTraceEntry
|
||||
{
|
||||
/// Initialize data members.
|
||||
CStackTraceEntry(void);
|
||||
/// Module name that contains the entry.
|
||||
TCHAR m_szModule[MAX_PATH];
|
||||
/// Address of current instruction.
|
||||
TCHAR m_szAddress[32];
|
||||
/// Function where current instruction is located.
|
||||
TCHAR m_szFunctionName[512];
|
||||
/// Byte offset from the beginning of the function.
|
||||
TCHAR m_szFunctionOffset[32];
|
||||
/// User-friendly function name and offset.
|
||||
TCHAR m_szFunctionInfo[512];
|
||||
/// Name of source file that contains the entry.
|
||||
TCHAR m_szSourceFile[MAX_PATH];
|
||||
/// Number of line in source file.
|
||||
TCHAR m_szLineNumber[16];
|
||||
/// Byte offset from the beginning of the line.
|
||||
TCHAR m_szLineOffset[32];
|
||||
/// User-friendly line number and offset.
|
||||
TCHAR m_szLineInfo[64];
|
||||
};
|
||||
|
||||
private:
|
||||
/// Context record of stack walk operations.
|
||||
struct CStackWalkContext
|
||||
{
|
||||
/// Initialize the object.
|
||||
CStackWalkContext(void);
|
||||
/// Current stack frame information used by stack tracing.
|
||||
STACKFRAME64 m_stFrame;
|
||||
/// Current context information used by stack tracing.
|
||||
CONTEXT m_context;
|
||||
/// Handle of examined thread.
|
||||
HANDLE m_hThread;
|
||||
};
|
||||
|
||||
/// Operating system information.
|
||||
struct COsInfo
|
||||
{
|
||||
/// Initialize the object.
|
||||
COsInfo(void);
|
||||
/// Windows version.
|
||||
PCTSTR m_pszWinVersion;
|
||||
/// Service pack version.
|
||||
TCHAR m_szSPVersion[128];
|
||||
/// Build number.
|
||||
TCHAR m_szBuildNumber[16];
|
||||
#ifdef _MANAGED
|
||||
/// CLR Version.
|
||||
WCHAR m_szNetVersion[64];
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Error information.
|
||||
struct CErrorInfo : public CStackTraceEntry
|
||||
{
|
||||
/// Initialize the object.
|
||||
CErrorInfo(void);
|
||||
/// What happened?
|
||||
PCTSTR m_pszWhat;
|
||||
/// Process file name.
|
||||
TCHAR m_szProcessName[MAX_PATH];
|
||||
/// Process ID.
|
||||
TCHAR m_szProcessID[16];
|
||||
};
|
||||
|
||||
/// CPUs information.
|
||||
struct CCpusInfo
|
||||
{
|
||||
/// Initialize the object.
|
||||
CCpusInfo(void);
|
||||
/// Processors architecture.
|
||||
PCTSTR m_pszCpuArch;
|
||||
/// Number of processors.
|
||||
DWORD m_dwNumCpus;
|
||||
};
|
||||
|
||||
/// CPU information.
|
||||
struct CCpuInfo
|
||||
{
|
||||
/// Initialize the object.
|
||||
CCpuInfo(void);
|
||||
/// Processor identifier.
|
||||
TCHAR m_szCpuId[128];
|
||||
/// Processor speed.
|
||||
TCHAR m_szCpuSpeed[16];
|
||||
/// Processor description.
|
||||
TCHAR m_szCpuDescription[128];
|
||||
};
|
||||
|
||||
/// Memory information.
|
||||
struct CMemInfo
|
||||
{
|
||||
/// Initialize the object.
|
||||
CMemInfo(void);
|
||||
/// Current memory load
|
||||
TCHAR m_szMemoryLoad[8];
|
||||
/// Total physical memory
|
||||
TCHAR m_szTotalPhys[16];
|
||||
/// Available physical memory
|
||||
TCHAR m_szAvailPhys[16];
|
||||
/// Total page file memory
|
||||
TCHAR m_szTotalPageFile[16];
|
||||
/// Available page file memory
|
||||
TCHAR m_szAvailPageFile[16];
|
||||
};
|
||||
|
||||
/// System error information.
|
||||
struct CSysErrorInfo
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CSysErrorInfo(void);
|
||||
/// De-initialize the object.
|
||||
~CSysErrorInfo(void);
|
||||
/// Copy the object.
|
||||
CSysErrorInfo(const CSysErrorInfo& rErrorInfo);
|
||||
/// Copy the object.
|
||||
CSysErrorInfo& operator=(const CSysErrorInfo& rErrorInfo);
|
||||
/// Last error code.
|
||||
TCHAR m_szErrorCode[16];
|
||||
/// Error description.
|
||||
PTSTR m_pszMessageBuffer;
|
||||
|
||||
private:
|
||||
/// Free member variables.
|
||||
void FreeData(void);
|
||||
/// Copy member variables.
|
||||
void CopyData(const CSysErrorInfo& rErrorInfo);
|
||||
};
|
||||
|
||||
/// COM error information.
|
||||
struct CComErrorInfo
|
||||
{
|
||||
/// A textual description of the error.
|
||||
CStrHolder m_strDescription;
|
||||
/// The path of the help file that describes the error.
|
||||
CStrHolder m_strHelpFile;
|
||||
/// The programmatic identifier (ProgID) for the class or application that returned the error.
|
||||
CStrHolder m_strSource;
|
||||
/// The globally unique identifier (GUID) for the interface that defined the error.
|
||||
CStrHolder m_strGuid;
|
||||
};
|
||||
|
||||
/// Keeps registers values in string format.
|
||||
struct CRegistersValues
|
||||
{
|
||||
/// Initialize the object.
|
||||
CRegistersValues(void);
|
||||
#if defined _M_IX86
|
||||
/// EAX register.
|
||||
TCHAR m_szEax[16];
|
||||
/// EBX register.
|
||||
TCHAR m_szEbx[16];
|
||||
/// ECX register.
|
||||
TCHAR m_szEcx[16];
|
||||
/// EDX register.
|
||||
TCHAR m_szEdx[16];
|
||||
/// ESI register.
|
||||
TCHAR m_szEsi[16];
|
||||
/// EDI register.
|
||||
TCHAR m_szEdi[16];
|
||||
/// ESP register.
|
||||
TCHAR m_szEsp[16];
|
||||
/// EBP register.
|
||||
TCHAR m_szEbp[16];
|
||||
/// EIP register.
|
||||
TCHAR m_szEip[16];
|
||||
/// CS register.
|
||||
TCHAR m_szSegCs[16];
|
||||
/// DS register.
|
||||
TCHAR m_szSegDs[16];
|
||||
/// SS register.
|
||||
TCHAR m_szSegSs[16];
|
||||
/// ES register.
|
||||
TCHAR m_szSegEs[16];
|
||||
/// FS register.
|
||||
TCHAR m_szSegFs[16];
|
||||
/// GS register.
|
||||
TCHAR m_szSegGs[16];
|
||||
/// EFLAGS register.
|
||||
TCHAR m_szEFlags[16];
|
||||
#elif defined _M_X64
|
||||
/// RAX register.
|
||||
TCHAR m_szRax[32];
|
||||
/// RBX register.
|
||||
TCHAR m_szRbx[32];
|
||||
/// RCX register.
|
||||
TCHAR m_szRcx[32];
|
||||
/// RDX register.
|
||||
TCHAR m_szRdx[32];
|
||||
/// RSI register.
|
||||
TCHAR m_szRsi[32];
|
||||
/// RDI register.
|
||||
TCHAR m_szRdi[32];
|
||||
/// RSP register.
|
||||
TCHAR m_szRsp[32];
|
||||
/// RBP register.
|
||||
TCHAR m_szRbp[32];
|
||||
/// RIP register.
|
||||
TCHAR m_szRip[32];
|
||||
/// CS register.
|
||||
TCHAR m_szSegCs[16];
|
||||
/// DS register.
|
||||
TCHAR m_szSegDs[16];
|
||||
/// SS register.
|
||||
TCHAR m_szSegSs[16];
|
||||
/// ES register.
|
||||
TCHAR m_szSegEs[16];
|
||||
/// FS register.
|
||||
TCHAR m_szSegFs[16];
|
||||
/// GS register.
|
||||
TCHAR m_szSegGs[16];
|
||||
/// EFLAGS register.
|
||||
TCHAR m_szEFlags[16];
|
||||
#else
|
||||
#error CPU architecture is not supported.
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Handle to the process for which symbols are to be maintained.
|
||||
HANDLE m_hSymProcess;
|
||||
/// Handle of DbgHelp.dll module.
|
||||
HINSTANCE m_hDbgHelpDll;
|
||||
/// Handle of Kernel32.dll module.
|
||||
HINSTANCE m_hKernelDll;
|
||||
/// Current exception information.
|
||||
PEXCEPTION_POINTERS m_pExceptionPointers;
|
||||
/// Date and time of the crash.
|
||||
SYSTEMTIME m_DateTime;
|
||||
/// Type of the exception.
|
||||
EXCEPTION_TYPE m_eExceptionType;
|
||||
/// Exception address corrected according to C++ exception information.
|
||||
DWORD64 m_dwExceptionAddress;
|
||||
/// Start context exception information.
|
||||
CONTEXT m_StartExceptionContext;
|
||||
/// COM error information.
|
||||
CInterfacePtr<IErrorInfo> m_pErrorInfo;
|
||||
/// System error code.
|
||||
DWORD m_dwLastError;
|
||||
/// Screen shot data.
|
||||
CScreenShotPtr m_pScreenShot;
|
||||
/// Stack walk context record.
|
||||
CStackWalkContext m_swContext;
|
||||
/// Frame count (in rare cases DbgHelp could produce infinite stack traces).
|
||||
DWORD m_dwFrameCount;
|
||||
|
||||
#ifdef _MANAGED
|
||||
/// Managed stack trace.
|
||||
CNetStackTrace* m_pNetStackTrace;
|
||||
#endif
|
||||
|
||||
/// Pointer to SymGetOptions() function.
|
||||
PFSymGetOptions FSymGetOptions;
|
||||
/// Pointer to SymSetOptions() function.
|
||||
PFSymSetOptions FSymSetOptions;
|
||||
/// Pointer to SymInitialize() function.
|
||||
PFSymInitialize FSymInitialize;
|
||||
/// Pointer to SymCleanup() function.
|
||||
PFSymCleanup FSymCleanup;
|
||||
/// Pointer to SymGetModuleBase64() function.
|
||||
PFSymGetModuleBase64 FSymGetModuleBase64;
|
||||
/// Pointer to SymFromAddr() function.
|
||||
PFSymFromAddr FSymFromAddr;
|
||||
/// Pointer to SymGetLineFromAddr64() function.
|
||||
PFSymGetLineFromAddr64 FSymGetLineFromAddr64;
|
||||
/// Pointer to StackWalk64() function.
|
||||
PFStackWalk64 FStackWalk64;
|
||||
/// Pointer to SymFunctionTableAccess64() function.
|
||||
PFSymFunctionTableAccess64 FSymFunctionTableAccess64;
|
||||
/// Pointer to MiniDumpWriteDump() function.
|
||||
PFMiniDumpWriteDump FMiniDumpWriteDump;
|
||||
/// Pointer to OpenThread() function.
|
||||
PFOpenThread FOpenThread;
|
||||
|
||||
/// Get string representation of system exception code.
|
||||
static PCTSTR ConvertExceptionCodeToString(DWORD dwException);
|
||||
/// Adapter for ReadProcessMemory() function called from StackWalk64() function.
|
||||
static BOOL CALLBACK ReadProcessMemoryProc64(HANDLE hProcess, DWORD64 pBaseAddress, PVOID pBuffer, DWORD dwSize, PDWORD pdwNumberOfBytesRead);
|
||||
/// Safely copy memory blocks.
|
||||
static void SafeCopy(PVOID pDestination, PVOID pSource, DWORD dwSize);
|
||||
/// Add new file to zip archive.
|
||||
static BOOL AddFileToArchive(zipFile hZipFile, PCTSTR pszFilePath, PCTSTR pszFileName);
|
||||
/// Adjust exception stack frame according to C++ exception.
|
||||
BOOL AdjustExceptionStackFrame(void);
|
||||
/// Inittialize stack from the thread/exception context.
|
||||
static void InitStackFrame(LPSTACKFRAME64 pStackFrame, const CONTEXT* pContext);
|
||||
/// Set stack frame structure to initial value.
|
||||
static BOOL GetCurrentThreadContext(PCONTEXT pContext);
|
||||
/// Set stack frame structure to initial value.
|
||||
BOOL InitStackTrace(HANDLE hThread);
|
||||
/// Set stack frame structure to initial value.
|
||||
BOOL InitStackTrace(LPSTACKFRAME64 pStackFrame);
|
||||
/// Get stack trace info for the interrupted thread.
|
||||
void GetWin32StackTrace(CUTF8EncStream& rEncStream, DWORD dwThreadID, HANDLE hThread, PCSTR pszThreadStatus);
|
||||
/// Get stack trace info for the interrupted thread.
|
||||
void GetWin32StackTrace(CXmlWriter& rXmlWriter, DWORD dwThreadID, HANDLE hThread, PCTSTR pszThreadStatus);
|
||||
/// Get error information in XML format.
|
||||
BOOL GetErrorInfo(CXmlWriter& rXmlWriter);
|
||||
#ifdef _MANAGED
|
||||
/// Get error information in XML format.
|
||||
BOOL GetErrorInfo(CXmlWriter& rXmlWriter, CNetStackTrace* pNetStackTrace, gcroot<Exception^> exception, DWORD dwNestedLevel);
|
||||
#endif
|
||||
/// Get register values.
|
||||
void GetRegistersInfo(CXmlWriter& rXmlWriter);
|
||||
/// Get system error information.
|
||||
void GetSysErrorInfo(CXmlWriter& rXmlWriter);
|
||||
/// Get COM error information.
|
||||
void GetComErrorInfo(CXmlWriter& rXmlWriter);
|
||||
/// Get description of system CPUs.
|
||||
void GetCpusInfo(CXmlWriter& rXmlWriter);
|
||||
/// Get OS information.
|
||||
void GetOsInfo(CXmlWriter& rXmlWriter);
|
||||
/// Get system memory information.
|
||||
void GetMemInfo(CXmlWriter& rXmlWriter);
|
||||
#ifdef _MANAGED
|
||||
/// Get stack trace info for interrupted .NET thread.
|
||||
void GetNetStackTrace(CUTF8EncStream& rEncStream);
|
||||
/// Get stack trace info for interrupted .NET thread.
|
||||
void GetNetStackTrace(CXmlWriter& rXmlWriter);
|
||||
#endif
|
||||
/// Get stack trace info for all threads.
|
||||
void GetWin32ThreadsList(CUTF8EncStream& rEncStream, CEnumProcess* pEnumProcess);
|
||||
/// Get stack trace info for all threads.
|
||||
void GetWin32ThreadsList(CXmlWriter& rXmlWriter, CEnumProcess* pEnumProcess);
|
||||
#ifdef _MANAGED
|
||||
/// Get stack trace info for all threads.
|
||||
void GetNetThreadsList(CUTF8EncStream& rEncStream);
|
||||
/// Get stack trace info for all threads.
|
||||
void GetNetThreadsList(CXmlWriter& rXmlWriter);
|
||||
#endif
|
||||
/// Get module list for specified process.
|
||||
void GetModuleList(CUTF8EncStream& rEncStream, CEnumProcess* pEnumProcess, CEnumProcess::CProcessEntry& rProcEntry);
|
||||
/// Get module list for specified process.
|
||||
void GetModuleList(CXmlWriter& rXmlWriter, CEnumProcess* pEnumProcess, CEnumProcess::CProcessEntry& rProcEntry);
|
||||
#ifdef _MANAGED
|
||||
/// Get assemblies list for current process.
|
||||
void GetAssemblyList(CUTF8EncStream& rEncStream);
|
||||
/// Get assemblies list for current process.
|
||||
void GetAssemblyList(CXmlWriter& rXmlWriter);
|
||||
#endif
|
||||
/// Get process info for specified process.
|
||||
void GetProcessList(CUTF8EncStream& rEncStream, CEnumProcess* pEnumProcess);
|
||||
/// Get process info for specified process.
|
||||
void GetProcessList(CXmlWriter& rXmlWriter, CEnumProcess* pEnumProcess);
|
||||
/// Get OS information.
|
||||
static void GetOsInfo(COsInfo& rOsInfo);
|
||||
/// Get description of system CPUs.
|
||||
static void GetCpusInfo(CCpusInfo& rCpusInfo);
|
||||
/// Get description of specific CPU.
|
||||
static BOOL GetCpuInfo(DWORD dwCpuNum, CCpuInfo& rCpuInfo);
|
||||
/// Get system memory information.
|
||||
static void GetMemInfo(CMemInfo& rMemInfo);
|
||||
/// Get system error information.
|
||||
void GetSysErrorInfo(CSysErrorInfo& rErrorInfo);
|
||||
/// Get COM error reason.
|
||||
BOOL GetComErrorInfo(CComErrorInfo& rErrorInfo);
|
||||
/// Get crash location and error reason.
|
||||
BOOL GetErrorInfo(CErrorInfo& rErrorInfo);
|
||||
/// Get string with CPU registers for the crash.
|
||||
void GetRegistersValues(CRegistersValues& rRegVals);
|
||||
/// Get text representation of topmost call stack entry.
|
||||
BOOL GetFirstWin32StackTraceString(CUTF8EncStream& rEncStream, HANDLE hThread = NULL);
|
||||
/// Get text representation of lower call stack entry.
|
||||
BOOL GetNextWin32StackTraceString(CUTF8EncStream& rEncStream);
|
||||
#ifdef _MANAGED
|
||||
/// Get text representation of topmost call stack entry.
|
||||
BOOL GetFirstNetStackTraceString(CUTF8EncStream& rEncStream);
|
||||
/// Get text representation of lower call stack entry.
|
||||
BOOL GetNextNetStackTraceString(CUTF8EncStream& rEncStream);
|
||||
#endif
|
||||
/// Get string with CPU registers for the crash.
|
||||
void GetRegistersString(CUTF8EncStream& rEncStream);
|
||||
/// Get crash location and reason.
|
||||
BOOL GetWin32ErrorString(CUTF8EncStream& rEncStream);
|
||||
#ifdef _MANAGED
|
||||
/// Get crash location and reason.
|
||||
BOOL GetNetErrorString(CUTF8EncStream& rEncStream);
|
||||
/// Get crash location and reason.
|
||||
BOOL GetNetErrorStringEx(CUTF8EncStream& rEncStream);
|
||||
#endif
|
||||
/// Get crash location and reason.
|
||||
BOOL GetErrorString(CUTF8EncStream& rEncStream);
|
||||
/// Get system error description.
|
||||
void GetSysErrorString(CUTF8EncStream& rEncStream);
|
||||
/// Get COM error reason.
|
||||
void GetComErrorString(CUTF8EncStream& rEncStream);
|
||||
/// Get description of system CPUs.
|
||||
static void GetCpuString(CUTF8EncStream& rEncStream);
|
||||
/// Get OS information.
|
||||
static void GetOsString(CUTF8EncStream& rEncStream);
|
||||
/// Get description of system memory.
|
||||
static void GetMemString(CUTF8EncStream& rEncStream);
|
||||
/// Get process environment strings.
|
||||
static void GetEnvironmentStrings(CUTF8EncStream& rEncStream);
|
||||
/// Get process environment strings.
|
||||
static void GetEnvironmentStrings(CXmlWriter& rXmlWriter);
|
||||
/// Get the list of computer IP addresses.
|
||||
static void GetComputerIPs(CStrStream& rStream);
|
||||
/// Get the list of computer IP addresses.
|
||||
static void GetComputerIPs(CUTF8EncStream& rEncStream);
|
||||
/// Get the list of computer IP addresses.
|
||||
static void GetComputerIPs(CXmlWriter& rXmlWriter);
|
||||
/// Get date-time string.
|
||||
void GetDateTime(PTSTR pszDateTime, DWORD dwDateTimeSize);
|
||||
/// Get time-stamp string.
|
||||
void GetTimeStamp(PTSTR pszTimeStamp, DWORD dwTimeStampSize);
|
||||
/// Generate comprehensive text information about the crash.
|
||||
void GetErrorLog(CUTF8EncStream& rEncStream, CEnumProcess* pEnumProcess);
|
||||
/// Generate comprehensive text information about the crash.
|
||||
void GetErrorLog(CXmlWriter& rXmlWriter, CEnumProcess* pEnumProcess);
|
||||
|
||||
/// Protects the class from being accidentally copied.
|
||||
CSymEngine(const CSymEngine& rSymEngine);
|
||||
/// Protects the class from being accidentally copied.
|
||||
CSymEngine& operator=(const CSymEngine& rSymEngine);
|
||||
|
||||
public:
|
||||
/// Initialize the object.
|
||||
explicit CSymEngine(const CEngineParams& rParams);
|
||||
/// Destroy the object.
|
||||
~CSymEngine(void);
|
||||
/// Set engine parameters
|
||||
void SetEngineParameters(const CEngineParams& rParams);
|
||||
/// Reset engine parameters.
|
||||
void ResetEngineParameters(void);
|
||||
/// Returns true if DbgHelp.dll on user computer supports MiniDumpWriteDump() function.
|
||||
BOOL IsMiniDumpSupported(void) const;
|
||||
/// Writes report to file in compressed or uncompressed format.
|
||||
BOOL WriteReport(PCTSTR pszFileName, CEnumProcess* pEnumProcess);
|
||||
/// Archive report files.
|
||||
BOOL ArchiveReportFiles(PCTSTR pszReportFolder, PCTSTR pszArchiveFileName);
|
||||
/// Writes crash log and mini-dump to zip archive.
|
||||
BOOL WriteReportArchive(PCTSTR pszArchiveFileName, CEnumProcess* pEnumProcess);
|
||||
/// Append file to the report.
|
||||
static BOOL AppendFileToReport(PCTSTR pszArchiveFileName, PCTSTR pszFileName);
|
||||
/// Write report files to a folder.
|
||||
BOOL WriteReportFiles(PCTSTR pszFolderName, CEnumProcess* pEnumProcess);
|
||||
/// Writes crash log to file.
|
||||
BOOL WriteLog(PCTSTR pszFileName, CEnumProcess* pEnumProcess);
|
||||
/// Writes crash dump to file.
|
||||
BOOL WriteDump(PCTSTR pszFileName);
|
||||
/// Writes screen-shot to file.
|
||||
BOOL WriteScreenShot(PCTSTR pszFileName);
|
||||
/// Get extension of report file.
|
||||
static PCTSTR GetReportFileExtension(void);
|
||||
/// Get extension of log file.
|
||||
static PCTSTR GetLogFileExtension(void);
|
||||
/// Automatically generate log/mini-dump file name according to the date and time of the crash.
|
||||
void GetReportFileName(PCTSTR pszExtension, PTSTR pszFileName, DWORD dwBufferSize) const;
|
||||
/// Automatically generate log/mini-dump file name according to the date and time of the crash.
|
||||
void GetReportFileName(PTSTR pszFileName, DWORD dwBufferSize) const;
|
||||
/// Get structured representation of topmost call stack entry.
|
||||
BOOL GetFirstStackTraceEntry(CStackTraceEntry& rEntry, HANDLE hThread = NULL);
|
||||
/// Get structured representation of lower call stack entry.
|
||||
BOOL GetNextStackTraceEntry(CStackTraceEntry& rEntry);
|
||||
#ifdef _MANAGED
|
||||
/// Get structured representation of topmost call stack entry.
|
||||
BOOL GetFirstStackTraceEntry(CNetStackTrace::CNetStackTraceEntry& rEntry);
|
||||
/// Get structured representation of lower call stack entry.
|
||||
BOOL GetNextStackTraceEntry(CNetStackTrace::CNetStackTraceEntry& rEntry);
|
||||
#endif
|
||||
/// Get string with CPU registers for the crash.
|
||||
void GetRegistersString(PTSTR pszRegString, DWORD dwRegStringSize);
|
||||
/// Get crash location and error reason.
|
||||
BOOL GetWin32ErrorString(CStrStream& rStream);
|
||||
#ifdef _MANAGED
|
||||
/// Return true if .NET exception info is valid.
|
||||
BOOL IsNetException(void) const;
|
||||
/// Get crash location and error reason.
|
||||
BOOL GetNetErrorString(CStrStream& rStream);
|
||||
/// Get crash location and error reason, including inner exception info.
|
||||
BOOL GetNetErrorStringEx(CStrStream& rStream);
|
||||
#endif
|
||||
/// Get crash location and error reason.
|
||||
BOOL GetErrorString(CStrStream& rStream);
|
||||
/// Get description of system CPUs.
|
||||
static void GetCpuString(CStrStream& rStream);
|
||||
/// Get user-friendly module version string.
|
||||
static BOOL GetVersionString(PCTSTR pszModuleName, PTSTR pszVersionString, DWORD dwVersionStringSize);
|
||||
/// Get OS information.
|
||||
static void GetOsString(PTSTR pszOSString, DWORD dwOSStringSize);
|
||||
/// Get description of system memory.
|
||||
static void GetMemString(PTSTR pszMemString, DWORD dwMemStringSize);
|
||||
/// Get process environment strings.
|
||||
static void GetEnvironmentStrings(CStrStream& rStream);
|
||||
};
|
||||
|
||||
inline CSymEngine::CStackWalkContext::CStackWalkContext(void)
|
||||
{
|
||||
ZeroMemory(this, sizeof(*this));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hProcess - handle to the process.
|
||||
* @param pBaseAddress - base of memory area.
|
||||
* @param pBuffer - data buffer.
|
||||
* @param dwSize - number of bytes to read.
|
||||
* @param pdwNumberOfBytesRead - number of bytes read.
|
||||
* @return if the function succeeds, the return value is nonzero.
|
||||
*/
|
||||
inline BOOL CALLBACK CSymEngine::ReadProcessMemoryProc64(HANDLE hProcess, DWORD64 pBaseAddress, PVOID pBuffer, DWORD dwSize, PDWORD pdwNumberOfBytesRead)
|
||||
{
|
||||
hProcess;
|
||||
#if defined _M_IX86
|
||||
return ReadProcessMemory(GetCurrentProcess(), (PVOID)pBaseAddress, pBuffer, dwSize, pdwNumberOfBytesRead);
|
||||
#elif defined _M_X64
|
||||
size_t nNumberOfBytesRead;
|
||||
BOOL bResult = ReadProcessMemory(GetCurrentProcess(), (PVOID)pBaseAddress, pBuffer, dwSize, &nNumberOfBytesRead);
|
||||
*pdwNumberOfBytesRead = (DWORD)nNumberOfBytesRead;
|
||||
return bResult;
|
||||
#else
|
||||
#error CPU architecture is not supported.
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if DbgHelp.dll on client computer has MiniDumpWriteDump() function.
|
||||
*/
|
||||
inline BOOL CSymEngine::IsMiniDumpSupported(void) const
|
||||
{
|
||||
return (FMiniDumpWriteDump != NULL);
|
||||
}
|
||||
|
||||
inline CSymEngine::CScreenShot::CBitmapInfo::CBitmapInfo(void)
|
||||
{
|
||||
ZeroMemory(this, sizeof(*this));
|
||||
}
|
||||
|
||||
inline CSymEngine::CScreenShot::CBitmapInfo::~CBitmapInfo(void)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
inline void CSymEngine::CScreenShot::CBitmapInfo::Free(void)
|
||||
{
|
||||
Destroy();
|
||||
ZeroMemory(this, sizeof(*this));
|
||||
}
|
||||
|
||||
inline void CSymEngine::CScreenShot::CBitmapInfo::Destroy(void)
|
||||
{
|
||||
delete[] (PBYTE)m_pBitsArray;
|
||||
delete[] (PBYTE)m_pBmpInfo;
|
||||
}
|
||||
|
||||
inline CSymEngine::CScreenShot::~CScreenShot(void)
|
||||
{
|
||||
delete[] m_arrBitmaps;
|
||||
}
|
||||
|
||||
inline CSymEngine::CSysErrorInfo::CSysErrorInfo(void)
|
||||
{
|
||||
*m_szErrorCode = _T('\0');
|
||||
m_pszMessageBuffer = NULL;
|
||||
}
|
||||
|
||||
inline CSymEngine::CSysErrorInfo::~CSysErrorInfo(void)
|
||||
{
|
||||
FreeData();
|
||||
}
|
||||
|
||||
inline void CSymEngine::CSysErrorInfo::FreeData(void)
|
||||
{
|
||||
if (m_pszMessageBuffer)
|
||||
LocalFree(m_pszMessageBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rErrorInfo - another error info object.
|
||||
*/
|
||||
inline CSymEngine::CSysErrorInfo::CSysErrorInfo(const CSysErrorInfo& rErrorInfo)
|
||||
{
|
||||
CopyData(rErrorInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pszFileName - buffer for resulting file name.
|
||||
* @param dwBufferSize - size of file name buffer.
|
||||
*/
|
||||
inline void CSymEngine::GetReportFileName(PTSTR pszFileName, DWORD dwBufferSize) const
|
||||
{
|
||||
PCTSTR pszReportExtension = GetReportFileExtension();
|
||||
GetReportFileName(pszReportExtension, pszFileName, dwBufferSize);
|
||||
}
|
||||
|
||||
#ifndef _MANAGED
|
||||
|
||||
/**
|
||||
* @param rStream - stream object.
|
||||
* @return true if error info is not empty.
|
||||
*/
|
||||
inline BOOL CSymEngine::GetErrorString(CStrStream& rStream)
|
||||
{
|
||||
return GetWin32ErrorString(rStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEncStream - UTF-8 encoder object.
|
||||
* @return true if error info is not empty.
|
||||
*/
|
||||
inline BOOL CSymEngine::GetErrorString(CUTF8EncStream& rEncStream)
|
||||
{
|
||||
return GetWin32ErrorString(rEncStream);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
/**
|
||||
* @param rEntry - stack entry information.
|
||||
* @return true if there is information about stack entry.
|
||||
*/
|
||||
inline BOOL CSymEngine::GetFirstStackTraceEntry(CNetStackTrace::CNetStackTraceEntry& rEntry)
|
||||
{
|
||||
_ASSERTE(m_pNetStackTrace != NULL);
|
||||
return (m_pNetStackTrace != NULL ? m_pNetStackTrace->GetFirstStackTraceEntry(rEntry) : FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEntry - stack entry information.
|
||||
* @return true if there is information about stack entry.
|
||||
*/
|
||||
inline BOOL CSymEngine::GetNextStackTraceEntry(CNetStackTrace::CNetStackTraceEntry& rEntry)
|
||||
{
|
||||
_ASSERTE(m_pNetStackTrace != NULL);
|
||||
return (m_pNetStackTrace != NULL ? m_pNetStackTrace->GetNextStackTraceEntry(rEntry) : FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEncStream - UTF-8 encoder object.
|
||||
* @return true if thread context was successfully resolved.
|
||||
*/
|
||||
inline BOOL CSymEngine::GetFirstNetStackTraceString(CUTF8EncStream& rEncStream)
|
||||
{
|
||||
_ASSERTE(m_pNetStackTrace != NULL);
|
||||
return (m_pNetStackTrace != NULL ? m_pNetStackTrace->GetFirstStackTraceString(rEncStream) : FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEncStream - UTF-8 encoder object.
|
||||
* @return true if thread context was successfully resolved.
|
||||
*/
|
||||
inline BOOL CSymEngine::GetNextNetStackTraceString(CUTF8EncStream& rEncStream)
|
||||
{
|
||||
_ASSERTE(m_pNetStackTrace != NULL);
|
||||
return (m_pNetStackTrace != NULL ? m_pNetStackTrace->GetNextStackTraceString(rEncStream) : FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rEncStream - UTF-8 encoder object.
|
||||
*/
|
||||
inline void CSymEngine::GetNetThreadsList(CUTF8EncStream& rEncStream)
|
||||
{
|
||||
rEncStream; // TBD
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rXmlWriter - XML writer.
|
||||
*/
|
||||
inline void CSymEngine::GetNetThreadsList(CXmlWriter& rXmlWriter)
|
||||
{
|
||||
rXmlWriter; // TBD
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if .NET exception info is valid.
|
||||
*/
|
||||
inline BOOL CSymEngine::IsNetException(void) const
|
||||
{
|
||||
return (NetThunks::IsNetException() && m_pNetStackTrace != NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
52
third-party/BugTrap-1.3-57bd515/source/SymEngineNet.cpp
vendored
Normal file
52
third-party/BugTrap-1.3-57bd515/source/SymEngineNet.cpp
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: .NET symbolic engine.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "SymEngineNet.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
#pragma managed
|
||||
|
||||
namespace IntelleSoft
|
||||
{
|
||||
namespace BugTrap
|
||||
{
|
||||
StackFrame^ StackFrameEnumerator::GetNextStackTraceEntry(void)
|
||||
{
|
||||
return (this->frameIndex < this->stackTrace->FrameCount ? this->stackTrace->GetFrame(this->frameIndex++) : nullptr);
|
||||
}
|
||||
|
||||
AssemblyEnumerator::AssemblyEnumerator(void)
|
||||
{
|
||||
AppDomain^ domain = AppDomain::CurrentDomain;
|
||||
this->assemblies = domain->GetAssemblies();
|
||||
this->assemblyEnumerator = this->assemblies->GetEnumerator();
|
||||
}
|
||||
|
||||
Assembly^ AssemblyEnumerator::GetNextAssembly(void)
|
||||
{
|
||||
return (this->assemblyEnumerator != nullptr && this->assemblyEnumerator->MoveNext() ? safe_cast<Assembly^>(this->assemblyEnumerator->Current) : nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unmanaged
|
||||
|
||||
#endif // _MANAGED
|
||||
|
||||
110
third-party/BugTrap-1.3-57bd515/source/SymEngineNet.h
vendored
Normal file
110
third-party/BugTrap-1.3-57bd515/source/SymEngineNet.h
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: .NET symbolic engine.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MANAGED
|
||||
|
||||
#include "BugTrapNet.h"
|
||||
|
||||
#pragma managed
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Threading;
|
||||
using namespace System::Diagnostics;
|
||||
using namespace System::Text;
|
||||
using namespace System::Collections;
|
||||
using namespace System::Reflection;
|
||||
|
||||
namespace IntelleSoft
|
||||
{
|
||||
namespace BugTrap
|
||||
{
|
||||
private ref class StackFrameEnumerator
|
||||
{
|
||||
public:
|
||||
StackFrameEnumerator(Thread^ thread);
|
||||
StackFrameEnumerator(Exception^ exception);
|
||||
void InitStackTrace(void);
|
||||
StackFrame^ GetFirstStackTraceEntry(void);
|
||||
StackFrame^ GetNextStackTraceEntry(void);
|
||||
property System::Exception^ Exception
|
||||
{
|
||||
System::Exception^ get(void);
|
||||
}
|
||||
|
||||
private:
|
||||
initonly StackTrace^ stackTrace;
|
||||
initonly System::Exception^ exception;
|
||||
int frameIndex;
|
||||
};
|
||||
|
||||
inline StackFrameEnumerator::StackFrameEnumerator(Thread^ thread)
|
||||
{
|
||||
this->stackTrace = gcnew StackTrace(thread, true);
|
||||
this->frameIndex = int::MaxValue;
|
||||
}
|
||||
|
||||
inline StackFrameEnumerator::StackFrameEnumerator(System::Exception^ exception)
|
||||
{
|
||||
this->stackTrace = gcnew StackTrace(exception, true);
|
||||
this->frameIndex = int::MaxValue;
|
||||
this->exception = exception;
|
||||
}
|
||||
|
||||
inline void StackFrameEnumerator::InitStackTrace(void)
|
||||
{
|
||||
this->frameIndex = 0;
|
||||
}
|
||||
|
||||
inline StackFrame^ StackFrameEnumerator::GetFirstStackTraceEntry(void)
|
||||
{
|
||||
this->InitStackTrace();
|
||||
return this->GetNextStackTraceEntry();
|
||||
}
|
||||
|
||||
inline System::Exception^ StackFrameEnumerator::Exception::get(void)
|
||||
{
|
||||
return this->exception;
|
||||
}
|
||||
|
||||
private ref class AssemblyEnumerator
|
||||
{
|
||||
public:
|
||||
AssemblyEnumerator(void);
|
||||
void InitAssemblies(void);
|
||||
Assembly^ GetFirstAssembly(void);
|
||||
Assembly^ GetNextAssembly(void);
|
||||
|
||||
private:
|
||||
initonly array<Assembly^>^ assemblies;
|
||||
IEnumerator^ assemblyEnumerator;
|
||||
};
|
||||
|
||||
inline void AssemblyEnumerator::InitAssemblies(void)
|
||||
{
|
||||
this->assemblyEnumerator->Reset();
|
||||
}
|
||||
|
||||
inline Assembly^ AssemblyEnumerator::GetFirstAssembly(void)
|
||||
{
|
||||
this->InitAssemblies();
|
||||
return this->GetNextAssembly();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma unmanaged
|
||||
|
||||
#endif // _MANAGED
|
||||
144
third-party/BugTrap-1.3-57bd515/source/TextFormat.cpp
vendored
Normal file
144
third-party/BugTrap-1.3-57bd515/source/TextFormat.cpp
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Text format analyzer.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "TextFormat.h"
|
||||
#include "BugTrapUtils.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Detect file format and encoding.
|
||||
* @param pszFileName - file name.
|
||||
* @param hFile - file handle.
|
||||
* @param bTextFile - true if file contains text and false for binary files.
|
||||
* @param eEncoding - text encoding.
|
||||
* @return sizeof of encoding signature.
|
||||
*/
|
||||
DWORD DetectFileFormat(PCTSTR pszFileName, HANDLE hFile, BOOL& bTextFile, TEXT_ENCODING& eEncoding)
|
||||
{
|
||||
_ASSERTE(hFile != INVALID_HANDLE_VALUE);
|
||||
BYTE arrBuffer[100];
|
||||
DWORD dwNumRead = 0;
|
||||
if (! ReadFile(hFile, arrBuffer, sizeof(arrBuffer), &dwNumRead, NULL))
|
||||
{
|
||||
bTextFile = FALSE;
|
||||
eEncoding = TXTENC_ANSI;
|
||||
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
|
||||
return 0;
|
||||
}
|
||||
static const TCHAR szXmlFileExt[] = _T(".xml");
|
||||
const size_t nXmlFileExtLength = countof(szXmlFileExt) - 1;
|
||||
size_t nFileNameLength = _tcslen(pszFileName);
|
||||
BOOL bIsXmlFile = nFileNameLength >= nXmlFileExtLength && _tcsicmp(pszFileName + nFileNameLength - nXmlFileExtLength, szXmlFileExt) == 0;
|
||||
bTextFile = TRUE;
|
||||
DWORD dwStartPos, dwCharSize, dwOffsetFromStart;
|
||||
if (dwNumRead >= sizeof(g_arrUTF16LEPreamble) && memcmp(arrBuffer, g_arrUTF16LEPreamble, sizeof(g_arrUTF16LEPreamble)) == 0)
|
||||
{
|
||||
eEncoding = TXTENC_UTF16LE;
|
||||
dwStartPos = sizeof(g_arrUTF16LEPreamble);
|
||||
dwCharSize = sizeof(WCHAR);
|
||||
dwOffsetFromStart = 0;
|
||||
}
|
||||
else if (dwNumRead >= sizeof(g_arrUTF16BEPreamble) && memcmp(arrBuffer, g_arrUTF16BEPreamble, sizeof(g_arrUTF16BEPreamble)) == 0)
|
||||
{
|
||||
eEncoding = TXTENC_UTF16BE;
|
||||
dwStartPos = sizeof(g_arrUTF16BEPreamble);
|
||||
dwCharSize = sizeof(WCHAR);
|
||||
dwOffsetFromStart = 1;
|
||||
}
|
||||
else if (dwNumRead >= sizeof(g_arrUTF8Preamble) && memcmp(arrBuffer, g_arrUTF8Preamble, sizeof(g_arrUTF8Preamble)) == 0)
|
||||
{
|
||||
eEncoding = TXTENC_UTF8;
|
||||
dwStartPos = sizeof(g_arrUTF8Preamble);
|
||||
dwCharSize = sizeof(CHAR);
|
||||
dwOffsetFromStart = 0;
|
||||
}
|
||||
else if (bIsXmlFile)
|
||||
{
|
||||
static const CHAR szXmlProcessingInstruction[] = "<?xml ";
|
||||
const DWORD dwXmlProcessingInstructionLength = sizeof(szXmlProcessingInstruction) - 1;
|
||||
static const CHAR szEncodingAttribute[] = "encoding";
|
||||
const DWORD dwEncodingAttributeLength = sizeof(szEncodingAttribute) - 1;
|
||||
static const CHAR szUTF8Encoding[] = "UTF-8";
|
||||
const DWORD dwUTF8EncodingLength = sizeof(szUTF8Encoding) - 1;
|
||||
|
||||
eEncoding = TXTENC_UTF8; // default XML encoding
|
||||
dwStartPos = dwOffsetFromStart = 0;
|
||||
dwCharSize = sizeof(CHAR);
|
||||
if (dwNumRead >= dwXmlProcessingInstructionLength && _memicmp(arrBuffer, szXmlProcessingInstruction, dwXmlProcessingInstructionLength) == 0)
|
||||
{
|
||||
DWORD dwBytePos = dwXmlProcessingInstructionLength;
|
||||
while (dwBytePos < dwNumRead)
|
||||
{
|
||||
while (dwBytePos < dwNumRead && IsSpace(arrBuffer[dwBytePos]))
|
||||
++dwBytePos;
|
||||
if (dwBytePos >= dwNumRead || arrBuffer[dwBytePos] == '?')
|
||||
break;
|
||||
DWORD dwWordStart = dwBytePos;
|
||||
while (dwBytePos < dwNumRead && IsAlpha(arrBuffer[dwBytePos]))
|
||||
++dwBytePos;
|
||||
DWORD dwWordLength = dwBytePos - dwWordStart;
|
||||
if (dwWordLength == 0)
|
||||
break;
|
||||
while (dwBytePos < dwNumRead && IsSpace(arrBuffer[dwBytePos]))
|
||||
++dwBytePos;
|
||||
if (dwBytePos < dwNumRead && arrBuffer[dwBytePos] == '=')
|
||||
++dwBytePos;
|
||||
else
|
||||
break;
|
||||
while (dwBytePos < dwNumRead && IsSpace(arrBuffer[dwBytePos]))
|
||||
++dwBytePos;
|
||||
if (dwBytePos < dwNumRead && IsQuotation(arrBuffer[dwBytePos]))
|
||||
++dwBytePos;
|
||||
else
|
||||
break;
|
||||
if (dwBytePos < dwNumRead)
|
||||
{
|
||||
DWORD dwValueStart = dwBytePos;
|
||||
while (dwBytePos < dwNumRead && ! IsQuotation(arrBuffer[dwBytePos]))
|
||||
++dwBytePos;
|
||||
DWORD dwValueLength = dwBytePos - dwValueStart;
|
||||
if (dwBytePos < dwNumRead)
|
||||
++dwBytePos;
|
||||
if (dwWordLength == dwEncodingAttributeLength && _memicmp(arrBuffer + dwWordStart, szEncodingAttribute, dwWordLength) == 0)
|
||||
{
|
||||
if (dwValueLength != dwUTF8EncodingLength || _memicmp(arrBuffer + dwValueStart, szUTF8Encoding, dwUTF8EncodingLength) != 0)
|
||||
eEncoding = TXTENC_ANSI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eEncoding = TXTENC_ANSI;
|
||||
dwStartPos = dwOffsetFromStart = 0;
|
||||
dwCharSize = sizeof(CHAR);
|
||||
}
|
||||
for (DWORD dwBytePos = dwStartPos + dwOffsetFromStart; dwBytePos < dwNumRead; dwBytePos += dwCharSize)
|
||||
{
|
||||
if (arrBuffer[dwBytePos] == 0)
|
||||
{
|
||||
bTextFile = FALSE;
|
||||
eEncoding = TXTENC_ANSI;
|
||||
dwStartPos = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return dwStartPos;
|
||||
}
|
||||
26
third-party/BugTrap-1.3-57bd515/source/TextFormat.h
vendored
Normal file
26
third-party/BugTrap-1.3-57bd515/source/TextFormat.h
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Text format analyzer.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Encoding.h"
|
||||
|
||||
/// UTF-8 preamble.
|
||||
const BYTE g_arrUTF8Preamble[] = { 0xEF, 0xBB, 0xBF };
|
||||
/// UTF-16/UCS-2, little-endian preamble.
|
||||
const BYTE g_arrUTF16LEPreamble[] = { 0xFF, 0xFE };
|
||||
/// UTF-16/UCS-2, big-endian preamble.
|
||||
const BYTE g_arrUTF16BEPreamble[] = { 0xFE, 0xFF };
|
||||
|
||||
DWORD DetectFileFormat(PCTSTR pszFileName, HANDLE hFile, BOOL& bTextFile, TEXT_ENCODING& eEncoding);
|
||||
287
third-party/BugTrap-1.3-57bd515/source/TextLogFile.cpp
vendored
Normal file
287
third-party/BugTrap-1.3-57bd515/source/TextLogFile.cpp
vendored
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Text log file.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
#include "TextLogFile.h"
|
||||
#include "TextFormat.h"
|
||||
#include "Globals.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @return true if the log was loaded successfully.
|
||||
*/
|
||||
BOOL CTextLogFile::LoadEntries(void)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DWORD dwStartTime = GetTickCount();
|
||||
#endif
|
||||
BOOL bResult = FALSE;
|
||||
PCTSTR pszLogFileName = GetLogFileName();
|
||||
HANDLE hFile = CreateFile(pszLogFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD dwFileSize = (DWORD)GetFileSize(hFile, NULL);
|
||||
if (dwFileSize == 0)
|
||||
{
|
||||
// ignore empty files
|
||||
CloseHandle(hFile);
|
||||
return TRUE;
|
||||
}
|
||||
DWORD dwBufferSize = min(dwFileSize, g_dwMaxBufferSize);
|
||||
PBYTE pFileBuffer = new BYTE[dwBufferSize];
|
||||
if (pFileBuffer)
|
||||
{
|
||||
BYTE arrUTF8Preamble[sizeof(g_arrUTF8Preamble)];
|
||||
DWORD dwWritten = 0;
|
||||
if (ReadFile(hFile, arrUTF8Preamble, sizeof(arrUTF8Preamble), &dwWritten, NULL) &&
|
||||
dwWritten == sizeof(arrUTF8Preamble) && memcmp(arrUTF8Preamble, g_arrUTF8Preamble, sizeof(arrUTF8Preamble)) == 0)
|
||||
{
|
||||
bResult = TRUE;
|
||||
DWORD dwCurrentPos = 0, dwLineStart = 0;
|
||||
for (;;)
|
||||
{
|
||||
dwWritten = 0;
|
||||
DWORD dwFreeSize = dwBufferSize - dwCurrentPos;
|
||||
if (! ReadFile(hFile, pFileBuffer + dwCurrentPos, dwFreeSize, &dwWritten, NULL))
|
||||
goto end;
|
||||
BOOL bEndOfFile = dwWritten < dwFreeSize;
|
||||
dwWritten += dwCurrentPos;
|
||||
dwCurrentPos = 0;
|
||||
if (dwWritten == 0)
|
||||
goto end;
|
||||
for (;;)
|
||||
{
|
||||
if (dwCurrentPos >= dwWritten && ! bEndOfFile)
|
||||
{
|
||||
if (dwLineStart > 0)
|
||||
{
|
||||
dwCurrentPos -= dwLineStart;
|
||||
MoveMemory(pFileBuffer, pFileBuffer + dwLineStart, dwCurrentPos);
|
||||
dwLineStart = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwBufferSize *= 2;
|
||||
PBYTE pNewFileBuffer = new BYTE[dwBufferSize];
|
||||
if (! pNewFileBuffer)
|
||||
{
|
||||
bResult = FALSE;
|
||||
goto end;
|
||||
}
|
||||
CopyMemory(pNewFileBuffer, pFileBuffer, dwCurrentPos);
|
||||
delete[] pFileBuffer;
|
||||
pFileBuffer = pNewFileBuffer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (dwCurrentPos < dwWritten ? pFileBuffer[dwCurrentPos] == '\r' || pFileBuffer[dwCurrentPos] == '\n' : bEndOfFile)
|
||||
{
|
||||
if (dwLineStart < dwCurrentPos && ! AddToTail(pFileBuffer + dwLineStart, dwCurrentPos - dwLineStart, true))
|
||||
{
|
||||
bResult = FALSE;
|
||||
goto end;
|
||||
}
|
||||
if (dwCurrentPos == dwWritten) // bEndOfFile == TRUE, see condition above
|
||||
{
|
||||
bResult = TRUE;
|
||||
goto end;
|
||||
}
|
||||
dwLineStart = dwCurrentPos + 1;
|
||||
}
|
||||
++dwCurrentPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
end:
|
||||
if (! bResult)
|
||||
FreeEntries();
|
||||
delete[] pFileBuffer;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD dwLastError = GetLastError();
|
||||
if (dwLastError == ERROR_FILE_NOT_FOUND ||
|
||||
dwLastError == ERROR_PATH_NOT_FOUND ||
|
||||
GetFileAttributes(pszLogFileName) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
bResult = TRUE; // ignore missing files
|
||||
}
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
DWORD dwEndTime = GetTickCount();
|
||||
TCHAR szMessage[128];
|
||||
_stprintf_s(szMessage, countof(szMessage), _T("CTextLogFile::LoadEntries(): %lu entries, %lu bytes, %lu milliseconds\r\n"), GetNumEntries(), GetNumBytes(), dwEndTime - dwStartTime);
|
||||
OutputDebugString(szMessage);
|
||||
#endif
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bCrash - true if crash has occurred.
|
||||
* @return true if the log was saved successfully.
|
||||
*/
|
||||
BOOL CTextLogFile::SaveEntries(BOOL /*bCrash*/)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DWORD dwStartTime = GetTickCount();
|
||||
#endif
|
||||
PCTSTR pszLogFileName = GetLogFileName();
|
||||
HANDLE hFile = CreateFile(pszLogFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return FALSE;
|
||||
DWORD dwWritten;
|
||||
WriteFile(hFile, g_arrUTF8Preamble, sizeof(g_arrUTF8Preamble), &dwWritten, NULL);
|
||||
CLogEntry* pLogEntry = GetFirstEntry();
|
||||
while (pLogEntry)
|
||||
{
|
||||
CTextLogEntry* pTextLogEntry = (CTextLogEntry*)pLogEntry;
|
||||
WriteFile(hFile, pTextLogEntry->m_pbData, pTextLogEntry->m_dwSize, &dwWritten, NULL);
|
||||
pLogEntry = pLogEntry->m_pNextEntry;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
DWORD dwEndTime = GetTickCount();
|
||||
TCHAR szMessage[128];
|
||||
_stprintf_s(szMessage, countof(szMessage), _T("CTextLogFile::SaveEntries(): %lu entries, %lu bytes, %lu milliseconds\r\n"), GetNumEntries(), GetNumBytes(), dwEndTime - dwStartTime);
|
||||
OutputDebugString(szMessage);
|
||||
#endif
|
||||
CloseHandle(hFile);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pbData - entry data.
|
||||
* @param dwSize - data size.
|
||||
* @param bAddCrLf - true if CR/LF must be added.
|
||||
* @return pointer to the new entry.
|
||||
*/
|
||||
CTextLogFile::CTextLogEntry* CTextLogFile::AllocLogEntry(const BYTE* pbData, DWORD dwSize, BOOL bAddCrLf)
|
||||
{
|
||||
DWORD dwFullSize = bAddCrLf ? dwSize + 2 : dwSize;
|
||||
CTextLogEntry* pLogEntry = (CTextLogEntry*)new BYTE[sizeof(CTextLogEntry) + dwFullSize];
|
||||
if (pLogEntry)
|
||||
{
|
||||
pLogEntry->m_dwSize = dwFullSize;
|
||||
PBYTE pDstData = pLogEntry->m_pbData;
|
||||
CopyMemory(pDstData, pbData, dwSize);
|
||||
if (bAddCrLf)
|
||||
{
|
||||
pDstData[dwSize++] = _T('\r');
|
||||
pDstData[dwSize++] = _T('\n');
|
||||
}
|
||||
}
|
||||
return pLogEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pbData - entry data.
|
||||
* @param dwSize - data size.
|
||||
* @param bAddCrLf - true if CR/LF must be added.
|
||||
* @return true if entry was added.
|
||||
*/
|
||||
BOOL CTextLogFile::AddToHead(const BYTE* pbData, DWORD dwSize, BOOL bAddCrLf)
|
||||
{
|
||||
CTextLogEntry* pLogEntry = AllocLogEntry(pbData, dwSize, bAddCrLf);
|
||||
if (pLogEntry)
|
||||
{
|
||||
CInMemLogFile::AddToHead(pLogEntry);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pbData - entry data.
|
||||
* @param dwSize - data size.
|
||||
* @param bAddCrLf - true if CR/LF must be added.
|
||||
* @return true if entry was added.
|
||||
*/
|
||||
BOOL CTextLogFile::AddToTail(const BYTE* pbData, DWORD dwSize, BOOL bAddCrLf)
|
||||
{
|
||||
CTextLogEntry* pLogEntry = AllocLogEntry(pbData, dwSize, bAddCrLf);
|
||||
if (pLogEntry)
|
||||
{
|
||||
CInMemLogFile::AddToTail(pLogEntry);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bAddCrLf - true if CR/LF must be added.
|
||||
* @return true if entry was added.
|
||||
*/
|
||||
BOOL CTextLogFile::AddToHead(BOOL bAddCrLf)
|
||||
{
|
||||
const BYTE* pBuffer = m_MemStream.GetBuffer();
|
||||
if (pBuffer == NULL)
|
||||
return FALSE;
|
||||
DWORD dwLength = (DWORD)m_MemStream.GetLength();
|
||||
_ASSERTE(dwLength > 0);
|
||||
return AddToHead(pBuffer, dwLength, bAddCrLf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bAddCrLf - true if CR/LF must be added.
|
||||
* @return true if entry was added.
|
||||
*/
|
||||
BOOL CTextLogFile::AddToTail(BOOL bAddCrLf)
|
||||
{
|
||||
const BYTE* pBuffer = m_MemStream.GetBuffer();
|
||||
if (pBuffer == NULL)
|
||||
return FALSE;
|
||||
DWORD dwLength = (DWORD)m_MemStream.GetLength();
|
||||
_ASSERTE(dwLength > 0);
|
||||
return AddToTail(pBuffer, dwLength, bAddCrLf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param eLogLevel - log level number.
|
||||
* @param eEntryMode - entry mode.
|
||||
* @param rcsConsoleAccess - provides synchronous access to the console.
|
||||
* @param pszEntry - log entry text.
|
||||
* @return true if operation was completed successfully.
|
||||
*/
|
||||
BOOL CTextLogFile::WriteLogEntry(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry)
|
||||
{
|
||||
BOOL bResult = TRUE;
|
||||
BUGTRAP_LOGLEVEL eLogFileLevel = GetLogLevel();
|
||||
if (eLogLevel <= eLogFileLevel)
|
||||
{
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime(&st);
|
||||
if (! WriteLogEntryToConsole(eLogLevel, &st, rcsConsoleAccess, pszEntry))
|
||||
FillEntryText(eLogLevel, &st, pszEntry);
|
||||
EncodeEntryText();
|
||||
switch (eEntryMode)
|
||||
{
|
||||
case EM_APPEND:
|
||||
AddToTail(FALSE);
|
||||
break;
|
||||
case EM_INSERT:
|
||||
AddToHead(FALSE);
|
||||
break;
|
||||
default:
|
||||
_ASSERT(FALSE);
|
||||
bResult = FALSE;
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
91
third-party/BugTrap-1.3-57bd515/source/TextLogFile.h
vendored
Normal file
91
third-party/BugTrap-1.3-57bd515/source/TextLogFile.h
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* This is a part of the BugTrap package.
|
||||
* Copyright (c) 2005-2009 IntelleSoft.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Description: Text log file.
|
||||
* Author: Maksim Pyatkovskiy.
|
||||
*
|
||||
* This source code is only intended as a supplement to the
|
||||
* BugTrap package reference and related electronic documentation
|
||||
* provided with the product. See these sources for detailed
|
||||
* information regarding the BugTrap package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "InMemLogFile.h"
|
||||
#include "Encoding.h"
|
||||
#include "MemStream.h"
|
||||
#include "TextFormat.h"
|
||||
|
||||
/**
|
||||
* @brief Text log file.
|
||||
*/
|
||||
class CTextLogFile : public CInMemLogFile
|
||||
{
|
||||
public:
|
||||
/// Initialize the object.
|
||||
CTextLogFile(void);
|
||||
/// Load entries into memory.
|
||||
virtual BOOL LoadEntries(void);
|
||||
/// Save entries into disk.
|
||||
virtual BOOL SaveEntries(BOOL bCrash);
|
||||
/// Add new log entry.
|
||||
virtual BOOL WriteLogEntry(BUGTRAP_LOGLEVEL eLogLevel, ENTRY_MODE eEntryMode, CRITICAL_SECTION& rcsConsoleAccess, PCTSTR pszEntry);
|
||||
|
||||
private:
|
||||
/// Protects the class from being accidentally copied.
|
||||
CTextLogFile(const CTextLogFile& rLogFile);
|
||||
/// Protects the class from being accidentally copied.
|
||||
CTextLogFile& operator=(const CTextLogFile& rLogFile);
|
||||
|
||||
/// Log entry data.
|
||||
struct CTextLogEntry : public CInMemLogFile::CLogEntry
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4200) // nonstandard extension used : zero-sized array in struct/union
|
||||
/// Data buffer.
|
||||
BYTE m_pbData[0];
|
||||
#pragma warning(pop)
|
||||
};
|
||||
|
||||
/// Get default log file extension.
|
||||
virtual PCTSTR GetLogFileExtension(void) const;
|
||||
/// Allocate log entry.
|
||||
CTextLogEntry* AllocLogEntry(const BYTE* pbData, DWORD dwSize, BOOL bAddCrLf);
|
||||
/// Add log entry to the head.
|
||||
BOOL AddToHead(BOOL bAddCrLf);
|
||||
/// Add log entry to the tail.
|
||||
BOOL AddToTail(BOOL bAddCrLf);
|
||||
/// Add log entry to the head.
|
||||
BOOL AddToHead(const BYTE* pbData, DWORD dwSize, BOOL bAddCrLf);
|
||||
/// Add log entry to the tail.
|
||||
BOOL AddToTail(const BYTE* pbData, DWORD dwSize, BOOL bAddCrLf);
|
||||
/// Encode entry text.
|
||||
void EncodeEntryText(void);
|
||||
|
||||
/// Encoder object pre-allocated for the log.
|
||||
CUTF8EncStream m_EncStream;
|
||||
/// Pre-allocated buffer for encoded log entry text.
|
||||
CMemStream m_MemStream;
|
||||
};
|
||||
|
||||
inline CTextLogFile::CTextLogFile(void) : CInMemLogFile(sizeof(g_arrUTF8Preamble)), m_MemStream(1024), m_EncStream(&m_MemStream)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return log file extension.
|
||||
*/
|
||||
inline PCTSTR CTextLogFile::GetLogFileExtension(void) const
|
||||
{
|
||||
return _T(".txt");
|
||||
}
|
||||
|
||||
inline void CTextLogFile::EncodeEntryText(void)
|
||||
{
|
||||
m_EncStream.Reset();
|
||||
PCTSTR pszEntry = GetEntryText();
|
||||
m_EncStream.WriteUTF8Bin(pszEntry);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue