clang-format and fix release build

This commit is contained in:
Luke Street 2025-09-26 12:10:56 -06:00
parent f83d228cc1
commit 8b29e1bcbb
3 changed files with 42 additions and 46 deletions

View File

@ -51,15 +51,16 @@ struct PEExportDirectory {
#define FOR_256_2(a, b) \
FOR_256_3(a, b, 0, 0) \
FOR_256_3(a, b, 0, 1) \
FOR_256_3(a, b, 0, 2) FOR_256_3(a, b, 0, 3) FOR_256_3(a, b, 1, 0) FOR_256_3(a, b, 1, 1) FOR_256_3(a, b, 1, 2) \
FOR_256_3(a, b, 1, 3) FOR_256_3(a, b, 2, 0) FOR_256_3(a, b, 2, 1) FOR_256_3(a, b, 2, 2) FOR_256_3(a, b, 2, 3) \
FOR_256_3(a, b, 3, 0) FOR_256_3(a, b, 3, 1) FOR_256_3(a, b, 3, 2) FOR_256_3(a, b, 3, 3)
FOR_256_3(a, b, 0, 2) \
FOR_256_3(a, b, 0, 3) FOR_256_3(a, b, 1, 0) FOR_256_3(a, b, 1, 1) FOR_256_3(a, b, 1, 2) FOR_256_3(a, b, 1, 3) \
FOR_256_3(a, b, 2, 0) FOR_256_3(a, b, 2, 1) FOR_256_3(a, b, 2, 2) FOR_256_3(a, b, 2, 3) FOR_256_3(a, b, 3, 0) \
FOR_256_3(a, b, 3, 1) FOR_256_3(a, b, 3, 2) FOR_256_3(a, b, 3, 3)
#define FOR_256 \
FOR_256_2(0, 0) \
FOR_256_2(0, 1) \
FOR_256_2(0, 2) FOR_256_2(0, 3) FOR_256_2(1, 0) FOR_256_2(1, 1) FOR_256_2(1, 2) FOR_256_2(1, 3) FOR_256_2(2, 0) \
FOR_256_2(2, 1) FOR_256_2(2, 2) FOR_256_2(2, 3) FOR_256_2(3, 0) FOR_256_2(3, 1) FOR_256_2(3, 2) \
FOR_256_2(3, 3)
FOR_256_2(0, 2) \
FOR_256_2(0, 3) FOR_256_2(1, 0) FOR_256_2(1, 1) FOR_256_2(1, 2) FOR_256_2(1, 3) FOR_256_2(2, 0) FOR_256_2(2, 1) \
FOR_256_2(2, 2) FOR_256_2(2, 3) FOR_256_2(3, 0) FOR_256_2(3, 1) FOR_256_2(3, 2) FOR_256_2(3, 3)
static int stubIndex = 0;
static char stubDlls[0x100][0x100];

View File

@ -1,5 +1,5 @@
#include "common.h"
#include "resources.h"
#include "common.h"
namespace {
@ -56,8 +56,7 @@ bool resourceNameEquals(const uint8_t *base, uint32_t nameField, const std::u16s
}
const ImageResourceDirectoryEntry *findEntry(const uint8_t *base, const ImageResourceDirectory *dir,
const wibo::ResourceIdentifier &ident,
uint32_t rsrcSize) {
const wibo::ResourceIdentifier &ident, uint32_t rsrcSize) {
const auto *entries = resourceEntries(dir);
if (ident.isString) {
for (uint16_t i = 0; i < dir->numberOfNamedEntries; ++i) {
@ -75,7 +74,8 @@ const ImageResourceDirectoryEntry *findEntry(const uint8_t *base, const ImageRes
return nullptr;
}
const ImageResourceDirectory *entryAsDirectory(const uint8_t *base, const ImageResourceDirectoryEntry *entry, uint32_t rsrcSize) {
const ImageResourceDirectory *entryAsDirectory(const uint8_t *base, const ImageResourceDirectoryEntry *entry,
uint32_t rsrcSize) {
if (!(entry->offsetToData & RESOURCE_DATA_IS_DIRECTORY))
return nullptr;
uint32_t offset = entry->offsetToData & ~RESOURCE_DATA_IS_DIRECTORY;
@ -84,7 +84,8 @@ const ImageResourceDirectory *entryAsDirectory(const uint8_t *base, const ImageR
return reinterpret_cast<const ImageResourceDirectory *>(base + offset);
}
const wibo::ImageResourceDataEntry *entryAsData(const uint8_t *base, const ImageResourceDirectoryEntry *entry, uint32_t rsrcSize) {
const wibo::ImageResourceDataEntry *entryAsData(const uint8_t *base, const ImageResourceDirectoryEntry *entry,
uint32_t rsrcSize) {
if (entry->offsetToData & RESOURCE_DATA_IS_DIRECTORY)
return nullptr;
uint32_t offset = entry->offsetToData;
@ -93,14 +94,10 @@ const wibo::ImageResourceDataEntry *entryAsData(const uint8_t *base, const Image
return reinterpret_cast<const wibo::ImageResourceDataEntry *>(base + offset);
}
uint16_t primaryLang(uint16_t lang) {
return lang & 0x3FFu;
}
uint16_t primaryLang(uint16_t lang) { return lang & 0x3FFu; }
const ImageResourceDirectoryEntry *selectLanguageEntry(const ImageResourceDirectory *dir,
const uint8_t *base,
uint32_t rsrcSize,
std::optional<uint16_t> desired,
const ImageResourceDirectoryEntry *selectLanguageEntry(const ImageResourceDirectory *dir, const uint8_t *base,
uint32_t rsrcSize, std::optional<uint16_t> desired,
uint16_t &chosenLang) {
const auto *entries = resourceEntries(dir);
uint16_t total = dir->numberOfNamedEntries + dir->numberOfIdEntries;
@ -143,10 +140,8 @@ const ImageResourceDirectoryEntry *selectLanguageEntry(const ImageResourceDirect
namespace wibo {
bool Executable::findResource(const ResourceIdentifier &type,
const ResourceIdentifier &name,
std::optional<uint16_t> language,
ResourceLocation &out) const {
bool Executable::findResource(const ResourceIdentifier &type, const ResourceIdentifier &name,
std::optional<uint16_t> language, ResourceLocation &out) const {
const uint8_t *base = reinterpret_cast<const uint8_t *>(rsrcBase);
if (!base) {
wibo::lastError = ERROR_RESOURCE_DATA_NOT_FOUND;
@ -201,9 +196,7 @@ bool resourceEntryBelongsToExecutable(const Executable &exe, const ImageResource
return ptr >= base && (ptr + sizeof(*entry)) <= (base + exe.rsrcSize);
}
static bool isIntegerIdentifier(const void *ptr) {
return ((uintptr_t)ptr >> 16) == 0;
}
static bool isIntegerIdentifier(const void *ptr) { return ((uintptr_t)ptr >> 16) == 0; }
static std::u16string ansiToU16String(const char *str) {
std::u16string result;

View File

@ -148,11 +148,13 @@ std::string wideStringToString(const uint16_t *src, int len) {
std::string result(count, '\0');
for (size_t i = 0; i < count; ++i) {
uint16_t value = src[i];
#ifndef NDEBUG
if (i > 0)
hexDump << ' ';
hexDump << "0x" << value;
if (value > 0xFF)
sawWide = true;
#endif
result[i] = static_cast<char>(value & 0xFF);
}