mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-27 00:28:14 +00:00
fix(shader): normalize mapped cache entry and pack paths
(cherry picked from commit 0a3621bbbfd27bafb1ff5b97208eaf51ba90ccf0)
This commit is contained in:
1 parent
56778c97d2
commit
340f5784b0
2 files changed
+8
-2
No files matched your search
@@ -40,7 +40,10 @@ std::vector<std::filesystem::path> PrebuiltCachePaths(const std::filesystem::pat
|
||||
CachePack::CachePack(const std::filesystem::path& path) {
|
||||
static_assert(std::endian::native == std::endian::little);
|
||||
#ifdef _WIN32
|
||||
const auto handle = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
std::error_code pathError;
|
||||
const auto filename = NativeCachePath_nid_no_patch(path, pathError);
|
||||
if (pathError) { error = "cannot resolve"; return; }
|
||||
const auto handle = CreateFileW(filename.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (handle == INVALID_HANDLE_VALUE) { error = "cannot open"; return; }
|
||||
LARGE_INTEGER size{};
|
||||
if (!GetFileSizeEx(handle, &size) || size.QuadPart < static_cast<LONGLONG>(sizeof(PackHeader)) || static_cast<std::uint64_t>(size.QuadPart) > std::numeric_limits<std::size_t>::max()) {
|
||||
|
||||
@@ -195,7 +195,10 @@ private:
|
||||
|
||||
std::shared_ptr<const MappedFile> MapFile(const std::filesystem::path& path) {
|
||||
#ifdef _WIN32
|
||||
const HANDLE file = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
std::error_code error;
|
||||
const auto filename = NativeCachePath_nid_no_patch(path, error);
|
||||
if (error) return nullptr;
|
||||
const HANDLE file = CreateFileW(filename.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (file == INVALID_HANDLE_VALUE) return nullptr;
|
||||
LARGE_INTEGER length{};
|
||||
if (!GetFileSizeEx(file, &length) || length.QuadPart <= 0 || static_cast<unsigned long long>(length.QuadPart) > std::numeric_limits<std::size_t>::max()) {
|
||||
|
||||
Reference in new issue
Block a user