r/howdidtheycodeit • • May 30 '23

Question How are unofficial modding software made without access to code bases?

Modding software that typically takes protected assets (like Valves's .vpk files), extracts them to textures, models, other random files that are usuable. These files are then modified and then reinjected (probably the opposite of the extract functions) into the protected files.

40 Upvotes

12 comments sorted by

View all comments

Show parent comment

18

u/AdarTan May 30 '23

With Unity-made games and like, it's quite simple as all the source code is readily available and is quite easy to read (albeit sometimes obfuscated to some degree).

That's not really the case. What is actually happening is that the Common Intermediate Language (CIL) that Unity C# code gets compiled to has some very good decompilers and that the C# code plugs into the rest of Unity in well understood ways.

13

u/-manabreak May 30 '23

Well, yes, it's bytecode, but it's really simple to convert back to source code that's quite similar to the original source code.

3

u/heyheyhey27 May 30 '23

The more precise answer is that c# code is (usually) only half-compiled, and the other half of the work is done as the program is running. Which means you don't have to do nearly as much work to "decompile".

1

u/Katniss218 Jun 23 '23

An even more precise answer is that it gets compiled twice. Once by roslyn, and then once more by the JIT.

1

u/Some_Tiny_Dragon May 31 '23

I've actually seen a lot of people get terrified of decompiles because they think that even comments will get seen.

It gets scrubbed and lightly optimized. To my knowledge: variables and methods lose their names and would become harder to understand when decompiled.

1

u/MCWizardYT Jul 09 '23

In default C# and Java compilers, methods and classes do not lose their names (same with variables, parameters, etc) but it is possible to scrub this info via an obfuscator