; by ManHunter / PCL 
; http://www.manhunter.ru 
;-----------------------------------------------------
; ”ã­ªæ¨ï ¯®«ã祭¨ï ¤«¨­ë áâப¨ (Fast)
;-----------------------------------------------------
; lpStr - 㪠§ â¥«ì ­  áâபã ASCIIZ
;   ¢ë室¥: EAX - ¤«¨­  áâப¨ ¡¥§ ãç¥â  § ¢¥àè î饣®
; ­ã«¥¢®£® ¡ ©â 
;-----------------------------------------------------
;proc    _lstrlen lpStr:DWORD
;        mov     eax, [lpStr]
;        sub     eax, 4
;@@:
;        add     eax, 4
;        cmp     byte [eax], 0
;        je      .szlen_lb1
;        cmp     byte [eax+1], 0
;        je      .szlen_lb2
;        cmp     byte [eax+2], 0
;        je      .szlen_lb3
;        cmp     byte [eax+3], 0
;        jne     @b
;        sub     eax, [lpStr]
;        add     eax, 3
;        ret
;.szlen_lb3:
;        sub     eax, [lpStr]
;        add     eax, 2
;        ret
;.szlen_lb2:
;        sub     eax, [lpStr]
;        add     eax, 1
;        ret
;.szlen_lb1:
;        sub     eax, [lpStr]
;        ret
;endp

;----------------------------------------------------- 
; ”ã­ªæ¨ï ¯®«ã祭¨ï ¤«¨­ë áâப¨ 
;----------------------------------------------------- 
; lpStr - 㪠§ â¥«ì ­  áâபã ASCIIZ 
;   ¢ë室¥: EAX - ¤«¨­  áâப¨ ¡¥§ ãç¥â  § ¢¥àè î饣® 
; ­ã«¥¢®£® ¡ ©â  
;-----------------------------------------------------
proc _lstrlen lpStr:DWORD
        mov     eax, [lpStr]
@@:     inc     eax
        cmp     byte [eax], 0
        jne     @b
        sub     eax, [lpStr]
        ret
endp
;----------------------------------------------------- 
; ”ã­ªæ¨ï ¡ëáâண® á«¨ï­¨ï ¤¢ãå áâப 
; ¨á¯®«ì§ãîâáï ä㭪樨 _lstrlen, _lstrcpy 
;----------------------------------------------------- 
; lpDst - 㪠§ â¥«ì ­  ¨á室­ãî áâபã ASCIIZ 
; lpSrc - 㪠§ â¥«ì ­  ¤®¡ ¢«ï¥¬ãî áâபã ASCIIZ 
;----------------------------------------------------- 
proc    _lstrcat lpDst:DWORD, lpSrc:DWORD 
        pusha 
  
        stdcall _lstrlen,[lpDst] 
        add     eax,[lpDst] 
  
        stdcall _lstrcpy,eax,[lpSrc] 
  
        popa 
        ret 
endp 

;----------------------------------------------------- 
; ”ã­ªæ¨ï ¡ëáâண® ª®¯¨à®¢ ­¨ï áâப¨ 
; ¨á¯®«ì§ãîâáï ä㭪樨 _lstrlen, _memcopy 
;----------------------------------------------------- 
; lpDst - 㪠§ â¥«ì ­  ¯à¨¥¬­¨ª 
; lpSrc - 㪠§ â¥«ì ­  áâபã ASCIIZ 
;----------------------------------------------------- 
proc    _lstrcpy lpDst:DWORD, lpSrc:DWORD 
        pusha 
  
        stdcall _lstrlen,[lpSrc] 
        inc     eax 
        stdcall _memcopy,[lpDst],[lpSrc],eax 
  
        popa 
        ret 
endp 

;----------------------------------------------------- 
; ”ã­ªæ¨ï ¡ëáâண® ª®¯¨à®¢ ­¨ï ãç á⪠ ¯ ¬ï⨠
;----------------------------------------------------- 
; lpDst - 㪠§ â¥«ì ­  ¯à¨¥¬­¨ª 
; lpSrc - 㪠§ â¥«ì ­  ¨áâ®ç­¨ª 
; dSize - à §¬¥à ª®¯¨à㥬®£® ¡«®ª  
;----------------------------------------------------- 
proc    _memcopy lpDst:DWORD, lpSrc:DWORD, dSize:DWORD 
        pusha 
  
        ; “áâ ­®¢¨âì 㪠§ â¥«¨ ­  ¨áâ®ç­¨ª ¨ ¯à¨¥¬­¨ª 
        cld 
        mov     edi,[lpDst] 
        mov     esi,[lpSrc] 
  
        mov     ecx,[dSize] 
        push    ecx 
        ;  §¤¥«¨âì ­  4 ¨ ¯®«ãç¨âì ¤«¨­ã ¢ DWORD 
        shr     ecx,2 
        ; ‘ª®¯¨à®¢ âì ®á­®¢­ãî ç áâì áâப¨ DWORD' ¬¨ 
        rep     movsd 
        pop     ecx 
        ; ®«ãç¨âì ®áâ â®ª ®â ¤¥«¥­¨ï ­  4 
        and     ecx,3 
        ; ‘ª®¯¨à®¢ âì ®áâ â®ª áâப¨ ¡ ©â ¬¨ 
        rep     movsb 
  
        popa 
        ret 
endp