Windows build 1.4.0

This commit is contained in:
WolverinDEV 2019-10-19 16:05:46 +01:00
parent d8c008ad56
commit ee7ae3b395
5 changed files with 31 additions and 9 deletions

View File

@ -110,7 +110,7 @@ if (MSVC)
foreach(CompilerFlag ${CompilerFlags}) foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach() endforeach()
add_compile_options("/EHa") #We require exception handling add_compile_options("/EHsc") #We require exception handling
else() else()
#This is a bad thing here! #This is a bad thing here!
function(resolve_library VARIABLE FALLBACK PATHS) function(resolve_library VARIABLE FALLBACK PATHS)

View File

@ -8,6 +8,7 @@
#include <experimental/filesystem> #include <experimental/filesystem>
#include <iostream> #include <iostream>
#include <thread>
#include "base64.h" #include "base64.h"
using namespace std; using namespace std;
@ -151,12 +152,12 @@ bool crash_callback(const fs::path& source_file, CrashContext* context, const st
return succeeded; return succeeded;
} }
bool signal::setup(std::unique_ptr<CrashContext>& context) { extern void create_minidump(struct _EXCEPTION_POINTERS* apExceptionInfo);
bool signal::setup(std::unique_ptr<CrashContext>& context) {
#ifndef WIN32 #ifndef WIN32
global_crash_handler = make_unique<google_breakpad::ExceptionHandler>(google_breakpad::MinidumpDescriptor("/tmp"), nullptr, breakpad_crash_callback, nullptr, true, -1); global_crash_handler = make_unique<google_breakpad::ExceptionHandler>(google_breakpad::MinidumpDescriptor("/tmp"), nullptr, breakpad_crash_callback, nullptr, true, -1);
#else #else
//SetUnhandledExceptionFilter(unhandled_handler);
global_crash_handler = AddVectoredExceptionHandler(0, unhandled_handler); /* this only works! */ global_crash_handler = AddVectoredExceptionHandler(0, unhandled_handler); /* this only works! */
#endif #endif
crash_context = move(context); crash_context = move(context);
@ -173,6 +174,7 @@ void signal::finalize() {
#else #else
if(global_crash_handler) if(global_crash_handler)
RemoveVectoredExceptionHandler(global_crash_handler); RemoveVectoredExceptionHandler(global_crash_handler);
global_crash_handler = nullptr; global_crash_handler = nullptr;
#endif #endif
crash_context.reset(); crash_context.reset();

View File

@ -85,6 +85,25 @@ void create_minidump(struct _EXCEPTION_POINTERS* apExceptionInfo)
} }
LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* apExceptionInfo) { LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* apExceptionInfo) {
auto code = apExceptionInfo->ExceptionRecord->ExceptionCode;
auto crash = false;
switch(code) {
case EXCEPTION_ACCESS_VIOLATION:
case EXCEPTION_ILLEGAL_INSTRUCTION:
case EXCEPTION_STACK_OVERFLOW:
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
case EXCEPTION_INT_DIVIDE_BY_ZERO:
case EXCEPTION_IN_PAGE_ERROR:
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
crash = true;
break;
default:
crash = false;
}
if(!crash)
return EXCEPTION_CONTINUE_SEARCH;
create_minidump(apExceptionInfo); create_minidump(apExceptionInfo);
exit(1); exit(1);
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;

View File

@ -155,7 +155,7 @@ void ProtocolHandler::progress_packet(const pipes::buffer_view &buffer) {
return; return;
} }
auto packet = std::make_shared<ServerPacket>(buffer); auto packet = std::shared_ptr<ts::protocol::ServerPacket>(ts::protocol::ServerPacket::from_buffer(buffer).release());
auto packet_type = packet->type(); auto packet_type = packet->type();
auto packet_id = packet->packetId(); auto packet_id = packet->packetId();
auto ordered = packet_type.type() == protocol::COMMAND || packet_type.type() == protocol::COMMAND_LOW; auto ordered = packet_type.type() == protocol::COMMAND || packet_type.type() == protocol::COMMAND_LOW;
@ -502,9 +502,10 @@ void ProtocolHandler::send_acknowledge(uint16_t packet_id, bool low) {
char buffer[2]; char buffer[2];
le2be16(packet_id, buffer); le2be16(packet_id, buffer);
auto packet = make_shared<protocol::ClientPacket>(low ? protocol::PacketTypeInfo::AckLow : protocol::PacketTypeInfo::Ack, 0, pipes::buffer_view{buffer, 2}); auto packet = make_shared<protocol::ClientPacket>(low ? protocol::PacketTypeInfo::AckLow : protocol::PacketTypeInfo::Ack, 0, pipes::buffer_view{buffer, 2});
if(this->connection_state >= connection_state::CONNECTING) if(this->connection_state >= connection_state::CONNECTING) {
;//packet->toggle(protocol::PacketFlag::NewProtocol, !low); ;//packet->toggle(protocol::PacketFlag::NewProtocol, !low);
//LivingBots DDOS protection dont want a new protocol here! //LivingBots DDOS protection dont want a new protocol here!
}
this->send_packet(packet); this->send_packet(packet);
} }

View File

@ -553,7 +553,7 @@ static shared_ptr<ts::protocol::ClientPacket> shuffle_cached_packet;
#endif #endif
void ServerConnection::send_voice_data(const void *buffer, size_t buffer_length, uint8_t codec, bool head) { void ServerConnection::send_voice_data(const void *buffer, size_t buffer_length, uint8_t codec, bool head) {
auto _buffer = pipes::buffer{ts::protocol::ClientPacket::META_SIZE + buffer_length + 3}; auto _buffer = pipes::buffer{ts::protocol::ClientPacket::META_SIZE + buffer_length + 3};
auto packet = make_shared<ts::protocol::ClientPacket>(_buffer); auto packet = ts::protocol::ClientPacket::from_buffer(_buffer);
memset(&_buffer[ts::protocol::ClientPacket::META_MAC_SIZE], 0, ts::protocol::ClientPacket::META_HEADER_SIZE); /* reset all header data */ memset(&_buffer[ts::protocol::ClientPacket::META_MAC_SIZE], 0, ts::protocol::ClientPacket::META_HEADER_SIZE); /* reset all header data */
packet->type(ts::protocol::PacketTypeInfo::Voice); packet->type(ts::protocol::PacketTypeInfo::Voice);
@ -581,7 +581,7 @@ void ServerConnection::send_voice_data(const void *buffer, size_t buffer_length,
shuffle_cached_packet = packet; shuffle_cached_packet = packet;
} }
#else #else
this->protocol_handler->send_packet(packet); this->protocol_handler->send_packet(std::shared_ptr<ts::protocol::ClientPacket>(packet.release()));
#endif #endif
} }