Delete the svn:executable property and set svn:eol-style to native for all those text files.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18012 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nicolas Pennequin 2008-07-11 16:51:25 +00:00
parent 141774be48
commit ca5bb76d2b
142 changed files with 33915 additions and 33915 deletions

26
utils/zenutils/CMakeLists.txt Executable file → Normal file
View file

@ -1,13 +1,13 @@
PROJECT(zenutils)
SET(EXECUTABLE_OUTPUT_PATH ${zenutils_SOURCE_DIR}/bin/${CMAKE_SYSTEM_NAME})
SUBDIRS(source libraries)
INCLUDE_DIRECTORIES(
${zenutils_SOURCE_DIR}/libraries/beecrypt-4.1.2
${zenutils_SOURCE_DIR}/libraries/getpot-c++-1.1.17
${zenutils_SOURCE_DIR}/libraries/pelib-0.9
${zenutils_SOURCE_DIR}/libraries/zlib123
${zenutils_SOURCE_DIR}/source/shared
)
PROJECT(zenutils)
SET(EXECUTABLE_OUTPUT_PATH ${zenutils_SOURCE_DIR}/bin/${CMAKE_SYSTEM_NAME})
SUBDIRS(source libraries)
INCLUDE_DIRECTORIES(
${zenutils_SOURCE_DIR}/libraries/beecrypt-4.1.2
${zenutils_SOURCE_DIR}/libraries/getpot-c++-1.1.17
${zenutils_SOURCE_DIR}/libraries/pelib-0.9
${zenutils_SOURCE_DIR}/libraries/zlib123
${zenutils_SOURCE_DIR}/source/shared
)

0
utils/zenutils/COPYING Executable file → Normal file
View file

6
utils/zenutils/libraries/CMakeLists.txt Executable file → Normal file
View file

@ -1,3 +1,3 @@
ADD_SUBDIRECTORY(beecrypt-4.1.2)
ADD_SUBDIRECTORY(pelib-0.9)
ADD_SUBDIRECTORY(zlib123)
ADD_SUBDIRECTORY(beecrypt-4.1.2)
ADD_SUBDIRECTORY(pelib-0.9)
ADD_SUBDIRECTORY(zlib123)

28
utils/zenutils/libraries/beecrypt-4.1.2/CMakeLists.txt Executable file → Normal file
View file

@ -1,14 +1,14 @@
PROJECT(beecrypt)
# source files for beecrypt
SET(beecrypt_srcs
beecrypt/blockmode.c
beecrypt/blowfish.c
beecrypt/endianness.c
beecrypt/hmac.c
beecrypt/hmacsha1.c
beecrypt/mp.c
beecrypt/sha1.c
)
ADD_LIBRARY(beecrypt ${beecrypt_srcs})
PROJECT(beecrypt)
# source files for beecrypt
SET(beecrypt_srcs
beecrypt/blockmode.c
beecrypt/blowfish.c
beecrypt/endianness.c
beecrypt/hmac.c
beecrypt/hmacsha1.c
beecrypt/mp.c
beecrypt/sha1.c
)
ADD_LIBRARY(beecrypt ${beecrypt_srcs})

View file

View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BUGS Executable file → Normal file
View file

View file

View file

View file

View file

View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/NEWS Executable file → Normal file
View file

View file

View file

View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/api.h Executable file → Normal file
View file

View file

View file

View file

View file

View file

View file

View file

View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/gnu.h Executable file → Normal file
View file

View file

View file

View file

View file

View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.c Executable file → Normal file
View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.h Executable file → Normal file
View file

View file

View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h Executable file → Normal file
View file

View file

View file

View file

0
utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h Executable file → Normal file
View file

View file

View file

View file

File diff suppressed because it is too large Load diff

40
utils/zenutils/libraries/pelib-0.9/CMakeLists.txt Executable file → Normal file
View file

@ -1,20 +1,20 @@
PROJECT(pelib)
# source files for pelib
SET(pelib_srcs
pelib/BoundImportDirectory.cpp
pelib/ComHeaderDirectory.cpp
pelib/DebugDirectory.cpp
pelib/ExportDirectory.cpp
pelib/IatDirectory.cpp
pelib/MzHeader.cpp
pelib/PeFile.cpp
pelib/PeHeader.cpp
pelib/PeLibAux.cpp
pelib/RelocationsDirectory.cpp
pelib/ResourceDirectory.cpp
pelib/buffer/InputBuffer.cpp
pelib/buffer/OutputBuffer.cpp
)
ADD_LIBRARY(pelib ${pelib_srcs})
PROJECT(pelib)
# source files for pelib
SET(pelib_srcs
pelib/BoundImportDirectory.cpp
pelib/ComHeaderDirectory.cpp
pelib/DebugDirectory.cpp
pelib/ExportDirectory.cpp
pelib/IatDirectory.cpp
pelib/MzHeader.cpp
pelib/PeFile.cpp
pelib/PeHeader.cpp
pelib/PeLibAux.cpp
pelib/RelocationsDirectory.cpp
pelib/ResourceDirectory.cpp
pelib/buffer/InputBuffer.cpp
pelib/buffer/OutputBuffer.cpp
)
ADD_LIBRARY(pelib ${pelib_srcs})

File diff suppressed because it is too large Load diff

View file

@ -1,87 +1,87 @@
/*
* BoundImportDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef BOUNDIMPORTDIRECTORY_H
#define BOUNDIMPORTDIRECTORY_H
#include "PeLibAux.h"
namespace PeLib
{
/// Class that handles the BoundImport directory.
/**
* This class can read and modify the BoundImport directory table of a PE file.
**/
class BoundImportDirectory
{
private:
std::vector<PELIB_IMAGE_BOUND_DIRECTORY> m_vIbd; ///< Stores the individual BoundImport fields.
int read(InputBuffer& inpBuffer, unsigned char* data, unsigned int dwSize);
unsigned int totalModules() const;
public:
/// Adds another bound import.
int addBoundImport(const std::string& strModuleName, dword dwTds, word dwOmn, word wWfr); // EXPORT
/// Identifies a module through it's name.
int getModuleIndex(const std::string& strModuleName) const; // EXPORT
/// Returns the number of files in the BoundImport directory.
unsigned int calcNumberOfModules() const; // EXPORT
/// Reads the BoundImport directory table from a PE file.
int read(const std::string& strFileName, dword dwOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* pcBuffer, unsigned int uiSize); // EXPORT
/// Rebuilds the BoundImport directory.
void rebuild(std::vector<byte>& vBuffer, bool fMakeValid = true) const; // EXPORT
/// Empties the BoundImport directory.
void clear(); // EXPORT
/// Removes a bound import.
void removeBoundImport(const std::string& strModuleName); // EXPORT
/// Returns the size of the BoundImport directory.
unsigned int size() const; // EXPORT
/// Writes the current bound import directory to a file.
int write(const std::string& strFilename, dword dwOffset, bool fMakeValid = true) const; // EXPORT
/// Retrieves the TimeDateStamp value of a bound import.
dword getTimeDateStamp(dword dwBidnr) const; // EXPORT
/// Retrieves the OffsetModuleName value of a bound import.
word getOffsetModuleName(dword dwBidnr) const; // EXPORT
/// Retrieves the NumberOfModuleForwarderRefs value of a bound import.
word getNumberOfModuleForwarderRefs(dword dwBidnr) const; // EXPORT
/// Retrieves the ModuleName value of a bound import.
std::string getModuleName(dword dwBidnr) const; // EXPORT
/// Updates the TimeDateStamp value of a bound import.
void setTimeDateStamp(dword dwBidnr, dword dwTds); // EXPORT
/// Updates the OffsetModuleName value of a bound import.
void setOffsetModuleName(dword dwBidnr, word wOmn); // EXPORT
/// Updates the NumberOfModuleForwarderRefs value of a bound import.
void setNumberOfModuleForwarderRefs(dword dwBidnr, word wMfr); // EXPORT
/// Updates the ModuleName value of a bound import.
void setModuleName(dword dwBidnr, const std::string& strModuleName); // EXPORT
dword getTimeDateStamp(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
word getOffsetModuleName(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
word getNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
std::string getModuleName(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
void setTimeDateStamp(dword dwBidnr, dword forwardedModule, dword dwTds); // EXPORT _module
void setOffsetModuleName(dword dwBidnr, dword forwardedModule, word wOmn); // EXPORT _module
void setNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule, word wMfr); // EXPORT _module
void setModuleName(dword dwBidnr, dword forwardedModule, const std::string& strModuleName); // EXPORT _module
word calcNumberOfModuleForwarderRefs(dword dwBidnr) const; // EXPORT
void addForwardedModule(dword dwBidnr, const std::string& name, dword timeStamp = 0, word offsetModuleName = 0, word forwardedModules = 0); // EXPORT
void removeForwardedModule(dword dwBidnr, word forwardedModule); // EXPORT
};
}
#endif
/*
* BoundImportDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef BOUNDIMPORTDIRECTORY_H
#define BOUNDIMPORTDIRECTORY_H
#include "PeLibAux.h"
namespace PeLib
{
/// Class that handles the BoundImport directory.
/**
* This class can read and modify the BoundImport directory table of a PE file.
**/
class BoundImportDirectory
{
private:
std::vector<PELIB_IMAGE_BOUND_DIRECTORY> m_vIbd; ///< Stores the individual BoundImport fields.
int read(InputBuffer& inpBuffer, unsigned char* data, unsigned int dwSize);
unsigned int totalModules() const;
public:
/// Adds another bound import.
int addBoundImport(const std::string& strModuleName, dword dwTds, word dwOmn, word wWfr); // EXPORT
/// Identifies a module through it's name.
int getModuleIndex(const std::string& strModuleName) const; // EXPORT
/// Returns the number of files in the BoundImport directory.
unsigned int calcNumberOfModules() const; // EXPORT
/// Reads the BoundImport directory table from a PE file.
int read(const std::string& strFileName, dword dwOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* pcBuffer, unsigned int uiSize); // EXPORT
/// Rebuilds the BoundImport directory.
void rebuild(std::vector<byte>& vBuffer, bool fMakeValid = true) const; // EXPORT
/// Empties the BoundImport directory.
void clear(); // EXPORT
/// Removes a bound import.
void removeBoundImport(const std::string& strModuleName); // EXPORT
/// Returns the size of the BoundImport directory.
unsigned int size() const; // EXPORT
/// Writes the current bound import directory to a file.
int write(const std::string& strFilename, dword dwOffset, bool fMakeValid = true) const; // EXPORT
/// Retrieves the TimeDateStamp value of a bound import.
dword getTimeDateStamp(dword dwBidnr) const; // EXPORT
/// Retrieves the OffsetModuleName value of a bound import.
word getOffsetModuleName(dword dwBidnr) const; // EXPORT
/// Retrieves the NumberOfModuleForwarderRefs value of a bound import.
word getNumberOfModuleForwarderRefs(dword dwBidnr) const; // EXPORT
/// Retrieves the ModuleName value of a bound import.
std::string getModuleName(dword dwBidnr) const; // EXPORT
/// Updates the TimeDateStamp value of a bound import.
void setTimeDateStamp(dword dwBidnr, dword dwTds); // EXPORT
/// Updates the OffsetModuleName value of a bound import.
void setOffsetModuleName(dword dwBidnr, word wOmn); // EXPORT
/// Updates the NumberOfModuleForwarderRefs value of a bound import.
void setNumberOfModuleForwarderRefs(dword dwBidnr, word wMfr); // EXPORT
/// Updates the ModuleName value of a bound import.
void setModuleName(dword dwBidnr, const std::string& strModuleName); // EXPORT
dword getTimeDateStamp(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
word getOffsetModuleName(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
word getNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
std::string getModuleName(dword dwBidnr, dword forwardedModule) const; // EXPORT _module
void setTimeDateStamp(dword dwBidnr, dword forwardedModule, dword dwTds); // EXPORT _module
void setOffsetModuleName(dword dwBidnr, dword forwardedModule, word wOmn); // EXPORT _module
void setNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule, word wMfr); // EXPORT _module
void setModuleName(dword dwBidnr, dword forwardedModule, const std::string& strModuleName); // EXPORT _module
word calcNumberOfModuleForwarderRefs(dword dwBidnr) const; // EXPORT
void addForwardedModule(dword dwBidnr, const std::string& name, dword timeStamp = 0, word offsetModuleName = 0, word forwardedModules = 0); // EXPORT
void removeForwardedModule(dword dwBidnr, word forwardedModule); // EXPORT
};
}
#endif

View file

@ -1,467 +1,467 @@
/*
* ComHeaderDirectory.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "ComHeaderDirectory.h"
namespace PeLib
{
void ComHeaderDirectory::read(InputBuffer& inputbuffer)
{
PELIB_IMAGE_COR20_HEADER ichCurr;
inputbuffer >> ichCurr.cb;
inputbuffer >> ichCurr.MajorRuntimeVersion;
inputbuffer >> ichCurr.MinorRuntimeVersion;
inputbuffer >> ichCurr.MetaData.VirtualAddress;
inputbuffer >> ichCurr.MetaData.Size;
inputbuffer >> ichCurr.Flags;
inputbuffer >> ichCurr.EntryPointToken;
inputbuffer >> ichCurr.Resources.VirtualAddress;
inputbuffer >> ichCurr.Resources.Size;
inputbuffer >> ichCurr.StrongNameSignature.VirtualAddress;
inputbuffer >> ichCurr.StrongNameSignature.Size;
inputbuffer >> ichCurr.CodeManagerTable.VirtualAddress;
inputbuffer >> ichCurr.CodeManagerTable.Size;
inputbuffer >> ichCurr.VTableFixups.VirtualAddress;
inputbuffer >> ichCurr.VTableFixups.Size;
inputbuffer >> ichCurr.ExportAddressTableJumps.VirtualAddress;
inputbuffer >> ichCurr.ExportAddressTableJumps.Size;
inputbuffer >> ichCurr.ManagedNativeHeader.VirtualAddress;
inputbuffer >> ichCurr.ManagedNativeHeader.Size;
std::swap(ichCurr, m_ichComHeader);
}
int ComHeaderDirectory::read(unsigned char* buffer, unsigned int buffersize)
{
if (buffersize < PELIB_IMAGE_COR20_HEADER::size())
{
return ERROR_INVALID_FILE;
}
std::vector<byte> vComDescDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vComDescDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Reads a file's COM+ descriptor.
* @param strFilename Name of the file.
* @param uiOffset File offset of the COM+ descriptor.
* @param uiSize Size of the COM+ descriptor.
**/
int ComHeaderDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<byte> vComDescDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vComDescDirectory[0]), uiSize);
InputBuffer ibBuffer(vComDescDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Rebuilds the current COM+ descriptor.
* @param vBuffer Buffer where the COM+ descriptor will be written to.
**/
void ComHeaderDirectory::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
obBuffer << m_ichComHeader.cb;
obBuffer << m_ichComHeader.MajorRuntimeVersion;
obBuffer << m_ichComHeader.MinorRuntimeVersion;
obBuffer << m_ichComHeader.MetaData.VirtualAddress;
obBuffer << m_ichComHeader.MetaData.Size;
obBuffer << m_ichComHeader.Flags;
obBuffer << m_ichComHeader.EntryPointToken;
obBuffer << m_ichComHeader.Resources.VirtualAddress;
obBuffer << m_ichComHeader.Resources.Size;
obBuffer << m_ichComHeader.StrongNameSignature.VirtualAddress;
obBuffer << m_ichComHeader.StrongNameSignature.Size;
obBuffer << m_ichComHeader.CodeManagerTable.VirtualAddress;
obBuffer << m_ichComHeader.CodeManagerTable.Size;
obBuffer << m_ichComHeader.VTableFixups.VirtualAddress;
obBuffer << m_ichComHeader.VTableFixups.Size;
obBuffer << m_ichComHeader.ExportAddressTableJumps.VirtualAddress;
obBuffer << m_ichComHeader.ExportAddressTableJumps.Size;
obBuffer << m_ichComHeader.ManagedNativeHeader.VirtualAddress;
obBuffer << m_ichComHeader.ManagedNativeHeader.Size;
}
/**
* @return Size in bytes.
**/
unsigned int ComHeaderDirectory::size() const
{
return PELIB_IMAGE_COR20_HEADER::size();
}
/**
* @param strFilename Name of the file.
* @param dwOffset File offset the COM+ descriptor will be written to.
**/
int ComHeaderDirectory::write(const std::string& strFilename, unsigned int dwOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(dwOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
/**
* @return SizeOfHeader value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getSizeOfHeader() const
{
return m_ichComHeader.cb;
}
/**
* @return MajorRuntimeVersion value of the current COM+ descriptor.
**/
word ComHeaderDirectory::getMajorRuntimeVersion() const
{
return m_ichComHeader.MajorRuntimeVersion;
}
/**
* @return MinorRuntimeVersion value of the current COM+ descriptor.
**/
word ComHeaderDirectory::getMinorRuntimeVersion() const
{
return m_ichComHeader.MinorRuntimeVersion;
}
/**
* @return MetaData (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getMetaDataVa() const
{
return m_ichComHeader.MetaData.VirtualAddress;
}
/**
* @return MetaData (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getMetaDataSize() const
{
return m_ichComHeader.MetaData.Size;
}
/**
* @return Flags value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getFlags() const
{
return m_ichComHeader.Flags;
}
/**
* @return EntryPointToken value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getEntryPointToken() const
{
return m_ichComHeader.EntryPointToken;
}
/**
* @return Resources (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getResourcesVa() const
{
return m_ichComHeader.Resources.VirtualAddress;
}
/**
* @return Resources (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getResourcesSize()
{
return m_ichComHeader.Resources.Size;
}
/**
* @return StrongNameSignature (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getStrongNameSignatureVa() const
{
return m_ichComHeader.StrongNameSignature.VirtualAddress;
}
/**
* @return StrongNameSignature (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getStrongNameSignagureSize() const
{
return m_ichComHeader.StrongNameSignature.Size;
}
/**
* @return CodeManagerTable (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getCodeManagerTableVa() const
{
return m_ichComHeader.CodeManagerTable.VirtualAddress;
}
/**
* @return CodeManagerTable (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getCodeManagerTableSize() const
{
return m_ichComHeader.CodeManagerTable.Size;
}
/**
* @return VTableFixups (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getVTableFixupsVa() const
{
return m_ichComHeader.VTableFixups.VirtualAddress;
}
/**
* @return VTableFixups (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getVTableFixupsSize() const
{
return m_ichComHeader.VTableFixups.Size;
}
/**
* @return ExportAddressTableJumps (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getExportAddressTableJumpsVa() const
{
return m_ichComHeader.ExportAddressTableJumps.VirtualAddress;
}
/**
* @return ExportAddressTableJumps (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getExportAddressTableJumpsSize() const
{
return m_ichComHeader.ExportAddressTableJumps.Size;
}
/**
* @return ManagedNativeHeader (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getManagedNativeHeaderVa() const
{
return m_ichComHeader.ManagedNativeHeader.VirtualAddress;
}
/**
* @return ManagedNativeHeader (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getManagedNativeHeaderSize() const
{
return m_ichComHeader.ManagedNativeHeader.Size;
}
/**
* @param dwValue New value for the current SizeOfHeader (cb) value.
**/
void ComHeaderDirectory::setSizeOfHeader(dword dwValue)
{
m_ichComHeader.cb = dwValue;
}
/**
* @param wValue New value for the current MajorRuntimeVersion value.
**/
void ComHeaderDirectory::setMajorRuntimeVersion(word wValue)
{
m_ichComHeader.MajorRuntimeVersion = wValue;
}
/**
* @param wValue New value for the current MinorRuntimeVersion value.
**/
void ComHeaderDirectory::setMinorRuntimeVersion(word wValue)
{
m_ichComHeader.MinorRuntimeVersion = wValue;
}
/**
* @param dwValue New value for the current MetaData (VirtualAddress) value.
**/
void ComHeaderDirectory::setMetaDataVa(dword dwValue)
{
m_ichComHeader.MetaData.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current MetaData (Size) value.
**/
void ComHeaderDirectory::setMetaDataSize(dword dwValue)
{
m_ichComHeader.MetaData.Size = dwValue;
}
/**
* @param dwValue New value for the current Flags value.
**/
void ComHeaderDirectory::setFlags(dword dwValue)
{
m_ichComHeader.Flags = dwValue;
}
/**
* @param dwValue New value for the current EntryPointToken value.
**/
void ComHeaderDirectory::setEntryPointToken(dword dwValue)
{
m_ichComHeader.EntryPointToken = dwValue;
}
/**
* @param dwValue New value for the current Resources (VirtualAddress) value.
**/
void ComHeaderDirectory::setResourcesVa(dword dwValue)
{
m_ichComHeader.Resources.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current Resources (Size) value.
**/
void ComHeaderDirectory::setResourcesSize(dword dwValue)
{
m_ichComHeader.Resources.Size = dwValue;
}
/**
* @param dwValue New value for the current StrongNameSignature (VirtualAddress) value.
**/
void ComHeaderDirectory::setStrongNameSignatureVa(dword dwValue)
{
m_ichComHeader.StrongNameSignature.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current StrongNameSignature (Size) value.
**/
void ComHeaderDirectory::setStrongNameSignagureSize(dword dwValue)
{
m_ichComHeader.StrongNameSignature.Size = dwValue;
}
/**
* @param dwValue New value for the current CodeManagerTable (VirtualAddress) value.
**/
void ComHeaderDirectory::setCodeManagerTableVa(dword dwValue)
{
m_ichComHeader.CodeManagerTable.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current CodeManagerTable (Size) value.
**/
void ComHeaderDirectory::setCodeManagerTableSize(dword dwValue)
{
m_ichComHeader.CodeManagerTable.Size = dwValue;
}
/**
* @param dwValue New value for the current VTableFixups (VirtualAddress) value.
**/
void ComHeaderDirectory::setVTableFixupsVa(dword dwValue)
{
m_ichComHeader.VTableFixups.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current VTableFixups (Size) value.
**/
void ComHeaderDirectory::setVTableFixupsSize(dword dwValue)
{
m_ichComHeader.VTableFixups.Size = dwValue;
}
/**
* @param dwValue New value for the current ExportAddressTableJumps (VirtualAddress) value.
**/
void ComHeaderDirectory::setExportAddressTableJumpsVa(dword dwValue)
{
m_ichComHeader.ExportAddressTableJumps.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current ExportAddressTableJumps (Size) value.
**/
void ComHeaderDirectory::setExportAddressTableJumpsSize(dword dwValue)
{
m_ichComHeader.ExportAddressTableJumps.Size = dwValue;
}
/**
* @param dwValue New value for the current ManagedNativeHeader (VirtualAddress) value.
**/
void ComHeaderDirectory::setManagedNativeHeaderVa(dword dwValue)
{
m_ichComHeader.ManagedNativeHeader.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current ManagedNativeHeader (Size) value.
**/
void ComHeaderDirectory::setManagedNativeHeaderSize(dword dwValue)
{
m_ichComHeader.ManagedNativeHeader.Size = dwValue;
}
}
/*
* ComHeaderDirectory.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "ComHeaderDirectory.h"
namespace PeLib
{
void ComHeaderDirectory::read(InputBuffer& inputbuffer)
{
PELIB_IMAGE_COR20_HEADER ichCurr;
inputbuffer >> ichCurr.cb;
inputbuffer >> ichCurr.MajorRuntimeVersion;
inputbuffer >> ichCurr.MinorRuntimeVersion;
inputbuffer >> ichCurr.MetaData.VirtualAddress;
inputbuffer >> ichCurr.MetaData.Size;
inputbuffer >> ichCurr.Flags;
inputbuffer >> ichCurr.EntryPointToken;
inputbuffer >> ichCurr.Resources.VirtualAddress;
inputbuffer >> ichCurr.Resources.Size;
inputbuffer >> ichCurr.StrongNameSignature.VirtualAddress;
inputbuffer >> ichCurr.StrongNameSignature.Size;
inputbuffer >> ichCurr.CodeManagerTable.VirtualAddress;
inputbuffer >> ichCurr.CodeManagerTable.Size;
inputbuffer >> ichCurr.VTableFixups.VirtualAddress;
inputbuffer >> ichCurr.VTableFixups.Size;
inputbuffer >> ichCurr.ExportAddressTableJumps.VirtualAddress;
inputbuffer >> ichCurr.ExportAddressTableJumps.Size;
inputbuffer >> ichCurr.ManagedNativeHeader.VirtualAddress;
inputbuffer >> ichCurr.ManagedNativeHeader.Size;
std::swap(ichCurr, m_ichComHeader);
}
int ComHeaderDirectory::read(unsigned char* buffer, unsigned int buffersize)
{
if (buffersize < PELIB_IMAGE_COR20_HEADER::size())
{
return ERROR_INVALID_FILE;
}
std::vector<byte> vComDescDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vComDescDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Reads a file's COM+ descriptor.
* @param strFilename Name of the file.
* @param uiOffset File offset of the COM+ descriptor.
* @param uiSize Size of the COM+ descriptor.
**/
int ComHeaderDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<byte> vComDescDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vComDescDirectory[0]), uiSize);
InputBuffer ibBuffer(vComDescDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Rebuilds the current COM+ descriptor.
* @param vBuffer Buffer where the COM+ descriptor will be written to.
**/
void ComHeaderDirectory::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
obBuffer << m_ichComHeader.cb;
obBuffer << m_ichComHeader.MajorRuntimeVersion;
obBuffer << m_ichComHeader.MinorRuntimeVersion;
obBuffer << m_ichComHeader.MetaData.VirtualAddress;
obBuffer << m_ichComHeader.MetaData.Size;
obBuffer << m_ichComHeader.Flags;
obBuffer << m_ichComHeader.EntryPointToken;
obBuffer << m_ichComHeader.Resources.VirtualAddress;
obBuffer << m_ichComHeader.Resources.Size;
obBuffer << m_ichComHeader.StrongNameSignature.VirtualAddress;
obBuffer << m_ichComHeader.StrongNameSignature.Size;
obBuffer << m_ichComHeader.CodeManagerTable.VirtualAddress;
obBuffer << m_ichComHeader.CodeManagerTable.Size;
obBuffer << m_ichComHeader.VTableFixups.VirtualAddress;
obBuffer << m_ichComHeader.VTableFixups.Size;
obBuffer << m_ichComHeader.ExportAddressTableJumps.VirtualAddress;
obBuffer << m_ichComHeader.ExportAddressTableJumps.Size;
obBuffer << m_ichComHeader.ManagedNativeHeader.VirtualAddress;
obBuffer << m_ichComHeader.ManagedNativeHeader.Size;
}
/**
* @return Size in bytes.
**/
unsigned int ComHeaderDirectory::size() const
{
return PELIB_IMAGE_COR20_HEADER::size();
}
/**
* @param strFilename Name of the file.
* @param dwOffset File offset the COM+ descriptor will be written to.
**/
int ComHeaderDirectory::write(const std::string& strFilename, unsigned int dwOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(dwOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
/**
* @return SizeOfHeader value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getSizeOfHeader() const
{
return m_ichComHeader.cb;
}
/**
* @return MajorRuntimeVersion value of the current COM+ descriptor.
**/
word ComHeaderDirectory::getMajorRuntimeVersion() const
{
return m_ichComHeader.MajorRuntimeVersion;
}
/**
* @return MinorRuntimeVersion value of the current COM+ descriptor.
**/
word ComHeaderDirectory::getMinorRuntimeVersion() const
{
return m_ichComHeader.MinorRuntimeVersion;
}
/**
* @return MetaData (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getMetaDataVa() const
{
return m_ichComHeader.MetaData.VirtualAddress;
}
/**
* @return MetaData (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getMetaDataSize() const
{
return m_ichComHeader.MetaData.Size;
}
/**
* @return Flags value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getFlags() const
{
return m_ichComHeader.Flags;
}
/**
* @return EntryPointToken value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getEntryPointToken() const
{
return m_ichComHeader.EntryPointToken;
}
/**
* @return Resources (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getResourcesVa() const
{
return m_ichComHeader.Resources.VirtualAddress;
}
/**
* @return Resources (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getResourcesSize()
{
return m_ichComHeader.Resources.Size;
}
/**
* @return StrongNameSignature (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getStrongNameSignatureVa() const
{
return m_ichComHeader.StrongNameSignature.VirtualAddress;
}
/**
* @return StrongNameSignature (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getStrongNameSignagureSize() const
{
return m_ichComHeader.StrongNameSignature.Size;
}
/**
* @return CodeManagerTable (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getCodeManagerTableVa() const
{
return m_ichComHeader.CodeManagerTable.VirtualAddress;
}
/**
* @return CodeManagerTable (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getCodeManagerTableSize() const
{
return m_ichComHeader.CodeManagerTable.Size;
}
/**
* @return VTableFixups (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getVTableFixupsVa() const
{
return m_ichComHeader.VTableFixups.VirtualAddress;
}
/**
* @return VTableFixups (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getVTableFixupsSize() const
{
return m_ichComHeader.VTableFixups.Size;
}
/**
* @return ExportAddressTableJumps (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getExportAddressTableJumpsVa() const
{
return m_ichComHeader.ExportAddressTableJumps.VirtualAddress;
}
/**
* @return ExportAddressTableJumps (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getExportAddressTableJumpsSize() const
{
return m_ichComHeader.ExportAddressTableJumps.Size;
}
/**
* @return ManagedNativeHeader (Virtual Address) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getManagedNativeHeaderVa() const
{
return m_ichComHeader.ManagedNativeHeader.VirtualAddress;
}
/**
* @return ManagedNativeHeader (Size) value of the current COM+ descriptor.
**/
dword ComHeaderDirectory::getManagedNativeHeaderSize() const
{
return m_ichComHeader.ManagedNativeHeader.Size;
}
/**
* @param dwValue New value for the current SizeOfHeader (cb) value.
**/
void ComHeaderDirectory::setSizeOfHeader(dword dwValue)
{
m_ichComHeader.cb = dwValue;
}
/**
* @param wValue New value for the current MajorRuntimeVersion value.
**/
void ComHeaderDirectory::setMajorRuntimeVersion(word wValue)
{
m_ichComHeader.MajorRuntimeVersion = wValue;
}
/**
* @param wValue New value for the current MinorRuntimeVersion value.
**/
void ComHeaderDirectory::setMinorRuntimeVersion(word wValue)
{
m_ichComHeader.MinorRuntimeVersion = wValue;
}
/**
* @param dwValue New value for the current MetaData (VirtualAddress) value.
**/
void ComHeaderDirectory::setMetaDataVa(dword dwValue)
{
m_ichComHeader.MetaData.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current MetaData (Size) value.
**/
void ComHeaderDirectory::setMetaDataSize(dword dwValue)
{
m_ichComHeader.MetaData.Size = dwValue;
}
/**
* @param dwValue New value for the current Flags value.
**/
void ComHeaderDirectory::setFlags(dword dwValue)
{
m_ichComHeader.Flags = dwValue;
}
/**
* @param dwValue New value for the current EntryPointToken value.
**/
void ComHeaderDirectory::setEntryPointToken(dword dwValue)
{
m_ichComHeader.EntryPointToken = dwValue;
}
/**
* @param dwValue New value for the current Resources (VirtualAddress) value.
**/
void ComHeaderDirectory::setResourcesVa(dword dwValue)
{
m_ichComHeader.Resources.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current Resources (Size) value.
**/
void ComHeaderDirectory::setResourcesSize(dword dwValue)
{
m_ichComHeader.Resources.Size = dwValue;
}
/**
* @param dwValue New value for the current StrongNameSignature (VirtualAddress) value.
**/
void ComHeaderDirectory::setStrongNameSignatureVa(dword dwValue)
{
m_ichComHeader.StrongNameSignature.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current StrongNameSignature (Size) value.
**/
void ComHeaderDirectory::setStrongNameSignagureSize(dword dwValue)
{
m_ichComHeader.StrongNameSignature.Size = dwValue;
}
/**
* @param dwValue New value for the current CodeManagerTable (VirtualAddress) value.
**/
void ComHeaderDirectory::setCodeManagerTableVa(dword dwValue)
{
m_ichComHeader.CodeManagerTable.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current CodeManagerTable (Size) value.
**/
void ComHeaderDirectory::setCodeManagerTableSize(dword dwValue)
{
m_ichComHeader.CodeManagerTable.Size = dwValue;
}
/**
* @param dwValue New value for the current VTableFixups (VirtualAddress) value.
**/
void ComHeaderDirectory::setVTableFixupsVa(dword dwValue)
{
m_ichComHeader.VTableFixups.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current VTableFixups (Size) value.
**/
void ComHeaderDirectory::setVTableFixupsSize(dword dwValue)
{
m_ichComHeader.VTableFixups.Size = dwValue;
}
/**
* @param dwValue New value for the current ExportAddressTableJumps (VirtualAddress) value.
**/
void ComHeaderDirectory::setExportAddressTableJumpsVa(dword dwValue)
{
m_ichComHeader.ExportAddressTableJumps.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current ExportAddressTableJumps (Size) value.
**/
void ComHeaderDirectory::setExportAddressTableJumpsSize(dword dwValue)
{
m_ichComHeader.ExportAddressTableJumps.Size = dwValue;
}
/**
* @param dwValue New value for the current ManagedNativeHeader (VirtualAddress) value.
**/
void ComHeaderDirectory::setManagedNativeHeaderVa(dword dwValue)
{
m_ichComHeader.ManagedNativeHeader.VirtualAddress = dwValue;
}
/**
* @param dwValue New value for the current ManagedNativeHeader (Size) value.
**/
void ComHeaderDirectory::setManagedNativeHeaderSize(dword dwValue)
{
m_ichComHeader.ManagedNativeHeader.Size = dwValue;
}
}

View file

@ -1,120 +1,120 @@
/*
* ComHeaderDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef COMHEADERDIRECTORY_H
#define COMHEADERDIRECTORY_H
namespace PeLib
{
/// Class that handles the COM+ descriptor directory.
/**
* This class handles the COM+ Descriptor directory which was added to PE files
* which work with the .NET runtime modules.
**/
class ComHeaderDirectory
{
private:
PELIB_IMAGE_COR20_HEADER m_ichComHeader; ///< The COM+ descriptor.
void read(InputBuffer& inputbuffer);
public:
/// Read a file's COM+ runtime descriptor directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Rebuild the COM+ descriptor.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the current COM+ descriptor.
unsigned int size() const; // EXPORT
/// Writes the current COM+ descriptor directory to a file.
int write(const std::string& strFilename, unsigned int dwOffset) const; // EXPORT
/// Get the COM+ descriptor's SizeOfHeader (cb) value.
dword getSizeOfHeader() const; // EXPORT
/// Get the COM+ descriptor's MajorRuntimeVersion value.
word getMajorRuntimeVersion() const; // EXPORT
/// Get the COM+ descriptor's MinorRuntimeVersion value.
word getMinorRuntimeVersion() const; // EXPORT
/// Get the COM+ descriptor's MetaData (Virtual Address) value.
dword getMetaDataVa() const; // EXPORT
/// Get the COM+ descriptor's MetaData (Size) value.
dword getMetaDataSize() const; // EXPORT
/// Get the COM+ descriptor's Flags value.
dword getFlags() const; // EXPORT
/// Get the COM+ descriptor's EntryPointToken value.
dword getEntryPointToken() const; // EXPORT
/// Get the COM+ descriptor's Resources (Virtual Address) value.
dword getResourcesVa() const; // EXPORT
/// Get the COM+ descriptor's Resources (Size) value.
dword getResourcesSize(); // EXPORT
/// Get the COM+ descriptor's StrongNameSignature (Virtual Address) value.
dword getStrongNameSignatureVa() const; // EXPORT
/// Get the COM+ descriptor's StrongNameSignature (Size) value.
dword getStrongNameSignagureSize() const; // EXPORT
/// Get the COM+ descriptor's CodeManagerTable (Virtual Address) value.
dword getCodeManagerTableVa() const; // EXPORT
/// Get the COM+ descriptor's CodeManagerTable (Size) value.
dword getCodeManagerTableSize() const; // EXPORT
/// Get the COM+ descriptor's VTableFixup (Virtual Address) value.
dword getVTableFixupsVa() const; // EXPORT
/// Get the COM+ descriptor's VTableFixup (Size) value.
dword getVTableFixupsSize() const; // EXPORT
/// Get the COM+ descriptor's ExportAddressTable (Virtual Address) value.
dword getExportAddressTableJumpsVa() const; // EXPORT
/// Get the COM+ descriptor's ExportAddressTable (Size) value.
dword getExportAddressTableJumpsSize() const; // EXPORT
/// Get the COM+ descriptor's ManagedNativeHeader (Virtual Address) value.
dword getManagedNativeHeaderVa() const; // EXPORT
/// Get the COM+ descriptor's ManagedNativeHeader (Size) value.
dword getManagedNativeHeaderSize() const; // EXPORT
/// Change the COM+ descriptor's SizeOfHeader (cb) value.
void setSizeOfHeader(dword dwValue); // EXPORT
/// Change the COM+ descriptor's MajorRuntimeVersion value.
void setMajorRuntimeVersion(word wValue); // EXPORT
/// Change the COM+ descriptor's MinorRuntimeVersion value.
void setMinorRuntimeVersion(word wValue); // EXPORT
/// Change the COM+ descriptor's MetaData (VirtualAddress) value.
void setMetaDataVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's MetaData (Size) value.
void setMetaDataSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's Flags value.
void setFlags(dword dwValue); // EXPORT
/// Change the COM+ descriptor's EntryPointToken value.
void setEntryPointToken(dword dwValue); // EXPORT
/// Change the COM+ descriptor's Resources (VirtualAddress) value.
void setResourcesVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's Resources (Size) value.
void setResourcesSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's StrongNameSignatureVa (VirtualAddress) value.
void setStrongNameSignatureVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's StrongNameSignatureVa (Size) value.
void setStrongNameSignagureSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's CodeManagerTable (VirtualAddress) value.
void setCodeManagerTableVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's CodeManagerTable (Size) value.
void setCodeManagerTableSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's VTableFixups (VirtualAddress) value.
void setVTableFixupsVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's VTableFixups (Size) value.
void setVTableFixupsSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ExportAddressTableJumps (VirtualAddress) value.
void setExportAddressTableJumpsVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ExportAddressTableJumps (Size) value.
void setExportAddressTableJumpsSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ManagedNativeHeader (VirtualAddress) value.
void setManagedNativeHeaderVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ManagedNativeHeader (Size) value.
void setManagedNativeHeaderSize(dword dwValue); // EXPORT
};
}
#endif
/*
* ComHeaderDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef COMHEADERDIRECTORY_H
#define COMHEADERDIRECTORY_H
namespace PeLib
{
/// Class that handles the COM+ descriptor directory.
/**
* This class handles the COM+ Descriptor directory which was added to PE files
* which work with the .NET runtime modules.
**/
class ComHeaderDirectory
{
private:
PELIB_IMAGE_COR20_HEADER m_ichComHeader; ///< The COM+ descriptor.
void read(InputBuffer& inputbuffer);
public:
/// Read a file's COM+ runtime descriptor directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Rebuild the COM+ descriptor.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the current COM+ descriptor.
unsigned int size() const; // EXPORT
/// Writes the current COM+ descriptor directory to a file.
int write(const std::string& strFilename, unsigned int dwOffset) const; // EXPORT
/// Get the COM+ descriptor's SizeOfHeader (cb) value.
dword getSizeOfHeader() const; // EXPORT
/// Get the COM+ descriptor's MajorRuntimeVersion value.
word getMajorRuntimeVersion() const; // EXPORT
/// Get the COM+ descriptor's MinorRuntimeVersion value.
word getMinorRuntimeVersion() const; // EXPORT
/// Get the COM+ descriptor's MetaData (Virtual Address) value.
dword getMetaDataVa() const; // EXPORT
/// Get the COM+ descriptor's MetaData (Size) value.
dword getMetaDataSize() const; // EXPORT
/// Get the COM+ descriptor's Flags value.
dword getFlags() const; // EXPORT
/// Get the COM+ descriptor's EntryPointToken value.
dword getEntryPointToken() const; // EXPORT
/// Get the COM+ descriptor's Resources (Virtual Address) value.
dword getResourcesVa() const; // EXPORT
/// Get the COM+ descriptor's Resources (Size) value.
dword getResourcesSize(); // EXPORT
/// Get the COM+ descriptor's StrongNameSignature (Virtual Address) value.
dword getStrongNameSignatureVa() const; // EXPORT
/// Get the COM+ descriptor's StrongNameSignature (Size) value.
dword getStrongNameSignagureSize() const; // EXPORT
/// Get the COM+ descriptor's CodeManagerTable (Virtual Address) value.
dword getCodeManagerTableVa() const; // EXPORT
/// Get the COM+ descriptor's CodeManagerTable (Size) value.
dword getCodeManagerTableSize() const; // EXPORT
/// Get the COM+ descriptor's VTableFixup (Virtual Address) value.
dword getVTableFixupsVa() const; // EXPORT
/// Get the COM+ descriptor's VTableFixup (Size) value.
dword getVTableFixupsSize() const; // EXPORT
/// Get the COM+ descriptor's ExportAddressTable (Virtual Address) value.
dword getExportAddressTableJumpsVa() const; // EXPORT
/// Get the COM+ descriptor's ExportAddressTable (Size) value.
dword getExportAddressTableJumpsSize() const; // EXPORT
/// Get the COM+ descriptor's ManagedNativeHeader (Virtual Address) value.
dword getManagedNativeHeaderVa() const; // EXPORT
/// Get the COM+ descriptor's ManagedNativeHeader (Size) value.
dword getManagedNativeHeaderSize() const; // EXPORT
/// Change the COM+ descriptor's SizeOfHeader (cb) value.
void setSizeOfHeader(dword dwValue); // EXPORT
/// Change the COM+ descriptor's MajorRuntimeVersion value.
void setMajorRuntimeVersion(word wValue); // EXPORT
/// Change the COM+ descriptor's MinorRuntimeVersion value.
void setMinorRuntimeVersion(word wValue); // EXPORT
/// Change the COM+ descriptor's MetaData (VirtualAddress) value.
void setMetaDataVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's MetaData (Size) value.
void setMetaDataSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's Flags value.
void setFlags(dword dwValue); // EXPORT
/// Change the COM+ descriptor's EntryPointToken value.
void setEntryPointToken(dword dwValue); // EXPORT
/// Change the COM+ descriptor's Resources (VirtualAddress) value.
void setResourcesVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's Resources (Size) value.
void setResourcesSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's StrongNameSignatureVa (VirtualAddress) value.
void setStrongNameSignatureVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's StrongNameSignatureVa (Size) value.
void setStrongNameSignagureSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's CodeManagerTable (VirtualAddress) value.
void setCodeManagerTableVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's CodeManagerTable (Size) value.
void setCodeManagerTableSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's VTableFixups (VirtualAddress) value.
void setVTableFixupsVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's VTableFixups (Size) value.
void setVTableFixupsSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ExportAddressTableJumps (VirtualAddress) value.
void setExportAddressTableJumpsVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ExportAddressTableJumps (Size) value.
void setExportAddressTableJumpsSize(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ManagedNativeHeader (VirtualAddress) value.
void setManagedNativeHeaderVa(dword dwValue); // EXPORT
/// Change the COM+ descriptor's ManagedNativeHeader (Size) value.
void setManagedNativeHeaderSize(dword dwValue); // EXPORT
};
}
#endif

View file

@ -1,383 +1,383 @@
/*
* DebugDirectory.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "DebugDirectory.h"
namespace PeLib
{
void DebugDirectory::clear()
{
m_vDebugInfo.clear();
}
std::vector<PELIB_IMG_DEBUG_DIRECTORY> DebugDirectory::read(InputBuffer& ibBuffer, unsigned int uiSize)
{
std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo;
PELIB_IMG_DEBUG_DIRECTORY iddCurr;
for (unsigned int i=0;i<uiSize/PELIB_IMAGE_DEBUG_DIRECTORY::size();i++)
{
ibBuffer >> iddCurr.idd.Characteristics;
ibBuffer >> iddCurr.idd.TimeDateStamp;
ibBuffer >> iddCurr.idd.MajorVersion;
ibBuffer >> iddCurr.idd.MinorVersion;
ibBuffer >> iddCurr.idd.Type;
ibBuffer >> iddCurr.idd.SizeOfData;
ibBuffer >> iddCurr.idd.AddressOfRawData;
ibBuffer >> iddCurr.idd.PointerToRawData;
currDebugInfo.push_back(iddCurr);
}
return currDebugInfo;
}
int DebugDirectory::read(unsigned char* buffer, unsigned int buffersize)
{
// XXX: Note, debug data is not read at all. This might or might not change
// in the future.
std::vector<byte> vDebugDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vDebugDirectory);
std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo = read(ibBuffer, buffersize);
std::swap(currDebugInfo, m_vDebugInfo);
return NO_ERROR;
}
/**
* @param strFilename Name of the file which will be read.
* @param uiOffset File offset of the Debug directory.
* @param uiSize Size of the Debug directory.
**/
int DebugDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<byte> vDebugDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vDebugDirectory[0]), uiSize);
InputBuffer ibBuffer(vDebugDirectory);
std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo = read(ibBuffer, uiSize);
for (unsigned int i=0;i<currDebugInfo.size();i++)
{
ifFile.seekg(currDebugInfo[i].idd.PointerToRawData, std::ios::beg);
currDebugInfo[i].data.resize(currDebugInfo[i].idd.SizeOfData);
ifFile.read(reinterpret_cast<char*>(&currDebugInfo[i].data[0]), currDebugInfo[i].idd.SizeOfData);
if (!ifFile) return ERROR_INVALID_FILE;
}
std::swap(currDebugInfo, m_vDebugInfo);
return NO_ERROR;
}
/**
* Rebuilds the current debug directory.
* @param vBuffer Buffer where the rebuilt directory is stored.
**/
void DebugDirectory::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
for (unsigned int i=0;i<m_vDebugInfo.size();i++)
{
obBuffer << m_vDebugInfo[i].idd.Characteristics;
obBuffer << m_vDebugInfo[i].idd.TimeDateStamp;
obBuffer << m_vDebugInfo[i].idd.MajorVersion;
obBuffer << m_vDebugInfo[i].idd.MinorVersion;
obBuffer << m_vDebugInfo[i].idd.Type;
obBuffer << m_vDebugInfo[i].idd.SizeOfData;
obBuffer << m_vDebugInfo[i].idd.AddressOfRawData;
obBuffer << m_vDebugInfo[i].idd.PointerToRawData;
}
}
/**
* @return Size of the debug directory.
**/
unsigned int DebugDirectory::size() const
{
return static_cast<unsigned int>(m_vDebugInfo.size()) * PELIB_IMAGE_DEBUG_DIRECTORY::size();
}
/**
* @param strFilename Name of the file which will be written.
* @param uiOffset File offset where the debug directory will be stored.
**/
int DebugDirectory::write(const std::string& strFilename, unsigned int uiOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(uiOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
/**
* @return Number of debug structures in the current Debug directory.
**/
unsigned int DebugDirectory::calcNumberOfEntries() const
{
return static_cast<unsigned int>(m_vDebugInfo.size());
}
/**
* Adds a new debug structure to the debug directory. The initial values of all members of the structure
* are undefined.
**/
void DebugDirectory::addEntry()
{
PELIB_IMG_DEBUG_DIRECTORY p;
m_vDebugInfo.push_back(p);
}
/**
* Removes a debug structure from the current debug directory. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
**/
void DebugDirectory::removeEntry(unsigned int uiIndex)
{
m_vDebugInfo.erase(m_vDebugInfo.begin() + uiIndex);
}
/**
* Returns the Characteristics value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return Characteristics value of the debug structure.
**/
dword DebugDirectory::getCharacteristics(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.Characteristics;
}
/**
* Returns the TimeDateStamp value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return TimeDateStamp value of the debug structure.
**/
dword DebugDirectory::getTimeDateStamp(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.TimeDateStamp;
}
/**
* Returns the MajorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return MajorVersion value of the debug structure.
**/
word DebugDirectory::getMajorVersion(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.MajorVersion;
}
/**
* Returns the MinorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return MinorVersion value of the debug structure.
**/
word DebugDirectory::getMinorVersion(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.MinorVersion;
}
/**
* Returns the Type value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return Type value of the debug structure.
**/
dword DebugDirectory::getType(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.Type;
}
/**
* Returns the SizeOfData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return SizeOfData value of the debug structure.
**/
dword DebugDirectory::getSizeOfData(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.SizeOfData;
}
/**
* Returns the AddressOfRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return AddressOfRawData value of the debug structure.
**/
dword DebugDirectory::getAddressOfRawData(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.AddressOfRawData;
}
/**
* Returns the PointerToRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return PointerToRawData value of the debug structure.
**/
dword DebugDirectory::getPointerToRawData(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.PointerToRawData;
}
std::vector<byte> DebugDirectory::getData(unsigned int index) const
{
return m_vDebugInfo[index].data;
}
/**
* Changes the Characteristics value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the Characteristics value of the debug structure.
**/
void DebugDirectory::setCharacteristics(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.Characteristics = dwValue;
}
/**
* Changes the TimeDateStamp value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the TimeDateStamp value of the debug structure.
**/
void DebugDirectory::setTimeDateStamp(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.TimeDateStamp = dwValue;
}
/**
* Changes the MajorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param wValue New value of the MajorVersion value of the debug structure.
**/
void DebugDirectory::setMajorVersion(unsigned int uiIndex, word wValue)
{
m_vDebugInfo[uiIndex].idd.MajorVersion = wValue;
}
/**
* Changes the MinorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param wValue New value of the MinorVersion value of the debug structure.
**/
void DebugDirectory::setMinorVersion(unsigned int uiIndex, word wValue)
{
m_vDebugInfo[uiIndex].idd.MinorVersion = wValue;
}
/**
* Changes the Type value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the Type value of the debug structure.
**/
void DebugDirectory::setType(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.Type = dwValue;
}
/**
* Changes the SizeOfData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the SizeOfData value of the debug structure.
**/
void DebugDirectory::setSizeOfData(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.SizeOfData = dwValue;
}
/**
* Changes the AddressOfRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the AddressOfRawData value of the debug structure.
**/
void DebugDirectory::setAddressOfRawData(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.AddressOfRawData = dwValue;
}
/**
* Changes the PointerToRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the PointerToRawData value of the debug structure.
**/
void DebugDirectory::setPointerToRawData(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.PointerToRawData = dwValue;
}
void DebugDirectory::setData(unsigned int index, const std::vector<byte>& data)
{
m_vDebugInfo[index].data = data;
}
}
/*
* DebugDirectory.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "DebugDirectory.h"
namespace PeLib
{
void DebugDirectory::clear()
{
m_vDebugInfo.clear();
}
std::vector<PELIB_IMG_DEBUG_DIRECTORY> DebugDirectory::read(InputBuffer& ibBuffer, unsigned int uiSize)
{
std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo;
PELIB_IMG_DEBUG_DIRECTORY iddCurr;
for (unsigned int i=0;i<uiSize/PELIB_IMAGE_DEBUG_DIRECTORY::size();i++)
{
ibBuffer >> iddCurr.idd.Characteristics;
ibBuffer >> iddCurr.idd.TimeDateStamp;
ibBuffer >> iddCurr.idd.MajorVersion;
ibBuffer >> iddCurr.idd.MinorVersion;
ibBuffer >> iddCurr.idd.Type;
ibBuffer >> iddCurr.idd.SizeOfData;
ibBuffer >> iddCurr.idd.AddressOfRawData;
ibBuffer >> iddCurr.idd.PointerToRawData;
currDebugInfo.push_back(iddCurr);
}
return currDebugInfo;
}
int DebugDirectory::read(unsigned char* buffer, unsigned int buffersize)
{
// XXX: Note, debug data is not read at all. This might or might not change
// in the future.
std::vector<byte> vDebugDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vDebugDirectory);
std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo = read(ibBuffer, buffersize);
std::swap(currDebugInfo, m_vDebugInfo);
return NO_ERROR;
}
/**
* @param strFilename Name of the file which will be read.
* @param uiOffset File offset of the Debug directory.
* @param uiSize Size of the Debug directory.
**/
int DebugDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<byte> vDebugDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vDebugDirectory[0]), uiSize);
InputBuffer ibBuffer(vDebugDirectory);
std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo = read(ibBuffer, uiSize);
for (unsigned int i=0;i<currDebugInfo.size();i++)
{
ifFile.seekg(currDebugInfo[i].idd.PointerToRawData, std::ios::beg);
currDebugInfo[i].data.resize(currDebugInfo[i].idd.SizeOfData);
ifFile.read(reinterpret_cast<char*>(&currDebugInfo[i].data[0]), currDebugInfo[i].idd.SizeOfData);
if (!ifFile) return ERROR_INVALID_FILE;
}
std::swap(currDebugInfo, m_vDebugInfo);
return NO_ERROR;
}
/**
* Rebuilds the current debug directory.
* @param vBuffer Buffer where the rebuilt directory is stored.
**/
void DebugDirectory::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
for (unsigned int i=0;i<m_vDebugInfo.size();i++)
{
obBuffer << m_vDebugInfo[i].idd.Characteristics;
obBuffer << m_vDebugInfo[i].idd.TimeDateStamp;
obBuffer << m_vDebugInfo[i].idd.MajorVersion;
obBuffer << m_vDebugInfo[i].idd.MinorVersion;
obBuffer << m_vDebugInfo[i].idd.Type;
obBuffer << m_vDebugInfo[i].idd.SizeOfData;
obBuffer << m_vDebugInfo[i].idd.AddressOfRawData;
obBuffer << m_vDebugInfo[i].idd.PointerToRawData;
}
}
/**
* @return Size of the debug directory.
**/
unsigned int DebugDirectory::size() const
{
return static_cast<unsigned int>(m_vDebugInfo.size()) * PELIB_IMAGE_DEBUG_DIRECTORY::size();
}
/**
* @param strFilename Name of the file which will be written.
* @param uiOffset File offset where the debug directory will be stored.
**/
int DebugDirectory::write(const std::string& strFilename, unsigned int uiOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(uiOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
/**
* @return Number of debug structures in the current Debug directory.
**/
unsigned int DebugDirectory::calcNumberOfEntries() const
{
return static_cast<unsigned int>(m_vDebugInfo.size());
}
/**
* Adds a new debug structure to the debug directory. The initial values of all members of the structure
* are undefined.
**/
void DebugDirectory::addEntry()
{
PELIB_IMG_DEBUG_DIRECTORY p;
m_vDebugInfo.push_back(p);
}
/**
* Removes a debug structure from the current debug directory. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
**/
void DebugDirectory::removeEntry(unsigned int uiIndex)
{
m_vDebugInfo.erase(m_vDebugInfo.begin() + uiIndex);
}
/**
* Returns the Characteristics value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return Characteristics value of the debug structure.
**/
dword DebugDirectory::getCharacteristics(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.Characteristics;
}
/**
* Returns the TimeDateStamp value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return TimeDateStamp value of the debug structure.
**/
dword DebugDirectory::getTimeDateStamp(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.TimeDateStamp;
}
/**
* Returns the MajorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return MajorVersion value of the debug structure.
**/
word DebugDirectory::getMajorVersion(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.MajorVersion;
}
/**
* Returns the MinorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return MinorVersion value of the debug structure.
**/
word DebugDirectory::getMinorVersion(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.MinorVersion;
}
/**
* Returns the Type value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return Type value of the debug structure.
**/
dword DebugDirectory::getType(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.Type;
}
/**
* Returns the SizeOfData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return SizeOfData value of the debug structure.
**/
dword DebugDirectory::getSizeOfData(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.SizeOfData;
}
/**
* Returns the AddressOfRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return AddressOfRawData value of the debug structure.
**/
dword DebugDirectory::getAddressOfRawData(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.AddressOfRawData;
}
/**
* Returns the PointerToRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @return PointerToRawData value of the debug structure.
**/
dword DebugDirectory::getPointerToRawData(unsigned int uiIndex) const
{
return m_vDebugInfo[uiIndex].idd.PointerToRawData;
}
std::vector<byte> DebugDirectory::getData(unsigned int index) const
{
return m_vDebugInfo[index].data;
}
/**
* Changes the Characteristics value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the Characteristics value of the debug structure.
**/
void DebugDirectory::setCharacteristics(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.Characteristics = dwValue;
}
/**
* Changes the TimeDateStamp value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the TimeDateStamp value of the debug structure.
**/
void DebugDirectory::setTimeDateStamp(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.TimeDateStamp = dwValue;
}
/**
* Changes the MajorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param wValue New value of the MajorVersion value of the debug structure.
**/
void DebugDirectory::setMajorVersion(unsigned int uiIndex, word wValue)
{
m_vDebugInfo[uiIndex].idd.MajorVersion = wValue;
}
/**
* Changes the MinorVersion value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param wValue New value of the MinorVersion value of the debug structure.
**/
void DebugDirectory::setMinorVersion(unsigned int uiIndex, word wValue)
{
m_vDebugInfo[uiIndex].idd.MinorVersion = wValue;
}
/**
* Changes the Type value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the Type value of the debug structure.
**/
void DebugDirectory::setType(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.Type = dwValue;
}
/**
* Changes the SizeOfData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the SizeOfData value of the debug structure.
**/
void DebugDirectory::setSizeOfData(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.SizeOfData = dwValue;
}
/**
* Changes the AddressOfRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the AddressOfRawData value of the debug structure.
**/
void DebugDirectory::setAddressOfRawData(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.AddressOfRawData = dwValue;
}
/**
* Changes the PointerToRawData value of a debug structure. If an invalid structure is specified
* by the parameter uiIndex the result will be undefined behaviour.
* @param uiIndex Identifies the debug structure.
* @param dwValue New value of the PointerToRawData value of the debug structure.
**/
void DebugDirectory::setPointerToRawData(unsigned int uiIndex, dword dwValue)
{
m_vDebugInfo[uiIndex].idd.PointerToRawData = dwValue;
}
void DebugDirectory::setData(unsigned int index, const std::vector<byte>& data)
{
m_vDebugInfo[index].data = data;
}
}

168
utils/zenutils/libraries/pelib-0.9/pelib/DebugDirectory.h Executable file → Normal file
View file

@ -1,84 +1,84 @@
/*
* DebugDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef DEBUGDIRECTORY_H
#define DEBUGDIRECTORY_H
namespace PeLib
{
/// Class that handles the Debug directory.
class DebugDirectory
{
private:
/// Stores the various DebugDirectory structures.
std::vector<PELIB_IMG_DEBUG_DIRECTORY> m_vDebugInfo;
std::vector<PELIB_IMG_DEBUG_DIRECTORY> read(InputBuffer& ibBuffer, unsigned int uiSize);
public:
void clear(); // EXPORT
/// Reads the Debug directory from a file.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize);
/// Rebuilds the current Debug directory.
void rebuild(std::vector<byte>& obBuffer) const; // EXPORT
/// Returns the size the current Debug directory needs after rebuilding.
unsigned int size() const;
/// Writes the current Debug directory back to a file.
int write(const std::string& strFilename, unsigned int uiOffset) const; // EXPORT
/// Returns the number of DebugDirectory image structures in the current DebugDirectory.
unsigned int calcNumberOfEntries() const; // EXPORT
/// Adds a new debug structure.
void addEntry(); // EXPORT
/// Removes a debug structure.
void removeEntry(unsigned int uiIndex); // EXPORT
/// Returns the Characteristics value of a debug structure.
dword getCharacteristics(unsigned int uiIndex) const; // EXPORT
/// Returns the TimeDateStamp value of a debug structure.
dword getTimeDateStamp(unsigned int uiIndex) const; // EXPORT
/// Returns the MajorVersion value of a debug structure.
word getMajorVersion(unsigned int uiIndex) const; // EXPORT
/// Returns the MinorVersion value of a debug structure.
word getMinorVersion(unsigned int uiIndex) const; // EXPORT
/// Returns the Type value of a debug structure.
dword getType(unsigned int uiIndex) const; // EXPORT
/// Returns the SizeOfData value of a debug structure.
dword getSizeOfData(unsigned int uiIndex) const; // EXPORT
/// Returns the AddressOfRawData value of a debug structure.
dword getAddressOfRawData(unsigned int uiIndex) const; // EXPORT
/// Returns the PointerToRawData value of a debug structure.
dword getPointerToRawData(unsigned int uiIndex) const; // EXPORT
std::vector<byte> getData(unsigned int index) const; // EXPORT
/// Sets the Characteristics value of a debug structure.
void setCharacteristics(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the TimeDateStamp value of a debug structure.
void setTimeDateStamp(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the MajorVersion value of a debug structure.
void setMajorVersion(unsigned int uiIndex, word wValue); // EXPORT
/// Sets the MinorVersion value of a debug structure.
void setMinorVersion(unsigned int uiIndex, word wValue); // EXPORT
/// Sets the Type value of a debug structure.
void setType(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the SizeOfData value of a debug structure.
void setSizeOfData(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the AddressOfRawData value of a debug structure.
void setAddressOfRawData(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the PointerToRawData value of a debug structure.
void setPointerToRawData(unsigned int uiIndex, dword dwValue); // EXPORT
void setData(unsigned int index, const std::vector<byte>& data); // EXPORT
};
}
#endif
/*
* DebugDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef DEBUGDIRECTORY_H
#define DEBUGDIRECTORY_H
namespace PeLib
{
/// Class that handles the Debug directory.
class DebugDirectory
{
private:
/// Stores the various DebugDirectory structures.
std::vector<PELIB_IMG_DEBUG_DIRECTORY> m_vDebugInfo;
std::vector<PELIB_IMG_DEBUG_DIRECTORY> read(InputBuffer& ibBuffer, unsigned int uiSize);
public:
void clear(); // EXPORT
/// Reads the Debug directory from a file.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize);
/// Rebuilds the current Debug directory.
void rebuild(std::vector<byte>& obBuffer) const; // EXPORT
/// Returns the size the current Debug directory needs after rebuilding.
unsigned int size() const;
/// Writes the current Debug directory back to a file.
int write(const std::string& strFilename, unsigned int uiOffset) const; // EXPORT
/// Returns the number of DebugDirectory image structures in the current DebugDirectory.
unsigned int calcNumberOfEntries() const; // EXPORT
/// Adds a new debug structure.
void addEntry(); // EXPORT
/// Removes a debug structure.
void removeEntry(unsigned int uiIndex); // EXPORT
/// Returns the Characteristics value of a debug structure.
dword getCharacteristics(unsigned int uiIndex) const; // EXPORT
/// Returns the TimeDateStamp value of a debug structure.
dword getTimeDateStamp(unsigned int uiIndex) const; // EXPORT
/// Returns the MajorVersion value of a debug structure.
word getMajorVersion(unsigned int uiIndex) const; // EXPORT
/// Returns the MinorVersion value of a debug structure.
word getMinorVersion(unsigned int uiIndex) const; // EXPORT
/// Returns the Type value of a debug structure.
dword getType(unsigned int uiIndex) const; // EXPORT
/// Returns the SizeOfData value of a debug structure.
dword getSizeOfData(unsigned int uiIndex) const; // EXPORT
/// Returns the AddressOfRawData value of a debug structure.
dword getAddressOfRawData(unsigned int uiIndex) const; // EXPORT
/// Returns the PointerToRawData value of a debug structure.
dword getPointerToRawData(unsigned int uiIndex) const; // EXPORT
std::vector<byte> getData(unsigned int index) const; // EXPORT
/// Sets the Characteristics value of a debug structure.
void setCharacteristics(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the TimeDateStamp value of a debug structure.
void setTimeDateStamp(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the MajorVersion value of a debug structure.
void setMajorVersion(unsigned int uiIndex, word wValue); // EXPORT
/// Sets the MinorVersion value of a debug structure.
void setMinorVersion(unsigned int uiIndex, word wValue); // EXPORT
/// Sets the Type value of a debug structure.
void setType(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the SizeOfData value of a debug structure.
void setSizeOfData(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the AddressOfRawData value of a debug structure.
void setAddressOfRawData(unsigned int uiIndex, dword dwValue); // EXPORT
/// Sets the PointerToRawData value of a debug structure.
void setPointerToRawData(unsigned int uiIndex, dword dwValue); // EXPORT
void setData(unsigned int index, const std::vector<byte>& data); // EXPORT
};
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,133 +1,133 @@
/*
* ExportDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef EXPORTDIRECTORY_H
#define EXPORTDIRECTORY_H
#include "PeHeader.h"
namespace PeLib
{
/// Class that handles the export directory.
/**
* This class handles the export directory.
* \todo getNameString
**/
// template<int bits>
class ExportDirectory
{
private:
/// Used to store all necessary information about a file's exported functions.
PELIB_IMAGE_EXP_DIRECTORY m_ied;
public:
/// Add another function to be exported.
void addFunction(const std::string& strFuncname, dword dwFuncAddr); // EXPORT
unsigned int calcNumberOfFunctions() const; // EXPORT
void clear(); // EXPORT
/// Identifies a function through it's name.
int getFunctionIndex(const std::string& strFunctionName) const; // EXPORT
/// Read a file's export directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize, const PeHeader& pehHeader); // EXPORT
/// Rebuild the current export directory.
void rebuild(std::vector<byte>& vBuffer, dword dwRva) const; // EXPORT
void removeFunction(unsigned int index); // EXPORT
/// Returns the size of the current export directory.
unsigned int size() const; // EXPORT
/// Writes the current export directory to a file.
int write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const; // EXPORT
/// Changes the name of the file (according to the export directory).
void setNameString(const std::string& strFilename); // EXPORT
std::string getNameString() const; // EXPORT
/// Get the name of an exported function.
std::string getFunctionName(unsigned int index) const; // EXPORT
/// Get the ordinal of an exported function.
word getFunctionOrdinal(unsigned int index) const; // EXPORT
/// Get the address of the name of an exported function.
dword getAddressOfName(unsigned int index) const; // EXPORT
/// Get the address of an exported function.
dword getAddressOfFunction(unsigned int index) const; // EXPORT
/// Change the name of an exported function.
void setFunctionName(unsigned int index, const std::string& strName); // EXPORT
/// Change the ordinal of an exported function.
void setFunctionOrdinal(unsigned int index, word wValue); // EXPORT
/// Change the address of the name of an exported function.
void setAddressOfName(unsigned int index, dword dwValue); // EXPORT
/// Change the address of an exported function.
void setAddressOfFunction(unsigned int index, dword dwValue); // EXPORT
/*
word getFunctionOrdinal(std::string strFuncname) const;
dword getAddressOfName(std::string strFuncname) const;
dword getAddressOfFunction(std::string strFuncname) const;
void setFunctionOrdinal(std::string strFuncname, word wValue);
void setAddressOfName(std::string strFuncname, dword dwValue);
void setAddressOfFunction(std::string strFuncname, dword dwValue);
*/
/// Return the Base value of the export directory.
dword getBase() const; // EXPORT
/// Return the Characteristics value of the export directory.
dword getCharacteristics() const; // EXPORT
/// Return the TimeDateStamp value of the export directory.
dword getTimeDateStamp() const; // EXPORT
/// Return the MajorVersion value of the export directory.
word getMajorVersion() const; // EXPORT
/// Return the MinorVersion value of the export directory.
word getMinorVersion() const; // EXPORT
/// Return the Name value of the export directory.
dword getName() const; // EXPORT
/// Return the NumberOfFunctions value of the export directory.
dword getNumberOfFunctions() const; // EXPORT
/// Return the NumberOfNames value of the export directory.
dword getNumberOfNames() const; // EXPORT
/// Return the AddressOfFunctions value of the export directory.
dword getAddressOfFunctions() const; // EXPORT
/// Return the AddressOfNames value of the export directory.
dword getAddressOfNames() const; // EXPORT
/// Returns the AddressOfNameOrdinals value.
dword getAddressOfNameOrdinals() const; // EXPORT
/* /// Returns the number of NameOrdinals.
dword getNumberOfNameOrdinals() const; // EXPORT
/// Returns the number of AddressOfFunctionNames values.
dword getNumberOfAddressOfFunctionNames() const; // EXPORT
/// Returns the number of AddressOfFunction values.
dword getNumberOfAddressOfFunctions() const; // EXPORT
*/
/// Set the Base value of the export directory.
void setBase(dword dwValue); // EXPORT
/// Set the Characteristics value of the export directory.
void setCharacteristics(dword dwValue); // EXPORT
/// Set the TimeDateStamp value of the export directory.
void setTimeDateStamp(dword dwValue); // EXPORT
/// Set the MajorVersion value of the export directory.
void setMajorVersion(word wValue); // EXPORT
/// Set the MinorVersion value of the export directory.
void setMinorVersion(word wValue); // EXPORT
/// Set the Name value of the export directory.
void setName(dword dwValue); // EXPORT
/// Set the NumberOfFunctions value of the export directory.
void setNumberOfFunctions(dword dwValue); // EXPORT
/// Set the NumberOfNames value of the export directory.
void setNumberOfNames(dword dwValue); // EXPORT
/// Set the AddressOfFunctions value of the export directory.
void setAddressOfFunctions(dword dwValue); // EXPORT
/// Set the AddressOfNames value of the export directory.
void setAddressOfNames(dword dwValue); // EXPORT
void setAddressOfNameOrdinals(dword value); // EXPORT
};
}
#endif
/*
* ExportDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef EXPORTDIRECTORY_H
#define EXPORTDIRECTORY_H
#include "PeHeader.h"
namespace PeLib
{
/// Class that handles the export directory.
/**
* This class handles the export directory.
* \todo getNameString
**/
// template<int bits>
class ExportDirectory
{
private:
/// Used to store all necessary information about a file's exported functions.
PELIB_IMAGE_EXP_DIRECTORY m_ied;
public:
/// Add another function to be exported.
void addFunction(const std::string& strFuncname, dword dwFuncAddr); // EXPORT
unsigned int calcNumberOfFunctions() const; // EXPORT
void clear(); // EXPORT
/// Identifies a function through it's name.
int getFunctionIndex(const std::string& strFunctionName) const; // EXPORT
/// Read a file's export directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize, const PeHeader& pehHeader); // EXPORT
/// Rebuild the current export directory.
void rebuild(std::vector<byte>& vBuffer, dword dwRva) const; // EXPORT
void removeFunction(unsigned int index); // EXPORT
/// Returns the size of the current export directory.
unsigned int size() const; // EXPORT
/// Writes the current export directory to a file.
int write(const std::string& strFilename, unsigned int uiOffset, unsigned int uiRva) const; // EXPORT
/// Changes the name of the file (according to the export directory).
void setNameString(const std::string& strFilename); // EXPORT
std::string getNameString() const; // EXPORT
/// Get the name of an exported function.
std::string getFunctionName(unsigned int index) const; // EXPORT
/// Get the ordinal of an exported function.
word getFunctionOrdinal(unsigned int index) const; // EXPORT
/// Get the address of the name of an exported function.
dword getAddressOfName(unsigned int index) const; // EXPORT
/// Get the address of an exported function.
dword getAddressOfFunction(unsigned int index) const; // EXPORT
/// Change the name of an exported function.
void setFunctionName(unsigned int index, const std::string& strName); // EXPORT
/// Change the ordinal of an exported function.
void setFunctionOrdinal(unsigned int index, word wValue); // EXPORT
/// Change the address of the name of an exported function.
void setAddressOfName(unsigned int index, dword dwValue); // EXPORT
/// Change the address of an exported function.
void setAddressOfFunction(unsigned int index, dword dwValue); // EXPORT
/*
word getFunctionOrdinal(std::string strFuncname) const;
dword getAddressOfName(std::string strFuncname) const;
dword getAddressOfFunction(std::string strFuncname) const;
void setFunctionOrdinal(std::string strFuncname, word wValue);
void setAddressOfName(std::string strFuncname, dword dwValue);
void setAddressOfFunction(std::string strFuncname, dword dwValue);
*/
/// Return the Base value of the export directory.
dword getBase() const; // EXPORT
/// Return the Characteristics value of the export directory.
dword getCharacteristics() const; // EXPORT
/// Return the TimeDateStamp value of the export directory.
dword getTimeDateStamp() const; // EXPORT
/// Return the MajorVersion value of the export directory.
word getMajorVersion() const; // EXPORT
/// Return the MinorVersion value of the export directory.
word getMinorVersion() const; // EXPORT
/// Return the Name value of the export directory.
dword getName() const; // EXPORT
/// Return the NumberOfFunctions value of the export directory.
dword getNumberOfFunctions() const; // EXPORT
/// Return the NumberOfNames value of the export directory.
dword getNumberOfNames() const; // EXPORT
/// Return the AddressOfFunctions value of the export directory.
dword getAddressOfFunctions() const; // EXPORT
/// Return the AddressOfNames value of the export directory.
dword getAddressOfNames() const; // EXPORT
/// Returns the AddressOfNameOrdinals value.
dword getAddressOfNameOrdinals() const; // EXPORT
/* /// Returns the number of NameOrdinals.
dword getNumberOfNameOrdinals() const; // EXPORT
/// Returns the number of AddressOfFunctionNames values.
dword getNumberOfAddressOfFunctionNames() const; // EXPORT
/// Returns the number of AddressOfFunction values.
dword getNumberOfAddressOfFunctions() const; // EXPORT
*/
/// Set the Base value of the export directory.
void setBase(dword dwValue); // EXPORT
/// Set the Characteristics value of the export directory.
void setCharacteristics(dword dwValue); // EXPORT
/// Set the TimeDateStamp value of the export directory.
void setTimeDateStamp(dword dwValue); // EXPORT
/// Set the MajorVersion value of the export directory.
void setMajorVersion(word wValue); // EXPORT
/// Set the MinorVersion value of the export directory.
void setMinorVersion(word wValue); // EXPORT
/// Set the Name value of the export directory.
void setName(dword dwValue); // EXPORT
/// Set the NumberOfFunctions value of the export directory.
void setNumberOfFunctions(dword dwValue); // EXPORT
/// Set the NumberOfNames value of the export directory.
void setNumberOfNames(dword dwValue); // EXPORT
/// Set the AddressOfFunctions value of the export directory.
void setAddressOfFunctions(dword dwValue); // EXPORT
/// Set the AddressOfNames value of the export directory.
void setAddressOfNames(dword dwValue); // EXPORT
void setAddressOfNameOrdinals(dword value); // EXPORT
};
}
#endif

358
utils/zenutils/libraries/pelib-0.9/pelib/IatDirectory.cpp Executable file → Normal file
View file

@ -1,179 +1,179 @@
/*
* IatDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "IatDirectory.h"
namespace PeLib
{
int IatDirectory::read(InputBuffer& inputBuffer, unsigned int size)
{
dword dwAddr;
std::vector<dword> vIat;
for (unsigned int i=0;i<size/sizeof(dword);i++)
{
inputBuffer >> dwAddr;
vIat.push_back(dwAddr);
}
std::swap(vIat, m_vIat);
return NO_ERROR;
}
/**
* Reads the Import Address table from a file.
* @param strFilename Name of the file.
* @param dwOffset File offset of the IAT (see #PeFile::PeHeader::getIDIatRVA).
* @param dwSize Size of the IAT (see #PeFile::PeHeader::getIDIatSize).
**/
int IatDirectory::read(const std::string& strFilename, unsigned int dwOffset, unsigned int dwSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (fileSize(ifFile) < dwOffset + dwSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(dwOffset, std::ios::beg);
std::vector<byte> vBuffer(dwSize);
ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), dwSize);
InputBuffer inpBuffer(vBuffer);
return read(inpBuffer, dwSize);
}
int IatDirectory::read(unsigned char* buffer, unsigned int buffersize)
{
std::vector<byte> vBuffer(buffer, buffer + buffersize);
InputBuffer inpBuffer(vBuffer);
return read(inpBuffer, buffersize);
}
/**
* Returns the number of fields in the IAT. This is equivalent to the number of
* imported functions.
* @return Number of fields in the IAT.
**/
unsigned int IatDirectory::calcNumberOfAddresses() const
{
return static_cast<unsigned int>(m_vIat.size());
}
/**
* Returns the dwValue of a field in the IAT.
* @param dwAddrnr Number identifying the field.
* @return dwValue of the field.
**/
dword IatDirectory::getAddress(unsigned int index) const
{
return m_vIat[index];
}
/**
* Updates the dwValue of a field in the IAT.
* @param dwAddrnr Number identifying the field.
* @param dwValue New dwValue of the field.
**/
void IatDirectory::setAddress(dword dwAddrnr, dword dwValue)
{
m_vIat[dwAddrnr] = dwValue;
}
/**
* Adds another field to the IAT.
* @param dwValue dwValue of the new field.
**/
void IatDirectory::addAddress(dword dwValue)
{
m_vIat.push_back(dwValue);
}
/**
* Removes an address from the IAT.
* @param dwAddrnr Number identifying the field.
**/
void IatDirectory::removeAddress(unsigned int index)
{
std::vector<dword>::iterator pos = m_vIat.begin() + index;
m_vIat.erase(pos);
}
/**
* Delete all entries from the IAT.
**/
void IatDirectory::clear()
{
m_vIat.clear();
}
/**
* Rebuilds the complete Import Address Table.
* @param vBuffer Buffer where the rebuilt IAT will be stored.
**/
void IatDirectory::rebuild(std::vector<byte>& vBuffer) const
{
vBuffer.reserve(size());
OutputBuffer obBuffer(vBuffer);
for (unsigned int i=0;i<m_vIat.size();i++)
{
obBuffer << m_vIat[i];
}
}
unsigned int IatDirectory::size() const
{
return static_cast<unsigned int>(m_vIat.size())* sizeof(dword);
}
/// Writes the current IAT to a file.
int IatDirectory::write(const std::string& strFilename, unsigned int uiOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(uiOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
}
/*
* IatDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "IatDirectory.h"
namespace PeLib
{
int IatDirectory::read(InputBuffer& inputBuffer, unsigned int size)
{
dword dwAddr;
std::vector<dword> vIat;
for (unsigned int i=0;i<size/sizeof(dword);i++)
{
inputBuffer >> dwAddr;
vIat.push_back(dwAddr);
}
std::swap(vIat, m_vIat);
return NO_ERROR;
}
/**
* Reads the Import Address table from a file.
* @param strFilename Name of the file.
* @param dwOffset File offset of the IAT (see #PeFile::PeHeader::getIDIatRVA).
* @param dwSize Size of the IAT (see #PeFile::PeHeader::getIDIatSize).
**/
int IatDirectory::read(const std::string& strFilename, unsigned int dwOffset, unsigned int dwSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (fileSize(ifFile) < dwOffset + dwSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(dwOffset, std::ios::beg);
std::vector<byte> vBuffer(dwSize);
ifFile.read(reinterpret_cast<char*>(&vBuffer[0]), dwSize);
InputBuffer inpBuffer(vBuffer);
return read(inpBuffer, dwSize);
}
int IatDirectory::read(unsigned char* buffer, unsigned int buffersize)
{
std::vector<byte> vBuffer(buffer, buffer + buffersize);
InputBuffer inpBuffer(vBuffer);
return read(inpBuffer, buffersize);
}
/**
* Returns the number of fields in the IAT. This is equivalent to the number of
* imported functions.
* @return Number of fields in the IAT.
**/
unsigned int IatDirectory::calcNumberOfAddresses() const
{
return static_cast<unsigned int>(m_vIat.size());
}
/**
* Returns the dwValue of a field in the IAT.
* @param dwAddrnr Number identifying the field.
* @return dwValue of the field.
**/
dword IatDirectory::getAddress(unsigned int index) const
{
return m_vIat[index];
}
/**
* Updates the dwValue of a field in the IAT.
* @param dwAddrnr Number identifying the field.
* @param dwValue New dwValue of the field.
**/
void IatDirectory::setAddress(dword dwAddrnr, dword dwValue)
{
m_vIat[dwAddrnr] = dwValue;
}
/**
* Adds another field to the IAT.
* @param dwValue dwValue of the new field.
**/
void IatDirectory::addAddress(dword dwValue)
{
m_vIat.push_back(dwValue);
}
/**
* Removes an address from the IAT.
* @param dwAddrnr Number identifying the field.
**/
void IatDirectory::removeAddress(unsigned int index)
{
std::vector<dword>::iterator pos = m_vIat.begin() + index;
m_vIat.erase(pos);
}
/**
* Delete all entries from the IAT.
**/
void IatDirectory::clear()
{
m_vIat.clear();
}
/**
* Rebuilds the complete Import Address Table.
* @param vBuffer Buffer where the rebuilt IAT will be stored.
**/
void IatDirectory::rebuild(std::vector<byte>& vBuffer) const
{
vBuffer.reserve(size());
OutputBuffer obBuffer(vBuffer);
for (unsigned int i=0;i<m_vIat.size();i++)
{
obBuffer << m_vIat[i];
}
}
unsigned int IatDirectory::size() const
{
return static_cast<unsigned int>(m_vIat.size())* sizeof(dword);
}
/// Writes the current IAT to a file.
int IatDirectory::write(const std::string& strFilename, unsigned int uiOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(uiOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<unsigned int>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
}

116
utils/zenutils/libraries/pelib-0.9/pelib/IatDirectory.h Executable file → Normal file
View file

@ -1,58 +1,58 @@
/*
* IatDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef IATDIRECTORY_H
#define IATDIRECTORY_H
#include "PeLibInc.h"
namespace PeLib
{
/// Class that handles the Import Address Table (IAT)
/**
* This class can read and modify the Import Address Table of a PE file.
**/
class IatDirectory
{
private:
std::vector<dword> m_vIat; ///< Stores the individual IAT fields.
int read(InputBuffer& inputBuffer, unsigned int size);
public:
/// Reads the Import Address Table from a PE file.
int read(const std::string& strFilename, unsigned int dwOffset, unsigned int dwSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Returns the number of fields in the IAT.
unsigned int calcNumberOfAddresses() const; // EXPORT
/// Adds another address to the IAT.
void addAddress(dword dwValue); // EXPORT
/// Removes an address from the IAT.
void removeAddress(unsigned int index); // EXPORT
/// Empties the IAT.
void clear(); // EXPORT
// Rebuilds the IAT.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the current IAT.
unsigned int size() const; // EXPORT
/// Writes the current IAT to a file.
int write(const std::string& strFilename, unsigned int uiOffset) const; // EXPORT
/// Retrieve the value of a field in the IAT.
dword getAddress(unsigned int index) const; // EXPORT
/// Change the value of a field in the IAT.
void setAddress(dword dwAddrnr, dword dwValue); // EXPORT
};
}
#endif
/*
* IatDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef IATDIRECTORY_H
#define IATDIRECTORY_H
#include "PeLibInc.h"
namespace PeLib
{
/// Class that handles the Import Address Table (IAT)
/**
* This class can read and modify the Import Address Table of a PE file.
**/
class IatDirectory
{
private:
std::vector<dword> m_vIat; ///< Stores the individual IAT fields.
int read(InputBuffer& inputBuffer, unsigned int size);
public:
/// Reads the Import Address Table from a PE file.
int read(const std::string& strFilename, unsigned int dwOffset, unsigned int dwSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Returns the number of fields in the IAT.
unsigned int calcNumberOfAddresses() const; // EXPORT
/// Adds another address to the IAT.
void addAddress(dword dwValue); // EXPORT
/// Removes an address from the IAT.
void removeAddress(unsigned int index); // EXPORT
/// Empties the IAT.
void clear(); // EXPORT
// Rebuilds the IAT.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the current IAT.
unsigned int size() const; // EXPORT
/// Writes the current IAT to a file.
int write(const std::string& strFilename, unsigned int uiOffset) const; // EXPORT
/// Retrieve the value of a field in the IAT.
dword getAddress(unsigned int index) const; // EXPORT
/// Change the value of a field in the IAT.
void setAddress(dword dwAddrnr, dword dwValue); // EXPORT
};
}
#endif

2278
utils/zenutils/libraries/pelib-0.9/pelib/ImportDirectory.h Executable file → Normal file

File diff suppressed because it is too large Load diff

1168
utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.cpp Executable file → Normal file

File diff suppressed because it is too large Load diff

296
utils/zenutils/libraries/pelib-0.9/pelib/MzHeader.h Executable file → Normal file
View file

@ -1,148 +1,148 @@
/*
* MzHeader.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef MZHEADER_H
#define MZHEADER_H
#include "PeLibInc.h"
namespace PeLib
{
/// Class that handles the MZ header of files.
/**
* This class can read and modify MZ headers. It provides set- and get functions to access
* all individual members of a MZ header. Furthermore it's possible to validate and rebuild
* MZ headers.
**/
class MzHeader
{
private:
PELIB_IMAGE_DOS_HEADER m_idhHeader; ///< Stores all MZ header information.
/// Reads data from an InputBuffer into a MZ header struct.
void read(InputBuffer& ibBuffer);
/// Offset of the MZ header in the original file.
unsigned int originalOffset;
public:
enum Field {e_magic, e_cblp, e_cp, e_crlc, e_cparhdr, e_minalloc, e_maxalloc,
e_ss, e_sp, e_csum, e_ip, e_cs, e_lfarlc, e_ovno, e_res, e_oemid,
e_oeminfo, e_res2, e_lfanew};
/// Checks if the current MZ header is valid.
bool isValid() const; // EXPORT
bool isValid(Field field) const; // EXPORT _field
/// Corrects the current MZ header.
void makeValid(); // EXPORT
void makeValid(Field field); // EXPORT _field
/// Reads the MZ header of a file.
int read(const std::string& strFilename); // EXPORT
/// Reads the MZ header from a memory location.
int read(unsigned char* pcBuffer, unsigned int uiSize, unsigned int originalOffs = 0); // EXPORT _fromMemory
/// Rebuild the MZ header.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the current MZ header.
unsigned int size() const; // EXPORT
/// Writes the current MZ header to offset 0 of a file.
int write(const std::string& strFilename, dword dwOffset) const; // EXPORT
/// Gets the e_magic value of the MZ header.
word getMagicNumber() const; // EXPORT
/// Gets the e_cblp value of the MZ header.
word getBytesOnLastPage() const; // EXPORT
/// Gets the e_cp value of the MZ header.
word getPagesInFile() const; // EXPORT
/// Gets the e_crlc value of the MZ header.
word getRelocations() const; // EXPORT
/// Gets the e_cparhdr value of the MZ header.
word getSizeOfHeader() const; // EXPORT
/// Gets the e_minalloc value of the MZ header.
word getMinExtraParagraphs() const; // EXPORT
/// Gets the e_maxalloc value of the MZ header.
word getMaxExtraParagraphs() const; // EXPORT
/// Gets the e_ss value of the MZ header.
word getSsValue() const; // EXPORT
/// Gets the e_sp value of the MZ header.
word getSpValue() const; // EXPORT
/// Gets the e_csum value of the MZ header.
word getChecksum() const; // EXPORT
/// Gets the e_ip value of the MZ header.
word getIpValue() const; // EXPORT
/// Gets the e_cs value of the MZ header.
word getCsValue() const; // EXPORT
/// Gets the e_lfarlc value of the MZ header.
word getAddrOfRelocationTable() const; // EXPORT
/// Gets the e_ovnovalue of the MZ header.
word getOverlayNumber() const; // EXPORT
/// Gets the e_oemid value of the MZ header.
word getOemIdentifier() const; // EXPORT
/// Gets the e_oeminfo value of the MZ header.
word getOemInformation() const; // EXPORT
/// Gets the e_lfanew value of the MZ header.
dword getAddressOfPeHeader() const; // EXPORT
/// Gets the e_res of the MZ header.
word getReservedWords1(unsigned int uiNr) const; // EXPORT
/// Gets the e_res2 of the MZ header.
word getReservedWords2(unsigned int uiNr) const; // EXPORT
/// Sets the e_magic value of the MZ header.
void setMagicNumber(word wValue); // EXPORT
/// Sets the e_cblp value of the MZ header.
void setBytesOnLastPage(word wValue); // EXPORT
/// Sets the e_cp value of the MZ header.
void setPagesInFile(word wValue); // EXPORT
/// Sets the e_crlc value of the MZ header.
void setRelocations(word wValue); // EXPORT
/// Sets the e_cparhdr value of the MZ header.
void setSizeOfHeader(word wValue); // EXPORT
/// Sets the e_minalloc value of the MZ header.
void setMinExtraParagraphs(word wValue); // EXPORT
/// Sets the e_maxalloc value of the MZ header.
void setMaxExtraParagraphs(word wValue); // EXPORT
/// Sets the e_ss value of the MZ header.
void setSsValue(word wValue); // EXPORT
/// Sets the e_sp value of the MZ header.
void setSpValue(word wValue); // EXPORT
/// Sets the e_csum value of the MZ header.
void setChecksum(word wValue); // EXPORT
/// Sets the e_ip value of the MZ header.
void setIpValue(word wValue); // EXPORT
/// Sets the e_cs value of the MZ header.
void setCsValue(word wValue); // EXPORT
/// Sets the e_lfarlc value of the MZ header.
void setAddrOfRelocationTable(word wValue); // EXPORT
/// Sets the e_ovno value of the MZ header.
void setOverlayNumber(word wValue); // EXPORT
/// Sets the e_oemid value of the MZ header.
void setOemIdentifier(word wValue); // EXPORT
/// Sets the e_oeminfo value of the MZ header.
void setOemInformation(word wValue); // EXPORT
/// Sets the e_lfanew value of the MZ header.
void setAddressOfPeHeader(dword dwValue); // EXPORT
/// Sets the e_res value of the MZ header.
void setReservedWords1(unsigned int uiNr, word wValue); // EXPORT
/// Sets the e_res2 value of the MZ header.
void setReservedWords2(unsigned int uiNr, word wValue); // EXPORT
};
}
#endif
/*
* MzHeader.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef MZHEADER_H
#define MZHEADER_H
#include "PeLibInc.h"
namespace PeLib
{
/// Class that handles the MZ header of files.
/**
* This class can read and modify MZ headers. It provides set- and get functions to access
* all individual members of a MZ header. Furthermore it's possible to validate and rebuild
* MZ headers.
**/
class MzHeader
{
private:
PELIB_IMAGE_DOS_HEADER m_idhHeader; ///< Stores all MZ header information.
/// Reads data from an InputBuffer into a MZ header struct.
void read(InputBuffer& ibBuffer);
/// Offset of the MZ header in the original file.
unsigned int originalOffset;
public:
enum Field {e_magic, e_cblp, e_cp, e_crlc, e_cparhdr, e_minalloc, e_maxalloc,
e_ss, e_sp, e_csum, e_ip, e_cs, e_lfarlc, e_ovno, e_res, e_oemid,
e_oeminfo, e_res2, e_lfanew};
/// Checks if the current MZ header is valid.
bool isValid() const; // EXPORT
bool isValid(Field field) const; // EXPORT _field
/// Corrects the current MZ header.
void makeValid(); // EXPORT
void makeValid(Field field); // EXPORT _field
/// Reads the MZ header of a file.
int read(const std::string& strFilename); // EXPORT
/// Reads the MZ header from a memory location.
int read(unsigned char* pcBuffer, unsigned int uiSize, unsigned int originalOffs = 0); // EXPORT _fromMemory
/// Rebuild the MZ header.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the current MZ header.
unsigned int size() const; // EXPORT
/// Writes the current MZ header to offset 0 of a file.
int write(const std::string& strFilename, dword dwOffset) const; // EXPORT
/// Gets the e_magic value of the MZ header.
word getMagicNumber() const; // EXPORT
/// Gets the e_cblp value of the MZ header.
word getBytesOnLastPage() const; // EXPORT
/// Gets the e_cp value of the MZ header.
word getPagesInFile() const; // EXPORT
/// Gets the e_crlc value of the MZ header.
word getRelocations() const; // EXPORT
/// Gets the e_cparhdr value of the MZ header.
word getSizeOfHeader() const; // EXPORT
/// Gets the e_minalloc value of the MZ header.
word getMinExtraParagraphs() const; // EXPORT
/// Gets the e_maxalloc value of the MZ header.
word getMaxExtraParagraphs() const; // EXPORT
/// Gets the e_ss value of the MZ header.
word getSsValue() const; // EXPORT
/// Gets the e_sp value of the MZ header.
word getSpValue() const; // EXPORT
/// Gets the e_csum value of the MZ header.
word getChecksum() const; // EXPORT
/// Gets the e_ip value of the MZ header.
word getIpValue() const; // EXPORT
/// Gets the e_cs value of the MZ header.
word getCsValue() const; // EXPORT
/// Gets the e_lfarlc value of the MZ header.
word getAddrOfRelocationTable() const; // EXPORT
/// Gets the e_ovnovalue of the MZ header.
word getOverlayNumber() const; // EXPORT
/// Gets the e_oemid value of the MZ header.
word getOemIdentifier() const; // EXPORT
/// Gets the e_oeminfo value of the MZ header.
word getOemInformation() const; // EXPORT
/// Gets the e_lfanew value of the MZ header.
dword getAddressOfPeHeader() const; // EXPORT
/// Gets the e_res of the MZ header.
word getReservedWords1(unsigned int uiNr) const; // EXPORT
/// Gets the e_res2 of the MZ header.
word getReservedWords2(unsigned int uiNr) const; // EXPORT
/// Sets the e_magic value of the MZ header.
void setMagicNumber(word wValue); // EXPORT
/// Sets the e_cblp value of the MZ header.
void setBytesOnLastPage(word wValue); // EXPORT
/// Sets the e_cp value of the MZ header.
void setPagesInFile(word wValue); // EXPORT
/// Sets the e_crlc value of the MZ header.
void setRelocations(word wValue); // EXPORT
/// Sets the e_cparhdr value of the MZ header.
void setSizeOfHeader(word wValue); // EXPORT
/// Sets the e_minalloc value of the MZ header.
void setMinExtraParagraphs(word wValue); // EXPORT
/// Sets the e_maxalloc value of the MZ header.
void setMaxExtraParagraphs(word wValue); // EXPORT
/// Sets the e_ss value of the MZ header.
void setSsValue(word wValue); // EXPORT
/// Sets the e_sp value of the MZ header.
void setSpValue(word wValue); // EXPORT
/// Sets the e_csum value of the MZ header.
void setChecksum(word wValue); // EXPORT
/// Sets the e_ip value of the MZ header.
void setIpValue(word wValue); // EXPORT
/// Sets the e_cs value of the MZ header.
void setCsValue(word wValue); // EXPORT
/// Sets the e_lfarlc value of the MZ header.
void setAddrOfRelocationTable(word wValue); // EXPORT
/// Sets the e_ovno value of the MZ header.
void setOverlayNumber(word wValue); // EXPORT
/// Sets the e_oemid value of the MZ header.
void setOemIdentifier(word wValue); // EXPORT
/// Sets the e_oeminfo value of the MZ header.
void setOemInformation(word wValue); // EXPORT
/// Sets the e_lfanew value of the MZ header.
void setAddressOfPeHeader(dword dwValue); // EXPORT
/// Sets the e_res value of the MZ header.
void setReservedWords1(unsigned int uiNr, word wValue); // EXPORT
/// Sets the e_res2 value of the MZ header.
void setReservedWords2(unsigned int uiNr, word wValue); // EXPORT
};
}
#endif

338
utils/zenutils/libraries/pelib-0.9/pelib/PeFile.cpp Executable file → Normal file
View file

@ -1,169 +1,169 @@
/*
* PeLib.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeFile.h"
namespace PeLib
{
PeFile::~PeFile()
{
}
PeFile32::PeFile32() : PeFileT<32>()
{
}
PeFile32::PeFile32(const std::string& strFlename) : PeFileT<32>(strFlename)
{
}
PeFile64::PeFile64() : PeFileT<64>()
{
}
PeFile64::PeFile64(const std::string& strFlename) : PeFileT<64>(strFlename)
{
}
/**
* @return A reference to the file's MZ header.
**/
const MzHeader& PeFile::mzHeader() const
{
return m_mzh;
}
/**
* @return A reference to the file's MZ header.
**/
MzHeader& PeFile::mzHeader()
{
return m_mzh;
}
/**
* @return A reference to the file's export directory.
**/
const ExportDirectory& PeFile::expDir() const
{
return m_expdir;
}
/**
* @return A reference to the file's export directory.
**/
ExportDirectory& PeFile::expDir()
{
return m_expdir;
}
/**
* @return A reference to the file's bound import directory.
**/
const BoundImportDirectory& PeFile::boundImpDir() const
{
return m_boundimpdir;
}
/**
* @return A reference to the file's bound import directory.
**/
BoundImportDirectory& PeFile::boundImpDir()
{
return m_boundimpdir;
}
/**
* @return A reference to the file's resource directory.
**/
const ResourceDirectory& PeFile::resDir() const
{
return m_resdir;
}
/**
* @return A reference to the file's resource directory.
**/
ResourceDirectory& PeFile::resDir()
{
return m_resdir;
}
/**
* @return A reference to the file's relocations directory.
**/
const RelocationsDirectory& PeFile::relocDir() const
{
return m_relocs;
}
/**
* @return A reference to the file's relocations directory.
**/
RelocationsDirectory& PeFile::relocDir()
{
return m_relocs;
}
/**
* @return A reference to the file's COM+ descriptor directory.
**/
const ComHeaderDirectory& PeFile::comDir() const
{
return m_comdesc;
}
/**
* @return A reference to the file's COM+ descriptor directory.
**/
ComHeaderDirectory & PeFile::comDir()
{
return m_comdesc;
}
const IatDirectory& PeFile::iatDir() const
{
return m_iat;
}
IatDirectory& PeFile::iatDir()
{
return m_iat;
}
const DebugDirectory& PeFile::debugDir() const
{
return m_debugdir;
}
DebugDirectory& PeFile::debugDir()
{
return m_debugdir;
}
}
/*
* PeLib.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeFile.h"
namespace PeLib
{
PeFile::~PeFile()
{
}
PeFile32::PeFile32() : PeFileT<32>()
{
}
PeFile32::PeFile32(const std::string& strFlename) : PeFileT<32>(strFlename)
{
}
PeFile64::PeFile64() : PeFileT<64>()
{
}
PeFile64::PeFile64(const std::string& strFlename) : PeFileT<64>(strFlename)
{
}
/**
* @return A reference to the file's MZ header.
**/
const MzHeader& PeFile::mzHeader() const
{
return m_mzh;
}
/**
* @return A reference to the file's MZ header.
**/
MzHeader& PeFile::mzHeader()
{
return m_mzh;
}
/**
* @return A reference to the file's export directory.
**/
const ExportDirectory& PeFile::expDir() const
{
return m_expdir;
}
/**
* @return A reference to the file's export directory.
**/
ExportDirectory& PeFile::expDir()
{
return m_expdir;
}
/**
* @return A reference to the file's bound import directory.
**/
const BoundImportDirectory& PeFile::boundImpDir() const
{
return m_boundimpdir;
}
/**
* @return A reference to the file's bound import directory.
**/
BoundImportDirectory& PeFile::boundImpDir()
{
return m_boundimpdir;
}
/**
* @return A reference to the file's resource directory.
**/
const ResourceDirectory& PeFile::resDir() const
{
return m_resdir;
}
/**
* @return A reference to the file's resource directory.
**/
ResourceDirectory& PeFile::resDir()
{
return m_resdir;
}
/**
* @return A reference to the file's relocations directory.
**/
const RelocationsDirectory& PeFile::relocDir() const
{
return m_relocs;
}
/**
* @return A reference to the file's relocations directory.
**/
RelocationsDirectory& PeFile::relocDir()
{
return m_relocs;
}
/**
* @return A reference to the file's COM+ descriptor directory.
**/
const ComHeaderDirectory& PeFile::comDir() const
{
return m_comdesc;
}
/**
* @return A reference to the file's COM+ descriptor directory.
**/
ComHeaderDirectory & PeFile::comDir()
{
return m_comdesc;
}
const IatDirectory& PeFile::iatDir() const
{
return m_iat;
}
IatDirectory& PeFile::iatDir()
{
return m_iat;
}
const DebugDirectory& PeFile::debugDir() const
{
return m_debugdir;
}
DebugDirectory& PeFile::debugDir()
{
return m_debugdir;
}
}

902
utils/zenutils/libraries/pelib-0.9/pelib/PeFile.h Executable file → Normal file
View file

@ -1,451 +1,451 @@
/*
* PeFile.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef PEFILE_H
#define PEFILE_H
#include "PeLibInc.h"
#include "MzHeader.h"
#include "PeHeader.h"
#include "ImportDirectory.h"
#include "ExportDirectory.h"
#include "BoundImportDirectory.h"
#include "ResourceDirectory.h"
#include "RelocationsDirectory.h"
#include "ComHeaderDirectory.h"
#include "IatDirectory.h"
#include "DebugDirectory.h"
#include "TlsDirectory.h"
namespace PeLib
{
class PeFile32;
class PeFile64;
/**
* Visitor base class for PeFiles.
**/
class PeFileVisitor
{
public:
virtual void callback(PeFile32 &file){}
virtual void callback(PeFile64 &file){}
virtual ~PeFileVisitor(){}
};
/**
* Traits class that's used to decide of what type the PeHeader in a PeFile is.
**/
template<int>
struct PeFile_Traits;
template<>
struct PeFile_Traits<32>
{
typedef PeHeader32 PeHeader32_64;
};
template<>
struct PeFile_Traits<64>
{
typedef PeHeader64 PeHeader32_64;
};
/**
* This class represents the common structures of PE and PE+ files.
**/
class PeFile
{
protected:
std::string m_filename; ///< Name of the current file.
MzHeader m_mzh; ///< MZ header of the current file.
ExportDirectory m_expdir; ///< Export directory of the current file.
BoundImportDirectory m_boundimpdir; ///< BoundImportDirectory of the current file.
ResourceDirectory m_resdir; ///< ResourceDirectory of the current file.
RelocationsDirectory m_relocs; ///< Relocations directory of the current file.
ComHeaderDirectory m_comdesc; ///< COM+ descriptor directory of the current file.
IatDirectory m_iat; ///< Import address table of the current file.
DebugDirectory m_debugdir;
public:
virtual ~PeFile();
/// Returns the name of the current file.
virtual std::string getFileName() const = 0; // EXPORT
/// Changes the name of the current file.
virtual void setFileName(std::string strFilename) = 0; // EXPORT
virtual void visit(PeFileVisitor &v) = 0;
/// Reads the MZ header of the current file from disc.
virtual int readMzHeader() = 0; // EXPORT
/// Reads the export directory of the current file from disc.
virtual int readExportDirectory() = 0; // EXPORT
/// Reads the PE header of the current file from disc.
virtual int readPeHeader() = 0; // EXPORT
/// Reads the import directory of the current file from disc.
virtual int readImportDirectory() = 0; // EXPORT
/// Reads the bound import directory of the current file from disc.
virtual int readBoundImportDirectory() = 0; // EXPORT
/// Reads the resource directory of the current file from disc.
virtual int readResourceDirectory() = 0; // EXPORT
/// Reads the relocations directory of the current file from disc.
virtual int readRelocationsDirectory() = 0; // EXPORT
/// Reads the COM+ descriptor directory of the current file from disc.
virtual int readComHeaderDirectory() = 0; // EXPORT
/// Reads the IAT directory of the current file from disc.
virtual int readIatDirectory() = 0; // EXPORT
/// Reads the Debug directory of the current file.
virtual int readDebugDirectory() = 0; // EXPORT
virtual int readTlsDirectory() = 0; // EXPORT
virtual unsigned int getBits() const = 0;
/// Accessor function for the MZ header.
const MzHeader& mzHeader() const;
/// Accessor function for the MZ header.
MzHeader& mzHeader(); // EXPORT
/// Accessor function for the export directory.
const ExportDirectory& expDir() const;
/// Accessor function for the export directory.
ExportDirectory& expDir(); // EXPORT
/// Accessor function for the bound import directory.
const BoundImportDirectory& boundImpDir() const;
/// Accessor function for the bound import directory.
BoundImportDirectory& boundImpDir(); // EXPORT
/// Accessor function for the resource directory.
const ResourceDirectory& resDir() const;
/// Accessor function for the resource directory.
ResourceDirectory& resDir(); // EXPORT
/// Accessor function for the relocations directory.
const RelocationsDirectory& relocDir() const;
/// Accessor function for the relocations directory.
RelocationsDirectory& relocDir(); // EXPORT
/// Accessor function for the COM+ descriptor directory.
const ComHeaderDirectory& comDir() const;
/// Accessor function for the COM+ descriptor directory.
ComHeaderDirectory& comDir(); // EXPORT
/// Accessor function for the IAT directory.
const IatDirectory& iatDir() const;
/// Accessor function for the IAT directory.
IatDirectory& iatDir(); // EXPORT
/// Accessor function for the debug directory.
const DebugDirectory& debugDir() const;
/// Accessor function for the debug directory.
DebugDirectory& debugDir(); // EXPORT
};
/**
* This class implements the common structures of PE and PE+ files.
**/
template<int bits>
class PeFileT : public PeFile
{
typedef typename PeFile_Traits<bits>::PeHeader32_64 PeHeader32_64;
private:
PeHeader32_64 m_peh; ///< PE header of the current file.
ImportDirectory<bits> m_impdir; ///< Import directory of the current file.
TlsDirectory<bits> m_tlsdir;
public:
/// Default constructor which exists only for the sake of allowing to construct files without filenames.
PeFileT();
virtual ~PeFileT() {}
/// Initializes a PeFile with a filename
explicit PeFileT(const std::string& strFilename);
/// Returns the name of the current file.
std::string getFileName() const;
/// Changes the name of the current file.
void setFileName(std::string strFilename);
/// Reads the MZ header of the current file from disc.
int readMzHeader() ;
/// Reads the export directory of the current file from disc.
int readExportDirectory() ;
/// Reads the PE header of the current file from disc.
int readPeHeader() ;
/// Reads the import directory of the current file from disc.
int readImportDirectory() ;
/// Reads the bound import directory of the current file from disc.
int readBoundImportDirectory() ;
/// Reads the resource directory of the current file from disc.
int readResourceDirectory() ;
/// Reads the relocations directory of the current file from disc.
int readRelocationsDirectory() ;
/// Reads the COM+ descriptor directory of the current file from disc.
int readComHeaderDirectory() ;
/// Reads the IAT directory of the current file from disc.
int readIatDirectory() ;
/// Reads the Debug directory of the current file.
int readDebugDirectory() ;
int readTlsDirectory() ;
unsigned int getBits() const
{
return bits;
}
/// Accessor function for the PE header.
const PeHeader32_64& peHeader() const;
/// Accessor function for the PE header.
PeHeader32_64& peHeader();
/// Accessor function for the import directory.
const ImportDirectory<bits>& impDir() const;
/// Accessor function for the import directory.
ImportDirectory<bits>& impDir();
const TlsDirectory<bits>& tlsDir() const;
TlsDirectory<bits>& tlsDir();
};
/**
* This class is the main class for handling PE files.
**/
class PeFile32 : public PeFileT<32>
{
public:
/// Default constructor which exists only for the sake of allowing to construct files without filenames.
PeFile32();
/// Initializes a PeFile with a filename
explicit PeFile32(const std::string& strFlename);
virtual void visit(PeFileVisitor &v) { v.callback( *this ); }
};
/**
* This class is the main class for handling PE+ files.
**/
class PeFile64 : public PeFileT<64>
{
public:
/// Default constructor which exists only for the sake of allowing to construct files without filenames.
PeFile64();
/// Initializes a PeFile with a filename
explicit PeFile64(const std::string& strFlename);
virtual void visit(PeFileVisitor &v) { v.callback( *this ); }
};
//typedef PeFileT<32> PeFile32;
//typedef PeFileT<64> PeFile64;
/**
* @param strFilename Name of the current file.
**/
template<int bits>
PeFileT<bits>::PeFileT(const std::string& strFilename)
{
m_filename = strFilename;
}
template<int bits>
PeFileT<bits>::PeFileT()
{
}
template<int bits>
int PeFileT<bits>::readPeHeader()
{
return peHeader().read(getFileName(), mzHeader().getAddressOfPeHeader());
}
template<int bits>
int PeFileT<bits>::readImportDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 2
&& peHeader().getIddImportRva()
&& peHeader().getIddImportSize())
{
return impDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddImportRva())), peHeader().getIddImportSize(), peHeader());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
/**
* @return A reference to the file's PE header.
**/
template<int bits>
const typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader() const
{
return m_peh;
}
/**
* @return A reference to the file's PE header.
**/
template<int bits>
typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader()
{
return m_peh;
}
/**
* @return A reference to the file's import directory.
**/
template<int bits>
const ImportDirectory<bits>& PeFileT<bits>::impDir() const
{
return m_impdir;
}
/**
* @return A reference to the file's import directory.
**/
template<int bits>
ImportDirectory<bits>& PeFileT<bits>::impDir()
{
return m_impdir;
}
template<int bits>
const TlsDirectory<bits>& PeFileT<bits>::tlsDir() const
{
return m_tlsdir;
}
template<int bits>
TlsDirectory<bits>& PeFileT<bits>::tlsDir()
{
return m_tlsdir;
}
/**
* @return Filename of the current file.
**/
template<int bits>
std::string PeFileT<bits>::getFileName() const
{
return m_filename;
}
/**
* @param strFilename New filename.
**/
template<int bits>
void PeFileT<bits>::setFileName(std::string strFilename)
{
m_filename = strFilename;
}
template<int bits>
int PeFileT<bits>::readMzHeader()
{
return mzHeader().read(getFileName());
}
template<int bits>
int PeFileT<bits>::readExportDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 1
&& peHeader().getIddExportRva() && peHeader().getIddExportSize())
{
return expDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddExportRva())), peHeader().getIddExportSize(), peHeader());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readBoundImportDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 12
&& peHeader().getIddBoundImportRva() && peHeader().getIddBoundImportSize())
{
return boundImpDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBoundImportRva())), peHeader().getIddBoundImportSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readResourceDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 3
&& peHeader().getIddResourceRva() && peHeader().getIddResourceSize())
{
return resDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddResourceRva())), peHeader().getIddResourceSize(), peHeader().getIddResourceRva());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readRelocationsDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 6
&& peHeader().getIddBaseRelocRva() && peHeader().getIddBaseRelocSize())
{
return relocDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBaseRelocRva())), peHeader().getIddBaseRelocSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readComHeaderDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 15
&& peHeader().getIddComHeaderRva() && peHeader().getIddComHeaderSize())
{
return comDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddComHeaderRva())), peHeader().getIddComHeaderSize());
}
std::cout << peHeader().getIddComHeaderRva() << std::endl;
std::exit(0);
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readIatDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 13
&& peHeader().getIddIatRva() && peHeader().getIddIatSize())
{
return iatDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddIatRva())), peHeader().getIddIatSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readDebugDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 7
&& peHeader().getIddDebugRva() && peHeader().getIddDebugSize())
{
return debugDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddDebugRva())), peHeader().getIddDebugSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readTlsDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 10
&& peHeader().getIddTlsRva() && peHeader().getIddTlsSize())
{
return tlsDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddTlsRva())), peHeader().getIddTlsSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
}
#endif
/*
* PeFile.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef PEFILE_H
#define PEFILE_H
#include "PeLibInc.h"
#include "MzHeader.h"
#include "PeHeader.h"
#include "ImportDirectory.h"
#include "ExportDirectory.h"
#include "BoundImportDirectory.h"
#include "ResourceDirectory.h"
#include "RelocationsDirectory.h"
#include "ComHeaderDirectory.h"
#include "IatDirectory.h"
#include "DebugDirectory.h"
#include "TlsDirectory.h"
namespace PeLib
{
class PeFile32;
class PeFile64;
/**
* Visitor base class for PeFiles.
**/
class PeFileVisitor
{
public:
virtual void callback(PeFile32 &file){}
virtual void callback(PeFile64 &file){}
virtual ~PeFileVisitor(){}
};
/**
* Traits class that's used to decide of what type the PeHeader in a PeFile is.
**/
template<int>
struct PeFile_Traits;
template<>
struct PeFile_Traits<32>
{
typedef PeHeader32 PeHeader32_64;
};
template<>
struct PeFile_Traits<64>
{
typedef PeHeader64 PeHeader32_64;
};
/**
* This class represents the common structures of PE and PE+ files.
**/
class PeFile
{
protected:
std::string m_filename; ///< Name of the current file.
MzHeader m_mzh; ///< MZ header of the current file.
ExportDirectory m_expdir; ///< Export directory of the current file.
BoundImportDirectory m_boundimpdir; ///< BoundImportDirectory of the current file.
ResourceDirectory m_resdir; ///< ResourceDirectory of the current file.
RelocationsDirectory m_relocs; ///< Relocations directory of the current file.
ComHeaderDirectory m_comdesc; ///< COM+ descriptor directory of the current file.
IatDirectory m_iat; ///< Import address table of the current file.
DebugDirectory m_debugdir;
public:
virtual ~PeFile();
/// Returns the name of the current file.
virtual std::string getFileName() const = 0; // EXPORT
/// Changes the name of the current file.
virtual void setFileName(std::string strFilename) = 0; // EXPORT
virtual void visit(PeFileVisitor &v) = 0;
/// Reads the MZ header of the current file from disc.
virtual int readMzHeader() = 0; // EXPORT
/// Reads the export directory of the current file from disc.
virtual int readExportDirectory() = 0; // EXPORT
/// Reads the PE header of the current file from disc.
virtual int readPeHeader() = 0; // EXPORT
/// Reads the import directory of the current file from disc.
virtual int readImportDirectory() = 0; // EXPORT
/// Reads the bound import directory of the current file from disc.
virtual int readBoundImportDirectory() = 0; // EXPORT
/// Reads the resource directory of the current file from disc.
virtual int readResourceDirectory() = 0; // EXPORT
/// Reads the relocations directory of the current file from disc.
virtual int readRelocationsDirectory() = 0; // EXPORT
/// Reads the COM+ descriptor directory of the current file from disc.
virtual int readComHeaderDirectory() = 0; // EXPORT
/// Reads the IAT directory of the current file from disc.
virtual int readIatDirectory() = 0; // EXPORT
/// Reads the Debug directory of the current file.
virtual int readDebugDirectory() = 0; // EXPORT
virtual int readTlsDirectory() = 0; // EXPORT
virtual unsigned int getBits() const = 0;
/// Accessor function for the MZ header.
const MzHeader& mzHeader() const;
/// Accessor function for the MZ header.
MzHeader& mzHeader(); // EXPORT
/// Accessor function for the export directory.
const ExportDirectory& expDir() const;
/// Accessor function for the export directory.
ExportDirectory& expDir(); // EXPORT
/// Accessor function for the bound import directory.
const BoundImportDirectory& boundImpDir() const;
/// Accessor function for the bound import directory.
BoundImportDirectory& boundImpDir(); // EXPORT
/// Accessor function for the resource directory.
const ResourceDirectory& resDir() const;
/// Accessor function for the resource directory.
ResourceDirectory& resDir(); // EXPORT
/// Accessor function for the relocations directory.
const RelocationsDirectory& relocDir() const;
/// Accessor function for the relocations directory.
RelocationsDirectory& relocDir(); // EXPORT
/// Accessor function for the COM+ descriptor directory.
const ComHeaderDirectory& comDir() const;
/// Accessor function for the COM+ descriptor directory.
ComHeaderDirectory& comDir(); // EXPORT
/// Accessor function for the IAT directory.
const IatDirectory& iatDir() const;
/// Accessor function for the IAT directory.
IatDirectory& iatDir(); // EXPORT
/// Accessor function for the debug directory.
const DebugDirectory& debugDir() const;
/// Accessor function for the debug directory.
DebugDirectory& debugDir(); // EXPORT
};
/**
* This class implements the common structures of PE and PE+ files.
**/
template<int bits>
class PeFileT : public PeFile
{
typedef typename PeFile_Traits<bits>::PeHeader32_64 PeHeader32_64;
private:
PeHeader32_64 m_peh; ///< PE header of the current file.
ImportDirectory<bits> m_impdir; ///< Import directory of the current file.
TlsDirectory<bits> m_tlsdir;
public:
/// Default constructor which exists only for the sake of allowing to construct files without filenames.
PeFileT();
virtual ~PeFileT() {}
/// Initializes a PeFile with a filename
explicit PeFileT(const std::string& strFilename);
/// Returns the name of the current file.
std::string getFileName() const;
/// Changes the name of the current file.
void setFileName(std::string strFilename);
/// Reads the MZ header of the current file from disc.
int readMzHeader() ;
/// Reads the export directory of the current file from disc.
int readExportDirectory() ;
/// Reads the PE header of the current file from disc.
int readPeHeader() ;
/// Reads the import directory of the current file from disc.
int readImportDirectory() ;
/// Reads the bound import directory of the current file from disc.
int readBoundImportDirectory() ;
/// Reads the resource directory of the current file from disc.
int readResourceDirectory() ;
/// Reads the relocations directory of the current file from disc.
int readRelocationsDirectory() ;
/// Reads the COM+ descriptor directory of the current file from disc.
int readComHeaderDirectory() ;
/// Reads the IAT directory of the current file from disc.
int readIatDirectory() ;
/// Reads the Debug directory of the current file.
int readDebugDirectory() ;
int readTlsDirectory() ;
unsigned int getBits() const
{
return bits;
}
/// Accessor function for the PE header.
const PeHeader32_64& peHeader() const;
/// Accessor function for the PE header.
PeHeader32_64& peHeader();
/// Accessor function for the import directory.
const ImportDirectory<bits>& impDir() const;
/// Accessor function for the import directory.
ImportDirectory<bits>& impDir();
const TlsDirectory<bits>& tlsDir() const;
TlsDirectory<bits>& tlsDir();
};
/**
* This class is the main class for handling PE files.
**/
class PeFile32 : public PeFileT<32>
{
public:
/// Default constructor which exists only for the sake of allowing to construct files without filenames.
PeFile32();
/// Initializes a PeFile with a filename
explicit PeFile32(const std::string& strFlename);
virtual void visit(PeFileVisitor &v) { v.callback( *this ); }
};
/**
* This class is the main class for handling PE+ files.
**/
class PeFile64 : public PeFileT<64>
{
public:
/// Default constructor which exists only for the sake of allowing to construct files without filenames.
PeFile64();
/// Initializes a PeFile with a filename
explicit PeFile64(const std::string& strFlename);
virtual void visit(PeFileVisitor &v) { v.callback( *this ); }
};
//typedef PeFileT<32> PeFile32;
//typedef PeFileT<64> PeFile64;
/**
* @param strFilename Name of the current file.
**/
template<int bits>
PeFileT<bits>::PeFileT(const std::string& strFilename)
{
m_filename = strFilename;
}
template<int bits>
PeFileT<bits>::PeFileT()
{
}
template<int bits>
int PeFileT<bits>::readPeHeader()
{
return peHeader().read(getFileName(), mzHeader().getAddressOfPeHeader());
}
template<int bits>
int PeFileT<bits>::readImportDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 2
&& peHeader().getIddImportRva()
&& peHeader().getIddImportSize())
{
return impDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddImportRva())), peHeader().getIddImportSize(), peHeader());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
/**
* @return A reference to the file's PE header.
**/
template<int bits>
const typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader() const
{
return m_peh;
}
/**
* @return A reference to the file's PE header.
**/
template<int bits>
typename PeFile_Traits<bits>::PeHeader32_64& PeFileT<bits>::peHeader()
{
return m_peh;
}
/**
* @return A reference to the file's import directory.
**/
template<int bits>
const ImportDirectory<bits>& PeFileT<bits>::impDir() const
{
return m_impdir;
}
/**
* @return A reference to the file's import directory.
**/
template<int bits>
ImportDirectory<bits>& PeFileT<bits>::impDir()
{
return m_impdir;
}
template<int bits>
const TlsDirectory<bits>& PeFileT<bits>::tlsDir() const
{
return m_tlsdir;
}
template<int bits>
TlsDirectory<bits>& PeFileT<bits>::tlsDir()
{
return m_tlsdir;
}
/**
* @return Filename of the current file.
**/
template<int bits>
std::string PeFileT<bits>::getFileName() const
{
return m_filename;
}
/**
* @param strFilename New filename.
**/
template<int bits>
void PeFileT<bits>::setFileName(std::string strFilename)
{
m_filename = strFilename;
}
template<int bits>
int PeFileT<bits>::readMzHeader()
{
return mzHeader().read(getFileName());
}
template<int bits>
int PeFileT<bits>::readExportDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 1
&& peHeader().getIddExportRva() && peHeader().getIddExportSize())
{
return expDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddExportRva())), peHeader().getIddExportSize(), peHeader());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readBoundImportDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 12
&& peHeader().getIddBoundImportRva() && peHeader().getIddBoundImportSize())
{
return boundImpDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBoundImportRva())), peHeader().getIddBoundImportSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readResourceDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 3
&& peHeader().getIddResourceRva() && peHeader().getIddResourceSize())
{
return resDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddResourceRva())), peHeader().getIddResourceSize(), peHeader().getIddResourceRva());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readRelocationsDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 6
&& peHeader().getIddBaseRelocRva() && peHeader().getIddBaseRelocSize())
{
return relocDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddBaseRelocRva())), peHeader().getIddBaseRelocSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readComHeaderDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 15
&& peHeader().getIddComHeaderRva() && peHeader().getIddComHeaderSize())
{
return comDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddComHeaderRva())), peHeader().getIddComHeaderSize());
}
std::cout << peHeader().getIddComHeaderRva() << std::endl;
std::exit(0);
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readIatDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 13
&& peHeader().getIddIatRva() && peHeader().getIddIatSize())
{
return iatDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddIatRva())), peHeader().getIddIatSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readDebugDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 7
&& peHeader().getIddDebugRva() && peHeader().getIddDebugSize())
{
return debugDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddDebugRva())), peHeader().getIddDebugSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
template<int bits>
int PeFileT<bits>::readTlsDirectory()
{
if (peHeader().calcNumberOfRvaAndSizes() >= 10
&& peHeader().getIddTlsRva() && peHeader().getIddTlsSize())
{
return tlsDir().read(getFileName(), static_cast<unsigned int>(peHeader().rvaToOffset(peHeader().getIddTlsRva())), peHeader().getIddTlsSize());
}
return ERROR_DIRECTORY_DOES_NOT_EXIST;
}
}
#endif

180
utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.cpp Executable file → Normal file
View file

@ -1,90 +1,90 @@
/*
* PeHeader.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "PeHeader.h"
namespace PeLib
{
template<>
void PeHeaderT<32>::readBaseOfData(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<32>& header) const
{
ibBuffer >> header.OptionalHeader.BaseOfData;
}
template<>
void PeHeaderT<64>::readBaseOfData(InputBuffer&, PELIB_IMAGE_NT_HEADERS<64>&) const
{
}
template<>
void PeHeaderT<32>::rebuildBaseOfData(OutputBuffer& obBuffer) const
{
obBuffer << m_inthHeader.OptionalHeader.BaseOfData;
}
template<>
void PeHeaderT<64>::rebuildBaseOfData(OutputBuffer&) const
{
}
template<>
bool PeHeaderT<32>::isValid() const
{
return true;
}
template<>
bool PeHeaderT<64>::isValid() const
{
return true;
}
template<>
bool PeHeaderT<32>::isValid(unsigned int pehf) const
{
/*
if (pehf == NtSignature)
{
return m_inthHeader.Signature == IMAGE_NT_SIGNATURE;
}
else if (pehf == NumberOfSections)
{
return getNumberOfSections() == calcNumberOfSections();
} */
return false;
}
template<>
bool PeHeaderT<64>::isValid(unsigned int pehf) const
{
return false;
}
/**
* @return The BaseOfData value from the PE header.
**/
dword PeHeader32::getBaseOfData() const
{
return m_inthHeader.OptionalHeader.BaseOfData;
}
/**
* Changes the file's BaseOfData.
* @param dwValue New value.
**/
void PeHeader32::setBaseOfData(dword dwValue)
{
m_inthHeader.OptionalHeader.BaseOfData = dwValue;
}
}
/*
* PeHeader.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "PeHeader.h"
namespace PeLib
{
template<>
void PeHeaderT<32>::readBaseOfData(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<32>& header) const
{
ibBuffer >> header.OptionalHeader.BaseOfData;
}
template<>
void PeHeaderT<64>::readBaseOfData(InputBuffer&, PELIB_IMAGE_NT_HEADERS<64>&) const
{
}
template<>
void PeHeaderT<32>::rebuildBaseOfData(OutputBuffer& obBuffer) const
{
obBuffer << m_inthHeader.OptionalHeader.BaseOfData;
}
template<>
void PeHeaderT<64>::rebuildBaseOfData(OutputBuffer&) const
{
}
template<>
bool PeHeaderT<32>::isValid() const
{
return true;
}
template<>
bool PeHeaderT<64>::isValid() const
{
return true;
}
template<>
bool PeHeaderT<32>::isValid(unsigned int pehf) const
{
/*
if (pehf == NtSignature)
{
return m_inthHeader.Signature == IMAGE_NT_SIGNATURE;
}
else if (pehf == NumberOfSections)
{
return getNumberOfSections() == calcNumberOfSections();
} */
return false;
}
template<>
bool PeHeaderT<64>::isValid(unsigned int pehf) const
{
return false;
}
/**
* @return The BaseOfData value from the PE header.
**/
dword PeHeader32::getBaseOfData() const
{
return m_inthHeader.OptionalHeader.BaseOfData;
}
/**
* Changes the file's BaseOfData.
* @param dwValue New value.
**/
void PeHeader32::setBaseOfData(dword dwValue)
{
m_inthHeader.OptionalHeader.BaseOfData = dwValue;
}
}

5370
utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.h Executable file → Normal file

File diff suppressed because it is too large Load diff

54
utils/zenutils/libraries/pelib-0.9/pelib/PeLib.h Executable file → Normal file
View file

@ -1,27 +1,27 @@
/*
* PeLib.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
/** \mainpage PeLib - An open-source C++ library to modify PE files.
*
* \section intro Introduction
*
* <b>What is PeLib?</b><br>
* PeLib is an open source C++ library with the purpose to ease the access and modification of PE (Portable executable) files. This is done through a multitude of classes which represent all important PE header and directory structures and which provide the necessary functions to read, modify and write these structures. As this library is fully ISO C++ compliant it should compile with all popular compilers for the Windows platform. For people who don't use C++ in their projects a dynamic link library is provided which encapsulates all of PeLib's functionality so that projects using programming languages as diverse as Win32 assembler, C# or Delphi can still benefit from PeLib's power
*/
#ifndef PELIB_H
#define PELIB_H
#include "PeFile.h"
#endif
/*
* PeLib.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
/** \mainpage PeLib - An open-source C++ library to modify PE files.
*
* \section intro Introduction
*
* <b>What is PeLib?</b><br>
* PeLib is an open source C++ library with the purpose to ease the access and modification of PE (Portable executable) files. This is done through a multitude of classes which represent all important PE header and directory structures and which provide the necessary functions to read, modify and write these structures. As this library is fully ISO C++ compliant it should compile with all popular compilers for the Windows platform. For people who don't use C++ in their projects a dynamic link library is provided which encapsulates all of PeLib's functionality so that projects using programming languages as diverse as Win32 assembler, C# or Delphi can still benefit from PeLib's power
*/
#ifndef PELIB_H
#define PELIB_H
#include "PeFile.h"
#endif

550
utils/zenutils/libraries/pelib-0.9/pelib/PeLibAux.cpp Executable file → Normal file
View file

@ -1,275 +1,275 @@
/*
* PeLibAux.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "PeLibAux.h"
#include "PeFile.h"
#ifdef _MSC_VER
#include <ctype.h>
#endif
namespace PeLib
{
const qword PELIB_IMAGE_ORDINAL_FLAGS<64>::IMAGE_ORDINAL_FLAG = 0x8000000000000000ULL;
bool PELIB_IMAGE_SECTION_HEADER::biggerFileOffset(const PELIB_IMAGE_SECTION_HEADER& ish) const
{
return PointerToRawData < ish.PointerToRawData;
}
bool PELIB_IMAGE_SECTION_HEADER::biggerVirtualAddress(const PELIB_IMAGE_SECTION_HEADER& ish) const
{
return VirtualAddress < ish.VirtualAddress;
}
unsigned int alignOffset(unsigned int uiOffset, unsigned int uiAlignment)
{
if (!uiAlignment) return uiAlignment;
return (uiOffset % uiAlignment) ? uiOffset + (uiAlignment - uiOffset % uiAlignment) : uiOffset;
}
unsigned int fileSize(const std::string& filename)
{
std::fstream file(filename.c_str());
file.seekg(0, std::ios::end);
return file.tellg();
}
unsigned int fileSize(std::ifstream& file)
{
unsigned int oldpos = file.tellg();
file.seekg(0, std::ios::end);
unsigned int filesize = file.tellg();
file.seekg(oldpos, std::ios::beg);
return filesize;
}
unsigned int fileSize(std::fstream& file)
{
unsigned int oldpos = file.tellg();
file.seekg(0, std::ios::end);
unsigned int filesize = file.tellg();
file.seekg(oldpos, std::ios::beg);
return filesize;
}
unsigned int fileSize(std::ofstream& file)
{
unsigned int oldpos = file.tellp();
file.seekp(0, std::ios::end);
unsigned int filesize = file.tellp();
file.seekp(oldpos, std::ios::beg);
return filesize;
}
bool isEqualNc(const std::string& s1, const std::string& s2)
{
std::string t1 = s1;
std::string t2 = s2;
// No std:: to make VC++ happy
#ifdef _MSC_VER
std::transform(t1.begin(), t1.end(), t1.begin(), toupper);
std::transform(t2.begin(), t2.end(), t2.begin(), toupper);
#else
// Weird syntax to make Borland C++ happy
std::transform(t1.begin(), t1.end(), t1.begin(), (int(*)(int))std::toupper);
std::transform(t2.begin(), t2.end(), t2.begin(), (int(*)(int))std::toupper);
#endif
return t1 == t2;
}
PELIB_IMAGE_DOS_HEADER::PELIB_IMAGE_DOS_HEADER()
{
e_magic = 0;
e_cblp = 0;
e_cp = 0;
e_crlc = 0;
e_cparhdr = 0;
e_minalloc = 0;
e_maxalloc = 0;
e_ss = 0;
e_sp = 0;
e_csum = 0;
e_ip = 0;
e_cs = 0;
e_lfarlc = 0;
e_ovno = 0;
for (unsigned int i=0;i<sizeof(e_res)/sizeof(e_res[0]);i++)
{
e_res[i] = 0;
}
e_oemid = 0;
e_oeminfo = 0;
for (unsigned int i=0;i<sizeof(e_res2)/sizeof(e_res2[0]);i++)
{
e_res2[i] = 0;
}
e_lfanew = 0;
}
PELIB_EXP_FUNC_INFORMATION::PELIB_EXP_FUNC_INFORMATION()
{
addroffunc = 0;
addrofname = 0;
ordinal = 0;
}
PELIB_IMAGE_RESOURCE_DIRECTORY::PELIB_IMAGE_RESOURCE_DIRECTORY()
{
Characteristics = 0;
TimeDateStamp = 0;
MajorVersion = 0;
MinorVersion = 0;
NumberOfNamedEntries = 0;
NumberOfIdEntries = 0;
}
PELIB_IMAGE_RESOURCE_DIRECTORY_ENTRY::PELIB_IMAGE_RESOURCE_DIRECTORY_ENTRY()
{
Name = 0;
OffsetToData = 0;
}
bool PELIB_IMG_RES_DIR_ENTRY::operator<(const PELIB_IMG_RES_DIR_ENTRY& first) const
{
if (irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING && first.irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING)
{
return wstrName < first.wstrName;
}
else if (irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING)
{
return true;
}
else if (first.irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING)
{
return false;
}
else
{
return irde.Name < first.irde.Name;
}
}
PELIB_IMAGE_BASE_RELOCATION::PELIB_IMAGE_BASE_RELOCATION()
{
VirtualAddress = 0;
SizeOfBlock = 0;
}
PELIB_IMAGE_COR20_HEADER::PELIB_IMAGE_COR20_HEADER()
{
cb = 0;
MajorRuntimeVersion = 0;
MinorRuntimeVersion = 0;
MetaData.VirtualAddress = 0;
MetaData.Size = 0;
Flags = 0;
EntryPointToken = 0;
Resources.VirtualAddress = 0;
Resources.Size = 0;
StrongNameSignature.VirtualAddress = 0;
StrongNameSignature.Size = 0;
CodeManagerTable.VirtualAddress = 0;
CodeManagerTable.Size = 0;
VTableFixups.VirtualAddress = 0;
VTableFixups.Size = 0;
ExportAddressTableJumps.VirtualAddress = 0;
ExportAddressTableJumps.Size = 0;
ManagedNativeHeader.VirtualAddress = 0;
ManagedNativeHeader.Size = 0;
}
/** Compares the passed filename to the struct's filename.
* @param strModuleName A filename.
* @return True, if the passed filename equals the struct's filename. The comparison is case-sensitive.
**/
bool PELIB_IMAGE_BOUND_DIRECTORY::equal(const std::string strModuleName) const
{
return this->strModuleName == strModuleName;
}
bool PELIB_EXP_FUNC_INFORMATION::equal(const std::string strFunctionName) const
{
return isEqualNc(this->funcname, strFunctionName);
}
/**
* @param strFilename Name of a file.
* @return Either PEFILE32, PEFILE64 or PEFILE_UNKNOWN
**/
unsigned int getFileType(const std::string strFilename)
{
word machine, magic;
PeFile32 pef(strFilename);
if (pef.readMzHeader() != NO_ERROR) return PEFILE_UNKNOWN;
if (pef.readPeHeader() != NO_ERROR) return PEFILE_UNKNOWN;
machine = pef.peHeader().getMachine();
magic = pef.peHeader().getMagic();
if (machine == PELIB_IMAGE_FILE_MACHINE_I386 && magic == PELIB_IMAGE_NT_OPTIONAL_HDR32_MAGIC)
{
return PEFILE32;
}
// 0x8664 == AMD64; no named constant yet
else if ((machine == 0x8664 || machine == PELIB_IMAGE_FILE_MACHINE_IA64) && magic == PELIB_IMAGE_NT_OPTIONAL_HDR64_MAGIC)
{
return PEFILE64;
}
else
{
return PEFILE_UNKNOWN;
}
}
/**
* Opens a PE file. The return type is either PeFile32 or PeFile64 object. If an error occurs the return
* value is 0.
* @param strFilename Name of a file.
* @return Either a PeFile32 object, a PeFil64 object or 0.
**/
PeFile* openPeFile(const std::string& strFilename)
{
unsigned int type = getFileType(strFilename);
if (type == PEFILE32)
{
return new PeFile32(strFilename);
}
else if (type == PEFILE64)
{
return new PeFile64(strFilename);
}
else
{
return 0;
}
}
unsigned int PELIB_IMAGE_BOUND_DIRECTORY::size() const
{
unsigned int size = 0;
for (unsigned int i=0;i<moduleForwarders.size();i++)
{
size += moduleForwarders[i].size();
}
return size + PELIB_IMAGE_BOUND_IMPORT_DESCRIPTOR::size() + strModuleName.size() + 1;
}
}
/*
* PeLibAux.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "PeLibAux.h"
#include "PeFile.h"
#ifdef _MSC_VER
#include <ctype.h>
#endif
namespace PeLib
{
const qword PELIB_IMAGE_ORDINAL_FLAGS<64>::IMAGE_ORDINAL_FLAG = 0x8000000000000000ULL;
bool PELIB_IMAGE_SECTION_HEADER::biggerFileOffset(const PELIB_IMAGE_SECTION_HEADER& ish) const
{
return PointerToRawData < ish.PointerToRawData;
}
bool PELIB_IMAGE_SECTION_HEADER::biggerVirtualAddress(const PELIB_IMAGE_SECTION_HEADER& ish) const
{
return VirtualAddress < ish.VirtualAddress;
}
unsigned int alignOffset(unsigned int uiOffset, unsigned int uiAlignment)
{
if (!uiAlignment) return uiAlignment;
return (uiOffset % uiAlignment) ? uiOffset + (uiAlignment - uiOffset % uiAlignment) : uiOffset;
}
unsigned int fileSize(const std::string& filename)
{
std::fstream file(filename.c_str());
file.seekg(0, std::ios::end);
return file.tellg();
}
unsigned int fileSize(std::ifstream& file)
{
unsigned int oldpos = file.tellg();
file.seekg(0, std::ios::end);
unsigned int filesize = file.tellg();
file.seekg(oldpos, std::ios::beg);
return filesize;
}
unsigned int fileSize(std::fstream& file)
{
unsigned int oldpos = file.tellg();
file.seekg(0, std::ios::end);
unsigned int filesize = file.tellg();
file.seekg(oldpos, std::ios::beg);
return filesize;
}
unsigned int fileSize(std::ofstream& file)
{
unsigned int oldpos = file.tellp();
file.seekp(0, std::ios::end);
unsigned int filesize = file.tellp();
file.seekp(oldpos, std::ios::beg);
return filesize;
}
bool isEqualNc(const std::string& s1, const std::string& s2)
{
std::string t1 = s1;
std::string t2 = s2;
// No std:: to make VC++ happy
#ifdef _MSC_VER
std::transform(t1.begin(), t1.end(), t1.begin(), toupper);
std::transform(t2.begin(), t2.end(), t2.begin(), toupper);
#else
// Weird syntax to make Borland C++ happy
std::transform(t1.begin(), t1.end(), t1.begin(), (int(*)(int))std::toupper);
std::transform(t2.begin(), t2.end(), t2.begin(), (int(*)(int))std::toupper);
#endif
return t1 == t2;
}
PELIB_IMAGE_DOS_HEADER::PELIB_IMAGE_DOS_HEADER()
{
e_magic = 0;
e_cblp = 0;
e_cp = 0;
e_crlc = 0;
e_cparhdr = 0;
e_minalloc = 0;
e_maxalloc = 0;
e_ss = 0;
e_sp = 0;
e_csum = 0;
e_ip = 0;
e_cs = 0;
e_lfarlc = 0;
e_ovno = 0;
for (unsigned int i=0;i<sizeof(e_res)/sizeof(e_res[0]);i++)
{
e_res[i] = 0;
}
e_oemid = 0;
e_oeminfo = 0;
for (unsigned int i=0;i<sizeof(e_res2)/sizeof(e_res2[0]);i++)
{
e_res2[i] = 0;
}
e_lfanew = 0;
}
PELIB_EXP_FUNC_INFORMATION::PELIB_EXP_FUNC_INFORMATION()
{
addroffunc = 0;
addrofname = 0;
ordinal = 0;
}
PELIB_IMAGE_RESOURCE_DIRECTORY::PELIB_IMAGE_RESOURCE_DIRECTORY()
{
Characteristics = 0;
TimeDateStamp = 0;
MajorVersion = 0;
MinorVersion = 0;
NumberOfNamedEntries = 0;
NumberOfIdEntries = 0;
}
PELIB_IMAGE_RESOURCE_DIRECTORY_ENTRY::PELIB_IMAGE_RESOURCE_DIRECTORY_ENTRY()
{
Name = 0;
OffsetToData = 0;
}
bool PELIB_IMG_RES_DIR_ENTRY::operator<(const PELIB_IMG_RES_DIR_ENTRY& first) const
{
if (irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING && first.irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING)
{
return wstrName < first.wstrName;
}
else if (irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING)
{
return true;
}
else if (first.irde.Name & PELIB_IMAGE_RESOURCE_NAME_IS_STRING)
{
return false;
}
else
{
return irde.Name < first.irde.Name;
}
}
PELIB_IMAGE_BASE_RELOCATION::PELIB_IMAGE_BASE_RELOCATION()
{
VirtualAddress = 0;
SizeOfBlock = 0;
}
PELIB_IMAGE_COR20_HEADER::PELIB_IMAGE_COR20_HEADER()
{
cb = 0;
MajorRuntimeVersion = 0;
MinorRuntimeVersion = 0;
MetaData.VirtualAddress = 0;
MetaData.Size = 0;
Flags = 0;
EntryPointToken = 0;
Resources.VirtualAddress = 0;
Resources.Size = 0;
StrongNameSignature.VirtualAddress = 0;
StrongNameSignature.Size = 0;
CodeManagerTable.VirtualAddress = 0;
CodeManagerTable.Size = 0;
VTableFixups.VirtualAddress = 0;
VTableFixups.Size = 0;
ExportAddressTableJumps.VirtualAddress = 0;
ExportAddressTableJumps.Size = 0;
ManagedNativeHeader.VirtualAddress = 0;
ManagedNativeHeader.Size = 0;
}
/** Compares the passed filename to the struct's filename.
* @param strModuleName A filename.
* @return True, if the passed filename equals the struct's filename. The comparison is case-sensitive.
**/
bool PELIB_IMAGE_BOUND_DIRECTORY::equal(const std::string strModuleName) const
{
return this->strModuleName == strModuleName;
}
bool PELIB_EXP_FUNC_INFORMATION::equal(const std::string strFunctionName) const
{
return isEqualNc(this->funcname, strFunctionName);
}
/**
* @param strFilename Name of a file.
* @return Either PEFILE32, PEFILE64 or PEFILE_UNKNOWN
**/
unsigned int getFileType(const std::string strFilename)
{
word machine, magic;
PeFile32 pef(strFilename);
if (pef.readMzHeader() != NO_ERROR) return PEFILE_UNKNOWN;
if (pef.readPeHeader() != NO_ERROR) return PEFILE_UNKNOWN;
machine = pef.peHeader().getMachine();
magic = pef.peHeader().getMagic();
if (machine == PELIB_IMAGE_FILE_MACHINE_I386 && magic == PELIB_IMAGE_NT_OPTIONAL_HDR32_MAGIC)
{
return PEFILE32;
}
// 0x8664 == AMD64; no named constant yet
else if ((machine == 0x8664 || machine == PELIB_IMAGE_FILE_MACHINE_IA64) && magic == PELIB_IMAGE_NT_OPTIONAL_HDR64_MAGIC)
{
return PEFILE64;
}
else
{
return PEFILE_UNKNOWN;
}
}
/**
* Opens a PE file. The return type is either PeFile32 or PeFile64 object. If an error occurs the return
* value is 0.
* @param strFilename Name of a file.
* @return Either a PeFile32 object, a PeFil64 object or 0.
**/
PeFile* openPeFile(const std::string& strFilename)
{
unsigned int type = getFileType(strFilename);
if (type == PEFILE32)
{
return new PeFile32(strFilename);
}
else if (type == PEFILE64)
{
return new PeFile64(strFilename);
}
else
{
return 0;
}
}
unsigned int PELIB_IMAGE_BOUND_DIRECTORY::size() const
{
unsigned int size = 0;
for (unsigned int i=0;i<moduleForwarders.size();i++)
{
size += moduleForwarders[i].size();
}
return size + PELIB_IMAGE_BOUND_IMPORT_DESCRIPTOR::size() + strModuleName.size() + 1;
}
}

1768
utils/zenutils/libraries/pelib-0.9/pelib/PeLibAux.h Executable file → Normal file

File diff suppressed because it is too large Load diff

64
utils/zenutils/libraries/pelib-0.9/pelib/PeLibInc.h Executable file → Normal file
View file

@ -1,32 +1,32 @@
/*
* PeLibInc.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef STD_H
#define STD_H
#ifdef _MSC_VER
#ifndef for
#define for if (0) {} else for
#endif
#endif
#include <algorithm>
#include <climits>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
// #include "PeLib.h"
#include "PeLibAux.h"
#endif
/*
* PeLibInc.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef STD_H
#define STD_H
#ifdef _MSC_VER
#ifndef for
#define for if (0) {} else for
#endif
#endif
#include <algorithm>
#include <climits>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
// #include "PeLib.h"
#include "PeLibAux.h"
#endif

View file

@ -1,211 +1,211 @@
/*
* Relocations.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "RelocationsDirectory.h"
namespace PeLib
{
void RelocationsDirectory::setRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber, word wData)
{
m_vRelocations[ulRelocation].vRelocData[ulDataNumber] = wData;
}
void RelocationsDirectory::read(InputBuffer& inputbuffer, unsigned int uiSize)
{
IMG_BASE_RELOC ibrCurr;
std::vector<IMG_BASE_RELOC> vCurrReloc;
do
{
inputbuffer >> ibrCurr.ibrRelocation.VirtualAddress;
inputbuffer >> ibrCurr.ibrRelocation.SizeOfBlock;
ibrCurr.vRelocData.clear();
// That's not how to check if there are relocations, some DLLs start at VA 0.
// if (!ibrCurr.ibrRelocation.VirtualAddress) break;
for (unsigned int i=0;i<(ibrCurr.ibrRelocation.SizeOfBlock - PELIB_IMAGE_SIZEOF_BASE_RELOCATION) / sizeof(word);i++)
{
word wData;
inputbuffer >> wData;
ibrCurr.vRelocData.push_back(wData);
}
vCurrReloc.push_back(ibrCurr);
} while (ibrCurr.ibrRelocation.VirtualAddress && inputbuffer.get() < uiSize);
std::swap(vCurrReloc, m_vRelocations);
}
// TODO: Return value is wrong if buffer was too small.
int RelocationsDirectory::read(const unsigned char* buffer, unsigned int buffersize)
{
std::vector<unsigned char> vRelocDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vRelocDirectory);
read(ibBuffer, buffersize);
return NO_ERROR;
}
int RelocationsDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<unsigned char> vRelocDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vRelocDirectory[0]), uiSize);
InputBuffer ibBuffer(vRelocDirectory);
read(ibBuffer, uiSize);
return NO_ERROR;
}
unsigned int RelocationsDirectory::size() const
{
unsigned int size = static_cast<unsigned int>(m_vRelocations.size()) * PELIB_IMAGE_BASE_RELOCATION::size();
for (unsigned int i=0;i<m_vRelocations.size();i++)
{
size += static_cast<unsigned int>(m_vRelocations[i].vRelocData.size()) * sizeof(word);
}
return size;
}
void RelocationsDirectory::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
for (unsigned int i=0;i<m_vRelocations.size();i++)
{
obBuffer << m_vRelocations[i].ibrRelocation.VirtualAddress;
obBuffer << m_vRelocations[i].ibrRelocation.SizeOfBlock;
for (unsigned int j=0;j<m_vRelocations[i].vRelocData.size();j++)
{
obBuffer << m_vRelocations[i].vRelocData[j];
}
}
}
unsigned int RelocationsDirectory::calcNumberOfRelocations() const
{
return static_cast<unsigned int>(m_vRelocations.size());
}
dword RelocationsDirectory::getVirtualAddress(unsigned int ulRelocation) const
{
return m_vRelocations[ulRelocation].ibrRelocation.VirtualAddress;
}
dword RelocationsDirectory::getSizeOfBlock(unsigned int ulRelocation) const
{
return m_vRelocations[ulRelocation].ibrRelocation.SizeOfBlock;
}
unsigned int RelocationsDirectory::calcNumberOfRelocationData(unsigned int ulRelocation) const
{
return static_cast<unsigned int>(m_vRelocations[ulRelocation].vRelocData.size());
}
word RelocationsDirectory::getRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber) const
{
return m_vRelocations[ulRelocation].vRelocData[ulDataNumber];
}
void RelocationsDirectory::setVirtualAddress(unsigned int ulRelocation, dword dwValue)
{
m_vRelocations[ulRelocation].ibrRelocation.VirtualAddress = dwValue;
}
void RelocationsDirectory::setSizeOfBlock(unsigned int ulRelocation, dword dwValue)
{
m_vRelocations[ulRelocation].ibrRelocation.SizeOfBlock = dwValue;
}
void RelocationsDirectory::addRelocation()
{
IMG_BASE_RELOC newrelocation;
m_vRelocations.push_back(newrelocation);
}
void RelocationsDirectory::addRelocationData(unsigned int ulRelocation, word wValue)
{
m_vRelocations[ulRelocation].vRelocData.push_back(wValue);
}
/* void RelocationsDirectory::removeRelocationData(unsigned int ulRelocation, word wValue)
{
// If you get an error with Borland C++ here you have two options: Upgrade your compiler
// or use the commented line instead of the line below.
m_vRelocations[ulRelocation].vRelocData.erase(std::remove(m_vRelocations[ulRelocation].vRelocData.begin(), m_vRelocations[ulRelocation].vRelocData.end(), wValue), m_vRelocations[ulRelocation].vRelocData.end());
}
*/
void RelocationsDirectory::removeRelocation(unsigned int index)
{
m_vRelocations.erase(m_vRelocations.begin() + index);
}
void RelocationsDirectory::removeRelocationData(unsigned int relocindex, unsigned int dataindex)
{
m_vRelocations[relocindex].vRelocData.erase(m_vRelocations[relocindex].vRelocData.begin() + dataindex);
}
int RelocationsDirectory::write(const std::string& strFilename, unsigned int uiOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(uiOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<std::streamsize>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
}
/*
* Relocations.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "PeLibInc.h"
#include "RelocationsDirectory.h"
namespace PeLib
{
void RelocationsDirectory::setRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber, word wData)
{
m_vRelocations[ulRelocation].vRelocData[ulDataNumber] = wData;
}
void RelocationsDirectory::read(InputBuffer& inputbuffer, unsigned int uiSize)
{
IMG_BASE_RELOC ibrCurr;
std::vector<IMG_BASE_RELOC> vCurrReloc;
do
{
inputbuffer >> ibrCurr.ibrRelocation.VirtualAddress;
inputbuffer >> ibrCurr.ibrRelocation.SizeOfBlock;
ibrCurr.vRelocData.clear();
// That's not how to check if there are relocations, some DLLs start at VA 0.
// if (!ibrCurr.ibrRelocation.VirtualAddress) break;
for (unsigned int i=0;i<(ibrCurr.ibrRelocation.SizeOfBlock - PELIB_IMAGE_SIZEOF_BASE_RELOCATION) / sizeof(word);i++)
{
word wData;
inputbuffer >> wData;
ibrCurr.vRelocData.push_back(wData);
}
vCurrReloc.push_back(ibrCurr);
} while (ibrCurr.ibrRelocation.VirtualAddress && inputbuffer.get() < uiSize);
std::swap(vCurrReloc, m_vRelocations);
}
// TODO: Return value is wrong if buffer was too small.
int RelocationsDirectory::read(const unsigned char* buffer, unsigned int buffersize)
{
std::vector<unsigned char> vRelocDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vRelocDirectory);
read(ibBuffer, buffersize);
return NO_ERROR;
}
int RelocationsDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<unsigned char> vRelocDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vRelocDirectory[0]), uiSize);
InputBuffer ibBuffer(vRelocDirectory);
read(ibBuffer, uiSize);
return NO_ERROR;
}
unsigned int RelocationsDirectory::size() const
{
unsigned int size = static_cast<unsigned int>(m_vRelocations.size()) * PELIB_IMAGE_BASE_RELOCATION::size();
for (unsigned int i=0;i<m_vRelocations.size();i++)
{
size += static_cast<unsigned int>(m_vRelocations[i].vRelocData.size()) * sizeof(word);
}
return size;
}
void RelocationsDirectory::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
for (unsigned int i=0;i<m_vRelocations.size();i++)
{
obBuffer << m_vRelocations[i].ibrRelocation.VirtualAddress;
obBuffer << m_vRelocations[i].ibrRelocation.SizeOfBlock;
for (unsigned int j=0;j<m_vRelocations[i].vRelocData.size();j++)
{
obBuffer << m_vRelocations[i].vRelocData[j];
}
}
}
unsigned int RelocationsDirectory::calcNumberOfRelocations() const
{
return static_cast<unsigned int>(m_vRelocations.size());
}
dword RelocationsDirectory::getVirtualAddress(unsigned int ulRelocation) const
{
return m_vRelocations[ulRelocation].ibrRelocation.VirtualAddress;
}
dword RelocationsDirectory::getSizeOfBlock(unsigned int ulRelocation) const
{
return m_vRelocations[ulRelocation].ibrRelocation.SizeOfBlock;
}
unsigned int RelocationsDirectory::calcNumberOfRelocationData(unsigned int ulRelocation) const
{
return static_cast<unsigned int>(m_vRelocations[ulRelocation].vRelocData.size());
}
word RelocationsDirectory::getRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber) const
{
return m_vRelocations[ulRelocation].vRelocData[ulDataNumber];
}
void RelocationsDirectory::setVirtualAddress(unsigned int ulRelocation, dword dwValue)
{
m_vRelocations[ulRelocation].ibrRelocation.VirtualAddress = dwValue;
}
void RelocationsDirectory::setSizeOfBlock(unsigned int ulRelocation, dword dwValue)
{
m_vRelocations[ulRelocation].ibrRelocation.SizeOfBlock = dwValue;
}
void RelocationsDirectory::addRelocation()
{
IMG_BASE_RELOC newrelocation;
m_vRelocations.push_back(newrelocation);
}
void RelocationsDirectory::addRelocationData(unsigned int ulRelocation, word wValue)
{
m_vRelocations[ulRelocation].vRelocData.push_back(wValue);
}
/* void RelocationsDirectory::removeRelocationData(unsigned int ulRelocation, word wValue)
{
// If you get an error with Borland C++ here you have two options: Upgrade your compiler
// or use the commented line instead of the line below.
m_vRelocations[ulRelocation].vRelocData.erase(std::remove(m_vRelocations[ulRelocation].vRelocData.begin(), m_vRelocations[ulRelocation].vRelocData.end(), wValue), m_vRelocations[ulRelocation].vRelocData.end());
}
*/
void RelocationsDirectory::removeRelocation(unsigned int index)
{
m_vRelocations.erase(m_vRelocations.begin() + index);
}
void RelocationsDirectory::removeRelocationData(unsigned int relocindex, unsigned int dataindex)
{
m_vRelocations[relocindex].vRelocData.erase(m_vRelocations[relocindex].vRelocData.begin() + dataindex);
}
int RelocationsDirectory::write(const std::string& strFilename, unsigned int uiOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(uiOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), static_cast<std::streamsize>(vBuffer.size()));
ofFile.close();
return NO_ERROR;
}
}

View file

@ -1,70 +1,70 @@
/*
* Relocations.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef RELOCATIONSDIRECTORY_H
#define RELOCATIONSDIRECTORY_H
namespace PeLib
{
/// Class that handles the relocations directory.
/**
* This class handles the relocations directory.
**/
class RelocationsDirectory
{
private:
std::vector<IMG_BASE_RELOC> m_vRelocations; ///< Used to store the relocation data.
void read(InputBuffer& inputbuffer, unsigned int uiSize);
public:
/// Returns the number of relocations in the relocations directory.
unsigned int calcNumberOfRelocations() const; // EXPORT
/// Returns the number of relocation data entries of a specific relocation.
unsigned int calcNumberOfRelocationData(unsigned int ulRelocation) const; // EXPORT
/// Read a file's relocations directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(const unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Rebuilds the relocations directory.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the relocations directory.
unsigned int size() const; // EXPORT
/// Writes the relocations directory to a file.
int write(const std::string& strFilename, unsigned int dwOffset) const; // EXPORT
/// Returns the VA of a relocation.
dword getVirtualAddress(unsigned int ulRelocation) const; // EXPORT
/// Returns the SizeOfBlock value of a relocation.
dword getSizeOfBlock(unsigned int ulRelocation) const; // EXPORT
/// Returns the RelocationData of a relocation.
word getRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber) const; // EXPORT
/// Changes the relocation data of a relocation.
void setRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber, word wData); // EXPORT
/// Changes the VirtualAddress of a relocation.
void setVirtualAddress(unsigned int ulRelocation, dword dwValue); // EXPORT
/// Changes the SizeOfBlock of a relocation.
void setSizeOfBlock(unsigned int ulRelocation, dword dwValue); // EXPORT
void addRelocation(); // EXPORT
/// Adds new data to a relocation.
void addRelocationData(unsigned int ulRelocation, word wValue); // EXPORT
/// Removes data from a relocation.
// void removeRelocationData(unsigned int ulRelocation, word wValue); // EXPORT
void removeRelocation(unsigned int index); // EXPORT
void removeRelocationData(unsigned int relocindex, unsigned int dataindex); // EXPORT
};
}
#endif
/*
* Relocations.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef RELOCATIONSDIRECTORY_H
#define RELOCATIONSDIRECTORY_H
namespace PeLib
{
/// Class that handles the relocations directory.
/**
* This class handles the relocations directory.
**/
class RelocationsDirectory
{
private:
std::vector<IMG_BASE_RELOC> m_vRelocations; ///< Used to store the relocation data.
void read(InputBuffer& inputbuffer, unsigned int uiSize);
public:
/// Returns the number of relocations in the relocations directory.
unsigned int calcNumberOfRelocations() const; // EXPORT
/// Returns the number of relocation data entries of a specific relocation.
unsigned int calcNumberOfRelocationData(unsigned int ulRelocation) const; // EXPORT
/// Read a file's relocations directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(const unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Rebuilds the relocations directory.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the relocations directory.
unsigned int size() const; // EXPORT
/// Writes the relocations directory to a file.
int write(const std::string& strFilename, unsigned int dwOffset) const; // EXPORT
/// Returns the VA of a relocation.
dword getVirtualAddress(unsigned int ulRelocation) const; // EXPORT
/// Returns the SizeOfBlock value of a relocation.
dword getSizeOfBlock(unsigned int ulRelocation) const; // EXPORT
/// Returns the RelocationData of a relocation.
word getRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber) const; // EXPORT
/// Changes the relocation data of a relocation.
void setRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber, word wData); // EXPORT
/// Changes the VirtualAddress of a relocation.
void setVirtualAddress(unsigned int ulRelocation, dword dwValue); // EXPORT
/// Changes the SizeOfBlock of a relocation.
void setSizeOfBlock(unsigned int ulRelocation, dword dwValue); // EXPORT
void addRelocation(); // EXPORT
/// Adds new data to a relocation.
void addRelocationData(unsigned int ulRelocation, word wValue); // EXPORT
/// Removes data from a relocation.
// void removeRelocationData(unsigned int ulRelocation, word wValue); // EXPORT
void removeRelocation(unsigned int index); // EXPORT
void removeRelocationData(unsigned int relocindex, unsigned int dataindex); // EXPORT
};
}
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

608
utils/zenutils/libraries/pelib-0.9/pelib/TlsDirectory.h Executable file → Normal file
View file

@ -1,304 +1,304 @@
/*
* TlsDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef TLSDIRECTORY_H
#define TLSDIRECTORY_H
namespace PeLib
{
/// Class that handles the TLS directory.
/**
* This class handles the TLS (Thread Local Storage) directory.
**/
template<int bits>
class TlsDirectory
{
private:
PELIB_IMAGE_TLS_DIRECTORY<bits> m_tls; ///< Structure that holds all information about the directory.
void read(InputBuffer& inputbuffer);
public:
/// Reads a file's TLS directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Rebuilds the TLS directory.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the TLS Directory.
unsigned int size() const; // EXPORT
/// Writes the TLS directory to a file.
int write(const std::string& strFilename, unsigned int dwOffset) const; // EXPORT
/// Returns the StartAddressOfRawData value of the TLS header.
dword getStartAddressOfRawData() const; // EXPORT
/// Returns the EndAddressOfRawData value of the TLS header.
dword getEndAddressOfRawData() const; // EXPORT
/// Returns the AddressOfIndex value of the TLS header.
dword getAddressOfIndex() const; // EXPORT
/// Returns the AddressOfCallBacks value of the TLS header.
dword getAddressOfCallBacks() const; // EXPORT
/// Returns the SizeOfZeroFill value of the TLS header.
dword getSizeOfZeroFill() const; // EXPORT
/// Returns the Characteristics value of the TLS header.
dword getCharacteristics() const; // EXPORT
/// Sets the StartAddressOfRawData value of the TLS header.
void setStartAddressOfRawData(dword dwValue); // EXPORT
/// Sets the EndAddressOfRawData value of the TLS header.
void setEndAddressOfRawData(dword dwValue); // EXPORT
/// Sets the AddressOfIndex value of the TLS header.
void setAddressOfIndex(dword dwValue); // EXPORT
/// Sets the AddressOfCallBacks value of the TLS header.
void setAddressOfCallBacks(dword dwValue); // EXPORT
/// Sets the SizeOfZeroFill value of the TLS header.
void setSizeOfZeroFill(dword dwValue); // EXPORT
/// Sets the Characteristics value of the TLS header.
void setCharacteristics(dword dwValue); // EXPORT
};
template<int bits>
void TlsDirectory<bits>::read(InputBuffer& inputBuffer)
{
PELIB_IMAGE_TLS_DIRECTORY<bits> itdCurr;
inputBuffer >> itdCurr.StartAddressOfRawData;
inputBuffer >> itdCurr.EndAddressOfRawData;
inputBuffer >> itdCurr.AddressOfIndex;
inputBuffer >> itdCurr.AddressOfCallBacks;
inputBuffer >> itdCurr.SizeOfZeroFill;
inputBuffer >> itdCurr.Characteristics;
std::swap(itdCurr, m_tls);
}
template<int bits>
int TlsDirectory<bits>::read(unsigned char* buffer, unsigned int buffersize)
{
if (buffersize < PELIB_IMAGE_TLS_DIRECTORY<bits>::size())
{
return ERROR_INVALID_FILE;
}
std::vector<byte> vTlsDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vTlsDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Reads a file's TLS directory.
* @param strFilename Name of the file.
* @param uiOffset File offset of the TLS directory.
* @param uiSize Size of the TLS directory.
**/
template<int bits>
int TlsDirectory<bits>::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<byte> vTlsDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vTlsDirectory[0]), uiSize);
InputBuffer ibBuffer(vTlsDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Rebuilds the current TLS Directory.
* @param vBuffer Buffer where the TLS directory will be written to.
**/
template<int bits>
void TlsDirectory<bits>::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
obBuffer << m_tls.StartAddressOfRawData;
obBuffer << m_tls.EndAddressOfRawData;
obBuffer << m_tls.AddressOfIndex;
obBuffer << m_tls.AddressOfCallBacks;
obBuffer << m_tls.SizeOfZeroFill;
obBuffer << m_tls.Characteristics;
}
/**
* Returns the size of the TLS directory. Due to the static nature of this structure the return value
* will always be 24.
* @return Size in bytes.
**/
template<int bits>
unsigned int TlsDirectory<bits>::size() const
{
return PELIB_IMAGE_TLS_DIRECTORY<bits>::size();
}
/**
* @param strFilename Name of the file.
* @param dwOffset File offset the TLS Directory will be written to.
**/
template<int bits>
int TlsDirectory<bits>::write(const std::string& strFilename, unsigned int dwOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(dwOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), vBuffer.size());
ofFile.close();
return NO_ERROR;
}
/**
* @return The StartAddressOfRawData value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getStartAddressOfRawData() const
{
return m_tls.StartAddressOfRawData;
}
/**
* @return The EndAddressOfRawData value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getEndAddressOfRawData() const
{
return m_tls.EndAddressOfRawData;
}
/**
* @return The AddressOfIndex value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getAddressOfIndex() const
{
return m_tls.AddressOfIndex;
}
/**
* @return The AddressOfCallBacks value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getAddressOfCallBacks() const
{
return m_tls.AddressOfCallBacks;
}
/**
* @return The SizeOfZeroFill value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getSizeOfZeroFill() const
{
return m_tls.SizeOfZeroFill;
}
/**
* @return The Characteristics value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getCharacteristics() const
{
return m_tls.Characteristics;
}
/**
* @param dwValue The new StartAddressOfRawData value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setStartAddressOfRawData(dword dwValue)
{
m_tls.StartAddressOfRawData = dwValue;
}
/**
* @param dwValue The new EndAddressOfRawData value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setEndAddressOfRawData(dword dwValue)
{
m_tls.EndAddressOfRawData = dwValue;
}
/**
* @param dwValue The new AddressOfIndex value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setAddressOfIndex(dword dwValue)
{
m_tls.AddressOfIndex = dwValue;
}
/**
* @param dwValue The new AddressOfCallBacks value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setAddressOfCallBacks(dword dwValue)
{
m_tls.AddressOfCallBacks = dwValue;
}
/**
* @param dwValue The new SizeOfZeroFill value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setSizeOfZeroFill(dword dwValue)
{
m_tls.SizeOfZeroFill = dwValue;
}
/**
* @param dwValue The new Characteristics value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setCharacteristics(dword dwValue)
{
m_tls.Characteristics = dwValue;
}
}
#endif
/*
* TlsDirectory.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef TLSDIRECTORY_H
#define TLSDIRECTORY_H
namespace PeLib
{
/// Class that handles the TLS directory.
/**
* This class handles the TLS (Thread Local Storage) directory.
**/
template<int bits>
class TlsDirectory
{
private:
PELIB_IMAGE_TLS_DIRECTORY<bits> m_tls; ///< Structure that holds all information about the directory.
void read(InputBuffer& inputbuffer);
public:
/// Reads a file's TLS directory.
int read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize); // EXPORT
int read(unsigned char* buffer, unsigned int buffersize); // EXPORT
/// Rebuilds the TLS directory.
void rebuild(std::vector<byte>& vBuffer) const; // EXPORT
/// Returns the size of the TLS Directory.
unsigned int size() const; // EXPORT
/// Writes the TLS directory to a file.
int write(const std::string& strFilename, unsigned int dwOffset) const; // EXPORT
/// Returns the StartAddressOfRawData value of the TLS header.
dword getStartAddressOfRawData() const; // EXPORT
/// Returns the EndAddressOfRawData value of the TLS header.
dword getEndAddressOfRawData() const; // EXPORT
/// Returns the AddressOfIndex value of the TLS header.
dword getAddressOfIndex() const; // EXPORT
/// Returns the AddressOfCallBacks value of the TLS header.
dword getAddressOfCallBacks() const; // EXPORT
/// Returns the SizeOfZeroFill value of the TLS header.
dword getSizeOfZeroFill() const; // EXPORT
/// Returns the Characteristics value of the TLS header.
dword getCharacteristics() const; // EXPORT
/// Sets the StartAddressOfRawData value of the TLS header.
void setStartAddressOfRawData(dword dwValue); // EXPORT
/// Sets the EndAddressOfRawData value of the TLS header.
void setEndAddressOfRawData(dword dwValue); // EXPORT
/// Sets the AddressOfIndex value of the TLS header.
void setAddressOfIndex(dword dwValue); // EXPORT
/// Sets the AddressOfCallBacks value of the TLS header.
void setAddressOfCallBacks(dword dwValue); // EXPORT
/// Sets the SizeOfZeroFill value of the TLS header.
void setSizeOfZeroFill(dword dwValue); // EXPORT
/// Sets the Characteristics value of the TLS header.
void setCharacteristics(dword dwValue); // EXPORT
};
template<int bits>
void TlsDirectory<bits>::read(InputBuffer& inputBuffer)
{
PELIB_IMAGE_TLS_DIRECTORY<bits> itdCurr;
inputBuffer >> itdCurr.StartAddressOfRawData;
inputBuffer >> itdCurr.EndAddressOfRawData;
inputBuffer >> itdCurr.AddressOfIndex;
inputBuffer >> itdCurr.AddressOfCallBacks;
inputBuffer >> itdCurr.SizeOfZeroFill;
inputBuffer >> itdCurr.Characteristics;
std::swap(itdCurr, m_tls);
}
template<int bits>
int TlsDirectory<bits>::read(unsigned char* buffer, unsigned int buffersize)
{
if (buffersize < PELIB_IMAGE_TLS_DIRECTORY<bits>::size())
{
return ERROR_INVALID_FILE;
}
std::vector<byte> vTlsDirectory(buffer, buffer + buffersize);
InputBuffer ibBuffer(vTlsDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Reads a file's TLS directory.
* @param strFilename Name of the file.
* @param uiOffset File offset of the TLS directory.
* @param uiSize Size of the TLS directory.
**/
template<int bits>
int TlsDirectory<bits>::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
{
std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
unsigned int ulFileSize = fileSize(ifFile);
if (!ifFile)
{
return ERROR_OPENING_FILE;
}
if (ulFileSize < uiOffset + uiSize)
{
return ERROR_INVALID_FILE;
}
ifFile.seekg(uiOffset, std::ios::beg);
std::vector<byte> vTlsDirectory(uiSize);
ifFile.read(reinterpret_cast<char*>(&vTlsDirectory[0]), uiSize);
InputBuffer ibBuffer(vTlsDirectory);
read(ibBuffer);
return NO_ERROR;
}
/**
* Rebuilds the current TLS Directory.
* @param vBuffer Buffer where the TLS directory will be written to.
**/
template<int bits>
void TlsDirectory<bits>::rebuild(std::vector<byte>& vBuffer) const
{
OutputBuffer obBuffer(vBuffer);
obBuffer << m_tls.StartAddressOfRawData;
obBuffer << m_tls.EndAddressOfRawData;
obBuffer << m_tls.AddressOfIndex;
obBuffer << m_tls.AddressOfCallBacks;
obBuffer << m_tls.SizeOfZeroFill;
obBuffer << m_tls.Characteristics;
}
/**
* Returns the size of the TLS directory. Due to the static nature of this structure the return value
* will always be 24.
* @return Size in bytes.
**/
template<int bits>
unsigned int TlsDirectory<bits>::size() const
{
return PELIB_IMAGE_TLS_DIRECTORY<bits>::size();
}
/**
* @param strFilename Name of the file.
* @param dwOffset File offset the TLS Directory will be written to.
**/
template<int bits>
int TlsDirectory<bits>::write(const std::string& strFilename, unsigned int dwOffset) const
{
std::fstream ofFile(strFilename.c_str(), std::ios_base::in);
if (!ofFile)
{
ofFile.clear();
ofFile.open(strFilename.c_str(), std::ios_base::out | std::ios_base::binary);
}
else
{
ofFile.close();
ofFile.open(strFilename.c_str(), std::ios_base::in | std::ios_base::out | std::ios_base::binary);
}
if (!ofFile)
{
return ERROR_OPENING_FILE;
}
ofFile.seekp(dwOffset, std::ios::beg);
std::vector<unsigned char> vBuffer;
rebuild(vBuffer);
ofFile.write(reinterpret_cast<const char*>(&vBuffer[0]), vBuffer.size());
ofFile.close();
return NO_ERROR;
}
/**
* @return The StartAddressOfRawData value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getStartAddressOfRawData() const
{
return m_tls.StartAddressOfRawData;
}
/**
* @return The EndAddressOfRawData value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getEndAddressOfRawData() const
{
return m_tls.EndAddressOfRawData;
}
/**
* @return The AddressOfIndex value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getAddressOfIndex() const
{
return m_tls.AddressOfIndex;
}
/**
* @return The AddressOfCallBacks value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getAddressOfCallBacks() const
{
return m_tls.AddressOfCallBacks;
}
/**
* @return The SizeOfZeroFill value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getSizeOfZeroFill() const
{
return m_tls.SizeOfZeroFill;
}
/**
* @return The Characteristics value of the TLS directory.
**/
template<int bits>
dword TlsDirectory<bits>::getCharacteristics() const
{
return m_tls.Characteristics;
}
/**
* @param dwValue The new StartAddressOfRawData value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setStartAddressOfRawData(dword dwValue)
{
m_tls.StartAddressOfRawData = dwValue;
}
/**
* @param dwValue The new EndAddressOfRawData value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setEndAddressOfRawData(dword dwValue)
{
m_tls.EndAddressOfRawData = dwValue;
}
/**
* @param dwValue The new AddressOfIndex value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setAddressOfIndex(dword dwValue)
{
m_tls.AddressOfIndex = dwValue;
}
/**
* @param dwValue The new AddressOfCallBacks value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setAddressOfCallBacks(dword dwValue)
{
m_tls.AddressOfCallBacks = dwValue;
}
/**
* @param dwValue The new SizeOfZeroFill value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setSizeOfZeroFill(dword dwValue)
{
m_tls.SizeOfZeroFill = dwValue;
}
/**
* @param dwValue The new Characteristics value of the TLS directory.
**/
template<int bits>
void TlsDirectory<bits>::setCharacteristics(dword dwValue)
{
m_tls.Characteristics = dwValue;
}
}
#endif

View file

@ -1,58 +1,58 @@
/*
* InputBuffer.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "InputBuffer.h"
namespace PeLib
{
unsigned long InputBuffer::get()
{
return ulIndex;
}
InputBuffer::InputBuffer(std::vector<unsigned char>& vBuffer) : m_vBuffer(vBuffer), ulIndex(0)
{
}
const unsigned char* InputBuffer::data() const
{
return &m_vBuffer[0];
}
unsigned long InputBuffer::size()
{
return static_cast<unsigned long>(m_vBuffer.size());
}
void InputBuffer::read(char* lpBuffer, unsigned long ulSize)
{
std::copy(&m_vBuffer[ulIndex], &m_vBuffer[ulIndex + ulSize], lpBuffer);
ulIndex += ulSize;
}
void InputBuffer::reset()
{
m_vBuffer.clear();
}
void InputBuffer::set(unsigned long ulIndex)
{
this->ulIndex = ulIndex;
}
void InputBuffer::setBuffer(std::vector<unsigned char>& vBuffer)
{
m_vBuffer = vBuffer;
ulIndex = 0;
}
}
/*
* InputBuffer.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "InputBuffer.h"
namespace PeLib
{
unsigned long InputBuffer::get()
{
return ulIndex;
}
InputBuffer::InputBuffer(std::vector<unsigned char>& vBuffer) : m_vBuffer(vBuffer), ulIndex(0)
{
}
const unsigned char* InputBuffer::data() const
{
return &m_vBuffer[0];
}
unsigned long InputBuffer::size()
{
return static_cast<unsigned long>(m_vBuffer.size());
}
void InputBuffer::read(char* lpBuffer, unsigned long ulSize)
{
std::copy(&m_vBuffer[ulIndex], &m_vBuffer[ulIndex + ulSize], lpBuffer);
ulIndex += ulSize;
}
void InputBuffer::reset()
{
m_vBuffer.clear();
}
void InputBuffer::set(unsigned long ulIndex)
{
this->ulIndex = ulIndex;
}
void InputBuffer::setBuffer(std::vector<unsigned char>& vBuffer)
{
m_vBuffer = vBuffer;
ulIndex = 0;
}
}

View file

@ -1,52 +1,52 @@
/*
* InputBuffer.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef INPUTBUFFER_H
#define INPUTBUFFER_H
#include <vector>
#include <iterator>
#include <cassert>
namespace PeLib
{
class InputBuffer
{
private:
std::vector<unsigned char>& m_vBuffer;
unsigned long ulIndex;
public:
InputBuffer(std::vector<unsigned char>& vBuffer);
const unsigned char* data() const;
unsigned long size();
template<typename T>
InputBuffer& operator>>(T& value)
{
assert(ulIndex + sizeof(value) <= m_vBuffer.size());
value = *(T*)(&m_vBuffer[ulIndex]);//reinterpret_cast<T*>(&m_vBuffer[ulIndex]);
ulIndex += sizeof(T);
return *this;
}
void read(char* lpBuffer, unsigned long ulSize);
void reset();
void set(unsigned long ulIndex);
unsigned long get();
void setBuffer(std::vector<unsigned char>& vBuffer);
// void updateData(unsigned long ulIndex,
};
}
#endif
/*
* InputBuffer.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef INPUTBUFFER_H
#define INPUTBUFFER_H
#include <vector>
#include <iterator>
#include <cassert>
namespace PeLib
{
class InputBuffer
{
private:
std::vector<unsigned char>& m_vBuffer;
unsigned long ulIndex;
public:
InputBuffer(std::vector<unsigned char>& vBuffer);
const unsigned char* data() const;
unsigned long size();
template<typename T>
InputBuffer& operator>>(T& value)
{
assert(ulIndex + sizeof(value) <= m_vBuffer.size());
value = *(T*)(&m_vBuffer[ulIndex]);//reinterpret_cast<T*>(&m_vBuffer[ulIndex]);
ulIndex += sizeof(T);
return *this;
}
void read(char* lpBuffer, unsigned long ulSize);
void reset();
void set(unsigned long ulIndex);
unsigned long get();
void setBuffer(std::vector<unsigned char>& vBuffer);
// void updateData(unsigned long ulIndex,
};
}
#endif

View file

@ -1,41 +1,41 @@
/*
* OutputBuffer.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "OutputBuffer.h"
namespace PeLib
{
OutputBuffer::OutputBuffer(std::vector<unsigned char>& vBuffer) : m_vBuffer(vBuffer)
{
m_vBuffer.clear();
}
const unsigned char* OutputBuffer::data() const
{
return &m_vBuffer[0];
}
unsigned long OutputBuffer::size()
{
return static_cast<unsigned long>(m_vBuffer.size());
}
void OutputBuffer::add(const char* lpBuffer, unsigned long ulSize)
{
std::copy(lpBuffer, lpBuffer + ulSize, std::back_inserter(m_vBuffer));
}
void OutputBuffer::reset()
{
m_vBuffer.clear();
}
}
/*
* OutputBuffer.cpp - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#include "OutputBuffer.h"
namespace PeLib
{
OutputBuffer::OutputBuffer(std::vector<unsigned char>& vBuffer) : m_vBuffer(vBuffer)
{
m_vBuffer.clear();
}
const unsigned char* OutputBuffer::data() const
{
return &m_vBuffer[0];
}
unsigned long OutputBuffer::size()
{
return static_cast<unsigned long>(m_vBuffer.size());
}
void OutputBuffer::add(const char* lpBuffer, unsigned long ulSize)
{
std::copy(lpBuffer, lpBuffer + ulSize, std::back_inserter(m_vBuffer));
}
void OutputBuffer::reset()
{
m_vBuffer.clear();
}
}

View file

@ -1,51 +1,51 @@
/*
* OutputBuffer.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef OUTPUTBUFFER_H
#define OUTPUTBUFFER_H
#include <vector>
#include <iterator>
namespace PeLib
{
class OutputBuffer
{
private:
std::vector<unsigned char>& m_vBuffer;
public:
OutputBuffer(std::vector<unsigned char>& vBuffer);
const unsigned char* data() const;
unsigned long size();
template<typename T>
OutputBuffer& operator<<(const T& value)
{
const unsigned char* p = reinterpret_cast<const unsigned char*>(&value);
std::copy(p, p + sizeof(value), std::back_inserter(m_vBuffer));
return *this;
}
void add(const char* lpBuffer, unsigned long ulSize);
void reset();
void resize(unsigned int uiSize);
void set(unsigned int uiPosition);
template<typename T>
void update(unsigned long ulIndex, const T& value)
{
*(T*)(&m_vBuffer[ulIndex]) = value;
}
};
}
#endif
/*
* OutputBuffer.h - Part of the PeLib library.
*
* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
* All rights reserved.
*
* This software is licensed under the zlib/libpng License.
* For more details see http://www.opensource.org/licenses/zlib-license.php
* or the license information file (license.htm) in the root directory
* of PeLib.
*/
#ifndef OUTPUTBUFFER_H
#define OUTPUTBUFFER_H
#include <vector>
#include <iterator>
namespace PeLib
{
class OutputBuffer
{
private:
std::vector<unsigned char>& m_vBuffer;
public:
OutputBuffer(std::vector<unsigned char>& vBuffer);
const unsigned char* data() const;
unsigned long size();
template<typename T>
OutputBuffer& operator<<(const T& value)
{
const unsigned char* p = reinterpret_cast<const unsigned char*>(&value);
std::copy(p, p + sizeof(value), std::back_inserter(m_vBuffer));
return *this;
}
void add(const char* lpBuffer, unsigned long ulSize);
void reset();
void resize(unsigned int uiSize);
void set(unsigned int uiPosition);
template<typename T>
void update(unsigned long ulIndex, const T& value)
{
*(T*)(&m_vBuffer[ulIndex]) = value;
}
};
}
#endif

640
utils/zenutils/libraries/pelib-0.9/pelib/changelog.txt Executable file → Normal file
View file

@ -1,321 +1,321 @@
PeLib 0.09 alpha (February 09, 2005)
Added:
- Added PeHeaderT<x>::setIddBaseRelocRva(dword value)
- Added PeHeaderT<x>::setIddBaseRelocSize(dword value)
- Added PeHeaderT<x>::setIddArchitectureRva(dword value)
- Added PeHeaderT<x>::setIddArchitectureSize(dword value)
- Added PeHeaderT<x>::setIddComHeaderRva(dword value)
- Added PeHeaderT<x>::setIddComHeaderSize(dword value)
- Added void PeHeaderT<x>::setImageDataDirectoryRva(dword dwDirectory, dword value)
- Added void PeHeaderT<x>::setImageDataDirectorySize(dword dwDirectory, dword value)
- Added bool PeHeaderT<x>::isValid() const
- Added int PeHeaderT<x>::read(const unsigned char* pcBuffer, unsigned int uiSize, unsigned int uiOffset);
- Added int BoundImportDirectory::read(unsigned char* pcBuffer, unsigned int uiSize);
- Added int BoundImportDirectory::read(InputBuffer& inpBuffer, unsigned char* data, unsigned int dwSize);
- Added unsigned int BoundImportDirectory::totalModules()
- Added DebugDirectory::setData to set the debug data of individual entries in the DebugDirectory.
- Added DebugDirectory::getData to get the debug data of individual entries in the DebugDirectory.
- Added int IatDirectory::read(unsigned char* buffer, unsigned int buffersize)
- Optimized the size and rebuild methods to avoid duplicate strings for files that appear
more than once in the BoundImport Directory.
- Added two read functions to TlsDirectory and updated the return values of the old read function.
- Added two read functions to ComHeaderDirectory and updated the return values of the old read function.
- Added two read functions to RelocationsDirectory and updated the return values of the old read function.
- Added void RelocationsDirectory::addRelocation()
- Added void RelocationsDirectory::removeRelocation(unsigned int index)
- Added void DebugDirectory::clear()
- Added void ExportDirectory::removeFunction(unsigned int index)
- Added void ExportDirectory::clear()
- Added unsigned int ExportDirectory::calcNumberOfFunctions()
- Added void ExportDirectory::setAddressOfNameOrdinals(dword value)
Bugfixes:
- Fixed a bug in TlsDirectory<bits>::size()
- Fixed a bug in PeHeaderT<64>::isValid(dword)
- Fixed a bug in PeHeaderT<bits>::removeDataDirectory(dword)
- Fixed a bug in BoundImportDirectory::rebuild()
- Fixed a bug in BoundImportDirectory::read() (Potential buffer overflow)
- Fixed a bug in BoundImportDirectory::read() (Bug caused incorrect results when reading the directory more than once)
- Fixed a bug when reading the debug data of individual DebugDirectory entries.
- Fixed a bug that caused non-existing data directories to be read (PeFile).
- Fixed a bug that caused problems when reading import directories that were located close to the end of the file (ImportDirectory).
- Fixed a minor bug in PeHeader::calcSizeOfImage
- Fixed some return values and removed all exception handling blocks.
Changes:
- Changed return values of PeHeader::addSection
- Changed return values of PeHeader::read
- Changed behaviour: PeHeader::m_uiOffset is initialized to 0 in default constructors.
- Changed return value of BoundImportDirectory::getNumberOfModules() from int to unsigned int
- Changed name of BoundImportDirectory::getNumberOfModules to calcNumberOfModules
- Changed the return values of the PeFile::read* functions.
- Renamed IatDirectory::removeAll to IatDirectory::clear
- Renamed IatDirectory::numberOfAddresses to IatDirectory::calcNumberOfAddresses
- Changed the parameter types of IatDirectory::getAddress from dword to unsigned int
- Changed the parameter types of IatDirectory::removeAddress from dword to unsigned int
- All constants taken from windows.h that were redefined in PeLibAux.h now have the prefix PELIB_ to avoid
conflicts with windows.h if both files are included to a project.
- Changed PELIB_IMAGE_TLS_DIRECTORY<bits>::size from an enum to a function.
- Changed the name of RelocationsDirectory::getNumberOfRelocationData to calcNumberOfRelocationData
- Changed void RelocationsDirectory::removeRelocationData(unsigned int ulRelocation, word wValue)
to void RelocationsDirectory::removeRelocationData(unsigned int relocindex, unsigned int dataindex)
- Removed dword ExportDirectory::getNumberOfNameOrdinals()
- Removed dword ExportDirectory::getNumberOfAddressOfFunctionNames()
- Removed dword ExportDirectory::getNumberOfAddressOfFunctions()
- Changed the parameters of some functions in ExportDirectory from dword to unsigned int.
January 16, 2005 PeLib 0.08 alpha
Added:
- Added std::string ExportDirectory::getNameString()
- Added resource type RT_MANIFEST to PeLibAux.h
- Added the following functions of PeHeaderT<int x>: setIddDebugRva, setIddDebugSize,
setIddDelayImportRva, setIddDelayImportSize, setIddExceptionRva, setIddExceptionSize, setIddGlobalPtrRva,
setIddGlobalPtrSize, setIddIatRva, setIddIatSize, setIddLoadConfigRva, setIddLoadConfigSize,
setIddResourceRva, setIddResourceSize, setIddResourceRva, setIddResourceSize, setIddSecurityRva,
setIddSecuritySize, setIddTlsRva, setIddTlsSize
- ImportDirectory32 and ImportDirectory64 are now available.
- Added ImportDirectory<bits>::setFileName(dword, currdir, const std::string&)
- Added ImportDirectory<bits>::setFirstThunk(dword, currdir, dword)
- Added ImportDirectory<bits>::setForwarderChain(dword, currdir, dword)
- Added ImportDirectory<bits>::setRvaOfName(dword, currdir, dword)
- Added ImportDirectory<bits>::setOriginalFirstThunk(dword, currdir, dword)
- Added ImportDirectory<bits>::setTimeDateStamp(dword, currdir, dword)
- Added ImportDirectory<bits>::setOriginalFirstThunk(dword, dword, currdir, dword)
- Added ImportDirectory<bits>::setFirstThunk(dword, dword, currdir, dword)
- Added ImportDirectory<bits>::setFunctionHint(dword, dword, currdir, word)
- Added ImportDirectory<bits>::setFunctionName(dword, dword, currdir, const std::string&)
- Added dword BoundImportDirectory::getTimeDateStamp(dword dwBidnr, dword forwardedModule) const
- Added word BoundImportDirectory::getOffsetModuleName(dword dwBidnr, dword forwardedModule) const
- Added word BoundImportDirectory::getNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule) const
- Added std::string BoundImportDirectory::getModuleName(dword dwBidnr, dword forwardedModule) const
- Added void BoundImportDirectory::setTimeDateStamp(dword dwBidnr, dword forwardedModule, dword dwTds)
- Added void BoundImportDirectory::setOffsetModuleName(dword dwBidnr, dword forwardedModule, word wOmn)
- Added void BoundImportDirectory::setNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule, word wMfr)
- Added void BoundImportDirectory::setModuleName(dword dwBidnr, dword forwardedModule, const std::string& strModuleName)
- Added word calcNumberOfModuleForwarderRefs(dword dwBidnr) const
- Added void addForwardedModule(dword dwBidnr, const std::string& name, dword timeStamp = 0, word offsetModuleName = 0, word forwardedModules = 0)
- Added void removeForwardedModule(dword dwBidnr, word forwardedModule)
- Added PeHeaderT<x>::addDataDirectory()
- Added PeHeaderT<x>::removeDataDirectory(dword)
Bugfixes:
- Fixed a bug in MzHeader::isValid
- Fixed a bug in PeHeaderT<x>::size()
- Fixed a bug in PeHeaderT<x>::calcRva()
- Fixed a bug in PeHeaderT<x>::calcSizeOfImage()
- Fixed a bug in PeHeaderT<x>::getSectionName(dword)
- Fixed a bug in PeHeaderT<x>::calcStartOfCode()
- Fixed a bug in PELIB_THUNK_DATA<bits>::bool equalHint(word wHint) const
- Fixed a bug in PELIB_IMAGE_THUNK_DATA<bits>::bool equalHint(word wHint) const
- Fixed a bug in int ImportDirectory<bits>::removeFunction(const std::string& strFilename, word wHint)
- Fixed a bug in int ImportDirectory<bits>::removeFile(const std::string& strFilename)
- Function hints are now properly added when rebuilding import directories.
- Reading and rebuilding bound import directories now works with forwarded modules.
Changes:
- Changed behaviour: Removed all exceptions from the MzHeader class. The functions work with return values now.
- Changed behaviour: The MzHeader::read() functions stopped checking if the MzHeader begins with "MZ".
- Changed behaviour: PeHeaderT<int x>::addSection(std::string, dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::getSectionWithOffset(dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::getSectionWithRva(dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::rvaToOffset(dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::write(std::string, unsigned int) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::writeSectionData(const std::string& strFilename, word wSecnr,
const std::vector<byte>& vBuffer) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::writeSections(std::string) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: Return value of PeHeaderT<x>::calcSpaceAfterHeader() changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::calcStartOfCode() changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::calcOffset() changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::offsetToRva(dword) changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::offsetToVa(dword) changed from unsigned long
to unsigned int.
- Renamed ExportDirectory::setName(std::string) to ExportDirectory::setNameString(std::string)
- Renamed the PeHeaderT::getId* functions to PeHeaderT::getIdd*
- Renamed PeHeaderT::getImageDirectoryRva to PeHeaderT::getImageDataDirectoryRva
- Renamed PeHeaderT::getImageDirectorySize to PeHeaderT::getImageDataDirectorySize
- Renamed void PeHeaderT<x>::setWinVersionValue(dword dwValue) to void PeHeaderT<x>::setWin32VersionValue(dword dwValue)
- Renamed the following functions of PeHeaderT<int x>: setIdImportRva to setIddImportRva,
setIdImportSize to setIddImportSize, setIdExportRva to setIddExportRva, setIdExportSize to setIddExportSize
- Renamed dword ImportDirectory<bits>::getName to dword ImportDirectory<bits>::getRvaOfName
- Changed behaviour: All removeFunction and removeFile functions from ImportDirectory.h return int instead
of void now.
- Changed behavior: ResourceDirectory::resourceTypeNameToIndex returns int instead of unsigned int.
-------------------------------------------------------------------------------------------------------------
July 18, 2004 PeLib 0.07 alpha
Added:
- Full support of the PE+ format.
- ImportDirectory::getName(string, currdir)
- ImportDirectory::getFirstThunk(dword, currdir)
- ImportDirectory::getOriginalFirstThunk(dword, currdir)
- ImportDirectory::getForwarderChain(dword, currdir)
- ImportDirectory::getName(dword, currdir)
- ImportDirectory::getTimeDateStamp(dword, currdir)
- PeLib::getFileType(string)
- PeLib::openPeFile(string)
- Added class PeFileVisitor
- Added PeFile::visit(PeFileVisitor&)
Bugfixes:
- Fixed a bug in PeHeader::rvaToOffset
Changes:
- Renamed ImportDirectory::OLD to PeLib::OLDDIR and ImportDirectory::NEW to PeLib::NEWDIR
- Renamed Relocations to RelocationsDirectory
- Renamed ImportAddressTable to IatDirectory
- Renamed ComDescriptor to ComHeader
- Renamed PeFile::comDescDir to PeFile::comDir
- Changed unsigned long ExportDirectory::getFunctionIndex to unsigned int ExportDirectory::getFunctionIndex
-------------------------------------------------------------------------------------------------------------
July 4, 2004 PeLib 0.06 alpha
Added:
- TlsDirectory class
Changes:
- ResourceElement::read and ResourceElement::rebuild are now protected.
Bugfixes:
- Fixed a bug in PeHeader::rvaToOffset
-------------------------------------------------------------------------------------------------------------
June 26, 2004 PeLib 0.05 alpha
Added:
- Constructor, Copy constructor, assignment operator and destructor for ResourceChild.
- ResourceDirectory::getRoot()
- ResourceElement::isLeaf()
- ResourceElement::getElementRva
- 10 new functions in ResourceLeaf.
- 22 new functions in ResourceNode.
- Added the RT_* constants which identify resource types to PeLibAux.h
- Added a new example (examples/ResourceTree) which shows how to use low level ResourceDirectory functions.
- Added PELIB_IMAGE_DEBUG_DIRECTORY and PELIB_IMG_DEBUG_DIRECTORY
- Added the new class DebugDirectory which handles the debug directory of PE files.
- Added readDebugDirectory() and debugDir() to PeFile.
Removed:
- ~ResourceNode()
-------------------------------------------------------------------------------------------------------------
June 12, 2004 PeLib 0.04 alpha
New:
- Finally implemented the class ResourceDirectory. That means lots of new functions I won't explicitly list here.
Check the documentation.
Removed:
- The files buffer/ResTree.cpp and buffer/ResTree.h are obsolete and were removed.
Bugfixes:
- Fixed PeHeader::calcStartOfCode
- Fixed PeHeader::getSectionWithRva
Changes:
- Changed PeHeader::read to throw an exception if the NT signature is not 'PE'\0\0
- Changed the 2nd parameter of void MzHeader::read(unsigned char*, unsigned long) from unsigned long to unsigned int.
- Changed the return value of MzHeader::size from long to int.
- Changed parameters of MzHeader::getReservedWords1, MzHeader::getReservedWords2, MzHeader::setReservedWords1 and
MzHeader::setReservedWords2 from long to int.
- Changed MzHeader::read(std::string) to MzHeader::read(const std::string&)
- Changed return value of BoundImportDirectory::getModuleIndex from long to int.
- Changed return value of BoundImportDirectory::size from long to int.
- Changed return value of ComDescriptor::size from long to int.
- Changed return value of ImportAddressTable::size from long to int.
- Changed return value of Relocations::getNumberOfRelocations from long to int.
- Changed return value of Relocations::getNumberOfRelocationData from long to int.
- Changed return value of Relocations::size from long to int.
- Changed parameter of Relocations::getVirtualAddress from long to int.
- Changed parameter of Relocations::getSizeOfBlock from long to int.
- Changed parameter of Relocations::getRelocationData from long to int.
- Changed parameters of Relocations::setRelocationData from long to int.
- Changed parameters of Relocations::setVirtualAddress from long to int.
- Changed parameters of Relocations::setSizeOfBlock from long to int.
- Changed parameters of Relocations::addRelocationData from long to int.
- Changed parameters of Relocations::removeRelocationData from long to int.
- Changed return value of ExportDirectory::getFunctionIndex(const std::string&) const from unsigned int to int.
-------------------------------------------------------------------------------------------------------------
May 31, 2004: PeLib 0.03 alpha
Bugfixes:
- Fixed some bugs in FileDump.cpp
Changes:
- Modified PeLibAux.cpp to make PeLib VC++ 7.1 compatible.
- Changed vector access from .at to operator[] all over the project.
Real undefined behaviour is probably better than spontaniously terminating applications.
New:
- Added makefiles for Borland C++ commandline tools (tested on version 5.6.4)
- Added makefiles for Digital Mars Compiler (tested on version 8.38n)
Note that support for DMC is not yet complete. PeLib compiles though, the examples don't yet but the
reason for this is that I am unable to correctly specifiy the PeLib object files when compiling.
- Added makefiles for Visual C++ 7.1 (tested on compiler Version 13.10.3052)
-------------------------------------------------------------------------------------------------------------
Mai 1, 2004: PeLib 0.02 alpha
Bugfixes:
- Fixed a bug in FileDump's and OON2's makefile.g++
- Fixed ImportDirectory::size
- Changed parameter of PELIB_THUNK_DATA::equalHint from dword to word
- Fixed a bug in PeHeader::read (PeLib always assumed 0x10 data directories in version 0.01 alpha)
Changes:
- Slightly changed ImportDirectory::removeFile (Changed function's signature)
- Moved the definitions of byte, word and dword into the PeLib namespace.
- Renamed PELIB_THUNK_DATA::equalName to PELIB_THUNK_DATA::equalFunctionName
- Started to add size() functions to structs defined in PeLibAux.h
- Moved PeFile::writeSectionData to PeHeader::writeSectionData
- Moved PeFile::writeSections to PeHeader::writeSections
New:
- Added ImportDirectory::hasFunction
- Wrote BoundImportDirectory::size
- Added accumulate function to PeLibAux.h
- Added PELIB_IMAGE_SECTION_HEADER::biggerFileOffset
- Added PELIB_IMAGE_SECTION_HEADER::biggerVirtualAddress
- Added PeHeader::calcSizeOfImage
- Added PeHeader::enlargeLastSection
Removed:
- Removed PeFile::write
- Removed PeFile::writeImportDirectory
Other changes:
- Rewrote parts of ImportDirectory::read
- Rewrote ImportDirectory::removeFunction (both version).
- Changed std::ios:: to std::ios_base:: in ImportDirectory
- Changed ImportDirectory::addFunction (both versions)
- Changed ExportDirectory::rebuild
- Changed ExportDirectory::size
- Rewrote ImportDirectory::size
- Rewrote PeHeader::size
- Rewrote ComDescriptor::size
-------------------------------------------------------------------------------------------------------------
PeLib 0.09 alpha (February 09, 2005)
Added:
- Added PeHeaderT<x>::setIddBaseRelocRva(dword value)
- Added PeHeaderT<x>::setIddBaseRelocSize(dword value)
- Added PeHeaderT<x>::setIddArchitectureRva(dword value)
- Added PeHeaderT<x>::setIddArchitectureSize(dword value)
- Added PeHeaderT<x>::setIddComHeaderRva(dword value)
- Added PeHeaderT<x>::setIddComHeaderSize(dword value)
- Added void PeHeaderT<x>::setImageDataDirectoryRva(dword dwDirectory, dword value)
- Added void PeHeaderT<x>::setImageDataDirectorySize(dword dwDirectory, dword value)
- Added bool PeHeaderT<x>::isValid() const
- Added int PeHeaderT<x>::read(const unsigned char* pcBuffer, unsigned int uiSize, unsigned int uiOffset);
- Added int BoundImportDirectory::read(unsigned char* pcBuffer, unsigned int uiSize);
- Added int BoundImportDirectory::read(InputBuffer& inpBuffer, unsigned char* data, unsigned int dwSize);
- Added unsigned int BoundImportDirectory::totalModules()
- Added DebugDirectory::setData to set the debug data of individual entries in the DebugDirectory.
- Added DebugDirectory::getData to get the debug data of individual entries in the DebugDirectory.
- Added int IatDirectory::read(unsigned char* buffer, unsigned int buffersize)
- Optimized the size and rebuild methods to avoid duplicate strings for files that appear
more than once in the BoundImport Directory.
- Added two read functions to TlsDirectory and updated the return values of the old read function.
- Added two read functions to ComHeaderDirectory and updated the return values of the old read function.
- Added two read functions to RelocationsDirectory and updated the return values of the old read function.
- Added void RelocationsDirectory::addRelocation()
- Added void RelocationsDirectory::removeRelocation(unsigned int index)
- Added void DebugDirectory::clear()
- Added void ExportDirectory::removeFunction(unsigned int index)
- Added void ExportDirectory::clear()
- Added unsigned int ExportDirectory::calcNumberOfFunctions()
- Added void ExportDirectory::setAddressOfNameOrdinals(dword value)
Bugfixes:
- Fixed a bug in TlsDirectory<bits>::size()
- Fixed a bug in PeHeaderT<64>::isValid(dword)
- Fixed a bug in PeHeaderT<bits>::removeDataDirectory(dword)
- Fixed a bug in BoundImportDirectory::rebuild()
- Fixed a bug in BoundImportDirectory::read() (Potential buffer overflow)
- Fixed a bug in BoundImportDirectory::read() (Bug caused incorrect results when reading the directory more than once)
- Fixed a bug when reading the debug data of individual DebugDirectory entries.
- Fixed a bug that caused non-existing data directories to be read (PeFile).
- Fixed a bug that caused problems when reading import directories that were located close to the end of the file (ImportDirectory).
- Fixed a minor bug in PeHeader::calcSizeOfImage
- Fixed some return values and removed all exception handling blocks.
Changes:
- Changed return values of PeHeader::addSection
- Changed return values of PeHeader::read
- Changed behaviour: PeHeader::m_uiOffset is initialized to 0 in default constructors.
- Changed return value of BoundImportDirectory::getNumberOfModules() from int to unsigned int
- Changed name of BoundImportDirectory::getNumberOfModules to calcNumberOfModules
- Changed the return values of the PeFile::read* functions.
- Renamed IatDirectory::removeAll to IatDirectory::clear
- Renamed IatDirectory::numberOfAddresses to IatDirectory::calcNumberOfAddresses
- Changed the parameter types of IatDirectory::getAddress from dword to unsigned int
- Changed the parameter types of IatDirectory::removeAddress from dword to unsigned int
- All constants taken from windows.h that were redefined in PeLibAux.h now have the prefix PELIB_ to avoid
conflicts with windows.h if both files are included to a project.
- Changed PELIB_IMAGE_TLS_DIRECTORY<bits>::size from an enum to a function.
- Changed the name of RelocationsDirectory::getNumberOfRelocationData to calcNumberOfRelocationData
- Changed void RelocationsDirectory::removeRelocationData(unsigned int ulRelocation, word wValue)
to void RelocationsDirectory::removeRelocationData(unsigned int relocindex, unsigned int dataindex)
- Removed dword ExportDirectory::getNumberOfNameOrdinals()
- Removed dword ExportDirectory::getNumberOfAddressOfFunctionNames()
- Removed dword ExportDirectory::getNumberOfAddressOfFunctions()
- Changed the parameters of some functions in ExportDirectory from dword to unsigned int.
January 16, 2005 PeLib 0.08 alpha
Added:
- Added std::string ExportDirectory::getNameString()
- Added resource type RT_MANIFEST to PeLibAux.h
- Added the following functions of PeHeaderT<int x>: setIddDebugRva, setIddDebugSize,
setIddDelayImportRva, setIddDelayImportSize, setIddExceptionRva, setIddExceptionSize, setIddGlobalPtrRva,
setIddGlobalPtrSize, setIddIatRva, setIddIatSize, setIddLoadConfigRva, setIddLoadConfigSize,
setIddResourceRva, setIddResourceSize, setIddResourceRva, setIddResourceSize, setIddSecurityRva,
setIddSecuritySize, setIddTlsRva, setIddTlsSize
- ImportDirectory32 and ImportDirectory64 are now available.
- Added ImportDirectory<bits>::setFileName(dword, currdir, const std::string&)
- Added ImportDirectory<bits>::setFirstThunk(dword, currdir, dword)
- Added ImportDirectory<bits>::setForwarderChain(dword, currdir, dword)
- Added ImportDirectory<bits>::setRvaOfName(dword, currdir, dword)
- Added ImportDirectory<bits>::setOriginalFirstThunk(dword, currdir, dword)
- Added ImportDirectory<bits>::setTimeDateStamp(dword, currdir, dword)
- Added ImportDirectory<bits>::setOriginalFirstThunk(dword, dword, currdir, dword)
- Added ImportDirectory<bits>::setFirstThunk(dword, dword, currdir, dword)
- Added ImportDirectory<bits>::setFunctionHint(dword, dword, currdir, word)
- Added ImportDirectory<bits>::setFunctionName(dword, dword, currdir, const std::string&)
- Added dword BoundImportDirectory::getTimeDateStamp(dword dwBidnr, dword forwardedModule) const
- Added word BoundImportDirectory::getOffsetModuleName(dword dwBidnr, dword forwardedModule) const
- Added word BoundImportDirectory::getNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule) const
- Added std::string BoundImportDirectory::getModuleName(dword dwBidnr, dword forwardedModule) const
- Added void BoundImportDirectory::setTimeDateStamp(dword dwBidnr, dword forwardedModule, dword dwTds)
- Added void BoundImportDirectory::setOffsetModuleName(dword dwBidnr, dword forwardedModule, word wOmn)
- Added void BoundImportDirectory::setNumberOfModuleForwarderRefs(dword dwBidnr, dword forwardedModule, word wMfr)
- Added void BoundImportDirectory::setModuleName(dword dwBidnr, dword forwardedModule, const std::string& strModuleName)
- Added word calcNumberOfModuleForwarderRefs(dword dwBidnr) const
- Added void addForwardedModule(dword dwBidnr, const std::string& name, dword timeStamp = 0, word offsetModuleName = 0, word forwardedModules = 0)
- Added void removeForwardedModule(dword dwBidnr, word forwardedModule)
- Added PeHeaderT<x>::addDataDirectory()
- Added PeHeaderT<x>::removeDataDirectory(dword)
Bugfixes:
- Fixed a bug in MzHeader::isValid
- Fixed a bug in PeHeaderT<x>::size()
- Fixed a bug in PeHeaderT<x>::calcRva()
- Fixed a bug in PeHeaderT<x>::calcSizeOfImage()
- Fixed a bug in PeHeaderT<x>::getSectionName(dword)
- Fixed a bug in PeHeaderT<x>::calcStartOfCode()
- Fixed a bug in PELIB_THUNK_DATA<bits>::bool equalHint(word wHint) const
- Fixed a bug in PELIB_IMAGE_THUNK_DATA<bits>::bool equalHint(word wHint) const
- Fixed a bug in int ImportDirectory<bits>::removeFunction(const std::string& strFilename, word wHint)
- Fixed a bug in int ImportDirectory<bits>::removeFile(const std::string& strFilename)
- Function hints are now properly added when rebuilding import directories.
- Reading and rebuilding bound import directories now works with forwarded modules.
Changes:
- Changed behaviour: Removed all exceptions from the MzHeader class. The functions work with return values now.
- Changed behaviour: The MzHeader::read() functions stopped checking if the MzHeader begins with "MZ".
- Changed behaviour: PeHeaderT<int x>::addSection(std::string, dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::getSectionWithOffset(dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::getSectionWithRva(dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::rvaToOffset(dword) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::write(std::string, unsigned int) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::writeSectionData(const std::string& strFilename, word wSecnr,
const std::vector<byte>& vBuffer) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: PeHeaderT<int x>::writeSections(std::string) doesn't use exceptions anymore.
Return values now indicate if the function succeeded or failed.
- Changed behaviour: Return value of PeHeaderT<x>::calcSpaceAfterHeader() changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::calcStartOfCode() changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::calcOffset() changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::offsetToRva(dword) changed from unsigned long
to unsigned int.
- Changed behaviour: Return value of PeHeaderT<x>::offsetToVa(dword) changed from unsigned long
to unsigned int.
- Renamed ExportDirectory::setName(std::string) to ExportDirectory::setNameString(std::string)
- Renamed the PeHeaderT::getId* functions to PeHeaderT::getIdd*
- Renamed PeHeaderT::getImageDirectoryRva to PeHeaderT::getImageDataDirectoryRva
- Renamed PeHeaderT::getImageDirectorySize to PeHeaderT::getImageDataDirectorySize
- Renamed void PeHeaderT<x>::setWinVersionValue(dword dwValue) to void PeHeaderT<x>::setWin32VersionValue(dword dwValue)
- Renamed the following functions of PeHeaderT<int x>: setIdImportRva to setIddImportRva,
setIdImportSize to setIddImportSize, setIdExportRva to setIddExportRva, setIdExportSize to setIddExportSize
- Renamed dword ImportDirectory<bits>::getName to dword ImportDirectory<bits>::getRvaOfName
- Changed behaviour: All removeFunction and removeFile functions from ImportDirectory.h return int instead
of void now.
- Changed behavior: ResourceDirectory::resourceTypeNameToIndex returns int instead of unsigned int.
-------------------------------------------------------------------------------------------------------------
July 18, 2004 PeLib 0.07 alpha
Added:
- Full support of the PE+ format.
- ImportDirectory::getName(string, currdir)
- ImportDirectory::getFirstThunk(dword, currdir)
- ImportDirectory::getOriginalFirstThunk(dword, currdir)
- ImportDirectory::getForwarderChain(dword, currdir)
- ImportDirectory::getName(dword, currdir)
- ImportDirectory::getTimeDateStamp(dword, currdir)
- PeLib::getFileType(string)
- PeLib::openPeFile(string)
- Added class PeFileVisitor
- Added PeFile::visit(PeFileVisitor&)
Bugfixes:
- Fixed a bug in PeHeader::rvaToOffset
Changes:
- Renamed ImportDirectory::OLD to PeLib::OLDDIR and ImportDirectory::NEW to PeLib::NEWDIR
- Renamed Relocations to RelocationsDirectory
- Renamed ImportAddressTable to IatDirectory
- Renamed ComDescriptor to ComHeader
- Renamed PeFile::comDescDir to PeFile::comDir
- Changed unsigned long ExportDirectory::getFunctionIndex to unsigned int ExportDirectory::getFunctionIndex
-------------------------------------------------------------------------------------------------------------
July 4, 2004 PeLib 0.06 alpha
Added:
- TlsDirectory class
Changes:
- ResourceElement::read and ResourceElement::rebuild are now protected.
Bugfixes:
- Fixed a bug in PeHeader::rvaToOffset
-------------------------------------------------------------------------------------------------------------
June 26, 2004 PeLib 0.05 alpha
Added:
- Constructor, Copy constructor, assignment operator and destructor for ResourceChild.
- ResourceDirectory::getRoot()
- ResourceElement::isLeaf()
- ResourceElement::getElementRva
- 10 new functions in ResourceLeaf.
- 22 new functions in ResourceNode.
- Added the RT_* constants which identify resource types to PeLibAux.h
- Added a new example (examples/ResourceTree) which shows how to use low level ResourceDirectory functions.
- Added PELIB_IMAGE_DEBUG_DIRECTORY and PELIB_IMG_DEBUG_DIRECTORY
- Added the new class DebugDirectory which handles the debug directory of PE files.
- Added readDebugDirectory() and debugDir() to PeFile.
Removed:
- ~ResourceNode()
-------------------------------------------------------------------------------------------------------------
June 12, 2004 PeLib 0.04 alpha
New:
- Finally implemented the class ResourceDirectory. That means lots of new functions I won't explicitly list here.
Check the documentation.
Removed:
- The files buffer/ResTree.cpp and buffer/ResTree.h are obsolete and were removed.
Bugfixes:
- Fixed PeHeader::calcStartOfCode
- Fixed PeHeader::getSectionWithRva
Changes:
- Changed PeHeader::read to throw an exception if the NT signature is not 'PE'\0\0
- Changed the 2nd parameter of void MzHeader::read(unsigned char*, unsigned long) from unsigned long to unsigned int.
- Changed the return value of MzHeader::size from long to int.
- Changed parameters of MzHeader::getReservedWords1, MzHeader::getReservedWords2, MzHeader::setReservedWords1 and
MzHeader::setReservedWords2 from long to int.
- Changed MzHeader::read(std::string) to MzHeader::read(const std::string&)
- Changed return value of BoundImportDirectory::getModuleIndex from long to int.
- Changed return value of BoundImportDirectory::size from long to int.
- Changed return value of ComDescriptor::size from long to int.
- Changed return value of ImportAddressTable::size from long to int.
- Changed return value of Relocations::getNumberOfRelocations from long to int.
- Changed return value of Relocations::getNumberOfRelocationData from long to int.
- Changed return value of Relocations::size from long to int.
- Changed parameter of Relocations::getVirtualAddress from long to int.
- Changed parameter of Relocations::getSizeOfBlock from long to int.
- Changed parameter of Relocations::getRelocationData from long to int.
- Changed parameters of Relocations::setRelocationData from long to int.
- Changed parameters of Relocations::setVirtualAddress from long to int.
- Changed parameters of Relocations::setSizeOfBlock from long to int.
- Changed parameters of Relocations::addRelocationData from long to int.
- Changed parameters of Relocations::removeRelocationData from long to int.
- Changed return value of ExportDirectory::getFunctionIndex(const std::string&) const from unsigned int to int.
-------------------------------------------------------------------------------------------------------------
May 31, 2004: PeLib 0.03 alpha
Bugfixes:
- Fixed some bugs in FileDump.cpp
Changes:
- Modified PeLibAux.cpp to make PeLib VC++ 7.1 compatible.
- Changed vector access from .at to operator[] all over the project.
Real undefined behaviour is probably better than spontaniously terminating applications.
New:
- Added makefiles for Borland C++ commandline tools (tested on version 5.6.4)
- Added makefiles for Digital Mars Compiler (tested on version 8.38n)
Note that support for DMC is not yet complete. PeLib compiles though, the examples don't yet but the
reason for this is that I am unable to correctly specifiy the PeLib object files when compiling.
- Added makefiles for Visual C++ 7.1 (tested on compiler Version 13.10.3052)
-------------------------------------------------------------------------------------------------------------
Mai 1, 2004: PeLib 0.02 alpha
Bugfixes:
- Fixed a bug in FileDump's and OON2's makefile.g++
- Fixed ImportDirectory::size
- Changed parameter of PELIB_THUNK_DATA::equalHint from dword to word
- Fixed a bug in PeHeader::read (PeLib always assumed 0x10 data directories in version 0.01 alpha)
Changes:
- Slightly changed ImportDirectory::removeFile (Changed function's signature)
- Moved the definitions of byte, word and dword into the PeLib namespace.
- Renamed PELIB_THUNK_DATA::equalName to PELIB_THUNK_DATA::equalFunctionName
- Started to add size() functions to structs defined in PeLibAux.h
- Moved PeFile::writeSectionData to PeHeader::writeSectionData
- Moved PeFile::writeSections to PeHeader::writeSections
New:
- Added ImportDirectory::hasFunction
- Wrote BoundImportDirectory::size
- Added accumulate function to PeLibAux.h
- Added PELIB_IMAGE_SECTION_HEADER::biggerFileOffset
- Added PELIB_IMAGE_SECTION_HEADER::biggerVirtualAddress
- Added PeHeader::calcSizeOfImage
- Added PeHeader::enlargeLastSection
Removed:
- Removed PeFile::write
- Removed PeFile::writeImportDirectory
Other changes:
- Rewrote parts of ImportDirectory::read
- Rewrote ImportDirectory::removeFunction (both version).
- Changed std::ios:: to std::ios_base:: in ImportDirectory
- Changed ImportDirectory::addFunction (both versions)
- Changed ExportDirectory::rebuild
- Changed ExportDirectory::size
- Rewrote ImportDirectory::size
- Rewrote PeHeader::size
- Rewrote ComDescriptor::size
-------------------------------------------------------------------------------------------------------------
April 9, 2004: PeLib 0.01 alpha Initial release

68
utils/zenutils/libraries/pelib-0.9/pelib/license.htm Executable file → Normal file
View file

@ -1,35 +1,35 @@
<html>
<body>
<h1>The zlib/libpng License</h1>
<tt>
<p>Copyright (c) 2004 - Sebastian Porst</p>
<p>This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.</p>
<p>Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:</p>
<blockquote>
<p>1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.</p>
<p>2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.</p>
<p>3. This notice may not be removed or altered from any source
distribution.</p>
</blockquote>
</tt>
</body>
<html>
<body>
<h1>The zlib/libpng License</h1>
<tt>
<p>Copyright (c) 2004 - Sebastian Porst</p>
<p>This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.</p>
<p>Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:</p>
<blockquote>
<p>1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.</p>
<p>2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.</p>
<p>3. This notice may not be removed or altered from any source
distribution.</p>
</blockquote>
</tt>
</body>
</html>

86
utils/zenutils/libraries/pelib-0.9/pelib/readme.txt Executable file → Normal file
View file

@ -1,44 +1,44 @@
PeLib - Version 0.09 (alpha release)
=========================================
Copyright 2004 by Sebastian Porst
WWW: http://www.pelib.com
E-Mail: webmaster@the-interweb.com
=========================================
1. What is PeLib?
2. Where can I find a documentation of PeLib DLL?
3. Which license is used for PeLib?
4. Which compilers are being supported?
5. How do I compile PeLib?
1. What is PeLib DLL?
PeLib is an open-source C++ library to modify
PE files. See http://www.pelib.com for more details.
2. Where can I find a documentation of PeLib DLL?
http://www.pelib.com
3. All parts of PeLib are distributed under the zlib/libpng license.
See license.htm for details.
4. The following compilers have been tested:
MingW with g++ 3.2.3
Visual C++ 7.1 / Compiler version 13.10.3052
Borland C++ 5.6.4 (currently not supported)
Digital Mars Compiler 8.38n (currently not supported)
5. Go into the PeLib/source directory and enter the following lines
depending on which compiler you use.
g++: make -f makefile.g++
Borland C++: make -f makefile.bcc (currently not supported)
Visual C++ 7.1: nmake makefile.vc7
Digital Mars: make makefile.dmc (currently not supported)
If the compilation is succesful there should be some *.o/*.obj files
and (if you used g++) a PeLib.a file in the lib directory.
Then go to the examples directory and pick one example (I
suggest FileDump) and try to build it with the same make
PeLib - Version 0.09 (alpha release)
=========================================
Copyright 2004 by Sebastian Porst
WWW: http://www.pelib.com
E-Mail: webmaster@the-interweb.com
=========================================
1. What is PeLib?
2. Where can I find a documentation of PeLib DLL?
3. Which license is used for PeLib?
4. Which compilers are being supported?
5. How do I compile PeLib?
1. What is PeLib DLL?
PeLib is an open-source C++ library to modify
PE files. See http://www.pelib.com for more details.
2. Where can I find a documentation of PeLib DLL?
http://www.pelib.com
3. All parts of PeLib are distributed under the zlib/libpng license.
See license.htm for details.
4. The following compilers have been tested:
MingW with g++ 3.2.3
Visual C++ 7.1 / Compiler version 13.10.3052
Borland C++ 5.6.4 (currently not supported)
Digital Mars Compiler 8.38n (currently not supported)
5. Go into the PeLib/source directory and enter the following lines
depending on which compiler you use.
g++: make -f makefile.g++
Borland C++: make -f makefile.bcc (currently not supported)
Visual C++ 7.1: nmake makefile.vc7
Digital Mars: make makefile.dmc (currently not supported)
If the compilation is succesful there should be some *.o/*.obj files
and (if you used g++) a PeLib.a file in the lib directory.
Then go to the examples directory and pick one example (I
suggest FileDump) and try to build it with the same make
command as above.

38
utils/zenutils/libraries/zlib123/CMakeLists.txt Executable file → Normal file
View file

@ -1,19 +1,19 @@
PROJECT(zlib)
# source files for zlib
SET(zlib_src
zlib/adler32.c
zlib/compress.c
zlib/crc32.c
zlib/deflate.c
zlib/gzio.c
zlib/infback.c
zlib/inffast.c
zlib/inflate.c
zlib/inftrees.c
zlib/trees.c
zlib/uncompr.c
zlib/zutil.c
)
ADD_LIBRARY(zlib ${zlib_src})
PROJECT(zlib)
# source files for zlib
SET(zlib_src
zlib/adler32.c
zlib/compress.c
zlib/crc32.c
zlib/deflate.c
zlib/gzio.c
zlib/infback.c
zlib/inffast.c
zlib/inflate.c
zlib/inftrees.c
zlib/trees.c
zlib/uncompr.c
zlib/zutil.c
)
ADD_LIBRARY(zlib ${zlib_src})

1710
utils/zenutils/libraries/zlib123/zlib/ChangeLog Executable file → Normal file

File diff suppressed because it is too large Load diff

678
utils/zenutils/libraries/zlib123/zlib/FAQ Executable file → Normal file
View file

@ -1,339 +1,339 @@
Frequently Asked Questions about zlib
If your question is not there, please check the zlib home page
http://www.zlib.org which may have more recent information.
The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
1. Is zlib Y2K-compliant?
Yes. zlib doesn't handle dates.
2. Where can I get a Windows DLL version?
The zlib sources can be compiled without change to produce a DLL.
See the file win32/DLL_FAQ.txt in the zlib distribution.
Pointers to the precompiled DLL are found in the zlib web site at
http://www.zlib.org.
3. Where can I get a Visual Basic interface to zlib?
See
* http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm
* contrib/visual-basic.txt in the zlib distribution
* win32/DLL_FAQ.txt in the zlib distribution
4. compress() returns Z_BUF_ERROR.
Make sure that before the call of compress, the length of the compressed
buffer is equal to the total size of the compressed buffer and not
zero. For Visual Basic, check that this parameter is passed by reference
("as any"), not by value ("as long").
5. deflate() or inflate() returns Z_BUF_ERROR.
Before making the call, make sure that avail_in and avail_out are not
zero. When setting the parameter flush equal to Z_FINISH, also make sure
that avail_out is big enough to allow processing all pending input.
Note that a Z_BUF_ERROR is not fatal--another call to deflate() or
inflate() can be made with more input or output space. A Z_BUF_ERROR
may in fact be unavoidable depending on how the functions are used, since
it is not possible to tell whether or not there is more output pending
when strm.avail_out returns with zero.
6. Where's the zlib documentation (man pages, etc.)?
It's in zlib.h for the moment, and Francis S. Lin has converted it to a
web page zlib.html. Volunteers to transform this to Unix-style man pages,
please contact us (zlib@gzip.org). Examples of zlib usage are in the files
example.c and minigzip.c.
7. Why don't you use GNU autoconf or libtool or ...?
Because we would like to keep zlib as a very small and simple
package. zlib is rather portable and doesn't need much configuration.
8. I found a bug in zlib.
Most of the time, such problems are due to an incorrect usage of
zlib. Please try to reproduce the problem with a small program and send
the corresponding source to us at zlib@gzip.org . Do not send
multi-megabyte data files without prior agreement.
9. Why do I get "undefined reference to gzputc"?
If "make test" produces something like
example.o(.text+0x154): undefined reference to `gzputc'
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
/usr/X11R6/lib. Remove any old versions, then do "make install".
10. I need a Delphi interface to zlib.
See the contrib/delphi directory in the zlib distribution.
11. Can zlib handle .zip archives?
Not by itself, no. See the directory contrib/minizip in the zlib
distribution.
12. Can zlib handle .Z files?
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
the code of uncompress on your own.
13. How can I make a Unix shared library?
make clean
./configure -s
make
14. How do I install a shared zlib library on Unix?
After the above, then:
make install
However, many flavors of Unix come with a shared zlib already installed.
Before going to the trouble of compiling a shared version of zlib and
trying to install it, you may want to check if it's already there! If you
can #include <zlib.h>, it's there. The -lz option will probably link to it.
15. I have a question about OttoPDF.
We are not the authors of OttoPDF. The real author is on the OttoPDF web
site: Joel Hainley, jhainley@myndkryme.com.
16. Can zlib decode Flate data in an Adobe PDF file?
Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ .
To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ .
17. Why am I getting this "register_frame_info not found" error on Solaris?
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
generates an error such as:
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
symbol __register_frame_info: referenced symbol not found
The symbol __register_frame_info is not part of zlib, it is generated by
the C compiler (cc or gcc). You must recompile applications using zlib
which have this problem. This problem is specific to Solaris. See
http://www.sunfreeware.com for Solaris versions of zlib and applications
using zlib.
18. Why does gzip give an error on a file I make with compress/deflate?
The compress and deflate functions produce data in the zlib format, which
is different and incompatible with the gzip format. The gz* functions in
zlib on the other hand use the gzip format. Both the zlib and gzip
formats use the same compressed data format internally, but have different
headers and trailers around the compressed data.
19. Ok, so why are there two different formats?
The gzip format was designed to retain the directory information about
a single file, such as the name and last modification date. The zlib
format on the other hand was designed for in-memory and communication
channel applications, and has a much more compact header and trailer and
uses a faster integrity check than gzip.
20. Well that's nice, but how do I make a gzip file in memory?
You can request that deflate write the gzip format instead of the zlib
format using deflateInit2(). You can also request that inflate decode
the gzip format using inflateInit2(). Read zlib.h for more details.
21. Is zlib thread-safe?
Yes. However any library routines that zlib uses and any application-
provided memory allocation routines must also be thread-safe. zlib's gz*
functions use stdio library routines, and most of zlib's functions use the
library memory allocation routines by default. zlib's Init functions allow
for the application to provide custom memory allocation routines.
Of course, you should only operate on any given zlib or gzip stream from a
single thread at a time.
22. Can I use zlib in my commercial application?
Yes. Please read the license in zlib.h.
23. Is zlib under the GNU license?
No. Please read the license in zlib.h.
24. The license says that altered source versions must be "plainly marked". So
what exactly do I need to do to meet that requirement?
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
particular, the final version number needs to be changed to "f", and an
identification string should be appended to ZLIB_VERSION. Version numbers
x.x.x.f are reserved for modifications to zlib by others than the zlib
maintainers. For example, if the version of the base zlib you are altering
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
update the version strings in deflate.c and inftrees.c.
For altered source distributions, you should also note the origin and
nature of the changes in zlib.h, as well as in ChangeLog and README, along
with the dates of the alterations. The origin should include at least your
name (or your company's name), and an email address to contact for help or
issues with the library.
Note that distributing a compiled zlib library along with zlib.h and
zconf.h is also a source distribution, and so you should change
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
in zlib.h as you would for a full source distribution.
25. Will zlib work on a big-endian or little-endian architecture, and can I
exchange compressed data between them?
Yes and yes.
26. Will zlib work on a 64-bit machine?
It should. It has been tested on 64-bit machines, and has no dependence
on any data types being limited to 32-bits in length. If you have any
difficulties, please provide a complete problem report to zlib@gzip.org
27. Will zlib decompress data from the PKWare Data Compression Library?
No. The PKWare DCL uses a completely different compressed data format
than does PKZIP and zlib. However, you can look in zlib's contrib/blast
directory for a possible solution to your problem.
28. Can I access data randomly in a compressed stream?
No, not without some preparation. If when compressing you periodically
use Z_FULL_FLUSH, carefully write all the pending data at those points,
and keep an index of those locations, then you can start decompression
at those points. You have to be careful to not use Z_FULL_FLUSH too
often, since it can significantly degrade compression.
29. Does zlib work on MVS, OS/390, CICS, etc.?
We don't know for sure. We have heard occasional reports of success on
these systems. If you do use it on one of these, please provide us with
a report, instructions, and patches that we can reference when we get
these questions. Thanks.
30. Is there some simpler, easier to read version of inflate I can look at
to understand the deflate format?
First off, you should read RFC 1951. Second, yes. Look in zlib's
contrib/puff directory.
31. Does zlib infringe on any patents?
As far as we know, no. In fact, that was originally the whole point behind
zlib. Look here for some more information:
http://www.gzip.org/#faq11
32. Can zlib work with greater than 4 GB of data?
Yes. inflate() and deflate() will process any amount of data correctly.
Each call of inflate() or deflate() is limited to input and output chunks
of the maximum value that can be stored in the compiler's "unsigned int"
type, but there is no limit to the number of chunks. Note however that the
strm.total_in and strm_total_out counters may be limited to 4 GB. These
counters are provided as a convenience and are not used internally by
inflate() or deflate(). The application can easily set up its own counters
updated after each call of inflate() or deflate() to count beyond 4 GB.
compress() and uncompress() may be limited to 4 GB, since they operate in a
single call. gzseek() and gztell() may be limited to 4 GB depending on how
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
The word "may" appears several times above since there is a 4 GB limit
only if the compiler's "long" type is 32 bits. If the compiler's "long"
type is 64 bits, then the limit is 16 exabytes.
33. Does zlib have any security vulnerabilities?
The only one that we are aware of is potentially in gzprintf(). If zlib
is compiled to use sprintf() or vsprintf(), then there is no protection
against a buffer overflow of a 4K string space, other than the caller of
gzprintf() assuring that the output will not exceed 4K. On the other
hand, if zlib is compiled to use snprintf() or vsnprintf(), which should
normally be the case, then there is no vulnerability. The ./configure
script will display warnings if an insecure variation of sprintf() will
be used by gzprintf(). Also the zlibCompileFlags() function will return
information on what variant of sprintf() is used by gzprintf().
If you don't have snprintf() or vsnprintf() and would like one, you can
find a portable implementation here:
http://www.ijs.si/software/snprintf/
Note that you should be using the most recent version of zlib. Versions
1.1.3 and before were subject to a double-free vulnerability.
34. Is there a Java version of zlib?
Probably what you want is to use zlib in Java. zlib is already included
as part of the Java SDK in the java.util.zip package. If you really want
a version of zlib written in the Java language, look on the zlib home
page for links: http://www.zlib.org/
35. I get this or that compiler or source-code scanner warning when I crank it
up to maximally-pedantic. Can't you guys write proper code?
Many years ago, we gave up attempting to avoid warnings on every compiler
in the universe. It just got to be a waste of time, and some compilers
were downright silly. So now, we simply make sure that the code always
works.
36. Valgrind (or some similar memory access checker) says that deflate is
performing a conditional jump that depends on an uninitialized value.
Isn't that a bug?
No. That is intentional for performance reasons, and the output of
deflate is not affected. This only started showing up recently since
zlib 1.2.x uses malloc() by default for allocations, whereas earlier
versions used calloc(), which zeros out the allocated memory.
37. Will zlib read the (insert any ancient or arcane format here) compressed
data format?
Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.
38. How can I encrypt/decrypt zip files with zlib?
zlib doesn't support encryption. The original PKZIP encryption is very weak
and can be broken with freely available programs. To get strong encryption,
use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
For PKZIP compatible "encryption", look at http://www.info-zip.org/
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
"gzip" is the gzip format, and "deflate" is the zlib format. They should
probably have called the second one "zlib" instead to avoid confusion
with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
correctly points to the zlib specification in RFC 1950 for the "deflate"
transfer encoding, there have been reports of servers and browsers that
incorrectly produce or expect raw deflate data per the deflate
specficiation in RFC 1951, most notably Microsoft. So even though the
"deflate" transfer encoding using the zlib format would be the more
efficient approach (and in fact exactly what the zlib format was designed
for), using the "gzip" transfer encoding is probably more reliable due to
an unfortunate choice of name on the part of the HTTP 1.1 authors.
Bottom line: use the gzip format for HTTP 1.1 encoding.
40. Does zlib support the new "Deflate64" format introduced by PKWare?
No. PKWare has apparently decided to keep that format proprietary, since
they have not documented it as they have previous compression formats.
In any case, the compression improvements are so modest compared to other
more modern approaches, that it's not worth the effort to implement.
41. Can you please sign these lengthy legal documents and fax them back to us
so that we can use your software in our product?
No. Go away. Shoo.
Frequently Asked Questions about zlib
If your question is not there, please check the zlib home page
http://www.zlib.org which may have more recent information.
The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
1. Is zlib Y2K-compliant?
Yes. zlib doesn't handle dates.
2. Where can I get a Windows DLL version?
The zlib sources can be compiled without change to produce a DLL.
See the file win32/DLL_FAQ.txt in the zlib distribution.
Pointers to the precompiled DLL are found in the zlib web site at
http://www.zlib.org.
3. Where can I get a Visual Basic interface to zlib?
See
* http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm
* contrib/visual-basic.txt in the zlib distribution
* win32/DLL_FAQ.txt in the zlib distribution
4. compress() returns Z_BUF_ERROR.
Make sure that before the call of compress, the length of the compressed
buffer is equal to the total size of the compressed buffer and not
zero. For Visual Basic, check that this parameter is passed by reference
("as any"), not by value ("as long").
5. deflate() or inflate() returns Z_BUF_ERROR.
Before making the call, make sure that avail_in and avail_out are not
zero. When setting the parameter flush equal to Z_FINISH, also make sure
that avail_out is big enough to allow processing all pending input.
Note that a Z_BUF_ERROR is not fatal--another call to deflate() or
inflate() can be made with more input or output space. A Z_BUF_ERROR
may in fact be unavoidable depending on how the functions are used, since
it is not possible to tell whether or not there is more output pending
when strm.avail_out returns with zero.
6. Where's the zlib documentation (man pages, etc.)?
It's in zlib.h for the moment, and Francis S. Lin has converted it to a
web page zlib.html. Volunteers to transform this to Unix-style man pages,
please contact us (zlib@gzip.org). Examples of zlib usage are in the files
example.c and minigzip.c.
7. Why don't you use GNU autoconf or libtool or ...?
Because we would like to keep zlib as a very small and simple
package. zlib is rather portable and doesn't need much configuration.
8. I found a bug in zlib.
Most of the time, such problems are due to an incorrect usage of
zlib. Please try to reproduce the problem with a small program and send
the corresponding source to us at zlib@gzip.org . Do not send
multi-megabyte data files without prior agreement.
9. Why do I get "undefined reference to gzputc"?
If "make test" produces something like
example.o(.text+0x154): undefined reference to `gzputc'
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
/usr/X11R6/lib. Remove any old versions, then do "make install".
10. I need a Delphi interface to zlib.
See the contrib/delphi directory in the zlib distribution.
11. Can zlib handle .zip archives?
Not by itself, no. See the directory contrib/minizip in the zlib
distribution.
12. Can zlib handle .Z files?
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
the code of uncompress on your own.
13. How can I make a Unix shared library?
make clean
./configure -s
make
14. How do I install a shared zlib library on Unix?
After the above, then:
make install
However, many flavors of Unix come with a shared zlib already installed.
Before going to the trouble of compiling a shared version of zlib and
trying to install it, you may want to check if it's already there! If you
can #include <zlib.h>, it's there. The -lz option will probably link to it.
15. I have a question about OttoPDF.
We are not the authors of OttoPDF. The real author is on the OttoPDF web
site: Joel Hainley, jhainley@myndkryme.com.
16. Can zlib decode Flate data in an Adobe PDF file?
Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ .
To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ .
17. Why am I getting this "register_frame_info not found" error on Solaris?
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
generates an error such as:
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
symbol __register_frame_info: referenced symbol not found
The symbol __register_frame_info is not part of zlib, it is generated by
the C compiler (cc or gcc). You must recompile applications using zlib
which have this problem. This problem is specific to Solaris. See
http://www.sunfreeware.com for Solaris versions of zlib and applications
using zlib.
18. Why does gzip give an error on a file I make with compress/deflate?
The compress and deflate functions produce data in the zlib format, which
is different and incompatible with the gzip format. The gz* functions in
zlib on the other hand use the gzip format. Both the zlib and gzip
formats use the same compressed data format internally, but have different
headers and trailers around the compressed data.
19. Ok, so why are there two different formats?
The gzip format was designed to retain the directory information about
a single file, such as the name and last modification date. The zlib
format on the other hand was designed for in-memory and communication
channel applications, and has a much more compact header and trailer and
uses a faster integrity check than gzip.
20. Well that's nice, but how do I make a gzip file in memory?
You can request that deflate write the gzip format instead of the zlib
format using deflateInit2(). You can also request that inflate decode
the gzip format using inflateInit2(). Read zlib.h for more details.
21. Is zlib thread-safe?
Yes. However any library routines that zlib uses and any application-
provided memory allocation routines must also be thread-safe. zlib's gz*
functions use stdio library routines, and most of zlib's functions use the
library memory allocation routines by default. zlib's Init functions allow
for the application to provide custom memory allocation routines.
Of course, you should only operate on any given zlib or gzip stream from a
single thread at a time.
22. Can I use zlib in my commercial application?
Yes. Please read the license in zlib.h.
23. Is zlib under the GNU license?
No. Please read the license in zlib.h.
24. The license says that altered source versions must be "plainly marked". So
what exactly do I need to do to meet that requirement?
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
particular, the final version number needs to be changed to "f", and an
identification string should be appended to ZLIB_VERSION. Version numbers
x.x.x.f are reserved for modifications to zlib by others than the zlib
maintainers. For example, if the version of the base zlib you are altering
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
update the version strings in deflate.c and inftrees.c.
For altered source distributions, you should also note the origin and
nature of the changes in zlib.h, as well as in ChangeLog and README, along
with the dates of the alterations. The origin should include at least your
name (or your company's name), and an email address to contact for help or
issues with the library.
Note that distributing a compiled zlib library along with zlib.h and
zconf.h is also a source distribution, and so you should change
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
in zlib.h as you would for a full source distribution.
25. Will zlib work on a big-endian or little-endian architecture, and can I
exchange compressed data between them?
Yes and yes.
26. Will zlib work on a 64-bit machine?
It should. It has been tested on 64-bit machines, and has no dependence
on any data types being limited to 32-bits in length. If you have any
difficulties, please provide a complete problem report to zlib@gzip.org
27. Will zlib decompress data from the PKWare Data Compression Library?
No. The PKWare DCL uses a completely different compressed data format
than does PKZIP and zlib. However, you can look in zlib's contrib/blast
directory for a possible solution to your problem.
28. Can I access data randomly in a compressed stream?
No, not without some preparation. If when compressing you periodically
use Z_FULL_FLUSH, carefully write all the pending data at those points,
and keep an index of those locations, then you can start decompression
at those points. You have to be careful to not use Z_FULL_FLUSH too
often, since it can significantly degrade compression.
29. Does zlib work on MVS, OS/390, CICS, etc.?
We don't know for sure. We have heard occasional reports of success on
these systems. If you do use it on one of these, please provide us with
a report, instructions, and patches that we can reference when we get
these questions. Thanks.
30. Is there some simpler, easier to read version of inflate I can look at
to understand the deflate format?
First off, you should read RFC 1951. Second, yes. Look in zlib's
contrib/puff directory.
31. Does zlib infringe on any patents?
As far as we know, no. In fact, that was originally the whole point behind
zlib. Look here for some more information:
http://www.gzip.org/#faq11
32. Can zlib work with greater than 4 GB of data?
Yes. inflate() and deflate() will process any amount of data correctly.
Each call of inflate() or deflate() is limited to input and output chunks
of the maximum value that can be stored in the compiler's "unsigned int"
type, but there is no limit to the number of chunks. Note however that the
strm.total_in and strm_total_out counters may be limited to 4 GB. These
counters are provided as a convenience and are not used internally by
inflate() or deflate(). The application can easily set up its own counters
updated after each call of inflate() or deflate() to count beyond 4 GB.
compress() and uncompress() may be limited to 4 GB, since they operate in a
single call. gzseek() and gztell() may be limited to 4 GB depending on how
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
The word "may" appears several times above since there is a 4 GB limit
only if the compiler's "long" type is 32 bits. If the compiler's "long"
type is 64 bits, then the limit is 16 exabytes.
33. Does zlib have any security vulnerabilities?
The only one that we are aware of is potentially in gzprintf(). If zlib
is compiled to use sprintf() or vsprintf(), then there is no protection
against a buffer overflow of a 4K string space, other than the caller of
gzprintf() assuring that the output will not exceed 4K. On the other
hand, if zlib is compiled to use snprintf() or vsnprintf(), which should
normally be the case, then there is no vulnerability. The ./configure
script will display warnings if an insecure variation of sprintf() will
be used by gzprintf(). Also the zlibCompileFlags() function will return
information on what variant of sprintf() is used by gzprintf().
If you don't have snprintf() or vsnprintf() and would like one, you can
find a portable implementation here:
http://www.ijs.si/software/snprintf/
Note that you should be using the most recent version of zlib. Versions
1.1.3 and before were subject to a double-free vulnerability.
34. Is there a Java version of zlib?
Probably what you want is to use zlib in Java. zlib is already included
as part of the Java SDK in the java.util.zip package. If you really want
a version of zlib written in the Java language, look on the zlib home
page for links: http://www.zlib.org/
35. I get this or that compiler or source-code scanner warning when I crank it
up to maximally-pedantic. Can't you guys write proper code?
Many years ago, we gave up attempting to avoid warnings on every compiler
in the universe. It just got to be a waste of time, and some compilers
were downright silly. So now, we simply make sure that the code always
works.
36. Valgrind (or some similar memory access checker) says that deflate is
performing a conditional jump that depends on an uninitialized value.
Isn't that a bug?
No. That is intentional for performance reasons, and the output of
deflate is not affected. This only started showing up recently since
zlib 1.2.x uses malloc() by default for allocations, whereas earlier
versions used calloc(), which zeros out the allocated memory.
37. Will zlib read the (insert any ancient or arcane format here) compressed
data format?
Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.
38. How can I encrypt/decrypt zip files with zlib?
zlib doesn't support encryption. The original PKZIP encryption is very weak
and can be broken with freely available programs. To get strong encryption,
use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
For PKZIP compatible "encryption", look at http://www.info-zip.org/
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
"gzip" is the gzip format, and "deflate" is the zlib format. They should
probably have called the second one "zlib" instead to avoid confusion
with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
correctly points to the zlib specification in RFC 1950 for the "deflate"
transfer encoding, there have been reports of servers and browsers that
incorrectly produce or expect raw deflate data per the deflate
specficiation in RFC 1951, most notably Microsoft. So even though the
"deflate" transfer encoding using the zlib format would be the more
efficient approach (and in fact exactly what the zlib format was designed
for), using the "gzip" transfer encoding is probably more reliable due to
an unfortunate choice of name on the part of the HTTP 1.1 authors.
Bottom line: use the gzip format for HTTP 1.1 encoding.
40. Does zlib support the new "Deflate64" format introduced by PKWare?
No. PKWare has apparently decided to keep that format proprietary, since
they have not documented it as they have previous compression formats.
In any case, the compression improvements are so modest compared to other
more modern approaches, that it's not worth the effort to implement.
41. Can you please sign these lengthy legal documents and fax them back to us
so that we can use your software in our product?
No. Go away. Shoo.

102
utils/zenutils/libraries/zlib123/zlib/INDEX Executable file → Normal file
View file

@ -1,51 +1,51 @@
ChangeLog history of changes
FAQ Frequently Asked Questions about zlib
INDEX this file
Makefile makefile for Unix (generated by configure)
Makefile.in makefile for Unix (template for configure)
README guess what
algorithm.txt description of the (de)compression algorithm
configure configure script for Unix
zconf.in.h template for zconf.h (used by configure)
amiga/ makefiles for Amiga SAS C
as400/ makefiles for IBM AS/400
msdos/ makefiles for MSDOS
old/ makefiles for various architectures and zlib documentation
files that have not yet been updated for zlib 1.2.x
projects/ projects for various Integrated Development Environments
qnx/ makefiles for QNX
win32/ makefiles for Windows
zlib public header files (must be kept):
zconf.h
zlib.h
private source files used to build the zlib library:
adler32.c
compress.c
crc32.c
crc32.h
deflate.c
deflate.h
gzio.c
infback.c
inffast.c
inffast.h
inffixed.h
inflate.c
inflate.h
inftrees.c
inftrees.h
trees.c
trees.h
uncompr.c
zutil.c
zutil.h
source files for sample programs:
example.c
minigzip.c
unsupported contribution by third parties
See contrib/README.contrib
ChangeLog history of changes
FAQ Frequently Asked Questions about zlib
INDEX this file
Makefile makefile for Unix (generated by configure)
Makefile.in makefile for Unix (template for configure)
README guess what
algorithm.txt description of the (de)compression algorithm
configure configure script for Unix
zconf.in.h template for zconf.h (used by configure)
amiga/ makefiles for Amiga SAS C
as400/ makefiles for IBM AS/400
msdos/ makefiles for MSDOS
old/ makefiles for various architectures and zlib documentation
files that have not yet been updated for zlib 1.2.x
projects/ projects for various Integrated Development Environments
qnx/ makefiles for QNX
win32/ makefiles for Windows
zlib public header files (must be kept):
zconf.h
zlib.h
private source files used to build the zlib library:
adler32.c
compress.c
crc32.c
crc32.h
deflate.c
deflate.h
gzio.c
infback.c
inffast.c
inffast.h
inffixed.h
inflate.c
inflate.h
inftrees.c
inftrees.h
trees.c
trees.h
uncompr.c
zutil.c
zutil.h
source files for sample programs:
example.c
minigzip.c
unsupported contribution by third parties
See contrib/README.contrib

308
utils/zenutils/libraries/zlib123/zlib/Makefile Executable file → Normal file
View file

@ -1,154 +1,154 @@
# Makefile for zlib
# Copyright (C) 1995-2005 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
# ./configure; make test
# The call of configure is optional if you don't have special requirements
# If you wish to build zlib as a shared library, use: ./configure -s
# To use the asm code, type:
# cp contrib/asm?86/match.S ./match.S
# make LOC=-DASMV OBJA=match.o
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
# make install
# To install in $HOME instead of /usr/local, use:
# make install prefix=$HOME
CC=cc
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
LDFLAGS=libz.a
LDSHARED=$(CC)
CPP=$(CC) -E
LIBS=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.3
SHAREDLIBM=libz.so.1
AR=ar rc
RANLIB=ranlib
TAR=tar
SHELL=/bin/sh
EXE=
prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infback.o inftrees.o inffast.o
OBJA =
# to use the asm code: make OBJA=match.o
TEST_OBJS = example.o minigzip.o
all: example$(EXE) minigzip$(EXE)
check: test
test: all
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
echo hello world | ./minigzip | ./minigzip -d || \
echo ' *** minigzip test FAILED ***' ; \
if ./example; then \
echo ' *** zlib test OK ***'; \
else \
echo ' *** zlib test FAILED ***'; \
fi
libz.a: $(OBJS) $(OBJA)
$(AR) $@ $(OBJS) $(OBJA)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s
$(SHAREDLIBV): $(OBJS)
$(LDSHARED) -o $@ $(OBJS)
rm -f $(SHAREDLIB) $(SHAREDLIBM)
ln -s $@ $(SHAREDLIB)
ln -s $@ $(SHAREDLIBM)
example$(EXE): example.o $(LIBS)
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
minigzip$(EXE): minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
install: $(LIBS)
-@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
-@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
-@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
cp zlib.h zconf.h $(includedir)
chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
cp $(LIBS) $(libdir)
cd $(libdir); chmod 755 $(LIBS)
-@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
cd $(libdir); if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIB) $(SHAREDLIBM); \
ln -s $(SHAREDLIBV) $(SHAREDLIB); \
ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
(ldconfig || true) >/dev/null 2>&1; \
fi
cp zlib.3 $(man3dir)
chmod 644 $(man3dir)/zlib.3
# The ranlib in install is needed on NeXTSTEP which checks file times
# ldconfig is for Linux
uninstall:
cd $(includedir); \
cd $(libdir); rm -f libz.a; \
if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
fi
cd $(man3dir); rm -f zlib.3
mostlyclean: clean
clean:
rm -f *.o *~ example$(EXE) minigzip$(EXE) \
libz.* foo.gz so_locations \
_match.s maketree contrib/infback9/*.o
maintainer-clean: distclean
distclean: clean
cp -p Makefile.in Makefile
cp -p zconf.in.h zconf.h
rm -f .DS_Store
tags:
etags *.[ch]
depend:
makedepend -- $(CFLAGS) -- *.[ch]
# DO NOT DELETE THIS LINE -- make depend depends on it.
adler32.o: zlib.h zconf.h
compress.o: zlib.h zconf.h
crc32.o: crc32.h zlib.h zconf.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
example.o: zlib.h zconf.h
gzio.o: zutil.h zlib.h zconf.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
minigzip.o: zlib.h zconf.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
zutil.o: zutil.h zlib.h zconf.h
# Makefile for zlib
# Copyright (C) 1995-2005 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
# ./configure; make test
# The call of configure is optional if you don't have special requirements
# If you wish to build zlib as a shared library, use: ./configure -s
# To use the asm code, type:
# cp contrib/asm?86/match.S ./match.S
# make LOC=-DASMV OBJA=match.o
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
# make install
# To install in $HOME instead of /usr/local, use:
# make install prefix=$HOME
CC=cc
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
LDFLAGS=libz.a
LDSHARED=$(CC)
CPP=$(CC) -E
LIBS=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.3
SHAREDLIBM=libz.so.1
AR=ar rc
RANLIB=ranlib
TAR=tar
SHELL=/bin/sh
EXE=
prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infback.o inftrees.o inffast.o
OBJA =
# to use the asm code: make OBJA=match.o
TEST_OBJS = example.o minigzip.o
all: example$(EXE) minigzip$(EXE)
check: test
test: all
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
echo hello world | ./minigzip | ./minigzip -d || \
echo ' *** minigzip test FAILED ***' ; \
if ./example; then \
echo ' *** zlib test OK ***'; \
else \
echo ' *** zlib test FAILED ***'; \
fi
libz.a: $(OBJS) $(OBJA)
$(AR) $@ $(OBJS) $(OBJA)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s
$(SHAREDLIBV): $(OBJS)
$(LDSHARED) -o $@ $(OBJS)
rm -f $(SHAREDLIB) $(SHAREDLIBM)
ln -s $@ $(SHAREDLIB)
ln -s $@ $(SHAREDLIBM)
example$(EXE): example.o $(LIBS)
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
minigzip$(EXE): minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
install: $(LIBS)
-@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
-@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
-@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
cp zlib.h zconf.h $(includedir)
chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
cp $(LIBS) $(libdir)
cd $(libdir); chmod 755 $(LIBS)
-@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
cd $(libdir); if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIB) $(SHAREDLIBM); \
ln -s $(SHAREDLIBV) $(SHAREDLIB); \
ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
(ldconfig || true) >/dev/null 2>&1; \
fi
cp zlib.3 $(man3dir)
chmod 644 $(man3dir)/zlib.3
# The ranlib in install is needed on NeXTSTEP which checks file times
# ldconfig is for Linux
uninstall:
cd $(includedir); \
cd $(libdir); rm -f libz.a; \
if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
fi
cd $(man3dir); rm -f zlib.3
mostlyclean: clean
clean:
rm -f *.o *~ example$(EXE) minigzip$(EXE) \
libz.* foo.gz so_locations \
_match.s maketree contrib/infback9/*.o
maintainer-clean: distclean
distclean: clean
cp -p Makefile.in Makefile
cp -p zconf.in.h zconf.h
rm -f .DS_Store
tags:
etags *.[ch]
depend:
makedepend -- $(CFLAGS) -- *.[ch]
# DO NOT DELETE THIS LINE -- make depend depends on it.
adler32.o: zlib.h zconf.h
compress.o: zlib.h zconf.h
crc32.o: crc32.h zlib.h zconf.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
example.o: zlib.h zconf.h
gzio.o: zutil.h zlib.h zconf.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
minigzip.o: zlib.h zconf.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
zutil.o: zutil.h zlib.h zconf.h

308
utils/zenutils/libraries/zlib123/zlib/Makefile.in Executable file → Normal file
View file

@ -1,154 +1,154 @@
# Makefile for zlib
# Copyright (C) 1995-2005 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
# ./configure; make test
# The call of configure is optional if you don't have special requirements
# If you wish to build zlib as a shared library, use: ./configure -s
# To use the asm code, type:
# cp contrib/asm?86/match.S ./match.S
# make LOC=-DASMV OBJA=match.o
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
# make install
# To install in $HOME instead of /usr/local, use:
# make install prefix=$HOME
CC=cc
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
LDFLAGS=libz.a
LDSHARED=$(CC)
CPP=$(CC) -E
LIBS=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.3
SHAREDLIBM=libz.so.1
AR=ar rc
RANLIB=ranlib
TAR=tar
SHELL=/bin/sh
EXE=
prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infback.o inftrees.o inffast.o
OBJA =
# to use the asm code: make OBJA=match.o
TEST_OBJS = example.o minigzip.o
all: example$(EXE) minigzip$(EXE)
check: test
test: all
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
echo hello world | ./minigzip | ./minigzip -d || \
echo ' *** minigzip test FAILED ***' ; \
if ./example; then \
echo ' *** zlib test OK ***'; \
else \
echo ' *** zlib test FAILED ***'; \
fi
libz.a: $(OBJS) $(OBJA)
$(AR) $@ $(OBJS) $(OBJA)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s
$(SHAREDLIBV): $(OBJS)
$(LDSHARED) -o $@ $(OBJS)
rm -f $(SHAREDLIB) $(SHAREDLIBM)
ln -s $@ $(SHAREDLIB)
ln -s $@ $(SHAREDLIBM)
example$(EXE): example.o $(LIBS)
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
minigzip$(EXE): minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
install: $(LIBS)
-@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
-@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
-@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
cp zlib.h zconf.h $(includedir)
chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
cp $(LIBS) $(libdir)
cd $(libdir); chmod 755 $(LIBS)
-@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
cd $(libdir); if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIB) $(SHAREDLIBM); \
ln -s $(SHAREDLIBV) $(SHAREDLIB); \
ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
(ldconfig || true) >/dev/null 2>&1; \
fi
cp zlib.3 $(man3dir)
chmod 644 $(man3dir)/zlib.3
# The ranlib in install is needed on NeXTSTEP which checks file times
# ldconfig is for Linux
uninstall:
cd $(includedir); \
cd $(libdir); rm -f libz.a; \
if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
fi
cd $(man3dir); rm -f zlib.3
mostlyclean: clean
clean:
rm -f *.o *~ example$(EXE) minigzip$(EXE) \
libz.* foo.gz so_locations \
_match.s maketree contrib/infback9/*.o
maintainer-clean: distclean
distclean: clean
cp -p Makefile.in Makefile
cp -p zconf.in.h zconf.h
rm -f .DS_Store
tags:
etags *.[ch]
depend:
makedepend -- $(CFLAGS) -- *.[ch]
# DO NOT DELETE THIS LINE -- make depend depends on it.
adler32.o: zlib.h zconf.h
compress.o: zlib.h zconf.h
crc32.o: crc32.h zlib.h zconf.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
example.o: zlib.h zconf.h
gzio.o: zutil.h zlib.h zconf.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
minigzip.o: zlib.h zconf.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
zutil.o: zutil.h zlib.h zconf.h
# Makefile for zlib
# Copyright (C) 1995-2005 Jean-loup Gailly.
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
# ./configure; make test
# The call of configure is optional if you don't have special requirements
# If you wish to build zlib as a shared library, use: ./configure -s
# To use the asm code, type:
# cp contrib/asm?86/match.S ./match.S
# make LOC=-DASMV OBJA=match.o
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
# make install
# To install in $HOME instead of /usr/local, use:
# make install prefix=$HOME
CC=cc
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
# -Wstrict-prototypes -Wmissing-prototypes
LDFLAGS=libz.a
LDSHARED=$(CC)
CPP=$(CC) -E
LIBS=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.3
SHAREDLIBM=libz.so.1
AR=ar rc
RANLIB=ranlib
TAR=tar
SHELL=/bin/sh
EXE=
prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
includedir = ${prefix}/include
mandir = ${prefix}/share/man
man3dir = ${mandir}/man3
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
zutil.o inflate.o infback.o inftrees.o inffast.o
OBJA =
# to use the asm code: make OBJA=match.o
TEST_OBJS = example.o minigzip.o
all: example$(EXE) minigzip$(EXE)
check: test
test: all
@LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \
echo hello world | ./minigzip | ./minigzip -d || \
echo ' *** minigzip test FAILED ***' ; \
if ./example; then \
echo ' *** zlib test OK ***'; \
else \
echo ' *** zlib test FAILED ***'; \
fi
libz.a: $(OBJS) $(OBJA)
$(AR) $@ $(OBJS) $(OBJA)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
match.o: match.S
$(CPP) match.S > _match.s
$(CC) -c _match.s
mv _match.o match.o
rm -f _match.s
$(SHAREDLIBV): $(OBJS)
$(LDSHARED) -o $@ $(OBJS)
rm -f $(SHAREDLIB) $(SHAREDLIBM)
ln -s $@ $(SHAREDLIB)
ln -s $@ $(SHAREDLIBM)
example$(EXE): example.o $(LIBS)
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
minigzip$(EXE): minigzip.o $(LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
install: $(LIBS)
-@if [ ! -d $(exec_prefix) ]; then mkdir -p $(exec_prefix); fi
-@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
-@if [ ! -d $(man3dir) ]; then mkdir -p $(man3dir); fi
cp zlib.h zconf.h $(includedir)
chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h
cp $(LIBS) $(libdir)
cd $(libdir); chmod 755 $(LIBS)
-@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1
cd $(libdir); if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIB) $(SHAREDLIBM); \
ln -s $(SHAREDLIBV) $(SHAREDLIB); \
ln -s $(SHAREDLIBV) $(SHAREDLIBM); \
(ldconfig || true) >/dev/null 2>&1; \
fi
cp zlib.3 $(man3dir)
chmod 644 $(man3dir)/zlib.3
# The ranlib in install is needed on NeXTSTEP which checks file times
# ldconfig is for Linux
uninstall:
cd $(includedir); \
cd $(libdir); rm -f libz.a; \
if test -f $(SHAREDLIBV); then \
rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \
fi
cd $(man3dir); rm -f zlib.3
mostlyclean: clean
clean:
rm -f *.o *~ example$(EXE) minigzip$(EXE) \
libz.* foo.gz so_locations \
_match.s maketree contrib/infback9/*.o
maintainer-clean: distclean
distclean: clean
cp -p Makefile.in Makefile
cp -p zconf.in.h zconf.h
rm -f .DS_Store
tags:
etags *.[ch]
depend:
makedepend -- $(CFLAGS) -- *.[ch]
# DO NOT DELETE THIS LINE -- make depend depends on it.
adler32.o: zlib.h zconf.h
compress.o: zlib.h zconf.h
crc32.o: crc32.h zlib.h zconf.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
example.o: zlib.h zconf.h
gzio.o: zutil.h zlib.h zconf.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
minigzip.o: zlib.h zconf.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
uncompr.o: zlib.h zconf.h
zutil.o: zutil.h zlib.h zconf.h

250
utils/zenutils/libraries/zlib123/zlib/README Executable file → Normal file
View file

@ -1,125 +1,125 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.3 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
and rfc1952.txt (gzip format). These documents are also available in other
formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
of the library is given in the file example.c which also tests that the library
is working correctly. Another example is given in the file minigzip.c. The
compression library itself is composed of all source files except example.c and
minigzip.c.
To compile all files and run the test program, follow the instructions given at
the top of Makefile. In short "make test; make install" should work for most
machines. For Unix: "./configure; make test; make install". For MSDOS, use one
of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
<info@winimage.com> for the Windows DLL version. The zlib home page is
http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
please check this site to verify that you have the latest version of zlib;
otherwise get the latest version and check whether the problem still exists or
not.
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.2.3 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib".
A Java implementation of zlib is available in the Java Development Kit
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
See the zlib home page http://www.zlib.org for details.
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
CPAN (Comprehensive Perl Archive Network) sites
http://www.cpan.org/modules/by-module/Compress/
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
http://www.python.org/doc/lib/module-zlib.html
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
An experimental package to read and write files in .zip format, written on top
of zlib by Gilles Vollant <info@winimage.com>, is available in the
contrib/minizip directory of zlib.
Notes for some targets:
- For Windows DLL versions, please see win32/DLL_FAQ.txt
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
compiler flag). The compiler bug has been reported to SGI.
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
when compiled with cc.
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
other compilers. Use "make test" to check your compiler.
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
- For PalmOs, see http://palmzlib.sourceforge.net/
- When building a shared, i.e. dynamic library on Mac OS X, the library must be
installed before testing (do "make install" before "make test"), since the
library location is specified in the library.
Acknowledgments:
The deflate format used by zlib was defined by Phil Katz. The deflate
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib;
they are too numerous to cite here.
Copyright notice:
(C) 1995-2004 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
If you use the zlib library in a product, we would appreciate *not*
receiving lengthy legal documents to sign. The sources are provided
for free but without warranty of any kind. The library has been
entirely written by Jean-loup Gailly and Mark Adler; it does not
include third-party code.
If you redistribute modified sources, we would appreciate that you include
in the file ChangeLog history information documenting your changes. Please
read the FAQ for more information on the distribution of modified source
versions.
ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.3 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
and rfc1952.txt (gzip format). These documents are also available in other
formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
of the library is given in the file example.c which also tests that the library
is working correctly. Another example is given in the file minigzip.c. The
compression library itself is composed of all source files except example.c and
minigzip.c.
To compile all files and run the test program, follow the instructions given at
the top of Makefile. In short "make test; make install" should work for most
machines. For Unix: "./configure; make test; make install". For MSDOS, use one
of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
<info@winimage.com> for the Windows DLL version. The zlib home page is
http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
please check this site to verify that you have the latest version of zlib;
otherwise get the latest version and check whether the problem still exists or
not.
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.2.3 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib".
A Java implementation of zlib is available in the Java Development Kit
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
See the zlib home page http://www.zlib.org for details.
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
CPAN (Comprehensive Perl Archive Network) sites
http://www.cpan.org/modules/by-module/Compress/
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
http://www.python.org/doc/lib/module-zlib.html
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
An experimental package to read and write files in .zip format, written on top
of zlib by Gilles Vollant <info@winimage.com>, is available in the
contrib/minizip directory of zlib.
Notes for some targets:
- For Windows DLL versions, please see win32/DLL_FAQ.txt
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
compiler flag). The compiler bug has been reported to SGI.
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
when compiled with cc.
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
other compilers. Use "make test" to check your compiler.
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
- For PalmOs, see http://palmzlib.sourceforge.net/
- When building a shared, i.e. dynamic library on Mac OS X, the library must be
installed before testing (do "make install" before "make test"), since the
library location is specified in the library.
Acknowledgments:
The deflate format used by zlib was defined by Phil Katz. The deflate
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib;
they are too numerous to cite here.
Copyright notice:
(C) 1995-2004 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
If you use the zlib library in a product, we would appreciate *not*
receiving lengthy legal documents to sign. The sources are provided
for free but without warranty of any kind. The library has been
entirely written by Jean-loup Gailly and Mark Adler; it does not
include third-party code.
If you redistribute modified sources, we would appreciate that you include
in the file ChangeLog history information documenting your changes. Please
read the FAQ for more information on the distribution of modified source
versions.

298
utils/zenutils/libraries/zlib123/zlib/adler32.c Executable file → Normal file
View file

@ -1,149 +1,149 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
#define BASE 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
/* use NO_DIVIDE if your processor does not do division in hardware */
#ifdef NO_DIVIDE
# define MOD(a) \
do { \
if (a >= (BASE << 16)) a -= (BASE << 16); \
if (a >= (BASE << 15)) a -= (BASE << 15); \
if (a >= (BASE << 14)) a -= (BASE << 14); \
if (a >= (BASE << 13)) a -= (BASE << 13); \
if (a >= (BASE << 12)) a -= (BASE << 12); \
if (a >= (BASE << 11)) a -= (BASE << 11); \
if (a >= (BASE << 10)) a -= (BASE << 10); \
if (a >= (BASE << 9)) a -= (BASE << 9); \
if (a >= (BASE << 8)) a -= (BASE << 8); \
if (a >= (BASE << 7)) a -= (BASE << 7); \
if (a >= (BASE << 6)) a -= (BASE << 6); \
if (a >= (BASE << 5)) a -= (BASE << 5); \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
# define MOD4(a) \
do { \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
#else
# define MOD(a) a %= BASE
# define MOD4(a) a %= BASE
#endif
/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
const Bytef *buf;
uInt len;
{
unsigned long sum2;
unsigned n;
/* split Adler-32 into component sums */
sum2 = (adler >> 16) & 0xffff;
adler &= 0xffff;
/* in case user likes doing a byte at a time, keep it fast */
if (len == 1) {
adler += buf[0];
if (adler >= BASE)
adler -= BASE;
sum2 += adler;
if (sum2 >= BASE)
sum2 -= BASE;
return adler | (sum2 << 16);
}
/* initial Adler-32 value (deferred check for len == 1 speed) */
if (buf == Z_NULL)
return 1L;
/* in case short lengths are provided, keep it somewhat fast */
if (len < 16) {
while (len--) {
adler += *buf++;
sum2 += adler;
}
if (adler >= BASE)
adler -= BASE;
MOD4(sum2); /* only added so many BASE's */
return adler | (sum2 << 16);
}
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
n = NMAX / 16; /* NMAX is divisible by 16 */
do {
DO16(buf); /* 16 sums unrolled */
buf += 16;
} while (--n);
MOD(adler);
MOD(sum2);
}
/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
}
while (len--) {
adler += *buf++;
sum2 += adler;
}
MOD(adler);
MOD(sum2);
}
/* return recombined sums */
return adler | (sum2 << 16);
}
/* ========================================================================= */
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off_t len2;
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;
/* the derivation of this formula is left as an exercise for the reader */
rem = (unsigned)(len2 % BASE);
sum1 = adler1 & 0xffff;
sum2 = rem * sum1;
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 > BASE) sum1 -= BASE;
if (sum1 > BASE) sum1 -= BASE;
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
if (sum2 > BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
/* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
#define BASE 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
/* use NO_DIVIDE if your processor does not do division in hardware */
#ifdef NO_DIVIDE
# define MOD(a) \
do { \
if (a >= (BASE << 16)) a -= (BASE << 16); \
if (a >= (BASE << 15)) a -= (BASE << 15); \
if (a >= (BASE << 14)) a -= (BASE << 14); \
if (a >= (BASE << 13)) a -= (BASE << 13); \
if (a >= (BASE << 12)) a -= (BASE << 12); \
if (a >= (BASE << 11)) a -= (BASE << 11); \
if (a >= (BASE << 10)) a -= (BASE << 10); \
if (a >= (BASE << 9)) a -= (BASE << 9); \
if (a >= (BASE << 8)) a -= (BASE << 8); \
if (a >= (BASE << 7)) a -= (BASE << 7); \
if (a >= (BASE << 6)) a -= (BASE << 6); \
if (a >= (BASE << 5)) a -= (BASE << 5); \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
# define MOD4(a) \
do { \
if (a >= (BASE << 4)) a -= (BASE << 4); \
if (a >= (BASE << 3)) a -= (BASE << 3); \
if (a >= (BASE << 2)) a -= (BASE << 2); \
if (a >= (BASE << 1)) a -= (BASE << 1); \
if (a >= BASE) a -= BASE; \
} while (0)
#else
# define MOD(a) a %= BASE
# define MOD4(a) a %= BASE
#endif
/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len)
uLong adler;
const Bytef *buf;
uInt len;
{
unsigned long sum2;
unsigned n;
/* split Adler-32 into component sums */
sum2 = (adler >> 16) & 0xffff;
adler &= 0xffff;
/* in case user likes doing a byte at a time, keep it fast */
if (len == 1) {
adler += buf[0];
if (adler >= BASE)
adler -= BASE;
sum2 += adler;
if (sum2 >= BASE)
sum2 -= BASE;
return adler | (sum2 << 16);
}
/* initial Adler-32 value (deferred check for len == 1 speed) */
if (buf == Z_NULL)
return 1L;
/* in case short lengths are provided, keep it somewhat fast */
if (len < 16) {
while (len--) {
adler += *buf++;
sum2 += adler;
}
if (adler >= BASE)
adler -= BASE;
MOD4(sum2); /* only added so many BASE's */
return adler | (sum2 << 16);
}
/* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) {
len -= NMAX;
n = NMAX / 16; /* NMAX is divisible by 16 */
do {
DO16(buf); /* 16 sums unrolled */
buf += 16;
} while (--n);
MOD(adler);
MOD(sum2);
}
/* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */
while (len >= 16) {
len -= 16;
DO16(buf);
buf += 16;
}
while (len--) {
adler += *buf++;
sum2 += adler;
}
MOD(adler);
MOD(sum2);
}
/* return recombined sums */
return adler | (sum2 << 16);
}
/* ========================================================================= */
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off_t len2;
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;
/* the derivation of this formula is left as an exercise for the reader */
rem = (unsigned)(len2 % BASE);
sum1 = adler1 & 0xffff;
sum2 = rem * sum1;
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 > BASE) sum1 -= BASE;
if (sum1 > BASE) sum1 -= BASE;
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
if (sum2 > BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}

418
utils/zenutils/libraries/zlib123/zlib/algorithm.txt Executable file → Normal file
View file

@ -1,209 +1,209 @@
1. Compression algorithm (deflate)
The deflation algorithm used by gzip (also zip and zlib) is a variation of
LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in
the input data. The second occurrence of a string is replaced by a
pointer to the previous string, in the form of a pair (distance,
length). Distances are limited to 32K bytes, and lengths are limited
to 258 bytes. When a string does not occur anywhere in the previous
32K bytes, it is emitted as a sequence of literal bytes. (In this
description, `string' must be taken as an arbitrary sequence of bytes,
and is not restricted to printable characters.)
Literals or match lengths are compressed with one Huffman tree, and
match distances are compressed with another tree. The trees are stored
in a compact form at the start of each block. The blocks can have any
size (except that the compressed data for one block must fit in
available memory). A block is terminated when deflate() determines that
it would be useful to start another block with fresh trees. (This is
somewhat similar to the behavior of LZW-based _compress_.)
Duplicated strings are found using a hash table. All input strings of
length 3 are inserted in the hash table. A hash index is computed for
the next 3 bytes. If the hash chain for this index is not empty, all
strings in the chain are compared with the current input string, and
the longest match is selected.
The hash chains are searched starting with the most recent strings, to
favor small distances and thus take advantage of the Huffman encoding.
The hash chains are singly linked. There are no deletions from the
hash chains, the algorithm simply discards matches that are too old.
To avoid a worst-case situation, very long hash chains are arbitrarily
truncated at a certain length, determined by a runtime option (level
parameter of deflateInit). So deflate() does not always find the longest
possible match but generally finds a match which is long enough.
deflate() also defers the selection of matches with a lazy evaluation
mechanism. After a match of length N has been found, deflate() searches for
a longer match at the next input byte. If a longer match is found, the
previous match is truncated to a length of one (thus producing a single
literal byte) and the process of lazy evaluation begins again. Otherwise,
the original match is kept, and the next match search is attempted only N
steps later.
The lazy match evaluation is also subject to a runtime parameter. If
the current match is long enough, deflate() reduces the search for a longer
match, thus speeding up the whole process. If compression ratio is more
important than speed, deflate() attempts a complete second search even if
the first match is already long enough.
The lazy match evaluation is not performed for the fastest compression
modes (level parameter 1 to 3). For these fast modes, new strings
are inserted in the hash table only when no match was found, or
when the match is not too long. This degrades the compression ratio
but saves time since there are both fewer insertions and fewer searches.
2. Decompression algorithm (inflate)
2.1 Introduction
The key question is how to represent a Huffman code (or any prefix code) so
that you can decode fast. The most important characteristic is that shorter
codes are much more common than longer codes, so pay attention to decoding the
short codes fast, and let the long codes take longer to decode.
inflate() sets up a first level table that covers some number of bits of
input less than the length of longest code. It gets that many bits from the
stream, and looks it up in the table. The table will tell if the next
code is that many bits or less and how many, and if it is, it will tell
the value, else it will point to the next level table for which inflate()
grabs more bits and tries to decode a longer code.
How many bits to make the first lookup is a tradeoff between the time it
takes to decode and the time it takes to build the table. If building the
table took no time (and if you had infinite memory), then there would only
be a first level table to cover all the way to the longest code. However,
building the table ends up taking a lot longer for more bits since short
codes are replicated many times in such a table. What inflate() does is
simply to make the number of bits in the first table a variable, and then
to set that variable for the maximum speed.
For inflate, which has 286 possible codes for the literal/length tree, the size
of the first table is nine bits. Also the distance trees have 30 possible
values, and the size of the first table is six bits. Note that for each of
those cases, the table ended up one bit longer than the ``average'' code
length, i.e. the code length of an approximately flat code which would be a
little more than eight bits for 286 symbols and a little less than five bits
for 30 symbols.
2.2 More details on the inflate table lookup
Ok, you want to know what this cleverly obfuscated inflate tree actually
looks like. You are correct that it's not a Huffman tree. It is simply a
lookup table for the first, let's say, nine bits of a Huffman symbol. The
symbol could be as short as one bit or as long as 15 bits. If a particular
symbol is shorter than nine bits, then that symbol's translation is duplicated
in all those entries that start with that symbol's bits. For example, if the
symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a
symbol is nine bits long, it appears in the table once.
If the symbol is longer than nine bits, then that entry in the table points
to another similar table for the remaining bits. Again, there are duplicated
entries as needed. The idea is that most of the time the symbol will be short
and there will only be one table look up. (That's whole idea behind data
compression in the first place.) For the less frequent long symbols, there
will be two lookups. If you had a compression method with really long
symbols, you could have as many levels of lookups as is efficient. For
inflate, two is enough.
So a table entry either points to another table (in which case nine bits in
the above example are gobbled), or it contains the translation for the symbol
and the number of bits to gobble. Then you start again with the next
ungobbled bit.
You may wonder: why not just have one lookup table for how ever many bits the
longest symbol is? The reason is that if you do that, you end up spending
more time filling in duplicate symbol entries than you do actually decoding.
At least for deflate's output that generates new trees every several 10's of
kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code
would take too long if you're only decoding several thousand symbols. At the
other extreme, you could make a new table for every bit in the code. In fact,
that's essentially a Huffman tree. But then you spend two much time
traversing the tree while decoding, even for short symbols.
So the number of bits for the first lookup table is a trade of the time to
fill out the table vs. the time spent looking at the second level and above of
the table.
Here is an example, scaled down:
The code being decoded, with 10 symbols, from 1 to 6 bits long:
A: 0
B: 10
C: 1100
D: 11010
E: 11011
F: 11100
G: 11101
H: 11110
I: 111110
J: 111111
Let's make the first table three bits long (eight entries):
000: A,1
001: A,1
010: A,1
011: A,1
100: B,2
101: B,2
110: -> table X (gobble 3 bits)
111: -> table Y (gobble 3 bits)
Each entry is what the bits decode as and how many bits that is, i.e. how
many bits to gobble. Or the entry points to another table, with the number of
bits to gobble implicit in the size of the table.
Table X is two bits long since the longest code starting with 110 is five bits
long:
00: C,1
01: C,1
10: D,2
11: E,2
Table Y is three bits long since the longest code starting with 111 is six
bits long:
000: F,2
001: F,2
010: G,2
011: G,2
100: H,2
101: H,2
110: I,3
111: J,3
So what we have here are three tables with a total of 20 entries that had to
be constructed. That's compared to 64 entries for a single table. Or
compared to 16 entries for a Huffman tree (six two entry tables and one four
entry table). Assuming that the code ideally represents the probability of
the symbols, it takes on the average 1.25 lookups per symbol. That's compared
to one lookup for the single table, or 1.66 lookups per symbol for the
Huffman tree.
There, I think that gives you a picture of what's going on. For inflate, the
meaning of a particular symbol is often more than just a letter. It can be a
byte (a "literal"), or it can be either a length or a distance which
indicates a base value and a number of bits to fetch after the code that is
added to the base value. Or it might be the special end-of-block code. The
data structures created in inftrees.c try to encode all that information
compactly in the tables.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
References:
[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data
Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
pp. 337-343.
``DEFLATE Compressed Data Format Specification'' available in
http://www.ietf.org/rfc/rfc1951.txt
1. Compression algorithm (deflate)
The deflation algorithm used by gzip (also zip and zlib) is a variation of
LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in
the input data. The second occurrence of a string is replaced by a
pointer to the previous string, in the form of a pair (distance,
length). Distances are limited to 32K bytes, and lengths are limited
to 258 bytes. When a string does not occur anywhere in the previous
32K bytes, it is emitted as a sequence of literal bytes. (In this
description, `string' must be taken as an arbitrary sequence of bytes,
and is not restricted to printable characters.)
Literals or match lengths are compressed with one Huffman tree, and
match distances are compressed with another tree. The trees are stored
in a compact form at the start of each block. The blocks can have any
size (except that the compressed data for one block must fit in
available memory). A block is terminated when deflate() determines that
it would be useful to start another block with fresh trees. (This is
somewhat similar to the behavior of LZW-based _compress_.)
Duplicated strings are found using a hash table. All input strings of
length 3 are inserted in the hash table. A hash index is computed for
the next 3 bytes. If the hash chain for this index is not empty, all
strings in the chain are compared with the current input string, and
the longest match is selected.
The hash chains are searched starting with the most recent strings, to
favor small distances and thus take advantage of the Huffman encoding.
The hash chains are singly linked. There are no deletions from the
hash chains, the algorithm simply discards matches that are too old.
To avoid a worst-case situation, very long hash chains are arbitrarily
truncated at a certain length, determined by a runtime option (level
parameter of deflateInit). So deflate() does not always find the longest
possible match but generally finds a match which is long enough.
deflate() also defers the selection of matches with a lazy evaluation
mechanism. After a match of length N has been found, deflate() searches for
a longer match at the next input byte. If a longer match is found, the
previous match is truncated to a length of one (thus producing a single
literal byte) and the process of lazy evaluation begins again. Otherwise,
the original match is kept, and the next match search is attempted only N
steps later.
The lazy match evaluation is also subject to a runtime parameter. If
the current match is long enough, deflate() reduces the search for a longer
match, thus speeding up the whole process. If compression ratio is more
important than speed, deflate() attempts a complete second search even if
the first match is already long enough.
The lazy match evaluation is not performed for the fastest compression
modes (level parameter 1 to 3). For these fast modes, new strings
are inserted in the hash table only when no match was found, or
when the match is not too long. This degrades the compression ratio
but saves time since there are both fewer insertions and fewer searches.
2. Decompression algorithm (inflate)
2.1 Introduction
The key question is how to represent a Huffman code (or any prefix code) so
that you can decode fast. The most important characteristic is that shorter
codes are much more common than longer codes, so pay attention to decoding the
short codes fast, and let the long codes take longer to decode.
inflate() sets up a first level table that covers some number of bits of
input less than the length of longest code. It gets that many bits from the
stream, and looks it up in the table. The table will tell if the next
code is that many bits or less and how many, and if it is, it will tell
the value, else it will point to the next level table for which inflate()
grabs more bits and tries to decode a longer code.
How many bits to make the first lookup is a tradeoff between the time it
takes to decode and the time it takes to build the table. If building the
table took no time (and if you had infinite memory), then there would only
be a first level table to cover all the way to the longest code. However,
building the table ends up taking a lot longer for more bits since short
codes are replicated many times in such a table. What inflate() does is
simply to make the number of bits in the first table a variable, and then
to set that variable for the maximum speed.
For inflate, which has 286 possible codes for the literal/length tree, the size
of the first table is nine bits. Also the distance trees have 30 possible
values, and the size of the first table is six bits. Note that for each of
those cases, the table ended up one bit longer than the ``average'' code
length, i.e. the code length of an approximately flat code which would be a
little more than eight bits for 286 symbols and a little less than five bits
for 30 symbols.
2.2 More details on the inflate table lookup
Ok, you want to know what this cleverly obfuscated inflate tree actually
looks like. You are correct that it's not a Huffman tree. It is simply a
lookup table for the first, let's say, nine bits of a Huffman symbol. The
symbol could be as short as one bit or as long as 15 bits. If a particular
symbol is shorter than nine bits, then that symbol's translation is duplicated
in all those entries that start with that symbol's bits. For example, if the
symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a
symbol is nine bits long, it appears in the table once.
If the symbol is longer than nine bits, then that entry in the table points
to another similar table for the remaining bits. Again, there are duplicated
entries as needed. The idea is that most of the time the symbol will be short
and there will only be one table look up. (That's whole idea behind data
compression in the first place.) For the less frequent long symbols, there
will be two lookups. If you had a compression method with really long
symbols, you could have as many levels of lookups as is efficient. For
inflate, two is enough.
So a table entry either points to another table (in which case nine bits in
the above example are gobbled), or it contains the translation for the symbol
and the number of bits to gobble. Then you start again with the next
ungobbled bit.
You may wonder: why not just have one lookup table for how ever many bits the
longest symbol is? The reason is that if you do that, you end up spending
more time filling in duplicate symbol entries than you do actually decoding.
At least for deflate's output that generates new trees every several 10's of
kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code
would take too long if you're only decoding several thousand symbols. At the
other extreme, you could make a new table for every bit in the code. In fact,
that's essentially a Huffman tree. But then you spend two much time
traversing the tree while decoding, even for short symbols.
So the number of bits for the first lookup table is a trade of the time to
fill out the table vs. the time spent looking at the second level and above of
the table.
Here is an example, scaled down:
The code being decoded, with 10 symbols, from 1 to 6 bits long:
A: 0
B: 10
C: 1100
D: 11010
E: 11011
F: 11100
G: 11101
H: 11110
I: 111110
J: 111111
Let's make the first table three bits long (eight entries):
000: A,1
001: A,1
010: A,1
011: A,1
100: B,2
101: B,2
110: -> table X (gobble 3 bits)
111: -> table Y (gobble 3 bits)
Each entry is what the bits decode as and how many bits that is, i.e. how
many bits to gobble. Or the entry points to another table, with the number of
bits to gobble implicit in the size of the table.
Table X is two bits long since the longest code starting with 110 is five bits
long:
00: C,1
01: C,1
10: D,2
11: E,2
Table Y is three bits long since the longest code starting with 111 is six
bits long:
000: F,2
001: F,2
010: G,2
011: G,2
100: H,2
101: H,2
110: I,3
111: J,3
So what we have here are three tables with a total of 20 entries that had to
be constructed. That's compared to 64 entries for a single table. Or
compared to 16 entries for a Huffman tree (six two entry tables and one four
entry table). Assuming that the code ideally represents the probability of
the symbols, it takes on the average 1.25 lookups per symbol. That's compared
to one lookup for the single table, or 1.66 lookups per symbol for the
Huffman tree.
There, I think that gives you a picture of what's going on. For inflate, the
meaning of a particular symbol is often more than just a letter. It can be a
byte (a "literal"), or it can be either a length or a distance which
indicates a base value and a number of bits to fetch after the code that is
added to the base value. Or it might be the special end-of-block code. The
data structures created in inftrees.c try to encode all that information
compactly in the tables.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
References:
[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data
Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3,
pp. 337-343.
``DEFLATE Compressed Data Format Specification'' available in
http://www.ietf.org/rfc/rfc1951.txt

158
utils/zenutils/libraries/zlib123/zlib/compress.c Executable file → Normal file
View file

@ -1,79 +1,79 @@
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least 0.1% larger than sourceLen plus
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
#endif
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err;
}
*destLen = stream.total_out;
err = deflateEnd(&stream);
return err;
}
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
/* ===========================================================================
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
uLong ZEXPORT compressBound (sourceLen)
uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
}
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#define ZLIB_INTERNAL
#include "zlib.h"
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least 0.1% larger than sourceLen plus
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
#endif
stream.next_out = dest;
stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err;
}
*destLen = stream.total_out;
err = deflateEnd(&stream);
return err;
}
/* ===========================================================================
*/
int ZEXPORT compress (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
/* ===========================================================================
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
uLong ZEXPORT compressBound (sourceLen)
uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
}

918
utils/zenutils/libraries/zlib123/zlib/configure vendored Executable file → Normal file
View file

@ -1,459 +1,459 @@
#!/bin/sh
# configure script for zlib. This script is needed only if
# you wish to build a shared library and your system supports them,
# of if you need special compiler, flags or install directory.
# Otherwise, you can just use directly "make test; make install"
#
# To create a shared library, use "configure --shared"; by default a static
# library is created. If the primitive shared library support provided here
# does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz
#
# To impose specific compiler or flags or install directory, use for example:
# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
# or for csh/tcsh users:
# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
# LDSHARED is the command to be used to create a shared library
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
# If you have problems, try without defining CC and CFLAGS before reporting
# an error.
LIBS=libz.a
LDFLAGS="-L. ${LIBS}"
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
AR=${AR-"ar rc"}
RANLIB=${RANLIB-"ranlib"}
prefix=${prefix-/usr/local}
exec_prefix=${exec_prefix-'${prefix}'}
libdir=${libdir-'${exec_prefix}/lib'}
includedir=${includedir-'${prefix}/include'}
mandir=${mandir-'${prefix}/share/man'}
shared_ext='.so'
shared=0
gcc=0
old_cc="$CC"
old_cflags="$CFLAGS"
while test $# -ge 1
do
case "$1" in
-h* | --h*)
echo 'usage:'
echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
exit 0;;
-p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
-p* | --p*) prefix="$2"; shift; shift;;
-e* | --e*) exec_prefix="$2"; shift; shift;;
-l* | --l*) libdir="$2"; shift; shift;;
-i* | --i*) includedir="$2"; shift; shift;;
-s* | --s*) shared=1; shift;;
*) echo "unknown option: $1"; echo "$0 --help for help"; exit 1;;
esac
done
test=ztest$$
cat > $test.c <<EOF
extern int getchar();
int hello() {return getchar();}
EOF
test -z "$CC" && echo Checking for gcc...
cc=${CC-gcc}
cflags=${CFLAGS-"-O3"}
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
case "$cc" in
*gcc*) gcc=1;;
esac
if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc"
SFLAGS=${CFLAGS-"-fPIC -O3"}
CFLAGS="$cflags"
case `(uname -s || echo unknown) 2>/dev/null` in
Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
CYGWIN* | Cygwin* | cygwin* | OS/2* )
EXE='.exe';;
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
# (alain.bonnefoy@icbt.com)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
HP-UX*)
LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
case `(uname -m || echo unknown) 2>/dev/null` in
ia64)
shared_ext='.so'
SHAREDLIB='libz.so';;
*)
shared_ext='.sl'
SHAREDLIB='libz.sl';;
esac;;
Darwin*) shared_ext='.dylib'
SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};;
*) LDSHARED=${LDSHARED-"$cc -shared"};;
esac
else
# find system name and corresponding cc options
CC=${CC-cc}
case `(uname -sr || echo unknown) 2>/dev/null` in
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
CFLAGS=${CFLAGS-"-O"}
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
LDSHARED=${LDSHARED-"ld -b"}
case `(uname -m || echo unknown) 2>/dev/null` in
ia64)
shared_ext='.so'
SHAREDLIB='libz.so';;
*)
shared_ext='.sl'
SHAREDLIB='libz.sl';;
esac;;
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
CFLAGS=${CFLAGS-"-ansi -O2"}
LDSHARED=${LDSHARED-"cc -shared"};;
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
CFLAGS=${CFLAGS-"-O -std1"}
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
CFLAGS=${CFLAGS-"-O -std1"}
LDSHARED=${LDSHARED-"cc -shared"};;
QNX*) SFLAGS=${CFLAGS-"-4 -O"}
CFLAGS=${CFLAGS-"-4 -O"}
LDSHARED=${LDSHARED-"cc"}
RANLIB=${RANLIB-"true"}
AR="cc -A";;
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
CFLAGS=${CFLAGS-"-O3"}
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
CFLAGS=${CFLAGS-"-fast -xcg89"}
LDSHARED=${LDSHARED-"cc -G"};;
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
CFLAGS=${CFLAGS-"-O2"}
LDSHARED=${LDSHARED-"ld"};;
SunStudio\ 9*) SFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
CFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"}
LDSHARED=${LDSHARED-"cc -xarch=v9b"};;
UNIX_System_V\ 4.2.0)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"};;
UNIX_SV\ 4.2MP)
SFLAGS=${CFLAGS-"-Kconform_pic -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"};;
OpenUNIX\ 5)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"};;
AIX*) # Courtesy of dbakker@arrayasolutions.com
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
LDSHARED=${LDSHARED-"xlc -G"};;
# send working options for other systems to support@gzip.org
*) SFLAGS=${CFLAGS-"-O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -shared"};;
esac
fi
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
if test $shared -eq 1; then
echo Checking for shared library support...
# we must test in two steps (cc then ld), required at least on SunOS 4.x
if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
CFLAGS="$SFLAGS"
LIBS="$SHAREDLIBV"
echo Building shared library $SHAREDLIBV with $CC.
elif test -z "$old_cc" -a -z "$old_cflags"; then
echo No shared library support.
shared=0;
else
echo 'No shared library support; try without defining CC and CFLAGS'
shared=0;
fi
fi
if test $shared -eq 0; then
LDSHARED="$CC"
echo Building static library $LIBS version $VER with $CC.
else
LDFLAGS="-L. ${SHAREDLIBV}"
fi
cat > $test.c <<EOF
#include <unistd.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
echo "Checking for unistd.h... Yes."
else
cp -p zconf.in.h zconf.h
echo "Checking for unistd.h... No."
fi
cat > $test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
#include "zconf.h"
int main()
{
#ifndef STDC
choke me
#endif
return 0;
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()"
cat > $test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(char *fmt, ...)
{
char buf[20];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
return 0;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
echo "Checking for vsnprintf() in stdio.h... Yes."
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(char *fmt, ...)
{
int n;
char buf[20];
va_list ap;
va_start(ap, fmt);
n = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
return n;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of vsnprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
echo "Checking for return value of vsnprintf()... No."
echo " WARNING: apparently vsnprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
else
CFLAGS="$CFLAGS -DNO_vsnprintf"
echo "Checking for vsnprintf() in stdio.h... No."
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
echo " can build but will be open to possible buffer-overflow security"
echo " vulnerabilities."
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(char *fmt, ...)
{
int n;
char buf[20];
va_list ap;
va_start(ap, fmt);
n = vsprintf(buf, fmt, ap);
va_end(ap);
return n;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of vsprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_vsprintf_void"
echo "Checking for return value of vsprintf()... No."
echo " WARNING: apparently vsprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
fi
else
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()"
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
char buf[20];
snprintf(buf, sizeof(buf), "%s", "foo");
return 0;
}
int main()
{
return (mytest());
}
EOF
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
echo "Checking for snprintf() in stdio.h... Yes."
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
char buf[20];
return snprintf(buf, sizeof(buf), "%s", "foo");
}
int main()
{
return (mytest());
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of snprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_snprintf_void"
echo "Checking for return value of snprintf()... No."
echo " WARNING: apparently snprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
else
CFLAGS="$CFLAGS -DNO_snprintf"
echo "Checking for snprintf() in stdio.h... No."
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
echo " can build but will be open to possible buffer-overflow security"
echo " vulnerabilities."
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
char buf[20];
return sprintf(buf, "%s", "foo");
}
int main()
{
return (mytest());
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of sprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_sprintf_void"
echo "Checking for return value of sprintf()... No."
echo " WARNING: apparently sprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
fi
fi
cat >$test.c <<EOF
#include <errno.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for errno.h... Yes."
else
echo "Checking for errno.h... No."
CFLAGS="$CFLAGS -DNO_ERRNO_H"
fi
cat > $test.c <<EOF
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
caddr_t hello() {
return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
CFLAGS="$CFLAGS -DUSE_MMAP"
echo Checking for mmap support... Yes.
else
echo Checking for mmap support... No.
fi
CPP=${CPP-"$CC -E"}
case $CFLAGS in
*ASMV*)
if test "`nm $test.o | grep _hello`" = ""; then
CPP="$CPP -DNO_UNDERLINE"
echo Checking for underline in external names... No.
else
echo Checking for underline in external names... Yes.
fi;;
esac
rm -f $test.[co] $test $test$shared_ext
# udpate Makefile
sed < Makefile.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^CPP *=/s#=.*#=$CPP#
/^LDSHARED *=/s#=.*#=$LDSHARED#
/^LIBS *=/s#=.*#=$LIBS#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
/^AR *=/s#=.*#=$AR#
/^RANLIB *=/s#=.*#=$RANLIB#
/^EXE *=/s#=.*#=$EXE#
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
" > Makefile
#!/bin/sh
# configure script for zlib. This script is needed only if
# you wish to build a shared library and your system supports them,
# of if you need special compiler, flags or install directory.
# Otherwise, you can just use directly "make test; make install"
#
# To create a shared library, use "configure --shared"; by default a static
# library is created. If the primitive shared library support provided here
# does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz
#
# To impose specific compiler or flags or install directory, use for example:
# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
# or for csh/tcsh users:
# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
# LDSHARED is the command to be used to create a shared library
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
# If you have problems, try without defining CC and CFLAGS before reporting
# an error.
LIBS=libz.a
LDFLAGS="-L. ${LIBS}"
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
AR=${AR-"ar rc"}
RANLIB=${RANLIB-"ranlib"}
prefix=${prefix-/usr/local}
exec_prefix=${exec_prefix-'${prefix}'}
libdir=${libdir-'${exec_prefix}/lib'}
includedir=${includedir-'${prefix}/include'}
mandir=${mandir-'${prefix}/share/man'}
shared_ext='.so'
shared=0
gcc=0
old_cc="$CC"
old_cflags="$CFLAGS"
while test $# -ge 1
do
case "$1" in
-h* | --h*)
echo 'usage:'
echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
exit 0;;
-p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
-p* | --p*) prefix="$2"; shift; shift;;
-e* | --e*) exec_prefix="$2"; shift; shift;;
-l* | --l*) libdir="$2"; shift; shift;;
-i* | --i*) includedir="$2"; shift; shift;;
-s* | --s*) shared=1; shift;;
*) echo "unknown option: $1"; echo "$0 --help for help"; exit 1;;
esac
done
test=ztest$$
cat > $test.c <<EOF
extern int getchar();
int hello() {return getchar();}
EOF
test -z "$CC" && echo Checking for gcc...
cc=${CC-gcc}
cflags=${CFLAGS-"-O3"}
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
case "$cc" in
*gcc*) gcc=1;;
esac
if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc"
SFLAGS=${CFLAGS-"-fPIC -O3"}
CFLAGS="$cflags"
case `(uname -s || echo unknown) 2>/dev/null` in
Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
CYGWIN* | Cygwin* | cygwin* | OS/2* )
EXE='.exe';;
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
# (alain.bonnefoy@icbt.com)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
HP-UX*)
LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
case `(uname -m || echo unknown) 2>/dev/null` in
ia64)
shared_ext='.so'
SHAREDLIB='libz.so';;
*)
shared_ext='.sl'
SHAREDLIB='libz.sl';;
esac;;
Darwin*) shared_ext='.dylib'
SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};;
*) LDSHARED=${LDSHARED-"$cc -shared"};;
esac
else
# find system name and corresponding cc options
CC=${CC-cc}
case `(uname -sr || echo unknown) 2>/dev/null` in
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
CFLAGS=${CFLAGS-"-O"}
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
LDSHARED=${LDSHARED-"ld -b"}
case `(uname -m || echo unknown) 2>/dev/null` in
ia64)
shared_ext='.so'
SHAREDLIB='libz.so';;
*)
shared_ext='.sl'
SHAREDLIB='libz.sl';;
esac;;
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
CFLAGS=${CFLAGS-"-ansi -O2"}
LDSHARED=${LDSHARED-"cc -shared"};;
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
CFLAGS=${CFLAGS-"-O -std1"}
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
CFLAGS=${CFLAGS-"-O -std1"}
LDSHARED=${LDSHARED-"cc -shared"};;
QNX*) SFLAGS=${CFLAGS-"-4 -O"}
CFLAGS=${CFLAGS-"-4 -O"}
LDSHARED=${LDSHARED-"cc"}
RANLIB=${RANLIB-"true"}
AR="cc -A";;
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
CFLAGS=${CFLAGS-"-O3"}
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
CFLAGS=${CFLAGS-"-fast -xcg89"}
LDSHARED=${LDSHARED-"cc -G"};;
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
CFLAGS=${CFLAGS-"-O2"}
LDSHARED=${LDSHARED-"ld"};;
SunStudio\ 9*) SFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
CFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"}
LDSHARED=${LDSHARED-"cc -xarch=v9b"};;
UNIX_System_V\ 4.2.0)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"};;
UNIX_SV\ 4.2MP)
SFLAGS=${CFLAGS-"-Kconform_pic -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"};;
OpenUNIX\ 5)
SFLAGS=${CFLAGS-"-KPIC -O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -G"};;
AIX*) # Courtesy of dbakker@arrayasolutions.com
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
LDSHARED=${LDSHARED-"xlc -G"};;
# send working options for other systems to support@gzip.org
*) SFLAGS=${CFLAGS-"-O"}
CFLAGS=${CFLAGS-"-O"}
LDSHARED=${LDSHARED-"cc -shared"};;
esac
fi
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
if test $shared -eq 1; then
echo Checking for shared library support...
# we must test in two steps (cc then ld), required at least on SunOS 4.x
if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
CFLAGS="$SFLAGS"
LIBS="$SHAREDLIBV"
echo Building shared library $SHAREDLIBV with $CC.
elif test -z "$old_cc" -a -z "$old_cflags"; then
echo No shared library support.
shared=0;
else
echo 'No shared library support; try without defining CC and CFLAGS'
shared=0;
fi
fi
if test $shared -eq 0; then
LDSHARED="$CC"
echo Building static library $LIBS version $VER with $CC.
else
LDFLAGS="-L. ${SHAREDLIBV}"
fi
cat > $test.c <<EOF
#include <unistd.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
echo "Checking for unistd.h... Yes."
else
cp -p zconf.in.h zconf.h
echo "Checking for unistd.h... No."
fi
cat > $test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
#include "zconf.h"
int main()
{
#ifndef STDC
choke me
#endif
return 0;
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()"
cat > $test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(char *fmt, ...)
{
char buf[20];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
return 0;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
echo "Checking for vsnprintf() in stdio.h... Yes."
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(char *fmt, ...)
{
int n;
char buf[20];
va_list ap;
va_start(ap, fmt);
n = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
return n;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of vsnprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
echo "Checking for return value of vsnprintf()... No."
echo " WARNING: apparently vsnprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
else
CFLAGS="$CFLAGS -DNO_vsnprintf"
echo "Checking for vsnprintf() in stdio.h... No."
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
echo " can build but will be open to possible buffer-overflow security"
echo " vulnerabilities."
cat >$test.c <<EOF
#include <stdio.h>
#include <stdarg.h>
int mytest(char *fmt, ...)
{
int n;
char buf[20];
va_list ap;
va_start(ap, fmt);
n = vsprintf(buf, fmt, ap);
va_end(ap);
return n;
}
int main()
{
return (mytest("Hello%d\n", 1));
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of vsprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_vsprintf_void"
echo "Checking for return value of vsprintf()... No."
echo " WARNING: apparently vsprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
fi
else
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()"
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
char buf[20];
snprintf(buf, sizeof(buf), "%s", "foo");
return 0;
}
int main()
{
return (mytest());
}
EOF
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
echo "Checking for snprintf() in stdio.h... Yes."
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
char buf[20];
return snprintf(buf, sizeof(buf), "%s", "foo");
}
int main()
{
return (mytest());
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of snprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_snprintf_void"
echo "Checking for return value of snprintf()... No."
echo " WARNING: apparently snprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
else
CFLAGS="$CFLAGS -DNO_snprintf"
echo "Checking for snprintf() in stdio.h... No."
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
echo " can build but will be open to possible buffer-overflow security"
echo " vulnerabilities."
cat >$test.c <<EOF
#include <stdio.h>
int mytest()
{
char buf[20];
return sprintf(buf, "%s", "foo");
}
int main()
{
return (mytest());
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for return value of sprintf()... Yes."
else
CFLAGS="$CFLAGS -DHAS_sprintf_void"
echo "Checking for return value of sprintf()... No."
echo " WARNING: apparently sprintf() does not return a value. zlib"
echo " can build but will be open to possible string-format security"
echo " vulnerabilities."
fi
fi
fi
cat >$test.c <<EOF
#include <errno.h>
int main() { return 0; }
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
echo "Checking for errno.h... Yes."
else
echo "Checking for errno.h... No."
CFLAGS="$CFLAGS -DNO_ERRNO_H"
fi
cat > $test.c <<EOF
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
caddr_t hello() {
return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
}
EOF
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
CFLAGS="$CFLAGS -DUSE_MMAP"
echo Checking for mmap support... Yes.
else
echo Checking for mmap support... No.
fi
CPP=${CPP-"$CC -E"}
case $CFLAGS in
*ASMV*)
if test "`nm $test.o | grep _hello`" = ""; then
CPP="$CPP -DNO_UNDERLINE"
echo Checking for underline in external names... No.
else
echo Checking for underline in external names... Yes.
fi;;
esac
rm -f $test.[co] $test $test$shared_ext
# udpate Makefile
sed < Makefile.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^CPP *=/s#=.*#=$CPP#
/^LDSHARED *=/s#=.*#=$LDSHARED#
/^LIBS *=/s#=.*#=$LIBS#
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
/^AR *=/s#=.*#=$AR#
/^RANLIB *=/s#=.*#=$RANLIB#
/^EXE *=/s#=.*#=$EXE#
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^libdir *=/s#=.*#=$libdir#
/^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
" > Makefile

846
utils/zenutils/libraries/zlib123/zlib/crc32.c Executable file → Normal file
View file

@ -1,423 +1,423 @@
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2005 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* tables for updating the shift register in one step with three exclusive-ors
* instead of four steps with four exclusive-ors. This results in about a
* factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
/* @(#) $Id$ */
/*
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
protection on the static variables used to control the first-use generation
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
first call get_crc_table() to initialize the tables before allowing more than
one thread to use crc32().
*/
#ifdef MAKECRCH
# include <stdio.h>
# ifndef DYNAMIC_CRC_TABLE
# define DYNAMIC_CRC_TABLE
# endif /* !DYNAMIC_CRC_TABLE */
#endif /* MAKECRCH */
#include "zutil.h" /* for STDC and FAR definitions */
#define local static
/* Find a four-byte integer type for crc32_little() and crc32_big(). */
#ifndef NOBYFOUR
# ifdef STDC /* need ANSI C limits.h to determine sizes */
# include <limits.h>
# define BYFOUR
# if (UINT_MAX == 0xffffffffUL)
typedef unsigned int u4;
# else
# if (ULONG_MAX == 0xffffffffUL)
typedef unsigned long u4;
# else
# if (USHRT_MAX == 0xffffffffUL)
typedef unsigned short u4;
# else
# undef BYFOUR /* can't find a four-byte integer type! */
# endif
# endif
# endif
# endif /* STDC */
#endif /* !NOBYFOUR */
/* Definitions for doing the crc four data bytes at a time. */
#ifdef BYFOUR
# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, unsigned));
local unsigned long crc32_big OF((unsigned long,
const unsigned char FAR *, unsigned));
# define TBLS 8
#else
# define TBLS 1
#endif /* BYFOUR */
/* Local functions for crc concatenation */
local unsigned long gf2_matrix_times OF((unsigned long *mat,
unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
#ifdef DYNAMIC_CRC_TABLE
local volatile int crc_table_empty = 1;
local unsigned long FAR crc_table[TBLS][256];
local void make_crc_table OF((void));
#ifdef MAKECRCH
local void write_table OF((FILE *, const unsigned long FAR *));
#endif /* MAKECRCH */
/*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
Polynomials over GF(2) are represented in binary, one bit per coefficient,
with the lowest powers in the most significant bit. Then adding polynomials
is just exclusive-or, and multiplying a polynomial by x is a right shift by
one. If we call the above polynomial p, and represent a byte as the
polynomial q, also with the lowest power in the most significant bit (so the
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
where a mod b means the remainder after dividing a by b.
This calculation is done using the shift-register method of multiplying and
taking the remainder. The register is initialized to zero, and for each
incoming bit, x^32 is added mod p to the register if the bit is a one (where
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
x (which is shifting right by one and adding x^32 mod p if the bit shifted
out is a one). We start with the highest power (least significant bit) of
q and repeat for all eight bits of q.
The first table is simply the CRC of all possible eight bit values. This is
all the information needed to generate CRCs on data a byte at a time for all
combinations of CRC register values and incoming bytes. The remaining tables
allow for word-at-a-time CRC calculation for both big-endian and little-
endian machines, where a word is four bytes.
*/
local void make_crc_table()
{
unsigned long c;
int n, k;
unsigned long poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* See if another task is already doing this (not thread-safe, but better
than nothing -- significantly reduces duration of vulnerability in
case the advice about DYNAMIC_CRC_TABLE is ignored) */
if (first) {
first = 0;
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0UL;
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
poly |= 1UL << (31 - p[n]);
/* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) {
c = (unsigned long)n;
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c;
}
#ifdef BYFOUR
/* generate crc for each value followed by one, two, and three zeros,
and then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) {
c = crc_table[0][n];
crc_table[4][n] = REV(c);
for (k = 1; k < 4; k++) {
c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c;
crc_table[k + 4][n] = REV(c);
}
}
#endif /* BYFOUR */
crc_table_empty = 0;
}
else { /* not first */
/* wait for the other guy to finish (not efficient, but rare) */
while (crc_table_empty)
;
}
#ifdef MAKECRCH
/* write out CRC tables to crc32.h */
{
FILE *out;
out = fopen("crc32.h", "w");
if (out == NULL) return;
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
fprintf(out, "local const unsigned long FAR ");
fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
write_table(out, crc_table[0]);
# ifdef BYFOUR
fprintf(out, "#ifdef BYFOUR\n");
for (k = 1; k < 8; k++) {
fprintf(out, " },\n {\n");
write_table(out, crc_table[k]);
}
fprintf(out, "#endif\n");
# endif /* BYFOUR */
fprintf(out, " }\n};\n");
fclose(out);
}
#endif /* MAKECRCH */
}
#ifdef MAKECRCH
local void write_table(out, table)
FILE *out;
const unsigned long FAR *table;
{
int n;
for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
}
#endif /* MAKECRCH */
#else /* !DYNAMIC_CRC_TABLE */
/* ========================================================================
* Tables of CRC-32s of all single-byte values, made by make_crc_table().
*/
#include "crc32.h"
#endif /* DYNAMIC_CRC_TABLE */
/* =========================================================================
* This function can be used by asm versions of crc32()
*/
const unsigned long FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
return (const unsigned long FAR *)crc_table;
}
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
unsigned long ZEXPORT crc32(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
if (buf == Z_NULL) return 0UL;
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
#ifdef BYFOUR
if (sizeof(void *) == sizeof(ptrdiff_t)) {
u4 endian;
endian = 1;
if (*((unsigned char *)(&endian)))
return crc32_little(crc, buf, len);
else
return crc32_big(crc, buf, len);
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;
while (len >= 8) {
DO8;
len -= 8;
}
if (len) do {
DO1;
} while (--len);
return crc ^ 0xffffffffUL;
}
#ifdef BYFOUR
/* ========================================================================= */
#define DOLIT4 c ^= *buf4++; \
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
local unsigned long crc32_little(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
register u4 c;
register const u4 FAR *buf4;
c = (u4)crc;
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--;
}
buf4 = (const u4 FAR *)(const void FAR *)buf;
while (len >= 32) {
DOLIT32;
len -= 32;
}
while (len >= 4) {
DOLIT4;
len -= 4;
}
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len);
c = ~c;
return (unsigned long)c;
}
/* ========================================================================= */
#define DOBIG4 c ^= *++buf4; \
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
local unsigned long crc32_big(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
register u4 c;
register const u4 FAR *buf4;
c = REV((u4)crc);
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--;
}
buf4 = (const u4 FAR *)(const void FAR *)buf;
buf4--;
while (len >= 32) {
DOBIG32;
len -= 32;
}
while (len >= 4) {
DOBIG4;
len -= 4;
}
buf4++;
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len);
c = ~c;
return (unsigned long)(REV(c));
}
#endif /* BYFOUR */
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */
local unsigned long gf2_matrix_times(mat, vec)
unsigned long *mat;
unsigned long vec;
{
unsigned long sum;
sum = 0;
while (vec) {
if (vec & 1)
sum ^= *mat;
vec >>= 1;
mat++;
}
return sum;
}
/* ========================================================================= */
local void gf2_matrix_square(square, mat)
unsigned long *square;
unsigned long *mat;
{
int n;
for (n = 0; n < GF2_DIM; n++)
square[n] = gf2_matrix_times(mat, mat[n]);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off_t len2;
{
int n;
unsigned long row;
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
/* degenerate case */
if (len2 == 0)
return crc1;
/* put operator for one zero bit in odd */
odd[0] = 0xedb88320L; /* CRC-32 polynomial */
row = 1;
for (n = 1; n < GF2_DIM; n++) {
odd[n] = row;
row <<= 1;
}
/* put operator for two zero bits in even */
gf2_matrix_square(even, odd);
/* put operator for four zero bits in odd */
gf2_matrix_square(odd, even);
/* apply len2 zeros to crc1 (first square will put the operator for one
zero byte, eight zero bits, in even) */
do {
/* apply zeros operator for this bit of len2 */
gf2_matrix_square(even, odd);
if (len2 & 1)
crc1 = gf2_matrix_times(even, crc1);
len2 >>= 1;
/* if no more bits set, then done */
if (len2 == 0)
break;
/* another iteration of the loop with odd and even swapped */
gf2_matrix_square(odd, even);
if (len2 & 1)
crc1 = gf2_matrix_times(odd, crc1);
len2 >>= 1;
/* if no more bits set, then done */
} while (len2 != 0);
/* return combined crc */
crc1 ^= crc2;
return crc1;
}
/* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2005 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
* CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* tables for updating the shift register in one step with three exclusive-ors
* instead of four steps with four exclusive-ors. This results in about a
* factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
*/
/* @(#) $Id$ */
/*
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
protection on the static variables used to control the first-use generation
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
first call get_crc_table() to initialize the tables before allowing more than
one thread to use crc32().
*/
#ifdef MAKECRCH
# include <stdio.h>
# ifndef DYNAMIC_CRC_TABLE
# define DYNAMIC_CRC_TABLE
# endif /* !DYNAMIC_CRC_TABLE */
#endif /* MAKECRCH */
#include "zutil.h" /* for STDC and FAR definitions */
#define local static
/* Find a four-byte integer type for crc32_little() and crc32_big(). */
#ifndef NOBYFOUR
# ifdef STDC /* need ANSI C limits.h to determine sizes */
# include <limits.h>
# define BYFOUR
# if (UINT_MAX == 0xffffffffUL)
typedef unsigned int u4;
# else
# if (ULONG_MAX == 0xffffffffUL)
typedef unsigned long u4;
# else
# if (USHRT_MAX == 0xffffffffUL)
typedef unsigned short u4;
# else
# undef BYFOUR /* can't find a four-byte integer type! */
# endif
# endif
# endif
# endif /* STDC */
#endif /* !NOBYFOUR */
/* Definitions for doing the crc four data bytes at a time. */
#ifdef BYFOUR
# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, unsigned));
local unsigned long crc32_big OF((unsigned long,
const unsigned char FAR *, unsigned));
# define TBLS 8
#else
# define TBLS 1
#endif /* BYFOUR */
/* Local functions for crc concatenation */
local unsigned long gf2_matrix_times OF((unsigned long *mat,
unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
#ifdef DYNAMIC_CRC_TABLE
local volatile int crc_table_empty = 1;
local unsigned long FAR crc_table[TBLS][256];
local void make_crc_table OF((void));
#ifdef MAKECRCH
local void write_table OF((FILE *, const unsigned long FAR *));
#endif /* MAKECRCH */
/*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
Polynomials over GF(2) are represented in binary, one bit per coefficient,
with the lowest powers in the most significant bit. Then adding polynomials
is just exclusive-or, and multiplying a polynomial by x is a right shift by
one. If we call the above polynomial p, and represent a byte as the
polynomial q, also with the lowest power in the most significant bit (so the
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
where a mod b means the remainder after dividing a by b.
This calculation is done using the shift-register method of multiplying and
taking the remainder. The register is initialized to zero, and for each
incoming bit, x^32 is added mod p to the register if the bit is a one (where
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
x (which is shifting right by one and adding x^32 mod p if the bit shifted
out is a one). We start with the highest power (least significant bit) of
q and repeat for all eight bits of q.
The first table is simply the CRC of all possible eight bit values. This is
all the information needed to generate CRCs on data a byte at a time for all
combinations of CRC register values and incoming bytes. The remaining tables
allow for word-at-a-time CRC calculation for both big-endian and little-
endian machines, where a word is four bytes.
*/
local void make_crc_table()
{
unsigned long c;
int n, k;
unsigned long poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* See if another task is already doing this (not thread-safe, but better
than nothing -- significantly reduces duration of vulnerability in
case the advice about DYNAMIC_CRC_TABLE is ignored) */
if (first) {
first = 0;
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0UL;
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
poly |= 1UL << (31 - p[n]);
/* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) {
c = (unsigned long)n;
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c;
}
#ifdef BYFOUR
/* generate crc for each value followed by one, two, and three zeros,
and then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) {
c = crc_table[0][n];
crc_table[4][n] = REV(c);
for (k = 1; k < 4; k++) {
c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c;
crc_table[k + 4][n] = REV(c);
}
}
#endif /* BYFOUR */
crc_table_empty = 0;
}
else { /* not first */
/* wait for the other guy to finish (not efficient, but rare) */
while (crc_table_empty)
;
}
#ifdef MAKECRCH
/* write out CRC tables to crc32.h */
{
FILE *out;
out = fopen("crc32.h", "w");
if (out == NULL) return;
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
fprintf(out, "local const unsigned long FAR ");
fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
write_table(out, crc_table[0]);
# ifdef BYFOUR
fprintf(out, "#ifdef BYFOUR\n");
for (k = 1; k < 8; k++) {
fprintf(out, " },\n {\n");
write_table(out, crc_table[k]);
}
fprintf(out, "#endif\n");
# endif /* BYFOUR */
fprintf(out, " }\n};\n");
fclose(out);
}
#endif /* MAKECRCH */
}
#ifdef MAKECRCH
local void write_table(out, table)
FILE *out;
const unsigned long FAR *table;
{
int n;
for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
}
#endif /* MAKECRCH */
#else /* !DYNAMIC_CRC_TABLE */
/* ========================================================================
* Tables of CRC-32s of all single-byte values, made by make_crc_table().
*/
#include "crc32.h"
#endif /* DYNAMIC_CRC_TABLE */
/* =========================================================================
* This function can be used by asm versions of crc32()
*/
const unsigned long FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
return (const unsigned long FAR *)crc_table;
}
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
unsigned long ZEXPORT crc32(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
if (buf == Z_NULL) return 0UL;
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
#ifdef BYFOUR
if (sizeof(void *) == sizeof(ptrdiff_t)) {
u4 endian;
endian = 1;
if (*((unsigned char *)(&endian)))
return crc32_little(crc, buf, len);
else
return crc32_big(crc, buf, len);
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;
while (len >= 8) {
DO8;
len -= 8;
}
if (len) do {
DO1;
} while (--len);
return crc ^ 0xffffffffUL;
}
#ifdef BYFOUR
/* ========================================================================= */
#define DOLIT4 c ^= *buf4++; \
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
local unsigned long crc32_little(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
register u4 c;
register const u4 FAR *buf4;
c = (u4)crc;
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--;
}
buf4 = (const u4 FAR *)(const void FAR *)buf;
while (len >= 32) {
DOLIT32;
len -= 32;
}
while (len >= 4) {
DOLIT4;
len -= 4;
}
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len);
c = ~c;
return (unsigned long)c;
}
/* ========================================================================= */
#define DOBIG4 c ^= *++buf4; \
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
local unsigned long crc32_big(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
register u4 c;
register const u4 FAR *buf4;
c = REV((u4)crc);
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--;
}
buf4 = (const u4 FAR *)(const void FAR *)buf;
buf4--;
while (len >= 32) {
DOBIG32;
len -= 32;
}
while (len >= 4) {
DOBIG4;
len -= 4;
}
buf4++;
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len);
c = ~c;
return (unsigned long)(REV(c));
}
#endif /* BYFOUR */
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */
local unsigned long gf2_matrix_times(mat, vec)
unsigned long *mat;
unsigned long vec;
{
unsigned long sum;
sum = 0;
while (vec) {
if (vec & 1)
sum ^= *mat;
vec >>= 1;
mat++;
}
return sum;
}
/* ========================================================================= */
local void gf2_matrix_square(square, mat)
unsigned long *square;
unsigned long *mat;
{
int n;
for (n = 0; n < GF2_DIM; n++)
square[n] = gf2_matrix_times(mat, mat[n]);
}
/* ========================================================================= */
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong crc1;
uLong crc2;
z_off_t len2;
{
int n;
unsigned long row;
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
/* degenerate case */
if (len2 == 0)
return crc1;
/* put operator for one zero bit in odd */
odd[0] = 0xedb88320L; /* CRC-32 polynomial */
row = 1;
for (n = 1; n < GF2_DIM; n++) {
odd[n] = row;
row <<= 1;
}
/* put operator for two zero bits in even */
gf2_matrix_square(even, odd);
/* put operator for four zero bits in odd */
gf2_matrix_square(odd, even);
/* apply len2 zeros to crc1 (first square will put the operator for one
zero byte, eight zero bits, in even) */
do {
/* apply zeros operator for this bit of len2 */
gf2_matrix_square(even, odd);
if (len2 & 1)
crc1 = gf2_matrix_times(even, crc1);
len2 >>= 1;
/* if no more bits set, then done */
if (len2 == 0)
break;
/* another iteration of the loop with odd and even swapped */
gf2_matrix_square(odd, even);
if (len2 & 1)
crc1 = gf2_matrix_times(odd, crc1);
len2 >>= 1;
/* if no more bits set, then done */
} while (len2 != 0);
/* return combined crc */
crc1 ^= crc2;
return crc1;
}

882
utils/zenutils/libraries/zlib123/zlib/crc32.h Executable file → Normal file
View file

@ -1,441 +1,441 @@
/* crc32.h -- tables for rapid CRC calculation
* Generated automatically by crc32.c
*/
local const unsigned long FAR crc_table[TBLS][256] =
{
{
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
0x2d02ef8dUL
#ifdef BYFOUR
},
{
0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
0x9324fd72UL
},
{
0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
0xbe9834edUL
},
{
0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
0xde0506f1UL
},
{
0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
0x8def022dUL
},
{
0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
0x72fd2493UL
},
{
0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
0xed3498beUL
},
{
0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
0xf10605deUL
#endif
}
};
/* crc32.h -- tables for rapid CRC calculation
* Generated automatically by crc32.c
*/
local const unsigned long FAR crc_table[TBLS][256] =
{
{
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
0x2d02ef8dUL
#ifdef BYFOUR
},
{
0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
0x9324fd72UL
},
{
0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
0xbe9834edUL
},
{
0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
0xde0506f1UL
},
{
0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
0x8def022dUL
},
{
0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
0x72fd2493UL
},
{
0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
0xed3498beUL
},
{
0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
0xf10605deUL
#endif
}
};

3472
utils/zenutils/libraries/zlib123/zlib/deflate.c Executable file → Normal file

File diff suppressed because it is too large Load diff

662
utils/zenutils/libraries/zlib123/zlib/deflate.h Executable file → Normal file
View file

@ -1,331 +1,331 @@
/* deflate.h -- internal compression state
* Copyright (C) 1995-2004 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
#ifndef DEFLATE_H
#define DEFLATE_H
#include "zutil.h"
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer creation by deflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip encoding
should be left enabled. */
#ifndef NO_GZIP
# define GZIP
#endif
/* ===========================================================================
* Internal compression state.
*/
#define LENGTH_CODES 29
/* number of length codes, not counting the special END_BLOCK code */
#define LITERALS 256
/* number of literal bytes 0..255 */
#define L_CODES (LITERALS+1+LENGTH_CODES)
/* number of Literal or Length codes, including the END_BLOCK code */
#define D_CODES 30
/* number of distance codes */
#define BL_CODES 19
/* number of codes used to transfer the bit lengths */
#define HEAP_SIZE (2*L_CODES+1)
/* maximum heap size */
#define MAX_BITS 15
/* All codes must not exceed MAX_BITS bits */
#define INIT_STATE 42
#define EXTRA_STATE 69
#define NAME_STATE 73
#define COMMENT_STATE 91
#define HCRC_STATE 103
#define BUSY_STATE 113
#define FINISH_STATE 666
/* Stream status */
/* Data structure describing a single value and its code string. */
typedef struct ct_data_s {
union {
ush freq; /* frequency count */
ush code; /* bit string */
} fc;
union {
ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */
} dl;
} FAR ct_data;
#define Freq fc.freq
#define Code fc.code
#define Dad dl.dad
#define Len dl.len
typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */
static_tree_desc *stat_desc; /* the corresponding static tree */
} FAR tree_desc;
typedef ush Pos;
typedef Pos FAR Posf;
typedef unsigned IPos;
/* A Pos is an index in the character window. We use short instead of int to
* save space in the various tables. IPos is used only for parameter passing.
*/
typedef struct internal_state {
z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */
Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */
uInt pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */
uInt gzindex; /* where in extra, name, or comment */
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
/* used by deflate.c: */
uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */
Bytef *window;
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of
* wSize-MAX_MATCH bytes, but this ensures that IO is always
* performed with a length multiple of the block size. Also, it limits
* the window size to 64K, which is quite useful on MSDOS.
* To do: use the user input buffer as sliding window.
*/
ulg window_size;
/* Actual size of window: 2*wSize, except when the user input buffer
* is directly used as sliding window.
*/
Posf *prev;
/* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K.
*/
Posf *head; /* Heads of the hash chains or NIL. */
uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */
uInt hash_bits; /* log2(hash_size) */
uInt hash_mask; /* hash_size-1 */
uInt hash_shift;
/* Number of bits by which ins_h must be shifted at each input
* step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is:
* hash_shift * MIN_MATCH >= hash_bits
*/
long block_start;
/* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards.
*/
uInt match_length; /* length of best match */
IPos prev_match; /* previous match */
int match_available; /* set if previous match exists */
uInt strstart; /* start of string to insert */
uInt match_start; /* start of matching string */
uInt lookahead; /* number of valid bytes ahead in window */
uInt prev_length;
/* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
*/
uInt max_chain_length;
/* To speed up deflation, hash chains are never searched beyond this
* length. A higher limit improves compression ratio but degrades the
* speed.
*/
uInt max_lazy_match;
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
* levels >= 4.
*/
# define max_insert_length max_lazy_match
/* Insert new strings in the hash table only if the match length is not
* greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3.
*/
int level; /* compression level (1..9) */
int strategy; /* favor or force Huffman coding*/
uInt good_match;
/* Use a faster search when the previous match is longer than this */
int nice_match; /* Stop searching when current match exceeds this */
/* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
struct tree_desc_s l_desc; /* desc. for literal tree */
struct tree_desc_s d_desc; /* desc. for distance tree */
struct tree_desc_s bl_desc; /* desc. for bit length tree */
ush bl_count[MAX_BITS+1];
/* number of codes at each bit length for an optimal tree */
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
int heap_len; /* number of elements in the heap */
int heap_max; /* element of largest frequency */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees.
*/
uch depth[2*L_CODES+1];
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
uchf *l_buf; /* buffer for literals or lengths */
uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
* limiting lit_bufsize to 64K:
* - frequencies can be kept in 16 bit counters
* - if compression is not successful for the first block, all input
* data is still in the window so we can still emit a stored block even
* when input comes from standard input. (This can also be done for
* all blocks if lit_bufsize is not greater than 32K.)
* - if compression is not successful for a file smaller than 64K, we can
* even emit a stored file instead of a stored block (saving 5 bytes).
* This is applicable only for zip (not gzip or zlib).
* - creating new Huffman trees less frequently may not provide fast
* adaptation to changes in the input data statistics. (Take for
* example a binary file with poorly compressible code followed by
* a highly compressible string table.) Smaller buffer sizes give
* fast adaptation but have of course the overhead of transmitting
* trees more frequently.
* - I can't count above 4
*/
uInt last_lit; /* running index in l_buf */
ushf *d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
* array would be necessary.
*/
ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */
uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
ush bi_buf;
/* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
*/
int bi_valid;
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
} FAR deflate_state;
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
/* Minimum amount of lookahead, except at the end of the input file.
* See deflate.c for comments about the MIN_MATCH+1.
*/
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
/* In order to simplify the code, particularly on 16 bit machines, match
* distances are limited to MAX_DIST instead of WSIZE.
*/
/* in trees.c */
void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
#define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
/* Mapping from a distance to a distance code. dist is the distance - 1 and
* must not have side effects. _dist_code[256] and _dist_code[257] are never
* used.
*/
#ifndef DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
extern uch _length_code[];
extern uch _dist_code[];
#else
extern const uch _length_code[];
extern const uch _dist_code[];
#endif
# define _tr_tally_lit(s, c, flush) \
{ uch cc = (c); \
s->d_buf[s->last_lit] = 0; \
s->l_buf[s->last_lit++] = cc; \
s->dyn_ltree[cc].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
# define _tr_tally_dist(s, distance, length, flush) \
{ uch len = (length); \
ush dist = (distance); \
s->d_buf[s->last_lit] = dist; \
s->l_buf[s->last_lit++] = len; \
dist--; \
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
s->dyn_dtree[d_code(dist)].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
#else
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
# define _tr_tally_dist(s, distance, length, flush) \
flush = _tr_tally(s, distance, length)
#endif
#endif /* DEFLATE_H */
/* deflate.h -- internal compression state
* Copyright (C) 1995-2004 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
#ifndef DEFLATE_H
#define DEFLATE_H
#include "zutil.h"
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer creation by deflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip encoding
should be left enabled. */
#ifndef NO_GZIP
# define GZIP
#endif
/* ===========================================================================
* Internal compression state.
*/
#define LENGTH_CODES 29
/* number of length codes, not counting the special END_BLOCK code */
#define LITERALS 256
/* number of literal bytes 0..255 */
#define L_CODES (LITERALS+1+LENGTH_CODES)
/* number of Literal or Length codes, including the END_BLOCK code */
#define D_CODES 30
/* number of distance codes */
#define BL_CODES 19
/* number of codes used to transfer the bit lengths */
#define HEAP_SIZE (2*L_CODES+1)
/* maximum heap size */
#define MAX_BITS 15
/* All codes must not exceed MAX_BITS bits */
#define INIT_STATE 42
#define EXTRA_STATE 69
#define NAME_STATE 73
#define COMMENT_STATE 91
#define HCRC_STATE 103
#define BUSY_STATE 113
#define FINISH_STATE 666
/* Stream status */
/* Data structure describing a single value and its code string. */
typedef struct ct_data_s {
union {
ush freq; /* frequency count */
ush code; /* bit string */
} fc;
union {
ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */
} dl;
} FAR ct_data;
#define Freq fc.freq
#define Code fc.code
#define Dad dl.dad
#define Len dl.len
typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */
static_tree_desc *stat_desc; /* the corresponding static tree */
} FAR tree_desc;
typedef ush Pos;
typedef Pos FAR Posf;
typedef unsigned IPos;
/* A Pos is an index in the character window. We use short instead of int to
* save space in the various tables. IPos is used only for parameter passing.
*/
typedef struct internal_state {
z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */
Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */
uInt pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */
uInt gzindex; /* where in extra, name, or comment */
Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
/* used by deflate.c: */
uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */
Bytef *window;
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of
* wSize-MAX_MATCH bytes, but this ensures that IO is always
* performed with a length multiple of the block size. Also, it limits
* the window size to 64K, which is quite useful on MSDOS.
* To do: use the user input buffer as sliding window.
*/
ulg window_size;
/* Actual size of window: 2*wSize, except when the user input buffer
* is directly used as sliding window.
*/
Posf *prev;
/* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K.
*/
Posf *head; /* Heads of the hash chains or NIL. */
uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */
uInt hash_bits; /* log2(hash_size) */
uInt hash_mask; /* hash_size-1 */
uInt hash_shift;
/* Number of bits by which ins_h must be shifted at each input
* step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is:
* hash_shift * MIN_MATCH >= hash_bits
*/
long block_start;
/* Window position at the beginning of the current output block. Gets
* negative when the window is moved backwards.
*/
uInt match_length; /* length of best match */
IPos prev_match; /* previous match */
int match_available; /* set if previous match exists */
uInt strstart; /* start of string to insert */
uInt match_start; /* start of matching string */
uInt lookahead; /* number of valid bytes ahead in window */
uInt prev_length;
/* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
*/
uInt max_chain_length;
/* To speed up deflation, hash chains are never searched beyond this
* length. A higher limit improves compression ratio but degrades the
* speed.
*/
uInt max_lazy_match;
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
* levels >= 4.
*/
# define max_insert_length max_lazy_match
/* Insert new strings in the hash table only if the match length is not
* greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3.
*/
int level; /* compression level (1..9) */
int strategy; /* favor or force Huffman coding*/
uInt good_match;
/* Use a faster search when the previous match is longer than this */
int nice_match; /* Stop searching when current match exceeds this */
/* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
struct tree_desc_s l_desc; /* desc. for literal tree */
struct tree_desc_s d_desc; /* desc. for distance tree */
struct tree_desc_s bl_desc; /* desc. for bit length tree */
ush bl_count[MAX_BITS+1];
/* number of codes at each bit length for an optimal tree */
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
int heap_len; /* number of elements in the heap */
int heap_max; /* element of largest frequency */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees.
*/
uch depth[2*L_CODES+1];
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
uchf *l_buf; /* buffer for literals or lengths */
uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
* limiting lit_bufsize to 64K:
* - frequencies can be kept in 16 bit counters
* - if compression is not successful for the first block, all input
* data is still in the window so we can still emit a stored block even
* when input comes from standard input. (This can also be done for
* all blocks if lit_bufsize is not greater than 32K.)
* - if compression is not successful for a file smaller than 64K, we can
* even emit a stored file instead of a stored block (saving 5 bytes).
* This is applicable only for zip (not gzip or zlib).
* - creating new Huffman trees less frequently may not provide fast
* adaptation to changes in the input data statistics. (Take for
* example a binary file with poorly compressible code followed by
* a highly compressible string table.) Smaller buffer sizes give
* fast adaptation but have of course the overhead of transmitting
* trees more frequently.
* - I can't count above 4
*/
uInt last_lit; /* running index in l_buf */
ushf *d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
* array would be necessary.
*/
ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */
uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
ush bi_buf;
/* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
*/
int bi_valid;
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
} FAR deflate_state;
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
/* Minimum amount of lookahead, except at the end of the input file.
* See deflate.c for comments about the MIN_MATCH+1.
*/
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
/* In order to simplify the code, particularly on 16 bit machines, match
* distances are limited to MAX_DIST instead of WSIZE.
*/
/* in trees.c */
void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
#define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
/* Mapping from a distance to a distance code. dist is the distance - 1 and
* must not have side effects. _dist_code[256] and _dist_code[257] are never
* used.
*/
#ifndef DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
extern uch _length_code[];
extern uch _dist_code[];
#else
extern const uch _length_code[];
extern const uch _dist_code[];
#endif
# define _tr_tally_lit(s, c, flush) \
{ uch cc = (c); \
s->d_buf[s->last_lit] = 0; \
s->l_buf[s->last_lit++] = cc; \
s->dyn_ltree[cc].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
# define _tr_tally_dist(s, distance, length, flush) \
{ uch len = (length); \
ush dist = (distance); \
s->d_buf[s->last_lit] = dist; \
s->l_buf[s->last_lit++] = len; \
dist--; \
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
s->dyn_dtree[d_code(dist)].Freq++; \
flush = (s->last_lit == s->lit_bufsize-1); \
}
#else
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
# define _tr_tally_dist(s, distance, length, flush) \
flush = _tr_tally(s, distance, length)
#endif
#endif /* DEFLATE_H */

1130
utils/zenutils/libraries/zlib123/zlib/example.c Executable file → Normal file

File diff suppressed because it is too large Load diff

2052
utils/zenutils/libraries/zlib123/zlib/gzio.c Executable file → Normal file

File diff suppressed because it is too large Load diff

1246
utils/zenutils/libraries/zlib123/zlib/infback.c Executable file → Normal file

File diff suppressed because it is too large Load diff

636
utils/zenutils/libraries/zlib123/zlib/inffast.c Executable file → Normal file
View file

@ -1,318 +1,318 @@
/* inffast.c -- fast decoding
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
#ifndef ASMINF
/* Allow machine dependent optimization for post-increment or pre-increment.
Based on testing to date,
Pre-increment preferred for:
- PowerPC G3 (Adler)
- MIPS R5000 (Randers-Pehrson)
Post-increment preferred for:
- none
No measurable difference:
- Pentium III (Anderson)
- M68060 (Nikl)
*/
#ifdef POSTINC
# define OFF 0
# define PUP(a) *(a)++
#else
# define OFF 1
# define PUP(a) *++(a)
#endif
/*
Decode literal, length, and distance codes and write out the resulting
literal and match bytes until either not enough input or output is
available, an end-of-block is encountered, or a data error is encountered.
When large enough input and output buffers are supplied to inflate(), for
example, a 16K input buffer and a 64K output buffer, more than 95% of the
inflate execution time is spent in this routine.
Entry assumptions:
state->mode == LEN
strm->avail_in >= 6
strm->avail_out >= 258
start >= strm->avail_out
state->bits < 8
On return, state->mode is one of:
LEN -- ran out of enough output space or enough available input
TYPE -- reached end of block code, inflate() to interpret next block
BAD -- error in block data
Notes:
- The maximum input bits used by a length/distance pair is 15 bits for the
length code, 5 bits for the length extra, 15 bits for the distance code,
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
Therefore if strm->avail_in >= 6, then there is enough input to avoid
checking for available input while decoding.
- The maximum bytes that a single length/distance pair can output is 258
bytes, which is the maximum length that can be coded. inflate_fast()
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
void inflate_fast(strm, start)
z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state;
unsigned char FAR *in; /* local strm->next_in */
unsigned char FAR *last; /* while in < last, enough input available */
unsigned char FAR *out; /* local strm->next_out */
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
unsigned char FAR *end; /* while out < end, enough space available */
#ifdef INFLATE_STRICT
unsigned dmax; /* maximum distance from zlib header */
#endif
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned write; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
unsigned long hold; /* local strm->hold */
unsigned bits; /* local strm->bits */
code const FAR *lcode; /* local strm->lencode */
code const FAR *dcode; /* local strm->distcode */
unsigned lmask; /* mask for first level of length codes */
unsigned dmask; /* mask for first level of distance codes */
code this; /* retrieved table entry */
unsigned op; /* code bits, operation, extra bits, or */
/* window position, window bytes to copy */
unsigned len; /* match length, unused bytes */
unsigned dist; /* match distance */
unsigned char FAR *from; /* where to copy match from */
/* copy state to local variables */
state = (struct inflate_state FAR *)strm->state;
in = strm->next_in - OFF;
last = in + (strm->avail_in - 5);
out = strm->next_out - OFF;
beg = out - (start - strm->avail_out);
end = out + (strm->avail_out - 257);
#ifdef INFLATE_STRICT
dmax = state->dmax;
#endif
wsize = state->wsize;
whave = state->whave;
write = state->write;
window = state->window;
hold = state->hold;
bits = state->bits;
lcode = state->lencode;
dcode = state->distcode;
lmask = (1U << state->lenbits) - 1;
dmask = (1U << state->distbits) - 1;
/* decode literals and length/distances until end-of-block or not enough
input data or output space */
do {
if (bits < 15) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
this = lcode[hold & lmask];
dolen:
op = (unsigned)(this.bits);
hold >>= op;
bits -= op;
op = (unsigned)(this.op);
if (op == 0) { /* literal */
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
"inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", this.val));
PUP(out) = (unsigned char)(this.val);
}
else if (op & 16) { /* length base */
len = (unsigned)(this.val);
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
len += (unsigned)hold & ((1U << op) - 1);
hold >>= op;
bits -= op;
}
Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
this = dcode[hold & dmask];
dodist:
op = (unsigned)(this.bits);
hold >>= op;
bits -= op;
op = (unsigned)(this.op);
if (op & 16) { /* distance base */
dist = (unsigned)(this.val);
op &= 15; /* number of extra bits */
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
}
dist += (unsigned)hold & ((1U << op) - 1);
#ifdef INFLATE_STRICT
if (dist > dmax) {
strm->msg = (char *)"invalid distance too far back";
state->mode = BAD;
break;
}
#endif
hold >>= op;
bits -= op;
Tracevv((stderr, "inflate: distance %u\n", dist));
op = (unsigned)(out - beg); /* max distance in output */
if (dist > op) { /* see if copy from window */
op = dist - op; /* distance back in window */
if (op > whave) {
strm->msg = (char *)"invalid distance too far back";
state->mode = BAD;
break;
}
from = window - OFF;
if (write == 0) { /* very common case */
from += wsize - op;
if (op < len) { /* some from window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
else if (write < op) { /* wrap around window */
from += wsize + write - op;
op -= write;
if (op < len) { /* some from end of window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = window - OFF;
if (write < len) { /* some from start of window */
op = write;
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
}
else { /* contiguous in window */
from += write - op;
if (op < len) { /* some from window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
while (len > 2) {
PUP(out) = PUP(from);
PUP(out) = PUP(from);
PUP(out) = PUP(from);
len -= 3;
}
if (len) {
PUP(out) = PUP(from);
if (len > 1)
PUP(out) = PUP(from);
}
}
else {
from = out - dist; /* copy direct from output */
do { /* minimum length is three */
PUP(out) = PUP(from);
PUP(out) = PUP(from);
PUP(out) = PUP(from);
len -= 3;
} while (len > 2);
if (len) {
PUP(out) = PUP(from);
if (len > 1)
PUP(out) = PUP(from);
}
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
this = dcode[this.val + (hold & ((1U << op) - 1))];
goto dodist;
}
else {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
}
else if ((op & 64) == 0) { /* 2nd level length code */
this = lcode[this.val + (hold & ((1U << op) - 1))];
goto dolen;
}
else if (op & 32) { /* end-of-block */
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
else {
strm->msg = (char *)"invalid literal/length code";
state->mode = BAD;
break;
}
} while (in < last && out < end);
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
len = bits >> 3;
in -= len;
bits -= len << 3;
hold &= (1U << bits) - 1;
/* update state and return */
strm->next_in = in + OFF;
strm->next_out = out + OFF;
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
strm->avail_out = (unsigned)(out < end ?
257 + (end - out) : 257 - (out - end));
state->hold = hold;
state->bits = bits;
return;
}
/*
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- Using bit fields for code structure
- Different op definition to avoid & for extra bits (do & for table bits)
- Three separate decoding do-loops for direct, window, and write == 0
- Special case for distance > 1 copies to do overlapped load and store copy
- Explicit branch predictions (based on measured branch probabilities)
- Deferring match copy and interspersed it with decoding subsequent codes
- Swapping literal/length else
- Swapping window/direct else
- Larger unrolled copy loops (three is about right)
- Moving len -= 3 statement into middle of loop
*/
#endif /* !ASMINF */
/* inffast.c -- fast decoding
* Copyright (C) 1995-2004 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
#ifndef ASMINF
/* Allow machine dependent optimization for post-increment or pre-increment.
Based on testing to date,
Pre-increment preferred for:
- PowerPC G3 (Adler)
- MIPS R5000 (Randers-Pehrson)
Post-increment preferred for:
- none
No measurable difference:
- Pentium III (Anderson)
- M68060 (Nikl)
*/
#ifdef POSTINC
# define OFF 0
# define PUP(a) *(a)++
#else
# define OFF 1
# define PUP(a) *++(a)
#endif
/*
Decode literal, length, and distance codes and write out the resulting
literal and match bytes until either not enough input or output is
available, an end-of-block is encountered, or a data error is encountered.
When large enough input and output buffers are supplied to inflate(), for
example, a 16K input buffer and a 64K output buffer, more than 95% of the
inflate execution time is spent in this routine.
Entry assumptions:
state->mode == LEN
strm->avail_in >= 6
strm->avail_out >= 258
start >= strm->avail_out
state->bits < 8
On return, state->mode is one of:
LEN -- ran out of enough output space or enough available input
TYPE -- reached end of block code, inflate() to interpret next block
BAD -- error in block data
Notes:
- The maximum input bits used by a length/distance pair is 15 bits for the
length code, 5 bits for the length extra, 15 bits for the distance code,
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
Therefore if strm->avail_in >= 6, then there is enough input to avoid
checking for available input while decoding.
- The maximum bytes that a single length/distance pair can output is 258
bytes, which is the maximum length that can be coded. inflate_fast()
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
void inflate_fast(strm, start)
z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state;
unsigned char FAR *in; /* local strm->next_in */
unsigned char FAR *last; /* while in < last, enough input available */
unsigned char FAR *out; /* local strm->next_out */
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
unsigned char FAR *end; /* while out < end, enough space available */
#ifdef INFLATE_STRICT
unsigned dmax; /* maximum distance from zlib header */
#endif
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned write; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
unsigned long hold; /* local strm->hold */
unsigned bits; /* local strm->bits */
code const FAR *lcode; /* local strm->lencode */
code const FAR *dcode; /* local strm->distcode */
unsigned lmask; /* mask for first level of length codes */
unsigned dmask; /* mask for first level of distance codes */
code this; /* retrieved table entry */
unsigned op; /* code bits, operation, extra bits, or */
/* window position, window bytes to copy */
unsigned len; /* match length, unused bytes */
unsigned dist; /* match distance */
unsigned char FAR *from; /* where to copy match from */
/* copy state to local variables */
state = (struct inflate_state FAR *)strm->state;
in = strm->next_in - OFF;
last = in + (strm->avail_in - 5);
out = strm->next_out - OFF;
beg = out - (start - strm->avail_out);
end = out + (strm->avail_out - 257);
#ifdef INFLATE_STRICT
dmax = state->dmax;
#endif
wsize = state->wsize;
whave = state->whave;
write = state->write;
window = state->window;
hold = state->hold;
bits = state->bits;
lcode = state->lencode;
dcode = state->distcode;
lmask = (1U << state->lenbits) - 1;
dmask = (1U << state->distbits) - 1;
/* decode literals and length/distances until end-of-block or not enough
input data or output space */
do {
if (bits < 15) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
this = lcode[hold & lmask];
dolen:
op = (unsigned)(this.bits);
hold >>= op;
bits -= op;
op = (unsigned)(this.op);
if (op == 0) { /* literal */
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
"inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", this.val));
PUP(out) = (unsigned char)(this.val);
}
else if (op & 16) { /* length base */
len = (unsigned)(this.val);
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
len += (unsigned)hold & ((1U << op) - 1);
hold >>= op;
bits -= op;
}
Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
this = dcode[hold & dmask];
dodist:
op = (unsigned)(this.bits);
hold >>= op;
bits -= op;
op = (unsigned)(this.op);
if (op & 16) { /* distance base */
dist = (unsigned)(this.val);
op &= 15; /* number of extra bits */
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
}
dist += (unsigned)hold & ((1U << op) - 1);
#ifdef INFLATE_STRICT
if (dist > dmax) {
strm->msg = (char *)"invalid distance too far back";
state->mode = BAD;
break;
}
#endif
hold >>= op;
bits -= op;
Tracevv((stderr, "inflate: distance %u\n", dist));
op = (unsigned)(out - beg); /* max distance in output */
if (dist > op) { /* see if copy from window */
op = dist - op; /* distance back in window */
if (op > whave) {
strm->msg = (char *)"invalid distance too far back";
state->mode = BAD;
break;
}
from = window - OFF;
if (write == 0) { /* very common case */
from += wsize - op;
if (op < len) { /* some from window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
else if (write < op) { /* wrap around window */
from += wsize + write - op;
op -= write;
if (op < len) { /* some from end of window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = window - OFF;
if (write < len) { /* some from start of window */
op = write;
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
}
else { /* contiguous in window */
from += write - op;
if (op < len) { /* some from window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
while (len > 2) {
PUP(out) = PUP(from);
PUP(out) = PUP(from);
PUP(out) = PUP(from);
len -= 3;
}
if (len) {
PUP(out) = PUP(from);
if (len > 1)
PUP(out) = PUP(from);
}
}
else {
from = out - dist; /* copy direct from output */
do { /* minimum length is three */
PUP(out) = PUP(from);
PUP(out) = PUP(from);
PUP(out) = PUP(from);
len -= 3;
} while (len > 2);
if (len) {
PUP(out) = PUP(from);
if (len > 1)
PUP(out) = PUP(from);
}
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
this = dcode[this.val + (hold & ((1U << op) - 1))];
goto dodist;
}
else {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
}
else if ((op & 64) == 0) { /* 2nd level length code */
this = lcode[this.val + (hold & ((1U << op) - 1))];
goto dolen;
}
else if (op & 32) { /* end-of-block */
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
else {
strm->msg = (char *)"invalid literal/length code";
state->mode = BAD;
break;
}
} while (in < last && out < end);
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
len = bits >> 3;
in -= len;
bits -= len << 3;
hold &= (1U << bits) - 1;
/* update state and return */
strm->next_in = in + OFF;
strm->next_out = out + OFF;
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
strm->avail_out = (unsigned)(out < end ?
257 + (end - out) : 257 - (out - end));
state->hold = hold;
state->bits = bits;
return;
}
/*
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- Using bit fields for code structure
- Different op definition to avoid & for extra bits (do & for table bits)
- Three separate decoding do-loops for direct, window, and write == 0
- Special case for distance > 1 copies to do overlapped load and store copy
- Explicit branch predictions (based on measured branch probabilities)
- Deferring match copy and interspersed it with decoding subsequent codes
- Swapping literal/length else
- Swapping window/direct else
- Larger unrolled copy loops (three is about right)
- Moving len -= 3 statement into middle of loop
*/
#endif /* !ASMINF */

22
utils/zenutils/libraries/zlib123/zlib/inffast.h Executable file → Normal file
View file

@ -1,11 +1,11 @@
/* inffast.h -- header to use inffast.c
* Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
void inflate_fast OF((z_streamp strm, unsigned start));
/* inffast.h -- header to use inffast.c
* Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
void inflate_fast OF((z_streamp strm, unsigned start));

188
utils/zenutils/libraries/zlib123/zlib/inffixed.h Executable file → Normal file
View file

@ -1,94 +1,94 @@
/* inffixed.h -- table for decoding fixed codes
* Generated automatically by makefixed().
*/
/* WARNING: this file should *not* be used by applications. It
is part of the implementation of the compression library and
is subject to change. Applications should only use zlib.h.
*/
static const code lenfix[512] = {
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
{0,9,255}
};
static const code distfix[32] = {
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
{22,5,193},{64,5,0}
};
/* inffixed.h -- table for decoding fixed codes
* Generated automatically by makefixed().
*/
/* WARNING: this file should *not* be used by applications. It
is part of the implementation of the compression library and
is subject to change. Applications should only use zlib.h.
*/
static const code lenfix[512] = {
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
{0,9,255}
};
static const code distfix[32] = {
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
{22,5,193},{64,5,0}
};

2736
utils/zenutils/libraries/zlib123/zlib/inflate.c Executable file → Normal file

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more