/* Chrysalide - Outil d'analyse de fichiers binaires * jdwp_def.h - transcription du protocole Java Debug Wire Protocol * * Copyright (C) 2010-2012 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 Foobar. If not, see . */ #ifndef _DEBUG_JDWP_JDWP_DEF_H #define _DEBUG_JDWP_JDWP_DEF_H #include #include /** * Les définitions ci-dessous sont issues des pages Web suivantes : * - http://download.oracle.com/javase/1.4.2/docs/guide/jpda/jdwp-spec.html * - http://download.oracle.com/javase/1.4.2/docs/guide/jpda/jdwp/jdwp-protocol.html */ /* ---------------------------------------------------------------------------------- */ /* EN-TETES DE PAQUETS JDWP */ /* ---------------------------------------------------------------------------------- */ /* En-tête générique */ typedef struct __attribute__((__packed__)) _jdwp_header { uint32_t length; /* Taille totale du paquet */ uint32_t id; /* Numéro de séquence */ uint8_t flags; /* Options diverses */ union { /* Requête */ struct { uint8_t set; /* Jeu de commandes */ uint8_t command; /* Identifiant de commande */ }; /* Réponse */ uint16_t error; /* Numéro d'erreur */ }; } jdwp_header; #define JDWP_FLAGS_NONE 0x00 #define JDWP_FLAGS_REPLY 0x80 /* ---------------------------------------------------------------------------------- */ /* CONSTANTES UTILISEES DANS JDWP */ /* ---------------------------------------------------------------------------------- */ /* Constantes TypeTag */ typedef uint8_t jdwp_type_tag; #define JDWP_TYPE_TAG_CLASS 1 /* Le type est une classe */ #define JDWP_TYPE_TAG_INTERFACE 2 /* Le type est une interface */ #define JDWP_TYPE_TAG_ARRAY 3 /* Le type est un tableau */ /* ---------------------------------------------------------------------------------- */ /* TYPES DE BASE DIVERS POUR JDWP */ /* ---------------------------------------------------------------------------------- */ /* Identifiant de taille dynamique */ typedef uint64_t jdwp_dynsized_id; /* "location" */ typedef struct _jdwp_location { jdwp_type_tag tag; /* Classe ou interface ? */ jdwp_dynsized_id class_id; /* Identifiant correspondant */ jdwp_dynsized_id method_id; /* Méthode concernée */ uint64_t index; /* Position dans le code */ } jdwp_location; /* "string" */ typedef struct _jdwp_string { uint32_t length; /* Taille de la chaîne */ char *value; /* Chaîne encodée en UTF-8 */ } jdwp_string; /** * Jeux de commandes. */ #define JDWP_CST_NONE 0 /* Organisation interne */ #define JDWP_CST_VIRTUAL_MACHINE 1 #define JDWP_CST_THREAD_REFERENCE 11 /** * Sous-commandes d'un jeu. */ /* Organisation interne */ #define JDWP_CMD_NONE 0 /* VirtualMachine Command Set */ #define JDWP_CMD_VM_VERSION 1 #define JDWP_CMD_VM_ALL_THREADS 4 #define JDWP_CMD_VM_ID_SIZES 7 /* ThreadReference Command Set */ #define JDWP_CMD_THREAD_NAME 1 #define JDWP_CMD_THREAD_FRAMES 6 /** * Charges utiles des paquets. */ /* JDWP_CMD_VM_VERSION */ typedef struct _jdwp_cmd_vm_version_reply { jdwp_string description; /* Infos sur la VM */ uint32_t jdwp_major; /* Numéro majeur de JDWP */ uint32_t jdwp_minor; /* Numéro mineur de JDWP */ jdwp_string vm_version; /* Version JRE de la VM ciblée */ jdwp_string vm_name; /* Nom de la VM */ } jdwp_cmd_vm_version_reply; /* JDWP_CMD_VM_ALL_THREADS */ typedef struct _jdwp_cmd_vm_allthreads_reply { uint32_t count; /* Taille de la liste */ jdwp_dynsized_id *threads; /* Identifiant des threads */ } jdwp_cmd_vm_allthreads_reply; /* JDWP_CMD_VM_ID_SIZES */ typedef struct _jdwp_cmd_vm_id_sizes_reply { uint32_t field_id_size; /* taille pour un 'fieldID' */ uint32_t method_id_size; /* taille pour un 'methodID' */ uint32_t object_id_size; /* taille pour un 'objectID' */ uint32_t reference_type_id_size; /* taille pour un '...TypeID' */ uint32_t frame_id_size; /* taille pour un 'frameID' */ } jdwp_cmd_vm_id_sizes_reply; /* JDWP_CMD_THREAD_NAME */ typedef struct _jdwp_cmd_thread_name_request { jdwp_dynsized_id id; /* Identifiant du thread visé */ } jdwp_cmd_thread_name_request; typedef struct _jdwp_cmd_thread_name_reply { jdwp_string name; /* Désignation humaine */ } jdwp_cmd_thread_name_reply; /* JDWP_CMD_THREAD_FRAMES */ typedef struct _jdwp_cmd_thread_frames_request { jdwp_dynsized_id id; /* Identifiant du thread visé */ uint32_t start; /* Première frame à traiter */ uint32_t length; /* Longueur de la liste ou -1 */ } jdwp_cmd_thread_frames_request; #define ALL_FRAMES 0xffffffff typedef struct _jdwp_thread_frame { jdwp_dynsized_id frame_id; /* Identifiant de la frame */ jdwp_location location; /* Localisation de la frame */ } jdwp_thread_frame; typedef struct _jdwp_cmd_thread_frames_reply { uint32_t count; /* Taille de la liste */ jdwp_thread_frame *frames; /* Liste de frames */ } jdwp_cmd_thread_frames_reply; #endif /* _DEBUG_JDWP_JDWP_DEF_H */