Update Packet.cpp

validated count-replacement helper.
This commit is contained in:
carman24r 2026-09-29 16:06:41 -04:00 committed by GitHub
parent 94035e6367
commit 5afbeca23c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -159,4 +159,11 @@ void PatchIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32
packet[4] += count;
}
void SetIndirectCount(std::uint32_t* packet, std::uint32_t opcode, std::uint32_t count, const char* function) {
ValidatePacket(packet, opcode, 5, function);
Require(packet[3] == 0x80000000u && packet[4] <= 0x3fffu, function, "invalid indirect register packet");
CheckBits(count, 0x3fffu, function);
packet[4] = count;
}
}