NASM Forum > Summer of Code Ideas

Direct output to PE32, PE64, DLL32 and DLL64 with Macro Sets

<< < (5/5)

encryptor256:

--- Quote from: nalsakas on July 19, 2015, 12:59:01 PM ---But why subtracting 8 bytes more crashes application?

sub rsp, 56 ---> NOT OK, crashes

--- End quote ---

Stack is not aligned and crashes.

Hey check this out: Stack alignment in x64 assembly

There is one: "vandale" individual who complains and one: "lurker" who explains.

EDIT:

--- Quote from: nalsakas on July 19, 2015, 12:59:01 PM ---Moreover putting extra alignment in Dlgproc also craches application.

DlgProc:
sub rsp, 32 ---> OK

sub rsp, 40 --> NOT OK

--- End quote ---

Yes! According to your prolog routine and later function calls, the number 32 is appropriate and stack will be aligned correctly, BUT 32+8 = 40 would ruin proper alignment.

Bryant Keller:
There are way too many things going on in this thread for me to go over every post, so I thought I would focus on the primary topic.


--- Quote from: nalsakas on May 24, 2015, 02:45:34 PM ---Request 1:

First is I need to test if a label is defined before or after the current test  location. I need a preprocessor directive,  something like %iflabel  /  %endif.
--- End quote ---

That one already exists. %ifid will tell you if an identifier is already defined.


--- Quote from: nalsakas on May 24, 2015, 02:45:34 PM ---Request 2:

I need to test if a single line macro defined after current line? %ifdef doesn't work in these situations.
--- End quote ---

This also, already exists. %ifmacro will tell you if a macro is currently defined.


--- Quote from: nalsakas on May 24, 2015, 02:45:34 PM ---Request 3:
I could get the last value of a single line macro (a %define statement). In order for me to fill in section table of pe file I need to know in advance how many sections are defined in pe file. I need to get last declared value of section number counter, each section increments the value by one.
--- End quote ---

To my knowledge, this one hasn't be implemented. But if you need to know how many sections are going to be used, why not ask the user. Add an operand to your PE macro that asks for the section count.

PE [type], [bits], [sections]
Usage:
PE EXE, 64, 5
PE DLL, 32, 2

HtH,
Bryant

nalsakas:
Hi Bryant,

Actually Request 2 isn't supported by nasm.

Below code block produces "something is defined". Because macro is defined before test.

--- Code: ---%define something 1

%ifdef something
%warning "something is defined"
%else
%warning "something isn't defined"
%endif

--- End code ---

Whereas following code block produces "something isn't defined". Because macro isn't defined before test.

--- Code: ---%ifdef something
%warning "something is defined"
%else
%warning "something isn't defined"
%endif

%define something 1

--- End code ---

Actually right now I don't need anything new from nasm. I made it work without future requests. PE macros works with current nasm and successfully produces PE32, PE64, DLL32 and DLL64 files using only nasm.

When I start to build PE macros I thought It would be fine to support multiple sections. But later I changed my mind. One section is enough for an executable. That way they become smaller.


regards

Navigation

[0] Message Index

[*] Previous page

Go to full version