Since the StrLen war has carm down for a whilei been using M32 Strlen and Jens Duttke 2nd smallest one.

Sometime one will work and the other don't in a given project in the SAME block of CODE. This is true...and i know what i am doing now...

Also one day i dumped my file and looked at it and for ONLY one string that i did a reverse ONLY once, cut off a piece, than turned it back around again and GUEST WHAT .... that string in my dumped file showed up more times than it was REVERSED. All over the place. ( i got more testing to do but i thought i should tell you Guys to be aware, because tomorrow i might for get...

I also had already mov Buffer1[0], 0 just after the operation so there was no reason to see more than one or two IF ANY reversted strings in my dumped files.

So I am sticking with M32 StrLen and Jen's VERY FIRST ONE and the 2nd smallest one if ALL ELSE FAIL....

As you build your app i think its a good idea to used difference styles and do some serious checking from time to time to see if the results underneath it all is true and acceptable.

Everybody got there own style of coding that why we all get difference strange results some time

BeWAre....Just in Case
Posted on 2002-03-25 04:11:45 by cmax
Could you please post some source code, wich produces this problem?
Posted on 2002-03-25 04:49:01 by bazik
The most reliable way to test a string length is to use a byte scanner as it does nothing fancy, it just scans until it finds a zero.

I exhaustively tested the version by Agner Fog that is in the masm32 library and it was reliable in all instances so I am not sure what is happening with the others.

Regards,

hutch@movsd.com
Posted on 2002-03-25 07:38:31 by hutch--
hi!

cmax, can you please post the code which make problems ?

I use my routine in some projects now, and it's already tested by some people, and nobody got any problem. And I am sure much more people used the routine which is included in hutch's MASM package without problems.

I am interested in it, what's the test-string, at which address is the test-string, how much memory have you allocated and how have you allocated the memory.

Maybe your string is langer than the allocated memory ?

Cu, Jens
----
http://www.emucheater.com
http://cyberpad.psxemu.com
Posted on 2002-03-25 08:33:46 by Jens Duttke
Jens Duttke

I use the First one that Hutch posted and the Last one that you posted ( the one with the minor changes ) and both are DAME good and fasters. I play with a lot of code as i build my app and found that M32 StrLen will not work when yours do... and via sa vir sa at times...

I do to much sh*t so i just want to say that they all have their place and that the programmmer should test them for themselfs when selecting for an CERTAIN block of code....

My Sh*t now is all based on protection and i can't show the stupit sh*t that i am doing right now or it will all be for nothing....

Give me a few weeks and i will put stuff together as i work and e-mail it to you because you and Hutch simply must know what i have founded. Right now i am on a ROLL and can't stop.

But mind you, my sh*t is BACKWARD so it may not be important anyway. But for people who do things differencly and don't know why sh*t went wrong than SIMPLY SWITCH LEN for that block of code ONLY. That's ALLLLLL.....

As i said i do a lot of Stupit Sh*t that workssss.

The regular programmer (doing things the right way) it will not give him stange results... only people like me get them because of the way we do things....BACKWARD sometime. So don't worry Just test the test until then...

excuse my lang

See ya

I will do this for you but i need time
Posted on 2002-03-25 18:56:29 by cmax

But mind you, my sh*t is BACKWARD

BACKWARD as in "weird a$$ code" or "std"? If it's the latter, always
"cld" after you're done...
Posted on 2002-03-25 19:04:32 by f0dder
f0dder

It's unbeleivable that you made since of what i did...

In that block of code i use StrLen first that a Reverse String added to it with other junk. And what you said, make me relize that it's not StrLen that cause my problem it's a the stuff i did AFTER it....

Sorry, Jens

I just got a big piece of bad coding. Thats a personal PROBLEM...Sorry Guys , I forgot it depend on what you doing and when you using stuff...


f0dder

it's "weird a$$ code" but i know how to fix it now....also i did not use std and stuff right...Thanks
Posted on 2002-03-26 03:26:29 by cmax
bAZiK

Sorry i did not see your reply, i was rushing and worried. I like your new logo.




.386
.model flat,stdcall
option casemap:none
WinMain proto :DWORD,:DWORD,:DWORD,:SWORD


include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\masm32.inc
include \MASM32\INCLUDE\gdi32.inc
include \MASM32\INCLUDE\user32.inc
include \MASM32\INCLUDE\kernel32.inc
includelib \MASM32\LIB\masm32.lib

includelib \MASM32\LIB\gdi32.lib
includelib \MASM32\LIB\user32.lib
includelib \MASM32\LIB\kernel32.lib


MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
Len2 PROTO :DWORD
wsprintfA PROTO C :DWORD,:VARARG
wsprintf equ <wsprintfA>

.data

String1 db "C:\Window\Notepad.exe",0


.data?


Buffer1 BYTE 128 dup(?)
Buffer2 BYTE 128 dup(?)
Buffer3 BYTE 128 dup(?)
Buffer4 BYTE 128 dup(?)
Buffer5 BYTE 128 dup(?)


.code
Main:

;.....; Copy the string To Buffer...Why...This is the way i want did
;.....; it in my app


mov esi, offset String1
mov edi, offset Buffer1
mov ecx, lengthof String1
rep movsb
; ...........................Jens StrLen Will not make it to Message box 3
; ...........................here, but in my app it Do. Switch and see
; ...........................Strange to me it don't work in this example
; ...........................It is the exact same way in my app but to
; ...........................get other words the same way....


; ..........................; M32 StrLen will get tMessage box 3
; ..........................; wrong with MY coding but that is not the
; ..........................; point just yet

mov ecx, offset Buffer1
@@:
mov eax, dword ptr
add ecx, 4
lea edx,
xor eax, edx
and eax, 80808080h
and eax, edx
jz @B
@@:
bsf edx, eax
lea eax, ; n
shr eax, 3
sub eax, offset Buffer1 ; n


; push offset Buffer1
; mov eax,eax
; lea edx,
; @@:
; mov ebx,
; add eax,128 ;; i have to put 128 here but i dont
;have to do that with Jens. His works
;;;;but in a few cases it sometimes the other way around....
; lea ecx,
; not ebx
; and ecx,ebx
; and ecx,80808080h
; jz @B
; test ecx,00008080h
; jnz @F
; shr ecx,16
; @@:
; shl cl,1
; sbb eax,edx
; pop ebx


;;invoke MessageBoxA, 0, offset Buffer1, 0, 0 ;MessageBox 1

; ...................................................... Part 1: Reverse String
push edi
mov ecx, offset Buffer1
lea edx,
lea ecx,
mov edi, offset Buffer2
@@:
mov al,
dec ecx
mov , al
inc edi
cmp ecx, edx
jne @B
mov byte ptr ,0
pop edi

invoke MessageBoxA, 0, offset Buffer2, 0, 0 ;MessageBox 2

; ............................................ Part 1: Cut Out .exe from String
lea esi, offset Buffer2
@@:
mov al, byte ptr
inc esi
cmp al, "\"
jne @B
lea edi, offset Buffer3 ; n
xor ecx, ecx

@@:
mov al, byte ptr
mov byte ptr , al
inc esi
inc edi
.if al == ':' ;n.. one of these is a facker just to get things to work
inc ecx
.endif
cmp ecx, SIZEOF Buffer2;;128 ; n
jne @B
xor edx,edx
xor ecx,edx
xor ebx,edx
xor eax,edx ;;;;;;;;; I don't know why these 4 line are here but i
;;;;;;;;;;;;;;;;;;;;;;;;;; had to do it some where to get it
;;;;;;;;;;;;;;;;;;;;;;;;;; to work when i first start trying to reverve
;;;;;;;;;;;;;;;;;;;;;;;;;; strings and stuff...It was stange too.


invoke MessageBoxA, 0, offset Buffer3, 0, 0 ;MessageBox 3

; .......................... Jens StrLen Round 2 GET Reverse String and
; .......................... Jens StrLen Round 2 GET Reverse String and
; .......................... Jens StrLen Round 2 GET Reverse String and
mov ecx, offset Buffer3
@@:
mov eax, dword ptr
add ecx, 4
lea edx,
xor eax, edx
and eax, 80808080h
and eax, edx
jz @B
@@:
bsf edx, eax
lea eax, ; n
shr eax, 3
sub eax, offset Buffer3 ; n
; ...................... Part 2: Reverse String Back to original state
push edi
mov ecx, offset Buffer3
lea edx,
lea ecx,
mov edi, offset Buffer4
@@:
mov al,
dec ecx
mov , al
inc edi
cmp ecx, edx
jne @B
mov byte ptr ,0
pop edi

;.................It should just end up with the word window
;.................and it does in my app. i don't know why it
;.................is not working here. But that still bring me
;.................back to when i dump my app it got 20 line of
;.................reversed of a single string reverved. Even
;.................though the my app works but i know that something
;.................is wrong and i got to fix it...
;......only the word WINDOWS should show up in the message box
;......Remember to DUMP it even if you fix-it to see if everything
;......is alright...Thank you for helping...

end Main



in the matter of fact bAZiK i got this code (Your Code) from smurf old post back when smurf and me went string crazy But he left me behind he were learning so fast...It's my favorite code before i got lost...
Posted on 2002-03-27 06:32:51 by cmax