Recommendation on win32 assembly reader - winapi

I'm a beginner to reading assembly language and I'm looking for a good assembly reader for win32, which one do you recommend?

You are much better off writing your own assembly code, best way to learn. But you can get reams of inscrutable assembly code from dumpbin.exe /disasm or IDA Pro.

Related

Is there a way to step through Rust code with the asm it compiled to in vscode?

Decades ago I learned a lot about C, C++, and assembly by looking at the compiled code in the debugger interleaved with the assembly.
I'm now learning Rust on a new M1 Mac and want to do the same thing. I especially want to learn about how well the zero-cost abstractions work. But I'm not proficient at Rust or ARM assembly.
I'm using VSCode and I can't find any way to see the Rust and assembly interleaved like I used to back in the day on my Amiga and 486 PC.
By Googling I can find ways to get rustc to generate the asm, but it's without the Rust code and very hard to follow, especially in an asm dialect I don't yet know.
I know I can see Rust and the asm it compiles to side-by-side on Godbolt, and that's great. But I want to see the code for my whole app and step through it. Is that possible these days?

Where can i find code for a compiler?

So I am trying to make a small programming language as a project. But the thing is I have no clue how to begin. I know how a compiler works and all but don't know how the code would be written for it. I searched everywhere for example for the code of any compiler but couldn't find anything. Where would I find this, or could someone explain to me the format and method I should use for creating the compiler? Also if you were wondering I am thinking of using c++ for writing the compiler.
I recommend taking a free online course in Compiler Construction. Guided material and thoughtfully designed coursework is the best way to ease into this sort of thing, in my opinion.
LLVM.org; open source modern C, C++, Objective-C and more

How to convert machine code to assembly code?

Please suggest me How to convert machine code to assembly code? excluding intel reference manual and dos debugger method?
You can use any debugger, such as gdb, or any disassembler, such as IDA Pro Advanced.
There also are opensource ones, such as Agner Fog's objtool.
IDA Pro Advanced also has the Hexrays plugin, with which you can decompile code.
look at this thread :
How might I convert Intel 80386 Machine Code to Assembly Language?

toggle numlock with assembly

I need a simple program that toggles numlock key, to be written in assembly. I googled this problem and I found these pages:
Art of Assembly 1
Art of Assembly 2
but because of my little experience in assembly, they lead me to no where.
any idea and help appreciated.
If you don't mind using the Windows API, then look into the keybd_event function. I'm pretty sure you can call it from assembly. Just google how to do it. I have successfully used this function in VB.Net to toggle CAPS Lock. I have not programmed in Intel assembly language in about 8-9 years.
http://msdn.microsoft.com/en-us/library/ms646304(v=vs.85).aspx
Call SendInput. It's possible to call this from assembly, although much easier through a higher-level language. For instance, you could write the SendInput call in C, then call your C routine from assembly.

Win32 Low Level Assembly

do you know where I can find Windows Low Level Assembly examples programs?
I have some exemples using macros (NASM, MASM) but I want pure assembly, in order I can build a shellcode later.
Thanks a lot guys!
This tutorial might be usefull for you: winamtut
Also this topic in MASM forum is great too.
If your architeture is x64 so try this link too.
And finally if you're interested in some theory, maybe this link could be nice.
Doing Windows GUI stuff in assembly language is a lot of work. This is why the examples you've found use macros - it takes away some of the pain.
If you really want pure assembly language, a great way is to ask your compiler. Write some C code to call CreateWindow or whatever, and then generate an assembly listing from the compiler (or step through it with a debugger).
If by "pure assembly" you mean "not done as a macro or library" then this is what you have to do:
download the masm32 package
check through the copius amount of samples, there will be many using CreateWindow or CreateWindowEx
start your own program
link in windows.h
use the invoke macro to call CreateWindow or CreateWindowEx
if you don't want to use invoke then just push the parameters onto the stack and call the functions directly - as this is what invoke does for you anyway
You can also get lots of help using the MASM package from the masm forum.
The best way to really (and quickly) learn win32 assembly is to decompile simple win32 programs. You could download lena's reversing tutorials from tutsforyou.com. Alternative you could tryout the reverse me's from osix.net - they have some pretty straight forward programs for you to reverse, and the best part is you get to see the masm32 sourcecode after completing the level.
tools: ollydbg, masm32 etc.
books: win32 assembler coding by Goppit, the arteam's PE compendium, intel developers handbook
hxxp://osix.net
hxxp://tuts4you.com/download.php?list.17
hxxp://www.intel.com/products/processor/manuals/
I'm not very pleased with your "in order I can build a shellcode later." - it's stuff like that which gives assembly a bad name.
I'd suggesty you take a look at FASM instead of MASM, though, since it's "closer to the metal", and directly supports binary output.
For learning to build shellcode I would suggest creating a very simple c program that does what you want the shellcode to do and than disassemble that using IDA or Immunity (or whatever debugger / dissasembler that you are familiar with). Than you can see what the instructions are that are being used.
I would also recommend the following books:
Hacking: The Art of Exploitation (2nd Edition)
The Shellcoder's Handbook

Resources