Adding a Custom File Type Filter

You can add a custom file type to the File Filters collection by creating a custom file type filter and configuring steps to identify the file type.

Prerequisites

  • Research the file format. Many file formats are documented publicly on the Internet. Understanding and using the characteristics that are specific to the file type you want to build a filter for will result in more accurate file identification.
  • Gather multiple samples of the file type you want to filter. Ensure the samples are from different sources, represent various versions, and created on assorted operating systems.
  • You must have hex editor software that enables you to view the bytes in any file in hexadecimal format.
  • Identify a few bytes common to all the sample files. If you use a filter that has too many bytes specified, some files of that type will not be recognized as such. If you use too few bytes, then some files that are not of that type will erroneously be recognized as files of that type.
  1. In the Control Panel pane under the Modules section, select Device Explorer.
  2. In the navigation bar, select Explorer > Manage Custom File Types.
    The Manage Custom File Types dialog opens.
  3. Click Add.
    The New Custom File Type dialog opens.
  4. Enter a name in the Name field.
    The name will be displayed in the File Type Filtering dialog.
  5. You must create at least one step to detect the file type. The steps you configure will run in the order they are placed in the Steps to detect the file type section. If all steps succeed then the file is determined to be of the type you want to filter. If one step fails the file type is determined not to be of that type.

    For example, a common step sequence is:

    • Search for particular bytes at the beginning of the file.
    • Move to an offset from the beginning of the file and read in a variable. Then move the current position by the offset in that variable, and then check for end of file.
    • Move to an offset from the beginning of the file and read in a variable. Move the current position by the offset in that variable, and then search for specific bytes.
    • Search for bytes at the beginning of the file. Read in a variable. Move to a given offset. Read in another variable. Move to a position of beginning of file plus the value in Variable 1, then check for specific bytes. Move to the end of file position minus the value in Variable 2, then check for specific bytes.
  6. Add steps to detect the type of file you want to filter:
  7. Option

    Description

    Search for Bytes

    Provide a byte string unique to the file type you want to detect:

    1. Select Add > Search for Bytes. The Search for Bytes dialog opens.
    2. In the Bytes to search for, in hexadecimal notation field, enter the string of bytes you have identified as unique to the file type you want to detect.
    3. From the Reference Point drop-down, select the point from where the system is to start its search for the byte string:
      • The beginning of the file: Search starts from the beginning of the file (Byte 0).
      • The current file position: Search starts at the current position of the Reference Point.
      • The end of the file: Search starts after the last byte in the file. If this Reference Point is selected, you must use a negative offset.

      If the bytes are found, the current position is changed to the byte after the end of the matching byte string.

    4. Select an option and set an offset value to have the system start its search for the byte string from a particular location in the file:
      • Use this offset: Enter a value that represents the number of bytes from the Reference Point the system should look for the unique byte string. Negative values go left from the Reference Point.
      • Use the offset in this variable: Select the value contained in a pre-defined variable to set the number of bytes from the Reference Point, the system should look for the unique byte string.
    5. Select an option and set a byte range within which the system is to confine its search for the byte string.
      • Bytes must start within this distance of the offset: Enter a value that represents the length of the byte range from the offset, where the system is to search for the beginning of the byte string.
      • Use the distance in this variable: Select the value contained in a pre-defined variable to set the length of the byte range from the current position, where the system is to search for the beginning of the byte string.

      For example, if you know that file you want to filter always contains the sequence of bytes 05 23 FF somewhere in the beginning between the bytes in positions 5 and 12, you might use the beginning of the file as the Reference Point, offset 5, and Within this distance of the offset value 7. On the other hand if that sequence is always at byte position 5 you would use Within this distance of the offset value 0.

    6. Click Save.

    Read a Variable

    Create a variable that reads an integer:

    1. Select Add > Read a Variable. The Read a Variable dialog opens.
    2. In the Variable name field, enter a name.
    3. From the Integer size in bytes drop-down, select the number of bytes the integer has. 1, 2, 4, and 8 are the available options.
    4. In the Byte Order section, select an endian format option for the integer value:

      An endianness format does not apply to 1 byte integers.

      • Little endian: Low-order byte is stored at the lowest address, and the high-order byte at the highest address.
      • Big endian: High-order byte is stored at the lowest address, and the low-order byte at the highest address.
    5. From the Reference Point drop-down, select the point from where the system is to start searching for the integer:
      • The beginning of the file: Search starts from the beginning of the file (Byte 0).
      • The current file position: Search starts at the current position of the Reference Point.
      • The end of the file: Search starts after the last byte in the file. If this Reference Point is selected, you must use a negative offset.

      If the integer is found, the current position is changed to the first byte after the integer.

    6. Select an option and set an offset value to have the system search for the integer from a particular location in the file:
      • Use this offset: Enter a value that represents the number of bytes from the Reference Point that the system should read the integer value to the variable from. Negative values go left from the Reference Point.
      • Use the offset in this variable: Select the value contained in a pre-defined variable to set the length of the byte range from the current position, where the system is to search for the integer value to be saved in the variable.
    7. Click Save.

    Change Current Position

    Move the current position used in previous steps:

    1. Select Add > Change Current Position. The Change Current Position dialog opens.
    2. From the Reference Point drop-down, select the point to where the pointer is to be moved:
      • The beginning of the file: Search starts from the beginning of the file (Byte 0).
      • The current file position: Search starts at the current position of the Reference Point.
      • The end of the file: Search starts after the last byte in the file. If this Reference Point is selected, you must use a negative offset.

      If the current position can be moved in the manner indicated in this step, it is changed and the step succeeds. If not, for example if the pointer is at the beginning of the file and the position changes to 5 bytes to the left, the step fails and the file is determined not to be of the custom file type.

    3. Select an option and set an offset value:
      • Use this offset: Enter a value that represents the number of bytes from the Reference Point, where the pointer should be moved to. Negative values go left from the Reference Point.
      • Use the offset in this variable: Select a variable containing an integer value that represents the number of bytes from the Reference Point, where the pointer should be moved to.
    4. Click Save.

    End of File

    Check if the current position is the end of the file:

    1. Select Add > Check End of File.The Check End of File dialog opens. No settings are required.
    2. Click Save.

    This step succeeds if the current pointer position is the end of the file. This step does not change the current position. If the current position is not the end of the file when this step is performed, the file is determined not to be of the custom file type and no further steps are performed.

  8. After you have finished adding the custom file type steps, click Save in the New Custom File Type dialog.
    The new custom file type is added and appears:
    • Within the Custom File Types list of the Manage Custom File Types dialog.
    • Under the Custom node in the File Type Filtering dialog when configuring permissions.

After Completing This Task

Now you can:

  • Use the newly created custom file type by navigating to the file filtering dialog, expanding the Custom section, and selecting the custom file type they created, then selecting Import / Export within the permission.
  • Edit the custom file type filter by selecting it in the Manage Custom File Types dialog and clicking Edit.
  • Remove the custom file type filter by selecting it in the Manage Custom File Types dialog and clicking Remove.

Related Information

Related Tasks