calpol2004
Joined: 16 Dec 2004
Posts: 110
|
ive made a little messenger program for school it sends messages using the net.exe program (all it does is parse the information entered then lets net.exe do the dirty work ) it was originally made in C, and a few days ago i thought to optimize it (i got bored) i thought id rewrite it in ASM, ive done a little .com applications before (im a asm newbie) so i got the dialog application included in the examples which i got with fasm edited it and got a skeleton for my application and played around with it. and now ive got this:
format PE GUI 4.0
entry start
include '..\..\include\win32a.inc'
ID_USERNAME = 100
ID_MESSAGE = 101
ID_SEND = 102
ID_CLEAR = 103
section '.data' data readable writeable
flags dd ?
open db "open",0
net db "net",0
path db "send ",0
sender rb 21
username rb 21
message rb 450
length db 1
section '.code' code readable executable
start:
invoke GetModuleHandle,0
invoke DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
or eax,eax
jz exit
exit:
invoke ExitProcess,0
proc DialogProc hwnddlg,msg,wparam,lparam
push ebx esi edi
cmp [msg],WM_INITDIALOG
je wminitdialog
cmp [msg],WM_COMMAND
je wmcommand
cmp [msg],WM_CLOSE
je wmclose
xor eax,eax
jmp finish
wminitdialog:
invoke SetWindowPos,[hwnddlg],HWND_TOPMOST,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE
jmp processed
wmcommand:
mov eax,[wparam]
and eax,0FFFFh
cmp eax,ID_SEND
je send
cmp eax,ID_CLEAR
je clear
jmp processed
send:
invoke GetUserName,sender,length+20
invoke GetDlgItemText,[hwnddlg],ID_USERNAME,username,length+20
invoke GetDlgItemText,[hwnddlg],ID_MESSAGE,message,length+449
;last few lines of code here i need function to concenate strings.
invoke ShellExecute,[hwnddlg],open,net,path,0,SW_HIDE
jmp processed
clear:
invoke SetDlgItemText,[hwnddlg],ID_USERNAME,""
invoke SetDlgItemText,[hwnddlg],ID_MESSAGE,""
jmp processed
wmclose:
invoke EndDialog,[hwnddlg],0
processed:
mov eax,1
finish:
pop edi esi ebx
ret
endp
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',user,'USER32.DLL',shell,'SHELL32.DLL',advapi,'ADVAPI32.DLL'
import kernel,GetModuleHandle,'GetModuleHandleA',ExitProcess,'ExitProcess'
import user,DialogBoxParam,'DialogBoxParamA',GetDlgItemText,'GetDlgItemTextA',\
SetDlgItemText,'SetDlgItemTextA',MessageBox,'MessageBoxA',EndDialog,'EndDialog',\
SetWindowPos,'SetWindowPos'
import shell,ShellExecute,'ShellExecuteA'
import advapi,GetUserName,'GetUserNameA'
section '.rsrc' resource data readable
directory RT_DIALOG,dialogs
resource dialogs,37,LANG_ENGLISH+SUBLANG_DEFAULT,messager
dialog messager,'Messager',340,280,180,55,DS_MODALFRAME+DS_CENTER+WS_POPUP+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX
dialogitem 'EDIT','Insert Username Here',ID_USERNAME,2,5,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP
dialogitem 'EDIT','Insert Message Here',ID_MESSAGE,2,25,121,15,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL
dialogitem 'BUTTON','Send',ID_SEND,125,5,50,15,WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON
dialogitem 'BUTTON','Clear',ID_CLEAR,125,25,50,15,WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON
dialogitem 'STATIC','Created By Callum Lamb',-1,54,46,100,9,WS_VISIBLE
enddialog
ive just got to do a few more lines which are relatively simple i just need to concenate the label username to the end of the label path, then concenate a space then the variable sender then a colon then the label message. which in C would be a series of StrCat() functions however because im very new to asm i rly dont want to have to make my own macro to concenate strings and i cant find a function on msdn which i can import to concenate strings can anyone help?
also if anyone could see any faults with my code and point them out to me that would be very helpful.
|