From 4917567d0e33f20b07b004c368cd66e301115db0 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 23 Sep 2013 15:13:53 +0000 Subject: small plugins cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@6193 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AVS/src/main.cpp | 16 ++++--------- plugins/AutoShutdown/shutdown_10.vcxproj | 8 +++---- plugins/AutoShutdown/shutdown_11.vcxproj | 8 +++---- plugins/AutoShutdown/src/common.h | 1 + plugins/AutoShutdown/src/utils.cpp | 12 +++------- plugins/BossKeyPlus/src/BossKeyIdle.cpp | 28 +++++----------------- plugins/Clist_mw/clist_mw_10.vcxproj | 8 +++---- plugins/Clist_mw/clist_mw_11.vcxproj | 8 +++---- plugins/Clist_mw/src/BkgrCfg.cpp | 6 +---- plugins/Clist_mw/src/clcopts.cpp | 10 ++------ plugins/Clist_mw/src/commonheaders.h | 1 + plugins/Clist_nicer/src/clcopts.cpp | 5 +--- plugins/Clist_nicer/src/clistmod.cpp | 7 ++---- plugins/Dbx_tree/src/DataBase.cpp | 5 +--- plugins/Dbx_tree/src/MappedMemory.cpp | 40 ++++++-------------------------- plugins/Dbx_tree/src/MappedMemory.h | 2 -- 16 files changed, 45 insertions(+), 120 deletions(-) (limited to 'plugins') diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index 83a36ea251..465edd4587 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -41,8 +41,6 @@ HANDLE hEventChanged, hEventContactAvatarChanged, hMyAvatarChanged; void InitServices(); -BOOL (WINAPI *AvsAlphaBlend)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION) = NULL; - static int ComparePicture( const protoPicCacheEntry* p1, const protoPicCacheEntry* p2 ) { if ((lstrcmpA(p1->szProtoname, "Global avatar") == 0) || strstr(p1->szProtoname, "Global avatar")) @@ -314,12 +312,12 @@ void InternalDrawAvatar(AVATARDRAWREQUEST *r, HBITMAP hbm, LONG bmWidth, LONG bm //else // FillRect(r->hTargetDC, &r->rcDraw, (HBRUSH)GetStockObject(BLACK_BRUSH)); - if (r->dwFlags & AVDRQ_FORCEFASTALPHA && !(r->dwFlags & AVDRQ_AERO) && AvsAlphaBlend) { - AvsAlphaBlend( + if (r->dwFlags & AVDRQ_FORCEFASTALPHA && !(r->dwFlags & AVDRQ_AERO)) { + GdiAlphaBlend( r->hTargetDC, r->rcDraw.left + leftoffset, r->rcDraw.top + topoffset, newWidth, newHeight, hdcAvatar, 0, 0, bmWidth, bmHeight, bf); } else { - if ((bf.SourceConstantAlpha == 255 && bf.AlphaFormat == 0 && !(r->dwFlags & AVDRQ_FORCEALPHA) && !(r->dwFlags & AVDRQ_AERO)) || !AvsAlphaBlend) { + if (bf.SourceConstantAlpha == 255 && bf.AlphaFormat == 0 && !(r->dwFlags & AVDRQ_FORCEALPHA) && !(r->dwFlags & AVDRQ_AERO)) { StretchBlt(r->hTargetDC, r->rcDraw.left + leftoffset, r->rcDraw.top + topoffset, newWidth, newHeight, hdcAvatar, 0, 0, bmWidth, bmHeight, SRCCOPY); } else { /* @@ -335,7 +333,7 @@ void InternalDrawAvatar(AVATARDRAWREQUEST *r, HBITMAP hbm, LONG bmWidth, LONG bm HDC hdcTemp = CreateCompatibleDC(r->hTargetDC); hbmTempOld = (HBITMAP)SelectObject(hdcTemp, hbmResized); - AvsAlphaBlend( + GdiAlphaBlend( r->hTargetDC, r->rcDraw.left + leftoffset, r->rcDraw.top + topoffset, newWidth, newHeight, hdcTemp, 0, 0, newWidth, newHeight, bf); @@ -430,12 +428,6 @@ static int LoadAvatarModule() InitCache(); InitPolls(); - HMODULE hDll; - if (hDll = GetModuleHandle(_T("gdi32"))) - AvsAlphaBlend = (BOOL (WINAPI *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION)) GetProcAddress(hDll, "GdiAlphaBlend"); - if (AvsAlphaBlend == NULL && (hDll = LoadLibrary(_T("msimg32.dll")))) - AvsAlphaBlend = (BOOL (WINAPI *)(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION)) GetProcAddress(hDll, "AlphaBlend"); - lstrcpyn(g_szDataPath, VARST(_T("%miranda_userdata%")), SIZEOF(g_szDataPath)-1); g_szDataPath[MAX_PATH - 1] = 0; _tcslwr(g_szDataPath); diff --git a/plugins/AutoShutdown/shutdown_10.vcxproj b/plugins/AutoShutdown/shutdown_10.vcxproj index 1c9a7e9cb2..4f6cd5f826 100644 --- a/plugins/AutoShutdown/shutdown_10.vcxproj +++ b/plugins/AutoShutdown/shutdown_10.vcxproj @@ -94,7 +94,7 @@ Windows $(IntDir)$(TargetName).lib 0x11070000 - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;Shlwapi.lib;%(AdditionalDependencies) false $(ProfileDir)..\..\bin10\lib @@ -122,7 +122,7 @@ Windows $(IntDir)$(TargetName).lib 0x11070000 - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;Shlwapi.lib;%(AdditionalDependencies) false $(ProfileDir)..\..\bin10\lib @@ -154,7 +154,7 @@ true true false - $(ProfileDir)..\..\bin10\lib + $(ProfileDir)..\..\bin11\lib comctl32.lib;UxTheme.lib;%(AdditionalDependencies) /PDBALTPATH:%_PDB% @@ -183,7 +183,7 @@ Windows $(IntDir)$(TargetName).lib 0x11070000 - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;Shlwapi.lib;%(AdditionalDependencies) true true false diff --git a/plugins/AutoShutdown/shutdown_11.vcxproj b/plugins/AutoShutdown/shutdown_11.vcxproj index aeef88602a..71b22a5bd5 100644 --- a/plugins/AutoShutdown/shutdown_11.vcxproj +++ b/plugins/AutoShutdown/shutdown_11.vcxproj @@ -98,7 +98,7 @@ Windows $(IntDir)$(TargetName).lib 0x11070000 - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;Shlwapi.lib;%(AdditionalDependencies) false $(ProfileDir)..\..\bin11\lib false @@ -127,7 +127,7 @@ Windows $(IntDir)$(TargetName).lib 0x11070000 - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;Shlwapi.lib;%(AdditionalDependencies) false $(ProfileDir)..\..\bin11\lib @@ -160,7 +160,7 @@ true false $(ProfileDir)..\..\bin11\lib - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;Shlwapi.lib;%(AdditionalDependencies) @@ -187,7 +187,7 @@ Windows $(IntDir)$(TargetName).lib 0x11070000 - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;Shlwapi.lib;%(AdditionalDependencies) true true false diff --git a/plugins/AutoShutdown/src/common.h b/plugins/AutoShutdown/src/common.h index 8752f1d0aa..2eae1b9bab 100644 --- a/plugins/AutoShutdown/src/common.h +++ b/plugins/AutoShutdown/src/common.h @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include /* for mktime(),time() */ #include #include +#include /* WinXP+: shutdown reason codes */ #if defined(EWX_RESTARTAPPS) /* new MS Platform SDK */ diff --git a/plugins/AutoShutdown/src/utils.cpp b/plugins/AutoShutdown/src/utils.cpp index 18c893a77d..b510fbd17c 100644 --- a/plugins/AutoShutdown/src/utils.cpp +++ b/plugins/AutoShutdown/src/utils.cpp @@ -160,15 +160,10 @@ BOOL TimeStampToSystemTime(time_t timestamp,SYSTEMTIME *st) BOOL GetFormatedCountdown(TCHAR *pszOut,int nSize,time_t countdown) { static BOOL fInited=FALSE; - static int (WINAPI *pfnStrFromTimeInterval)(TCHAR*,UINT,DWORD,int); static int (WINAPI *pfnGetDurationFormat)(LCID,DWORD,const SYSTEMTIME*,double,WCHAR*,WCHAR*,int); /* Init */ - if(!fInited) { + if(!fInited && IsWinVerVistaPlus()) { *(PROC*)&pfnGetDurationFormat=GetProcAddress(GetModuleHandleA("KERNEL32"),"GetDurationFormat"); - if(pfnGetDurationFormat==NULL) { - HMODULE hShlwDLL=LoadLibraryA("SHLWAPI"); /* all ascii */ - *(PROC*)&pfnStrFromTimeInterval=GetProcAddress(hShlwDLL,"StrFromTimeIntervalW"); - } fInited=TRUE; } /* WinVista */ @@ -180,10 +175,9 @@ BOOL GetFormatedCountdown(TCHAR *pszOut,int nSize,time_t countdown) if(pfnGetDurationFormat(locale,0,&st,0,NULL,pszOut,nSize)) return TRUE; return FALSE; - } + } else /* Win9x/NT/XP */ - if(pfnStrFromTimeInterval!=NULL) - return pfnStrFromTimeInterval(pszOut,nSize,(countdown>(MAXDWORD/1000))?MAXDWORD:(countdown*1000),10)!=0; + return StrFromTimeInterval(pszOut,nSize,(countdown>(MAXDWORD/1000))?MAXDWORD:(countdown*1000),10)!=0; return FALSE; } diff --git a/plugins/BossKeyPlus/src/BossKeyIdle.cpp b/plugins/BossKeyPlus/src/BossKeyIdle.cpp index a71bd2200c..a97bf01abc 100644 --- a/plugins/BossKeyPlus/src/BossKeyIdle.cpp +++ b/plugins/BossKeyPlus/src/BossKeyIdle.cpp @@ -27,8 +27,6 @@ POINT mousepos; UINT_PTR hTimer; UINT mouseidle, minutes; -static BOOL (WINAPI * MyGetLastInputInfo)(PLASTINPUTINFO); - VOID CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT idEvent, DWORD dwTime); static bool IsScreenSaverRunning() @@ -46,25 +44,12 @@ static bool IsUserIdle() return GetTickCount() - dwTick > (minutes * 60 * 1000); } - if ( MyGetLastInputInfo != NULL ) { - LASTINPUTINFO ii; - ZeroMemory(&ii,sizeof(ii)); - ii.cbSize=sizeof(ii); - if ( MyGetLastInputInfo(&ii)) - return GetTickCount() - ii.dwTime > (minutes * 60 * 1000); - } - else { - POINT pt; - GetCursorPos(&pt); - if ( pt.x != mousepos.x || pt.y != mousepos.y ) { - mousepos=pt; - mouseidle=0; - } - else mouseidle += 2; - - if ( mouseidle ) - return mouseidle >= (minutes * 60); - } + LASTINPUTINFO ii; + ZeroMemory(&ii,sizeof(ii)); + ii.cbSize=sizeof(ii); + if (GetLastInputInfo(&ii)) + return GetTickCount() - ii.dwTime > (minutes * 60 * 1000); + return FALSE; } @@ -81,7 +66,6 @@ VOID CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT_PTR idEvent, DWORD dwTime) void InitIdleTimer() { minutes = db_get_b(NULL,MOD_NAME,"time",10); - MyGetLastInputInfo=(BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); hTimer=SetTimer(NULL, 0, 2000, IdleTimer); } diff --git a/plugins/Clist_mw/clist_mw_10.vcxproj b/plugins/Clist_mw/clist_mw_10.vcxproj index c15757ac30..9c0b340767 100644 --- a/plugins/Clist_mw/clist_mw_10.vcxproj +++ b/plugins/Clist_mw/clist_mw_10.vcxproj @@ -89,7 +89,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) true 0x6590000 false @@ -118,7 +118,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) true 0x6590000 @@ -149,7 +149,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) true true @@ -183,7 +183,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) true true diff --git a/plugins/Clist_mw/clist_mw_11.vcxproj b/plugins/Clist_mw/clist_mw_11.vcxproj index 6f33fd2410..f43e276ea3 100644 --- a/plugins/Clist_mw/clist_mw_11.vcxproj +++ b/plugins/Clist_mw/clist_mw_11.vcxproj @@ -93,7 +93,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) true 0x6590000 false @@ -123,7 +123,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) true 0x6590000 @@ -154,7 +154,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) true true @@ -187,7 +187,7 @@ ..\..\include;..\..\include\msapi - comctl32.lib;UxTheme.lib;%(AdditionalDependencies) + comctl32.lib;UxTheme.lib;shlwapi.lib;%(AdditionalDependencies) type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27*%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) true true diff --git a/plugins/Clist_mw/src/BkgrCfg.cpp b/plugins/Clist_mw/src/BkgrCfg.cpp index 237cd6317c..8287bbc5d0 100644 --- a/plugins/Clist_mw/src/BkgrCfg.cpp +++ b/plugins/Clist_mw/src/BkgrCfg.cpp @@ -85,11 +85,7 @@ static INT_PTR CALLBACK DlgProcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP } SendMessage(hList, CB_SETCURSEL, 0, 0); PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_BKGRLIST, CBN_SELCHANGE), 0); - { - HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD); - MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete"); - if (MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1); - } + SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILENAME), 1); return TRUE; } case WM_DESTROY: diff --git a/plugins/Clist_mw/src/clcopts.cpp b/plugins/Clist_mw/src/clcopts.cpp index c9e2dee781..287a8e79d6 100644 --- a/plugins/Clist_mw/src/clcopts.cpp +++ b/plugins/Clist_mw/src/clcopts.cpp @@ -343,10 +343,7 @@ static INT_PTR CALLBACK DlgProcStatusBarBkgOpts(HWND hwndDlg, UINT msg, WPARAM w CheckDlgButton(hwndDlg,IDC_PROPORTIONAL,bmpUse&CLBF_PROPORTIONAL?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hwndDlg,IDC_TILEVROWH,bmpUse&CLBF_TILEVTOROWHEIGHT?BST_CHECKED:BST_UNCHECKED); - HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD); - MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete"); - if (MySHAutoComplete) - MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1); + SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILENAME), 1); } return TRUE; @@ -467,10 +464,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, CheckDlgButton(hwndDlg,IDC_TILEVROWH,bmpUse&CLBF_TILEVTOROWHEIGHT?BST_CHECKED:BST_UNCHECKED); } - { HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND,DWORD); - MySHAutoComplete = (HRESULT (STDAPICALLTYPE*)(HWND,DWORD))GetProcAddress(GetModuleHandleA("shlwapi"),"SHAutoComplete"); - if (MySHAutoComplete) MySHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1); - } + SHAutoComplete(GetDlgItem(hwndDlg,IDC_FILENAME),1); return TRUE; case WM_USER+10: EnableWindow(GetDlgItem(hwndDlg,IDC_FILENAME),IsDlgButtonChecked(hwndDlg,IDC_BITMAP)); diff --git a/plugins/Clist_mw/src/commonheaders.h b/plugins/Clist_mw/src/commonheaders.h index 2aecdd67d3..ca9c6069e4 100644 --- a/plugins/Clist_mw/src/commonheaders.h +++ b/plugins/Clist_mw/src/commonheaders.h @@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include diff --git a/plugins/Clist_nicer/src/clcopts.cpp b/plugins/Clist_nicer/src/clcopts.cpp index d142ae7c02..17f5b0e3b9 100644 --- a/plugins/Clist_nicer/src/clcopts.cpp +++ b/plugins/Clist_nicer/src/clcopts.cpp @@ -747,10 +747,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, CheckDlgButton(hwndDlg, IDC_SCROLL, bmpUse & CLBF_SCROLL ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_PROPORTIONAL, bmpUse & CLBF_PROPORTIONAL ? BST_CHECKED : BST_UNCHECKED); - HRESULT (STDAPICALLTYPE *MySHAutoComplete)(HWND, DWORD); - MySHAutoComplete = (HRESULT(STDAPICALLTYPE *)(HWND, DWORD))GetProcAddress(GetModuleHandleA("shlwapi"), "SHAutoComplete"); - if (MySHAutoComplete) - MySHAutoComplete(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + SHAutoComplete(GetDlgItem(hwndDlg, IDC_FILENAME), 1); } return TRUE; diff --git a/plugins/Clist_nicer/src/clistmod.cpp b/plugins/Clist_nicer/src/clistmod.cpp index fced8ea43a..3eda89c7a4 100644 --- a/plugins/Clist_nicer/src/clistmod.cpp +++ b/plugins/Clist_nicer/src/clistmod.cpp @@ -32,8 +32,6 @@ #include -BOOL (WINAPI *MySetProcessWorkingSetSize)(HANDLE, SIZE_T, SIZE_T) = 0; - extern int AddEvent(WPARAM wParam, LPARAM lParam); extern int RemoveEvent(WPARAM wParam, LPARAM lParam); @@ -102,7 +100,6 @@ int LoadContactListModule(void) hSvc_GetContactStatusMsg = CreateServiceFunction("CList/GetContactStatusMsg", GetContactStatusMessage); InitCustomMenus(); - MySetProcessWorkingSetSize = (BOOL(WINAPI *)(HANDLE, SIZE_T, SIZE_T))GetProcAddress(GetModuleHandleA("kernel32"), "SetProcessWorkingSetSize"); return 0; } @@ -273,8 +270,8 @@ int ShowHide(WPARAM wParam, LPARAM lParam) else { //It needs to be hidden ShowWindow(pcli->hwndContactList, SW_HIDE); cfg::writeByte("CList", "State", SETTING_STATE_HIDDEN); - if (MySetProcessWorkingSetSize != NULL && cfg::getByte("CList", "DisableWorkingSet", 1)) - MySetProcessWorkingSetSize(GetCurrentProcess(), -1, -1); + if (cfg::getByte("CList", "DisableWorkingSet", 1)) + SetProcessWorkingSetSize(GetCurrentProcess(), -1, -1); } return 0; } diff --git a/plugins/Dbx_tree/src/DataBase.cpp b/plugins/Dbx_tree/src/DataBase.cpp index 37067ff350..451ce89a00 100644 --- a/plugins/Dbx_tree/src/DataBase.cpp +++ b/plugins/Dbx_tree/src/DataBase.cpp @@ -150,10 +150,7 @@ int CDataBase::LoadFile(TDBFileType Index) TGenericFileHeader h; m_EncryptionManager[Index] = new CEncryptionManager; - if (CMappedMemory::InitMMAP()) - m_FileAccess[Index] = new CMappedMemory(m_FileName[Index]); - else - m_FileAccess[Index] = new CDirectAccess(m_FileName[Index]); + m_FileAccess[Index] = new CMappedMemory(m_FileName[Index]); m_FileAccess[Index]->Read(&h, 0, sizeof(h)); m_EncryptionManager[Index]->InitEncryption(h.Gen.FileEncryption); diff --git a/plugins/Dbx_tree/src/MappedMemory.cpp b/plugins/Dbx_tree/src/MappedMemory.cpp index 5a8d264844..7ced28a886 100644 --- a/plugins/Dbx_tree/src/MappedMemory.cpp +++ b/plugins/Dbx_tree/src/MappedMemory.cpp @@ -24,32 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "MappedMemory.h" #include "Logger.h" -typedef BOOL (WINAPI *TUnmapViewOfFile)(LPCVOID); -typedef BOOL (WINAPI *TFlushViewOfFile)(LPCVOID, SIZE_T); -typedef HANDLE (WINAPI *TCreateFileMappingA)(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCSTR); -typedef LPVOID (WINAPI *TMapViewOfFile)(HANDLE, DWORD, DWORD, DWORD, SIZE_T); - -HMODULE myKernelLib = NULL; -TUnmapViewOfFile myUnmapViewOfFile = NULL; -TFlushViewOfFile myFlushViewOfFile = NULL; -TCreateFileMappingA myCreateFileMappingA = NULL; -TMapViewOfFile myMapViewOfFile = NULL; - -bool CMappedMemory::InitMMAP() -{ - if (!myKernelLib) - myKernelLib = GetModuleHandleA("kernel32.dll"); // is always loaded - - if (myKernelLib) - { - myUnmapViewOfFile = (TUnmapViewOfFile) GetProcAddress(myKernelLib, "UnmapViewOfFile"); - myFlushViewOfFile = (TFlushViewOfFile) GetProcAddress(myKernelLib, "FlushViewOfFile"); - myCreateFileMappingA = (TCreateFileMappingA) GetProcAddress(myKernelLib, "CreateFileMappingA"); - myMapViewOfFile = (TMapViewOfFile) GetProcAddress(myKernelLib, "MapViewOfFile"); - } - - return myUnmapViewOfFile && myFlushViewOfFile && myCreateFileMappingA && myMapViewOfFile; -} CMappedMemory::CMappedMemory(const TCHAR* FileName) : CFileAccess(FileName) { @@ -85,8 +59,8 @@ CMappedMemory::~CMappedMemory() { if (m_Base) { - myFlushViewOfFile(m_Base, NULL); - myUnmapViewOfFile(m_Base); + FlushViewOfFile(m_Base, NULL); + UnmapViewOfFile(m_Base); } if (m_FileMapping) CloseHandle(m_FileMapping); @@ -117,8 +91,8 @@ uint32_t CMappedMemory::_SetSize(uint32_t Size) { if (m_Base) { - myFlushViewOfFile(m_Base, 0); - myUnmapViewOfFile(m_Base); + FlushViewOfFile(m_Base, 0); + UnmapViewOfFile(m_Base); } if (m_FileMapping) CloseHandle(m_FileMapping); @@ -138,7 +112,7 @@ uint32_t CMappedMemory::_SetSize(uint32_t Size) return 0; } - m_FileMapping = myCreateFileMappingA(m_DirectFile, NULL, PAGE_READWRITE, 0, Size, NULL); + m_FileMapping = CreateFileMappingA(m_DirectFile, NULL, PAGE_READWRITE, 0, Size, NULL); if (!m_FileMapping) { @@ -146,7 +120,7 @@ uint32_t CMappedMemory::_SetSize(uint32_t Size) return 0; } - m_Base = (uint8_t*) myMapViewOfFile(m_FileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); + m_Base = (uint8_t*)MapViewOfFile(m_FileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0); if (!m_Base) { LOGSYS(logERROR, _T("MapViewOfFile failed")); @@ -163,6 +137,6 @@ void CMappedMemory::_Invalidate(uint32_t Dest, uint32_t Size) void CMappedMemory::_Flush() { - myFlushViewOfFile(m_Base, NULL); + FlushViewOfFile(m_Base, NULL); FlushFileBuffers(m_DirectFile); } diff --git a/plugins/Dbx_tree/src/MappedMemory.h b/plugins/Dbx_tree/src/MappedMemory.h index e66862836e..8b13aa7bd1 100644 --- a/plugins/Dbx_tree/src/MappedMemory.h +++ b/plugins/Dbx_tree/src/MappedMemory.h @@ -42,6 +42,4 @@ protected: public: CMappedMemory(const TCHAR* FileName); virtual ~CMappedMemory(); - - static bool InitMMAP(); }; -- cgit v1.2.3