├── CHANGES ├── COPYING ├── CREDITS ├── Makefile ├── Makefile.in ├── README ├── TODO ├── blocks.c ├── bscript.c ├── buffers.c ├── bvim.1 ├── bvim.c ├── bvim.doxygen ├── bvim.man ├── collaboration.c ├── commands.c ├── config.guess ├── config.h ├── config.h.in ├── config.status ├── config.sub ├── configure ├── configure.in ├── edit.c ├── html ├── bmore.html ├── bmore_cmd.html ├── bmore_opt.html ├── bvi.css ├── colon.html ├── cursor.html ├── download.html ├── edit.html ├── german.html ├── gif │ ├── .xvpics │ │ └── bg2.gif │ ├── bg2.gif │ ├── bvi_m.gif │ ├── bvi_s.gif │ ├── dcbacks.gif │ ├── dot.gif │ └── up.gif ├── index.html ├── install.html ├── man_bmore.html ├── man_bvi.html ├── new120.html ├── new130.html ├── new131.html ├── new132.html ├── overview.html ├── qt_bit.html ├── qt_edit.html ├── qt_find.html ├── qt_partial.html ├── qt_search.html ├── qt_set.html ├── qt_yank.html ├── quick.html ├── rpm.html ├── set.html ├── sitemap.html └── yank.html ├── include ├── blocks.h ├── bmath.h ├── bscript.h ├── buffers.h ├── bvim.h ├── collaboration.h ├── commands.h ├── data.h ├── keys.h ├── messages.h ├── patchlevel.h ├── plugins.h ├── search.h ├── set.h ├── signature.h └── ui.h ├── install-sh ├── io.c ├── keys.c ├── lua ├── Makefile ├── bitwise_operators_5.1.4_1.patch ├── jh-lua-binoctal-5.1.4.patch └── lua-5.1.4.tar.gz ├── math.c ├── mkinstalldirs ├── plugins.c ├── plugins ├── Makefile ├── test.c └── visualisation.c ├── re.c ├── recomp.c ├── scripts ├── checksum.lua ├── init.lua ├── search.lua ├── statistics.lua ├── test.lua └── unittest.lua ├── search.c ├── set.c ├── signature.c └── ui.c /CHANGES: -------------------------------------------------------------------------------- 1 | New in release 1.3.2 2 | ==================== 3 | 4 | * configure: checking term.h and ncurses/term.h 5 | * cast in bmore.c in putline(); 6 | * ported to compile under DJGPP v2.0 w/ PDCURSES (by simoN) 7 | * fixed multiple file handling for "bmore" (by simoN) 8 | * renamed several local screen processing routines to avoid compiler conflicts 9 | * several minor fixes to "bmore" code (by simoN) 10 | * reset tty after CTRL-C in bmore 11 | * -c option in bmore (clear before displaying) 12 | * -n num option in bmore (display the indicated number of lines in each 13 | screenful 14 | * -w num option in bmore (display the indicated number of bytes in each 15 | line) 16 | 17 | 18 | New in release 1.3.1 19 | ==================== 20 | 21 | * autoconf 2.52 22 | * do_back() fix 23 | * replace sys_errlist[errno] with strerror(errno) (Debian #106762) 24 | * deleting bytes in empty file fixed (Debian #121934) 25 | * no ":set mm" for x at eof (Debian #122240) 26 | * cast for alloc_buf() in set.c 27 | * r-bug fix in edit.c and bvi.c 28 | * renamed CTRL to BVICTRL (AIX problem) 29 | * bmore: nicer last line 30 | * bmore: bmbeep() instead of beep() 31 | * bmore: subshell support fixes 32 | 33 | 34 | New in release 1.3.0 35 | ==================== 36 | 37 | * a "bmore" program has been added 38 | * --with-ncurses option to configure to specify an alternate 39 | search path for Ncurses outside the normal include/lib search path. 40 | * make uninstall option 41 | * Reading of Block Special Files 42 | * New Command line options: 43 | +cmd 44 | -b begin \ 45 | -e end > for partial file read 46 | -s size / 47 | * :e# bug fixed 48 | * Debian bug #68436 (Buffer overflow in io.c) fixed 49 | 50 | 51 | New in release 1.2.0 52 | ==================== 53 | 54 | * configuration with GNU autoconfig 55 | * CR moves cursor to 1st column 56 | * alphabet. order for :set all 57 | * new settings: 58 | set columns=n 59 | set (no)memmove 60 | * insert and delete (a, d, i, I, x, X) 61 | * vi-syntax for y (yank), overwriting put o 62 | * new colon (ex) commands: 63 | :undo :delete :global 64 | :yank :put :overwrite 65 | :insert :change :append 66 | * new option: 67 | -f script 68 | 69 | 70 | New in release 1.1.1 71 | ===================== 72 | 73 | * .bvirc not read in some cases, fixed 74 | * ":f newname" does not work, fixed 75 | * distribution tar file with no directory, fixed 76 | * freebsd and openbsd added to Makefile 77 | * undo of D command fixed 78 | 79 | 80 | New in release 1.1.0 81 | ===================== 82 | 83 | * A lot of bugfixes 84 | * New option ":set offset=n" for counting the addresses beginning 85 | with n instead of 0 86 | * New bit-wise commands :xor :and :or :not :neg :lshift :rshift 87 | :rrotate :lrotate 88 | * Byte addressing for colon commands, e.g. ":5,100w foo" writes 89 | byte 5 through 100 to file foo 90 | * Backwards hex search character % changed to # 91 | * Filename substitution with %, e.g. ":w %.new" 92 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | Patches: 2 | Guido sys_errlist 3 | Christian "naddy" Weisgerber {Free,Open}BSD 4 | Gunnar Larisch ^ZZ bug 5 | Peter J. Holzer setlocale 6 | Albert Chin-A-Young Makefile.in 7 | Ralf AIX fixes 8 | Claudio Nieder Makefile 9 | Nico Schmidt r-bug fix 10 | Steve Waltner Mac OS X support 11 | Andre Wobst AIX fixes 12 | SimoN bmore: subshell support fixes, DJGPP support 13 | 14 | Packages: 15 | Christian "naddy" Weisgerber Source RPM 16 | Christian Kurz Debian package 17 | Stijn de Bekker Debian package 18 | Troy Engel i386 RPM package 19 | Thomas Steudten RH alpha and x86 RPM package 20 | 21 | Doc: 22 | Sven Guckes 23 | Ben 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # bvim - bvi improved Makefile 2 | # 3 | # This is the Makefile for bvi - binary visual editor. If it has the name 4 | # "Makefile.in" then it is a template for a Makefile; to generate the actual 5 | # Makefile, run "./configure", which is a configuration script generated by the 6 | # "autoconf" program (constructs like "@foo@" will get replaced in the 7 | # actual Makefile. 8 | # 9 | # Copyright (c) 1996-2003 by Gerhard Buergmann 10 | # gerhard@puon.at 11 | # 12 | # 1996-01-18 V 1.0.0 13 | # 1999-01-15 V 1.1.0 14 | # 1999-03-03 V 1.1.1 15 | # 1999-10-22 V 1.2.0 16 | # 2000-05-31 V 1.3.0 beta 17 | # 2000-10-01 V 1.3.0 final 18 | # 2003-07-03 V 1.3.2 19 | # 20 | ############################################### 21 | 22 | srcdir = . 23 | prefix = /usr/local 24 | exec_prefix = ${prefix} 25 | 26 | bindir = $(DESTDIR)${exec_prefix}/bin 27 | mandir = $(DESTDIR)${prefix}/share/man 28 | libdir = $(DESTDIR)${exec_prefix}/lib 29 | 30 | man1dir = $(mandir)/man1 31 | 32 | OBJS = bvim.o blocks.o keys.o commands.o buffers.o set.o re.o io.o edit.o recomp.o bscript.o math.o ui.o plugins.o collaboration.o signature.o search.o 33 | HEADER = data.h bvim.h blocks.h buffers.h set.h bscript.h math.h ui.h keys.h commands.h plugins.h messages.h collaboration.h signature.h search.h 34 | CC = gcc 35 | CFLAGS = -g -O2 -Wall -Iinclude -I./lua/include 36 | DEFS = -DHAVE_CONFIG_H 37 | LDFLAGS= 38 | LIBS = -lm -lncurses -lssl -ldl -L./lua/lib -llua 39 | SHELL = /bin/sh 40 | 41 | 42 | 43 | INSTALL = /usr/bin/install -c 44 | INSTALL_PROGRAM = ${INSTALL} 45 | INSTALL_DATA = ${INSTALL} -m 644 46 | 47 | 48 | all: blua bvim 49 | 50 | blua: 51 | make -C lua lua 52 | 53 | bvim: $(OBJS) 54 | $(CC) $(LDFLAGS) -o bvim $(OBJS) $(LIBS) 55 | 56 | .c.o: 57 | $(CC) $(CFLAGS) $(DEFS) -c $< 58 | 59 | plugins: 60 | make -C plugins plugins 61 | 62 | install: all installdirs 63 | @echo "Installing bvi" 64 | @$(INSTALL_DATA) bvim.1 $(man1dir) 65 | @$(INSTALL_PROGRAM) -s bvim $(bindir) 66 | @if [ -f $(bindir)/bview ]; then rm $(bindir)/bview; fi 67 | @if [ -f $(bindir)/bvedit ]; then rm $(bindir)/bvedit; fi 68 | @ln $(bindir)/bvim $(bindir)/bview 69 | @ln $(bindir)/bvim $(bindir)/bvedit 70 | 71 | installdirs: 72 | $(SHELL) ${srcdir}/mkinstalldirs $(bindir) $(libdir) $(man1dir) 73 | 74 | uninstall: 75 | @echo "Uninstalling bvi" 76 | @if [ -f $(bindir)/bview ]; then rm $(bindir)/bview; fi 77 | @if [ -f $(bindir)/bvedit ]; then rm $(bindir)/bvedit; fi 78 | @if [ -f $(bindir)/bvim ]; then rm $(bindir)/bvim; fi 79 | @if [ -f $(man1dir)/bvim.1 ]; then rm $(man1dir)/bvim.1; fi 80 | 81 | clean: 82 | rm -f core *.o *.c~ *.h~ bvim bvim.exe a.out 83 | 84 | deepclean: 85 | make -C lua clean 86 | make -C plugins clean 87 | rm -f core *.o *.c~ *.h~ .*.swp bvim bvim.exe a.out 88 | 89 | distclean: deepclean 90 | rm -f Makefile config.cache config.h config.log config.status 91 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # bvim - bvi improved Makefile 2 | # 3 | # This is the Makefile for bvi - binary visual editor. If it has the name 4 | # "Makefile.in" then it is a template for a Makefile; to generate the actual 5 | # Makefile, run "./configure", which is a configuration script generated by the 6 | # "autoconf" program (constructs like "@foo@" will get replaced in the 7 | # actual Makefile. 8 | # 9 | # Copyright (c) 1996-2003 by Gerhard Buergmann 10 | # gerhard@puon.at 11 | # 12 | # 1996-01-18 V 1.0.0 13 | # 1999-01-15 V 1.1.0 14 | # 1999-03-03 V 1.1.1 15 | # 1999-10-22 V 1.2.0 16 | # 2000-05-31 V 1.3.0 beta 17 | # 2000-10-01 V 1.3.0 final 18 | # 2003-07-03 V 1.3.2 19 | # 20 | ############################################### 21 | 22 | srcdir = @srcdir@ 23 | prefix = @prefix@ 24 | exec_prefix = @exec_prefix@ 25 | 26 | bindir = $(DESTDIR)@bindir@ 27 | mandir = $(DESTDIR)@mandir@ 28 | libdir = $(DESTDIR)@libdir@ 29 | 30 | man1dir = $(mandir)/man1 31 | 32 | OBJS = bvim.o blocks.o keys.o commands.o buffers.o set.o re.o io.o edit.o recomp.o bscript.o math.o ui.o plugins.o collaboration.o signature.o search.o 33 | HEADER = data.h bvim.h blocks.h buffers.h set.h bscript.h math.h ui.h keys.h commands.h plugins.h messages.h collaboration.h signature.h search.h 34 | CC = @CC@ 35 | CFLAGS = @CFLAGS@ @CPPFLAGS@ -Iinclude -I./lua/include 36 | DEFS = @DEFS@ 37 | LDFLAGS= @LDFLAGS@ 38 | LIBS = @LIBS@ -ldl -lm -L./lib/lua -llua 39 | SHELL = /bin/sh 40 | 41 | 42 | 43 | INSTALL = @INSTALL@ 44 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 45 | INSTALL_DATA = @INSTALL_DATA@ 46 | 47 | 48 | all: blua bvim 49 | 50 | blua: 51 | cd lua 52 | make lua 53 | 54 | bvim: $(OBJS) 55 | $(CC) $(LDFLAGS) -o bvim $(OBJS) $(LIBS) 56 | 57 | .c.o: 58 | $(CC) $(CFLAGS) $(DEFS) -c $< 59 | 60 | plugins: 61 | cd plugins 62 | make plugins 63 | 64 | install: all installdirs 65 | @echo "Installing bvi" 66 | @$(INSTALL_DATA) bvim.1 $(man1dir) 67 | @$(INSTALL_PROGRAM) -s bvim $(bindir) 68 | @if [ -f $(bindir)/bview ]; then rm $(bindir)/bview; fi 69 | @if [ -f $(bindir)/bvedit ]; then rm $(bindir)/bvedit; fi 70 | @ln $(bindir)/bvim $(bindir)/bview 71 | @ln $(bindir)/bvim $(bindir)/bvedit 72 | 73 | installdirs: 74 | $(SHELL) ${srcdir}/mkinstalldirs $(bindir) $(libdir) $(man1dir) 75 | 76 | uninstall: 77 | @echo "Uninstalling bvim" 78 | @if [ -f $(bindir)/bview ]; then rm $(bindir)/bview; fi 79 | @if [ -f $(bindir)/bvedit ]; then rm $(bindir)/bvedit; fi 80 | @if [ -f $(bindir)/bvim ]; then rm $(bindir)/bvim; fi 81 | @if [ -f $(man1dir)/bvim.1 ]; then rm $(man1dir)/bvim.1; fi 82 | 83 | clean: 84 | rm -f core *.o *.c~ *.h~ bvim bvim.exe a.out 85 | 86 | deepclean: 87 | cd lua 88 | make clean 89 | rm -f core *.o *.c~ *.h~ .*.swp bvim bvim.exe a.out 90 | 91 | distclean: clean 92 | rm -f Makefile config.cache config.h config.log config.status 93 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | BVIM - Bvi IMproved 2 | =================== 3 | 4 | http://bvim.github.com/ 5 | 6 | This editor for binary files was written by Gerhard Buergmann 7 | and Anton Kochkov and is distributed under the GPL (GNU Public License). 8 | 9 | It was an improved version of original bvi editor 10 | (http://bvi.sourceforge.net/) 11 | 12 | How to compile 13 | ============== 14 | 15 | gunzip -c bvim-1.3.4.tar.gz | tar xvf - 16 | cd bvim-1.3.4 17 | ./configure 18 | make 19 | make install 20 | 21 | MAC OS X 22 | ======== 23 | Looks like the curses implementation in Darwin is really limited. 24 | You should install and use ncurses instead. You can download it from 25 | ftp.gnu.org; install it and then use 26 | ./configure --with-ncurses=/usr/local/ncurses-5.2 27 | 28 | 29 | HTML documentation in subdirectory html/ 30 | 31 | Subscribe to the bvi mailing for support, updates and other news: 32 | 33 | Send a blank email to bvi-subscribe@yahoogroups.com. You will receive a 34 | subscription confirmation message. Simply reply this message and your 35 | subscription will be complete. 36 | 37 | Used code from 38 | ============== 39 | 40 | universal_crc - CRC C code generator utility 41 | Copyright (C) 2011 Danjel McGougan 42 | 43 | ------------------------------------------------------------------------ 44 | PLEASE send any bug reports (and fixes), code for new features, 45 | comments, questions, etc. to: 46 | 47 | Anton Kochkov 48 | Moscow, Russia 49 | E-mail: anton.kochkov@gmail.com 50 | 51 | 52 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Implement libbvim and Qt gui 2 | 3 | Directions 4 | =========================== 5 | 6 | 1. Add C-syntax structures parsing and searching (high priority) 7 | -- IN PROGRESS 8 | 2. Add hex-data folding support (or lines, or blocks) 9 | 3. Add GZIP, ZIP, TAR, etc signatures to search and highlight (e.g. from binwalk) 10 | add them into sqlite 11 | 4. Add :unmap (:unm) feature 12 | -- IN PROGRESS 13 | 5. Add :split feature (low priority) 14 | 6. Add binary diff mode 15 | 7. Templates support (high priority) 16 | 8. Add support for 8-bit, 16-bit, 32-bit, 64-bit and 128-bit modes 17 | 9. Add support for big-endian and little-endian 18 | 10. Add signature search for executable code and file headers 19 | 12. Add tabs for various buffers 20 | 13. Add tools tabs (e.g. for templates, history, etc) 21 | 14. Implement lua REPL console 22 | -- 90% done 23 | 15. Implement network team work support (like PiratePad, Gobby/infinoted) 24 | 16. Add terminal resizing support 25 | 17. Add MathGL visualisation plugin: gistogram, file map, etc. 26 | 18. Save project (with comments, marks, blocks list, highlights and history) 27 | into some file (can be just zip directory with all files) 28 | 19. Implement VIRTUAL_BLOCK with id == 0, which mean whole file/buffer 29 | 20. Add Unicode and other encodings support 30 | 21. Implement lua REPL as pipe/server, to use with multimonitor configuration 31 | 22. Add fuzzy logic 32 | 33 | Simple tasks 34 | ============================ 35 | 36 | 1. Rename project to "bvim" 37 | -- 90% done 38 | 2. Add history of commands 39 | -- 90% done 40 | 3. Blocks commands: 41 | a) block-save to separate file 42 | b) block-reverse 43 | c) blocks list 44 | d) blocks send to disasm 45 | 4. Add lua events: 46 | a) cursor move back, forward, up and down 47 | b) cursor on some block 48 | 5. Add scrolling in tools window (with keys and from lua) (HIGH PRIORITY!) 49 | 6. Add checks of terminal color mode 50 | 7. Add normal keymapping with keys names 51 | -- 90% done 52 | 8. Implement block parameter as bitfields (folding, highlighting, color, etc) (LOW PRIORITY) 53 | 9. All operations (XOR, AND, etc) must support hexadecimal arguments 54 | -- IN PROGRESS 55 | 10. Prevent blocks overlapping 56 | -- 90% done 57 | 11. Add folding empty and repeating data sequences 58 | 12. Implement "universal" CRC poly/gen calculator, with ability setup generator poly from lua 59 | -- 80% done 60 | 13. Add lua/plugins hooks into standard handler_* and command_* 61 | 14. Add block and symbol annotations - show when place cursor on it 62 | 15. Add possibility to :run 17 | 18 | 19 | 20 | 74 | 75 |
21 | 22 |
23 | 24 |

25 | Quick Tutorial 26 |

27 | 28 |

29 | Download 30 |

31 | 32 |

33 | Installation 34 |

35 | 36 |

37 | Command Overview 38 |

39 | 40 |

41 | bmore 42 |

43 | 44 |

45 | Deutsche
Beschreibung 46 |

47 | 48 |

49 | Sitemap 50 |

51 | 52 |

53 | Project Page 54 |

55 | 56 |
57 | 58 |

59 | VI and Clones 60 |

61 | 62 |

63 | Hex-Editors 64 |

65 | 66 |
67 | 68 |

69 | 70 | SourceForge Logo 71 |

72 | 73 |
76 |
77 |

Welcome to the
78 | bvi
79 | Homepage

80 | Here you can find all the informations about bvi you need. 81 |
82 |
83 | The bvi is a display-oriented editor for binary files, based on the vi texteditor. 84 | If you are familiar with vi, just start the editor and begin 85 | to edit! A bmore programm is also included in the package. 86 |
87 | If you never heard about vi, maybe bvi is not the best 88 | choice for you. 89 | 90 |

91 |

Current: Version 1.3.2

92 | 93 | You can download source and compiled versions from the 94 | download page.
95 | Check out whats new in 1.3.2! 96 | 97 |

98 | Newsgroup: comp.editors 99 | 100 |

101 | Mailing List (very low traffic): 102 |

103 | To join this list, simply send a blank email to 104 | bvi-subscribe@yahoogroups.com. 105 | You will receive a subscription confirmation message. 106 | Simply reply this message and your subscription will be complete. 107 |
108 | 109 | Bvi was developed by Gerhard Bürgmann and is published 110 | under the GNU Public License. Current stable version is 1.3.2. 111 | Bvi is running on most UNIX - like operating systems and 112 | on MSDOS. 113 |

114 | If you want to contact me:
115 | Gerhard Bürgmann, Vienna ( Purkersdorf ) / Austria / Europe
116 | E-mail: gerhard@puon.at
117 | Have a look at Meta Chrom Kennzeichenhalter 118 | 119 |

120 | 121 | 122 | Back to the topBack to the top 124 | 125 |


126 | Last update: January 8th 2004 by Gerhard Bürgmann 127 |

128 |
129 | 130 | 131 | -------------------------------------------------------------------------------- /html/install.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Installation 4 | 5 | 6 | 7 | 8 | 9 | 37 | 38 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 |

19 |

20 | Download
21 |

22 |

23 | Installation
24 |

25 |

26 | Command Overview
27 |

28 |

29 | bmore
30 |

31 |

32 | Deutsche Beschreibung
33 |

34 |
35 | 36 |
39 | 40 | 41 | 44 | 49 |
42 | Installation 43 | 45 | 46 | BVI 48 |
50 |
51 |
52 | 53 |

54 | The following steps are necessary to get bvi running: 55 |

UNIX

56 | The Unix version of bvi needs the curses (ncurses) library 57 | for cursor movement. 58 |
    59 |
  1. Download the source package from the Download Page
  2. 60 |
  3. Unzip the package with the command:
  4. 61 |
     62 |     # gunzip -c bvi-1.3.2.src.tar.gz | tar xvf
     63 | 
    64 |
  5. Change to the directory bvi-1.3.2 and type 65 |
     66 |     # ./configure
     67 |     # make
     68 | 
  6. 69 | 70 |
  7. Type `make install' for copying the executable files 71 | and manual pages to the final directories. 72 |
    73 | By default, `make install' will install the package's files in 74 | `/usr/local/bin', `/usr/local/man', etc. 75 | You can specify an 76 | installation prefix other than `/usr/local' by giving 77 | `configure' the option 78 | `--prefix=PATH'. Use the 79 | `--with-ncurses' option to configure to specify an 80 | alternate search path for Ncurses outside the normal 81 | include/lib search path. 82 |

    83 | You will find now four new commands: 84 |

     85 |     bvi     The binary editor
     86 |     bview   The readonly version of bvi
     87 |     bedit   The beginners version of bvi
     88 |     bmore   The binary more program
     89 | 
  8. 90 |
  9. Use `make uninstall' to remove the installed 91 | files from your file system.
    92 | You can remove the program binaries and object files from the 93 | source code directory by typing `make clean'. 94 | To also remove the files that `configure' created 95 | (so you can compile the package for 96 | a different kind of computer), type `make distclean'.
  10. 97 |
98 | 99 |

MSDOS

100 | Beginning with version 1.3.2 you may use the DJGPP environment to 101 | compile bvi for working under both Win32 and DOS. 102 |

103 | The MSDOS version (Borland C) exists for historical reasons and is not 104 | supported anymore: 105 |

106 |

107 | You have to convert the sourcefiles from the UNIX textformat to 108 | the MSDOS textformat first. This can be done e.g. by loading and 109 | saving them with the MSDOS standard editor `edit'. 110 |

111 | The MSDOS version is using the conio routines of the 112 | Borland - C compilers for cursor movement. The doscur.h 113 | header file substitutes the curses commands.
114 | Bvi is using the "HUGE" memory model, bmore 115 | needs the "TINY" model to 116 | be able to convert it to a .COM file. 117 | 118 |

    119 |
  1. Download the source package from the Download Page
  2. 120 |
  3. Unzip the package with the command: 121 |
    122 |     gunzip -c bvi-1.3.2.src.tar.gz | tar xvf
    123 | 
  4. 124 |
  5. Load the tcconfig file (located in the bc subdirectory 125 | for Borland - C).
  6. 126 | 127 |
  7. Press F9-Make
  8. 128 |
129 |
130 |

131 | 132 | Back to the topBack to the top 134 | 135 |


136 | Last update: February 12th 2004 by Gerhard Bürgmann, 137 | Purkersdorf/Austria 138 |
139 | 140 | -------------------------------------------------------------------------------- /html/new120.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: CHANGES in bvi 1.2.0 4 | 5 | 6 | 7 | 8 | 9 | 41 | 42 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 |

19 |

20 | Download
21 | New in 1.3.2
22 | New in 1.3.1
23 | New in 1.3.0
24 | New in 1.2.0
25 |

26 |

27 | Installation
28 |

29 |

30 | Command Overview
31 |

32 |

33 | bmore
34 |

35 |

36 | Deutsche Beschreibung
37 |

38 |
39 | 40 |
43 | 44 | 45 | 48 | 53 |
46 | CHANGES in bvi 1.2.0 47 | 49 | 50 | BVI 52 |
54 |
55 |
56 | 57 |

58 |

    59 |
  • Configuration with GNU autoconfig 60 |
  • New :set options: 61 |
      62 |
    • :set columns=n
      63 | You can set the number of columns on the screen to an 64 | arbitrary value. This might be useful if you edit a file 65 | with a fixed record length.
      66 | Default: max number of columns, divisible by four.
      67 | Abbreviation: :set cm=n 68 |
    • :set memmove 69 | enables the new commands to insert or delete bytes.
      70 | Per default this commands are disabled, because e.g. in 71 | executable files you must not move bytes.
      72 | Default: :set nomemmove
      73 | Abbreviation: :set mm - :set nomm 74 |
    • The listing for :set all is now in 75 | alphabetical order. 76 |
    77 |
  • New insert and delete commands: 78 |
      79 |
    • a inserts after cursor position 80 |
    • i inserts on cursor position 81 |
    • x deletes byte under cursor 82 |
    • X deletes byte before cursor 83 |
    • d delete command with modifiers: 84 |
        85 |
      • dSPACE deletes byte under cursor 86 |
      • dfC deletes from current position to 87 | next character C 88 |
      • d/xyz deletes from current position 89 | to first matching pattern xyz 90 |
      • d$ deletes from current position to EOF 91 |
      • d'a deletes from current positions 92 | to mark a 93 |
      • dnG deletes from current position to 94 | byte with (decimal) address n 95 |
      96 |
    97 |
  • New syntax for p (put) command:
    98 | In previous versions of bvi the p command did an overwriting 99 | "put". Now the bytes are inserted. 100 |
  • New command o (overwrite):
    101 | This is an overwriting "put" command. It is the only command in bvi 102 | that uses a command key in a complete different way than in vi 103 | (o opens a new line in vi). 104 |
  • New syntax for y (yank) command: 105 |
      106 |
    • ySPACE yanks byte under cursor 107 |
    • yfC yanks from current position to next 108 | character C 109 |
    • y/xyz yanks from current position to 110 | first matching pattern xyz 111 |
    • y$ yanks from current position to EOF 112 |
    • y'a yanks from current position to 113 | mark a 114 |
    • ynG yanks from current position to 115 | byte with (decimal) address n 116 |
    117 |
  • New ex (colon) commands: 118 |
      119 |
    • :a(ppend) a(scii)|b(binary)|d(ecimal)|h(exadecimal)|o(ctal) 120 |
    • :c(hange) a(scii)|b(binary)|d(ecimal)|h(exadecimal)|o(ctal) 121 |
    • :i(nsert) a(scii)|b(binary)|d(ecimal)|h(exadecimal)|o(ctal)
      122 | The three commands above are used to append or change or insert bytes 123 | in the selected representation until you type a line containing only 124 | a dot, e.g. insert bytes in binary mode: 125 |
      126 | 	:i b
      127 | 	0 010 110 1110010 10 100
      128 | 	1 1001 1001 0 0
      129 | 	.
      130 | 	
      131 | Pressing the RETURN key does not insert 132 | a newline - character into the file. If you use :i a (insert 133 | ascii) you can use the special characters \n, \r, \t and \0. 134 |
    • :d(elete) 135 |
    • :g(lobal) does a global search with printing found items 136 |
    • :ma(rk) 137 |
    • :pu(t) puts yanked bytes into the file 138 |
    • :o(verwrite) is an overwriting ":put" 139 |
    • :y(ank) 140 |
    141 |
  • :f newname - bug fixed 142 |
  • new command line option -f script 143 |
  • CTRL - C aborts some commands, e.g. search commands 144 |
  • CR moves cursor to 1st column of next screen line 145 |
  • Local settings according to the environment variable LANG 146 | will be evaluated (see setlocal(3)). 147 |
148 |

149 | 150 | Back to the topBack to the top 152 | 153 |


154 | Last update: June, 1st 2000 by Gerhard Bürgmann, 155 | Purkersdorf/Austria 156 |
157 | 158 | -------------------------------------------------------------------------------- /html/new130.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: CHANGES in bvi 1.3.0 4 | 5 | 6 | 7 | 8 | 9 | 41 | 42 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 |

19 |

20 | Download
21 | New in 1.3.2
22 | New in 1.3.1
23 | New in 1.3.0
24 | New in 1.2.0
25 |

26 |

27 | Installation
28 |

29 |

30 | Command Overview
31 |

32 |

33 | bmore
34 |

35 |

36 | Deutsche Beschreibung
37 |

38 |
39 | 40 |
43 | 44 | 45 | 48 | 53 |
46 | CHANGES in bvi 1.3.0 47 | 49 | 50 | BVI 52 |
54 |
55 |
56 | 57 |

58 |

    59 |
  • In the configure script you can use --with-ncurses 60 | option to configure to specify an alternate 61 | search path for Ncurses outside the normal include/lib search path. 62 |

    63 |

  • A make uninstall option has been added 64 |

    65 |

  • A bmore program has been added. It acts like the BSD - text - more, 66 | but for binary files.

    67 | Additional command line options: 68 |

    69 | -a   ASCII mode 70 |
    71 | Additional (changed) Commands: 72 |
    73 | v   does not invoke vi but bvi
    74 | w   invokes bvi with only that portion of the file 75 | which is displayed on the screen. 76 |
    77 |
  • New in bvi: 78 |
      79 |
    • You can edit now Block Special Files too. 80 |
    • You can read - edit - write files partly. 81 |
    • New Command line options: 82 |
      83 | +cmd
      84 | -b begin \
      85 | -e end    > for partial file read
      86 | -s size  /

      87 |

      88 | begin, end or size can be an integer value (decimal or 89 | hexadecimal) or an integer value with an appended k (for 90 | multiply by 1024) or m (for multiply by 1.048.576). 91 |
    • :e# bug fixed 92 |
    • Debian bug #68436 (Buffer overflow in io.c) fixed 93 |
    94 |
95 |

96 | 97 | Back to the topBack to the top 99 | 100 |


101 | Last update: October 12th 2000 by Gerhard Bürgmann, 102 | Purkersdorf/Austria 103 |
104 | 105 | -------------------------------------------------------------------------------- /html/new131.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: CHANGES in bvi 1.3.1 4 | 5 | 6 | 7 | 8 | 9 | 41 | 42 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 |

19 |

20 | Download
21 | New in 1.3.2
22 | New in 1.3.1
23 | New in 1.3.0
24 | New in 1.2.0
25 |

26 |

27 | Installation
28 |

29 |

30 | Command Overview
31 |

32 |

33 | bmore
34 |

35 |

36 | Deutsche Beschreibung
37 |

38 |
39 | 40 |
43 | 44 | 45 | 48 | 53 |
46 | CHANGES in bvi 1.3.1 47 | 49 | 50 | BVI 52 |
54 |
55 |
56 | 57 |

58 | This is a bugfix release. 59 |

60 | BVI: 61 |

    62 |
  • autoconf 2.52 used 63 |

    64 |

  • do_back() fixed (cast)
  • 65 |

    66 |

  • replace sys_errlist[errno] with strerror(errno) (Debian #106762)
  • 67 |

    68 |

  • fix: one can continue deleting bytes even when file is empty (Debian #121934)
  • 69 |

    70 |

  • wish: no ":set mm" to delete bytes from end of file (Debian #122240)
  • 71 |

    72 |

  • cast for alloc_buf() in set.c
  • 73 |

    74 |

  • r-bug fix in edit.c and bvi.c
  • 75 |

    76 |

  • renamed CTRL to BVICTRL (AIX problem)
  • 77 |

    78 |

79 | 80 | BMORE: 81 |
    82 |
  • nicer last line
  • 83 |

    84 |

  • bmbeep() instead of beep() (SOLARIS problem)
  • 85 |

    86 |

  • subshell support fixes
  • 87 |
88 | 89 |

90 | 91 | Back to the topBack to the top 93 | 94 |


95 | Last update: February 12th 2002 by Gerhard Bürgmann, 96 | Purkersdorf/Austria 97 |
98 | 99 | -------------------------------------------------------------------------------- /html/new132.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: CHANGES in bvi 1.3.2 4 | 5 | 6 | 7 | 8 | 9 | 41 | 42 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 |

19 |

20 | Download
21 | New in 1.3.2
22 | New in 1.3.1
23 | New in 1.3.0
24 | New in 1.2.0
25 |

26 |

27 | Installation
28 |

29 |

30 | Command Overview
31 |

32 |

33 | bmore
34 |

35 |

36 | Deutsche Beschreibung
37 |

38 |
39 | 40 |
43 | 44 | 45 | 48 | 53 |
46 | CHANGES in bvi 1.3.2 47 | 49 | 50 | BVI 52 |
54 |
55 |
56 | 57 |

58 | This is a bugfix release. 59 |

60 | BVI: 61 |

    62 |
  • ported to compile under DJGPP v2.0 w/ PDCURSES (by simoN)
  • 63 |

    64 |

  • some minor fixes
  • 65 |

    66 |

67 |


68 | BMORE: 69 |
    70 |
  • configure: checking term.h and ncurses/term.h
  • 71 |

    72 |

  • cast in bmore.c in putline();
  • 73 |

    74 |

  • fixed multiple file handling for "bmore" (by simoN)
  • 75 |

    76 |

  • renamed several local screen processing routines to avoid compiler conflicts
  • 77 |

    78 |

  • several minor fixes to "bmore" code (by simoN)
  • 79 |

    80 |

  • reset tty after CTRL-C in bmore
  • 81 |
82 |


83 | 84 |

85 | 86 | Back to the topBack to the top 88 | 89 |


90 | Last update: January 8th 2004 by Gerhard Bürgmann, 91 | Purkersdorf/Austria 92 |
93 | 94 | -------------------------------------------------------------------------------- /html/overview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Command Overview 4 | 5 | 6 | 7 | 8 | 9 | 43 | 44 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 |

19 |

20 | Download
21 |

22 |

23 | Installation
24 |

25 |

26 | Command Overview
27 | Cursor Movement
28 | Edit Cmds
29 | Yank and Put Cmds
30 | Set Options
31 | Colon (ex) Cmds
32 | man - Page
33 |

34 |

35 | bmore
36 |

37 |

38 | Deutsche Beschreibung
39 |

40 |
41 | 42 |
45 | 46 | 47 | 50 | 55 |
48 | Command Overview 49 | 51 | 52 | BVI 54 |
56 |
57 |
58 | 59 |

60 | This overview compares bvi commands with the corresponding commands of 61 | the standard ascii vi. 62 |

63 |

64 | 65 | 68 | 70 | 71 |
Commands shown in blue frames are commands which 66 | are available in both bvi and vi, but with a slightly different 67 | behavior.
Green frames are used for commands which are 69 | equal in both bvi and vi.
Red frames are used for missing commands
72 |
73 |

74 | Special keys are displayed in a gray font, e.g. 75 | RETURN, 76 | ARROW_UP or 77 | CTRL. 78 | 79 |

Topics:

80 |

81 |

88 |

89 | 90 | Back to the topBack to the top 92 | 93 |


94 | Last update: June 1st 2000 by Gerhard Bürgmann, 95 | Purkersdorf/Austria 96 |
97 | 98 | -------------------------------------------------------------------------------- /html/qt_bit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Bit-wise Operations 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 52 | 57 |
49 | Quick Tutorial 50 |
Bit-wise Operations 51 |
53 | 54 | BVI 56 |
58 |
59 |
60 | 61 |

62 | To perform logical operations, bvi has a set of bit-level commands. 63 | The following commands are available: 64 |

65 | 67 | 68 | 69 | 70 | 72 | 73 | 74 | 75 | 76 |
:rl nrotate left 66 | n is a number from 1 through 7
:rr nrotate right
:sr nshift right
:sl nshift left
:and iand operation 71 | i is a number from 0 through 255
:or ior operation
:xor ior operation
:not negates operation
:neg negates operation
77 |

78 | The i value can be entered as a decimal number (0 - 255), 79 | a hexadecimal number with a leading zero (0 - 0ff) or a binary number, 80 | either with a leading B (B101) or exactly eight digits long (00000101). 81 |

82 | On default the whole file is affected, but you can use the usual 83 | colon command address forms. In contrast to vi the addresses designate 84 | not line numbers but byte numbers. These addresses can be enterd in 85 | decimal or hexadecimal notation.
86 | Examples: 87 |

88 | :100,500and 01A RETURN
89 | :03FA,01000or 00001000 RETURN
90 | :.rr 3 RETURN
91 | :'a,$sl 1 RETURN
92 |
93 |

94 | 95 | Back to the topBack to the top 97 | 98 |


99 | Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann, 100 | Purkersdorf/Austria 101 |
102 | 103 | -------------------------------------------------------------------------------- /html/qt_edit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Editing Files 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 52 | 57 |
49 | Quick tutorial 50 |
Editing Files 51 |
53 | 54 | BVI 56 |
58 |
59 |
60 | 61 |

62 | Inserting or deleting bytes can be dangerous on some kind of files, 63 | because binary files are mostly executables, database files or maybe 64 | graphic files. So you must not shift the remaining bytes to another 65 | address. 66 | Therefor commands for inserting or deleting bytes are disabled by 67 | default. 68 | You can use the r command to change a single byte, or 69 | the R command to replace multiple characters. You can use a 70 | numeric prefix for both commands. 71 |

72 | You can add characters at the end of the file using the A command. 73 | If you start with an empty file, you can create a binary file from 74 | scratch. If the cursor is in the ASCII section of the screen and you 75 | type 100AxESC, you create a file 76 | which contents 100 x'es. 77 |

78 | The D command can be used to truncate a file at a certain position. 79 | Since there are no lines in a binary file, the D command deletes 80 | to end of file. 81 |

82 | If you have to edit a binary file where it does not matter to move bytes 83 | to a different address, you can enable the insert and delete commands by 84 | typing :set memmove. 85 | Now you are able to use the i command for inserting bytes, the 86 | x or X command to delete the byte over or before the cursor 87 | and those types of d commands, which does not rely on text lines 88 | (e.g. dSPACE, dfC, d/xyz, 89 | d$, d'a, dnG). 90 | 91 |

92 | All edits can be undone by pressing the u key. 93 |

Using ex (colon) commands

94 | The edit commands of the ex editor are usually not available in 95 | standard vi implementations (:i[nsert], :a[ppend] 96 | and :c[hange]). In bvi 97 | they are available with extended options. There are five 98 | modifiers a[scii], b[inary], d[ecimal], h[exadecimal] and 99 | o[ctal] (ascii is default). Therefor you can insert, append 100 | or change data in all five representations. 101 |

102 | Example:
103 | you would like to append a file with data available in decimal 104 | representation: 105 |

106 | :a d
107 | 0 12 3 128 255 17 0 0 255 255
108 | 23 24 25 128 6 6 6
109 | .
110 | 
111 | A line with only a period (.) in it will terminate the command. 112 |
113 | You must not type values greater than a byte value (255 decimal, FF hex). 114 | This causes an abandon of the command.
115 | Pressing the RETURN key does not insert 116 | a newline - character into the file. If you use :i a (insert 117 | ascii) you can use the special characters \n, \r, \t and \0. 118 |

119 | An additional advantage is, that all typed bytes are inserted into the 120 | file at once. If you insert characters in vi - mode, for every byte typed, 121 | the whole remaining file has to be moved one position backwards. 122 |

123 | 124 | Back to the topBack to the top 126 | 127 |


128 | Last update: June 1st 2000 by Gerhard Bürgmann, 129 | Purkersdorf/Austria 130 |
131 | 132 | -------------------------------------------------------------------------------- /html/qt_find.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Find and Replace 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 52 | 57 |
49 | Quick Tutorial 50 |
Find and Replace 51 |
53 | 54 | BVI 56 |
58 |
59 |
60 | 61 |

62 | The :s (substitute) command behaves a little bit 63 | different to that of vi. If you type a command like this in vi   64 | :s/XXXX/UU/ then the four XXXX's are 65 | replaced by 66 | two UU's. This means, the file size decreases and all characters after 67 | the replacement are moved to another position in the file. Since bvi 68 | does not move characters, only two XX's are replaced by two UU's and 69 | the third and fourth X still remains in the file.
70 | Another example: 71 |

72 | :0,500s/Taste\0/Key\0/RETURN
73 |
74 |

75 | This command replaces within the first 500 bytes of a file the 0 - 76 | terminated ASCII string "Taste" 77 | with the 0 - terminated 78 | string "Key". After the substitution 79 | you will find a 80 | character sequence "Key\0e\0" in the file.
81 | CAUTION: If the replace 82 | string is longer than the find string, additional bytes are overwritten! 83 |
84 | This behaviour will not be changed by setting the 85 | :set memmove option! 86 |

87 | Of course you can do also binary substitutions, similar to the search 88 | command. The ability of remembering patterns like \(pattern\) 89 | is currently not implemented. 90 |

91 | 92 | Back to the topBack to the top 94 | 95 |


96 | Last update: Fri Jun 30 22:33:20 CEST 2000 by Gerhard Bürgmann, 97 | Purkersdorf/Austria 98 |
99 | 100 | -------------------------------------------------------------------------------- /html/qt_partial.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Partial File Read 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 52 | 57 |
49 | Quick Tutorial 50 |
Partial File Read 51 |
53 | 54 | BVI 56 |
58 |
59 |
60 | 61 |

62 | A new feature of version 1.3.0 is the Partial File Read. 63 | If you want to edit a file, you have not to read the file into 64 | memory but only the part you want to edit. You can write back this part 65 | into the file after editing. 66 |
67 | Example: 68 |
69 | You have to change only some bytes of the header of a graphic file 70 | (e.g. a color). Graphic files can be very large. With the -s 71 | option you can load only the first kilobyte of the file: 72 |

 73 |              bvi -s 1000 large.gif
 74 | 
75 | In this case of course you cannot insert or delete bytes of the file. 76 | The editor is set to the no memmove mode. You can write back 77 | only as much bytes as you read before. If you add or delete bytes 78 | even though, the extra bytes will be ignored or garbage will be 79 | written to the file. 80 |

81 | It is also possible to start not at the begin of the file, but at a 82 | certain address. To do this you have to use the option -b. 83 | You can read the file from this starting point until the end of the file 84 | or you can use the -s option to specify a size or the 85 | -e option to specify an end address. 86 |

87 | If you read the file not from the start an offset will be set to 88 | display the correct address at the left side of the screen. If you change this 89 | offset with the :set offset=nnnn command, this has 90 | no effect to the write back operation. The edited part of the 91 | file will always be written back at the same position, where it was read. 92 |

93 | In the Linux /proc directory there are files which are listed 94 | with length 0 in a directory listing. But in reality they have a content. 95 | You can read this files, if you use the -s option and guess a 96 | size. This size should be a little bit larger than the size you expect. 97 |

98 | The same guidlines can be used, if you load a block device, e.g. a 99 | floppy disk. 100 |

101 |              bvi -s 1450k /dev/fd0
102 | 
103 | After reading the device, you get a message with the value of the 104 | real read bytes at the bottom of the screen: 105 |
106 |              "/dev/fd0" range 0-1474559
107 | 
108 | Note that the size value will be used to allocate memory before 109 | reading the file. Therefore do not choose a too large size.
110 | Note further, that 1450k in the example above is calculated as 111 | 1450 * 1024 bytes. This gives 1484800 bytes allocated size. 112 | If bvi reads the exact number of bytes you have asked for 113 | in the -s option, the file may be larger. 114 |

115 | WARNING: 116 |

117 | Do not use bvi at mounted disk devices!
118 | Do not edit disk devices, if you don't know exactly what you change!
119 | You may make your disk unreadable by editing it!! 120 |
121 |

Interaction with bmore

122 | You may use bmore to browse through large files or 123 | devices. You may use the ASCII - or Hex - search possibilities to 124 | locate a certain section of the file.
125 | If you see the desired part of the file on your screen, press w to 126 | read the contents of the file displayed currently on your screen into 127 | bvi. You can use a decimal prefix at the w - 128 | command to read more or less bytes than displayed into bvi. 129 |
130 | The letter w is the next letter after v, which 131 | is used in more and bmore to read the whole file into vi or bvi! 132 |

133 | If you used the ZZ or :w command, this part of the file will be 134 | written back into the original file. 135 | 136 |

137 | 138 | Back to the topBack to the top 140 | 141 |


142 | Last update: Sun Jul 09 21:57:38 CEST 2000 by Gerhard Bürgmann, 143 | Purkersdorf/Austria 144 |
145 | 146 | -------------------------------------------------------------------------------- /html/qt_search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Search Commands 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 52 | 57 |
49 | Quick Tutorial 50 |
Search Commands 51 |
53 | 54 | BVI 56 |
58 |
59 |
60 | 61 |

62 | Additional to the well known / and ? for searching ASCII 63 | strings there are two new commands for searching binary strings. These 64 | are the keys \ and #. 65 |

66 | In the ASCII search commands / and ? you can use \n, \r, 67 | \t and \0. You can also use regular expressions. Do not use 68 | ^ and $, because there are no lines in a binary file. 69 | Type /foo\0RETURN to 70 | search for the null terminated string foo in the file. 71 |

72 | In the Hex section you can search for a sequence of bytes in hexadecimal 73 | notation, e.g. \01 AF 12RETURN, 74 | which is the same as \01AF12 75 | RETURN. 76 | You can also use regular expressions and quoted ASCII strings. Inside of 77 | the quotes no character is treated as a special character!
78 | Example:   79 | \01 [^AF DE] "foo" 00 RETURN 80 |
81 | This means: Search for a string beginning with 01, the second character 82 | must not be a hex AF or DE, followed by the ASCII 83 | characters foo, terminated with a binary zero. 84 | 85 |

Global Search

86 | There is also a global search option available, but only with the 87 | print option.
88 | Example: 89 |
90 | :g/text_pattern/pRETURN 91 |
or
92 | :g\hex_pattern\pRETURN 93 |
94 | This commands are displaying all found patterns, one per screen line. 95 | Of course you can limit the search to a certain part of the file by 96 | specifying the starting and ending address.
97 | Other forms of the global search command 98 | are line oriented, therefor not useful for binary files and 99 | not implemented, e.g.
100 |
101 | 102 | 103 | 104 | 105 |
:g/pattern/dDelete all lines containing pattern
:g/pattern/yYank all lines containing pattern
:g!/pattern/pPrint all lines not containing pattern
106 |
107 |

108 | 109 | Back to the topBack to the top 111 | 112 |


113 | Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann, 114 | Purkersdorf/Austria 115 |
116 | 117 | -------------------------------------------------------------------------------- /html/qt_set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Settings 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 52 | 57 |
49 | Quick Tutorial 50 |
Settings 51 |
53 | 54 | BVI 56 |
58 |
59 |
60 | 61 |

62 | To customize bvi some additional :set options are 63 | available. You can add them to your .bvirc 64 | file, if you need them all the time. 65 | 66 |

columns

67 |
68 | You can set the number of columns on the screen to an arbitrary value. 69 | This might be useful if you edit a file with a fixed record length.
70 | Default value is the max. number of columns, divisible by four.
71 | Example: :set columns=13RETURN
72 | Abbreviation: :set cm=9RETURN 73 |
74 | 75 |

memmove

76 |
77 | This option enables the commands for inserting and deleting bytes. 78 |
79 | Default: :set nomemmoveRETURN
80 | Abbreviation: :set mmRETURN 81 |
82 | 83 |

offset

84 |
85 | You can change the beginning of the displayed byte numbering to a 86 | certain number. The default address of the first byte is 0. You can 87 | change it to 1 or to any other number by typing:
88 |   :set offset=1RETURN
89 | You can also use a hexadecimal address, if you type a leading zero:
90 |   :set of=01FFRETURN
91 | The only commands which are not affected by these numbering is 92 | :f or CTRL 93 | -G. These commands always 94 | designates the first byte in file as 1. 95 |
96 | 97 |

unixstyle

98 |
99 | The rightmost character in the status line displays the ASCII value of 100 | the current byte. For values below 32 you can use the notation used on 101 | the ascii(7) man page (like NUL, SOH, STX etc.) if you do a
102 | :set unixstyleRETURN or a
103 | :set usRETURN. If you do a
104 | :set nousRETURN you get a 105 | DOS style representation (^A, ^B, ^C etc.). 106 |
107 | 108 |

wordlength

109 |
110 | This setting is used to define the minimum length of a "word". 111 | A "word" is a sequence of ASCII characters within a binary 112 | file. The commands w, b, e, W, B and E are affected by 113 | this setting. 114 |

115 | Default: :set wordlength=4RETURN
116 | Abbreviation: :set wl=4RETURN 117 |

118 |

119 | 120 | Back to the topBack to the top 122 | 123 |


124 | Last update: Thu Jun 01 12:00:00 CEST 2000 by Gerhard Bürgmann, 125 | Purkersdorf/Austria 126 |
127 | 128 | -------------------------------------------------------------------------------- /html/qt_yank.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Yank and Put 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 52 | 57 |
49 | Quick Tutorial 50 |
Yank and Put 51 |
53 | 54 | BVI 56 |
58 |
59 |
60 | 61 |

62 | Starting with version 1.2.0 there is a new syntax for the yank and put 63 | commands! Yank is now more similare to vi. 64 |

65 | 66 | 67 | 68 | 70 | 72 | 73 | 75 | 76 | 78 | 79 | 80 | 81 | 82 | 84 | 85 | 87 | 89 | 91 |
ySPACEyanks byte under cursor
nySPACE 69 | yanks n bytes, beginning at cursor 71 | position
yfCyanks from current position to next 74 | character C
y/xyzyanks from current position to first matching 77 | pattern xyz
y$yanks from current position to EOF
y'ayanks from current position to mark a
ynGyanks from current position to byte with (decimal) 83 | address n
ooverwrites the bytes after the cursor with the contents of the yank 86 | or delete buffer
pputs the contents of the yank or delete 88 | buffer after the cursor
Pappends the contents of the buffer to end 90 | of file
92 | 93 |

Using ex (colon) Commands

94 | :y(ank) 95 |
96 | yank can be used with one or two addresses specified. One address 97 | with no count specified copies the specified byte into the buffer. 98 | Two addresses with no count specified copies multiple bytes 99 | starting and ending with the specified bytes. Two addresses and a count 100 | value copies count bytes starting at the second specified address (the 101 | first address is ignored). If no address is specified, the current address 102 | ist used by yank.
103 | Examples: 104 |
105 | :start_addr,end_addr y RETURN
106 | :start_addr y byte_countRETURN
107 | :y byte_countRETURN
108 |
109 |
110 |

111 | :pu(t) 112 |

113 | Restores previously deleted or yanked bytes after the address specified 114 | in the put command. 115 |
116 |

117 | :o(verwrite) 118 |

119 | Overwrites bytes after the specified address with previously deleted or yanked 120 | bytes. 121 |
122 |

123 | NOTE: There are currently no namend buffers available. 124 |

125 | 126 | Back to the topBack to the top 128 | 129 |


130 | Last update: June 1st 2000 by Gerhard Bürgmann, 131 | Purkersdorf/Austria 132 |
133 | 134 | -------------------------------------------------------------------------------- /html/quick.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Quick Tutorial 4 | 5 | 6 | 7 | 8 | 9 | 44 | 45 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 | Editing Files
19 | Search Commands
20 | Bit-wise Operations
21 | Find and Replace
22 | Yank and Put
23 | Settings
24 | Partial File Read
25 |

26 |

27 | Download
28 |

29 |

30 | Installation
31 |

32 |

33 | Command Overview
34 |

35 |

36 | bmore
37 |

38 |

39 | Deutsche Beschreibung
40 |

41 |
42 | 43 |
46 | 47 | 48 | 51 | 56 |
49 | Quick Tutorial 50 | 52 | 53 | BVI 55 |
57 |
58 |
59 | 60 |

61 | This tutorial will explain all commands which behaves different to 62 | vi. Note that, if you are on a Linux system, you will probably 63 | have an 'improved' version of vi. Bvi is more similar to the standard 64 | version. 65 | 66 |

The Screen

67 |
68 | 69 | 126 | 127 | 128 |
 70 | 000000
 71 | 00000C
 72 | 000018
 73 | 000024
 74 | 000030
 75 | 00003C
 76 | 000048
 77 | 000054
 78 | 000060
 79 | 00006C
 80 | 000078
 81 | 000084
 82 | 000090
 83 | 00009C
 84 |  7F 45 4C 46 01 01
 85 |  00 00 00 00 01 00
 86 |  00 00 00 00 00 00
 87 |  00 00 00 00 34 00
 88 |  0C 00 09 00 00 00
 89 |  00 00 00 00 55 89
 90 |  53 C7 45 A4 00 00
 91 |  00 00 00 83 7D 08
 92 |  8C 02 00 00 E9 6F
 93 |  00 00 00 00 6A 03
 94 |  45 08 50 E8 FC FF
 95 |  0C 85 D2 75 17 6A
 96 |  E9 43 02 00 00 8D
 97 |  0C 85 D2 75 0D C7
 98 |  01 00 00 00 00 00
 99 |  03 00 01 00 00 00
100 |  00 00 0C 07 00 00
101 |  00 00 00 00 28 00
102 |  00 00 00 00 00 00
103 |  E5 83 EC 68 57 56
104 |  00 00 C7 45 A0 01
105 |  00 75 13 6A 00 E8
106 |  02 00 00 8D B4 26
107 |  68 90 00 00 00 8B
108 |  FF FF 89 C2 83 C4
109 |  01 E8 60 02 00 00
110 |  74 26 00 8D BC 27
111 |  45 A0 00 00 00 00
112 |  .ELF........
113 |  ............
114 |  ............
115 |  ....4.....(.
116 |  ............
117 |  ....U....hWV
118 |  S.E......E..
119 |  ....}..u.j..
120 |  .....o.....&
121 |  ....j.h.....
122 |  E.P.........
123 |  ...u.j..`...
124 |  .C....t&...'
125 |  ...u..E.....
"set.o" 3500 bytes000001 \105 0x45 69 'E'
129 |
130 |

131 | The screen is divided into four areas, symbolized by four different 132 | colors. The magenta area contents the addresses in hexadecimal 133 | notation. The green area contents the values of the edited file in 134 | hexadecimal notation. The red area contents the same bytes in ASCII 135 | representation. The yellow status line displays on the left side the 136 | current status messages and on the right site the current position 137 | of the cursor and the value of the byte on this address in octal, 138 | hexadecimal, decimal and ASCII notation. 139 |
140 | You can toggle between the Hex and ASCII value of the same byte by 141 | pressing the TAB key both in command 142 | and input mode. 143 | 144 |

Command Line Options

145 | There are some additional command line options in bvi:
146 | 147 |
148 | -f script 149 |
150 | This command provides a means for collecting a series of ex 151 | (colon) commands into a script file, then using this file to edit 152 | other files. Since there is no binary stream editor bsed, you 153 | can use this option to make several global changes in a binary file. 154 | You can do this of course with the source command (:so file) 155 | from within bvi too. 156 | 157 |
158 | -b begin 159 |
160 | This option causes bvi to load a file not from start but from address 161 | begin. 162 | 163 |
164 | -e end 165 |
166 | This option causes bvi to load a file not till end but till address 167 | end. 168 | 169 |
170 | -s size 171 |
172 | This option causes bvi not to load the complete file but only size 173 | bytes. This option can also be used to read a file reported with a 174 | length 0 like some files in the Linux /proc 175 | directory. 176 |

177 | begin, end or size can be an integer value (decimal or 178 | hexadecimal) or an integer value with an appended k (for 179 | multiply by 1024) or m (for multiply by 1.048.576). 180 |

181 | You should use at most two of the three address options to avoid ambiguity! 182 | 183 | 184 |

Not Implemented Commands

185 |

186 |

    187 |
  • :map and :unmap (Macros) 188 |
  • :abbreviate (:ab) and :una 189 |
  • no named buffers. 190 |
191 |

192 | 193 | Back to the topBack to the top 195 | 196 |


197 | Last update: October 19th 2000 by Gerhard Bürgmann, 198 | Purkersdorf/Austria 199 |
200 | 201 | -------------------------------------------------------------------------------- /html/rpm.html: -------------------------------------------------------------------------------- 1 | 2 | Source RPM 3 | 4 | 5 | Switching to http://sites.inka.de/mips/unix/index.html . . . 6 | 7 | -------------------------------------------------------------------------------- /html/set.html: -------------------------------------------------------------------------------- 1 | 2 | BVI: Set Commands 3 | 4 | 5 | 6 | 7 | 8 | 15 |
9 | Command Overview 10 |
Set Commands 11 |
12 | 13 | BVI 14 |
16 |
17 |
18 |

19 | 20 |

21 | [ Cursor Movements 22 | | Edit Cmds 23 | | Yank and Put Cmds 24 | | Set Options 25 | | Colon (ex) Cmds 26 | ] 27 |
28 |

29 | 30 | 31 | 47 | 48 | 58 | 59 | 72 | 73 | 74 | 95 | 96 |
CommandBVIVI
Search
settings
32 | 33 | 35 | 38 | 40 | 42 | 44 | 45 |
:set wrapscan or :set ws
34 | :set nows
When this option is set, pattern searches resulting from a /, 36 | ?, n, N (#, \) command automatically wrap around to the opposit end of the file 37 | and continue whenever the beginning or end of a file is reached.
:set ignorecase or :set ic
39 | :set noic
Uppercase and lowercase characters in text are treated identically 41 | in regular expression matching
:set magic
43 | :set nomagic
Enables metacharacters for use in regular expressions
46 |
Display
options
49 | 50 | 52 | 53 | 55 | 56 |
:set showmode
51 | :set noshowmode
Displays a status message in the lowest line on the screen
:set terse
54 | :set noterse
The terse option lets you obtain shorter error diagnostics.
57 |
File
options
60 | 61 | 63 | 65 | 67 | 70 |
:set readonly or :set ro
62 | :set noro
This option sets the read-only flag for the file being editeds, 64 | thus preventing accidental overwriting at the end of the session.
:set autowrite or :set aw
66 | :set noaw
Causes the contents of the buffer to be written to the current file 68 | if you have modified them and given a :next, :rewind or ! 69 | command.
71 |
bvi
options
75 | 76 | 77 | 79 | 80 | 83 | 84 | 86 | 87 | 88 | 89 | 91 |
:set columns=13
:set cm=5
You can set the number of bytes displayed in on screenline. 78 | Default is max. number divisible by four.
:set memmove
:set nomm
If memmove is set, you can use commands to insert or delete bytes. 81 | This can be dangerous for e.g. executable programs. 82 | Default is nomemmove.
:set offset=1
:set of=5
An offset is added to all addresses and byte counts. Default 85 | address of the first byte is 0.
:set wordlength=5
:set wl=8
Length of an ASCII-string found by w, W, b or B
:set unixstyle
:set nous
displays ASCII characters below 32 in the status line in 90 | Unix-style instead of DOS-style
92 |
93 | Not available. 94 |
97 | 98 |

99 |

100 | [ Cursor Movements 101 | | Edit Cmds 102 | | Yank and Put Cmds 103 | | Set Options 104 | | Colon (ex) Cmds 105 | ] 106 |
107 |

108 | 109 | Back to the topBack to the top 111 | 112 |


113 | Last update: October 30th 1999 by Gerhard Bürgmann, 114 | Purkersdorf/Austria 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /html/sitemap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | BVI: Sitemap 4 | 5 | 6 | 7 | 8 | 9 | 37 | 38 |
10 | 11 | 12 |
13 |

14 | Home
15 |

16 |

17 | Quick Tutorial
18 |

19 |

20 | Download
21 |

22 |

23 | Installation
24 |

25 |

26 | Command Overview
27 |

28 |

29 | bmore
30 |

31 |

32 | Deutsche Beschreibung
33 |

34 |
35 | 36 |
39 | 40 | 41 | 44 | 49 |
42 | Sitemap 43 | 45 | 46 | BVI 48 |
50 |
51 |
52 | 53 |

54 |

151 |

152 | 153 | Back to the topBack to the top 155 | 156 |


157 | Last update: January 8th 2004 by Gerhard Bürgmann, 158 | Purkersdorf/Austria 159 |
160 | 161 | -------------------------------------------------------------------------------- /html/yank.html: -------------------------------------------------------------------------------- 1 | 2 | BVI: Yank and Put Commands 3 | 4 | 5 | 6 | 7 | 8 | 15 |
9 | Command Overview 10 |
Yank and Put Commands 11 |
12 | 13 | BVI 14 |
16 |
17 |
18 |

19 | 20 |

21 | [ Cursor Movements 22 | | Edit Cmds 23 | | Yank and Put Cmds 24 | | Set Options 25 | | Colon (ex) Cmds 26 | ] 27 |
28 |

29 | NOTE: the o command (overwriting put) is the only command in 30 | bvi that uses a key for a complete different purpose than in vi. 31 |

32 | 33 | 34 | 35 | 36 | 42 | 52 | 62 | 63 | 64 | 79 | 80 | 95 | 109 | 118 |
CommandBVIVI
Put
bytes
37 | 38 | 39 | 40 |
  p  put the contents of the yank or delete buffer after cursor position
41 |
43 | 44 | 45 |
  P  append the contents of the yank or delete buffer at EOF
46 |
47 | 48 | 50 |
  P  put the contents of the yank or delete buffer 49 | before cursor position
51 |
53 | 54 | 56 |
  o  overwrite the following bytes with the contents 55 | of the yank or delete buffer
57 |
58 | 59 | 60 |
not available
61 |
Yank
bytes
65 | 66 | 67 | 68 | 69 | 70 | 72 | 73 | 75 | 76 | 77 |
ySPACEyank byte at cursor position
yfCyank from current position to next character C
y/xyzyank from current position to matching pattern xyz 71 |
y?xyzyank from current position to matching pattern xyz in reverse direction 74 |
y'ayank from current position to mark a
ynGyank from current position to byte with (decimal) address n
78 |
81 | 82 | 83 |
not available
84 |
85 | 86 | 87 | 89 | 91 | 93 |
yy  yank line
y)yank from cursor position through first 88 | following end of sentence
y}yank from cursor position through first 90 | following end of paragraph
y]yank from cursor position through first 92 | following end of section
94 |
96 | 97 | 98 | 100 | 101 | 103 |
y\6a 56 ff  yank from cursor position to first occurance of hex pattern 99 | 6a 56 ff
y#6a 56 ff  yank from cursor position to first occurance of hex pattern 102 | 6a 56 ff in reverse direction
104 |
105 | 106 | 107 |
not available
108 |
110 | 111 | 112 |
  y$  yank from current position to EOF
113 |
114 | 115 | 116 |
  y$  yank from current position to end of line
117 |
119 |

120 | Note that most of the commands can be used with a decimal repeat count in front 121 | of the command! 122 | 123 |

124 |

125 | [ Cursor Movements 126 | | Edit Cmds 127 | | Yank and Put Cmds 128 | | Set Options 129 | | Colon (ex) Cmds 130 | ] 131 |
132 |

133 | 134 | Back to the topBack to the top 136 | 137 |


138 | Last update: October 30th 1999 by Gerhard Bürgmann, 139 | Purkersdorf/Austria 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /include/blocks.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | /* Internal abstractions */ 23 | 24 | int InitBlocksList(); 25 | block_link BlockNew(); 26 | void BlockFree(); 27 | void BlockInsertNext(); 28 | block_link BlockDeleteNext(); 29 | block_link BlockNext(); 30 | struct block_item BlockGet(); 31 | 32 | /* External interface */ 33 | 34 | int blocks__Iterator(buf_t *buf, int (*(func))(), int result); 35 | int blocks__Add(buf_t *buf, struct block_item b); 36 | int blocks__Init(buf_t *buf); 37 | int blocks__Destroy(buf_t *buf); 38 | int blocks__DelByID(buf_t *buf, int id); 39 | int blocks__DelByName(buf_t *buf, char* name); 40 | struct block_item* blocks__GetByID(buf_t *buf, unsigned int id); 41 | struct block_item* blocks__GetByName(buf_t *buf, char* name); 42 | 43 | -------------------------------------------------------------------------------- /include/bmath.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | #include 23 | #define MATH_ARITH 1 24 | 25 | typedef unsigned char bit_t; 26 | typedef unsigned char bool_t; 27 | 28 | /* 29 | * If your env does not support inttypes.h replace with this: 30 | * typedef unsigned long long crc_reg_t; 31 | * #define REGFMT "llx" 32 | */ 33 | typedef uint64_t crc_reg_t; 34 | #define REGFMT PRIx64 35 | 36 | int math__logic(core_t* core, buf_t* buf, int mode, char* str); 37 | int math__logic_block(core_t *core, buf_t* buf, int mode, char* str, int block_id); 38 | double math__entropy(core_t *core, buf_t* buf, int block_id); 39 | 40 | /* Arithmetics */ 41 | long math__eval(int mode, char *expression); 42 | 43 | /* Checksums */ 44 | unsigned int crc16(char *addr, int num, unsigned int crc); 45 | unsigned int crc32(char *addr, int num, unsigned int crc); 46 | 47 | /* MD hashes */ 48 | void math__md4_hash_string(unsigned char *string, long len, char *outputBuffer); 49 | void math__md5_hash_string(unsigned char *string, long len, char *outputBuffer); 50 | 51 | /* SHA hashes */ 52 | void math__sha1_hash_string(unsigned char *string, long len, char *outputBuffer); 53 | void math__sha256_hash_string(unsigned char *string, long len, char *outputBuffer); 54 | void math__sha512_hash_string(unsigned char *string, long len, char *outputBuffer); 55 | 56 | /* RIPEMD hash */ 57 | void math__ripemd160_hash_string(unsigned char *string, long len, char *outputBuffer); 58 | -------------------------------------------------------------------------------- /include/bscript.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | #define LUA_DEFAULT_SCRIPT_PATH "scripts" 23 | 24 | #define lua_setConst(state, name) { lua_pushnumber(state, name); lua_setglobal(state, #name ); } 25 | 26 | typedef struct lua_io *lua_io_link; 27 | 28 | struct lua_io_item { 29 | char* lua_input; 30 | char* lua_output; 31 | char* lua_error; 32 | }; 33 | 34 | struct lua_io { 35 | struct lua_io_item item; 36 | lua_io_link next; 37 | }; 38 | 39 | void bvim_lua_init(core_t*); 40 | void bvim_lua_finish(core_t*); 41 | int bvim_run_lua_string(core_t*, buf_t*, char*); 42 | int bvim_run_lua_script(core_t*, buf_t*, char*); 43 | int bvim_repl_read(); 44 | int bvim_repl_eval(char* line); 45 | 46 | int luaF_Add(core_t*, struct luaF_item b); 47 | int luaF_Iterator(core_t *, int (*(func))(), int result); 48 | int luaF_DelByName(core_t*, char *); 49 | int luaF_DelByID(core_t*, int); 50 | struct luaF_item* luaF_GetByName(core_t*, char*); 51 | struct luaF_item* luaF_GetByID(core_t*, unsigned int); 52 | 53 | -------------------------------------------------------------------------------- /include/buffers.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | /* e.g. 23 | * input = "print(4+9)" 24 | * output = "13" 25 | */ 26 | struct iorecord { 27 | char* input; 28 | char* output; 29 | }; 30 | 31 | typedef struct iorecord iorecord_t; 32 | 33 | typedef struct iorecord_l *iorecord_link; 34 | 35 | struct iorecord_l { 36 | iorecord_t item; 37 | iorecord_link next; 38 | }; 39 | 40 | unsigned long io__BufferAdd(); 41 | int io__BufferAdd2(unsigned long id); 42 | int io__BufferDestroy(unsigned long buffer_id); 43 | unsigned long io__RecordInsert(unsigned long buffer_id, iorecord_t record); 44 | int io__RecordDelete(unsigned long buffer_id, unsigned long record_id); 45 | iorecord_t* io__RecordGet(unsigned long buffer_id, unsigned long record_id); 46 | -------------------------------------------------------------------------------- /include/collaboration.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | 23 | /* 24 | * Protocol: 25 | * 26 | * SERVER 27 | * ====== 28 | * 29 | * Connecting messages: 30 | * 31 | * CONNECT 32 | * - OK 33 | * AUTH 34 | * - OK 35 | * - FAIL: INCORRECT LOGIN 36 | * DISCONNECT 37 | * 38 | * Project messages: 39 | * 40 | * PROJECT LIST 41 | * - list of (name, id) 42 | * 43 | * PROJECT OPEN [] 44 | * - OK (stream data) 45 | * 46 | * PROJECT CLOSE 47 | * - OK 48 | * - FAIL: UNKNOWN ERROR 49 | */ 50 | -------------------------------------------------------------------------------- /include/commands.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | int command__help(core_t*, buf_t*, char, int, char**); 23 | int command__map(core_t*, buf_t*, char, int, char**); 24 | int command__unmap(core_t*, buf_t*, char, int, char**); 25 | int command__set(core_t*, buf_t*, char, int, char**); 26 | int command__block(core_t*, buf_t*, char, int, char**); 27 | int command__lua(core_t*, buf_t*, char, int, char**); 28 | int command__args(core_t*, buf_t*, char, int, char**); 29 | int command__source(core_t*, buf_t*, char, int, char**); 30 | int command__run(core_t*, buf_t*, char, int, char**); 31 | int command__cd(core_t*, buf_t*, char, int, char**); 32 | int command__edit(core_t*, buf_t*, char, int, char**); 33 | int command__file(core_t*, buf_t*, char, int, char**); 34 | int command__read(core_t*, buf_t*, char, int, char**); 35 | int command__xit(core_t*, buf_t*, char, int, char**); 36 | int command__next(core_t*, buf_t*, char, int, char**); 37 | int command__rewind(core_t*, buf_t*, char, int, char**); 38 | int command__append(core_t*, buf_t*, char, int, char**); 39 | int command__change(core_t*, buf_t*, char, int, char**); 40 | int command__mark(core_t*, buf_t*, char, int, char**); 41 | int command__yank(core_t*, buf_t*, char, int, char**); 42 | int command__overwrite(core_t*, buf_t*, char, int, char**); 43 | int command__undo(core_t*, buf_t*, char, int, char**); 44 | int command__version(core_t*, buf_t*, char, int, char**); 45 | int command__shell(core_t*, buf_t*, char, int, char**); 46 | int command__quit(core_t*, buf_t*, char, int, char**); 47 | int command__sleft(core_t*, buf_t*, char, int, char**); 48 | int command__sright(core_t*, buf_t*, char, int, char**); 49 | int command__rleft(core_t*, buf_t*, char, int, char**); 50 | int command__rright(core_t*, buf_t*, char, int, char**); 51 | int command__and(core_t*, buf_t*, char, int, char**); 52 | int command__or(core_t*, buf_t*, char, int, char**); 53 | int command__xor(core_t*, buf_t*, char, int, char**); 54 | int command__neg(core_t*, buf_t*, char, int, char**); 55 | int command__not(core_t*, buf_t*, char, int, char**); 56 | int command__fuz(core_t*, buf_t*, char, int, char**); 57 | 58 | void commands__Init(core_t*); 59 | void commands__Destroy(core_t*); 60 | int commands__Cmd_Add(core_t*, command_t*); 61 | int commands__Cmd_Del(core_t*, char*); 62 | 63 | 64 | void docmdline(core_t*, buf_t *, char *); 65 | int chk_comm(core_t *core, buf_t* buf, int flag); 66 | 67 | -------------------------------------------------------------------------------- /include/keys.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | void keys__Init(core_t*); 23 | void keys__Destroy(core_t*); 24 | int keys__Key_Pressed(core_t*, int); 25 | bkey_t *keys__KeyString_Parse(core_t*, char*); 26 | int keys__Key_Map(core_t*, bkey_t*); 27 | int keys__Key_Unmap(core_t*, bkey_t*); 28 | void keys__KeyMaps_Show(core_t*); 29 | 30 | -------------------------------------------------------------------------------- /include/messages.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | #define BVI_ERROR_PATNOTFOUND "Fail|Pattern not found" 23 | #define BVI_ERROR_NOPREVEXPR "No previous expression" 24 | #define BVI_ERROR_EMPTYCLASS "Bad character class|Empty byte class '[]' or '[^]' cannot match" 25 | #define BVI_ERROR_NOWRITE "No write@since last change (:%s! overrides)" 26 | #define BVI_ERROR_MOREFILES "more files@to edit" 27 | #define BVI_ERROR_AMBIGOUS "Ambigous|Too many file names" 28 | #define BVI_ERROR_AMBVALUE "Ambigous|Too many values" 29 | #define BVI_ERROR_EXTRACHARS "Extra chars|Extra characters at end of command" 30 | #define BVI_ERROR_NOADDR "No address allowed@on this command" 31 | #define BVI_ERROR_NOVAL "No value@for binary operation" 32 | #define BVI_ERROR_NOBYTES "No bytes@in the buffer" 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /include/patchlevel.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | #define VERSION "1.3.3" 23 | -------------------------------------------------------------------------------- /include/plugins.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | /* Exported types: 23 | * int command__handler(char, int, char**); - for commands handlers 24 | * int handler__func() - for key handlers 25 | * bvim_add_lua_function - not yet implemented 26 | */ 27 | 28 | typedef struct plugin *plugin_link; 29 | 30 | struct plugin_ { 31 | char* name; 32 | char* author; 33 | char* license; 34 | struct { 35 | short major; 36 | short minor; 37 | } version; 38 | char* description; 39 | void* module; 40 | struct { 41 | struct key *keys; 42 | struct command *cmds; 43 | struct luaF_item *luaF_list; 44 | } exports; 45 | }; 46 | 47 | typedef struct plugin_ plugin_t; 48 | 49 | struct plugin { 50 | plugin_t item; 51 | plugin_link next; 52 | }; 53 | 54 | /* Plugin API: 55 | * 56 | * plugin_t plugin_register() function - fill plugin info 57 | * plugin_init(plugin_t plugin); 58 | * 59 | * Import core, state, blocks, commands and keys structure. 60 | * 61 | * plugin_unregister() function - remove plugin info, 62 | * remove previously exported handlers, keys, commands, lua 63 | * functions, etc. 64 | */ 65 | 66 | // TODO: Export all data as set of objects 67 | // TODO: and export iterator functions on these sets 68 | 69 | /* --------------------------------------------------------- 70 | * for using only in bvimm 71 | * --------------------------------------------------------- 72 | */ 73 | 74 | int plugins__Init(core_t*); 75 | plugin_t* plugins__GetByName(core_t*, char*); 76 | int plugins__Destroy(core_t*); 77 | int plugin__Load(core_t*, char *path); 78 | int plugin__Unload(core_t*, plugin_t *plg); 79 | -------------------------------------------------------------------------------- /include/search.h: -------------------------------------------------------------------------------- 1 | #define FUZZY_BITAP_HAMMINGTON_DISTANCE 1 2 | #define FUZZY_BITAP_LEVENSHTEIN_DISTANCE 2 3 | 4 | struct match { 5 | char* ptr; 6 | char* str; 7 | long start; 8 | long length; 9 | }; 10 | 11 | typedef struct match match_t; 12 | 13 | typedef struct match_list *mlist; 14 | 15 | struct match_list { 16 | match_t m; 17 | mlist next; 18 | }; 19 | 20 | struct found { 21 | mlist ml; 22 | long cnt; 23 | }; 24 | 25 | /* Exported functions */ 26 | 27 | struct found fuzzy_search(core_t *core, buf_t *buf, long input_size, void *pattern, long pattern_size, int algo, int distance); 28 | 29 | -------------------------------------------------------------------------------- /include/set.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | struct param { 23 | char *fullname; /* full parameter name */ 24 | char *shortname; /* permissible abbreviation */ 25 | long nvalue; 26 | char *svalue; 27 | int flags; 28 | }; 29 | 30 | struct color { 31 | char *fullname; /* full name of color attribute */ 32 | char *shortname; /* permissible abbreviation */ 33 | unsigned int r; 34 | unsigned int g; 35 | unsigned int b; 36 | unsigned int short_value; 37 | }; 38 | 39 | extern struct param params[]; 40 | extern struct color colors[]; 41 | 42 | #define P_BOOL 0x01 /* the parameter is boolean */ 43 | #define P_NUM 0x02 /* the parameter is numeric */ 44 | #define P_TEXT 0x04 /* the paameter is text */ 45 | #define P_CHANGED 0x08 /* the parameter has been changed */ 46 | 47 | /* 48 | * The following are the indices in the params array for each parameter 49 | */ 50 | 51 | /* 52 | * parameters 53 | */ 54 | #define P_AW 0 /* Autowrite */ 55 | #define P_CM 1 /* Columns */ 56 | #define P_EB 2 /* error bells */ 57 | #define P_IC 3 /* ignore case in searches */ 58 | #define P_MA 4 /* Magic characters in reg expr */ 59 | #define P_MM 5 /* move bytes in file */ 60 | #define P_OF 6 /* address offset */ 61 | #define P_RO 7 /* Readonly */ 62 | #define P_SS 8 /* scroll size */ 63 | #define P_MO 9 /* show mode */ 64 | #define P_TT 10 /* Terminal type */ 65 | #define P_TE 11 /* Terse (short messages) */ 66 | #define P_US 12 /* Unix-Style of ASCII representation */ 67 | #define P_LI 13 /* lines */ 68 | #define P_WL 14 /* Wordlength for w, W, b, B command */ 69 | #define P_WS 15 /* wrapscan */ 70 | 71 | /* 72 | * colors 73 | */ 74 | 75 | #define C_BG 0 /* Background color */ 76 | #define C_AD 1 /* Addresses color */ 77 | #define C_HX 2 /* Hexadecimal data window color */ 78 | #define C_DT 3 /* Source data window color */ 79 | #define C_ER 4 /* Error message color */ 80 | #define C_ST 5 /* Status line color */ 81 | #define C_CM 6 /* Command line color */ 82 | #define C_WN 7 /* Window color */ 83 | #define C_AB 8 /* Addresses background color */ 84 | 85 | /* 86 | * Macro to get the value of a parameter 87 | */ 88 | #define P(n) (params[n].nvalue) 89 | #define C_r(n) (colors[n].r) 90 | #define C_g(n) (colors[n].g) 91 | #define C_b(n) (colors[n].b) 92 | #define C_s(n) (colors[n].short_value) 93 | 94 | void set_palette(void); 95 | -------------------------------------------------------------------------------- /include/signature.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | /* --------------------------------------------------------------- 23 | * Internal abstractions 24 | * --------------------------------------------------------------- 25 | */ 26 | 27 | struct magic { 28 | int record_size; 29 | int type; 30 | char* str; 31 | char* description; 32 | }; 33 | 34 | /* Signature item */ 35 | struct sig { 36 | char* name; 37 | char* description; 38 | int size; 39 | unsigned char* signature; 40 | }; 41 | 42 | typedef struct sig signature_t; 43 | 44 | /* List of signatures (named signatures pack) */ 45 | typedef struct sigl *siglist; 46 | 47 | struct sigl { 48 | signature_t sg; 49 | siglist next; 50 | }; 51 | 52 | struct sigpack { 53 | char* name; 54 | char* description; 55 | int size; 56 | siglist sigs; 57 | }; 58 | 59 | typedef struct sigpack sigpack_t; 60 | -------------------------------------------------------------------------------- /include/ui.h: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | typedef struct hl_t *hl_link; 23 | 24 | struct hl_item { 25 | unsigned int id; /* unique id */ 26 | char name[64]; /* for naming highlights */ 27 | unsigned long hex_start; 28 | unsigned long hex_end; 29 | unsigned long dat_start; 30 | unsigned long dat_end; 31 | int flg; 32 | unsigned int palette; /* pallete, which we are using for highlight */ 33 | int toggle; /* is this highlighting enabled? */ 34 | }; 35 | 36 | struct hl_t { 37 | struct hl_item item; 38 | hl_link next; 39 | }; 40 | 41 | 42 | struct repl_t { 43 | int current_y; 44 | int current_x; 45 | }; 46 | 47 | void ui__Init(core_t*, buf_t*); 48 | void ui__ErrorMsg(core_t*, buf_t*, char *); 49 | void ui__SystemErrorMsg(core_t*, buf_t *, char *); 50 | void ui__StatusMsg(core_t*, buf_t*, char *); 51 | void ui__MsgWin_Show(core_t*, buf_t*, char *, int width, int height); 52 | 53 | int ui__ToolWin_Show(core_t*, buf_t*, int); 54 | int ui__ToolWin_Hide(core_t*, buf_t*); 55 | int ui__ToolWin_Print(core_t*, buf_t*, char *, int); 56 | short ui__ToolWin_Exist(core_t*, buf_t*); 57 | 58 | int ui__REPL_Main(core_t*, buf_t*); 59 | int ui__REPLWin_Show(core_t*, buf_t*); 60 | int ui__REPLWin_Hide(core_t*, buf_t*); 61 | int ui__REPLWin_print(core_t*, buf_t*, char*); 62 | int ui__REPLWin_clear(core_t*, buf_t*); 63 | short ui__REPLWin_Exist(); 64 | 65 | void ui__MainWin_Resize(core_t*, int); 66 | void printcolorline(int, int, int, char *); 67 | void ui__Line_Print(core_t*, buf_t*, PTR, int); 68 | int ui__lineout(core_t*, buf_t*); 69 | void ui__clearstr(core_t*, buf_t*); 70 | void ui__smsg(core_t*, buf_t*, char *s); 71 | 72 | void ui__setcur(void); 73 | 74 | int ui__Color_Set(core_t *core, buf_t *buf, char *); 75 | void ui__Colors_Set(); 76 | void ui__Colors_Load(); 77 | void ui__Colors_Save(); 78 | 79 | void ui__Screen_Repaint(core_t*, buf_t*); 80 | void ui__Screen_New(core_t*, buf_t*); 81 | 82 | int ui__BlockHighlightAdd(struct block_item *blk); 83 | 84 | int ui__Destroy(); 85 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # install - install a program, script, or datafile 4 | # This comes from X11R5 (mit/util/scripts/install.sh). 5 | # 6 | # Copyright 1991 by the Massachusetts Institute of Technology 7 | # 8 | # Permission to use, copy, modify, distribute, and sell this software and its 9 | # documentation for any purpose is hereby granted without fee, provided that 10 | # the above copyright notice appear in all copies and that both that 11 | # copyright notice and this permission notice appear in supporting 12 | # documentation, and that the name of M.I.T. not be used in advertising or 13 | # publicity pertaining to distribution of the software without specific, 14 | # written prior permission. M.I.T. makes no representations about the 15 | # suitability of this software for any purpose. It is provided "as is" 16 | # without express or implied warranty. 17 | # 18 | # Calling this script install-sh is preferred over install.sh, to prevent 19 | # `make' implicit rules from creating a file called install from it 20 | # when there is no Makefile. 21 | # 22 | # This script is compatible with the BSD install script, but was written 23 | # from scratch. It can only install one file at a time, a restriction 24 | # shared with many OS's install programs. 25 | 26 | 27 | # set DOITPROG to echo to test this script 28 | 29 | # Don't use :- since 4.3BSD and earlier shells don't like it. 30 | doit="${DOITPROG-}" 31 | 32 | 33 | # put in absolute paths if you don't have them in your path; or use env. vars. 34 | 35 | mvprog="${MVPROG-mv}" 36 | cpprog="${CPPROG-cp}" 37 | chmodprog="${CHMODPROG-chmod}" 38 | chownprog="${CHOWNPROG-chown}" 39 | chgrpprog="${CHGRPPROG-chgrp}" 40 | stripprog="${STRIPPROG-strip}" 41 | rmprog="${RMPROG-rm}" 42 | mkdirprog="${MKDIRPROG-mkdir}" 43 | 44 | transformbasename="" 45 | transform_arg="" 46 | instcmd="$mvprog" 47 | chmodcmd="$chmodprog 0755" 48 | chowncmd="" 49 | chgrpcmd="" 50 | stripcmd="" 51 | rmcmd="$rmprog -f" 52 | mvcmd="$mvprog" 53 | src="" 54 | dst="" 55 | dir_arg="" 56 | 57 | while [ x"$1" != x ]; do 58 | case $1 in 59 | -c) instcmd=$cpprog 60 | shift 61 | continue;; 62 | 63 | -d) dir_arg=true 64 | shift 65 | continue;; 66 | 67 | -m) chmodcmd="$chmodprog $2" 68 | shift 69 | shift 70 | continue;; 71 | 72 | -o) chowncmd="$chownprog $2" 73 | shift 74 | shift 75 | continue;; 76 | 77 | -g) chgrpcmd="$chgrpprog $2" 78 | shift 79 | shift 80 | continue;; 81 | 82 | -s) stripcmd=$stripprog 83 | shift 84 | continue;; 85 | 86 | -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87 | shift 88 | continue;; 89 | 90 | -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91 | shift 92 | continue;; 93 | 94 | *) if [ x"$src" = x ] 95 | then 96 | src=$1 97 | else 98 | # this colon is to work around a 386BSD /bin/sh bug 99 | : 100 | dst=$1 101 | fi 102 | shift 103 | continue;; 104 | esac 105 | done 106 | 107 | if [ x"$src" = x ] 108 | then 109 | echo "$0: no input file specified" >&2 110 | exit 1 111 | else 112 | : 113 | fi 114 | 115 | if [ x"$dir_arg" != x ]; then 116 | dst=$src 117 | src="" 118 | 119 | if [ -d "$dst" ]; then 120 | instcmd=: 121 | chmodcmd="" 122 | else 123 | instcmd=$mkdirprog 124 | fi 125 | else 126 | 127 | # Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128 | # might cause directories to be created, which would be especially bad 129 | # if $src (and thus $dsttmp) contains '*'. 130 | 131 | if [ -f "$src" ] || [ -d "$src" ] 132 | then 133 | : 134 | else 135 | echo "$0: $src does not exist" >&2 136 | exit 1 137 | fi 138 | 139 | if [ x"$dst" = x ] 140 | then 141 | echo "$0: no destination specified" >&2 142 | exit 1 143 | else 144 | : 145 | fi 146 | 147 | # If destination is a directory, append the input filename; if your system 148 | # does not like double slashes in filenames, you may need to add some logic 149 | 150 | if [ -d "$dst" ] 151 | then 152 | dst=$dst/`basename "$src"` 153 | else 154 | : 155 | fi 156 | fi 157 | 158 | ## this sed command emulates the dirname command 159 | dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160 | 161 | # Make sure that the destination directory exists. 162 | # this part is taken from Noah Friedman's mkinstalldirs script 163 | 164 | # Skip lots of stat calls in the usual case. 165 | if [ ! -d "$dstdir" ]; then 166 | defaultIFS=' 167 | ' 168 | IFS="${IFS-$defaultIFS}" 169 | 170 | oIFS=$IFS 171 | # Some sh's can't handle IFS=/ for some reason. 172 | IFS='%' 173 | set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` 174 | IFS=$oIFS 175 | 176 | pathcomp='' 177 | 178 | while [ $# -ne 0 ] ; do 179 | pathcomp=$pathcomp$1 180 | shift 181 | 182 | if [ ! -d "$pathcomp" ] ; 183 | then 184 | $mkdirprog "$pathcomp" 185 | else 186 | : 187 | fi 188 | 189 | pathcomp=$pathcomp/ 190 | done 191 | fi 192 | 193 | if [ x"$dir_arg" != x ] 194 | then 195 | $doit $instcmd "$dst" && 196 | 197 | if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && 198 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && 199 | if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && 200 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi 201 | else 202 | 203 | # If we're going to rename the final executable, determine the name now. 204 | 205 | if [ x"$transformarg" = x ] 206 | then 207 | dstfile=`basename "$dst"` 208 | else 209 | dstfile=`basename "$dst" $transformbasename | 210 | sed $transformarg`$transformbasename 211 | fi 212 | 213 | # don't allow the sed command to completely eliminate the filename 214 | 215 | if [ x"$dstfile" = x ] 216 | then 217 | dstfile=`basename "$dst"` 218 | else 219 | : 220 | fi 221 | 222 | # Make a couple of temp file names in the proper directory. 223 | 224 | dsttmp=$dstdir/#inst.$$# 225 | rmtmp=$dstdir/#rm.$$# 226 | 227 | # Trap to clean up temp files at exit. 228 | 229 | trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 230 | trap '(exit $?); exit' 1 2 13 15 231 | 232 | # Move or copy the file name to the temp name 233 | 234 | $doit $instcmd "$src" "$dsttmp" && 235 | 236 | # and set any options; do chmod last to preserve setuid bits 237 | 238 | # If any of these fail, we abort the whole thing. If we want to 239 | # ignore errors from any of these, just make sure not to ignore 240 | # errors from the above "$doit $instcmd $src $dsttmp" command. 241 | 242 | if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && 243 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && 244 | if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && 245 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && 246 | 247 | # Now remove or move aside any old file at destination location. We try this 248 | # two ways since rm can't unlink itself on some systems and the destination 249 | # file might be busy for other reasons. In this case, the final cleanup 250 | # might fail but the new file should still install successfully. 251 | 252 | { 253 | if [ -f "$dstdir/$dstfile" ] 254 | then 255 | $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || 256 | $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || 257 | { 258 | echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 259 | (exit 1); exit 260 | } 261 | else 262 | : 263 | fi 264 | } && 265 | 266 | # Now rename the file to the real destination. 267 | 268 | $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" 269 | 270 | fi && 271 | 272 | # The final little trick to "correctly" pass the exit status to the exit trap. 273 | 274 | { 275 | (exit 0); exit 276 | } 277 | -------------------------------------------------------------------------------- /lua/Makefile: -------------------------------------------------------------------------------- 1 | OS_ARCH ?= $(shell uname) 2 | ifeq ($(OS_ARCH), Darwin) 3 | PLATFORM=macosx 4 | endif 5 | ifeq ($(OS_ARCH), FreeBSD) 6 | PLATFORM=freebsd 7 | endif 8 | ifeq ($(OS_ARCH), Linux) 9 | PLATFORM=linux 10 | endif 11 | ifeq ($(OS_ARCH), SunOS) 12 | PLATFORM=solaris 13 | endif 14 | ifeq ($(OS_ARCH), OpenBSD) 15 | PLATFORM=bsd 16 | endif 17 | ifeq ($(OS_ARCH), NetBSD) 18 | PLATFORM=bsd 19 | endif 20 | 21 | VERSION=5.1.4 22 | 23 | lua: compile install 24 | 25 | compile: 26 | @if [ ! -d lua-${VERSION} ]; then tar -xf lua-${VERSION}.tar.gz; fi 27 | @if [ ! -d lua-${VERSION} ]; then patch -p0 < bitwise_operators_5.1.4_1.patch; fi 28 | @if [ ! -d lua-${VERSION} ]; then patch -p0 < jh-lua-binoctal-5.1.4.patch; fi 29 | cd lua-${VERSION} && make ${PLATFORM} 30 | 31 | install: 32 | @if [ ! -d lib ]; then mkdir lib; fi 33 | @if [ ! -d include ]; then mkdir include; fi 34 | cp lua-${VERSION}/src/liblua.a lib/liblua.a 35 | cp lua-${VERSION}/src/lua.h include/lua.h 36 | cp lua-${VERSION}/src/luaconf.h include/luaconf.h 37 | cp lua-${VERSION}/src/lualib.h include/lualib.h 38 | cp lua-${VERSION}/src/lauxlib.h include/lauxlib.h 39 | 40 | clean: 41 | rm -rf lua-${VERSION} 42 | rm -rf include 43 | rm -rf lib 44 | -------------------------------------------------------------------------------- /lua/jh-lua-binoctal-5.1.4.patch: -------------------------------------------------------------------------------- 1 | diff U5 lua-5.1.4/src/lobject.c lua-5.1.4jh/src/lobject.c 2 | --- lua-5.1.4/src/lobject.c Thu Dec 27 13:02:24 2007 3 | +++ lua-5.1.4jh/src/lobject.c Thu Jan 14 15:34:36 2010 4 | @@ -91,10 +91,18 @@ 5 | char *endptr; 6 | *result = lua_str2number(s, &endptr); 7 | if (endptr == s) return 0; /* conversion failed */ 8 | if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ 9 | *result = cast_num(strtoul(s, &endptr, 16)); 10 | + 11 | +#if defined(JH_LUA_BINOCTAL) 12 | + if ((*endptr == 'o' || *endptr == 'O') && (*(endptr+1) != '\0')) 13 | + *result = cast_num(strtoul(endptr+1, &endptr, 8)); 14 | + if ((*endptr == 'b' || *endptr == 'B') && (*(endptr+1) != '\0')) 15 | + *result = cast_num(strtoul(endptr+1, &endptr, 2)); 16 | +#endif 17 | + 18 | if (*endptr == '\0') return 1; /* most common case */ 19 | while (isspace(cast(unsigned char, *endptr))) endptr++; 20 | if (*endptr != '\0') return 0; /* invalid trailing characters? */ 21 | return 1; 22 | } 23 | -------------------------------------------------------------------------------- /lua/lua-5.1.4.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XVilka/bvim/eaff1399a42b41f2477c0c9a321610a088988d16/lua/lua-5.1.4.tar.gz -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | errstatus=0 8 | dirmode="" 9 | 10 | usage="\ 11 | Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." 12 | 13 | # process command line arguments 14 | while test $# -gt 0 ; do 15 | case $1 in 16 | -h | --help | --h*) # -h for help 17 | echo "$usage" 1>&2 18 | exit 0 19 | ;; 20 | -m) # -m PERM arg 21 | shift 22 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } 23 | dirmode=$1 24 | shift 25 | ;; 26 | --) # stop option processing 27 | shift 28 | break 29 | ;; 30 | -*) # unknown option 31 | echo "$usage" 1>&2 32 | exit 1 33 | ;; 34 | *) # first non-opt arg 35 | break 36 | ;; 37 | esac 38 | done 39 | 40 | for file 41 | do 42 | if test -d "$file"; then 43 | shift 44 | else 45 | break 46 | fi 47 | done 48 | 49 | case $# in 50 | 0) exit 0 ;; 51 | esac 52 | 53 | case $dirmode in 54 | '') 55 | if mkdir -p -- . 2>/dev/null; then 56 | echo "mkdir -p -- $*" 57 | exec mkdir -p -- "$@" 58 | fi 59 | ;; 60 | *) 61 | if mkdir -m "$dirmode" -p -- . 2>/dev/null; then 62 | echo "mkdir -m $dirmode -p -- $*" 63 | exec mkdir -m "$dirmode" -p -- "$@" 64 | fi 65 | ;; 66 | esac 67 | 68 | for file 69 | do 70 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 71 | shift 72 | 73 | pathcomp= 74 | for d 75 | do 76 | pathcomp="$pathcomp$d" 77 | case $pathcomp in 78 | -*) pathcomp=./$pathcomp ;; 79 | esac 80 | 81 | if test ! -d "$pathcomp"; then 82 | echo "mkdir $pathcomp" 83 | 84 | mkdir "$pathcomp" || lasterr=$? 85 | 86 | if test ! -d "$pathcomp"; then 87 | errstatus=$lasterr 88 | else 89 | if test ! -z "$dirmode"; then 90 | echo "chmod $dirmode $pathcomp" 91 | lasterr="" 92 | chmod "$dirmode" "$pathcomp" || lasterr=$? 93 | 94 | if test ! -z "$lasterr"; then 95 | errstatus=$lasterr 96 | fi 97 | fi 98 | fi 99 | fi 100 | 101 | pathcomp="$pathcomp/" 102 | done 103 | done 104 | 105 | exit $errstatus 106 | 107 | # Local Variables: 108 | # mode: shell-script 109 | # sh-indentation: 2 110 | # End: 111 | # mkinstalldirs ends here 112 | -------------------------------------------------------------------------------- /plugins/Makefile: -------------------------------------------------------------------------------- 1 | IDIR = ../include 2 | CC = gcc 3 | CFLAGS = -I$(IDIR) -I../lua/include 4 | DEPS = plugins.h 5 | OBJ = test.o 6 | LIBS = -lc -llua 7 | 8 | plugins: test.so visualisation.so 9 | 10 | test.so: test.o 11 | $(CC) -shared -fPIC -o $@ $^ $(CFLAGS) $(LIBS) 12 | 13 | test.o: test.c 14 | $(CC) -c -fPIC -o $@ $< $(CFLAGS) 15 | 16 | visualisation.so: visualisation.o 17 | $(CC) -shared -fPIC -o $@ $^ $(CFLAGS) $(LIBS) -lmgl 18 | 19 | visualisation.o: visualisation.c 20 | $(CC) -c -fPIC -o $@ $< $(CFLAGS) 21 | 22 | clean: 23 | rm *.o *.so 24 | -------------------------------------------------------------------------------- /plugins/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "plugins.h" 6 | #include "data.h" 7 | 8 | core_t *core; 9 | state_t *state; 10 | api_t *api; 11 | 12 | void (*plugin_error)(int, char*, ...); 13 | void (*plugin_info)(int, char*, ...); 14 | void (*plugin_debug)(int, char*, ...); 15 | 16 | /* --------------------------------------------------------------- 17 | * exported commands 18 | * --------------------------------------------------------------- 19 | */ 20 | 21 | struct command cmds[] = { 22 | { 35, "test", "do nothing", 1, BVI_HANDLER_EXTERNAL, { .func_name = "plg_command_test" }, 4, 1}, 23 | { 0, NULL, NULL, 0, 0, { NULL }, 0, 0} 24 | }; 25 | 26 | /* --------------------------------------------------------------- 27 | * exported keys 28 | * --------------------------------------------------------------- 29 | */ 30 | 31 | 32 | struct key keys[] = { 33 | { BVI_CTRL('P'), "Ctrl-P", "", 1, BVI_HANDLER_EXTERNAL, { .func_name = "plg_key_test" }}, 34 | { 0, NULL, NULL, 0, 0, { NULL }} 35 | }; 36 | 37 | /* --------------------------------------------------------------- 38 | * exported lua functions 39 | * --------------------------------------------------------------- 40 | */ 41 | 42 | struct luaF_item luaF_list[] = { 43 | { 1, "bvi_test", "Do nothing, just testing purposes", BVI_HANDLER_EXTERNAL, { .func_name = "plg_lua_test" }}, 44 | { 0, NULL, NULL, 0, { NULL }} 45 | }; 46 | 47 | 48 | /* --------------------------------------------------------------- 49 | * plugin registration info 50 | * --------------------------------------------------------------- 51 | */ 52 | 53 | plugin_t plugin_register() 54 | { 55 | plugin_t plg; 56 | 57 | plg.name = "test"; 58 | plg.author = "Anton Kochkov"; 59 | plg.license = "GPLv2"; 60 | plg.version.major = 0; 61 | plg.version.minor = 1; 62 | plg.description = "Just test plugin, for example purposes"; 63 | plg.module = NULL; 64 | plg.exports.keys = keys; 65 | plg.exports.cmds = cmds; 66 | plg.exports.luaF_list = luaF_list; 67 | return plg; 68 | } 69 | 70 | /* --------------------------------------------------------------- 71 | * plugin initialization function 72 | * --------------------------------------------------------------- 73 | */ 74 | 75 | int plugin_init(core_t *bvim_core, state_t *bvim_state, api_t *bvim_api) 76 | { 77 | plugin_error = bvim_api->error; 78 | plugin_info = bvim_api->info; 79 | plugin_debug = bvim_api->debug; 80 | core = bvim_core; 81 | state = bvim_state; 82 | api = bvim_api; 83 | return 0; 84 | } 85 | 86 | /* --------------------------------------------------------------- 87 | * exported command handlers 88 | * --------------------------------------------------------------- 89 | */ 90 | 91 | int plg_command_test(char flags, int c_argc, char** c_argv) 92 | { 93 | plugin_info(state->mode, "Command from \"%s\" plugin successfully executed!", "test"); 94 | return 0; 95 | } 96 | 97 | /* --------------------------------------------------------------- 98 | * exported key handlers 99 | * --------------------------------------------------------------- 100 | */ 101 | 102 | int plg_key_test() 103 | { 104 | plugin_info(state->mode, "Key, defined in \"%s\" plugin, pressed!", "test"); 105 | return 0; 106 | } 107 | 108 | /* --------------------------------------------------------------- 109 | * exported lua functions 110 | * --------------------------------------------------------------- 111 | */ 112 | 113 | int plg_lua_test(lua_State *L) 114 | { 115 | plugin_info(state->mode, "Lua function from \"%s\" plugin successfully executed", "test"); 116 | lua_pushstring(L, "test function"); 117 | return 1; 118 | } 119 | -------------------------------------------------------------------------------- /plugins/visualisation.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "plugins.h" 7 | #include "data.h" 8 | 9 | core_t *core; 10 | state_t *state; 11 | api_t *api; 12 | 13 | void (*plugin_error)(int, char*, ...); 14 | void (*plugin_info)(int, char*, ...); 15 | void (*plugin_debug)(int, char*, ...); 16 | 17 | /* --------------------------------------------------------------- 18 | * exported commands 19 | * --------------------------------------------------------------- 20 | */ 21 | 22 | struct command cmds[] = { 23 | { 35, "gist", "show gistogram", 1, BVI_HANDLER_EXTERNAL, { .func_name = "plg_command_gistogram" }, 4, 1}, 24 | { 0, NULL, NULL, 0, 0, { NULL }, 0, 0} 25 | }; 26 | 27 | /* --------------------------------------------------------------- 28 | * exported keys 29 | * --------------------------------------------------------------- 30 | */ 31 | 32 | 33 | struct key keys[] = { 34 | { BVI_CTRL('P'), "Ctrl-P", "", 1, BVI_HANDLER_EXTERNAL, { .func_name = "plg_key_gistogram" }}, 35 | { 0, NULL, NULL, 0, 0, { NULL }} 36 | }; 37 | 38 | /* --------------------------------------------------------------- 39 | * exported lua functions 40 | * --------------------------------------------------------------- 41 | */ 42 | 43 | struct luaF_item luaF_list[] = { 44 | { 1, "gistogram", "Open gistogram window", BVI_HANDLER_EXTERNAL, { .func_name = "plg_lua_gistogram" }}, 45 | { 0, NULL, NULL, 0, { NULL }} 46 | }; 47 | 48 | 49 | /* --------------------------------------------------------------- 50 | * plugin registration info 51 | * --------------------------------------------------------------- 52 | */ 53 | 54 | plugin_t plugin_register() 55 | { 56 | plugin_t plg; 57 | 58 | plg.name = "visualisation"; 59 | plg.author = "Anton Kochkov"; 60 | plg.license = "GPLv2"; 61 | plg.version.major = 0; 62 | plg.version.minor = 1; 63 | plg.description = "Added MathGL visualisation features"; 64 | plg.module = NULL; 65 | plg.exports.keys = keys; 66 | plg.exports.cmds = cmds; 67 | plg.exports.luaF_list = luaF_list; 68 | return plg; 69 | } 70 | 71 | /* --------------------------------------------------------------- 72 | * plugin initialization function 73 | * --------------------------------------------------------------- 74 | */ 75 | 76 | int plugin_init(core_t *bvim_core, state_t *bvim_state, api_t *bvim_api) 77 | { 78 | plugin_error = bvim_api->error; 79 | plugin_info = bvim_api->info; 80 | plugin_debug = bvim_api->debug; 81 | core = bvim_core; 82 | state = bvim_state; 83 | api = bvim_api; 84 | return 0; 85 | } 86 | 87 | /* --------------------------------------------------------------- 88 | * exported command handlers 89 | * --------------------------------------------------------------- 90 | */ 91 | 92 | int plg_command_gistogram(char flags, int c_argc, char** c_argv) 93 | { 94 | HMGL gr = mgl_create_graph_zb(600, 400); 95 | mgl_show_image(gr, "", 0); 96 | mgl_delete_graph(gr); 97 | //plugin_info(state->mode, "Command from \"%s\" plugin successfully executed!", "test"); 98 | return 0; 99 | } 100 | 101 | /* --------------------------------------------------------------- 102 | * exported key handlers 103 | * --------------------------------------------------------------- 104 | */ 105 | 106 | static int plg_key_gistogram() 107 | { 108 | //plugin_info(state->mode, "Key, defined in \"%s\" plugin, pressed!", "test"); 109 | return 0; 110 | } 111 | 112 | /* --------------------------------------------------------------- 113 | * exported lua functions 114 | * --------------------------------------------------------------- 115 | */ 116 | 117 | static int plg_lua_gistogram(lua_State *L) 118 | { 119 | //plugin_info(state->mode, "Lua function from \"%s\" plugin successfully executed", "test"); 120 | //lua_pushstring(L, "test function"); 121 | return 0; 122 | } 123 | -------------------------------------------------------------------------------- /recomp.c: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | /* You cannot use a common regexp subroutine, because \0 is a regular 23 | * character in a binary string ! 24 | */ 25 | 26 | #include "bvim.h" 27 | #include "blocks.h" 28 | #include "set.h" 29 | #include "ui.h" 30 | 31 | #include "messages.h" 32 | 33 | char *poi; 34 | int smode; 35 | int again = 0; 36 | int magic = 1; 37 | int ignore_case = 0; 38 | 39 | extern long bytepos; 40 | extern int ignore_case; 41 | 42 | /* 43 | * Compiling an ASCII sequence to a regex string 44 | */ 45 | // TODO: Add return codes/error codes 46 | int ascii_comp(smem, pattern) 47 | char *smem; 48 | char *pattern; 49 | { 50 | char *end; 51 | char *comp; 52 | char cc, cc1; 53 | char *counter; 54 | int count; 55 | int bracket, dot; 56 | 57 | comp = smem; 58 | poi = pattern; 59 | while (*poi != END) { 60 | bracket = FALSE; 61 | if (magic) { 62 | if (*poi == '[') 63 | bracket = TRUE; 64 | } else { 65 | if (*poi == '\\' && *(poi + 1) == '[') { 66 | bracket = TRUE; 67 | poi++; 68 | } 69 | } 70 | if (bracket) { 71 | if (!(end = strchr(poi, ']'))) { 72 | //bvim_error(core, buf, "Missing ]"); 73 | return 1; 74 | } 75 | poi++; 76 | if (*poi == ']' || (*poi == '^' && *(poi + 1) == ']')) { 77 | //bvim_error(core, buf, BVI_ERROR_EMPTYCLASS); 78 | return 1; 79 | } 80 | if (magic) { 81 | if (*(end + 1) == '*') 82 | *comp++ = STAR; 83 | else 84 | *comp++ = ONE; 85 | } else { 86 | if (*(end + 1) == '\\' && *(end + 2) == '*') 87 | *comp++ = STAR; 88 | else 89 | *comp++ = ONE; 90 | } 91 | count = 0; 92 | counter = comp; 93 | comp++; 94 | if (*poi != '^') { 95 | *comp++ = '\0'; 96 | count++; 97 | } 98 | 99 | while (end > poi) { 100 | if (*poi == '-') { 101 | if (ignore_case) { 102 | cc = toupper(*(poi - 1)); 103 | cc1 = toupper(*(poi + 1)); 104 | } else { 105 | cc = *(poi - 1); 106 | cc1 = *(poi + 1); 107 | } 108 | while (cc <= cc1) { 109 | *comp++ = cc++; 110 | count++; 111 | } 112 | poi++; 113 | poi++; 114 | } else { 115 | count++; 116 | if (ignore_case) 117 | *comp++ = toupper(*poi++); 118 | else 119 | *comp++ = *poi++; 120 | } 121 | } 122 | poi++; 123 | *counter = count; 124 | } else { 125 | dot = FALSE; 126 | if (magic) { 127 | if (*poi == '.') 128 | dot = TRUE; 129 | } else { 130 | if (*poi == '\\' && *(poi + 1) == '.') { 131 | dot = TRUE; 132 | poi++; 133 | } 134 | } 135 | 136 | if (*poi == '\\') { 137 | switch (*(poi + 1)) { 138 | case 'n': 139 | *++poi = '\n'; 140 | break; 141 | case 'r': 142 | *++poi = '\r'; 143 | break; 144 | case 't': 145 | *++poi = '\t'; 146 | break; 147 | case '0': 148 | *++poi = '\0'; 149 | break; 150 | default: 151 | ++poi; 152 | } 153 | } 154 | if (magic) 155 | if (*(poi + 1) == '*') 156 | *comp++ = STAR; 157 | else 158 | *comp++ = ONE; 159 | else if (*(poi + 1) == '\\' && *(poi + 2) == '*') 160 | *comp++ = STAR; 161 | else 162 | *comp++ = ONE; 163 | 164 | if (dot) { 165 | *comp++ = 0; 166 | poi++; 167 | } else { 168 | *comp++ = 1; 169 | if (ignore_case) 170 | *comp++ = toupper(*poi++); 171 | else 172 | *comp++ = *poi++; 173 | } 174 | } 175 | if (magic) { 176 | if (*poi == '*') 177 | poi++; 178 | } else { 179 | if (*poi == '\\' && *(poi + 1) == '*') { 180 | poi++; 181 | poi++; 182 | } 183 | } 184 | } 185 | *comp = END; 186 | smode = ASCII; 187 | return 0; 188 | } 189 | 190 | /* 191 | * Compiling a hex expression to a regex string 192 | */ 193 | // TODO: Add return codes/error codes 194 | int hex_comp(smem, pattern) 195 | char *smem; 196 | char *pattern; 197 | { 198 | char *end; 199 | char *comp; 200 | int cc, ccm; 201 | char *counter; 202 | int count, nr; 203 | 204 | comp = smem; 205 | poi = pattern; 206 | while (*poi != END) { 207 | while (*poi == ' ' || *poi == '\t') 208 | poi++; 209 | if (*poi == '[') { 210 | if (!(end = strchr(poi, ']'))) { 211 | //bvim_error(core, buf, "Missing ]"); 212 | return 1; 213 | } 214 | poi++; 215 | while (*poi == ' ' || *poi == '\t') 216 | poi++; 217 | 218 | if (*poi == ']' || (*poi == '^' && *(poi + 1) == ']')) { 219 | //bvim_error(core, buf, BVI_ERROR_EMPTYCLASS); 220 | return 1; 221 | } 222 | if (*(end + 1) == '*') 223 | *comp++ = STAR; 224 | else 225 | *comp++ = ONE; 226 | count = 1; 227 | counter = comp; 228 | comp++; 229 | if (*poi == '^') 230 | *comp++ = *poi++; 231 | else 232 | *comp++ = '\0'; 233 | while (end > poi) { 234 | if (*poi == ' ' || *poi == '\t') 235 | poi++; 236 | else if (*poi == '-') { 237 | cc = *(comp - 1); 238 | poi++; 239 | if ((ccm = hexchar()) < 0) 240 | return 1; 241 | while (cc <= ccm) { 242 | *comp++ = cc++; 243 | count++; 244 | } 245 | poi++; 246 | poi++; 247 | } else { 248 | if ((nr = hexchar()) < 0) 249 | return 1; 250 | count++; 251 | *comp++ = nr; 252 | } 253 | } 254 | poi++; 255 | *counter = count; 256 | if (*poi == '*') 257 | poi++; 258 | } else if (*poi == '"') { 259 | poi++; 260 | if (!(end = strchr(poi, '"'))) { 261 | /* 262 | bvim_error(core, buf, "Missing '\"'"); 263 | return 1; 264 | */ 265 | end = poi + strlen(poi); 266 | } 267 | while (end > poi) { 268 | *comp++ = 1; 269 | *comp++ = 1; 270 | if (ignore_case) 271 | *comp++ = toupper(*poi++); 272 | else 273 | *comp++ = *poi++; 274 | } 275 | poi++; 276 | } else { 277 | if (*poi == '.') { 278 | if (*(poi + 1) == '*') { 279 | *comp++ = STAR; 280 | poi++; 281 | } else 282 | *comp++ = ONE; 283 | *comp++ = 0; 284 | poi++; 285 | } else { 286 | if ((nr = hexchar()) < 0) 287 | return 1; 288 | if (*poi == '*') { 289 | poi++; 290 | *comp++ = STAR; 291 | } else 292 | *comp++ = ONE; 293 | *comp++ = 1; 294 | *comp++ = nr; 295 | } 296 | } 297 | } 298 | *comp = END; 299 | smode = HEX; 300 | return 0; 301 | } 302 | 303 | int hexchar() 304 | { 305 | unsigned int nr; 306 | char tmpbuf[3]; 307 | 308 | if (isxdigit(*poi)) { 309 | tmpbuf[0] = *poi++; 310 | tmpbuf[1] = '\0'; 311 | if (isxdigit(*poi)) 312 | tmpbuf[1] = *poi++; 313 | tmpbuf[2] = '\0'; 314 | sscanf(tmpbuf, "%2x", &nr); 315 | while (*poi == ' ' || *poi == '\t') 316 | poi++; 317 | return nr; 318 | } else { 319 | //bvim_error(core, buf, "Bad hex character@in expression"); 320 | return -1; 321 | } 322 | } 323 | -------------------------------------------------------------------------------- /scripts/checksum.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2011 by Anton Kochkov 3 | 4 | This file is part of Bvim. 5 | 6 | Bvim is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Bvim is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with Bvim. If not, see . 18 | --]] 19 | 20 | 21 | -- Show all CRC* sums in tools window 22 | function crcsums(block_start, block_end) 23 | bvim.block_select(14, block_start, block_end, 0) 24 | bvim.tools_window(4) 25 | bvim.print_tools_window("Block #14 [" .. block_start .. "," .. block_end .. "]", 1) 26 | bvim.print_tools_window("------------------------------------------------", 2) 27 | bvim.print_tools_window("CRC-8 : [ " .. "" .. " ]", 3) 28 | bvim.print_tools_window("CRC-16 : [ " .. string.gsub(string.format("%04x", hash.crc16(14)), "(..)(..)", "%1 %2") .. " ]", 4) 29 | bvim.print_tools_window("CRC-32 : [ " .. string.gsub(string.format("%08x", hash.crc32(14)), "(..)(..)(..)(..)", "%1 %2 %3 %4") .. " ]", 5) 30 | end 31 | 32 | -- Show all MD* sums in tools window 33 | function mdsums(block_start, block_end) 34 | bvim.block_select(14, block_start, block_end, 0) 35 | bvim.tools_window(3) 36 | bvim.print_tools_window("Block #14 [" .. block_start .. "," .. block_end .. "]", 1) 37 | bvim.print_tools_window("------------------------------------------------", 2) 38 | bvim.print_tools_window("MD4 : " .. hash.md4(14), 3) 39 | bvim.print_tools_window("MD5 : " .. hash.md5(14), 4) 40 | end 41 | 42 | -- Show all SHA* sums in tools window 43 | function shasums(block_start, block_end) 44 | bvim.block_select(14, block_start, block_end, 0) 45 | bvim.tools_window(4) 46 | bvim.print_tools_window("Block #14 [" .. block_start .. "," .. block_end .. "]", 1) 47 | bvim.print_tools_window("------------------------------------------------", 2) 48 | bvim.print_tools_window("SHA1 : " .. hash.sha1(14), 3) 49 | bvim.print_tools_window("SHA256 : " .. hash.sha256(14), 4) 50 | bvim.print_tools_window("SHA512 : " .. hash.sha512(14), 5) 51 | end 52 | -------------------------------------------------------------------------------- /scripts/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2011 by Anton Kochkov 3 | 4 | This file is part of Bvim. 5 | 6 | Bvim is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Bvim is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with Bvim. If not, see . 18 | --]] 19 | 20 | local constants_store = { 21 | VISUAL_SELECTION_ID = BVI_VISUAL_SELECTION_ID, 22 | MODE_CMD = BVI_MODE_CMD, 23 | MODE_EDIT = BVI_MODE_EDIT, 24 | MODE_VISUAL = BVI_MODE_VISUAL, 25 | MODE_REPL = BVI_MODE_REPL, 26 | } 27 | 28 | local const = newproxy(true) 29 | 30 | getmetatable(const).__index = function(t,k) return constants_store[k] end 31 | getmetatable(const).__newindex = function() error 'attempted to overwrite a constant!' end 32 | getmetatable(const).__metatable = false 33 | 34 | -- Using constants as const.MODE_CMD , for example 35 | -------------------------------------------------------------------------------- /scripts/search.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2011 by Anton Kochkov 3 | 4 | This file is part of Bvim. 5 | 6 | Bvim is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Bvim is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with Bvim. If not, see . 18 | --]] 19 | 20 | function search(bytes) 21 | bvim.search_bytes(bytes) 22 | end 23 | -------------------------------------------------------------------------------- /scripts/statistics.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2011 by Anton Kochkov 3 | 4 | This file is part of Bvim. 5 | 6 | Bvim is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Bvim is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with Bvim. If not, see . 18 | --]] 19 | 20 | -- Show all CRC* sums in tools window 21 | function stats(block_start, block_end) 22 | bvim.block_select(155, block_start, block_end, 0) 23 | bvim.tools_window(4) 24 | bvim.print_tools_window("Block #155 [" .. block_start .. "," .. block_end .. "]", 1) 25 | bvim.print_tools_window("------------------------------------------------", 2) 26 | bvim.print_tools_window("Entropy: " .. stat.entropy(155), 3) 27 | end 28 | 29 | 30 | -------------------------------------------------------------------------------- /scripts/test.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2011 by Anton Kochkov 3 | 4 | This file is part of Bvim. 5 | 6 | Bvim is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Bvim is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with Bvim. If not, see . 18 | --]] 19 | 20 | bvim.exec("set color(data,999,000,000)") 21 | bvim.display_error("here is an example error message!") 22 | bvim.msg_window("please, press any key to exit window") 23 | bvim.scrolldown(5) 24 | bvim.print(8, 15, 4, "here is lua scripting test") 25 | bvim.exec("block add 1 12 233 4") 26 | bvim.exec("block add 2 357 683 2") 27 | bvim.exec("block add 3 749 919 3") 28 | bvim.block_xor(1, 15) 29 | bvim.block_and(2, 14) 30 | bvim.block_or(3, 255) 31 | bvim.block_lshift(2, 2) 32 | bvim.block_and(3, 26) 33 | bvim.block_rrotate(3, 3) 34 | bvim.exec("run checksum") 35 | shasums(15, 200) 36 | 37 | -------------------------------------------------------------------------------- /scripts/unittest.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2011 by Anton Kochkov 3 | 4 | This file is part of Bvim. 5 | 6 | Bvim is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Bvim is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with Bvim. If not, see . 18 | --]] 19 | 20 | tests_passed = 0 21 | tests_failed = 0 22 | 23 | if hash.md4("1234567890") ~= "85b196c3e39457d91cab9c905f9a11c0" then 24 | bvim.msg_window("MD4 hash is WRONG!") 25 | bvim.tools_window(2) 26 | bvim.print_tools_window("BVI MD4 hash: [ " .. hash.md4("1234567890") .. " ]", 1) 27 | bvim.print_tools_window("ORIG MD4 hash: [ 85b196c3e39457d91cab9c905f9a11c0 ]", 2) 28 | tests_failed = tests_failed + 1 29 | else 30 | tests_passed = tests_passed + 1 31 | end 32 | if hash.md5("1234567890") ~= "e807f1fcf82d132f9bb018ca6738a19f" then 33 | bvim.msg_window("MD5 hash is WRONG!") 34 | bvim.tools_window(2) 35 | bvim.print_tools_window("BVI MD5 hash: [ " .. hash.md5("1234567890") .. " ]", 1) 36 | bvim.print_tools_window("ORIG MD5 hash: [ e807f1fcf82d132f9bb018ca6738a19f ]", 2) 37 | tests_failed = tests_failed + 1 38 | else 39 | tests_passed = tests_passed + 1 40 | end 41 | if hash.sha1("1234567890") ~= "01b307acba4f54f55aafc33bb06bbbf6ca803e9a" then 42 | bvim.msg_window("SHA1 hash is WRONG!") 43 | bvim.tools_window(2) 44 | bvim.print_tools_window("BVI SHA1 hash: [ " .. hash.sha1("1234567890") .. " ]", 1) 45 | bvim.print_tools_window("ORIG SHA1 hash: [ 01b307acba4f54f55aafc33bb06bbbf6ca803e9a ]", 2) 46 | tests_failed = tests_failed + 1 47 | else 48 | tests_passed = tests_passed + 1 49 | end 50 | if hash.sha256("1234567890") ~= "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646" then 51 | bvim.msg_window("SHA256 hash is WRONG!") 52 | bvim.tools_window(2) 53 | bvim.print_tools_window("BVI SHA256 hash: [ " .. hash.sha256("1234567890") .. " ]", 1) 54 | bvim.print_tools_window("ORIG SHA256 hash: [ c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646 ]", 2) 55 | tests_failed = tests_failed + 1 56 | else 57 | tests_passed = tests_passed + 1 58 | end 59 | if hash.sha512("1234567890") ~= "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9" then 60 | bvim.msg_window("SHA512 hash is WRONG!") 61 | bvim.tools_window(2) 62 | bvim.print_tools_window("BVI SHA512 hash: [ " .. hash.sha512("1234567890") .. " ]", 1) 63 | bvim.print_tools_window("ORIG SHA512 hash: [ 12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9 ]", 2) 64 | tests_failed = tests_failed + 1 65 | else 66 | tests_passed = tests_passed + 1 67 | end 68 | if hash.ripemd160("1234567890") ~= "9d752daa3fb4df29837088e1e5a1acf74932e074" then 69 | bvim.msg_window("RIPEMD160 hash is WRONG!") 70 | bvim.tools_window(2) 71 | bvim.print_tools_window("BVI RIPEMD160 hash: [ " .. hash.ripemd160("1234567890") .. " ]", 1) 72 | bvim.print_tools_window("ORIG RIPEMD160 hash: [ 9d752daa3fb4df29837088e1e5a1acf74932e074 ]", 2) 73 | tests_failed = tests_failed + 1 74 | else 75 | tests_passed = tests_passed + 1 76 | end 77 | 78 | bvim.msg_window("PASSED: " .. tests_passed .. " FAILED: " .. tests_failed) 79 | -------------------------------------------------------------------------------- /search.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "bvim.h" 5 | #include "search.h" 6 | 7 | extern core_t core; 8 | extern state_t state; 9 | 10 | int mlist_add(mlist ml, match_t item) 11 | { 12 | mlist t = NULL; 13 | t = (mlist)malloc(sizeof(*t)); 14 | if (t != NULL) { 15 | t->m = item; 16 | if (ml != NULL) { 17 | t->next = ml->next; 18 | ml->next = t; 19 | } else { 20 | ml = t; 21 | ml->next = NULL; 22 | } 23 | } else { 24 | return -1; 25 | } 26 | return 0; 27 | } 28 | 29 | void mlist_free(mlist ml) 30 | { 31 | mlist t = ml; 32 | while (t != NULL) { 33 | free(t); 34 | t = t->next; 35 | } 36 | } 37 | 38 | // Bitup fuzzy search algorithm 39 | // pattern must be < 32 bytes 40 | // saving results in ml parameter 41 | // k == errors count 42 | long bitap_fuzzy_bitwise_search_binary(mlist ml, const char *buf, long buf_length, const char *pattern, long pat_size, int k) 43 | { 44 | match_t *result = NULL; 45 | long m = pat_size; 46 | unsigned long *R; 47 | unsigned long pattern_mask[CHAR_MAX+1]; 48 | long i, d; 49 | long match_count = 0; 50 | 51 | result = (match_t *)malloc(sizeof(*result)); 52 | 53 | if (pattern[0] == '\0') { 54 | return -1; // Error: wrong pattern 55 | } 56 | if (m > 31) { 57 | return -1 ; // pattern too long! 58 | } 59 | 60 | /* Initialize the bit array R */ 61 | R = malloc((k + 1) * sizeof *R); 62 | for (i = 0; i <= k; ++i) 63 | R[i] = ~1; 64 | 65 | /* Initialize the pattern bitmasks */ 66 | for (i = 0; i <= CHAR_MAX; ++i) 67 | pattern_mask[i] = ~0; 68 | for (i = 0; i < m; ++i) 69 | pattern_mask[pattern[i]] &= ~(1UL << i); 70 | 71 | for (i = 0; i < buf_length; ++i) { 72 | /* Update the bit arrays */ 73 | unsigned long old_Rd1 = R[0]; 74 | 75 | R[0] |= pattern_mask[buf[i]]; 76 | R[0] <<= 1; 77 | 78 | for (d=1; d <= k; ++d) { 79 | unsigned long tmp = R[d]; 80 | /* Substitution is all we care about */ 81 | R[d] = (old_Rd1 & (R[d] | pattern_mask[buf[i]])) << 1; 82 | old_Rd1 = tmp; 83 | } 84 | 85 | if (0 == (R[k] & (1UL << m))) { 86 | result->ptr = (buf + i - m) + 1; 87 | result->start = i - m + 1; 88 | result->length = m; 89 | result->str = (char*)malloc(result->length); 90 | memcpy(result->str, result->ptr, result->length); 91 | mlist_add(ml, *result); 92 | match_count++; 93 | } 94 | } 95 | 96 | free(R); 97 | return match_count; 98 | } 99 | 100 | // TODO: Add distance propose 101 | struct found fuzzy_search(core_t *core, buf_t *buf, long input_size, void *pattern, long pattern_size, int algo, int distance) 102 | { 103 | struct found fnd; 104 | fnd.cnt = 0; 105 | fnd.ml = NULL; 106 | 107 | if (algo == FUZZY_BITAP_HAMMINGTON_DISTANCE) { 108 | fnd.cnt = bitap_fuzzy_bitwise_search_binary(fnd.ml, buf->mem, input_size, pattern, pattern_size, distance); 109 | } else if (algo == FUZZY_BITAP_LEVENSHTEIN_DISTANCE) { 110 | bvim_error(core, buf, "Levenshtein distance: not yet supported!"); 111 | } else { 112 | bvim_error(core, buf, "Wrong fuzzy search algorithm!"); 113 | } 114 | return fnd; 115 | } 116 | -------------------------------------------------------------------------------- /signature.c: -------------------------------------------------------------------------------- 1 | /* Bvim - BVi IMproved, binary analysis framework 2 | * 3 | * Copyright 1996-2004 by Gerhard Buergmann 4 | * Copyright 2011 by Anton Kochkov 5 | * 6 | * This file is part of Bvim. 7 | * 8 | * Bvim is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Bvim is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Bvim. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include "data.h" 25 | #include "signature.h" 26 | 27 | extern core_t core; 28 | extern state_t state; 29 | 30 | // TODO: Implement signatures pack and signatures as linked lists 31 | // TODO: Add lua/plugin interface for access to signatures base 32 | // TODO: Link signatures and C-structs for autosearch and 33 | // extracting data 34 | 35 | /* --------------------------------------------------------------- 36 | * Internal functions 37 | * --------------------------------------------------------------- 38 | */ 39 | 40 | /* Load column from "magic" file */ 41 | static struct magic* extract_magic_record(char* line) 42 | { 43 | int line_size = 0; 44 | struct magic *mg; 45 | 46 | mg = (struct magic*)malloc(sizeof(mg)); 47 | line_size = strlen(line); 48 | 49 | return mg; 50 | } 51 | 52 | /* Load named signatures pack */ 53 | // TODO: Load from file 54 | // TODO: Load from SQLite 55 | static int signatures_load(char* path) 56 | { 57 | return 0; 58 | } 59 | 60 | /* Unload named signatures pack */ 61 | static int signatures_unload(char *name) 62 | { 63 | return 0; 64 | } 65 | 66 | // TODO: Add fuzzy search support 67 | /* Return offset from block start, or offsets list */ 68 | offset_list signature_search(signature_t sg, unsigned long block_id) 69 | { 70 | return 0; 71 | } 72 | --------------------------------------------------------------------------------