Xeno-rat
Loading...
Searching...
No Matches
xeno_rat_server.Forms.File_manager Class Reference
Inheritance diagram for xeno_rat_server.Forms.File_manager:
Collaboration diagram for xeno_rat_server.Forms.File_manager:

Public Member Functions

 File_manager (Node _client)
 
async Task InitializeAsync ()
 Initializes the object asynchronously by creating a FileViewer, sending type, and updating the list view.
 
void TempOnDisconnect (Node node)
 Handles the disconnection of a node.
 
async Task FileUpload (string filepath, string savepath)
 Uploads a file from the specified filepath to the given savepath using the asynchronous protocol.
 
async Task FileDownload (string path, string savepath)
 Downloads a file from the specified path and saves it to the provided save path.
 
async Task StartFile (string path)
 Starts a file operation using the specified path.
 
async Task DeleteFile (string path)
 Deletes a file at the specified path.
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases the unmanaged resources used by the component and optionally releases the managed resources.
 

Private Member Functions

async Task UpdateListViewNonInvoke (string path)
 Updates the list view without invoking the UI thread, using the provided file path.
 
async Task< NodeCreateSubSubNode (Node client)
 Creates a sub-sub node for the given client node and returns the created node.
 
void listView1_SelectedIndexChanged (object sender, EventArgs e)
 Occurs when the selected index of the ListView control changes.
 
async void listView1_MouseDoubleClick (object sender, MouseEventArgs e)
 Handles the event when the user double-clicks on an item in the list view.
 
async void textBox1_KeyDown (object sender, KeyEventArgs e)
 Handles the KeyDown event for textBox1 and updates the ListView if the Enter key is pressed.
 
void listView2_SelectedIndexChanged (object sender, EventArgs e)
 Occurs when the selected index of the ListView2 control changes.
 
void DownloadMenuItem_Click (object sender, EventArgs e)
 Handles the click event of the download menu item by initiating the file download process.
 
async void OpenMenuItem_Click (object sender, EventArgs e)
 Opens the file associated with the selected menu item.
 
async void DeleteMenuItem_Click (object sender, EventArgs e)
 Deletes the file associated with the selected menu item and updates the list view.
 
void listView1_MouseClick (object sender, MouseEventArgs e)
 Handles the mouse click event on the listView1 control, and displays a context menu with options based on the selected item.
 
async void button1_Click (object sender, EventArgs e)
 Asynchronously updates the list view with the contents of the specified directory without requiring an invoke.
 
void button2_Click (object sender, EventArgs e)
 Handles the click event of button2. Launches a new thread to open a file dialog, select a file, and upload it to a specified location.
 
void InitializeComponent ()
 Initializes the components of the form, including tab controls, buttons, text boxes, labels, and list views.
 

Private Attributes

Node client
 
FileView FileViewer
 
string currentDirectory = ""
 
System.ComponentModel.IContainer components = null
 Required designer variable.
 
System.Windows.Forms.TabControl tabControl1
 
System.Windows.Forms.TabPage tabPage1
 
System.Windows.Forms.ListView listView1
 
System.Windows.Forms.TabPage tabPage2
 
System.Windows.Forms.ColumnHeader columnHeader1
 
System.Windows.Forms.ColumnHeader columnHeader2
 
System.Windows.Forms.TextBox textBox1
 
System.Windows.Forms.Label label1
 
System.Windows.Forms.ListView listView2
 
System.Windows.Forms.ColumnHeader columnHeader3
 
System.Windows.Forms.ColumnHeader columnHeader4
 
System.Windows.Forms.ColumnHeader columnHeader5
 
System.Windows.Forms.ColumnHeader columnHeader6
 
System.Windows.Forms.Button button2
 
System.Windows.Forms.Button button1
 

Constructor & Destructor Documentation

◆ File_manager()

xeno_rat_server.Forms.File_manager.File_manager ( Node _client)
inline
Here is the call graph for this function:

Member Function Documentation

◆ button1_Click()

async void xeno_rat_server.Forms.File_manager.button1_Click ( object sender,
EventArgs e )
inlineprivate

Asynchronously updates the list view with the contents of the specified directory without requiring an invoke.

Parameters
currentDirectoryThe directory whose contents will be displayed in the list view.

This method updates the list view with the contents of the specified directory without requiring an invoke, allowing for asynchronous execution.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ button2_Click()

void xeno_rat_server.Forms.File_manager.button2_Click ( object sender,
EventArgs e )
inlineprivate

Handles the click event of button2. Launches a new thread to open a file dialog, select a file, and upload it to a specified location.

Parameters
senderThe object that raised the event.
eThe event data.
Exceptions
System.InvalidOperationExceptionThrown when the thread is in an invalid state for the requested operation.

This method creates a new thread to handle the file selection and upload process. It sets the thread's apartment state to STA (Single-Threaded Apartment) to ensure proper interaction with the UI components. The method uses an OpenFileDialog to allow the user to select a file. Once a file is selected, it retrieves the file path, extracts the file name, and combines it with the current directory to create a save path. The method then calls the FileUpload method to upload the selected file to the specified location.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateSubSubNode()

async Task< Node > xeno_rat_server.Forms.File_manager.CreateSubSubNode ( Node client)
inlineprivate

Creates a sub-sub node for the given client node and returns the created node.

Parameters
clientThe client node for which the sub-sub node is to be created.
Returns
The created sub-sub node if successful; otherwise, null.
Exceptions
ExceptionThrown when an error occurs during the creation of the sub-sub node.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteFile()

async Task xeno_rat_server.Forms.File_manager.DeleteFile ( string path)
inline

Deletes a file at the specified path.

Parameters
pathThe path of the file to be deleted.
Exceptions
ExceptionThrown when the file deletion process fails.
Returns
No return value.

This method sends a delete request to the server for the file located at the specified path . If the deletion process fails, an exception is thrown.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeleteMenuItem_Click()

async void xeno_rat_server.Forms.File_manager.DeleteMenuItem_Click ( object sender,
EventArgs e )
inlineprivate

Deletes the file associated with the selected menu item and updates the list view.

Parameters
senderThe object that raised the event.
eThe event data.
Exceptions
InvalidCastExceptionThrown when the sender or tag is not of the expected type.
Returns
An asynchronous task representing the operation.

This method deletes the file specified by the filePath and then updates the list view to reflect the changes. The file path is obtained from the tag of the selected item in the list view. The method uses asynchronous operations to delete the file and update the list view without blocking the UI thread.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispose()

override void xeno_rat_server.Forms.File_manager.Dispose ( bool disposing)
inlineprotected

Releases the unmanaged resources used by the component and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method releases the unmanaged resources used by the component and optionally releases the managed resources. If disposing is true, this method disposes of the managed resources.

◆ DownloadMenuItem_Click()

void xeno_rat_server.Forms.File_manager.DownloadMenuItem_Click ( object sender,
EventArgs e )
inlineprivate

Handles the click event of the download menu item by initiating the file download process.

Parameters
senderThe object that raised the event.
eThe event arguments.

This method retrieves the necessary information from the selected item in the ListView, creates and configures a SaveFileDialog in a new STA thread, and initiates the file download process by calling the FileDownload method with the selected file's path and the chosen save path.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileDownload()

async Task xeno_rat_server.Forms.File_manager.FileDownload ( string path,
string savepath )
inline

Downloads a file from the specified path and saves it to the provided save path.

Parameters
pathThe path of the file to be downloaded.
savepathThe path where the downloaded file will be saved.
Exceptions
ExceptionThrown when the download start fails or if there is an error accessing the file or if the file does not exist or if there is an error with file read or writing to the save file path.

This method initiates a download of the file from the specified path and saves it to the savepath . It updates the progress of the download in a list view, showing the percentage of completion. If the download fails, it displays an appropriate message in the list view.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileUpload()

async Task xeno_rat_server.Forms.File_manager.FileUpload ( string filepath,
string savepath )
inline

Uploads a file from the specified filepath to the given savepath using the asynchronous protocol.

Parameters
filepathThe path of the file to be uploaded.
savepathThe path where the file will be saved on the server.
Exceptions
ExceptionThrown when the upload start fails or when there is an error reading the file.

This method initiates the upload process by creating a sub-sub node and sending the file data in blocks to the server using asynchronous communication. It updates the progress of the upload in a list view and handles various error scenarios such as failed connections and file write errors.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeAsync()

async Task xeno_rat_server.Forms.File_manager.InitializeAsync ( )
inline

Initializes the object asynchronously by creating a FileViewer, sending type, and updating the list view.

Returns
A task representing the asynchronous operation.

This method initializes the FileViewer by creating a new instance using the result of the asynchronous operation from CreateSubSubNode method. It then sends the type using the FileViewer.SendType method and updates the list view using the UpdateListViewNonInvoke method with the current directory.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeComponent()

void xeno_rat_server.Forms.File_manager.InitializeComponent ( )
inlineprivate

Initializes the components of the form, including tab controls, buttons, text boxes, labels, and list views.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ listView1_MouseClick()

void xeno_rat_server.Forms.File_manager.listView1_MouseClick ( object sender,
MouseEventArgs e )
inlineprivate

Handles the mouse click event on the listView1 control, and displays a context menu with options based on the selected item.

Parameters
senderThe object that raised the event.
eA MouseEventArgs that contains the event data.

This method checks if the right mouse button is clicked, and if so, it retrieves the selected item from the listView1 control. If the selected item is not null and its second subitem's text is "File", a context menu is created with options for Download, Open, and Delete. Each option is associated with a specific action and is added to the context menu. The context menu is then displayed at the position of the mouse click within the listView1 control.

Here is the call graph for this function:

◆ listView1_MouseDoubleClick()

async void xeno_rat_server.Forms.File_manager.listView1_MouseDoubleClick ( object sender,
MouseEventArgs e )
inlineprivate

Handles the event when the user double-clicks on an item in the list view.

Parameters
senderThe source of the event.
eA MouseEventArgs that contains the event data.

This method retrieves the path, directory, and type of the selected item in the list view. If the type is not a directory, the method returns. If the directory is "..", it constructs a new path based on the parent directory and updates the list view asynchronously. Otherwise, it constructs a new path based on the current directory and the selected directory, and updates the list view asynchronously.

Here is the call graph for this function:

◆ listView1_SelectedIndexChanged()

void xeno_rat_server.Forms.File_manager.listView1_SelectedIndexChanged ( object sender,
EventArgs e )
inlineprivate

Occurs when the selected index of the ListView control changes.

Parameters
senderThe source of the event.
eAn EventArgs that contains the event data.

◆ listView2_SelectedIndexChanged()

void xeno_rat_server.Forms.File_manager.listView2_SelectedIndexChanged ( object sender,
EventArgs e )
inlineprivate

Occurs when the selected index of the ListView2 control changes.

Parameters
senderThe source of the event.
eAn EventArgs that contains the event data.

◆ OpenMenuItem_Click()

async void xeno_rat_server.Forms.File_manager.OpenMenuItem_Click ( object sender,
EventArgs e )
inlineprivate

Opens the file associated with the selected menu item.

Parameters
senderThe object that raised the event.
eThe event arguments.

This method retrieves the file path associated with the selected menu item and asynchronously starts the file.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartFile()

async Task xeno_rat_server.Forms.File_manager.StartFile ( string path)
inline

Starts a file operation using the specified path.

Parameters
pathThe path of the file to be operated on.
Exceptions
ExceptionThrown when the file operation fails.
Returns
A task representing the asynchronous operation.

This method initiates a file operation using the provided path . It creates a sub-sub-node using the client and sends a byte array with a type value of 3 to the node. It then sends the UTF-8 encoded bytes of the path to the node and receives a response. If the received data is null, it displays a message box indicating that the file operation start has failed and disconnects the node. If the received data's first byte is 0, it displays a message box indicating that the file could not be opened or does not exist and disconnects the node.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TempOnDisconnect()

void xeno_rat_server.Forms.File_manager.TempOnDisconnect ( Node node)
inline

Handles the disconnection of a node.

Parameters
nodeThe node to be handled.

If the provided node is the client, it disconnects the FileViewer client if it exists. If the current instance is not disposed, it closes the form using the System.Windows.Forms.Control.Invoke(Delegate) method.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textBox1_KeyDown()

async void xeno_rat_server.Forms.File_manager.textBox1_KeyDown ( object sender,
KeyEventArgs e )
inlineprivate

Handles the KeyDown event for textBox1 and updates the ListView if the Enter key is pressed.

Parameters
senderThe object that raised the event.
eA KeyEventArgs that contains the event data.

This method asynchronously updates the ListView with the text from textBox1 if the Enter key is pressed. It sets the KeyEventArgs.Handled and KeyEventArgs.SuppressKeyPress properties to true after updating the ListView.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateListViewNonInvoke()

async Task xeno_rat_server.Forms.File_manager.UpdateListViewNonInvoke ( string path)
inlineprivate

Updates the list view without invoking the UI thread, using the provided file path.

Parameters
pathThe path of the directory to be updated in the list view.
Returns
A task representing the asynchronous operation.

This method asynchronously retrieves file information using the FileViewer.GetInfo method and updates the list view with the directories and files found at the specified path. If the file information retrieval is unsuccessful, a message box is displayed indicating the problem, and the method returns without further processing. The current directory is updated to the specified path, and the text box displaying the current directory is also updated. The list view is then updated by clearing its items, adding a parent directory item if the path is not empty, and adding items for each directory and file found in the retrieved file data. Finally, the list view update is completed by ending the update operation.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ button1

System.Windows.Forms.Button xeno_rat_server.Forms.File_manager.button1
private

◆ button2

System.Windows.Forms.Button xeno_rat_server.Forms.File_manager.button2
private

◆ client

Node xeno_rat_server.Forms.File_manager.client
private

◆ columnHeader1

System.Windows.Forms.ColumnHeader xeno_rat_server.Forms.File_manager.columnHeader1
private

◆ columnHeader2

System.Windows.Forms.ColumnHeader xeno_rat_server.Forms.File_manager.columnHeader2
private

◆ columnHeader3

System.Windows.Forms.ColumnHeader xeno_rat_server.Forms.File_manager.columnHeader3
private

◆ columnHeader4

System.Windows.Forms.ColumnHeader xeno_rat_server.Forms.File_manager.columnHeader4
private

◆ columnHeader5

System.Windows.Forms.ColumnHeader xeno_rat_server.Forms.File_manager.columnHeader5
private

◆ columnHeader6

System.Windows.Forms.ColumnHeader xeno_rat_server.Forms.File_manager.columnHeader6
private

◆ components

System.ComponentModel.IContainer xeno_rat_server.Forms.File_manager.components = null
private

Required designer variable.

◆ currentDirectory

string xeno_rat_server.Forms.File_manager.currentDirectory = ""
private

◆ FileViewer

FileView xeno_rat_server.Forms.File_manager.FileViewer
private

◆ label1

System.Windows.Forms.Label xeno_rat_server.Forms.File_manager.label1
private

◆ listView1

System.Windows.Forms.ListView xeno_rat_server.Forms.File_manager.listView1
private

◆ listView2

System.Windows.Forms.ListView xeno_rat_server.Forms.File_manager.listView2
private

◆ tabControl1

System.Windows.Forms.TabControl xeno_rat_server.Forms.File_manager.tabControl1
private

◆ tabPage1

System.Windows.Forms.TabPage xeno_rat_server.Forms.File_manager.tabPage1
private

◆ tabPage2

System.Windows.Forms.TabPage xeno_rat_server.Forms.File_manager.tabPage2
private

◆ textBox1

System.Windows.Forms.TextBox xeno_rat_server.Forms.File_manager.textBox1
private

The documentation for this class was generated from the following files: