@flow.StateHandler(next_state="ProcessListDirectory")
  def ListDeviceDirectories(self, responses):
    if not responses.success:
      raise flow.FlowError("Unable to query Volume Shadow Copy information.")

    for response in responses:
      device_object = response.GetItem("DeviceObject", "")
      global_root = r"\\?\GLOBALROOT\Device"

      if device_object.startswith(global_root):
        # The VSC device path is returned as \\?\GLOBALROOT\Device\
        # HarddiskVolumeShadowCopy1 and need to pass it as
        #  \\.\HarddiskVolumeShadowCopy1 to the ListDirectory flow
        device_object = r"\\." + device_object[len(global_root):]

        path_spec = rdf_paths.PathSpec(
            path=device_object,
            pathtype=rdf_paths.PathSpec.PathType.OS)

        path_spec.Append(path="/", pathtype=rdf_paths.PathSpec.PathType.TSK)

        self.Log("Listing Volume Shadow Copy device: %s.", device_object)
        self.CallClient("ListDirectory", pathspec=path_spec,
                        next_state="ProcessListDirectory")

        self.state.raw_device = aff4.AFF4Object.VFSGRRClient.PathspecToURN(
            path_spec, self.client_id).Dirname()

        self.state.shadows.append(aff4.AFF4Object.VFSGRRClient.PathspecToURN(
            path_spec, self.client_id))
dataset/ETHPy150Open google/grr/grr/lib/flows/general/windows_vsc.py/ListVolumeShadowCopies.ListDeviceDirectories/original