EUA / wxHexEditor

wxHexEditor official GIT repo
http://www.wxhexeditor.org
GNU General Public License v2.0
546 stars 118 forks source link

Save as Dump doesn't work with large dumps on MacOS v0.24 #94

Closed jerryjeremiah closed 4 years ago

jerryjeremiah commented 6 years ago

Thanks so much for implementing the Save as Dump function - it is exactly what I need. Unfortunately it doesn't work right with large dumps. I am trying to extract a 3.8TB section of bytes and save them to another disk as a file. I set the block start and end with no problem and then I fill the Save as Dump dialog and press Save. Depending on the size of the selection one of the following happens:

The destination disk is an empty 5TB disk so it isn't a disk space issue. The crashing makes sense maybe but how can it save 1.08GB out of 3.8TB and not know that it didm't work I think it really believes it saved the whole range of bytes...

EUA commented 6 years ago

I believe it's not OSX depended. "Save as dump" is developed for dumping "small chunks" of file. Not something to work with GB of data. Probably it tries to copy section to memory. Since there are not enough memory to do that, it gives error.

Well, I can put file size warning for quick fix. Or just code to allow big data sections.

jerryjeremiah commented 6 years ago

I have an MacOs drive that had a 3.8TB TrueCrypt file and I was trying to back up that file to another disk. I accidentally got the two disks swapped and started to write over the file instead of backing it up. I quickly stopped the copy so not much (maybe none?) of the file's data is overwritten but there is no directory entry for the file so there is no way to open it If I can make a file out of the data I maybe able to recover the data.

By searching the physical disk I have found the start and end of the data I wish to become a file again. I thought I could just select the data and save it to another disk so I was using the Mark Block Start, Mark Block End and Save as Dump function as was suggested in https://sourceforge.net/p/wxhexeditor/bugs/90/.

If that won't work, what feature of the product should I attempt to use to solve my problem?

EUA commented 6 years ago

I don't think if any feature of wxHexEditor help you in this situation except fix this error.

jerryjeremiah commented 6 years ago

Because of my inability ( https://github.com/EUA/wxHexEditor/issues/74 ) to compile the code and have a completely working executable (still not sure why) I can't do this myself but here is a diff (that I can't test) that would add this ability to SaveAsDump():

$diff HexEditor.original.cpp HexEditor.new.cpp
602,611c602,626
<          int rd;
<          wxMemoryBuffer m_buffer;
<          void* buff=NULL;
<           buff = m_buffer.GetWriteBuf( select->GetSize() );
< 
<           myfile->Seek( select->GetStart(), wxFromStart);
<           rd = myfile->Read( static_cast< char*>( buff ), select->GetSize() );
< 
<           m_buffer.UngetWriteBuf( rd );
<           savefile.Write( m_buffer.GetData(), rd );
---
>           wxMemoryBuffer m_buffer;
>           void* buff = NULL;
>           wxLongLong next = 0;
>                         wxFileOffset current = select->GetStart();
>                         size_t read, size = 100000000;
>           int i = 1, max = select->GetSize() / size + 1;
>           bool abort = false;
> 
>           wxProgressDialog progress("Save As Dump", "Saving...", max, this, wxPD_APP_MODAL | wxPD_CAN_ABORT );
>           progress.Show();
>           for(; i<=max && !abort; i++ ) {
>               if ( i == max ) size = select->GetSize() % size;
>               std::cout << "Reading " << size << " bytes starting at " << current << std::endl ;
>               buff = m_buffer.GetWriteBuf( size );
>               myfile->Seek( current, wxFromStart );
>               read = myfile->Read( static_cast< char*>( buff ), size );
>               m_buffer.UngetWriteBuf( read );
>               std::cout << "Saving " << read << " bytes" << std::endl ;
>               savefile.Write( m_buffer.GetData(), read );
>               current += read;
>               if(wxGetLocalTimeMillis() > next) {
>                   abort = !progress.Update( (int)i, wxString::Format("Saving... %.1f%%", 1.0*i/max) );
>                   next = wxGetLocalTimeMillis() + 200;   // 200ms = 5 updates per second
>               }
>           }
jerryjeremiah commented 6 years ago

Did that bit of code help?

jerryjeremiah commented 5 years ago

Did that bit of code help?

EUA commented 4 years ago

Hi. I don't inspect the code but probably, that code do the job.

Yesterday night, I installed catalina to VM, ( thanks to https://github.com/foxlet/macOS-Simple-KVM ) Will setup a compilation tools and send you fixed binary if you like.

Alternatively, why do you try to do it with Save as Dump option? You better to remove unneeded sections from your and use SaveAs function to save it to another file. PS:Now checked, since it's block device, program disable that option also. Anyway, patch is coming...

jerryjeremiah commented 4 years ago

I really appreciate your help. Will there be a new release soon?

EUA commented 4 years ago

I want to give a release now but there are some bugs. I don't estimate when. You can easily compile from source. If you can't, let me know. Thanks.