WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Pages (2) [1] 2   ( Go to first unread post )

I need a little FASM help :), Needing help in learning assembler without macros.

Jesse
Quote Post


New Member
*

Group: Members
Posts: 3
Member No.: 34163
Joined: 25-April 10


Hello ASMer's,

I'm new here and just starting out with ASM, so please forgive me if I sound noobish because......I am lol smile.gif. For my first trek into assembly I decided to use FASM because I heard it's very easy to learn (and it seems to be), but I have two questions and I hope someone can help. I decided to try and use the ShellExecute and ExitProcess API's to open the Google website. Here is my code:

CODE
format PE GUI
entry start
include "win32ax.inc"

section '.code' code import writeable readable executable

library shell32,"SHELL32.DLL",\
kernel32,"KERNEL32.DLL"

import shell32,  ShellExecute,      "ShellExecuteA"
import kernel32, ExitProcess,      "ExitProcess"

start:
invoke ShellExecute,0,0,_URL,0,0,SW_SHOW
invoke ExitProcess,0

_URL db "http://www.google.com",0


Now I have no problems with it, because it seems to work perfectly. What I wanted to ask you pros is, how can I use those two API's in FASM without using macros? I have a hard time with understanding how to push the arguments in pure assembly and just wanted to know the easiest way to do it. I get a bit confused with "mov eax" or "push eax". I just wanted an example if no one minded smile.gif

Also, I have been trying to have FASM give me COFF file output with my code and not having any luck with it. I get an error using "format MS COFF". It says something is wrong with "entry point" and I'm not sure what that means.

Sorry if I am making you read too much, but those are the only two things I need help with. Any help is greatly appreciated because I really want to learn this. Thank you all so much for your time! smile.gif

Jesse

PMEmail Poster
Top
ragdog
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 873
Member No.: 5019
Joined: 13-May 07


Hi

You mean with call and push...?

If correct load your app in olly and you see all without macros
PMUsers Website
Top
Jesse
Quote Post


New Member
*

Group: Members
Posts: 3
Member No.: 34163
Joined: 25-April 10


Hi ragdog smile.gif

Thank you for your response. Yes that is what I was meaning. Here is what Olly says about my code:

CODE
PUSH 5                                  ; IsShown = 5
PUSH 0                                  ; DefDir = NULL
PUSH 0                                  ; Parameters = NULL
PUSH 1.004010B1                         ; FileName = "http://www.google.com"
PUSH 0                                  ; Operation = NULL
PUSH 0                                  ; hWnd = NULL
CALL DWORD PTR DS:[<&SHELL32.ShellExecut>; ShellExecuteA
PUSH 0                                  ; ExitCode = 0
CALL DWORD PTR DS:[<&KERNEL32.ExitProces>; ExitProcess



The problem I have is with "PUSH 1.004010B1" and the two calls for Shellexecute and ExitProcess. I don't think if I put the assembly code as is in FASM, it would compile. Could I use the memory address of the two calls to make it work? like "call eax, 0x7ca0fe44"? If I can do that, all I need now is to figure out how to push the filename parameter correctly.

I'm just trying to figure out how to write it all correctly with the pushes and the calls. I thank you so much for the help so far! smile.gif

Jesse
PMEmail Poster
Top
creeper_coder
Quote Post


New Member
*

Group: Members
Posts: 3
Member No.: 34137
Joined: 23-April 10


you see push in olly,thats what you need to do push param from >> to << as for the string you need to push its address (pointer to it),then after that call the proc you should follow the address further you will see that those parameters and popped,so function can receive them properly and to get cleaned from the stack.
PMEmail Poster
Top
ragdog
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 873
Member No.: 5019
Joined: 13-May 07


CODE

.data
FileName = "http://www.google.com",0
.code
start:

PUSH 5                                ; SW_SHOW = 5
PUSH 0                                ; DefDir = NULL
PUSH 0                                ; Parameters = NULL
PUSH Offset  FileName            ; FileName = "http://www.google.com"
PUSH 0                                ; Operation = NULL
PUSH 0                                ; hWnd = NULL
CALL ShellExecute
PUSH 0                                ; ExitCode = 0
CALL ExitProcess
end start


Now compile it

U must change this "end start " to fasm
PMUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages (2) [1] 2  Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google