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