1 /***********************************(GPL)******************************** 2 * wxHexEditor is a hex edit tool for editing massive files in Linux * 3 * Copyright (C) 2010 Erdem U. Altinyurt * 4 * * 5 * This program is free software; you can redistribute it and/or * 6 * modify it under the terms of the GNU General Public License * 7 * as published by the Free Software Foundation; either version 2 * 8 * of the License. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program; * 17 * if not, write to the Free Software Foundation, Inc., * 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 19 * * 20 * home : www.wxhexeditor.org * 21 * email : spamjunkeater@gmail.com * 22 *************************************************************************/ 23 24 25 #ifndef __HexEditorDialogs__ 26 #define __HexEditorDialogs__ 27 28 #include "HexEditor.h" 29 #include "FAL.h" 30 #include "HexEditorCtrl/HexEditorCtrl.h" 31 #include "HexEditorGui.h" 32 #include <vector> 33 #ifdef WX_GCH 34 #include <wx_pch.h> 35 #else 36 #include <wx/wx.h> 37 #endif 38 39 bool HexVerifyAndPrepare(wxString& hexval, wxString Value_Name, wxWindow* parent=NULL); 40 41 //ComboBox Filler from stored Registry values 42 void ComboBoxFill( wxString SearchFormat, wxComboBox* CurrentBox, bool AddString); 43 44 class GotoDialog : public GotoDialogGui{ 45 public: 46 GotoDialog( wxWindow* parent, uint64_t& offset, uint64_t cursor_offset, uint64_t filesize, unsigned BlockSize ); 47 void OnChar( wxKeyEvent& event ); 48 void OnInput( wxCommandEvent& event ); 49 void OnGo( wxCommandEvent& event ); 50 void OnConvert( wxCommandEvent& event ); 51 void EventHandler( wxCommandEvent& event ); 52 wxString Filter( wxString text ); 53 void OnPreviousSector( wxCommandEvent& event ); 54 void OnNextSector( wxCommandEvent& event ); 55 56 protected: 57 enum {OPT_OFFSET_MODE=0x1,OPT_DEC_INPUT=0x2,OPT_BRANCH_NORMAL=0x4,OPT_BRANCH_END=0x8}; 58 uint64_t *offset; 59 uint64_t cursor_offset; 60 uint64_t filesize; 61 unsigned BlockSize; 62 bool is_olddec; 63 class HexEditor* parent; 64 wxArrayString hex_letters;//=wxT("abcdefABCDEFxX"); 65 wxArrayString dec_letters;//=wxT("1234567890abcdefABCDEFxX"); 66 }; 67 68 class FindDialog : public FindDialogGui{ 69 public: 70 FindDialog( wxWindow* parent, FAL *find_file, wxString title=_("Find") ); 71 bool OnFind( bool intenal=false ); 72 void OnFindPrev( wxCommandEvent& event ); 73 void OnFindAll( bool internal=false ); 74 void OnChar( wxKeyEvent& event ); 75 virtual void EventHandler( wxCommandEvent& event ); 76 bool OnFindEvents( wxCommandEvent& event ); 77 char UTF8SpeedHackChrs[2]; 78 79 protected: 80 enum search_options{ SEARCH_HEX=0x1, SEARCH_TEXT=0x2, SEARCH_UTF8=0x4, SEARCH_UTF16=0x8, 81 SEARCH_MATCHCASE=0x10, SEARCH_BACKWARDS=0x20, SEARCH_WRAPAROUND=0x40, SEARCH_FINDALL=0x80} searchtype; 82 bool FindBinaryUnitTest( void ); 83 uint64_t FindBinary( wxMemoryBuffer target, uint64_t start_from, unsigned oper=SEARCH_HEX ); 84 uint64_t FindBinaryForward( wxMemoryBuffer target, uint64_t start_from, uint64_t end_to, unsigned oper, 85 wxProgressDialog* progress_gauge, 86 wxString& gauge_msg, 87 uint64_t& totalread); 88 uint64_t FindBinaryBackward( wxMemoryBuffer target, uint64_t start_from, uint64_t end_to, unsigned oper, 89 wxProgressDialog* progress_gauge, 90 wxString& gauge_msg, 91 uint64_t& totalread); 92 93 uint64_t FindText( wxString target, uint64_t start_from, unsigned oper=SEARCH_TEXT); 94 int SearchAtBuffer( char *bfr, int bfr_size, char* search, int search_size, unsigned oper, std::vector<int> *ret_ptr=NULL ); 95 int MultiThreadMultiSearchAtBuffer( char *bfr, int bfr_size, char* search, int search_size, unsigned oper, std::vector<int> *ret_ptr ); 96 bool SearchAtBufferUnitTest(); 97 void FindSomeBytes( void ); 98 class HexEditor* parent; 99 FAL *findfile; 100 void PrepareComboBox( bool AddString ); 101 bool SkipRAM( uint64_t& current_offset, unsigned search_size, unsigned& search_step, bool backward=false ); 102 }; 103 104 class ReplaceDialog : public FindDialog{ 105 public: 106 ReplaceDialog( wxWindow* parent, FAL *find_file, wxString title=_("Find & Replace") ); 107 void EventHandler( wxCommandEvent& event ); 108 int OnReplace( bool internal = false ); 109 void OnReplaceAll( void ); 110 void PrepareComboBox( bool AddString ); 111 }; 112 113 class CopyAsDialog : public CopyAsDialogGui{ 114 public: 115 CopyAsDialog( wxWindow* parent, FAL* copy_file, Select* select, ArrayOfTAG* MainTagArray); 116 private: 117 class HexEditor* parent; 118 class Select* select; 119 FAL * copy_file; 120 ArrayOfTAG* MainTagArray; 121 void EventHandler( wxCommandEvent& event ); 122 void Copy( void ); 123 void PrepareOptions( int SelectedFunction ); 124 void PrepareFullText( wxString& , wxMemoryBuffer& ); 125 void PrepareFullTextWithTAGs( wxString& , wxMemoryBuffer& , wxString startup, wxString ending, wxString blank); 126 wxString GetDigitFormat( void ); 127 }; 128 129 class CompareDialog : public CompareDialogGui{ 130 public: 131 //CompareDialog( wxWindow* parent ); 132 CompareDialog( wxWindow* parent, wxString file1=wxEmptyString, wxString file2=wxEmptyString ); 133 ~CompareDialog(); 134 135 private: 136 enum{OPT_CMP_SEARCH_DIFF=0x01,OPT_CMP_STOP_AFTER=0x02, OPT_CMP_MERGE_SECTION=0x04, OPT_CMP_SAVE=0x8, OPT_CMP_CONNECT=0x10}; 137 class HexEditorFrame* parent; 138 bool Compare( wxFileName f1, wxFileName f2, bool SearchForDiff, int StopAfterNMatch, wxFileName fsave); 139 void EventHandler( wxCommandEvent& event ); 140 void EventHandler2( wxDropFilesEvent& event ); 141 void OnFileChange( wxFileDirPickerEvent& event ); 142 }; 143 144 class ChecksumDialog : public ChecksumDialogGui{ 145 public: 146 ChecksumDialog( wxWindow* parent ); 147 ChecksumDialog( wxWindow* parent, FAL *find_file ); 148 private: 149 class HexEditorFrame* parent; 150 wxString CalculateChecksum( FAL& fl, int options ); 151 void EventHandler( wxCommandEvent& event ); 152 void OnFileChange( wxFileDirPickerEvent& event ); 153 }; 154 155 class XORViewDialog : public XORViewDialogGui{ 156 public: 157 XORViewDialog( wxWindow* parent, wxMemoryBuffer *XORKey ); 158 void EventHandler( wxCommandEvent& event ); 159 private: 160 wxMemoryBuffer *XORKey; 161 }; 162 163 class PreferencesDialog : public PreferencesDialogGui{ 164 public: 165 PreferencesDialog( wxWindow* parent ); 166 void EventHandler( wxCommandEvent& event ); 167 void SpinEventHandler( wxSpinEvent& event ); 168 void GetInstalledLanguages(wxArrayString & names, wxArrayLong & identifiers); 169 void OnSave(wxCommandEvent& event); 170 void OnResetColours(wxCommandEvent& event); 171 void SaveRegistry( void ); 172 173 wxArrayString LangNames; 174 wxArrayLong LangIds; 175 176 wxArrayString ExperimentalEncodingsList; 177 wxArrayString AvailableEncodings; 178 }; 179 180 class DeviceBackupDialog : public DeviceBackupDialogGui{ 181 public: 182 DeviceBackupDialog( wxWindow* parent ); 183 void OnBackup( wxCommandEvent& event ); 184 }; 185 186 class DeviceRestoreDialog : public DeviceRestoreDialogGui{ 187 public: 188 DeviceRestoreDialog( wxWindow* parent ); 189 void OnRestore( wxCommandEvent& event ); 190 }; 191 192 class DeviceEraseDialog : public DeviceEraseDialogGui{ 193 public: 194 DeviceEraseDialog( wxWindow* parent ); 195 void OnErase( wxCommandEvent& event ); 196 }; 197 198 class OSXMessageDialog : public OSXMessageDialogGui{ 199 public: 200 OSXMessageDialog( wxWindow* parent, wxString message, wxString Caption ); 201 }; 202 203 void OSXwxMessageBox( wxString message, wxString Caption, int x, wxWindow* parent ); 204 205 #endif //__HexEditorDialogs__ 206