mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 04:50:14 +00:00
Memory/Utils: Added a function to retrieve a string from emulated memory.
This commit is contained in:
parent
4b1ae3a24e
commit
d964ab667f
@ -183,6 +183,15 @@ u8* GetPointer(const VAddr vaddr) {
|
|||||||
return nullptr;
|
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) {
|
u8* GetPhysicalPointer(PAddr address) {
|
||||||
return GetPointer(PhysicalToVirtualAddress(address));
|
return GetPointer(PhysicalToVirtualAddress(address));
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
@ -130,6 +131,15 @@ void WriteBlock(VAddr addr, const u8* data, size_t size);
|
|||||||
|
|
||||||
u8* GetPointer(VAddr virtual_address);
|
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
|
* 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.
|
* address. This should be used by services to translate addresses for use by the hardware.
|
||||||
|
Loading…
Reference in New Issue
Block a user