Some cleanup
This commit is contained in:
parent
bd7bdaeda2
commit
64a90a5573
@ -266,7 +266,7 @@ namespace demonware
|
|||||||
|
|
||||||
bool byte_buffer::write(const int bytes, const void* data)
|
bool byte_buffer::write(const int bytes, const void* data)
|
||||||
{
|
{
|
||||||
this->buffer_.append(reinterpret_cast<const char*>(data), bytes);
|
this->buffer_.append(static_cast<const char*>(data), bytes);
|
||||||
this->current_byte_ += bytes;
|
this->current_byte_ += bytes;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace demonware
|
|||||||
public:
|
public:
|
||||||
std::string file_data;
|
std::string file_data;
|
||||||
|
|
||||||
explicit bdFileData(const std::string& buffer) : file_data(buffer)
|
explicit bdFileData(std::string buffer) : file_data(std::move(buffer))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ namespace demonware
|
|||||||
|
|
||||||
void deserialize(byte_buffer* buffer) override
|
void deserialize(byte_buffer* buffer) override
|
||||||
{
|
{
|
||||||
int size;
|
int size{};
|
||||||
char* data;
|
char* data{};
|
||||||
buffer->read_blob(&data, &size);
|
buffer->read_blob(&data, &size);
|
||||||
|
|
||||||
if (data && size >= sizeof this->session_id)
|
if (data && uint32_t(size) >= sizeof(this->session_id))
|
||||||
{
|
{
|
||||||
this->session_id = *reinterpret_cast<uint64_t*>(data);
|
this->session_id = *reinterpret_cast<uint64_t*>(data);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ namespace demonware
|
|||||||
buffer.read_uint32(&seed);
|
buffer.read_uint32(&seed);
|
||||||
buffer.read_uint32(&title_id);
|
buffer.read_uint32(&title_id);
|
||||||
|
|
||||||
unsigned char rsakey[140];
|
unsigned char rsa_key[140];
|
||||||
buffer.read_bytes(sizeof(rsakey), rsakey);
|
buffer.read_bytes(sizeof(rsa_key), rsa_key);
|
||||||
|
|
||||||
uint8_t ticket[1024];
|
uint8_t ticket[1024];
|
||||||
buffer.read_bytes(std::min(ticket_size, static_cast<uint32_t>(sizeof(ticket))), ticket);
|
buffer.read_bytes(std::min(ticket_size, static_cast<uint32_t>(sizeof(ticket))), ticket);
|
||||||
@ -52,9 +52,9 @@ namespace demonware
|
|||||||
register_hash(&sha1_desc);
|
register_hash(&sha1_desc);
|
||||||
register_prng(&yarrow_desc);
|
register_prng(&yarrow_desc);
|
||||||
|
|
||||||
std::string encrypted_key = utils::cryptography::rsa::encrypt(std::string(SERVER_CD_KEY, 24),
|
auto encrypted_key = utils::cryptography::rsa::encrypt(std::string(SERVER_CD_KEY, 24),
|
||||||
std::string("DW-RSAENC", 10),
|
std::string("DW-RSAENC", 10),
|
||||||
std::string(PCHAR(rsakey), sizeof(rsakey)));
|
std::string(PCHAR(rsa_key), sizeof(rsa_key)));
|
||||||
|
|
||||||
bit_buffer response;
|
bit_buffer response;
|
||||||
response.set_use_data_types(false);
|
response.set_use_data_types(false);
|
||||||
|
@ -264,7 +264,7 @@ namespace demonware
|
|||||||
const auto path = get_user_file_path(filename);
|
const auto path = get_user_file_path(filename);
|
||||||
utils::io::write_file(path, data);
|
utils::io::write_file(path, data);
|
||||||
|
|
||||||
auto info = new bdFileInfo;
|
auto* info = new bdFileInfo;
|
||||||
|
|
||||||
info->file_id = *reinterpret_cast<const uint64_t*>(utils::cryptography::sha1::compute(filename).data());
|
info->file_id = *reinterpret_cast<const uint64_t*>(utils::cryptography::sha1::compute(filename).data());
|
||||||
info->filename = filename;
|
info->filename = filename;
|
||||||
@ -281,7 +281,7 @@ namespace demonware
|
|||||||
|
|
||||||
void bdStorage::get_user_file(i_server* server, byte_buffer* buffer) const
|
void bdStorage::get_user_file(i_server* server, byte_buffer* buffer) const
|
||||||
{
|
{
|
||||||
uint64_t owner;
|
uint64_t owner{};
|
||||||
std::string game, filename, platform, data;
|
std::string game, filename, platform, data;
|
||||||
|
|
||||||
buffer->read_string(&game);
|
buffer->read_string(&game);
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -3,12 +3,15 @@
|
|||||||
#include "loader/loader.hpp"
|
#include "loader/loader.hpp"
|
||||||
#include "loader/module_loader.hpp"
|
#include "loader/module_loader.hpp"
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
#include "loader/binary_loader.hpp"
|
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "utils/flags.hpp"
|
#include "utils/flags.hpp"
|
||||||
|
|
||||||
//#define GENERATE_DIFFS
|
//#define GENERATE_DIFFS
|
||||||
|
|
||||||
|
#ifdef GENERATE_DIFFS
|
||||||
|
#include "loader/binary_loader.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
DECLSPEC_NORETURN void WINAPI exit_hook(const int code)
|
DECLSPEC_NORETURN void WINAPI exit_hook(const int code)
|
||||||
{
|
{
|
||||||
module_loader::pre_destroy();
|
module_loader::pre_destroy();
|
||||||
@ -18,11 +21,8 @@ DECLSPEC_NORETURN void WINAPI exit_hook(const int code)
|
|||||||
void verify_tls()
|
void verify_tls()
|
||||||
{
|
{
|
||||||
const utils::nt::module self;
|
const utils::nt::module self;
|
||||||
const auto self_tls = reinterpret_cast<PIMAGE_TLS_DIRECTORY>(self.get_ptr() + self
|
const auto self_tls = reinterpret_cast<PIMAGE_TLS_DIRECTORY>(self.get_ptr()
|
||||||
.get_optional_header()
|
+ self.get_optional_header()->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress);
|
||||||
->
|
|
||||||
DataDirectory
|
|
||||||
[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress);
|
|
||||||
|
|
||||||
const auto ref = DWORD(&tls_data);
|
const auto ref = DWORD(&tls_data);
|
||||||
const auto tls_index = *reinterpret_cast<DWORD*>(self_tls->AddressOfIndex);
|
const auto tls_index = *reinterpret_cast<DWORD*>(self_tls->AddressOfIndex);
|
||||||
|
@ -36,7 +36,7 @@ private:
|
|||||||
|
|
||||||
static void launch_game(const bool singleplayer)
|
static void launch_game(const bool singleplayer)
|
||||||
{
|
{
|
||||||
utils::nt::module self;
|
const utils::nt::module self;
|
||||||
|
|
||||||
STARTUPINFOA s_info;
|
STARTUPINFOA s_info;
|
||||||
PROCESS_INFORMATION p_info;
|
PROCESS_INFORMATION p_info;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <std_include.hpp>
|
#include <std_include.hpp>
|
||||||
#include "scheduler.hpp"
|
#include "scheduler.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "game/structs.hpp"
|
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
#include "utils/hook.hpp"
|
#include "utils/hook.hpp"
|
||||||
|
|
||||||
@ -60,8 +59,8 @@ void scheduler::execute_safe()
|
|||||||
|
|
||||||
void scheduler::execute_error()
|
void scheduler::execute_error()
|
||||||
{
|
{
|
||||||
const char* message;
|
const char* message = nullptr;
|
||||||
int level;
|
int level = 0;
|
||||||
|
|
||||||
if (get_next_error(&message, &level) && message)
|
if (get_next_error(&message, &level) && message)
|
||||||
{
|
{
|
||||||
|
@ -120,13 +120,13 @@ private:
|
|||||||
static void start_execution_stub()
|
static void start_execution_stub()
|
||||||
{
|
{
|
||||||
module_loader::get<scripting>()->start_execution();
|
module_loader::get<scripting>()->start_execution();
|
||||||
reinterpret_cast<void(*)()>(start_hook_.get_original())();
|
static_cast<void(*)()>(start_hook_.get_original())();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stop_execution_stub()
|
static void stop_execution_stub()
|
||||||
{
|
{
|
||||||
module_loader::get<scripting>()->stop_execution();
|
module_loader::get<scripting>()->stop_execution();
|
||||||
reinterpret_cast<void(*)()>(stop_hook_.get_original())();
|
static_cast<void(*)()>(stop_hook_.get_original())();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vm_notify_stub(const unsigned int notify_id, const unsigned short type,
|
static void vm_notify_stub(const unsigned int notify_id, const unsigned short type,
|
||||||
@ -142,7 +142,7 @@ private:
|
|||||||
|
|
||||||
//printf("%X: %s\n", e.entity_id, e.name.data());
|
//printf("%X: %s\n", e.entity_id, e.name.data());
|
||||||
|
|
||||||
for (auto value = stack; value->type != game::native::SCRIPT_END; --value)
|
for (auto* value = stack; value->type != game::native::SCRIPT_END; --value)
|
||||||
{
|
{
|
||||||
e.arguments.emplace_back(*value);
|
e.arguments.emplace_back(*value);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,9 @@ namespace steam
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <size_t X, size_t ... Xs>
|
template <size_t X, size_t ... Xs>
|
||||||
struct argument_size_calculator<X, Xs...> final : std::integral_constant<
|
struct argument_size_calculator<X, Xs...> final
|
||||||
size_t, X + ((argument_size_calculator<Xs...>::value + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1))>
|
: std::integral_constant<size_t, X + ((argument_size_calculator<Xs...>::value
|
||||||
|
+ (sizeof(void*) - 1)) & ~(sizeof(void*) - 1))>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class apps final
|
class apps
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~apps() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool BIsSubscribed();
|
virtual bool BIsSubscribed();
|
||||||
virtual bool BIsLowViolence();
|
virtual bool BIsLowViolence();
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class friends final
|
class friends
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~friends() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual const char* GetPersonaName();
|
virtual const char* GetPersonaName();
|
||||||
virtual void SetPersonaName(const char* pchPersonaName);
|
virtual void SetPersonaName(const char* pchPersonaName);
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class game_server final
|
class game_server
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~game_server() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void LogOn();
|
virtual void LogOn();
|
||||||
virtual void LogOff();
|
virtual void LogOff();
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class master_server_updater final
|
class master_server_updater
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~master_server_updater() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void SetActive(bool bActive);
|
virtual void SetActive(bool bActive);
|
||||||
virtual void SetHeartbeatInterval(int iHeartbeatInterval);
|
virtual void SetHeartbeatInterval(int iHeartbeatInterval);
|
||||||
|
@ -21,8 +21,11 @@ namespace steam
|
|||||||
int m_e_chat_room_enter_response;
|
int m_e_chat_room_enter_response;
|
||||||
};
|
};
|
||||||
|
|
||||||
class matchmaking final
|
class matchmaking
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~matchmaking() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual int GetFavoriteGameCount();
|
virtual int GetFavoriteGameCount();
|
||||||
virtual bool GetFavoriteGame(int iGame, unsigned int* pnAppID, unsigned int* pnIP, unsigned short* pnConnPort,
|
virtual bool GetFavoriteGame(int iGame, unsigned int* pnAppID, unsigned int* pnIP, unsigned short* pnConnPort,
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class matchmaking_servers final
|
class matchmaking_servers
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~matchmaking_servers() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void* RequestInternetServerList(unsigned int iApp, void** ppchFilters, unsigned int nFilters,
|
virtual void* RequestInternetServerList(unsigned int iApp, void** ppchFilters, unsigned int nFilters,
|
||||||
void* pRequestServersResponse);
|
void* pRequestServersResponse);
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class networking final
|
class networking
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~networking() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool SendP2PPacket(steam_id steamIDRemote, const void* pubData, unsigned int cubData, int eP2PSendType);
|
virtual bool SendP2PPacket(steam_id steamIDRemote, const void* pubData, unsigned int cubData, int eP2PSendType);
|
||||||
virtual bool IsP2PPacketAvailable(unsigned int* pcubMsgSize, int idk);
|
virtual bool IsP2PPacketAvailable(unsigned int* pcubMsgSize, int idk);
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class remote_storage final
|
class remote_storage
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~remote_storage() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool FileWrite(const char* pchFile, const void* pvData, int cubData);
|
virtual bool FileWrite(const char* pchFile, const void* pvData, int cubData);
|
||||||
virtual int GetFileSize(const char* pchFile);
|
virtual int GetFileSize(const char* pchFile);
|
||||||
|
@ -9,8 +9,11 @@ namespace steam
|
|||||||
int m_e_result;
|
int m_e_result;
|
||||||
};
|
};
|
||||||
|
|
||||||
class user final
|
class user
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~user() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual int GetHSteamUser();
|
virtual int GetHSteamUser();
|
||||||
virtual bool LoggedOn();
|
virtual bool LoggedOn();
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class user_stats final
|
class user_stats
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~user_stats() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool RequestCurrentStats();
|
virtual bool RequestCurrentStats();
|
||||||
virtual bool GetStat(const char* pchName, int* pData);
|
virtual bool GetStat(const char* pchName, int* pData);
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace steam
|
namespace steam
|
||||||
{
|
{
|
||||||
class utils final
|
class utils
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
~utils() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual unsigned int GetSecondsSinceAppActive();
|
virtual unsigned int GetSecondsSinceAppActive();
|
||||||
virtual unsigned int GetSecondsSinceComputerActive();
|
virtual unsigned int GetSecondsSinceComputerActive();
|
||||||
|
@ -64,6 +64,8 @@ namespace steam
|
|||||||
void set_i_callback(const int i_callback) { callback_ = i_callback; }
|
void set_i_callback(const int i_callback) { callback_ = i_callback; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
~base() = default;
|
||||||
|
|
||||||
unsigned char flags_;
|
unsigned char flags_;
|
||||||
int callback_;
|
int callback_;
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ namespace utils
|
|||||||
{
|
{
|
||||||
if (this->signatures_.empty()) return;
|
if (this->signatures_.empty()) return;
|
||||||
|
|
||||||
const auto start = reinterpret_cast<char*>(this->start_);
|
const auto start = static_cast<char*>(this->start_);
|
||||||
|
|
||||||
const unsigned int sig_count = this->signatures_.size();
|
const unsigned int sig_count = this->signatures_.size();
|
||||||
const auto containers = this->signatures_.data();
|
const auto containers = this->signatures_.data();
|
||||||
|
@ -91,7 +91,7 @@ namespace utils
|
|||||||
|
|
||||||
bool memory::is_set(const void* mem, const char chr, const size_t length)
|
bool memory::is_set(const void* mem, const char chr, const size_t length)
|
||||||
{
|
{
|
||||||
const auto mem_arr = reinterpret_cast<const char*>(mem);
|
const auto mem_arr = static_cast<const char*>(mem);
|
||||||
|
|
||||||
for (size_t i = 0; i < length; ++i)
|
for (size_t i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
|
@ -16,16 +16,16 @@ namespace utils
|
|||||||
|
|
||||||
void free(const void* data);
|
void free(const void* data);
|
||||||
|
|
||||||
void* allocate(const size_t length);
|
void* allocate(size_t length);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T* allocate()
|
T* allocate()
|
||||||
{
|
{
|
||||||
return this->allocate_array<T>(1);
|
return this->allocate_array<T>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T* allocate_array(const size_t count = 1)
|
T* allocate_array(const size_t count = 1)
|
||||||
{
|
{
|
||||||
return static_cast<T*>(this->allocate(count * sizeof(T)));
|
return static_cast<T*>(this->allocate(count * sizeof(T)));
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace utils::nt
|
|||||||
module module::get_by_address(void* address)
|
module module::get_by_address(void* address)
|
||||||
{
|
{
|
||||||
HMODULE handle = nullptr;
|
HMODULE handle = nullptr;
|
||||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<LPCSTR>(address), &handle);
|
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast<LPCSTR>(address), &handle);
|
||||||
return module(handle);
|
return module(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace utils::nt
|
|||||||
std::function<T> get(const std::string& process) const
|
std::function<T> get(const std::string& process) const
|
||||||
{
|
{
|
||||||
if (!this->is_valid()) std::function<T>();
|
if (!this->is_valid()) std::function<T>();
|
||||||
return reinterpret_cast<T*>(this->get_proc<void*>(process));
|
return static_cast<T*>(this->get_proc<void*>(process));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
|
Loading…
Reference in New Issue
Block a user