mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-11-24 07:10:22 +00:00
!369 Execute abc in safe memory
Merge pull request !369 from xliu/secure_mem
This commit is contained in:
commit
90acfc21cc
@ -298,6 +298,23 @@ std::unique_ptr<const File> OpenPandaFileFromMemory(const void *buffer, size_t s
|
||||
return panda_file::File::OpenFromMemory(std::move(ptr), std::to_string(hash(mem)));
|
||||
}
|
||||
|
||||
std::unique_ptr<const File> OpenPandaFileFromSecureMemory(uint8_t *buffer, size_t size)
|
||||
{
|
||||
if (buffer == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::byte *mem = reinterpret_cast<std::byte *>(buffer);
|
||||
os::mem::ConstBytePtr ptr(mem, size, nullptr);
|
||||
if (ptr.Get() == nullptr) {
|
||||
PLOG(ERROR, PANDAFILE) << "Failed to open panda file from secure memory'";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::hash<std::byte *> hash;
|
||||
return panda_file::File::OpenFromMemory(std::move(ptr), std::to_string(hash(mem)));
|
||||
}
|
||||
|
||||
class ClassIdxIterator {
|
||||
public:
|
||||
using value_type = const uint8_t *;
|
||||
|
@ -479,6 +479,11 @@ std::unique_ptr<const File> OpenPandaFileOrZip(std::string_view location,
|
||||
*/
|
||||
std::unique_ptr<const File> OpenPandaFileFromMemory(const void *buffer, size_t size);
|
||||
|
||||
/*
|
||||
* OpenPandaFileFromMemory from secure buffer.
|
||||
*/
|
||||
std::unique_ptr<const File> OpenPandaFileFromSecureMemory(uint8_t *buffer, size_t size);
|
||||
|
||||
/*
|
||||
* OpenPandaFile from location which specicify the name.
|
||||
*/
|
||||
|
@ -166,6 +166,15 @@ HWTEST(File, OpenPandaFileFromMemory, testing::ext::TestSize.Level0)
|
||||
EXPECT_EQ(pf, nullptr);
|
||||
}
|
||||
|
||||
HWTEST(File, OpenPandaFileFromSecureMemory, testing::ext::TestSize.Level0)
|
||||
{
|
||||
auto pf = OpenPandaFileFromSecureMemory(nullptr, -1);
|
||||
EXPECT_EQ(pf, nullptr);
|
||||
|
||||
pf = OpenPandaFileFromSecureMemory(nullptr, 1U);
|
||||
EXPECT_EQ(pf, nullptr);
|
||||
}
|
||||
|
||||
HWTEST(File, OpenPandaFileFromZipNameAnonMem, testing::ext::TestSize.Level0)
|
||||
{
|
||||
// Create ZIP
|
||||
|
Loading…
Reference in New Issue
Block a user