diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-12-07 22:17:48 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-12-07 22:17:48 (GMT) |
commit | f36b525987442d46c920f76dced29356663ae85b (patch) | |
tree | a8e231bd4cb209a42155e927fdd17f807a42dc68 /src/debug/jdwp/misc | |
parent | 5a85f3d6ee1d6121c0f7bec0eceb677179f5b3de (diff) |
Removed code.
Diffstat (limited to 'src/debug/jdwp/misc')
-rw-r--r-- | src/debug/jdwp/misc/Makefile.am | 20 | ||||
-rw-r--r-- | src/debug/jdwp/misc/header.c | 196 | ||||
-rw-r--r-- | src/debug/jdwp/misc/header.h | 50 | ||||
-rw-r--r-- | src/debug/jdwp/misc/id.c | 148 | ||||
-rw-r--r-- | src/debug/jdwp/misc/id.h | 131 | ||||
-rw-r--r-- | src/debug/jdwp/misc/location.c | 64 | ||||
-rw-r--r-- | src/debug/jdwp/misc/location.h | 40 | ||||
-rw-r--r-- | src/debug/jdwp/misc/types.c | 85 | ||||
-rw-r--r-- | src/debug/jdwp/misc/types.h | 44 |
9 files changed, 0 insertions, 778 deletions
diff --git a/src/debug/jdwp/misc/Makefile.am b/src/debug/jdwp/misc/Makefile.am deleted file mode 100644 index aec026d..0000000 --- a/src/debug/jdwp/misc/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ - -noinst_LTLIBRARIES = libdebugjdwpmisc.la - -libdebugjdwpmisc_la_SOURCES = \ - header.h header.c \ - id.h id.c \ - location.h location.c \ - types.h types.c - -libdebugjdwpmisc_la_LDFLAGS = - - -devdir = $(includedir)/chrysalide/$(subdir:src/%=%) - -dev_HEADERS = $(libdebugjdwpmisc_la_SOURCES:%c=) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/src/debug/jdwp/misc/header.c b/src/debug/jdwp/misc/header.c deleted file mode 100644 index 82ba187..0000000 --- a/src/debug/jdwp/misc/header.c +++ /dev/null @@ -1,196 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * header.c - constitution des deux types d'en-têtes JDWP - * - * Copyright (C) 2010-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "header.h" - - -#include <string.h> - - -#include "../../../common/endianness.h" - - - -/****************************************************************************** -* * -* Paramètres : header = en-tête logicielle au format local à constituer. * -* blob = en-tête en gros boutiste du paquet à constituer. * -* length = taille totale du paquet. * -* set = jeu de commandes de la requête. * -* command = commande proprement dite. * -* * -* Description : Définit une en-tête de requête au format JDWP. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void set_jdwp_request_header(jdwp_header *header, bin_t *blob, uint32_t length, uint8_t set, uint8_t command) -{ - off_t pos; /* Tête d'écriture */ - - pos = 0; - - length += sizeof(jdwp_header); - - /* Encodage local */ - - header->length = length; - header->id = 1; - header->flags = JDWP_FLAGS_NONE; - - header->set = set; - header->command = command; - - /* Encodage gros boutiste */ - - write_u32(&length, blob, &pos, sizeof(jdwp_header), SRE_BIG); - write_u32((uint32_t []) { 1 }, blob, &pos, sizeof(jdwp_header), SRE_BIG); - write_u8((uint8_t []) { JDWP_FLAGS_NONE }, blob, &pos, sizeof(jdwp_header), SRE_BIG); - - write_u8(&set, blob, &pos, sizeof(jdwp_header), SRE_BIG); - write_u8(&command, blob, &pos, sizeof(jdwp_header), SRE_BIG); - -} - - -/****************************************************************************** -* * -* Paramètres : header = en-tête logicielle au format local à constituer. * -* blob = en-tête en gros boutiste du paquet à constituer. * -* length = taille totale du paquet. * -* lastid = jeton du paquet à l'origine du besoin de réponse. * -* error = éventuelle indication d'erreur. * -* * -* Description : Définit une en-tête de réponse au format JDWP. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void set_jdwp_reply_header(jdwp_header *header, bin_t *blob, uint32_t length, uint32_t lastid, uint16_t error) -{ - off_t pos; /* Tête d'écriture */ - - pos = 0; - - length += sizeof(jdwp_header); - - /* Encodage local */ - - header->length = length; - header->id = 1; - header->flags = JDWP_FLAGS_REPLY; - - header->error = error; - - /* Encodage gros boutiste */ - - write_u32(&length, blob, &pos, sizeof(jdwp_header), SRE_BIG); - write_u32((uint32_t []) { 1 }, blob, &pos, sizeof(jdwp_header), SRE_BIG); - write_u8((uint8_t []) { JDWP_FLAGS_REPLY }, blob, &pos, sizeof(jdwp_header), SRE_BIG); - - write_u16(&error, blob, &pos, sizeof(jdwp_header), SRE_BIG); - -} - - -/****************************************************************************** -* * -* Paramètres : header = en-tête logicielle au format local à constituer. * -* blob = en-tête en gros boutiste du paquet à constituer. * -* * -* Description : Enregistre au format binaire la valeur actuelle de la taille.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void update_jdwp_header_length(const jdwp_header *header, bin_t *blob) -{ - off_t pos; /* Tête d'écriture */ - - pos = 0; - - write_u32(&header->length, blob, &pos, sizeof(jdwp_header), SRE_BIG); - -} - - -/****************************************************************************** -* * -* Paramètres : blob = flux de données à analyser. * -* header = en-tête de paquet JDWP reconstituée. [OUT] * -* * -* Description : Lit une en-tête de paquet au format JDWP. * -* * -* Retour : Bilan de l'opération : true en cas de succès, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool get_jdwp_header(const bin_t *blob, jdwp_header *header) -{ - off_t pos; /* Tête de lecture */ - off_t len; /* Taille standard d'en-tête */ - - pos = 0; - len = sizeof(jdwp_header); - - if (!read_u32(&header->length, blob, &pos, len, SRE_BIG)) - return false; - - if (!read_u32(&header->id, blob, &pos, len, SRE_BIG)) - return false; - - if (!read_u8(&header->flags, blob, &pos, len)) - return false; - - /* Réponse ? */ - if (header->flags & JDWP_FLAGS_REPLY) - { - if (!read_u16(&header->error, blob, &pos, len, SRE_BIG)) - return false; - } - - /* Requête ! */ - else - { - if (!read_u8(&header->set, blob, &pos, len)) - return false; - - if (!read_u8(&header->command, blob, &pos, len)) - return false; - - } - - return true; - -} diff --git a/src/debug/jdwp/misc/header.h b/src/debug/jdwp/misc/header.h deleted file mode 100644 index e1bedad..0000000 --- a/src/debug/jdwp/misc/header.h +++ /dev/null @@ -1,50 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * header.h - prototypes pour la constitution des deux types d'en-têtes JDWP - * - * Copyright (C) 2010-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _DEBUG_JDWP_MISC_HEADER_H -#define _DEBUG_JDWP_MISC_HEADER_H - - -#include <stdbool.h> - - -#include "../jdwp_def.h" -#include "../../../arch/archbase.h" - - - -/* Définit une en-tête de requête au format JDWP. */ -void set_jdwp_request_header(jdwp_header *, bin_t *, uint32_t, uint8_t, uint8_t); - -/* Définit une en-tête de réponse au format JDWP. */ -void set_jdwp_reply_header(jdwp_header *, bin_t *, uint32_t, uint32_t, uint16_t); - -/* Enregistre au format binaire la valeur actuelle de la taille. */ -void update_jdwp_header_length(const jdwp_header *, bin_t *); - -/* Lit une en-tête de paquet au format JDWP. */ -bool get_jdwp_header(const bin_t *, jdwp_header *); - - - -#endif /* _DEBUG_JDWP_MISC_HEADER_H */ diff --git a/src/debug/jdwp/misc/id.c b/src/debug/jdwp/misc/id.c deleted file mode 100644 index ba2724e..0000000 --- a/src/debug/jdwp/misc/id.c +++ /dev/null @@ -1,148 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * id.c - constitution des identifiants de taille dynamique - * - * Copyright (C) 2012-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "id.h" - - -#include "../../../common/endianness.h" - - - -/****************************************************************************** -* * -* Paramètres : id = identifiant à fournir. * -* size = référence pour la taille utilisée. * -* blob = flux de données à analyser. [OUT] * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* * -* Description : Ecrit un identifiant enregistré dans une taille dynamique. * -* * -* Retour : Bilan de l'opération : true en cas de succès, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool _set_jdwp_dynsized_id(const jdwp_dynsized_id *id, uint32_t size, bin_t *blob, off_t *pos, off_t len) -{ - uint8_t id8; /* Valeur sur 1 octets */ - uint16_t id16; /* Valeur sur 2 octets */ - uint32_t id32; /* Valeur sur 4 octets */ - uint64_t id64; /* Valeur sur 8 octets */ - - switch (size) - { - case 1: - id8 = (uint8_t)*id; - if (!write_u8(&id8, blob, pos, len, SRE_BIG)) - return false; - break; - - case 2: - id16 = (uint16_t)*id; - if (!write_u16(&id16, blob, pos, len, SRE_BIG)) - return false; - break; - - case 4: - id32 = (uint32_t)*id; - if (!write_u32(&id32, blob, pos, len, SRE_BIG)) - return false; - break; - - case 8: - id64 = (uint64_t)*id; - if (!write_u64(&id64, blob, pos, len, SRE_BIG)) - return false; - break; - - default: - return false; - break; - - } - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : blob = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* size = référence pour la taille utilisée. * -* id = identifiant à fournir. [OUT] * -* * -* Description : Lit un identifiant enregistré dans une taille dynamique. * -* * -* Retour : Bilan de l'opération : true en cas de succès, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool _get_jdwp_dynsized_id(const bin_t *blob, off_t *pos, off_t len, uint32_t size, jdwp_dynsized_id *id) -{ - uint8_t id8; /* Valeur sur 1 octets */ - uint16_t id16; /* Valeur sur 2 octets */ - uint32_t id32; /* Valeur sur 4 octets */ - uint64_t id64; /* Valeur sur 8 octets */ - - switch (size) - { - case 1: - if (!read_u8(&id8, blob, pos, len)) - return false; - *id = (jdwp_dynsized_id)id8; - break; - - case 2: - if (!read_u16(&id16, blob, pos, len, SRE_BIG)) - return false; - *id = (jdwp_dynsized_id)id16; - break; - - case 4: - if (!read_u32(&id32, blob, pos, len, SRE_BIG)) - return false; - *id = (jdwp_dynsized_id)id32; - break; - - case 8: - if (!read_u64(&id64, blob, pos, len, SRE_BIG)) - return false; - *id = (jdwp_dynsized_id)id64; - break; - - default: - return false; - break; - - } - - return true; - -} diff --git a/src/debug/jdwp/misc/id.h b/src/debug/jdwp/misc/id.h deleted file mode 100644 index 0000886..0000000 --- a/src/debug/jdwp/misc/id.h +++ /dev/null @@ -1,131 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * id.h - prototypes pour la constitution des identifiants de taille dynamique - * - * Copyright (C) 2012-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _DEBUG_JDWP_MISC_ID_H -#define _DEBUG_JDWP_MISC_ID_H - - -#include <stdbool.h> - - -#include "../jdwp_def.h" -#include "../../../arch/archbase.h" - - - -/* Ecrit un identifiant enregistré dans une taille dynamique. */ -bool _set_jdwp_dynsized_id(const jdwp_dynsized_id *, uint32_t, bin_t *, off_t *, off_t); - - -#define set_jdwp_object_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_thread_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_thread_group_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_string_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_class_loader_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_class_object_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_array_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_reference_type_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->object_id_size, blob, pos, len) - -#define set_jdwp_class_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->reference_type_id_size, blob, pos, len) - -#define set_jdwp_interface_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->reference_type_id_size, blob, pos, len) - -#define set_jdwp_array_type_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->reference_type_id_size, blob, pos, len) - -#define set_jdwp_method_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->method_id_size, blob, pos, len) - -#define set_jdwp_field_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->field_id_size, blob, pos, len) - -#define set_jdwp_frame_id(id, sizes, blob, pos, len) \ - _set_jdwp_dynsized_id(id, sizes->frame_id_size, blob, pos, len) - - -/* Lit un identifiant enregistré dans une taille dynamique. */ -bool _get_jdwp_dynsized_id(const bin_t *, off_t *, off_t, uint32_t, jdwp_dynsized_id *); - - -#define get_jdwp_object_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_thread_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_thread_group_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_string_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_class_loader_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_class_object_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_array_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_reference_type_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->object_id_size, id) - -#define get_jdwp_class_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->reference_type_id_size, id) - -#define get_jdwp_interface_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->reference_type_id_size, id) - -#define get_jdwp_array_type_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->reference_type_id_size, id) - -#define get_jdwp_method_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->method_id_size, id) - -#define get_jdwp_field_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->field_id_size, id) - -#define get_jdwp_frame_id(blob, pos, len, sizes, id) \ - _get_jdwp_dynsized_id(blob, pos, len, sizes->frame_id_size, id) - - - -#endif /* _DEBUG_JDWP_MISC_ID_H */ diff --git a/src/debug/jdwp/misc/location.c b/src/debug/jdwp/misc/location.c deleted file mode 100644 index dbf14b1..0000000 --- a/src/debug/jdwp/misc/location.c +++ /dev/null @@ -1,64 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * location.c - constitution des localisations d'instructions courantes - * - * Copyright (C) 2012-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "location.h" - - -#include "id.h" -#include "../../../common/endianness.h" - - - -/****************************************************************************** -* * -* Paramètres : blob = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* sizes = référence pour la taille utilisée. * -* loc = localisation à fournir. [OUT] * -* * -* Description : Lit une localisation d'instruction courante dans l'exécution.* -* * -* Retour : Bilan de l'opération : true en cas de succès, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool get_jdwp_location(const bin_t *blob, off_t *pos, off_t len, const jdwp_cmd_vm_id_sizes_reply *sizes, jdwp_location *loc) -{ - if (!read_u8(&loc->tag, blob, pos, len)) - return false; - - if (!get_jdwp_class_id(blob, pos, len, sizes, &loc->class_id)) - return false; - - if (!get_jdwp_method_id(blob, pos, len, sizes, &loc->method_id)) - return false; - - if (!read_u64(&loc->index, blob, pos, len, SRE_BIG)) - return false; - - return true; - -} diff --git a/src/debug/jdwp/misc/location.h b/src/debug/jdwp/misc/location.h deleted file mode 100644 index 4b9bf1b..0000000 --- a/src/debug/jdwp/misc/location.h +++ /dev/null @@ -1,40 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * location.h - prototypes pour la constitution des localisations d'instructions courantes - * - * Copyright (C) 2012-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _DEBUG_JDWP_MISC_LOCATION_H -#define _DEBUG_JDWP_MISC_LOCATION_H - - -#include <stdbool.h> - - -#include "../jdwp_def.h" -#include "../../../arch/archbase.h" - - -/* Lit une localisation d'instruction courante dans l'exécution. */ -bool get_jdwp_location(const bin_t *, off_t *, off_t, const jdwp_cmd_vm_id_sizes_reply *, jdwp_location *); - - - -#endif /* _DEBUG_JDWP_MISC_LOCATION_H */ diff --git a/src/debug/jdwp/misc/types.c b/src/debug/jdwp/misc/types.c deleted file mode 100644 index b901704..0000000 --- a/src/debug/jdwp/misc/types.c +++ /dev/null @@ -1,85 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * types.c - constitution des types communs de JDWP - * - * Copyright (C) 2010-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "types.h" - - -#include <malloc.h> -#include <string.h> - - -#include "../../../common/endianness.h" - - - -/****************************************************************************** -* * -* Paramètres : blob = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* len = taille totale des données à analyser. * -* str = chaîne de caractères à la sauce JDWP. [OUT] * -* * -* Description : Lit une chaîne de caractères UTF-8 au format JDWP. * -* * -* Retour : Bilan de l'opération : true en cas de succès, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool get_jdwp_string(const bin_t *blob, off_t *pos, off_t len, jdwp_string *str) -{ - if (!read_u32(&str->length, blob, pos, len, SRE_BIG)) - return false; - - if ((*pos + str->length) > len) - return false; - - str->value = (char *)calloc(str->length + 1, sizeof(char)); - memcpy(str->value, &blob[*pos], str->length); - - *pos += str->length; - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : str = chaîne de caractères à la sauce JDWP. * -* * -* Description : Libère de la mémoire une chaîne de caractères UTF-8 JDWP. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void free_jdwp_string(jdwp_string *str) -{ - if (str->value != NULL) - free(str->value); - -} diff --git a/src/debug/jdwp/misc/types.h b/src/debug/jdwp/misc/types.h deleted file mode 100644 index 11f9c60..0000000 --- a/src/debug/jdwp/misc/types.h +++ /dev/null @@ -1,44 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * types.h - prototypes pour la constitution des types communs de JDWP - * - * Copyright (C) 2010-2017 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef _DEBUG_JDWP_MISC_TYPES_H -#define _DEBUG_JDWP_MISC_TYPES_H - - -#include <stdbool.h> - - -#include "../jdwp_def.h" -#include "../../../arch/archbase.h" - - - -/* Lit une chaîne de caractères UTF-8 au format JDWP. */ -bool get_jdwp_string(const bin_t *, off_t *, off_t, jdwp_string *); - -/* Libère de la mémoire une chaîne de caractères UTF-8 JDWP. */ -void free_jdwp_string(jdwp_string *); - - - -#endif /* _DEBUG_JDWP_MISC_TYPES_H */ |