Use sysinternals procdump to dump process memory on a specific process. If only the pid is specified, the default
        behavior is to use the version of ProcDump supplied with cbinterface's pip3 installer.

        :requires: SysInternals ProcDump v9.0 included with cbinterface==1.1.0
        :arguments pid: Process id to dump memory for
        :arguments working_dir: Specify a directoy on the windows sensor to work out of. Default: C:\\Windows\\CarbonBlack\\
        :arguments path_to_procdump: Specify the path to a version of procdump you want to use. Default is included copy

def dump_process_memory(self, pid, working_dir="c:\\windows\\carbonblack\\", path_to_procdump=None):
        """Use sysinternals procdump to dump process memory on a specific process. If only the pid is specified, the default
        behavior is to use the version of ProcDump supplied with cbinterface's pip3 installer.

        :requires: SysInternals ProcDump v9.0 included with cbinterface==1.1.0
        :arguments pid: Process id to dump memory for
        :arguments working_dir: Specify a directoy on the windows sensor to work out of. Default: C:\\Windows\\CarbonBlack\\
        :arguments path_to_procdump: Specify the path to a version of procdump you want to use. Default is included copy
        """

        self.go_live()

        print("~ dumping memory where pid={} for {}".format(pid, self.sensor.computer_name))
        # need to make sure procdump.exe is on the sensor
        procdump_host_path = None
        dir_output = self.lr_session.list_directory(working_dir)
        for dir_item in dir_output:
            if dir_item['filename'] == 'procdump.exe':
                logging.info("procdump.exe already on host.")
                procdump_host_path = working_dir + "procdump.exe"
                break
        else:
            logging.info("Dropping procdump.exe on host.")

        if not procdump_host_path:
            if not os.path.exists(path_to_procdump):
                HOME_DIR = os.path.abspath(os.path.join(os.path.realpath(__file__),'..','..'))
                path_to_procdump = os.path.join(HOME_DIR, 'lr_tools', 'procdump.exe')
                if not os.path.exists(path_to_procdump):
                    logging.warn("{} not found".format(path_to_procdump))
                    return False

            print("~ dropping procdump.exe on host.")
            filedata = None
            with open(path_to_procdump, 'rb') as f:
                filedata = f.read()
            try:
                self.lr_session.create_directory(working_dir)
            except LiveResponseError:
                logging.debug("working directory already exists")
            self.lr_session.put_file(filedata, working_dir + "procdump.exe")
            procdump_host_path = working_dir + "procdump.exe"

        print("~ Executing procdump..")
        command_str = procdump_host_path + " -accepteula -ma " + str(pid)
        result = self.lr_session.create_process(command_str)
        time.sleep(1)
        print("+ procdump output:\n-------------------------")
        result = result.decode('utf-8')
        print(result + "\n-------------------------")

        # cut off the carriage return and line feed from filename 
        dumpfile_name = result[result.rfind('\\')+1:result.rfind('.dmp')+4]
        while True:
            if 'procdump.exe' not in str(self.lr_session.list_processes()):
                break
            else:
                time.sleep(1)
        # download dumpfile to localdir
        self.getFile_with_timeout(working_dir + dumpfile_name)