• [psp][lumines]dat数据包解包程序


    看上去蛮简单的。包内每个文件开头都有一个16*n个字节的头。接下去是不加密的文件。文件连续排放。

    #include <stdio.h>
    #include 
    <string.h>
    #include 
    <stdlib.h>
    #include 
    <assert.h>

    struct PkHead
    {
        unsigned 
    short a;
        unsigned 
    short namelen;
        
    char b[8];
        unsigned 
    long filelen;
        
    char filename[256];
    }
    ;

    void bulidpath(const char *path)
    {
        
    char buf[256], *name, *next, buf2[256], cmd[256];

        strncpy(buf, path, 
    255);
        name 
    = strtok(buf, "/\\");
        sprintf(buf2, 
    ".", name);
        
    while(name)
        
    {
            next 
    = strtok(NULL, "/\\");
            
    if (next == NULL)
                
    break;
            FILE 
    *fp;
            sprintf(cmd, 
    "%s/%s", buf2, name);
            fp 
    = fopen(cmd, "rb");
            
    if (fp == NULL)
            
    {
                sprintf(cmd, 
    "md %s\\%s", buf2, name);
                system(cmd);
            }

            
    else fclose(fp);
            strcat(buf2, 
    "\\");
            strcat(buf2, name);
            assert(strlen(buf2) 
    < 255);
            name 
    = next;
        }

    }

    int main(int argc, char *argv[])
    {
        
    char filename[256];
        
    if (argc != 3)
        
    {
            fprintf(stderr, 
    "Usage: luconv  ");
            
    return 0;
        }

        FILE 
    *fp = fopen(argv[1], "rb");
        
    while(!feof(fp))
        
    {
            PkHead head;
            
    if (fread(&head.a, sizeof(unsigned short), 1, fp) != 1)
                
    break;
            
    if (head.a < 2)
                
    break;
            
    if (fread(((char*)&head) + sizeof(unsigned short), head.a - sizeof(unsigned short), 1, fp) != 1)
                
    break;
            sprintf(filename, 
    "%s/%s", argv[2], head.filename);
            bulidpath(filename);
            FILE 
    *= fopen(filename, "wb");
            
    if (f)
            
    {
                
    int size = head.filelen;
                
    while(size--)
                
    {
                    fputc(fgetc(fp), f);
                }

                fclose(f);
            }

            
    else fseek(fp, head.filelen, SEEK_CUR);
        }

        fclose(fp);
        
    return 0;
    }
  • 相关阅读:
    NSURLSessionDataDelegate 文件下载
    NSURLConnection 大文件下载
    全屏滑动
    qq粒子效果
    iOS 技巧
    iOS 15 新特性适配
    iOS 字符串转json 字符串转数组
    iOS 微信分享显示未验证应用2
    iOS 微信分享显示未验证应用1
    iOS 隐藏系统音量提示框
  • 原文地址:https://www.cnblogs.com/kaikai/p/189994.html
Copyright © 2020-2023  润新知