/* Chrysalide - Outil d'analyse de fichiers binaires * constants.c - ajout des constantes de base pour les architectures * * Copyright (C) 2018 Cyrille Bagard * * This file is part of Chrysalide. * * Chrysalide 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. * * Chrysalide 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "constants.h" #include #include #include "../helpers.h" /****************************************************************************** * * * Paramètres : type = type dont le dictionnaire est à compléter. * * * * Description : Définit les constantes relatives aux instructions. * * * * Retour : true en cas de succès de l'opération, false sinon. * * * * Remarques : - * * * ******************************************************************************/ bool define_arch_instruction_constants(PyTypeObject *type) { bool result; /* Bilan à retourner */ PyObject *values; /* Groupe de valeurs à établir */ values = PyDict_New(); result = add_const_to_group(values, "NONE", AIF_NONE); if (result) result = add_const_to_group(values, "ROUTINE_START", AIF_ROUTINE_START); if (result) result = add_const_to_group(values, "RETURN_POINT", AIF_RETURN_POINT); if (result) result = add_const_to_group(values, "CALL", AIF_CALL); if (result) result = add_const_to_group(values, "LOW_USER", AIF_LOW_USER); if (result) result = add_const_to_group(values, "HIGH_USER", AIF_HIGH_USER); if (!result) { Py_DECREF(values); goto exit; } result = attach_constants_group_to_type(type, true, "ArchInstrFlag", values, "Flags for some instruction properties."); values = PyDict_New(); result = add_const_to_group(values, "FETCH", IPH_FETCH); if (result) result = add_const_to_group(values, "LINK", IPH_LINK); if (result) result = add_const_to_group(values, "POST", IPH_POST); if (result) result = add_const_to_group(values, "COUNT", IPH_COUNT); if (!result) { Py_DECREF(values); goto exit; } result = attach_constants_group_to_type(type, false, "InstrProcessHook", values, "Kind of hook for instruction processing after disassembling."); values = PyDict_New(); result = add_const_to_group(values, "EXEC_FLOW", ILT_EXEC_FLOW); if (result) result = add_const_to_group(values, "JUMP", ILT_JUMP); if (result) result = add_const_to_group(values, "CASE_JUMP", ILT_CASE_JUMP); if (result) result = add_const_to_group(values, "JUMP_IF_TRUE", ILT_JUMP_IF_TRUE); if (result) result = add_const_to_group(values, "JUMP_IF_FALSE", ILT_JUMP_IF_FALSE); if (result) result = add_const_to_group(values, "LOOP", ILT_LOOP); if (result) result = add_const_to_group(values, "CALL", ILT_CALL); if (result) result = add_const_to_group(values, "CATCH_EXCEPTION", ILT_CATCH_EXCEPTION); if (result) result = add_const_to_group(values, "REF", ILT_REF); if (result) result = add_const_to_group(values, "COUNT", ILT_COUNT); if (!result) { Py_DECREF(values); goto exit; } result = attach_constants_group_to_type(type, false, "InstructionLinkType", values, "Kind of link between two instructions."); exit: return result; } /****************************************************************************** * * * Paramètres : type = type dont le dictionnaire est à compléter. * * * * Description : Définit les constantes relatives aux emplacements. * * * * Retour : true en cas de succès de l'opération, false sinon. * * * * Remarques : - * * * ******************************************************************************/ bool define_arch_vmpa_constants(PyTypeObject *type) { bool result; /* Bilan à retourner */ PyObject *values; /* Groupe de valeurs à établir */ values = PyDict_New(); result = add_const_to_group(values, "NO_PHYSICAL", VMPA_NO_PHYSICAL); if (result) result = add_const_to_group(values, "NO_VIRTUAL", VMPA_NO_VIRTUAL); if (!result) { Py_DECREF(values); goto exit; } result = attach_constants_group_to_type(type, false, "VmpaSpecialValue", values, "Special values for memory locations."); exit: return result; } /****************************************************************************** * * * Paramètres : type = type dont le dictionnaire est à compléter. * * * * Description : Définit les constantes relatives aux instructions brutes. * * * * Retour : true en cas de succès de l'opération, false sinon. * * * * Remarques : - * * * ******************************************************************************/ bool define_raw_instruction_constants(PyTypeObject *type) { bool result; /* Bilan à retourner */ PyObject *values; /* Groupe de valeurs à établir */ values = PyDict_New(); result = add_const_to_group(values, "PADDING", RIF_PADDING); if (result) result = add_const_to_group(values, "STRING", RIF_STRING); if (!result) { Py_DECREF(values); goto exit; } result = attach_constants_group_to_type(type, true, "RawInstrFlag", values, "Flags for some instruction properties.\n" "\n" "They can be seen as an extension of" \ " pychrysalide.arch.ArchInstruction.ArchInstrFlag"); exit: return result; }