mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-02-16 10:40:46 +00:00
more cleanup
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 7/16/2020
|
||||
///
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "Xor.h"
|
||||
struct RSA{
|
||||
int n = 0;
|
||||
int e = 0;
|
||||
int d = 0;
|
||||
};
|
||||
std::string RSA_D(const std::string& Data,int d, int n);
|
||||
std::string RSA_E(const std::string& Data,int e, int n);
|
||||
std::string LocalEnc(const std::string& Data);
|
||||
std::string LocalDec(const std::string& Data);
|
||||
RSA* GenKey();
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright (c) 2020 Anonymous275.
|
||||
// BeamMP Launcher code is not in the public domain and is not free software.
|
||||
// One must be granted explicit permission by the copyright holder in order to modify or distribute any part of the source or binaries.
|
||||
// Anything else is prohibited. Modified works may not be published and have be upstreamed to the official repository.
|
||||
///
|
||||
/// Created by Anonymous275 on 7/19/2020
|
||||
///
|
||||
#pragma once
|
||||
extern unsigned long GamePID;
|
||||
void SecureMods();
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
// Copyright (c) 2020 Anonymous275.
|
||||
// BeamMP Launcher code is not in the public domain and is not free software.
|
||||
// One must be granted explicit permission by the copyright holder in order to modify or distribute any part of the source or binaries.
|
||||
// Anything else is prohibited. Modified works may not be published and have be upstreamed to the official repository.
|
||||
///
|
||||
/// Created by Anonymous275 on 7/18/2020
|
||||
///
|
||||
#pragma once
|
||||
#include <string>
|
||||
void PreGame(int argc, char* argv[],const std::string& GamePath);
|
||||
void InitGame(const std::string& Dir,const std::string&Current);
|
||||
std::string CheckVer(const std::string &path);
|
||||
void InitGame(const std::string& Dir);
|
||||
std::string GetGameDir();
|
||||
void LegitimacyCheck();
|
||||
void CheckLocalKey();
|
||||
@@ -1,130 +0,0 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 8/11/2020
|
||||
///
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <cstdarg>
|
||||
|
||||
#define BEGIN_NAMESPACE(x) namespace x {
|
||||
#define END_NAMESPACE }
|
||||
|
||||
BEGIN_NAMESPACE(XorCompileTime)
|
||||
|
||||
constexpr auto time = __TIME__;
|
||||
constexpr auto seed = static_cast<int>(time[7]) + static_cast<int>(time[6]) * 10 + static_cast<int>(time[4]) * 60 + static_cast<int>(time[3]) * 600 + static_cast< int >(time[1]) * 3600 + static_cast< int >(time[0]) * 36000;
|
||||
|
||||
// 1988, Stephen Park and Keith Miller
|
||||
// "Random Number Generators: Good Ones Are Hard To Find", considered as "minimal standard"
|
||||
// Park-Miller 31 bit pseudo-random number generator, implemented with G. Carta's optimisation:
|
||||
// with 32-bit math and without division
|
||||
|
||||
template <int N>
|
||||
struct RandomGenerator{
|
||||
private:
|
||||
static constexpr unsigned a = 16807; // 7^5
|
||||
static constexpr unsigned m = 2147483647; // 2^31 - 1
|
||||
|
||||
static constexpr unsigned s = RandomGenerator< N - 1 >::value;
|
||||
static constexpr unsigned lo = a * (s & 0xFFFFu); // Multiply lower 16 bits by 16807
|
||||
static constexpr unsigned hi = a * (s >> 16u); // Multiply higher 16 bits by 16807
|
||||
static constexpr unsigned lo2 = lo + ((hi & 0x7FFFu) << 16u); // Combine lower 15 bits of hi with lo's upper bits
|
||||
static constexpr unsigned hi2 = hi >> 15u; // Discard lower 15 bits of hi
|
||||
static constexpr unsigned lo3 = lo2 + hi;
|
||||
|
||||
public:
|
||||
static constexpr unsigned max = m;
|
||||
static constexpr unsigned value = lo3 > m ? lo3 - m : lo3;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RandomGenerator< 0 >{
|
||||
static constexpr unsigned value = seed;
|
||||
};
|
||||
|
||||
template <int N, int M>
|
||||
struct RandomInt{
|
||||
static constexpr auto value = RandomGenerator< N + 1 >::value % M;
|
||||
};
|
||||
|
||||
template <int N>
|
||||
struct RandomChar{
|
||||
static const char value = static_cast< char >(1 + RandomInt< N, 0x7F - 1 >::value);
|
||||
};
|
||||
|
||||
template <size_t N, int K, typename Char>
|
||||
struct XorString{
|
||||
private:
|
||||
const char _key;
|
||||
std::array< Char, N + 1 > _encrypted;
|
||||
|
||||
constexpr Char enc(Char c) const{
|
||||
return c ^ _key;
|
||||
}
|
||||
|
||||
Char dec(Char c) const{
|
||||
return c ^ _key;
|
||||
}
|
||||
|
||||
public:
|
||||
template <size_t... Is>
|
||||
constexpr __forceinline XorString(const Char* str, std::index_sequence< Is... >) : _key(RandomChar< K >::value), _encrypted{ enc(str[Is])... }
|
||||
{}
|
||||
|
||||
__forceinline decltype(auto) decrypt(){
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
_encrypted[i] = dec(_encrypted[i]);
|
||||
}
|
||||
_encrypted[N] = '\0';
|
||||
return _encrypted.data();
|
||||
}
|
||||
};
|
||||
|
||||
static auto w_printf = [](const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf_s(fmt, args);
|
||||
va_end(args);
|
||||
};
|
||||
|
||||
static auto w_printf_s = [](const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf_s(fmt, args);
|
||||
va_end(args);
|
||||
};
|
||||
|
||||
/*static auto w_sprintf = [](char* buf, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(buf, fmt, args);
|
||||
va_end(args);
|
||||
};*/
|
||||
|
||||
/*static auto w_sprintf_ret = [](char* buf, const char* fmt, ...) {
|
||||
int ret;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ret = vsprintf(buf, fmt, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
};*/
|
||||
|
||||
static auto w_sprintf_s = [](char* buf, size_t buf_size, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf_s(buf, buf_size, fmt, args);
|
||||
va_end(args);
|
||||
};
|
||||
|
||||
static auto w_sprintf_s_ret = [](char* buf, size_t buf_size, const char* fmt, ...) {
|
||||
int ret;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ret = vsprintf_s(buf, buf_size, fmt, args);
|
||||
va_end(args);
|
||||
return ret;
|
||||
};
|
||||
#define Sec( s ) []{ constexpr XorCompileTime::XorString< sizeof(s)/sizeof(char) - 1, __COUNTER__, char > expr( s, std::make_index_sequence< sizeof(s)/sizeof(char) - 1>() ); return expr; }().decrypt()
|
||||
#define SecW( s ) []{ constexpr XorCompileTime::XorString< sizeof(s)/sizeof(wchar_t) - 1, __COUNTER__, wchar_t > expr( s, std::make_index_sequence< sizeof(s)/sizeof(wchar_t) - 1>() ); return expr; }().decrypt()
|
||||
END_NAMESPACE
|
||||
Reference in New Issue
Block a user