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.

12.7 Splitting Variables<br />

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

Large scalar variables that cannot be merged, or that have large values that cannot<br />

easily be manipulated with a constant transform, need to be obfuscated.<br />

Solution<br />

Splitting variables can be effective when the variables holding the split values are in<br />

different scopes. The split can also be performed during variable initialization by<br />

rewriting the SPLIT_VAR macro presented in the “Discussion” section to declare and<br />

initialize the variables, rather than simply assigning to them.<br />

Discussion<br />

The value of a scalar variable can be split over a number of equal- or smaller-sized<br />

variables. The following code demonstrates how the four bytes of an integer can be<br />

stored in four different character variables:<br />

#define SPLIT_VAR(in, a, b, c, d) do { \<br />

(a) = (char)((in) >> 24); \<br />

(b) = (char)((in) >> 16); \<br />

(c) = (char)((in) >> 8); \<br />

(d) = (char)((in) & 0xFF); \<br />

} while (0)<br />

#define REBUILD_VAR(a, b, c, d) \<br />

((((a)

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

Saved successfully!

Ooh no, something went wrong!