flat assembler
Message board for the users of flat assembler.

Index > Windows > new to FASM, need a little bit of help.

Author
Thread Post new topic Reply to topic
slovach



Joined: 14 May 2007
Posts: 4
slovach
some quick questions, which are in the code. trying to work out the kinks from MASM to this. thanks!

Code:
format PE GUI 4.0
include 'win32a.inc'
        invoke FindWindow, NULL, gameWindow
       ; if eax == 0
             invoke MessageBox,0, message, caption, MB_OK
       ; endif -- first problem, how exactly do the if macros work in FASM?
        invoke GetWindowThreadProcessId, eax, gamePID
        invoke OpenProcess, PROCESS_ALL_ACCESS, FALSE, gamePID
       ; mov gameProcess, eax -- this is the second problem, why can't i do this?

         invoke WriteProcessMemory, gameProcess, startAddress, patch, 6, NULL
         invoke WriteProcessMemory, gameProcess, startAddress, injection, 18, NULL

exit:
        invoke  ExitProcess, 0

gameWindow  db 'Minesweeper', 0
gamePID     db ?
gameProcess db ?
message    db 'failed', 0
caption    db 'test', 0


... unimportant stuff past this point    
Post 13 Oct 2007, 06:59
View user's profile Send private message Reply with quote
smoke



Joined: 16 Jan 2006
Posts: 42
smoke
you can do it like this:
Code:
format PE GUI 4.0 
include 'win32a.inc' 
         invoke FindWindow, NULL, gameWindow 
         test eax,eax
         jne @f
         invoke MessageBox,0, message, caption, MB_OK 
@@:
         invoke GetWindowThreadProcessId, eax, gamePID 
         invoke OpenProcess, PROCESS_ALL_ACCESS, FALSE, gamePID 
         mov dword[gameProcess],eax
         invoke WriteProcessMemory, gameProcess, startAddress, patch, 6, NULL 
         invoke WriteProcessMemory, gameProcess, startAddress, injection, 18, NULL 

exit: 
        invoke  ExitProcess, 0 

gameWindow  db 'Minesweeper', 0 
gamePID     db ? 
gameProcess db ? 
message    db 'failed', 0 
caption    db 'test', 0 
    


although you still need the import table Smile
Post 13 Oct 2007, 08:19
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 693
Location: Adelaide
sinsi
smoke wrote:

although you still need the import table Smile


Speaking as a long-time MASM/ML user this was one of the harder things to get used to, but once you get it then no worries.
I'm still exploring the win32*.inc files, but the level of control is 'sweet, mate' Very Happy

I am for sure a convert to FASM, especially FASMW. (seeya hutch...)


As for the trainer part,
Code:
         invoke GetWindowThreadProcessId, eax, gamePID  
         invoke OpenProcess, PROCESS_ALL_ACCESS, FALSE, gamePID
...
         gamePID     db ?  
    

needs to be
Code:
         invoke GetWindowThreadProcessId, eax, gamePID  ;<<<<<gamePID here is the address of a DWORD
         invoke OpenProcess, PROCESS_ALL_ACCESS, FALSE, [gamePID]  ;<<<<<<brackets denote contents not address
...
         gamePID     dd ?  ; <<<<<< dword not byte
    


Brackets/OFFSET was another hurdle for MASM->FASM
Post 13 Oct 2007, 08:52
View user's profile Send private message Reply with quote
slovach



Joined: 14 May 2007
Posts: 4
slovach
smoke wrote:
although you still need the import table Smile


Yeah I forgot to include that in my post since it was so late, but I had one. Smile I got everything working all dandy now, thanks fellas!
Post 13 Oct 2007, 16:15
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.