How do I determine the name of the counter associated with a theorem-like environment

\makeatletter
\def\getenvcounter#1{%
  \expandafter\expandafter\expandafter\@getenvcounter\csname mkheader@#1\endcsname}
\def\@getenvcounter\csname#1\endcsname#2#3#4#5{#4}
\makeatother

Explanation: \show\prop gives

> \prop=macro:
->\let \thm@starredenv \@undefined \csname mkheader@prop\endcsname .

Then \show\mkheader@prop gives

> \mkheader@prop=macro:
->\csname setparms@prop\endcsname \@thm {prop}{theorem}{Proposition}.

So I expand twice \csname mkheader@#1\endcsname, which gives the token list shown last and define \@getenvcounter accordingly.

The version for the LaTeX kernel definition (kept by amsthm) would be

\makeatletter
\def\getenvcounter#1{%
  \expandafter\expandafter\expandafter\@getenvcounter\csname#1\endcsname}
\def\@getenvcounter#1#2#3{#2}
\makeatother

Common version

If you prefer a version that doesn't depend on package loading, here it is:

\makeatletter
\def\getenvcounter#1{%
  \@ifundefined{mkheader@#1}
    {\expandafter\expandafter\expandafter\@getenvcounterkernel\csname#1\endcsname}
    {\expandafter\expandafter\expandafter\@getenvcounterntheorem\csname mkheader@#1\endcsname}}
\def\@getenvcounterkernel#1#2#3{#2}
\def\@getenvcounterntheorem\csname#1\endcsname#2#3#4#5{#4}
\makeatother

Version supporting also thmtools

\makeatletter
\def\getenvcounter#1{%
  \@ifundefined{mkheader@#1}
    {\expandafter\expandafter\expandafter\@getenvcounterkernel
     \csname\ifcsname thmt@original@#1\endcsname thmt@original@\fi#1\endcsname}
    {\expandafter\expandafter\expandafter\@getenvcounterntheorem\csname mkheader@#1\endcsname}}
\def\@getenvcounterkernel#1#2#3{#2}
\def\@getenvcounterntheorem\csname#1\endcsname#2#3#4#5{#4}
\makeatother