📄 hash.asm
字号:
include crc32.asm
include md5.asm
DlgHashProc proto:DWORD ,:DWORD ,:DWORD ,:DWORD
ShowSumReulst proto:DWORD
__sum macro uType
.if isBlockSelMode
mov ebx, eax
invoke _InBlock,esi,TRUE
.if eax
add ecx,ebx
adc edx,0
.endif
.else
add ecx,eax
adc edx,0
.endif
if uType eq 1
inc esi
else
add esi,uType
endif
endm
.code
DlgHashProc proc @hDlg,uMsg,wParam,lParam
local @szBuf[255]:BYTE
mov eax,uMsg
.if eax==WM_INITDIALOG
__senddlgmessage 1000,BM_SETCHECK ,1
__senddlgmessage 1002,CB_ADDSTRING ,0,ctext("CRC-32")
__senddlgmessage 1002,CB_ADDSTRING ,0,ctext("求和(BYTE)")
__senddlgmessage 1002,CB_ADDSTRING ,0,ctext("求和(WORD)")
__senddlgmessage 1002,CB_ADDSTRING ,0,ctext("求和(DWORD)")
__senddlgmessage 1002,CB_ADDSTRING ,0,ctext("MD5")
__senddlgmessage 1002,CB_SETCURSEL
.elseif eax==WM_COMMAND
mov eax,wParam
.if ax==IDOK
pushad
__senddlgmessage 1000,BM_GETCHECK
.if eax
mov eax,lpMemFile
mov esi,dwBlockStart
mov edi,dwBlockEnd
add esi,eax
add edi,eax
.else
mov esi,lpMemFile
mov edi,lpMemFileEnd
.endif
.if esi>edi
xchg esi,edi
.endif
__senddlgmessage 1002,CB_GETCURSEL
xor ecx,ecx
xor edx,edx
.if eax==0
and FLAG_ALL,not FLAG_BLOCKSEL
invoke calc_crc32,esi,edi;esi:首地址,edi:尾地址
invoke wsprintf,addr @szBuf,ctext("%08X"),eax
invoke SetDlgItemText,@hDlg,1003,addr @szBuf
.elseif eax==1;求和(byte)
.while esi<=edi
xor eax,eax
mov al,[esi]
__sum 1
.endw
invoke ShowSumReulst,@hDlg
.elseif eax==2;求和(word)
xor ecx,ecx
.while esi<=edi
.if (FLAG_ALL & FLAG_BLOCKSEL)
invoke _GetBlockEnd,esi,TRUE
.else
mov eax,edi
.endif
.if esi==eax
xor eax,eax
mov al,[esi]
.else
xor eax,eax
mov ax,[esi]
.endif
__sum 2
.endw
invoke ShowSumReulst,@hDlg
.elseif eax==3;求和(dword)
.while esi<=edi
.if (FLAG_ALL & FLAG_BLOCKSEL)
invoke _GetBlockEnd,esi ,TRUE
.else
mov eax,edi
.endif
sub eax,esi
.if eax==0
mov al,[esi]
.elseif eax==1
xor eax,eax
mov ax,[esi]
.elseif eax==2
xor eax,eax
mov ax,[esi+1]
shl eax,8
mov al,[esi]
.else
mov eax,[esi]
.endif
__sum 4
.endw
invoke ShowSumReulst,@hDlg
.elseif eax==4
and FLAG_ALL,not FLAG_BLOCKSEL
mov eax,edi
sub eax,esi
inc eax
invoke _MD5output,addr @szBuf,esi,eax,FALSE ;esi:首地址,eax:大小
invoke SetDlgItemText,@hDlg,1003,eax
.endif
popad
.endif
.elseif eax==WM_CLOSE
invoke ShowWindow,@hDlg,SW_HIDE
.else
xor eax,eax
ret
.endif
mov eax,TRUE
ret
DlgHashProc endp
;---------------------------------------------
ShowSumReulst proc @hDlg
local @szBuf[255]:BYTE
push ecx
test edx,edx
jnz @1
push ecx
push ctext("(Hex)%08X",9,"(Dec)%u")
jmp @2
@1:
push edx
push ctext("%08X %08X")
@2:
lea eax,@szBuf
push eax
call wsprintf
add esp,4*4
invoke SetDlgItemText,@hDlg,1003,addr @szBuf
ret
ShowSumReulst endp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -