a quick hack to set the 32bit flag in corheader
This commit is contained in:
6
Makefile
6
Makefile
@@ -155,9 +155,12 @@ OpenRA.TilesetBuilder.Form1.resources:
|
|||||||
tools: editor ralint seqed filex tsbuild
|
tools: editor ralint seqed filex tsbuild
|
||||||
all: game tools
|
all: game tools
|
||||||
|
|
||||||
|
fixheader: packaging/fixheader.cs
|
||||||
|
@$(CSC) packaging/fixheader.cs $(CSFLAGS) -out:fixheader.exe -t:exe $(COMMON_LIBS:%=-r:%)
|
||||||
|
|
||||||
define BUILD_ASSEMBLY
|
define BUILD_ASSEMBLY
|
||||||
|
|
||||||
$$($(1)_TARGET): $$($(1)_SRCS) Makefile $$($(1)_DEPS)
|
$$($(1)_TARGET): $$($(1)_SRCS) Makefile $$($(1)_DEPS) fixheader
|
||||||
@echo CSC $$(@)
|
@echo CSC $$(@)
|
||||||
@$(CSC) $$($(1)_LIBS:%=-r:%) \
|
@$(CSC) $$($(1)_LIBS:%=-r:%) \
|
||||||
-out:$$(@) $(CSFLAGS) $$($(1)_FLAGS) \
|
-out:$$(@) $(CSFLAGS) $$($(1)_FLAGS) \
|
||||||
@@ -165,6 +168,7 @@ $$($(1)_TARGET): $$($(1)_SRCS) Makefile $$($(1)_DEPS)
|
|||||||
-t:"$$($(1)_KIND)" \
|
-t:"$$($(1)_KIND)" \
|
||||||
$$($(1)_EXTRA) \
|
$$($(1)_EXTRA) \
|
||||||
$$($(1)_SRCS)
|
$$($(1)_SRCS)
|
||||||
|
@mono fixheader.exe $$(@)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach prog,$(PROGRAMS),$(eval $(call BUILD_ASSEMBLY,$(prog))))
|
$(foreach prog,$(PROGRAMS),$(eval $(call BUILD_ASSEMBLY,$(prog))))
|
||||||
|
|||||||
42
packaging/fixheader.cs
Normal file
42
packaging/fixheader.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace fixheader
|
||||||
|
{
|
||||||
|
class fixheader
|
||||||
|
{
|
||||||
|
static byte[] data;
|
||||||
|
static int peOffset;
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
data = File.ReadAllBytes(args[0]);
|
||||||
|
peOffset = BitConverter.ToInt32(data, 0x3c);
|
||||||
|
var corHeaderRva = BitConverter.ToInt32(data, peOffset + 20 + 100 + 14 * 8);
|
||||||
|
var corHeaderOffset = RvaToOffset(corHeaderRva);
|
||||||
|
|
||||||
|
data[corHeaderOffset + 16] |= 2;
|
||||||
|
|
||||||
|
File.WriteAllBytes(args[0], data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int RvaToOffset(int va)
|
||||||
|
{
|
||||||
|
var numSections = BitConverter.ToInt16(data, peOffset + 6);
|
||||||
|
var numDataDirectories = BitConverter.ToInt32(data, peOffset + 24 + 92);
|
||||||
|
var sectionTableStart = peOffset + 24 + 96 + 8 * numDataDirectories;
|
||||||
|
|
||||||
|
for (var i = 0; i < numSections; i++)
|
||||||
|
{
|
||||||
|
var virtualSize = BitConverter.ToInt32(data, sectionTableStart + 40 * i + 8);
|
||||||
|
var virtualAddr = BitConverter.ToInt32(data, sectionTableStart + 40 * i + 12);
|
||||||
|
var fileOffset = BitConverter.ToInt32(data, sectionTableStart + 40 * i + 20);
|
||||||
|
|
||||||
|
if (va >= virtualAddr && va < virtualAddr + virtualSize)
|
||||||
|
return va - virtualAddr + fileOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user