I thought I read a few years back that C++ is officially supported building drivers. I've long before time used C++ (no exceptions/implemented new/delete versions using ExAllocatePool / ExFreePool) , however now if I don't include those overrides it says there is no "new" or "delete", if I include <new> to override it complains about exception handling (even though the header file is in a /km/ sub-directory). What's available and proper way to now implement my own new/delete (the old method has some issues)?
C++ is supported. You need to provide your own operator new and operator delete that calls ExAllocPool and friends. The include file <kcom.h> contains implementations of both.
Is it only the global objects? Funny, I was just looking at the new implementation and thought, does this call the constructor, but it had always worked in the past (I could look at the disassembly).
Well, the operator doesn't, but the compiler does. "new" is not involved with global objects.
Global object constructors are a strange little quirk in C++. The compiler puts the objects and the constructor address in a special section of the binary surrounded by special symbol names. The runtime initialization then starts at the "begin" symbol and initializes everything up to the "end" symbol. However, a kernel driver doesn't undergo runtime initialization.
Note also that if you don't want to have a global new and delete or if they exist but you don't want to use them you can add "operator new" and "operator delete" as member functions to each of your classes and they will be called instead of the global ones.
Actually, we can live without global object constructors being invoked.
I would recommend studying GitHub - jxy-s/stlkrn: C++ STL in the Windows Kernel with C++ Exception Support. We can use most of the std like vector, smart pointers so on, with few exceptions, I had to implement my self the std::function and some kind of shared pointer. The library also adds scoped exit objects used to replace ugly cleanup and much more...
Also exceptions are supported, though me personally I made a fork with no exceptions support.