source: trunk/eraser5/EraserDll/EraserDll.h @ 1294

Revision 1294, 12.6 KB checked in by lowjoel, 5 years ago (diff)

Upgrade the Eraser custom erasure methods to the new Unicode versions so that custom methods are preserved. Fixes #225.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1// EraserDll.h
2// Header file for the Eraser Library.
3//
4// Eraser. Secure data removal. For Windows.
5// Copyright © 2002  Garrett Trant (gtrant@heidi.ie).
6// Copyright © 1997-2001  Sami Tolvanen (sami@tolvanen.com).
7//
8// This program is free software; you can redistribute it and/or
9// modify it under the terms of the GNU General Public License
10// as published by the Free Software Foundation; either version 2
11// of the License, or (at your option) any later version.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21// 02111-1307, USA.
22
23#ifndef ERASERDLL_H
24#define ERASERDLL_H
25
26#include "EraserExport.h"
27
28// GUID
29//
30#ifndef _GUID_ERASER
31    #define _GUID_ERASER "Eraser.{D5BBB6C1-64F1-11d1-A87C-444553540000}"
32#endif
33
34
35// Registry keys (HKEY_CURRENT_USER)
36//
37// base keys
38const LPCTSTR ERASER_REGISTRY_AUTHOR
39    = _T("Software\\Heidi Computers Ltd");
40const LPCTSTR ERASER_REGISTRY_PROGRAM
41    = _T("Software\\Heidi Computers Ltd\\Eraser");
42const LPCTSTR ERASER_REGISTRY_BASE
43    = _T("Software\\Heidi Computers Ltd\\Eraser\\5.8");
44// settings for the library
45const LPCTSTR ERASER_REGISTRY_LIBRARY
46    = _T("Library");
47const LPCTSTR ERASER_REGISTRY_LIBRARY_VERSION
48    = _T("LibraryVersion");
49// enable Shell Extension?
50const LPCTSTR ERASEXT_REGISTRY_ENABLED
51    = _T("ErasextEnabled");
52// results for the Shell Extension
53const LPCTSTR ERASEXT_REGISTRY_RESULTS
54    = _T("ResultsErasext");
55// enable slow entropy polling?
56const LPCTSTR ERASER_RANDOM_SLOW_POLL
57    = _T("EraserSlowPollEnabled");
58// common results
59const LPCTSTR ERASER_REGISTRY_RESULTS_WHENFAILED
60    = _T("ResultsOnlyWhenFailed");
61const LPCTSTR ERASER_REGISTRY_RESULTS_FILES
62    = _T("ResultsForFiles");
63const LPCTSTR ERASER_REGISTRY_RESULTS_UNUSEDSPACE
64    = _T("ResultsForUnusedSpace");
65
66
67// URLs
68//
69const LPCTSTR ERASER_URL_HOMEPAGE
70    = _T("http://www.heidi.ie/eraser/");
71const LPCTSTR ERASER_URL_EMAIL
72    = _T("mailto:support@heidi.ie");
73
74#ifdef DMARS
75typedef unsigned __int64 ULONGLONG;
76#endif
77
78// Library basic types
79//
80typedef char        E_INT8,   *E_PINT8;
81typedef short       E_INT16,  *E_PINT16;
82typedef LONG        E_INT32,  *E_PINT32;
83typedef LONGLONG    E_INT64,  *E_PINT64;
84
85typedef BYTE        E_UINT8,  *E_PUINT8;
86typedef WORD        E_UINT16, *E_PUINT16;
87typedef ULONG       E_UINT32, *E_PUINT32;
88typedef ULONGLONG   E_UINT64, *E_PUINT64;
89
90#define E_IN        const
91#define E_OUT
92#define E_INOUT
93
94
95// Window messages
96//
97#define WM_ERASERNOTIFY     (WM_USER + 10)
98
99// wParam values
100#define ERASER_WIPE_BEGIN   0
101#define ERASER_WIPE_UPDATE  1
102#define ERASER_WIPE_DONE    2
103#define ERASER_TEST_PAUSED  3
104
105// Library type definitions
106//
107typedef E_UINT32 ERASER_HANDLE;
108
109typedef enum {
110    ERASER_METHOD_LIBRARY,
111    ERASER_METHOD_GUTMANN,
112    ERASER_METHOD_DOD,
113    ERASER_METHOD_DOD_E,
114    ERASER_METHOD_PSEUDORANDOM,
115    ERASER_METHOD_FIRST_LAST_2KB,
116    ERASER_METHOD_SCHNEIER
117} ERASER_METHOD;
118
119
120#define eraserIsValidMethod(x)  (( (x) >= ERASER_METHOD_LIBRARY ) && \
121                                 ( (x) <= ERASER_METHOD_SCHNEIER ))
122
123typedef enum {
124    ERASER_DATA_DRIVES,
125    ERASER_DATA_FILES } ERASER_DATA_TYPE;
126
127#define eraserIsValidDataType(x)  (( (x) >= ERASER_DATA_DRIVES ) && \
128                                   ( (x) <= ERASER_DATA_FILES ))
129
130typedef enum {
131    ERASER_PAGE_DRIVE,
132    ERASER_PAGE_FILES } ERASER_OPTIONS_PAGE;
133
134// eraserRemoveFolder options
135enum {
136    ERASER_REMOVE_FOLDERONLY  = 0,
137    ERASER_REMOVE_RECURSIVELY = 1
138};
139
140// display flags
141enum {
142    eraserDispPass     = (1 << 0),     // Show pass information
143    eraserDispTime     = (1 << 1),     // Show estimated time
144    eraserDispMessage  = (1 << 2),     // [UNUSED] Show message
145    eraserDispProgress = (1 << 3),     // [UNUSED] Show progress bar
146    eraserDispStop     = (1 << 4),     // [UNUSED] Allow termination
147    eraserDispItem     = (1 << 5),     // [UNUSED] Show item name
148    eraserDispInit     = (1 << 6),     // Set progress to 0 on ERASER_WIPE_BEGIN
149    eraserDispReserved = (1 << 7)      // [UNUSED]
150};
151
152// bit masks for items to erase
153enum {
154    // files
155    fileClusterTips      = (1 << 0),
156    fileNames            = (1 << 1),
157    fileAlternateStreams = (1 << 2),
158    // unused disk space
159    diskFreeSpace        = (1 << 5),
160    diskClusterTips      = (1 << 6),
161    diskDirEntries       = (1 << 7)
162};
163
164
165// Error messages
166//
167typedef E_INT32 ERASER_RESULT;
168
169#define ERASER_OK                       0       // No error
170#define ERASER_ERROR                    -1      // Unspecified error
171#define ERASER_ERROR_PARAM1             -2      // Parameter 1 invalid
172#define ERASER_ERROR_PARAM2             -3      // Parameter 2 invalid
173#define ERASER_ERROR_PARAM3             -4      // Parameter 3 invalid
174#define ERASER_ERROR_PARAM4             -5      // Parameter 4 invalid
175#define ERASER_ERROR_PARAM5             -6      // Parameter 5 invalid
176#define ERASER_ERROR_PARAM6             -7      // Parameter 6 invalid
177#define ERASER_ERROR_MEMORY             -8      // Out of memory
178#define ERASER_ERROR_THREAD             -9      // Failed to start thread
179#define ERASER_ERROR_EXCEPTION          -10     // BUG!
180#define ERASER_ERROR_CONTEXT            -11     // Context array full (ERASER_MAX_CONTEXT)
181#define ERASER_ERROR_INIT               -12     // Library not initialized (eraserInit())
182#define ERASER_ERROR_RUNNING            -13     // Failed because the thread is running
183#define ERASER_ERROR_NOTRUNNING         -14     // Failed because the thread is not running
184#define ERASER_ERROR_DENIED             -15     // Operation not permitted
185#define ERASER_ERROR_NOTIMPLEMENTED     -32     // Function not implemented
186
187#define eraserOK(x)     ((x) >= ERASER_OK)
188#define eraserError(x)  (!eraserOK(x))
189
190// only for marking a context invalid, use eraserIsValidContext to verify a handle!
191#define ERASER_INVALID_CONTEXT          ((ERASER_HANDLE)-1)
192
193
194// Export definitions
195//
196
197#if defined(__cplusplus)
198extern "C" {
199#endif
200
201
202
203
204// Library initialization
205//
206
207// initializes the library, must be called before using
208ERASER_EXPORT
209eraserInit();
210// cleans up after use
211ERASER_EXPORT
212eraserEnd();
213
214
215// Context creation and destruction
216
217//convert ERASER_METHOD to inner format
218ERASER_API E_UINT8 convEraseMethod(ERASER_METHOD mIn);
219// creates context with predefined settings
220ERASER_EXPORT
221eraserCreateContext(E_OUT ERASER_HANDLE*);
222// creates context and sets an alternative method, pass count and items to erase
223ERASER_EXPORT
224eraserCreateContextEx(E_OUT ERASER_HANDLE*, E_IN E_UINT8, E_IN E_UINT16, E_IN E_UINT8);
225// destroys a context
226ERASER_EXPORT
227eraserDestroyContext(E_IN ERASER_HANDLE);
228// checks the validity of a context, return ERASER_OK if valid
229ERASER_EXPORT
230eraserIsValidContext(E_IN ERASER_HANDLE);
231
232
233//error handler
234typedef DWORD (*EraserErrorHandler) (LPCTSTR /*filename*/, DWORD /*dwErrorCode*/, void* /*ctx*/, void* /*param*/);
235ERASER_EXPORT
236eraserSetErrorHandler(E_IN ERASER_HANDLE, EraserErrorHandler pfn, void* fnParam);
237
238// Data type
239//
240
241// sets context data type
242ERASER_EXPORT
243eraserSetDataType(E_IN ERASER_HANDLE, E_IN ERASER_DATA_TYPE);
244// returns context data type
245ERASER_EXPORT
246eraserGetDataType(E_IN ERASER_HANDLE, E_OUT ERASER_DATA_TYPE*);
247
248
249// Data
250//
251
252// adds item to the context data array
253ERASER_EXPORT
254eraserAddItem(E_IN ERASER_HANDLE, E_IN LPVOID, E_IN E_UINT16);
255
256//set finish action - flags for ExitWindowsEx
257
258ERASER_EXPORT
259eraserSetFinishAction(E_IN ERASER_HANDLE param1, E_IN DWORD action);
260// clears the context data array
261ERASER_EXPORT
262eraserClearItems(E_IN ERASER_HANDLE);
263
264
265// Notification
266//
267
268// sets the window to notify
269ERASER_EXPORT
270eraserSetWindow(E_IN ERASER_HANDLE, E_IN HWND);
271// returns the window
272ERASER_EXPORT
273eraserGetWindow(E_IN ERASER_HANDLE, E_OUT HWND*);
274// sets the window message
275ERASER_EXPORT
276eraserSetWindowMessage(E_IN ERASER_HANDLE, E_IN E_UINT32);
277// returns the window message
278ERASER_EXPORT
279eraserGetWindowMessage(E_IN ERASER_HANDLE, E_OUT E_PUINT32);
280
281
282// Statistics
283//
284
285// returns the erased area
286ERASER_EXPORT
287eraserStatGetArea(E_IN ERASER_HANDLE, E_OUT E_PUINT64);
288// returns the erased cluster tip area
289ERASER_EXPORT
290eraserStatGetTips(E_IN ERASER_HANDLE, E_OUT E_PUINT64);
291// returns the amount of data written
292ERASER_EXPORT
293eraserStatGetWiped(E_IN ERASER_HANDLE, E_OUT E_PUINT64);
294// returns the time used (ms)
295ERASER_EXPORT
296eraserStatGetTime(E_IN ERASER_HANDLE, E_OUT E_PUINT32);
297
298
299// Display
300//
301
302// returns what the UI should show (see above for flag descriptions)
303ERASER_EXPORT
304eraserDispFlags(E_IN ERASER_HANDLE, E_OUT E_PUINT8);
305
306
307// Progress information
308//
309
310// returns an estimate of how long the operation takes to complete
311ERASER_EXPORT
312eraserProgGetTimeLeft(E_IN ERASER_HANDLE, E_OUT E_PUINT32);
313// returns the completion percent of current item
314ERASER_EXPORT
315eraserProgGetPercent(E_IN ERASER_HANDLE, E_OUT E_PUINT8);
316// returns the completion percent of the operation
317ERASER_EXPORT
318eraserProgGetTotalPercent(E_IN ERASER_HANDLE, E_OUT E_PUINT8);
319// returns the index of the current overwriting pass
320ERASER_EXPORT
321eraserProgGetCurrentPass(E_IN ERASER_HANDLE, E_OUT E_PUINT16);
322// returns the amount of passes
323ERASER_EXPORT
324eraserProgGetPasses(E_IN ERASER_HANDLE, E_OUT E_PUINT16);
325// returns a message UI can to show to the user telling what is going on
326ERASER_EXPORT
327eraserProgGetMessage(E_IN ERASER_HANDLE, E_OUT LPVOID, E_INOUT E_PUINT16);
328// returns the name of the item that is being processed
329ERASER_EXPORT
330eraserProgGetCurrentDataString(E_IN ERASER_HANDLE, E_OUT LPVOID, E_INOUT E_PUINT16);
331
332
333
334// Control
335//
336
337// starts overwriting in a new thread
338ERASER_EXPORT
339eraserStart(E_IN ERASER_HANDLE);
340// starts overwriting
341ERASER_EXPORT
342eraserStartSync(E_IN ERASER_HANDLE);
343// stops running task
344ERASER_EXPORT
345eraserStop(E_IN ERASER_HANDLE);
346// checks whether task is being processed
347ERASER_EXPORT
348eraserIsRunning(E_IN ERASER_HANDLE, E_OUT E_PUINT8);
349
350
351// Result
352//
353
354// checks whether the task was completed successfully
355ERASER_EXPORT
356eraserCompleted(E_IN ERASER_HANDLE, E_OUT E_PUINT8);
357// checks whether the task failed
358ERASER_EXPORT
359eraserFailed(E_IN ERASER_HANDLE, E_OUT E_PUINT8);
360// checks whether the task was terminated
361ERASER_EXPORT
362eraserTerminated(E_IN ERASER_HANDLE, E_OUT E_PUINT8);
363// returns the amount of error messages in the context array
364ERASER_EXPORT
365eraserErrorStringCount(E_IN ERASER_HANDLE, E_OUT E_PUINT16);
366// retrieves the given error message from the array
367ERASER_EXPORT
368eraserErrorString(E_IN ERASER_HANDLE, E_IN E_UINT16, E_OUT LPVOID, E_INOUT E_PUINT16);
369// returns the amount of failed items in the context array
370ERASER_EXPORT
371eraserFailedCount(E_IN ERASER_HANDLE, E_OUT E_PUINT32);
372// retrieves the given failed item from the array
373ERASER_EXPORT
374eraserFailedString(E_IN ERASER_HANDLE, E_IN E_UINT32, E_OUT LPVOID, E_INOUT E_PUINT16);
375
376
377// Display report
378//
379
380// displays erasing report
381ERASER_EXPORT
382eraserShowReport(E_IN ERASER_HANDLE, E_IN HWND);
383
384
385// Display library options
386//
387
388// displays the options window
389ERASER_EXPORT
390eraserShowOptions(E_IN HWND, E_IN ERASER_OPTIONS_PAGE);
391
392
393// File / directory deletion
394//
395
396// removes a file
397ERASER_EXPORT
398eraserRemoveFile(E_IN LPVOID, E_IN E_UINT16);
399// removes a folder
400ERASER_EXPORT
401eraserRemoveFolder(E_IN LPVOID, E_IN E_UINT16, E_IN E_UINT8);
402
403
404// Helpers
405//
406
407// returns the amount of free disk space on a drive
408ERASER_EXPORT
409eraserGetFreeDiskSpace(E_IN LPVOID, E_IN E_UINT16, E_OUT E_PUINT64);
410
411// returns the cluster size of a partition
412ERASER_EXPORT
413eraserGetClusterSize(E_IN LPVOID, E_IN E_UINT16, E_OUT E_PUINT32);
414
415
416// Test mode
417//
418
419// enables test mode --> files will be opened with sharing enabled
420// and erasing process will be paused after each overwriting pass
421// until eraserTestContinueProcess(...) is called for the handle
422ERASER_EXPORT
423eraserTestEnable(E_IN ERASER_HANDLE);
424
425// continues paused erasing process in test mode
426ERASER_EXPORT
427eraserTestContinueProcess(E_IN ERASER_HANDLE);
428
429
430#if defined(__cplusplus)
431}
432#endif
433
434
435// Helper definitions
436//
437#ifdef DEBUG
438    #define NODEFAULT ASSERT(0)
439#else
440    #define NODEFAULT __assume(0)
441#endif
442
443// "." or ".."
444#define ISNT_SUBFOLDER(lpsz) \
445    ((lpsz)[0] == _T('.') && \
446     ((lpsz)[1] == _T('\0') || \
447      ((lpsz)[1] == _T('.') && \
448       (lpsz)[2] == _T('\0'))))
449#define IS_SUBFOLDER(lpsz) \
450    (!ISNT_SUBFOLDER(lpsz))
451
452// bit mask operations
453//
454#define bitSet(x, mask) \
455    (((x) & (mask)) != 0)
456#define setBit(x, mask) \
457    (x) |= (mask)
458#define unsetBit(x, mask) \
459    (x) &= ~(mask)
460
461// Library internal header file
462//
463#ifdef _DLL_ERASER
464    #include "EraserDllInternal.h"
465#endif
466
467#endif // ERASERDLL_H
Note: See TracBrowser for help on using the repository browser.