summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/MRA/Mra.cpp516
-rw-r--r--protocols/MRA/Mra.vcxproj16
2 files changed, 10 insertions, 522 deletions
diff --git a/protocols/MRA/Mra.cpp b/protocols/MRA/Mra.cpp
index 69a8a6574a..da3158bea7 100644
--- a/protocols/MRA/Mra.cpp
+++ b/protocols/MRA/Mra.cpp
@@ -1,405 +1,5 @@
#include "Mra.h"
-
-
-
-
-
-#ifndef _WIN64
-
-/*extern "C" __declspec(naked) void _chkstk()
-{
- #define _PAGESIZE_ 4096
-
- __asm
- {
- push ecx
-
- ; Calculate new TOS.
-
- lea ecx, [esp] + 8 - 4 ; TOS before entering function + size for ret value
- sub ecx, eax ; new TOS
-
- ; Handle allocation size that results in wraparound.
- ; Wraparound will result in StackOverflow exception.
-
- sbb eax, eax ; 0 if CF==0, ~0 if CF==1
- not eax ; ~0 if TOS did not wrapped around, 0 otherwise
- and ecx, eax ; set to 0 if wraparound
-
- mov eax, esp ; current TOS
- and eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary
-
- cs10:
- cmp ecx, eax ; Is new TOS
- jb short cs20 ; in probed page?
- mov eax, ecx ; yes.
- pop ecx
- xchg esp, eax ; update esp
- mov eax, dword ptr [eax] ; get return address
- mov dword ptr [esp], eax ; and put it at new TOS
- ret
-
- ; Find next lower page and probe
- cs20:
- sub eax, _PAGESIZE_ ; decrease by PAGESIZE
- test dword ptr [eax],eax ; probe page.
- jmp short cs10
-
- }
-}//*/
-
-
-
-
-/*extern "C" __declspec(naked) void __cdecl _chkstk()
-{
- _asm { jz esp_okay };
- _asm { int 3 };
-esp_okay:
- _asm { ret };
-} //*/
-
-
-
-
-
-
- /*//_alloca_probe_16 : 16 byte aligned alloca
- extern "C" void _alloca_probe_16()
- {
- __asm
- {
- push ecx
- lea ecx, [esp] + 8 ; TOS before entering this function
- sub ecx, eax ; New TOS
- and ecx, (16 - 1) ; Distance from 16 bit align (align down)
- add eax, ecx ; Increase allocation size
- sbb ecx, ecx ; ecx = 0xFFFFFFFF if size wrapped around
- or eax, ecx ; cap allocation size on wraparound
- pop ecx ; Restore ecx
- jmp _chkstk
- }
- }
-
- //alloca_8: 8 byte aligned alloca
- extern "C" void _alloca_probe_8()
- {
- __asm
- {
- push ecx
- lea ecx, [esp] + 8 ; TOS before entering this function
- sub ecx, eax ; New TOS
- and ecx, (8 - 1) ; Distance from 8 bit align (align down)
- add eax, ecx ; Increase allocation Size
- sbb ecx, ecx ; ecx = 0xFFFFFFFF if size wrapped around
- or eax, ecx ; cap allocation size on wraparound
- pop ecx ; Restore ecx
- jmp _chkstk
- }
- }//*/
-
-/*extern "C" void __cdecl _chkstk()
-{
- __asm
- {
- push ebp
- sub eax, 4
- xchg [esp+4], ebp
- sub esp, eax
- xchg [esp], ebp
- mov ebp, esp
- add ebp, eax
- mov ebp, [ebp]
- }
-}//*/
-
-
-
-/*#define _PAGESIZE_ 1000h
-
-#if !defined (__MARM__)
-extern "C" void __declspec(naked) _chkstk(void)
-{
- _asm
- {
- push ecx
- cmp eax,_PAGESIZE_
- lea ecx,[esp] + 8
- jb short lastpage
-
- probepages:
- sub ecx,_PAGESIZE_
- sub eax,_PAGESIZE_
-
- test dword ptr [ecx],eax
-
- cmp eax,_PAGESIZE_
- jae short probepages
-
- lastpage:
- sub ecx,eax
- mov eax,esp
-
- test dword ptr [ecx],eax
-
- mov esp,ecx
-
- mov ecx,dword ptr [eax]
- mov eax,dword ptr [eax + 4]
-
- push eax
- ret
- }
-}
-#endif**/
-
-
-
-/*// будем тока выделять место в стеке под переменные
-extern "C" __declspec(naked) void _chkstk()
-{
- __asm
- {
- // Enter: EAX = size
-
- xor ebx, ebx
- xchg [esp], ebx // запоминаем адрес возврата
- add esp, 4 // удаляем его
- sub esp, eax // выделяем место
- push ebx // кладем адрес возврата на место и возвращаемся
- retn
- }
-}//*/
-
-
-
-//extern "C" void __declspec(naked) __cdecl _chkesp()
-/*extern "C" __declspec(naked) void __cdecl _chkstk()
-{
-#ifndef _PAGESIZE_
- #define _PAGESIZE_ 1000h
-#endif //_PAGESIZE_
-
- __asm
- {
- push ecx // save ecx
- cmp eax, _PAGESIZE_ // more than one page requested?
- lea ecx, [esp] + 8 // compute new stack pointer in ecx
- // correct for return address and
- // saved ecx
- jb short lastpage // no
-
-
-probepages:
-
- sub ecx, _PAGESIZE_ // yes, move down a page
- sub eax, _PAGESIZE_ // adjust request and...
-
- test dword ptr [ecx], eax // ...probe it
-
- cmp eax, _PAGESIZE_ // more than one page requested?
- jae short probepages // no
-
-
-lastpage:
-
- sub ecx, eax // move stack down by eax
- mov eax, esp // save current tos and do a...
-
- test dword ptr [ecx], eax // ...probe in case a page was crossed
-
- mov esp, ecx // set the new stack pointer
-
- mov ecx, dword ptr [eax] // recover ecx
- mov eax, dword ptr [eax + 4]// recover return address
-
- push eax // prepare return address
- // ...probe in case a page was crossed
- ret
- }
-}//*/
-
-
-
-
-
-
-extern "C" __declspec(naked) void __cdecl _chkstk()
-{
- #define _PAGESIZE_ 4096
-
- __asm
- {
- push ecx
-
- ; Calculate new TOS.
-
- lea ecx, [esp] + 8 - 4 ; TOS before entering function + size for ret value
- sub ecx, eax ; new TOS
-
- ; Handle allocation size that results in wraparound.
- ; Wraparound will result in StackOverflow exception.
-
- sbb eax, eax ; 0 if CF==0, ~0 if CF==1
- not eax ; ~0 if TOS did not wrapped around, 0 otherwise
- and ecx, eax ; set to 0 if wraparound
-
- mov eax, esp ; current TOS
- and eax, not ( _PAGESIZE_ - 1) ; Round down to current page boundary
-
- cs10:
- cmp ecx, eax ; Is new TOS
- jb short cs20 ; in probed page?
- mov eax, ecx ; yes.
- pop ecx
- xchg esp, eax ; update esp
- mov eax, dword ptr [eax] ; get return address
- mov dword ptr [esp], eax ; and put it at new TOS
- ret
-
- ; Find next lower page and probe
- cs20:
- sub eax, _PAGESIZE_ ; decrease by PAGESIZE
- test dword ptr [eax],eax ; probe page.
- jmp short cs10
-
- }
-}//
-
-
-extern "C" void __declspec(naked) __cdecl _aulldiv()
-{// http://tamiaode.3322.org/svn/ntldr/trunk/source/ntldr/ia32/x86stub.cpp
- __asm
- {
- push ebx
- push esi
-
- mov eax,[esp + 24]
- or eax,eax
- jnz short L1
-
- mov ecx,[esp + 20]
- mov eax,[esp + 16]
- xor edx,edx
- div ecx
- mov ebx,eax
- mov eax,[esp + 12]
- div ecx
- mov edx,ebx
- jmp short L2
-
- L1:
- mov ecx,eax
- mov ebx,[esp + 20]
- mov edx,[esp + 14]
- mov eax,[esp + 12]
-
- L3:
- shr ecx,1
- rcr ebx,1
- shr edx,1
- rcr eax,1
- or ecx,ecx
- jnz short L3
- div ebx
- mov esi,eax
-
- mul dword ptr [esp + 24]
- mov ecx,eax
- mov eax,[esp + 20]
- mul esi
- add edx,ecx
- jc short L4
-
- cmp edx,[esp + 16]
- ja short L4
- jb short L5
- cmp eax,[esp + 12]
- jbe short L5
- L4:
- dec esi
- L5:
- xor edx,edx
- mov eax,esi
-
- L2:
-
- pop esi
- pop ebx
-
- ret 16
- }
-}//
-
-//
-// LONG64 mul
-//
-extern "C" void __declspec(naked) __cdecl _allmul()
-{
- __asm
- {
- mov eax,[esp + 4][4]
- mov ecx,[esp + 12][4]
- or ecx,eax
- mov ecx,[esp + 12]
- jnz short hard
-
- mov eax,[esp + 4]
- mul ecx
- ret 16
-
-hard:
- push ebx
- mul ecx
- mov ebx,eax
- mov eax,[esp + 8]
- mul dword ptr [esp + 16][4]
- add ebx,eax
- mov eax,[esp + 8]
- mul ecx
- add edx,ebx
- pop ebx
-
- ret 16
- }
-}//*/
-
-
-//
-// 64bits shift left
-//
-extern "C" __declspec(naked) void __cdecl _allshl()
-{
- __asm
- {
- cmp cl, 64
- jae short RETZERO
-
- cmp cl, 32
- jae short MORE32
- shld edx,eax,cl
- shl eax,cl
- ret
-
- MORE32:
- mov edx,eax
- xor eax,eax
- and cl,31
- shl edx,cl
- ret
-
- RETZERO:
- xor eax,eax
- xor edx,edx
- ret
- }
-}
-#endif
-
-
-
-
PLUGINLINK *pluginLink;
MM_INTERFACE mmi;
MRA_SETTINGS masMraSettings;
@@ -428,10 +28,6 @@ int OnPreShutdown (WPARAM wParam,LPARAM lParam);
void VersionConversions ();
-
-
-
-
BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID Reserved)
{
switch(dwReason){
@@ -452,55 +48,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID Reserved)
break;
}
- /*BYTE szBuff[1024]={0};
- LPSTR lpszString="\r\n\t GET \t \r\n \r\n \r\n http://mail.ru/ \tHTTP/1.1 \t ";
- LPSTR lpszFindString="123456 ";
- LPSTR lpszWhatFindString="123456";
- SIZE_T dwStringLen=lstrlenA(lpszString),dwBuffSize,dwBuffLen;
-
-//#define LWSHT "\r\n\t"
-//#define LWSSP "\r\n "
-
-
- //lpszString=(LPSTR)MemoryFind(0,lpszFindString,(lstrlenA(lpszFindString)),lpszWhatFindString,lstrlenA(lpszWhatFindString));
- //lpszString=(LPSTR)MemoryFindByte(0,lpszFindString,(lstrlenA(lpszFindString)-1),'6');
-
-
- //WSP2SP(lpszString,dwStringLen,(LPSTR)szBuff,&dwBuffSize);
- //HT2SP(lpszString,dwStringLen,(LPSTR)szBuff,&dwBuffSize);
- CleanUnneededSP(lpszString,dwStringLen,(LPSTR)szBuff,&dwBuffSize);
-
- dwBuffLen=lstrlenA((LPSTR)szBuff);
- if (dwBuffSize!=dwBuffLen) DebugBreak();
- //*/
-
-
- /*LPCSTR lpszHeader,lpszHeaderLow,lpszValueName;
- LPSTR lpszValueNameRet;
- SIZE_T dwHeaderSize,dwValueNameSize,dwValueNameRetSize;
- CHAR szHeader[4096]={0},szHeaderLow[4096]={0};
-
- //lstrcpynA(szHeader,"Server: squid/3.1.0.15\r\nMime-Version: 1.0\r\nContent-Length: 0\r\nX-Cache: MISS from Firewall\r\nProxy-Connection: keep-alive",SIZEOF(szHeader));
- lstrcpynA(szHeader,"http/1.0 200 ok\r\nserver: apache-coyote/1.1\r\ndate: fri, 30 apr 2010 08:36:10 gmt\r\nlast-modified: wed, 28 apr 2010 03:22:49 gmt\r\ncache-control: max-age=360000\r\ncontent-type: \r\ncontent-length: 55946",SIZEOF(szHeader));
- lpszHeader=(LPCSTR)szHeader;
- lpszHeaderLow=(LPCSTR)szHeaderLow;
- dwHeaderSize=lstrlenA(lpszHeader);
-
- //lpszValueName="proxy-connection";
- //lpszValueName="content-length";
- lpszValueName="content-type";
- dwValueNameSize=lstrlenA(lpszValueName);
-
-
- BuffToLowerCase(lpszHeaderLow,lpszHeader,dwHeaderSize);
-
- HeaderValueGet(lpszHeader,lpszHeaderLow,dwHeaderSize,lpszValueName,dwValueNameSize,&lpszValueNameRet,&dwValueNameRetSize);
- //HeaderValueRemove(lpszHeader,lpszHeaderLow,dwHeaderSize,&dwBuffLen,lpszValueName,dwValueNameSize);
- szHeader[dwBuffLen]=0;
- szHeaderLow[dwBuffLen]=0;//*/
-
-
-return(TRUE);
+ return(TRUE);
}
@@ -601,35 +149,6 @@ extern "C" MRA_API int Load(PLUGINLINK *link)
}
}
-
- /*HMODULE hDLLCrypt32=LoadLibraryW(L"Crypt32.dll");
- if (hDLLCrypt32)
- {
- HANDLE hFunc=(HANDLE)GetProcAddress(hDLLCrypt32,"CryptProtectMemory");
- FreeLibrary(hDLLCrypt32);
- }
-
- HMODULE hDLLAdvapi32=LoadLibraryW(L"Advapi32.dll");
- if (hDLLAdvapi32)
- {
- HANDLE hFunc=(HANDLE)GetProcAddress(hDLLAdvapi32,"SystemFunction040");
- FreeLibrary(hDLLAdvapi32);
- }
-
- for(DWORD i=0;i<MRA_XSTATUS_COUNT;i++)
- {
- if (lstrlenA(lpcszXStatusNameDef[i])>STATUS_TITLE_MAX)
- {
- DebugPrintCRLF(lpcszXStatusNameDef[i]);
- }
- if (lstrlenA(TranslateW(lpcszXStatusNameDef[i]))>STATUS_TITLE_MAX)
- {
- DebugPrintCRLF(TranslateW(lpcszXStatusNameDef[i]));
- }
- }*/
-
-
-
InitializeCriticalSectionAndSpinCount(&masMraSettings.csCriticalSectionSend,0);
MraSendQueueInitialize(0,&masMraSettings.hSendQueueHandle);
MraFilesQueueInitialize(0,&masMraSettings.hFilesQueueHandle);
@@ -752,15 +271,6 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam)
#endif
MraAvatarsQueueInitialize(&masMraSettings.hAvatarsQueueHandle);
- /*{
- HANDLE hContact;
- for(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);hContact!=NULL;hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0))
- {// функция сама проверяет принадлежность контакта к MRA
- if (IsContactMra(hContact)) break;
- }
- DB_Mra_DeleteValue(hContact,"AvatarLastCheckTime");
- MraAvatarsQueueGetAvatar(masMraSettings.hAvatarsQueueHandle,GAIF_FORCE,hContact,NULL,NULL,NULL);
- }//*/
VersionConversions();
@@ -770,28 +280,8 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam)
CallService(MS_UPDATE_REGISTERFL,(WPARAM)MRA_PLUGIN_UPDATER_ID,(LPARAM)&pluginInfoEx);
-
- //hHookOnUserInfoInit=HookEvent(ME_USERINFO_INITIALISE,MsnOnDetailsInit);
-
-
- /*//BYTE btRND[MAX_PATH]={0};
- char szPass[MAX_PATH]={0};
- //LPSTR lpszPass="1234567890";
- SIZE_T dwBuffLen;
-
- //dwBuffLen=lstrlenA(lpszPass);
- //SetPassDB(lpszPass,dwBuffLen);
- GetPassDB(szPass,sizeof(szPass),&dwBuffLen);
-
- MessageBoxA(NULL,szPass,"Password",(MB_OK));
-
- //*/
-
-
InterlockedExchange((volatile LONG*)&masMraSettings.dwGlobalPluginRunning,TRUE);
- //MraSetStatus(ID_STATUS_OFFLINE,0);
-
DebugPrintCRLFW(L"OnModulesLoaded - DONE");
return(0);
}
@@ -905,8 +395,4 @@ void VersionConversions()
DB_Mra_DeleteValue(NULL,"Password");
}
}
-
-//*/
}
-
-
diff --git a/protocols/MRA/Mra.vcxproj b/protocols/MRA/Mra.vcxproj
index cee08ebc76..9da2641b77 100644
--- a/protocols/MRA/Mra.vcxproj
+++ b/protocols/MRA/Mra.vcxproj
@@ -28,6 +28,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -109,10 +110,8 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <PrecompiledHeaderFile>
- </PrecompiledHeaderFile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Mra.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalIncludeDirectories>./sdk;../../include;../../Plugins/ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -203,12 +202,12 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
- <PrecompiledHeader>
- </PrecompiledHeader>
+ <PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>./sdk;../../include;../../Plugins/ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
+ <PrecompiledHeaderFile>Mra.h</PrecompiledHeaderFile>
</ClCompile>
<ProjectReference />
<Link>
@@ -296,7 +295,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="Mra.cpp" />
+ <ClCompile Include="Mra.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ </ClCompile>
<ClCompile Include="Mra_functions.cpp" />
<ClCompile Include="Mra_options.cpp" />
<ClCompile Include="Mra_proto.cpp" />