Explorar o código

格式化代码。

Wang Jeff %!s(int64=3) %!d(string=hai) anos
pai
achega
70527eaf7f
Modificáronse 31 ficheiros con 8934 adicións e 8934 borrados
  1. 1216 1216
      天使插件源码/TSPlug/ASM/MgAsmBase.cpp
  2. 617 617
      天使插件源码/TSPlug/ASM/MgAsmCom.cpp
  3. 74 74
      天使插件源码/TSPlug/ASM/MgAsmCom.h
  4. 690 690
      天使插件源码/TSPlug/ASM/MgDisasmBase.cpp
  5. 249 248
      天使插件源码/TSPlug/CreateGif/GSKCreateGIF.cpp
  6. 170 166
      天使插件源码/TSPlug/CreateGif/Quantizer.cpp
  7. 27 27
      天使插件源码/TSPlug/CreateGif/Quantizer.h
  8. 357 357
      天使插件源码/TSPlug/DXBind.cpp
  9. 34 34
      天使插件源码/TSPlug/DXBind.h
  10. 43 43
      天使插件源码/TSPlug/KeyMouse/MyKeyboardNamespace.cpp
  11. 53 53
      天使插件源码/TSPlug/KeyMouse/MyKeyboardNamespace.h
  12. 304 304
      天使插件源码/TSPlug/KeyMouse/MyMouseNamespace.cpp
  13. 67 67
      天使插件源码/TSPlug/KeyMouse/MyMouseNamespace.h
  14. 312 312
      天使插件源码/TSPlug/TSFindPicture.cpp
  15. 51 51
      天使插件源码/TSPlug/TSFindPicture.h
  16. 373 373
      天使插件源码/TSPlug/TSHookFuntion.h
  17. 337 337
      天使插件源码/TSPlug/TSMemoryAPI.cpp
  18. 97 100
      天使插件源码/TSPlug/TSMemoryAPI.h
  19. 106 106
      天使插件源码/TSPlug/TSMessage.h
  20. 26 26
      天使插件源码/TSPlug/TSPlug.cpp
  21. 2 2
      天使插件源码/TSPlug/TSPlug.vcxproj
  22. 297 297
      天使插件源码/TSPlug/TSPlugInterFace.cpp
  23. 13 13
      天使插件源码/TSPlug/TSPlugInterFace.h
  24. 2 2
      天使插件源码/TSPlug/TSPlugPS.vcxproj
  25. 367 368
      天使插件源码/TSPlug/TSRuntime.cpp
  26. 20 20
      天使插件源码/TSPlug/TSRuntime.h
  27. 52 52
      天使插件源码/TSPlug/TSVIPHookFuntion.h
  28. 2758 2759
      天使插件源码/TSPlug/TSWindowsAPI.cpp
  29. 38 38
      天使插件源码/TSPlug/TSWindowsAPI.h
  30. 165 165
      天使插件源码/TSPlug/dllmain.cpp
  31. 17 17
      天使插件源码/TSPlug/dllmain.h

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1216 - 1216
天使插件源码/TSPlug/ASM/MgAsmBase.cpp


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 617 - 617
天使插件源码/TSPlug/ASM/MgAsmCom.cpp


+ 74 - 74
天使插件源码/TSPlug/ASM/MgAsmCom.h

@@ -44,23 +44,23 @@ typedef unsigned long  ulong;          // Unsigned long
 //-------------------------------------------------------------------------------------------------------------------------
 //结构声明
 //
-typedef		struct		_tagMgAsmCom_CommandData_ 
+typedef		struct		_tagMgAsmCom_CommandData_
 {
 	ulong          mask;                 // Mask for first 4 bytes of the command
 	ulong          code;                 // Compare masked bytes with this
 	uchar          len;                  // Length of the main command code
 	uchar          bits;                 // Special bits within the command
-	uchar          arg1,arg2,arg3;       // Types of possible arguments
+	uchar          arg1, arg2, arg3;       // Types of possible arguments
 	uchar          type;                 // C_xxx + additional information
-	char           *name;                // Symbolic name for this command
-} _MGASM_CMDDATA_,t_cmddata;
+	char* name;                // Symbolic name for this command
+} _MGASM_CMDDATA_, t_cmddata;
 
 //
-typedef		struct		_tagMgAsmCom_AddrDec_ 
+typedef		struct		_tagMgAsmCom_AddrDec_
 {
 	int            defseg;
-	char           *descr;
-} _MGASM_ADDRDEC_,t_addrdec;
+	char* descr;
+} _MGASM_ADDRDEC_, t_addrdec;
 
 
 //-------------------------------------------------------------------------------------------------------------------------
@@ -77,15 +77,15 @@ private:
 public:	//-------------------------------------- 结构部分 ----------------------------------
 
 	// Model to search for assembler command
-	typedef struct _tagAsmModel 
-	{            
-unsigned	char           code[MAXCMDSIZE];     // Binary code
-unsigned	char           mask[MAXCMDSIZE];     // Mask for binary code (0: bit ignored)
-			int            length;               // Length of code, bytes (0: empty)
-			int            jmpsize;              // Offset size if relative jump
-			int            jmpoffset;            // Offset relative to IP
-			int            jmppos;               // Position of jump offset in command
-	} _ASMMODEL_,t_asmmodel;
+	typedef struct _tagAsmModel
+	{
+		unsigned	char           code[MAXCMDSIZE];     // Binary code
+		unsigned	char           mask[MAXCMDSIZE];     // Mask for binary code (0: bit ignored)
+		int            length;               // Length of code, bytes (0: empty)
+		int            jmpsize;              // Offset size if relative jump
+		int            jmpoffset;            // Offset relative to IP
+		int            jmppos;               // Position of jump offset in command
+	} _ASMMODEL_, t_asmmodel;
 
 	//
 	typedef struct _tagAsmOperand {
@@ -98,11 +98,11 @@ unsigned	char           mask[MAXCMDSIZE];     // Mask for binary code (0: bit ig
 		int            anyoffset;            // Offset is present but undefined
 		int            segment;              // Segment in address if present
 		int            jmpmode;              // Specified jump size
-	} _ASMOPERAND_,t_asmoperand;
+	} _ASMOPERAND_, t_asmoperand;
 
 	/*
 	//
-	typedef		struct		_tagAddrDec_ 
+	typedef		struct		_tagAddrDec_
 	{
 		int            defseg;
 		char           *descr;
@@ -111,7 +111,7 @@ unsigned	char           mask[MAXCMDSIZE];     // Mask for binary code (0: bit ig
 
 	//
 	/*
-	typedef		struct		_tagCommandData_ 
+	typedef		struct		_tagCommandData_
 	{
 		ulong          mask;                 // Mask for first 4 bytes of the command
 		ulong          code;                 // Compare masked bytes with this
@@ -124,13 +124,13 @@ unsigned	char           mask[MAXCMDSIZE];     // Mask for binary code (0: bit ig
 	*/
 
 public:		//-------------------------------------- 变量部分 ----------------------------------
-	char	*	m_pAsmCmd;              // Pointer to 0-terminated source line
+	char* m_pAsmCmd;              // Pointer to 0-terminated source line
 	int			m_nScan;                // Type of last scanned element
 	int			m_nPrio;                // Priority of operation (0: highest)
 	char		m_sdata[TEXTLEN];     // Last scanned name (depends on type)
 	long		m_idata;               // Last scanned value
 	long double m_fdata;                // Floating-point number
-	char	*	m_pAsmError;            // Explanation of last error, or NULL
+	char* m_pAsmError;            // Explanation of last error, or NULL
 
 public:
 	int			m_nIDEAL;                // Force IDEAL decoding mode
@@ -138,48 +138,48 @@ public:
 
 protected:  //-------------------------------------- 函数部分 ----------------------------------
 	void		Scanasm(int mode);
-	void		Parseasmoperand(t_asmoperand *op);
-	
+	void		Parseasmoperand(t_asmoperand* op);
+
 public:
-	int			Assemble(char *cmd,ulong ip,t_asmmodel *model,int attempt,int constsize,char *errtext);
+	int			Assemble(char* cmd, ulong ip, t_asmmodel* model, int attempt, int constsize, char* errtext);
 
 };
 
 //-------------------------------------------------------------------------------------------------------------------------
 //反汇编基础类声明
-class CMgDisasmBase  
+class CMgDisasmBase
 {
 public:
 	CMgDisasmBase();
 	virtual ~CMgDisasmBase();
 
 public:	//-------------------------------------- 结构部分 ----------------------------------
-	
+
 	// Results of disassembling
-	typedef		struct		_tagDisasm_ 
-	{             
-			ulong          ip;                   // Instrucion pointer
-			char           dump[TEXTLEN];        // Hexadecimal dump of the command
-			char           result[TEXTLEN];      // Disassembled command
-			char           comment[TEXTLEN];     // Brief comment
-			int            cmdtype;              // One of C_xxx
-			int            memtype;              // Type of addressed variable in memory
-			int            nprefix;              // Number of prefixes
-			int            indexed;              // Address contains register(s)
-			ulong          jmpconst;             // Constant jump address
-			ulong          jmptable;             // Possible address of switch table
-			ulong          adrconst;             // Constant part of address
-			ulong          immconst;             // Immediate constant
-			int            zeroconst;            // Whether contains zero constant
-			int            fixupoffset;          // Possible offset of 32-bit fixups
-			int            fixupsize;            // Possible total size of fixups or 0
-			int            error;                // Error while disassembling command
-			int            warnings;             // Combination of DAW_xxx
-	} _DISASM_,t_disasm;
+	typedef		struct		_tagDisasm_
+	{
+		ulong          ip;                   // Instrucion pointer
+		char           dump[TEXTLEN];        // Hexadecimal dump of the command
+		char           result[TEXTLEN];      // Disassembled command
+		char           comment[TEXTLEN];     // Brief comment
+		int            cmdtype;              // One of C_xxx
+		int            memtype;              // Type of addressed variable in memory
+		int            nprefix;              // Number of prefixes
+		int            indexed;              // Address contains register(s)
+		ulong          jmpconst;             // Constant jump address
+		ulong          jmptable;             // Possible address of switch table
+		ulong          adrconst;             // Constant part of address
+		ulong          immconst;             // Immediate constant
+		int            zeroconst;            // Whether contains zero constant
+		int            fixupoffset;          // Possible offset of 32-bit fixups
+		int            fixupsize;            // Possible total size of fixups or 0
+		int            error;                // Error while disassembling command
+		int            warnings;             // Combination of DAW_xxx
+	} _DISASM_, t_disasm;
 
 	/*
 	//
-	typedef		struct		_tagAddrDec_ 
+	typedef		struct		_tagAddrDec_
 	{
 		int            defseg;
 		char           *descr;
@@ -188,7 +188,7 @@ public:	//-------------------------------------- 
 
 	//
 	/*
-	typedef		struct		_tagCommandData_ 
+	typedef		struct		_tagCommandData_
 	{
 		ulong          mask;                 // Mask for first 4 bytes of the command
 		ulong          code;                 // Compare masked bytes with this
@@ -202,17 +202,17 @@ public:	//-------------------------------------- 
 
 public:
 	//
-	t_disasm	*	m_pDisasm;
+	t_disasm* m_pDisasm;
 
 	//
-	char		*	m_pCmd;                 // Pointer to binary data
-	char		*	m_pPFixup;              // Pointer to possible fixups or NULL
+	char* m_pCmd;                 // Pointer to binary data
+	char* m_pPFixup;              // Pointer to possible fixups or NULL
 	ulong			m_ulSize;                 // Remaining size of the command buffer
 	int				m_nMode;                 // Disassembly mode (DISASM_xxx)
 
 
 public:		//-------------------------------------- 变量部分 ----------------------------------
-	
+
 	//
 	ulong		m_ulDataSize;			// Size of data (1,2,4 bytes)
 	ulong		m_ulAddrSize;			// Size of address (2 or 4 bytes)
@@ -251,19 +251,19 @@ public:
 
 protected:  //-------------------------------------- 函数部分 ----------------------------------
 	//
-	void		DecodeRG(int index,int datasize,int type);
-	void		DecodeST(int index,int pseudoop);
+	void		DecodeRG(int index, int datasize, int type);
+	void		DecodeST(int index, int pseudoop);
 	void		DecodeMX(int index);
 	void		DecodeNR(int index);
 	void		DecodeMR(int type);
 	void		DecodeSO(void);
 	void		DecodeDE(void);
 	void		DecodeXL(void);
-	void		DecodeIM(int constsize,int sxt,int type);
+	void		DecodeIM(int constsize, int sxt, int type);
 	void		DecodeVX(void);
 	void		DecodeC1(void);
 	void		DecodeIA(void);
-	void		DecodeRJ(ulong offsize,ulong nextip);
+	void		DecodeRJ(ulong offsize, ulong nextip);
 	void		DecodeJF(void);
 	void		DecodeSG(int index);
 	void		DecodeCR(int index);
@@ -271,28 +271,28 @@ protected:  //-------------------------------------- 
 
 public:
 	int			Get3dnowsuffix(void);
-	void		Memadr(int defseg,const char *descr,long offset,int dsize);
-	int			Decodeaddress(ulong addr,char *symb,int nsymb,char *comment);
+	void		Memadr(int defseg, const char* descr, long offset, int dsize);
+	int			Decodeaddress(ulong addr, char* symb, int nsymb, char* comment);
 
 public:
-	ulong		Disasm( char *src, ulong srcsize, ulong srcip, t_disasm *disasm, int disasmmode );
-	ulong		Disassembleback(char *block,ulong base,ulong size,ulong ip,int n);
-	ulong		Disassembleforward(char *block,ulong base,ulong size,ulong ip,int n);
+	ulong		Disasm(char* src, ulong srcsize, ulong srcip, t_disasm* disasm, int disasmmode);
+	ulong		Disassembleback(char* block, ulong base, ulong size, ulong ip, int n);
+	ulong		Disassembleforward(char* block, ulong base, ulong size, ulong ip, int n);
 
 
 };
 
 //-------------------------------------------------------------------------------------------------------------------------
 //全局变量声明:
-extern	char	*	g_szSegName[8];
-extern	char	*	g_szRegName[3][9];
-extern	char	*	g_szCRName[9];
-extern	char	*	g_szDRName[9];
-extern	char	*	g_szFPUName[9];
-extern	char	*	g_szMMXName[9];
+extern	char* g_szSegName[8];
+extern	char* g_szRegName[3][9];
+extern	char* g_szCRName[9];
+extern	char* g_szDRName[9];
+extern	char* g_szFPUName[9];
+extern	char* g_szMMXName[9];
 
 //
-extern	char	*	g_szSizeName[11];
+extern	char* g_szSizeName[11];
 
 //
 extern	t_cmddata	g_CmdData[];
@@ -311,7 +311,7 @@ extern	t_addrdec	g_addr32[8];
 // Returns 1 if condition is met, 0 if not and -1 in case of error (which is
 // not possible).
 //--------------------------------------------------------------------------------
-int			Checkcondition(int code,ulong flags);
+int			Checkcondition(int code, ulong flags);
 
 //--------------------------------------------------------------------------------
 // Service function, checks whether command at offset addr in data is a valid
@@ -319,13 +319,13 @@ int			Checkcondition(int code,ulong flags);
 // (align=power of 2, 0 means no alignment) border. Returns length of filling
 // command in bytes or 0 if command is not a recognized filling.
 //--------------------------------------------------------------------------------
-int			Isfilling(ulong addr,char *data,ulong size,ulong align);
+int			Isfilling(ulong addr, char* data, ulong size, ulong align);
 
 //--------------------------------------------------------------------------------
 // Decodes and prints 64-bit 3DNow! element f into string s (which must be at
 // least 30 bytes long). Returns resulting length of the string.
 //--------------------------------------------------------------------------------
-int			Print3dnow(char *s,char *f);
+int			Print3dnow(char* s, char* f);
 
 
 
@@ -334,21 +334,21 @@ int			Print3dnow(char *s,char *f);
 // long). Procedure correctly displays all, even invalid, numbers without
 // arithmetical exceptions. Returns resulting length of the string.
 //--------------------------------------------------------------------------------
-int			Printfloat10(char *s,long double ext);
+int			Printfloat10(char* s, long double ext);
 
 
 //--------------------------------------------------------------------------------
 // Decodes and prints 64-bit double d into string s (at least 25 bytes long).
 // Returns resulting length of the string.
 //--------------------------------------------------------------------------------
-int			Printfloat8(char *s,double d);
+int			Printfloat8(char* s, double d);
 
 
 //--------------------------------------------------------------------------------
 // Decodes and prints 32-bit float f into string s (which must be at least 16
 // bytes long). Returns resulting length of the string.
 //--------------------------------------------------------------------------------
-int			Printfloat4(char *s,float f);
+int			Printfloat4(char* s, float f);
 
 //-------------------------------------------------------------------------------------------------------------------------
 //

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 690 - 690
天使插件源码/TSPlug/ASM/MgDisasmBase.cpp


+ 249 - 248
天使插件源码/TSPlug/CreateGif/GSKCreateGIF.cpp

@@ -15,7 +15,7 @@ typedef struct _GIFHEADER
 	WORD ScreenHeight;
 	BYTE GlobalFlagByte;
 	BYTE BackGroundColor;
-	BYTE AspectRatio;	
+	BYTE AspectRatio;
 }GIFHEARD;
 
 #define HASPalette 0x80
@@ -32,57 +32,57 @@ typedef struct _GIFDATAHEARD
 }GIFDATAHEARD;
 
 
-void addToBuf(HANDLE file,BYTE *buf,long &nUsedBits,BYTE data,int nBit)
+void addToBuf(HANDLE file, BYTE* buf, long& nUsedBits, BYTE data, int nBit)
 {
-	int nIndex,nCurByteUsedBits;
-	
-	nIndex = nUsedBits/8;
-	nCurByteUsedBits = nUsedBits%8;
+	int nIndex, nCurByteUsedBits;
 
-	if(nIndex >= 255)
+	nIndex = nUsedBits / 8;
+	nCurByteUsedBits = nUsedBits % 8;
+
+	if (nIndex >= 255)
 	{//已经产生255个字节的数据
 		BYTE bytes = 0xFF;
-		DWORD DwWitten=0;
-		::WriteFile(file,&bytes,1,&DwWitten,NULL);
-		::WriteFile(file,buf,bytes,&DwWitten,NULL);
+		DWORD DwWitten = 0;
+		::WriteFile(file, &bytes, 1, &DwWitten, NULL);
+		::WriteFile(file, buf, bytes, &DwWitten, NULL);
 		//file.Write(&bytes,1);
 		//file.Write(buf,bytes);
 
 		buf[0] = buf[255];
 		nIndex = 0;
-		nUsedBits -= 255*8;
+		nUsedBits -= 255 * 8;
 	}
-	
-	if(nCurByteUsedBits == 0)
+
+	if (nCurByteUsedBits == 0)
 	{
 		buf[nIndex] = data;
 	}
 	else
 	{
-		buf[nIndex] |= data<<nCurByteUsedBits;
-	
-		if(nBit > 8-nCurByteUsedBits)
+		buf[nIndex] |= data << nCurByteUsedBits;
+
+		if (nBit > 8 - nCurByteUsedBits)
 		{
 			nIndex++;
-			buf[nIndex] = data>>(8-nCurByteUsedBits);
+			buf[nIndex] = data >> (8 - nCurByteUsedBits);
 		}
 	}
-		
+
 	nUsedBits += nBit;
 }
 
-void WriteData(HANDLE file,WORD *pHeard,int nDataCount,BYTE bitsPixel,BOOL bEnd)
+void WriteData(HANDLE file, WORD* pHeard, int nDataCount, BYTE bitsPixel, BOOL bEnd)
 {
-	BYTE initBits = bitsPixel+1;
+	BYTE initBits = bitsPixel + 1;
 	BYTE pByts[256];
-	BYTE *pTmp = (BYTE*)pHeard;
-	int nCurCodeBits=initBits;
-	WORD nMaxCode=1;
-	WORD nClearCode=1;
+	BYTE* pTmp = (BYTE*)pHeard;
+	int nCurCodeBits = initBits;
+	WORD nMaxCode = 1;
+	WORD nClearCode = 1;
 	WORD nEndCode;
 
 	/*CStdioFile strFile;
-	
+
 	if(strFile.Open("d:\\writedata.txt",CFile::modeWrite|CFile::modeCreate|CFile::typeText))
 	{
 		CString sTmp;
@@ -94,139 +94,139 @@ void WriteData(HANDLE file,WORD *pHeard,int nDataCount,BYTE bitsPixel,BOOL bEnd)
 	}
 	*/
 
-	nClearCode <<= nCurCodeBits-1;
+	nClearCode <<= nCurCodeBits - 1;
 	nMaxCode <<= nCurCodeBits;
-	nEndCode = nClearCode+1;
+	nEndCode = nClearCode + 1;
+
+	memset(pByts, 0, 256);
 
-	memset(pByts,0,256);
-	
 	long nUsedBits = 0;
 
-	addToBuf(file,pByts,nUsedBits,nClearCode&0xFF,min(8,nCurCodeBits));
-	if(nCurCodeBits > 8)
+	addToBuf(file, pByts, nUsedBits, nClearCode & 0xFF, min(8, nCurCodeBits));
+	if (nCurCodeBits > 8)
 	{
-		addToBuf(file,pByts,nUsedBits,(nClearCode&0xFF00)>>8,nCurCodeBits-8);
+		addToBuf(file, pByts, nUsedBits, (nClearCode & 0xFF00) >> 8, nCurCodeBits - 8);
 	}
-	
-	int nHeardCode = nClearCode+1;
 
-	for(int i=0; i<nDataCount; i++)
+	int nHeardCode = nClearCode + 1;
+
+	for (int i = 0; i < nDataCount; i++)
 	{
-		if(nHeardCode++ >= nMaxCode)
+		if (nHeardCode++ >= nMaxCode)
 		{
 			nCurCodeBits++;
-			if(nCurCodeBits == 13)
+			if (nCurCodeBits == 13)
 			{
 				//CString sMsg;
 				//sMsg.Format("[%X,%X]",pHeard[i-1],pHeard[i]);
 				//AfxMessageBox(sMsg);
 
-				addToBuf(file,pByts,nUsedBits,nClearCode&0xFF,8);
-				addToBuf(file,pByts,nUsedBits,(nClearCode&0xFF00)>>8,4);
+				addToBuf(file, pByts, nUsedBits, nClearCode & 0xFF, 8);
+				addToBuf(file, pByts, nUsedBits, (nClearCode & 0xFF00) >> 8, 4);
 				nCurCodeBits = initBits;
 
-				nHeardCode = nClearCode+2;
+				nHeardCode = nClearCode + 2;
 			}
-			
-			nMaxCode = (WORD)1<<nCurCodeBits;
+
+			nMaxCode = (WORD)1 << nCurCodeBits;
 		}
-		
-		addToBuf(file,pByts,nUsedBits,pHeard[i]&0xFF,min(8,nCurCodeBits));
-		
-		if(nCurCodeBits > 8)
+
+		addToBuf(file, pByts, nUsedBits, pHeard[i] & 0xFF, min(8, nCurCodeBits));
+
+		if (nCurCodeBits > 8)
 		{
-			addToBuf(file,pByts,nUsedBits,(pHeard[i]&0xFF00)>>8,nCurCodeBits-8);
+			addToBuf(file, pByts, nUsedBits, (pHeard[i] & 0xFF00) >> 8, nCurCodeBits - 8);
 		}
 	}
 
-	if(bEnd)
+	if (bEnd)
 	{
-		addToBuf(file,pByts,nUsedBits,nEndCode&0xFF,min(8,nCurCodeBits));
-		if(nCurCodeBits > 8)
+		addToBuf(file, pByts, nUsedBits, nEndCode & 0xFF, min(8, nCurCodeBits));
+		if (nCurCodeBits > 8)
 		{
-			addToBuf(file,pByts,nUsedBits,(nEndCode&0xFF00)>>8,nCurCodeBits-8);
+			addToBuf(file, pByts, nUsedBits, (nEndCode & 0xFF00) >> 8, nCurCodeBits - 8);
 		}
 	}
 
-	long nByteCount = nUsedBits/8;
-	
-	if(nUsedBits%8 != 0)
+	long nByteCount = nUsedBits / 8;
+
+	if (nUsedBits % 8 != 0)
 	{
 		nByteCount++;
 	}
-	
+
 	BYTE bytes;
 	int nIndex = 0;
-	DWORD DwWitten=0;
-	while(nByteCount>0)
+	DWORD DwWitten = 0;
+	while (nByteCount > 0)
 	{
-		bytes = min(0xFF,(BYTE)nByteCount);
+		bytes = min(0xFF, (BYTE)nByteCount);
 		nByteCount -= bytes;
-		
-		
-		::WriteFile(file,&bytes,1,&DwWitten,NULL);
-		::WriteFile(file,pByts+nIndex,bytes,&DwWitten,NULL);
+
+
+		::WriteFile(file, &bytes, 1, &DwWitten, NULL);
+		::WriteFile(file, pByts + nIndex, bytes, &DwWitten, NULL);
 		//file.Write(&bytes,1);
 		//file.Write(pByts+nIndex,bytes);
-		
+
 		nIndex += bytes;
 	}
 
 	bytes = 0x0;
 	//file.Write(&bytes,1);
-	::WriteFile(file,&bytes,1,&DwWitten,NULL);
+	::WriteFile(file, &bytes, 1, &DwWitten, NULL);
 }
 
-BYTE GetColorIndex(RGBQUAD *pQuad, UINT nSize,BYTE r,BYTE g,BYTE b)
+BYTE GetColorIndex(RGBQUAD* pQuad, UINT nSize, BYTE r, BYTE g, BYTE b)
 {
 	BYTE nIndex;
-	long nDist,nRDist,nGDist,nBDist,nMinDist = 999999999;
+	long nDist, nRDist, nGDist, nBDist, nMinDist = 999999999;
+
 
-	
-	for(UINT i=0; i<nSize; i++)
+	for (UINT i = 0; i < nSize; i++)
 	{
 		nRDist = pQuad[i].rgbRed - r;
 		nGDist = pQuad[i].rgbGreen - g;
 		nBDist = pQuad[i].rgbBlue - b;
 
-		nDist = nRDist*nRDist + nGDist*nGDist + nBDist*nBDist;
+		nDist = nRDist * nRDist + nGDist * nGDist + nBDist * nBDist;
 
 		//nDist = 0.3*abs(nRDist) + 0.59*abs(nGDist) + 0.11*abs(nBDist);
 
-		if(nDist < nMinDist)
+		if (nDist < nMinDist)
 		{
 			nIndex = (BYTE)i;
 			nMinDist = nDist;
-			if(nDist == 0)
+			if (nDist == 0)
 			{
 				break;
 			}
 		}
 	}
-	
+
 	return nIndex;
 }
 
-BOOL GetData(HBITMAP hBmp,BYTE **ppPalette,BYTE **ppData,BYTE *pBitsPixel,int *pWidth,int *pHeight)
+BOOL GetData(HBITMAP hBmp, BYTE** ppPalette, BYTE** ppData, BYTE* pBitsPixel, int* pWidth, int* pHeight)
 {
 	BITMAP bm;
 	PBITMAPINFO bmpInf;
-	
-	if(GetObject(hBmp,sizeof(bm),&bm)==0)
+
+	if (GetObject(hBmp, sizeof(bm), &bm) == 0)
 		return FALSE;
-	
-	int nPaletteSize=0;
-	
-	if(bm.bmBitsPixel<16)
-		nPaletteSize=(int)pow(2.0,bm.bmBitsPixel);
-	
-	bmpInf=(PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER)+
-		sizeof(RGBQUAD)*nPaletteSize+((bm.bmWidth*bm.bmBitsPixel+31)/32)*4*bm.bmHeight);
-	
-	BYTE* buf=((BYTE*)bmpInf) + 
-		sizeof(BITMAPINFOHEADER)+
-		sizeof(RGBQUAD)*nPaletteSize;
-	
+
+	int nPaletteSize = 0;
+
+	if (bm.bmBitsPixel < 16)
+		nPaletteSize = (int)pow(2.0, bm.bmBitsPixel);
+
+	bmpInf = (PBITMAPINFO)LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER) +
+		sizeof(RGBQUAD) * nPaletteSize + ((bm.bmWidth * bm.bmBitsPixel + 31) / 32) * 4 * bm.bmHeight);
+
+	BYTE* buf = ((BYTE*)bmpInf) +
+		sizeof(BITMAPINFOHEADER) +
+		sizeof(RGBQUAD) * nPaletteSize;
+
 	//-----------------------------------------------
 	bmpInf->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 	bmpInf->bmiHeader.biWidth = bm.bmWidth;
@@ -234,144 +234,145 @@ BOOL GetData(HBITMAP hBmp,BYTE **ppPalette,BYTE **ppData,BYTE *pBitsPixel,int *p
 	bmpInf->bmiHeader.biPlanes = bm.bmPlanes;
 	bmpInf->bmiHeader.biBitCount = bm.bmBitsPixel;
 	bmpInf->bmiHeader.biCompression = BI_RGB;
-	bmpInf->bmiHeader.biSizeImage = (bm.bmWidth+7)/8*bm.bmHeight*bm.bmBitsPixel;
+	bmpInf->bmiHeader.biSizeImage = (bm.bmWidth + 7) / 8 * bm.bmHeight * bm.bmBitsPixel;
 	//-----------------------------------------------
-	
+
 	HDC hDC = ::GetWindowDC(NULL);
-	
-	if(!::GetDIBits(hDC,hBmp,0,(UINT)bm.bmHeight,buf,bmpInf,DIB_RGB_COLORS))
+
+	if (!::GetDIBits(hDC, hBmp, 0, (UINT)bm.bmHeight, buf, bmpInf, DIB_RGB_COLORS))
 	{
-		::ReleaseDC(NULL,hDC);
+		::ReleaseDC(NULL, hDC);
 		LocalFree(bmpInf);
 		return FALSE;
 	}
-	
-	::ReleaseDC(NULL,hDC);
+
+	::ReleaseDC(NULL, hDC);
 
 	*pWidth = bm.bmWidth;
 	*pHeight = bm.bmHeight;
 
-	*ppData = new BYTE[bm.bmWidth*bm.bmHeight];
+	*ppData = new BYTE[bm.bmWidth * bm.bmHeight];
 
 
-	CQuantizer quan(256,8);
-	
-	bmpInf->bmiHeader.biSize = sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*nPaletteSize;
+	CQuantizer quan(256, 8);
+
+	bmpInf->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * nPaletteSize;
 	quan.ProcessImage(bmpInf);
 
 	int nColorCount = quan.GetColorCount();
-	RGBQUAD *pQuad = new RGBQUAD[nColorCount];
-	
+	RGBQUAD* pQuad = new RGBQUAD[nColorCount];
+
 	quan.SetColorTable(pQuad);
-	
+
 	int nLnBytes;
-	
+
 	//每行数据是4字节的整数倍
-	nLnBytes = ((bm.bmWidth*bm.bmBitsPixel+31)/32)*4;
+	nLnBytes = ((bm.bmWidth * bm.bmBitsPixel + 31) / 32) * 4;
 
-	int nOffset,i,nIndex=0;
-	BYTE r,g,b;
+	int nOffset, i, nIndex = 0;
+	BYTE r, g, b;
 	UINT nColorIndex;
-	
-	switch(bm.bmBitsPixel)
+
+	switch (bm.bmBitsPixel)
 	{
 	case 1:
 	case 4:
 	case 8:
+	{
+		delete[]pQuad;
+		nColorCount = (int)pow(2.0, bm.bmBitsPixel);
+		pQuad = new RGBQUAD[nColorCount];
+		memcpy(pQuad, (BYTE*)bmpInf + sizeof(BITMAPINFOHEADER), sizeof(RGBQUAD) * nColorCount);
+
+		for (i = bm.bmHeight - 1; i >= 0; i--)
 		{
-			delete []pQuad;
-			nColorCount = (int)pow(2.0,bm.bmBitsPixel);
-			pQuad = new RGBQUAD[nColorCount];
-			memcpy(pQuad,(BYTE*)bmpInf+sizeof(BITMAPINFOHEADER),sizeof(RGBQUAD)*nColorCount);
+			nOffset = i * nLnBytes;
 
-			for(i=bm.bmHeight-1; i>=0; i--)
+			for (int j = 0; j < bm.bmWidth; j++)
 			{
-				nOffset = i*nLnBytes;
-				
-				for(int j=0; j<bm.bmWidth; j++)
+				if (bm.bmBitsPixel == 8)
+				{
+					(*ppData)[nIndex++] = buf[nOffset + j];
+				}
+				else
 				{
-					if(bm.bmBitsPixel==8)
+					BYTE pos;
+					BYTE iDst = buf[nOffset + (j * bm.bmBitsPixel >> 3)];
+					if (bm.bmBitsPixel == 4)
 					{
-						(*ppData)[nIndex++] = buf[nOffset+j];
-					} 
-					else
+						pos = 4 * (1 - j % 2);
+						iDst &= (0x0F << pos);
+						(*ppData)[nIndex++] = iDst >> pos;
+					}
+					else if (bm.bmBitsPixel == 1)
 					{
-						BYTE pos;
-						BYTE iDst= buf[nOffset + (j*bm.bmBitsPixel >> 3)];
-						if (bm.bmBitsPixel==4)
-						{
-							pos = 4*(1-j%2);
-							iDst &= (0x0F<<pos);
-							(*ppData)[nIndex++] = iDst >> pos;
-						}else if (bm.bmBitsPixel==1)
-						{
-							pos = 7-j%8;
-							iDst &= (0x01<<pos);
-							(*ppData)[nIndex++] = iDst >> pos;
-						}
+						pos = 7 - j % 8;
+						iDst &= (0x01 << pos);
+						(*ppData)[nIndex++] = iDst >> pos;
 					}
 				}
 			}
 		}
-		break;
+	}
+	break;
 	case 15:
 	case 16:
-		for(i=bm.bmHeight-1; i>=0; i--)
+		for (i = bm.bmHeight - 1; i >= 0; i--)
 		{
-			nOffset = i*nLnBytes;
-			
-			for(int j=0; j<bm.bmWidth; j++)
+			nOffset = i * nLnBytes;
+
+			for (int j = 0; j < bm.bmWidth; j++)
 			{
-				b = buf[nOffset+j*2]&0x1F;
-				g = buf[nOffset+j*2]>>5;
-				g |= (buf[nOffset+j*2+1]&0x03)<<3;
-				r = (buf[nOffset+j*2+1]>>2)&0x1F;
-				
+				b = buf[nOffset + j * 2] & 0x1F;
+				g = buf[nOffset + j * 2] >> 5;
+				g |= (buf[nOffset + j * 2 + 1] & 0x03) << 3;
+				r = (buf[nOffset + j * 2 + 1] >> 2) & 0x1F;
+
 				r *= 8;
 				b *= 8;
 				g *= 8;
 
-				quan.GetColorIndex(r,g,b,&nColorIndex);
+				quan.GetColorIndex(r, g, b, &nColorIndex);
 				(*ppData)[nIndex++] = (BYTE)nColorIndex;
 			}
 		}
 		break;
 	case 24:
-		for(i=bm.bmHeight-1; i>=0; i--)
+		for (i = bm.bmHeight - 1; i >= 0; i--)
 		{
-			nOffset = i*nLnBytes;
-			
-			for(int j=0; j<bm.bmWidth; j++)
+			nOffset = i * nLnBytes;
+
+			for (int j = 0; j < bm.bmWidth; j++)
 			{
-				b = buf[nOffset+j*3];
-				g = buf[nOffset+j*3+1];
-				r = buf[nOffset+j*3+2];
+				b = buf[nOffset + j * 3];
+				g = buf[nOffset + j * 3 + 1];
+				r = buf[nOffset + j * 3 + 2];
 
-				quan.GetColorIndex(r,g,b,&nColorIndex);
+				quan.GetColorIndex(r, g, b, &nColorIndex);
 				(*ppData)[nIndex++] = (BYTE)nColorIndex;
-		
+
 				//该算法效果好,但速度慢
 				//pData[nIndex++]=GetColorIndex(pQuad,nColorCount,r,g,b);
 			}
 		}
 		break;
 	case 32:
-		for(i=bm.bmHeight-1; i>=0; i--)
+		for (i = bm.bmHeight - 1; i >= 0; i--)
 		{
-			nOffset = i*nLnBytes;
-			
-			for(int j=0; j<bm.bmWidth; j++)
+			nOffset = i * nLnBytes;
+
+			for (int j = 0; j < bm.bmWidth; j++)
 			{
-				b = buf[nOffset+j*4];
-				g = buf[nOffset+j*4+1];
-				r = buf[nOffset+j*4+2];
-				quan.GetColorIndex(r,g,b,&nColorIndex);
+				b = buf[nOffset + j * 4];
+				g = buf[nOffset + j * 4 + 1];
+				r = buf[nOffset + j * 4 + 2];
+				quan.GetColorIndex(r, g, b, &nColorIndex);
 				(*ppData)[nIndex++] = (BYTE)nColorIndex;
 			}
 		}
 		break;
 	default:
-		delete []pQuad;
+		delete[]pQuad;
 		LocalFree(bmpInf);
 		return FALSE;
 		break;
@@ -379,72 +380,72 @@ BOOL GetData(HBITMAP hBmp,BYTE **ppPalette,BYTE **ppData,BYTE *pBitsPixel,int *p
 
 	*pBitsPixel = 8;
 
-	if(nColorCount <= 8)
+	if (nColorCount <= 8)
 	{
 		*pBitsPixel = 3;
 	}
-	else if(nColorCount <= 16)
+	else if (nColorCount <= 16)
 	{
 		*pBitsPixel = 4;
 	}
-	else if(nColorCount <= 32)
+	else if (nColorCount <= 32)
 	{
 		*pBitsPixel = 5;
 	}
-	else if(nColorCount <= 64)
+	else if (nColorCount <= 64)
 	{
 		*pBitsPixel = 6;
 	}
-	else if(nColorCount <= 128)
+	else if (nColorCount <= 128)
 	{
 		*pBitsPixel = 7;
 	}
-	
-	int nGIFPaletteSize = (int)pow(2.0,(int)*pBitsPixel);
-	*ppPalette = new BYTE[nGIFPaletteSize*3];
-	memset(*ppPalette,0,nGIFPaletteSize*3);
-	
-	for(i=0; i<(int)nColorCount; i++)
+
+	int nGIFPaletteSize = (int)pow(2.0, (int)*pBitsPixel);
+	*ppPalette = new BYTE[nGIFPaletteSize * 3];
+	memset(*ppPalette, 0, nGIFPaletteSize * 3);
+
+	for (i = 0; i < (int)nColorCount; i++)
 	{
-		(*ppPalette)[i*3] = pQuad[i].rgbRed;
-		(*ppPalette)[i*3+1] = pQuad[i].rgbGreen;
-		(*ppPalette)[i*3+2] = pQuad[i].rgbBlue;
+		(*ppPalette)[i * 3] = pQuad[i].rgbRed;
+		(*ppPalette)[i * 3 + 1] = pQuad[i].rgbGreen;
+		(*ppPalette)[i * 3 + 2] = pQuad[i].rgbBlue;
 	}
 
-	delete []pQuad;
+	delete[]pQuad;
 	LocalFree(bmpInf);
 
 	return TRUE;
 }
 
-void EnCode(BYTE *pData,long nDataSize,BYTE bitsPixel,WORD **ppEnCodeData,long *pnSize)
+void EnCode(BYTE* pData, long nDataSize, BYTE bitsPixel, WORD** ppEnCodeData, long* pnSize)
 {
-	WORD *pHeard = new WORD[4097];
-	WORD *pEnd = new WORD[4096];
-	int nDataBufIndex=0;
+	WORD* pHeard = new WORD[4097];
+	WORD* pEnd = new WORD[4096];
+	int nDataBufIndex = 0;
 
 	//每幅图片最大1000000个像素
 	*ppEnCodeData = new WORD[1000000];
 
-	int nIndex =0;
+	int nIndex = 0;
 	int nDataIndex = 0;
 
 	pHeard[nIndex] = pData[nDataIndex];
-	pEnd[nIndex] = pData[nDataIndex+1];
+	pEnd[nIndex] = pData[nDataIndex + 1];
 	nIndex++;
 	nDataIndex++;
 
-	WORD wHeard,wEnd;
+	WORD wHeard, wEnd;
 	BOOL bEndIsValide = TRUE;
 
-	WORD wBeginCode = (((WORD)1)<<bitsPixel)+2;
+	WORD wBeginCode = (((WORD)1) << bitsPixel) + 2;
 
 	//编码
-	for(; nDataIndex<nDataSize; )
+	for (; nDataIndex < nDataSize; )
 	{
 		wHeard = pData[nDataIndex];
 
-		if(nDataIndex+1 >= nDataSize)
+		if (nDataIndex + 1 >= nDataSize)
 		{
 			pHeard[nIndex] = wHeard;
 			nIndex++;
@@ -452,30 +453,30 @@ void EnCode(BYTE *pData,long nDataSize,BYTE bitsPixel,WORD **ppEnCodeData,long *
 			break;
 		}
 
-		wEnd = pData[nDataIndex+1];
+		wEnd = pData[nDataIndex + 1];
 		nDataIndex++;
 
-		for(int i=0; i<nIndex; i++)
+		for (int i = 0; i < nIndex; i++)
 		{
-			if( (pHeard[i] == wHeard) && (pEnd[i] == wEnd) )
+			if ((pHeard[i] == wHeard) && (pEnd[i] == wEnd))
 			{
-				wHeard = wBeginCode+i;
-				if(nDataIndex+1 >= nDataSize)
+				wHeard = wBeginCode + i;
+				if (nDataIndex + 1 >= nDataSize)
 				{
 					pHeard[nIndex] = wHeard;
 					nIndex++;
 					bEndIsValide = FALSE;
 					break;
 				}
-				
-				wEnd = pData[nDataIndex+1];
+
+				wEnd = pData[nDataIndex + 1];
 				nDataIndex++;
 			}
 		}
-		
+
 		pHeard[nIndex] = wHeard;
-		
-		if(bEndIsValide)
+
+		if (bEndIsValide)
 		{
 			pEnd[nIndex] = wEnd;
 			nIndex++;
@@ -484,28 +485,28 @@ void EnCode(BYTE *pData,long nDataSize,BYTE bitsPixel,WORD **ppEnCodeData,long *
 		{
 			break;
 		}
-		
+
 		//达到4096(12位)后,重新开始编码
-		if(wBeginCode+nIndex-1 == 4096)
+		if (wBeginCode + nIndex - 1 == 4096)
 		{
-			memcpy( ((BYTE*)*ppEnCodeData)+nDataBufIndex,pHeard,nIndex*2);
-			nDataBufIndex += nIndex*2;
+			memcpy(((BYTE*)*ppEnCodeData) + nDataBufIndex, pHeard, nIndex * 2);
+			nDataBufIndex += nIndex * 2;
 			nIndex = 0;
-			
+
 			pHeard[nIndex] = pData[nDataIndex];
-			pEnd[nIndex] = pData[nDataIndex+1];
+			pEnd[nIndex] = pData[nDataIndex + 1];
 			nIndex++;
 			nDataIndex++;
 		}
 	}
-	
-	memcpy( ((BYTE*)*ppEnCodeData)+nDataBufIndex,pHeard,nIndex*2);
-	nDataBufIndex += nIndex*2;
 
-	*pnSize = nDataBufIndex/2;
+	memcpy(((BYTE*)*ppEnCodeData) + nDataBufIndex, pHeard, nIndex * 2);
+	nDataBufIndex += nIndex * 2;
 
-	delete []pHeard;
-	delete []pEnd;
+	*pnSize = nDataBufIndex / 2;
+
+	delete[]pHeard;
+	delete[]pEnd;
 }
 
 typedef struct _GraphicController
@@ -530,57 +531,57 @@ typedef struct _ApplicationExtension
 	BYTE blockTerminator;
 }ApplicationExtension;
 
-void CreateGIFHeard(HANDLE file,WORD nImageWidth,WORD nImageHeight,BYTE bitsPixel)
+void CreateGIFHeard(HANDLE file, WORD nImageWidth, WORD nImageHeight, BYTE bitsPixel)
 {
 	//GIF文件头,89a格式
 	GIFHEARD heard;
-	memcpy(heard.Signature,"GIF89a",6);
+	memcpy(heard.Signature, "GIF89a", 6);
 	heard.ScreenWidth = nImageWidth;
 	heard.ScreenHeight = nImageHeight;
 	//heard.GlobalFlagByte = HASPalette|((bitsPixel-1)<<4)|0|(bitsPixel-1);全局调色板
-	heard.GlobalFlagByte = ((bitsPixel-1)<<4);
+	heard.GlobalFlagByte = ((bitsPixel - 1) << 4);
 	heard.BackGroundColor = 0;
 	heard.AspectRatio = 0;
 
-	DWORD DwWitten=0;
-	::WriteFile(file,&heard,13,&DwWitten,NULL);
+	DWORD DwWitten = 0;
+	::WriteFile(file, &heard, 13, &DwWitten, NULL);
 	//file.Write(&heard,13);//不要用sizeof(GIFHEARD),除非把编译器设为1字节对齐
-	
+
 	//为了让IE循环播放,必须加入该应用程序块(如果只有一幅图片,可省略该块)
 	ApplicationExtension appData;
 	appData.extensionIntroducer = 0x21;
 	appData.applicationLabel = 0xFF;
 	appData.blockSize = 11;
-	memcpy(appData.applicationId,"NETSCAPE",8);
-	memcpy(appData.appAuthCode,"2.0",3);
+	memcpy(appData.applicationId, "NETSCAPE", 8);
+	memcpy(appData.appAuthCode, "2.0", 3);
 	appData.cAppData[0] = 3;
 	appData.cAppData[1] = 1;
 	appData.cAppData[2] = 0;
 	appData.cAppData[3] = 0;
 	appData.blockTerminator = 0;
-	
-	
-	::WriteFile(file,&appData,sizeof(ApplicationExtension),&DwWitten,NULL);
+
+
+	::WriteFile(file, &appData, sizeof(ApplicationExtension), &DwWitten, NULL);
 	//file.Write(&appData,sizeof(ApplicationExtension));
 }
 
-void AddImageToGIF(HANDLE file,BYTE *pData,BYTE *palette,WORD nImageWidth,WORD nImageHeight,BYTE bitsPixel,WORD nDelay,
-				   short int nTransparentColorIndex)
+void AddImageToGIF(HANDLE file, BYTE* pData, BYTE* palette, WORD nImageWidth, WORD nImageHeight, BYTE bitsPixel, WORD nDelay,
+	short int nTransparentColorIndex)
 {
 	//控制块
 	GraphicController control;
-	
+
 	control.extensionIntroducer = 0x21;
 	control.graphicControlLabel = 0xF9;
 	control.blockSize = 4;
-	control.packedField = (nTransparentColorIndex==-1? 4:5);
+	control.packedField = (nTransparentColorIndex == -1 ? 4 : 5);
 	control.nDelayTime = nDelay;//延迟时间
-	control.transparentColorIndex = (BYTE)(nTransparentColorIndex==-1? 0:nTransparentColorIndex);
+	control.transparentColorIndex = (BYTE)(nTransparentColorIndex == -1 ? 0 : nTransparentColorIndex);
 	control.blockTerminator = 0;
-	
+
 	//file.Write(&control,sizeof(GraphicController));
-	DWORD DwWitten=0;
-	::WriteFile(file,&control,sizeof(GraphicController),&DwWitten,NULL);
+	DWORD DwWitten = 0;
+	::WriteFile(file, &control, sizeof(GraphicController), &DwWitten, NULL);
 	////file.Write(palette,nGIFPaletteSize*3);全局调色板
 	//图片数据头
 	GIFDATAHEARD dataHeard;
@@ -589,14 +590,14 @@ void AddImageToGIF(HANDLE file,BYTE *pData,BYTE *palette,WORD nImageWidth,WORD n
 	dataHeard.imageTop = 0;
 	dataHeard.imageWidth = nImageWidth;
 	dataHeard.imageHeight = nImageHeight;
-	dataHeard.localFlagByte = HASPalette|(bitsPixel-1);
-	
-	::WriteFile(file,&dataHeard.imageLabel,1,&DwWitten,NULL);
-	::WriteFile(file,&dataHeard.imageLeft,2,&DwWitten,NULL);
-	::WriteFile(file,&dataHeard.imageTop,2,&DwWitten,NULL);
-	::WriteFile(file,&dataHeard.imageWidth,2,&DwWitten,NULL);
-	::WriteFile(file,&dataHeard.imageHeight,2,&DwWitten,NULL);
-	::WriteFile(file,&dataHeard.localFlagByte,1,&DwWitten,NULL);
+	dataHeard.localFlagByte = HASPalette | (bitsPixel - 1);
+
+	::WriteFile(file, &dataHeard.imageLabel, 1, &DwWitten, NULL);
+	::WriteFile(file, &dataHeard.imageLeft, 2, &DwWitten, NULL);
+	::WriteFile(file, &dataHeard.imageTop, 2, &DwWitten, NULL);
+	::WriteFile(file, &dataHeard.imageWidth, 2, &DwWitten, NULL);
+	::WriteFile(file, &dataHeard.imageHeight, 2, &DwWitten, NULL);
+	::WriteFile(file, &dataHeard.localFlagByte, 1, &DwWitten, NULL);
 
 	//file.Write(&dataHeard.imageLabel,1);
 	//file.Write(&dataHeard.imageLeft,2);
@@ -604,25 +605,25 @@ void AddImageToGIF(HANDLE file,BYTE *pData,BYTE *palette,WORD nImageWidth,WORD n
 	//file.Write(&dataHeard.imageWidth,2);
 	//file.Write(&dataHeard.imageHeight,2);
 	//file.Write(&dataHeard.localFlagByte,1);
-	
+
 	//调色板
 	//file.Write(palette,(int)pow(2,bitsPixel)*3);
-	::WriteFile(file,palette,(int)pow(2.0,bitsPixel)*3,&DwWitten,NULL);
+	::WriteFile(file, palette, (int)pow(2.0, bitsPixel) * 3, &DwWitten, NULL);
 
 	//每像素占用位数
 	//file.Write(&bitsPixel,1);
-	::WriteFile(file,&bitsPixel,1,&DwWitten,NULL);
-	
-	WORD *pEnCodeData = NULL;
+	::WriteFile(file, &bitsPixel, 1, &DwWitten, NULL);
+
+	WORD* pEnCodeData = NULL;
 	long nSize = 0;
 
 	//编码
-	EnCode(pData,nImageWidth*nImageHeight,bitsPixel,&pEnCodeData,&nSize);
-	
+	EnCode(pData, nImageWidth * nImageHeight, bitsPixel, &pEnCodeData, &nSize);
+
 	//写入数据
-	WriteData(file,pEnCodeData,nSize,bitsPixel,TRUE);
-	
-	delete []pEnCodeData;
+	WriteData(file, pEnCodeData, nSize, bitsPixel, TRUE);
+
+	delete[]pEnCodeData;
 }
 
 void CloseGIF(HANDLE file)
@@ -630,6 +631,6 @@ void CloseGIF(HANDLE file)
 	//写入结束标志
 	BYTE bytes = 0x3B;
 	//file.Write(&bytes,1);
-	DWORD DwWitten=0;
-	::WriteFile(file,&bytes,1,&DwWitten,NULL);
+	DWORD DwWitten = 0;
+	::WriteFile(file, &bytes, 1, &DwWitten, NULL);
 }

+ 170 - 166
天使插件源码/TSPlug/CreateGif/Quantizer.cpp

@@ -1,37 +1,37 @@
- #include "stdafx.h"
+#include "stdafx.h"
 #include "Quantizer.h"
 #include <MATH.H>
 
 /////////////////////////////////////////////////////////////////////////////
-CQuantizer::CQuantizer (UINT nMaxColors, UINT nColorBits)
+CQuantizer::CQuantizer(UINT nMaxColors, UINT nColorBits)
 {
 	m_nColorBits = nColorBits < 8 ? nColorBits : 8;
 
-	m_pTree	= NULL;
+	m_pTree = NULL;
 	m_nLeafCount = 0;
-	for	(int i=0; i<=(int) m_nColorBits; i++)
+	for (int i = 0; i <= (int)m_nColorBits; i++)
 		m_pReducibleNodes[i] = NULL;
 	m_nMaxColors = nMaxColors;
 }
 
 /////////////////////////////////////////////////////////////////////////////
-CQuantizer::~CQuantizer	()
+CQuantizer::~CQuantizer()
 {
-	if (m_pTree	!= NULL)
-		DeleteTree (&m_pTree);
+	if (m_pTree != NULL)
+		DeleteTree(&m_pTree);
 }
 
 /////////////////////////////////////////////////////////////////////////////
-BOOL CQuantizer::ProcessImage (HANDLE hImage)
+BOOL CQuantizer::ProcessImage(HANDLE hImage)
 {
-	BYTE r,	g, b;
+	BYTE r, g, b;
 	int	i, j;
 
 	BITMAPINFOHEADER ds;
-	memcpy(&ds,hImage, sizeof(ds));
-	int effwdt = ((((ds.biBitCount * ds.biWidth ) + 31) / 32) * 4);
+	memcpy(&ds, hImage, sizeof(ds));
+	int effwdt = ((((ds.biBitCount * ds.biWidth) + 31) / 32) * 4);
 
-	int	nPad = effwdt - (((ds.biWidth *	ds.biBitCount) + 7) / 8);
+	int	nPad = effwdt - (((ds.biWidth * ds.biBitCount) + 7) / 8);
 
 	BYTE* pbBits = (BYTE*)hImage + *(LPDWORD)hImage;
 
@@ -40,72 +40,72 @@ BOOL CQuantizer::ProcessImage (HANDLE hImage)
 	case 1:	// 1-bit DIB
 	case 4:	// 4-bit DIB
 	case 8:	// 8-bit DIB
-		for	(i=0; i<ds.biHeight;	i++) {
-			for	(j=0; j<ds.biWidth; j++)	{
-				BYTE idx=GetPixelIndex(j,i,ds.biBitCount,effwdt,pbBits);
-				BYTE* pal = (BYTE*)(hImage) + sizeof(BITMAPINFOHEADER);
-				long ldx = idx*sizeof(RGBQUAD);
+		for (i = 0; i < ds.biHeight; i++) {
+			for (j = 0; j < ds.biWidth; j++) {
+				BYTE idx = GetPixelIndex(j, i, ds.biBitCount, effwdt, pbBits);
+				BYTE* pal = (BYTE*)(hImage)+sizeof(BITMAPINFOHEADER);
+				long ldx = idx * sizeof(RGBQUAD);
 				b = pal[ldx++];
 				g = pal[ldx++];
 				r = pal[ldx];
-				AddColor (&m_pTree,	r, g, b, m_nColorBits, 0, &m_nLeafCount,
+				AddColor(&m_pTree, r, g, b, m_nColorBits, 0, &m_nLeafCount,
 					m_pReducibleNodes);
-				while (m_nLeafCount	> m_nMaxColors)
-					ReduceTree (m_nColorBits, &m_nLeafCount,
+				while (m_nLeafCount > m_nMaxColors)
+					ReduceTree(m_nColorBits, &m_nLeafCount,
 						m_pReducibleNodes);
 			}
 		}
 		break;
 	case 15:
 	case 16://16bit
-		for	(i=0; i<ds.biHeight;	i++) 
+		for (i = 0; i < ds.biHeight; i++)
 		{
-			for	(j=0; j<ds.biWidth; j++)
+			for (j = 0; j < ds.biWidth; j++)
 			{
-				b = (*pbBits)&0x1F;
-				g = (*pbBits++)>>5;
-				g |= ((*pbBits)&0x03)<<3;
-				r = ((*pbBits++)>>2)&0x1F;
+				b = (*pbBits) & 0x1F;
+				g = (*pbBits++) >> 5;
+				g |= ((*pbBits) & 0x03) << 3;
+				r = ((*pbBits++) >> 2) & 0x1F;
 
 				r *= 8;
 				b *= 8;
 				g *= 8;
-			
-				AddColor (&m_pTree,	r, g, b, m_nColorBits, 0, &m_nLeafCount,
+
+				AddColor(&m_pTree, r, g, b, m_nColorBits, 0, &m_nLeafCount,
 					m_pReducibleNodes);
-				while (m_nLeafCount	> m_nMaxColors)
-					ReduceTree (m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
+				while (m_nLeafCount > m_nMaxColors)
+					ReduceTree(m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
 			}
 
 			pbBits += nPad;
 		}
 		break;
 	case 24: //	24-bit DIB
-		for	(i=0; i<ds.biHeight;	i++) {
-			for	(j=0; j<ds.biWidth; j++)	{
-				b =	*pbBits++;
-				g =	*pbBits++;
-				r =	*pbBits++;
-				AddColor (&m_pTree,	r, g, b, m_nColorBits, 0, &m_nLeafCount,
+		for (i = 0; i < ds.biHeight; i++) {
+			for (j = 0; j < ds.biWidth; j++) {
+				b = *pbBits++;
+				g = *pbBits++;
+				r = *pbBits++;
+				AddColor(&m_pTree, r, g, b, m_nColorBits, 0, &m_nLeafCount,
 					m_pReducibleNodes);
-				while (m_nLeafCount	> m_nMaxColors)
-					ReduceTree (m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
+				while (m_nLeafCount > m_nMaxColors)
+					ReduceTree(m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
 			}
 			pbBits += nPad;
 		}
 		break;
 	case 32: //	32-bit DIB
-		for	(i=0; i<ds.biHeight;	i++) {
-			for	(j=0; j<ds.biWidth; j++)	{
-				b =	*pbBits++;
-				g =	*pbBits++;
-				r =	*pbBits++;
+		for (i = 0; i < ds.biHeight; i++) {
+			for (j = 0; j < ds.biWidth; j++) {
+				b = *pbBits++;
+				g = *pbBits++;
+				r = *pbBits++;
 				pbBits++;
 
-				AddColor (&m_pTree,	r, g, b, m_nColorBits, 0, &m_nLeafCount,
+				AddColor(&m_pTree, r, g, b, m_nColorBits, 0, &m_nLeafCount,
 					m_pReducibleNodes);
-				while (m_nLeafCount	> m_nMaxColors)
-					ReduceTree (m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
+				while (m_nLeafCount > m_nMaxColors)
+					ReduceTree(m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
 			}
 			pbBits += nPad;
 		}
@@ -117,221 +117,225 @@ BOOL CQuantizer::ProcessImage (HANDLE hImage)
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void CQuantizer::AddColor (NODE** ppNode, BYTE r, BYTE g, BYTE b,
-	UINT nColorBits, UINT nLevel, UINT*	pLeafCount,	NODE** pReducibleNodes)
+void CQuantizer::AddColor(NODE** ppNode, BYTE r, BYTE g, BYTE b,
+	UINT nColorBits, UINT nLevel, UINT* pLeafCount, NODE** pReducibleNodes)
 {
-	static BYTE	mask[8]	= {	0x80, 0x40,	0x20, 0x10,	0x08, 0x04,	0x02, 0x01 };
+	static BYTE	mask[8] = { 0x80, 0x40,	0x20, 0x10,	0x08, 0x04,	0x02, 0x01 };
 
 	// If the node doesn't exist, create it.
-	if (*ppNode	== NULL)
-		*ppNode	= (NODE*)CreateNode (nLevel, nColorBits, pLeafCount, pReducibleNodes);
+	if (*ppNode == NULL)
+		*ppNode = (NODE*)CreateNode(nLevel, nColorBits, pLeafCount, pReducibleNodes);
 
 	// Update color	information	if it's	a leaf node.
-	if ((*ppNode)->bIsLeaf)	
+	if ((*ppNode)->bIsLeaf)
 	{
 		(*ppNode)->nPixelCount++;
 		(*ppNode)->nRedSum += r;
-		(*ppNode)->nGreenSum +=	g;
-		(*ppNode)->nBlueSum	+= b;
-	} else 
+		(*ppNode)->nGreenSum += g;
+		(*ppNode)->nBlueSum += b;
+	}
+	else
 	{	// Recurse a level deeper if the node is not a leaf.
-		int	shift =	7 -	nLevel;
-		int	nIndex =(((r & mask[nLevel]) >> shift) << 2) |
-					(((g & mask[nLevel]) >>	shift) << 1) |
-					(( b & mask[nLevel]) >> shift);
-		AddColor(&((*ppNode)->pChild[nIndex]),	r, g, b, nColorBits,
-					nLevel + 1,	pLeafCount,	pReducibleNodes);
+		int	shift = 7 - nLevel;
+		int	nIndex = (((r & mask[nLevel]) >> shift) << 2) |
+			(((g & mask[nLevel]) >> shift) << 1) |
+			((b & mask[nLevel]) >> shift);
+		AddColor(&((*ppNode)->pChild[nIndex]), r, g, b, nColorBits,
+			nLevel + 1, pLeafCount, pReducibleNodes);
 	}
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void* CQuantizer::CreateNode (UINT nLevel, UINT	nColorBits,	UINT* pLeafCount,
+void* CQuantizer::CreateNode(UINT nLevel, UINT	nColorBits, UINT* pLeafCount,
 	NODE** pReducibleNodes)
 {
-	NODE* pNode = (NODE*)calloc(1,sizeof(NODE));
+	NODE* pNode = (NODE*)calloc(1, sizeof(NODE));
 
-	if (pNode== NULL) return NULL;
+	if (pNode == NULL) return NULL;
 
-	pNode->bIsLeaf = (nLevel ==	nColorBits)	? TRUE : FALSE;
+	pNode->bIsLeaf = (nLevel == nColorBits) ? TRUE : FALSE;
 	if (pNode->bIsLeaf) (*pLeafCount)++;
 	else {
 		pNode->pNext = pReducibleNodes[nLevel];
-		pReducibleNodes[nLevel]	= pNode;
+		pReducibleNodes[nLevel] = pNode;
 	}
 	return pNode;
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void CQuantizer::ReduceTree	(UINT nColorBits, UINT*	pLeafCount,
+void CQuantizer::ReduceTree(UINT nColorBits, UINT* pLeafCount,
 	NODE** pReducibleNodes)
 {
 	int i;
 	// Find	the	deepest	level containing at	least one reducible	node.
-	for	(i=nColorBits -	1; (i>0) &&	(pReducibleNodes[i]	== NULL); i--);
+	for (i = nColorBits - 1; (i > 0) && (pReducibleNodes[i] == NULL); i--);
 
 	// Reduce the node most	recently added to the list at level	i.
-	NODE* pNode	= pReducibleNodes[i];
+	NODE* pNode = pReducibleNodes[i];
 	pReducibleNodes[i] = pNode->pNext;
 
 	NODE* pNodeTmp = pNode;
-	NODE* pNeedReduceNode = NULL,*pPreNode = NULL,*pPreNodeTmp = NULL;
+	NODE* pNeedReduceNode = NULL, * pPreNode = NULL, * pPreNodeTmp = NULL;
 	long nMinPixelCount = 0;
 
-	while(pNodeTmp)
-		{
+	while (pNodeTmp)
+	{
 		long nPixelCount = 0;
-		for	(int m=0; m<8; m++)	
+		for (int m = 0; m < 8; m++)
+		{
+			if (pNodeTmp->pChild[m] != NULL)
 			{
-			if (pNodeTmp->pChild[m] !=	NULL) 
-				{
 				nPixelCount += pNodeTmp->pChild[m]->nPixelCount;
-				}
 			}
+		}
 
-		if(nMinPixelCount == 0)
-			{
+		if (nMinPixelCount == 0)
+		{
 			nMinPixelCount = nPixelCount;
 			pNeedReduceNode = pNodeTmp;
-			}
-		else if(nPixelCount < nMinPixelCount)
-			{
+		}
+		else if (nPixelCount < nMinPixelCount)
+		{
 			nMinPixelCount = nPixelCount;
 			pNeedReduceNode = pNodeTmp;
 			pPreNode = pPreNodeTmp;
-			}
+		}
 
 		pPreNodeTmp = pNodeTmp;
 		pNodeTmp = pNodeTmp->pNext;
-		}
+	}
 
-	if(pPreNode)
-		{
+	if (pPreNode)
+	{
 		pPreNode->pNext = pNeedReduceNode->pNext;
 		pReducibleNodes[i] = pNode;
-		}
+	}
 
 	pNode = pNeedReduceNode;
 
 	UINT nRedSum = 0;
 	UINT nGreenSum = 0;
-	UINT nBlueSum =	0;
+	UINT nBlueSum = 0;
 	UINT nChildren = 0;
 
-	for	(i=0; i<8; i++)	
+	for (i = 0; i < 8; i++)
+	{
+		if (pNode->pChild[i] != NULL)
 		{
-		if (pNode->pChild[i] !=	NULL) 
-			{
-			nRedSum	+= pNode->pChild[i]->nRedSum;
+			nRedSum += pNode->pChild[i]->nRedSum;
 			nGreenSum += pNode->pChild[i]->nGreenSum;
-			nBlueSum +=	pNode->pChild[i]->nBlueSum;
+			nBlueSum += pNode->pChild[i]->nBlueSum;
 			pNode->nPixelCount += pNode->pChild[i]->nPixelCount;
 			free(pNode->pChild[i]);
 			pNode->pChild[i] = NULL;
 			nChildren++;
-			}
 		}
+	}
 
 	pNode->bIsLeaf = TRUE;
 	pNode->nRedSum = nRedSum;
 	pNode->nGreenSum = nGreenSum;
-	pNode->nBlueSum	= nBlueSum;
-	*pLeafCount	-= (nChildren -	1);
+	pNode->nBlueSum = nBlueSum;
+	*pLeafCount -= (nChildren - 1);
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void CQuantizer::DeleteTree	(NODE**	ppNode)
+void CQuantizer::DeleteTree(NODE** ppNode)
 {
-	for	(int i=0; i<8; i++)	{
-		if ((*ppNode)->pChild[i] !=	NULL) DeleteTree (&((*ppNode)->pChild[i]));
+	for (int i = 0; i < 8; i++) {
+		if ((*ppNode)->pChild[i] != NULL) DeleteTree(&((*ppNode)->pChild[i]));
 	}
 	free(*ppNode);
-	*ppNode	= NULL;
+	*ppNode = NULL;
 }
 
 
-BOOL CQuantizer::FindColorIndex(NODE *pNode,BYTE r,BYTE g,BYTE b,int nLevel,UINT *pColorIndex)
+BOOL CQuantizer::FindColorIndex(NODE* pNode, BYTE r, BYTE g, BYTE b, int nLevel, UINT* pColorIndex)
 {
-	static BYTE	mask[8]	= {	0x80, 0x40,	0x20, 0x10,	0x08, 0x04,	0x02, 0x01 };
+	static BYTE	mask[8] = { 0x80, 0x40,	0x20, 0x10,	0x08, 0x04,	0x02, 0x01 };
 
 	// If the node doesn't exist, create it.
 	if (pNode == NULL)
-	{	
+	{
 		return FALSE;
 	}
 
 	// Update color	information	if it's	a leaf node.
-	if (pNode->bIsLeaf)	
+	if (pNode->bIsLeaf)
 	{
 		*pColorIndex = pNode->nColorIndex;
 		return TRUE;
 	}
-	
+
 	// Recurse a level deeper if the node is not a leaf.
-	int	shift =	7 -	nLevel;
-	int	nIndex =(((r & mask[nLevel]) >> shift) << 2) |
-				(((g & mask[nLevel]) >>	shift) << 1) |
-				(( b & mask[nLevel]) >> shift);
+	int	shift = 7 - nLevel;
+	int	nIndex = (((r & mask[nLevel]) >> shift) << 2) |
+		(((g & mask[nLevel]) >> shift) << 1) |
+		((b & mask[nLevel]) >> shift);
 
-	return FindColorIndex(pNode->pChild[nIndex], r, g, b, nLevel+1, pColorIndex);
+	return FindColorIndex(pNode->pChild[nIndex], r, g, b, nLevel + 1, pColorIndex);
 }
 
-BOOL CQuantizer::GetColorIndex(BYTE r,BYTE g,BYTE b,UINT *pColorIndex)
+BOOL CQuantizer::GetColorIndex(BYTE r, BYTE g, BYTE b, UINT* pColorIndex)
 {
-	return FindColorIndex(m_pTree,r,g,b,0,pColorIndex);
+	return FindColorIndex(m_pTree, r, g, b, 0, pColorIndex);
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void CQuantizer::GetPaletteColors (NODE* pTree,	RGBQUAD* prgb, UINT* pIndex)
+void CQuantizer::GetPaletteColors(NODE* pTree, RGBQUAD* prgb, UINT* pIndex)
 {
-	if (pTree){
-		if (pTree->bIsLeaf)	{
-			prgb[*pIndex].rgbRed = (BYTE)((pTree->nRedSum)/(pTree->nPixelCount));
-			prgb[*pIndex].rgbGreen = (BYTE)((pTree->nGreenSum)/(pTree->nPixelCount));
-			prgb[*pIndex].rgbBlue = (BYTE)((pTree->nBlueSum)/(pTree->nPixelCount));
-			prgb[*pIndex].rgbReserved =	0;
+	if (pTree) {
+		if (pTree->bIsLeaf) {
+			prgb[*pIndex].rgbRed = (BYTE)((pTree->nRedSum) / (pTree->nPixelCount));
+			prgb[*pIndex].rgbGreen = (BYTE)((pTree->nGreenSum) / (pTree->nPixelCount));
+			prgb[*pIndex].rgbBlue = (BYTE)((pTree->nBlueSum) / (pTree->nPixelCount));
+			prgb[*pIndex].rgbReserved = 0;
 			pTree->nColorIndex = *pIndex;
 			(*pIndex)++;
-		} else {
-			for	(int i=0; i<8; i++)	{
-				if (pTree->pChild[i] !=	NULL)
-					GetPaletteColors (pTree->pChild[i],	prgb, pIndex);
+		}
+		else {
+			for (int i = 0; i < 8; i++) {
+				if (pTree->pChild[i] != NULL)
+					GetPaletteColors(pTree->pChild[i], prgb, pIndex);
 			}
 		}
 	}
 }
 
 /////////////////////////////////////////////////////////////////////////////
-UINT CQuantizer::GetColorCount ()
+UINT CQuantizer::GetColorCount()
 {
 	return m_nLeafCount;
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void CQuantizer::SetColorTable (RGBQUAD* prgb)
+void CQuantizer::SetColorTable(RGBQUAD* prgb)
 {
-	UINT nIndex	= 0;
-	GetPaletteColors (m_pTree, prgb, &nIndex);
+	UINT nIndex = 0;
+	GetPaletteColors(m_pTree, prgb, &nIndex);
 }
 
 /////////////////////////////////////////////////////////////////////////////
-BYTE CQuantizer::GetPixelIndex(long x, long y, int nbit, long effwdt, BYTE *pimage)
+BYTE CQuantizer::GetPixelIndex(long x, long y, int nbit, long effwdt, BYTE* pimage)
 {
-	if (nbit==8)
+	if (nbit == 8)
 	{
-		return pimage[y*effwdt + x];
-	} else 
+		return pimage[y * effwdt + x];
+	}
+	else
 	{
 		BYTE pos;
-		BYTE iDst= pimage[y*effwdt + (x*nbit >> 3)];
-		if (nbit==4)
+		BYTE iDst = pimage[y * effwdt + (x * nbit >> 3)];
+		if (nbit == 4)
 		{
-			pos = 4*(1-x%2);
-			iDst &= (0x0F<<pos);
+			pos = 4 * (1 - x % 2);
+			iDst &= (0x0F << pos);
 			return iDst >> pos;
-		} else if (nbit==1)
+		}
+		else if (nbit == 1)
 		{
-			pos = 7-x%8;
-			iDst &= (0x01<<pos);
+			pos = 7 - x % 8;
+			iDst &= (0x01 << pos);
 			return iDst >> pos;
 		}
 	}
@@ -339,25 +343,25 @@ BYTE CQuantizer::GetPixelIndex(long x, long y, int nbit, long effwdt, BYTE *pima
 }
 
 CRGBQuantizer::CRGBQuantizer(UINT nMaxColors, UINT nColorBits)
-:CQuantizer(nMaxColors,nColorBits)
+	:CQuantizer(nMaxColors, nColorBits)
 {
 }
 
-BOOL CRGBQuantizer::ProcessImageRGB(BYTE *pRGBData,UINT nWidth,UINT nHeight)
+BOOL CRGBQuantizer::ProcessImageRGB(BYTE* pRGBData, UINT nWidth, UINT nHeight)
 {
-	BYTE r,g,b;
+	BYTE r, g, b;
 
-	for	(int i=0; i<nHeight;	i++) 
+	for (int i = 0; i < nHeight; i++)
 	{
-		for	(int j=0; j<nWidth; j++)	
+		for (int j = 0; j < nWidth; j++)
 		{
-			r =	*pRGBData++;
-			g =	*pRGBData++;
-			b =	*pRGBData++;
-			AddColor (&m_pTree,	r, g, b, m_nColorBits, 0, &m_nLeafCount,
+			r = *pRGBData++;
+			g = *pRGBData++;
+			b = *pRGBData++;
+			AddColor(&m_pTree, r, g, b, m_nColorBits, 0, &m_nLeafCount,
 				m_pReducibleNodes);
-			while (m_nLeafCount	> m_nMaxColors)
-				ReduceTree (m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
+			while (m_nLeafCount > m_nMaxColors)
+				ReduceTree(m_nColorBits, &m_nLeafCount, m_pReducibleNodes);
 		}
 	}
 
@@ -365,31 +369,31 @@ BOOL CRGBQuantizer::ProcessImageRGB(BYTE *pRGBData,UINT nWidth,UINT nHeight)
 }
 
 CBitmapQuantizer::CBitmapQuantizer(UINT nMaxColors, UINT nColorBits)
-:CQuantizer(nMaxColors,nColorBits)
+	:CQuantizer(nMaxColors, nColorBits)
 {
 }
 
-BOOL CBitmapQuantizer::ProcessImageBitmap (HBITMAP hBmp)
+BOOL CBitmapQuantizer::ProcessImageBitmap(HBITMAP hBmp)
 {
 	BITMAP bm;
 	PBITMAPINFO bmpInf;
 
-	if(GetObject(hBmp,sizeof(bm),&bm)==0)
+	if (GetObject(hBmp, sizeof(bm), &bm) == 0)
 		return FALSE;
 
-	int nPaletteSize=0;
+	int nPaletteSize = 0;
+
+	if (bm.bmBitsPixel < 16)
+		nPaletteSize = (int)pow(2.0, bm.bmBitsPixel);
 
-	if(bm.bmBitsPixel<16)
-		nPaletteSize=(int)pow(2.0,bm.bmBitsPixel);
+	bmpInf = (PBITMAPINFO)LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER) +
+		sizeof(RGBQUAD) * nPaletteSize +
+		(bm.bmWidth + 7) / 8 * bm.bmHeight * bm.bmBitsPixel);
 
-	bmpInf=(PBITMAPINFO)LocalAlloc(LPTR,sizeof(BITMAPINFOHEADER)+
-		sizeof(RGBQUAD)*nPaletteSize+
-		(bm.bmWidth+7)/8*bm.bmHeight*bm.bmBitsPixel);
+	BYTE* buf = ((BYTE*)bmpInf) +
+		sizeof(BITMAPINFOHEADER) +
+		sizeof(RGBQUAD) * nPaletteSize;
 
-	BYTE* buf = ((BYTE*)bmpInf)+
-		sizeof(BITMAPINFOHEADER)+
-		sizeof(RGBQUAD)*nPaletteSize;
-	
 	//-----------------------------------------------
 	bmpInf->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 	bmpInf->bmiHeader.biWidth = bm.bmWidth;
@@ -397,7 +401,7 @@ BOOL CBitmapQuantizer::ProcessImageBitmap (HBITMAP hBmp)
 	bmpInf->bmiHeader.biPlanes = bm.bmPlanes;
 	bmpInf->bmiHeader.biBitCount = bm.bmBitsPixel;
 	bmpInf->bmiHeader.biCompression = BI_RGB;
-	bmpInf->bmiHeader.biSizeImage = (bm.bmWidth+7)/8*bm.bmHeight*bm.bmBitsPixel;
+	bmpInf->bmiHeader.biSizeImage = (bm.bmWidth + 7) / 8 * bm.bmHeight * bm.bmBitsPixel;
 	bmpInf->bmiHeader.biXPelsPerMeter = 0;
 	bmpInf->bmiHeader.biYPelsPerMeter = 0;
 	bmpInf->bmiHeader.biClrUsed = 0;
@@ -406,16 +410,16 @@ BOOL CBitmapQuantizer::ProcessImageBitmap (HBITMAP hBmp)
 
 	HDC hDC = ::GetWindowDC(NULL);
 
-	if(!::GetDIBits(hDC,hBmp,0,(UINT)bm.bmHeight,buf,bmpInf,DIB_RGB_COLORS))
+	if (!::GetDIBits(hDC, hBmp, 0, (UINT)bm.bmHeight, buf, bmpInf, DIB_RGB_COLORS))
 	{
-		::ReleaseDC(NULL,hDC);
+		::ReleaseDC(NULL, hDC);
 		LocalFree(bmpInf);
 		return FALSE;
 	}
 
-	::ReleaseDC(NULL,hDC);
+	::ReleaseDC(NULL, hDC);
 
-	bmpInf->bmiHeader.biSize = sizeof(BITMAPINFOHEADER)+sizeof(RGBQUAD)*nPaletteSize;
+	bmpInf->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * nPaletteSize;
 	BOOL bRet = ProcessImage(bmpInf);
 
 	LocalFree(bmpInf);

+ 27 - 27
天使插件源码/TSPlug/CreateGif/Quantizer.h

@@ -9,8 +9,8 @@ struct NODE
 	long nGreenSum;
 	long nBlueSum;
 	UINT nColorIndex;
-	NODE *pChild[8];
-	NODE *pNext;
+	NODE* pChild[8];
+	NODE* pNext;
 };
 
 class CQuantizer
@@ -18,53 +18,53 @@ class CQuantizer
 public:
 	CQuantizer(UINT nMaxColors, UINT nColorBits);
 	~CQuantizer();
-	
-	BOOL ProcessImage (HANDLE hImage);
-	
-	UINT GetColorCount ();
 
-	void SetColorTable (RGBQUAD* prgb);
+	BOOL ProcessImage(HANDLE hImage);
 
-	BOOL GetColorIndex(BYTE r,BYTE g,BYTE b,UINT *pColorIndex);
+	UINT GetColorCount();
+
+	void SetColorTable(RGBQUAD* prgb);
+
+	BOOL GetColorIndex(BYTE r, BYTE g, BYTE b, UINT* pColorIndex);
 
 protected:
-	
-	void AddColor (NODE** ppNode, BYTE r, BYTE g, BYTE b,
-		UINT nColorBits, UINT nLevel, UINT*	pLeafCount,	NODE** pReducibleNodes);
-	
-	void* CreateNode (UINT nLevel, UINT	nColorBits,	UINT* pLeafCount,
-			NODE** pReducibleNodes);
-	
-	void ReduceTree	(UINT nColorBits, UINT*	pLeafCount,
-			NODE** pReducibleNodes);
 
-	void DeleteTree	(NODE**	ppNode);
+	void AddColor(NODE** ppNode, BYTE r, BYTE g, BYTE b,
+		UINT nColorBits, UINT nLevel, UINT* pLeafCount, NODE** pReducibleNodes);
+
+	void* CreateNode(UINT nLevel, UINT	nColorBits, UINT* pLeafCount,
+		NODE** pReducibleNodes);
+
+	void ReduceTree(UINT nColorBits, UINT* pLeafCount,
+		NODE** pReducibleNodes);
+
+	void DeleteTree(NODE** ppNode);
 
-	void GetPaletteColors (NODE* pTree,	RGBQUAD* prgb, UINT* pIndex);
+	void GetPaletteColors(NODE* pTree, RGBQUAD* prgb, UINT* pIndex);
 
-	BOOL FindColorIndex(NODE *pNode,BYTE r,BYTE g,BYTE b,int nLevel,UINT *pColorIndex);
+	BOOL FindColorIndex(NODE* pNode, BYTE r, BYTE g, BYTE b, int nLevel, UINT* pColorIndex);
 
-	BYTE GetPixelIndex(long x, long y, int nbit, long effwdt, BYTE *pimage);
+	BYTE GetPixelIndex(long x, long y, int nbit, long effwdt, BYTE* pimage);
 
 	int m_nColorBits;
 	UINT m_nLeafCount;
 	int m_nMaxColors;
-	NODE *m_pTree;
-	NODE *m_pReducibleNodes[9];
+	NODE* m_pTree;
+	NODE* m_pReducibleNodes[9];
 };
 
-class CRGBQuantizer: public CQuantizer
+class CRGBQuantizer : public CQuantizer
 {
 public:
 	CRGBQuantizer(UINT nMaxColors, UINT nColorBits);
-	BOOL ProcessImageRGB (BYTE *pRGBData,UINT nWidth,UINT nHeight);
+	BOOL ProcessImageRGB(BYTE* pRGBData, UINT nWidth, UINT nHeight);
 };
 
-class CBitmapQuantizer: public CQuantizer
+class CBitmapQuantizer : public CQuantizer
 {
 public:
 	CBitmapQuantizer(UINT nMaxColors, UINT nColorBits);
-	BOOL ProcessImageBitmap (HBITMAP hBmp);
+	BOOL ProcessImageBitmap(HBITMAP hBmp);
 };
 
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 357 - 357
天使插件源码/TSPlug/DXBind.cpp


+ 34 - 34
天使插件源码/TSPlug/DXBind.h

@@ -1,7 +1,7 @@
 #pragma once
 #include "TSMessage.h"
 #include "TSFindPicture.h"
-typedef bool (__stdcall  *  MySetWindowHook)(BOOL,DWORD); 
+typedef bool(__stdcall* MySetWindowHook)(BOOL, DWORD);
 
 //TSMOUSE_MODE 鼠标模式
 #define MOUSE_NORMAL    0x00000001L
@@ -66,10 +66,10 @@ enum BIND_MODE
 	BIND_WINHOOK,
 	BIND_IME,
 	BIND_IME101 = 101,
-	BIND_103	=103,
-	BIND_201	=201,
-	BIND_203	=203,
-    BIND_MAX,
+	BIND_103 = 103,
+	BIND_201 = 201,
+	BIND_203 = 203,
+	BIND_MAX,
 };
 ////绑定的显示模式
 //enum DISPLAY_MODE
@@ -82,20 +82,20 @@ enum BIND_MODE
 class DXBind
 {
 public:
-    //////////////////////////////////这里是本地使用的API接口////////////////////////////////////
+	//////////////////////////////////这里是本地使用的API接口////////////////////////////////////
 	//MyFindPictureClass  fpic;
 
 	//绑定操作
-	bool bind(HWND wnd,DWORD keyMod,DWORD mouseMod,DWORD disMod,BIND_MODE bindMode);
+	bool bind(HWND wnd, DWORD keyMod, DWORD mouseMod, DWORD disMod, BIND_MODE bindMode);
 
 	bool UnBind();
 
-	 //发送消息
-     LRESULT SendMsg(UINT Msg, WPARAM wParam=0, LPARAM lParam=0) {
-         return ::SendMessage(m_mousekeyhwnd, Msg, wParam, lParam);
-     }
+	//发送消息
+	LRESULT SendMsg(UINT Msg, WPARAM wParam = 0, LPARAM lParam = 0) {
+		return ::SendMessage(m_mousekeyhwnd, Msg, wParam, lParam);
+	}
 
-	 bool SetWindowHookExInject(HWND wnd);
+	bool SetWindowHookExInject(HWND wnd);
 
 	//输入法注入
 	bool IMEInject(HWND wnd);
@@ -104,34 +104,34 @@ public:
 	bool Inject201();
 
 	//
-	int findPic(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_name,  wchar_t *color, DOUBLE sim, LONG dir, LONG &intX, LONG &intY,wchar_t *retstring=NULL,int type=0);
+	int findPic(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_name, wchar_t* color, DOUBLE sim, LONG dir, LONG& intX, LONG& intY, wchar_t* retstring = NULL, int type = 0);
 
 	//
-	int findColor(LONG x1, LONG y1, LONG x2, LONG y2, int color, DOUBLE sim, LONG dir, LONG &intX, LONG &intY,wchar_t *colorstr=NULL,wchar_t *retstring=NULL,wchar_t *MultiColor=NULL);
+	int findColor(LONG x1, LONG y1, LONG x2, LONG y2, int color, DOUBLE sim, LONG dir, LONG& intX, LONG& intY, wchar_t* colorstr = NULL, wchar_t* retstring = NULL, wchar_t* MultiColor = NULL);
 
-	int GetColor(LONG x,LONG y,BSTR sColor);
+	int GetColor(LONG x, LONG y, BSTR sColor);
 
-	bool CmpColor(LONG x,LONG y,BSTR sColor,DOUBLE sim);
+	bool CmpColor(LONG x, LONG y, BSTR sColor, DOUBLE sim);
 
-	bool TSSetpath(wchar_t *path);
+	bool TSSetpath(wchar_t* path);
 	//
 	void setIsBind(bool isbind);
 
-	int Capture(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_path,int pictype);
+	int Capture(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_path, int pictype);
 
-	int CaptureGif(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_path,int delay,int time);
+	int CaptureGif(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* pic_path, int delay, int time);
 
-	bool TSSetDict(int index,wchar_t *filepath);
+	bool TSSetDict(int index, wchar_t* filepath);
 
 	bool TSUseDict(int index);
 
-	int Ocr(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t *color, DOUBLE sim,int type=0);
+	int Ocr(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* color, DOUBLE sim, int type = 0);
 
 	//Findstrtype=0,Findstr=Findstr;Findstrtype=1,Findstr=FindstrFast;
-	int Findstr(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* findstring, wchar_t *color, DOUBLE sim, LONG &intX, LONG &intY,BYTE Findstrtype,wchar_t *retstring=NULL,int type=0);
+	int Findstr(LONG x1, LONG y1, LONG x2, LONG y2, wchar_t* findstring, wchar_t* color, DOUBLE sim, LONG& intX, LONG& intY, BYTE Findstrtype, wchar_t* retstring = NULL, int type = 0);
 
-	 //判断是否卡屏
-	int IsDisplayDead(LONG x1, LONG y1, LONG x2, LONG y2,int times);
+	//判断是否卡屏
+	int IsDisplayDead(LONG x1, LONG y1, LONG x2, LONG y2, int times);
 
 	bool TSGetScreenData(LONG x1, LONG y1, LONG x2, LONG y2);
 	//
@@ -142,7 +142,7 @@ public:
 
 	bool DownCpu(DWORD sleeptime);
 
-	bool TSMatchPicName(wchar_t *pic_name,wchar_t*ret_name);
+	bool TSMatchPicName(wchar_t* pic_name, wchar_t* ret_name);
 
 	bool TSGetMachineCode(wchar_t* retcode);
 
@@ -150,17 +150,17 @@ public:
 
 	void InitGdiNormal();
 
-	bool TSEnableRealMouse(LONG X,LONG Y);
+	bool TSEnableRealMouse(LONG X, LONG Y);
 
 	DWORD TSRealKeyMousSleepTime(DWORD type);
 
-	void TSMoveToEx(ULONG x,ULONG y,ULONG w,ULONG h,wchar_t *retstring);
+	void TSMoveToEx(ULONG x, ULONG y, ULONG w, ULONG h, wchar_t* retstring);
 
 public:
 	DWORD ColorDataInfo[2000][2000];
 	COLORREF** pWndBmpBuffer;
-	short **pWndBmpStrxy;
-	BYTE * pBuffer;
+	short** pWndBmpStrxy;
+	BYTE* pBuffer;
 	DWORD winver;
 	DWORD nPid;
 	DWORD KeyDownsleep;//键盘单击延时
@@ -173,9 +173,9 @@ public:
 	HWND m_parenthwnd;		//父窗口句柄
 	HANDLE m_eventMsg;
 	int BindMode;
-	MySetWindowHook mSetHook; 
+	MySetWindowHook mSetHook;
 	wchar_t m_SetPath[MAX_PATH];
-	wchar_t m_Retstr[MAX_PATH*100];
+	wchar_t m_Retstr[MAX_PATH * 100];
 	short LastMouseMoveX;
 	short LastMouseMoveY;
 	bool m_isBind;
@@ -185,7 +185,7 @@ public:
 	DWORD m_dwExStyle;
 	bool g_IsSYSKEY;
 	bool IsNpProtect;
-	CMessageData *pData;
+	CMessageData* pData;
 	bool Isdxkmprotect;  //dx键鼠不被恶意检测盾
 	bool Isdxantiapi;//开启dx.public.anti.api保护
 	pMyDictInfo MyDictCount[20]; //存储当前所有字库,默认最大字库个数为20个
@@ -201,7 +201,7 @@ public:
 	LONG mousestep;
 	DWORD GDI_dwExStyle;
 private:
-	
+
 	int CallCodelen;
 	LPVOID Alloaddr;//201注入的申请到的内存地址
 	HKL  MSetUpIME;
@@ -210,7 +210,7 @@ private:
 	BYTE       m_colorOffR[MAX_PATH]; // R的偏移量
 	BYTE       m_colorOffG[MAX_PATH]; // G的偏移量
 	BYTE       m_colorOffB[MAX_PATH]; // B的偏移量
-	
+
 public:
 	DXBind(void);
 	~DXBind(void);

+ 43 - 43
天使插件源码/TSPlug/KeyMouse/MyKeyboardNamespace.cpp

@@ -14,7 +14,7 @@
 ====================================================================*/
 MyKeyboardNamespace::MyKeyboardNamespace(void)
 {
-	delaytime=40;
+	delaytime = 40;
 }
 
 
@@ -40,16 +40,16 @@ ret        _variant_t *      
 
 修改历史 :
 修改者   日期           描述
-邓媛元   2010-07-18  
-邓媛元   2010-07-20     检测    
+邓媛元   2010-07-18
+邓媛元   2010-07-20     检测
 ====================================================================*/
 bool MyKeyboardNamespace::keyPress(DWORD keycode)
 {
-	unsigned char bkeydown=keycode;
-    keybd_event(bkeydown,MapVirtualKey(bkeydown,0),0, 0);
-    ::Sleep(delaytime);
+	unsigned char bkeydown = keycode;
+	keybd_event(bkeydown, MapVirtualKey(bkeydown, 0), 0, 0);
+	::Sleep(delaytime);
 	//2011-11-02 修改按键延时,有人反应按键太慢
-    keybd_event(bkeydown,MapVirtualKey(bkeydown,0),KEYEVENTF_KEYUP, 0);
+	keybd_event(bkeydown, MapVirtualKey(bkeydown, 0), KEYEVENTF_KEYUP, 0);
 	//*ret = true;
 	return true;
 }
@@ -69,13 +69,13 @@ ret        _variant_t *      
 
 修改历史 :
 修改者   日期           描述
-邓媛元   2010-07-18      
-邓媛元   2010-07-20     检测 
+邓媛元   2010-07-18
+邓媛元   2010-07-20     检测
 ====================================================================*/
 bool  MyKeyboardNamespace::keyDown(DWORD keycode)
-{	
-	unsigned char bkeydown=keycode;	
-	keybd_event(bkeydown, MapVirtualKey(bkeydown,0), 0, 0);
+{
+	unsigned char bkeydown = keycode;
+	keybd_event(bkeydown, MapVirtualKey(bkeydown, 0), 0, 0);
 	return true;
 }
 
@@ -94,13 +94,13 @@ ret        _variant_t *      
 
 修改历史 :
 修改者   日期           描述
-邓媛元   2010-07-18      
-邓媛元   2010-07-20     检测 
+邓媛元   2010-07-18
+邓媛元   2010-07-20     检测
 ====================================================================*/
 bool  MyKeyboardNamespace::keyUp(DWORD keycode)
 {
-	unsigned char bkeydown=keycode;
-	keybd_event(bkeydown, MapVirtualKey(bkeydown,0), KEYEVENTF_KEYUP, 0);//放开键 
+	unsigned char bkeydown = keycode;
+	keybd_event(bkeydown, MapVirtualKey(bkeydown, 0), KEYEVENTF_KEYUP, 0);//放开键 
 	return true;
 }
 
@@ -119,22 +119,22 @@ ret        _variant_t *      
 
 修改历史 :
 修改者   日期           描述
-邓媛元   2010-07-18      
-邓媛元   2010-07-20     检测 
+邓媛元   2010-07-18
+邓媛元   2010-07-20     检测
 ====================================================================*/
-bool  MyKeyboardNamespace::sendkeyString(wchar_t *strs,DWORD delays)
+bool  MyKeyboardNamespace::sendkeyString(wchar_t* strs, DWORD delays)
 {
 	int length = wcslen(strs);
 	for (int i = 0; i < length; ++i)
 	{
 		INPUT   keyin;
-		keyin.type=INPUT_KEYBOARD;
-		keyin.ki.wVk=0;
-		keyin.ki.wScan=strs[i];
-		keyin.ki.time=100;
-		keyin.ki.dwFlags=KEYEVENTF_UNICODE;
-		keyin.ki.dwExtraInfo=GetMessageExtraInfo();
-		::SendInput(1,  &keyin, sizeof(INPUT));
+		keyin.type = INPUT_KEYBOARD;
+		keyin.ki.wVk = 0;
+		keyin.ki.wScan = strs[i];
+		keyin.ki.time = 100;
+		keyin.ki.dwFlags = KEYEVENTF_UNICODE;
+		keyin.ki.dwExtraInfo = GetMessageExtraInfo();
+		::SendInput(1, &keyin, sizeof(INPUT));
 		Sleep(delays);
 	}
 	return true;
@@ -142,7 +142,7 @@ bool  MyKeyboardNamespace::sendkeyString(wchar_t *strs,DWORD delays)
 
 
 
-BYTE keyCode[127]={	VK_BACK,VK_TAB,VK_CLEAR,VK_RETURN,VK_SHIFT,VK_CONTROL,VK_MENU,VK_PAUSE,VK_CAPITAL,VK_KANA,		//10
+BYTE keyCode[127] = { VK_BACK,VK_TAB,VK_CLEAR,VK_RETURN,VK_SHIFT,VK_CONTROL,VK_MENU,VK_PAUSE,VK_CAPITAL,VK_KANA,		//10
 	VK_JUNJA,VK_FINAL,VK_HANJA,VK_KANJI,VK_ESCAPE,VK_CONVERT,VK_NONCONVERT,VK_ACCEPT,VK_MODECHANGE,VK_SPACE,		//10
 	VK_PRIOR,VK_NEXT,VK_END,VK_HOME,VK_LEFT,VK_UP,VK_RIGHT,VK_DOWN,VK_SELECT,VK_PRINT,								//10
 	VK_EXECUTE,VK_SNAPSHOT,VK_INSERT,VK_DELETE,VK_HELP,																//5
@@ -170,32 +170,32 @@ ret        _variant_t *      
 
 修改历史 :
 修改者   日期           描述
-邓媛元   2010-07-18      
-邓媛元   2010-07-20     检测 
+邓媛元   2010-07-18
+邓媛元   2010-07-20     检测
 ====================================================================*/
-bool  MyKeyboardNamespace::waitkeypress(DWORD keycode,DWORD delay)
+bool  MyKeyboardNamespace::waitkeypress(DWORD keycode, DWORD delay)
 {
 	MSG  msg;
-	int waittime=0;
-	if(delay>0)
-		waittime=delay;
-	int time1=::GetTickCount();
-	while(true)
+	int waittime = 0;
+	if (delay > 0)
+		waittime = delay;
+	int time1 = ::GetTickCount();
+	while (true)
 	{
-		if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
+		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
 		{
-			if(WM_QUIT==msg.message)
+			if (WM_QUIT == msg.message)
 				break;
 			TranslateMessage(&msg);
 			DispatchMessage(&msg);
 		}
 		else
 		{
-			if(keycode==0)
+			if (keycode == 0)
 			{
-				for(int i=0;i<127;i++)
+				for (int i = 0; i < 127; i++)
 				{
-					if(0x8000 & GetAsyncKeyState(keyCode[i]))
+					if (0x8000 & GetAsyncKeyState(keyCode[i]))
 					{
 						return true;
 					}
@@ -203,15 +203,15 @@ bool  MyKeyboardNamespace::waitkeypress(DWORD keycode,DWORD delay)
 			}
 			else
 			{
-				if(0x8000 & GetAsyncKeyState(keycode))
+				if (0x8000 & GetAsyncKeyState(keycode))
 				{
 					return true;
 				}
 
 			}
-			if(waittime>0)
+			if (waittime > 0)
 			{
-				if((::GetTickCount()-time1)>=waittime)
+				if ((::GetTickCount() - time1) >= waittime)
 					return false;
 			}
 		}

+ 53 - 53
天使插件源码/TSPlug/KeyMouse/MyKeyboardNamespace.h

@@ -10,71 +10,71 @@ private:
 	//KEY_DOWN  键盘处于按下状态
 	//KEY_UP    键盘处于弹起的状态
 	//KEY_DOWNANDUP  键盘处于按下弹起的状态
-    enum KeyboardEvent
-    {
-        KEY_DOWN
-        ,KEY_UP
-        ,KEY_DOWNANDUP
-    };
+	enum KeyboardEvent
+	{
+		KEY_DOWN
+		, KEY_UP
+		, KEY_DOWNANDUP
+	};
 
 public:
 	//方法描述:键盘按下弹起
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //list            MyDataList *   键盘按下弹起什么键以及键盘按下弹起具体的次数
-    //ret             _variant_t *      接收返回值传出去
-	 bool keyPress(DWORD keycode);
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//list            MyDataList *   键盘按下弹起什么键以及键盘按下弹起具体的次数
+	//ret             _variant_t *      接收返回值传出去
+	bool keyPress(DWORD keycode);
 
 	//方法描述:键盘按下
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //list            MyDataList *   键盘按下什么键以及键盘按下具体次数
-    //ret             _variant_t *      接收返回值传出去
-	 bool keyDown(DWORD keycode);
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//list            MyDataList *   键盘按下什么键以及键盘按下具体次数
+	//ret             _variant_t *      接收返回值传出去
+	bool keyDown(DWORD keycode);
 
 	//方法描述:键盘弹起
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //list            MyDataList *   键盘弹起什么键以及键盘弹起的次数
-    //ret             _variant_t *      接收返回值传出去
-	 bool keyUp(DWORD keycode);
-    
-    //方法描述:按下键盘发送一串字符串
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //list            MyDataList *   键盘发送的字符串
-    //ret             _variant_t *      接收返回值传出去
-	 bool sendkeyString(wchar_t *strs,DWORD delays);
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//list            MyDataList *   键盘弹起什么键以及键盘弹起的次数
+	//ret             _variant_t *      接收返回值传出去
+	bool keyUp(DWORD keycode);
+
+	//方法描述:按下键盘发送一串字符串
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//list            MyDataList *   键盘发送的字符串
+	//ret             _variant_t *      接收返回值传出去
+	bool sendkeyString(wchar_t* strs, DWORD delays);
 
 	//方法描述:暂停程序等待任意按键后继续
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //list            MyDataList *   键盘发送的字符串
-    //ret             _variant_t *      接收返回值传出去
-	 bool waitkeypress(DWORD keycode,DWORD delay);
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//list            MyDataList *   键盘发送的字符串
+	//ret             _variant_t *      接收返回值传出去
+	bool waitkeypress(DWORD keycode, DWORD delay);
 
-	 //键盘功能类的构造函数
-	 MyKeyboardNamespace(void);
+	//键盘功能类的构造函数
+	MyKeyboardNamespace(void);
 
-	 //键盘功能类的析构函数
-	 ~MyKeyboardNamespace(void);
+	//键盘功能类的析构函数
+	~MyKeyboardNamespace(void);
 public:
-	 DWORD delaytime;
+	DWORD delaytime;
 };
 
 #endif

+ 304 - 304
天使插件源码/TSPlug/KeyMouse/MyMouseNamespace.cpp

@@ -10,7 +10,7 @@
 ====================================================================*/
 MyMouseNamespace::MyMouseNamespace()
 {
-	delaytimes=30;
+	delaytimes = 30;
 }
 /*===================================================================
 //析构函数
@@ -24,13 +24,13 @@ MyMouseNamespace::~MyMouseNamespace()
 函数名称 :  mouseMvrelative
 功能描述 :  鼠标移动的相对位置
 ====================================================================*/
-bool  MyMouseNamespace::mouseMvrelative(DWORD x_pos,DWORD y_pos)
+bool  MyMouseNamespace::mouseMvrelative(DWORD x_pos, DWORD y_pos)
 {
-    //移动鼠标的坐标
+	//移动鼠标的坐标
 	POINT pt;
 	::GetCursorPos(&pt);
-	::SetCursorPos(pt.x+x_pos,pt.y+y_pos);
-    return true;
+	::SetCursorPos(pt.x + x_pos, pt.y + y_pos);
+	return true;
 }
 
 //鼠标移动到绝对坐标
@@ -40,11 +40,11 @@ bool  MyMouseNamespace::mouseMvrelative(DWORD x_pos,DWORD y_pos)
 
 ====================================================================*/
 //鼠标移动到绝对位置
-bool  MyMouseNamespace::mouseMove(DWORD x_pos,DWORD y_pos)
+bool  MyMouseNamespace::mouseMove(DWORD x_pos, DWORD y_pos)
 {
-    //移动鼠标的坐标
-	::SetCursorPos(x_pos,y_pos);
-    return true;
+	//移动鼠标的坐标
+	::SetCursorPos(x_pos, y_pos);
+	return true;
 }
 
 //// 鼠标操作
@@ -76,279 +76,279 @@ nEcute      int            执
 
 修改历史 :
 修改者   日期           描述
-邓媛元   2010-07-17     
+邓媛元   2010-07-17
 邓媛元   2010-07-20     修改注释
 ====================================================================*/
 void MyMouseNamespace::mouseAction(MouseMode mousemode, int nEcute)
 {
-    //Sleep(1000);
-
-    //鼠标状态选取 
-    switch (mousemode) 
-    {
-        //鼠标左键单击
-    case LEFTCLICK:
-        for(int i = 0; i < nEcute; i++)
-        {   //鼠标按下
-            //mouse_event(MOUSEEVENTF_LEFTDOWN , 0, 0, 0, 0);
-            //::Sleep(100);
-            //mouse_event(MOUSEEVENTF_LEFTUP , 0, 0, 0, 0);
-
-			INPUT  MyMouseClick[1];  
+	//Sleep(1000);
+
+	//鼠标状态选取 
+	switch (mousemode)
+	{
+		//鼠标左键单击
+	case LEFTCLICK:
+		for (int i = 0; i < nEcute; i++)
+		{   //鼠标按下
+			//mouse_event(MOUSEEVENTF_LEFTDOWN , 0, 0, 0, 0);
+			//::Sleep(100);
+			//mouse_event(MOUSEEVENTF_LEFTUP , 0, 0, 0, 0);
+
+			INPUT  MyMouseClick[1];
 			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			Sleep(delaytimes);
 			////第二个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTUP;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL; ;
 			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-        }
-        break;
-        //鼠标右键单击
-    case RIGHTCLICK: 
-        for(int i = 0; i < nEcute; i++)
-        {   //鼠标按下
-            //mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
-            //::Sleep(100);
-            //mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
-
-			INPUT  MyMouseClick[1];  
+			SendInput(1, MyMouseClick, sizeof(INPUT));
+		}
+		break;
+		//鼠标右键单击
+	case RIGHTCLICK:
+		for (int i = 0; i < nEcute; i++)
+		{   //鼠标按下
+			//mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);
+			//::Sleep(100);
+			//mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);
+
+			INPUT  MyMouseClick[1];
 			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			Sleep(delaytimes);
 			////第二个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL; ;
 			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-        }
-        break;
-        //鼠标中键单击
-    case MIDDLECLICK:
-        for(int i = 0; i < nEcute; i++)
-        {   //鼠标按下
-            //mouse_event(MOUSEEVENTF_MIDDLEDOWN|MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
-
-			INPUT  MyMouseClick[1];  
+			SendInput(1, MyMouseClick, sizeof(INPUT));
+		}
+		break;
+		//鼠标中键单击
+	case MIDDLECLICK:
+		for (int i = 0; i < nEcute; i++)
+		{   //鼠标按下
+			//mouse_event(MOUSEEVENTF_MIDDLEDOWN|MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0);
+
+			INPUT  MyMouseClick[1];
 			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_MIDDLEDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 
 			Sleep(delaytimes);
 			////第二个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_MIDDLEUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
-			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-        }
-        break;
-        //鼠标左键按下
-    case LEFTDOWN:
-		{
-			//左键按下一次
-			//mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); 	
-			INPUT  MyMouseClick[1];  
-			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-		}
-        break;
-        //鼠标左键弹起
-    case LEFTUP:
-		{
-			//mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
-			INPUT  MyMouseClick[1]; 
-			////第二个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
-			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-		}
-        break;
-        //鼠标右键按下
-    case RIGHTDOWN:
-		{
-        //mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0,0);
-		    INPUT  MyMouseClick[1];  
-			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-		}
-        break;
-        //鼠标右键盘弹起
-    case RIGHTUP:
-		{
-        //mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0,0);
-			INPUT  MyMouseClick[1];  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL; ;
 			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 		}
-        break;
-        //鼠标中键按下
-    case MIDDLEDOWN:
-		{
-        //mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0,0);
-			INPUT  MyMouseClick[1];  
-			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_MIDDLEDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-		}
-        break;
-        //鼠标中键盘弹起
-    case MIDDLEUP:
-		{
-        //mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0,0);
-			INPUT  MyMouseClick[1]; 			
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_MIDDLEUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
-			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
-		}
-        break;
-        //鼠标左键双击
+		break;
+		//鼠标左键按下
+	case LEFTDOWN:
+	{
+		//左键按下一次
+		//mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); 	
+		INPUT  MyMouseClick[1];
+		////第一个动作:模拟鼠标左键按下  
+		MyMouseClick[0].type = INPUT_MOUSE;
+		MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
+		MyMouseClick[0].mi.mouseData = NULL;
+		MyMouseClick[0].mi.dwExtraInfo = NULL;
+		MyMouseClick[0].mi.time = NULL;
+		SendInput(1, MyMouseClick, sizeof(INPUT));
+	}
+	break;
+	//鼠标左键弹起
+	case LEFTUP:
+	{
+		//mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
+		INPUT  MyMouseClick[1];
+		////第二个动作:模拟鼠标左键释放  
+		MyMouseClick[0].type = INPUT_MOUSE;
+		MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTUP;
+		MyMouseClick[0].mi.mouseData = NULL;
+		MyMouseClick[0].mi.dwExtraInfo = NULL;
+		MyMouseClick[0].mi.time = NULL; ;
+		////发送鼠标动作到消息序列。
+		SendInput(1, MyMouseClick, sizeof(INPUT));
+	}
+	break;
+	//鼠标右键按下
+	case RIGHTDOWN:
+	{
+		//mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0,0);
+		INPUT  MyMouseClick[1];
+		////第一个动作:模拟鼠标左键按下  
+		MyMouseClick[0].type = INPUT_MOUSE;
+		MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
+		MyMouseClick[0].mi.mouseData = NULL;
+		MyMouseClick[0].mi.dwExtraInfo = NULL;
+		MyMouseClick[0].mi.time = NULL;
+		SendInput(1, MyMouseClick, sizeof(INPUT));
+	}
+	break;
+	//鼠标右键盘弹起
+	case RIGHTUP:
+	{
+		//mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0,0);
+		INPUT  MyMouseClick[1];
+		MyMouseClick[0].type = INPUT_MOUSE;
+		MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
+		MyMouseClick[0].mi.mouseData = NULL;
+		MyMouseClick[0].mi.dwExtraInfo = NULL;
+		MyMouseClick[0].mi.time = NULL; ;
+		////发送鼠标动作到消息序列。
+		SendInput(1, MyMouseClick, sizeof(INPUT));
+	}
+	break;
+	//鼠标中键按下
+	case MIDDLEDOWN:
+	{
+		//mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0,0);
+		INPUT  MyMouseClick[1];
+		////第一个动作:模拟鼠标左键按下  
+		MyMouseClick[0].type = INPUT_MOUSE;
+		MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
+		MyMouseClick[0].mi.mouseData = NULL;
+		MyMouseClick[0].mi.dwExtraInfo = NULL;
+		MyMouseClick[0].mi.time = NULL;
+		SendInput(1, MyMouseClick, sizeof(INPUT));
+	}
+	break;
+	//鼠标中键盘弹起
+	case MIDDLEUP:
+	{
+		//mouse_event(MOUSEEVENTF_MIDDLEUP, 0, 0, 0,0);
+		INPUT  MyMouseClick[1];
+		MyMouseClick[0].type = INPUT_MOUSE;
+		MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
+		MyMouseClick[0].mi.mouseData = NULL;
+		MyMouseClick[0].mi.dwExtraInfo = NULL;
+		MyMouseClick[0].mi.time = NULL; ;
+		////发送鼠标动作到消息序列。
+		SendInput(1, MyMouseClick, sizeof(INPUT));
+	}
+	break;
+	//鼠标左键双击
 	case LEFTDOUBLECLICK:
 		for (int i = 0; i < nEcute; i++)
-		{   
-			INPUT  MyMouseClick[1];  
+		{
+			INPUT  MyMouseClick[1];
 			//第二个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
 			Sleep(delaytimes);
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			//第三个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTUP;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
 			//发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			Sleep(delaytimes);
 			//第二个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			Sleep(delaytimes);
 			//第三个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_LEFTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_LEFTUP;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
 			//发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 		}
 		break;
-        //鼠标右键双击
-    case RIGHTDOUBLECLICK:
-        for (int i = 0; i < nEcute; i++)
-        {
-			INPUT  MyMouseClick[1];  
+		//鼠标右键双击
+	case RIGHTDOUBLECLICK:
+		for (int i = 0; i < nEcute; i++)
+		{
+			INPUT  MyMouseClick[1];
 			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			Sleep(delaytimes);
 			////第二个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL; ;
 			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			Sleep(delaytimes);
 			////第一个动作:模拟鼠标左键按下  
-			MyMouseClick[0].type   =   INPUT_MOUSE;  
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTDOWN;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL;
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 			Sleep(delaytimes);
 			////第二个动作:模拟鼠标左键释放  
-			MyMouseClick[0].type   =   INPUT_MOUSE;   
-			MyMouseClick[0].mi.dwFlags   =   MOUSEEVENTF_RIGHTUP;  
-			MyMouseClick[0].mi.mouseData   =   NULL;  
-			MyMouseClick[0].mi.dwExtraInfo   =   NULL;  
-			MyMouseClick[0].mi.time   =   NULL;  ;
+			MyMouseClick[0].type = INPUT_MOUSE;
+			MyMouseClick[0].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
+			MyMouseClick[0].mi.mouseData = NULL;
+			MyMouseClick[0].mi.dwExtraInfo = NULL;
+			MyMouseClick[0].mi.time = NULL; ;
 			////发送鼠标动作到消息序列。
-			SendInput(1,MyMouseClick,sizeof(INPUT));
+			SendInput(1, MyMouseClick, sizeof(INPUT));
 
-        }
-        break;
-    default:
-        return;
-    }
+		}
+		break;
+	default:
+		return;
+	}
 }
 
 /*===================================================================
 函数名称 :  GetmousePoint
 功能描述 :  获取当前鼠标的位置坐标
 ====================================================================*/
-bool  MyMouseNamespace::GetmousePoint(DWORD &x_pos,DWORD &y_pos)
+bool  MyMouseNamespace::GetmousePoint(DWORD& x_pos, DWORD& y_pos)
 {
-    POINT pt;
-    GetCursorPos(&pt);
-	x_pos=pt.x;
-	y_pos=pt.y;
-    return true;
+	POINT pt;
+	GetCursorPos(&pt);
+	x_pos = pt.x;
+	y_pos = pt.y;
+	return true;
 }
 /*返回值: void类型
 
@@ -358,120 +358,120 @@ bool  MyMouseNamespace::GetmousePoint(DWORD &x_pos,DWORD &y_pos)
 direction   MouseWheel       接收返回值传出去
 nMove       int              控制滚轮移动多少
 ====================================================================*/
-void MyMouseNamespace::mouseMidleWheel(MouseWheel direction,int  nMove)
+void MyMouseNamespace::mouseMidleWheel(MouseWheel direction, int  nMove)
 {
-    if (direction == MouseWheel::WHEEL_DOWN) //滚轮向下
-    {
-        mouse_event(MOUSEEVENTF_WHEEL, 0,0,-nMove, 0);
-    }
-    else if (direction == MouseWheel::WHEEL_UP) //滚轮向上
-    {
-        mouse_event(MOUSEEVENTF_WHEEL, 0,0, nMove, 0);
-    }
+	if (direction == MouseWheel::WHEEL_DOWN) //滚轮向下
+	{
+		mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -nMove, 0);
+	}
+	else if (direction == MouseWheel::WHEEL_UP) //滚轮向上
+	{
+		mouse_event(MOUSEEVENTF_WHEEL, 0, 0, nMove, 0);
+	}
 }
 
 HBITMAP BitmapFromIcon(HICON hIcon)
 {
-    HDC dDC = CreateDC(_T("DISPLAY"),NULL,NULL,NULL);
-    HDC hDC = CreateCompatibleDC(dDC);
-    HBITMAP hBitmap = CreateCompatibleBitmap(hDC, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
-    HBITMAP hOldBitmap = (HBITMAP)SelectObject(hDC, hBitmap);
-    DrawIcon(hDC, 0, 0, hIcon);
-    hBitmap=(HBITMAP)SelectObject(hDC, hOldBitmap);
-    DeleteDC(hDC);
-    ::DeleteDC(dDC);
-
-    return hBitmap;
+	HDC dDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
+	HDC hDC = CreateCompatibleDC(dDC);
+	HBITMAP hBitmap = CreateCompatibleBitmap(hDC, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
+	HBITMAP hOldBitmap = (HBITMAP)SelectObject(hDC, hBitmap);
+	DrawIcon(hDC, 0, 0, hIcon);
+	hBitmap = (HBITMAP)SelectObject(hDC, hOldBitmap);
+	DeleteDC(hDC);
+	::DeleteDC(dDC);
+
+	return hBitmap;
 }
 
 ////////////////////////获取鼠标形状特征码 ///////////////
-bool MyMouseNamespace::getmouseshape(DWORD &dwshape)
+bool MyMouseNamespace::getmouseshape(DWORD& dwshape)
 {
-	dwshape=0;
+	dwshape = 0;
 	CURSORINFO pci;
-	pci.cbSize=sizeof(CURSORINFO);
-	pci.flags=0;
-	pci.hCursor=0;
-	if(!::GetCursorInfo(&pci))
+	pci.cbSize = sizeof(CURSORINFO);
+	pci.flags = 0;
+	pci.hCursor = 0;
+	if (!::GetCursorInfo(&pci))
 		return false;
-	
-	HDC dDC = CreateDC(_T("DISPLAY"),NULL,NULL,NULL);
+
+	HDC dDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
 	HDC hDC = CreateCompatibleDC(dDC);
 	HBITMAP hBitmap = CreateCompatibleBitmap(dDC, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
 	HBITMAP hOldBitmap = (HBITMAP)SelectObject(hDC, hBitmap);
 
-	DrawIcon(hDC,0,0,pci.hCursor);
-	hBitmap=(HBITMAP)SelectObject(hDC, hOldBitmap);
+	DrawIcon(hDC, 0, 0, pci.hCursor);
+	hBitmap = (HBITMAP)SelectObject(hDC, hOldBitmap);
 
-	DWORD           dwPaletteSize=0,dwBmBitsSize;
-	BITMAP          Bitmap;              
+	DWORD           dwPaletteSize = 0, dwBmBitsSize;
+	BITMAP          Bitmap;
 	BITMAPINFOHEADER   bi;
 	//位图信息头结构 
-	LPBITMAPINFOHEADER lpbi; 
+	LPBITMAPINFOHEADER lpbi;
 	HANDLE       hDib;
-	HPALETTE     hOldPal=NULL;
+	HPALETTE     hOldPal = NULL;
 
 	//设置位图信息头结构
 	GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&Bitmap);
 	WORD    wBitCount = Bitmap.bmBitsPixel;
-	dwBmBitsSize = ((Bitmap.bmWidth*wBitCount+31)& ~31)/8*Bitmap.bmHeight;
+	dwBmBitsSize = ((Bitmap.bmWidth * wBitCount + 31) & ~31) / 8 * Bitmap.bmHeight;
 	BYTE* bmpDate = new BYTE[dwBmBitsSize];
 
-	bi.biSize            = sizeof(BITMAPINFOHEADER);
-	bi.biWidth           = Bitmap.bmWidth;
-	bi.biHeight          = Bitmap.bmHeight;
-	bi.biPlanes          = 1;
-	bi.biBitCount         = wBitCount;
-	bi.biCompression      = BI_RGB;
-	bi.biSizeImage        = dwBmBitsSize;
-	bi.biXPelsPerMeter     = 0;
-	bi.biYPelsPerMeter     = 0;
-	bi.biClrUsed         = 0;
-	bi.biClrImportant      = 0;
-
-	hDib  = GlobalAlloc(GHND,dwBmBitsSize+dwPaletteSize+sizeof(BITMAPINFOHEADER));
+	bi.biSize = sizeof(BITMAPINFOHEADER);
+	bi.biWidth = Bitmap.bmWidth;
+	bi.biHeight = Bitmap.bmHeight;
+	bi.biPlanes = 1;
+	bi.biBitCount = wBitCount;
+	bi.biCompression = BI_RGB;
+	bi.biSizeImage = dwBmBitsSize;
+	bi.biXPelsPerMeter = 0;
+	bi.biYPelsPerMeter = 0;
+	bi.biClrUsed = 0;
+	bi.biClrImportant = 0;
+
+	hDib = GlobalAlloc(GHND, dwBmBitsSize + dwPaletteSize + sizeof(BITMAPINFOHEADER));
 	lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib);
 	*lpbi = bi;
-	GetDIBits(hDC,hBitmap,0,(UINT)Bitmap.bmHeight,bmpDate, (BITMAPINFO *)lpbi,DIB_RGB_COLORS);
-	DWORD num=0;
-	int height=Bitmap.bmHeight;
-	int width =Bitmap.bmWidth;
-	
+	GetDIBits(hDC, hBitmap, 0, (UINT)Bitmap.bmHeight, bmpDate, (BITMAPINFO*)lpbi, DIB_RGB_COLORS);
+	DWORD num = 0;
+	int height = Bitmap.bmHeight;
+	int width = Bitmap.bmWidth;
+
 	BYTE  b0 = bmpDate[0];
 	BYTE  g0 = bmpDate[1];
 	BYTE  r0 = bmpDate[2];
 
 	// 32位图进行解析
-	if(Bitmap.bmBitsPixel==32)
+	if (Bitmap.bmBitsPixel == 32)
 	{
-			for(int i=0;i<height;i++)
+		for (int i = 0; i < height; i++)
+		{
+			for (int j = 0; j < width; j++)
 			{
-				for(int j=0;j<width;j++)
+				UCHAR b = bmpDate[(i * width + j) * 4];
+				UCHAR g = bmpDate[(i * width + j) * 4 + 1];
+				UCHAR r = bmpDate[(i * width + j) * 4 + 2];
+				if (b == b0 && g == g0 && r == r0)
+				{
+					continue;
+				}
+				else
 				{
-					UCHAR b=bmpDate[(i*width+j)*4];
-					UCHAR g=bmpDate[(i*width+j)*4+1];
-					UCHAR r=bmpDate[(i*width+j)*4+2];
-					if( b == b0 && g == g0 && r == r0 )
-					{
-						continue;
-					}
-					else
-					{
-						num++;
-					}
+					num++;
 				}
 			}
+		}
 	}
 
 
 	////////////////////////////////////////////////////////////////////////
-	DWORD helpnum=num*RGB(255,255,0);
-	delete [] bmpDate;
-	:: GlobalFree(hDib);
+	DWORD helpnum = num * RGB(255, 255, 0);
+	delete[] bmpDate;
+	::GlobalFree(hDib);
 	::DeleteDC(hDC);
 	::DeleteDC(dDC);
 	::DeleteObject(hBitmap);
-	dwshape=helpnum;
+	dwshape = helpnum;
 	return true;
 }
 

+ 67 - 67
天使插件源码/TSPlug/KeyMouse/MyMouseNamespace.h

@@ -7,77 +7,77 @@ private:
 	//鼠标按键状态枚举 
 	enum MouseMode
 	{
-		 LEFTCLICK   =0    //左键单击
-		,RIGHTCLICK        //右键单击
-		,MIDDLECLICK       //中键单击
-		,LEFTDOWN          //左键按下
-		,LEFTUP            //左键弹起
-		,RIGHTDOWN         //右键按下
-		,RIGHTUP           //右键弹起
-		,MIDDLEDOWN        //中键按下
-		,MIDDLEUP          //中键弹起
-		,LEFTDOUBLECLICK   //左键双击
-		,RIGHTDOUBLECLICK  //右键双击
+		LEFTCLICK = 0    //左键单击
+		, RIGHTCLICK        //右键单击
+		, MIDDLECLICK       //中键单击
+		, LEFTDOWN          //左键按下
+		, LEFTUP            //左键弹起
+		, RIGHTDOWN         //右键按下
+		, RIGHTUP           //右键弹起
+		, MIDDLEDOWN        //中键按下
+		, MIDDLEUP          //中键弹起
+		, LEFTDOUBLECLICK   //左键双击
+		, RIGHTDOUBLECLICK  //右键双击
 	};
 
 	//鼠标滑轮方向
 	enum MouseWheel
 	{
-		 WHEEL_UP   =0       //向上滑动
-		,WHEEL_DOWN          //向下滑动
+		WHEEL_UP = 0       //向上滑动
+		, WHEEL_DOWN          //向下滑动
 	};
 
 	//方法描述:鼠标单击双击模式以及具体的执行次数
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //mousemode       MouseMode *   传进来鼠标单击双击模式
-    //nEcute          int           执行单击或者双击几次
-	void mouseAction(MouseMode mousemode, int nEcute=1);
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//mousemode       MouseMode *   传进来鼠标单击双击模式
+	//nEcute          int           执行单击或者双击几次
+	void mouseAction(MouseMode mousemode, int nEcute = 1);
 
 	//方法描述:滚轮的实现   
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
 	//direction       MouseWheel     鼠标中键模式
 	//nMove           int            鼠标中键向上还是向下具体移动多少值
-	void mouseMidleWheel(MouseWheel direction,int  nMove=1);
+	void mouseMidleWheel(MouseWheel direction, int  nMove = 1);
 
 public:
 	//方法描述:鼠标移动的相对位置
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //list            MyDataList *   传进来函数的参数,鼠标的x,y值
-    //ret             _variant_t *      接收返回值传出去
-	 bool  mouseMvrelative(DWORD x_pos,DWORD y_pos);
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//list            MyDataList *   传进来函数的参数,鼠标的x,y值
+	//ret             _variant_t *      接收返回值传出去
+	bool  mouseMvrelative(DWORD x_pos, DWORD y_pos);
 
 	//方法描述:鼠标移动的绝对位置
-    //返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //list            MyDataList *   传进来函数的参数,鼠标的x,y值
-    //ret             _variant_t *      接收返回值传出去
-	 bool   mouseMove(DWORD x_pos,DWORD y_pos);
+	//返回值:BOOL类型
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//list            MyDataList *   传进来函数的参数,鼠标的x,y值
+	//ret             _variant_t *      接收返回值传出去
+	bool   mouseMove(DWORD x_pos, DWORD y_pos);
 
 	//方法描述:获取当前鼠标的当前位置坐标
 	//返回值:BOOL类型
-    //_TRUE表示成功,_FALSE表示失败
-    //
-    //参数说明:
-    //参数名称        参数类型       说明
-    //ret             _variant_t *      接收返回值传出去
-	 bool GetmousePoint(DWORD &x_pos,DWORD &y_pos);
+	//_TRUE表示成功,_FALSE表示失败
+	//
+	//参数说明:
+	//参数名称        参数类型       说明
+	//ret             _variant_t *      接收返回值传出去
+	bool GetmousePoint(DWORD& x_pos, DWORD& y_pos);
 	////////////////////////获取鼠标形状特征码 ///////////////
-	bool getmouseshape(DWORD &dwshape);
+	bool getmouseshape(DWORD& dwshape);
 
 	////////等待鼠标任意操作//////////////////
 	//static bool waitClick(MyDataList * list,_variant_t * ret);
@@ -85,27 +85,27 @@ public:
 	// 获取上一次鼠标的动作
 	//bool getLastClick(MyDataList * list,_variant_t * ret);
 
-	 bool leftClick();
-	 bool leftDoubleClick();
-	 bool leftDown();
-	 bool leftUp();
+	bool leftClick();
+	bool leftDoubleClick();
+	bool leftDown();
+	bool leftUp();
 
-	 bool rightClick();
-	 bool rightDoubleClick();
-	 bool rightDown();
-	 bool rightUp();
+	bool rightClick();
+	bool rightDoubleClick();
+	bool rightDown();
+	bool rightUp();
 
-	 bool middleClick();
-	 bool middleDown();
-	 bool middleUp();
+	bool middleClick();
+	bool middleDown();
+	bool middleUp();
 	// 向下滚动
-	 bool mouseSheetDown();
+	bool mouseSheetDown();
 	// 向上滚动
-	 bool mouseSheetUp();
-	 //鼠标功能类的构造函数
-	 MyMouseNamespace();
-	 //鼠标功能类的析构函数
-	 ~MyMouseNamespace();
+	bool mouseSheetUp();
+	//鼠标功能类的构造函数
+	MyMouseNamespace();
+	//鼠标功能类的析构函数
+	~MyMouseNamespace();
 public:
 	DWORD delaytimes;
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 312 - 312
天使插件源码/TSPlug/TSFindPicture.cpp


+ 51 - 51
天使插件源码/TSPlug/TSFindPicture.h

@@ -15,7 +15,7 @@ public:
 	MyFindPictureClass(void);
 	~MyFindPictureClass(void);
 
-	enum RUNTYPE{TurnUP=0,TurnDOWN,TurnLEFT,TurnRIGHT,TurnERRORR};
+	enum RUNTYPE { TurnUP = 0, TurnDOWN, TurnLEFT, TurnRIGHT, TurnERRORR };
 	//LPDIRECT3DDEVICE9 m_pDxdevice;
 	//HWND              m_Wnd;
 	bool isprocessColor;//说明是找色或者取色
@@ -29,22 +29,22 @@ public:
 	bool IsLastFindStr;//是否最后一次查找
 
 	//COLORREF pWndBmpBuffer[2000][2000];
-	COLORREF** pWndBmpBuffer; 
+	COLORREF** pWndBmpBuffer;
 	//DWORD ColorDataInfo[2000][2000];
-	BYTE * pBuffer;
+	BYTE* pBuffer;
 	//COLORREF** pColorBuffer; 
 	int wndWidth;
 	int wndHeight;
 	int nbuffersize;
 	PVOID pbuffer;
 
-	bool SaveGDIBitmap(HWND hWnd,RECT rect,wchar_t *savepath);
+	bool SaveGDIBitmap(HWND hWnd, RECT rect, wchar_t* savepath);
 
 	bool SaveBitmapToFile(HBITMAP hBitmap, LPCWSTR lpFileName);
 
-	bool CopyScreenToBitmap(LPRECT lpRect,wchar_t *savepath);
+	bool CopyScreenToBitmap(LPRECT lpRect, wchar_t* savepath);
 
-	DWORD GetBkMouseShape(HCURSOR bkmouseshape=NULL);//默认bkmouseshape为空时为前台模式, bkmouseshape有值的时候是后台模式
+	DWORD GetBkMouseShape(HCURSOR bkmouseshape = NULL);//默认bkmouseshape为空时为前台模式, bkmouseshape有值的时候是后台模式
 
 	bool loadBitmap(wchar_t* path);
 	//////////////////找图   支持的是24位位图/////////////////////
@@ -61,50 +61,50 @@ public:
 	////  dir            检索方式
 	////  xpos           返回的图片的左上角x坐标
 	////  ypos           返回的图片的左上角y坐标
-	int findPicture(PVOID pbuffer,HWND hwnd,int left, int top, int right, int bottom, wchar_t* path, wchar_t *color, double simi, int dir, long &x,long &y,DWORD (*ColorDataInfo)[2000],wchar_t *retstring=NULL,int type=0);
+	int findPicture(PVOID pbuffer, HWND hwnd, int left, int top, int right, int bottom, wchar_t* path, wchar_t* color, double simi, int dir, long& x, long& y, DWORD(*ColorDataInfo)[2000], wchar_t* retstring = NULL, int type = 0);
 
 	/////// 颜色内存处理。。 提高速度 //////////////////////
-	bool processCreenWindow(int color,int left,int top,int right,int bottom,double simi,int dir,int &x,int &y,wchar_t* colorStr=NULL,bool isMulitColor=false);
+	bool processCreenWindow(int color, int left, int top, int right, int bottom, double simi, int dir, int& x, int& y, wchar_t* colorStr = NULL, bool isMulitColor = false);
 
 	/////// 后台颜色内存处理。。 提高速度 //////////////////////
-	int processColor(PVOID pbuffer,HWND hwnd,int &color,int left,int top,int right,int buttom,double simi,int dir,long &x,long &y,DWORD (*ColorDataInfo)[2000],wchar_t *colorstr=NULL,wchar_t *retstring=NULL,wchar_t *MultiColor=NULL);
+	int processColor(PVOID pbuffer, HWND hwnd, int& color, int left, int top, int right, int buttom, double simi, int dir, long& x, long& y, DWORD(*ColorDataInfo)[2000], wchar_t* colorstr = NULL, wchar_t* retstring = NULL, wchar_t* MultiColor = NULL);
 
 	//将BMP图转JPG图
-	bool   BMP2JPG(wchar_t*   strBMPFile,wchar_t*   strJPGFile);
+	bool   BMP2JPG(wchar_t* strBMPFile, wchar_t* strJPGFile);
 	//将BMP图转PNG图
-	bool   BMP2PNG(wchar_t*   strBMPFile,wchar_t*   strPNGFile);
+	bool   BMP2PNG(wchar_t* strBMPFile, wchar_t* strPNGFile);
 
 	//////////////////////////////////////////////////////////////////////////////////////找字算法
 	int   strColor;//字的颜色
 	int   strColors[MAX_PATH];//字的颜色
 	int   strColoroff[MAX_PATH];//字的色偏
 	int ncount;//记录位图加载的点阵个数
-	int addrxy[MAX_PATH*10][4];
+	int addrxy[MAX_PATH * 10][4];
 	int dictindex;//记录当前字库的数量
 	int usingindex;	//当前使用字库的下标
 	std::vector<POINT> pWndBmpStr[2048];
-	short **pWndBmpStrxy;//存储当前图片的所有坐标对于的整形值
+	short** pWndBmpStrxy;//存储当前图片的所有坐标对于的整形值
 	wchar_t SetPath[MAX_PATH];
 	//wchar_t SetPicPwdString[MAX_PATH];
 	//COLORREF **pLoadstrBuffer;
 	//COLORREF pLoadstrBuffer[11][MAX_PATH-10];
 
-	void hextobyte(char * hexStr,char * byteStr);//将十六进制字符串转换成二进制字符串
+	void hextobyte(char* hexStr, char* byteStr);//将十六进制字符串转换成二进制字符串
 	//void byteTopic(short strvalue[MAX_PATH],int strwide,COLORREF pLoadstrBuffer[11][MAX_PATH-10]);//二进制数值还原成图片MAX_PATH
-	void byteTopic(short strvalue[MAX_PATH],int strwide);//二进制数值还原成图片MAX_PATH
+	void byteTopic(short strvalue[MAX_PATH], int strwide);//二进制数值还原成图片MAX_PATH
 	//bool comparaStrTosim(COLORREF pLoadstrBuffer[11][MAX_PATH-10],int strwide,int strhight,int &RetX,int &RetY,int startX,int startY,float simi,int nstrcount);	//相似度匹配
-	bool comparaStrTosim(int strwide,int strhight,int &RetX,int &RetY,int startX,int startY,float simi,int nstrcount);	//相似度匹配
-	bool comparaStr(short pLoadstrBufferxy[MAX_PATH],int strwide,int strhight,int &RetX,int &RetY,int startX,int startY,float simi,int nstrcount);//匹配字符串
-	void dicthextobyte(char * hexStr,char * byteStr,int &hexlen,short &nstrinfo);// 字库信息转二进制
+	bool comparaStrTosim(int strwide, int strhight, int& RetX, int& RetY, int startX, int startY, float simi, int nstrcount);	//相似度匹配
+	bool comparaStr(short pLoadstrBufferxy[MAX_PATH], int strwide, int strhight, int& RetX, int& RetY, int startX, int startY, float simi, int nstrcount);//匹配字符串
+	void dicthextobyte(char* hexStr, char* byteStr, int& hexlen, short& nstrinfo);// 字库信息转二进制
 	bool GetStringInfo();//获取位置点阵信息
 	//获取位置点阵信息,和GetStringInfo区别是,多了一层X坐标的扫描,排除多余无效的点阵信息
 	bool GetStringInfo1();
-	bool MySetDict(int nindex,wchar_t *dictpath,pMyDictInfo *MyDictCount,int *nMyDictCountsize,int &NowUsingDictIndex);//设置字库 加载字库
-	bool MyUseDict(int Useindex,pMyDictInfo *MyDictCount,int &NowUsingDictIndex);	   //使用字库
-	bool MyDeleteDict(int deleteindex,pMyDictInfo *MyDictCount,int *nMyDictCountsize,int &NowUsingDictIndex);	//删除字库
-	int ocr(PVOID pbuffer,HWND hwnd,int left, int top, int right, int bottom, wchar_t * color_format, double simi,wchar_t * retstr,pMyDictInfo *MyDictCount,int *nMyDictCountsize,int NowUsingDictIndex,DWORD (*ColorDataInfo)[2000],int type=0);
-	int FindStr(PVOID pbuffer,HWND hwnd,int left, int top, int right, int bottom, wchar_t* strings, wchar_t* color, double simi, long &x,long &y,pMyDictInfo *MyDictCount,int *nMyDictCountsize,int NowUsingDictIndex,DWORD (*ColorDataInfo)[2000],wchar_t *retstring=NULL,int type=0);
-	int FindStrFast(PVOID pbuffer,HWND hwnd,int left, int top, int right, int bottom, wchar_t* strings, wchar_t* color, double simi, long &x,long &y,pMyDictInfo *MyDictCount,int *nMyDictCountsize,int NowUsingDictIndex,DWORD (*ColorDataInfo)[2000],wchar_t *retstring=NULL,int type=0);
+	bool MySetDict(int nindex, wchar_t* dictpath, pMyDictInfo* MyDictCount, int* nMyDictCountsize, int& NowUsingDictIndex);//设置字库 加载字库
+	bool MyUseDict(int Useindex, pMyDictInfo* MyDictCount, int& NowUsingDictIndex);	   //使用字库
+	bool MyDeleteDict(int deleteindex, pMyDictInfo* MyDictCount, int* nMyDictCountsize, int& NowUsingDictIndex);	//删除字库
+	int ocr(PVOID pbuffer, HWND hwnd, int left, int top, int right, int bottom, wchar_t* color_format, double simi, wchar_t* retstr, pMyDictInfo* MyDictCount, int* nMyDictCountsize, int NowUsingDictIndex, DWORD(*ColorDataInfo)[2000], int type = 0);
+	int FindStr(PVOID pbuffer, HWND hwnd, int left, int top, int right, int bottom, wchar_t* strings, wchar_t* color, double simi, long& x, long& y, pMyDictInfo* MyDictCount, int* nMyDictCountsize, int NowUsingDictIndex, DWORD(*ColorDataInfo)[2000], wchar_t* retstring = NULL, int type = 0);
+	int FindStrFast(PVOID pbuffer, HWND hwnd, int left, int top, int right, int bottom, wchar_t* strings, wchar_t* color, double simi, long& x, long& y, pMyDictInfo* MyDictCount, int* nMyDictCountsize, int NowUsingDictIndex, DWORD(*ColorDataInfo)[2000], wchar_t* retstring = NULL, int type = 0);
 	//pMyDictInfo mydict;
 	//////////////////////////////////////////////////////////////////////////////////////找字算法
 private:
@@ -125,58 +125,58 @@ private:
 
 	//////////////////////////////存储传进来的四点的范围/////////////
 	int        m_Left;       // 左上点
-	int        m_Top ;       // 顶端点
-	int        m_Right ;     // 右下点
-	int        m_bottom ;    // 底端点
+	int        m_Top;       // 顶端点
+	int        m_Right;     // 右下点
+	int        m_bottom;    // 底端点
 
 	int		xpos_offset;
 	int		ypos_offset;
 
 	///////////////////////////// 助记透明图的处理 /////////////
 	int        m_helpXpoint;
-	int        m_helpYpoint; 
-    //bool catchWindowBitmap();
- 	//bool processBKWindows(HWND src_hWnd);
+	int        m_helpYpoint;
+	//bool catchWindowBitmap();
+	//bool processBKWindows(HWND src_hWnd);
 
 	//配合BMP2JPG使用
-	int   GetEncoderClsid(const   WCHAR*   format,   CLSID*   pClsid);
-	bool getGDIBitmap(HWND wnd,RECT rc,int typemode=0);//初始默认为找图	,typemode=0
-	bool getDXBitmap(PVOID pbuffer,DWORD (*ColorDataInfo)[2000],int typemode=0);//初始默认为找图	,typemode=0
-	bool findImage(wchar_t* path,long &x,long &y,int type=0);
+	int   GetEncoderClsid(const   WCHAR* format, CLSID* pClsid);
+	bool getGDIBitmap(HWND wnd, RECT rc, int typemode = 0);//初始默认为找图	,typemode=0
+	bool getDXBitmap(PVOID pbuffer, DWORD(*ColorDataInfo)[2000], int typemode = 0);//初始默认为找图	,typemode=0
+	bool findImage(wchar_t* path, long& x, long& y, int type = 0);
 
-	bool comparabmp(int startX,int startY,int endX,int endY);
+	bool comparabmp(int startX, int startY, int endX, int endY);
 	//////////////// 检索 方式 //////////////////
 	//////////////////////////////////0:从左到右,从上倒下/////////////////////
-	bool leftToRightFromTop(long &x,long &y);
+	bool leftToRightFromTop(long& x, long& y);
 	//////处理背景色为透明的图片////////////////
-	bool comparaLeftToRightFromTop(int h,int w,int startX,int startY);
+	bool comparaLeftToRightFromTop(int h, int w, int startX, int startY);
 	//////处理背景色为不透明的图片////////////////
-	bool comparaLeftToRightFromTopEx(int h,int w);
-	
+	bool comparaLeftToRightFromTopEx(int h, int w);
+
 	////////////////////////////////////1:从左到右,从下倒上//////////////////
-	bool leftToRightFromBottom(long &x,long &y);
+	bool leftToRightFromBottom(long& x, long& y);
 	////////处理背景色为透明的图片////////////////
-	bool comparaLeftToRightFromBottom(int h,int w,int startX,int startY);
+	bool comparaLeftToRightFromBottom(int h, int w, int startX, int startY);
 	////////处理背景色为不透明的图片////////////////
-	bool comparaLeftToRightFromBottomEx(int h,int w);
+	bool comparaLeftToRightFromBottomEx(int h, int w);
 
 	////////////////////////////////////2:从右到左,从上倒下//////////////////
-	bool rightToLeftFromTop(long &x,long &y);
+	bool rightToLeftFromTop(long& x, long& y);
 	////////处理背景色为透明的图片////////////////
-	bool comparaRightToLeftFromTop(int h,int w,int startX,int startY);
+	bool comparaRightToLeftFromTop(int h, int w, int startX, int startY);
 	////////处理背景色为不透明的图片////////////////
-	bool comparaRightToLeftFromTopEx(int h,int w);	
-	
+	bool comparaRightToLeftFromTopEx(int h, int w);
+
 	//////////////////////////////////3:从右到左,从下倒上///////////////////
-	bool rightToLeftFromBottom(long &x,long &y);
+	bool rightToLeftFromBottom(long& x, long& y);
 	////////处理背景色为透明的图片////////////////
-	bool comparaRightToLeftFromBottom(int h,int w,int startX,int startY);
+	bool comparaRightToLeftFromBottom(int h, int w, int startX, int startY);
 	////////处理背景色为不透明的图片////////////////
-	bool comparaRightToLeftFromBottomEx(int h,int w);
+	bool comparaRightToLeftFromBottomEx(int h, int w);
 
 	COLORREF RgbToBgb(__in COLORREF rgb);
 
-	bool FindMultiColor(wchar_t *MultiColor,int i,int j,int Bottom,int right,int help_simi);
-	
+	bool FindMultiColor(wchar_t* MultiColor, int i, int j, int Bottom, int right, int help_simi);
+
 };
 #endif

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 373 - 373
天使插件源码/TSPlug/TSHookFuntion.h


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 337 - 337
天使插件源码/TSPlug/TSMemoryAPI.cpp


+ 97 - 100
天使插件源码/TSPlug/TSMemoryAPI.h

@@ -10,60 +10,60 @@
 #define  FINDDATATYPE_FINDINTEX			4
 #define  FINDDATATYPE_FINDSTRINGEX		5
 
-typedef struct  _FindDataInfo //线程传参数结构体
+typedef struct _FindDataInfo //线程传参数结构体
+{
+	HANDLE hprocess;
+	DWORD dwncount;	//要找的地址数据个数
+	int count;//记录个数
+	double double_value_min;
+	double double_value_max;
+	float float_value_min;
+	float float_value_max;
+	LONG int_value_min;
+	LONG int_value_max;
+	BYTE FindIntType;//找0:32位,1:16位,2:8位
+	LONG FindDataType;//找数据的类型
+	wchar_t Findstring[MAX_PATH];
+	DWORD Finddata[MAX_PATH];  //要找的数据字符串
+	DWORD dwbegin[MAX_PATH * 10];
+	DWORD dwend[MAX_PATH * 10];
+	bool bfindindex[MAX_PATH * 10];//做地址标志位,标识多线程要处理的地址
+	wchar_t* retstr;
+	CRITICAL_SECTION m_mutex;//多线程临界区
+	_FindDataInfo()
 	{
-		HANDLE hprocess;
-		DWORD dwncount;	//要找的地址数据个数
-		int count;//记录个数
-		double double_value_min;
-		double double_value_max;
-		float float_value_min;
-		float float_value_max;
-		LONG int_value_min;
-		LONG int_value_max;
-		BYTE FindIntType;//找0:32位,1:16位,2:8位
-		LONG FindDataType;//找数据的类型
-		wchar_t Findstring[MAX_PATH];
-		DWORD Finddata[MAX_PATH];  //要找的数据字符串
-		DWORD dwbegin[MAX_PATH*10];
-		DWORD dwend[MAX_PATH*10];
-		bool bfindindex[MAX_PATH*10];//做地址标志位,标识多线程要处理的地址
-		wchar_t *retstr;
-		CRITICAL_SECTION m_mutex;//多线程临界区
-	   _FindDataInfo()
-		   {
-			  hprocess=NULL;
-			  retstr=NULL;
-			  dwncount=0;
-			  count=0;
-			  double_value_min=0;
-			  double_value_max=0;
-			  float_value_min=0;
-			  float_value_max=0;
-			  int_value_min=0;
-			  int_value_max=0;
-			  FindIntType=-1;//找0:32位,1:16位,2:8位
-			  FindDataType=-1;//找数据的类型
-			  memset(Finddata,0,MAX_PATH*sizeof(DWORD));
-			  memset(Findstring,0,MAX_PATH);
-			  memset(dwbegin,0,MAX_PATH*10);
-			  memset(dwend,0,MAX_PATH*10);
-			  memset(bfindindex,0,MAX_PATH*10);	//模式为false
-		   }
-	}FindDataInfo, *PFindDataInfo;
+		hprocess = NULL;
+		retstr = NULL;
+		dwncount = 0;
+		count = 0;
+		double_value_min = 0;
+		double_value_max = 0;
+		float_value_min = 0;
+		float_value_max = 0;
+		int_value_min = 0;
+		int_value_max = 0;
+		FindIntType = -1;//找0:32位,1:16位,2:8位
+		FindDataType = -1;//找数据的类型
+		memset(Finddata, 0, MAX_PATH * sizeof(DWORD));
+		memset(Findstring, 0, MAX_PATH);
+		memset(dwbegin, 0, MAX_PATH * 10);
+		memset(dwend, 0, MAX_PATH * 10);
+		memset(bfindindex, 0, MAX_PATH * 10);	//模式为false
+	}
+}FindDataInfo, * PFindDataInfo;
 
 typedef struct {
 	unsigned short Length;
 	unsigned short MaximumLength;
-	unsigned short *Buffer;
-	} UNICODE_STRING;
-typedef UNICODE_STRING *PUNICODE_STRING;
+	unsigned short* Buffer;
+} UNICODE_STRING;
+typedef UNICODE_STRING* PUNICODE_STRING;
 
 typedef struct _CLIENT_ID {
 	HANDLE UniqueProcess;
 	HANDLE UniqueThread;
-	} CLIENT_ID;
-typedef CLIENT_ID *PCLIENT_ID;
+} CLIENT_ID;
+typedef CLIENT_ID* PCLIENT_ID;
 
 typedef struct _OBJECT_ATTRIBUTES {
 	ULONG  Length;
@@ -72,10 +72,8 @@ typedef struct _OBJECT_ATTRIBUTES {
 	ULONG  Attributes;
 	PVOID  SecurityDescriptor;
 	PVOID  SecurityQualityOfService;
-	} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
-typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES;
-
-
+} OBJECT_ATTRIBUTES, * POBJECT_ATTRIBUTES;
+typedef CONST OBJECT_ATTRIBUTES* PCOBJECT_ATTRIBUTES;
 
 typedef struct {
 	unsigned long AllocationSize;
@@ -83,88 +81,87 @@ typedef struct {
 	unsigned long Flags;
 	unsigned long Unknown1;
 	UNICODE_STRING Unknown2;
-	void *InputHandle;
-	void *OutputHandle;
-	void *ErrorHandle;
+	void* InputHandle;
+	void* OutputHandle;
+	void* ErrorHandle;
 	UNICODE_STRING CurrentDirectory;
-	void *CurrentDirectoryHandle;
+	void* CurrentDirectoryHandle;
 	UNICODE_STRING SearchPaths;
 	UNICODE_STRING ApplicationName;
 	UNICODE_STRING CommandLine;
-	void *EnvironmentBlock;
+	void* EnvironmentBlock;
 	unsigned long Unknown[9];
 	UNICODE_STRING Unknown3;
 	UNICODE_STRING Unknown4;
 	UNICODE_STRING Unknown5;
 	UNICODE_STRING Unknown6;
-	} PROCESS_PARAMETERS;
+} PROCESS_PARAMETERS;
 
 typedef struct {
 	unsigned long AllocationSize;
 	unsigned long Unknown1;
-	void *ProcessHinstance;
-	void *ListDlls;
-	PROCESS_PARAMETERS *ProcessParameters;
+	void* ProcessHinstance;
+	void* ListDlls;
+	PROCESS_PARAMETERS* ProcessParameters;
 	unsigned long Unknown2;
-	void *Heap;
-	} PEB;
+	void* Heap;
+} PEB;
 
 typedef struct {
 	unsigned int ExitStatus;
-	PEB *PebBaseAddress;
+	PEB* PebBaseAddress;
 	unsigned int AffinityMask;
 	unsigned int BasePriority;
 	unsigned long UniqueProcessId;
 	unsigned long InheritedFromUniqueProcessId;
-	} PROCESS_BASIC_INFORMATION;
-
+} PROCESS_BASIC_INFORMATION;
 
 class TSMemoryAPI
-	{
-	public:
-		TSMemoryAPI(void);
-		~TSMemoryAPI(void);
+{
+public:
+	TSMemoryAPI(void);
+	~TSMemoryAPI(void);
 	CMgAsmBase tsasm;
 	CMgDisasmBase tsdsm;
-	public:
-		bool TSValueTypeToData(int type,wchar_t *retstr,double dvalue=NULL,float fvalue=NULL,int ivalue=0,wchar_t *svalue=NULL,int type1=0);
-		bool TSFindData(LONG hwnd,wchar_t * addr_range,wchar_t *data,wchar_t *retstr,bool threadtype=false);
-		bool TSFindDouble(LONG hwnd,wchar_t * addr_range,wchar_t *retstr,double double_value_min,double double_value_max,bool threadtype=false);
-		bool TSFindFloat(LONG hwnd,wchar_t * addr_range,wchar_t *retstr,FLOAT float_value_min, FLOAT float_value_max,bool threadtype=false);
-		bool TSFindInt(LONG hwnd,wchar_t * addr_range,wchar_t *retstr,LONG int_value_min, LONG int_value_max,LONG type,bool threadtype=false);
-		bool TSFindString(LONG hwnd,wchar_t * addr_range,wchar_t *retstr,wchar_t*string_value,LONG type,bool threadtype=false);
-		bool TSReadData(LONG hwnd,wchar_t*addr,wchar_t *retstr,LONG len);
-		bool TSReadDouble(LONG hwnd,wchar_t*addr,double &dvalue,float &fvalue,int type=0); //type0:DOUBLE,1:FLOAT
-		bool TSReadInt(LONG hwnd,wchar_t*addr,int &ivalue,short &svalue,BYTE &bvalue,int type);
-		bool TSReadString(LONG hwnd,wchar_t*addr,wchar_t *retstr,LONG len,int type);
-		bool TSTerminateProcess(LONG pid);
-		bool TSVirtualAllocEx(LONG hwnd,LONG &addr,LONG size,LONG type);
-		bool TSVirtualFreeEx(LONG hwnd,LONG addr);
-		bool TSWriteData(LONG hwnd,wchar_t * addr,wchar_t *data);
-		bool TSWriteDouble(LONG hwnd,wchar_t *addr,DOUBLE dvalue=0,FLOAT fvlaue=0);
-		bool TSWriteInt(LONG hwnd,wchar_t *addr,int ivalue=0,short svalue=0,BYTE bvalue=0);
-		bool TSWriteString(LONG hwnd,wchar_t*addr,wchar_t* strvalue,LONG type);
-		bool TSGetCmdLine(LONG hwnd,wchar_t *retstr);
-		bool TSAsmAdd(wchar_t*asm_ins);
-		bool TSAsmCall(LONG hwnd,LONG mode);
-		bool TSAsmClear();
-		bool TSAsmCode(LONG base_addr,wchar_t *retstr);
-		bool TSAssemble(wchar_t * asm_code,LONG base_addr,LONG is_upper,wchar_t *retstr);
-		bool TSFreeProcessMemory(LONG hwnd);
-	private:
+public:
+	bool TSValueTypeToData(int type, wchar_t* retstr, double dvalue = NULL, float fvalue = NULL, int ivalue = 0, wchar_t* svalue = NULL, int type1 = 0);
+	bool TSFindData(LONG hwnd, wchar_t* addr_range, wchar_t* data, wchar_t* retstr, bool threadtype = false);
+	bool TSFindDouble(LONG hwnd, wchar_t* addr_range, wchar_t* retstr, double double_value_min, double double_value_max, bool threadtype = false);
+	bool TSFindFloat(LONG hwnd, wchar_t* addr_range, wchar_t* retstr, FLOAT float_value_min, FLOAT float_value_max, bool threadtype = false);
+	bool TSFindInt(LONG hwnd, wchar_t* addr_range, wchar_t* retstr, LONG int_value_min, LONG int_value_max, LONG type, bool threadtype = false);
+	bool TSFindString(LONG hwnd, wchar_t* addr_range, wchar_t* retstr, wchar_t* string_value, LONG type, bool threadtype = false);
+	bool TSReadData(LONG hwnd, wchar_t* addr, wchar_t* retstr, LONG len);
+	bool TSReadDouble(LONG hwnd, wchar_t* addr, double& dvalue, float& fvalue, int type = 0); //type0:DOUBLE,1:FLOAT
+	bool TSReadInt(LONG hwnd, wchar_t* addr, int& ivalue, short& svalue, BYTE& bvalue, int type);
+	bool TSReadString(LONG hwnd, wchar_t* addr, wchar_t* retstr, LONG len, int type);
+	bool TSTerminateProcess(LONG pid);
+	bool TSVirtualAllocEx(LONG hwnd, LONG& addr, LONG size, LONG type);
+	bool TSVirtualFreeEx(LONG hwnd, LONG addr);
+	bool TSWriteData(LONG hwnd, wchar_t* addr, wchar_t* data);
+	bool TSWriteDouble(LONG hwnd, wchar_t* addr, DOUBLE dvalue = 0, FLOAT fvlaue = 0);
+	bool TSWriteInt(LONG hwnd, wchar_t* addr, int ivalue = 0, short svalue = 0, BYTE bvalue = 0);
+	bool TSWriteString(LONG hwnd, wchar_t* addr, wchar_t* strvalue, LONG type);
+	bool TSGetCmdLine(LONG hwnd, wchar_t* retstr);
+	bool TSAsmAdd(wchar_t* asm_ins);
+	bool TSAsmCall(LONG hwnd, LONG mode);
+	bool TSAsmClear();
+	bool TSAsmCode(LONG base_addr, wchar_t* retstr);
+	bool TSAssemble(wchar_t* asm_code, LONG base_addr, LONG is_upper, wchar_t* retstr);
+	bool TSFreeProcessMemory(LONG hwnd);
+private:
 	DWORD nPid;
 	int retstringlen;//线程函数返回地址的长度
 	CMgAsmBase::t_asmmodel  am;
 	std::string asmcodearry;//存储AsmAdd的指令
 	char Asmcalladdr[MAX_PATH]; //记录保存CALL指令
 	LPVOID allocatememory;
-	
-	
+
+
 	DWORD TSGetFindDataAddr(wchar_t* strs, DWORD pid);//读取要读写的多层级别的地址指针
-	bool TSGetaddr_range(wchar_t* strs,LONG &begin,LONG &end,DWORD *addr_range,int &nconut); //读取要找的地址集合
-	bool TSGetDataValue(wchar_t* strs,DWORD *Data_range,int &nconut);
+	bool TSGetaddr_range(wchar_t* strs, LONG& begin, LONG& end, DWORD* addr_range, int& nconut); //读取要找的地址集合
+	bool TSGetDataValue(wchar_t* strs, DWORD* Data_range, int& nconut);
 	//void FindDataThread(void *para);
-	bool GetFindaddr(HANDLE hprocess,PVOID  lpbegin,PVOID lpend,DWORD *ibegin,DWORD *ipend,int &ncount);
+	bool GetFindaddr(HANDLE hprocess, PVOID  lpbegin, PVOID lpend, DWORD* ibegin, DWORD* ipend, int& ncount);
 
-	DWORD GetCallstartData(DWORD Allocaddr,DWORD * startaddr,char *code=NULL);//获取CALL地址前的汇编指令
-	};
+	DWORD GetCallstartData(DWORD Allocaddr, DWORD* startaddr, char* code = NULL);//获取CALL地址前的汇编指令
+};

+ 106 - 106
天使插件源码/TSPlug/TSMessage.h

@@ -22,7 +22,7 @@
 #define TS_MBUTTONDOWN        (TS_MESSAGEBASE +  28)
 #define TS_MBUTTONUP          (TS_MESSAGEBASE +  29)
 #define TS_MOUSEWHEEL         (TS_MESSAGEBASE +  30)
-			 
+
 #define TS_FINDPIC            (TS_MESSAGEBASE +  40)
 #define TS_FINDCOLOR          (TS_MESSAGEBASE +  41)
 #define TS_GETCOLOR			  (TS_MESSAGEBASE +  42)
@@ -174,7 +174,7 @@
 
 struct ST_MSGBASE
 {
-   
+
 };
 
 #define  DICTLENGMAX     256*11 //单个字信息最大长度
@@ -187,49 +187,49 @@ typedef struct __WriteMemoryInfo
 	ULONG BaseAddress;
 	ULONG BufferSize;
 	__WriteMemoryInfo()
-		{
-		Pid=0;
-		BaseAddress=0;
-		memset(Pbuff,0,10);
-		BufferSize=0;
-		}
-}WriteMemoryInfo,*PWriteMemoryInfo;
+	{
+		Pid = 0;
+		BaseAddress = 0;
+		memset(Pbuff, 0, 10);
+		BufferSize = 0;
+	}
+}WriteMemoryInfo, * PWriteMemoryInfo;
 
 typedef struct _MYDICTINFO   //记录当前字库每一个字体信息
-	{
+{
 	char mydistchar[16];//记录当前点阵对应的字体信息
 	int strwide;//记录点阵字宽
 	int strhight;
 	short nstrcount;//记录当前这个字的点阵数量
 	short nstrvalue[MAX_PATH];//记录前点阵整形制
 	_MYDICTINFO()
-		{
-		memset(this,0,sizeof(_MYDICTINFO));
-		}
-	}MYDICTINFO, *pMyDictInfo;
+	{
+		memset(this, 0, sizeof(_MYDICTINFO));
+	}
+}MYDICTINFO, * pMyDictInfo;
 
-struct ST_TSBIND:ST_MSGBASE
+struct ST_TSBIND :ST_MSGBASE
 {
 	DWORD key;
 	DWORD mouse;
 	DWORD display;
 	HWND hwnd;
 	ST_TSBIND()
-    {
-    hwnd=0;
-	key=NULL;
-	mouse=NULL;
-	display=NULL;
-    }
+	{
+		hwnd = 0;
+		key = NULL;
+		mouse = NULL;
+		display = NULL;
+	}
 };
 
-struct ST_TSFINDPIC:ST_MSGBASE
+struct ST_TSFINDPIC :ST_MSGBASE
 {
 	int left;
 	int top;
 	int right;
 	int bottom;
-	wchar_t path[MAX_PATH*4];
+	wchar_t path[MAX_PATH * 4];
 	wchar_t color_format[MAX_PATH];
 	int colorOffset;
 	double simi;
@@ -238,27 +238,27 @@ struct ST_TSFINDPIC:ST_MSGBASE
 	long y;
 	int pictype;
 	int  ret;
-	wchar_t *retstring;
+	wchar_t* retstring;
 	bool IsDisplayDead;
 	int sleeptime;
 	ST_TSFINDPIC()
-    {
-	sleeptime=0;
-	IsDisplayDead=false;
-	memset(path,0,512);
-	memset(color_format,0,16);
- //   hwnd=0;
-	//key=NULL;
-	//mouse=NULL;
-	//display=NULL;
-    }
+	{
+		sleeptime = 0;
+		IsDisplayDead = false;
+		memset(path, 0, 512);
+		memset(color_format, 0, 16);
+		//   hwnd=0;
+		   //key=NULL;
+		   //mouse=NULL;
+		   //display=NULL;
+	}
 };
 
-typedef struct tagWNDINFO 
-	{
-	DWORD dwProcessId; 
-	HWND hWnd; 
-	}WNDINFO, *LPWNDINFO;
+typedef struct tagWNDINFO
+{
+	DWORD dwProcessId;
+	HWND hWnd;
+}WNDINFO, * LPWNDINFO;
 
 
 struct CMessageData	           //数据共享结构体
@@ -279,11 +279,11 @@ struct CMessageData	           //
 	DWORD message;
 	DWORD wparam;
 	DWORD lparam;
-    pMyDictInfo MyDictCount[20]; //存储当前所有字库,默认最大字库个数为20个
+	pMyDictInfo MyDictCount[20]; //存储当前所有字库,默认最大字库个数为20个
 	int nMaxStrHight[20]; //记录每个字库中,最高的字高
 	int nMyDictCountsize[20]; //记录每个字库的数量
 	int NowUsingDictIndex;//记录当前正在使用的字库下标
-	wchar_t RetString[MAX_PATH*100];
+	wchar_t RetString[MAX_PATH * 100];
 	bool IsNpProtect;
 	bool isgraphicprotect;//是否开启图色防检测
 	wchar_t SetDictPwdString[MAX_PATH];
@@ -298,65 +298,65 @@ struct CMessageData	           //
 	CMessageData()
 	{
 		//memset(ColorDataInfo,0,sizeof(ColorDataInfo));
-		m_hwnd=NULL;
-		RemodeDLLMode=NULL;
-		Isdxkmprotect=false;
-		Isdxantiapi=false;
-		isgraphicprotect=false;
-		NowUsingDictIndex=-1;
-		SleepTime=0;
-		isHSProtect=false;
-		InjectType=-1;
-		isInject=false;
-		isRead=false;
-		isBind=false;
-		ispichook=false;
-		iskeyboardhook=false;
-		ismousehook=false;
-		IsNpProtect=false;
-		InjectHwnd=NULL;
-		message=0;
-		wparam=0;
-		lparam=0;
-		memset(SetDictPwdString,0,MAX_PATH);
-		memset(SetPicPwdString,0,MAX_PATH);
-		::wmemset(setpath,0,MAX_PATH);
-		::wmemset(eventName,0,MAX_PATH);
-		::wmemset(RetString,0,MAX_PATH*100-1);
-		memset(pmsg,0,2048);
-		memset(MyDictCount,0,20);	//存储字库
-		memset(nMaxStrHight,0,20);//记录每个字库中,最高的字高.
-		memset(nMyDictCountsize,0,20);//记录每个字库的数量
-		NowUsingDictIndex=0;
+		m_hwnd = NULL;
+		RemodeDLLMode = NULL;
+		Isdxkmprotect = false;
+		Isdxantiapi = false;
+		isgraphicprotect = false;
+		NowUsingDictIndex = -1;
+		SleepTime = 0;
+		isHSProtect = false;
+		InjectType = -1;
+		isInject = false;
+		isRead = false;
+		isBind = false;
+		ispichook = false;
+		iskeyboardhook = false;
+		ismousehook = false;
+		IsNpProtect = false;
+		InjectHwnd = NULL;
+		message = 0;
+		wparam = 0;
+		lparam = 0;
+		memset(SetDictPwdString, 0, MAX_PATH);
+		memset(SetPicPwdString, 0, MAX_PATH);
+		::wmemset(setpath, 0, MAX_PATH);
+		::wmemset(eventName, 0, MAX_PATH);
+		::wmemset(RetString, 0, MAX_PATH * 100 - 1);
+		memset(pmsg, 0, 2048);
+		memset(MyDictCount, 0, 20);	//存储字库
+		memset(nMaxStrHight, 0, 20);//记录每个字库中,最高的字高.
+		memset(nMyDictCountsize, 0, 20);//记录每个字库的数量
+		NowUsingDictIndex = 0;
 		// tt.clear();
-	} 
+	}
 	void reset()
 	{
 		//memset(ColorDataInfo,0,sizeof(ColorDataInfo));
-		m_hwnd=NULL;
-		Isdxkmprotect=false;
-		Isdxantiapi=false;
-		isgraphicprotect=false;
-		NowUsingDictIndex=-1;
-		SleepTime=0;
-		isHSProtect=false;
-		InjectType=-1;
-		isInject=false;
-		isRead=false;
-		isBind=false;
-		ispichook=false;
-		iskeyboardhook=false;
-		ismousehook=false;
-		IsNpProtect=false;
-		InjectHwnd=NULL;
-		message=0;
-		wparam=0;
-		lparam=0;
-		memset(SetDictPwdString,0,MAX_PATH);
-		memset(SetPicPwdString,0,MAX_PATH);
-		::wmemset(setpath,0,MAX_PATH);
-		::wmemset(eventName,0,MAX_PATH);
-		::wmemset(RetString,0,MAX_PATH*100);
+		m_hwnd = NULL;
+		Isdxkmprotect = false;
+		Isdxantiapi = false;
+		isgraphicprotect = false;
+		NowUsingDictIndex = -1;
+		SleepTime = 0;
+		isHSProtect = false;
+		InjectType = -1;
+		isInject = false;
+		isRead = false;
+		isBind = false;
+		ispichook = false;
+		iskeyboardhook = false;
+		ismousehook = false;
+		IsNpProtect = false;
+		InjectHwnd = NULL;
+		message = 0;
+		wparam = 0;
+		lparam = 0;
+		memset(SetDictPwdString, 0, MAX_PATH);
+		memset(SetPicPwdString, 0, MAX_PATH);
+		::wmemset(setpath, 0, MAX_PATH);
+		::wmemset(eventName, 0, MAX_PATH);
+		::wmemset(RetString, 0, MAX_PATH * 100);
 		//::memset(pmsg,0,2048);
 	}
 };
@@ -365,24 +365,24 @@ struct CMessageData	           //
 class CShareMemory
 {
 public:
-// 构造函数和析构函数
-	CShareMemory(const char * pszMapName, int nFileSize = 0, BOOL bServer = FALSE);
+	// 构造函数和析构函数
+	CShareMemory(const char* pszMapName, int nFileSize = 0, BOOL bServer = FALSE);
 	~CShareMemory();
-// 属性
+	// 属性
 	LPVOID GetBuffer() const { return  m_pBuffer; }
 	HANDLE	m_hFileMap;
-// 实现
+	// 实现
 private:
 	LPVOID	m_pBuffer;
 };
 
-inline CShareMemory::CShareMemory(const char * pszMapName, 
-			int nFileSize, BOOL bServer) : m_hFileMap(NULL), m_pBuffer(NULL)
+inline CShareMemory::CShareMemory(const char* pszMapName,
+	int nFileSize, BOOL bServer) : m_hFileMap(NULL), m_pBuffer(NULL)
 {
-	if(bServer)
+	if (bServer)
 	{
 		// 创建一个内存映射文件对象
-		m_hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE, 
+		m_hFileMap = CreateFileMappingA(INVALID_HANDLE_VALUE,
 			NULL, PAGE_READWRITE, 0, nFileSize, pszMapName);
 	}
 	else
@@ -390,7 +390,7 @@ inline CShareMemory::CShareMemory(const char * pszMapName,
 		// 打开一个内存映射文件对象
 		m_hFileMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, pszMapName);
 	}
-	
+
 	// 映射它到内存,取得共享内存的首地址
 	m_pBuffer = (LPBYTE)MapViewOfFile(
 		m_hFileMap,
@@ -398,7 +398,7 @@ inline CShareMemory::CShareMemory(const char * pszMapName,
 		0,
 		0,
 		0
-		);
+	);
 }
 
 inline CShareMemory::~CShareMemory()

+ 26 - 26
天使插件源码/TSPlug/TSPlug.cpp

@@ -13,21 +13,21 @@
 // 用于确定 DLL 是否可由 OLE 卸载
 STDAPI DllCanUnloadNow(void)
 {
-    return _AtlModule.DllCanUnloadNow();
+	return _AtlModule.DllCanUnloadNow();
 }
 
 
 // 返回一个类工厂以创建所请求类型的对象
 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
 {
-    return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
+	return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
 }
 
 // DllRegisterServer - 将项添加到系统注册表
 STDAPI DllRegisterServer(void)
 {
-    // 注册对象、类型库和类型库中的所有接口
-    HRESULT hr = _AtlModule.DllRegisterServer();
+	// 注册对象、类型库和类型库中的所有接口
+	HRESULT hr = _AtlModule.DllRegisterServer();
 	return hr;
 }
 
@@ -42,29 +42,29 @@ STDAPI DllUnregisterServer(void)
 //              项。	
 STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
 {
-    HRESULT hr = E_FAIL;
-    static const wchar_t szUserSwitch[] = _T("user");
+	HRESULT hr = E_FAIL;
+	static const wchar_t szUserSwitch[] = _T("user");
 
-    if (pszCmdLine != NULL)
-    {
-    	if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
-    	{
-    		AtlSetPerUserRegistration(true);
-    	}
-    }
+	if (pszCmdLine != NULL)
+	{
+		if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
+		{
+			AtlSetPerUserRegistration(true);
+		}
+	}
 
-    if (bInstall)
-    {	
-    	hr = DllRegisterServer();
-    	if (FAILED(hr))
-    	{	
-    		DllUnregisterServer();
-    	}
-    }
-    else
-    {
-    	hr = DllUnregisterServer();
-    }
+	if (bInstall)
+	{
+		hr = DllRegisterServer();
+		if (FAILED(hr))
+		{
+			DllUnregisterServer();
+		}
+	}
+	else
+	{
+		hr = DllUnregisterServer();
+	}
 
-    return hr;
+	return hr;
 }

+ 2 - 2
天使插件源码/TSPlug/TSPlug.vcxproj

@@ -18,13 +18,13 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <PlatformToolset>v110</PlatformToolset>
+    <PlatformToolset>v143</PlatformToolset>
     <UseOfAtl>Static</UseOfAtl>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <PlatformToolset>v110</PlatformToolset>
+    <PlatformToolset>v143</PlatformToolset>
     <UseOfAtl>Static</UseOfAtl>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 297 - 297
天使插件源码/TSPlug/TSPlugInterFace.cpp


+ 13 - 13
天使插件源码/TSPlug/TSPlugInterFace.h

@@ -22,16 +22,16 @@ class ATL_NO_VTABLE CTSPlugInterFace :
 public:
 	CTSPlugInterFace()
 	{
-		  
+
 	}
 
-DECLARE_REGISTRY_RESOURCEID(IDR_TSPLUGINTERFACE)
+	DECLARE_REGISTRY_RESOURCEID(IDR_TSPLUGINTERFACE)
 
 
-BEGIN_COM_MAP(CTSPlugInterFace)
-	COM_INTERFACE_ENTRY(ITSPlugInterFace)
-	COM_INTERFACE_ENTRY(IDispatch)
-END_COM_MAP()
+	BEGIN_COM_MAP(CTSPlugInterFace)
+		COM_INTERFACE_ENTRY(ITSPlugInterFace)
+		COM_INTERFACE_ENTRY(IDispatch)
+	END_COM_MAP()
 
 
 
@@ -47,7 +47,7 @@ END_COM_MAP()
 	}
 
 public:
-	DXBind gDxObj; 
+	DXBind gDxObj;
 	TSWindowsAPI  gWindowObj;
 	TSMemoryAPI   gMemoryObj;
 	STDMETHOD(BindWindow)(LONG hwnd, BSTR display, BSTR mouse, BSTR keypad, LONG mode, LONG* nret);
@@ -68,7 +68,7 @@ public:
 	STDMETHOD(GetColor)(LONG x, LONG y, BSTR* RetStrColor);
 	STDMETHOD(GetCursorShape)(BSTR* RetCursorShape);
 	STDMETHOD(SetPath)(BSTR path, LONG* nret);
-	STDMETHOD(TSGuardProtect)(LONG enable, BSTR type,LONG* nret);
+	STDMETHOD(TSGuardProtect)(LONG enable, BSTR type, LONG* nret);
 	STDMETHOD(KeyPressStr)(BSTR key_str, LONG delay, LONG* nret);
 	STDMETHOD(SendString)(LONG hwnd, BSTR str, LONG* nret);
 	STDMETHOD(SendString2)(LONG hwnd, BSTR str, LONG* nret);
@@ -83,7 +83,7 @@ public:
 	STDMETHOD(WheelDown)(LONG* nret);
 	STDMETHOD(WheelUp)(LONG* nret);
 	STDMETHOD(Capture)(LONG x1, LONG y1, LONG x2, LONG y2, BSTR file, LONG* nret);
-	STDMETHOD(CaptureJpg)(LONG x1, LONG y1, LONG x2, LONG y2,BSTR file, LONG* nret);
+	STDMETHOD(CaptureJpg)(LONG x1, LONG y1, LONG x2, LONG y2, BSTR file, LONG* nret);
 	STDMETHOD(CapturePng)(LONG x1, LONG y1, LONG x2, LONG y2, BSTR file, LONG* nret);
 	STDMETHOD(LockInput)(LONG lock, LONG* nret);
 	STDMETHOD(Ocr)(LONG x1, LONG y1, LONG x2, LONG y2, BSTR color_format, FLOAT sim, BSTR* retstr);
@@ -109,10 +109,10 @@ public:
 	STDMETHOD(EnumWindowByProcess)(BSTR process_name, BSTR title, BSTR class_name, LONG filter, BSTR* retstring);
 	STDMETHOD(EnumProcess)(BSTR name, BSTR* retstring);
 	STDMETHOD(ClientToScreen)(LONG ClientToScreen, VARIANT* x, VARIANT* y, LONG* bret);
-	STDMETHOD(FindWindow)(BSTR class_name,BSTR title,LONG* rethwnd);
+	STDMETHOD(FindWindow)(BSTR class_name, BSTR title, LONG* rethwnd);
 	STDMETHOD(FindWindowByProcess)(BSTR process_name, BSTR class_name, BSTR title, LONG* rethwnd);
 	STDMETHOD(FindWindowByProcessId)(LONG process_id, BSTR class_name, BSTR title, LONG* rethwnd);
-	STDMETHOD(FindWindowEx)(LONG parent,BSTR class_name,BSTR title,LONG* rethwnd);
+	STDMETHOD(FindWindowEx)(LONG parent, BSTR class_name, BSTR title, LONG* rethwnd);
 	STDMETHOD(GetClientRect)(LONG hwnd, VARIANT* x1, VARIANT* y1, VARIANT* x2, VARIANT* y2, LONG* nret);
 	STDMETHOD(GetClientSize)(LONG hwnd, VARIANT* width, VARIANT* height, LONG* nret);
 	STDMETHOD(GetForegroundFocus)(LONG* rethwnd);
@@ -129,7 +129,7 @@ public:
 	STDMETHOD(GetWindowState)(LONG hwnd, LONG flag, LONG* rethwnd);
 	STDMETHOD(GetWindowTitle)(LONG hwnd, BSTR* rettitle);
 	STDMETHOD(MoveWindow)(LONG hwnd, LONG x, LONG y, LONG* nret);
-	STDMETHOD(ScreenToClient)(LONG hwnd, VARIANT* x, VARIANT* y,LONG* nret);
+	STDMETHOD(ScreenToClient)(LONG hwnd, VARIANT* x, VARIANT* y, LONG* nret);
 	STDMETHOD(SendPaste)(LONG hwnd, LONG* nret);
 	STDMETHOD(SetClientSize)(LONG hwnd, LONG width, LONG hight, LONG* nret);
 	STDMETHOD(SetWindowState)(LONG hwnd, LONG flag, LONG* nret);
@@ -201,7 +201,7 @@ public:
 	STDMETHOD(EnableRealKeypad)(ULONG enable, ULONG* nret);
 	STDMETHOD(MoveToEx)(ULONG x, ULONG y, ULONG w, ULONG h, BSTR* retstring);
 	STDMETHOD(CheckUAC)(ULONG* nret);
-	STDMETHOD(SetUAC)(ULONG enable,ULONG* nret);
+	STDMETHOD(SetUAC)(ULONG enable, ULONG* nret);
 	STDMETHOD(WaitKey)(ULONG vk_code, ULONG time_out, ULONG* nret);
 	STDMETHOD(FindMultiColor)(ULONG x1, ULONG y1, ULONG x2, ULONG y2, BSTR first_color, BSTR offset_color, DOUBLE sim, ULONG dir, VARIANT* intX, VARIANT* intY, ULONG* nret);
 	STDMETHOD(FindMultiColorEx)(ULONG x1, ULONG y1, ULONG x2, ULONG y2, BSTR first_color, BSTR offset_color, DOUBLE sim, ULONG dir, BSTR* retstring);

+ 2 - 2
天使插件源码/TSPlug/TSPlugPS.vcxproj

@@ -17,12 +17,12 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <PlatformToolset>v110</PlatformToolset>
+    <PlatformToolset>v143</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
     <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <PlatformToolset>v110</PlatformToolset>
+    <PlatformToolset>v143</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 367 - 368
天使插件源码/TSPlug/TSRuntime.cpp


+ 20 - 20
天使插件源码/TSPlug/TSRuntime.h

@@ -13,7 +13,7 @@
 #define TSPROTECT_HIDE    0x00000001L  //"phide [pid]" : 保护指定进程以及进程内的窗口不被非法访问.默认保护当前进程.(此模式需要加载驱动,目前仅支持32位系统)
 #define TSPROTECT_HIDE2    0x00000002L	//"phide2 [pid]" : 同phide. 只是进程不隐藏(可在任务管理器中操作)
 
-typedef void *HMEMORYLOADER;
+typedef void* HMEMORYLOADER;
 void MemoryFreeLibrary(HMEMORYLOADER mod);
 class DXBind;
 class TSRuntime
@@ -22,11 +22,11 @@ public:
 	static MyMouseNamespace    g_Mouse;
 	static MyKeyboardNamespace g_KeyBoard;
 	static DXBind g_DxObj;  //DX后台操作对象,全局唯一,就是一个com只能绑定一个窗口,多窗口就要多实例化几次了          
-	static CMessageData *pData;	      //定义为静态类成员,方便保存共享数据指针
+	static CMessageData* pData;	      //定义为静态类成员,方便保存共享数据指针
 	static HANDLE MapViewThread;      //保存检测共享内存线程,方便卸载时调用TerminateThread结束线程
 	static DWORD m_displayMode;
 	static DWORD m_dwExStyle;
-	static wchar_t RetStr[MAX_PATH*4];
+	static wchar_t RetStr[MAX_PATH * 4];
 	static wchar_t  SetPath[MAX_PATH];
 	static LPOLESTR KeyPressCharMap[0x100];	  //256个键位
 	static BYTE VirtualToASCIIMap[0x100];  //256个键位
@@ -46,14 +46,14 @@ public:
 	static int nMyDictCountsize[20]; //记录每个字库的数量
 	static int NowUsingDictIndex;//记录当前正在使用字库的下标
 	static COLORREF pLoadstrBuffer[11][MAX_PATH];//存储字库点阵还原图片颜色矩阵COLORREF
-	static char bytestr[1024*3]; //存储点阵二进制信息最大存储为250*11
+	static char bytestr[1024 * 3]; //存储点阵二进制信息最大存储为250*11
 	static bool IsVirtualProtectEx;//是否驱动模式远程修改注入进程的页面保护属性
 	static HWND hookHwnd;//记录要注入的窗口句柄
 	static HMEMORYLOADER myUser32module;
 	static HMEMORYLOADER mykernel32module;
 	static bool IsInitialmyUser32module;
 	static bool IsInitialmykernel32module;
-	static wchar_t membstr[MAX_PATH*400];
+	static wchar_t membstr[MAX_PATH * 400];
 	static bool IsShowErrorMsg;
 	static bool IsNpProtect;
 	static bool IsWin7X64;
@@ -72,29 +72,29 @@ public:
 	//static CComBSTR newbstr;
 public:
 	static HWND  GetProcessMainWnd(DWORD  dwProcessId);	 //获取自身窗口句柄
-	static void getMode(wchar_t *mouse,wchar_t *key,wchar_t *display,DWORD &dwMouse,DWORD &dwKey,DWORD &dwDisplay);
-    static void my_split(TCHAR* sourcestr, TCHAR *oldstr, TCHAR (*temp)[28], int &rlen);
-	static void add_log( const char * fmt, ... );
+	static void getMode(wchar_t* mouse, wchar_t* key, wchar_t* display, DWORD& dwMouse, DWORD& dwKey, DWORD& dwDisplay);
+	static void my_split(TCHAR* sourcestr, TCHAR* oldstr, TCHAR(*temp)[28], int& rlen);
+	static void add_log(const char* fmt, ...);
 	static int  InitialWindowsVersion();//获取系统版本
-	static bool EnablePrivilege(LPCTSTR pszPrivName, bool fEnable );
+	static bool EnablePrivilege(LPCTSTR pszPrivName, bool fEnable);
 	static void initial();
 	static bool  MyWriteMemory(IN PWriteMemoryInfo WriteInfo);
-	static int VipLogin(wchar_t *regcode,int type,bool isvip=true);
-	static bool GetComPath(TCHAR * Path);
-	static bool StartProtect(long enable,long type,int Pid=0);
+	static int VipLogin(wchar_t* regcode, int type, bool isvip = true);
+	static bool GetComPath(TCHAR* Path);
+	static bool StartProtect(long enable, long type, int Pid = 0);
 	static void InitKeyPressCharMap();//初始化KeyPressCharMap
 	static void InitVirtualToASCIIMap();
 	static void InitKeyMap();
 	static void InitKeyPressMap();
 	static int retrunLparamDown(int key);
-	static BOOL MByteToWChar(LPCSTR lpcszStr,LPWSTR lpwszStr,DWORD dwSize);
-	static BOOL WCharToMByte(LPCWSTR lpcwszStr,LPSTR lpszStr,DWORD dwSize);
-	static DWORD GetPassR3HookFuntionAddr(char *modename,char*funname);
-	static HMODULE GetRemoteModuleHandle(const wchar_t *module, short nPID);//获取指定进程ID的DLL模块句柄
-	static HMODULE TSRuntime::GetRemoteModuleBase(const wchar_t *module, short nPID);
-	static DWORD GetRemoteModuleBaseAddr(const wchar_t *module, short nPID);//获取指定进程ID的DLL模块地址
-	static bool GetRemoteModulePath(const wchar_t *module, short nPID,wchar_t *modulepath);//获取指定进程ID的DLL模块路径
-	static FARPROC GetRemoteProcAddress( wchar_t *module, const char *func, short nPID);//获取指定进程ID的DLL模块函数的地址
+	static BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize);
+	static BOOL WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize);
+	static DWORD GetPassR3HookFuntionAddr(char* modename, char* funname);
+	static HMODULE GetRemoteModuleHandle(const wchar_t* module, short nPID);//获取指定进程ID的DLL模块句柄
+	static HMODULE TSRuntime::GetRemoteModuleBase(const wchar_t* module, short nPID);
+	static DWORD GetRemoteModuleBaseAddr(const wchar_t* module, short nPID);//获取指定进程ID的DLL模块地址
+	static bool GetRemoteModulePath(const wchar_t* module, short nPID, wchar_t* modulepath);//获取指定进程ID的DLL模块路径
+	static FARPROC GetRemoteProcAddress(wchar_t* module, const char* func, short nPID);//获取指定进程ID的DLL模块函数的地址
 	static bool MyLoadLibrary();
 private:
 	TSRuntime(void);

+ 52 - 52
天使插件源码/TSPlug/TSVIPHookFuntion.h

@@ -75,71 +75,71 @@
 //77D2A93A __stdcall NtUserCallTwoParam(x, x, x)
 #define	 NtUserCallTwoParam_WIN8X64Offset  0x8012
 
-DWORD   EAX_NtUserCallOneParam=0;
-DWORD   EAX_NtUserGetThreadState=0;
-DWORD   EAX_NtUserGetKeyState=0;
-DWORD   EAX_NtUserGetAsyncKeyState=0;
-DWORD   EAX_NtUserCallTwoParam=0;
-
-DWORD   NtUserCallOneParamRet=0;
-DWORD   NtUserGetThreadStateRet=0;
-DWORD   NtUserGetKeyStateRet=0;
-DWORD   NtUserGetAsyncKeyStateRet=0;
-DWORD   NtUserCallTwoParamRet=0;
-
-BYTE NtUserCallOneParamUnhookByte[5]={0};
-BYTE NtUserGetThreadStateUnhookByte[5]={0};
-BYTE NtUserGetKeyStateUnhookByte[5]={0};
-BYTE NtUserGetAsyncKeyStateUnhookByte[5]={0};
-BYTE NtUserCallTwoParamUnhookByte[5]={0};
-
-void VIPHookandUnhookAPI(void *para);
+DWORD   EAX_NtUserCallOneParam = 0;
+DWORD   EAX_NtUserGetThreadState = 0;
+DWORD   EAX_NtUserGetKeyState = 0;
+DWORD   EAX_NtUserGetAsyncKeyState = 0;
+DWORD   EAX_NtUserCallTwoParam = 0;
+
+DWORD   NtUserCallOneParamRet = 0;
+DWORD   NtUserGetThreadStateRet = 0;
+DWORD   NtUserGetKeyStateRet = 0;
+DWORD   NtUserGetAsyncKeyStateRet = 0;
+DWORD   NtUserCallTwoParamRet = 0;
+
+BYTE NtUserCallOneParamUnhookByte[5] = { 0 };
+BYTE NtUserGetThreadStateUnhookByte[5] = { 0 };
+BYTE NtUserGetKeyStateUnhookByte[5] = { 0 };
+BYTE NtUserGetAsyncKeyStateUnhookByte[5] = { 0 };
+BYTE NtUserCallTwoParamUnhookByte[5] = { 0 };
+
+void VIPHookandUnhookAPI(void* para);
 
 __declspec(naked) ULONG  __stdcall NtUserCallOneParam(DWORD Param, DWORD Routine)
-	{
-	_asm{
-			mov eax,EAX_NtUserCallOneParam
-			//mov eax,0x1143
-			jmp NtUserCallOneParamRet
-			ret
-		}	
+{
+	_asm {
+		mov eax, EAX_NtUserCallOneParam
+		//mov eax,0x1143
+		jmp NtUserCallOneParamRet
+		ret
 	}
+}
 
 __declspec(naked) ULONG_PTR  __stdcall NtUserGetThreadState(DWORD 	Routine)
-	{
-	_asm{
-			mov eax,EAX_NtUserGetThreadState
-			jmp NtUserGetThreadStateRet
-			ret
-		}	
+{
+	_asm {
+		mov eax, EAX_NtUserGetThreadState
+		jmp NtUserGetThreadStateRet
+		ret
 	}
+}
 
 __declspec(naked) SHORT  __stdcall NtUserGetKeyState(int nVirtKey)
-	{
-	_asm{
-			mov eax,EAX_NtUserGetKeyState
-			jmp NtUserGetKeyStateRet
-			ret
-		}	
+{
+	_asm {
+		mov eax, EAX_NtUserGetKeyState
+		jmp NtUserGetKeyStateRet
+		ret
 	}
+}
 
 __declspec(naked) SHORT  __stdcall NtUserGetAsyncKeyState(int nVirtKey)
-	{
-	_asm{
-			mov eax,EAX_NtUserGetAsyncKeyState
-			jmp NtUserGetAsyncKeyStateRet
-			ret
-		}	
+{
+	_asm {
+		mov eax, EAX_NtUserGetAsyncKeyState
+		jmp NtUserGetAsyncKeyStateRet
+		ret
 	}
-
-__declspec(naked) ULONG  __stdcall NtUserCallTwoParam(  DWORD Param1,DWORD Param2,DWORD Routine)
-	{
-	_asm{
-			mov eax,EAX_NtUserCallTwoParam
-			jmp NtUserCallTwoParamRet
-			ret
-		}	
+}
+
+__declspec(naked) ULONG  __stdcall NtUserCallTwoParam(DWORD Param1, DWORD Param2, DWORD Routine)
+{
+	_asm {
+		mov eax, EAX_NtUserCallTwoParam
+		jmp NtUserCallTwoParamRet
+		ret
 	}
+}
 
 
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 2758 - 2759
天使插件源码/TSPlug/TSWindowsAPI.cpp


+ 38 - 38
天使插件源码/TSPlug/TSWindowsAPI.h

@@ -1,44 +1,44 @@
 #pragma once
 
 class TSWindowsAPI
-	{
-	public:
-		TSWindowsAPI(void);
-		~TSWindowsAPI(void);
+{
+public:
+	TSWindowsAPI(void);
+	~TSWindowsAPI(void);
 
 
-	public:
-		int retstringlen;
-		DWORD WindowVerion;
-		DWORD IsEuemprosuccess;
-		DWORD npid[MAX_PATH];
-		bool TSEnumWindow(HWND parent,wchar_t *title,wchar_t *class_name,LONG filter,wchar_t *retstring,wchar_t  *process_name=NULL );
-		bool TSEnumWindowSuper(wchar_t *spec1,LONG flag1,LONG type1,wchar_t *spec2,LONG flag2,LONG type2,LONG sort,wchar_t *retstring=NULL);
-		bool TSEnumProcess(wchar_t *name,wchar_t *retstring);
-		bool TSClientToScreen(LONG hwnd,LONG &x,LONG &y);
-		bool TSFindWindow(wchar_t *class_name,wchar_t*title,LONG &rethwnd,DWORD parent=0);
-		bool TSFindWindowByProcess(wchar_t *class_name,wchar_t *titl,LONG &rethwnd,wchar_t *process_name=NULL,DWORD Pid=0);
-		bool TSGetClientRect(LONG hwnd,LONG &x,LONG &y,LONG &x1, LONG &y1);
-		bool TSGetClientSize(LONG hwnd,LONG &width,LONG &height);
-		bool TSGetMousePointWindow(LONG &rethwnd,LONG x=-1,LONG y=-1);
-		bool TSGetProcessInfo(LONG pid,wchar_t *retstring);
-		bool TSGetWindow(LONG hwnd,LONG flag,LONG &rethwnd);
-		bool GetProcesspath(DWORD ProcessID,wchar_t* process_path);
-		bool TSGetWindowState(LONG hwnd,LONG flag);
-		bool TSSendPaste(LONG hwnd);
-		bool TSSetWindowSize(LONG hwnd, LONG width, LONG hight,int type=0);
-		bool TSSetWindowState(LONG hwnd,LONG flag,LONG rethwnd=0);
-		bool TSSetWindowTransparent(LONG hwnd,LONG trans);
-		bool TSSetClipboard(wchar_t *values);
-		bool TSGetClipboard(wchar_t *retstr);
-	private:
-		DWORD  FindChildWnd(HWND hchile, wchar_t *title,wchar_t *classname,wchar_t *retstring,bool isGW_OWNER=false,bool isVisible=false,wchar_t  *process_name=NULL);
-		BOOL   EnumProcessbyName(DWORD   dwPID,   LPCWSTR   ExeName,LONG type=0) ;
-		int GetProcessNumber();//获取CPU个数
-		// 时间格式转换
-		__int64 FileTimeToInt64(const FILETIME& time);
-		double get_cpu_usage(DWORD ProcessID);	 //获取指定进程CPU使用率
-		DWORD GetMemoryInfo(DWORD ProcessID);  //或者指定进程内存使用率
-		
+public:
+	int retstringlen;
+	DWORD WindowVerion;
+	DWORD IsEuemprosuccess;
+	DWORD npid[MAX_PATH];
+	bool TSEnumWindow(HWND parent, wchar_t* title, wchar_t* class_name, LONG filter, wchar_t* retstring, wchar_t* process_name = NULL);
+	bool TSEnumWindowSuper(wchar_t* spec1, LONG flag1, LONG type1, wchar_t* spec2, LONG flag2, LONG type2, LONG sort, wchar_t* retstring = NULL);
+	bool TSEnumProcess(wchar_t* name, wchar_t* retstring);
+	bool TSClientToScreen(LONG hwnd, LONG& x, LONG& y);
+	bool TSFindWindow(wchar_t* class_name, wchar_t* title, LONG& rethwnd, DWORD parent = 0);
+	bool TSFindWindowByProcess(wchar_t* class_name, wchar_t* titl, LONG& rethwnd, wchar_t* process_name = NULL, DWORD Pid = 0);
+	bool TSGetClientRect(LONG hwnd, LONG& x, LONG& y, LONG& x1, LONG& y1);
+	bool TSGetClientSize(LONG hwnd, LONG& width, LONG& height);
+	bool TSGetMousePointWindow(LONG& rethwnd, LONG x = -1, LONG y = -1);
+	bool TSGetProcessInfo(LONG pid, wchar_t* retstring);
+	bool TSGetWindow(LONG hwnd, LONG flag, LONG& rethwnd);
+	bool GetProcesspath(DWORD ProcessID, wchar_t* process_path);
+	bool TSGetWindowState(LONG hwnd, LONG flag);
+	bool TSSendPaste(LONG hwnd);
+	bool TSSetWindowSize(LONG hwnd, LONG width, LONG hight, int type = 0);
+	bool TSSetWindowState(LONG hwnd, LONG flag, LONG rethwnd = 0);
+	bool TSSetWindowTransparent(LONG hwnd, LONG trans);
+	bool TSSetClipboard(wchar_t* values);
+	bool TSGetClipboard(wchar_t* retstr);
+private:
+	DWORD  FindChildWnd(HWND hchile, wchar_t* title, wchar_t* classname, wchar_t* retstring, bool isGW_OWNER = false, bool isVisible = false, wchar_t* process_name = NULL);
+	BOOL   EnumProcessbyName(DWORD   dwPID, LPCWSTR   ExeName, LONG type = 0);
+	int GetProcessNumber();//获取CPU个数
+	// 时间格式转换
+	__int64 FileTimeToInt64(const FILETIME& time);
+	double get_cpu_usage(DWORD ProcessID);	 //获取指定进程CPU使用率
+	DWORD GetMemoryInfo(DWORD ProcessID);  //或者指定进程内存使用率
 
-	};
+
+};

+ 165 - 165
天使插件源码/TSPlug/dllmain.cpp

@@ -18,53 +18,53 @@
 
 CTSPlugModule _AtlModule;
 TCHAR gDLLFolder[MAX_PATH + 1];
-HHOOK g_hSetWindowsHook=NULL;
-HMODULE g_hInstance=NULL;
+HHOOK g_hSetWindowsHook = NULL;
+HMODULE g_hInstance = NULL;
 extern bool g_Unbind;
 extern HWND g_InjectHWND;
 extern HWND g_currentHwnd;
-HANDLE g_hthread=NULL;
+HANDLE g_hthread = NULL;
 extern int SySTpye;
 
 //卸载线程
-void IMEUnLoadThread(void *para)
+void IMEUnLoadThread(void* para)
 {
-	while(1)
+	while (1)
 	{
-		if(TSRuntime::pData->InjectType==204)//203注入
+		if (TSRuntime::pData->InjectType == 204)//203注入
 		{
-			TSRuntime::pData->InjectType=205;
+			TSRuntime::pData->InjectType = 205;
 			TSRuntime::MyLoadLibrary();
-			FreeLibraryAndExitThread(g_hInstance,0);  //卸载DLL
+			FreeLibraryAndExitThread(g_hInstance, 0);  //卸载DLL
 			return;
 		}
-		if(g_Unbind==true)	 //等待窗口解绑
-			{
+		if (g_Unbind == true)	 //等待窗口解绑
+		{
 			//TSRuntime::add_log( "卸载DLL,InjectType:%d",TSRuntime::pData->InjectType);
-			if(TSRuntime::pData->InjectType==1||TSRuntime::pData->InjectType==202||TSRuntime::pData->InjectType==205)
-				{
-					//TSRuntime::add_log( "卸载DLL,InjectType:%d",TSRuntime::pData->InjectType);
-					FreeLibraryAndExitThread(g_hInstance,0);  //卸载DLL
-				}
-			   return ;
+			if (TSRuntime::pData->InjectType == 1 || TSRuntime::pData->InjectType == 202 || TSRuntime::pData->InjectType == 205)
+			{
+				//TSRuntime::add_log( "卸载DLL,InjectType:%d",TSRuntime::pData->InjectType);
+				FreeLibraryAndExitThread(g_hInstance, 0);  //卸载DLL
 			}
+			return;
+		}
 		//如果注入方进程异常退出,自我解绑,卸载DLL
-		if(::IsWindow(g_InjectHWND)==false&&g_InjectHWND!=NULL)
+		if (::IsWindow(g_InjectHWND) == false && g_InjectHWND != NULL)
+		{
+			if (TSRuntime::pData->InjectType == 0)
 			{
-			if(TSRuntime::pData->InjectType==0)
-				{
-					//通知自身窗口解绑
-					SendMessage(g_currentHwnd,TS_UNBIND,0,0);
-					::UnhookWindowsHookEx(g_hSetWindowsHook);
-				}
+				//通知自身窗口解绑
+				SendMessage(g_currentHwnd, TS_UNBIND, 0, 0);
+				::UnhookWindowsHookEx(g_hSetWindowsHook);
+			}
 			else
-				{
-					//通知自身窗口解绑
-					SendMessage(g_currentHwnd,TS_UNBIND,0,0);
-					FreeLibraryAndExitThread(g_hInstance,0);  //卸载DLL
-				}
-				return ;
+			{
+				//通知自身窗口解绑
+				SendMessage(g_currentHwnd, TS_UNBIND, 0, 0);
+				FreeLibraryAndExitThread(g_hInstance, 0);  //卸载DLL
 			}
+			return;
+		}
 		Sleep(10);
 
 		//CString scd;
@@ -72,185 +72,185 @@ void IMEUnLoadThread(void *para)
 
 }
 
-DWORD CALLBACK CBFunA(DWORD calldata1, DWORD calldata2,DWORD calldata3)	//输入法注入回调函数
+DWORD CALLBACK CBFunA(DWORD calldata1, DWORD calldata2, DWORD calldata3)	//输入法注入回调函数
 {
-	HINSTANCE my_hInstance=(HINSTANCE)calldata1;  //输入法传入自身DLL基址和自身得到的基址验证后才开启线程
+	HINSTANCE my_hInstance = (HINSTANCE)calldata1;  //输入法传入自身DLL基址和自身得到的基址验证后才开启线程
 	//TSRuntime::add_log( "IME注入");
-	if(my_hInstance)
-		{
-			if(my_hInstance==g_hInstance)
-				g_hthread=(HANDLE)_beginthread(IMEUnLoadThread, 0 ,0 );//启动线程等待解绑卸载DLL
-		}
+	if (my_hInstance)
+	{
+		if (my_hInstance == g_hInstance)
+			g_hthread = (HANDLE)_beginthread(IMEUnLoadThread, 0, 0);//启动线程等待解绑卸载DLL
+	}
 	return 0;
 }
 
-static HMODULE ModuleFromAddress(PVOID pv) 
+static HMODULE ModuleFromAddress(PVOID pv)
 {
 	MEMORY_BASIC_INFORMATION mbi;
-	if(::VirtualQuery(pv, &mbi, sizeof(mbi)) != 0)
-		{
-			return (HMODULE)mbi.AllocationBase;
-		}
+	if (::VirtualQuery(pv, &mbi, sizeof(mbi)) != 0)
+	{
+		return (HMODULE)mbi.AllocationBase;
+	}
 	else
-		{
-			return NULL;
-		}
+	{
+		return NULL;
+	}
 }
 
-static LRESULT WINAPI GetMsgProc(int code, WPARAM wParam, LPARAM lParam) 
+static LRESULT WINAPI GetMsgProc(int code, WPARAM wParam, LPARAM lParam)
 {
-	
+
 	return ::CallNextHookEx(g_hSetWindowsHook, code, wParam, lParam);
 }
 
 BOOL WINAPI CBFunB(BOOL bInstall, DWORD dwThreadId)
 {
-	BOOL bOk=FALSE;
-	if(bInstall)
-		{
-		g_hSetWindowsHook = ::SetWindowsHookEx(WH_CALLWNDPROC, GetMsgProc,ModuleFromAddress(GetMsgProc), dwThreadId);
+	BOOL bOk = FALSE;
+	if (bInstall)
+	{
+		g_hSetWindowsHook = ::SetWindowsHookEx(WH_CALLWNDPROC, GetMsgProc, ModuleFromAddress(GetMsgProc), dwThreadId);
 		//TSRuntime::add_log( "g_hSetWindowsHook:%x,PID:%d",GetCurrentProcessId());
-		if(g_hSetWindowsHook != NULL)
-			{
-			   bOk = true;
-			}
-			
-		} 
-	else 
+		if (g_hSetWindowsHook != NULL)
+		{
+			bOk = true;
+		}
+
+	}
+	else
+	{
+
+		if (g_hSetWindowsHook)
 		{
-		 
-		 if(g_hSetWindowsHook)
-			 {
-				//::MessageBox(0,L"Dll Main:UnhookWindowsHookEx",L"TS",0);
-				bOk = ::UnhookWindowsHookEx(g_hSetWindowsHook);
-			 }
+			//::MessageBox(0,L"Dll Main:UnhookWindowsHookEx",L"TS",0);
+			bOk = ::UnhookWindowsHookEx(g_hSetWindowsHook);
 		}
+	}
 	return bOk;
 }
 
 // DLL 入口点
 extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 {
-	switch(dwReason)
+	switch (dwReason)
+	{
+	case DLL_PROCESS_ATTACH:
+	{
+
+		TSRuntime::InitKeyPressCharMap();
+		TSRuntime::InitVirtualToASCIIMap();
+		TSRuntime::InitKeyMap();
+		TSRuntime::InitKeyPressMap();
+		SySTpye = TSRuntime::InitialWindowsVersion();
+		g_hInstance = hInstance;
+		//wcscpy(gDLLFolder,TSRuntime::GetComPath()); 
+		TSRuntime::GetComPath(gDLLFolder);
+		//::MessageBox(0,gDLLFolder,L"TS",0);
+		char pszMapName[MAX_PATH] = { 0 };
+		sprintf(pszMapName, "%s%d", TS_MAPVIEW_NAME, GetCurrentProcessId());
+		HANDLE hFileMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, pszMapName);
+		//如果hFileMap句柄不为空说明DLL被注入,准备启动注入线程
+		if (hFileMap != NULL)
 		{
-		case DLL_PROCESS_ATTACH:
+			//::MessageBox(0,L"Dll Main:DLL_PROCESS_ATTACH",L"TS",0);
+		   //// 这里先打开共享内存,共享内存和程序是一对一的关系
+			CShareMemory* sm = new CShareMemory(pszMapName);
+			TSRuntime::pData = (CMessageData*)sm->GetBuffer();
+			//// 共享内存的初始化数据是不能为空的,为空就不正常
+			if (TSRuntime::pData != NULL)
 			{
+				if (TSRuntime::pData->InjectType == BIND_201 || TSRuntime::pData->InjectType == BIND_203)//201模式注入
+				{
+					if (TSRuntime::pData->InjectType == BIND_201)
+						TSRuntime::pData->InjectType = 202;
+					else if (TSRuntime::pData->InjectType == BIND_203)
+						TSRuntime::pData->InjectType = 204;
+					//TSRuntime::add_log("201模式注入");
+					DWORD InternalCallWinProc_Addr = (DWORD)::GetModuleHandle(L"user32.dll");
+					if (SySTpye == 1)//WinXP
+						InternalCallWinProc_Addr += USER32InternalCallWinProcXPoffse;
+					else if (SySTpye == 2)//Win2003
+						InternalCallWinProc_Addr += USER32InternalCallWinProcWin2003offse;
+					else if (SySTpye == 4 && TSRuntime::IsWin7X64)//WIN7X64
+						InternalCallWinProc_Addr += USER32InternalCallProcWin7x64offse;
+					else if (SySTpye == 4)//WIN7X86
+						InternalCallWinProc_Addr += USER32InternalCallProcWin7offse;
+					else if (SySTpye == 5 && TSRuntime::IsWin8X64)//WIN8X64
+						InternalCallWinProc_Addr += USER32InternalCallProcWin8x64offse;
+					else if (SySTpye == 5)//WIN8X86
+						InternalCallWinProc_Addr += USER32InternalCallProcWin8offse;
 
-				TSRuntime::InitKeyPressCharMap();
-				TSRuntime::InitVirtualToASCIIMap();
-				TSRuntime::InitKeyMap();
-				TSRuntime::InitKeyPressMap();
-				SySTpye=TSRuntime::InitialWindowsVersion();
-				g_hInstance=hInstance;
-				//wcscpy(gDLLFolder,TSRuntime::GetComPath()); 
-				TSRuntime::GetComPath(gDLLFolder);
-				//::MessageBox(0,gDLLFolder,L"TS",0);
-				char pszMapName[MAX_PATH]={0};
-				sprintf( pszMapName,"%s%d",TS_MAPVIEW_NAME,GetCurrentProcessId());
-				HANDLE hFileMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, pszMapName);
-					//如果hFileMap句柄不为空说明DLL被注入,准备启动注入线程
-				if(hFileMap!=NULL)                           
-					{
-					  //::MessageBox(0,L"Dll Main:DLL_PROCESS_ATTACH",L"TS",0);
-					 //// 这里先打开共享内存,共享内存和程序是一对一的关系
-				      CShareMemory *sm=new CShareMemory(pszMapName);
-					  TSRuntime::pData=(CMessageData*)sm->GetBuffer();
-					 //// 共享内存的初始化数据是不能为空的,为空就不正常
-					  if(TSRuntime::pData!=NULL)       
-						{
-							if(TSRuntime::pData->InjectType==BIND_201||TSRuntime::pData->InjectType==BIND_203)//201模式注入
-							{
-								if(TSRuntime::pData->InjectType==BIND_201)
-									TSRuntime::pData->InjectType=202;
-								else if(TSRuntime::pData->InjectType==BIND_203)
-									TSRuntime::pData->InjectType=204;
-								//TSRuntime::add_log("201模式注入");
-								DWORD InternalCallWinProc_Addr=(DWORD)::GetModuleHandle(L"user32.dll");
-								if(SySTpye==1)//WinXP
-									InternalCallWinProc_Addr+=USER32InternalCallWinProcXPoffse;
-								else if(SySTpye==2)//Win2003
-									InternalCallWinProc_Addr+=USER32InternalCallWinProcWin2003offse;
-								else if(SySTpye==4&&TSRuntime::IsWin7X64)//WIN7X64
-									InternalCallWinProc_Addr+=USER32InternalCallProcWin7x64offse;
-								else if(SySTpye==4)//WIN7X86
-									InternalCallWinProc_Addr+=USER32InternalCallProcWin7offse;
-								else if(SySTpye==5&&TSRuntime::IsWin8X64)//WIN8X64
-									InternalCallWinProc_Addr+=USER32InternalCallProcWin8x64offse;
-								else if(SySTpye==5)//WIN8X86
-									InternalCallWinProc_Addr+=USER32InternalCallProcWin8offse;
-
-								BYTE ori[5]={0x55,0x8b,0xec,0x56,0x57};
-
-								//注入完成还原钩子
-								memcpy((void*)InternalCallWinProc_Addr,ori,5);
-								FlushInstructionCache(GetCurrentProcess(),(void*)InternalCallWinProc_Addr,5);
+					BYTE ori[5] = { 0x55,0x8b,0xec,0x56,0x57 };
 
-								////TS_BIND201_NAME
-								wchar_t pszEventName[MAX_PATH]={0};
-								::wsprintf(pszEventName,L"%s%d",TS_BIND201_NAME,::GetCurrentProcessId());
-								HANDLE picEvent=::CreateEvent(NULL,TRUE,FALSE,pszEventName);
-								::WaitForSingleObject(picEvent,INFINITE);
-								::CloseHandle(picEvent);
-								g_Unbind=false;
+					//注入完成还原钩子
+					memcpy((void*)InternalCallWinProc_Addr, ori, 5);
+					FlushInstructionCache(GetCurrentProcess(), (void*)InternalCallWinProc_Addr, 5);
 
-								_beginthread(IMEUnLoadThread, 0 ,0 );
-								if(TSRuntime::pData->InjectType==202)
-									TSRuntime::g_DxObj.hookApi();
-							}
-							else if(TSRuntime::pData->InjectType!=202&&TSRuntime::pData->InjectType!=204) //// 这里根据传入的模式进行函数拦截,兵起一个检测线程进行检测
-							{
-								if(TSRuntime::pData->InjectType==205)//203绑定
-									_beginthread(IMEUnLoadThread, 0 ,0 );	
-								TSRuntime::g_DxObj.hookApi();
-							}
-						}
+					////TS_BIND201_NAME
+					wchar_t pszEventName[MAX_PATH] = { 0 };
+					::wsprintf(pszEventName, L"%s%d", TS_BIND201_NAME, ::GetCurrentProcessId());
+					HANDLE picEvent = ::CreateEvent(NULL, TRUE, FALSE, pszEventName);
+					::WaitForSingleObject(picEvent, INFINITE);
+					::CloseHandle(picEvent);
+					g_Unbind = false;
 
-					}
-				
-			break;
+					_beginthread(IMEUnLoadThread, 0, 0);
+					if (TSRuntime::pData->InjectType == 202)
+						TSRuntime::g_DxObj.hookApi();
+				}
+				else if (TSRuntime::pData->InjectType != 202 && TSRuntime::pData->InjectType != 204) //// 这里根据传入的模式进行函数拦截,兵起一个检测线程进行检测
+				{
+					if (TSRuntime::pData->InjectType == 205)//203绑定
+						_beginthread(IMEUnLoadThread, 0, 0);
+					TSRuntime::g_DxObj.hookApi();
+				}
 			}
 
 		}
-	return _AtlModule.DllMain(dwReason, lpReserved); 
+
+		break;
+	}
+
+	}
+	return _AtlModule.DllMain(dwReason, lpReserved);
 }
 
-TsMutex::TsMutex(char *pszEventName)
+TsMutex::TsMutex(char* pszEventName)
+{
+	//InitializeCriticalSection(&m_mutex);
+	hEvent = OpenEventA(EVENT_ALL_ACCESS, false, pszEventName);
+	if (hEvent == NULL)
 	{
-		//InitializeCriticalSection(&m_mutex);
-		hEvent=OpenEventA(EVENT_ALL_ACCESS,false,pszEventName);
-		if(hEvent==NULL)
-			{
-				hEvent=CreateEventA(NULL,FALSE,FALSE,pszEventName);
-				::SetEvent(hEvent);
-			}
-		
+		hEvent = CreateEventA(NULL, FALSE, FALSE, pszEventName);
+		::SetEvent(hEvent);
 	}
 
+}
+
 TsMutex::~TsMutex()
-	{
-		//DeleteCriticalSection(&m_mutex);
-		CloseHandle(hEvent);
-	}
+{
+	//DeleteCriticalSection(&m_mutex);
+	CloseHandle(hEvent);
+}
 
 void TsMutex::lock()
-	{
-		//::WaitForSingleObject(hEvent,INFINITE);
-		::WaitForSingleObject(hEvent,10000);
-		//EnterCriticalSection(&m_mutex);
-	}
+{
+	//::WaitForSingleObject(hEvent,INFINITE);
+	::WaitForSingleObject(hEvent, 10000);
+	//EnterCriticalSection(&m_mutex);
+}
 void TsMutex::unlock()
-	{
-		::SetEvent(hEvent);
-		//LeaveCriticalSection(&m_mutex);
-	}
+{
+	::SetEvent(hEvent);
+	//LeaveCriticalSection(&m_mutex);
+}
 
-TsMutexlock::TsMutexlock(TsMutex *ptcmutex)
-	{
-		m_ptcmutex=	 ptcmutex;
-		m_ptcmutex->lock();
-	}
+TsMutexlock::TsMutexlock(TsMutex* ptcmutex)
+{
+	m_ptcmutex = ptcmutex;
+	m_ptcmutex->lock();
+}
 
 TsMutexlock::~TsMutexlock()
-	{
-		m_ptcmutex->unlock();
-	}
+{
+	m_ptcmutex->unlock();
+}

+ 17 - 17
天使插件源码/TSPlug/dllmain.h

@@ -1,32 +1,32 @@
 // dllmain.h : 模块类的声明。
 class CTSPlugModule : public CAtlDllModuleT< CTSPlugModule >
 {
-public :
+public:
 	DECLARE_LIBID(LIBID_TSPlugLib)
 	DECLARE_REGISTRY_APPID_RESOURCEID(IDR_TSPLUG, "{900527EB-7D74-41DE-9E3E-80E4B267E0F2}")
-	
+
 };
 
 //访问控制
 class TsMutex//创建临界区和销毁临界区
-	{
-	public:
-		TsMutex(char *pszEventName);
-		~TsMutex();
-		//CRITICAL_SECTION m_mutex;
-		HANDLE hEvent;
-		void lock();
-		void unlock();
+{
+public:
+	TsMutex(char* pszEventName);
+	~TsMutex();
+	//CRITICAL_SECTION m_mutex;
+	HANDLE hEvent;
+	void lock();
+	void unlock();
 
-	};
+};
 
 class TsMutexlock//进入和离开临界区
-	{
-	public:
-		TsMutexlock(TsMutex *ptcmutex);
-		~TsMutexlock();
-		TsMutex *m_ptcmutex;
-	};
+{
+public:
+	TsMutexlock(TsMutex* ptcmutex);
+	~TsMutexlock();
+	TsMutex* m_ptcmutex;
+};
 
 
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio