Ability to get buffer from inputmessage

Sorry for three commits at once since I have no idea how to undo a commit.
You may delete this pull requests and do it with one commit by urself.