#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040\r
#endif\r
\r
-#ifndef IMAGE_DLLCHARACTERISTICS_NX_COMPAT \r
+#ifndef IMAGE_DLLCHARACTERISTICS_NX_COMPAT\r
#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100\r
#endif\r
- \r
+\r
namespace sw\r
{\r
#ifdef _M_AMD64\r
const unsigned char *function = (const unsigned char*)i->first;\r
const std::vector<Relocation> &functionRelocations = i->second;\r
unsigned int location = functionList[function]->location;\r
- \r
+\r
for(unsigned int j = 0; j < functionRelocations.size(); j++)\r
{\r
unsigned int address = location + functionRelocations[j].offset;\r
DOSheader.e_lfanew = sizeof(DOSheader);\r
\r
int base = 0x10000000;\r
- int codePage = pageAlign(sizeof(DOSheader) + AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32));\r
+ int codePage = pageAlign(sizeof(DOSheader) + (AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32)));\r
int exportsPage = codePage + pageAlign(codeSize);\r
int exportsSize = (int)(sizeof(IMAGE_EXPORT_DIRECTORY) + functionList.size() * sizeof(void*) + (strlen(dllName) + 1));\r
int relocPage = exportsPage + pageAlign(exportsSize);\r
textSection.Misc.VirtualSize = pageAlign(codeSize);\r
textSection.VirtualAddress = codePage;\r
textSection.SizeOfRawData = fileAlign(codeSize);\r
- textSection.PointerToRawData = fileAlign(sizeof(DOSheader) + AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32));\r
+ textSection.PointerToRawData = fileAlign(sizeof(DOSheader) + (AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32)));\r
textSection.PointerToRelocations = 0;\r
textSection.PointerToLinenumbers = 0;\r
textSection.NumberOfRelocations = 0;\r
if(file)\r
{\r
fwrite(&DOSheader, 1, sizeof(DOSheader), file);\r
- \r
+\r
if(AMD64)\r
{\r
fwrite(&COFFheader64, 1, sizeof(COFFheader64), file);\r
fwrite(&exportsSection, 1, sizeof(textSection), file);\r
fwrite(&relocSection, 1, sizeof(relocSection), file);\r
fwrite(&constSection, 1, sizeof(constSection), file);\r
- \r
+\r
for(FunctionList::iterator i = functionList.begin(); i != functionList.end(); i++)\r
{\r
const void *function = i->first;\r
fwrite(dllName, 1, strlen(dllName) + 1, file);\r
\r
fseek(file, relocSection.PointerToRawData, SEEK_SET);\r
- \r
+\r
for(PageRelocations::iterator i = pageRelocations.begin(); i != pageRelocations.end(); i++)\r
{\r
IMAGE_BASE_RELOCATION relocationBlock;\r