diff --git a/.gitignore b/.gitignore index a650b4c..e793569 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,10 @@ +# The actual built game, optimistically +*.exe +*.xbe + # Can't distribute objects pulled from the JSRF executable *.obj + +# Other build artifacts +*.lib +*.exp diff --git a/decompile/Makefile b/decompile/Makefile index fd0adf5..8691d92 100644 --- a/decompile/Makefile +++ b/decompile/Makefile @@ -5,19 +5,32 @@ OBJ = src/JSRF/Jet2.obj src/JSRF/Core.obj src/JSRF/GameData.obj\ src/XDK/CRT/CRT0.obj +# Import library for the only thing we don't compile ourselves, the Xbox kernel +LIB = lib/xboxkrnl.lib + + +#all: src/JSRF/Jet2.xbe +all: $(OBJ) # For now, just compile all the object files + + +## Build commands +.SUFFIXES: .cpp .obj .def .lib .exe.xbe + +# Convert compiled executable into a working Xbox executable +# (TODO: we may want to fork cxbe to add section checksums and the game ID) +.exe.xbe: + cxbe.exe -OUT:$@ -TITLE:'Jet Set Radio Future' -MODE:retail $< # Linking into an executable; expect this to fail with undefined references # until we've made at least stubs for everything in the game -#all: src/JSRF/Jet2.exe -#src/JSRF/Jet2.exe: $(OBJ) -# LINK.EXE /NOLOGO /NODEFAULTLIB /MERGE:.CRT=.data /OUT:$@ $** +src/JSRF/Jet2.exe: $(OBJ) $(LIB) + LINK.EXE /NOLOGO /NODEFAULTLIB /MERGE:.CRT=.data /OUT:$@ $** -# For now, just compile all the object files -all: $(OBJ) +# Create import library for Xbox kernel +.def.lib: + LIB.EXE /NOLOGO /MACHINE:X86 /DEF:$< /OUT:$@ - -# Simple inference rule for producing object files -.SUFFIXES: .cpp .obj +# Compile object files from source .cpp.obj: CL.EXE /nologo /Wall /W4 /Ogityb0 /GfX /Fo$@ /c $< diff --git a/decompile/lib/xboxkrnl.def b/decompile/lib/xboxkrnl.def new file mode 100644 index 0000000..7c94bca --- /dev/null +++ b/decompile/lib/xboxkrnl.def @@ -0,0 +1,386 @@ +; JSRF Decompilation: xboxkrnl.exe.def +; The import library for the Xbox kernel, which allows dynamic linking against +; its provided functions, is produced from this file. +; +; This file was included in the nxdk project and graciously dedicated to the +; public domain under the CC0 licence. The remainder of this file is its +; original form in the nxdk repository in early 2026. + +; SPDX-License-Identifier: CC0-1.0 + +; SPDX-FileCopyrightText: 2017 Stefan Schmidt + +LIBRARY xboxkrnl.exe + +EXPORTS + AvGetSavedDataAddress@0 @ 1 NONAME + AvSendTVEncoderOption@16 @ 2 NONAME + AvSetDisplayMode@24 @ 3 NONAME + AvSetSavedDataAddress@4 @ 4 NONAME + DbgBreakPoint@0 @ 5 NONAME + DbgBreakPointWithStatus@4 @ 6 NONAME + DbgLoadImageSymbols@12 @ 7 NONAME + DbgPrint @ 8 NONAME + HalReadSMCTrayState@8 @ 9 NONAME + DbgPrompt@12 @ 10 NONAME + DbgUnLoadImageSymbols@12 @ 11 NONAME + ExAcquireReadWriteLockExclusive@4 @ 12 NONAME + ExAcquireReadWriteLockShared@4 @ 13 NONAME + ExAllocatePool@4 @ 14 NONAME + ExAllocatePoolWithTag@8 @ 15 NONAME + ExEventObjectType @ 16 NONAME DATA + ExFreePool@4 @ 17 NONAME + ExInitializeReadWriteLock@4 @ 18 NONAME + ExInterlockedAddLargeInteger@16 @ 19 NONAME + @ExInterlockedAddLargeStatistic@8 @ 20 NONAME + @ExInterlockedCompareExchange64@12 @ 21 NONAME + ExMutantObjectType @ 22 NONAME DATA + ExQueryPoolBlockSize@4 @ 23 NONAME + ExQueryNonVolatileSetting@20 @ 24 NONAME + ExReadWriteRefurbInfo@12 @ 25 NONAME + ExRaiseException@4 @ 26 NONAME + ExRaiseStatus@4 @ 27 NONAME + ExReleaseReadWriteLock@4 @ 28 NONAME + ExSaveNonVolatileSetting@16 @ 29 NONAME + ExSemaphoreObjectType @ 30 NONAME DATA + ExTimerObjectType @ 31 NONAME DATA + @ExfInterlockedInsertHeadList@8 @ 32 NONAME + @ExfInterlockedInsertTailList@8 @ 33 NONAME + @ExfInterlockedRemoveHeadList@4 @ 34 NONAME + FscGetCacheSize@0 @ 35 NONAME + FscInvalidateIdleBlocks@0 @ 36 NONAME + FscSetCacheSize@4 @ 37 NONAME + @HalClearSoftwareInterrupt@4 @ 38 NONAME + HalDisableSystemInterrupt@4 @ 39 NONAME + HalDiskCachePartitionCount @ 40 NONAME DATA + HalDiskModelNumber @ 41 NONAME DATA + HalDiskSerialNumber @ 42 NONAME DATA + HalEnableSystemInterrupt@8 @ 43 NONAME + HalGetInterruptVector@8 @ 44 NONAME + HalReadSMBusValue@16 @ 45 NONAME + HalReadWritePCISpace@24 @ 46 NONAME + HalRegisterShutdownNotification@8 @ 47 NONAME + @HalRequestSoftwareInterrupt@4 @ 48 NONAME + HalReturnToFirmware@4 @ 49 NONAME + HalWriteSMBusValue@16 @ 50 NONAME + @InterlockedCompareExchange@12 @ 51 NONAME + @InterlockedDecrement@4 @ 52 NONAME + @InterlockedIncrement@4 @ 53 NONAME + @InterlockedExchange@8 @ 54 NONAME + @InterlockedExchangeAdd@8 @ 55 NONAME + @InterlockedFlushSList@4 @ 56 NONAME + @InterlockedPopEntrySList@4 @ 57 NONAME + @InterlockedPushEntrySList@8 @ 58 NONAME + IoAllocateIrp@4 @ 59 NONAME + IoBuildAsynchronousFsdRequest@24 @ 60 NONAME + IoBuildDeviceIoControlRequest@36 @ 61 NONAME + IoBuildSynchronousFsdRequest@28 @ 62 NONAME + IoCheckShareAccess@20 @ 63 NONAME + IoCompletionObjectType @ 64 NONAME DATA + IoCreateDevice@24 @ 65 NONAME + IoCreateFile@40 @ 66 NONAME + IoCreateSymbolicLink@8 @ 67 NONAME + IoDeleteDevice@4 @ 68 NONAME + IoDeleteSymbolicLink@4 @ 69 NONAME + IoDeviceObjectType @ 70 NONAME DATA + IoFileObjectType @ 71 NONAME DATA + IoFreeIrp@4 @ 72 NONAME + IoInitializeIrp@12 @ 73 NONAME + IoInvalidDeviceRequest@8 @ 74 NONAME + IoQueryFileInformation@20 @ 75 NONAME + IoQueryVolumeInformation@20 @ 76 NONAME + IoQueueThreadIrp@4 @ 77 NONAME + IoRemoveShareAccess@8 @ 78 NONAME + IoSetIoCompletion@20 @ 79 NONAME + IoSetShareAccess@16 @ 80 NONAME + IoStartNextPacket@4 @ 81 NONAME + IoStartNextPacketByKey@8 @ 82 NONAME + IoStartPacket@12 @ 83 NONAME + IoSynchronousDeviceIoControlRequest@32 @ 84 NONAME + IoSynchronousFsdRequest@20 @ 85 NONAME + @IofCallDriver@8 @ 86 NONAME + @IofCompleteRequest@8 @ 87 NONAME + KdDebuggerEnabled @ 88 NONAME DATA + KdDebuggerNotPresent @ 89 NONAME DATA + IoDismountVolume@4 @ 90 NONAME + IoDismountVolumeByName@4 @ 91 NONAME + KeAlertResumeThread@4 @ 92 NONAME + KeAlertThread@8 @ 93 NONAME + KeBoostPriorityThread@8 @ 94 NONAME + KeBugCheck@4 @ 95 NONAME + KeBugCheckEx@20 @ 96 NONAME + KeCancelTimer@4 @ 97 NONAME + KeConnectInterrupt@4 @ 98 NONAME + KeDelayExecutionThread@12 @ 99 NONAME + KeDisconnectInterrupt@4 @ 100 NONAME + KeEnterCriticalRegion@0 @ 101 NONAME + MmGlobalData @ 102 NONAME DATA + KeGetCurrentIrql@0 @ 103 NONAME + KeGetCurrentThread@0 @ 104 NONAME + KeInitializeApc@28 @ 105 NONAME + KeInitializeDeviceQueue@4 @ 106 NONAME + KeInitializeDpc@12 @ 107 NONAME + KeInitializeEvent@12 @ 108 NONAME + KeInitializeInterrupt@28 @ 109 NONAME + KeInitializeMutant@8 @ 110 NONAME + KeInitializeQueue@8 @ 111 NONAME + KeInitializeSemaphore@12 @ 112 NONAME + KeInitializeTimerEx@8 @ 113 NONAME + KeInsertByKeyDeviceQueue@12 @ 114 NONAME + KeInsertDeviceQueue@8 @ 115 NONAME + KeInsertHeadQueue@8 @ 116 NONAME + KeInsertQueue@8 @ 117 NONAME + KeInsertQueueApc@16 @ 118 NONAME + KeInsertQueueDpc@12 @ 119 NONAME + KeInterruptTime @ 120 NONAME DATA + KeIsExecutingDpc@0 @ 121 NONAME + KeLeaveCriticalRegion@0 @ 122 NONAME + KePulseEvent@12 @ 123 NONAME + KeQueryBasePriorityThread@4 @ 124 NONAME + KeQueryInterruptTime@0 @ 125 NONAME + KeQueryPerformanceCounter@0 @ 126 NONAME + KeQueryPerformanceFrequency@0 @ 127 NONAME + KeQuerySystemTime@4 @ 128 NONAME + KeRaiseIrqlToDpcLevel@0 @ 129 NONAME + KeRaiseIrqlToSynchLevel@0 @ 130 NONAME + KeReleaseMutant@16 @ 131 NONAME + KeReleaseSemaphore@16 @ 132 NONAME + KeRemoveByKeyDeviceQueue@8 @ 133 NONAME + KeRemoveDeviceQueue@4 @ 134 NONAME + KeRemoveEntryDeviceQueue@8 @ 135 NONAME + KeRemoveQueue@12 @ 136 NONAME + KeRemoveQueueDpc@4 @ 137 NONAME + KeResetEvent@4 @ 138 NONAME + KeRestoreFloatingPointState@4 @ 139 NONAME + KeResumeThread@4 @ 140 NONAME + KeRundownQueue@4 @ 141 NONAME + KeSaveFloatingPointState@4 @ 142 NONAME + KeSetBasePriorityThread@8 @ 143 NONAME + KeSetDisableBoostThread@8 @ 144 NONAME + KeSetEvent@12 @ 145 NONAME + KeSetEventBoostPriority@8 @ 146 NONAME + KeSetPriorityProcess@8 @ 147 NONAME + KeSetPriorityThread@8 @ 148 NONAME + KeSetTimer@16 @ 149 NONAME + KeSetTimerEx@20 @ 150 NONAME + KeStallExecutionProcessor@4 @ 151 NONAME + KeSuspendThread@4 @ 152 NONAME + KeSynchronizeExecution@12 @ 153 NONAME + KeSystemTime @ 154 NONAME DATA + KeTestAlertThread@4 @ 155 NONAME + KeTickCount @ 156 NONAME DATA + KeTimeIncrement @ 157 NONAME DATA + KeWaitForMultipleObjects@32 @ 158 NONAME + KeWaitForSingleObject@20 @ 159 NONAME + @KfRaiseIrql@4 @ 160 NONAME + @KfLowerIrql@4 @ 161 NONAME + KiBugCheckData @ 162 NONAME DATA + @KiUnlockDispatcherDatabase@4 @ 163 NONAME + LaunchDataPage @ 164 NONAME DATA + MmAllocateContiguousMemory@4 @ 165 NONAME + MmAllocateContiguousMemoryEx@20 @ 166 NONAME + MmAllocateSystemMemory@8 @ 167 NONAME + MmClaimGpuInstanceMemory@8 @ 168 NONAME + MmCreateKernelStack@8 @ 169 NONAME + MmDeleteKernelStack@8 @ 170 NONAME + MmFreeContiguousMemory@4 @ 171 NONAME + MmFreeSystemMemory@8 @ 172 NONAME + MmGetPhysicalAddress@4 @ 173 NONAME + MmIsAddressValid@4 @ 174 NONAME + MmLockUnlockBufferPages@12 @ 175 NONAME + MmLockUnlockPhysicalPage@8 @ 176 NONAME + MmMapIoSpace@12 @ 177 NONAME + MmPersistContiguousMemory@12 @ 178 NONAME + MmQueryAddressProtect@4 @ 179 NONAME + MmQueryAllocationSize@4 @ 180 NONAME + MmQueryStatistics@4 @ 181 NONAME + MmSetAddressProtect@12 @ 182 NONAME + MmUnmapIoSpace@8 @ 183 NONAME + NtAllocateVirtualMemory@20 @ 184 NONAME + NtCancelTimer@8 @ 185 NONAME + NtClearEvent@4 @ 186 NONAME + NtClose@4 @ 187 NONAME + NtCreateDirectoryObject@8 @ 188 NONAME + NtCreateEvent@16 @ 189 NONAME + NtCreateFile@36 @ 190 NONAME + NtCreateIoCompletion@16 @ 191 NONAME + NtCreateMutant@12 @ 192 NONAME + NtCreateSemaphore@16 @ 193 NONAME + NtCreateTimer@12 @ 194 NONAME + NtDeleteFile@4 @ 195 NONAME + NtDeviceIoControlFile@40 @ 196 NONAME + NtDuplicateObject@12 @ 197 NONAME + NtFlushBuffersFile@8 @ 198 NONAME + NtFreeVirtualMemory@12 @ 199 NONAME + NtFsControlFile@40 @ 200 NONAME + NtOpenDirectoryObject@8 @ 201 NONAME + NtOpenFile@24 @ 202 NONAME + NtOpenSymbolicLinkObject@8 @ 203 NONAME + NtProtectVirtualMemory@16 @ 204 NONAME + NtPulseEvent@8 @ 205 NONAME + NtQueueApcThread@20 @ 206 NONAME + NtQueryDirectoryFile@40 @ 207 NONAME + NtQueryDirectoryObject@24 @ 208 NONAME + NtQueryEvent@8 @ 209 NONAME + NtQueryFullAttributesFile@8 @ 210 NONAME + NtQueryInformationFile@20 @ 211 NONAME + NtQueryIoCompletion@8 @ 212 NONAME + NtQueryMutant@8 @ 213 NONAME + NtQuerySemaphore@8 @ 214 NONAME + NtQuerySymbolicLinkObject@12 @ 215 NONAME + NtQueryTimer@8 @ 216 NONAME + NtQueryVirtualMemory@8 @ 217 NONAME + NtQueryVolumeInformationFile@20 @ 218 NONAME + NtReadFile@32 @ 219 NONAME + NtReadFileScatter@32 @ 220 NONAME + NtReleaseMutant@8 @ 221 NONAME + NtReleaseSemaphore@12 @ 222 NONAME + NtRemoveIoCompletion@20 @ 223 NONAME + NtResumeThread@8 @ 224 NONAME + NtSetEvent@8 @ 225 NONAME + NtSetInformationFile@20 @ 226 NONAME + NtSetIoCompletion@20 @ 227 NONAME + NtSetSystemTime@8 @ 228 NONAME + NtSetTimerEx@32 @ 229 NONAME + NtSignalAndWaitForSingleObjectEx@20 @ 230 NONAME + NtSuspendThread@8 @ 231 NONAME + NtUserIoApcDispatcher@12 @ 232 NONAME + NtWaitForSingleObject@12 @ 233 NONAME + NtWaitForSingleObjectEx@16 @ 234 NONAME + NtWaitForMultipleObjectsEx@24 @ 235 NONAME + NtWriteFile@32 @ 236 NONAME + NtWriteFileGather@32 @ 237 NONAME + NtYieldExecution@0 @ 238 NONAME + ObCreateObject@16 @ 239 NONAME + ObDirectoryObjectType @ 240 NONAME DATA + ObInsertObject@16 @ 241 NONAME + ObMakeTemporaryObject@4 @ 242 NONAME + ObOpenObjectByName@16 @ 243 NONAME + ObOpenObjectByPointer@12 @ 244 NONAME + ObpObjectHandleTable @ 245 NONAME DATA + ObReferenceObjectByHandle@12 @ 246 NONAME + ObReferenceObjectByName@20 @ 247 NONAME + ObReferenceObjectByPointer@8 @ 248 NONAME + ObSymbolicLinkObjectType @ 249 NONAME DATA + @ObfDereferenceObject@4 @ 250 NONAME + @ObfReferenceObject@4 @ 251 NONAME + PhyGetLinkState@4 @ 252 NONAME + PhyInitialize@8 @ 253 NONAME + PsCreateSystemThread@20 @ 254 NONAME + PsCreateSystemThreadEx@40 @ 255 NONAME + PsQueryStatistics@4 @ 256 NONAME + PsSetCreateThreadNotifyRoutine@4 @ 257 NONAME + PsTerminateSystemThread@4 @ 258 NONAME + PsThreadObjectType @ 259 NONAME DATA + RtlAnsiStringToUnicodeString@12 @ 260 NONAME + RtlAppendStringToString@8 @ 261 NONAME + RtlAppendUnicodeStringToString@8 @ 262 NONAME + RtlAppendUnicodeToString@8 @ 263 NONAME + RtlAssert@16 @ 264 NONAME + RtlCaptureContext@4 @ 265 NONAME + RtlCaptureStackBackTrace@16 @ 266 NONAME + RtlCharToInteger@12 @ 267 NONAME + RtlCompareMemory@12 @ 268 NONAME + RtlCompareMemoryUlong@12 @ 269 NONAME + RtlCompareString@12 @ 270 NONAME + RtlCompareUnicodeString@12 @ 271 NONAME + RtlCopyString@8 @ 272 NONAME + RtlCopyUnicodeString@8 @ 273 NONAME + RtlCreateUnicodeString@8 @ 274 NONAME + RtlDowncaseUnicodeChar@4 @ 275 NONAME + RtlDowncaseUnicodeString@12 @ 276 NONAME + RtlEnterCriticalSection@4 @ 277 NONAME + RtlEnterCriticalSectionAndRegion@4 @ 278 NONAME + RtlEqualString@12 @ 279 NONAME + RtlEqualUnicodeString@12 @ 280 NONAME + RtlExtendedIntegerMultiply@12 @ 281 NONAME + RtlExtendedLargeIntegerDivide@16 @ 282 NONAME + RtlExtendedMagicDivide@20 @ 283 NONAME + RtlFillMemory@12 @ 284 NONAME + RtlFillMemoryUlong@12 @ 285 NONAME + RtlFreeAnsiString@4 @ 286 NONAME + RtlFreeUnicodeString@4 @ 287 NONAME + RtlGetCallersAddress@8 @ 288 NONAME + RtlInitAnsiString@8 @ 289 NONAME + RtlInitUnicodeString@8 @ 290 NONAME + RtlInitializeCriticalSection@4 @ 291 NONAME + RtlIntegerToChar@16 @ 292 NONAME + RtlIntegerToUnicodeString@12 @ 293 NONAME + RtlLeaveCriticalSection@4 @ 294 NONAME + RtlLeaveCriticalSectionAndRegion@4 @ 295 NONAME + RtlLowerChar@4 @ 296 NONAME + RtlMapGenericMask@8 @ 297 NONAME + RtlMoveMemory@12 @ 298 NONAME + RtlMultiByteToUnicodeN@20 @ 299 NONAME + RtlMultiByteToUnicodeSize@12 @ 300 NONAME + RtlNtStatusToDosError@4 @ 301 NONAME + RtlRaiseException@4 @ 302 NONAME + RtlRaiseStatus@4 @ 303 NONAME + RtlTimeFieldsToTime@8 @ 304 NONAME + RtlTimeToTimeFields@8 @ 305 NONAME + RtlTryEnterCriticalSection@4 @ 306 NONAME + @RtlUlongByteSwap@4 @ 307 NONAME + RtlUnicodeStringToAnsiString@12 @ 308 NONAME + RtlUnicodeStringToInteger@12 @ 309 NONAME + RtlUnicodeToMultiByteN@20 @ 310 NONAME + RtlUnicodeToMultiByteSize@12 @ 311 NONAME + RtlUnwind@16 @ 312 NONAME + RtlUpcaseUnicodeChar@4 @ 313 NONAME + RtlUpcaseUnicodeString@12 @ 314 NONAME + RtlUpcaseUnicodeToMultiByteN@20 @ 315 NONAME + RtlUpperChar@4 @ 316 NONAME + RtlUpperString@8 @ 317 NONAME + @RtlUshortByteSwap@4 @ 318 NONAME + RtlWalkFrameChain@12 @ 319 NONAME + RtlZeroMemory@8 @ 320 NONAME + XboxEEPROMKey @ 321 NONAME DATA + XboxHardwareInfo @ 322 NONAME DATA + XboxHDKey @ 323 NONAME DATA + XboxKrnlVersion @ 324 NONAME DATA + XboxSignatureKey @ 325 NONAME DATA + XeImageFileName @ 326 NONAME DATA + XeLoadSection@4 @ 327 NONAME + XeUnloadSection@4 @ 328 NONAME + READ_PORT_BUFFER_UCHAR@12 @ 329 NONAME + READ_PORT_BUFFER_USHORT@12 @ 330 NONAME + READ_PORT_BUFFER_ULONG@12 @ 331 NONAME + WRITE_PORT_BUFFER_UCHAR@12 @ 332 NONAME + WRITE_PORT_BUFFER_USHORT@12 @ 333 NONAME + WRITE_PORT_BUFFER_ULONG@12 @ 334 NONAME + XcSHAInit@4 @ 335 NONAME + XcSHAUpdate@12 @ 336 NONAME + XcSHAFinal@8 @ 337 NONAME + XcRC4Key@12 @ 338 NONAME + XcRC4Crypt@12 @ 339 NONAME + XcHMAC@28 @ 340 NONAME + XcPKEncPublic@12 @ 341 NONAME + XcPKDecPrivate@12 @ 342 NONAME + XcPKGetKeyLen@4 @ 343 NONAME + XcVerifyPKCS1Signature@12 @ 344 NONAME + XcModExp@20 @ 345 NONAME + XcDESKeyParity@8 @ 346 NONAME + XcKeyTable@12 @ 347 NONAME + XcBlockCrypt@20 @ 348 NONAME + XcBlockCryptCBC@28 @ 349 NONAME + XcCryptService@8 @ 350 NONAME + XcUpdateCrypto@8 @ 351 NONAME + RtlRip@12 @ 352 NONAME + XboxLANKey @ 353 NONAME DATA + XboxAlternateSignatureKeys @ 354 NONAME DATA + XePublicKeyData @ 355 NONAME DATA + HalBootSMCVideoMode @ 356 NONAME DATA + IdexChannelObject @ 357 NONAME DATA + HalIsResetOrShutdownPending@0 @ 358 NONAME + IoMarkIrpMustComplete@4 @ 359 NONAME + HalInitiateShutdown@0 @ 360 NONAME + RtlSnprintf @ 361 NONAME + RtlSprintf @ 362 NONAME + RtlVsnprintf @ 363 NONAME + RtlVsprintf @ 364 NONAME + HalEnableSecureTrayEject@0 @ 365 NONAME + HalWriteSMCScratchRegister@4 @ 366 NONAME + MmDbgAllocateMemory@8 @ 374 NONAME + MmDbgFreeMemory@8 @ 375 NONAME + MmDbgQueryAvailablePages@0 @ 376 NONAME + MmDbgReleaseAddress@8 @ 377 NONAME + MmDbgWriteCheck@8 @ 378 NONAME diff --git a/decompile/src/JSRF/Jet2.cpp b/decompile/src/JSRF/Jet2.cpp index 86f6f30..470c144 100644 --- a/decompile/src/JSRF/Jet2.cpp +++ b/decompile/src/JSRF/Jet2.cpp @@ -14,8 +14,8 @@ Game * g_game; // Address: 0x0006F9E0 // Matching: yes void main(void) { - g_game = new Game(NULL, 0); - g_game->initRootExecObj(); - g_game->mainLoop(); - delete g_game; + g_game = new Game(NULL, 0); + g_game->initRootExecObj(); + g_game->mainLoop(); + delete g_game; } diff --git a/decompile/src/XDK/CRT/CRT0.cpp b/decompile/src/XDK/CRT/CRT0.cpp index 349b67f..c305130 100644 --- a/decompile/src/XDK/CRT/CRT0.cpp +++ b/decompile/src/XDK/CRT/CRT0.cpp @@ -4,7 +4,7 @@ Like other CRT code, there's some magic here with symbols that get special treatment from the compiler and linker. */ -#include "Win32.hpp" +#include "../Win32.hpp" // Every program is supposed to have a main(), so we can just assume its @@ -29,4 +29,5 @@ The linker automatically sets this function to the entrypoint. DWORD _mainXapiStartup(LPVOID const lpThreadParameter) { /* Runs some initialization and then calls main() */ main(); + return 0; } diff --git a/ghidra/ghidra_scripts/EnhancedExport.java b/ghidra/ghidra_scripts/EnhancedExport.java new file mode 100644 index 0000000..de693af --- /dev/null +++ b/ghidra/ghidra_scripts/EnhancedExport.java @@ -0,0 +1,65 @@ +// TODO +// +// @category Export + +import ghidra.app.script.GhidraScript; +import ghidra.program.flatapi.FlatProgramAPI; +import ghidra.program.model.listing.Data; +import ghidra.program.model.listing.Function; +import ghidra.program.model.symbol.SourceType; +import ghidra.program.model.symbol.Symbol; +import ghidra.program.model.symbol.SymbolIterator; + +import java.io.FileWriter; +import java.util.Arrays; + + +public class EnhancedExport extends GhidraScript{ + @Override + public void run() throws Exception { + final FileWriter out = new FileWriter(askFile("Specify output file", "OK")); + + final SymbolIterator iter = currentProgram.getSymbolTable() + .getPrimarySymbolIterator(true); + while (iter.hasNext() && !monitor.isCancelled()) { + final Symbol s = iter.next(); + if (s.getSource() != SourceType.USER_DEFINED) continue; + + final Object obj = s.getObject(); + if (obj != null) switch (obj) { + case Data d: + out.write( + "0x" + s.getAddress().toString() + "\t" + + "d" + "\t" + + d.getDataType().getDisplayName() + "\t" + + s.getName(true) + "\n" + ); + break; + + case Function f: + out.write( + "0x" + s.getAddress().toString() + "\t" + + "f" + "\t" + + f.getSignature(true).getReturnType() + .getDisplayName() + "\t" + + f.getCallingConventionName() + "\t" + + f.getName(true) + + String.join( + "\t", + Arrays.stream(f.getSignature(true).getArguments()) + .map(arg -> "\t" + + arg.getDataType().getDisplayName() + "\t" + + arg.getName() + ).toArray(String[]::new) + ) + + (f.hasVarArgs() ? "\t..." : "") + "\n" + ); + break; + + default: {} + } + } + + out.close(); + } +} diff --git a/readme.md b/readme.md index 91f5012..c865555 100644 --- a/readme.md +++ b/readme.md @@ -17,10 +17,9 @@ The approach of this decompilation is to: We are currently engaging in the first two steps simultaneously, decompiling code as it's delinked. Further details on these steps can be found in the -[contribution guide](documentation/gettingstarted.md). Step 3 will use the -linker from the same Visual C++ 7.0 already used to compile object files. Step -4 is expected to use the `cxbe` tool found in e.g. -[nxdk](https://github.com/XboxDev/nxdk). +[contribution guide](documentation/gettingstarted.md). Step 3 uses the linker +from the same Visual C++ 7.0 already used to compile object files. Step 4 uses +the `cxbe` tool found in e.g. [nxdk](https://github.com/XboxDev/nxdk). ## Contributing Anybody interested in joining the effort is welcome to read the