⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgtranslater.h

📁 一个很好的协议,数据包解码工具,可以分析7号(ISUP,MTP,...), TCP/UDP等各种协议,特别的是还能支持自定义的二进制数据报,可以通过插件无限扩充协议库.
💻 H
字号:
#if !defined(_MSGTRANLATER_H)
#define _MSGTRANLATER_H

#include "../Include/MsgUtility.h"
#include "CPlusAnalyser.h"


/////////////////////////////////////////////////
//////////////////////////////////////
class TStruct;

#ifdef _DLL_PROJECT
class CLASS_EXPORT TVariableItem: public CVariableItem
#else
class TVariableItem: public CVariableItem
#endif
{
public:
    long m_beginLocat,m_len;
    bool m_bErr;

    TObArray<TVariableItem> m_IntegrateStructList;

public:
    TVariableItem();
    virtual ~TVariableItem();
    
    void DumpLocationMask(OTSTR& str);
    bool DumpBitsMask(OTSTR& str);
    bool DumpErrorFlag() { return m_bErr; }
    bool ValueValid();                  // 是否解析完整
    
    virtual bool isValueCommentValid();
    virtual int  GetValueComment(TObject* pTranslater,CVariableItem* pParentObject,int nArrIndex,OTSTR& strComment,char* szDefault=SHOW_WHEN_COMMENT_NOT_FOUND); // false表示未取得匹配的Comment ( or或者equal不匹配 , strComment可返回不匹配描述)
                                // return:   0 fail    1 succ   2 default(not found)
    
    bool ProcessDumpProc(int nArrIndex,ExecuteEnv* pRunEnv,Procedure* pDumpProc,bool isVarDump, CVariableItem* pThisObject,OTSTR& strRet);
        
    virtual bool isTypeOfDataValid(WORD nDisplayAttr);
    virtual CVariableItem* GetTypeOfData(int nIndex,WORD nDisplayAttr);
        
protected:
    friend class MsgTranslater;
    
    CStruct* NewStruct();
};

//////////////////////////////////////
class TStruct: public CStruct
{
public:
    long m_beginLocat,m_len;
    
public:
    TStruct();
    virtual ~TStruct();
    
protected:
    friend class MsgTranslater;
    
    CVariableItem* NewVariableItem();
};

//////////////////////////////////////////////////
#ifdef _DLL_PROJECT
class CLASS_EXPORT MsgTranslater: public TObject
#else
class MsgTranslater: public TObject
#endif
{
public:
    OTSTR m_strProtocolName;

    OTSTR m_strLastError;
    
    void ClearLastError();

public:
    MsgTranslater();	
   ~MsgTranslater();	

    void SetPlugInCallback(void* handler, cCallback::tFunction pFunctionPointer);

    bool LoadScript(char* szFilename);
    bool SetTranslateAttr(char* szAccessStruct,Waiter* pWaiter);
        
    bool Translate(bool bPreserveIntegrateStructObject, BYTE* szRowData, long& len); // len return translated byte

    TVariableItem& GetResult() { return m_VariableTran; }
        
    ExecuteEnv* GetEnv()     { return (m_pRootProgram)? (&m_Env):NULL; }
    Program*    GetProgram() { return m_pRootProgram; }
    bool        GetConstDefinition(OTSTR strName, OTSTR& strContent); // Get the Defininition string of "strName"
        
protected:
    void Clear(bool bClearError=true);

    bool TranslateStruct(TVariableItem& VariableTran, long nIndex, BinStream& stream);
    bool TranslateVariableItem          (char* szVarIdent, TVariableItem* pThisObject, TVariableItem& VariableTran, BinStream& stream, DWORD* lpParam=NULL);
    bool TranslateIntegratedVariableItem(char* szVarIdent, TVariableItem* pThisObject, TVariableItem& VariableTran, BinStream& stream, StructDefinition* pTypeOfStructDefinition);

    ///////////////////////////////////////////////////////////
    // Default TypeOf struct process function ( when relate function not found, try this default proc )
    // return: 0 fail    1 succ   2 default(not found)   // 暂不支持Parent.Ident, this.Ident

    static int Process_IntegrateProc(MsgTranslater& Translater,char* szVarIdent, StructDefinition* pTypeOfStructDefinition, BinStream& stream, CVarient& result);    // #1
    static int Process_IntegrateDumpProc(TObject* Translater, StructDefinition* pTypeOfStructDefinition, bool bJustValidCheck, CVarient* pItemValue, OTSTR* pStrComment);    // #1
    
    //////////////////////////////////////////
    static DWORD SysFunction(void* pParent, unsigned int params_num, DWORD params[]);
        
    //////////////////////////////////////////
    cCallback         m_PlugIn_Callback;

    Program*          m_pRootProgram;
    StructDefinition* m_pAccessDefinition;
    bool              m_bPreserveIntegrateStructObject;

    ExecuteEnv        m_Env;
    TVariableItem     m_VariableTran;

    //////////////////////////////////////////
    friend class TVariableItem;
};


#endif















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -