Giter Club home page Giter Club logo

odin_whitebox's Introduction

odin_whitebox

example on how to make odin work with whitebox.

Please Note: This process is currently very cumbersome to set up and use and does not take advantage of WhiteBox's actual capability (by a long shot). This is presented as one working example in case you want to inspect the inputs/outputs of some of your Odin procs.

Overview:

Odin Language Home Page
Whitebox

Instructions:

  1. Follow instructions to get/compile Odin and install WhiteBox
    • The Odin and WhiteBox Discord servers are very helpful
    • Specifically, thanks @4984 and @azmr, since you guys did most of the work helping me out!
  2. Install the WhiteBox plugin in your editor of choice
    • I use VS Code
  3. Compile add.odin to .dll by running build.bat
  4. Open whitebox_hack.c in your editor
  5. Start the WhiteBox executable
    • NOTE: WhiteBox MUST be running before trying to connect.
  6. Start the WhiteBox plugin
    • In VS Code, press CTRL + SHIFT + P and select WhiteBox: Connect
  7. In WhiteBox, create a new profile to point to the odin_add.dll
    • Preferences
    • clone
    • Set a name
      • I named mine dll
    • Click the DLL files tab
    • Scroll down and click Add group button
    • In the text box, enter the path to your odin_add.dll
    • click OK to save
      image
  8. Click on a line of source code and Watch The Magic!
    image

How does this work?

Currently, WhiteBox is unable to work with Odin source code. However, after a fun screen-sharing session with Andrew (@azmr, creator of WhiteBox) and @4984, we managed to get WhiteBox to communicate with an Odin .dll.

Refer to the Odin Binding to C docs and the discussion on Implicit context system.

Basically, we create a global context and set it in the main to the actual context. Then inside the proc we want to view in WhiteBox, we can get the global context and ensure the correct symbols are created in the .dll.

package main
import "core:fmt"
import "core:runtime"

g_context : runtime.Context 

main :: proc() {
    g_context = context
    x:=add(1.0,1.0)
    fmt.println("Hello Whitebox!")
    fmt.println(x)
}

@(export) 
@(link_name="odin_add")
add :: proc"system"(a,b :f32) -> f32 {
    context=g_context
    sum : f32 = a + b
    fmt.println("Adding:", a, "plus", b, "=", sum)
    return sum
}

Due to this dependency on main, everything in the main proc is run in WhiteBox. image

A final caveat is that when you recompile your Odin .dll, you will need to completely close out WhiteBox since WhiteBox currently locks the .dll, preventing recompilation. This should be addressed in a future update.

Again, this is more of a "Here's Proof That You Can Run Odin With WhiteBox".

odin_whitebox's People

Contributors

jmbjr avatar

Stargazers

Noah Betzen avatar SelasieHanson avatar Andrew Reece avatar

Watchers

 avatar

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.