@@ -9,11 +9,27 @@ module Epm
99 # Operation numbers
1010 EPT_MAP = 0x0003
1111
12+ # MS-RPCE specific error codes
13+ STATUS_NO_ELEMENTS = 0x16C9A0D6
14+
1215 require 'ruby_smb/dcerpc/epm/epm_twrt'
1316 require 'ruby_smb/dcerpc/epm/epm_ept_map_request'
1417 require 'ruby_smb/dcerpc/epm/epm_ept_map_response'
1518
16- def ept_map ( uuid :, maj_ver :, min_ver :, max_towers : 1 , protocol : :ncacn_ip_tcp )
19+ # Map a service to a connection end point.
20+ #
21+ # @param uuid [String] The object UUID of the interface.
22+ # @param maj_ver [Integer] The major version number of the interface.
23+ # @param min_ver [Integer] The minor version number of the interface.
24+ # @param max_towers [Integer] The maximum number of results to obtain.
25+ # @param protocol [Symbol] The protocol of endpoint to obtain.
26+ #
27+ # @return [Array<Hash<Symbol,>>] The mapped endpoints. The hash keys will
28+ # depend on the protocol that was selected but an endpoint key will
29+ # always be present.
30+ # @raise [NotImplementedError] Raised if the *protocol* argument is not
31+ # supported.
32+ def ept_map ( uuid :, maj_ver :, min_ver : 0 , max_towers : 1 , protocol : :ncacn_ip_tcp )
1733 interface_identifier = {
1834 interface : uuid ,
1935 major_version : maj_ver ,
@@ -92,7 +108,11 @@ def ept_map(uuid:, maj_ver:, min_ver:, max_towers: 1, protocol: :ncacn_ip_tcp)
92108 raise RubySMB ::Dcerpc ::Error ::InvalidPacket , 'Error reading EptMapResponse'
93109 end
94110
95- unless ept_map_response . error_status == WindowsError ::NTStatus ::STATUS_SUCCESS
111+ if ept_map_response . error_status == STATUS_NO_ELEMENTS
112+ raise RubySMB ::Dcerpc ::Error ::EpmError ,
113+ "Error returned with ept_map: " \
114+ "(0x16c9a0d6) STATUS_NO_ELEMENTS: There are no elements that satisfy the specified search criteria."
115+ elsif ept_map_response . error_status != WindowsError ::NTStatus ::STATUS_SUCCESS
96116 raise RubySMB ::Dcerpc ::Error ::EpmError ,
97117 "Error returned with ept_map: " \
98118 "#{ WindowsError ::NTStatus . find_by_retval ( ept_map_response . error_status . value ) . join ( ',' ) } "
0 commit comments