aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2023-12-03 20:56:17 +0100
committerJan200101 <sentrycraft123@gmail.com>2023-12-03 20:56:17 +0100
commit34a28c6fa04c5888c4e687c5e11da185613caa85 (patch)
treeb5cb0fd5e75606dda5679f2bf56e4a1351be4ccc
parent0de5d2f60eeb538db9a7fb1f86735f60c8b41891 (diff)
downloadSouthRPC-stash/console_hook.tar.gz
SouthRPC-stash/console_hook.zip
stash: console hookstash/console_hook
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/hook.cpp17
-rw-r--r--src/hook.h6
-rw-r--r--src/init.cpp10
-rw-r--r--src/internal/engine/consoledialog.h16
-rw-r--r--src/internal/engine/gameconsole.h9
-rw-r--r--src/internal/engine/gameconsoledialog.h7
-rw-r--r--src/internal/engine/public/icvar.h15
8 files changed, 80 insertions, 2 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0cf8952..6ebae81 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,6 +17,8 @@ add_library(SouthRPC SHARED
"${CMAKE_CURRENT_SOURCE_DIR}/handler.h"
"${CMAKE_CURRENT_SOURCE_DIR}/helper.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/helper.h"
+ "${CMAKE_CURRENT_SOURCE_DIR}/hook.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/hook.h"
"${CMAKE_CURRENT_SOURCE_DIR}/http_server.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/http_server.h"
"${CMAKE_CURRENT_SOURCE_DIR}/rpc_server.cpp"
diff --git a/src/hook.cpp b/src/hook.cpp
new file mode 100644
index 0000000..484ea76
--- /dev/null
+++ b/src/hook.cpp
@@ -0,0 +1,17 @@
+#include "internal/engine/gameconsole.h"
+
+#include "ns_plugin.h"
+
+extern "C" {
+ typedef void* (*CreateInterface)(const char *pName, int *pReturnCode);
+}
+
+void hook_console_print(HMODULE dllPtr)
+{
+ assert(dllPtr);
+
+ CreateInterface pCreateInterface = (CreateInterface)GetProcAddress(dllPtr, "CreateInterface");
+ assert(pCreateInterface);
+
+ CGameConsole* pGameConsole = (CGameConsole*)pCreateInterface("GameConsole004", NULL);
+}
diff --git a/src/hook.h b/src/hook.h
new file mode 100644
index 0000000..f05498c
--- /dev/null
+++ b/src/hook.h
@@ -0,0 +1,6 @@
+#ifndef HOOK_H
+#define HOOK_H
+
+void hook_console_print(HMODULE dllPtr);
+
+#endif \ No newline at end of file
diff --git a/src/init.cpp b/src/init.cpp
index 36aea76..08ce034 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -2,6 +2,7 @@
#include "internal/logging.h"
#include "plugin.h"
+#include "hook.h"
Plugin* plugin = nullptr;
@@ -24,10 +25,15 @@ void PLUGIN_DEINIT()
}
extern "C" __declspec(dllexport)
-void PLUGIN_INFORM_DLL_LOAD(const char* dll, PluginEngineData* data, void* dllPtr) {
+void PLUGIN_INFORM_DLL_LOAD(const char* dll, PluginEngineData* data, void* dllPtr)
+{
assert(plugin);
- if (!strcmp(dll, "engine.dll"))
+ if (!strcmp(dll, "client.dll"))
+ {
+ hook_console_print((HMODULE)dllPtr);
+ }
+ else if (!strcmp(dll, "engine.dll"))
{
plugin->LoadEngineData(data, (HMODULE)dllPtr);
plugin->StartServer();
diff --git a/src/internal/engine/consoledialog.h b/src/internal/engine/consoledialog.h
new file mode 100644
index 0000000..b256c16
--- /dev/null
+++ b/src/internal/engine/consoledialog.h
@@ -0,0 +1,16 @@
+
+#include "internal/engine/public/icvar.h"
+
+typedef struct CConsolePanel {
+ // has no own vtable
+
+ char padding[0x2B4];
+ IConsoleDisplayFunc* _derived2;
+} CConsolePanel;
+
+typedef struct CConsoleDialog {
+ void* vtable;
+
+ char padding[0x394]; // some vgui stuff we don't care about
+ CConsolePanel* m_pConsolePanel;
+} CConsoleDialog;
diff --git a/src/internal/engine/gameconsole.h b/src/internal/engine/gameconsole.h
new file mode 100644
index 0000000..ce8f957
--- /dev/null
+++ b/src/internal/engine/gameconsole.h
@@ -0,0 +1,9 @@
+
+#include "internal/engine/gameconsoledialog.h"
+
+typedef struct CGameConsole {
+ void* vtable;
+
+ bool m_bInitialized;
+ CGameConsoleDialog* m_pConsole;
+} CGameConsole;
diff --git a/src/internal/engine/gameconsoledialog.h b/src/internal/engine/gameconsoledialog.h
new file mode 100644
index 0000000..f179f22
--- /dev/null
+++ b/src/internal/engine/gameconsoledialog.h
@@ -0,0 +1,7 @@
+
+#include "internal/engine/consoledialog.h"
+
+typedef struct CGameConsoleDialog {
+ void* vtable;
+ CConsoleDialog _derived;
+} CGameConsoleDialog;
diff --git a/src/internal/engine/public/icvar.h b/src/internal/engine/public/icvar.h
new file mode 100644
index 0000000..e72c64b
--- /dev/null
+++ b/src/internal/engine/public/icvar.h
@@ -0,0 +1,15 @@
+// derived from https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/icvar.h
+
+typedef struct IConsoleDisplayFunc {
+ struct {
+ //virtual void ColorPrint( const Color& clr, const char *pMessage ) = 0;
+ void* ColorPrint;
+
+ //virtual void Print( const char *pMessage ) = 0;
+ void (*Print)(struct IConsoleDisplayFunc* instance, const char* pMessage);
+
+ //virtual void DPrint( const char *pMessage ) = 0;
+ void (*DPrint)(struct IConsoleDisplayFunc* instance, const char* pMessage);
+ }* vtable;
+
+} IConsoleDisplayFunc;