I don't know if this has anything to do with the problem but posting anyway. It's about pointer size and integers, which work differently than Delphi i presume:
http://wiki.freepascal.org/Integer