Major edit:
ok my string replace function will replace any find string with any other string of any lenght
like
this is the string you want to find in b db "im gettin good"
this is your string to find f db "g" and ur replace string r db "w"
you will end up with "im wettin wood" in a new buff
or ur replace string "****" = "im ****ettin ****ood"
im soo hyped that ive done such a complex thing ive gotta say every thing about it!
also if therres any way to optimize or make it better/faster please tell me.



ret1 macro
xor eax,eax
inc eax
endm

ret0 macro
xor eax,eax
endm
sav macro
pushad
pushf
endm

res macro
popf
popad
endm

PStrCpy Proc stdcall public,PTRDEST long ,PTRSRC long,DIFputnull long;
sav
mov ecx,PTRDEST
mov ebx,PTRSRC
Invoke StringLen,ebx
mov edi,eax
cmp eax,0
je @PStrCpyEND
dec edi
xor eax,eax
xor edx,edx
mov dl, BYTE PTR [ebx+eax]
mov BYTE PTR [ecx+eax],dl
;inc eax
cmp eax,edi
je @PStrCpy@PUtnull
@@:
inc eax
mov dl, BYTE PTR [ebx+eax]
mov BYTE PTR [ecx+eax],dl
cmp eax,edi
jne @B
@PStrCpy@PUtnull:
cmp DIFputnull,1
je @PStrCpyEND
inc eax
mov BYTE PTR [ecx+eax],0
@PStrCpyEND:
res
ret
PStrCpy EndP
;=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|;for string replace
PStrMultiMove Proc,PTRDEST long ,PTRFIND long,PTRSRC long;,DIFputnull long


Local pdest long
Local pfind long
Local psrc long
Local lpheap long
sav
mov ecx,PTRDEST
Invoke StringLen,ecx
cmp eax,0
je PStrMultiMoveEND
mov pdest,eax

mov ebx,PTRSRC
Invoke StringLen,ebx
cmp eax,0
je PStrMultiMoveEND
mov psrc,eax

Invoke StringLen,PTRFIND
cmp eax,0
je PStrMultiMoveEND
mov pfind,eax
add ecx,eax
sav
mov edx,pdest
add edx,1000
;13+1000 for 5l4xx0r
Invoke GetProcessHeap
Invoke HeapAlloc,eax,HEAP_GENERATE_EXCEPTIONS or HEAP_ZERO_MEMORY,edx
mov lpheap,eax
res
Invoke PStrCpy,lpheap,ecx,0
sub ecx,pfind
Invoke PStrCpy,ecx,ebx,1
add ecx,psrc
Invoke PStrCpy,ecx,lpheap,0




PStrMultiMoveENDHEAP:
Invoke GetProcessHeap
Invoke HeapFree, eax, 0, lpheap
PStrMultiMoveEND:

res
ret
PStrMultiMove EndP
;=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|
PStrReplace Proc stdcall public,PTRstringrep long,PTRstrrep long,PTRSTRING2REPW long,PTRbuffer long
Local PTRstringrepLEN long
Local PTRstrrepwLEN long
Local fstrun long
;int 3
sav
Invoke PStrCpy,PTRbuffer,PTRstringrep,0

mov ecx,PTRbuffer
mov ebx,PTRstrrep
Invoke StringLen,ecx
mov PTRstringrepLEN,eax
Invoke StringLen,ebx
mov PTRstrrepwLEN,eax
cmp PTRstringrepLEN,eax
jb PStrReplace@endo
mov edx,PTRstringrepLEN
sub edx,PTRstrrepwLEN
mov edi,edx
xor eax,eax
xor edx,eax
mov esi,-1
jmp @neloop
PStrReplace@not:
dec ecx
Invoke PStrMultiMove,ecx,ebx,PTRSTRING2REPW

push eax
push edx
Invoke StringLen,PTRbuffer
mov PTRstringrepLEN,eax
mov edx,PTRstringrepLEN
sub edx,PTRstrrepwLEN
mov edi,edx
pop edx
pop eax
inc ecx



@neloop:
cmp esi,edi
je PStrReplace@endo
Invoke PStrCmp,ecx,ebx
inc ecx
inc esi
cmp eax,1
jne @neloop
je PStrReplace@not
PStrReplace@endo:
res
ret
PStrReplace EndP
;=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|
PStrCmp Proc stdcall public, PTRstring long,PTRstring2find long
;Local strlenght1 long
push ecx
push ebx
push edx
push esi
mov ecx,PTRstring
Invoke StringLen,ecx
cmp eax,0
je @ret0attrrcmp
mov ebx,PTRstring2find
Invoke StringLen,ebx
cmp eax,0
je @ret0attrrcmp
mov esi,eax
dec esi
xor eax,eax
xor edx,eax
mov dl, BYTE PTR [ebx+eax]
cmp dl, BYTE PTR [ecx+eax]
jne @ret0attrrcmp
;inc eax
@@:
cmp eax,esi
je @ret1attrrcmp
inc eax
mov dl, BYTE PTR [ebx+eax]
cmp dl, BYTE PTR [ecx+eax]
je @B
jne @ret0attrrcmp
@ret1attrrcmp:
ret1
@popptrecmp:
pop esi
pop edx
pop ebx
pop ecx
ret
@ret0attrrcmp:
ret0
jmp @popptrecmp
PStrCmp EndP
StringLen Proc stdcall public,ptrSTRING1:DWORD;duh
pushf
push esi
push ebx
mov esi,ptrSTRING1
xor ebx,ebx
xor eax,eax
@@:
mov bl,BYTE PTR [esi+eax]
inc eax
cmp bl,0
jne @B
dec eax
pop ebx
pop esi
popf
ret
StringLen end
Posted on 2002-05-25 12:37:07 by Qages