diff options
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/kernel/process.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/kernel/process.h | 44 |
2 files changed, 35 insertions, 15 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 5403ceef5..edf34c5a3 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -142,9 +142,9 @@ void Process::LoadModule(SharedPtr<CodeSet> module_, VAddr base_addr) { }; // Map CodeSet segments - MapSegment(module_->code, VMAPermission::ReadExecute, MemoryState::CodeStatic); - MapSegment(module_->rodata, VMAPermission::Read, MemoryState::CodeMutable); - MapSegment(module_->data, VMAPermission::ReadWrite, MemoryState::CodeMutable); + MapSegment(module_->CodeSegment(), VMAPermission::ReadExecute, MemoryState::CodeStatic); + MapSegment(module_->RODataSegment(), VMAPermission::Read, MemoryState::CodeMutable); + MapSegment(module_->DataSegment(), VMAPermission::ReadWrite, MemoryState::CodeMutable); } ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 98d8da35e..f29ee67c6 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -55,6 +55,12 @@ enum class ProcessStatus { Created, Running, Exited }; class ResourceLimit; struct CodeSet final : public Object { + struct Segment { + size_t offset = 0; + VAddr addr = 0; + u32 size = 0; + }; + static SharedPtr<CodeSet> Create(std::string name); std::string GetTypeName() const override { @@ -69,24 +75,38 @@ struct CodeSet final : public Object { return HANDLE_TYPE; } - /// Name of the process - std::string name; + Segment& CodeSegment() { + return segments[0]; + } - std::shared_ptr<std::vector<u8>> memory; + const Segment& CodeSegment() const { + return segments[0]; + } - struct Segment { - size_t offset = 0; - VAddr addr = 0; - u32 size = 0; - }; + Segment& RODataSegment() { + return segments[1]; + } - Segment segments[3]; - Segment& code = segments[0]; - Segment& rodata = segments[1]; - Segment& data = segments[2]; + const Segment& RODataSegment() const { + return segments[1]; + } + + Segment& DataSegment() { + return segments[2]; + } + + const Segment& DataSegment() const { + return segments[2]; + } + + std::shared_ptr<std::vector<u8>> memory; + Segment segments[3]; VAddr entrypoint; + /// Name of the process + std::string name; + private: CodeSet(); ~CodeSet() override; |