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

Revision 1110, 12.5 KB checked in by lowjoel, 5 years ago (diff)

fixed #49: Eraser 5 Unicode Support
Implemented tn123's patch with some minor changes. Thank you!

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