Qwokka / Cetus

Browser extension for hacking WebAssembly games a la Cheat Engine
Apache License 2.0
529 stars 45 forks source link

Turning off watchpoints fails #71

Open Riddle1001 opened 1 year ago

Riddle1001 commented 1 year ago

In reference to #58

Coming back to this after a little while, I tried it and my patch works fine until I disable the watch points inside the chrome extension options. I also tried manually commenting watch point functions out the like I did before //wail.addInstructionParser(OP_I64_LOAD, readWatchpointInstrCallback); as a temp fix and still the same error occurs.

error: /#file-name:1 Uncaught (in promise) CompileError: WebAssembly.instantiate(): Compiling function #54979 failed: function index #110895 is out of bounds @+19973184


Only tested it with one patch, only happens when I add this patch AND disable the watch points Tested with firefox and chrome Tried all three options, only all extension option seemed to not break

Qwokka commented 1 year ago

Hey @Riddle1001 ,

I think I know what's going on, and it's something I didn't think about in the first place. Essentially, when watchpoints are enabled, it adds some new functions to the binary that don't need to be there otherwise. This throws off the "index" used by the patch, causing it to (probably) modify a different function.

The fix here is going to need to be treated indices in patches as corresponding to the un-instrumented binary, then doing the math to make sure everything lines up. I'll try and make this work in the near future.

Jack

Riddle1001 commented 1 year ago

Hey @Riddle1001 ,

I think I know what's going on, and it's something I didn't think about in the first place. Essentially, when watchpoints are enabled, it adds some new functions to the binary that don't need to be there otherwise. This throws off the "index" used by the patch, causing it to (probably) modify a different function.

The fix here is going to need to be treated indices in patches as corresponding to the un-instrumented binary, then doing the math to make sure everything lines up. I'll try and make this work in the near future.

Jack

Sounds good. I've just been using the older version with the commented out watchpoints meantime. Thanks for the quick reply