summaryrefslogtreecommitdiffstats
path: root/src/hidden.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-10-07 20:56:20 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2008-10-07 20:56:20 +0200
commit7f62071c624a4441e046d9ffdd0ca60332a1b392 (patch)
treec8bf75eca3a421693d046e1d2f4ccbb4f2980681 /src/hidden.c
parente86b823143e83f20043835ae32c2179843622f54 (diff)
Display a warning if HPA or DCO is present
Diffstat (limited to 'src/hidden.c')
-rw-r--r--src/hidden.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/hidden.c b/src/hidden.c
new file mode 100644
index 0000000..275162e
--- /dev/null
+++ b/src/hidden.c
@@ -0,0 +1,115 @@
+/*
+
+ File: hidden.c
+
+ Copyright (C) 2008 Christophe GRENIER <grenier@cgsecurity.org>
+
+ This software 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 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 the Free Software Foundation, Inc., 51
+ Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include "types.h"
+#include "common.h"
+#include "intrf.h"
+#ifdef HAVE_NCURSES
+#include "intrfn.h"
+#else
+#include <stdio.h>
+#endif
+#include "log.h"
+#include "hidden.h"
+
+#define INTER_DISK_X 0
+#define INTER_DISK_Y 18
+
+#ifdef HAVE_NCURSES
+static int interface_check_hidden_ncurses(disk_t *disk)
+{
+ static const struct MenuItem menuHidden[]=
+ {
+ { 'C', "Continue", "Continue even if there are hidden data"},
+ { 0,NULL,NULL}
+ };
+ unsigned int menu=0;
+ int car;
+ int line=8;
+ aff_copy(stdscr);
+ wmove(stdscr,4,0);
+ wprintw(stdscr,"%s\n",disk->description_short(disk));
+ wmove(stdscr,6,0);
+ wprintw(stdscr,"Hidden sectors are present.");
+ if(disk->sector_size!=0)
+ {
+ wmove(stdscr,line++,0);
+ wprintw(stdscr, "size %llu sectors\n", (long long unsigned)(disk->disk_real_size/disk->sector_size));
+ }
+ if(disk->user_max!=0)
+ {
+ wmove(stdscr,line++,0);
+ wprintw(stdscr, "user_max %llu sectors\n", (long long unsigned)disk->user_max);
+ }
+ if(disk->native_max!=0)
+ {
+ wmove(stdscr,line++,0);
+ wprintw(stdscr, "native_max %llu sectors\n", (long long unsigned)(disk->native_max+1));
+ }
+ if(disk->dco!=0)
+ {
+ wmove(stdscr,line++,0);
+ wprintw(stdscr, "dco %llu sectors\n", (long long unsigned)(disk->dco+1));
+ }
+ if(disk->user_max < disk->native_max+1)
+ {
+ wmove(stdscr,line++,0);
+ wprintw(stdscr, "Host Protected Area (HPA) present.\n");
+ }
+ if(disk->native_max < disk->dco)
+ {
+ wmove(stdscr,line++,0);
+ wprintw(stdscr, "Device Configuration Overlay (DCO) present.\n");
+ }
+ car= wmenuSelect_ext(stdscr, 23, INTER_DISK_Y, INTER_DISK_X, menuHidden, 10,
+ "CQ", MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
+ if(car=='c' || car=='C')
+ return 0;
+ return 1;
+}
+#endif
+
+int interface_check_hidden(disk_t *disk, char **current_cmd)
+{
+ if(disk->user_max>0 && (disk->user_max < disk->native_max+1 || disk->native_max < disk->dco))
+ {
+ if(disk->user_max < disk->native_max+1)
+ log_warning("%s: Host Protected Area (HPA) present.\n", disk->device);
+ if(disk->native_max < disk->dco)
+ log_warning("%s: Device Configuration Overlay (DCO) present.\n", disk->device);
+ log_flush();
+ if(*current_cmd!=NULL)
+ return 0;
+#ifdef HAVE_NCURSES
+ return interface_check_hidden_ncurses(disk);
+#else
+ return 0;
+#endif
+ }
+ return 0;
+}