Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

486 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: windproc.c
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 7-14-94 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "testgina.h"
  18. #include <commdlg.h>
  19. WCHAR szFilter[] = TEXT("DLLs (*.dll)\0*.dll\0\0");
  20. DoLoadDll(void)
  21. {
  22. if (LoadGinaDll())
  23. {
  24. WCHAR szCaption[MAX_PATH];
  25. fTestGina |= GINA_DLL_KNOWN;
  26. SaveParameters();
  27. wcscpy(szCaption, TEXT("TestGina - "));
  28. wcscat(szCaption, szGinaDll);
  29. SetWindowText(hMainWindow, szCaption);
  30. GinaState = Winsta_PreLoad;
  31. UpdateStatusBar();
  32. LoadGinaSpecificParameters();
  33. UpdateSasMenu();
  34. }
  35. UpdateMenuBar();
  36. return(0);
  37. }
  38. int
  39. GetFile()
  40. {
  41. OPENFILENAME ofn;
  42. ofn.lStructSize = sizeof(OPENFILENAME);
  43. ofn.hwndOwner = hMainWindow;
  44. ofn.hInstance = hAppInstance;
  45. ofn.lpstrFilter = szFilter;
  46. ofn.lpstrCustomFilter = NULL;
  47. ofn.nMaxCustFilter = 0;
  48. ofn.nFilterIndex = 0;
  49. ofn.lpstrFile = szGinaDll;
  50. ofn.nMaxFile = MAX_PATH;
  51. ofn.lpstrFileTitle = NULL;
  52. ofn.nMaxFileTitle = 0;
  53. ofn.lpstrInitialDir = NULL;
  54. ofn.lpstrTitle = TEXT("Load A DLL");
  55. ofn.Flags = OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON | OFN_NOTESTFILECREATE |
  56. OFN_PATHMUSTEXIST ;
  57. ofn.lpstrDefExt = TEXT("DLL");
  58. if (GetOpenFileName(&ofn))
  59. {
  60. DoLoadDll();
  61. }
  62. return(0);
  63. }
  64. LRESULT
  65. MprDialogProc(
  66. HWND hDlg,
  67. UINT Message,
  68. WPARAM wParam,
  69. LPARAM lParam)
  70. {
  71. if (Message == WM_INITDIALOG)
  72. {
  73. SetDlgItemText(hDlg, IDD_VIEW_MPR_USERNAME,
  74. (GlobalMprInfo.pszUserName ? GlobalMprInfo.pszUserName : TEXT("<Null>")));
  75. SetDlgItemText(hDlg, IDD_VIEW_MPR_DOMAIN,
  76. (GlobalMprInfo.pszDomain ? GlobalMprInfo.pszDomain : TEXT("<Null>")));
  77. SetDlgItemText(hDlg, IDD_VIEW_MPR_PASSWORD,
  78. (GlobalMprInfo.pszPassword ? GlobalMprInfo.pszPassword : TEXT("<Null>")));
  79. SetDlgItemText(hDlg, IDD_VIEW_MPR_OLD_PASSWORD,
  80. (GlobalMprInfo.pszOldPassword ? GlobalMprInfo.pszOldPassword : TEXT("<Null>")));
  81. SetDlgItemText(hDlg, IDD_VIEW_MPR_PROVIDER,
  82. GlobalProviderName);
  83. EnableWindow( GetDlgItem( hDlg, IDD_VIEW_MPR_USERNAME ), FALSE );
  84. EnableWindow( GetDlgItem( hDlg, IDD_VIEW_MPR_DOMAIN ), FALSE );
  85. EnableWindow( GetDlgItem( hDlg, IDD_VIEW_MPR_PASSWORD ), FALSE );
  86. EnableWindow( GetDlgItem( hDlg, IDD_VIEW_MPR_OLD_PASSWORD ), FALSE );
  87. EnableWindow( GetDlgItem( hDlg, IDD_VIEW_MPR_PROVIDER ), FALSE );
  88. return(TRUE);
  89. }
  90. if (Message == WM_COMMAND)
  91. {
  92. if (LOWORD(wParam) == IDOK)
  93. {
  94. EndDialog(hDlg, IDOK);
  95. return(TRUE);
  96. }
  97. }
  98. return(FALSE);
  99. }
  100. void
  101. DoViewMPR(void)
  102. {
  103. DialogBox( hAppInstance,
  104. MAKEINTRESOURCE(IDD_VIEW_MPR),
  105. hMainWindow,
  106. MprDialogProc );
  107. }
  108. SasBoxProc(
  109. HWND hDlg,
  110. UINT Message,
  111. WPARAM wParam,
  112. LPARAM lParam)
  113. {
  114. USER_SAS Sas;
  115. switch (Message)
  116. {
  117. case WM_INITDIALOG:
  118. SetDlgItemText( hDlg, IDD_SAS_USERNAME, TEXT("User Defined") );
  119. SetDlgItemText( hDlg, IDD_SAS_VALUE, TEXT("128") );
  120. if (UserSases == MAX_USER_SASES)
  121. {
  122. EnableWindow( GetDlgItem(hDlg, IDD_SAS_KEEPAROUND), FALSE );
  123. }
  124. EnableWindow( GetDlgItem( hDlg, IDD_SAS_REMOVE ), FALSE );
  125. return( TRUE );
  126. case WM_COMMAND:
  127. if (LOWORD(wParam) == IDCANCEL)
  128. {
  129. EndDialog( hDlg, IDCANCEL );
  130. }
  131. if ((LOWORD(wParam) == IDOK) ||
  132. (LOWORD(wParam) == IDD_SAS_REMOVE) )
  133. {
  134. GetDlgItemText(hDlg, IDD_SAS_USERNAME, Sas.Name, 128);
  135. Sas.Value = GetDlgItemInt(hDlg, IDD_SAS_VALUE, NULL, FALSE );
  136. if (Sas.Value <= WLX_SAS_TYPE_MAX_MSFT_VALUE)
  137. {
  138. MessageBox( hDlg, TEXT("Invalid SAS Value!"), TEXT("Error"),
  139. MB_OK | MB_ICONERROR);
  140. }
  141. else
  142. {
  143. if (IsDlgButtonChecked(hDlg, IDD_SAS_KEEPAROUND) == BST_CHECKED)
  144. {
  145. //
  146. // Ok, big update time:
  147. //
  148. UserDefSas[UserSases ++ ] = Sas;
  149. SaveGinaSpecificParameters();
  150. UpdateSasMenu();
  151. }
  152. EndDialog( hDlg, Sas.Value );
  153. }
  154. }
  155. return( TRUE );
  156. }
  157. return( FALSE );
  158. }
  159. ToggleDebugItem(DWORD MenuId,
  160. DWORD FlagId)
  161. {
  162. DWORD fuFlags;
  163. if (TEST_FLAG(GinaBreakFlags, FlagId))
  164. {
  165. FLAG_OFF(GinaBreakFlags, FlagId);
  166. fuFlags = MF_UNCHECKED;
  167. }
  168. else
  169. {
  170. FLAG_ON(GinaBreakFlags, FlagId);
  171. fuFlags = MF_CHECKED;
  172. }
  173. fuFlags |= MF_BYCOMMAND;
  174. CheckMenuItem(hDebugMenu, MenuId, fuFlags);
  175. DrawMenuBar(hMainWindow);
  176. return(0);
  177. }
  178. void
  179. ShowDialogUnits(HWND hWnd)
  180. {
  181. CHAR Buff[256];
  182. LONG l;
  183. LONG DlgX;
  184. LONG DlgY;
  185. l = GetDialogBaseUnits();
  186. DlgX = LOWORD(l);
  187. DlgY = HIWORD(l);
  188. sprintf(Buff, "BaseUnits are\nX = %d\nY = %d", DlgX, DlgY);
  189. MessageBoxA( hWnd, Buff, "Hello!", MB_OK);
  190. }
  191. VOID
  192. DoSendSS( VOID )
  193. {
  194. }
  195. VOID
  196. DoSendLogoff( VOID )
  197. {
  198. }
  199. LRESULT
  200. DoCommand( HWND hWnd,
  201. UINT Message,
  202. WPARAM wParam,
  203. LPARAM lParam)
  204. {
  205. DWORD res;
  206. switch (wParam)
  207. {
  208. case IDM_DLL_EXIT:
  209. PostQuitMessage(0);
  210. return(0);
  211. case IDM_DLL_OPEN:
  212. GetFile();
  213. return(0);
  214. case IDM_DLL_LOAD_LAST:
  215. DoLoadDll();
  216. return(0);
  217. case IDM_WHACK_NEGOTIATE:
  218. TestNegotiate();
  219. return(0);
  220. case IDM_WHACK_INITIALIZE:
  221. TestInitialize();
  222. return(0);
  223. case IDM_WHACK_DISPLAY:
  224. TestDisplaySASNotice();
  225. return(0);
  226. case IDM_WHACK_LOGGEDOUT:
  227. UpdateGinaState(UPDATE_SAS_BYPASS);
  228. TestLoggedOutSAS(WLX_SAS_TYPE_CTRL_ALT_DEL);
  229. return(0);
  230. case IDM_WHACK_STARTSHELL:
  231. TestActivateUserShell();
  232. return(0);
  233. case IDM_WHACK_LOGGEDON:
  234. UpdateGinaState(UPDATE_SAS_RECEIVED);
  235. TestLoggedOnSAS(WLX_SAS_TYPE_CTRL_ALT_DEL);
  236. return(0);
  237. case IDM_WHACK_DISPLAYLOCKED:
  238. TestDisplayLockedNotice();
  239. return(0);
  240. case IDM_WHACK_LOCKED:
  241. UpdateGinaState(UPDATE_SAS_RECEIVED);
  242. TestWkstaLockedSAS(WLX_SAS_TYPE_CTRL_ALT_DEL);
  243. return(0);
  244. case IDM_SAS_CAD:
  245. PingSAS(WLX_SAS_TYPE_CTRL_ALT_DEL);
  246. return(0);
  247. case IDM_SAS_TIMEOUT:
  248. PingSAS(WLX_SAS_TYPE_TIMEOUT);
  249. return(0);
  250. case IDM_SAS_SCRNSVR:
  251. PingSAS(WLX_SAS_TYPE_SCRNSVR_TIMEOUT);
  252. return(0);
  253. case IDM_SAS_SC_INSERT:
  254. PingSAS(WLX_SAS_TYPE_SC_INSERT );
  255. return(0);
  256. case IDM_SAS_SC_REMOVE:
  257. PingSAS( WLX_SAS_TYPE_SC_REMOVE );
  258. return(0);
  259. case IDM_SAS_USERDEF1:
  260. PingSAS(UserDefSas[0].Value);
  261. return(0);
  262. case IDM_SAS_USERDEF2:
  263. PingSAS(UserDefSas[1].Value);
  264. return(0);
  265. case IDM_SAS_USERDEF3:
  266. PingSAS(UserDefSas[2].Value);
  267. return(0);
  268. case IDM_SAS_USERDEF4:
  269. PingSAS(UserDefSas[3].Value);
  270. return(0);
  271. case IDM_SAS_USERDEF:
  272. res = DialogBox( hAppInstance,
  273. MAKEINTRESOURCE(IDD_USERDEF_SAS),
  274. hMainWindow,
  275. SasBoxProc );
  276. if (res != IDCANCEL)
  277. {
  278. PingSAS( res );
  279. }
  280. return( 0 );
  281. case IDM_OPTIONS_SSNOTIFY:
  282. DoSendSS();
  283. return( 0 );
  284. case IDM_OPTIONS_LOGOFF:
  285. DoSendLogoff();
  286. return( 0 );
  287. case IDM_OPTIONS_VIEW_MPR:
  288. DoViewMPR();
  289. return(0);
  290. case IDM_HELP_ABOUT:
  291. ShellAbout(hWnd, TEXT("TestGina"), TEXT("Graphical Logon Tester"), hIcon);
  292. return(0);
  293. case IDM_DEBUG_BREAK_NOW:
  294. if (AmIBeingDebugged())
  295. {
  296. DebugBreak();
  297. }
  298. return(0);
  299. case IDM_DEBUG_NEGOTIATE:
  300. ToggleDebugItem(IDM_DEBUG_NEGOTIATE, BREAK_NEGOTIATE);
  301. return(0);
  302. case IDM_DEBUG_INITIALIZE:
  303. ToggleDebugItem(IDM_DEBUG_INITIALIZE, BREAK_INITIALIZE);
  304. return(0);
  305. case IDM_DEBUG_DISPLAYSAS:
  306. ToggleDebugItem(IDM_DEBUG_DISPLAYSAS, BREAK_DISPLAY);
  307. return(0);
  308. case IDM_DEBUG_LOGGEDOUT:
  309. ToggleDebugItem(IDM_DEBUG_LOGGEDOUT, BREAK_LOGGEDOUT);
  310. return(0);
  311. case IDM_DEBUG_ACTIVATE:
  312. ToggleDebugItem(IDM_DEBUG_ACTIVATE, BREAK_ACTIVATE);
  313. return(0);
  314. case IDM_DEBUG_LOGGEDON:
  315. ToggleDebugItem(IDM_DEBUG_LOGGEDON, BREAK_LOGGEDON);
  316. return(0);
  317. case IDM_DEBUG_DISPLAYLOCKED:
  318. ToggleDebugItem(IDM_DEBUG_DISPLAYLOCKED, BREAK_DISPLAYLOCKED);
  319. return(0);
  320. case IDM_DEBUG_LOCKED:
  321. ToggleDebugItem(IDM_DEBUG_LOCKED, BREAK_WKSTALOCKED);
  322. return(0);
  323. case IDM_DEBUG_LOGOFF:
  324. ToggleDebugItem(IDM_DEBUG_LOGOFF, BREAK_LOGOFF);
  325. return(0);
  326. case IDM_DEBUG_SHUTDOWN:
  327. ToggleDebugItem(IDM_DEBUG_SHUTDOWN, BREAK_SHUTDOWN);
  328. return(0);
  329. }
  330. return 0;
  331. }
  332. LRESULT
  333. CreateMainWindow(
  334. HWND hWnd,
  335. WPARAM wParam,
  336. LPARAM lParam )
  337. {
  338. hStatusWindow = CreateStatusWindow(
  339. WS_CHILD | WS_BORDER | WS_VISIBLE | SBARS_SIZEGRIP,
  340. TEXT("Initializing"),
  341. hWnd,
  342. 10 );
  343. if (hStatusWindow == NULL)
  344. {
  345. return( FALSE );
  346. }
  347. UpdateStatusBar();
  348. return( TRUE );
  349. }
  350. LRESULT
  351. CALLBACK
  352. WndProc(
  353. HWND hWnd,
  354. UINT Message,
  355. WPARAM wParam,
  356. LPARAM lParam)
  357. {
  358. RECT rect;
  359. switch (Message)
  360. {
  361. case WM_CREATE:
  362. return( CreateMainWindow( hWnd, wParam, lParam ) );
  363. case WM_CLOSE:
  364. PostQuitMessage(0);
  365. return(0);
  366. case WM_SIZE:
  367. case WM_MOVE:
  368. if ((Message == WM_SIZE) && (wParam != SIZE_RESTORED))
  369. {
  370. break;
  371. }
  372. GetWindowRect(hWnd, &rect);
  373. PosX = rect.left;
  374. PosY = rect.top;
  375. SizeX = rect.right - rect.left;
  376. SizeY = rect.bottom - rect.top;
  377. SaveParameters();
  378. SendMessage( hStatusWindow, Message, wParam, lParam );
  379. UpdateStatusBar();
  380. return(0);
  381. case WM_HOTKEY:
  382. if (wParam == 0)
  383. {
  384. if (TEST_FLAG(fTestGina, GINA_USE_CAD))
  385. {
  386. PingSAS(WLX_SAS_TYPE_CTRL_ALT_DEL);
  387. }
  388. }
  389. OutputDebugStringA("Got a hotkey!\n");
  390. return(0);
  391. case WM_COMMAND:
  392. return DoCommand(hWnd, Message, wParam, lParam);
  393. }
  394. return(DefWindowProc(hWnd, Message, wParam, lParam));
  395. }