flat assembler
Message board for the users of flat assembler.

Index > Windows > Concenating Strings

Thread Post new topic Reply to topic

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 Very Happy ) 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_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

        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
        or      eax,eax
        jz      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
        invoke  SetWindowPos,[hwnddlg],HWND_TOPMOST,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE
        jmp     processed
        mov     eax,[wparam]
        and     eax,0FFFFh
        cmp     eax,ID_SEND
        je      send
        cmp     eax,ID_CLEAR
        je      clear
        jmp     processed
                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
                invoke SetDlgItemText,[hwnddlg],ID_USERNAME,""
                invoke SetDlgItemText,[hwnddlg],ID_MESSAGE,""
        jmp     processed
        invoke  EndDialog,[hwnddlg],0
        mov     eax,1
        pop     edi esi ebx

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',\
  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
  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 'STATIC','Created By Callum Lamb',-1,54,46,100,9,WS_VISIBLE

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.
Post 03 Jan 2006, 12:59
View user's profile Send private message MSN Messenger Reply with quote

Joined: 12 May 2005
Posts: 29
Check _snprintf in msvcrt.dll
Post 03 Jan 2006, 18:44
View user's profile Send private message Reply with quote

Joined: 13 Sep 2005
Posts: 19
Location: Siberia
Look for lstrcat in MSDN. But GetUserName and GetDlgItemText return the number of characters copied, so it's very easy to concatenate them without strcat(). Just add the returned length to the pointer: you will get the pointer to the end of the string. Then copy the next string to this location.
Post 04 Jan 2006, 11:54
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 GitHub, YouTube, Twitter.

Website powered by rwasa.