mirror of
https://github.com/decompals/wibo.git
synced 2025-10-18 08:05:10 +00:00
clang-format and fix release build
This commit is contained in:
parent
f83d228cc1
commit
8b29e1bcbb
@ -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];
|
||||
@ -416,7 +417,7 @@ void ensureInitialized() {
|
||||
}
|
||||
|
||||
void registerExternalModuleAliases(const std::string &requestedName, const std::filesystem::path &resolvedPath,
|
||||
wibo::ModuleInfo *info) {
|
||||
wibo::ModuleInfo *info) {
|
||||
ParsedModuleName parsed = parseModuleName(requestedName);
|
||||
registerAlias(normalizedBaseKey(parsed), info);
|
||||
registerAlias(normalizeAlias(requestedName), info);
|
||||
@ -428,24 +429,24 @@ wibo::ModuleInfo *moduleFromAddress(void *addr) {
|
||||
return nullptr;
|
||||
auto ® = registry();
|
||||
for (auto &pair : reg.modulesByKey) {
|
||||
wibo::ModuleInfo *info = pair.second.get();
|
||||
if (!info)
|
||||
continue;
|
||||
uint8_t *base = nullptr;
|
||||
size_t size = 0;
|
||||
if (info->imageBase && info->imageSize) {
|
||||
base = static_cast<uint8_t *>(info->imageBase);
|
||||
size = info->imageSize;
|
||||
} else if (info->executable) {
|
||||
base = static_cast<uint8_t *>(info->executable->imageBuffer);
|
||||
size = info->executable->imageSize;
|
||||
}
|
||||
if (!base || size == 0)
|
||||
continue;
|
||||
uint8_t *ptr = static_cast<uint8_t *>(addr);
|
||||
if (ptr >= base && ptr < base + size) {
|
||||
return info;
|
||||
}
|
||||
wibo::ModuleInfo *info = pair.second.get();
|
||||
if (!info)
|
||||
continue;
|
||||
uint8_t *base = nullptr;
|
||||
size_t size = 0;
|
||||
if (info->imageBase && info->imageSize) {
|
||||
base = static_cast<uint8_t *>(info->imageBase);
|
||||
size = info->imageSize;
|
||||
} else if (info->executable) {
|
||||
base = static_cast<uint8_t *>(info->executable->imageBuffer);
|
||||
size = info->executable->imageSize;
|
||||
}
|
||||
if (!base || size == 0)
|
||||
continue;
|
||||
uint8_t *ptr = static_cast<uint8_t *>(addr);
|
||||
if (ptr >= base && ptr < base + size) {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -624,7 +625,7 @@ HMODULE loadModule(const char *dllName) {
|
||||
return nullptr;
|
||||
}
|
||||
std::string requested(dllName);
|
||||
DEBUG_LOG("loadModule(%s)\n", requested.c_str());
|
||||
DEBUG_LOG("loadModule(%s)\n", requested.c_str());
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(registry().mutex);
|
||||
ensureInitialized();
|
||||
|
@ -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,15 +94,11 @@ 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,
|
||||
uint16_t &chosenLang) {
|
||||
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;
|
||||
const ImageResourceDirectoryEntry *primaryMatch = nullptr;
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user