Index: src/ch/MainWnd.cpp =================================================================== diff -u -rebabad67cdda34ed4e36ab794e10d0ade8124bf3 -rb5f6c00d1615afa6d26e4d74e564afe0af893174 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision ebabad67cdda34ed4e36ab794e10d0ade8124bf3) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision b5f6c00d1615afa6d26e4d74e564afe0af893174) @@ -1927,7 +1927,7 @@ _tcscpy(g_pscsShared->szSizes[i], GetResManager()->LoadString(IDS_BYTE_STRING+i)); // convert to list of _COMMAND's - _COMMAND *pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND *pCommand = g_pscsShared->GetCommandsPtr(); // what kind of menu ? switch (wParam) @@ -1991,7 +1991,7 @@ // count of shortcuts to store g_pscsShared->iShortcutsCount=__min(cvShortcuts.size(), SHARED_BUFFERSIZE-5*sizeof(_COMMAND)); - _SHORTCUT* pShortcut=(_SHORTCUT*)(g_pscsShared->szData+5*sizeof(_COMMAND)); + _SHORTCUT* pShortcut = g_pscsShared->GetShortcutsPtr(); CShortcut sc; for (int i=0;iiShortcutsCount;i++) { Index: src/chext/DropMenuExt.cpp =================================================================== diff -u -r1e067c9bfa3d29a7299317c9a6f782bf2849b9b3 -rb5f6c00d1615afa6d26e4d74e564afe0af893174 --- src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision 1e067c9bfa3d29a7299317c9a6f782bf2849b9b3) +++ src/chext/DropMenuExt.cpp (.../DropMenuExt.cpp) (revision b5f6c00d1615afa6d26e4d74e564afe0af893174) @@ -66,7 +66,7 @@ OTF2("Keys State: Shift:%u, ctrl:%u, alt:%u\r\n", bShift, bCtrl, bAlt); */ // got a config - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand = g_pscsShared->GetCommandsPtr(); int iCommandCount=0; if (g_pscsShared->uiFlags & DD_COPY_FLAG) @@ -116,7 +116,7 @@ hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); if (hWnd) { - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand = g_pscsShared->GetCommandsPtr(); switch (idCmd) { @@ -144,7 +144,7 @@ if (hWnd) { - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand = g_pscsShared->GetCommandsPtr(); switch (idCmd) { @@ -313,7 +313,7 @@ return E_FAIL; // commands - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand = g_pscsShared->GetCommandsPtr(); // IPC struct COPYDATASTRUCT cds; Index: src/chext/MenuExt.cpp =================================================================== diff -u -r1e067c9bfa3d29a7299317c9a6f782bf2849b9b3 -rb5f6c00d1615afa6d26e4d74e564afe0af893174 --- src/chext/MenuExt.cpp (.../MenuExt.cpp) (revision 1e067c9bfa3d29a7299317c9a6f782bf2849b9b3) +++ src/chext/MenuExt.cpp (.../MenuExt.cpp) (revision b5f6c00d1615afa6d26e4d74e564afe0af893174) @@ -78,7 +78,7 @@ // establish display text int iShortcutIndex=(lpmis->itemID-m_uiFirstID-5)%g_pscsShared->iShortcutsCount; - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + _SHORTCUT* pShortcuts = g_pscsShared->GetShortcutsPtr(); // measure the text HWND hDesktop=GetDesktopWindow(); @@ -124,7 +124,7 @@ const int iRightMargin=GetSystemMetrics(SM_CXMENUCHECK)-iLeftMargin; int iShortcutIndex=(lpdis->itemID-m_uiFirstID-5)%g_pscsShared->iShortcutsCount; - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + _SHORTCUT* pShortcuts=g_pscsShared->GetShortcutsPtr(); // text color HBRUSH hbr; @@ -240,7 +240,7 @@ // OTF("after placement\r\n"); // main command adding - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand=g_pscsShared->GetCommandsPtr(); // data about commands int iCommandCount=0; @@ -273,7 +273,6 @@ // copy to > if (g_pscsShared->uiFlags & EC_COPYTO_FLAG) { - MENUITEMINFO mii; mii.cbSize=sizeof(MENUITEMINFO); mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; mii.fType=MFT_STRING; @@ -293,7 +292,6 @@ // move to > if (g_pscsShared->uiFlags & EC_MOVETO_FLAG) { - MENUITEMINFO mii; mii.cbSize=sizeof(MENUITEMINFO); mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; mii.fType=MFT_STRING; @@ -312,7 +310,6 @@ // copy/move to special... > if (g_pscsShared->uiFlags & EC_COPYMOVETOSPECIAL_FLAG) { - MENUITEMINFO mii; mii.cbSize=sizeof(MENUITEMINFO); mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; mii.fType=MFT_STRING; @@ -343,7 +340,7 @@ m_mMenus.hShortcuts[2]=CreatePopupMenu(); // fill with shortcuts - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + _SHORTCUT* pShortcuts=g_pscsShared->GetShortcutsPtr(); TCHAR szText[256], szSize[32]; __int64 iiFree; @@ -352,7 +349,8 @@ // modify text if (g_pscsShared->bShowFreeSpace && GetDynamicFreeSpace(pShortcuts[i].szPath, &iiFree, NULL)) { - _sntprintf(szText, 256, _T("%s (%s)"), pShortcuts[i].szName, GetSizeString(iiFree, szSize, 32)); + _sntprintf(szText, 256 - 1, _T("%s (%s)"), pShortcuts[i].szName, GetSizeString(iiFree, szSize, 32)); + szText[256 - 1] = _T('\0'); _tcsncpy(pShortcuts[i].szName, szText, 127); // OTF("Text to display=%s\r\n", pShortcuts[i].szName); pShortcuts[i].szName[127]=_T('\0'); @@ -375,7 +373,7 @@ if (!hWnd) wcscpy(reinterpret_cast(pszName), L""); - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand=g_pscsShared->GetCommandsPtr(); switch (idCmd) { @@ -390,7 +388,7 @@ break; } default: - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + _SHORTCUT* pShortcuts = g_pscsShared->GetShortcutsPtr(); if ((int)(idCmd-5) < g_pscsShared->iShortcutsCount*3) { CT2W ct2w(pShortcuts[(idCmd-5)%g_pscsShared->iShortcutsCount].szPath); @@ -409,7 +407,7 @@ if (!hWnd) strcpy(pszName, ""); - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand=g_pscsShared->GetCommandsPtr(); switch (idCmd) { @@ -424,7 +422,7 @@ break; } default: // rest of commands - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + _SHORTCUT* pShortcuts = g_pscsShared->GetShortcutsPtr(); if ((int)(idCmd-5) < g_pscsShared->iShortcutsCount*3) { CT2A ct2a(pShortcuts[(idCmd-5)%g_pscsShared->iShortcutsCount].szPath); @@ -520,7 +518,7 @@ return E_FAIL; // commands - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + _COMMAND* pCommand = g_pscsShared->GetCommandsPtr(); // OTF("Invoke Command\r\n"); // command type @@ -547,9 +545,10 @@ UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect")); if (IsClipboardFormatAvailable(nFormat)) { - HANDLE handle=GetClipboardData(nFormat); + handle=GetClipboardData(nFormat); LPVOID addr=GlobalLock(handle); - + if(!addr) + return E_FAIL; DWORD dwData=((DWORD*)addr)[0]; if (dwData & DROPEFFECT_MOVE) bMove=true; @@ -583,7 +582,7 @@ if (LOWORD(lpici->lpVerb) < g_pscsShared->iCommandCount+(m_bBackground ? 0 : 3*g_pscsShared->iShortcutsCount)) { // addr of a table with shortcuts - _SHORTCUT* stShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + _SHORTCUT* stShortcuts = g_pscsShared->GetShortcutsPtr(); // find command for which this command is generated int iCommandIndex=(int)(((LOWORD(lpici->lpVerb)-5) / g_pscsShared->iShortcutsCount))+2; // command index Index: src/common/FileSupport.cpp =================================================================== diff -u -r4c272b19c74694c428c943011f279ec064fbd894 -rb5f6c00d1615afa6d26e4d74e564afe0af893174 --- src/common/FileSupport.cpp (.../FileSupport.cpp) (revision 4c272b19c74694c428c943011f279ec064fbd894) +++ src/common/FileSupport.cpp (.../FileSupport.cpp) (revision b5f6c00d1615afa6d26e4d74e564afe0af893174) @@ -92,7 +92,10 @@ ULARGE_INTEGER ui64Available, ui64Total; PGETDISKFREESPACEEX pGetDiskFreeSpaceEx; - pGetDiskFreeSpaceEx = (PGETDISKFREESPACEEX)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetDiskFreeSpaceExA"); + HMODULE hModule = GetModuleHandle(_T("kernel32.dll")); + if(!hModule) + return false; + pGetDiskFreeSpaceEx = (PGETDISKFREESPACEEX)GetProcAddress(hModule, "GetDiskFreeSpaceExA"); if (pGetDiskFreeSpaceEx) { if (!pGetDiskFreeSpaceEx(lpszPath, &ui64Available, &ui64Total, NULL)) Index: src/common/ipcstructs.h =================================================================== diff -u -rce5a87f4daca41daeb018a27e9ecdd353fb80c1e -rb5f6c00d1615afa6d26e4d74e564afe0af893174 --- src/common/ipcstructs.h (.../ipcstructs.h) (revision ce5a87f4daca41daeb018a27e9ecdd353fb80c1e) +++ src/common/ipcstructs.h (.../ipcstructs.h) (revision b5f6c00d1615afa6d26e4d74e564afe0af893174) @@ -65,6 +65,10 @@ class CSharedConfigStruct { public: + _SHORTCUT* GetShortcutsPtr() const { return (_SHORTCUT*)(byData + iCommandCount * sizeof(_COMMAND)); } + _COMMAND* GetCommandsPtr() const { return (_COMMAND*)byData; } + +public: UINT uiFlags; // what items and how to display in drag&drop ctx menu & explorer.ctx.menu bool bShowFreeSpace; // showthe free space by the shortcuts ? @@ -75,7 +79,7 @@ int iCommandCount; // count of commands stored at the beginning of a buffer int iShortcutsCount; // count of shortcuts to display in submenus - TCHAR szData[SHARED_BUFFERSIZE]; // buffer for texts and other stuff + BYTE byData[SHARED_BUFFERSIZE]; // buffer for texts and other stuff }; #endif