Untitled
unknown
c_cpp
a year ago
2.8 kB
6
Indexable
```c++ #include <Windows.h> #include <iostream> #include "SDK/Engine_classes.hpp" // Basic.cpp was added to the VS project // Engine_functions.cpp was added to the VS project DWORD MainThread(HMODULE hModule) { /* Code to open a console window */ AllocConsole(); FILE* Dummy; freopen_s(&Dummy, "CONOUT$", "w", stdout); freopen_s(&Dummy, "CONIN$", "r", stdin); /* Functions returning "static" instances */ SDK::UEngine* Engine = SDK::UEngine::GetEngine(); SDK::UWorld* World = SDK::UWorld::GetWorld(); /* Getting the PlayerController, World, OwningGameInstance, ... should all be checked not to be nullptr! */ SDK::APlayerController* MyController = World->OwningGameInstance->LocalPlayers[0]->PlayerController; /* Print the full-name of an object ("ClassName PackageName.OptionalOuter.ObjectName") */ std::cout << Engine->ConsoleClass->GetFullName() << std::endl; /* Manually iterating GObjects and printing the FullName of every UObject that is a Pawn (not recommended) */ for (int i = 0; i < SDK::UObject::GObjects->Num(); i++) { SDK::UObject* Obj = SDK::UObject::GObjects->GetByIndex(i); if (!Obj) continue; if (!Obj->IsDefaultObject()) continue; /* Only the 'IsA' check using the cast flags is required, the other 'IsA' is redundant */ if (Obj->IsA(SDK::APawn::StaticClass()) || Obj->HasTypeFlag(SDK::EClassCastFlags::Pawn)) { std::cout << Obj->GetFullName() << "\n"; } } /* * Changes the keyboard-key that's used to open the UE console * * This is a rare case of a DefaultObjects' member-variables being changed. * By default you do not want to use the DefaultObject, this is a rare exception. */ SDK::UInputSettings::GetDefaultObj()->ConsoleKeys[0].KeyName = SDK::UKismetStringLibrary::Conv_StringToName(L"F2"); /* Creates a new UObject of class-type specified by Engine->ConsoleClass */ SDK::UObject* NewObject = SDK::UGameplayStatics::SpawnObject(Engine->ConsoleClass, Engine->GameViewport); /* The Object we created is a subclass of UConsole, so this cast is **safe**. */ Engine->GameViewport->ViewportConsole = static_cast<SDK::UConsole*>(NewObject); while (true) { if (GetAsyncKeyState(VK_DELETE) & 1) { std::cout << "Trying to uninject\n"; fclose(Dummy); FreeConsole(); FreeLibraryAndExitThread(hModule, NULL); } } } BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) { switch (reason) { case DLL_PROCESS_ATTACH: CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainThread, hModule, 0, 0); break; } return TRUE; } ```
Editor is loading...
Leave a Comment