mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-04 07:38:47 +00:00 
			
		
		
		
	Memory: move IsValidVirtualAddress into class
This commit is contained in:
		
							parent
							
								
									296c458e0e
								
							
						
					
					
						commit
						405218c3a7
					
				
					 6 changed files with 27 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -105,6 +105,7 @@ public:
 | 
			
		|||
private:
 | 
			
		||||
    Core::System& system;
 | 
			
		||||
    Kernel::KernelSystem& kernel;
 | 
			
		||||
    Memory::MemorySystem& memory;
 | 
			
		||||
 | 
			
		||||
    friend class SVCWrapper<SVC>;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -346,7 +347,7 @@ ResultCode SVC::UnmapMemoryBlock(Handle handle, u32 addr) {
 | 
			
		|||
 | 
			
		||||
/// Connect to an OS service given the port name, returns the handle to the port to out
 | 
			
		||||
ResultCode SVC::ConnectToPort(Handle* out_handle, VAddr port_name_address) {
 | 
			
		||||
    if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), port_name_address))
 | 
			
		||||
    if (!memory.IsValidVirtualAddress(*kernel.GetCurrentProcess(), port_name_address))
 | 
			
		||||
        return ERR_NOT_FOUND;
 | 
			
		||||
 | 
			
		||||
    static constexpr std::size_t PortNameMaxLength = 11;
 | 
			
		||||
| 
						 | 
				
			
			@ -451,7 +452,7 @@ ResultCode SVC::WaitSynchronizationN(s32* out, VAddr handles_address, s32 handle
 | 
			
		|||
                                     bool wait_all, s64 nano_seconds) {
 | 
			
		||||
    Thread* thread = kernel.GetThreadManager().GetCurrentThread();
 | 
			
		||||
 | 
			
		||||
    if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address))
 | 
			
		||||
    if (!memory.IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address))
 | 
			
		||||
        return ERR_INVALID_POINTER;
 | 
			
		||||
 | 
			
		||||
    // NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If
 | 
			
		||||
| 
						 | 
				
			
			@ -622,7 +623,7 @@ static ResultCode ReceiveIPCRequest(SharedPtr<ServerSession> server_session,
 | 
			
		|||
/// In a single operation, sends a IPC reply and waits for a new request.
 | 
			
		||||
ResultCode SVC::ReplyAndReceive(s32* index, VAddr handles_address, s32 handle_count,
 | 
			
		||||
                                Handle reply_target) {
 | 
			
		||||
    if (!Memory::IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address))
 | 
			
		||||
    if (!memory.IsValidVirtualAddress(*kernel.GetCurrentProcess(), handles_address))
 | 
			
		||||
        return ERR_INVALID_POINTER;
 | 
			
		||||
 | 
			
		||||
    // Check if 'handle_count' is invalid
 | 
			
		||||
| 
						 | 
				
			
			@ -1584,7 +1585,7 @@ void SVC::CallSVC(u32 immediate) {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SVC::SVC(Core::System& system) : system(system), kernel(system.Kernel()) {}
 | 
			
		||||
SVC::SVC(Core::System& system) : system(system), kernel(system.Kernel()), memory(system.Memory()) {}
 | 
			
		||||
 | 
			
		||||
u32 SVC::GetReg(std::size_t n) {
 | 
			
		||||
    return system.CPU().GetReg(static_cast<int>(n));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -303,7 +303,7 @@ ResultVal<SharedPtr<Thread>> KernelSystem::CreateThread(std::string name, VAddr
 | 
			
		|||
 | 
			
		||||
    // TODO(yuriks): Other checks, returning 0xD9001BEA
 | 
			
		||||
 | 
			
		||||
    if (!Memory::IsValidVirtualAddress(owner_process, entry_point)) {
 | 
			
		||||
    if (!memory.IsValidVirtualAddress(owner_process, entry_point)) {
 | 
			
		||||
        LOG_ERROR(Kernel_SVC, "(name={}): invalid entry {:08x}", name, entry_point);
 | 
			
		||||
        // TODO: Verify error
 | 
			
		||||
        return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue