Merge branch 'master' into pr/18

This commit is contained in:
itsmattkc 2023-06-18 21:30:15 -07:00
commit 2516ce7e0e
29 changed files with 446 additions and 107 deletions

View File

@ -54,6 +54,15 @@ jobs:
mkdir Release
.\msvc420\bin\NMAKE.EXE /f isle.mak CFG="ISLE - Win32 Release"
- name: Summarize Accuracy
shell: cmd
run: |
C:\msys64\usr\bin\wget.exe https://legoisland.org/download/ISLE.EXE
C:\msys64\usr\bin\wget.exe https://legoisland.org/download/LEGO1.DLL
pip install capstone
python3 tools/reccomp/reccomp.py ISLE.EXE Release/ISLE.EXE Release/ISLE.PDB ISLE
python3 tools/reccomp/reccomp.py LEGO1.DLL Release/LEGO1.DLL Release/LEGO1.PDB LEGO1
- name: Upload Artifact
uses: actions/upload-artifact@master
with:

View File

@ -1,17 +1,43 @@
#include "define.h"
// 0x410030
Isle *g_isle = 0;
// 0x410034
unsigned char g_mousedown = 0;
// 0x410038
unsigned char g_mousemoved = 0;
// 0x41003c
int g_closed = 0;
const char *WINDOW_TITLE = "LEGO\xAE";
// 0x410040
RECT g_windowRect = {0, 0, 640, 480};
unsigned char g_mousedown = 0;
unsigned char g_mousemoved = 0;
// 0x410050
int g_rmDisabled = 0;
// 0x410054
int g_waitingForTargetDepth = 1;
// 0x410058
int g_targetWidth = 640;
// 0x41005c
int g_targetHeight = 480;
// 0x410060
unsigned int g_targetDepth = 16;
// 0x410064
int g_reqEnableRMDevice = 0;
// 0x4101bc
int g_startupDelay = 200;
// 0x4101c0
long g_lastFrameTime = 0;
// 0x4101dc
const char *WINDOW_TITLE = "LEGO\xAE";

View File

@ -1,6 +1,8 @@
#ifndef DEFINE_H
#define DEFINE_H
#include <Windows.h>
class Isle;
extern Isle *g_isle;
@ -9,6 +11,7 @@ extern int g_closed;
extern const char *WINDOW_TITLE;
extern unsigned char g_mousedown;
extern unsigned char g_mousemoved;
extern RECT g_windowRect;
extern int g_rmDisabled;
extern int g_waitingForTargetDepth;
extern int g_targetWidth;

View File

@ -7,8 +7,7 @@
#include "mxomni.h"
#include "res/resource.h"
RECT windowRect = {0, 0, 640, 480};
// OFFSET: ISLE 0x401000
Isle::Isle()
{
m_hdPath = NULL;
@ -51,6 +50,7 @@ Isle::Isle()
LegoOmni::CreateInstance();
}
// OFFSET: ISLE 0x4011a0
Isle::~Isle()
{
if (LegoOmni::GetInstance()) {
@ -75,6 +75,7 @@ Isle::~Isle()
}
}
// OFFSET: ISLE 0x401260
void Isle::close()
{
MxDSAction ds;
@ -85,10 +86,7 @@ void Isle::close()
InputManager()->QueueEvent(KEYDOWN, 0, 0, 0, 0x20);
}
// FIXME: Untangle
//VideoManager()->GetViewManager()->RemoveAll(NULL);
//ViewManager::RemoveAll
// (*(ViewManager **)(*(int *)(*(int *)(pLVar4 + 0x68) + 8) + 0x88), NULL);
VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveAll(NULL);
long local_88 = 0;
Lego()->RemoveWorld(ds.m_atomId, local_88);
@ -102,7 +100,7 @@ void Isle::close()
} while (lVar8 == 0);
while (Lego()) {
if (Lego()->vtable28(ds) != 0) {
if (Lego()->vtable28(ds) != MX_FALSE) {
break;
}
@ -112,6 +110,7 @@ void Isle::close()
}
}
// OFFSET: ISLE 0x402740
BOOL readReg(LPCSTR name, LPSTR outValue, DWORD outSize)
{
HKEY hKey;
@ -130,6 +129,7 @@ BOOL readReg(LPCSTR name, LPSTR outValue, DWORD outSize)
return out;
}
// OFFSET: ISLE 0x4027b0
int readRegBool(LPCSTR name, BOOL *out)
{
char buffer[256];
@ -149,6 +149,7 @@ int readRegBool(LPCSTR name, BOOL *out)
return FALSE;
}
// OFFSET: ISLE 0x402880
int readRegInt(LPCSTR name, int *out)
{
char buffer[256];
@ -161,6 +162,7 @@ int readRegInt(LPCSTR name, int *out)
return FALSE;
}
// OFFSET: ISLE 0x4028d0
void Isle::loadConfig()
{
#define BUFFER_SIZE 1024
@ -227,6 +229,7 @@ void Isle::loadConfig()
}
}
// OFFSET: ISLE 0x401560
void Isle::setupVideoFlags(BOOL fullScreen, BOOL flipSurfaces, BOOL backBuffers,
BOOL using8bit, BOOL m_using16bit, BOOL param_6, BOOL param_7,
BOOL wideViewAngle, char *deviceId)
@ -247,6 +250,7 @@ void Isle::setupVideoFlags(BOOL fullScreen, BOOL flipSurfaces, BOOL backBuffers,
}
}
// OFFSET: ISLE 0x4013b0
BOOL Isle::setupLegoOmni()
{
char mediaPath[256];
@ -261,6 +265,7 @@ BOOL Isle::setupLegoOmni()
return FALSE;
}
// OFFSET: ISLE 0x402e80
void Isle::setupCursor(WPARAM wParam)
{
switch (wParam) {
@ -281,6 +286,7 @@ void Isle::setupCursor(WPARAM wParam)
SetCursor(m_cursorCurrent);
}
// OFFSET: ISLE 0x401d20
LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (!g_isle) {
@ -295,9 +301,9 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_ACTIVATEAPP:
if (g_isle) {
if ((wParam != 0) && (g_isle->m_fullScreen)) {
MoveWindow(hWnd, windowRect.left, windowRect.top,
(windowRect.right - windowRect.left) + 1,
(windowRect.bottom - windowRect.top) + 1, TRUE);
MoveWindow(hWnd, g_windowRect.left, g_windowRect.top,
(g_windowRect.right - g_windowRect.left) + 1,
(g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
}
g_isle->m_windowActive = wParam;
}
@ -316,10 +322,10 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MINMAXINFO *mmi = (MINMAXINFO *) lParam;
mmi->ptMaxTrackSize.x = (windowRect.right - windowRect.left) + 1;
mmi->ptMaxTrackSize.y = (windowRect.bottom - windowRect.top) + 1;
mmi->ptMinTrackSize.x = (windowRect.right - windowRect.left) + 1;
mmi->ptMinTrackSize.y = (windowRect.bottom - windowRect.top) + 1;
mmi->ptMaxTrackSize.x = (g_windowRect.right - g_windowRect.left) + 1;
mmi->ptMaxTrackSize.y = (g_windowRect.bottom - g_windowRect.top) + 1;
mmi->ptMinTrackSize.x = (g_windowRect.right - g_windowRect.left) + 1;
mmi->ptMinTrackSize.y = (g_windowRect.bottom - g_windowRect.top) + 1;
return 0;
}
@ -450,6 +456,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return DefWindowProcA(hWnd,uMsg,wParam,lParam);
}
// OFFSET: ISLE 0x4023e0
MxResult Isle::setupWindow(HINSTANCE hInstance)
{
WNDCLASSA wndclass;
@ -489,21 +496,21 @@ MxResult Isle::setupWindow(HINSTANCE hInstance)
int x, y, width, height;
if (!m_fullScreen) {
AdjustWindowRectEx(&windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
AdjustWindowRectEx(&g_windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
height = windowRect.bottom - windowRect.top;
width = windowRect.right - windowRect.left;
height = g_windowRect.bottom - g_windowRect.top;
width = g_windowRect.right - g_windowRect.left;
y = CW_USEDEFAULT;
x = CW_USEDEFAULT;
dwStyle = WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
} else {
AdjustWindowRectEx(&windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
height = windowRect.bottom - windowRect.top;
width = windowRect.right - windowRect.left;
AdjustWindowRectEx(&g_windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
height = g_windowRect.bottom - g_windowRect.top;
width = g_windowRect.right - g_windowRect.left;
dwStyle = WS_CAPTION | WS_SYSMENU;
x = windowRect.left;
y = windowRect.top;
x = g_windowRect.left;
y = g_windowRect.top;
}
m_windowHandle = CreateWindowExA(WS_EX_APPWINDOW, WNDCLASS_NAME, WINDOW_TITLE, dwStyle,
@ -513,7 +520,7 @@ MxResult Isle::setupWindow(HINSTANCE hInstance)
}
if (m_fullScreen) {
MoveWindow(m_windowHandle, windowRect.left, windowRect.top, (windowRect.right - windowRect.left) + 1, (windowRect.bottom - windowRect.top) + 1, TRUE);
MoveWindow(m_windowHandle, g_windowRect.left, g_windowRect.top, (g_windowRect.right - g_windowRect.left) + 1, (g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
}
ShowWindow(m_windowHandle, SW_SHOWNORMAL);
@ -549,7 +556,7 @@ MxResult Isle::setupWindow(HINSTANCE hInstance)
}
}
if (m_fullScreen) {
MoveWindow(m_windowHandle, windowRect.left, windowRect.top, (windowRect.right - windowRect.left) + 1, (windowRect.bottom - windowRect.top) + 1, TRUE);
MoveWindow(m_windowHandle, g_windowRect.left, g_windowRect.top, (g_windowRect.right - g_windowRect.left) + 1, (g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
}
ShowWindow(m_windowHandle, SW_SHOWNORMAL);
UpdateWindow(m_windowHandle);
@ -557,6 +564,7 @@ MxResult Isle::setupWindow(HINSTANCE hInstance)
return SUCCESS;
}
// OFFSET: ISLE 0x402c20
void Isle::tick(BOOL sleepIfNotNextFrame)
{
if (this->m_windowActive) {

View File

@ -5,6 +5,7 @@
#include "isle.h"
#include "legoomni.h"
// OFFSET: ISLE 0x401ca0
BOOL findExistingInstance(void)
{
HWND hWnd = FindWindowA(WNDCLASS_NAME, WINDOW_TITLE);
@ -17,6 +18,7 @@ BOOL findExistingInstance(void)
return 1;
}
// OFFSET: ISLE 0x401ce0
BOOL startDirectSound(void)
{
LPDIRECTSOUND lpDS = NULL;
@ -29,6 +31,7 @@ BOOL startDirectSound(void)
return FALSE;
}
// OFFSET: ISLE 0x401610
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
// Look for another instance, if we find one, bring it to the foreground instead

View File

@ -1,5 +1,6 @@
#include <windows.h>
// OFFSET: LEGO1 0x10091ee0
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
return TRUE;

17
LEGO1/lego3dmanager.h Executable file
View File

@ -0,0 +1,17 @@
#ifndef LEGO3DMANAGER_H
#define LEGO3DMANAGER_H
#include "lego3dview.h"
class Lego3DManager
{
public:
inline Lego3DView *GetLego3DView() { return this->m_3dView; }
private:
int m_unk00;
int m_unk04;
Lego3DView *m_3dView;
};
#endif // LEGO3DMANAGER_H

16
LEGO1/lego3dview.h Executable file
View File

@ -0,0 +1,16 @@
#ifndef LEGO3DVIEW_H
#define LEGO3DVIEW_H
#include "viewmanager.h"
class Lego3DView
{
public:
inline ViewManager *GetViewManager() { return this->m_viewManager; }
private:
char unknown[0x88];
ViewManager *m_viewManager;
};
#endif // LEGO3DVIEW_H

View File

@ -3,12 +3,12 @@
__declspec(dllexport) enum NotificationId
{
NONE = 0x0,
KEYDOWN = 0x7,
MOUSEUP = 0x8,
MOUSEDOWN = 0x9,
MOUSEMOVE = 0xA,
TIMER = 0xF
NONE = 0,
KEYDOWN = 7,
MOUSEUP = 8,
MOUSEDOWN = 9,
MOUSEMOVE = 10,
TIMER = 15
};
class LegoInputManager

View File

@ -2,12 +2,20 @@
LegoOmni *LegoOmni::m_instance = NULL;
// OFFSET: LEGO1 0x1005ad10
LegoOmni *LegoOmni::GetInstance()
{
return m_instance;
}
// OFFSET: LEGO1 0x10015700
LegoOmni *Lego()
{
return LegoOmni::GetInstance();
}
// OFFSET: LEGO1 0x10015720
LegoVideoManager *VideoManager()
{
return LegoOmni::GetInstance()->GetVideoManager();
}

View File

@ -28,6 +28,7 @@ class MxMusicManager;
class MxNotificationManager;
class MxSoundManager;
// class LegoOmni : public MxOmni
class LegoOmni
{
public:
@ -48,7 +49,7 @@ class LegoOmni
virtual void vtable1c();
virtual void vtable20();
virtual void vtable24(MxDSAction &ds);
virtual int vtable28(MxDSAction &ds);
virtual MxBool vtable28(MxDSAction &ds);
virtual void vtable2c();
virtual void vtable30();
virtual void vtable34();
@ -56,6 +57,7 @@ class LegoOmni
virtual void vtable3c();
virtual unsigned char vtable40();
LegoVideoManager *GetVideoManager() { return m_videoMgr; }
LegoInputManager *GetInputManager() { return m_inputMgr; }
private:
@ -69,7 +71,7 @@ class LegoOmni
int m_unk20;
int m_unk24;
int m_unk28;
int m_unk2c;
LegoVideoManager *m_videoMgr;
int m_unk30;
int m_unk34;
int m_unk38;

View File

@ -1,17 +1,19 @@
#ifndef LEGOVIDEOMANAGER_H
#define LEGOVIDEOMANAGER_H
#include "lego3dmanager.h"
// class LegoVideoManager : public MxVideoManager
class LegoVideoManager
{
public:
__declspec(dllexport) int EnableRMDevice();
__declspec(dllexport) int DisableRMDevice();
__declspec(dllexport) void EnableFullScreenMovie(unsigned char a, unsigned char b);
__declspec(dllexport) void MoveCursor(int x, int y);
inline Lego3DManager *Get3DManager() { return this->m_3dManager; }
int m_unk00;
int m_unk04;
int m_unk08;
@ -38,11 +40,10 @@ class LegoVideoManager
int m_unk5c;
int m_unk60;
int m_unk64;
int m_unk68;
Lego3DManager *m_3dManager;
int m_unk6c;
int m_unk70;
int *m_unk74;
};
#endif // LEGOVIDEOMANAGER_H

View File

@ -1,5 +1,6 @@
#include "mxautolocker.h"
// OFFSET: LEGO1 0x100b8ed0
MxAutoLocker::MxAutoLocker(MxCriticalSection *critsect)
{
this->m_criticalSection = critsect;
@ -7,6 +8,7 @@ MxAutoLocker::MxAutoLocker(MxCriticalSection *critsect)
this->m_criticalSection->Enter();
}
// OFFSET: LEGO1 0x100b8ef0
MxAutoLocker::~MxAutoLocker()
{
if (this->m_criticalSection != 0)

View File

@ -2,33 +2,40 @@
#include <string.h>
// 0x1010141c
unsigned int g_mxcoreCount = 0;
// OFFSET: LEGO1 0x100ae1a0
MxCore::MxCore()
{
m_id = g_mxcoreCount;
g_mxcoreCount++;
}
// OFFSET: LEGO1 0x100ae1e0
MxCore::~MxCore()
{
}
// OFFSET: LEGO1 0x100ae1f0
long MxCore::Notify(MxParam &p)
{
return 0;
}
// OFFSET: LEGO1 0x10001f70
long MxCore::Tickle()
{
return 0;
}
// OFFSET: LEGO1 0x100144c0
const char *MxCore::GetClassName() const
{
return "MxCore";
}
// OFFSET: LEGO1 0x100140d0
MxBool MxCore::IsClass(const char *name) const
{
return strcmp(name, "MxCore") == 0;

View File

@ -2,8 +2,10 @@
#include <stdio.h>
// 0x10101e78
int g_useMutex = 0;
// OFFSET: LEGO1 0x100b6d20
MxCriticalSection::MxCriticalSection()
{
HANDLE mutex;
@ -19,6 +21,7 @@ MxCriticalSection::MxCriticalSection()
this->m_mutex = NULL;
}
// OFFSET: LEGO1 0x100b6d60
MxCriticalSection::~MxCriticalSection()
{
if (this->m_mutex != NULL)
@ -30,11 +33,13 @@ MxCriticalSection::~MxCriticalSection()
DeleteCriticalSection(&this->m_criticalSection);
}
// OFFSET: LEGO1 0x100b6e00
void MxCriticalSection::SetDoMutex()
{
g_useMutex = 1;
}
// OFFSET: LEGO1 0x100b6d80
void MxCriticalSection::Enter()
{
DWORD result;
@ -61,6 +66,7 @@ void MxCriticalSection::Enter()
}
}
// OFFSET: LEGO1 0x100b6de0
void MxCriticalSection::Leave()
{
if (this->m_mutex != NULL)
@ -70,4 +76,4 @@ void MxCriticalSection::Leave()
}
LeaveCriticalSection(&this->m_criticalSection);
}
}

View File

@ -1,5 +1,6 @@
#include "mxomni.h"
// OFFSET: LEGO1 0x100af0c0
MxResult MxOmni::Create(const MxOmniCreateParam &p)
{
if (p.CreateFlags().CreateTimer())

View File

@ -1,5 +1,6 @@
#include "mxomnicreateflags.h"
// OFFSET: LEGO1 0x100b0a30
MxOmniCreateFlags::MxOmniCreateFlags()
{
this->CreateObjectFactory(MX_TRUE);

View File

@ -1,9 +1,10 @@
#include "mxomnicreateparam.h"
MxOmniCreateParam::MxOmniCreateParam(const char *mediaPath, HWND windowHandle, MxVideoParam &vparam, MxOmniCreateFlags flags)
// OFFSET: LEGO1 0x100b0b00
MxOmniCreateParam::MxOmniCreateParam(const char *mediaPath, struct HWND__ *windowHandle, MxVideoParam &vparam, MxOmniCreateFlags flags)
{
this->m_mediaPath = mediaPath;
this->m_windowHandle = windowHandle;
this->m_windowHandle = (HWND) windowHandle;
this->m_videoParam = vparam;
this->m_createFlags = flags;
}

View File

@ -11,8 +11,7 @@
class MxOmniCreateParam : public MxOmniCreateParamBase
{
public:
__declspec(dllexport) MxOmniCreateParam(const char *mediaPath, HWND windowHandle, MxVideoParam &vparam, MxOmniCreateFlags flags);
// virtual void vtable00(); seems to be a destructor
__declspec(dllexport) MxOmniCreateParam(const char *mediaPath, struct HWND__ *windowHandle, MxVideoParam &vparam, MxOmniCreateFlags flags);
const MxOmniCreateFlags& CreateFlags() const { return this->m_createFlags; }

View File

@ -5,9 +5,7 @@
class MxOmniCreateParamBase
{
public:
~MxOmniCreateParamBase() {
}
virtual void vtable00(){}
virtual ~MxOmniCreateParamBase(){}
};

View File

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
// OFFSET: LEGO1 0x100ae200
MxString::MxString()
{
// Set string to one char in length and set that char to null terminator
@ -11,6 +12,7 @@ MxString::MxString()
}
// TODO: this *mostly* matches, again weird with the comparison
// OFFSET: LEGO1 0x100ae510
const MxString &MxString::operator=(const char *param)
{
if (this->m_data != param)
@ -24,6 +26,7 @@ const MxString &MxString::operator=(const char *param)
return *this;
}
// OFFSET: LEGO1 0x100ae420
MxString::~MxString()
{
free(this->m_data);

View File

@ -2,9 +2,13 @@
#include <windows.h>
// 0x10101414
long MxTimer::s_LastTimeCalculated = 0;
// 0x10101418
long MxTimer::s_LastTimeTimerStarted = 0;
// OFFSET: LEGO1 0x100ae060
MxTimer::MxTimer()
{
this->m_isRunning = MX_FALSE;
@ -12,12 +16,14 @@ MxTimer::MxTimer()
this->m_startTime = MxTimer::s_LastTimeCalculated;
}
// OFFSET: LEGO1 0x100ae160
void MxTimer::Start()
{
this->m_isRunning = MX_TRUE;
MxTimer::s_LastTimeTimerStarted = timeGetTime();
}
// OFFSET: LEGO1 0x100ae180
void MxTimer::Stop()
{
long elapsed = this->GetRealTime();
@ -27,6 +33,7 @@ void MxTimer::Stop()
this->m_startTime = this->m_startTime + startTime - 5;
}
// OFFSET: LEGO1 0x100ae140
long MxTimer::GetRealTime()
{
MxTimer::s_LastTimeCalculated = timeGetTime();

View File

@ -1,5 +1,6 @@
#include "mxvideoparam.h"
// OFFSET: LEGO1 0x100bec70
MxVideoParam::MxVideoParam()
{
this->m_flags = MxVideoParamFlags();
@ -13,6 +14,7 @@ MxVideoParam::MxVideoParam()
this->m_deviceId = 0;
}
// OFFSET: LEGO1 0x100becf0
MxVideoParam &MxVideoParam::operator=(const MxVideoParam &other)
{
m_flags = MxVideoParamFlags();
@ -30,6 +32,7 @@ MxVideoParam &MxVideoParam::operator=(const MxVideoParam &other)
return *this;
}
// OFFSET: LEGO1 0x100bed70
void MxVideoParam::SetDeviceName(char *id)
{
if (this->m_deviceId != 0)
@ -48,6 +51,7 @@ void MxVideoParam::SetDeviceName(char *id)
}
}
// OFFSET: LEGO1 0x100bed50
MxVideoParam::~MxVideoParam()
{
if (this->m_deviceId != 0)

View File

@ -1,5 +1,6 @@
#include "mxvideoparamflags.h"
// OFFSET: LEGO1 0x100bec40
MxVideoParamFlags::MxVideoParamFlags()
{
// TODO: convert to EnableXXX function calls

View File

@ -1,6 +1,8 @@
#ifndef VIEWMANAGER_H
#define VIEWMANAGER_H
class ViewROI;
class ViewManager
{
public:

105
isle.mak
View File

@ -68,19 +68,20 @@ CLEAN :
-@erase "$(INTDIR)\mxtimer.obj"
-@erase "$(INTDIR)\mxvideoparam.obj"
-@erase "$(INTDIR)\mxvideoparamflags.obj"
-@erase "$(INTDIR)\vc40.pdb"
-@erase ".\Release\LEGO1.DLL"
-@erase ".\Release\LEGO1.EXP"
-@erase ".\Release\LEGO1.LIB"
-@erase ".\Release\LEGO1.MAP"
-@erase ".\Release\LEGO1.PDB"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
CPP_PROJ=/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
/Fp"$(INTDIR)/LEGO1.pch" /YX /Fo"$(INTDIR)/" /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
CPP_PROJ=/nologo /MT /W3 /GX /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
/Fp"$(INTDIR)/LEGO1.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\LEGO1\Release/
CPP_SBRS=.\.
@ -117,13 +118,13 @@ BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /pdb:"Release/LEGO1.PDB" /map:"Release/LEGO1.MAP" /machine:I386 /out:"Release/LEGO1.DLL" /implib:"Release/LEGO1.LIB"
# SUBTRACT LINK32 /pdb:none
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /pdb:"Release/LEGO1.PDB" /debug /machine:I386 /out:"Release/LEGO1.DLL" /implib:"Release/LEGO1.LIB"
# SUBTRACT LINK32 /pdb:none /map
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /incremental:no\
/pdb:"Release/LEGO1.PDB" /map:"Release/LEGO1.MAP" /machine:I386\
/out:"Release/LEGO1.DLL" /implib:"Release/LEGO1.LIB"
/pdb:"Release/LEGO1.PDB" /debug /machine:I386 /out:"Release/LEGO1.DLL"\
/implib:"Release/LEGO1.LIB"
LINK32_OBJS= \
"$(INTDIR)\dllmain.obj" \
"$(INTDIR)\legonavcontroller.obj" \
@ -181,7 +182,6 @@ CLEAN :
-@erase "$(INTDIR)\vc40.pdb"
-@erase "$(OUTDIR)\LEGO1.exp"
-@erase "$(OUTDIR)\LEGO1.lib"
-@erase "$(OUTDIR)\LEGO1.map"
-@erase "$(OUTDIR)\LEGO1.pdb"
-@erase ".\Debug\LEGO1.DLL"
-@erase ".\Debug\LEGO1.ILK"
@ -230,13 +230,13 @@ BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /map /debug /machine:I386 /out:"Debug/LEGO1.DLL"
# SUBTRACT LINK32 /pdb:none
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"Debug/LEGO1.DLL"
# SUBTRACT LINK32 /pdb:none /map
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
odbccp32.lib winmm.lib /nologo /subsystem:windows /dll /incremental:yes\
/pdb:"$(OUTDIR)/LEGO1.pdb" /map:"$(INTDIR)/LEGO1.map" /debug /machine:I386\
/out:"Debug/LEGO1.DLL" /implib:"$(OUTDIR)/LEGO1.lib"
/pdb:"$(OUTDIR)/LEGO1.pdb" /debug /machine:I386 /out:"Debug/LEGO1.DLL"\
/implib:"$(OUTDIR)/LEGO1.lib"
LINK32_OBJS= \
"$(INTDIR)\dllmain.obj" \
"$(INTDIR)\legonavcontroller.obj" \
@ -280,17 +280,18 @@ CLEAN :
-@erase "$(INTDIR)\isle.obj"
-@erase "$(INTDIR)\isle.res"
-@erase "$(INTDIR)\main.obj"
-@erase "$(INTDIR)\mxomnicreateparambase.obj"
-@erase "$(INTDIR)\vc40.pdb"
-@erase ".\Release\ISLE.EXE"
-@erase ".\Release\ISLE.PDB"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /W3 /GX /O2 /I "LEGO1" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "LEGO1" /D "WIN32" /D "NDEBUG" /D\
"_WINDOWS" /Fp"$(INTDIR)/ISLE.pch" /YX /Fo"$(INTDIR)/" /c
# ADD CPP /nologo /W3 /GX /Zi /O2 /I "LEGO1" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
CPP_PROJ=/nologo /ML /W3 /GX /Zi /O2 /I "LEGO1" /D "WIN32" /D "NDEBUG" /D\
"_WINDOWS" /Fp"$(INTDIR)/ISLE.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\ISLE\Release/
CPP_SBRS=.\.
@ -328,19 +329,18 @@ BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib lego1.lib dsound.lib /nologo /subsystem:windows /pdb:"Release/ISLE.PDB" /machine:I386 /out:"Release/ISLE.EXE" /LIBPATH:"ISLE/ext"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib lego1.lib dsound.lib /nologo /subsystem:windows /pdb:"Release/ISLE.PDB" /debug /machine:I386 /out:"Release/ISLE.EXE" /LIBPATH:"ISLE/ext"
# SUBTRACT LINK32 /pdb:none
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
odbccp32.lib winmm.lib lego1.lib dsound.lib /nologo /subsystem:windows\
/incremental:no /pdb:"Release/ISLE.PDB" /machine:I386 /out:"Release/ISLE.EXE"\
/LIBPATH:"ISLE/ext"
/incremental:no /pdb:"Release/ISLE.PDB" /debug /machine:I386\
/out:"Release/ISLE.EXE" /LIBPATH:"ISLE/ext"
LINK32_OBJS= \
"$(INTDIR)\define.obj" \
"$(INTDIR)\isle.obj" \
"$(INTDIR)\isle.res" \
"$(INTDIR)\main.obj" \
"$(INTDIR)\mxomnicreateparambase.obj" \
".\Release\LEGO1.LIB"
".\Release\ISLE.EXE" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
@ -370,7 +370,6 @@ CLEAN :
-@erase "$(INTDIR)\isle.obj"
-@erase "$(INTDIR)\isle.res"
-@erase "$(INTDIR)\main.obj"
-@erase "$(INTDIR)\mxomnicreateparambase.obj"
-@erase "$(INTDIR)\vc40.idb"
-@erase "$(INTDIR)\vc40.pdb"
-@erase ".\Debug\ISLE.EXE"
@ -434,7 +433,6 @@ LINK32_OBJS= \
"$(INTDIR)\isle.obj" \
"$(INTDIR)\isle.res" \
"$(INTDIR)\main.obj" \
"$(INTDIR)\mxomnicreateparambase.obj" \
".\LEGO1\Debug\LEGO1.lib"
".\Debug\ISLE.EXE" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
@ -485,6 +483,8 @@ SOURCE=.\LEGO1\dllmain.cpp
SOURCE=.\LEGO1\legoomni.cpp
DEP_CPP_LEGOO=\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoanimationmanager.h"\
".\LEGO1\legobuildingmanager.h"\
".\LEGO1\legoentity.h"\
@ -518,6 +518,7 @@ DEP_CPP_LEGOO=\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
".\LEGO1\viewmanager.h"\
"$(INTDIR)\legoomni.obj" : $(SOURCE) $(DEP_CPP_LEGOO) "$(INTDIR)"
@ -578,10 +579,14 @@ DEP_CPP_MXOMN=\
".\LEGO1\mxomnicreateflags.h"\
".\LEGO1\mxomnicreateparam.h"\
".\LEGO1\mxomnicreateparambase.h"\
".\LEGO1\mxpalette.h"\
".\LEGO1\mxrect32.h"\
".\LEGO1\mxresult.h"\
".\LEGO1\mxstring.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
"$(INTDIR)\mxomni.obj" : $(SOURCE) $(DEP_CPP_MXOMN) "$(INTDIR)"
@ -594,7 +599,11 @@ DEP_CPP_MXOMN=\
SOURCE=.\LEGO1\mxvideoparam.cpp
DEP_CPP_MXVID=\
".\LEGO1\mxpalette.h"\
".\LEGO1\mxrect32.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
"$(INTDIR)\mxvideoparam.obj" : $(SOURCE) $(DEP_CPP_MXVID) "$(INTDIR)"
@ -625,8 +634,12 @@ DEP_CPP_MXOMNI=\
".\LEGO1\mxomnicreateflags.h"\
".\LEGO1\mxomnicreateparam.h"\
".\LEGO1\mxomnicreateparambase.h"\
".\LEGO1\mxpalette.h"\
".\LEGO1\mxrect32.h"\
".\LEGO1\mxstring.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
"$(INTDIR)\mxomnicreateparam.obj" : $(SOURCE) $(DEP_CPP_MXOMNI) "$(INTDIR)"
@ -644,8 +657,12 @@ DEP_CPP_MXOMNIC=\
".\LEGO1\mxomnicreateflags.h"\
".\LEGO1\mxomnicreateparam.h"\
".\LEGO1\mxomnicreateparambase.h"\
".\LEGO1\mxpalette.h"\
".\LEGO1\mxrect32.h"\
".\LEGO1\mxstring.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
"$(INTDIR)\mxomnicreateparambase.obj" : $(SOURCE) $(DEP_CPP_MXOMNIC)\
@ -732,6 +749,8 @@ DEP_CPP_ISLE_=\
".\ISLE\define.h"\
".\ISLE\isle.h"\
".\ISLE\res\resource.h"\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoanimationmanager.h"\
".\LEGO1\legobuildingmanager.h"\
".\LEGO1\legoentity.h"\
@ -767,6 +786,7 @@ DEP_CPP_ISLE_=\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
".\LEGO1\viewmanager.h"\
"$(INTDIR)\isle.obj" : $(SOURCE) $(DEP_CPP_ISLE_) "$(INTDIR)"
@ -781,6 +801,8 @@ SOURCE=.\ISLE\main.cpp
DEP_CPP_MAIN_=\
".\ISLE\define.h"\
".\ISLE\isle.h"\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoanimationmanager.h"\
".\LEGO1\legobuildingmanager.h"\
".\LEGO1\legoentity.h"\
@ -814,6 +836,7 @@ DEP_CPP_MAIN_=\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
".\LEGO1\viewmanager.h"\
"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
@ -842,30 +865,6 @@ SOURCE=.\ISLE\res\isle.rc
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\LEGO1\mxomnicreateparambase.cpp
DEP_CPP_MXOMNIC=\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxomnicreateflags.h"\
".\LEGO1\mxomnicreateparam.h"\
".\LEGO1\mxomnicreateparambase.h"\
".\LEGO1\mxpalette.h"\
".\LEGO1\mxrect32.h"\
".\LEGO1\mxstring.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\mxvideoparamflags.h"\
"$(INTDIR)\mxomnicreateparambase.obj" : $(SOURCE) $(DEP_CPP_MXOMNIC)\
"$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
@ -1122,18 +1121,6 @@ SOURCE=.\LEGO1\mxomnicreateparam.h
################################################################################
# Begin Source File
SOURCE=.\LEGO1\mxomnicreateparambase.h
!IF "$(CFG)" == "ISLE - Win32 Release"
!ELSEIF "$(CFG)" == "ISLE - Win32 Debug"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\LEGO1\mxpalette.h
!IF "$(CFG)" == "ISLE - Win32 Release"

BIN
isle.mdp

Binary file not shown.

BIN
tools/reccomp/cvdump.exe Normal file

Binary file not shown.

226
tools/reccomp/reccomp.py Executable file
View File

@ -0,0 +1,226 @@
#!/usr/bin/env python3
from capstone import *
import difflib
import struct
import subprocess
import os
import sys
def print_usage():
print('Usage: %s [options] <original-binary> <recompiled-binary> <recompiled-pdb> <decomp-dir>\n' % sys.argv[0])
print('\t-v, --verbose <offset>\t\t\tPrint assembly diff for specific function (original file\'s offset)')
sys.exit(1)
positional_args = []
verbose = None
skip = False
for i, arg in enumerate(sys.argv):
if skip:
skip = False
continue
if arg.startswith('-'):
# A flag rather than a positional arg
flag = arg[1:]
if flag == 'v' or flag == '-verbose':
verbose = int(sys.argv[i + 1], 16)
skip = True
else:
print('Unknown flag: %s' % arg)
print_usage()
else:
positional_args.append(arg)
if len(positional_args) != 5:
print_usage()
original = positional_args[1]
if not os.path.isfile(original):
print('Invalid input: Original binary does not exist')
sys.exit(1)
recomp = positional_args[2]
if not os.path.isfile(recomp):
print('Invalid input: Recompiled binary does not exist')
sys.exit(1)
syms = positional_args[3]
if not os.path.isfile(syms):
print('Invalid input: Symbols PDB does not exist')
sys.exit(1)
source = positional_args[4]
if not os.path.isdir(source):
print('Invalid input: Source directory does not exist')
sys.exit(1)
# Declare a class that can automatically convert virtual executable addresses
# to file addresses
class Bin:
def __init__(self, filename):
self.file = open(filename, 'rb')
#HACK: Strictly, we should be parsing the header, but we know where
# everything is in these two files so we just jump straight there
# Read ImageBase
self.file.seek(0xB4)
self.imagebase = struct.unpack('i', self.file.read(4))[0]
# Read .text VirtualAddress
self.file.seek(0x184)
self.textvirt = struct.unpack('i', self.file.read(4))[0]
# Read .text PointerToRawData
self.file.seek(0x18C)
self.textraw = struct.unpack('i', self.file.read(4))[0]
def __del__(self):
if self.file:
self.file.close()
def get_addr(self, virt):
return virt - self.imagebase - self.textvirt + self.textraw
def read(self, offset, size):
self.file.seek(self.get_addr(offset))
return self.file.read(size)
line_dump = None
origfile = Bin(original)
recompfile = Bin(recomp)
class RecompiledInfo:
addr = None
size = None
name = None
print()
def get_recompiled_address(filename, line):
global line_dump, sym_dump
def get_wine_path(fn):
return subprocess.check_output(['winepath', '-w', fn]).decode('utf-8').strip()
# Load source lines from PDB
if not line_dump:
call = [os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'cvdump.exe'), '-l', '-s']
if os.name != 'nt':
# Run cvdump through wine and convert path to Windows-friendly wine path
call.insert(0, 'wine')
call.append(get_wine_path(syms))
else:
call.append(syms)
line_dump = subprocess.check_output(call).decode('utf-8').split('\r\n')
# Find requested filename/line in PDB
if os.name != 'nt':
# Convert filename to Wine path
filename = get_wine_path(filename)
#print('Looking for ' + filename + ' line ' + str(line))
addr = None
found = False
for i, s in enumerate(line_dump):
try:
sourcepath = s.split()[0]
if os.path.isfile(sourcepath) and os.path.samefile(sourcepath, filename):
lines = line_dump[i + 2].split()
if line == int(lines[0]):
# Found address
addr = int(lines[1], 16)
found = True
break
except IndexError:
pass
if found:
# Find size of function
for i, s in enumerate(line_dump):
if 'S_GPROC32' in s:
if int(s[26:34], 16) == addr:
obj = RecompiledInfo()
obj.addr = addr + recompfile.imagebase + recompfile.textvirt
obj.size = int(s[41:49], 16)
obj.name = s[77:]
return obj
md = Cs(CS_ARCH_X86, CS_MODE_32)
def parse_asm(file, addr, size):
asm = []
data = file.read(addr, size)
for i in md.disasm(data, 0):
if i.mnemonic == 'call':
# Filter out "calls" because the offsets we're not currently trying to
# match offsets. As long as there's a call in the right place, it's
# probably accurate.
asm.append(i.mnemonic)
else:
asm.append("%s %s" % (i.mnemonic, i.op_str))
return asm
function_count = 0
total_accuracy = 0
for subdir, dirs, files in os.walk(source):
for file in files:
srcfilename = os.path.join(os.path.abspath(subdir), file)
srcfile = open(srcfilename, 'r')
line_no = 0
while True:
try:
line = srcfile.readline()
line_no += 1
if not line:
break
if line.startswith('// OFFSET:'):
par = line[10:].strip().split()
module = par[0]
addr = int(par[1], 16)
find_open_bracket = line
while '{' not in find_open_bracket:
find_open_bracket = srcfile.readline()
line_no += 1
recinfo = get_recompiled_address(srcfilename, line_no)
if not recinfo:
print('Failed to find recompiled address of ' + hex(addr))
continue
origasm = parse_asm(origfile, addr, recinfo.size)
recompasm = parse_asm(recompfile, recinfo.addr, recinfo.size)
diff = difflib.SequenceMatcher(None, origasm, recompasm)
ratio = diff.ratio()
print('%s (%s / %s) is %.2f%% similar to the original' % (recinfo.name, hex(addr), hex(recinfo.addr), ratio * 100))
function_count += 1
total_accuracy += ratio
if verbose == addr:
udiff = difflib.unified_diff(origasm, recompasm)
for line in udiff:
print(line)
print()
print()
except UnicodeDecodeError:
break
if function_count > 0:
print('\nTotal accuracy %.2f%% across %i functions' % (total_accuracy / function_count * 100, function_count))