21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

int main(int argc, char *argv[ ]) {<br />

void (*ptr)(void);<br />

ptr = GET_FN_PTR(my_func); /* get the real address of the function */<br />

(*ptr)( ); /* make the function call */<br />

return 0;<br />

}<br />

12.10 Restructuring Arrays<br />

<strong>Problem</strong><br />

Arrays contain information in their structure. Knowing how many dimensions an<br />

array has can help in understanding the underlying data. You need a way to hide<br />

dimensional information about arrays.<br />

Solution<br />

Disguising the nature of arrays is different from obfuscating a variable. What is<br />

important in this case is the order of elements in the array, not the elements themselves.<br />

Array elements can be obfuscated using any standard variable obfuscation,<br />

but arrays themselves should be restructured as well.<br />

Arrays can be restructured in four ways:<br />

• Splitting a one-dimensional array into multiple one-dimension arrays<br />

• Folding a one-dimensional array into a multidimensional array<br />

• Flattening a multidimensional array into a one-dimensional array<br />

• Merging two one-dimensional arrays into a single one-dimensional array<br />

In this recipe, an API will be developed for splitting, folding, flattening, and merging<br />

arrays.<br />

Discussion<br />

Array obfuscation is a powerful way of disguising groupings of information<br />

by adding or subtracting dimensions from an array. Note that<br />

the array data is not obfuscated, merely the ordering of the data. This<br />

is insignificant with one-dimensional arrays but can be very effective<br />

with large multidimensional arrays.<br />

The first step in developing the API for restructuring arrays is to define a new data<br />

type that will represent an array, rather than using the normal C convention for<br />

672 | Chapter 12: Anti-Tampering<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!