SHARE
TWEET

Untitled

a guest Apr 24th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Registry.h
  2.  
  3. #pragma once
  4. #include <string>
  5. #include <Windows.h>
  6. #include <Lib.h>
  7. #include <util/FString.h>
  8.  
  9. struct Registry {
  10.     std::string name;
  11.     PVOID func;
  12. };
  13.  
  14. SML_API void registerCommand(std::string name, PVOID func);
  15.  
  16. void hookCommandRegistry();
  17.  
  18. void player_sent_message(void* player, FString* message);
  19.  
  20. //Registry.cpp
  21.  
  22. #include <stdafx.h>
  23. #include "Registry.h"
  24. #include <detours.h>
  25. #include <SatisfactoryModLoader.h>
  26. #include <util/Utility.h>
  27.  
  28. SML_API void registerCommand(std::string name, PVOID func) {
  29.     Registry r = {
  30.         name,
  31.         func
  32.     };
  33.     modHandler.commandRegistry.push_back(r);
  34.     info(modHandler.commandRegistry.size());
  35. }
  36.  
  37. void player_sent_message(void* player, FString* message) {
  38.  
  39.     //auto pointer = (void(WINAPI*)(void*, FString*))DetourFindFunction("FactoryGame-Win64-Shipping.exe", "AFGPlayerController::EnterChatMessage");
  40.  
  41.     char* chars = new char[message->length];
  42.  
  43.     for (size_t i = 0; i < message->length; i++) {
  44.         chars[i] = message->data[i];
  45.     }
  46.  
  47.     std::string str(chars);
  48.  
  49.     //pointer(player, message);
  50.  
  51. }
  52.  
  53. void hookCommandRegistry(){
  54.     DetourTransactionBegin();
  55.     DetourUpdateThread(GetCurrentThread());
  56.  
  57.     // find the function by name
  58.     PVOID func = DetourFindFunction("FactoryGame-Win64-Shipping.exe", "AFGPlayerController::EnterChatMessage");
  59.  
  60.     // attach it, clearly
  61.     DetourAttach(&(PVOID&)func, player_sent_message);
  62.     DetourTransactionCommit();
  63.     info("Hooked Command Registry!");
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top