CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    convert asm to c

    hi. i know u cant get the c or c++ source back from the program trough asm unless the source is compiled along.

    however i do look for a program that converts asm to C or C++.
    with olly dbg doesnt make much sense when you look at adress jumps instead of functions. especially when you havent made the program.

  2. #2
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128

    Re: convert asm to c

    It is not possible. You should be able to find more details from a previous thread discussing on reverse engineering in CG.
    quoted from C++ Coding Standards:

    KISS (Keep It Simple Software):
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.

    Avoid magic number:
    Programming isn't magic, so don't incant it.

  3. #3
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: convert asm to c

    maybe you dont read the forum im not talking about reverse engeneering.

    the applicationmight as well be made with vb classis or c#


    im talking about converting asm to c or C++

    and that is possible, i will just look for my selvei or maybe make it myselve.

  4. #4
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: convert asm to c

    here it is...

    http://boomerang.sourceforge.net/index.php

    but.

    This release is strictly for developers and experimenters, to get an idea of what Boomerang is about without having to download and compile a lot of code. Machine code decompilation, unlike Java/.NET decompilation, is still a very immature technology, so if you're hoping to decompile a large binary with this release you will be disappointed. Please read the documentation on the Boomerang web site.

  5. #5
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: convert asm to c

    i run the tool and it crashed...

  6. #6
    Join Date
    Sep 2005
    Location
    United States
    Posts
    799

    Re: convert asm to c

    maybe you dont read the forum im not talking about reverse engeneering.
    Why the hostility anytime you post something on the forums if the answer isn't what you expected? You do this in a lot of posts. Not nice.

    im talking about converting asm to c or C++
    We know. What Kheun was trying to say is that this cannot really be done.

    Sure, the tool you linked to might be able to somewhat do what you say, but it even says that it is still a very immature technology. The code generated won't be anywhere even near what the original source code looked like. So why even bother?

    and that is possible, i will just look for my selvei or maybe make it myselve.
    Fine, go look for it or write it yourself. If you are so sure of yourself, why bother posting on the forums then? All you do is get upset when someone tells you something you don't want to hear.
    Last edited by dcjr84; November 14th, 2006 at 09:09 PM.
    Please rate my post if you felt it was helpful

  7. #7
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    3,128

    Re: convert asm to c

    I have no doubt that it is reverse engineering. Let me put it this way. If you have the binaries or executable. It is very easy to reverse the opcode back into asm. However for converting asm back into C/C++, it is virtually impossible because the compiler can do many things to optimize your code such as reordering your code, etc. Code generated for switch-case switch can vary between situations even on the same compiler. In addition, different compilers generate code differently.
    quoted from C++ Coding Standards:

    KISS (Keep It Simple Software):
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.

    Avoid magic number:
    Programming isn't magic, so don't incant it.

  8. #8
    Join Date
    May 2005
    Posts
    399

    Re: convert asm to c

    Quote Originally Posted by Mitsukai
    maybe you dont read the forum im not talking about reverse engeneering.
    A better term for this would be decompilation
    Try some searches on this and see if you can find anything useful.

  9. #9
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: convert asm to c

    Quote Originally Posted by Kheun
    I have no doubt that it is reverse engineering. Let me put it this way. If you have the binaries or executable. It is very easy to reverse the opcode back into asm. However for converting asm back into C/C++, it is virtually impossible because the compiler can do many things to optimize your code such as reordering your code, etc. Code generated for switch-case switch can vary between situations even on the same compiler. In addition, different compilers generate code differently.

    o say again i dont want to go from asm to original. just from asm to c.

  10. #10
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: convert asm to c

    Asm to C is quite easy... It won't produce the original symbol information (which is the most useful thing to understand a program), nor the original statements.
    In fact, it can't help much somebody who knows assembly code.
    But it can help somebody who don't know assembly, but knows C.
    I won't name that a "decompiler". But a "compiler".
    It compiles asm to C.

    For example, it's possible to write such dump compiler which does things like converting
    Code:
    ; ...
    mov eax, ecx;
    add ecx, eax;
    mov edx,[esi]
    ; ...
    To
    Code:
    int main() {
    intptr_t eax, ecx, edx, ebx, esp, ebp, esi, edi;
    /* ... */
    eax=ecx;
    ecx+=eax;
    edx=*((int*)esi);
    /* ... */
    }
    However I admit that such dumb compiler don't help much... You can't understand the meaning of variables nor the global structure of programs.

    It's possible to write much smarter asm->C compiler, producing better looking statements, however I doubt it's possible to write something that makes things more understandable at global level... It's possible at local level...
    Unfortunately, this is exactly what humans are good at too. Locally understanding assembly code is very easy... Understanding a global program is tough and requires much time.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  11. #11
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: convert asm to c

    gotta love you koko, you are always the one who understand me.

    i have this program i disambled with ollydbg. i need to figure out how it connects to a certain server. however it is hard to figure out the program flow for me, when a function is called i only see the module name and the function adress. like user32.35645 for ex. but if it was to be compiled into C would say for ex GetModuleHandle.

    for ex this would output:

    Code:
    int main(void); //<ModuleEntryPoint>
    void Func1(int&); // adress 145345
    
    int main(void)
    {
     void* Local1;
     Func1(&local1);
    }
    
    void Func1(int& Param1)
    {
     Param1 = 2134;
    }
    just for a simple example. this would help me understand the program flow alot.
    then if u get more into it and make it more advanced you can determine if the register is a string and make a std::string localX instead of void* and compile it into C++

  12. #12
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: convert asm to c

    Quote Originally Posted by Mitsukai


    i have this program i disambled with ollydbg. i need to figure out how it connects to a certain server. however it is hard to figure out the program flow for me, when a function is called i only see the module name and the function adress. like user32.35645 for ex. but if it was to be compiled into C would say for ex GetModuleHandle.
    w32dasm does this work for you.
    Yes, there exists "assembly disassembler".
    And, yes, it's useful.

    Note also that asm->C compilers can seriously increase the understanding speed (perhaps by 3, 4 or more) of the reader, because, even local understanding, when reading assembly code, take some time.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  13. #13
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: convert asm to c

    yes you are completly right koko. i really understand 1% of what is happening, maybe a simple exe i would understand but wen it gets bigger, it is completly chaos. thats why they invented higher level prorgamming in the first place i think

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured