I found a bug in the implementation of DosGetMessage.
It seems the call to "catclose" should be made after
the strcpy call that uses "catPtr". Right now, the
catalog is closed before the string copy and that
results in a segmentation violation because the memory
associated with catPtr gets free'd in the close call.
Also, you might consider using "strncpy" rather than
"strcpy" to avoid overwriting the target buffer if the
message is too long.