Camouflaging identifiers




The camouflage of identifiers (names of variables, procedures, modules, etc.)
is performed by replacement with randomly generated code names.

This complicates the readability of the code
and the meaning of the respective object is obscured.
The function can now only be understood by gradual Debugging.


Code names generation

Method of generating camouflaged names.

with VBA keywords
Generating of code names by using of random VBA keywords.

Example: Public_To_LSet_Print
MsgBox_Close_ChDir_Input_Then

Benefit: Bewildering accumulation of VBA keywords
Downside: Names can be relatively easily noticed and distinguished from each other

Note: For syntactic reasons will in the names of the following identifier types
no underscores "_" used:

Procedure
Function
Property Get
Property Let
Property Set

random text
Generating of codenames using different long random sequences of letters.

Example: YmTh
dFlOqOhcMgEB
oHeZXQietUdsgOsdjiGkjaHHzqimcLa

Benefit: Extremely chaotic appearance of the source–code
Downside: Letters and lengths can be distinguished from each other


"binary" form
Generation of codename using equally long sequences of zeros and ones.

This method increases the difficulty of reliably tracking or recognizing names.
All identifiers are extremely difficult to distinguish from each other!

Example: O001011010110101101001110100110
O110010001001010110111010010011
O010010010100100100110000000111

Benefit: Extremely difficult identification and differentiation of identifiers
Downside: Same–long names can lead to rhythmical code structures


Camouflage the identifiers of...

Selection of code elements (types), whose identifiers should be replaced by code names.
For more information, please position the mouse over the respective component.

Note: If an identifier is excluded from being camouflaged because its type was deactivated,
then ALL other identifiers with the same name are NOT camouflaged either,
regardless of their type!
This measure serves the syntactic security.


Filtering

In this section you can specify which identifiers should be camouflaged
or be excluded from thereof.


ONLY identifier with suffix

This option gives you the ability to determine
which identifiers are to be camouflaged.
This is especially helpful if it is not required to camouflage the entire project
but only the names of certain procedures, modules, etc.

Define a distinctive Suffix and add it to each identifier to be camouflaged.

Example: Suffix = "_cc": strText  –>  strText_cc

Mark so all elements to be camouflaged,
including controls, UserForms, procedures, etc.

CrunchCode then camouflages only the identifiers whose name contains the suffix.
All other identifiers remain uncamouflaged.


Individually select dentifiers

In certain cases, identifiers must remain unchanged and may NOT be camouflaged.

Example 1: Access to UserForm–elements with use only of a part of their name

A UserForm contains five text fields "Label1, Label2,...,Label5"
that are filled successively:

For bytX = 1 To 5
    frmXXX.Controls("Label" & bytX).Caption = ...
Next bytX

In this example, camouflaging the name of the UserForm elements would
result in a runtime error when they
are called by their old names ("Label1", "Label2" etc.).

The identifiers "Label1...5" must be excluded from being camouflaged.

This situation can also occur if the names "Label1... 5"
are generated in a function:

For bytX = 1 To 5
    frmXXX.Controls(prcBuildLabelName(bytX)).Caption = ...
Next bytX


Example 2: External call of procedures

If a procedure is called by an external program,
the procedure must NOT be camouflaged
or else the external program will not be able to find it.

By activating this option during the program a list is displayed,
where you can select for each identifier, whether it should be camouflaged or not.


Exclude

You can exclude identifier also from the camouflage with the help of a text pattern
which seems in the respective name.

Attention!
Do NOT use this option to exclude SINGLE identifiers from the camouflage!
Activate for this purpose "Individually select dentifiers".

Note:
If you always want the same identifiers to leave uncamouflagedin all your projects,
then please enter their names in the list "Globally blocked keywords"
(see start menu –> "CrunchCode options").


Force

Under certain circumstances, the camouflaging of identifiers is denied.
However, you can force the camouflaging for single identifier
More details, please refer to the Help of the "Force" dialog.


Identifiers WITHIN Strings?


   This information is very important for preventing runtime errors!.
   Please read the following instructions and check your settings carefully.

   If you are unsure of the answer to this question, then you have two options:

a) Select "Skip" to exclude the problem initially.
    Identifiers whose names also appear in texts are then ignored.

b) Select "Yes" and activate "All".
    You will receive during the program an overview of all strings
    that may contain a reference to identifier, and you can edit each individually.

   More details are in the description below.


Some VBA statements and certain programming techniques require the disclosure
of an identifier in textual form (e.g. a function name or UserForm name).

Example: Application.OnKey  "{F1}",  "Help" assigns key F1 to the procedure "Help()".

'Help' is the name of a procedure and thus WITHIN the string "Help"
a REFERENCE to an IDENTIFIER.


The same word may occur in another string, WITHOUT being a reference.

Example: MsgBox  "For help press key F1"

'Help' just happens to be the same word as the name of the procedure "Help()",
but it is not a reference.

CrunchCode must due to the various usages assume that EACH such occurrence
of an identifier is a reference to a procedure, variable etc.,
and has to replace it with a masked name.

This also applies if the identifier appears WITHIN STRINGS,
because it cannot decide on the basis of the source–code
whether there is a reference or a random word match.

Therefore CrunchCode reviewes each string and replaces all words,
that are identical with an identifier with the masked names.

The following options are available:

No
Warning!
Select this option only if you are sure that the project
contains NO REFERENCES to identifiers WITHIN STRINGS!

CrunchCode will then NOT investigate the existence
of identifier names within strings.
This significantly reduces the processing time.


Skip
This is the safest option, but also decreases the camouflage effect.

If CrunchCode finds a word in a string that is identical
to an identifier, then the identifier
will NOT be camouflaged in the WHOLE project.

This happens regardless of case sensitivity and regardless of whether a syntactic
relation exists between identifier and the identical word.


Yes
This option provides the highest camouflage effect.

Select what type of identifiers (procedures, modules, etc.)
will be referred in the strings.

If you are not sure which identifier types are referred to,
then select "All".
During processing, all strings
in which CrunchCode has found such an identifier can be checked.
Strings that contain NO reference to an identifier can be sorted out.

Some identifier types are marked in RED.
These are identifiers that are often used within strings.
Therefore you should be ABSOLUTELY SURE that NO strings
include a reference to one of these identifiers!


------------------------------------------------------------------------------------------------------------------------------------------------
Examples of the relationship between identifiers and the same words in strings
------------------------------------------------------------------------------------------------------------------------------------------------

   Example 1: Words in strings that refer to identifiers of procedures

Two procedures should be called by the keys F1 or F2,
Additionally, a short message will be shown in one procedure:
It is the following code present:

Const  HELP_PROC  =  "Help" <–– !
...


Sub  Init()
...
Application.OnKey  "{F1}",  HELP_PROC
Application.OnKey  "{F2}",  "Check" <–– !
...
End  Sub


Sub  Help()
...
End  Sub


Function  Check()  As  Boolean
...
    MsgBox  "To get help press F1"
...
End  Function


At the two labeled positions "Help" and "Check " are references to procedures.
But in the message box, the word "Help" is not related to the "Sub Help()".

Because of the two marked positions the option "Yes" must be selected,
so that CrunchCode examines all the texts for the existence of references.


   Example 2: Words in strings that are NOT references to procedures

Sub  Help()
...
End  Sub


Function  Check()  As  Boolean
...
    MsgBox  "To get help press F1"
...
End  Function


Because the word "help" in the message only matches the name
of "Sub Help()" by chance and in WHOLE source–code within strings
no reference to procedures or variables exists,
the option "No" can be selected thus simplifying the process.
------------------------------------------------------------------------------------------------------------------------------------------------


Exception rules

As a consequence of the option "Identifiers WITHIN Strings?" –> "Yes",
CrunchCode will display a list of ALL codelines,
which contain an identifier–name within a string.
You must then decide whether or not each line refers to an identifier.

To limit the number of these references, you can set up rules
that define whether a word is certainly NOT A REFERENCE to an identifier.

Tip: You can get a complete listing of all positions found
by running CrunchCode with the processing level "Analysis".


Camouflaging in external text files

Sometimes identifiers that are declared in the VBA project are also used in
external text files and have to be camouflaged in the same way (e.g. in languages files).

You can compile a list of the text files in which all words that
are identical to identifiers will be replaced by the corresponding code names.

Only plain text files can be processed.


VBA project:

Masking of UserForms in VBA editor

In a VBA project are UserForms conspicuous objects that allow very quick access
to sensitive source–code–positions (e.g., UserForms for password input).

To considerably complicate this, CrunchCode offers the possibility
to show all UserForms in the VBA–editor at the same size
and to completely hide control elements as well as the caption.

During the program run time, the UserForms are re–created
and appear the original size with the original controls.



Source–code protection

Activates the detection and handling of source–code manipulations.

An open source code such as VBA is NEVER safe from manipulations.
If in the program, however, procedures exist whose code must not be changed
(for example checking the licence key),
then their contents must be protected against interventions.

CrunchCode inserts additional procedures
which verify the CRC32–checksum of these program segments
and respond to manipulations.

For more details refer to the help for "Source–code protection".



as Standard

Selecting "OK" will save the current settings as your default for future projects.
Then they can be also reactivated with "Preset" –> "user–defined".

Preset

Optimisation of the settings or reset to defaults.
(inter alia to those values which were saved "as Standard").