├── PETOOLS ├── PETOOLS │ ├── Debug │ │ ├── PETOOLS.vcxproj.FileListAbsolute.txt │ │ ├── vc142.idb │ │ ├── PETOOLS.res │ │ ├── PETOOLS.tlog │ │ │ └── PETOOLS.lastbuildstate │ │ └── PETOOLS.exe.recipe │ ├── stdafx.h │ ├── AddPatch.h │ ├── GlobeVar.h │ ├── MFCEdit.cpp │ ├── PETOOLS.cpp │ ├── PETOOLS.h │ ├── PETOOLS.rc │ ├── ReadMe.txt │ ├── resource.h │ ├── stdafx.cpp │ ├── targetver.h │ ├── AddPatch.cpp │ ├── DialogFirst.h │ ├── DisaDialog.h │ ├── MFCStatic.cpp │ ├── MFCStatus.cpp │ ├── MyListCtrl.h │ ├── PETOOLSDlg.h │ ├── PosCalcDlg.h │ ├── SectionsDlg.h │ ├── AddSectionDlg.h │ ├── DialogFirst.cpp │ ├── DisaDialog.cpp │ ├── MyListCtrl.cpp │ ├── PosCalcDlg.cpp │ ├── ProBarThread.cpp │ ├── ProBarThread.h │ ├── ProgressDialog.h │ ├── SectionsDlg.cpp │ ├── res │ │ ├── PETOOLS.ico │ │ └── PETOOLS.rc2 │ ├── AddSectionDlg.cpp │ ├── DataDirectoryDlg.h │ ├── ProgressDialog.cpp │ ├── DataDirectoryDlg.cpp │ ├── MyResource.h │ ├── PETOOLS.vcxproj.user │ ├── MFCEdit.h │ ├── Release │ │ └── PETOOLS.exe.recipe │ ├── MFCStatus.h │ ├── MFCStatic.h │ ├── GlobeVar.cpp │ ├── PETOOLS.vcxproj.filters │ ├── PETOOLS.vcxproj │ └── PETOOLSDlg.cpp ├── PETOOLS.suo ├── Debug │ ├── 16Edit.ini │ ├── 加壳示例.rar │ ├── 16Edit.dll │ ├── PELib.dll │ ├── PEMake.exe │ ├── PETOOLS.exe │ ├── configure.ini │ ├── dbghelp.lib │ ├── shellcode │ │ ├── 1.bin │ │ ├── 2.bin │ │ ├── cc.bin │ │ └── patch.exe │ └── otherconfigure.ini ├── Release │ ├── 16Edit.ini │ ├── 加壳示例.rar │ ├── 16Edit.dll │ ├── PELib.dll │ ├── PEMake.exe │ ├── PETOOLS.exe │ ├── dbghelp.lib │ ├── configure.ini │ ├── shellcode │ │ ├── 1.bin │ │ ├── 2.bin │ │ ├── cc.bin │ │ └── patch.exe │ └── otherconfigure.ini ├── VSCleaner.exe ├── vscleaner.ini ├── CommonLib │ ├── MiniDump.h │ ├── CodedConvert.h │ ├── MiniDump.cpp │ ├── disasm │ │ ├── disasm.h │ │ ├── asmserv.cpp │ │ ├── assembl.cpp │ │ └── disasm.cpp │ ├── 16Edit │ │ ├── 16Edit.dll │ │ ├── 16Edit.lib │ │ ├── 16EditDll.h │ │ └── APIs.tXt │ ├── MemoryPool │ │ ├── MemMgr.h │ │ ├── bin │ │ │ └── MemMgr.lib │ │ └── bind │ │ │ └── MemMgr.lib │ ├── PELib │ │ ├── PE │ │ │ ├── PEMake.h │ │ │ └── PEStruct.h │ │ ├── bin │ │ │ └── PELib.lib │ │ └── bind │ │ │ └── PELib.lib │ ├── pack │ │ ├── ByteBuffer.h │ │ ├── TXCommPack.cpp │ │ └── TXCommPack.h │ ├── Ini.h │ ├── Lock.h │ ├── Ini.cpp │ ├── LogLib │ │ ├── DebugLog.h │ │ ├── DebugLog.cpp │ │ └── log4z.h │ ├── Hex.h │ ├── typedef.h │ ├── zlib │ │ └── zconf.h │ └── xml │ │ └── Markup.h └── PETOOLS.sln ├── README.md ├── LICENSE └── .gitignore /PETOOLS/PETOOLS/Debug/PETOOLS.vcxproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS.suo -------------------------------------------------------------------------------- /PETOOLS/Debug/16Edit.ini: -------------------------------------------------------------------------------- 1 | [Options] 2 | WinPos=010000000C020000FD0000007E020000900100001D 3 | -------------------------------------------------------------------------------- /PETOOLS/Debug/加壳示例.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/加壳示例.rar -------------------------------------------------------------------------------- /PETOOLS/Release/16Edit.ini: -------------------------------------------------------------------------------- 1 | [Options] 2 | WinPos=010000000C020000FD0000007E020000900100001D 3 | -------------------------------------------------------------------------------- /PETOOLS/VSCleaner.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/VSCleaner.exe -------------------------------------------------------------------------------- /PETOOLS/vscleaner.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/vscleaner.ini -------------------------------------------------------------------------------- /PETOOLS/Debug/16Edit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/16Edit.dll -------------------------------------------------------------------------------- /PETOOLS/Debug/PELib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/PELib.dll -------------------------------------------------------------------------------- /PETOOLS/Debug/PEMake.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/PEMake.exe -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/stdafx.h -------------------------------------------------------------------------------- /PETOOLS/Release/加壳示例.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/加壳示例.rar -------------------------------------------------------------------------------- /PETOOLS/Debug/PETOOLS.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/PETOOLS.exe -------------------------------------------------------------------------------- /PETOOLS/Debug/configure.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/configure.ini -------------------------------------------------------------------------------- /PETOOLS/Debug/dbghelp.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/dbghelp.lib -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/AddPatch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/AddPatch.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/GlobeVar.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/GlobeVar.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MFCEdit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/MFCEdit.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLS.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/PETOOLS.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLS.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/PETOOLS.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLS.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/PETOOLS.rc -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/ReadMe.txt -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/resource.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/stdafx.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/targetver.h -------------------------------------------------------------------------------- /PETOOLS/Release/16Edit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/16Edit.dll -------------------------------------------------------------------------------- /PETOOLS/Release/PELib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/PELib.dll -------------------------------------------------------------------------------- /PETOOLS/Release/PEMake.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/PEMake.exe -------------------------------------------------------------------------------- /PETOOLS/Release/PETOOLS.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/PETOOLS.exe -------------------------------------------------------------------------------- /PETOOLS/Release/dbghelp.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/dbghelp.lib -------------------------------------------------------------------------------- /PETOOLS/CommonLib/MiniDump.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/MiniDump.h -------------------------------------------------------------------------------- /PETOOLS/Debug/shellcode/1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/shellcode/1.bin -------------------------------------------------------------------------------- /PETOOLS/Debug/shellcode/2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/shellcode/2.bin -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/AddPatch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/AddPatch.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/DialogFirst.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/DialogFirst.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/DisaDialog.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/DisaDialog.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MFCStatic.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/MFCStatic.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MFCStatus.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/MFCStatus.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MyListCtrl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/MyListCtrl.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLSDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/PETOOLSDlg.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PosCalcDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/PosCalcDlg.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/SectionsDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/SectionsDlg.h -------------------------------------------------------------------------------- /PETOOLS/Release/configure.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/configure.ini -------------------------------------------------------------------------------- /PETOOLS/CommonLib/CodedConvert.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/CodedConvert.h -------------------------------------------------------------------------------- /PETOOLS/CommonLib/MiniDump.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/MiniDump.cpp -------------------------------------------------------------------------------- /PETOOLS/Debug/otherconfigure.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/otherconfigure.ini -------------------------------------------------------------------------------- /PETOOLS/Debug/shellcode/cc.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/shellcode/cc.bin -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/AddSectionDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/AddSectionDlg.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/Debug/vc142.idb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/Debug/vc142.idb -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/DialogFirst.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/DialogFirst.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/DisaDialog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/DisaDialog.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MyListCtrl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/MyListCtrl.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PosCalcDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/PosCalcDlg.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/ProBarThread.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/ProBarThread.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/ProBarThread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/ProBarThread.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/ProgressDialog.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/ProgressDialog.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/SectionsDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/SectionsDlg.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/res/PETOOLS.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/res/PETOOLS.ico -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/res/PETOOLS.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/res/PETOOLS.rc2 -------------------------------------------------------------------------------- /PETOOLS/Release/shellcode/1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/shellcode/1.bin -------------------------------------------------------------------------------- /PETOOLS/Release/shellcode/2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/shellcode/2.bin -------------------------------------------------------------------------------- /PETOOLS/Release/shellcode/cc.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/shellcode/cc.bin -------------------------------------------------------------------------------- /PETOOLS/CommonLib/disasm/disasm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/disasm/disasm.h -------------------------------------------------------------------------------- /PETOOLS/Debug/shellcode/patch.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Debug/shellcode/patch.exe -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/AddSectionDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/AddSectionDlg.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/DataDirectoryDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/DataDirectoryDlg.h -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/Debug/PETOOLS.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/Debug/PETOOLS.res -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/ProgressDialog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/ProgressDialog.cpp -------------------------------------------------------------------------------- /PETOOLS/Release/otherconfigure.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/otherconfigure.ini -------------------------------------------------------------------------------- /PETOOLS/CommonLib/16Edit/16Edit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/16Edit/16Edit.dll -------------------------------------------------------------------------------- /PETOOLS/CommonLib/16Edit/16Edit.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/16Edit/16Edit.lib -------------------------------------------------------------------------------- /PETOOLS/CommonLib/MemoryPool/MemMgr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/MemoryPool/MemMgr.h -------------------------------------------------------------------------------- /PETOOLS/CommonLib/PELib/PE/PEMake.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/PELib/PE/PEMake.h -------------------------------------------------------------------------------- /PETOOLS/CommonLib/PELib/PE/PEStruct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/PELib/PE/PEStruct.h -------------------------------------------------------------------------------- /PETOOLS/CommonLib/PELib/bin/PELib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/PELib/bin/PELib.lib -------------------------------------------------------------------------------- /PETOOLS/CommonLib/disasm/asmserv.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/disasm/asmserv.cpp -------------------------------------------------------------------------------- /PETOOLS/CommonLib/disasm/assembl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/disasm/assembl.cpp -------------------------------------------------------------------------------- /PETOOLS/CommonLib/disasm/disasm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/disasm/disasm.cpp -------------------------------------------------------------------------------- /PETOOLS/CommonLib/pack/ByteBuffer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/pack/ByteBuffer.h -------------------------------------------------------------------------------- /PETOOLS/CommonLib/pack/TXCommPack.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/pack/TXCommPack.cpp -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/DataDirectoryDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/PETOOLS/DataDirectoryDlg.cpp -------------------------------------------------------------------------------- /PETOOLS/Release/shellcode/patch.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/Release/shellcode/patch.exe -------------------------------------------------------------------------------- /PETOOLS/CommonLib/PELib/bind/PELib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/PELib/bind/PELib.lib -------------------------------------------------------------------------------- /PETOOLS/CommonLib/MemoryPool/bin/MemMgr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/MemoryPool/bin/MemMgr.lib -------------------------------------------------------------------------------- /PETOOLS/CommonLib/MemoryPool/bind/MemMgr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SurrealSky/PETOOLS/HEAD/PETOOLS/CommonLib/MemoryPool/bind/MemMgr.lib -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MyResource.h: -------------------------------------------------------------------------------- 1 | #define PB_SETVALUE WM_USER+1 2 | #define WM_UPDATEUI WM_USER+2 3 | #define MSG_SAVE WM_USER+3 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PETOOLS 2 | - https://github.com/SurrealSky/PETOOLS 3 | - mail:securitysky@sina.com 4 | 5 | ## 介绍 6 | 7 | * PETOOLS是一款Windows下PE文件分析工具,软件加壳工具。 8 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLS.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PETOOLS.rc 5 | 6 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/Debug/PETOOLS.tlog/PETOOLS.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:VCServicingVersionCrtHeaders=14.29.30136:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|D:\work\program\PETOOLS\PETOOLS\| 3 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/Debug/PETOOLS.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | D:\work\program\PETOOLS\PETOOLS\Debug\PETOOLS.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MFCEdit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // MFCEdit 5 | 6 | class MFCEdit : public CMFCEditBrowseCtrl 7 | { 8 | DECLARE_DYNAMIC(MFCEdit) 9 | 10 | public: 11 | MFCEdit(); 12 | virtual ~MFCEdit(); 13 | 14 | protected: 15 | DECLARE_MESSAGE_MAP() 16 | 17 | public: 18 | virtual void PreSubclassWindow(); 19 | }; 20 | 21 | 22 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/Release/PETOOLS.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | D:\work\program\PETOOLS\PETOOLS\Release\PETOOLS.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/Ini.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | class Ini 5 | { 6 | public: 7 | Ini(void); 8 | ~Ini(void); 9 | public: 10 | int GetIntKey(IN TCHAR *File,IN TCHAR *section,IN TCHAR *key); 11 | void GetStrKey(IN TCHAR *File,IN TCHAR *section,IN TCHAR *key,OUT TCHAR *pOutBuffer); 12 | TCHAR *GetPath(void); 13 | private: 14 | TCHAR PATH[MAX_PATH]; 15 | }; 16 | 17 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MFCStatus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // MFCStatus 5 | 6 | class MFCStatus : public CStatusBarCtrl 7 | { 8 | DECLARE_DYNAMIC(MFCStatus) 9 | 10 | public: 11 | MFCStatus(); 12 | virtual ~MFCStatus(); 13 | CProgressCtrl m_progres; 14 | public: 15 | void SetUI(); 16 | void SetProcessBar(UINT pos){this->m_progres.SetPos(pos);}; 17 | protected: 18 | DECLARE_MESSAGE_MAP() 19 | }; 20 | 21 | 22 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/MFCStatic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | // MFCStatic 5 | 6 | class MFCStatic : public CStatic 7 | { 8 | DECLARE_DYNAMIC(MFCStatic) 9 | 10 | public: 11 | MFCStatic(); 12 | virtual ~MFCStatic(); 13 | protected: 14 | DECLARE_MESSAGE_MAP() 15 | public: 16 | TCHAR Title[MAX_PATH]; 17 | public: 18 | afx_msg void OnMouseMove(UINT nFlags, CPoint point); 19 | afx_msg void OnMouseLeave(); 20 | virtual void PreSubclassWindow(); 21 | }; 22 | 23 | 24 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/Lock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | class CLock 4 | { 5 | public: 6 | CLock() 7 | { 8 | InitializeCriticalSection(&m_cs); 9 | } 10 | 11 | ~CLock() 12 | { 13 | DeleteCriticalSection(&m_cs); 14 | } 15 | 16 | void Lock() 17 | { 18 | EnterCriticalSection(&m_cs); 19 | } 20 | 21 | void Unlock() 22 | { 23 | LeaveCriticalSection(&m_cs); 24 | } 25 | private: 26 | CRITICAL_SECTION m_cs; 27 | }; 28 | 29 | class AutoLock 30 | { 31 | public: 32 | AutoLock() 33 | { 34 | m_lock.Lock(); 35 | } 36 | ~AutoLock() 37 | { 38 | m_lock.Unlock(); 39 | } 40 | private: 41 | CLock m_lock; 42 | private: 43 | AutoLock(const AutoLock& lock); 44 | AutoLock& operator=(const AutoLock& lock); 45 | }; 46 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/GlobeVar.cpp: -------------------------------------------------------------------------------- 1 | #include"GlobeVar.h" 2 | 3 | const char *UNUSE="N/A"; 4 | 5 | void Create16EditWindow(unsigned char *buffer,unsigned int size,unsigned int startoff,unsigned int endoff) 6 | { 7 | HE_SETTINGS s; 8 | memset(&s, 0, sizeof(s)); 9 | s.dwMask = HE_SET_MEMORYBLOCKINPUT | HE_SET_SETSELECTION; 10 | //s.szFilePath = "D://flash.exe"; 11 | s.diMem.bReadOnly = TRUE; 12 | s.diMem.pDataBuff = buffer; 13 | s.diMem.dwSize = size; 14 | s.dwSelStartOff = startoff; 15 | s.dwSelEndOff = endoff; 16 | 17 | if (!HESpecifySettings(&s)) 18 | { 19 | MessageBox(0,"16EditLoader", "File access error !", MB_ICONERROR); 20 | return; 21 | } 22 | // 23 | // enter window loop (with current thread) 24 | // 25 | HEEnterWindowLoop(); 26 | } 27 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/Ini.cpp: -------------------------------------------------------------------------------- 1 | #include "Ini.h" 2 | #include 3 | 4 | Ini::Ini(void) 5 | { 6 | ZeroMemory(this->PATH,sizeof(this->PATH)); 7 | } 8 | 9 | TCHAR* Ini::GetPath(void) 10 | { 11 | return this->PATH; 12 | } 13 | 14 | int Ini::GetIntKey(IN TCHAR *File,IN TCHAR *section,IN TCHAR *key) 15 | { 16 | ::GetModuleFileName(NULL,this->GetPath(),MAX_PATH); 17 | *(strrchr(this->GetPath(),'\\')+1)=0x00; 18 | strcat(this->GetPath(),File); 19 | return ::GetPrivateProfileInt(section,key,0,this->GetPath()); 20 | 21 | } 22 | 23 | void Ini::GetStrKey(IN TCHAR *File,IN TCHAR *section,IN TCHAR *key,OUT TCHAR *pOutBuffer) 24 | { 25 | ::GetModuleFileName(NULL,this->GetPath(),MAX_PATH); 26 | *(strrchr(this->GetPath(),'\\')+1)=0x00; 27 | strcat(this->GetPath(),File); 28 | GetPrivateProfileString(section,key,0,pOutBuffer,MAX_PATH,this->GetPath()); 29 | } 30 | 31 | Ini::~Ini(void) 32 | { 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/LogLib/DebugLog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace SurrealDebugLog 10 | { 11 | // 12 | //NOTICE 13 | // 14 | template 15 | std::string string_format(const std::string& format, Args ... args) 16 | { 17 | size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; // Extra space for '\0' 18 | std::unique_ptr buf(new char[size]); 19 | snprintf(buf.get(), size, format.c_str(), args ...); 20 | return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside 21 | } 22 | 23 | //#define Dbg 24 | 25 | void DebugLog(const std::string &OutputString); 26 | 27 | void DebugLog(const std::string& lpTag, const std::string OutputString); 28 | 29 | void DebugLogHex(const std::string &lpTag, std::string &OutputString, SurrealTypes::STu32 lpOutputStringLen); 30 | 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/pack/TXCommPack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define BUFFER_SIZE 0x200 5 | #pragma pack(1) 6 | class CTXCommPack 7 | { 8 | public: 9 | CTXCommPack(void); 10 | CTXCommPack(size_t); 11 | virtual ~CTXCommPack(void); 12 | public: 13 | void AddByte(STu8); 14 | void PreAddByte(STu8); 15 | void AddWord(STu16); 16 | void PreAddWord(STu16); 17 | void AddDWord(STu32); 18 | void PreAddDWord(const STu32); 19 | void AddDDWord(const STu64); 20 | void PreAddDDWord(const STu64); 21 | void AddBuf(const STu8 *,const STu32); 22 | void PreAddBuf(const STu8 *, const STu32); 23 | void AddBufLenWord(); 24 | void AddBufLenDWord(); 25 | void AddFieldCode(STu16); 26 | void ChangeByte(const STu32,const STu8); 27 | void ChangeWord(const STu32,const STu16); 28 | void ChangeDWord(const STu32,const STu32); 29 | void ChangeDDWord(const STu32, const STu64); 30 | void ChangeBuffer(const STu32,const STu8*,const STu32); 31 | void GetBufferOut(); 32 | public: 33 | ByteBuffer buffer; 34 | }; 35 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/Hex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace SurrealHex 5 | { 6 | class HexConvert 7 | { 8 | public: 9 | HexConvert() {}; 10 | ~HexConvert() {}; 11 | public: 12 | std::string HexToStr(STu8 *pbSrc, STu32 nLen) 13 | { 14 | std::string str; 15 | char ddl, ddh; 16 | int i; 17 | 18 | for (i = 0; i 57) ddh = ddh + 7; 23 | if (ddl > 57) ddl = ddl + 7; 24 | str.push_back(ddh); 25 | str.push_back(ddl); 26 | } 27 | return str; 28 | } 29 | 30 | std::string StrToHex(STu8 *pbSrc, STu32 nLen) 31 | { 32 | std::string str; 33 | STu8 h1, h2; 34 | STu8 s1, s2; 35 | int i; 36 | 37 | for (i = 0; i 9) 44 | s1 -= 7; 45 | 46 | s2 = toupper(h2) - 0x30; 47 | if (s2 > 9) 48 | s2 -= 7; 49 | 50 | str.push_back(s1 * 16 + s2); 51 | } 52 | return str; 53 | } 54 | }; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 SurrealSky 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32407.337 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PETOOLS", "PETOOLS\PETOOLS.vcxproj", "{382BBBA3-9C9A-4C64-85C4-9D8D829D1A6E}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4858E49D-2D26-49A3-A94F-A9F6EC21FE67}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Release|Win32 = Release|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {382BBBA3-9C9A-4C64-85C4-9D8D829D1A6E}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {382BBBA3-9C9A-4C64-85C4-9D8D829D1A6E}.Debug|Win32.Build.0 = Debug|Win32 18 | {382BBBA3-9C9A-4C64-85C4-9D8D829D1A6E}.Release|Win32.ActiveCfg = Release|Win32 19 | {382BBBA3-9C9A-4C64-85C4-9D8D829D1A6E}.Release|Win32.Build.0 = Release|Win32 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | GlobalSection(ExtensibilityGlobals) = postSolution 25 | SolutionGuid = {58929CCC-EA0B-4CC0-B752-8A7D56BA8A61} 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/typedef.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by wzh. 3 | // 4 | 5 | #ifndef NDKAPPECG_TYPEDEF_H 6 | #define NDKAPPECG_TYPEDEF_H 7 | 8 | namespace SurrealTypes 9 | { 10 | #if defined(_MSC_VER) 11 | // 12 | // Windows/Visual C++ 13 | // 14 | typedef unsigned __int8 STbool; 15 | typedef unsigned __int8 STu8; 16 | typedef signed __int8 STs8; 17 | typedef signed __int16 STs16; 18 | typedef unsigned __int16 STu16; 19 | typedef signed __int32 STs32; 20 | typedef unsigned __int32 STu32; 21 | typedef signed __int64 STs64; 22 | typedef unsigned __int64 STu64; 23 | typedef float STfp32; 24 | typedef double STfp64; 25 | #else 26 | typedef unsigned char STbool; 27 | typedef unsigned char STu8; 28 | typedef char STs8; 29 | typedef unsigned short STu16; 30 | typedef signed short STs16; 31 | typedef unsigned int STu32; 32 | typedef signed int STs32; 33 | typedef signed long long STs64; 34 | typedef unsigned long long STu64; 35 | typedef float STfp32; 36 | typedef double STfp64; 37 | #endif 38 | 39 | #define TRUE 1 40 | #define FALSE 0 41 | 42 | #define STswab64(x) ((x&0x00000000000000ff) << 56|(((x&0x000000000000ff00) << 40)|((x&0x0000000000ff0000) << 24)|((x&0x00000000ff000000) << 8)|((x&0x000000ff00000000) >> 8)|((x&0x0000ff0000000000) >> 24)|((x&0x00ff000000000000) >> 40)|((x&0xff00000000000000) >> 56))) 43 | #define STswab32(x) ((x&0x000000ff) << 24 | (x&0x0000ff00) << 8 | (x&0x00ff0000) >> 8 | (x&0xff000000) >> 24) 44 | #define STswab16(x) ((x&0x00ff) << 8 | (x&0xff00) >> 8) 45 | } 46 | 47 | #endif 48 | 49 | 50 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/LogLib/DebugLog.cpp: -------------------------------------------------------------------------------- 1 | #include "./DebugLog.h" 2 | #include"../LogLib/log4z.h" 3 | 4 | using namespace zsummer::log4z; 5 | 6 | namespace SurrealDebugLog 7 | { 8 | void DebugLog(const std::string& OutputString) 9 | { 10 | #ifdef Dbg 11 | ILog4zManager::getRef().setLoggerPath(LOG4Z_MAIN_LOGGER_ID, "./log"); 12 | ILog4zManager::getRef().start(); 13 | ILog4zManager::getRef().setLoggerLevel(LOG4Z_MAIN_LOGGER_ID, LOG_LEVEL_TRACE); 14 | //LOGD: LOG WITH level LOG_DEBUG 15 | //LOGI: LOG WITH level LOG_INFO 16 | 17 | LOGD(OutputString); 18 | 19 | #endif 20 | } 21 | 22 | void DebugLog(const std::string& Tag, const std::string OutputString) 23 | { 24 | #ifdef Dbg 25 | ILog4zManager::getRef().setLoggerPath(LOG4Z_MAIN_LOGGER_ID, "./log"); 26 | ILog4zManager::getRef().start(); 27 | ILog4zManager::getRef().setLoggerLevel(LOG4Z_MAIN_LOGGER_ID, LOG_LEVEL_TRACE); 28 | //LOGD: LOG WITH level LOG_DEBUG 29 | //LOGI: LOG WITH level LOG_INFO 30 | 31 | LOGD(Tag <<":"< 19 | 20 | // 21 | // constants 22 | // 23 | 24 | // handler action codes 25 | #define HE_ACTION_EXITING 0x00000001 26 | #define HE_ACTION_SAVED 0x00000002 27 | #define HE_ACTION_FILEACCESSINFO 0x00000004 28 | #define HE_ACTION_WINDOWCREATED 0x00000008 29 | 30 | // flags for HE_SETTINGS 31 | #define HE_SET_FORCEREADONLY 0x00000001 32 | #define HE_SET_NORESIZE 0x00000002 33 | #define HE_SET_SETCURRENTOFFSET 0x00000004 34 | #define HE_SET_SETSELECTION 0x00000008 35 | #define HE_SET_ACTIONHANDLER 0x00000010 36 | #define HE_SET_INPUTFILE 0x00000020 37 | #define HE_SET_MEMORYBLOCKINPUT 0x00000040 38 | #define HE_SET_ONTOP 0x00000080 39 | #define HE_SET_PARENTWINDOW 0x00000100 40 | #define HE_SET_MINIMIZETOTRAY 0x00000200 41 | #define HE_SET_SAVEWINDOWPOSITION 0x00000400 42 | #define HE_SET_RESTOREWINDOWPOSITION 0x00000800 43 | #define HE_SET_USERWINDOWPOSITION 0x00001000 44 | 45 | // 46 | // structures 47 | // 48 | 49 | // force byte alignment of structures 50 | #if defined(__BORLANDC__) 51 | #pragma option -a1 52 | #else if defined(_MSC_VER) 53 | #pragma pack(1) 54 | #endif 55 | 56 | #ifndef EXTERN_HE_STRUCTS 57 | #define EXTERN_HE_STRUCTS 58 | 59 | typedef struct _HE_DATA_INFO 60 | { 61 | void* pDataBuff; 62 | DWORD dwSize; // data indicator 63 | BOOL bReadOnly; 64 | } HE_DATA_INFO, *PHE_DATA_INFO; 65 | 66 | typedef struct _HE_POS 67 | { 68 | DWORD dwOffset; 69 | BOOL bHiword; // (opt.) first digit of the pair ? ...or the 2nd one ? 70 | BOOL bTextSection; // (opt.) Caret in the text part ? 71 | } HE_POS, *PHE_POS; 72 | 73 | #endif // EXTERN_HE_STRUCTS 74 | 75 | typedef struct _HE_WIN_POS 76 | { 77 | int iState; // SW_SHOWNORMAL/SW_MAXIMIZE/SW_MINIMIZE 78 | int ix, iy, icx, icy; // left, top, width, height 79 | } HE_WIN_POS, *PHE_WIN_POS; 80 | 81 | typedef struct _HE_ACTION 82 | { 83 | DWORD dwActionCode; 84 | 85 | DWORD dwNewSize; // HE_ACTION_SAVED 86 | 87 | BOOL bReadWrite; // HE_ACTION_FILEACCESSINFO 88 | 89 | HWND hwnd16Edit; // HE_ACTION_WINDOWCREATED 90 | } HE_ACTION, *PHE_ACTION; 91 | 92 | typedef BOOL (__stdcall* procActionHandler)(PHE_ACTION pa); 93 | 94 | typedef struct _HE_SETTINGS 95 | { 96 | DWORD dwMask; // HE_SET_XXX flags 97 | 98 | procActionHandler pHandler; // HE_SET_ACTIONHANDLER 99 | 100 | HE_POS posCaret; // HE_SET_SETCURRENTOFFSET 101 | 102 | DWORD dwSelStartOff; // HE_SET_SETSELECTION 103 | DWORD dwSelEndOff; // 104 | 105 | HWND hwndParent; // HE_SET_PARENTWINDOW 106 | 107 | union 108 | { 109 | char* szFilePath; // HE_SET_INPUTFILE 110 | 111 | HE_DATA_INFO diMem; // HE_SET_MEMORYBLOCKINPUT 112 | }; 113 | 114 | HE_WIN_POS wpUser; // HE_SET_USERWINDOWPOSITION 115 | } HE_SETTINGS, *PHE_SETTINGS; 116 | 117 | #if defined(_MSC_VER) 118 | #pragma pack() 119 | #endif 120 | 121 | // 122 | // function prototypes 123 | // 124 | 125 | #ifdef __cplusplus 126 | extern "C" 127 | { 128 | #endif // __cplusplus 129 | 130 | BOOL __stdcall HESpecifySettings(PHE_SETTINGS sets); 131 | BOOL __stdcall HEEnterWindowLoop(); 132 | BOOL __stdcall HEEnterWindowLoopInNewThread(); 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif // __cplusplus 137 | 138 | #endif // __16EditDll_h__ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | #[Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | #[Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | #[Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | *.tlog 332 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLS.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 | {aca3e5de-9a6e-490f-a0ff-d51ab68cb20b} 18 | 19 | 20 | {9bb16d05-43b9-4f6f-b9a9-6f43332c03db} 21 | 22 | 23 | {190770a1-c831-4826-8e45-62f3662f5ac6} 24 | 25 | 26 | {45e0e910-4eb6-473c-9670-b7a4e8d3b499} 27 | 28 | 29 | {5f86cbbb-d6fa-45bd-9b80-a9f4e5e2c5d5} 30 | 31 | 32 | 33 | 34 | 35 | 资源文件 36 | 37 | 38 | 资源文件 39 | 40 | 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | 头文件 50 | 51 | 52 | 头文件 53 | 54 | 55 | 头文件 56 | 57 | 58 | Assistant 59 | 60 | 61 | 头文件 62 | 63 | 64 | 头文件 65 | 66 | 67 | 头文件 68 | 69 | 70 | 头文件 71 | 72 | 73 | 头文件 74 | 75 | 76 | 头文件 77 | 78 | 79 | ControlsClass 80 | 81 | 82 | ControlsClass 83 | 84 | 85 | ControlsClass 86 | 87 | 88 | ControlsClass 89 | 90 | 91 | ControlsClass 92 | 93 | 94 | 头文件 95 | 96 | 97 | CommonLib\LogLib 98 | 99 | 100 | CommonLib\LogLib 101 | 102 | 103 | CommonLib 104 | 105 | 106 | CommonLib 107 | 108 | 109 | CommonLib\disasm 110 | 111 | 112 | 头文件 113 | 114 | 115 | 头文件 116 | 117 | 118 | 119 | 120 | 源文件 121 | 122 | 123 | 源文件 124 | 125 | 126 | 源文件 127 | 128 | 129 | 源文件 130 | 131 | 132 | Assistant 133 | 134 | 135 | 源文件 136 | 137 | 138 | 源文件 139 | 140 | 141 | 源文件 142 | 143 | 144 | 源文件 145 | 146 | 147 | ControlsClass 148 | 149 | 150 | ControlsClass 151 | 152 | 153 | ControlsClass 154 | 155 | 156 | ControlsClass 157 | 158 | 159 | ControlsClass 160 | 161 | 162 | 源文件 163 | 164 | 165 | CommonLib\LogLib 166 | 167 | 168 | CommonLib\LogLib 169 | 170 | 171 | CommonLib 172 | 173 | 174 | CommonLib 175 | 176 | 177 | CommonLib\disasm 178 | 179 | 180 | CommonLib\disasm 181 | 182 | 183 | CommonLib\disasm 184 | 185 | 186 | 源文件 187 | 188 | 189 | 源文件 190 | 191 | 192 | 193 | 194 | 资源文件 195 | 196 | 197 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/16Edit/APIs.tXt: -------------------------------------------------------------------------------- 1 | 2 | ---------------------------------------- 3 | 16Edit - programming interface reference 4 | ---------------------------------------- 5 | 6 | 7 | General Notes: 8 | -------------- 9 | Per process can only one 16Edit window be opened at the same time. 10 | 11 | 16Edit uses an own clipboard format, so it's not possible to correspond with 12 | other programms. Anyway one can transfer data between 16Edit instances. 13 | 14 | Keep attention on the byte alignment of the 16Edit structures! 15 | 16 | 17 | API: 18 | ---- 19 | To open up a 16Edit window instance in your project you always have to call 20 | "HESpecifySettings" first and after that either "HEEnterWindowLoop" or 21 | "HEEnterWindowLoopInNewThread". 22 | 23 | ------------------------------------------------------------------------------------- 24 | 25 | BOOL __stdcall HESpecifySettings(PHE_SETTINGS sets); 26 | 27 | 28 | This function configures 16Edit and specifies the input which is either a 29 | memory block (HE_SET_MEMORYBLOCKINPUT) or a file (HE_SET_INPUTFILE). 30 | 31 | This function could fail because of the following reasons: 32 | - neither an input file nor an input memory block was specified 33 | - the input file could not be loaded 34 | - not enough memory available 35 | - the 16Edit window is opened 36 | .. all other errors or bad items in HE_SETTINGS are ignored or validated. 37 | 38 | ------------------------------------------------------------------------------------- 39 | 40 | Possible flags for "HE_SETTINGS.dwMask": 41 | 42 | #define HE_SET_FORCEREADONLY 0x00000001 43 | #define HE_SET_NORESIZE 0x00000002 44 | #define HE_SET_SETCURRENTOFFSET 0x00000004 45 | #define HE_SET_SETSELECTION 0x00000008 46 | #define HE_SET_ACTIONHANDLER 0x00000010 47 | #define HE_SET_INPUTFILE 0x00000020 48 | #define HE_SET_MEMORYBLOCKINPUT 0x00000040 49 | #define HE_SET_ONTOP 0x00000080 50 | #define HE_SET_PARENTWINDOW 0x00000100 51 | #define HE_SET_MINIMIZETOTRAY 0x00000200 52 | #define HE_SET_SAVEWINDOWPOSITION 0x00000400 53 | #define HE_SET_RESTOREWINDOWPOSITION 0x00000800 54 | #define HE_SET_USERWINDOWPOSITION 0x00001000 55 | 56 | 57 | HE_SET_FORCEREADONLY: 58 | Forbids any changes in the buffer, also if read-write-access could be 59 | obtained. 60 | 61 | HE_SET_NORESIZE: 62 | Forbids any operations which modify the size of the buffer. In fact the 63 | cutting and pasting functions are disabled. 64 | 65 | HE_SET_SETCURRENTOFFSET: 66 | The caret is set to the position specified in "HE_SETTINGS.posCaret" on 67 | startup. 68 | 69 | HE_SET_SETSELECTION: 70 | The buffer block defined by "HE_SETTINGS.dwSelStartOff" and 71 | "HE_SETTINGS.dwSelEndOff" is selected on startup. 72 | 73 | You can only use either HE_SET_SETCURRENTOFFSET or HE_SET_SETSELECTION ! 74 | 75 | HE_SET_ACTIONHANDLER: 76 | Installs an action handler which will get called in special effets are 77 | occurring or passed. The address of this handler should be put into 78 | "HE_SETTINGS.pHandler". Look down for the description of "HE_ACTION" for more 79 | information. 80 | 81 | HE_SET_INPUTFILE: 82 | A file ("HE_SETTINGS.szFilePath") is used as input. 16Edit tries to get write 83 | access. The client is informed about the result through the 84 | HE_ACTION_FILEACCESSINFO action event. 85 | 86 | HE_SET_MEMORYBLOCKINPUT: 87 | A memory block ("HE_SETTINGS.diMem") is used as input. Also if the user is 88 | allowed to resize the memory block, it's not able to make it grow over the 89 | size specifed in "HE_SETTINGS.diData.dwSize" ! 90 | 91 | You can only specify either HE_SET_INPUTFILE or HE_SET_MEMORYBLOCKINPUT ! 92 | 93 | HE_SET_ONTOP: 94 | The main window is set to top state on startup. 95 | 96 | HE_SET_PARENTWINDOW: 97 | The main window gets a client window of the window whose handle is set it 98 | "HE_SETTINGS.hwndParent". 99 | 100 | HE_SET_MINIMIZETOTRAY: 101 | Every time the main window is minimized it inserts an icon in the system tray and the 102 | window isn't visible in the task bar anymore. The minimized window can be restored 103 | either by double clicking on the icon in the tray or by a right click which causes a 104 | menu to appear. 105 | 106 | HE_SET_SAVEWINDOWPOSITION: 107 | 16Edit saves its window size,position and state in an ini file (16Edit.ini) which 108 | will be saved in the same directory as 16Edit.dll. 109 | 110 | HE_SET_RESTOREWINDOWPOSITION: 111 | If you specify this flag then 16Edit will restore the old window size,position and 112 | state if a 16Edit.ini lies in the same directory as 16Edit.dll. 113 | See HE_SET_SAVEWINDOWPOSITION. 114 | 115 | HE_SET_USERWINDOWPOSITION: 116 | "HE_SETTINGS.wpUser" is used to setup the main window on startup. 117 | HE_SET_RESTOREWINDOWPOSITION has no effect in this case. 118 | 119 | ------------------------------------------------------------------------------------- 120 | 121 | typedef struct HE_DATA_INFO 122 | { 123 | void* pDataBuff; 124 | DWORD dwSize; 125 | BOOL bReadOnly; 126 | } *PHE_DATA_INFO; 127 | 128 | 129 | This is the structure for an input memory block (HE_SET_MEMORYBLOCKINPUT). All structure 130 | items are self-explaining, I think. 131 | 132 | ------------------------------------------------------------------------------------- 133 | 134 | typedef struct HE_POS 135 | { 136 | DWORD dwOffset; 137 | BOOL bHiword; // (opt.) first digit of the pair ? ...or the 2nd one ? 138 | BOOL bTextSection; // (opt.) Caret in the text part ? 139 | } *PHE_POS; 140 | 141 | 142 | This structure is used if you wish to set the caret on startup (HE_SET_SETCURRENTOFFSET). 143 | 144 | ------------------------------------------------------------------------------------- 145 | 146 | typedef struct _HE_WIN_POS 147 | { 148 | int iState; // SW_SHOWNORMAL/SW_MAXIMIZE/SW_MINIMIZE 149 | int ix, iy, icx, icy; // left, top, width, height 150 | } HE_WIN_POS, *PHE_WIN_POS; 151 | 152 | 153 | Used to describe the state of a window. 154 | 155 | ------------------------------------------------------------------------------------- 156 | 157 | typedef struct _HE_SETTINGS 158 | { 159 | DWORD dwMask; // HE_SET_XXX flags 160 | 161 | procActionHandler pHandler; // HE_SET_ACTIONHANDLER 162 | 163 | HE_POS posCaret; // HE_SET_SETCURRENTOFFSET 164 | 165 | DWORD dwSelStartOff; // HE_SET_SETSELECTION 166 | DWORD dwSelEndOff; // 167 | 168 | HWND hwndParent; // HE_SET_PARENTWINDOW 169 | 170 | union 171 | { 172 | char* szFilePath; // HE_SET_INPUTFILE 173 | 174 | HE_DATA_INFO diMem; // HE_SET_MEMORYBLOCKINPUT 175 | }; 176 | 177 | HE_WIN_POS wpUser; // HE_SET_USERWINDOWPOSITION 178 | } HE_SETTINGS, *PHE_SETTINGS; 179 | 180 | 181 | dwMask: 182 | is a combination of HE_SET_XXX flags. 183 | 184 | pHandler: (HE_SET_ACTIONHANDLER) 185 | Optional address of a action handler routine. 186 | 187 | posCaret: (HE_SET_SETCURRENTOFFSET) 188 | Optional address of a HE_POS structure for the caret position. 189 | 190 | dwSelStartOff/dwSelEndOff: (HE_SET_SETSELECTION) 191 | Optional selection start/end. 192 | 193 | hwndParent: (HE_SET_PARENTWINDOW) 194 | Optional parent window handle. 195 | 196 | szFilePath: (HE_SET_INPUTFILE) 197 | Optional NUL terminated string pointer to the input file path. 198 | 199 | diMem: (HE_SET_MEMORYBLOCKINPUT) 200 | Optional information about the input memory block. 201 | 202 | wpUser: (HE_SET_USERWINDOWPOSITION) 203 | Apply user window state on startup. 204 | 205 | Look at the HE_SET_XXX flag definition above for more information. 206 | 207 | ------------------------------------------------------------------------------------- 208 | 209 | typedef struct HE_ACTION 210 | { 211 | DWORD dwActionCode; 212 | 213 | DWORD dwNewSize; // HE_ACTION_SAVED 214 | 215 | BOOL bReadWrite; // HE_ACTION_FILEACCESSINFO 216 | 217 | HWND hwnd16Edit; // HE_ACTION_WINDOWCREATED 218 | } *PHE_ACTION; 219 | 220 | typedef BOOL (__stdcall* procActionHandler)(PHE_ACTION pa); 221 | 222 | 223 | As mentioned you can specify an action handler. Every time if one of the following 224 | mentioned events occurres, the action handler is called. The event type is signed by 225 | "PHE_ACTION->dwActionCode". 226 | The BOOL return value is up to now useless. 227 | 228 | ------------------------------------------------------------------------------------- 229 | 230 | Possible values for "HE_ACTION.dwActionCode": 231 | 232 | #define HE_ACTION_EXITING 0x00000001 233 | #define HE_ACTION_SAVED 0x00000002 234 | #define HE_ACTION_FILEACCESSINFO 0x00000004 235 | #define HE_ACTION_WINDOWCREATED 0x00000008 236 | 237 | 238 | HE_ACTION_EXITING: 239 | The user is closing the window. No additional information. 240 | 241 | HE_ACTION_SAVED: 242 | The modification were saved to the input file/memory block. "HE_ACTION.dwNewSize" 243 | holds the new size. 244 | 245 | HE_ACTION_FILEACCESSINFO: 246 | This event occurs if input is a file and 16Edit finished the file opening 247 | process. "HE_ACTION.bReadWrite" shows whether 16Edit was able to gain read and 248 | write access. 249 | 250 | HE_ACTION_WINDOWCREATED: 251 | The handler will be called after the main window was created and set up. 252 | "HE_ACTION.hwnd16Edit" will hold the handle of the 16Edit main window. 253 | 254 | ------------------------------------------------------------------------------------- 255 | 256 | BOOL __stdcall HEEnterWindowLoop(); 257 | BOOL __stdcall HEEnterWindowLoopInNewThread(); 258 | 259 | 260 | Both routines open the 16Edit main window up. 261 | But "HEEnterWindowLoop" enters the window loop within the thread which calls 262 | the function and "HEEnterWindowLoopInNewThread" creates a new thread which is 263 | entering the window loop. 264 | Both routines fail if the window of the 16Edit.dll instance is already opened. 265 | 266 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLS.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {382BBBA3-9C9A-4C64-85C4-9D8D829D1A6E} 15 | PETOOLS 16 | MFCProj 17 | 10.0 18 | 19 | 20 | 21 | Application 22 | true 23 | MultiByte 24 | Dynamic 25 | v142 26 | 27 | 28 | Application 29 | false 30 | true 31 | MultiByte 32 | Dynamic 33 | false 34 | v142 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | true 49 | $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(SolutionDir)$(Configuration)\;$(SolutionDir)\ 50 | $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\CommonLib\; 51 | 52 | 53 | false 54 | $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(SolutionDir)$(Configuration)\;$(SolutionDir)\ 55 | $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)\CommonLib\; 56 | 57 | 58 | 59 | Use 60 | Level3 61 | Disabled 62 | WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) 63 | true 64 | 65 | 66 | Windows 67 | true 68 | AsInvoker 69 | 70 | 71 | true 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | true 79 | _DEBUG;%(PreprocessorDefinitions) 80 | 81 | 82 | 0x0804 83 | _DEBUG;%(PreprocessorDefinitions) 84 | $(IntDir);%(AdditionalIncludeDirectories) 85 | 86 | 87 | C:\masm32\include 88 | 89 | 90 | 91 | 92 | Level3 93 | Use 94 | MaxSpeed 95 | true 96 | true 97 | WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) 98 | 99 | 100 | MultiThreadedDLL 101 | 102 | 103 | Windows 104 | true 105 | true 106 | true 107 | 108 | 109 | 110 | 111 | false 112 | true 113 | NDEBUG;%(PreprocessorDefinitions) 114 | 115 | 116 | 0x0804 117 | NDEBUG;%(PreprocessorDefinitions) 118 | $(IntDir);%(AdditionalIncludeDirectories) 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | NotUsing 156 | NotUsing 157 | 158 | 159 | NotUsing 160 | NotUsing 161 | 162 | 163 | NotUsing 164 | NotUsing 165 | 166 | 167 | NotUsing 168 | NotUsing 169 | 170 | 171 | NotUsing 172 | NotUsing 173 | 174 | 175 | NotUsing 176 | NotUsing 177 | 178 | 179 | NotUsing 180 | NotUsing 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | NotUsing 189 | NotUsing 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | Create 203 | Create 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/zlib/zconf.h: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2013 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #ifndef ZCONF_H 9 | #define ZCONF_H 10 | 11 | /* 12 | * If you *really* need a unique prefix for all types and library functions, 13 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 14 | * Even better than compiling with -DZ_PREFIX would be to use configure to set 15 | * this permanently in zconf.h using "./configure --zprefix". 16 | */ 17 | #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ 18 | # define Z_PREFIX_SET 19 | 20 | /* all linked symbols */ 21 | # define _dist_code z__dist_code 22 | # define _length_code z__length_code 23 | # define _tr_align z__tr_align 24 | # define _tr_flush_bits z__tr_flush_bits 25 | # define _tr_flush_block z__tr_flush_block 26 | # define _tr_init z__tr_init 27 | # define _tr_stored_block z__tr_stored_block 28 | # define _tr_tally z__tr_tally 29 | # define adler32 z_adler32 30 | # define adler32_combine z_adler32_combine 31 | # define adler32_combine64 z_adler32_combine64 32 | # ifndef Z_SOLO 33 | # define compress z_compress 34 | # define compress2 z_compress2 35 | # define compressBound z_compressBound 36 | # endif 37 | # define crc32 z_crc32 38 | # define crc32_combine z_crc32_combine 39 | # define crc32_combine64 z_crc32_combine64 40 | # define deflate z_deflate 41 | # define deflateBound z_deflateBound 42 | # define deflateCopy z_deflateCopy 43 | # define deflateEnd z_deflateEnd 44 | # define deflateInit2_ z_deflateInit2_ 45 | # define deflateInit_ z_deflateInit_ 46 | # define deflateParams z_deflateParams 47 | # define deflatePending z_deflatePending 48 | # define deflatePrime z_deflatePrime 49 | # define deflateReset z_deflateReset 50 | # define deflateResetKeep z_deflateResetKeep 51 | # define deflateSetDictionary z_deflateSetDictionary 52 | # define deflateSetHeader z_deflateSetHeader 53 | # define deflateTune z_deflateTune 54 | # define deflate_copyright z_deflate_copyright 55 | # define get_crc_table z_get_crc_table 56 | # ifndef Z_SOLO 57 | # define gz_error z_gz_error 58 | # define gz_intmax z_gz_intmax 59 | # define gz_strwinerror z_gz_strwinerror 60 | # define gzbuffer z_gzbuffer 61 | # define gzclearerr z_gzclearerr 62 | # define gzclose z_gzclose 63 | # define gzclose_r z_gzclose_r 64 | # define gzclose_w z_gzclose_w 65 | # define gzdirect z_gzdirect 66 | # define gzdopen z_gzdopen 67 | # define gzeof z_gzeof 68 | # define gzerror z_gzerror 69 | # define gzflush z_gzflush 70 | # define gzgetc z_gzgetc 71 | # define gzgetc_ z_gzgetc_ 72 | # define gzgets z_gzgets 73 | # define gzoffset z_gzoffset 74 | # define gzoffset64 z_gzoffset64 75 | # define gzopen z_gzopen 76 | # define gzopen64 z_gzopen64 77 | # ifdef _WIN32 78 | # define gzopen_w z_gzopen_w 79 | # endif 80 | # define gzprintf z_gzprintf 81 | # define gzvprintf z_gzvprintf 82 | # define gzputc z_gzputc 83 | # define gzputs z_gzputs 84 | # define gzread z_gzread 85 | # define gzrewind z_gzrewind 86 | # define gzseek z_gzseek 87 | # define gzseek64 z_gzseek64 88 | # define gzsetparams z_gzsetparams 89 | # define gztell z_gztell 90 | # define gztell64 z_gztell64 91 | # define gzungetc z_gzungetc 92 | # define gzwrite z_gzwrite 93 | # endif 94 | # define inflate z_inflate 95 | # define inflateBack z_inflateBack 96 | # define inflateBackEnd z_inflateBackEnd 97 | # define inflateBackInit_ z_inflateBackInit_ 98 | # define inflateCopy z_inflateCopy 99 | # define inflateEnd z_inflateEnd 100 | # define inflateGetHeader z_inflateGetHeader 101 | # define inflateInit2_ z_inflateInit2_ 102 | # define inflateInit_ z_inflateInit_ 103 | # define inflateMark z_inflateMark 104 | # define inflatePrime z_inflatePrime 105 | # define inflateReset z_inflateReset 106 | # define inflateReset2 z_inflateReset2 107 | # define inflateSetDictionary z_inflateSetDictionary 108 | # define inflateGetDictionary z_inflateGetDictionary 109 | # define inflateSync z_inflateSync 110 | # define inflateSyncPoint z_inflateSyncPoint 111 | # define inflateUndermine z_inflateUndermine 112 | # define inflateResetKeep z_inflateResetKeep 113 | # define inflate_copyright z_inflate_copyright 114 | # define inflate_fast z_inflate_fast 115 | # define inflate_table z_inflate_table 116 | # ifndef Z_SOLO 117 | # define uncompress z_uncompress 118 | # endif 119 | # define zError z_zError 120 | # ifndef Z_SOLO 121 | # define zcalloc z_zcalloc 122 | # define zcfree z_zcfree 123 | # endif 124 | # define zlibCompileFlags z_zlibCompileFlags 125 | # define zlibVersion z_zlibVersion 126 | 127 | /* all zlib typedefs in zlib.h and zconf.h */ 128 | # define Byte z_Byte 129 | # define Bytef z_Bytef 130 | # define alloc_func z_alloc_func 131 | # define charf z_charf 132 | # define free_func z_free_func 133 | # ifndef Z_SOLO 134 | # define gzFile z_gzFile 135 | # endif 136 | # define gz_header z_gz_header 137 | # define gz_headerp z_gz_headerp 138 | # define in_func z_in_func 139 | # define intf z_intf 140 | # define out_func z_out_func 141 | # define uInt z_uInt 142 | # define uIntf z_uIntf 143 | # define uLong z_uLong 144 | # define uLongf z_uLongf 145 | # define voidp z_voidp 146 | # define voidpc z_voidpc 147 | # define voidpf z_voidpf 148 | 149 | /* all zlib structs in zlib.h and zconf.h */ 150 | # define gz_header_s z_gz_header_s 151 | # define internal_state z_internal_state 152 | 153 | #endif 154 | 155 | #if defined(__MSDOS__) && !defined(MSDOS) 156 | # define MSDOS 157 | #endif 158 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 159 | # define OS2 160 | #endif 161 | #if defined(_WINDOWS) && !defined(WINDOWS) 162 | # define WINDOWS 163 | #endif 164 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 165 | # ifndef WIN32 166 | # define WIN32 167 | # endif 168 | #endif 169 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 170 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 171 | # ifndef SYS16BIT 172 | # define SYS16BIT 173 | # endif 174 | # endif 175 | #endif 176 | 177 | /* 178 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 179 | * than 64k bytes at a time (needed on systems with 16-bit int). 180 | */ 181 | #ifdef SYS16BIT 182 | # define MAXSEG_64K 183 | #endif 184 | #ifdef MSDOS 185 | # define UNALIGNED_OK 186 | #endif 187 | 188 | #ifdef __STDC_VERSION__ 189 | # ifndef STDC 190 | # define STDC 191 | # endif 192 | # if __STDC_VERSION__ >= 199901L 193 | # ifndef STDC99 194 | # define STDC99 195 | # endif 196 | # endif 197 | #endif 198 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 199 | # define STDC 200 | #endif 201 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 202 | # define STDC 203 | #endif 204 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 205 | # define STDC 206 | #endif 207 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 208 | # define STDC 209 | #endif 210 | 211 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 212 | # define STDC 213 | #endif 214 | 215 | #ifndef STDC 216 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 217 | # define const /* note: need a more gentle solution here */ 218 | # endif 219 | #endif 220 | 221 | #if defined(ZLIB_CONST) && !defined(z_const) 222 | # define z_const const 223 | #else 224 | # define z_const 225 | #endif 226 | 227 | /* Some Mac compilers merge all .h files incorrectly: */ 228 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 229 | # define NO_DUMMY_DECL 230 | #endif 231 | 232 | /* Maximum value for memLevel in deflateInit2 */ 233 | #ifndef MAX_MEM_LEVEL 234 | # ifdef MAXSEG_64K 235 | # define MAX_MEM_LEVEL 8 236 | # else 237 | # define MAX_MEM_LEVEL 9 238 | # endif 239 | #endif 240 | 241 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 242 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 243 | * created by gzip. (Files created by minigzip can still be extracted by 244 | * gzip.) 245 | */ 246 | #ifndef MAX_WBITS 247 | # define MAX_WBITS 15 /* 32K LZ77 window */ 248 | #endif 249 | 250 | /* The memory requirements for deflate are (in bytes): 251 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 252 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 253 | plus a few kilobytes for small objects. For example, if you want to reduce 254 | the default memory requirements from 256K to 128K, compile with 255 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 256 | Of course this will generally degrade compression (there's no free lunch). 257 | 258 | The memory requirements for inflate are (in bytes) 1 << windowBits 259 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 260 | for small objects. 261 | */ 262 | 263 | /* Type declarations */ 264 | 265 | #ifndef OF /* function prototypes */ 266 | # ifdef STDC 267 | # define OF(args) args 268 | # else 269 | # define OF(args) () 270 | # endif 271 | #endif 272 | 273 | #ifndef Z_ARG /* function prototypes for stdarg */ 274 | # if defined(STDC) || defined(Z_HAVE_STDARG_H) 275 | # define Z_ARG(args) args 276 | # else 277 | # define Z_ARG(args) () 278 | # endif 279 | #endif 280 | 281 | /* The following definitions for FAR are needed only for MSDOS mixed 282 | * model programming (small or medium model with some far allocations). 283 | * This was tested only with MSC; for other MSDOS compilers you may have 284 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 285 | * just define FAR to be empty. 286 | */ 287 | #ifdef SYS16BIT 288 | # if defined(M_I86SM) || defined(M_I86MM) 289 | /* MSC small or medium model */ 290 | # define SMALL_MEDIUM 291 | # ifdef _MSC_VER 292 | # define FAR _far 293 | # else 294 | # define FAR far 295 | # endif 296 | # endif 297 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 298 | /* Turbo C small or medium model */ 299 | # define SMALL_MEDIUM 300 | # ifdef __BORLANDC__ 301 | # define FAR _far 302 | # else 303 | # define FAR far 304 | # endif 305 | # endif 306 | #endif 307 | 308 | #if defined(WINDOWS) || defined(WIN32) 309 | /* If building or using zlib as a DLL, define ZLIB_DLL. 310 | * This is not mandatory, but it offers a little performance increase. 311 | */ 312 | # ifdef ZLIB_DLL 313 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 314 | # ifdef ZLIB_INTERNAL 315 | # define ZEXTERN extern __declspec(dllexport) 316 | # else 317 | # define ZEXTERN extern __declspec(dllimport) 318 | # endif 319 | # endif 320 | # endif /* ZLIB_DLL */ 321 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 322 | * define ZLIB_WINAPI. 323 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 324 | */ 325 | # ifdef ZLIB_WINAPI 326 | # ifdef FAR 327 | # undef FAR 328 | # endif 329 | # include 330 | /* No need for _export, use ZLIB.DEF instead. */ 331 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 332 | # define ZEXPORT WINAPI 333 | # ifdef WIN32 334 | # define ZEXPORTVA WINAPIV 335 | # else 336 | # define ZEXPORTVA FAR CDECL 337 | # endif 338 | # endif 339 | #endif 340 | 341 | #if defined (__BEOS__) 342 | # ifdef ZLIB_DLL 343 | # ifdef ZLIB_INTERNAL 344 | # define ZEXPORT __declspec(dllexport) 345 | # define ZEXPORTVA __declspec(dllexport) 346 | # else 347 | # define ZEXPORT __declspec(dllimport) 348 | # define ZEXPORTVA __declspec(dllimport) 349 | # endif 350 | # endif 351 | #endif 352 | 353 | #ifndef ZEXTERN 354 | # define ZEXTERN extern 355 | #endif 356 | #ifndef ZEXPORT 357 | # define ZEXPORT 358 | #endif 359 | #ifndef ZEXPORTVA 360 | # define ZEXPORTVA 361 | #endif 362 | 363 | #ifndef FAR 364 | # define FAR 365 | #endif 366 | 367 | #if !defined(__MACTYPES__) 368 | typedef unsigned char Byte; /* 8 bits */ 369 | #endif 370 | typedef unsigned int uInt; /* 16 bits or more */ 371 | typedef unsigned long uLong; /* 32 bits or more */ 372 | 373 | #ifdef SMALL_MEDIUM 374 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 375 | # define Bytef Byte FAR 376 | #else 377 | typedef Byte FAR Bytef; 378 | #endif 379 | typedef char FAR charf; 380 | typedef int FAR intf; 381 | typedef uInt FAR uIntf; 382 | typedef uLong FAR uLongf; 383 | 384 | #ifdef STDC 385 | typedef void const *voidpc; 386 | typedef void FAR *voidpf; 387 | typedef void *voidp; 388 | #else 389 | typedef Byte const *voidpc; 390 | typedef Byte FAR *voidpf; 391 | typedef Byte *voidp; 392 | #endif 393 | 394 | #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) 395 | # include 396 | # if (UINT_MAX == 0xffffffffUL) 397 | # define Z_U4 unsigned 398 | # elif (ULONG_MAX == 0xffffffffUL) 399 | # define Z_U4 unsigned long 400 | # elif (USHRT_MAX == 0xffffffffUL) 401 | # define Z_U4 unsigned short 402 | # endif 403 | #endif 404 | 405 | #ifdef Z_U4 406 | typedef Z_U4 z_crc_t; 407 | #else 408 | typedef unsigned long z_crc_t; 409 | #endif 410 | 411 | #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ 412 | # define Z_HAVE_UNISTD_H 413 | #endif 414 | 415 | #ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ 416 | # define Z_HAVE_STDARG_H 417 | #endif 418 | 419 | #ifdef STDC 420 | # ifndef Z_SOLO 421 | # include /* for off_t */ 422 | # endif 423 | #endif 424 | 425 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) 426 | # ifndef Z_SOLO 427 | # include /* for va_list */ 428 | # endif 429 | #endif 430 | 431 | #ifdef _WIN32 432 | # ifndef Z_SOLO 433 | # include /* for wchar_t */ 434 | # endif 435 | #endif 436 | 437 | /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and 438 | * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even 439 | * though the former does not conform to the LFS document), but considering 440 | * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as 441 | * equivalently requesting no 64-bit operations 442 | */ 443 | #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 444 | # undef _LARGEFILE64_SOURCE 445 | #endif 446 | 447 | #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) 448 | # define Z_HAVE_UNISTD_H 449 | #endif 450 | #ifndef Z_SOLO 451 | # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) 452 | # include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ 453 | # ifdef VMS 454 | # include /* for off_t */ 455 | # endif 456 | # ifndef z_off_t 457 | # define z_off_t off_t 458 | # endif 459 | # endif 460 | #endif 461 | 462 | #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 463 | # define Z_LFS64 464 | #endif 465 | 466 | #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) 467 | # define Z_LARGE64 468 | #endif 469 | 470 | #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) 471 | # define Z_WANT64 472 | #endif 473 | 474 | #if !defined(SEEK_SET) && !defined(Z_SOLO) 475 | # define SEEK_SET 0 /* Seek from beginning of file. */ 476 | # define SEEK_CUR 1 /* Seek from current position. */ 477 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 478 | #endif 479 | 480 | #ifndef z_off_t 481 | # define z_off_t long 482 | #endif 483 | 484 | #if !defined(_WIN32) && defined(Z_LARGE64) 485 | # define z_off64_t off64_t 486 | #else 487 | # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) 488 | # define z_off64_t __int64 489 | # else 490 | # define z_off64_t z_off_t 491 | # endif 492 | #endif 493 | 494 | /* MVS linker does not support external names larger than 8 bytes */ 495 | #if defined(__MVS__) 496 | #pragma map(deflateInit_,"DEIN") 497 | #pragma map(deflateInit2_,"DEIN2") 498 | #pragma map(deflateEnd,"DEEND") 499 | #pragma map(deflateBound,"DEBND") 500 | #pragma map(inflateInit_,"ININ") 501 | #pragma map(inflateInit2_,"ININ2") 502 | #pragma map(inflateEnd,"INEND") 503 | #pragma map(inflateSync,"INSY") 504 | #pragma map(inflateSetDictionary,"INSEDI") 505 | #pragma map(compressBound,"CMBND") 506 | #pragma map(inflate_table,"INTABL") 507 | #pragma map(inflate_fast,"INFA") 508 | #pragma map(inflate_copyright,"INCOPY") 509 | #endif 510 | 511 | #endif /* ZCONF_H */ 512 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/xml/Markup.h: -------------------------------------------------------------------------------- 1 | // Markup.h: interface for the CMarkup class. 2 | // 3 | // Markup Release 11.5 4 | // Copyright (C) 2011 First Objective Software, Inc. All rights reserved 5 | // Go to www.firstobject.com for the latest CMarkup and EDOM documentation 6 | // Use in commercial applications requires written permission 7 | // This software is provided "as is", with no warranty. 8 | 9 | #if !defined(_MARKUP_H_INCLUDED_) 10 | #define _MARKUP_H_INCLUDED_ 11 | 12 | #include 13 | #include // memcpy, memset, strcmp... 14 | 15 | // Major build options 16 | // MARKUP_WCHAR wide char (2-byte UTF-16 on Windows, 4-byte UTF-32 on Linux and OS X) 17 | // MARKUP_MBCS ANSI/double-byte strings on Windows 18 | // MARKUP_STL (default except VC++) use STL strings instead of MFC strings 19 | // MARKUP_SAFESTR to use string _s functions in VC++ 2005 (_MSC_VER >= 1400) 20 | // MARKUP_WINCONV (default for VC++) for Windows API character conversion 21 | // MARKUP_ICONV (default for GNU) for character conversion on Linux and OS X and other platforms 22 | // MARKUP_STDCONV to use neither WINCONV or ICONV, falls back to setlocale based conversion for ANSI 23 | // 24 | #if ! defined(MARKUP_WINDOWS) 25 | #if defined(_WIN32) || defined(WIN32) 26 | #define MARKUP_WINDOWS 27 | #endif // WIN32 or _WIN32 28 | #endif // not MARKUP_WINDOWS 29 | #if _MSC_VER > 1000 // VC++ 30 | #pragma once 31 | #if ! defined(MARKUP_SAFESTR) // not VC++ safe strings 32 | #pragma warning(disable:4996) // VC++ 2005 deprecated function warnings 33 | #endif // not VC++ safe strings 34 | #if defined(MARKUP_STL) && _MSC_VER < 1400 // STL pre VC++ 2005 35 | #pragma warning(disable:4786) // std::string long names 36 | #endif // VC++ 2005 STL 37 | #else // not VC++ 38 | #if ! defined(MARKUP_STL) 39 | #define MARKUP_STL 40 | #endif // not STL 41 | #if defined(__GNUC__) && ! defined(MARKUP_ICONV) && ! defined(MARKUP_STDCONV) && ! defined(MARKUP_WINCONV) 42 | #if ! defined(MARKUP_WINDOWS) 43 | #define MARKUP_ICONV 44 | #endif // not Windows 45 | #endif // GNUC and not ICONV not STDCONV not WINCONV 46 | #endif // not VC++ 47 | #if (defined(_UNICODE) || defined(UNICODE)) && ! defined(MARKUP_WCHAR) 48 | #define MARKUP_WCHAR 49 | #endif // _UNICODE or UNICODE 50 | #if (defined(_MBCS) || defined(MBCS)) && ! defined(MARKUP_MBCS) 51 | #define MARKUP_MBCS 52 | #endif // _MBCS and not MBCS 53 | #if ! defined(MARKUP_SIZEOFWCHAR) 54 | #if __SIZEOF_WCHAR_T__ == 4 || __WCHAR_MAX__ > 0x10000 55 | #define MARKUP_SIZEOFWCHAR 4 56 | #else // sizeof(wchar_t) != 4 57 | #define MARKUP_SIZEOFWCHAR 2 58 | #endif // sizeof(wchar_t) != 4 59 | #endif // not MARKUP_SIZEOFWCHAR 60 | #if ! defined(MARKUP_WINCONV) && ! defined(MARKUP_STDCONV) && ! defined(MARKUP_ICONV) 61 | #define MARKUP_WINCONV 62 | #endif // not WINCONV not STDCONV not ICONV 63 | #if ! defined(MARKUP_FILEBLOCKSIZE) 64 | #define MARKUP_FILEBLOCKSIZE 16384 65 | #endif 66 | 67 | // Text type and function defines (compiler and build-option dependent) 68 | // 69 | #define MCD_ACP 0 70 | #define MCD_UTF8 65001 71 | #define MCD_UTF16 1200 72 | #define MCD_UTF32 65005 73 | #if defined(MARKUP_WCHAR) 74 | #define MCD_CHAR wchar_t 75 | #define MCD_PCSZ const wchar_t* 76 | #define MCD_PSZLEN (int)wcslen 77 | #define MCD_PSZCHR wcschr 78 | #define MCD_PSZSTR wcsstr 79 | #define MCD_PSZTOL wcstol 80 | #if defined(MARKUP_SAFESTR) // VC++ safe strings 81 | #define MCD_SSZ(sz) sz,(sizeof(sz)/sizeof(MCD_CHAR)) 82 | #define MCD_PSZCPY(sz,p) wcscpy_s(MCD_SSZ(sz),p) 83 | #define MCD_PSZNCPY(sz,p,n) wcsncpy_s(MCD_SSZ(sz),p,n) 84 | #define MCD_SPRINTF swprintf_s 85 | #define MCD_FOPEN(f,n,m) {if(_wfopen_s(&f,n,m)!=0)f=NULL;} 86 | #else // not VC++ safe strings 87 | #if defined(__GNUC__) && ! defined(MARKUP_WINDOWS) // non-Windows GNUC 88 | #define MCD_SSZ(sz) sz,(sizeof(sz)/sizeof(MCD_CHAR)) 89 | #else // not non-Windows GNUC 90 | #define MCD_SSZ(sz) sz 91 | #endif // not non-Windows GNUC 92 | #define MCD_PSZCPY wcscpy 93 | #define MCD_PSZNCPY wcsncpy 94 | #define MCD_SPRINTF swprintf 95 | #define MCD_FOPEN(f,n,m) f=_wfopen(n,m) 96 | #endif // not VC++ safe strings 97 | #define MCD_T(s) L ## s 98 | #if MARKUP_SIZEOFWCHAR == 4 // sizeof(wchar_t) == 4 99 | #define MCD_ENC MCD_T("UTF-32") 100 | #else // sizeof(wchar_t) == 2 101 | #define MCD_ENC MCD_T("UTF-16") 102 | #endif 103 | #define MCD_CLEN(p) 1 104 | #else // not MARKUP_WCHAR 105 | #define MCD_CHAR char 106 | #define MCD_PCSZ const char* 107 | #define MCD_PSZLEN (int)strlen 108 | #define MCD_PSZCHR strchr 109 | #define MCD_PSZSTR strstr 110 | #define MCD_PSZTOL strtol 111 | #if defined(MARKUP_SAFESTR) // VC++ safe strings 112 | #define MCD_SSZ(sz) sz,(sizeof(sz)/sizeof(MCD_CHAR)) 113 | #define MCD_PSZCPY(sz,p) strcpy_s(MCD_SSZ(sz),p) 114 | #define MCD_PSZNCPY(sz,p,n) strncpy_s(MCD_SSZ(sz),p,n) 115 | #define MCD_SPRINTF sprintf_s 116 | #define MCD_FOPEN(f,n,m) {if(fopen_s(&f,n,m)!=0)f=NULL;} 117 | #else // not VC++ safe strings 118 | #define MCD_SSZ(sz) sz 119 | #define MCD_PSZCPY strcpy 120 | #define MCD_PSZNCPY strncpy 121 | #define MCD_SPRINTF sprintf 122 | #define MCD_FOPEN(f,n,m) f=fopen(n,m) 123 | #endif // not VC++ safe strings 124 | #define MCD_T(s) s 125 | #if defined(MARKUP_MBCS) // MBCS/double byte 126 | #define MCD_ENC MCD_T("") 127 | #if defined(MARKUP_WINCONV) 128 | #define MCD_CLEN(p) (int)_mbclen((const unsigned char*)p) 129 | #else // not WINCONV 130 | #define MCD_CLEN(p) (int)mblen(p,MB_CUR_MAX) 131 | #endif // not WINCONV 132 | #else // not MBCS/double byte 133 | #define MCD_ENC MCD_T("UTF-8") 134 | #define MCD_CLEN(p) 1 135 | #endif // not MBCS/double byte 136 | #endif // not MARKUP_WCHAR 137 | #if _MSC_VER < 1000 // not VC++ 138 | #define MCD_STRERROR strerror(errno) 139 | #endif // not VC++ 140 | 141 | // String type and function defines (compiler and build-option dependent) 142 | // Define MARKUP_STL to use STL strings 143 | // 144 | #if defined(MARKUP_STL) // STL 145 | #include 146 | #if defined(MARKUP_WCHAR) 147 | #define MCD_STR std::wstring 148 | #else // not MARKUP_WCHAR 149 | #define MCD_STR std::string 150 | #endif // not MARKUP_WCHAR 151 | #define MCD_2PCSZ(s) s.c_str() 152 | #define MCD_STRLENGTH(s) (int)s.size() 153 | #define MCD_STRCLEAR(s) s.erase() 154 | #define MCD_STRCLEARSIZE(s) MCD_STR t; s.swap(t) 155 | #define MCD_STRISEMPTY(s) s.empty() 156 | #define MCD_STRMID(s,n,l) s.substr(n,l) 157 | #define MCD_STRASSIGN(s,p,n) s.assign(p,n) 158 | #define MCD_STRCAPACITY(s) (int)s.capacity() 159 | #define MCD_STRINSERTREPLACE(d,i,r,s) d.replace(i,r,s) 160 | #define MCD_GETBUFFER(s,n) new MCD_CHAR[n+1]; if ((int)s.capacity()<(int)n) s.reserve(n) 161 | #define MCD_RELEASEBUFFER(s,p,n) s.replace(0,s.size(),p,n); delete[]p 162 | #define MCD_BLDRESERVE(s,n) s.reserve(n) 163 | #define MCD_BLDCHECK(s,n,d) ; 164 | #define MCD_BLDRELEASE(s) ; 165 | #define MCD_BLDAPPENDN(s,p,n) s.append(p,n) 166 | #define MCD_BLDAPPEND(s,p) s.append(p) 167 | #define MCD_BLDAPPEND1(s,c) s+=(MCD_CHAR)(c) 168 | #define MCD_BLDLEN(s) (int)s.size() 169 | #define MCD_BLDTRUNC(s,n) s.resize(n) 170 | #else // not STL, i.e. MFC 171 | // afx.h provides CString, to avoid "WINVER not defined" #include stdafh.x in Markup.cpp 172 | #include 173 | #define MCD_STR CString 174 | #define MCD_2PCSZ(s) ((MCD_PCSZ)s) 175 | #define MCD_STRLENGTH(s) s.GetLength() 176 | #define MCD_STRCLEAR(s) s.Empty() 177 | #define MCD_STRCLEARSIZE(s) s=MCD_STR() 178 | #define MCD_STRISEMPTY(s) s.IsEmpty() 179 | #define MCD_STRMID(s,n,l) s.Mid(n,l) 180 | #define MCD_STRASSIGN(s,p,n) memcpy(s.GetBuffer(n),p,(n)*sizeof(MCD_CHAR));s.ReleaseBuffer(n); 181 | #define MCD_STRCAPACITY(s) (((CStringData*)((MCD_PCSZ)s)-1)->nAllocLength) 182 | #define MCD_GETBUFFER(s,n) s.GetBuffer(n) 183 | #define MCD_RELEASEBUFFER(s,p,n) s.ReleaseBuffer(n) 184 | #define MCD_BLDRESERVE(s,n) MCD_CHAR*pD=s.GetBuffer(n); int nL=0 185 | #define MCD_BLDCHECK(s,n,d) if(nL+(int)(d)>n){s.ReleaseBuffer(nL);n<<=2;pD=s.GetBuffer(n);} 186 | #define MCD_BLDRELEASE(s) s.ReleaseBuffer(nL) 187 | #define MCD_BLDAPPENDN(s,p,n) MCD_PSZNCPY(&pD[nL],p,n);nL+=n 188 | #define MCD_BLDAPPEND(s,p) MCD_PSZCPY(&pD[nL],p);nL+=MCD_PSZLEN(p) 189 | #define MCD_BLDAPPEND1(s,c) pD[nL++]=(MCD_CHAR)(c) 190 | #define MCD_BLDLEN(s) nL 191 | #define MCD_BLDTRUNC(s,n) nL=n 192 | #endif // not STL 193 | #define MCD_STRTOINT(s) MCD_PSZTOL(MCD_2PCSZ(s),NULL,10) 194 | 195 | // Allow function args to accept string objects as constant string pointers 196 | struct MCD_CSTR 197 | { 198 | MCD_CSTR() { pcsz=NULL; }; 199 | MCD_CSTR( MCD_PCSZ p ) { pcsz=p; }; 200 | MCD_CSTR( const MCD_STR& s ) { pcsz = MCD_2PCSZ(s); }; 201 | operator MCD_PCSZ() const { return pcsz; }; 202 | MCD_PCSZ pcsz; 203 | }; 204 | 205 | // On Linux and OS X, filenames are not specified in wchar_t 206 | #if defined(MARKUP_WCHAR) && defined(__GNUC__) 207 | #undef MCD_FOPEN 208 | #define MCD_FOPEN(f,n,m) f=fopen(n,m) 209 | #define MCD_T_FILENAME(s) s 210 | #define MCD_PCSZ_FILENAME const char* 211 | struct MCD_CSTR_FILENAME 212 | { 213 | MCD_CSTR_FILENAME() { pcsz=NULL; }; 214 | MCD_CSTR_FILENAME( MCD_PCSZ_FILENAME p ) { pcsz=p; }; 215 | MCD_CSTR_FILENAME( const std::string& s ) { pcsz = s.c_str(); }; 216 | operator MCD_PCSZ_FILENAME() const { return pcsz; }; 217 | MCD_PCSZ_FILENAME pcsz; 218 | }; 219 | #else // not WCHAR GNUC 220 | #define MCD_CSTR_FILENAME MCD_CSTR 221 | #define MCD_T_FILENAME MCD_T 222 | #define MCD_PCSZ_FILENAME MCD_PCSZ 223 | #endif // not WCHAR GNUC 224 | 225 | // File fseek, ftell and offset type 226 | #if defined(__GNUC__) && ! defined(MARKUP_WINDOWS) // non-Windows GNUC 227 | #define MCD_FSEEK fseeko 228 | #define MCD_FTELL ftello 229 | #define MCD_INTFILEOFFSET off_t 230 | #elif _MSC_VER >= 1000 && defined(MARKUP_HUGEFILE) // VC++ HUGEFILE 231 | #if _MSC_VER < 1400 // before VC++ 2005 232 | extern "C" int __cdecl _fseeki64(FILE *, __int64, int); 233 | extern "C" __int64 __cdecl _ftelli64(FILE *); 234 | #endif // before VC++ 2005 235 | #define MCD_FSEEK _fseeki64 236 | #define MCD_FTELL _ftelli64 237 | #define MCD_INTFILEOFFSET __int64 238 | #else // not non-Windows GNUC or VC++ HUGEFILE 239 | #define MCD_FSEEK fseek 240 | #define MCD_FTELL ftell 241 | #define MCD_INTFILEOFFSET long 242 | #endif // not non-Windows GNUC or VC++ HUGEFILE 243 | 244 | // End of line choices: none, return, newline, or CRLF 245 | #if defined(MARKUP_EOL_NONE) 246 | #define MCD_EOL MCD_T("") 247 | #elif defined(MARKUP_EOL_RETURN) // rare; only used on some old operating systems 248 | #define MCD_EOL MCD_T("\r") 249 | #elif defined(MARKUP_EOL_NEWLINE) // Unix standard 250 | #define MCD_EOL MCD_T("\n") 251 | #elif defined(MARKUP_EOL_CRLF) || defined(MARKUP_WINDOWS) // Windows standard 252 | #define MCD_EOL MCD_T("\r\n") 253 | #else // not Windows and not otherwise specified 254 | #define MCD_EOL MCD_T("\n") 255 | #endif // not Windows and not otherwise specified 256 | #define MCD_EOLLEN (sizeof(MCD_EOL)/sizeof(MCD_CHAR)-1) // string length of MCD_EOL 257 | 258 | struct FilePos; 259 | struct TokenPos; 260 | struct NodePos; 261 | struct PathPos; 262 | struct SavedPosMapArray; 263 | struct ElemPosTree; 264 | 265 | class CMarkup 266 | { 267 | public: 268 | CMarkup() { x_InitMarkup(); SetDoc( NULL ); }; 269 | CMarkup( MCD_CSTR szDoc ) { x_InitMarkup(); SetDoc( szDoc ); }; 270 | CMarkup( int nFlags ) { x_InitMarkup(); SetDoc( NULL ); m_nDocFlags = nFlags; }; 271 | CMarkup( const CMarkup& markup ) { x_InitMarkup(); *this = markup; }; 272 | void operator=( const CMarkup& markup ); 273 | ~CMarkup(); 274 | 275 | // Navigate 276 | bool Load( MCD_CSTR_FILENAME szFileName ); 277 | bool SetDoc( MCD_PCSZ pDoc ); 278 | bool SetDoc( const MCD_STR& strDoc ); 279 | bool IsWellFormed(); 280 | bool FindElem( MCD_CSTR szName=NULL ); 281 | bool FindChildElem( MCD_CSTR szName=NULL ); 282 | bool IntoElem(); 283 | bool OutOfElem(); 284 | void ResetChildPos() { x_SetPos(m_iPosParent,m_iPos,0); }; 285 | void ResetMainPos() { x_SetPos(m_iPosParent,0,0); }; 286 | void ResetPos() { x_SetPos(0,0,0); }; 287 | MCD_STR GetTagName() const; 288 | MCD_STR GetChildTagName() const { return x_GetTagName(m_iPosChild); }; 289 | MCD_STR GetData() { return x_GetData(m_iPos); }; 290 | MCD_STR GetChildData() { return x_GetData(m_iPosChild); }; 291 | MCD_STR GetElemContent() const { return x_GetElemContent(m_iPos); }; 292 | MCD_STR GetAttrib( MCD_CSTR szAttrib ) const { return x_GetAttrib(m_iPos,szAttrib); }; 293 | MCD_STR GetChildAttrib( MCD_CSTR szAttrib ) const { return x_GetAttrib(m_iPosChild,szAttrib); }; 294 | bool GetNthAttrib( int n, MCD_STR& strAttrib, MCD_STR& strValue ) const; 295 | MCD_STR GetAttribName( int n ) const; 296 | int FindNode( int nType=0 ); 297 | int GetNodeType() { return m_nNodeType; }; 298 | bool SavePos( MCD_CSTR szPosName=MCD_T(""), int nMap = 0 ); 299 | bool RestorePos( MCD_CSTR szPosName=MCD_T(""), int nMap = 0 ); 300 | bool SetMapSize( int nSize, int nMap = 0 ); 301 | MCD_STR GetError() const; 302 | const MCD_STR& GetResult() const { return m_strResult; }; 303 | int GetDocFlags() const { return m_nDocFlags; }; 304 | void SetDocFlags( int nFlags ) { m_nDocFlags = (nFlags & ~(MDF_READFILE|MDF_WRITEFILE|MDF_APPENDFILE)); }; 305 | enum MarkupDocFlags 306 | { 307 | MDF_UTF16LEFILE = 1, 308 | MDF_UTF8PREAMBLE = 4, 309 | MDF_IGNORECASE = 8, 310 | MDF_READFILE = 16, 311 | MDF_WRITEFILE = 32, 312 | MDF_APPENDFILE = 64, 313 | MDF_UTF16BEFILE = 128, 314 | MDF_TRIMWHITESPACE = 256, 315 | MDF_COLLAPSEWHITESPACE = 512 316 | }; 317 | enum MarkupNodeFlags 318 | { 319 | MNF_WITHCDATA = 0x01, 320 | MNF_WITHNOLINES = 0x02, 321 | MNF_WITHXHTMLSPACE = 0x04, 322 | MNF_WITHREFS = 0x08, 323 | MNF_WITHNOEND = 0x10, 324 | MNF_ESCAPEQUOTES = 0x100, 325 | MNF_NONENDED = 0x100000, 326 | MNF_ILLDATA = 0x200000 327 | }; 328 | enum MarkupNodeType 329 | { 330 | MNT_ELEMENT = 1, // 0x0001 331 | MNT_TEXT = 2, // 0x0002 332 | MNT_WHITESPACE = 4, // 0x0004 333 | MNT_TEXT_AND_WHITESPACE = 6, // 0x0006 334 | MNT_CDATA_SECTION = 8, // 0x0008 335 | MNT_PROCESSING_INSTRUCTION = 16, // 0x0010 336 | MNT_COMMENT = 32, // 0x0020 337 | MNT_DOCUMENT_TYPE = 64, // 0x0040 338 | MNT_EXCLUDE_WHITESPACE = 123, // 0x007b 339 | MNT_LONE_END_TAG = 128, // 0x0080 340 | MNT_NODE_ERROR = 32768 // 0x8000 341 | }; 342 | 343 | // Create 344 | bool Save( MCD_CSTR_FILENAME szFileName ); 345 | const MCD_STR& GetDoc() const { return m_strDoc; }; 346 | bool AddElem( MCD_CSTR szName, MCD_CSTR szData=NULL, int nFlags=0 ) { return x_AddElem(szName,szData,nFlags); }; 347 | bool InsertElem( MCD_CSTR szName, MCD_CSTR szData=NULL, int nFlags=0 ) { return x_AddElem(szName,szData,nFlags|MNF_INSERT); }; 348 | bool AddChildElem( MCD_CSTR szName, MCD_CSTR szData=NULL, int nFlags=0 ) { return x_AddElem(szName,szData,nFlags|MNF_CHILD); }; 349 | bool InsertChildElem( MCD_CSTR szName, MCD_CSTR szData=NULL, int nFlags=0 ) { return x_AddElem(szName,szData,nFlags|MNF_INSERT|MNF_CHILD); }; 350 | bool AddElem( MCD_CSTR szName, int nValue, int nFlags=0 ) { return x_AddElem(szName,nValue,nFlags); }; 351 | bool InsertElem( MCD_CSTR szName, int nValue, int nFlags=0 ) { return x_AddElem(szName,nValue,nFlags|MNF_INSERT); }; 352 | bool AddChildElem( MCD_CSTR szName, int nValue, int nFlags=0 ) { return x_AddElem(szName,nValue,nFlags|MNF_CHILD); }; 353 | bool InsertChildElem( MCD_CSTR szName, int nValue, int nFlags=0 ) { return x_AddElem(szName,nValue,nFlags|MNF_INSERT|MNF_CHILD); }; 354 | bool AddAttrib( MCD_CSTR szAttrib, MCD_CSTR szValue ) { return x_SetAttrib(m_iPos,szAttrib,szValue); }; 355 | bool AddChildAttrib( MCD_CSTR szAttrib, MCD_CSTR szValue ) { return x_SetAttrib(m_iPosChild,szAttrib,szValue); }; 356 | bool AddAttrib( MCD_CSTR szAttrib, int nValue ) { return x_SetAttrib(m_iPos,szAttrib,nValue); }; 357 | bool AddChildAttrib( MCD_CSTR szAttrib, int nValue ) { return x_SetAttrib(m_iPosChild,szAttrib,nValue); }; 358 | bool AddSubDoc( MCD_CSTR szSubDoc ) { return x_AddSubDoc(szSubDoc,0); }; 359 | bool InsertSubDoc( MCD_CSTR szSubDoc ) { return x_AddSubDoc(szSubDoc,MNF_INSERT); }; 360 | MCD_STR GetSubDoc() { return x_GetSubDoc(m_iPos); }; 361 | bool AddChildSubDoc( MCD_CSTR szSubDoc ) { return x_AddSubDoc(szSubDoc,MNF_CHILD); }; 362 | bool InsertChildSubDoc( MCD_CSTR szSubDoc ) { return x_AddSubDoc(szSubDoc,MNF_CHILD|MNF_INSERT); }; 363 | MCD_STR GetChildSubDoc() { return x_GetSubDoc(m_iPosChild); }; 364 | bool AddNode( int nType, MCD_CSTR szText ) { return x_AddNode(nType,szText,0); }; 365 | bool InsertNode( int nType, MCD_CSTR szText ) { return x_AddNode(nType,szText,MNF_INSERT); }; 366 | 367 | // Modify 368 | bool RemoveElem(); 369 | bool RemoveChildElem(); 370 | bool RemoveNode(); 371 | bool SetAttrib( MCD_CSTR szAttrib, MCD_CSTR szValue, int nFlags=0 ) { return x_SetAttrib(m_iPos,szAttrib,szValue,nFlags); }; 372 | bool SetChildAttrib( MCD_CSTR szAttrib, MCD_CSTR szValue, int nFlags=0 ) { return x_SetAttrib(m_iPosChild,szAttrib,szValue,nFlags); }; 373 | bool SetAttrib( MCD_CSTR szAttrib, int nValue, int nFlags=0 ) { return x_SetAttrib(m_iPos,szAttrib,nValue,nFlags); }; 374 | bool SetChildAttrib( MCD_CSTR szAttrib, int nValue, int nFlags=0 ) { return x_SetAttrib(m_iPosChild,szAttrib,nValue,nFlags); }; 375 | bool SetData( MCD_CSTR szData, int nFlags=0 ) { return x_SetData(m_iPos,szData,nFlags); }; 376 | bool SetChildData( MCD_CSTR szData, int nFlags=0 ) { return x_SetData(m_iPosChild,szData,nFlags); }; 377 | bool SetData( int nValue ) { return x_SetData(m_iPos,nValue); }; 378 | bool SetChildData( int nValue ) { return x_SetData(m_iPosChild,nValue); }; 379 | bool SetElemContent( MCD_CSTR szContent ) { return x_SetElemContent(szContent); }; 380 | 381 | 382 | // Utility 383 | static bool ReadTextFile( MCD_CSTR_FILENAME szFileName, MCD_STR& strDoc, MCD_STR* pstrResult=NULL, int* pnDocFlags=NULL, MCD_STR* pstrEncoding=NULL ); 384 | static bool WriteTextFile( MCD_CSTR_FILENAME szFileName, const MCD_STR& strDoc, MCD_STR* pstrResult=NULL, int* pnDocFlags=NULL, MCD_STR* pstrEncoding=NULL ); 385 | static MCD_STR EscapeText( MCD_CSTR szText, int nFlags = 0 ); 386 | static MCD_STR UnescapeText( MCD_CSTR szText, int nTextLength = -1, int nFlags = 0 ); 387 | static int UTF16To8( char *pszUTF8, const unsigned short* pwszUTF16, int nUTF8Count ); 388 | static int UTF8To16( unsigned short* pwszUTF16, const char* pszUTF8, int nUTF8Count ); 389 | static MCD_STR UTF8ToA( MCD_CSTR pszUTF8, int* pnFailed = NULL ); 390 | static MCD_STR AToUTF8( MCD_CSTR pszANSI ); 391 | static void EncodeCharUTF8( int nUChar, char* pszUTF8, int& nUTF8Len ); 392 | static int DecodeCharUTF8( const char*& pszUTF8, const char* pszUTF8End = NULL ); 393 | static void EncodeCharUTF16( int nUChar, unsigned short* pwszUTF16, int& nUTF16Len ); 394 | static int DecodeCharUTF16( const unsigned short*& pwszUTF16, const unsigned short* pszUTF16End = NULL ); 395 | static bool DetectUTF8( const char* pText, int nTextLen, int* pnNonASCII = NULL, bool* bErrorAtEnd = NULL ); 396 | static MCD_STR GetDeclaredEncoding( MCD_CSTR szDoc ); 397 | static int GetEncodingCodePage( MCD_CSTR pszEncoding ); 398 | 399 | protected: 400 | 401 | #if defined(_DEBUG) 402 | MCD_PCSZ m_pDebugCur; 403 | MCD_PCSZ m_pDebugPos; 404 | #endif // DEBUG 405 | 406 | MCD_STR m_strDoc; 407 | MCD_STR m_strResult; 408 | 409 | int m_iPosParent; 410 | int m_iPos; 411 | int m_iPosChild; 412 | int m_iPosFree; 413 | int m_iPosDeleted; 414 | int m_nNodeType; 415 | int m_nNodeOffset; 416 | int m_nNodeLength; 417 | int m_nDocFlags; 418 | 419 | FilePos* m_pFilePos; 420 | SavedPosMapArray* m_pSavedPosMaps; 421 | ElemPosTree* m_pElemPosTree; 422 | 423 | enum MarkupNodeFlagsInternal 424 | { 425 | MNF_INSERT = 0x002000, 426 | MNF_CHILD = 0x004000 427 | }; 428 | 429 | #if defined(_DEBUG) // DEBUG 430 | void x_SetDebugState(); 431 | #define MARKUP_SETDEBUGSTATE x_SetDebugState() 432 | #else // not DEBUG 433 | #define MARKUP_SETDEBUGSTATE 434 | #endif // not DEBUG 435 | 436 | void x_InitMarkup(); 437 | void x_SetPos( int iPosParent, int iPos, int iPosChild ); 438 | int x_GetFreePos(); 439 | bool x_AllocElemPos( int nNewSize = 0 ); 440 | int x_GetParent( int i ); 441 | bool x_ParseDoc(); 442 | int x_ParseElem( int iPos, TokenPos& token ); 443 | int x_FindElem( int iPosParent, int iPos, PathPos& path ) const; 444 | MCD_STR x_GetPath( int iPos ) const; 445 | MCD_STR x_GetTagName( int iPos ) const; 446 | MCD_STR x_GetData( int iPos ); 447 | MCD_STR x_GetAttrib( int iPos, MCD_PCSZ pAttrib ) const; 448 | static MCD_STR x_EncodeCDATASection( MCD_PCSZ szData ); 449 | bool x_AddElem( MCD_PCSZ pName, MCD_PCSZ pValue, int nFlags ); 450 | bool x_AddElem( MCD_PCSZ pName, int nValue, int nFlags ); 451 | MCD_STR x_GetSubDoc( int iPos ); 452 | bool x_AddSubDoc( MCD_PCSZ pSubDoc, int nFlags ); 453 | bool x_SetAttrib( int iPos, MCD_PCSZ pAttrib, MCD_PCSZ pValue, int nFlags=0 ); 454 | bool x_SetAttrib( int iPos, MCD_PCSZ pAttrib, int nValue, int nFlags=0 ); 455 | bool x_AddNode( int nNodeType, MCD_PCSZ pText, int nNodeFlags ); 456 | void x_RemoveNode( int iPosParent, int& iPos, int& nNodeType, int& nNodeOffset, int& nNodeLength ); 457 | static bool x_CreateNode( MCD_STR& strNode, int nNodeType, MCD_PCSZ pText ); 458 | int x_InsertNew( int iPosParent, int& iPosRel, NodePos& node ); 459 | void x_AdjustForNode( int iPosParent, int iPos, int nShift ); 460 | void x_Adjust( int iPos, int nShift, bool bAfterPos = false ); 461 | void x_LinkElem( int iPosParent, int iPosBefore, int iPos ); 462 | int x_UnlinkElem( int iPos ); 463 | int x_UnlinkPrevElem( int iPosParent, int iPosBefore, int iPos ); 464 | int x_ReleaseSubDoc( int iPos ); 465 | int x_ReleasePos( int iPos ); 466 | void x_CheckSavedPos(); 467 | bool x_SetData( int iPos, MCD_PCSZ szData, int nFlags ); 468 | bool x_SetData( int iPos, int nValue ); 469 | int x_RemoveElem( int iPos ); 470 | MCD_STR x_GetElemContent( int iPos ) const; 471 | bool x_SetElemContent( MCD_PCSZ szContent ); 472 | void x_DocChange( int nLeft, int nReplace, const MCD_STR& strInsert ); 473 | }; 474 | 475 | #endif // !defined(_MARKUP_H_INCLUDED_) 476 | -------------------------------------------------------------------------------- /PETOOLS/CommonLib/LogLib/log4z.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Log4z License 3 | * ----------- 4 | * 5 | * Log4z is licensed under the terms of the MIT license reproduced below. 6 | * This means that Log4z is free software and can be used for both academic 7 | * and commercial purposes at absolutely no cost. 8 | * 9 | * 10 | * =============================================================================== 11 | * 12 | * Copyright (C) 2010-2017 YaweiZhang . 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to deal 16 | * in the Software without restriction, including without limitation the rights 17 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | * copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | * THE SOFTWARE. 31 | * 32 | * =============================================================================== 33 | * 34 | * (end of COPYRIGHT) 35 | */ 36 | 37 | 38 | /* 39 | * AUTHORS: YaweiZhang 40 | * VERSION: 3.5.0 41 | * PURPOSE: A lightweight library for error reporting and logging to file and screen . 42 | * CREATION: 2010.10.4 43 | * LCHANGE: 2017.08.20 44 | * LICENSE: Expat/MIT License, See Copyright Notice at the begin of this file. 45 | */ 46 | 47 | 48 | /* 49 | * contact me: 50 | * tencent qq group: 19811947 51 | * mail: yawei.zhang@foxmail.com 52 | */ 53 | 54 | 55 | /* 56 | * UPDATES LOG 57 | * 58 | * VERSION 0.1.0 59 | * create the first project. 60 | * It support put log to screen and files, 61 | * support log level, support one day one log file. 62 | * support multi-thread, cross-platform. 63 | * 64 | * VERSION .... 65 | * ... 66 | * 67 | * VERSION 0.9.0 68 | * support config files. 69 | * support color text in screen. 70 | * support multiple output to different files. 71 | * 72 | * VERSION 1.0.0 73 | * support comments in the config file. 74 | * add a advanced demo in the ./project 75 | * fix some details. 76 | * 77 | * VERSION 1.0.1 78 | * change and add some Comments in the log4z 79 | * simplify the 'fast_test' demo projects. 80 | * 81 | * VERSION 1.1.0 82 | * the method Start will wait for the logger thread started. 83 | * config and add method change. 84 | * namespace change. 85 | * 86 | * VERSION 1.1.1 87 | * add status info method. 88 | * optimize. 89 | * 90 | * VERSION 1.2.0 91 | * add stress test demo 92 | * rewrite Stream module,better performance. 93 | * 94 | * VERSION 1.2.1 95 | * fixed type name 'long' stream format on 64/32 operation system. 96 | * logger will not loss any log on process normal exit. 97 | * 98 | * VERSION 2.0.0 99 | * new interface: 100 | * merge some Main interface and Dynamic interface 101 | * add Change Logger Attribute method by thread-safe 102 | * new config design. 103 | * log file name append process id. 104 | * 105 | * VERSION 2.1 106 | * support binary text output 107 | * rewrite write file module, support vs2005 open Chinese characters path 108 | * 109 | * VERSION 2.2 110 | * optimized binary stream output view 111 | * support wchar * string. 112 | * 113 | * VERSION 2.3 114 | * adjust output file named. 115 | * support different month different directory. 116 | * adjust some detail. 117 | * 118 | * VERSION 2.4 119 | * support rolling log file. 120 | * support hot update configure 121 | * used precision time in log. 122 | * micro set default logger attribute 123 | * fix tls bug in windows xp dll 124 | * 125 | * VERSION 2.5 126 | * screen output can choice synchronous or not 127 | * fix sometimes color will disorder on windows. 128 | * eliminate some compiler warning 129 | * fix sem_timewait in linux 130 | * add format-style method at input log, cannot support vs2003 and VC6. 131 | * fix WCHAR String cannot output 132 | * optimize std::string, binary log input, and support std::wstring. 133 | * clean code, better readability 134 | * 135 | * VERSION 2.6 136 | * add PrePushLog 137 | * better performance when log is filter out. 138 | * interface replace std::string because it's in shared library is unsafe. 139 | * add log level 'trace' 140 | * 141 | * VERSION 2.6.1 142 | * fix bug from defined _MSC_VER 143 | * 144 | * VERSION 2.7 145 | * compatible mac machine, now log4z can working in linux/windows/mac. 146 | * 147 | * VERSION 2.8 148 | * support synchronous written to file and thread-safe 149 | * fix compatibility on MinGW. a constant value suffix. 150 | * ignore utf-8 file BOM when load configure file 151 | * use macro WIN32_LEAN_AND_MEAN replace head file winsock2.h 152 | * new naming notations 153 | * 154 | * VERSION 3.0 155 | * new naming notations 156 | * support for reading config from a string. 157 | * remove all TLS code, used dispatch_semaphore in apple OS. 158 | * support system: windows, linux, mac, iOS 159 | * 160 | * VERSION 3.1 161 | * add method enable/disable logger by specific logger id 162 | * add method enable/disable log suffix line number. 163 | * add method enable/disable log output to file. 164 | * 165 | * VERSION 3.2 166 | * add interface setLoggerName,setLoggerPath,setAutoUpdate 167 | * support auto update from configure file 168 | * 169 | * VERSION 3.3 170 | * support map vector list 171 | * support continuum via travis. 172 | * new hot change design, all change realize need via push log flow. 173 | * support oem string convert. 174 | * new method to read whole content of file. 175 | * check configure's checksum when auto update it. 176 | * some other optimize. 177 | * 178 | * VERSION 3.5 179 | * optimization 180 | * 181 | */ 182 | 183 | 184 | #pragma once 185 | #ifndef _ZSUMMER_LOG4Z_H_ 186 | #define _ZSUMMER_LOG4Z_H_ 187 | 188 | #include 189 | #include 190 | #include 191 | #include 192 | #include 193 | #include 194 | #include 195 | #ifdef WIN32 196 | #define WIN32_LEAN_AND_MEAN 197 | #include 198 | #endif 199 | #include 200 | #include 201 | #include 202 | #include 203 | #include 204 | 205 | 206 | //! logger ID type. DO NOT TOUCH 207 | typedef int LoggerId; 208 | 209 | //! the invalid logger id. DO NOT TOUCH 210 | const int LOG4Z_INVALID_LOGGER_ID = -1; 211 | 212 | //! the main logger id. DO NOT TOUCH 213 | //! can use this id to set the main logger's attribute. 214 | //! example: 215 | //! ILog4zManager::getPtr()->setLoggerLevel(LOG4Z_MAIN_LOGGER_ID, LOG_LEVEL_WARN); 216 | //! ILog4zManager::getPtr()->setLoggerDisplay(LOG4Z_MAIN_LOGGER_ID, false); 217 | const int LOG4Z_MAIN_LOGGER_ID = 0; 218 | 219 | //! the main logger name. DO NOT TOUCH 220 | const char*const LOG4Z_MAIN_LOGGER_KEY = "Main"; 221 | 222 | //! check VC VERSION. DO NOT TOUCH 223 | //! format micro cannot support VC6 or VS2003, please use stream input log, like LOGI, LOGD, LOG_DEBUG, LOG_STREAM ... 224 | #if _MSC_VER >= 1400 //MSVC >= VS2005 225 | #define LOG4Z_FORMAT_INPUT_ENABLE 226 | #endif 227 | 228 | #ifndef WIN32 229 | #define LOG4Z_FORMAT_INPUT_ENABLE 230 | #endif 231 | 232 | //! LOG Level 233 | enum ENUM_LOG_LEVEL 234 | { 235 | LOG_LEVEL_TRACE = 0, 236 | LOG_LEVEL_DEBUG, 237 | LOG_LEVEL_INFO, 238 | LOG_LEVEL_WARN, 239 | LOG_LEVEL_ERROR, 240 | LOG_LEVEL_ALARM, 241 | LOG_LEVEL_FATAL, 242 | }; 243 | 244 | ////////////////////////////////////////////////////////////////////////// 245 | //! -----------------default logger config, can change on this.----------- 246 | ////////////////////////////////////////////////////////////////////////// 247 | //! the max logger count. 248 | const int LOG4Z_LOGGER_MAX = 20; 249 | //! the max log content length. 250 | const int LOG4Z_LOG_BUF_SIZE = 1024 * 8; 251 | //! the max stl container depth. 252 | const int LOG4Z_LOG_CONTAINER_DEPTH = 5; 253 | //! the log queue length limit size. 254 | const int LOG4Z_LOG_QUEUE_LIMIT_SIZE = 20000; 255 | 256 | //! all logger synchronous output or not 257 | const bool LOG4Z_ALL_SYNCHRONOUS_OUTPUT = false; 258 | //! all logger synchronous display to the windows debug output 259 | const bool LOG4Z_ALL_DEBUGOUTPUT_DISPLAY = false; 260 | 261 | //! default logger output file. 262 | const char* const LOG4Z_DEFAULT_PATH = "./log/"; 263 | //! default log filter level 264 | const int LOG4Z_DEFAULT_LEVEL = LOG_LEVEL_DEBUG; 265 | //! default logger display 266 | const bool LOG4Z_DEFAULT_DISPLAY = true; 267 | //! default logger output to file 268 | const bool LOG4Z_DEFAULT_OUTFILE = true; 269 | //! default logger month dir used status 270 | const bool LOG4Z_DEFAULT_MONTHDIR = false; 271 | //! default logger output file limit size, unit M byte. 272 | const int LOG4Z_DEFAULT_LIMITSIZE = 100; 273 | //! default logger show suffix (file name and line number) 274 | const bool LOG4Z_DEFAULT_SHOWSUFFIX = true; 275 | //! support ANSI->OEM console conversion on Windows 276 | #undef LOG4Z_OEM_CONSOLE 277 | //! default logger force reserve log file count. 278 | const size_t LOG4Z_FORCE_RESERVE_FILE_COUNT = 7; 279 | 280 | /////////////////////////////////////////////////////////////////////////// 281 | //! ----------------------------------------------------------------------- 282 | ////////////////////////////////////////////////////////////////////////// 283 | 284 | #ifndef _ZSUMMER_BEGIN 285 | #define _ZSUMMER_BEGIN namespace zsummer { 286 | #endif 287 | #ifndef _ZSUMMER_LOG4Z_BEGIN 288 | #define _ZSUMMER_LOG4Z_BEGIN namespace log4z { 289 | #endif 290 | _ZSUMMER_BEGIN 291 | _ZSUMMER_LOG4Z_BEGIN 292 | 293 | 294 | struct LogData 295 | { 296 | LoggerId _id; //dest logger id 297 | int _type; //type. 298 | int _typeval; 299 | int _level; //log level 300 | time_t _time; //create time 301 | unsigned int _precise; //create time 302 | unsigned int _threadID; 303 | int _contentLen; 304 | char _content[1]; //content 305 | }; 306 | 307 | //! log4z class 308 | class ILog4zManager 309 | { 310 | public: 311 | ILog4zManager(){}; 312 | virtual ~ILog4zManager(){}; 313 | 314 | //! Log4z Singleton 315 | 316 | static ILog4zManager * getInstance(); 317 | inline static ILog4zManager & getRef(){return *getInstance();} 318 | inline static ILog4zManager * getPtr(){return getInstance();} 319 | 320 | //! Config or overwrite configure 321 | //! Needs to be called before ILog4zManager::Start,, OR Do not call. 322 | virtual bool config(const char * configPath) = 0; 323 | virtual bool configFromString(const char * configContent) = 0; 324 | 325 | //! Create or overwrite logger. 326 | //! Needs to be called before ILog4zManager::Start, OR Do not call. 327 | virtual LoggerId createLogger(const char* key) = 0; 328 | 329 | //! Start Log Thread. This method can only be called once by one process. 330 | virtual bool start() = 0; 331 | 332 | //! Default the method will be calling at process exit auto. 333 | //! Default no need to call and no recommended. 334 | virtual bool stop() = 0; 335 | 336 | //! Find logger. thread safe. 337 | virtual LoggerId findLogger(const char* key) =0; 338 | 339 | //pre-check the log filter. if filter out return false. 340 | virtual bool prePushLog(LoggerId id, int level) = 0; 341 | //! Push log, thread safe. 342 | virtual bool pushLog(LogData * pLog, const char * file = NULL, int line = 0) = 0; 343 | 344 | //! set logger's attribute, thread safe. 345 | virtual bool enableLogger(LoggerId id, bool enable) = 0; // immediately when enable, and queue up when disable. 346 | virtual bool setLoggerName(LoggerId id, const char * name) = 0; 347 | virtual bool setLoggerPath(LoggerId id, const char * path) = 0; 348 | virtual bool setLoggerLevel(LoggerId id, int nLevel) = 0; // immediately when enable, and queue up when disable. 349 | virtual bool setLoggerFileLine(LoggerId id, bool enable) = 0; 350 | virtual bool setLoggerDisplay(LoggerId id, bool enable) = 0; 351 | virtual bool setLoggerOutFile(LoggerId id, bool enable) = 0; 352 | virtual bool setLoggerLimitsize(LoggerId id, unsigned int limitsize) = 0; 353 | virtual bool setLoggerMonthdir(LoggerId id, bool enable) = 0; 354 | virtual bool setLoggerReserveTime(LoggerId id, time_t sec) = 0; 355 | 356 | 357 | //! Update logger's attribute from config file, thread safe. 358 | virtual bool setAutoUpdate(int interval/*per second, 0 is disable auto update*/) = 0; 359 | virtual bool updateConfig() = 0; 360 | 361 | //! Log4z status statistics, thread safe. 362 | virtual bool isLoggerEnable(LoggerId id) = 0; 363 | virtual unsigned long long getStatusTotalWriteCount() = 0; 364 | virtual unsigned long long getStatusTotalWriteBytes() = 0; 365 | virtual unsigned long long getStatusTotalPushQueue() = 0; 366 | virtual unsigned long long getStatusTotalPopQueue() = 0; 367 | virtual unsigned int getStatusActiveLoggers() = 0; 368 | 369 | virtual LogData * makeLogData(LoggerId id, int level) = 0; 370 | virtual void freeLogData(LogData * log) = 0; 371 | }; 372 | 373 | class Log4zStream; 374 | class Log4zBinary; 375 | 376 | #ifndef _ZSUMMER_END 377 | #define _ZSUMMER_END } 378 | #endif 379 | #ifndef _ZSUMMER_LOG4Z_END 380 | #define _ZSUMMER_LOG4Z_END } 381 | #endif 382 | 383 | _ZSUMMER_LOG4Z_END 384 | _ZSUMMER_END 385 | 386 | 387 | 388 | //! base macro. 389 | #define LOG_STREAM(id, level, file, line, log)\ 390 | do{\ 391 | if (zsummer::log4z::ILog4zManager::getPtr()->prePushLog(id,level)) \ 392 | {\ 393 | zsummer::log4z::LogData * __pLog = zsummer::log4z::ILog4zManager::getPtr()->makeLogData(id, level); \ 394 | zsummer::log4z::Log4zStream __ss(__pLog->_content + __pLog->_contentLen, LOG4Z_LOG_BUF_SIZE - __pLog->_contentLen);\ 395 | __ss << log;\ 396 | __pLog->_contentLen += __ss.getCurrentLen(); \ 397 | zsummer::log4z::ILog4zManager::getPtr()->pushLog(__pLog, file, line);\ 398 | }\ 399 | } while (0) 400 | 401 | 402 | //! fast macro 403 | #define LOG_TRACE(id, log) LOG_STREAM(id, LOG_LEVEL_TRACE, __FILE__, __LINE__, log) 404 | #define LOG_DEBUG(id, log) LOG_STREAM(id, LOG_LEVEL_DEBUG, __FILE__, __LINE__, log) 405 | #define LOG_INFO(id, log) LOG_STREAM(id, LOG_LEVEL_INFO, __FILE__, __LINE__, log) 406 | #define LOG_WARN(id, log) LOG_STREAM(id, LOG_LEVEL_WARN, __FILE__, __LINE__, log) 407 | #define LOG_ERROR(id, log) LOG_STREAM(id, LOG_LEVEL_ERROR, __FILE__, __LINE__, log) 408 | #define LOG_ALARM(id, log) LOG_STREAM(id, LOG_LEVEL_ALARM, __FILE__, __LINE__, log) 409 | #define LOG_FATAL(id, log) LOG_STREAM(id, LOG_LEVEL_FATAL, __FILE__, __LINE__, log) 410 | 411 | //! super macro. 412 | #define LOGT( log ) LOG_TRACE(LOG4Z_MAIN_LOGGER_ID, log ) 413 | #define LOGD( log ) LOG_DEBUG(LOG4Z_MAIN_LOGGER_ID, log ) 414 | #define LOGI( log ) LOG_INFO(LOG4Z_MAIN_LOGGER_ID, log ) 415 | #define LOGW( log ) LOG_WARN(LOG4Z_MAIN_LOGGER_ID, log ) 416 | #define LOGE( log ) LOG_ERROR(LOG4Z_MAIN_LOGGER_ID, log ) 417 | #define LOGA( log ) LOG_ALARM(LOG4Z_MAIN_LOGGER_ID, log ) 418 | #define LOGF( log ) LOG_FATAL(LOG4Z_MAIN_LOGGER_ID, log ) 419 | 420 | 421 | //! format input log. 422 | #ifdef LOG4Z_FORMAT_INPUT_ENABLE 423 | #ifdef WIN32 424 | #define LOG_FORMAT(id, level, file, line, logformat, ...) \ 425 | do{ \ 426 | if (zsummer::log4z::ILog4zManager::getPtr()->prePushLog(id,level)) \ 427 | {\ 428 | zsummer::log4z::LogData * __pLog = zsummer::log4z::ILog4zManager::getPtr()->makeLogData(id, level); \ 429 | int __logLen = _snprintf_s(__pLog->_content + __pLog->_contentLen, LOG4Z_LOG_BUF_SIZE - __pLog->_contentLen, _TRUNCATE, logformat, ##__VA_ARGS__); \ 430 | if (__logLen < 0) __logLen = LOG4Z_LOG_BUF_SIZE - __pLog->_contentLen; \ 431 | __pLog->_contentLen += __logLen; \ 432 | zsummer::log4z::ILog4zManager::getPtr()->pushLog(__pLog, file, line); \ 433 | }\ 434 | } while (0) 435 | #else 436 | #define LOG_FORMAT(id, level, file, line, logformat, ...) \ 437 | do{ \ 438 | if (zsummer::log4z::ILog4zManager::getPtr()->prePushLog(id,level)) \ 439 | {\ 440 | zsummer::log4z::LogData * __pLog = zsummer::log4z::ILog4zManager::getPtr()->makeLogData(id, level); \ 441 | int __logLen = snprintf(__pLog->_content + __pLog->_contentLen, LOG4Z_LOG_BUF_SIZE - __pLog->_contentLen,logformat, ##__VA_ARGS__); \ 442 | if (__logLen < 0) __logLen = 0; \ 443 | if (__logLen > LOG4Z_LOG_BUF_SIZE - __pLog->_contentLen) __logLen = LOG4Z_LOG_BUF_SIZE - __pLog->_contentLen; \ 444 | __pLog->_contentLen += __logLen; \ 445 | zsummer::log4z::ILog4zManager::getPtr()->pushLog(__pLog, file, line); \ 446 | } \ 447 | }while(0) 448 | #endif 449 | //!format string 450 | #define LOGFMT_TRACE(id, fmt, ...) LOG_FORMAT(id, LOG_LEVEL_TRACE, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 451 | #define LOGFMT_DEBUG(id, fmt, ...) LOG_FORMAT(id, LOG_LEVEL_DEBUG, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 452 | #define LOGFMT_INFO(id, fmt, ...) LOG_FORMAT(id, LOG_LEVEL_INFO, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 453 | #define LOGFMT_WARN(id, fmt, ...) LOG_FORMAT(id, LOG_LEVEL_WARN, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 454 | #define LOGFMT_ERROR(id, fmt, ...) LOG_FORMAT(id, LOG_LEVEL_ERROR, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 455 | #define LOGFMT_ALARM(id, fmt, ...) LOG_FORMAT(id, LOG_LEVEL_ALARM, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 456 | #define LOGFMT_FATAL(id, fmt, ...) LOG_FORMAT(id, LOG_LEVEL_FATAL, __FILE__, __LINE__, fmt, ##__VA_ARGS__) 457 | #define LOGFMTT( fmt, ...) LOGFMT_TRACE(LOG4Z_MAIN_LOGGER_ID, fmt, ##__VA_ARGS__) 458 | #define LOGFMTD( fmt, ...) LOGFMT_DEBUG(LOG4Z_MAIN_LOGGER_ID, fmt, ##__VA_ARGS__) 459 | #define LOGFMTI( fmt, ...) LOGFMT_INFO(LOG4Z_MAIN_LOGGER_ID, fmt, ##__VA_ARGS__) 460 | #define LOGFMTW( fmt, ...) LOGFMT_WARN(LOG4Z_MAIN_LOGGER_ID, fmt, ##__VA_ARGS__) 461 | #define LOGFMTE( fmt, ...) LOGFMT_ERROR(LOG4Z_MAIN_LOGGER_ID, fmt, ##__VA_ARGS__) 462 | #define LOGFMTA( fmt, ...) LOGFMT_ALARM(LOG4Z_MAIN_LOGGER_ID, fmt, ##__VA_ARGS__) 463 | #define LOGFMTF( fmt, ...) LOGFMT_FATAL(LOG4Z_MAIN_LOGGER_ID, fmt, ##__VA_ARGS__) 464 | #else 465 | inline void empty_log_format_function1(LoggerId id, const char*, ...){} 466 | inline void empty_log_format_function2(const char*, ...){} 467 | #define LOGFMT_TRACE empty_log_format_function1 468 | #define LOGFMT_DEBUG LOGFMT_TRACE 469 | #define LOGFMT_INFO LOGFMT_TRACE 470 | #define LOGFMT_WARN LOGFMT_TRACE 471 | #define LOGFMT_ERROR LOGFMT_TRACE 472 | #define LOGFMT_ALARM LOGFMT_TRACE 473 | #define LOGFMT_FATAL LOGFMT_TRACE 474 | #define LOGFMTT empty_log_format_function2 475 | #define LOGFMTD LOGFMTT 476 | #define LOGFMTI LOGFMTT 477 | #define LOGFMTW LOGFMTT 478 | #define LOGFMTE LOGFMTT 479 | #define LOGFMTA LOGFMTT 480 | #define LOGFMTF LOGFMTT 481 | #endif 482 | 483 | 484 | _ZSUMMER_BEGIN 485 | _ZSUMMER_LOG4Z_BEGIN 486 | 487 | //! optimze from std::stringstream to Log4zStream 488 | #ifdef WIN32 489 | #pragma warning(push) 490 | #pragma warning(disable:4996) 491 | #endif 492 | class Log4zBinary 493 | { 494 | public: 495 | Log4zBinary(const void * buf, size_t len) 496 | { 497 | this->buf = (const char *)buf; 498 | this->len = len; 499 | } 500 | const char * buf; 501 | size_t len; 502 | }; 503 | 504 | class Log4zString 505 | { 506 | public: 507 | Log4zString(const char * buf, size_t len) 508 | { 509 | this->buf = (const char *)buf; 510 | this->len = len; 511 | } 512 | const char * buf; 513 | size_t len; 514 | }; 515 | 516 | class Log4zStream 517 | { 518 | public: 519 | inline Log4zStream(char * buf, int len); 520 | inline int getCurrentLen(){return (int)(_cur - _begin);} 521 | public: 522 | inline Log4zStream & writeLongLong(long long t, int width = 0, int dec = 10); 523 | inline Log4zStream & writeULongLong(unsigned long long t, int width = 0, int dec = 10); 524 | inline Log4zStream & writeDouble(double t, bool isSimple); 525 | inline Log4zStream & writePointer(const void * t); 526 | inline Log4zStream & writeString(const char * t) { return writeString(t, strlen(t)); }; 527 | inline Log4zStream & writeString(const char * t, size_t len); 528 | inline Log4zStream & writeChar(char ch); 529 | inline Log4zStream & writeBinary(const Log4zBinary & t); 530 | public: 531 | inline Log4zStream & operator <<(const void * t){ return writePointer(t); } 532 | 533 | inline Log4zStream & operator <<(const char * t){return writeString(t);} 534 | 535 | inline Log4zStream & operator <<(bool t){ return (t ? writeString("true", 4) : writeString("false", 5));} 536 | 537 | inline Log4zStream & operator <<(char t){return writeChar(t);} 538 | 539 | inline Log4zStream & operator <<(unsigned char t){return writeULongLong(t);} 540 | 541 | inline Log4zStream & operator <<(short t){ return writeLongLong(t); } 542 | 543 | inline Log4zStream & operator <<(unsigned short t){ return writeULongLong(t); } 544 | 545 | inline Log4zStream & operator <<(int t){return writeLongLong(t);} 546 | 547 | inline Log4zStream & operator <<(unsigned int t){return writeULongLong(t);} 548 | 549 | inline Log4zStream & operator <<(long t) { return writeLongLong(t); } 550 | 551 | inline Log4zStream & operator <<(unsigned long t){ return writeULongLong(t); } 552 | 553 | inline Log4zStream & operator <<(long long t) { return writeLongLong(t); } 554 | 555 | inline Log4zStream & operator <<(unsigned long long t){ return writeULongLong(t); } 556 | 557 | inline Log4zStream & operator <<(float t){return writeDouble(t, true);} 558 | 559 | inline Log4zStream & operator <<(double t){return writeDouble(t, false);} 560 | 561 | template //support std::string, std::wstring 562 | inline Log4zStream & operator <<(const std::basic_string<_Elem, _Traits, _Alloc> & t){ return writeString(t.c_str(), t.length()); } 563 | 564 | inline Log4zStream & operator << (const zsummer::log4z::Log4zBinary & binary) { return writeBinary(binary); } 565 | 566 | inline Log4zStream & operator << (const zsummer::log4z::Log4zString & str) { return writeString(str.buf, str.len); } 567 | 568 | template 569 | inline Log4zStream & operator <<(const std::pair<_Ty1, _Ty2> & t){ return *this << "pair(" << t.first << ":" << t.second << ")"; } 570 | 571 | template 572 | inline Log4zStream & operator <<(const std::vector<_Elem, _Alloc> & t) 573 | { 574 | *this << "vector(" << t.size() << ")["; 575 | int inputCount = 0; 576 | for (typename std::vector<_Elem, _Alloc>::const_iterator iter = t.begin(); iter != t.end(); iter++) 577 | { 578 | inputCount++; 579 | if (inputCount > LOG4Z_LOG_CONTAINER_DEPTH) 580 | { 581 | *this << "..., "; 582 | break; 583 | } 584 | *this << *iter << ", "; 585 | } 586 | if (!t.empty()) 587 | { 588 | _cur -= 2; 589 | } 590 | return *this << "]"; 591 | } 592 | template 593 | inline Log4zStream & operator <<(const std::list<_Elem, _Alloc> & t) 594 | { 595 | *this << "list(" << t.size() << ")["; 596 | int inputCount = 0; 597 | for (typename std::list<_Elem, _Alloc>::const_iterator iter = t.begin(); iter != t.end(); iter++) 598 | { 599 | inputCount++; 600 | if (inputCount > LOG4Z_LOG_CONTAINER_DEPTH) 601 | { 602 | *this << "..., "; 603 | break; 604 | } 605 | *this << *iter << ", "; 606 | } 607 | if (!t.empty()) 608 | { 609 | _cur -= 2; 610 | } 611 | return *this << "]"; 612 | } 613 | template 614 | inline Log4zStream & operator <<(const std::deque<_Elem, _Alloc> & t) 615 | { 616 | *this << "deque(" << t.size() << ")["; 617 | int inputCount = 0; 618 | for (typename std::deque<_Elem, _Alloc>::const_iterator iter = t.begin(); iter != t.end(); iter++) 619 | { 620 | inputCount++; 621 | if (inputCount > LOG4Z_LOG_CONTAINER_DEPTH) 622 | { 623 | *this << "..., "; 624 | break; 625 | } 626 | *this << *iter << ", "; 627 | } 628 | if (!t.empty()) 629 | { 630 | _cur -= 2; 631 | } 632 | return *this << "]"; 633 | } 634 | template 635 | inline Log4zStream & operator <<(const std::queue<_Elem, _Alloc> & t) 636 | { 637 | *this << "queue(" << t.size() << ")["; 638 | int inputCount = 0; 639 | for (typename std::queue<_Elem, _Alloc>::const_iterator iter = t.begin(); iter != t.end(); iter++) 640 | { 641 | inputCount++; 642 | if (inputCount > LOG4Z_LOG_CONTAINER_DEPTH) 643 | { 644 | *this << "..., "; 645 | break; 646 | } 647 | *this << *iter << ", "; 648 | } 649 | if (!t.empty()) 650 | { 651 | _cur -= 2; 652 | } 653 | return *this << "]"; 654 | } 655 | template 656 | inline Log4zStream & operator <<(const std::map<_K, _V, _Pr, _Alloc> & t) 657 | { 658 | *this << "map(" << t.size() << ")["; 659 | int inputCount = 0; 660 | for (typename std::map < _K, _V, _Pr, _Alloc>::const_iterator iter = t.begin(); iter != t.end(); iter++) 661 | { 662 | inputCount++; 663 | if (inputCount > LOG4Z_LOG_CONTAINER_DEPTH) 664 | { 665 | *this << "..., "; 666 | break; 667 | } 668 | *this << *iter << ", "; 669 | } 670 | if (!t.empty()) 671 | { 672 | _cur -= 2; 673 | } 674 | return *this << "]"; 675 | } 676 | 677 | private: 678 | Log4zStream(){} 679 | Log4zStream(Log4zStream &){} 680 | char * _begin; 681 | char * _end; 682 | char * _cur; 683 | }; 684 | 685 | inline Log4zStream::Log4zStream(char * buf, int len) 686 | { 687 | _begin = buf; 688 | _end = buf + len; 689 | _cur = _begin; 690 | } 691 | 692 | 693 | 694 | inline Log4zStream & Log4zStream::writeLongLong(long long t, int width, int dec) 695 | { 696 | if (t < 0 ) 697 | { 698 | t = -t; 699 | writeChar('-'); 700 | } 701 | writeULongLong((unsigned long long)t, width, dec); 702 | return *this; 703 | } 704 | 705 | inline Log4zStream & Log4zStream::writeULongLong(unsigned long long t, int width, int dec) 706 | { 707 | static const char * lut = 708 | "0123456789abcdef"; 709 | 710 | static const char *lutDec = 711 | "00010203040506070809" 712 | "10111213141516171819" 713 | "20212223242526272829" 714 | "30313233343536373839" 715 | "40414243444546474849" 716 | "50515253545556575859" 717 | "60616263646566676869" 718 | "70717273747576777879" 719 | "80818283848586878889" 720 | "90919293949596979899"; 721 | 722 | static const char *lutHex = 723 | "000102030405060708090A0B0C0D0E0F" 724 | "101112131415161718191A1B1C1D1E1F" 725 | "202122232425262728292A2B2C2D2E2F" 726 | "303132333435363738393A3B3C3D3E3F" 727 | "404142434445464748494A4B4C4D4E4F" 728 | "505152535455565758595A5B5C5D5E5F" 729 | "606162636465666768696A6B6C6D6E6F" 730 | "707172737475767778797A7B7C7D7E7F" 731 | "808182838485868788898A8B8C8D8E8F" 732 | "909192939495969798999A9B9C9D9E9F" 733 | "A0A1A2A3A4A5A6A7A8A9AAABACADAEAF" 734 | "B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF" 735 | "C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF" 736 | "D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF" 737 | "E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF" 738 | "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; 739 | 740 | const unsigned long long cacheSize = 64; 741 | 742 | if ((unsigned long long)(_end - _cur) > cacheSize) 743 | { 744 | char buf[cacheSize]; 745 | unsigned long long val = t; 746 | unsigned long long i = cacheSize; 747 | unsigned long long digit = 0; 748 | 749 | 750 | 751 | if (dec == 10) 752 | { 753 | do 754 | { 755 | const unsigned long long m2 = (unsigned long long)((val % 100) * 2); 756 | *(buf + i - 1) = lutDec[m2 + 1]; 757 | *(buf + i - 2) = lutDec[m2]; 758 | i -= 2; 759 | val /= 100; 760 | digit += 2; 761 | } while (val && i >= 2); 762 | if (digit >= 2 && buf[cacheSize - digit] == '0') 763 | { 764 | digit--; 765 | } 766 | } 767 | else if (dec == 16) 768 | { 769 | do 770 | { 771 | const unsigned long long m2 = (unsigned long long)((val % 256) * 2); 772 | *(buf + i - 1) = lutHex[m2 + 1]; 773 | *(buf + i - 2) = lutHex[m2]; 774 | i -= 2; 775 | val /= 256; 776 | digit += 2; 777 | } while (val && i >= 2); 778 | if (digit >= 2 && buf[cacheSize - digit] == '0') 779 | { 780 | digit--; 781 | } 782 | } 783 | else 784 | { 785 | do 786 | { 787 | buf[--i] = lut[val % dec]; 788 | val /= dec; 789 | digit++; 790 | } while (val && i > 0); 791 | } 792 | 793 | while (digit < (unsigned long long)width) 794 | { 795 | digit++; 796 | buf[cacheSize - digit] = '0'; 797 | } 798 | 799 | writeString(buf + (cacheSize - digit), (size_t)digit); 800 | } 801 | return *this; 802 | } 803 | inline Log4zStream & Log4zStream::writeDouble(double t, bool isSimple) 804 | { 805 | 806 | #if __cplusplus >= 201103L 807 | using std::isnan; 808 | using std::isinf; 809 | #endif 810 | if (isnan(t)) 811 | { 812 | writeString("nan", 3); 813 | return *this; 814 | } 815 | else if (isinf(t)) 816 | { 817 | writeString("inf", 3); 818 | return *this; 819 | } 820 | 821 | 822 | 823 | size_t count = _end - _cur; 824 | double fabst = fabs(t); 825 | if (count > 30) 826 | { 827 | if ( fabst < 0.0001 || (!isSimple && fabst > 4503599627370495ULL) || (isSimple && fabst > 8388607)) 828 | { 829 | gcvt(t, isSimple ? 7 : 16, _cur); 830 | size_t len = strlen(_cur); 831 | if (len > count) len = count; 832 | _cur += len; 833 | return *this; 834 | } 835 | else 836 | { 837 | if (t < 0.0) 838 | { 839 | writeChar('-'); 840 | } 841 | double intpart = 0; 842 | unsigned long long fractpart = (unsigned long long)(modf(fabst, &intpart) * 10000); 843 | writeULongLong((unsigned long long)intpart); 844 | if (fractpart > 0) 845 | { 846 | writeChar('.'); 847 | writeULongLong(fractpart, 4); 848 | } 849 | } 850 | } 851 | 852 | return *this; 853 | } 854 | 855 | inline Log4zStream & Log4zStream::writePointer(const void * t) 856 | { 857 | sizeof(t) == 8 ? writeULongLong((unsigned long long)t, 16, 16): writeULongLong((unsigned long long)t, 8, 16); 858 | return *this; 859 | } 860 | 861 | inline Log4zStream & Log4zStream::writeBinary(const Log4zBinary & t) 862 | { 863 | writeString("\r\n\t["); 864 | for (size_t i=0; i<(t.len / 32)+1; i++) 865 | { 866 | writeString("\r\n\t"); 867 | *this << (void*)(t.buf + i*32); 868 | writeString(": "); 869 | for (size_t j = i * 32; j < (i + 1) * 32 && j < t.len; j++) 870 | { 871 | if (isprint((unsigned char)t.buf[j])) 872 | { 873 | writeChar(' '); 874 | writeChar(t.buf[j]); 875 | writeChar(' '); 876 | } 877 | else 878 | { 879 | *this << " . "; 880 | } 881 | } 882 | writeString("\r\n\t"); 883 | *this << (void*)(t.buf + i * 32); 884 | writeString(": "); 885 | for (size_t j = i * 32; j < (i + 1) * 32 && j < t.len; j++) 886 | { 887 | writeULongLong((unsigned long long)(unsigned char)t.buf[j], 2, 16); 888 | writeChar(' '); 889 | } 890 | } 891 | 892 | writeString("\r\n\t]\r\n\t"); 893 | return *this; 894 | } 895 | inline Log4zStream & zsummer::log4z::Log4zStream::writeChar(char ch) 896 | { 897 | if (_end - _cur > 1) 898 | { 899 | _cur[0] = ch; 900 | _cur++; 901 | } 902 | return *this; 903 | } 904 | 905 | inline Log4zStream & zsummer::log4z::Log4zStream::writeString(const char * t, size_t len) 906 | { 907 | size_t count = _end - _cur; 908 | if (len > count) 909 | { 910 | len = count; 911 | } 912 | if (len > 0) 913 | { 914 | memcpy(_cur, t, len); 915 | _cur += len; 916 | } 917 | 918 | return *this; 919 | } 920 | 921 | 922 | 923 | 924 | #ifdef WIN32 925 | #pragma warning(pop) 926 | #endif 927 | 928 | _ZSUMMER_LOG4Z_END 929 | _ZSUMMER_END 930 | 931 | #endif 932 | -------------------------------------------------------------------------------- /PETOOLS/PETOOLS/PETOOLSDlg.cpp: -------------------------------------------------------------------------------- 1 | 2 | // PETOOLSDlg.cpp : 实现文件 3 | // 4 | 5 | #include "stdafx.h" 6 | #include "PETOOLS.h" 7 | #include "PETOOLSDlg.h" 8 | #include "afxdialogex.h" 9 | #include"DisaDialog.h" 10 | #include"ProBarThread.h" 11 | #include"AddSectionDlg.h" 12 | #include"AddPatch.h" 13 | #include 14 | #include 15 | #include"DataDirectoryDlg.h" 16 | #include"SectionsDlg.h" 17 | 18 | 19 | //#ifdef _DEBUG 20 | //#define new DEBUG_NEW 21 | //#endif 22 | 23 | 24 | // CPETOOLSDlg 对话框 25 | 26 | CPETOOLSDlg *MainDlg; 27 | 28 | CPETOOLSDlg::CPETOOLSDlg(CWnd* pParent /*=NULL*/) 29 | : CDialogEx(CPETOOLSDlg::IDD, pParent) 30 | { 31 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 32 | pPosCalcDlg = NULL; 33 | } 34 | CPETOOLSDlg::~CPETOOLSDlg() 35 | { 36 | if (pPosCalcDlg != NULL) 37 | { 38 | delete pPosCalcDlg; 39 | pPosCalcDlg = NULL; 40 | } 41 | } 42 | 43 | void CPETOOLSDlg::DoDataExchange(CDataExchange* pDX) 44 | { 45 | CDialogEx::DoDataExchange(pDX); 46 | DDX_Control(pDX, IDC_MFCBUTTON1, m_Button1); 47 | DDX_Control(pDX, IDC_MFCBUTTON2, m_Button2); 48 | DDX_Control(pDX, IDC_MFCBUTTON3, m_Button3); 49 | DDX_Control(pDX, IDC_MFCBUTTON4, m_Button4); 50 | DDX_Control(pDX, IDC_MFCBUTTON5, m_Button5); 51 | DDX_Control(pDX, IDC_MFCBUTTON6, m_Button6); 52 | DDX_Control(pDX, IDC_MFCBUTTON7, m_Button7); 53 | DDX_Control(pDX, IDC_STATIC1, m_Static1); 54 | DDX_Control(pDX, IDC_MFCEDITBROWSE1, m_Edit1); 55 | DDX_Control(pDX, IDC_STATIC2, m_Static2); 56 | DDX_Control(pDX, IDC_STATIC3, m_Static3); 57 | DDX_Control(pDX, IDC_MFCEDITBROWSE2, m_Edit2); 58 | DDX_Control(pDX, IDC_STATIC4, m_Static4); 59 | DDX_Control(pDX, IDC_STATIC5, m_Static5); 60 | DDX_Control(pDX, IDC_STATIC6, m_Static6); 61 | DDX_Control(pDX, IDC_STATIC9, m_Static9); 62 | DDX_Control(pDX, IDC_STATIC10, m_Static10); 63 | DDX_Control(pDX, IDC_STATIC11, m_Static11); 64 | DDX_Control(pDX, IDC_STATIC12, m_Static12); 65 | DDX_Control(pDX, IDC_STATIC13, m_Static13); 66 | DDX_Control(pDX, IDC_STATIC14, m_Static14); 67 | DDX_Control(pDX, IDC_STATIC15, m_Static15); 68 | DDX_Control(pDX, IDC_STATIC16, m_Static16); 69 | DDX_Control(pDX, IDC_STATIC17, m_Static17); 70 | DDX_Control(pDX, IDC_STATIC18, m_Static18); 71 | DDX_Control(pDX, IDC_STATIC19, m_Static19); 72 | DDX_Control(pDX, IDC_STATIC20, m_Static20); 73 | DDX_Control(pDX, IDC_STATIC21, m_Static21); 74 | DDX_Control(pDX, IDC_STATIC22, m_Static22); 75 | DDX_Control(pDX, IDC_STATIC23, m_Static23); 76 | DDX_Control(pDX, IDC_STATIC24, m_Static24); 77 | DDX_Control(pDX, IDC_STATIC25, m_Static25); 78 | DDX_Control(pDX, IDC_STATIC26, m_Static26); 79 | DDX_Control(pDX, IDC_STATIC27, m_Static27); 80 | DDX_Control(pDX, IDC_STATIC28, m_Static28); 81 | DDX_Control(pDX, IDC_STATIC29, m_Static29); 82 | DDX_Control(pDX, IDC_STATIC30, m_Static30); 83 | DDX_Control(pDX, IDC_STATIC31, m_Static31); 84 | DDX_Control(pDX, IDC_STATIC32, m_Static32); 85 | DDX_Control(pDX, IDC_STATIC33, m_Static33); 86 | DDX_Control(pDX, IDC_STATIC34, m_Static34); 87 | DDX_Control(pDX, IDC_STATIC35, m_Static35); 88 | DDX_Control(pDX, IDC_STATIC36, m_Static36); 89 | DDX_Control(pDX, IDC_STATIC37, m_Static37); 90 | DDX_Control(pDX, IDC_STATIC38, m_Static38); 91 | DDX_Control(pDX, IDC_STATIC39, m_Static39); 92 | DDX_Control(pDX, IDC_STATIC40, m_Static40); 93 | DDX_Control(pDX, IDC_STATIC41, m_Static41); 94 | DDX_Control(pDX, IDC_STATIC42, m_Static42); 95 | DDX_Control(pDX, IDC_STATIC43, m_Static43); 96 | DDX_Control(pDX, IDC_STATIC44, m_Static44); 97 | DDX_Control(pDX, IDC_STATIC45, m_Static45); 98 | DDX_Control(pDX, IDC_STATIC46, m_Static46); 99 | DDX_Control(pDX, IDC_MFCEDITBROWSE5, m_Edit5); 100 | DDX_Control(pDX, IDC_MFCEDITBROWSE6, m_Edit6); 101 | DDX_Control(pDX, IDC_MFCEDITBROWSE7, m_Edit7); 102 | DDX_Control(pDX, IDC_MFCEDITBROWSE8, m_Edit8); 103 | DDX_Control(pDX, IDC_MFCEDITBROWSE9, m_Edit9); 104 | DDX_Control(pDX, IDC_MFCEDITBROWSE10, m_Edit10); 105 | DDX_Control(pDX, IDC_MFCEDITBROWSE11, m_Edit11); 106 | DDX_Control(pDX, IDC_MFCEDITBROWSE12, m_Edit12); 107 | DDX_Control(pDX, IDC_MFCEDITBROWSE13, m_Edit13); 108 | DDX_Control(pDX, IDC_MFCEDITBROWSE14, m_Edit14); 109 | DDX_Control(pDX, IDC_MFCEDITBROWSE15, m_Edit15); 110 | DDX_Control(pDX, IDC_MFCEDITBROWSE16, m_Edit16); 111 | DDX_Control(pDX, IDC_MFCEDITBROWSE17, m_Edit17); 112 | DDX_Control(pDX, IDC_MFCEDITBROWSE18, m_Edit18); 113 | DDX_Control(pDX, IDC_MFCEDITBROWSE19, m_Edit19); 114 | DDX_Control(pDX, IDC_MFCEDITBROWSE20, m_Edit20); 115 | DDX_Control(pDX, IDC_MFCEDITBROWSE21, m_Edit21); 116 | DDX_Control(pDX, IDC_MFCEDITBROWSE22, m_Edit22); 117 | DDX_Control(pDX, IDC_MFCEDITBROWSE23, m_Edit23); 118 | DDX_Control(pDX, IDC_MFCEDITBROWSE24, m_Edit24); 119 | DDX_Control(pDX, IDC_MFCEDITBROWSE25, m_Edit25); 120 | DDX_Control(pDX, IDC_MFCEDITBROWSE26, m_Edit26); 121 | DDX_Control(pDX, IDC_MFCEDITBROWSE27, m_Edit27); 122 | DDX_Control(pDX, IDC_MFCEDITBROWSE28, m_Edit28); 123 | DDX_Control(pDX, IDC_MFCEDITBROWSE29, m_Edit29); 124 | DDX_Control(pDX, IDC_MFCEDITBROWSE30, m_Edit30); 125 | DDX_Control(pDX, IDC_MFCEDITBROWSE31, m_Edit31); 126 | DDX_Control(pDX, IDC_MFCEDITBROWSE32, m_Edit32); 127 | DDX_Control(pDX, IDC_MFCEDITBROWSE33, m_Edit33); 128 | DDX_Control(pDX, IDC_MFCEDITBROWSE34, m_Edit34); 129 | DDX_Control(pDX, IDC_MFCEDITBROWSE35, m_Edit35); 130 | DDX_Control(pDX, IDC_MFCEDITBROWSE36, m_Edit36); 131 | DDX_Control(pDX, IDC_MFCEDITBROWSE37, m_Edit37); 132 | DDX_Control(pDX, IDC_MFCEDITBROWSE38, m_Edit38); 133 | DDX_Control(pDX, IDC_MFCEDITBROWSE39, m_Edit39); 134 | DDX_Control(pDX, IDC_MFCEDITBROWSE40, m_Edit40); 135 | DDX_Control(pDX, IDC_MFCEDITBROWSE41, m_Edit41); 136 | DDX_Control(pDX, IDC_STATIC7, m_Static7); 137 | DDX_Control(pDX, IDC_MFCBUTTON8, m_Button8); 138 | DDX_Control(pDX, IDC_MFCBUTTON9, m_Button9); 139 | DDX_Control(pDX, IDC_MFCBUTTON10, m_Button10); 140 | DDX_Control(pDX, IDC_MFCBUTTON11, m_Button11); 141 | } 142 | 143 | BEGIN_MESSAGE_MAP(CPETOOLSDlg, CDialogEx) 144 | ON_WM_PAINT() 145 | ON_WM_QUERYDRAGICON() 146 | ON_BN_CLICKED(IDC_MFCBUTTON1, &CPETOOLSDlg::OnBnClickedMfcbutton1) 147 | ON_BN_CLICKED(IDC_MFCBUTTON2, &CPETOOLSDlg::OnBnClickedMfcbutton2) 148 | ON_BN_CLICKED(IDC_MFCBUTTON3, &CPETOOLSDlg::OnBnClickedMfcbutton3) 149 | ON_BN_CLICKED(IDC_MFCBUTTON4, &CPETOOLSDlg::OnBnClickedMfcbutton4) 150 | ON_BN_CLICKED(IDC_MFCBUTTON5, &CPETOOLSDlg::OnBnClickedMfcbutton5) 151 | ON_BN_CLICKED(IDC_MFCBUTTON6, &CPETOOLSDlg::OnBnClickedMfcbutton6) 152 | ON_BN_CLICKED(IDC_MFCBUTTON7, &CPETOOLSDlg::OnBnClickedMfcbutton7) 153 | ON_BN_CLICKED(IDC_MFCBUTTON8, &CPETOOLSDlg::OnBnClickedMfcbutton8) 154 | ON_WM_MOUSEMOVE() 155 | 156 | ON_COMMAND(ID_32771, &CPETOOLSDlg::OnOpen) 157 | ON_COMMAND(ID_Disa, &CPETOOLSDlg::OnDisa) 158 | ON_COMMAND(ID_RESET, &CPETOOLSDlg::OnReset) 159 | ON_COMMAND(ID_32780, &CPETOOLSDlg::OnTest) 160 | ON_MESSAGE(WM_UPDATEUI, &CPETOOLSDlg::OnUpdateUi) 161 | ON_COMMAND(ID_32781, &CPETOOLSDlg::OnSaveFile) 162 | ON_COMMAND(ID_32782, &CPETOOLSDlg::OnSaveAs) 163 | ON_COMMAND(ID_32787, &CPETOOLSDlg::OnHexEditView) 164 | 165 | ON_BN_CLICKED(IDC_MFCBUTTON9, &CPETOOLSDlg::OnBnClickedMfcbutton9) 166 | ON_BN_CLICKED(IDC_MFCBUTTON10, &CPETOOLSDlg::OnBnClickedMfcbutton10) 167 | ON_BN_CLICKED(IDC_MFCBUTTON11, &CPETOOLSDlg::OnBnClickedMfcbutton11) 168 | END_MESSAGE_MAP() 169 | 170 | 171 | // CPETOOLSDlg 消息处理程序 172 | 173 | BOOL CPETOOLSDlg::OnInitDialog() 174 | { 175 | CDialogEx::OnInitDialog(); 176 | 177 | // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 178 | // 执行此操作 179 | SetIcon(m_hIcon, TRUE); // 设置大图标 180 | SetIcon(m_hIcon, FALSE); // 设置小图标 181 | 182 | //设置本地中文字符集 183 | setlocale(LC_ALL,"chs"); 184 | //初始化全局变量 185 | ::MainDlg=this; 186 | //安装异常链 187 | if(!this->SetDumpFunc()) 188 | { 189 | //设置对话框日志 190 | DebugLog("Dump线程设置失败"); 191 | return FALSE; 192 | } 193 | 194 | DebugLog("Dump线程设置完毕"); 195 | 196 | if(!this->SetDlgUI()) 197 | { 198 | //设置对话框日志 199 | DebugLog("UI设置创建失败"); 200 | return FALSE; 201 | } 202 | DebugLog("主对话框UI设置完毕"); 203 | return TRUE; // 除非将焦点设置到控件,否则返回 TRUE 204 | } 205 | 206 | // 如果向对话框添加最小化按钮,则需要下面的代码 207 | // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, 208 | // 这将由框架自动完成。 209 | 210 | void CPETOOLSDlg::OnPaint() 211 | { 212 | if (IsIconic()) 213 | { 214 | CPaintDC dc(this); // 用于绘制的设备上下文 215 | 216 | SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); 217 | 218 | // 使图标在工作区矩形中居中 219 | int cxIcon = GetSystemMetrics(SM_CXICON); 220 | int cyIcon = GetSystemMetrics(SM_CYICON); 221 | CRect rect; 222 | GetClientRect(&rect); 223 | int x = (rect.Width() - cxIcon + 1) / 2; 224 | int y = (rect.Height() - cyIcon + 1) / 2; 225 | 226 | // 绘制图标 227 | dc.DrawIcon(x, y, m_hIcon); 228 | } 229 | else 230 | { 231 | CDialogEx::OnPaint(); 232 | } 233 | } 234 | 235 | //当用户拖动最小化窗口时系统调用此函数取得光标 236 | //显示。 237 | HCURSOR CPETOOLSDlg::OnQueryDragIcon() 238 | { 239 | return static_cast(m_hIcon); 240 | } 241 | 242 | //用于设置主对话框的UI 243 | BOOL CPETOOLSDlg::SetDlgUI(void) 244 | { 245 | //初始化MainFrame UI界面 246 | int x=0,y=0,height=0,width=0; 247 | TCHAR TextDisplay[MAX_PATH]={0}; 248 | height=mIni.GetIntKey("configure.ini","MainFrame","height"); 249 | width=mIni.GetIntKey("configure.ini","MainFrame","width"); 250 | RECT rect={0}; 251 | this->GetWindowRect(&rect); 252 | this->MoveWindow(rect.left,rect.top,width,height,TRUE); 253 | 254 | //初始化界面控件UI 255 | this->SetControlUI("configure.ini",&this->m_Static1,"Static1"); 256 | this->SetControlUI("configure.ini",&this->m_Static2,"Static2"); 257 | this->SetControlUI("configure.ini",&this->m_Static3,"Static3"); 258 | this->SetControlUI("configure.ini",&this->m_Static4,"Static4"); 259 | this->SetControlUI("configure.ini",&this->m_Static5,"Static5"); 260 | this->SetControlUI("configure.ini",&this->m_Static6,"Static6"); 261 | this->SetControlUI("configure.ini",&this->m_Static7, "Static7"); 262 | this->SetControlUI("configure.ini",&this->m_Static9,"Static9"); 263 | this->SetControlUI("configure.ini",&this->m_Static10,"Static10"); 264 | this->SetControlUI("configure.ini",&this->m_Static11,"Static11"); 265 | this->SetControlUI("configure.ini",&this->m_Static12,"Static12"); 266 | this->SetControlUI("configure.ini",&this->m_Static13,"Static13"); 267 | this->SetControlUI("configure.ini",&this->m_Static14,"Static14"); 268 | this->SetControlUI("configure.ini",&this->m_Static15,"Static15"); 269 | this->SetControlUI("configure.ini",&this->m_Static16,"Static16"); 270 | this->SetControlUI("configure.ini",&this->m_Static17,"Static17"); 271 | this->SetControlUI("configure.ini",&this->m_Static18,"Static18"); 272 | this->SetControlUI("configure.ini",&this->m_Static19,"Static19"); 273 | this->SetControlUI("configure.ini",&this->m_Static20,"Static20"); 274 | this->SetControlUI("configure.ini",&this->m_Static21,"Static21"); 275 | this->SetControlUI("configure.ini",&this->m_Static22,"Static22"); 276 | this->SetControlUI("configure.ini",&this->m_Static23,"Static23"); 277 | this->SetControlUI("configure.ini",&this->m_Static24,"Static24"); 278 | this->SetControlUI("configure.ini",&this->m_Static25,"Static25"); 279 | this->SetControlUI("configure.ini",&this->m_Static26,"Static26"); 280 | this->SetControlUI("configure.ini",&this->m_Static27,"Static27"); 281 | this->SetControlUI("configure.ini",&this->m_Static28,"Static28"); 282 | this->SetControlUI("configure.ini",&this->m_Static29,"Static29"); 283 | this->SetControlUI("configure.ini",&this->m_Static30,"Static30"); 284 | this->SetControlUI("configure.ini",&this->m_Static31,"Static31"); 285 | this->SetControlUI("configure.ini",&this->m_Static32,"Static32"); 286 | this->SetControlUI("configure.ini",&this->m_Static33,"Static33"); 287 | this->SetControlUI("configure.ini",&this->m_Static34,"Static34"); 288 | this->SetControlUI("configure.ini",&this->m_Static35,"Static35"); 289 | this->SetControlUI("configure.ini",&this->m_Static36,"Static36"); 290 | this->SetControlUI("configure.ini",&this->m_Static37,"Static37",FALSE); 291 | this->SetControlUI("configure.ini",&this->m_Static38,"Static38",FALSE); 292 | this->SetControlUI("configure.ini",&this->m_Static39,"Static39",FALSE); 293 | this->SetControlUI("configure.ini",&this->m_Static40,"Static40",FALSE); 294 | this->SetControlUI("configure.ini",&this->m_Static41,"Static41",FALSE); 295 | this->SetControlUI("configure.ini",&this->m_Static42,"Static42",FALSE); 296 | this->SetControlUI("configure.ini",&this->m_Static43,"Static43",FALSE); 297 | this->SetControlUI("configure.ini",&this->m_Static44,"Static44",FALSE); 298 | this->SetControlUI("configure.ini",&this->m_Static45,"Static45",FALSE); 299 | this->SetControlUI("configure.ini",&this->m_Static46,"Static46",FALSE); 300 | 301 | this->SetControlUI("configure.ini",&this->m_Edit1,"Edit1",TRUE); 302 | this->m_Edit1.SetWindowText("D:\\calc.exe"); 303 | 304 | this->SetControlUI("configure.ini",&this->m_Edit2,"Edit2",FALSE); 305 | //this->SetControlUI("configure.ini",&this->m_Edit3,"Edit3",TRUE); 306 | //this->SetControlUI("configure.ini",&this->m_Edit4,"Edit4",TRUE); 307 | this->SetControlUI("configure.ini",&this->m_Edit5,"Edit5",TRUE); 308 | this->SetControlUI("configure.ini",&this->m_Edit6,"Edit6",TRUE); 309 | this->SetControlUI("configure.ini",&this->m_Edit7,"Edit7",TRUE); 310 | this->SetControlUI("configure.ini",&this->m_Edit8,"Edit8",TRUE); 311 | this->SetControlUI("configure.ini",&this->m_Edit9,"Edit9",TRUE); 312 | this->SetControlUI("configure.ini",&this->m_Edit10,"Edit10",TRUE); 313 | this->SetControlUI("configure.ini",&this->m_Edit11,"Edit11",TRUE); 314 | this->SetControlUI("configure.ini",&this->m_Edit12,"Edit12",TRUE); 315 | this->SetControlUI("configure.ini",&this->m_Edit13,"Edit13",TRUE); 316 | this->SetControlUI("configure.ini",&this->m_Edit14,"Edit14",TRUE); 317 | this->SetControlUI("configure.ini",&this->m_Edit15,"Edit15",TRUE); 318 | this->SetControlUI("configure.ini",&this->m_Edit16,"Edit16",TRUE); 319 | this->SetControlUI("configure.ini",&this->m_Edit17,"Edit17",TRUE); 320 | this->SetControlUI("configure.ini",&this->m_Edit18,"Edit18",TRUE); 321 | this->SetControlUI("configure.ini",&this->m_Edit19,"Edit19",TRUE); 322 | this->SetControlUI("configure.ini",&this->m_Edit20,"Edit20",TRUE); 323 | this->SetControlUI("configure.ini",&this->m_Edit21,"Edit21",TRUE); 324 | this->SetControlUI("configure.ini",&this->m_Edit22,"Edit22",TRUE); 325 | this->SetControlUI("configure.ini",&this->m_Edit23,"Edit23",TRUE); 326 | this->SetControlUI("configure.ini",&this->m_Edit24,"Edit24",TRUE); 327 | this->SetControlUI("configure.ini",&this->m_Edit25,"Edit25",TRUE); 328 | this->SetControlUI("configure.ini",&this->m_Edit26,"Edit26",TRUE); 329 | this->SetControlUI("configure.ini",&this->m_Edit27,"Edit27",TRUE); 330 | this->SetControlUI("configure.ini",&this->m_Edit28,"Edit28",TRUE); 331 | this->SetControlUI("configure.ini",&this->m_Edit29,"Edit29",TRUE); 332 | this->SetControlUI("configure.ini",&this->m_Edit30,"Edit30",TRUE); 333 | this->SetControlUI("configure.ini",&this->m_Edit31,"Edit31",TRUE); 334 | this->SetControlUI("configure.ini",&this->m_Edit32,"Edit32",TRUE,FALSE); 335 | this->SetControlUI("configure.ini",&this->m_Edit33,"Edit33",TRUE,FALSE); 336 | this->SetControlUI("configure.ini",&this->m_Edit34,"Edit34",TRUE,FALSE); 337 | this->SetControlUI("configure.ini",&this->m_Edit35,"Edit35",TRUE,FALSE); 338 | this->SetControlUI("configure.ini",&this->m_Edit36,"Edit36",TRUE,FALSE); 339 | this->SetControlUI("configure.ini",&this->m_Edit37,"Edit37",TRUE,FALSE); 340 | this->SetControlUI("configure.ini",&this->m_Edit38,"Edit38",TRUE,FALSE); 341 | this->SetControlUI("configure.ini",&this->m_Edit39,"Edit39",TRUE,FALSE); 342 | this->SetControlUI("configure.ini",&this->m_Edit40,"Edit40",TRUE,FALSE); 343 | this->SetControlUI("configure.ini",&this->m_Edit41,"Edit41",TRUE,FALSE); 344 | 345 | this->SetControlUI("configure.ini",&this->m_Button1,"Button1"); 346 | this->SetControlUI("configure.ini",&this->m_Button2,"Button2"); 347 | this->SetControlUI("configure.ini",&this->m_Button3,"Button3"); 348 | this->SetControlUI("configure.ini", &this->m_Button4, "Button4"); 349 | this->SetControlUI("configure.ini", &this->m_Button5, "Button5"); 350 | this->SetControlUI("configure.ini", &this->m_Button6, "Button6"); 351 | this->SetControlUI("configure.ini", &this->m_Button7, "Button7"); 352 | this->SetControlUI("configure.ini", &this->m_Button8, "Button8"); 353 | this->SetControlUI("configure.ini", &this->m_Button9, "Button9"); 354 | this->SetControlUI("configure.ini", &this->m_Button10, "Button10"); 355 | this->SetControlUI("configure.ini", &this->m_Button11, "Button11"); 356 | 357 | //创建状态栏 358 | this->m_Status.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM,CRect(0,0,0,0), this, IDC_STATUSBARCTRL); 359 | this->m_Status.SetUI(); 360 | 361 | return TRUE; 362 | } 363 | 364 | //用于设置Dump线程 365 | BOOL CPETOOLSDlg::SetDumpFunc(void) 366 | { 367 | CMiniDump::EnableAutoDump(true); 368 | return TRUE; 369 | } 370 | 371 | //分析按钮事件处理代码 372 | void CPETOOLSDlg::OnBnClickedMfcbutton1() 373 | { 374 | //清空界面 375 | this->Reset(); 376 | 377 | //开启进度条 378 | //CProBarThread pProBarThread; 379 | //pProBarThread.Create(); 380 | 381 | //pProBarThread.SetProValue(0); 382 | 383 | //需要等待线程等待完成 384 | if(mPEMake.isAnalysised()) 385 | { 386 | mPEMake.PEUnload(); 387 | } 388 | 389 | CString m_Path; 390 | this->m_Edit1.GetWindowText(m_Path); 391 | if(m_Path.GetLength()==0) 392 | { 393 | ::MessageBox(this->m_hWnd,"请选择要分析的文件","警告",MB_OK); 394 | return; 395 | } 396 | //pProBarThread.SetProValue(20); 397 | 398 | //加载文件 399 | if(!mPEMake.PELoadFile(m_Path.GetBuffer(0),"r")) //只读方式打开文件 400 | { 401 | DebugLog("PeStruct初始化失败!"); 402 | return; 403 | } 404 | 405 | //开始分析 406 | DebugLog("开始分析PE文件"); 407 | 408 | if(!mPEMake.CheckPESig()) 409 | { 410 | DebugLog("PE文件错误"); 411 | return; 412 | } 413 | 414 | if(mPEMake.Analysis()) 415 | { 416 | DebugLog("PE文件分析完毕"); 417 | mPEMake.SetAnalysised(true); 418 | }else 419 | { 420 | DebugLog("PE分析失败"); 421 | return; 422 | } 423 | 424 | //pProBarThread.SetProValue(50); 425 | DebugLog("开始设置对话框控件的值"); 426 | 427 | if(this->SetCtrlContent()) 428 | { 429 | DebugLog("对话框值设置完毕"); 430 | }else 431 | { 432 | DebugLog("对话框值设置失败"); 433 | return; 434 | } 435 | //pProBarThread.SetProValue(100); 436 | 437 | } 438 | 439 | void CPETOOLSDlg::SetControlUI(TCHAR pFile[],MFCStatic *m_Static,TCHAR *m_tag,BOOL isVisible) 440 | { 441 | int x=0,y=0,height=0,width=0; 442 | TCHAR TextDisplay[MAX_PATH]={0}; 443 | x=mIni.GetIntKey(pFile,m_tag,"x"); 444 | y=mIni.GetIntKey(pFile,m_tag,"y"); 445 | height=mIni.GetIntKey(pFile,m_tag,"height"); 446 | width=mIni.GetIntKey(pFile,m_tag,"width"); 447 | m_Static->MoveWindow(x,y,width,height,TRUE); 448 | ZeroMemory(TextDisplay,sizeof(TextDisplay)); 449 | mIni.GetStrKey(pFile,m_tag,"text",TextDisplay); 450 | m_Static->SetWindowText(TextDisplay); 451 | ZeroMemory(TextDisplay,sizeof(TextDisplay)); 452 | mIni.GetStrKey(pFile,m_tag,"title",TextDisplay); 453 | memcpy_s(m_Static->Title,sizeof(m_Static->Title),TextDisplay,sizeof(TextDisplay)); 454 | isVisible?m_Static->ShowWindow(SW_SHOW):m_Static->ShowWindow(SW_HIDE); 455 | } 456 | 457 | void CPETOOLSDlg::SetControlUI(TCHAR pFile[],MFCEdit *m_Edit,TCHAR *m_tag,BOOL isEnable,BOOL isVisible) 458 | { 459 | int x=0,y=0,height=0,width=0; 460 | x=mIni.GetIntKey(pFile,m_tag,"x"); 461 | y=mIni.GetIntKey(pFile,m_tag,"y"); 462 | height=mIni.GetIntKey(pFile,m_tag,"height"); 463 | width=mIni.GetIntKey(pFile,m_tag,"width"); 464 | m_Edit->MoveWindow(x,y,width,height,TRUE); 465 | isEnable?m_Edit->EnableWindow(TRUE):m_Edit->EnableWindow(FALSE); 466 | isVisible?m_Edit->ShowWindow(SW_SHOW):m_Edit->ShowWindow(SW_HIDE); 467 | } 468 | 469 | void CPETOOLSDlg::SetControlUI(TCHAR pFile[],CMFCButton *m_Button,TCHAR *m_tag) 470 | { 471 | int x=0,y=0,height=0,width=0; 472 | TCHAR TextDisplay[MAX_PATH]={0}; 473 | x=mIni.GetIntKey(pFile,m_tag,"x"); 474 | y=mIni.GetIntKey(pFile,m_tag,"y"); 475 | height=mIni.GetIntKey(pFile,m_tag,"height"); 476 | width=mIni.GetIntKey(pFile,m_tag,"width"); 477 | m_Button->MoveWindow(x,y,width,height,TRUE); 478 | ZeroMemory(TextDisplay,sizeof(TextDisplay)); 479 | mIni.GetStrKey(pFile,m_tag,"text",TextDisplay); 480 | m_Button->SetWindowText(TextDisplay); 481 | } 482 | 483 | void CPETOOLSDlg::SetControlUI(TCHAR pFile[],CWnd *m_Ctrl,TCHAR *m_tag,BOOL isVisible) 484 | { 485 | int x=0,y=0,height=0,width=0; 486 | x=mIni.GetIntKey(pFile,m_tag,"x"); 487 | y=mIni.GetIntKey(pFile,m_tag,"y"); 488 | height=mIni.GetIntKey(pFile,m_tag,"height"); 489 | width=mIni.GetIntKey(pFile,m_tag,"width"); 490 | m_Ctrl->MoveWindow(x,y,width,height,TRUE); 491 | isVisible?m_Ctrl->ShowWindow(SW_SHOW):m_Ctrl->ShowWindow(SW_HIDE); 492 | } 493 | 494 | BOOL CPETOOLSDlg::SetCtrlContent() 495 | { 496 | 497 | CString strFormat; 498 | strFormat.Format("0X%X",mPEMake.mPeCtx.pe.mDosHeader.e_lfanew); 499 | m_Edit2.SetWindowText(strFormat); 500 | 501 | strFormat.Format("0X%04X", mPEMake.mPeCtx.pe.mNtHeader.FileHeader.Machine); 502 | m_Edit5.SetWindowText(strFormat); 503 | 504 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.FileHeader.NumberOfSections); 505 | m_Edit6.SetWindowText(strFormat); 506 | 507 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.FileHeader.TimeDateStamp); 508 | m_Edit7.SetWindowText(strFormat); 509 | 510 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.FileHeader.PointerToSymbolTable); 511 | m_Edit8.SetWindowText(strFormat); 512 | 513 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.FileHeader.NumberOfSymbols); 514 | m_Edit9.SetWindowText(strFormat); 515 | 516 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.FileHeader.SizeOfOptionalHeader); 517 | m_Edit10.SetWindowText(strFormat); 518 | 519 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.FileHeader.Characteristics); 520 | m_Edit11.SetWindowText(strFormat); 521 | 522 | strFormat.Format("0X%04X", mPEMake.mPeCtx.pe.wMagic); 523 | m_Edit12.SetWindowText(strFormat); 524 | 525 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MajorLinkerVersion); 526 | m_Edit13.SetWindowText(strFormat); 527 | 528 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MinorLinkerVersion); 529 | m_Edit14.SetWindowText(strFormat); 530 | 531 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfCode); 532 | m_Edit15.SetWindowText(strFormat); 533 | 534 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfInitializedData); 535 | m_Edit16.SetWindowText(strFormat); 536 | 537 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfUninitializedData); 538 | m_Edit17.SetWindowText(strFormat); 539 | 540 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.AddressOfEntryPoint); 541 | m_Edit18.SetWindowText(strFormat); 542 | 543 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.BaseOfCode); 544 | m_Edit19.SetWindowText(strFormat); 545 | 546 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.BaseOfData); 547 | m_Edit20.SetWindowText(strFormat); 548 | 549 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.ImageBase); 550 | m_Edit21.SetWindowText(strFormat); 551 | 552 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SectionAlignment); 553 | m_Edit22.SetWindowText(strFormat); 554 | 555 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.FileAlignment); 556 | m_Edit23.SetWindowText(strFormat); 557 | 558 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MajorOperatingSystemVersion); 559 | m_Edit24.SetWindowText(strFormat); 560 | 561 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MinorOperatingSystemVersion); 562 | m_Edit25.SetWindowText(strFormat); 563 | 564 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MajorImageVersion); 565 | m_Edit26.SetWindowText(strFormat); 566 | 567 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MinorImageVersion); 568 | m_Edit27.SetWindowText(strFormat); 569 | 570 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MajorSubsystemVersion); 571 | m_Edit28.SetWindowText(strFormat); 572 | 573 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.MinorSubsystemVersion); 574 | m_Edit29.SetWindowText(strFormat); 575 | 576 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.Win32VersionValue); 577 | m_Edit30.SetWindowText(strFormat); 578 | 579 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfImage); 580 | m_Edit31.SetWindowText(strFormat); 581 | 582 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfHeaders); 583 | m_Edit32.SetWindowText(strFormat); 584 | 585 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.CheckSum); 586 | m_Edit33.SetWindowText(strFormat); 587 | 588 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.Subsystem); 589 | m_Edit34.SetWindowText(strFormat); 590 | 591 | strFormat.Format("0X%04X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.DllCharacteristics); 592 | m_Edit35.SetWindowText(strFormat); 593 | 594 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfStackReserve); 595 | m_Edit36.SetWindowText(strFormat); 596 | 597 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfStackCommit); 598 | m_Edit37.SetWindowText(strFormat); 599 | 600 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfHeapReserve); 601 | m_Edit38.SetWindowText(strFormat); 602 | 603 | strFormat.Format("0X%X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.SizeOfStackCommit); 604 | m_Edit39.SetWindowText(strFormat); 605 | 606 | strFormat.Format("0X%08X", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.LoaderFlags); 607 | m_Edit40.SetWindowText(strFormat); 608 | 609 | strFormat.Format("%d", mPEMake.mPeCtx.pe.mNtHeader.OptionalHeader.NumberOfRvaAndSizes); 610 | m_Edit41.SetWindowText(strFormat); 611 | 612 | return TRUE; 613 | } 614 | 615 | void CPETOOLSDlg::Reset() 616 | { 617 | //将所有的控件内容和状态还原 618 | EnumChildWindows(this->m_hWnd,CPETOOLSDlg::EnumChildProc,(LPARAM)this); 619 | //mPEMake卸载 620 | mPEMake.PEUnload(); 621 | } 622 | 623 | //按钮-切换 624 | void CPETOOLSDlg::OnBnClickedMfcbutton2() 625 | { 626 | TCHAR Buffer[20] = { 0 }; 627 | this->m_Button2.GetWindowText(Buffer, sizeof(Buffer)); 628 | if (_tcscmp(Buffer, "切换>>") == 0) 629 | { 630 | this->m_Button2.SetWindowText("切换<<"); 631 | for (int i = this->m_Static17.GetDlgCtrlID(), j = this->m_Edit12.GetDlgCtrlID(); i <= this->m_Static36.GetDlgCtrlID(); i++, j++) 632 | { 633 | MFCStatic *m_Static = static_cast(this->GetDlgItem(i)); 634 | m_Static->ShowWindow(SW_HIDE); 635 | MFCEdit *m_Edit = static_cast(this->GetDlgItem(j)); 636 | m_Edit->ShowWindow(SW_HIDE); 637 | } 638 | for (int i = this->m_Static37.GetDlgCtrlID(), j = this->m_Edit32.GetDlgCtrlID(); i <= this->m_Static46.GetDlgCtrlID(); i++, j++) 639 | { 640 | MFCStatic *m_Static = static_cast(this->GetDlgItem(i)); 641 | m_Static->ShowWindow(SW_SHOW); 642 | MFCEdit *m_Edit = static_cast(this->GetDlgItem(j)); 643 | m_Edit->ShowWindow(SW_SHOW); 644 | } 645 | } 646 | else 647 | { 648 | this->m_Button2.SetWindowText("切换>>"); 649 | 650 | for (int i = this->m_Static17.GetDlgCtrlID(), j = this->m_Edit12.GetDlgCtrlID(); i <= this->m_Static36.GetDlgCtrlID(); i++, j++) 651 | { 652 | MFCStatic *m_Static = static_cast(this->GetDlgItem(i)); 653 | m_Static->ShowWindow(SW_SHOW); 654 | MFCEdit *m_Edit = static_cast(this->GetDlgItem(j)); 655 | m_Edit->ShowWindow(SW_SHOW); 656 | } 657 | for (int i = this->m_Static37.GetDlgCtrlID(), j = this->m_Edit32.GetDlgCtrlID(); i <= this->m_Static46.GetDlgCtrlID(); i++, j++) 658 | { 659 | MFCStatic *m_Static = static_cast(this->GetDlgItem(i)); 660 | m_Static->ShowWindow(SW_HIDE); 661 | MFCEdit *m_Edit = static_cast(this->GetDlgItem(j)); 662 | m_Edit->ShowWindow(SW_HIDE); 663 | } 664 | } 665 | } 666 | 667 | //按钮-目录 668 | void CPETOOLSDlg::OnBnClickedMfcbutton3() 669 | { 670 | if(!mPEMake.isAnalysised()) 671 | { 672 | AfxMessageBox("请先分析PE文件"); 673 | return; 674 | } 675 | DataDirectoryDlg dlg(this); 676 | dlg.DoModal(); 677 | } 678 | 679 | //按钮-区段 680 | void CPETOOLSDlg::OnBnClickedMfcbutton4() 681 | { 682 | // TODO: 在此添加控件通知处理程序代码 683 | if (!mPEMake.isAnalysised()) 684 | { 685 | AfxMessageBox("请先分析PE文件"); 686 | return; 687 | } 688 | SectionsDlg dlg(this); 689 | dlg.DoModal(); 690 | } 691 | 692 | //按钮-位置计算器 693 | void CPETOOLSDlg::OnBnClickedMfcbutton5() 694 | { 695 | // TODO: 在此添加命令处理程序代码 696 | if (!mPEMake.isAnalysised()) 697 | { 698 | AfxMessageBox("请先分析PE文件"); 699 | return; 700 | } 701 | if (pPosCalcDlg == NULL) 702 | { 703 | pPosCalcDlg = new CPosCalcDlg(this); 704 | pPosCalcDlg->Create(IDD_DIALOG8, this); 705 | } 706 | pPosCalcDlg->ShowWindow(SW_SHOW); 707 | } 708 | 709 | //按钮-十六进制 710 | void CPETOOLSDlg::OnBnClickedMfcbutton6() 711 | { 712 | // TODO: 在此添加控件通知处理程序代码 713 | if (!mPEMake.isAnalysised()) 714 | { 715 | AfxMessageBox("请先分析PE文件"); 716 | return; 717 | } 718 | Create16EditWindow((unsigned char *)(mPEMake.mPeCtx.pVirMem), mPEMake.mPeCtx.size, 0, 0); 719 | } 720 | 721 | //按钮-dump 722 | void CPETOOLSDlg::OnBnClickedMfcbutton7() 723 | { 724 | // TODO: 在此添加控件通知处理程序代码 725 | if (!mPEMake.isAnalysised()) 726 | { 727 | AfxMessageBox("请先分析PE文件"); 728 | return; 729 | } 730 | } 731 | 732 | //按钮-去重定位表 733 | void CPETOOLSDlg::OnBnClickedMfcbutton8() 734 | { 735 | // TODO: 在此添加控件通知处理程序代码 736 | //TODO: 在此添加命令处理程序代码 737 | if (!mPEMake.isAnalysised()) 738 | { 739 | AfxMessageBox("请先分析PE文件"); 740 | return; 741 | } 742 | if (mPEMake.mPeCtx.pe.mRelocsVector.size() == 0) 743 | { 744 | AfxMessageBox("无重定位表"); 745 | return; 746 | } 747 | 748 | if (mPEMake.ClsRelocDataDirectory()) 749 | { 750 | OnSaveAs(); 751 | } 752 | 753 | DebugLog("菜单-功能-去重定位表:去除成功!"); 754 | //更新界面 755 | this->SendMessage(WM_UPDATEUI, NULL, NULL); 756 | MessageBox("重定位表去除成功!"); 757 | 758 | //此种方法弊端,如果为DLL,则当无法加载到缺省基址,则代码无法进行重定位出错 759 | //更好的方法是对代码中重定位项进行重新编码计算,参考《Windows PE》P182。 760 | } 761 | 762 | //按钮-添加区段 763 | void CPETOOLSDlg::OnBnClickedMfcbutton9() 764 | { 765 | if (!mPEMake.isAnalysised()) 766 | { 767 | AfxMessageBox("请先分析PE文件"); 768 | return; 769 | } 770 | CAddSectionDlg mDlg(this); 771 | if (mDlg.DoModal() == IDOK) 772 | { 773 | OnSaveAs(); 774 | } 775 | /*else 776 | AfxMessageBox("添加失败!");*/ 777 | } 778 | 779 | //按钮-添加补丁 780 | void CPETOOLSDlg::OnBnClickedMfcbutton10() 781 | { 782 | // TODO: 在此添加控件通知处理程序代码 783 | if (!mPEMake.isAnalysised()) 784 | { 785 | AfxMessageBox("请先分析PE文件"); 786 | return; 787 | } 788 | CAddPatch mDlg(this); 789 | if (mDlg.DoModal() == IDOK) 790 | { 791 | OnSaveAs(); 792 | } 793 | } 794 | 795 | //按钮-导入表加密 796 | void CPETOOLSDlg::OnBnClickedMfcbutton11() 797 | { 798 | // TODO: 在此添加控件通知处理程序代码 799 | if (!mPEMake.isAnalysised()) 800 | { 801 | AfxMessageBox("请先分析PE文件"); 802 | return; 803 | } 804 | if (mPEMake.mPeCtx.pe.mImportsVector.size() == 0) 805 | { 806 | AfxMessageBox("无导入表"); 807 | return; 808 | } 809 | 810 | if (mPEMake.EncryptImportTable()) 811 | { 812 | OnSaveAs(); 813 | } 814 | //更新界面 815 | SendMessage(WM_UPDATEUI, NULL, NULL); 816 | } 817 | 818 | BOOL CALLBACK CPETOOLSDlg::EnumChildProc(HWND hwnd,LPARAM lParam) 819 | { 820 | CPETOOLSDlg *MainDlg=static_cast((PVOID)lParam); 821 | CWnd *Wnd=MainDlg->GetDlgItem(::GetDlgCtrlID(hwnd)); 822 | if(Wnd==NULL) return TRUE; 823 | if(Wnd->GetRuntimeClass()==RUNTIME_CLASS(MFCEdit)) 824 | { 825 | if(::GetDlgCtrlID(hwnd)!=MainDlg->m_Edit1.GetDlgCtrlID()) 826 | { 827 | Wnd->SetWindowText(""); 828 | } 829 | }else if(Wnd->GetRuntimeClass()==RUNTIME_CLASS(CComboBoxEx)) 830 | { 831 | CComboBoxEx *cbo=static_cast(Wnd); 832 | cbo->ResetContent(); 833 | } 834 | return TRUE; 835 | } 836 | 837 | //文件-打开 838 | void CPETOOLSDlg::OnOpen() 839 | { 840 | // TODO: 在此添加命令处理程序代码 841 | CFileDialog dlg(TRUE);///TRUE为OPEN对话框,FALSE为SAVE AS对话框 842 | if(dlg.DoModal()==IDOK) 843 | this->m_Edit1.SetWindowText(dlg.GetPathName()); 844 | } 845 | 846 | //文件-保存 847 | void CPETOOLSDlg::OnSaveFile() 848 | { 849 | if (!mPEMake.isAnalysised()) 850 | { 851 | AfxMessageBox("请先分析PE文件"); 852 | return; 853 | } 854 | // TODO: 在此添加命令处理程序代码 855 | if (IDYES == MessageBox("是否保存文件", "保存", MB_YESNO | MB_ICONQUESTION)) 856 | { 857 | CFile mFile(mPEMake.mPeCtx.path.c_str(), CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite); 858 | mFile.SetLength(0); 859 | mFile.Write(mPEMake.mPeCtx.pVirMem, mPEMake.mPeCtx.size); 860 | mFile.Close(); 861 | } 862 | } 863 | 864 | //文件-另存为 865 | void CPETOOLSDlg::OnSaveAs() 866 | { 867 | if (!mPEMake.isAnalysised()) 868 | { 869 | AfxMessageBox("请先分析PE文件"); 870 | return; 871 | } 872 | CFileDialog dlg(FALSE, "exe", mPEMake.mPeCtx.path.c_str(), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "TXT Files(*.exe)|*.exe|All Files(*.*)|*.*"); 873 | ///TRUE为OPEN对话框,FALSE为SAVE AS对话框 874 | if (dlg.DoModal() == IDOK) 875 | { 876 | CFile mFile(dlg.GetPathName(), CFile::modeCreate | CFile::modeReadWrite); 877 | mFile.Write(mPEMake.mPeCtx.pVirMem, mPEMake.mPeCtx.size); 878 | mFile.Close(); 879 | AfxMessageBox("另存成功"); 880 | } 881 | 882 | } 883 | 884 | //编辑-重置 885 | void CPETOOLSDlg::OnReset() 886 | { 887 | mPEMake.PEUnload(); 888 | //将所有的控件内容和状态还原 889 | EnumChildWindows(this->m_hWnd, CPETOOLSDlg::EnumChildProc, (LPARAM)this); 890 | 891 | } 892 | 893 | //编辑-十六进制浏览 894 | void CPETOOLSDlg::OnHexEditView() 895 | { 896 | Create16EditWindow((unsigned char *)(mPEMake.mPeCtx.pVirMem), mPEMake.mPeCtx.size, 0, 0); 897 | } 898 | 899 | //功能-反汇编 900 | void CPETOOLSDlg::OnDisa() 901 | { 902 | 903 | if(!this->mPEMake.isAnalysised()) 904 | { 905 | AfxMessageBox("请先分析PE文件"); 906 | return; 907 | } 908 | CDisaDialog DDia(this); 909 | DDia.DoModal(); 910 | 911 | } 912 | 913 | 914 | //功能-测试功能项 915 | void CPETOOLSDlg::OnTest() 916 | { 917 | //TODO: 在此添加命令处理程序代码 918 | if(!mPEMake.isAnalysised()) 919 | { 920 | AfxMessageBox("请先分析PE文件"); 921 | return; 922 | } 923 | } 924 | 925 | 926 | afx_msg LRESULT CPETOOLSDlg::OnUpdateUi(WPARAM wParam, LPARAM lParam) 927 | { 928 | //清空控件内容 929 | EnumChildWindows(this->m_hWnd,CPETOOLSDlg::EnumChildProc,(LPARAM)this); 930 | //重置内容 931 | if(this->SetCtrlContent()) 932 | { 933 | DebugLog("对话框值设置完毕"); 934 | }else 935 | { 936 | DebugLog("对话框值设置失败"); 937 | } 938 | return 0; 939 | } 940 | --------------------------------------------------------------------------------