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.

2767 lines
69 KiB

  1. #include "main.h"
  2. #include "UserMode.h"
  3. #include "WinMessages.h"
  4. #include "CUserList.h"
  5. #include "ReportFault.h"
  6. DWORD uTextOffset = 10;
  7. DWORD uBucketWindowSize = 120;
  8. BOOL UserListItemSelected = FALSE;
  9. extern TCHAR szUserColumnHeaders[][100];
  10. extern GLOBAL_POLICY GlobalPolicy;
  11. typedef enum LEVEL {APPNAME, APPVER, MODNAME,MODVER, OFFSET};
  12. extern TCHAR CerRoot[];
  13. extern HINSTANCE g_hinst;
  14. extern HWND hUserMode;
  15. extern CUserList cUserData;
  16. HWND g_hUMListView = NULL;
  17. BOOL g_bUMSortAsc = TRUE;
  18. int g_dwUmodeIndex = -1;
  19. int g_iSelCurrent = -1;
  20. extern BOOL g_bFirstBucket;
  21. extern g_bAdminAccess;
  22. BOOL bCapture = FALSE;
  23. BOOL ParsePolicy( TCHAR *Path, PUSER_DATA pUserData, BOOL Global);
  24. int CALLBACK UmCompareFunc (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  25. {
  26. int Result = -1;
  27. int SubItemIndex = (INT) lParamSort;
  28. int Item1 = 0;
  29. int Item2 = 0;
  30. // int OldIndex = 0;
  31. TCHAR String1 [1000];
  32. TCHAR String2 [1000];
  33. PUSER_DATA pItem1 = NULL;
  34. PUSER_DATA pItem2 = NULL;
  35. ZeroMemory(String1, sizeof String1);
  36. ZeroMemory(String2, sizeof String2);
  37. ListView_GetItemText( g_hUMListView, lParam1, SubItemIndex, String1, 1000);
  38. ListView_GetItemText( g_hUMListView, lParam2, SubItemIndex, String2, 1000);
  39. pItem1 = cUserData.GetEntry(lParam1);
  40. pItem2 = cUserData.GetEntry(lParam2);
  41. if (g_bUMSortAsc) // Sort Acending
  42. {
  43. if ((lParamSort == 0) || (lParamSort == 6) || (lParamSort == 7) || (lParamSort == 8))
  44. {
  45. // Conver to int and compare
  46. Item1 = atoi(String1);
  47. Item2 = atoi(String2);
  48. if (Item1 > Item2)
  49. Result = 1;
  50. else
  51. Result = -1;
  52. }
  53. else
  54. {
  55. Result = _tcsicmp(String1,String2);
  56. }
  57. }
  58. else // Sort Decending
  59. {
  60. if ((lParamSort == 0) || (lParamSort == 6) || (lParamSort == 7) || (lParamSort == 8))
  61. {
  62. // Conver to int and compare
  63. Item1 = atoi(String1);
  64. Item2 = atoi(String2);
  65. if (Item1 > Item2)
  66. Result = -1;
  67. else
  68. Result = 1;
  69. }
  70. else
  71. {
  72. Result = -_tcsicmp(String1,String2);
  73. }
  74. }
  75. return Result;
  76. }
  77. void PopulateFilters(HWND hwnd)
  78. {
  79. COMBOBOXEXITEM cbi;
  80. BOOL bEOF = FALSE;
  81. // int iIndex = 0;
  82. USER_DATA UserData;
  83. HWND hAppnameFltr = GetDlgItem(hwnd, IDC_APPNAME_FILTER);
  84. HWND hAppverFltr = GetDlgItem(hwnd, IDC_APPVER_FILTER);
  85. HWND hModnameFltr = GetDlgItem(hwnd, IDC_MODNAME_FILTER);
  86. HWND hModverFltr = GetDlgItem(hwnd, IDC_MODVER_FILTER);
  87. // Now run through the UserMode linked list and populate the filters.
  88. ZeroMemory(&cbi, sizeof COMBOBOXEXITEM);
  89. ComboBox_ResetContent(hAppnameFltr);
  90. ComboBox_ResetContent(hAppverFltr);
  91. ComboBox_ResetContent(hModnameFltr);
  92. ComboBox_ResetContent(hModverFltr);
  93. ComboBox_InsertString(hAppnameFltr,0,_T("(All Applications)"));
  94. ComboBox_SetCurSel(hAppnameFltr, 0);
  95. ComboBox_InsertString(hAppverFltr,0,_T("(All Application Versions)"));
  96. ComboBox_SetCurSel(hAppverFltr, 0);
  97. ComboBox_InsertString(hModnameFltr,0,_T("(All Modules)"));
  98. ComboBox_SetCurSel(hModnameFltr, 0);
  99. ComboBox_InsertString(hModverFltr,0,_T("(All Module Versions)"));
  100. ComboBox_SetCurSel(hModverFltr, 0);
  101. // Now for each entry in the cUserData Linked list fill in the filters
  102. // Avoiding duplicates if possible.
  103. cUserData.ResetCurrPos();
  104. while(cUserData.GetNextEntry(&UserData, &bEOF))
  105. {
  106. if (ComboBox_FindStringExact(hAppnameFltr, -1, UserData.AppName) == CB_ERR)
  107. ComboBox_InsertString(hAppnameFltr,1,UserData.AppName);
  108. if (ComboBox_FindStringExact(hAppverFltr, -1, UserData.AppVer) == CB_ERR)
  109. ComboBox_InsertString(hAppverFltr,1,UserData.AppVer);
  110. if (ComboBox_FindStringExact(hModnameFltr, -1, UserData.ModName) == CB_ERR)
  111. ComboBox_InsertString(hModnameFltr,1,UserData.ModName);
  112. if (ComboBox_FindStringExact(hModverFltr, -1, UserData.ModVer) == CB_ERR)
  113. ComboBox_InsertString(hModverFltr,1,UserData.ModVer);
  114. }
  115. }
  116. void PopulateFiltersWSelection(HWND hwnd)
  117. {
  118. // COMBOBOXEXITEM cbi;
  119. BOOL bEOF = FALSE;
  120. // int iIndex = 0;
  121. USER_DATA UserData;
  122. HWND hAppnameFltr = GetDlgItem(hwnd, IDC_APPNAME_FILTER);
  123. HWND hAppverFltr = GetDlgItem(hwnd, IDC_APPVER_FILTER);
  124. HWND hModnameFltr = GetDlgItem(hwnd, IDC_MODNAME_FILTER);
  125. HWND hModverFltr = GetDlgItem(hwnd, IDC_MODVER_FILTER);
  126. TCHAR AppNameFilter[MAX_PATH];
  127. TCHAR AppVerFilter[MAX_PATH];
  128. TCHAR ModNameFilter[MAX_PATH];
  129. TCHAR ModVerFilter[MAX_PATH];
  130. BOOL bUseAppName = FALSE;
  131. BOOL bUseAppVer = FALSE;
  132. BOOL bUseModName = FALSE;
  133. BOOL bUseModVer = FALSE;
  134. int iAppNameSel = 0;
  135. int iAppVerSel = 0;
  136. int iModNameSel = 0;
  137. int iModVerSel = 0;
  138. iAppNameSel = ComboBox_GetCurSel(hAppnameFltr);
  139. iAppVerSel = ComboBox_GetCurSel(hAppverFltr);
  140. iModNameSel = ComboBox_GetCurSel(hModnameFltr);
  141. iModVerSel = ComboBox_GetCurSel(hModverFltr);
  142. // Get the current Filter Selection Strings.
  143. if (iAppNameSel != 0)
  144. {
  145. bUseAppName = TRUE;
  146. ComboBox_GetLBText(hAppnameFltr,iAppNameSel, AppNameFilter);
  147. }
  148. if (iAppVerSel != 0)
  149. {
  150. bUseAppVer = TRUE;
  151. ComboBox_GetLBText(hAppverFltr,iAppVerSel, AppVerFilter);
  152. }
  153. if (iModNameSel != 0)
  154. {
  155. bUseModName = TRUE;
  156. ComboBox_GetLBText(hModnameFltr,iModNameSel, ModNameFilter);
  157. }
  158. if (iModVerSel != 0)
  159. {
  160. bUseModVer = TRUE;
  161. ComboBox_GetLBText(hModverFltr,iModVerSel, ModVerFilter);
  162. }
  163. // Now run through the UserMode linked list and populate the filters.
  164. //ZeroMemory(&cbi, sizeof COMBOBOXEXITEM);
  165. ComboBox_ResetContent(hAppnameFltr);
  166. ComboBox_ResetContent(hAppverFltr);
  167. ComboBox_ResetContent(hModnameFltr);
  168. ComboBox_ResetContent(hModverFltr);
  169. ComboBox_InsertString(hAppnameFltr,0,_T("(All Applications)"));
  170. ComboBox_SetCurSel(hAppnameFltr, 0);
  171. ComboBox_InsertString(hAppverFltr,0,_T("(All Application Versions)"));
  172. ComboBox_SetCurSel(hAppverFltr, 0);
  173. ComboBox_InsertString(hModnameFltr,0,_T("(All Modules)"));
  174. ComboBox_SetCurSel(hModnameFltr, 0);
  175. ComboBox_InsertString(hModverFltr,0,_T("(All Module Versions)"));
  176. ComboBox_SetCurSel(hModverFltr, 0);
  177. if (bUseAppName)
  178. {
  179. bUseAppName = TRUE;
  180. //ComboBox_GetLBText(hAppnameFltr,iAppNameSel, AppNameFilter);
  181. ComboBox_InsertString(hAppnameFltr,1,AppNameFilter);
  182. ComboBox_SetCurSel(hAppnameFltr, 1);
  183. }
  184. if (iAppVerSel != 0)
  185. {
  186. bUseAppVer = TRUE;
  187. ComboBox_InsertString(hAppverFltr,1, AppVerFilter);
  188. ComboBox_SetCurSel(hAppverFltr,1);
  189. }
  190. if (iModNameSel != 0)
  191. {
  192. bUseModName = TRUE;
  193. ComboBox_InsertString(hModnameFltr,1, ModNameFilter);
  194. ComboBox_SetCurSel(hModnameFltr,1);
  195. }
  196. if (iModVerSel != 0)
  197. {
  198. bUseModVer = TRUE;
  199. ComboBox_InsertString(hModverFltr,1, ModVerFilter);
  200. ComboBox_SetCurSel (hModverFltr,1);
  201. }
  202. // Now for each entry in the cUserData Linked list fill in the filters
  203. // Based on the previous filter settings.
  204. cUserData.ResetCurrPos();
  205. while(cUserData.GetNextEntry(&UserData, &bEOF))
  206. {
  207. //Add filters here.
  208. if (bUseAppName)
  209. {
  210. // only show entries with the selected application name
  211. if (_tcscmp(AppNameFilter, UserData.AppName))
  212. {
  213. // Nope continue on
  214. goto SkipEntry;
  215. }
  216. }
  217. if (bUseAppVer)
  218. {
  219. if (_tcscmp(AppVerFilter, UserData.AppVer))
  220. {
  221. // Nope continue on
  222. goto SkipEntry;
  223. }
  224. }
  225. if (bUseModName)
  226. {
  227. if (_tcscmp(ModNameFilter, UserData.ModName))
  228. {
  229. // Nope continue on
  230. goto SkipEntry;
  231. }
  232. }
  233. if (bUseModVer)
  234. {
  235. if (_tcscmp(ModVerFilter, UserData.ModVer))
  236. {
  237. // Nope continue on
  238. goto SkipEntry;
  239. }
  240. }
  241. if (ComboBox_FindStringExact(hAppnameFltr, -1, UserData.AppName) == CB_ERR)
  242. ComboBox_InsertString(hAppnameFltr,1,UserData.AppName);
  243. if (ComboBox_FindStringExact(hAppverFltr, -1, UserData.AppVer) == CB_ERR)
  244. ComboBox_InsertString(hAppverFltr,1,UserData.AppVer);
  245. if (ComboBox_FindStringExact(hModnameFltr, -1, UserData.ModName) == CB_ERR)
  246. ComboBox_InsertString(hModnameFltr,1,UserData.ModName);
  247. if (ComboBox_FindStringExact(hModverFltr, -1, UserData.ModVer) == CB_ERR)
  248. ComboBox_InsertString(hModverFltr,1,UserData.ModVer);
  249. SkipEntry:
  250. ;
  251. }
  252. }
  253. void
  254. OnUserDialogInit(
  255. IN HWND hwnd
  256. )
  257. {
  258. DWORD yOffset = 5;
  259. RECT rc;
  260. RECT rcButton;
  261. RECT rcDlg;
  262. RECT rcList;
  263. RECT rcStatic;
  264. //RECT rcVSlider;
  265. HWND hParent = GetParent(hwnd);
  266. HWND hButton = GetDlgItem(hParent, IDC_USERMODE);
  267. HWND hCombo = GetDlgItem(hwnd, IDC_FLTR_RESPONSE);
  268. RECT rcCombo;
  269. HWND hVSlider = GetDlgItem(hwnd, IDC_VERT_SLIDER);
  270. UserListItemSelected = FALSE;
  271. HDC hDC = NULL;
  272. TEXTMETRIC TextMetric;
  273. GetClientRect(hParent, &rc);
  274. GetWindowRect(hButton, &rcButton);
  275. ScreenToClient(hButton, (LPPOINT)&rcButton.left);
  276. ScreenToClient(hButton, (LPPOINT)&rcButton.right);
  277. SetWindowPos(hwnd, HWND_TOP, rc.left + yOffset, rcButton.bottom + yOffset , rc.right - rc.left - yOffset, rc.bottom - rcButton.bottom - yOffset , 0);
  278. GetWindowRect(hwnd, &rcDlg);
  279. ScreenToClient(hwnd, (LPPOINT)&rcDlg.left);
  280. ScreenToClient(hwnd, (LPPOINT)&rcDlg.right);
  281. // Position the List View
  282. GetClientRect(hCombo, &rcCombo);
  283. // Position the List View
  284. HWND hList = GetDlgItem(hwnd, IDC_USER_LIST);
  285. SetWindowPos(hList,NULL, rcDlg.left + yOffset, rcDlg.top + (rcCombo.bottom - rcCombo.top), rcDlg.right - rcDlg.left - yOffset, rcDlg.bottom - uBucketWindowSize - (rcDlg.top + (rcCombo.bottom - rcCombo.top)) , SWP_NOZORDER);
  286. GetWindowRect(hList, &rcList);
  287. ScreenToClient(hList, (LPPOINT)&rcList.left);
  288. ScreenToClient(hList, (LPPOINT)&rcList.right);
  289. SetWindowPos(hVSlider,
  290. NULL,
  291. rcDlg.left + yOffset,
  292. rcList.bottom + (rcCombo.bottom - rcCombo.top) ,
  293. rcDlg.right - rcDlg.left - yOffset,
  294. 6,
  295. SWP_NOZORDER);
  296. // Position the bucket info window.
  297. HWND hBucket2 = GetDlgItem(hwnd, IDC_BUCKETTEXT);
  298. SetWindowPos(hBucket2,
  299. NULL,
  300. rcDlg.left + yOffset,
  301. rcList.bottom + uTextOffset + (rcCombo.bottom - rcCombo.top) ,
  302. 0,
  303. 0,
  304. SWP_NOSIZE | SWP_NOZORDER);
  305. hBucket2 = GetDlgItem(hwnd, IDC_NOTESTEXT);
  306. SetWindowPos(hBucket2,
  307. NULL,
  308. (rcDlg.right - rcDlg.left) /2 + uTextOffset,
  309. rcList.bottom + uTextOffset + (rcCombo.bottom - rcCombo.top),
  310. 0,
  311. 0,
  312. SWP_NOSIZE | SWP_NOZORDER);
  313. SetDlgItemText(hwnd, IDC_BUCKETTEXT,"Bucket Information:");
  314. GetClientRect (hBucket2, &rcStatic);
  315. HWND hBucket = GetDlgItem (hwnd, IDC_USER_EDIT);
  316. if (hBucket)
  317. {
  318. SetWindowPos(hBucket,
  319. NULL,
  320. rcDlg.left + yOffset,
  321. rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top) + 5 ,
  322. (rcDlg.right - rcDlg.left) /2 - yOffset ,
  323. rcDlg.bottom - (rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top)+5 ),
  324. SWP_NOZORDER);
  325. }
  326. HWND hNotes = GetDlgItem (hwnd, IDC_NOTES);
  327. if (hNotes)
  328. {
  329. SetWindowPos(hNotes,
  330. NULL,
  331. (rcDlg.right - rcDlg.left) /2 + uTextOffset,
  332. rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top) + 5 ,
  333. (rcDlg.right - rcDlg.left) /2 - uTextOffset,
  334. rcDlg.bottom - (rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top)+5 ),
  335. SWP_NOZORDER);
  336. }
  337. LVCOLUMN lvc;
  338. int iCol;
  339. // Set the extended styles
  340. ListView_SetExtendedListViewStyleEx(hList,
  341. LVS_EX_GRIDLINES |
  342. LVS_EX_HEADERDRAGDROP |
  343. LVS_EX_FULLROWSELECT,
  344. LVS_EX_GRIDLINES |
  345. LVS_EX_FULLROWSELECT |
  346. LVS_EX_HEADERDRAGDROP);
  347. // Initialize the LVCOLUMN structure.
  348. // The mask specifies that the format, width, text, and subitem
  349. // members of the structure are valid.
  350. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  351. hDC = GetDC(hwnd);
  352. GetTextMetrics(hDC, &TextMetric);
  353. // Add the columns.
  354. for (iCol = 0; iCol < USER_COL_COUNT; iCol++)
  355. {
  356. lvc.iSubItem = iCol;
  357. lvc.pszText = szUserColumnHeaders[iCol];
  358. lvc.cx = _tcslen(szUserColumnHeaders[iCol]) * TextMetric.tmAveCharWidth + 8 ; // width of column in pixels
  359. lvc.fmt = LVCFMT_LEFT; // left-aligned column
  360. if (ListView_InsertColumn(hList, iCol, &lvc) == -1)
  361. {
  362. ;
  363. }
  364. }
  365. ReleaseDC(hwnd, hDC);
  366. ListView_SetColumnWidth(hList, USER_COL_COUNT-1, LVSCW_AUTOSIZE_USEHEADER);
  367. g_hUMListView = hList;
  368. }
  369. void ResizeUserMode(HWND hwnd)
  370. {
  371. DWORD yOffset = 5;
  372. RECT rc;
  373. RECT rcButton;
  374. RECT rcDlg;
  375. RECT rcList;
  376. RECT rcStatic;
  377. HWND hParent = GetParent(hwnd);
  378. HWND hButton = GetDlgItem(hParent, IDC_USERMODE);
  379. HWND hCombo = GetDlgItem(hwnd, IDC_FLTR_RESPONSE);
  380. RECT rcCombo;
  381. HWND hVSlider = GetDlgItem(hwnd, IDC_VERT_SLIDER);
  382. UserListItemSelected = FALSE;
  383. GetClientRect(hParent, &rc);
  384. GetWindowRect(hButton, &rcButton);
  385. ScreenToClient(hButton, (LPPOINT)&rcButton.left);
  386. ScreenToClient(hButton, (LPPOINT)&rcButton.right);
  387. SetWindowPos(hwnd, HWND_TOP, rc.left + yOffset, rcButton.bottom + yOffset , rc.right - rc.left - yOffset, rc.bottom - rcButton.bottom - yOffset , 0);
  388. GetWindowRect(hwnd, &rcDlg);
  389. ScreenToClient(hwnd, (LPPOINT)&rcDlg.left);
  390. ScreenToClient(hwnd, (LPPOINT)&rcDlg.right);
  391. // Position the List View
  392. GetClientRect(hCombo, &rcCombo);
  393. // Position the List View
  394. HWND hList = GetDlgItem(hwnd, IDC_USER_LIST);
  395. SetWindowPos(hList,NULL, rcDlg.left + yOffset, rcDlg.top + (rcCombo.bottom - rcCombo.top) , rcDlg.right - rcDlg.left - yOffset, rcDlg.bottom - uBucketWindowSize - (rcDlg.top + (rcCombo.bottom - rcCombo.top)) , SWP_NOZORDER);
  396. GetWindowRect(hList, &rcList);
  397. ScreenToClient(hList, (LPPOINT)&rcList.left);
  398. ScreenToClient(hList, (LPPOINT)&rcList.right);
  399. SetWindowPos(hVSlider,
  400. NULL,
  401. rcDlg.left + yOffset,
  402. rcList.bottom + (rcCombo.bottom - rcCombo.top) ,
  403. rcDlg.right - rcDlg.left - yOffset,
  404. 6,
  405. SWP_NOZORDER);
  406. // Position the bucket info window.
  407. HWND hBucket2 = GetDlgItem(hwnd, IDC_BUCKETTEXT);
  408. SetWindowPos(hBucket2,
  409. NULL,
  410. rcDlg.left + yOffset,
  411. rcList.bottom + uTextOffset + (rcCombo.bottom - rcCombo.top) ,
  412. 0,
  413. 0,
  414. SWP_NOSIZE | SWP_NOZORDER);
  415. hBucket2 = GetDlgItem(hwnd, IDC_NOTESTEXT);
  416. SetWindowPos(hBucket2,
  417. NULL,
  418. (rcDlg.right - rcDlg.left) /2 + uTextOffset,
  419. rcList.bottom + uTextOffset + (rcCombo.bottom - rcCombo.top) ,
  420. 0,
  421. 0,
  422. SWP_NOSIZE | SWP_NOZORDER);
  423. SetDlgItemText(hwnd, IDC_BUCKETTEXT,"Bucket Information:");
  424. GetClientRect (hBucket2, &rcStatic);
  425. HWND hBucket = GetDlgItem (hwnd, IDC_USER_EDIT);
  426. if (hBucket)
  427. {
  428. SetWindowPos(hBucket,
  429. NULL,
  430. rcDlg.left + yOffset,
  431. rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top) + 5 ,
  432. (rcDlg.right - rcDlg.left) /2 - yOffset ,
  433. rcDlg.bottom - (rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top)+5 ),
  434. SWP_NOZORDER);
  435. }
  436. HWND hNotes = GetDlgItem (hwnd, IDC_NOTES);
  437. if (hNotes)
  438. {
  439. SetWindowPos(hNotes,
  440. NULL,
  441. (rcDlg.right - rcDlg.left) /2 + uTextOffset,
  442. rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top) + 5 ,
  443. (rcDlg.right - rcDlg.left) /2 - uTextOffset,
  444. rcDlg.bottom - (rcList.bottom + uTextOffset + (rcStatic.bottom - rcStatic.top) + (rcCombo.bottom - rcCombo.top)+5 ),
  445. SWP_NOZORDER);
  446. }
  447. ListView_SetColumnWidth(hList, USER_COL_COUNT-1, LVSCW_AUTOSIZE_USEHEADER);
  448. }
  449. void RefreshUserMode(HWND hwnd)
  450. {
  451. LVITEM lvi;
  452. // TCHAR Temp[100];
  453. // double ElapsedTime;
  454. // TCHAR tmpbuf[128];
  455. // COLORREF CurrentColor;
  456. // HWND hEditBox;
  457. // TCHAR TempString [50];
  458. USER_DATA UserData;
  459. BOOL bEOL = FALSE;
  460. TCHAR AppNameFilter[MAX_PATH];
  461. TCHAR AppVerFilter[MAX_PATH];
  462. TCHAR ModNameFilter[MAX_PATH];
  463. TCHAR ModVerFilter[MAX_PATH];
  464. HWND hList = GetDlgItem(hwnd, IDC_USER_LIST);
  465. ZeroMemory(&lvi, sizeof LVITEM);
  466. ListView_DeleteAllItems(hList);
  467. g_dwUmodeIndex = -1;
  468. cUserData.ResetCurrPos();
  469. BOOL bUseAppName = FALSE;
  470. BOOL bUseAppVer = FALSE;
  471. BOOL bUseModName = FALSE;
  472. BOOL bUseModVer = FALSE;
  473. HWND hAppName = GetDlgItem(hwnd, IDC_APPNAME_FILTER);
  474. HWND hAppVer = GetDlgItem(hwnd, IDC_APPVER_FILTER);
  475. HWND hModName = GetDlgItem(hwnd, IDC_MODNAME_FILTER);
  476. HWND hModVer = GetDlgItem(hwnd, IDC_MODVER_FILTER);
  477. int iAppNameSel = 0;
  478. int iAppVerSel = 0;
  479. int iModNameSel = 0;
  480. int iModVerSel = 0;
  481. iAppNameSel = ComboBox_GetCurSel(hAppName);
  482. iAppVerSel = ComboBox_GetCurSel(hAppVer);
  483. iModNameSel = ComboBox_GetCurSel(hModName);
  484. iModVerSel = ComboBox_GetCurSel(hModVer);
  485. g_iSelCurrent = -1;
  486. // Get the current Filter Selection Strings.
  487. if (iAppNameSel != 0)
  488. {
  489. bUseAppName = TRUE;
  490. ComboBox_GetLBText(hAppName,iAppNameSel, AppNameFilter);
  491. }
  492. if (iAppVerSel != 0)
  493. {
  494. bUseAppVer = TRUE;
  495. ComboBox_GetLBText(hAppVer,iAppVerSel, AppVerFilter);
  496. }
  497. if (iModNameSel != 0)
  498. {
  499. bUseModName = TRUE;
  500. ComboBox_GetLBText(hModName,iModNameSel, ModNameFilter);
  501. }
  502. if (iModVerSel != 0)
  503. {
  504. bUseModVer = TRUE;
  505. ComboBox_GetLBText(hModVer,iModVerSel, ModVerFilter);
  506. }
  507. while ( (cUserData.GetNextEntryNoMove(&UserData, &bEOL)) && (!bEOL) )
  508. {
  509. //Add filters here.
  510. if (bUseAppName)
  511. {
  512. // only show entries with the selected application name
  513. if (_tcscmp(AppNameFilter, UserData.AppName))
  514. {
  515. // Nope continue on
  516. goto SkipEntry;
  517. }
  518. }
  519. if (bUseAppVer)
  520. {
  521. if (_tcscmp(AppVerFilter, UserData.AppVer))
  522. {
  523. // Nope continue on
  524. goto SkipEntry;
  525. }
  526. }
  527. if (bUseModName)
  528. {
  529. if (_tcscmp(ModNameFilter, UserData.ModName))
  530. {
  531. // Nope continue on
  532. goto SkipEntry;
  533. }
  534. }
  535. if (bUseModVer)
  536. {
  537. if (_tcscmp(ModVerFilter, UserData.ModVer))
  538. {
  539. // Nope continue on
  540. goto SkipEntry;
  541. }
  542. }
  543. ++g_dwUmodeIndex;
  544. cUserData.SetIndex(g_dwUmodeIndex);
  545. lvi.mask = LVIF_TEXT | LVIF_PARAM ;
  546. /*if (g_dwUmodeIndex == 0)
  547. {
  548. lvi.state = LVIS_SELECTED | LVIS_FOCUSED;
  549. lvi.stateMask = (UINT)-1;
  550. UserListItemSelected = TRUE;
  551. g_iSelCurrent = 0;
  552. }
  553. else
  554. {
  555. lvi.state= 0;
  556. lvi.stateMask = 0;
  557. }
  558. */
  559. lvi.iItem = g_dwUmodeIndex ;
  560. lvi.iSubItem = 0;
  561. lvi.pszText = UserData.Status.BucketID;
  562. lvi.lParam = g_dwUmodeIndex;
  563. ListView_InsertItem(hList,&lvi);
  564. lvi.mask = LVIF_TEXT ;
  565. // lvi.iItem = g_dwUmodeIndex ;
  566. lvi.iSubItem = 1;
  567. lvi.pszText = UserData.AppName;
  568. ListView_SetItem(hList,&lvi);
  569. // lvi.iItem = g_dwUmodeIndex ;
  570. lvi.iSubItem = 2;
  571. lvi.pszText = UserData.AppVer;
  572. ListView_SetItem(hList,&lvi);
  573. // lvi.iItem = g_dwUmodeIndex ;
  574. lvi.iSubItem = 3;
  575. lvi.pszText = UserData.ModName ;
  576. ListView_SetItem(hList,&lvi);
  577. // lvi.iItem = g_dwUmodeIndex ;
  578. lvi.iSubItem = 4;
  579. lvi.pszText = UserData.ModVer;
  580. ListView_SetItem(hList,&lvi);
  581. // lvi.iItem = g_dwUmodeIndex ;
  582. lvi.iSubItem = 5;
  583. lvi.pszText = UserData.Offset;
  584. ListView_SetItem(hList,&lvi);
  585. // lvi.iItem = g_dwUmodeIndex ;
  586. lvi.iSubItem = 6;
  587. lvi.pszText = UserData.Hits;
  588. ListView_SetItem(hList,&lvi);
  589. // lvi.iItem = g_dwUmodeIndex ;
  590. lvi.iSubItem = 7;
  591. lvi.pszText = UserData.Cabs;
  592. ListView_SetItem(hList,&lvi);
  593. // lvi.iItem = g_dwUmodeIndex ;
  594. lvi.iSubItem = 8;
  595. lvi.pszText = UserData.CabCount;
  596. ListView_SetItem(hList,&lvi);
  597. lvi.iSubItem = 9;
  598. if ( (UserData.Status.GetFile[0] != _T('\0')) || (!_tcscmp(UserData.Status.fDoc, _T("1"))))
  599. {
  600. lvi.pszText=_T("Advanced"); // Advanced
  601. }
  602. else
  603. {
  604. if ( (UserData.Status.RegKey[0] != _T('\0')) ||
  605. (UserData.Status.WQL[0] != _T('\0')) ||
  606. (UserData.Status.GetFileVersion[0] != _T('\0')) ||
  607. ( !_tcscmp(UserData.Status.MemoryDump, _T("1"))) )
  608. {
  609. lvi.pszText=_T("Basic"); // Basic Collection
  610. }
  611. else
  612. lvi.pszText = _T("");
  613. }
  614. ListView_SetItem(hList,&lvi);
  615. lvi.iSubItem = 10;
  616. lvi.pszText = _T("");
  617. if (!_tcscmp(UserData.Status.SecondLevelData,_T("\0")))
  618. {
  619. // Use Global
  620. if( (!_tcscmp(GlobalPolicy.AllowBasic, _T("NO"))) || (!_tcscmp(GlobalPolicy.AllowBasic, _T("\0"))) )
  621. {
  622. lvi.pszText=_T("Basic"); // basic
  623. }
  624. }
  625. else
  626. {
  627. if ((!_tcscmp(UserData.Status.SecondLevelData,_T("NO"))) || (!_tcscmp(UserData.Status.SecondLevelData,_T("\0"))) )
  628. {
  629. lvi.pszText=_T("Basic"); // basic
  630. }
  631. }
  632. if ( !_tcscmp (UserData.Status.FileCollection, _T("\0")))
  633. {
  634. if ((!_tcscmp(GlobalPolicy.AllowAdvanced, _T("NO"))) || (!_tcscmp(GlobalPolicy.AllowAdvanced, _T("\0"))))
  635. {
  636. lvi.pszText=_T("Advanced"); // Advanced
  637. }
  638. }
  639. else
  640. {
  641. if ((!_tcscmp(UserData.Status.FileCollection,_T("NO")))|| (!_tcscmp(UserData.Status.FileCollection,_T("\0"))))
  642. {
  643. lvi.pszText=_T("Advanced"); // Advanced
  644. }
  645. }
  646. /*
  647. if ( ((!_tcscmp(UserData.Status.FileCollection,_T("NO"))) || (!_tcscmp(UserData.Status.FileCollection,_T("\0")))) && ( (!_tcscmp(GlobalPolicy.AllowAdvanced, _T("NO"))) || (!_tcscmp(GlobalPolicy.AllowAdvanced, _T("\0")))) )
  648. {
  649. lvi.pszText=_T("Advanced"); // Advanced
  650. }
  651. else
  652. {
  653. if ( ( (!_tcscmp(UserData.Status.SecondLevelData,_T("NO"))) || (!_tcscmp(UserData.Status.SecondLevelData,_T("\0"))) ) && ( (!_tcscmp(GlobalPolicy.AllowBasic, _T("NO"))) || (!_tcscmp(GlobalPolicy.AllowBasic, _T("\0"))) ) )
  654. {
  655. lvi.pszText=_T("Basic"); // Advanced
  656. }
  657. }
  658. */
  659. ListView_SetItem(hList,&lvi);
  660. lvi.pszText = _T("");
  661. if (_tcscmp(UserData.Status.Response, _T("1")) && _tcscmp(UserData.Status.Response, _T("\0")) )
  662. {
  663. lvi.iSubItem = 11;
  664. lvi.pszText = UserData.Status.Response;
  665. ListView_SetItem(hList,&lvi);
  666. }
  667. lvi.iSubItem = 12;
  668. lvi.pszText = _T("");
  669. if (_tcscmp(UserData.Status.UrlToLaunch, _T("\0")))
  670. {
  671. lvi.pszText = UserData.Status.UrlToLaunch ;
  672. }
  673. else
  674. {
  675. // try the default policy
  676. lvi.pszText = GlobalPolicy.CustomURL;
  677. }
  678. ListView_SetItem(hList,&lvi);
  679. SkipEntry:
  680. cUserData.MoveNext(&bEOL);
  681. }
  682. SendMessage(GetDlgItem(hwnd,IDC_USER_EDIT ), WM_SETTEXT, NULL, (LPARAM)_T(""));
  683. if (g_iSelCurrent == -1)
  684. {
  685. SendMessage(GetDlgItem(hwnd,IDC_NOTES ), WM_SETTEXT, NULL, (LPARAM)_T(""));
  686. }
  687. //DisplayUserBucketData(hwnd, g_iSelCurrent);
  688. PopulateFiltersWSelection(hwnd);
  689. //UserListItemSelected = FALSE;
  690. }
  691. BOOL VerifyFileAccess(TCHAR *szPath, BOOL fOptional)
  692. {
  693. HANDLE hFile = CreateFile(szPath, GENERIC_READ | GENERIC_WRITE | DELETE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
  694. if ((hFile == INVALID_HANDLE_VALUE) && !((GetLastError() == ERROR_FILE_NOT_FOUND) ||(GetLastError() == ERROR_PATH_NOT_FOUND)))
  695. {
  696. MessageBox(NULL, _T("You do not have the required Administrative access to the selected CER file tree.\r\nAs a result, administrative options will be disabled."), NULL, MB_OK | MB_TASKMODAL);
  697. g_bFirstBucket = FALSE;
  698. return FALSE;
  699. }
  700. if (hFile == INVALID_HANDLE_VALUE)
  701. {
  702. // Try to Create the Status.txt file
  703. hFile = CreateFile(szPath, GENERIC_READ | GENERIC_WRITE | DELETE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL);
  704. if (hFile == INVALID_HANDLE_VALUE)
  705. {
  706. MessageBox(NULL, _T("You do not have the required Administrative access to the selected CER file tree.\r\nAs a result, administrative options will be disabled."), NULL, MB_OK | MB_TASKMODAL);
  707. g_bFirstBucket = FALSE;
  708. return FALSE;
  709. }
  710. else
  711. {
  712. CloseHandle(hFile);
  713. hFile = INVALID_HANDLE_VALUE;
  714. g_bFirstBucket = FALSE;
  715. return TRUE;
  716. }
  717. }
  718. g_bFirstBucket = FALSE;
  719. if (hFile != INVALID_HANDLE_VALUE)
  720. CloseHandle(hFile);
  721. return TRUE;
  722. }
  723. //////////////////////////////////////////////////////////////////
  724. // Get user mode Data
  725. /////////////////////////////////////////////////////////////////
  726. BOOL ParseCountsFile(PUSER_DATA UserData)
  727. {
  728. FILE *pFile = NULL;
  729. TCHAR Buffer[100];
  730. TCHAR *Temp = NULL;
  731. BOOL Status = TRUE;
  732. ZeroMemory(Buffer,sizeof Buffer);
  733. pFile = _tfopen(UserData->CountPath, _T("r"));
  734. if (pFile)
  735. {
  736. // Get the Cabs Gathered Count
  737. if (!_fgetts(Buffer, sizeof Buffer, pFile))
  738. {
  739. Status = FALSE;
  740. goto ERRORS;
  741. }
  742. // Remove \r\n and
  743. Temp = Buffer;
  744. while ( (*Temp != _T('\r')) && (*Temp != _T('\n')) && (*Temp != _T('\0')) )
  745. {
  746. ++Temp;
  747. }
  748. *Temp = _T('\0');
  749. Temp = _tcsstr(Buffer, _T("="));
  750. if (Temp)
  751. {
  752. ++Temp; // move path the = sign
  753. if (StringCbCopy(UserData->Cabs, sizeof UserData->Cabs, Temp) != S_OK)
  754. {
  755. Status = FALSE;
  756. goto ERRORS;
  757. }
  758. }
  759. // Get the Total Hits Count
  760. ZeroMemory(Buffer,sizeof Buffer);
  761. if (! _fgetts(Buffer, sizeof Buffer, pFile))
  762. {
  763. Status = FALSE;
  764. goto ERRORS;
  765. }
  766. Temp = Buffer;
  767. while ( (*Temp != _T('\r')) && (*Temp != _T('\n')) && (*Temp != _T('\0')) )
  768. {
  769. ++Temp;
  770. }
  771. *Temp = _T('\0');
  772. Temp = _tcsstr(Buffer, _T("="));
  773. if (Temp)
  774. {
  775. ++Temp; // move path the = sign
  776. if (StringCbCopy(UserData->Hits, sizeof UserData->Hits, Temp) != S_OK)
  777. {
  778. Status = FALSE;
  779. goto ERRORS;
  780. }
  781. }
  782. fclose(pFile);
  783. pFile = NULL;
  784. Status = TRUE;
  785. }
  786. else
  787. {
  788. Status = FALSE;
  789. }
  790. pFile = NULL;
  791. UserData->iReportedCount = 0;
  792. pFile = _tfopen(UserData->ReportedCountPath, _T("r"));
  793. if (pFile)
  794. {
  795. // Get the Cabs Gathered Count
  796. ZeroMemory (Buffer,sizeof Buffer);
  797. if (!_fgetts(Buffer, sizeof Buffer, pFile))
  798. {
  799. Status = FALSE;
  800. goto ERRORS;
  801. }
  802. // Remove \r\n and
  803. Temp = Buffer;
  804. while ( (*Temp != _T('\r')) && (*Temp != _T('\n')) && (*Temp != _T('\0')) )
  805. {
  806. ++Temp;
  807. }
  808. *Temp = _T('\0');
  809. Temp = _tcsstr(Buffer, _T("="));
  810. if (Temp)
  811. {
  812. ++Temp; // move past the = sign
  813. UserData->iReportedCount = _ttoi (Temp);
  814. }
  815. fclose(pFile);
  816. pFile = NULL;
  817. Status = TRUE;
  818. }
  819. else
  820. {
  821. Status = FALSE;
  822. }
  823. ERRORS:
  824. if (pFile)
  825. {
  826. fclose(pFile);
  827. }
  828. return Status;
  829. }
  830. BOOL ParseStatusFile(PUSER_DATA UserData)
  831. {
  832. FILE *pFile = NULL;
  833. TCHAR Buffer[1024];
  834. // TCHAR szTempDir[MAX_PATH];
  835. TCHAR *Temp = NULL;
  836. // int id = 0;
  837. ZeroMemory(Buffer,sizeof Buffer);
  838. pFile = _tfopen(UserData->StatusPath, _T("r"));
  839. if (pFile)
  840. {
  841. // Get the Cabs Gathered Count
  842. if (!_fgetts(Buffer, sizeof Buffer, pFile))
  843. {
  844. goto ERRORS;
  845. }
  846. do
  847. {
  848. // Remove \r\n and force termination of the buffer.
  849. Temp = Buffer;
  850. while ( (*Temp != _T('\r')) && (*Temp != _T('\n')) && (*Temp != _T('\0')) )
  851. {
  852. ++Temp;
  853. }
  854. *Temp = _T('\0');
  855. Temp = _tcsstr(Buffer, BUCKET_PREFIX);
  856. if (Temp == Buffer)
  857. {
  858. Temp+= _tcslen(BUCKET_PREFIX);
  859. if (StringCbCopy(UserData->Status.BucketID, sizeof UserData->Status.BucketID, Temp) != S_OK)
  860. {
  861. goto ERRORS;
  862. }
  863. continue;
  864. }
  865. Temp = _tcsstr(Buffer,RESPONSE_PREFIX);
  866. if (Temp == Buffer)
  867. {
  868. Temp+= _tcslen(RESPONSE_PREFIX);
  869. if (StringCbCopy(UserData->Status.Response, sizeof UserData->Status.Response, Temp) != S_OK)
  870. {
  871. goto ERRORS;
  872. }
  873. continue;
  874. }
  875. Temp = _tcsstr(Buffer, URLLAUNCH_PREFIX);
  876. if (Temp == Buffer)
  877. {
  878. Temp+= _tcslen(URLLAUNCH_PREFIX);
  879. if (StringCbCopy(UserData->Status.UrlToLaunch , sizeof UserData->Status.UrlToLaunch , Temp) != S_OK)
  880. {
  881. goto ERRORS;
  882. }
  883. continue;
  884. }
  885. Temp = _tcsstr(Buffer, SECOND_LEVEL_DATA_PREFIX);
  886. if (Temp==Buffer)
  887. {
  888. Temp+= _tcslen(SECOND_LEVEL_DATA_PREFIX);
  889. if (StringCbCopy(UserData->Status.SecondLevelData , sizeof UserData->Status.SecondLevelData , Temp) != S_OK)
  890. {
  891. goto ERRORS;
  892. }
  893. continue;
  894. }
  895. Temp = _tcsstr(Buffer, TRACKING_PREFIX);
  896. if (Temp==Buffer)
  897. {
  898. Temp+= _tcslen(TRACKING_PREFIX);
  899. if (StringCbCopy(UserData->Status.Tracking , sizeof UserData->Status.Tracking , Temp) != S_OK)
  900. {
  901. goto ERRORS;
  902. }
  903. continue;
  904. }
  905. Temp = _tcsstr(Buffer, CRASH_PERBUCKET_PREFIX);
  906. if (Temp==Buffer)
  907. {
  908. Temp+= _tcslen(CRASH_PERBUCKET_PREFIX);
  909. if (StringCbCopy(UserData->Status.CrashPerBucketCount , sizeof UserData->Status.CrashPerBucketCount , Temp) != S_OK)
  910. {
  911. goto ERRORS;
  912. }
  913. continue;
  914. }
  915. Temp = _tcsstr(Buffer, FILE_COLLECTION_PREFIX);
  916. if (Temp==Buffer)
  917. {
  918. Temp+= _tcslen(FILE_COLLECTION_PREFIX);
  919. if (StringCbCopy(UserData->Status.FileCollection , sizeof UserData->Status.FileCollection, Temp) != S_OK)
  920. {
  921. goto ERRORS;
  922. }
  923. continue;
  924. }
  925. Temp = _tcsstr(Buffer, REGKEY_PREFIX);
  926. if (Temp==Buffer)
  927. {
  928. Temp+= _tcslen(REGKEY_PREFIX);
  929. if (StringCbCopy(UserData->Status.RegKey , sizeof UserData->Status.RegKey , Temp) != S_OK)
  930. {
  931. goto ERRORS;
  932. }
  933. continue;
  934. }
  935. Temp = _tcsstr(Buffer, FDOC_PREFIX);
  936. if (Temp==Buffer)
  937. {
  938. Temp+= _tcslen(FDOC_PREFIX);
  939. if (StringCbCopy(UserData->Status.fDoc , sizeof UserData->Status.fDoc , Temp) != S_OK)
  940. {
  941. goto ERRORS;
  942. }
  943. continue;
  944. }
  945. Temp = _tcsstr(Buffer, IDATA_PREFIX);
  946. if (Temp==Buffer)
  947. {
  948. Temp+= _tcslen(IDATA_PREFIX);
  949. if (StringCbCopy(UserData->Status.iData , sizeof UserData->Status.iData , Temp) != S_OK)
  950. {
  951. goto ERRORS;
  952. }
  953. continue;
  954. }
  955. Temp = _tcsstr(Buffer, WQL_PREFIX);
  956. if (Temp==Buffer)
  957. {
  958. Temp+= _tcslen(WQL_PREFIX);
  959. if (StringCbCopy(UserData->Status.WQL , sizeof UserData->Status.WQL , Temp) != S_OK)
  960. {
  961. goto ERRORS;
  962. }
  963. continue;
  964. }
  965. Temp = _tcsstr(Buffer, GETFILE_PREFIX);
  966. if (Temp==Buffer)
  967. {
  968. Temp+= _tcslen(GETFILE_PREFIX);
  969. if (StringCbCopy(UserData->Status.GetFile , sizeof UserData->Status.GetFile, Temp) != S_OK)
  970. {
  971. goto ERRORS;
  972. }
  973. continue;
  974. }
  975. Temp = _tcsstr(Buffer, GETFILEVER_PREFIX);
  976. if (Temp==Buffer)
  977. {
  978. Temp+= _tcslen(GETFILEVER_PREFIX);
  979. if (StringCbCopy(UserData->Status.GetFileVersion , sizeof UserData->Status.GetFileVersion , Temp) != S_OK)
  980. {
  981. goto ERRORS;
  982. }
  983. continue;
  984. }
  985. Temp = _tcsstr(Buffer, MEMDUMP_PREFIX);
  986. if (Temp==Buffer)
  987. {
  988. Temp+= _tcslen(MEMDUMP_PREFIX);
  989. if (StringCbCopy(UserData->Status.MemoryDump , sizeof UserData->Status.MemoryDump, Temp) != S_OK)
  990. {
  991. goto ERRORS;
  992. }
  993. continue;
  994. }
  995. Temp = _tcsstr(Buffer, ALLOW_EXTERNAL_PREFIX);
  996. if (Temp==Buffer)
  997. {
  998. Temp+= _tcslen(ALLOW_EXTERNAL_PREFIX);
  999. if (StringCbCopy(UserData->Status.AllowResponse , sizeof UserData->Status.AllowResponse, Temp) != S_OK)
  1000. {
  1001. goto ERRORS;
  1002. }
  1003. continue;
  1004. }
  1005. ZeroMemory(Buffer, sizeof Buffer);
  1006. } while (_fgetts(Buffer, sizeof Buffer, pFile));
  1007. fclose(pFile);
  1008. return TRUE;
  1009. }
  1010. else
  1011. {
  1012. return FALSE;
  1013. }
  1014. ERRORS:
  1015. if (pFile)
  1016. {
  1017. fclose(pFile);
  1018. }
  1019. return FALSE;
  1020. }
  1021. BOOL CreateStatusDir(TCHAR *szPath)
  1022. {
  1023. if (!PathIsDirectory(szPath))
  1024. return CreateDirectory(szPath,NULL);
  1025. else
  1026. return TRUE;
  1027. }
  1028. BOOL IsHexDigit(TCHAR Digit)
  1029. {
  1030. if ((_T('0') <= Digit && Digit <= _T('9')) ||
  1031. (_T('A') <= Digit && Digit <= _T('F')) ||
  1032. (_T('a') <= Digit && Digit <= _T('f')))
  1033. return TRUE;
  1034. return FALSE;
  1035. }
  1036. BOOL GetBucketData(HWND hwnd, TCHAR *FilePath, int iLevel)
  1037. /*
  1038. Recursively process the user mode filetree schema
  1039. */
  1040. {
  1041. WIN32_FIND_DATA FindData;
  1042. HANDLE hFind = INVALID_HANDLE_VALUE;
  1043. TCHAR szSubPath [MAX_PATH];
  1044. TCHAR szSearchPath[MAX_PATH];
  1045. TCHAR szTempDir[MAX_PATH];
  1046. PUSER_DATA NewNode = NULL;
  1047. TCHAR *Temp;
  1048. HANDLE hCabFind = INVALID_HANDLE_VALUE;
  1049. WIN32_FIND_DATA CabFindData;
  1050. // TCHAR szPolicyFilePath[MAX_PATH];
  1051. int iCabCount;
  1052. if (iLevel != OFFSET)
  1053. {
  1054. if (StringCbPrintf(szSearchPath,sizeof szSearchPath, _T("%s\\*.*"), FilePath) != S_OK)
  1055. {
  1056. goto ERRORS;
  1057. }
  1058. }
  1059. else
  1060. {
  1061. if (StringCbPrintf(szSearchPath,sizeof szSearchPath, _T("%s\\*.cab"), FilePath) != S_OK)
  1062. {
  1063. goto ERRORS;
  1064. }
  1065. }
  1066. if (iLevel < OFFSET)
  1067. {
  1068. hFind = FindFirstFile(szSearchPath, &FindData);
  1069. if ( hFind != INVALID_HANDLE_VALUE)
  1070. {
  1071. do
  1072. {
  1073. // find the next directory
  1074. // skip the . and ..
  1075. if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  1076. {
  1077. // recursively call ourselves with the level incremented.
  1078. if ( (_tcscmp(FindData.cFileName, _T("."))) && (_tcscmp(FindData.cFileName, _T(".."))) )
  1079. {
  1080. if (StringCbPrintf( szSubPath,
  1081. sizeof szSubPath,
  1082. _T("%s\\%s"),
  1083. FilePath,
  1084. FindData.cFileName) != S_OK)
  1085. {
  1086. goto ERRORS;
  1087. }
  1088. GetBucketData(hwnd, szSubPath, iLevel+1);
  1089. }
  1090. }
  1091. }while (FindNextFile(hFind, &FindData));
  1092. FindClose(hFind);
  1093. hFind = INVALID_HANDLE_VALUE;
  1094. }
  1095. else
  1096. {
  1097. // This is an invalid case
  1098. // we are done with this tree segment
  1099. goto ERRORS;
  1100. }
  1101. }
  1102. if (iLevel == OFFSET)
  1103. {
  1104. // Verify that this directory name meets the OFFSET criteria
  1105. Temp = FilePath + _tcslen(FilePath) * sizeof TCHAR;
  1106. while ((*Temp != _T('\\')))
  1107. {
  1108. --Temp;
  1109. }
  1110. if ( (_tcslen(Temp+1) == 8) || (_tcslen(Temp+1) == 16) )
  1111. {
  1112. // The string should be hex
  1113. for (UINT i = 0; i < _tcslen(Temp+1); i++)
  1114. {
  1115. if (!IsHexDigit(Temp[i+1]))
  1116. {
  1117. goto DONE;
  1118. }
  1119. }
  1120. }
  1121. else
  1122. {
  1123. // Failed
  1124. goto DONE;
  1125. }
  1126. /* if ( !IsStringHexDigits (Temp))
  1127. {
  1128. // Nope
  1129. goto DONE;
  1130. }
  1131. */
  1132. // If we made it here we are calling it good.
  1133. // We should now be at a leaf node.
  1134. NewNode = (PUSER_DATA) malloc (sizeof (USER_DATA));
  1135. // Now we need to parse the path into it's component parts
  1136. if (!NewNode )
  1137. {
  1138. goto ERRORS;
  1139. }
  1140. ZeroMemory(NewNode, sizeof USER_DATA);
  1141. if (StringCbCopy(NewNode->BucketPath, sizeof NewNode->BucketPath, FilePath)!= S_OK)
  1142. {
  1143. goto ERRORS;
  1144. }
  1145. Temp = FilePath + _tcslen(FilePath) * sizeof TCHAR;
  1146. while ((*Temp != _T('\\')))
  1147. {
  1148. --Temp;
  1149. }
  1150. // Copy Temp+1 into Offset
  1151. if (StringCbCopy(NewNode->Offset, sizeof NewNode->Offset, Temp+1) != S_OK)
  1152. {
  1153. goto ERRORS;
  1154. }
  1155. else
  1156. {
  1157. if (_tcslen (NewNode->Offset) == 16)
  1158. {
  1159. NewNode->Is64Bit = TRUE;
  1160. }
  1161. }
  1162. *Temp = _T('\0');
  1163. while ((*Temp != _T('\\')))
  1164. {
  1165. --Temp;
  1166. }
  1167. if (StringCbCopy(NewNode->ModVer, sizeof NewNode->ModVer, Temp+1) != S_OK)
  1168. {
  1169. goto ERRORS;
  1170. }
  1171. *Temp = _T('\0');
  1172. while ((*Temp != _T('\\')))
  1173. {
  1174. --Temp;
  1175. }
  1176. if (StringCbCopy(NewNode->ModName, sizeof NewNode->ModName, Temp+1) != S_OK)
  1177. {
  1178. goto ERRORS;
  1179. }
  1180. *Temp = _T('\0');
  1181. while ((*Temp != _T('\\')))
  1182. {
  1183. --Temp;
  1184. }
  1185. if (StringCbCopy(NewNode->AppVer, sizeof NewNode->AppVer, Temp+1) != S_OK)
  1186. {
  1187. goto ERRORS;
  1188. }
  1189. *Temp = _T('\0');
  1190. while ((*Temp != _T('\\')))
  1191. {
  1192. --Temp;
  1193. }
  1194. if (StringCbCopy(NewNode->AppName, sizeof NewNode->AppName, Temp+1) != S_OK)
  1195. {
  1196. goto ERRORS;
  1197. }
  1198. // MessageBox(NULL, NewNode->AppName, "AddingNode",MB_OK);
  1199. // Count the number of unprocessed cabs.
  1200. iCabCount = 0;
  1201. hCabFind = FindFirstFile(szSearchPath, &CabFindData);
  1202. if (hCabFind != INVALID_HANDLE_VALUE)
  1203. {
  1204. do
  1205. {
  1206. ++iCabCount;
  1207. }
  1208. while (FindNextFile(hCabFind, &FindData));
  1209. FindClose (hCabFind);
  1210. }
  1211. else
  1212. {
  1213. iCabCount = 0;
  1214. }
  1215. _itot(iCabCount, NewNode->CabCount, 10);
  1216. // Read the status.txt file for each entry in the Data Structure ?
  1217. // Build path to Status file
  1218. if (StringCbPrintf(NewNode->StatusPath,
  1219. sizeof NewNode->StatusPath,
  1220. _T("%s\\Status\\%s\\%s\\%s\\%s\\%s\\Status.txt"),
  1221. CerRoot,
  1222. NewNode->AppName,
  1223. NewNode->AppVer,
  1224. NewNode->ModName,
  1225. NewNode->ModVer,
  1226. NewNode->Offset
  1227. ) != S_OK)
  1228. {
  1229. goto ERRORS;
  1230. }
  1231. if (StringCbPrintf(szTempDir,
  1232. sizeof szTempDir,
  1233. _T("%s\\Status\\%s\\%s\\%s\\%s\\%s"),
  1234. CerRoot,
  1235. NewNode->AppName,
  1236. NewNode->AppVer,
  1237. NewNode->ModName,
  1238. NewNode->ModVer,
  1239. NewNode->Offset
  1240. ) != S_OK)
  1241. {
  1242. goto ERRORS;
  1243. }
  1244. if (!PathIsDirectory(szTempDir))
  1245. {
  1246. // Let's create it
  1247. if (StringCbPrintf(szTempDir,
  1248. sizeof szTempDir,
  1249. _T("%s\\Status"),CerRoot)!= S_OK)
  1250. {
  1251. goto ERRORS;
  1252. }
  1253. else
  1254. {
  1255. if (CreateStatusDir(szTempDir))
  1256. {
  1257. // Next
  1258. if (StringCbCat(szTempDir, sizeof szTempDir,_T("\\")) !=S_OK)
  1259. {
  1260. goto ERRORS;
  1261. }
  1262. if (StringCbCat(szTempDir, sizeof szTempDir, NewNode->AppName) !=S_OK)
  1263. {
  1264. goto ERRORS;
  1265. }
  1266. if (CreateStatusDir(szTempDir))
  1267. {
  1268. if (StringCbCat(szTempDir, sizeof szTempDir,_T("\\")) !=S_OK)
  1269. {
  1270. goto ERRORS;
  1271. }
  1272. if (StringCbCat(szTempDir, sizeof szTempDir, NewNode->AppVer) !=S_OK)
  1273. {
  1274. goto ERRORS;
  1275. }
  1276. if (CreateStatusDir(szTempDir))
  1277. {
  1278. if (StringCbCat(szTempDir, sizeof szTempDir,_T("\\")) !=S_OK)
  1279. {
  1280. goto ERRORS;
  1281. }
  1282. if (StringCbCat(szTempDir, sizeof szTempDir, NewNode->ModName) !=S_OK)
  1283. {
  1284. goto ERRORS;
  1285. }
  1286. if (CreateStatusDir(szTempDir))
  1287. {
  1288. if (StringCbCat(szTempDir, sizeof szTempDir,_T("\\")) !=S_OK)
  1289. {
  1290. goto ERRORS;
  1291. }
  1292. if (StringCbCat(szTempDir, sizeof szTempDir, NewNode->ModVer) !=S_OK)
  1293. {
  1294. goto ERRORS;
  1295. }
  1296. if (CreateStatusDir(szTempDir))
  1297. {
  1298. if (StringCbCat(szTempDir, sizeof szTempDir,_T("\\")) !=S_OK)
  1299. {
  1300. goto ERRORS;
  1301. }
  1302. if (StringCbCat(szTempDir, sizeof szTempDir, NewNode->Offset) !=S_OK)
  1303. {
  1304. goto ERRORS;
  1305. }
  1306. CreateStatusDir(szTempDir);
  1307. }
  1308. }
  1309. }
  1310. }
  1311. }
  1312. }
  1313. }
  1314. //Verify That we can create and delete a file from the status directory
  1315. if (g_bFirstBucket)
  1316. {
  1317. // Build the file name
  1318. if (!VerifyFileAccess(NewNode->StatusPath, FALSE))
  1319. {
  1320. g_bAdminAccess = FALSE;
  1321. }
  1322. }
  1323. ParseStatusFile(NewNode);
  1324. // Read the counts file for each entry in the data structure. ?
  1325. // Build path to counts file
  1326. if (StringCbPrintf(NewNode->CountPath,
  1327. sizeof NewNode->CountPath,
  1328. _T("%s\\Counts\\%s\\%s\\%s\\%s\\%s\\count.txt"),
  1329. CerRoot,
  1330. NewNode->AppName,
  1331. NewNode->AppVer,
  1332. NewNode->ModName,
  1333. NewNode->ModVer,
  1334. NewNode->Offset
  1335. ) != S_OK)
  1336. {
  1337. goto ERRORS;
  1338. }
  1339. if (StringCbPrintf(NewNode->ReportedCountPath,
  1340. sizeof NewNode->ReportedCountPath,
  1341. _T("%s\\Counts\\%s\\%s\\%s\\%s\\%s\\RepCounts.txt"),
  1342. CerRoot,
  1343. NewNode->AppName,
  1344. NewNode->AppVer,
  1345. NewNode->ModName,
  1346. NewNode->ModVer,
  1347. NewNode->Offset
  1348. ) != S_OK)
  1349. {
  1350. goto ERRORS;
  1351. }
  1352. ParseCountsFile(NewNode);
  1353. // Update the linked list
  1354. cUserData.AddNode(NewNode);
  1355. // Update Progress Bar
  1356. //if (Pos == 99)
  1357. //{
  1358. // SendDlgItemMessage(hwnd, IDC_LOADPB, PBM_SETPOS,
  1359. }
  1360. DONE:
  1361. --iLevel;
  1362. return TRUE; // Prefix Note: This is not a memory leak the node will be freed when the
  1363. // linked list is freed in the cUserData destructor
  1364. ERRORS:
  1365. if (hFind != INVALID_HANDLE_VALUE)
  1366. {
  1367. FindClose(hFind);
  1368. }
  1369. return FALSE;
  1370. }
  1371. BOOL ParsePolicy( TCHAR *Path, PUSER_DATA pUserData, BOOL Global)
  1372. {
  1373. // Same basic parsing of Status file
  1374. // Will cleanup at a later date.
  1375. FILE *pFile = NULL;
  1376. TCHAR Buffer[MAX_PATH + 10];
  1377. // TCHAR szTempDir[MAX_PATH];
  1378. TCHAR *Temp = NULL;
  1379. // int id = 0;
  1380. ZeroMemory(Buffer,sizeof Buffer);
  1381. ZeroMemory(&GlobalPolicy, sizeof GLOBAL_POLICY);
  1382. pFile = _tfopen(Path, _T("r"));
  1383. if (pFile)
  1384. {
  1385. // Get the Cabs Gathered Count
  1386. if (!_fgetts(Buffer, sizeof Buffer, pFile))
  1387. {
  1388. goto ERRORS;
  1389. }
  1390. do
  1391. {
  1392. // Remove \r\n and force termination of the buffer.
  1393. Temp = Buffer;
  1394. while ( (*Temp != _T('\r')) && (*Temp != _T('\n')) && (*Temp != _T('\0')) )
  1395. {
  1396. ++Temp;
  1397. }
  1398. *Temp = _T('\0');
  1399. Temp = _tcsstr(Buffer, URLLAUNCH_PREFIX);
  1400. if (Temp == Buffer)
  1401. {
  1402. Temp+= _tcslen(URLLAUNCH_PREFIX);
  1403. if (Global)
  1404. {
  1405. if (StringCbCopy(GlobalPolicy.CustomURL , sizeof GlobalPolicy.CustomURL , Temp) != S_OK)
  1406. {
  1407. goto ERRORS;
  1408. }
  1409. }
  1410. else
  1411. {
  1412. if (StringCbCopy(pUserData->Policy.CustomURL , sizeof pUserData->Policy.CustomURL , Temp) != S_OK)
  1413. {
  1414. goto ERRORS;
  1415. }
  1416. }
  1417. continue;
  1418. }
  1419. Temp = _tcsstr(Buffer, SECOND_LEVEL_DATA_PREFIX);
  1420. if (Temp==Buffer)
  1421. {
  1422. Temp+= _tcslen(SECOND_LEVEL_DATA_PREFIX);
  1423. if (Global)
  1424. {
  1425. if (StringCbCopy(GlobalPolicy.AllowBasic , sizeof GlobalPolicy.AllowBasic , Temp) != S_OK)
  1426. {
  1427. goto ERRORS;
  1428. }
  1429. }
  1430. else
  1431. {
  1432. if (StringCbCopy(pUserData->Policy.AllowBasic , sizeof pUserData->Policy.AllowBasic , Temp) != S_OK)
  1433. {
  1434. goto ERRORS;
  1435. }
  1436. }
  1437. continue;
  1438. }
  1439. Temp = _tcsstr(Buffer, FILE_COLLECTION_PREFIX);
  1440. if (Temp==Buffer)
  1441. {
  1442. Temp+= _tcslen(FILE_COLLECTION_PREFIX);
  1443. if (Global)
  1444. {
  1445. if (StringCbCopy(GlobalPolicy.AllowAdvanced , sizeof GlobalPolicy.AllowAdvanced, Temp) != S_OK)
  1446. {
  1447. goto ERRORS;
  1448. }
  1449. }
  1450. else
  1451. {
  1452. if (StringCbCopy(pUserData->Policy.AllowAdvanced , sizeof pUserData->Policy.AllowAdvanced, Temp) != S_OK)
  1453. {
  1454. goto ERRORS;
  1455. }
  1456. }
  1457. continue;
  1458. }
  1459. Temp = _tcsstr(Buffer, TRACKING_PREFIX);
  1460. if (Temp==Buffer)
  1461. {
  1462. Temp+= _tcslen(TRACKING_PREFIX);
  1463. if (Global)
  1464. {
  1465. if (StringCbCopy(GlobalPolicy.EnableCrashTracking , sizeof GlobalPolicy.EnableCrashTracking , Temp) != S_OK)
  1466. {
  1467. goto ERRORS;
  1468. }
  1469. }
  1470. else
  1471. {
  1472. if (StringCbCopy(pUserData->Policy.EnableCrashTracking , sizeof pUserData->Policy.EnableCrashTracking , Temp) != S_OK)
  1473. {
  1474. goto ERRORS;
  1475. }
  1476. }
  1477. continue;
  1478. }
  1479. Temp = _tcsstr(Buffer, CRASH_PERBUCKET_PREFIX);
  1480. if (Temp==Buffer)
  1481. {
  1482. Temp+= _tcslen(CRASH_PERBUCKET_PREFIX);
  1483. if (Global)
  1484. {
  1485. if (StringCbCopy(GlobalPolicy.CabsPerBucket , sizeof GlobalPolicy.CabsPerBucket , Temp) != S_OK)
  1486. {
  1487. goto ERRORS;
  1488. }
  1489. }
  1490. else
  1491. {
  1492. if (StringCbCopy(pUserData->Policy.CabsPerBucket , sizeof pUserData->Policy.CabsPerBucket , Temp) != S_OK)
  1493. {
  1494. goto ERRORS;
  1495. }
  1496. }
  1497. continue;
  1498. }
  1499. Temp = _tcsstr(Buffer, ALLOW_EXTERNAL_PREFIX);
  1500. if (Temp==Buffer)
  1501. {
  1502. Temp+= _tcslen(ALLOW_EXTERNAL_PREFIX);
  1503. if (Global)
  1504. {
  1505. if (StringCbCopy(GlobalPolicy.AllowMicrosoftResponse , sizeof GlobalPolicy.AllowMicrosoftResponse , Temp) != S_OK)
  1506. {
  1507. goto ERRORS;
  1508. }
  1509. }
  1510. else
  1511. {
  1512. if (StringCbCopy(pUserData->Policy.AllowMicrosoftResponse , sizeof pUserData->Policy.AllowMicrosoftResponse , Temp) != S_OK)
  1513. {
  1514. goto ERRORS;
  1515. }
  1516. }
  1517. continue;
  1518. }
  1519. if (Global) // This entry is not available on a per bucket basis.
  1520. {
  1521. Temp = _tcsstr(Buffer, FILE_TREE_ROOT_PREFIX);
  1522. if (Temp==Buffer)
  1523. {
  1524. Temp+= _tcslen(FILE_TREE_ROOT_PREFIX);
  1525. if (StringCbCopy(GlobalPolicy.RedirectFileServer , sizeof GlobalPolicy.RedirectFileServer , Temp) != S_OK)
  1526. {
  1527. goto ERRORS;
  1528. }
  1529. continue;
  1530. }
  1531. }
  1532. ZeroMemory(Buffer, sizeof Buffer);
  1533. } while (_fgetts(Buffer, sizeof Buffer, pFile));
  1534. fclose(pFile);
  1535. return TRUE;
  1536. }
  1537. else
  1538. {
  1539. return FALSE;
  1540. }
  1541. ERRORS:
  1542. if (pFile)
  1543. {
  1544. fclose(pFile);
  1545. }
  1546. return FALSE;
  1547. }
  1548. BOOL GetAllBuckets(HWND hwnd)
  1549. {
  1550. WIN32_FIND_DATA FindData;
  1551. HANDLE hFind = INVALID_HANDLE_VALUE;
  1552. TCHAR szSearchPattern[MAX_PATH];
  1553. TCHAR szSubPath[MAX_PATH];
  1554. int iDirCount = 0;
  1555. TCHAR PolicyPath[MAX_PATH];
  1556. // Parse the global Policy
  1557. if (StringCbPrintf(PolicyPath, sizeof PolicyPath,_T("%s\\policy.txt"), CerRoot) != S_OK)
  1558. {
  1559. goto ERRORS;
  1560. }
  1561. ParsePolicy(PolicyPath,
  1562. NULL, // Use the Global Policy Structure.
  1563. TRUE); // Set to true if Global policy False = selected.
  1564. // Start with a clean Linked List.
  1565. cUserData.CleanupList();
  1566. if (StringCbPrintf(szSearchPattern,sizeof szSearchPattern,_T("%s\\cabs\\*.*"), CerRoot) != S_OK)
  1567. {
  1568. ; // Need to define error case handling code here.
  1569. }
  1570. // Count all the directories and set the progress bar range.
  1571. hFind = FindFirstFile(szSearchPattern, &FindData);
  1572. if (hFind != INVALID_HANDLE_VALUE)
  1573. {
  1574. do
  1575. {
  1576. if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  1577. {
  1578. // skip the . and .. directories.
  1579. if ( (_tcscmp(FindData.cFileName, _T("."))) && (_tcscmp(FindData.cFileName, _T(".."))) )
  1580. {
  1581. ++iDirCount;
  1582. }
  1583. }
  1584. } while (FindNextFile(hFind, &FindData));
  1585. FindClose (hFind);
  1586. hFind = INVALID_HANDLE_VALUE;
  1587. //if (iDirCount > 100)
  1588. //iDirCount = 100;
  1589. // SetDlgItemText(hwnd, IDC_STATIC1, _T("Reading current status of user mode tree..."));
  1590. SendDlgItemMessage(hwnd, IDC_LOADPB, PBM_SETRANGE, 0, MAKELPARAM(0, iDirCount));
  1591. SendDlgItemMessage(hwnd, IDC_LOADPB, PBM_SETSTEP, 1, 0);
  1592. }
  1593. else
  1594. {
  1595. goto ERRORS;
  1596. }
  1597. hFind = FindFirstFile(szSearchPattern, &FindData);
  1598. if (hFind != INVALID_HANDLE_VALUE)
  1599. {
  1600. if ( hFind != INVALID_HANDLE_VALUE)
  1601. {
  1602. do
  1603. {
  1604. if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  1605. {
  1606. // skip the . and .. directories.
  1607. if ( (_tcscmp(FindData.cFileName, _T("."))) && (_tcscmp(FindData.cFileName, _T(".."))) )
  1608. {
  1609. // now skip the blue shutdown and appcompat
  1610. if (_tcscmp(FindData.cFileName, _T("blue")) &&
  1611. _tcscmp(FindData.cFileName, _T("shutdown")) &&
  1612. _tcscmp(FindData.cFileName, _T("appcompat")) )
  1613. {
  1614. if (StringCbPrintf(szSubPath, sizeof szSubPath, _T("%s\\cabs\\%s"), CerRoot, FindData.cFileName)!= S_OK)
  1615. {
  1616. goto ERRORS;
  1617. }
  1618. SetDlgItemText(hwnd, IDC_SUBDIR, szSubPath);
  1619. GetBucketData(hwnd, szSubPath, APPNAME);
  1620. SendDlgItemMessage(hwnd,IDC_LOADPB, PBM_STEPIT, 0,0);
  1621. }
  1622. }
  1623. }
  1624. }while (FindNextFile(hFind, &FindData));
  1625. FindClose(hFind);
  1626. hFind = INVALID_HANDLE_VALUE;
  1627. }
  1628. }
  1629. PopulateFilters(hUserMode);
  1630. return TRUE;
  1631. ERRORS:
  1632. if (hFind != INVALID_HANDLE_VALUE)
  1633. {
  1634. FindClose(hFind);
  1635. }
  1636. return FALSE;
  1637. }
  1638. void
  1639. OnUserContextMenu(HWND hwnd,
  1640. LPARAM lParam )
  1641. /*++
  1642. Routine Description:
  1643. This routine Loads and provides a message pump for the User mode context menu
  1644. Arguments:
  1645. hwnd - Handle of the Kernel mode dialog box
  1646. lParam - Not Used
  1647. Return value:
  1648. Does not return a value
  1649. ++*/
  1650. {
  1651. BOOL Result = FALSE;
  1652. HMENU hMenu = NULL;
  1653. HMENU hmenuPopup = NULL;
  1654. int xPos, yPos;
  1655. hMenu = LoadMenu(g_hinst, MAKEINTRESOURCE( IDR_USERCONTEXT));
  1656. hmenuPopup = GetSubMenu (hMenu,0);
  1657. if (!hmenuPopup)
  1658. {
  1659. //MessageBox(NULL,"Failed to get sub item", NULL,MB_OK);
  1660. ;
  1661. }
  1662. else
  1663. {
  1664. // Grey out the menu items
  1665. EnableMenuItem (hMenu, ID_REPORT_ALL, MF_BYCOMMAND| MF_GRAYED);
  1666. EnableMenuItem (hMenu, ID_REPORT_ALLUSERMODEFAULTS, MF_BYCOMMAND| MF_GRAYED);
  1667. EnableMenuItem (hMenu, ID_REPORT_SELECTEDBUCKET, MF_BYCOMMAND| MF_GRAYED);
  1668. EnableMenuItem (hMenu, ID_VIEW_MICROSOFTRESPONSE, MF_BYCOMMAND| MF_GRAYED);
  1669. EnableMenuItem (hMenu, ID_VIEW_BUCKETOVERRIDERESPONSE155, MF_BYCOMMAND| MF_GRAYED);
  1670. EnableMenuItem (hMenu, ID_VIEW_REFRESH140, MF_BYCOMMAND| MF_GRAYED);
  1671. EnableMenuItem (hMenu, ID_VIEW_REFRESH121, MF_BYCOMMAND| MF_GRAYED);
  1672. EnableMenuItem (hMenu, ID_VIEW_CRASHLOG, MF_BYCOMMAND| MF_GRAYED);
  1673. //EnableMenuItem (hMenu, ID_EDIT_COPY144, MF_BYCOMMAND| MF_GRAYED);
  1674. //EnableMenuItem (hMenu, ID_EDIT_DEFAULTREPORTINGOPTIONS, MF_BYCOMMAND| MF_GRAYED);
  1675. EnableMenuItem (hMenu, ID_EDIT_USERMODEREPORTINGOPTIONS, MF_BYCOMMAND| MF_GRAYED);
  1676. EnableMenuItem (hMenu, ID_EDIT_SELECTEDBUCKETREPORTINGOPTIONS, MF_BYCOMMAND| MF_GRAYED);
  1677. //EnableMenuItem (hMenu, ID_EXPORT_USERMODEFAULTDATA174, MF_BYCOMMAND| MF_GRAYED);
  1678. EnableMenuItem (hMenu, ID_VIEW_BUCKETCABFILEDIRECTORY157, MF_BYCOMMAND| MF_GRAYED);
  1679. if (_tcscmp(CerRoot, _T("\0")))
  1680. {
  1681. EnableMenuItem (hMenu, ID_REPORT_ALL, MF_BYCOMMAND| MF_ENABLED);
  1682. EnableMenuItem (hMenu, ID_REPORT_ALLUSERMODEFAULTS, MF_BYCOMMAND| MF_ENABLED);
  1683. EnableMenuItem (hMenu, ID_REPORT_SELECTEDBUCKET, MF_BYCOMMAND| MF_ENABLED);
  1684. EnableMenuItem (hMenu, ID_VIEW_MICROSOFTRESPONSE, MF_BYCOMMAND| MF_ENABLED);
  1685. EnableMenuItem (hMenu, ID_VIEW_BUCKETOVERRIDERESPONSE155, MF_BYCOMMAND| MF_ENABLED);
  1686. EnableMenuItem (hMenu, ID_VIEW_REFRESH140, MF_BYCOMMAND| MF_ENABLED);
  1687. EnableMenuItem (hMenu, ID_VIEW_REFRESH121, MF_BYCOMMAND| MF_ENABLED);
  1688. EnableMenuItem (hMenu, ID_VIEW_CRASHLOG, MF_BYCOMMAND| MF_ENABLED);
  1689. //EnableMenuItem (hMenu, ID_EDIT_COPY144, MF_BYCOMMAND| MF_ENABLED);
  1690. //EnableMenuItem (hMenu, ID_EDIT_DEFAULTREPORTINGOPTIONS, MF_BYCOMMAND| MF_ENABLED);
  1691. EnableMenuItem (hMenu, ID_EDIT_USERMODEREPORTINGOPTIONS, MF_BYCOMMAND| MF_ENABLED);
  1692. EnableMenuItem (hMenu, ID_EDIT_SELECTEDBUCKETREPORTINGOPTIONS, MF_BYCOMMAND| MF_ENABLED);
  1693. //EnableMenuItem (hMenu, ID_EXPORT_USERMODEFAULTDATA174, MF_BYCOMMAND| MF_ENABLED);
  1694. EnableMenuItem (hMenu, ID_VIEW_BUCKETCABFILEDIRECTORY157, MF_BYCOMMAND| MF_ENABLED);
  1695. if ( !g_bAdminAccess)
  1696. {
  1697. EnableMenuItem (hMenu, ID_REPORT_ALL, MF_BYCOMMAND| MF_GRAYED);
  1698. EnableMenuItem (hMenu, ID_REPORT_ALLUSERMODEFAULTS, MF_BYCOMMAND| MF_GRAYED);
  1699. EnableMenuItem (hMenu, ID_REPORT_SELECTEDBUCKET, MF_BYCOMMAND| MF_GRAYED);
  1700. EnableMenuItem (hMenu, ID_EDIT_USERMODEREPORTINGOPTIONS, MF_BYCOMMAND| MF_GRAYED);
  1701. EnableMenuItem (hMenu, ID_EDIT_SELECTEDBUCKETREPORTINGOPTIONS, MF_BYCOMMAND| MF_GRAYED);
  1702. }
  1703. }
  1704. xPos = GET_X_LPARAM(lParam);
  1705. yPos = GET_Y_LPARAM(lParam);
  1706. Result = TrackPopupMenu (hmenuPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, xPos,yPos,0,hwnd,NULL);
  1707. }
  1708. if (hMenu)
  1709. DestroyMenu(hMenu);
  1710. }
  1711. void ViewResponse(HWND hwnd, BOOL bMSResponse)
  1712. /*++
  1713. Routine Description:
  1714. This routine Launches the system default Web browser useing shellexec
  1715. Arguments:
  1716. hwnd - Handle of the Kernel mode dialog box
  1717. Return value:
  1718. Does not return a value
  1719. ++*/
  1720. {
  1721. TCHAR Url [255];
  1722. HWND hList = GetDlgItem(hwnd, IDC_USER_LIST);
  1723. int sel;
  1724. // LVITEM lvi;
  1725. if (!hList)
  1726. return;
  1727. ZeroMemory (Url, sizeof Url);
  1728. sel = ListView_GetNextItem(hList,-1, LVNI_SELECTED);
  1729. // Now get the lParam for this item
  1730. if (bMSResponse)
  1731. {
  1732. ListView_GetItemText(hList, sel,11, Url,sizeof Url);
  1733. }
  1734. else
  1735. {
  1736. ListView_GetItemText(hList, sel,12, Url,sizeof Url);
  1737. }
  1738. if ( (!_tcsncicmp(Url, _T("http://"), _tcslen(_T("http://")))) || (!_tcsncicmp(Url, _T("https://"), _tcslen(_T("https://")))) )
  1739. {
  1740. SHELLEXECUTEINFOA sei = {0};
  1741. sei.cbSize = sizeof(sei);
  1742. sei.lpFile = Url;
  1743. sei.nShow = SW_SHOWDEFAULT;
  1744. if (! ShellExecuteEx(&sei) )
  1745. {
  1746. // What do we display here.
  1747. ;
  1748. }
  1749. }
  1750. }
  1751. void ErrorLoadTree()
  1752. {
  1753. MessageBox(NULL, _T("To complete the requested operation you must first load a file tree"), NULL,MB_OK);
  1754. }
  1755. void ViewBucketDir(HWND hwnd)
  1756. {
  1757. TCHAR szPath[MAX_PATH];
  1758. // TCHAR TempBuffer[MAX_PATH];
  1759. PUSER_DATA pUserData;
  1760. LVITEM lvi;
  1761. int sel;
  1762. HWND hList = GetDlgItem(hwnd, IDC_USER_LIST);
  1763. sel = ListView_GetNextItem(hList,-1, LVNI_SELECTED);
  1764. lvi.iItem = sel;
  1765. lvi.mask = LVIF_PARAM;
  1766. ListView_GetItem(hList, &lvi);
  1767. sel = lvi.lParam;
  1768. pUserData = cUserData.GetEntry(sel);
  1769. if (pUserData)
  1770. {
  1771. if (StringCbPrintf(szPath, sizeof szPath, _T("%s\\cabs\\%s\\%s\\%s\\%s\\%s"),
  1772. CerRoot,
  1773. pUserData->AppName,
  1774. pUserData->AppVer,
  1775. pUserData->ModName,
  1776. pUserData->ModVer,
  1777. pUserData->Offset) != S_OK)
  1778. {
  1779. return;
  1780. }
  1781. else
  1782. {
  1783. SHELLEXECUTEINFOA sei = {0};
  1784. sei.cbSize = sizeof(sei);
  1785. sei.lpFile = szPath;
  1786. sei.nShow = SW_SHOWDEFAULT;
  1787. if (! ShellExecuteEx(&sei) )
  1788. {
  1789. // What do we display here.
  1790. ;
  1791. }
  1792. }
  1793. }
  1794. }
  1795. BOOL WriteNotesFile(HWND hwnd)
  1796. {
  1797. TCHAR szNotesPath[MAX_PATH];
  1798. // TCHAR TempBuffer[MAX_PATH];
  1799. PUSER_DATA pUserData;
  1800. // int sel;
  1801. TCHAR *Buffer = NULL;
  1802. DWORD dwBufferSize = 100000; // 100000 bytes or 50K Unicode characters
  1803. HANDLE hFile = INVALID_HANDLE_VALUE;
  1804. TCHAR *Temp = NULL;
  1805. Buffer = (TCHAR *) malloc (dwBufferSize);
  1806. if (!Buffer)
  1807. {
  1808. goto ERRORS;
  1809. }
  1810. ZeroMemory(Buffer,dwBufferSize);
  1811. DWORD dwBytesWritten = 0;
  1812. // Get current notes file text
  1813. GetDlgItemText(hwnd, IDC_NOTES, Buffer, dwBufferSize / sizeof TCHAR - sizeof TCHAR);
  1814. // Get Current selected item Index
  1815. pUserData = cUserData.GetEntry(g_iSelCurrent);
  1816. if (pUserData)
  1817. {
  1818. if (StringCbCopy(szNotesPath, sizeof szNotesPath, pUserData->StatusPath)!= S_OK)
  1819. {
  1820. goto ERRORS;
  1821. }
  1822. Temp = _tcsstr(szNotesPath, _T("Status.txt"));
  1823. if (!Temp)
  1824. {
  1825. goto ERRORS;
  1826. }
  1827. else
  1828. {
  1829. *Temp = _T('\0');
  1830. if (StringCbCat(szNotesPath, sizeof szNotesPath, _T("Notes.txt")) != S_OK)
  1831. {
  1832. goto ERRORS;
  1833. }
  1834. hFile = CreateFile(szNotesPath, GENERIC_WRITE, NULL,NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
  1835. if (hFile != INVALID_HANDLE_VALUE)
  1836. {
  1837. WriteFile(hFile, Buffer, _tcslen(Buffer)*sizeof TCHAR, &dwBytesWritten, NULL);
  1838. }
  1839. CloseHandle(hFile);
  1840. }
  1841. }
  1842. if (g_iSelCurrent == -1)
  1843. {
  1844. SendMessage(GetDlgItem(hwnd,IDC_NOTES ), WM_SETTEXT, NULL, (LPARAM)_T(""));
  1845. }
  1846. //SetWindowText(GetDlgItem(hwnd,IDC_NOTES ),_T(""));
  1847. ERRORS:
  1848. if (Buffer)
  1849. free(Buffer);
  1850. return TRUE;
  1851. }
  1852. BOOL DisplayUserBucketData(HWND hwnd, int iItem)
  1853. {
  1854. HWND hEditBox = GetDlgItem(hwnd, IDC_USER_EDIT);
  1855. HANDLE hFile = INVALID_HANDLE_VALUE;
  1856. TCHAR NotesFilePath[MAX_PATH];
  1857. PUSER_DATA pUserData = NULL;
  1858. TCHAR *Temp = NULL;
  1859. DWORD dwBytesRead = 0;
  1860. TCHAR *Source = NULL;
  1861. TCHAR *Dest = NULL;
  1862. TCHAR TempBuffer[1000];
  1863. TCHAR *Buffer = NULL; // we have to use a dynamic buffer since we don't
  1864. // have a clue as to the text length.
  1865. DWORD BufferLength = 100000; // 100k bytes should be plenty. or 50K unicode chars.
  1866. Buffer = (TCHAR *) malloc (BufferLength);
  1867. if (Buffer)
  1868. {
  1869. ZeroMemory(Buffer,BufferLength);
  1870. if (g_iSelCurrent == -1)
  1871. {
  1872. SendMessage(GetDlgItem(hwnd,IDC_NOTES ), WM_SETTEXT, NULL, (LPARAM)_T(""));
  1873. }
  1874. //SetWindowText(GetDlgItem(hwnd,IDC_NOTES ),_T(""));
  1875. pUserData = cUserData.GetEntry(iItem);
  1876. if (pUserData)
  1877. {
  1878. // Build the strings for the Edit box.
  1879. // Basic data collection first.
  1880. if ( (!_tcscmp (pUserData->Status.SecondLevelData, _T("YES"))) && (_tcscmp(pUserData->Status.FileCollection, _T("YES"))) )
  1881. {
  1882. if (StringCbPrintf(Buffer, BufferLength, _T("The following information will be sent to Microsoft.\r\n\tHowever, this bucket's policy would prevent files and user documents from being reported.\r\n"))!= S_OK)
  1883. {
  1884. goto ERRORS;
  1885. }
  1886. }
  1887. else
  1888. {
  1889. if ( !_tcscmp (pUserData->Status.SecondLevelData, _T("YES")))
  1890. {
  1891. if (StringCbPrintf(Buffer, BufferLength, _T("Microsoft would like to collect the following information but the default policy prevents the exchange.\r\n"))!= S_OK)
  1892. {
  1893. goto ERRORS;
  1894. }
  1895. }
  1896. else
  1897. {
  1898. if (!_tcscmp(pUserData->Status.FileCollection, _T("YES")))
  1899. {
  1900. if (StringCbCat(Buffer,BufferLength, _T(" Microsoft would like to collect the following information but default policy\r\n\tprevents files and user documents from being reported.\r\n\t As a result, no exchange will take place.\r\n"))!= S_OK)
  1901. {
  1902. goto ERRORS;
  1903. }
  1904. }
  1905. else
  1906. {
  1907. if (StringCbPrintf(Buffer, BufferLength, _T("The following information will be sent to Microsoft:\r\n"))!= S_OK)
  1908. {
  1909. goto ERRORS;
  1910. }
  1911. }
  1912. }
  1913. }
  1914. if (_tcscmp(pUserData->Status.GetFile, _T("\0")))
  1915. {
  1916. if (StringCbCat(Buffer, BufferLength, _T("These files:\r\n"))!= S_OK)
  1917. {
  1918. goto ERRORS;
  1919. }
  1920. Source = pUserData->Status.GetFile;
  1921. while ((*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n')) )
  1922. {
  1923. ZeroMemory (TempBuffer, sizeof TempBuffer);
  1924. Dest = TempBuffer;
  1925. while ( (*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n'))&& (*Source != _T(';') ))
  1926. {
  1927. *Dest = *Source;
  1928. ++Dest;
  1929. ++Source;
  1930. }
  1931. if (*Source == _T(';'))
  1932. {
  1933. ++Source;
  1934. }
  1935. *Dest =_T('\0');
  1936. if (StringCbCat(Dest, sizeof TempBuffer, _T("\r\n")) != S_OK)
  1937. {
  1938. goto ERRORS;
  1939. }
  1940. if (StringCbCat(Buffer, BufferLength, _T("\t") )!= S_OK)
  1941. {
  1942. goto ERRORS;
  1943. }
  1944. if (StringCbCat(Buffer, BufferLength, TempBuffer )!= S_OK)
  1945. {
  1946. goto ERRORS;
  1947. }
  1948. }
  1949. }
  1950. if (_tcscmp(pUserData->Status.RegKey, _T("\0")))
  1951. {
  1952. if (StringCbCat(Buffer, BufferLength, _T("These Registry Keys:\r\n"))!= S_OK)
  1953. {
  1954. goto ERRORS;
  1955. }
  1956. Source = pUserData->Status.RegKey;
  1957. while ((*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n')) )
  1958. {
  1959. ZeroMemory (TempBuffer, sizeof TempBuffer);
  1960. Dest = TempBuffer;
  1961. while ( (*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n'))&& (*Source != _T(';') ))
  1962. {
  1963. *Dest = *Source;
  1964. ++Dest;
  1965. ++Source;
  1966. }
  1967. if (*Source == _T(';'))
  1968. {
  1969. ++Source;
  1970. }
  1971. *Dest =_T('\0');
  1972. if (StringCbCat(Dest, sizeof TempBuffer, _T("\r\n")) != S_OK)
  1973. {
  1974. goto ERRORS;
  1975. }
  1976. if (StringCbCat(Buffer, BufferLength, _T("\t") )!= S_OK)
  1977. {
  1978. goto ERRORS;
  1979. }
  1980. if (StringCbCat(Buffer, BufferLength, TempBuffer )!= S_OK)
  1981. {
  1982. goto ERRORS;
  1983. }
  1984. }
  1985. }
  1986. if (_tcscmp(pUserData->Status.WQL, _T("\0")))
  1987. {
  1988. if (StringCbCat(Buffer, BufferLength, _T("The Results of these WQL queries:\r\n"))!= S_OK)
  1989. {
  1990. goto ERRORS;
  1991. }
  1992. // Replace ; with \t\r\n
  1993. Source = pUserData->Status.WQL;
  1994. while ((*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n')) )
  1995. {
  1996. ZeroMemory (TempBuffer, sizeof TempBuffer);
  1997. Dest = TempBuffer;
  1998. while ( (*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n'))&& (*Source != _T(';') ))
  1999. {
  2000. *Dest = *Source;
  2001. ++Dest;
  2002. ++Source;
  2003. }
  2004. if (*Source == _T(';'))
  2005. {
  2006. ++Source;
  2007. }
  2008. *Dest =_T('\0');
  2009. if (StringCbCat(Dest, sizeof TempBuffer, _T("\r\n")) != S_OK)
  2010. {
  2011. goto ERRORS;
  2012. }
  2013. if (StringCbCat(Buffer, BufferLength, _T("\t") )!= S_OK)
  2014. {
  2015. goto ERRORS;
  2016. }
  2017. if (StringCbCat(Buffer, BufferLength, TempBuffer )!= S_OK)
  2018. {
  2019. goto ERRORS;
  2020. }
  2021. }
  2022. }
  2023. if (!_tcscmp (pUserData->Status.MemoryDump, _T("1")))
  2024. {
  2025. if (StringCbCat(Buffer, BufferLength, _T("The contents of global memory\r\n"))!= S_OK)
  2026. {
  2027. goto ERRORS;
  2028. }
  2029. }
  2030. if (_tcscmp(pUserData->Status.GetFileVersion, _T("\0")))
  2031. {
  2032. if (StringCbCat(Buffer, BufferLength, _T("The versions of these files:\r\n"))!= S_OK)
  2033. {
  2034. goto ERRORS;
  2035. }
  2036. Source = pUserData->Status.GetFileVersion;
  2037. while ((*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n')) )
  2038. {
  2039. ZeroMemory (TempBuffer, sizeof TempBuffer);
  2040. Dest = TempBuffer;
  2041. while ( (*Source != _T('\0')) && (*Source != _T('\r')) && (*Source != _T('\n'))&& (*Source != _T(';') ))
  2042. {
  2043. *Dest = *Source;
  2044. ++Dest;
  2045. ++Source;
  2046. }
  2047. if (*Source == _T(';'))
  2048. {
  2049. ++Source;
  2050. }
  2051. *Dest =_T('\0');
  2052. if (StringCbCat(Dest, sizeof TempBuffer, _T("\r\n")) != S_OK)
  2053. {
  2054. goto ERRORS;
  2055. }
  2056. if (StringCbCat(Buffer, BufferLength, _T("\t") )!= S_OK)
  2057. {
  2058. goto ERRORS;
  2059. }
  2060. if (StringCbCat(Buffer, BufferLength, TempBuffer )!= S_OK)
  2061. {
  2062. goto ERRORS;
  2063. }
  2064. }
  2065. }
  2066. if (!_tcscmp(pUserData->Status.fDoc, _T("1")))
  2067. {
  2068. if (StringCbCat(Buffer, BufferLength, _T("The users current document.\r\n"))!= S_OK)
  2069. {
  2070. goto ERRORS;
  2071. }
  2072. }
  2073. SendMessage(hEditBox, WM_SETTEXT, NULL, (LPARAM)Buffer);
  2074. // Now display the Notes file
  2075. // Use the same buffer. Just truncate if it doesn't fit
  2076. ZeroMemory(Buffer, BufferLength);
  2077. if (StringCbCopy(NotesFilePath, sizeof NotesFilePath, pUserData->StatusPath)!= S_OK)
  2078. {
  2079. goto ERRORS;
  2080. }
  2081. Temp = _tcsstr(NotesFilePath, _T("Status.txt"));
  2082. if (!Temp)
  2083. {
  2084. goto ERRORS;
  2085. }
  2086. else
  2087. {
  2088. *Temp = _T('\0');
  2089. if (StringCbCat(NotesFilePath, sizeof NotesFilePath, _T("Notes.txt")) != S_OK)
  2090. {
  2091. goto ERRORS;
  2092. }
  2093. hFile = CreateFile(NotesFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL);
  2094. if (hFile != INVALID_HANDLE_VALUE)
  2095. {
  2096. if (ReadFile(hFile, Buffer, BufferLength - sizeof TCHAR, &dwBytesRead, NULL))
  2097. {
  2098. SendMessage(GetDlgItem(hwnd,IDC_NOTES ), WM_SETTEXT, NULL, (LPARAM) Buffer);
  2099. }
  2100. CloseHandle (hFile);
  2101. }
  2102. }
  2103. }
  2104. }
  2105. ERRORS:
  2106. if (Buffer)
  2107. free(Buffer);
  2108. return TRUE;
  2109. }
  2110. /*
  2111. void UMCopyToClipboard(HWND hwnd )
  2112. {
  2113. if (!OpenClipboard(NULL))
  2114. return;
  2115. EmptyClipboard();
  2116. char rtfRowHeader[sizeof(rtfRowHeader1) + (sizeof(rtfRowHeader2)+6)*USER_COL_COUNT + sizeof(rtfRowHeader3)];
  2117. char *rtfWalk = rtfRowHeader;
  2118. memcpy(rtfWalk, rtfRowHeader1, sizeof(rtfRowHeader1));
  2119. rtfWalk += sizeof(rtfRowHeader1)-1;
  2120. DWORD cxTotal = 0;
  2121. for(int i=0;i<USER_COL_COUNT;i++)
  2122. {
  2123. LVCOLUMNA lv;
  2124. lv.mask = LVCF_WIDTH;
  2125. lv.iSubItem = i;
  2126. SendMessageA(GetDlgItem(hwnd,IDC_USER_LIST), LVM_GETCOLUMN, i, (LPARAM)&lv);
  2127. cxTotal += lv.cx;
  2128. wsprintf(rtfWalk, "%s%d", rtfRowHeader2, cxTotal);
  2129. while(*++rtfWalk)
  2130. ;
  2131. };
  2132. memcpy(rtfWalk, rtfRowHeader3, sizeof(rtfRowHeader3));
  2133. DWORD crtfHeader = strlen(rtfRowHeader);
  2134. DWORD crtf = 0, cwz = 0;
  2135. crtf += sizeof(rtfPrologue)-1;
  2136. int iSel = -1;
  2137. while ((iSel = SendMessageW(GetDlgItem(hwnd,IDC_USER_LIST), LVM_GETNEXTITEM, iSel, MAKELPARAM(LVNI_SELECTED, 0))) != -1)
  2138. {
  2139. crtf += crtfHeader;
  2140. for(int i=0;i<USER_COL_COUNT;i++)
  2141. {
  2142. WCHAR wzBuffer[1024];
  2143. LVITEMW lv;
  2144. lv.pszText = wzBuffer;
  2145. lv.cchTextMax = sizeof(wzBuffer);
  2146. lv.iSubItem = i;
  2147. lv.iItem = iSel;
  2148. cwz += SendMessageW(GetDlgItem(hwnd,IDC_USER_LIST), LVM_GETITEMTEXTW, iSel, (LPARAM)&lv);
  2149. cwz++;
  2150. crtf += WideCharToMultiByte(CP_ACP, 0, wzBuffer, -1, NULL, 0, NULL, NULL) - 1;
  2151. crtf += sizeof(rtfRowPref)-1;
  2152. crtf += sizeof(rtfRowSuff)-1;
  2153. };
  2154. cwz++;
  2155. crtf += sizeof(rtfRowFooter)-1;
  2156. };
  2157. crtf += sizeof(rtfEpilogue);
  2158. cwz++;
  2159. HGLOBAL hgwz = GlobalAlloc(GMEM_FIXED, cwz*sizeof(WCHAR));
  2160. HGLOBAL hgrtf = GlobalAlloc(GMEM_FIXED, crtf);
  2161. WCHAR *wz = (WCHAR *)GlobalLock(hgwz);
  2162. char *rtf = (char *)GlobalLock(hgrtf);
  2163. rtfWalk = rtf;
  2164. WCHAR *wzWalk = wz;
  2165. memcpy(rtfWalk, rtfPrologue, sizeof(rtfPrologue));
  2166. rtfWalk += sizeof(rtfPrologue)-1;
  2167. iSel = -1;
  2168. while ((iSel = SendMessageW(GetDlgItem(hwnd,IDC_USER_LIST), LVM_GETNEXTITEM, iSel, MAKELPARAM(LVNI_SELECTED, 0))) != -1)
  2169. {
  2170. memcpy(rtfWalk, rtfRowHeader, crtfHeader);
  2171. rtfWalk += crtfHeader;
  2172. for(int i=0;i<USER_COL_COUNT;i++)
  2173. {
  2174. memcpy(rtfWalk, rtfRowPref, sizeof(rtfRowPref));
  2175. rtfWalk += sizeof(rtfRowPref)-1;
  2176. LVITEMW lv;
  2177. lv.pszText = wzWalk;
  2178. lv.cchTextMax = cwz;
  2179. lv.iSubItem = i;
  2180. lv.iItem = iSel;
  2181. SendMessageW(GetDlgItem(hwnd, IDC_USER_LIST), LVM_GETITEMTEXTW, iSel, (LPARAM)&lv);
  2182. WideCharToMultiByte(CP_ACP, 0, wzWalk, -1, rtfWalk, crtf, NULL, NULL);
  2183. wzWalk += wcslen(wzWalk);
  2184. if (i == 11)
  2185. {
  2186. *wzWalk++ = L'\r';
  2187. *wzWalk++ = L'\n';
  2188. }
  2189. else
  2190. *wzWalk++ = L'\t';
  2191. rtfWalk += strlen(rtfWalk);
  2192. memcpy(rtfWalk, rtfRowSuff, sizeof(rtfRowSuff));
  2193. rtfWalk += sizeof(rtfRowSuff)-1;
  2194. };
  2195. memcpy(rtfWalk, rtfRowFooter, sizeof(rtfRowFooter));
  2196. rtfWalk += sizeof(rtfRowFooter)-1;
  2197. };
  2198. memcpy(rtfWalk, rtfEpilogue, sizeof(rtfEpilogue));
  2199. rtfWalk += sizeof(rtfEpilogue);
  2200. *wzWalk++ = 0;
  2201. // Assert(rtfWalk - rtf == crtf);
  2202. // Assert(wzWalk - wz == cwz);
  2203. GlobalUnlock(hgwz);
  2204. GlobalUnlock(hgrtf);
  2205. SetClipboardData(CF_UNICODETEXT, hgwz);
  2206. SetClipboardData(RegisterClipboardFormatA(szRTFClipFormat), hgrtf);
  2207. // hgwz and hgrtf are now owned by the system. DO NOT FREE!
  2208. CloseClipboard();
  2209. }
  2210. void UMExportDataToCSV (TCHAR *FileName)
  2211. {
  2212. // Open file
  2213. // write headers
  2214. // loop through data structure and write all fields.
  2215. // Should we include filtered data views?
  2216. }
  2217. */
  2218. LRESULT CALLBACK
  2219. UserDlgProc(
  2220. HWND hwnd,
  2221. UINT iMsg,
  2222. WPARAM wParam,
  2223. LPARAM lParam
  2224. )
  2225. {
  2226. // int Index = 0;
  2227. TCHAR Temp[100];
  2228. LVITEM lvi;
  2229. static int cDragOffset;
  2230. switch (iMsg)
  2231. {
  2232. case WM_NOTIFY:
  2233. {
  2234. switch(((NMHDR *)lParam)->code)
  2235. {
  2236. case LVN_COLUMNCLICK:
  2237. if (g_iSelCurrent > -1)
  2238. {
  2239. WriteNotesFile(hwnd);
  2240. g_iSelCurrent = -1;
  2241. }
  2242. _itot(((NM_LISTVIEW*)lParam)->iSubItem,Temp,10);
  2243. ListView_SortItemsEx( ((NMHDR *)lParam)->hwndFrom,
  2244. UmCompareFunc,
  2245. ((NM_LISTVIEW*)lParam)->iSubItem
  2246. );
  2247. g_bUMSortAsc = !g_bUMSortAsc;
  2248. break;
  2249. case NM_CLICK:
  2250. if (g_iSelCurrent > -1)
  2251. {
  2252. WriteNotesFile(hwnd);
  2253. g_iSelCurrent = -1;
  2254. }
  2255. g_iSelCurrent = ((NM_LISTVIEW*)lParam)->iItem;
  2256. lvi.iItem = g_iSelCurrent;
  2257. lvi.mask = LVIF_PARAM;
  2258. ListView_GetItem(((NMHDR *)lParam)->hwndFrom, &lvi);
  2259. g_iSelCurrent = lvi.lParam;
  2260. DisplayUserBucketData(hwnd, g_iSelCurrent);
  2261. break;
  2262. }
  2263. return TRUE;
  2264. }
  2265. case WM_INITDIALOG:
  2266. OnUserDialogInit(hwnd);
  2267. return TRUE;
  2268. case WM_FileTreeLoaded:
  2269. RefreshUserMode(hwnd);
  2270. return TRUE;
  2271. case WM_CONTEXTMENU:
  2272. //if (g_iSelCurrent > -1)
  2273. //WriteNotesFile(hwnd);
  2274. OnUserContextMenu(hwnd, lParam );
  2275. return TRUE;
  2276. case WM_ERASEBKGND:
  2277. // Don't know why this doesn't happen automatically...
  2278. {
  2279. HDC hdc = (HDC)wParam;
  2280. HPEN hpen = (HPEN)CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNFACE));
  2281. HPEN hpenOld = (HPEN)SelectObject(hdc, hpen);
  2282. SelectObject(hdc, GetSysColorBrush(COLOR_BTNFACE));
  2283. RECT rc;
  2284. GetClientRect(hwnd, &rc);
  2285. Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
  2286. SelectObject(hdc, hpenOld);
  2287. DeleteObject(hpen);
  2288. return TRUE;
  2289. }
  2290. /*case WM_LBUTTONUP:
  2291. if (bCapture)
  2292. {
  2293. HWND hSlider = GetDlgItem(hwnd, IDC_VERT_SLIDER);
  2294. RECT rcDlg;
  2295. GetClientRect(hwnd, &rcDlg);
  2296. //MoveWindow(hSlider,
  2297. SetWindowPos( hSlider,
  2298. NULL,
  2299. rcDlg.left + yOffset,
  2300. rcList.bottom + (rcCombo.bottom - rcCombo.top) ,
  2301. rcDlg.right - rcDlg.left - yOffset,
  2302. 6,
  2303. SWP_NOZORDER);
  2304. ReleaseCapture();
  2305. bCapture = FALSE;
  2306. }
  2307. */
  2308. case WM_COMMAND:
  2309. switch (LOWORD(wParam))
  2310. {
  2311. /* case IDC_VERT_SLIDER:
  2312. {
  2313. RECT r;
  2314. GetWindowRect(GetDlgItem(hwnd, IDC_USER_EDIT), &r);
  2315. //cDragOffset = GET_X_LPARAM(GetMessagePos()) - r.right;
  2316. //fCapture = DRAG_HORIZ;
  2317. cDragOffset = GET_Y_LPARAM(GetMessagePos()) - r.bottom;
  2318. bCapture = TRUE;
  2319. SetCapture(hwnd);
  2320. return 0;
  2321. };
  2322. */
  2323. case ID_REPORT_ALLUSERMODEFAULTS:
  2324. if (g_iSelCurrent > -1)
  2325. {
  2326. WriteNotesFile(hwnd);
  2327. g_iSelCurrent = -1;
  2328. }
  2329. ReportUserModeFault(hwnd, FALSE,0);
  2330. RefreshUserMode(hwnd);
  2331. break;
  2332. case ID_REPORT_SELECTEDBUCKET:
  2333. if (g_iSelCurrent > -1)
  2334. {
  2335. WriteNotesFile(hwnd);
  2336. g_iSelCurrent = -1;
  2337. }
  2338. ReportUserModeFault(hwnd, TRUE, GetDlgItem(hwnd, IDC_USER_LIST));
  2339. RefreshUserMode(hwnd);
  2340. break;
  2341. case ID_VIEW_CRASHLOG:
  2342. if (g_iSelCurrent > -1)
  2343. {
  2344. WriteNotesFile(hwnd);
  2345. g_iSelCurrent = -1;
  2346. }
  2347. if (_tcscmp(CerRoot, _T("\0")))
  2348. {
  2349. ViewCrashLog();
  2350. }
  2351. else
  2352. {
  2353. ErrorLoadTree();
  2354. }
  2355. break;
  2356. case ID_VIEW_REFRESH140:
  2357. if (g_iSelCurrent > -1)
  2358. {
  2359. WriteNotesFile(hwnd);
  2360. g_iSelCurrent = -1;
  2361. }
  2362. if (_tcscmp(CerRoot, _T("\0")))
  2363. {
  2364. RefreshUserMode(hwnd);
  2365. }
  2366. else
  2367. {
  2368. ErrorLoadTree();
  2369. }
  2370. break;
  2371. case ID_VIEW_MICROSOFTRESPONSE:
  2372. if (g_iSelCurrent > -1)
  2373. {
  2374. WriteNotesFile(hwnd);
  2375. g_iSelCurrent = -1;
  2376. }
  2377. if (_tcscmp(CerRoot, _T("\0")))
  2378. {
  2379. ViewResponse(hwnd, TRUE);
  2380. }
  2381. else
  2382. {
  2383. ErrorLoadTree();
  2384. }
  2385. break;
  2386. // case ID_EDIT_COPY144:
  2387. // UMCopyToClipboard(hwnd);
  2388. // break;
  2389. case ID_VIEW_BUCKETOVERRIDERESPONSE155:
  2390. if (g_iSelCurrent > -1)
  2391. {
  2392. WriteNotesFile(hwnd);
  2393. g_iSelCurrent = -1;
  2394. }
  2395. if (_tcscmp(CerRoot, _T("\0")))
  2396. {
  2397. ViewResponse(hwnd, FALSE);
  2398. }
  2399. else
  2400. {
  2401. ErrorLoadTree();
  2402. }
  2403. break;
  2404. case ID_VIEW_BUCKETCABFILEDIRECTORY157:
  2405. if (g_iSelCurrent > -1)
  2406. {
  2407. WriteNotesFile(hwnd);
  2408. g_iSelCurrent = -1;
  2409. }
  2410. ViewBucketDir(hwnd);
  2411. break;
  2412. case ID_REPORT_ALL:
  2413. if (g_iSelCurrent > -1)
  2414. {
  2415. WriteNotesFile(hwnd);
  2416. g_iSelCurrent = -1;
  2417. }
  2418. //SendMessage(GetParent(hwnd), WM_COMMAND, 0, 0);
  2419. PostMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(ID_REPORT_ALLCRASHES,0),0);
  2420. break;
  2421. case ID_EDIT_USERMODEREPORTINGOPTIONS:
  2422. if (g_iSelCurrent > -1)
  2423. {
  2424. WriteNotesFile(hwnd);
  2425. g_iSelCurrent = -1;
  2426. }
  2427. PostMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(ID_EDIT_DEFAULTPOLICY,0),0);
  2428. RefreshUserMode(hwnd);
  2429. break;
  2430. case ID_EDIT_SELECTEDBUCKETREPORTINGOPTIONS:
  2431. if (g_iSelCurrent > -1)
  2432. {
  2433. WriteNotesFile(hwnd);
  2434. g_iSelCurrent = -1;
  2435. }
  2436. PostMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(ID_EDIT_SELECTEDBUCKETSPOLICY,0),0);
  2437. break;
  2438. }
  2439. switch (HIWORD(wParam))
  2440. {
  2441. case CBN_SELCHANGE:
  2442. if (g_iSelCurrent > -1)
  2443. {
  2444. WriteNotesFile(hwnd);
  2445. g_iSelCurrent = -1;
  2446. }
  2447. RefreshUserMode(hwnd);
  2448. break;
  2449. }
  2450. }
  2451. return FALSE;
  2452. }