Initial commit

This commit is contained in:
coddec
2017-12-04 13:27:18 +11:00
commit f6150dafc8
1282 changed files with 193271 additions and 0 deletions
@@ -0,0 +1,367 @@
// StartMenuExt.cpp : Implementation of CStartMenuExt
#include "stdafx.h"
#include "StartMenuExt.h"
#include "dllmain.h"
#include "StringUtils.h"
#include "Translations.h"
#include "Settings.h"
#include "ComHelper.h"
#include "FileHelper.h"
#include <propvarutil.h>
#include <propkey.h>
#include <vector>
#define PIN_VERB "pin_classic"
// CStartMenuExt
static CLIPFORMAT s_ShellFormat;
#define GetPIDLFolder(pida) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[0])
#define GetPIDLItem(pida, i) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[i+1])
// FOLDERID_AppsFolder is defined in the 8.0 SDK, but we don't want to require it
KNOWNFOLDERID FOLDERID_AppsFolder2={0x1E87508D,0x89C2,0x42F0,{0x8A,0x7E,0x64,0x5A,0x0F,0x50,0xCA,0x58}}; // similar to shell:::{4234d49b-0245-4df3-b780-3893943456e1}
static HRESULT CreateLink( const wchar_t *source, LPITEMIDLIST sourcePidl, const wchar_t *dir, const wchar_t *fname )
{
HRESULT hr;
{
CComPtr<IShellLink> pLink;
hr=pLink.CoCreateInstance(CLSID_ShellLink);
if (FAILED(hr)) return hr;
if (sourcePidl)
hr=pLink->SetIDList(sourcePidl);
else
hr=pLink->SetPath(source);
if (FAILED(hr)) return hr;
if (dir)
pLink->SetWorkingDirectory(dir);
CComQIPtr<IPersistFile> pFile=pLink;
if (!pFile) return E_FAIL;
hr=pFile->Save(fname,TRUE);
}
{
// reopen the link and set the "no new" property. without reopening the original properties are lost
CComPtr<IShellLink> pLink;
hr=pLink.CoCreateInstance(CLSID_ShellLink);
CComQIPtr<IPersistFile> pFile=pLink;
hr=pFile->Load(fname,STGM_READWRITE);
CComQIPtr<IPropertyStore> pStore=pLink;
if (pStore)
{
PROPVARIANT val;
InitPropVariantFromBoolean(TRUE,&val);
pStore->SetValue(PKEY_AppUserModel_ExcludeFromShowInNewInstall,val);
PropVariantClear(&val);
pStore->Commit();
}
hr=pFile->Save(fname,TRUE);
}
HANDLE h=CreateFile(fname,GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if (h!=INVALID_HANDLE_VALUE)
{
FILETIME curTime;
GetSystemTimeAsFileTime(&curTime);
SetFileTime(h,&curTime,&curTime,&curTime);
CloseHandle(h);
}
return S_OK;
}
HRESULT WINAPI CStartMenuExt::UpdateRegistry( BOOL bRegister )
{
return _AtlModule.UpdateRegistryFromResource(IDR_STARTMENUEXT,bRegister);
}
STDMETHODIMP CStartMenuExt::Initialize( PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pData, HKEY hkey )
{
WaitDllInitThread();
LoadSettings();
s_ShellFormat=RegisterClipboardFormat(CFSTR_SHELLIDLIST);
if (GetSettingBool(L"DisablePinExt"))
return E_FAIL;
bool bUsePinned;
bool bDef;
int setting=GetSettingInt(L"PinnedPrograms",bDef);
if (bDef)
bUsePinned=(GetSettingInt(L"MenuStyle")==2); // pinned is default in Win7 style
else
bUsePinned=(setting==1);
if (bUsePinned)
{
Strcpy(m_PinFolder1,_countof(m_PinFolder1),L"%APPDATA%\\ClassicShell\\Pinned\\");
DoEnvironmentSubst(m_PinFolder1,_countof(m_PinFolder1));
m_PinFolder2[0]=0;
}
else
{
CString str=GetSettingString(L"FolderStartMenu");
if (!str.IsEmpty())
{
Sprintf(m_PinFolder1,_countof(m_PinFolder1),L"%s\\",str);
DoEnvironmentSubst(m_PinFolder1,_countof(m_PinFolder1));
}
else
{
CComString pPath;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_StartMenu,0,NULL,&pPath)))
Sprintf(m_PinFolder1,_countof(m_PinFolder1),L"%s\\",pPath);
}
str=GetSettingString(L"FolderCommonStartMenu");
if (!str.IsEmpty())
{
Sprintf(m_PinFolder2,_countof(m_PinFolder2),L"%s\\",str);
DoEnvironmentSubst(m_PinFolder2,_countof(m_PinFolder2));
}
else
{
CComString pPath;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_CommonStartMenu,0,NULL,&pPath)))
Sprintf(m_PinFolder2,_countof(m_PinFolder2),L"%s\\",pPath);
}
}
FORMATETC fmt1={CF_HDROP,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
FORMATETC fmt2={s_ShellFormat,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
STGMEDIUM stg={TYMED_HGLOBAL};
if (pData && SUCCEEDED(pData->GetData(&fmt1,&stg)))
{
HDROP hDrop=(HDROP)GlobalLock(stg.hGlobal);
if (hDrop)
{
if (DragQueryFile(hDrop,0xFFFFFFFF,NULL,0)==1)
{
DragQueryFile(hDrop,0,m_FileName,_countof(m_FileName));
const wchar_t *fname=PathFindFileName(m_FileName);
m_bInPinFolder1=(fname-m_FileName==Strlen(m_PinFolder1) && _wcsnicmp(m_PinFolder1,m_FileName,(fname-m_FileName))==0);
m_bInPinFolder2=(m_PinFolder2[0] && fname-m_FileName==Strlen(m_PinFolder2) && _wcsnicmp(m_PinFolder2,m_FileName,(fname-m_FileName))==0);
GlobalUnlock(stg.hGlobal);
ReleaseStgMedium(&stg);
return S_OK;
}
GlobalUnlock(stg.hGlobal);
}
ReleaseStgMedium(&stg);
}
else if (pData && SUCCEEDED(pData->GetData(&fmt2,&stg)))
{
CIDA *pIda=(CIDA*)GlobalLock(stg.hGlobal);
if (pIda)
{
if (pIda->cidl==1)
{
LPCITEMIDLIST folderPidl=GetPIDLFolder(pIda);
LPCITEMIDLIST itemPidl=GetPIDLItem(pIda,0);
m_bInPinFolder1=m_bInPinFolder2=false;
LPITEMIDLIST appsFolder;
if (SUCCEEDED(SHGetKnownFolderIDList(FOLDERID_AppsFolder2,0,NULL,&appsFolder)) && ILIsEqual(folderPidl,appsFolder))
m_FilePidl=ILCombine(folderPidl,itemPidl);
GlobalUnlock(stg.hGlobal);
ReleaseStgMedium(&stg);
return m_FilePidl?S_OK:E_INVALIDARG;
}
GlobalUnlock(stg.hGlobal);
}
ReleaseStgMedium(&stg);
}
return E_INVALIDARG;
}
STDMETHODIMP CStartMenuExt::QueryContextMenu( HMENU menu, UINT uMenuIndex, UINT uidFirstCmd, UINT uidLastCmd, UINT uFlags )
{
if (uFlags&(CMF_DEFAULTONLY|CMF_VERBSONLY))
return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0);
if (m_bInPinFolder2)
return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0); // can't unpin from common folder
bool bDirectory=(PathIsDirectory(m_FileName)!=FALSE);
bool bFakeDirectory=bDirectory && IsFakeFolder(m_FileName);
const wchar_t *ext=PathFindExtension(m_FileName);
if (bDirectory || m_FilePidl || _wcsicmp(ext,L".exe")==0 || _wcsicmp(ext,L".lnk")==0)
{
if (m_bInPinFolder1)
{
if (!bFakeDirectory && _wcsicmp(ext,L".lnk")!=0)
return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0); // can only unpin fake folders and links
InsertMenu(menu,uMenuIndex,MF_BYPOSITION,uidFirstCmd,FindTranslation(L"Menu.UnpinStartCs",L"Unpin from Start menu (Classic Shell)"));
}
else
{
if (bFakeDirectory)
return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0); // can't pin fake folders
InsertMenu(menu,uMenuIndex,MF_BYPOSITION,uidFirstCmd,FindTranslation(L"Menu.PinStartCs",L"Pin to Start menu (Classic Shell)"));
}
return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,1);
}
return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0);
}
static CString GetFileDescription( const wchar_t *fname )
{
DWORD q;
DWORD size=GetFileVersionInfoSizeEx(FILE_VER_GET_LOCALISED|FILE_VER_GET_NEUTRAL,fname,&q);
if (size)
{
std::vector<char> buf(size);
if (GetFileVersionInfoEx(FILE_VER_GET_LOCALISED|FILE_VER_GET_NEUTRAL,fname,0,size,&buf[0]))
{
wchar_t languages[100];
size=0;
DWORD len=_countof(languages);
GetUserPreferredUILanguages(MUI_LANGUAGE_ID,&size,languages,&len);
for (const wchar_t *lang=languages;*lang;lang+=Strlen(lang)+1)
{
wchar_t key[100];
Sprintf(key,_countof(key),L"\\StringFileInfo\\%s%04X\\FileDescription",lang,1200);
const wchar_t *text=NULL;
UINT q;
if (VerQueryValue(&buf[0],key,(void**)&text,&q))
return text;
}
DWORD *langs;
UINT count;
if (VerQueryValue(&buf[0],L"\\VarFileInfo\\Translation",(void**)&langs,&count))
{
count/=4;
for (DWORD i=0;i<count;i++)
{
if (HIWORD(langs[i])==1200)
{
wchar_t key[100];
Sprintf(key,_countof(key),L"\\StringFileInfo\\%04X%04X\\FileDescription",LOWORD(langs[i]),1200);
const wchar_t *text=NULL;
UINT q;
if (VerQueryValue(&buf[0],key,(void**)&text,&q))
return text;
}
}
}
}
}
return CString();
}
STDMETHODIMP CStartMenuExt::InvokeCommand( CMINVOKECOMMANDINFO *pInfo )
{
if (pInfo->lpVerb==NULL || (!IS_INTRESOURCE(pInfo->lpVerb) && strcmp(pInfo->lpVerb,PIN_VERB)==0))
{
bool bDirectory=(*m_FileName && PathIsDirectory(m_FileName)!=FALSE);
bool bFakeDirectory=bDirectory && IsFakeFolder(m_FileName);
const wchar_t *fname=PathFindFileName(m_FileName);
const wchar_t *ext=PathFindExtension(fname);
if (m_bInPinFolder1)
{
// the file is in the user pin folder - unpin
if (!bFakeDirectory && _wcsicmp(ext,L".lnk")!=0)
return E_FAIL; // can only unpin fake folders and links
if (bFakeDirectory)
DeleteFakeFolder(m_FileName);
else
{
SetFileAttributes(m_FileName,GetFileAttributes(m_FileName)&~FILE_ATTRIBUTE_READONLY);
DeleteFile(m_FileName);
}
}
else if (!m_bInPinFolder2)
{
// the file is not in any pin folder - pin
if (bFakeDirectory)
return E_FAIL; // can't pin fake folders
wchar_t locName[_MAX_PATH];
int locIndex;
bool bHasLocName=(*m_FileName && SHGetLocalizedName(m_FileName,locName,_countof(locName),&locIndex)==S_OK);
wchar_t finalPath[_MAX_PATH];
bool res=false;
if (bDirectory)
{
int len=Strlen(fname);
while (len>0 && (fname[len-1]=='\\' || fname[len-1]==':'))
len--;
wchar_t path[_MAX_PATH];
Sprintf(path,_countof(path),L"%s%.*s",m_PinFolder1,len,fname);
PathYetAnotherMakeUniqueName(finalPath,path,NULL,PathFindFileName(path));
res=CreateFakeFolder(m_FileName,finalPath);
}
else
{
wchar_t name[_MAX_FNAME];
name[0]=0;
if (m_FilePidl)
{
CComPtr<IShellItem> pItem;
SHCreateItemFromIDList(m_FilePidl,IID_IShellItem,(void**)&pItem);
if (pItem)
{
wchar_t *pName;
if (SUCCEEDED(pItem->GetDisplayName(SIGDN_NORMALDISPLAY,&pName)))
{
Strcpy(name,_countof(name),pName);
CoTaskMemFree(pName);
}
}
}
else if (_wcsicmp(ext,L".exe")==0 && !bHasLocName)
{
CString desc=GetFileDescription(m_FileName);
Strcpy(name,_countof(name),desc);
}
if (!name[0])
{
memcpy(name,fname,(ext-fname)*2);
name[ext-fname]=0;
}
wchar_t path[_MAX_PATH];
Sprintf(path,_countof(path),L"%s%s.lnk",m_PinFolder1,name);
PathYetAnotherMakeUniqueName(finalPath,path,NULL,PathFindFileName(path));
if (m_FilePidl)
{
res=SUCCEEDED(CreateLink(NULL,m_FilePidl,NULL,finalPath));
}
else if (_wcsicmp(ext,L".lnk")==0)
{
res=SUCCEEDED(CreateLink(m_FileName,NULL,NULL,finalPath));
}
else
{
wchar_t dir[_MAX_PATH];
Strcpy(dir,_countof(dir),m_FileName);
PathRemoveFileSpec(dir);
res=SUCCEEDED(CreateLink(m_FileName,NULL,dir,finalPath));
}
}
if (!res)
return E_FAIL;
if (bHasLocName)
{
SHSetLocalizedName(finalPath,locName,locIndex);
}
}
return S_OK;
}
return E_FAIL;
}
STDMETHODIMP CStartMenuExt::GetCommandString( UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax )
{
if (idCmd==0)
{
if (uFlags==GCS_VERBA)
{
Strcpy(pszName,cchMax,PIN_VERB);
return S_OK;
}
return E_NOTIMPL;
}
return E_INVALIDARG;
}
@@ -0,0 +1,65 @@
// StartMenuExt.h : Declaration of the CStartMenuExt
#pragma once
#include "resource.h" // main symbols
#include "StartMenuHelper_i.h"
#include <shlobj.h>
// CStartMenuExt
class ATL_NO_VTABLE CStartMenuExt :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CStartMenuExt, &CLSID_StartMenuExt>,
public IShellExtInit,
public IContextMenu
{
public:
CStartMenuExt()
{
m_PinFolder1[0]=m_PinFolder2[0]=m_FileName[0]=0;
m_bInPinFolder1=m_bInPinFolder2=false;
}
static HRESULT WINAPI UpdateRegistry( BOOL bRegister );
DECLARE_NOT_AGGREGATABLE(CStartMenuExt)
BEGIN_COM_MAP(CStartMenuExt)
COM_INTERFACE_ENTRY(IShellExtInit)
COM_INTERFACE_ENTRY(IContextMenu)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
m_FilePidl=NULL;
return S_OK;
}
void FinalRelease()
{
if (m_FilePidl) ILFree(m_FilePidl);
m_FilePidl=NULL;
}
// from IShellExtInit
STDMETHODIMP Initialize( PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pData, HKEY hkey );
// from IContextMenu
STDMETHODIMP QueryContextMenu(HMENU, UINT, UINT, UINT, UINT);
STDMETHODIMP InvokeCommand( CMINVOKECOMMANDINFO *pInfo );
STDMETHODIMP GetCommandString( UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax );
wchar_t m_PinFolder1[_MAX_PATH]; // ending with \
wchar_t m_PinFolder2[_MAX_PATH]; // ending with \
wchar_t m_FileName[_MAX_PATH];
LPITEMIDLIST m_FilePidl;
bool m_bInPinFolder1, m_bInPinFolder2;
};
OBJECT_ENTRY_AUTO(__uuidof(StartMenuExt), CStartMenuExt)
@@ -0,0 +1,54 @@
HKCR
{
NoRemove CLSID
{
ForceRemove {E595F05F-903F-4318-8B0A-7F633B520D2B} = s 'StartMenuExt'
{
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
}
ForceRemove {D3214FBB-3CA1-406A-B3E8-3EB7C393A15E} = s 'StartMenuEmulation'
{
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
}
}
}
HKCR
{
NoRemove exefile
{
NoRemove ShellEx
{
NoRemove ContextMenuHandlers
{
ForceRemove StartMenuExt = s '{E595F05F-903F-4318-8B0A-7F633B520D2B}'
}
}
}
NoRemove lnkfile
{
NoRemove ShellEx
{
NoRemove ContextMenuHandlers
{
ForceRemove StartMenuExt = s '{E595F05F-903F-4318-8B0A-7F633B520D2B}'
}
}
}
NoRemove Folder
{
NoRemove ShellEx
{
NoRemove ContextMenuHandlers
{
ForceRemove StartMenuExt = s '{E595F05F-903F-4318-8B0A-7F633B520D2B}'
}
}
}
}
@@ -0,0 +1,388 @@
// StartMenuHelper.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include "StartMenuHelper_i.h"
#include "dllmain.h"
#include "ResourceHelper.h"
#include "Settings.h"
#include "StringUtils.h"
#include "..\ClassicStartMenuDLL\LogManager.h"
#include <AccCtrl.h>
#include <Aclapi.h>
#include <Taskschd.h>
//#define EXPLORER_CLSID L"{c71c41f1-ddad-42dc-a8fc-f5bfc61df957}"
//const CLSID g_ExplorerClsid= {0xC71C41F1, 0xDDAD, 0x42DC, {0xA8, 0xFC, 0xF5, 0xBF, 0xC6, 0x1D, 0xF9, 0x57}};
//#define EXPLORER_DLL L"twinui.dll"
#define EXPLORER_CLSID L"{ECD4FC4D-521C-11D0-B792-00A0C90312E1}"
const CLSID g_ExplorerClsid= {0xECD4FC4D, 0x521C, 0x11D0, {0xB7, 0x92, 0x00, 0xA0, 0xC9, 0x03, 0x12, 0xE1}};
#define EXPLORER_DLL L"explorerframe.dll"
#define EMULATION_CLSID L"{D3214FBB-3CA1-406a-B3E8-3EB7C393A15E}"
const CLSID g_EmulationClsid= {0xD3214FBB, 0x3CA1, 0x406A, {0xB3, 0xE8, 0x3E, 0xB7, 0xC3, 0x93, 0xA1, 0x5E}};
#define EMULATION_KEY L"TreatAs"
static void AdjustPrivileges( void )
{
HANDLE hToken;
if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
{
{
TOKEN_PRIVILEGES tp={1};
if (LookupPrivilegeValue(NULL,L"SeBackupPrivilege",&tp.Privileges[0].Luid))
tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),NULL,NULL);
}
{
TOKEN_PRIVILEGES tp={1};
if (LookupPrivilegeValue(NULL,L"SeRestorePrivilege",&tp.Privileges[0].Luid))
tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),NULL,NULL);
}
CloseHandle(hToken);
}
}
static void AddRegistryKeys( bool bPin )
{
AdjustPrivileges();
PSID pEveryoneSID=NULL, pAdminSID=NULL;
// Create a well-known SID for the Everyone group.
SID_IDENTIFIER_AUTHORITY SIDAuthWorld=SECURITY_WORLD_SID_AUTHORITY;
if (!AllocateAndInitializeSid(&SIDAuthWorld,1,SECURITY_WORLD_RID,0,0,0,0,0,0,0,&pEveryoneSID))
return;
// Create a SID for the BUILTIN\Administrators group.
SID_IDENTIFIER_AUTHORITY SIDAuthNT=SECURITY_NT_AUTHORITY;
if (!AllocateAndInitializeSid(&SIDAuthNT,2,SECURITY_BUILTIN_DOMAIN_RID,DOMAIN_ALIAS_RID_ADMINS,0,0,0,0,0,0,&pAdminSID))
{
if (pEveryoneSID) FreeSid(pEveryoneSID);
}
EXPLICIT_ACCESS ea[2];
memset(&ea,0,sizeof(ea));
// Initialize an EXPLICIT_ACCESS structure for an ACE.
// The ACE will allow Everyone read access to the key.
ea[0].grfAccessPermissions=KEY_READ;
ea[0].grfAccessMode=SET_ACCESS;
ea[0].grfInheritance=NO_INHERITANCE;
ea[0].Trustee.TrusteeForm=TRUSTEE_IS_SID;
ea[0].Trustee.TrusteeType=TRUSTEE_IS_WELL_KNOWN_GROUP;
ea[0].Trustee.ptstrName=(LPTSTR)pEveryoneSID;
// Initialize an EXPLICIT_ACCESS structure for an ACE.
// The ACE will allow the Administrators group full access to
// the key.
ea[1].grfAccessPermissions=KEY_ALL_ACCESS;
ea[1].grfAccessMode=SET_ACCESS;
ea[1].grfInheritance=NO_INHERITANCE;
ea[1].Trustee.TrusteeForm=TRUSTEE_IS_SID;
ea[1].Trustee.TrusteeType=TRUSTEE_IS_GROUP;
ea[1].Trustee.ptstrName=(LPTSTR)pAdminSID;
// Create a new ACL that contains the new ACEs.
PACL pACL=NULL;
if (SetEntriesInAcl(2,ea,NULL,&pACL)==ERROR_SUCCESS)
{
char buf[SECURITY_DESCRIPTOR_MIN_LENGTH];
SECURITY_DESCRIPTOR *psd=(SECURITY_DESCRIPTOR*)buf;
if (InitializeSecurityDescriptor(psd,SECURITY_DESCRIPTOR_REVISION))
{
if (SetSecurityDescriptorDacl(psd,TRUE,pACL,FALSE))
{
SECURITY_ATTRIBUTES sa={sizeof(sa),psd};
HKEY hkey=NULL;
if (RegCreateKeyEx(HKEY_CLASSES_ROOT,L"CLSID\\" EXPLORER_CLSID L"\\" EMULATION_KEY,NULL,NULL,REG_OPTION_BACKUP_RESTORE,KEY_WRITE,&sa,&hkey,NULL)==ERROR_SUCCESS)
{
wchar_t val[]=EMULATION_CLSID;
RegSetValueEx(hkey,NULL,NULL,REG_SZ,(BYTE*)val,sizeof(val));
RegCloseKey(hkey);
}
hkey=NULL;
if (bPin)
{
if (RegCreateKeyEx(HKEY_CLASSES_ROOT,L"Launcher.ImmersiveApplication\\ShellEx\\ContextMenuHandlers\\StartMenuExt",NULL,NULL,REG_OPTION_BACKUP_RESTORE,KEY_WRITE,&sa,&hkey,NULL)==ERROR_SUCCESS)
{
wchar_t val[]=L"{E595F05F-903F-4318-8B0A-7F633B520D2B}";
RegSetValueEx(hkey,NULL,NULL,REG_SZ,(BYTE*)val,sizeof(val));
RegCloseKey(hkey);
}
if (RegCreateKeyEx(HKEY_CLASSES_ROOT,L"Launcher.SystemSettings\\ShellEx\\ContextMenuHandlers\\StartMenuExt",NULL,NULL,REG_OPTION_BACKUP_RESTORE,KEY_WRITE,&sa,&hkey,NULL)==ERROR_SUCCESS)
{
wchar_t val[]=L"{E595F05F-903F-4318-8B0A-7F633B520D2B}";
RegSetValueEx(hkey,NULL,NULL,REG_SZ,(BYTE*)val,sizeof(val));
RegCloseKey(hkey);
}
}
}
}
LocalFree(pACL);
}
FreeSid(pEveryoneSID);
FreeSid(pAdminSID);
}
static void RemoveRegistryKeys( bool bPin )
{
AdjustPrivileges();
HKEY hkey=NULL;
if (RegCreateKeyEx(HKEY_CLASSES_ROOT,L"CLSID\\" EXPLORER_CLSID,NULL,NULL,REG_OPTION_BACKUP_RESTORE,KEY_WRITE|DELETE,NULL,&hkey,NULL)==ERROR_SUCCESS)
{
RegDeleteTree(hkey,EMULATION_KEY);
RegCloseKey(hkey);
}
hkey=NULL;
if (bPin)
{
if (RegCreateKeyEx(HKEY_CLASSES_ROOT,L"Launcher.ImmersiveApplication\\ShellEx\\ContextMenuHandlers",NULL,NULL,REG_OPTION_BACKUP_RESTORE,KEY_WRITE|DELETE,NULL,&hkey,NULL)==ERROR_SUCCESS)
{
RegDeleteTree(hkey,L"StartMenuExt");
RegCloseKey(hkey);
}
if (RegCreateKeyEx(HKEY_CLASSES_ROOT,L"Launcher.SystemSettings\\ShellEx\\ContextMenuHandlers",NULL,NULL,REG_OPTION_BACKUP_RESTORE,KEY_WRITE|DELETE,NULL,&hkey,NULL)==ERROR_SUCCESS)
{
RegDeleteTree(hkey,L"StartMenuExt");
RegCloseKey(hkey);
}
}
}
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
return _AtlModule.DllCanUnloadNow();
}
typedef HRESULT (__stdcall *FDllGetClassObject)(REFCLSID,REFIID,LPVOID*);
static HMODULE g_ExplorerModule=NULL;
static void StartStartMenu( void )
{
STARTUPINFO startupInfo={sizeof(STARTUPINFO)};
PROCESS_INFORMATION processInfo;
memset(&processInfo,0,sizeof(processInfo));
wchar_t path[_MAX_PATH];
path[0]=0;
{
CRegKey regKey;
if (regKey.Open(HKEY_LOCAL_MACHINE,L"Software\\IvoSoft\\ClassicShell",KEY_READ|KEY_WOW64_64KEY)==ERROR_SUCCESS)
{
ULONG size=_countof(path);
if (regKey.QueryStringValue(L"Path",path,&size)!=ERROR_SUCCESS)
path[0]=0;
}
}
if (!path[0])
{
GetModuleFileName(g_Instance,path,_countof(path));
PathRemoveFileSpec(path);
}
PathAppend(path,L"ClassicStartMenu.exe");
LogToFile(STARTUP_LOG,L"StartMenuHelper: starting \"%s\" -startup",path);
if (CreateProcess(path,L"ClassicStartMenu.exe -startup",NULL,NULL,TRUE,0,NULL,NULL,&startupInfo,&processInfo))
{
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
else
LogToFile(STARTUP_LOG,L"StartMenuHelper: starting failed: 0x%08X",GetLastError());
}
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
WaitDllInitThread();
if (rclsid==g_EmulationClsid)
{
LogToFile(STARTUP_LOG,L"StartMenuHelper: DllGetClassObject1");
HRESULT res=E_FAIL;
if (!g_ExplorerModule)
g_ExplorerModule=LoadLibrary(EXPLORER_DLL);
if (g_ExplorerModule)
{
LogToFile(STARTUP_LOG,L"StartMenuHelper: DllGetClassObject2");
if (GetSettingBool(L"AutoStart"))
StartStartMenu();
FDllGetClassObject func=(FDllGetClassObject)GetProcAddress(g_ExplorerModule,"DllGetClassObject");
if (func)
res=func(g_ExplorerClsid,riid,ppv);
}
return res;
}
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
}
/*
const wchar_t *TASK_NAME=L"Classic Shell Start Menu";
const wchar_t *TASK_XML=
L"<?xml version=\"1.0\" encoding=\"UTF-16\"?>\r\n"
L"<Task version=\"1.2\" xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\r\n"
L" <RegistrationInfo>\r\n"
L" <Date>2014-11-23T10:00:00</Date>\r\n"
L" <Author>Classic Shell</Author>\r\n"
L" <Description>A task that launches the start menu at logon. It also repairs the installation after an upgrade of Windows.</Description>\r\n"
L" </RegistrationInfo>\r\n"
L" <Triggers>\r\n"
L" <LogonTrigger>\r\n"
L" <Enabled>true</Enabled>\r\n"
L" </LogonTrigger>\r\n"
L" </Triggers>\r\n"
L" <Principals>\r\n"
L" <Principal id=\"Author\">\r\n"
L" <RunLevel>LeastPrivilege</RunLevel>\r\n"
L" <GroupId>BUILTIN\\Users</GroupId>\r\n"
L" </Principal>\r\n"
L" </Principals>\r\n"
L" <Settings>\r\n"
L" <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>\r\n"
L" <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>\r\n"
L" <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>\r\n"
L" <AllowHardTerminate>false</AllowHardTerminate>\r\n"
L" <StartWhenAvailable>false</StartWhenAvailable>\r\n"
L" <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>\r\n"
L" <IdleSettings>\r\n"
L" <StopOnIdleEnd>true</StopOnIdleEnd>\r\n"
L" <RestartOnIdle>false</RestartOnIdle>\r\n"
L" </IdleSettings>\r\n"
L" <AllowStartOnDemand>false</AllowStartOnDemand>\r\n"
L" <Enabled>true</Enabled>\r\n"
L" <Hidden>false</Hidden>\r\n"
L" <RunOnlyIfIdle>false</RunOnlyIfIdle>\r\n"
L" <WakeToRun>false</WakeToRun>\r\n"
L" <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>\r\n"
L" </Settings>\r\n"
L" <Actions Context=\"Author\">\r\n"
L" <Exec>\r\n"
L" <Command>\"%s\"</Command>\r\n"
L" <Arguments>-autorun</Arguments>\r\n"
L" </Exec>\r\n"
L" </Actions>\r\n"
L"</Task>\r\n";
*/
static void InstallUpgradeTask( bool bInstall )
{
wchar_t exePath[_MAX_PATH];
exePath[0]=0;
{
CRegKey regKey;
if (regKey.Open(HKEY_LOCAL_MACHINE,L"Software\\IvoSoft\\ClassicShell",KEY_READ|KEY_WRITE|KEY_WOW64_64KEY)==ERROR_SUCCESS)
{
if (bInstall)
{
ULONG size=_countof(exePath);
if (regKey.QueryStringValue(L"Path",exePath,&size)==ERROR_SUCCESS)
{
PathAppend(exePath,L"ClassicStartMenu.exe");
}
else
{
exePath[0]=0;
}
regKey.SetDWORDValue(L"WinVersion",GetVersionEx(GetModuleHandle(L"user32.dll")));
}
else
{
regKey.DeleteValue(L"WinVersion");
}
}
}
/*
CComPtr<ITaskService> pService;
pService.CoCreateInstance(CLSID_TaskScheduler);
if (pService && SUCCEEDED(pService->Connect(CComVariant(),CComVariant(),CComVariant(),CComVariant())))
{
CComPtr<ITaskFolder> pFolder;
if (SUCCEEDED(pService->GetFolder(CComBSTR(L""),&pFolder)) && pFolder)
{
pFolder->DeleteTask(CComBSTR(TASK_NAME),0);
if (bInstall)
{
wchar_t buf[4096];
Sprintf(buf,_countof(buf),TASK_XML,exePath);
CComPtr<IRegisteredTask> pTask;
pFolder->RegisterTask(CComBSTR(TASK_NAME),CComBSTR(buf),TASK_CREATE,CComVariant(),CComVariant(),TASK_LOGON_INTERACTIVE_TOKEN,CComVariant(L""),&pTask);
}
}
}
*/
}
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
WaitDllInitThread();
CoInitialize(NULL);
// registers object, typelib and all interfaces in typelib
HRESULT hr = _AtlModule.DllRegisterServer(FALSE);
#ifdef BUILD_SETUP
BOOL bWow64=FALSE;
// GetVersion lies! it always returns Vista when running inside msiexec. must check version of some system dll
WORD winVer=HIWORD(GetVersionEx(GetModuleHandle(L"user32.dll")));
if (SUCCEEDED(hr) && winVer>=WIN_VER_WIN8 && IsWow64Process(GetCurrentProcess(),&bWow64) && !bWow64)
{
AddRegistryKeys(winVer>=WIN_VER_WIN10);
InstallUpgradeTask(true);
}
#endif
CoUninitialize();
return hr;
}
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
WaitDllInitThread();
CoInitialize(NULL);
#ifdef BUILD_SETUP
BOOL bWow64=FALSE;
WORD winVer=HIWORD(GetVersionEx(GetModuleHandle(L"user32.dll")));
if (winVer>=WIN_VER_WIN8 && IsWow64Process(GetCurrentProcess(),&bWow64) && !bWow64)
{
RemoveRegistryKeys(winVer>=WIN_VER_WIN10);
InstallUpgradeTask(false);
}
#endif
HRESULT hr = _AtlModule.DllUnregisterServer(FALSE);
CoUninitialize();
return hr;
}
// DllInstall - Adds/Removes entries to the system registry per user
// per machine.
STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
{
WaitDllInitThread();
HRESULT hr = E_FAIL;
static const wchar_t szUserSwitch[] = _T("user");
if (pszCmdLine != NULL)
{
if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
{
AtlSetPerUserRegistration(true);
}
}
if (bInstall)
{
hr = DllRegisterServer();
if (FAILED(hr))
{
DllUnregisterServer();
}
}
else
{
hr = DllUnregisterServer();
}
return hr;
}
@@ -0,0 +1,34 @@
// StartMenuHelper.idl : IDL source for StartMenuHelper
//
// This file will be processed by the MIDL tool to
// produce the type library (StartMenuHelper.tlb) and marshalling code.
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(379C7129-9462-42A8-A5F3-68A65A0DEF8A),
helpstring("IStartMenuExt Interface"),
pointer_default(unique)
]
interface IStartMenuExt : IUnknown{
};
[
uuid(6A62B77B-9003-49FA-83D7-1BF82296EF49),
version(1.0),
helpstring("StartMenuHelper 1.0 Type Library")
]
library StartMenuHelperLib
{
importlib("stdole2.tlb");
[
uuid(E595F05F-903F-4318-8B0A-7F633B520D2B),
helpstring("StartMenuExt Class")
]
coclass StartMenuExt
{
[default] interface IStartMenuExt;
};
};
@@ -0,0 +1,114 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#include ""winres.h""\r\0"
END
3 TEXTINCLUDE
BEGIN
"1 TYPELIB ""StartMenuHelper.tlb""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,3,1,0
PRODUCTVERSION 4,3,1,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "IvoSoft"
VALUE "FileDescription", "Start Menu Helper Extension"
VALUE "FileVersion", "4, 3, 1, 0"
VALUE "InternalName", "StartMenuHelper"
VALUE "LegalCopyright", "Copyright (C) 2009-2016, Ivo Beltchev"
VALUE "OriginalFilename", "StartMenuHelper.dll"
VALUE "ProductName", "Classic Shell"
VALUE "ProductVersion", "4, 3, 1, 0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_STARTMENUHELPER REGISTRY "StartMenuHelper.rgs"
IDR_STARTMENUEXT REGISTRY "StartMenuExt.rgs"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB "StartMenuHelper.tlb"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
@@ -0,0 +1,11 @@
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'StartMenuHelper'
'StartMenuHelper.DLL'
{
val AppID = s '%APPID%'
}
}
}
@@ -0,0 +1,831 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="StartMenuHelper"
ProjectGUID="{A42C6159-ACA8-46D1-A0FB-19C398B137D5}"
RootNamespace="StartMenuHelper"
SccProjectName="SAK"
SccAuxPath="SAK"
SccLocalPath="SAK"
SccProvider="SAK"
Keyword="AtlProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/StartMenuHelper.tlb"
HeaderFileName="StartMenuHelper_i.h"
DLLDataFileName=""
InterfaceIdentifierFileName="StartMenuHelper_i.c"
ProxyFileName="StartMenuHelper_p.c"
ValidateParameters="true"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\ClassicShellLib"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib uxtheme.lib winmm.lib htmlhelp.lib wininet.lib version.lib"
OutputFile="$(OutDir)\$(ProjectName)32.dll"
LinkIncremental="2"
ModuleDefinitionFile=".\StartMenuHelper32.def"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(ConfigurationName)64"
IntermediateDirectory="$(ConfigurationName)64"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="false"
TargetEnvironment="3"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/StartMenuHelper.tlb"
HeaderFileName="StartMenuHelper_i.h"
DLLDataFileName=""
InterfaceIdentifierFileName="StartMenuHelper_i.c"
ProxyFileName="StartMenuHelper_p.c"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\ClassicShellLib"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib uxtheme.lib winmm.lib htmlhelp.lib wininet.lib version.lib"
OutputFile="$(OutDir)\$(ProjectName)64.dll"
LinkIncremental="2"
ModuleDefinitionFile=".\StartMenuHelper64.def"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/StartMenuHelper.tlb"
HeaderFileName="StartMenuHelper_i.h"
DLLDataFileName=""
InterfaceIdentifierFileName="StartMenuHelper_i.c"
ProxyFileName="StartMenuHelper_p.c"
ValidateParameters="true"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\ClassicShellLib"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib uxtheme.lib winmm.lib htmlhelp.lib wininet.lib version.lib"
OutputFile="$(OutDir)\$(ProjectName)32.dll"
LinkIncremental="1"
ModuleDefinitionFile=".\StartMenuHelper32.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(ConfigurationName)64"
IntermediateDirectory="$(ConfigurationName)64"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="3"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/StartMenuHelper.tlb"
HeaderFileName="StartMenuHelper_i.h"
DLLDataFileName=""
InterfaceIdentifierFileName="StartMenuHelper_i.c"
ProxyFileName="StartMenuHelper_p.c"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\ClassicShellLib"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RegisterOutput="true"
IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib uxtheme.lib winmm.lib htmlhelp.lib wininet.lib version.lib"
OutputFile="$(OutDir)\$(ProjectName)64.dll"
LinkIncremental="1"
ModuleDefinitionFile=".\StartMenuHelper64.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Setup|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="1"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/StartMenuHelper.tlb"
HeaderFileName="StartMenuHelper_i.h"
DLLDataFileName=""
InterfaceIdentifierFileName="StartMenuHelper_i.c"
ProxyFileName="StartMenuHelper_p.c"
ValidateParameters="true"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\ClassicShellLib"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;BUILD_SETUP"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib uxtheme.lib winmm.lib htmlhelp.lib wininet.lib version.lib"
OutputFile="$(OutDir)\$(ProjectName)32.dll"
LinkIncremental="1"
ModuleDefinitionFile=".\StartMenuHelper32.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Setup|x64"
OutputDirectory="$(ConfigurationName)64"
IntermediateDirectory="$(ConfigurationName)64"
ConfigurationType="2"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="false"
TargetEnvironment="3"
GenerateStublessProxies="true"
TypeLibraryName="$(IntDir)/StartMenuHelper.tlb"
HeaderFileName="StartMenuHelper_i.h"
DLLDataFileName=""
InterfaceIdentifierFileName="StartMenuHelper_i.c"
ProxyFileName="StartMenuHelper_p.c"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="..\..\ClassicShellLib"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;BUILD_SETUP"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="true"
AdditionalDependencies="comctl32.lib uxtheme.lib winmm.lib htmlhelp.lib wininet.lib version.lib"
OutputFile="$(OutDir)\$(ProjectName)64.dll"
LinkIncremental="1"
ModuleDefinitionFile=".\StartMenuHelper64.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\dllmain.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Setup|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Setup|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\StartMenuExt.cpp"
>
</File>
<File
RelativePath=".\StartMenuHelper.cpp"
>
</File>
<File
RelativePath=".\StartMenuHelper.idl"
>
</File>
<File
RelativePath=".\StartMenuHelper32.def"
>
</File>
<File
RelativePath=".\StartMenuHelper64.def"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Setup|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Setup|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\dllmain.h"
>
</File>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\StartMenuExt.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\targetver.h"
>
</File>
</Filter>
<Filter
Name="Generated Files"
SourceControlFiles="false"
>
<File
RelativePath=".\StartMenuHelper_i.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Setup|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Setup|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAsManaged="0"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\StartMenuHelper_i.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\StartMenuExt.rgs"
>
</File>
<File
RelativePath=".\StartMenuHelper.rc"
>
</File>
<File
RelativePath=".\StartMenuHelper.rgs"
>
</File>
<File
RelativePath=".\StartMenuHelperL10N.ini"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
@@ -0,0 +1,10 @@
; StartMenuHelper.def : Declares the module parameters.
LIBRARY "StartMenuHelper32.DLL"
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllInstall PRIVATE
@@ -0,0 +1,10 @@
; StartMenuHelper.def : Declares the module parameters.
LIBRARY "StartMenuHelper64.DLL"
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllInstall PRIVATE
@@ -0,0 +1,123 @@
// dllmain.cpp : Implementation of DllMain.
#include "stdafx.h"
#include "resource.h"
#include "StartMenuHelper_i.h"
#include "dllmain.h"
#include "Settings.h"
#include "Translations.h"
#include "StringUtils.h"
#include "ResourceHelper.h"
#include "..\ClassicStartMenuDLL\LogManager.h"
CStartMenuHelperModule _AtlModule;
void UpgradeSettings( bool bShared )
{
}
void UpdateSettings( void )
{
CRegKey regKey;
wchar_t language[100]=L"";
if (regKey.Open(HKEY_LOCAL_MACHINE,L"Software\\IvoSoft\\ClassicShell",KEY_READ|KEY_WOW64_64KEY)==ERROR_SUCCESS)
{
ULONG size=_countof(language);
if (regKey.QueryStringValue(L"DefaultLanguage",language,&size)!=ERROR_SUCCESS)
language[0]=0;
}
UpdateSetting(L"Language",language,false);
}
void ClosingSettings( HWND hWnd, int flags, int command )
{
}
void SettingChangedCallback( const CSetting *pSetting )
{
}
const wchar_t *GetDocRelativePath( void )
{
return L"";
}
CSetting g_Settings[]={
{L"MenuStyleGroup",CSetting::TYPE_GROUP},
{L"MenuStyle",CSetting::TYPE_INT,0,0,2},
{L"Classic1",CSetting::TYPE_RADIO},
{L"Classic2",CSetting::TYPE_RADIO},
{L"Win7",CSetting::TYPE_RADIO},
{L"GeneralBehavior",CSetting::TYPE_GROUP},
{L"AutoStart",CSetting::TYPE_BOOL,0,0,1},
{L"PinnedPrograms",CSetting::TYPE_INT,0,0,1},
{L"FastItems",CSetting::TYPE_RADIO},
{L"PinnedItems",CSetting::TYPE_RADIO},
{L"DisablePinExt",CSetting::TYPE_BOOL,0,0,0},
{L"FolderStartMenu",CSetting::TYPE_STRING,0,0,L""},
{L"FolderCommonStartMenu",CSetting::TYPE_STRING,0,0,L""},
{L"Language",CSetting::TYPE_GROUP},
{L"Language",CSetting::TYPE_STRING,0,0,L"",CSetting::FLAG_COLD|CSetting::FLAG_SHARED},
{NULL}
};
static HANDLE g_DllInitThread;
static DWORD CALLBACK DllInitThread( void* )
{
CoInitialize(NULL);
InitSettings(g_Settings,COMPONENT_MENU,NULL);
wchar_t path[_MAX_PATH];
path[0]=0;
#ifdef BUILD_SETUP
{
CRegKey regKey;
if (regKey.Open(HKEY_LOCAL_MACHINE,L"Software\\IvoSoft\\ClassicShell",KEY_READ|KEY_WOW64_64KEY)==ERROR_SUCCESS)
{
ULONG size=_countof(path);
if (regKey.QueryStringValue(L"Path",path,&size)!=ERROR_SUCCESS)
path[0]=0;
}
}
#endif
if (!path[0])
{
GetModuleFileName(g_Instance,path,_countof(path));
PathRemoveFileSpec(path);
}
wchar_t fname[_MAX_PATH];
Sprintf(fname,_countof(fname),L"%s" INI_PATH L"StartMenuHelperL10N.ini",path);
CString language=GetSettingString(L"Language");
ParseTranslations(fname,language);
CoUninitialize();
return 0;
}
void WaitDllInitThread( void )
{
ATLASSERT(g_DllInitThread);
WaitForSingleObject(g_DllInitThread,INFINITE);
LogToFile(STARTUP_LOG,L"StartMenuHelper: WaitDllInitThread");
}
// DLL Entry Point
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason==DLL_PROCESS_ATTACH)
{
LogToFile(STARTUP_LOG,L"StartMenuHelper: DLL_PROCESS_ATTACH");
g_Instance=hInstance;
g_DllInitThread=CreateThread(NULL,0,DllInitThread,NULL,0,NULL);
}
if (dwReason==DLL_PROCESS_DETACH)
{
LogToFile(STARTUP_LOG,L"StartMenuHelper: DLL_PROCESS_DETACH");
}
return _AtlModule.DllMain(dwReason, lpReserved);
}
@@ -0,0 +1,12 @@
// dllmain.h : Declaration of module class.
class CStartMenuHelperModule : public CAtlDllModuleT< CStartMenuHelperModule >
{
public :
DECLARE_LIBID(LIBID_StartMenuHelperLib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_STARTMENUHELPER, "{62D2FBE4-89F7-48A5-A35F-DA2B8A3C54B7}")
};
extern CStartMenuHelperModule _AtlModule;
void WaitDllInitThread( void );
@@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by StartMenuHelper.rc
//
#define IDR_STARTMENUHELPER 101
#define IDR_STARTMENUEXT 102
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 201
#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif
@@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// StartMenuHelper.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
@@ -0,0 +1,30 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef STRICT
#define STRICT
#endif
#include "targetver.h"
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#include "resource.h"
#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>
#include <atlstr.h>
using namespace ATL;
#ifdef BUILD_SETUP
#define INI_PATH L""
#else
#define INI_PATH L"..\\"
#endif
@@ -0,0 +1,24 @@
#pragma once
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Specifies that the minimum required platform is Windows 7.
#define WINVER 0x0602 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows 7.
#define _WIN32_WINNT 0x0602 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
#endif