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.

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