;======================================Monk Corp=============================
.586p
.model flat, stdcall
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\user32.lib
;-------------------Functions----------------
extern GetStdHandle@4:NEAR
extern WriteConsoleA@20:NEAR
extern ExitProcess@4:NEAR
extern GetCommandLineA@0:NEAR
extern CreateFileA@28:NEAR
extern CloseHandle@4:NEAR
extern ReadFile@20:NEAR
extern FindFirstFileA@8:near
extern FindNextFileA@8:near
extern FindCloseA@4:near
extern CharToOemA@8:near
extern WSprintfA@12:near
extern LstrCatA@8:near
extern ReadConsoleA@20:near
;=============================EQU=====================
std_output_handle equ -11
std_input_handle equ -10
;============================FIND=======================
_FIND struc
art dword ?
crtime dword ?
dword ?
actime dword ?
dword ?
sizeh dword ?
sizel dword ?
dword ?
dword ?
nam dword ?
anam dword ?
_FIND ends
;============================SEGMENT FOR DATA=====================
data segment
handle dword ?
handle1 dword ?
str1 db 'Find Files',0
str2 db 'Directory Find ',0
str3 db 'Enter other key',0
p1 dword ?
buf db 100 dup(0)
slash db '\',0
maskn db '*.*',0
numf dword ?
numd dword ?
num dword ?
bufin db 100 dup(0)
lens dword ?
text db 100 dup(0)
buffer db 100 dup(0)
fin _FIND <0>
findh dword ?
dir db 100 dup(0)
data ends
;====================================TEXT==========================
_text segment
start:
push std_output_handle
call GetStdHandle@4
mov handle,eax
push std_input_handle
call GetStdHandle@4
mov handle1,eax
push offset str1
push offset str1
call CharToOemA@8
push offset str2
push offset str2
call CharToOemA@8
push offset str3
push offset str3
call CharToOemA@8
call countofpar
cmp eax,1
je dalee1
mov p1,eax
mov edi,2
lea ebx,buf
call getparam
push offset buf
call strlen
cmp byte ptr[ebx+buf-1],'\'
je dalee1
push offset slash
push offset buf
call lstrcatA@8
dalee1:
call FIND
push numf
push offset str1
push offset buffer
call WSprintfA@12
push numd
push offset str2
push offset buffer
call WSprintfA@12
push 0
call ExitProcess@4
countofpar proc
call GetCommandLineA@0
mov esi,eax
mov ebx,0
cloop:
cmp byte ptr[esi],32
jne dalee2
inc ebx
dalee2:
inc esi
cmp byte ptr[esi],0
jne cloop
inc ebx
mov eax,ebx
ret
countofpar endp
getparam proc
call GetCommandLineA@0
mov esi,eax
mov ebx,0
dec edi
cloop:
cmp byte ptr[esi],32
jne dalee2
inc ebx
dalee2:
inc esi
cmp ebx,edi
jne cloop
cloop2:
push esi
push ebx
call LstrCatA@8
inc esi
cmp byte ptr[esi],0
jne cloop2
ret
getparam endp
strlen proc
pop esi
mov ebx,0
cloopstr:
cmp byte ptr[esi],0
je daleestr1
inc esi
inc ebx
jmp cloopstr
daleestr1:
ret
strlen endp
find proc
push offset maskn
push offset buf
call LstrCatA@8
push offset fin
push offset buf
call FindFirstFileA@8
cmp eax,-1
je derr
mov findh,eax
usl:
cmp byte ptr fin.nam ,"."
je dnet
test byte ptr fin.art,10h
je nedir
push offset dir
push offset fin.nam
call LstrCatA@8
inc numd
dec numf
nedir:
push offset fin.nam
push offset fin.nam
call CharToOemA@8
mov edi,1
lea eax,fin.nam
inc numf
inc num
cmp num,32
jne dnet
mov num,0
mov edi,0
lea eax,text
push 0
push offset lens
push 10
push offset bufin
push handle1
call ReadConsoleA@20
dnet:
push offset fin
push findh
call FindNextFileA@8
cmp eax,0
jne usl
push findh
call FindCloseA@4
derr:
ret
find endp
_text ends
end start
Поиск файлов и папок.Asm.Masm32
Опять этот гад ругается на LIBCD.LIb....понять не могу, почиму....я ее даже не подключал....
Цитата: Padsh
Опять этот гад ругается на LIBCD.LIb....понять не могу, почиму....я ее даже не подключал....
Как ругается? Как собираешь программу?
Цитата: Padsh
Код:
extern GetStdHandle@4:NEAR
extern WriteConsoleA@20:NEAR
extern ExitProcess@4:NEAR
extern GetCommandLineA@0:NEAR
extern CreateFileA@28:NEAR
extern CloseHandle@4:NEAR
extern ReadFile@20:NEAR
extern FindFirstFileA@8:near
extern FindNextFileA@8:near
extern FindCloseA@4:near
extern CharToOemA@8:near
extern WSprintfA@12:near
extern LstrCatA@8:near
extern ReadConsoleA@20:near
;=============================EQU=====================
std_output_handle equ -11
std_input_handle equ -10
;============================FIND=======================
_FIND struc
art dword ?
crtime dword ?
dword ?
actime dword ?
dword ?
sizeh dword ?
sizel dword ?
dword ?
dword ?
nam dword ?
anam dword ?
_FIND ends
extern WriteConsoleA@20:NEAR
extern ExitProcess@4:NEAR
extern GetCommandLineA@0:NEAR
extern CreateFileA@28:NEAR
extern CloseHandle@4:NEAR
extern ReadFile@20:NEAR
extern FindFirstFileA@8:near
extern FindNextFileA@8:near
extern FindCloseA@4:near
extern CharToOemA@8:near
extern WSprintfA@12:near
extern LstrCatA@8:near
extern ReadConsoleA@20:near
;=============================EQU=====================
std_output_handle equ -11
std_input_handle equ -10
;============================FIND=======================
_FIND struc
art dword ?
crtime dword ?
dword ?
actime dword ?
dword ?
sizeh dword ?
sizel dword ?
dword ?
dword ?
nam dword ?
anam dword ?
_FIND ends
А не проще сделать так:
Код:
option casemap : none
include c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc
------------------------------------------------------------------------
Такое изобилие call'ов... Чем не устраивает invoke?
------------------------------------------------------------------------
По поводу wsprintf - эта функция принимает параметры, используя С calling convention, с вытекающими отсюда последствиями.
Код:
c:\masm32\bin\ml /c /coff w.asm
pause
c:\masm32\bin\link /SUBSYSTEM:CONSOLE w.obj
pause
w.exe d:/masm32/
pause
pause
c:\masm32\bin\link /SUBSYSTEM:CONSOLE w.obj
pause
w.exe d:/masm32/
pause
Тип того.....
----------------------------------------------------
Хы, попробуем по вашему....может и сработает....