| [2399] | 1 | Attribute VB_Name = "Module1" |
|---|
| 2 | ' EraserDll.bas |
|---|
| 3 | ' Header file for the Eraser Library. |
|---|
| 4 | ' |
|---|
| 5 | ' Eraser. Secure data removal. For Windows. |
|---|
| 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 | |
|---|
| 24 | ' wParam values |
|---|
| 25 | Public Const ERASER_WIPE_BEGIN = 0 |
|---|
| 26 | Public Const ERASER_WIPE_UPDATE = 1 |
|---|
| 27 | Public Const ERASER_WIPE_DONE = 2 |
|---|
| 28 | Public Const ERASER_TEST_PAUSED = 3 |
|---|
| 29 | |
|---|
| 30 | ' Library type definitions |
|---|
| 31 | |
|---|
| 32 | Public Enum ERASER_METHOD |
|---|
| 33 | ERASER_METHOD_LIBRARY |
|---|
| 34 | ERASER_METHOD_GUTMANN |
|---|
| 35 | ERASER_METHOD_DOD |
|---|
| 36 | ERASER_METHOD_PSEUDORANDOM |
|---|
| 37 | End Enum |
|---|
| 38 | |
|---|
| 39 | Public Enum ERASER_DATA_TYPE |
|---|
| 40 | ERASER_DATA_DRIVES |
|---|
| 41 | ERASER_DATA_FILES |
|---|
| 42 | End Enum |
|---|
| 43 | |
|---|
| 44 | Public Enum ERASER_OPTIONS_PAGE |
|---|
| 45 | ERASER_PAGE_DRIVE |
|---|
| 46 | ERASER_PAGE_FILES |
|---|
| 47 | End Enum |
|---|
| 48 | |
|---|
| 49 | ' eraserRemoveFolder options |
|---|
| 50 | Public Const ERASER_REMOVE_FOLDERONLY = 0 |
|---|
| 51 | Public Const ERASER_REMOVE_RECURSIVELY = 1 |
|---|
| 52 | |
|---|
| 53 | ' display flags |
|---|
| 54 | Public Const eraserDispPass = 1 ' Show pass information |
|---|
| 55 | Public Const eraserDispTime = 2 ' Show estimated time |
|---|
| 56 | Public Const eraserDispMessage = 4 ' [UNUSED] Show message |
|---|
| 57 | Public Const eraserDispProgress = 8 ' [UNUSED] Show progress bar |
|---|
| 58 | Public Const eraserDispStop = 16 ' [UNUSED] Allow termination |
|---|
| 59 | Public Const eraserDispItem = 32 ' [UNUSED] Show item name |
|---|
| 60 | Public Const eraserDispInit = 64 ' Set progress to 0 on ERASER_WIPE_BEGIN |
|---|
| 61 | Public Const eraserDispReserved = 128 ' [UNUSED] |
|---|
| 62 | |
|---|
| 63 | ' bit masks for items to erase |
|---|
| 64 | ' files |
|---|
| 65 | Public Const fileClusterTips = 1 |
|---|
| 66 | Public Const fileNames = 2 |
|---|
| 67 | Public Const fileAlternateStreams = 4 |
|---|
| 68 | ' unused disk space |
|---|
| 69 | Public Const diskFreeSpace = 32 |
|---|
| 70 | Public Const diskClusterTips = 64 |
|---|
| 71 | Public Const diskDirEntries = 128 |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | ' Error messages |
|---|
| 75 | Public Const ERASER_OK = 0 ' No error |
|---|
| 76 | Public Const ERASER_ERROR = -1 ' Unspecified error |
|---|
| 77 | Public Const ERASER_ERROR_PARAM1 = -2 ' Parameter 1 invalid |
|---|
| 78 | Public Const ERASER_ERROR_PARAM2 = -3 ' Parameter 2 invalid |
|---|
| 79 | Public Const ERASER_ERROR_PARAM3 = -4 ' Parameter 3 invalid |
|---|
| 80 | Public Const ERASER_ERROR_PARAM4 = -5 ' Parameter 4 invalid |
|---|
| 81 | Public Const ERASER_ERROR_PARAM5 = -6 ' Parameter 5 invalid |
|---|
| 82 | Public Const ERASER_ERROR_PARAM6 = -7 ' Parameter 6 invalid |
|---|
| 83 | Public Const ERASER_ERROR_MEMORY = -8 ' Out of memory |
|---|
| 84 | Public Const ERASER_ERROR_THREAD = -9 ' Failed to start thread |
|---|
| 85 | Public Const ERASER_ERROR_EXCEPTION = -10 ' BUG! |
|---|
| 86 | Public Const ERASER_ERROR_CONTEXT = -11 ' Context array full (ERASER_MAX_CONTEXT) |
|---|
| 87 | Public Const ERASER_ERROR_INIT = -12 ' Library not initialized (eraserInit()) |
|---|
| 88 | Public Const ERASER_ERROR_RUNNING = -13 ' Failed because the thread is running |
|---|
| 89 | Public Const ERASER_ERROR_NOTRUNNING = -14 ' Failed because the thread not running |
|---|
| 90 | Public Const ERASER_ERROR_DENIED = -15 ' Operation not permitted |
|---|
| 91 | Public Const ERASER_ERROR_NOTIMPLEMENTED = -32 ' Function not implemented |
|---|
| 92 | |
|---|
| 93 | ' Library initialization |
|---|
| 94 | |
|---|
| 95 | ' initializes the library, must be called before using |
|---|
| 96 | Public Declare Function eraserInit Lib "eraser.dll" () As Long |
|---|
| 97 | ' cleans up after use |
|---|
| 98 | Public Declare Function eraserEnd Lib "eraser.dll" () As Long |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | ' Context creation and destruction |
|---|
| 102 | |
|---|
| 103 | ' creates context with predefined settings |
|---|
| 104 | Public Declare Function eraserCreateContext Lib "eraser.dll" (ByRef Context As Long) As Long |
|---|
| 105 | ' creates context and sets an alternative method, pass count and items to erase |
|---|
| 106 | Public Declare Function eraserCreateContextEx Lib "eraser.dll" (ByRef Context As Long, ByVal Method As ERASER_METHOD, ByVal Passes As Integer, ByVal Items As Byte) As Long |
|---|
| 107 | ' destroys a context |
|---|
| 108 | Public Declare Function eraserDestroyContext Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 109 | ' checks the validity of a context, return ERASER_OK if valid |
|---|
| 110 | Public Declare Function eraserIsValidContext Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | ' Data type |
|---|
| 114 | |
|---|
| 115 | ' sets context data type |
|---|
| 116 | Public Declare Function eraserSetDataType Lib "eraser.dll" (ByVal Context As Long, ByVal DataType As ERASER_DATA_TYPE) As Long |
|---|
| 117 | ' returns context data type |
|---|
| 118 | Public Declare Function eraserGetDataType Lib "eraser.dll" (ByVal Context As Long, ByRef DataType As ERASER_DATA_TYPE) As Long |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | ' Data |
|---|
| 122 | |
|---|
| 123 | ' adds item to the context data array |
|---|
| 124 | Public Declare Function eraserAddItem Lib "eraser.dll" (ByVal Context As Long, ByVal FileName As String, ByVal NameLength As Integer) As Long |
|---|
| 125 | ' clears the context data array |
|---|
| 126 | Public Declare Function eraserClearItems Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | ' Notification |
|---|
| 130 | |
|---|
| 131 | ' sets the window to notify |
|---|
| 132 | Public Declare Function eraserSetWindow Lib "eraser.dll" (ByVal Context As Long, ByVal Hwnd As Long) As Long |
|---|
| 133 | ' returns the window |
|---|
| 134 | Public Declare Function eraserGetWindow Lib "eraser.dll" (ByVal Context As Long, ByRef Hwnd As Long) As Long |
|---|
| 135 | ' sets the window message |
|---|
| 136 | Public Declare Function eraserSetWindowMessage Lib "eraser.dll" (ByVal Context As Long, ByVal Message As Long) As Long |
|---|
| 137 | ' returns the window message |
|---|
| 138 | Public Declare Function eraserGetWindowMessage Lib "eraser.dll" (ByVal Context As Long, ByRef Message As Long) As Long |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | ' Statistics |
|---|
| 142 | |
|---|
| 143 | ' returns the erased area |
|---|
| 144 | Public Declare Function eraserStatGetArea Lib "eraser.dll" (ByVal Context As Long, ByRef Bytes As Long) As Long |
|---|
| 145 | ' returns the erased cluster tip area |
|---|
| 146 | Public Declare Function eraserStatGetTips Lib "eraser.dll" (ByVal Context As Long, ByRef Bytes As Long) As Long |
|---|
| 147 | ' returns the amount of data written |
|---|
| 148 | Public Declare Function eraserStatGetWiped Lib "eraser.dll" (ByVal Context As Long, ByRef Bytes As Long) As Long |
|---|
| 149 | ' returns the time used (ms) |
|---|
| 150 | Public Declare Function eraserStatGetTime Lib "eraser.dll" (ByVal Context As Long, ByRef MilliSeconds As Long) As Long |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | ' Display |
|---|
| 154 | |
|---|
| 155 | ' returns what the UI should show (see above for flag descriptions) |
|---|
| 156 | Public Declare Function eraserDispFlags Lib "eraser.dll" (ByVal Context As Long, ByRef Flags As Byte) As Long |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | ' Progress information |
|---|
| 160 | |
|---|
| 161 | ' returns an estimate of how long the operation takes to complete |
|---|
| 162 | Public Declare Function eraserProgGetTimeLeft Lib "eraser.dll" (ByVal Context As Long, ByRef Seconds As Long) As Long |
|---|
| 163 | ' returns the completion percent of current item |
|---|
| 164 | Public Declare Function eraserProgGetPercent Lib "eraser.dll" (ByVal Context As Long, ByRef Percent As Byte) As Long |
|---|
| 165 | ' returns the completion percent of the operation |
|---|
| 166 | Public Declare Function eraserProgGetTotalPercent Lib "eraser.dll" (ByVal Context As Long, ByRef Percent As Byte) As Long |
|---|
| 167 | ' returns the index of the current overwriting pass |
|---|
| 168 | Public Declare Function eraserProgGetCurrentPass Lib "eraser.dll" (ByVal Context As Long, ByRef Pass As Integer) As Long |
|---|
| 169 | ' returns the amount of passes |
|---|
| 170 | Public Declare Function eraserProgGetPasses Lib "eraser.dll" (ByVal Context As Long, ByRef Passes As Integer) As Long |
|---|
| 171 | ' returns a message UI can to show to the user telling what is going on |
|---|
| 172 | Public Declare Function eraserProgGetMessage Lib "eraser.dll" (ByVal Context As Long, ByRef Message As String, ByRef Length As Integer) As Long |
|---|
| 173 | ' returns the name of the item that is being processed |
|---|
| 174 | Public Declare Function eraserProgGetCurrentDataString Lib "eraser.dll" (ByVal Context As Long, ByRef Data As String, ByRef Length As Integer) As Long |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | ' Control |
|---|
| 178 | |
|---|
| 179 | ' starts overwriting in a new thread |
|---|
| 180 | Public Declare Function eraserStart Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 181 | ' starts overwriting |
|---|
| 182 | Public Declare Function eraserStartSync Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 183 | ' stops running task |
|---|
| 184 | Public Declare Function eraserStop Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 185 | ' checks whether task is being processed |
|---|
| 186 | Public Declare Function eraserIsRunning Lib "eraser.dll" (ByVal Context As Long, ByRef Running As Byte) As Long |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | ' Result |
|---|
| 190 | |
|---|
| 191 | ' checks whether the task was completed successfully |
|---|
| 192 | Public Declare Function eraserCompleted Lib "eraser.dll" (ByVal Context As Long, ByRef Completed As Byte) As Long |
|---|
| 193 | ' checks whether the task failed |
|---|
| 194 | Public Declare Function eraserFailed Lib "eraser.dll" (ByVal Context As Long, ByRef Failed As Byte) As Long |
|---|
| 195 | ' checks whether the task was terminated |
|---|
| 196 | Public Declare Function eraserTerminated Lib "eraser.dll" (ByVal Context As Long, ByRef Terminated As Byte) As Long |
|---|
| 197 | ' returns the amount of error messages in the context array |
|---|
| 198 | Public Declare Function eraserErrorStringCount Lib "eraser.dll" (ByVal Context As Long, ByRef Count As Integer) As Long |
|---|
| 199 | ' retrieves the given error message from the array |
|---|
| 200 | Public Declare Function eraserErrorString Lib "eraser.dll" (ByVal Context As Long, ByVal Index As Integer, ByRef Error As String, ByRef Length As Integer) As Long |
|---|
| 201 | ' returns the amount of failed items in the context array |
|---|
| 202 | Public Declare Function eraserFailedCount Lib "eraser.dll" (ByVal Context As Long, ByRef Count As Long) As Long |
|---|
| 203 | ' retrieves the given failed item from the array |
|---|
| 204 | Public Declare Function eraserFailedString Lib "eraser.dll" (ByVal Context As Long, ByVal Index As Long, ByRef Error As String, ByRef Length As Integer) As Long |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | ' Display report |
|---|
| 208 | |
|---|
| 209 | ' displays erasing report |
|---|
| 210 | Public Declare Function eraserShowReport Lib "eraser.dll" (ByVal Context As Long, ByVal Hwnd As Long) As Long |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | ' Display library options |
|---|
| 214 | |
|---|
| 215 | ' displays the options window |
|---|
| 216 | Public Declare Function eraserShowOptions Lib "eraser.dll" (ByVal Hwnd As Long, ByVal OptionsPage As ERASER_OPTIONS_PAGE) As Long |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | ' File / directory deletion |
|---|
| 220 | |
|---|
| 221 | ' removes a file |
|---|
| 222 | Public Declare Function eraserRemoveFile Lib "eraser.dll" (ByVal FileName As String, ByVal NameLength As Integer) As Long |
|---|
| 223 | ' removes a folder |
|---|
| 224 | Public Declare Function eraserRemoveFolder Lib "eraser.dll" (ByVal FolderName As String, ByVal NameLength As Integer, ByVal RemoveType As Byte) As Long |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | ' Helpers |
|---|
| 228 | |
|---|
| 229 | ' returns the amount of free disk space on a drive |
|---|
| 230 | Public Declare Function eraserGetFreeDiskSpace Lib "eraser.dll" (ByVal Drive As String, ByVal NameLength As Integer, ByRef FreeBytes As Long) As Long |
|---|
| 231 | |
|---|
| 232 | ' returns the cluster size of a partition |
|---|
| 233 | Public Declare Function eraserGetClusterSize Lib "eraser.dll" (ByVal Drive As String, ByVal NameLength As Integer, ByRef ClusterSize As Long) As Long |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | ' Test mode |
|---|
| 237 | |
|---|
| 238 | ' enables test mode --> files will be opened with sharing enabled |
|---|
| 239 | ' and erasing process will be paused after each overwriting pass |
|---|
| 240 | ' until eraserTestContinueProcess(...) is called for the handle |
|---|
| 241 | Public Declare Function eraserTestEnable Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 242 | |
|---|
| 243 | ' continues paused erasing process in test mode |
|---|
| 244 | Public Declare Function eraserTestContinueProcess Lib "eraser.dll" (ByVal Context As Long) As Long |
|---|
| 245 | |
|---|
| 246 | Public Function eraserOK(ByVal ReturnValue As Long) As Boolean |
|---|
| 247 | eraserOK = (ReturnValue >= ERASER_OK) |
|---|
| 248 | End Function |
|---|
| 249 | |
|---|
| 250 | Public Function eraserError(ByVal ReturnValue As Long) As Boolean |
|---|
| 251 | eraserError = (ReturnValue < ERASER_OK) |
|---|
| 252 | End Function |
|---|