MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / sendFindFirst

Method sendFindFirst

pager_lib/smb/base.py:2183–2207  ·  view source on GitHub ↗
(tid, support_dfs=False)

Source from the content-addressed store, hash-verified

2181 results = [ ]
2182
2183 def sendFindFirst(tid, support_dfs=False):
2184 setup_bytes = struct.pack('<H', 0x0001) # TRANS2_FIND_FIRST2 sub-command. See [MS-CIFS]: 2.2.6.2.1
2185 params_bytes = \
2186 struct.pack('<HHHHI',
2187 search & 0xFFFF, # SearchAttributes (need to restrict the values due to introduction of SMB_FILE_ATTRIBUTE_INCL_NORMAL)
2188 100, # SearchCount
2189 0x0006, # Flags: SMB_FIND_CLOSE_AT_EOS | SMB_FIND_RETURN_RESUME_KEYS
2190 0x0104, # InfoLevel: SMB_FIND_FILE_BOTH_DIRECTORY_INFO
2191 0x0000) # SearchStorageType (seems to be ignored by Windows)
2192 if support_dfs:
2193 params_bytes += ("\\" + self.remote_name + "\\" + service_name + path + pattern + '\0').encode('UTF-16LE')
2194 else:
2195 params_bytes += (path + pattern + '\0').encode('UTF-16LE')
2196
2197 m = SMBMessage(ComTransaction2Request(max_params_count = 10,
2198 max_data_count = 16644,
2199 max_setup_count = 0,
2200 params_bytes = params_bytes,
2201 setup_bytes = setup_bytes))
2202 m.tid = tid
2203 if support_dfs:
2204 m.flags2 |= SMB_FLAGS2_DFS
2205 self._sendSMBMessage(m)
2206 self.pending_requests[m.mid] = _PendingRequest(m.mid, expiry_time, findFirstCB, errback)
2207 self._pushToArray(messages_history, m)
2208
2209 def decodeFindStruct(data_bytes):
2210 # SMB_FIND_FILE_BOTH_DIRECTORY_INFO structure. See [MS-CIFS]: 2.2.8.1.7 and [MS-SMB]: 2.2.8.1.1

Callers

nothing calls this directly

Calls 5

_pushToArrayMethod · 0.95
SMBMessageClass · 0.85
_PendingRequestClass · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected