blob: d77f6dd94c5d20251b8e6f8c07542b45d698ea16 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// -----------------------------------------------------------------------------
// This defines the expected contents of a packed whitelist file.
// - At offset 0 of the file: {PackedWhitelistMetadata}
// - Immediately following: {Array of PackedWhitelistModule}
// - Anything else can be stored in the rest of the file.
// - It's a requirement that the file be packed little-endian and also that
// 32-bit alignment == 64-bit alignment (so no handling required).
// - It's also required that the array be *sorted*. First by basename hash,
// second by code_id hash (there can be multiple of the same basename hash).
// -----------------------------------------------------------------------------
#include <stdint.h>
namespace whitelist {
// Subdir relative to install_static::GetUserDataDirectory().
extern const wchar_t kFileSubdir[];
// Packed module data cache file.
extern const wchar_t kBlFileName[];
enum PackedWhitelistVersion : uint32_t {
kInitialVersion = 1,
kCurrent = kInitialVersion,
struct PackedWhitelistMetadata {
// The version of the packed whitelist format. This should always be ordered
// first for backward compatibility purposes.
PackedWhitelistVersion version;
// The number of PackedWhitelistModule elements that follows the metadata in
// the packed whitelist file.
uint32_t module_count;
struct PackedWhitelistModule {
// SHA1 of lowercase basename (no path).
uint8_t basename_hash[20];
// Code ID. This is equivalent to the string generated by formatting
// the FileHeader.TimeDateStamp and OptionalHeader.SizeOfImage with the
// formatting string %08X%x. Then SHA1 the string.
uint8_t code_id_hash[20];
// A timestamp used for tracking "last attempted load". Used to manage
// lifetime of entries in the local caches.
uint32_t time_date_stamp;
// These struct are directly written to a file. Therefore the padding should
// be consistent across compilations.
static_assert(sizeof(PackedWhitelistMetadata) == 8,
"The actual padding of the PackedWhitelistMetadata struct "
"doesn't match the expected padding");
static_assert(sizeof(PackedWhitelistModule) == 44,
"The actual padding of the PackedWhitelistModule struct doesn't "
"match the expected padding");
} // namespace whitelist