in client.c [46:85]
void cl_change_working_directory(HANDLE pipe, const char* target,
uint32_t pid)
{
assert(INVALID_HANDLE_VALUE != pipe);
wchar_t directory[MAX_PATH_LENGTH] = { 0 };
wchar_t* updated_working_directory = NULL;
packet_t* packet = NULL;
packet_t* result = NULL;
h_get_wide_user_string(L"Enter new working directory: ", directory, MAX_PATH_LENGTH);
comm_send_command(pipe, CHANGE_WORKING_DIRECTORY, (uint8_t*)directory,
(uint32_t)((wcslen(directory) + 1) * sizeof(wchar_t)),
RC4_KEY, RC4_KEY_LENGTH);
packet = comm_receive_packet(pipe);
if (!packet->_0.result)
{
printf("Change working directory command failed\n");
cl_print_packet(packet);
goto end;
}
updated_working_directory = (wchar_t*)comm_receive_decrypt_data(
pipe, packet->_1.buffer_size, RC4_KEY, RC4_KEY_LENGTH);
wprintf(L"New working directory: %.*ls\n", packet->_1.buffer_size / 2, updated_working_directory);
result = comm_receive_packet(pipe);
cl_print_packet(result);
end:
if (packet)
free(packet);
if (result)
free(result);
if (updated_working_directory)
free(updated_working_directory);
}