.386
.model flat,stdcall
option casemap:none
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
include \masm32\include\shell32.inc
includelib \masm32\lib\shell32.lib
.data
string db "user0 whjJGXajAqpRMN hex:77686a4a4758616a417170524d4e",0ah
db "test RY3FETU<notfound> hex:52593346455455<notfound>",0ah
db "test3 TY65DDQ<notfound> hex:52556654165165<notfound>",0ah,0
.code
start:
invoke StdOut,addr string
lea esi,string
mov edi, esi ; set pointer to string start
xor ecx, ecx ; reset ecx
dec ecx ; dec wraps ecx to 0xFFFFFFFF, since 'repne scasb' decriments ecx
mov eax, 0ah ; the byte to search for ('\n' newline)
;; after this executes [edi] will point to the byte after '\n' is encountered
repne scasb ; decriment ECX and incriment EDI until AL is encountered
mov byte ptr [edi], 00h ; terminate the string
invoke StdOut,esi ; esi now holds the user0 string
;at this point i want to loop and get the strings of test and test3 to push to StdOut
invoke ExitProcess,0
end start
figured it out :U
.data
string db "user0 whjJGXajAqpRMN hex:77686a4a4758616a417170524d4e",0ah
db "test RY3FETU<notfound> hex:52593346455455<notfound>",0ah
db "test3 TY65DDQ<notfound> hex:52556654165165<notfound>",0ah,0
.code
start:
lea esi,string
mov edi, esi ; set pointer to string start
invoke lstrlen,esi ;get the length of the string
mov ecx,eax ;store the length in ecx
loops:
test ecx,ecx ; see if the length is 0
jz done ;if it is then were at the end of the string
mov eax, 0ah ; the byte to search for ('\n' newline)
repne scasb ; decriment ECX and incriment EDI until AL is encountered
mov byte ptr [edi-1], 00h ; terminate the string right before the \n
push ecx
invoke StdOut,esi ; esi now holds the user0 string so we output it to screen
pop ecx
mov esi,edi ;store the new string pointer
jmp loops
done:
invoke ExitProcess,0
end start