diff --git a/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.cpp b/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.cpp index 667ad4ea..aeca5a94 100644 --- a/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.cpp +++ b/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.cpp @@ -9,6 +9,7 @@ class C7zFileEngineIterator : public QAbstractFileEngineIterator { public: +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) C7zFileEngineIterator(QDir::Filters filters, const QStringList& filterNames, const QStringList& allEntries) : QAbstractFileEngineIterator(filters, filterNames), entries(allEntries), index(0) {} @@ -25,7 +26,21 @@ public: { return index < entries.size(); } +#else + C7zFileEngineIterator(const QString &path, QDir::Filters filters, const QStringList& filterNames, + const QStringList& allEntries) + : QAbstractFileEngineIterator(path, filters, filterNames), entries(allEntries), index(0) {} + ~C7zFileEngineIterator() {} + bool advance() override + { + if (index >= entries.size()) + return false; + ++index; + return true; + } +#endif + QString currentFileName() const override { if (index <= 0 || index > entries.size()) @@ -172,7 +187,11 @@ QAbstractFileEngine::Iterator *C7zFileEngine::beginEntryList(QDir::Filters filte allEntries.append(Path); } +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) return new C7zFileEngineIterator(filters, filterNames, allEntries); +#else + return new C7zFileEngineIterator("", filters, filterNames, allEntries); +#endif } QAbstractFileEngine::FileFlags C7zFileEngine::fileFlags(FileFlags type) const @@ -201,11 +220,19 @@ QString C7zFileEngine::fileName(FileName file) const return _filename; } +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) QDateTime C7zFileEngine::fileTime(FileTime time) const +#else +QDateTime C7zFileEngine::fileTime(QFile::FileTime time) const +#endif { switch (time) { +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) case QAbstractFileEngine::ModificationTime: +#else + case QFile::FileModificationTime: +#endif default: return _datetime; break; @@ -316,6 +343,7 @@ void C7zFileEngineHandler::Close() m_pArchive = NULL; } +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) QAbstractFileEngine* C7zFileEngineHandler::create(const QString& filename) const { if (m_pArchive && filename.startsWith(m_Scheme)) @@ -323,3 +351,12 @@ QAbstractFileEngine* C7zFileEngineHandler::create(const QString& filename) const return NULL; } +#else +std::unique_ptr C7zFileEngineHandler::create(const QString& filename) const +{ + if (m_pArchive && filename.startsWith(m_Scheme)) + return std::unique_ptr(new C7zFileEngine(filename, m_pArchive, &m_Mutex)); + + return std::unique_ptr(); +} +#endif diff --git a/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.h b/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.h index 9e7ced82..5c191d8c 100644 --- a/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.h +++ b/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.h @@ -35,7 +35,11 @@ public: virtual bool isRelativePath() const; virtual FileFlags fileFlags(FileFlags type = FileInfoAll) const; virtual QString fileName(FileName file = DefaultName) const; - virtual QDateTime fileTime(FileTime time) const; +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) + virtual QDateTime fileTime(FileTime time) const; +#else + virtual QDateTime fileTime(QFile::FileTime time) const; +#endif virtual void setFileName(const QString& file); bool atEnd() const; @@ -82,7 +86,11 @@ public: bool IsOpen() { return m_pArchive != NULL; } QString Prefix() { return m_Scheme; } +#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0) QAbstractFileEngine* create(const QString& filename) const; +#else + std::unique_ptr create(const QString& filename) const; +#endif private: QString m_Scheme; diff --git a/SandboxiePlus/MiscHelpers/Common/DebugHelpers.cpp b/SandboxiePlus/MiscHelpers/Common/DebugHelpers.cpp index 0cab5b6e..ae87f553 100644 --- a/SandboxiePlus/MiscHelpers/Common/DebugHelpers.cpp +++ b/SandboxiePlus/MiscHelpers/Common/DebugHelpers.cpp @@ -216,7 +216,7 @@ static LONG __stdcall MyCrashHandlerExceptionFilter(EXCEPTION_POINTERS* pEx) return EXCEPTION_CONTINUE_SEARCH; wchar_t szMiniDumpFileName[128]; - wsprintf(szMiniDumpFileName, L"%s %s.dmp", s_szMiniDumpName, QDateTime::currentDateTime().toString("dd.MM.yyyy hh-mm-ss,zzz").replace(QRegularExpression("[:*?<>|\"\\/]"), "_").toStdWString().c_str()); + wsprintfW(szMiniDumpFileName, L"%s %s.dmp", s_szMiniDumpName, QDateTime::currentDateTime().toString("dd.MM.yyyy hh-mm-ss,zzz").replace(QRegularExpression("[:*?<>|\"\\/]"), "_").toStdWString().c_str()); /*wchar_t szMiniDumpPath[MAX_PATH] = { 0 }; @@ -237,7 +237,7 @@ static LONG __stdcall MyCrashHandlerExceptionFilter(EXCEPTION_POINTERS* pEx) wcscat(szMiniDumpPath, L"\\"); wcscat(szMiniDumpPath, szMiniDumpFileName); - HANDLE hFile = CreateFile(szMiniDumpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = CreateFileW(szMiniDumpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { @@ -255,10 +255,10 @@ static LONG __stdcall MyCrashHandlerExceptionFilter(EXCEPTION_POINTERS* pEx) wchar_t szMiniDumpMessage[256]; if (!bSuccess) - wsprintf(szMiniDumpMessage, L"%s crashed!\r\nCrashdump creation failed.", s_szMiniDumpName); + wsprintfW(szMiniDumpMessage, L"%s crashed!\r\nCrashdump creation failed.", s_szMiniDumpName); else - wsprintf(szMiniDumpMessage, L"%s crashed!\r\nCrashdump saved to \"%s\".\r\nPlease report the crash and attach the file \"%s\".", s_szMiniDumpName, szMiniDumpPath, szMiniDumpFileName); - MessageBox(NULL, szMiniDumpMessage, s_szMiniDumpName, MB_OK | MB_ICONERROR); + wsprintfW(szMiniDumpMessage, L"%s crashed!\r\nCrashdump saved to \"%s\".\r\nPlease report the crash and attach the file \"%s\".", s_szMiniDumpName, szMiniDumpPath, szMiniDumpFileName); + MessageBoxW(NULL, szMiniDumpMessage, s_szMiniDumpName, MB_OK | MB_ICONERROR); // or return one of the following: // - EXCEPTION_CONTINUE_SEARCH @@ -279,7 +279,7 @@ void InitMiniDumpWriter(const wchar_t* Name, const wchar_t* Path) // Initialize the member, so we do not load the dll after the exception has occurred // which might be not possible anymore... - s_hDbgHelpMod = LoadLibrary(L"dbghelp.dll"); + s_hDbgHelpMod = LoadLibraryW(L"dbghelp.dll"); if (s_hDbgHelpMod != NULL) s_pMDWD = (tMDWD) GetProcAddress(s_hDbgHelpMod, "MiniDumpWriteDump"); diff --git a/SandboxiePlus/QSbieAPI/Helpers/DbgHelper.cpp b/SandboxiePlus/QSbieAPI/Helpers/DbgHelper.cpp index 4f272ef9..eb69a59d 100644 --- a/SandboxiePlus/QSbieAPI/Helpers/DbgHelper.cpp +++ b/SandboxiePlus/QSbieAPI/Helpers/DbgHelper.cpp @@ -371,7 +371,7 @@ CSymbolProvider* CSymbolProvider::Instance() HMODULE DbgHelpMod = LoadLibrary((KitsRoot + "dbghelp.dll").toStdWString().c_str()); HMODULE SymSrvMod = LoadLibrary((KitsRoot + "symsrv.dll").toStdWString().c_str());*/ - HMODULE DbgHelpMod = LoadLibrary(L"dbghelp.dll"); + HMODULE DbgHelpMod = LoadLibraryW(L"dbghelp.dll"); __sys_SymFromAddr = (P_SymFromAddr)GetProcAddress(DbgHelpMod, "SymFromAddr"); __sys_SymGetModuleInfoW64 = (P_SymGetModuleInfoW64)GetProcAddress(DbgHelpMod, "SymGetModuleInfoW64"); diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp b/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp index 34467ff1..3b80a549 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp +++ b/SandboxiePlus/QSbieAPI/Sandboxie/BoxBorder.cpp @@ -105,7 +105,7 @@ void CBoxBorder::ThreadFunc() m->ThumbWidth = GetSystemMetrics(SM_CXHTHUMB); m->ThumbHeight = GetSystemMetrics(SM_CYVTHUMB); - HMODULE dwmapi = LoadLibrary(L"dwmapi.dll"); + HMODULE dwmapi = LoadLibraryW(L"dwmapi.dll"); if (dwmapi) { m->DwmIsCompositionEnabled = (P_DwmIsCompositionEnabled)GetProcAddress(dwmapi, "DwmIsCompositionEnabled"); if (m->DwmIsCompositionEnabled) { @@ -115,7 +115,7 @@ void CBoxBorder::ThreadFunc() } } - WNDCLASSEX wc; + WNDCLASSEXW wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_GLOBALCLASS; wc.lpfnWndProc = ::DefWindowProc; @@ -128,9 +128,9 @@ void CBoxBorder::ThreadFunc() wc.lpszMenuName = NULL; wc.lpszClassName = Sandboxie_WindowClassName; wc.hIconSm = NULL; - if (ATOM lpClassName = RegisterClassEx(&wc)) + if (ATOM lpClassName = RegisterClassExW(&wc)) { - m->BorderWnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST, (LPCWSTR)lpClassName, + m->BorderWnd = CreateWindowExW(WS_EX_LAYERED | WS_EX_TRANSPARENT | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST, (LPCWSTR)lpClassName, Sandboxie_WindowClassName, WS_POPUP | WS_CLIPSIBLINGS, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL); } if (!m->BorderWnd) diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp b/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp index 26ae0a7c..71f119c2 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp +++ b/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp @@ -19,9 +19,6 @@ #include #include "SandBox.h" #include "../SbieAPI.h" -#ifdef _DEBUG -#include -#endif #include #define WIN32_NO_STATUS @@ -149,10 +146,10 @@ void CSandBox::SetFileRoot(const QString& FilePath) SB_STATUS CSandBox::RunStart(const QString& Command, bool Elevated) { -#ifdef _DEBUG +/*#ifdef _DEBUG if ((QGuiApplication::queryKeyboardModifiers() & Qt::ControlModifier) != 0) return RunSandboxed(Command); -#endif +#endif*/ return m_pAPI->RunStart(m_Name, Command, Elevated ? CSbieAPI::eStartElevated : CSbieAPI::eStartDefault); } diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/SbieTemplates.cpp b/SandboxiePlus/QSbieAPI/Sandboxie/SbieTemplates.cpp index bae6e7a6..b3b232b5 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/SbieTemplates.cpp +++ b/SandboxiePlus/QSbieAPI/Sandboxie/SbieTemplates.cpp @@ -235,7 +235,7 @@ void CSbieTemplates::CollectClasses() EnumWindows([](HWND hwnd, LPARAM lparam) { WCHAR clsnm[256]; - GetClassName(hwnd, clsnm, 250); + GetClassNameW(hwnd, clsnm, 250); clsnm[250] = L'\0'; if (clsnm[0] && wcsncmp(clsnm, L"Sandbox:", 8) != 0) @@ -257,14 +257,14 @@ void CSbieTemplates::CollectServices() return; ULONG info_len = 10240; - ENUM_SERVICE_STATUS* info = (ENUM_SERVICE_STATUS *)malloc(info_len); + ENUM_SERVICE_STATUSW* info = (ENUM_SERVICE_STATUSW *)malloc(info_len); ULONG ResumeHandle = 0; for(;;) { ULONG len; ULONG num; - BOOL ret = EnumServicesStatus(hManager, SERVICE_TYPE_ALL, SERVICE_STATE_ALL, info, info_len, &len, &num, &ResumeHandle); + BOOL ret = EnumServicesStatusW(hManager, SERVICE_TYPE_ALL, SERVICE_STATE_ALL, info, info_len, &len, &num, &ResumeHandle); if (!ret && GetLastError() != ERROR_MORE_DATA) break; @@ -298,7 +298,7 @@ void CSbieTemplates::CollectProducts() for(;;) { HKEY hkey; - LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, DesiredAccess, &hkey); + LONG rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, DesiredAccess, &hkey); if (rc != 0) continue; @@ -306,7 +306,7 @@ void CSbieTemplates::CollectProducts() for(ULONG index = 0; rc != ERROR_NO_MORE_ITEMS; index++) { ULONG name_len = 120; - rc = RegEnumKeyEx(hkey, index, name, &name_len, NULL, NULL, NULL, NULL); + rc = RegEnumKeyExW(hkey, index, name, &name_len, NULL, NULL, NULL, NULL); if (rc == 0) { _wcslwr(name); m_Products.append(QString::fromWCharArray(name)); @@ -450,7 +450,7 @@ bool CSbieTemplates::CheckRegistryKey(const QString& Value) bool CSbieTemplates::CheckFile(const QString& Value) { std::wstring path = Value.toStdWString(); - if (GetFileAttributes(path.c_str()) != INVALID_FILE_ATTRIBUTES) + if (GetFileAttributesW(path.c_str()) != INVALID_FILE_ATTRIBUTES) return true; return false; } @@ -507,7 +507,7 @@ void CSbieTemplates::InitExpandPaths(bool WithUser) keyPath += L"Shell Folders"; HKEY hkey; - LONG rc = RegOpenKey(HKEY_CURRENT_USER, keyPath.c_str(), &hkey); + LONG rc = RegOpenKeyW(HKEY_CURRENT_USER, keyPath.c_str(), &hkey); for (ULONG index = 0; rc == 0; index++) { WCHAR name[64]; @@ -518,11 +518,11 @@ void CSbieTemplates::InitExpandPaths(bool WithUser) name_len = 60; value_len = MAX_PATH + 4; - rc = RegEnumValue(hkey, index, name, &name_len, NULL, &type, (BYTE *)value, &value_len); + rc = RegEnumValueW(hkey, index, name, &name_len, NULL, &type, (BYTE *)value, &value_len); if (rc == 0 && (type == REG_SZ || type == REG_EXPAND_SZ)) { WCHAR expand[MAX_PATH + 8]; - ULONG len = ExpandEnvironmentStrings(value, expand, MAX_PATH + 4); + ULONG len = ExpandEnvironmentStringsW(value, expand, MAX_PATH + 4); if (len > 0 && len <= MAX_PATH) { QString value = QString::fromWCharArray(expand); diff --git a/SandboxiePlus/QSbieAPI/SbieAPI.cpp b/SandboxiePlus/QSbieAPI/SbieAPI.cpp index 8199f536..27138ff1 100644 --- a/SandboxiePlus/QSbieAPI/SbieAPI.cpp +++ b/SandboxiePlus/QSbieAPI/SbieAPI.cpp @@ -18,9 +18,6 @@ #include "stdafx.h" #include #include -#ifdef _DEBUG -#include -#endif #include "SbieAPI.h" #include @@ -60,7 +57,7 @@ struct SSbieAPI if (!ProcessIdToSessionId(GetCurrentProcessId(), &sessionId)) sessionId = 0; - wsprintf(QueueName, L"*%s_%08X", INTERACTIVE_QUEUE_NAME, sessionId); + wsprintfW(QueueName, L"*%s_%08X", INTERACTIVE_QUEUE_NAME, sessionId); lastMessageNum = 0; //lastRecordNum = 0; @@ -156,7 +153,7 @@ bool CSbieAPI::IsSbieCtrlRunning() { static const WCHAR *SbieCtrlMutexName = SANDBOXIE L"_SingleInstanceMutex_Control"; - HANDLE hSbieCtrlMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, SbieCtrlMutexName); + HANDLE hSbieCtrlMutex = OpenMutexW(MUTEX_ALL_ACCESS, FALSE, SbieCtrlMutexName); if (hSbieCtrlMutex) { CloseHandle(hSbieCtrlMutex); return true; @@ -168,14 +165,14 @@ bool CSbieAPI::TerminateSbieCtrl() { static const WCHAR *WindowClassName = L"SandboxieControlWndClass"; - HWND hwnd = FindWindow(WindowClassName, NULL); + HWND hwnd = FindWindowW(WindowClassName, NULL); if (hwnd) { PostMessage(hwnd, WM_QUIT, 0, 0); } for (int i = 0; i < 10 && hwnd != NULL; i++) { QThread::msleep(100); - hwnd = FindWindow(WindowClassName, NULL); + hwnd = FindWindowW(WindowClassName, NULL); } return hwnd == NULL; @@ -202,7 +199,7 @@ QString CSbieAPI__GetRegValue(HANDLE hKey, const WCHAR* pName) if (NT_SUCCESS(NtQueryValueKey(hKey, &uni, KeyValuePartialInformation, value, sizeof(buf) - 16, &len))) { WCHAR expand[MAX_PATH + 8]; - len = ExpandEnvironmentStrings((WCHAR*)value->Data, expand, MAX_PATH + 4); + len = ExpandEnvironmentStringsW((WCHAR*)value->Data, expand, MAX_PATH + 4); return QString::fromWCharArray(expand); } @@ -291,7 +288,7 @@ SB_STATUS CSbieAPI::Connect(bool takeOver, bool withQueue) UpdateDriveLetters(); m_SbiePath = GetSbieHome(); - m->SbieMsgDll = LoadLibraryEx((m_SbiePath.toStdWString() + L"\\" SBIEMSG_DLL).c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE); + m->SbieMsgDll = LoadLibraryExW((m_SbiePath.toStdWString() + L"\\" SBIEMSG_DLL).c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE); m->lastMessageNum = 0; //m->lastRecordNum = 0; @@ -911,7 +908,7 @@ void CSbieAPI::UpdateDriveLetters() for (wchar_t ltr = L'A'; ltr <= L'Z'; ltr++) { wchar_t drv[] = { ltr, L':', '\0' }; - uint size = QueryDosDevice(drv, lpTargetPath, MAX_PATH); + uint size = QueryDosDeviceW(drv, lpTargetPath, MAX_PATH); if (size > 0) { SDrive Drive; @@ -1161,7 +1158,7 @@ QString CSbieAPI__FormatNtStatus(long nsCode) { static HMODULE hNtDll = NULL; if(!hNtDll) - hNtDll = GetModuleHandle(L"ntdll.dll"); + hNtDll = GetModuleHandleW(L"ntdll.dll"); if (hNtDll == NULL) return QString(); @@ -1810,7 +1807,7 @@ QByteArray CSbieAPI::MakeEnvironment(bool AddDeviceMap) foreach(const QString& Entry, EnvList) ExtraLength += Entry.length() + 1; - WCHAR *Environment = GetEnvironmentStrings(); + WCHAR *Environment = GetEnvironmentStringsW(); ULONG EnvLength = 0; for(WCHAR* envPtr = (WCHAR*)Environment; *envPtr;) { @@ -1860,10 +1857,10 @@ SB_STATUS CSbieAPI::RunSandboxed(const QString& BoxName, const QString& Command, BoxName.toWCharArray(req->boxname); // fix-me: potential overflow req->boxname[BoxName.length()] = L'\0'; req->si_flags = STARTF_FORCEOFFFEEDBACK; -#ifdef _DEBUG +/*#ifdef _DEBUG if ((QGuiApplication::queryKeyboardModifiers() & Qt::ShiftModifier) != 0) req->si_flags |= 0x80000000; -#endif +#endif*/ req->si_show_window = wShowWindow; if (req->si_show_window != SW_SHOWNORMAL) req->si_flags |= STARTF_USESHOWWINDOW; @@ -2864,8 +2861,8 @@ QString CSbieAPI::GetSbieMsgStr(quint32 code, quint32 Lang) { ULONG FormatFlags = FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER; WCHAR* ret_str = NULL; - if (!m->SbieMsgDll || (FormatMessage(FormatFlags, m->SbieMsgDll, code, Lang, (LPWSTR)&ret_str, 4, NULL) == 0 - && FormatMessage(FormatFlags, m->SbieMsgDll, code, 1033, (LPWSTR)&ret_str, 4, NULL) == 0)) + if (!m->SbieMsgDll || (FormatMessageW(FormatFlags, m->SbieMsgDll, code, Lang, (LPWSTR)&ret_str, 4, NULL) == 0 + && FormatMessageW(FormatFlags, m->SbieMsgDll, code, 1033, (LPWSTR)&ret_str, 4, NULL) == 0)) return QString("SBIE%0: %1; %2").arg(code & 0xFFFF, 4, 10); QString qStr = QString::fromWCharArray(ret_str); LocalFree(ret_str); @@ -2877,12 +2874,12 @@ void CSbieAPI::LoadEventLog() QByteArray buff; buff.resize(8 * 1024); - HANDLE hEventLog = OpenEventLog(NULL, L"System"); + HANDLE hEventLog = OpenEventLogW(NULL, L"System"); while (hEventLog) { ULONG bytesRead, bytesNeeded; - if(!ReadEventLog(hEventLog, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, 0, buff.data(), buff.size(), &bytesRead, &bytesNeeded)) + if(!ReadEventLogW(hEventLog, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, 0, buff.data(), buff.size(), &bytesRead, &bytesNeeded)) break; EVENTLOGRECORD *rec = (EVENTLOGRECORD *)buff.data(); diff --git a/SandboxiePlus/QSbieAPI/SbieTrace.cpp b/SandboxiePlus/QSbieAPI/SbieTrace.cpp index f05ae615..3fb1702b 100644 --- a/SandboxiePlus/QSbieAPI/SbieTrace.cpp +++ b/SandboxiePlus/QSbieAPI/SbieTrace.cpp @@ -49,10 +49,10 @@ QString ErrorString(qint32 err) QString Error; HMODULE handle = NULL; //err < 0 ? GetModuleHandle(L"NTDLL.DLL") : NULL; DWORD flags = 0; //err < 0 ? FORMAT_MESSAGE_FROM_HMODULE : 0; - LPTSTR s; + LPWSTR s; if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | flags, handle, err, 0, (LPTSTR)&s, 0, NULL) > 0) { - LPTSTR p = wcschr(s, L'\r'); + LPWSTR p = wcschr(s, L'\r'); if (p != NULL) *p = L'\0'; Error = QString::fromWCharArray(s); ::LocalFree(s); diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.cpp b/SandboxiePlus/QSbieAPI/SbieUtils.cpp index f48c553c..470ac779 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.cpp +++ b/SandboxiePlus/QSbieAPI/SbieUtils.cpp @@ -70,7 +70,7 @@ int GetServiceStatus(const wchar_t* name) if (!scm) return -1; - SC_HANDLE service = OpenService(scm, name, SERVICE_QUERY_STATUS); + SC_HANDLE service = OpenServiceW(scm, name, SERVICE_QUERY_STATUS); if (!service) { CloseServiceHandle(scm); return 0; @@ -211,7 +211,7 @@ SB_RESULT(void*) CSbieUtils::ElevateOps(const QStringList& Ops) std::wstring path = QCoreApplication::applicationFilePath().toStdWString(); std::wstring params = L"-assist \"" + Ops.join("\" \"").toStdWString() + L"\""; - SHELLEXECUTEINFO shex; + SHELLEXECUTEINFOW shex; memset(&shex, 0, sizeof(SHELLEXECUTEINFO)); shex.cbSize = sizeof(SHELLEXECUTEINFO); shex.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS; @@ -221,7 +221,7 @@ SB_RESULT(void*) CSbieUtils::ElevateOps(const QStringList& Ops) shex.nShow = SW_SHOWNORMAL; shex.lpVerb = L"runas"; - if (!ShellExecuteEx(&shex)) + if (!ShellExecuteExW(&shex)) return SB_ERR(SB_NeedAdmin); return CSbieResult(OP_ASYNC, shex.hProcess); } @@ -384,14 +384,14 @@ QString CSbieUtils::GetContextMenuStartCmd() { const wchar_t* key = L"Software\\Classes\\*\\shell\\sandbox\\command"; HKEY hkey; - LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); + LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); if (rc != 0) return QString(); ULONG type; WCHAR path[512]; ULONG path_len = sizeof(path) - sizeof(WCHAR) * 4; - rc = RegQueryValueEx(hkey, NULL, NULL, &type, (BYTE *)path, &path_len); + rc = RegQueryValueExW(hkey, NULL, NULL, &type, (BYTE *)path, &path_len); RegCloseKey(hkey); if (rc != 0) return QString(); @@ -409,12 +409,12 @@ void CSbieUtils::AddContextMenu(const QString& StartPath, const QString& RunStr, std::wstring explorer_path(512, L'\0'); HKEY hkeyWinlogon; - LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"software\\microsoft\\windows nt\\currentversion\\winlogon", 0, KEY_READ, &hkeyWinlogon); + LONG rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\microsoft\\windows nt\\currentversion\\winlogon", 0, KEY_READ, &hkeyWinlogon); if (rc == 0) { ULONG path_len = explorer_path.size() * sizeof(WCHAR); ULONG type; - rc = RegQueryValueEx(hkeyWinlogon, L"Shell", NULL, &type, (BYTE *)explorer_path.c_str(), &path_len); + rc = RegQueryValueExW(hkeyWinlogon, L"Shell", NULL, &type, (BYTE *)explorer_path.c_str(), &path_len); if (rc == 0 && (type == REG_SZ || type == REG_EXPAND_SZ)) explorer_path.resize(path_len / sizeof(WCHAR)); RegCloseKey(hkeyWinlogon); @@ -423,7 +423,7 @@ void CSbieUtils::AddContextMenu(const QString& StartPath, const QString& RunStr, // get default explorer path if (*explorer_path.c_str() == L'\0' || _wcsicmp(explorer_path.c_str(), L"explorer.exe") == 0) { - GetWindowsDirectory((wchar_t*)explorer_path.c_str(), MAX_PATH); + GetWindowsDirectoryW((wchar_t*)explorer_path.c_str(), MAX_PATH); ULONG path_len = wcslen(explorer_path.c_str()); explorer_path.resize(path_len); explorer_path.append(L"\\explorer.exe"); @@ -435,22 +435,22 @@ void CSbieUtils::AddContextMenu(const QString& StartPath, const QString& RunStr, void CSbieUtils::CreateShellEntry(const std::wstring& classname, const std::wstring& key, const std::wstring& cmdtext, const std::wstring& iconpath, const std::wstring& startcmd) { HKEY hkey; - LONG rc = RegCreateKeyEx(HKEY_CURRENT_USER, (L"software\\classes\\" + classname + L"\\shell\\" + key).c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL); + LONG rc = RegCreateKeyExW(HKEY_CURRENT_USER, (L"software\\classes\\" + classname + L"\\shell\\" + key).c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL); if (rc != 0) return; - RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)cmdtext.c_str(), (cmdtext.length() + 1) * sizeof(WCHAR)); - RegSetValueEx(hkey, L"Icon", 0, REG_SZ, (BYTE *)iconpath.c_str(), (iconpath.length() + 1) * sizeof(WCHAR)); + RegSetValueExW(hkey, NULL, 0, REG_SZ, (BYTE *)cmdtext.c_str(), (cmdtext.length() + 1) * sizeof(WCHAR)); + RegSetValueExW(hkey, L"Icon", 0, REG_SZ, (BYTE *)iconpath.c_str(), (iconpath.length() + 1) * sizeof(WCHAR)); RegCloseKey(hkey); if (rc != 0) return; - rc = RegCreateKeyEx(HKEY_CURRENT_USER, (L"software\\classes\\" + classname + L"\\shell\\" + key + L"\\command").c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL); + rc = RegCreateKeyExW(HKEY_CURRENT_USER, (L"software\\classes\\" + classname + L"\\shell\\" + key + L"\\command").c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL); if (rc != 0) return; - RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)startcmd.c_str(), (startcmd.length() + 1) * sizeof(WCHAR)); + RegSetValueExW(hkey, NULL, 0, REG_SZ, (BYTE *)startcmd.c_str(), (startcmd.length() + 1) * sizeof(WCHAR)); RegCloseKey(hkey); } @@ -465,7 +465,7 @@ bool CSbieUtils::HasContextMenu2() { const wchar_t* key = L"Software\\Classes\\*\\shell\\unbox\\command"; HKEY hkey; - LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); + LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); if (rc != 0) return false; @@ -492,7 +492,7 @@ bool CSbieUtils::HasContextMenu3() const wchar_t* key = L"Software\\Classes\\*\\shell\\addforce\\command"; //const wchar_t* key2 = L"Software\\Classes\\*\\Folder\\addforce\\command"; HKEY hkey,hKey2; - LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); + LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); if (rc != 0) return false; @@ -529,7 +529,7 @@ bool CSbieUtils::HasContextMenu4() const wchar_t* key = L"Software\\Classes\\*\\shell\\addopen\\command"; //const wchar_t* key2 = L"Software\\Classes\\*\\Folder\\addforce\\command"; HKEY hkey, hKey2; - LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); + LONG rc = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); if (rc != 0) return false; @@ -583,8 +583,8 @@ bool CSbieUtils::CreateShortcut(const QString& StartExe, QString LinkPath, const if (FAILED(hr)) return false; - IShellLink *pShellLink; - hr = pUnknown->QueryInterface(IID_IShellLink, (void **)&pShellLink); + IShellLinkW *pShellLink; + hr = pUnknown->QueryInterface(IID_IShellLinkW, (void **)&pShellLink); if (SUCCEEDED(hr)) { pShellLink->SetPath(StartExe.toStdWString().c_str()); @@ -620,8 +620,8 @@ bool CSbieUtils::CreateShortcut(const QString& StartExe, QString LinkPath, const bool CSbieUtils::GetStartMenuShortcut(CSbieAPI* pApi, QString &BoxName, QString &LinkPath, QString &IconPath, quint32& IconIndex, QString &WorkDir) { WCHAR MapName[128]; - wsprintf(MapName, SANDBOXIE L"_StartMenu_WorkArea_%08X_%08X", GetCurrentProcessId(), GetTickCount()); - HANDLE hMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 8192, MapName); + wsprintfW(MapName, SANDBOXIE L"_StartMenu_WorkArea_%08X_%08X", GetCurrentProcessId(), GetTickCount()); + HANDLE hMapping = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 8192, MapName); if (!hMapping) return false; @@ -710,13 +710,13 @@ BOOLEAN SelectFavoriteInRegedit(HWND RegeditWindow, std::wstring FavoriteName) for (i = 3; i < count; i++) { - MENUITEMINFO info = { sizeof(MENUITEMINFO) }; + MENUITEMINFOW info = { sizeof(MENUITEMINFO) }; WCHAR buffer[MAX_PATH]; info.fMask = MIIM_ID | MIIM_STRING; info.dwTypeData = buffer; info.cch = RTL_NUMBER_OF(buffer); - GetMenuItemInfo(favoritesMenu, i, TRUE, &info); + GetMenuItemInfoW(favoritesMenu, i, TRUE, &info); if (info.cch > 0 && _wcsicmp(FavoriteName.c_str(),buffer) == 0) { id = info.wID; @@ -737,13 +737,13 @@ bool ShellOpenRegKey(const QString& KeyName) { std::wstring keyName = KeyName.toStdWString(); - HWND regeditWindow = FindWindow(L"RegEdit_RegEdit", NULL); + HWND regeditWindow = FindWindowW(L"RegEdit_RegEdit", NULL); if (!regeditWindow) { - RegSetKeyValue(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit", L"LastKey", REG_SZ, keyName.c_str(), (keyName.size() + 1) * sizeof(WCHAR)); + RegSetKeyValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit", L"LastKey", REG_SZ, keyName.c_str(), (keyName.size() + 1) * sizeof(WCHAR)); - SHELLEXECUTEINFO sei = { sizeof(sei) }; + SHELLEXECUTEINFOW sei = { sizeof(sei) }; sei.fMask = 0; sei.lpVerb = NULL; sei.lpFile = L"regedit.exe"; @@ -751,7 +751,7 @@ bool ShellOpenRegKey(const QString& KeyName) sei.hwnd = NULL; sei.nShow = SW_NORMAL; - ShellExecuteEx(&sei); + ShellExecuteExW(&sei); return TRUE; } @@ -761,13 +761,13 @@ bool ShellOpenRegKey(const QString& KeyName) QString FavoriteName = "A_Sandbox_" + QString::number((quint32)rand(), 16); std::wstring favoriteName = FavoriteName.toStdWString(); - RegSetKeyValue(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites", favoriteName.c_str(), REG_SZ, keyName.c_str(), (keyName.size() + 1) * sizeof(WCHAR)); + RegSetKeyValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites", favoriteName.c_str(), REG_SZ, keyName.c_str(), (keyName.size() + 1) * sizeof(WCHAR)); BOOLEAN result = SelectFavoriteInRegedit(regeditWindow, favoriteName); HKEY key; - RegOpenKey(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites", &key); - RegDeleteValue(key, favoriteName.c_str()); + RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit\\Favorites", &key); + RegDeleteValueW(key, favoriteName.c_str()); RegCloseKey(key); return result; diff --git a/SandboxiePlus/SandMan/Engine/SysObject.cpp b/SandboxiePlus/SandMan/Engine/SysObject.cpp index 204f579e..e30b2d72 100644 --- a/SandboxiePlus/SandMan/Engine/SysObject.cpp +++ b/SandboxiePlus/SandMan/Engine/SysObject.cpp @@ -227,9 +227,9 @@ HANDLE openRegKey(const QString& Key, bool bWrite = false) else if (RootPath.first == "HKEY_CURRENT_CONFIG") hRoot = HKEY_CURRENT_CONFIG; if (bWrite) - RegCreateKeyEx(hRoot, RootPath.second.toStdWString().c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, (PHKEY)&handle, NULL); + RegCreateKeyExW(hRoot, RootPath.second.toStdWString().c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, (PHKEY)&handle, NULL); else - RegOpenKeyEx(hRoot, RootPath.second.toStdWString().c_str(), REG_OPTION_NON_VOLATILE, KEY_READ, (PHKEY)&handle); + RegOpenKeyExW(hRoot, RootPath.second.toStdWString().c_str(), REG_OPTION_NON_VOLATILE, KEY_READ, (PHKEY)&handle); } else { @@ -262,7 +262,7 @@ QJSValue JSysObject::listRegKey(const QString& Key) for (DWORD dwIndex = 0; ; dwIndex++) { dwSubKeyNameSize = ARRAYSIZE(szSubKeyName); - if (RegEnumKeyEx((HKEY)handle, dwIndex, szSubKeyName, &dwSubKeyNameSize, NULL, NULL, NULL, &ftLastWriteTime) != ERROR_SUCCESS) + if (RegEnumKeyExW((HKEY)handle, dwIndex, szSubKeyName, &dwSubKeyNameSize, NULL, NULL, NULL, &ftLastWriteTime) != ERROR_SUCCESS) break; QVariantMap entry; @@ -283,7 +283,7 @@ QJSValue JSysObject::listRegKey(const QString& Key) { dwValueNameSize = MAX_VALUE_NAME; dwDataSize = MAX_VALUE_DATA; - if (RegEnumValue((HKEY)handle, dwIndex, szValueName, &dwValueNameSize, NULL, &dwType, lpData, &dwDataSize) != ERROR_SUCCESS) + if (RegEnumValueW((HKEY)handle, dwIndex, szValueName, &dwValueNameSize, NULL, &dwType, lpData, &dwDataSize) != ERROR_SUCCESS) break; QVariantMap entry; @@ -377,7 +377,7 @@ QJSValue JSysObject::setRegValue(const QString& Key, const QString& Name, const //case REG_FULL_RESOURCE_DESCRIPTOR: break; } - bRet = RegSetKeyValue((HKEY)handle, L"", Name.toStdWString().c_str(), dwType, lpData, dwDataSize); + bRet = RegSetKeyValueW((HKEY)handle, L"", Name.toStdWString().c_str(), dwType, lpData, dwDataSize); CloseHandle(handle); } return bRet; @@ -395,7 +395,7 @@ QJSValue JSysObject::getRegValue(const QString& Key, const QString& Name) BYTE* lpData = Buff.data(); DWORD dwDataSize = MAX_VALUE_DATA; - if (RegQueryValueEx((HKEY)handle, Name.toStdWString().c_str(), 0, &dwType, lpData, &dwDataSize)) { + if (RegQueryValueExW((HKEY)handle, Name.toStdWString().c_str(), 0, &dwType, lpData, &dwDataSize)) { switch (dwType) { case REG_SZ: value = QString::fromStdWString((wchar_t*)lpData); break; @@ -435,7 +435,7 @@ QJSValue JSysObject::removeRegValue(const QString& Key, const QString& Name) HANDLE handle = openRegKey(Key, true); if (handle && handle != INVALID_HANDLE_VALUE) { - RegDeleteValue((HKEY)handle, Name.toStdWString().c_str()); + RegDeleteValueW((HKEY)handle, Name.toStdWString().c_str()); CloseHandle(handle); } return QJSValue(); @@ -463,7 +463,7 @@ QJSValue JSysObject::execute(const QString& Path, const QVariant& Arguments, con if (Options["elevate"].toBool()) { - SHELLEXECUTEINFO shex; + SHELLEXECUTEINFOW shex; memset(&shex, 0, sizeof(SHELLEXECUTEINFO)); shex.cbSize = sizeof(SHELLEXECUTEINFO); shex.fMask = SEE_MASK_NOCLOSEPROCESS; @@ -476,7 +476,7 @@ QJSValue JSysObject::execute(const QString& Path, const QVariant& Arguments, con shex.nShow = nShow; shex.lpVerb = L"runas"; - if (ShellExecuteEx(&shex)) { + if (ShellExecuteExW(&shex)) { hProcess = shex.hProcess; } } diff --git a/SandboxiePlus/SandMan/Helpers/FindTool.cpp b/SandboxiePlus/SandMan/Helpers/FindTool.cpp index 0964baa5..33fbee85 100644 --- a/SandboxiePlus/SandMan/Helpers/FindTool.cpp +++ b/SandboxiePlus/SandMan/Helpers/FindTool.cpp @@ -167,10 +167,10 @@ void FlashWindowBorder(HWND hwnd, BOOL fShowHidden) void LoadFinderResources() { - hBitmapDrag1 = LoadBitmap(GetModuleHandle(0), L"FINDER_FULL"); - hBitmapDrag2 = LoadBitmap(GetModuleHandle(0), L"FINDER_EMPTY"); + hBitmapDrag1 = LoadBitmapW(GetModuleHandle(0), L"FINDER_FULL"); + hBitmapDrag2 = LoadBitmapW(GetModuleHandle(0), L"FINDER_EMPTY"); - hCursor = LoadCursor(GetModuleHandle(0), L"FINDER_CURSOR"); + hCursor = LoadCursorW(GetModuleHandle(0), L"FINDER_CURSOR"); } void FreeFinderResources() diff --git a/SandboxiePlus/SandMan/Helpers/FullScreen.cpp b/SandboxiePlus/SandMan/Helpers/FullScreen.cpp index 0898ee09..8e752e82 100644 --- a/SandboxiePlus/SandMan/Helpers/FullScreen.cpp +++ b/SandboxiePlus/SandMan/Helpers/FullScreen.cpp @@ -23,7 +23,7 @@ static bool IsPlatformFullScreenMode() typedef HRESULT(WINAPI* SHQueryUserNotificationStatePtr)( QUERY_USER_NOTIFICATION_STATE* state); - HMODULE shell32_base = ::GetModuleHandle(L"shell32.dll"); + HMODULE shell32_base = ::GetModuleHandleW(L"shell32.dll"); if (!shell32_base) { return false; } diff --git a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.cpp b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.cpp index e8ce288e..617a6b1f 100644 --- a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.cpp +++ b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.cpp @@ -76,7 +76,7 @@ void CReadDirectoryChanges::Terminate() } } -void CReadDirectoryChanges::AddDirectory( LPCTSTR szDirectory, BOOL bWatchSubtree, DWORD dwNotifyFilter, DWORD dwBufferSize ) +void CReadDirectoryChanges::AddDirectory(LPCWSTR szDirectory, BOOL bWatchSubtree, DWORD dwNotifyFilter, DWORD dwBufferSize ) { if (!m_hThread) Init(); @@ -85,7 +85,7 @@ void CReadDirectoryChanges::AddDirectory( LPCTSTR szDirectory, BOOL bWatchSubtre QueueUserAPC(CReadChangesServer::AddDirectoryProc, m_hThread, (ULONG_PTR)pRequest); } -void CReadDirectoryChanges::DetachDirectory( LPCTSTR szDirectory ) +void CReadDirectoryChanges::DetachDirectory(LPCWSTR szDirectory ) { if (!m_hThread) Init(); diff --git a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.h b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.h index 61f0efb6..56949f4a 100644 --- a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.h +++ b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChanges.h @@ -115,9 +115,9 @@ public: /// ReadDirectoryChangesW call for the given directory with the given flags. /// /// - void AddDirectory( LPCTSTR wszDirectory, BOOL bWatchSubtree, DWORD dwNotifyFilter, DWORD dwBufferSize=16384 ); + void AddDirectory( LPCWSTR wszDirectory, BOOL bWatchSubtree, DWORD dwNotifyFilter, DWORD dwBufferSize=16384 ); - void DetachDirectory( LPCTSTR wszDirectory ); + void DetachDirectory( LPCWSTR wszDirectory ); virtual void Notify( const std::wstring& strDirectory ) {} diff --git a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.cpp b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.cpp index 3be3b0a8..5aed84d3 100644 --- a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.cpp +++ b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.cpp @@ -41,7 +41,7 @@ namespace ReadDirectoryChangesPrivate /////////////////////////////////////////////////////////////////////////// // CReadChangesRequest -CReadChangesRequest::CReadChangesRequest(CReadChangesServer* pServer, LPCTSTR sz, BOOL b, DWORD dw, DWORD size) +CReadChangesRequest::CReadChangesRequest(CReadChangesServer* pServer, LPCWSTR sz, BOOL b, DWORD dw, DWORD size) { m_pServer = pServer; m_dwFilterFlags = dw; diff --git a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.h b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.h index 577acbcc..a34ae8f7 100644 --- a/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.h +++ b/SandboxiePlus/SandMan/Helpers/ReadDirectoryChangesPrivate.h @@ -40,7 +40,7 @@ class CReadChangesServer; class CReadChangesRequest { public: - CReadChangesRequest(CReadChangesServer* pServer, LPCTSTR sz, BOOL b, DWORD dw, DWORD size); + CReadChangesRequest(CReadChangesServer* pServer, LPCWSTR sz, BOOL b, DWORD dw, DWORD size); ~CReadChangesRequest(); diff --git a/SandboxiePlus/SandMan/Helpers/StorageInfo.cpp b/SandboxiePlus/SandMan/Helpers/StorageInfo.cpp index 437f9f03..51e85449 100644 --- a/SandboxiePlus/SandMan/Helpers/StorageInfo.cpp +++ b/SandboxiePlus/SandMan/Helpers/StorageInfo.cpp @@ -137,7 +137,7 @@ bool GetVolumeInfo(wchar_t* w32_name, SVolumeInfo* info) PVOLUME_DISK_EXTENTS ext = (PVOLUME_DISK_EXTENTS)buff; DWORD dwBytes; - hVolume = CreateFile(w32_name, SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + hVolume = CreateFileW(w32_name, SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (hVolume == INVALID_HANDLE_VALUE) return false; @@ -186,7 +186,7 @@ std::list ListAllVolumes() std::list volumes; wchar_t volumeName[MAX_PATH + 1]; - HANDLE hFindVolume = FindFirstVolume(volumeName, MAX_PATH + 1); + HANDLE hFindVolume = FindFirstVolumeW(volumeName, MAX_PATH + 1); if (hFindVolume == INVALID_HANDLE_VALUE) return volumes; @@ -198,12 +198,12 @@ std::list ListAllVolumes() DWORD dwRetLen = 0; wchar_t mountPoints[0x1000]; //QueryDosDevice(&volumeName[4], driveLetter, MAX_PATH + 1); - if (GetVolumePathNamesForVolumeName(volumeName, mountPoints, ARRAYSIZE(mountPoints), &dwRetLen)) { + if (GetVolumePathNamesForVolumeNameW(volumeName, mountPoints, ARRAYSIZE(mountPoints), &dwRetLen)) { for (wchar_t* mountPoint = mountPoints; *mountPoint; mountPoint += wcslen(mountPoint) + 1) info.mountPoints.push_back(mountPoint); } - volumeName[wcslen(volumeName) - 1] = 0; // strip trailing L'\\' + volumeName[wcslen(volumeName) - 1] = 0; // strip tailing L'\\' info.deviceName = QueryLinkTarget(volumeName); @@ -212,7 +212,7 @@ std::list ListAllVolumes() volumes.push_back(info); - } while (FindNextVolume(hFindVolume, volumeName, MAX_PATH + 1)); + } while (FindNextVolumeW(hFindVolume, volumeName, MAX_PATH + 1)); FindVolumeClose(hFindVolume); @@ -228,19 +228,19 @@ std::wstring QueryDiskDeviceInterfaceString(PWSTR DeviceInterface, CONST DEVPROP ULONG deviceInstanceIdLength = MAX_DEVICE_ID_LEN; WCHAR deviceInstanceId[MAX_DEVICE_ID_LEN + 1] = L""; - if (CM_Get_Device_Interface_Property(DeviceInterface, &DEVPKEY_Device_InstanceId, &devicePropertyType, (PBYTE)deviceInstanceId, &deviceInstanceIdLength, 0 ) != CR_SUCCESS) + if (CM_Get_Device_Interface_PropertyW(DeviceInterface, &DEVPKEY_Device_InstanceId, &devicePropertyType, (PBYTE)deviceInstanceId, &deviceInstanceIdLength, 0 ) != CR_SUCCESS) return L""; - if (CM_Locate_DevNode(&deviceInstanceHandle, deviceInstanceId, CM_LOCATE_DEVNODE_PHANTOM ) != CR_SUCCESS) + if (CM_Locate_DevNodeW(&deviceInstanceHandle, deviceInstanceId, CM_LOCATE_DEVNODE_PHANTOM ) != CR_SUCCESS) return L""; bufferSize = 0x40; std::wstring deviceDescription; deviceDescription.resize(bufferSize); - if ((result = CM_Get_DevNode_Property(deviceInstanceHandle, PropertyKey, &devicePropertyType, (PBYTE)deviceDescription.c_str(), &bufferSize, 0 )) != CR_SUCCESS) { + if ((result = CM_Get_DevNode_PropertyW(deviceInstanceHandle, PropertyKey, &devicePropertyType, (PBYTE)deviceDescription.c_str(), &bufferSize, 0 )) != CR_SUCCESS) { deviceDescription.resize(bufferSize); - result = CM_Get_DevNode_Property(deviceInstanceHandle, PropertyKey, &devicePropertyType, (PBYTE)deviceDescription.c_str(), &bufferSize, 0 ); + result = CM_Get_DevNode_PropertyW(deviceInstanceHandle, PropertyKey, &devicePropertyType, (PBYTE)deviceDescription.c_str(), &bufferSize, 0 ); } return deviceDescription.c_str(); // truncate @@ -273,7 +273,7 @@ std::map ListAllDrives() deviceInterfaceList = (PWSTR)malloc(deviceInterfaceListLength * sizeof(WCHAR)); memset(deviceInterfaceList, 0, deviceInterfaceListLength * sizeof(WCHAR)); - if (CM_Get_Device_Interface_List(pdevice->guid, NULL, deviceInterfaceList, deviceInterfaceListLength, CM_GET_DEVICE_INTERFACE_LIST_PRESENT) != CR_SUCCESS) { + if (CM_Get_Device_Interface_ListW(pdevice->guid, NULL, deviceInterfaceList, deviceInterfaceListLength, CM_GET_DEVICE_INTERFACE_LIST_PRESENT) != CR_SUCCESS) { free(deviceInterfaceList); return drives; } @@ -281,7 +281,7 @@ std::map ListAllDrives() for (deviceInterface = deviceInterfaceList; *deviceInterface; deviceInterface += wcslen(deviceInterface) + 1) { - HANDLE deviceHandle = CreateFile(deviceInterface, FILE_READ_ATTRIBUTES | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + HANDLE deviceHandle = CreateFileW(deviceInterface, FILE_READ_ATTRIBUTES | SYNCHRONIZE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (deviceHandle != INVALID_HANDLE_VALUE) { STORAGE_DEVICE_NUMBER result; diff --git a/SandboxiePlus/SandMan/Helpers/WinAdmin.cpp b/SandboxiePlus/SandMan/Helpers/WinAdmin.cpp index 54ca5a88..7ce37b2b 100644 --- a/SandboxiePlus/SandMan/Helpers/WinAdmin.cpp +++ b/SandboxiePlus/SandMan/Helpers/WinAdmin.cpp @@ -25,14 +25,14 @@ int RunElevated(const std::wstring& Params, bool bGetCode) { // Launch itself as admin wchar_t szPath[MAX_PATH]; - if (!GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath))) + if (!GetModuleFileNameW(NULL, szPath, ARRAYSIZE(szPath))) return -104; return RunElevated(std::wstring(szPath), Params, bGetCode ? 10000 : 0); } int RunElevated(const std::wstring& binaryPath, const std::wstring& Params, quint32 uTimeOut) { - SHELLEXECUTEINFO sei = { sizeof(sei) }; + SHELLEXECUTEINFOW sei = { sizeof(sei) }; sei.fMask = SEE_MASK_NOCLOSEPROCESS; sei.lpVerb = L"runas"; sei.lpFile = binaryPath.c_str(); @@ -40,7 +40,7 @@ int RunElevated(const std::wstring& binaryPath, const std::wstring& Params, quin sei.hwnd = NULL; sei.nShow = SW_NORMAL; - if (!ShellExecuteEx(&sei)) + if (!ShellExecuteExW(&sei)) { DWORD dwError = GetLastError(); if (dwError == ERROR_CANCELLED) @@ -115,17 +115,17 @@ bool IsAutorunEnabled() bool result = false; HKEY hkey = nullptr; - if (ERROR_SUCCESS == RegOpenKeyEx (HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey)) + if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey)) { // First, determine the required buffer size, including NUL terminator (in bytes). RegGetValue() always adds // an extra NUL terminator to size, even if one already exists, in case the stored value doesn't have one. DWORD size {0}; - if (ERROR_SUCCESS == RegGetValue(hkey, nullptr, AUTO_RUN_KEY_NAME, RRF_RT_REG_SZ, nullptr, nullptr, &size)) + if (ERROR_SUCCESS == RegGetValueW(hkey, nullptr, AUTO_RUN_KEY_NAME, RRF_RT_REG_SZ, nullptr, nullptr, &size)) { // Then, allocate the buffer (in WCHARs) and retrieve the auto-run value. If successful, the size // variable will be set to the actual size, without the extra NUL terminator. auto buffer = std::make_unique< WCHAR[] >(size / sizeof(WCHAR)); - if (ERROR_SUCCESS == RegGetValue(hkey, nullptr, AUTO_RUN_KEY_NAME, RRF_RT_REG_SZ, nullptr, reinterpret_cast(buffer.get()), &size)) + if (ERROR_SUCCESS == RegGetValueW(hkey, nullptr, AUTO_RUN_KEY_NAME, RRF_RT_REG_SZ, nullptr, reinterpret_cast(buffer.get()), &size)) { result = true; // todo: check path } @@ -142,22 +142,22 @@ bool AutorunEnable (bool is_enable) bool result = false; HKEY hkey = nullptr; - if (ERROR_SUCCESS == RegOpenKeyEx (HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey)) + if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey)) { if (is_enable) { constexpr size_t MAX_PATH_EX = 32767; // Long file path max length, in characters auto szPath = std::make_unique< WCHAR[] >(MAX_PATH_EX); - if (GetModuleFileName(NULL, szPath.get(), MAX_PATH_EX)) + if (GetModuleFileNameW(NULL, szPath.get(), MAX_PATH_EX)) { const std::wstring path = L"\"" + std::wstring(szPath.get()) + L"\" -autorun"; - result = (ERROR_SUCCESS == RegSetValueEx(hkey, AUTO_RUN_KEY_NAME, 0, REG_SZ, reinterpret_cast(path.c_str()), static_cast((path.length() + 1) * sizeof(WCHAR)))); + result = (ERROR_SUCCESS == RegSetValueExW(hkey, AUTO_RUN_KEY_NAME, 0, REG_SZ, reinterpret_cast(path.c_str()), static_cast((path.length() + 1) * sizeof(WCHAR)))); } } else { - result = (ERROR_SUCCESS == RegDeleteValue (hkey, AUTO_RUN_KEY_NAME)); + result = (ERROR_SUCCESS == RegDeleteValueW(hkey, AUTO_RUN_KEY_NAME)); } RegCloseKey (hkey); @@ -231,7 +231,7 @@ bool SkipUacEnable (bool is_enable) IRegisteredTask* registered_task = nullptr; wchar_t szPath[MAX_PATH]; - if (!GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath))) + if (!GetModuleFileNameW(NULL, szPath, ARRAYSIZE(szPath))) return false; std::wstring::size_type pos = std::wstring(szPath).find_last_of( L"\\/" ); std::wstring dir = std::wstring(szPath).substr(0, pos); @@ -372,7 +372,7 @@ bool SkipUacRun (bool test_only) IRunningTask* running_task = nullptr; wchar_t szPath[MAX_PATH]; - if (!GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath))) + if (!GetModuleFileNameW(NULL, szPath, ARRAYSIZE(szPath))) return false; MBSTR root (L"\\"); @@ -404,7 +404,7 @@ bool SkipUacRun (bool test_only) exec_action->get_Path (&path); - PathUnquoteSpaces (path); + PathUnquoteSpacesW(path); // check path is to current module if (_wcsicmp (path, szPath) == 0) @@ -420,7 +420,7 @@ bool SkipUacRun (bool test_only) // get arguments { INT numargs = 0; - LPWSTR* arga = CommandLineToArgvW(GetCommandLine(), &numargs); + LPWSTR* arga = CommandLineToArgvW(GetCommandLineW(), &numargs); for (INT i = 1; i < numargs; i++) { if (i > 1) diff --git a/SandboxiePlus/SandMan/Helpers/WinHelper.cpp b/SandboxiePlus/SandMan/Helpers/WinHelper.cpp index 6ad737b8..695cbf59 100644 --- a/SandboxiePlus/SandMan/Helpers/WinHelper.cpp +++ b/SandboxiePlus/SandMan/Helpers/WinHelper.cpp @@ -16,13 +16,13 @@ QVariantMap ResolveShortcut(const QString& LinkPath) QVariantMap Link; HRESULT hRes = E_FAIL; - IShellLink* psl = NULL; + IShellLinkW* psl = NULL; // buffer that receives the null-terminated string // for the drive and path - TCHAR szPath[0x1000]; + WCHAR szPath[0x1000]; // structure that receives the information about the shortcut - WIN32_FIND_DATA wfd; + WIN32_FIND_DATAW wfd; // Get a pointer to the IShellLink interface hRes = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl); @@ -138,13 +138,13 @@ QString GetProductVersion(const QString &filePath) DWORD verHandle = 0; UINT size = 0; LPBYTE lpBuffer = NULL; - DWORD verSize = GetFileVersionInfoSize(filePath.toStdWString().c_str(), &verHandle); + DWORD verSize = GetFileVersionInfoSizeW(filePath.toStdWString().c_str(), &verHandle); if (verSize != NULL) { LPSTR verData = new char[verSize]; - if (GetFileVersionInfo(filePath.toStdWString().c_str(), verHandle, verSize, verData)) { - if (VerQueryValue(verData, L"\\", (VOID FAR* FAR*)&lpBuffer, &size)) { + if (GetFileVersionInfoW(filePath.toStdWString().c_str(), verHandle, verSize, verData)) { + if (VerQueryValueW(verData, L"\\", (VOID FAR* FAR*)&lpBuffer, &size)) { if (size) { VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *)lpBuffer; if (verInfo->dwSignature == 0xfeef04bd) { @@ -169,4 +169,27 @@ QString GetProductVersion(const QString &filePath) } } return QString(); +} + +bool KillProcessById(DWORD processId) +{ + bool ok = false; + HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, processId); + if (hProcess && hProcess != INVALID_HANDLE_VALUE) { + if (TerminateProcess(hProcess, 0)) + ok = true; + CloseHandle(hProcess); + } + return ok; +} + +bool KillProcessByWnd(const QString& WndName) +{ + HWND hwnd = FindWindowW(WndName.toStdWString().c_str(), 0); + if (hwnd) { + DWORD processId; + if (GetWindowThreadProcessId(hwnd, &processId)) + return KillProcessById(processId); + } + return false; } \ No newline at end of file diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index d62f92bf..6d14c96a 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -450,12 +450,12 @@ void CSandMan::CreateMaintenanceMenu() if (QFile::exists(ImDiskCpl)) { m_pImDiskCpl = m_pMaintenance->addAction(LoadWindowsIcon(ImDiskCpl, 0), tr("Virtual Disks"), this, [ImDiskCpl]() { std::wstring imDiskCpl = ImDiskCpl.toStdWString(); - SHELLEXECUTEINFO si = { 0 }; + SHELLEXECUTEINFOW si = { 0 }; si.cbSize = sizeof(SHELLEXECUTEINFO); si.lpVerb = L"runas"; si.lpFile = imDiskCpl.c_str(); si.nShow = SW_SHOW; - ShellExecuteEx(&si); + ShellExecuteExW(&si); }); } @@ -3858,7 +3858,7 @@ void CSandMan::EditIni(const QString& IniPath, bool bPlus) std::wstring Editor = theConf->GetString("Options/Editor", "notepad.exe").toStdWString(); std::wstring iniPath = L"\"" + IniPath.toStdWString() + L"\""; - SHELLEXECUTEINFO si = { 0 }; + SHELLEXECUTEINFOW si = { 0 }; si.cbSize = sizeof(SHELLEXECUTEINFO); si.fMask = SEE_MASK_NOCLOSEPROCESS; si.hwnd = NULL; @@ -3868,7 +3868,7 @@ void CSandMan::EditIni(const QString& IniPath, bool bPlus) si.lpDirectory = NULL; si.nShow = SW_SHOW; si.hInstApp = NULL; - ShellExecuteEx(&si); + ShellExecuteExW(&si); //WaitForSingleObject(si.hProcess, INFINITE); //CloseHandle(si.hProcess); @@ -4178,7 +4178,7 @@ void CSandMan::OpenUrl(const QUrl& url) } if (iSandboxed) RunSandboxed(QStringList(url.toString())); - else ShellExecute(MainWndHandle, NULL, url.toString().toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL); + else ShellExecuteW(MainWndHandle, NULL, url.toString().toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL); } bool CSandMan::IsWFPEnabled() const @@ -4267,7 +4267,7 @@ void CSandMan::SetTitleTheme(const HWND& hwnd) if (CurrentVersion < 17763) // Windows 10 1809 - return; - HMODULE dwmapi = GetModuleHandle(L"dwmapi.dll"); + HMODULE dwmapi = GetModuleHandleW(L"dwmapi.dll"); if (dwmapi) { typedef HRESULT(WINAPI* P_DwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD); @@ -4499,7 +4499,7 @@ int g_CertAmount = 0; void SlotSend(const std::wstring& message) { std::wstring strSlotName = L"\\\\*\\mailslot\\" + g_SlotName; - HANDLE hSlot = CreateFile(strSlotName.c_str(), + HANDLE hSlot = CreateFileW(strSlotName.c_str(), GENERIC_WRITE, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES) NULL, @@ -4545,7 +4545,7 @@ int CountSeats() DWORD WINAPI MailThreadFunc(LPVOID lpParam) { std::wstring strSlotName = L"\\\\.\\mailslot\\" + g_SlotName; - HANDLE hSlot = CreateMailslot(strSlotName.c_str(), + HANDLE hSlot = CreateMailslotW(strSlotName.c_str(), 0, // no maximum message size MAILSLOT_WAIT_FOREVER, // no time-out for operations (LPSECURITY_ATTRIBUTES) NULL); // default security diff --git a/SandboxiePlus/SandMan/SandManRecovery.cpp b/SandboxiePlus/SandMan/SandManRecovery.cpp index 8f7fbf9e..a7a71333 100644 --- a/SandboxiePlus/SandMan/SandManRecovery.cpp +++ b/SandboxiePlus/SandMan/SandManRecovery.cpp @@ -251,10 +251,10 @@ void CSandMan::RecoverFilesAsync(QPair pParam, switch (Action) { case 1: // open - ShellExecute(NULL, NULL, path.c_str(), NULL, NULL, SW_SHOWNORMAL); + ShellExecuteW(NULL, NULL, path.c_str(), NULL, NULL, SW_SHOWNORMAL); break; case 2: // explore - ShellExecute(NULL, NULL, L"explorer.exe", (L"/select,\"" + path + L"\"").c_str(), NULL, SW_SHOWNORMAL); + ShellExecuteW(NULL, NULL, L"explorer.exe", (L"/select,\"" + path + L"\"").c_str(), NULL, SW_SHOWNORMAL); break; } } @@ -350,7 +350,7 @@ void CRecoveryLogWnd::closeEvent(QCloseEvent *e) void CRecoveryLogWnd::OnDblClick(QTreeWidgetItem* pItem) { - ShellExecute(NULL, NULL, L"explorer.exe", (L"/select,\"" + pItem->text(2).toStdWString() + L"\"").c_str(), NULL, SW_SHOWNORMAL); + ShellExecuteW(NULL, NULL, L"explorer.exe", (L"/select,\"" + pItem->text(2).toStdWString() + L"\"").c_str(), NULL, SW_SHOWNORMAL); } void CSandMan::OnRecoveryLog() diff --git a/SandboxiePlus/SandMan/SbieFindWnd.cpp b/SandboxiePlus/SandMan/SbieFindWnd.cpp index 2004b273..d539c994 100644 --- a/SandboxiePlus/SandMan/SbieFindWnd.cpp +++ b/SandboxiePlus/SandMan/SbieFindWnd.cpp @@ -31,7 +31,7 @@ typedef HRESULT (CALLBACK *P_GetScaleFactorForMonitor)(HMONITOR, DEVICE_SCALE_FA UINT GetMonitorScaling(HWND hwnd) { - static HINSTANCE shcore = LoadLibrary(L"Shcore.dll"); + static HINSTANCE shcore = LoadLibraryW(L"Shcore.dll"); if (shcore != nullptr) { if (auto getScaleFactorForMonitor = @@ -87,14 +87,14 @@ UINT CALLBACK FindProc(HWND hwndTool, UINT uCode, HWND hwnd) { std::wstring result = CSandMan::tr("The selected window is running as part of program %1 in sandbox %2").arg(pProcess->GetProcessName()).arg(pProcess->GetBoxName()).toStdWString(); - SetWindowText(GetDlgItem(hwndTool, ID_FINDER_RESULT), result.c_str()); + SetWindowTextW(GetDlgItem(hwndTool, ID_FINDER_RESULT), result.c_str()); //::ShowWindow(GetDlgItem(hwndTool, ID_FINDER_YES_BOXED), SW_SHOW); } else { std::wstring result = CSandMan::tr("The selected window is not running as part of any sandboxed program.").toStdWString(); - SetWindowText(GetDlgItem(hwndTool, ID_FINDER_RESULT), result.c_str()); + SetWindowTextW(GetDlgItem(hwndTool, ID_FINDER_RESULT), result.c_str()); //::ShowWindow(GetDlgItem(hwndTool, ID_FINDER_NOT_BOXED), SW_SHOW); } ::ShowWindow(GetDlgItem(hwndTool, ID_FINDER_RESULT), SW_SHOW); @@ -133,9 +133,9 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) std::wstring info = CSandMan::tr("Drag the Finder Tool over a window to select it, then release the mouse to check if the window is sandboxed.").toStdWString(); - CreateWindow(L"Static", L"", SS_BITMAP | SS_NOTIFY | WS_VISIBLE | WS_CHILD, DS(10), DS(10), DS(32), DS(32), hwnd, (HMENU)ID_FINDER_TARGET, NULL, NULL); - CreateWindow(L"Static", info.c_str(), WS_VISIBLE | WS_CHILD, DS(60), DS(10), DS(180), DS(85), hwnd, (HMENU)ID_FINDER_EXPLAIN, NULL, NULL); - CreateWindow(L"Static", L"", WS_CHILD, DS(60), DS(100), DS(180), DS(50), hwnd, (HMENU)ID_FINDER_RESULT, NULL, NULL); + CreateWindowW(L"Static", L"", SS_BITMAP | SS_NOTIFY | WS_VISIBLE | WS_CHILD, DS(10), DS(10), DS(32), DS(32), hwnd, (HMENU)ID_FINDER_TARGET, NULL, NULL); + CreateWindowW(L"Static", info.c_str(), WS_VISIBLE | WS_CHILD, DS(60), DS(10), DS(180), DS(85), hwnd, (HMENU)ID_FINDER_EXPLAIN, NULL, NULL); + CreateWindowW(L"Static", L"", WS_CHILD, DS(60), DS(100), DS(180), DS(50), hwnd, (HMENU)ID_FINDER_RESULT, NULL, NULL); WndData.hFont = CreateFont(DS(13), 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")); if (WndData.hFont) { @@ -164,14 +164,14 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) DWORD WINAPI FinderThreadFunc(LPVOID lpParam) { MSG msg; - WNDCLASS mainWindowClass = { 0 }; + WNDCLASSW mainWindowClass = { 0 }; HINSTANCE hInstance = NULL; // You can set the main window name to anything, but // typically you should prefix custom window classes // with something that makes it unique. - mainWindowClass.lpszClassName = TEXT("SBp.WndFinder"); + mainWindowClass.lpszClassName = L"SBp.WndFinder"; mainWindowClass.hInstance = hInstance; mainWindowClass.hbrBackground = GetSysColorBrush(COLOR_3DFACE); @@ -180,7 +180,7 @@ DWORD WINAPI FinderThreadFunc(LPVOID lpParam) mainWindowClass.cbWndExtra = sizeof(void*); // SFinderWndData - RegisterClass(&mainWindowClass); + RegisterClassW(&mainWindowClass); // Notes: // - The classname identifies the TYPE of the window. Not a C type. @@ -201,7 +201,7 @@ DWORD WINAPI FinderThreadFunc(LPVOID lpParam) SFinderWndData WndData; WndData.Scale = GetMonitorScaling(MainWndHandle); - HWND hwnd = CreateWindow(mainWindowClass.lpszClassName, CSandMan::tr("Sandboxie-Plus - Window Finder").toStdWString().c_str() + HWND hwnd = CreateWindowW(mainWindowClass.lpszClassName, CSandMan::tr("Sandboxie-Plus - Window Finder").toStdWString().c_str() , WS_SYSMENU | WS_CAPTION | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, DS(275), DS(135), NULL, 0, hInstance, &WndData); while (GetMessage(&msg, NULL, 0, 0)) diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.cpp b/SandboxiePlus/SandMan/SbiePlusAPI.cpp index 01fc6394..578c56db 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.cpp +++ b/SandboxiePlus/SandMan/SbiePlusAPI.cpp @@ -46,17 +46,17 @@ CBoxedProcessPtr CSbiePlusAPI::OnProcessBoxed(quint32 ProcessId, const QString& std::wstring GetWindowTextTimeout(HWND hWnd, UINT timeout) { - int length = 0; + unsigned long long length = 0; - if (SendMessageTimeoutW(hWnd, WM_GETTEXTLENGTH, 0, 0, SMTO_ABORTIFHUNG, timeout, reinterpret_cast(&length)) == 0) + if (SendMessageTimeoutW(hWnd, WM_GETTEXTLENGTH, 0, 0, SMTO_ABORTIFHUNG, timeout, &length) == 0) return L""; if (length == 0) return L""; std::vector buffer(length + 1); - if (SendMessageTimeoutW(hWnd, WM_GETTEXT, length + 1, reinterpret_cast(buffer.data()), SMTO_ABORTIFHUNG, timeout, nullptr) == 0) + if (SendMessageTimeoutW(hWnd, WM_GETTEXT, length + 1, reinterpret_cast(buffer.data()), SMTO_ABORTIFHUNG, timeout, &length) == 0) return L""; - return std::wstring(buffer.data()); + return std::wstring(buffer.data(), length); } BOOL CALLBACK CSbiePlusAPI__WindowEnum(HWND hwnd, LPARAM lParam) @@ -239,7 +239,7 @@ void CSandBoxPlus::ExportBoxAsync(const CSbieProgressPtr& pProgress, const QStri { QString FileName = (RootName.first.isEmpty() ? RootPath + "\\" : RootName.first) + RootName.second; Files.insert(ArcIndex, new QFileX(FileName, pProgress, &Archive)); - Attributes.insert(ArcIndex, GetFileAttributes(QString(FileName).replace("/", "\\").toStdWString().c_str())); + Attributes.insert(ArcIndex, GetFileAttributesW(QString(FileName).replace("/", "\\").toStdWString().c_str())); } //else // this file is already present in the archive, this should not happen !!! @@ -507,7 +507,7 @@ void CSandBoxPlus::ScanStartMenu() for (int i = 0; i < ARRAYSIZE(csidls); i++) { WCHAR path[2048]; - if (SHGetFolderPath(NULL, csidls[i], NULL, SHGFP_TYPE_CURRENT, path) != S_OK) + if (SHGetFolderPathW(NULL, csidls[i], NULL, SHGFP_TYPE_CURRENT, path) != S_OK) continue; foreach (const QString& Snapshot, SnapshotList) @@ -618,6 +618,7 @@ void CSandBoxPlus::ScanStartMenu() void CSandBoxPlus::SetBoxPaths(const QString& FilePath, const QString& RegPath, const QString& IpcPath) { + //bool bPathChanged = (FilePath != m_FileNtPath); bool bPathChanged = (FilePath != m_FilePath); if (bPathChanged && !m_FilePath.isEmpty()) @@ -648,7 +649,7 @@ void CSandBoxPlus::UpdateSize(bool bReset) if (m_bImageFile) { LARGE_INTEGER liSparseFileCompressedSize; - liSparseFileCompressedSize.LowPart = GetCompressedFileSize(GetBoxImagePath().toStdWString().c_str(), (LPDWORD)&liSparseFileCompressedSize.HighPart); + liSparseFileCompressedSize.LowPart = GetCompressedFileSizeW(GetBoxImagePath().toStdWString().c_str(), (LPDWORD)&liSparseFileCompressedSize.HighPart); m_TotalSize = liSparseFileCompressedSize.QuadPart; } @@ -855,9 +856,9 @@ void CSandBoxPlus::SetINetBlock(bool bEnable) { if (bEnable) { if(theGUI->IsWFPEnabled()) - InsertText("AllowNetworkAccess", "!,n"); + AppendText("AllowNetworkAccess", "!,n"); else - InsertText("ClosedFilePath", "!,InternetAccessDevices"); + AppendText("ClosedFilePath", "!,InternetAccessDevices"); } else { @@ -973,7 +974,7 @@ void CSandBoxPlus::BlockProgram(const QString& ProgName) if (!WhiteList && !BlackList) { BlackList = true; - InsertText("ClosedIpcPath", ",*"); + AppendText("ClosedIpcPath", ",*"); } EditProgramGroup("", ProgName, !WhiteList); diff --git a/SandboxiePlus/SandMan/Views/FileView.cpp b/SandboxiePlus/SandMan/Views/FileView.cpp index ae01ea03..a73b089f 100644 --- a/SandboxiePlus/SandMan/Views/FileView.cpp +++ b/SandboxiePlus/SandMan/Views/FileView.cpp @@ -122,7 +122,7 @@ void addSeparatorToShellContextMenu(HMENU hMenu) void addItemToShellContextMenu(HMENU hMenu, const wchar_t *name, int ID, bool bChecked = false) { - MENUITEMINFO menu_item_info; + MENUITEMINFOW menu_item_info; memset(&menu_item_info, 0, sizeof(MENUITEMINFO)); menu_item_info.cbSize = sizeof(MENUITEMINFO); menu_item_info.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA; @@ -132,7 +132,7 @@ void addItemToShellContextMenu(HMENU hMenu, const wchar_t *name, int ID, bool bC } menu_item_info.wID = 0xF000 + ID; menu_item_info.dwTypeData = (wchar_t*)name; - InsertMenuItem(hMenu, 0, TRUE, &menu_item_info); + InsertMenuItemW(hMenu, 0, TRUE, &menu_item_info); } void RemoveMenuItemByVerb(HMENU hMenu, IContextMenu* pContextMenu, UINT idCmdFirst, UINT idCmdLast, const std::wstring& verbToRemove) @@ -449,7 +449,7 @@ void CFileView::OnFileDblClick(const QModelIndex &) QString BoxedPath = m_pFileModel->fileInfo(m_pTreeView->currentIndex()).absoluteFilePath(); - ShellExecute(NULL, NULL, BoxedPath.toStdWString().c_str(), NULL, m_pBox->GetFileRoot().toStdWString().c_str(), SW_SHOWNORMAL); + ShellExecuteW(NULL, NULL, BoxedPath.toStdWString().c_str(), NULL, m_pBox->GetFileRoot().toStdWString().c_str(), SW_SHOWNORMAL); } diff --git a/SandboxiePlus/SandMan/Views/SbieView.cpp b/SandboxiePlus/SandMan/Views/SbieView.cpp index 847d00b8..551a3dd0 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.cpp +++ b/SandboxiePlus/SandMan/Views/SbieView.cpp @@ -1283,7 +1283,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList& SandB theConf->SetValue("Options/ExplorerInfo", false); } - ::ShellExecute(NULL, NULL, SandBoxes.first()->GetFileRoot().toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL); + ::ShellExecuteW(NULL, NULL, SandBoxes.first()->GetFileRoot().toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL); } else if (Action == m_pMenuRegEdit) { @@ -1317,7 +1317,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList& SandB if (SandBoxes.first()->GetActiveProcessCount() == 0) params += L" \"" + theAPI->GetStartPath().toStdWString() + L" /box:" + SandBoxes.first()->GetName().toStdWString() + L" mount_hive\""; - SHELLEXECUTEINFO shex; + SHELLEXECUTEINFOW shex; memset(&shex, 0, sizeof(SHELLEXECUTEINFO)); shex.cbSize = sizeof(SHELLEXECUTEINFO); shex.fMask = SEE_MASK_FLAG_NO_UI; @@ -1327,7 +1327,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList& SandB shex.nShow = SW_SHOWNORMAL; shex.lpVerb = L"runas"; - ShellExecuteEx(&shex); + ShellExecuteExW(&shex); } else if (Action == m_pMenuSnapshots) { diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index a9301449..8b8dfec3 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -2710,7 +2710,7 @@ void WindowsMoveFile(const QString& From, const QString& To) std::wstring to = To.toStdWString(); to.append(L"\0", 1); - SHFILEOPSTRUCT SHFileOp; + SHFILEOPSTRUCTW SHFileOp; memset(&SHFileOp, 0, sizeof(SHFILEOPSTRUCT)); SHFileOp.hwnd = NULL; SHFileOp.wFunc = To.isEmpty() ? FO_DELETE : FO_MOVE; @@ -2719,5 +2719,5 @@ void WindowsMoveFile(const QString& From, const QString& To) SHFileOp.fFlags = NULL; //The Copying Function - SHFileOperation(&SHFileOp); + SHFileOperationW(&SHFileOp); } diff --git a/SandboxiePlus/SandMan/main.cpp b/SandboxiePlus/SandMan/main.cpp index 4e9cae3c..08f3bfc0 100644 --- a/SandboxiePlus/SandMan/main.cpp +++ b/SandboxiePlus/SandMan/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) //SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); //SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); typedef DPI_AWARENESS_CONTEXT(WINAPI* P_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext); - P_SetThreadDpiAwarenessContext pSetThreadDpiAwarenessContext = (P_SetThreadDpiAwarenessContext)GetProcAddress(GetModuleHandle(L"user32.dll"), "SetThreadDpiAwarenessContext"); + P_SetThreadDpiAwarenessContext pSetThreadDpiAwarenessContext = (P_SetThreadDpiAwarenessContext)GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetThreadDpiAwarenessContext"); if(pSetThreadDpiAwarenessContext) // not present on windows 7 pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); else @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) //InitConsole(false); - bool IsBoxed = GetModuleHandle(L"SbieDll.dll") != NULL; + bool IsBoxed = GetModuleHandleW(L"SbieDll.dll") != NULL; if (!IsBoxed) { SB_STATUS Status = CSbieUtils::DoAssist(); @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) if (!cmdLine) return -2; if (IsBoxed) { - ShellExecute(NULL, L"open", cmdLine + 1, NULL, NULL, SW_SHOWNORMAL); + ShellExecuteW(NULL, L"open", cmdLine + 1, NULL, NULL, SW_SHOWNORMAL); return 0; } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) LPWSTR cmdLine = cmdLine0 + 14; if (IsBoxed) { - ShellExecute(NULL, L"open", cmdLine + 1, NULL, NULL, SW_SHOWNORMAL); + ShellExecuteW(NULL, L"open", cmdLine + 1, NULL, NULL, SW_SHOWNORMAL); return 0; }