mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu.git
				synced 2025-05-12 00:45:25 +00:00 
			
		
		
		
	Memory: add ReadCString function
This commit is contained in:
		
							parent
							
								
									b879d8c31b
								
							
						
					
					
						commit
						b2df959733
					
				@ -280,6 +280,20 @@ u8* GetPointer(const VAddr vaddr) {
 | 
			
		||||
    return nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::string ReadCString(VAddr vaddr, std::size_t max_length) {
 | 
			
		||||
    std::string string;
 | 
			
		||||
    string.reserve(max_length);
 | 
			
		||||
    for (std::size_t i = 0; i < max_length; ++i) {
 | 
			
		||||
        char c = Read8(vaddr);
 | 
			
		||||
        if (c == '\0')
 | 
			
		||||
            break;
 | 
			
		||||
        string.push_back(c);
 | 
			
		||||
        ++vaddr;
 | 
			
		||||
    }
 | 
			
		||||
    string.shrink_to_fit();
 | 
			
		||||
    return string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
u8* GetPhysicalPointer(PAddr address) {
 | 
			
		||||
    // TODO(Subv): This call should not go through the application's memory mapping.
 | 
			
		||||
    return GetPointer(PhysicalToVirtualAddress(address));
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <cstddef>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include "common/common_types.h"
 | 
			
		||||
 | 
			
		||||
@ -130,6 +131,8 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, size_t size);
 | 
			
		||||
 | 
			
		||||
u8* GetPointer(VAddr virtual_address);
 | 
			
		||||
 | 
			
		||||
std::string ReadCString(VAddr virtual_address, std::size_t max_length);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* 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 New Issue
	
	Block a user