| 
									
										
										
										
											2022-03-08 12:57:35 +08:00
										 |  |  |  | #include "pch.h"
 | 
					
						
							|  |  |  |  | #include "DNFTOOL.h"
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int DNFTOOL::GetExeNutWrtNum(int Pos) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     int num = *(int*)(0x40079F + (Pos * 4)); | 
					
						
							|  |  |  |  |     return num; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void DNFTOOL::SetExeNutWrtNum(int Pos, int num) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     int* p = (int*)(0x40079F + (Pos * 4)); | 
					
						
							|  |  |  |  |     *p = num; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int DNFTOOL::GetNutArrNum(int Nutͷ<EFBFBD><EFBFBD>ַ, int Pos) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     int num = *(int*)(Nutͷ<EFBFBD><EFBFBD>ַ + (Pos * 8)); | 
					
						
							|  |  |  |  |     return num; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void DNFTOOL::SetNutArrNum(int Nutͷ<EFBFBD><EFBFBD>ַ, int Pos, int num) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     int* p = (int*)(Nutͷ<EFBFBD><EFBFBD>ַ + (Pos * 8)); | 
					
						
							|  |  |  |  |     *p = num; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 17:17:12 +08:00
										 |  |  |  | int DNFTOOL::GetHook(int Addr, std::string <EFBFBD><EFBFBD>ַ,int Type) | 
					
						
							| 
									
										
										
										
											2022-03-08 12:57:35 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |     size_t pos = <EFBFBD><EFBFBD>ַ.find("+"); | 
					
						
							|  |  |  |  |     size_t size = <EFBFBD><EFBFBD>ַ.size(); | 
					
						
							|  |  |  |  |     int GetHookArr[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; | 
					
						
							|  |  |  |  |     int i = 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     while (pos != std::string::npos) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         std::string x = <EFBFBD><EFBFBD>ַ.substr(0, pos); | 
					
						
							|  |  |  |  |         GetHookArr[i] = stoi(x, 0, 16); | 
					
						
							|  |  |  |  |         i++; | 
					
						
							|  |  |  |  |         <EFBFBD><EFBFBD>ַ = <EFBFBD><EFBFBD>ַ.substr(pos + 1, size); | 
					
						
							|  |  |  |  |         pos = <EFBFBD><EFBFBD>ַ.find("+"); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     int num; | 
					
						
							|  |  |  |  |     num = *(int*)(Addr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     if (num != 0) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         for (int z = 0; z < i; z++) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-03-27 17:17:12 +08:00
										 |  |  |  |             if (z == i - 1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (Type == 0)return *(int*)(num + GetHookArr[z]); | 
					
						
							|  |  |  |  |                 else return (num + GetHookArr[z]); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 num = *(int*)(num + GetHookArr[z]); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-03-08 12:57:35 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     return num; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int DNFTOOL::DNFDeCode(int Address) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     DWORD nEax, nEcx8, nEsi, nEdx, nTmp; | 
					
						
							|  |  |  |  |     nEax = *(int*)(Address); | 
					
						
							|  |  |  |  |     if (nEax == -1) | 
					
						
							|  |  |  |  |         return nEax; | 
					
						
							|  |  |  |  |     nEcx8 = *(int*)(Address + 8); | 
					
						
							|  |  |  |  |     if (nEcx8 == -1) | 
					
						
							|  |  |  |  |         return nEcx8; | 
					
						
							|  |  |  |  |     nEsi = *(int*)(0x1AF8D78); | 
					
						
							|  |  |  |  |     nEdx = nEax >> 16; | 
					
						
							|  |  |  |  |     nTmp = (nEdx << 2) + nEsi + 36; | 
					
						
							|  |  |  |  |     nEdx = *(int*)(nTmp); | 
					
						
							|  |  |  |  |     if (nEdx == -1) | 
					
						
							|  |  |  |  |         return nEdx; | 
					
						
							|  |  |  |  |     nEax = nEax & 65535; | 
					
						
							|  |  |  |  |     nTmp = (nEax << 2) + nEdx + 8468; | 
					
						
							|  |  |  |  |     nEax = *(int*)(nTmp); | 
					
						
							|  |  |  |  |     if (nEax == -1) | 
					
						
							|  |  |  |  |         return nEax; | 
					
						
							|  |  |  |  |     _asm | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mov eax, nEax | 
					
						
							|  |  |  |  |         movzx   edx, ax | 
					
						
							|  |  |  |  |         mov nEdx, edx | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     nEsi = nEdx << 16; | 
					
						
							|  |  |  |  |     nEsi = nEsi | nEdx; | 
					
						
							|  |  |  |  |     nEax = nEsi ^ nEcx8; | 
					
						
							|  |  |  |  |     return nEax; | 
					
						
							|  |  |  |  |     return 0; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void DNFTOOL::DNFEnCode(int AddreSs, int Data) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     long JEdi, JEcx, JEax, JEsi, JEdx, JSs; | 
					
						
							|  |  |  |  |     JEcx = AddreSs; | 
					
						
							|  |  |  |  |     JEax = *(int*)(0x1AF8DB8); | 
					
						
							|  |  |  |  |     JEax = JEax + 1; | 
					
						
							|  |  |  |  |     *(int*)(0x1AF8DB8) = JEax; | 
					
						
							|  |  |  |  |     JEdx = JEax; | 
					
						
							|  |  |  |  |     JEdx = JEdx >> 8; | 
					
						
							|  |  |  |  |     JEdx = JEdx << 24; | 
					
						
							|  |  |  |  |     JEdx = JEdx >> 24; | 
					
						
							|  |  |  |  |     JEdx = *(int*)(JEdx * 2 + 0x1843F58); | 
					
						
							|  |  |  |  |     JEdx = JEdx & 0xFFFF; | 
					
						
							|  |  |  |  |     JEax = JEax << 24; | 
					
						
							|  |  |  |  |     JEax = JEax >> 24; | 
					
						
							|  |  |  |  |     JSs = *(int*)(JEax * 2 + 0x1844158); | 
					
						
							|  |  |  |  |     JSs = JSs & 0xFFFF; | 
					
						
							|  |  |  |  |     JEdx = JEdx ^ JSs; | 
					
						
							|  |  |  |  |     JEax = JEdx; | 
					
						
							|  |  |  |  |     JEax = JEax & 0xFFFF; | 
					
						
							|  |  |  |  |     JEsi = Data; | 
					
						
							|  |  |  |  |     JEdx = JEsi >> 16; | 
					
						
							|  |  |  |  |     Sleep(10); | 
					
						
							|  |  |  |  |     JSs = JEsi & 0xFFFF; | 
					
						
							|  |  |  |  |     JEdx = JEdx + JSs; | 
					
						
							|  |  |  |  |     JEdx = JEdx ^ JEax; | 
					
						
							|  |  |  |  |     JEdi = JEdx; | 
					
						
							|  |  |  |  |     JEdx = JEax; | 
					
						
							|  |  |  |  |     JEax = JEax << 16; | 
					
						
							|  |  |  |  |     JEax = JEax + JEdx; | 
					
						
							|  |  |  |  |     JEsi = Data; | 
					
						
							|  |  |  |  |     JEax = JEax ^ JEsi; | 
					
						
							|  |  |  |  |     JEsi = AddreSs + 8; | 
					
						
							|  |  |  |  |     *(int*)(JEsi) = JEax; | 
					
						
							|  |  |  |  |     JEax = *(int*)(AddreSs); | 
					
						
							|  |  |  |  |     JEsi = *(int*)(0x1AF8D78); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     JEcx = JEdi; | 
					
						
							|  |  |  |  |     JEcx = JEcx << 16; | 
					
						
							|  |  |  |  |     JEcx = JEcx + JEdx; | 
					
						
							|  |  |  |  |     JEdx = JEax; | 
					
						
							|  |  |  |  |     JEdx = JEdx >> 16; | 
					
						
							|  |  |  |  |     JEdx = *(int*)(JEsi + JEdx * 4 + 36); | 
					
						
							|  |  |  |  |     JEax = JEax & 0xFFFF; | 
					
						
							|  |  |  |  |     *(int*)(JEdx + JEax * 4 + 8468) = JEcx; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | int DNFTOOL::GetEquAddr(int addr) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     switch (addr) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |     case 1: | 
					
						
							|  |  |  |  |         return 0x3038; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 2: | 
					
						
							|  |  |  |  |         return 0x304C; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 3: | 
					
						
							|  |  |  |  |         return 0x3048; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 4: | 
					
						
							|  |  |  |  |         return 0x3050; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 5: | 
					
						
							|  |  |  |  |         return 0x3044; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 6: | 
					
						
							|  |  |  |  |         return 0x3040; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 7: | 
					
						
							|  |  |  |  |         return 0x3058; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 8: | 
					
						
							|  |  |  |  |         return 0x305C; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 9: | 
					
						
							|  |  |  |  |         return 0x3054; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 10: | 
					
						
							|  |  |  |  |         return 0x3060; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 11: | 
					
						
							|  |  |  |  |         return 0x3064; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 12: | 
					
						
							|  |  |  |  |         return 0x3038; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     case 13: | 
					
						
							|  |  |  |  |         return 0x3008; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 14: | 
					
						
							|  |  |  |  |         return 0x300C; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 15: | 
					
						
							|  |  |  |  |         return 0x3010; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 16: | 
					
						
							|  |  |  |  |         return 0x3014; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 17: | 
					
						
							|  |  |  |  |         return 0x3018; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 18: | 
					
						
							|  |  |  |  |         return 0x301C; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 19: | 
					
						
							|  |  |  |  |         return 0x3020; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 20: | 
					
						
							|  |  |  |  |         return 0x3024; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 21: | 
					
						
							|  |  |  |  |         return 0x3028; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 22: | 
					
						
							|  |  |  |  |         return 0x302C; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 23: | 
					
						
							|  |  |  |  |         return 0x3030; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 24: | 
					
						
							|  |  |  |  |         return 0x3068; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 25: | 
					
						
							|  |  |  |  |         return 0x306C; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 26: | 
					
						
							|  |  |  |  |         return 0x3070; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     case 27: | 
					
						
							|  |  |  |  |         return 0x3074; | 
					
						
							|  |  |  |  |         break; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     return -1; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | char* DNFTOOL::UnicodeToAnsi(const wchar_t* szStr, char* pResult, int maxLen) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     if (NULL == pResult) | 
					
						
							|  |  |  |  |         return NULL; | 
					
						
							|  |  |  |  |     int nLen = WideCharToMultiByte(CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL); | 
					
						
							|  |  |  |  |     if (0 == nLen) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return NULL; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     if (nLen >= maxLen) | 
					
						
							|  |  |  |  |         nLen = maxLen; | 
					
						
							|  |  |  |  |     WideCharToMultiByte(CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL); | 
					
						
							|  |  |  |  |     return pResult; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-22 02:16:45 +08:00
										 |  |  |  | char* DNFTOOL::wchar_tTochar(wchar_t* wbuffer) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     size_t requiredSize = wcstombs(nullptr, wbuffer, 0); | 
					
						
							|  |  |  |  |     char* key = new char[requiredSize + 1]; | 
					
						
							|  |  |  |  |     wcstombs(key, wbuffer, requiredSize + 1); | 
					
						
							|  |  |  |  |     return key; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | wchar_t* DNFTOOL::charTowchar_t(char* wbuffer) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     size_t requiredSize = mbstowcs(nullptr, wbuffer, 0); | 
					
						
							|  |  |  |  |     wchar_t* wcString = new wchar_t[requiredSize + 1]; | 
					
						
							|  |  |  |  |     mbstowcs(wcString, wbuffer, requiredSize + 1); | 
					
						
							|  |  |  |  |     return wcString; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-24 18:02:17 +08:00
										 |  |  |  | wchar_t* DNFTOOL::char2wchar(const char* cchar) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     wchar_t* m_wchar; | 
					
						
							|  |  |  |  |     int len = MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), NULL, 0); | 
					
						
							|  |  |  |  |     m_wchar = new wchar_t[len + 1]; | 
					
						
							|  |  |  |  |     MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), m_wchar, len); | 
					
						
							|  |  |  |  |     m_wchar[len] = '\0'; | 
					
						
							|  |  |  |  |     return m_wchar; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | char* DNFTOOL::wchar2char(const wchar_t* wchar) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     char* m_char; | 
					
						
							|  |  |  |  |     int len = WideCharToMultiByte(CP_ACP, 0, wchar, wcslen(wchar), NULL, 0, NULL, NULL); | 
					
						
							|  |  |  |  |     m_char = new char[len + 1]; | 
					
						
							|  |  |  |  |     WideCharToMultiByte(CP_ACP, 0, wchar, wcslen(wchar), m_char, len, NULL, NULL); | 
					
						
							|  |  |  |  |     m_char[len] = '\0'; | 
					
						
							|  |  |  |  |     return m_char; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | wchar_t* DNFTOOL::SquirrelW2W(const wchar_t* Str) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     size_t len = 0; | 
					
						
							|  |  |  |  |     char* wbuffer = (char*)(Str); | 
					
						
							|  |  |  |  |     while (true) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-05-07 14:31:17 +08:00
										 |  |  |  |         if (wbuffer[len] == 0 && wbuffer[len - 1] == 0)break; | 
					
						
							| 
									
										
										
										
											2022-04-24 18:02:17 +08:00
										 |  |  |  |         ++len; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     char* cbuffer = new char[len / 2 + 1]; | 
					
						
							|  |  |  |  |     int k = 0; | 
					
						
							|  |  |  |  |     for (size_t i = 0; i < len; i++) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (i % 2 == 0) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             cbuffer[k] = wbuffer[i]; | 
					
						
							|  |  |  |  |             ++k; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     cbuffer[len / 2] = '\0'; | 
					
						
							|  |  |  |  |     wchar_t* str = DNFTOOL::char2wchar(cbuffer); | 
					
						
							|  |  |  |  |     delete cbuffer; | 
					
						
							|  |  |  |  |     return str; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-08 12:57:35 +08:00
										 |  |  |  | wchar_t* DNFTOOL::AnsiToUnicode(const char* szStr, wchar_t* pResult, int maxLen) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     if (NULL == pResult) | 
					
						
							|  |  |  |  |         return NULL; | 
					
						
							|  |  |  |  |     int nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, NULL, 0); | 
					
						
							|  |  |  |  |     if (0 == nLen) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return NULL; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     if (nLen >= maxLen) | 
					
						
							|  |  |  |  |         nLen = maxLen; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, pResult, nLen); | 
					
						
							|  |  |  |  |     if (0 == nLen) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return NULL; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     return pResult; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void DNFTOOL::WindowsNotice(char* str, int type, int b) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     DWORD thisc = 0x1A5FB20; | 
					
						
							|  |  |  |  |     thisc = *(DWORD*)thisc; | 
					
						
							|  |  |  |  |     _NoticeTcall(thisc, 0, type, str, b); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void DNFTOOL::GMNotice(char* str, int type, int color) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     if (type == NULL)type = 14; | 
					
						
							|  |  |  |  |     if (color == NULL)color = 0x65535; | 
					
						
							|  |  |  |  |     DWORD thisc = 0x1A5FB20; | 
					
						
							|  |  |  |  |     thisc = *(DWORD*)thisc; | 
					
						
							|  |  |  |  |     thisc = *(DWORD*)(thisc + 0x40); | 
					
						
							|  |  |  |  |     _Noticecall(thisc, 0, str, color, type, 0, 0, 0); | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-21 12:48:20 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-21 13:02:35 +08:00
										 |  |  |  | #if defined LOCALHOSTS_SWITCH
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2022-04-21 12:48:20 +08:00
										 |  |  |  | std::string DNFTOOL::GetIP() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-05-08 07:29:20 +08:00
										 |  |  |  |     httplib::SSLClient Tencword("gitee.com"); | 
					
						
							| 
									
										
										
										
											2022-04-21 12:48:20 +08:00
										 |  |  |  |     std::string body; | 
					
						
							| 
									
										
										
										
											2022-05-08 07:29:20 +08:00
										 |  |  |  |     auto res = Tencword.Get("/yosin_team/request-ip/raw/master/README.md", | 
					
						
							| 
									
										
										
										
											2022-04-21 12:48:20 +08:00
										 |  |  |  |         [&](const char* data, size_t data_length) { | 
					
						
							|  |  |  |  |             body.append(data, data_length); | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2022-05-08 07:29:20 +08:00
										 |  |  |  |     if (!body.empty()) | 
					
						
							| 
									
										
										
										
											2022-04-21 12:48:20 +08:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-05-08 07:29:20 +08:00
										 |  |  |  |         return body; | 
					
						
							| 
									
										
										
										
											2022-04-21 12:48:20 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  |     else | 
					
						
							|  |  |  |  |         return GetIP(); | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-21 13:02:35 +08:00
										 |  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2022-04-21 12:48:20 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | void DNFTOOL::Wchar_tToString(std::string& szDst, wchar_t* wchar) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     wchar_t* wText = wchar; | 
					
						
							|  |  |  |  |     DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, NULL, 0, NULL, FALSE);// WideCharToMultiByte<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     char* psText; // psTextΪchar*<2A><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>飬<EFBFBD><E9A3AC>Ϊ<EFBFBD><CEAA>ֵ<EFBFBD><D6B5>std::string<6E><67><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     psText = new char[dwNum]; | 
					
						
							|  |  |  |  |     WideCharToMultiByte(CP_OEMCP, NULL, wText, -1, psText, dwNum, NULL, FALSE);// WideCharToMultiByte<74><65><EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     szDst = psText;// std::string<6E><67>ֵ
 | 
					
						
							|  |  |  |  |     delete[]psText;// psText<78><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-22 02:16:45 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | const wchar_t* DNFTOOL::GetWC(const char* c) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     const size_t cSize = strlen(c) + 1; | 
					
						
							|  |  |  |  |     wchar_t* wc = new wchar_t[cSize]; | 
					
						
							|  |  |  |  |     mbstowcs(wc, c, cSize); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     return wc; | 
					
						
							| 
									
										
										
										
											2022-04-23 00:49:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void DNFTOOL::Split(const std::string& src, std::vector<std::string>& dest, const std::string& separator) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     std::string str = src; | 
					
						
							|  |  |  |  |     std::string substring; | 
					
						
							|  |  |  |  |     std::string::size_type start = 0, index; | 
					
						
							|  |  |  |  |     dest.clear(); | 
					
						
							|  |  |  |  |     index = str.find_first_of(separator, start); | 
					
						
							|  |  |  |  |     do | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (index != std::string::npos) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             substring = str.substr(start, index - start); | 
					
						
							|  |  |  |  |             dest.push_back(substring); | 
					
						
							|  |  |  |  |             start = index + separator.size(); | 
					
						
							|  |  |  |  |             index = str.find(separator, start); | 
					
						
							|  |  |  |  |             if (start == std::string::npos) break; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } while (index != std::string::npos); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     //the last part
 | 
					
						
							|  |  |  |  |     substring = str.substr(start); | 
					
						
							|  |  |  |  |     dest.push_back(substring); | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-05-07 14:31:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | bool DNFTOOL::isNum(std::string str) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     for (int i = 0; i < str.size(); i++) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         int tmp = (int)str[i]; | 
					
						
							|  |  |  |  |         if (tmp >= 48 && tmp <= 57) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             continue; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     return true; | 
					
						
							|  |  |  |  | } |