MCPcopy Create free account
hub / github.com/NetSPI/BOF-PE / GetExceptionTables

Function GetExceptionTables

loader/mappedmodule.cpp:169–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169static const PVOID GetExceptionTables(const Pe::PeNative& mappedPe, ULONG& size) {
170
171 size = (ULONG)(-1);
172 auto result = PVOID(-1);
173
174#if defined(_X86_)
175
176 if (mappedPe.headers().opt()->DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NO_SEH)
177 return result;
178
179 auto loadConfigDir = mappedPe.directory(IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG);
180 auto loadConfig = mappedPe.byRva<IMAGE_LOAD_CONFIG_DIRECTORY32>(loadConfigDir->VirtualAddress);
181
182 if (loadConfigDir->VirtualAddress && loadConfigDir->Size && loadConfig->SEHandlerCount && loadConfig->SEHandlerTable) {
183 result = PVOID(loadConfig->SEHandlerTable);
184 size = sizeof(IMAGE_RUNTIME_FUNCTION_ENTRY) * loadConfig->SEHandlerCount;
185 }
186 else {
187 result = nullptr;
188 size = 0;
189 }
190
191#else
192
193 result = (PVOID)mappedPe.exceptions().descriptor().ptr;
194 size = mappedPe.exceptions().descriptor().size;
195
196#endif
197
198 return result;
199}
200
201static RTL_INVERTED_FUNCTION_TABLE* FindLdrpInvertedFunctionTable(uintptr_t& mrDataPtr, DWORD& mrDataSize) {
202

Callers 3

AddExceptionSupportFunction · 0.85
RemoveExceptionSupportFunction · 0.85

Calls 5

optMethod · 0.80
headersMethod · 0.80
directoryMethod · 0.80
exceptionsMethod · 0.80
descriptorMethod · 0.45

Tested by

no test coverage detected