flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > win32ax.inc powerful macro basic to advance guide

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 12801
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 02 Aug 2011, 22:47
well, like title, am thinking of a list of source code samples that shows directly how to "use" those powerful macros in this thread, hopefully it would be a one-stop resource for everybody.
Post 02 Aug 2011, 22:47
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12801
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 02 Aug 2011, 22:48
how win32ax.inc looks like
Code:
include '%fasminc%\win32ax.inc'

TITLE_TO_FIND equ 'Untitled - Notepad'

proc start
      invoke  PostMessage, <invoke FindWindow, NULL, TITLE_TO_FIND>, WM_CLOSE, 0, 0
      invoke  ExitProcess, 0
endp

.end start
    

based on post 132212 by LocoDelAssembly,
Post 02 Aug 2011, 22:48
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12801
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 02 Aug 2011, 23:29
how to add extra library .dll under win32ax.inc
thanks to LocoDelAssembly, revolution & edfed.
Code:
format PE console 4.0
include '%fasminc%\WIN32AX.INC'

.code
start:
        cinvoke printf, hello
        invoke  ExitProcess,0

.data
hello db "hello world!"

section '.idata' import data readable writeable
library kernel32, 'kernel32.dll',\
                msvcrt, 'msvcrt.dll'

include '%fasminc%\API\kernel32.inc'
import msvcrt, printf, 'printf' 
    


Last edited by sleepsleep on 03 Aug 2011, 18:36; edited 4 times in total
Post 02 Aug 2011, 23:29
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12801
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 02 Aug 2011, 23:30
.if
.endif
example
Post 02 Aug 2011, 23:30
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Aug 2011, 14:47
The "won't work" example the problem you have is that the ".end" macro already built the import table, so "library" and "import" macros won't work.
Post 03 Aug 2011, 14:47
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 12801
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 03 Aug 2011, 16:53
i change it to be like this,
assembled but crashed.
Code:
include '%fasminc%\WIN32AX.INC'

.code
start:
  cinvoke printf, hello
       invoke  ExitProcess,0

.data
hello db "hello world!"

library  msvcrt, 'msvcrt.dll', \
          kernel32, 'kernel32.dll'
import msvcrt, printf, 'printf'
include '%fasminc%\API\kernel32.inc'
    


this display what intended
Code:
format PE console 4.0
include '%fasminc%\WIN32AX.INC'

.code
start:
      cinvoke printf, hello
       invoke  ExitProcess,0

.data
hello db "hello world!"

section '.idata' import data readable writeable
library     kernel32, 'kernel32.dll',\
               msvcrt, 'msvcrt.dll'

include '%fasminc%\API\kernel32.inc'
import msvcrt, printf, 'printf'
    


but does this mean, when user start using etc DLLs, they must code their idata section on their own?
Post 03 Aug 2011, 16:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20339
Location: In your JS exploiting you and your system
revolution 03 Aug 2011, 16:57
The current import and library macros cannot be extended. If you want to add more imports then currently you must code a custom section.

I did write some macros for this some time ago. libraryonce and some others. Perhaps the search will find them?
Post 03 Aug 2011, 16:57
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.