-
Notifications
You must be signed in to change notification settings - Fork 0
/
wCleaner.asm
147 lines (118 loc) · 2.63 KB
/
wCleaner.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.486
.model flat, stdcall
option casemap:none
include std.inc
.data
hInst dd 0h
lpCmd dd 0h
szMbTitle db "Aseshsoft Cleaner", 0h
szMessage db "Are you sure you want to clean this directory?", 09h, 0h
szNoOfFilesFound db "No. of files found: ", 0h
szNoOfFilesDeleted db "No. of files deleted: ", 0h
szExeExtension db "*.exe", 0h
szObjExtension db "*.obj", 0h
dwNoOfFilesFound dd 0h
; Prototypes
WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
delObjFiles PROTO :DWORD
delExeFiles PROTO :DWORD
scanAndDeleteFiles PROTO :BYTE
.code
start:
push ebp
mov ebp, esp
push 0h
call GetModuleHandle
mov hInst, eax
call GetCommandLine
mov lpCmd, eax
push 1h
push lpCmd
push 0h
push hInst
call WinMain
leave
ret
WinMain proc hInstance:DWORD, hPrevInstance:DWORD, lpCmdLine:DWORD, nCmdShow:DWORD
LOCAL hThread[2]:DWORD, dwThreadId[2]:DWORD, dwSignalState:DWORD
mov eax, MB_YESNOCANCEL
or eax, MB_ICONINFORMATION
push eax
push OFFSET szMbTitle
push OFFSET szMessage
push 0h
call MessageBox
cmp eax, IDYES
je continueCleaner
ret
continueCleaner:
lea eax, dwThreadId[0]
push eax
push 0h
push 0h
push offset delObjFiles ; function for deleting obj files
push 0h
push 0h
call CreateThread
mov hThread[0], eax
lea eax, dwThreadId[1]
push eax
push 0h
push 0h
push offset delExeFiles ; function for deleting exe files
push 0h
push 0h
call CreateThread
mov hThread[1], eax
; Wait for the threads to terminate
push 0FFFFFFFFh
push 1h
lea eax, hThread
push eax
push 2h
call WaitForMultipleObjects
mov eax, dwSignalState
cmp dwSignalState, WAIT_OBJECT_0
push MB_OK or MB_ICONINFORMATION
ret
exitMainProc:
ret
WinMain endp
delObjFiles proc lpVoid:DWORD
push OFFSET szObjExtension
call scanAndDeleteFiles
ret
delObjFiles endp
delExeFiles proc lpVoid:DWORD
push OFFSET szExeExtension
call scanAndDeleteFiles
ret
delExeFiles endp
scanAndDeleteFiles proc szExtension:BYTE
comment* LOCAL hFindFile:DWORD, w32Data:WIN32_FIND_DATA
lea eax, w32Data
push eax
mov eax, dword ptr szExtension
push eax
call FindFirstFile
cmp eax, INVALID_HANDLE_VALUE
je fileNotFound
mov hFindFile, eax
jmp scanLoop
fileNotFound:
ret
scanLoop:
lea eax, w32Data
push eax
push hFindFile
call FindNextFile
call GetLastError
cmp eax, 12h
je exitScanLoop
jmp scanLoop
exitScanLoop:
push hFindFile
call CloseHandle*
ret
scanAndDeleteFiles endp
end start