Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * FortConsole by Makks
- * Build with debug configuration for nerd stuff.
- */
- #ifdef WIN32
- #error x86 is not supported, please compile in x64
- #endif
- #define _CRT_SECURE_NO_WARNINGS
- #include "enums.h"
- #include "memory.h"
- #include <stdio.h>
- #include <iostream>
- #include <string>
- HMODULE handle;
- uintptr_t moduleBase = (uintptr_t)GetModuleHandle(nullptr);
- struct UObject;
- struct UClass;
- struct UPackage;
- struct UConsole;
- struct FString;
- struct UGameViewportClient
- {
- char unknown1[0x40];
- UConsole* ViewportConsole;
- };
- struct UEngine
- {
- char unknown1[0xF8];
- UClass* ConsoleClass;
- char unknown2[0x688];
- UGameViewportClient* GameViewportClient;
- };
- #ifdef _DEBUG
- #define DEBUG_LOG(input, ...) printf(input, __VA_ARGS__);
- #else
- #define DEBUG_LOG(input, ...)
- #endif
- #define VALIDATE_ADDRESS(address, error) \
- if (!address) { \
- MessageBox(0, (LPCWSTR)error, L"FortConsole", MB_OK); \
- FreeLibraryAndExitThread((HMODULE)param, 0); \
- return 0; \
- }
- UEngine* GEngine;
- /*
- typedef UObject* (__fastcall* f_StaticConstructObject_Internal)(
- UClass* Class,
- UObject* InOuter,
- void* Name,
- int SetFlags,
- unsigned int InternalSetFlags,
- UObject* Template,
- bool bCopyTransientsFromClassDefaults,
- void* InstanceGraph,
- bool bAssumeTemplateIsArchetype
- );
- static f_StaticConstructObject_Internal StaticConstructObject_Internal;
- */
- template<class T>
- struct TArray
- {
- T* Data;
- int Count;
- int Max;
- };
- struct FString : public TArray<wchar_t>
- {
- inline const wchar_t* c_str() const
- {
- return Data;
- }
- std::string ToString() const
- {
- const auto length = std::wcslen(Data);
- std::string str(length, '\0');
- std::use_facet<std::ctype<wchar_t>>(std::locale()).narrow(Data, Data + length, '?', &str[0]);
- return str;
- }
- };
- void* Result;
- typedef FString* (__fastcall* fGetEngineVersion)
- (
- void* Result
- );
- static fGetEngineVersion GetEngineVersion;
- struct FStaticConstructObjectParameters
- {
- /** The class of the object to create */
- const UClass* Class = {};
- /** The object to create this object within (the Outer property for the new object will be set to the value specified here). */
- UObject* Outer = {};
- /** The name to give the new object.If no value(NAME_None) is specified, the object will be given a unique name in the form of ClassName_#. */
- void* Name = {};
- /** The ObjectFlags to assign to the new object. some flags can affect the behavior of constructing the object. */
- int SetFlags = {};
- /** The InternalObjectFlags to assign to the new object. some flags can affect the behavior of constructing the object. */
- unsigned int InternalSetFlags = {};
- /** If true, copy transient from the class defaults instead of the pass in archetype ptr(often these are the same) */
- bool bCopyTransientsFromClassDefaults = false;
- /** If true, Template is guaranteed to be an archetype */
- bool bAssumeTemplateIsArchetype = false;
- /**
- * If specified, the property values from this object will be copied to the new object, and the new object's ObjectArchetype value will be set to this object.
- * If nullptr, the class default object is used instead.
- */
- UObject* Template = nullptr;
- /** Contains the mappings of instanced objects and components to their templates */
- void* InstanceGraph = nullptr;
- /** Assign an external Package to the created object if non-null */
- UPackage* ExternalPackage = nullptr;
- FStaticConstructObjectParameters() {};
- };
- typedef UObject* (__fastcall* fStaticConstructObject_Internal)
- (
- const FStaticConstructObjectParameters&
- );
- static fStaticConstructObject_Internal StaticConstructObject_Internal;
- std::string text;
- DWORD WINAPI MainThread(LPVOID param)
- {
- #ifdef _DEBUG
- AllocConsole();
- #pragma warning( push )
- #pragma warning( disable : 6031 )
- freopen("CONOUT$", "w", stdout);
- #pragma warning( pop )
- #endif
- handle = (HMODULE)param;
- const char* comboPattern = "48 83 3D ?? ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 48 8D 54 24 ?? 48 89 5C 24 ?? 48 8D 4D A0";
- //uintptr_t GEngine_Address = (uintptr_t)Memory::ScanIn(comboPattern, (char*)moduleBase);
- uintptr_t GEngine_Address = moduleBase + 0x561F6A8;
- GEngine = (UEngine*) GEngine_Address;
- VALIDATE_ADDRESS(GEngine_Address, L"Failed to find GEngine.");
- DEBUG_LOG("GEngine: %p\n", GEngine);
- DEBUG_LOG("Console Class: %p\n", GEngine->ConsoleClass);
- DEBUG_LOG("Game Viewport Client: %p\n", GEngine->GameViewportClient);
- const char* scoifullcombo = "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 48 8B 31 48 8B D9";
- uintptr_t SCOIAddress = (uintptr_t)Memory::ScanIn(scoifullcombo, (char*)moduleBase);
- VALIDATE_ADDRESS(SCOIAddress, L"Failed to find StaticConstructObject_Internal.");
- StaticConstructObject_Internal = reinterpret_cast<fStaticConstructObject_Internal>(SCOIAddress);
- DEBUG_LOG("StaticConstructObject_Internal: %p\n", StaticConstructObject_Internal);
- FStaticConstructObjectParameters Params;
- Params.Class = GEngine->ConsoleClass;
- Params.Outer = reinterpret_cast<UObject*>(GEngine->GameViewportClient);
- Params.Name = nullptr;
- Params.SetFlags = 0;
- Params.InternalSetFlags = 0;
- Params.Template = nullptr;
- Params.bCopyTransientsFromClassDefaults = false;
- Params.InstanceGraph = nullptr;
- Params.bAssumeTemplateIsArchetype = false;
- Params.ExternalPackage = nullptr;
- //return reinterpret_cast<UConsole*>(StaticConstructObject_Internal(ConsoleClass, outer, nullptr, 0, 0, nullptr, false, nullptr, false));// , nullptr));
- UConsole* Console = reinterpret_cast<UConsole*>(StaticConstructObject_Internal(Params));
- /*
- UConsole* Console = reinterpret_cast<UConsole*>(StaticConstructObject_Internal(
- GEngine->ConsoleClass,
- reinterpret_cast<UObject*>(GEngine->GameViewportClient),
- nullptr,
- EObjectFlags::RF_NoFlags,
- EInternalObjectFlags::None,
- nullptr,
- false,
- nullptr,
- false
- ));
- */
- GEngine->GameViewportClient->ViewportConsole = Console;
- FreeLibraryAndExitThread((HMODULE)param, 0);
- return 0;
- }
- BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- CreateThread(0, 0, MainThread, hModule, 0, 0);
- break;
- }
- return TRUE;
- }
Add Comment
Please, Sign In to add comment