7 Commits

Author SHA1 Message Date
mooooonlight 9764cebcb1 Fix context setting errors in DetourEnumerateImports API (#266)
* fix context setting errors in DetourEnumerateImports API

* Fix SAL annotation on DetouerEnumerateImportThunk 

SAL annotation for VoidContext should just be In rather than In_opt (this is consistent with how the existing DetouerEnumerateImportThunk is structured).  

This was causing an error in the static analysis checks in the CI build.

* Update test_module_api.cpp

Comparison of BOOL vs. bool, this should fix it.

---------

Co-authored-by: g00356712 <guochenyang@huawei.com>
Co-authored-by: Jeff Bisset <43155345+BissetJ@users.noreply.github.com>
2025-06-20 18:29:16 -07:00
Ben Niu ea6c4ae7f3 Add Arm64EC support (#338)
This change adds Arm64EC detours support.

It bumps the toolset version to 143 from 142 since 142 does not support Arm64EC officially.
It adds a new Arm64EC target.
It passes Arm64EC-specific compilation flag /arm64EC and linker flag /machine:arm64x or /machine:arm64ec in right places.
2025-04-02 14:57:54 -07:00
JohnMcPMS 24357c6a5a Feature: Make section count configurable, fix RTC error, and expose DetourIsFunctionImported (#225)
A few minor changes:

- Expose detour_is_imported via a new public function DetourIsFunctionImported
- Make certain runtime checks happy by masking pbTarget before casting to smaller type
- Enable user to compile with a different number of supported section headers (leaves default at 32)
2022-07-06 16:36:20 -07:00
Brian Gianforcaro 3c226ee760 Tests: Fix flaky module test, which assumed it would be loaded first
In the case of ASLR this is not always true, so we should not take a
dependency on this behavior.

Reported-by: John McPherson <johnmcp@microsoft.com>>
2022-03-04 16:01:17 -08:00
Charles Milette 8cbb9e2b82 Feature: Add DetourFindRemotePayload and improve other payload-related methods (#81)
Other improvements:

- Makes the pcbData parameter 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 passing nullptr.

- Makes the pvData parameter in DetourCopyPayloadToProcess const, so that a pointer to a const C++ object can be passed instead of the object needing to be const_casted or being non-const.

- Adds DetourCopyPayloadToProcessEx, which has the same interface than DetourCopyPayloadToProcess, but it returns the address of the payload in the remote module, if the program later wants to write to it.

- Add payload example and extra unit tests covering new APIs. 

Fixes #79

Co-authored-by: Charles Milette <me@charlesmilette.net>
2021-03-06 00:22:08 -08:00
Brian Gianforcaro 0a3ab89e57 Fix + Tests: Add more tests covering the modules API, fix error handling bug that were found. (#177)
* Fix: Handle more error cases in module API.

- `DetoursFindFunction` wasn't gracefully handling NULL function name.

- `DetourEnumerateModules` wasn't resetting GLE on success.

- `DetourEnumerateExports` wasn't gracefully handling NULL export callback.

- `DetourEnumerateImports` wasn't gracefully handling NULL arguments.

* Tests: Add more tests covering the modules API.

Test basic functionality and error handling of the Detours Module API.

* DetourLoadImageHlp
* DetourFindFunction
* DetourEnumerateModules
* DetourEnumerateExports
* DetourEnumerateImports
* DetourGetSizeOfPayloads
* DetourFindPayload
* DetourFindPayloadEx
* DetourRestoreAfterWithEx
2021-03-04 22:26:33 -08:00
Brian Gianforcaro 2de2babb25 Tests: Add initial set of unit tests for Detours (#137)
- Import the Catch2 self-contained C++ test framework.
  It's used by many Microsoft OSS projects:
  - https://github.com/microsoft/cppwinrt/tree/master/test
  - https://github.com/microsoft/wil/tree/master/tests
  As well as many OSS projects in general.

  When the CMake PR is merged, we can remove this as
  a checked in development dependency, and can instead
  download it using CMake.

- Start basic set of unit tests to validate failure modes of

- Hook the execution into the existing NMake build system.

- Hook test execution into CI pipeline
2020-12-01 16:16:13 -08:00