MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / interface_editor_ncurses

Function interface_editor_ncurses

src/edit.c:56–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54static void interface_editor_ncurses(disk_t *disk);
55
56static void interface_editor_ncurses(disk_t *disk)
57{
58 int done = 0;
59 uint64_t hd_offset=0;
60 unsigned char *buffer=(unsigned char *)MALLOC(disk->sector_size);
61 log_info("%s\n",disk->description(disk));
62 aff_copy(stdscr);
63 wmove(stdscr,4,0);
64 wprintw(stdscr,"%s", disk->description_short(disk));
65 while (done==0)
66 {
67 static const struct MenuItem menuEditor[]=
68 {
69 { 'C', "Change location", "" },
70 { 'D', "Dump", "Dump sector" },
71 { 'Q', "Quit",""},
72 { 0, NULL, NULL }
73 };
74 switch ( wmenuSelect(stdscr, INTER_EDIT_Y+1, INTER_EDIT_Y, INTER_EDIT_X, menuEditor, 8, "CDQ", MENU_HORIZ | MENU_BUTTON, 0))
75 {
76 case 'c':
77 case 'C':
78 interface_editor_location(disk,&hd_offset);
79 break;
80 case 'd':
81 case 'D':
82 {
83 int menu_pos=KEY_DOWN;
84 while(done==0)
85 {
86 wmove(stdscr,5,0);
87 wclrtoeol(stdscr);
88 wprintw(stdscr,"%lu ", (unsigned long)(hd_offset/disk->sector_size));
89 aff_LBA2CHS(disk, hd_offset/disk->sector_size);
90 if((unsigned)disk->pread(disk, buffer, disk->sector_size, hd_offset) != disk->sector_size)
91 {
92 wprintw(stdscr,msg_PART_RD_ERR);
93 }
94 {
95 menu_pos=dump_editor(buffer, disk->sector_size, menu_pos);
96 switch(menu_pos)
97 {
98 case KEY_UP:
99 if(hd_offset>0)
100 hd_offset-=disk->sector_size;
101 else
102 menu_pos=KEY_DOWN;
103 break;
104 case KEY_DOWN:
105 if(hd_offset<disk->disk_size)
106 hd_offset+=disk->sector_size;
107 else
108 menu_pos=KEY_UP;
109 break;
110 default:
111 done = 1;
112 break;
113 }

Callers 1

interface_editorFunction · 0.85

Calls 6

MALLOCFunction · 0.85
wmenuSelectFunction · 0.85
aff_LBA2CHSFunction · 0.85
dump_editorFunction · 0.85
aff_copyFunction · 0.70

Tested by

no test coverage detected