Remove .dll extension from forwards (lookup failure causes crashes on some 2k8/w7 hosts)

This commit is contained in:
Nick Landers
2020-07-06 08:47:53 -06:00
parent 40c67226c1
commit c2eafe11e6
4 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ int main() {
HMODULE module = LoadLibrary(L"Theif.dll"); HMODULE module = LoadLibrary(L"Theif.dll");
if (!module) return 1; if (!module) return 1;
DynExport Dynamic = (DynExport)GetProcAddress(module, "Mucklow"); DynExport Dynamic = (DynExport)GetProcAddress(module, "Dynamic");
if (!Dynamic) return 1; if (!Dynamic) return 1;
if (Dynamic()) { if (Dynamic()) {
+3
View File
@@ -83,6 +83,9 @@ namespace NetClone
} }
static void CloneExports(ref PeFile target, PeFile reference, string referencePath, string sectionName) static void CloneExports(ref PeFile target, PeFile reference, string referencePath, string sectionName)
{ {
// Forwards don't typically supply an extension
referencePath = referencePath.Replace(".dll", "");
IMAGE_DATA_DIRECTORY tgtExportDirectory = target.ImageNtHeaders.OptionalHeader.DataDirectory[0]; IMAGE_DATA_DIRECTORY tgtExportDirectory = target.ImageNtHeaders.OptionalHeader.DataDirectory[0];
IMAGE_DATA_DIRECTORY refExportDirectory = reference.ImageNtHeaders.OptionalHeader.DataDirectory[0]; IMAGE_DATA_DIRECTORY refExportDirectory = reference.ImageNtHeaders.OptionalHeader.DataDirectory[0];
+3
View File
@@ -67,6 +67,9 @@ def add_section(pe, name, size, characteristics = DEFAULT_CHARACTERISTICS):
def _clone_exports(tgt, ref, ref_path, new_section_name = '.rdata2'): def _clone_exports(tgt, ref, ref_path, new_section_name = '.rdata2'):
# Forwards don't typically supply the extension
ref_path = ref_path.replace('.dll', '')
ref = copy.deepcopy(ref) ref = copy.deepcopy(ref)
tgt = copy.deepcopy(tgt) tgt = copy.deepcopy(tgt)
+2 -2
View File
@@ -9,8 +9,8 @@ BOOL RebuildExportTable(PBYTE ourBase, PBYTE targetBase);
#ifdef _FORWARD #ifdef _FORWARD
#pragma comment(linker,"/export:Static=Functions.dll.Static") #pragma comment(linker,"/export:Static=Functions.Static")
#pragma comment(linker,"/export:Dynamic=Functions.dll.Dynamic") #pragma comment(linker,"/export:Dynamic=Functions.Dynamic")
#else #else