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.

980 lines
27 KiB

  1. #define SRVDBG 1
  2. #define SRVKD 1
  3. #include <nt.h>
  4. #include <ntrtl.h>
  5. #include <nturtl.h>
  6. #include <ntverp.h>
  7. #include <windows.h>
  8. #include <ntosp.h>
  9. #include <wdbgexts.h>
  10. #define NT
  11. #include <tdi.h>
  12. #include <tdikrnl.h>
  13. #include <tdistat.h>
  14. #include <tdiinfo.h>
  15. #include <irda.h>
  16. #include <irlmp.h>
  17. #include <irlmpp.h>
  18. #include <irdap.h>
  19. #include <dbgmsg.h>
  20. #include <irioctl.h>
  21. #include <irlap.h>
  22. #include <irlapp.h>
  23. /*
  24. #define DBG_NDIS 0x00000002 // keep in sync with test\irdakdx
  25. #define DBG_TIMER 0x00000004
  26. #define DBG_IRMAC 0x00000008
  27. #define DBG_IRLAP 0x00000010
  28. #define DBG_IRLAPLOG 0x00000020
  29. #define DBG_RXFRAME 0x00000040
  30. #define DBG_TXFRAME 0x00000080
  31. #define DBG_IRLMP 0x00000100
  32. #define DBG_IRLMP_CONN 0x00000200
  33. #define DBG_IRLMP_CRED 0x00000400
  34. #define DBG_IRLMP_IAS 0x00000800
  35. #define DBG_DISCOVERY 0x00001000
  36. #define DBG_PRINT 0x00002000
  37. #define DBG_ADDR 0x00004000
  38. #define DBG_REF 0x00010000
  39. #define DBG_TDI 0x00020000
  40. #define DBG_TDI_IRP 0x00040000
  41. #define DBG_ALLOC 0x10000000
  42. #define DBG_FUNCTION 0x20000000
  43. #define DBG_WARN 0x40000000
  44. #define DBG_ERROR 0x80000000
  45. */
  46. WINDBG_EXTENSION_APIS ExtensionApis;
  47. EXT_API_VERSION ApiVersion = { 5, 0, EXT_API_VERSION_NUMBER, 0 };
  48. #define ERRPRT dprintf
  49. #define NL 1
  50. #define NONL 0
  51. USHORT SavedMajorVersion;
  52. USHORT SavedMinorVersion;
  53. BOOL ChkTarget; // is debuggee a CHK build?
  54. typedef struct
  55. {
  56. char Name[16];
  57. int Val;
  58. } DBG_LEVEL;
  59. #if 0
  60. DBG_LEVEL DbgLevel[] = {
  61. {"RXFRAME", DBG_RXFRAME },
  62. {"TXFRAME", DBG_TXFRAME },
  63. {"NDIS", DBG_NDIS },
  64. {"IRMAC", DBG_IRMAC },
  65. {"IRLAP", DBG_IRLAP },
  66. {"IRLAPLOG", DBG_IRLAPLOG },
  67. {"IRLMP", DBG_IRLMP },
  68. {"IRLMP_CONN", DBG_IRLMP_CONN },
  69. {"IRLMP_CRED", DBG_IRLMP_CRED },
  70. {"IRLMP_IAS", DBG_IRLMP_IAS },
  71. {"DISCOVERY", DBG_DISCOVERY },
  72. {"TDI", DBG_TDI },
  73. {"TDI_IRP", DBG_TDI_IRP },
  74. {"ALLOC", DBG_ALLOC },
  75. {"TIMER ", DBG_TIMER },
  76. {"PRINT", DBG_PRINT },
  77. {"ADDRESS", DBG_ADDR },
  78. {"REFERENCE", DBG_REF },
  79. {"FUNCTION", DBG_FUNCTION },
  80. {"WARN", DBG_WARN },
  81. {"ERROR", DBG_ERROR }};
  82. #endif
  83. char *IrlmpState[] =
  84. {"LINK_DOWN",
  85. "LINK_DISCONNECTED",
  86. "LINK_DISCONNECTING",
  87. "LINK_IN_DISCOVERY",
  88. "LINK_CONNECTING",
  89. "LINK_READY"};
  90. char *LsapState[] =
  91. {"LSAP_CREATED",
  92. "LSAP_DISCONNECTED",
  93. "LSAP_IRLAP_CONN_PEND",
  94. "LSAP_LMCONN_CONF_PEND",
  95. "LSAP_CONN_RESP_PEND",
  96. "LSAP_CONN_REQ_PEND",
  97. "LSAP_EXCLUSIVEMODE_PEND",
  98. "LSAP_MULTIPLEXEDMODE_PEND",
  99. "LSAP_READY",
  100. "LSAP_NO_TX_CREDIT"};
  101. char *ConnObjState[] =
  102. {"IRDA_CONN_CREATED",
  103. "IRDA_CONN_CLOSING",
  104. "IRDA_CONN_OPENING",
  105. "IRDA_CONN_OPEN"};
  106. char *IrlapState[] =
  107. { "NDM",
  108. "DSCV_MEDIA_SENSE",
  109. "DSCV_QUERY",
  110. "DSCV_REPLY",
  111. "CONN_MEDIA_SENSE",
  112. "SNRM_SENT",
  113. "BACKOFF_WAIT",
  114. "SNRM_RECEIVED",
  115. "P_XMIT",
  116. "P_RECV",
  117. "P_DISCONNECT_PEND",
  118. "P_CLOSE",
  119. "S_NRM",
  120. "S_DISCONNECT_PEND",
  121. "S_ERROR",
  122. "S_CLOSE"};
  123. /*
  124. * Print out an optional message, an ANSI_STRING, and maybe a new-line
  125. */
  126. BOOL
  127. PrintStringA( IN LPSTR msg OPTIONAL, IN PANSI_STRING pStr, IN BOOL nl )
  128. {
  129. PCHAR StringData;
  130. ULONG BytesRead;
  131. if( msg )
  132. dprintf( msg );
  133. if( pStr->Length == 0 ) {
  134. if( nl )
  135. dprintf( "\n" );
  136. return TRUE;
  137. }
  138. StringData = (PCHAR)LocalAlloc( LPTR, pStr->Length + 1 );
  139. if( StringData == NULL ) {
  140. ERRPRT( "Out of memory!\n" );
  141. return FALSE;
  142. }
  143. ReadMemory((ULONG_PTR) pStr->Buffer,
  144. StringData,
  145. pStr->Length,
  146. &BytesRead );
  147. if ( BytesRead ) {
  148. StringData[ pStr->Length ] = '\0';
  149. dprintf("%s%s", StringData, nl ? "\n" : "" );
  150. }
  151. LocalFree((HLOCAL)StringData);
  152. return BytesRead;
  153. }
  154. /*
  155. * Get 'size' bytes from the debuggee program at 'dwAddress' and place it
  156. * in our address space at 'ptr'. Use 'type' in an error printout if necessary
  157. */
  158. BOOL
  159. GetData( IN LPVOID ptr, IN DWORD_PTR dwAddress, IN ULONG size, IN PCSTR type )
  160. {
  161. BOOL b;
  162. ULONG BytesRead;
  163. ULONG count = size;
  164. while( size > 0 ) {
  165. if (count >= 3000)
  166. count = 3000;
  167. b = ReadMemory((ULONG) dwAddress, ptr, count, &BytesRead );
  168. if (!b || BytesRead != count ) {
  169. ERRPRT( "Unable to read %u bytes at %X, for %s\n", size, dwAddress, type );
  170. return FALSE;
  171. }
  172. dwAddress += count;
  173. size -= count;
  174. ptr = (LPVOID)((ULONG_PTR)ptr + count);
  175. }
  176. return TRUE;
  177. }
  178. /*
  179. * Follow a LIST_ENTRY list beginning with a head at dwListHeadAddr in the debugee's
  180. * address space. For each element in the list, print out the pointer value at 'offset'
  181. */
  182. BOOL
  183. PrintListEntryList( IN DWORD dwListHeadAddr, IN LONG offset )
  184. {
  185. LIST_ENTRY ListEntry;
  186. ULONG i=0;
  187. BOOL retval = TRUE;
  188. ULONG count = 20;
  189. if( !GetData( &ListEntry, dwListHeadAddr, sizeof( ListEntry ), "LIST_ENTRY" ) )
  190. return FALSE;
  191. while( count-- ) {
  192. if( (DWORD_PTR)ListEntry.Flink == dwListHeadAddr || (DWORD_PTR)ListEntry.Flink == 0 )
  193. break;
  194. if( !GetData( &ListEntry, (DWORD_PTR)ListEntry.Flink, (ULONG)sizeof( ListEntry ), "ListEntry" ) ) {
  195. retval = FALSE;
  196. break;
  197. }
  198. dprintf( "%16X%s", (DWORD_PTR)ListEntry.Flink + offset, (i && !(i&3)) ? "\n" : "" );
  199. i++;
  200. }
  201. if( count == 0 && (DWORD_PTR)ListEntry.Flink != dwListHeadAddr && ListEntry.Flink ) {
  202. dprintf( "\nTruncated list dump\n" );
  203. } else if( ! ( i && !(i&3) ) ) {
  204. dprintf( "\n" );
  205. }
  206. return retval;
  207. }
  208. /*
  209. * Print out a single HEX character
  210. */
  211. VOID
  212. PrintHexChar( IN UCHAR c )
  213. {
  214. dprintf( "%c%c", "0123456789abcdef"[ (c>>4)&0xf ], "0123456789abcdef"[ c&0xf ] );
  215. }
  216. /*
  217. * Print out 'buf' of 'cbuf' bytes as HEX characters
  218. */
  219. VOID
  220. PrintHexBuf( IN PUCHAR buf, IN ULONG cbuf )
  221. {
  222. while( cbuf-- ) {
  223. PrintHexChar( *buf++ );
  224. dprintf( " " );
  225. }
  226. }
  227. /*
  228. * Fetch the null terminated UNICODE string at dwAddress into buf
  229. */
  230. BOOL
  231. GetString( IN DWORD_PTR dwAddress, IN LPSTR buf, IN ULONG MaxChars )
  232. {
  233. do {
  234. if( !GetData( buf, dwAddress, sizeof( *buf ), "Character" ) )
  235. return FALSE;
  236. dwAddress += sizeof( *buf );
  237. } while( --MaxChars && *buf++ != '\0' );
  238. return TRUE;
  239. }
  240. char *mystrtok ( char *string, char * control )
  241. {
  242. static unsigned char *str;
  243. char *p, *s;
  244. if( string )
  245. str = string;
  246. if( str == NULL || *str == '\0' )
  247. return NULL;
  248. //
  249. // Skip leading delimiters...
  250. //
  251. for( ; *str; str++ ) {
  252. for( s=control; *s; s++ ) {
  253. if( *str == *s )
  254. break;
  255. }
  256. if( *s == '\0' )
  257. break;
  258. }
  259. //
  260. // Was it was all delimiters?
  261. //
  262. if( *str == '\0' ) {
  263. str = NULL;
  264. return NULL;
  265. }
  266. //
  267. // We've got a string, terminate it at first delimeter
  268. //
  269. for( p = str+1; *p; p++ ) {
  270. for( s = control; *s; s++ ) {
  271. if( *p == *s ) {
  272. s = str;
  273. *p = '\0';
  274. str = p+1;
  275. return s;
  276. }
  277. }
  278. }
  279. //
  280. // We've got a string that ends with the NULL
  281. //
  282. s = str;
  283. str = NULL;
  284. return s;
  285. }
  286. DECLARE_API( help )
  287. {
  288. int i;
  289. dprintf("IrDA extenstions:\n");
  290. dprintf(" dbgmsgs dump debug message buffer\n");
  291. dprintf(" dbg [Level [Level] ...] toggle debug level\n");
  292. }
  293. DECLARE_API( dbgmsgs )
  294. {
  295. DWORD p;
  296. DWORD Last, First;
  297. char DbgMsg[MAX_MSG_LEN];
  298. ULONG Read;
  299. char *DbgMsgs;
  300. if (!GetData(&Last,
  301. GetExpression("irda!Last"),
  302. sizeof(Last), "DWORD"))
  303. {
  304. dprintf("error\n");
  305. return;
  306. }
  307. if (!GetData(&First,
  308. GetExpression("irda!First"),
  309. sizeof(Last), "DWORD"))
  310. {
  311. dprintf("error\n");
  312. return;
  313. }
  314. DbgMsgs = (char *) GetExpression("irda!dbgmsgs");
  315. dprintf("\n\n");
  316. while (First != Last)
  317. {
  318. if (!GetString((DWORD_PTR) (DbgMsgs + First * MAX_MSG_LEN),
  319. DbgMsg, MAX_MSG_LEN))
  320. break;
  321. /*
  322. ReadMemory((ULONG) (DbgMsgs + First * MAX_MSG_LEN),
  323. DbgMsg, MAX_MSG_LEN, &Read); */
  324. dprintf("%s", DbgMsg);
  325. First++;
  326. if (First == DBG_MSG_CNT)
  327. First = 0;
  328. }
  329. }
  330. DECLARE_API( dbg )
  331. {
  332. #if 0
  333. int i;
  334. int col = 0;
  335. DWORD DbgSettings;
  336. char argbuf[ MAX_PATH ];
  337. char *p;
  338. DWORD_PTR dwAddress;
  339. DWORD Written;
  340. dwAddress = GetExpression("irda!dbgsettings");
  341. if (!GetData(&DbgSettings,
  342. dwAddress,
  343. sizeof(DbgSettings), "DWORD"))
  344. {
  345. dprintf("error\n");
  346. return;
  347. }
  348. if (!args || !*args)
  349. {
  350. dprintf("Current settings:\n");
  351. for (i = 0; i < sizeof(DbgLevel)/sizeof(DBG_LEVEL); i++)
  352. {
  353. if (DbgSettings & DbgLevel[i].Val)
  354. {
  355. dprintf(" %s", DbgLevel[i].Name);
  356. if (col == 4)
  357. {
  358. col = 0;
  359. dprintf("\n");
  360. }
  361. else
  362. {
  363. col ++;
  364. }
  365. }
  366. }
  367. if (col != 0)
  368. dprintf("\n");
  369. col = 0;
  370. dprintf("Available settings:\n");
  371. for (i = 0; i < sizeof(DbgLevel)/sizeof(DBG_LEVEL); i++)
  372. {
  373. if (!(DbgSettings & DbgLevel[i].Val))
  374. {
  375. dprintf(" %s", DbgLevel[i].Name);
  376. if (col == 4)
  377. {
  378. col = 0;
  379. dprintf("\n");
  380. }
  381. else
  382. {
  383. col++;
  384. }
  385. }
  386. }
  387. if (col != 0)
  388. dprintf("\n");
  389. return;
  390. }
  391. strcpy( argbuf, args );
  392. for (p = mystrtok( argbuf, " \t,;" );
  393. p && *p;
  394. p = mystrtok(NULL, " \t,;"))
  395. {
  396. for (i = 0; i < sizeof(DbgLevel)/sizeof(DBG_LEVEL); i++)
  397. {
  398. if (strcmp(p, DbgLevel[i].Name) == 0)
  399. {
  400. if (DbgSettings & DbgLevel[i].Val)
  401. {
  402. DbgSettings &= ~DbgLevel[i].Val;
  403. }
  404. else
  405. {
  406. DbgSettings |= DbgLevel[i].Val;
  407. }
  408. }
  409. }
  410. }
  411. WriteMemory(dwAddress, &DbgSettings, sizeof(DWORD), &Written);
  412. #endif
  413. }
  414. DECLARE_API( link )
  415. {
  416. LIST_ENTRY IrdaLinkCbListEntry, *pIrdaLinkCbListEntry;
  417. PIRDA_LINK_CB pIrdaLinkCb;
  418. IRDA_LINK_CB IrdaLinkCb;
  419. LIST_ENTRY *pListEntry, ListEntry, *pListHead;
  420. pIrdaLinkCbListEntry = (LIST_ENTRY *) GetExpression("irda!IrdaLinkCbList");
  421. if (!GetData(&IrdaLinkCbListEntry,
  422. (DWORD_PTR) pIrdaLinkCbListEntry,
  423. sizeof(LIST_ENTRY), "LIST_ENTRY"))
  424. {
  425. return;
  426. }
  427. for (pIrdaLinkCb = (PIRDA_LINK_CB) IrdaLinkCbListEntry.Flink;
  428. (LIST_ENTRY *) pIrdaLinkCb != pIrdaLinkCbListEntry;
  429. pIrdaLinkCb = (PIRDA_LINK_CB) IrdaLinkCb.Linkage.Flink)
  430. {
  431. if (!GetData(&IrdaLinkCb,
  432. (DWORD_PTR) pIrdaLinkCb,
  433. sizeof(IRDA_LINK_CB), "IRDA_LINK_CB"))
  434. {
  435. return;
  436. }
  437. dprintf("IrdaLinkCb:%X, Irlap:%X, Irlmp:%X NdisBindingHandle:%X\n", pIrdaLinkCb,
  438. IrdaLinkCb.IrlapContext, IrdaLinkCb.IrlmpContext,
  439. IrdaLinkCb.NdisBindingHandle);
  440. dprintf(" MinTat:%d, WaitMinTat:%d, SendOutCnt %d\n",
  441. IrdaLinkCb.MinTat, IrdaLinkCb.WaitMinTat, IrdaLinkCb.SendOutCnt);
  442. #if DBG
  443. dprintf(" DelayedRxFrameCnt %d\n", IrdaLinkCb.DelayedRxFrameCnt);
  444. #endif
  445. pListHead = (PLIST_ENTRY) ((char *) pIrdaLinkCb +
  446. FIELD_OFFSET(IRDA_LINK_CB, TxMsgFreeList));
  447. dprintf("TxMsgFreeList:%X len %d\n", pListHead,
  448. IrdaLinkCb.TxMsgFreeListLen);
  449. for (pListEntry = IrdaLinkCb.TxMsgFreeList.Flink;
  450. pListEntry != pListHead;
  451. pListEntry = ListEntry.Flink)
  452. {
  453. if (!GetData(&ListEntry,
  454. (DWORD_PTR) pListEntry,
  455. sizeof(LIST_ENTRY),
  456. "LIST_ENTRY"))
  457. {
  458. return;
  459. }
  460. dprintf(" %X\n", pListEntry);
  461. }
  462. pListHead = (PLIST_ENTRY) ((char *) pIrdaLinkCb +
  463. FIELD_OFFSET(IRDA_LINK_CB, RxMsgFreeList));
  464. dprintf("RxMsgFreeList:%X len %d\n", pListHead,
  465. IrdaLinkCb.RxMsgFreeListLen);
  466. for (pListEntry = IrdaLinkCb.RxMsgFreeList.Flink;
  467. pListEntry != pListHead;
  468. pListEntry = ListEntry.Flink)
  469. {
  470. if (!GetData(&ListEntry,
  471. (DWORD_PTR) pListEntry,
  472. sizeof(LIST_ENTRY),
  473. "LIST_ENTRY"))
  474. {
  475. return;
  476. }
  477. dprintf(" %X\n", pListEntry);
  478. }
  479. pListHead = (PLIST_ENTRY) ((char *) pIrdaLinkCb +
  480. FIELD_OFFSET(IRDA_LINK_CB, RxMsgList));
  481. dprintf("RxMsgList:%Xd\n", pListHead);
  482. for (pListEntry = IrdaLinkCb.RxMsgList.Flink;
  483. pListEntry != pListHead;
  484. pListEntry = ListEntry.Flink)
  485. {
  486. if (!GetData(&ListEntry,
  487. (DWORD_PTR) pListEntry,
  488. sizeof(LIST_ENTRY),
  489. "LIST_ENTRY"))
  490. {
  491. return;
  492. }
  493. dprintf(" %X\n", pListEntry);
  494. }
  495. }
  496. }
  497. DECLARE_API( irlmp )
  498. {
  499. LIST_ENTRY IrdaLinkCbListEntry, *pIrdaLinkCbListEntry;
  500. PIRDA_LINK_CB pIrdaLinkCb;
  501. IRDA_LINK_CB IrdaLinkCb;
  502. IRLMP_LINK_CB IrlmpLinkCb;
  503. PIRLMP_LSAP_CB pLsapCb;
  504. IRLMP_LSAP_CB LsapCb;
  505. IRDA_MSG *pMsg, IMsg;
  506. pIrdaLinkCbListEntry = (LIST_ENTRY *) GetExpression("irda!IrdaLinkCbList");
  507. if (!GetData(&IrdaLinkCbListEntry,
  508. (DWORD_PTR) pIrdaLinkCbListEntry,
  509. sizeof(LIST_ENTRY), "LIST_ENTRY"))
  510. {
  511. return;
  512. }
  513. for (pIrdaLinkCb = (PIRDA_LINK_CB) IrdaLinkCbListEntry.Flink;
  514. (LIST_ENTRY *) pIrdaLinkCb != pIrdaLinkCbListEntry;
  515. pIrdaLinkCb = (PIRDA_LINK_CB) IrdaLinkCb.Linkage.Flink)
  516. {
  517. if (!GetData(&IrdaLinkCb,
  518. (DWORD_PTR) pIrdaLinkCb,
  519. sizeof(IRDA_LINK_CB), "IRDA_LINK_CB"))
  520. {
  521. return;
  522. }
  523. if (!GetData(&IrlmpLinkCb,
  524. (DWORD_PTR) IrdaLinkCb.IrlmpContext,
  525. sizeof(IRLMP_LINK_CB), "IRLMP_LINK_CB"))
  526. {
  527. return;
  528. }
  529. dprintf("IrlmpLinkCb %x, State:%s, MaxSlot:%d, MaxPdu:%d, WindowSize:%d\n",
  530. IrdaLinkCb.IrlmpContext,
  531. IrlmpState[IrlmpLinkCb.LinkState],
  532. IrlmpLinkCb.MaxSlot, IrlmpLinkCb.MaxPDUSize,
  533. IrlmpLinkCb.WindowSize);
  534. dprintf(" Exclusive LsapCb:%x\n", IrlmpLinkCb.pExclLsapCb);
  535. for (pLsapCb = (PIRLMP_LSAP_CB) IrlmpLinkCb.LsapCbList.Flink;
  536. pLsapCb != (PIRLMP_LSAP_CB) ((char *)IrdaLinkCb.IrlmpContext + FIELD_OFFSET(IRLMP_LINK_CB, LsapCbList));
  537. pLsapCb = (PIRLMP_LSAP_CB) LsapCb.Linkage.Flink)
  538. {
  539. if (!GetData(&LsapCb,
  540. (DWORD_PTR) pLsapCb,
  541. sizeof(IRLMP_LSAP_CB), "IRLMP_LSAP_CB"))
  542. {
  543. return;
  544. }
  545. dprintf(" LsapCb:%x State:%s LocalLsapSel:%d RemoteLsapSel:%d\n",
  546. pLsapCb, LsapState[LsapCb.State],
  547. LsapCb.LocalLsapSel, LsapCb.RemoteLsapSel);
  548. dprintf(" TdiContext:%x AvailCredit:%d LocalCredit:%d RemoteCredit:%d, RefCnt:%d\n",
  549. LsapCb.TdiContext, LsapCb.AvailableCredit,
  550. LsapCb.LocalTxCredit,
  551. LsapCb.RemoteTxCredit,
  552. LsapCb.RefCnt.Count);
  553. dprintf(" TxMsgList:%x\n", LsapCb.TxMsgList);
  554. for (pMsg = (IRDA_MSG *) LsapCb.TxMsgList.Flink;
  555. pMsg != (IRDA_MSG *) ((char *) pLsapCb + FIELD_OFFSET(IRLMP_LSAP_CB, TxMsgList));
  556. pMsg = (IRDA_MSG *) IMsg.Linkage.Flink)
  557. {
  558. if (!GetData(&IMsg,
  559. (DWORD_PTR) pMsg,
  560. sizeof(IRDA_MSG), "IRDA_MSG"))
  561. {
  562. dprintf("error\n");
  563. }
  564. dprintf(" Msg:%x\n", pMsg);
  565. }
  566. dprintf(" SegTxMsgList:%x\n", LsapCb.TxMsgList);
  567. for (pMsg = (IRDA_MSG *) LsapCb.SegTxMsgList.Flink;
  568. pMsg != (IRDA_MSG *) ((char *) pLsapCb + FIELD_OFFSET(IRLMP_LSAP_CB, SegTxMsgList));
  569. pMsg = (IRDA_MSG *) IMsg.Linkage.Flink)
  570. {
  571. if (!GetData(&IMsg,
  572. (DWORD_PTR) pMsg,
  573. sizeof(IRDA_MSG), "IRDA_MSG"))
  574. {
  575. return;
  576. }
  577. dprintf(" Msg:%x\n", pMsg);
  578. }
  579. }
  580. }
  581. }
  582. DECLARE_API( irlap )
  583. {
  584. LIST_ENTRY IrdaLinkCbListEntry, *pIrdaLinkCbListEntry;
  585. IRDA_LINK_CB IrdaLinkCb, *pIrdaLinkCb;
  586. IRLAP_CB IrlapCb;
  587. int i;
  588. pIrdaLinkCbListEntry = (LIST_ENTRY *) GetExpression("irda!IrdaLinkCbList");
  589. if (!GetData(&IrdaLinkCbListEntry,
  590. (DWORD_PTR) pIrdaLinkCbListEntry,
  591. sizeof(LIST_ENTRY), "LIST_ENTRY"))
  592. {
  593. return;
  594. }
  595. for (pIrdaLinkCb = (PIRDA_LINK_CB) IrdaLinkCbListEntry.Flink;
  596. (LIST_ENTRY *) pIrdaLinkCb != pIrdaLinkCbListEntry;
  597. pIrdaLinkCb = (PIRDA_LINK_CB) IrdaLinkCb.Linkage.Flink)
  598. {
  599. if (!GetData(&IrdaLinkCb,
  600. (DWORD_PTR) pIrdaLinkCb,
  601. sizeof(IRDA_LINK_CB), "IRDA_LINK_CB"))
  602. {
  603. return;
  604. }
  605. if (!GetData(&IrlapCb,
  606. (DWORD_PTR) IrdaLinkCb.IrlapContext,
  607. sizeof(IRLAP_CB), "IRLAP_CB"))
  608. {
  609. return;
  610. }
  611. dprintf("\nIrlapCb:%X State:%s Vs:%d Vr:%d FTimerExpCnt:%d RetranCnt:%d\n",
  612. IrdaLinkCb.IrlapContext,
  613. IrlapState[IrlapCb.State],
  614. IrlapCb.Vs, IrlapCb.Vr, IrlapCb.FTimerExpCnt, IrlapCb.RetranCnt);
  615. #if DBG
  616. dprintf("DelayedConfirms:%d\n", IrlapCb.DelayedConf);
  617. #endif
  618. dprintf(" TxMsgList:%X\n",
  619. *(DWORD*)&IrlapCb.TxMsgList);
  620. dprintf(" RxWin start:%d end:%d pMsgs:\n",
  621. IrlapCb.RxWin.Start,
  622. IrlapCb.RxWin.End);
  623. for (i = 0; i < IRLAP_MOD; i++)
  624. {
  625. dprintf(" %d. %X\n", i, IrlapCb.RxWin.pMsg[i]);
  626. }
  627. dprintf("TxWin start:%d end:%d pMsgs:\n",
  628. IrlapCb.TxWin.Start,
  629. IrlapCb.TxWin.End);
  630. for (i = 0; i < IRLAP_MOD; i++)
  631. {
  632. dprintf(" %d. %X\n", i, IrlapCb.TxWin.pMsg[i]);
  633. }
  634. }
  635. }
  636. VOID
  637. DumpIrpList(LIST_ENTRY *pIrpList)
  638. {
  639. LIST_ENTRY IrpList, *pListEntry, ListEntry;
  640. IRP *pIrp;
  641. if (!GetData(&IrpList,
  642. (DWORD_PTR) pIrpList,
  643. sizeof(LIST_ENTRY), "LIST_ENTRY"))
  644. {
  645. return;
  646. }
  647. for (pListEntry = IrpList.Flink;
  648. pListEntry != pIrpList;
  649. pListEntry = ListEntry.Flink)
  650. {
  651. if (!GetData(&ListEntry,
  652. (DWORD_PTR) pListEntry,
  653. sizeof(LIST_ENTRY), "LIST_ENTRY"))
  654. {
  655. return;
  656. }
  657. pIrp = CONTAINING_RECORD(pListEntry, IRP, Tail.Overlay.ListEntry);
  658. dprintf(" %x\n", pIrp);
  659. }
  660. }
  661. DECLARE_API( tdi )
  662. {
  663. PIRDA_CONN_OBJ pConnObjList, pConnObj;
  664. PIRDA_ADDR_OBJ pAddrObjList, pAddrObj;
  665. IRDA_ADDR_OBJ AddrObj;
  666. IRDA_CONN_OBJ ConnObj;
  667. int i;
  668. pAddrObjList = (PIRDA_ADDR_OBJ) GetExpression("irda!AddrObjList");
  669. if (!GetData(&pAddrObj,
  670. (DWORD_PTR) pAddrObjList,
  671. sizeof(PIRDA_ADDR_OBJ), "IRDA_ADDR_OBJ_LIST"))
  672. {
  673. return;
  674. }
  675. if (pAddrObj == NULL)
  676. {
  677. dprintf("No address objects\n");
  678. return;
  679. }
  680. while (pAddrObj)
  681. {
  682. if (!GetData(&AddrObj,
  683. (DWORD_PTR) pAddrObj,
  684. sizeof(IRDA_ADDR_OBJ), "IRDA_ADDR_OBJ"))
  685. {
  686. return;
  687. }
  688. dprintf("AddrObj:%x Server:%s LocalLsapSel:%d Service:%s\n", pAddrObj,
  689. AddrObj.IsServer ? "TRUE":"FALSE", AddrObj.LocalLsapSel,
  690. AddrObj.LocalAddr.irdaServiceName);
  691. pConnObj = AddrObj.ConnObjList;
  692. if (pConnObj == NULL)
  693. {
  694. dprintf(" No connect objects\n");
  695. }
  696. while (pConnObj)
  697. {
  698. IRDA_RECV_BUF *pRecvBuf, RecvBuf;
  699. if (!GetData(&ConnObj,
  700. (DWORD_PTR) pConnObj,
  701. sizeof(IRDA_CONN_OBJ), "IRDA_CONN_OBJ"))
  702. {
  703. return;
  704. }
  705. dprintf(" ConnObj:%x State:%s Irlmp:%X TtpCreditsLeft:%d RecvBusy:%s\n",
  706. pConnObj,
  707. ConnObjState[ConnObj.ConnState],
  708. ConnObj.IrlmpContext,
  709. ConnObj.TtpRecvCreditsLeft,
  710. ConnObj.RecvBusy ? "TRUE":"FALSE");
  711. dprintf(" LocalLsapSel:%d Addr:\"%s\" RemoteLsapSel:%d Addr:\"%s\"\n",
  712. ConnObj.LocalLsapSel, ConnObj.LocalAddr.irdaServiceName,
  713. ConnObj.RemoteLsapSel, ConnObj.RemoteAddr.irdaServiceName);
  714. /*
  715. i = 0;
  716. for (pRecvBuf = (PIRDA_RECV_BUF) ConnObj.RecvBufList.Flink;
  717. pRecvBuf != (PIRDA_RECV_BUF) ((char *) pConnObj + FIELD_OFFSET(IRDA_CONN_OBJ, RecvBufList));
  718. pRecvBuf = (PIRDA_RECV_BUF) RecvBuf.Linkage.Flink)
  719. {
  720. i++;
  721. if (!GetData(&RecvBuf,
  722. (DWORD_PTR) pRecvBuf,
  723. sizeof(IRDA_RECV_BUF)-IRDA_MAX_DATA_SIZE,
  724. "IRDA_RECV_BUF"))
  725. {
  726. break;
  727. }
  728. dprintf(" RecvBuf:%x Len:%d Offset:%d\n",
  729. pRecvBuf, RecvBuf.Len, RecvBuf.Offset);
  730. if (i > 100)
  731. {
  732. dprintf(" !!! Infinite loop ???\n");
  733. break;
  734. }
  735. }
  736. */
  737. dprintf(" SendIrpList:\n");
  738. DumpIrpList((LIST_ENTRY *) ((char *) pConnObj + FIELD_OFFSET(IRDA_CONN_OBJ, SendIrpList)));
  739. dprintf(" RecvIrpList:\n");
  740. DumpIrpList((LIST_ENTRY *) ((char *) pConnObj + FIELD_OFFSET(IRDA_CONN_OBJ, RecvIrpList)));
  741. pConnObj = ConnObj.pNext;
  742. }
  743. pAddrObj = AddrObj.pNext;
  744. }
  745. dprintf("IasIrp %x\n", GetExpression("irda!pIasIrp"));
  746. dprintf("DscvIrpList:\n");
  747. DumpIrpList((LIST_ENTRY *) GetExpression("irda!DscvIrpList"));
  748. dprintf("IasIrpList:\n");
  749. DumpIrpList((LIST_ENTRY *) GetExpression("irda!IasIrpList"));
  750. dprintf("ConnIrpList:\n");
  751. DumpIrpList((LIST_ENTRY *) GetExpression("irda!ConnIrpList"));
  752. }
  753. VOID
  754. WinDbgExtensionDllInit(
  755. PWINDBG_EXTENSION_APIS lpExtensionApis,
  756. USHORT MajorVersion,
  757. USHORT MinorVersion
  758. )
  759. {
  760. ExtensionApis = *lpExtensionApis;
  761. SavedMajorVersion = MajorVersion;
  762. SavedMinorVersion = MinorVersion;
  763. ChkTarget = SavedMajorVersion == 0x0c ? TRUE : FALSE;
  764. }
  765. DECLARE_API( version )
  766. {
  767. #if DBG
  768. PCSTR kind = "Checked";
  769. #else
  770. PCSTR kind = "Free";
  771. #endif
  772. dprintf(
  773. "%s SMB Extension dll for Build %d debugging %s kernel for Build %d\n",
  774. kind,
  775. VER_PRODUCTBUILD,
  776. SavedMajorVersion == 0x0c ? "Checked" : "Free",
  777. SavedMinorVersion
  778. );
  779. }
  780. VOID
  781. CheckVersion(
  782. VOID
  783. )
  784. {
  785. #if DBG
  786. if ((SavedMajorVersion != 0x0c) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  787. dprintf("\r\n*** Extension DLL(%d Checked) does not match target system(%d %s)\r\n\r\n",
  788. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  789. }
  790. #else
  791. if ((SavedMajorVersion != 0x0f) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  792. dprintf("\r\n*** Extension DLL(%d Free) does not match target system(%d %s)\r\n\r\n",
  793. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  794. }
  795. #endif
  796. }
  797. LPEXT_API_VERSION
  798. ExtensionApiVersion(
  799. VOID
  800. )
  801. {
  802. return &ApiVersion;
  803. }