This is the simplest example of how to use assembly language to create a DLL file functional.

It is written using flat assembler (FASM).

An example is simple and I created for testing with python.

You can call the function created with other programming languages?.

After I created the DLL file can execute the following python code to check if it works correctly.

python dll

Let’s go to the DLL file creation.

The theory says about this example, show at the end of this tutorial:

format directive allows selecting the output format.

entry directive sets the entry point for Portable Executable, the value of the entry point should follow.

include directive includes the specified source file at the position where it is used and should be followed by the quoted name of a file that should be included.

section directive defines a new section, it should be followed by quoted string defining the name of the section, then one or more section arguments can follow.

Available arguments are code, data, readable, writeable, executable, shareable, discardable, notpageable.

A section is marked to contain fixups, they are generated automatically and no more data needs to be defined in this section.

In the section code, we define two procedures.

The first procedure allows a DLL to use its entry-point function for allocating memory in the virtual address space of the calling process or to open handles access to the process.

The second procedure will call a MessageBox function from the operating system, see more here.

data directive begins the definition of special PE data.

It should be followed by one of the data identifiers (export, import, resource or fixups) or by the number of data entry in PE header.

This example can be developed and completed with additional functions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.