Merge branch 'develop' into feature/assetinterface-weapon
# Conflicts: # src/Components/Modules/Exception.cpp
This commit is contained in:
commit
5db668cb15
@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0.3.0/) and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [unreleased] - xxxx-xx-xx
|
||||
|
||||
### Added
|
||||
|
||||
- Add host information to /info endpoint (request)
|
||||
|
||||
## [0.6.0] - 2018-12-30
|
||||
|
||||
### Added
|
||||
|
@ -72,9 +72,7 @@ namespace Components
|
||||
Loader::Register(new Renderer());
|
||||
Loader::Register(new UIFeeder());
|
||||
Loader::Register(new UIScript());
|
||||
#ifndef DISABLE_ANTICHEAT
|
||||
Loader::Register(new AntiCheat());
|
||||
#endif
|
||||
Loader::Register(new Changelog());
|
||||
Loader::Register(new Dedicated());
|
||||
Loader::Register(new Discovery());
|
||||
|
@ -824,6 +824,64 @@ namespace Components
|
||||
__VMProtectEnd;
|
||||
}
|
||||
|
||||
void AntiCheat::SystemTimeDiff(LPSYSTEMTIME stA, LPSYSTEMTIME stB, LPSYSTEMTIME stC) {
|
||||
FILETIME ftA, ftB, ftC;
|
||||
ULARGE_INTEGER uiA, uiB, uiC;
|
||||
|
||||
SystemTimeToFileTime(stA, &ftA);
|
||||
SystemTimeToFileTime(stB, &ftB);
|
||||
uiA.HighPart = ftA.dwHighDateTime;
|
||||
uiA.LowPart = ftA.dwLowDateTime;
|
||||
uiB.HighPart = ftB.dwHighDateTime;
|
||||
uiB.LowPart = ftB.dwLowDateTime;
|
||||
|
||||
uiC.QuadPart = uiA.QuadPart - uiB.QuadPart;
|
||||
|
||||
ftC.dwHighDateTime = uiC.HighPart;
|
||||
ftC.dwLowDateTime = uiC.LowPart;
|
||||
FileTimeToSystemTime(&ftC, stC);
|
||||
}
|
||||
|
||||
void AntiCheat::CheckStartupTime()
|
||||
{
|
||||
__VMProtectBeginUltra("");
|
||||
FILETIME creation, exit, kernel, user;
|
||||
SYSTEMTIME current, creationSt, diffSt;
|
||||
|
||||
GetSystemTime(¤t);
|
||||
GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user);
|
||||
|
||||
FileTimeToSystemTime(&creation, &creationSt);
|
||||
AntiCheat::SystemTimeDiff(¤t, &creationSt, &diffSt);
|
||||
|
||||
#ifdef DEBUG
|
||||
char buf[512];
|
||||
snprintf(buf, 512, "creation: %d:%d:%d:%d\n", creationSt.wHour, creationSt.wMinute, creationSt.wSecond, creationSt.wMilliseconds);
|
||||
OutputDebugStringA(buf);
|
||||
|
||||
snprintf(buf, 512, "current: %d:%d:%d:%d\n", current.wHour, current.wMinute, current.wSecond, current.wMilliseconds);
|
||||
OutputDebugStringA(buf);
|
||||
|
||||
snprintf(buf, 512, "diff: %d:%d:%d:%d\n", diffSt.wHour, diffSt.wMinute, diffSt.wSecond, diffSt.wMilliseconds);
|
||||
OutputDebugStringA(buf);
|
||||
#endif
|
||||
|
||||
// crash client if they are using process suspension to inject dlls during startup (aka before we got to here)
|
||||
// maybe tweak this value depending on what the above logging reveals during testing,
|
||||
// but 5 seconds seems about right for now
|
||||
int time = diffSt.wMilliseconds + (diffSt.wSecond * 1000) + (diffSt.wMinute * 1000 * 60);
|
||||
if (time > 5000) {
|
||||
Components::AntiCheat::CrashClient();
|
||||
}
|
||||
|
||||
// use below for logging when using StartSuspended.exe
|
||||
// FILE* f = fopen("times.txt", "a");
|
||||
// fwrite(buf, 1, strlen(buf), f);
|
||||
// fclose(f);
|
||||
|
||||
__VMProtectEnd;
|
||||
}
|
||||
|
||||
AntiCheat::AntiCheat()
|
||||
{
|
||||
__VMProtectBeginUltra("");
|
||||
@ -831,13 +889,12 @@ namespace Components
|
||||
time(nullptr);
|
||||
AntiCheat::Flags = NO_FLAG;
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DISABLE_ANTICHEAT
|
||||
Command::Add("penis", [](Command::Params*)
|
||||
{
|
||||
AntiCheat::CrashClient();
|
||||
});
|
||||
#else
|
||||
|
||||
Utils::Hook(0x507BD5, AntiCheat::PatchWinAPI, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x5082FD, AntiCheat::LostD3DStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x51C76C, AntiCheat::CinematicStub, HOOK_CALL).install()->quick();
|
||||
@ -866,6 +923,7 @@ namespace Components
|
||||
|
||||
// Set the integrity flag
|
||||
AntiCheat::Flags |= AntiCheat::IntergrityFlag::INITIALIZATION;
|
||||
|
||||
#endif
|
||||
|
||||
__VMProtectEnd;
|
||||
|
@ -54,6 +54,9 @@ namespace Components
|
||||
static void UninstallLibHook();
|
||||
static void InstallLibHook();
|
||||
|
||||
static void CheckStartupTime();
|
||||
static void SystemTimeDiff(LPSYSTEMTIME stA, LPSYSTEMTIME stB, LPSYSTEMTIME stC);
|
||||
|
||||
private:
|
||||
enum IntergrityFlag
|
||||
{
|
||||
@ -114,3 +117,4 @@ namespace Components
|
||||
static Utils::Hook VirtualProtectHook[2];
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ namespace Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (Steam::Enabled() && !Dvar::Var("cl_anonymous").get<bool>() && Steam::Proxy::SteamUser_)
|
||||
if (Steam::Enabled() && !Friends::IsInvisible() && !Dvar::Var("cl_anonymous").get<bool>() && Steam::Proxy::SteamUser_)
|
||||
{
|
||||
infostr.set("realsteamId", Utils::String::VA("%llX", Steam::Proxy::SteamUser_->GetSteamID().bits));
|
||||
}
|
||||
|
@ -220,6 +220,12 @@ namespace Components
|
||||
// Table lookup stuff
|
||||
Utils::Hook(0x62DCC1, CardTitles::TableLookupByRowHookStub).install()->quick();
|
||||
Utils::Hook::Nop(0x62DCC6, 1);
|
||||
|
||||
// This is placed here in case the anticheat has been disabled!
|
||||
// This checks specifically for launching the process suspended to inject a dll
|
||||
#if !defined(DISABLE_ANTICHEAT)
|
||||
AntiCheat::CheckStartupTime();
|
||||
#endif
|
||||
}
|
||||
|
||||
CardTitles::~CardTitles()
|
||||
|
@ -701,9 +701,11 @@ namespace Components
|
||||
//if (!Download::VerifyPassword(nc, reinterpret_cast<http_message*>(ev_data))) return;
|
||||
|
||||
Utils::InfoString status = ServerInfo::GetInfo();
|
||||
Utils::InfoString host = ServerInfo::GetHostInfo();
|
||||
|
||||
std::map<std::string, json11::Json> info;
|
||||
info["status"] = status.to_json();
|
||||
info["host"] = host.to_json();
|
||||
|
||||
std::vector<json11::Json> players;
|
||||
|
||||
|
@ -176,54 +176,6 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
// this isn't in a lambda because the compiler complains when we use inline assembly inside of a lambda
|
||||
void Exception::DebugMinidumpCommand(Command::Params*)
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4740) // flow in or out of inline asm code suppresses global optimization
|
||||
// The following code was taken from VC++ 8.0 CRT (invarg.c: line 104)
|
||||
|
||||
CONTEXT ContextRecord;
|
||||
EXCEPTION_RECORD ExceptionRecord;
|
||||
ZeroMemory(&ContextRecord, sizeof(CONTEXT));
|
||||
|
||||
__asm
|
||||
{
|
||||
mov[ContextRecord.Eax], eax
|
||||
mov[ContextRecord.Ecx], ecx
|
||||
mov[ContextRecord.Edx], edx
|
||||
mov[ContextRecord.Ebx], ebx
|
||||
mov[ContextRecord.Esi], esi
|
||||
mov[ContextRecord.Edi], edi
|
||||
mov word ptr[ContextRecord.SegSs], ss
|
||||
mov word ptr[ContextRecord.SegCs], cs
|
||||
mov word ptr[ContextRecord.SegDs], ds
|
||||
mov word ptr[ContextRecord.SegEs], es
|
||||
mov word ptr[ContextRecord.SegFs], fs
|
||||
mov word ptr[ContextRecord.SegGs], gs
|
||||
|
||||
pushfd
|
||||
pop[ContextRecord.EFlags]
|
||||
}
|
||||
|
||||
ContextRecord.ContextFlags = CONTEXT_CONTROL;
|
||||
ContextRecord.Eip = reinterpret_cast<DWORD>(_ReturnAddress());
|
||||
ContextRecord.Esp = reinterpret_cast<DWORD>(_AddressOfReturnAddress());
|
||||
ContextRecord.Ebp = *reinterpret_cast<DWORD*>(_AddressOfReturnAddress()) - 1;
|
||||
|
||||
ZeroMemory(&ExceptionRecord, sizeof(EXCEPTION_RECORD));
|
||||
|
||||
ExceptionRecord.ExceptionCode = EXCEPTION_BREAKPOINT;
|
||||
ExceptionRecord.ExceptionAddress = _ReturnAddress();
|
||||
|
||||
EXCEPTION_POINTERS eptr;
|
||||
eptr.ExceptionRecord = &ExceptionRecord;
|
||||
eptr.ContextRecord = &ContextRecord;
|
||||
|
||||
Exception::ExceptionFilter(&eptr);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
||||
Exception::Exception()
|
||||
{
|
||||
Exception::SetMiniDumpType(Flags::HasFlag("bigminidumps"), Flags::HasFlag("reallybigminidumps"));
|
||||
@ -280,9 +232,6 @@ namespace Components
|
||||
Logger::Print("Old exception handler was 0x%010X.\n", oldHandler);
|
||||
});
|
||||
|
||||
|
||||
Command::Add("debug_minidump", Exception::DebugMinidumpCommand);
|
||||
|
||||
// Check if folder exists && crash-helper exists
|
||||
|
||||
if (Utils::IO::DirectoryExists("minidumps\\") && Utils::IO::FileExists("crash-helper.exe"))
|
||||
|
@ -124,7 +124,7 @@ namespace Components
|
||||
|
||||
void Friends::UpdateState(bool force)
|
||||
{
|
||||
if (Dvar::Var("cl_anonymous").get<bool>() || !Steam::Enabled()) return;
|
||||
if (Dvar::Var("cl_anonymous").get<bool>() || Friends::IsInvisible() || !Steam::Enabled()) return;
|
||||
|
||||
if (force)
|
||||
{
|
||||
@ -228,7 +228,7 @@ namespace Components
|
||||
|
||||
void Friends::SetPresence(const std::string& key, const std::string& value)
|
||||
{
|
||||
if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamUtils && !Dvar::Var("cl_anonymous").get<bool>() && Steam::Enabled())
|
||||
if (Steam::Proxy::ClientFriends && Steam::Proxy::SteamUtils && !Dvar::Var("cl_anonymous").get<bool>() && !Friends::IsInvisible() && Steam::Enabled())
|
||||
{
|
||||
Friends::SetRawPresence(key.data(), value.data());
|
||||
}
|
||||
@ -494,6 +494,11 @@ namespace Components
|
||||
return appId;
|
||||
}
|
||||
|
||||
bool Friends::IsInvisible()
|
||||
{
|
||||
return Friends::InitialState == 7;
|
||||
}
|
||||
|
||||
void Friends::UpdateTimeStamp()
|
||||
{
|
||||
Friends::SetPresence("iw4x_playing", Utils::String::VA("%d", Steam::SteamUtils()->GetServerRealTime()));
|
||||
@ -696,10 +701,10 @@ namespace Components
|
||||
{
|
||||
if (Steam::Proxy::SteamFriends)
|
||||
{
|
||||
Friends::InitialState = Steam::Proxy::SteamFriends->GetPersonaState();
|
||||
Friends::InitialState = Steam::Proxy::SteamFriends->GetFriendPersonaState(Steam::Proxy::SteamUser_->GetSteamID());
|
||||
}
|
||||
|
||||
if (Dvar::Var("cl_anonymous").get<bool>() || !Steam::Enabled())
|
||||
if (Dvar::Var("cl_anonymous").get<bool>() || Friends::IsInvisible() || !Steam::Enabled())
|
||||
{
|
||||
if (Steam::Proxy::ClientFriends)
|
||||
{
|
||||
|
@ -23,6 +23,8 @@ namespace Components
|
||||
|
||||
static int GetGame(SteamID user);
|
||||
|
||||
static bool IsInvisible();
|
||||
|
||||
private:
|
||||
#pragma pack(push, 4)
|
||||
struct FriendRichPresenceUpdate
|
||||
|
@ -212,6 +212,11 @@ namespace Components
|
||||
Utils::OpenUrl(Utils::Cache::GetStaticUrl("/wiki/"));
|
||||
});
|
||||
|
||||
UIScript::Add("visitDiscord", [](UIScript::Token)
|
||||
{
|
||||
Utils::OpenUrl("https://discord.gg/sKeVmR3");
|
||||
});
|
||||
|
||||
Localization::Set("MPUI_CHANGELOG_TEXT", "Loading...");
|
||||
Localization::Set("MPUI_MOTD_TEXT", NEWS_MOTD_DEFAULT);
|
||||
|
||||
|
@ -110,6 +110,19 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
Utils::InfoString ServerInfo::GetHostInfo()
|
||||
{
|
||||
Utils::InfoString info;
|
||||
|
||||
// TODO: Possibly add all Dvar starting with _
|
||||
info.set("admin", Dvar::Var("_Admin").get<const char*>());
|
||||
info.set("website", Dvar::Var("_Website").get<const char*>());
|
||||
info.set("email", Dvar::Var("_Email").get<const char*>());
|
||||
info.set("location", Dvar::Var("_Location").get<const char*>());
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
Utils::InfoString ServerInfo::GetInfo()
|
||||
{
|
||||
int maxclientCount = *Game::svs_numclients;
|
||||
|
@ -8,6 +8,7 @@ namespace Components
|
||||
ServerInfo();
|
||||
~ServerInfo();
|
||||
|
||||
static Utils::InfoString GetHostInfo();
|
||||
static Utils::InfoString GetInfo();
|
||||
|
||||
private:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define PROTOCOL 0x95
|
||||
#define PROTOCOL 0x96
|
||||
#define NUM_CUSTOM_CLASSES 15
|
||||
#define SEMANTIC_WATER_MAP 11
|
||||
#define FX_ELEM_FIELD_COUNT 90
|
||||
|
@ -86,7 +86,11 @@ namespace Steam
|
||||
if (ud_insn_mnemonic(&ud) == UD_Iret)
|
||||
{
|
||||
const ud_operand* operand = ud_insn_opr(&ud, 0);
|
||||
if (!operand) break;
|
||||
if (!operand)
|
||||
{
|
||||
*params = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (operand->type == UD_OP_IMM && operand->size == 16)
|
||||
{
|
||||
@ -110,6 +114,8 @@ namespace Steam
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*reinterpret_cast<unsigned char*>(ud.pc) == 0xCC) break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user