diff --git a/.gitignore b/.gitignore index 4612351..a756370 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +/.vs/ # User-specific files *.suo @@ -187,4 +188,19 @@ FakesAssemblies/ GeneratedArtifacts/ _Pvt_Extensions/ ModelManifest.xml + +# Visual Studio cache/options directory +.vs/ + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + /do/err.txt diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100644 index 0000000..fd844a8 --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1 @@ +/.browse.VC.db diff --git a/audio-router-gui/app_list.cpp b/audio-router-gui/app_list.cpp index 1f920b3..2322e3f 100644 --- a/audio-router-gui/app_list.cpp +++ b/audio-router-gui/app_list.cpp @@ -1,114 +1,103 @@ #include "app_list.h" -#include -#include +#include < Psapi.h > +#include < algorithm > -bool app_list::populate_list(bool x86, const filters_t& filters) -{ - DWORD processes[1024], needed; - if(!EnumProcesses(processes, sizeof(processes), &needed)) - return false; +bool app_list::populate_list(bool x86, const filters_t & filters) { + DWORD processes[1024], needed; + if ( ! EnumProcesses(processes, sizeof(processes), & needed)) + return false; - for(DWORD i = 0; i < (needed / sizeof(DWORD)); i++) - { - app_info info; - info.id = processes[i]; - if(this->get_app_info(info, filters, x86, true)) - this->apps.push_back(info); + size_t count = needed / sizeof(DWORD); + for (DWORD i = 0; i < count; i++) { + app_info info; + info.id = processes[i]; + if (this->get_app_info(info, filters, x86, true)) + this->apps.push_back(info); } - return true; + return true; } -bool app_list::populate_list() -{ - filters_t filters; - filters.push_back(L"mmdevapi.dll"); - return this->populate_list(filters); +bool app_list::populate_list() { + filters_t filters; + filters.push_back(L"mmdevapi.dll"); + return this->populate_list(filters); } -bool app_list::populate_list(const filters_t& filters) -{ - this->apps.clear(); +bool app_list::populate_list(const filters_t & filters) { + this->apps.clear(); - if(!this->populate_list(true, filters)) - return false; + if (!this->populate_list(true, filters)) + return false; #ifdef _WIN64 - return this->populate_list(false, filters); + return this->populate_list(false, filters); #else - return true; + return true; #endif } -bool app_list::get_app_info(app_info& info, const filters_t& filters, bool x86, bool query_name) -{ - HMODULE hmodules[1024]; - DWORD needed; +bool app_list::get_app_info(app_info & info, const filters_t & filters, bool x86, bool query_name) { + HMODULE hmodules[1024]; + DWORD needed; HANDLE hprocess = OpenProcess( - PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, - FALSE, info.id); - if(hprocess == NULL) - return false; + PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, + FALSE, info.id); + if (hprocess == NULL) + return false; #ifdef _WIN64 - BOOL px86; - if(!IsWow64Process(hprocess, &px86)) - { - CloseHandle(hprocess); - return false; + BOOL px86; + if ( ! IsWow64Process(hprocess, & px86)) { + CloseHandle(hprocess); + return false; } - info.x86 = px86; + info.x86 = px86; #else - info.x86 = true; + info.x86 = true; #endif - if(query_name && EnumProcessModulesEx( - hprocess, hmodules, sizeof(hmodules), - &needed, x86 ? LIST_MODULES_32BIT : LIST_MODULES_64BIT)) - { - WCHAR name[MAX_PATH] = {0}; + if (query_name && EnumProcessModulesEx( + hprocess, hmodules, sizeof(hmodules), & needed, x86?LIST_MODULES_32BIT:LIST_MODULES_64BIT)) { + WCHAR name[MAX_PATH] = {0}; std::wstring exename; - if(GetModuleBaseName(hprocess, hmodules[0], name, sizeof(name) / sizeof(WCHAR))) - { - _wcslwr(name); - exename = name; + auto name_size = sizeof(name) / sizeof(WCHAR); + if (GetModuleBaseName(hprocess, hmodules[0], name, name_size)) { + _wcslwr(name); + exename = name; // skip filter - if(filters.empty()) - { - info.name = exename; - CloseHandle(hprocess); - return true; + if (filters.empty()) { + info.name = exename; + CloseHandle(hprocess); + return true; } - for(DWORD j = 0; j < (needed / sizeof(HMODULE)); j++) - { - WCHAR name[MAX_PATH] = {0}; - if(GetModuleBaseName(hprocess, hmodules[j], name, sizeof(name) / sizeof(WCHAR))) - { - _wcslwr(name); - for(filters_t::const_iterator it = filters.begin(); it != filters.end(); it++) - if(*it == name) - { - info.name = exename; - CloseHandle(hprocess); - return true; - }; + size_t needed_count = needed / sizeof(HMODULE); + for (DWORD j = 0; j < needed_count; j++) { + WCHAR name[MAX_PATH] = {0}; + if (GetModuleBaseName(hprocess, hmodules[j], name, name_size)) { + _wcslwr(name); + for (filters_t::const_iterator it = filters.begin(); it != filters.end(); it++) + if ( * it == name) { + info.name = exename; + CloseHandle(hprocess); + return true; + }; } } } } - CloseHandle(hprocess); - return !query_name; + CloseHandle(hprocess); + return ! query_name; } -bool app_list::get_app_info(app_info& info, const filters_t& filters, bool query_name) -{ - if(get_app_info(info, filters, true, query_name)) - return true; +bool app_list::get_app_info(app_info & info, const filters_t & filters, bool query_name) { + if (get_app_info(info, filters, true, query_name)) + return true; #ifdef _WIN64 - return get_app_info(info, filters, false, query_name); + return get_app_info(info, filters, false, query_name); #else - return false; + return false; #endif } \ No newline at end of file diff --git a/audio-router-gui/audio-router-gui.rc b/audio-router-gui/audio-router-gui.rc index 53b4014..81c35b9 100644 Binary files a/audio-router-gui/audio-router-gui.rc and b/audio-router-gui/audio-router-gui.rc differ diff --git a/audio-router-gui/audio-router-gui.vcxproj b/audio-router-gui/audio-router-gui.vcxproj index 1523f64..a8ead2c 100644 --- a/audio-router-gui/audio-router-gui.vcxproj +++ b/audio-router-gui/audio-router-gui.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -26,26 +26,26 @@ Application true - v120 + v141 Unicode Application true - v120 + v141 Unicode Application false - v120 + v141 true Unicode Application false - v120 + v141 true Unicode @@ -159,6 +159,7 @@ + @@ -182,6 +183,7 @@ + diff --git a/audio-router-gui/audio-router-gui.vcxproj.filters b/audio-router-gui/audio-router-gui.vcxproj.filters index de1426e..7245f82 100644 --- a/audio-router-gui/audio-router-gui.vcxproj.filters +++ b/audio-router-gui/audio-router-gui.vcxproj.filters @@ -69,6 +69,9 @@ Header Files + + Header Files + @@ -127,6 +130,9 @@ Source Files + + Source Files + diff --git a/audio-router-gui/clsSysTray.cpp b/audio-router-gui/clsSysTray.cpp new file mode 100644 index 0000000..4ea2771 --- /dev/null +++ b/audio-router-gui/clsSysTray.cpp @@ -0,0 +1,89 @@ +#include "clsSysTray.h" +#include "resource.h" + + +clsSysTray::clsSysTray() +{ + bInTray = false; + NotifyIconData.cbSize = sizeof(NotifyIconData); + NotifyIconData.uID = uID = 2; + NotifyIconData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; + NotifyIconData.uCallbackMessage = WM_TRAYNOTIFY; + NotifyIconData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME)); + NotifyIconData.szTip[0] = '\0'; + NotifyIconData.hWnd = NULL; +} + + +clsSysTray::~clsSysTray() +{ +} + +BOOL clsSysTray::SetIcon(HICON hNewIcon) +{ + NotifyIconData.hIcon = hNewIcon; + if (bInTray) + { + BOOL iRetVal; + iRetVal = Shell_NotifyIcon(NIM_MODIFY, &NotifyIconData); + if (iRetVal) + { + bInTray = true; + } + return iRetVal; + } + else + return (1); +} + +HICON clsSysTray::GetIcon() +{ + return NotifyIconData.hIcon; +} + +BOOL clsSysTray::SetTipText(char *lpstrNewTipText) +{ + //strncpy(NotifyIconData.szTip, lpstrNewTipText); + if (bInTray) + { + BOOL iRetVal; + iRetVal = Shell_NotifyIcon(NIM_MODIFY, &NotifyIconData); + if (iRetVal) + { + bInTray = true; + } + return iRetVal; + } + else + return (1); +} + +char *clsSysTray::GetTipText() +{ + return "test"; // NotifyIconData.szTip; +} + +BOOL clsSysTray::AddIcon() +{ + BOOL iRetVal; + NotifyIconData.hWnd = hWnd; + NotifyIconData.uID = uID; + iRetVal = Shell_NotifyIcon(NIM_ADD, &NotifyIconData); + if (iRetVal) + { + bInTray = true; + + } + return iRetVal; +} + +BOOL clsSysTray::RemoveIcon() +{ + BOOL iRetVal; + iRetVal = Shell_NotifyIcon(NIM_DELETE, &NotifyIconData); + if (iRetVal) + { + bInTray = false; + } + return iRetVal; +} diff --git a/audio-router-gui/clsSysTray.h b/audio-router-gui/clsSysTray.h new file mode 100644 index 0000000..32f430e --- /dev/null +++ b/audio-router-gui/clsSysTray.h @@ -0,0 +1,27 @@ +#pragma once +#pragma warning(disable: 4996) + +#include + +#define WM_TRAYNOTIFY 0XA44C +#include + +class clsSysTray +{ +public: + clsSysTray(); + ~clsSysTray(); + BOOL SetIcon(HICON hNewIcon); + HICON GetIcon(); + BOOL SetTipText(char *lpstrNewTipText); + char *GetTipText(); + BOOL AddIcon(); + BOOL RemoveIcon(); + HWND hWnd; + UINT uID; +protected: + NOTIFYICONDATA NotifyIconData; + bool bInTray; +}; + + diff --git a/audio-router-gui/dialog_main.cpp b/audio-router-gui/dialog_main.cpp index 17aa13b..d4496de 100644 --- a/audio-router-gui/dialog_main.cpp +++ b/audio-router-gui/dialog_main.cpp @@ -15,9 +15,7 @@ dialog_main::~dialog_main() void dialog_main::clear_dialog_arrays() { - for(auto it = this->dialog_arrays.begin(); - it != this->dialog_arrays.end(); - it++) + for (auto it = this->dialog_arrays.begin(); it != this->dialog_arrays.end(); it++) { delete *it; } diff --git a/audio-router-gui/main.cpp b/audio-router-gui/main.cpp index d27a44c..2b51827 100644 --- a/audio-router-gui/main.cpp +++ b/audio-router-gui/main.cpp @@ -11,6 +11,7 @@ CAppModule _Module; HANDLE audio_router_mutex; + int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { /*srand(time(NULL));*/ @@ -47,7 +48,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi delete [] serialized_params;*/ - if(GetModuleHandle(L"Audio Router.exe") == NULL) + if (GetModuleHandle(L"Audio Router.exe") == NULL) { MessageBox( NULL, L"Wrong application name. Audio Router will close.", NULL, MB_ICONERROR); @@ -59,31 +60,31 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi assert(sec.get() != NULL); audio_router_mutex = CreateMutex(sec.get(), FALSE, L"Local\\audio-router-mutex"); } - if(audio_router_mutex == NULL) - { - MessageBox( - NULL, L"Mutex creation failed. Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } - else if(GetLastError() == ERROR_ALREADY_EXISTS) - { - CloseHandle(audio_router_mutex); - MessageBox( - NULL, L"Another instance of Audio Router is already running. " \ - L"Audio Router will close.", NULL, MB_ICONERROR); - return 0; - } + + //if (audio_router_mutex == NULL) + //{ + // MessageBox( + // NULL, L"Mutex creation failed. Audio Router will close.", NULL, MB_ICONERROR); + // return 0; + //} + //else if (GetLastError() == ERROR_ALREADY_EXISTS) + //{ + // CloseHandle(audio_router_mutex); + // MessageBox( + // NULL, L"Another instance of Audio Router is already running. " \ + // L"Audio Router will close.", NULL, MB_ICONERROR); + // return 0; + //} HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); - if(hr != S_OK) + if (hr != S_OK) { CloseHandle(audio_router_mutex); - MessageBox( - NULL, L"COM could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); + MessageBox(NULL, L"COM could not be initialized. Audio Router will close.", NULL, MB_ICONERROR); return 0; } - if(_Module.Init(NULL, hInstance) != S_OK) + if (_Module.Init(NULL, hInstance) != S_OK) { CoUninitialize(); CloseHandle(audio_router_mutex); @@ -94,7 +95,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi ULONG_PTR gdiplusToken; Gdiplus::GdiplusStartupInput gdiplusStartupInput; - if(Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) != Gdiplus::Ok) + if (Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) != Gdiplus::Ok) { _Module.Term(); CoUninitialize(); @@ -104,7 +105,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi return 0; } - MSG msg = {0}; + MSG msg = { 0 }; //std::unique_ptr bootstrap; //try //{ @@ -117,20 +118,25 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi // MessageBox(NULL, err.c_str(), NULL, MB_ICONERROR); // goto cleanup; //} + { window win/*(bootstrap.get())*/; - RECT r = {CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT + WIN_WIDTH, CW_USEDEFAULT + WIN_HEIGHT}; - if(win.CreateEx(NULL, &r) == NULL) + RECT r = { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT + WIN_WIDTH, CW_USEDEFAULT + WIN_HEIGHT }; + + + if (win.CreateEx(NULL, &r) == NULL) { MessageBox(NULL, L"Could not create window. Audio Router will close.", NULL, MB_ICONERROR); goto cleanup; } + win.ShowWindow(nCmdShow); win.UpdateWindow(); - while(GetMessage(&msg, NULL, 0, 0) > 0) + while (GetMessage(&msg, NULL, 0, 0) > 0) { - if(win.dlg_main && IsDialogMessage(*win.dlg_main, &msg)) + + if (win.dlg_main && IsDialogMessage(*win.dlg_main, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); @@ -144,4 +150,5 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi CloseHandle(audio_router_mutex); return (int)msg.wParam; -} \ No newline at end of file +} + diff --git a/audio-router-gui/resource.h b/audio-router-gui/resource.h index 252eace..0e2d8b2 100644 Binary files a/audio-router-gui/resource.h and b/audio-router-gui/resource.h differ diff --git a/audio-router-gui/window.cpp b/audio-router-gui/window.cpp index 196585a..05610c9 100644 --- a/audio-router-gui/window.cpp +++ b/audio-router-gui/window.cpp @@ -1,6 +1,7 @@ #include "window.h" telemetry* telemetry_m = NULL; +HMENU trayIconMenu; window::window(/*bootstrapper* bootstrap*/) : dlg_main_b(true)/*, license(NULL)*//*, bootstrap(bootstrap)*/ { @@ -10,7 +11,8 @@ window::window(/*bootstrapper* bootstrap*/) : dlg_main_b(true)/*, license(NULL)* window::~window() { - if(this->dlg_main_b) + STray.RemoveIcon(); + if (this->dlg_main_b) delete this->dlg_main; delete this->form_view; @@ -27,72 +29,125 @@ int window::OnCreate(LPCREATESTRUCT lpcs) this->m_hWndClient = this->dlg_main->Create(this->m_hWnd); this->dlg_main->ShowWindow(SW_SHOW); + bIsVisible = true; + STray.hWnd = this->m_hWnd; + STray.SetTipText("Audio Router"); + STray.AddIcon(); return 0; } LRESULT window::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - if(wParam == SC_MINIMIZE) - { - for(dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); - it != this->dlg_main->dialog_arrays.end(); - it++) + + if (wParam == SC_MINIMIZE) { + for (dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); + it != this->dlg_main->dialog_arrays.end(); + it++) { - for(dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); - jt != (*it)->dialog_controls.end(); - jt++) + for (dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); + jt != (*it)->dialog_controls.end(); + jt++) { (*jt)->set_display_name(false, true); } + } - } - else if(wParam == SC_RESTORE) - { - for(dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); - it != this->dlg_main->dialog_arrays.end(); - it++) + + this->ShowWindow(SW_HIDE); + bIsVisible = false; + return 0; + + } else if (wParam == SC_RESTORE) { + for (dialog_main::dialog_arrays_t::iterator it = this->dlg_main->dialog_arrays.begin(); + it != this->dlg_main->dialog_arrays.end(); + it++) { - for(dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); - jt != (*it)->dialog_controls.end(); - jt++) + for (dialog_array::dialog_controls_t::iterator jt = (*it)->dialog_controls.begin(); + jt != (*it)->dialog_controls.end(); + jt++) { (*jt)->set_display_name(false, false); } } + } else if (wParam == SC_CLOSE) { + this->ShowWindow(SW_HIDE); + bIsVisible = false; + return 0; } + bHandled = FALSE; return 0; } +LRESULT window::OnTrayNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled) +{ + if (trayIconMenu != NULL) { + DestroyMenu(trayIconMenu); + trayIconMenu = NULL; + } + + switch (LOWORD(lParam)) + { + case WM_LBUTTONUP: + if (bIsVisible) { + this->ShowWindow(SW_HIDE); + bIsVisible = false; + } + else { + this->ShowWindow(SW_SHOW); + this->BringWindowToTop(); + bIsVisible = true; + } + break; + case WM_RBUTTONUP: + trayIconMenu = CreatePopupMenu(); + + UINT menuFlags = MF_BYPOSITION | MF_STRING; + InsertMenuW(trayIconMenu, -1, menuFlags, ID_TRAYMENU_SHOWHIDE, _T("Show/hide")); + InsertMenuW(trayIconMenu, -1, menuFlags, ID_FILE_EXIT, _T("Exit")); + + POINT lpClickPoint; + GetCursorPos(&lpClickPoint); + + int nReserved = 0; + + TrackPopupMenu(trayIconMenu, + TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON, + lpClickPoint.x, lpClickPoint.y, + nReserved, this->m_hWnd, NULL + ); + break; + } + return 0; +} + LRESULT window::OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { - if(!this->dlg_main_b) + if (!this->dlg_main_b) { this->form_view->refresh_list(); } return 0; } - LRESULT window::OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { this->MessageBoxW( L"Audio Router version 0.10.2.\n" \ L"\nIf you come across any bugs(especially relating to routing or duplicating), " \ L"or just have an idea for a new feature, " \ - L"please send a PM to the developer on reddit: reddit.com/user/audiorouterdev/", + L"please send a PM to the developer on reddit: reddit.com/user/audiorouterdev/", L"About", MB_ICONINFORMATION); return 0; } - LRESULT window::OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { RECT rc; this->GetClientRect(&rc); - if(this->dlg_main_b) + if (this->dlg_main_b) { this->dlg_main->DestroyWindow(); delete this->dlg_main; @@ -100,8 +155,7 @@ LRESULT window::OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWnd this->m_hWndClient = this->form_view->Create(*this); //this->form_view->ShowWindow(SW_SHOW); this->form_view->SetWindowPos(NULL, &rc, SWP_NOZORDER | SWP_SHOWWINDOW); - } - else + } else { this->form_view->DestroyWindow(); @@ -119,4 +173,40 @@ LRESULT window::OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWnd LRESULT window::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { return HTCLOSE; -} \ No newline at end of file +} + +LRESULT window::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + PostQuitMessage(0); + return 0; +} + +LRESULT window::OnTrayMenuExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + if (trayIconMenu != NULL) { + DestroyMenu(trayIconMenu); + trayIconMenu = NULL; + } + + PostQuitMessage(0); + return 0; +} + +LRESULT window::OnTrayMenuShowHide(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + if (trayIconMenu != NULL) { + DestroyMenu(trayIconMenu); + trayIconMenu = NULL; + } + + if (bIsVisible) { + this->ShowWindow(SW_HIDE); + bIsVisible = false; + } + else { + this->ShowWindow(SW_SHOW); + this->BringWindowToTop(); + bIsVisible = true; + } + return 0; +} diff --git a/audio-router-gui/window.h b/audio-router-gui/window.h index 70d6b77..4b88719 100644 --- a/audio-router-gui/window.h +++ b/audio-router-gui/window.h @@ -6,6 +6,8 @@ #include "licensing.h" #include +#include "clsSysTray.h" + #define WIN_WIDTH 970//400 #define WIN_HEIGHT 670//360 #define GET(type, item) reinterpret_cast(this->GetDlgItem(item)) @@ -14,6 +16,10 @@ class window : public CFrameWindowImpl { private: bool dlg_main_b; + + clsSysTray STray; + BOOL bIsVisible; + public: dialog_main* dlg_main; formview* form_view; @@ -27,12 +33,16 @@ class window : public CFrameWindowImpl BEGIN_MSG_MAP(window) MESSAGE_HANDLER(WM_SYSCOMMAND, OnSysCommand) + MESSAGE_HANDLER(WM_TRAYNOTIFY, OnTrayNotify) MSG_WM_CREATE(OnCreate) /*MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest)*/ CHAIN_MSG_MAP(CFrameWindowImpl) COMMAND_ID_HANDLER(ID_FILE_REFRESHLIST, OnFileRefreshlist) COMMAND_ID_HANDLER(ID_ABOUT, OnAbout) COMMAND_ID_HANDLER(ID_FILE_SWITCHVIEW, OnFileSwitchview) + COMMAND_ID_HANDLER(ID_FILE_EXIT, OnFileExit) + COMMAND_ID_HANDLER(ID_TRAYMENU_SHOWHIDE, OnTrayMenuShowHide) + COMMAND_ID_HANDLER(ID_TRAYMENU_EXIT, OnTrayMenuExit) /*MSG_WM_NCHITTEST(OnNcHitTest)*/ END_MSG_MAP() @@ -40,6 +50,11 @@ class window : public CFrameWindowImpl LRESULT OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); LRESULT OnFileSwitchview(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnTrayMenuShowHide(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnTrayMenuExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT OnTrayNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + }; \ No newline at end of file diff --git a/audio-router/audio-router.vcxproj b/audio-router/audio-router.vcxproj index 9089c8e..aabfa08 100644 --- a/audio-router/audio-router.vcxproj +++ b/audio-router/audio-router.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -26,26 +26,26 @@ DynamicLibrary true - v120 + v141 Unicode DynamicLibrary true - v120 + v141 Unicode DynamicLibrary false - v120 + v141 true Unicode DynamicLibrary false - v120 + v141 true Unicode diff --git a/audio-router/patcher.h b/audio-router/patcher.h index a1c017d..78dd123 100644 --- a/audio-router/patcher.h +++ b/audio-router/patcher.h @@ -50,17 +50,17 @@ class patcher int is_patched() const { - if(IsBadReadPtr(this->original_func, sizeof(jmp_to))) + if (IsBadReadPtr(this->original_func, sizeof(jmp_to))) return 2; return (int)(memcmp(this->original_func, &this->old_bytes, sizeof(jmp_to)) != 0); } - const void* get_function() const {return this->original_func;} + const void* get_function() const { return this->original_func; } int patch(void* func_address) { - if(!func_address) + if (!func_address) return 1; //// patchable function must be 16 byte aligned to ensure atomic patching @@ -74,22 +74,22 @@ class patcher //#endif // assert(size >= sizeof(jmp_to)); // - if(!VirtualProtect(func_address, sizeof(jmp_to), PAGE_EXECUTE_READWRITE, &this->old_protect)) + if (!VirtualProtect(func_address, sizeof(jmp_to), PAGE_EXECUTE_READWRITE, &this->old_protect)) return 2; this->original_func = func_address; memcpy(&this->old_bytes, this->original_func, sizeof(jmp_to)); this->apply(); - + return 0; } - void lock() {EnterCriticalSection(&this->critical_section);} - void unlock() {LeaveCriticalSection(&this->critical_section);} + void lock() { EnterCriticalSection(&this->critical_section); } + void unlock() { LeaveCriticalSection(&this->critical_section); } void revert() { - if(IsBadWritePtr(this->original_func, sizeof(jmp_to))) + if (IsBadWritePtr(this->original_func, sizeof(jmp_to))) return; //if(this->patched) @@ -105,7 +105,7 @@ class patcher void apply() { - if(IsBadWritePtr(this->original_func, sizeof(jmp_to))) + if (IsBadWritePtr(this->original_func, sizeof(jmp_to))) return; //if(!this->patched) diff --git a/bootstrapper/bootstrapper.vcxproj b/bootstrapper/bootstrapper.vcxproj index eedcf5e..5ab541d 100644 --- a/bootstrapper/bootstrapper.vcxproj +++ b/bootstrapper/bootstrapper.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -32,26 +32,26 @@ DynamicLibrary true - v120 + v141 Unicode DynamicLibrary true - v120 + v141 Unicode DynamicLibrary false - v120 + v141 true Unicode DynamicLibrary false - v120 + v141 true Unicode diff --git a/bootstrapper/main.cpp b/bootstrapper/main.cpp index 98fb316..4bf89c6 100644 --- a/bootstrapper/main.cpp +++ b/bootstrapper/main.cpp @@ -241,7 +241,7 @@ NTSTATUS NTAPI ntcreateuserprocess_patch( DWORD mode = PIPE_READMODE_MESSAGE; SetNamedPipeHandleState(hpipe, &mode, NULL, NULL); // flag 2 indicates that bootstrapping is only injected - DWORD pid_tid_both[3] = {pid, tid, in_list ? 1 : 2}; + DWORD pid_tid_both[3] = {pid, tid, (DWORD)(in_list ? 1 : 2) }; DWORD exitcode, bytes_read; BOOL success = TransactNamedPipe( hpipe, pid_tid_both, sizeof(pid_tid_both), &exitcode, sizeof(exitcode), diff --git a/do/do.vcxproj b/do/do.vcxproj index 2bece19..dba3be8 100644 --- a/do/do.vcxproj +++ b/do/do.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -26,26 +26,26 @@ Application true - v120 + v141 Unicode Application true - v120 + v141 Unicode Application false - v120 + v141 true Unicode Application false - v120 + v141 true Unicode diff --git a/third-party/WTL90_4140_Final/Include/atlframe.h b/third-party/WTL90_4140_Final/Include/atlframe.h index 7d7acd5..18df933 100644 --- a/third-party/WTL90_4140_Final/Include/atlframe.h +++ b/third-party/WTL90_4140_Final/Include/atlframe.h @@ -987,7 +987,7 @@ class ATL_NO_VTABLE CFrameWindowImplBase : public ATL::CWindowImplBaseT< TBase, bool PrepareChevronMenu(_ChevronMenuInfo& cmi) { // get rebar and toolbar - REBARBANDINFO rbbi = { RunTimeHelper::SizeOf_REBARBANDINFO() }; + REBARBANDINFO rbbi = { (UINT)RunTimeHelper::SizeOf_REBARBANDINFO() }; rbbi.fMask = RBBIM_CHILD; BOOL bRet = (BOOL)::SendMessage(cmi.lpnm->hdr.hwndFrom, RB_GETBANDINFO, cmi.lpnm->uBand, (LPARAM)&rbbi); ATLASSERT(bRet); diff --git a/third-party/WTL90_4140_Final/Include/atlgdi.h b/third-party/WTL90_4140_Final/Include/atlgdi.h index 03aa076..eb7c9ed 100644 --- a/third-party/WTL90_4140_Final/Include/atlgdi.h +++ b/third-party/WTL90_4140_Final/Include/atlgdi.h @@ -467,28 +467,28 @@ class CLogFont : public LOGFONT #ifndef _WIN32_WCE void SetCaptionFont() { - NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + NONCLIENTMETRICS ncm = { (UINT)RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); Copy(&ncm.lfCaptionFont); } void SetMenuFont() { - NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + NONCLIENTMETRICS ncm = { (UINT)RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); Copy(&ncm.lfMenuFont); } void SetStatusFont() { - NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + NONCLIENTMETRICS ncm = { (UINT)RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); Copy(&ncm.lfStatusFont); } void SetMessageBoxFont() { - NONCLIENTMETRICS ncm = { RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; + NONCLIENTMETRICS ncm = { (UINT)RunTimeHelper::SizeOf_NONCLIENTMETRICS() }; ATLVERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0)); Copy(&ncm.lfMessageFont); } @@ -3680,8 +3680,8 @@ struct DIBINFO16 // a BITMAPINFO with 2 additional color bitfields DIBINFO16(SIZE size) { BITMAPINFOHEADER bmih = { sizeof(BITMAPINFOHEADER), size.cx, size.cy, - 1, 16, BI_BITFIELDS, 2 * size.cx * size.cy , 0, 0, 3 }; - DWORD dw[3] = DIBINFO16_BITFIELDS ; + 1, 16, (DWORD)BI_BITFIELDS, (DWORD)2 * size.cx * size.cy, 0, 0, 3 }; + DWORD dw[3] = DIBINFO16_BITFIELDS; bmiHeader = bmih; SecureHelper::memcpy_x(bmiColors, sizeof(bmiColors), dw, 3 * sizeof(DWORD));