04827466b0
This removes one the last remnants of the SourceMod 1.0 VM implementation. The new parser introduces a number of design changes in the VM. First, the VM now takes greater responsibility for validating and sanity checking the structure of the SMX container format. Previously, malformed SMX files could easily crash SourcePawn. The loader now rejects files that have out-of-bounds offsets or incomplete sections. Complex sections, like debug info or the code stream, are verified lazily. Internally, the sp_plugin_t structure has been removed. It has been replaced by a new LegacyImage class, designed to be independent from the SPVM API. This potentially lets us load code streams from non-.smx containers. More importantly, it removes a lot of bookkeeping and pre-computed state from PluginRuntime. The LegacyImage class is now responsible for handling debug info as well. PluginRuntime is now intended to hold only cached or immutable data, and PluginContext holds all VM state. As such PluginContext is now responsible for allocating a plugin's runtime memory, not PluginRuntime. Finally, some aspects of the loading process have been cleaned up. The decompression and image handoff logic should now be easier to understand.
48 lines
981 B
C++
48 lines
981 B
C++
// vim: set sts=2 ts=8 sw=2 tw=99 et:
|
|
//
|
|
// Copyright (C) 2004-2015 AlliedModers LLC
|
|
//
|
|
// This file is part of SourcePawn. SourcePawn is licensed under the GNU
|
|
// General Public License, version 3.0 (GPL). If a copy of the GPL was not
|
|
// provided with this file, you can obtain it here:
|
|
// http://www.gnu.org/licenses/gpl.html
|
|
//
|
|
#ifndef _include_sourcepawn_file_parser_h_
|
|
#define _include_sourcepawn_file_parser_h_
|
|
|
|
#include <stdio.h>
|
|
#include <am-utility.h>
|
|
|
|
namespace sp {
|
|
|
|
enum class FileType {
|
|
UNKNOWN,
|
|
AMX,
|
|
AMXMODX,
|
|
SPFF
|
|
};
|
|
|
|
FileType DetectFileType(FILE *fp);
|
|
|
|
class FileReader
|
|
{
|
|
public:
|
|
FileReader(FILE *fp);
|
|
FileReader(ke::AutoArray<uint8_t> &buffer, size_t length);
|
|
|
|
const uint8_t *buffer() const {
|
|
return buffer_;
|
|
}
|
|
size_t length() const {
|
|
return length_;
|
|
}
|
|
|
|
protected:
|
|
ke::AutoArray<uint8_t> buffer_;
|
|
size_t length_;
|
|
};
|
|
|
|
} // namespace sp
|
|
|
|
#endif // _include_sourcepawn_file_parser_h_
|