Is there a way to define a material using only C++ and HLSL?

Depending on what your original HLSL code does, you may be able to use the custom expression in the Material Editor, which lets you enter raw HLSL code.