Memory/Utils: Added a function to retrieve a string from emulated memory.
This commit is contained in:
parent
a8ff29adae
commit
c80394fd00
2 changed files with 24 additions and 5 deletions
|
@ -149,6 +149,15 @@ u8* GetPointer(const VAddr vaddr) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::string GetString(const VAddr vaddr, const u32 size) {
|
||||
std::string string;
|
||||
string.reserve(size);
|
||||
for (u32 offset = 0; offset < size; ++offset)
|
||||
string.push_back(Read8(vaddr + offset));
|
||||
return string;
|
||||
|
||||
}
|
||||
|
||||
u8* GetPhysicalPointer(PAddr address) {
|
||||
return GetPointer(PhysicalToVirtualAddress(address));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
|
@ -130,6 +131,15 @@ void WriteBlock(VAddr addr, const u8* data, size_t size);
|
|||
|
||||
u8* GetPointer(VAddr virtual_address);
|
||||
|
||||
/**
|
||||
* Reads a fixed-size string of the specified size starting at
|
||||
* the specified address and returns a copy of it.
|
||||
* @param vaddr Starting address of the string.
|
||||
* @param size Size of the string.
|
||||
* @return A copy of the string that was read.
|
||||
*/
|
||||
std::string GetString(const VAddr vaddr, const u32 size);
|
||||
|
||||
/**
|
||||
* Converts a virtual address inside a region with 1:1 mapping to physical memory to a physical
|
||||
* address. This should be used by services to translate addresses for use by the hardware.
|
||||
|
|
Loading…
Reference in a new issue