Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
horsicq committed Dec 11, 2019
1 parent 5c70d39 commit d67f79c
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 11 deletions.
37 changes: 34 additions & 3 deletions xbinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ QString XBinary::convertFileName(QString sFileName)
return sFileName;
}

QString XBinary::convertPathName(QString sPathName)
{
QString sResult=sPathName;

if(sPathName.contains("$app"))
{
sResult.replace("$app",QCoreApplication::applicationDirPath());
sResult.replace("/",QDir::separator());
}

return sResult;
}

//void XBinary::findFiles(QString sDirectoryName, QList<QString> *pListFileNames)
//{
// if((sDirectoryName!=".")&&(sDirectoryName!=".."))
Expand Down Expand Up @@ -1935,15 +1948,15 @@ QSet<XBinary::FT> XBinary::getFileTypes()
{
if(((XMACH_DEF::mach_header *)pOffset)->filetype<0xFFFF)
{
stResult.insert(FT_MACH);

if((((XMACH_DEF::mach_header *)pOffset)->magic==XMACH_DEF::S_MH_MAGIC)||(((XMACH_DEF::mach_header *)pOffset)->magic==XMACH_DEF::S_MH_CIGAM))
{
stResult.insert(FT_MACH);
stResult.insert(FT_MACH32);
}
else if((((XMACH_DEF::mach_header *)pOffset)->magic==XMACH_DEF::S_MH_MAGIC_64)||(((XMACH_DEF::mach_header *)pOffset)->magic==XMACH_DEF::S_MH_CIGAM_64))
{
stResult.insert(FT_MACH32);
stResult.insert(FT_MACH);
stResult.insert(FT_MACH64);
}
}
}
Expand Down Expand Up @@ -3292,6 +3305,24 @@ QString XBinary::getStringCollision(QList<QString> *pListStrings, QString sStrin
return sResult;
}

bool XBinary::writeToFile(QString sFileName, QByteArray baData)
{
bool bResult=false;

QFile file;
file.setFileName(sFileName);

if(file.open(QIODevice::ReadWrite))
{
file.write(baData.data(),baData.size());

file.close();
bResult=true;
}

return bResult;
}

QList<XBinary::SIGNATURE_RECORD> XBinary::getSignatureRecords(QString sSignature)
{
QList<SIGNATURE_RECORD> result;
Expand Down
4 changes: 4 additions & 0 deletions xbinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QSet>
#include <QTemporaryFile>
#include <QCryptographicHash>
#include <QCoreApplication>
#if (QT_VERSION_MAJOR<5)
#include <QRegExp>
#else
Expand Down Expand Up @@ -174,6 +175,7 @@ class XBinary : public QObject
static QString fileTypeIdToString(FT fileType);

static QString convertFileName(QString sFileName);
static QString convertPathName(QString sPathName);
// static void findFiles(QString sDirectoryName,QList<QString> *pListFileNames); // TODO Check

struct FFOPTIONS
Expand Down Expand Up @@ -434,6 +436,8 @@ class XBinary : public QObject

static QString getStringCollision(QList<QString> *pListStrings,QString sString1,QString sString2);

static bool writeToFile(QString sFileName,QByteArray baData);

private:
static QString convertSignature(QString sSignature);
static QString qcharToHex(QChar c);
Expand Down
200 changes: 200 additions & 0 deletions xne.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ XNE_DEF::IMAGE_OS2_HEADER XNE::getImageOS2Header()
result.ne_stack=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_stack));
result.ne_csip=read_uint32(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_csip));
result.ne_sssp=read_uint32(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_sssp));
result.ne_cseg=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cseg));
result.ne_cmod=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cmod));
result.ne_cbnrestab=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cbnrestab));
result.ne_segtab=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_segtab));
result.ne_rsrctab=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_rsrctab));
result.ne_restab=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_restab));
result.ne_modtab=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_modtab));
result.ne_imptab=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_imptab));
}

return result;
Expand Down Expand Up @@ -254,6 +262,118 @@ quint32 XNE::getImageOS2Header_sssp()
return nResult;
}

quint16 XNE::getImageOS2Header_cseg()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cseg));
}

return nResult;
}

quint16 XNE::getImageOS2Header_cmod()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cmod));
}

return nResult;
}

quint16 XNE::getImageOS2Header_cbnrestab()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cbnrestab));
}

return nResult;
}

quint16 XNE::getImageOS2Header_segtab()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_segtab));
}

return nResult;
}

quint16 XNE::getImageOS2Header_rsrctab()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_rsrctab));
}

return nResult;
}

quint16 XNE::getImageOS2Header_restab()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_restab));
}

return nResult;
}

quint16 XNE::getImageOS2Header_modtab()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_modtab));
}

return nResult;
}

quint16 XNE::getImageOS2Header_imptab()
{
quint16 nResult=0;

qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
nResult=read_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_imptab));
}

return nResult;
}

void XNE::setImageOS2Header_magic(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();
Expand Down Expand Up @@ -374,6 +494,86 @@ void XNE::setImageOS2Header_sssp(quint32 value)
}
}

void XNE::setImageOS2Header_cseg(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cseg),value);
}
}

void XNE::setImageOS2Header_cmod(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cmod),value);
}
}

void XNE::setImageOS2Header_cbnrestab(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_cbnrestab),value);
}
}

void XNE::setImageOS2Header_segtab(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_segtab),value);
}
}

void XNE::setImageOS2Header_rsrctab(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_rsrctab),value);
}
}

void XNE::setImageOS2Header_restab(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_restab),value);
}
}

void XNE::setImageOS2Header_modtab(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_modtab),value);
}
}

void XNE::setImageOS2Header_imptab(quint16 value)
{
qint64 nOffset=getImageOS2HeaderOffset();

if(nOffset!=-1)
{
write_uint16(nOffset+offsetof(XNE_DEF::IMAGE_OS2_HEADER,ne_imptab),value);
}
}

QMap<quint64, QString> XNE::getImageNEMagics()
{
QMap<quint64, QString> mapResult;
Expand Down
25 changes: 25 additions & 0 deletions xne.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ class XNE : public XMSDOS
quint16 getImageOS2Header_stack();
quint32 getImageOS2Header_csip();
quint32 getImageOS2Header_sssp();
quint16 getImageOS2Header_cseg();
quint16 getImageOS2Header_cmod();
quint16 getImageOS2Header_cbnrestab();
quint16 getImageOS2Header_segtab();
quint16 getImageOS2Header_rsrctab();
quint16 getImageOS2Header_restab();
quint16 getImageOS2Header_modtab();
quint16 getImageOS2Header_imptab();

void setImageOS2Header_magic(quint16 value);
void setImageOS2Header_ver(quint8 value);
Expand All @@ -60,6 +68,23 @@ class XNE : public XMSDOS
void setImageOS2Header_stack(quint16 value);
void setImageOS2Header_csip(quint32 value);
void setImageOS2Header_sssp(quint32 value);
void setImageOS2Header_cseg(quint16 value);
void setImageOS2Header_cmod(quint16 value);
void setImageOS2Header_cbnrestab(quint16 value);
void setImageOS2Header_segtab(quint16 value);
void setImageOS2Header_rsrctab(quint16 value);
void setImageOS2Header_restab(quint16 value);
void setImageOS2Header_modtab(quint16 value);
void setImageOS2Header_imptab(quint16 value);

// quint16 ne_; // Count of file segments
// quint16 ne_; // Entries in Module Reference Table
// quint16 ne_; // Size of non-resident name table
// quint16 ne_; // Offset of Segment Table
// quint16 ne_; // Offset of Resource Table
// quint16 ne_; // Offset of resident name table
// quint16 ne_; // Offset of Module Reference Table
// quint16 ne_; // Offset of Imported Names Table

static QMap<quint64, QString> getImageNEMagics();
static QMap<quint64, QString> getImageNEMagicsS();
Expand Down
16 changes: 8 additions & 8 deletions xne_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ struct IMAGE_OS2_HEADER // OS/2 .EXE header
quint16 ne_stack; // Initial stack allocation
quint32 ne_csip; // Initial CS:IP setting
quint32 ne_sssp; // Initial SS:SP setting
// WORD ne_cseg; // Count of file segments
// WORD ne_cmod; // Entries in Module Reference Table
// WORD ne_cbnrestab; // Size of non-resident name table
// WORD ne_segtab; // Offset of Segment Table
// WORD ne_rsrctab; // Offset of Resource Table
// WORD ne_restab; // Offset of resident name table
// WORD ne_modtab; // Offset of Module Reference Table
// WORD ne_imptab; // Offset of Imported Names Table
quint16 ne_cseg; // Count of file segments
quint16 ne_cmod; // Entries in Module Reference Table
quint16 ne_cbnrestab; // Size of non-resident name table
quint16 ne_segtab; // Offset of Segment Table
quint16 ne_rsrctab; // Offset of Resource Table
quint16 ne_restab; // Offset of resident name table
quint16 ne_modtab; // Offset of Module Reference Table
quint16 ne_imptab; // Offset of Imported Names Table
// LONG ne_nrestab; // Offset of Non-resident Names Table
// WORD ne_cmovent; // Count of movable entries
// WORD ne_align; // Segment alignment shift count
Expand Down
Loading

0 comments on commit d67f79c

Please sign in to comment.