diff options
-rw-r--r-- | bin10/lib/mir_core.lib | bin | 300772 -> 301148 bytes | |||
-rw-r--r-- | bin10/lib/mir_core64.lib | bin | 301856 -> 302184 bytes | |||
-rw-r--r-- | bin12/lib/mir_core.lib | bin | 300772 -> 301148 bytes | |||
-rw-r--r-- | bin12/lib/mir_core64.lib | bin | 301856 -> 302184 bytes | |||
-rw-r--r-- | bin14/lib/mir_core.lib | bin | 300772 -> 301148 bytes | |||
-rw-r--r-- | bin14/lib/mir_core64.lib | bin | 301856 -> 302184 bytes | |||
-rw-r--r-- | include/m_core.h | 5 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 2 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 2 | ||||
-rw-r--r-- | src/mir_core/src/utils.cpp | 50 |
10 files changed, 59 insertions, 0 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex adf79d9616..36f443165c 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex 94ba8545b0..89832ebfab 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib Binary files differindex adf79d9616..36f443165c 100644 --- a/bin12/lib/mir_core.lib +++ b/bin12/lib/mir_core.lib diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib Binary files differindex 94ba8545b0..89832ebfab 100644 --- a/bin12/lib/mir_core64.lib +++ b/bin12/lib/mir_core64.lib diff --git a/bin14/lib/mir_core.lib b/bin14/lib/mir_core.lib Binary files differindex adf79d9616..36f443165c 100644 --- a/bin14/lib/mir_core.lib +++ b/bin14/lib/mir_core.lib diff --git a/bin14/lib/mir_core64.lib b/bin14/lib/mir_core64.lib Binary files differindex 94ba8545b0..89832ebfab 100644 --- a/bin14/lib/mir_core64.lib +++ b/bin14/lib/mir_core64.lib diff --git a/include/m_core.h b/include/m_core.h index a9a900f03c..0231e3cdef 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -408,6 +408,9 @@ MIR_CORE_DLL(int) wildcmpiw(const wchar_t *name, const wchar_t *mask); MIR_CORE_DLL(char*) bin2hex(const void *pData, size_t len, char *dest);
MIR_CORE_DLL(wchar_t*) bin2hexW(const void *pData, size_t len, wchar_t *dest);
+MIR_CORE_DLL(bool) hex2bin(const char *pSrc, void *pData, size_t len);
+MIR_CORE_DLL(bool) hex2binW(const wchar_t *pSrc, void *pData, size_t len);
+
__forceinline char* lrtrim(char *str) { return ltrim(rtrim(str)); };
__forceinline char* lrtrimp(char *str) { return ltrimp(rtrim(str)); };
@@ -459,6 +462,7 @@ typedef union { #define replaceStrT replaceStrW
#define bin2hexT bin2hexW
+ #define hex2binT hex2binW
#define rtrimt rtrimw
#define ltrimt ltrimw
@@ -499,6 +503,7 @@ typedef union { #define replaceStrT replaceStr
#define bin2hexT bin2hex
+ #define hex2binT hex2bin
#define rtrimt rtrim
#define ltrimt ltrim
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index fb89dde82b..c5ff0c1fbc 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -988,3 +988,5 @@ mir_sha256_hash @1145 mir_sha256_init @1146
mir_sha256_write @1147
mir_forkthreadowner @1148
+hex2bin @1149
+hex2binW @1150
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index f7cb356fdb..3d660b330c 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -988,3 +988,5 @@ mir_sha256_hash @1145 mir_sha256_init @1146
mir_sha256_write @1147
mir_forkthreadowner @1148
+hex2bin @1149
+hex2binW @1150
diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp index 91b057b301..a2f1ab0171 100644 --- a/src/mir_core/src/utils.cpp +++ b/src/mir_core/src/utils.cpp @@ -282,6 +282,56 @@ MIR_CORE_DLL(WCHAR*) bin2hexW(const void *pData, size_t len, WCHAR *dest) return dest;
}
+static int hex2dec(int iHex)
+{
+ if (iHex >= '0' && iHex <= '9')
+ return iHex - '0';
+ if (iHex >= 'a' && iHex <= 'f')
+ return iHex - 'a' + 10;
+ if (iHex >= 'A' && iHex <= 'F')
+ return iHex - 'A' + 10;
+ return 0;
+}
+
+MIR_CORE_DLL(bool) hex2bin(const char *pSrc, void *pData, size_t len)
+{
+ if (pSrc == NULL || pData == NULL || len == 0)
+ return false;
+
+ size_t bufLen = strlen(pSrc)/2;
+ if (pSrc[bufLen*2] != 0 || bufLen > len)
+ return false;
+
+ BYTE *pDest = (BYTE*)pData;
+ const char *p = (const char *)pSrc;
+ for (size_t i = 0; i < bufLen; i++, p += 2)
+ pDest[i] = hex2dec(p[0]) * 16 + hex2dec(p[1]);
+
+ if (bufLen < len)
+ memset(pDest + bufLen, 0, len - bufLen);
+ return true;
+}
+
+MIR_CORE_DLL(bool) hex2binW(const wchar_t *pSrc, void *pData, size_t len)
+{
+ if (pSrc == NULL || pData == NULL || len == 0)
+ return false;
+
+ size_t bufLen = wcslen(pSrc);
+ if (pSrc[bufLen * 2] != 0 || bufLen > len)
+ return false;
+
+ BYTE *pDest = (BYTE*)pData;
+ const wchar_t *p = (const wchar_t *)pSrc;
+ for (size_t i = 0; i < bufLen; i++, p += 2)
+ pDest[i] = hex2dec(p[0]) * 16 + hex2dec(p[1]);
+
+ if (bufLen < len)
+ memset(pDest+bufLen, 0, len - bufLen);
+ return true;
+}
+
+
/////////////////////////////////////////////////////////////////////////////////////////
#pragma intrinsic(strlen, strcpy, strcat, strcmp, wcslen, wcscpy, wcscat, wcscmp)
|