I have witnessed factory techs attempt to prove an ECU was tuned, and fail in doing so. These were vehicles that I KNOW were infact tuned previously. It's a never ending cat and mouse game. Aftermarket finds a way to get something done undetectable, then the factories find a way to prevent that exploitation in the future.
More often than not, you are correct though, even port flashes can usually be detected.
This was what I previously thought, and I have come to find that it is not fully correct.
See the Dinan comments above. Dinan packages sold by and installed by BMW dealers can still cause warranty issues.