After reading the answer of Heiko Oberdiek, I understood (at least something of) the meaning of the original code.
After reading the answer of Steven B. Segletes, I could simplify the original code to
\Longstack{%
\raisebox{+2ex}{X}\cr%
\raisebox{-1ex}{X}\cr%
}
(with package and configuration as in Steven B. Segletes' answer).
Just to get height and depth of this, also measuring the replacement
\raisebox{+2ex}{X}
\raisebox{-1ex}{X}
works, i.e.
\newlength\myHeight
\newlength\myDepth
\settoheight{\myHeight}{%
\raisebox{+2ex}{\vphantom{X}}%
\raisebox{-1ex}\vphantom{{X}}% this line only needed when this "lower X"
% would reach higher than the "upper X"
}%
\settodepth{\myDepth}{%
\raisebox{+2ex}{\vphantom{X}}% this line only needed when this "higher X"
% would reach deeper than the "lower X"
\raisebox{-1ex}{\vphantom{X}}%
}%
where I added \vphantoms for the case when "XX" is wider than \textwidth (but neither "higher X" nor "lower X" is wider).
Then
\hbox{\vrule\@height\myHeight%
\@depth\myDepth%
\@width\z@}
has height and depth of the \ooalign{...} (and width zero).
MWE:
\documentclass{article}
\newlength\myHeight
\newlength\myDepth
\begin{document}
\makeatletter
\hrule
\ooalign{\relax\cr%
\noalign{\vskip-2ex}{X}\cr%
\noalign{\vskip+2ex}\cr%
\noalign{\vskip+1ex}{X}\cr%
\noalign{\vskip-1ex}%
}%
%
\settoheight{\myHeight}{%
\raisebox{+2ex}{\vphantom{X}}%
\raisebox{-1ex}\vphantom{{X}}%
}%
\settodepth{\myDepth}{%
\raisebox{+2ex}{\vphantom{X}}%
\raisebox{-1ex}{\vphantom{X}}%
}%
\hbox{\vrule\@height\myHeight%
\@depth\myDepth%
\@width\z@}%
\hrule
\makeatother
\end{document}
resulting in this output:

(which I would have never come to without the other two answers - thanks!).