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.
//
// Use of this source code is governed by a GNU GPLv3 license
// that can be found in the LICENSE file.
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4005)
#pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <fstream>
#include <unordered_map>
#include <stdio.h>
// Ext
using namespace std::literals;
#include "xsk/iw5.hpp"
// Copyright 2021 xensik. All rights reserved.
//
// Use of this source code is governed by a GNU GPLv3 license
// that can be found in the LICENSE file.
#pragma once
// Warnings
#ifdef _WIN32
#pragma warning(disable:4244)
#pragma warning(disable:4267)
#pragma warning(disable:4005)
#pragma warning(disable:4065)
#define _CRT_SECURE_NO_WARNINGS
#endif
// C/C++
#include <regex>
#include <string>
#include <vector>
#include <memory>
#include <algorithm>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <map>
#include <stack>
#include <array>
#include <iostream>
#include <sstream>
#include <fstream>
#include <unordered_map>
#include <stdio.h>
#include <cassert>
// Ext
using namespace std::literals;
#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>());
auto& inst = func->instructions.back();
inst->index = static_cast<std::uint32_t>(script_->pos());
assert(script_->is_avail());
inst->opcode = script_->read<std::uint8_t>();
inst->size = opcode_size(inst->opcode);