GetPointers()

The GetPointers() procedure is the only one we make public, the only one that would be visible to a dynamic or static linker, depending on the selected output target. The logic behind this procedure is primitive. It creates a structure (in this example, the structure is statically allocated), filled with the addresses of core procedures, and returns the address of this structure:

GetPointers:

if (ACTIVE_TARGET = TARGET_W32_OBJ) |
(ACTIVE_TARGET = TARGET_W32_DLL) |
(ACTIVE_TARGET = TARGET_L32_O)

push dword pointers
pop eax
mov [eax], dword f_set_data_pointer
mov [eax + 4], dword f_set_data_length
mov [eax + 8], dword f_encrypt
mov [eax + 12], dword f_decrypt
ret

else if (ACTIVE_TARGET = TARGET_W64_OBJ) |
(ACTIVE_TARGET = TARGET_W64_DLL) |
(ACTIVE_TARGET = TARGET_L64_O)

push rbx
mov rbx, pointers
mov rax, rbx
mov rbx, f_set_data_pointer
mov [rax], rbx
mov rbx, f_set_data_length
mov [rax + 8], rbx
mov rbx, f_encrypt
mov [rax + 16], rbx
mov rbx, f_decrypt
mov [rax + 24], rbx
pop rbx
ret

end if

Once all of the preceding procedures have been added to the main source file, you may safely compile it and see that an output of the selected output format is being generated. If you leave the target specified here, you should be able to see a 32-bit windows DLL being created.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset