Here is the source code to the Windows Program Manager, this is the main interface in Windows 3.1 and 3.11. This used program groups to organize various applications like Microsoft Office and accessories. As well as the ability to create your own program groups to organize your favorite applications.
Download the source code here: https://mega.nz/file/R1hy1RyS#Dkm0hK8hGmwTx-__9hOQKBWtNDDBCW-ChSneHGSc_RY. This is not that useful anymore, it was removed in Windows XP Service Pack 2 and Windows Vista removed it completely. But it is interesting to see this old program`s code though. The only traces I could find in Windows 8.1 is the grpconv.exe utility for converting program groups to a new format. But this is hardly needed anymore.
Here is a sample of the source code, this checks if a user is part of the ADMIN group.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | BOOL TestTokenForAdmin( HANDLE Token ); /***************************************************************************\ * TestUserForAdmin * * * Returns TRUE if the current user is part of the ADMIN group, * FALSE otherwise * * History: * 07-15-92 JohanneC Created \***************************************************************************/ BOOL TestUserForAdmin() { BOOL UserIsAdmin = FALSE; HANDLE Token; #if 0 ACCESS_MASK GrantedAccess; GENERIC_MAPPING GenericMapping; PPRIVILEGE_SET pPrivilegeSet; DWORD dwPrivilegeSetLength; MYACE Ace[1]; PSECURITY_DESCRIPTOR pSecDesc; NTSTATUS Status; #endif PSID AdminAliasSid = NULL; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; // // Get the token of the current process. // if (!OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &Token ) ) { DbgOnlyPrint("Progman: Can't open own process token for token_query access\n\r"); return(FALSE); } #if 0 |
This might not be the most secure code but it is very old. It is from 1992. But Program Manager was fun to play around with. And seeing old source code can be very interesting. The source code below is for showing a shutdown dialog when the user wishes to shutdown the machine.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | BOOL ShutdownDialog( HANDLE hInst, HWND hwnd ) { INT_PTR nResult; BOOLEAN WasEnabled; NTSTATUS Status; TCHAR szMessage[MAXMESSAGELEN]; TCHAR szTitle[MAXMESSAGELEN]; Status = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, (BOOLEAN)TRUE, (BOOLEAN)FALSE, &WasEnabled); if (!NT_SUCCESS(Status)) { // // We don't have permission to shutdown // LoadString(hInst, IDS_NO_PERMISSION_SHUTDOWN, szMessage, CharSizeOf(szMessage)); LoadString(hInst, IDS_SHUTDOWN_MESSAGE, szTitle, CharSizeOf(szTitle)); nResult = MessageBox(hwnd, szMessage, szTitle, MB_OK | MB_ICONSTOP); return(FALSE); } // // Put up the shutdown dialog // nResult = DialogBox(hInst, (LPTSTR) MAKEINTRESOURCE(IDD_SHUTDOWN_QUERY), hwnd, ShutdownDlgProc); // // Restore the shutdown privilege state // if (!WasEnabled) { Status = RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, (BOOLEAN)WasEnabled, (BOOLEAN)FALSE, &WasEnabled); } return(FALSE); } |
GUI programming in Windows must be a nightmare, especially how complicated Windows 10 is, adding a simple dialog must be annoying finding the proper parts of the code to reference to get it working. Maybe that is why Windows 10 has so many issues. Maybe it would have been better to start a new version of Windows from scratch? But that would also be a massive job. It would be a great idea though if the code was actually secure.