working default shell detection
This commit is contained in:
@@ -36,7 +36,7 @@ HWND hWndMDIClient = NULL;
|
||||
wWinMain -
|
||||
Program Manager's entry point.
|
||||
\* * * */
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
MSG msg = { 0 };
|
||||
HANDLE hAccel;
|
||||
@@ -73,10 +73,11 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||
if (!hAccel)
|
||||
return FALSE;
|
||||
|
||||
InitializeRegistryKeys();
|
||||
//if (IsProgMgrDefaultShell) {
|
||||
// Perform Registry actions, close if registry is inaccessible.
|
||||
if (!InitializeRegistryKeys())
|
||||
return FALSE;
|
||||
|
||||
//}
|
||||
bIsDefaultShell = IsProgMgrDefaultShell();
|
||||
|
||||
GetUserNameEx(NameSamCompatible, szUsername, &dwUsernameLen);
|
||||
// OutputDebugString(szUsername);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
|
||||
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#pragma comment(lib, "Shlwapi.lib")
|
||||
#pragma comment(lib, "Secur32.lib")
|
||||
|
||||
/* Includes */
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -8,9 +8,11 @@
|
||||
\* * * * * * * */
|
||||
|
||||
/* Headers */
|
||||
#include "progmgr.h"
|
||||
#include "registry.h"
|
||||
// #define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
/* Functions */
|
||||
/* * * *\
|
||||
@@ -35,24 +37,35 @@ BOOL InitializeRegistryKeys()
|
||||
IsProgMgrDefaultShell -
|
||||
Detects if Program Manager is the default shell.
|
||||
RETURNS -
|
||||
True if successful, false if unsuccessful.
|
||||
True if Program Manager is the default shell,
|
||||
false if otherwise or an error occurs.
|
||||
\* * * */
|
||||
BOOL IsProgMgrDefaultShell()
|
||||
{
|
||||
HKEY hkeyWinlogon;
|
||||
//DWORD szShell;
|
||||
//DWORD cbBuffer = 0;
|
||||
HKEY hKeyWinlogon;
|
||||
WCHAR szShell[HKEYMAXLEN] = L"";
|
||||
DWORD dwType;
|
||||
DWORD dwBufferSize;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SHELL_KEY, 0, KEY_READ, &hkeyWinlogon) == ERROR_SUCCESS) {
|
||||
//if (RegQueryValueEx(hkeyWinlogon, L"Shell", 0, NULL, szShell, &cbBuffer) == ERROR_SUCCESS) {
|
||||
// we probably found progman
|
||||
//}
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SHELL_KEY, 0, KEY_READ, &hKeyWinlogon) == ERROR_SUCCESS) {
|
||||
if (RegQueryValueEx(hKeyWinlogon, L"Shell", 0, &dwType, (LPBYTE)szShell, &dwBufferSize) == ERROR_SUCCESS) {
|
||||
if (StrStr(szShell, szProgMgr)) {
|
||||
// ProgMgr detected >:)
|
||||
RegCloseKey(hKeyWinlogon);
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
// Inferior shell detected.
|
||||
RegCloseKey(hKeyWinlogon);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// assume that progman is the shell.
|
||||
// Assume that we're the shell... just incase.
|
||||
RegCloseKey(hKeyWinlogon);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
RegCloseKey(hkeyWinlogon);
|
||||
|
||||
// No registry access.
|
||||
return FALSE;
|
||||
}
|
||||
@@ -18,11 +18,11 @@
|
||||
#define PROGMAN_KEY L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Program Manager"
|
||||
#define WINDOWS_KEY L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
|
||||
#define PROGMGR_KEY L"Software\\Freedom Desktop\\Program Manager II"
|
||||
#define HKEYMAXLENGTH 261
|
||||
#define HKEYMAXLEN 261
|
||||
|
||||
/* Global Registry Keys */
|
||||
//HKEY hkeyProgramManager;
|
||||
//HKEY hkeyPMSettings;
|
||||
//HKEY hKeyProgramManager;
|
||||
//HKEY hKeyPMSettings;
|
||||
|
||||
/* Function Prototypes */
|
||||
BOOL InitializeRegistryKeys(VOID);
|
||||
|
||||
Reference in New Issue
Block a user