Difference between revisions of "Truxton child file create"

From truxwiki.com
Jump to navigation Jump to search
Line 2: Line 2:
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint64_t truxton_child_file_create( uint64_t trutxon_handle );
 
uint64_t truxton_child_file_create( uint64_t trutxon_handle );
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 8: Line 8:
 
=Parameters=
 
=Parameters=
 
==<code>truxton_handle</code>==
 
==<code>truxton_handle</code>==
 
+
The Truxton instance this child file will belong.
The handle created by the [[truxton_create]] call.
+
This handle comes from calling <code>[[truxton_create]]()</code>.
  
 
=Return value=
 
=Return value=
Line 15: Line 15:
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="5">
<syntaxhighlight lang="C" highlight="5">
 
 
void add_folder(uint64_t truxton, uint64_t parent_file)
 
void add_folder(uint64_t truxton, uint64_t parent_file)
 
{
 
{
Line 52: Line 51:
 
   truxton_child_file_destroy(child);
 
   truxton_child_file_destroy(child);
 
}
 
}
</syntaxhighlight>
+
</source>

Revision as of 10:56, 18 January 2021

This creates a child file object that you can populate with information before adding it to Truxton.

Syntax

uint64_t truxton_child_file_create( uint64_t trutxon_handle );
</syntaxhighlight>

=Parameters=
==<code>truxton_handle</code>==
The Truxton instance this child file will belong.
This handle comes from calling <code>[[truxton_create]]()</code>.

=Return value=
A non-zero value on success, zero on failure.

=Sample=
<source lang="C" highlight="5">
void add_folder(uint64_t truxton, uint64_t parent_file)
{
   truxton_start_adding_files(truxton);

   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;

   GetSystemTimePreciseAsFileTime(&now);

   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" );
   }

   truxton_child_file_destroy(child);
}