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.

3997 lines
133 KiB

  1. //*****************************************************************************
  2. //
  3. // Name: msrpc.c
  4. //
  5. // Description: MSRPC protocol parser.
  6. //
  7. // History:
  8. // 08/01/93 t-glennc Created.
  9. //
  10. //*****************************************************************************
  11. //*****************************************************************************
  12. //
  13. // Copyright (c) 1993 by Microsoft Corp. All rights reserved.
  14. //
  15. //*****************************************************************************
  16. #include "precomp.h"
  17. #pragma hdrstop
  18. // #define DEBUGBIND
  19. extern char IniFile[];
  20. extern HPROTOCOL hNETBIOS;
  21. HPROTOCOL hNBIPX;
  22. HPROTOCOL hSPX;
  23. HPROTOCOL hTCP;
  24. HPROTOCOL hSMB;
  25. HPROTOCOL hVinesTL;
  26. HPROTOCOL hIPX;
  27. HPROTOCOL hUDP;
  28. HPROTOCOL hCDP; // cluster dgram protocol
  29. int fUseFrmLen;
  30. int nIIDs; // the number of IIDs in our handoff table.
  31. IID_HANDOFF *HandoffTable;
  32. BINDTABLE * lpBindTable;
  33. HPROTOCOL FindBindParser (
  34. HFRAME hOrgFrame,
  35. HPROTOCOL hPrevProtocol,
  36. LPBYTE lpPrevProtocol,
  37. WORD PConID,
  38. LPWORD lpOpNum,
  39. LPDWORD lpBindVersion
  40. );
  41. HPROTOCOL FindParserInTable ( ULPDWORD lpDIID );
  42. LPBYTE FindDGRequestFrame(
  43. HFRAME hOrgFrame,
  44. DWORD UNALIGNED * lpOrigAID,
  45. DWORD OrigSeqNum
  46. );
  47. int FormatUUID ( LPSTR pIn, LPBYTE pIID);
  48. VOID WINAPIV FmtIID( LPPROPERTYINST lpPropertyInst );
  49. VOID AttachPContElem (
  50. p_cont_elem_t UNALIGNED * pContElem,
  51. BYTE nContext,
  52. HFRAME hFrame,
  53. DWORD Level,
  54. BOOL fLittleEndian
  55. );
  56. VOID AddEntryToBindTable ( DWORD OrgFrameNumber, HFRAME hBindFrame );
  57. LPBINDENTRY GetBindEntry ( DWORD nFrame );
  58. //DWORD FindInsertionPoint ( DWORD FindFrameNumber );
  59. VOID AttachIIDFromBindFrame ( HFRAME hFrame, HFRAME hBindFrame, DWORD Level );
  60. int _cdecl CompareBindEntry(const void *lpPtr1, const void *lpPtr2 );
  61. extern BOOL _cdecl bInsert(
  62. const void *lpNewRecord,
  63. const void *lpBase,
  64. DWORD Number,
  65. DWORD width,
  66. BOOL fAllowDuplicates,
  67. int ( __cdecl *compare )( const void *elem1, const void *elem2 )
  68. );
  69. //
  70. // MSRPC Types Labeled Set
  71. //
  72. LABELED_BYTE MSRPCTypes[] =
  73. {
  74. MSRPC_PDU_REQUEST, "Request",
  75. MSRPC_PDU_PING, "Ping",
  76. MSRPC_PDU_RESPONSE, "Response",
  77. MSRPC_PDU_FAULT, "Fault",
  78. MSRPC_PDU_WORKING, "Working",
  79. MSRPC_PDU_NOCALL, "No Call",
  80. MSRPC_PDU_REJECT, "Reject",
  81. MSRPC_PDU_ACK, "Ack",
  82. MSRPC_PDU_CL_CANCEL, "Cancel",
  83. MSRPC_PDU_FACK, "F Ack",
  84. MSRPC_PDU_CANCEL_ACK, "Cancel Ack",
  85. MSRPC_PDU_BIND, "Bind",
  86. MSRPC_PDU_BIND_ACK, "Bind Ack",
  87. MSRPC_PDU_BIND_NAK, "Bind Nak",
  88. MSRPC_PDU_ALTER_CONTEXT, "Alter Context",
  89. MSRPC_PDU_ALTER_CONTEXT_RESP, "Alter Context Responce",
  90. MSRPC_PDU_SHUTDOWN, "Shutdown",
  91. MSRPC_PDU_CO_CANCEL, "Cancel",
  92. MSRPC_PDU_ORPHANED, "Orphaned"
  93. };
  94. SET MSRPCTypesSet = {sizeof(MSRPCTypes)/sizeof(LABELED_BYTE), MSRPCTypes};
  95. //
  96. // MSRPC Reject Reason Labeled Set
  97. //
  98. LABELED_WORD MSRPCRejectReason[] =
  99. {
  100. 0, "Reason not specified",
  101. 1, "Temporary congestion",
  102. 2, "Local limit exceeded",
  103. 3, "Called presentation address unknown",
  104. 4, "Protocol version not supported",
  105. 5, "Default context not supported",
  106. 6, "User data not readable",
  107. 7, "No PSAP available",
  108. 8, "Authentication type not recognized",
  109. 9, "Invalid checksum"
  110. };
  111. SET MSRPCRejectReasonSet = {sizeof(MSRPCRejectReason)/sizeof(LABELED_WORD), MSRPCRejectReason};
  112. LPSTR RejectReason[] =
  113. {
  114. "Reason not specified",
  115. "Temporary congestion",
  116. "Local limit exceeded",
  117. "Called presentation address unknown",
  118. "Protocol version not supported",
  119. "Default context not supported",
  120. "User data not readable",
  121. "No PSAP available",
  122. "Authentication type not recognized",
  123. "Invalid checksum"
  124. "Invalid Reject Reason!"
  125. };
  126. //
  127. // MSRPC Result Labeled Set
  128. //
  129. LABELED_WORD MSRPCResult[] =
  130. {
  131. 0, "Acceptance",
  132. 1, "User rejection",
  133. 2, "Provider rejection"
  134. };
  135. SET MSRPCResultSet = {sizeof(MSRPCResult)/sizeof(LABELED_WORD), MSRPCResult};
  136. //
  137. // MSRPC Reason Labeled Set
  138. //
  139. LABELED_WORD MSRPCReason[] =
  140. {
  141. 0, "Reason not specified",
  142. 1, "Abstract syntax not supported",
  143. 2, "Proposed transfer syntaxes not supported",
  144. 3, "Local limit exceeded"
  145. };
  146. SET MSRPCReasonSet = {sizeof(MSRPCReason)/sizeof(LABELED_WORD), MSRPCReason};
  147. //
  148. // MSRPC PDU FLAGS - 1st Set
  149. //
  150. LABELED_BIT MSRPCFlags1[] =
  151. {
  152. {
  153. 0,
  154. "Reserved -or- Not the first fragment (AES/DC)",
  155. "Reserved -or- First fragment (AES/DC)",
  156. },
  157. {
  158. 1,
  159. "Not a last fragment -or- No cancel pending",
  160. "Last fragment -or- Cancel pending",
  161. },
  162. {
  163. 2,
  164. "Not a fragment -or- No cancel pending (AES/DC)",
  165. "Fragment -or- Cancel pending (AES/DC)",
  166. },
  167. {
  168. 3,
  169. "Receiver to repond with a fack PDU -or- Reserved (AES/DC)",
  170. "Receiver is not requested to repond with a fack PDU -or- Reserved (AES/DC)",
  171. },
  172. {
  173. 4,
  174. "Not used -or- Does not support concurrent multiplexing (AES/DC)",
  175. "For a maybe request (client-to-server only) -or- Supports concurrent multiplexing (AES/DC)",
  176. },
  177. {
  178. 5,
  179. "Not for an idempotent request -or- Did not execute guaranteed call (Fault PDU only) (AES/DC)",
  180. "For an idempotent request (client-to-server only) -or- Did not execute guaranteed call (Fault PDU only) (AES/DC)",
  181. },
  182. {
  183. 6,
  184. "Not for a broadcast request -or- 'Maybe' call semantics not requested (AES/DC)",
  185. "For a broadcast request (client-to-server only) -or- 'Maybe' call semantics requested (AES/DC)",
  186. },
  187. {
  188. 7,
  189. "Reserved -or- No object UUID specified in the optional object field (AES/DC)",
  190. "Reserved -or- None NIL object UUID specified in the optional object field (AES/DC)",
  191. }
  192. };
  193. SET MSRPCFlags1Set = {sizeof(MSRPCFlags1)/sizeof(LABELED_BIT), MSRPCFlags1};
  194. //
  195. // MSRPC PDU FLAGS - 2nd Set
  196. //
  197. LABELED_BIT MSRPCFlags2[] =
  198. {
  199. {
  200. 0,
  201. "Reserved",
  202. "Reserved",
  203. },
  204. {
  205. 1,
  206. "No cancel pending",
  207. "Cancel pending",
  208. },
  209. {
  210. 2,
  211. "Reserved",
  212. "Reserved",
  213. },
  214. {
  215. 3,
  216. "Reserved",
  217. "Reserved",
  218. },
  219. {
  220. 4,
  221. "Reserved",
  222. "Reserved",
  223. },
  224. {
  225. 5,
  226. "Reserved",
  227. "Reserved",
  228. },
  229. {
  230. 6,
  231. "Reserved",
  232. "Reserved",
  233. },
  234. {
  235. 7,
  236. "Reserved",
  237. "Reserved",
  238. }
  239. };
  240. SET MSRPCFlags2Set = {sizeof(MSRPCFlags2)/sizeof(LABELED_BIT), MSRPCFlags2};
  241. //
  242. // Property Info table for MSRPC protocol
  243. //
  244. PROPERTYINFO MSRPC_Prop[] =
  245. {
  246. // MSRPC_SUMMARY 0x00
  247. { 0,0,
  248. "Summary",
  249. "MS RPC Protocol Packet Summary",
  250. PROP_TYPE_SUMMARY,
  251. PROP_QUAL_NONE,
  252. NULL,
  253. 200,
  254. MSRPC_FmtSummary },
  255. // MSRPC_VERSION 0x01
  256. { 0,0,
  257. "Version",
  258. "MS RPC Version Number",
  259. PROP_TYPE_BYTE,
  260. PROP_QUAL_NONE,
  261. NULL,
  262. 200,
  263. FormatPropertyInstance },
  264. // MSRPC_VERSION_MINOR 0x02
  265. { 0,0,
  266. "Version (Minor)",
  267. "MS RPC Version Number (Minor)",
  268. PROP_TYPE_BYTE,
  269. PROP_QUAL_NONE,
  270. NULL,
  271. 200,
  272. FormatPropertyInstance },
  273. // MSRPC_PTYPE 0x03
  274. { 0,0,
  275. "Packet Type",
  276. "MS RPC Packet Type (c/o & dg header prop)",
  277. PROP_TYPE_BYTE,
  278. PROP_QUAL_LABELED_SET,
  279. &MSRPCTypesSet,
  280. 200,
  281. FormatPropertyInstance },
  282. // MSRPC_PFC_FLAGS1 0x04
  283. { 0,0,
  284. "Flags 1",
  285. "MS RPC Flags 1 (c/o & dg header prop)",
  286. PROP_TYPE_BYTE,
  287. PROP_QUAL_NONE,
  288. NULL,
  289. 200,
  290. FormatPropertyInstance },
  291. // MSRPC_PFC_FLAGS1_BITS 0x05
  292. { 0,0,
  293. "Flags 1 (Bits)",
  294. "MS RPC Flags 1 (Bits)",
  295. PROP_TYPE_BYTE,
  296. PROP_QUAL_FLAGS,
  297. &MSRPCFlags1Set,
  298. 200 * 8,
  299. FormatPropertyInstance },
  300. // MSRPC_PACKED_DREP 0x06
  301. { 0,0,
  302. "Packed Data Representation",
  303. "MS RPC Packed Data Representation (c/o & dg header prop)",
  304. PROP_TYPE_VOID,
  305. PROP_QUAL_NONE,
  306. NULL,
  307. 200,
  308. FormatPropertyInstance },
  309. // MSRPC_FRAG_LENGTH 0x07
  310. { 0,0,
  311. "Fragment Length",
  312. "MS RPC Fragment Length (c/o header prop)",
  313. PROP_TYPE_WORD,
  314. PROP_QUAL_NONE,
  315. NULL,
  316. 200,
  317. FormatPropertyInstance },
  318. // MSRPC_AUTH_LENGTH 0x08
  319. { 0,0,
  320. "Authentication Length",
  321. "MS RPC Authentication Length (c/o header prop)",
  322. PROP_TYPE_WORD,
  323. PROP_QUAL_NONE,
  324. NULL,
  325. 200,
  326. FormatPropertyInstance },
  327. // MSRPC_CALL_ID 0x09
  328. { 0,0,
  329. "Call Identifier",
  330. "MS RPC Call Identifier (c/o header prop)",
  331. PROP_TYPE_DWORD,
  332. PROP_QUAL_NONE,
  333. NULL,
  334. 200,
  335. FormatPropertyInstance },
  336. // MSRPC_MAX_XMIT_FRAG 0x0A
  337. { 0,0,
  338. "Max Trans Frag Size",
  339. "MS RPC Maximum Transmition Fragment Size",
  340. PROP_TYPE_WORD,
  341. PROP_QUAL_NONE,
  342. NULL,
  343. 200,
  344. FormatPropertyInstance },
  345. // MSRPC_MAX_RECV_FRAG 0x0B
  346. { 0,0,
  347. "Max Recv Frag Size",
  348. "MS RPC Maximum Receiver Fragment Size",
  349. PROP_TYPE_WORD,
  350. PROP_QUAL_NONE,
  351. NULL,
  352. 200,
  353. FormatPropertyInstance },
  354. // MSRPC_ASSOC_GROUP_ID 0x0C
  355. { 0,0,
  356. "Assoc Group Identifier",
  357. "MS RPC Association Group Identifier",
  358. PROP_TYPE_DWORD,
  359. PROP_QUAL_NONE,
  360. NULL,
  361. 200,
  362. FormatPropertyInstance },
  363. // MSRPC_P_CONTEXT_SUM 0x0D
  364. { 0,0,
  365. "Presentation Context List",
  366. "MS RPC Presentation Context List",
  367. PROP_TYPE_VOID,
  368. PROP_QUAL_NONE,
  369. NULL,
  370. 200,
  371. FormatPropertyInstance },
  372. // MSRPC_AUTH_VERIFIER 0x0E
  373. { 0,0,
  374. "Authentication Verifier",
  375. "MS RPC Authentication Verifier",
  376. PROP_TYPE_VOID,
  377. PROP_QUAL_NONE,
  378. NULL,
  379. 200,
  380. FormatPropertyInstance },
  381. // MSRPC_SEC_ADDR 0x0F
  382. { 0,0,
  383. "Secondary Address",
  384. "MS RPC Secondary Address",
  385. PROP_TYPE_VOID,
  386. PROP_QUAL_NONE,
  387. NULL,
  388. 200,
  389. FormatPropertyInstance },
  390. // MSRPC_PAD 0x10
  391. { 0,0,
  392. "Padding Byte(s)",
  393. "MS RPC Padding Byte(s) - 4 Octet alignment",
  394. PROP_TYPE_VOID,
  395. PROP_QUAL_NONE,
  396. NULL,
  397. 200,
  398. FormatPropertyInstance },
  399. // MSRPC_P_RESULT_LIST 0x11
  400. { 0,0,
  401. "Result List",
  402. "MS RPC Presentation Context Result List",
  403. PROP_TYPE_VOID,
  404. PROP_QUAL_NONE,
  405. NULL,
  406. 200,
  407. FormatPropertyInstance },
  408. // MSRPC_PROVIDER_REJECT_REASON 0x12
  409. { 0,0,
  410. "Provider Reject Reason",
  411. "MS RPC Provider Reject Reason",
  412. PROP_TYPE_WORD,
  413. PROP_QUAL_LABELED_SET,
  414. &MSRPCRejectReasonSet,
  415. 200,
  416. FormatPropertyInstance },
  417. // MSRPC_VERSIONS_SUPPORTED 0x13
  418. { 0,0,
  419. "Versions Supported",
  420. "MS RPC Protocol Versions Supported",
  421. PROP_TYPE_VOID,
  422. PROP_QUAL_NONE,
  423. NULL,
  424. 200,
  425. FormatPropertyInstance },
  426. // MSRPC_ALLOC_HINT 0x14
  427. { 0,0,
  428. "Allocation Hint",
  429. "MS RPC Allocation Hint",
  430. PROP_TYPE_DWORD,
  431. PROP_QUAL_NONE,
  432. NULL,
  433. 200,
  434. FormatPropertyInstance },
  435. // MSRPC_PRES_CONTEXT_ID 0x15
  436. { 0,0,
  437. "Presentation Context Identifier",
  438. "MS RPC Presentation Context Identifier",
  439. PROP_TYPE_WORD,
  440. PROP_QUAL_NONE,
  441. NULL,
  442. 200,
  443. FormatPropertyInstance },
  444. // MSRPC_CANCEL_COUNT 0x16
  445. { 0,0,
  446. "Cancel Count",
  447. "MS RPC Cancel Count",
  448. PROP_TYPE_BYTE,
  449. PROP_QUAL_NONE,
  450. NULL,
  451. 200,
  452. FormatPropertyInstance },
  453. // MSRPC_RESERVED 0x17
  454. { 0,0,
  455. "Reserved",
  456. "MS RPC Reserved",
  457. PROP_TYPE_BYTE,
  458. PROP_QUAL_NONE,
  459. NULL,
  460. 200,
  461. FormatPropertyInstance },
  462. // MSRPC_STATUS 0x18
  463. { 0,0,
  464. "Status",
  465. "MS RPC Status",
  466. PROP_TYPE_DWORD,
  467. PROP_QUAL_NONE,
  468. NULL,
  469. 200,
  470. FormatPropertyInstance },
  471. // MSRPC_RESERVED_2 0x19
  472. { 0,0,
  473. "Reserved 2",
  474. "MS RPC Reserved 2",
  475. PROP_TYPE_VOID,
  476. PROP_QUAL_NONE,
  477. NULL,
  478. 200,
  479. FormatPropertyInstance },
  480. // MSRPC_STUB_DATA 0x1A
  481. { 0,0,
  482. "Stub Data",
  483. "MS RPC Stub Data",
  484. PROP_TYPE_VOID,
  485. PROP_QUAL_NONE,
  486. NULL,
  487. 200,
  488. FormatPropertyInstance },
  489. // MSRPC_OPNUM 0x1B
  490. { 0,0,
  491. "Operation Number (c/o Request prop. dg header prop)",
  492. "MS RPC Operation Number (c/o Request prop. dg header prop)",
  493. PROP_TYPE_WORD,
  494. PROP_QUAL_NONE,
  495. NULL,
  496. 200,
  497. FormatPropertyInstance },
  498. // MSRPC_OBJECT 0x1C
  499. { 0,0,
  500. "Object",
  501. "MS RPC Object",
  502. PROP_TYPE_VOID,
  503. PROP_QUAL_NONE,
  504. NULL,
  505. 200,
  506. FormatPropertyInstance },
  507. // MSRPC_PFC_FLAGS2 0x1D
  508. { 0,0,
  509. "Flags 2 (dg header prop)",
  510. "MS RPC Flags 2 (dg header prop)",
  511. PROP_TYPE_BYTE,
  512. PROP_QUAL_NONE,
  513. NULL,
  514. 200,
  515. FormatPropertyInstance },
  516. // MSRPC_PFC_FLAGS2_BITS 0x1E
  517. { 0,0,
  518. "Flags 2 (Bits)",
  519. "MS RPC Flags 2 (Bits)",
  520. PROP_TYPE_BYTE,
  521. PROP_QUAL_FLAGS,
  522. &MSRPCFlags2Set,
  523. 200 * 8,
  524. FormatPropertyInstance },
  525. // MSRPC_SERIAL_HI 0x1F
  526. { 0,0,
  527. "Serial Number High Byte",
  528. "MS RPC Serial Number High Byte (dg header prop)",
  529. PROP_TYPE_BYTE,
  530. PROP_QUAL_NONE,
  531. NULL,
  532. 200,
  533. FormatPropertyInstance },
  534. // MSRPC_OBJECT_ID 0x20
  535. { 0,0,
  536. "Object Identifier",
  537. "MS RPC Object Identifier (dg header prop)",
  538. PROP_TYPE_BYTE,
  539. PROP_QUAL_ARRAY,
  540. NULL,
  541. 200,
  542. FmtIID },
  543. // MSRPC_INTERFACE_ID 0x21
  544. { 0,0,
  545. "Interface Identifier",
  546. "MS RPC Interface Identifier (dg header prop)",
  547. PROP_TYPE_BYTE,
  548. PROP_QUAL_ARRAY,
  549. NULL,
  550. 200,
  551. FmtIID },
  552. // MSRPC_ACTIVITY_ID 0x22
  553. { 0,0,
  554. "Activity Identifier",
  555. "MS RPC Activity Identifier (dg header prop)",
  556. PROP_TYPE_BYTE,
  557. PROP_QUAL_ARRAY,
  558. NULL,
  559. 200,
  560. FmtIID },
  561. // MSRPC_SERVER_BOOT_TIME 0x23
  562. { 0,0,
  563. "Server Boot Time",
  564. "MS RPC Server Boot Time (dg header prop)",
  565. PROP_TYPE_DWORD,
  566. PROP_QUAL_NONE,
  567. NULL,
  568. 200,
  569. FormatPropertyInstance },
  570. // MSRPC_INTERFACE_VER 0x24
  571. { 0,0,
  572. "Interface Version (dg header prop)",
  573. "MS RPC Interface Version (dg header prop)",
  574. PROP_TYPE_DWORD,
  575. PROP_QUAL_NONE,
  576. NULL,
  577. 200,
  578. FormatPropertyInstance },
  579. // MSRPC_SEQ_NUM 0x25
  580. { 0,0,
  581. "Sequence Number (dg header prop)",
  582. "MS RPC Sequence Number (dg header prop)",
  583. PROP_TYPE_DWORD,
  584. PROP_QUAL_NONE,
  585. NULL,
  586. 200,
  587. FormatPropertyInstance },
  588. // MSRPC_INTERFACE_HINT 0x26
  589. { 0,0,
  590. "Interface Hint",
  591. "MS RPC Interface Hint (dg header prop)",
  592. PROP_TYPE_WORD,
  593. PROP_QUAL_NONE,
  594. NULL,
  595. 200,
  596. FormatPropertyInstance },
  597. // MSRPC_ACTIVITY_HINT 0x27
  598. { 0,0,
  599. "Activity Hint",
  600. "MS RPC Activity Hint (dg header prop)",
  601. PROP_TYPE_WORD,
  602. PROP_QUAL_NONE,
  603. NULL,
  604. 200,
  605. FormatPropertyInstance },
  606. // MSRPC_LEN_OF_PACKET_BODY 0x28
  607. { 0,0,
  608. "Packet Body Length",
  609. "MS RPC Packet Body Length (dg header prop)",
  610. PROP_TYPE_WORD,
  611. PROP_QUAL_NONE,
  612. NULL,
  613. 200,
  614. FormatPropertyInstance },
  615. // MSRPC_FRAG_NUM 0x29
  616. { 0,0,
  617. "Fragment Number",
  618. "MS RPC Fragment Number (dg header prop)",
  619. PROP_TYPE_WORD,
  620. PROP_QUAL_NONE,
  621. NULL,
  622. 200,
  623. FormatPropertyInstance },
  624. // MSRPC_AUTH_PROTO_ID 0x2A
  625. { 0,0,
  626. "Authentication Protocol Identifier",
  627. "MS RPC Authentication Protocol Identifier (dg header prop)",
  628. PROP_TYPE_BYTE,
  629. PROP_QUAL_NONE,
  630. NULL,
  631. 200,
  632. FormatPropertyInstance },
  633. // MSRPC_SERIAL_LO 0x2B
  634. { 0,0,
  635. "Serial Number Low Byte",
  636. "MS RPC Serial Number Low Byte (dg header prop)",
  637. PROP_TYPE_BYTE,
  638. PROP_QUAL_NONE,
  639. NULL,
  640. 200,
  641. FormatPropertyInstance },
  642. // MSRPC_CANCEL_ID 0x2C
  643. { 0,0,
  644. "Identifier of Cancel/Request Event Being Ack'd",
  645. "MS RPC Identifier of Cancel/Request Event Being Ack'd",
  646. PROP_TYPE_DWORD,
  647. PROP_QUAL_NONE,
  648. NULL,
  649. 200,
  650. FormatPropertyInstance },
  651. // MSRPC_SERVER_IS_ACCEPTING 0x2D
  652. { 0,0,
  653. "Is Server Accepting Cancels",
  654. "MS RPC Is Server Accepting Cancels",
  655. PROP_TYPE_DWORD,
  656. PROP_QUAL_NONE,
  657. NULL,
  658. 200,
  659. FormatPropertyInstance },
  660. // MSRPC_STATUS_CODE 0x2E
  661. { 0,0,
  662. "Status Code",
  663. "MS RPC Status Code",
  664. PROP_TYPE_DWORD,
  665. PROP_QUAL_NONE,
  666. NULL,
  667. 200,
  668. FormatPropertyInstance },
  669. // MSRPC_WINDOW_SIZE 0x2F
  670. { 0,0,
  671. "Window Size",
  672. "MS RPC Window Size",
  673. PROP_TYPE_WORD,
  674. PROP_QUAL_NONE,
  675. NULL,
  676. 200,
  677. FormatPropertyInstance },
  678. // MSRPC_MAX_TPDU 0x30
  679. { 0,0,
  680. "Largest Local TPDU Size",
  681. "MS RPC Largest Local TPDU Size",
  682. PROP_TYPE_DWORD,
  683. PROP_QUAL_NONE,
  684. NULL,
  685. 200,
  686. FormatPropertyInstance },
  687. // MSRPC_MAX_PATH_TPDU 0x31
  688. { 0,0,
  689. "Largest TPDU Not Fragmented",
  690. "MS RPC Largest TPDU Not Fragmented",
  691. PROP_TYPE_DWORD,
  692. PROP_QUAL_NONE,
  693. NULL,
  694. 200,
  695. FormatPropertyInstance },
  696. // MSRPC_SERIAL_NUM 0x32
  697. { 0,0,
  698. "Serial number of packet that induced this fack",
  699. "MS RPC Serial number of packet that induced this fack",
  700. PROP_TYPE_WORD,
  701. PROP_QUAL_NONE,
  702. NULL,
  703. 200,
  704. FormatPropertyInstance },
  705. // MSRPC_SELACK_LEN 0x33
  706. { 0,0,
  707. "Number of Selective Ack Elements",
  708. "MS RPC Number of Selective Ack Elements",
  709. PROP_TYPE_WORD,
  710. PROP_QUAL_NONE,
  711. NULL,
  712. 200,
  713. FormatPropertyInstance },
  714. // MSRPC_SELACK 0x34
  715. { 0,0,
  716. "Selective Ack Elements",
  717. "MS RPC Selective Ack Elements",
  718. PROP_TYPE_VOID,
  719. PROP_QUAL_NONE,
  720. NULL,
  721. 200,
  722. FormatPropertyInstance },
  723. // MSRPC_CANCEL_REQUEST_FMT_VER 0x35
  724. { 0,0,
  725. "Cancel/Request Body Format Version",
  726. "MS RPC Cancel/Request Body Format Version",
  727. PROP_TYPE_DWORD,
  728. PROP_QUAL_NONE,
  729. NULL,
  730. 200,
  731. FormatPropertyInstance },
  732. // MSRPC_SEQ_NUMBER 0x36
  733. { 0,0,
  734. "Netbios Sequence Number",
  735. "MS RPC Netbios Sequence Number",
  736. PROP_TYPE_DWORD,
  737. PROP_QUAL_NONE,
  738. NULL,
  739. 200,
  740. FormatPropertyInstance },
  741. // MSRPC_SEC_ADDR_LENGTH 0x37
  742. { 0,0,
  743. "Secondary Address Length",
  744. "MS RPC Secondary Address Length",
  745. PROP_TYPE_WORD,
  746. PROP_QUAL_NONE,
  747. NULL,
  748. 200,
  749. FormatPropertyInstance },
  750. // MSRPC_SEC_ADDR_PORT 0x38
  751. { 0,0,
  752. "Secondary Address Port",
  753. "MS RPC Secondary Address Port",
  754. PROP_TYPE_VOID,
  755. PROP_QUAL_NONE,
  756. NULL,
  757. 200,
  758. FormatPropertyInstance },
  759. // MSRPC_N_RESULTS 0x39
  760. { 0,0,
  761. "Number of Results",
  762. "MS RPC Number of Results",
  763. PROP_TYPE_BYTE,
  764. PROP_QUAL_NONE,
  765. NULL,
  766. 200,
  767. FormatPropertyInstance },
  768. // MSRPC_P_RESULTS 0x3A
  769. { 0,0,
  770. "Presentation Context Results",
  771. "MS RPC Presentation Context Results",
  772. PROP_TYPE_VOID,
  773. PROP_QUAL_NONE,
  774. NULL,
  775. 200,
  776. FormatPropertyInstance },
  777. // MSRPC_P_CONT_DEF_RESULT 0x3B
  778. { 0,0,
  779. "Result",
  780. "MS RPC Result",
  781. PROP_TYPE_WORD,
  782. PROP_QUAL_LABELED_SET,
  783. &MSRPCResultSet,
  784. 200,
  785. FormatPropertyInstance },
  786. // MSRPC_P_PROVIDER_REASON 0x3C
  787. { 0,0,
  788. "Reason",
  789. "MS RPC Reason",
  790. PROP_TYPE_WORD,
  791. PROP_QUAL_LABELED_SET,
  792. &MSRPCReasonSet,
  793. 200,
  794. FormatPropertyInstance },
  795. // MSRPC_P_TRANSFER_SYNTAX 0x3A
  796. { 0,0,
  797. "Transfer Syntax",
  798. "MS RPC Transfer Syntax",
  799. PROP_TYPE_VOID,
  800. PROP_QUAL_NONE,
  801. NULL,
  802. 200,
  803. FormatPropertyInstance },
  804. // MSRPC_IF_UUID 0x3E
  805. { 0,0,
  806. "Interface UUID",
  807. "MS RPC Interface UUID",
  808. PROP_TYPE_BYTE,
  809. PROP_QUAL_ARRAY,
  810. NULL,
  811. 200,
  812. FmtIID },
  813. // MSRPC_IF_VERSION 0x3F
  814. { 0,0,
  815. "Interface Version (c/o BindAck and AltContResp prop)",
  816. "MS RPC Interface Version (c/o BindAck and AltContResp property)",
  817. PROP_TYPE_DWORD,
  818. PROP_QUAL_NONE,
  819. NULL,
  820. 200,
  821. FormatPropertyInstance },
  822. // MSRPC_P_CONTEXT_ELEM 0x40
  823. { 0,0,
  824. "Number of Context Elements",
  825. "Number of items.",
  826. PROP_TYPE_BYTE,
  827. PROP_QUAL_NONE,
  828. NULL,
  829. 80,
  830. FormatPropertyInstance },
  831. // MSRPC_NUM_TRANSFER_SYNTAX 0x41
  832. { 0,0,
  833. "Number of Transfer Syntaxs",
  834. "MS RPC Transfer Syntax count",
  835. PROP_TYPE_BYTE,
  836. PROP_QUAL_NONE,
  837. NULL,
  838. 80,
  839. FormatPropertyInstance },
  840. // MSRPC_ABSTRACT_IF_UUID 0x3E
  841. { 0,0,
  842. "Abstract Interface UUID",
  843. "Abstract Syntax Interface UUID",
  844. PROP_TYPE_BYTE,
  845. PROP_QUAL_ARRAY,
  846. NULL,
  847. 100,
  848. FmtIID },
  849. // MSRPC_ABSTRACT_IF_VERSION 0x3F
  850. { 0,0,
  851. "Abstract Interface Version",
  852. "Abstract Syntax Interface Version",
  853. PROP_TYPE_DWORD,
  854. PROP_QUAL_NONE,
  855. NULL,
  856. 80,
  857. FormatPropertyInstance },
  858. // MSRPC_TRANSFER_IF_UUID 0x3E
  859. { 0,0,
  860. "Transfer Interface UUID",
  861. "Transfer Syntax Interface UUID",
  862. PROP_TYPE_BYTE,
  863. PROP_QUAL_ARRAY,
  864. NULL,
  865. 100,
  866. FmtIID },
  867. // MSRPC_TRANSFER_IF_VERSION
  868. { 0,0,
  869. "Transfer Interface Version",
  870. "Transfer Syntax Interface Version",
  871. PROP_TYPE_DWORD,
  872. PROP_QUAL_NONE,
  873. NULL,
  874. 80,
  875. FormatPropertyInstance },
  876. // MSRPC_BIND_FRAME_NUMBER 0x46
  877. { 0,0,
  878. "Bind Frame Number",
  879. "The frame number that defines the IID for this request or response.",
  880. PROP_TYPE_DWORD,
  881. PROP_QUAL_NONE,
  882. NULL,
  883. 80,
  884. FormatPropertyInstance },
  885. };
  886. #define NUM_MSRPC_PROPERTIES (sizeof MSRPC_Prop / PROPERTYINFO_SIZE)
  887. // A few simple helper functions
  888. BOOL PFC_OBJECT_UUID( BYTE Flag )
  889. {
  890. if ( Flag >= 0x80 )
  891. return TRUE;
  892. else
  893. return FALSE;
  894. }
  895. BOOL IsLittleEndian( BYTE value )
  896. {
  897. if ( value >= 0x10 )
  898. return TRUE;
  899. else
  900. return FALSE;
  901. }
  902. void AttachProperty( BOOL fIsLittleEndian,
  903. HFRAME hFrame,
  904. HPROPERTY hProperty,
  905. DWORD Length,
  906. ULPVOID lpData,
  907. DWORD HelpID,
  908. DWORD Level,
  909. DWORD fError)
  910. {
  911. ULPVOID lpSwappedData = lpData;
  912. // WORD wordChunk;
  913. // DWORD dwordChunk;
  914. AttachPropertyInstance( hFrame,
  915. hProperty,
  916. Length,
  917. lpData,
  918. HelpID,
  919. Level,
  920. fIsLittleEndian?(fError?IFLAG_ERROR:0):(fError?IFLAG_ERROR|IFLAG_SWAPPED:IFLAG_SWAPPED) );
  921. /*
  922. else
  923. {
  924. if ( Length == sizeof( WORD ) )
  925. {
  926. memcpy( &wordChunk, lpData, sizeof( WORD ) );
  927. wordChunk = XCHG( wordChunk );
  928. lpSwappedData = &wordChunk;
  929. }
  930. else
  931. {
  932. memcpy( &dwordChunk, lpData, sizeof( DWORD ) );
  933. dwordChunk = DXCHG( dwordChunk );
  934. lpSwappedData = &dwordChunk;
  935. }
  936. AttachPropertyInstanceEx( hFrame, hProperty,
  937. Length, lpData,
  938. Length, lpSwappedData,
  939. HelpID, Level, fError );
  940. }
  941. */
  942. }
  943. //*****************************************************************************
  944. //
  945. // Name: MSRPC_Register
  946. //
  947. // Description: Registers MSRPC protocol parser property database.
  948. //
  949. // Parameters: HPARSER hParser: handle to the parser.
  950. //
  951. // Return Code: BOOL: TRUE if all is successful.
  952. //
  953. // History:
  954. // 08/01/93 t-glennc Created.
  955. // 08/29/95 SteveHi build IID handoff table to target next parser.
  956. //
  957. //*****************************************************************************
  958. VOID WINAPI MSRPC_Register( HPROTOCOL hMSRPC )
  959. {
  960. register WORD idx;
  961. int i,Count;
  962. DWORD nChars;
  963. // Create the database for the MSRPC protocol
  964. fUseFrmLen = GetPrivateProfileInt( "MSRPC", "USE_FRAME_LENGTH_DURING_RECOGNIZE", 1, IniFile );
  965. // build the IID handoff table.
  966. //_asm int 3;
  967. nIIDs = GetPrivateProfileInt( "FollowSet", "NumIIDs", 0, IniFile );
  968. if (nIIDs)
  969. {
  970. char ValueString[20] = {"IID_VALUE1"};
  971. char HandleString[20] = {"IID_HANDOFF1"};
  972. char RetString[200];
  973. Count = 0;
  974. HandoffTable = (IID_HANDOFF *)HeapAlloc ( GetProcessHeap(), HEAP_ZERO_MEMORY,
  975. sizeof (IID_HANDOFF) * nIIDs);
  976. // _asm int 3;
  977. for ( i=0;i<nIIDs;i++)
  978. {
  979. // use i to target specific strings in the ini file.
  980. // Count will only be incremented on successful finding of a followon parser.
  981. if ( i<9) // 1 relative...
  982. {
  983. ValueString[9]='1'+i; // this is not localizable, but then, neither is the .ini file.
  984. HandleString[11]='1'+i;
  985. }
  986. else
  987. {
  988. ValueString[9]='0'+(i+1)/10; // this is not localizable, but then, neither is the .ini file.
  989. ValueString[12]='\0';
  990. ValueString[10]='0'+(i+1)%10;
  991. HandleString[11]='0'+(i+1)/10;
  992. HandleString[12]='0'+(i+1)%10;
  993. HandleString[13]='\0';
  994. }
  995. // see if the handle exists first before attempting to convert
  996. // the IID string to a number.
  997. nChars = GetPrivateProfileString ( "FollowSet",
  998. HandleString,
  999. "0",
  1000. RetString,
  1001. 200,
  1002. IniFile );
  1003. if (nChars) // we have a target... see if we have an enabled parser with that name.
  1004. {
  1005. HandoffTable[Count].hNext = GetProtocolFromName(RetString);
  1006. if ( HandoffTable[Count].hNext ) // then we have a valid handle... extract the iid from the string
  1007. {
  1008. nChars = GetPrivateProfileString ( "FollowSet",
  1009. ValueString,
  1010. "0",
  1011. RetString,
  1012. 200,
  1013. IniFile );
  1014. if ( nChars >= 32 ) // possibly valid...
  1015. {
  1016. char *pChar = RetString;
  1017. char *pEnd = &RetString[strlen(RetString)];
  1018. int n=0;
  1019. BYTE Hi, Low;
  1020. while ((*pChar==' ')||(*pChar=='\t'))
  1021. pChar++;
  1022. // we have a string of hex values... convert them into our IID datastruct
  1023. while ( pChar <= pEnd )
  1024. {
  1025. // do Hex conversion
  1026. if ( *pChar > '9' )
  1027. Hi = toupper (*pChar++) - 'A' + 10;
  1028. else
  1029. Hi = *pChar++ - '0';
  1030. if ( *pChar > '9' )
  1031. Low = toupper (*pChar++) - 'A' + 10;
  1032. else
  1033. Low = *pChar++ - '0';
  1034. if (( Hi > 16 ) || (Low > 16) || (Hi <0) || (Low <0))
  1035. break;
  1036. HandoffTable[Count].ByteRep[n++] = (char)(Hi << 4) + (char)Low;
  1037. if ( n==16)
  1038. break;
  1039. }
  1040. // did we get 16??
  1041. if ( n == 16 )
  1042. {
  1043. Count++;
  1044. }
  1045. }
  1046. }
  1047. }
  1048. }
  1049. nIIDs = Count; // adjust the nIIDs down to the valid ones...
  1050. }
  1051. CreatePropertyDatabase( hMSRPC, NUM_MSRPC_PROPERTIES );
  1052. for ( idx = 0; idx < NUM_MSRPC_PROPERTIES; idx++ )
  1053. {
  1054. MSRPC_Prop[idx].hProperty = AddProperty( hMSRPC, &MSRPC_Prop[idx] );
  1055. }
  1056. hNBIPX = GetProtocolFromName ("NBIPX");
  1057. hSPX = GetProtocolFromName ("SPX");
  1058. hTCP = GetProtocolFromName ("TCP");
  1059. hSMB = GetProtocolFromName ("SMB");
  1060. hVinesTL = GetProtocolFromName ("Vines_TL");
  1061. hIPX =GetProtocolFromName ("IPX");
  1062. hUDP = GetProtocolFromName ("UDP");
  1063. hCDP = GetProtocolFromName ("CDP");
  1064. //_asm int 3;
  1065. }
  1066. //*****************************************************************************
  1067. //
  1068. // Name: MSRPC_Deregister
  1069. //
  1070. // Description:
  1071. //
  1072. // Parameters: HPARSER hParser: handle to the parser.
  1073. //
  1074. // Return Code: BOOL: TRUE if all is successful.
  1075. //
  1076. // History:
  1077. // 08/01/93 t-glennc Created.
  1078. //
  1079. //*****************************************************************************
  1080. VOID WINAPI MSRPC_Deregister( HPROTOCOL hMSRPC )
  1081. {
  1082. DestroyPropertyDatabase( hMSRPC );
  1083. }
  1084. //*****************************************************************************
  1085. //
  1086. // Name: MSRPC_RecognizeFrame
  1087. //
  1088. // Description: Determine size of MSRPC frame.
  1089. //
  1090. // Parameters: HFRAME hFrame: handle to the frame.
  1091. // LPBYTE lpStartUDP: pointer to the start of the UDP frame.
  1092. // LPBYTE lpStartMSRPC: pointer to the start of a MSRPC frame.
  1093. // WORD MacType: type of MAC frame
  1094. // WORD BytesLeft: bytes left in the frame.
  1095. // LPRECOGNIZEDATA lpRecognizeDataArray: Table to fill if rec.
  1096. // LPBYTE lpEntriesAdded : Number of PropInstTable entries added.
  1097. //
  1098. // Return Code: LPBYTE: Pointer to the end of protocol
  1099. //
  1100. // History:
  1101. // 08/01/93 t-glennc Created.
  1102. // 08/29/95 SteveHi Find the IID and handoff to the right parser.
  1103. //
  1104. //*****************************************************************************
  1105. LPBYTE WINAPI MSRPC_RecognizeFrame(
  1106. HFRAME hFrame,
  1107. LPBYTE lpStartFrame,
  1108. LPBYTE lpStartMSRPC,
  1109. DWORD MacType,
  1110. DWORD BytesLeft,
  1111. HPROTOCOL hPreviousProtocol, // Previous protocol or NULL if none.
  1112. DWORD nPreviousProtocolOffset, // Offset of previous protocol.
  1113. LPDWORD ProtocolStatusCode, // Pointer to return status code in.
  1114. LPHPROTOCOL hNextProtocol, // Next protocol to call (optional).
  1115. LPDWORD lpInstData )
  1116. {
  1117. LPMSRPCCO lpMSRPCCO = (LPMSRPCCO) lpStartMSRPC;
  1118. LPMSRPCCL lpMSRPCCL = (LPMSRPCCL) lpStartMSRPC;
  1119. DWORD length = 0;
  1120. DWORD size = 0;
  1121. DWORD fNetBios = 0;
  1122. DWORD fNBT = 0;
  1123. DWORD fNBIPX = 0;
  1124. HPROTOCOL hNext=NULL; // next protocol to hand off to...
  1125. WORD OpNum;
  1126. DWORD BindVersion;
  1127. if ((lpBindTable = (LPBINDTABLE) GetCCInstPtr()) == NULL)
  1128. {
  1129. // _asm int 3;
  1130. if ((lpBindTable = CCHeapAlloc(BINDTABLEHEADERSIZE + 100 * sizeof (BINDENTRY), TRUE)) == NULL)
  1131. {
  1132. #ifdef DEBUG
  1133. dprintf ("**** Cannot get memory for CCHeapAlloc!!\n");
  1134. #endif
  1135. }
  1136. else
  1137. {
  1138. lpBindTable->nEntries = 0;
  1139. lpBindTable->nAllocated = 100;
  1140. lpBindTable->State = NORMAL;
  1141. SetCCInstPtr ( lpBindTable );
  1142. }
  1143. }
  1144. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1145. // Recognizing Ver. 4 RPC packets
  1146. if ( lpMSRPCCL->Version == 0x04 && BytesLeft >= 80 )
  1147. {
  1148. // this can ONLY be true if the previous protocol is either IPX or UDP
  1149. if (!((hPreviousProtocol == hIPX) || (hPreviousProtocol==hUDP) || (hPreviousProtocol==hCDP)))
  1150. {
  1151. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1152. return (LPBYTE) lpStartMSRPC;
  1153. }
  1154. *ProtocolStatusCode = PROTOCOL_STATUS_RECOGNIZED;
  1155. length = 80;
  1156. switch ( lpMSRPCCL->PType )
  1157. {
  1158. case MSRPC_PDU_REQUEST :
  1159. //_asm int 3;
  1160. OpNum = lpMSRPCCL->OpNum,
  1161. hNext = FindParserInTable ( (ULPDWORD) lpMSRPCCL->InterfaceId);
  1162. if ( hNext )
  1163. {
  1164. *ProtocolStatusCode = PROTOCOL_STATUS_NEXT_PROTOCOL;
  1165. *hNextProtocol = hNext;
  1166. }
  1167. *lpInstData = (lpMSRPCCL->InterfaceVersion <<16) | OpNum;
  1168. *lpInstData |= 0x80000000; // set the high bit.. for request
  1169. if (IsLittleEndian( (BYTE) lpMSRPCCL->PackedDrep[0] ))
  1170. *lpInstData &= 0xBFFFFFFF; // unset the 2nd bit.. for Intel
  1171. else
  1172. *lpInstData |= 0x40000000; // set the 2nd bit.. for flipped
  1173. length = (LPBYTE) &lpMSRPCCL->Request.Data[0] - (LPBYTE)lpMSRPCCL;
  1174. break;
  1175. case MSRPC_PDU_PING :
  1176. break;
  1177. case MSRPC_PDU_RESPONSE :
  1178. {
  1179. LPMSRPCCL lpOrig;
  1180. //_asm int 3;
  1181. OpNum = 0;
  1182. // get the correct opnum and GUID...
  1183. // EMERALD - this code keeps our lookback from becoming recursive,
  1184. // those frames that are recognized as part of the lookback process will
  1185. // stop attaching at the end of MSRPC as that is all that is needed.
  1186. // (Note that the problem here is that if there are two threads recognizing
  1187. // at the same time, then they will clobber each other's flags.)
  1188. if( lpBindTable->fCurrentlyLookingBack == FALSE)
  1189. {
  1190. // we are not currently looking back but we are about to start
  1191. lpBindTable->fCurrentlyLookingBack = TRUE;
  1192. lpOrig = (LPMSRPCCL) FindDGRequestFrame (hFrame,
  1193. (DWORD UNALIGNED * ) lpMSRPCCL->ActivityId,
  1194. lpMSRPCCL->SeqNum);
  1195. lpBindTable->fCurrentlyLookingBack = FALSE;
  1196. }
  1197. else
  1198. {
  1199. // we are currently in the middle of a lookback,
  1200. // do not look any further
  1201. break;
  1202. }
  1203. if ( lpOrig) // we found the request...
  1204. {
  1205. OpNum = lpOrig->OpNum;
  1206. hNext = FindParserInTable ( (ULPDWORD) lpOrig->InterfaceId);
  1207. }
  1208. else
  1209. hNext = NULL;
  1210. if ( hNext )
  1211. {
  1212. *ProtocolStatusCode = PROTOCOL_STATUS_NEXT_PROTOCOL;
  1213. *hNextProtocol = hNext;
  1214. }
  1215. *lpInstData = (lpMSRPCCL->InterfaceVersion <<16) | OpNum;
  1216. *lpInstData &= 0x7FFFFFFF; // unset the high bit.. for response
  1217. if (IsLittleEndian( (BYTE) lpMSRPCCL->PackedDrep[0] ))
  1218. *lpInstData &= 0xBFFFFFFF; // unset the 2nd bit.. for Intel
  1219. else
  1220. *lpInstData |= 0x40000000; // set the 2nd bit.. for flipped
  1221. length = (LPBYTE) &lpMSRPCCL->Response.Data[0] - (LPBYTE)lpMSRPCCL;
  1222. break;
  1223. }
  1224. case MSRPC_PDU_FAULT :
  1225. length += 4;
  1226. break;
  1227. case MSRPC_PDU_WORKING :
  1228. break;
  1229. case MSRPC_PDU_NOCALL :
  1230. if ( lpMSRPCCL->Length >= 16 )
  1231. {
  1232. length = length + 16 + ( 4*lpMSRPCCL->NoCall.SelAckLen );
  1233. }
  1234. break;
  1235. case MSRPC_PDU_REJECT :
  1236. length += 4;
  1237. break;
  1238. case MSRPC_PDU_ACK :
  1239. break;
  1240. case MSRPC_PDU_CL_CANCEL :
  1241. length += 8;
  1242. break;
  1243. case MSRPC_PDU_FACK :
  1244. if ( lpMSRPCCL->Length >= 16 )
  1245. {
  1246. length = length + 16 + ( 4*lpMSRPCCL->Fack.SelAckLen );
  1247. }
  1248. break;
  1249. case MSRPC_PDU_CANCEL_ACK :
  1250. if ( lpMSRPCCL->Length == 12 )
  1251. {
  1252. length += 12;
  1253. }
  1254. default :
  1255. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1256. return (LPBYTE) lpStartMSRPC;
  1257. }
  1258. #define SSP_DECODE
  1259. #ifdef SSP_DECODE
  1260. if((*ProtocolStatusCode == PROTOCOL_STATUS_RECOGNIZED))
  1261. {
  1262. // CHECK TO PASS OFF TO SSP
  1263. if(lpMSRPCCL->AuthProtoId)
  1264. {
  1265. hNext = GetProtocolFromName("SSP");
  1266. if(hNext)
  1267. {
  1268. *ProtocolStatusCode = PROTOCOL_STATUS_NEXT_PROTOCOL;
  1269. *hNextProtocol = hNext;
  1270. length+=lpMSRPCCL->Length;
  1271. }
  1272. }
  1273. }
  1274. #endif
  1275. if ( ( (*ProtocolStatusCode == PROTOCOL_STATUS_RECOGNIZED) ||
  1276. (*ProtocolStatusCode == PROTOCOL_STATUS_NEXT_PROTOCOL) ) &&
  1277. (fUseFrmLen == 1 ))
  1278. {
  1279. //if ( BytesLeft == length )
  1280. return (LPBYTE) lpStartMSRPC + length;
  1281. //else
  1282. if ( BytesLeft == ( length + 1 ) )
  1283. return (LPBYTE) lpStartMSRPC + length + 1;
  1284. else
  1285. {
  1286. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1287. return (LPBYTE) lpStartMSRPC;
  1288. }
  1289. }
  1290. if ( *ProtocolStatusCode == PROTOCOL_STATUS_RECOGNIZED && fUseFrmLen == 0 )
  1291. {
  1292. return (LPBYTE) lpStartMSRPC + BytesLeft;
  1293. }
  1294. }
  1295. // Before parsing ver. 5.0 stuff, check to see if a sequence number
  1296. // header is sitting in front of the normal RPC packet.
  1297. fNetBios = GetProtocolStartOffset( hFrame, "NETBIOS" );
  1298. fNBT = GetProtocolStartOffset( hFrame, "NBT" );
  1299. fNBIPX = GetProtocolStartOffset ( hFrame, "NBIPX");
  1300. if ( ( (fNetBios != 0xffffffff) || (fNBT != 0xffffffff) || (fNBIPX != 0xffffffff) ) &&
  1301. lpMSRPCCO->PackedDrep[0] == 0x05 &&
  1302. lpMSRPCCO->PackedDrep[1] == 0x00 )
  1303. {
  1304. lpMSRPCCO = (LPMSRPCCO) lpMSRPCCO->PackedDrep;
  1305. length += 4;
  1306. }
  1307. // Recognizing Ver. 5.0 RPC packets
  1308. if ( lpMSRPCCO->Version == 0x05 &&
  1309. lpMSRPCCO->VersionMinor == 0x00 &&
  1310. BytesLeft > 16 )
  1311. {
  1312. WORD PConID;
  1313. // If the previous protocol is IPX or UDP, this cannot be a connection oriented frame
  1314. if ((hPreviousProtocol == hIPX) || (hPreviousProtocol==hUDP) || (hPreviousProtocol==hCDP))
  1315. {
  1316. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1317. return (LPBYTE) lpStartMSRPC;
  1318. }
  1319. *ProtocolStatusCode = PROTOCOL_STATUS_RECOGNIZED;
  1320. switch ( lpMSRPCCO->PType )
  1321. {
  1322. case MSRPC_PDU_REQUEST:
  1323. // Find the BIND that references our Presentation Context ID...
  1324. // _asm int 3;
  1325. PConID = lpMSRPCCO->Request.PContId;
  1326. OpNum = lpMSRPCCO->Request.OpNum;
  1327. // EMERALD - this code keeps our lookback from becoming recursive,
  1328. // those frames that are recognized as part of the lookback process will
  1329. // stop attaching at the end of MSRPC as that is all that is needed.
  1330. if( lpBindTable->fCurrentlyLookingBack == FALSE)
  1331. {
  1332. // we are not currently looking back but we are about to start
  1333. lpBindTable->fCurrentlyLookingBack = TRUE;
  1334. hNext = FindBindParser ( hFrame, hPreviousProtocol, lpStartFrame + nPreviousProtocolOffset, PConID, NULL, &BindVersion );
  1335. lpBindTable->fCurrentlyLookingBack = FALSE;
  1336. }
  1337. else
  1338. {
  1339. // we are currently in the middle of a lookback,
  1340. // do not look any further
  1341. hNext = FALSE;
  1342. }
  1343. if ( hNext )
  1344. {
  1345. *ProtocolStatusCode = PROTOCOL_STATUS_NEXT_PROTOCOL;
  1346. *hNextProtocol = hNext;
  1347. }
  1348. length += sizeof(REQUEST);
  1349. *lpInstData = (BindVersion <<16) | OpNum;
  1350. *lpInstData |= 0x80000000; // set the high bit.. for request
  1351. if (IsLittleEndian( (BYTE) lpMSRPCCO->PackedDrep[0] ))
  1352. *lpInstData &= 0xBFFFFFFF; // unset the 2nd bit.. for Intel
  1353. else
  1354. *lpInstData |= 0x40000000; // set the 2nd bit.. for flipped
  1355. break;
  1356. case MSRPC_PDU_RESPONSE:
  1357. //_asm int 3;
  1358. // Find the BIND that references our Presentation Context ID...
  1359. PConID = lpMSRPCCO->Response.PContId;
  1360. // EMERALD - this code keeps our lookback from becoming recursive,
  1361. // those frames that are recognized as part of the lookback process will
  1362. // stop attaching at the end of MSRPC as that is all that is needed.
  1363. if( lpBindTable->fCurrentlyLookingBack == FALSE)
  1364. {
  1365. // we are not currently looking back but we are about to start
  1366. lpBindTable->fCurrentlyLookingBack = TRUE;
  1367. hNext = FindBindParser ( hFrame, hPreviousProtocol, lpStartFrame + nPreviousProtocolOffset, PConID, &OpNum, &BindVersion );
  1368. lpBindTable->fCurrentlyLookingBack = FALSE;
  1369. }
  1370. else
  1371. {
  1372. // we are currently in the middle of a lookback,
  1373. // do not look any further
  1374. hNext = FALSE;
  1375. }
  1376. if ( hNext )
  1377. {
  1378. *ProtocolStatusCode = PROTOCOL_STATUS_NEXT_PROTOCOL;
  1379. *hNextProtocol = hNext;
  1380. }
  1381. length = &lpMSRPCCO->Response.Data[0] - lpStartMSRPC;
  1382. *lpInstData = (BindVersion <<16) | OpNum;
  1383. *lpInstData &= 0x7FFFFFFF; // unset the high bit.. for response
  1384. if (IsLittleEndian( (BYTE) lpMSRPCCO->PackedDrep[0] ))
  1385. *lpInstData &= 0xBFFFFFFF; // unset the 2nd bit.. for Intel
  1386. else
  1387. *lpInstData |= 0x40000000; // set the 2nd bit.. for flipped
  1388. break;
  1389. case MSRPC_PDU_FAULT :
  1390. case MSRPC_PDU_BIND :
  1391. case MSRPC_PDU_BIND_ACK :
  1392. case MSRPC_PDU_BIND_NAK :
  1393. case MSRPC_PDU_ALTER_CONTEXT :
  1394. case MSRPC_PDU_ALTER_CONTEXT_RESP :
  1395. case MSRPC_PDU_SHUTDOWN :
  1396. case MSRPC_PDU_CO_CANCEL :
  1397. case MSRPC_PDU_ORPHANED :
  1398. size = lpMSRPCCO->FragLength;
  1399. length += size;
  1400. break;
  1401. default :
  1402. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1403. return (LPBYTE) lpStartMSRPC;
  1404. }
  1405. if ( ( (*ProtocolStatusCode == PROTOCOL_STATUS_RECOGNIZED) ||
  1406. (*ProtocolStatusCode == PROTOCOL_STATUS_NEXT_PROTOCOL) ) &&
  1407. (fUseFrmLen == 1 ))
  1408. {
  1409. //if ( BytesLeft == length )
  1410. return (LPBYTE) lpStartMSRPC + length;
  1411. //else
  1412. if ( BytesLeft == ( length + 1 ) )
  1413. return (LPBYTE) lpStartMSRPC + length + 1;
  1414. else
  1415. {
  1416. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1417. return (LPBYTE) lpStartMSRPC;
  1418. }
  1419. }
  1420. if ( ( (*ProtocolStatusCode == PROTOCOL_STATUS_RECOGNIZED) ||
  1421. (*ProtocolStatusCode == PROTOCOL_STATUS_NEXT_PROTOCOL) ) &&
  1422. (fUseFrmLen == 0 ))
  1423. {
  1424. return (LPBYTE) lpStartMSRPC + BytesLeft;
  1425. }
  1426. }
  1427. *ProtocolStatusCode = PROTOCOL_STATUS_NOT_RECOGNIZED;
  1428. return (LPBYTE) lpStartMSRPC;
  1429. }
  1430. //*****************************************************************************
  1431. //
  1432. // Name: MSRPC_AttachProperties
  1433. //
  1434. // Description: Attach MSRPC protocol properties to a given frame.
  1435. //
  1436. // Parameters: HFRAME hFrame: handle to the frame.
  1437. // LPBYTE lpStartUDP: pointer to the start of the UDP frame.
  1438. // LPBYTE lpStartMSRPC: pointer to the start of a MSRPC frame.
  1439. // WORD MacType: type of MAC frame
  1440. // WORD BytesLeft: bytes left in the frame.
  1441. //
  1442. // Return Code: LPBYTE: Pointer to the end of protocol
  1443. //
  1444. // History:
  1445. // 08/01/93 t-glennc Created.
  1446. //
  1447. //*****************************************************************************
  1448. LPBYTE WINAPI MSRPC_AttachProperties( HFRAME hFrame,
  1449. LPBYTE lpStartFrame,
  1450. LPBYTE TheFrame,
  1451. DWORD MacType,
  1452. DWORD BytesLeft,
  1453. HPROTOCOL hPreviousProtocol,
  1454. DWORD nPreviousProtocolOffset,
  1455. DWORD InstData )
  1456. {
  1457. LPMSRPCCO lpMSRPCCO = (LPMSRPCCO) TheFrame;
  1458. LPMSRPCCL lpMSRPCCL = (LPMSRPCCL) TheFrame;
  1459. DWORD length = 0;
  1460. DWORD size = 0;
  1461. DWORD fNetBios = 0;
  1462. DWORD fNBT = 0;
  1463. DWORD fNBIPX = 0;
  1464. WORD i;
  1465. WORD offset;
  1466. WORD nResults;
  1467. BOOL fLittleEndian = FALSE;
  1468. ULPWORD AddrLen;
  1469. LPBINDENTRY lpBindEntry;
  1470. if ((lpBindTable = (LPBINDTABLE) GetCCInstPtr()) == NULL)
  1471. {
  1472. #ifdef DEBUG
  1473. dprintf ("lpBindTable is NULL at Attach time??");
  1474. DebugBreak();
  1475. #endif
  1476. }
  1477. // Before parsing ver. 5.0 stuff, check to see if a sequence number
  1478. // header is sitting in front of the normal RPC packet.
  1479. fNetBios = GetProtocolStartOffset( hFrame, "NETBIOS" );
  1480. fNBT = GetProtocolStartOffset( hFrame, "NBT" );
  1481. fNBIPX = GetProtocolStartOffset( hFrame, "NBIPX" );
  1482. if ( ( (fNetBios != 0xffffffff) || (fNBT != 0xffffffff) || (fNBIPX != 0xffffffff) ) &&
  1483. lpMSRPCCO->PackedDrep[0] == 0x05 &&
  1484. lpMSRPCCO->PackedDrep[1] == 0x00 )
  1485. {
  1486. //
  1487. // Attach Summary property
  1488. //
  1489. AttachPropertyInstance( hFrame, // SUMMARY INFORMATION
  1490. MSRPC_Prop[MSRPC_SUMMARY].hProperty,
  1491. BytesLeft,
  1492. lpMSRPCCO,
  1493. 0,0,0); // HELPID, Level, Errorflag
  1494. AttachPropertyInstance( hFrame,
  1495. MSRPC_Prop[MSRPC_SEQ_NUMBER].hProperty,
  1496. sizeof( DWORD ),
  1497. &lpMSRPCCO->Version,
  1498. 0,1,0); // HELPID, Level, Errorflag
  1499. lpMSRPCCO = (LPMSRPCCO) lpMSRPCCO->PackedDrep;
  1500. length += 4;
  1501. }
  1502. else
  1503. {
  1504. //
  1505. // Attach Summary property
  1506. //
  1507. AttachPropertyInstance( hFrame, // SUMMARY INFORMATION
  1508. MSRPC_Prop[MSRPC_SUMMARY].hProperty,
  1509. BytesLeft,
  1510. lpMSRPCCO,
  1511. 0,0,0); // HELPID, Level, Errorflag
  1512. }
  1513. if ( lpMSRPCCO->Version == 0x05 && lpMSRPCCO->VersionMinor == 0x00 )
  1514. {
  1515. // Determine the big or little endianess of this packet
  1516. fLittleEndian = IsLittleEndian( (BYTE) lpMSRPCCO->PackedDrep[0] );
  1517. //
  1518. // Attach the standard part of MSRPC Connection Oriented packet
  1519. //
  1520. AttachPropertyInstance( hFrame,
  1521. MSRPC_Prop[MSRPC_VERSION].hProperty,
  1522. sizeof( BYTE ),
  1523. &lpMSRPCCO->Version,
  1524. 0,1,0); // HELPID, Level, Errorflag
  1525. AttachPropertyInstance( hFrame,
  1526. MSRPC_Prop[MSRPC_VERSION_MINOR].hProperty,
  1527. sizeof( BYTE ),
  1528. &lpMSRPCCO->VersionMinor,
  1529. 0,1,0); // HELPID, Level, Errorflag
  1530. AttachPropertyInstance( hFrame,
  1531. MSRPC_Prop[MSRPC_PTYPE].hProperty,
  1532. sizeof( BYTE ),
  1533. &lpMSRPCCO->PType,
  1534. 0,1,0); // HELPID, Level, Errorflag
  1535. AttachPropertyInstance( hFrame,
  1536. MSRPC_Prop[MSRPC_PFC_FLAGS1].hProperty,
  1537. sizeof( BYTE ),
  1538. &lpMSRPCCO->PFCFlags,
  1539. 0,1,0); // HELPID, Level, Errorflag
  1540. AttachPropertyInstance( hFrame,
  1541. MSRPC_Prop[MSRPC_PFC_FLAGS1_BITS].hProperty,
  1542. sizeof( BYTE ),
  1543. &lpMSRPCCO->PFCFlags,
  1544. 0,2,0); // HELPID, Level, Errorflag
  1545. AttachPropertyInstance( hFrame,
  1546. MSRPC_Prop[MSRPC_PACKED_DREP].hProperty,
  1547. sizeof( BYTE ) * 4,
  1548. &lpMSRPCCO->PackedDrep,
  1549. 0,1,0); // HELPID, Level, Errorflag
  1550. AttachProperty( fLittleEndian,
  1551. hFrame,
  1552. MSRPC_Prop[MSRPC_FRAG_LENGTH].hProperty,
  1553. sizeof( WORD ),
  1554. &lpMSRPCCO->FragLength,
  1555. 0,1,0); // HELPID, Level, Errorflag
  1556. AttachProperty( fLittleEndian,
  1557. hFrame,
  1558. MSRPC_Prop[MSRPC_AUTH_LENGTH].hProperty,
  1559. sizeof( WORD ),
  1560. &lpMSRPCCO->AuthLength,
  1561. 0,1,0); // HELPID, Level, Errorflag
  1562. AttachProperty( fLittleEndian,
  1563. hFrame,
  1564. MSRPC_Prop[MSRPC_CALL_ID].hProperty,
  1565. sizeof( DWORD ),
  1566. &lpMSRPCCO->CallID,
  1567. 0,1,0); // HELPID, Level, Errorflag
  1568. length += 16;
  1569. //
  1570. // Attach the specific part of MSRPC packets based on PType
  1571. //
  1572. switch ( lpMSRPCCO->PType )
  1573. {
  1574. case MSRPC_PDU_REQUEST :
  1575. if ( (lpBindEntry = GetBindEntry ( GetFrameNumber(hFrame)+1)) != NULL )
  1576. {
  1577. DWORD nBindFrame = GetFrameNumber ( lpBindEntry->hBindFrame) + 1;
  1578. AttachPropertyInstanceEx( hFrame,
  1579. MSRPC_Prop[MSRPC_BIND_FRAME_NUMBER].hProperty,
  1580. 0,
  1581. NULL,
  1582. sizeof (nBindFrame),
  1583. &nBindFrame,
  1584. 0,1,0); // HELPID, Level, Errorflag
  1585. AttachIIDFromBindFrame ( hFrame, lpBindEntry->hBindFrame, 1 );
  1586. }
  1587. AttachProperty( fLittleEndian,
  1588. hFrame,
  1589. MSRPC_Prop[MSRPC_ALLOC_HINT].hProperty,
  1590. sizeof( DWORD ),
  1591. &lpMSRPCCO->Request.AllocHint,
  1592. 0,1,0); // HELPID, Level, Errorflag
  1593. AttachProperty( fLittleEndian,
  1594. hFrame,
  1595. MSRPC_Prop[MSRPC_PRES_CONTEXT_ID].hProperty,
  1596. sizeof( WORD ),
  1597. &lpMSRPCCO->Request.PContId,
  1598. 0,1,0); // HELPID, Level, Errorflag
  1599. AttachProperty( fLittleEndian,
  1600. hFrame,
  1601. MSRPC_Prop[MSRPC_OPNUM].hProperty,
  1602. sizeof( WORD ),
  1603. &lpMSRPCCO->Request.OpNum,
  1604. 0,1,0); // HELPID, Level, Errorflag
  1605. length += 8;
  1606. if ( PFC_OBJECT_UUID( lpMSRPCCO->PFCFlags ) )
  1607. {
  1608. AttachPropertyInstance( hFrame,
  1609. MSRPC_Prop[MSRPC_OBJECT].hProperty,
  1610. 16,
  1611. &lpMSRPCCO->Request.Object,
  1612. 0,1,0); // HELPID, Level, Errorflag
  1613. length += 16;
  1614. size = BytesLeft - lpMSRPCCO->AuthLength - length;
  1615. if ( size )
  1616. {
  1617. AttachPropertyInstance( hFrame,
  1618. MSRPC_Prop[MSRPC_STUB_DATA].hProperty,
  1619. size,
  1620. &lpMSRPCCO->Request.Data,
  1621. 0,1,0); // HELPID, Level, Errorflag
  1622. length += size;
  1623. }
  1624. if ( lpMSRPCCO->AuthLength )
  1625. {
  1626. AttachPropertyInstance( hFrame,
  1627. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  1628. lpMSRPCCO->AuthLength,
  1629. &lpMSRPCCO->Request.Data[size],
  1630. 0,1,0); // HELPID, Level, Errorflag
  1631. length += lpMSRPCCO->AuthLength;
  1632. }
  1633. }
  1634. else
  1635. {
  1636. size = BytesLeft - lpMSRPCCO->AuthLength - length;
  1637. if ( size )
  1638. {
  1639. AttachPropertyInstance( hFrame,
  1640. MSRPC_Prop[MSRPC_STUB_DATA].hProperty,
  1641. size,
  1642. &lpMSRPCCO->Request.Object,
  1643. 0,1,0); // HELPID, Level, Errorflag
  1644. length += size;
  1645. }
  1646. if ( lpMSRPCCO->AuthLength )
  1647. {
  1648. AttachPropertyInstance( hFrame,
  1649. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  1650. lpMSRPCCO->AuthLength,
  1651. &lpMSRPCCO->Request.Object[size],
  1652. 0,1,0); // HELPID, Level, Errorflag
  1653. length += lpMSRPCCO->AuthLength;
  1654. }
  1655. }
  1656. break;
  1657. case MSRPC_PDU_RESPONSE :
  1658. if ( (lpBindEntry = GetBindEntry ( GetFrameNumber(hFrame)+1)) != NULL )
  1659. {
  1660. DWORD nBindFrame = GetFrameNumber ( lpBindEntry->hBindFrame) + 1;
  1661. AttachPropertyInstanceEx( hFrame,
  1662. MSRPC_Prop[MSRPC_BIND_FRAME_NUMBER].hProperty,
  1663. 0,
  1664. NULL,
  1665. sizeof (nBindFrame),
  1666. &nBindFrame,
  1667. 0,1,0); // HELPID, Level, Errorflag
  1668. AttachIIDFromBindFrame ( hFrame, lpBindEntry->hBindFrame, 1 );
  1669. }
  1670. AttachProperty( fLittleEndian,
  1671. hFrame,
  1672. MSRPC_Prop[MSRPC_ALLOC_HINT].hProperty,
  1673. sizeof( DWORD ),
  1674. &lpMSRPCCO->Response.AllocHint,
  1675. 0,1,0); // HELPID, Level, Errorflag
  1676. AttachProperty( fLittleEndian,
  1677. hFrame,
  1678. MSRPC_Prop[MSRPC_PRES_CONTEXT_ID].hProperty,
  1679. sizeof( WORD ),
  1680. &lpMSRPCCO->Response.PContId,
  1681. 0,1,0); // HELPID, Level, Errorflag
  1682. AttachPropertyInstance( hFrame,
  1683. MSRPC_Prop[MSRPC_CANCEL_COUNT].hProperty,
  1684. sizeof( BYTE ),
  1685. &lpMSRPCCO->Response.CancelCount,
  1686. 0,1,0); // HELPID, Level, Errorflag
  1687. AttachPropertyInstance( hFrame,
  1688. MSRPC_Prop[MSRPC_RESERVED].hProperty,
  1689. sizeof( BYTE ),
  1690. &lpMSRPCCO->Response.Reserved,
  1691. 0,1,0); // HELPID, Level, Errorflag
  1692. length += 8;
  1693. size = BytesLeft - lpMSRPCCO->AuthLength - length;
  1694. if ( size )
  1695. {
  1696. AttachPropertyInstance( hFrame,
  1697. MSRPC_Prop[MSRPC_STUB_DATA].hProperty,
  1698. size,
  1699. &lpMSRPCCO->Response.Data,
  1700. 0,1,0); // HELPID, Level, Errorflag
  1701. length += size;
  1702. }
  1703. if ( lpMSRPCCO->AuthLength )
  1704. {
  1705. AttachPropertyInstance( hFrame,
  1706. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  1707. lpMSRPCCO->AuthLength,
  1708. &lpMSRPCCO->Response.Data[size],
  1709. 0,1,0); // HELPID, Level, Errorflag
  1710. length += lpMSRPCCO->AuthLength;
  1711. }
  1712. break;
  1713. case MSRPC_PDU_FAULT :
  1714. AttachProperty( fLittleEndian,
  1715. hFrame,
  1716. MSRPC_Prop[MSRPC_ALLOC_HINT].hProperty,
  1717. sizeof( DWORD ),
  1718. &lpMSRPCCO->Fault.AllocHint,
  1719. 0,1,0); // HELPID, Level, Errorflag
  1720. AttachProperty( fLittleEndian,
  1721. hFrame,
  1722. MSRPC_Prop[MSRPC_PRES_CONTEXT_ID].hProperty,
  1723. sizeof( WORD ),
  1724. &lpMSRPCCO->Fault.PContId,
  1725. 0,1,0); // HELPID, Level, Errorflag
  1726. AttachPropertyInstance( hFrame,
  1727. MSRPC_Prop[MSRPC_CANCEL_COUNT].hProperty,
  1728. sizeof( BYTE ),
  1729. &lpMSRPCCO->Fault.CancelCount,
  1730. 0,1,0); // HELPID, Level, Errorflag
  1731. AttachPropertyInstance( hFrame,
  1732. MSRPC_Prop[MSRPC_RESERVED].hProperty,
  1733. sizeof( BYTE ),
  1734. &lpMSRPCCO->Fault.Reserved,
  1735. 0,1,0); // HELPID, Level, Errorflag
  1736. AttachProperty( fLittleEndian,
  1737. hFrame,
  1738. MSRPC_Prop[MSRPC_STATUS].hProperty,
  1739. sizeof( DWORD ),
  1740. &lpMSRPCCO->Fault.Status,
  1741. 0,1,0); // HELPID, Level, Errorflag
  1742. AttachProperty( fLittleEndian,
  1743. hFrame,
  1744. MSRPC_Prop[MSRPC_RESERVED_2].hProperty,
  1745. sizeof( DWORD ),
  1746. &lpMSRPCCO->Fault.Reserved2,
  1747. 0,1,0); // HELPID, Level, Errorflag
  1748. length += 16;
  1749. size = BytesLeft - lpMSRPCCO->AuthLength - length;
  1750. if ( size )
  1751. {
  1752. AttachPropertyInstance( hFrame,
  1753. MSRPC_Prop[MSRPC_STUB_DATA].hProperty,
  1754. size,
  1755. &lpMSRPCCO->Fault.Data,
  1756. 0,1,0); // HELPID, Level, Errorflag
  1757. length += size;
  1758. }
  1759. if ( lpMSRPCCO->AuthLength )
  1760. {
  1761. AttachPropertyInstance( hFrame,
  1762. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  1763. lpMSRPCCO->AuthLength,
  1764. &lpMSRPCCO->Fault.Data[size],
  1765. 0,1,0); // HELPID, Level, Errorflag
  1766. length += lpMSRPCCO->AuthLength;
  1767. }
  1768. break;
  1769. case MSRPC_PDU_BIND :
  1770. AttachProperty( fLittleEndian,
  1771. hFrame,
  1772. MSRPC_Prop[MSRPC_MAX_XMIT_FRAG].hProperty,
  1773. sizeof( WORD ),
  1774. &lpMSRPCCO->Bind.MaxXmitFrag,
  1775. 0,1,0); // HELPID, Level, Errorflag
  1776. AttachProperty( fLittleEndian,
  1777. hFrame,
  1778. MSRPC_Prop[MSRPC_MAX_RECV_FRAG].hProperty,
  1779. sizeof( WORD ),
  1780. &lpMSRPCCO->Bind.MaxRecvFrag,
  1781. 0,1,0); // HELPID, Level, Errorflag
  1782. AttachProperty( fLittleEndian,
  1783. hFrame,
  1784. MSRPC_Prop[MSRPC_ASSOC_GROUP_ID].hProperty,
  1785. sizeof( DWORD ),
  1786. &lpMSRPCCO->Bind.AssocGroupId,
  1787. 0,1,0); // HELPID, Level, Errorflag
  1788. length += 8;
  1789. size = BytesLeft - lpMSRPCCO->AuthLength - length;
  1790. if ( size )
  1791. {
  1792. BYTE nContext;
  1793. //p_cont_elem_t UNALIGNED * pContElem;
  1794. AttachPropertyInstance( hFrame,
  1795. MSRPC_Prop[MSRPC_P_CONTEXT_SUM].hProperty,
  1796. size,
  1797. &lpMSRPCCO->Bind.PContextElem[0],
  1798. 0,1,0); // HELPID, Level, Errorflag
  1799. // break out the GUIDs etc from the context element...
  1800. AttachPropertyInstance( hFrame,
  1801. MSRPC_Prop[MSRPC_P_CONTEXT_ELEM].hProperty,
  1802. sizeof( BYTE ),
  1803. &lpMSRPCCO->Bind.PContextElem[0],
  1804. 0,2,0); // HELPID, Level, Errorflag
  1805. nContext = (BYTE)lpMSRPCCO->Bind.PContextElem[0];
  1806. AttachPContElem ( (p_cont_elem_t UNALIGNED * )&lpMSRPCCO->Bind.PContextElem[4],
  1807. nContext,
  1808. hFrame,
  1809. 2,
  1810. fLittleEndian);
  1811. length += size;
  1812. }
  1813. if ( lpMSRPCCO->AuthLength )
  1814. {
  1815. AttachPropertyInstance( hFrame,
  1816. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  1817. lpMSRPCCO->AuthLength,
  1818. &lpMSRPCCO->Bind.PContextElem[size],
  1819. 0,1,0); // HELPID, Level, Errorflag
  1820. length += lpMSRPCCO->AuthLength;
  1821. }
  1822. break;
  1823. case MSRPC_PDU_BIND_ACK :
  1824. AttachProperty( fLittleEndian,
  1825. hFrame,
  1826. MSRPC_Prop[MSRPC_MAX_XMIT_FRAG].hProperty,
  1827. sizeof( WORD ),
  1828. &lpMSRPCCO->BindAck.MaxXmitFrag,
  1829. 0,1,0); // HELPID, Level, Errorflag
  1830. AttachProperty( fLittleEndian,
  1831. hFrame,
  1832. MSRPC_Prop[MSRPC_MAX_RECV_FRAG].hProperty,
  1833. sizeof( WORD ),
  1834. &lpMSRPCCO->BindAck.MaxRecvFrag,
  1835. 0,1,0); // HELPID, Level, Errorflag
  1836. AttachProperty( fLittleEndian,
  1837. hFrame,
  1838. MSRPC_Prop[MSRPC_ASSOC_GROUP_ID].hProperty,
  1839. sizeof( DWORD ),
  1840. &lpMSRPCCO->BindAck.AssocGroupId,
  1841. 0,1,0); // HELPID, Level, Errorflag
  1842. length += 8;
  1843. AddrLen = (ULPWORD) &lpMSRPCCO->BindAck.SecAddr,
  1844. AttachPropertyInstance( hFrame,
  1845. MSRPC_Prop[MSRPC_SEC_ADDR].hProperty,
  1846. AddrLen[0] + 2,
  1847. &lpMSRPCCO->BindAck.SecAddr[0],
  1848. 0,1,0); // HELPID, Level, Errorflag
  1849. AttachProperty( fLittleEndian,
  1850. hFrame,
  1851. MSRPC_Prop[MSRPC_SEC_ADDR_LENGTH].hProperty,
  1852. sizeof( WORD ),
  1853. &lpMSRPCCO->BindAck.SecAddr[0],
  1854. 0,2,0); // HELPID, Level, Errorflag
  1855. AttachPropertyInstance( hFrame,
  1856. MSRPC_Prop[MSRPC_SEC_ADDR_PORT].hProperty,
  1857. AddrLen[0],
  1858. &lpMSRPCCO->BindAck.SecAddr[2],
  1859. 0,2,0); // HELPID, Level, Errorflag
  1860. // Add bytes for secondary address
  1861. length += AddrLen[0] + 2;
  1862. AttachPropertyInstance( hFrame,
  1863. MSRPC_Prop[MSRPC_PAD].hProperty,
  1864. (((AddrLen[0]+2)/4+1)*4)-(AddrLen[0]+2),
  1865. &lpMSRPCCO->BindAck.SecAddr[AddrLen[0] + 2],
  1866. 0,1,0); // HELPID, Level, Errorflag
  1867. // Add bytes for secondary address padding
  1868. offset = ((AddrLen[0]+2)/4+1)*4;
  1869. length += offset - ( AddrLen[0] + 2 );
  1870. nResults = lpMSRPCCO->BindAck.SecAddr[offset];
  1871. AttachPropertyInstance( hFrame,
  1872. MSRPC_Prop[MSRPC_P_RESULT_LIST].hProperty,
  1873. nResults*24 + 4,
  1874. &lpMSRPCCO->BindAck.SecAddr[offset],
  1875. 0,1,0); // HELPID, Level, Errorflag
  1876. AttachPropertyInstance( hFrame,
  1877. MSRPC_Prop[MSRPC_N_RESULTS].hProperty,
  1878. sizeof( BYTE ),
  1879. &lpMSRPCCO->BindAck.SecAddr[offset],
  1880. 0,2,0); // HELPID, Level, Errorflag
  1881. offset += 1;
  1882. AttachPropertyInstance( hFrame,
  1883. MSRPC_Prop[MSRPC_RESERVED].hProperty,
  1884. sizeof( BYTE ),
  1885. &lpMSRPCCO->BindAck.SecAddr[offset],
  1886. 0,2,0); // HELPID, Level, Errorflag
  1887. offset += 1;
  1888. AttachProperty( fLittleEndian,
  1889. hFrame,
  1890. MSRPC_Prop[MSRPC_RESERVED_2].hProperty,
  1891. sizeof( WORD ),
  1892. &lpMSRPCCO->BindAck.SecAddr[offset],
  1893. 0,2,0); // HELPID, Level, Errorflag
  1894. offset += 2;
  1895. for ( i = 0; i < nResults; i++ )
  1896. {
  1897. AttachPropertyInstance( hFrame,
  1898. MSRPC_Prop[MSRPC_P_RESULTS].hProperty,
  1899. 24,
  1900. &lpMSRPCCO->BindAck.SecAddr[offset+i*24],
  1901. 0,2,0); // HELPID, Level, Errorflag
  1902. AttachProperty( fLittleEndian,
  1903. hFrame,
  1904. MSRPC_Prop[MSRPC_P_CONT_DEF_RESULT].hProperty,
  1905. sizeof( WORD ),
  1906. &lpMSRPCCO->BindAck.SecAddr[offset+i*24],
  1907. 0,3,0); // HELPID, Level, Errorflag
  1908. AttachProperty( fLittleEndian,
  1909. hFrame,
  1910. MSRPC_Prop[MSRPC_P_PROVIDER_REASON].hProperty,
  1911. sizeof( WORD ),
  1912. &lpMSRPCCO->BindAck.SecAddr[offset+i*24+2],
  1913. 0,3,0); // HELPID, Level, Errorflag
  1914. AttachPropertyInstance( hFrame,
  1915. MSRPC_Prop[MSRPC_P_TRANSFER_SYNTAX].hProperty,
  1916. 20,
  1917. &lpMSRPCCO->BindAck.SecAddr[offset+i*24+4],
  1918. 0,3,0); // HELPID, Level, Errorflag
  1919. AttachPropertyInstance( hFrame,
  1920. MSRPC_Prop[MSRPC_TRANSFER_IF_UUID].hProperty,
  1921. 16,
  1922. &lpMSRPCCO->BindAck.SecAddr[offset+i*24+4],
  1923. 0,4,0); // HELPID, Level, Errorflag
  1924. AttachProperty( fLittleEndian,
  1925. hFrame,
  1926. MSRPC_Prop[MSRPC_TRANSFER_IF_VERSION].hProperty,
  1927. sizeof( DWORD ),
  1928. &lpMSRPCCO->BindAck.SecAddr[offset+i*24+20],
  1929. 0,4,0); // HELPID, Level, Errorflag
  1930. }
  1931. offset = nResults*24;
  1932. length += offset;
  1933. if ( lpMSRPCCO->AuthLength > 0 )
  1934. {
  1935. AttachPropertyInstance( hFrame,
  1936. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  1937. lpMSRPCCO->AuthLength,
  1938. &lpMSRPCCO->BindAck.SecAddr[offset],
  1939. 0,1,0); // HELPID, Level, Errorflag
  1940. length += lpMSRPCCO->AuthLength;
  1941. }
  1942. break;
  1943. case MSRPC_PDU_BIND_NAK :
  1944. AttachProperty( fLittleEndian,
  1945. hFrame,
  1946. MSRPC_Prop[MSRPC_PROVIDER_REJECT_REASON].hProperty,
  1947. sizeof( WORD ),
  1948. &lpMSRPCCO->BindNak.RejectReason,
  1949. 0,1,0); // HELPID, Level, Errorflag
  1950. length += 2;
  1951. if ( lpMSRPCCO->BindNak.Versions[0] > 0 )
  1952. {
  1953. AttachPropertyInstance( hFrame,
  1954. MSRPC_Prop[MSRPC_VERSIONS_SUPPORTED].hProperty,
  1955. 1 + lpMSRPCCO->BindNak.Versions[0] * sizeof( WORD ),
  1956. &lpMSRPCCO->BindNak.Versions[0],
  1957. 0,1,0); // HELPID, Level, Errorflag
  1958. for ( i = 0; i > lpMSRPCCO->BindNak.Versions[0]; i++ )
  1959. {
  1960. AttachPropertyInstance( hFrame,
  1961. MSRPC_Prop[MSRPC_VERSION].hProperty,
  1962. sizeof( BYTE ),
  1963. &lpMSRPCCO->BindNak.Versions[i*2 + 1],
  1964. 0,2,0); // HELPID, Level, Errorflag
  1965. AttachPropertyInstance( hFrame,
  1966. MSRPC_Prop[MSRPC_VERSION_MINOR].hProperty,
  1967. sizeof( BYTE ),
  1968. &lpMSRPCCO->BindNak.Versions[i*2 + 2],
  1969. 0,2,0); // HELPID, Level, Errorflag
  1970. }
  1971. }
  1972. break;
  1973. case MSRPC_PDU_ALTER_CONTEXT :
  1974. AttachProperty( fLittleEndian,
  1975. hFrame,
  1976. MSRPC_Prop[MSRPC_MAX_XMIT_FRAG].hProperty,
  1977. sizeof( WORD ),
  1978. &lpMSRPCCO->AlterContext.MaxXmitFrag,
  1979. 0,1,0); // HELPID, Level, Errorflag
  1980. AttachProperty( fLittleEndian,
  1981. hFrame,
  1982. MSRPC_Prop[MSRPC_MAX_RECV_FRAG].hProperty,
  1983. sizeof( WORD ),
  1984. &lpMSRPCCO->AlterContext.MaxRecvFrag,
  1985. 0,1,0); // HELPID, Level, Errorflag
  1986. AttachProperty( fLittleEndian,
  1987. hFrame,
  1988. MSRPC_Prop[MSRPC_ASSOC_GROUP_ID].hProperty,
  1989. sizeof( DWORD ),
  1990. &lpMSRPCCO->AlterContext.AssocGroupId,
  1991. 0,1,0); // HELPID, Level, Errorflag
  1992. length += 8;
  1993. size = BytesLeft - lpMSRPCCO->AuthLength - length;
  1994. if ( size )
  1995. {
  1996. BYTE nContext;
  1997. AttachPropertyInstance( hFrame,
  1998. MSRPC_Prop[MSRPC_P_CONTEXT_SUM].hProperty,
  1999. size,
  2000. &lpMSRPCCO->AlterContext.PContextElem[0],
  2001. 0,1,0); // HELPID, Level, Errorflag
  2002. // break out the GUIDs etc from the context element...
  2003. AttachPropertyInstance( hFrame,
  2004. MSRPC_Prop[MSRPC_P_CONTEXT_ELEM].hProperty,
  2005. sizeof( BYTE ),
  2006. &lpMSRPCCO->Bind.PContextElem[0],
  2007. 0,2,0); // HELPID, Level, Errorflag
  2008. nContext = (BYTE)lpMSRPCCO->Bind.PContextElem[0];
  2009. AttachPContElem ( (p_cont_elem_t UNALIGNED * )&lpMSRPCCO->Bind.PContextElem[4],
  2010. nContext,
  2011. hFrame,
  2012. 2,
  2013. fLittleEndian);
  2014. length += size;
  2015. }
  2016. if ( lpMSRPCCO->AuthLength )
  2017. {
  2018. AttachPropertyInstance( hFrame,
  2019. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  2020. lpMSRPCCO->AuthLength,
  2021. &lpMSRPCCO->AlterContext.PContextElem[size],
  2022. 0,1,0); // HELPID, Level, Errorflag
  2023. length += lpMSRPCCO->AuthLength;
  2024. }
  2025. break;
  2026. case MSRPC_PDU_ALTER_CONTEXT_RESP :
  2027. AttachProperty( fLittleEndian,
  2028. hFrame,
  2029. MSRPC_Prop[MSRPC_MAX_XMIT_FRAG].hProperty,
  2030. sizeof( WORD ),
  2031. &lpMSRPCCO->AlterContextResp.MaxXmitFrag,
  2032. 0,1,0); // HELPID, Level, Errorflag
  2033. AttachProperty( fLittleEndian,
  2034. hFrame,
  2035. MSRPC_Prop[MSRPC_MAX_RECV_FRAG].hProperty,
  2036. sizeof( WORD ),
  2037. &lpMSRPCCO->AlterContextResp.MaxRecvFrag,
  2038. 0,1,0); // HELPID, Level, Errorflag
  2039. AttachProperty( fLittleEndian,
  2040. hFrame,
  2041. MSRPC_Prop[MSRPC_ASSOC_GROUP_ID].hProperty,
  2042. sizeof( DWORD ),
  2043. &lpMSRPCCO->AlterContextResp.AssocGroupId,
  2044. 0,1,0); // HELPID, Level, Errorflag
  2045. length += 8;
  2046. AddrLen = (ULPWORD) &lpMSRPCCO->AlterContextResp.SecAddr,
  2047. AttachPropertyInstance( hFrame,
  2048. MSRPC_Prop[MSRPC_SEC_ADDR].hProperty,
  2049. AddrLen[0] + 2,
  2050. &lpMSRPCCO->AlterContextResp.SecAddr[0],
  2051. 0,1,0); // HELPID, Level, Errorflag
  2052. AttachProperty( fLittleEndian,
  2053. hFrame,
  2054. MSRPC_Prop[MSRPC_SEC_ADDR_LENGTH].hProperty,
  2055. sizeof( WORD ),
  2056. &lpMSRPCCO->AlterContextResp.SecAddr[0],
  2057. 0,2,0); // HELPID, Level, Errorflag
  2058. AttachPropertyInstance( hFrame,
  2059. MSRPC_Prop[MSRPC_SEC_ADDR_PORT].hProperty,
  2060. AddrLen[0],
  2061. &lpMSRPCCO->AlterContextResp.SecAddr[2],
  2062. 0,2,0); // HELPID, Level, Errorflag
  2063. // Add bytes for secondary address
  2064. length += AddrLen[0] + 2;
  2065. AttachPropertyInstance( hFrame,
  2066. MSRPC_Prop[MSRPC_PAD].hProperty,
  2067. (((AddrLen[0]+2)/4+1)*4)-(AddrLen[0]+2),
  2068. &lpMSRPCCO->AlterContextResp.SecAddr[AddrLen[0] + 2],
  2069. 0,1,0); // HELPID, Level, Errorflag
  2070. // Add bytes for secondary address padding
  2071. offset = ((AddrLen[0]+2)/4+1)*4;
  2072. length += offset - ( AddrLen[0] + 2 );
  2073. nResults = lpMSRPCCO->AlterContextResp.SecAddr[offset];
  2074. AttachPropertyInstance( hFrame,
  2075. MSRPC_Prop[MSRPC_P_RESULT_LIST].hProperty,
  2076. nResults*24 + 4,
  2077. &lpMSRPCCO->AlterContextResp.SecAddr[offset],
  2078. 0,1,0); // HELPID, Level, Errorflag
  2079. AttachPropertyInstance( hFrame,
  2080. MSRPC_Prop[MSRPC_N_RESULTS].hProperty,
  2081. sizeof( BYTE ),
  2082. &lpMSRPCCO->AlterContextResp.SecAddr[offset],
  2083. 0,2,0); // HELPID, Level, Errorflag
  2084. offset += 1;
  2085. AttachPropertyInstance( hFrame,
  2086. MSRPC_Prop[MSRPC_RESERVED].hProperty,
  2087. sizeof( BYTE ),
  2088. &lpMSRPCCO->AlterContextResp.SecAddr[offset],
  2089. 0,2,0); // HELPID, Level, Errorflag
  2090. offset += 1;
  2091. AttachProperty( fLittleEndian,
  2092. hFrame,
  2093. MSRPC_Prop[MSRPC_RESERVED_2].hProperty,
  2094. sizeof( WORD ),
  2095. &lpMSRPCCO->AlterContextResp.SecAddr[offset],
  2096. 0,2,0); // HELPID, Level, Errorflag
  2097. offset += 2;
  2098. for ( i = 0; i < nResults; i++ )
  2099. {
  2100. AttachPropertyInstance( hFrame,
  2101. MSRPC_Prop[MSRPC_P_RESULTS].hProperty,
  2102. 24,
  2103. &lpMSRPCCO->AlterContextResp.SecAddr[offset+i*24],
  2104. 0,2,0); // HELPID, Level, Errorflag
  2105. AttachProperty( fLittleEndian,
  2106. hFrame,
  2107. MSRPC_Prop[MSRPC_P_CONT_DEF_RESULT].hProperty,
  2108. sizeof( WORD ),
  2109. &lpMSRPCCO->AlterContextResp.SecAddr[offset+i*24],
  2110. 0,3,0); // HELPID, Level, Errorflag
  2111. AttachProperty( fLittleEndian,
  2112. hFrame,
  2113. MSRPC_Prop[MSRPC_P_PROVIDER_REASON].hProperty,
  2114. sizeof( WORD ),
  2115. &lpMSRPCCO->AlterContextResp.SecAddr[offset+i*24+2],
  2116. 0,3,0); // HELPID, Level, Errorflag
  2117. AttachPropertyInstance( hFrame,
  2118. MSRPC_Prop[MSRPC_P_TRANSFER_SYNTAX].hProperty,
  2119. 20,
  2120. &lpMSRPCCO->AlterContextResp.SecAddr[offset+i*24+4],
  2121. 0,3,0); // HELPID, Level, Errorflag
  2122. AttachPropertyInstance( hFrame,
  2123. MSRPC_Prop[MSRPC_IF_UUID].hProperty,
  2124. 16,
  2125. &lpMSRPCCO->AlterContextResp.SecAddr[offset+i*24+4],
  2126. 0,4,0); // HELPID, Level, Errorflag
  2127. AttachProperty( fLittleEndian,
  2128. hFrame,
  2129. MSRPC_Prop[MSRPC_IF_VERSION].hProperty,
  2130. sizeof( DWORD ),
  2131. &lpMSRPCCO->AlterContextResp.SecAddr[offset+i*24+20],
  2132. 0,4,0); // HELPID, Level, Errorflag
  2133. }
  2134. offset = nResults*24;
  2135. length += offset;
  2136. if ( lpMSRPCCO->AuthLength > 0 )
  2137. {
  2138. AttachPropertyInstance( hFrame,
  2139. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  2140. lpMSRPCCO->AuthLength,
  2141. &lpMSRPCCO->AlterContextResp.SecAddr[offset],
  2142. 0,1,0); // HELPID, Level, Errorflag
  2143. length += lpMSRPCCO->AuthLength;
  2144. }
  2145. break;
  2146. case MSRPC_PDU_CO_CANCEL :
  2147. if ( lpMSRPCCO->AuthLength > 0 )
  2148. {
  2149. AttachPropertyInstance( hFrame,
  2150. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  2151. lpMSRPCCO->AuthLength,
  2152. &lpMSRPCCO->COCancel.AuthTrailer,
  2153. 0,1,0); // HELPID, Level, Errorflag
  2154. length += lpMSRPCCO->AuthLength;
  2155. }
  2156. break;
  2157. case MSRPC_PDU_ORPHANED :
  2158. if ( lpMSRPCCO->AuthLength > 0 )
  2159. {
  2160. AttachPropertyInstance( hFrame,
  2161. MSRPC_Prop[MSRPC_AUTH_VERIFIER].hProperty,
  2162. lpMSRPCCO->AuthLength,
  2163. &lpMSRPCCO->Orphaned.AuthTrailer,
  2164. 0,1,0); // HELPID, Level, Errorflag
  2165. length += lpMSRPCCO->AuthLength;
  2166. }
  2167. break;
  2168. case MSRPC_PDU_SHUTDOWN :
  2169. break;
  2170. }
  2171. }
  2172. if ( lpMSRPCCL->Version == 0x04 )
  2173. {
  2174. // Determine the big or little endianess of this packet
  2175. fLittleEndian = IsLittleEndian( (BYTE) lpMSRPCCL->PackedDrep[0] );
  2176. //
  2177. // Attach the standard part of MSRPC Connection-less packet
  2178. //
  2179. AttachPropertyInstance( hFrame,
  2180. MSRPC_Prop[MSRPC_VERSION].hProperty,
  2181. sizeof( BYTE ),
  2182. &lpMSRPCCL->Version,
  2183. 0,1,0); // HELPID, Level, Errorflag
  2184. AttachPropertyInstance( hFrame,
  2185. MSRPC_Prop[MSRPC_PTYPE].hProperty,
  2186. sizeof( BYTE ),
  2187. &lpMSRPCCL->PType,
  2188. 0,1,0); // HELPID, Level, Errorflag
  2189. AttachPropertyInstance( hFrame,
  2190. MSRPC_Prop[MSRPC_PFC_FLAGS1].hProperty,
  2191. sizeof( BYTE ),
  2192. &lpMSRPCCL->PFCFlags1,
  2193. 0,1,0); // HELPID, Level, Errorflag
  2194. AttachPropertyInstance( hFrame,
  2195. MSRPC_Prop[MSRPC_PFC_FLAGS1_BITS].hProperty,
  2196. sizeof( BYTE ),
  2197. &lpMSRPCCL->PFCFlags1,
  2198. 0,2,0); // HELPID, Level, Errorflag
  2199. AttachPropertyInstance( hFrame,
  2200. MSRPC_Prop[MSRPC_PFC_FLAGS2].hProperty,
  2201. sizeof( BYTE ),
  2202. &lpMSRPCCL->PFCFlags2,
  2203. 0,1,0); // HELPID, Level, Errorflag
  2204. AttachPropertyInstance( hFrame,
  2205. MSRPC_Prop[MSRPC_PFC_FLAGS2_BITS].hProperty,
  2206. sizeof( BYTE ),
  2207. &lpMSRPCCL->PFCFlags2,
  2208. 0,2,0); // HELPID, Level, Errorflag
  2209. AttachPropertyInstance( hFrame,
  2210. MSRPC_Prop[MSRPC_PACKED_DREP].hProperty,
  2211. sizeof( BYTE ) * 3,
  2212. &lpMSRPCCL->PackedDrep,
  2213. 0,1,0); // HELPID, Level, Errorflag
  2214. AttachPropertyInstance( hFrame,
  2215. MSRPC_Prop[MSRPC_SERIAL_HI].hProperty,
  2216. sizeof( BYTE ),
  2217. &lpMSRPCCL->SerialNumHi,
  2218. 0,1,0); // HELPID, Level, Errorflag
  2219. AttachPropertyInstance( hFrame,
  2220. MSRPC_Prop[MSRPC_OBJECT_ID].hProperty,
  2221. 16,
  2222. &lpMSRPCCL->ObjectId,
  2223. 0,1,0); // HELPID, Level, Errorflag
  2224. AttachPropertyInstance( hFrame,
  2225. MSRPC_Prop[MSRPC_INTERFACE_ID].hProperty,
  2226. 16,
  2227. &lpMSRPCCL->InterfaceId,
  2228. 0,1,0); // HELPID, Level, Errorflag
  2229. AttachPropertyInstance( hFrame,
  2230. MSRPC_Prop[MSRPC_ACTIVITY_ID].hProperty,
  2231. 16,
  2232. &lpMSRPCCL->ActivityId,
  2233. 0,1,0); // HELPID, Level, Errorflag
  2234. AttachProperty( fLittleEndian,
  2235. hFrame,
  2236. MSRPC_Prop[MSRPC_SERVER_BOOT_TIME].hProperty,
  2237. sizeof( DWORD ),
  2238. &lpMSRPCCL->ServerBootTime,
  2239. 0,1,0); // HELPID, Level, Errorflag
  2240. AttachProperty( fLittleEndian,
  2241. hFrame,
  2242. MSRPC_Prop[MSRPC_INTERFACE_VER].hProperty,
  2243. sizeof( DWORD ),
  2244. &lpMSRPCCL->InterfaceVersion,
  2245. 0,1,0); // HELPID, Level, Errorflag
  2246. AttachProperty( fLittleEndian,
  2247. hFrame,
  2248. MSRPC_Prop[MSRPC_SEQ_NUM].hProperty,
  2249. sizeof( DWORD ),
  2250. &lpMSRPCCL->SeqNum,
  2251. 0,1,0); // HELPID, Level, Errorflag
  2252. AttachProperty( fLittleEndian,
  2253. hFrame,
  2254. MSRPC_Prop[MSRPC_OPNUM].hProperty,
  2255. sizeof( WORD ),
  2256. &lpMSRPCCL->OpNum,
  2257. 0,1,0); // HELPID, Level, Errorflag
  2258. AttachProperty( fLittleEndian,
  2259. hFrame,
  2260. MSRPC_Prop[MSRPC_INTERFACE_HINT].hProperty,
  2261. sizeof( WORD ),
  2262. &lpMSRPCCL->InterfaceHint,
  2263. 0,1,0); // HELPID, Level, Errorflag
  2264. AttachProperty( fLittleEndian,
  2265. hFrame,
  2266. MSRPC_Prop[MSRPC_ACTIVITY_HINT].hProperty,
  2267. sizeof( WORD ),
  2268. &lpMSRPCCL->ActivityHint,
  2269. 0,1,0); // HELPID, Level, Errorflag
  2270. AttachProperty( fLittleEndian,
  2271. hFrame,
  2272. MSRPC_Prop[MSRPC_LEN_OF_PACKET_BODY].hProperty,
  2273. sizeof( WORD ),
  2274. &lpMSRPCCL->Length,
  2275. 0,1,0); // HELPID, Level, Errorflag
  2276. AttachProperty( fLittleEndian,
  2277. hFrame,
  2278. MSRPC_Prop[MSRPC_FRAG_NUM].hProperty,
  2279. sizeof( WORD ),
  2280. &lpMSRPCCL->FragNum,
  2281. 0,1,0); // HELPID, Level, Errorflag
  2282. AttachPropertyInstance( hFrame,
  2283. MSRPC_Prop[MSRPC_AUTH_PROTO_ID].hProperty,
  2284. sizeof( BYTE ),
  2285. &lpMSRPCCL->AuthProtoId,
  2286. 0,1,0); // HELPID, Level, Errorflag
  2287. AttachPropertyInstance( hFrame,
  2288. MSRPC_Prop[MSRPC_SERIAL_LO].hProperty,
  2289. sizeof( BYTE ),
  2290. &lpMSRPCCL->SerialNumLo,
  2291. 0,1,0); // HELPID, Level, Errorflag
  2292. length = 80;
  2293. //
  2294. // Attach the specific part of MSRPC packets based on PType
  2295. //
  2296. switch ( lpMSRPCCL->PType )
  2297. {
  2298. case MSRPC_PDU_REQUEST :
  2299. size = lpMSRPCCL->Length;
  2300. if ( size )
  2301. {
  2302. AttachPropertyInstance( hFrame,
  2303. MSRPC_Prop[MSRPC_STUB_DATA].hProperty,
  2304. size,
  2305. &lpMSRPCCL->Request.Data[0],
  2306. 0,1,0); // HELPID, Level, Errorflag
  2307. length += size;
  2308. }
  2309. break;
  2310. case MSRPC_PDU_PING :
  2311. // NO BODY DATA
  2312. break;
  2313. case MSRPC_PDU_RESPONSE :
  2314. size = lpMSRPCCL->Length;
  2315. if ( size )
  2316. {
  2317. AttachPropertyInstance( hFrame,
  2318. MSRPC_Prop[MSRPC_STUB_DATA].hProperty,
  2319. size,
  2320. &lpMSRPCCL->Response.Data[0],
  2321. 0,1,0); // HELPID, Level, Errorflag
  2322. length += size;
  2323. }
  2324. break;
  2325. case MSRPC_PDU_FAULT :
  2326. AttachProperty( fLittleEndian,
  2327. hFrame,
  2328. MSRPC_Prop[MSRPC_STATUS_CODE].hProperty,
  2329. sizeof( DWORD ),
  2330. &lpMSRPCCL->Fault.StatusCode,
  2331. 0,1,0); // HELPID, Level, Errorflag
  2332. length += 4;
  2333. break;
  2334. case MSRPC_PDU_WORKING :
  2335. // NO BODY DATA
  2336. break;
  2337. case MSRPC_PDU_NOCALL :
  2338. if ( lpMSRPCCL->Length >= 16 )
  2339. {
  2340. AttachPropertyInstance( hFrame,
  2341. MSRPC_Prop[MSRPC_VERSION].hProperty,
  2342. sizeof( BYTE ),
  2343. &lpMSRPCCL->NoCall.Vers,
  2344. 0,1,0); // HELPID, Level, Errorflag
  2345. AttachPropertyInstance( hFrame,
  2346. MSRPC_Prop[MSRPC_PAD].hProperty,
  2347. sizeof( BYTE ),
  2348. &lpMSRPCCL->NoCall.Pad1,
  2349. 0,1,0); // HELPID, Level, Errorflag
  2350. AttachProperty( fLittleEndian,
  2351. hFrame,
  2352. MSRPC_Prop[MSRPC_WINDOW_SIZE].hProperty,
  2353. sizeof( WORD ),
  2354. &lpMSRPCCL->NoCall.WindowSize,
  2355. 0,1,0); // HELPID, Level, Errorflag
  2356. AttachProperty( fLittleEndian,
  2357. hFrame,
  2358. MSRPC_Prop[MSRPC_MAX_TPDU].hProperty,
  2359. sizeof( DWORD ),
  2360. &lpMSRPCCL->NoCall.MaxTPDU,
  2361. 0,1,0); // HELPID, Level, Errorflag
  2362. AttachProperty( fLittleEndian,
  2363. hFrame,
  2364. MSRPC_Prop[MSRPC_MAX_PATH_TPDU].hProperty,
  2365. sizeof( DWORD ),
  2366. &lpMSRPCCL->NoCall.MaxPathTPDU,
  2367. 0,1,0); // HELPID, Level, Errorflag
  2368. AttachProperty( fLittleEndian,
  2369. hFrame,
  2370. MSRPC_Prop[MSRPC_SERIAL_NUM].hProperty,
  2371. sizeof( WORD ),
  2372. &lpMSRPCCL->NoCall.SerialNumber,
  2373. 0,1,0); // HELPID, Level, Errorflag
  2374. AttachProperty( fLittleEndian,
  2375. hFrame,
  2376. MSRPC_Prop[MSRPC_SELACK_LEN].hProperty,
  2377. sizeof( WORD ),
  2378. &lpMSRPCCL->NoCall.SelAckLen,
  2379. 0,1,0); // HELPID, Level, Errorflag
  2380. AttachPropertyInstance( hFrame,
  2381. MSRPC_Prop[MSRPC_SELACK].hProperty,
  2382. sizeof( DWORD )*lpMSRPCCL->NoCall.SelAckLen,
  2383. &lpMSRPCCL->NoCall.SelAck,
  2384. 0,1,0); // HELPID, Level, Errorflag
  2385. length = length + 16 + ( 4*lpMSRPCCL->NoCall.SelAckLen );
  2386. }
  2387. break;
  2388. case MSRPC_PDU_REJECT :
  2389. AttachProperty( fLittleEndian,
  2390. hFrame,
  2391. MSRPC_Prop[MSRPC_STATUS_CODE].hProperty,
  2392. sizeof( DWORD ),
  2393. &lpMSRPCCL->Reject.StatusCode,
  2394. 0,1,0); // HELPID, Level, Errorflag
  2395. length += 4;
  2396. break;
  2397. case MSRPC_PDU_ACK :
  2398. // NO BODY DATA
  2399. break;
  2400. case MSRPC_PDU_CL_CANCEL :
  2401. AttachProperty( fLittleEndian,
  2402. hFrame,
  2403. MSRPC_Prop[MSRPC_CANCEL_REQUEST_FMT_VER].hProperty,
  2404. sizeof( DWORD ),
  2405. &lpMSRPCCL->CLCancel.Vers,
  2406. 0,1,0); // HELPID, Level, Errorflag
  2407. AttachProperty( fLittleEndian,
  2408. hFrame,
  2409. MSRPC_Prop[MSRPC_CANCEL_ID].hProperty,
  2410. sizeof( DWORD ),
  2411. &lpMSRPCCL->CLCancel.CancelId,
  2412. 0,1,0); // HELPID, Level, Errorflag
  2413. length += 8;
  2414. break;
  2415. case MSRPC_PDU_FACK :
  2416. if ( lpMSRPCCL->Length >= 16 )
  2417. {
  2418. AttachPropertyInstance( hFrame,
  2419. MSRPC_Prop[MSRPC_VERSION].hProperty,
  2420. sizeof( BYTE ),
  2421. &lpMSRPCCL->Fack.Vers,
  2422. 0,1,0); // HELPID, Level, Errorflag
  2423. AttachPropertyInstance( hFrame,
  2424. MSRPC_Prop[MSRPC_PAD].hProperty,
  2425. sizeof( BYTE ),
  2426. &lpMSRPCCL->Fack.Pad1,
  2427. 0,1,0); // HELPID, Level, Errorflag
  2428. AttachProperty( fLittleEndian,
  2429. hFrame,
  2430. MSRPC_Prop[MSRPC_WINDOW_SIZE].hProperty,
  2431. sizeof( WORD ),
  2432. &lpMSRPCCL->Fack.WindowSize,
  2433. 0,1,0); // HELPID, Level, Errorflag
  2434. AttachProperty( fLittleEndian,
  2435. hFrame,
  2436. MSRPC_Prop[MSRPC_MAX_TPDU].hProperty,
  2437. sizeof( DWORD ),
  2438. &lpMSRPCCL->Fack.MaxTPDU,
  2439. 0,1,0); // HELPID, Level, Errorflag
  2440. AttachProperty( fLittleEndian,
  2441. hFrame,
  2442. MSRPC_Prop[MSRPC_MAX_PATH_TPDU].hProperty,
  2443. sizeof( DWORD ),
  2444. &lpMSRPCCL->Fack.MaxPathTPDU,
  2445. 0,1,0); // HELPID, Level, Errorflag
  2446. AttachProperty( fLittleEndian,
  2447. hFrame,
  2448. MSRPC_Prop[MSRPC_SERIAL_NUM].hProperty,
  2449. sizeof( WORD ),
  2450. &lpMSRPCCL->Fack.SerialNumber,
  2451. 0,1,0); // HELPID, Level, Errorflag
  2452. AttachProperty( fLittleEndian,
  2453. hFrame,
  2454. MSRPC_Prop[MSRPC_SELACK_LEN].hProperty,
  2455. sizeof( WORD ),
  2456. &lpMSRPCCL->Fack.SelAckLen,
  2457. 0,1,0); // HELPID, Level, Errorflag
  2458. AttachPropertyInstance( hFrame,
  2459. MSRPC_Prop[MSRPC_SELACK].hProperty,
  2460. sizeof( DWORD )*lpMSRPCCL->Fack.SelAckLen,
  2461. &lpMSRPCCL->Fack.SelAck,
  2462. 0,1,0); // HELPID, Level, Errorflag
  2463. length = length + 16 + ( 4*lpMSRPCCL->Fack.SelAckLen );
  2464. }
  2465. break;
  2466. case MSRPC_PDU_CANCEL_ACK :
  2467. if ( lpMSRPCCL->Length >= 12 )
  2468. {
  2469. AttachProperty( fLittleEndian,
  2470. hFrame,
  2471. MSRPC_Prop[MSRPC_CANCEL_REQUEST_FMT_VER].hProperty,
  2472. sizeof( DWORD ),
  2473. &lpMSRPCCL->CancelAck.Vers,
  2474. 0,1,0); // HELPID, Level, Errorflag
  2475. AttachProperty( fLittleEndian,
  2476. hFrame,
  2477. MSRPC_Prop[MSRPC_CANCEL_ID].hProperty,
  2478. sizeof( DWORD ),
  2479. &lpMSRPCCL->CancelAck.CancelId,
  2480. 0,1,0); // HELPID, Level, Errorflag
  2481. AttachProperty( fLittleEndian,
  2482. hFrame,
  2483. MSRPC_Prop[MSRPC_SERVER_IS_ACCEPTING].hProperty,
  2484. sizeof( DWORD ),
  2485. &lpMSRPCCL->CancelAck.ServerIsAccepting,
  2486. 0,1,0); // HELPID, Level, Errorflag
  2487. length += 12;
  2488. }
  2489. }
  2490. }
  2491. return (LPBYTE) TheFrame + length;
  2492. }
  2493. // *****************************************************************************
  2494. //
  2495. // Name: MSRPC_FormatProperties
  2496. //
  2497. // Description: Format all of the properties attached to a given frame.
  2498. //
  2499. // Return Code: DWORD: NMERR_SUCCESS.
  2500. //
  2501. // History:
  2502. // 12/18/92 JayPh Shamelessly ripped off from RayPa.
  2503. // 11/06/93 SteveHi converted to property centric
  2504. //
  2505. // *****************************************************************************
  2506. DWORD WINAPI MSRPC_FormatProperties( HFRAME hFrame,
  2507. LPBYTE MacFrame,
  2508. LPBYTE ProtocolFrame,
  2509. DWORD nPropertyInsts,
  2510. LPPROPERTYINST p )
  2511. {
  2512. if ((lpBindTable = (LPBINDTABLE) GetCCInstPtr()) == NULL)
  2513. {
  2514. #ifdef DEBUG
  2515. dprintf ("No lpBindTable at Format Time!!");
  2516. DebugBreak();
  2517. #endif
  2518. }
  2519. while ( nPropertyInsts-- )
  2520. {
  2521. ( (FORMAT) p->lpPropertyInfo->InstanceData )( p );
  2522. p++;
  2523. }
  2524. return NMERR_SUCCESS;
  2525. }
  2526. //*****************************************************************************
  2527. //
  2528. // Name: MSRPC_FmtSummary
  2529. //
  2530. // Description: Format function for MSRPC Summary Information.
  2531. //
  2532. // Parameters: LPPROPERTYINST lpPropertyInst: pointer to property instance.
  2533. //
  2534. // Return Code: VOID.
  2535. //
  2536. // History:
  2537. // 08/11/93 GlennC Created.
  2538. //
  2539. //*****************************************************************************
  2540. VOID WINAPIV MSRPC_FmtSummary( LPPROPERTYINST lpPropertyInst )
  2541. {
  2542. LPMSRPCCO lpMSRPCCO = (LPMSRPCCO)(lpPropertyInst->lpData);
  2543. LPMSRPCCL lpMSRPCCL = (LPMSRPCCL)(lpPropertyInst->lpData);
  2544. LPSTR PType = NULL;
  2545. WORD Serial = 0;
  2546. LPSTR str;
  2547. int i;
  2548. BOOL fLittle;
  2549. if ( lpMSRPCCO->PackedDrep[0] == 0x05 && lpMSRPCCO->PackedDrep[1] == 0x00 )
  2550. lpMSRPCCO = (LPMSRPCCO) lpMSRPCCO->PackedDrep;
  2551. if ( lpMSRPCCO->Version == 0x05 && lpMSRPCCO->VersionMinor == 0x00 )
  2552. {
  2553. // Determine the big or little endianess of this packet
  2554. fLittle = IsLittleEndian( (BYTE) lpMSRPCCO->PackedDrep[0] );
  2555. switch( lpMSRPCCO->PType )
  2556. {
  2557. case MSRPC_PDU_REQUEST :
  2558. PType = "Request: ";
  2559. wsprintf( lpPropertyInst->szPropertyText,
  2560. "c/o RPC %scall 0x%X opnum 0x%X context 0x%X hint 0x%X",
  2561. PType,
  2562. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2563. fLittle ? lpMSRPCCO->Request.OpNum : XCHG( lpMSRPCCO->Request.OpNum ),
  2564. fLittle ? lpMSRPCCO->Request.PContId : XCHG( lpMSRPCCO->Request.PContId ),
  2565. fLittle ? lpMSRPCCO->Request.AllocHint : DXCHG( lpMSRPCCO->Request.AllocHint ) );
  2566. break;
  2567. case MSRPC_PDU_RESPONSE :
  2568. PType = "Response: ";
  2569. wsprintf( lpPropertyInst->szPropertyText,
  2570. "c/o RPC %scall 0x%X context 0x%X hint 0x%X cancels 0x%X",
  2571. PType,
  2572. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2573. fLittle ? lpMSRPCCO->Response.PContId : XCHG( lpMSRPCCO->Response.PContId ),
  2574. fLittle ? lpMSRPCCO->Response.AllocHint : DXCHG( lpMSRPCCO->Response.AllocHint ),
  2575. lpMSRPCCO->Response.CancelCount );
  2576. break;
  2577. case MSRPC_PDU_FAULT :
  2578. PType = "Fault: ";
  2579. wsprintf( lpPropertyInst->szPropertyText,
  2580. "c/o RPC %scall 0x%X context 0x%X status 0x%X cancels 0x%X",
  2581. PType,
  2582. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2583. fLittle ? lpMSRPCCO->Fault.PContId : XCHG( lpMSRPCCO->Fault.PContId ),
  2584. fLittle ? lpMSRPCCO->Fault.Status : DXCHG( lpMSRPCCO->Fault.Status ),
  2585. lpMSRPCCO->Fault.CancelCount );
  2586. break;
  2587. case MSRPC_PDU_BIND:
  2588. {
  2589. int Length;
  2590. p_cont_elem_t UNALIGNED * pContElem= (p_cont_elem_t UNALIGNED * )&lpMSRPCCO->Bind.PContextElem[4];
  2591. LPBYTE pIUUID = (LPBYTE)&pContElem->abstract_syntax.if_uuid;
  2592. PType = "Bind: ";
  2593. Length = wsprintf( lpPropertyInst->szPropertyText,
  2594. "c/o RPC %sUUID ",
  2595. PType);
  2596. Length += FormatUUID( &lpPropertyInst->szPropertyText[Length],
  2597. pIUUID);
  2598. wsprintf ( &lpPropertyInst->szPropertyText[Length],
  2599. " call 0x%X assoc grp 0x%X xmit 0x%X recv 0x%X",
  2600. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2601. fLittle ? lpMSRPCCO->Bind.AssocGroupId : DXCHG( lpMSRPCCO->Bind.AssocGroupId ),
  2602. fLittle ? lpMSRPCCO->Bind.MaxXmitFrag : XCHG( lpMSRPCCO->Bind.MaxXmitFrag ),
  2603. fLittle ? lpMSRPCCO->Bind.MaxRecvFrag : XCHG( lpMSRPCCO->Bind.MaxRecvFrag ) );
  2604. break;
  2605. }
  2606. case MSRPC_PDU_BIND_ACK :
  2607. PType = "Bind Ack: ";
  2608. wsprintf( lpPropertyInst->szPropertyText,
  2609. "c/o RPC %scall 0x%X assoc grp 0x%X xmit 0x%X recv 0x%X",
  2610. PType,
  2611. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2612. fLittle ? lpMSRPCCO->BindAck.AssocGroupId : DXCHG( lpMSRPCCO->BindAck.AssocGroupId ),
  2613. fLittle ? lpMSRPCCO->BindAck.MaxXmitFrag : XCHG( lpMSRPCCO->BindAck.MaxXmitFrag ),
  2614. fLittle ? lpMSRPCCO->BindAck.MaxRecvFrag : XCHG( lpMSRPCCO->BindAck.MaxRecvFrag ) );
  2615. break;
  2616. case MSRPC_PDU_BIND_NAK :
  2617. PType = "Bind Nak: ";
  2618. i = (int) ( fLittle ? lpMSRPCCO->BindNak.RejectReason : XCHG( lpMSRPCCO->BindNak.RejectReason ) );
  2619. if ( ( 0 < i ) && ( i < 11 ) )
  2620. str = RejectReason[i - 1];
  2621. else
  2622. str = RejectReason[10];
  2623. wsprintf( lpPropertyInst->szPropertyText,
  2624. "c/o RPC %scall 0x%X reject reason (%s)",
  2625. PType,
  2626. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2627. str );
  2628. break;
  2629. case MSRPC_PDU_ALTER_CONTEXT :
  2630. {
  2631. int Length;
  2632. p_cont_elem_t UNALIGNED * pContElem= (p_cont_elem_t UNALIGNED * )&lpMSRPCCO->Bind.PContextElem[4];
  2633. LPBYTE pIUUID = (LPBYTE)&pContElem->abstract_syntax.if_uuid;
  2634. PType = "Alt-Cont: ";
  2635. Length = wsprintf( lpPropertyInst->szPropertyText,
  2636. "c/o RPC %sUUID ",
  2637. PType);
  2638. Length += FormatUUID( &lpPropertyInst->szPropertyText[Length],
  2639. pIUUID);
  2640. wsprintf ( &lpPropertyInst->szPropertyText[Length],
  2641. " call 0x%X assoc grp 0x%X xmit 0x%X recv 0x%X",
  2642. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2643. fLittle ? lpMSRPCCO->AlterContext.AssocGroupId : DXCHG( lpMSRPCCO->AlterContext.AssocGroupId ),
  2644. fLittle ? lpMSRPCCO->AlterContext.MaxXmitFrag : XCHG( lpMSRPCCO->AlterContext.MaxXmitFrag ),
  2645. fLittle ? lpMSRPCCO->AlterContext.MaxRecvFrag : XCHG( lpMSRPCCO->AlterContext.MaxRecvFrag ) );
  2646. break;
  2647. }
  2648. case MSRPC_PDU_ALTER_CONTEXT_RESP :
  2649. PType = "Alt-Cont Rsp: ";
  2650. wsprintf( lpPropertyInst->szPropertyText,
  2651. "c/o RPC %scall 0x%X assoc grp 0x%X xmit 0x%X recv 0x%X",
  2652. PType,
  2653. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ),
  2654. fLittle ? lpMSRPCCO->AlterContextResp.AssocGroupId : DXCHG( lpMSRPCCO->AlterContextResp.AssocGroupId ),
  2655. fLittle ? lpMSRPCCO->AlterContextResp.MaxXmitFrag : XCHG( lpMSRPCCO->AlterContextResp.MaxXmitFrag ),
  2656. fLittle ? lpMSRPCCO->AlterContextResp.MaxRecvFrag : XCHG( lpMSRPCCO->AlterContextResp.MaxRecvFrag ) );
  2657. break;
  2658. case MSRPC_PDU_SHUTDOWN :
  2659. PType = "Shutdown: ";
  2660. wsprintf( lpPropertyInst->szPropertyText,
  2661. "c/o RPC %scall 0x%X",
  2662. PType,
  2663. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ) );
  2664. break;
  2665. case MSRPC_PDU_CO_CANCEL :
  2666. PType = "Cancel: ";
  2667. wsprintf( lpPropertyInst->szPropertyText,
  2668. "c/o RPC %scall 0x%X",
  2669. PType,
  2670. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ) );
  2671. break;
  2672. case MSRPC_PDU_ORPHANED :
  2673. PType = "Orphaned: ";
  2674. wsprintf( lpPropertyInst->szPropertyText,
  2675. "c/o RPC %scall 0x%X",
  2676. PType,
  2677. fLittle ? lpMSRPCCO->CallID : DXCHG( lpMSRPCCO->CallID ) );
  2678. break;
  2679. }
  2680. }
  2681. if ( lpMSRPCCL->Version == 0x04 )
  2682. {
  2683. // Determine the big or little endianess of this packet
  2684. fLittle = IsLittleEndian( (BYTE) lpMSRPCCL->PackedDrep[0] );
  2685. switch( lpMSRPCCL->PType )
  2686. {
  2687. case MSRPC_PDU_REQUEST :
  2688. PType = "Request: ";
  2689. break;
  2690. case MSRPC_PDU_PING :
  2691. PType = "Ping: ";
  2692. break;
  2693. case MSRPC_PDU_RESPONSE :
  2694. PType = "Response: ";
  2695. break;
  2696. case MSRPC_PDU_FAULT :
  2697. PType = "Fault: ";
  2698. break;
  2699. case MSRPC_PDU_WORKING :
  2700. PType = "Working: ";
  2701. break;
  2702. case MSRPC_PDU_NOCALL :
  2703. PType = "No Call: ";
  2704. break;
  2705. case MSRPC_PDU_REJECT :
  2706. PType = "Reject: ";
  2707. break;
  2708. case MSRPC_PDU_ACK :
  2709. PType = "Ack: ";
  2710. break;
  2711. case MSRPC_PDU_CL_CANCEL :
  2712. PType = "Cancel: ";
  2713. break;
  2714. case MSRPC_PDU_FACK :
  2715. PType = "Fack: ";
  2716. break;
  2717. case MSRPC_PDU_CANCEL_ACK :
  2718. PType = "Cancel Ack: ";
  2719. break;
  2720. }
  2721. Serial = (WORD) lpMSRPCCL->SerialNumHi;
  2722. Serial = ( Serial << 8 ) | lpMSRPCCL->SerialNumLo;
  2723. wsprintf( lpPropertyInst->szPropertyText,
  2724. "dg RPC %sseq 0x%X opnum 0x%X frag 0x%X serial 0x%X act id 0x%.8X%.8X%.8X%.8X",
  2725. PType,
  2726. fLittle ? lpMSRPCCL->SeqNum : DXCHG( lpMSRPCCL->SeqNum ),
  2727. fLittle ? lpMSRPCCL->OpNum : XCHG( lpMSRPCCL->OpNum ),
  2728. fLittle ? lpMSRPCCL->FragNum : XCHG( lpMSRPCCL->FragNum ),
  2729. Serial,
  2730. DXCHG( ((DWORD UNALIGNED *) lpMSRPCCL->ActivityId)[0] ),
  2731. DXCHG( ((DWORD UNALIGNED *) lpMSRPCCL->ActivityId)[1] ),
  2732. DXCHG( ((DWORD UNALIGNED *) lpMSRPCCL->ActivityId)[2] ),
  2733. DXCHG( ((DWORD UNALIGNED *) lpMSRPCCL->ActivityId)[3] ) );
  2734. }
  2735. }
  2736. // FindBindParser will search back into the RPC capture, trying to find
  2737. // the BIND frame that this request or response relates to. If found,
  2738. // it will extract the Abstract IID from the BIND, figure out if a
  2739. // parser is activated in the system that represents the IID and returns
  2740. // its HPROTOCOL. In the case of a response, it will also find the request
  2741. // and return the "Operation Number" of the request.
  2742. // Note that this function must identify the previous protocol and match
  2743. // the session between the BIND and the request or response.
  2744. HPROTOCOL FindBindParser ( HFRAME hOrgFrame,
  2745. HPROTOCOL hPrevProtocol,
  2746. LPBYTE lpPrevProtocol,
  2747. WORD PConID,
  2748. LPWORD lpOpNum,
  2749. LPDWORD lpBindVersion )
  2750. {
  2751. ADDRESS Dst, Src;
  2752. DWORD OrgFrameNumber = GetFrameNumber ( hOrgFrame);
  2753. DWORD StopFrameNumber = OrgFrameNumber>999?(OrgFrameNumber - 1000):0;
  2754. WORD RPCOffset;
  2755. HFRAME hFindFrame = hOrgFrame;
  2756. LPMSRPCCO lpMSRPCCO;
  2757. BOOL fKeepGoing;
  2758. HPROTOCOL hTemp;
  2759. DWORD TCPPorts;
  2760. DWORD TCPFlippedPorts;
  2761. DWORD SMBID;
  2762. WORD SMBFID;
  2763. DWORD VinesTLPorts;
  2764. DWORD VinesTLFlippedPorts;
  2765. DWORD SPXControl;
  2766. DWORD SPXFlippedControl;
  2767. if ( nIIDs == 0 )
  2768. return NULL; // have have NO follows at this time to find... don't do work.
  2769. // find this frames source and dest address
  2770. if ((GetFrameSourceAddress(hOrgFrame,&Src,ADDRESS_TYPE_FIND_HIGHEST,FALSE) == NMERR_SUCCESS) &&
  2771. (GetFrameDestAddress (hOrgFrame,&Dst,ADDRESS_TYPE_FIND_HIGHEST,FALSE) == NMERR_SUCCESS))
  2772. fKeepGoing = TRUE;
  2773. else
  2774. return NULL;
  2775. // Get protocol specific information about the starting frame.
  2776. if (hPrevProtocol == hTCP)
  2777. {
  2778. // extract the source and destination port. Store them in a DWORD that
  2779. // can be effeciently compared.
  2780. TCPPorts = *(ULPDWORD)lpPrevProtocol;
  2781. TCPFlippedPorts = ((*(ULPWORD) lpPrevProtocol)<<16) + *(ULPWORD)((LPBYTE)lpPrevProtocol+2) ;
  2782. }
  2783. else if ( hPrevProtocol == hSMB )
  2784. {
  2785. // Just get the PID and TID from the SMB. Ignore the MID (which will change as the transactions
  2786. // change... and ignore the UID (simply because the PID and TID fit nicely into 1 dword... and
  2787. // right now, NT will only have 1 user at at time doing session IPC between a client and server.
  2788. SMBID = *(ULPDWORD) ((LPBYTE)lpPrevProtocol+0x18); // 0x18 is where the header starts. (pid tid)
  2789. // We NEED the FID... there can be multiple files open at this point.
  2790. // NOTE NOTE NOTE If this is a response frame, the FID will be bogus at this point
  2791. // until we go find the request frame...
  2792. SMBFID = *(WORD UNALIGNED *)((LPBYTE)lpPrevProtocol+0x3f);
  2793. }
  2794. else if ( (hPrevProtocol == hSPX) || (hPrevProtocol == hNBIPX) )
  2795. {
  2796. // COOL! NBIPX and SPX have the same offset to the bytes we need to id the connection.
  2797. // extract the source and destination connection id. Store them in a DWORD that
  2798. // can be effeciently compared.
  2799. SPXControl = *(ULPDWORD) ( (LPBYTE)lpPrevProtocol +2);
  2800. SPXFlippedControl = ((*(ULPWORD) ( (LPBYTE)lpPrevProtocol +2))<<16) + *(ULPWORD)((LPBYTE)lpPrevProtocol+4);
  2801. }
  2802. else if (hPrevProtocol == hVinesTL)
  2803. {
  2804. // extract the source and destination port. Store them in a DWORD that
  2805. // can be effeciently compared.
  2806. VinesTLPorts = *(ULPDWORD)lpPrevProtocol;;
  2807. VinesTLFlippedPorts = ((*(ULPWORD) lpPrevProtocol)<<16) + *(ULPWORD)((LPBYTE)lpPrevProtocol+2);
  2808. }
  2809. else
  2810. {
  2811. // If we cannot determine the previous protocol, then we cannot FIND the
  2812. // previous frame and know that we are using the correct concept of a
  2813. // session on that protocol... bail.
  2814. return NULL;
  2815. }
  2816. if (lpOpNum) // this is a response frame. Get more information about the request frame.
  2817. {
  2818. // we must first find the REQUEST frame with the same response PConID
  2819. // to get the op number from it.
  2820. while (fKeepGoing)
  2821. {
  2822. // note the flipped src and dst address...
  2823. hFindFrame = FindPreviousFrame( hFindFrame,
  2824. "MSRPC",
  2825. &Src,
  2826. &Dst,
  2827. &RPCOffset,
  2828. OrgFrameNumber,
  2829. StopFrameNumber);
  2830. if ( hFindFrame )
  2831. {
  2832. LPBYTE lpFrame = ParserTemporaryLockFrame (hFindFrame);
  2833. // get a pointer to the frame
  2834. lpMSRPCCO = (LPMSRPCCO) (lpFrame + RPCOffset);
  2835. // OK.. we have found a frame... is it the one we want?
  2836. if (lpMSRPCCO->PType == MSRPC_PDU_REQUEST )
  2837. {
  2838. // but do the presentation context ID's match??
  2839. // The following check should work, but doesn't!!!! So,
  2840. // we always execute this code!
  2841. // if (PConID == lpMSRPCCO->Request.PContId);
  2842. {
  2843. if (hPrevProtocol == hTCP)
  2844. {
  2845. DWORD Offset = GetProtocolStartOffset ( hFindFrame, "TCP" );
  2846. LPBYTE lpTCP = lpFrame + Offset;
  2847. if ( ( Offset == (DWORD)-1) || // if TCP doesn't exist
  2848. ( *(ULPDWORD) lpTCP != TCPFlippedPorts)) // or if the port doesn't match
  2849. continue;
  2850. }
  2851. else if (hPrevProtocol == hSMB)
  2852. {
  2853. DWORD Offset = GetProtocolStartOffset ( hFindFrame, "SMB" );
  2854. LPBYTE lpSMB = lpFrame + Offset;
  2855. if ( ( Offset == (DWORD)-1) ||
  2856. ( SMBID != *(ULPDWORD)((LPBYTE)lpSMB+0x18) ) )
  2857. continue;
  2858. else
  2859. { // we have found our request. This makes the assumption
  2860. // that ONLY ONE FILE CAN BE TRANSACTED AT A TIME with
  2861. // pipe IPC!!!
  2862. SMBFID = *(WORD UNALIGNED *)((LPBYTE)lpSMB+0x3f);
  2863. }
  2864. }
  2865. else if ( (hPrevProtocol == hSPX) || (hPrevProtocol == hNBIPX) )
  2866. {
  2867. LPBYTE lpSPX;
  2868. DWORD Offset = (hPrevProtocol==hSPX)?GetProtocolStartOffset ( hFindFrame, "SPX" ):GetProtocolStartOffset ( hFindFrame, "NBIPX" );
  2869. lpSPX = lpFrame + Offset;
  2870. if ( ( Offset == (DWORD)-1) || // if SPX doesn't exist
  2871. ( *(ULPDWORD) ((LPBYTE)lpSPX+2) != SPXFlippedControl)) // or if the connection doesn't match
  2872. continue;
  2873. }
  2874. else if (hPrevProtocol == hVinesTL)
  2875. {
  2876. DWORD Offset = GetProtocolStartOffset ( hFindFrame, "Vines_TL" );
  2877. LPBYTE lpVineTL = lpFrame + Offset;
  2878. if ( ( Offset == (DWORD)-1) || // if Vines doesn't exist
  2879. ( *(ULPDWORD) lpVineTL != VinesTLFlippedPorts)) // or if the port doesn't match
  2880. continue;
  2881. }
  2882. //YES! we have OUR request frame... get the OpCode...
  2883. *lpOpNum = lpMSRPCCO->Request.OpNum;
  2884. break;
  2885. }
  2886. // else fall through and keep going...
  2887. }
  2888. // keep looking back
  2889. }
  2890. else
  2891. {
  2892. fKeepGoing = FALSE; // tell peice of logic that we failed..
  2893. break; // find frame failed... nothing to continue with.
  2894. }
  2895. }
  2896. // Decisions... Decisions... If we did not find the request frame, do we still
  2897. // attempt to find the BIND?? The next parser will not know how to format the
  2898. // frame...
  2899. // Resolution: Hand the next parser control anyway (ie, find the BIND frame)... but
  2900. // set the OpCode to be 0xFFFF and doc that behavior.
  2901. if ( !fKeepGoing)
  2902. *lpOpNum = (WORD)-1;
  2903. // restore the hFindFrame back to the original response frame
  2904. hFindFrame = hOrgFrame;
  2905. // Flip the src and dest to setup for finding the BIND frame...
  2906. if ((GetFrameSourceAddress(hOrgFrame,&Dst,ADDRESS_TYPE_FIND_HIGHEST,FALSE) == NMERR_SUCCESS) &&
  2907. (GetFrameDestAddress (hOrgFrame,&Src,ADDRESS_TYPE_FIND_HIGHEST,FALSE) == NMERR_SUCCESS))
  2908. fKeepGoing = TRUE;
  2909. else
  2910. return NULL;
  2911. // flip the tcp port too...
  2912. TCPPorts = TCPFlippedPorts;
  2913. VinesTLPorts = VinesTLFlippedPorts;
  2914. SPXControl= SPXFlippedControl;
  2915. }
  2916. // Look back and find the BIND frame with the same src and dst address
  2917. // and the same Presentation Context ID.
  2918. while (fKeepGoing)
  2919. {
  2920. hFindFrame = FindPreviousFrame( hFindFrame,
  2921. "MSRPC",
  2922. &Dst,
  2923. &Src,
  2924. &RPCOffset,
  2925. OrgFrameNumber,
  2926. StopFrameNumber);
  2927. if ( hFindFrame )
  2928. {
  2929. LPBYTE lpFrame = ParserTemporaryLockFrame (hFindFrame);
  2930. p_cont_elem_t UNALIGNED * pContElem;
  2931. // get a pointer to the frame
  2932. lpMSRPCCO = (LPMSRPCCO) (lpFrame + RPCOffset);
  2933. // OK.. we have found a frame... but this could be another request..
  2934. if ( (lpMSRPCCO->PType == MSRPC_PDU_BIND ) || (lpMSRPCCO->PType == MSRPC_PDU_ALTER_CONTEXT))
  2935. {
  2936. // YES! It is a BIND or an ALTER_CONTEXT.. Note that ALTER CONTEXT
  2937. // has the same structure size as a bind... so we can get the Context Element
  2938. // without caring which one it is.
  2939. pContElem = (p_cont_elem_t UNALIGNED * )&lpMSRPCCO->Bind.PContextElem[4];
  2940. // but do the presentation context ID's match??
  2941. if (PConID == pContElem->p_cont_id)
  2942. {
  2943. // OK that was the easy part. Now, verify that the session concept was
  2944. // maintained on the protocol in question.
  2945. // Note that we do this LATE because it is expensive...
  2946. if (hPrevProtocol == hTCP)
  2947. {
  2948. DWORD Offset = GetProtocolStartOffset ( hFindFrame, "TCP" );
  2949. LPBYTE lpTCP = lpFrame + Offset;
  2950. if ( ( Offset == (DWORD)-1) || // if TCP doesn't exist
  2951. ( *(ULPDWORD) lpTCP != TCPPorts)) // or if the port doesn't match
  2952. continue;
  2953. }
  2954. else if (hPrevProtocol == hSMB)
  2955. {
  2956. DWORD Offset = GetProtocolStartOffset ( hFindFrame, "SMB" );
  2957. LPBYTE lpSMB = lpFrame + Offset;
  2958. if ( ( Offset == (DWORD)-1) ||
  2959. ( SMBID != *(ULPDWORD)((LPBYTE)lpSMB+0x18) ) ||
  2960. ( SMBFID != *(UNALIGNED WORD *)((LPBYTE)lpSMB+0x3f) ) )
  2961. continue;
  2962. }
  2963. else if ( (hPrevProtocol == hSPX) || (hPrevProtocol == hNBIPX) )
  2964. {
  2965. LPBYTE lpSPX;
  2966. DWORD Offset = (hPrevProtocol==hSPX)?GetProtocolStartOffset ( hFindFrame, "SPX" ):GetProtocolStartOffset ( hFindFrame, "NBIPX" );
  2967. lpSPX = lpFrame + Offset;
  2968. if ( ( Offset == (DWORD)-1) || // if SPX doesn't exist
  2969. ( *(ULPDWORD) ((LPBYTE)lpSPX+2) != SPXControl)) // or if the connection doesn't match
  2970. continue;
  2971. }
  2972. else if (hPrevProtocol == hVinesTL)
  2973. {
  2974. DWORD Offset = GetProtocolStartOffset ( hFindFrame, "Vines_TL" );
  2975. LPBYTE lpVinesTL = lpFrame + Offset;
  2976. if ( ( Offset == (DWORD)-1) || // if Vines doesn't exist
  2977. ( *(ULPDWORD) lpVinesTL != VinesTLPorts)) // or if the port doesn't match
  2978. continue;
  2979. }
  2980. hTemp = FindParserInTable ( (ULPDWORD)&pContElem->abstract_syntax.if_uuid);
  2981. *lpBindVersion = pContElem->abstract_syntax.if_version;
  2982. #ifdef DEBUGBIND
  2983. {
  2984. dprintf ( "The BIND frame for frame %d is %d\n", OrgFrameNumber ,GetFrameNumber ( hFindFrame));
  2985. }
  2986. #endif
  2987. AddEntryToBindTable ( OrgFrameNumber, hFindFrame);
  2988. return hTemp;
  2989. }
  2990. // else fall through and keep going...
  2991. }
  2992. // keep looking back
  2993. }
  2994. else
  2995. break; // find frame failed... nothing to continue with.
  2996. }
  2997. return NULL;
  2998. }
  2999. // Given an IID in a BIND address, FindParserInTable will see if the IID exists in the
  3000. // global HandoffTable of IIDs and hProtocols.
  3001. HPROTOCOL FindParserInTable ( ULPDWORD lpDIID )
  3002. {
  3003. int i,j;
  3004. BOOL fGood;
  3005. // we have already bailed earlier if nIIDs is 0...
  3006. for ( i=0; i< nIIDs; i++ )
  3007. {
  3008. fGood = TRUE;
  3009. for ( j=0;j<4;j++)
  3010. if ( lpDIID[j] != HandoffTable[i].DwordRep[j] )
  3011. {
  3012. fGood = FALSE;
  3013. break;
  3014. }
  3015. if ( fGood )
  3016. return HandoffTable[i].hNext;
  3017. }
  3018. return NULL;
  3019. }
  3020. // FindDGRequestFrame takes a datagram RPC response and finds the request.
  3021. // Unfortunately, the response OPNUM and GUID is garbage... therefore, we
  3022. // have to find the request to get the real ones.
  3023. LPBYTE FindDGRequestFrame(HFRAME hOrgFrame,
  3024. DWORD UNALIGNED * lpOrigAID,
  3025. DWORD OrigSeqNum )
  3026. {
  3027. HFRAME hFindFrame = hOrgFrame;
  3028. ADDRESS FrameDst, FrameSrc, HighestDst, HighestSrc;
  3029. BOOL fKeepGoing=TRUE;
  3030. WORD RPCOffset;
  3031. DWORD OrgFrameNumber = GetFrameNumber ( hOrgFrame);
  3032. DWORD StopFrameNumber = OrgFrameNumber>999?(OrgFrameNumber - 1000):0;
  3033. DWORD FrameType;
  3034. LPMSRPCCL lpMSRPCCL;
  3035. BOOL fGood;
  3036. int j;
  3037. DWORD UNALIGNED * lpAID;
  3038. FrameType = MacTypeToAddressType( GetFrameMacType( hOrgFrame ));
  3039. // find this frames source and dest address as well as highest level addr
  3040. if ((GetFrameSourceAddress(hOrgFrame,&FrameSrc,FrameType,FALSE) != NMERR_SUCCESS) ||
  3041. (GetFrameDestAddress (hOrgFrame,&FrameDst,FrameType,FALSE) != NMERR_SUCCESS) ||
  3042. (GetFrameSourceAddress(hOrgFrame,&HighestSrc,ADDRESS_TYPE_FIND_HIGHEST,FALSE) != NMERR_SUCCESS) ||
  3043. (GetFrameDestAddress (hOrgFrame,&HighestDst,ADDRESS_TYPE_FIND_HIGHEST,FALSE) != NMERR_SUCCESS))
  3044. {
  3045. return NULL;
  3046. }
  3047. do
  3048. {
  3049. // note the flipped src and dst address...
  3050. hFindFrame = FindPreviousFrame( hFindFrame,
  3051. "MSRPC",
  3052. &FrameSrc,
  3053. &FrameDst,
  3054. &RPCOffset,
  3055. OrgFrameNumber,
  3056. StopFrameNumber);
  3057. if ( hFindFrame )
  3058. {
  3059. if ( HighestSrc.Type == HighestDst.Type ) {
  3060. LPBYTE lpFrame = ParserTemporaryLockFrame (hFindFrame);
  3061. // get a pointer to the frame
  3062. lpMSRPCCL = (LPMSRPCCL) (lpFrame + RPCOffset);
  3063. // OK.. we have found a frame... is it the one we want?
  3064. if (lpMSRPCCL->PType == MSRPC_PDU_REQUEST ) {
  3065. // but do the activity ID's and sequence numbers match??
  3066. fGood = TRUE;
  3067. lpAID = (DWORD UNALIGNED * )lpMSRPCCL->ActivityId;
  3068. // compare as an array of dwords...
  3069. for ( j=0;j<3;j++) {
  3070. if ( *lpAID++ != lpOrigAID[j] ) {
  3071. fGood = FALSE;
  3072. break;
  3073. }
  3074. }
  3075. if (( fGood ) &&(lpMSRPCCL->SeqNum == OrigSeqNum))
  3076. return (LPBYTE)lpMSRPCCL;
  3077. }
  3078. }
  3079. }
  3080. } while ( hFindFrame );
  3081. return NULL;
  3082. }
  3083. int FormatUUID ( LPSTR pIn, LPBYTE pIID)
  3084. {
  3085. wsprintf ( pIn, "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
  3086. pIID[3],pIID[2],pIID[1],pIID[0],
  3087. pIID[5],pIID[4],
  3088. pIID[7],pIID[6],
  3089. pIID[8],pIID[9],
  3090. pIID[10],pIID[11],pIID[12],pIID[13],pIID[14],pIID[15],pIID[16] );
  3091. return ( strlen(pIn) );
  3092. }
  3093. VOID WINAPIV FmtIID( LPPROPERTYINST lpPropertyInst )
  3094. {
  3095. int Length;
  3096. LPBYTE lpData = (LPBYTE)(lpPropertyInst->DataLength!=(WORD)-1)?lpPropertyInst->lpData:lpPropertyInst->lpPropertyInstEx->Byte;
  3097. Length = wsprintf ( lpPropertyInst->szPropertyText, "%s = ",lpPropertyInst->lpPropertyInfo->Label);
  3098. FormatUUID ( &lpPropertyInst->szPropertyText[Length],lpData );
  3099. }
  3100. VOID AttachPContElem ( p_cont_elem_t UNALIGNED * pContElem, BYTE nContext, HFRAME hFrame, DWORD Level, BOOL fLittleEndian)
  3101. {
  3102. BYTE nTransfer;
  3103. INT i;
  3104. AttachProperty( fLittleEndian,
  3105. hFrame,
  3106. MSRPC_Prop[MSRPC_PRES_CONTEXT_ID].hProperty,
  3107. sizeof( WORD ),
  3108. &pContElem->p_cont_id,
  3109. 0,Level,0); // HELPID, Level, Errorflag
  3110. AttachPropertyInstance( hFrame,
  3111. MSRPC_Prop[MSRPC_NUM_TRANSFER_SYNTAX].hProperty,
  3112. sizeof( BYTE ),
  3113. &pContElem->n_transfer_syn,
  3114. 0,Level,0); // HELPID, Level, Errorflag
  3115. AttachPropertyInstance( hFrame,
  3116. MSRPC_Prop[MSRPC_ABSTRACT_IF_UUID].hProperty,
  3117. 16,
  3118. &pContElem->abstract_syntax.if_uuid,
  3119. 0,Level,0); // HELPID, Level, Errorflag
  3120. AttachProperty( fLittleEndian,
  3121. hFrame,
  3122. MSRPC_Prop[MSRPC_ABSTRACT_IF_VERSION].hProperty,
  3123. sizeof( DWORD ),
  3124. &pContElem->abstract_syntax.if_version,
  3125. 0,Level,0); // HELPID, Level, Errorflag
  3126. nTransfer = pContElem->n_transfer_syn;
  3127. i=0;
  3128. while ((nTransfer--)>0)
  3129. {
  3130. AttachPropertyInstance( hFrame,
  3131. MSRPC_Prop[MSRPC_TRANSFER_IF_UUID].hProperty,
  3132. 16,
  3133. &pContElem->transfer_syntaxes[i].if_uuid,
  3134. 0,Level,0); // HELPID, Level, Errorflag
  3135. AttachProperty( fLittleEndian,
  3136. hFrame,
  3137. MSRPC_Prop[MSRPC_TRANSFER_IF_VERSION].hProperty,
  3138. sizeof( DWORD ),
  3139. &pContElem->transfer_syntaxes[i].if_version,
  3140. 0,Level,0); // HELPID, Level, Errorflag
  3141. i++;
  3142. }
  3143. }
  3144. //////////////////////////////////////////////////////////////////////////////
  3145. // AddEntryToBindTable Given that we have found a frame/Bindframe pair,
  3146. // put it into the table (sorted) for reference later.
  3147. //////////////////////////////////////////////////////////////////////////////
  3148. VOID AddEntryToBindTable ( DWORD OrgFrameNumber, HFRAME hBindFrame )
  3149. {
  3150. LPBINDENTRY lpBindEntry;
  3151. BINDENTRY NewBindEntry;
  3152. LPBINDENTRY lpNBE = &NewBindEntry;
  3153. // normalize the numbers... the user sees 1 relative output.
  3154. OrgFrameNumber++;
  3155. #ifdef DEBUG
  3156. if ( lpBindTable->State == UNINITED)
  3157. {
  3158. dprintf ("AddEntryToBindTable with UNINITED Bind Table");
  3159. BreakPoint();
  3160. return;
  3161. }
  3162. #endif
  3163. if ( lpBindTable->State == FULL)
  3164. {
  3165. #ifdef DEBUG
  3166. dprintf ( "returning from AddEntryToBindTable with no work (%d, %d)... FULL!",
  3167. OrgFrameNumber,
  3168. GetFrameNumber(hBindFrame));
  3169. #endif
  3170. return;
  3171. }
  3172. // We MIGHT already have the frame in the table... The could be the second time that recognize was
  3173. // called on this frame... Verify that the number isn't already in the table first.
  3174. // dprintf ("OrgFrameNumber is %d\n", OrgFrameNumber);
  3175. if ( (lpBindEntry = GetBindEntry ( OrgFrameNumber )) != NULL )
  3176. {
  3177. // What if the user edits the frame and modifies the session definition of
  3178. // the protocol below us?? We would have a NEW bind frame... and would
  3179. // need to replace the current one.
  3180. lpBindEntry->hBindFrame = hBindFrame;
  3181. return;
  3182. }
  3183. // add the new entry SORTED!!!
  3184. if ((lpBindTable->nEntries+1) > lpBindTable->nAllocated )
  3185. {
  3186. LPBINDTABLE lpTemp;
  3187. lpBindTable->nAllocated += 100;
  3188. lpTemp = CCHeapReAlloc (lpBindTable,
  3189. BINDTABLEHEADERSIZE + lpBindTable->nAllocated * sizeof (BINDENTRY),
  3190. FALSE ); // don't zero init...
  3191. if (lpTemp == NULL)
  3192. {
  3193. // We have a working table, but we cannot get MORE memory.
  3194. // Work with what we have
  3195. lpBindTable->nAllocated-=100;
  3196. lpBindTable->State = FULL;
  3197. #ifdef DEBUG
  3198. dprintf ("AddEntryToBindTable: cannot alloc more entries!!");
  3199. #endif
  3200. return;
  3201. }
  3202. else
  3203. {
  3204. lpBindTable = lpTemp;
  3205. SetCCInstPtr ( lpBindTable );
  3206. }
  3207. }
  3208. NewBindEntry.nFrame = OrgFrameNumber;
  3209. NewBindEntry.hBindFrame = hBindFrame;
  3210. if (bInsert( &NewBindEntry, // new record
  3211. lpBindTable->BindEntry, // base
  3212. lpBindTable->nEntries, // count
  3213. sizeof(BINDENTRY), // size
  3214. FALSE, // don't allow duplicates
  3215. CompareBindEntry) == FALSE) // compare routine
  3216. {
  3217. // huh??
  3218. #ifdef DEBUG
  3219. dprintf ("bInsert has FAILED??!?");
  3220. DebugBreak();
  3221. #endif
  3222. }
  3223. else
  3224. lpBindTable->nEntries++;
  3225. /*
  3226. if (( lpBindTable->nEntries == 0 ) || // we are first
  3227. ( lpBindTable->BindEntry[lpBindTable->nEntries-1].nFrame < OrgFrameNumber)) // or insert at end
  3228. {
  3229. lpBindTable->nEntries++;
  3230. lpBindTable->BindEntry[lpBindTable->nEntries-1].nFrame = OrgFrameNumber;
  3231. lpBindTable->BindEntry[lpBindTable->nEntries-1].hBindFrame = hBindFrame;
  3232. }
  3233. else
  3234. { // do it the hard way
  3235. DWORD InsertAt = FindInsertionPoint ( OrgFrameNumber ); // get the array location to insert in front of
  3236. MoveMemory (&lpBindTable->BindEntry[InsertAt+1], // dest
  3237. &lpBindTable->BindEntry[InsertAt],
  3238. sizeof(BINDENTRY) * (lpBindTable->nEntries-InsertAt-1) );
  3239. lpBindTable->BindEntry[InsertAt].nFrame = OrgFrameNumber;
  3240. lpBindTable->BindEntry[InsertAt].hBindFrame = hBindFrame;
  3241. lpBindTable->nEntries++;
  3242. }
  3243. */
  3244. }
  3245. //////////////////////////////////////////////////////////////////////////////
  3246. // GetBindEntry attempts to find a frame/Bindframe pair for the given nFrame
  3247. //////////////////////////////////////////////////////////////////////////////
  3248. LPBINDENTRY GetBindEntry ( DWORD nFrame )
  3249. {
  3250. BINDENTRY BE;
  3251. BE.nFrame = nFrame;
  3252. return bsearch( &BE, // key to search for (pointer to pointer to addressinfo)
  3253. &lpBindTable->BindEntry, // base
  3254. lpBindTable->nEntries, // size
  3255. sizeof(BINDENTRY), // width
  3256. CompareBindEntry); // compare routine
  3257. }
  3258. /*
  3259. //////////////////////////////////////////////////////////////////////////////
  3260. // FindInsertionPoint is around because bsearch doesn't tell you WHERE to
  3261. // insert the entry in the sorted list...
  3262. //////////////////////////////////////////////////////////////////////////////
  3263. DWORD FindInsertionPoint ( DWORD FindFrameNumber )
  3264. {
  3265. DWORD i;
  3266. //NOTE that we know the frame is NOT going to be the first or the last frame...
  3267. for (i=0; i < lpBindTable->nEntries; i++)
  3268. if ( lpBindTable->BindEntry[i].nFrame > FindFrameNumber )
  3269. return i;
  3270. }
  3271. */
  3272. //////////////////////////////////////////////////////////////////////////////
  3273. // AttachIIDFromBindFrame
  3274. //////////////////////////////////////////////////////////////////////////////
  3275. VOID AttachIIDFromBindFrame ( HFRAME hFrame, HFRAME hBindFrame, DWORD Level )
  3276. {
  3277. LPBYTE lpFrame = ParserTemporaryLockFrame (hBindFrame);
  3278. DWORD nRPC = GetProtocolStartOffset ( hBindFrame, "MSRPC" );
  3279. LPMSRPCCO lpMSRPCCO = (LPMSRPCCO)(lpFrame + nRPC);
  3280. p_cont_elem_t UNALIGNED * pContElem= (p_cont_elem_t UNALIGNED * )&lpMSRPCCO->Bind.PContextElem[4];
  3281. AttachPropertyInstanceEx( hFrame,
  3282. MSRPC_Prop[MSRPC_ABSTRACT_IF_UUID].hProperty,
  3283. 0,
  3284. NULL,
  3285. 16,
  3286. &pContElem->abstract_syntax.if_uuid,
  3287. 0,Level,0); // HELPID, Level, Errorflag
  3288. }
  3289. //////////////////////////////////////////////////////////////////////////////
  3290. // FUNCTION: CompareAddressInfoByAddress
  3291. //
  3292. // Used to do bsearch binary searches through the table
  3293. //
  3294. // Modification History:
  3295. // Tom Laird-McConnell 05/94 created
  3296. //////////////////////////////////////////////////////////////////////////////
  3297. int _cdecl CompareBindEntry(const void *lpPtr1, const void *lpPtr2 )
  3298. {
  3299. LPBINDENTRY lpBind1= (LPBINDENTRY)lpPtr1;
  3300. LPBINDENTRY lpBind2= (LPBINDENTRY)lpPtr2;
  3301. return (lpBind1->nFrame - lpBind2->nFrame);
  3302. }