MCPcopy Create free account
hub / github.com/lief-project/LIEF / parse

Method parse

src/PE/LoadConfigurations/DynamicRelocation/DynamicFixup.cpp:32–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30using IMAGE_DYNAMIC_RELOCATION = DynamicRelocation::IMAGE_DYNAMIC_RELOCATION;
31
32ok_error_t DynamicFixup::parse(Parser& ctx, SpanStream& stream, DynamicRelocation& R) {
33 auto default_ret = std::make_unique<DynamicFixupUnknown>(stream.content());
34 if (R.symbol() == IMAGE_DYNAMIC_RELOCATION::RELOCATION_FUNCTION_OVERRIDE) {
35 LIEF_DEBUG("IMAGE_DYNAMIC_RELOCATION_FUNCTION_OVERRIDE");
36 auto func = FunctionOverride::parse(ctx, stream);
37 if (func != nullptr) {
38 R.fixups(std::move(func));
39 return ok();
40 }
41 LIEF_DEBUG("Error: {}:{}", __FUNCTION__, __LINE__);
42 R.fixups(std::move(default_ret));
43 return make_error_code(lief_errors::parsing_error);
44 }
45
46 if (R.symbol() == IMAGE_DYNAMIC_RELOCATION::RELOCATION_ARM64X) {
47 LIEF_DEBUG("IMAGE_DYNAMIC_RELOCATION_ARM64X");
48 auto arm64x_fixups = DynamicFixupARM64X::parse(ctx, stream);
49 if (arm64x_fixups != nullptr) {
50 R.fixups(std::move(arm64x_fixups));
51 return ok();
52 }
53 LIEF_DEBUG("Error: {}:{}", __FUNCTION__, __LINE__);
54 R.fixups(std::move(default_ret));
55 return make_error_code(lief_errors::parsing_error);
56 }
57
58 if (R.symbol() == IMAGE_DYNAMIC_RELOCATION::RELOCATION_ARM64_KERNEL_IMPORT_CALL_TRANSFER) {
59 // Note(romain): According to link.exe there is a special processing for
60 // this symbol (c.f. 0x140164140 in link.exe from 14.42.34433)
61 //
62 // Sample: win11-arm64/sources/winsetupmon.sys
63 auto fixups = DynamicFixupARM64Kernel::parse(ctx, stream);
64 if (fixups != nullptr) {
65 R.fixups(std::move(fixups));
66 return ok();
67 }
68 LIEF_DEBUG("Error: {}:{}", __FUNCTION__, __LINE__);
69 R.fixups(std::move(default_ret));
70 return make_error_code(lief_errors::parsing_error);
71 }
72
73 if (R.symbol() == IMAGE_DYNAMIC_RELOCATION::RELOCATION_GUARD_IMPORT_CONTROL_TRANSFER) {
74 LIEF_DEBUG("IMAGE_DYNAMIC_RELOCATION_GUARD_IMPORT_CONTROL_TRANSFER");
75 auto fixups = DynamicFixupControlTransfer::parse(ctx, stream);
76 if (fixups != nullptr) {
77 R.fixups(std::move(fixups));
78 return ok();
79 }
80 LIEF_DEBUG("Error: {}:{}", __FUNCTION__, __LINE__);
81 R.fixups(std::move(default_ret));
82 return make_error_code(lief_errors::parsing_error);
83 }
84
85 auto generic = DynamicFixupGeneric::parse(ctx, stream);
86 if (generic != nullptr) {
87 R.fixups(std::move(generic));
88 return ok();
89 }

Callers

nothing calls this directly

Calls 6

okFunction · 0.85
make_error_codeFunction · 0.85
parseFunction · 0.50
contentMethod · 0.45
symbolMethod · 0.45
fixupsMethod · 0.45

Tested by

no test coverage detected