-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Feature: Add DetourFindRemotePayload and improve other payload-related methods #81
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
Conversation
|
@dtarditi could this and other PRs/issues be addressed? I'd like at some point to start using this in production (it's been working flawlessly in development) |
|
@sylveon, what is the motivation for wanting to add DetourFindRemotePayload? The other changes look straightforward. It isn't clear to me how this new function would help with the core goal of detours, which is allow ppeople to instrument and monitor and API calls. |
|
My use-case is described in #79. Basically, I use the payload as a flag to check if the DLL is actually loaded in the process I want to detour API calls (much like the current However, the way my app works, the user can close and reopen it at will, so the DLL and detour may be removed (as in, completely unloaded from the target process's address space) and added multiple times within the lifetime of the target process. Without this API, I cannot know if a payload already exists in the target process, so I always have to create a new payload, making its potential future purpose of transmitting information useless since there is not guarantee about which payload With this API, I can instead just find an existing payload (or create a new payload if there is none yet), not having to allocate a new one each time, and then edit the payload's content using WriteProcessMemory calls. This function can very well be written standalone, but since it taps into implementation details of Detours, which might change in the future, I think that having it as part of the core codebase would be better. |
|
Note that my commits became unverified due to me changing my GPG key, you can ignore that. |
|
@sylveon, this use case makes sense. Could you add a test case for the new API function? |
|
@dtarditi I fixed a bug related to memory allocation (used
|
|
It you don't mind, it would be nice if you could include the markdown for the WIKI documentation pages for these new API's in this PR (just in the PR description, or as comments) we can just paste them in once we merge. |
|
https://gist.github.com/sylveon/0a38efaa506ccebf5c91c7e4e32deaf5 I've uploaded my wiki updates here |
|
@dtarditi, do you think this needs more work? Or is it ready to merge? |
dtarditi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
|
@sylveon I would like to include this in the next release can you:
|
|
Yeah I was actually planning to take a look at the conflicts tonight. I'll see for the unit tests as well. |
|
Sorry can you submit the tab commit as a separate PR? Since the repository is configured to only allow squash commits, that's going to make this PR's commit diff pretty noisy and messy. ☹ |
This reverts commit f1dd31b.
|
Reverted that commit for now |
|
There seems to be some contamination between PR builds, the builds are complaining about tests for DetourFindPayloadEx already existing in test_modules_api.cpp at line 623, but the file isn't even that long in my branch. |
|
Looks like I've got conflicts to resolve anyways - will do tonight |
|
Thanks again for the contribution @sylveon! |
|
I merged all of the doc changes that you provided in your gist as well. |
Other improvements are:
pcbDataparameter in DetourFindPayload and DetourFindPayloadEx optional, so that if an application only needs to search for the presence of a payload, they can ignore the size by passingnullptr.pvDataparameter in DetourCopyPayloadToProcess const, so that a pointer to a const C++ object can be passed instead of the object needing to beconst_casted or being non-const.Fixes #79
From basic testing, it seems to work for me. I can apply corrections and add a sample if required (although finding a trivial use case for those APIs would be required)