Ensure enough data available while disassembling

This commit is contained in:
user4520 2021-10-17 13:35:03 +02:00 committed by Xenxo Espasandín
parent 1d32f27680
commit a015ab8708
2 changed files with 40 additions and 38 deletions

View File

@ -1,38 +1,39 @@
// Copyright 2021 xensik. All rights reserved. // Copyright 2021 xensik. All rights reserved.
// //
// Use of this source code is governed by a GNU GPLv3 license // Use of this source code is governed by a GNU GPLv3 license
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
#pragma once #pragma once
// Warnings // Warnings
#ifdef _WIN32 #ifdef _WIN32
#pragma warning(disable:4244) #pragma warning(disable:4244)
#pragma warning(disable:4267) #pragma warning(disable:4267)
#pragma warning(disable:4005) #pragma warning(disable:4005)
#pragma warning(disable:4065) #pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
// C/C++ // C/C++
#include <regex> #include <regex>
#include <string> #include <string>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <algorithm> #include <algorithm>
#include <filesystem> #include <filesystem>
#include <functional> #include <functional>
#include <stdexcept> #include <stdexcept>
#include <map> #include <map>
#include <stack> #include <stack>
#include <array> #include <array>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include <unordered_map> #include <unordered_map>
#include <stdio.h> #include <stdio.h>
#include <cassert>
// Ext
using namespace std::literals; // Ext
using namespace std::literals;
#include "xsk/iw5.hpp"
#include "xsk/iw5.hpp"

View File

@ -71,6 +71,7 @@ void disassembler::dissasemble_function(const gsc::function_ptr& func)
func->instructions.push_back(std::make_unique<gsc::instruction>()); func->instructions.push_back(std::make_unique<gsc::instruction>());
auto& inst = func->instructions.back(); auto& inst = func->instructions.back();
inst->index = static_cast<std::uint32_t>(script_->pos()); inst->index = static_cast<std::uint32_t>(script_->pos());
assert(script_->is_avail());
inst->opcode = script_->read<std::uint8_t>(); inst->opcode = script_->read<std::uint8_t>();
inst->size = opcode_size(inst->opcode); inst->size = opcode_size(inst->opcode);