Split OpenFile implementation in separate 16- and 32-bit versions, and changed it to use exported APIs instead of internal functions where possible.