Im just curious what register does lstrlen return in? Also can it count ascii in buffers?
It returns the lenght in eax and it counts the chars in your buffer until it reaches a 0.
:) JC
:) JC
So does that mean if the buffer is like 256 dup(?) then it will return all zeros after it counts the actual count of whats in the buffer?
Strings in memory are typically "null terminated", meaning at the end of the byte array there is a 0 to indicate termination.
myString db "Hello World", 0
myString has a length of 11. Strlen() scans the bytes, counting as it goes, and when it finds a 0 it stops counting.
myString db "Hello World", 0
myString has a length of 11. Strlen() scans the bytes, counting as it goes, and when it finds a 0 it stops counting.
oh okay. thanks for the explaination. Do you know of any thing (api etc) that can count what is inside a buffer. Like for example I put "Hello world" in a buffer (lets say this one: "mybuffer db 254 dup(?)"). Is there a way to get it to count and read out how many letters are in that buffer?
Originally posted by resistance_is_futile in thread lstrlen???
oh okay. thanks for the explaination. Do you know of any thing (api etc) that can count what is inside a buffer. Like for example I put "Hello world" in a buffer (lets say this one: "mybuffer db 254 dup(?)"). Is there a way to get it to count and read out how many letters are in that buffer?
oh okay. thanks for the explaination. Do you know of any thing (api etc) that can count what is inside a buffer. Like for example I put "Hello world" in a buffer (lets say this one: "mybuffer db 254 dup(?)"). Is there a way to get it to count and read out how many letters are in that buffer?
Yes, there's an api called lstrlen which does exactly that :grin:
lol
lol Umm this doesnt work:
How do I get it to print out how many characters are in Buffer?
invoke lstrlen,offset Buffer
invoke MessageBox,0,eax,0,0
How do I get it to print out how many characters are in Buffer?
Use a debugger to see what it returns. It will return a number in eax.
This number will not be in ascii format - so you can't show it inside a MessageBox.
You have to convert the number first using for example the function from masmlib dwtoa. (Dword to Ascii)
So:
This number will not be in ascii format - so you can't show it inside a MessageBox.
You have to convert the number first using for example the function from masmlib dwtoa. (Dword to Ascii)
So:
invoke lstrlen, ADDR Buffer
mov dword ptr [Buffer],0
mov dword ptr [Buffer+1],0
invoke dwtoa, eax, ADDR Buffer
invoke MessageBox, 0, ADDR Buffer, 0, 0
okay d00d thx a lot...