Japanese-style horizontal version of the shooting game "sky blue elexiaj" resource unpacking

Source: Internet
Author: User

-----------------------------------------------------------------------

!! Warning!!

Ownership of game resources, owned by the game developers;

The following unpacking algorithm is only for learning and communication, do not use for commercial and illegal purposes;

All the consequences of this have nothing to do with bloggers (me);

-----------------------------------------------------------------------

Needless to say, the game's pack is the name of the pack suffix, the memory layout is simple, first of all, a file information header:

1 struct Pack_file_header {2     Char 4 // KCAP 3      Short // Number of files 4     Char 2  ]; 5 };

The SIG is a 4-byte signature, which is always a four-letter KCAP, followed by a 2-byte file number;

This is followed by a sequential sequence of file information structures, defined as follows:

1 structPack_file_info {2     Charfile_name[ -];//file full path name3BYTE u1[8 ];4     intFile_data_pos_in_file;//Where the file data begins in the pack5     intFile_size;//File Data size6BYTE u2[4 ];7};

the above two structure, the member structure that starts with u, has not been explored the concrete function at present, the other members can see the concrete usage from the variable name, do not explain much;

1#include <stdio.h>2#include <string.h>3#include <Windows.h>4 5 structPack_file_header {6     Charsig[4];//KCAP7      ShortFile_number;//Number of files8     Charu1[2 ];9 };Ten  One structPack_file_info { A     Charfile_name[ -];//file full path name -BYTE u1[8 ]; -     intFile_data_pos_in_file;//Where the file data begins in the pack the     intFile_size;//File Data size -BYTE u2[4 ]; - }; -  + voidBuilddirectorypath (Const Char*_path) { -UnsignedintLen =:: strlen (_path); +     Char* Build_path =New Char[Len +1 ]; A      for(unsignedinti =0; i < Len; ++i) { atbuild_path[I] =_path[i]; -         if('\\'==build_path[i]) { -build_path[i +1] =' /'; - Createdirectorya (Build_path, nullptr); -         } -     } in } -  to Const Char* GetFileTitle (Const Char*_file_name) { +     Static Chartitle[ the] = {0 }; -memset (title,0,sizeof(title)); the      for(unsignedinti =0; I < strlen (_file_name); ++i) { *         if('.'==_file_name[i]) $              Break;Panax Notoginsengtitle[I] =_file_name[i]; -     } the     return(Const Char*) title; + } A  the voidExtrafile (FILE * _pack_file,Const Char* _pack_name, Pack_file_info *_file_info) { +File * File =nullptr; -BYTE * File_data =Newbyte[_file_info->File_size]; $     Charfull_path[ the] = {0 }; $  -sprintf_s (Full_path, the, -         "%s\\%s", the GetFileTitle (_pack_name), -_file_info->file_name);Wuyi Builddirectorypath (full_path); the  -printf"%s \ n", Full_path); Wufopen_s (& File, Full_path,"WB" ); -Fseek (_pack_file, _file_info->File_data_pos_in_file, seek_set); AboutFread (File_data,1, _file_info->file_size, _pack_file); $Fwrite (File_data,1, _file_info->file_size, file); -     Delete[] file_data; - fclose (file); - } A  + voidExtrapack (Const Char*_pack_name) { theFILE * Pack_file =nullptr; - Pack_file_header HEADER; $Pack_file_info * File_list =nullptr; the  theFopen_s (& Pack_file, _pack_name,"RB" ); the  the     //Read file header information -Fread ((void*) & Header,1,sizeof(Pack_file_header), pack_file); in  the     //Read file information theFile_list =Newpack_file_info[Header.file_number]; AboutFread ((void*) File_list,1,sizeof(pack_file_info) *Header.file_number, pack_file); the  the     //Unpack Files the      for( Shorti =0; i < Header.file_number; ++i) { +Extrafile (Pack_file, _pack_name, &file_list[i]); -     } the Bayi     Delete[] file_list; the fclose (pack_file); the } -  - intMainintargcChar*argv[]) { theExtrapack ("data2. Pack" ); theExtrapack ("data. Pack" ); the     return 0; the}

The above code is solved by the function extrapack () respectively data2. Pack and data. Pack two resource packs, the Extrafile () function is responsible for reading the file data from the pack, creating a complete directory structure and file, and then writing the data to the newly created file, GetFileTitle () The function can extract the title portion of a file that does not contain a suffix from a filename with a suffix, and the Builddirectorypath () function creates a complete directory chain from the given full file path;

The code is so much, the following shows the extracted resources:

There are also text files such as scripts:

Complete executable program will not give out, the resources can download the game, the program can create a new Win32 Console project, paste the above code, directly generated on the line;

The Ps:builddirectorypath () function forgot to delete the new Build_path variable, resulting in a lot of memory leaks after the program ran, and everyone manually added to it (laughter)

Japanese-style horizontal version of the shooting game "sky blue elexiaj" resource unpacking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.