I've not used it but there is a game_save command which saves this kind of information.

You can also mark up to memory areas with add_struct.