It's really problematic. I've been using marshal and carefully examining anything that comes back from the unmarshaller. That looks to be pretty safe, but isn't promised to be portable between versions.