.($functype eq "patches" ? "captive_ModuleList_patch" : "captive_ModuleList_add_builtin")
."(\"$module\",\n";
for my $symbol (sort keys(%$moduleref)) {
- next if $functype eq "patches" && (!$def{$symbol} || "data" eq $def{$symbol}{"type"});
+ next if $functype eq "patches" && !$def{$symbol};
print "\t\t\t\"$symbol\",&${symbol}_",
($def{$symbol}{"type"} || "undef"),
- (($functype ne "patches") ? () : (",&${symbol}_patchpoint")),
+ (($functype ne "patches") ? () : (",".("data" eq $def{$symbol}{"type"} ? "NULL" : "&${symbol}_patchpoint"))),
",\n";
}
print <<"HERE";
ExportAddressp=(PVOID *)(FunctionList+OrdinalList[Idx]);
ExportAddress=(PVOID)MODULEOBJECT_BASE_OFFSET_PLUS(*ExportAddressp);
if (0xF4 /* hlt */ ==*(guint8 *)ExportAddress) {
+ /* FIXME: 'data' type symbols should be permitted to have 0xF4 byte */
g_error("%s: Function already patched although we did not touch it yet: %s",G_STRLOC,funcname);
g_assert_not_reached();
}
while (captive_va_arg(sym_name,ap)) {
captive_va_arg(sym_val ,ap);
g_assert(sym_val!=NULL);
- captive_va_arg(patchpoint,ap);
- g_assert(patchpoint!=NULL);
+ captive_va_arg(patchpoint,ap); /* 'data' type if ==NULL */
ExportAddressp=g_hash_table_lookup(exportdir_hash,sym_name);
if (ExportAddressp==NULL) {
g_error("%s: Function not found for patchpoint: %s",G_STRLOC,sym_name);
errbool=g_hash_table_remove(exportdir_hash,sym_name);
g_assert(errbool==TRUE);
ExportAddress=(PVOID)MODULEOBJECT_BASE_OFFSET_PLUS(*ExportAddressp);
+ *ExportAddressp=(PVOID)MODULEOBJECT_BASE_OFFSET_MINUS(sym_val);
if (((ULONG)ExportAddress >= (ULONG)ExportDir) &&
((ULONG)ExportAddress < (ULONG)ExportDir + ExportDirSize))
g_assert_not_reached(); /* LdrPEFixupForward() needed */
+ if (!patchpoint) /* 'data' type */
+ continue;
patchpoint->orig_w32_func=ExportAddress;
g_assert(0xF4 /* hlt */ !=*patchpoint->orig_w32_func);
patchpoint->orig_w32_2ndinstr=patchpoint->orig_w32_func
patchpoint->orig_w32_2ndinstr, /* key */
patchpoint); /* value */
*(guint8 *)ExportAddress=0xF4; /* hlt */
- *ExportAddressp=(PVOID)MODULEOBJECT_BASE_OFFSET_MINUS(sym_val);
}
va_end(ap);