diff --git a/LEGO1/mxdirectdraw.cpp b/LEGO1/mxdirectdraw.cpp index 923459ed..12a7cde0 100644 --- a/LEGO1/mxdirectdraw.cpp +++ b/LEGO1/mxdirectdraw.cpp @@ -372,7 +372,7 @@ BOOL MxDirectDraw::DDSetMode(int width, int height, int bpp) m_bIgnoreWMSIZE = TRUE; dwStyle = GetWindowLong(m_hWndMain, GWL_STYLE); - dwStyle &= ~(WS_POPUP | WS_CAPTION | WS_THICKFRAME | WS_OVERLAPPED); + dwStyle &= ~WS_POPUP; dwStyle |= WS_CAPTION | WS_THICKFRAME | WS_OVERLAPPED; SetWindowLong(m_hWndMain, GWL_STYLE, dwStyle); diff --git a/tools/isledecomp/isledecomp/bin.py b/tools/isledecomp/isledecomp/bin.py index bee28444..1aec9330 100644 --- a/tools/isledecomp/isledecomp/bin.py +++ b/tools/isledecomp/isledecomp/bin.py @@ -72,6 +72,7 @@ class Bin: self.imagebase = None self.sections = [] self.last_section = None + self._relocated_addrs = set() def __enter__(self): self._debuglog(f"Bin {self.filename} Enter") @@ -100,6 +101,8 @@ class Bin: for i in range(pe_hdr.NumberOfSections) ] + self._populate_relocations() + text_section = self._get_section_by_name(".text") self.last_section = text_section @@ -116,6 +119,52 @@ class Bin: if self.logger is not None: self.logger.debug(msg) + def get_relocated_addresses(self): + return sorted(self._relocated_addrs) + + def is_relocated_addr(self, vaddr) -> bool: + return vaddr in self._relocated_addrs + + def _populate_relocations(self): + """The relocation table in .reloc gives each virtual address where the next four + bytes are, itself, another virtual address. During loading, these values will be + patched according to the virtual address space for the image, as provided by Windows. + We can use this information to get a list of where each significant "thing" + in the file is located. Anything that is referenced absolutely (i.e. excluding + jump destinations given by local offset) will be here. + One use case is to tell whether an immediate value in an operand represents + a virtual address or just a big number.""" + + ofs = self.get_section_offset_by_name(".reloc") + reloc_addrs = [] + + # Parse the structure in .reloc to get the list locations to check. + # The first 8 bytes are 2 dwords that give the base page address + # and the total block size (including this header). + # The page address is used to compact the list; each entry is only + # 2 bytes, and these are added to the base to get the full location. + # If the entry read in is zero, we are at the end of this section and + # these are padding bytes. + while True: + (page_base, block_size) = struct.unpack("<2I", self.read(ofs, 8)) + if block_size == 0: + break + + # HACK: ignore the relocation type for now (the top 4 bits of the value). + values = list(struct.iter_unpack("= file.get_section_offset_by_index(1): + if file.is_relocated_addr(inttest): words[i] = placeholder_generator.get(inttest) except ValueError: pass