Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Registry.h
- #pragma once
- #include <string>
- #include <Windows.h>
- #include <Lib.h>
- #include <util/FString.h>
- struct Registry {
- std::string name;
- PVOID func;
- };
- SML_API void registerCommand(std::string name, PVOID func);
- void hookCommandRegistry();
- void player_sent_message(void* player, FString* message);
- //Registry.cpp
- #include <stdafx.h>
- #include "Registry.h"
- #include <detours.h>
- #include <SatisfactoryModLoader.h>
- #include <util/Utility.h>
- SML_API void registerCommand(std::string name, PVOID func) {
- Registry r = {
- name,
- func
- };
- modHandler.commandRegistry.push_back(r);
- info(modHandler.commandRegistry.size());
- }
- void player_sent_message(void* player, FString* message) {
- //auto pointer = (void(WINAPI*)(void*, FString*))DetourFindFunction("FactoryGame-Win64-Shipping.exe", "AFGPlayerController::EnterChatMessage");
- char* chars = new char[message->length];
- for (size_t i = 0; i < message->length; i++) {
- chars[i] = message->data[i];
- }
- std::string str(chars);
- //pointer(player, message);
- }
- void hookCommandRegistry(){
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
- // find the function by name
- PVOID func = DetourFindFunction("FactoryGame-Win64-Shipping.exe", "AFGPlayerController::EnterChatMessage");
- // attach it, clearly
- DetourAttach(&(PVOID&)func, player_sent_message);
- DetourTransactionCommit();
- info("Hooked Command Registry!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement