Commit Graph

844 Commits

Author SHA1 Message Date
Léo Lam b5a2f34a37 Check TMD sizes using the actual constant
0x49e4 is the actual maximum TMD size (which is checked against in ES).
IsValidTMDSize is added to ESFormats to avoid duplicating the constant.
2017-05-26 11:27:43 +02:00
Pierre Bourdon d592bdd4d4 Migrate to Visual Studio 2017.
Auto-generated by the IDE, I'll trust it knows what it's doing.
2017-05-25 15:58:59 -07:00
Léo Lam cf0c4455cd Fix indirect includes 2017-05-22 10:39:36 +02:00
Silvan Jegen d8db6a7139 NANDImporter: fix printf warning
gcc complains that the printf %x formatting instruction expects an
'unsigned int' but we pass a 'size_t'.  We add the 'z' length formatting
specifier used for 'size_t'
2017-05-21 13:06:40 +02:00
JosJuice 1575020c3a VolumeWiiCrypted: Get title keys from TicketReader 2017-05-20 20:44:12 +02:00
JosJuice 26f5b53ecb VolumeWiiCrypted: Get title IDs from TicketReader 2017-05-20 20:43:31 +02:00
JosJuice 5c68a03ae4 VolumeWiiCrypted: Cache TMDs and tickets 2017-05-20 20:42:44 +02:00
Starsam80 3229cde292
NANDImporter: Add logging 2017-05-19 16:36:06 -06:00
Starsam80 618eb9f743
NANDImporter: Use a indeterminate progress meter 2017-05-19 16:31:47 -06:00
JosJuice 78effbabc6 Replace some usages of IVolume::ReadSwapped with IBlobReader::ReadSwapped
Skips needing to specify PARTITION_NONE.
2017-05-19 21:31:47 +02:00
JosJuice fcb2c5bd29 Remove CBlobBigEndianReader
We can simply put ReadSwapped directly in IBlobReader.
2017-05-19 21:23:00 +02:00
JosJuice ac5c82b36b DiscIO: Remove VolumeCreator
This file is pretty small now that it doesn't handle Wii
partitions anymore, so let's move its contents to Volume.cpp.
This is also more consistent with how blob creation works.
2017-05-19 18:33:21 +02:00
JosJuice 56b218a750 DiscIO: Simplify volume creation
Basically inlining GetDiscType into CreateVolumeFromFilename.
2017-05-19 18:18:43 +02:00
JosJuice fa06d10f4a Merge pull request #2353 from JosJuice/wii-partition-cleanup
VolumeWiiCrypted: Replace ChangePartition with a partition parameter
2017-05-16 23:06:32 +02:00
JosJuice 2bcad57225 Check file system validity before reading opening.bnr
This happened to work without any problems because the only way for a
file system to be invalid was to not have the right GC/Wii magic word
in the unencrypted area, and a volume could not be created without
having the right GC/Wii magic word there. Now that file systems read
the magic word from a partition instead, a fix is needed.
2017-05-16 22:59:01 +02:00
JosJuice 639ce6c484 FileSystemGCWii: Replace m_Wii with m_offset_shift
I replaced m_OffsetShift with m_Wii in bb93336 to support
the decrypt parameter for read functions. Doing that is no
longer necessary, so m_offset_shift is now used like before.
2017-05-16 22:58:57 +02:00
JosJuice 19b8f1c10a VolumeWiiCrypted: Replace ChangePartition with a partition parameter
By removing mutable state in VolumeWiiCrypted, this change makes
partition-related code simpler. It also gets rid of other ugly things,
like ISOProperties's "over 9000" loop that creates a list of
partitions by trying possible combinations, and DiscScrubber's
volume swapping that recreates the entire volume when it needs to
change partition.
2017-05-16 22:58:15 +02:00
JosJuice 74d84c5af2 VolumeWiiCrypted: Turn m_dataOffset into a constant 2017-05-16 22:56:53 +02:00
JosJuice 405643b902 VolumeWiiCrypted: Use std::min 2017-05-14 22:52:21 +02:00
JosJuice 5c46810a36 VolumeWiiCrypted: Store last decrypted offset instead of block number
This makes it unnecessary to reset m_last_decrypted_offset
when changing partition.
2017-05-14 22:52:21 +02:00
Léo Lam c8bffb0153 Reuse the IOS code for WAD installation
* Less code and logic duplication.

* Fixes a bug with the data dir not being created, steps being done in
  the wrong order.
2017-05-14 15:30:42 +02:00
Léo Lam afcda22da9 DiscIO: Add GetContent() for reading content from WADs
Direct access to the WAD bytes is required to read contents with proper
padding data (since they can sometimes end up being outside of the
data app section). Allowing the whole buffer to be accessed directly
would be error prone, so this commit adds GetContent() to WiiWAD
for getting raw content data by index.
2017-05-14 15:30:42 +02:00
Léo Lam bacf52384f IOS/ES: Implement DeleteTitleContent properly
Just like DeleteTitle, Using CNANDContentManager is overkill,
inefficient and useless. And it results in a few failures in
situations where a delete should just always work.

But here it gets bonus points, because it manages to actually use
the TMD for deleting contents, when IOS does none of that and just
deletes files ending with .app in the title content directory. :)
2017-05-13 00:34:58 +02:00
JosJuice 36b9e3dd35 Don't duplicate code for getting paths based on title IDs
I've seen the expression (u32)(title_id >> 32), (u32)title_id
a few more times in my life than I would've liked to...
2017-05-06 17:45:08 +02:00
Michael Maltese f04747e910 NANDImporter: fix printf warning
Fixes warning:

```
Source/Core/DiscIO/NANDImporter.cpp:55:17: warning: format specifies type 'unsigned long' but the argument has type 'u64' (aka 'unsigned long long') [-Wformat]
                file.GetSize(), NAND_BIN_SIZE);
                ^~~~~~~~~~~~~~
1 warning generated.

```
2017-05-02 15:13:46 -07:00
spycrab e66ad018f4 Convert VolumeDirectory names back to SHIFT-JIS (issue #9988) 2017-05-01 14:08:47 +02:00
Léo Lam f56a9b660d Merge pull request #5077 from ds84182/volume_directory_off_by_uno
Fix VolumeDirectory for Wii games
2017-04-29 23:57:32 +02:00
Léo Lam f8ab521e6d Merge pull request #5335 from JosJuice/clinclude-tgcblob
Fix TGCBlob.h's listing in DiscIO.vcxproj.filters
2017-04-29 13:35:26 +02:00
JosJuice d1b54f7697 Fix TGCBlob.h's listing in DiscIO.vcxproj.filters 2017-04-28 18:16:08 +02:00
Léo Lam dae950ff90 IOS: Implement UID/GID changes for the PPC
This will be required for permission checks in the future.

Note that this is only for the PPC as we do not have actual processes.
Keeping track of other modules' UIDs/GIDs is virtually useless anyway.

UID/GID changes are implemented in the following functions:

* ES_Launch
* ES_DIVerify

ES_SetUid is not implemented yet because it'd need further changes.
2017-04-23 23:09:44 +02:00
Dwayne Slater 1b9268485c VolumeDirectory: Pass address shift to WriteEntryData as argument 2017-04-15 14:04:17 -04:00
Dwayne Slater 108d59b131 VolumeDirectory: Correctly check name_offset alignment in assert 2017-04-15 14:04:10 -04:00
Dwayne Slater 138b0cb14e VolumeDirectory: Align the name table size up properly
If the name table isn't rounded up, a Wii game can read an incorrect
number of bytes when fetching the FST.
2017-04-15 14:03:31 -04:00
Dwayne Slater 9d633307e3 VolumeDirectory: Shift parent_entry_index by m_address_shift
Parent entrys were written correctly for GameCube (since the address
shift is 0), but not for Wii (since the address shift is 2).
2017-04-15 13:53:59 -04:00
Dwayne Slater d3e9569cf0 VolumeDirectory: Compare case-insensitive file names as uppercase, not lowercase
Fixes file ordering in games that use ASCII characters between lowercase
'z' and uppercase 'A' (underscores).

MySims Kingdom has the files "terrainLightMapTinted.shader",
"terrainLightMapTintedGrid.shader", and
"terrainLightMapTinted_no_shadow.shader". In lowercase,
"terrainLightMapTinted_no_shadow.shader" comes before
"terrainLightMapTinted.shader" and "terrainLightMapTintedGrid.shader",
which is invalid.
2017-04-15 13:53:53 -04:00
Dwayne Slater 7908302782 VolumeDirectory: Fix off-by-one in entry count calculation
The size field in FSTEntry contains the total amount of children, not
including the parent, but the parent needs to be included.

VolumeDirectory: Fix off-by-one in entry count calculation

The size field in FSTEntry contains the total amount of children, not
including the parent, but the parent needs to be included.
2017-04-15 13:52:46 -04:00
Starsam80 6bccc13f3b
Add BootMii NAND import functionality 2017-04-09 13:14:05 -06:00
Mat M 80a812322e Merge pull request #5152 from ligfx/disciomaybeuninitialized
DiscIO: initialize out args to ReadSwapped (fixes warning)
2017-03-31 00:11:53 -04:00
Léo Lam 7b17163a7a IOS/ES: Move shared content map, uid.sys code
These are all specific to ES and belong there.

The SharedContentMap and UIDSys classes were also modernised.
2017-03-26 12:16:28 +02:00
Michael Maltese 4cd9a2ef1e DiscIO: make sure to initialize out args to ReadSwapped
Fixes warnings:

```
../Source/Core/DiscIO/VolumeGC.cpp: In member function 'virtual u8 DiscIO::CVolumeGC::GetDiscNumber() const':
../Source/Core/DiscIO/VolumeGC.cpp:178:10: error: 'disc_number' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   return disc_number;
          ^
../Source/Core/DiscIO/VolumeWiiCrypted.cpp: In member function 'virtual u8 DiscIO::CVolumeWiiCrypted::GetDiscNumber() const':
../Source/Core/DiscIO/VolumeWiiCrypted.cpp:258:10: error: 'disc_number' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   return disc_number;
          ^
../Source/Core/DiscIO/VolumeWiiCrypted.cpp: In member function 'virtual IOS::ES::TMDReader DiscIO::CVolumeWiiCrypted::GetTMD() const':
../Source/Core/DiscIO/VolumeWiiCrypted.cpp:123:20: error: 'tmd_address' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   tmd_address <<= 2;
                    ^
```
2017-03-25 13:50:23 -07:00
JosJuice a31bb7a27c Clarify the log message for unknown Wii Menu regions
Saying just "title" made it seem like we are showing the title
ID, but what we actually are showing is the title version.
2017-03-24 16:44:38 +01:00
Michael Maltese 0767c3d94d DiscIO: add empty UNKNOWN_REGION case (fixes warning)
Fixes warning:

```
dolphin/Source/Core/DiscIO/Enums.cpp:171:11: warning: enumeration value 'UNKNOWN_REGION' not handled in switch [-Wswitch]
  switch (GetSysMenuRegion(title_version))
          ^
```
2017-03-23 20:14:11 -07:00
Anthony 26bb26fe54 Merge pull request #4901 from JosJuice/filemonitor-redesign
FileMonitor redesign
2017-03-20 12:46:19 -07:00
Matthew Parlane 8eb26d298e Merge pull request #5099 from JosJuice/wii-menu-strings
Display nicer version strings for the Wii Menu
2017-03-20 14:03:04 +13:00
Matthew Parlane 9da35edd15 Merge pull request #5093 from JosJuice/six-char-game-ids
Use 6-char game IDs for NAND tiles (if they are printable)
2017-03-20 13:38:35 +13:00
Léo Lam 194b0ae36d IOS: Add NandUtils
This keeps the ES specific NAND code in a single place and makes it
reusable. Eventually, other ES specific code will be moved to it.
2017-03-19 11:10:45 +01:00
Anthony 9604a06921 Merge pull request #5102 from leoetlino/channel-title-type
Check whether WAD is a channel before reading names
2017-03-18 23:30:27 -07:00
Léo Lam c987f58319 Check whether WAD is a channel before reading names
Dolphin assumes that content 0 is opening.bnr, without checking
whether content 0 exists or if it is even supposed to be there (it's
only there for channels). This results in sometimes reading garbage.

This adds a check to only try to read names from content 0's header
if the title is a channel (channel, system channel or game channel).
2017-03-18 19:07:11 +01:00
JosJuice 9d54e4a9de Return a more meaningful type from GetSysMenuRegion 2017-03-18 10:13:36 +01:00
JosJuice 04c49aa395 Fix GetSysMenuRegion's handling of Wii Menu 1.0
This was a regression in 58bd129.
2017-03-18 10:13:31 +01:00
JosJuice 19d6092847 Display nicer version strings for the Wii Menu
The Tools > Load System Menu option displays the version of the
installed Wii Menu. This commit changes the way we display that
version, like so: "Load System Menu 514P" -> "Load System Menu 4.3E"

The numbers are from http://wiibrew.org/wiki/System_Menu
2017-03-18 10:08:13 +01:00
JosJuice ff7425214a Use 6-char game IDs for NAND tiles (if they are printable)
5.0-2712 made ES's code for setting the game ID use the
title ID converted to hex (except for disc titles) instead
of using a 6-char game ID like before. Then, 5.0-2830 made
us use that code even when loading game INIs. This breaks the
expectations of both users and the game INIs we ship with.

This commit makes Dolphin use 6-char game IDs for all
titles (unless the 6-char ID would contain unprintable
characters, which is the case with e.g. the Wii Menu).

I'm also putting unprintability checks in VolumeWad
for consistency.
2017-03-16 11:21:31 +01:00
JosJuice 58bd129987 Simplify GetSysMenuRegion 2017-03-16 10:45:57 +01:00
JosJuice b470fa5454 FileMonitor redesign
Advantages:

* Simpler code in general
* No extra volume objects created
* Now actually notices if the disc or partition gets
  changed while the core is running
* No longer picks up on disc access done by the GUI
  (it used to do so as long as the core was running)
* Gets rid of a Core dependency in DiscIO

There are two performance disadvantages:

* FileMonitor is now a bit slower when used with VolumeDirectory
  because FileMonitor now always uses the FileSystemGCWii code
  for finding filenames instead of VolumeDirectory finding the
  filename on its own and directly hooking into FileMonitor.
  But this isn't such a big deal, because it's happening on the
  DVD thread, and my currently unmerged file system PR will make
  FileSystemGCWii's file finding code about as fast as
  VolumeDirectory's.
* FileMonitor's creation of the file system object is now
  done on the CPU thread instead of the DVD thread, and
  it will be done even if FileMonitor logging is disabled.
  This will be fixed in the next commit.
2017-03-13 17:13:20 +01:00
JosJuice acec02ffc6 Remove Blob nullptr checks from Volume code
There's no point in creating a volume without a blob,
since essentially all the functionality of a volume
requires a blob to be used.

Also, VolumeCreator doesn't support creating volumes
without blobs (it can't even figure out the volume type
unless it gets a blob), so it's currently impossible
for a volume to be created without a blob.
2017-03-13 14:13:55 +01:00
JosJuice 135733e285 Volume: Use ReadSwapped more
Most of the Volume code was written before this
convenience function was added. Let's use it more.

Also deleting m_pReader nullptr checks that are
unnecessary because of Read (which ReadSwapped calls)
already having a nullptr check.
2017-03-09 21:03:28 +01:00
JosJuice ab616145c2 Get the right game ID for SSBB's Masterpiece partitions 2017-03-09 18:47:40 +01:00
Mat M 7fa14169e9 Merge pull request #5007 from lioncash/swap
Common: Move byte swapping utilities into their own header
2017-03-05 09:45:29 -05:00
Léo Lam b1ffbef5ce IOS/ES: Implement ES_GetOwnedTitles 2017-03-04 20:33:35 +01:00
Lioncash 552c0d8404 Common: Move byte swapping utilities into their own header
This moves all the byte swapping utilities into a header named Swap.h.

A dedicated header is much more preferable here due to the size of the
code itself. In general usage throughout the codebase, CommonFuncs.h was
generally only included for these functions anyway. These being in their
own header avoids dumping the lesser used utilities into scope. As well
as providing a localized area for more utilities related to byte
swapping in the future (should they be needed). This also makes it nicer
to identify which files depend on the byte swapping utilities in
particular.

Since this is a completely new header, moving the code uncovered a few
indirect includes, as well as making some other inclusions unnecessary.
2017-03-03 17:18:18 -05:00
Léo Lam 4d776ffa8f IOS/ES: Keep track of the active title properly
This changes ES to keep track of the active title properly,
just like IOS:

* It is NOT changed on resource manager open/close.
* It is reset on IOS reload.
* It is changed by ES_DIVerify and ES_Launch.

IOS stores the active title in a structure like this:

    struct ESTitleContext
    {
      Ticket* ticket;
      TMD* tmd;
      u32 active;
    };

With this commit, we also do keep the Ticket and TMD around. This
makes some of the DI ioctlvs (which return data about the current
active title) trivial to implement in the future.

This fixes the System Menu not being able to see update partitions
and also allows us to change Dolphin's active game info in the future.
2017-03-02 20:28:01 +01:00
Mat M 78e7f4aae3 Merge pull request #4984 from leoetlino/content-fixes
IOS/ES: Title import fixes + hack removals (fix for System Menu disc updates)
2017-03-02 14:17:29 -05:00
Lioncash ee61bd6f2e CMakeLists: Normalize whitespace
Normalizes tabs to spaces to follow our codebase's indentation style.
2017-03-01 14:53:23 -05:00
Léo Lam ac27aff9c8 Add ES::Content::IsShared to avoid hardcoding 0x8000 2017-03-01 17:36:07 +01:00
Léo Lam 6327a29847 IOS/ES: Implement ES_Export* ioctlvs
This should allow channels to be copied to the SD properly.
2017-02-27 21:26:28 +01:00
Léo Lam 44a3db21e4 ES: Make sure the TMD and ticket are valid before use 2017-02-26 19:46:30 +01:00
Léo Lam 5104caf6a6 Move AES code to Common/Crypto 2017-02-26 19:46:30 +01:00
Léo Lam c1a139e8ac Use ESFormats for TMDs
We already have a TMDReader, so let's actually use it.

And move ESFormats to IOS::ES, since it's definitely part of IOS.
This adds a DiscIO dependency on Core which will be fixed in a
follow-up PR.
2017-02-26 19:46:29 +01:00
Léo Lam bf1f70db0a Move the ticket code to ESFormats
This moves some parsing code for tickets and ticket views to ESFormats
instead of duplicating it over DiscIO and Core.
2017-02-26 19:46:28 +01:00
JosJuice 298e81881f Forward declare IBlobReader in Volume headers
We have to do this (or include Blob.h) since the
constructors take unique_ptr<IBlobReader> parameters.
2017-02-19 08:40:30 +01:00
JosJuice f80f7b6f9c Merge pull request #4883 from JosJuice/dvd-timing-address-translation-2
DVDInterface: Translate Wii partition offsets for timing purposes
2017-02-15 21:12:42 +01:00
JosJuice 49ec22bc42 DVDInterface: Translate Wii partition offsets for timing purposes
Until now, Dolphin has been using the wrong values
for calculating DVD timing for decrypted Wii reads
(which Wii games essentially always use).
2017-02-12 09:37:39 +01:00
JosJuice c96bcace2f VolumeWiiCrypted: Use constant naming style for constants 2017-02-11 12:56:48 +01:00
Léo Lam 850802ea88 Get rid of a singleton for NAND shared contents
This also allows shared contents to be installed to the configured root
when installing a WAD.
2017-02-10 22:46:38 +01:00
Léo Lam 7a1f676ef4 Always use configured root when installing WAD
This prevents Dolphin from writing to /sys/uid.sys (on the host; root
partition) when installing a WAD before starting emulation, because
the session root is not initialized at that moment.

Incidentally, this also gets rid of a singleton.
2017-02-10 19:12:08 +01:00
Lioncash e07383a783 Core: Convert State enum into an enum class 2017-02-05 08:32:23 -05:00
Matthew Parlane 017e8050b6 Merge pull request #4746 from JosJuice/volumedirectory-sort-case-insensitive
VolumeDirectory: Use case-insensitive comparison when sorting
2017-01-27 18:23:14 +13:00
JosJuice 104faa9fb3 VolumeDirectory: Use case-insensitive comparison when sorting
This fixes a regression from 5.0-1556, but I don't know why
the regression occurred or why this fixes it. (Many games
failed to fully boot - I tried Metroid Prime and Twilight
Princess (both GC), and they never got to the title screen.)
2017-01-25 15:07:07 +01:00
Léo Lam 3d21280ab4 DiscIO: Fix out-of-bounds access in NANDContentDataBuffer
Accessing buffer[start + size] triggers an error (and a crash) in debug
builds. Using std::copy_n fixes this.
2017-01-23 21:49:26 +01:00
Léo Lam b892d78872 VolumeWad: Implement GetTMD()
This allows getting useful info like the required IOS version for WADs
(for showing it in the UI, for example).
2017-01-23 20:59:02 +01:00
Léo Lam f89aaee91a VolumeWad: Remove useless else after return 2017-01-23 18:17:34 +01:00
Léo Lam 2cd287baf7 VolumeWad: Add missing forward declaration 2017-01-23 18:17:34 +01:00
Léo Lam 6128679396 VolumeWad: Clean up variable naming 2017-01-23 18:07:23 +01:00
Léo Lam 6d909b3e30 VolumeWad: In-class initialise member variables 2017-01-23 18:07:21 +01:00
Markus Wick 90ee85f4e8 Merge pull request #4714 from JosJuice/wbfs-file-entry
Fix -Wshadow warning for file_entry
2017-01-22 17:56:51 +01:00
JosJuice 79f3b5c5ff Fix -Wshadow warning for file_entry
This struct didn't follow our naming convention,
so let's rename the struct itself instead of
the variable that triggered the warning.
2017-01-22 17:27:37 +01:00
BhaaL 07d1f18f53 CompressFileToBlob: add an explicit seek to make sure we're at the start 2017-01-21 21:42:58 +01:00
BhaaL 30e0f3d9ca DecompressFileToBlob: don't assume success if decompression failed 2017-01-21 21:42:58 +01:00
BhaaL 24be8c0814 IsGCZBlob: try to leave the file position where it was before
callers that don't seek afterwards might be missing a few bytes that way.
2017-01-21 21:42:57 +01:00
Pierre Bourdon 334ddf754e DiscIO: Export GetKeyFromTicket
This function has more uses than just in DiscIO (e.g. WFS).
2017-01-14 17:06:40 +01:00
Pierre Bourdon 650a1fdb1f DiscIO: Implement functions to lookup tickets
These two functions load either a signed ticket or a raw ticket from the
emulated NAND.

The ticket signature skip is refactored out of the ticket writing in
order to be usable by the raw ticket reading function.
2017-01-14 17:06:40 +01:00
Pierre Bourdon 2ed352698f IOS/ES: Implement ES_AddTicket.
Refactor the existing DiscIO::AddTicket to not require the caller to
pass the requested title ID. We do not have the title ID in the ES case,
and it needs to be extracted from the ticket. Since this is always a
safe operation to do (title ID is always in the ticket), the
implementation is made default.
2017-01-14 15:23:16 +01:00
Matthew Parlane 9838afea41 Merge pull request #4479 from GerbilSoft/feature/RVT-R.dev-key
Support for RVT-R disc images
2017-01-13 09:56:50 +13:00
Matthew Parlane d346d4ced1 Merge pull request #4544 from JosJuice/region-enum
DiscIO: Add GetRegion function and Region enum
2017-01-13 09:19:27 +13:00
JosJuice b1873264d7 WbfsBlob: Don't wrap file_entry in std::unique_ptr
There doesn't seem to be any reason for doing it.
2017-01-11 13:39:46 +01:00
JosJuice 0363be4320 WbfsBlob: Remove m_total_files
std::vector already keeps track of this for us.
2017-01-11 13:39:38 +01:00
JosJuice 5c02795af0 WbfsBlob: Only open each file once
The first file used to be opened once by
CreateBlobReader and once inside WbfsFileReader.
2017-01-11 13:33:27 +01:00
JosJuice 8d54bbc528 Don't create new IOFiles when creating a blob
...except for WBFS, which is special because
it has the ability to open multiple files.
2017-01-11 13:23:23 +01:00
JosJuice d1ea00ed88 Only open file once when detecting blob type 2017-01-11 13:23:19 +01:00
Lioncash a93861ab49 DiscScrubber: Don't take SFileInfo instances by value
Avoids unnecessary copies.
2017-01-04 20:12:49 -05:00