Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing Argument to DLL in inject time #2

Closed
YouKnow-sys opened this issue Jan 15, 2021 · 5 comments
Closed

Passing Argument to DLL in inject time #2

YouKnow-sys opened this issue Jan 15, 2021 · 5 comments

Comments

@YouKnow-sys
Copy link

Hi I wonder its possible to be able to pass argument to dll in inject time?
I Don't know if dll accept argument or not by default, but I think it a good thing to have

@samuelgr
Copy link
Owner

Could you please provide an example to help me understand what you mean by passing arguments to DLLs at injection time?

@YouKnow-sys
Copy link
Author

Could you please provide an example to help me understand what you mean by passing arguments to DLLs at injection time?

I mean something like this tutorial I found
thank you

@samuelgr
Copy link
Owner

If I understand correctly, the idea is to:

  • Inject a DLL (by specifying it on an Inject = line in a Hookshot configuration file).
  • After the DLL is injected, call a function in the DLL and pass arguments to that function.

Is this right?

@YouKnow-sys
Copy link
Author

YouKnow-sys commented Jan 19, 2021

If I understand correctly, the idea is to:

  • Inject a DLL (by specifying it on an Inject = line in a Hookshot configuration file).
  • After the DLL is injected, call a function in the DLL and pass arguments to that function.

Is this right?

Yes, This is exactly what I have in mind


and also I think its good Idea to create some kind of library with HookShot to be able to use it inside of program
for now HookShot working very well, but its not good in term of easy use, because for that you need to include compiled binary to project... and its not ideal
you think its possible?

@samuelgr
Copy link
Owner

Yes, This is exactly what I have in mind

Based on this use case, I suggest creating a hook module rather than relying on Inject = to load your DLL. The Inject = functionality is intended as a quick and convenient way for a user to inject a DLL that does not need much in the way of interaction.

Suppose you are trying to inject FancyLibrary.dll into a program called App.exe. Rather than using Inject = FancyLibrary.dll to do it, you can write a hook module called (for example) FancyLibraryWrapper. In the hook module's entry point, you could:

  • Call the Windows API function LoadLibrary and pass FancyLibrary.dll as an argument.
  • Use GetProcAddress (or some other means) to locate the address of the function in FancyLibrary.dll that you want to call.
  • Invoke the function with whatever arguments you want.
  • Set up some IPC channels, spawn new threads, and do basically anything you want to make it possible to call functions in FancyLibrary.dll in App.exe from some other program, perhaps another program you wrote.

While hook modules are intended to set hooks using the Hookshot API, this is not strictly a requirement. The hook module entry point gives you an opportunity to run whatever code you want inside the space of App.exe.

for that you need to include compiled binary to project... and its not ideal

Could you please explain this issue a little bit more? What "compiled binary" are you referring to, and why is including it not ideal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants