Difference between revisions of "Truxton file open id"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This retrieves entropy of the file contents. =Syntax= <syntaxhighlight lang="C"> uint64_t truxton_file_open_id( uint64_t truxton_handle, char const * guid_string ) </syntaxhi...")
 
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
This retrieves entropy of the file contents.
+
This retrieves a file from Truxton by its [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID].
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
uint64_t truxton_file_open_id( uint64_t truxton_handle, char const * guid_string )
+
uint64_t truxton_file_open_id( uint64_t truxton_handle, char const * guid_string );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
 
==<code>truxton_handle</code>==
 
==<code>truxton_handle</code>==
 
 
The handle created by the [[truxton_create]] call.
 
The handle created by the [[truxton_create]] call.
  
 
==<code>guid_string</code>==
 
==<code>guid_string</code>==
 
 
The string representation of the identifier of the file to get in Truxton.
 
The string representation of the identifier of the file to get in Truxton.
This corresponds to the <code>ID</code> column of the <code>File</code> table.
+
This corresponds to the <code>[ID]</code> column of the <code><nowiki>[</nowiki>[[File Table|File]]<nowiki>]</nowiki></code> table.
 +
The [[TGUID#File_ID|file identifier]] is not random.
  
 
=Return value=
 
=Return value=
Line 20: Line 19:
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="3">
<syntaxhighlight lang="C" highlight="35">
+
int check_it( uint64_t truxton )
void add_folder(uint64_t truxton, uint64_t parent_file)
 
 
{
 
{
  truxton_start_adding_files(truxton);
+
   uint64_t file = truxton_file_open_id( truxton, "5ed3aeb7-3da4-5f5c-8c8f-af5200000000" );
 
 
   uint64_t child = truxton_child_file_create(truxton);
 
 
 
  char id[40];
 
 
 
  truxton_file_get_id(parent_file, id, sizeof(id));
 
  truxton_child_file_set_parent_id(child, id);
 
  truxton_child_file_set_type(child, Type_Directory);
 
  truxton_child_file_set_name(child, "Custom Exploits Folder");
 
 
 
  FILETIME now;
 
  
  GetSystemTimeAsFileTime(&now);
+
   if ( file == 0 )
 
 
  ULARGE_INTEGER ticks;
 
 
 
  ticks.LowPart = now.dwLowDateTime;
 
  ticks.HighPart = now.dwHighDateTime;
 
 
 
  truxton_child_file_set_created(child, ticks.QuadPart);
 
  truxton_child_file_set_accessed(child, ticks.QuadPart);
 
  truxton_child_file_set_modified(child, ticks.QuadPart);
 
 
 
  truxton_child_file_set_origin(child, ORIGIN_GENERATED);
 
 
 
   if ( truxton_child_file_save(child) == 0 )
 
 
   {
 
   {
       printf( "Failed to add child to Truxton\n" );
+
       return( 0 );
  }
 
  else
 
  {
 
      double entropy = truxton_child_file_get_entropy(child_file);
 
      printf( "Entropy:s %lf\n", entropy );
 
 
   }
 
   }
  
   truxton_child_file_destroy(child);
+
   truxton_file_close( file );
 +
  truxton_file_free( file );
 +
 
 +
  return( 1 )
 
}
 
}
</syntaxhighlight>
+
</source>

Latest revision as of 05:42, 6 February 2026

This retrieves a file from Truxton by its GUID.

Syntax

uint64_t truxton_file_open_id( uint64_t truxton_handle, char const * guid_string );

Parameters

truxton_handle

The handle created by the truxton_create call.

guid_string

The string representation of the identifier of the file to get in Truxton. This corresponds to the [ID] column of the [File] table. The file identifier is not random.

Return value

A handle to a read-only file in Truxton.

Sample

int check_it( uint64_t truxton )
{
   uint64_t file = truxton_file_open_id( truxton, "5ed3aeb7-3da4-5f5c-8c8f-af5200000000" );

   if ( file == 0 )
   {
      return( 0 );
   }

   truxton_file_close( file );
   truxton_file_free( file );

   return( 1 )
}