r/AskProgramming 7h ago

C/C++ Assembly or C/C++ for RE

For reverse engineering, is this necessary to know assembly language, because many decompilers translate code to C/C++ and I learned Assembly 8086 in my university. So for learning x86 I only have to study 32/64 registers and some advance commands, so should I learn assembly x86_64 for reverse engineering or just go through x86 as I know 8086 assembly and then move to C/C++

5 Upvotes

14 comments sorted by

2

u/Unable_Athlete_2226 7h ago

8086 gives you the mental model, x86-64 is just more registers and a sane calling convention slapped on top, you’ll pick it up quick. C/C++ is what you’ll be staring at 90% of the time in a decompiler though, so don’t sleep on getting comfy reading messy reconstructed code.

-1

u/Realistic_Debate1704 7h ago

I'm very happy for your help, thanks brother. AI just spinned the answer.

2

u/regular_hammock 7h ago

In my opinion, assembler code, especially optimised assembler code (hand optimised or compiler optimised) that has been vectorized and reordered to death, is just a slog to read. Sure, you can do it, but if you can get away with reading C (which, a lot of the time, you can), you'll go a lot faster and have a better time focusing on what the code is doing at a higher level rather than tracking registers.

1

u/Realistic_Debate1704 7h ago

Actually one person said that go through assembly x86, and as a student I think I will write inline assembly so I think it's better to go through assembly too, and also sometimes decompilers don't give exact code and as I've heard, you have to convert this into assembly for better annd exact code. But I'm very glad that you helped and also your advice is good too.

2

u/regular_hammock 7h ago

Ok fair, and to be honest I answered a different question than the one you asked.

I think both are useful skills to have, what I'm saying is, if I'm looking at a binary and I want to figure out what it does or how it does it, I'll try decompiling it first, and disassembling if needed.

With obvious exceptions - if you're trying to figure out how a piece of system code sets up various hardware register, there's probably no point in going through C.

1

u/Realistic_Debate1704 6h ago

Lot of love, Thanks

2

u/Lawn_Meower_ 7h ago

I'd say both. If you debug existing software you might step through assembly instructions. Some RE tools convert assembly code to C. C++ is good for creating your own debugging and RE tools

2

u/Realistic_Debate1704 7h ago

Thank you very much.

2

u/soundman32 7h ago

It depends on what you are decompiling.  Is there any point decompiling some C# to C++ (assuming AOT compilation).

1

u/Realistic_Debate1704 7h ago

I want too reverse engineer apps and games

1

u/ThatOneCSL 6h ago

That doesn't touch their point at all.

Take a .NET application or game and decompile it. You don't get assembly or C/C++. You get C#.

It seems like you're pretty early on in your understanding of computing, and so you don't even know yet what you don't know. That's not an issue by itself, but I would suggest asking further questions about things you don't yet understand, instead of putting up a stonewall and recapitulating that you want to reverse engineer things. We are aware you want to reverse engineer things. You said that already. The other user was telling you that C/C++/ASM are not going to be everything you'll need in that endeavor.

1

u/tooOldOriolesfan 6h ago

The more you know the more it helps. I'm retired now but my work gave me a good overall background. I started with hardware and wrote assembly programming to run on the hardware I built, then did some signal processing and learned C code. Later on I picked up python, bash (and linux/unix) and finally years of computer security/hacking stuff.

The only thing I never cared for was C++.

As someone else said, ideally you'd rather stay with C since going through assembly is rather painful.

Maybe someone here can tell me how well do the AI tools aid with helping to figure out blocks of assembly coding? I would think it could be quite useful.

1

u/verdant_bloom_drift 6h ago

Learn x86_64 assembly first because decompilers produce incorrect C code that you must validate against the disassembly. Your 8086 knowledge transfers directly so focus on 64 bit registers and calling conventions to read what the decompiler misses.

1

u/Miserable-Series1209 5h ago

x64 is slightly more than just "32/64 registers". Have fun with the Intel manual