- UID
- 1821
- 精华
- 积分
- 3247
- 威望
- 点
- 宅币
- 个
- 贡献
- 次
- 宅之契约
- 份
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
本帖最后由 Ayala 于 2017-7-3 19:25 编辑
- fdata struc
- h dword ?
- n dword ?
- k dword ?
- fdata ends
- llist struc
- _next dword ?
- _last dword ?
- _data fdata <>
- llist ends
- .code
- Dirtrav proc uses esi edi ebx fdir,fcallback,fcontext
- LOCAL fd1:WIN32_FIND_DATA
- LOCAL dp:llist
- LOCAL dir[MAX_PATH*2]:word
- LOCAL curDir[MAX_PATH]:word
-
- lea edi,fd1
- assume edi:ptr WIN32_FIND_DATA
- invoke GetCurrentDirectory,MAX_PATH,addr curDir
-
-
- mov ebx,fdir
- invoke SetCurrentDirectory,ebx
- invoke FindFirstFile,$CTA0(".\\*"),edi
-
-
- lea ebx,dp
- assume ebx:ptr llist
- mov [ebx]._next,0
- mov [ebx]._last,0
- mov [ebx]._data.h,eax
-
- .while [ebx]._data.h!=INVALID_HANDLE_VALUE
- mov esi,[ebx]._data.h
- mov eax,fcallback
- .if eax
- PROTO@8 TYPEDEF PROTO STDCALL :DWORD,:DWORD
- invoke (PROTO@8 ptr eax),edi,fcontext
- .break .if eax
- .endif
- mov eax,dword ptr [edi].cFileName
- and eax,0FFFFFFh
- .if [edi].dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY && eax!=".." && ax!="."
-
- invoke crt_malloc,sizeof dp
- .if !eax
- jmp done
- .endif
- assume eax:ptr llist
- mov [eax]._next,0
- mov [eax]._last,ebx
- mov [ebx]._next,eax
- mov ebx,eax
- assume eax:ptr nothing
-
- invoke SetCurrentDirectory,addr [edi].cFileName
- invoke FindFirstFile,$CTA0(".\\*"),edi
- mov [ebx]._data.h,eax
- .else
- invoke FindNextFile,esi,edi
- .if !eax
- invoke FindClose,esi
- mov ebx,[ebx]._last
- .break .if !ebx
- invoke crt_free,[ebx]._next
- ;invoke crt_system,$CTA0("PAUSE")
- invoke SetCurrentDirectory,$CTA0("..\")
- .endif
- .endif
- .endw
- done:
- .while ebx
- invoke crt_free,[ebx]._next
- mov ebx,[ebx]._last
- .endw
- invoke SetCurrentDirectory,addr curDir
- assume edi:nothing
- xor eax,eax
- ret
- Dirtrav endp
复制代码 |
|