Add function to get size of in-memory resource and used this function to copy resource to writable memory.