This commit is contained in:
2025-11-24 14:19:51 +05:30
commit f5c1412b28
6734 changed files with 1527575 additions and 0 deletions

View File

@ -0,0 +1,17 @@
#
# This file was taken from RakNet 4.082 without any modifications.
# Please see licenses/RakNet license.txt for the underlying license and related copyright.
#
cmake_minimum_required(VERSION 2.6)
IF (WIN32 AND NOT UNIX)
GETCURRENTFOLDER()
STANDARDSUBPROJECTWITHOPTIONS(${current_folder} "" "" "Dbghelp.lib")
ENDIF(WIN32 AND NOT UNIX)

View File

@ -0,0 +1,223 @@
/*
* Original work: Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
*
* Modified work: Copyright (c) 2016-2020, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
// To compile link with Dbghelp.lib
// The callstack in release is the same as usual, which means it isn't all that accurate.
#ifdef WIN32
#include <stdio.h>
#include "slikenet/WindowsIncludes.h"
#pragma warning(push)
// disable warning 4091 (triggers for enum typedefs in DbgHelp.h in Windows SDK 7.1 and Windows SDK 8.1)
#pragma warning(disable:4091)
#include <DbgHelp.h>
#pragma warning(pop)
#include <stdlib.h>
#include <time.h>
#include "SendFileTo.h"
#include "CrashReporter.h"
#include "slikenet/EmailSender.h"
#include "slikenet/FileList.h"
#include "slikenet/FileOperations.h"
#include "slikenet/SimpleMutex.h"
#include "slikenet/linux_adapter.h"
#include "slikenet/osx_adapter.h"
using namespace SLNet;
CrashReportControls CrashReporter::controls;
// More info at:
// http://www.codeproject.com/debug/postmortemdebug_standalone1.asp
// http://www.codeproject.com/debug/XCrashReportPt3.asp
// http://www.codeproject.com/debug/XCrashReportPt1.asp
// http://www.microsoft.com/msj/0898/bugslayer0898.aspx
LONG ProcessException(struct _EXCEPTION_POINTERS *ExceptionInfo)
{
char appDescriptor[_MAX_PATH];
if ((CrashReporter::controls.actionToTake & AOC_SILENT_MODE) == 0)
{
sprintf_s(appDescriptor, "%s has crashed.\nGenerate a report?", CrashReporter::controls.appName);
if (::MessageBoxA(nullptr, appDescriptor, "Crash Reporter", MB_YESNO )==IDNO)
{
return EXCEPTION_CONTINUE_SEARCH;
}
}
char dumpFilepath[_MAX_PATH];
char dumpFilename[_MAX_PATH];
sprintf_s(appDescriptor, "%s %s - %s %s", CrashReporter::controls.appName, CrashReporter::controls.appVersion, __DATE__, __TIME__);
if ((CrashReporter::controls.actionToTake & AOC_EMAIL_WITH_ATTACHMENT) ||
(CrashReporter::controls.actionToTake & AOC_WRITE_TO_DISK)
)
{
if (CrashReporter::controls.actionToTake & AOC_WRITE_TO_DISK)
{
strcpy_s(dumpFilepath, CrashReporter::controls.pathToMinidump);
WriteFileWithDirectories(dumpFilepath,0,0);
AddSlash(dumpFilepath);
}
else
{
// Write to a temporary directory if the user doesn't want the dump on the harddrive.
if (!GetTempPathA( _MAX_PATH, dumpFilepath ))
dumpFilepath[0]=0;
}
unsigned i, dumpFilenameLen;
strcpy_s(dumpFilename, appDescriptor);
dumpFilenameLen=(unsigned) strlen(appDescriptor);
for (i=0; i < dumpFilenameLen; i++)
if (dumpFilename[i]==':' || dumpFilename[i]=='/' || dumpFilename[i]=='\\')
dumpFilename[i]='.'; // Remove illegal characters from filename
strcat_s(dumpFilepath, dumpFilename);
strcat_s(dumpFilepath, ".dmp");
HANDLE hFile = CreateFileA(dumpFilepath,GENERIC_WRITE, FILE_SHARE_READ, nullptr,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile==INVALID_HANDLE_VALUE)
return EXCEPTION_CONTINUE_SEARCH;
MINIDUMP_EXCEPTION_INFORMATION eInfo;
eInfo.ThreadId = GetCurrentThreadId();
eInfo.ExceptionPointers = ExceptionInfo;
eInfo.ClientPointers = FALSE;
if (MiniDumpWriteDump(
GetCurrentProcess(),
GetCurrentProcessId(),
hFile,
(MINIDUMP_TYPE)CrashReporter::controls.minidumpType,
ExceptionInfo ? &eInfo : nullptr,
nullptr,
nullptr)==false)
return EXCEPTION_CONTINUE_SEARCH;
CloseHandle(hFile);
}
char silentModeEmailBody[1024];
char subject[1204];
if (CrashReporter::controls.actionToTake & AOC_EMAIL_NO_ATTACHMENT)
{
strcpy_s(subject, CrashReporter::controls.emailSubjectPrefix);
strcat_s(subject, appDescriptor);
if (CrashReporter::controls.actionToTake & AOC_SILENT_MODE)
{
sprintf_s(silentModeEmailBody, "%s%s version %s has crashed.\r\nIt was compiled on %s %s.\r\n", CrashReporter::controls.emailBody, CrashReporter::controls.appName,CrashReporter::controls.appVersion, __DATE__, __TIME__);
if (CrashReporter::controls.actionToTake & AOC_WRITE_TO_DISK)
sprintf_s(silentModeEmailBody+strlen(silentModeEmailBody), 1024-strlen(silentModeEmailBody), "Minidump written to %s \r\n", dumpFilepath);
// Silently send email with attachment
EmailSender emailSender;
emailSender.Send(CrashReporter::controls.SMTPServer,
25,
CrashReporter::controls.SMTPAccountName,
CrashReporter::controls.emailRecipient,
CrashReporter::controls.emailSender,
CrashReporter::controls.emailRecipient,
subject,
silentModeEmailBody,
0,
false,
CrashReporter::controls.emailPassword);
}
else
{
CSendFileTo sendFile;
sendFile.SendMail(0, 0, 0, subject, CrashReporter::controls.emailBody, CrashReporter::controls.emailRecipient);
}
}
else if (CrashReporter::controls.actionToTake & AOC_EMAIL_WITH_ATTACHMENT)
{
strcpy_s(subject, CrashReporter::controls.emailSubjectPrefix);
strcat_s(subject, dumpFilename);
strcat_s(dumpFilename, ".dmp");
if (CrashReporter::controls.actionToTake & AOC_SILENT_MODE)
{
sprintf_s(silentModeEmailBody, "%s%s version %s has crashed.\r\nIt was compiled on %s %s.\r\n", CrashReporter::controls.emailBody, CrashReporter::controls.appName,CrashReporter::controls.appVersion, __DATE__, __TIME__);
if (CrashReporter::controls.actionToTake & AOC_WRITE_TO_DISK)
sprintf_s(silentModeEmailBody+strlen(silentModeEmailBody), 1024-strlen(silentModeEmailBody), "Minidump written to %s \r\n", dumpFilepath);
// Silently send email with attachment
EmailSender emailSender;
FileList files;
files.AddFile(dumpFilepath,dumpFilename,FileListNodeContext(0,0,0,0));
emailSender.Send(CrashReporter::controls.SMTPServer,
25,
CrashReporter::controls.SMTPAccountName,
CrashReporter::controls.emailRecipient,
CrashReporter::controls.emailSender,
CrashReporter::controls.emailRecipient,
subject,
silentModeEmailBody,
&files,
false,
CrashReporter::controls.emailPassword);
}
else
{
CSendFileTo sendFile;
sendFile.SendMail(0, dumpFilepath, dumpFilename, subject, CrashReporter::controls.emailBody, CrashReporter::controls.emailRecipient);
}
}
return EXCEPTION_EXECUTE_HANDLER;
}
LONG WINAPI CrashExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo )
{
// Mutex here due to http://www.jenkinssoftware.com/raknet/forum/index.php?topic=2305.0;topicseen
static SimpleMutex crashExceptionFilterMutex;
crashExceptionFilterMutex.Lock();
LONG retVal = ProcessException(ExceptionInfo);
crashExceptionFilterMutex.Unlock();
return retVal;
}
void DumpMiniDump(PEXCEPTION_POINTERS excpInfo)
{
if (excpInfo == nullptr)
{
// Generate exception to get proper context in dump
__try
{
RaiseException(EXCEPTION_BREAKPOINT, 0, 0, nullptr);
}
__except(DumpMiniDump(GetExceptionInformation()),EXCEPTION_EXECUTE_HANDLER)
{
}
}
else
{
ProcessException(excpInfo);
}
}
// #define _DEBUG_CRASH_REPORTER
void CrashReporter::Start(CrashReportControls *input)
{
memcpy(&controls, input, sizeof(CrashReportControls));
#ifndef _DEBUG_CRASH_REPORTER
SetUnhandledExceptionFilter(CrashExceptionFilter);
#endif
}
#endif //WIN32

View File

@ -0,0 +1,142 @@
/*
* Original work: Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
*
* Modified work: Copyright (c) 2017-2018, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#ifndef __CRASH_REPORTER_H
#define __CRASH_REPORTER_H
// This is a crash reporter that will send a minidump by email on unhandled exceptions
// This normally only runs if you are not currently debugging.
// To send reports while debugging (mostly to test this class), define _DEBUG_CRASH_REPORTER
// and put your code in a try/except block such as
//
// extern void DumpMiniDump(PEXCEPTION_POINTERS excpInfo);
//
// void main(void)
//{
//__try
//{
// RunGame();
//}
//__except(DumpMiniDump(GetExceptionInformation()),EXCEPTION_EXECUTE_HANDLER)
//{
//}
//}
// The minidump can be opened in visual studio and will show you where the crash occurred and give you the local variable values.
//
// How to use the minidump:
//
// Put the minidump on your harddrive and double click it. It will open Visual Studio. It will look for the exe that caused the crash in the directory
// that the program that crashed was running at. If it can't find this exe, or if it is different, it will look in the current
// directory for that exe. If it still can't find it, or if it is different, it will load Visual Studio and indicate that it can't find
// the executable module. No source code will be shown at that point. However, you can specify modpath=<pathToExeDirectory> in the
// project properties window for "Command Arguments".
// The best solution is copy the .dmp to a directory containing a copy of the exe that crashed.
//
// On load, Visual Studio will look for the .pdb, which it uses to find the source code files and other information. This is fine as long as the source
// code files on your harddrive match those that were used to create the exe. If they don't, you will see source code but it will be the wrong code.
// There are three ways to deal with this.
//
// The first way is to change the path to your source code so it won't find the wrong code automatically.
// This will cause the debugger to not find the source code pointed to in the .pdb . You will be prompted for the location of the correct source code.
//
// The second way is to build the exe on a different path than what you normally program with. For example, when you program you use c:/Working/Mygame
// When you release builds, you do at c:/Version2.2/Mygame . After a build, you keep the source files, the exe, and the pdb
// on a harddrive at that location. When you get a crash .dmp, copy it to the same directory as the exe, ( c:/Version2.2/Mygame/bin )
// This way the .pdb will point to the correct sources to begin wtih.
//
// The third way is save build labels or branches in source control and get that version (you only need source code + .exe + .pdb) before debugging.
// After debugging, restore your previous work.
//
// To use:
// #include "DbgHelp.h"
// Link with Dbghelp.lib ws2_32.lib
#include "slikenet/defines.h" // used for SLNet -> RakNet namespace change in RAKNET_COMPATIBILITY mode
namespace SLNet {
// Possible actions to take on a crash. If you want to restart the app as well, see the CrashRelauncher sample.
enum CrashReportAction
{
// Send an email (mutually exclusive with AOC_EMAIL_WITH_ATTACHMENT)
AOC_EMAIL_NO_ATTACHMENT=1,
// Send an email and attach the minidump (mutually exclusive with AOC_EMAIL_NO_ATTACHMENT)
AOC_EMAIL_WITH_ATTACHMENT=2,
// Write the minidump to disk in a specified directory
AOC_WRITE_TO_DISK=4,
// In silent mode there are no prompts. This is useful for an unmonitored application.
AOC_SILENT_MODE=8
};
/// Holds all the parameters to CrashReporter::Start
struct CrashReportControls
{
// Bitwise OR of CrashReportAction values to determine what to do on a crash.
int actionToTake;
// Used to generate the dump filename. Required with AOC_EMAIL_WITH_ATTACHMENT or AOC_WRITE_TO_DISK
char appName[128];
char appVersion[128];
// Used with AOC_WRITE_TO_DISK . Path to write to. Not the filename, just the path. Empty string means the current directory.
char pathToMinidump[260];
// Required with AOC_EMAIL_* & AOC_SILENT_MODE . The SMTP server to send emails from.
char SMTPServer[128];
// Required with AOC_EMAIL_* & AOC_SILENT_MODE . The account name to send emails with (probably your email address).
char SMTPAccountName[64];
// Required with AOC_EMAIL_* & AOC_SILENT_MODE . What to put in the sender field of the email.
char emailSender[64];
// Required with AOC_EMAIL_* . What to put in the subject of the email.
char emailSubjectPrefix[128];
// Required with AOC_EMAIL_* as long as you are NOT in AOC_SILENT_MODE . What to put in the body of the email.
char emailBody[1024];
// Required with AOC_EMAIL_* . Who to send the email to.
char emailRecipient[64];
// Required with AOC_EMAIL_* . What password to use to send the email under TLS, if required
char emailPassword[64];
// How much memory to write. MiniDumpNormal is the least but doesn't seem to give correct globals. MiniDumpWithDataSegs gives more.
// Include "DbgHelp.h" for these enumerations.
int minidumpType;
};
/// \brief On an unhandled exception, will save a minidump and email it.
/// A minidump can be opened in visual studio to give the callstack and local variables at the time of the crash.
/// It has the same amount of information as if you crashed while debugging in the relevant mode. So Debug tends to give
/// accurate stacks and info while Release does not.
///
/// Minidumps are only accurate for the code as it was compiled at the date of the release. So you should label releases in source control
/// and put that label number in the 'appVersion' field.
class CrashReporter
{
public:
static void Start(CrashReportControls *input);
static CrashReportControls controls;
};
} // namespace SLNet
#endif

View File

@ -0,0 +1,269 @@
<?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="Debug - Unicode|Win32">
<Configuration>Debug - Unicode</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release - Unicode|Win32">
<Configuration>Release - Unicode</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Retail - Unicode|Win32">
<Configuration>Retail - Unicode</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Retail|Win32">
<Configuration>Retail</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>CrashReporter</ProjectName>
<ProjectGuid>{F1DC7171-0188-492F-9FC3-733B285836D2}</ProjectGuid>
<RootNamespace>CrashReporter</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</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" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</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" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">$(Configuration)\</OutDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">$(Configuration)\</OutDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>Dbghelp.lib;./../../Lib/SLikeNet_LibStatic_Debug_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)CrashReporter.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - Unicode|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>Dbghelp.lib;./../../Lib/SLikeNet_LibStatic_Debug - Unicode_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)CrashReporter.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>Dbghelp.lib;./../../Lib/SLikeNet_LibStatic_Release_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Retail|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_RETAIL;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<AdditionalDependencies>Dbghelp.lib;./../../Lib/SLikeNet_LibStatic_Retail_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - Unicode|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>Dbghelp.lib;./../../Lib/SLikeNet_LibStatic_Release - Unicode_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Retail - Unicode|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>./../../Source/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;WIN32;_RETAIL;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>true</MinimalRebuild>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<AdditionalDependencies>Dbghelp.lib;./../../Lib/SLikeNet_LibStatic_Retail - Unicode_Win32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CrashReporter.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="SendFileTo.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CrashReporter.h" />
<ClInclude Include="SendFileTo.h" />
</ItemGroup>
<ItemGroup>
<None Include="VTune\CrashReporter.vpj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Lib\LibStatic\LibStatic.vcxproj">
<Project>{6533bdae-0f0c-45e4-8fe7-add0f37fe063}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CrashReporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SendFileTo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CrashReporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SendFileTo.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="VTune\CrashReporter.vpj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,121 @@
/*
* Original work: Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
*
* Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#include "slikenet/WindowsIncludes.h"
#include "SendFileTo.h"
#include <shlwapi.h>
#include <tchar.h>
#include <stdio.h>
#include <direct.h>
#include "slikenet/linux_adapter.h"
#include "slikenet/osx_adapter.h"
bool CSendFileTo::SendMail(HWND hWndParent, const char *strAttachmentFilePath, const char *strAttachmentFileName, const char *strSubject, const char *strBody, const char *strRecipient)
{
// if (strAttachmentFileName==0)
// return false;
// if (!hWndParent || !::IsWindow(hWndParent))
// return false;
HINSTANCE hMAPI = LoadLibrary(_T("MAPI32.DLL"));
if (!hMAPI)
return false;
ULONG (PASCAL *SendMail)(ULONG, ULONG_PTR, MapiMessage*, FLAGS, ULONG);
(FARPROC&)SendMail = GetProcAddress(hMAPI, "MAPISendMail");
if (!SendMail)
return false;
// char szFileName[_MAX_PATH];
// char szPath[_MAX_PATH];
char szName[_MAX_PATH];
char szSubject[_MAX_PATH];
char szBody[_MAX_PATH];
char szAddress[_MAX_PATH];
char szSupport[_MAX_PATH];
//strcpy_s(szFileName, strAttachmentFileName);
//strcpy_s(szPath, strAttachmentFilePath);
if (strAttachmentFileName)
strcpy_s(szName, strAttachmentFileName);
strcpy_s(szSubject, strSubject);
strcpy_s(szBody, strBody);
sprintf_s(szAddress, "SMTP:%s", strRecipient);
//strcpy_s(szSupport, "Support");
char fullPath[_MAX_PATH];
if (strAttachmentFileName && strAttachmentFilePath)
{
if (strlen(strAttachmentFilePath)<3 ||
strAttachmentFilePath[1]!=':' ||
(strAttachmentFilePath[2]!='\\' &&
strAttachmentFilePath[2]!='/'))
{
// Make relative paths absolute
_getcwd(fullPath, _MAX_PATH);
strcat_s(fullPath, "/");
strcat_s(fullPath, strAttachmentFilePath);
}
else
strcpy_s(fullPath, strAttachmentFilePath);
// All slashes have to be \\ and not /
int len=(unsigned int)strlen(fullPath);
int i;
for (i=0; i < len; i++)
{
if (fullPath[i]=='/')
fullPath[i]='\\';
}
}
MapiFileDesc fileDesc;
if (strAttachmentFileName && strAttachmentFilePath)
{
ZeroMemory(&fileDesc, sizeof(fileDesc));
fileDesc.nPosition = (ULONG)-1;
fileDesc.lpszPathName = fullPath;
fileDesc.lpszFileName = szName;
}
MapiRecipDesc recipDesc;
ZeroMemory(&recipDesc, sizeof(recipDesc));
recipDesc.lpszName = szSupport;
recipDesc.ulRecipClass = MAPI_TO;
recipDesc.lpszName = szAddress+5;
recipDesc.lpszAddress = szAddress;
MapiMessage message;
ZeroMemory(&message, sizeof(message));
message.nRecipCount = 1;
message.lpRecips = &recipDesc;
message.lpszSubject = szSubject;
message.lpszNoteText = szBody;
if (strAttachmentFileName && strAttachmentFilePath)
{
message.nFileCount = 1;
message.lpFiles = &fileDesc;
}
int nError = SendMail(0, (ULONG_PTR)hWndParent, &message, MAPI_LOGON_UI|MAPI_DIALOG, 0);
if (nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
return false;
return true;
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
* Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
// Mostly from http://www.codeproject.com/internet/SendTo.asp and
// Also see http://www.codeguru.com/cpp/i-n/network/messaging/article.php/c5417/
#ifndef __SENDFILETO_H__
#define __SENDFILETO_H__
#include "slikenet/WindowsIncludes.h"
#include <mapi.h>
class CSendFileTo
{
public:
bool SendMail(HWND hWndParent, const char *strAttachmentFilePath, const char *strAttachmentFileName,const char *strSubject, const char *strBody, const char *strRecipient);
};
#endif

View File

@ -0,0 +1,172 @@
/*
* Original work: Copyright (c) 2014, Oculus VR, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* RakNet License.txt file in the licenses directory of this source tree. An additional grant
* of patent rights can be found in the RakNet Patents.txt file in the same directory.
*
*
* Modified work: Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
// Windows only sample to catch unhandled exceptions and email a minidump.
// The minidump can be opened in visual studio and will show you where the crash occurred and give you the local variable values.
//
// How to use the minidump:
//
// Put the minidump on your harddrive and double click it. It will open Visual Studio. It will look for the exe that caused the crash in the directory
// that the program that crashed was running at. If it can't find this exe, or if it is different, it will look in the current
// directory for that exe. If it still can't find it, or if it is different, it will load Visual Studio and indicate that it can't find
// the executable module. No source code will be shown at that point. However, you can specify modpath=<pathToExeDirectory> in the
// project properties window for "Command Arguments".
// The best solution is copy the .dmp to a directory containing a copy of the exe that crashed.
//
// On load, Visual Studio will look for the .pdb, which it uses to find the source code files and other information. This is fine as long as the source
// code files on your harddrive match those that were used to create the exe. If they don't, you will see source code but it will be the wrong code.
// There are three ways to deal with this.
//
// The first way is to change the path to your source code so it won't find the wrong code automatically.
// This will cause the debugger to not find the source code pointed to in the .pdb . You will be prompted for the location of the correct source code.
//
// The second way is to build the exe on a different path than what you normally program with. For example, when you program you use c:/Working/Mygame
// When you release builds, you do at c:/Version2.2/Mygame . After a build, you keep the source files, the exe, and the pdb
// on a harddrive at that location. When you get a crash .dmp, copy it to the same directory as the exe, ( c:/Version2.2/Mygame/bin )
// This way the .pdb will point to the correct sources to begin wtih.
//
// The third way is save build labels or branches in source control and get that version (you only need source code + .exe + .pdb) before debugging.
// After debugging, restore your previous work.
#include "slikenet/SocketLayer.h"
#include "CrashReporter.h" // This is the only required file for the crash reporter. You must link in Dbghelp.lib
#include <stdio.h> // Printf, for the sample code
#include "slikenet/Kbhit.h" // getch, for the sample code
#pragma warning(push)
// disable warning 4091 (triggers for enum typedefs in DbgHelp.h in Windows SDK 7.1 and Windows SDK 8.1)
#pragma warning(disable:4091)
#include <DbgHelp.h>
#pragma warning(pop)
#include "slikenet/Gets.h"
void function1(int a)
{
int *crashPtr=0;
// Keep crashPtr from getting compiled out
printf("Now crashing!!!! %p\n", crashPtr);
// If it crashes here in your debugger that is because you didn't define _DEBUG_CRASH_REPORTER to catch it.
// The normal mode of the crash handler is to only catch when you are NOT debugging (started through ctrl-f5)
*crashPtr=a;
}
void RunGame(void)
{
int a=10;
int b=20;
function1(a);
printf("%i", b);
}
//#define _DEBUG_CRASH_REPORTER
// If you don't plan to debug the crash reporter itself, you can remove _DEBUG_CRASH_REPORTER
#ifdef _DEBUG_CRASH_REPORTER
#include "slikenet/WindowsIncludes.h"
extern void DumpMiniDump(PEXCEPTION_POINTERS excpInfo);
#endif
void main(void)
{
printf("Demonstrates the crash reporter.\n");
printf("This program will prompt you for a variety of actions to take on crash.\n");
printf("If so desired, it will generate a minidump which can be opened in visual studio\n");
printf("to debug the crash.\n\n");
SLNet::CrashReportControls controls;
controls.actionToTake=0;
printf("Send an email? (y/n)\n");
if (_getch()=='y')
{
printf("Attach the mini-dump to the email? (y/n)\n");
if (_getch()=='y')
controls.actionToTake|= SLNet::AOC_EMAIL_WITH_ATTACHMENT;
else
controls.actionToTake|= SLNet::AOC_EMAIL_NO_ATTACHMENT;
}
printf("Write mini-dump to disk? (y/n)\n");
if (_getch()=='y')
controls.actionToTake|= SLNet::AOC_WRITE_TO_DISK;
printf("Handle crashes in silent mode (no prompts)? (y/n)\n");
if (_getch()=='y')
controls.actionToTake|= SLNet::AOC_SILENT_MODE;
if ((controls.actionToTake & SLNet::AOC_EMAIL_WITH_ATTACHMENT) || (controls.actionToTake & SLNet::AOC_EMAIL_NO_ATTACHMENT))
{
if (controls.actionToTake & SLNet::AOC_SILENT_MODE)
{
printf("Enter SMTP Server: ");
Gets(controls.SMTPServer,sizeof(controls.SMTPServer));
if (controls.SMTPServer[0]==0)
return;
printf("Enter SMTP account name: ");
Gets(controls.SMTPAccountName,sizeof(controls.SMTPAccountName));
if (controls.SMTPAccountName[0]==0)
return;
printf("Enter sender email address: ");
Gets(controls.emailSender,sizeof(controls.emailSender));
}
printf("Enter email recipient email address: ");
Gets(controls.emailRecipient,sizeof(controls.emailRecipient));
if (controls.emailRecipient[0]==0)
return;
printf("Enter subject prefix, if any: ");
Gets(controls.emailSubjectPrefix,sizeof(controls.emailSubjectPrefix));
if ((controls.actionToTake & SLNet::AOC_SILENT_MODE)==0)
{
printf("Enter text to write in email body: ");
Gets(controls.emailBody,sizeof(controls.emailBody));
}
}
if (controls.actionToTake & SLNet::AOC_WRITE_TO_DISK)
{
printf("Enter disk path to write to (ENTER for current directory): ");
Gets(controls.pathToMinidump,sizeof(controls.pathToMinidump));
}
printf("Enter application name: ");
Gets(controls.appName,sizeof(controls.appName));
printf("Enter application version: ");
Gets(controls.appVersion,sizeof(controls.appVersion));
// MiniDumpNormal will not give you SocketLayer::I correctly but is small (like 15K)
// MiniDumpWithDataSegs is much bigger (391K) but does give you SocketLayer::I correctly.
controls.minidumpType=MiniDumpWithDataSegs;
// You must call Start before any crashes will be reported.
SLNet::CrashReporter::Start(&controls);
printf("Crash reporter started.\n");
// If you don't plan to debug the crash reporter itself, you can remove the __try within _DEBUG_CRASH_REPORTER
#ifdef _DEBUG_CRASH_REPORTER
__try
#endif
{
RunGame();
}
// If you don't plan to debug the crash reporter itself, you can remove the DumpMiniDump code within _DEBUG_CRASH_REPORTER
#ifdef _DEBUG_CRASH_REPORTER
__except(DumpMiniDump(GetExceptionInformation()),EXCEPTION_EXECUTE_HANDLER)
{
}
#endif
}