Difference between revisions of "Truxton message get route id"

From truxwiki.com
Jump to navigation Jump to search
Line 3: Line 3:
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint32_t truxton_message_get_route_id( uint64_t message_handle );
 
uint32_t truxton_message_get_route_id( uint64_t message_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
Line 15: Line 15:
  
 
=Sample=
 
=Sample=
<syntaxhighlight lang="C" highlight="3">
+
<source lang="C" highlight="3">
 
void dump_route(uint64_t message)
 
void dump_route(uint64_t message)
 
{
 
{
Line 37: Line 37:
 
   }
 
   }
 
}
 
}
</syntaxhighlight>
+
</source>
 +
 
 +
The <code>PRIu32</code> in the sample code above is a standard way of [https://en.wikipedia.org/wiki/C_data_types#Printf_and_scanf_format_specifiers formatting] a 32-bit unsigned integer in C.
 +
Over the years, different compilers on different operating systems used different format specifiers for things, these <code>PRI</code> macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.

Revision as of 12:55, 22 January 2021

Tells you the route this media is taking through the exploitation process. This corresponds to the [ID] column of the [LoadConfiguration] table.

Syntax

uint32_t truxton_message_get_route_id( uint64_t message_handle );

Parameters

message_handle

The handle to a message created by the truxton_message_create call.

Return value

The identifier of the type of load being performed.

Sample

void dump_route(uint64_t message)
{
   uint32_t id = truxton_message_get_route_id( message );

   if ( id == 0 )
   {
      printf( "Performing a default load.\n" );
   }
   else if ( id == 4 )
   {
      printf( "Performing a triage load.\n" );
   }
   else if ( id == 5 )
   {
      printf( "Data recovery load.\n" );
   }
   else
   {
      printf( "Some load with an id of %" PRIu32 "\n", id );
   }
}

The PRIu32 in the sample code above is a standard way of formatting a 32-bit unsigned integer in C. Over the years, different compilers on different operating systems used different format specifiers for things, these PRI macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.