if(car_is_being_emissions_tested()) {
...
}
...and such an audit could have been done by a junior in college working at a $15/hour internship. As these ways to cheat regulation become more sophisticated, under-funded regulatory agencies will be unable to keep up. It may be mathematically possible to audit binaries effectively, but it's not monetarily or organizationally an effective way to do regulation.
Does it? What result are you trying to produce by this legislation?
If you're trying to produce the result that fewer people use X harmful substance, then it absolutely does not make sense to regulate the substance itself. Evidence suggests that regulation merely makes selling the substance more profitable and buying the substance more "edgy", making the substance more dangerous. Instead, it makes sense to provide better programs for treatment and education around the substance, which results in lower usage, higher recovery rates when someone does use it, and less incentives for people to traffic the substance.
But if you're trying to produce profits for prison corporations and further militarize law enforcement, by all means, let's make all substances illegal.