Browse Source

Fix MSVC 9 build

coverity_scan
Daniel Scharrer 13 years ago
parent
commit
1a986a8709
  1. 10
      CMakeLists.txt
  2. 2
      src/cli/debug.cpp
  3. 6
      src/cli/main.cpp
  4. 28
      src/crypto/adler32.cpp
  5. 7
      src/crypto/adler32.hpp
  6. 4
      src/crypto/checksum.cpp
  7. 7
      src/crypto/checksum.hpp
  8. 8
      src/crypto/crc32.cpp
  9. 10
      src/crypto/crc32.hpp
  10. 12
      src/crypto/iteratedhash.hpp
  11. 4
      src/crypto/md5.hpp
  12. 4
      src/crypto/sha1.hpp
  13. 87
      src/loader/exereader.cpp
  14. 11
      src/loader/exereader.hpp
  15. 36
      src/loader/offsets.cpp
  16. 17
      src/loader/offsets.hpp
  17. 10
      src/setup/component.cpp
  18. 7
      src/setup/component.hpp
  19. 34
      src/setup/data.cpp
  20. 9
      src/setup/data.hpp
  21. 2
      src/setup/delete.cpp
  22. 6
      src/setup/directory.cpp
  23. 5
      src/setup/directory.hpp
  24. 12
      src/setup/file.cpp
  25. 9
      src/setup/file.hpp
  26. 1
      src/setup/filename.hpp
  27. 72
      src/setup/header.cpp
  28. 13
      src/setup/header.hpp
  29. 8
      src/setup/icon.cpp
  30. 5
      src/setup/icon.hpp
  31. 2
      src/setup/info.cpp
  32. 4
      src/setup/ini.cpp
  33. 16
      src/setup/language.cpp
  34. 7
      src/setup/language.hpp
  35. 4
      src/setup/message.cpp
  36. 5
      src/setup/permission.cpp
  37. 8
      src/setup/registry.cpp
  38. 6
      src/setup/run.cpp
  39. 6
      src/setup/task.cpp
  40. 2
      src/setup/type.cpp
  41. 5
      src/setup/type.hpp
  42. 15
      src/setup/version.hpp
  43. 13
      src/setup/windows.cpp
  44. 20
      src/stream/block.cpp
  45. 2
      src/stream/chunk.cpp
  46. 8
      src/stream/chunk.hpp
  47. 30
      src/stream/exefilter.hpp
  48. 2
      src/stream/file.cpp
  49. 4
      src/stream/file.hpp
  50. 16
      src/stream/lzma.cpp
  51. 13
      src/stream/slice.cpp
  52. 8
      src/stream/slice.hpp
  53. 10
      src/util/console.cpp
  54. 11
      src/util/console.hpp
  55. 32
      src/util/endian.hpp
  56. 2
      src/util/enum.hpp
  57. 14
      src/util/load.cpp
  58. 17
      src/util/load.hpp
  59. 7
      src/util/output.hpp
  60. 26
      src/util/storedenum.hpp
  61. 16
      src/util/time.cpp
  62. 4
      src/util/time.hpp
  63. 16
      src/util/types.hpp
  64. 15
      src/util/util.hpp

10
CMakeLists.txt

@ -35,6 +35,14 @@ include(VersionString)
# Find required libraries
# Win32 API
if(WIN32)
# Ensure we aren't using functionalities not found under Window XP SP1
add_definitions(-D_WIN32_WINNT=0x0502)
add_definitions(-DNOMINMAX)
add_definitions(-DWIN32_LEAN_AND_MEAN)
endif()
if(USE_STATIC_LIBS)
add_cxxflag("-static-libgcc")
add_cxxflag("-static-libstdc++")
@ -131,7 +139,7 @@ if(NOT INNOEXTRACT_HAVE_TIMEGM)
endif()
check_symbol_exists(gmtime_r "time.h" INNOEXTRACT_HAVE_GMTIME_R)
if(NOT INNOEXTRACT_HAVE_GMTIME_R)
check_symbol_exists(_gmtime_s "time.h" INNOEXTRACT_HAVE_GMTIME_S)
check_symbol_exists(gmtime_s "time.h" INNOEXTRACT_HAVE_GMTIME_S)
endif()
if(NOT WIN32)
check_symbol_exists(utimensat "sys/stat.h" INNOEXTRACT_HAVE_UTIMENSAT)

2
src/cli/debug.cpp

@ -219,7 +219,7 @@ static void print_entry(const setup::info & info, size_t i, const setup::file_en
} else {
cout << " - " << quoted(entry.destination);
}
if(entry.location != uint32_t(-1)) {
if(entry.location != boost::uint32_t(-1)) {
cout << " (location: " << color::cyan << entry.location << color::reset << ')';
}
cout << '\n';

6
src/cli/main.cpp

@ -190,7 +190,7 @@ static void process_file(const fs::path & file, const options & o) {
}
#endif
uint64_t total_size = 0;
boost::uint64_t total_size = 0;
std::vector< std::vector<size_t> > files_for_location;
files_for_location.resize(info.data_entries.size());
@ -235,7 +235,7 @@ static void process_file(const fs::path & file, const options & o) {
chunk_source = stream::chunk_reader::get(*slice_reader, chunk.first);
}
uint64_t offset = 0;
boost::uint64_t offset = 0;
BOOST_FOREACH(const Files::value_type & location, chunk.second) {
const stream::file & file = location.first;
@ -351,7 +351,7 @@ static void process_file(const fs::path & file, const options & o) {
+ out.name.string() + '"');
}
}
extract_progress.update(uint64_t(n));
extract_progress.update(boost::uint64_t(n));
}
}

28
src/crypto/adler32.cpp

@ -27,15 +27,15 @@ namespace crypto {
void adler32::update(const char * input, size_t length) {
const uint_fast32_t base = 65521;
const boost::uint_fast32_t base = 65521;
uint_fast32_t s1 = this->s1;
uint_fast32_t s2 = this->s2;
boost::uint_fast32_t s1 = this->s1;
boost::uint_fast32_t s2 = this->s2;
if(length % 8 != 0) {
do {
s1 += uint8_t(*input++);
s1 += boost::uint8_t(*input++);
s2 += s1;
length--;
} while(length % 8 != 0);
@ -49,14 +49,14 @@ void adler32::update(const char * input, size_t length) {
while(length > 0) {
s1 += uint8_t(input[0]), s2 += s1;
s1 += uint8_t(input[1]), s2 += s1;
s1 += uint8_t(input[2]), s2 += s1;
s1 += uint8_t(input[3]), s2 += s1;
s1 += uint8_t(input[4]), s2 += s1;
s1 += uint8_t(input[5]), s2 += s1;
s1 += uint8_t(input[6]), s2 += s1;
s1 += uint8_t(input[7]), s2 += s1;
s1 += boost::uint8_t(input[0]), s2 += s1;
s1 += boost::uint8_t(input[1]), s2 += s1;
s1 += boost::uint8_t(input[2]), s2 += s1;
s1 += boost::uint8_t(input[3]), s2 += s1;
s1 += boost::uint8_t(input[4]), s2 += s1;
s1 += boost::uint8_t(input[5]), s2 += s1;
s1 += boost::uint8_t(input[6]), s2 += s1;
s1 += boost::uint8_t(input[7]), s2 += s1;
length -= 8;
input += 8;
@ -70,8 +70,8 @@ void adler32::update(const char * input, size_t length) {
}
}
this->s1 = uint16_t(s1);
this->s2 = uint16_t(s2);
this->s1 = boost::uint16_t(s1);
this->s2 = boost::uint16_t(s2);
}
} // namespace crypto

7
src/crypto/adler32.hpp

@ -22,7 +22,8 @@
#define INNOEXTRACT_CRYPTO_ADLER32_HPP
#include <stddef.h>
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "crypto/checksum.hpp"
@ -35,11 +36,11 @@ struct adler32 : public checksum_base<adler32> {
void update(const char * data, size_t length);
uint32_t finalize() const { return (uint32_t(s2) << 16) | s1; }
boost::uint32_t finalize() const { return (boost::uint32_t(s2) << 16) | s1; }
private:
uint16_t s1, s2;
boost::uint16_t s1, s2;
};
} // namespace crypto

4
src/crypto/checksum.cpp

@ -68,13 +68,13 @@ std::ostream & operator<<(std::ostream & os, const crypto::checksum & checksum)
}
case crypto::MD5: {
for(size_t i = 0; i < ARRAY_SIZE(checksum.md5); i++) {
os << std::setfill('0') << std::hex << std::setw(2) << int(uint8_t(checksum.md5[i]));
os << std::setfill('0') << std::hex << std::setw(2) << int(boost::uint8_t(checksum.md5[i]));
}
break;
}
case crypto::SHA1: {
for(size_t i = 0; i < ARRAY_SIZE(checksum.sha1); i++) {
os << std::setfill('0') << std::hex << std::setw(2) << int(uint8_t(checksum.sha1[i]));
os << std::setfill('0') << std::hex << std::setw(2) << int(boost::uint8_t(checksum.sha1[i]));
}
break;
}

7
src/crypto/checksum.hpp

@ -21,11 +21,12 @@
#ifndef INNOEXTRACT_CRYPTO_CHECKSUM_HPP
#define INNOEXTRACT_CRYPTO_CHECKSUM_HPP
#include <stdint.h>
#include <cstring>
#include <iosfwd>
#include <istream>
#include <boost/cstdint.hpp>
#include "util/endian.hpp"
#include "util/enum.hpp"
#include "util/types.hpp"
@ -42,8 +43,8 @@ enum checksum_type {
struct checksum {
union {
uint32_t adler32;
uint32_t crc32;
boost::uint32_t adler32;
boost::uint32_t crc32;
char md5[16];
char sha1[20];
};

8
src/crypto/crc32.cpp

@ -38,7 +38,7 @@ namespace crypto {
#endif
/* Table of CRC-32's of all single byte values (made by makecrc.c) */
const uint32_t crc32::table[] = {
const boost::uint32_t crc32::table[] = {
#if INNOEXTRACT_ENDIANNESS == LITTLE_ENDIAN
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
@ -151,11 +151,11 @@ const uint32_t crc32::table[] = {
void crc32::update(const char * s, size_t n) {
for(; (size_t(s) % 4 != 0) && n > 0; n--) {
crc = table[CRC32_INDEX(crc) ^ uint8_t(*s++)] ^ CRC32_SHIFTED(crc);
crc = table[CRC32_INDEX(crc) ^ boost::uint8_t(*s++)] ^ CRC32_SHIFTED(crc);
}
while(n >= 4) {
crc ^= *reinterpret_cast<const uint32_t *>(s);
crc ^= *reinterpret_cast<const boost::uint32_t *>(s);
crc = table[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = table[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
crc = table[CRC32_INDEX(crc)] ^ CRC32_SHIFTED(crc);
@ -165,7 +165,7 @@ void crc32::update(const char * s, size_t n) {
}
while(n--) {
crc = table[CRC32_INDEX(crc) ^ uint8_t(*s++)] ^ CRC32_SHIFTED(crc);
crc = table[CRC32_INDEX(crc) ^ boost::uint8_t(*s++)] ^ CRC32_SHIFTED(crc);
}
}

10
src/crypto/crc32.hpp

@ -21,7 +21,7 @@
#ifndef INNOEXTRACT_CRYPTO_CRC32_HPP
#define INNOEXTRACT_CRYPTO_CRC32_HPP
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "crypto/checksum.hpp"
@ -34,14 +34,14 @@ struct crc32 : public checksum_base<crc32> {
void update(const char * data, size_t length);
uint32_t finalize() const { return crc ^ CRC32_NEGL; }
boost::uint32_t finalize() const { return crc ^ CRC32_NEGL; }
private:
static const uint32_t CRC32_NEGL = 0xffffffffl;
static const boost::uint32_t CRC32_NEGL = 0xffffffffl;
static const uint32_t table[256];
uint32_t crc;
static const boost::uint32_t table[256];
boost::uint32_t crc;
};
} // namespace crypto

12
src/crypto/iteratedhash.hpp

@ -23,8 +23,10 @@
// Taken from Crypto++ and modified to fit the project.
#include <stdint.h>
#include <cstring>
#include <boost/cstdint.hpp>
#include "crypto/checksum.hpp"
#include "util/endian.hpp"
#include "util/types.hpp"
@ -52,7 +54,7 @@ public:
private:
size_t hash(const hash_word * input, size_t length);
void pad(size_t last_block_size, uint8_t pad_first = 0x80);
void pad(size_t last_block_size, boost::uint8_t pad_first = 0x80);
hash_word bit_count_hi() const {
return (count_lo >> (8 * sizeof(hash_word) - 3)) + (count_hi << 3);
@ -78,7 +80,7 @@ void iterated_hash<T>::update(const char * input, size_t len) {
count_hi += hash_word(safe_right_shift<8 * sizeof(hash_word)>(len));
size_t num = mod_power_of_2(old_count_lo, size_t(block_size));
uint8_t * d = reinterpret_cast<uint8_t *>(data);
boost::uint8_t * d = reinterpret_cast<boost::uint8_t *>(data);
if(num != 0) { // process left over data
if(num + len >= block_size) {
@ -137,11 +139,11 @@ size_t iterated_hash<T>::hash(const hash_word * input, size_t length) {
}
template <class T>
void iterated_hash<T>::pad(size_t last_block_size, uint8_t pad_first) {
void iterated_hash<T>::pad(size_t last_block_size, boost::uint8_t pad_first) {
size_t num = mod_power_of_2(count_lo, size_t(block_size));
uint8_t * d = reinterpret_cast<uint8_t *>(data);
boost::uint8_t * d = reinterpret_cast<boost::uint8_t *>(data);
d[num++] = pad_first;

4
src/crypto/md5.hpp

@ -21,7 +21,7 @@
#ifndef INNOEXTRACT_CRYPTO_MD5_HPP
#define INNOEXTRACT_CRYPTO_MD5_HPP
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "crypto/iteratedhash.hpp"
#include "util/endian.hpp"
@ -32,7 +32,7 @@ class md5_transform {
public:
typedef uint32_t hash_word;
typedef boost::uint32_t hash_word;
typedef little_endian byte_order;
static const size_t block_size = 64;
static const size_t hash_size = 16;

4
src/crypto/sha1.hpp

@ -21,7 +21,7 @@
#ifndef INNOEXTRACT_CRYPTO_SHA1_HPP
#define INNOEXTRACT_CRYPTO_SHA1_HPP
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "crypto/iteratedhash.hpp"
#include "util/endian.hpp"
@ -32,7 +32,7 @@ class sha1_transform {
public:
typedef uint32_t hash_word;
typedef boost::uint32_t hash_word;
typedef big_endian byte_order;
static const size_t block_size = 64;
static const size_t hash_size = 20;

87
src/loader/exereader.cpp

@ -20,13 +20,14 @@
#include "loader/exereader.hpp"
#include <stdint.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstring>
#include <vector>
#include <boost/cstdint.hpp>
#include "util/load.hpp"
namespace loader {
@ -38,22 +39,22 @@ struct exe_reader_impl : public exe_reader {
struct header {
//! Number of CoffSection structures following this header after optionalHeaderSize bytes
uint16_t nsections;
boost::uint16_t nsections;
//! Offset of the section table in the file
uint32_t section_table_offset;
boost::uint32_t section_table_offset;
//! Virtual memory address of the resource root table
uint32_t resource_table_address;
boost::uint32_t resource_table_address;
};
struct section {
uint32_t virtual_size; //!< Section size in virtual memory
uint32_t virtual_address; //!< Base virtual memory address
boost::uint32_t virtual_size; //!< Section size in virtual memory
boost::uint32_t virtual_address; //!< Base virtual memory address
uint32_t raw_address; //!< Base file offset
boost::uint32_t raw_address; //!< Base file offset
};
@ -70,7 +71,7 @@ struct exe_reader_impl : public exe_reader {
* Remaining 31 bits: Offset to the resource table / leaf relative to
* the directory start.
*/
static uint32_t find_resource_entry(std::istream & is, uint32_t id);
static boost::uint32_t find_resource_entry(std::istream & is, boost::uint32_t id);
static bool load_header(std::istream & is, header & coff);
@ -79,25 +80,25 @@ struct exe_reader_impl : public exe_reader {
/*!
* Convert a memory address to a file offset according to the given section list.
*/
static uint32_t to_file_offset(const section_list & sections, uint32_t address);
static boost::uint32_t to_file_offset(const section_list & sections, boost::uint32_t address);
static resource find_resource(std::istream & is, uint32_t name, uint32_t type = TypeData,
uint32_t language = LanguageDefault);
static resource find_resource(std::istream & is, boost::uint32_t name, boost::uint32_t type = TypeData,
boost::uint32_t language = LanguageDefault);
};
static const char PE_MAGIC[] = { 'P', 'E', 0, 0 };
bool get_resource_table(uint32_t & entry, uint32_t resource_offset) {
bool get_resource_table(boost::uint32_t & entry, boost::uint32_t resource_offset) {
bool is_table = (entry & (uint32_t(1) << 31));
bool is_table = (entry & (boost::uint32_t(1) << 31));
entry &= ~(1 << 31), entry += resource_offset;
return is_table;
}
uint32_t exe_reader_impl::find_resource_entry(std::istream & is, uint32_t needle) {
boost::uint32_t exe_reader_impl::find_resource_entry(std::istream & is, boost::uint32_t needle) {
// skip: characteristics + timestamp + major version + minor version
if(is.seekg(4 + 4 + 2 + 2, std::ios_base::cur).fail()) {
@ -105,22 +106,22 @@ uint32_t exe_reader_impl::find_resource_entry(std::istream & is, uint32_t needle
}
// Number of named resource entries.
uint16_t nbnames = load_number<uint16_t>(is);
boost::uint16_t nbnames = load_number<boost::uint16_t>(is);
// Number of id resource entries.
uint16_t nbids = load_number<uint16_t>(is);
boost::uint16_t nbids = load_number<boost::uint16_t>(is);
// Ignore named resource entries.
const uint32_t entry_size = 4 + 4; // id / string address + offset
const boost::uint32_t entry_size = 4 + 4; // id / string address + offset
if(is.seekg(nbnames * entry_size, std::ios_base::cur).fail()) {
return 0;
}
for(size_t i = 0; i < nbids; i++) {
uint32_t id = load_number<uint32_t>(is);
uint32_t offset = load_number<uint32_t>(is);
boost::uint32_t id = load_number<boost::uint32_t>(is);
boost::uint32_t offset = load_number<boost::uint32_t>(is);
if(is.fail()) {
return 0;
}
@ -136,7 +137,7 @@ uint32_t exe_reader_impl::find_resource_entry(std::istream & is, uint32_t needle
bool exe_reader_impl::load_header(std::istream & is, header & coff) {
// Skip the DOS stub.
uint16_t peOffset = load_number<uint16_t>(is.seekg(0x3c));
boost::uint16_t peOffset = load_number<boost::uint16_t>(is.seekg(0x3c));
if(is.fail()) {
return false;
}
@ -150,15 +151,15 @@ bool exe_reader_impl::load_header(std::istream & is, header & coff) {
}
is.seekg(2, std::ios_base::cur); // machine
coff.nsections = load_number<uint16_t>(is);
coff.nsections = load_number<boost::uint16_t>(is);
is.seekg(4 + 4 + 4, std::ios_base::cur); // creation time + symbol table offset + nbsymbols
uint16_t optional_header_size = load_number<uint16_t>(is);
boost::uint16_t optional_header_size = load_number<boost::uint16_t>(is);
is.seekg(2, std::ios_base::cur); // characteristics
coff.section_table_offset = uint32_t(is.tellg()) + optional_header_size;
coff.section_table_offset = boost::uint32_t(is.tellg()) + optional_header_size;
// Skip the optional header.
uint16_t optionalHeaderMagic = load_number<uint16_t>(is);
boost::uint16_t optionalHeaderMagic = load_number<boost::uint16_t>(is);
if(is.fail()) {
return false;
}
@ -168,16 +169,16 @@ bool exe_reader_impl::load_header(std::istream & is, header & coff) {
is.seekg(90, std::ios_base::cur);
}
uint32_t ndirectories = load_number<uint32_t>(is);
boost::uint32_t ndirectories = load_number<boost::uint32_t>(is);
if(is.fail() || ndirectories < 3) {
return false;
}
const uint32_t directory_header_size = 4 + 4; // address + size
const boost::uint32_t directory_header_size = 4 + 4; // address + size
is.seekg(2 * directory_header_size, std::ios_base::cur);
// Virtual memory address and size of the start of resource directory.
coff.resource_table_address = load_number<uint32_t>(is);
uint32_t resource_size = load_number<uint32_t>(is);
coff.resource_table_address = load_number<boost::uint32_t>(is);
boost::uint32_t resource_size = load_number<boost::uint32_t>(is);
if(is.fail() || !coff.resource_table_address || !resource_size) {
return false;
}
@ -196,11 +197,11 @@ bool exe_reader_impl::load_section_list(std::istream & is, const header & coff,
is.seekg(8, std::ios_base::cur); // name
section.virtual_size = load_number<uint32_t>(is);
section.virtual_address = load_number<uint32_t>(is);
section.virtual_size = load_number<boost::uint32_t>(is);
section.virtual_address = load_number<boost::uint32_t>(is);
is.seekg(4, std::ios_base::cur); // raw size
section.raw_address = load_number<uint32_t>(is);
section.raw_address = load_number<boost::uint32_t>(is);
// relocation addr + line number addr + relocation count
// + line number count + characteristics
@ -211,7 +212,7 @@ bool exe_reader_impl::load_section_list(std::istream & is, const header & coff,
return !is.fail();
}
uint32_t exe_reader_impl::to_file_offset(const section_list & sections, uint32_t memory) {
boost::uint32_t exe_reader_impl::to_file_offset(const section_list & sections, boost::uint32_t memory) {
for(section_list::const_iterator i = sections.begin(); i != sections.end(); ++i) {
const section & s = *i;
@ -223,8 +224,8 @@ uint32_t exe_reader_impl::to_file_offset(const section_list & sections, uint32_t
return 0;
}
exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, uint32_t name,
uint32_t type, uint32_t language) {
exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, boost::uint32_t name,
boost::uint32_t type, boost::uint32_t language) {
is.seekg(0);
@ -241,39 +242,39 @@ exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, uint
return result;
}
uint32_t resource_offset = to_file_offset(sections, coff.resource_table_address);
boost::uint32_t resource_offset = to_file_offset(sections, coff.resource_table_address);
if(!resource_offset) {
return result;
}
is.seekg(resource_offset);
uint32_t type_offset = find_resource_entry(is, type);
boost::uint32_t type_offset = find_resource_entry(is, type);
if(!get_resource_table(type_offset, resource_offset)) {
return result;
}
is.seekg(type_offset);
uint32_t name_offset = find_resource_entry(is, name);
boost::uint32_t name_offset = find_resource_entry(is, name);
if(!get_resource_table(name_offset, resource_offset)) {
return result;
}
is.seekg(name_offset);
uint32_t leaf_offset = find_resource_entry(is, language);
boost::uint32_t leaf_offset = find_resource_entry(is, language);
if(!leaf_offset || get_resource_table(leaf_offset, resource_offset)) {
return result;
}
// Virtual memory address and size of the resource data.
is.seekg(leaf_offset);
uint32_t data_address = load_number<uint32_t>(is);
uint32_t data_size = load_number<uint32_t>(is);
boost::uint32_t data_address = load_number<boost::uint32_t>(is);
boost::uint32_t data_size = load_number<boost::uint32_t>(is);
// ignore codepage and reserved word
if(is.fail()) {
return result;
}
uint32_t data_offset = to_file_offset(sections, data_address);
boost::uint32_t data_offset = to_file_offset(sections, data_address);
if(!data_offset) {
return result;
}
@ -286,8 +287,8 @@ exe_reader_impl::resource exe_reader_impl::find_resource(std::istream & is, uint
} // anonymous namespace
exe_reader::resource exe_reader::find_resource(std::istream & is, uint32_t name,
uint32_t type, uint32_t language) {
exe_reader::resource exe_reader::find_resource(std::istream & is, boost::uint32_t name,
boost::uint32_t type, boost::uint32_t language) {
return exe_reader_impl::find_resource(is, name, type, language);
}

11
src/loader/exereader.hpp

@ -21,9 +21,10 @@
#ifndef INNOEXTRACT_LOADER_EXEREADER_HPP
#define INNOEXTRACT_LOADER_EXEREADER_HPP
#include <stdint.h>
#include <istream>
#include <boost/cstdint.hpp>
namespace loader {
/*!
@ -38,9 +39,9 @@ public:
//! Position and size of a resource entry
struct resource {
uint32_t offset; //!< File offset of the resource data in bytes
boost::uint32_t offset; //!< File offset of the resource data in bytes
uint32_t size; //!< Size of the resource data in bytes
boost::uint32_t size; //!< Size of the resource data in bytes
};
@ -61,8 +62,8 @@ public:
*
* \return the location of the resource or `(0, 0)` if the requested resource does not exist.
*/
static resource find_resource(std::istream & is, uint32_t name, uint32_t type = TypeData,
uint32_t language = LanguageDefault);
static resource find_resource(std::istream & is, boost::uint32_t name, boost::uint32_t type = TypeData,
boost::uint32_t language = LanguageDefault);
};

36
src/loader/offsets.cpp

@ -20,9 +20,9 @@
#include "loader/offsets.hpp"
#include <stdint.h>
#include <cstring>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <stddef.h>
@ -57,8 +57,8 @@ const setup_loader_version known_setup_loader_versions[] = {
const int ResourceNameInstaller = 11111;
const uint32_t SetupLoaderHeaderOffset = 0x30;
const uint32_t SetupLoaderHeaderMagic = 0x6f6e6e49;
const boost::uint32_t SetupLoaderHeaderOffset = 0x30;
const boost::uint32_t SetupLoaderHeaderMagic = 0x6f6e6e49;
} // anonymous namespace
@ -66,14 +66,14 @@ bool offsets::load_from_exe_file(std::istream & is) {
is.seekg(SetupLoaderHeaderOffset);
uint32_t magic = load_number<uint32_t>(is);
boost::uint32_t magic = load_number<boost::uint32_t>(is);
if(is.fail() || magic != SetupLoaderHeaderMagic) {
is.clear();
return false;
}
uint32_t offset_table_offset = load_number<uint32_t>(is);
uint32_t not_offset_table_offset = load_number<uint32_t>(is);
boost::uint32_t offset_table_offset = load_number<boost::uint32_t>(is);
boost::uint32_t not_offset_table_offset = load_number<boost::uint32_t>(is);
if(is.fail() || offset_table_offset != ~not_offset_table_offset) {
is.clear();
return false;
@ -93,7 +93,7 @@ bool offsets::load_from_exe_resource(std::istream & is) {
return load_offsets_at(is, resource.offset);
}
bool offsets::load_offsets_at(std::istream & is, uint32_t pos) {
bool offsets::load_offsets_at(std::istream & is, boost::uint32_t pos) {
if(is.seekg(pos).fail()) {
is.clear();
@ -124,40 +124,40 @@ bool offsets::load_offsets_at(std::istream & is, uint32_t pos) {
checksum.update(magic, ARRAY_SIZE(magic));
if(version >= INNO_VERSION(5, 1, 5)) {
uint32_t revision = checksum.load_number<uint32_t>(is);
boost::uint32_t revision = checksum.load_number<boost::uint32_t>(is);
if(is.fail() || revision != 1) {
is.clear();
return false;
}
}
(void)checksum.load_number<uint32_t>(is);
exe_offset = checksum.load_number<uint32_t>(is);
(void)checksum.load_number<boost::uint32_t>(is);
exe_offset = checksum.load_number<boost::uint32_t>(is);
if(version >= INNO_VERSION(4, 1, 6)) {
exe_compressed_size = 0;
} else {
exe_compressed_size = checksum.load_number<uint32_t>(is);
exe_compressed_size = checksum.load_number<boost::uint32_t>(is);
}
exe_uncompressed_size = checksum.load_number<uint32_t>(is);
exe_uncompressed_size = checksum.load_number<boost::uint32_t>(is);
if(version >= INNO_VERSION(4, 0, 3)) {
exe_checksum.type = crypto::CRC32;
exe_checksum.crc32 = checksum.load_number<uint32_t>(is);
exe_checksum.crc32 = checksum.load_number<boost::uint32_t>(is);
} else {
exe_checksum.type = crypto::Adler32;
exe_checksum.adler32 = checksum.load_number<uint32_t>(is);
exe_checksum.adler32 = checksum.load_number<boost::uint32_t>(is);
}
if(version >= INNO_VERSION(4, 0, 0)) {
message_offset = 0;
} else {
message_offset = load_number<uint32_t>(is);
message_offset = load_number<boost::uint32_t>(is);
}
header_offset = checksum.load_number<uint32_t>(is);
data_offset = checksum.load_number<uint32_t>(is);
header_offset = checksum.load_number<boost::uint32_t>(is);
data_offset = checksum.load_number<boost::uint32_t>(is);
if(is.fail()) {
is.clear();
@ -165,7 +165,7 @@ bool offsets::load_offsets_at(std::istream & is, uint32_t pos) {
}
if(version >= INNO_VERSION(4, 0, 10)) {
uint32_t expected = load_number<uint32_t>(is);
boost::uint32_t expected = load_number<boost::uint32_t>(is);
if(is.fail()) {
is.clear();
return false;

17
src/loader/offsets.hpp

@ -21,9 +21,10 @@
#ifndef INNOEXTRACT_LOADER_OFFSETS_HPP
#define INNOEXTRACT_LOADER_OFFSETS_HPP
#include <stdint.h>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "crypto/checksum.hpp"
namespace loader {
@ -49,17 +50,17 @@ struct offsets {
*
* A value of \c 0 means there is no setup.e32 embedded in this file
*/
uint32_t exe_offset;
boost::uint32_t exe_offset;
/*!
* Size of `setup.e32` after compression, in bytes
*
* A value of \c 0 means the executable size is not known
*/
uint32_t exe_compressed_size;
boost::uint32_t exe_compressed_size;
//! Size of `setup.e32` before compression, in bytes
uint32_t exe_uncompressed_size;
boost::uint32_t exe_uncompressed_size;
/*!
* Checksum of `setup.e32` before compression
@ -69,7 +70,7 @@ struct offsets {
crypto::checksum exe_checksum;
//! Offset of embedded setup messages
uint32_t message_offset;
boost::uint32_t message_offset;
/*!
* Offset of embedded `setup-0.bin` data (the setup headers)
@ -82,7 +83,7 @@ struct offsets {
*
* Loading the version and headers is done in \ref setup::info.
*/
uint32_t header_offset;
boost::uint32_t header_offset;
/*!
* Offset of embedded `setup-1.bin` data
@ -98,7 +99,7 @@ struct offsets {
* The layout of the chunks and files is stored in the \ref setup::data_entry headers
* while the \ref setup::file_entry headers provide the filenames and meta information.
*/
uint32_t data_offset;
boost::uint32_t data_offset;
/*!
* \brief Find the setup loader offsets in a file
@ -117,7 +118,7 @@ private:
bool load_from_exe_resource(std::istream & is);
bool load_offsets_at(std::istream & is, uint32_t pos);
bool load_offsets_at(std::istream & is, boost::uint32_t pos);
};

10
src/setup/component.cpp

@ -70,14 +70,14 @@ void component_entry::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(4, 0, 0)) {
extra_disk_pace_required = load_number<uint64_t>(is);
extra_disk_pace_required = load_number<boost::uint64_t>(is);
} else {
extra_disk_pace_required = load_number<uint32_t>(is);
extra_disk_pace_required = load_number<boost::uint32_t>(is);
}
if(version >= INNO_VERSION_EXT(3, 0, 6, 1)) {
level = load_number<int32_t>(is);
used = load_number<uint8_t>(is);
level = load_number<boost::int32_t>(is);
used = load_number<boost::uint8_t>(is);
} else {
level = 0, used = true;
}
@ -92,7 +92,7 @@ void component_entry::load(std::istream & is, const version & version) {
options = stored_flags<stored_component_flags_0>(is).get();
}
size = (version >= INNO_VERSION(4, 0, 0)) ? load_number<uint64_t>(is) : load_number<uint32_t>(is);
size = (version >= INNO_VERSION(4, 0, 0)) ? load_number<boost::uint64_t>(is) : load_number<boost::uint32_t>(is);
}
} // namespace setup

7
src/setup/component.hpp

@ -21,10 +21,11 @@
#ifndef INNOEXTRACT_SETUP_COMPONENT_HPP
#define INNOEXTRACT_SETUP_COMPONENT_HPP
#include <stdint.h>
#include <string>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "setup/windows.hpp"
#include "util/enum.hpp"
#include "util/flags.hpp"
@ -51,7 +52,7 @@ struct component_entry {
std::string languages;
std::string check;
uint64_t extra_disk_pace_required;
boost::uint64_t extra_disk_pace_required;
int level;
bool used;
@ -60,7 +61,7 @@ struct component_entry {
flags options;
uint64_t size;
boost::uint64_t size;
void load(std::istream & is, const version & version);

34
src/setup/data.cpp

@ -31,8 +31,8 @@ namespace setup {
void data_entry::load(std::istream & is, const version & version) {
chunk.first_slice = load_number<uint32_t>(is, version.bits);
chunk.last_slice = load_number<uint32_t>(is, version.bits);
chunk.first_slice = load_number<boost::uint32_t>(is, version.bits);
chunk.last_slice = load_number<boost::uint32_t>(is, version.bits);
if(version < INNO_VERSION(4, 0, 0)) {
if(chunk.first_slice < 1 || chunk.last_slice < 1) {
log_warning << "[file location] unexpected disk number: " << chunk.first_slice
@ -42,20 +42,20 @@ void data_entry::load(std::istream & is, const version & version) {
}
}
chunk.offset = load_number<uint32_t>(is);
chunk.offset = load_number<boost::uint32_t>(is);
if(version >= INNO_VERSION(4, 0, 1)) {
file.offset = load_number<uint64_t>(is);
file.offset = load_number<boost::uint64_t>(is);
} else {
file.offset = 0;
}
if(version >= INNO_VERSION(4, 0, 0)) {
file.size = load_number<uint64_t>(is);
chunk.size = load_number<uint64_t>(is);
file.size = load_number<boost::uint64_t>(is);
chunk.size = load_number<boost::uint64_t>(is);
} else {
file.size = load_number<uint32_t>(is);
chunk.size = load_number<uint32_t>(is);
file.size = load_number<boost::uint32_t>(is);
chunk.size = load_number<boost::uint32_t>(is);
}
if(version >= INNO_VERSION(5, 3, 9)) {
@ -65,10 +65,10 @@ void data_entry::load(std::istream & is, const version & version) {
is.read(file.checksum.md5, std::streamsize(sizeof(file.checksum.md5)));
file.checksum.type = crypto::MD5;
} else if(version >= INNO_VERSION(4, 0, 1)) {
file.checksum.crc32 = load_number<uint32_t>(is);
file.checksum.crc32 = load_number<boost::uint32_t>(is);
file.checksum.type = crypto::CRC32;
} else {
file.checksum.adler32 = load_number<uint32_t>(is);
file.checksum.adler32 = load_number<boost::uint32_t>(is);
file.checksum.type = crypto::Adler32;
}
@ -76,8 +76,8 @@ void data_entry::load(std::istream & is, const version & version) {
// 16-bit installers use the FAT filetime format
uint16_t time = load_number<uint16_t>(is);
uint16_t date = load_number<uint16_t>(is);
boost::uint16_t time = load_number<boost::uint16_t>(is);
boost::uint16_t date = load_number<boost::uint16_t>(is);
struct tm t;
t.tm_sec = get_bits(time, 0, 4) * 2; // [0, 58]
@ -94,21 +94,21 @@ void data_entry::load(std::istream & is, const version & version) {
// 32-bit installers use the Win32 FILETIME format
int64_t filetime = load_number<int64_t>(is);
boost::int64_t filetime = load_number<boost::int64_t>(is);
static const int64_t FiletimeOffset = 0x19DB1DED53E8000ll;
static const boost::int64_t FiletimeOffset = 0x19DB1DED53E8000ll;
if(filetime < FiletimeOffset) {
log_warning << "[file location] unexpected filetime: " << filetime;
}
filetime -= FiletimeOffset;
timestamp = std::time_t(filetime / 10000000);
timestamp_nsec = uint32_t(filetime % 10000000) * 100;
timestamp_nsec = boost::uint32_t(filetime % 10000000) * 100;
}
file_version_ms = load_number<uint32_t>(is);
file_version_ls = load_number<uint32_t>(is);
file_version_ms = load_number<boost::uint32_t>(is);
file_version_ls = load_number<boost::uint32_t>(is);
options = 0;

9
src/setup/data.hpp

@ -22,10 +22,11 @@
#define INNOEXTRACT_SETUP_DATA_HPP
#include <stddef.h>
#include <stdint.h>
#include <ctime>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "crypto/checksum.hpp"
#include "stream/chunk.hpp"
#include "stream/file.hpp"
@ -59,10 +60,10 @@ struct data_entry {
stream::file file;
std::time_t timestamp;
uint32_t timestamp_nsec;
boost::uint32_t timestamp_nsec;
uint32_t file_version_ms;
uint32_t file_version_ls;
boost::uint32_t file_version_ms;
boost::uint32_t file_version_ls;
flags options;

2
src/setup/delete.cpp

@ -39,7 +39,7 @@ STORED_ENUM_MAP(delete_target_type_map, delete_entry::Files,
void delete_entry::load(std::istream & is, const version & version) {
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the directory entry structure
::load<boost::uint32_t>(is); // uncompressed size of the directory entry structure
}
is >> encoded_string(name, version.codepage());

6
src/setup/directory.cpp

@ -48,7 +48,7 @@ STORED_FLAGS_MAP(stored_inno_directory_options_1,
void directory_entry::load(std::istream & is, const version & version) {
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the directory entry structure
::load<boost::uint32_t>(is); // uncompressed size of the directory entry structure
}
is >> encoded_string(name, version.codepage());
@ -62,7 +62,7 @@ void directory_entry::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(2, 0, 11)) {
attributes = load_number<uint32_t>(is);
attributes = load_number<boost::uint32_t>(is);
} else {
attributes = 0;
}
@ -70,7 +70,7 @@ void directory_entry::load(std::istream & is, const version & version) {
load_version_data(is, version);
if(version >= INNO_VERSION(4, 1, 0)) {
permission = load_number<int16_t>(is);
permission = load_number<boost::int16_t>(is);
} else {
permission = -1;
}

5
src/setup/directory.hpp

@ -21,10 +21,11 @@
#ifndef INNOEXTRACT_SETUP_DIRECTORY_HPP
#define INNOEXTRACT_SETUP_DIRECTORY_HPP
#include <stdint.h>
#include <string>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "setup/item.hpp"
#include "util/enum.hpp"
#include "util/flags.hpp"
@ -46,7 +47,7 @@ struct directory_entry : public item {
std::string name;
std::string permissions;
uint32_t attributes;
boost::uint32_t attributes;
int permission; //!< index into the permission entry list

12
src/setup/file.cpp

@ -77,7 +77,7 @@ void file_entry::load(std::istream & is, const version & version) {
options = 0;
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the file entry structure
::load<boost::uint32_t>(is); // uncompressed size of the file entry structure
}
is >> encoded_string(source, version.codepage());
@ -93,10 +93,10 @@ void file_entry::load(std::istream & is, const version & version) {
load_version_data(is, version);
location = load_number<uint32_t>(is, version.bits);
attributes = load_number<uint32_t>(is, version.bits);
external_size = (version >= INNO_VERSION(4, 0, 0)) ? load_number<uint64_t>(is)
: load_number<uint32_t>(is);
location = load_number<boost::uint32_t>(is, version.bits);
attributes = load_number<boost::uint32_t>(is, version.bits);
external_size = (version >= INNO_VERSION(4, 0, 0)) ? load_number<boost::uint64_t>(is)
: load_number<boost::uint32_t>(is);
if(version < INNO_VERSION(3, 0, 5)) {
file_copy_mode copyMode = stored_enum<stored_file_copy_mode>(is).get();
@ -109,7 +109,7 @@ void file_entry::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(4, 1, 0)) {
permission = load_number<int16_t>(is);
permission = load_number<boost::int16_t>(is);
} else {
permission = -1;
}

9
src/setup/file.hpp

@ -21,10 +21,11 @@
#ifndef INNOEXTRACT_SETUP_FILE_HPP
#define INNOEXTRACT_SETUP_FILE_HPP
#include <stdint.h>
#include <string>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "setup/item.hpp"
#include "util/enum.hpp"
#include "util/flags.hpp"
@ -85,9 +86,9 @@ struct file_entry : public item {
std::string install_font_name;
std::string strong_assembly_name;
uint32_t location; //!< index into the data entry list
uint32_t attributes;
uint64_t external_size;
boost::uint32_t location; //!< index into the data entry list
boost::uint32_t attributes;
boost::uint64_t external_size;
int permission; //!< index into the permission entry list

1
src/setup/filename.hpp

@ -23,6 +23,7 @@
#include <string>
#include <map>
#include <boost/filesystem/path.hpp>
namespace setup {

72
src/setup/header.cpp

@ -128,7 +128,7 @@ void header::load(std::istream & is, const version & version) {
options = 0;
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the setup header structure
::load<boost::uint32_t>(is); // uncompressed size of the setup header structure
}
is >> encoded_string(app_name, version.codepage());
@ -237,7 +237,7 @@ void header::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(4, 0, 0)) {
language_count = load_number<uint32_t>(is);
language_count = load_number<boost::uint32_t>(is);
} else if(version >= INNO_VERSION(2, 0, 1)) {
language_count = 1;
} else {
@ -245,62 +245,62 @@ void header::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(4, 2, 1)) {
message_count = load_number<uint32_t>(is);
message_count = load_number<boost::uint32_t>(is);
} else {
message_count = 0;
}
if(version >= INNO_VERSION(4, 1, 0)) {
permission_count = load_number<uint32_t>(is);
permission_count = load_number<boost::uint32_t>(is);
} else {
permission_count = 0;
}
if(version >= INNO_VERSION(2, 0, 0)) {
type_count = load_number<uint32_t>(is);
component_count = load_number<uint32_t>(is);
task_count = load_number<uint32_t>(is);
type_count = load_number<boost::uint32_t>(is);
component_count = load_number<boost::uint32_t>(is);
task_count = load_number<boost::uint32_t>(is);
} else {
type_count = 0, component_count = 0, task_count = 0;
}
directory_count = load_number<uint32_t>(is, version.bits);
file_count = load_number<uint32_t>(is, version.bits);
data_entry_count = load_number<uint32_t>(is, version.bits);
icon_count = load_number<uint32_t>(is, version.bits);
ini_entry_count = load_number<uint32_t>(is, version.bits);
registry_entry_count = load_number<uint32_t>(is, version.bits);
delete_entry_count = load_number<uint32_t>(is, version.bits);
uninstall_delete_entry_count = load_number<uint32_t>(is, version.bits);
run_entry_count = load_number<uint32_t>(is, version.bits);
uninstall_run_entry_count = load_number<uint32_t>(is, version.bits);
int32_t license_size = 0;
int32_t info_before_size = 0;
int32_t info_after_size = 0;
directory_count = load_number<boost::uint32_t>(is, version.bits);
file_count = load_number<boost::uint32_t>(is, version.bits);
data_entry_count = load_number<boost::uint32_t>(is, version.bits);
icon_count = load_number<boost::uint32_t>(is, version.bits);
ini_entry_count = load_number<boost::uint32_t>(is, version.bits);
registry_entry_count = load_number<boost::uint32_t>(is, version.bits);
delete_entry_count = load_number<boost::uint32_t>(is, version.bits);
uninstall_delete_entry_count = load_number<boost::uint32_t>(is, version.bits);
run_entry_count = load_number<boost::uint32_t>(is, version.bits);
uninstall_run_entry_count = load_number<boost::uint32_t>(is, version.bits);
boost::int32_t license_size = 0;
boost::int32_t info_before_size = 0;
boost::int32_t info_after_size = 0;
if(version < INNO_VERSION(1, 3, 21)) {
license_size = load_number<int32_t>(is, version.bits);
info_before_size = load_number<int32_t>(is, version.bits);
info_after_size = load_number<int32_t>(is, version.bits);
license_size = load_number<boost::int32_t>(is, version.bits);
info_before_size = load_number<boost::int32_t>(is, version.bits);
info_after_size = load_number<boost::int32_t>(is, version.bits);
}
winver.load(is, version);
back_color = load_number<uint32_t>(is);
back_color = load_number<boost::uint32_t>(is);
if(version >= INNO_VERSION(1, 3, 21)) {
back_color2 = load_number<uint32_t>(is);
back_color2 = load_number<boost::uint32_t>(is);
} else {
back_color2 = 0;
}
image_back_color = load_number<uint32_t>(is);
image_back_color = load_number<boost::uint32_t>(is);
if(version >= INNO_VERSION(2, 0, 0) && version < INNO_VERSION(5, 0, 4)) {
small_image_back_color = load_number<uint32_t>(is);
small_image_back_color = load_number<boost::uint32_t>(is);
} else {
small_image_back_color = 0;
}
if(version < INNO_VERSION(4, 2, 0)) {
password.crc32 = load_number<uint32_t>(is);
password.crc32 = load_number<boost::uint32_t>(is);
password.type = crypto::CRC32;
} else if(version < INNO_VERSION(5, 3, 9)) {
is.read(password.md5, std::streamsize(sizeof(password.md5)));
@ -316,10 +316,10 @@ void header::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(4, 0, 0)) {
extra_disk_space_required = load_number<int64_t>(is);
slices_per_disk = load_number<uint32_t>(is);
extra_disk_space_required = load_number<boost::int64_t>(is);
slices_per_disk = load_number<boost::uint32_t>(is);
} else {
extra_disk_space_required = load_number<int32_t>(is);
extra_disk_space_required = load_number<boost::int32_t>(is);
slices_per_disk = 1;
}
@ -386,8 +386,8 @@ void header::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(5, 2, 1) && version < INNO_VERSION(5, 3, 10)) {
signed_uninstaller_original_size = load_number<uint32_t>(is);
signed_uninstaller_header_checksum = load_number<uint32_t>(is);
signed_uninstaller_original_size = load_number<boost::uint32_t>(is);
signed_uninstaller_header_checksum = load_number<boost::uint32_t>(is);
} else {
signed_uninstaller_original_size = signed_uninstaller_header_checksum = 0;
}
@ -398,9 +398,9 @@ void header::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION(5, 5, 0)) {
uninstall_display_size = load_number<uint64_t>(is);
uninstall_display_size = load_number<boost::uint64_t>(is);
} else if(version >= INNO_VERSION(5, 3, 6)) {
uninstall_display_size = load_number<uint32_t>(is);
uninstall_display_size = load_number<boost::uint32_t>(is);
} else {
uninstall_display_size = 0;
}

13
src/setup/header.hpp

@ -21,12 +21,13 @@
#ifndef INNOEXTRACT_SETUP_HEADER_HPP
#define INNOEXTRACT_SETUP_HEADER_HPP
#include <stdint.h>
#include <stddef.h>
#include <bitset>
#include <string>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "crypto/checksum.hpp"
#include "setup/windows.hpp"
#include "stream/chunk.hpp"
@ -171,7 +172,7 @@ struct header {
windows_version_range winver;
typedef uint32_t Color;
typedef boost::uint32_t Color;
Color back_color;
Color back_color2;
Color image_back_color;
@ -180,7 +181,7 @@ struct header {
crypto::checksum password;
salt password_salt;
int64_t extra_disk_space_required;
boost::int64_t extra_disk_space_required;
size_t slices_per_disk;
enum install_verbosity {
@ -233,13 +234,13 @@ struct header {
architecture_types architectures_allowed;
architecture_types architectures_installed_in_64bit_mode;
uint32_t signed_uninstaller_original_size;
uint32_t signed_uninstaller_header_checksum;
boost::uint32_t signed_uninstaller_original_size;
boost::uint32_t signed_uninstaller_header_checksum;
auto_bool disable_dir_page;
auto_bool disable_program_group_page;
uint64_t uninstall_display_size;
boost::uint64_t uninstall_display_size;
flags options;

8
src/setup/icon.cpp

@ -39,7 +39,7 @@ STORED_ENUM_MAP(stored_close_setting, icon_entry::NoSetting,
void icon_entry::load(std::istream & is, const version & version) {
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the icon entry structure
::load<boost::uint32_t>(is); // uncompressed size of the icon entry structure
}
is >> encoded_string(name, version.codepage());
@ -59,17 +59,17 @@ void icon_entry::load(std::istream & is, const version & version) {
load_version_data(is, version);
icon_index = load_number<int32_t>(is, version.bits);
icon_index = load_number<boost::int32_t>(is, version.bits);
if(version >= INNO_VERSION(1, 3, 21)) {
show_command = load_number<int32_t>(is);
show_command = load_number<boost::int32_t>(is);
close_on_exit = stored_enum<stored_close_setting>(is).get();
} else {
show_command = 1, close_on_exit = NoSetting;
}
if(version >= INNO_VERSION(2, 0, 7)) {
hotkey = load_number<uint16_t>(is);
hotkey = load_number<boost::uint16_t>(is);
} else {
hotkey = 0;
}

5
src/setup/icon.hpp

@ -21,10 +21,11 @@
#ifndef INNOEXTRACT_SETUP_ICON_HPP
#define INNOEXTRACT_SETUP_ICON_HPP
#include <stdint.h>
#include <string>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "setup/item.hpp"
#include "util/enum.hpp"
#include "util/flags.hpp"
@ -66,7 +67,7 @@ struct icon_entry : public item {
close_setting close_on_exit;
uint16_t hotkey;
boost::uint16_t hotkey;
flags options;

2
src/setup/info.cpp

@ -149,7 +149,7 @@ void info::load(std::istream & ifs, entry_types e, const setup::version & v) {
continue;
}
uint32_t codepage;
boost::uint32_t codepage;
if(entry.language < 0) {
codepage = v.codepage();
} else {

4
src/setup/ini.cpp

@ -20,7 +20,7 @@
#include "setup/ini.hpp"
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "setup/version.hpp"
#include "util/load.hpp"
@ -43,7 +43,7 @@ STORED_FLAGS_MAP(stored_ini_flags,
void ini_entry::load(std::istream & is, const version & version) {
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the ini entry structure
::load<boost::uint32_t>(is); // uncompressed size of the ini entry structure
}
is >> encoded_string(inifile, version.codepage());

16
src/setup/language.cpp

@ -52,10 +52,10 @@ void language_entry::load(std::istream & is, const version & version) {
license_text.clear(), info_before.clear(), info_after.clear();
}
language_id = load_number<uint32_t>(is);
language_id = load_number<boost::uint32_t>(is);
if(version >= INNO_VERSION(4, 2, 2) && (version < INNO_VERSION(5, 3, 0) || !version.unicode)) {
codepage = load_number<uint32_t>(is);
codepage = load_number<boost::uint32_t>(is);
} else {
codepage = 0;
}
@ -63,20 +63,20 @@ void language_entry::load(std::istream & is, const version & version) {
codepage = version.codepage();
}
dialog_font_size = load_number<uint32_t>(is);
dialog_font_size = load_number<boost::uint32_t>(is);
if(version < INNO_VERSION(4, 1, 0)) {
dialog_font_standard_height = load_number<uint32_t>(is);
dialog_font_standard_height = load_number<boost::uint32_t>(is);
} else {
dialog_font_standard_height = 0;
}
title_font_size = load_number<uint32_t>(is);
welcome_font_size = load_number<uint32_t>(is);
copyright_font_size = load_number<uint32_t>(is);
title_font_size = load_number<boost::uint32_t>(is);
welcome_font_size = load_number<boost::uint32_t>(is);
copyright_font_size = load_number<boost::uint32_t>(is);
if(version >= INNO_VERSION(5, 2, 3)) {
right_to_left = ::load<uint8_t>(is);
right_to_left = ::load<boost::uint8_t>(is);
} else {
right_to_left = false;
}

7
src/setup/language.hpp

@ -21,10 +21,11 @@
#ifndef INNOEXTRACT_SETUP_LANGUAGE_HPP
#define INNOEXTRACT_SETUP_LANGUAGE_HPP
#include <stdint.h>
#include <string>
#include <iosfwd>
#include <boost/cstdint.hpp>
namespace setup {
struct version;
@ -44,8 +45,8 @@ struct language_entry {
std::string info_before;
std::string info_after;
uint32_t language_id;
uint32_t codepage;
boost::uint32_t language_id;
boost::uint32_t codepage;
size_t dialog_font_size;
size_t dialog_font_standard_height;
size_t title_font_size;

4
src/setup/message.cpp

@ -20,7 +20,7 @@
#include "setup/message.hpp"
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "setup/version.hpp"
#include "util/load.hpp"
@ -32,7 +32,7 @@ void message_entry::load(std::istream & is, const version & version) {
is >> encoded_string(name, version.codepage());
is >> binary_string(value); // encoding depends on the codepage in the LanguageEntry
language = load_number<int32_t>(is);
language = load_number<boost::int32_t>(is);
}

5
src/setup/permission.cpp

@ -20,13 +20,14 @@
#include "setup/permission.hpp"
#include "setup/version.hpp"
#include "util/load.hpp"
namespace setup {
void permission_entry::load(std::istream & is, const version & version) {
void permission_entry::load(std::istream & is, const version & v) {
(void)version;
(void)v;
is >> binary_string(permissions); // an array of TGrantPermissionEntry's

8
src/setup/registry.cpp

@ -20,7 +20,7 @@
#include "setup/registry.hpp"
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "setup/version.hpp"
#include "util/load.hpp"
@ -61,7 +61,7 @@ STORED_ENUM_MAP(stored_registry_entry_type_2, registry_entry::None,
void registry_entry::load(std::istream & is, const version & version) {
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the directory entry structure
::load<boost::uint32_t>(is); // uncompressed size of the directory entry structure
}
is >> encoded_string(key, version.codepage());
@ -83,13 +83,13 @@ void registry_entry::load(std::istream & is, const version & version) {
load_version_data(is, version);
if(version.bits != 16) {
hive = hive_name(load_number<uint32_t>(is) & ~0x80000000);
hive = hive_name(load_number<boost::uint32_t>(is) & ~0x80000000);
} else {
hive = Unset;
}
if(version >= INNO_VERSION(4, 1, 0)) {
permission = load_number<int16_t>(is);
permission = load_number<boost::int16_t>(is);
} else {
permission = -1;
}

6
src/setup/run.cpp

@ -20,7 +20,7 @@
#include "setup/run.hpp"
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "setup/version.hpp"
#include "util/load.hpp"
@ -41,7 +41,7 @@ STORED_ENUM_MAP(stored_run_wait_condition, run_entry::WaitUntilTerminated,
void run_entry::load(std::istream & is, const version & version) {
if(version < INNO_VERSION(1, 3, 21)) {
::load<uint32_t>(is); // uncompressed size of the directory entry structure
::load<boost::uint32_t>(is); // uncompressed size of the directory entry structure
}
is >> encoded_string(name, version.codepage());
@ -71,7 +71,7 @@ void run_entry::load(std::istream & is, const version & version) {
load_version_data(is, version);
if(version >= INNO_VERSION(1, 3, 21)) {
show_command = load_number<int32_t>(is);
show_command = load_number<boost::int32_t>(is);
} else {
show_command = 0;
}

6
src/setup/task.cpp

@ -20,7 +20,7 @@
#include "setup/task.hpp"
#include <stdint.h>
#include <boost/cstdint.hpp>
#include "setup/version.hpp"
#include "util/load.hpp"
@ -41,8 +41,8 @@ void task_entry::load(std::istream & is, const version & version) {
}
if(version >= INNO_VERSION_EXT(3, 0, 6, 1)) {
is >> encoded_string(check, version.codepage());
level = load_number<int32_t>(is);
used = load_number<uint8_t>(is);
level = load_number<boost::int32_t>(is);
used = load_number<boost::uint8_t>(is);
} else {
check.clear(), level = 0, used = true;
}

2
src/setup/type.cpp

@ -79,7 +79,7 @@ void type_entry::load(std::istream & is, const version & version) {
type = User;
}
size = (version >= INNO_VERSION(4, 0, 0)) ? load_number<uint64_t>(is) : load_number<uint32_t>(is);
size = (version >= INNO_VERSION(4, 0, 0)) ? load_number<boost::uint64_t>(is) : load_number<boost::uint32_t>(is);
}
} // namespace setup

5
src/setup/type.hpp

@ -21,10 +21,11 @@
#ifndef INNOEXTRACT_SETUP_TYPE_HPP
#define INNOEXTRACT_SETUP_TYPE_HPP
#include <stdint.h>
#include <string>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include "setup/windows.hpp"
#include "util/enum.hpp"
#include "util/flags.hpp"
@ -55,7 +56,7 @@ struct type_entry {
setup_type type;
uint64_t size;
boost::uint64_t size;
void load(std::istream & is, const version & version);

15
src/setup/version.hpp

@ -21,15 +21,16 @@
#ifndef INNOEXTRACT_SETUP_VERSION_HPP
#define INNOEXTRACT_SETUP_VERSION_HPP
#include <stdint.h>
#include <iosfwd>
#include <exception>
#include <boost/cstdint.hpp>
namespace setup {
struct version_error : public std::exception { };
typedef uint32_t version_constant;
typedef boost::uint32_t version_constant;
#define INNO_VERSION_EXT(a, b, c, d) ( \
(::setup::version_constant(a) << 24) \
| (::setup::version_constant(b) << 16) \
@ -42,7 +43,7 @@ struct version {
version_constant value;
uint8_t bits; // 16 or 32
boost::uint8_t bits; // 16 or 32
bool unicode;
@ -51,12 +52,12 @@ struct version {
version() : known(false) { }
version(version_constant value, bool unicode = false,
bool known = false, uint8_t bits = 32)
bool known = false, boost::uint8_t bits = 32)
: value(value), bits(bits), unicode(unicode), known(known) { }
version(uint8_t a, uint8_t b, uint8_t c, uint8_t d = 0, bool unicode = false,
bool known = false, uint8_t bits = 32)
version(boost::uint8_t a, boost::uint8_t b, boost::uint8_t c, boost::uint8_t d = 0, bool unicode = false,
bool known = false, boost::uint8_t bits = 32)
: value(INNO_VERSION_EXT(a, b, c, d)), bits(bits), unicode(unicode), known(known) { }
unsigned int a() const { return value >> 24; }
@ -67,7 +68,7 @@ struct version {
void load(std::istream & is);
//! \return the Windows codepage used to encode strings
uint32_t codepage() const { return uint32_t(unicode ? 1200 : 1252); }
boost::uint32_t codepage() const { return boost::uint32_t(unicode ? 1200 : 1252); }
//! \return true if the version stored might not be correct
bool is_ambiguous() const;

13
src/setup/windows.cpp

@ -20,9 +20,10 @@
#include "setup/windows.hpp"
#include <stdint.h>
#include <ostream>
#include <boost/cstdint.hpp>
#include "setup/version.hpp"
#include "util/load.hpp"
#include "util/util.hpp"
@ -34,13 +35,13 @@ const windows_version windows_version::none = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0
void windows_version::data::load(std::istream & is, const version & version) {
if(version >= INNO_VERSION(1, 3, 21)) {
build = load_number<uint16_t>(is);
build = load_number<boost::uint16_t>(is);
} else {
build = 0;
}
minor = load_number<uint8_t>(is);
major = load_number<uint8_t>(is);
minor = load_number<boost::uint8_t>(is);
major = load_number<boost::uint8_t>(is);
}
@ -50,8 +51,8 @@ void windows_version::load(std::istream & is, const version & version) {
nt_version.load(is, version);
if(version >= INNO_VERSION(1, 3, 21)) {
nt_service_pack.minor = load_number<uint8_t>(is);
nt_service_pack.major = load_number<uint8_t>(is);
nt_service_pack.minor = load_number<boost::uint8_t>(is);
nt_service_pack.major = load_number<boost::uint8_t>(is);
} else {
nt_service_pack.major = 0, nt_service_pack.minor = 0;
}

20
src/stream/block.cpp

@ -20,13 +20,13 @@
#include "stream/block.hpp"
#include <stdint.h>
#include <cstring>
#include <string>
#include <istream>
#include <algorithm>
#include <cassert>
#include <boost/cstdint.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/restrict.hpp>
#include <boost/iostreams/filter/zlib.hpp>
@ -82,7 +82,7 @@ public:
template<typename Source>
bool read_chunk(Source & src) {
uint32_t block_crc32;
boost::uint32_t block_crc32;
char temp[sizeof(block_crc32)];
std::streamsize temp_size = std::streamsize(sizeof(temp));
std::streamsize nread = boost::iostreams::read(src, temp, temp_size);
@ -157,33 +157,33 @@ block_reader::pointer block_reader::get(std::istream & base, const setup::versio
USE_ENUM_NAMES(block_compression)
uint32_t expected_checksum = load_number<uint32_t>(base);
boost::uint32_t expected_checksum = load_number<boost::uint32_t>(base);
crypto::crc32 actual_checksum;
actual_checksum.init();
uint32_t stored_size;
boost::uint32_t stored_size;
block_compression compression;
if(version >= INNO_VERSION(4, 0, 9)) {
stored_size = actual_checksum.load_number<uint32_t>(base);
uint8_t compressed = actual_checksum.load_number<uint8_t>(base);
stored_size = actual_checksum.load_number<boost::uint32_t>(base);
boost::uint8_t compressed = actual_checksum.load_number<boost::uint8_t>(base);
compression = compressed ? (version >= INNO_VERSION(4, 1, 6) ? LZMA1 : Zlib) : Stored;
} else {
uint32_t compressed_size = actual_checksum.load_number<uint32_t>(base);
uint32_t uncompressed_size = actual_checksum.load_number<uint32_t>(base);
boost::uint32_t compressed_size = actual_checksum.load_number<boost::uint32_t>(base);
boost::uint32_t uncompressed_size = actual_checksum.load_number<boost::uint32_t>(base);
if(compressed_size == uint32_t(-1)) {
if(compressed_size == boost::uint32_t(-1)) {
stored_size = uncompressed_size, compression = Stored;
} else {
stored_size = compressed_size, compression = Zlib;
}
// Add the size of a CRC32 checksum for each 4KiB subblock.
stored_size += uint32_t(ceildiv<uint64_t>(stored_size, 4096) * 4);
stored_size += boost::uint32_t(ceildiv<boost::uint64_t>(stored_size, 4096) * 4);
}
if(actual_checksum.finalize() != expected_checksum) {

2
src/stream/chunk.cpp

@ -91,7 +91,7 @@ chunk_reader::pointer chunk_reader::get(slice_reader & base, const chunk & chunk
default: throw chunk_error("unknown compression");
}
result->push(io::restrict(boost::ref(base), 0, int64_t(chunk.size)));
result->push(io::restrict(boost::ref(base), 0, boost::int64_t(chunk.size)));
return result;
}

8
src/stream/chunk.hpp

@ -22,11 +22,11 @@
#define INNOEXTRACT_STREAM_CHUNK_HPP
#include <stddef.h>
#include <stdint.h>
#include <ios>
#include <boost/shared_ptr.hpp>
#include <boost/cstdint.hpp>
#include <boost/iostreams/chain.hpp>
#include <boost/shared_ptr.hpp>
#include "util/enum.hpp"
@ -54,8 +54,8 @@ struct chunk {
size_t first_slice; //!< Slice where the chunk starts.
size_t last_slice;
uint32_t offset; //!< Offset of the compressed chunk in firstSlice.
uint64_t size; //! Total compressed size of the chunk.
boost::uint32_t offset; //!< Offset of the compressed chunk in firstSlice.
boost::uint64_t size; //! Total compressed size of the chunk.
compression_method compression;
bool encrypted;

30
src/stream/exefilter.hpp

@ -21,10 +21,10 @@
#ifndef INNOEXTRACT_STREAM_EXEFILTER_HPP
#define INNOEXTRACT_STREAM_EXEFILTER_HPP
#include <stdint.h>
#include <stddef.h>
#include <iosfwd>
#include <boost/cstdint.hpp>
#include <boost/iostreams/char_traits.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/get.hpp>
@ -51,9 +51,9 @@ public:
addr_bytes_left = 0, addr_offset = 5;
}
uint32_t addr;
boost::uint32_t addr;
size_t addr_bytes_left;
uint32_t addr_offset;
boost::uint32_t addr_offset;
};
@ -104,10 +104,10 @@ private:
static const size_t block_size = 0x10000;
const bool flip_high_byte;
uint32_t offset; //! Total number of bytes read from the source.
boost::uint32_t offset; //! Total number of bytes read from the source.
int8_t flush_bytes;
uint8_t buffer[4];
boost::int8_t flush_bytes;
boost::uint8_t buffer[4];
};
@ -131,13 +131,13 @@ std::streamsize inno_exe_decoder_4108::read(Source & src, char * dest, std::stre
}
} else {
addr += uint8_t(byte);
byte = uint8_t(addr);
addr += boost::uint8_t(byte);
byte = boost::uint8_t(addr);
addr >>= 8;
addr_bytes_left--;
}
*dest++ = char(uint8_t(byte));
*dest++ = char(boost::uint8_t(byte));
}
return n;
@ -200,20 +200,20 @@ std::streamsize inno_exe_decoder_5200::read(Source & src, char * dest, std::stre
char * dst = reinterpret_cast<char *>(buffer + 4 + flush_bytes);
std::streamsize nread = boost::iostreams::read(src, dst, -flush_bytes);
if(nread == EOF) {
flush(int8_t(4 + flush_bytes));
flush(boost::int8_t(4 + flush_bytes));
return total_read ? total_read : EOF;
}
flush_bytes = int8_t(flush_bytes + nread), offset += uint32_t(nread);
flush_bytes = boost::int8_t(flush_bytes + nread), offset += boost::uint32_t(nread);
if(flush_bytes) { return total_read; }
// Verify that the high byte of the address is 0x00 or 00xff.
if(buffer[3] == 0x00 || buffer[3] == 0xff) {
uint32_t addr = offset & 0xffffff; // may wrap, but OK
boost::uint32_t addr = offset & 0xffffff; // may wrap, but OK
uint32_t rel = buffer[0] | (uint32_t(buffer[1]) << 8) | (uint32_t(buffer[2]) << 16);
boost::uint32_t rel = buffer[0] | (boost::uint32_t(buffer[1]) << 8) | (boost::uint32_t(buffer[2]) << 16);
rel -= addr;
buffer[0] = uint8_t(rel), buffer[1] = uint8_t(rel >> 8), buffer[2] = uint8_t(rel >> 16);
buffer[0] = boost::uint8_t(rel), buffer[1] = boost::uint8_t(rel >> 8), buffer[2] = boost::uint8_t(rel >> 16);
if(flip_high_byte) {
// For a slightly higher compression ratio, we want the resulting high
@ -221,7 +221,7 @@ std::streamsize inno_exe_decoder_5200::read(Source & src, char * dest, std::stre
// of the original relative address is likely to be the sign extension
// of bit 23, so if bit 23 is set, toggle all bits in the high byte.
if(rel & 0x800000) {
buffer[3] = uint8_t(~buffer[3]);
buffer[3] = boost::uint8_t(~buffer[3]);
}
}

2
src/stream/file.cpp

@ -67,7 +67,7 @@ file_reader::pointer file_reader::get(base_type & base, const file & file,
case InstructionFilter5309: result->push(inno_exe_decoder_5200(true), 8192); break;
}
result->push(io::restrict(base, 0, int64_t(file.size)));
result->push(io::restrict(base, 0, boost::int64_t(file.size)));
return result;
}

4
src/stream/file.hpp

@ -39,8 +39,8 @@ enum compression_filter {
struct file {
uint64_t offset; //!< Offset of this file within the decompressed chunk.
uint64_t size; //!< Decompressed size of this file.
boost::uint64_t offset; //!< Offset of this file within the decompressed chunk.
boost::uint64_t size; //!< Decompressed size of this file.
crypto::checksum checksum;

16
src/stream/lzma.cpp

@ -20,7 +20,7 @@
#include "stream/lzma.hpp"
#include <stdint.h>
#include <boost/cstdint.hpp>
#include <lzma.h>
@ -30,7 +30,7 @@ static lzma_stream * init_raw_lzma_stream(lzma_vli filter, lzma_options_lzma & o
options.preset_dict = NULL;
if(options.dict_size > (uint32_t(1) << 28)) {
if(options.dict_size > (boost::uint32_t(1) << 28)) {
throw lzma_error("inno lzma dict size too large", LZMA_FORMAT_ERROR);
}
@ -55,10 +55,10 @@ bool lzma_decompressor_impl_base::filter(const char * & begin_in, const char * e
lzma_stream * strm = static_cast<lzma_stream *>(stream);
strm->next_in = reinterpret_cast<const uint8_t *>(begin_in);
strm->next_in = reinterpret_cast<const boost::uint8_t *>(begin_in);
strm->avail_in = size_t(end_in - begin_in);
strm->next_out = reinterpret_cast<uint8_t *>(begin_out);
strm->next_out = reinterpret_cast<boost::uint8_t *>(begin_out);
strm->avail_out = size_t(end_out - begin_out);
lzma_ret ret = lzma_code(strm, LZMA_RUN);
@ -98,7 +98,7 @@ bool inno_lzma1_decompressor_impl::filter(const char * & begin_in, const char *
lzma_options_lzma options;
uint8_t properties = uint8_t(header[0]);
boost::uint8_t properties = boost::uint8_t(header[0]);
if(properties > (9 * 5 * 5)) {
throw lzma_error("inno lzma1 property error", LZMA_FORMAT_ERROR);
}
@ -108,7 +108,7 @@ bool inno_lzma1_decompressor_impl::filter(const char * & begin_in, const char *
options.dict_size = 0;
for(size_t i = 0; i < 4; i++) {
options.dict_size += uint32_t(uint8_t(header[i + 1])) << (i * 8);
options.dict_size += boost::uint32_t(boost::uint8_t(header[i + 1])) << (i * 8);
}
stream = init_raw_lzma_stream(LZMA_FILTER_LZMA1, options);
@ -129,7 +129,7 @@ bool inno_lzma2_decompressor_impl::filter(const char * & begin_in, const char *
lzma_options_lzma options;
uint8_t prop = uint8_t(*begin_in++);
boost::uint8_t prop = boost::uint8_t(*begin_in++);
if(prop > 40) {
throw lzma_error("inno lzma2 property error", LZMA_FORMAT_ERROR);
}
@ -137,7 +137,7 @@ bool inno_lzma2_decompressor_impl::filter(const char * & begin_in, const char *
if(prop == 40) {
options.dict_size = 0xffffffff;
} else {
options.dict_size = ((uint32_t(2) | uint32_t((prop) & 1)) << ((prop) / 2 + 11));
options.dict_size = ((boost::uint32_t(2) | boost::uint32_t((prop) & 1)) << ((prop) / 2 + 11));
}
stream = init_raw_lzma_stream(LZMA_FILTER_LZMA2, options);

13
src/stream/slice.cpp

@ -20,11 +20,12 @@
#include "stream/slice.hpp"
#include <stdint.h>
#include <sstream>
#include <cstring>
#include <limits>
#include <boost/cstdint.hpp>
#include "util/console.hpp"
#include "util/load.hpp"
#include "util/log.hpp"
@ -41,13 +42,13 @@ const char slice_ids[][8] = {
} // anonymous namespace
slice_reader::slice_reader(const path_type & setup_file, uint32_t data_offset)
slice_reader::slice_reader(const path_type & setup_file, boost::uint32_t data_offset)
: dir(), last_dir(), base_file(), data_offset(data_offset), slices_per_disk(1),
current_slice(0) {
ifs.open(setup_file, std::ios_base::binary | std::ios_base::in | std::ios_base::ate);
slice_size = uint32_t(std::min<std::streampos>(ifs.tellg(), std::numeric_limits<int32_t>::max()));
slice_size = boost::uint32_t(std::min<std::streampos>(ifs.tellg(), std::numeric_limits<boost::int32_t>::max()));
if(ifs.seekg(data_offset).fail()) {
ifs.close();
}
@ -105,7 +106,7 @@ bool slice_reader::open_file(const path_type & file) {
return false;
}
slice_size = load_number<uint32_t>(ifs);
slice_size = load_number<boost::uint32_t>(ifs);
if(ifs.fail() || std::streampos(slice_size) > fileSize) {
log_error << "[slice] bad slice size: " << slice_size << " > " << fileSize;
ifs.close();
@ -140,7 +141,7 @@ bool slice_reader::open(size_t slice, const path_type & file) {
} else {
size_t major = (slice / slices_per_disk) + 1;
size_t minor = slice % slices_per_disk;
oss << major << char(uint8_t('a') + minor);
oss << major << char(boost::uint8_t('a') + minor);
}
oss << ".bin";
@ -158,7 +159,7 @@ bool slice_reader::open(size_t slice, const path_type & file) {
return false;
}
bool slice_reader::seek(size_t slice, uint32_t offset) {
bool slice_reader::seek(size_t slice, boost::uint32_t offset) {
if(!seek(slice)) {
return false;

8
src/stream/slice.hpp

@ -34,12 +34,12 @@ class slice_reader : public boost::iostreams::source {
path_type dir;
path_type last_dir;
path_type base_file;
const uint32_t data_offset;
const boost::uint32_t data_offset;
const size_t slices_per_disk;
size_t current_slice;
path_type slice_file;
uint32_t slice_size;
boost::uint32_t slice_size;
boost::filesystem::ifstream ifs;
@ -48,11 +48,11 @@ class slice_reader : public boost::iostreams::source {
public:
slice_reader(const path_type & setup_file, uint32_t data_offset);
slice_reader(const path_type & setup_file, boost::uint32_t data_offset);
slice_reader(const path_type & dir, const path_type & base_file, size_t slices_per_disk);
bool seek(size_t slice, uint32_t offset);
bool seek(size_t slice, boost::uint32_t offset);
std::streamsize read(char * buffer, std::streamsize bytes);

10
src/util/console.cpp

@ -225,12 +225,14 @@ static int query_screen_width() {
#endif
#if !defined(_WIN32)
try {
char * columns = std::getenv("COLUMNS");
if(columns) {
return boost::lexical_cast<int>(columns);
}
} catch(...) { /* ignore bad values */ }
#endif
// Assume a default screen width of 80 columns
return 80;
@ -365,12 +367,12 @@ void progress::show_unbounded(float value, const std::string & label) {
progress_cleared = false;
}
progress::progress(uint64_t max, bool show_rate)
progress::progress(boost::uint64_t max, bool show_rate)
: max(max), value(0), show_rate(show_rate),
start_time(boost::posix_time::microsec_clock::universal_time()),
last_status(-1.f), last_time(0), last_rate(0.f) { }
void progress::update(uint64_t delta, bool force) {
void progress::update(boost::uint64_t delta, bool force) {
if(!show_progress) {
return;
@ -390,9 +392,9 @@ void progress::update(uint64_t delta, bool force) {
}
boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
uint64_t time = uint64_t((now - start_time).total_microseconds());
boost::uint64_t time = boost::uint64_t((now - start_time).total_microseconds());
const uint64_t update_interval = 100000;
const boost::uint64_t update_interval = 100000;
if(!force && time - last_time < update_interval) {
return;
}

11
src/util/console.hpp

@ -22,7 +22,6 @@
#define INNOEXTRACT_UTIL_CONSOLE_HPP
#include <stddef.h>
#include <stdint.h>
#include <ostream>
#include <iomanip>
#include <sstream>
@ -84,27 +83,27 @@ void init(is_enabled color = automatic, is_enabled progress = automatic);
class progress {
uint64_t max;
uint64_t value;
boost::uint64_t max;
boost::uint64_t value;
bool show_rate;
boost::posix_time::ptime start_time;
float last_status;
uint64_t last_time;
boost::uint64_t last_time;
float last_rate;
std::ostringstream label;
public:
progress(uint64_t max = 0, bool show_rate = true);
progress(boost::uint64_t max = 0, bool show_rate = true);
progress(const progress & o)
: max(o.max), value(o.value), show_rate(o.show_rate), start_time(o.start_time),
last_status(o.last_status), last_time(o.last_time),
last_rate(o.last_rate), label(o.label.str()) { }
void update(uint64_t delta = 0, bool force = false);
void update(boost::uint64_t delta = 0, bool force = false);
static void show(float value, const std::string & label = std::string());

32
src/util/endian.hpp

@ -29,29 +29,31 @@
#include <byteswap.h>
#endif
inline uint8_t byteswap(uint8_t value) {
#include <boost/cstdint.hpp>
inline boost::uint8_t byteswap(boost::uint8_t value) {
return value;
}
inline int8_t byteswap(int8_t value) {
return int8_t(byteswap(uint8_t(value)));
inline boost::int8_t byteswap(boost::int8_t value) {
return boost::int8_t(byteswap(boost::uint8_t(value)));
}
inline uint16_t byteswap(uint16_t value) {
inline boost::uint16_t byteswap(boost::uint16_t value) {
#if defined(_MSC_VER) && _MSC_VER >= 1300
return _byteswap_ushort(value);
#elif INNOEXTRACT_HAVE_BSWAP_16
return bswap_16(value);
#else
return uint16_t((uint16_t(uint8_t(value)) << 8) | uint8_t(value >> 8));
return boost::uint16_t((boost::uint16_t(boost::uint8_t(value)) << 8) | boost::uint8_t(value >> 8));
#endif
}
inline int16_t byteswap(int16_t value) {
return int16_t(byteswap(uint16_t(value)));
inline boost::int16_t byteswap(boost::int16_t value) {
return boost::int16_t(byteswap(boost::uint16_t(value)));
}
inline uint32_t byteswap(uint32_t value) {
inline boost::uint32_t byteswap(boost::uint32_t value) {
#if defined(__GNUC__) && !defined(__PATHCC__) \
&& __GNUC__ >= 4 && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
return __builtin_bswap32(value);
@ -60,15 +62,15 @@ inline uint32_t byteswap(uint32_t value) {
#elif INNOEXTRACT_HAVE_BSWAP_32
return bswap_32(value);
#else
return (uint32_t(byteswap(uint16_t(value))) << 16) | byteswap(uint16_t(value >> 16));
return (boost::uint32_t(byteswap(boost::uint16_t(value))) << 16) | byteswap(boost::uint16_t(value >> 16));
#endif
}
inline int32_t byteswap(int32_t value) {
return int32_t(byteswap(uint32_t(value)));
inline boost::int32_t byteswap(boost::int32_t value) {
return boost::int32_t(byteswap(boost::uint32_t(value)));
}
inline uint64_t byteswap(uint64_t value) {
inline boost::uint64_t byteswap(boost::uint64_t value) {
#if defined(__GNUC__) && !defined(__PATHCC__) \
&& __GNUC__ >= 4 && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
return __builtin_bswap64(value);
@ -77,12 +79,12 @@ inline uint64_t byteswap(uint64_t value) {
#elif INNOEXTRACT_HAVE_BSWAP_64
return bswap_64(value);
#else
return (uint64_t(byteswap(uint32_t(value))) << 32) | byteswap(uint32_t(value >> 32));
return (boost::uint64_t(byteswap(boost::uint32_t(value))) << 32) | byteswap(boost::uint32_t(value >> 32));
#endif
}
inline int64_t byteswap(int64_t value) {
return int64_t(byteswap(uint64_t(value)));
inline boost::int64_t byteswap(boost::int64_t value) {
return boost::int64_t(byteswap(boost::uint64_t(value)));
}
template <class T>

2
src/util/enum.hpp

@ -46,7 +46,7 @@ struct enum_names {
const char * name;
const char * names[];
const char * names[1];
};

14
src/util/load.cpp

@ -32,11 +32,11 @@
namespace {
std::map<uint32_t, iconv_t> converters;
std::map<boost::uint32_t, iconv_t> converters;
iconv_t get_converter(uint32_t codepage) {
iconv_t get_converter(boost::uint32_t codepage) {
std::map<uint32_t, iconv_t>::iterator i = converters.find(codepage);
std::map<boost::uint32_t, iconv_t>::iterator i = converters.find(codepage);
if(i != converters.end()) {
return i->second;
@ -59,7 +59,7 @@ iconv_t get_converter(uint32_t codepage) {
void binary_string::load(std::istream & is, std::string & target) {
int32_t length = load_number<int32_t>(is);
boost::int32_t length = load_number<boost::int32_t>(is);
if(is.fail()) {
return;
}
@ -68,14 +68,14 @@ void binary_string::load(std::istream & is, std::string & target) {
while(length) {
char buffer[10 * 1024];
int32_t buf_size = std::min(length, int32_t(sizeof(buffer)));
boost::int32_t buf_size = std::min(length, boost::int32_t(sizeof(buffer)));
is.read(buffer, buf_size);
target.append(buffer, size_t(buf_size));
length -= buf_size;
}
}
void encoded_string::load(std::istream & is, std::string & target, uint32_t codepage) {
void encoded_string::load(std::istream & is, std::string & target, boost::uint32_t codepage) {
std::string temp;
binary_string::load(is, temp);
@ -83,7 +83,7 @@ void encoded_string::load(std::istream & is, std::string & target, uint32_t code
to_utf8(temp, target, codepage);
}
void to_utf8(const std::string & from, std::string & to, uint32_t codepage) {
void to_utf8(const std::string & from, std::string & to, boost::uint32_t codepage) {
iconv_t converter = get_converter(codepage);

17
src/util/load.hpp

@ -21,11 +21,12 @@
#ifndef INNOEXTRACT_UTIL_LOAD_HPP
#define INNOEXTRACT_UTIL_LOAD_HPP
#include <stdint.h>
#include <cstring>
#include <iostream>
#include <string>
#include <boost/cstdint.hpp>
#include "util/endian.hpp"
#include "util/types.hpp"
#include "util/util.hpp"
@ -45,17 +46,17 @@ inline std::istream & operator>>(std::istream & is, const binary_string & str) {
return is;
}
void to_utf8(const std::string & from, std::string & to, uint32_t codepage = 1252);
void to_utf8(const std::string & from, std::string & to, boost::uint32_t codepage = 1252);
struct encoded_string {
std::string & data;
uint32_t codepage;
boost::uint32_t codepage;
encoded_string(std::string & target, uint32_t _codepage)
encoded_string(std::string & target, boost::uint32_t _codepage)
: data(target), codepage(_codepage) { }
static void load(std::istream & is, std::string & target, uint32_t codepage);
static void load(std::istream & is, std::string & target, boost::uint32_t codepage);
};
@ -108,12 +109,12 @@ T load_number(std::istream & is, size_t bits) {
}
template <class T>
void discard(T & is, uint64_t bytes) {
void discard(T & is, boost::uint64_t bytes) {
char buf[1024];
while(bytes) {
std::streamsize n = std::streamsize(std::min<uint64_t>(bytes, ARRAY_SIZE(buf)));
std::streamsize n = std::streamsize(std::min<boost::uint64_t>(bytes, ARRAY_SIZE(buf)));
is.read(buf, n);
bytes -= uint64_t(n);
bytes -= boost::uint64_t(n);
}
}

7
src/util/output.hpp

@ -21,10 +21,11 @@
#ifndef INNOEXTRACT_UTIL_OUTPUT_HPP
#define INNOEXTRACT_UTIL_OUTPUT_HPP
#include <stdint.h>
#include <iostream>
#include <string>
#include <boost/cstdint.hpp>
#include "util/console.hpp"
#include "util/util.hpp"
@ -172,8 +173,8 @@ std::ostream & operator<<(std::ostream & os, const print_bytes<T> & s) {
std::streamsize precision = os.precision();
size_t frac = size_t(1024 * (s.value - T(uint64_t(s.value))));
uint64_t whole = uint64_t(s.value);
size_t frac = size_t(1024 * (s.value - T(boost::uint64_t(s.value))));
boost::uint64_t whole = boost::uint64_t(s.value);
size_t i = 0;

26
src/util/storedenum.hpp

@ -21,13 +21,13 @@
#ifndef INNOEXTRACT_UTIL_STOREDENUM_HPP
#define INNOEXTRACT_UTIL_STOREDENUM_HPP
#include <stdint.h>
#include <stddef.h>
#include <vector>
#include <boost/utility/enable_if.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/utility/enable_if.hpp>
#include "util/enum.hpp"
#include "util/load.hpp"
@ -69,7 +69,7 @@ public:
explicit stored_enum(std::istream & is) {
BOOST_STATIC_ASSERT(size <= (1 << 8));
value = load_number<uint8_t>(is);
value = load_number<boost::uint8_t>(is);
}
enum_type get() {
@ -92,7 +92,7 @@ public:
template <size_t Bits, size_t PadBits = 32>
class stored_bitfield {
typedef uint8_t base_type;
typedef boost::uint8_t base_type;
static const size_t base_size = sizeof(base_type) * 8;
static const size_t count = (Bits + (base_size - 1)) / base_size; // ceildiv
@ -113,14 +113,14 @@ public:
}
}
uint64_t lower_bits() const {
boost::uint64_t lower_bits() const {
BOOST_STATIC_ASSERT(sizeof(uint64_t) % sizeof(base_type) == 0);
BOOST_STATIC_ASSERT(sizeof(boost::uint64_t) % sizeof(base_type) == 0);
uint64_t result = 0;
boost::uint64_t result = 0;
for(size_t i = 0; i < std::min(sizeof(uint64_t) / sizeof(base_type), size_t(count)); i++) {
result |= (uint64_t(bits[i]) << (i * base_size));
for(size_t i = 0; i < std::min(sizeof(boost::uint64_t) / sizeof(base_type), size_t(count)); i++) {
result |= (boost::uint64_t(bits[i]) << (i * base_size));
}
return result;
@ -168,13 +168,13 @@ public:
flag_type get() {
uint64_t bits = this->lower_bits();
boost::uint64_t bits = this->lower_bits();
flag_type result = 0;
for(size_t i = 0; i < this->size; i++) {
if(bits & (uint64_t(1) << i)) {
if(bits & (boost::uint64_t(1) << i)) {
result |= Mapping::values[i];
bits &= ~(uint64_t(1) << i);
bits &= ~(boost::uint64_t(1) << i);
}
}
@ -207,7 +207,7 @@ private:
std::istream & is;
typedef uint8_t stored_type;
typedef boost::uint8_t stored_type;
static const size_t stored_bits = sizeof(stored_type) * 8;
size_t pos;

16
src/util/time.cpp

@ -48,7 +48,7 @@ static void set_timezone(const char * value) {
const char * variable = "TZ";
#if defined(WIN32)
#if defined(_WIN32)
SetEnvironmentVariable(variable, value);
_tzset();
@ -100,7 +100,7 @@ std::time_t parse_time(std::tm tm) {
}
std::tm format_time(time_t t) {
std::tm format_time(std::time_t t) {
std::tm ret;
@ -114,7 +114,7 @@ std::tm format_time(time_t t) {
// Windows (MSVC)
_gmtime_s(&ret, &t);
gmtime_s(&ret, &t);
#else
@ -174,7 +174,7 @@ static HANDLE open_file(LPCWSTR name) {
#endif
bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t nsec) {
bool set_file_time(const boost::filesystem::path & path, std::time_t t, boost::uint32_t nsec) {
#if INNOEXTRACT_HAVE_UTIMENSAT && INNOEXTRACT_HAVE_AT_FDCWD
@ -182,7 +182,7 @@ bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t
struct timespec times[2];
times[0].tv_sec = t;
times[0].tv_nsec = int32_t(nsec);
times[0].tv_nsec = boost::int32_t(nsec);
times[1] = times[0];
return (utimensat(AT_FDCWD, path.string().c_str(), times, 0) == 0);
@ -201,8 +201,8 @@ bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t
}
// Convert the std::time_t and nanoseconds to a FILETIME struct
static const int64_t FiletimeOffset = 0x19DB1DED53E8000ll;
int64_t time = int64_t(t) * 10000000 + int64_t(nsec) / 100;
static const boost::int64_t FiletimeOffset = 0x19DB1DED53E8000ll;
boost::int64_t time = boost::int64_t(t) * 10000000 + boost::int64_t(nsec) / 100;
time += FiletimeOffset;
FILETIME filetime;
filetime.dwLowDateTime = DWORD(time);
@ -219,7 +219,7 @@ bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t
struct timeval times[2];
times[0].tv_sec = t;
times[0].tv_usec = int32_t(nsec / 1000);
times[0].tv_usec = boost::int32_t(nsec / 1000);
times[1] = times[0];
return (utimes(path.string().c_str(), times) == 0);

4
src/util/time.hpp

@ -21,10 +21,10 @@
#ifndef INNOEXTRACT_UTIL_TIME_HPP
#define INNOEXTRACT_UTIL_TIME_HPP
#include <stdint.h>
#include <ctime>
#include <string>
#include <boost/cstdint.hpp>
#include <boost/filesystem/path.hpp>
namespace util {
@ -51,7 +51,7 @@ std::time_t to_local_time(std::time_t t);
void set_local_timezone(std::string timezone);
//! Set a file's creation/modification time
bool set_file_time(const boost::filesystem::path & path, std::time_t t, uint32_t nsec);
bool set_file_time(const boost::filesystem::path & path, std::time_t t, boost::uint32_t nsec);
} // namespace util

16
src/util/types.hpp

@ -44,22 +44,22 @@ namespace detail {
template <>
struct uint_t<8> : public boost::uint_t<8> {
typedef uint8_t exact;
typedef boost::uint8_t exact;
};
template <>
struct uint_t<16> : public boost::uint_t<16> {
typedef uint16_t exact;
typedef boost::uint16_t exact;
};
template <>
struct uint_t<32> : public boost::uint_t<32> {
typedef uint32_t exact;
typedef boost::uint32_t exact;
};
template <>
struct uint_t<64> {
typedef uint64_t exact;
typedef boost::uint64_t exact;
};
template <size_t Bits>
@ -67,22 +67,22 @@ namespace detail {
template <>
struct int_t<8> : public boost::int_t<8> {
typedef int8_t exact;
typedef boost::int8_t exact;
};
template <>
struct int_t<16> : public boost::int_t<16> {
typedef int16_t exact;
typedef boost::int16_t exact;
};
template <>
struct int_t<32> : public boost::int_t<32> {
typedef int32_t exact;
typedef boost::int32_t exact;
};
template <>
struct int_t<64> {
typedef int64_t exact;
typedef boost::int64_t exact;
};
}

15
src/util/util.hpp

@ -21,6 +21,10 @@
#ifndef INNOEXTRACT_UTIL_UTIL_HPP
#define INNOEXTRACT_UTIL_UTIL_HPP
#ifdef _MSC_VER
#include <intrin.h>
#endif
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(*(array)))
template <typename T>
@ -88,27 +92,24 @@ template <class T> T rotl_fixed(T x, unsigned int y) {
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__INTEL_COMPILER)
template<> uint8_t rotl_fixed<uint8_t>(uint8_t x, unsigned int y) {
template<> inline unsigned char rotl_fixed<unsigned char>(unsigned char x, unsigned int y) {
return y ? _rotl8(x, y) : x;
}
// Intel C++ Compiler 10.0 gives undefined externals with these
template<> uint16_t rotl_fixed<uint16_t>(uint16_t x, unsigned int y) {
template<> inline unsigned short rotl_fixed<unsigned short>(unsigned short x, unsigned int y) {
return y ? _rotl16(x, y) : x;
}
#endif
#ifdef _MSC_VER
template<> uint32_t rotl_fixed<uint32_t>(uint32_t x, unsigned int y) {
template<> inline unsigned long rotl_fixed<unsigned long>(unsigned long x, unsigned int y) {
return y ? _lrotl(x, y) : x;
}
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
// Intel C++ Compiler 10.0 calls a function instead of using the rotate instruction when
// using these instructions
template<> uint64_t rotl_fixed<uint64_t>(uint64_t x, unsigned int y) {
template<> inline __int64 rotl_fixed<__int64>(__int64 x, unsigned int y) {
return y ? _rotl64(x, y) : x;
}
#endif

Loading…
Cancel
Save