00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "analy.h"
00022 #include "htdebug.h"
00023 #include "htinfo.h"
00024 #include "snprintf.h"
00025 #include "out_txt.h"
00026
00027 #include <string.h>
00028 #include <stdlib.h>
00029
00030
00031 #include "x86dis.h"
00032
00033 void AnalyserTxtOutput::init(Analyser *analy, ht_stream *s)
00034 {
00035 AnalyserOutput::init(analy);
00036 stream = s;
00037 dis_style = DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE+X86DIS_STYLE_OPTIMIZE_ADDR;
00038 }
00039
00040 void AnalyserTxtOutput::done()
00041 {
00042 AnalyserOutput::done();
00043 }
00044
00045 void AnalyserTxtOutput::beginAddr()
00046 {
00047 AnalyserOutput::beginAddr();
00048 }
00049
00050 void AnalyserTxtOutput::beginLine()
00051 {
00052 AnalyserOutput::beginLine();
00053 char temp[20];
00054 if (line==0) {
00055 addr->stringify(temp, sizeof temp, ADDRESS_STRING_FORMAT_LEADING_WHITESPACE);
00056 char temp2[20];
00057 last = addr->stringify(temp2, sizeof temp2, ADDRESS_STRING_FORMAT_COMPACT);
00058 } else {
00059 int s = addr->stringSize();
00060 memset(temp, ' ', s);
00061 memset(&temp[s-last], '.', last);
00062 temp[s] = 0;
00063 }
00064 write(temp);
00065
00066 if (analy->explored->contains(addr)) {
00067 write(" ! ");
00068 } else {
00069 write(" ");
00070 }
00071 }
00072
00073 ht_stream *AnalyserTxtOutput::getGenerateStream()
00074 {
00075 return stream;
00076 }
00077
00078 int AnalyserTxtOutput::elementLength(const char *s)
00079 {
00080 return strlen(s);
00081 }
00082
00083 void AnalyserTxtOutput::endAddr()
00084 {
00085 AnalyserOutput::endAddr();
00086 }
00087
00088 void AnalyserTxtOutput::endLine()
00089 {
00090 write("\n");
00091 AnalyserOutput::endLine();
00092 }
00093
00094 void AnalyserTxtOutput::putElement(int element_type, const char *element)
00095 {
00096 switch (element_type) {
00097 case ELEMENT_TYPE_HIGHLIGHT_DATA_CODE:
00098 write(" ");
00099 write(element);
00100 break;
00101 default:
00102 write(element);
00103 break;
00104 }
00105 }
00106
00107 char *AnalyserTxtOutput::link(char *s, Address *Addr)
00108 {
00109 global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS | ADDRESS_STRING_FORMAT_ADD_H;
00110 ht_snprintf(tmpbuf, sizeof tmpbuf, "%s<%y>", s, Addr);
00111 return tmpbuf;
00112 }
00113
00114 char *AnalyserTxtOutput::externalLink(char *s, int type1, int type2, int type3, int type4, void *special)
00115 {
00116 strcpy(tmpbuf, "test");
00117 return tmpbuf;
00118 }
00119
00120 void AnalyserTxtOutput::footer()
00121 {
00122 }
00123
00124 void AnalyserTxtOutput::header()
00125 {
00126 ht_snprintf(tmpbuf, sizeof tmpbuf, "Analysis of %s\ngenerated by "ht_name" version "ht_version" ("ht_url")\n\n", analy->getName());
00127 stream->write(tmpbuf, strlen(tmpbuf));
00128 }
00129