⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findfiles.asm

📁 一个十六进制编辑器源代码,cool!
💻 ASM
字号:
_FindFilesDlgProc proto:DWORD ,:DWORD ,:DWORD ,:DWORD 
_DoFindFiles proto:DWORD ,:DWORD ,:DWORD ,:DWORD 
_FindFile proto:DWORD ,:DWORD 
_FindInFile proto:DWORD ,:DWORD 
_findinfile_thread proto:DWORD 
_FindinFileFinish proto:DWORD 
FLAG_INCLUDESUBDIR=1
FLAG_RUNNING=2
FLAG_INCLUDEHIDDEN=4
FFdata struct
	_hWnd dd ?
	nLength dd ?;要查找的数据的长度
	lpfnCmp dd ?;对查找的数据进行比较的函数的地址
	uFlag db ?;是否包括子目录,控制停止标志	
	lpszPath db 255 dup(?);要查找的目录
	lpData db 255 dup(?);要查找的数据(转换后)
FFdata ends
.data?
	lpffData dd ?	
.data
	szFindInFileKey db 'findinfile',0
	szLastFindInFileKey db 'lastfindinfile',0
.code
_FindFilesDlgProc proc @hDlg,uMsg,wParam,lParam
local lpBuf[MAX_PATH ]:BYTE,@szBuf[255]:BYTE 
	mov eax,uMsg
	.if eax==WM_INITDIALOG
			invoke _AddFindType,@hDlg,1005
			invoke _IniSet2Default
			invoke _IniGetStr2Edit,@hDlg,1001,0,addr szFindInFileKey
			invoke _IniGetStr2Edit,@hDlg,1000,0,addr szLastFindInFileKey
			;__senddlgmessage 1008,ACM_OPEN,0,ctext("C:\Documents and Settings\KEN\桌面\1.avi")
	.elseif eax==WM_COMMAND 
		mov eax,wParam
		.if ax==1007;开始/停止
			push esi
			assume esi:ptr FFdata
			mov esi,lpffData
			.if esi && [esi].uFlag & FLAG_RUNNING
					and [esi].uFlag,not FLAG_RUNNING
			.else
					__senddlgmessage 1010,LB_RESETCONTENT
					__alloc sizeof FFdata
					mov lpffData,eax
					mov esi,eax
					invoke GetDlgItemText,@hDlg,1001,addr [esi].lpszPath,255
					.if eax==0;没有输入文件夹,
						__free lpffData
						ret
					.endif
					invoke IsDlgButtonChecked,@hDlg,1006
					mov [esi].uFlag,al
					invoke IsDlgButtonChecked,@hDlg,1003
					.if eax
						or [esi].uFlag,FLAG_INCLUDEHIDDEN
					.endif
					__senddlgmessage 1005,CB_GETCURSEL 
					.if sdword ptr eax<0
						__free lpffData
						ret
					.endif
					inc eax
					push ebx
					mov ebx,eax
					invoke _InitFindData,@hDlg,1000,ebx,addr [esi].lpData
					mov [esi].nLength,edx
					mov [esi].lpfnCmp,ebx
					m2m [esi]._hWnd,@hDlg
					or [esi].uFlag,FLAG_RUNNING
					invoke SetDlgItemText,@hDlg,1007,ctext("停止")
					invoke CreateThread,0,0,offset _findinfile_thread,NULL ,0,addr wParam
					invoke CloseHandle,eax
					pop ebx
			.endif
			assume esi:nothing
			pop esi
		.elseif ax==1002;浏览文件夹
			lea eax,@szBuf
			push eax
			invoke GetDlgItemText,@hDlg,1001,eax,255
			pop eax
			invoke _BrowserDir,@hDlg,eax,eax
			.if eax
				invoke SetDlgItemText,@hDlg,1001,eax
			.endif
		.else;双击打开文件
			shr eax,16
			.if ax==LBN_DBLCLK 
				__senddlgmessage 1010,LB_GETCURSEL 
				.if sdword ptr eax>=0
					mov ebx,eax
					mov wParam,eax
					__senddlgmessage 1010,LB_GETTEXT ,ebx,addr @szBuf
					call _GetModify
					.if eax!=IDCANCEL
						invoke _OpenFile,addr @szBuf
						__senddlgmessage 1010,LB_GETITEMDATA,wParam
						invoke _SetPos,eax
					.endif
				.endif
			.endif
		.endif
	.elseif eax==WM_CLOSE 
		invoke ShowWindow,@hDlg,SW_HIDE 
	.elseif eax==WM_DESTROY 
		invoke _IniSet2Default
		invoke _IniSetStrFromEdit,@hDlg,1001,0,addr szFindInFileKey
		invoke _IniSetStrFromEdit,@hDlg,1000,0,addr szLastFindInFileKey
	.else
		xor eax,eax
		ret
	.endif
	mov eax,TRUE 
	ret
_FindFilesDlgProc endp
;--------------------------------------------------------------------
_findinfile_thread proc uses esi lParam
local @hDlg
		mov esi,lpffData
		assume esi:ptr FFdata
		invoke SetDlgItemText,[esi]._hWnd,5000,ctext("正在查找...")
		invoke _FindFile,[esi]._hWnd,addr [esi].lpszPath
		invoke _FindinFileFinish,NULL 
		assume esi:nothing
		ret
_findinfile_thread endp
;---------------------------------------------------------
_FindFile proc uses esi ebx @hDlg,lpszPath
local @szPath[255]:BYTE ,@szPathTmp[255]:BYTE 
local wfd:WIN32_FIND_DATA,hFind
	mov esi,lpszPath
	invoke lstrlen,lpszPath
	add esi,eax
	.if BYTE ptr [esi-1]!='\'
		mov WORD  ptr [esi],'\'
	.endif
	invoke lstrcpy,addr @szPath,lpszPath
	invoke SetDlgItemText,@hDlg,5000,lpszPath
	invoke lstrcat,lpszPath,ctext('*.*')
	lea ebx,wfd
	invoke FindFirstFile,eax,ebx
	mov hFind,eax
	mov esi,lpffData
	assume esi:ptr FFdata
	.while eax && ([esi].uFlag & FLAG_RUNNING)
		.if (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ;隐藏属性
			test [esi].uFlag , FLAG_INCLUDEHIDDEN
			jnz @f
		.else
			@@:
			.if wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
				.if wfd.cFileName!='.' 
					.if [esi].uFlag & FLAG_INCLUDESUBDIR
						invoke lstrcpy,addr @szPathTmp,addr @szPath
						lea ebx,wfd.cFileName
						invoke lstrcat,eax,ebx 
						invoke _FindFile,@hDlg,eax;递归
					.endif
				.endif
			.else
				invoke lstrcpy,addr @szPathTmp,addr @szPath
				lea ebx,wfd.cFileName
				invoke lstrcat,eax,ebx
				invoke _FindInFile,@hDlg,eax
			.endif
		.endif
		invoke FindNextFile,hFind,addr wfd
	.endw
	invoke FindClose,hFind
	assume esi:nothing
	ret
_FindFile endp
;--------------------------------------------
_FindInFile proc uses esi edi ebx @hDlg,lpFile
local lpMap,@dwFileSize,hMap,@hFile
	invoke CreateFile,lpFile,GENERIC_READ ,0,0,OPEN_EXISTING,0,0
	.if  eax!=INVALID_HANDLE_VALUE
		mov @hFile,eax
		invoke GetFileSize,eax,0
		.if eax		
			push eax
			invoke CreateFileMapping,@hFile,0,PAGE_READONLY ,0,0,0		
			mov hMap, eax
			invoke MapViewOfFile,eax, FILE_MAP_READ ,0,0,0			
			mov lpMap,eax
			mov esi,eax
			pop ebx
			add eax,ebx
			mov edi,lpffData
			assume edi:ptr FFdata
			sub eax,[edi].nLength
			.while esi<=eax
				push eax
				push [edi].nLength
				lea eax,[edi].lpData
				push eax
				push esi
				call [edi].lpfnCmp
				.if eax
					__senddlgmessage 1010,LB_ADDSTRING ,0,lpFile
					sub esi,lpMap
					__senddlgmessage 1010,LB_SETITEMDATA ,eax,esi
					pop eax
					.break
				.endif
				inc esi
				pop eax
			.endw
			assume edi:nothing
			invoke UnmapViewOfFile,lpMap
			invoke CloseHandle,hMap
		.endif
		invoke CloseHandle,@hFile
	.endif			
	ret
_FindInFile endp
;-----------------------------------------------------
_FindinFileFinish proc uses esi lParam
local @szBuf[100]:BYTE
	mov esi,lpffData
	assume esi:ptr FFdata
	and [esi].uFlag,not FLAG_RUNNING
	invoke SetDlgItemText,[esi]._hWnd,1007,ctext("查找")
	invoke SendDlgItemMessage,[esi]._hWnd,1010,LB_GETCOUNT ,0,0
	invoke wsprintf,addr @szBuf,ctext("查找完成,共找到%lu个文件"),eax
	invoke SetDlgItemText,[esi]._hWnd,5000,addr @szBuf
	invoke _addItemIfNotExist,[esi]._hWnd,1010
	invoke _SetLBHScroll,[esi]._hWnd,1010
	__free lpffData
	mov lpffData,0
	assume esi:nothing
	ret
_FindinFileFinish endp
		


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -