Fix warnings and issues

This commit is contained in:
momo5502 2018-12-25 00:32:21 +01:00
parent 81df7c9ca2
commit 1c6ae05dcb
29 changed files with 110 additions and 98 deletions

View File

@ -12,19 +12,19 @@ window::window(const std::string& title, const int width, const int height)
this->wc_.cbSize = sizeof(this->wc_);
this->wc_.style = CS_HREDRAW | CS_VREDRAW;
this->wc_.lpfnWndProc = window::static_processor;
this->wc_.lpfnWndProc = static_processor;
this->wc_.hInstance = handle;
this->wc_.hCursor = LoadCursor(nullptr, IDC_ARROW);
this->wc_.hIcon = LoadIcon(handle, MAKEINTRESOURCE(102));
this->wc_.hIconSm = this->wc_.hIcon;
this->wc_.hbrBackground = CreateSolidBrush(RGB(35, 35, 35));
this->wc_.lpszClassName = L"omw3_window";
this->wc_.lpszClassName = L"lul_window";
RegisterClassEx(&this->wc_);
const auto x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2;
const auto y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2;
this->handle_ = CreateWindowExA(NULL, "omw3_window", title.data(),
this->handle_ = CreateWindowExA(NULL, "lul_window", title.data(),
(WS_OVERLAPPEDWINDOW | WS_VISIBLE) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), x, y, width,
height, nullptr, nullptr, handle, nullptr);

View File

@ -5,22 +5,22 @@ std::vector<std::unique_ptr<module>>* module_loader::modules_ = nullptr;
void module_loader::register_module(std::unique_ptr<module>&& module_)
{
if (!module_loader::modules_)
if (!modules_)
{
module_loader::modules_ = new std::vector<std::unique_ptr<module>>();
atexit(module_loader::destroy_modules);
modules_ = new std::vector<std::unique_ptr<module>>();
atexit(destroy_modules);
}
module_loader::modules_->push_back(std::move(module_));
modules_->push_back(std::move(module_));
}
void module_loader::post_load()
{
static auto handled = false;
if (handled || !module_loader::modules_) return;
if (handled || !modules_) return;
handled = true;
for (const auto& module_ : *module_loader::modules_)
for (const auto& module_ : *modules_)
{
module_->post_load();
}
@ -29,10 +29,10 @@ void module_loader::post_load()
void module_loader::pre_destroy()
{
static auto handled = false;
if (handled || !module_loader::modules_) return;
if (handled || !modules_) return;
handled = true;
for (const auto& module_ : *module_loader::modules_)
for (const auto& module_ : *modules_)
{
module_->pre_destroy();
}
@ -40,10 +40,10 @@ void module_loader::pre_destroy()
void module_loader::destroy_modules()
{
module_loader::pre_destroy();
pre_destroy();
if (!module_loader::modules_) return;
if (!modules_) return;
delete module_loader::modules_;
module_loader::modules_ = nullptr;
delete modules_;
modules_ = nullptr;
}

View File

@ -28,5 +28,3 @@ using namespace std::literals;
#pragma warning(disable: 4100)
#include "resource.hpp"
#include "steam/steam.hpp"

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{
@ -54,14 +55,9 @@ namespace steam
void utils::SetOverlayNotificationPosition(int eNotificationPosition)
{
if (steam::overlay)
if (overlay)
{
const auto set_position = GetProcAddress(steam::overlay, "SetNotificationPosition");
if (set_position)
{
reinterpret_cast<void(*)(int)>(set_position)(eNotificationPosition);
}
overlay.invoke<void>("SetNotificationPosition", eNotificationPosition);
}
}

View File

@ -1,8 +1,9 @@
#include <std_include.hpp>
#include "steam/steam.hpp"
namespace steam
{
HMODULE overlay = nullptr;
::utils::nt::module overlay(nullptr);
uint64_t callbacks::call_id_ = 0;
std::recursive_mutex callbacks::mutex_;
@ -13,52 +14,52 @@ namespace steam
uint64_t callbacks::register_call()
{
std::lock_guard _(callbacks::mutex_);
callbacks::calls_[++callbacks::call_id_] = false;
return callbacks::call_id_;
std::lock_guard _(mutex_);
calls_[++call_id_] = false;
return call_id_;
}
void callbacks::register_callback(callbacks::base* handler, const int callback)
void callbacks::register_callback(base* handler, const int callback)
{
std::lock_guard _(callbacks::mutex_);
std::lock_guard _(mutex_);
handler->set_i_callback(callback);
callbacks::callback_list_.push_back(handler);
callback_list_.push_back(handler);
}
void callbacks::register_call_result(const uint64_t call, callbacks::base* result)
void callbacks::register_call_result(const uint64_t call, base* result)
{
std::lock_guard _(callbacks::mutex_);
callbacks::result_handlers_[call] = result;
std::lock_guard _(mutex_);
result_handlers_[call] = result;
}
void callbacks::return_call(void* data, const int size, const int type, const uint64_t call)
{
std::lock_guard _(callbacks::mutex_);
std::lock_guard _(mutex_);
callbacks::result result;
result result{};
result.call = call;
result.data = data;
result.size = size;
result.type = type;
callbacks::calls_[call] = true;
calls_[call] = true;
callbacks::results_.push_back(result);
results_.push_back(result);
}
void callbacks::run_callbacks()
{
std::lock_guard _(callbacks::mutex_);
std::lock_guard _(mutex_);
for (auto result : callbacks::results_)
for (auto result : results_)
{
if (callbacks::result_handlers_.find(result.call) != callbacks::result_handlers_.end())
if (result_handlers_.find(result.call) != result_handlers_.end())
{
callbacks::result_handlers_[result.call]->run(result.data, false, result.call);
result_handlers_[result.call]->run(result.data, false, result.call);
}
for (auto callback : callbacks::callback_list_)
for (auto callback : callback_list_)
{
if (callback && callback->get_i_callback() == result.type)
{
@ -72,7 +73,7 @@ namespace steam
}
}
callbacks::results_.clear();
results_.clear();
}
extern "C"
@ -84,7 +85,7 @@ namespace steam
bool SteamAPI_Init()
{
overlay = GetModuleHandleA("gameoverlayrenderer.dll");
overlay = ::utils::nt::module("gameoverlayrenderer.dll");
if (!overlay)
{
@ -96,11 +97,14 @@ namespace steam
RegQueryValueExA(reg_key, "InstallPath", nullptr, nullptr, reinterpret_cast<BYTE*>(steam_path), &length);
RegCloseKey(reg_key);
SetDllDirectoryA(steam_path);
std::string overlay_path = steam_path;
if(overlay_path.back() != '\\' && overlay_path.back() != '/')
{
overlay_path.push_back('\\');
}
strcat_s(steam_path, "gameoverlayrenderer.dll");
overlay = LoadLibraryA(steam_path);
overlay_path.append("gameoverlayrenderer.dll");
overlay = ::utils::nt::module::load(overlay_path);
}
}
@ -149,69 +153,69 @@ namespace steam
}
steam::friends* SteamFriends()
friends* SteamFriends()
{
static steam::friends friends;
static friends friends;
return &friends;
}
steam::matchmaking* SteamMatchmaking()
matchmaking* SteamMatchmaking()
{
static steam::matchmaking matchmaking;
static matchmaking matchmaking;
return &matchmaking;
}
steam::matchmaking_servers* SteamMatchmakingServers()
matchmaking_servers* SteamMatchmakingServers()
{
static steam::matchmaking_servers matchmaking_servers;
static matchmaking_servers matchmaking_servers;
return &matchmaking_servers;
}
steam::game_server* SteamGameServer()
game_server* SteamGameServer()
{
static steam::game_server game_server;
static game_server game_server;
return &game_server;
}
steam::master_server_updater* SteamMasterServerUpdater()
master_server_updater* SteamMasterServerUpdater()
{
static steam::master_server_updater master_server_updater;
static master_server_updater master_server_updater;
return &master_server_updater;
}
steam::networking* SteamNetworking()
networking* SteamNetworking()
{
static steam::networking networking;
static networking networking;
return &networking;
}
steam::remote_storage* SteamRemoteStorage()
remote_storage* SteamRemoteStorage()
{
static steam::remote_storage remote_storage;
static remote_storage remote_storage;
return &remote_storage;
}
steam::user* SteamUser()
user* SteamUser()
{
static steam::user user;
static user user;
return &user;
}
steam::utils* SteamUtils()
utils* SteamUtils()
{
static steam::utils utils;
static utils utils;
return &utils;
}
steam::apps* SteamApps()
apps* SteamApps()
{
static steam::apps apps;
static apps apps;
return &apps;
}
steam::user_stats* SteamUserStats()
user_stats* SteamUserStats()
{
static steam::user_stats user_stats;
static user_stats user_stats;
return &user_stats;
}
}

View File

@ -1,6 +1,7 @@
#pragma once
#define STEAM_EXPORT extern "C" __declspec(dllexport)
#include "utils/nt.hpp"
struct raw_steam_id final
{
@ -16,17 +17,17 @@ typedef union
unsigned long long bits;
} steam_id;
#include "interfaces/SteamApps.hpp"
#include "interfaces/SteamUser.hpp"
#include "interfaces/SteamUtils.hpp"
#include "interfaces/SteamFriends.hpp"
#include "interfaces/SteamUserStats.hpp"
#include "interfaces/SteamGameServer.hpp"
#include "interfaces/SteamNetworking.hpp"
#include "interfaces/SteamMatchmaking.hpp"
#include "interfaces/SteamRemoteStorage.hpp"
#include "interfaces/SteamMatchmakingServers.hpp"
#include "interfaces/SteamMasterServerUpdater.hpp"
#include "interfaces/apps.hpp"
#include "interfaces/user.hpp"
#include "interfaces/utils.hpp"
#include "interfaces/friends.hpp"
#include "interfaces/user_stats.hpp"
#include "interfaces/game_server.hpp"
#include "interfaces/networking.hpp"
#include "interfaces/matchmaking.hpp"
#include "interfaces/remote_storage.hpp"
#include "interfaces/matchmaking_servers.hpp"
#include "interfaces/master_server_updater.hpp"
namespace steam
{
@ -86,17 +87,17 @@ namespace steam
STEAM_EXPORT void SteamGameServer_RunCallbacks();
STEAM_EXPORT void SteamGameServer_Shutdown();
STEAM_EXPORT steam::friends* SteamFriends();
STEAM_EXPORT steam::matchmaking* SteamMatchmaking();
STEAM_EXPORT steam::matchmaking_servers* SteamMatchmakingServers();
STEAM_EXPORT steam::game_server* SteamGameServer();
STEAM_EXPORT steam::master_server_updater* SteamMasterServerUpdater();
STEAM_EXPORT steam::networking* SteamNetworking();
STEAM_EXPORT steam::remote_storage* SteamRemoteStorage();
STEAM_EXPORT steam::user* SteamUser();
STEAM_EXPORT steam::utils* SteamUtils();
STEAM_EXPORT steam::apps* SteamApps();
STEAM_EXPORT steam::user_stats* SteamUserStats();
STEAM_EXPORT friends* SteamFriends();
STEAM_EXPORT matchmaking* SteamMatchmaking();
STEAM_EXPORT matchmaking_servers* SteamMatchmakingServers();
STEAM_EXPORT game_server* SteamGameServer();
STEAM_EXPORT master_server_updater* SteamMasterServerUpdater();
STEAM_EXPORT networking* SteamNetworking();
STEAM_EXPORT remote_storage* SteamRemoteStorage();
STEAM_EXPORT user* SteamUser();
STEAM_EXPORT utils* SteamUtils();
STEAM_EXPORT apps* SteamApps();
STEAM_EXPORT user_stats* SteamUserStats();
extern HMODULE overlay;
extern ::utils::nt::module overlay;
}

View File

@ -37,9 +37,9 @@ namespace utils
}
}
void hook::signature::add(const hook::signature::container& container)
void hook::signature::add(const container& container)
{
hook::signature::signatures_.push_back(container);
signatures_.push_back(container);
}
hook::~hook()
@ -103,9 +103,9 @@ namespace utils
void hook::quick()
{
if (hook::installed_)
if (this->installed_)
{
hook::installed_ = false;
this->installed_ = false;
}
}

View File

@ -40,6 +40,9 @@ namespace utils
hook(const DWORD place, const DWORD stub, const bool use_jump = true) : hook(reinterpret_cast<void*>(place), reinterpret_cast<void*>(stub), use_jump) {}
hook(const DWORD place, void(*stub)(), const bool use_jump = true) : hook(reinterpret_cast<void*>(place), reinterpret_cast<void*>(stub), use_jump) {}
hook(const hook&) = delete;
hook(const hook&&) = delete;
~hook();
hook* initialize(void* place, void* stub, bool use_jump = true);