Commit Graph

9036 Commits (6467b01de2debf86db8c409160ab50d24d32149e)
 

Author SHA1 Message Date
Lioncash 6467b01de2 partition_data_manager: Reserve and insert data within output vector in DecryptPackage2()
We can just reserve the memory then perform successive insertions
instead of needing to use memcpy. This also avoids the need to zero out
the output vector's memory before performing the insertions.

We can also std::move the output std::vector into the destination so
that we don't need to make a completely new copy of the vector, getting
rid of an unnecessary allocation.

Additionally, we can use iterators to determine the beginning and end
ranges of the std::vector instances that comprise the output vector, as
the end of one range just becomes the beginning for the next successive
range, and since std::vector's iterator constructor copies data within
the range [begin, end), this is more straightforward and gets rid of the
need to have an offset variable that keeps getting incremented to
determine where to do the next std::memcpy.
Lioncash 781fd7983c partition_data_manager: Remove unused std::map instance within DecryptPackage2()
Aside from emplacing elements into the map, the map itself is never
actually queried for contained data.
Lioncash e0c76226ad partition_data_manager: Take package2_keys by const reference
These are only ever read from, so we don't need to make a copy of all
the keys here.
Lioncash 3d9df49619 partition_data_manager: Move IV data to where it's needed in DecryptPackage2()
Given it's only used in one spot and has a fairly generic name, we can
just specify it directly in the function call. This also the benefit of
automatically moving it.
Lioncash bc2196bb09 partition_data_manager: Remove commented out code
Commented out code shouldn't be left in without a reason indicating why
in a comment.
Lioncash 6da2ed4232 key_manager/partition_data_manager: Silence truncation compiler warnings
Lioncash f56a8da46a partition_data_manager: Dehardcode array bounds
Instead, we can make it part of the type and make named variables for
them, so they only require one definition (and if they ever change for
whatever reason, they only need to be changed in one spot).
Lioncash d257a3b56c partition_data_manager: Take VirtualFile by const reference in constructor
Given the VirtualFile instance isn't stored into the class as a data
member, or written to, this can just be turned into a const reference,
as the constructor doesn't need to make a copy of it.
Lioncash e96d69c328 partition_data_manager: Amend constructor initializer list order
Orders the members in the exact order they would be initialized. This
also prevents compiler warnings about this sort of thing.
Lioncash aaca7543f0 partition_data_manager: Remove unused includes
Gets unused includes out of the headers and moves them into the cpp file
if they're used there instead.
Lioncash 06898263f6 key_manager: Use std::vector's insert() instead of std::copy with a back_inserter
If the data is unconditionally being appended to the back of a
std::vector, we can just directly insert it there without the need to
insert all of the elements one-by-one with a std::back_inserter.
Lioncash e70c08b543 key_manager: Brace long conditional body
If a conditional (or it's body) travels more than one line, it should be
braced.
Lioncash ef5639bfbb key_manager: Don't assume file seeks and reads will always succeed
Given the filesystem should always be assumed to be volatile, we should
check and bail out if a seek operation isn't successful. This'll prevent
potentially writing/returning garbage data from the function in rare
cases.

This also allows removing a check to see if an offset is within the
bounds of a file before perfoming a seek operation. If a seek is
attempted beyond the end of a file, it will fail, so this essentially
combines two checks into one in one place.
Lioncash 82ea1cf35a key_manager: Remove unnecessary seek in DeriveSDSeed()
Given the file is opened a few lines above and no operations are done,
other than check if the file is in a valid state, the read/write pointer
will always be at the beginning of the file.
bunnei 1584fb6b38
Merge pull request from DarkLordZach/key-derivation
crypto: Add support for full key derivation
bunnei c2aa4293ec
Merge pull request from lioncash/codeset
kernel/process: Make CodeSet a regular non-inherited object
bunnei 38b027aa81
Merge pull request from FernandoS27/calculate-size
Implemented helper function to correctly calculate a texture's size
bunnei ffcda6c08e
Merge pull request from lioncash/typo
svc: Fix typos in sanitizing checks for MapMemory/UnmapMemory
FernandoS27 97b6405a17 Implemented helper function to correctly calculate a texture's size
bunnei 2946d4bdbe
Merge pull request from ogniK5377/svcbreak-type-fix
Fixed incorrect types for svcBreak
Lioncash 1abed2f4c4 kernel/process: Make CodeSet a regular non-inherited object
These only exist to ferry data into a Process instance and end up going
out of scope quite early. Because of this, we can just make it a plain
struct for holding things and just std::move it into the relevant
function. There's no need to make this inherit from the kernel's Object
type.
bunnei 0f7ab3e21a
Merge pull request from ogniK5377/remap-invalidhandle-remap
Passing an invalid nmap handle to Remap should throw an error
bunnei f9d03b1d41
Merge pull request from lioncash/init
thread: Remove unnecessary memset from ResetThreadContext()
bunnei dc328440c8
Merge pull request from ogniK5377/nmap-revamped
Added error codes for nvmap
Lioncash b492d43e63 thread: Remove unnecessary memset from ResetThreadContext()
Regular value initialization is adequate here for zeroing out data. It
also has the benefit of not invoking undefined behavior if a non-trivial
type is ever added to the struct for whatever reason.
David Marcec 4d2de6564f Returned an error before processing other remaps
David Marcec c55b5de0fb Made the minimum alignment more clear
Lioncash 4ccf30dfaa svc: Fix typos in sanitizing checks for MapMemory/UnmapMemory
bunnei 9bf409f275
Merge pull request from ogniK5377/hwopus-decodeinterleavedwithperformance
HwOpus, Implemented DecodeInterleavedWithPerformance
bunnei 3fd26b7147
Merge pull request from lioncash/san
svc: Add missing address range sanitizing checks to MapMemory/UnmapMemory
bunnei bc293e1751
Merge pull request from bunnei/fix-unmap-flush
nvhost_as_gpu: Flush/invalidate CPU VAddr on UnmapBuffer.
bunnei 83ac3e6395
Merge pull request from ReinUsesLisp/vmad
gl_shader_decompiler: Implement VMAD
David Marcec c7763603ef Added error codes for nvmap
David Marcec 5dd538cace Passing an invalid nmap handle to Remap should throw an error
Added error for invalid nmap handles
ReinUsesLisp 17290a4416 gl_shader_decompiler: Implement VMAD
bunnei bf795edac4 nvhost_as_gpu: Flush CPU VAddr on UnmapBuffer.
David Marcec fa10905e1e HwOpus, Implemented DecodeInterleavedWithPerformance
Used by sonic ages
bunnei 6d82c4adf9
Merge pull request from FernandoS27/fix-render-target-block-settings
Fixed block height settings for RenderTargets and Depth Buffers
Lioncash 72e9cb523e svc: Add missing address range sanitizing checks to MapMemory/UnmapMemory
This adds the missing address range checking that the service functions
do before attempting to map or unmap memory. Given that both service
functions perform the same set of checks in the same order, we can wrap
these into a function and just call it from both functions, which
deduplicates a little bit of code.
bunnei 03ec936ca0
Merge pull request from FernandoS27/scissor_test
Implemented Scissor Testing
bunnei ee1b204749
Merge pull request from ReinUsesLisp/geometry-shaders
gl_shader_decompiler: Implement geometry shaders
bunnei 68b3d8b7a9
Merge pull request from lioncash/ptr
kernel/thread: Use a regular pointer for the owner/current process
Lioncash 5c0408596f kernel/thread: Use a regular pointer for the owner/current process
There's no real need to use a shared pointer in these cases, and only
makes object management more fragile in terms of how easy it would be to
introduce cycles. Instead, just do the simple thing of using a regular
pointer. Much of this is just a hold-over from citra anyways.

It also doesn't make sense from a behavioral point of view for a
process' thread to prolong the lifetime of the process itself (the
process is supposed to own the thread, not the other way around).
bunnei 5461b21c7a
Merge pull request from lioncash/warn
ips_layer: Silence truncation and conversion warnings
bunnei 3ac874c32e
Merge pull request from lioncash/unique
patch_manager: Return a std::unique_ptr from ParseControlNCA() and GetControlMetadata() instead of a std::shared_ptr
FernandoS27 5f4ee6f0c8 Add memory Layout to Render Targets and Depth Buffers
David Marcec 2db37ddea9 Changed all casts in svc_wrap.h to be static_cast instead
David Marcec 09b6dda8f0 Use a better name than "dont_kill_application"
signal_debugger seems like a more fitting name
David Marcec a4412c8e22 Fixed incorrect types for svcBreak
svcBreak reason should be a u32, not a u64.
FernandoS27 af653906d0 Fixed block height settings for RenderTargets and Depth Buffers, and added block width and block depth