User:Renamed user awfwvowjvwrvnwio/NASM in Win32

Programming with the Netwide Assembler (NASM) in Win32 meets several constraints:


 * NEVER use, because it makes linking very frustrating.
 * There are no structured programming constructs, contrary to MASM, used in many tutorials.
 * No include files are available with NASM.

Hello World!
This works using the Native API by locating a function named NtWriteFile in NTDLL, obtaining console handles (for example stdout) and writing "Hello, World!" to stdout.

This example has 862 lines of code, doing the following tasks:


 * Defining the program's entry point.
 * Obtaining handles for stdin, stdout and stderr.
 * Obtaining the environment variables pointer from the Process Environment Block.
 * Traversing executable module list to find NTDLL, by comparing Unicode strings.
 * Obtaining NTDLL's module information.
 * Performing a binary search on NTDLL's export table to search for NtWriteFile.
 * Implementing fputs and puts using the Native API
 * Defining the main function, writing "Hello, World!" to stdout.

Note fputs is protected against buffer overflows by using a cookie obtained by performing a bitwise exclusive or operation on the security cookie value and the frame pointer (EBP). No frame pointer omission is used, except in the cookie checker.