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