WiiUPluginLoaderBackend/source/plugin/PluginData.h

78 lines
1.9 KiB
C
Raw Normal View History

/****************************************************************************
* Copyright (C) 2020 Maschell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#pragma once
2020-05-03 12:30:15 +02:00
#include <optional>
#include <vector>
#include <malloc.h>
#include <coreinit/memexpheap.h>
#include "elfio/elfio.hpp"
using namespace ELFIO;
enum eMemoryTypes {
eMemTypeMEM2,
eMemTypeExpHeap
};
class PluginData {
public:
2020-05-03 12:30:15 +02:00
const std::optional<elfio *> &getReader() const {
return reader;
}
2020-05-03 12:30:15 +02:00
~PluginData() {
2020-05-03 12:30:15 +02:00
if (nReader != NULL) {
delete nReader;
nReader = NULL;
}
}
void freeMemory();
2020-05-03 12:30:15 +02:00
private:
2020-05-17 20:43:04 +02:00
PluginData(const PluginData &obj);
PluginData() {
}
PluginData(std::vector<uint8_t> buffer);
2020-05-03 12:30:15 +02:00
PluginData(std::vector<uint8_t> input, MEMHeapHandle heapHandle, eMemoryTypes memoryType);
void loadReader();
2020-05-03 12:30:15 +02:00
static std::optional<PluginData> createFromExistingData(const void *buffer, MEMHeapHandle heapHandle, eMemoryTypes memoryType, const size_t length);
2020-05-03 12:30:15 +02:00
std::optional<elfio *> reader;
elfio *nReader = NULL;
void *buffer;
MEMHeapHandle heapHandle;
eMemoryTypes memoryType;
size_t length;
2020-05-03 12:30:15 +02:00
friend class PluginDataFactory;
2020-05-03 12:30:15 +02:00
friend class PluginContainer;
2020-05-03 12:30:15 +02:00
2020-05-17 20:45:10 +02:00
friend class PluginDataPersistence;
};