Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shared/tree_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class TreeContainer
}

const int count = boost::lexical_cast<int>(match[2]);
return match[1].str() + std::to_string(count + 1);
return std::format("{}{}", match[1].str(), count + 1);
}

bool unassign(const std::shared_ptr<SharedMemoryT>& shm, TreeMeta* tree)
Expand Down
3 changes: 2 additions & 1 deletion src/shared/winapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ std::vector<FileResult> quickFindFiles(LPCWSTR directoryName, LPCWSTR pattern)
return result;
}

bool createPath(boost::filesystem::path path, LPSECURITY_ATTRIBUTES securityAttributes)
bool createPath(const boost::filesystem::path& path,
LPSECURITY_ATTRIBUTES securityAttributes)
{
// sanity and guaranteed recursion end:
if (!path.has_relative_path())
Expand Down
2 changes: 1 addition & 1 deletion src/shared/winapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ std::vector<FileResult> quickFindFiles(LPCWSTR directoryName, LPCWSTR pattern);
* @return true if the directory (and possibly parent directories) were actually created
* and false if the directory already existed. Throws exceptions on failure.
*/
bool createPath(boost::filesystem::path path,
bool createPath(const boost::filesystem::path& path,
LPSECURITY_ATTRIBUTES securityAttributes = nullptr);
inline bool createPath(LPCWSTR path, LPSECURITY_ATTRIBUTES securityAttributes = nullptr)
{
Expand Down
11 changes: 6 additions & 5 deletions src/thooklib/ttrampolinepool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,11 @@ LPVOID TrampolinePool::currentBufferAddress(LPVOID addressNear)
auto lookupAddress = m_Buffers.find(rounded);

if (lookupAddress == m_Buffers.end()) {
lookupAddress = m_Buffers.insert(std::make_pair(rounded, BufferList())).first;
lookupAddress =
m_Buffers.try_emplace(rounded /* automatically emplaces default BufferList() */)
.first;
}
if (lookupAddress->second.buffers.size() == 0) {
if (lookupAddress->second.buffers.empty()) {
allocateBuffer(addressNear);
}

Expand All @@ -503,7 +505,7 @@ TrampolinePool::BufferMap::iterator TrampolinePool::allocateBuffer(LPVOID addres
LPVOID rounded = roundAddress(addressNear);
auto iter = m_Buffers.find(rounded);
uintptr_t lowerEnd = reinterpret_cast<uintptr_t>(rounded);
if (iter->second.buffers.size() > 0) {
if (!iter->second.buffers.empty()) {
// start searching were we last found a buffer
lowerEnd = reinterpret_cast<uintptr_t>(*iter->second.buffers.rbegin()) +
sysInfo.dwPageSize;
Expand Down Expand Up @@ -584,8 +586,7 @@ LPVOID TrampolinePool::releaseInt(LPVOID func)
m_ThreadGuards.reset(new TThreadMap());
}

auto iter = m_ThreadGuards->find(func);
if (iter == m_ThreadGuards->end()) {
if (!m_ThreadGuards->contains(func)) {
spdlog::get("hooks")->error("failed to release barrier for func {}", func);
::SetLastError(lastError);
return nullptr;
Expand Down
8 changes: 4 additions & 4 deletions src/usvfs_dll/hookmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ void HookManager::installHook(HMODULE module1, HMODULE module2,
spdlog::get("usvfs")->error("failed to hook {0}: {1}", functionName,
GetErrorString(err));
} else {
m_Stubs.insert(make_pair(funcAddr, functionName));
m_Hooks.insert(make_pair(std::string(functionName), handle));
m_Stubs.try_emplace(funcAddr, functionName);
m_Hooks.try_emplace(std::string(functionName), handle);
spdlog::get("usvfs")->info("hooked {0} ({1}) in {2} type {3}", functionName,
funcAddr, winapi::ansi::getModuleFileName(usedModule),
GetHookType(handle));
Expand Down Expand Up @@ -213,8 +213,8 @@ void HookManager::installStub(HMODULE module1, HMODULE module2,
spdlog::get("usvfs")->error("failed to stub {0}: {1}", functionName,
GetErrorString(err));
} else {
m_Stubs.insert(make_pair(funcAddr, functionName));
m_Hooks.insert(make_pair(std::string(functionName), handle));
m_Stubs.try_emplace(funcAddr, functionName);
m_Hooks.try_emplace(std::string(functionName), handle);
spdlog::get("usvfs")->info("stubbed {0} ({1}) in {2} type {3}", functionName,
funcAddr, winapi::ansi::getModuleFileName(usedModule),
GetHookType(handle));
Expand Down
5 changes: 3 additions & 2 deletions src/usvfs_dll/maptracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ class RerouteW
}
}

static bool createFakePath(fs::path path, LPSECURITY_ATTRIBUTES securityAttributes)
static bool createFakePath(const fs::path& path,
LPSECURITY_ATTRIBUTES securityAttributes)
{
// sanity and guaranteed recursion end:
if (!path.has_relative_path())
Expand Down Expand Up @@ -516,7 +517,7 @@ class RerouteW
auto res = create(context, callContext, inPath);
if (res.wasRerouted() || !interestingPath(inPath) || !callContext.active() ||
pathExists(inPath))
return std::move(res);
return res;
}
return createNew(context, callContext, inPath, createPath, securityAttributes);
}
Expand Down
6 changes: 3 additions & 3 deletions src/usvfs_dll/usvfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void __cdecl InitHooks(LPVOID parameters, size_t)
auto context = manager->context();
auto exePath = boost::dll::program_location();
auto libraries = context->librariesToForceLoad(exePath.filename().c_str());
for (auto library : libraries) {
for (const auto& library : libraries) {
if (std::filesystem::exists(library)) {
const auto ret = LoadLibraryExW(library.c_str(), NULL, 0);
if (ret) {
Expand Down Expand Up @@ -588,9 +588,9 @@ bool assertPathExists(usvfs::RedirectionTreeContainer& table, LPCWSTR path)
usvfs::RedirectionTree::NodeT* current = table.get();

for (auto iter = p.begin(); iter != p.end(); iter = ush::nextIter(iter, p.end())) {
if (current->exists(iter->string().c_str())) {
if (current->exists(iter->string())) {
// subdirectory exists virtually, all good
usvfs::RedirectionTree::NodePtrT found = current->node(iter->string().c_str());
usvfs::RedirectionTree::NodePtrT found = current->node(iter->string());
current = found.get().get();
} else {
// targetPath is relative to the last rerouted "real" path. This means
Expand Down