Fixup source offsets are signed values (and sometimes negative!).
This commit is contained in:
1 parent
17a64c9407
commit
c3d9945942
3 files changed
+14
-10
No files matched your search
@@ -162,7 +162,7 @@ static void parseExe(const char *exefname, uint8 *exe, uint32 exelen)
|
||||
printf("Object pages:\n");
|
||||
const LxObjectPageTableEntry *objpage = ((const LxObjectPageTableEntry *) (exe + lx->object_page_table_offset)) + (obj->page_table_index - 1);
|
||||
const uint32 *fixuppage = (((const uint32 *) (exe + lx->fixup_page_table_offset)) + (obj->page_table_index - 1));
|
||||
for (uint32 i = 0; i < obj->num_page_table_entries; i++, objpage++) {
|
||||
for (uint32 i = 0; i < obj->num_page_table_entries; i++, objpage++, fixuppage++) {
|
||||
printf("Object Page #%u:\n", (unsigned int) (i + obj->page_table_index));
|
||||
printf("Page data offset: 0x%X\n", (unsigned int) objpage->page_data_offset);
|
||||
printf("Page data size: %u\n", (unsigned int) objpage->data_size);
|
||||
@@ -222,8 +222,8 @@ static void parseExe(const char *exefname, uint8 *exe, uint32 exelen)
|
||||
srclist_count = *(fixup++);
|
||||
printf("Source offset list count: %u\n", (unsigned int) srclist_count);
|
||||
} else {
|
||||
const uint16 srcoffset = *((uint16 *) fixup); fixup += 2;
|
||||
printf("Source offset: %u\n", (unsigned int) srcoffset);
|
||||
const sint16 srcoffset = *((sint16 *) fixup); fixup += 2;
|
||||
printf("Source offset: %d\n", (int) srcoffset);
|
||||
} // else
|
||||
printf("\n");
|
||||
|
||||
@@ -298,8 +298,8 @@ static void parseExe(const char *exefname, uint8 *exe, uint32 exelen)
|
||||
if (srctype & 0x20) { // source list
|
||||
printf("Source offset list:");
|
||||
for (uint8 i = 0; i < srclist_count; i++) {
|
||||
const uint16 val = *((uint16 *) fixup); fixup += 2;
|
||||
printf(" %u", (unsigned int) val);
|
||||
const sint16 val = *((sint16 *) fixup); fixup += 2;
|
||||
printf(" %d", (int) val);
|
||||
} // for
|
||||
} // if
|
||||
|
||||
|
||||
+5
-5
@@ -390,7 +390,7 @@ static uint32 getModuleProcAddrByName(const LxModule *module, const char *name)
|
||||
} // getModuleProcAddrByName
|
||||
#endif
|
||||
|
||||
static void doFixup(uint8 *page, const uint16 offset, const uint32 finalval, const uint16 finalval2, const uint32 finalsize)
|
||||
static void doFixup(uint8 *page, const sint16 offset, const uint32 finalval, const uint16 finalval2, const uint32 finalsize)
|
||||
{
|
||||
#if 1
|
||||
if (finalsize == 6) {
|
||||
@@ -418,7 +418,7 @@ static void doFixup(uint8 *page, const uint16 offset, const uint32 finalval, con
|
||||
} // switch
|
||||
} // doFixup
|
||||
|
||||
static void fixupPage(const uint8 *exe, LxModule *lxmod, const LxObjectTableEntry *obj, const uint32 pagenum, uint8 *page)
|
||||
static void fixupPage(const uint8 *exe, LxModule *lxmod, const LxObjectTableEntry *obj, const uint32 pagenum, uint8 *page)
|
||||
{
|
||||
const LxHeader *lx = &lxmod->lx;
|
||||
const uint32 *fixuppage = (((const uint32 *) (exe + lx->fixup_page_table_offset)) + ((obj->page_table_index - 1) + pagenum));
|
||||
@@ -431,7 +431,7 @@ static void fixupPage(const uint8 *exe, LxModule *lxmod, const LxObjectTableEntr
|
||||
const uint8 srctype = *(fixup++);
|
||||
const uint8 fixupflags = *(fixup++);
|
||||
uint8 srclist_count = 0;
|
||||
uint16 srcoffset = 0;
|
||||
sint16 srcoffset = 0;
|
||||
|
||||
uint32 finalval = 0;
|
||||
uint16 finalval2 = 0;
|
||||
@@ -458,7 +458,7 @@ static void fixupPage(const uint8 *exe, LxModule *lxmod, const LxObjectTableEntr
|
||||
if (srctype & 0x20) { // contains a source list
|
||||
srclist_count = *(fixup++);
|
||||
} else {
|
||||
srcoffset = *((uint16 *) fixup);
|
||||
srcoffset = *((sint16 *) fixup);
|
||||
fixup += 2;
|
||||
} // else
|
||||
|
||||
@@ -547,7 +547,7 @@ static void fixupPage(const uint8 *exe, LxModule *lxmod, const LxObjectTableEntr
|
||||
|
||||
if (srctype & 0x20) { // source list
|
||||
for (uint8 i = 0; i < srclist_count; i++) {
|
||||
const uint16 offset = *((uint16 *) fixup); fixup += 2;
|
||||
const sint16 offset = *((sint16 *) fixup); fixup += 2;
|
||||
if ((srctype & 0xF) == 0x08) { // self-relative fixup?
|
||||
assert(finalval2 == 0);
|
||||
doFixup(page, offset, finalval - (((uint32)page)+offset+4), 0, finalsize);
|
||||
|
||||
@@ -12,6 +12,10 @@ typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
|
||||
typedef int8_t sint8;
|
||||
typedef int16_t sint16;
|
||||
typedef int32_t sint32;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct LxHeader
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user