diff --git a/ARMeilleure/Translation/SsaConstruction.cs b/ARMeilleure/Translation/SsaConstruction.cs index f74d6c712..2b6efc113 100644 --- a/ARMeilleure/Translation/SsaConstruction.cs +++ b/ARMeilleure/Translation/SsaConstruction.cs @@ -140,7 +140,7 @@ namespace ARMeilleure.Translation } } - Array.Clear(localDefs, 0, localDefs.Length); + Array.Clear(localDefs); } } diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs index ef0a1a645..210b369c3 100644 --- a/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs +++ b/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserProfile.cs @@ -4,8 +4,6 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc { public class UserProfile { - private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - public UserId UserId { get; } public long LastModifiedTimestamp { get; set; } @@ -83,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc private void UpdateLastModifiedTimestamp() { - LastModifiedTimestamp = (long)(DateTime.Now - Epoch).TotalSeconds; + LastModifiedTimestamp = (long)(DateTime.Now - DateTime.UnixEpoch).TotalSeconds; } } } \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs b/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs index 357815627..522de8e03 100644 --- a/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs +++ b/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs @@ -100,27 +100,24 @@ namespace Ryujinx.HLE.HOS.Services.Caps Unknown0x1f = 1 }; - using (SHA256 sha256Hash = SHA256.Create()) + // NOTE: The hex hash is a HMAC-SHA256 (first 32 bytes) using a hardcoded secret key over the titleId, we can simulate it by hashing the titleId instead. + string hash = BitConverter.ToString(SHA256.HashData(BitConverter.GetBytes(titleId))).Replace("-", "").Remove(0x20); + string folderPath = Path.Combine(_sdCardPath, "Nintendo", "Album", currentDateTime.Year.ToString("00"), currentDateTime.Month.ToString("00"), currentDateTime.Day.ToString("00")); + string filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash); + + // TODO: Handle that using the FS service implementation and return the right error code instead of throwing exceptions. + Directory.CreateDirectory(folderPath); + + while (File.Exists(filePath)) { - // NOTE: The hex hash is a HMAC-SHA256 (first 32 bytes) using a hardcoded secret key over the titleId, we can simulate it by hashing the titleId instead. - string hash = BitConverter.ToString(sha256Hash.ComputeHash(BitConverter.GetBytes(titleId))).Replace("-", "").Remove(0x20); - string folderPath = Path.Combine(_sdCardPath, "Nintendo", "Album", currentDateTime.Year.ToString("00"), currentDateTime.Month.ToString("00"), currentDateTime.Day.ToString("00")); - string filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash); + applicationAlbumEntry.AlbumFileDateTime.UniqueId++; - // TODO: Handle that using the FS service implementation and return the right error code instead of throwing exceptions. - Directory.CreateDirectory(folderPath); - - while (File.Exists(filePath)) - { - applicationAlbumEntry.AlbumFileDateTime.UniqueId++; - - filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash); - } - - // NOTE: The saved JPEG file doesn't have the limitation in the extra EXIF data. - Image.LoadPixelData(screenshotData, 1280, 720).SaveAsJpegAsync(filePath); + filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash); } + // NOTE: The saved JPEG file doesn't have the limitation in the extra EXIF data. + Image.LoadPixelData(screenshotData, 1280, 720).SaveAsJpegAsync(filePath); + return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IRtcManager.cs b/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IRtcManager.cs index f1808923f..6e1e9e6d6 100644 --- a/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IRtcManager.cs +++ b/Ryujinx.HLE/HOS/Services/Pcv/Bpc/IRtcManager.cs @@ -24,9 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Bpc public static ResultCode GetExternalRtcValue(out ulong rtcValue) { // TODO: emulate MAX77620/MAX77812 RTC - DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - rtcValue = (ulong)(DateTime.Now.ToUniversalTime() - unixEpoch).TotalSeconds; + rtcValue = (ulong)(DateTime.Now.ToUniversalTime() - DateTime.UnixEpoch).TotalSeconds; return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs index 0d1ae27f2..a111d5d65 100644 --- a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs @@ -142,14 +142,9 @@ namespace Ryujinx.HLE.HOS.Services.Ro _owner.CpuMemory.Read(nroAddress, nroData); - byte[] nroHash = null; - MemoryStream stream = new MemoryStream(nroData); - using (SHA256 hasher = SHA256.Create()) - { - nroHash = hasher.ComputeHash(stream); - } + byte[] nroHash = SHA256.HashData(stream); if (!IsNroHashPresent(nroHash)) { diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs index 94c1b4885..0070193f2 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs @@ -10,8 +10,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public static readonly TimeSpanType Zero = new TimeSpanType(0); - private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - public long NanoSeconds; public TimeSpanType(long nanoSeconds) @@ -31,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public bool IsDaylightSavingTime() { - return UnixEpoch.AddSeconds(ToSeconds()).ToLocalTime().IsDaylightSavingTime(); + return DateTime.UnixEpoch.AddSeconds(ToSeconds()).ToLocalTime().IsDaylightSavingTime(); } public static TimeSpanType FromSeconds(long seconds)