flat assembler
Message board for the users of flat assembler.

Index > Windows > Help, problems with stings

Author
Thread Post new topic Reply to topic
||CyrUS||



Joined: 11 Mar 2006
Posts: 11
||CyrUS|| 02 Apr 2006, 14:18
Hi all, I want to do a function like strcat.

I want to do:



while ( strlen(str1) !=16 )
{
strcat(str1,string);
}

I just want to do a string with 16 chars and to put for example: AA in the lenght of this string his 16.

I've tried:

Code:
invoke  GetDlgItemText,[hwnddlg],IDC_EDIT1,name,16 
mov ecx,eax
        mov ebx,ecx
        xor esi,esi
  loop0:
        dec ecx
        cmp ecx,0
        jnz loop0
  loop1:
        mov al,[string+ecx+esi]
        cmp ecx,ebx
        ja loop0
        inc esi
        cmp esi,17
        jnz loop1   
    


but it doesn't work can you explain me why please?
Post 02 Apr 2006, 14:18
View user's profile Send private message Reply with quote
||CyrUS||



Joined: 11 Mar 2006
Posts: 11
||CyrUS|| 02 Apr 2006, 14:21
Quote:

I just want to do a string with 16 chars and to put for example: AA in the lenght of this string his 16.


I just want to do a string with 16 chars and to put for example: AA until the lenght of this string his 16.
Post 02 Apr 2006, 14:21
View user's profile Send private message Reply with quote
||CyrUS||



Joined: 11 Mar 2006
Posts: 11
||CyrUS|| 02 Apr 2006, 15:17
ok I've found but there is an other problem :

Code:
 format PE GUI 4.0
entry start

include 'win32a.inc'

section '.data' data readable writable

   IDC_EDIT1  = 1000

   name            db 40
   strtemp         db 16,0
   serial          db 17,0

   StrToGen        db '_r <()<1-Z2[l5,^',0

section '.code' code readable executable

  start:

        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,101,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:

         jmp processed
  wmcommand:
        cmp     [wparam],BN_CLICKED shl 16 + IDCANCEL
        je      wmclose
        cmp     [wparam],BN_CLICKED shl 16 + IDOK
        jne     processed
        invoke  GetDlgItemText,[hwnddlg],IDC_EDIT1,name,16
        mov ecx,eax
        mov ebx,ecx
        xor esi,esi
  loop0:
        dec ecx
        cmp ecx,0
        jnz loop0

  loop1:
        mov al,[name+ecx]
        mov byte [strtemp+esi],al
        cmp ecx,ebx
        inc ecx
        ja loop0
        inc esi
        cmp esi,17
        jnz loop1
        xor eax,eax
        xor ecx,ecx
        xor ebx,ebx
        xor esi,esi
        xor edx,edx
        mov ebx,19h
  loopsr:
        mov al,[strtemp+ecx]
        mov dl,[StrToGen+ecx]    ; doesn't move strtogen it moves strtemp.
        xor al,dl

        IDIV ebx
        add al,41
        mov [serial+ecx],al
        inc ecx
        cmp ecx,17
        jnz loopsr

        invoke MessageBox,HWND_DESKTOP,serial,serial,MB_OK
        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'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess',\
         CreateFile,'CreateFileA',\
         WriteFile,'WriteFile',\
         CloseHandle,'CloseHandle'
  import user,\
         DialogBoxParam,'DialogBoxParamA',\
         EndDialog,'EndDialog',\
         GetDlgItemText,'GetDlgItemTextA',\
         MessageBox,'MessageBoxA'

section '.rsrc' resource from 'C:\fasmw165\projects\falcon1\dlg.res' data readable     
Post 02 Apr 2006, 15:17
View user's profile Send private message Reply with quote
AsmER



Joined: 25 Mar 2006
Posts: 64
Location: England
AsmER 02 Apr 2006, 15:29
If I understand you good, you should try:

Code:
invoke  GetDlgItemText,[hwnddlg],IDC_EDIT1,name,16
MOV EDI, EAX     ; result of function call in EDI & EAX
XOR ECX, ECX    ; set ECX & ESI to zero
XOR ESI, ESI
Loop1:  ;FIND THE END OF RETUNED STRING
        CMP BYTE [ECX+EDI], 0h
        JE  Loop2 ; if('ret_str'[ecx] == 0) goto Loop2
        INC ECX   ; ECX++ // increase index
        JMP Loop1 ;repeat

Loop2:  ;ADD OTHER STRING TO STRING RETURNED BY GetDlgItemText
        CMP ECX, 10h        ;IF LETTERS COUNT IS EQUAL 16?
        JE  End_Loop2       ; goto End_Loop2
        MOV AL, BYTE [String+ESI] ;else AL = String[ESI];
        MOV BYTE [ECX+EDI], AL    ;ret_str[EDI] = AL
        INC ESI         ;ESI++ //increase index of String
        INC ECX         ;ECX++ //increase index of 'ret_str'
        JMP Loop2       ; repeat
End_Loop2:              ; Finished           


I hope it helped

_________________
;\\ http://theasmer.spaces.live.com \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Post 02 Apr 2006, 15:29
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 03 Apr 2006, 22:33
You could just use the lstrcat API call (its in kernel32.dll), considering you're using Windows.
P.S. It is not a C call!!!!!!
Post 03 Apr 2006, 22:33
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 03 Apr 2006, 23:46
UCM: well, it is C call adopted by windoze too. i believe you can find it in msvcrt.dll too.
Post 03 Apr 2006, 23:46
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY 03 Apr 2006, 23:53
lstrcat is from kernel32.dll
strcat is from msvcrt.dll

both work in the same way, but I think lstrcat is faster, 'coz strcat would be calling it anyway, I don't know...
Post 03 Apr 2006, 23:53
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 04 Apr 2006, 05:44
if you have a problem with stings, maybe you should stay away from scorpions Laughing (sorry Cool)

_________________
redghost.ca
Post 04 Apr 2006, 05:44
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 04 Apr 2006, 07:10
Here I Am
Rock You Like Hurricane

....

Babe, you 'r you'r
Dynamiiiiiiiiiiiiiiite
Post 04 Apr 2006, 07:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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.