clang-format issues
This commit is contained in:
parent
ed2b29524c
commit
153362f13e
|
@ -217,36 +217,34 @@ struct AddressSpace::Impl {
|
|||
}
|
||||
|
||||
void Protect(VAddr virtual_addr, size_t size, bool read, bool write, bool execute) {
|
||||
DWORD new_flags{};
|
||||
if (read && write && execute) {
|
||||
new_flags = PAGE_EXECUTE_READWRITE;
|
||||
} else if (read && write) {
|
||||
new_flags = PAGE_READWRITE;
|
||||
} else if (read && !write) {
|
||||
new_flags = PAGE_READONLY;
|
||||
} else if (execute && !read && !write) {
|
||||
new_flags = PAGE_EXECUTE;
|
||||
} else if (!read && !write && !execute) {
|
||||
new_flags = PAGE_NOACCESS;
|
||||
} else {
|
||||
LOG_CRITICAL(Common_Memory, "Unsupported protection flag combination");
|
||||
}
|
||||
DWORD new_flags{};
|
||||
if (read && write && execute) {
|
||||
new_flags = PAGE_EXECUTE_READWRITE;
|
||||
} else if (read && write) {
|
||||
new_flags = PAGE_READWRITE;
|
||||
} else if (read && !write) {
|
||||
new_flags = PAGE_READONLY;
|
||||
} else if (execute && !read && !write) {
|
||||
new_flags = PAGE_EXECUTE;
|
||||
} else if (!read && !write && !execute) {
|
||||
new_flags = PAGE_NOACCESS;
|
||||
} else {
|
||||
LOG_CRITICAL(Common_Memory, "Unsupported protection flag combination");
|
||||
}
|
||||
|
||||
const VAddr virtual_end = virtual_addr + size;
|
||||
auto [it, end] = placeholders.equal_range({virtual_addr, virtual_end});
|
||||
while (it != end) {
|
||||
const size_t offset = std::max(it->lower(), virtual_addr);
|
||||
const size_t protect_length = std::min(it->upper(), virtual_end) - offset;
|
||||
DWORD old_flags{};
|
||||
if (!VirtualProtect(virtual_base + offset, protect_length, new_flags, &old_flags)) {
|
||||
LOG_CRITICAL(Common_Memory, "Failed to change virtual memory protect rules");
|
||||
}
|
||||
++it;
|
||||
auto [it, end] = placeholders.equal_range({virtual_addr, virtual_end});
|
||||
while (it != end) {
|
||||
const size_t offset = std::max(it->lower(), virtual_addr);
|
||||
const size_t protect_length = std::min(it->upper(), virtual_end) - offset;
|
||||
DWORD old_flags{};
|
||||
if (!VirtualProtect(virtual_base + offset, protect_length, new_flags, &old_flags)) {
|
||||
LOG_CRITICAL(Common_Memory, "Failed to change virtual memory protect rules");
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
HANDLE process{};
|
||||
HANDLE backing_handle{};
|
||||
u8* backing_base{};
|
||||
|
@ -468,7 +466,8 @@ void AddressSpace::Unmap(VAddr virtual_addr, size_t size, bool has_backing) {
|
|||
void AddressSpace::Protect(VAddr virtual_addr, size_t size, MemoryPermission perms) {
|
||||
bool read = static_cast<int>(perms & MemoryPermission::Read) != 0;
|
||||
bool write = static_cast<int>(perms & MemoryPermission::Write) != 0;
|
||||
bool execute = static_cast<int>(perms & MemoryPermission::Execute) != 0; // Assuming you have an Execute permission
|
||||
bool execute = static_cast<int>(perms & MemoryPermission::Execute) !=
|
||||
0; // Assuming you have an Execute permission
|
||||
|
||||
return impl->Protect(virtual_addr, size, read, write, execute);
|
||||
}
|
||||
|
|
|
@ -427,7 +427,6 @@ void LibKernel_Register(Core::Loader::SymbolsResolver* sym) {
|
|||
LIB_FUNCTION("9bfdLIyuwCY", "libkernel", 1, "libkernel", 1, 1, sceKernelMTypeProtect);
|
||||
LIB_FUNCTION("vSMAm3cxYTY", "libkernel", 1, "libkernel", 1, 1, sceKernelMProtect);
|
||||
|
||||
|
||||
// misc
|
||||
LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, sceKernelIsNeoMode);
|
||||
LIB_FUNCTION("Ou3iL1abvng", "libkernel", 1, "libkernel", 1, 1, stack_chk_fail);
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/singleton.h"
|
||||
#include "core/address_space.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/kernel/memory_management.h"
|
||||
#include "core/linker.h"
|
||||
#include "core/memory.h"
|
||||
#include "core/address_space.h"
|
||||
|
||||
|
||||
namespace Libraries::Kernel {
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ int MemoryManager::MProtect(VAddr addr, size_t size, int prot) {
|
|||
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
|
||||
// Check if the new protection flags are valid.
|
||||
// Check if the new protection flags are valid.
|
||||
if ((static_cast<int>(prot) &
|
||||
~(static_cast<int>(MemoryProt::NoAccess) | static_cast<int>(MemoryProt::CpuRead) |
|
||||
static_cast<int>(MemoryProt::CpuReadWrite) | static_cast<int>(MemoryProt::GpuRead) |
|
||||
|
@ -313,7 +313,6 @@ int MemoryManager::MProtect(VAddr addr, size_t size, int prot) {
|
|||
int MemoryManager::MTypeProtect(VAddr addr, size_t size, VMAType mtype, int prot) {
|
||||
std::scoped_lock lk{mutex};
|
||||
|
||||
|
||||
// Find the virtual memory area that contains the specified address range.
|
||||
auto it = FindVMA(addr);
|
||||
if (it == vma_map.end() || !it->second.Contains(addr, size)) {
|
||||
|
@ -323,7 +322,6 @@ int MemoryManager::MTypeProtect(VAddr addr, size_t size, VMAType mtype, int prot
|
|||
|
||||
VirtualMemoryArea& vma = it->second;
|
||||
|
||||
|
||||
if (vma.type == VMAType::Free) {
|
||||
LOG_ERROR(Core, "Cannot change protection on free memory region");
|
||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||
|
@ -361,9 +359,6 @@ int MemoryManager::MTypeProtect(VAddr addr, size_t size, VMAType mtype, int prot
|
|||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int MemoryManager::VirtualQuery(VAddr addr, int flags,
|
||||
::Libraries::Kernel::OrbisVirtualQueryInfo* info) {
|
||||
std::scoped_lock lk{mutex};
|
||||
|
|
|
@ -166,7 +166,8 @@ public:
|
|||
|
||||
int VirtualQuery(VAddr addr, int flags, ::Libraries::Kernel::OrbisVirtualQueryInfo* info);
|
||||
|
||||
int DirectMemoryQuery(PAddr addr, bool find_next, ::Libraries::Kernel::OrbisQueryInfo* out_info);
|
||||
int DirectMemoryQuery(PAddr addr, bool find_next,
|
||||
::Libraries::Kernel::OrbisQueryInfo* out_info);
|
||||
|
||||
int DirectQueryAvailable(PAddr search_start, PAddr search_end, size_t alignment,
|
||||
PAddr* phys_addr_out, size_t* size_out);
|
||||
|
|
Loading…
Reference in New Issue