Source code of Windows XP (NT5)
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.

867 lines
22 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. w9xtool.c
  5. Abstract:
  6. Implements a stub tool that is designed to run with Win9x-side
  7. upgrade code.
  8. Author:
  9. <full name> (<alias>) <date>
  10. Revision History:
  11. <alias> <date> <comments>
  12. --*/
  13. #include "pch.h"
  14. typedef struct _IPData {
  15. DWORD dwSize;
  16. DWORD fdwTCPIP;
  17. DWORD dwIPAddr;
  18. DWORD dwDNSAddr;
  19. DWORD dwDNSAddrAlt;
  20. DWORD dwWINSAddr;
  21. DWORD dwWINSAddrAlt;
  22. } IPDATA, *PIPDATA;
  23. typedef struct _AddrEntry {
  24. DWORD dwVersion;
  25. DWORD dwCountryCode;
  26. UINT uOffArea;
  27. UINT uOffPhone;
  28. DWORD dwCountryID;
  29. UINT uOffSMMCfg;
  30. UINT uOffSMM;
  31. UINT uOffDI;
  32. } ADDRENTRY, *PADDRENTRY;
  33. typedef struct _SubConnEntry {
  34. DWORD dwSize;
  35. DWORD dwFlags;
  36. char szDeviceType[RAS_MaxDeviceType+1];
  37. char szDeviceName[RAS_MaxDeviceName+1];
  38. char szLocal[RAS_MaxPhoneNumber+1];
  39. } SUBCONNENTRY, *PSUBCONNENTRY;
  40. typedef struct _DEVICEINFO {
  41. DWORD dwVersion;
  42. UINT uSize;
  43. char szDeviceName[RAS_MaxDeviceName+1];
  44. char szDeviceType[RAS_MaxDeviceType+1];
  45. } DEVICEINFO, *PDEVICEINFO;
  46. typedef struct _SMMCFG {
  47. DWORD dwSize;
  48. DWORD fdwOptions;
  49. DWORD fdwProtocols;
  50. } SMMCFG, *PSMMCFG;
  51. typedef struct {
  52. DWORD Size;
  53. DWORD Unknown1;
  54. DWORD ModemUiOptions; // num seconds in high byte.
  55. DWORD Unknown2;
  56. DWORD Unknown3;
  57. DWORD Unknown4;
  58. DWORD ConnectionSpeed;
  59. DWORD UnknownFlowControlData; //Somehow related to flow control.
  60. DWORD Unknown5;
  61. DWORD Unknown6;
  62. DWORD Unknown7;
  63. DWORD Unknown8;
  64. DWORD Unknown9;
  65. DWORD Unknown10;
  66. DWORD Unknown11;
  67. DWORD Unknown12;
  68. DWORD Unknown13;
  69. DWORD Unknown14;
  70. DWORD Unknown15;
  71. DWORD CancelSeconds; //Num seconds to wait before cancel if not connected. (0xFF equals off.)
  72. DWORD IdleDisconnectSeconds; // 0 = Not Set.
  73. DWORD Unknown16;
  74. DWORD SpeakerVolume; // 0|1
  75. DWORD ConfigOptions;
  76. DWORD Unknown17;
  77. DWORD Unknown18;
  78. DWORD Unknown19;
  79. } MODEMDEVINFO, *PMODEMDEVINFO;
  80. #define RAS_UI_FLAG_TERMBEFOREDIAL 0x1
  81. #define RAS_UI_FLAG_TERMAFTERDIAL 0x2
  82. #define RAS_UI_FLAG_OPERATORASSISTED 0x4
  83. #define RAS_UI_FLAG_MODEMSTATUS 0x8
  84. #define RAS_CFG_FLAG_HARDWARE_FLOW_CONTROL 0x00000010
  85. #define RAS_CFG_FLAG_SOFTWARE_FLOW_CONTROL 0x00000020
  86. #define RAS_CFG_FLAG_STANDARD_EMULATION 0x00000040
  87. #define RAS_CFG_FLAG_COMPRESS_DATA 0x00000001
  88. #define RAS_CFG_FLAG_USE_ERROR_CONTROL 0x00000002
  89. #define RAS_CFG_FLAG_ERROR_CONTROL_REQUIRED 0x00000004
  90. #define RAS_CFG_FLAG_USE_CELLULAR_PROTOCOL 0x00000008
  91. #define RAS_CFG_FLAG_NO_WAIT_FOR_DIALTONE 0x00000200
  92. PCTSTR g_User = NULL;
  93. PCTSTR g_Setting = NULL;
  94. PCTSTR g_Entry = NULL;
  95. BOOL g_ShowBinary = FALSE;
  96. #define S_REMOTE_ACCESS_KEY TEXT("RemoteAccess")
  97. #define S_PROFILE_KEY TEXT("RemoteAccess\\Profile")
  98. #define S_ADDRESSES_KEY TEXT("RemoteAccess\\Addresses")
  99. #define S_DIALUI TEXT("DialUI")
  100. #define S_ENABLE_REDIAL TEXT("EnableRedial")
  101. #define S_REDIAL_WAIT TEXT("RedialWait")
  102. #define S_REDIAL_TRY TEXT("RedialTry")
  103. #define S_ENABLE_IMPLICIT TEXT("EnableImplicit")
  104. #define S_TERMINAL TEXT("Terminal")
  105. #define S_MODE TEXT("Mode")
  106. #define S_MULTILINK TEXT("MultiLink")
  107. #define DIALUI_DONT_PROMPT_FOR_INFO 0x01
  108. #define DIALUI_DONT_SHOW_CONFIRM_DIALOG 0x02
  109. #define DIALUI_DONT_SHOW_ICON 0x04
  110. #define SMMCFG_TCPIP_PROTOCOL 0x04
  111. #define SMMCFG_NETBEUI_PROTOCOL 0x01
  112. #define SMMCFG_IPXSPX_PROTOCOL 0x02
  113. #define PAESMMCFG(pAE) ((PSMMCFG)(((PBYTE)pAE)+(pAE->uOffSMMCfg)))
  114. #define PAESMM(pAE) ((PSTR)(((PBYTE)pAE)+(pAE->uOffSMM)))
  115. #define PAEDI(pAE) ((PDEVICEINFO)(((PBYTE)pAE)+(pAE->uOffDI )))
  116. #define PAEAREA(pAE) ((PSTR)(((PBYTE)pAE)+(pAE->uOffArea)))
  117. #define PAEPHONE(pAE) ((PSTR)(((PBYTE)pAE)+(pAE->uOffPhone)))
  118. #define DECRYPTENTRY(x, y, z) EnDecryptEntry(x, (LPBYTE)y, z)
  119. static BYTE NEAR PASCAL GenerateEncryptKey (LPSTR szKey)
  120. {
  121. BYTE bKey;
  122. LPBYTE lpKey;
  123. for (bKey = 0, lpKey = (LPBYTE)szKey; *lpKey != 0; lpKey++)
  124. {
  125. bKey += *lpKey;
  126. };
  127. return bKey;
  128. }
  129. DWORD NEAR PASCAL EnDecryptEntry (LPSTR szEntry, LPBYTE lpEnt,
  130. DWORD cb);
  131. VOID
  132. pDumpPerUserSettings (
  133. IN HKEY UserKey
  134. )
  135. {
  136. HKEY settingsKey;
  137. PDWORD data;
  138. printf("\n*** Ras Per User Setting Information ***\n");
  139. settingsKey = OpenRegKey(UserKey,S_REMOTE_ACCESS_KEY);
  140. if (settingsKey) {
  141. //
  142. // Get UI settings.
  143. //
  144. data = (PDWORD) GetRegValueBinary(settingsKey,S_DIALUI);
  145. printf("\n\t** Dialup UI Information **\n");
  146. if (data) {
  147. printf("\t\t%sprompt for information before dialing.\n",
  148. DIALUI_DONT_PROMPT_FOR_INFO & *data ? "Don't " :""
  149. );
  150. printf("\t\t%sshow confirmation dialog after connected.\n",
  151. DIALUI_DONT_SHOW_CONFIRM_DIALOG & *data ? "Don't ":""
  152. );
  153. printf("\t\t%sshow an icon on the taskbar after connected.\n",
  154. DIALUI_DONT_SHOW_ICON & *data ? "Don't ":""
  155. );
  156. MemFree(g_hHeap,0,data);
  157. }
  158. else {
  159. printf("\t\tNo user UI Settings found..\n");
  160. }
  161. //
  162. // Get Redial information.
  163. //
  164. printf("\n\t** Redialing Information **\n");
  165. data = (PDWORD) GetRegValueBinary(settingsKey,S_ENABLE_REDIAL);
  166. if (data) {
  167. printf("\t\tRedialing %s.\n",*data ? "Enabled." : "Disabled.");
  168. MemFree(g_hHeap,0,data);
  169. }
  170. else {
  171. printf("\t\tNo Redial information found.\n");
  172. }
  173. data = (PDWORD) GetRegValueBinary(settingsKey,S_REDIAL_TRY);
  174. if (data) {
  175. printf("\t\tNumber of redial tries: %u.\n", *data);
  176. MemFree(g_hHeap,0,data);
  177. }
  178. data = (PDWORD) GetRegValueBinary(settingsKey,S_REDIAL_WAIT);
  179. if (data) {
  180. printf("\t\tRedial time in seconds: %u\n", HIWORD(*data) * 60 + LOWORD(*data));
  181. MemFree(g_hHeap,0,data);
  182. }
  183. //
  184. // Get implicit connection information.
  185. //
  186. data = (PDWORD) GetRegValueBinary(settingsKey,S_ENABLE_IMPLICIT);
  187. if (data) {
  188. printf("\n\t%sprompt with dial-up networking to establish connection.\n",
  189. *data ? "" : "Don't "
  190. );
  191. MemFree(g_hHeap,0,data);
  192. }
  193. CloseRegKey(settingsKey);
  194. }
  195. printf("\n***\n");
  196. }
  197. PTSTR
  198. pIpAddressAsString(
  199. DWORD dwAddress
  200. )
  201. {
  202. BYTE bAddress[4];
  203. static TCHAR address[30];
  204. *((LPDWORD)bAddress) = dwAddress;
  205. sprintf(address,"%d.%d.%d.%d", bAddress[0], bAddress[1], bAddress[2],bAddress[3]);
  206. return address;
  207. }
  208. VOID
  209. pDumpBinaryData(
  210. IN PBYTE Data,
  211. IN UINT Size
  212. )
  213. {
  214. UINT i,j;
  215. TCHAR hexArray[40];
  216. TCHAR strArray[20];
  217. TCHAR buf[20];
  218. printf("\n\t\tBinary Dump...\n");
  219. for (j = 0;j<Size + Size % 8;j +=8) {
  220. *hexArray = 0;
  221. *strArray = 0;
  222. for (i = 0;i < 8;i++) {
  223. sprintf(buf," %02x",i + j < Size ? Data[i+j] : 0x00);
  224. _tcscat(hexArray,buf);
  225. sprintf(buf," %c",isprint(Data[i+j]) && i + j < Size ? Data[i+j] : TEXT('.'));
  226. _tcscat(strArray,buf);
  227. }
  228. printf("\n\t\t%s\t%s",hexArray,strArray);
  229. }
  230. printf("\n\n");
  231. }
  232. VOID
  233. pDumpIpInformation (
  234. IN PIPDATA IpData
  235. )
  236. {
  237. printf("\t\t<IPINFO> fTcpIp = %u\n",IpData -> fdwTCPIP);
  238. printf("\t\t<IPINFO> IP Address = %s\n",pIpAddressAsString(IpData -> dwIPAddr));
  239. printf("\t\t<IPINFO> DNS Address = %s\n",pIpAddressAsString(IpData -> dwDNSAddr));
  240. printf("\t\t<IPINFO> Alternate DNS Address = %s\n",pIpAddressAsString(IpData -> dwDNSAddrAlt));
  241. printf("\t\t<IPINFO> WINS Address = %s\n",pIpAddressAsString(IpData -> dwWINSAddr));
  242. printf("\t\t<IPINFO> Alternate WINS Address = %s\n",pIpAddressAsString(IpData -> dwWINSAddrAlt));
  243. }
  244. VOID
  245. pDumpConnectionSettings (
  246. IN HANDLE Key,
  247. IN PCTSTR Name
  248. )
  249. {
  250. REGVALUE_ENUM e;
  251. PBYTE curData;
  252. printf("\n\t** %s Setting.. **\n",Name);
  253. if (EnumFirstRegValue(&e,Key)) {
  254. do {
  255. //
  256. // Get the data for this entry.
  257. //
  258. curData = GetRegValueData(Key,e.ValueName);
  259. if (curData) {
  260. if (!g_Setting || StringIMatch(g_Setting,e.ValueName)) {
  261. switch (e.Type) {
  262. case REG_SZ:
  263. case REG_MULTI_SZ:
  264. case REG_EXPAND_SZ:
  265. printf("\t\t<STRING DATA> %s = %s\n",e.ValueName,(PCTSTR) curData);
  266. break;
  267. case REG_DWORD:
  268. printf("\t\t<DWORD DATA> %s = %u\n",e.ValueName,*((PDWORD) curData));
  269. break;
  270. case REG_BINARY:
  271. if (StringIMatch(S_IPINFO,e.ValueName)) {
  272. pDumpIpInformation((PIPDATA) curData);
  273. }
  274. else if (StringIMatch(S_TERMINAL,e.ValueName)) {
  275. PWINDOWPLACEMENT wp = (PWINDOWPLACEMENT) curData;
  276. PCTSTR showStr = NULL;
  277. switch(wp -> showCmd) {
  278. case SW_HIDE:
  279. showStr = "SW_HIDE";
  280. break;
  281. case SW_MINIMIZE:
  282. showStr = "SW_MINIMIZE";
  283. break;
  284. case SW_RESTORE:
  285. showStr = "SW_RESTORE";
  286. break;
  287. case SW_SHOW:
  288. showStr = "SW_SHOW";
  289. break;
  290. case SW_SHOWMAXIMIZED:
  291. showStr = "SW_SHOWMAXIMIZED";
  292. break;
  293. case SW_SHOWMINIMIZED:
  294. showStr = "SW_SHOWMINIMIZED";
  295. break;
  296. case SW_SHOWMINNOACTIVE:
  297. showStr = "SW_SHOWMINNOACTIVE";
  298. break;
  299. case SW_SHOWNA:
  300. showStr = "SW_SHOWNA";
  301. break;
  302. case SW_SHOWNOACTIVATE:
  303. showStr = "SW_SHOWNOACTIVATE";
  304. break;
  305. case SW_SHOWNORMAL:
  306. showStr = "SW_SHOWNORMAL";
  307. break;
  308. default:
  309. showStr = "Unknown SHOW FLAG!";
  310. break;
  311. }
  312. printf("\t\tTerminal Window Show Flag: %s\n", showStr);
  313. } else if (StringIMatch(S_MODE,e.ValueName)) {
  314. if (*curData) {
  315. printf("\t\tStep through script. (Testing Mode..)\n");
  316. }
  317. else {
  318. printf("\t\tScript should be run in normal mode.\n");
  319. }
  320. } else if (StringIMatch(S_MULTILINK,e.ValueName)) {
  321. printf("\t\tMultilink is %s.\n",*curData ? "ENABLED" : "DISABLED");
  322. } else {
  323. printf("\t\t<!!UNKNOWN BINARY DATA!!> %s = <BINARY BLOB>\n",e.ValueName);
  324. }
  325. if (g_ShowBinary) {
  326. pDumpBinaryData(curData,e.DataSize);
  327. }
  328. break;
  329. default:
  330. printf("\t\t<UNKNOWN DATA TYPE> %s = <UNKNOWN DATA TYPE>\n",e.ValueName);
  331. break;
  332. }
  333. }
  334. MemFree(g_hHeap,0,curData);
  335. }
  336. } while (EnumNextRegValue(&e));
  337. }
  338. }
  339. VOID
  340. pDumpDevInfo (
  341. IN PDEVICEINFO Info
  342. )
  343. {
  344. UINT size;
  345. UINT i;
  346. PMODEMDEVINFO caps;
  347. printf ("** Device Info: \n"
  348. "\t\tVersion: %u \n"
  349. "\t\tSize: %u\n"
  350. "\t\tDevice Name: %s\n"
  351. "\t\tDevice Type: %s\n",
  352. Info->dwVersion,
  353. Info->uSize,
  354. Info->szDeviceName,
  355. Info->szDeviceType
  356. );
  357. size = Info->uSize - ((PBYTE) (Info->szDeviceType + RAS_MaxDeviceType + 1) - (PBYTE) Info);
  358. caps = (PMODEMDEVINFO) (Info->szDeviceType + RAS_MaxDeviceType + 3);
  359. #if 0
  360. pDumpBinaryData ((PBYTE) caps, sizeof (REGDEVCAPS));
  361. printf ("As Dwords..\n");
  362. for (i = 0; i < 27; i++) {
  363. printf ("Dword %u = %u (%x)\n",i, caps->foo[i], caps->foo[i]);
  364. }
  365. #endif
  366. printf (
  367. "\tCaps Size: %u\n"
  368. "\tStart Term Before Redial? %s\n"
  369. "\tStart Term After Redial? %s\n"
  370. "\tOperator Assited Dial? %s\n"
  371. "\tShow Modem Status? %s\n"
  372. "\tUI Options: %u (%x)\n"
  373. "\tConnection Speed: %u\n"
  374. "\tCancel if not connected within %u seconds.\n"
  375. "\tDisconnect if Idle for %u seconds.\n"
  376. "\tSpeaker %s.\n"
  377. "\tHardware Flow Control? %s\n"
  378. "\tSoftware Flow Control? %s\n"
  379. "\tStandard Emulation? %s\n"
  380. "\tCompress Data? %s\n"
  381. "\tUse Error Control? %s\n"
  382. "\tError Control Required? %s\n"
  383. "\tUse Cellular Protocol? %s\n"
  384. "\tWait for Dialtone? %s\n"
  385. "\tConfig Options: %u (%x)\n",
  386. caps->Size,
  387. caps->ModemUiOptions & RAS_UI_FLAG_TERMBEFOREDIAL ? "Yes" : "No",
  388. caps->ModemUiOptions & RAS_UI_FLAG_TERMAFTERDIAL ? "Yes" : "No",
  389. caps->ModemUiOptions & RAS_UI_FLAG_OPERATORASSISTED ? "Yes" : "No",
  390. caps->ModemUiOptions & RAS_UI_FLAG_MODEMSTATUS ? "Yes" : "No",
  391. caps->ModemUiOptions,
  392. caps->ModemUiOptions,
  393. caps->ConnectionSpeed,
  394. caps->CancelSeconds,
  395. caps->IdleDisconnectSeconds,
  396. caps->SpeakerVolume ? "Yes" : "No",
  397. caps->ConfigOptions & RAS_CFG_FLAG_HARDWARE_FLOW_CONTROL ? "Yes" : "No",
  398. caps->ConfigOptions & RAS_CFG_FLAG_SOFTWARE_FLOW_CONTROL ? "Yes" : "No",
  399. caps->ConfigOptions & RAS_CFG_FLAG_STANDARD_EMULATION ? "Yes" : "No",
  400. caps->ConfigOptions & RAS_CFG_FLAG_COMPRESS_DATA ? "Yes" : "No",
  401. caps->ConfigOptions & RAS_CFG_FLAG_USE_ERROR_CONTROL ? "Yes" : "No",
  402. caps->ConfigOptions & RAS_CFG_FLAG_ERROR_CONTROL_REQUIRED ? "Yes" : "No",
  403. caps->ConfigOptions & RAS_CFG_FLAG_USE_CELLULAR_PROTOCOL ? "Yes" : "No",
  404. caps->ConfigOptions & RAS_CFG_FLAG_NO_WAIT_FOR_DIALTONE ? "No" : "Yes",
  405. caps->ConfigOptions,
  406. caps->ConfigOptions
  407. );
  408. }
  409. VOID
  410. pDumpAddressInfo (
  411. IN HKEY AddressKey,
  412. IN PCTSTR SubKeyName
  413. )
  414. {
  415. PBYTE data = NULL;
  416. UINT count = 0;
  417. UINT type = 0;
  418. PADDRENTRY entry;
  419. PSMMCFG smmCfg;
  420. PDEVICEINFO devInfo;
  421. UINT sequencer = 0;
  422. HKEY subEntriesKey;
  423. PTSTR subEntriesKeyStr;
  424. REGVALUE_ENUM eSubEntries;
  425. PSUBCONNENTRY subEntry;
  426. if (RegQueryValueEx(AddressKey, SubKeyName, NULL, &type, NULL, &count) == ERROR_SUCCESS) {
  427. data = MemAlloc(g_hHeap,0,count);
  428. if (data) {
  429. if (RegQueryValueEx(AddressKey, SubKeyName, NULL, &type, (LPBYTE)data,&count) == ERROR_SUCCESS) {
  430. entry = (PADDRENTRY) data;
  431. DECRYPTENTRY((PTSTR)SubKeyName, entry, count);
  432. smmCfg = PAESMMCFG(entry);
  433. devInfo = PAEDI(entry);
  434. pDumpDevInfo (devInfo);
  435. if (!g_Setting || StringMatch(g_Setting,"AddressData")) {
  436. printf("\t\t<AddressData> Phone Number = %s\n",PAEPHONE(entry));
  437. printf("\t\t<AddressData> Area Code = %s\n",PAEAREA(entry));
  438. printf("\t\t<AddressData> SMM = %s\n",PAESMM(entry));
  439. printf("\t\t<AddressData> Country Code = %u\n",entry -> dwCountryCode);
  440. printf("\t\t<AddressData> Country Id = %u\n",entry -> dwCountryID);
  441. printf("\t\t<Device Info> DeviceName = %s\n",devInfo -> szDeviceName);
  442. printf("\t\t<Device Info> DeviceType = %s\n",devInfo -> szDeviceType);
  443. printf("\t\t<SMM Cfg> Options = %u\n",smmCfg -> fdwOptions);
  444. printf("\t\t<SMM Cfg> TCPIP is %s.\n",
  445. smmCfg -> fdwProtocols & SMMCFG_TCPIP_PROTOCOL ? "ENABLED" : "DISABLED");
  446. printf("\t\t<SMM Cfg> NETBEUI is %s.\n",
  447. smmCfg -> fdwProtocols & SMMCFG_NETBEUI_PROTOCOL ? "ENABLED" : "DISABLED");
  448. printf("\t\t<SMM Cfg> IPX/SPX is %s.\n",
  449. smmCfg -> fdwProtocols & SMMCFG_IPXSPX_PROTOCOL ? "ENABLED" : "DISABLED");
  450. if (g_ShowBinary) {
  451. pDumpBinaryData((PBYTE) entry,count);
  452. }
  453. }
  454. }
  455. MemFree(g_hHeap,0,data);
  456. subEntriesKeyStr = JoinPaths ("SubEntries", SubKeyName);
  457. subEntriesKey = OpenRegKey (AddressKey, subEntriesKeyStr);
  458. FreePathString (subEntriesKeyStr);
  459. sequencer = 0;
  460. if (subEntriesKey) {
  461. if (EnumFirstRegValue (&eSubEntries, subEntriesKey)) {
  462. do {
  463. data = GetRegValueBinary (subEntriesKey, eSubEntries.ValueName);
  464. if (data) {
  465. subEntry = (PSUBCONNENTRY) data;
  466. DECRYPTENTRY ((PTSTR) SubKeyName, subEntry, eSubEntries.DataSize);
  467. printf ("\tSub Entry Device Type: %s\n", subEntry->szDeviceType);
  468. printf ("\tSub Entry Device Name: %s\n", subEntry->szDeviceName);
  469. printf ("\tSub Entry Phone Number: %s\n", subEntry->szDeviceName);
  470. printf ("\tSub Entry Flags: %u (%x)\n", subEntry->dwFlags);
  471. printf ("\tSub Entry Size: %u\n", subEntry->dwSize);
  472. pDumpBinaryData ((PBYTE) subEntry, subEntry->dwSize);
  473. MemFree (g_hHeap, 0, data);
  474. }
  475. sequencer++;
  476. } while (EnumNextRegValue (&eSubEntries));
  477. }
  478. CloseRegKey (subEntriesKey);
  479. }
  480. }
  481. }
  482. }
  483. VOID
  484. pDumpPerConnectionSettings (
  485. IN HKEY UserKey
  486. )
  487. {
  488. REGKEY_ENUM e;
  489. HKEY profileKey;
  490. HKEY entryKey = NULL;
  491. HKEY addressKey = NULL;
  492. printf("\n*** Ras Per Connection Setting Information ***\n");
  493. profileKey = OpenRegKey (UserKey,S_PROFILE_KEY);
  494. addressKey = OpenRegKey (UserKey,S_ADDRESSES_KEY);
  495. if (profileKey && addressKey) {
  496. if (EnumFirstRegKey(&e,addressKey)) {
  497. do {
  498. if (!g_Entry || StringIMatch(g_Entry,e.SubKeyName)) {
  499. pDumpAddressInfo(addressKey,e.SubKeyName);
  500. entryKey = OpenRegKey(profileKey,e.SubKeyName);
  501. if (entryKey ) {
  502. pDumpConnectionSettings (entryKey, e.SubKeyName);
  503. CloseRegKey(entryKey);
  504. }
  505. }
  506. } while (EnumNextRegKey(&e));
  507. }
  508. }
  509. CloseRegKey(addressKey);
  510. CloseRegKey(profileKey);
  511. printf("\n***\n");
  512. }
  513. BOOL
  514. Init (
  515. VOID
  516. )
  517. {
  518. HINSTANCE hInstance;
  519. hInstance = GetModuleHandle (NULL);
  520. return InitToolMode (hInstance);
  521. }
  522. VOID
  523. Terminate (
  524. VOID
  525. )
  526. {
  527. HINSTANCE hInstance;
  528. hInstance = GetModuleHandle (NULL);
  529. TerminateToolMode (hInstance);
  530. }
  531. VOID
  532. pShowHelp (
  533. VOID
  534. )
  535. {
  536. printf("\nUsage: RasDump [-h?b] [-u:<UserName>] [-e:<EntryName>] [-s:<SettingName>]\n"
  537. "\n\t\t -h - Display this message."
  538. "\n\t\t -? - Display this message."
  539. "\n\t\t -u - Dump information for user <UserName>."
  540. "\n\t\t -b - Dump raw binary data."
  541. "\n\t\t -e - Dump Entry infor for DialUp Connection <EntryName>.\n");
  542. exit(0);
  543. }
  544. VOID
  545. pProcessCommandLine (
  546. UINT argc,
  547. PTSTR * argv
  548. )
  549. {
  550. UINT i;
  551. PTSTR p;
  552. for (i = 1;i < argc; i++) {
  553. p = argv[i];
  554. if (*p != TEXT('-') && *p != TEXT('/')) {
  555. pShowHelp();
  556. }
  557. p++;
  558. switch(tolower(*p)) {
  559. case TEXT('u'):
  560. if (*++p != ':') {
  561. pShowHelp();
  562. }
  563. g_User = ++p;
  564. break;
  565. case TEXT('s'):
  566. if (*++p != ':') {
  567. pShowHelp();
  568. }
  569. g_Setting = ++p;
  570. break;
  571. case TEXT('h'): case TEXT('?'):
  572. pShowHelp();
  573. break;
  574. case TEXT('e'):
  575. if (*++p != ':') {
  576. pShowHelp();
  577. }
  578. g_Entry = ++p;
  579. break;
  580. case TEXT('b') :
  581. g_ShowBinary = TRUE;
  582. break;
  583. default:
  584. pShowHelp();
  585. break;
  586. }
  587. }
  588. }
  589. INT
  590. __cdecl
  591. main (
  592. INT argc,
  593. CHAR *argv[]
  594. )
  595. {
  596. USERENUM e;
  597. TCHAR buf[MEMDB_MAX];
  598. if (!Init()) {
  599. printf ("Unable to initialize!\n");
  600. return 255;
  601. }
  602. //
  603. // needed by enumuser..
  604. //
  605. GetWindowsDirectory(buf,MAX_PATH);
  606. g_WinDir = buf;
  607. Win95RegInit(g_WinDir,NULL);
  608. pProcessCommandLine(argc,argv);
  609. if (EnumFirstUser (&e, ENUMUSER_ENABLE_NAME_FIX)) {
  610. do {
  611. if (!g_User || StringIMatch(g_User,e.UserName)) {
  612. printf("Dumping ras settings for user %s..\n",*e.UserName ? e.UserName : "<Default>");
  613. __try {
  614. pDumpPerUserSettings(e.UserRegKey);
  615. pDumpPerConnectionSettings(e.UserRegKey);
  616. }
  617. except (1) {
  618. printf("Caught an exception..");
  619. }
  620. }
  621. } while (EnumNextUser(&e));
  622. }
  623. Terminate();
  624. return 0;
  625. }