Browse Source

Kill pnCrashExe.

Darryl Pogue 13 years ago
parent
commit
46ca15c61c
  1. 2
      Sources/Plasma/NucleusLib/CMakeLists.txt
  2. 28
      Sources/Plasma/NucleusLib/pnCrashExe/CMakeLists.txt
  3. 65
      Sources/Plasma/NucleusLib/pnCrashExe/Pch.h
  4. 147
      Sources/Plasma/NucleusLib/pnCrashExe/Win32/W32Int.h
  5. 1075
      Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreError.cpp
  6. 49
      Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreGui.cpp
  7. 214
      Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreMail.cpp
  8. 201
      Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreTools.cpp

2
Sources/Plasma/NucleusLib/CMakeLists.txt

@ -4,8 +4,6 @@ add_subdirectory(inc)
add_subdirectory(pnAddrInfo)
add_subdirectory(pnAsyncCore)
add_subdirectory(pnAsyncCoreExe)
#add_subdirectory(pnCrash) # Not being used in any current sln
#add_subdirectory(pnCrashExe) # Not being used in any current sln
#add_subdirectory(pnCsrCli) # Not being used in any current sln
add_subdirectory(pnCsrNet)
add_subdirectory(pnDispatch)

28
Sources/Plasma/NucleusLib/pnCrashExe/CMakeLists.txt

@ -1,28 +0,0 @@
include_directories(../../CoreLib)
include_directories(../../NucleusLib)
set(pnCrashExe_SOURCES
)
set(pnCrashExe_HEADERS
Pch.h
)
if(WIN32 AND NOT CYGWIN)
set (pnCrashExe_SOURCES ${pnCrashExe_SOURCES}
Win32/pnCreError.cpp
Win32/pnCreGui.cpp
Win32/pnCreMail.cpp
Win32/pnCreTools.cpp
)
set (pnCrashExe_HEADERS ${pnCrashExe_HEADERS}
Win32/W32Int.h
)
endif(WIN32 AND NOT CYGWIN)
add_library(pnCrashExe STATIC ${pnCrashExe_SOURCES} ${pnCrashExe_HEADERS})
source_group("Source Files" FILES ${pnCrashExe_SOURCES})
source_group("Header Files" FILES ${pnCrashExe_HEADERS})

65
Sources/Plasma/NucleusLib/pnCrashExe/Pch.h

@ -1,65 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnMail/pnMail.h"
#include <ImageHlp.h>
#include <process.h>
#ifdef HS_BUILD_FOR_WIN32
#include "Win32/W32Int.h"
#endif

147
Sources/Plasma/NucleusLib/pnCrashExe/Win32/W32Int.h

@ -1,147 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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;

1075
Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreError.cpp

File diff suppressed because it is too large Load Diff

49
Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreGui.cpp

@ -1,49 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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

214
Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreMail.cpp

@ -1,214 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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;
memset(&si, 0, sizeof(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
//============================================================================

201
Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreTools.cpp

@ -1,201 +0,0 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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
) {
memset(ModuleInfo, 0, sizeof(*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;
memset(Symbol, 0, sizeof(*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
//============================================================================
Loading…
Cancel
Save