diff options
author | Robert Pösel <robyer@seznam.cz> | 2012-12-24 21:30:41 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2012-12-24 21:30:41 +0000 |
commit | 367d9f6f71420e4c7ed5f273e04d280655bb3d7a (patch) | |
tree | d4bb82414145d3be020ab2b579bcd1947d8b6fa2 /plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h | |
parent | 0851c3965879663c41cfe435d1b320ba68cf873a (diff) |
SMS plugin adopted (32bit version only)
git-svn-id: http://svn.miranda-ng.org/main/trunk@2831 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h')
-rw-r--r-- | plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h b/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h new file mode 100644 index 0000000000..002f76e44c --- /dev/null +++ b/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h @@ -0,0 +1,71 @@ +#if !defined(AFX_MEMORYFINDBYTE__H__INCLUDED_)
+#define AFX_MEMORYFINDBYTE__H__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+
+__inline LPVOID MemoryFindByte(SIZE_T dwFrom,LPCVOID lpcSource,SIZE_T dwSourceSize,unsigned char chWhatFind)
+{
+ LPVOID lpRet=NULL;
+
+ if (lpcSource && dwSourceSize)
+ {
+ if (dwFrom<dwSourceSize)
+ {
+ lpRet=(LPVOID)memchr((LPCVOID)(((SIZE_T)lpcSource)+dwFrom),chWhatFind,(dwSourceSize-dwFrom));
+ }
+ }
+return(lpRet);
+}
+
+
+
+__inline LPVOID MemoryFindByteReverse(SIZE_T dwFrom,LPCVOID lpcSource,SIZE_T dwSourceSize,unsigned char chWhatFind)
+{
+ LPVOID lpRet=NULL;
+
+ __asm
+ {
+ push ebx // сохраняем регистр
+ push edi // сохраняем регистр
+ push esi // сохраняем регистр
+
+ mov ecx,dwSourceSize
+ test ecx,ecx //; проверка входного параметра, он !=0
+ je short end_func
+
+ mov edi,lpcSource //; di = string
+ test edi,edi //; проверка входного параметра, он !=0
+ jz short end_func
+
+ mov eax,dwFrom
+
+/////////////////////////////////////////////
+ cmp eax,ecx //; проверка ecx(=len)=>dwFrom
+ jae short end_func
+
+ std //; count 'up' on string this time
+ sub ecx,eax //; уменьшаем длинну на dwFrom(нач смещен)
+ add edi,ecx //; сдвигаем начало на dwSourceSize(на конец)
+ mov al,chWhatFind //; al=search byte
+ repne scasb //; find that byte
+ inc edi //; di points to byte which stopped scan
+ cmp [edi],al //; see if we have a hit
+ jne short end_func //; yes, point to byte
+ mov lpRet,edi //; ax=pointer to byte
+ end_func:
+
+ cld
+ pop esi // восстанавливаем содержимое регистра
+ pop edi // восстанавливаем содержимое регистра
+ pop ebx // восстанавливаем содержимое регистра
+ }
+return(lpRet);
+}
+
+
+
+#endif // !defined(AFX_MEMORYFINDBYTE__H__INCLUDED_)
|