My question concerns the legality of "software patching", specifically making changes to the compiled code of an existing third-party software application in order to alter its behavior. My understanding is that this would be illegal in the event that:
Such patches are intended to circumvent DRM (unless an exception applies)
Distribution of the patches includes distribution of copyrighted parts of the original code* that the patch distributor is not permitted to distribute
Under civil or contract law, the patches are intended to cause the application to behave in a way that causes damage/abuse to a remote service (e.g. API misuse) or that harm the experience for other users (e.g. cheating in a multiplayer game), where these terms are included in an EULA or ToS
However, my understanding is that the mere act itself of producing, distributing, or applying patches to an existing application is legal because the patches do not contain portions of the original copyrighted work* and are not considered a "derived work" under copyright law.
Now, I am aware that it is a reasonably well-established practice in the video game modding community to produce patches for games and I am not aware of any cases where a company has taken legal action against the act of patching in itself (barring other factors such as DRM circumvention etc.), but are there any cases where this has been legally tested (either demonstrating that it is legal or cases where companies have won against people producing or distributing patches)? Alternatively, what other laws might apply to the act of software patching?
*It is relevant to note that some popular formats used for patch distribution include a copy of the small portion of unmodified code that appears at or surrounding the location where the patch is to be applied, which may infringe copyright. However, it is technically possible to distribute a patch in a way that does not include this and includes only the replacement code written by the patch author.