70#define CHM_ACQUIRE_LOCK(a) do { \
71 EnterCriticalSection(&(a)); \
73#define CHM_RELEASE_LOCK(a) do { \
74 LeaveCriticalSection(&(a)); \
77#define CHM_NULL_FD (INVALID_HANDLE_VALUE)
78#define CHM_CLOSE_FILE(fd) CloseHandle((fd))
83#ifndef CHM_MAX_BLOCKS_CACHED
84#define CHM_MAX_BLOCKS_CACHED 5
86#define CHM_PARAM_MAX_BLOCKS_CACHED 0
110 unsigned int *pLenRemain,
114 if (
count <= 0 || (
unsigned int)
count > *pLenRemain)
118 *pLenRemain -=
count;
123 unsigned int *pLenRemain,
127 if (
count <= 0 || (
unsigned int)
count > *pLenRemain)
131 *pLenRemain -=
count;
136 unsigned int *pLenRemain,
141 *
dest = (*pData)[0] | (*pData)[1]<<8 | (*pData)[2]<<16 | (*pData)[3]<<24;
148 unsigned int *pLenRemain,
153 *
dest = (*pData)[0] | (*pData)[1]<<8 | (*pData)[2]<<16 | (*pData)[3]<<24;
160 unsigned int *pLenRemain,
171 temp |= (*pData)[
i-1];
180 unsigned int *pLenRemain,
191 temp |= (*pData)[
i-1];
200 unsigned int *pDataLen,
208':',
':',
'D',
'a',
't',
'a',
'S',
'p',
'a',
'c',
'e',
'/',
209 'S',
't',
'o',
'r',
'a',
'g',
'e',
'/',
210 'M',
'S',
'C',
'o',
'm',
'p',
'r',
'e',
's',
's',
'e',
'd',
'/',
211 'T',
'r',
'a',
'n',
's',
'f',
'o',
'r',
'm',
'/',
212 '{',
'7',
'F',
'C',
'2',
'8',
'9',
'4',
'0',
'-',
'9',
'D',
'3',
'1',
213 '-',
'1',
'1',
'D',
'0',
'-',
'9',
'B',
'2',
'7',
'-',
214 '0',
'0',
'A',
'0',
'C',
'9',
'1',
'E',
'9',
'C',
'7',
'C',
'}',
'/',
215 'I',
'n',
's',
't',
'a',
'n',
'c',
'e',
'D',
'a',
't',
'a',
'/',
216 'R',
'e',
's',
'e',
't',
'T',
'a',
'b',
'l',
'e',0
219':',
':',
'D',
'a',
't',
'a',
'S',
'p',
'a',
'c',
'e',
'/',
220 'S',
't',
'o',
'r',
'a',
'g',
'e',
'/',
221 'M',
'S',
'C',
'o',
'm',
'p',
'r',
'e',
's',
's',
'e',
'd',
'/',
222 'C',
'o',
'n',
't',
'r',
'o',
'l',
'D',
'a',
't',
'a',0
225':',
':',
'D',
'a',
't',
'a',
'S',
'p',
'a',
'c',
'e',
'/',
226 'S',
't',
'o',
'r',
'a',
'g',
'e',
'/',
227 'M',
'S',
'C',
'o',
'm',
'p',
'r',
'e',
's',
's',
'e',
'd',
'/',
228 'C',
'o',
'n',
't',
'e',
'n',
't',0
236#define _CHM_ITSF_V2_LEN (0x58)
237#define _CHM_ITSF_V3_LEN (0x60)
256 unsigned int *pDataLen,
283 if (
dest->version == 2)
288 else if (
dest->version == 3)
299 if (
dest->version == 3)
313#define _CHM_ITSP_V1_LEN (0x54)
334 unsigned int *pDataLen,
361 if (
dest->version != 1)
371#define _CHM_PMGL_LEN (0x14)
382 unsigned int *pDataLen,
405#define _CHM_PMGI_LEN (0x08)
413 unsigned int *pDataLen,
432#define _CHM_LZXC_RESETTABLE_V1_LEN (0x28)
445 unsigned int *pDataLen,
462 if (
dest->version != 2)
469#define _CHM_LZXC_MIN_LEN (0x18)
470#define _CHM_LZXC_V2_LEN (0x1c)
483 unsigned int *pDataLen,
501 dest->unknown_18 = 0;
503 if (
dest->version == 2)
505 dest->resetInterval *= 0x8000;
506 dest->windowSize *= 0x8000;
508 if (
dest->windowSize == 0 ||
dest->resetInterval == 0)
512 if (
dest->windowSize == 1)
514 if ((
dest->resetInterval % (
dest->windowSize/2)) != 0)
621 if (paramVal !=
h->cache_num_blocks)
630 for (
i=0;
i<paramVal;
i++)
639 for (
i=0;
i<
h->cache_num_blocks;
i++)
641 int newSlot = (
int)(
h->cache_block_indices[
i] % paramVal);
643 if (
h->cache_blocks[
i])
646 if (newBlocks[newSlot])
649 h->cache_blocks[
i] =
NULL;
653 newBlocks[newSlot] =
h->cache_blocks[
i];
654 newIndices[newSlot] =
655 h->cache_block_indices[
i];
665 h->cache_blocks = newBlocks;
666 h->cache_block_indices = newIndices;
667 h->cache_num_blocks = paramVal;
680 unsigned char sbuffer[256];
681 unsigned int sremain;
682 unsigned char *sbufpos;
790 0, sremain) != sremain ||
804 0, sremain) != sremain ||
836 *newHandle = *oldHandle;
871 h->mutex.DebugInfo->Spare[0] = 0;
873 h->lzx_mutex.DebugInfo->Spare[0] = 0;
875 h->cache_mutex.DebugInfo->Spare[0] = 0;
885 for (
i=0;
i<
h->cache_num_blocks;
i++)
890 h->cache_blocks =
NULL;
894 h->cache_block_indices =
NULL;
907 while (*(*
pEntry)++ >= 0x80)
927 accum +=
temp & 0x7f;
930 return (accum << 7) +
temp;
966 const WCHAR *objPath)
984 end = page_buf + block_len - (
header.free_space);
1008 const WCHAR *objPath)
1026 end = page_buf + block_len - (
header.free_space);
1049 const WCHAR *objPath,
1062 curPage =
h->index_root;
1065 while (curPage != -1)
1070 h->dir_offset + (
UInt64)curPage*
h->block_len,
1071 h->block_len) !=
h->block_len)
1127 if (block < h->reset_table.block_count-1)
1135 +
h->reset_table.table_offset
1137 remain) != remain ||
1147 +
h->reset_table.table_offset
1149 remain) != remain ||
1163 +
h->reset_table.table_offset
1165 remain) != remain ||
1169 *
len =
h->reset_table.compressed_len;
1174 *
start +=
h->data_offset +
h->cn_unit.start;
1185 ((
unsigned int)
h->reset_table.block_len + 6144));
1194 if (
block - blockAlign <= h->lzx_last_block &&
1195 block >=
h->lzx_last_block)
1196 blockAlign = (
block -
h->lzx_last_block);
1199 if (blockAlign != 0)
1202 for (
i = blockAlign;
i > 0;
i--)
1207 if (
h->lzx_last_block != curBlockIdx)
1209 if ((curBlockIdx %
h->reset_blkcount) == 0)
1217 indexSlot = (
int)((curBlockIdx) %
h->cache_num_blocks);
1218 h->cache_block_indices[indexSlot] = curBlockIdx;
1219 if (!
h->cache_blocks[indexSlot])
1220 h->cache_blocks[indexSlot] =
1222 (
unsigned int)(
h->reset_table.block_len));
1223 lbuffer =
h->cache_blocks[indexSlot];
1227 fprintf(
stderr,
"Decompressing block #%4d (EXTRA)\n", curBlockIdx);
1232 (
int)
h->reset_table.block_len) !=
DECR_OK)
1241 h->lzx_last_block = (
int)curBlockIdx;
1247 if ((
block %
h->reset_blkcount) == 0)
1257 indexSlot = (
int)(
block %
h->cache_num_blocks);
1258 h->cache_block_indices[indexSlot] =
block;
1259 if (!
h->cache_blocks[indexSlot])
1260 h->cache_blocks[indexSlot] =
1262 lbuffer =
h->cache_blocks[indexSlot];
1272 (
int)
h->reset_table.block_len) !=
DECR_OK)
1286 return h->reset_table.block_len;
1304 nBlock =
start /
h->reset_table.block_len;
1305 nOffset =
start %
h->reset_table.block_len;
1307 if (nLen > (
h->reset_table.block_len - nOffset))
1308 nLen =
h->reset_table.block_len - nOffset;
1313 if (
h->cache_block_indices[nBlock %
h->cache_num_blocks] == nBlock &&
1314 h->cache_blocks[nBlock %
h->cache_num_blocks] !=
NULL)
1317 h->cache_blocks[nBlock %
h->cache_num_blocks] + nOffset,
1318 (
unsigned int)nLen);
1328 h->lzx_last_block = -1;
1336 memcpy(
buf, ubuffer+nOffset, (
unsigned int)nLen);
1366 h->data_offset +
ui->start +
addr,
1376 if (!
h->compression_enabled)
1401 const WCHAR *prefix,
1417 unsigned int lenRemain;
1434 curPage =
h->index_head;
1438 prefixLen =
lstrlenW(prefixRectified);
1441 if (prefixRectified[prefixLen-1] !=
'/')
1443 prefixRectified[prefixLen] =
'/';
1444 prefixRectified[prefixLen+1] =
'\0';
1452 while (curPage != -1)
1458 h->dir_offset + (
UInt64)curPage*
h->block_len,
1459 h->block_len) !=
h->block_len)
1473 end = page_buf +
h->block_len - (
header.free_space);
1487 if (
ui.length == 0 &&
_wcsnicmp(
ui.path, prefixRectified, prefixLen) == 0)
1488 it_has_begun =
TRUE;
1492 if (
ui.path[prefixLen] ==
'\0')
1499 if (
_wcsnicmp(
ui.path, prefixRectified, prefixLen) != 0)
1507 if (lastPathLen != -1)
1509 if (
_wcsnicmp(
ui.path, lastPath, lastPathLen) == 0)
1527 if (
ui.path[0] ==
'/')
1531 if (
ui.path[1] ==
'#' ||
ui.path[1] ==
'$')
1538 if (! (what &
flag))
1561 curPage =
header.block_next;
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
static Int32 _chm_find_in_PMGI(UChar *page_buf, UInt32 block_len, const WCHAR *objPath)
static const WCHAR _CHMU_LZXC_CONTROLDATA[]
static BOOL _unmarshal_int32(unsigned char **pData, unsigned int *pLenRemain, Int32 *dest)
#define CHM_RELEASE_LOCK(a)
static void _chm_skip_PMGL_entry_data(UChar **pEntry)
#define _CHM_LZXC_RESETTABLE_V1_LEN
static BOOL _unmarshal_uint32(unsigned char **pData, unsigned int *pLenRemain, UInt32 *dest)
#define CHM_ACQUIRE_LOCK(a)
static void chm_set_param(struct chmFile *h, int paramType, int paramVal)
LONGINT64 chm_retrieve_object(struct chmFile *h, struct chmUnitInfo *ui, unsigned char *buf, LONGUINT64 addr, LONGINT64 len)
static BOOL _unmarshal_uuid(unsigned char **pData, unsigned int *pDataLen, unsigned char *dest)
#define CHM_MAX_BLOCKS_CACHED
int chm_resolve_object(struct chmFile *h, const WCHAR *objPath, struct chmUnitInfo *ui)
static BOOL _unmarshal_pmgl_header(unsigned char **pData, unsigned int *pDataLen, struct chmPmglHeader *dest)
#define CHM_PARAM_MAX_BLOCKS_CACHED
#define CHM_CLOSE_FILE(fd)
static const char _chm_pmgi_marker[4]
static Int64 _chm_decompress_region(struct chmFile *h, UChar *buf, UInt64 start, Int64 len)
static UChar * _chm_find_in_PMGL(UChar *page_buf, UInt32 block_len, const WCHAR *objPath)
static BOOL _unmarshal_itsp_header(unsigned char **pData, unsigned int *pDataLen, struct chmItspHeader *dest)
static BOOL _unmarshal_pmgi_header(unsigned char **pData, unsigned int *pDataLen, struct chmPmgiHeader *dest)
static BOOL _unmarshal_lzxc_reset_table(unsigned char **pData, unsigned int *pDataLen, struct chmLzxcResetTable *dest)
static BOOL _unmarshal_char_array(unsigned char **pData, unsigned int *pLenRemain, char *dest, int count)
static BOOL _unmarshal_uchar_array(unsigned char **pData, unsigned int *pLenRemain, unsigned char *dest, int count)
struct chmFile * chm_dup(struct chmFile *oldHandle)
static BOOL _unmarshal_int64(unsigned char **pData, unsigned int *pLenRemain, Int64 *dest)
static const WCHAR _CHMU_RESET_TABLE[]
BOOL chm_enumerate_dir(struct chmFile *h, const WCHAR *prefix, int what, CHM_ENUMERATOR e, void *context)
static void _chm_skip_cword(UChar **pEntry)
static Int64 _chm_decompress_block(struct chmFile *h, UInt64 block, UChar **ubuffer)
static BOOL _unmarshal_uint64(unsigned char **pData, unsigned int *pLenRemain, UInt64 *dest)
#define _CHM_LZXC_MIN_LEN
static BOOL _unmarshal_lzxc_control_data(unsigned char **pData, unsigned int *pDataLen, struct chmLzxcControlData *dest)
static BOOL _chm_parse_UTF8(UChar **pEntry, UInt64 count, WCHAR *path)
struct chmFile * chm_openW(const WCHAR *filename)
static const WCHAR _CHMU_CONTENT[]
static BOOL _unmarshal_itsf_header(unsigned char **pData, unsigned int *pDataLen, struct chmItsfHeader *dest)
void chm_close(struct chmFile *h)
static UInt64 _chm_parse_cword(UChar **pEntry)
static BOOL _chm_parse_PMGL_entry(UChar **pEntry, struct chmUnitInfo *ui)
static BOOL _chm_get_cmpblock_bounds(struct chmFile *h, UInt64 block, UInt64 *start, Int64 *len)
static const char _chm_pmgl_marker[4]
static Int64 _chm_fetch_bytes(struct chmFile *h, UChar *buf, UInt64 os, Int64 len)
#define CHM_ENUMERATE_NORMAL
#define CHM_RESOLVE_FAILURE
#define CHM_ENUMERATOR_CONTINUE
#define CHM_ENUMERATE_META
#define CHM_ENUMERATE_SPECIAL
#define CHM_RESOLVE_SUCCESS
#define CHM_ENUMERATE_DIRS
int(* CHM_ENUMERATOR)(struct chmFile *h, struct chmUnitInfo *ui, void *context)
#define CHM_ENUMERATE_FILES
#define CHM_ENUMERATOR_SUCCESS
#define CHM_ENUMERATOR_FAILURE
#define ReadFile(a, b, c, d, e)
#define GetCurrentProcess()
#define HeapFree(x, y, z)
#define FILE_ATTRIBUTE_NORMAL
#define MultiByteToWideChar
BOOL WINAPI SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLuint GLuint GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLenum const GLvoid * addr
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
void LZXteardown(struct LZXstate *pState)
int LZXdecompress(struct LZXstate *pState, unsigned char *inpos, unsigned char *outpos, int inlen, int outlen)
struct LZXstate * LZXinit(int wndsize)
int LZXreset(struct LZXstate *pState)
#define memcpy(s1, s2, n)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
PCRITICAL_SECTION_DEBUG DebugInfo
Int64 * cache_block_indices
struct chmUnitInfo rt_unit
CRITICAL_SECTION cache_mutex
struct chmUnitInfo cn_unit
struct LZXstate * lzx_state
CRITICAL_SECTION lzx_mutex
struct chmLzxcResetTable reset_table
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define DUPLICATE_SAME_ACCESS
static unsigned int block