dolphin/Source/Core/DiscIO/WiiWad.h
Léo Lam 9000a042e4 Drop the direct WAD launch hack
This removes the hack that enables directly booting from WADs
without installing them first for the following reasons:

1. It makes the NAND content handling much more complicated than what
   it should be and makes future changes like permissions or booting
   NAND titles without a WAD more annoying to implement.

   Because of this hack, we needed an extra level of abstraction
   (NANDContent*) which has to read tons of things from the NAND, even
   most of the time it's useless. This in turn forces us to have
   caching, which is known to break titles and requires manual cache
   invalidations. Annoying and error prone.

2. It prevents the WAD boot code from being easily accurate. With this
   change, we can simply reuse the existing launch code, and ask IOS
   to launch the title from the NAND.

3. The hack did not work that well since it did not cover a lot of ES
   commands. And it works even less since the ES accuracy fixes.
   This results in Dolphin returning inconsistent results: a
   lot of the ES "DI" commands will just fail because the active title
   is not installed on the NAND. uid.sys is not changed, etc.

   And I'm not even talking about FS stuff -- where this would still
   totally fail, unless we add even more unnecessary hacks.

   This is not just theoretical -- the system menu and the Wii Shop are
   known to behave strangely because the hack damages the NAND
   structure, and we've already had several users report issues.

This commit makes it so WADs are always installed prior to launching.
A future commit will remove any code that was there only for the hack.
2017-10-24 11:41:54 +02:00

50 lines
1.2 KiB
C++

// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "Core/IOS/ES/Formats.h"
namespace DiscIO
{
class BlobReader;
class WiiWAD
{
public:
explicit WiiWAD(const std::string& name);
explicit WiiWAD(std::unique_ptr<BlobReader> blob_reader);
WiiWAD(WiiWAD&&) = default;
WiiWAD& operator=(WiiWAD&&) = default;
~WiiWAD();
bool IsValid() const { return m_valid; }
const std::vector<u8>& GetCertificateChain() const { return m_certificate_chain; }
const IOS::ES::TicketReader& GetTicket() const { return m_ticket; }
const IOS::ES::TMDReader& GetTMD() const { return m_tmd; }
const std::vector<u8>& GetDataApp() const { return m_data_app; }
const std::vector<u8>& GetFooter() const { return m_footer; }
std::vector<u8> GetContent(u16 index) const;
private:
bool ParseWAD();
bool m_valid = false;
std::unique_ptr<BlobReader> m_reader;
u64 m_data_app_offset = 0;
std::vector<u8> m_certificate_chain;
IOS::ES::TicketReader m_ticket;
IOS::ES::TMDReader m_tmd;
std::vector<u8> m_data_app;
std::vector<u8> m_footer;
};
}