Solved need to learn how to asm in C#

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

xkroxy

Newbie
May 27, 2016
4
32
0
i need to learn how to coded asm in C# i know how do that in cheat engine it's simple but i never coded asm out of cheat engine so i here to ask if there any tutorial how to write asm in C# i'll be grateful for that help guidedhacking<3

P.S. coded it such as
mov ecx, [ebp - 0x40]
mov[ecx + 0x08], 00000000
lea edx, [edx]
push edx
call addy
and not like bytes 0x88
 
Last edited:

Revester

Silenced
Full Member
Dec 31, 2019
27
203
0
You can use FASM.NET to write assembly and assemble machine code from it, but note that you need to use their syntax:
https://github.com/ZenLulz/Fasm.NET


So if Cheat Engine has this code:
Code:
game.exe+1A35B8 - fld dword ptr [esi+00000158]
game.exe+1A35BE - fmul dword ptr [game.exe+4E7610]
game.exe+1A35C4 - mov edx,[esi+00000158]
game.exe+1A35CA - mov eax,[esi+0000015C]
game.exe+1A35D0 - lea ecx,[esi+00000158]
game.exe+1A35D6 - mov [ebp-0C],edx
game.exe+1A35D9 - mov edx,[ecx+08]
game.exe+1A35DC - fstp dword ptr [ecx]
game.exe+1A35DE - fld dword ptr [ecx+04]
game.exe+1A35E1 - mov [ebp-08],eax
game.exe+1A35E4 - fmul dword ptr [game.exe+4E7610] { (1,00) }
You will need to get that to this syntax:
C#:
private void AssembleButton_OnClick(object sender, RoutedEventArgs e) {

            IntPtr gameModuleAddr = memoryCommander.GetModuleBaseAddress("game.exe");

            var fasm = new FasmNet();
            fasm.AddLine("fld dword [esi+0x00000158]");
            fasm.AddLine("fmul dword [{0}]", string.Format("0x{0:x16}", gameModuleAddr+0x4E7610));
            fasm.AddLine("mov edx,[esi+0x00000158]");
            fasm.AddLine("mov eax,[esi+0x0000015C]");
            fasm.AddLine("lea ecx,[esi+0x00000158]");
            fasm.AddLine("mov [ebp-0x0C],edx");
            fasm.AddLine("mov edx,[ecx+0x08]");
            fasm.AddLine("fstp dword [ecx]");
            fasm.AddLine("fld dword [ecx+0x04]");
            fasm.AddLine("mov [ebp-0x08],eax");
            fasm.AddLine("fmul dword [{0}]", string.Format("0x{0:x16}", gameModuleAddr+0x4E7610));

            byte[] machineCode = fasm.Assemble();
}
Unless there are some plugins for Cheat Engine or some debugger that shows assembly with FASM syntax during debugging. Would be pretty cool if you could copy-paste it and inject.
 
Last edited:
  • Like
Reactions: Rake

Revester

Silenced
Full Member
Dec 31, 2019
27
203
0
Ok I tried FASM. For whatever reason, it generates some wrong code: it inserts 67s, I don't know what's that about. Here's original code:
cheatengine-x86_64_W9tZgyBgaZ.png

D9 86 58 01 00 00 D8 0D 10 76 8E 00 8B 96 58 01 00 00 8B 86 5C 01 00 00 8D 8E 58 01 00 00 89 55 F4 8B 51 08 D9 19 D9 41 04 89 45 F8 D8 0D 10 76 8E 00
And here's code generated by FASM and injected with Jupiter:
cheatengine-x86_64_6LBOhr8wXe.png

67 D9 86 58 1 0 0 67 D8 D 36 63 33 9 67 66 8B 96 58 1 0 0 67 66 8B 86 5C 1 0 0 67 66 8D 8E 58 1 0 0 67 66 89 55 F4 67 66 8B 51 8 67 D9 19 67 D9 41 4 67 66 89 45 F8 67 D8 D 36 63 33 9

It inserts 67s in places and then generates whatever. Idk.
@Akaion, do you know anything that could make my life easier, so I don't have to work with machine code and write something adequate like this:
C#:
private void AssembleButton_OnClick(object sender, RoutedEventArgs e) {

            IntPtr gameModuleAddr = memoryCommander.GetModuleBaseAddress("game.exe");

            var fasm = new FasmNet();
            fasm.AddLine("fld dword [esi+0x00000158]");
            fasm.AddLine("fmul dword [{0}]", gameModuleAddr+0x4E7610);
            fasm.AddLine("mov edx,[esi+0x00000158]");
            fasm.AddLine("mov eax,[esi+0x0000015C]");
            fasm.AddLine("lea ecx,[esi+0x00000158]");
            fasm.AddLine("mov [ebp-0x0C],edx");
            fasm.AddLine("mov edx,[ecx+0x08]");
            fasm.AddLine("fstp dword [ecx]");
            fasm.AddLine("fld dword [ecx+0x04]");
            fasm.AddLine("mov [ebp-0x08],eax");
            fasm.AddLine("fmul dword [{0}]", gameModuleAddr+0x4E7610);

            byte[] machineCode = fasm.Assemble();
}
Some library that transforms assembly to machine code?
 
Last edited:

Akaion

Wizard
Meme Tier VIP
Trump Tier Donator
Oct 13, 2018
230
7,948
14
Ok I tried FASM. For whatever reason, it generates some wrong code: it inserts 67s, I don't know what's that about. Here's original code:
View attachment 8444
D9 86 58 01 00 00 D8 0D 10 76 8E 00 8B 96 58 01 00 00 8B 86 5C 01 00 00 8D 8E 58 01 00 00 89 55 F4 8B 51 08 D9 19 D9 41 04 89 45 F8 D8 0D 10 76 8E 00
And here's code generated by FASM and injected with Jupiter:
View attachment 8445
67 D9 86 58 1 0 0 67 D8 D 36 63 33 9 67 66 8B 96 58 1 0 0 67 66 8B 86 5C 1 0 0 67 66 8D 8E 58 1 0 0 67 66 89 55 F4 67 66 8B 51 8 67 D9 19 67 D9 41 4 67 66 89 45 F8 67 D8 D 36 63 33 9

It inserts 67s in places and then generates whatever. Idk.
@Akaion, do you know anything that could make my life easier, so I don't have to work with machine code and write something adequate like this:
C#:
private void AssembleButton_OnClick(object sender, RoutedEventArgs e) {

            IntPtr gameModuleAddr = memoryCommander.GetModuleBaseAddress("game.exe");

            var fasm = new FasmNet();
            fasm.AddLine("fld dword [esi+0x00000158]");
            fasm.AddLine("fmul dword [{0}]", gameModuleAddr+0x4E7610);
            fasm.AddLine("mov edx,[esi+0x00000158]");
            fasm.AddLine("mov eax,[esi+0x0000015C]");
            fasm.AddLine("lea ecx,[esi+0x00000158]");
            fasm.AddLine("mov [ebp-0x0C],edx");
            fasm.AddLine("mov edx,[ecx+0x08]");
            fasm.AddLine("fstp dword [ecx]");
            fasm.AddLine("fld dword [ecx+0x04]");
            fasm.AddLine("mov [ebp-0x08],eax");
            fasm.AddLine("fmul dword [{0}]", gameModuleAddr+0x4E7610);

            byte[] machineCode = fasm.Assemble();
}
Some library that transforms assembly to machine code?
Nothing public unfortunately. If you only need snippets of ASM consider just assembling externally and storing in C# as a byte array?
 
  • Like
Reactions: Revester

Revester

Silenced
Full Member
Dec 31, 2019
27
203
0
I haven't tried it, but before I forget I decided to post it here. Boys on UC.me recommended this iced library:
https://github.com/0xd4d/iced

And from what I read if I understood it correctly, that's what I was looking for back then. Going to try to use it later.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods