The way Microsoft patched a recent bug raised some eyebrows
bleepingcomputer.com
bleepingcomputer.com
That is, the binary patch path is more expensive than code patches, because it requires more specialized skills. At some point, with enough patches, it would have been worthwhile to update the source and rebuild than to modify the binary.
https://github.com/int19h/aow-patch
http://steamcommunity.com/app/61500/discussions/0/2154397748...
Originally it was a fix for a bug that would show up when running it under Wine. Now the game is re-released on Steam and GoG, and same thing came up on regular Win10.
The funniest part is, I don't even remember what the patch does - I made it 12 years ago! I remember spending a lot of time reading disassembly, trying to figure out what's going on, and eventually figuring just enough to plug the immediate hole. Then I posted the binary diff on a forum, and subsequently forgot all about it, because the bug went away in some Wine update shortly thereafter.
http://aow.heavengames.com/cgi-bin/forums/display.cgi?action...
When I dug that diff out, it made zero sense to me. So now not only there's no source for the game, but I've "lost the source" for the patch, as well - I'd have to reverse engineer it all again to figure out what it actually does. ~
Some bugs went unnoticed until very recently. For example I was one of playtesters of this patch, and I reported that Invulnerability spell appears impossible to dispel. Kyrub checked it out, and... would you believe ? There was an off-by-one error, Invulnerability was the last on the list. It was literally impossible to dispel because of a programming error. Those old strategy guides recommending Guardian Spirit + Invulnerability rushes... they were so effective because they unknowingly exploited a bug!!
So what you're saying is that Wine is more Windows compatible in the case of AoW than Windows itself? :- )
I thought I'd even seen reference to support in compilers to pre-assign such spaces.
If (for instance) this is a product acquired from outside the Redmond campus, run successfully unpatched since B.C. and now needing work, it might actually be more effective to do what they did instead of reverse-compiling code, re-implementing, the whole shebang.
Security nightmare? Sure. Unsafe? depends. NASA pay old-timers the big bucks to keep things working out in space, which probably involves processes which aren't morally far removed from this.
Are you referring to Microsoft's MOV EDI, EDI at the beginning of every function? That's a hot-patch point.[1]. I think that was more for in-memory patching to get around the problem that if you replace the current code, you might run afoul of some thread actually executing it. That wouldn't necessarily apply to the binary/DLL, which when loaded from scratch wouldn't need any such hot-patching.
1: https://blogs.msdn.microsoft.com/oldnewthing/20110921-00/?p=...
Maybe you're thinking about hot patch points in Windows DLLs?
https://blogs.msdn.microsoft.com/oldnewthing/20110921-00/?p=...
Another advantage of the small and localised changes, besides rapid and efficient application (and reversion), is the ability to do it to all in-memory copies of the file in addition to the one on disk, eliminating the need to reboot.
A company like Microsoft that has solid and complex software development and security practices in place would never deem manually binary editing as acceptable.
Perhaps what we need is better tooling to make this process easier, and I guess in general a more "bidirectional" view of binaries vs. source --- small changes in source should correspond to proportionally small changes in binaries, and also proportionally small updates for end-users.
The current "binaries are sacred and shall only be the outputs of long and complex build processes" attitude is neither efficient nor optimal from the perspective of the end-user experience, or even developers sometimes --- for example, changing a one-letter typo in a string constant and testing the change should not involve hours of compilation, deployment, and installation, but be closer to the minutes it would take to do it in a hex editor.
I posted more on this topic recently: https://news.ycombinator.com/item?id=15729874
https://dev.chromium.org/developers/design-documents/softwar...
There's also this to consider: https://blog.regehr.org/archives/294
I would love to read the post mortem.
Is introducing a whole new set of bugs responsible? After seventeen years, if there are any skeletons left they're going to be hard to find. And I'll betcha there's an individual (at a minimum) at Microsoft sitting there right now beating the hell out of that component with all manner of fuzzing and stack manipulation trying to tease out anything else that might have been missed.
Or we can rewrite it and hope we caught all of those weird edge cases, as well as replicated any bugs that downstream components might have come to rely upon. In the mean time, make sure not to introduce any new bugs or pull in any dependencies that might have new bugs. And make sure to test it on every version of Office for the last seventeen years. We still have those tests for Office 2000, right?
So I whipped up a dummy driver that Windows could ship that just NOP'ed every ODBC call with a text box that said "go download the Fox driver from...". For all I know, it still ships in Windows today (VFPODBC.DLL, IIRC).
But even that simple task wasn't simple when you're working at Windows scale. First was even getting it checked in, and check-ins at the time were more tribal knowledge than documented. A helpful Windows engineer documented what they knew. But it turns out that there were a lot of assumptions made that were valid if one were on the Windows team, but not if you're an external group. And thus is how the Windows build got broken. Breaking the Windows build is a little different than it might be on your team when the build gets broken. Yeah, maybe you give someone some shit, maybe you make them wear the "I Broke the Build" shirt for a day (don't do that, BTW). But when the Windows build gets broken, emails go out, and war rooms with VPs happen. And that's how I got to meet Chris Jones. He asked why Windows had 1200 testers sitting around doing nothing. Fingers begin to point at the strangers in the room. We said that we followed the directions given to the letter, but there was no formal process for Windows to take check-ins from external groups, so here we are. We were dismissed, and a few weeks later a document started going around on how to check-in to the Windows repo. It was probably a month or more from the time I wrote the dummy (which probably took all of an hour or two) until it showed up in internal builds.
So, yeah, I can kind of see why there might not have been any volunteers to go modify and rebuild a seventeen year old component. Put a two byte patch on the thing and call it a day.
Binary patches are a perfectly normal thing, may it be from Microsoft or a random company.