ole32: Avoid opening source storage in IStorage::CopyTo.

Vincent Povirk vincent at codeweavers.com
Thu Jun 2 14:55:35 CDT 2011


The recursion test is a bit of a mess, but I don't think there's a cleaner way of fixing it. On Windows, CopyTo can copy from a storage that has substorages open. This doesn't work on Wine because we need to open the substorage, and a storage cannot be opened twice.

The solution is to use the lower-level functions to read from the source storage instead of opening it, but we were relying on the failure to prevent a storage from being copied to a child of itself, causing infinite recursion. We cannot assume that the destination is an IStorage object implemented in ole32; we can only assume that of the source. Tests show that Windows can fail on "recusive" situations that aren't really recursive and could have worked just fine, such as copying to a substorage that has been opened in transacted mode. We cannot use the actual copy to detect recursive situations.

To implement Windows' rather odd behavior, we must go through the ancestors of the destination storage until we find the source (or a top-level storage object or a storage implementation from outside ole32). That means checking the vtable of all of these objects and casting them to their most specific type. This is evil and ugly and I hate it, but I can't see any way to avoid it.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-ole32-Avoid-opening-source-storage-in-IStorage-CopyTo.txt
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20110602/270d1085/attachment.txt>


More information about the wine-patches mailing list