feat: logiciel permettant d'explorer les ressources d'un exécutable au format CE (sections, importations, exportations)

This commit is contained in:
Nicolas Hordé 2007-03-17 11:48:35 +00:00
parent d539bd2d8c
commit fe2558dda0
10 changed files with 1917 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

BIN
outils/CE explorer/imgs.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -0,0 +1,139 @@
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.06.00"/>
<PROJECT value="Project1.exe"/>
<OBJFILES value="Project1.obj Unit1.obj"/>
<RESFILES value="Project1.res"/>
<IDLFILES value=""/>
<IDLGENFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES) Unit1.dfm"/>
<LIBFILES value=""/>
<LIBRARIES value="rtl.lib vcl.lib"/>
<SPARELIBS value="vcl.lib rtl.lib"/>
<PACKAGES value="vcl.bpi rtl.bpi dbrtl.bpi adortl.bpi vcldb.bpi vclx.bpi bdertl.bpi
ibxpress.bpi dsnap.bpi cds.bpi bdecds.bpi qrpt.bpi teeui.bpi teedb.bpi
tee.bpi vcldbx.bpi dss.bpi teeqr.bpi visualclx.bpi visualdbclx.bpi
dsnapcrba.bpi dsnapcon.bpi bcbsmp.bpi vclie.bpi xmlrtl.bpi inet.bpi
inetdbbde.bpi inetdbxpress.bpi inetdb.bpi nmfast.bpi webdsnap.bpi
bcbie.bpi websnap.bpi soaprtl.bpi dclocx.bpi dbexpress.bpi dbxcds.bpi
indy.bpi bcb2kaxserver.bpi OpenGLPanel_DP.bpi IcsBcb60.bpi ZComponent.bpi
ZPlain.bpi ZCore.bpi ZDbc.bpi ZParseSql.bpi"/>
<PATHCPP value=".;"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="ilink32"/>
<USERDEFINES value=""/>
<SYSDEFINES value="_RTLDLL;NO_STRICT"/>
<MAINSOURCE value="Project1.cpp"/>
<INCLUDEPATH value="D:\CBuilder6\Bin;&quot;C:\Documents and Settings\admin\Bureau\perso\cos\CE explorer&quot;;$(BCB)\include;$(BCB)\include\vcl"/>
<LIBPATH value="D:\CBuilder6\Bin;&quot;C:\Documents and Settings\admin\Bureau\perso\cos\CE explorer&quot;;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w-par"/>
<OTHERFILES value=""/>
</MACROS>
<OPTIONS>
<IDLCFLAGS value="-ID:\CBuilder6\Bin
-I&quot;C:\Documents and Settings\admin\Bureau\perso\cos\CE explorer&quot;
-I$(BCB)\include -I$(BCB)\include\vcl -src_suffix cpp -boa"/>
<CFLAG1 value="-O2 -H=$(BCB)\lib\vcl60.csm -Hc -Vx -Ve -X- -a8 -b- -k- -vi -c -tW -tWM"/>
<PFLAGS value="-$Y- -$L- -$D- -$A8 -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zn"/>
<LFLAGS value="-D&quot;&quot; -aa -Tpe -x -Gn"/>
<OTHERFILES value=""/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0w32.obj Memmgr.Lib sysinit.obj $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib"/>
<OTHERFILES value=""/>
</LINKER>
<FILELIST>
<FILE FILENAME="Project1.res" FORMNAME="" UNITNAME="Project1.res" CONTAINERID="ResTool" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="Project1.cpp" FORMNAME="" UNITNAME="Project1" CONTAINERID="CCompiler" DESIGNCLASS="" LOCALCOMMAND=""/>
<FILE FILENAME="Unit1.cpp" FORMNAME="Form1" UNITNAME="Unit1" CONTAINERID="CCompiler" DESIGNCLASS="" LOCALCOMMAND=""/>
</FILELIST>
<BUILDTOOLS>
</BUILDTOOLS>
<IDEOPTIONS>
[Version Info]
IncludeVerInfo=1
AutoIncBuild=1
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1036
CodePage=1252
[Version Info Keys]
CompanyName=COS2000
FileDescription=Cos2000 lib explorer
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=Cos2000 lib explorer
ProductVersion=1.0.0.0
Comments=FOR CE ONLY
[Excluded Packages]
..\lib\DragDrop_B5.bpl=(untitled)
..\lib\Moje_B5.bpl=(untitled)
..\lib\DriveDir_B5.bpl=(untitled)
..\lib\tb2k_cb6.bpl=(untitled)
..\lib\tb2kdsgn_cb6.bpl=(untitled)
..\lib\tbx_cb6.bpl=(untitled)
..\lib\tbxdsgn_cb6.bpl=(untitled)
d:\cbuilder6\Bin\dclite60.bpl=Borland Integrated Translation Environment
[HistoryLists\hlIncludePath]
Count=1
Item0=D:\CBuilder6\Bin;C:\Documents and Settings\admin\Bureau\perso\cos\CE explorer;$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=1
Item0=D:\CBuilder6\Bin;C:\Documents and Settings\admin\Bureau\perso\cos\CE explorer;$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[Debugging]
DebugSourceDirs=$(BCB)\source\vcl
[Parameters]
RunParams=
Launcher=
UseLauncher=0
DebugCWD=
HostApplication=
RemoteHost=
RemotePath=
RemoteLauncher=
RemoteCWD=
RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
LinkCGLIB=0
[CORBA]
AddServerUnit=1
AddClientUnit=1
PrecompiledHeaders=1
</IDEOPTIONS>
</PROJECT>

View File

@ -0,0 +1,34 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("Unit1.cpp", Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->Title = "CE explorer";
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
catch (...)
{
try
{
throw Exception("");
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
}
return 0;
}
//---------------------------------------------------------------------------

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,273 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#include <math.h>
#include <stdio.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
tree(AnsiString file,int offset,TTreeNode* rootnode)
{
FILE* in;
#pragma option -a1
struct CE {
char checks[2];
unsigned char major;
unsigned int checksum;
unsigned char compressed;
unsigned short exports;
unsigned short imports;
unsigned short sections;
unsigned short starting;
} myce;
#pragma option -a
long pointeur=0;
if ((in = fopen(file.c_str(), "rb"))!= NULL)
{
fseek(in, pointeur+offset, SEEK_SET);
fread(&myce, sizeof(myce), 1, in);
TTreeNode* currentnode;
TTreeNode* subcurrentnode;
TTreeNode* subsubcurrentnode;
if (offset==0)
{
fseek(in, 0L, SEEK_END);
Form1->TreeView->Items->AddChild(rootnode,"Adresse réelle: 0x0000")->ImageIndex=31;
Form1->TreeView->Items->AddChild(rootnode,"Adresse : 0x0000")->ImageIndex=31;
}
currentnode=Form1->TreeView->Items->AddChild(rootnode,"Entête");
currentnode->ImageIndex=10;
Form1->TreeView->Items->AddChild(currentnode,"Adresse réelle: 0x"+IntToHex((int)pointeur+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(currentnode,"Adresse : 0x"+IntToHex((int)pointeur,4))->ImageIndex=31;
if (AnsiString(myce.checks,2)!="CE")
{
rootnode->ImageIndex=4;
Form1->TreeView->Items->AddChild(currentnode,"Type : ceci n'est pas un fichier CE")->ImageIndex=1;
}
else
{
rootnode->ImageIndex=2;
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Type : "+AnsiString(myce.checks,2));
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)0+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)0,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0002")->ImageIndex=31;
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Version : "+IntToStr(myce.major));
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)2+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)2,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0001")->ImageIndex=31;
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Checksum : 0x"+IntToHex((int)myce.checksum,8));
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)3+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)3,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0004")->ImageIndex=31;
if (myce.compressed>=1)
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Fichier compressé avec RIP");
else
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Fichier sans compression");
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)7+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)7,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0001")->ImageIndex=31;
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Pointeur exportation : 0x"+IntToHex(myce.exports,4));
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)8+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)8,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0002")->ImageIndex=31;
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Pointeur Importation : 0x"+IntToHex(myce.imports,4));
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)10+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)10,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0002")->ImageIndex=31;
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Pointeur sections : 0x"+IntToHex(myce.sections,4));
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)12+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)12,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0002")->ImageIndex=31;
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,"Point d'entrée : 0x"+IntToHex(myce.starting,4));
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex((int)14+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex((int)14,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille: 0x0002")->ImageIndex=31;
Form1->TreeView->Items->AddChild(currentnode,"Taille : 0x0010")->ImageIndex=31;
char imported[30];
AnsiString imports[30]={""};
AnsiString exports[30]={""};
AnsiString sections[30]={""};
unsigned short iaddrs[30]={0};
unsigned short eaddrs[30]={0};
unsigned short saddrs[30]={0};
unsigned short ssize[30]={0};
AnsiString libraries[30]={""};
AnsiString alib;
int i=0;
pointeur=myce.imports;
int nblib=0;
int nbimp=0;
if (myce.imports!=0)
{
currentnode=Form1->TreeView->Items->AddChild(rootnode,"Importations");
currentnode->ImageIndex=14;
Form1->TreeView->Items->AddChild(currentnode,"Adresse réelle: 0x"+IntToHex((int)pointeur+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(currentnode,"Adresse : 0x"+IntToHex((int)pointeur,4))->ImageIndex=31;
do
{
fseek(in, pointeur+offset, SEEK_SET);
fread(&imported, sizeof(imported), 1, in);
imports[i]=AnsiString((char*)&imported);
iaddrs[i]=pointeur;
pointeur+=imports[i].Length()+5;
alib=imports[i].SubString(0,imports[i].Pos(":")-1);
int j;
for(j=0;(j<nblib)&&(alib!=libraries[j])&&(libraries[j]!="");j++);
if ((libraries[j]=="")&&(alib!="")) {
libraries[j]=alib;
nblib++;
}
i++;
} while(imports[i-1]!="");
nbimp=i-1;
for(int i=0;i<nblib;i++)
{
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,libraries[i]);
subcurrentnode->ImageIndex=13;
for(int j=0;j<nbimp;j++)
{
if (imports[j].SubString(0,imports[j].Pos(":")-1)==libraries[i])
{
subsubcurrentnode=Form1->TreeView->Items->AddChild(subcurrentnode,imports[j].SubString(imports[j].Pos(":")+2,255));
subsubcurrentnode->ImageIndex=3;
Form1->TreeView->Items->AddChild(subsubcurrentnode,"Adresse réelle: 0x"+IntToHex((int)iaddrs[j]+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subsubcurrentnode,"Adresse : 0x"+IntToHex((int)iaddrs[j],4))->ImageIndex=31;
}
}
}
currentnode->Text="importations ("+IntToStr(nbimp)+"/"+IntToStr(nblib)+")";
Form1->TreeView->Items->AddChild(currentnode,"Taille : 0x"+IntToHex((int)pointeur-myce.imports,4))->ImageIndex=31;
}
else
{
nbimp=0;
}
i=0;
pointeur=myce.exports;
int nbexp=0;
if (myce.exports!=0)
{
currentnode=Form1->TreeView->Items->AddChild(rootnode,"Exportations");
currentnode->ImageIndex=14;
Form1->TreeView->Items->AddChild(currentnode,"Adresse réelle: 0x"+IntToHex((int)pointeur+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(currentnode,"Adresse : 0x"+IntToHex((int)pointeur,4))->ImageIndex=31;
do
{
fseek(in, pointeur+offset, SEEK_SET);
fread(&imported, sizeof(imported), 1, in);
exports[i]=AnsiString((char*)&imported);
pointeur+=exports[i].Length()+1;
fseek(in, pointeur+offset, SEEK_SET);
fread(&eaddrs[i],sizeof(eaddrs[i]),1,in);
pointeur+=2;
i++;
} while(exports[i-1]!="");
nbexp=i-1;
for(int i=0;i<nbexp;i++)
{
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,exports[i]);
subcurrentnode->ImageIndex=3;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex(eaddrs[i]+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex(eaddrs[i],4))->ImageIndex=31;
}
currentnode->Text="exportations ("+IntToStr(nbexp)+")";
Form1->TreeView->Items->AddChild(currentnode,"Taille : 0x"+IntToHex((int)pointeur-myce.exports,4))->ImageIndex=31;
}
else
{
nbexp=0;
}
pointeur=myce.sections;
i=0;
int nbsec=0;
if (myce.sections!=0)
{
currentnode=Form1->TreeView->Items->AddChild(rootnode,"Sections");
currentnode->ImageIndex=12;
Form1->TreeView->Items->AddChild(currentnode,"Adresse réelle: 0x"+IntToHex((int)pointeur+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(currentnode,"Adresse : 0x"+IntToHex((int)pointeur,4))->ImageIndex=31;
do
{
fseek(in, pointeur+offset, SEEK_SET);
fread(&saddrs[i],sizeof(saddrs[i]),1,in);
pointeur+=2;
fseek(in, pointeur+offset, SEEK_SET);
fread(&ssize[i],sizeof(ssize[i]),1,in);
pointeur+=2;
fseek(in, pointeur+offset, SEEK_SET);
fread(&imported, sizeof(imported), 1, in);
sections[i]=AnsiString((char*)&imported);
pointeur+=sections[i].Length()+1;
i++;
} while(ssize[i-1]!=0);
nbsec=i-1;
for(int i=0;i<nbsec;i++)
{
subcurrentnode=Form1->TreeView->Items->AddChild(currentnode,sections[i]);
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse réelle: 0x"+IntToHex(saddrs[i]+offset,4))->ImageIndex=31;
Form1->TreeView->Items->AddChild(subcurrentnode,"Adresse : 0x"+IntToHex(saddrs[i],4))->ImageIndex=31;
if (saddrs[i]!=0) tree(file,saddrs[i],subcurrentnode);
subcurrentnode->ImageIndex=2;
Form1->TreeView->Items->AddChild(subcurrentnode,"Taille : 0x"+IntToHex(ssize[i],4))->ImageIndex=31;
}
Form1->TreeView->Items->AddChild(currentnode,"Taille : 0x"+IntToHex((int)pointeur-myce.sections,4))->ImageIndex=31;
currentnode->Text="Sections ("+IntToStr(nbsec)+")";
}
else
{
nbsec=0;
}
if (offset==0)
{
fseek(in, 0L, SEEK_END);
int size = ftell(in);
Form1->TreeView->Items->AddChild(rootnode,"Taille : 0x"+IntToHex(size,4))->ImageIndex=31;
}
}
fclose(in);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Ouvrir1Click(TObject *Sender)
{
if (OpenDialog->Execute())
tree(OpenDialog->FileName,0,Form1->TreeView->Items->Add(Form1->TreeView->Items->GetFirstNode(),ExtractFileName(OpenDialog->FileName)));
TTreeNode* node=Form1->TreeView->Items->GetFirstNode();
while(node!=NULL)
{
node->SelectedIndex=node->ImageIndex;
node=node->GetNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Quitter1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------

Binary file not shown.

1434
outils/CE explorer/unit1.dfm Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Menus.hpp>
#include <Dialogs.hpp>
#include <ComCtrls.hpp>
#include <ImgList.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TMainMenu *MainMenu1;
TMenuItem *Fichier1;
TMenuItem *Ouvrir1;
TOpenDialog *OpenDialog;
TTreeView *TreeView;
TImageList *ImageList;
TMenuItem *N1;
TMenuItem *Quitter1;
TRichEdit *RichEdit1;
void __fastcall Ouvrir1Click(TObject *Sender);
void __fastcall Quitter1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif