Changeset 739db5a in nscp for modules/SysTray
- Timestamp:
- 09/27/08 19:06:35 (5 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 37e6081
- Parents:
- 9567d4b
- Location:
- modules/SysTray
- Files:
-
- 7 edited
-
SysTray-2005.vcproj (modified) (20 diffs)
-
SysTray.cpp (modified) (7 diffs)
-
SysTray.def (modified) (1 diff)
-
SysTray.h (modified) (2 diffs)
-
SysTray.rc (modified) (2 diffs)
-
TrayIcon.cpp (modified) (3 diffs)
-
res/standby.ico (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
modules/SysTray/SysTray-2005.vcproj
r6b690bf r739db5a 25 25 Name="Release|Win32" 26 26 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 27 IntermediateDirectory="$( ConfigurationName)"27 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 28 28 ConfigurationType="2" 29 29 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 66 66 <Tool 67 67 Name="VCLinkerTool" 68 OutputFile=" ../../Release/modules/$(ProjectName).dll"68 OutputFile="$(OutDir)\$(ProjectName).dll" 69 69 LinkIncremental="1" 70 70 ModuleDefinitionFile="SysTray.def" … … 104 104 Name="Release|x64" 105 105 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 106 IntermediateDirectory="$( PlatformName)\$(ConfigurationName)"106 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 107 107 ConfigurationType="2" 108 108 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 146 146 <Tool 147 147 Name="VCLinkerTool" 148 OutputFile=" ../../Release/modules/$(ProjectName).dll"148 OutputFile="$(OutDir)\$(ProjectName).dll" 149 149 LinkIncremental="1" 150 150 ModuleDefinitionFile="SysTray.def" … … 183 183 <Configuration 184 184 Name="Debug|Win32" 185 OutputDirectory="$( ConfigurationName)"186 IntermediateDirectory="$( ConfigurationName)"185 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 186 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 187 187 ConfigurationType="2" 188 188 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 228 228 <Tool 229 229 Name="VCLinkerTool" 230 OutputFile=" ../../Debug/modules/$(ProjectName).dll"230 OutputFile="$(OutDir)\$(ProjectName).dll" 231 231 ModuleDefinitionFile="SysTray.def" 232 232 GenerateDebugInformation="true" … … 261 261 <Configuration 262 262 Name="Debug|x64" 263 OutputDirectory="$( PlatformName)\$(ConfigurationName)"264 IntermediateDirectory="$( PlatformName)\$(ConfigurationName)"263 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 264 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 265 265 ConfigurationType="2" 266 266 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 307 307 <Tool 308 308 Name="VCLinkerTool" 309 OutputFile=" ../../Debug/modules/$(ProjectName).dll"309 OutputFile="$(OutDir)\$(ProjectName).dll" 310 310 ModuleDefinitionFile="SysTray.def" 311 311 GenerateDebugInformation="true" … … 340 340 <Configuration 341 341 Name="Distribution|Win32" 342 OutputDirectory="$( ConfigurationName)"343 IntermediateDirectory="$( ConfigurationName)"342 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 343 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 344 344 ConfigurationType="2" 345 345 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 382 382 <Tool 383 383 Name="VCLinkerTool" 384 OutputFile=" ../../Dist/modules/$(ProjectName).dll"384 OutputFile="$(OutDir)\$(ProjectName).dll" 385 385 LinkIncremental="1" 386 386 ModuleDefinitionFile="SysTray.def" … … 419 419 <Configuration 420 420 Name="Distribution|x64" 421 OutputDirectory="$( PlatformName)\$(ConfigurationName)"422 IntermediateDirectory="$( PlatformName)\$(ConfigurationName)"421 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 422 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 423 423 ConfigurationType="2" 424 424 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 462 462 <Tool 463 463 Name="VCLinkerTool" 464 OutputFile=" ../../Dist/modules/$(ProjectName).dll"464 OutputFile="$(OutDir)\$(ProjectName).dll" 465 465 LinkIncremental="1" 466 466 ModuleDefinitionFile="SysTray.def" … … 500 500 Name="Nightly|Win32" 501 501 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 502 IntermediateDirectory="$( ConfigurationName)"502 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 503 503 ConfigurationType="2" 504 504 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 539 539 <Tool 540 540 Name="VCLinkerTool" 541 OutputFile="$(OutDir)\$(ProjectName).dll" 541 542 LinkIncremental="1" 542 543 ModuleDefinitionFile="SysTray.def" … … 575 576 Name="Nightly|x64" 576 577 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 577 IntermediateDirectory="$( PlatformName)\$(ConfigurationName)"578 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 578 579 ConfigurationType="2" 579 580 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 615 616 <Tool 616 617 Name="VCLinkerTool" 618 OutputFile="$(OutDir)\$(ProjectName).dll" 617 619 LinkIncremental="1" 618 620 ModuleDefinitionFile="SysTray.def" … … 650 652 <Configuration 651 653 Name="Debug-MemCheck|Win32" 652 OutputDirectory="$( ConfigurationName)"653 IntermediateDirectory="$( ConfigurationName)"654 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 655 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 654 656 ConfigurationType="2" 655 657 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 695 697 <Tool 696 698 Name="VCLinkerTool" 697 OutputFile=" ../../Debug/modules/$(ProjectName).dll"699 OutputFile="$(OutDir)\$(ProjectName).dll" 698 700 ModuleDefinitionFile="SysTray.def" 699 701 GenerateDebugInformation="true" … … 728 730 <Configuration 729 731 Name="Debug-MemCheck|x64" 730 OutputDirectory="$( PlatformName)\$(ConfigurationName)"731 IntermediateDirectory="$( PlatformName)\$(ConfigurationName)"732 OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\modules" 733 IntermediateDirectory="$(SolutionDir)\tmp\$(PlatformName)\$(ConfigurationName)\$(ProjectName)" 732 734 ConfigurationType="2" 733 735 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" … … 774 776 <Tool 775 777 Name="VCLinkerTool" 776 OutputFile=" ../../Debug/modules/$(ProjectName).dll"778 OutputFile="$(OutDir)\$(ProjectName).dll" 777 779 ModuleDefinitionFile="SysTray.def" 778 780 GenerateDebugInformation="true" -
modules/SysTray/SysTray.cpp
r9567d4b r739db5a 24 24 #include <ServiceCmd.h> 25 25 #include <config.h> 26 #include <Winwlx.h> 27 #include <sysinfo.h> 26 28 27 29 SysTray gSysTray; … … 35 37 SysTray::SysTray() : icon(_T("SysTray")) {} 36 38 SysTray::~SysTray() {} 39 40 41 void SysTray::show() { 42 icon.createThread(); 43 } 44 37 45 bool SysTray::loadModule(NSCAPI::moduleLoadMode mode) { 38 46 if (mode == NSCAPI::normalStart) { 47 if (SETTINGS_GET_BOOL(settings_def::SHARED_SESSION)) { 48 NSC_LOG_ERROR(_T("You have enabled shared session, systray module will not load...")); 49 return true; 50 } 39 51 try { 40 52 if ((serviceControll::GetServiceType(SZSERVICENAME)&SERVICE_INTERACTIVE_PROCESS)!=SERVICE_INTERACTIVE_PROCESS) { … … 46 58 return true; 47 59 } 48 icon.createThread();60 show(); 49 61 } 50 62 return true; 51 63 } 52 bool SysTray::unloadModule() {64 void SysTray::hide() { 53 65 if (!icon.exitThread(20000)) { 54 66 std::wcout << _T("MAJOR ERROR: Could not unload thread...") << std::endl; 55 67 NSC_LOG_ERROR(_T("Could not exit the thread, memory leak and potential corruption may be the result...")); 56 return false; 68 } 69 } 70 bool SysTray::unloadModule() { 71 if (systemInfo::isBelowXP(systemInfo::getOSVersion())) { 72 hide(); 57 73 } 58 74 return true; … … 63 79 try { 64 80 serviceControll::ModifyServiceType(SZSERVICENAME, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS); 65 NSC_LOG_MESSAGE_STD(_T(MODULE_NAME) _T(" is now able to run as the SERVICE_INTERACTIVE_PROCESS flag has been set."));81 std::wcout << _T(MODULE_NAME) << _T(" is now able to run as the SERVICE_INTERACTIVE_PROCESS flag has been set.") << std::endl; 66 82 } catch (const serviceControll::SCException& e) { 67 NSC_LOG_ERROR_STD(_T("Could not modify service: ") + e.error_); 83 std::wcerr << _T("Could not modify service: ") << e.error_ << std::endl; 84 return -1; 85 } catch (...) { 86 std::wcerr << _T("Could not modify service: Unknown error!") << std::endl; 68 87 return -1; 69 88 } … … 71 90 try { 72 91 serviceControll::ModifyServiceType(SZSERVICENAME, SERVICE_WIN32_OWN_PROCESS); 73 NSC_LOG_MESSAGE_STD(_T(MODULE_NAME) _T(" is now not able to run as the SERVICE_INTERACTIVE_PROCESS flag has been reset."));92 std::wcout << _T(" is now not able to run as the SERVICE_INTERACTIVE_PROCESS flag has been reset.") << std::endl; 74 93 } catch (const serviceControll::SCException& e) { 75 NSC_LOG_ERROR_STD(_T("Could not modify service: ") + e.error_); 94 std::wcerr << _T("Could not modify service: ") << e.error_ << std::endl; 95 return -1; 96 } catch (...) { 97 std::wcerr << _T("Could not modify service: Unknown error!") << std::endl; 76 98 return -1; 77 99 } 78 100 } else { 79 NSC_LOG_ERROR_STD(_T("Undefined command, usage: install or uninstall"));101 std::wcerr << _T("Undefined command, usage: install or uninstall") << std::endl; 80 102 return -1; 81 103 } … … 108 130 hWnd = hLogWnd; 109 131 } else { 110 std::cout << "Damnit!!!" << std::endl;111 132 NSC_LOG_ERROR_STD(_T("Failed to get mutex in logger, message discarded")); 112 133 } … … 123 144 } 124 145 125 126 127 146 extern void ShowIcon() { 147 gSysTray.show(); 148 } 149 extern void HideIcon() { 150 gSysTray.hide(); 151 } 128 152 NSC_WRAPPERS_MAIN_DEF(gSysTray); 129 153 NSC_WRAPPERS_HANDLE_MSG_DEF(gSysTray); -
modules/SysTray/SysTray.def
r6817602 r739db5a 13 13 NSGetModuleDescription 14 14 NSCommandLineExec 15 ShowIcon 16 HideIcon -
modules/SysTray/SysTray.h
r9567d4b r739db5a 26 26 NSC_WRAPPERS_MAIN(); 27 27 NSC_WRAPPERS_CLI(); 28 28 29 29 30 … … 56 57 bool unloadModule(); 57 58 void setLogWindow(HWND hWnd); 59 void show(); 60 void hide(); 58 61 59 62 std::wstring getModuleName() { -
modules/SysTray/SysTray.rc
rde8ef76 r739db5a 95 95 POPUP "POPUP" 96 96 BEGIN 97 MENUITEM "NSClient++", ID_POPUP_NSCLIENT, INACTIVE97 MENUITEM "NSClient++", ID_POPUP_NSCLIENT, INACTIVE 98 98 MENUITEM SEPARATOR 99 MENUITEM " Inject Command",ID_POPUP_INJECTCOMMAND100 MENUITEM "S top Service", ID_POPUP_STOPSERVICE99 MENUITEM "Run &Command", ID_POPUP_INJECTCOMMAND 100 MENUITEM "Show &Log", ID_POPUP_SHOWLOG 101 101 MENUITEM SEPARATOR 102 MENUITEM " Show Log", ID_POPUP_SHOWLOG102 MENUITEM "&Close", ID_POPUP_STOPSERVICE 103 103 END 104 104 END … … 225 225 ///////////////////////////////////////////////////////////////////////////// 226 226 #endif // not APSTUDIO_INVOKED 227 -
modules/SysTray/TrayIcon.cpp
r6d3bbc1 r739db5a 39 39 } 40 40 41 #ifdef WINVER < 0x0600 42 #define MSGFLT_ADD 1 43 #define MSGFLT_REMOVE 2 44 typedef BOOL (WINAPI *LPFN_CHANGEWINDOWMESSAGEFILTER) (UINT, DWORD); 45 #endif 46 47 LPFN_CHANGEWINDOWMESSAGEFILTER fnChangeWindowMessageFilter = NULL; 48 BOOL ChangeWindowMessageFilter_(UINT message, DWORD what) 49 { 50 if (fnChangeWindowMessageFilter == NULL) 51 fnChangeWindowMessageFilter = (LPFN_CHANGEWINDOWMESSAGEFILTER)GetProcAddress(GetModuleHandle(TEXT("user32")),"ChangeWindowMessageFilter"); 52 if (fnChangeWindowMessageFilter == NULL) { 53 NSC_DEBUG_MSG(_T("Failed to load: ChangeWindowMessageFilter aparently we are not on Vista...")); 54 return true; 55 } 56 NSC_DEBUG_MSG(_T("Chaning window message filters...")); 57 return fnChangeWindowMessageFilter(message,what); 58 } 59 60 void test() { 61 /* error 62 WTSQueryUserToken(dwSessionId, &hToken); 63 DuplicateTokenEx(hTokenNew,MAXIMUM_ALLOWED,NULL,SecurityIdentification,TokenPrimary,&hTokenDup); 64 */ 65 /* 66 HANDLE hToken = NULL, hTokenDup = NULL; 67 HMODULE hmod = LoadLibrary("kernel32.dll"); 68 WTSGETACTIVECONSOLESESSIONID lpfnWTSGetActiveConsoleSessionId = (WTSGETACTIVECONSOLESESSIONID)GetProcAddress(hmod,"WTSGetActiveConsoleSessionId"); 69 DWORD dwSessionId = lpfnWTSGetActiveConsoleSessionId(); 70 WTSQueryUserToken(dwSessionId, &hToken); 71 //DuplicateTokenEx(hTokenNew,MAXIMUM_ALLOWED,NULL,SecurityIdentification,TokenPrimary,&hTokenDup); 72 // 73 WriteToLog("Calling lpfnCreateEnvironmentBlock"); 74 ZeroMemory( &si, sizeof( STARTUPINFO ) ); 75 si.cb = sizeof( STARTUPINFO ); 76 si.lpDesktop = "winsta0\\default"; 77 78 79 LPVOID pEnv = NULL; 80 DWORD dwCreationFlag = NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE; 81 HMODULE hModule = LoadLibrary("Userenv.dll"); 82 if(hModule ) 83 { 84 LPFN_CreateEnvironmentBlock lpfnCreateEnvironmentBlock = (LPFN_CreateEnvironmentBlock)GetProcAddress( hModule, "CreateEnvironmentBlock" ); 85 if( lpfnCreateEnvironmentBlock != NULL ) 86 { 87 if(lpfnCreateEnvironmentBlock(&pEnv, hTokenDup, FALSE)) 88 { 89 WriteToLog("CreateEnvironmentBlock Ok"); 90 dwCreationFlag |= CREATE_UNICODE_ENVIRONMENT; 91 } 92 else 93 { 94 pEnv = NULL; 95 } 96 } 97 } 98 // 99 ZeroMemory( &pi,sizeof(pi)); 100 101 if ( !CreateProcessAsUser( 102 hTokenDup, 103 NULL, 104 ( char * )pszCmd, 105 NULL, 106 NULL, 107 FALSE, 108 dwCreationFlag, 109 pEnv, 110 NULL, 111 &si, 112 &pi 113 ) ) 114 { 115 116 goto RESTORE; 117 } 118 */ 119 120 } 41 121 42 122 void IconWidget_::createDialog(void) { … … 46 126 if (UDM_TASKBARCREATED == 0) { 47 127 NSC_LOG_ERROR_STD(_T("Failed to register 'TaskbarCreated': ") + error::lookup::last_error()); 128 } 129 if (!ChangeWindowMessageFilter_(UDM_TASKBARCREATED, MSGFLT_ADD)) { 130 NSC_LOG_ERROR_STD(_T("Failed to cchange window filter: ") + error::lookup::last_error()); 48 131 } 49 132 … … 301 384 switch (cmd) { 302 385 case ID_POPUP_STOPSERVICE: 303 NSCModuleHelper:: StopService();386 NSCModuleHelper::Exit(); 304 387 break; 305 388 case ID_POPUP_INJECTCOMMAND:
Note: See TracChangeset
for help on using the changeset viewer.








