精易论坛

标题: 求助c#代码实现汇编 [打印本页]

作者: FanLi    时间: 2024-4-12 16:48
标题: 求助c#代码实现汇编
易语言中是:
置入代码 ({ 86, 190, 15, 0, 0, 0, 141, 77, 8, 141, 76, 241, 252, 139, 65, 4, 133, 192, 116, 2, 255, 49, 78, 131, 233, 8, 133, 246, 117, 239, 255, 85, 8, 94, 201, 194, 124, 0 })
转成汇编代码是这样:
push esi
mov esi, 0x0000000F
lea ecx, dword [ebp+0x08]
lea ecx, dword [ecx+esi*8-0x04]
label1:
mov eax, dword [ecx+0x04]
test eax, eax
je label2
push dword [ecx]
label2:
dec esi
sub ecx, 0x08
test esi, esi
jne label1
call dword [ebp+0x08]
pop esi
leave
retn 0x007C
求助各位大佬,能不能用c#写个例子实现这个代码。
谢谢各位大佬。


作者: 8881020    时间: 2024-4-12 17:04
C# 最简单就是易语言写一个DLL然后C#调用
作者: gezixiangfei    时间: 2024-4-12 17:27
8881020 发表于 2024-4-12 17:04
C# 最简单就是易语言写一个DLL然后C#调用

我就是这样,可是只能32的
作者: 24124    时间: 2024-4-12 17:30
int sum(int a, int b) {
    int result;
    __asm {
        mov eax, a
        add eax, b
        mov result, eax
    }
    return result;
}

    static void Main(string[] args)
    {
        int a = 10;
        int b = 20;
        int result = sum(a, b);
        Console.WriteLine($"Sum of {a} and {b} is {result}");
    }
作者: FanLi    时间: 2024-4-12 17:40
24124 发表于 2024-4-12 17:30
int sum(int a, int b) {
    int result;
    __asm {

大佬,c#支持asm吗
作者: 果心豆腐酱    时间: 2024-4-12 17:44
我页不知道能不能用,翻译的


[C#] 纯文本查看 复制代码
using System;

class Program
{
    static void Main(string[] args)
    {
        int[] code = { 86, 190, 15, 0, 0, 0, 141, 77, 8, 141, 76, 241, 252, 139, 65, 4, 133, 192, 116, 2, 255, 49, 78, 131, 233, 8, 133, 246, 117, 239, 255, 85, 8, 94, 201, 194, 124, 0 };
        ExecuteAssemblyCode(code);
    }

    static void ExecuteAssemblyCode(int[] code)
    {
        int esi = 0x0000000F;
        int ebp = 0; // Assuming ebp is a base pointer

        int ecx = ebp + 0x08 + esi * 8 - 0x04;

    label1:
        int eax = BitConverter.ToInt32(code, ecx + 0x04);
        if (eax != 0)
        {
            // Push dword [ecx]
            // Assuming dword [ecx] is an integer in the code array
            int value = BitConverter.ToInt32(code, ecx);
            // Perform whatever operation you need with 'value'
            Console.WriteLine(value);
        }

        esi--;
        ecx -= 0x08;

        if (esi != 0)
            goto label1;

        // Call dword [ebp+0x08]
        // Assuming ebp+0x08 contains the address of a function to call
        CallFunction(code, ebp + 0x08);
    }

    static void CallFunction(int[] code, int address)
    {
        // Implement calling the function at the specified address
        // This part depends on how functions are called in your C# environment
        // You may need to use delegates or other mechanisms to call the function
        Console.WriteLine("Calling function at address: " + address);
    }
}

作者: 果心豆腐酱    时间: 2024-4-12 17:45
我页不知道能不能用,翻译的


[C#] 纯文本查看 复制代码
using System;

class Program
{
    static void Main(string[] args)
    {
        int[] code = { 86, 190, 15, 0, 0, 0, 141, 77, 8, 141, 76, 241, 252, 139, 65, 4, 133, 192, 116, 2, 255, 49, 78, 131, 233, 8, 133, 246, 117, 239, 255, 85, 8, 94, 201, 194, 124, 0 };
        ExecuteAssemblyCode(code);
    }

    static void ExecuteAssemblyCode(int[] code)
    {
        int esi = 0x0000000F;
        int ebp = 0; // Assuming ebp is a base pointer

        int ecx = ebp + 0x08 + esi * 8 - 0x04;

    label1:
        int eax = BitConverter.ToInt32(code, ecx + 0x04);
        if (eax != 0)
        {
            // Push dword [ecx]
            // Assuming dword [ecx] is an integer in the code array
            int value = BitConverter.ToInt32(code, ecx);
            // Perform whatever operation you need with 'value'
            Console.WriteLine(value);
        }

        esi--;
        ecx -= 0x08;

        if (esi != 0)
            goto label1;

        // Call dword [ebp+0x08]
        // Assuming ebp+0x08 contains the address of a function to call
        CallFunction(code, ebp + 0x08);
    }

    static void CallFunction(int[] code, int address)
    {
        // Implement calling the function at the specified address
        // This part depends on how functions are called in your C# environment
        // You may need to use delegates or other mechanisms to call the function
        Console.WriteLine("Calling function at address: " + address);
    }
}

作者: 尛龍科技    时间: 2024-4-12 18:02

[C#] 纯文本查看 复制代码
using System;

class Program
{
    static void Main()
    {
        int[] array = new int[15];
        
        for (int i = 0; i < array.Length; i++)
        {
            array = i + 1;
        }
        

        for (int i = 0; i < array.Length; i++)
        {
            if (array != 0)
            {
                Console.WriteLine(array);
            }
            else
            {
                break;
            }
        }
        
        CallFunction();
    }
   
    static void CallFunction()
    {
        Console.WriteLine("Function called.");
    }
}





欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4