diff --git a/progmgr/progmgr.c b/progmgr/progmgr.c
index 9781942..6c16cf8 100644
--- a/progmgr/progmgr.c
+++ b/progmgr/progmgr.c
@@ -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);
diff --git a/progmgr/progmgr.h b/progmgr/progmgr.h
index 9f27f22..63f7e66 100644
--- a/progmgr/progmgr.h
+++ b/progmgr/progmgr.h
@@ -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 */
diff --git a/progmgr/progmgr.vcxproj.user b/progmgr/progmgr.vcxproj.user
index 88a5509..9573012 100644
--- a/progmgr/progmgr.vcxproj.user
+++ b/progmgr/progmgr.vcxproj.user
@@ -1,4 +1,6 @@
-
+
+ WindowsLocalDebugger
+
\ No newline at end of file
diff --git a/progmgr/registry.c b/progmgr/registry.c
index 3c66896..15d8e7d 100644
--- a/progmgr/registry.c
+++ b/progmgr/registry.c
@@ -8,9 +8,11 @@
\* * * * * * * */
/* Headers */
+#include "progmgr.h"
#include "registry.h"
// #define WIN32_LEAN_AND_MEAN
#include
+#include
/* 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;
}
\ No newline at end of file
diff --git a/progmgr/registry.h b/progmgr/registry.h
index 9fecdde..12058cc 100644
--- a/progmgr/registry.h
+++ b/progmgr/registry.h
@@ -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);