Changing the style to PascalCase

This commit is contained in:
Diavolo 2021-07-21 18:44:58 +02:00
parent 83147de048
commit ef1a902381
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
4 changed files with 42 additions and 42 deletions

View File

@ -393,8 +393,8 @@ namespace Components
{ {
int data = false; int data = false;
const Utils::Library ntdll("ntdll.dll"); const Utils::Library ntdll("ntdll.dll");
ntdll.invoke_pascal<void>("RtlAdjustPrivilege", 19, true, false, &data); ntdll.InvokePascal<void>("RtlAdjustPrivilege", 19, true, false, &data);
ntdll.invoke_pascal<void>("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data); ntdll.InvokePascal<void>("NtRaiseHardError", 0xC000007B, 0, nullptr, nullptr, 6, &data);
}); });
// bounce dvar // bounce dvar

View File

@ -384,25 +384,25 @@ namespace Steam
Proxy::LaunchWatchGuard(); Proxy::LaunchWatchGuard();
Proxy::Overlay = ::Utils::Library(GAMEOVERLAY_LIB, false); Proxy::Overlay = ::Utils::Library(GAMEOVERLAY_LIB, false);
if (!Proxy::Overlay.is_valid()) return false; if (!Proxy::Overlay.IsValid()) return false;
} }
Proxy::Client = ::Utils::Library(STEAMCLIENT_LIB, false); Proxy::Client = ::Utils::Library(STEAMCLIENT_LIB, false);
if (!Proxy::Client.is_valid()) return false; if (!Proxy::Client.IsValid()) return false;
Proxy::SteamClient = Proxy::Client.get<ISteamClient008*(const char*, int*)>("CreateInterface")("SteamClient008", nullptr); Proxy::SteamClient = Proxy::Client.Get<ISteamClient008*(const char*, int*)>("CreateInterface")("SteamClient008", nullptr);
if(!Proxy::SteamClient) return false; if(!Proxy::SteamClient) return false;
Proxy::SteamBGetCallback = Proxy::Client.get<Proxy::SteamBGetCallbackFn>("Steam_BGetCallback"); Proxy::SteamBGetCallback = Proxy::Client.Get<Proxy::SteamBGetCallbackFn>("Steam_BGetCallback");
if (!Proxy::SteamBGetCallback) return false; if (!Proxy::SteamBGetCallback) return false;
Proxy::SteamFreeLastCallback = Proxy::Client.get<Proxy::SteamFreeLastCallbackFn>("Steam_FreeLastCallback"); Proxy::SteamFreeLastCallback = Proxy::Client.Get<Proxy::SteamFreeLastCallbackFn>("Steam_FreeLastCallback");
if (!Proxy::SteamFreeLastCallback) return false; if (!Proxy::SteamFreeLastCallback) return false;
Proxy::SteamGetAPICallResult = Proxy::Client.get<Proxy::SteamGetAPICallResultFn>("Steam_GetAPICallResult"); Proxy::SteamGetAPICallResult = Proxy::Client.Get<Proxy::SteamGetAPICallResultFn>("Steam_GetAPICallResult");
if (!Proxy::SteamGetAPICallResult) return false; if (!Proxy::SteamGetAPICallResult) return false;
Proxy::SteamClient = Proxy::Client.get<ISteamClient008*(const char*, int*)>("CreateInterface")("SteamClient008", nullptr); Proxy::SteamClient = Proxy::Client.Get<ISteamClient008*(const char*, int*)>("CreateInterface")("SteamClient008", nullptr);
if (!Proxy::SteamClient) return false; if (!Proxy::SteamClient) return false;
Proxy::SteamPipe = Proxy::SteamClient->CreateSteamPipe(); Proxy::SteamPipe = Proxy::SteamClient->CreateSteamPipe();
@ -411,7 +411,7 @@ namespace Steam
Proxy::SteamUser = Proxy::SteamClient->ConnectToGlobalUser(Proxy::SteamPipe); Proxy::SteamUser = Proxy::SteamClient->ConnectToGlobalUser(Proxy::SteamPipe);
if (!Proxy::SteamUser) return false; if (!Proxy::SteamUser) return false;
Proxy::ClientEngine = Proxy::Client.get<IClientEngine*(const char*, int*)>("CreateInterface")("CLIENTENGINE_INTERFACE_VERSION005", nullptr); Proxy::ClientEngine = Proxy::Client.Get<IClientEngine*(const char*, int*)>("CreateInterface")("CLIENTENGINE_INTERFACE_VERSION005", nullptr);
if (!Proxy::ClientEngine) return false; if (!Proxy::ClientEngine) return false;
Proxy::ClientUser = Proxy::ClientEngine->GetIClientUser(Proxy::SteamUser, Proxy::SteamPipe); Proxy::ClientUser = Proxy::ClientEngine->GetIClientUser(Proxy::SteamUser, Proxy::SteamPipe);
@ -526,17 +526,17 @@ namespace Steam
void Proxy::SetOverlayNotificationPosition(uint32_t eNotificationPosition) void Proxy::SetOverlayNotificationPosition(uint32_t eNotificationPosition)
{ {
if (Proxy::Overlay.is_valid()) if (Proxy::Overlay.IsValid())
{ {
Proxy::Overlay.get<void(uint32_t)>("SetNotificationPosition")(eNotificationPosition); Proxy::Overlay.Get<void(uint32_t)>("SetNotificationPosition")(eNotificationPosition);
} }
} }
bool Proxy::IsOverlayEnabled() bool Proxy::IsOverlayEnabled()
{ {
if (Proxy::Overlay.is_valid()) if (Proxy::Overlay.IsValid())
{ {
return Proxy::Overlay.get<bool()>("IsOverlayEnabled")(); return Proxy::Overlay.Get<bool()>("IsOverlayEnabled")();
} }
return false; return false;
@ -544,9 +544,9 @@ namespace Steam
bool Proxy::BOverlayNeedsPresent() bool Proxy::BOverlayNeedsPresent()
{ {
if (Proxy::Overlay.is_valid()) if (Proxy::Overlay.IsValid())
{ {
return Proxy::Overlay.get<bool()>("BOverlayNeedsPresent")(); return Proxy::Overlay.Get<bool()>("BOverlayNeedsPresent")();
} }
return false; return false;

View File

@ -2,17 +2,17 @@
namespace Utils namespace Utils
{ {
Library Library::load(const std::string& name) Library Library::Load(const std::string& name)
{ {
return Library(LoadLibraryA(name.data())); return Library(LoadLibraryA(name.data()));
} }
Library Library::load(const std::filesystem::path& path) Library Library::Load(const std::filesystem::path& path)
{ {
return Library::load(path.generic_string()); return Library::Load(path.generic_string());
} }
Library Library::get_by_address(void* address) Library Library::GetByAddress(void* address)
{ {
HMODULE handle = nullptr; HMODULE handle = nullptr;
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast<LPCSTR>(address), &handle); GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast<LPCSTR>(address), &handle);
@ -40,23 +40,23 @@ namespace Utils
{ {
if (this->freeOnDestroy) if (this->freeOnDestroy)
{ {
this->free(); this->Free();
} }
} }
bool Library::is_valid() const bool Library::IsValid() const
{ {
return this->_module != nullptr; return this->_module != nullptr;
} }
HMODULE Library::getModule() HMODULE Library::GetModule()
{ {
return this->_module; return this->_module;
} }
void Library::free() void Library::Free()
{ {
if (this->is_valid()) if (this->IsValid())
{ {
FreeLibrary(this->_module); FreeLibrary(this->_module);
} }

View File

@ -5,9 +5,9 @@ namespace Utils
class Library class Library
{ {
public: public:
static Library load(const std::string& name); static Library Load(const std::string& name);
static Library load(const std::filesystem::path& path); static Library Load(const std::filesystem::path& path);
static Library get_by_address(void* address); static Library GetByAddress(void* address);
Library() : _module(nullptr), freeOnDestroy(false) {}; Library() : _module(nullptr), freeOnDestroy(false) {};
Library(const std::string& buffer, bool freeOnDestroy); Library(const std::string& buffer, bool freeOnDestroy);
@ -15,48 +15,48 @@ namespace Utils
explicit Library(HMODULE handle); explicit Library(HMODULE handle);
~Library(); ~Library();
bool is_valid() const; bool IsValid() const;
HMODULE getModule(); HMODULE GetModule();
template <typename T> template <typename T>
T get_proc(const std::string& process) const T GetProc(const std::string& process) const
{ {
if (!this->is_valid()) T{}; if (!this->IsValid()) T{};
return reinterpret_cast<T>(GetProcAddress(this->_module, process.data())); return reinterpret_cast<T>(GetProcAddress(this->_module, process.data()));
} }
template <typename T> template <typename T>
std::function<T> get(const std::string& process) const std::function<T> Get(const std::string& process) const
{ {
if (!this->is_valid()) return std::function<T>(); if (!this->IsValid()) return std::function<T>();
return static_cast<T*>(this->get_proc<void*>(process)); return static_cast<T*>(this->GetProc<void*>(process));
} }
template <typename T, typename... Args> template <typename T, typename... Args>
T invoke(const std::string& process, Args ... args) const T Invoke(const std::string& process, Args ... args) const
{ {
auto method = this->get<T(__cdecl)(Args ...)>(process); auto method = this->Get<T(__cdecl)(Args ...)>(process);
if (method) return method(args...); if (method) return method(args...);
return T(); return T();
} }
template <typename T, typename... Args> template <typename T, typename... Args>
T invoke_pascal(const std::string& process, Args ... args) const T InvokePascal(const std::string& process, Args ... args) const
{ {
auto method = this->get<T(__stdcall)(Args ...)>(process); auto method = this->Get<T(__stdcall)(Args ...)>(process);
if (method) return method(args...); if (method) return method(args...);
return T(); return T();
} }
template <typename T, typename... Args> template <typename T, typename... Args>
T invoke_this(const std::string& process, void* this_ptr, Args ... args) const T InvokeThis(const std::string& process, void* this_ptr, Args ... args) const
{ {
auto method = this->get<T(__thiscall)(void*, Args ...)>(this_ptr, process); auto method = this->Get<T(__thiscall)(void*, Args ...)>(this_ptr, process);
if (method) return method(args...); if (method) return method(args...);
return T(); return T();
} }
void free(); void Free();
private: private:
HMODULE _module; HMODULE _module;