File size: 1,628 Bytes
2edf277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// FCS Glass - src/test/probe_main.cpp
//
// The console entry point for fcs_selftest (REQ sec 16).
//
// This lives in its own file rather than in platform.cpp for a concrete reason:
// platform.cpp is in FCS_CORE_SOURCES, which BOTH executables link. fcs_glass is
// a WIN32-subsystem app whose entry point is wWinMain (src/app/main.cpp), so a
// `main` in a shared translation unit would put a second entry point into the GUI
// binary. Keeping the probe's main separate means each target has exactly one.
//
// It had never been linked by CMake at all - every earlier M0a build supplied its
// own main() from a temporary harness - which is why the canonical build reported
// LNK2019 unresolved external `main`.
//
// COM is initialised here rather than inside the probe: apartment selection is a
// per-thread contract and does not carry to another thread, and the probe creates
// the D3D/DComp objects on this one. COINIT_APARTMENTTHREADED matches what the UI
// process wants (HC3/D-5: the UI is its own process and never a COM server).

#include "platform/platform.h"

#include <cstdio>

namespace fcs {
int ProbeMain(HINSTANCE instance);   // defined in src/test/probe.cpp
}  // namespace fcs

int main() {
  fcs::ScopedCoInitialize com(COINIT_APARTMENTTHREADED);
  if (!com.ok()) {
    std::fprintf(stderr, "CoInitializeEx failed; the probe cannot run (hr=0x%08lX)\n",
                 static_cast<unsigned long>(com.hr()));
    return 2;
  }
  // The probe's exit code is the scriptable result: 0 only when no row FAILed.
  return fcs::ProbeMain(::GetModuleHandleW(nullptr));
}