Giter VIP home page Giter VIP logo

cryogenic's Introduction

Linux OSX Windows

Cryo dune reverse engineering

Fiddling with Cryo dune (CD Version) for fun:

SHA256 signature of supported dncdprg.exe: 5f30aeb84d67cf2e053a83c09c2890f010f2e25ee877ebec58ea15c5b30cfff9

The CD release of DUNE (version 3.7, the most widely available one), must be downloaded separately, as it is copyrighted material.

This projects requires the .NET 8 SDK.

Download

See the releases section.

The CD release of DUNE (version 3.7, the most widely available one), must be downloaded separately, as it is copyrighted material.

Status

Thanks to the hybrid ASM / .NET mode provided by Spice86, the game is fully playable, including sound and music.

The goal is to have more and more logic written in human readable C#.

Build & Run

Running it

To run it, just run the project with dune CD exe in parameter:

git clone https://github.com/OpenRakis/Crygenic
cd Cryogenic/src
dotnet run --Exe C:/path/to/dunecd/DNCDPRG.EXE --UseCodeOverride true

Running it with music and sound effetcs enabled:

Example with Adlib music:

cd Cryogenic/src
dotnet run --Exe C:/path/to/dunecd/DNCDPRG.EXE --UseCodeOverride true -a "ADL220 SBP2227"

Building it

  • Clone this repo, and build it:
git clone https://github.com/OpenRakis/Crygenic
cd Cryogenic/src
dotnet build

cryogenic's People

Contributors

dependabot[bot] avatar kevinferrare avatar maximilien-noal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

nubox007

cryogenic's Issues

Latest "Fake ASM" generated code access the emulated stack when it is empty -> Exception

21:41:35 ERR { SourceContext: "Spice86.UI.ViewModels.MainWindowViewModel" }] An error occurred during execution
System.InvalidOperationException: Stack empty.
at System.Collections.Generic.Stack1.ThrowForEmptyStack() at System.Collections.Generic.Stack1.Pop()
at Spice86.Emulator.ReverseEngineer.JumpDispatcher.Jump(Func2 target, Int32 entryAddress) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/JumpDispatcher.cs:line 26 at Cryogenic.Overrides.Overrides.spice86_generated_label_ret_target_1000_E67B_01E67B(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode17.cs:line 3739 at Spice86.Emulator.ReverseEngineer.JumpDispatcher.Jump(Func2 target, Int32 entryAddress) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/JumpDispatcher.cs:line 22
at Cryogenic.Overrides.Overrides.spice86_generated_label_call_target_1000_E675_01E675(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode17.cs:line 3692
at Spice86.Emulator.ReverseEngineer.JumpDispatcher.Jump(Func2 target, Int32 entryAddress) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/JumpDispatcher.cs:line 22 at Cryogenic.Overrides.Overrides.spice86_generated_label_ret_target_1000_E67B_01E67B(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode17.cs:line 3739 at Spice86.Emulator.ReverseEngineer.JumpDispatcher.Jump(Func2 target, Int32 entryAddress) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/JumpDispatcher.cs:line 22
at Cryogenic.Overrides.Overrides.spice86_generated_label_call_target_1000_E675_01E675(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode17.cs:line 3692
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.<>c__DisplayClass140_0.b__0() in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 201
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.ExecuteEnsuringSameStack(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Action action) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 250
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.NearCall(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Func2 function) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 199 at Cryogenic.Overrides.Overrides.spice86_generated_label_ret_target_1000_E5B4_01E5B4(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode17.cs:line 3484 at Spice86.Emulator.ReverseEngineer.JumpDispatcher.Jump(Func2 target, Int32 entryAddress) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/JumpDispatcher.cs:line 22
at Cryogenic.Overrides.Overrides.spice86_generated_label_call_target_1000_E594_01E594(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode17.cs:line 3436
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.<>c__DisplayClass140_0.b__0() in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 201
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.ExecuteEnsuringSameStack(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Action action) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 250
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.NearCall(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Func2 function) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 199 at Cryogenic.Overrides.Overrides.entry_1000_0000_10000(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode.cs:line 2406 at Spice86.Emulator.Function.FunctionInformation.CallOverride() in /home/max/repos/Spice86/src/Spice86/Emulator/Function/FunctionInformation.cs:line 43 at Spice86.Emulator.Function.FunctionHandler.Call(CallType callType, UInt16 entrySegment, UInt16 entryOffset, Nullable1 expectedReturnSegment, Nullable`1 expectedReturnOffset, String name, Boolean recordReturn) in /home/max/repos/Spice86/src/Spice86/Emulator/Function/FunctionHandler.cs:line 52
at Spice86.Emulator.VM.Machine.Run() in /home/max/repos/Spice86/src/Spice86/Emulator/VM/Machine.cs:line 213
at Spice86.Emulator.ProgramExecutor.Run() in /home/max/repos/Spice86/src/Spice86/Emulator/ProgramExecutor.cs:line 51
at Spice86.UI.ViewModels.MainWindowViewModel.RunMachine() in /home/max/repos/Spice86/src/Spice86/UI/ViewModels/MainWindowViewModel.cs:line 292

The code crashes the emulator

After a Grp5 instruction.
The DOSInt21Handler is asked for a service at index 0
It doesn't exist -> exception -> crash.

Doesn't happen in the Java original, with or without running overrides from CryoDuneRE.

MT-32 : Generate the code using the generator

Normally there should not be too much variation in the driver, so a quick game where you change the volume can be enough
To generate it because of the ghidra bug on the segments it is necessary that the segment of the driver is a multiple of 4096
like in what I posted in the main chat, the exe I have it at segment 0x1000, and the code is good
the driver was at segment 0x563E -> ghidra might be a bit crazy

We can change the base segment of the game, it changes the drivers?

I would have to set it to segment 0x6000, so add 0x9C2 to the load address of the exe (command line parameter)
Yes
Everything is provided ๐Ÿ™‚
--ProgramEntryPointSegment=4096 => base segment 0x1000
--ProgramEntryPointSegment=6594 => audio driver will be at 0x6000
the rest will be a mess but you don't care
you get the code generated only for these functions

Ghidra Generated Code produces an Exception

[21:00:36 ERR { SourceContext: "Spice86.UI.ViewModels.MainWindowViewModel" }] An error occurred during execution
Spice86.Emulator.Errors.UnrecoverableException: Untested code reached, please tell us how to reach this state.Here is the message: Error: Function not registered at address 235C8 Here is the call stack: - entry_1000_0000_10000 expected to return to address
at Cryogenic.Overrides.Overrides.spice86_generated_label_call_target_1000_C0AD_01C0AD(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode7.cs:line 2550
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.<>c__DisplayClass136_0.b__0() in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 197
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.ExecuteEnsuringSameStack(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Action action) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 246
at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.NearCall(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Func2 function) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 195 at Cryogenic.Overrides.Overrides.spice86_generated_label_call_target_1000_E594_01E594(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode9.cs:line 4514 at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.<>c__DisplayClass136_0.<NearCall>b__0() in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 197 at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.ExecuteEnsuringSameStack(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Action action) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 246 at Spice86.Emulator.ReverseEngineer.CSharpOverrideHelper.NearCall(UInt16 expectedReturnCs, UInt16 expectedReturnIp, Func2 function) in /home/max/repos/Spice86/src/Spice86/Emulator/ReverseEngineer/CSharpOverrideHelper.cs:line 195
at Cryogenic.Overrides.Overrides.entry_1000_0000_10000(Int32 loadOffset) in /home/max/repos/Cryogenic/src/Cryogenic/Overrides/Generated/GeneratedCode.cs:line 1143
at Spice86.Emulator.Function.FunctionInformation.CallOverride() in /home/max/repos/Spice86/src/Spice86/Emulator/Function/FunctionInformation.cs:line 43
at Spice86.Emulator.Function.FunctionHandler.Call(CallType callType, UInt16 entrySegment, UInt16 entryOffset, Nullable1 expectedReturnSegment, Nullable1 expectedReturnOffset, String name, Boolean recordReturn) in /home/max/repos/Spice86/src/Spice86/Emulator/Function/FunctionHandler.cs:line 52
at Spice86.Emulator.VM.Machine.Run() in /home/max/repos/Spice86/src/Spice86/Emulator/VM/Machine.cs:line 213
at Spice86.Emulator.ProgramExecutor.Run() in /home/max/repos/Spice86/src/Spice86/Emulator/ProgramExecutor.cs:line 51
at Spice86.UI.ViewModels.MainWindowViewModel.RunMachine() in /home/max/repos/Spice86/src/Spice86/UI/ViewModels/MainWindowViewModel.cs:line 291

Somewhere, the Java code that generated the fake ASM has a bug.

First step :
Compare Spice86 + gdb and Cryogenic + gdb

A good GDB client for Linux :
https://github.com/hugsy/gef

Or browser based:
https://github.com/cs01/gdbgui/

Or inside VSCode:
https://marketplace.visualstudio.com/items?itemName=webfreak.debug

Try to connect Ghidra to Spice86:
https://wrongbaud.github.io/posts/ghidra-debugger/#debugging-the-rom

Also maybe use the -d option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.