How to decode the msg.data on a function in plain solidity?

https://ethereum.stackexchange.com/questions/144944/how-to-decode-the-msg-data-on-a-function-in-plain-solidity

I was wondering how to decode the data payload received on a function

At first, I thought it would be enough with knowing the order of the variables and the exact data type of them at the moment of encoding, but when I tried to decode the msg.data as follows (var1,var2,var3) = abi.decode(msg.data,(dataType1,dataType2,dataType3));, the operation was failing and the entire tx was reverted.