Skip to content

Commit

Permalink
fix nonstandard sizeof() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Nov 13, 2024
1 parent c6b0db0 commit e2e11d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dalamud.Boot/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool utils::loaded_module::find_imported_function_pointer(const char* pcszDllNam
ppFunctionAddress = nullptr;

// This span might be too long in terms of meaningful data; it only serves to prevent accessing memory outsides boundaries.
for (const auto& importDescriptor : span_as<IMAGE_IMPORT_DESCRIPTOR>(directory.VirtualAddress, directory.Size / sizeof IMAGE_IMPORT_DESCRIPTOR)) {
for (const auto& importDescriptor : span_as<IMAGE_IMPORT_DESCRIPTOR>(directory.VirtualAddress, directory.Size / sizeof(IMAGE_IMPORT_DESCRIPTOR))) {

// Having all zero values signals the end of the table. We didn't find anything.
if (!importDescriptor.OriginalFirstThunk && !importDescriptor.TimeDateStamp && !importDescriptor.ForwarderChain && !importDescriptor.FirstThunk)
Expand Down
2 changes: 1 addition & 1 deletion Dalamud.Boot/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace utils {
memory_tenderizer(const void* pAddress, size_t length, DWORD dwNewProtect);

template<typename T, typename = std::enable_if_t<std::is_trivial_v<T>&& std::is_standard_layout_v<T>>>
memory_tenderizer(const T& object, DWORD dwNewProtect) : memory_tenderizer(&object, sizeof T, dwNewProtect) {}
memory_tenderizer(const T& object, DWORD dwNewProtect) : memory_tenderizer(&object, sizeof(T), dwNewProtect) {}

template<typename T>
memory_tenderizer(std::span<const T> s, DWORD dwNewProtect) : memory_tenderizer(&s[0], s.size(), dwNewProtect) {}
Expand Down

0 comments on commit e2e11d5

Please sign in to comment.