2012年7月4日星期三

str.asm


;made by correy
;Email:leguanyuan@126.com
;QQ:112426112
;rc me.rc
;ml /coff test.asm /link /subsystem:windows me.res
;自己编写子程序实现api函数的功能。
;invoke lstrlen,addr str 等于用伪指令sizeof str - 1.
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
include Advapi32.inc
includelib user32.lib
includelib kernel32.lib
includelib Advapi32.lib
.data
correy db "made by correy",0
path db "c:\windows\system32\cmd.exe",0
h db "%d",0
.data?
ofn OPENFILENAME <>
buffer db 256 DUP (?)
buffer2 db 256 DUP (?)
var dword ?
.code
;;;;;;;;;;;;;;;;;;;;;;
lenstr proc s
local z
mov eax,s
mov z,eax
xor eax,eax
pop ecx
comp:
cmp byte ptr [ecx],0
je exit2
inc eax
inc ecx
jmp comp
exit2:
ret
lenstr endp
;;;;;;;;;;;;;;;;;;;
;此子程序没有比较两个字符串的大小。
strcat proc s1,s2
invoke lenstr,s1
add s1,eax
mov esi,s2
mov edi,s1
invoke lenstr,s2
mov ecx,eax
rep movsb
ret
strcat endp
;;;;;;;;;;;;;;;;;;;;
start:
invoke strcat,addr buffer,addr correy
invoke MessageBox,0,addr buffer,addr buffer,0
invoke strcat,addr buffer,addr correy
invoke MessageBox,0,addr buffer,addr buffer,0
exit:invoke ExitProcess,NULL
end start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;made by correy
;Email:leguanyuan@126.com
;QQ:112426112
;rc me.rc
;ml /coff test.asm /link /subsystem:windows me.res
;自己编写子程序实现api函数的功能。
;invoke lstrlen,addr str 等于用伪指令sizeof str - 1.
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
include Advapi32.inc
includelib user32.lib
includelib kernel32.lib
includelib Advapi32.lib
.data
correy db "made by correy",0
path db "c:\windows\system32\cmd.exe",0
h db "%d",0
.data?
ofn OPENFILENAME <>
buffer db 256 DUP (?)
buffer2 db 256 DUP (?)
var dword ?
.code
;;;;;;;;;;;;;;;;;;;;;;
lenstr proc s
local z
mov eax,s
mov z,eax
xor eax,eax
pop ecx
comp:
cmp byte ptr [ecx],0
je exit2
inc eax
inc ecx
jmp comp
exit2:
ret
lenstr endp
;;;;;;;;;;;;;;;;;;;;
lenstrm macro s
xor eax,eax
mov ecx,offset correy
comp2:
cmp byte ptr [ecx],0
je next3
inc eax
inc ecx
jmp comp2
endm
;;;;;;;;;;;;;;;;;;;;
;此子程序没有比较两个字符串的大小。
cpystr proc s1,s2
mov esi,s2
mov edi,s1
invoke lenstr,s2
mov ecx,eax
rep movsb
ret
cpystr endp
;;;;;;;;;;;;;;;;;;;;
start:
;用自己编写的子程序写的
invoke cpystr,addr buffer,addr correy
invoke MessageBox,0,addr buffer,addr buffer,0
;原套写的
mov esi,offset correy
mov edi,offset buffer
invoke lenstr,addr correy
mov ecx,eax
rep movsb
invoke MessageBox,0,addr buffer,addr buffer,0
;invoke MessageBox,0,addr correy,addr correy,0
;调用系统写的
invoke lstrcpy,addr buffer2,addr correy
invoke MessageBox,0,addr buffer2,addr buffer2,0
;用自己编写的子程序写的
invoke lenstr,addr correy
invoke wsprintf,addr buffer,addr h,eax
;invoke MessageBox,0,addr buffer,addr buffer,0
;用宏写的
lenstrm addr correy
next3:
invoke wsprintf,addr buffer,addr h,eax
;invoke MessageBox,0,addr buffer,addr buffer,0
;用伪指令写的
mov eax,sizeof correy-1
invoke wsprintf,addr buffer,addr h,eax
;invoke MessageBox,0,addr buffer,addr buffer,0
;原套写的
xor eax,eax
mov ecx,offset correy
comp:
cmp byte ptr [ecx],0
je next2
inc eax
inc ecx
jmp comp
next2:
invoke wsprintf,addr buffer,addr h,eax
;invoke MessageBox,0,addr buffer,addr buffer,0
exit:invoke ExitProcess,NULL
end start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;made by correy
;Email:leguanyuan@126.com
;QQ:112426112
;rc me.rc
;ml /coff test.asm /link /subsystem:windows me.res
;自己编写子程序实现api函数的功能。
;invoke lstrlen,addr str 等于用伪指令sizeof str - 1.
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
include Advapi32.inc
includelib user32.lib
includelib kernel32.lib
includelib Advapi32.lib
.data
correy db "made by correy",0
h db "%d",0
.data?
ofn OPENFILENAME <>
buffer db 256 DUP (?)
var dword ?
.code
;;;;;;;;;;;;;;;;;;;;;;
lenstr proc s
local z
mov eax,s
mov z,eax
xor eax,eax
pop ecx
comp:
cmp byte ptr [ecx],0
je exit2
inc eax
inc ecx
jmp comp
exit2:
ret
lenstr endp
;;;;;;;;;;;;;;;;;;;;
lenstrm macro s
xor eax,eax
mov ecx,offset correy
comp2:
cmp byte ptr [ecx],0
je next3
inc eax
inc ecx
jmp comp2
endm
;;;;;;;;;;;;;;;;;;;;
start:
;用自己编写的子程序写的
invoke lenstr,addr correy
invoke wsprintf,addr buffer,addr h,eax
invoke MessageBox,0,addr buffer,addr buffer,0
;用宏写的
lenstrm addr correy
next3:
invoke wsprintf,addr buffer,addr h,eax
invoke MessageBox,0,addr buffer,addr buffer,0
;用伪指令写的
mov eax,sizeof correy-1
invoke wsprintf,addr buffer,addr h,eax
invoke MessageBox,0,addr buffer,addr buffer,0
;原套写的
xor eax,eax
mov ecx,offset correy
comp:
cmp byte ptr [ecx],0
je next2
inc eax
inc ecx
jmp comp
next2:
invoke wsprintf,addr buffer,addr h,eax
invoke MessageBox,0,addr buffer,addr buffer,0
exit:invoke ExitProcess,NULL
end start

没有评论:

发表评论