Watermarking

From Nesdev wiki
Revision as of 11:19, 20 January 2011 by Tepples (Talk | contribs) (outline)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Watermarking is defined by Wikipedia as "the process of embedding information into a digital signal in a way that is difficult to remove." In some cases, the developer of an unreleased NES program wants to distribute to beta testers but still trace any leaked copies of the program to the tester who broke the non-disclosure agreement. There are several ways to produce binaries that can be traced back to a particular recipient.

Shuffling

One way to make each copy unique is to shuffle, or randomly rearrange, pieces of a program at compile time.

A code preprocessor can randomize the order of statically allocated variables in a program. This causes the addresses embedded in the code to change every time the program is compiled. It has benefits beyond watermarking: as the program is shuffled, the effects of a buffer overflow may become more apparent.

A code preprocessor can shuffle the order of subroutines in a program. Watch out: A common technique on the NES is the "inline tail call", in which a subroutine doesn't return but instead falls off the end into the following subroutine. You'll need to take this into account when adding markup to control the preprocessor.

A code preprocessor can shuffle the order of instructions in a subroutine. When the order of (e.g. LDA vs. CLC or STA) Adding the required markup

Instruction encoding

A few instructions have multiple encodings. A code preprocessor can introduce any of several NOP instructions at random points in a non-time-critical subroutine.

Graphics changes

Graphics can depend on the build:

  • Choose one of several alternatives for grass and other noisy tiles
  • Tester's name or something derived from tester's name on the title screen
  • Tester's name or something derived from tester's name on a sign in a building in the game

Compression

If your program includes compressed data, you can change the interpretation of bits in the data format. For example, in RLE compression of graphics, the sense of bits denoting a run of repeated pixels vs. bits denoting a run of several literal pixels can be inverted.