  We say that a subring $R_0$ of a ring $R$ is semi-invariant if $R_0$ is the
ring of invariants in $R$ under some set of ring endomorphisms of some ring
containing $R$. We show that $R_0$ is semi-invariant if and only if there is a
ring $S\supseteq R$ and a set $X\subseteq S$ such that $R_0=\Cent_R(X):={r\in R
\suchthat xr=rx \forall x\in X}$; in particular, centralizers of subsets of $R$
are semi-invariant subrings.
  We prove various properties of semi-invariant subrings and show how they can
be used for various applications including: (1) The center of a semiprimary
(resp. right perfect) ring is semiprimary (resp. right perfect). (2) If $M$ is
a finitely presented module over a "good" semiperfect ring (e.g. an inverse
limit of semiprimary rings), then $(M)$ is semiperfect, hence $M$ has a
Krull-Schmidt decomposition. (This generalizes results of Bjork and Rowen). (3)
If $\rho$ is a representation of a monoid or a ring over a module with a "good"
semiperfect endomorphism ring (in the sense of (2)), then $\rho$ has a
Krull-Schmidt decomposition. (4) If $S$ is a "good" commutative semiperfect
ring and $R$ is an $S$-algebra that is f.p.\ as an $S$-module, then $R$ is
semiperfect. (5) Let $R\subseteq S$ be rings and let $M$ be a right $S$-module.
If $(M_R)$ is semiprimary (resp. right perfect), then $(M_S)$ is semiprimary
(resp. right perfect).
