Reverse engineering is allowed to an extent. I would have to do some research so don't take what I say as fact but I believe it to be so. I believe that you are allowed to reverse engineer closed source software that do not document their protocols and interfaces so as to make your software work/communicate with said closed source software.
That is what allows Samba to exist and allows it to communicate with Windows on many levels. However, I believe with Samba most of the reverse engineering is done to the protocol and not necessarily the Windows software itself. That is, network sniffers come in handy to figure out what the closed source software is doing. Again, this is from memory of reading several articles and discussions about it, and if I recall there have been court rulings on such activity to support it.
Someone please correct me if/where I am wrong on this.