@@ -32,8 +32,12 @@ namespace peacock {
3232 if (!scanned)
3333 return nullptr ;
3434
35- PatchRegistry::instance ().add_version (identifier, std::move (*scanned));
36- return PatchRegistry::instance ().find_version (identifier);
35+ if (identifier != 0 ) {
36+ PatchRegistry::instance ().add_version (identifier, std::move (*scanned));
37+ return PatchRegistry::instance ().find_version (identifier);
38+ }
39+
40+ return new HitmanVersion (std::move (*scanned));
3741 }
3842
3943 // / Collect patches to apply based on user options.
@@ -91,6 +95,7 @@ namespace peacock {
9195 if (!Memory::write (task, addr, data_to_write.data (),
9296 data_to_write.size ())) {
9397 log (" Failed to write at offset 0x" + to_hex (patch->offset ));
98+ Memory::protect (task, addr, data_to_write.size (), old_prot, nullptr );
9499 return false ;
95100 }
96101
@@ -159,8 +164,15 @@ namespace peacock {
159164
160165 const auto patches = collect_patches (*version, options);
161166
162- // Build the custom URL bytes
167+ // Build the custom URL bytes (must fit in the configdomain buffer)
168+ static constexpr size_t kMaxConfigDomainLen = 256 ;
163169 const std::string &url = options.custom_config_domain ;
170+ if (url.size () >= kMaxConfigDomainLen ) {
171+ log (" Custom config domain too long (" + std::to_string (url.size ()) +
172+ " bytes, max " + std::to_string (kMaxConfigDomainLen - 1 ) + " )" );
173+ Memory::close_task (task);
174+ return false ;
175+ }
164176 std::vector<uint8_t > url_bytes (url.begin (), url.end ());
165177 url_bytes.push_back (0x00 );
166178
0 commit comments