mirror of
https://github.com/bitdefender/bddisasm.git
synced 2025-01-22 04:50:55 +00:00
Added a check for the latest version of the library which is compatible with pybddisasm.
This commit is contained in:
parent
90c020a114
commit
3d8401be4c
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
#define _SIGNAL_H
|
#define _SIGNAL_H
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
#include <assert.h>
|
||||||
#include "pybddisasm.h"
|
#include "pybddisasm.h"
|
||||||
|
|
||||||
|
|
||||||
@ -334,7 +335,7 @@ static PyObject *_pybddisasm_build_operand(ND_OPERAND *operand)
|
|||||||
nd_operand = Py_BuildValue("{}");
|
nd_operand = Py_BuildValue("{}");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PyErr_SetString(PyExc_RuntimeError, "invalid operand type... Talk with @csirb to update pybddisasm...");
|
PyErr_SetString(PyExc_RuntimeError, "invalid operand type...");
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +366,7 @@ static PyObject *_pybddisasm_build_operand(ND_OPERAND *operand)
|
|||||||
|
|
||||||
static PyObject *_pybddisasm_build_operands(ND_OPERAND *operands, size_t count)
|
static PyObject *_pybddisasm_build_operands(ND_OPERAND *operands, size_t count)
|
||||||
{
|
{
|
||||||
char op_str_format[400] = {'[', 0};
|
char op_str_format[1024] = {'[', 0};
|
||||||
size_t last = 1;
|
size_t last = 1;
|
||||||
|
|
||||||
PyObject *nd_operands[ND_MAX_OPERAND] = {0};
|
PyObject *nd_operands[ND_MAX_OPERAND] = {0};
|
||||||
@ -1127,5 +1128,7 @@ static struct PyModuleDef pybddisasm =
|
|||||||
|
|
||||||
PyMODINIT_FUNC PyInit__pybddisasm(void)
|
PyMODINIT_FUNC PyInit__pybddisasm(void)
|
||||||
{
|
{
|
||||||
|
static_assert(sizeof(INSTRUX) == LIBRARY_INSTRUX_SIZE, "The size of INSTRUX is not compatible with pybddisasm!");
|
||||||
|
|
||||||
return PyModule_Create(&pybddisasm);
|
return PyModule_Create(&pybddisasm);
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,51 @@ import re
|
|||||||
from setuptools import find_packages, setup, Command, Extension, Distribution
|
from setuptools import find_packages, setup, Command, Extension, Distribution
|
||||||
from codecs import open
|
from codecs import open
|
||||||
|
|
||||||
VERSION = (0, 1, 0)
|
VERSION = (0, 1, 2)
|
||||||
|
LIBRARY_VERSION = (1, 28, 0)
|
||||||
|
LIBRARY_INSTRUX_SIZE = 856
|
||||||
|
|
||||||
packages = ['pybddisasm']
|
packages = ['pybddisasm']
|
||||||
requires = [ "setuptools"]
|
requires = ['setuptools']
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
def _check_library_version():
|
||||||
|
version_header = '../inc/version.h'
|
||||||
|
with open(version_header, 'r') as file:
|
||||||
|
data = file.read()
|
||||||
|
|
||||||
|
major = re.search(r'(?<=\bDISASM_VERSION_MAJOR).*(\d+)', data)
|
||||||
|
if not major:
|
||||||
|
print('error: Major version not found!')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
minor = re.search(r'(?<=\bDISASM_VERSION_MINOR).*(\d+)', data)
|
||||||
|
if not minor:
|
||||||
|
print('error: Minor version not found!')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
revision = re.search(r'(?<=\bDISASM_VERSION_REVISION).*(\d+)', data)
|
||||||
|
if not revision:
|
||||||
|
print('error: Revision version not found!')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
major = major.group(0).strip()
|
||||||
|
minor = minor.group(0).strip()
|
||||||
|
revision = revision.group(0).strip()
|
||||||
|
|
||||||
|
if int(major) != LIBRARY_VERSION[0] or int(minor) != LIBRARY_VERSION[1] or int(revision) != LIBRARY_VERSION[2]:
|
||||||
|
print('error: The version of the library is not compatible with the pybddisasm!')
|
||||||
|
print('error: Library : %s.%s.%s - pybddisasm : %d.%d.%d' % (major, minor, revision, LIBRARY_VERSION[0],
|
||||||
|
LIBRARY_VERSION[1], LIBRARY_VERSION[2]))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
_check_library_version()
|
||||||
|
|
||||||
with open('README.md', 'r', 'utf-8') as f:
|
with open('README.md', 'r', 'utf-8') as f:
|
||||||
readme = f.read()
|
readme = f.read()
|
||||||
|
|
||||||
class BinaryDistribution(Distribution):
|
class BinaryDistribution(Distribution):
|
||||||
"""Distribution which always forces a binary package with platform name"""
|
def has_ext_modules(arg):
|
||||||
def has_ext_modules(foo):
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def is_pure(self):
|
def is_pure(self):
|
||||||
@ -56,7 +89,7 @@ setup(
|
|||||||
],
|
],
|
||||||
ext_modules = [Extension("_pybddisasm",
|
ext_modules = [Extension("_pybddisasm",
|
||||||
sources = ["_pybddisasm/_pybddisasm.c", "_pybddisasm/pybddisasm.c"],
|
sources = ["_pybddisasm/_pybddisasm.c", "_pybddisasm/pybddisasm.c"],
|
||||||
define_macros = [('AMD64', None), ('Py_LIMITED_API', None)],
|
define_macros = [('AMD64', None), ('Py_LIMITED_API', None), ('LIBRARY_INSTRUX_SIZE', LIBRARY_INSTRUX_SIZE)],
|
||||||
include_dirs = ['../inc'],
|
include_dirs = ['../inc'],
|
||||||
libraries = ['bddisasm'],
|
libraries = ['bddisasm'],
|
||||||
library_dirs = ['/usr/local/lib', '../bin/x64/Release'],
|
library_dirs = ['/usr/local/lib', '../bin/x64/Release'],
|
||||||
|
Loading…
Reference in New Issue
Block a user