#include <string.h>
#include <stdio.h>
#include "defines.h"
#include "obfuscate.h"
#include "util.h"
#include "tree.h"
Functions | |
| void | obfuscate_set_mode (bool value) |
| Sets the global 'obf_mode' variable to the specified value. | |
| char * | obfuscate_name (const char *real_name, char prefix) |
| Gets an obfuscated name for the given actual name. | |
| void | obfuscate_dealloc () |
| Deallocates all memory associated with obfuscation. | |
Variables | |
| tnode * | obf_tree = NULL |
| int | obf_curr_id = 1000 |
| bool | obf_mode |
|
|
Deallocates all memory associated with obfuscation. Deallocates all memory associated with obfuscation.
00109 { PROFILE(OBFUSCATE_DEALLOC);
00110
00111 tree_dealloc( obf_tree );
00112
00113 PROFILE_END;
00114
00115 }
|
|
||||||||||||
|
Gets an obfuscated name for the given actual name.
00070 { PROFILE(OBFUSCATE_NAME);
00071
00072 tnode* obfnode; /* Pointer to obfuscated tree node */
00073 char* key; /* Temporary name used for searching */
00074 char tname[30]; /* Temporary name used for sizing obfuscation ID */
00075 unsigned int rv; /* Return value from snprintf calls */
00076 unsigned int slen; /* String length */
00077
00078 /* Create temporary name */
00079 slen = strlen( real_name ) + 3;
00080 key = (char*)malloc_safe( slen );
00081 rv = snprintf( key, slen, "%s-%c", real_name, prefix );
00082 assert( rv < slen );
00083
00084 /* If the name was not previously obfuscated, create a new obfuscated entry in the tree and return the new name */
00085 if( (obfnode = tree_find( key, obf_tree )) == NULL ) {
00086
00087 /* Create obfuscated name */
00088 rv = snprintf( tname, 30, "%c%04d", prefix, obf_curr_id );
00089 assert( rv < 30 );
00090 obf_curr_id++;
00091
00092 /* Add the obfuscated name to the tree and get the pointer to the new node */
00093 obfnode = tree_add( key, tname, FALSE, &obf_tree );
00094
00095 }
00096
00097 /* Deallocate key string */
00098 free_safe( key, (strlen( key ) + 1) );
00099
00100 PROFILE_END;
00101
00102 return( obfnode->value );
00103
00104 }
|
|
|
Sets the global 'obf_mode' variable to the specified value. Sets the global 'obf_mode' variable to the specified value.
00052 { PROFILE(OBFUSCATE_SET_MODE);
00053
00054 obf_mode = value;
00055
00056 PROFILE_END;
00057
00058 }
|
|
|
Current obfuscation identifier. Incremented by one each time that a new obfuscation occurs. |
|
|
Specifies obfuscation mode. |
|
|
Pointer to the root of the obfuscation tree containing real to obfuscated name pairings. |
1.3.4