Files
mirror-processhacker/2.x/trunk/plugins/Updater/main.c
T
dmex 9289bca9b7 Updater: Fixed some string leaks
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4713 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2011-09-25 01:45:10 +00:00

127 lines
3.7 KiB
C

/*
* Process Hacker Update Checker -
* main program
*
* Copyright (C) 2011 dmex
*
* This file is part of Process Hacker.
*
* Process Hacker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Process Hacker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*x
* You should have received a copy of the GNU General Public License
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
*/
#include "updater.h"
LOGICAL DllMain(
__in HINSTANCE Instance,
__in ULONG Reason,
__reserved PVOID Reserved
)
{
static PH_SETTING_CREATE settings[] =
{
{ IntegerSettingType, L"ProcessHacker.Updater.EnableCache", L"1" },
{ IntegerSettingType, L"ProcessHacker.Updater.HashAlgorithm", L"1" },
{ IntegerSettingType, L"ProcessHacker.Updater.PromptStart", L"1" },
};
switch (Reason)
{
case DLL_PROCESS_ATTACH:
{
PPH_PLUGIN_INFORMATION info;
PluginInstance = PhRegisterPlugin(L"ProcessHacker.UpdateChecker", Instance, &info);
if (!PluginInstance)
return FALSE;
info->DisplayName = L"Update Checker";
info->Author = L"dmex";
info->Description = L"Adds the ability to check for new Process Hacker releases via the Help menu.";
info->Url = L"http://processhacker.sf.net/forums/viewtopic.php?f=18&t=273";
info->HasOptions = TRUE;
PhRegisterCallback(
PhGetGeneralCallback(GeneralCallbackMainWindowShowing),
MainWindowShowingCallback,
NULL,
&MainWindowShowingCallbackRegistration
);
PhRegisterCallback(
PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem),
MenuItemCallback,
NULL,
&PluginMenuItemCallbackRegistration
);
PhRegisterCallback(
PhGetPluginCallback(PluginInstance, PluginCallbackShowOptions),
ShowOptionsCallback,
NULL,
&PluginShowOptionsCallbackRegistration
);
PhAddSettings(settings, sizeof(settings) / sizeof(PH_SETTING_CREATE));
}
break;
}
return TRUE;
}
VOID NTAPI MainWindowShowingCallback(
__in_opt PVOID Parameter,
__in_opt PVOID Context
)
{
// Add our menu item, 4 = Help menu.
PhPluginAddMenuItem(PluginInstance, 4, NULL, UPDATE_MENUITEM, L"Check for Updates", NULL);
if (PhGetIntegerSetting(L"ProcessHacker.Updater.PromptStart"))
{
StartInitialCheck();
}
}
VOID NTAPI MenuItemCallback(
__in_opt PVOID Parameter,
__in_opt PVOID Context
)
{
PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter;
if (menuItem != NULL)
{
switch (menuItem->Id)
{
case UPDATE_MENUITEM:
{
ShowUpdateDialog();
}
break;
}
}
}
VOID NTAPI ShowOptionsCallback(
__in_opt PVOID Parameter,
__in_opt PVOID Context
)
{
DialogBox(
(HINSTANCE)PluginInstance->DllBase,
MAKEINTRESOURCE(IDD_OPTIONS),
(HWND)Parameter,
OptionsDlgProc
);
}