From b870e05547bc189f29569a5d21db0c875c8f9983 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Tue, 30 Oct 2012 21:29:30 +0000 Subject: Imported Upstream version 0.67 --- Makefile | 8 +++---- README.txt | 6 ++++- configfile.c | 28 +++++++++++++++-------- correlation.c | 2 +- datatypes.h | 1 + dhex.1 | 34 ++++++++++++++++++++++++++- dhex_markers.5 | 2 +- dhex_searchlog.5 | 2 +- dhexrc.5 | 10 +++++--- main.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++------ markers.c | 10 ++++---- markers.h | 2 +- mkrelease.sh | 12 +++++----- output.c | 58 +++++++++++++++++++++++----------------------- search.c | 4 ++-- todo.txt | 3 +-- 16 files changed, 179 insertions(+), 73 deletions(-) diff --git a/Makefile b/Makefile index d72dde1..7415929 100644 --- a/Makefile +++ b/Makefile @@ -29,10 +29,10 @@ dhex: $(OFILES) install:all strip dhex cp dhex $(DESTDIR)/bin - cp dhex.1 $(DESTDIR)/share/man/man1 - cp dhexrc.5 $(DESTDIR)/share/man/man5 - cp dhex_markers.5 $(DESTDIR)/share/man/man5 - cp dhex_searchlog.5 $(DESTDIR)/share/man/man5 + cp dhex.1 $(DESTDIR)/man/man1 + cp dhexrc.5 $(DESTDIR)/man/man5 + cp dhex_markers.5 $(DESTDIR)/man/man5 + cp dhex_searchlog.5 $(DESTDIR)/man/man5 diff --git a/README.txt b/README.txt index 4c61f21..ff0f613 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,6 @@ -----------------------------------------------------------------[ 0. Welcome ]- -Thank you for downloading dhex 0.63. It is a hex editor with a diff mode. +Thank you for downloading dhex 0.67. It is a hex editor with a diff mode. Since it is based on ncurses, it runs in any console. It makes heavy use of colors, but it is themeable to run on monochrome-displays as well. @@ -18,6 +18,10 @@ Thomas Dettbarn, 30-Dec-2010 0.63: Man pages were written, searching is possible from the command line. 0.64: Naive correlation, a new default theme 0.65: dhex 0.64 crashed at startup on some systems. +0.66: searching for an ascii string with spaces works, some problems with the + color themes were fixed +0.67: a "base address" functionality was added, which makes it easier to work + with memory dumps. ---------------------------------------------------------[ 1. Getting started ]- diff --git a/configfile.c b/configfile.c index 85beaec..47cd6ac 100644 --- a/configfile.c +++ b/configfile.c @@ -23,7 +23,8 @@ typedef struct _tColorGroup uicolors uicol; } tColorGroup; -const tColorGroup colorGroups[13]={ +#define NUMCOLORGROUPS 14 +const tColorGroup colorGroups[NUMCOLORGROUPS]={ {"BRACKETS:", 9,COLOR_BRACKETS}, {"HEXFIELD:", 9,COLOR_HEXFIELD}, {"INPUT:", 6,COLOR_INPUT}, @@ -36,8 +37,12 @@ const tColorGroup colorGroups[13]={ {"NORMAL_DIFF:", 12,COLOR_DIFF}, {"CURSOR_DIFF:", 12,COLOR_CURSORDIFF}, {"HEADLINE:", 9,COLOR_HEADLINE}, - {"FRAME:", 6,COLOR_FRAME}}; -const tColorName colorNames[20]={ {"BLACK", 5,COLOR_BLACK,0}, + {"HEADER:", 7,COLOR_HEADER}, + {"FRAME:", 6,COLOR_FRAME} + }; +#define NUMCOLORNAMES 20 +const tColorName colorNames[NUMCOLORNAMES]={ + {"BLACK", 5,COLOR_BLACK,0}, {"RED", 3,COLOR_RED,0}, {"GREEN", 5,COLOR_GREEN,0}, {"BLUE", 4,COLOR_BLUE,0}, @@ -57,13 +62,17 @@ const tColorName colorNames[20]={ {"BLACK", 5,COLOR_BLACK,0}, {"LIGHTCYAN", 9,COLOR_CYAN,A_BOLD}, {"LIGHTWHITE", 10,COLOR_WHITE,A_BOLD}, {"LIGHTYELLOW", 11,COLOR_YELLOW,A_BOLD}, - {"LIGHTBROWN", 10,COLOR_YELLOW,A_BOLD}}; + {"LIGHTBROWN", 10,COLOR_YELLOW,A_BOLD} + }; -const tColorName attrNames[5]={ {"UNDERLINE", 9,0,A_UNDERLINE}, +#define NUMATTRNAMES 5 +const tColorName attrNames[NUMATTRNAMES]={ + {"UNDERLINE", 9,0,A_UNDERLINE}, {"REVERSE", 7,0,A_REVERSE}, {"BLINK", 5,0,A_BLINK}, {"DIM", 3,0,A_DIM}, - {"BOLD", 4,0,A_BOLD}}; + {"BOLD", 4,0,A_BOLD} + }; int getcolors(tOutput* output,char* line) { @@ -118,8 +127,9 @@ int getcolors(tOutput* output,char* line) col1=0;col2=0; attrs1=0;attrs2=0; attrsret=0; - for (i=0;i<20;i++) + for (i=0;i #include #include @@ -22,7 +22,7 @@ void welcomescreen(char* argv0) { fprintf(stderr,"*** DHEX %i.%i%i\n",MAJORVERSION,MINORVERSION,REVISION); - fprintf(stderr,"*** (C)opyleft 2011 by Thomas Dettbarn\n"); + fprintf(stderr,"*** (C)opyleft 2012 by Thomas Dettbarn\n"); fprintf(stderr,"*** dettus@dettus.net (include DHEX somewhere in the subject)\n\n"); fprintf(stderr,"\n"); fprintf(stderr,"(start it with %s -gpl to see the license)\n",argv0); @@ -56,6 +56,10 @@ void helpscreen(char* argv0,int exitval) fprintf(stderr," -m, -M [markerfile] read the bookmarks from [markerfile]\n"); fprintf(stderr,"\n"); fprintf(stderr,"%s [Parameters] [Filename]: Edit a single file\n",argv0); + fprintf(stderr," -ab, -AB [x] set the base address to [x] (binary)\n"); + fprintf(stderr," -ad, -AD [x] set the base address to [x] (decimal)\n"); + fprintf(stderr," -ah, -AH [x] set the base address to [x] (hexadecimal)\n"); + fprintf(stderr," -ao, -AO [x] set the base address to [x] (octal)\n"); fprintf(stderr," -ob, -OB [x] set the cursor to [x] (binary)\n"); fprintf(stderr," -od, -OD [x] set the cursor to [x] (decimal)\n"); fprintf(stderr," -oh, -OH [x] set the cursor to [x] (hexadecimal)\n"); @@ -68,6 +72,10 @@ void helpscreen(char* argv0,int exitval) fprintf(stderr,"%s [Parameters] [Filename1] [Filename2]: Diff mode\n",argv0); fprintf(stderr," -cd, -CD [x] correlate with the minimum difference\n"); fprintf(stderr," -cb, -CB, -cl, -CL correlate with the best/longest match\n"); + fprintf(stderr," -a1b, -A1B [x] -a2b, -A2B [y] base addresses to [x] and [y] (binary)\n"); + fprintf(stderr," -a1d, -A1D [x] -a2d, -A2D [y] base addresses to [x] and [y] (decimal)\n"); + fprintf(stderr," -a1h, -A1H [x] -a2h, -A2H [y] base addresses to [x] and [y] (hexadecimal)\n"); + fprintf(stderr," -a1o, -A1O [x] -a2o, -A2O [y] base addresses to [x] and [y] (octal)\n"); fprintf(stderr," -o1b, -O1B [x] -o2b, -O2B [y] set the cursors to [x] and [y] (binary)\n"); fprintf(stderr," -o1d, -O1D [x] -o2d, -O2D [y] set the cursors to [x] and [y] (decimal)\n"); fprintf(stderr," -o1h, -O1H [x] -o2h, -O2H [y] set the cursors to [x] and [y] (hexadecimal)\n"); @@ -122,7 +130,7 @@ int parsecursorpos(tInt64* cursorpos1,tInt64* cursorpos2,char* lastopt,char* arg return RETOK; } -int parsecommandlineoptions(int argc,char** argv,tInt64* cursorpos1,tInt64* cursorpos2,tBool* diffmode,int* filename1,int* filename2,tBool* keyboardsetupreq,char* markerfilename,char* configfile,tSearch* search1,tBool* gosearch1,tSearch* search2,tBool* gosearch2,tCorrelation* correlation,tBool* gocorr) +int parsecommandlineoptions(int argc,char** argv,tInt64* baseaddr1,tInt64* baseaddr2,tInt64* cursorpos1,tInt64* cursorpos2,tBool* diffmode,int* filename1,int* filename2,tBool* keyboardsetupreq,char* markerfilename,char* configfile,tSearch* search1,tBool* gosearch1,tSearch* search2,tBool* gosearch2,tCorrelation* correlation,tBool* gocorr) { int filenamecnt=0; int i; @@ -190,6 +198,10 @@ int parsecommandlineoptions(int argc,char** argv,tInt64* cursorpos1,tInt64* curs { switch (lastopt[0]) { + case 'A': + case 'a': + retval=parsecursorpos(baseaddr1,baseaddr2,lastopt,argv[i]); + break; case 'C': case 'c': correlation->start_mindiff=atoi(argv[i]); @@ -231,8 +243,44 @@ int parsecommandlineoptions(int argc,char** argv,tInt64* cursorpos1,tInt64* curs search->forwardnotbackward=!(lastopt[2]=='b' || lastopt[2]=='B'); if (stringtype==1) { - memcpy(search->searchstring,argv[i],19); - search->searchlen=strlen(argv[i]); + if (argv[i][0]=='"' || argv[i][0]=='\'') + { + char quotechar=argv[i][0]; + int j,k=0; + int start=1; + int found=0; + + while (!found && isearchstring[k++]=argv[i][j]; + search->searchstring[k]=0; + } + if (argv[i][j]=='\\' && !escape) escape=1; + else escape=0; + } + start=0; + if (!found) { + i++; + if (k<19) + { + search->searchstring[k++]=' '; + search->searchstring[k]=0; + } + } + } + search->searchlen=k; + } else { + memcpy(search->searchstring,argv[i],19); + search->searchlen=strlen(argv[i]); + } if (search->searchlen>19) search->searchlen=19; } else if (stringtype==2) { int k=0; @@ -324,8 +372,10 @@ int main(int argc,char** argv) tBuffer* buf1=NULL; tBuffer* buf2=NULL; tOutput* output=NULL; + tInt64 baseaddr1=0; tInt64 cursorpos1; tInt64 firstpos1; + tInt64 baseaddr2=0; tInt64 cursorpos2; tInt64 firstpos2; tInt64 oldcursorpos1; @@ -366,7 +416,7 @@ int main(int argc,char** argv) clearsearch(&search1); clearsearch(&search2); clear_correlation(&correlation); - if (parsecommandlineoptions(argc,argv,&cursorpos1,&cursorpos2,&diffmode,&filename1,&filename2,&keyboardsetupreq,markerfilename,configfile,&search1,&gosearch1,&search2,&gosearch2,&correlation,&gocorr)!=RETOK) + if (parsecommandlineoptions(argc,argv,&baseaddr1,&baseaddr2,&cursorpos1,&cursorpos2,&diffmode,&filename1,&filename2,&keyboardsetupreq,markerfilename,configfile,&search1,&gosearch1,&search2,&gosearch2,&correlation,&gocorr)!=RETOK) { if (output) { @@ -376,6 +426,8 @@ int main(int argc,char** argv) if (markers) free(markers); helpscreen(argv[0],0); } + if (cursorpos1 && baseaddr1 && cursorpos1>=baseaddr1) cursorpos1-=baseaddr1; + if (cursorpos2 && baseaddr2 && cursorpos2>=baseaddr2) cursorpos2-=baseaddr2; if (configfile[0]==0) { homedir=getenv("HOME"); @@ -431,6 +483,8 @@ int main(int argc,char** argv) fprintf(f,"NORMAL_DIFF: FG=YELLOW,BG=BLACK,BOLD\n"); fprintf(f,"CURSOR_DIFF: FG=YELLOW,BG=WHITE,BOLD\n"); fprintf(f,"HEADLINE: FG=BLUE,BG=BLACK\n"); + fprintf(f,"HEADER: FG=BLACK,BG=CYAN\n"); + fprintf(f," \n"); fclose(f); retval=2; @@ -441,10 +495,12 @@ int main(int argc,char** argv) memset(hHexCalc,0,sizeof(thHexCalc)); buf1=malloc(sizeof(tBuffer)); memset(buf1,0,sizeof(tBuffer)); + buf1->baseaddr=baseaddr1; if (diffmode) { buf2=malloc(sizeof(tBuffer)); memset(buf2,0,sizeof(tBuffer)); + buf2->baseaddr=baseaddr2; } if (openbuf(buf1,1,argv[filename1])!=RETOK) @@ -562,7 +618,7 @@ int main(int argc,char** argv) } if (ch==KEYTAB) {windowfield=(windowfield+1)&1;} if ((ch==KEYF1 || (ch==':' && windowfield==0))&& !diffmode) { - if (gotomask(output,markers,&cursorpos1)==RETOK) + if (gotomask(output,markers,&cursorpos1,buf1->baseaddr)==RETOK) { firstpos1=cursorpos1; } diff --git a/markers.c b/markers.c index 6731e24..925f890 100644 --- a/markers.c +++ b/markers.c @@ -95,10 +95,10 @@ int writemarkerfile(tMarkers* markers,char* filename) fclose(f); return RETOK; } -tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos) +tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos,tInt64 baseaddr) { - tUInt64 actcursorpos=*cursorpos; - tUInt64 newcursorpos=*cursorpos; + tUInt64 actcursorpos=*cursorpos+baseaddr; + tUInt64 newcursorpos=*cursorpos+baseaddr; tInt8 itemnums[25]; tInt8 selected; tMenu Menu1; @@ -177,7 +177,7 @@ tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos) newcursorpos=actcursorpos; hexinput(output,offsy+3,offsx+8,&newcursorpos,NULL,17); } - if (selected==itemnums[1]) {*cursorpos=newcursorpos;return RETOK;} + if (selected==itemnums[1]) {*cursorpos=newcursorpos-baseaddr;return RETOK;} //FIXME if (selected==itemnums[2]) return RETNOK; for (i=0;irelative[i]=='=') newcursorpos =markers->cursorpos[i]; + if (markers->relative[i]=='=') newcursorpos =markers->cursorpos[i]-baseaddr; // FIXME if (markers->relative[i]=='-') newcursorpos=actcursorpos-markers->cursorpos[i]; if (markers->relative[i]=='+') newcursorpos=actcursorpos+markers->cursorpos[i]; } diff --git a/markers.h b/markers.h index 908bb5a..210d3cb 100644 --- a/markers.h +++ b/markers.h @@ -6,7 +6,7 @@ void* initmarkers(); int parsemarkerfile(tMarkers* markers,char* filename); -tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos); +tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos,tInt64 baseaddr); #endif diff --git a/mkrelease.sh b/mkrelease.sh index e740d80..d6fc4bc 100644 --- a/mkrelease.sh +++ b/mkrelease.sh @@ -1,4 +1,4 @@ -mkdir dhex_0.65 +mkdir dhex_0.67 for I in `echo " Makefile buffers.c @@ -37,11 +37,11 @@ dhex_markers.5 dhex_searchlog.5 mkrelease.sh" | sort -f` do - cp $I dhex_0.65/ + cp $I dhex_0.67/ done -( cd dhex_0.65/ && make && make clean && cd .. && \ -tar cvfz dhex_0.65.tar.gz dhex_0.65/ ) -cp dhex_0.65.tar.gz dhex_latest.tar.gz -md5 dhex_0.65.tar.gz +( cd dhex_0.67/ && make && ./dhex -v && make clean && cd .. && \ +tar cvfz dhex_0.67.tar.gz dhex_0.67 ) +cp dhex_0.67.tar.gz dhex_latest.tar.gz +md5 dhex_0.67.tar.gz md5 dhex_latest.tar.gz diff --git a/output.c b/output.c index 6e7cda0..e81ef29 100644 --- a/output.c +++ b/output.c @@ -9,20 +9,20 @@ void initcolors(tOutput* output) { - output->colors[COLOR_BRACKETS].fg =COLOR_WHITE; output->colors[COLOR_BRACKETS].bg =COLOR_BLACK; output->colors[COLOR_BRACKETS].attrs =0; + output->colors[COLOR_BRACKETS].fg =COLOR_BLACK; output->colors[COLOR_BRACKETS].bg =COLOR_BLACK; output->colors[COLOR_BRACKETS].attrs =A_BOLD; + output->colors[COLOR_HEXFIELD].fg =COLOR_WHITE; output->colors[COLOR_HEXFIELD].bg =COLOR_BLACK; output->colors[COLOR_HEXFIELD].attrs =0; output->colors[COLOR_INPUT].fg =COLOR_BLACK; output->colors[COLOR_INPUT].bg =COLOR_WHITE; output->colors[COLOR_INPUT].attrs =0; output->colors[COLOR_CURSOR].fg =COLOR_WHITE; output->colors[COLOR_CURSOR].bg =COLOR_BLACK; output->colors[COLOR_CURSOR].attrs =0; - output->colors[COLOR_TEXT].fg =COLOR_WHITE; output->colors[COLOR_TEXT].bg =COLOR_BLACK; output->colors[COLOR_TEXT].attrs =A_BOLD; - output->colors[COLOR_HEXFIELD].fg =COLOR_WHITE; output->colors[COLOR_HEXFIELD].bg =COLOR_BLACK; output->colors[COLOR_HEXFIELD].attrs =0; + output->colors[COLOR_TEXT].fg =COLOR_CYAN; output->colors[COLOR_TEXT].bg =COLOR_BLACK; output->colors[COLOR_TEXT].attrs =A_BOLD; + output->colors[COLOR_MENUNORMAL].fg =COLOR_BLUE; output->colors[COLOR_MENUNORMAL].bg =COLOR_BLACK; output->colors[COLOR_MENUNORMAL].attrs =A_BOLD; + output->colors[COLOR_MENUACTIVE].fg =COLOR_BLUE; output->colors[COLOR_MENUACTIVE].bg =COLOR_BLUE; output->colors[COLOR_MENUACTIVE].attrs =A_BOLD; + output->colors[COLOR_MENUHOTKEY].fg =COLOR_CYAN; output->colors[COLOR_MENUHOTKEY].bg =COLOR_BLACK; output->colors[COLOR_MENUHOTKEY].attrs =0; + output->colors[COLOR_MENUHOTKEYACTIVE].fg=COLOR_CYAN; output->colors[COLOR_MENUHOTKEYACTIVE].bg=COLOR_BLUE; output->colors[COLOR_MENUHOTKEYACTIVE].attrs=0; + output->colors[COLOR_FRAME].fg =COLOR_BLUE; output->colors[COLOR_FRAME].bg =COLOR_BLACK; output->colors[COLOR_FRAME].attrs =0; output->colors[COLOR_DIFF].fg =COLOR_YELLOW; output->colors[COLOR_DIFF].bg =COLOR_BLACK; output->colors[COLOR_DIFF].attrs =A_BOLD; - output->colors[COLOR_HEADLINE].fg =COLOR_BLUE; output->colors[COLOR_HEADLINE].bg =COLOR_BLACK; output->colors[COLOR_HEADLINE].attrs =A_BOLD; + output->colors[COLOR_HEADLINE].fg =COLOR_BLUE; output->colors[COLOR_HEADLINE].bg =COLOR_BLACK; output->colors[COLOR_HEADLINE].attrs =0; // output->colors[COLOR_INFO].fg =COLOR_WHITE; output->colors[COLOR_INFO].bg =COLOR_BLACK; output->colors[COLOR_INFO].attrs =A_BOLD; output->colors[COLOR_HEADER].fg =COLOR_BLACK; output->colors[COLOR_HEADER].bg =COLOR_CYAN; output->colors[COLOR_HEADER].attrs =0; - output->colors[COLOR_MENUHOTKEY].fg =COLOR_YELLOW; output->colors[COLOR_MENUHOTKEY].bg =COLOR_BLACK; output->colors[COLOR_MENUHOTKEY].attrs =A_BOLD; - output->colors[COLOR_MENUNORMAL].fg =COLOR_CYAN; output->colors[COLOR_MENUNORMAL].bg =COLOR_BLACK; output->colors[COLOR_MENUNORMAL].attrs =A_BOLD; - output->colors[COLOR_FRAME].fg =COLOR_BLUE; output->colors[COLOR_FRAME].bg =COLOR_BLACK; output->colors[COLOR_FRAME].attrs =A_BOLD; - output->colors[COLOR_MENUACTIVE].fg =COLOR_BLACK; output->colors[COLOR_MENUACTIVE].bg =COLOR_CYAN; output->colors[COLOR_MENUACTIVE].attrs =0; - output->colors[COLOR_MENUHOTKEYACTIVE].fg=COLOR_YELLOW; output->colors[COLOR_MENUHOTKEYACTIVE].bg=COLOR_CYAN; output->colors[COLOR_MENUHOTKEYACTIVE].attrs=A_BOLD; } void colorpair(tOutput* output,uicolors uicol,short fg,short bg,int attr) { @@ -91,7 +91,7 @@ void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64 - addrwidth=(hBuf1->bufsize>0xffffffffull)?16:8; + addrwidth=((hBuf1->bufsize+hBuf1->baseaddr)>0xffffffffull)?16:8; bytesperline=(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field. setcolor(output,COLOR_HEADLINE); @@ -107,13 +107,13 @@ void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64 { mvwprintw(output->win,0,1,"[ / ]"); setcolor(output,COLOR_TEXT); - mvwprintw(output->win,0,2,"%16llX",cursorpos1); - mvwprintw(output->win,0,19,"%16llX",hBuf1->bufsize); + mvwprintw(output->win,0,2,"%16llX",cursorpos1+hBuf1->baseaddr); + mvwprintw(output->win,0,19,"%16llX",hBuf1->bufsize+hBuf1->baseaddr); } else { mvwprintw(output->win,0,1,"[ / ]"); setcolor(output,COLOR_TEXT); - mvwprintw(output->win,0,2,"%8X",(tUInt32)cursorpos1); - mvwprintw(output->win,0,11,"%8X",(tUInt32)hBuf1->bufsize); + mvwprintw(output->win,0,2,"%8X",(tUInt32)(cursorpos1+hBuf1->baseaddr)); + mvwprintw(output->win,0,11,"%8X",(tUInt32)(hBuf1->bufsize+hBuf1->baseaddr)); } setcolor(output,COLOR_HEADER); mvwprintw(output->win,0,COLS-2-strlen(hBuf1->filename),"%s",hBuf1->filename); @@ -125,8 +125,8 @@ void printbuffersingle(tOutput* output,tBuffer* hBuf1,tInt64 cursorpos1,tUInt64 { tBool colhex; setcolor(output,COLOR_HEXFIELD); - if (addrwidth==8) mvwprintw(output->win,i+1,0, "% 8X ",(tUInt32)firstpos1); - else mvwprintw(output->win,i+1,0,"% 16llX ",firstpos1); + if (addrwidth==8) mvwprintw(output->win,i+1,0, "% 8X ",(tUInt32)(firstpos1+hBuf1->baseaddr)); + else mvwprintw(output->win,i+1,0,"% 16llX ",firstpos1+hBuf1->baseaddr); mvwprintw(output->win,i+1,COLS-bytesperline-5," "); wmove(output->win,i+1,addrwidth+3); @@ -206,7 +206,7 @@ void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursor uicolors oldcolor; - addrwidth=(hBuf1->bufsize>0xffffffffull || hBuf2->bufsize>0xffffffffull)?16:8; + addrwidth=((hBuf1->bufsize+hBuf1->baseaddr)>0xffffffffull || (hBuf2->bufsize+hBuf2->baseaddr)>0xffffffffull)?16:8; bytesperline=(COLS-(addrwidth+3+3))*8/(8*3+8+1); // this many bytes can be printed in one line. every 8 bytes there is an extra space in the hex field. setcolor(output,COLOR_HEADLINE); @@ -230,19 +230,19 @@ void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursor mvwprintw(output->win,0,1,"[ / ]"); mvwprintw(output->win,LINES/2,1,"[ / ]"); setcolor(output,COLOR_TEXT); - mvwprintw(output->win,0,2,"%16llX",cursorpos1); - mvwprintw(output->win,0,19,"%16llX",hBuf1->bufsize); - mvwprintw(output->win,LINES/2,2,"%16llX",cursorpos1); - mvwprintw(output->win,LINES/2,19,"%16llX",hBuf1->bufsize); + mvwprintw(output->win,0,2,"%16llX",cursorpos1+hBuf1->baseaddr); + mvwprintw(output->win,0,19,"%16llX",hBuf1->bufsize+hBuf1->baseaddr); + mvwprintw(output->win,LINES/2,2,"%16llX",cursorpos2+hBuf2->baseaddr); + mvwprintw(output->win,LINES/2,19,"%16llX",hBuf2->bufsize+hBuf2->baseaddr); } else { mvwprintw(output->win,0,1,"[ / ]"); mvwprintw(output->win,LINES/2,1,"[ / ]"); setcolor(output,COLOR_TEXT); - mvwprintw(output->win,0,2,"%8X",(tUInt32)cursorpos1); - mvwprintw(output->win,0,11,"%8X",(tUInt32)hBuf1->bufsize); - mvwprintw(output->win,LINES/2,2,"%8X",(tUInt32)cursorpos2); - mvwprintw(output->win,LINES/2,11,"%8X",(tUInt32)hBuf2->bufsize); + mvwprintw(output->win,0,2,"%8X",(tUInt32)cursorpos1+hBuf1->baseaddr); + mvwprintw(output->win,0,11,"%8X",(tUInt32)hBuf1->bufsize+hBuf1->baseaddr); + mvwprintw(output->win,LINES/2,2,"%8X",(tUInt32)cursorpos2+hBuf2->baseaddr); + mvwprintw(output->win,LINES/2,11,"%8X",(tUInt32)hBuf2->bufsize+hBuf2->baseaddr); } setcolor(output,COLOR_HEADER); mvwprintw(output->win,0,COLS-2-strlen(hBuf1->filename),"%s",hBuf1->filename); @@ -270,8 +270,8 @@ void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursor for (i=0;i<(LINES+1)/2-2;i++) { setcolor(output,COLOR_HEXFIELD); - if (addrwidth==8) mvwprintw(output->win,i+1,0, "% 8X ",(tUInt32)cursorpos1); - else mvwprintw(output->win,i+1,0,"% 16llX ",cursorpos1); + if (addrwidth==8) mvwprintw(output->win,i+1,0, "% 8X ",(tUInt32)(cursorpos1+hBuf1->baseaddr)); + else mvwprintw(output->win,i+1,0,"% 16llX ",cursorpos1+hBuf1->baseaddr); mvwprintw(output->win,i+1,COLS-bytesperline-5," "); oldcolor=COLOR_HEXFIELD; @@ -342,8 +342,8 @@ void printbufferdiff(tOutput* output,tBuffer* hBuf1,tBuffer* hBuf2,tInt64 cursor for (i=0;i<(LINES+1)/2-2;i++) { setcolor(output,COLOR_HEXFIELD); - if (addrwidth==8) mvwprintw(output->win,i+1+LINES/2,0, "% 8X ",(tUInt32)cursorpos2); - else mvwprintw(output->win,i+1+LINES/2,0,"% 16llX ",cursorpos2); + if (addrwidth==8) mvwprintw(output->win,i+1+LINES/2,0, "% 8X ",(tUInt32)(cursorpos2+hBuf2->baseaddr)); + else mvwprintw(output->win,i+1+LINES/2,0,"% 16llX ",cursorpos2+hBuf2->baseaddr); mvwprintw(output->win,i+1+LINES/2,COLS-bytesperline-5," "); oldcolor=COLOR_HEXFIELD; diff --git a/search.c b/search.c index 5a7370e..9adc1e7 100644 --- a/search.c +++ b/search.c @@ -114,7 +114,7 @@ tInt8 searchfor(tSearch* search,tBuffer* buf,tUInt64* cursorpos,tBool nextnotpre } } } - actcursorpos=x; + actcursorpos=x-buf->baseaddr; // FIXME search->lastsearchlogpos=getfilepos(frlog); } increment=1; @@ -126,7 +126,7 @@ tInt8 searchfor(tSearch* search,tBuffer* buf,tUInt64* cursorpos,tBool nextnotpre { search->occurancesfound++; search->lastoccurance=actcursorpos; - if (search->writesearchlog) fprintf(fwlog,"%016llx\n",(tUInt64)actcursorpos); else done=1; + if (search->writesearchlog) fprintf(fwlog,"%016llx\n",(tUInt64)actcursorpos+buf->baseaddr); else done=1; } } if (frlog) fclose(frlog); diff --git a/todo.txt b/todo.txt index 8798b98..e2aef5a 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,5 @@ - error: when searching, the changes are being ignored -- feature: correlation -- feature: snapshot - the length of input fields is restricted by the gui - return value of dhex itself - try compiling it under windows with cl.exe +- write a test suite which checks if searching/correlation etc. works -- cgit v1.2.3