You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to load an invalid trace file path, or anything that triggers an internal error message it will result in an access violation crash.
This is because of a missing "TTD::ErrorReporting" class with callbacks we need to add.
To fix this we need to first define the class.
It's actually pretty simple to locate if you have symbols.
The totally virtual base class is "TTD::ErrorReporting" ??_7ErrorReporting@TTD@@6B@
The actual derived instance is "TtdTargetInfo::DbgErrorReporting" ??_7DbgErrorReporting@TtdTargetInfo@@6B@
Recreated class:
namespaceTTD
{
// Error output callbacks for internal TTD errorsclassErrorReporting
{
public:virtual~ErrorReporting() {}
virtualvoidPrintError(const std::string &error) {}
virtualvoidVPrintError(LPCSTR format, ...) {}
};
static_assert(sizeof(ErrorReporting) == sizeof(ULONG_PTR), "Should be equal the size of a vftable");
}
By declaring all the members virtual in their original order, we will end up with virtual class with a single vftable (no need for wrappers or other tricks). Thus the size of the class will be sizeof(ULONG_PTR).
Then down in the "ReplayEngine" class we can now define "RegisterDebugModeAndLogging":
Don't know if there is any more "DebugModeType", in code seen is only a '0' type which I name "DefaultMode".
Now after creating a class instance, somewhere around here ReplayEngine::ReplayEngine() we can add this handler before returning.
// Set internal ErrorReporting callbacks to avoid crash when trace file path is invalid, etc.this->engine->IReplayEngine->RegisterDebugModeAndLogging(TTD::Replay::DefaultMode, new TTD::ErrorReporting());
Now after a failed ->Initialize(wchar_t const*) call it will not crash, and we can do a HRESULT_FROM_WIN32(GetLastError()) and we'll will get: a 0x80070002 "The system cannot find the file specified.".
The text was updated successfully, but these errors were encountered:
One caveat though it will crash in the "PrintError" function while debugging because the class fields (the data members) in "std::string" are different between the debug and the release versions. Of course the binary code we have is always release.
Now.. to get around this one can do a simple recreation that is always the release size:
Just replace the "const std::string &error" with "std_string &error".
Interesting, but didn't find the internal debug output particularly useful.
kweatherman
changed the title
Using an invalid trace file path crashed with access violation
Using an invalid trace file path crashes with an access violation
Nov 20, 2022
If you try to load an invalid trace file path, or anything that triggers an internal error message it will result in an access violation crash.
This is because of a missing "TTD::ErrorReporting" class with callbacks we need to add.
To fix this we need to first define the class.
It's actually pretty simple to locate if you have symbols.
The totally virtual base class is "TTD::ErrorReporting"
??_7ErrorReporting@TTD@@6B@
The actual derived instance is "TtdTargetInfo::DbgErrorReporting"
??_7DbgErrorReporting@TtdTargetInfo@@6B@
Recreated class:
By declaring all the members virtual in their original order, we will end up with virtual class with a single vftable (no need for wrappers or other tricks). Thus the size of the class will be
sizeof(ULONG_PTR)
.Then down in the "ReplayEngine" class we can now define "RegisterDebugModeAndLogging":
Don't know if there is any more "DebugModeType", in code seen is only a '0' type which I name "DefaultMode".
Now after creating a class instance, somewhere around here ReplayEngine::ReplayEngine() we can add this handler before returning.
Now after a failed
->Initialize(wchar_t const*)
call it will not crash, and we can do aHRESULT_FROM_WIN32(GetLastError())
and we'll will get: a 0x80070002 "The system cannot find the file specified.".The text was updated successfully, but these errors were encountered: