2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Fix line endings and tabs

This commit is contained in:
Branan Purvine-Riley
2011-04-11 16:27:55 -07:00
parent d4250e19b5
commit 908aaeb6f6
2738 changed files with 702562 additions and 702562 deletions

View File

@ -1,131 +1,131 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_INTERN_H
namespace Crash {
/*****************************************************************************
*
* Mail
*
***/
void CrashSendEmail (
const char smtp[],
const char sender[],
const char recipients[],
const char replyTo[],
const char username[],
const char password[],
const char programName[],
const char errorType[],
const char logBuffer[]
);
/*****************************************************************************
*
* ImgHlp
*
***/
// make our own IMAGEAPI type because the real definition uses DECLSPEC_IMPORT
#define MYIMAGEAPI __stdcall
class CImageHelp {
private:
HMODULE m_libInst;
HANDLE m_process;
char * m_appName;
char m_appPath[MAX_PATH];
public:
CImageHelp (HINSTANCE instance);
~CImageHelp ();
inline HANDLE Process () const {
return m_process;
}
inline const char * GetProgramPath () const {
return m_appPath;
}
inline const char * GetProgramName () const {
return m_appName;
}
BOOL (MYIMAGEAPI * SymGetModuleInfo)(
HANDLE hProcess,
DWORD dwAddr,
IMAGEHLP_MODULE * ModuleInfo
);
BOOL (MYIMAGEAPI * StackWalk)(
DWORD MachineType,
HANDLE hProcess,
HANDLE hThread,
LPSTACKFRAME StackFrame,
LPVOID ContextRecord,
PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
);
LPVOID (MYIMAGEAPI * SymFunctionTableAccess)(
HANDLE hProcess,
DWORD AddrBase
);
DWORD (MYIMAGEAPI * SymGetModuleBase)(
HANDLE hProcess,
DWORD dwAddr
);
BOOL (MYIMAGEAPI * SymGetSymFromAddr)(
HANDLE hProcess,
DWORD Address,
LPDWORD Displacement,
PIMAGEHLP_SYMBOL Symbol
);
};
} using namespace Crash;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_INTERN_H
namespace Crash {
/*****************************************************************************
*
* Mail
*
***/
void CrashSendEmail (
const char smtp[],
const char sender[],
const char recipients[],
const char replyTo[],
const char username[],
const char password[],
const char programName[],
const char errorType[],
const char logBuffer[]
);
/*****************************************************************************
*
* ImgHlp
*
***/
// make our own IMAGEAPI type because the real definition uses DECLSPEC_IMPORT
#define MYIMAGEAPI __stdcall
class CImageHelp {
private:
HMODULE m_libInst;
HANDLE m_process;
char * m_appName;
char m_appPath[MAX_PATH];
public:
CImageHelp (HINSTANCE instance);
~CImageHelp ();
inline HANDLE Process () const {
return m_process;
}
inline const char * GetProgramPath () const {
return m_appPath;
}
inline const char * GetProgramName () const {
return m_appName;
}
BOOL (MYIMAGEAPI * SymGetModuleInfo)(
HANDLE hProcess,
DWORD dwAddr,
IMAGEHLP_MODULE * ModuleInfo
);
BOOL (MYIMAGEAPI * StackWalk)(
DWORD MachineType,
HANDLE hProcess,
HANDLE hThread,
LPSTACKFRAME StackFrame,
LPVOID ContextRecord,
PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
);
LPVOID (MYIMAGEAPI * SymFunctionTableAccess)(
HANDLE hProcess,
DWORD AddrBase
);
DWORD (MYIMAGEAPI * SymGetModuleBase)(
HANDLE hProcess,
DWORD dwAddr
);
BOOL (MYIMAGEAPI * SymGetSymFromAddr)(
HANDLE hProcess,
DWORD Address,
LPDWORD Displacement,
PIMAGEHLP_SYMBOL Symbol
);
};
} using namespace Crash;

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,33 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/pnCreGui.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/pnCreGui.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -1,198 +1,198 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreMail.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
//============================================================================
namespace Crash {
//============================================================================
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static bool CreateInheritablePipe (
HANDLE * read,
HANDLE * write,
bool inheritRead
) {
// create pipe for std error read/write
if (!CreatePipe(read, write, (LPSECURITY_ATTRIBUTES) NULL, 0))
return false;
// make the appropriate handle inheritable
HANDLE hProcess = GetCurrentProcess();
HANDLE * inherit = inheritRead ? read : write;
bool result = DuplicateHandle(
hProcess,
*inherit,
hProcess,
inherit,
0,
true, // make inheritable
DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS
);
if (!result)
return false;
return true;
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void CrashSendEmail (
const char smtp[],
const char sender[],
const char recipients[],
const char replyTo[],
const char username[],
const char password[],
const char programName[],
const char errorType[],
const char logBuffer[]
) {
enum {
IN_CHILD,
IN_PARENT,
NUM_PIPES
};
unsigned i;
HANDLE pipes[NUM_PIPES];
for (i = 0; i < arrsize(pipes); ++i)
pipes[i] = INVALID_HANDLE_VALUE;
for (;;) {
// create pipes for Server -> StdIn -> Client
if (!CreateInheritablePipe(&pipes[IN_CHILD], &pipes[IN_PARENT], true))
break;
char subject[512];
StrPrintf(
subject,
arrsize(subject),
"\"[Crash] %s, %s\"",
programName,
errorType
);
char cmdLine[512];
StrPrintf(
cmdLine,
arrsize(cmdLine),
"plMail.exe -smtp %s -sender %s",
smtp,
sender
);
if (replyTo && replyTo[0]) {
StrPack(cmdLine, " -replyTo ", arrsize(cmdLine));
StrPack(cmdLine, replyTo, arrsize(cmdLine));
}
if (username && username[0]) {
StrPack(cmdLine, " -u ", arrsize(cmdLine));
StrPack(cmdLine, username, arrsize(cmdLine));
}
if (password && password[0]) {
StrPack(cmdLine, " -p ", arrsize(cmdLine));
StrPack(cmdLine, password, arrsize(cmdLine));
}
StrPack(cmdLine, " ", arrsize(cmdLine));
StrPack(cmdLine, recipients, arrsize(cmdLine));
StrPack(cmdLine, " ", arrsize(cmdLine));
StrPack(cmdLine, subject, arrsize(cmdLine));
// create process
STARTUPINFO si;
ZERO(si);
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdInput = pipes[IN_CHILD];
si.hStdOutput = INVALID_HANDLE_VALUE;
si.hStdError = INVALID_HANDLE_VALUE;
PROCESS_INFORMATION pi;
BOOL result = CreateProcess(
NULL,
cmdLine,
(LPSECURITY_ATTRIBUTES) NULL,
(LPSECURITY_ATTRIBUTES) NULL,
true, // => inherit handles
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi
);
if (!result)
break;
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
// Write output data
DWORD written, length = StrLen(logBuffer);
WriteFile(pipes[IN_PARENT], logBuffer, length, &written, NULL);
// complete
break;
}
// cleanup pipes
for (i = 0; i < arrsize(pipes); ++i) {
if (pipes[i] != INVALID_HANDLE_VALUE)
CloseHandle(pipes[i]);
}
}
//============================================================================
} // namespace Crash
//============================================================================
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreMail.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
//============================================================================
namespace Crash {
//============================================================================
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static bool CreateInheritablePipe (
HANDLE * read,
HANDLE * write,
bool inheritRead
) {
// create pipe for std error read/write
if (!CreatePipe(read, write, (LPSECURITY_ATTRIBUTES) NULL, 0))
return false;
// make the appropriate handle inheritable
HANDLE hProcess = GetCurrentProcess();
HANDLE * inherit = inheritRead ? read : write;
bool result = DuplicateHandle(
hProcess,
*inherit,
hProcess,
inherit,
0,
true, // make inheritable
DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS
);
if (!result)
return false;
return true;
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void CrashSendEmail (
const char smtp[],
const char sender[],
const char recipients[],
const char replyTo[],
const char username[],
const char password[],
const char programName[],
const char errorType[],
const char logBuffer[]
) {
enum {
IN_CHILD,
IN_PARENT,
NUM_PIPES
};
unsigned i;
HANDLE pipes[NUM_PIPES];
for (i = 0; i < arrsize(pipes); ++i)
pipes[i] = INVALID_HANDLE_VALUE;
for (;;) {
// create pipes for Server -> StdIn -> Client
if (!CreateInheritablePipe(&pipes[IN_CHILD], &pipes[IN_PARENT], true))
break;
char subject[512];
StrPrintf(
subject,
arrsize(subject),
"\"[Crash] %s, %s\"",
programName,
errorType
);
char cmdLine[512];
StrPrintf(
cmdLine,
arrsize(cmdLine),
"plMail.exe -smtp %s -sender %s",
smtp,
sender
);
if (replyTo && replyTo[0]) {
StrPack(cmdLine, " -replyTo ", arrsize(cmdLine));
StrPack(cmdLine, replyTo, arrsize(cmdLine));
}
if (username && username[0]) {
StrPack(cmdLine, " -u ", arrsize(cmdLine));
StrPack(cmdLine, username, arrsize(cmdLine));
}
if (password && password[0]) {
StrPack(cmdLine, " -p ", arrsize(cmdLine));
StrPack(cmdLine, password, arrsize(cmdLine));
}
StrPack(cmdLine, " ", arrsize(cmdLine));
StrPack(cmdLine, recipients, arrsize(cmdLine));
StrPack(cmdLine, " ", arrsize(cmdLine));
StrPack(cmdLine, subject, arrsize(cmdLine));
// create process
STARTUPINFO si;
ZERO(si);
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdInput = pipes[IN_CHILD];
si.hStdOutput = INVALID_HANDLE_VALUE;
si.hStdError = INVALID_HANDLE_VALUE;
PROCESS_INFORMATION pi;
BOOL result = CreateProcess(
NULL,
cmdLine,
(LPSECURITY_ATTRIBUTES) NULL,
(LPSECURITY_ATTRIBUTES) NULL,
true, // => inherit handles
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi
);
if (!result)
break;
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
// Write output data
DWORD written, length = StrLen(logBuffer);
WriteFile(pipes[IN_PARENT], logBuffer, length, &written, NULL);
// complete
break;
}
// cleanup pipes
for (i = 0; i < arrsize(pipes); ++i) {
if (pipes[i] != INVALID_HANDLE_VALUE)
CloseHandle(pipes[i]);
}
}
//============================================================================
} // namespace Crash
//============================================================================

View File

@ -1,185 +1,185 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/pnCreTools.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
//============================================================================
namespace Crash {
//============================================================================
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static BOOL MYIMAGEAPI iSymGetModuleInfo (
HANDLE,
DWORD,
IMAGEHLP_MODULE * ModuleInfo
) {
ZEROPTR(ModuleInfo);
return false;
}
//===========================================================================
static BOOL MYIMAGEAPI iStackWalk (
DWORD,
HANDLE,
HANDLE,
LPSTACKFRAME,
LPVOID,
PREAD_PROCESS_MEMORY_ROUTINE,
PFUNCTION_TABLE_ACCESS_ROUTINE,
PGET_MODULE_BASE_ROUTINE,
PTRANSLATE_ADDRESS_ROUTINE
) {
return false;
}
//===========================================================================
static LPVOID MYIMAGEAPI iSymFunctionTableAccess (
HANDLE,
DWORD
) {
return nil;
}
//===========================================================================
static DWORD MYIMAGEAPI iSymGetModuleBase (
HANDLE,
DWORD
) {
return 0;
}
//===========================================================================
static BOOL MYIMAGEAPI iSymGetSymFromAddr (
HANDLE,
DWORD,
LPDWORD Displacement,
PIMAGEHLP_SYMBOL Symbol
) {
*Displacement = 0;
ZEROPTR(Symbol);
return false;
}
/*****************************************************************************
*
* CImageHelp
*
***/
//============================================================================
CImageHelp::CImageHelp (HINSTANCE instance)
: m_libInst(nil),
m_process(nil)
{
// get program directory and filename
if (!GetModuleFileNameA(instance, m_appPath, arrsize(m_appPath)))
m_appPath[0] = 0;
if (nil != (m_appName = StrChrR(m_appPath, '\\')))
*m_appName++ = '\0';
else
m_appName = m_appPath;
// initialize symbols
for (;;) {
if (nil == (m_libInst = LoadLibrary("ImageHlp.dll")))
break;
// initialize symbols for this process
BOOL (MYIMAGEAPI * SymInitialize)(HANDLE hProcess, char * path, BOOL fInvade);
* (FARPROC *) &SymInitialize = GetProcAddress(m_libInst, "SymInitialize");
if (!SymInitialize)
break;
HANDLE hProcess = GetCurrentProcess();
if (!SymInitialize(hProcess, m_appPath, false))
break;
// import functions
FARPROC proc;
#define BIND(x) * (FARPROC *) &(x) = ((proc = GetProcAddress(m_libInst, #x)) != nil) ? proc : (FARPROC) i##x
BIND(SymGetModuleInfo);
BIND(StackWalk);
BIND(SymFunctionTableAccess);
BIND(SymGetModuleBase);
BIND(SymGetSymFromAddr);
#undef BIND
// success
m_process = hProcess;
return;
}
// failure!
if (m_libInst) {
FreeLibrary(m_libInst);
m_libInst = nil;
}
#define INIT(x) x = i##x
INIT(SymGetModuleInfo);
INIT(StackWalk);
INIT(SymFunctionTableAccess);
INIT(SymGetModuleBase);
INIT(SymGetSymFromAddr);
#undef INIT
}
//============================================================================
CImageHelp::~CImageHelp () {
if (m_process) {
BOOL (MYIMAGEAPI * SymCleanup)(HANDLE hProcess);
* (FARPROC *) &SymCleanup = GetProcAddress(m_libInst, "SymCleanup");
if (SymCleanup)
SymCleanup(m_process);
m_process = 0;
}
if (m_libInst) {
FreeLibrary(m_libInst);
m_libInst = 0;
}
}
//============================================================================
} // namespace Crash
//============================================================================
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/pnCreTools.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
//============================================================================
namespace Crash {
//============================================================================
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static BOOL MYIMAGEAPI iSymGetModuleInfo (
HANDLE,
DWORD,
IMAGEHLP_MODULE * ModuleInfo
) {
ZEROPTR(ModuleInfo);
return false;
}
//===========================================================================
static BOOL MYIMAGEAPI iStackWalk (
DWORD,
HANDLE,
HANDLE,
LPSTACKFRAME,
LPVOID,
PREAD_PROCESS_MEMORY_ROUTINE,
PFUNCTION_TABLE_ACCESS_ROUTINE,
PGET_MODULE_BASE_ROUTINE,
PTRANSLATE_ADDRESS_ROUTINE
) {
return false;
}
//===========================================================================
static LPVOID MYIMAGEAPI iSymFunctionTableAccess (
HANDLE,
DWORD
) {
return nil;
}
//===========================================================================
static DWORD MYIMAGEAPI iSymGetModuleBase (
HANDLE,
DWORD
) {
return 0;
}
//===========================================================================
static BOOL MYIMAGEAPI iSymGetSymFromAddr (
HANDLE,
DWORD,
LPDWORD Displacement,
PIMAGEHLP_SYMBOL Symbol
) {
*Displacement = 0;
ZEROPTR(Symbol);
return false;
}
/*****************************************************************************
*
* CImageHelp
*
***/
//============================================================================
CImageHelp::CImageHelp (HINSTANCE instance)
: m_libInst(nil),
m_process(nil)
{
// get program directory and filename
if (!GetModuleFileNameA(instance, m_appPath, arrsize(m_appPath)))
m_appPath[0] = 0;
if (nil != (m_appName = StrChrR(m_appPath, '\\')))
*m_appName++ = '\0';
else
m_appName = m_appPath;
// initialize symbols
for (;;) {
if (nil == (m_libInst = LoadLibrary("ImageHlp.dll")))
break;
// initialize symbols for this process
BOOL (MYIMAGEAPI * SymInitialize)(HANDLE hProcess, char * path, BOOL fInvade);
* (FARPROC *) &SymInitialize = GetProcAddress(m_libInst, "SymInitialize");
if (!SymInitialize)
break;
HANDLE hProcess = GetCurrentProcess();
if (!SymInitialize(hProcess, m_appPath, false))
break;
// import functions
FARPROC proc;
#define BIND(x) * (FARPROC *) &(x) = ((proc = GetProcAddress(m_libInst, #x)) != nil) ? proc : (FARPROC) i##x
BIND(SymGetModuleInfo);
BIND(StackWalk);
BIND(SymFunctionTableAccess);
BIND(SymGetModuleBase);
BIND(SymGetSymFromAddr);
#undef BIND
// success
m_process = hProcess;
return;
}
// failure!
if (m_libInst) {
FreeLibrary(m_libInst);
m_libInst = nil;
}
#define INIT(x) x = i##x
INIT(SymGetModuleInfo);
INIT(StackWalk);
INIT(SymFunctionTableAccess);
INIT(SymGetModuleBase);
INIT(SymGetSymFromAddr);
#undef INIT
}
//============================================================================
CImageHelp::~CImageHelp () {
if (m_process) {
BOOL (MYIMAGEAPI * SymCleanup)(HANDLE hProcess);
* (FARPROC *) &SymCleanup = GetProcAddress(m_libInst, "SymCleanup");
if (SymCleanup)
SymCleanup(m_process);
m_process = 0;
}
if (m_libInst) {
FreeLibrary(m_libInst);
m_libInst = 0;
}
}
//============================================================================
} // namespace Crash
//============================================================================