I am having a very weird result with some code:
I am using boost.any
(before was using void *
) to return an address from a .dll in a .exe.
The dll has a function like this:
boost::any User::getNativeHandle() {
return boost::any(pimpl_->adressOfObject_);
}
And my exe, code like this:
class SomeClass {
public:
SomeClass(User & user) {
scopedResource_([&](InternalType * s) {
InternalTypeConstruct(..., user.getNativeHandle());
}
}
private:
ScopedResource<InternalType> scopedResource_;
};
Facts and observations:
User
object is created in the .exe, but it's a dll class.- The pointer printed from inside the .dll and outside of it has the same address, so it seems to be the correct object.
- The printed value address is a multiple of 4 all the time, so it seems to be a valid address at least. 64-bit machine windows 8.
- I had to remove some runtime libraries with
/NODEFAULTLIB: ...
but now it seems to be correctly setup. The cast seems to be correct from
boost.any
back to my type in the .exe, since I made it fail before on purpose to make this sure.The pointer returned from the
User::getNativeHandle
.dll is a type that is a pointer to a type from another library, a .lib library without any .dll, namely, a real static library.
It ends up crashing with SEH 0x00000005. My class User
exposes the interface, and I also tried to dll export the Impl class for Pimpl, but it seems to do nothing.
Any idea? This bug is making me mad :).