[+] IProcessSectionView::MapIPCMemory now takes a 'length' parameter

This commit is contained in:
Reece Wilson 2022-08-11 12:28:20 +01:00
parent f98174b7a2
commit 51facdb6a3
5 changed files with 24 additions and 3 deletions

View File

@ -29,6 +29,7 @@ namespace Aurora::Process
virtual AuSPtr<IProcessSectionMapView> MapIPCMemory(const AuString &handle,
AuUInt64 offset,
AuUInt64 length,
Aurora::IO::FS::EFileOpenMode mode) = 0;
};

View File

@ -176,6 +176,7 @@ namespace Aurora::Process
AuSPtr<IProcessSectionMapView> ProcessSectionView::MapIPCMemory(const AuString &handleString,
AuUInt64 offset,
AuUInt64 length,
AuFS::EFileOpenMode mode)
{
AuIPC::IPCHandle handle;
@ -195,8 +196,14 @@ namespace Aurora::Process
return {};
}
auto length = token->token.word;
auto path = token->token.ToNTPath();
auto actualLength = token->token.word;
auto path = token->token.ToNTPath();
if (actualLength < offset + length)
{
SysPushErrorIO("Out of range");
return {};
}
switch (mode)
{

View File

@ -27,6 +27,7 @@ namespace Aurora::Process
AuSPtr<IProcessSectionMapView> MapIPCMemory(const AuString &handle,
AuUInt64 offset,
AuUInt64 length,
AuFS::EFileOpenMode mode) override;
};

View File

@ -115,6 +115,7 @@ namespace Aurora::Process
AuSPtr<IProcessSectionMapView> ProcessSectionView::MapIPCMemory(const AuString &handleString,
AuUInt64 offset,
AuUInt64 length,
AuFS::EFileOpenMode mode)
{
AuIPC::IPCHandle handle;
@ -132,7 +133,15 @@ namespace Aurora::Process
return {};
}
auto path = AuIPC::GetServerPath(val->token);
auto actualLength = val->token.word;
auto path = AuIPC::GetServerPath(val->token);
if (actualLength < offset + length)
{
SysPushErrorIO("Out of range");
return {};
}
int fd = ::shm_open(path.c_str(), O_RDWR, S_IRUSR | S_IWUSR);
if (fd == -1)
{
@ -140,6 +149,8 @@ namespace Aurora::Process
return {};
}
// TODO (Reece): lock garbage ( ??? )
int prot {};
switch (mode)
{

View File

@ -27,6 +27,7 @@ namespace Aurora::Process
AuSPtr<IProcessSectionMapView> MapIPCMemory(const AuString &handle,
AuUInt64 offset,
AuUInt64 length,
AuFS::EFileOpenMode mode) override;
};