diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-02-17 17:51:06 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-02-17 17:51:06 (GMT) |
commit | 73605bffb935fc51a52be1936426211e31dd898a (patch) | |
tree | 094d72321011baae0d5054e06906e9d006249c3b /src/debug/jdwp/packet.c | |
parent | 98a3c749a15349b874dcef0ce3a43ebff651d95a (diff) |
Listed all running threads using Python.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@234 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/debug/jdwp/packet.c')
-rw-r--r-- | src/debug/jdwp/packet.c | 90 |
1 files changed, 82 insertions, 8 deletions
diff --git a/src/debug/jdwp/packet.c b/src/debug/jdwp/packet.c index 8afaeb4..5b496f7 100644 --- a/src/debug/jdwp/packet.c +++ b/src/debug/jdwp/packet.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * packet.c - définition des paquets destiné au protocole JDWP * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -41,6 +41,7 @@ struct _GJdwpPacket jdwp_payload payload; /* Charge utile du paquet */ bin_t pblob[sizeof(jdwp_payload)]; /* Contenu encodé en B.E. */ + bool got; /* Précise le type de charge */ }; @@ -50,6 +51,8 @@ struct _GJdwpPacketClass { GDebugPacketClass parent; /* A laisser en premier */ + jdwp_cmd_vm_id_sizes_reply sizes; /* Réf. des tailles dynamiques */ + }; @@ -111,6 +114,26 @@ static void g_jdwp_packet_init(GJdwpPacket *packet) /****************************************************************************** * * +* Paramètres : packet = instance à utiliser comme intermédiaire. * +* sizes = références pour la valeur des tailles dynamiques. * +* * +* Description : Enregistre les différentes tailles dynamiques. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_jdwp_packet_set_sizes(GJdwpPacket *packet, const jdwp_cmd_vm_id_sizes_reply *sizes) +{ + G_JDWP_PACKET_GET_CLASS(packet)->sizes = *sizes; + +} + + +/****************************************************************************** +* * * Paramètres : packet = instance à convertir. * * iov = table de vecteurs. [OUT] * * iovcnt = quantité de champs renseignés. [OUT] * @@ -220,7 +243,9 @@ bool g_jdwp_packet_parse_header(GJdwpPacket *packet) void g_jdwp_packet_set_request_header(GJdwpPacket *packet, uint8_t set, uint8_t command) { set_jdwp_request_header(&packet->header, packet->hblob, - 0 /* FIXME */, set, command); + 0, set, command); + + packet->got = false; } @@ -242,7 +267,41 @@ void g_jdwp_packet_set_request_header(GJdwpPacket *packet, uint8_t set, uint8_t void g_jdwp_packet_set_reply_header(GJdwpPacket *packet, uint32_t lastid, uint16_t error) { set_jdwp_reply_header(&packet->header, packet->hblob, - 0 /* FIXME */, lastid, error); + 0, lastid, error); + + packet->got = false; + +} + + +/****************************************************************************** +* * +* Paramètres : packet = instance à consulter. * +* payload = modèle de charge à copier. * +* * +* Description : Fournit l'adresse des charges utiles d'un paquet JDWP. * +* * +* Retour : Adresse des données d'une charge utile. * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_jdwp_packet_set_payload(GJdwpPacket *packet, const jdwp_payload *payload) +{ + off_t len; /* Quantité max puis effective */ + + len = sizeof(jdwp_payload); + + set_jdwp_payload(payload, packet->header.set, packet->header.command, + &G_JDWP_PACKET_GET_CLASS(packet)->sizes, + packet->pblob, &len); + + packet->header.length += len; + + update_jdwp_header_length(&packet->header, packet->hblob); + + packet->got = false; } @@ -301,7 +360,20 @@ bin_t *g_jdwp_packet_get_pblob(GJdwpPacket *packet) bool g_jdwp_packet_parse_payload(GJdwpPacket *packet, uint8_t set, uint8_t cmd) { - return get_jdwp_payload(packet->pblob, packet->header.length - sizeof(jdwp_header)/* FIXME */, set, cmd, &packet->payload); + bool result; /* Bilan à retourner */ + + result = get_jdwp_payload(packet->pblob, packet->header.length - sizeof(jdwp_header)/* FIXME */, + set, cmd, &G_JDWP_PACKET_GET_CLASS(packet)->sizes, &packet->payload); + + if (result) + { + packet->header.set = set; + packet->header.command = cmd; + } + + packet->got = true; + + return result; } @@ -309,8 +381,6 @@ bool g_jdwp_packet_parse_payload(GJdwpPacket *packet, uint8_t set, uint8_t cmd) /****************************************************************************** * * * Paramètres : packet = instance à mettre à jour. * -* set = jeu de commandes concerné. * -* cmd = identifiant d'une commande donnée. * * * * Description : Libère la mémoire occupée par une charge utile de paquet. * * * @@ -320,9 +390,13 @@ bool g_jdwp_packet_parse_payload(GJdwpPacket *packet, uint8_t set, uint8_t cmd) * * ******************************************************************************/ -void g_jdwp_packet_free_payload(GJdwpPacket *packet, uint8_t set, uint8_t cmd) +void g_jdwp_packet_free_payload(GJdwpPacket *packet) { - free_jdwp_payload(&packet->payload, set, cmd); + if (packet->header.set == JDWP_CST_NONE || packet->header.command == JDWP_CMD_NONE) + return; + + free_jdwp_payload(&packet->payload, packet->got, + packet->header.set, packet->header.command); } |