| 140 | |
| 141 | |
| 142 | bool DbgEngTTDAdapter::Start() |
| 143 | { |
| 144 | if (this->m_debugActive) |
| 145 | this->Reset(); |
| 146 | |
| 147 | auto handle = GetModuleHandleA("dbgeng.dll"); |
| 148 | if (handle == nullptr) |
| 149 | false; |
| 150 | |
| 151 | // HRESULT DebugCreate( |
| 152 | // [in] REFIID InterfaceId, |
| 153 | // [out] PVOID *Interface |
| 154 | // ); |
| 155 | typedef HRESULT(__stdcall * pfunDebugCreate)(REFIID, PVOID*); |
| 156 | auto DebugCreate = (pfunDebugCreate)GetProcAddress(handle, "DebugCreate"); |
| 157 | if (DebugCreate == nullptr) |
| 158 | return false; |
| 159 | |
| 160 | if (const auto result = DebugCreate(__uuidof(IDebugClient7), reinterpret_cast<void**>(&this->m_debugClient)); |
| 161 | result != S_OK) |
| 162 | throw std::runtime_error("Failed to create IDebugClient7"); |
| 163 | |
| 164 | QUERY_DEBUG_INTERFACE(IDebugControl7, &this->m_debugControl); |
| 165 | QUERY_DEBUG_INTERFACE(IDebugDataSpaces, &this->m_debugDataSpaces); |
| 166 | QUERY_DEBUG_INTERFACE(IDebugRegisters, &this->m_debugRegisters); |
| 167 | QUERY_DEBUG_INTERFACE(IDebugSymbols3, &this->m_debugSymbols); |
| 168 | QUERY_DEBUG_INTERFACE(IDebugSystemObjects, &this->m_debugSystemObjects); |
| 169 | |
| 170 | m_debugEventCallbacks.SetAdapter(this); |
| 171 | if (const auto result = this->m_debugClient->SetEventCallbacks(&this->m_debugEventCallbacks); result != S_OK) |
| 172 | { |
| 173 | LogWarn("Failed to set event callbacks"); |
| 174 | return false; |
| 175 | } |
| 176 | |
| 177 | m_outputCallbacks.SetAdapter(this); |
| 178 | if (const auto result = this->m_debugClient->SetOutputCallbacks(&this->m_outputCallbacks); result != S_OK) |
| 179 | { |
| 180 | LogWarn("Failed to set output callbacks"); |
| 181 | return false; |
| 182 | } |
| 183 | |
| 184 | m_inputCallbacks.SetDbgControl(m_debugControl); |
| 185 | if (const auto result = this->m_debugClient->SetInputCallbacks(&this->m_inputCallbacks); result != S_OK) |
| 186 | { |
| 187 | LogWarn("Failed to set input callbacks"); |
| 188 | return false; |
| 189 | } |
| 190 | |
| 191 | this->m_debugActive = true; |
| 192 | return true; |
| 193 | } |
| 194 | |
| 195 | |
| 196 | void DbgEngTTDAdapter::Reset() |
nothing calls this directly
no test coverage detected