//-------------------------------------------------------------------------- // Function: FloatType::decode ///\brief Returns an FloatType object via DataType* by decoding the /// binary object description of this type. ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - Aug 2017 //-------------------------------------------------------------------------- DataType* FloatType::decode() const { hid_t encoded_flttype_id = H5I_INVALID_HID; try { encoded_flttype_id = p_decode(); } catch (DataTypeIException &err) { throw; } FloatType *encoded_flttype = new FloatType; encoded_flttype->p_setId(encoded_flttype_id); return(encoded_flttype); }
int XP3SaveResource ( const HANDLE hFile, std::vector<file_entry>& Entry, const char *game, const wchar_t *cur_dir ) { _XOR_DECODE p_decode = (_XOR_DECODE)0x80000000; DWORD R, game_idx, offset_hi, cnt_savefile = 0; if (!strcmp(game, unencry_game)) // 决定解密使用的函数 p_decode = 0; else for (int i=0; i<sizeof(simple_xor_game)/sizeof(simple_xor_game[0]); ++i) if (!strcmp(game, simple_xor_game[i].name)) { p_decode = simple_xor_game[i].p_decode; game_idx = i; break; } for each(file_entry fe in Entry) { DWORD file_pkg_len = 0; DWORD file_org_len = 0; for (int i=0; i<fe.part; ++i) { file_pkg_len += (DWORD)fe.info[i].pkg_length; file_org_len += (DWORD)fe.info[i].orig_length; } DWORD file_read = 0; PBYTE cipher = (PBYTE)VirtualAlloc(NULL, file_pkg_len, MEM_COMMIT, PAGE_READWRITE); for (int i=0; i<fe.part; ++i) { offset_hi = (DWORD)(fe.info[i].offset >> 32); SetFilePointer(hFile, (DWORD)fe.info[i].offset, (PLONG)&offset_hi, FILE_BEGIN); ReadFile(hFile, cipher + file_read, (DWORD)fe.info[i].pkg_length, &R, NULL); file_read += (DWORD)fe.info[i].pkg_length; } PBYTE unpack = (PBYTE)VirtualAlloc(NULL, file_org_len, MEM_COMMIT, PAGE_READWRITE); DWORD unpack_len = (DWORD)file_org_len; DWORD unpack_offset = 0; if (fe.info[0].compress_flag) unCom(unpack, &unpack_len, cipher, file_pkg_len); else memcpy(unpack, cipher, file_org_len); //*****************************************************************************// do { if (!p_decode) break; else if (p_decode == (_XOR_DECODE)0x80000000) xp3filter_decode(const_cast<char*>(game), fe.file_name, unpack, file_org_len, unpack_offset, file_org_len, fe.checksum); else p_decode(fe.checksum, simple_xor_game[game_idx].extend_key, simple_xor_game[game_idx].offset, unpack, file_org_len); }while(0); //*****************************************************************************// if (!SplitFileNameAndSave(cur_dir, fe.file_name, unpack, file_org_len)) ++cnt_savefile; VirtualFree(unpack, 0, MEM_RELEASE); VirtualFree(cipher, 0, MEM_RELEASE); }