aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile8
-rw-r--r--README.txt6
-rw-r--r--configfile.c28
-rw-r--r--correlation.c2
-rw-r--r--datatypes.h1
-rw-r--r--dhex.134
-rw-r--r--dhex_markers.52
-rw-r--r--dhex_searchlog.52
-rw-r--r--dhexrc.510
-rw-r--r--main.c70
-rw-r--r--markers.c10
-rw-r--r--markers.h2
-rw-r--r--mkrelease.sh12
-rw-r--r--output.c58
-rw-r--r--search.c4
-rw-r--r--todo.txt3
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<NUMCOLORNAMES;i++)
{
+ //printf(" colorNames[i].name=%s,token[2]=%s\n",colorNames[i].name,token[2]);
if (strncmp(token[2],colorNames[i].name,colorNames[i].len)==0) {col1=colorNames[i].val;attrs1=colorNames[i].attrs;}
if (strncmp(token[4],colorNames[i].name,colorNames[i].len)==0) {col2=colorNames[i].val;attrs2=colorNames[i].attrs;}
}
@@ -144,12 +154,12 @@ int getcolors(tOutput* output,char* line)
bg=col2;
attrsret|=(attrs2==A_BOLD)?A_BLINK:attrs2;
}
- for (i=0;i<5;i++)
+ for (i=0;i<NUMATTRNAMES;i++)
{
if (strncmp(attrNames[i].name,token[5],attrNames[i].len)==0) attrsret|=attrNames[i].attrs;
}
- for (i=0;i<13;i++)
+ for (i=0;i<NUMCOLORGROUPS;i++)
{
if (strncmp(colorGroups[i].configname,token[0],colorGroups[i].len)==0)
{
diff --git a/correlation.c b/correlation.c
index 2c0e68e..ef49608 100644
--- a/correlation.c
+++ b/correlation.c
@@ -179,7 +179,7 @@ void find_mindiff(tOutput* output,tCorrelation* correlation,tBuffer* buf1,tBuffe
tBuffer* smallbuf;
tBuffer* bigbuf;
tInt64 match;
- tBool found;
+ tBool found=0;
diff --git a/datatypes.h b/datatypes.h
index ced6166..2f18d6e 100644
--- a/datatypes.h
+++ b/datatypes.h
@@ -58,6 +58,7 @@ typedef struct _tBuffer
tBool nibble;
tUInt8 nexthex;
tUInt64 changepos;
+ tInt64 baseaddr;
} tBuffer;
diff --git a/dhex.1 b/dhex.1
index 01f3129..5154f44 100644
--- a/dhex.1
+++ b/dhex.1
@@ -2,7 +2,7 @@
.\" groff -man -Tascii dhex.1
.\"
.
-.Dd February 12, 2011
+.Dd May 12, 2012
.Os
.Dt DHEX 1
.
@@ -20,6 +20,9 @@
.Op Fl g
.Op Fl k
.Bk -words
+.Op Fl ab ad ah ao Ar base address
+.Ek
+.Bk -words
.Op Fl f Ar config-file
.Ek
.Bk -words
@@ -47,6 +50,12 @@
.Op Fl g
.Op Fl k
.Bk -words
+.Op Fl a1b a1d a1h a1o Ar base address 1
+.Ek
+.Bk -words
+.Op Fl a2b a2d a2h a2o Ar base address 2
+.Ek
+.Bk -words
.Op Fl cb
.Ek
.Bk -words
@@ -98,6 +107,27 @@ is called with two instead of one file as parameters.
.Sh OPTIONS
All the options are case-insensitive and can be given as either upper- or lowercase characters.
.Bl -tag -width 10n
+.It Fl ab ad ah ao Ar base address
+After loading a file, every address gets a base address other than 0. With this, it is easier to work on partial memory dumps. The base address can be given as a binary one with
+.Op Fl ab
+, as a decimal one with
+.Op Fl ad
+, as a hexadecimal one with
+.Op Fl ah
+or an octal with
+.Op Fl ao .
+.It Fl a1b a1d a1h a1o Ar base address 1
+.It Fl a2b a2d a2h a2o Ar base address 2
+For the diff mode, it is possible to set two different base addresses. Again, a binary address can be given as
+.Op Fl a1b a2b
+, as decimal one with
+.Op Fl a1d a2d
+, as hexadecimal one with
+.Op Fl a1h a2h
+or an octal one with
+.Op Fl a1o a2o .
+.Pp
+This base address is calculated into the marker files as well as the searchlogs.
.It Fl cb cl
Diff mode only: The input files can be correlated from the command line with the best
.Fl cb
@@ -199,6 +229,8 @@ How many bytes are are being shown in a line depends on the width of the termina
.Pp
If no other
.Op Fl o
+or
+.Op Fl a
parameter was given at start time, the cursor is being set to offset 0. It is also being shown in the hex column. Here, it can be moved with the cursor keys. When entering a hexadecimal number, the file is being edited. The file can be edited in the ascii column as well, simply by pressing the TAB key (or whichever key was substituted for it in the keyboard setup). Pressing TAB again will return the cursor to the hex column. Pressing F9 (or its substitute) will undo the last of the changes. Changes are being shown in a differnt color.
.Pp
Editing is not possible in the diff mode. Here, pressing the cursor keys will move both files synchronously.
diff --git a/dhex_markers.5 b/dhex_markers.5
index 64815e3..205171f 100644
--- a/dhex_markers.5
+++ b/dhex_markers.5
@@ -1,7 +1,7 @@
.\" Process this file with
.\" groff -man -Tascii dhex.1
.\"
-.Dd January 28, 2011
+.Dd May 12, 2012
.Os
.Dt DHEX_MARKERS 5
.Sh NAME
diff --git a/dhex_searchlog.5 b/dhex_searchlog.5
index 81e23cc..468cd7d 100644
--- a/dhex_searchlog.5
+++ b/dhex_searchlog.5
@@ -1,7 +1,7 @@
.\" Process this file with
.\" groff -man -Tascii dhex.1
.\"
-.Dd January 28, 2011
+.Dd May 12, 2012
.Os
.Dt DHEX_SEARCHLOG 5
.Sh NAME
diff --git a/dhexrc.5 b/dhexrc.5
index 69e5344..5a3fe31 100644
--- a/dhexrc.5
+++ b/dhexrc.5
@@ -1,7 +1,7 @@
.\" Process this file with
.\" groff -man -Tascii dhex.1
.\"
-.Dd January 28, 2011
+.Dd May 12, 2012
.Os
.Dt DHEXRC 5
.
@@ -52,6 +52,8 @@ A typical .dhexrc file looks like this:
.br
.Ql HEADLINE: FG=BLUE,BG=BLACK,BOLD
.br
+.Ql HEADER: FG=BLACK,BG=CYAN
+.br
.br
.Ql KEYF1:1b 5b 31 31 7e
.br
@@ -104,7 +106,7 @@ In the example above, the dhexrc file has three distinct sections: A comment sec
.Ss Comments
Comments are indicated with a '#' character. Everything afterwards in a line is being ignored when parsing the file
.Ss Color section
-There are 13 color groups. Each of the color group has a foreground color, a background color and some extra flags, coming from ncurses. The foreground color is being defined by
+There are 14 color groups. Each of the color group has a foreground color, a background color and some extra flags, coming from ncurses. The foreground color is being defined by
.Nm FG=
while the background color is being defined by
.Nm BG=.
@@ -163,6 +165,8 @@ Differences in the file's content (either because of changes or because dhex is
If the cursor is on one of those differences, it will have this color.
.It HEADLINE:
On top of the screen, there is a headline. Which is shown in this color.
+.It HEADER:
+In the headline, there are brackets. Within those brackets is the header. It tells you what the window is all about.
.El
.Ss Key conversion tab section
When pressing a "standard" key, something which can be mapped directly to an ascii character, only this character will end up in ncurses' buffer. However, pressing special keys like (for example)
@@ -195,7 +199,7 @@ will produce longer sequences. Mapping those sequences back to a specific key is
and
.Nm KEYEND .
.Pp
-Sequences itself are a string of lower case hex-values, each two nibbles long. Currently, there is no way of adding an alternativ sequence to the same key.
+Sequences itself are a string of lower case hex-values, each two nibbles long. Currently, there is no way of adding an alternative sequence to the same key.
.Pp
It is possible that the sequence made up of hex values does not REALLY belong to the key. (For example if F2 was pressed in the setup program when F1 was prompted).
However, when this sequence ends up in the ncurses buffer, it is being interpreted as if that key was pressed.
diff --git a/main.c b/main.c
index 99ab651..cb2964e 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,6 @@
#define MAJORVERSION 0
#define MINORVERSION 6
-#define REVISION 5
+#define REVISION 7
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
@@ -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 && i<argc)
+ {
+ int escape=0;
+ k=0;
+ for (j=start;j<strlen(argv[i]);j++)
+ {
+ if (!escape && argv[i][j]==quotechar) found=1;
+
+ if (!found && k<19 && (argv[i][j]!='\\' || escape))
+ {
+ search->searchstring[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;i<NUMMARKERS;i++)
@@ -189,7 +189,7 @@ tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos)
}
if (selected==itemnums[13+i])
{
- if (markers->relative[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