Jump to content

FileWipe - very fast (using memory mapped files + memset)


Zedna
 Share

Recommended Posts

Is there a way to get this to write files over 2gb or ram?

I really like this one ;), but some points came to my mind. Better use _Winapi_FileGetSizeEx to pass the 2 GB limit. Also I would recommend to process larger files in a loop, as the files are mapped to the process address space and thus large files are likely to consume too much RAM (up to crashing the script). My post on " should contain all required details for that.

Link to comment
Share on other sites

  • 2 years later...

Only your test version works for me:

Is it considered safe, so the files can't be recovered with such software as recuva?

Func FileWipe($sFileName, $nByte = 0x0)
    If Not FileExists($sFileName) Then Return
    $iSize = FileGetSize($sFileName)
    $tBuffer = DLLStructCreate("byte[" & $iSize & "]")
    MemSet(DLLStructGetPtr($tBuffer), $nByte, $iSize)
    $hFile = _WinAPI_CreateFile($sFileName, 2, 6)
    _WinAPI_WriteFile($hFile, DLLStructGetPtr($tBuffer), $iSize, $iSize)
    _WinAPI_CloseHandle($hFile)
    FileDelete($sFileName)
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...