-------------------------------------------------------------------------
| 30 | |
| 31 | //------------------------------------------------------------------------- |
| 32 | void SetBreakPointsRange(HANDLE hProcess, |
| 33 | AddressesIt begin, |
| 34 | AddressesIt end, |
| 35 | BreakPoint::InstructionCollection& oldInstructions) |
| 36 | { |
| 37 | if (begin == end) |
| 38 | return; |
| 39 | |
| 40 | auto firstValue = *begin; |
| 41 | auto memorySpaceSize = |
| 42 | *(end - 1) - firstValue + sizeof(BreakPoint::breakPointInstruction); |
| 43 | auto firstAddress = reinterpret_cast<void*>(firstValue); |
| 44 | auto buffer = Tools::ReadProcessMemory( |
| 45 | hProcess, firstAddress, static_cast<size_t>(memorySpaceSize)); |
| 46 | |
| 47 | for (auto it = begin; it < end; ++it) |
| 48 | { |
| 49 | auto index = static_cast<size_t>(*it - firstValue); |
| 50 | auto oldInstruction = buffer[index]; |
| 51 | buffer[index] = BreakPoint::breakPointInstruction; |
| 52 | oldInstructions.emplace_back(oldInstruction, *it); |
| 53 | } |
| 54 | Tools::WriteProcessMemory( |
| 55 | hProcess, firstAddress, &buffer[0], buffer.size()); |
| 56 | } |
| 57 | |
| 58 | const unsigned char BreakPoint::breakPointInstruction = 0xCC; |
| 59 |
no test coverage detected