Browse Source

Merge branch 64bit

pull/25/head
Xadhoom 7 years ago
parent
commit
454ba99701
  1. 14
      Absolute/.clang-format
  2. 2224
      Absolute/absolute-decls.h
  3. 248
      Absolute/absolute-imports.h
  4. 47
      Absolute/absolute-stubs.h
  5. 55
      Absolute/absolute.cpp
  6. 6
      Absolute/absolute.h
  7. 230
      Absolute/default.ld
  8. 8500
      Absolute/harness.asm
  9. 34
      Absolute/hook.cpp
  10. 6
      Absolute/hook.h
  11. 4
      Absolute/sections.ld
  12. 88
      CMake/FindSDL2_mixer.cmake
  13. 11
      CMake/SDL2_fixed.cmake
  14. 9
      CMake/SDL2_fixed_old.cmake
  15. 26
      CMake/absolute.cmake
  16. 18
      CMake/sanitize.cmake
  17. 107
      CMakeLists.txt
  18. 2341
      Stub/diablo.cpp
  19. 12
      Stub/main_harness.cpp
  20. 4
      Stub/sanitize.cpp
  21. 54
      Stub/sanitize_coverage.cpp
  22. 5
      Stub/sanitize_coverage.h
  23. 4
      Stub/sdlrender.cpp

14
Absolute/.clang-format

@ -1,14 +0,0 @@
---
IndentWidth: 4
TabWidth: 4
---
Language: Cpp
UseTab: ForIndentation
AlignTrailingComments: false
BreakBeforeBraces: Linux
ColumnLimit: 120
IncludeBlocks: Preserve
AlignEscapedNewlines: DontAlign
AlignOperands: true
AllowShortFunctionsOnASingleLine: Inline
Standard: Cpp11

2224
Absolute/absolute-decls.h

File diff suppressed because it is too large Load Diff

248
Absolute/absolute-imports.h

@ -1,248 +0,0 @@
LINK_IMPORT(imp_CloseHandle, CloseHandle)
LINK_IMPORT(imp_CopyFileA, CopyFileA)
LINK_IMPORT(imp_CreateEventA, CreateEventA)
LINK_IMPORT(imp_CreateFileA, CreateFileA)
LINK_IMPORT(imp_CreateFileMappingA, CreateFileMappingA)
LINK_IMPORT(imp_CreateProcessA, CreateProcessA)
LINK_IMPORT(imp_DeleteCriticalSection, DeleteCriticalSection)
LINK_IMPORT(imp_DeleteFileA, DeleteFileA)
LINK_IMPORT(imp_DestroyWindow, DestroyWindow)
LINK_IMPORT(imp_DispatchMessageA, DispatchMessageA)
LINK_IMPORT(imp_EnterCriticalSection, EnterCriticalSection)
LINK_IMPORT(imp_ExitProcess, ExitProcess)
LINK_IMPORT(imp_FindClose, FindClose)
LINK_IMPORT(imp_FindFirstFileA, FindFirstFileA)
LINK_IMPORT(imp_FindWindowA, FindWindowA)
LINK_IMPORT(imp_GetComputerNameA, GetComputerNameA)
LINK_IMPORT(imp_GetCurrentProcessId, GetCurrentProcessId)
LINK_IMPORT(imp_GetCurrentThread, GetCurrentThread)
LINK_IMPORT(imp_GetCurrentThreadId, GetCurrentThreadId)
LINK_IMPORT(imp_GetDC, GetDC)
LINK_IMPORT(imp_GetDeviceCaps, GetDeviceCaps)
LINK_IMPORT(imp_GetDiskFreeSpaceA, GetDiskFreeSpaceA)
LINK_IMPORT(imp_GetFileAttributesA, GetFileAttributesA)
LINK_IMPORT(imp_GetFileSize, GetFileSize)
LINK_IMPORT(imp_GetForegroundWindow, GetForegroundWindow)
LINK_IMPORT(imp_GetLastActivePopup, GetLastActivePopup)
LINK_IMPORT(imp_GetLastError, GetLastError)
LINK_IMPORT(imp_GetModuleFileNameA, GetModuleFileNameA)
LINK_IMPORT(imp_GetPrivateProfileStringA, GetPrivateProfileStringA)
LINK_IMPORT(imp_GetSystemInfo, GetSystemInfo)
LINK_IMPORT(imp_GetSystemPaletteEntries, GetSystemPaletteEntries)
LINK_IMPORT(imp_GetTickCount, GetTickCount)
LINK_IMPORT(imp_GetTopWindow, GetTopWindow)
LINK_IMPORT(imp_GetWindow, GetWindow)
LINK_IMPORT(imp_GetWindowThreadProcessId, GetWindowThreadProcessId)
LINK_IMPORT(imp_GetWindowsDirectoryA, GetWindowsDirectoryA)
LINK_IMPORT(imp_InitializeCriticalSection, InitializeCriticalSection)
LINK_IMPORT(imp_LeaveCriticalSection, LeaveCriticalSection)
LINK_IMPORT(imp_MapViewOfFile, MapViewOfFile)
LINK_IMPORT(imp_OpenFile, OpenFile)
LINK_IMPORT(imp_PeekMessageA, PeekMessageA)
LINK_IMPORT(imp_PostMessageA, PostMessageA)
LINK_IMPORT(imp_ReadFile, ReadFile)
LINK_IMPORT(imp_ReleaseCapture, ReleaseCapture)
LINK_IMPORT(imp_ReleaseDC, ReleaseDC)
LINK_IMPORT(imp_SDrawGetFrameWindow, SDrawGetFrameWindow)
LINK_IMPORT(imp_SDrawRealizePalette, SDrawRealizePalette)
LINK_IMPORT(imp_SDrawUpdatePalette, SDrawUpdatePalette)
LINK_IMPORT(imp_SErrGetErrorStr, SErrGetErrorStr)
LINK_IMPORT(imp_SErrGetLastError, SErrGetLastError)
LINK_IMPORT(imp_SErrSetLastError, SErrSetLastError)
LINK_IMPORT(imp_SFileCloseArchive, SFileCloseArchive)
LINK_IMPORT(imp_SFileCloseFile, SFileCloseFile)
LINK_IMPORT(imp_SFileDdaBeginEx, SFileDdaBeginEx)
LINK_IMPORT(imp_SFileDdaDestroy, SFileDdaDestroy)
LINK_IMPORT(imp_SFileDdaEnd, SFileDdaEnd)
LINK_IMPORT(imp_SFileDdaGetPos, SFileDdaGetPos)
LINK_IMPORT(imp_SFileDdaInitialize, SFileDdaInitialize)
LINK_IMPORT(imp_SFileDdaSetVolume, SFileDdaSetVolume)
LINK_IMPORT(imp_SFileGetFileArchive, SFileGetFileArchive)
LINK_IMPORT(imp_SFileGetFileSize, SFileGetFileSize)
LINK_IMPORT(imp_SFileOpenArchive, SFileOpenArchive)
LINK_IMPORT(imp_SFileOpenFile, SFileOpenFile)
LINK_IMPORT(imp_SFileOpenFileEx, SFileOpenFileEx)
LINK_IMPORT(imp_SFileReadFile, SFileReadFile)
LINK_IMPORT(imp_SFileSetFilePointer, SFileSetFilePointer)
LINK_IMPORT(imp_SMemAlloc, SMemAlloc)
LINK_IMPORT(imp_SMemFree, SMemFree)
LINK_IMPORT(imp_SNetCreateGame, SNetCreateGame)
LINK_IMPORT(imp_SNetDestroy, SNetDestroy)
LINK_IMPORT(imp_SNetDropPlayer, SNetDropPlayer)
LINK_IMPORT(imp_SNetGetGameInfo, SNetGetGameInfo)
LINK_IMPORT(imp_SNetGetOwnerTurnsWaiting, SNetGetOwnerTurnsWaiting)
LINK_IMPORT(imp_SNetGetProviderCaps, SNetGetProviderCaps)
LINK_IMPORT(imp_SNetGetTurnsInTransit, SNetGetTurnsInTransit)
LINK_IMPORT(imp_SNetInitializeProvider, SNetInitializeProvider)
LINK_IMPORT(imp_SNetLeaveGame, SNetLeaveGame)
LINK_IMPORT(imp_SNetPerformUpgrade, SNetPerformUpgrade)
LINK_IMPORT(imp_SNetReceiveMessage, SNetReceiveMessage)
LINK_IMPORT(imp_SNetReceiveTurns, SNetReceiveTurns)
LINK_IMPORT(imp_SNetRegisterEventHandler, SNetRegisterEventHandler)
LINK_IMPORT(imp_SNetSendMessage, SNetSendMessage)
LINK_IMPORT(imp_SNetSendServerChatCommand, SNetSendServerChatCommand)
LINK_IMPORT(imp_SNetSendTurn, SNetSendTurn)
LINK_IMPORT(imp_SNetSetBasePlayer, SNetSetBasePlayer)
LINK_IMPORT(imp_SNetUnregisterEventHandler, SNetUnregisterEventHandler)
LINK_IMPORT(imp_SRegLoadData, SRegLoadData)
LINK_IMPORT(imp_SRegLoadString, SRegLoadString)
LINK_IMPORT(imp_SRegLoadValue, SRegLoadValue)
LINK_IMPORT(imp_SRegSaveData, SRegSaveData)
LINK_IMPORT(imp_SRegSaveString, SRegSaveString)
LINK_IMPORT(imp_SRegSaveValue, SRegSaveValue)
LINK_IMPORT(imp_SStrCopy, SStrCopy)
LINK_IMPORT(imp_SetCapture, SetCapture)
LINK_IMPORT(imp_SetCursorPos, SetCursorPos)
LINK_IMPORT(imp_SetEndOfFile, SetEndOfFile)
LINK_IMPORT(imp_SetFileAttributesA, SetFileAttributesA)
LINK_IMPORT(imp_SetFilePointer, SetFilePointer)
LINK_IMPORT(imp_SetFocus, SetFocus)
LINK_IMPORT(imp_SetForegroundWindow, SetForegroundWindow)
LINK_IMPORT(imp_SetLastError, SetLastError)
LINK_IMPORT(imp_SetThreadPriority, SetThreadPriority)
LINK_IMPORT(imp_ShowCursor, ShowCursor)
LINK_IMPORT(imp_Sleep, Sleep)
LINK_IMPORT(imp_TranslateMessage, TranslateMessage)
LINK_IMPORT(imp_UiAppActivate, UiAppActivate)
LINK_IMPORT(imp_UiArtCallback, UiArtCallback)
LINK_IMPORT(imp_UiAuthCallback, UiAuthCallback)
LINK_IMPORT(imp_UiCategoryCallback, UiCategoryCallback)
LINK_IMPORT(imp_UiCopyProtError, UiCopyProtError)
LINK_IMPORT(imp_UiCreateGameCallback, UiCreateGameCallback)
LINK_IMPORT(imp_UiCreatePlayerDescription, UiCreatePlayerDescription)
LINK_IMPORT(imp_UiCreditsDialog, UiCreditsDialog)
LINK_IMPORT(imp_UiDestroy, UiDestroy)
LINK_IMPORT(imp_UiDrawDescCallback, UiDrawDescCallback)
LINK_IMPORT(imp_UiGetDataCallback, UiGetDataCallback)
LINK_IMPORT(imp_UiInitialize, UiInitialize)
LINK_IMPORT(imp_UiMainMenuDialog, UiMainMenuDialog)
LINK_IMPORT(imp_UiMessageBoxCallback, UiMessageBoxCallback)
LINK_IMPORT(imp_UiProfileCallback, UiProfileCallback)
LINK_IMPORT(imp_UiProfileDraw, UiProfileDraw)
LINK_IMPORT(imp_UiProfileGetString, UiProfileGetString)
LINK_IMPORT(imp_UiProgressDialog, UiProgressDialog)
LINK_IMPORT(imp_UiSelHeroMultDialog, UiSelHeroMultDialog)
LINK_IMPORT(imp_UiSelHeroSingDialog, UiSelHeroSingDialog)
LINK_IMPORT(imp_UiSelectGame, UiSelectGame)
LINK_IMPORT(imp_UiSelectProvider, UiSelectProvider)
LINK_IMPORT(imp_UiSetupPlayerInfo, UiSetupPlayerInfo)
LINK_IMPORT(imp_UiSoundCallback, UiSoundCallback)
LINK_IMPORT(imp_UiTitleDialog, UiTitleDialog)
LINK_IMPORT(imp_UiValidPlayerName, UiValidPlayerName)
LINK_IMPORT(imp_UnmapViewOfFile, UnmapViewOfFile)
LINK_IMPORT(imp_WaitForInputIdle, WaitForInputIdle)
LINK_IMPORT(imp_WaitForSingleObject, WaitForSingleObject)
LINK_IMPORT(imp_WriteFile, WriteFile)
LINK_IMPORT(imp_wsprintfA, wsprintfA)
MISSING_IMPORT(imp_CompareStringA, CompareStringA)
MISSING_IMPORT(imp_CompareStringW, CompareStringW)
MISSING_IMPORT(imp_CreateThread, CreateThread)
MISSING_IMPORT(imp_CreateWindowExA, CreateWindowExA)
MISSING_IMPORT(imp_DefWindowProcA, DefWindowProcA)
MISSING_IMPORT(imp_DialogBoxParamA, DialogBoxParamA)
MISSING_IMPORT(imp_EndDialog, EndDialog)
MISSING_IMPORT(imp_ExitThread, ExitThread)
MISSING_IMPORT(imp_FileTimeToLocalFileTime, FileTimeToLocalFileTime)
MISSING_IMPORT(imp_FileTimeToSystemTime, FileTimeToSystemTime)
MISSING_IMPORT(imp_FindNextFileA, FindNextFileA)
MISSING_IMPORT(imp_FlushFileBuffers, FlushFileBuffers)
MISSING_IMPORT(imp_FormatMessageA, FormatMessageA)
MISSING_IMPORT(imp_FreeEnvironmentStringsA, FreeEnvironmentStringsA)
MISSING_IMPORT(imp_FreeEnvironmentStringsW, FreeEnvironmentStringsW)
MISSING_IMPORT(imp_GdiSetBatchLimit, GdiSetBatchLimit)
MISSING_IMPORT(imp_GetACP, GetACP)
MISSING_IMPORT(imp_GetCPInfo, GetCPInfo)
MISSING_IMPORT(imp_GetClassNameA, GetClassNameA)
MISSING_IMPORT(imp_GetCommandLineA, GetCommandLineA)
MISSING_IMPORT(imp_GetCurrentDirectoryA, GetCurrentDirectoryA)
MISSING_IMPORT(imp_GetCurrentProcess, GetCurrentProcess)
MISSING_IMPORT(imp_GetDesktopWindow, GetDesktopWindow)
MISSING_IMPORT(imp_GetDriveTypeA, GetDriveTypeA)
MISSING_IMPORT(imp_GetEnvironmentStrings, GetEnvironmentStrings)
MISSING_IMPORT(imp_GetEnvironmentStringsW, GetEnvironmentStringsW)
MISSING_IMPORT(imp_GetFileType, GetFileType)
MISSING_IMPORT(imp_GetFileVersionInfoA, GetFileVersionInfoA)
MISSING_IMPORT(imp_GetFileVersionInfoSizeA, GetFileVersionInfoSizeA)
MISSING_IMPORT(imp_GetLocalTime, GetLocalTime)
MISSING_IMPORT(imp_GetLocaleInfoA, GetLocaleInfoA)
MISSING_IMPORT(imp_GetLocaleInfoW, GetLocaleInfoW)
MISSING_IMPORT(imp_GetLogicalDriveStringsA, GetLogicalDriveStringsA)
MISSING_IMPORT(imp_GetModuleHandleA, GetModuleHandleA)
MISSING_IMPORT(imp_GetOEMCP, GetOEMCP)
MISSING_IMPORT(imp_GetProcAddress, GetProcAddress)
MISSING_IMPORT(imp_GetStartupInfoA, GetStartupInfoA)
MISSING_IMPORT(imp_GetStdHandle, GetStdHandle)
MISSING_IMPORT(imp_GetStockObject, GetStockObject)
MISSING_IMPORT(imp_GetStringTypeA, GetStringTypeA)
MISSING_IMPORT(imp_GetStringTypeW, GetStringTypeW)
MISSING_IMPORT(imp_GetSystemMetrics, GetSystemMetrics)
MISSING_IMPORT(imp_GetSystemTime, GetSystemTime)
MISSING_IMPORT(imp_GetTimeZoneInformation, GetTimeZoneInformation)
MISSING_IMPORT(imp_GetUserNameA, GetUserNameA)
MISSING_IMPORT(imp_GetVersion, GetVersion)
MISSING_IMPORT(imp_GetVersionExA, GetVersionExA)
MISSING_IMPORT(imp_GetWindowLongA, GetWindowLongA)
MISSING_IMPORT(imp_GetWindowRect, GetWindowRect)
MISSING_IMPORT(imp_HeapAlloc, HeapAlloc)
MISSING_IMPORT(imp_HeapCreate, HeapCreate)
MISSING_IMPORT(imp_HeapDestroy, HeapDestroy)
MISSING_IMPORT(imp_HeapFree, HeapFree)
MISSING_IMPORT(imp_HeapReAlloc, HeapReAlloc)
MISSING_IMPORT(imp_HeapSize, HeapSize)
MISSING_IMPORT(imp_InterlockedDecrement, InterlockedDecrement)
MISSING_IMPORT(imp_InterlockedIncrement, InterlockedIncrement)
MISSING_IMPORT(imp_InvalidateRect, InvalidateRect)
MISSING_IMPORT(imp_IsBadReadPtr, IsBadReadPtr)
MISSING_IMPORT(imp_IsBadWritePtr, IsBadWritePtr)
MISSING_IMPORT(imp_LCMapStringA, LCMapStringA)
MISSING_IMPORT(imp_LCMapStringW, LCMapStringW)
MISSING_IMPORT(imp_LoadCursorA, LoadCursorA)
MISSING_IMPORT(imp_LoadIconA, LoadIconA)
MISSING_IMPORT(imp_LoadImageA, LoadImageA)
MISSING_IMPORT(imp_LoadLibraryA, LoadLibraryA)
MISSING_IMPORT(imp_MessageBoxA, MessageBoxA)
MISSING_IMPORT(imp_MultiByteToWideChar, MultiByteToWideChar)
MISSING_IMPORT(imp_PostQuitMessage, PostQuitMessage)
MISSING_IMPORT(imp_RaiseException, RaiseException)
MISSING_IMPORT(imp_RegCloseKey, RegCloseKey)
MISSING_IMPORT(imp_RegOpenKeyExA, RegOpenKeyExA)
MISSING_IMPORT(imp_RegQueryValueExA, RegQueryValueExA)
MISSING_IMPORT(imp_RegSetValueExA, RegSetValueExA)
MISSING_IMPORT(imp_RegisterClassExA, RegisterClassExA)
MISSING_IMPORT(imp_ResetEvent, ResetEvent)
MISSING_IMPORT(imp_RtlUnwind, RtlUnwind)
MISSING_IMPORT(imp_SDrawDestroy, SDrawDestroy)
MISSING_IMPORT(imp_SDrawManualInitialize, SDrawManualInitialize)
MISSING_IMPORT(imp_SDrawMessageBox, SDrawMessageBox)
MISSING_IMPORT(imp_SFileSetBasePath, SFileSetBasePath)
MISSING_IMPORT(imp_SHGetPathFromIDListA, SHGetPathFromIDListA)
MISSING_IMPORT(imp_SHGetSpecialFolderLocation, SHGetSpecialFolderLocation)
MISSING_IMPORT(imp_SVidDestroy, SVidDestroy)
MISSING_IMPORT(imp_SVidInitialize, SVidInitialize)
MISSING_IMPORT(imp_SVidPlayBegin, SVidPlayBegin)
MISSING_IMPORT(imp_SVidPlayContinue, SVidPlayContinue)
MISSING_IMPORT(imp_SVidPlayEnd, SVidPlayEnd)
MISSING_IMPORT(imp_SetDlgItemTextA, SetDlgItemTextA)
MISSING_IMPORT(imp_SetEnvironmentVariableA, SetEnvironmentVariableA)
MISSING_IMPORT(imp_SetEvent, SetEvent)
MISSING_IMPORT(imp_SetHandleCount, SetHandleCount)
MISSING_IMPORT(imp_SetStdHandle, SetStdHandle)
MISSING_IMPORT(imp_SetUnhandledExceptionFilter, SetUnhandledExceptionFilter)
MISSING_IMPORT(imp_SetWindowLongA, SetWindowLongA)
MISSING_IMPORT(imp_SetWindowPos, SetWindowPos)
MISSING_IMPORT(imp_ShellExecuteA, ShellExecuteA)
MISSING_IMPORT(imp_ShowWindow, ShowWindow)
MISSING_IMPORT(imp_StormDestroy, StormDestroy)
MISSING_IMPORT(imp_TerminateProcess, TerminateProcess)
MISSING_IMPORT(imp_TlsAlloc, TlsAlloc)
MISSING_IMPORT(imp_TlsGetValue, TlsGetValue)
MISSING_IMPORT(imp_TlsSetValue, TlsSetValue)
MISSING_IMPORT(imp_UnhandledExceptionFilter, UnhandledExceptionFilter)
MISSING_IMPORT(imp_UpdateWindow, UpdateWindow)
MISSING_IMPORT(imp_VerQueryValueA, VerQueryValueA)
MISSING_IMPORT(imp_VirtualAlloc, VirtualAlloc)
MISSING_IMPORT(imp_VirtualFree, VirtualFree)
MISSING_IMPORT(imp_VirtualQuery, VirtualQuery)
MISSING_IMPORT(imp_WideCharToMultiByte, WideCharToMultiByte)
MISSING_IMPORT(imp_lstrcpynA, lstrcpynA)
MISSING_IMPORT(imp_wvsprintfA, wvsprintfA)

47
Absolute/absolute-stubs.h

@ -1,47 +0,0 @@
LINK_STUB(d_CaptureScreen, CaptureScreen)
LINK_STUB(d_DDErrMsg, DDErrMsg)
LINK_STUB(d_DirErrorDlg, DirErrorDlg)
LINK_STUB(d_DiskFreeDlg, DiskFreeDlg)
LINK_STUB(d_DrawDlg, DrawDlg)
LINK_STUB(d_ErrDlg, ErrDlg)
LINK_STUB(d_ErrOkDlg, ErrOkDlg)
LINK_STUB(d_FileErrDlg, FileErrDlg)
LINK_STUB(d_InsertCDDlg, InsertCDDlg)
LINK_STUB(d_MainWndProc, MainWndProc)
LINK_STUB(d_ReadOnlyTest, ReadOnlyTest)
LINK_STUB(d_RestrictedTest, RestrictedTest)
LINK_STUB(d_SetWindowProc, SetWindowProc)
LINK_STUB(d_TermMsg, TermMsg)
LINK_STUB(d_TraceLastError, TraceLastError)
LINK_STUB(d_dthread_cleanup, dthread_cleanup)
LINK_STUB(d_dthread_remove_player, dthread_remove_player)
LINK_STUB(d_dthread_send_delta, dthread_send_delta)
LINK_STUB(d_dthread_start, dthread_start)
LINK_STUB(d_dx_init, dx_init)
LINK_STUB(d_dx_reinit, dx_reinit)
LINK_STUB(d_exception_get_filter, exception_get_filter)
LINK_STUB(d_init_archives, init_archives)
LINK_STUB(d_init_create_window, init_create_window)
LINK_STUB(d_init_get_file_info, init_get_file_info)
LINK_STUB(d_lock_buf_priv, lock_buf_priv)
LINK_STUB(d_music_start, music_start)
LINK_STUB(d_music_stop, music_stop)
LINK_STUB(d_nthread_cleanup, nthread_cleanup)
LINK_STUB(d_nthread_has_500ms_passed, nthread_has_500ms_passed)
LINK_STUB(d_nthread_ignore_mutex, nthread_ignore_mutex)
LINK_STUB(d_nthread_recv_turns, nthread_recv_turns)
LINK_STUB(d_nthread_send_and_recv_turn, nthread_send_and_recv_turn)
LINK_STUB(d_nthread_set_turn_upper_bit, nthread_set_turn_upper_bit)
LINK_STUB(d_nthread_start, nthread_start)
LINK_STUB(d_nthread_terminate_game, nthread_terminate_game)
LINK_STUB(d_play_movie, play_movie)
LINK_STUB(d_snd_init, snd_init)
LINK_STUB(d_snd_play_snd, snd_play_snd)
LINK_STUB(d_snd_playing, snd_playing)
LINK_STUB(d_snd_stop_snd, snd_stop_snd)
LINK_STUB(d_snd_update, snd_update)
LINK_STUB(d_sound_file_cleanup, sound_file_cleanup)
LINK_STUB(d_sound_file_load, sound_file_load)
LINK_STUB(d_sound_get_or_set_music_volume, sound_get_or_set_music_volume)
LINK_STUB(d_sound_get_or_set_sound_volume, sound_get_or_set_sound_volume)
LINK_STUB(d_unlock_buf_priv, unlock_buf_priv)

55
Absolute/absolute.cpp

@ -1,55 +0,0 @@
#include <assert.h>
#include <string.h>
#include <sys/mman.h>
#include "Stub/stubs.h"
#include "absolute.h"
#include "hook.h"
static void missing_import()
{
UNIMPLEMENTED();
}
static void link_imports()
{
#define LINK_IMPORT(imp_name, name) imp_name = (void *)name;
#define MISSING_IMPORT(imp_name, name) imp_name = (void *)missing_import;
#include "absolute-imports.h"
}
static void link_stubs()
{
#define LINK_STUB(orig, dest) hook((void *)orig, (void *)dest);
#include "absolute-stubs.h"
LINK_STUB(d_srand, srand_miniwin);
LINK_STUB(d_rand, rand_miniwin);
LINK_STUB(d_time, time);
LINK_STUB(d_sprintf, sprintf); // Calls into kernel
// These functions potentially access uninitialized memory
LINK_STUB(d_strcat, strcat);
LINK_STUB(d_strcpy, strcpy);
LINK_STUB(d_strlen, strlen);
// strchr() is overloaded in glibc C++ mode, pick right function....
char *(*strchr_overload)(char *, int) = strchr;
LINK_STUB(d_strchr, strchr_overload);
}
static void protect_rdata(int prot)
{
mprotect(&__start_rdata, &__end_rdata - &__start_rdata, prot);
}
void init_absolute()
{
protect_rdata(PROT_READ | PROT_WRITE);
link_imports();
protect_rdata(PROT_READ);
link_stubs();
}

6
Absolute/absolute.h

@ -1,6 +0,0 @@
#pragma once
#include "../types.h"
#include "absolute-decls.h"
void init_absolute();

230
Absolute/default.ld

@ -1,230 +0,0 @@
/* Script for -z combreloc -z separate-code: combine and sort reloc sections with separate code segment */
/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf32-i386", "elf32-i386",
"elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SEARCH_DIR("=/usr/local/lib/i386-linux-gnu"); SEARCH_DIR("=/lib/i386-linux-gnu"); SEARCH_DIR("=/usr/lib/i386-linux-gnu"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu32"); SEARCH_DIR("=/usr/local/lib32"); SEARCH_DIR("=/lib32"); SEARCH_DIR("=/usr/lib32"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("=/usr/i386-linux-gnu/lib32"); SEARCH_DIR("=/usr/x86_64-linux-gnu/lib32"); SEARCH_DIR("=/usr/i386-linux-gnu/lib");
SECTIONS
{
INCLUDE "sections.ld"
/* Note: Start address of regular sections was adjusted for
there to be enough contiguous virtual address space for eg. Valgrind. */
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x0A00000));
. = SEGMENT_START("text-segment", 0x0A00000) + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
*(.rel.ifunc)
}
.rel.plt :
{
*(.rel.plt)
PROVIDE_HIDDEN (__rel_iplt_start = .);
*(.rel.iplt)
PROVIDE_HIDDEN (__rel_iplt_end = .);
}
. = ALIGN(CONSTANT (MAXPAGESIZE));
.init :
{
KEEP (*(SORT_NONE(.init)))
}
.plt : { *(.plt) *(.iplt) }
.plt.got : { *(.plt.got) }
.plt.sec : { *(.plt.sec) }
.text :
{
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
}
.fini :
{
KEEP (*(SORT_NONE(.fini)))
}
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
. = ALIGN(CONSTANT (MAXPAGESIZE));
/* Adjust the address for the rodata segment. We want to adjust up to
the same address within the page on the next page up. */
. = SEGMENT_START("rodata-segment", ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)));
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
.gcc_except_table.*) }
.gnu_extab : ONLY_IF_RO { *(.gnu_extab*) }
/* These sections are generated by the Sun/Oracle C++ compiler. */
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
.exception_ranges*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
.gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
.exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
/* Thread Local Storage sections */
.tdata :
{
PROVIDE_HIDDEN (__tdata_start = .);
*(.tdata .tdata.* .gnu.linkonce.td.*)
}
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
.got : { *(.got) *(.igot) }
. = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 12 ? 12 : 0, .);
.got.plt : { *(.got.plt) *(.igot.plt) }
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
. = .;
__bss_start = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
. = ALIGN(32 / 8);
. = SEGMENT_START("ldata-segment", .);
. = ALIGN(32 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/* DWARF Extension. */
.debug_macro 0 : { *(.debug_macro) }
.debug_addr 0 : { *(.debug_addr) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}

8500
Absolute/harness.asm

File diff suppressed because it is too large Load Diff

34
Absolute/hook.cpp

@ -1,34 +0,0 @@
#include "Stub/asserts.h"
#include <assert.h>
#include <cstdio>
#include <sys/mman.h>
#include "hook.h"
#pragma pack(push, 1)
struct hook_jmp_rel32 {
uint8_t op;
int32_t offset;
};
#pragma pack(pop)
static void hook_assemble_jump(void *at, void *to)
{
hook_jmp_rel32 *jmp = (hook_jmp_rel32 *)at;
jmp->op = 0xE9;
jmp->offset = (intptr_t)to - ((intptr_t)at + sizeof(*jmp));
}
static int hook_unprotect(void *address, size_t size)
{
// Align to bottom of page
address = (void *)((uintptr_t)address & ~(4096 - 1));
return mprotect(address, size, PROT_READ | PROT_WRITE | PROT_EXEC);
}
void hook(void *at, void *to)
{
ASSERT(hook_unprotect(at, sizeof(hook_jmp_rel32)) == 0);
hook_assemble_jump(at, to);
}

6
Absolute/hook.h

@ -1,6 +0,0 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
void hook(void *at, void *to);

4
Absolute/sections.ld

@ -1,4 +0,0 @@
. = 0x00401000; .d.text : { *(.d.text) }
. = 0x00479000; .d.rdata : { *(.d.rdata) }
. = 0x00483000; .d.data : { *(.d.data) }
. = 0x004B7930; .d.bss : { *(.d.bss) }

88
CMake/FindSDL2_mixer.cmake

@ -0,0 +1,88 @@
# - Locate SDL2_mixer library
# This module defines:
# SDL2_MIXER_LIBRARIES, the name of the library to link against
# SDL2_MIXER_INCLUDE_DIRS, where to find the headers
# SDL2_MIXER_FOUND, if false, do not try to link against
# SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL2_mixer
#
# For backward compatiblity the following variables are also set:
# SDLMIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
# SDLMIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
# SDLMIXER_FOUND (same value as SDL2_MIXER_FOUND)
#
# $SDLDIR is an environment variable that would
# correspond to the ./configure --prefix=$SDLDIR
# used in building SDL.
#
# Created by Eric Wing. This was influenced by the FindSDL.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(NOT SDL2_MIXER_INCLUDE_DIR AND SDLMIXER_INCLUDE_DIR)
set(SDL2_MIXER_INCLUDE_DIR ${SDLMIXER_INCLUDE_DIR} CACHE PATH "directory cache
entry initialized from old variable name")
endif()
find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
HINTS
ENV SDLMIXERDIR
ENV SDLDIR
PATH_SUFFIXES include/SDL2 include/SDL2.0 include
)
if(NOT SDL2_MIXER_LIBRARY AND SDLMIXER_LIBRARY)
set(SDL2_MIXER_LIBRARY ${SDLMIXER_LIBRARY} CACHE FILEPATH "file cache entry
initialized from old variable name")
endif()
find_library(SDL2_MIXER_LIBRARY
NAMES SDL2_mixer
HINTS
ENV SDLMIXERDIR
ENV SDLDIR
PATH_SUFFIXES lib
)
if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h")
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define[ \t]+SDL2_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MAJOR "${SDL2_MIXER_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL2_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MINOR "${SDL2_MIXER_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL2_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_PATCH "${SDL2_MIXER_VERSION_PATCH_LINE}")
set(SDL2_MIXER_VERSION_STRING ${SDL2_MIXER_VERSION_MAJOR}.${SDL2_MIXER_VERSION_MINOR}.${SDL2_MIXER_VERSION_PATCH})
unset(SDL2_MIXER_VERSION_MAJOR_LINE)
unset(SDL2_MIXER_VERSION_MINOR_LINE)
unset(SDL2_MIXER_VERSION_PATCH_LINE)
unset(SDL2_MIXER_VERSION_MAJOR)
unset(SDL2_MIXER_VERSION_MINOR)
unset(SDL2_MIXER_VERSION_PATCH)
endif()
set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
VERSION_VAR SDL2_MIXER_VERSION_STRING)
# for backward compatiblity
set(SDLMIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
set(SDLMIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
set(SDLMIXER_FOUND ${SDL2_MIXER_FOUND})
mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)

11
CMake/SDL2_fixed.cmake

@ -1,2 +1,9 @@
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2 SDL2_mixer)
find_package(SDL2 REQUIRED)
# WORKAROUND: Arch Linux SDL2 cmake config not setting this variable
if(NOT SDL2_LIBRARIES)
# Note: you will probably need to install multilib/lib32-dbus on Arch
set(SDL2_LIBRARIES SDL2::SDL2)
endif()
# WORKAROUND: Issue with Ubuntu 16.04 having whitespace (CMP0004)
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)

9
CMake/SDL2_fixed_old.cmake

@ -1,9 +0,0 @@
find_package(SDL2 REQUIRED)
# WORKAROUND: Arch Linux SDL2 cmake config not setting this variable
if(NOT SDL2_LIBRARIES)
# Note: you will probably need to install multilib/lib32-dbus on Arch
set(SDL2_LIBRARIES SDL2::SDL2)
endif()
# WORKAROUND: Issue with Ubuntu 16.04 having whitespace (CMP0004)
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)

26
CMake/absolute.cmake

@ -1,26 +0,0 @@
set(ORIGINAL_EXE "${CMAKE_SOURCE_DIR}/Diablo.exe")
if(EXISTS "${ORIGINAL_EXE}")
message(STATUS "Using EXE at ${ORIGINAL_EXE}")
file(MD5 ${ORIGINAL_EXE} MD5SUM)
if(NOT MD5SUM STREQUAL "da62d5cd8bd71a0b66e6d4ef7a111233")
message(FATAL_ERROR "MD5 of EXE is not correct (${MD5SUM})")
endif()
enable_language(ASM_NASM)
set(HARNESS_ASM "${CMAKE_SOURCE_DIR}/Absolute/harness.asm")
# This can not be an OBJECT library since those can not have link flags on older versions of cmake
add_library(harness STATIC ${HARNESS_ASM})
target_compile_options(harness PRIVATE -f elf -DEXE=\"${ORIGINAL_EXE}\")
target_compile_options(harness INTERFACE -fno-pie -fno-pic)
target_compile_definitions(harness INTERFACE -DNO_GLOBALS)
target_link_libraries(harness INTERFACE
-L${CMAKE_SOURCE_DIR}/Absolute -Tdefault.ld
)
else()
message(STATUS "Original .exe not found at ${ORIGINAL_EXE}")
endif()

18
CMake/sanitize.cmake

@ -1,18 +0,0 @@
include(CheckCXXCompilerFlag)
include(CMakePushCheckState)
set(SANITIZE_OPTIONS -fsanitize=null -fsanitize=return)
# TODO: use "-fsanitize=object-size"
# "-fsanitize=bounds" not enabled because the code often generates temporary pointers out-of-bounds of arrays
# Note: The compiler must always support recovery because the decompiled code is not ASAN-clean
set(SANITIZE_ADDRESS_FLAGS -fsanitize=address -fsanitize-recover=address)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES ${SANITIZE_ADDRESS_FLAGS})
check_cxx_compiler_flag("${SANITIZE_ADDRESS_FLAGS}" HAS_SANITIZE_ADDRESS)
cmake_pop_check_state()
if(HAS_SANITIZE_ADDRESS)
list(APPEND SANITIZE_OPTIONS ${SANITIZE_ADDRESS_FLAGS})
endif()

107
CMakeLists.txt

@ -11,30 +11,37 @@ endif()
include(CMake/out_of_tree.cmake)
# This *must* be included before calling `project()`, due to setting early compiler flags.
include(CMake/32bit.cmake)
if($ENV{FORCE32})
include(CMake/32bit.cmake)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
project(devil-miniwin
project(devilutionX
VERSION 0.0.1
LANGUAGES C CXX
)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${devilutionX_SOURCE_DIR}/CMake")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
message(WARNING "sizeof(void*) == ${CMAKE_SIZEOF_VOID_P}.")
message(FATAL_ERROR [[This project can only be compiled in 32-bit mode.]])
if($ENV{FORCE32})
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
message(WARNING "sizeof(void*) == ${CMAKE_SIZEOF_VOID_P}.")
message(FATAL_ERROR [[32-bit mode was requested but pointer size is not 32 bits.]])
endif()
endif()
# Note: In Debug mode, GCC generates spurious memory references that upset Valgrind,
# these options fix that.
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fno-omit-frame-pointer")
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Clang/LLVM optimizations break everything
# string(APPEND CMAKE_CXX_FLAGS_DEBUG " -Og")
# string(APPEND CMAKE_CXX_FLAGS_DEBUG " -fvar-tracking-assignments -ggdb -gdwarf-4")
endif()
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
set(SOURCES
Source/automap.cpp
@ -132,7 +139,7 @@ set(STUB_SOURCES
Stub/miniwin_io.cpp
Stub/miniwin_msg_sdl.cpp
Stub/storm_net.cpp
Stub/validate.cpp
# Stub/validate.cpp
Stub/sdlrender.cpp
Stub/gamemenu.cpp
@ -150,11 +157,9 @@ set(STUB_SOURCES
)
include(CMake/SDL2_fixed.cmake)
include(CMake/sanitize.cmake)
include(CMake/absolute.cmake)
include(CMake/CodeCoverage.cmake)
include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIR})
include_directories(. Stub)
@ -180,7 +185,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-fms-extensions)
endif()
# Vanilla build
add_executable(devilution
${SOURCES}
${STUB_SOURCES}
@ -190,80 +194,11 @@ add_executable(devilution
target_link_libraries(devilution PUBLIC
m
${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
)
# Coverage tracing library (compiled separately so it itself is not traced & can be optimized)
add_library(sanitize_coverage STATIC Stub/sanitize_coverage.cpp)
target_compile_options(sanitize_coverage PRIVATE -O2 -fno-pie -fno-pic)
cmake_push_check_state()
set(SANITIZE_COVERAGE_FLAGS -fsanitize-coverage=trace-pc)
set(CMAKE_REQUIRED_FLAGS ${SANITIZE_COVERAGE_FLAGS})
check_cxx_source_compiles([[extern "C" void __sanitizer_cov_trace_pc(void) {} int main() { return 0; }]] HAS_SANITIZE_COVERAGE)
cmake_pop_check_state()
# xxhash fast hashing library
add_library(xxhash STATIC 3rdParty/xxhash/xxhash.c)
set_source_files_properties(3rdParty/xxhash/xxhash.c PROPERTIES LANGUAGE CXX)
target_include_directories(xxhash PUBLIC 3rdParty/xxhash)
target_compile_options(xxhash PRIVATE -O3 -fno-pie -fno-pic)
# Build with harness enabled (conflicts with sanitizers)
if(TARGET harness)
add_executable(devil-harness
${SOURCES}
${STUB_SOURCES}
# Stub/main_harness.cpp
Stub/main_test.cpp
Absolute/absolute.cpp
Absolute/hook.cpp
Stub/test_utils.cpp
)
if(HAS_SANITIZE_COVERAGE)
target_compile_options(devil-harness PRIVATE ${SANITIZE_COVERAGE_FLAGS})
target_compile_definitions(devil-harness PRIVATE -DHAVE_SANITIZE_COVERGE)
endif()
target_compile_definitions(devil-harness PUBLIC -DHAVE_HARNESS)
target_link_libraries(devil-harness PUBLIC
m
harness
xxhash
sanitize_coverage
${SDL2_LIBRARIES}
)
endif()
# Build with sanitizers enabled
add_executable(devil-sanitize
${SOURCES}
${STUB_SOURCES}
Stub/main_test.cpp
Stub/test_utils.cpp
Stub/sanitize.cpp
)
target_compile_options(devil-sanitize PRIVATE
${SANITIZE_OPTIONS}
${COVERAGE_COMPILER_FLAGS}
)
target_link_libraries(devil-sanitize PUBLIC
m
xxhash
sanitize_coverage
${SDL2_LIBRARIES}
${SANITIZE_OPTIONS}
${COVERAGE_COMPILER_FLAGS}
)
if(COVERAGE_COMPILER_FLAGS)
SETUP_TARGET_FOR_COVERAGE_GCOVR_HTML(
NAME devil-sanitize-coverage
EXECUTABLE devil-sanitize
DEPENDENCIES devil-sanitize
)
endif()

2341
Stub/diablo.cpp

File diff suppressed because it is too large Load Diff

12
Stub/main_harness.cpp

@ -1,12 +0,0 @@
#include "../types.h"
#include "Absolute/absolute.h"
#include "stubs.h"
#include <stddef.h>
int main(int argc, char **argv)
{
init_absolute();
d_WinMain(NULL, NULL, "", 0);
}

4
Stub/sanitize.cpp

@ -1,4 +0,0 @@
// extern "C" const char *__asan_default_options()
// {
// return "halt_on_error=0:print_legend=0";
// }

54
Stub/sanitize_coverage.cpp

@ -1,54 +0,0 @@
#include "asserts.h"
#include <malloc.h>
#include <stdint.h>
#include <string.h>
#include "sanitize_coverage.h"
constexpr int pc_shift = 2;
constexpr uint32_t coverage_size = 1024 * 1024; // must be power of 2
constexpr uint32_t coverage_mask = coverage_size - 1;
extern char __executable_start;
extern char __etext;
static char coverage_data[coverage_size];
static bool found_new = false;
void coverage_init()
{
uint32_t code_size = &__etext - &__executable_start;
uint32_t required_coverage_size = (code_size >> pc_shift) + 1;
if (coverage_size < required_coverage_size) {
fprintf(stderr, "Warning: Not enough space for coverage data (%d < %d)\n", coverage_size,
required_coverage_size);
}
memset(coverage_data, 0, sizeof(coverage_data));
}
void coverage_start_round()
{
found_new = false;
}
bool coverage_found_new()
{
return found_new;
}
extern "C" void __sanitizer_cov_trace_pc(void)
{
auto ip = (uint32_t)__builtin_return_address(0);
// This function is optimized since it is called for every basic block (compiling to 6 x86 instructions on the hot
// path currently). Just set a byte in the coverage array "somewhere", anywhere is fine as long as there is no
// chance of overlap. This way we do not need to eg. subtract __executable_start or do bounds checks.
uint32_t byte_pos = (ip >> pc_shift) & coverage_mask;
if (!coverage_data[byte_pos]) {
coverage_data[byte_pos] = 1;
found_new = true;
}
}

5
Stub/sanitize_coverage.h

@ -1,5 +0,0 @@
#pragma once
void coverage_init();
void coverage_start_round();
bool coverage_found_new();

4
Stub/sdlrender.cpp

@ -1174,8 +1174,8 @@ void SDL_RenderDiabloMainPage()
PrintText16Silver(17, 444, gszProductName);
ADD_PlrStringXY(0, 600 - 150, 640, "DedicaTed To David Brevik, Erich Schaefer, Max Schaefer,", COL_BLUE);// Red isn't red
ADD_PlrStringXY(0, 600 - 130, 640, " MaTT Uelman, and The Blizzard North Team ThaT Gave Us A Childhood.", COL_BLUE);
//ADD_PlrStringXY(0, 600 - 150, 640, "DedicaTed To David Brevik, Erich Schaefer, Max Schaefer,", COL_BLUE);// Red isn't red
//ADD_PlrStringXY(0, 600 - 130, 640, " MaTT Uelman, and The Blizzard North Team ThaT Gave Us A Childhood.", COL_BLUE);
}
void SDL_RenderDiabloSinglePlayerPage()

Loading…
Cancel
Save