Validate all parameters Injection context Error code
| 229 | /// <param name="context">Injection context</param> |
| 230 | /// <returns>Error code</returns> |
| 231 | NTSTATUS InjectionCore::ValidateContext( InjectContext& context, const blackbone::pe::PEImage& img ) |
| 232 | { |
| 233 | // Invalid path |
| 234 | if (context.images.empty()) |
| 235 | { |
| 236 | Message::ShowError( _hMainDlg, L"Please add at least one image to inject" ); |
| 237 | return STATUS_INVALID_PARAMETER_1; |
| 238 | } |
| 239 | |
| 240 | // Validate driver |
| 241 | if (context.cfg.injectMode == Kernel_DriverMap) |
| 242 | { |
| 243 | // Only x64 drivers are supported |
| 244 | if (img.mType() != blackbone::mt_mod64) |
| 245 | { |
| 246 | Message::ShowError( _hMainDlg, L"Can't map x86 drivers - '" + img.name() + L"'" ); |
| 247 | return STATUS_INVALID_IMAGE_WIN_32; |
| 248 | } |
| 249 | |
| 250 | // Image must be native |
| 251 | if (img.subsystem() != IMAGE_SUBSYSTEM_NATIVE) |
| 252 | { |
| 253 | Message::ShowError( _hMainDlg, L"Can't map image with non-native subsystem - '" + img.name() + L"'" ); |
| 254 | return STATUS_INVALID_IMAGE_HASH; |
| 255 | } |
| 256 | |
| 257 | return STATUS_SUCCESS; |
| 258 | } |
| 259 | |
| 260 | // No process selected |
| 261 | if (!_process.valid()) |
| 262 | { |
| 263 | Message::ShowError( _hMainDlg, L"Please select valid process before injection" ); |
| 264 | return STATUS_INVALID_HANDLE; |
| 265 | } |
| 266 | |
| 267 | auto& barrier = _process.barrier(); |
| 268 | |
| 269 | // Validate architecture |
| 270 | if (!img.pureIL() && img.mType() == blackbone::mt_mod32 && barrier.targetWow64 == false) |
| 271 | { |
| 272 | Message::ShowError( _hMainDlg, L"Can't inject 32 bit image '" + img.name() + L"' into native 64 bit process" ); |
| 273 | return STATUS_INVALID_IMAGE_WIN_32; |
| 274 | } |
| 275 | |
| 276 | // Trying to inject x64 dll into WOW64 process |
| 277 | if (!img.pureIL() && img.mType() == blackbone::mt_mod64 && barrier.targetWow64 == true) |
| 278 | { |
| 279 | Message::ShowError( _hMainDlg, L"Can't inject 64 bit image '" + img.name() + L"' into WOW64 process" ); |
| 280 | return STATUS_INVALID_IMAGE_WIN_64; |
| 281 | } |
| 282 | |
| 283 | // Can't inject managed dll through WOW64 barrier |
| 284 | /*if (img.pureIL() && (barrier.type == blackbone::wow_32_64 || barrier.type == blackbone::wow_64_32)) |
| 285 | { |
| 286 | if (barrier.type == blackbone::wow_32_64) |
| 287 | Message::ShowWarning( _hMainDlg, L"Please use Xenos64.exe to inject managed dll '" + img.name() + L"' into x64 process" ); |
| 288 | else |