diff --git a/AAS.py b/AAS.py index 6d8d3f5..da823b8 100644 --- a/AAS.py +++ b/AAS.py @@ -75,6 +75,7 @@ def MakeArchive(srcDir): for x in os.listdir(tempDir): if x.endswith(".exe"): EmbedAndDeleteManifest(os.path.join(tempDir, x)) + print(shutil.get_archive_formats()) shutil.make_archive(tempDir, "zip", tempDir) shutil.rmtree(tempDir) @@ -83,6 +84,7 @@ def Format(): for name in files: if name.endswith(".c") or name.endswith(".h"): os.system(f"clang-format.exe { path }/{ name } -i") + print(f"clang-format.exe { path }/{ name } -i") import sys if __name__ == "__main__": diff --git a/Assets/AAS/AddToStartup.bat b/Assets/AAS/AddToStartup.bat index 6a162c6..566a2ad 100644 --- a/Assets/AAS/AddToStartup.bat +++ b/Assets/AAS/AddToStartup.bat @@ -11,10 +11,9 @@ if not exist "%fullPath%" ( exit ) -schtasks /create /sc ONEVENT /ec Application /tn AltAppSwitcher /tr "'%fullPath%'" /RL HIGHEST /F - +call :createTask HighestAvailable if !errorlevel! neq 0 ( - schtasks /create /sc ONEVENT /ec Application /tn AltAppSwitcher /tr "'%fullPath%'" /RL LIMITED /F + call :createTask LeastPrivilege if !errorlevel! neq 0 ( msg * "Task creation failed. If a previous task was created with admin privileges, please re-run this utility as an admin." exit @@ -30,7 +29,52 @@ if !errorlevel! neq 0 ( ) if "%limited%" == "true" ( - msg * "Startup task added with limited rights. Re-run this utility as admin for admin rights. + msg * "Startup task added with limited rights. Re-run this utility as admin for admin rights." ) else ( msg * "Startup task added. Re-run this utility when moving AltAppSwitcher.exe." ) +exit /b + +:createTask +set "curUser=%USERDOMAIN%\%USERNAME%" +set "xmlFile=%TEMP%\AltAppSwitcher_task.xml" +( +echo ^ +echo ^ +echo ^ +echo ^ +echo ^true^ +echo ^%curUser%^ +echo ^ +echo ^ +echo ^true^ +echo ^SessionUnlock^ +echo ^%curUser%^ +echo ^ +echo ^ +echo ^ +echo ^ +echo ^InteractiveToken^ +echo ^%1^ +echo ^ +echo ^ +echo ^ +echo ^IgnoreNew^ +echo ^false^ +echo ^false^ +echo ^PT0S^ +echo ^7^ +echo ^ +echo ^ +echo ^ +echo ^%fullPath%^ +echo ^ +echo ^ +echo ^ +) > "%xmlFile%" + +schtasks /create /tn AltAppSwitcher /xml "%xmlFile%" /F + +set "result=!errorlevel!" +del "%xmlFile%" +exit /b !result! diff --git a/Makefile b/Makefile index 83402d9..a01722a 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ clang_tidy_disable_if_dbg = --checks=-* endif $(ALLOBJECTS): $(OBJDIR)/%.o: $(ROOTDIR)/%.c $(ALLH) clang-format $< --dry-run --Werror - clang-tidy $< --warnings-as-errors=* --allow-no-checks $(clang_tidy_disable_if_dbg) -- $(CFLAGS) + clang-tidy $< --warnings-as-errors=* --allow-no-checks $(clang_tidy_disable_if_dbg) --header-filter=$(SOURCEDIR)/.* -- $(CFLAGS) $(CC) $(CFLAGS) -MJ $@.json -c $< -o $@ # Build exe targets (link): diff --git a/Sources/.clang-tidy b/Sources/.clang-tidy index c595375..0b494fc 100644 --- a/Sources/.clang-tidy +++ b/Sources/.clang-tidy @@ -4,11 +4,6 @@ Checks: cert-*, concurrency-*, portability-*, - readability-*, -bugprone-easily-swappable-parameters, - -readability-identifier-length, - -readability-magic-numbers, - -readability-uppercase-literal-suffix, - -readability-braces-around-statements, - -readability-function-cognitive-complexity, + -portability-avoid-pragma-once, -cert-dcl16-c \ No newline at end of file diff --git a/Sources/AltAppSwitcher/App.c b/Sources/AltAppSwitcher/App.c index 65a38e6..a8cbd91 100644 --- a/Sources/AltAppSwitcher/App.c +++ b/Sources/AltAppSwitcher/App.c @@ -42,12 +42,8 @@ static DWORD MainThread; static void RestoreKey(WORD keyCode) { - // if (GetAsyncKeyState(VK_RCONTROL) & 0x8000) - // { - // printf("WHY\n"); - // } { - INPUT input = {}; + INPUT input = { }; input.type = INPUT_KEYBOARD; input.ki.wVk = VK_RCONTROL; input.ki.dwFlags = 0; @@ -59,7 +55,7 @@ static void RestoreKey(WORD keyCode) { // Needed ? - INPUT input = {}; + INPUT input = { }; input.type = INPUT_KEYBOARD; input.ki.wVk = KeyConfig->Invert; input.ki.dwFlags = KEYEVENTF_KEYUP; @@ -67,7 +63,7 @@ static void RestoreKey(WORD keyCode) ASSERT(uSent == 1); } { - INPUT input = {}; + INPUT input = { }; input.type = INPUT_KEYBOARD; input.ki.wVk = keyCode; input.ki.dwFlags = KEYEVENTF_KEYUP; @@ -78,7 +74,7 @@ static void RestoreKey(WORD keyCode) usleep(1000); if (GetAsyncKeyState(VK_RCONTROL) & 0x8000) { // printf("need reset key 0\n"); - INPUT input = {}; + INPUT input = { }; input.type = INPUT_KEYBOARD; input.ki.wVk = VK_RCONTROL; input.ki.dwFlags = KEYEVENTF_KEYUP; @@ -89,7 +85,7 @@ static void RestoreKey(WORD keyCode) usleep(1000); if (GetKeyState(VK_RCONTROL) & 0x8000) { // printf("need reset key 1\n"); - INPUT input = {}; + INPUT input = { }; input.type = INPUT_KEYBOARD; input.ki.wVk = VK_RCONTROL; input.ki.dwFlags = KEYEVENTF_KEYUP; @@ -115,19 +111,19 @@ static LRESULT KbProc(int nCode, WPARAM wParam, LPARAM lParam) const bool prevAppKey = kbStrut.vkCode == KeyConfig->PrevApp; const bool winHoldKey = kbStrut.vkCode == KeyConfig->WinHold; const bool nextWinKey = kbStrut.vkCode == KeyConfig->WinSwitch; - const bool isWatchedKey = appHoldKey || nextAppKey || prevAppKey || winHoldKey || nextWinKey; + const bool isWatchedKey = appHoldKey || nextAppKey || prevAppKey || winHoldKey || nextWinKey; // NOLINT if (!isWatchedKey) return CallNextHookEx(NULL, nCode, wParam, lParam); static enum Mode mode = ModeNone; - const bool rel = kbStrut.flags & LLKHF_UP; + const bool rel = (kbStrut.flags & LLKHF_UP) != 0; // Update target app state bool bypassMsg = false; const enum Mode prevMode = mode; { - const bool winHoldRelease = winHoldKey && rel; + const bool winHoldRelease = (winHoldKey && rel) != 0; const bool appHoldRelease = appHoldKey && rel; const bool nextApp = nextAppKey && !rel; const bool nextWin = nextWinKey && !rel; @@ -166,7 +162,7 @@ static DWORD KbHookCb(LPVOID param) { (void)param; ASSERT(SetWindowsHookEx(WH_KEYBOARD_LL, KbProc, 0, 0)); - MSG msg = {}; + MSG msg = { }; while (GetMessage(&msg, NULL, 0, 0) > 0) { } @@ -188,12 +184,22 @@ static HWND GetFirstChild(HWND win) } #endif +static void AssertSingleInstance() +{ + HANDLE hMutex = CreateMutexA(NULL, TRUE, "Global\\AltAppSwitcher{4fb3d3f7-9f35-41ce-b4d2-83c18eac3f54}"); + if (GetLastError() == ERROR_ALREADY_EXISTS) { + CloseHandle(hMutex); + ExitProcess(1); + } +} + int StartAltAppSwitcher(HINSTANCE instance) { SetLastError(0); + AssertSingleInstance(); ASSERT(SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)); - static struct AppData appData = {}; + static struct AppData appData = { }; { appData.Instance = instance; // Hook needs globals @@ -223,11 +229,11 @@ int StartAltAppSwitcher(HINSTANCE instance) CloseHandle(tok); } - char updater[MAX_PATH] = {}; + char updater[MAX_PATH] = { }; UpdaterPath(updater); if (appData.Config.CheckForUpdates && access(updater, F_OK) == 0) { - STARTUPINFO si = {}; - PROCESS_INFORMATION pi = {}; + STARTUPINFO si = { }; + PROCESS_INFORMATION pi = { }; CreateProcess(NULL, updater, 0, 0, false, CREATE_NEW_PROCESS_GROUP, 0, 0, &si, &pi); } @@ -237,9 +243,10 @@ int StartAltAppSwitcher(HINSTANCE instance) AppModeInit(instance, &appData.Config); WinModeInit(instance, &appData.Config); - HANDLE threadKbHook = CreateRemoteThread(GetCurrentProcess(), NULL, 0, KbHookCb, (void*)&appData, 0, NULL); + HANDLE threadKbHook = CreateThread(NULL, 0, KbHookCb, (void*)&appData, CREATE_SUSPENDED, NULL); (void)threadKbHook; - + SetThreadPriority(threadKbHook, THREAD_PRIORITY_TIME_CRITICAL); + ResumeThread(threadKbHook); AllowSetForegroundWindow(GetCurrentProcessId()); HANDLE token; @@ -258,7 +265,7 @@ int StartAltAppSwitcher(HINSTANCE instance) ChangeWindowMessageFilter(MSG_RESTART_AAS, MSGFLT_ADD); ChangeWindowMessageFilter(MSG_CLOSE_AAS, MSGFLT_ADD); - MSG msg = {}; + MSG msg = { }; bool restartAAS = false; bool closeAAS = false; while (GetMessage(&msg, NULL, 0, 0) > 0) { @@ -324,10 +331,10 @@ int StartAltAppSwitcher(HINSTANCE instance) WinModeDeinit(); if (restartAAS) { - STARTUPINFO si = {}; - PROCESS_INFORMATION pi = {}; + STARTUPINFO si = { }; + PROCESS_INFORMATION pi = { }; - char currentExe[MAX_PATH] = {}; + char currentExe[MAX_PATH] = { }; GetModuleFileName(NULL, currentExe, MAX_PATH); CreateProcess(NULL, currentExe, 0, 0, false, CREATE_NEW_PROCESS_GROUP, 0, 0, diff --git a/Sources/AltAppSwitcher/AppMode.c b/Sources/AltAppSwitcher/AppMode.c index 2b3451d..9b316ec 100644 --- a/Sources/AltAppSwitcher/AppMode.c +++ b/Sources/AltAppSwitcher/AppMode.c @@ -111,7 +111,7 @@ struct StaticData { ULONG_PTR GdiplusToken; }; -static struct StaticData StaticData = {}; +static struct StaticData StaticData = { }; struct WindowData { HWND MainWin; @@ -249,7 +249,7 @@ static BOOL GetWindowAUMI(HWND window, wchar_t* outUMI) HRESULT res = SHGetPropertyStoreForWindow(window, &IID_IPropertyStore, (void**)&propertyStore); if (!SUCCEEDED(res)) return false; - PROPVARIANT pv = {}; + PROPVARIANT pv = { }; PropVariantInit(&pv); res = IPropertyStore_GetValue(propertyStore, &PKEY_AppUserModel_ID, &pv); IPropertyStore_Release(propertyStore); @@ -516,7 +516,7 @@ static void StoreAppInfoToMap(struct UWPIconMap* map, const wchar_t* aumid, GpBi if (map->Data[storeIdx].UserModelID[0] != L'\0') { GdipDisposeImage(map->Data[storeIdx].Icon); - map->Data[storeIdx] = (SUWPIconMapElement) {}; + map->Data[storeIdx] = (SUWPIconMapElement) { }; } wcscpy(map->Data[storeIdx].UserModelID, aumid); @@ -534,7 +534,7 @@ static bool FindLnk(wchar_t* dirpath, const wchar_t* userModelID, wchar_t* outNa { const uint32_t dirPathLen = wcslen(dirpath); wcscat(dirpath, L"\\*"); - WIN32_FIND_DATAW findData = {}; + WIN32_FIND_DATAW findData = { }; HANDLE hFind = FindFirstFileW(dirpath, &findData); if (hFind == INVALID_HANDLE_VALUE) { dirpath[dirPathLen] = L'\0'; @@ -603,7 +603,7 @@ static bool FindLnk(wchar_t* dirpath, const wchar_t* userModelID, wchar_t* outNa HRESULT hr = IShellLinkW_QueryInterface(shellLink, &IID_IPropertyStore, (void**)&propertyStore); ASSERT(SUCCEEDED(hr)); } - PROPVARIANT pv = {}; + PROPVARIANT pv = { }; { PropVariantInit(&pv); HRESULT hr = IPropertyStore_GetValue(propertyStore, &PKEY_AppUserModel_ID, &pv); @@ -613,7 +613,7 @@ static bool FindLnk(wchar_t* dirpath, const wchar_t* userModelID, wchar_t* outNa HRESULT hr = IPropertyStore_Release(propertyStore); ASSERT(SUCCEEDED(hr)); } - static wchar_t foundAUMID[512] = {}; + static wchar_t foundAUMID[512] = { }; if (pv.vt == VT_LPWSTR) wcscpy_s(foundAUMID, 512 * sizeof(char), pv.pwszVal); if (pv.vt == VT_LPSTR) @@ -657,7 +657,7 @@ static bool GetAppInfoFromLnk(const wchar_t* userModelID, wchar_t* outIconPath, { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); static wchar_t* startMenu; - static wchar_t workPath[512] = {}; + static wchar_t workPath[512] = { }; bool found = false; { SHGetKnownFolderPath(&FOLDERID_StartMenu, 0, 0, &startMenu); @@ -675,6 +675,110 @@ static bool GetAppInfoFromLnk(const wchar_t* userModelID, wchar_t* outIconPath, return found; } +static void FindLogoInDir(wchar_t parentDir[MAX_PATH], wchar_t* logoNoExt, wchar_t* outIconPath, bool lightTheme, uint32_t* maxSize) { + wchar_t parentDirStar[MAX_PATH]; + wcscpy(parentDirStar, parentDir); + wcscat(parentDirStar, L"/*"); + + WIN32_FIND_DATAW findData; + HANDLE hFind = INVALID_HANDLE_VALUE; + hFind = FindFirstFileW(parentDirStar, &findData); + + if (hFind == INVALID_HANDLE_VALUE) { + return; + } + + bool foundAny = false; + + // https://learn.microsoft.com/en-us/windows/apps/design/style/iconography/app-icon-construction + while (FindNextFileW(hFind, &findData) != 0) { + const wchar_t* postLogoName = NULL; + { + const wchar_t* at = wcsstr(findData.cFileName, logoNoExt); + if (at == != findData.cFileName) + continue; + postLogoName = at + wcslen(logoNoExt); + } + + uint32_t targetsize = 0; + { + const wchar_t* at = wcsstr(postLogoName, L"targetsize-"); + if (at != NULL) { + at += (sizeof(L"targetsize-") / sizeof(wchar_t)) - 1; + targetsize = wcstol(at, NULL, 10); + } + } + + const bool lightUnplated = wcsstr(postLogoName, L"altform-lightunplated") != NULL; + const bool unplated = wcsstr(postLogoName, L"altform-unplated") != NULL; + const bool constrast = wcsstr(postLogoName, L"contrast") != NULL; + const bool matchingTheme = !constrast + && ((lightTheme && lightUnplated) + || (!lightTheme && unplated)); + + if (targetsize > *maxSize || !foundAny || (targetsize == *maxSize && matchingTheme)) { + *maxSize = targetsize; + foundAny = true; + wcscpy(outIconPath, parentDir); + wcscat(outIconPath, L"/"); + wcscat(outIconPath, findData.cFileName); + } + } +} + +static void ScanDirForAppLogoRecursive(wchar_t dir[MAX_PATH], wchar_t* logoPath, uint32_t logoPathDepth, wchar_t* logoName, bool lightTheme, uint32_t* maxSize, wchar_t* outIconPath) { + if (logoPathDepth == 0) { + FindLogoInDir(dir, logoName, outIconPath, lightTheme, maxSize); + } + + wchar_t dirWildcard[MAX_PATH]; + wcscpy(dirWildcard, dir); + wcscat(dirWildcard, L"/*"); + + WIN32_FIND_DATAW findData; + HANDLE hFind = INVALID_HANDLE_VALUE; + hFind = FindFirstFileW(dirWildcard, &findData); + + if (hFind == INVALID_HANDLE_VALUE) { + return; + } + + while (FindNextFileW(hFind, &findData) != 0) { + if (!wcscmp(findData.cFileName, L".") || !wcscmp(findData.cFileName, L"..")) + continue; + + if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + wchar_t childDir[MAX_PATH]; + wcscpy(childDir, dir); + wcscat(childDir, L"/"); + wcscat(childDir, findData.cFileName); + + wchar_t* nextLogoPath = logoPath; + uint32_t nextLogoPathDepth = logoPathDepth; + if (logoPathDepth && !wcscmp(findData.cFileName, logoPath)) { + nextLogoPath = logoPath + wcslen(logoPath) + 1; + nextLogoPathDepth--; + } + + ScanDirForAppLogoRecursive(childDir, nextLogoPath, nextLogoPathDepth, logoName, lightTheme, maxSize, outIconPath); + } + } +} + +static void FindLogoFromProp(wchar_t packagePath[MAX_PATH], wchar_t logoPath[MAX_PATH], wchar_t* logoName, bool lightTheme, wchar_t* outIconPath) { + uint32_t logoPathDepth = 1; + for (wchar_t* c = logoPath; *c; c++) { + if (*c == '/') { + logoPathDepth++; + *c = '\0'; + c++; + } + } + + uint32_t maxSize = 0; + ScanDirForAppLogoRecursive(packagePath, logoPath, logoPathDepth, logoName, lightTheme, &maxSize, outIconPath); +} + // https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/AppxPackingDescribeAppx/cpp/DescribeAppx.cpp static void GetAppInfoFromManifest(HANDLE process, const wchar_t* userModelID, wchar_t* outIconPath, wchar_t* outAppName, bool lightTheme) { @@ -778,74 +882,15 @@ static void GetAppInfoFromManifest(HANDLE process, const wchar_t* userModelID, w } else wcscpy(outAppName, displayName); } - wchar_t logoPath[MAX_PATH]; - wcscpy(logoPath, packagePath); - wcscat(logoPath, L"/"); - wcscat(logoPath, logoProp); - - wchar_t parentDir[MAX_PATH]; - wcscpy(parentDir, logoPath); - *wcsrchr(parentDir, L'/') = L'\0'; - - wchar_t parentDirStar[MAX_PATH]; - wcscpy(parentDirStar, parentDir); - wcscat(parentDirStar, L"/*"); wchar_t logoNoExt[MAX_PATH]; wchar_t* atLastSlash = wcsrchr(logoProp, L'/'); wcscpy(logoNoExt, atLastSlash ? atLastSlash + 1 : logoProp); wcsrchr(logoNoExt, L'.')[0] = L'\0'; - wchar_t ext[16]; - wcscpy(ext, wcsrchr(logoProp, L'.')); - - WIN32_FIND_DATAW findData; - HANDLE hFind = INVALID_HANDLE_VALUE; - hFind = FindFirstFileW(parentDirStar, &findData); - - if (hFind == INVALID_HANDLE_VALUE) { - CoUninitialize(); - return; - } - - uint32_t maxSize = 0; - bool foundAny = false; - - // https://learn.microsoft.com/en-us/windows/apps/design/style/iconography/app-icon-construction - while (FindNextFileW(hFind, &findData) != 0) { - const wchar_t* postLogoName = NULL; - { - const wchar_t* at = wcsstr(findData.cFileName, logoNoExt); - if (at == NULL) - continue; - postLogoName = at + wcslen(logoNoExt); - } - - uint32_t targetsize = 0; - { - const wchar_t* at = wcsstr(postLogoName, L"targetsize-"); - if (at != NULL) { - at += (sizeof(L"targetsize-") / sizeof(wchar_t)) - 1; - targetsize = wcstol(at, NULL, 10); - } - } - - const bool lightUnplated = wcsstr(postLogoName, L"altform-lightunplated") != NULL; - const bool unplated = wcsstr(postLogoName, L"altform-unplated") != NULL; - const bool constrast = wcsstr(postLogoName, L"contrast") != NULL; - const bool matchingTheme = !constrast - && ((lightTheme && lightUnplated) - || (!lightTheme && unplated)); - - if (targetsize > maxSize || !foundAny || (targetsize == maxSize && matchingTheme)) { - maxSize = targetsize; - foundAny = true; - wcscpy(outIconPath, parentDir); - wcscat(outIconPath, L"/"); - wcscat(outIconPath, findData.cFileName); - } - } + *atLastSlash = '\0'; + FindLogoFromProp(packagePath, logoProp, logoNoExt, lightTheme, outIconPath); CoUninitialize(); } @@ -999,12 +1044,12 @@ static GpBitmap* GetIconFromBinary(const wchar_t* binPath, int iconIdx) // Creates a gdi bitmap from the win base api bitmap GpBitmap* out; { - BITMAP bm = {}; + BITMAP bm = { }; GetObject(hbm, sizeof(BITMAP), &bm); const int iconSize = bm.bmWidth; GdipCreateBitmapFromScan0(iconSize, iconSize, 4 * iconSize, PixelFormat32bppARGB, NULL, &out); GpRect r = { 0, 0, iconSize, iconSize }; - BitmapData dstData = {}; + BitmapData dstData = { }; GdipBitmapLockBits(out, &r, 0, PixelFormat32bppARGB, &dstData); GetBitmapBits(hbm, (LONG)sizeof(uint32_t) * iconSize * iconSize, dstData.Scan0); // Check if color has non zero alpha (is there an alternative) @@ -1018,10 +1063,10 @@ static GpBitmap* GetIconFromBinary(const wchar_t* binPath, int iconIdx) } // If no alpha, init if (noAlpha && hbmMask != NULL && iconSize <= 256) { - BITMAP bitmapMask = {}; + BITMAP bitmapMask = { }; GetObject(hbmMask, sizeof(bitmapMask), (LPVOID)&bitmapMask); unsigned int maskByteSize = bitmapMask.bmWidthBytes * bitmapMask.bmHeight; - static char maskData[256 * 256 * 1 / 8] = {}; + static char maskData[256 * 256 * 1 / 8] = { }; GetBitmapBits(hbmMask, (LONG)maskByteSize, maskData); for (int i = 0; i < iconSize * iconSize; i++) { unsigned int aFromMask = (0x1 & (maskData[i / 8] >> (7 - i % 8))) ? 0 : 0xFF000000; @@ -1041,7 +1086,7 @@ static GpBitmap* GetIconFromBinary(const wchar_t* binPath, int iconIdx) static BOOL IsRunWindow(HWND hwnd) { { - WINDOWINFO wi = {}; + WINDOWINFO wi = { }; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(hwnd, &wi); if (wi.atomWindowType != 0x8002) @@ -1053,7 +1098,7 @@ static BOOL IsRunWindow(HWND hwnd) return false; { - WINDOWINFO wi = {}; + WINDOWINFO wi = { }; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(owner, &wi); if (wi.atomWindowType != 0xC01A) @@ -1066,7 +1111,7 @@ static BOOL IsRunWindow(HWND hwnd) void GetAppInfos(DWORD PID, struct StaticData* staticData, const wchar_t* aumid, GpBitmap** outIcon, wchar_t* outAppName) { bool found = GetAppInfoFromMap(&staticData->UWPIconMap, aumid, outIcon, outAppName); - if (!found) { + if (! found) { static wchar_t iconPath[MAX_PATH] = {}; int iconIdx = 0; iconPath[0] = L'\0'; @@ -1089,7 +1134,7 @@ void GetAppInfos(DWORD PID, struct StaticData* staticData, const wchar_t* aumid, isUWP = true; } if (!isUWP) { - static wchar_t exePath[512] = {}; + static wchar_t exePath[512] = { }; GetModuleFileNameExW(process, NULL, exePath, 512); iconPath[0] = L'\0'; wcscpy(iconPath, exePath); @@ -1105,7 +1150,7 @@ void GetAppInfos(DWORD PID, struct StaticData* staticData, const wchar_t* aumid, // Load bitmap if (wcslen(iconPath)) { - static wchar_t iconPathExpanded[MAX_PATH] = {}; + static wchar_t iconPathExpanded[MAX_PATH] = { }; ExpandEnvironmentStringsW(iconPath, iconPathExpanded, MAX_PATH - 1); if (EndsWithW(iconPathExpanded, L".exe") || EndsWithW(iconPathExpanded, L".EXE")) *outIcon = GetIconFromBinary(iconPathExpanded, iconIdx); @@ -1135,12 +1180,12 @@ void GetAppInfos(DWORD PID, struct StaticData* staticData, const wchar_t* aumid, // Creates a gdi bitmap from the win base api bitmap GpBitmap* out; { - BITMAP bm = {}; + BITMAP bm = { }; GetObject(hbm, sizeof(BITMAP), &bm); const uint32_t iconSize = bm.bmWidth; GdipCreateBitmapFromScan0((int)iconSize, (int)iconSize, (int)(4 * iconSize), PixelFormat32bppARGB, NULL, &out); GpRect r = { 0, 0, (int)iconSize, (int)iconSize }; - BitmapData dstData = {}; + BitmapData dstData = { }; GdipBitmapLockBits(out, &r, 0, PixelFormat32bppARGB, &dstData); GetBitmapBits(hbm, (LONG)(sizeof(uint32_t) * iconSize * iconSize), dstData.Scan0); GdipBitmapUnlockBits(out, &dstData); @@ -1324,7 +1369,7 @@ void AppModeInit(HINSTANCE instance, const struct Config* cfg) StaticData.GdiplusToken = 0; { - GdiplusStartupInput gdiplusStartupInput = {}; + GdiplusStartupInput gdiplusStartupInput = { }; gdiplusStartupInput.GdiplusVersion = 1; uint32_t status = GdiplusStartup(&StaticData.GdiplusToken, &gdiplusStartupInput, NULL); ASSERT(!status); @@ -1333,7 +1378,7 @@ void AppModeInit(HINSTANCE instance, const struct Config* cfg) InitGraphicsResources(&StaticData.GraphicsResources, cfg); { - WNDCLASS wc = {}; + WNDCLASS wc = { }; wc.lpfnWndProc = MainWindowProc; wc.hInstance = instance; wc.lpszClassName = MAIN_CLASS_NAME; @@ -1344,7 +1389,7 @@ void AppModeInit(HINSTANCE instance, const struct Config* cfg) } { - WNDCLASS wc = {}; + WNDCLASS wc = { }; wc.lpfnWndProc = FocusWindowProc; wc.hInstance = instance; wc.lpszClassName = FOCUS_CLASS_NAME; @@ -1363,7 +1408,7 @@ void AppModeDeinit() if (StaticData.UWPIconMap.Data[i].Icon) GdipDisposeImage(StaticData.UWPIconMap.Data[i].Icon); } - StaticData.UWPIconMap = (struct UWPIconMap) {}; + StaticData.UWPIconMap = (struct UWPIconMap) { }; DeinitGraphicsResources(&StaticData.GraphicsResources); GdiplusShutdown(StaticData.GdiplusToken); UnregisterClass(MAIN_CLASS_NAME, StaticData.Instance); @@ -1372,10 +1417,12 @@ void AppModeDeinit() HWND AppModeCreateWindow() { + DWORD curThread = GetCurrentThreadId(); DWORD fgwinthread = 0; + // Do not attach if drag in progress. Messes up drag. if (!((SHORT)GetAsyncKeyState(VK_LBUTTON) & 0x8000)) fgwinthread = GetWindowThreadProcessId(GetForegroundWindow(), NULL); - if (fgwinthread) { + if (fgwinthread && fgwinthread != curThread) { WINBOOL r = AttachThreadInput(GetCurrentThreadId(), fgwinthread, TRUE); VERIFY(r); } @@ -1396,7 +1443,7 @@ HWND AppModeCreateWindow() ); ASSERT(hwnd); SetForegroundWindow(hwnd); - if (fgwinthread) { + if (fgwinthread && fgwinthread != curThread) { WINBOOL r = AttachThreadInput(GetCurrentThreadId(), fgwinthread, FALSE); VERIFY(r); } @@ -1548,7 +1595,7 @@ static void DrawRoundedRect(GpGraphics* pGraphics, GpPen* pPen, GpBrush* pBrush, static bool IsInside(int x, int y, HWND win) { - RECT r = {}; + RECT r = { }; ASSERT(GetClientRect(win, &r)); return x > r.left && x < r.right && y > r.top && y < r.bottom; } @@ -1941,7 +1988,7 @@ static void Init(struct WindowData* windowData) DeleteObject(windowData->Bitmap); // Clear - *windowData = (struct WindowData) {}; + *windowData = (struct WindowData) { }; windowData->StaticData = sd; windowData->MainWin = w; @@ -2036,7 +2083,7 @@ static void Init(struct WindowData* windowData) void CloseAppGroup(const SWinGroup* winGroup, HWND hwnd) { static HANDLE ht = 0; - static CloseThreadData ctd = {}; + static CloseThreadData ctd = { }; if (ht) TerminateThread(ht, 0); ctd.Count = 0; @@ -2059,7 +2106,7 @@ void CloseAppGroup(const SWinGroup* winGroup, HWND hwnd) static LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static struct WindowData windowData = {}; + static struct WindowData windowData = { }; if (ProcessKeys(&windowData, uMsg, wParam) == 0) return 0; @@ -2085,7 +2132,7 @@ static LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR return 0; } case WM_CREATE: { - windowData = (struct WindowData) {}; + windowData = (struct WindowData) { }; windowData.StaticData = (struct StaticData*)((CREATESTRUCTA*)lParam)->lpCreateParams; windowData.MainWin = hwnd; Init(&windowData); @@ -2163,7 +2210,7 @@ static LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPAR return 0; } case WM_PAINT: { - PAINTSTRUCT ps = {}; + PAINTSTRUCT ps = { }; if (BeginPaint(hwnd, &ps) == NULL) { ASSERT(false); return 0; diff --git a/Sources/AltAppSwitcher/Common.c b/Sources/AltAppSwitcher/Common.c index c9c6130..51dc509 100644 --- a/Sources/AltAppSwitcher/Common.c +++ b/Sources/AltAppSwitcher/Common.c @@ -39,20 +39,21 @@ static const char* WindowsClassNamesToSkip[] = { static bool BelongsToCurrentDesktop(HWND window) { - IVirtualDesktopManager* vdm = NULL; - (void)vdm; - CoInitialize(NULL); - CoCreateInstance(&CLSID_VirtualDesktopManager, NULL, CLSCTX_ALL, &IID_IVirtualDesktopManager, (void**)&vdm); - + static IVirtualDesktopManager* vdm = NULL; if (!vdm) { - CoUninitialize(); - return true; + // Do not init each time, this affects the perf. a lot + CoInitialize(NULL); + CoCreateInstance(&CLSID_VirtualDesktopManager, NULL, CLSCTX_ALL, &IID_IVirtualDesktopManager, (void**)&vdm); + if (!vdm) { + CoUninitialize(); + return true; + } } - WINBOOL isCurrent = true; IVirtualDesktopManager_IsWindowOnCurrentVirtualDesktop(vdm, window, &isCurrent); - IVirtualDesktopManager_Release(vdm); - CoUninitialize(); + // Not clean, we should release. + // IVirtualDesktopManager_Release(vdm); + // CoUninitialize(); return isCurrent; } @@ -114,7 +115,7 @@ bool IsEligibleWindow(HWND hwnd, const struct Config* cfg, HMONITOR mouseMonitor { if (hwnd == GetShellWindow()) // Desktop return false; - WINDOWINFO wi = {}; + WINDOWINFO wi = { }; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(hwnd, &wi); if (!(wi.dwStyle & WS_VISIBLE)) @@ -210,7 +211,7 @@ static char WorkerClassName[] = "AASWorker"; void CommonInit(HINSTANCE instance) { - WNDCLASS wc = {}; + WNDCLASS wc = { }; wc.lpfnWndProc = WorkerWindowProc; wc.hInstance = instance; wc.lpszClassName = WorkerClassName; @@ -233,7 +234,7 @@ static DWORD WorkerThread(LPVOID data) 0, 0, 0, 0, HWND_MESSAGE, NULL, arg->instance, arg); SetEvent(arg->workerReady); - MSG msg = {}; + MSG msg = { }; while (GetMessage(&msg, arg->workerWin, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); diff --git a/Sources/AltAppSwitcher/WinMode.c b/Sources/AltAppSwitcher/WinMode.c index bd4aa04..b85fab9 100644 --- a/Sources/AltAppSwitcher/WinMode.c +++ b/Sources/AltAppSwitcher/WinMode.c @@ -40,7 +40,7 @@ struct StaticData { HMODULE Instance; }; -struct StaticData StaticData = {}; +struct StaticData StaticData = { }; struct WindowData { HWND MainWin; @@ -175,7 +175,7 @@ static void FindActualPID(HWND hwnd, DWORD* PID) static BOOL IsRunWindow(HWND hwnd) { { - WINDOWINFO wi = {}; + WINDOWINFO wi = { }; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(hwnd, &wi); if (wi.atomWindowType != 0x8002) @@ -187,7 +187,7 @@ static BOOL IsRunWindow(HWND hwnd) return false; { - WINDOWINFO wi = {}; + WINDOWINFO wi = { }; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(owner, &wi); if (wi.atomWindowType != 0xC01A) @@ -335,12 +335,12 @@ struct MainWindowArg { }; static LRESULT MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static struct WindowData windowData = {}; + static struct WindowData windowData = { }; switch (uMsg) { case WM_CREATE: { struct MainWindowArg* arg = (struct MainWindowArg*)((CREATESTRUCTA*)lParam)->lpCreateParams; - windowData = (struct WindowData) {}; + windowData = (struct WindowData) { }; windowData.MainWin = hwnd; windowData.StaticData = arg->StaticData; InitializeSwitchWin(arg->ForegroundWindow, &windowData); @@ -411,7 +411,7 @@ void WinModeInit(HINSTANCE instance, const struct Config* cfg) StaticData.Config = cfg; { - WNDCLASS wc = {}; + WNDCLASS wc = { }; wc.lpfnWndProc = MainWindowProc; wc.hInstance = instance; wc.lpszClassName = MAIN_CLASS_NAME; diff --git a/Sources/Config/Config.c b/Sources/Config/Config.c index d1c5da7..8a3ff35 100644 --- a/Sources/Config/Config.c +++ b/Sources/Config/Config.c @@ -150,7 +150,7 @@ void DefaultConfig(Config* config) void LoadConfig(Config* config) { DefaultConfig(config); - char configFile[MAX_PATH] = {}; + char configFile[MAX_PATH] = { }; ConfigPath(configFile); FILE* file = fopen(configFile, "rb"); if (file == NULL) { @@ -167,9 +167,9 @@ void LoadConfig(Config* config) #define GET_FLOAT(ENTRY, DST) \ TryGetFloat(keyValues, ENTRY, &(DST)) - static StrPair keyValues[32] = {}; + static StrPair keyValues[32] = { }; - static char lineBuf[1024] = {}; + static char lineBuf[1024] = { }; unsigned int i = 0; while (fgets(lineBuf, 1024, file)) { if (!strncmp(lineBuf, "//", 2)) @@ -241,7 +241,7 @@ static void WriteFloat(FILE* file, const char* entry, float value) void WriteConfig(const Config* config) { - char configFile[MAX_PATH] = {}; + char configFile[MAX_PATH] = { }; ConfigPath(configFile); FILE* file = fopen(configFile, "w"); ASSERT(file); diff --git a/Sources/Settings/Settings.c b/Sources/Settings/Settings.c index 4444866..8b52b01 100644 --- a/Sources/Settings/Settings.c +++ b/Sources/Settings/Settings.c @@ -95,7 +95,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine (void)hPrevInstance; (void)lpCmdLine; (void)nShowCmd; - Config config = {}; + Config config = { }; GUIWindow(SetupGUI, ButtonMessage, (void*)&config, hInstance, "AASSettings"); return 0; } \ No newline at end of file diff --git a/Sources/Updater/Updater.c b/Sources/Updater/Updater.c index abe2f1a..b7e62e4 100644 --- a/Sources/Updater/Updater.c +++ b/Sources/Updater/Updater.c @@ -50,10 +50,10 @@ static int GetLastAASVersion(BOOL preview, char* outVersion, char* assetURL) return 0; } - DynMem response = {}; + DynMem response = { }; curl_easy_setopt(curl, CURLOPT_URL, "https://api.github.com/repos/hdlx/altappswitcher/releases"); struct curl_slist* list = NULL; - char userAgent[256] = {}; + char userAgent[256] = { }; int a = sprintf_s(userAgent, sizeof(userAgent) / sizeof(userAgent[0]), "User-Agent: AltAppSwitcher_v%i.%i", AAS_MAJOR, AAS_MINOR); ASSERT(a > 0); list = curl_slist_append(list, userAgent); @@ -153,7 +153,7 @@ static void DownloadArchive(const char* dstFile, const char* url) return; curl_easy_setopt(curl, CURLOPT_URL, url); struct curl_slist* list = NULL; - char userAgent[256] = {}; + char userAgent[256] = { }; int a = sprintf_s(userAgent, sizeof(userAgent) / sizeof(userAgent[0]), "User-Agent: AltAppSwitcher_v%i.%i", AAS_MAJOR, AAS_MINOR); ASSERT(a > 0); list = curl_slist_append(list, userAgent); @@ -188,7 +188,7 @@ static void Extract(const char* targetDir) return; unsigned char buf[1024]; for (int i = 0; i < zip_get_num_entries(z, 0); i++) { - struct zip_stat zs = {}; + struct zip_stat zs = { }; zip_stat_index(z, i, 0, &zs); // printf("Name: [%s], ", zs.name); if (!strcmp(zs.name, "AltAppSwitcherConfig.txt")) @@ -197,7 +197,7 @@ static void Extract(const char* targetDir) ASSERT(zf); if (!zf) return; - char dstPath[256] = {}; + char dstPath[256] = { }; strcpy_s(dstPath, sizeof(dstPath), targetDir); strcat_s(dstPath, sizeof(dstPath), "/"); strcat_s(dstPath, sizeof(dstPath), zs.name); @@ -217,11 +217,11 @@ static void Extract(const char* targetDir) zip_fclose(zf); } { - char AASExe[256] = {}; + char AASExe[256] = { }; strcat_s(AASExe, sizeof(AASExe), targetDir); strcat_s(AASExe, sizeof(AASExe), "/AltAppSwitcher.exe"); - STARTUPINFO si = {}; - PROCESS_INFORMATION pi = {}; + STARTUPINFO si = { }; + PROCESS_INFORMATION pi = { }; CreateProcess(NULL, AASExe, 0, 0, 0, CREATE_NEW_PROCESS_GROUP, 0, targetDir, &si, &pi); } MessageBox(0, "AltAppSwitcher successfully updated", "AltAppSwitcher", MB_OK | MB_SETFOREGROUND); @@ -231,7 +231,7 @@ int main(int argc, char* argv[]) { BOOL extract = 0; BOOL preview = 0; - char targetDir[256] = {}; + char targetDir[256] = { }; for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "--target") && (i + 1) < argc) { strcpy_s(targetDir, sizeof(targetDir), argv[i + 1]); @@ -246,8 +246,8 @@ int main(int argc, char* argv[]) return 0; } - char version[64] = {}; - char assetURL[512] = {}; + char version[64] = { }; + char assetURL[512] = { }; GetLastAASVersion(preview, version, assetURL); if (assetURL[0] == '\0') return 0; @@ -266,7 +266,7 @@ int main(int argc, char* argv[]) } // Make temp dir - char tempDir[256] = {}; + char tempDir[256] = { }; { GetTempPath(sizeof(tempDir), tempDir); StrBToF(tempDir); @@ -279,7 +279,7 @@ int main(int argc, char* argv[]) mkdir(tempDir); } - char archivePath[256] = {}; + char archivePath[256] = { }; { strcpy_s(archivePath, sizeof(archivePath), tempDir); strcat_s(archivePath, sizeof(archivePath), "/AltAppSwitcher.zip"); @@ -287,11 +287,11 @@ int main(int argc, char* argv[]) } // Copy updater to temp - char updaterPath[256] = {}; + char updaterPath[256] = { }; { - char currentExe[256] = {}; + char currentExe[256] = { }; GetModuleFileName(NULL, currentExe, 256); - char currentDir[256] = {}; + char currentDir[256] = { }; ParentDir(currentExe, currentDir); CopyDirContent(currentDir, tempDir); strcat_s(updaterPath, sizeof(updaterPath), tempDir); @@ -299,8 +299,8 @@ int main(int argc, char* argv[]) } // Run copied updater - char args[512] = {}; - char AASDir[256] = {}; + char args[512] = { }; + char AASDir[256] = { }; GetCurrentDirectory(256, AASDir); int a = sprintf_s(args, sizeof(args) / sizeof(args[0]), "--target \"%s\"", AASDir); ASSERT(a > 0); diff --git a/Sources/Utils/Error.c b/Sources/Utils/Error.c index dcca06a..0ff566b 100644 --- a/Sources/Utils/Error.c +++ b/Sources/Utils/Error.c @@ -31,7 +31,7 @@ void ASSError(const char* file, uint32_t line, const char* assertStr, ...) DWORD err = GetLastError(); SetLastError(0); - char winMsg[512] = {}; + char winMsg[512] = { }; if (err != 0) { GetErrStr(err, winMsg, 512); } @@ -40,7 +40,7 @@ void ASSError(const char* file, uint32_t line, const char* assertStr, ...) char* timeStr = ctime(&mytime); // NOLINT timeStr[strlen(timeStr) - 1] = '\0'; - char logFile[MAX_PATH] = {}; + char logFile[MAX_PATH] = { }; LogPath(logFile); FILE* f = fopen(logFile, "ab"); diff --git a/Sources/Utils/Error.h b/Sources/Utils/Error.h index 41dbc2b..899ab89 100644 --- a/Sources/Utils/Error.h +++ b/Sources/Utils/Error.h @@ -1,18 +1,18 @@ #pragma once #include #include -#define ASSERT(arg) \ - if (!(arg)) { \ - ASSError(__FILE__, __LINE__, #arg); \ - assert(false); \ +#define ASSERT(arg) \ + if (!(arg)) { \ + ASSError(__FILE__, __LINE__, #arg); \ + assert(false); \ } -#define ASSERT_MSG(arg, str, ...) \ - if (!(arg)) { \ - ASSError(__FILE__, __LINE__, str, __VA_ARGS__); \ - assert(false); \ +#define ASSERT_MSG(arg, str, ...) \ + if (!(arg)) { \ + ASSError(__FILE__, __LINE__, str, __VA_ARGS__); \ + assert(false); \ } -#define VERIFY(arg) \ - if (!(arg)) { \ - ASSError(__FILE__, __LINE__, #arg); \ +#define VERIFY(arg) \ + if (!(arg)) { \ + ASSError(__FILE__, __LINE__, #arg); \ } void ASSError(const char* file, unsigned int line, const char* assertStr, ...); \ No newline at end of file diff --git a/Sources/Utils/File.c b/Sources/Utils/File.c index 18b8d1a..32075f0 100644 --- a/Sources/Utils/File.c +++ b/Sources/Utils/File.c @@ -67,7 +67,7 @@ static void CopyFile(const char* srcStr, const char* dstStr) ASSERT(a == 0); return; } - unsigned char buf[1024] = {}; + unsigned char buf[1024] = { }; while (true) { int a = fseek(src, 0, SEEK_CUR); ASSERT(a == 0); @@ -95,14 +95,14 @@ void CopyDirContent(const char* srcDir, const char* dstDir) stat(e->d_name, &info); if (info.st_mode & S_IFDIR) { } else if (info.st_mode & S_IFREG) { - char srcFile[256] = {}; + char srcFile[256] = { }; { strcpy_s(srcFile, sizeof(srcFile), srcDir); StrBToF(srcFile); strcat_s(srcFile, sizeof(srcFile), "/"); strcat_s(srcFile, sizeof(srcFile), e->d_name); } - char dstFile[256] = {}; + char dstFile[256] = { }; { strcpy_s(dstFile, sizeof(dstFile), dstDir); StrBToF(dstFile); @@ -119,7 +119,7 @@ void CopyDirContent(const char* srcDir, const char* dstDir) void ConfigPath(char* outPath) { outPath[0] = '\0'; - char currentExe[MAX_PATH] = {}; + char currentExe[MAX_PATH] = { }; GetModuleFileName(NULL, currentExe, MAX_PATH); ParentDir(currentExe, outPath); strcat_s(outPath, sizeof(char) * MAX_PATH, "/AltAppSwitcherConfig.txt"); @@ -128,7 +128,7 @@ void ConfigPath(char* outPath) void LogPath(char* outPath) { outPath[0] = '\0'; - char currentExe[MAX_PATH] = {}; + char currentExe[MAX_PATH] = { }; GetModuleFileName(NULL, currentExe, MAX_PATH); ParentDir(currentExe, outPath); strcat_s(outPath, sizeof(char) * MAX_PATH, "/AltAppSwitcherLog.txt"); @@ -137,7 +137,7 @@ void LogPath(char* outPath) void UpdaterPath(char* outPath) { outPath[0] = '\0'; - char currentExe[MAX_PATH] = {}; + char currentExe[MAX_PATH] = { }; GetModuleFileName(NULL, currentExe, MAX_PATH); ParentDir(currentExe, outPath); strcat_s(outPath, sizeof(char) * MAX_PATH, "/Updater.exe"); diff --git a/Sources/Utils/GUI.c b/Sources/Utils/GUI.c index b0aa5c9..e6f213d 100644 --- a/Sources/Utils/GUI.c +++ b/Sources/Utils/GUI.c @@ -85,7 +85,7 @@ static void CreateTooltip(HWND parent, HWND tool, char* string) 0, 0, 100, 100, parent, NULL, (HINSTANCE)GetWindowLongPtr(parent, GWLP_HINSTANCE), NULL); SetWindowPos(tt, HWND_TOPMOST, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - TOOLINFO ti = {}; + TOOLINFO ti = { }; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.uId = (UINT_PTR)tool; @@ -168,7 +168,7 @@ HWND CreateButton(const char* text, HMENU ID, GUIData* guiData) guiData->Cell.X, guiData->Cell.Y, 0, 0, guiData->Parent, (HMENU)ID, inst, NULL); SendMessage(button, WM_SETFONT, (WPARAM)guiData->Font, true); - SIZE size = {}; + SIZE size = { }; Button_GetIdealSize(button, &size); SetWindowPos(button, NULL, guiData->Cell.X + (guiData->Cell.W / 2) - (size.cx / 2), guiData->Cell.Y, size.cx, guiData->Cell.H, 0); NextCell(guiData); @@ -184,7 +184,7 @@ void CreateBoolControl(const char* tooltip, bool* value, GUIData* guiData) guiData->Cell.X, guiData->Cell.Y, guiData->Cell.W, guiData->Cell.H, guiData->Parent, (HMENU)0, inst, NULL); SendMessage(button, BM_SETCHECK, (WPARAM)*value ? BST_CHECKED : BST_UNCHECKED, true); - SIZE size = {}; + SIZE size = { }; Button_GetIdealSize(button, &size); guiData->BBindings[guiData->BBindingCount].CheckBox = button; guiData->BBindings[guiData->BBindingCount].TargetValue = value; @@ -194,7 +194,7 @@ void CreateBoolControl(const char* tooltip, bool* value, GUIData* guiData) static void InitGUIData(GUIData* guiData, HWND parent) { - NONCLIENTMETRICS metrics = {}; + NONCLIENTMETRICS metrics = { }; metrics.cbSize = sizeof(metrics); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0); metrics.lfCaptionFont.lfHeight = (LONG)((float)metrics.lfCaptionFont.lfHeight * 1.2f); @@ -214,7 +214,7 @@ static void InitGUIData(GUIData* guiData, HWND parent) 0, 0, 0, 0, parent, NULL, NULL, NULL); SendMessage(combobox, WM_SETFONT, (LPARAM)guiData->Font, true); - RECT rect = {}; + RECT rect = { }; GetWindowRect(combobox, &rect); guiData->Cell.H = rect.bottom - rect.top; DestroyWindow(combobox); @@ -222,7 +222,7 @@ static void InitGUIData(GUIData* guiData, HWND parent) guiData->Cell.X = WIN_PAD; guiData->Cell.Y = WIN_PAD; { - RECT parentRect = {}; + RECT parentRect = { }; GetClientRect(guiData->Parent, &parentRect); guiData->Cell.W = (parentRect.right - parentRect.left - WIN_PAD - WIN_PAD); } @@ -258,7 +258,7 @@ void ApplyBindings(const GUIData* guiData) const EnumBinding* bd = &guiData->EBindings[i]; const unsigned int iValue = SendMessage(bd->ComboBox, (UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0); - char sValue[64] = {}; + char sValue[64] = { }; SendMessage(bd->ComboBox, (UINT)CB_GETLBTEXT, (WPARAM)iValue, (LPARAM)sValue); bool found = false; for (unsigned int j = 0; bd->EnumStrings[j].Value != 0xFFFFFFFF; j++) { @@ -291,7 +291,7 @@ typedef struct UserData { static LRESULT GUIWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static GUIData guiData = {}; + static GUIData guiData = { }; static UserData* userData = 0; switch (uMsg) { case WM_DESTROY: { @@ -374,7 +374,7 @@ void GUIWindow(void (*setupGUI)(GUIData*, void*), // Class COLORREF col = LIGHT_COLOR; HBRUSH bkg = CreateSolidBrush(col); - WNDCLASS wc = {}; + WNDCLASS wc = { }; wc.lpfnWndProc = GUIWindowProc; wc.hInstance = instance; wc.lpszClassName = className; @@ -390,7 +390,7 @@ void GUIWindow(void (*setupGUI)(GUIData*, void*), 0, 0, 0, 0, NULL, NULL, instance, (LPVOID)userData); - MSG msg = {}; + MSG msg = { }; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); diff --git a/Sources/Utils/Message.c b/Sources/Utils/Message.c index 3626fa4..4101de4 100644 --- a/Sources/Utils/Message.c +++ b/Sources/Utils/Message.c @@ -5,7 +5,7 @@ static void PostAASMsg(int msg) { HANDLE procSnap = CreateToolhelp32Snapshot((DWORD)TH32CS_SNAPPROCESS, (DWORD)0); - PROCESSENTRY32 procEntry = {}; + PROCESSENTRY32 procEntry = { }; procEntry.dwSize = sizeof(procEntry); BOOL procRes = Process32First(procSnap, &procEntry); while (procRes) { @@ -15,7 +15,7 @@ static void PostAASMsg(int msg) } { HANDLE threadSnap = CreateToolhelp32Snapshot((DWORD)TH32CS_SNAPTHREAD, (DWORD)0); - THREADENTRY32 threadEntry = {}; + THREADENTRY32 threadEntry = { }; threadEntry.dwSize = sizeof(threadEntry); BOOL threadRes = Thread32First(threadSnap, &threadEntry); while (threadRes) { @@ -43,7 +43,7 @@ void CloseAAS() int AASIsRunning() { HANDLE procSnap = CreateToolhelp32Snapshot((DWORD)TH32CS_SNAPPROCESS, (DWORD)0); - PROCESSENTRY32 procEntry = {}; + PROCESSENTRY32 procEntry = { }; procEntry.dwSize = sizeof(procEntry); BOOL procRes = Process32First(procSnap, &procEntry); while (procRes) { diff --git a/Sources/Utils/Version.h b/Sources/Utils/Version.h index f80d4a8..d48cdbd 100644 --- a/Sources/Utils/Version.h +++ b/Sources/Utils/Version.h @@ -1,2 +1,2 @@ #define AAS_MAJOR 0 -#define AAS_MINOR 74 \ No newline at end of file +#define AAS_MINOR 77 \ No newline at end of file