Although grammarians are not entirely in agreement concerning such cases, many would argue that they are gerunds whose governing prepositions have simply been ellipted. The second sentence, for instance, could be considered as representing
I feel better through having him here.
It is, however, difficult to disprove that the sentence is not merely a reordered version of
Having him here, I feel better.
where most would have no hesitation in labelling 'having' a participle.
There are, nonetheless, ostensibly similar cases in which such a reordering does not necessarily render a semantically identical sentence, e.g.
He hurt his knees playing basketball.
which, although it could still be comfortably considered elliptical for
He hurt his knees through playing basketball.
is somewhat different in sense from
?Playing basketball, he hurt his knees.
, which - if it means much at all! - seems to be stating merely that the injury occurred while he was playing basketball, rather than - as is much more clearly implied by the original - as a direct result of it.
On account, therefore, of the relative unreliability of the fronted -ing transformation, my own preference is ultimately for the gerund analysis.
Student or Learner