Category Archives: Assembler

Programming with FASM – test with CPUID .

First you need to take a look at this website.
The CPUID returns processor identification and feature information in the EAX, EBX, ECX, and EDX registers.
What the source code from my example do ?
First I start with the default assembly program .
The next step is to strat with reset xor eax,eax use cpuid.
The result of CPUID will be put into EBX.
Into section ‘.data’ data readable writeable make a structure named out_buffer.
The structure will be fill so you need to EBX, see example:
mov [out_buffer.vendor_ebx],ebx will give us “Genu”.
The next step for test EBX is this example:
test edx,00010000000000000000000000000000b
jz .NoHTT
mov [out_buffer.htt_arch4],’YES ‘
.NoHTT:

The structure of out_buffer is :
db ‘NoHTT’,2,9,’- ‘
.htt_arch4 dd ‘NO ‘
db 9,10

Because I used MessageBox to show us the out_buffer.
The result will be : No or Yes with the size of dd.
The db can define byte variables, as well as arrays of bytes.
Fasm documentation tell us: For example db 1,2,3 will define the three bytes of values 1, 2 and 3 respectively.
The dd has 4 bytes.
The result will be this text (the result is true so the text will be YES): “NoHTT – YES”.
Let’s see one screenshot:

This is the source code:

Posted in All, Assembler, Windows 10, Windows 7, Windows 8. Tagged with , , , , , .

Programming with FASM – Calendar Control.

I have not done a tutorial about the assembler programming language for a while, so today I had a good reason to write this tutorial.
The tutorial focuses on using Calendar Control (MSAA UI Element Reference).

The source code of the window made in fasm is used into this tutorial.
I added the window class name for a month calendar which is defined as SysMonthCal32.
The file if.inc is used for message selection.
When we close the program, a closing dialog is displayed.
To run the Go to today click is displayed but I did not implement execution code.
The IDD_DLG parameter is random and I put the year of my birth to be more fun.
The program contains comments to understand the source code.
For execution, you need to add it to the FASM editor and run it with the F9 key.
You also have the executable version in the Downloads section of the main page menu.

Posted in All, Assembler, Programming, Windows 10, Windows 7, Windows 8. Tagged with , , , , , .

Enables or disables privileges with fasm.

Today I will show you how to enables or disables privileges with fasm.
The Windows 10 come with Authorization and this is the right granted an individual to use the system and the data stored on it.
This is based on the Windows Server and Windows operating systems that control access to resources.
The example is a shutdown application tool make with FASM version 1.71.61.
I used functions from MSDN like: GetCurrentProcess, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivileges and CloseHandle.
This functions need to be fill with parameters.
For example the OpenProcessToken function need this parameters:

You can take a look at this function at MSDN website.
The base of assembly file come with include win32ax.inc file.
The ..\include\ let the fasm to get this file and use this functions.
The SE_PRIVILEGE_ENABLED set with 2 make the privilege enabled.
Also the TOKEN_ADJUST_PRIVILEGES is required to enable or disable the privileges in an access token.
This two is used to make the executable application.
Into .data area I put the data need by application – messages to show.
For example if I want to put a string into my application then I will use this:

The title_msg is used by application to take the string tool_shutdown_cmd and 0 is used to end the string into the application.
Also I need the SeShutdownPrivilege parameter required to shut down a local system..
The application will run into loop from .code to enable_privilege.
It start with .code start: show the window with message box make by MessageBox and ask us the option to shutdown or not.
IN this area will run some MSDN functions like: MessageBox, InitiateSystemShutdown and ExitProcess.
When the user will press the Yes button then the application will run the enable_privilege area.
The cmp, jne, jc and jmp is used to take decisions into application.
The invoke is used to invoke can be used to call the procedures through pointers defined in the import tables.
Example of this line:

is equivalent to:

The start: , exit: , fail: , enable_privilege: is used by fasm to know points of application.
The .end start is put to end the program of fasm language.
You have question about the fasm the take a look at fasm manual.

Posted in All, Assembler, Programming, Windows 10. Tagged with , , , , .

The SASM I.D.E. assembler for NASM, GAS, FASM and MASM.

The SimpleASM named SASM is a simple open source crossplatform IDE for NASM, MASM, GAS, FASM assembly languages and is working with Windows and Linux.
I tested the Windows version 3.8.0 with FASM x64 example and is working well.
Also I tested another FASM files from my projects area and also working great.
You need to add the FASM folder into SASM folder and this just to include all libraries of FASM.
You can use the help page by pressing the F1 key.
Also you need to check from Menu Page the Settings of your build project.
You can download it from here.
assembly

Posted in All, Assembler, Programming, Windows 10. Tagged with , , , , .

Assembly language x64: The System V ABI – part 001.

The System V Application Binary Interface named ABI defines a system interface for compiled application programs.
This System V Application Binary Interface is a set of specifications that detail calling conventions, object file formats, executable file formats, dynamic linking semantics, and much more.
The ABI defines a binary interface for application programs that are compiled for System V implementations on many different hardware architectures.
Also the System V ABI is a family of specifications composed of two basic parts:
– a generic part of the specification ( describes those parts of the interface that remain constant across all hardware implementations of System V;
– a processor-specific part ( the specification describes the parts of the specification that are specific to a particular processor architecture ).
Example:
Virtual addresses and file offsets for the 64-bit PowerPC processor family segments are congruent modulo 64
Kbytes (0x10000) or larger powers of 2. Although 4096 bytes is currently the 64-bit PowerPC page size, this
allows files to be suitable for paging even if implementations appear with larger page sizes. The value of the
p_align member of each program header in a shared object file must be 0x10000.
You need to put segments with different characteristics in separate 256 Mbyte portions of the address space, to give the operating system full paging flexibility in the 64-bit address space.
One example of an executable file (the program linked with a base address of 0x10000000):

The possible corresponding program header segments:

The memory image of virtual adress for the program above is shown here, assuming 4096 (0x1000) byte pages.

Documents about: System V ABI
TODO:Ensure whether these are the latest official links.

Posted in All, Assembler, Programming, Windows 10. Tagged with , , , .