├── LICENSE ├── README ├── fileDissect.sln ├── fileDissect ├── fileDissect.h ├── fileDissect.idc ├── fileDissect.vcproj ├── fileDissect.vcxproj ├── fileDissect.vcxproj.filters ├── fileDissectApp.cpp ├── fileDissectApp.h ├── fileDissectDnD.cpp ├── fileDissectDnD.h ├── fileDissectFmts.cpp ├── fileDissectFmts.h ├── fileDissectFrame.cpp ├── fileDissectFrame.h ├── fileDissectGUI.h ├── fileDissectPlugin.h ├── fileDissectTree.cpp ├── fileDissectTree.h ├── makefile └── plugins │ ├── cbff │ ├── cbff.cpp │ ├── cbff.h │ ├── cbff.vcproj │ ├── cbff.vcxproj │ ├── cbff.vcxproj.filters │ ├── cbffStream.cpp │ ├── cbffStream.h │ ├── cbffStreamPlugin.h │ ├── cbffStreamPlugins.cpp │ ├── cbffStreamPlugins.h │ ├── cbff_defs.h │ ├── makefile │ └── plugins │ │ ├── excel │ │ ├── Workbook.cpp │ │ ├── Workbook.h │ │ ├── WorkbookDefs.h │ │ ├── auto-gen │ │ │ ├── gen_tmpls.sh │ │ │ ├── xls97-chart-recs.txt │ │ │ └── xls97-recs.txt │ │ ├── excel.vcxproj │ │ ├── excel.vcxproj.filters │ │ └── makefile │ │ ├── makefile │ │ └── summInfo │ │ ├── makefile │ │ ├── summInfo.cpp │ │ ├── summInfo.h │ │ ├── summinfo.vcproj │ │ ├── summinfo.vcxproj │ │ └── summinfo.vcxproj.filters │ ├── makefile │ └── pdf │ ├── makefile │ ├── pdf.cpp │ ├── pdf.h │ ├── pdf.vcxproj │ ├── pdf.vcxproj.filters │ ├── pdfObjects.cpp │ ├── pdfObjects.h │ ├── pdfPred.cpp │ ├── pdfPred.h │ └── pdf_defs.h ├── libfileDissect ├── fileDissectItemData.cpp ├── fileDissectItemData.h ├── fileDissectSel.cpp ├── fileDissectSel.h ├── libfileDissect.vcxproj ├── libfileDissect.vcxproj.filters ├── makefile └── wxFileMap │ ├── wxFileMap.cpp │ └── wxFileMap.h ├── makefile ├── wxHexView ├── wxHexView.cpp └── wxHexView.h └── wxPluginLoader └── wxPluginLoader.h /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2007-2010, VeriSign iDefense Labs 2 | Copyright (C) 2011-2012, Joshua J. Drake 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | * Neither the name of VeriSign iDefense Labs nor the names of its 18 | contributors may be used to endorse or promote products derived 19 | from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | File Dissect is a cross-platform framework and UI for analyzing 2 | various file formats. It is based on wxWidgets since it provides a 3 | native feel regardless of base OS. It has been designed with a tiered 4 | plug-in architecture to facilitate the quick and easy addition of new 5 | dissectors or sub-dissectors. 6 | 7 | It has been contructed using a custom wxHexView widget and 8 | automatically associates items within a wxTreeView with positions 9 | within the wxHexView. As such, it is possible to select all associated 10 | bytes in the wxHexView by clicking a node in the wxTreeView. 11 | 12 | It was originally developed during jduck's tenure at VeriSign's 13 | iDefense Labs from 2007 til 2009. It was subsequently released under 14 | a BSD License, the license which it holds today. 15 | -------------------------------------------------------------------------------- /fileDissect.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fd plugins", "fd plugins", "{1DBB020C-046B-41D1-A017-05C1D66BF372}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cbff plugins", "cbff plugins", "{B0569127-79DA-40B7-BC4D-605E17146675}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fileDissect", "fileDissect\fileDissect.vcxproj", "{03362E13-9438-4467-AAF4-CAEB76B17844}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {96755F53-5EDF-4E34-AB61-B85EB8BDE90E} = {96755F53-5EDF-4E34-AB61-B85EB8BDE90E} 11 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474} = {02FDD8C6-0AC4-4C61-86AA-283ACE914474} 12 | {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61} = {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61} 13 | {FAE031F5-4305-4113-9E48-91A80763A46C} = {FAE031F5-4305-4113-9E48-91A80763A46C} 14 | EndProjectSection 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cbff", "fileDissect\plugins\cbff\cbff.vcxproj", "{96755F53-5EDF-4E34-AB61-B85EB8BDE90E}" 17 | ProjectSection(ProjectDependencies) = postProject 18 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474} = {02FDD8C6-0AC4-4C61-86AA-283ACE914474} 19 | EndProjectSection 20 | EndProject 21 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "summinfo", "fileDissect\plugins\cbff\plugins\summInfo\summinfo.vcxproj", "{ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61}" 22 | ProjectSection(ProjectDependencies) = postProject 23 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474} = {02FDD8C6-0AC4-4C61-86AA-283ACE914474} 24 | EndProjectSection 25 | EndProject 26 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "excel", "fileDissect\plugins\cbff\plugins\excel\excel.vcxproj", "{FAE031F5-4305-4113-9E48-91A80763A46C}" 27 | ProjectSection(ProjectDependencies) = postProject 28 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474} = {02FDD8C6-0AC4-4C61-86AA-283ACE914474} 29 | EndProjectSection 30 | EndProject 31 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfileDissect", "libfileDissect\libfileDissect.vcxproj", "{02FDD8C6-0AC4-4C61-86AA-283ACE914474}" 32 | EndProject 33 | Global 34 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 35 | Debug|Win32 = Debug|Win32 36 | Release|Win32 = Release|Win32 37 | EndGlobalSection 38 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 39 | {03362E13-9438-4467-AAF4-CAEB76B17844}.Debug|Win32.ActiveCfg = Debug|Win32 40 | {03362E13-9438-4467-AAF4-CAEB76B17844}.Debug|Win32.Build.0 = Debug|Win32 41 | {03362E13-9438-4467-AAF4-CAEB76B17844}.Release|Win32.ActiveCfg = Release|Win32 42 | {03362E13-9438-4467-AAF4-CAEB76B17844}.Release|Win32.Build.0 = Release|Win32 43 | {96755F53-5EDF-4E34-AB61-B85EB8BDE90E}.Debug|Win32.ActiveCfg = Debug|Win32 44 | {96755F53-5EDF-4E34-AB61-B85EB8BDE90E}.Debug|Win32.Build.0 = Debug|Win32 45 | {96755F53-5EDF-4E34-AB61-B85EB8BDE90E}.Release|Win32.ActiveCfg = Release|Win32 46 | {96755F53-5EDF-4E34-AB61-B85EB8BDE90E}.Release|Win32.Build.0 = Release|Win32 47 | {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61}.Debug|Win32.ActiveCfg = Debug|Win32 48 | {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61}.Debug|Win32.Build.0 = Debug|Win32 49 | {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61}.Release|Win32.ActiveCfg = Release|Win32 50 | {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61}.Release|Win32.Build.0 = Release|Win32 51 | {FAE031F5-4305-4113-9E48-91A80763A46C}.Debug|Win32.ActiveCfg = Debug|Win32 52 | {FAE031F5-4305-4113-9E48-91A80763A46C}.Debug|Win32.Build.0 = Debug|Win32 53 | {FAE031F5-4305-4113-9E48-91A80763A46C}.Release|Win32.ActiveCfg = Release|Win32 54 | {FAE031F5-4305-4113-9E48-91A80763A46C}.Release|Win32.Build.0 = Release|Win32 55 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474}.Debug|Win32.ActiveCfg = Debug|Win32 56 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474}.Debug|Win32.Build.0 = Debug|Win32 57 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474}.Release|Win32.ActiveCfg = Release|Win32 58 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474}.Release|Win32.Build.0 = Release|Win32 59 | EndGlobalSection 60 | GlobalSection(SolutionProperties) = preSolution 61 | HideSolutionNode = FALSE 62 | EndGlobalSection 63 | GlobalSection(NestedProjects) = preSolution 64 | {B0569127-79DA-40B7-BC4D-605E17146675} = {1DBB020C-046B-41D1-A017-05C1D66BF372} 65 | {96755F53-5EDF-4E34-AB61-B85EB8BDE90E} = {1DBB020C-046B-41D1-A017-05C1D66BF372} 66 | {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61} = {B0569127-79DA-40B7-BC4D-605E17146675} 67 | {FAE031F5-4305-4113-9E48-91A80763A46C} = {B0569127-79DA-40B7-BC4D-605E17146675} 68 | EndGlobalSection 69 | EndGlobal 70 | -------------------------------------------------------------------------------- /fileDissect/fileDissect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissect.h: 6 | * general declarations 7 | */ 8 | #ifndef __fileDissect_h_ 9 | #define __fileDissect_h_ 10 | 11 | //=============================================================== 12 | // wxWidgets stuff 13 | //=============================================================== 14 | 15 | // For compilers that support precompilation, includes "wx.h". 16 | #include 17 | #ifdef __BORLANDC__ 18 | # pragma hdrstop 19 | #endif 20 | #ifndef WX_PRECOMP 21 | # include 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /fileDissect/fileDissect.idc: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /fileDissect/fileDissect.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 50 | 53 | 56 | 59 | 66 | 69 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 96 | 99 | 102 | 105 | 108 | 111 | 121 | 124 | 127 | 130 | 139 | 142 | 145 | 148 | 151 | 154 | 157 | 160 | 161 | 162 | 163 | 164 | 165 | 170 | 173 | 174 | 177 | 178 | 181 | 182 | 185 | 186 | 189 | 190 | 193 | 194 | 197 | 198 | 201 | 202 | 203 | 208 | 211 | 212 | 215 | 216 | 219 | 220 | 223 | 224 | 227 | 228 | 231 | 232 | 235 | 236 | 239 | 240 | 243 | 244 | 247 | 248 | 251 | 252 | 255 | 256 | 257 | 262 | 263 | 264 | 265 | 266 | 267 | -------------------------------------------------------------------------------- /fileDissect/fileDissect.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {03362E13-9438-4467-AAF4-CAEB76B17844} 15 | fileDissect 16 | 17 | 18 | 19 | Application 20 | Unicode 21 | true 22 | 23 | 24 | Application 25 | Unicode 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | <_ProjectFileVersion>10.0.30319.1 39 | $(SolutionDir)$(Configuration)\ 40 | $(Configuration)\ 41 | $(SolutionDir)$(Configuration)\ 42 | $(Configuration)\ 43 | MinimumRecommendedRules.ruleset 44 | 45 | 46 | AllRules.ruleset 47 | 48 | 49 | 50 | 51 | 52 | Disabled 53 | $(SolutionDir)\libfileDissect;$(SolutionDir)\libfileDissect\wxFileMap;$(SolutionDir)\wxHexView;$(SolutionDir)\wxPluginLoader;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 54 | true 55 | EnableFastChecks 56 | MultiThreadedDebugDLL 57 | Level3 58 | ProgramDatabase 59 | _UNICODE;UNICODE;%(PreprocessorDefinitions) 60 | 61 | 62 | comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) 63 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 64 | true 65 | MachineX86 66 | 67 | 68 | 69 | 70 | MaxSpeed 71 | true 72 | $(SolutionDir)\libfileDissect;$(SolutionDir)\libfileDissect\wxFileMap;$(SolutionDir)\wxHexView;$(SolutionDir)\wxPluginLoader;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 73 | MultiThreadedDLL 74 | true 75 | Level3 76 | ProgramDatabase 77 | false 78 | 79 | 80 | comctl32.lib;rpcrt4.lib;%(AdditionalDependencies) 81 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 82 | true 83 | true 84 | true 85 | MachineX86 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | {02fdd8c6-0ac4-4c61-86aa-283ace914474} 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /fileDissect/fileDissect.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | -------------------------------------------------------------------------------- /fileDissect/fileDissectApp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectApp.cpp: 6 | * application launching code 7 | * 8 | * load plugins, process command line, create and show the frame 9 | */ 10 | 11 | #include "fileDissect.h" // wxWidgets base 12 | #include "fileDissectApp.h" 13 | 14 | 15 | // implement it 16 | IMPLEMENT_APP(fileDissectApp); 17 | 18 | 19 | // the actual implementation 20 | bool fileDissectApp::OnInit () 21 | { 22 | /* this only appears to process the command line... 23 | * we do that ourselves later... 24 | * 25 | if (!wxApp::OnInit()) 26 | return false; 27 | */ 28 | 29 | // scanning for file format modules is done in frame the constructor 30 | 31 | // create application frame 32 | m_frame = new fileDissectFrame(APP_NAME); 33 | 34 | // check command line 35 | wxCmdLineParser parser(argc, argv); 36 | parser.SetDesc(g_cmdLineDesc); 37 | parser.SetSwitchChars(wxT("-")); 38 | if (parser.Parse(false) == 0) 39 | { 40 | size_t pcount = parser.GetParamCount(); 41 | 42 | // wxMessageBox(wxString::Format(wxT("Found %d parameters"), pcount), wxT("Information")); 43 | if (pcount > 0) 44 | { 45 | wxString param = parser.GetParam(0); 46 | m_frame->OpenFile(param); 47 | } 48 | } 49 | 50 | // show application frame 51 | m_frame->Show(true); 52 | SetTopWindow(m_frame); 53 | return true; 54 | } 55 | -------------------------------------------------------------------------------- /fileDissect/fileDissectApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectApp.h: 6 | * application declarations 7 | */ 8 | #ifndef __fileDissectApp_h_ 9 | #define __fileDissectApp_h_ 10 | 11 | #include "fileDissect.h" // wxWidgets base 12 | #include // command line 13 | 14 | #include "fileDissectFrame.h" 15 | 16 | #define APP_NAME wxT("fileDissect") 17 | 18 | /* 19 | * derive our application from wxApp 20 | */ 21 | class fileDissectApp : public wxApp 22 | { 23 | public: 24 | bool OnInit(); 25 | 26 | // frame window 27 | fileDissectFrame *m_frame; 28 | }; 29 | 30 | 31 | /* command line parameters */ 32 | static const wxCmdLineEntryDesc g_cmdLineDesc[] = 33 | { 34 | { wxCMD_LINE_PARAM, NULL, NULL, wxT("input file"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, 35 | { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0 } 36 | }; 37 | 38 | 39 | DECLARE_APP(fileDissectApp); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /fileDissect/fileDissectDnD.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectDnD.cpp: 6 | * drag and drop implementation 7 | */ 8 | #include "fileDissectDnD.h" 9 | 10 | #if wxUSE_DRAG_AND_DROP 11 | 12 | bool fileDissectDnD::OnDropFiles(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxArrayString& filenames) 13 | { 14 | size_t nFiles = filenames.GetCount(); 15 | if (nFiles != 1) 16 | return false; 17 | 18 | wxString str = filenames[0]; 19 | m_frame->CloseFile(); 20 | m_frame->OpenFile(str); 21 | return true; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /fileDissect/fileDissectDnD.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectDnD.h: 6 | * drag and drop declarations 7 | */ 8 | #ifndef __fileDissectDnD_h_ 9 | #define __fileDissectDnD_h_ 10 | 11 | #include "fileDissectFrame.h" 12 | 13 | #if wxUSE_DRAG_AND_DROP 14 | #include // drag and drop 15 | 16 | class fileDissectDnD : public wxFileDropTarget 17 | { 18 | public: 19 | fileDissectDnD(fileDissectFrame *pf) { m_frame = pf; } 20 | 21 | virtual bool OnDropFiles(wxCoord x, wxCoord y, 22 | const wxArrayString& filenames); 23 | private: 24 | fileDissectFrame *m_frame; 25 | }; 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /fileDissect/fileDissectFmts.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectFmts.cpp: 6 | * the list of found/loaded plugins supporting file formats 7 | */ 8 | #include "fileDissectFmts.h" 9 | #include 10 | 11 | #include 12 | WX_DEFINE_PLUGINLIST(fileDissectPlugin); 13 | 14 | 15 | // default class constructor 16 | fileDissectFmts::fileDissectFmts(void) 17 | { 18 | m_list.DeleteContents(true); 19 | 20 | m_log = 0; 21 | m_tree = 0; 22 | } 23 | 24 | // scan the module directory 25 | void fileDissectFmts::LoadPlugins(wxLog *plog, fileDissectTreeCtrl *tree) 26 | { 27 | m_log = plog; 28 | m_tree = tree; 29 | 30 | // scan for modules 31 | wxString path(wxGetCwd()); 32 | path += wxFileName::GetPathSeparator(); 33 | path += wxT("plugins"); 34 | path += wxFileName::GetPathSeparator(); 35 | 36 | fileDissectFmtsBase::LoadPlugins(path, plog, tree); 37 | } 38 | 39 | 40 | // look for a plugin that reports to suppor this 41 | fileDissectPlugin *fileDissectFmts::FindPluginForExt(const wxChar *extension) 42 | { 43 | #ifdef CHECK_FOR_DUPLICATE_EXTENSION_SUPPORT 44 | fileDissectPlugin *found = NULL; 45 | #endif 46 | for (fileDissectFmtsBase::iterator i = m_list.begin(); 47 | i != m_list.end(); 48 | i++) 49 | { 50 | fileDissectPlugin *p = (*i)->m_instance; 51 | 52 | if (p->SupportsExtension(extension)) 53 | { 54 | #ifdef CHECK_FOR_DUPLICATE_EXTENSION_SUPPORT 55 | if (found) 56 | // wtf! 57 | ; 58 | #endif 59 | // make a new one, it will be deleted by the parent 60 | // return (*i)->m_create_instance(m_log, m_tree); 61 | 62 | return p; 63 | } 64 | } 65 | // not found 66 | return NULL; 67 | } 68 | -------------------------------------------------------------------------------- /fileDissect/fileDissectFmts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectFmts.h: 6 | * the list of found/loaded plugins supporting file formats 7 | */ 8 | #ifndef __fileDissectFmts_h__ 9 | #define __fileDissectFmts_h__ 10 | 11 | #include "fileDissectPlugin.h" 12 | #include "wxPluginLoader.h" 13 | 14 | WX_DECLARE_PLUGINLIST(fileDissectPlugin, fileDissectFmtsBase); 15 | 16 | class fileDissectFmts : public fileDissectFmtsBase 17 | { 18 | public: 19 | fileDissectFmts(void); 20 | void LoadPlugins(wxLog *plog, fileDissectTreeCtrl *tree); 21 | fileDissectPlugin *FindPluginForExt(const wxChar *extension); 22 | 23 | wxLog *m_log; 24 | fileDissectTreeCtrl *m_tree; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /fileDissect/fileDissectFrame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectFrame.cpp: 6 | * Main frame code 7 | */ 8 | #include "fileDissectApp.h" // for APP_NAME only 9 | #include "fileDissectFrame.h" 10 | #include "fileDissectGUI.h" 11 | #include "fileDissectDnD.h" 12 | 13 | 14 | BEGIN_EVENT_TABLE(fileDissectFrame, wxFrame) 15 | // EVT_MENU(IDM_FILE_NEW, fileDissectFrame::OnFileNew) 16 | EVT_MENU(IDM_FILE_OPEN, fileDissectFrame::OnFileOpen) 17 | EVT_MENU(IDM_FILE_CLOSE, fileDissectFrame::OnFileClose) 18 | // EVT_MENU(IDM_FILE_SAVE, fileDissectFrame::OnFileSave) 19 | // EVT_MENU(IDM_FILE_SAVE_AS, fileDissectFrame::OnFileSaveAs) 20 | EVT_MENU(IDM_FILE_RELOAD, fileDissectFrame::OnFileReload) 21 | EVT_MENU(IDM_FILE_EXIT, fileDissectFrame::OnFileExit) 22 | EVT_MENU(IDM_TOOLS_RESCAN, fileDissectFrame::OnToolsRescan) 23 | EVT_MENU(IDM_NODE_EXPANDBELOW, fileDissectFrame::OnNodeExpandChildren) 24 | EVT_MENU(IDM_NODE_COLLAPSEBELOW, fileDissectFrame::OnNodeCollapseChildren) 25 | EVT_MENU(IDM_NODE_HIGHLIGHT, fileDissectFrame::OnNodeHighlight) 26 | END_EVENT_TABLE(); 27 | 28 | 29 | /* 30 | * application main frame.. 31 | */ 32 | fileDissectFrame::fileDissectFrame (const wxString &title) 33 | : wxFrame (NULL, wxID_ANY, title) 34 | { 35 | m_file = NULL; 36 | m_plugin = NULL; 37 | m_formats = NULL; 38 | 39 | InitGUI(title); 40 | InitFormats(); 41 | } 42 | 43 | void fileDissectFrame::InitGUI(const wxString& WXUNUSED(title)) 44 | { 45 | // file menu 46 | m_mnuFile = new wxMenu; 47 | // m_mnuFile->Append(IDM_FILE_NEW, wxT("&New..\tCtrl-N")); 48 | m_mnuFile->Append(IDM_FILE_OPEN, wxT("&Open..\tCtrl-O")); 49 | m_mnuFile->Append(IDM_FILE_CLOSE, wxT("&Close..\tCtrl-W")); 50 | m_mnuFile->Enable(IDM_FILE_CLOSE, false); 51 | // m_mnuFile->Append(IDM_FILE_SAVE, wxT("&Save..\tCtrl-S")); 52 | // m_mnuFile->Append(IDM_FILE_SAVE_AS, wxT("Save &As..")); 53 | m_mnuFile->Append(IDM_FILE_RELOAD, wxT("&Reload..\tCtrl-R")); 54 | m_mnuFile->Enable(IDM_FILE_RELOAD, false); 55 | m_mnuFile->AppendSeparator(); 56 | m_mnuFile->Append(IDM_FILE_EXIT, wxT("E&xit")); 57 | 58 | // tools menu 59 | m_mnuTools = new wxMenu; 60 | m_mnuTools->Append(IDM_TOOLS_RESCAN, wxT("&Reload Modules")); 61 | 62 | // menu bar 63 | m_menubar = new wxMenuBar; 64 | m_menubar->Append(m_mnuFile, wxT("&File")); 65 | m_menubar->Append(m_mnuTools, wxT("&Tools")); 66 | SetMenuBar(m_menubar); 67 | 68 | // init the panel.. 69 | m_panel = new wxPanel(this); 70 | 71 | // initialize the tree 72 | m_tree = new fileDissectTreeCtrl(m_panel, IDC_TREE, 73 | wxDefaultPosition, wxDefaultSize, 74 | wxSUNKEN_BORDER | wxTR_HAS_VARIABLE_ROW_HEIGHT | wxTR_HAS_BUTTONS); 75 | 76 | m_contents = new wxHexView(m_panel, IDC_HEXVIEW, 77 | wxDefaultPosition, wxDefaultSize); 78 | 79 | // m_contents->AdjustSize(); 80 | 81 | // initialize the static text box 82 | m_warnings = new wxTextCtrl(m_panel, IDC_LOG, _T(""), 83 | wxDefaultPosition, wxSize::wxSize(-1, 100), 84 | wxTE_MULTILINE); 85 | m_warnings->SetEditable(false); 86 | 87 | m_log = new wxLogTextCtrl(m_warnings); 88 | wxLog::SetActiveTarget(m_log); 89 | 90 | // set the icon 91 | // SetIcon(wxICON(fileDissect)); 92 | 93 | // set up the horizontal sizer 94 | wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); 95 | sizerTop->Add(m_contents, 0, wxEXPAND | (wxTOP|wxLEFT|wxRIGHT), 8); 96 | sizerTop->Add(m_tree, 1, wxEXPAND | (wxTOP|wxRIGHT), 8); 97 | 98 | wxSizer *sizerVert = new wxBoxSizer(wxVERTICAL); 99 | sizerVert->Add(sizerTop, 2, wxEXPAND, 0); 100 | sizerVert->Add(m_warnings, 1, wxEXPAND | wxALL, 8); 101 | m_panel->SetSizer(sizerVert); 102 | 103 | /* set window size */ 104 | wxSize ssz = wxGetDisplaySize(); 105 | // int sh = ssz.GetHeight(); 106 | // int sw = ssz.GetWidth(); 107 | SetSize(1024 - 40, 768 - 40); 108 | 109 | // center the window 110 | wxSize wsz = GetClientSize(); 111 | wxPoint pt; 112 | pt.x = (ssz.x / 2) - (wsz.x / 2); 113 | pt.y = (ssz.y / 2) - (wsz.y / 2); 114 | SetPosition(pt); 115 | 116 | #if wxUSE_DRAG_AND_DROP 117 | SetDropTarget(new fileDissectDnD(this)); 118 | #endif 119 | } 120 | 121 | void fileDissectFrame::InitFormats(void) 122 | { 123 | m_formats = new fileDissectFmts(); 124 | m_formats->LoadPlugins(m_log, m_tree); 125 | m_strWildcard = wxT("All Files (*.*)|*.*"); 126 | 127 | // build the file list based on modules 128 | wxString strExts = wxT(""); 129 | for (fileDissectFmts::iterator i = m_formats->begin(); 130 | i != m_formats->end(); 131 | i++) 132 | { 133 | fileDissectPlugin *p = (*i)->m_instance; 134 | 135 | if (p->m_extensions) 136 | { 137 | if (!strExts.IsEmpty()) 138 | strExts += wxT(";"); 139 | strExts += p->m_extensions; 140 | } 141 | else 142 | strExts += wxT("*.*"); 143 | 144 | if (p->m_description) 145 | { 146 | if (!m_strWildcard.empty()) 147 | m_strWildcard += wxT("|"); 148 | m_strWildcard += p->m_description; 149 | m_strWildcard += wxT(" ("); 150 | m_strWildcard += strExts; 151 | m_strWildcard += wxT(")|"); 152 | m_strWildcard += strExts; 153 | } 154 | } 155 | } 156 | 157 | fileDissectFrame::~fileDissectFrame(void) 158 | { 159 | delete m_panel; 160 | if (m_file) 161 | delete m_file; 162 | if (m_formats) 163 | delete m_formats; 164 | } 165 | 166 | 167 | #if 0 168 | void 169 | fileDissectFrame::OnFileNew(wxCommandEvent& WXUNUSED(event)) 170 | { 171 | } 172 | #endif 173 | 174 | 175 | void fileDissectFrame::OnFileOpen(wxCommandEvent& WXUNUSED(event)) 176 | { 177 | // present them with a file dialog to choose the project 178 | wxString prjFile = ::wxFileSelector(wxT("Select a file to dissect..."), 179 | NULL, 180 | NULL, 181 | NULL, 182 | m_strWildcard, 183 | wxFD_OPEN, 184 | this); 185 | if (!prjFile.empty()) 186 | { 187 | CloseFile(); 188 | OpenFile(prjFile); 189 | } 190 | } 191 | 192 | 193 | void fileDissectFrame::OpenFile(wxString& fname) 194 | { 195 | wxLogMessage(wxT("Opening file \"%s\""), fname.GetData()); 196 | 197 | m_file = new wxFileMap(); 198 | if (!m_file->Open(fname.c_str())) 199 | // error message is logged 200 | return; 201 | 202 | wxFileOffset len = m_file->Length(); 203 | m_contents->SetData(m_file->GetBaseAddress(), len); 204 | 205 | // update the menu items that require an open file 206 | m_mnuFile->Enable(IDM_FILE_CLOSE, true); 207 | m_mnuFile->Enable(IDM_FILE_RELOAD, true); 208 | 209 | // update the window 210 | UpdateDisplay(); 211 | } 212 | 213 | 214 | void fileDissectFrame::OnFileClose(wxCommandEvent& WXUNUSED(event)) 215 | { 216 | CloseFile(); 217 | } 218 | 219 | 220 | void fileDissectFrame::CloseFile(void) 221 | { 222 | if (m_file) 223 | { 224 | wxLogMessage(wxT("Closing file.")); 225 | 226 | delete m_file; 227 | m_file = NULL; 228 | m_tree->DeleteAllItems(); 229 | m_contents->SetData(NULL, 0); 230 | if (m_plugin) 231 | m_plugin->CloseFile(); 232 | 233 | // re-disable menu items that require a file being open 234 | m_mnuFile->Enable(IDM_FILE_CLOSE, false); 235 | m_mnuFile->Enable(IDM_FILE_RELOAD, false); 236 | } 237 | } 238 | 239 | 240 | #if 0 241 | void 242 | fileDissectFrame::OnFileSave(wxCommandEvent& WXUNUSED(event)) 243 | { 244 | } 245 | 246 | 247 | void 248 | fileDissectFrame::OnFileSaveAs(wxCommandEvent& event) 249 | { 250 | // present them with a file dialog to choose 251 | wxString prjFile = ::wxFileSelector(wxT("Save as..."), 252 | NULL, 253 | NULL, 254 | wxT("xls"), 255 | wxT("BIFF files (*.xls)|*.xls"), 256 | wxSAVE, 257 | this); 258 | if (!prjFile.empty()) 259 | { 260 | OnFileSave(event); 261 | } 262 | } 263 | #endif 264 | 265 | void fileDissectFrame::OnFileReload(wxCommandEvent& event) 266 | { 267 | // reload the file and reparse 268 | wxString fname = m_file->m_filename; 269 | CloseFile(); 270 | OpenFile(fname); 271 | } 272 | 273 | 274 | void fileDissectFrame::OnFileExit(wxCommandEvent& WXUNUSED(event)) 275 | { 276 | Close(true); 277 | } 278 | 279 | 280 | void fileDissectFrame::OnNodeExpandChildren(wxCommandEvent& WXUNUSED(event)) 281 | { 282 | wxTreeItemId id = m_tree->GetSelection(); 283 | 284 | m_tree->ExpandAllChildren(id); 285 | } 286 | 287 | 288 | void fileDissectFrame::OnNodeCollapseChildren(wxCommandEvent& WXUNUSED(event)) 289 | { 290 | wxTreeItemId id = m_tree->GetSelection(); 291 | 292 | m_tree->CollapseAllChildren(id); 293 | } 294 | 295 | 296 | void fileDissectFrame::OnNodeHighlight(wxCommandEvent& WXUNUSED(event)) 297 | { 298 | // find node data 299 | wxTreeItemId id = m_tree->GetSelection(); 300 | HighlightItem(id); 301 | } 302 | 303 | void fileDissectFrame::HighlightItem(wxTreeItemId &id) 304 | { 305 | // clear the hexview selection 306 | m_contents->ClearSelection(); 307 | 308 | fdTIData *pTID = (fdTIData *)m_tree->GetItemData(id); 309 | if (!pTID) 310 | { 311 | m_contents->Redraw(); 312 | return; 313 | } 314 | 315 | // update the selection based on the node data 316 | wxFileOffset start = m_file->Length(); 317 | for (fdTIData::iterator i = pTID->begin(); 318 | i != pTID->end(); 319 | i++) 320 | { 321 | fileDissectSel *pSel = *i; 322 | 323 | if (pSel->m_start < start) 324 | start = pSel->m_start; 325 | m_contents->AddToSelection(pSel->m_start, pSel->m_end); 326 | } 327 | m_contents->GotoOffset(start); 328 | 329 | // refresh hexview 330 | m_contents->Redraw(); 331 | } 332 | 333 | 334 | // set the window title 335 | void fileDissectFrame::UpdateTitle(void) 336 | { 337 | wxString new_title(APP_NAME); 338 | if (m_file) 339 | { 340 | new_title += wxT(" - "); 341 | new_title += m_file->m_filename; 342 | } 343 | this->SetTitle(new_title); 344 | } 345 | 346 | 347 | void fileDissectFrame::UpdateDisplay(void) 348 | { 349 | UpdateTitle(); 350 | 351 | // refresh the tree 352 | m_tree->DeleteAllItems(); 353 | if (!m_file) 354 | return; 355 | 356 | // see if we have a plugin that can dissect this file extension 357 | wxFileName fname(m_file->m_filename); 358 | m_plugin = m_formats->FindPluginForExt(fname.GetExt().c_str()); 359 | if (!m_plugin) 360 | { 361 | wxLogError(wxT("No plug-ins support this file extension!")); 362 | return; 363 | } 364 | 365 | // pass the file and some UI elements off to the plugin 366 | wxLogMessage(wxT("Dissecting using the \"%s\" plug-in."), m_plugin->m_description); 367 | m_plugin->m_file = m_file; 368 | m_plugin->Dissect(); 369 | } 370 | 371 | 372 | void fileDissectFrame::OnToolsRescan(wxCommandEvent& WXUNUSED(event)) 373 | { 374 | if (m_plugin) 375 | m_plugin = NULL; 376 | m_formats->LoadPlugins(m_log, m_tree); 377 | } 378 | -------------------------------------------------------------------------------- /fileDissect/fileDissectFrame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectFrame.h: 6 | * frame declarations 7 | */ 8 | #ifndef __fileDissectFrame_h_ 9 | #define __fileDissectFrame_h_ 10 | 11 | #include "fileDissect.h" // wxWidgets base 12 | 13 | // #include // standard paths 14 | // #include // file dialog 15 | // #include // file handling 16 | // #include 17 | // #include // filename handling 18 | 19 | /* classes used in this app */ 20 | class fileDissectFrame; 21 | class fileDissectApp; 22 | 23 | #include "fileDissectFmts.h" 24 | #include "fileDissectTree.h" 25 | #include "wxFileMap.h" 26 | #include "wxHexView.h" 27 | 28 | /* 29 | * the main frame of the application 30 | */ 31 | class fileDissectFrame : public wxFrame 32 | { 33 | public: 34 | fileDissectFrame(const wxString &title); 35 | ~fileDissectFrame(void); 36 | 37 | // init stuff 38 | void InitGUI(const wxString &title); 39 | void InitFormats(void); 40 | 41 | // state maintenance code 42 | void UpdateTitle(void); 43 | void UpdateDisplay(void); 44 | void OpenFile(wxString& fname); 45 | void CloseFile(void); 46 | void HighlightItem(wxTreeItemId &id); 47 | 48 | // file menu event handlers 49 | // void OnFileNew(wxCommandEvent& event); 50 | void OnFileOpen(wxCommandEvent& event); 51 | void OnFileClose(wxCommandEvent& event); 52 | // void OnFileSave(wxCommandEvent& event); 53 | // void OnFileSaveAs(wxCommandEvent& event); 54 | void OnFileReload(wxCommandEvent& event); 55 | void OnFileExit(wxCommandEvent& event); 56 | 57 | // tools menu event handlers 58 | void OnToolsRescan(wxCommandEvent& event); 59 | 60 | // context menu event handlers 61 | void OnNodeExpandChildren(wxCommandEvent& event); 62 | void OnNodeCollapseChildren(wxCommandEvent& event); 63 | void OnNodeHighlight(wxCommandEvent& event); // probably not needed, since we do this on click 64 | 65 | // gui items (tree below as well) 66 | wxPanel *m_panel; // main panel 67 | wxMenuBar *m_menubar; // main menu bar 68 | wxMenu *m_mnuFile; // file menu 69 | wxMenu *m_mnuTools; // tools menu 70 | wxHexView *m_contents; // hex viewer 71 | wxTextCtrl *m_warnings; // log output gets put here 72 | 73 | // data items passed down to plugins 74 | wxFileMap *m_file; // mapped file 75 | wxLogTextCtrl *m_log; // logging object 76 | fileDissectTreeCtrl *m_tree; // custom tree view control 77 | 78 | private: 79 | fileDissectFmts *m_formats; // supported file formats 80 | fileDissectPlugin *m_plugin; // the plugin for the currently open file 81 | wxString m_strWildcard; // the wildcard data for file select dialog 82 | 83 | DECLARE_EVENT_TABLE() 84 | }; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /fileDissect/fileDissectGUI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectGUI.h: 6 | * GUI definitions (ids for controls) 7 | */ 8 | #ifndef __fileDissectGUI_h_ 9 | #define __fileDissectGUI_h_ 10 | 11 | // main contols 12 | #define IDC_TREE 1000 13 | #define IDC_HEXVIEW 1001 14 | #define IDC_LOG 1002 15 | 16 | // file menu 17 | #define IDM_FILE_NEW 2000 18 | #define IDM_FILE_OPEN 2001 19 | #define IDM_FILE_CLOSE 2002 20 | #define IDM_FILE_SAVE 2003 21 | #define IDM_FILE_SAVE_AS 2004 22 | #define IDM_FILE_RELOAD 2005 23 | #define IDM_FILE_EXIT 2006 24 | 25 | // tools menu 26 | #define IDM_TOOLS_RESCAN 2500 27 | 28 | // context menu stuff 29 | #define IDM_NODE_EXPANDBELOW 3000 30 | #define IDM_NODE_COLLAPSEBELOW 3001 31 | #define IDM_NODE_HIGHLIGHT 3002 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /fileDissect/fileDissectPlugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectPlugin.h: 6 | * common implmentation for file format handling plug-ins 7 | * 8 | * plug-ins will derive from this class and export a single "create_instance" function 9 | * that returns a pointer to a new instance 10 | */ 11 | #ifndef __fileDissectPlugin_h__ 12 | #define __fileDissectPlugin_h__ 13 | 14 | #include "fileDissect.h" // wxWidgets base 15 | #include "fileDissectTree.h" // custom TreeCtrl 16 | #include "wxFileMap.h" // memory mapped files 17 | 18 | 19 | #define FD_PLUGIN_VERSION 0x0001 20 | 21 | #ifdef __WXMSW__ 22 | #define DECLARE_FD_PLUGIN(class_name) \ 23 | extern "C" __declspec (dllexport) fileDissectPlugin *create_instance(wxLog *plog, fileDissectTreeCtrl *tree) \ 24 | { return (fileDissectPlugin *)new class_name(plog, tree); } 25 | #else 26 | #define DECLARE_FD_PLUGIN(class_name) \ 27 | extern "C" fileDissectPlugin *create_instance(wxLog *plog, fileDissectTreeCtrl *tree) \ 28 | { return (fileDissectPlugin *)new class_name(plog, tree); } 29 | #endif 30 | 31 | 32 | class fileDissectPlugin 33 | { 34 | public: 35 | fileDissectPlugin(void) 36 | : m_description(0), 37 | m_extensions(0), 38 | m_log(0), 39 | m_tree(0), 40 | m_file(0), 41 | m_version(FD_PLUGIN_VERSION) 42 | { 43 | }; 44 | virtual ~fileDissectPlugin(void) 45 | { 46 | }; 47 | 48 | // do we support this file? 49 | virtual bool SupportsExtension(const wxChar *extension) = 0; 50 | virtual void Dissect(void) = 0; 51 | virtual void CloseFile(void) = 0; 52 | 53 | wxChar *m_description; 54 | wxChar *m_extensions; 55 | 56 | // passed from app 57 | wxLog *m_log; 58 | fileDissectTreeCtrl *m_tree; 59 | wxFileMap *m_file; 60 | 61 | private: 62 | unsigned long m_version; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /fileDissect/fileDissectTree.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectTree.cpp: 6 | * Tree Control code 7 | */ 8 | #include "fileDissectTree.h" 9 | #include "fileDissectGUI.h" 10 | #include "fileDissectApp.h" 11 | 12 | BEGIN_EVENT_TABLE(fileDissectTreeCtrl, wxTreeCtrl) 13 | EVT_TREE_ITEM_COLLAPSING(IDC_TREE, fileDissectTreeCtrl::OnItemCollapsing) 14 | EVT_TREE_ITEM_MENU(IDC_TREE, fileDissectTreeCtrl::OnItemMenu) 15 | EVT_TREE_ITEM_RIGHT_CLICK(IDC_TREE, fileDissectTreeCtrl::OnRightClick) 16 | EVT_TREE_SEL_CHANGED(IDC_TREE, fileDissectTreeCtrl::OnSelChanged) 17 | END_EVENT_TABLE(); 18 | 19 | /* implement the class */ 20 | IMPLEMENT_DYNAMIC_CLASS(fileDissectTreeCtrl, wxTreeCtrl); 21 | 22 | /* === member functions ==== */ 23 | 24 | // constructor 25 | fileDissectTreeCtrl::fileDissectTreeCtrl(wxWindow *parent, const wxWindowID id, 26 | const wxPoint& pos, const wxSize& size, 27 | long style) 28 | : wxTreeCtrl(parent, id, pos, size, style) 29 | { 30 | // CreateImageList(24); 31 | } 32 | 33 | 34 | #if 0 35 | // create the image list 36 | void fileDissectTreeCtrl::CreateImageList(int WXUNUSED(size)) 37 | { 38 | } 39 | #endif 40 | 41 | 42 | // item collapse event handler 43 | void fileDissectTreeCtrl::OnItemCollapsing(wxTreeEvent& event) 44 | { 45 | wxTreeItemId id = event.GetItem(); 46 | 47 | // prevent the root from collapsing 48 | if (id == GetRootItem()) 49 | { 50 | event.Veto(); 51 | return; 52 | } 53 | } 54 | 55 | // context menu event 56 | void fileDissectTreeCtrl::OnItemMenu(wxTreeEvent& event) 57 | { 58 | wxMenu mnuPopup; 59 | wxTreeItemId id = event.GetItem(); 60 | wxMenuItem *pm; 61 | 62 | pm = mnuPopup.Append(IDM_NODE_EXPANDBELOW, wxT("E&xpand children")); 63 | if (!HasChildren(id)) 64 | pm->Enable(false); 65 | 66 | pm = mnuPopup.Append(IDM_NODE_COLLAPSEBELOW, wxT("&Collapse children")); 67 | if (!HasChildren(id)) 68 | pm->Enable(false); 69 | 70 | pm = mnuPopup.Append(IDM_NODE_HIGHLIGHT, wxT("&Highlight")); 71 | if (!GetItemData(id)) 72 | pm->Enable(false); 73 | 74 | wxPoint pt = event.GetPoint(); 75 | PopupMenu(&mnuPopup, pt); 76 | } 77 | 78 | 79 | void fileDissectTreeCtrl::OnRightClick(wxTreeEvent& event) 80 | { 81 | wxTreeItemId id = event.GetItem(); 82 | 83 | SelectItem(id); 84 | } 85 | 86 | void fileDissectTreeCtrl::OnSelChanged(wxTreeEvent& event) 87 | { 88 | wxTreeItemId id = event.GetItem(); 89 | wxGetApp().m_frame->HighlightItem(id); 90 | } 91 | -------------------------------------------------------------------------------- /fileDissect/fileDissectTree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectTree.h: 6 | * tree view declarations 7 | */ 8 | #ifndef __fileDissectTree_h_ 9 | #define __fileDissectTree_h_ 10 | 11 | #include "fileDissect.h" // wxWidgets base 12 | #include // tree control 13 | #include "fileDissectItemData.h" 14 | 15 | 16 | /* 17 | * the tree holding our data 18 | */ 19 | class fileDissectTreeCtrl : public wxTreeCtrl 20 | { 21 | public: 22 | fileDissectTreeCtrl() 23 | { 24 | } 25 | 26 | fileDissectTreeCtrl(wxWindow *parent, const wxWindowID id, 27 | const wxPoint& pos, const wxSize& size, 28 | long style); 29 | 30 | #if 0 31 | // images.. 32 | void CreateImageList(int); 33 | #endif 34 | 35 | // event handlers 36 | void OnItemCollapsing(wxTreeEvent& event); 37 | void OnItemMenu(wxTreeEvent& event); 38 | void OnRightClick(wxTreeEvent& event); 39 | void OnSelChanged(wxTreeEvent& event); 40 | 41 | DECLARE_DYNAMIC_CLASS(fileDissectTreeCtrl) 42 | DECLARE_EVENT_TABLE() 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /fileDissect/makefile: -------------------------------------------------------------------------------- 1 | CPP = g++ 2 | CPPFLAGS = -ggdb -Wall -Wextra `wx-config --cflags` 3 | 4 | PATHREL = .. 5 | INCLUDE = -I$(PATHREL)/fileDissect -I$(PATHREL)/libfileDissect -I$(PATHREL)/libfileDissect/wxFileMap -I$(PATHREL)/wxHexView -I$(PATHREL)/wxPluginLoader 6 | BINDIR = $(PATHREL)/bin 7 | LDFLAGS = -L$(BINDIR) -lfileDissect `wx-config --libs` -ldl 8 | 9 | FD = $(BINDIR)/fd 10 | BINS = $(FD) 11 | FD_OBJS = \ 12 | fileDissectApp.o \ 13 | fileDissectFrame.o \ 14 | fileDissectDnD.o \ 15 | fileDissectFmts.o \ 16 | fileDissectTree.o \ 17 | $(PATHREL)/wxHexView/wxHexView.o 18 | 19 | all: bindir libfileDissect $(BINS) plugins-dir 20 | 21 | bindir: 22 | if test \! -d $(BINDIR); then mkdir $(BINDIR); fi 23 | 24 | 25 | $(FD): $(FD_OBJS) 26 | $(CPP) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) 27 | 28 | 29 | libfileDissect: 30 | make -C $(PATHREL)/libfileDissect 31 | 32 | libfileDissect-clean: 33 | make -C $(PATHREL)/libfileDissect clean 34 | 35 | 36 | plugins-dir: 37 | make -C plugins 38 | 39 | 40 | plugins-clean: 41 | make -C plugins clean 42 | 43 | clean: libfileDissect-clean plugins-clean 44 | rm -f $(BINS) $(FD_OBJS) 45 | rm -f $(BINDIR)/.gdb_history 46 | if test -d $(BINDIR); then rmdir $(BINDIR); fi 47 | 48 | 49 | .cpp.o: 50 | $(CPP) $(CPPFLAGS) $(INCLUDE) -o $@ -c $< 51 | 52 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * cbff.h: 6 | * class declaration for cbff class 7 | */ 8 | #ifndef __cbff_h_ 9 | #define __cbff_h_ 10 | 11 | // TODO: support more than 109 FAT sectors 12 | // #define READ_FAT_OFFSETS 13 | 14 | #include "fileDissectPlugin.h" 15 | #include "cbff_defs.h" // compound binary file format (OLE 2) 16 | 17 | #include "cbffStream.h" 18 | #include "cbffStreamPlugin.h" 19 | #include "cbffStreamPlugins.h" 20 | 21 | // list of sectors we visited (used to prevent loops) 22 | #include 23 | WX_DECLARE_LIST(SECT, visitedSectors); 24 | 25 | class cbff : public fileDissectPlugin 26 | { 27 | public: 28 | cbff(wxLog *plog, fileDissectTreeCtrl *tree); 29 | ~cbff (void); 30 | 31 | // plugin member functions 32 | bool SupportsExtension(const wxChar *extension); 33 | void Dissect(void); 34 | void CloseFile(void); 35 | 36 | private: 37 | void DestroyFileData(void); 38 | void InitFileData(void); 39 | 40 | // tree nodes for dissection output 41 | wxTreeItemId m_root_id; 42 | wxTreeItemId m_hdr_id; 43 | wxTreeItemId m_dir_root_id; 44 | 45 | // additional dissection routines 46 | bool DissectHeader(void); 47 | bool DissectFAT(void); 48 | bool DissectMiniFAT(void); 49 | bool DissectDirectory(void); 50 | void AddDirectoryNode(wxTreeItemId&, ULONG); 51 | void AddStreamData(wxTreeItemId&, wxString&, DIRENT_T *); 52 | 53 | // private file format functionality 54 | bool ReadStructuredStorageHeader(void); 55 | bool ReadFAT(void); 56 | bool ReadMiniFAT(void); 57 | bool ReadDirectory(void); 58 | void ReadStreamData(cbffStream *pStream); 59 | void ReadStreamDataFAT(cbffStream *pStream); 60 | void ReadStreamDataMiniFAT(cbffStream *pStream); 61 | 62 | //=============================== 63 | // low-level file format methods 64 | //=============================== 65 | bool GetSectorData(SECT sector, wxByte *dest, size_t len, wxFileOffset *poff); 66 | SECT GetNextSectorId(SECT sector, visitedSectors &visited); 67 | // mini-sector stuff 68 | bool GetMiniSectorData(SECT sector, wxByte *dest, size_t len, wxFileOffset *poff); 69 | SECT GetNextMiniSectorId(SECT sector, visitedSectors &visited); 70 | // directory stuff 71 | void ConvertDirEntName(DIRENT_T *pdir, wxString &dest); 72 | 73 | // this program is for human use after all... 74 | wxChar *HumanReadableByteOrder(void); 75 | wxChar *HumanReadableSectorType(SECT sector); 76 | wxChar *HumanReadableDirObjType(wxByte type); 77 | wxChar *HumanReadableColor(wxByte flags); 78 | 79 | //=============================== 80 | // low-level file format details 81 | //=============================== 82 | ULONG m_sectorSize; 83 | ULONG m_miniSectorSize; 84 | // header 85 | struct StructuredStorageHeader m_sshdr; 86 | // cache of FAT/miniFAT sectors 87 | SECT *m_FAT; 88 | #ifdef READ_FAT_OFFSETS 89 | wxFileOffset *m_FATOffsets; 90 | #endif 91 | SECT *m_MiniFAT; 92 | wxFileOffset *m_MiniFATOffsets; 93 | 94 | // directory details 95 | ULONG m_nDirSects; 96 | ULONG m_nDirEntries; 97 | struct StructuredStorageDirectoryEntry *m_DIR; 98 | struct StructuredStorageDirectoryEntry *m_DirRoot; 99 | wxFileOffset *m_DIROffsets; 100 | 101 | // plugin handling 102 | void QueryStreamPlugins(void); 103 | void ReadDesiredStreamData(void); 104 | void InvokeStreamPlugins(void); 105 | cbffStreamPlugins *m_plugins; 106 | 107 | // for passing to plugins 108 | cbffStreamList m_streams; 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbff.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 50 | 53 | 56 | 59 | 66 | 69 | 72 | 75 | 78 | 81 | 84 | 87 | 88 | 96 | 99 | 102 | 105 | 108 | 111 | 121 | 124 | 127 | 130 | 139 | 142 | 145 | 148 | 151 | 154 | 157 | 160 | 161 | 162 | 163 | 164 | 165 | 170 | 173 | 174 | 177 | 178 | 181 | 182 | 185 | 186 | 189 | 190 | 191 | 196 | 199 | 200 | 203 | 204 | 207 | 208 | 211 | 212 | 215 | 216 | 219 | 220 | 223 | 224 | 225 | 230 | 231 | 232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbff.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {96755F53-5EDF-4E34-AB61-B85EB8BDE90E} 15 | cbff 16 | 17 | 18 | 19 | DynamicLibrary 20 | Unicode 21 | true 22 | 23 | 24 | DynamicLibrary 25 | Unicode 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | <_ProjectFileVersion>10.0.30319.1 39 | $(SolutionDir)$(Configuration)\plugins\ 40 | $(Configuration)\ 41 | $(SolutionDir)$(Configuration)\plugins\ 42 | $(Configuration)\ 43 | MinimumRecommendedRules.ruleset 44 | 45 | 46 | AllRules.ruleset 47 | 48 | 49 | 50 | 51 | 52 | Disabled 53 | $(SolutionDir)\fileDissect;$(SolutionDir)\libfileDissect;$(SolutionDir)\libfileDissect\wxFileMap;$(SolutionDir)\wxPluginLoader;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 54 | true 55 | EnableFastChecks 56 | MultiThreadedDebugDLL 57 | Level3 58 | ProgramDatabase 59 | _WINDLL;%(PreprocessorDefinitions) 60 | 61 | 62 | $(OutDir)$(ProjectName).dll 63 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 64 | true 65 | MachineX86 66 | 67 | 68 | 69 | 70 | MaxSpeed 71 | true 72 | $(SolutionDir)\fileDissect;$(SolutionDir)\libfileDissect;$(SolutionDir)\libfileDissect\wxFileMap;$(SolutionDir)\wxPluginLoader;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 73 | MultiThreadedDLL 74 | true 75 | Level3 76 | ProgramDatabase 77 | false 78 | 79 | 80 | $(OutDir)$(ProjectName).dll 81 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 82 | true 83 | true 84 | true 85 | MachineX86 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | {02fdd8c6-0ac4-4c61-86aa-283ace914474} 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbff.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbffStream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * cbffStream.cpp: 6 | * implementation for cbffStream class 7 | */ 8 | #include "cbffStream.h" 9 | 10 | #include 11 | WX_DEFINE_LIST(cbffStreamList); 12 | 13 | cbffStream::cbffStream(wxString &name) 14 | : m_name(name) 15 | { 16 | m_wanted = false; 17 | 18 | m_data = 0; 19 | m_length = 0; 20 | 21 | m_start = CBFF_SECT_FREE; 22 | m_offsets = 0; 23 | m_sectCnt = 0; 24 | 25 | // m_id = .. 26 | 27 | m_phdr = 0; 28 | m_miniSectorSize = 0; 29 | m_sectorSize = 0; 30 | } 31 | 32 | cbffStream::~cbffStream(void) 33 | { 34 | if (m_data) 35 | free(m_data); 36 | if (m_offsets) 37 | free(m_offsets); 38 | } 39 | 40 | wxFileOffset cbffStream::GetFileOffset(wxFileOffset streamOffset) 41 | { 42 | if (streamOffset > (wxFileOffset)m_length) 43 | // XXX: fix me! 44 | return m_length; 45 | 46 | ULONG mod; 47 | if (m_length < m_phdr->_ulMiniSectorCutoff) 48 | // its stored in the minifat 49 | mod = m_miniSectorSize; 50 | else 51 | // its stored in the fat 52 | mod = m_sectorSize; 53 | 54 | ULONG sect = streamOffset / mod; 55 | ULONG rem = streamOffset % mod; 56 | if (sect >= m_sectCnt) 57 | return m_length; 58 | 59 | return m_offsets[sect] + rem; 60 | } 61 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbffStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * cbffStream.h: 6 | * class declaration for cbffStream (passed to stream plugins) 7 | */ 8 | #ifndef __cbffStream_h_ 9 | #define __cbffStream_h_ 10 | 11 | #ifdef __linux__ 12 | # define __declspec(x) 13 | #endif 14 | 15 | #include "fileDissect.h" 16 | #include 17 | #include "cbff_defs.h" 18 | 19 | class cbffStream 20 | { 21 | public: 22 | cbffStream(wxString &name); 23 | ~cbffStream(void); 24 | 25 | __declspec(dllexport) wxFileOffset GetFileOffset(wxFileOffset streamOffset); 26 | 27 | wxString m_name; 28 | 29 | // for the query process 30 | bool m_wanted; 31 | 32 | // for processing 33 | BYTE *m_data; 34 | ULONG m_length; // limited by file format to ULONG 35 | wxTreeItemId m_id; 36 | 37 | SECT m_start; 38 | wxFileOffset *m_offsets; 39 | ULONG m_sectCnt; 40 | 41 | // from parent (cbff) 42 | struct StructuredStorageHeader *m_phdr; 43 | ULONG m_sectorSize; 44 | ULONG m_miniSectorSize; 45 | }; 46 | 47 | 48 | // list of streams in the file (for stream plugin to dissect) 49 | #include 50 | WX_DECLARE_LIST(cbffStream, cbffStreamList); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbffStreamPlugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * cbffStreamPlugin.h: 6 | * class declaration for cbffStreamPlugin 7 | */ 8 | #ifndef __cbffStreamPlugin_h_ 9 | #define __cbffStreamPlugin_h_ 10 | 11 | #include "fileDissect.h" // wxWidgets base 12 | #include "fileDissectTree.h" // custom tree 13 | #include "cbffStream.h" 14 | 15 | #define CBF_PLUGIN_VERSION 0x0001 16 | 17 | #ifdef __WXMSW__ 18 | #define DECLARE_CBF_PLUGIN(class_name) \ 19 | extern "C" __declspec (dllexport) cbffStreamPlugin *create_instance(wxLog *plog, fileDissectTreeCtrl *tree) \ 20 | { return (cbffStreamPlugin *)new class_name(plog, tree); } 21 | #else 22 | #define DECLARE_CBF_PLUGIN(class_name) \ 23 | extern "C" cbffStreamPlugin *create_instance(wxLog *plog, fileDissectTreeCtrl *tree) \ 24 | { return (cbffStreamPlugin *)new class_name(plog, tree); } 25 | #endif 26 | 27 | 28 | class cbffStreamPlugin 29 | { 30 | public: 31 | cbffStreamPlugin(void) 32 | : m_description(0), 33 | m_log(0), 34 | m_tree(0), 35 | m_version(CBF_PLUGIN_VERSION) 36 | { 37 | }; 38 | // allow derivatives to implement a destructor 39 | virtual ~cbffStreamPlugin(void) 40 | { 41 | }; 42 | 43 | // plugin interface methods 44 | virtual void MarkDesiredStreams(void) = 0; 45 | virtual void Dissect(void) = 0; 46 | virtual void CloseFile(void) 47 | { 48 | m_streams = 0; 49 | }; 50 | 51 | wxChar *m_description; 52 | 53 | // passed from app -> plugin 54 | wxLog *m_log; 55 | fileDissectTreeCtrl *m_tree; 56 | cbffStreamList *m_streams; 57 | 58 | private: 59 | unsigned long m_version; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbffStreamPlugins.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * cbffStreamPlugins.cpp: 6 | * implementation for cbffStreamPlugins class 7 | */ 8 | #include "cbffStreamPlugins.h" 9 | #include 10 | 11 | #include 12 | WX_DEFINE_PLUGINLIST(cbffStreamPlugin); 13 | 14 | // default class constructor 15 | cbffStreamPlugins::cbffStreamPlugins(void) 16 | { 17 | // destroy elements on instance destruction 18 | m_list.DeleteContents(true); 19 | } 20 | 21 | // scan the module directory 22 | void cbffStreamPlugins::LoadPlugins(wxLog *plog, fileDissectTreeCtrl *tree) 23 | { 24 | // scan for modules 25 | wxString path(wxGetCwd()); 26 | path += wxFileName::GetPathSeparator(); 27 | path += wxT("plugins"); 28 | path += wxFileName::GetPathSeparator(); 29 | path += wxT("cbff"); 30 | path += wxFileName::GetPathSeparator(); 31 | 32 | cbffStreamPluginsBase::LoadPlugins(path, plog, tree); 33 | } 34 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbffStreamPlugins.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * cbffStreamPlugin.h: 6 | * class declaration for cbffStreamPlugin 7 | */ 8 | #ifndef __cbffStreamPlugins_h_ 9 | #define __cbffStreamPlugins_h_ 10 | 11 | #include "cbffStreamPlugin.h" 12 | #include "wxPluginLoader.h" 13 | 14 | // list of stream plugins 15 | WX_DECLARE_PLUGINLIST(cbffStreamPlugin, cbffStreamPluginsBase); 16 | 17 | class cbffStreamPlugins : public cbffStreamPluginsBase 18 | { 19 | public: 20 | cbffStreamPlugins(void); 21 | void LoadPlugins(wxLog *plog, fileDissectTreeCtrl *tree); 22 | }; 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/cbff_defs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jduck/file-dissect/3ebeaf30e63edae991544a3c429008c24ec46d3c/fileDissect/plugins/cbff/cbff_defs.h -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/makefile: -------------------------------------------------------------------------------- 1 | CPP = g++ 2 | CPPFLAGS = -ggdb -fPIC -Wall -Wextra `wx-config --cflags` 3 | FDPATH = ../../.. 4 | INCLUDE = -I$(FDPATH)/fileDissect -I$(FDPATH)/libfileDissect -I$(FDPATH)/libfileDissect/wxFileMap -I$(FDPATH)/wxHexView -I$(FDPATH)/wxPluginLoader 5 | LDFLAGS = `wx-config --libs` -ldl 6 | 7 | BINDIR = $(FDPATH)/bin/plugins 8 | 9 | 10 | CBFF = $(BINDIR)/cbff.so 11 | BINS = $(CBFF) $(BINDIR)/libcbff.so 12 | CBFF_OBJS = \ 13 | cbff.o \ 14 | cbffStream.o \ 15 | cbffStreamPlugins.o 16 | 17 | 18 | all: $(BINS) plugins-dir 19 | 20 | 21 | $(CBFF): $(CBFF_OBJS) 22 | $(CPP) $(CPPFLAGS) -fpic -shared -o $@ -Wl,-soname,CBFF_SONAME $^ $(LDFLAGS) 23 | 24 | $(BINDIR)/libcbff.so: 25 | cd $(BINDIR) && ln -s cbff.so libcbff.so 26 | 27 | plugins-dir: 28 | make -C plugins 29 | 30 | 31 | plugins-clean: 32 | make -C plugins clean 33 | 34 | clean: plugins-clean 35 | rm -f $(CBFF_OBJS) $(BINS) 36 | 37 | 38 | .cpp.o: 39 | $(CPP) $(CPPFLAGS) $(INCLUDE) -o $@ -c $< 40 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/Workbook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Microsoft Office Excel Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * Workbook.h: 6 | * class declaration for Workbook cbffStreamPlugin class 7 | */ 8 | 9 | #ifndef __Workbook_h_ 10 | #define __Workbook_h_ 11 | 12 | #include "cbffStreamPlugin.h" 13 | #include "WorkbookDefs.h" 14 | 15 | 16 | // used for tracking nested pages (BOFs) 17 | #include 18 | WX_DECLARE_STACK(wxTreeItemId, wxNodeStack); 19 | 20 | 21 | class Workbook : public cbffStreamPlugin 22 | { 23 | public: 24 | Workbook(wxLog *plog, fileDissectTreeCtrl *tree); 25 | 26 | // plugin interface methods 27 | void MarkDesiredStreams(void); 28 | void Dissect(void); 29 | // XXX: determine if this is needed 30 | // void CloseFile(void); 31 | 32 | private: 33 | BYTE *m_cur; 34 | BYTE *m_end; 35 | 36 | void DissectStream(cbffStream *pStream); 37 | 38 | struct WorkbookRecord *GetNextRecord(void); 39 | 40 | void AddBOFContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 41 | void AddBOUNDSHEETContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 42 | void AddFORMATContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 43 | void AddHEADERContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 44 | void AddINTERFACEHDRContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 45 | void AddMMSContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 46 | void AddWRITEACCESSContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 47 | void AddFONTContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 48 | void AddLABELSSTContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 49 | void AddSSTContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 50 | void AddEXTSSTContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 51 | void AddMULBLANKContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 52 | void AddMULRKContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 53 | void AddRKContents(cbffStream *pStream, wxTreeItemId &parent, struct WorkbookRecord *prec); 54 | 55 | wxChar *HumanReadableBOFType(USHORT); 56 | wxChar *HumanReadableRecordTypeShort(USHORT); 57 | wxChar *HumanReadableRecordTypeLong(USHORT); 58 | wxChar *HumanReadableRKType(ULONG); 59 | 60 | void DecodeString(BYTE *, USHORT, USHORT, wxString &); 61 | size_t GetStringLength(USHORT, USHORT); 62 | 63 | double RKDecode(ULONG); 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/WorkbookDefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Microsoft Office Excel Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * WorkbookDefs.h: 6 | * data structure definitions requierd by Workbook cbffStreamPlugin class 7 | */ 8 | 9 | #ifndef __WorkbookDefs_h_ 10 | #define __WorkbookDefs_h_ 11 | 12 | #pragma pack(push, 1) 13 | struct WorkbookRecord 14 | { 15 | USHORT uNumber; 16 | USHORT uLength; 17 | }; 18 | 19 | // manully added record types 20 | #define WBOOK_RT_UFONT 0x31 21 | 22 | // BOF record types (including version) 23 | #define WBOOK_RT_BOF2 0x09 24 | #define WBOOK_RT_BOF3 0x209 25 | #define WBOOK_RT_BOF4 0x409 26 | #define WBOOK_RT_BOF578 0x809 27 | 28 | // misc missing record numbers 29 | #define WBOOK_RT_RK3 0x27E 30 | 31 | // auto-generated record types 32 | #define WBOOK_RT_EOF 0x0A 33 | #define WBOOK_RT_CALCCOUNT 0x0C 34 | #define WBOOK_RT_CALCMODE 0x0D 35 | #define WBOOK_RT_PRECISION 0x0E 36 | #define WBOOK_RT_REFMODE 0x0F 37 | #define WBOOK_RT_DELTA 0x10 38 | #define WBOOK_RT_ITERATION 0x11 39 | #define WBOOK_RT_PROTECT 0x12 40 | #define WBOOK_RT_PASSWORD 0x13 41 | #define WBOOK_RT_HEADER 0x14 42 | #define WBOOK_RT_FOOTER 0x15 43 | #define WBOOK_RT_EXTERNCOUNT 0x16 44 | #define WBOOK_RT_EXTERNSHEET 0x17 45 | #define WBOOK_RT_WINDOWPROTECT 0x19 46 | #define WBOOK_RT_VERTICALPAGEBREAKS 0x1A 47 | #define WBOOK_RT_HORIZONTALPAGEBREAKS 0x1B 48 | #define WBOOK_RT_NOTE 0x1C 49 | #define WBOOK_RT_SELECTION 0x1D 50 | #define WBOOK_RT_1904 0x22 51 | #define WBOOK_RT_LEFTMARGIN 0x26 52 | #define WBOOK_RT_RIGHTMARGIN 0x27 53 | #define WBOOK_RT_TOPMARGIN 0x28 54 | #define WBOOK_RT_BOTTOMMARGIN 0x29 55 | #define WBOOK_RT_PRINTHEADERS 0x2A 56 | #define WBOOK_RT_PRINTGRIDLINES 0x2B 57 | #define WBOOK_RT_FILEPASS 0x2F 58 | #define WBOOK_RT_CONTINUE 0x3C 59 | #define WBOOK_RT_WINDOW1 0x3D 60 | #define WBOOK_RT_BACKUP 0x40 61 | #define WBOOK_RT_PANE 0x41 62 | // dupes! 63 | #define WBOOK_RT_CODENAME 0x42 64 | #define WBOOK_RT_CODEPAGE 0x42 65 | #define WBOOK_RT_PLS 0x4D 66 | #define WBOOK_RT_DCON 0x50 67 | #define WBOOK_RT_DCONREF 0x51 68 | #define WBOOK_RT_DCONNAME 0x52 69 | #define WBOOK_RT_DEFCOLWIDTH 0x55 70 | #define WBOOK_RT_XCT 0x59 71 | #define WBOOK_RT_CRN 0x5A 72 | #define WBOOK_RT_FILESHARING 0x5B 73 | #define WBOOK_RT_WRITEACCESS 0x5C 74 | #define WBOOK_RT_OBJ 0x5D 75 | #define WBOOK_RT_UNCALCED 0x5E 76 | #define WBOOK_RT_SAVERECALC 0x5F 77 | #define WBOOK_RT_TEMPLATE 0x60 78 | #define WBOOK_RT_OBJPROTECT 0x63 79 | #define WBOOK_RT_COLINFO 0x7D 80 | #define WBOOK_RT_RK 0x7E 81 | #define WBOOK_RT_IMDATA 0x7F 82 | #define WBOOK_RT_GUTS 0x80 83 | #define WBOOK_RT_WSBOOL 0x81 84 | #define WBOOK_RT_GRIDSET 0x82 85 | #define WBOOK_RT_HCENTER 0x83 86 | #define WBOOK_RT_VCENTER 0x84 87 | #define WBOOK_RT_BOUNDSHEET 0x85 88 | #define WBOOK_RT_WRITEPROT 0x86 89 | #define WBOOK_RT_ADDIN 0x87 90 | #define WBOOK_RT_EDG 0x88 91 | #define WBOOK_RT_PUB 0x89 92 | #define WBOOK_RT_COUNTRY 0x8C 93 | #define WBOOK_RT_HIDEOBJ 0x8D 94 | #define WBOOK_RT_SORT 0x90 95 | #define WBOOK_RT_SUB 0x91 96 | #define WBOOK_RT_PALETTE 0x92 97 | #define WBOOK_RT_LHRECORD 0x94 98 | #define WBOOK_RT_LHNGRAPH 0x95 99 | #define WBOOK_RT_SOUND 0x96 100 | #define WBOOK_RT_LPR 0x98 101 | #define WBOOK_RT_STANDARDWIDTH 0x99 102 | #define WBOOK_RT_FILTERMODE 0x9B 103 | #define WBOOK_RT_FNGROUPCOUNT 0x9C 104 | #define WBOOK_RT_AUTOFILTERINFO 0x9D 105 | #define WBOOK_RT_AUTOFILTER 0x9E 106 | #define WBOOK_RT_SCL 0xA0 107 | #define WBOOK_RT_SETUP 0xA1 108 | #define WBOOK_RT_COORDLIST 0xA9 109 | #define WBOOK_RT_GCW 0xAB 110 | #define WBOOK_RT_SCENMAN 0xAE 111 | #define WBOOK_RT_SCENARIO 0xAF 112 | #define WBOOK_RT_SXVIEW 0xB0 113 | #define WBOOK_RT_SXVD 0xB1 114 | #define WBOOK_RT_SXVI 0xB2 115 | #define WBOOK_RT_SXIVD 0xB4 116 | #define WBOOK_RT_SXLI 0xB5 117 | #define WBOOK_RT_SXPI 0xB6 118 | #define WBOOK_RT_DOCROUTE 0xB8 119 | #define WBOOK_RT_RECIPNAME 0xB9 120 | #define WBOOK_RT_SHRFMLA 0xBC 121 | #define WBOOK_RT_MULRK 0xBD 122 | #define WBOOK_RT_MULBLANK 0xBE 123 | #define WBOOK_RT_MMS 0xC1 124 | #define WBOOK_RT_ADDMENU 0xC2 125 | #define WBOOK_RT_DELMENU 0xC3 126 | #define WBOOK_RT_SXDI 0xC5 127 | #define WBOOK_RT_SXDB 0xC6 128 | #define WBOOK_RT_SXSTRING 0xCD 129 | #define WBOOK_RT_SXTBL 0xD0 130 | #define WBOOK_RT_SXTBRGIITM 0xD1 131 | #define WBOOK_RT_SXTBPG 0xD2 132 | #define WBOOK_RT_OBPROJ 0xD3 133 | #define WBOOK_RT_SXIDSTM 0xD5 134 | #define WBOOK_RT_RSTRING 0xD6 135 | #define WBOOK_RT_DBCELL 0xD7 136 | #define WBOOK_RT_BOOKBOOL 0xDA 137 | // dupes! 138 | #define WBOOK_RT_PARAMQRY 0xDC 139 | #define WBOOK_RT_SXEXT 0xDC 140 | #define WBOOK_RT_SCENPROTECT 0xDD 141 | #define WBOOK_RT_OLESIZE 0xDE 142 | #define WBOOK_RT_UDDESC 0xDF 143 | #define WBOOK_RT_XF 0xE0 144 | #define WBOOK_RT_INTERFACEHDR 0xE1 145 | #define WBOOK_RT_INTERFACEEND 0xE2 146 | #define WBOOK_RT_SXVS 0xE3 147 | #define WBOOK_RT_MERGECELLS 0xE5 148 | #define WBOOK_RT_TABIDCONF 0xEA 149 | #define WBOOK_RT_MSODRAWINGGROUP 0xEB 150 | #define WBOOK_RT_MSODRAWING 0xEC 151 | #define WBOOK_RT_MSODRAWINGSELECTION 0xED 152 | #define WBOOK_RT_SXRULE 0xF0 153 | #define WBOOK_RT_SXEX 0xF1 154 | #define WBOOK_RT_SXFILT 0xF2 155 | #define WBOOK_RT_SXDXF 0xF4 156 | #define WBOOK_RT_SXITM 0xF5 157 | #define WBOOK_RT_SXNAME 0xF6 158 | #define WBOOK_RT_SXSELECT 0xF7 159 | #define WBOOK_RT_SXPAIR 0xF8 160 | #define WBOOK_RT_SXFMLA 0xF9 161 | #define WBOOK_RT_SXFORMAT 0xFB 162 | #define WBOOK_RT_SST 0xFC 163 | #define WBOOK_RT_LABELSST 0xFD 164 | #define WBOOK_RT_EXTSST 0xFF 165 | #define WBOOK_RT_SXVDEX 0x100 166 | #define WBOOK_RT_SXFORMULA 0x103 167 | #define WBOOK_RT_SXDBEX 0x122 168 | #define WBOOK_RT_TABID 0x13D 169 | #define WBOOK_RT_USESELFS 0x160 170 | #define WBOOK_RT_DSF 0x161 171 | #define WBOOK_RT_XL5MODIFY 0x162 172 | #define WBOOK_RT_FILESHARING2 0x1A5 173 | #define WBOOK_RT_USERBVIEW 0x1A9 174 | #define WBOOK_RT_USERSVIEWBEGIN 0x1AA 175 | #define WBOOK_RT_USERSVIEWEND 0x1AB 176 | #define WBOOK_RT_QSI 0x1AD 177 | #define WBOOK_RT_SUPBOOK 0x1AE 178 | #define WBOOK_RT_PROT4REV 0x1AF 179 | #define WBOOK_RT_CONDFMT 0x1B0 180 | #define WBOOK_RT_CF 0x1B1 181 | #define WBOOK_RT_DVAL 0x1B2 182 | #define WBOOK_RT_DCONBIN 0x1B5 183 | #define WBOOK_RT_TXO 0x1B6 184 | #define WBOOK_RT_REFRESHALL 0x1B7 185 | #define WBOOK_RT_HLINK 0x1B8 186 | #define WBOOK_RT_SXFDBTYPE 0x1BB 187 | #define WBOOK_RT_PROT4REVPASS 0x1BC 188 | #define WBOOK_RT_DV 0x1BE 189 | #define WBOOK_RT_EXCEL9FILE 0x1C0 190 | #define WBOOK_RT_RECALCID 0x1C1 191 | #define WBOOK_RT_DIMENSIONS 0x200 192 | #define WBOOK_RT_BLANK 0x201 193 | #define WBOOK_RT_NUMBER 0x203 194 | #define WBOOK_RT_LABEL 0x204 195 | #define WBOOK_RT_BOOLERR 0x205 196 | #define WBOOK_RT_STRING 0x207 197 | #define WBOOK_RT_ROW 0x208 198 | #define WBOOK_RT_INDEX 0x20B 199 | #define WBOOK_RT_NAME 0x218 200 | #define WBOOK_RT_ARRAY 0x221 201 | #define WBOOK_RT_EXTERNNAME 0x223 202 | #define WBOOK_RT_DEFAULTROWHEIGHT 0x225 203 | #define WBOOK_RT_FONT 0x231 204 | #define WBOOK_RT_TABLE 0x236 205 | #define WBOOK_RT_WINDOW2 0x23E 206 | #define WBOOK_RT_STYLE 0x293 207 | #define WBOOK_RT_FORMULA 0x406 208 | #define WBOOK_RT_FORMAT 0x41E 209 | #define WBOOK_RT_HLINKTOOLTIP 0x800 210 | #define WBOOK_RT_WEBPUB 0x801 211 | #define WBOOK_RT_QSISXTAG 0x802 212 | #define WBOOK_RT_DBQUERYEXT 0x803 213 | #define WBOOK_RT_EXTSTRING 0x804 214 | #define WBOOK_RT_TXTQUERY 0x805 215 | #define WBOOK_RT_QSIR 0x806 216 | #define WBOOK_RT_QSIF 0x807 217 | // #define WBOOK_RT_BOF 0x809 218 | #define WBOOK_RT_OLEDBCONN 0x80A 219 | #define WBOOK_RT_WOPT 0x80B 220 | #define WBOOK_RT_SXVIEWEX 0x80C 221 | #define WBOOK_RT_SXTH 0x80D 222 | #define WBOOK_RT_SXPIEX 0x80E 223 | #define WBOOK_RT_SXVDTEX 0x80F 224 | #define WBOOK_RT_SXVIEWEX9 0x810 225 | #define WBOOK_RT_CONTINUEFRT 0x812 226 | #define WBOOK_RT_REALTIMEDATA 0x813 227 | #define WBOOK_RT_SHEETEXT 0x862 228 | #define WBOOK_RT_BOOKEXT 0x863 229 | #define WBOOK_RT_SXADDL 0x864 230 | #define WBOOK_RT_CRASHRECERR 0x865 231 | #define WBOOK_RT_HFPicture 0x866 232 | #define WBOOK_RT_FEATHEADR 0x867 233 | #define WBOOK_RT_FEAT 0x868 234 | #define WBOOK_RT_DATALABEXT 0x86A 235 | #define WBOOK_RT_DATALABEXTCONTENTS 0x86B 236 | #define WBOOK_RT_CELLWATCH 0x86C 237 | #define WBOOK_RT_FEATHEADR11 0x871 238 | #define WBOOK_RT_FEAT11 0x872 239 | #define WBOOK_RT_FEATINFO11 0x873 240 | #define WBOOK_RT_DROPDOWNOBJIDS 0x874 241 | #define WBOOK_RT_CONTINUEFRT11 0x875 242 | #define WBOOK_RT_DCONN 0x876 243 | #define WBOOK_RT_LIST12 0x877 244 | #define WBOOK_RT_FEAT12 0x878 245 | #define WBOOK_RT_CONDFMT12 0x879 246 | #define WBOOK_RT_CF12 0x87A 247 | #define WBOOK_RT_CFEX 0x87B 248 | #define WBOOK_RT_XFCRC 0x87C 249 | #define WBOOK_RT_XFEXT 0x87D 250 | #define WBOOK_RT_EZFILTER12 0x87E 251 | #define WBOOK_RT_CONTINUEFRT12 0x87F 252 | #define WBOOK_RT_SXADDL12 0x881 253 | #define WBOOK_RT_MDTINFO 0x884 254 | #define WBOOK_RT_MDXSTR 0x885 255 | #define WBOOK_RT_MDXTUPLE 0x886 256 | #define WBOOK_RT_MDXSET 0x887 257 | #define WBOOK_RT_MDXPROP 0x888 258 | #define WBOOK_RT_MDXKPI 0x889 259 | #define WBOOK_RT_MDTB 0x88A 260 | #define WBOOK_RT_PLV_XLS2007 0x88B 261 | #define WBOOK_RT_COMPAT12 0x88C 262 | #define WBOOK_RT_DXF 0x88D 263 | #define WBOOK_RT_TABLESTYLES 0x88E 264 | #define WBOOK_RT_TABLESTYLE 0x88F 265 | #define WBOOK_RT_TABLESTYLEELEMENT 0x890 266 | #define WBOOK_RT_STYLEEXT 0x892 267 | #define WBOOK_RT_NAMEPUBLISH 0x893 268 | #define WBOOK_RT_NAMECMT 0x894 269 | #define WBOOK_RT_SORTDATA12 0x895 270 | #define WBOOK_RT_THEME 0x896 271 | #define WBOOK_RT_GUIDTYPELIB 0x897 272 | #define WBOOK_RT_FNGRP12 0x898 273 | #define WBOOK_RT_NAMEFNGRP12 0x899 274 | #define WBOOK_RT_MTRSETTINGS 0x89A 275 | #define WBOOK_RT_COMPRESSPICTURES 0x89B 276 | #define WBOOK_RT_HEADERFOOTER 0x89C 277 | #define WBOOK_RT_FORCEFULLCALCULATION 0x8A3 278 | #define WBOOK_RT_LISTOBJ 0x8c1 279 | #define WBOOK_RT_LISTFIELD 0x8c2 280 | #define WBOOK_RT_LISTDV 0x8c3 281 | #define WBOOK_RT_LISTCONDFMT 0x8c4 282 | #define WBOOK_RT_LISTCF 0x8c5 283 | #define WBOOK_RT_FMQRY 0x8c6 284 | #define WBOOK_RT_FMSQRY 0x8c7 285 | #define WBOOK_RT_PLV_MAC11 0x8c8 286 | #define WBOOK_RT_LNEXT 0x8c9 287 | #define WBOOK_RT_MKREXT 0x8ca 288 | #define WBOOK_RT_CRTCOOPT 0x8cb 289 | 290 | // auto-generated chart record types 291 | #define WBOOK_RT_CHUNITS 0x1001 292 | #define WBOOK_RT_CHCHART 0x1002 293 | #define WBOOK_RT_CHSERIES 0x1003 294 | #define WBOOK_RT_CHDATAFORMAT 0x1006 295 | #define WBOOK_RT_CHLINEFORMAT 0x1007 296 | #define WBOOK_RT_CHMARKERFORMAT 0x1009 297 | #define WBOOK_RT_CHAREAFORMAT 0x100A 298 | #define WBOOK_RT_CHPIEFORMAT 0x100B 299 | #define WBOOK_RT_CHATTACHEDLABEL 0x100C 300 | #define WBOOK_RT_CHSERIESTEXT 0x100D 301 | #define WBOOK_RT_CHCHARTFORMAT 0x1014 302 | #define WBOOK_RT_CHLEGEND 0x1015 303 | #define WBOOK_RT_CHSERIESLIST 0x1016 304 | #define WBOOK_RT_CHBAR 0x1017 305 | #define WBOOK_RT_CHLINE 0x1018 306 | #define WBOOK_RT_CHPIE 0x1019 307 | #define WBOOK_RT_CHAREA 0x101A 308 | #define WBOOK_RT_CHSCATTER 0x101B 309 | #define WBOOK_RT_CHCHARTLINE 0x101C 310 | #define WBOOK_RT_CHAXIS 0x101D 311 | #define WBOOK_RT_CHTICK 0x101E 312 | #define WBOOK_RT_CHVALUERANGE 0x101F 313 | #define WBOOK_RT_CHCATSERRANGE 0x1020 314 | #define WBOOK_RT_CHAXISLINEFORMAT 0x1021 315 | #define WBOOK_RT_CHCHARTFORMATLINK 0x1022 316 | #define WBOOK_RT_CHDEFAULTTEXT 0x1024 317 | #define WBOOK_RT_CHTEXT 0x1025 318 | #define WBOOK_RT_CHFONTX 0x1026 319 | #define WBOOK_RT_CHOBJECTLINK 0x1027 320 | #define WBOOK_RT_CHFRAME 0x1032 321 | #define WBOOK_RT_CHBEGIN 0x1033 322 | #define WBOOK_RT_CHEND 0x1034 323 | #define WBOOK_RT_CHPLOTAREA 0x1035 324 | #define WBOOK_RT_CH3D 0x103A 325 | #define WBOOK_RT_CHPICF 0x103C 326 | #define WBOOK_RT_CHDROPBAR 0x103D 327 | #define WBOOK_RT_CHRADAR 0x103E 328 | #define WBOOK_RT_CHSURFACE 0x103F 329 | #define WBOOK_RT_CHRADARAREA 0x1040 330 | #define WBOOK_RT_CHAXISPARENT 0x1041 331 | #define WBOOK_RT_CHLEGENDXN 0x1043 332 | #define WBOOK_RT_CHSHTPROPS 0x1044 333 | #define WBOOK_RT_CHSERTOCRT 0x1045 334 | #define WBOOK_RT_CHAXESUSED 0x1046 335 | #define WBOOK_RT_CHSBASEREF 0x1048 336 | #define WBOOK_RT_CHSERPARENT 0x104A 337 | #define WBOOK_RT_CHSERAUXTREND 0x104B 338 | #define WBOOK_RT_CHIFMT 0x104E 339 | #define WBOOK_RT_CHPOS 0x104F 340 | #define WBOOK_RT_CHALRUNS 0x1050 341 | #define WBOOK_RT_CHAI 0x1051 342 | #define WBOOK_RT_CHSERAUXERRBAR 0x105B 343 | #define WBOOK_RT_CHSERFMT 0x105D 344 | #define WBOOK_RT_CHFBI 0x1060 345 | #define WBOOK_RT_CHBOPPOP 0x1061 346 | #define WBOOK_RT_CHAXCEXT 0x1062 347 | #define WBOOK_RT_CHDAT 0x1063 348 | #define WBOOK_RT_CHPLOTGROWTH 0x1064 349 | #define WBOOK_RT_CHSIINDEX 0x1065 350 | #define WBOOK_RT_CHGELFRAME 0x1066 351 | #define WBOOK_RT_CHBOPPOPCUSTOM 0x1067 352 | 353 | // manually defined BOF types 354 | #define WBOOK_BT_WBGLOBALS 0x05 355 | #define WBOOK_BT_VBMODULE 0x06 356 | #define WBOOK_BT_SHEET 0x10 357 | #define WBOOK_BT_CHART 0x20 358 | #define WBOOK_BT_XCL4MACRO 0x40 359 | #define WBOOK_BT_WORKSPACE 0x100 360 | 361 | // manually defined RK value types 362 | #define WBOOK_RKT_IEEE 0 363 | #define WBOOK_RKT_IEEEx100 1 364 | #define WBOOK_RKT_INT 2 365 | #define WBOOK_RKT_INTx100 3 366 | 367 | 368 | struct WorkbookWSZ 369 | { 370 | USHORT cch; // string length 371 | BYTE grbit; // string options 372 | // char *rgb; // string data (variable fields not included) 373 | }; 374 | 375 | struct WorkbookBOFRecord 376 | { 377 | USHORT _uvers; // Version number (0x0006 for BIFF8) 378 | USHORT _udt; // Substream type 379 | USHORT _urupBuild; // Build identifier (=0DBBh for Excel 97) 380 | USHORT _urupYear; // Build year (=07CCh for Excel 97) 381 | ULONG _ulbfh; // File history flags 382 | ULONG _ulsfo; // Lowest BIFF version 383 | }; 384 | 385 | struct WorkbookFORMATRecord 386 | { 387 | USHORT ifmt; // internal format index 388 | USHORT cch; // length of format string 389 | BYTE grbit; // string options 390 | // char *rgb; // string data (var fields not included) 391 | }; 392 | 393 | struct WorkbookWRITEACCESSRecord7 394 | { 395 | BYTE cch; // Length of user name 396 | BYTE stName[31]; // User name (space padded) 397 | }; 398 | 399 | struct WorkbookWRITEACCESSRecord8 400 | { 401 | USHORT cch; // length of string 402 | BYTE grbit; // string options 403 | BYTE stName[109]; // user name (space padded) 404 | }; 405 | 406 | struct WorkbookBOUNDSHEETRecord 407 | { 408 | ULONG lbPlyPos; // Stream position for BOF 409 | USHORT grbit; // sheet options 410 | BYTE cch; // length of string 411 | BYTE rg_grbit; // (custom adjustment) string options byte 412 | // char *rgch; (var fields not included) 413 | }; 414 | 415 | struct WorkbookFONTRecord 416 | { 417 | USHORT dyHeight; // Height of the font 418 | USHORT grbit; // Font attributes 419 | USHORT icv; // Index to the color palette 420 | USHORT bls; // Bold style 421 | USHORT sss; // Subscript/Superscript 422 | BYTE uls; // Underline style 423 | BYTE bFamily; // Font family 424 | BYTE bCharSet; // Character set 425 | BYTE _reserved; // Reserved 426 | BYTE cch; // Length of the font name 427 | BYTE rg_grbit; // (custom adjustment) string options byte 428 | // char *rgch; // string data (var fields not included) 429 | }; 430 | 431 | struct WorkbookLABELSSTRecord 432 | { 433 | USHORT rw; // Row (0-based) 434 | USHORT col; // Column (0-based) 435 | USHORT ixfe; // Index to XF record 436 | ULONG isst; // Index into the SST record where the string is stored 437 | }; 438 | 439 | struct WorkbookSSTRecord 440 | { 441 | ULONG cstTotal; // Total strings in SST and EXTSST 442 | ULONG cstUnique; // Unique strings in SST 443 | // char *rgb; // array of strings (var fields not included) 444 | }; 445 | 446 | struct WorkbookEXTSSTRecord 447 | { 448 | USHORT Dsst; // Number of strings in each bucket 449 | // struct WorkbookEXTSST_ISSTINF Rgisstinf[]; 450 | // array of ISSTINF structures (var fields not included) 451 | }; 452 | 453 | struct WorkbookEXTSST_ISSTINF 454 | { 455 | ULONG ib; // Stream position of string 456 | USHORT cb; // Offset into SST where bucket begins 457 | USHORT _reserved; // Reserved "must be zero" 458 | }; 459 | 460 | struct WorkbookMULBLANKRecord 461 | { 462 | USHORT rw; // Row number (0-based) 463 | USHORT colFirst; // Column number (0-based) of the first column of the multiple RK record 464 | // variable length rgixfe data - Array of indexes to XF records 465 | USHORT colLast; // Last column containing the BLANKREC structure 466 | }; 467 | 468 | struct WorkbookMULRKRecord 469 | { 470 | USHORT rw; // Row number (0-based) 471 | USHORT colFirst; // Column number (0-based) of the first column of the multiple RK record 472 | // struct WorkbookRKREC rgrkrec[]; 473 | // Array of 6-byte RKREC structures 474 | USHORT colLast; // Last column containing the RKREC structure 475 | }; 476 | 477 | struct WorkbookRKREC 478 | { 479 | USHORT ixfe; // index to XF record 480 | ULONG RK; // RK number 481 | }; 482 | 483 | struct WorkbookRKRecord 484 | { 485 | USHORT rw; // Row number 486 | USHORT col; // Column number 487 | struct WorkbookRKREC rk; // RK data 488 | }; 489 | 490 | 491 | #pragma pack(pop) 492 | 493 | #endif 494 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/auto-gen/gen_tmpls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | 4 | OUTDIR=to_c 5 | 6 | # generate the record define list 7 | awk -F: '{printf "#define WBOOK_RT_"$2" \t"$1"\n"}' xls97-recs.txt > $OUTDIR/record-defs.tmpl 8 | awk -F: '{printf "#define WBOOK_RT_CH"$2" \t"$1"\n"}' xls97-chart-recs.txt > $OUTDIR/chart-defs.tmpl 9 | 10 | # generate long string switch cases 11 | awk -F: '{printf "\t\tcase WBOOK_RT_"$2":\n\t\t\treturn wxT(\""$3"\");\n"}' xls97-recs.txt > $OUTDIR/record_type_long.tmpl 12 | awk -F: '{printf "\t\tcase WBOOK_RT_CH"$2":\n\t\t\treturn wxT(\""$3"\");\n"}' xls97-chart-recs.txt > $OUTDIR/record_type_ch_long.tmpl 13 | 14 | # generate short string switch cases 15 | awk -F: '{printf "\t\tcase WBOOK_RT_"$2":\n\t\t\treturn wxT(\""$2"\");\n"}' xls97-recs.txt > $OUTDIR/record_type_short.tmpl 16 | awk -F: '{printf "\t\tcase WBOOK_RT_CH"$2":\n\t\t\treturn wxT(\"CH"$2"\");\n"}' xls97-chart-recs.txt > $OUTDIR/record_type_ch_short.tmpl 17 | 18 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/auto-gen/xls97-chart-recs.txt: -------------------------------------------------------------------------------- 1 | 0x1001:UNITS:Chart Units 2 | 0x1002:CHART:Location and Overall Chart Dimensions 3 | 0x1003:SERIES:Series Definition 4 | 0x1006:DATAFORMAT:Series and Data Point Numbers 5 | 0x1007:LINEFORMAT:Style of a Line or Border 6 | 0x1009:MARKERFORMAT:Style of a Line Marker 7 | 0x100A:AREAFORMAT:Colors and Patterns for an Area 8 | 0x100B:PIEFORMAT:Position of the Pie Slice 9 | 0x100C:ATTACHEDLABEL:Series Data/Value Labels 10 | 0x100D:SERIESTEXT:Legend/Category/Value Text 11 | 0x1014:CHARTFORMAT:Parent Record for Chart Group 12 | 0x1015:LEGEND:Legend Type and Position 13 | 0x1016:SERIESLIST:Specifies the Series in an Overlay Chart 14 | 0x1017:BAR:Chart Group is a Bar or Column Chart Group 15 | 0x1018:LINE:Chart Group Is a Line Chart Group 16 | 0x1019:PIE:Chart Group Is a Pie Chart Group 17 | 0x101A:AREA:Chart Group Is an Area Chart Group 18 | 0x101B:SCATTER:Chart Group Is a Scatter Chart Group 19 | 0x101C:CHARTLINE:Drop/Hi-Lo/Series Lines on a Line Chart 20 | 0x101D:AXIS:Axis Type 21 | 0x101E:TICK:Tick Marks and Labels Format 22 | 0x101F:VALUERANGE:Defines Value Axis Scale 23 | 0x1020:CATSERRANGE:Defines a Category or Series Axis 24 | 0x1021:AXISLINEFORMAT:Defines a Line That Spans an Axis 25 | 0x1022:CHARTFORMATLINK:Not Used 26 | 0x1024:DEFAULTTEXT:Default Data Label Text Properties 27 | 0x1025:TEXT:Defines Display of Text Fields 28 | 0x1026:FONTX:Font Index 29 | 0x1027:OBJECTLINK:Attaches Text to Chart or to Chart Item 30 | 0x1032:FRAME:Defines Border Shape Around Displayed Text 31 | 0x1033:BEGIN:Defines the Beginning of an Object 32 | 0x1034:END:Defines the End of an Object 33 | 0x1035:PLOTAREA:Frame Belongs to Plot Area 34 | 0x103A:3D:Chart Group Is a 3-D Chart Group 35 | 0x103C:PICF:Picture Format 36 | 0x103D:DROPBAR:Defines Drop Bars 37 | 0x103E:RADAR:Chart Group Is a Radar Chart Group 38 | 0x103F:SURFACE:Chart Group Is a Surface Chart Group 39 | 0x1040:RADARAREA:Chart Group Is a Radar Area Chart Group 40 | 0x1041:AXISPARENT:Axis Size and Location 41 | 0x1043:LEGENDXN:Legend Exception 42 | 0x1044:SHTPROPS:Sheet Properties 43 | 0x1045:SERTOCRT:Series Chart-Group Index 44 | 0x1046:AXESUSED:Number of Axes Sets 45 | 0x1048:SBASEREF:PivotTable Reference 46 | 0x104A:SERPARENT:Trendline or ErrorBar Series Index 47 | 0x104B:SERAUXTREND:Series Trendline 48 | 0x104E:IFMT:Number-Format Index 49 | 0x104F:POS:Position Information 50 | 0x1050:ALRUNS:Text Formatting 51 | 0x1051:AI:Linked Data 52 | 0x105B:SERAUXERRBAR:Series ErrorBar 53 | 0x105D:SERFMT:Series Format 54 | 0x1060:FBI:Font Basis 55 | 0x1061:BOPPOP:Bar of Pie/Pie of Pie Chart Options 56 | 0x1062:AXCEXT:Axis Options 57 | 0x1063:DAT:Data Table Options 58 | 0x1064:PLOTGROWTH:Font Scale Factors 59 | 0x1065:SIINDEX:Series Index 60 | 0x1066:GELFRAME:Fill Data 61 | 0x1067:BOPPOPCUSTOM:Custom Bar of Pie/Pie of Pie Chart Options 62 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/auto-gen/xls97-recs.txt: -------------------------------------------------------------------------------- 1 | 0x0A:EOF:End of File 2 | 0x0C:CALCCOUNT:Iteration Count 3 | 0x0D:CALCMODE:Calculation Mode 4 | 0x0E:PRECISION:Precision 5 | 0x0F:REFMODE:Reference Mode 6 | 0x10:DELTA:Iteration Increment 7 | 0x11:ITERATION:Iteration Mode 8 | 0x12:PROTECT:Protection Flag 9 | 0x13:PASSWORD:Protection Password 10 | 0x14:HEADER:Print Header on Each Page 11 | 0x15:FOOTER:Print Footer on Each Page 12 | 0x16:EXTERNCOUNT:Number of External References 13 | 0x17:EXTERNSHEET:External Reference 14 | 0x19:WINDOWPROTECT:Windows Are Protected 15 | 0x1A:VERTICALPAGEBREAKS:Explicit Column Page Breaks 16 | 0x1B:HORIZONTALPAGEBREAKS:Explicit Row Page Breaks 17 | 0x1C:NOTE:Comment Associated with a Cell 18 | 0x1D:SELECTION:Current Selection 19 | 0x22:1904:1904 Date System 20 | 0x26:LEFTMARGIN:Left Margin Measurement 21 | 0x27:RIGHTMARGIN:Right Margin Measurement 22 | 0x28:TOPMARGIN:Top Margin Measurement 23 | 0x29:BOTTOMMARGIN:Bottom Margin Measurement 24 | 0x2A:PRINTHEADERS:Print Row/Column Labels 25 | 0x2B:PRINTGRIDLINES:Print Gridlines Flag 26 | 0x2F:FILEPASS:File Is Password-Protected 27 | 0x3C:CONTINUE:Continues Long Records 28 | 0x3D:WINDOW1:Window Information 29 | 0x40:BACKUP:Save Backup Version of the File 30 | 0x41:PANE:Number of Panes and Their Position 31 | 0x42:CODENAME:VBE Object Name 32 | 0x42:CODEPAGE:Default Code Page 33 | 0x4D:PLS:Environment-Specific Print Record 34 | 0x50:DCON:Data Consolidation Information 35 | 0x51:DCONREF:Data Consolidation References 36 | 0x52:DCONNAME:Data Consolidation Named References 37 | 0x55:DEFCOLWIDTH:Default Width for Columns 38 | 0x59:XCT:CRN Record Count 39 | 0x5A:CRN:Nonresident Operands 40 | 0x5B:FILESHARING:File-Sharing Information 41 | 0x5C:WRITEACCESS:Write Access User Name 42 | 0x5D:OBJ:Describes a Graphic Object 43 | 0x5E:UNCALCED:Recalculation Status 44 | 0x5F:SAVERECALC:Recalculate Before Save 45 | 0x60:TEMPLATE:Workbook Is a Template 46 | 0x63:OBJPROTECT:Objects Are Protected 47 | 0x7D:COLINFO:Column Formatting Information 48 | 0x7E:RK:Cell Value, RK Number 49 | 0x7F:IMDATA:Image Data 50 | 0x80:GUTS:Size of Row and Column Gutters 51 | 0x81:WSBOOL:Additional Workspace Information 52 | 0x82:GRIDSET:State Change of Gridlines Option 53 | 0x83:HCENTER:Center Between Horizontal Margins 54 | 0x84:VCENTER:Center Between Vertical Margins 55 | 0x85:BOUNDSHEET:Sheet Information 56 | 0x86:WRITEPROT:Workbook Is Write-Protected 57 | 0x87:ADDIN:Workbook Is an Add-in Macro 58 | 0x88:EDG:Edition Globals 59 | 0x89:PUB:Publisher 60 | 0x8C:COUNTRY:Default Country and WIN.INI Country 61 | 0x8D:HIDEOBJ:Object Display Options 62 | 0x90:SORT:Sorting Options 63 | 0x91:SUB:Subscriber 64 | 0x92:PALETTE:Color Palette Definition 65 | 0x94:LHRECORD:.WK? File Conversion Information 66 | 0x95:LHNGRAPH:Named Graph Information 67 | 0x96:SOUND:Sound Note 68 | 0x98:LPR:Sheet Was Printed Using LINE.PRINT( 69 | 0x99:STANDARDWIDTH:Standard Column Widt:9A:FNGROUPNAME:Function Group Name 70 | 0x9B:FILTERMODE:Sheet Contains Filtered List 71 | 0x9C:FNGROUPCOUNT:Built-in Function Group Count 72 | 0x9D:AUTOFILTERINFO:Drop-Down Arrow Count 73 | 0x9E:AUTOFILTER:AutoFilter Data 74 | 0xA0:SCL:Window Zoom Magnification 75 | 0xA1:SETUP:Page Setup 76 | 0xA9:COORDLIST:Polygon Object Vertex Coordinates 77 | 0xAB:GCW:Global Column-Width Flags 78 | 0xAE:SCENMAN:Scenario Output Data 79 | 0xAF:SCENARIO:Scenario Data 80 | 0xB0:SXVIEW:View Definition 81 | 0xB1:SXVD:View Fields 82 | 0xB2:SXVI:View Item 83 | 0xB4:SXIVD:Row/Column Field IDs 84 | 0xB5:SXLI:Line Item Array 85 | 0xB6:SXPI:Page Item 86 | 0xB8:DOCROUTE:Routing Slip Information 87 | 0xB9:RECIPNAME:Recipient Name 88 | 0xBC:SHRFMLA:Shared Formula 89 | 0xBD:MULRK:Multiple RK Cells 90 | 0xBE:MULBLANK:Multiple Blank Cells 91 | 0xC1:MMS:ADDMENU/DELMENU Record Group Count 92 | 0xC2:ADDMENU:Menu Addition 93 | 0xC3:DELMENU:Menu Deletion 94 | 0xC5:SXDI:Data Item 95 | 0xC6:SXDB:PivotTable Cache Data 96 | 0xCD:SXSTRING:String 97 | 0xD0:SXTBL:Multiple Consolidation Source Info 98 | 0xD1:SXTBRGIITM:Page Item Name Count 99 | 0xD2:SXTBPG:Page Item Indexes 100 | 0xD3:OBPROJ:Visual Basic Project 101 | 0xD5:SXIDSTM:Stream ID 102 | 0xD6:RSTRING:Cell with Character Formatting 103 | 0xD7:DBCELL:Stream Offsets 104 | 0xDA:BOOKBOOL:Workbook Option Flag 105 | 0xDC:PARAMQRY:Query Parameters 106 | 0xDC:SXEXT:External Source Information 107 | 0xDD:SCENPROTECT:Scenario Protection 108 | 0xDE:OLESIZE:Size of OLE Object 109 | 0xDF:UDDESC:Description String for Chart Autoformat 110 | 0xE0:XF:Extended Format 111 | 0xE1:INTERFACEHDR:Beginning of User Interface Records 112 | 0xE2:INTERFACEEND:End of User Interface Records 113 | 0xE3:SXVS:View Source 114 | 0xE5:MERGECELLS:Merged Cells 115 | 0xEA:TABIDCONF:Sheet Tab ID of Conflict History 116 | 0xEB:MSODRAWINGGROUP:Microsoft Office Drawing Group 117 | 0xEC:MSODRAWING:Microsoft Office Drawing 118 | 0xED:MSODRAWINGSELECTION:Microsoft Office Drawing Selection 119 | 0xF0:SXRULE:PivotTable Rule Data 120 | 0xF1:SXEX:PivotTable View Extended Information 121 | 0xF2:SXFILT:PivotTable Rule Filter 122 | 0xF4:SXDXF:Pivot Table Formatting 123 | 0xF5:SXITM:Pivot Table Item Indexes 124 | 0xF6:SXNAME:PivotTable Name 125 | 0xF7:SXSELECT:PivotTable Selection Information 126 | 0xF8:SXPAIR:PivotTable Name Pair 127 | 0xF9:SXFMLA:Pivot Table Parsed Expression 128 | 0xFB:SXFORMAT:PivotTable Format Record 129 | 0xFC:SST:Shared String Table 130 | 0xFD:LABELSST:Cell Value, String Constant/SST 131 | 0xFF:EXTSST:Extended Shared String Table 132 | 0x100:SXVDEX:Extended PivotTable View Fields 133 | 0x103:SXFORMULA:PivotTable Formula Record 134 | 0x122:SXDBEX:PivotTable Cache Data 135 | 0x13D:TABID:Sheet Tab Index Array 136 | 0x160:USESELFS:Natural Language Formulas Flag 137 | 0x161:DSF:Double Stream File 138 | 0x162:XL5MODIFY:Flag for DSF 139 | 0x1A5:FILESHARING2:File-Sharing Information for Shared Lists 140 | 0x1A9:USERBVIEW:Workbook Custom View Settings 141 | 0x1AA:USERSVIEWBEGIN:Custom View Settings 142 | 0x1AB:USERSVIEWEND:End of Custom View Records 143 | 0x1AD:QSI:External Data Range 144 | 0x1AE:SUPBOOK:Supporting Workbook 145 | 0x1AF:PROT4REV:Shared Workbook Protection Flag 146 | 0x1B0:CONDFMT:Conditional Formatting Range Information 147 | 0x1B1:CF:Conditional Formatting Conditions 148 | 0x1B2:DVAL:Data Validation Information 149 | 0x1B5:DCONBIN:Data Consolidation Information 150 | 0x1B6:TXO:Text Object 151 | 0x1B7:REFRESHALL:Refresh Flag 152 | 0x1B8:HLINK:Hyperlink 153 | 0x1BB:SXFDBTYPE:SQL Datatype Identifier 154 | 0x1BC:PROT4REVPASS:Shared Workbook Protection Password 155 | 0x1BE:DV:Data Validation Criteria 156 | 0x1C0:EXCEL9FILE:Excel 9 File 157 | 0x1C1:RECALCID:Recalc Information 158 | 0x200:DIMENSIONS:Cell Table Size 159 | 0x201:BLANK:Cell Value, Blank Cell 160 | 0x203:NUMBER:Cell Value, Floating-Point Number 161 | 0x204:LABEL:Cell Value, String Constant 162 | 0x205:BOOLERR:Cell Value, Boolean or Error 163 | 0x207:STRING:String Value of a Formula 164 | 0x208:ROW:Describes a Row 165 | 0x20B:INDEX:Index Record 166 | 0x218:NAME:Defined Name 167 | 0x221:ARRAY:Array-Entered Formula 168 | 0x223:EXTERNNAME:Externally Referenced Name 169 | 0x225:DEFAULTROWHEIGHT:Default Row Height 170 | 0x231:FONT:Font Description 171 | 0x236:TABLE:Data Table 172 | 0x23E:WINDOW2:Sheet Window Information 173 | 0x293:STYLE:Style Information 174 | 0x406:FORMULA:Cell Formula 175 | 0x41E:FORMAT:Number Format 176 | 0x800:HLINKTOOLTIP:Hyperlink Tooltip 177 | 0x801:WEBPUB:Web Publish Item 178 | 0x802:QSISXTAG:PivotTable and Query Table Extensions 179 | 0x803:DBQUERYEXT:Database Query Extensions 180 | 0x804:EXTSTRING:FRT String 181 | 0x805:TXTQUERY:Text Query Information 182 | 0x806:QSIR:Query Table Formatting 183 | 0x807:QSIF:Query Table Field Formatting 184 | 0x809:BOF:Beginning of File 185 | 0x80A:OLEDBCONN:OLE Database Connection 186 | 0x80B:WOPT:Web Options 187 | 0x80C:SXVIEWEX:Pivot Table OLAP Extensions 188 | 0x80D:SXTH:PivotTable OLAP Hierarchy 189 | 0x80E:SXPIEX:OLAP Page Item Extensions 190 | 0x80F:SXVDTEX:View Dimension OLAP Extensions 191 | 0x810:SXVIEWEX9:Pivot Table Extensions 192 | 0x812:CONTINUEFRT:Continued FRT 193 | 0x813:REALTIMEDATA:Real-Time Data (RTD) 194 | 0x862:SHEETEXT:Extra Sheet Info 195 | 0x863:BOOKEXT:Extra Book Info 196 | 0x864:SXADDL:Pivot Table Additional Info 197 | 0x865:CRASHRECERR:Crash Recovery Error 198 | 0x866:HFPicture:Header / Footer Picture 199 | 0x867:FEATHEADR:Shared Feature Header 200 | 0x868:FEAT:Shared Feature Record 201 | 0x86A:DATALABEXT:Chart Data Label Extension 202 | 0x86B:DATALABEXTCONTENTS:Chart Data Label Extension Contents 203 | 0x86C:CELLWATCH:Cell Watc:86d:FEATINFO:Shared Feature Info Record 204 | 0x871:FEATHEADR11:Shared Feature Header 11 205 | 0x872:FEAT11:Shared Feature 11 Record 206 | 0x873:FEATINFO11:Shared Feature Info 11 Record 207 | 0x874:DROPDOWNOBJIDS:Drop Down Object 208 | 0x875:CONTINUEFRT11:Continue FRT 11 209 | 0x876:DCONN:Data Connection 210 | 0x877:LIST12:Extra Table Data Introduced in Excel 2007 211 | 0x878:FEAT12:Shared Feature 12 Record 212 | 0x879:CONDFMT12:Conditional Formatting Range Information 12 213 | 0x87A:CF12:Conditional Formatting Condition 12 214 | 0x87B:CFEX:Conditional Formatting Extension 215 | 0x87C:XFCRC:XF Extensions Checksum 216 | 0x87D:XFEXT:XF Extension 217 | 0x87E:EZFILTER12:AutoFilter Data Introduced in Excel 2007 218 | 0x87F:CONTINUEFRT12:Continue FRT 12 219 | 0x881:SXADDL12:Additional Workbook Connections Information 220 | 0x884:MDTINFO:Information about a Metadata Type 221 | 0x885:MDXSTR:MDX Metadata String 222 | 0x886:MDXTUPLE:Tuple MDX Metadata 223 | 0x887:MDXSET:Set MDX Metadata 224 | 0x888:MDXPROP:Member Property MDX Metadata 225 | 0x889:MDXKPI:Key Performance Indicator MDX Metadata 226 | 0x88A:MDTB:Block of Metadata Records 227 | 0x88B:PLV:Page Layout View Settings in Excel 2007 228 | 0x88C:COMPAT12:Compatibility Checker 12 229 | 0x88D:DXF:Differential XF 230 | 0x88E:TABLESTYLES:Table Styles 231 | 0x88F:TABLESTYLE:Table Style 232 | 0x890:TABLESTYLEELEMENT:Table Style Element 233 | 0x892:STYLEEXT:Named Cell Style Extension 234 | 0x893:NAMEPUBLISH:Publish To Excel Server Data for Name 235 | 0x894:NAMECMT:Name Comment 236 | 0x895:SORTDATA12:Sort Data 12 237 | 0x896:THEME:Theme 238 | 0x897:GUIDTYPELIB:VB Project Typelib GUID 239 | 0x898:FNGRP12:Function Group 240 | 0x899:NAMEFNGRP12:Extra Function Group 241 | 0x89A:MTRSETTINGS:Multi-Threaded Calculation Settings 242 | 0x89B:COMPRESSPICTURES:Automatic Picture Compression Mode 243 | 0x89C:HEADERFOOTER:Header Footer 244 | 0x8A3:FORCEFULLCALCULATION:Force Full Calculation Settings 245 | 0x8c1:LISTOBJ:List Object 246 | 0x8c2:LISTFIELD:List Field 247 | 0x8c3:LISTDV:List Data Validation 248 | 0x8c4:LISTCONDFMT:List Conditional Formatting 249 | 0x8c5:LISTCF:List Cell Formatting 250 | 0x8c6:FMQRY:Filemaker queries 251 | 0x8c7:FMSQRY:File maker queries 252 | 0x8c8:PLV:Page Layout View in Mac Excel 11 253 | 0x8c9:LNEXT:Extension information for borders in Mac Office 11 254 | 0x8ca:MKREXT:Extension information for markers in Mac Office 11 255 | 0x8cb:CRTCOOPT:Color options for Chart series in Mac Office 11 256 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/excel.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {FAE031F5-4305-4113-9E48-91A80763A46C} 15 | excel 16 | 17 | 18 | 19 | DynamicLibrary 20 | true 21 | Unicode 22 | 23 | 24 | DynamicLibrary 25 | false 26 | true 27 | Unicode 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | $(SolutionDir)$(Configuration)\plugins\cbff\ 41 | 42 | 43 | $(SolutionDir)$(Configuration)\plugins\cbff\ 44 | AllRules.ruleset 45 | 46 | 47 | 48 | Level3 49 | Disabled 50 | $(SolutionDir)\libfileDissect;$(SolutionDir)\fileDissect;$(SolutionDir)\fileDissect\plugins\cbff;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 51 | _WINDLL;%(PreprocessorDefinitions) 52 | 53 | 54 | true 55 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 56 | 57 | 58 | 59 | 60 | Level3 61 | MaxSpeed 62 | true 63 | true 64 | $(SolutionDir)\libfileDissect;$(SolutionDir)\fileDissect;$(SolutionDir)\fileDissect\plugins\cbff;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 65 | 66 | 67 | true 68 | true 69 | true 70 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | {02fdd8c6-0ac4-4c61-86aa-283ace914474} 83 | 84 | 85 | {96755f53-5edf-4e34-ab61-b85eb8bde90e} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/excel.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/excel/makefile: -------------------------------------------------------------------------------- 1 | CPP = g++ 2 | CPPFLAGS = -ggdb -fPIC -Wall -Wextra `wx-config --cflags` 3 | FDPATH = ../../../../.. 4 | CBFFPATH = ../.. 5 | INCLUDE = -I$(FDPATH)/fileDissect -I$(FDPATH)/libfileDissect -I$(FDPATH)/libfileDissect/wxFileMap -I$(FDPATH)/wxHexView -I$(FDPATH)/wxPluginLoader \ 6 | -I$(CBFFPATH) 7 | LDFLAGS = -L$(FDPATH)/bin/plugins -lcbff `wx-config --libs` 8 | 9 | BINDIR = $(FDPATH)/bin/plugins/cbff 10 | 11 | 12 | SI = $(BINDIR)/excel.so 13 | SI_OBJS = \ 14 | Workbook.o 15 | 16 | 17 | BINS = $(SI) 18 | 19 | 20 | all: bindir $(BINS) 21 | 22 | bindir: 23 | if test \! -d $(BINDIR); then mkdir $(BINDIR); fi 24 | 25 | 26 | $(SI): $(SI_OBJS) 27 | $(CPP) $(CPPFLAGS) -fpic -shared -o $@ -Wl,-soname,CBFF_SONAME $^ $(LDFLAGS) 28 | 29 | 30 | clean: 31 | rm -f $(SI_OBJS) $(BINS) 32 | 33 | 34 | .cpp.o: 35 | $(CPP) $(CPPFLAGS) $(INCLUDE) -o $@ -c $< 36 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # cbff plugins dir makefile for GCC/G++ 3 | # 4 | 5 | DIRS = summInfo excel 6 | FDPATH = ../../../.. 7 | BINDIR = $(FDPATH)/bin/plugins/cbff 8 | 9 | all: plugins-dir dirs 10 | 11 | plugins-dir: 12 | if test \! -d $(BINDIR); then mkdir $(BINDIR); fi 13 | 14 | dirs: $(DIRS) 15 | for ii in $(DIRS); do \ 16 | make -C $$ii; \ 17 | done 18 | 19 | clean: clean-dirs clean-plugins-dir 20 | 21 | clean-dirs: 22 | for ii in $(DIRS); do \ 23 | make -C $$ii clean; \ 24 | done 25 | 26 | clean-plugins-dir: 27 | if test -d $(BINDIR); then rmdir $(BINDIR); fi 28 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/summInfo/makefile: -------------------------------------------------------------------------------- 1 | CPP = g++ 2 | CPPFLAGS = -ggdb -fPIC -Wall -Wextra `wx-config --cflags` 3 | FDPATH = ../../../../.. 4 | CBFFPATH = ../.. 5 | INCLUDE = -I$(FDPATH)/fileDissect -I$(FDPATH)/libfileDissect -I$(FDPATH)/libfileDissect/wxFileMap -I$(FDPATH)/wxHexView -I$(FDPATH)/wxPluginLoader \ 6 | -I$(CBFFPATH) 7 | LDFLAGS = -L$(FDPATH)/bin/plugins -lcbff `wx-config --libs` 8 | 9 | BINDIR = $(FDPATH)/bin/plugins/cbff 10 | 11 | 12 | SI = $(BINDIR)/summInfo.so 13 | SI_OBJS = \ 14 | summInfo.o 15 | 16 | 17 | BINS = $(SI) 18 | 19 | 20 | all: bindir $(BINS) 21 | 22 | bindir: 23 | if test \! -d $(BINDIR); then mkdir $(BINDIR); fi 24 | 25 | 26 | $(SI): $(SI_OBJS) 27 | $(CPP) $(CPPFLAGS) -fpic -shared -o $@ -Wl,-soname,CBFF_SONAME $^ $(LDFLAGS) 28 | 29 | 30 | clean: 31 | rm -f $(SI_OBJS) $(BINS) 32 | 33 | 34 | .cpp.o: 35 | $(CPP) $(CPPFLAGS) $(INCLUDE) -o $@ -c $< 36 | 37 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/summInfo/summInfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * summinfo.h: 6 | * class implementation for summinfo cbffStreamPlugin class 7 | */ 8 | #include "summInfo.h" 9 | 10 | // Format IDs : windows appears to have these definted in objidl.h 11 | #ifndef __objidl_h__ 12 | CLSID FMTID_SummaryInformation = { 0xf29f85e0, 0x4ff9, 0x1068, { 0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9 } }; 13 | CLSID FMTID_DocSummaryInformation = { 0xd5cdd502, 0x2e9c, 0x101b, { 0x93, 0x97, 0x08, 0x00, 0x2b, 0x2c, 0xf9, 0xae } }; 14 | CLSID FMTID_UserDefinedProperties = { 0xd5cdd505, 0x2e9c, 0x101b, { 0x93, 0x97, 0x08, 0x00, 0x2b, 0x2c, 0xf9, 0xae } }; 15 | #endif 16 | 17 | // map of property types -> property value types 18 | typedef struct __property_type_stru 19 | { 20 | wxChar *name; 21 | ULONG id; 22 | ULONG type; 23 | } propType_t; 24 | 25 | 26 | /* 27 | * http://sedna-soft.de/summary-information-stream/ 28 | * 29 | Property IDs for the section {f29f85e0-4ff9-1068-ab91-08002b27b3d9} 30 | 01 Code page (02) 06 Comments (1e) 0b Last Printed (40) 10 Number of Characters (03) 31 | 02 Title (1e) 07 Template (1e) 0c Create Time/Date (40) 11 Thumbnail (47) 32 | 03 Subject (1e) 08 Last Saved By (1e) 0d Last Saved Time/Date (40) 12 Name of Creating Application (1e) 33 | 04 Author (1e) 09 Revision Number (1e) 0e Number of Pages (03) 13 Security (03) 34 | 05 Keywords (1e) 0a Total Editing Time (40) 0f Number of Words (03) 8000 0000 Locale ID (13) 35 | */ 36 | propType_t summInfoPropIds[] = 37 | { 38 | { wxT("Code Page"), SPT_CODEPAGE, SVT_SHORT }, 39 | { wxT("Title"), SPT_TITLE, SVT_STRING }, 40 | { wxT("Subject"), SPT_SUBJECT, SVT_STRING }, 41 | { wxT("Author"), SPT_AUTHOR, SVT_STRING }, 42 | { wxT("Keywords"), SPT_KEYWORDS, SVT_STRING }, 43 | { wxT("Comments"), SPT_COMMENTS, SVT_STRING }, 44 | { wxT("Template"), SPT_TEMPLATE, SVT_STRING }, 45 | { wxT("Last Saved By"), SPT_LASTAUTHOR, SVT_STRING }, 46 | { wxT("Revision Number"), SPT_REVNUMBER, SVT_STRING }, 47 | { wxT("Total Editing Time"), SPT_EDITTIME, SVT_FILETIME }, 48 | { wxT("Last Printed"), SPT_LASTPRINTED, SVT_FILETIME }, 49 | { wxT("Create Time/Date"), SPT_CREATE_DTM, SVT_FILETIME }, 50 | { wxT("Last Saved Time/Date"), SPT_LASTSAVE_DTM, SVT_FILETIME }, 51 | { wxT("Number of Pages"), SPT_PAGECOUNT, SVT_LONG }, 52 | { wxT("Number of Words"), SPT_WORDCOUNT, SVT_LONG }, 53 | { wxT("Number of Characters"), SPT_CHARCOUNT, SVT_LONG }, 54 | { wxT("Thumbnail"), SPT_THUMBNAIL, SVT_CLIPBOARD }, 55 | { wxT("Name of Creating Application"), 56 | SPT_APPNAME, SVT_STRING }, 57 | { wxT("Security"), SPT_SECURITY, SVT_LONG }, 58 | { wxT("Locale Id"), SPT_LOCALEID, SVT_ULONG }, 59 | { NULL, 0, 0 } 60 | }; 61 | 62 | 63 | summInfo::summInfo(wxLog *plog, fileDissectTreeCtrl *tree) 64 | { 65 | m_log = plog; 66 | wxLog::SetActiveTarget(m_log); 67 | m_tree = tree; 68 | 69 | m_description = wxT("SummaryInformation Stream Dissector"); 70 | m_streams = 0; 71 | } 72 | 73 | 74 | void summInfo::MarkDesiredStreams(void) 75 | { 76 | wxLog::SetActiveTarget(m_log); 77 | 78 | for (cbffStreamList::iterator i = m_streams->begin(); 79 | i != m_streams->end(); 80 | i++) 81 | { 82 | cbffStream *p = (cbffStream *)(*i); 83 | if (p->m_name.Matches(wxT("*SummaryInformation"))) 84 | { 85 | // wxLogMessage(wxT("%s: flagging %s"), wxT("summInfo::MarkDesiredStream()"), p->m_name); 86 | p->m_wanted = true; 87 | } 88 | } 89 | } 90 | 91 | 92 | void summInfo::Dissect(void) 93 | { 94 | // still need to visit all streams to know if we should actually dissect 95 | for (cbffStreamList::iterator i = m_streams->begin(); 96 | i != m_streams->end(); 97 | i++) 98 | { 99 | cbffStream *p = (cbffStream *)(*i); 100 | 101 | if (p->m_name.Matches(wxT("*SummaryInformation"))) 102 | { 103 | // wxLogMessage(wxT("%s: dissecting %s"), wxT("summInfo::MarkDesiredStream()"), p->m_name); 104 | DissectStream(p); 105 | } 106 | } 107 | } 108 | 109 | 110 | void summInfo::DissectStream(cbffStream *pStream) 111 | { 112 | // erm, wtf? 113 | if (!pStream->m_id) 114 | return; 115 | 116 | // Dissect Header 117 | if (pStream->m_length < sizeof(struct SummaryInformationHeader)) 118 | { 119 | wxLogError(wxT("%s: Stream too short (no header)"), wxT("summInfo::DissectStream()")); 120 | return; 121 | } 122 | 123 | // add the header to the tree 124 | struct SummaryInformationHeader *phdr = (struct SummaryInformationHeader *)pStream->m_data; 125 | // XXX: what about tiny tiny mini sector sizes?? 126 | wxFileOffset off = pStream->GetFileOffset(0); 127 | wxTreeItemId hdr_id = m_tree->AppendItem(pStream->m_id, wxT("Header"), -1, -1, 128 | new fdTIData(off, sizeof(struct SummaryInformationHeader))); 129 | m_tree->AppendItem(hdr_id, wxString::Format(wxT("Byte Order: 0x%04x"), phdr->uByteOrder), 130 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(uByteOrder, (*phdr)), FDT_SIZE_OF(uByteOrder, (*phdr)))); 131 | m_tree->AppendItem(hdr_id, wxString::Format(wxT("Reserved: 0x%04x"), phdr->uReserved), 132 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(uReserved, (*phdr)), FDT_SIZE_OF(uReserved, (*phdr)))); 133 | m_tree->AppendItem(hdr_id, wxString::Format(wxT("OS Version: 0x%04x"), phdr->uOSVersion), 134 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(uOSVersion, (*phdr)), FDT_SIZE_OF(uOSVersion, (*phdr)))); 135 | m_tree->AppendItem(hdr_id, wxString::Format(wxT("Platform: 0x%04x"), phdr->uPlatform), 136 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(uPlatform, (*phdr)), FDT_SIZE_OF(uPlatform, (*phdr)))); 137 | m_tree->AppendItem(hdr_id, wxString::Format( 138 | wxT("CLSID: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"), 139 | phdr->clsid.Data1, 140 | phdr->clsid.Data2, 141 | phdr->clsid.Data3, 142 | phdr->clsid.Data4[0], 143 | phdr->clsid.Data4[1], 144 | phdr->clsid.Data4[2], 145 | phdr->clsid.Data4[3], 146 | phdr->clsid.Data4[4], 147 | phdr->clsid.Data4[5], 148 | phdr->clsid.Data4[6], 149 | phdr->clsid.Data4[7]), 150 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(clsid, (*phdr)), FDT_SIZE_OF(clsid, (*phdr)))); 151 | m_tree->AppendItem(hdr_id, wxString::Format(wxT("Section Count: 0x%08x"), phdr->ulSectionCount), 152 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(ulSectionCount, (*phdr)), FDT_SIZE_OF(ulSectionCount, (*phdr)))); 153 | 154 | // validate the data 155 | if (phdr->uByteOrder != 0xfffe) 156 | { 157 | wxLogError(wxT("%s: Unsupported byte order (0x%04x) in section header!"), wxT("summInfo::DissectStream()"), phdr->uByteOrder); 158 | return; 159 | } 160 | if (phdr->uReserved != 0) 161 | { 162 | wxLogError(wxT("%s: The reserved field is non-zero"), wxT("summInfo::DissectStream()")); 163 | return; 164 | } 165 | 166 | // sections 167 | wxTreeItemId sroot_id = m_tree->AppendItem(pStream->m_id, wxT("Sections")); 168 | if (phdr->ulSectionCount == 0) 169 | { 170 | wxLogWarning(wxT("%s: Section count was zero!"), wxT("summInfo::DissectStream()")); 171 | return; 172 | } 173 | 174 | // ensure the section count wont overflow for the check below 175 | if (phdr->ulSectionCount > (0xffffffff / sizeof(struct SummaryInformationSectionDeclaration))) 176 | { 177 | wxLogError(wxT("%s: Section count would cause integer overflow!"), wxT("summInfo::DissectStream()")); 178 | return; 179 | } 180 | ULONG ulSHdrSz = phdr->ulSectionCount * sizeof(struct SummaryInformationSectionDeclaration); 181 | // adding the static size might cause overflow too 182 | if (0xffffffff - ulSHdrSz < sizeof(SummaryInformationHeader)) 183 | { 184 | wxLogError(wxT("%s: Adding header size would cause integer overflow!"), wxT("summInfo::DissectStream()")); 185 | return; 186 | } 187 | ulSHdrSz += sizeof(SummaryInformationHeader); 188 | // make sure there are enough bytes in the stream for the section headers 189 | // NOTE: this doesn't factor in section data 190 | if (pStream->m_length < ulSHdrSz) 191 | { 192 | wxLogError(wxT("%s: Not enough data for section declarations"), wxT("summInfo::DissectStream()")); 193 | return; 194 | } 195 | 196 | // treat this as an array since we know we have enough for the section declarations 197 | struct SummaryInformationSectionDeclaration *psd = (struct SummaryInformationSectionDeclaration *)(pStream->m_data + sizeof(SummaryInformationHeader)); 198 | 199 | // for each section... 200 | ULONG i; 201 | for (i = 0; i < phdr->ulSectionCount; i++) 202 | { 203 | // XXX: what about tiny tiny mini sector sizes?? 204 | off = pStream->GetFileOffset(sizeof(SummaryInformationHeader) + (sizeof(SummaryInformationSectionDeclaration) * i)); 205 | 206 | // ...add a pStream->m_id and... 207 | wxTreeItemId sec_id = m_tree->AppendItem(sroot_id, wxString::Format(wxT("Section %lu"), i)); 208 | wxTreeItemId id = m_tree->AppendItem(sec_id, wxT("Header"), 209 | -1, -1, new fdTIData(off, sizeof(SummaryInformationSectionDeclaration))); 210 | 211 | if (pStream->m_name == wxT("\x05SummaryInformation")) 212 | { 213 | if (memcmp(&FMTID_SummaryInformation, &(psd[i].clsid), sizeof(CLSID)) != 0) 214 | wxLogWarning(wxT("%s: Section %lu CLSID is not FMTID_SummaryInformation!"), wxT("summInfo::DissectStream()"), i); 215 | } 216 | else if (pStream->m_name == (wxT("\x05") wxT("DocumentSummaryInformation"))) 217 | { 218 | if (i == 0 && memcmp(&FMTID_DocSummaryInformation, &(psd[i].clsid), sizeof(CLSID)) != 0) 219 | wxLogWarning(wxT("%s: Section %lu CLSID is not FMTID_DocSummaryInformation!"), wxT("summInfo::DissectStream()"), i); 220 | if (i == 1 && memcmp(&FMTID_UserDefinedProperties, &(psd[i].clsid), sizeof(CLSID)) != 0) 221 | wxLogWarning(wxT("%s: Section %lu CLSID is not FMTID_UserDefinedProperties!"), wxT("summInfo::DissectStream()"), i); 222 | } 223 | 224 | // ...add declaration data... 225 | m_tree->AppendItem(id, wxString::Format( 226 | wxT("CLSID: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"), 227 | psd[i].clsid.Data1, 228 | psd[i].clsid.Data2, 229 | psd[i].clsid.Data3, 230 | psd[i].clsid.Data4[0], 231 | psd[i].clsid.Data4[1], 232 | psd[i].clsid.Data4[2], 233 | psd[i].clsid.Data4[3], 234 | psd[i].clsid.Data4[4], 235 | psd[i].clsid.Data4[5], 236 | psd[i].clsid.Data4[6], 237 | psd[i].clsid.Data4[7]), 238 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(clsid, psd[i]), FDT_SIZE_OF(clsid, psd[i]))); 239 | m_tree->AppendItem(id, wxString::Format(wxT("Offset: 0x%08x"), psd[i].ulOffset), 240 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(ulOffset, psd[i]), FDT_SIZE_OF(ulOffset, psd[i]))); 241 | 242 | // make sure the offset is inside the stream 243 | if (psd[i].ulOffset > pStream->m_length) 244 | { 245 | wxLogError(wxT("%s: Section %lu offset outside of stream!"), wxT("summInfo::DissectStream()"), i); 246 | // go to the next one 247 | continue; 248 | } 249 | if (pStream->m_length - psd[i].ulOffset < sizeof(struct SummaryInformationSectionHeader)) 250 | { 251 | wxLogError(wxT("%s: Not enough space for a section header at section %lu offset"), wxT("summInfo::DissectStream()"), i); 252 | // go to the next one 253 | continue; 254 | } 255 | 256 | // now add the section header data 257 | struct SummaryInformationSectionHeader *pshdr; 258 | pshdr = (struct SummaryInformationSectionHeader *)(pStream->m_data + psd[i].ulOffset); 259 | // XXX: what about tiny tiny mini sector sizes?? 260 | off = pStream->GetFileOffset(psd[i].ulOffset); 261 | id = m_tree->AppendItem(sec_id, wxT("Section Header"), 262 | -1, -1, new fdTIData(off, sizeof(SummaryInformationSectionHeader))); 263 | m_tree->AppendItem(id, wxString::Format(wxT("Length: 0x%08x"), pshdr->ulLength), 264 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(ulLength, (*pshdr)), FDT_SIZE_OF(ulLength, (*pshdr)))); 265 | m_tree->AppendItem(id, wxString::Format(wxT("Property Count: 0x%08x"), pshdr->ulPropertyCount), 266 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(ulPropertyCount, (*pshdr)), FDT_SIZE_OF(ulPropertyCount, (*pshdr)))); 267 | 268 | wxTreeItemId proot_id = m_tree->AppendItem(sec_id, wxT("Properties")); 269 | 270 | // no properties? go to next section 271 | if (pshdr->ulPropertyCount < 1) 272 | { 273 | wxLogWarning(wxT("%s: Section %lu property count was zero!"), wxT("summInfo::DissectStream()"), i); 274 | continue; 275 | } 276 | 277 | // prevent integer overflow with property count 278 | if (pshdr->ulPropertyCount > (0xffffffff / sizeof(struct SummaryInformationPropertyDeclaration))) 279 | { 280 | wxLogError(wxT("%s: Section %lu property count would cause integer overflow!"), wxT("summInfo::DissectStream()"), i); 281 | continue; 282 | } 283 | ULONG ulPHdrSz = pshdr->ulPropertyCount * sizeof(struct SummaryInformationPropertyDeclaration); 284 | if (ulPHdrSz > pStream->m_length) 285 | { 286 | wxLogError(wxT("%s: Not enough data for property declarations in section %lu"), wxT("summInfo::DissectStream()"), i); 287 | continue; 288 | } 289 | 290 | // point to section data! 291 | BYTE *sec_data = pStream->m_data + sizeof(SummaryInformationSectionHeader) + psd[i].ulOffset; 292 | struct SummaryInformationPropertyDeclaration *ppd = (struct SummaryInformationPropertyDeclaration *)sec_data; 293 | 294 | // treat this one as an array since we know we have enough data for the declarations 295 | ULONG j; 296 | for (j = 0; j < pshdr->ulPropertyCount; j++) 297 | { 298 | wxTreeItemId prop_id = m_tree->AppendItem(proot_id, wxString::Format(wxT("Property %lu"), j)); 299 | 300 | // XXX: what about tiny tiny mini sector sizes?? 301 | off = pStream->GetFileOffset(psd[i].ulOffset + sizeof(SummaryInformationSectionHeader) + (sizeof(struct SummaryInformationPropertyDeclaration) * j)); 302 | 303 | id = m_tree->AppendItem(prop_id, wxT("Declaration"), -1, -1, 304 | new fdTIData(off, sizeof(struct SummaryInformationPropertyDeclaration))); 305 | 306 | // XXX: link PropIds arrays to CLSIDs (but have a generic handler for unknown ones) 307 | m_tree->AppendItem(id, wxString::Format(wxT("Id: 0x%08x (%s)"), ppd[j].ulPropertyId, 308 | HumanReadablePropId(ppd[j].ulPropertyId)), 309 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(ulPropertyId, ppd[j]), 310 | FDT_SIZE_OF(ulPropertyId, ppd[j]))); 311 | m_tree->AppendItem(id, wxString::Format(wxT("Offset: 0x%08x"), ppd[j].ulOffset), 312 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(ulOffset, ppd[j]), 313 | FDT_SIZE_OF(ulOffset, ppd[j]))); 314 | 315 | // make sure the offset fits within this section's data 316 | if (ppd[j].ulOffset > pshdr->ulLength) 317 | { 318 | wxLogWarning(wxT("%s: Section %lu property %lu offset (0x%x) out of bounds!"), wxT("summInfo::DissectStream()"), i, j, ppd[j].ulOffset); 319 | continue; 320 | } 321 | if (pshdr->ulLength - ppd[j].ulOffset < sizeof(struct SummaryInformationProperty)) 322 | { 323 | wxLogWarning(wxT("%s: Not enough data for information property in section %lu property %lu"), wxT("summInfo::DissectStream()"), i, j); 324 | continue; 325 | } 326 | 327 | // okay, we have enough for the property 328 | struct SummaryInformationProperty *pprop; 329 | pprop = (struct SummaryInformationProperty *)(pStream->m_data + psd[i].ulOffset + ppd[j].ulOffset); 330 | off = pStream->GetFileOffset(psd[i].ulOffset + ppd[j].ulOffset); 331 | id = m_tree->AppendItem(prop_id, wxT("Property"), -1, -1, 332 | new fdTIData(off, sizeof(struct SummaryInformationProperty))); 333 | 334 | // XXX: link PropIds arrays to CLSIDs (but have a generic handler for unknown ones) 335 | m_tree->AppendItem(id, wxString::Format(wxT("Type: 0x%08x (%s)"), pprop->ulType, 336 | HumanReadablePropType(pprop->ulType)), 337 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(ulType, (*pprop)), 338 | FDT_SIZE_OF(ulType, (*pprop)))); 339 | 340 | // property value 341 | switch (pprop->ulType) 342 | { 343 | case SVT_SHORT: 344 | m_tree->AppendItem(id, wxString::Format(wxT("Value: 0x%04x"), pprop->u.sWord1), 345 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(u.sWord1, (*pprop)), 346 | FDT_SIZE_OF(u.sWord1, (*pprop)))); 347 | break; 348 | 349 | case SVT_LONG: 350 | m_tree->AppendItem(id, wxString::Format(wxT("Value: 0x%08x"), pprop->u.lDword1), 351 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(u.lDword1, (*pprop)), 352 | FDT_SIZE_OF(u.lDword1, (*pprop)))); 353 | break; 354 | 355 | case SVT_ULONG: 356 | m_tree->AppendItem(id, wxString::Format(wxT("Value: 0x%08x"), pprop->u.ulDword1), 357 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(u.ulDword1, (*pprop)), 358 | FDT_SIZE_OF(u.ulDword1, (*pprop)))); 359 | break; 360 | 361 | case SVT_STRING: 362 | m_tree->AppendItem(id, wxString::Format(wxT("Length: 0x%08x"), pprop->u.ulDword1), 363 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(u.ulDword1, (*pprop)), 364 | FDT_SIZE_OF(u.ulDword1, (*pprop)))); 365 | if (pprop->u.ulDword1 > 0 && pprop->u.ulDword1 < pStream->m_length) 366 | { 367 | BYTE *str; 368 | 369 | str = pStream->m_data + psd[i].ulOffset + ppd[j].ulOffset + sizeof(struct SummaryInformationProperty); 370 | off = pStream->GetFileOffset(psd[i].ulOffset + ppd[j].ulOffset + sizeof(struct SummaryInformationProperty)); 371 | wxString strValue = wxT("Value: "); 372 | strValue += wxString::From8BitData((const char *)str, pprop->u.ulDword1); 373 | m_tree->AppendItem(id, strValue, -1, -1, new fdTIData(off, pprop->u.ulDword1)); 374 | } 375 | break; 376 | 377 | case SVT_BLOB: 378 | m_tree->AppendItem(id, wxString::Format(wxT("Length: 0x%08x"), pprop->u.ulDword1), 379 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(u.ulDword1, (*pprop)), 380 | FDT_SIZE_OF(u.ulDword1, (*pprop)))); 381 | if (pprop->u.ulDword1 > 0 && pprop->u.ulDword1 <= pStream->m_length) 382 | { 383 | BYTE *str; 384 | 385 | str = pStream->m_data + psd[i].ulOffset + ppd[j].ulOffset + sizeof(struct SummaryInformationProperty); 386 | off = pStream->GetFileOffset(psd[i].ulOffset + ppd[j].ulOffset + sizeof(struct SummaryInformationProperty)); 387 | 388 | wxString strValue = wxT("Value decoding not supported."); 389 | m_tree->AppendItem(id, strValue, -1, -1, new fdTIData(off, pprop->u.ulDword1)); 390 | } 391 | break; 392 | 393 | case SVT_CLIPBOARD: 394 | m_tree->AppendItem(id, wxString::Format(wxT("Length: 0x%08x"), pprop->u.ulDword1), 395 | -1, -1, new fdTIData(off + FDT_OFFSET_OF(u.ulDword1, (*pprop)), 396 | FDT_SIZE_OF(u.ulDword1, (*pprop)))); 397 | if (pprop->u.ulDword1 > 0 && pprop->u.ulDword1 <= pStream->m_length) 398 | { 399 | ULONG left = pprop->u.ulDword1; 400 | DWORD format; 401 | BYTE *str; 402 | 403 | if (left < sizeof(DWORD)) 404 | { 405 | wxLogWarning(wxT("%s: Not enough data for Clipboard Data in section %lu property %lu"), wxT("summInfo::DissectStream()"), i, j); 406 | break; 407 | } 408 | str = pStream->m_data + psd[i].ulOffset + ppd[j].ulOffset + sizeof(struct SummaryInformationProperty); 409 | off = pStream->GetFileOffset(psd[i].ulOffset + ppd[j].ulOffset + sizeof(struct SummaryInformationProperty)); 410 | 411 | format = *(DWORD *)str; 412 | m_tree->AppendItem(id, wxString::Format(wxT("Format: 0x%08x"), format), 413 | -1, -1, new fdTIData(off, sizeof(DWORD))); 414 | off += sizeof(DWORD); 415 | left -= sizeof(DWORD); 416 | 417 | if (left > 0) 418 | { 419 | wxString strValue = wxT("Value decoding not supported."); 420 | //strValue += wxString::From8BitData((const char *)str, pprop->u.ulDword1); 421 | m_tree->AppendItem(id, strValue, -1, -1, new fdTIData(off, left)); 422 | } 423 | } 424 | break; 425 | 426 | // XXX: add support for more types 427 | case SVT_FILETIME: 428 | default: 429 | m_tree->AppendItem(id, wxT("Unsupported type!")); 430 | break; 431 | 432 | } // end switch 433 | } // end property loop 434 | } // end section loop 435 | } 436 | 437 | 438 | wxChar *summInfo::HumanReadablePropId(ULONG id) 439 | { 440 | ULONG i; 441 | 442 | for (i = 0; summInfoPropIds[i].name; i++) 443 | { 444 | if (summInfoPropIds[i].id == id) 445 | return summInfoPropIds[i].name; 446 | } 447 | return wxT("Unknown"); 448 | } 449 | 450 | 451 | wxChar *summInfo::HumanReadablePropType(ULONG type) 452 | { 453 | switch (type) 454 | { 455 | case SVT_SHORT: 456 | return wxT("Short"); 457 | 458 | case SVT_LONG: 459 | return wxT("Long"); 460 | 461 | case SVT_ULONG: 462 | return wxT("Unsigned Long"); 463 | 464 | case SVT_STRING: 465 | return wxT("String"); 466 | 467 | case SVT_FILETIME: 468 | return wxT("File Time"); 469 | 470 | case SVT_BLOB: 471 | return wxT("BLOB"); 472 | 473 | case SVT_CLIPBOARD: 474 | return wxT("Clipboard"); 475 | } 476 | return wxT("Unknown"); 477 | } 478 | 479 | 480 | 481 | DECLARE_CBF_PLUGIN(summInfo); 482 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/summInfo/summInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Compound Binary File Format implementation 3 | * Joshua J. Drake 4 | * 5 | * summinfo.h: 6 | * class declaration for summinfo cbffStreamPlugin class 7 | */ 8 | #ifndef __summInfo_h_ 9 | #define __summInfo_h_ 10 | 11 | #include "cbffStreamPlugin.h" 12 | #include "cbff_defs.h" 13 | 14 | 15 | class summInfo : public cbffStreamPlugin 16 | { 17 | public: 18 | summInfo(wxLog *plog, fileDissectTreeCtrl *tree); 19 | 20 | // plugin interface methods 21 | void MarkDesiredStreams(void); 22 | void Dissect(void); 23 | // we don't store anything extra, this isn't needed (use default) 24 | // void CloseFile(void); 25 | 26 | private: 27 | void DissectStream(cbffStream *pStream); 28 | 29 | wxChar *HumanReadablePropId(ULONG id); 30 | wxChar *HumanReadablePropType(ULONG type); 31 | }; 32 | 33 | 34 | struct SummaryInformationHeader 35 | { 36 | USHORT uByteOrder; 37 | USHORT uReserved; 38 | USHORT uOSVersion; 39 | USHORT uPlatform; 40 | CLSID clsid; 41 | ULONG ulSectionCount; 42 | }; 43 | 44 | struct SummaryInformationSectionDeclaration 45 | { 46 | CLSID clsid; 47 | ULONG ulOffset; 48 | }; 49 | 50 | struct SummaryInformationSectionHeader 51 | { 52 | ULONG ulLength; 53 | ULONG ulPropertyCount; 54 | }; 55 | 56 | struct SummaryInformationPropertyDeclaration 57 | { 58 | ULONG ulPropertyId; 59 | ULONG ulOffset; 60 | }; 61 | 62 | struct SummaryInformationProperty 63 | { 64 | ULONG ulType; 65 | union 66 | { 67 | ULONG ulDword1; 68 | USHORT uWord1; 69 | SHORT sWord1; 70 | LONG lDword1; 71 | } u; 72 | }; 73 | 74 | 75 | #define SVT_SHORT 0x02 76 | #define SVT_LONG 0x03 77 | #define SVT_ULONG 0x13 78 | #define SVT_STRING 0x1e 79 | #define SVT_FILETIME 0x40 80 | #define SVT_BLOB 0x41 81 | #define SVT_CLIPBOARD 0x47 82 | 83 | 84 | #define SPT_CODEPAGE 0x00000001 85 | #define SPT_TITLE 0x00000002 86 | #define SPT_SUBJECT 0x00000003 87 | #define SPT_AUTHOR 0x00000004 88 | #define SPT_KEYWORDS 0x00000005 89 | #define SPT_COMMENTS 0x00000006 90 | #define SPT_TEMPLATE 0x00000007 91 | #define SPT_LASTAUTHOR 0x00000008 92 | #define SPT_REVNUMBER 0x00000009 93 | #define SPT_EDITTIME 0x0000000A 94 | #define SPT_LASTPRINTED 0x0000000B 95 | #define SPT_CREATE_DTM 0x0000000C 96 | #define SPT_LASTSAVE_DTM 0x0000000D 97 | #define SPT_PAGECOUNT 0x0000000E 98 | #define SPT_WORDCOUNT 0x0000000F 99 | #define SPT_CHARCOUNT 0x00000010 100 | #define SPT_THUMBNAIL 0x00000011 101 | #define SPT_APPNAME 0x00000012 102 | #define SPT_SECURITY 0x00000013 103 | #define SPT_LOCALEID 0x80000000 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/summInfo/summinfo.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 26 | 29 | 32 | 35 | 38 | 41 | 51 | 54 | 57 | 60 | 67 | 70 | 73 | 76 | 79 | 82 | 85 | 88 | 89 | 97 | 100 | 103 | 106 | 109 | 112 | 122 | 125 | 128 | 131 | 140 | 143 | 146 | 149 | 152 | 155 | 158 | 161 | 162 | 163 | 164 | 165 | 166 | 171 | 174 | 175 | 178 | 179 | 182 | 183 | 184 | 189 | 192 | 193 | 194 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/summInfo/summinfo.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {ED6380E9-9EA6-4097-B5BF-7EB6AFA8EE61} 15 | summinfo 16 | 17 | 18 | 19 | DynamicLibrary 20 | Unicode 21 | true 22 | 23 | 24 | DynamicLibrary 25 | Unicode 26 | false 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30319.1 40 | $(SolutionDir)$(Configuration)\plugins\cbff\ 41 | $(Configuration)\ 42 | $(SolutionDir)$(Configuration)\plugins\cbff\ 43 | $(Configuration)\ 44 | MinimumRecommendedRules.ruleset 45 | 46 | 47 | AllRules.ruleset 48 | 49 | 50 | 51 | 52 | 53 | Disabled 54 | $(SolutionDir)\libfileDissect;$(SolutionDir)\fileDissect;$(SolutionDir)\fileDissect\plugins\cbff;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 55 | true 56 | EnableFastChecks 57 | MultiThreadedDebugDLL 58 | Level3 59 | EditAndContinue 60 | _WINDLL;%(PreprocessorDefinitions) 61 | 62 | 63 | $(OutDir)$(TargetName)$(TargetExt) 64 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 65 | true 66 | MachineX86 67 | 68 | 69 | 70 | 71 | MaxSpeed 72 | true 73 | $(SolutionDir)\libfileDissect;$(SolutionDir)\fileDissect;$(SolutionDir)\fileDissect\plugins\cbff;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 74 | MultiThreadedDLL 75 | true 76 | Level3 77 | ProgramDatabase 78 | false 79 | 80 | 81 | $(OutDir)$(TargetName)$(TargetExt) 82 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 83 | true 84 | true 85 | true 86 | MachineX86 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | {02fdd8c6-0ac4-4c61-86aa-283ace914474} 98 | 99 | 100 | {96755f53-5edf-4e34-ab61-b85eb8bde90e} 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /fileDissect/plugins/cbff/plugins/summInfo/summinfo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /fileDissect/plugins/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # fd plugins dir makefile for GCC/G++ 3 | # 4 | 5 | DIRS = cbff 6 | FDPATH = ../.. 7 | BINDIR = $(FDPATH)/bin/plugins 8 | 9 | all: plugins-dir dirs 10 | 11 | plugins-dir: 12 | if test \! -d $(BINDIR); then mkdir $(BINDIR); fi 13 | 14 | 15 | dirs: $(DIRS) 16 | for ii in $(DIRS); do \ 17 | make -C $$ii; \ 18 | done 19 | 20 | clean: clean-dirs clean-plugins-dir 21 | 22 | clean-dirs: 23 | for ii in $(DIRS); do \ 24 | make -C $$ii clean; \ 25 | done 26 | 27 | clean-plugins-dir: 28 | if test -d $(BINDIR); then rmdir $(BINDIR); fi 29 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/makefile: -------------------------------------------------------------------------------- 1 | CPP = g++ 2 | CPPFLAGS = -ggdb -fPIC -Wall -Wextra `wx-config --cflags` 3 | FDPATH = ../../.. 4 | INCLUDE = -I$(FDPATH)/fileDissect -I$(FDPATH)/wxHexView -I$(FDPATH)/wxFileMap -I$(FDPATH)/wxPluginLoader 5 | LDFLAGS = `wx-config --libs` 6 | 7 | BINDIR = $(FDPATH)/bin/plugins 8 | 9 | 10 | PDF = $(BINDIR)/pdf.so 11 | BINS = $(PDF) 12 | PDF_OBJS = \ 13 | pdf.o \ 14 | wxFileMap.o 15 | 16 | 17 | all: plugins-dir $(BINS) 18 | 19 | 20 | $(PDF): $(PDF_OBJS) 21 | $(CPP) $(CPPFLAGS) -fpic -shared -o $@ -Wl,-soname,PDF_SONAME $^ $(LDFLAGS) 22 | 23 | 24 | plugins-dir: 25 | make -C plugins 26 | 27 | 28 | plugins-clean: 29 | make -C plugins clean 30 | 31 | clean: plugins-clean 32 | rm -f $(PDF_OBJS) $(BINS) 33 | rm -f fileDissectSel.cpp wxFileMap.cpp 34 | 35 | 36 | .cpp.o: 37 | $(CPP) $(CPPFLAGS) $(INCLUDE) -o $@ -c $< 38 | 39 | 40 | fileDissectSel.o: fileDissectSel.cpp 41 | fileDissectSel.cpp: 42 | ln -s $(FDPATH)/fileDissect/fileDissectSel.cpp 43 | 44 | 45 | wxHexView.o: wxHexView.cpp 46 | wxHexView.cpp: 47 | ln -s $(FDPATH)/wxHexView/wxHexView.cpp 48 | 49 | wxFileMap.o: wxFileMap.cpp 50 | wxFileMap.cpp: 51 | ln -s $(FDPATH)/wxFileMap/wxFileMap.cpp 52 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adobe Portable Document Format implementation 3 | * Joshua J. Drake 4 | * 5 | * pdf.h: 6 | * class declaration for pdf class 7 | */ 8 | #ifndef __pdf_h_ 9 | #define __pdf_h_ 10 | 11 | #include "fileDissectPlugin.h" 12 | #include "pdf_defs.h" // portable document format 13 | 14 | #include "pdfObjects.h" 15 | 16 | 17 | class pdf : public fileDissectPlugin 18 | { 19 | public: 20 | pdf(wxLog *plog, fileDissectTreeCtrl *tree); 21 | ~pdf(void); 22 | 23 | // plugin member functions 24 | bool SupportsExtension(const wxChar *extension); 25 | void Dissect(void); 26 | void CloseFile(void); 27 | void Destroy(void); 28 | 29 | private: 30 | void DestroyFileData(void); 31 | void InitFileData(void); 32 | 33 | // tree nodes for dissection output 34 | wxTreeItemId m_root_id; 35 | wxTreeItemId m_hdr_id; 36 | wxTreeItemId m_xref_id; 37 | wxTreeItemId m_indobj_id; 38 | 39 | // PDF data items 40 | pdfObjectsHashMap m_objects; 41 | wxFileOffset m_xref_off; 42 | 43 | // we use an indirect object here even though thats not *EXACTLY* what a trailer is... 44 | pdfIndirect *m_trailer; 45 | 46 | // additional dissection routines 47 | bool DissectHeader(void); 48 | bool DissectTrailer(void); 49 | bool DissectXref(wxFileOffset offset = wxInvalidOffset); 50 | bool DissectXrefStm(wxByte *ptr, wxByte *base); 51 | bool DissectObjects(void); 52 | bool DissectStream(pdfIndirect *pObj); 53 | 54 | bool DissectData(wxTreeItemId &parent, pdfIndirect *pObj); 55 | 56 | // private file format functionality 57 | bool ReadIndirect(pdfIndirect *pObj); 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdf.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {E0C417DC-963F-4A01-B603-DF7562A932F9} 15 | pdf 16 | 17 | 18 | 19 | DynamicLibrary 20 | true 21 | Unicode 22 | v110 23 | 24 | 25 | DynamicLibrary 26 | false 27 | true 28 | Unicode 29 | v110 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | $(SolutionDir)$(Configuration)\plugins\ 43 | 44 | 45 | $(SolutionDir)$(Configuration)\plugins\ 46 | AllRules.ruleset 47 | 48 | 49 | 50 | Level3 51 | Disabled 52 | $(SolutionDir)\fileDissect;$(SolutionDir)\libfileDissect;$(SolutionDir)\libfileDissect\wxFileMap;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 53 | ProgramDatabase 54 | _WINDLL_DEBUG;%(PreprocessorDefinitions) 55 | 56 | 57 | true 58 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 59 | 60 | 61 | 62 | 63 | Level3 64 | MaxSpeed 65 | true 66 | true 67 | $(SolutionDir)\fileDissect;$(SolutionDir)\libfileDissect;$(SolutionDir)\libfileDissect\wxFileMap;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 68 | ProgramDatabase 69 | 70 | 71 | true 72 | true 73 | true 74 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | {02fdd8c6-0ac4-4c61-86aa-283ace914474} 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdf.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdfObjects.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Adobe Portable Document Format implementation 3 | * Joshua J. Drake 4 | * 5 | * pdfObject.cpp: 6 | * implementation for pdfObject class 7 | */ 8 | #include "pdfObjects.h" 9 | 10 | #include 11 | WX_DEFINE_LIST(pdfObjectList); 12 | 13 | 14 | pdfObjectBase::pdfObjectBase(void) 15 | { 16 | m_type = PDF_OBJ_BASE; 17 | m_len = 0; 18 | m_ptr = 0; 19 | } 20 | 21 | pdfObjectBase::pdfObjectBase(wxTreeItemId &id, wxByte *ptr) 22 | { 23 | m_type = PDF_OBJ_BASE; 24 | m_len = 0; // dunno yet 25 | m_id = id; 26 | m_ptr = ptr; 27 | } 28 | 29 | pdfObjectBase::pdfObjectBase(wxTreeItemId &id, wxByte *ptr, size_t len) 30 | { 31 | m_type = PDF_OBJ_BASE; 32 | m_len = len; 33 | m_id = id; 34 | m_ptr = ptr; 35 | } 36 | 37 | 38 | pdfArray::~pdfArray(void) 39 | { 40 | pdfObjectList::iterator it, en; 41 | for (it = m_list.begin(), en = m_list.end(); it != en; ++it) 42 | Delete(*it); 43 | m_list.clear(); 44 | } 45 | 46 | 47 | pdfDictionary::~pdfDictionary(void) 48 | { 49 | pdfDictHashMap::iterator it = m_entries.begin(); 50 | pdfDictHashMap::iterator en = m_entries.end(); 51 | for (; it != en; ++it) 52 | { 53 | pdfObjectBase *pObj = (pdfObjectBase *)it->second; 54 | // For some reason, wxHashMap creates keys with NULL values whenever 55 | // you access an element that didn't exist. We can't delete NULL 56 | // so we just skip them.. 57 | if (!pObj) 58 | continue; 59 | Delete(pObj); 60 | } 61 | m_entries.clear(); 62 | } 63 | 64 | 65 | pdfIndirect::pdfIndirect(unsigned long num, unsigned long offset, unsigned long generation) 66 | { 67 | m_type = PDF_OBJ_INDIRECT; 68 | m_length = 0; // dunno yet 69 | 70 | m_data_offset = wxInvalidOffset; 71 | m_data = 0; 72 | m_datalen = 0; 73 | 74 | m_offset = offset; 75 | 76 | m_number = num; 77 | m_generation = generation; 78 | 79 | m_dict = 0; 80 | m_stream = 0; 81 | m_obj = 0; 82 | } 83 | 84 | pdfIndirect::~pdfIndirect(void) 85 | { 86 | if (m_dict) 87 | delete m_dict; 88 | if (m_stream) 89 | delete m_stream; 90 | if (m_obj) 91 | pdfObjectBase::Delete(m_obj); 92 | } 93 | 94 | 95 | void pdfObjectBase::Delete(pdfObjectBase *pObj) 96 | { 97 | switch (pObj->m_type) 98 | { 99 | case PDF_OBJ_STREAM: 100 | delete (pdfStream *)pObj; 101 | break; 102 | 103 | case PDF_OBJ_DICTIONARY: 104 | delete (pdfDictionary *)pObj; 105 | break; 106 | 107 | case PDF_OBJ_INDIRECT: 108 | delete (pdfIndirect *)pObj; 109 | break; 110 | 111 | case PDF_OBJ_ARRAY: 112 | delete (pdfArray *)pObj; 113 | break; 114 | 115 | case PDF_OBJ_LITERAL: 116 | delete (pdfLiteral *)pObj; 117 | break; 118 | 119 | case PDF_OBJ_HEXSTRING: 120 | delete (pdfHexString *)pObj; 121 | break; 122 | 123 | case PDF_OBJ_REFERENCE: 124 | delete (pdfReference *)pObj; 125 | break; 126 | 127 | case PDF_OBJ_NAME: 128 | delete (pdfName *)pObj; 129 | break; 130 | 131 | case PDF_OBJ_REAL: 132 | delete (pdfReal *)pObj; 133 | break; 134 | 135 | case PDF_OBJ_INTEGER: 136 | delete (pdfInteger *)pObj; 137 | break; 138 | 139 | case PDF_OBJ_BOOLEAN: 140 | delete (pdfBoolean *)pObj; 141 | break; 142 | 143 | case PDF_OBJ_NULL: 144 | delete (pdfNull *)pObj; 145 | break; 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdfObjects.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adobe Portable Document Format implementation 3 | * Joshua J. Drake 4 | * 5 | * pdfObject.h: 6 | * class declaration for pdfObject 7 | */ 8 | #ifndef __pdfObject_h_ 9 | #define __pdfObject_h_ 10 | 11 | #include "fileDissect.h" 12 | #include 13 | #include 14 | #include 15 | 16 | #include "pdf_defs.h" 17 | 18 | 19 | // this defines the most basic pdf object 20 | class pdfObjectBase 21 | { 22 | public: 23 | pdfObjectBase(void); 24 | pdfObjectBase(wxTreeItemId &id, wxByte *ptr); 25 | pdfObjectBase(wxTreeItemId &id, wxByte *ptr, size_t len); 26 | 27 | static void Delete(pdfObjectBase *pObj); 28 | 29 | // internal object type, refers to PDF_OBJ_xxx macros 30 | pdfObjType m_type; 31 | 32 | // source data information 33 | wxByte *m_ptr; // the pointer to the start in the filemap 34 | size_t m_len; // the length of this object's source data 35 | 36 | // the node that holds this item in the tree 37 | wxTreeItemId m_id; 38 | }; 39 | 40 | 41 | class pdfStream : public pdfObjectBase 42 | { 43 | public: 44 | pdfStream(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 45 | { 46 | m_type = PDF_OBJ_STREAM; 47 | }; 48 | pdfStream(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 49 | { 50 | m_type = PDF_OBJ_STREAM; 51 | }; 52 | 53 | wxMemoryOutputStream m_decoded; 54 | }; 55 | 56 | 57 | #include 58 | WX_DECLARE_STRING_HASH_MAP(pdfObjectBase *, pdfDictHashMap); 59 | 60 | class pdfDictionary : public pdfObjectBase 61 | { 62 | public: 63 | ~pdfDictionary(void); 64 | pdfDictionary(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 65 | { 66 | m_type = PDF_OBJ_DICTIONARY; 67 | }; 68 | 69 | pdfDictHashMap m_entries; 70 | }; 71 | 72 | 73 | class pdfIndirect : public pdfObjectBase 74 | { 75 | public: 76 | ~pdfIndirect(void); 77 | pdfIndirect(unsigned long num, unsigned long offset, unsigned long generation); 78 | 79 | // for processing 80 | ULONG m_length; // includes obj/endobj stuff 81 | 82 | // data portion 83 | wxFileOffset m_data_offset; 84 | BYTE *m_data; 85 | unsigned long m_datalen; // just the data portion 86 | 87 | // where this object supposedly lives in the file 88 | wxFileOffset m_offset; 89 | 90 | // indirect object specific data 91 | unsigned long m_number; 92 | unsigned long m_generation; 93 | 94 | pdfDictionary *m_dict; 95 | pdfObjectBase *m_obj; 96 | pdfStream *m_stream; 97 | }; 98 | 99 | 100 | // used for tracking nested pdf objects (arrays, dictionaries) 101 | #include 102 | WX_DECLARE_LIST(pdfObjectBase, pdfObjectList); 103 | 104 | class pdfArray : public pdfObjectBase 105 | { 106 | public: 107 | ~pdfArray(void); 108 | pdfArray(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 109 | { 110 | m_type = PDF_OBJ_ARRAY; 111 | }; 112 | 113 | pdfObjectList m_list; 114 | }; 115 | 116 | 117 | // this one is for storing all objects in the file 118 | WX_DECLARE_STRING_HASH_MAP(pdfObjectList *, pdfObjectsHashMap); 119 | 120 | 121 | class pdfLiteral : public pdfObjectBase 122 | { 123 | public: 124 | pdfLiteral(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 125 | { 126 | m_type = PDF_OBJ_LITERAL; 127 | }; 128 | pdfLiteral(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 129 | { 130 | m_type = PDF_OBJ_LITERAL; 131 | m_value = wxString::From8BitData((const char *)ptr, len); 132 | }; 133 | 134 | wxString m_value; 135 | }; 136 | 137 | 138 | class pdfHexString : public pdfObjectBase 139 | { 140 | public: 141 | pdfHexString(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 142 | { 143 | m_type = PDF_OBJ_HEXSTRING; 144 | }; 145 | pdfHexString(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 146 | { 147 | m_type = PDF_OBJ_HEXSTRING; 148 | m_value.From8BitData((const char *)ptr, len); 149 | }; 150 | 151 | wxString m_value; 152 | wxString m_decoded; 153 | }; 154 | 155 | 156 | class pdfReference : public pdfObjectBase 157 | { 158 | public: 159 | pdfReference(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 160 | { 161 | m_type = PDF_OBJ_REFERENCE; 162 | m_refnum = m_refgen = 0xffffffff; 163 | }; 164 | pdfReference(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 165 | { 166 | m_type = PDF_OBJ_REFERENCE; 167 | m_refnum = m_refgen = 0xffffffff; 168 | }; 169 | 170 | unsigned long m_refnum; 171 | unsigned long m_refgen; 172 | }; 173 | 174 | 175 | class pdfName : public pdfObjectBase 176 | { 177 | public: 178 | pdfName(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 179 | { 180 | m_type = PDF_OBJ_NAME; 181 | }; 182 | pdfName(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 183 | { 184 | m_type = PDF_OBJ_NAME; 185 | if (len > 0) 186 | m_value = wxString::From8BitData((const char *)ptr, len); 187 | }; 188 | 189 | wxString m_value; 190 | }; 191 | 192 | 193 | class pdfReal : public pdfObjectBase 194 | { 195 | public: 196 | pdfReal(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 197 | { 198 | m_type = PDF_OBJ_REAL; 199 | m_value = 0; 200 | }; 201 | pdfReal(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 202 | { 203 | m_type = PDF_OBJ_REAL; 204 | m_value = 0; 205 | }; 206 | 207 | double m_value; 208 | }; 209 | 210 | 211 | class pdfInteger : public pdfObjectBase 212 | { 213 | public: 214 | pdfInteger(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 215 | { 216 | m_type = PDF_OBJ_INTEGER; 217 | m_value = 0; 218 | }; 219 | pdfInteger(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 220 | { 221 | m_type = PDF_OBJ_INTEGER; 222 | m_value = 0; 223 | }; 224 | 225 | long m_value; 226 | }; 227 | 228 | 229 | class pdfBoolean : public pdfObjectBase 230 | { 231 | public: 232 | pdfBoolean(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 233 | { 234 | m_type = PDF_OBJ_BOOLEAN; 235 | m_value = false; 236 | }; 237 | pdfBoolean(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 238 | { 239 | m_type = PDF_OBJ_BOOLEAN; 240 | m_value = false; 241 | }; 242 | 243 | bool m_value; 244 | }; 245 | 246 | 247 | class pdfNull : public pdfObjectBase 248 | { 249 | public: 250 | pdfNull(wxTreeItemId &id, wxByte *ptr) : pdfObjectBase(id, ptr) 251 | { 252 | m_type = PDF_OBJ_NULL; 253 | }; 254 | pdfNull(wxTreeItemId &id, wxByte *ptr, size_t len) : pdfObjectBase(id, ptr, len) 255 | { 256 | m_type = PDF_OBJ_NULL; 257 | }; 258 | }; 259 | 260 | 261 | #endif 262 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdfPred.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Adobe Portable Document Format implementation 3 | * Joshua J. Drake 4 | * 5 | * pdfPred.h: 6 | * implementation for pdfPredInputStream class 7 | */ 8 | 9 | #include "pdfPred.h" 10 | 11 | pdfPredInputStream::pdfPredInputStream(wxInputStream& stream, unsigned long type, unsigned long cols) 12 | : wxFilterInputStream(stream), m_prevln(0), 13 | m_cols(cols), m_predictor(type) 14 | { 15 | Init(); 16 | } 17 | 18 | pdfPredInputStream::pdfPredInputStream(wxInputStream *stream, unsigned long type, unsigned long cols) 19 | : wxFilterInputStream(stream), m_prevln(0), 20 | m_cols(cols), m_predictor(type) 21 | { 22 | Init(); 23 | } 24 | 25 | 26 | pdfPredInputStream::~pdfPredInputStream(void) 27 | { 28 | if (m_ln1) 29 | delete[] m_ln1; 30 | if (m_ln2) 31 | delete[] m_ln2; 32 | } 33 | 34 | 35 | void pdfPredInputStream::Init(void) 36 | { 37 | m_ln1 = new wxByte[1 + m_cols]; 38 | m_ln2 = new wxByte[1 + m_cols]; 39 | m_line = m_ln1; 40 | m_ptr = NULL; 41 | } 42 | 43 | 44 | size_t pdfPredInputStream::OnSysRead(void *buffer, size_t size) 45 | { 46 | if (!IsOk() || !size) 47 | return 0; 48 | 49 | wxByte *p_buf = (wxByte *)buffer; 50 | wxByte *p_out = p_buf; 51 | 52 | // what follows is a PNG predictor decoder that won't work well 53 | // XXX: TODO: This only implements PNG Up predictor.. 54 | while ((size_t)(p_out - p_buf) < size && m_parent_i_stream->IsOk()) 55 | { 56 | // do we have some data already ready? 57 | if (m_ptr) 58 | { 59 | while (m_ptr < m_prevln + m_cols + 1 60 | && (size_t)(p_out - p_buf) < size) 61 | *p_out++ = *m_ptr++; 62 | if (m_ptr >= m_prevln + m_cols + 1) 63 | m_ptr = NULL; 64 | } 65 | else 66 | { 67 | // read another scanline of data 68 | m_parent_i_stream->Read(m_line, m_cols + 1); 69 | if (m_parent_i_stream->LastRead() < 1) 70 | break; 71 | 72 | // We don't support changing predictors, nor any others than this one. 73 | if (m_line[0] != 0x02) 74 | break; 75 | 76 | // decode it 77 | if (m_prevln) 78 | { 79 | for (unsigned long j = 1; j < m_cols + 1; j++) 80 | m_line[j] = m_line[j] + m_prevln[j]; 81 | } 82 | 83 | // save the ptr to the data we have ready 84 | m_ptr = m_line + 1; 85 | 86 | // switch line to the other buffer 87 | m_prevln = m_line; 88 | if (m_line == m_ln1) 89 | m_line = m_ln2; 90 | else 91 | m_line = m_ln1; 92 | } 93 | } 94 | if (!m_parent_i_stream->IsOk()) 95 | m_lasterror = wxSTREAM_EOF; 96 | return (p_out - p_buf); 97 | } 98 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdfPred.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adobe Portable Document Format implementation 3 | * Joshua J. Drake 4 | * 5 | * pdfPred.h: 6 | * class declaration for pdfPredInputStream class 7 | */ 8 | #ifndef __pdfPred_h_ 9 | #define __pdfPred_h_ 10 | 11 | #include 12 | 13 | class pdfPredInputStream : public wxFilterInputStream 14 | { 15 | public: 16 | pdfPredInputStream(wxInputStream &, unsigned long, unsigned long); 17 | pdfPredInputStream(wxInputStream *, unsigned long, unsigned long); 18 | ~pdfPredInputStream(); 19 | 20 | private: 21 | void Init(void ); 22 | 23 | wxByte *m_line; 24 | wxByte *m_prevln; 25 | wxByte *m_ln1; 26 | wxByte *m_ln2; 27 | wxByte *m_ptr; 28 | 29 | protected: 30 | size_t OnSysRead(void *buffer, size_t size); 31 | 32 | unsigned long m_cols; 33 | unsigned long m_predictor; 34 | 35 | DECLARE_NO_COPY_CLASS(pdfPredInputStream) 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /fileDissect/plugins/pdf/pdf_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Adobe Portable Document Format implementation 3 | * Joshua J. Drake 4 | * 5 | * pdf_defs.h: 6 | * type declarations for portal documents 7 | */ 8 | #ifndef __pdf_defs_h_ 9 | #define __pdf_defs_h_ 10 | 11 | // types used in struct declarations 12 | #ifdef __WXWINDOWS__ 13 | // yay for wxWidgets 14 | typedef wxByte BYTE; 15 | typedef wxUint16 USHORT; 16 | typedef wxInt16 SHORT; 17 | //typedef wxUint32 ULONG; 18 | //typedef wxInt32 LONG; 19 | #else 20 | // NOTE: these might not be correct (particularly on 64-bit platforms) 21 | typedef unsigned char BYTE; 22 | typedef unsigned short USHORT; 23 | typedef unsigned long ULONG; 24 | typedef short SHORT; 25 | typedef int LONG; 26 | #endif 27 | 28 | 29 | typedef USHORT WORD; 30 | typedef ULONG DWORD; 31 | 32 | 33 | #define PDF_TRAILER_MIN_SIZE 18 // startxref\nN\n%%EOF\n 34 | 35 | #define PDF_WHITESPACE_CHARS "\x00\x09\x0a\x0c\x0d\x20" 36 | #define PDF_WHITESPACE_CHARSLEN 6 37 | 38 | #define PDF_DELIMITERS_CHARS "()<>[]{}/%" 39 | #define PDF_DELIMITERS_CHARSLEN 10 40 | 41 | #define PDF_NAME_DELIM_CHARS (PDF_WHITESPACE_CHARS PDF_DELIMITERS_CHARS) 42 | #define PDF_NAME_DELIM_CHARSLEN (PDF_WHITESPACE_CHARSLEN + PDF_DELIMITERS_CHARSLEN) 43 | 44 | 45 | // types of pdf objects 46 | enum pdfObjType 47 | { 48 | PDF_OBJ_BASE = 0, 49 | PDF_OBJ_NULL, 50 | PDF_OBJ_BOOLEAN, 51 | PDF_OBJ_INTEGER, // 3 52 | PDF_OBJ_REAL, 53 | PDF_OBJ_NAME, 54 | PDF_OBJ_REFERENCE, 55 | PDF_OBJ_HEXSTRING, // 7 56 | PDF_OBJ_LITERAL, 57 | PDF_OBJ_ARRAY, 58 | PDF_OBJ_DICTIONARY, 59 | PDF_OBJ_INDIRECT, 60 | PDF_OBJ_STREAM 61 | }; 62 | 63 | 64 | #pragma pack(push, 1) 65 | 66 | // ... 67 | 68 | #pragma pack(pop) 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /libfileDissect/fileDissectItemData.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectItemData.cpp: 6 | * Tree Item Data code 7 | */ 8 | 9 | #include "fileDissectItemData.h" 10 | 11 | 12 | fdTIData::fdTIData(const wxFileOffset offset_start, const wxFileOffset length) 13 | { 14 | m_selected.AddToSelection(offset_start, offset_start + length); 15 | }; 16 | 17 | 18 | fdTIData::~fdTIData() 19 | { 20 | m_selected.clear(); 21 | } 22 | 23 | 24 | fdTIData::iterator fdTIData::begin(void) 25 | { 26 | return m_selected.begin(); 27 | } 28 | 29 | 30 | fdTIData::iterator fdTIData::end(void) 31 | { 32 | return m_selected.end(); 33 | } 34 | -------------------------------------------------------------------------------- /libfileDissect/fileDissectItemData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectItemData.h: 6 | * tree item data declarations 7 | */ 8 | #ifndef __fileDissectItemData_h_ 9 | #define __fileDissectItemData_h_ 10 | 11 | #include "fileDissectSel.h" 12 | #include 13 | 14 | // macro to calculate the offset into a structure 15 | #define FDT_OFFSET_OF(member,stru) ((wxByte *)&(stru.member) - (wxByte *)&stru) 16 | #define FDT_SIZE_OF(member,stru) (sizeof(stru.member)) 17 | 18 | // macro to make a new item for this structure member 19 | #define FDT_NEW(member,stru) new fdTIData( FDT_OFFSET_OF(member,stru), FDT_SIZE_OF(member,stru)) 20 | #define FDT_NEW_OFF(off,member,stru) new fdTIData( off + FDT_OFFSET_OF(member,stru), FDT_SIZE_OF(member,stru)) 21 | 22 | 23 | /* 24 | * the item data class for our tree 25 | */ 26 | class fdTIData : public wxTreeItemData 27 | { 28 | public: 29 | __declspec(dllexport) fdTIData(const wxFileOffset offset_start, const wxFileOffset length); 30 | __declspec(dllexport) ~fdTIData(); 31 | 32 | typedef fileDissectSelList::iterator iterator; 33 | __declspec(dllexport) iterator begin(void); 34 | __declspec(dllexport) iterator end(void); 35 | 36 | private: 37 | // list of selected bytes 38 | fileDissectSelList m_selected; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /libfileDissect/fileDissectSel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectSel.cpp: 6 | * a list class of selected bytes in a file 7 | */ 8 | #include "fileDissectSel.h" 9 | 10 | // actually define the internal list class 11 | #include 12 | WX_DEFINE_LIST(fileDissectSelListInt); 13 | 14 | 15 | fileDissectSel::fileDissectSel(wxFileOffset start, wxFileOffset end) 16 | : m_start(start), m_end(end) 17 | { 18 | } 19 | 20 | 21 | fileDissectSelList::fileDissectSelList(void) 22 | { 23 | DeleteContents(true); 24 | } 25 | 26 | 27 | fileDissectSelList::~fileDissectSelList(void) 28 | { 29 | } 30 | 31 | 32 | fileDissectSelList::fileDissectSelList(wxFileOffset start, wxFileOffset end) 33 | { 34 | DeleteContents(true); 35 | push_back(new fileDissectSel(start, end)); 36 | } 37 | 38 | 39 | void fileDissectSelList::AddToSelection(wxFileOffset start, wxFileOffset end) 40 | { 41 | push_back(new fileDissectSel(start, end)); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /libfileDissect/fileDissectSel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fileDissect - a cross platform file dissection tool 3 | * Joshua J. Drake 4 | * 5 | * fileDissectSel.h: 6 | * common implmentation for selecting bytes in the file 7 | * 8 | */ 9 | #ifndef __fileDissectSel_h__ 10 | #define __fileDissectSel_h__ 11 | 12 | #ifdef __linux__ 13 | # define __declspec(x) 14 | #endif 15 | 16 | #include 17 | #ifdef __BORLANDC__ 18 | # pragma hdrstop 19 | #endif 20 | #ifndef WX_PRECOMP 21 | # include 22 | #endif 23 | #include 24 | 25 | 26 | // a single selection range 27 | class fileDissectSel 28 | { 29 | public: 30 | fileDissectSel(wxFileOffset start, wxFileOffset end); 31 | 32 | wxFileOffset m_start; 33 | wxFileOffset m_end; 34 | }; 35 | 36 | 37 | // internal list class 38 | WX_DECLARE_LIST(fileDissectSel, fileDissectSelListInt); 39 | 40 | 41 | // value added list class 42 | class fileDissectSelList : public fileDissectSelListInt 43 | { 44 | public: 45 | ~fileDissectSelList(void); 46 | fileDissectSelList(void); 47 | fileDissectSelList(wxFileOffset start, wxFileOffset end); 48 | 49 | void AddToSelection(wxFileOffset start, wxFileOffset end); 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /libfileDissect/libfileDissect.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {02FDD8C6-0AC4-4C61-86AA-283ACE914474} 15 | libfileDissect 16 | 17 | 18 | 19 | DynamicLibrary 20 | true 21 | Unicode 22 | 23 | 24 | DynamicLibrary 25 | false 26 | true 27 | Unicode 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | AllRules.ruleset 41 | 42 | 43 | 44 | Level3 45 | Disabled 46 | $(SolutionDir)\libfileDissect\wxFileMap;$(SolutionDir)\wxHexView;$(SolutionDir)\wxPluginLoader;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 47 | ProgramDatabase 48 | _WINDLL;%(PreprocessorDefinitions) 49 | 50 | 51 | true 52 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 53 | 54 | 55 | 56 | 57 | Level3 58 | MaxSpeed 59 | true 60 | true 61 | $(SolutionDir)\libfileDissect\wxFileMap;$(SolutionDir)\wxHexView;$(SolutionDir)\wxPluginLoader;C:\wxWidgets\include;C:\wxWidgets\include\msvc;%(AdditionalIncludeDirectories) 62 | ProgramDatabase 63 | 64 | 65 | true 66 | true 67 | true 68 | C:\wxWidgets\lib\vc_lib;%(AdditionalLibraryDirectories) 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /libfileDissect/libfileDissect.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /libfileDissect/makefile: -------------------------------------------------------------------------------- 1 | CPP = g++ 2 | CPPFLAGS = -ggdb -fPIC -Wall -Wextra `wx-config --cflags` 3 | FDPATH = .. 4 | INCLUDE = -I$(FDPATH)/fileDissect -IwxFileMap 5 | LDFLAGS = `wx-config --libs` 6 | 7 | BINDIR = $(FDPATH)/bin 8 | 9 | 10 | LIBFD_SONAME=libfileDissect.so 11 | LIBFD = $(BINDIR)/libfileDissect.so 12 | BINS = $(LIBFD) 13 | LIBFD_OBJS = \ 14 | fileDissectItemData.o \ 15 | fileDissectSel.o \ 16 | wxFileMap/wxFileMap.o 17 | 18 | 19 | all: $(BINS) 20 | 21 | 22 | $(LIBFD): $(LIBFD_OBJS) 23 | $(CPP) $(CPPFLAGS) -fpic -shared -o $@ -Wl,-soname,$(LIBFD_SONAME) $^ $(LDFLAGS) 24 | 25 | 26 | clean: 27 | rm -f $(LIBFD_OBJS) $(BINS) 28 | 29 | 30 | .cpp.o: 31 | $(CPP) $(CPPFLAGS) $(INCLUDE) -o $@ -c $< 32 | -------------------------------------------------------------------------------- /libfileDissect/wxFileMap/wxFileMap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * wxFileMap 3 | * cross-platform class for creating a file mapping 4 | * Joshua J. Drake 5 | * 6 | * wxFileMap.cpp: 7 | * implementation details 8 | */ 9 | #include "wxFileMap.h" 10 | 11 | 12 | wxFileMap::wxFileMap (void) 13 | { 14 | m_ptr = NULL; 15 | m_offset = 0; 16 | } 17 | 18 | wxFileMap::~wxFileMap (void) 19 | { 20 | if (m_ptr) 21 | Close(); 22 | m_ptr = NULL; 23 | m_offset = 0; 24 | } 25 | 26 | bool wxFileMap::Open(const wxChar *filename, OpenMode mode, int WXUNUSED(perms)) 27 | { 28 | // open the file 29 | if (!wxFile::Open(filename, mode)) 30 | return false; 31 | 32 | // get the length 33 | m_len = wxFile::Length(); 34 | int fd = wxFile::fd(); 35 | 36 | // windows version 37 | #if defined(__WXMSW__) 38 | HANDLE hFile = (HANDLE)_get_osfhandle(fd); 39 | if (hFile == INVALID_HANDLE_VALUE) 40 | { 41 | wxFile::Close(); 42 | return false; 43 | } 44 | DWORD flProtect = PAGE_READONLY; 45 | if (mode == wxFile::read_write) 46 | flProtect = PAGE_READWRITE; 47 | m_hMap = CreateFileMapping(hFile, NULL, flProtect, m_len >> 32, m_len & 0xffffffff, NULL); 48 | if (m_hMap == NULL) 49 | { 50 | wxFile::Close(); 51 | return false; 52 | } 53 | 54 | DWORD desiredAccess = FILE_MAP_READ; 55 | if (mode == wxFile::read_write) 56 | desiredAccess = FILE_MAP_ALL_ACCESS; 57 | m_ptr = (wxByte *)MapViewOfFile(m_hMap, desiredAccess, 0, 0, 0); 58 | if (!m_ptr) 59 | { 60 | CloseHandle(m_hMap); 61 | wxFile::Close(); 62 | return false; 63 | } 64 | 65 | // *nix version 66 | #elif (defined(__UNIX__) || defined(__GNUWIN32__)) 67 | int prot = PROT_READ; 68 | if (mode == wxFile::read_write) 69 | prot |= PROT_WRITE; 70 | m_ptr = (wxByte *)mmap(NULL, m_len, prot, MAP_PRIVATE, fd, 0); 71 | if (m_ptr == MAP_FAILED) 72 | { 73 | m_ptr = NULL; 74 | wxFile::Close(); 75 | return false; 76 | } 77 | #endif 78 | 79 | m_filename = filename; 80 | return true; 81 | } 82 | 83 | void wxFileMap::Close(void) 84 | { 85 | #ifdef __WXMSW__ 86 | if (m_ptr) 87 | { 88 | UnmapViewOfFile(m_ptr); 89 | CloseHandle(m_hMap); 90 | } 91 | #elif (defined(__UNIX__) || defined(__GNUWIN32__)) 92 | if (m_ptr && munmap(m_ptr, m_len) == -1) 93 | /* need error report */; 94 | #endif 95 | 96 | wxFile::Close(); 97 | m_ptr = NULL; 98 | m_len = m_offset = 0; 99 | } 100 | 101 | 102 | wxByte *wxFileMap::GetBaseAddress() 103 | { 104 | return m_ptr; 105 | } 106 | 107 | wxByte *wxFileMap::GetAddress() 108 | { 109 | return m_ptr + m_offset; 110 | } 111 | 112 | wxFileOffset wxFileMap::Length(void) 113 | { 114 | return m_len; 115 | } 116 | 117 | ssize_t wxFileMap::Read(void *pBuf, size_t nCount) 118 | { 119 | // must have map 120 | if (!m_ptr) 121 | return wxInvalidOffset; 122 | 123 | // offset must be in bounds 124 | if (m_offset < 0 || m_offset > m_len) 125 | return wxInvalidOffset; 126 | 127 | // convert to space after the offset only 128 | wxFileOffset left = m_len - m_offset; 129 | 130 | // must have enough data to cover the entire read 131 | if ((wxFileOffset)nCount > left) 132 | return wxInvalidOffset; 133 | 134 | memcpy(pBuf, m_ptr + m_offset, nCount); 135 | return nCount; 136 | } 137 | 138 | wxFileOffset wxFileMap::Seek(wxFileOffset ofs, wxSeekMode mode) 139 | { 140 | // must have map 141 | if (!m_ptr) 142 | return wxInvalidOffset; 143 | 144 | if (mode == wxFromStart) 145 | { 146 | if (ofs < 0 || ofs > m_len) 147 | return wxInvalidOffset; 148 | m_offset = ofs; 149 | } 150 | else if (mode == wxFromEnd) 151 | { 152 | if (ofs > 0 || (ofs < (-1 * m_len))) 153 | return wxInvalidOffset; 154 | m_offset = m_len + ofs; 155 | } 156 | else 157 | // not implementing other seek modes 158 | return wxInvalidOffset; 159 | 160 | return ofs; 161 | } 162 | 163 | 164 | wxByte *wxFileMap::FindString(const char *str) 165 | { 166 | wxByte *p = m_ptr + m_offset; 167 | wxByte *end = m_ptr + m_len; 168 | size_t len = strlen(str); 169 | 170 | while (1) 171 | { 172 | // find next occurrence of first char 173 | while (p < end && *p != *str) 174 | p++; 175 | // eek! 176 | if (p >= end) 177 | break; 178 | // check if the entire string is there 179 | if (memcmp(p, str, len) == 0) 180 | return p; 181 | // skip current occurrence of byte 182 | p++; 183 | } 184 | 185 | // not found :( 186 | return NULL; 187 | } 188 | 189 | 190 | wxByte *wxFileMap::FindStringReverse(const char *str) 191 | { 192 | size_t len = strlen(str); 193 | wxByte *p = m_ptr + m_offset; 194 | wxByte *end = m_ptr + m_len; 195 | do 196 | { 197 | while (p > m_ptr && *p != *str) 198 | p--; 199 | 200 | if (p <= m_ptr) 201 | return NULL; 202 | 203 | if ((size_t)(end - p) < len) // should be safe, so we cast to get rid of warning 204 | { 205 | // not enough 206 | p--; 207 | continue; 208 | } 209 | 210 | if (memcmp(p, str, len) != 0) 211 | { 212 | // mismatch 213 | p--; 214 | continue; 215 | } 216 | 217 | // got it 218 | break; 219 | } while(1); 220 | 221 | return p; 222 | } 223 | -------------------------------------------------------------------------------- /libfileDissect/wxFileMap/wxFileMap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wxFileMap 3 | * cross-platform class for creating a file mapping 4 | * Joshua J. Drake 5 | * 6 | * wxFileMap.h: 7 | * class declaration 8 | */ 9 | #ifndef __wxFileMap_h_ 10 | #define __wxFileMap_h_ 11 | 12 | #ifdef __linux__ 13 | # define __declspec(x) 14 | #endif 15 | 16 | 17 | // we derive from wxFile 18 | 19 | // For compilers that support precompilation, includes "wx.h". 20 | #include 21 | #ifdef __BORLANDC__ 22 | # pragma hdrstop 23 | #endif 24 | #ifndef WX_PRECOMP 25 | # include 26 | #endif 27 | #include 28 | 29 | // for mapping code 30 | #ifdef __WXMSW__ 31 | # include 32 | #elif (defined(__UNIX__) || defined(__GNUWIN32__)) 33 | # include 34 | #endif 35 | 36 | class wxFileMap : private wxFile 37 | { 38 | public: 39 | __declspec(dllexport) wxFileMap (void); 40 | __declspec(dllexport) ~wxFileMap (void); 41 | 42 | __declspec(dllexport) bool Open(const wxChar *filename, OpenMode mode = read, int perms = wxS_DEFAULT); 43 | __declspec(dllexport) void Close(void); 44 | 45 | __declspec(dllexport) ssize_t Read(void *pBuf, size_t nCount); 46 | __declspec(dllexport) wxFileOffset Seek(wxFileOffset ofs, wxSeekMode mode = wxFromStart); 47 | __declspec(dllexport) wxByte *FindString(const char *str); 48 | __declspec(dllexport) wxByte *FindStringReverse(const char *str); 49 | 50 | __declspec(dllexport) wxByte *GetBaseAddress(void); 51 | __declspec(dllexport) wxByte *GetAddress(void); 52 | __declspec(dllexport) wxFileOffset Length(void); 53 | 54 | wxString m_filename; 55 | 56 | protected: 57 | #ifdef __WXMSW__ 58 | HANDLE m_hMap; 59 | #endif 60 | wxByte *m_ptr; 61 | wxFileOffset m_len; 62 | wxFileOffset m_offset; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # 2 | # top level makefile for GCC/G++ 3 | # 4 | 5 | CPP = g++ 6 | 7 | DIRS = fileDissect 8 | 9 | all: dirs 10 | 11 | dirs: $(DIRS) 12 | for ii in $(DIRS); do \ 13 | make -C $$ii; \ 14 | done 15 | 16 | clean: clean-dirs 17 | 18 | clean-dirs: 19 | for ii in $(DIRS); do \ 20 | make -C $$ii clean; \ 21 | done 22 | -------------------------------------------------------------------------------- /wxHexView/wxHexView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * wxHexView 3 | * 4 | * a wxWidgets based Hex Viewer 5 | * 6 | * (c) 2007-2009 Joshua J. Drake 7 | */ 8 | #include "wxHexView.h" 9 | 10 | BEGIN_EVENT_TABLE(wxHexView, wxWindow) 11 | EVT_SIZE(wxHexView::OnSize) 12 | EVT_PAINT(wxHexView::OnPaint) 13 | EVT_COMMAND_SCROLL(IDC_VSCROLL, wxHexView::OnVScroll) 14 | EVT_MOUSEWHEEL(wxHexView::OnMouseWheel) 15 | END_EVENT_TABLE() 16 | 17 | 18 | #include 19 | WX_DEFINE_LIST(selectionList); 20 | 21 | 22 | wxHexView::wxHexView(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) 23 | : wxWindow(parent, id, pos, size, style) 24 | { 25 | // delete the items we destroy the list 26 | m_selection.DeleteContents(true); 27 | 28 | m_data = NULL; 29 | m_datalen = 0; 30 | m_curLine = 0; 31 | m_numLines = 0; 32 | m_visibleLines = 0; 33 | 34 | m_width = m_height = 0; 35 | 36 | m_cliBitmap = NULL; 37 | 38 | m_txtbg = new wxColor((unsigned long)0xffffff); // white 39 | m_txtfg = new wxColor((unsigned long)0); // black 40 | 41 | // XXX: TODO: allow font choice 42 | m_font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT); 43 | m_font.SetPointSize(8); 44 | wxWindow::SetFont(m_font); 45 | 46 | m_vscroll = NULL; 47 | m_vscroll = new wxScrollBar(this, IDC_VSCROLL, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL); 48 | 49 | // set the new window size 50 | int x_size = (8 + 1 + (8 * 3) + 1 + (8 * 3) + 1 + 16); 51 | m_charheight = wxWindow::GetCharHeight(); 52 | m_charwidth = wxWindow::GetCharWidth() - 1; 53 | x_size *= m_charwidth; 54 | 55 | #ifdef USE_HEXDIGITBITMAP_OPTIMIZATION 56 | // init the hexdigits bitmap 57 | int i, hw; 58 | wxString str(wxT('0')); 59 | hw = m_charwidth * 16; 60 | m_hexdigits = new wxBitmap(hw, m_charheight); 61 | m_hexDC.SelectObject(*m_hexdigits); 62 | // clear the background 63 | m_hexDC.SetBrush(*wxTheBrushList->FindOrCreateBrush(*m_txtbg)); 64 | m_hexDC.SetPen(*wxThePenList->FindOrCreatePen(*m_txtbg, 1, wxSOLID)); 65 | m_hexDC.DrawRectangle(0, 0, hw, m_charheight); 66 | // set the foreground pen/font 67 | m_hexDC.SetPen(*wxThePenList->FindOrCreatePen(*m_txtfg, 1, wxSOLID)); 68 | m_hexDC.SetFont(m_font); 69 | // draw the digits 70 | for (i = 0; i < 16; i++) 71 | { 72 | if (i < 10) 73 | str.SetChar(0, i + '0'); 74 | else 75 | str.SetChar(0, i - 10 + 'a'); 76 | m_hexDC.DrawText(str, (i * m_charwidth), 0); 77 | } 78 | #endif 79 | 80 | // set size 81 | wxSize sz(x_size + 18, -1); 82 | SetMinSize(sz); 83 | SetSize(sz); 84 | 85 | // set scroll bar position 86 | wxPoint pt(x_size, 0); 87 | m_vscroll->SetPosition(pt); 88 | m_vscroll->SetScrollbar(0, 0, 0, 0); 89 | } 90 | 91 | wxHexView::~wxHexView() 92 | { 93 | // caller is responsible for free'n data 94 | m_data = NULL; 95 | 96 | if (m_cliBitmap) 97 | delete m_cliBitmap; 98 | delete m_txtbg; 99 | delete m_txtfg; 100 | } 101 | 102 | void wxHexView::OnPaint(wxPaintEvent& WXUNUSED(evt)) 103 | { 104 | wxPaintDC dc(this); 105 | wxMemoryDC memdc; 106 | memdc.SelectObject(*m_cliBitmap); 107 | 108 | if (m_repaint) 109 | { 110 | // draw the text background 111 | memdc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*m_txtbg)); 112 | memdc.SetPen(*wxThePenList->FindOrCreatePen(*m_txtbg, 1, wxSOLID)); 113 | memdc.DrawRectangle(0, 0, m_width, m_height); 114 | 115 | #ifndef USE_HEXDIGITBITMAP_OPTIMIZATION 116 | // draw the text 117 | memdc.SetPen(*wxThePenList->FindOrCreatePen(*m_txtfg, 1, wxSOLID)); 118 | memdc.SetFont(m_font); 119 | 120 | wxString str; 121 | #endif 122 | 123 | /* process all lines */ 124 | int offset = m_curLine * 16; 125 | wxCoord out_y; 126 | int idx; 127 | 128 | // are we starting with selected text? 129 | bool selected = false; 130 | if (offset > 0) 131 | { 132 | for (selectionList::const_iterator i = m_selection.begin(); 133 | i != m_selection.end(); 134 | i++) 135 | { 136 | wxHexViewSelection *p = (*i); 137 | if (p->m_start < offset) 138 | selected = true; 139 | if (p->m_end <= offset) 140 | selected = false; 141 | if (p->m_start >= offset 142 | && p->m_end >= offset) 143 | // neither are less.. we found out! 144 | break; 145 | } 146 | } 147 | 148 | #ifdef USE_HEXDIGITBITMAP_OPTIMIZATION 149 | int tmp_off, char_off; 150 | #endif 151 | for (out_y = 0; out_y < m_height; out_y += m_charheight) 152 | { 153 | #ifdef USE_HEXDIGITBITMAP_OPTIMIZATION 154 | // paint the offset hex digits 155 | tmp_off = offset; 156 | for (idx = 7; idx >= 0; --idx) 157 | { 158 | char_off = tmp_off & 0xf; 159 | memdc.Blit((idx * m_charwidth), out_y, 160 | m_charwidth, m_charheight, 161 | &m_hexDC, 162 | (char_off * m_charwidth), 0); 163 | tmp_off >>= 4; 164 | } 165 | 166 | // not much faster, gave up on this 167 | #else 168 | /* for each line, draw the offset... */ 169 | str = wxString::Format(wxT("%08x "), offset); 170 | wxCoord hex_start = m_charwidth * 9; 171 | wxCoord ascii_start = hex_start + (((3 * 8) * 2) + 1) * m_charwidth; 172 | 173 | /* must have data to continue */ 174 | if (m_data && m_datalen > 0) 175 | { 176 | /* ...the hex data... */ 177 | for (idx = 0; idx < 16; idx++) 178 | { 179 | if (offset + idx < m_datalen) 180 | str += wxString::Format(wxT("%02x "), m_data[offset + idx]); 181 | else 182 | str += wxT(" "); 183 | // add a space after the first 8 184 | if (idx == 7) 185 | str.Append(wxT(' ')); 186 | } 187 | 188 | /* ...and the ascii representation */ 189 | wxString tmp = wxT("."); 190 | for (idx = 0; idx < 16; idx++) 191 | { 192 | if (offset + idx < m_datalen) 193 | { 194 | wxByte ch = m_data[offset + idx]; 195 | /* 196 | * this is the old way, this causes alignment problems with some chars 197 | * 198 | tmp.SetChar(0, ch); 199 | str += tmp; 200 | */ 201 | if (ch > 0x1f && ch < 0x7f) 202 | str.Append(ch); 203 | else 204 | str.Append(wxT('.')); 205 | } 206 | } 207 | } 208 | 209 | memdc.DrawText(str, 0, out_y); 210 | 211 | // invert highlighted parts in this line 212 | if (m_data && m_datalen > 0) 213 | { 214 | // start and stop selection characters for this line 215 | int selChLeft = -1; 216 | int selChRight = -1; 217 | 218 | // if we are already selecting at line start, note it 219 | if (selected) 220 | selChLeft = 0; 221 | 222 | // see if we have selections starting/stopping on this line 223 | for (selectionList::const_iterator i = m_selection.begin(); 224 | i != m_selection.end(); 225 | i++) 226 | { 227 | wxHexViewSelection *p = (*i); 228 | 229 | // XXX: what about multiple start/top in a line? 230 | 231 | // is the start of the selection in this line? 232 | if (selChLeft == -1) 233 | if (p->m_start >= offset && p->m_start < offset + 16) 234 | selChLeft = p->m_start - offset; 235 | 236 | // does it stop on this line? 237 | if (selChRight == -1) 238 | if (p->m_end > offset && p->m_end <= offset + 16) 239 | selChRight = p->m_end - offset; 240 | } 241 | 242 | // what kind of selection actions are on this line? 243 | if (selChLeft != -1 && selChRight != -1) // both stop and start! 244 | { 245 | // start first, or stop first? 246 | if (selChLeft > selChRight) 247 | { 248 | // stop first (two selection bits) 249 | wxCoord l, r; 250 | 251 | // select 0 -> new end 252 | 253 | // hex part 254 | l = hex_start; 255 | r = hex_start + (selChRight * 3 * m_charwidth); 256 | if (selChRight <= 8) 257 | r -= m_charwidth; 258 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 259 | 260 | // ascii part 261 | l = ascii_start; 262 | r = ascii_start + (selChRight * m_charwidth); 263 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 264 | 265 | // select new start -> end 266 | 267 | // hex part 268 | l = hex_start + (selChLeft * 3 * m_charwidth); 269 | if (selChLeft > 7) 270 | l += m_charwidth; 271 | r = ascii_start - m_charwidth; 272 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 273 | 274 | // ascii part 275 | l = ascii_start + (selChLeft * m_charwidth); 276 | r = ascii_start + (16 * m_charwidth); 277 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 278 | } 279 | else if (selChLeft < selChRight) 280 | { 281 | // start first, select start -> end 282 | wxCoord l, r; 283 | 284 | // hex part 285 | l = hex_start + (selChLeft * 3 * m_charwidth); 286 | if (selChLeft > 7) 287 | l += m_charwidth; 288 | r = hex_start + (selChRight * 3 * m_charwidth); 289 | if (selChRight <= 8) 290 | r -= m_charwidth; 291 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 292 | 293 | // ascii part 294 | l = ascii_start + (selChLeft * m_charwidth); 295 | r = ascii_start + (selChRight * m_charwidth); 296 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 297 | 298 | // not selected anymore 299 | selected = false; 300 | } 301 | // ==? no action. 302 | } 303 | else if (!selected && selChLeft != -1 && selChRight == -1) // start only 304 | { 305 | // select from sel start to end 306 | wxCoord l, r; 307 | 308 | // hex part 309 | l = hex_start + (selChLeft * 3 * m_charwidth); 310 | if (selChLeft > 7) 311 | l += m_charwidth; 312 | r = ascii_start - m_charwidth; 313 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 314 | 315 | // ascii part 316 | l = ascii_start + (selChLeft * m_charwidth); 317 | r = ascii_start + (16 * m_charwidth); 318 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 319 | 320 | selected = true; 321 | } 322 | else if (selected && selChLeft == -1 && selChRight != -1) // stop only 323 | { 324 | // select from start to sel stop 325 | wxCoord l, r; 326 | 327 | // hex part 328 | l = hex_start; 329 | r = hex_start + (selChRight * 3 * m_charwidth); 330 | if (selChRight <= 8) 331 | r -= m_charwidth; 332 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 333 | 334 | // ascii part 335 | l = ascii_start; 336 | r = ascii_start + (selChRight * m_charwidth); 337 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 338 | 339 | selected = false; 340 | } 341 | else if (selected) 342 | { 343 | // if we're selected, select the entire line 344 | wxCoord l, r; 345 | 346 | // hex part 347 | l = hex_start; 348 | r = ascii_start - m_charwidth; 349 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 350 | 351 | // ascii part 352 | l = ascii_start; 353 | r = ascii_start + (16 * m_charwidth); 354 | memdc.Blit(l, out_y, r-l, m_charheight, &memdc, 0, 0, wxINVERT); 355 | } 356 | } 357 | #endif 358 | offset += 16; // bytes per line 359 | } 360 | m_repaint = false; 361 | } 362 | 363 | dc.Blit(0, 0, m_width, m_height, &memdc, 0, 0); 364 | } 365 | 366 | void wxHexView::OnSize(wxSizeEvent &evt) 367 | { 368 | int w, h; 369 | 370 | GetClientSize(&w, &h); 371 | if (w != m_width 372 | || h != m_height) 373 | { 374 | m_width = w; 375 | m_height = h; 376 | 377 | delete m_cliBitmap; 378 | m_cliBitmap = NULL; 379 | } 380 | m_visibleLines = m_height / m_charheight; 381 | 382 | if (!m_cliBitmap) 383 | m_cliBitmap = new wxBitmap(w, h); 384 | 385 | // GetSize(&w, &h); 386 | 387 | UpdateScrollBar(); 388 | 389 | m_repaint = true; 390 | Refresh(false); 391 | 392 | evt.Skip(); 393 | } 394 | 395 | 396 | void wxHexView::SetData(wxByte *ptr, wxFileOffset len) 397 | { 398 | m_data = ptr; 399 | m_datalen = len; 400 | m_numLines = m_datalen / 16; 401 | if (m_datalen % 16) 402 | m_numLines++; 403 | UpdateScrollBar(); 404 | 405 | // GotoLine refreshes the display 406 | GotoLine(0); 407 | } 408 | 409 | 410 | void wxHexView::GotoLine(unsigned int line) 411 | { 412 | // don't move below the last "page" 413 | if (m_numLines > m_visibleLines) 414 | { 415 | if (line > m_numLines - m_visibleLines) 416 | line = m_numLines - m_visibleLines; 417 | } 418 | 419 | m_curLine = line; 420 | m_vscroll->SetThumbPosition(line); 421 | Redraw(); 422 | } 423 | 424 | 425 | void wxHexView::GotoOffset(wxFileOffset offset) 426 | { 427 | // don't move the screen if the line is already onscreen 428 | unsigned int line = offset / 16; 429 | if (line < m_curLine 430 | || line > m_curLine + m_visibleLines) 431 | GotoLine(offset / 16); 432 | } 433 | 434 | 435 | // update the scroll bar 436 | void wxHexView::UpdateScrollBar() 437 | { 438 | // only update/show it if there's more lines than the visible height 439 | if (m_vscroll) 440 | { 441 | m_vscroll->SetSize(16, m_height); 442 | m_vscroll->SetScrollbar(0, m_visibleLines, m_numLines, m_visibleLines - 1); 443 | if (m_numLines > m_visibleLines) 444 | m_vscroll->Enable(true); 445 | else 446 | m_vscroll->Enable(false); 447 | } 448 | } 449 | 450 | 451 | void wxHexView::OnVScroll(wxScrollEvent &evt) 452 | { 453 | unsigned int pos = evt.GetPosition(); 454 | 455 | if (pos == m_curLine) 456 | return; 457 | GotoLine(pos); 458 | } 459 | 460 | 461 | void wxHexView::OnMouseWheel(wxMouseEvent &evt) 462 | { 463 | int th_size = m_vscroll->GetThumbSize(); 464 | int th_max = m_vscroll->GetRange(); 465 | 466 | if (th_max <= th_size) 467 | return; 468 | 469 | int th_cur = m_vscroll->GetThumbPosition(); 470 | 471 | if (evt.m_wheelRotation > 0) 472 | { 473 | // scroll up 474 | if (th_cur > th_size) 475 | th_cur -= th_size; 476 | else 477 | th_cur = 0; 478 | } 479 | else 480 | { 481 | // scroll down 482 | if (th_cur < th_max - (th_size * 2)) 483 | th_cur += th_size; 484 | else 485 | th_cur = th_max - th_size; 486 | } 487 | if (th_cur == (int)m_curLine) 488 | return; 489 | 490 | GotoLine(th_cur); 491 | } 492 | 493 | 494 | void wxHexView::AddToSelection(wxFileOffset start, wxFileOffset end) 495 | { 496 | m_selection.push_back(new wxHexViewSelection(start, end)); 497 | } 498 | 499 | void wxHexView::ClearSelection(void) 500 | { 501 | m_selection.clear(); 502 | } 503 | 504 | void wxHexView::Redraw(void) 505 | { 506 | m_repaint = true; 507 | Refresh(); 508 | } 509 | -------------------------------------------------------------------------------- /wxHexView/wxHexView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wxHexView 3 | * 4 | * a wxWidgets based Hex Viewer 5 | * 6 | * (c) 2007-2009 Joshua J. Drake 7 | */ 8 | #ifndef __wxHexView_h_ 9 | #define __wxHexView_h_ 10 | 11 | #include 12 | #ifdef __BORLANDC__ 13 | # pragma hdrstop 14 | #endif 15 | #ifndef WX_PRECOMP 16 | # include 17 | #endif 18 | #include 19 | 20 | 21 | class wxHexViewSelection 22 | { 23 | public: 24 | wxHexViewSelection(wxFileOffset start, wxFileOffset end) 25 | : m_start(start), m_end(end) 26 | { 27 | }; 28 | 29 | wxFileOffset m_start; 30 | wxFileOffset m_end; 31 | }; 32 | 33 | // list of selected bytes 34 | WX_DECLARE_LIST(wxHexViewSelection, selectionList); 35 | 36 | 37 | class wxHexView : public wxWindow 38 | { 39 | public: 40 | wxHexView(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSIMPLE_BORDER|wxWANTS_CHARS); 41 | ~wxHexView(void); 42 | void SetData(wxByte *ptr, wxFileOffset len); 43 | void GotoLine(unsigned int line); 44 | void GotoOffset(wxFileOffset offset); 45 | void AddToSelection(wxFileOffset start, wxFileOffset end); 46 | void ClearSelection(void); 47 | void Redraw(void); 48 | 49 | private: 50 | // the painted area 51 | bool m_repaint; 52 | wxBitmap *m_cliBitmap; 53 | int m_width; 54 | int m_height; 55 | 56 | // font stuff 57 | wxFont m_font; 58 | int m_charheight; 59 | int m_charwidth; 60 | 61 | #ifdef USE_HEXDIGITBITMAP_OPTIMIZATION 62 | // hexdigit painting optimization 63 | wxBitmap *m_hexdigits; 64 | wxMemoryDC m_hexDC; 65 | #endif 66 | 67 | // scroll bars! 68 | wxScrollBar *m_vscroll; 69 | 70 | // colors! 71 | wxColor *m_txtbg; 72 | wxColor *m_txtfg; 73 | 74 | // the data 75 | wxByte *m_data; 76 | wxFileOffset m_datalen; 77 | unsigned int m_curLine; 78 | unsigned int m_numLines; 79 | unsigned int m_visibleLines; 80 | 81 | // selection info 82 | selectionList m_selection; 83 | 84 | protected: 85 | void OnPaint(wxPaintEvent &evt); 86 | void OnSize(wxSizeEvent &evt); 87 | void OnVScroll(wxScrollEvent &evt); 88 | void OnMouseWheel(wxMouseEvent &evt); 89 | 90 | void UpdateScrollBar(void); 91 | 92 | private: 93 | DECLARE_EVENT_TABLE() 94 | }; 95 | 96 | #define IDC_VSCROLL 5000 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /wxPluginLoader/wxPluginLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Basic plugin loader class -- derive from me! 3 | * Joshua J. Drake 4 | * 5 | * wxPluginLoader.h: 6 | * 7 | */ 8 | #ifndef __wxPluginLoader_h_ 9 | #define __wxPluginLoader_h_ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef __WXMSW__ 17 | typedef HMODULE libhandle_t; 18 | #define WXPLL_CLOSE FreeLibrary 19 | #define WXPLL_EXT wxT("dll"); 20 | #define WXPLL_LOAD(p) LoadLibrary(p) 21 | #define WXPLL_LOOKUP GetProcAddress 22 | #define WXPLL_LOADERRMSG(x) wxString errMsg = wxT("Unknown error") 23 | #else 24 | #include 25 | 26 | typedef void * libhandle_t; 27 | #define WXPLL_CLOSE dlclose 28 | #define WXPLL_EXT wxT("so"); 29 | #define WXPLL_LOAD(p) dlopen((const char *)p,RTLD_NOW) 30 | #define WXPLL_LOOKUP dlsym 31 | #define WXPLL_LOADERRMSG(x) const char *perr = (const char *)dlerror(); \ 32 | if (!perr) perr = "Unknown error"; \ 33 | wxString errMsg(perr, wxConvLibc, wxSTRING_MAXLEN) 34 | #endif 35 | 36 | 37 | 38 | 39 | #define WX_DECLARE_PLUGINLIST(apiclass, lcname) \ 40 | typedef apiclass *(*pfn##apiclass)(wxLog *plog, fileDissectTreeCtrl *tree); \ 41 | \ 42 | class apiclass##__Module \ 43 | { \ 44 | public: \ 45 | apiclass##__Module(wxString &fname, libhandle_t h, pfn##apiclass ci, apiclass *ph) \ 46 | : m_filename(fname), m_handle(h), m_create_instance(ci), m_instance(ph) { }; \ 47 | ~apiclass##__Module(void) { \ 48 | if (m_instance) delete m_instance; \ 49 | if (m_handle) WXPLL_CLOSE(m_handle); \ 50 | }; \ 51 | wxString m_filename; \ 52 | libhandle_t m_handle; \ 53 | pfn##apiclass m_create_instance; \ 54 | apiclass *m_instance; \ 55 | }; \ 56 | WX_DECLARE_LIST(apiclass##__Module, apiclass##__List); \ 57 | class lcname \ 58 | { \ 59 | public: \ 60 | lcname(void) { \ 61 | m_list.DeleteContents(true); \ 62 | wxString path = wxT("."); \ 63 | }; \ 64 | void LoadPlugins(wxString &path, wxLog *plog, fileDissectTreeCtrl *tree) \ 65 | { \ 66 | m_list.clear(); \ 67 | wxDir dir(path); \ 68 | if (!dir.IsOpened()) return; \ 69 | wxString filespec(wxT("*.")); \ 70 | filespec += WXPLL_EXT; \ 71 | wxString fname; \ 72 | bool cont = dir.GetFirst(&fname, filespec, wxDIR_FILES | wxDIR_HIDDEN); \ 73 | while (cont) { \ 74 | wxString fullpath = path + fname; \ 75 | pfn##apiclass pfn; \ 76 | apiclass *ph = 0; \ 77 | libhandle_t h; \ 78 | if (!(h = WXPLL_LOAD(fullpath.fn_str()))) \ 79 | { \ 80 | WXPLL_LOADERRMSG(""); \ 81 | wxLogError(wxT("Unable to load plugin \"%s\": %s"), \ 82 | fname.c_str(), errMsg.c_str()); \ 83 | cont = dir.GetNext(&fname); \ 84 | continue; \ 85 | } \ 86 | if (!(pfn = (pfn##apiclass)WXPLL_LOOKUP(h, "create_instance"))) \ 87 | { \ 88 | WXPLL_CLOSE(h); \ 89 | wxLogError(wxT("Invalid plugin \"%s\": Unable to lookup export"), fname.c_str()); \ 90 | cont = dir.GetNext(&fname); \ 91 | continue; \ 92 | } \ 93 | if (!(ph = pfn(plog, tree))) \ 94 | { \ 95 | WXPLL_CLOSE(h); \ 96 | wxLogError(wxT("Invalid plugin \"%s\": Object factory failed"), fname.c_str()); \ 97 | cont = dir.GetNext(&fname); \ 98 | continue; \ 99 | } \ 100 | m_list.push_back(new apiclass##__Module(fname, h, pfn, ph)); \ 101 | wxLogMessage(wxT("Registered support for \"%s\" (%s)"), \ 102 | ph->m_description, fname.c_str()); \ 103 | \ 104 | cont = dir.GetNext(&fname); \ 105 | } \ 106 | }; \ 107 | typedef apiclass##__List::iterator iterator; \ 108 | iterator begin() { return m_list.begin(); } \ 109 | iterator end() { return m_list.end(); } \ 110 | apiclass##__List m_list; \ 111 | }; 112 | 113 | #define WX_DEFINE_PLUGINLIST(apiclass) \ 114 | WX_DEFINE_LIST(apiclass##__List); 115 | 116 | #endif 117 | --------------------------------------------------------------------------------