1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-09-20 05:53:24 +01:00

fs.mitm: skeleton logic for protecting autorcm.

This commit is contained in:
Michael Scire 2018-11-14 19:49:12 -08:00
parent e1cc1b8d29
commit 878ac59aae

View file

@ -125,16 +125,21 @@ class SectoredProxyStorage : public ProxyStorage {
class Boot0Storage : public SectoredProxyStorage<0x200> { class Boot0Storage : public SectoredProxyStorage<0x200> {
using Base = SectoredProxyStorage<0x200>; using Base = SectoredProxyStorage<0x200>;
private: private:
bool allow_writes; u64 title_id;
private: private:
HosMutex *GetMutex() { HosMutex *GetMutex() {
static HosMutex s_boot0_mutex; static HosMutex s_boot0_mutex;
return &s_boot0_mutex; return &s_boot0_mutex;
} }
bool AllowWrites() {
return title_id < 0x0100000000001000ULL;
}
bool CanModifyBctPubks() {
return title_id != 0x010000000000001FULL;
}
public: public:
Boot0Storage(FsStorage *s, bool w) : Base(s), allow_writes(w) { } Boot0Storage(FsStorage *s, u64 t) : Base(s), title_id(t) { }
Boot0Storage(FsStorage s, bool w) : Base(s), allow_writes(w) { } Boot0Storage(FsStorage s, u64 t) : Base(s), title_id(t) { }
public: public:
virtual Result Read(void *_buffer, size_t size, u64 offset) override { virtual Result Read(void *_buffer, size_t size, u64 offset) override {
GetMutex()->Lock(); GetMutex()->Lock();
@ -147,10 +152,16 @@ class Boot0Storage : public SectoredProxyStorage<0x200> {
GetMutex()->Lock(); GetMutex()->Lock();
ON_SCOPE_EXIT { GetMutex()->Unlock(); }; ON_SCOPE_EXIT { GetMutex()->Unlock(); };
if (!this->allow_writes) { if (!AllowWrites()) {
return 0x313802; return 0x313802;
} }
return Base::Write(_buffer, size, offset); /* We care about protecting autorcm from NS. */
if (CanModifyBctPubks()) {
return Base::Write(_buffer, size, offset);
}
/* TODO */
return 0x313802;
} }
}; };