From 9c62ad6bb204781819184f772992fec768cb4418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Thu, 12 Jul 2012 12:09:32 +0000 Subject: Added SMS (not adopted yet) git-svn-id: http://svn.miranda-ng.org/main/trunk@919 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SMS/AdditionalFunctions/MemoryFind.h | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 plugins/SMS/AdditionalFunctions/MemoryFind.h (limited to 'plugins/SMS/AdditionalFunctions/MemoryFind.h') diff --git a/plugins/SMS/AdditionalFunctions/MemoryFind.h b/plugins/SMS/AdditionalFunctions/MemoryFind.h new file mode 100644 index 0000000000..dbc5f1a2d1 --- /dev/null +++ b/plugins/SMS/AdditionalFunctions/MemoryFind.h @@ -0,0 +1,81 @@ +#if !defined(AFX_MEMORYFIND__H__INCLUDED_) +#define AFX_MEMORYFIND__H__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +__inline LPVOID MemoryFind(SIZE_T dwFrom,LPCVOID lpcSource,SIZE_T dwSourceSize,LPCVOID lpcWhatFind,SIZE_T dwWhatFindSize) +{ + LPVOID lpRet=NULL; + + __asm + { + push ebx // сохраняем регистр + push edi // сохраняем регистр + push esi // сохраняем регистр + + mov ecx,dwSourceSize //; ecx = Source string Size + test ecx,ecx // is size unknown? + jz short end_func + + mov edx,dwWhatFindSize //; edx = WhatFind string Size + test edx,edx // is size unknown? + jz short end_func + + mov ebx,dwFrom // ebx - start pos in Source string + mov edi,lpcSource //; edi = Source string + mov esi,lpcWhatFind //; esi = WhatFind string + + cmp ebx,ecx // проверка ecx(=len)=>ulFrom + jae short end_func + + add edi,ebx // сдвигаем начало на ulFrom(нач смещен) + sub ecx,ebx // уменьшаем длинну SourceSize на ulFrom(нач смещен) + + cmp ecx,edx // проверка NEWSourceSize ??? ulWhatFindSize + je short begin_memorycompare // NEWulSourceSize==ulWhatFindSize, Source ??? WhatFind + jl short end_func // NEWulSourceSize Source!=WhatFind + + sub ecx,edx // уменьшаем длинну SourceSize на ulWhatFindSize + inc ecx + + mov al,[esi] //; al=search byte + dec edi + cld //; сканируя в прямом направлении + + find_loop: + test ecx,ecx + jz short end_func + inc edi + repne scasb //; find that byte + dec 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 + + begin_memorycompare: + push esi + push edi + push ecx + mov ecx,edx //; ulWhatFindSize байтов (CX используется в REPE), + repe cmpsb //; сравниваем их. + pop ecx + pop edi + pop esi + jne short find_loop //; признак ZF = 0, если сравниваемые + //; строки не совпадают (mismatch) match: + //; если мы попали сюда, значит, они + //; совпадают (match) + mov lpRet,edi //; ax=pointer to byte + end_func: + + pop esi // восстанавливаем содержимое регистра + pop edi // восстанавливаем содержимое регистра + pop ebx // восстанавливаем содержимое регистра + } +return(lpRet); +} + + +#endif // !defined(AFX_MEMORYFIND__H__INCLUDED_) -- cgit v1.2.3