People are either hacking their DS' hardware or they're using emulators. Commercials for DS games use special development kits that don't involve an actual DS.
It might also be possible to rig some kind of video camera right on top of the screen, but that would be even more difficult than the above three options.