Merge branch 'master' into MxObjectFactory-create

This commit is contained in:
MattKC 2023-07-01 23:55:04 -07:00 committed by GitHub
commit 94c941f09d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 202 additions and 73 deletions

View File

@ -1,10 +1,6 @@
name: Build name: Build
on: on: [push, pull_request]
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs: jobs:
build: build:
@ -61,6 +57,27 @@ jobs:
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "NMake Makefiles" cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "NMake Makefiles"
cmake --build . cmake --build .
- name: Upload Artifact
uses: actions/upload-artifact@master
with:
name: Win32
path: |
build/ISLE.EXE
build/ISLE.PDB
build/LEGO1.DLL
build/LEGO1.PDB
compare:
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@master
- uses: actions/download-artifact@master
with:
name: Win32
path: build
- name: Restore cached original binaries - name: Restore cached original binaries
id: cache-original-binaries id: cache-original-binaries
uses: actions/cache/restore@v3 uses: actions/cache/restore@v3
@ -103,14 +120,6 @@ jobs:
run: | run: |
python3 tools/verexp/verexp.py legobin/LEGO1.DLL build/LEGO1.DLL python3 tools/verexp/verexp.py legobin/LEGO1.DLL build/LEGO1.DLL
- name: Upload Artifact
uses: actions/upload-artifact@master
with:
name: Win32
path: |
build/ISLE.EXE
build/LEGO1.DLL
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
@ -118,15 +127,30 @@ jobs:
path: | path: |
ISLEPROGRESS.* ISLEPROGRESS.*
LEGO1PROGRESS.* LEGO1PROGRESS.*
upload:
needs: [build, compare]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v3
with:
repository: 'probonopd/uploadtool'
- uses: actions/download-artifact@master
with:
name: Win32
path: build
- uses: actions/download-artifact@master
with:
name: Accuracy Report
- name: Upload Continuous Release - name: Upload Continuous Release
shell: bash
if: github.event_name == 'push'
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPLOAD_KEY: ${{ secrets.UPLOAD_KEY }} UPLOAD_KEY: ${{ secrets.UPLOAD_KEY }}
run: | run: |
curl -fLOSs https://raw.githubusercontent.com/probonopd/uploadtool/master/upload.sh
./upload.sh \ ./upload.sh \
build/ISLE.EXE \ build/ISLE.EXE \
build/LEGO1.DLL \ build/LEGO1.DLL \

View File

@ -1,9 +1,8 @@
#ifndef LEGOINPUTMANAGER_H #ifndef LEGOINPUTMANAGER_H
#define LEGOINPUTMANAGER_H #define LEGOINPUTMANAGER_H
#include "mxpresenter.h"
#include "decomp.h" #include "decomp.h"
#include "mxpresenter.h"
enum NotificationId enum NotificationId
{ {

View File

@ -14,15 +14,75 @@ MxBitmap::MxBitmap()
// OFFSET: LEGO1 0x100bca10 // OFFSET: LEGO1 0x100bca10
MxBitmap::~MxBitmap() MxBitmap::~MxBitmap()
{ {
if (this->m_info != NULL) { if (this->m_info != NULL)
delete m_info; delete m_info;
} if (this->m_data != NULL)
if (this->m_data != NULL) {
delete m_data; delete m_data;
} if (this->m_palette != NULL)
if (this->m_palette != NULL) {
delete m_palette; delete m_palette;
} }
// OFFSET: LEGO1 0x100bcc40 STUB
int MxBitmap::vtable14(int)
{
return 0;
}
// OFFSET: LEGO1 0x100bcba0 STUB
int MxBitmap::vtable18(BITMAPINFOHEADER *p_bmiHeader)
{
return 0;
}
// OFFSET: LEGO1 0x100bcaa0 STUB
int MxBitmap::vtable1c(int p_width, int p_height, MxPalette *p_palette, int)
{
return 0;
}
// OFFSET: LEGO1 0x100bcd60 STUB
MxResult MxBitmap::LoadFile(HANDLE p_handle)
{
return SUCCESS;
}
// OFFSET: LEGO1 0x100bcd10
long MxBitmap::Read(const char *p_filename)
{
MxResult result = FAILURE;
HANDLE handle = CreateFileA(
p_filename,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if (handle != INVALID_HANDLE_VALUE && !LoadFile(handle))
result = SUCCESS;
if (handle)
CloseHandle(handle);
return result;
}
// OFFSET: LEGO1 0x1004e0d0
int MxBitmap::vtable28(int)
{
return -1;
}
// OFFSET: LEGO1 0x100ce70 STUB
void MxBitmap::vtable2c(int, int, int, int, int, int, int)
{
}
// OFFSET: LEGO1 0x100d020 STUB
void MxBitmap::vtable30(int, int, int, int, int, int, int)
{
} }
// OFFSET: LEGO1 0x100bd1c0 // OFFSET: LEGO1 0x100bd1c0
@ -51,24 +111,19 @@ MxPalette *MxBitmap::CreatePalette()
return pal; return pal;
} }
// OFFSET: LEGO1 0x100bcd10 // OFFSET: LEGO1 0x100bd280 STUB
long MxBitmap::Read(const char *filename) void MxBitmap::vtable38(void*)
{ {
HANDLE handle;
int unk1;
MxResult ret = FAILURE;
handle = CreateFileA(filename,GENERIC_READ,FILE_SHARE_READ,(LPSECURITY_ATTRIBUTES)NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,(HANDLE)NULL);
if(handle != (HANDLE)INVALID_HANDLE_VALUE) { // INVALID_HANDLE_VALUE = -1, or 0xffffffff
// FIXME: line 16. iVar gets changed in this line
if(unk1 == 0) {
ret = SUCCESS;
}
}
if(handle != (HANDLE)NULL) {
CloseHandle(handle);
}
return ret;
} }
// OFFSET: LEGO1 0x100bd2d0 STUB
int MxBitmap::vtable3c(MxBool)
{
return 0;
}
// OFFSET: LEGO1 0x100bd3e0 STUB
int MxBitmap::vtable40(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight)
{
return 0;
}

View File

@ -11,9 +11,21 @@ class MxBitmap : public MxCore
{ {
public: public:
__declspec(dllexport) MxBitmap(); __declspec(dllexport) MxBitmap();
__declspec(dllexport) virtual ~MxBitmap(); __declspec(dllexport) virtual ~MxBitmap(); // vtable+00
__declspec(dllexport) virtual MxPalette *CreatePalette();
__declspec(dllexport) virtual long Read(const char *); virtual int vtable14(int);
virtual int vtable18(BITMAPINFOHEADER *p_bmiHeader);
virtual int vtable1c(int p_width, int p_height, MxPalette *p_palette, int);
virtual MxResult LoadFile(HANDLE p_handle);
__declspec(dllexport) virtual long Read(const char *p_filename); // vtable+24
virtual int vtable28(int);
virtual void vtable2c(int, int, int, int, int, int, int);
virtual void vtable30(int, int, int, int, int, int, int);
__declspec(dllexport) virtual MxPalette *CreatePalette(); // vtable+34
virtual void vtable38(void*);
virtual int vtable3c(MxBool);
virtual int vtable40(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight);
private: private:
BITMAPINFO *m_info; BITMAPINFO *m_info;
BITMAPINFOHEADER *m_bmiHeader; BITMAPINFOHEADER *m_bmiHeader;

View File

@ -6,6 +6,7 @@
import difflib import difflib
import struct import struct
import subprocess import subprocess
import logging
import os import os
import sys import sys
import colorama import colorama
@ -24,8 +25,14 @@
parser.add_argument('--svg-icon', metavar='icon', help='Icon to use in SVG (PNG)') parser.add_argument('--svg-icon', metavar='icon', help='Icon to use in SVG (PNG)')
parser.add_argument('--print-rec-addr', action='store_true', help='Print addresses of recompiled functions too') parser.add_argument('--print-rec-addr', action='store_true', help='Print addresses of recompiled functions too')
parser.set_defaults(loglevel=logging.INFO)
parser.add_argument('--debug', action='store_const', const=logging.DEBUG, dest='loglevel', help='Print script debug information')
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=args.loglevel, format='[%(levelname)s] %(message)s')
logger = logging.getLogger(__name__)
colorama.init() colorama.init()
verbose = None verbose = None
@ -61,6 +68,7 @@
# to file addresses # to file addresses
class Bin: class Bin:
def __init__(self, filename): def __init__(self, filename):
logger.debug('Parsing headers of "%s"... ', filename)
self.file = open(filename, 'rb') self.file = open(filename, 'rb')
#HACK: Strictly, we should be parsing the header, but we know where #HACK: Strictly, we should be parsing the header, but we know where
@ -68,15 +76,16 @@ def __init__(self, filename):
# Read ImageBase # Read ImageBase
self.file.seek(0xB4) self.file.seek(0xB4)
self.imagebase = struct.unpack('i', self.file.read(4))[0] self.imagebase, = struct.unpack('<i', self.file.read(4))
# Read .text VirtualAddress # Read .text VirtualAddress
self.file.seek(0x184) self.file.seek(0x184)
self.textvirt = struct.unpack('i', self.file.read(4))[0] self.textvirt, = struct.unpack('<i', self.file.read(4))
# Read .text PointerToRawData # Read .text PointerToRawData
self.file.seek(0x18C) self.file.seek(0x18C)
self.textraw = struct.unpack('i', self.file.read(4))[0] self.textraw, = struct.unpack('<i', self.file.read(4))
logger.debug('... Parsing finished')
def __del__(self): def __del__(self):
if self.file: if self.file:
@ -90,16 +99,38 @@ def read(self, offset, size):
return self.file.read(size) return self.file.read(size)
class RecompiledInfo: class RecompiledInfo:
addr = None def __init__(self):
size = None self.addr = None
name = None self.size = None
start = None self.name = None
self.start = None
def get_wine_path(fn): class WinePathConverter:
return subprocess.check_output(['winepath', '-w', fn]).decode('utf-8').strip() def __init__(self, unix_cwd):
self.unix_cwd = unix_cwd
self.win_cwd = self._call_winepath_unix2win(self.unix_cwd)
def get_unix_path(fn): def get_wine_path(self, unix_fn: str) -> str:
return subprocess.check_output(['winepath', fn]).decode('utf-8').strip() if unix_fn.startswith('./'):
return self.win_cmd + '\\' + unix_fn[2:].replace('/', '\\')
if unix_fn.startswith(self.unix_cwd):
return self.win_cwd + '\\' + unix_fn.removeprefix(self.unix_cwd).replace('/', '\\').lstrip('\\')
return self._call_winepath_unix2win(unix_fn)
def get_unix_path(self, win_fn: str) -> str:
if win_fn.startswith('.\\') or win_fn.startswith('./'):
return self.unix_cwd + '/' + win_fn[2:].replace('\\', '/')
if win_fn.startswith(self.win_cwd):
return self.unix_cwd + '/' + win_fn.removeprefix(self.win_cwd).replace('\\', '/')
return self._call_winepath_win2unix(win_fn)
@staticmethod
def _call_winepath_unix2win(fn: str) -> str:
return subprocess.check_output(['winepath', '-w', fn], text=True).strip()
@staticmethod
def _call_winepath_win2unix(fn: str) -> str:
return subprocess.check_output(['winepath', fn], text=True).strip()
def get_file_in_script_dir(fn): def get_file_in_script_dir(fn):
return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn) return os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), fn)
@ -109,22 +140,24 @@ class SymInfo:
funcs = {} funcs = {}
lines = {} lines = {}
def __init__(self, pdb, file): def __init__(self, pdb, file, wine_path_converter):
call = [get_file_in_script_dir('cvdump.exe'), '-l', '-s'] call = [get_file_in_script_dir('cvdump.exe'), '-l', '-s']
if os.name != 'nt': if wine_path_converter:
# Run cvdump through wine and convert path to Windows-friendly wine path # Run cvdump through wine and convert path to Windows-friendly wine path
call.insert(0, 'wine') call.insert(0, 'wine')
call.append(get_wine_path(pdb)) call.append(wine_path_converter.get_wine_path(pdb))
else: else:
call.append(pdb) call.append(pdb)
print('Parsing %s...' % pdb) logger.info('Parsing %s ...', pdb)
logger.debug('Command = %r', call)
line_dump = subprocess.check_output(call).decode('utf-8').split('\r\n') line_dump = subprocess.check_output(call).decode('utf-8').split('\r\n')
current_section = None current_section = None
logger.debug('Parsing output of cvdump.exe ...')
for i, line in enumerate(line_dump): for i, line in enumerate(line_dump):
if line.startswith('***'): if line.startswith('***'):
current_section = line[4:] current_section = line[4:]
@ -132,8 +165,6 @@ def __init__(self, pdb, file):
if current_section == 'SYMBOLS' and 'S_GPROC32' in line: if current_section == 'SYMBOLS' and 'S_GPROC32' in line:
addr = int(line[26:34], 16) addr = int(line[26:34], 16)
info = RecompiledInfo() info = RecompiledInfo()
info.addr = addr + recompfile.imagebase + recompfile.textvirt info.addr = addr + recompfile.imagebase + recompfile.textvirt
@ -155,9 +186,9 @@ def __init__(self, pdb, file):
elif current_section == 'LINES' and line.startswith(' ') and not line.startswith(' '): elif current_section == 'LINES' and line.startswith(' ') and not line.startswith(' '):
sourcepath = line.split()[0] sourcepath = line.split()[0]
if os.name != 'nt': if wine_path_converter:
# Convert filename to Unix path for file compare # Convert filename to Unix path for file compare
sourcepath = get_unix_path(sourcepath) sourcepath = wine_path_converter.get_unix_path(sourcepath)
if sourcepath not in self.lines: if sourcepath not in self.lines:
self.lines[sourcepath] = {} self.lines[sourcepath] = {}
@ -178,18 +209,23 @@ def __init__(self, pdb, file):
j += 1 j += 1
logger.debug('... Parsing output of cvdump.exe finished')
def get_recompiled_address(self, filename, line): def get_recompiled_address(self, filename, line):
addr = None addr = None
found = False found = False
#print('Looking for ' + filename + ' line ' + str(line)) logger.debug('Looking for %s:%d', filename, line)
for fn in self.lines: for fn in self.lines:
# Sometimes a PDB is compiled with a relative path while we always have # Sometimes a PDB is compiled with a relative path while we always have
# an absolute path. Therefore we must # an absolute path. Therefore we must
if os.path.samefile(fn, filename): try:
filename = fn if os.path.samefile(fn, filename):
break filename = fn
break
except FileNotFoundError as e:
continue
if filename in self.lines and line in self.lines[fn]: if filename in self.lines and line in self.lines[fn]:
addr = self.lines[fn][line] addr = self.lines[fn][line]
@ -197,13 +233,16 @@ def get_recompiled_address(self, filename, line):
if addr in self.funcs: if addr in self.funcs:
return self.funcs[addr] return self.funcs[addr]
else: else:
print('Failed to find function symbol with address: %s' % hex(addr)) logger.error('Failed to find function symbol with address: 0x%x', addr)
else: else:
print('Failed to find function symbol with filename and line: %s:%s' % (filename, str(line))) logger.error('Failed to find function symbol with filename and line: %s:%d', filename, line)
wine_path_converter = None
if os.name != 'nt':
wine_path_converter = WinePathConverter(source)
origfile = Bin(original) origfile = Bin(original)
recompfile = Bin(recomp) recompfile = Bin(recomp)
syminfo = SymInfo(syms, recompfile) syminfo = SymInfo(syms, recompfile, wine_path_converter)
print() print()