Decompiling x86 PE binary to C? - decompiler

I'd like to know if there's any way to generate the C code of a x86 PE binary. I don't really need this, I just want to learn how some closed-source software are working.
From my common sense, I think the process is:
Converting the x86 binary to Assembly, which can be done with a disassembler like OllyDbg.
Converting this Assembly to C. I don't know any tools for that, any that's my question actually.

If you use IDA Pro with the HexRay decompiler you can get a somewhat readable C source code. (But prepare for a bunch of goto-s and unnecessary variables).

Related

How to check if x86 assembler AT&T code is ok?

I'm writing a small C compiler using SLY (python) and x86 AT&T syntax. I want to check if the code I'm generating is ok, because I don't know so much about this assembler language.
Some years ago I did something similar with MIPS32 and I used MARS to check if the code was correct.
Is there anything that I can use to check the code? Also, if you know any similar project it would be very useful.

Can I use a normal dll or another language package in Ada?

Currently I am using a hardware that provides me a software package that comes from a DLL. They also provide packages in different languages (Java, C++ and Python) with functions from the DLL, so I am programming my app in Java. I would like to change to Ada but I don't know the way to use the DLL functions or the packages that the company offer me in other languages. Is there a way to do it?
I know I can extract the function names from the DLL, but I don't exactly know how to convert that into an Ada package, or if I can use the packages already made in other languages in any way.
The lazy answer is simply "yes". :-)
The GCC documentation on the subject is here: https://gcc.gnu.org/onlinedocs/gnat_ugn/Using-DLLs-with-GNAT.html
As it says, you also need an Ada specification for the functions in the DLL, you want to use. You can either write it by hand, or use gcc -fdump-ada-spec on the C or C++ header files to have one generated automatically. The generated specifications are not always beautiful, but they are more likely to be correct than something you write from scratch yourself.

How to decompile an exe or a dll to assembly

I am really interested in assembly language and I want to learn about how exe files work how dlls run etc... and I have an idea of writing an application to decompile an exe to assembly code since i am not a very good assembly programmer and with the lack of knowledge of the inner working of exe I couldn't do it. Since I can read an exe in hex i think it is not impossible but I don't know how to write my own program. Any resources or any help would be appreciated.
I think you're looking for a disassembler not a decompiler. IDA pro seems to be popular and you can download an older version for free at http://www.hex-rays.com/idapro/idadownfreeware.htm
There are a lot of dissemblers already written for you (see above), but I don't think reading disassembled code is going to help you become a better assembly writer. The main reason for this is that compilers do A LOT of optimization before they generate assemblies. Often this makes for very tricky code to read but highly efficient code to analyze.
If you're interested in what a compiled program looks like at the a assembler level a much more meaningful approach would be compile and look at the generated assembly. For example with gcc/g++ this just requires gcc -c -S filename.c and will leave a clear text assembly file to look at.
Take a look at this Decompilation Wiki, I suspect it will answer most of your questions.

objective c on windows and gcc

Is the gnu objective c compiler for windows the same as the compiler for Mac OS X (and Ipad)?
I want to write some code on windows and run it on the mac and ipad, objective C seems to be the best way to go for the Mac/Ipad but is the gnu compiler the same? I know the libraries cocoa etc are not available but this is not an issue we'll be writing different interface code for each platform (please no comments about this is not the right way etc).
tia,
Dave
The compiler is more or less the same, but the runtime systems are different. If you don’t use the new features from Objective-C 2.0 your code should work fine with both runtime systems. If you want to use the new features you have to use a different runtime. You can find more information here on the GNUstepWiki.
But you still need a framework that provides basic objects like strings, arrays, dictionaries and so on. You could use this part from The Cocotron, a framework that tries to make all of Cocoa available on Windows, Linux and other platforms.

how to convert from matlab file to dll

I am using matlab 2009 -- I have .m file.
I want to convert it to dll file so i can use it in c++.
how can I do that, someone told me to use the matlab compiler and is it free?
First you need the compiler. Available from Mathworks here. Also, the compiler is not free for most people, a student version is available when bundled with other Mathworks products.
Mathworks provides a 'Free MATLAB Compiler Interactive Kit' which provides walkthroughs covering the DLL and executable build process.
Another option is to use MATLAB's C/C++ API to convert your source code to C++. All MATLAB's functions are accessible, but it's a pain to write this without good wrappers. It might be worth your while to purchase the compiler.