summaryrefslogtreecommitdiff
path: root/plugins/SMS/src/AdditionalFunctions
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SMS/src/AdditionalFunctions')
-rw-r--r--plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h56
-rw-r--r--plugins/SMS/src/AdditionalFunctions/ListMT.h4
-rw-r--r--plugins/SMS/src/AdditionalFunctions/MemoryCompare.h175
-rw-r--r--plugins/SMS/src/AdditionalFunctions/MemoryFind.h81
-rw-r--r--plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h60
5 files changed, 22 insertions, 354 deletions
diff --git a/plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h b/plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h
deleted file mode 100644
index d2bb7a6671..0000000000
--- a/plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#if !defined(AFX_BUFFTOLOWERCASE__H__INCLUDED_)
-#define AFX_BUFFTOLOWERCASE__H__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-
-
-__inline DWORD BuffToLowerCase(LPCVOID lpcOutBuff,LPCVOID lpcBuff,SIZE_T dwLen)
-{
- DWORD dwRetErrorCode=NO_ERROR;
-
- __asm
- {
- mov ecx,dwLen
- test ecx,ecx
- jz short end_func
-
- push ebx // сохраняем регистр
- push edi // сохраняем регистр
- push esi // сохраняем регистр
- mov esi,lpcBuff
- mov edi,lpcOutBuff
- mov bl,'A'
- mov bh,'Z'
- mov ah,32
- cld
-
- lowcaseloop:
- lodsb
- cmp al,bl
- jl short savebyte
- cmp al,bh
- jg short savebyte
- or al,ah
-
- savebyte:
- stosb
-
- dec ecx
- jnz short lowcaseloop
-
- pop esi // восстанавливаем содержимое регистра
- pop edi // восстанавливаем содержимое регистра
- pop ebx // восстанавливаем содержимое регистра
- end_func:
- }
-
-return(dwRetErrorCode);
-}
-
-
-
-
-#endif // !defined(AFX_BUFFTOLOWERCASE__H__INCLUDED_) \ No newline at end of file
diff --git a/plugins/SMS/src/AdditionalFunctions/ListMT.h b/plugins/SMS/src/AdditionalFunctions/ListMT.h
index fd9ab3baaf..7d7884ec66 100644
--- a/plugins/SMS/src/AdditionalFunctions/ListMT.h
+++ b/plugins/SMS/src/AdditionalFunctions/ListMT.h
@@ -67,7 +67,7 @@ __inline DWORD ListMTInitialize(PCLIST_MT pclmtListMT,DWORD dwSpinCount)
if (TRUE)
#endif
{
- InterlockedExchangePointer(&pclmtListMT->nCount,NULL);
+ InterlockedExchangePointer((volatile PVOID*)&pclmtListMT->nCount,NULL);
pclmtListMT->plmtiFirst=NULL;
pclmtListMT->plmtiLast=NULL;
dwRetErrorCode=NO_ERROR;
@@ -80,7 +80,7 @@ return(dwRetErrorCode);
__inline void ListMTDestroy(PCLIST_MT pclmtListMT)
{
- InterlockedExchangePointer(&pclmtListMT->nCount,NULL);
+ InterlockedExchangePointer((volatile PVOID*)&pclmtListMT->nCount,NULL);
pclmtListMT->plmtiFirst=NULL;
pclmtListMT->plmtiLast=NULL;
DeleteCriticalSection(&pclmtListMT->cs);
diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h b/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h
index de663c6d8a..3fdb5e08b3 100644
--- a/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h
+++ b/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h
@@ -5,173 +5,32 @@
#pragma once
#endif // _MSC_VER > 1000
-
-// If the string pointed to by lpString1 is less than the string pointed
-// to by lpString2, the return value is negative.
-// If the string pointed to by lpString1 is greater than the string pointed
-// to by lpString2, the return value is positive.
-// If the strings are equal, the return value is zero.
-//
-// lpString1<lpString2 >> ret=1=CSTR_LESS_THAN
-// lpString1=lpString2 >> ret=2=CSTR_EQUAL
-// lpString1>lpString2 >> ret=3=CSTR_GREATER_THAN
-
-
-/*__inline DWORD MemoryCompare(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size)
-{
- DWORD dwRet;
-
- __asm
- {
- mov ecx,dwSource1Size //; ecx = Source string 1 Size
- cmp ecx,dwSource2Size //; сверяем длинны участков памяти
- jg short greater_than
- jl short less_than
- test ecx,ecx
- jz short equal //; NULL=NULL
-
- mov esi,lpcSource1 //; edi = Source string 1
- mov edi,lpcSource2 //; esi = Source string 2
- cmp edi,esi //; сверяем указатели на участки памяти
- je short equal //; это один и тотже участок, они естественно равны
-
- test esi,esi //; lpcSource1=NULL, lpcSource1<lpcSource2
- jz short less_than //; CSTR_LESS_THAN
-
- test edi,edi //; lpcSource2=NULL, lpcSource1>lpcSource2
- jz short greater_than //; CSTR_GREATER_THAN
-
- //cld //; сканируя в прямом направлении
-
- repe cmpsb //; цикл сравнения.
- cmp_loop:
- //sub ecx,4
- //jz short equal
-
- //inc esi
- //inc edi
- //mov al,byte ptr [esi]
- //cmpsd
- //cmp al,byte ptr [edi]
- //je short cmp_loop
- jg short greater_than
- jl short less_than
-
- equal: //; если мы попали сюда, значит, они
- mov dwRet,CSTR_EQUAL //; совпадают (match)
- jmp end_func
- less_than: //; не совпадают
- mov dwRet,CSTR_LESS_THAN
- jmp end_func
- greater_than:
- mov dwRet,CSTR_GREATER_THAN
-
- end_func:
- }
-return(dwRet);
-}//*/
-
__inline DWORD MemoryCompare(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size)
{
- DWORD dwRet;
+ if (dwSource1Size == dwSource2Size) {
+ if (lpcSource1 == lpcSource2)
+ return CSTR_EQUAL;
- if (dwSource1Size==dwSource2Size)
- {
- if (lpcSource1==lpcSource2)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if (lpcSource1 && lpcSource2)
- {
+ if (lpcSource1 && lpcSource2) {
#ifdef _INC_MEMORY
- dwRet=(2+memcmp(lpcSource1,lpcSource2,dwSource1Size));
+ return 2 + memcmp(lpcSource1,lpcSource2,dwSource1Size));
#else
- SIZE_T dwDiffPosition;
-
- //dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
- for(dwDiffPosition=0; (dwDiffPosition<dwSource1Size) && (((const BYTE*)lpcSource1)[dwDiffPosition]==((const BYTE*)lpcSource2)[dwDiffPosition]); dwDiffPosition++);
- if (dwDiffPosition==dwSource1Size)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition))))
- {
- dwRet=CSTR_GREATER_THAN;
- }else{
- dwRet=CSTR_LESS_THAN;
- }
- }
-#endif
- }else{
- if (lpcSource1)
- {//lpcSource2==NULL
- dwRet=CSTR_GREATER_THAN;
- }else{//lpcSource1==NULL
- dwRet=CSTR_LESS_THAN;
- }
- }
- }
- }else{
- if (dwSource1Size<dwSource2Size)
- {
- dwRet=CSTR_LESS_THAN;
- }else{
- dwRet=CSTR_GREATER_THAN;
- }
- }
-return(dwRet);
-}//*/
+ SIZE_T dwDiffPosition;
+ //dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
+ for(dwDiffPosition=0; (dwDiffPosition<dwSource1Size) && (((const BYTE*)lpcSource1)[dwDiffPosition]==((const BYTE*)lpcSource2)[dwDiffPosition]); dwDiffPosition++);
+ if (dwDiffPosition==dwSource1Size)
+ return CSTR_EQUAL;
-/*
-__inline DWORD MemoryCompareEx(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size,SIZE_T *pdwDiffPosition)
-{
- DWORD dwRet;
-
- if (dwSource1Size==dwSource2Size)
- {
- if (lpcSource1==lpcSource2)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if (lpcSource1 && lpcSource2)
- {
- SIZE_T dwDiffPosition;
-
- dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
- if (dwDiffPosition==dwSource1Size)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition))))
- {
- dwRet=CSTR_GREATER_THAN;
- }else{
- dwRet=CSTR_LESS_THAN;
- }
- }
-
- if (pdwDiffPosition) (*pdwDiffPosition)=dwDiffPosition;
- }else{
- if (lpcSource1)
- {//lpcSource2==NULL
- dwRet=CSTR_GREATER_THAN;
- }else{//lpcSource1==NULL
- dwRet=CSTR_LESS_THAN;
- }
- }
- }
- }else{
- if (dwSource1Size<dwSource2Size)
- {
- dwRet=CSTR_LESS_THAN;
- }else{
- dwRet=CSTR_GREATER_THAN;
+ if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition))))
+ return CSTR_GREATER_THAN;
+
+ return CSTR_LESS_THAN;
+#endif
}
+ return (lpcSource1) ? CSTR_GREATER_THAN : CSTR_LESS_THAN;
}
-return(dwRet);
+ return (dwSource1Size < dwSource2Size) ? CSTR_LESS_THAN : CSTR_GREATER_THAN;
}
-*/
-
#endif // !defined(AFX_MEMORYCOMPARE__H__INCLUDED_)
diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryFind.h b/plugins/SMS/src/AdditionalFunctions/MemoryFind.h
deleted file mode 100644
index dbc5f1a2d1..0000000000
--- a/plugins/SMS/src/AdditionalFunctions/MemoryFind.h
+++ /dev/null
@@ -1,81 +0,0 @@
-#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<ulWhatFindSize, => 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_)
diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h b/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h
index 002f76e44c..83ca9c5468 100644
--- a/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h
+++ b/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h
@@ -5,67 +5,13 @@
#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;
+ if (dwFrom < dwSourceSize)
+ return memchr((BYTE*)lpcSource + dwFrom, chWhatFind, dwSourceSize-dwFrom);
- __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);
+ return NULL;
}
-
-
#endif // !defined(AFX_MEMORYFINDBYTE__H__INCLUDED_)