O
O
Olegofr3n772020-10-30 18:07:23
assembler
Olegofr3n77, 2020-10-30 18:07:23

How to push a parameter onto the stack?

I decided to try to pee on FASM,
In kernel32.dll, there is a function (GetModuleFileNameA) that returns the path to the file
. I want to call it, for this I need to import the function on the stack, and then put the parameters?
How to do it?

format PE console

entry start

include 'win32a.inc'

section '.data' data readable writable

        NULL = 0

section '.code' code readable executable

        start:
                push NULL
                call [ExitProcess]

section '.idata' import data readable

        library kernel, 'kernel32.dll',\
                msvcrt, 'msvcrt.dll',\
                user32dll, 'user32.dll'

        import kernel,\
               ExitProcess, 'ExitProcess',\
               CreateDirectoryA, 'CreateDirectoryA',\
               GetModuleFileNameA, 'GetModuleFileNameA'

        import msvcrt,\
               printf, 'printf',\
               getch, '_getch'

        import user32dll,\
               MessageBoxA, 'MessageBoxA'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-10-31
@Olegofr3n77

You already have exactly the same situation with ExitProcess, and there is even code that does this:

push NULL
call [ExitProcess]

What's stopping you from doing the same?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question