MCPcopy Create free account
hub / github.com/beefytech/Beef / PatchOneModuleLocked

Function PatchOneModuleLocked

BeefRT/gperftools/src/windows/patch_functions.cc:620–640  ·  view source on GitHub ↗

You should hold the patch_all_modules_lock when calling this.

Source from the content-addressed store, hash-verified

618
619// You should hold the patch_all_modules_lock when calling this.
620void PatchOneModuleLocked(const LibcInfo& me_info) {
621 // If we don't already have info on this module, let's add it. This
622 // is where we're sad that each libcX has a different type, so we
623 // can't use an array; instead, we have to use a switch statement.
624 // Patch() returns false if there were no libc functions in the module.
625 for (int i = 0; i < sizeof(g_module_libcs)/sizeof(*g_module_libcs); i++) {
626 if (!g_module_libcs[i]->is_valid()) { // found an empty spot to add!
627 switch (i) {
628 case 0: libc1.Patch(me_info); return;
629 case 1: libc2.Patch(me_info); return;
630 case 2: libc3.Patch(me_info); return;
631 case 3: libc4.Patch(me_info); return;
632 case 4: libc5.Patch(me_info); return;
633 case 5: libc6.Patch(me_info); return;
634 case 6: libc7.Patch(me_info); return;
635 case 7: libc8.Patch(me_info); return;
636 }
637 }
638 }
639 printf("PERFTOOLS ERROR: Too many modules containing libc in this executable\n");
640}
641
642void PatchMainExecutableLocked() {
643 if (main_executable.patched())

Callers 1

PatchAllModulesFunction · 0.70

Calls 2

is_validMethod · 0.45
PatchMethod · 0.45

Tested by

no test coverage detected