-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathERASER.CPP
More file actions
193 lines (163 loc) · 4.18 KB
/
ERASER.CPP
File metadata and controls
193 lines (163 loc) · 4.18 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*--------------------------------------------------------------------------
*
* Welcome to Eraser for MS-DOS!
*
* Eraser is still under developement.
* Current version is 0.1 (pre-official release).
*
* Eraser's main goals are super-speed and super-options.
* In its actual form Eraser is already one of the fastest file wipe
* utilities in the world !!! (courtesy of assembler code, of course).
*
* Eraser97 for Windows 95 is under developement, too.
* Contact the author for more information.
*
* ERASER.CPP: Source code
*
* May 1997
*
* Copyright (c) 1997 Horatiu Tanescu / East-Tec
* https://www.east-tec.com
*
* Written and compiled under Borland C++ Version 3.1.
*
* Licensed under the MIT License. See LICENSE file in the project
* root for full license information.
*
*--------------------------------------------------------------------------
*
* Revision history:
* 1.0 May 27 1997 Initial coding.
*
*/
#include <stdio.h>
#include <dos.h>
#include <mem.h>
#pragma inline
const char* errstr_open = "Error opening file\r\n$";
const char* errstr_write = "Error encountered while overwriting file data\r\n$";
unsigned pBuffer;
unsigned bufSize = 32768U;
#define MAKE_FP(seg, off) ((void _seg *)(seg) + (void near *)(off))
#define memL(seg, off) *((unsigned long far*)MAKE_FP(seg, off))
unsigned long timer;
unsigned long fulltime = 0UL;
int wipedfiles = 0;
int wipe_standard(const char* filename)
{
asm .386
unsigned handle;
long size;
long curBuf = 0;
timer = memL(0x0040, 0x006C);
asm mov dx, filename
asm mov ax, 0x3D02
asm int 0x21
asm mov handle, ax
asm jnc _OpenOK
asm mov dx, errstr_open
asm mov ah, 0x09
asm int 0x21
return (0);
_OpenOK:
asm xor cx, cx
asm xor dx, dx
asm mov bx, handle
asm mov al, 0x02
asm mov ah, 0x42
asm int 0x21
asm mov word ptr [size], ax
asm mov word ptr [size + 2], dx
long buffers = size/bufSize;
unsigned lastBuffer = size%bufSize;
asm xor cx, cx
asm xor dx, dx
asm mov bx, handle
asm xor al, al
asm mov ah, 0x42
asm int 0x21
// write loop
asm mov eax, dword ptr [curBuf]
asm cmp eax, dword ptr [buffers]
asm jnl _EndLoopWrite
_WriteLoop:
asm mov cx, bufSize
asm mov bx, handle
asm push ds
asm mov ax, pBuffer
asm mov ds, ax
asm xor dx, dx
asm mov ah, 0x40
asm int 0x21
asm pop ds
asm jc _WriteError
asm cmp ax, cx
asm jb _WriteError
asm inc dword ptr [curBuf]
asm mov eax, dword ptr [curBuf]
asm cmp eax, dword ptr [buffers]
asm jl _WriteLoop
asm jmp short _EndLoopWrite
_WriteError:
asm mov dx, errstr_write
asm mov ah, 0x09
asm int 0x21
asm inc dword ptr [curBuf]
asm mov eax, dword ptr [curBuf]
asm cmp eax, dword ptr [buffers]
asm jl _WriteLoop
_EndLoopWrite:
// write the last buffer
asm mov cx, lastBuffer
asm mov bx, handle
asm push ds
asm mov ax, pBuffer
asm mov ds, ax
asm xor dx, dx
asm mov ah, 0x40
asm int 0x21
asm pop ds
asm jc _WriteError2
asm cmp ax, cx
asm jb _WriteError2
asm jmp short _EndLastWrite
_WriteError2:
asm mov dx, errstr_write
asm mov ah, 0x09
asm int 0x21
// finish writting
_EndLastWrite:
timer = memL(0x0040, 0x006C) - timer;
return (1);
}
int main(int argc, char *argv[])
{
printf("Eraser Fast! for MS-DOS => World's fastest freeware file wipe utility! <=\n");
printf("Version 0.1 (pre-official release) Copyright (c) 1997 Horatiu Tanescu / East-Tec\n\n");
if (argc > 1)
{
if (allocmem(bufSize / 16, &pBuffer) >= 0)
{
printf("Not enough memory\n");
return (-1);
}
_fmemset(MK_FP(pBuffer, 0), 0, bufSize);
for (int i = 1; i < argc; i++)
{
printf("Wiping %s...\n", argv[i]);
if (wipe_standard(argv[i]))
{
printf("Wiping time: %lf second(s)\n", timer / 18.2);
fulltime += timer;
wipedfiles++;
}
}
freemem(pBuffer);
printf("\nWiped %d file(s) in %lf second(s)\n", wipedfiles, fulltime / 18.2);
}
else
{
printf("Usage: ERASER <filename1> <filename2...>\n\nWildcards are not allowed (yet).\n");
}
return (1);
}