this post was submitted on 01 Aug 2026
39 points (100.0% liked)

No Stupid Questions

49595 readers
619 users here now

No such thing. Ask away!

!nostupidquestions is a community dedicated to being helpful and answering each others' questions on various topics.

The rules for posting and commenting, besides the rules defined here for lemmy.world, are as follows:

Rules (interactive)


Rule 1- All posts must be legitimate questions. All post titles must include a question.

All posts must be legitimate questions, and all post titles must include a question. Questions that are joke or trolling questions, memes, song lyrics as title, etc. are not allowed here. See Rule 6 for all exceptions.



Rule 2- Your question subject cannot be illegal or NSFW material.

Your question subject cannot be illegal or NSFW material. You will be warned first, banned second.



Rule 3- Do not seek mental, medical and professional help here.

Do not seek mental, medical and professional help here. Breaking this rule will not get you or your post removed, but it will put you at risk, and possibly in danger.



Rule 4- No self promotion or upvote-farming of any kind.

That's it.



Rule 5- No baiting or sealioning or promoting an agenda.

Questions which, instead of being of an innocuous nature, are specifically intended (based on reports and in the opinion of our crack moderation team) to bait users into ideological wars on charged political topics will be removed and the authors warned - or banned - depending on severity.



Rule 6- Regarding META posts and joke questions.

Provided it is about the community itself, you may post non-question posts using the [META] tag on your post title.

On fridays, you are allowed to post meme and troll questions, on the condition that it's in text format only, and conforms with our other rules. These posts MUST include the [NSQ Friday] tag in their title.

If you post a serious question on friday and are looking only for legitimate answers, then please include the [Serious] tag on your post. Irrelevant replies will then be removed by moderators.



Rule 7- You can't intentionally annoy, mock, or harass other members.

If you intentionally annoy, mock, harass, or discriminate against any individual member, you will be removed.

Likewise, if you are a member, sympathiser or a resemblant of a movement that is known to largely hate, mock, discriminate against, and/or want to take lives of a group of people, and you were provably vocal about your hate, then you will be banned on sight.



Rule 8- All comments should try to stay relevant to their parent content.



Rule 9- Reposts from other platforms are not allowed.

Let everyone have their own content.



Rule 10- Majority of bots aren't allowed to participate here. This includes using AI responses and summaries.



Credits

Our breathtaking icon was bestowed upon us by @Cevilia!

The greatest banner of all time: by @TheOneWithTheHair!

founded 3 years ago
MODERATORS
 

I know some games will actually release modding tools, but if I had to guess I would think those are the exception, not the rule.

Thanks in advance!

you are viewing a single comment's thread
view the rest of the comments
[–] xan1242@lemmy.dbzer0.com 14 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

I do this quite a lot myself.

Beside the games that do officially support it via modding APIs, or older games that are just naturally extensible like Unreal Engine games that ship with an editor; it is usually done by the way of code injection.

Think of code injection like a manually placed interrupt - you modify the flow of execution at some point to execute your own code.

For this, you need something known as an entrypoint - place where mod code begins executing. Usually, at the entrypoint, the mod code bootstraps itself further.

To obtain an entrypoint, you have 2 options:

  1. On supported OSs, you can abuse dynamic library loading and make a library wrapper which masquerades as the original library. When its execution begins (on Windows this is usually very early in the importing stage, on Unix/Linux you need to swap functions), you can bootstrap your mod(s) further.
  2. On other systems (game consoles, embedded, etc), you have to modify the game executable directly. Either via the way of memory injection of another tool or direct binary modifications. Depending on the platform, if it supports loading of libraries, you would either load your mod as a library or, if not, inject the mod elsewhere into memory (slack/unused space).

How do you figure all of this mumbo-jumbo out? Well, you use tools designed to disassemble the game binary into machine language. Most popular examples are IDA, Ghidra and Binary Ninja.

You usually won't have any information on what's what, but if you know a bit about code design of games, you come to realize that a lot of them follow similar principles/patterns (depending on the era and platform), so you can probably figure it out once you've seen a few games. Especially if the game is using the same game engines as others, then you can cross reference stuff.

However, if you're lucky, you can obtain something known as debugging symbols which have all of the information about the generated binary. Ideally, it'd be for your executable that you're working with directly, but if it's not, you can usually just cross reference it by either binary pattern matching or simple deduction (same execution flows, same data, etc). This will give you a nice map of where's what in your disassembler tool.

Thanks to standardization of binaries, ABIs (Application Binary Interfaces) usually allows you to match the types as they're defined originally and have them work directly in your bespoke code. This means, for example, that if a function takes 3 arguments, those 3 arguments will be passed in the same way (depending on its calling convention), so you can expect to receive them in your own code the same way. (This is what we call code reflection - you can reflect the game's types in your own code. If you're using the same compiler as the original, even better!)

And, ideally, you would be working with code directly and not with machine language, but some lower level stuff will need it inevitably.

Usually, in your mod source code, you would work with a library that is specifically designed for code injection. This is effectively a JIT compiler which emits machine code instructions which are needed to redirect the flow of execution to your own modded functions. (Usually is capable of memory editing and making branch instructions)

There are 2 ways to perform a code modification:

  1. Inlined code - this means you write your own code in the middle of another game function. Usually, this is done via lower level assembly and a branch instruction to put it in. Requires decent knowledge of the target CPU to use it (to not corrupt any stack or registers)
  2. High-level function hooks - this usually means that you interrupt a function call/branch with your own equivalent. Your equivalent function will have to do the job of the original usually, but depending on the case, you may replace it outright or simply pass the call onto the original function. Thanks to ABIs, this is possible.

With all of this being said, you need to have the knowledge being able to read machine language of CPUs. This isn't too difficult once you realize RISC CPUs are mostly very similar at a glance which helps out a lot.

But, in order to be able to read it, you have to first obtain it and, as we all know, DRMs, executable packers and anti-cheats/tampers protect this, so you may need to get your hands dirty a bit to bypass that (e.g. memory dumps). A lot of the same tricks that security researchers use in their rulebook apply to modding as well.

I hope I've explained enough. I'm aware I used a bunch of terms that may be foreign, so I hope you will get the gist at the very least.

[–] Azzu@leminal.space 1 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

As an extension to this, many games use interpreted languages, essentially another language before it gets made into machine language, which makes decompilation much more easy and readable since you're already working with a higher level programming interface.

Mostly with Unity games or games that use lua scripting.

[–] xan1242@lemmy.dbzer0.com 1 points 3 weeks ago

True. But even in this case, the same code injection logic can apply (depending on where you make the changes). The IL itself can simply be seen as yet another platform.

A great example is Android - you can patch the .dex class files with Lucky Patcher (in cases where apktool smali changes cannot help you).

IL obfuscations may also be worked around by patching the IL code directly too, which depends on the use case again.

The gist always is - carve out a space for your own code. No matter the language, a computer program is a computer program.