On the canonical decomposition of generalized modular functions