HearthSim/UnityHook

Need a bit help please

Closed this issue · 4 comments

Hey,

so, i tried to work with your Program, which is very pretty, but I have some issues.

I compiled the "Hooker" and the "HookerRegistry" and set the "Hooker" correctly with valid path's. At next I compiled your "Proto-Extractor" and tried to extract the functtions. I got two File-Path Errors. I thought I fixed them, but theres still an File-Path Error in the ProgramTest.cs File in Line 178.

I went on and looked with .Net-Reflector in the Assembly-CSharp.dll File's and found the functions I need, I think. But at least I'am a bit confused how to go on.

For testing this I want to write a Script that automaticly click the "Play"-Button in Hearthstone, and then hook this Script to execute it.

Am I missed something important about the functionality about your Hooker/Extractro? ^^

If not, someone wants to help me with the script? Or give me a hint in the right direction? Would be Nice :)

PS: I am using Windows 10 as OS, The newest Version of Hearthstone and Visual Studio Express 2017 for compiling.

  • Cheers!

Hi

Regarding ProgramTest.cs, that's a file in the Proto-Extractor which shouldn't be there. It's something i hacked together to test the library on my personal computer and shouldn't have been committed. Of course this file will be removed with a next commit. For problems regarding the Proto-Extractor project, please file your issues with that repository. https://github.com/HearthSim/proto-extractor/issues
The purpose of Proto-Extractor project is to extract structural message types that are used in communication between HS client and server. Because you wrote and tried to extract the functtions[sic] i'm not sure what you are trying to accomplish in your use case.

The purpose of UnityHook is to change the behavior of handpicked game methods, so emulating 'clicking' will not be possible (as far as i know).
In this use case hooking the click callback method of the game with your script and manually clicking the play button seems like a good approach. (This suggestion is based on the only information you provided thus far, since you haven't linked your script.)
I try to explain everything about UnityHook and Proto-Extractor inside their README file, but it's possible that something is missing/not clearly explained. If that's the case feel free to suggest improvements.

If you have more questions, feel free to ask!
Bert

Hey dude,

at first, thanks for the quick answers!

Of course, I missed some information about your stuff. Maybe its my english, but I thougt it hooks the Client functions, to control the callback functions like "MyHerTurn" and "Clicking". So in this I case I am a bit confused - what is actually possible with your API? Can you explain in short version what programs I scripts I can write with that usage?

Would be very nice if you answers again ^^

  • Greetings

Hi

As stated in the README

UnityHook is a simple platform for hooking managed function calls, targeting specifically assemblies compiled for Unity3d games.
Installed hooks allow overriding hooked functions' return values, essentially granting complete control over managed code execution in a targeted game.

So yes it can hook into the callback methods.

I suppose the part where i said so emulating 'clicking' will not be possible is confusing; Emulating a click is NOT exactly the same as executing the callback attached to the clicked object. In general there are timing and thread boundary issues when trying to emulate a click by code.. but with enough knowledge about Unity's internal working it's doable. Other people/developers in our community know a lot more about these things than i do, try reaching out to them through https://hearthsim.info/join/

Theoretically you could do almost anything with the UnityHook project. Examples can be found inside the HookRegistry project, Overriding game initialization parameters (SSLDisable hook) and copying packet data sent/received by the client (IncomingPackets and OutgoingPackets hook).
These examples change the behavior or introduce new functionality to the game.

Also worth noting; you could compile a HookRegistry library with it's own dependencies to not have to use reflection for dynamic method execution. In that case you need to manually copy all these dependencies next to the game libraries before performing the hook, since only the HookRegistry library will be copied to the game library folder.

Bert

edit: added the word library in last paragraph

Hey m8y,

yeah, nailed it. Now I am not confused anymore ^^ Thank you for your time to describe the Hook!

Okay, so I am trying it out, maybe I should learn more about The Work Wise of The Unity Enigine. I understood it right - With the Hooker I can overwrite the CallBack's of Hearthstone, manage the Packet Traffic and more, ya?

Maybe I will try to reach those guys you are talking about on your Website ^^ Thanks for that!

  • Cheers!