Skip to content

Commit

Permalink
Find interfaces with a regular string instead of wide
Browse files Browse the repository at this point in the history
  • Loading branch information
degeneratehyperbola committed Mar 19, 2021
1 parent 15fa87e commit 371f3ac
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ void Hooks::install() noexcept
sound.hookAt(5, emitSound);
surface.hookAt(15, setDrawColor);
surface.hookAt(67, lockCursor);
svCheats.hookAt(13, svCheatsGetBool);
//svCheats.hookAt(13, svCheatsGetBool);
viewRender.hookAt(39, render2dEffectsPreHud);
viewRender.hookAt(41, renderSmokeOverlay);

Expand Down
79 changes: 42 additions & 37 deletions Interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,53 @@ class SoundEmitter;
class StudioRender;
//class SteamMatchMaking;

class Interfaces {
class Interfaces
{
public:
#define GAME_INTERFACE(type, name, module, version) \
type* name = reinterpret_cast<type*>(find(L##module, version));
#define GAME_INTERFACE(type, name, module, version) \
type* name = reinterpret_cast<type*>(find(##module, version));

GAME_INTERFACE(Client, client, "client", "VClient018")
GAME_INTERFACE(Cvar, cvar, "vstdlib", "VEngineCvar007")
GAME_INTERFACE(Effects, effects, "engine", "VEngineEffects001")
GAME_INTERFACE(Engine, engine, "engine", "VEngineClient014")
GAME_INTERFACE(EngineTrace, engineTrace, "engine", "EngineTraceClient004")
GAME_INTERFACE(EntityList, entityList, "client", "VClientEntityList003")
//GAME_INTERFACE(FileSystem, fileSystem, "filesystem_stdio", "VFileSystem017")
GAME_INTERFACE(GameEventManager, gameEventManager, "engine", "GAMEEVENTSMANAGER002")
GAME_INTERFACE(GameMovement, gameMovement, "client", "GameMovement001")
GAME_INTERFACE(GameUI, gameUI, "client", "GameUI011")
GAME_INTERFACE(InputSystem, inputSystem, "inputsystem", "InputSystemVersion001")
GAME_INTERFACE(Localize, localize, "localize", "Localize_001")
GAME_INTERFACE(MaterialSystem, materialSystem, "materialsystem", "VMaterialSystem080")
GAME_INTERFACE(ModelInfo, modelInfo, "engine", "VModelInfoClient004")
GAME_INTERFACE(ModelRender, modelRender, "engine", "VEngineModel016")
GAME_INTERFACE(NetworkStringTableContainer, networkStringTableContainer, "engine", "VEngineClientStringTable001")
GAME_INTERFACE(Panel, panel, "vgui2", "VGUI_Panel009")
GAME_INTERFACE(PhysicsSurfaceProps, physicsSurfaceProps, "vphysics", "VPhysicsSurfaceProps001")
GAME_INTERFACE(Prediction, prediction, "client", "VClientPrediction001")
GAME_INTERFACE(RenderView, renderView, "engine", "VEngineRenderView014")
GAME_INTERFACE(Surface, surface, "vguimatsurface", "VGUI_Surface031")
GAME_INTERFACE(Sound, sound, "engine", "IEngineSoundClient003")
GAME_INTERFACE(SoundEmitter, soundEmitter, "soundemittersystem", "VSoundEmitter003")
GAME_INTERFACE(StudioRender, studioRender, "studiorender", "VStudioRender026")
//GAME_INTERFACE(SteamMatchMaking, steamMatchMaking, "steam_api", "SteamMatchMaking009")
GAME_INTERFACE(Client, client, "client", "VClient018")
GAME_INTERFACE(Cvar, cvar, "vstdlib", "VEngineCvar007")
GAME_INTERFACE(Effects, effects, "engine", "VEngineEffects001")
GAME_INTERFACE(Engine, engine, "engine", "VEngineClient014")
GAME_INTERFACE(EngineTrace, engineTrace, "engine", "EngineTraceClient004")
GAME_INTERFACE(EntityList, entityList, "client", "VClientEntityList003")
//GAME_INTERFACE(FileSystem, fileSystem, "filesystem_stdio", "VFileSystem017")
GAME_INTERFACE(GameEventManager, gameEventManager, "engine", "GAMEEVENTSMANAGER002")
GAME_INTERFACE(GameMovement, gameMovement, "client", "GameMovement001")
GAME_INTERFACE(GameUI, gameUI, "client", "GameUI011")
GAME_INTERFACE(InputSystem, inputSystem, "inputsystem", "InputSystemVersion001")
GAME_INTERFACE(Localize, localize, "localize", "Localize_001")
GAME_INTERFACE(MaterialSystem, materialSystem, "materialsystem", "VMaterialSystem080")
GAME_INTERFACE(ModelInfo, modelInfo, "engine", "VModelInfoClient004")
GAME_INTERFACE(ModelRender, modelRender, "engine", "VEngineModel016")
GAME_INTERFACE(NetworkStringTableContainer, networkStringTableContainer, "engine", "VEngineClientStringTable001")
GAME_INTERFACE(Panel, panel, "vgui2", "VGUI_Panel009")
GAME_INTERFACE(PhysicsSurfaceProps, physicsSurfaceProps, "vphysics", "VPhysicsSurfaceProps001")
GAME_INTERFACE(Prediction, prediction, "client", "VClientPrediction001")
GAME_INTERFACE(RenderView, renderView, "engine", "VEngineRenderView014")
GAME_INTERFACE(Surface, surface, "vguimatsurface", "VGUI_Surface031")
GAME_INTERFACE(Sound, sound, "engine", "IEngineSoundClient003")
GAME_INTERFACE(SoundEmitter, soundEmitter, "soundemittersystem", "VSoundEmitter003")
GAME_INTERFACE(StudioRender, studioRender, "studiorender", "VStudioRender026")
//GAME_INTERFACE(SteamMatchMaking, steamMatchMaking, "steam_api", "SteamMatchMaking009")

#undef GAME_INTERFACE
#undef GAME_INTERFACE
private:
static void* find(const wchar_t* moduleName, const char* name) noexcept
{
if (const auto createInterface = reinterpret_cast<std::add_pointer_t<void* __cdecl (const char* name, int* returnCode)>>(GetProcAddress(GetModuleHandleW(moduleName), "CreateInterface")))
if (void* foundInterface = createInterface(name, nullptr))
return foundInterface;
static void *find(const char *moduleName, const char *name) noexcept
{
if (const auto createInterface = reinterpret_cast<std::add_pointer_t<void *__cdecl(const char *name, int *returnCode)>>(
GetProcAddress(GetModuleHandleA(moduleName), "CreateInterface")
))
{
if (void *foundInterface = createInterface(name, nullptr))
return foundInterface;
}

MessageBoxA(nullptr, ("Failed to find " + std::string{ name } + " interface!").c_str(), "NEPS.PP", MB_OK | MB_ICONERROR);
std::exit(EXIT_FAILURE);
}
MessageBoxA(nullptr, ("Failed to find " + std::string{name} + " interface!").c_str(), "NEPS.PP", MB_OK | MB_ICONERROR);
std::exit(EXIT_FAILURE);
}
};

inline std::unique_ptr<const Interfaces> interfaces;

0 comments on commit 371f3ac

Please sign in to comment.