void extractRestoreFiles( string filepath, bool known ) { cout << "Extracting restore files" << endl; CZipArchive zip; ZIP_INDEX_TYPE index; try { zip.Open(_T(filepath.c_str())); cout << "Extracting ramdisk" << endl; if( known ) { index = zip.FindFile(_T("694-5259-38.dmg")); zip.ExtractFile(index, _T(cwd.c_str())); ramdisk = (cwd + "/694-5259-38.dmg"); } else { CZipIndexesArray indexes; zip.FindMatches(_T("*.dmg"), indexes, false); for (ZIP_ARRAY_SIZE_TYPE i = 0; i < indexes.GetCount(); i++) { ZIP_INDEX_TYPE ind = indexes[i]; if(zip[ind]->m_uUncomprSize > (10*1024*1024) && zip[ind]->m_uUncomprSize < (20*1024*1024) ) { zip.ExtractFile(ind, _T(cwd.c_str())); FILE *f = fopen((cwd + "/" + zip[ind]->GetFileName()).c_str(), "rb"); if(!f) { continue; } else { unsigned char magic[4]; fread(magic, 1, 4, f); if( magic[0] == 0x38 && magic[1] == 0x39 && magic[2] == 0x30 && magic[3] == 0x30 ) { ramdisk = cwd + "/" + zip[ind]->GetFileName(); fclose(f); break; } fclose(f); } } } } cout << "Extracting kernelcache" << endl; if(known) { index = zip.FindFile(_T("kernelcache.restore.release.s5l8900xrb")); zip.ExtractFile(index, _T(cwd.c_str())); kernelcache = (cwd + "/kernelcache.restore.release.s5l8900xrb"); } else { CZipIndexesArray indexes; zip.FindMatches (_T("*kernelcache*"), indexes, false); if(indexes.GetCount() > 0) { zip.ExtractFile(indexes[0], _T(cwd.c_str())); kernelcache = cwd + "/" + zip[indexes[0]]->GetFileName(); } } zip.Close(); } catch(...) { cout << "Error extracting restore file" << endl; } }