亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chm_lib.cpp

?? chm文件閱覽器的源代碼
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
/* $Id: chm_lib.c,v 1.18 2002/10/10 03:24:51 jedwin Exp $ */
/***************************************************************************
 *             chm_lib.c - CHM archive manipulation routines               *
 *                           -------------------                           *
 *                                                                         *
 *  author:     Jed Wing <jedwin@ugcs.caltech.edu>                         *
 *  version:    0.3                                                        *
 *  notes:      These routines are meant for the manipulation of microsoft *
 *              .chm (compiled html help) files, but may likely be used    *
 *              for the manipulation of any ITSS archive, if ever ITSS     *
 *              archives are used for any other purpose.                   *
 *                                                                         *
 *              Note also that the section names are statically handled.   *
 *              To be entirely correct, the section names should be read   *
 *              from the section names meta-file, and then the various     *
 *              content sections and the "transforms" to apply to the data *
 *              they contain should be inferred from the section name and  *
 *              the meta-files referenced using that name; however, all of *
 *              the files I've been able to get my hands on appear to have *
 *              only two sections: Uncompressed and MSCompressed.          *
 *              Additionally, the ITSS.DLL file included with Windows does *
 *              not appear to handle any different transforms than the     *
 *              simple LZX-transform.  Furthermore, the list of transforms *
 *              to apply is broken, in that only half the required space   *
 *              is allocated for the list.  (It appears as though the      *
 *              space is allocated for ASCII strings, but the strings are  *
 *              written as unicode.  As a result, only the first half of   *
 *              the string appears.)  So this is probably not too big of   *
 *              a deal, at least until CHM v4 (MS .lit files), which also  *
 *              incorporate encryption, of some description.               *
 *                                                                         *
 * switches:    CHM_MT:        compile library with thread-safety          *
 *                                                                         *
 * switches (Linux only):                                                  *
 *              CHM_USE_PREAD: compile library to use pread instead of     *
 *                             lseek/read                                  *
 *              CHM_USE_IO64:  compile library to support full 64-bit I/O  *
 *                             as is needed to properly deal with the      *
 *                             64-bit file offsets.                        *
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Lesser General Public License as        *
 *   published by the Free Software Foundation; either version 2.1 of the  *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include "chm_lib.h"
#include "lzx.h"

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

#include <windows.h>
#include <malloc.h>


#define CHM_NULL_FD (NULL)
#define CHM_CLOSE_FILE(fd) fclose((fd))

/*
 * defines related to tuning
 */
#ifndef CHM_MAX_BLOCKS_CACHED
#define CHM_MAX_BLOCKS_CACHED 5
#endif

static int ffs(unsigned int val)
{
        int bit=1, idx=1;
        while (bit != 0  &&  (val & bit) == 0)
        {
                bit <<= 1;
                ++idx;
        }
        if (bit == 0)
                return 0;
        else
                return idx;
}

/*
 * architecture specific defines
 *
 * Note: as soon as C99 is more widespread, the below defines should
 * probably just use the C99 sized-int types.
 *
 * The following settings will probably work for many platforms.  The sizes
 * don't have to be exactly correct, but the types must accommodate at least as
 * many bits as they specify.
 */

/* i386, 32-bit, Windows */

typedef unsigned char           UChar;
typedef __int16                 Int16;
typedef unsigned __int16        UInt16;
typedef __int32                 Int32;
typedef unsigned __int32        UInt32;
typedef __int64                 Int64;
typedef unsigned __int64        UInt64;

/* utilities for unmarshalling data */
static int _unmarshal_char_array(unsigned char **pData,
                                 unsigned long *pLenRemain,
                                 char *dest,
                                 int count)
{
    if (count <= 0  ||  (unsigned int)count > *pLenRemain)
        return 0;
    memcpy(dest, (*pData), count);
    *pData += count;
    *pLenRemain -= count;
    return 1;
}

static int _unmarshal_uchar_array(unsigned char **pData,
                                  unsigned long *pLenRemain,
                                  unsigned char *dest,
                                  int count)
{
        if (count <= 0  ||  (unsigned int)count > *pLenRemain)
        return 0;
    memcpy(dest, (*pData), count);
    *pData += count;
    *pLenRemain -= count;
    return 1;
}

static int _unmarshal_int16(unsigned char **pData,
                            unsigned long *pLenRemain,
                            Int16 *dest)
{
    if (2 > *pLenRemain)
        return 0;
    *dest = (*pData)[0] | (*pData)[1]<<8;
    *pData += 2;
    *pLenRemain -= 2;
    return 1;
}

static int _unmarshal_uint16(unsigned char **pData,
                             unsigned long *pLenRemain,
                             UInt16 *dest)
{
    if (2 > *pLenRemain)
        return 0;
    *dest = (*pData)[0] | (*pData)[1]<<8;
    *pData += 2;
    *pLenRemain -= 2;
    return 1;
}

static int _unmarshal_int32(unsigned char **pData,
                            unsigned long *pLenRemain,
                            Int32 *dest)
{
    if (4 > *pLenRemain)
        return 0;
    *dest = (*pData)[0] | (*pData)[1]<<8 | (*pData)[2]<<16 | (*pData)[3]<<24;
    *pData += 4;
    *pLenRemain -= 4;
    return 1;
}

static int _unmarshal_uint32(unsigned char **pData,
                             unsigned long *pLenRemain,
                             UInt32 *dest)
{
    if (4 > *pLenRemain)
        return 0;
    *dest = (*pData)[0] | (*pData)[1]<<8 | (*pData)[2]<<16 | (*pData)[3]<<24;
    *pData += 4;
    *pLenRemain -= 4;
    return 1;
}

static int _unmarshal_int64(unsigned char **pData,
                            unsigned long *pLenRemain,
                            Int64 *dest)
{
    Int64 temp;
    int i;
    if (8 > *pLenRemain)
        return 0;
    temp=0;
    for(i=8; i>0; i--)
    {
        temp <<= 8;
        temp |= (*pData)[i-1];
    }
    *dest = temp;
    *pData += 8;
    *pLenRemain -= 8;
    return 1;
}

static int _unmarshal_uint64(unsigned char **pData,
                             unsigned long *pLenRemain,
                             UInt64 *dest)
{
    UInt64 temp;
    int i;
    if (8 > *pLenRemain)
        return 0;
    temp=0;
    for(i=8; i>0; i--)
    {
        temp <<= 8;
        temp |= (*pData)[i-1];
    }
    *dest = temp;
    *pData += 8;
    *pLenRemain -= 8;
    return 1;
}

static int _unmarshal_uuid(unsigned char **pData,
                           unsigned long *pDataLen,
                           unsigned char *dest)
{
    return _unmarshal_uchar_array(pData, pDataLen, dest, 16);
}

/* names of sections essential to decompression */
static const char _CHMU_RESET_TABLE[] =
        "::DataSpace/Storage/MSCompressed/Transform/"
        "{7FC28940-9D31-11D0-9B27-00A0C91E9C7C}/"
        "InstanceData/ResetTable";
static const char _CHMU_LZXC_CONTROLDATA[] =
        "::DataSpace/Storage/MSCompressed/ControlData";
static const char _CHMU_CONTENT[] =
        "::DataSpace/Storage/MSCompressed/Content";
static const char _CHMU_SPANINFO[] =
        "::DataSpace/Storage/MSCompressed/SpanInfo";

/*
 * structures local to this module
 */

/* structure of ITSF headers */
#define _CHM_ITSF_V2_LEN (0x58)
#define _CHM_ITSF_V3_LEN (0x60)
struct chmItsfHeader
{
    char        signature[4];           /*  0 (ITSF) */
    Int32       version;                /*  4 */
    Int32       header_len;             /*  8 */
    Int32       unknown_000c;           /*  c */
    UInt32      last_modified;          /* 10 */
    UInt32      lang_id;                /* 14 */
    UChar       dir_uuid[16];           /* 18 */
    UChar       stream_uuid[16];        /* 28 */
    UInt64      unknown_offset;         /* 38 */
    UInt64      unknown_len;            /* 40 */
    UInt64      dir_offset;             /* 48 */
    UInt64      dir_len;                /* 50 */
    UInt64      data_offset;            /* 58 (Not present before V3) */
}; /* __attribute__ ((aligned (1))); */

static int _unmarshal_itsf_header(unsigned char **pData,
                                  unsigned long *pDataLen,
                                  struct chmItsfHeader *dest)
{
    /* we only know how to deal with the 0x58 and 0x60 byte structures */
    if (*pDataLen != _CHM_ITSF_V2_LEN  &&  *pDataLen != _CHM_ITSF_V3_LEN)
        return 0;

    /* unmarshal common fields */
    _unmarshal_char_array(pData, pDataLen,  dest->signature, 4);
    _unmarshal_int32     (pData, pDataLen, &dest->version);
    _unmarshal_int32     (pData, pDataLen, &dest->header_len);
    _unmarshal_int32     (pData, pDataLen, &dest->unknown_000c);
    _unmarshal_uint32    (pData, pDataLen, &dest->last_modified);
    _unmarshal_uint32    (pData, pDataLen, &dest->lang_id);
    _unmarshal_uuid      (pData, pDataLen,  dest->dir_uuid);
    _unmarshal_uuid      (pData, pDataLen,  dest->stream_uuid);
    _unmarshal_uint64    (pData, pDataLen, &dest->unknown_offset);
    _unmarshal_uint64    (pData, pDataLen, &dest->unknown_len);
    _unmarshal_uint64    (pData, pDataLen, &dest->dir_offset);
    _unmarshal_uint64    (pData, pDataLen, &dest->dir_len);

    /* error check the data */
    /* XXX: should also check UUIDs, probably, though with a version 3 file,
     * current MS tools do not seem to use them.
     */
    if (memcmp(dest->signature, "ITSF", 4) != 0)
        return 0;
    if (dest->version == 2)
    {
        if (dest->header_len < _CHM_ITSF_V2_LEN)
            return 0;
    }
    else if (dest->version == 3)
    {
        if (dest->header_len < _CHM_ITSF_V3_LEN)
            return 0;
    }
    else
        return 0;

    /* now, if we have a V3 structure, unmarshal the rest.
     * otherwise, compute it
     */
    if (dest->version == 3)
    {
        if (*pDataLen != 0)
            _unmarshal_uint64(pData, pDataLen, &dest->data_offset);
        else
            return 0;
    }
    else
        dest->data_offset = dest->dir_offset + dest->dir_len;

    return 1;
}

/* structure of ITSP headers */
#define _CHM_ITSP_V1_LEN (0x54)
struct chmItspHeader
{
    char        signature[4];           /*  0 (ITSP) */
    Int32       version;                /*  4 */
    Int32       header_len;             /*  8 */
    Int32       unknown_000c;           /*  c */
    UInt32      block_len;              /* 10 */
    Int32       blockidx_intvl;         /* 14 */
    Int32       index_depth;            /* 18 */
    Int32       index_root;             /* 1c */
    Int32       index_head;             /* 20 */
    Int32       unknown_0024;           /* 24 */
    UInt32      num_blocks;             /* 28 */
    Int32       unknown_002c;           /* 2c */
    UInt32      lang_id;                /* 30 */
    UChar       system_uuid[16];        /* 34 */
    UChar       unknown_0044[16];       /* 44 */
}; /* __attribute__ ((aligned (1))); */

static int _unmarshal_itsp_header(unsigned char **pData,
                                  unsigned long *pDataLen,
                                  struct chmItspHeader *dest)
{
    /* we only know how to deal with a 0x54 byte structures */
    if (*pDataLen != _CHM_ITSP_V1_LEN)
        return 0;

    /* unmarshal fields */
    _unmarshal_char_array(pData, pDataLen,  dest->signature, 4);
    _unmarshal_int32     (pData, pDataLen, &dest->version);
    _unmarshal_int32     (pData, pDataLen, &dest->header_len);
    _unmarshal_int32     (pData, pDataLen, &dest->unknown_000c);
    _unmarshal_uint32    (pData, pDataLen, &dest->block_len);
    _unmarshal_int32     (pData, pDataLen, &dest->blockidx_intvl);
    _unmarshal_int32     (pData, pDataLen, &dest->index_depth);
    _unmarshal_int32     (pData, pDataLen, &dest->index_root);
    _unmarshal_int32     (pData, pDataLen, &dest->index_head);
    _unmarshal_int32     (pData, pDataLen, &dest->unknown_0024);
    _unmarshal_uint32    (pData, pDataLen, &dest->num_blocks);
    _unmarshal_int32     (pData, pDataLen, &dest->unknown_002c);
    _unmarshal_uint32    (pData, pDataLen, &dest->lang_id);
    _unmarshal_uuid      (pData, pDataLen,  dest->system_uuid);
    _unmarshal_uchar_array(pData, pDataLen, dest->unknown_0044, 16);

    /* error check the data */
    if (memcmp(dest->signature, "ITSP", 4) != 0)
        return 0;
    if (dest->version != 1)
        return 0;
    if (dest->header_len != _CHM_ITSP_V1_LEN)
        return 0;

    return 1;
}

/* structure of PMGL headers */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区啦啦啦在线观看| 一区二区三区免费| 国产精品一区二区无线| 日韩精品一区国产麻豆| 激情欧美一区二区三区在线观看| 日韩视频123| 韩国欧美一区二区| 久久久久久久久蜜桃| 国产69精品久久久久777| 国产色综合久久| 成人午夜av电影| 一区二区在线免费观看| 欧美体内she精视频| 日本成人在线看| 日本一区二区免费在线| 97se亚洲国产综合在线| 五月婷婷综合在线| 精品粉嫩aⅴ一区二区三区四区| 国产在线不卡一区| 亚洲欧美在线视频观看| 欧美视频第二页| 久久99精品国产.久久久久 | 国产九色sp调教91| 国产精品护士白丝一区av| 欧美日韩久久一区| 国产成人啪免费观看软件| 亚洲人123区| 精品91自产拍在线观看一区| av成人免费在线| 爽爽淫人综合网网站| 国产喂奶挤奶一区二区三区| 欧美日韩免费视频| 国产成人aaa| 日韩精品一区第一页| 国产精品成人免费| 日韩一区二区中文字幕| 91免费看`日韩一区二区| 免费不卡在线视频| 亚洲高清一区二区三区| 久久精品免视看| 69av一区二区三区| 99久久久无码国产精品| 久久精品国内一区二区三区| 亚洲欧美日韩系列| 国产午夜精品一区二区三区四区| 在线视频国产一区| 国产91精品入口| 久久精品久久久精品美女| 亚洲成人综合在线| 亚洲欧美日韩在线不卡| 国产欧美日韩精品在线| 欧美电影免费观看高清完整版在 | 在线视频亚洲一区| 国产精品亚洲专一区二区三区 | 欧美激情一区二区三区全黄| 这里只有精品电影| 在线免费观看视频一区| 99久久婷婷国产精品综合| 精品无人区卡一卡二卡三乱码免费卡| 亚洲国产成人精品视频| 亚洲欧美国产77777| 国产精品久久久久永久免费观看| 久久夜色精品国产欧美乱极品| 欧美精品123区| 欧美日韩在线三区| 在线观看av一区| 91亚洲国产成人精品一区二三| 国产精华液一区二区三区| 美脚の诱脚舐め脚责91| 蜜臀91精品一区二区三区| 午夜精品视频一区| 亚洲成av人片在www色猫咪| 亚洲综合色成人| 亚洲一区二区三区中文字幕| 亚洲影视资源网| 一区二区三区国产精华| 一区二区三区在线影院| 亚洲欧美日韩国产综合| 亚洲欧美一区二区三区极速播放 | 日韩午夜av电影| 日韩免费电影一区| 欧美tickle裸体挠脚心vk| 日韩欧美一级在线播放| 欧美xxx久久| 国产午夜精品一区二区| 国产免费观看久久| 国产精品久久看| 亚洲人妖av一区二区| 亚洲专区一二三| 亚洲一区二区免费视频| 日韩主播视频在线| 久久国产精品免费| 国产成人欧美日韩在线电影| 97se亚洲国产综合自在线不卡 | 免费在线观看日韩欧美| 麻豆久久久久久| 国产乱人伦偷精品视频不卡| 成人va在线观看| 日本精品免费观看高清观看| 欧美日韩精品福利| 精品少妇一区二区三区视频免付费 | 国产成人免费在线观看不卡| 国产suv精品一区二区三区| 波多野结衣视频一区| 在线观看一区不卡| 日韩手机在线导航| 国产精品视频看| 亚洲成人动漫在线免费观看| 久久电影网电视剧免费观看| 成人综合在线观看| 欧美日韩中字一区| 国产日韩欧美综合在线| 亚洲精品日韩一| 精品一区二区日韩| 一本一道久久a久久精品综合蜜臀| 欧美色区777第一页| 日韩午夜在线播放| 中文字幕一区二区三区在线不卡| 亚洲成人激情社区| 国产成人午夜99999| 欧美日韩激情一区| 国产日产精品1区| 亚洲午夜一区二区三区| 韩国欧美一区二区| 在线日韩av片| 国产欧美一区二区三区网站| 亚洲一区二区三区在线| 丁香婷婷综合五月| 在线电影一区二区三区| 国产偷国产偷精品高清尤物 | 国产综合色视频| 欧美日韩在线播放三区四区| 国产色综合一区| 久久精品免费观看| 在线免费一区三区| 国产精品久久久99| 久久se精品一区二区| 欧美日韩国产天堂| ...av二区三区久久精品| 国产综合色精品一区二区三区| 欧美日韩国产在线观看| 中文字幕在线免费不卡| 激情图区综合网| 欧美酷刑日本凌虐凌虐| 1区2区3区国产精品| 老司机午夜精品| 欧美日韩一区视频| 亚洲视频中文字幕| 成人自拍视频在线| 精品国内片67194| 日本不卡的三区四区五区| 91成人免费网站| 一区二区久久久| 色天使久久综合网天天| 亚洲人吸女人奶水| 91在线一区二区三区| 国产精品沙发午睡系列990531| 九九国产精品视频| 日韩视频一区二区三区在线播放 | xnxx国产精品| 麻豆精品国产91久久久久久| 欧美剧情电影在线观看完整版免费励志电影 | 视频一区二区欧美| 欧美日韩精品福利| 天天影视色香欲综合网老头| 欧美性猛片aaaaaaa做受| 亚洲精品久久7777| 91麻豆.com| 亚洲卡通欧美制服中文| 91浏览器入口在线观看| 亚洲欧美国产三级| 欧美熟乱第一页| 亚洲一区国产视频| 欧美日韩一区二区三区在线看| 亚洲一区电影777| 欧美日韩国产成人在线免费| 亚洲第一主播视频| 91精品黄色片免费大全| 裸体在线国模精品偷拍| 欧美成人猛片aaaaaaa| 国产一区二区毛片| 中文字幕第一区| 色综合久久久久| 亚洲成av人片| 精品av久久707| av爱爱亚洲一区| 亚洲激情自拍偷拍| 欧美狂野另类xxxxoooo| 国产一区二区三区综合 | 亚洲精品日产精品乱码不卡| 欧美日韩在线播放一区| 精品在线播放免费| 国产精品天天看| 色婷婷久久综合| 免费视频最近日韩| 欧美激情一区二区三区全黄| 91高清视频免费看| 精品无人码麻豆乱码1区2区| 中文字幕五月欧美| 91精品国产综合久久精品性色|