RussellJerome / UnrealModLoader

GNU Lesser General Public License v2.1
209 stars 66 forks source link

How do I create a game profile? #2

Closed s0renbjerg closed 3 years ago

s0renbjerg commented 3 years ago

How do I go about finding the required function offsets, to create a profile, for a game I'd like to mod using this tool?

The game executable is available to me (obviously), and so is the PDB file (as it was distributed alongside the game).

I have tried running them through IDA, after which I thought I could simply search for the functions, but it does not appear to be as simple as that, since no occurrences were found for e.g. "GameStateInit".

s0renbjerg commented 3 years ago

Alright, so I've made some progress after finding out about and using x64dbg to search the Symbols.

The UML console is fortunately more helpful than the profiles themselves, since it spells out full name of the function that it's looking for once it gets going (or at least for the ones I've seen it mention).

Using the x64dbg-found addresses of these functions (that I assume are correct?)...

GameStateInit : AGameModeBase::InitGameState BeginPlay : AActor::BeginPlay Say : AGameMode::Say StaticLoadObject : StaticLoadObject SpawnActorFTrans : UWorld::SpawnActor CallFunctionByNameWithArguments : UObject::CallFunctionByNameWithArguments CreateDefualtObject : UClass::CreateDefaultObject ProcessEvent : UObject::ProcessEvent

...takes me this far (it found GName, GObject and GWorld on its own):

[UnrealModLoader][INFO] Created by ~Russell.J Release V1.1.0 [UnrealModLoader][INFO] Profile Detected: [...] [UnrealModLoader][INFO] GName: 0x00007FF7C405A890 [UnrealModLoader][INFO] GObject: 0x00007FF7C405DC20 [UnrealModLoader][INFO] GWorld: 0x00007FF7C419E310 [UnrealModLoader][INFO] Function Offsets Set! [UnrealModLoader][INFO] Setup [...] [UnrealModLoader][INFO] Setting Up Loader [UnrealModLoader][INFO] MinHook Setup [UnrealModLoader][INFO] PakModLoaded: [...] [UnrealModLoader][INFO] ScanLoadedPaks Setup [UnrealModLoader][INFO] Added hook: AGameModeBase::InitGameState [UnrealModLoader][INFO] Added hook: AActor::BeginPlay [UnrealModLoader][INFO] Added hook: AGameMode::Say [UnrealModLoader][INFO] GameStateHook [UnrealModLoader][WARNING] Engine Classes Not Defined. Starting Automatic Class Finder.

Looking at the existing profiles I do see some engine definition stuff in some of them ("EngineDefs via their offsets found in reclass"), so I've downloaded ReClass.NET, attached to the game process... and now I'm even more lost than I was before.

s0renbjerg commented 3 years ago

Hi there. It's me... again, again.

Digging/experimenting some more with IDA, I managed to find UObjectBase, UField, UStruct and UFunction and their respective variable offsets in Local Types and Structures, and with those I get a little further:

[UnrealModLoader][INFO] Created by ~Russell.J Release V1.1.0 [UnrealModLoader][INFO] Profile Detected: [...] [UnrealModLoader][INFO] GName: 0x00007FF6D1DEA890 [UnrealModLoader][INFO] GObject: 0x00007FF6D1DEDC20 [UnrealModLoader][INFO] GWorld: 0x00007FF6D1F2E310 [UnrealModLoader][INFO] Function Offsets Set! [UnrealModLoader][INFO] Setup [...] [UnrealModLoader][INFO] Setting Up Loader [UnrealModLoader][INFO] MinHook Setup [UnrealModLoader][INFO] PakModLoaded: [...] [UnrealModLoader][INFO] ScanLoadedPaks Setup [UnrealModLoader][INFO] Added hook: AGameModeBase::InitGameState [UnrealModLoader][INFO] Added hook: AActor::BeginPlay [UnrealModLoader][INFO] Added hook: AGameMode::Say [UnrealModLoader][INFO] GameStateHook [UnrealModLoader][INFO] Engine Classes Loaded [UnrealModLoader][INFO] StaticLoadObject Found

And at this point, the program hangs around for a bit before terminating and nothing more happens (the game isn't launched).

Blindly trying out any and all combinations of UsesFNamePool, IsUsingFChunkedFixedUObjectArray, IsUsingDeferedSpawn doesn't seem to change anything (other than the log saying "FoundNamePool: 0x00007FF6D1DD5480" instead of "GName: 0x00007FF6D1DEA890" when using UsesFNamePool=1).

Setting IsFunctionPatterns=1 causes the hooking of InitGameState, BeginPlay and Say to fail, though the program does allow the game to be launched.

So at this point I am infinitely more lost than before, where I at least had some idea of what I needed to progress. It's greatly demotivating.

Mythical-Github commented 3 years ago

I am also interested in the process of this, I know that I need to find offsets and such, but looking at these profiles, they are all different, how does one know which ones are necessary?

Mythical-Github commented 3 years ago

Found your youtube videos on it, somehow missed those, thanks for all your hard work

RussellJerome commented 3 years ago

I apologize for the late response, I got no notification that an issue was added so I never even got a to see this. I have been working on V2 for a few months now which should automatically find everything for you. I will also be making multiple docs and tutorials soon on the loader, .profiles, everything. Feel free to hmu on discord (Russell.J#7723) if you want me to help you 1 on 1 with the issues you are all facing. Again I really apologize for the delayed response.

s0renbjerg commented 3 years ago

I should apologize as well. After Mythical's post I searched for and found your YouTube videos as well, which were very helpful and helped me get a better grasp on the situation, correct my GName offset (which is actually FNamePool, so I flagged that setting too), and eventually I managed to piece together a working profile (also turned out I had to increase my function offsets from 6 to 7 digits), but I didn't post an update here.

I'm still banging my head a bit against a wall, with trying to figure out how to do what I want with my mod, but that's no fault of this great project :).

RussellJerome commented 3 years ago

V2 along with full docs and video tutorials on things will be out between Friday - Monday, in the meantime I recommend this tutorial for Ghost runner, it the best explanation atm for some modloader stuff :) https://github.com/Dmgvol/GR_Guides/blob/main/ModLoaderExample.md