Граф коммитов

117 Коммитов

Автор SHA1 Сообщение Дата
microsoft-github-policy-service[bot] bb7431dee5 Deleting fabricbot.json 2023-06-15 11:47:57 +00:00
microsoft-github-policy-service[bot] a609cb7127
Add prIssueManagement.yml to onboard repo to GitOps.ResourceManagement as FabricBot replacement 2023-06-15 11:47:57 +00:00
fishjam 734ac64899
fix build error for error C2065: 'GetThreadLocale': undeclared identifier (#247) 2022-08-15 16:12:45 -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
fishjam a1dd93fddf
Fix: Handle ERROR_PIPE_CONNECTED error from ConnectNamedPipe in syelogd
Fixes #241

Co-authored-by: fishjam <fish.jam@navercorp.com>
2022-06-29 17:19:42 -07:00
msftbot[bot] 61c652325c
Maintenance: Migrate FabricBot Tasks to Config-as-Code
Co-authored-by: msftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com>
2022-06-29 13:15:48 -07:00
dependabot[bot] 2ec2a2a83e Dependencies: Bump github/codeql-action from 1 to 2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1 to 2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-26 12:44:25 -07:00
dependabot[bot] 5ae79d3850 Dependencies: Bump actions/upload-artifact from 2 to 3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-11 15:36:29 -07:00
Brian Gianforcaro 332651239b Maintenance: Fix incorrect SAL annotation found by latest MSVC Analysis
warning C6553: The annotation for function 'PF_SymLoadModule64' on
                   _Param_(6) does not apply to a value type.

Flagged By: VS 17.1.0 (CL.exe 14.31.31103)
2022-03-04 16:26:14 -08:00
Brian Gianforcaro 86141cd26c CI: Switch build matrix off of windows-2016, and on to windows-2022
The github windows-2016 runner is being deprecated in the middle of
March. So lets pre-emptively move off of that and on to the next version
of the runner so we are still testing all the versions of windows we
have available.
2022-03-04 16:26:14 -08: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
dependabot[bot] 2e0b08ff97
Dependencies: Bump actions/checkout from 2 to 3 (#226)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-04 15:58:35 -08:00
Rene Nyffenegger 66d6f2d34a
Fix: Include intsafe.h when compiling with MingW (#223) 2021-11-30 12:51:05 -08:00
Mathias Berchtold 45a76a3599
DetourAttachEx: set out params to NULL on failure (#211)
Sets ppRealDetour and ppRealTarget out params to NULL on failure.
2021-08-17 10:15:40 -07:00
Jay Krell 05623a5026
Disx86: Add support for FP16. (#209)
See https://software.intel.com/content/www/us/en/develop/download/intel-avx512-fp16-architecture-specification.html

For 16bit floating point numbers, EVEX maps 5 and 6 become defined.
EVEX includes a 4 bit map.
Previously only 2 bits were allowed. Now 3.

EVEX and VEX share logic but VEX cannot encode FP16.

Tests are lacking.
2021-08-10 19:07:03 +00:00
Brian Gianforcaro 84d4356acb
GitHub: Tweak template to encourage questions to be asked in the Discussions 2021-07-19 17:45:37 -07:00
Brian Gianforcaro 2b3e7c4d79 Dependencies: Configure Dependabot to update github action versions. 2021-07-15 11:44:59 -07:00
Brian Gianforcaro fe7216c037
Maintenance: Add .editorconfig file to try to standardize formatting. (#194)
See: https://editorconfig.org

Closes: #181
2021-04-13 16:37:46 -07:00
sonyps5201314 bc7688373b
Fix: Delete payload after finish associated task (#143)
Delete the payload after finish associated task, and need change the `DETOUR_EXE_RESTORE_GUID`'s value for compatibility with these dlls that compiled by old version Detours.

For example:
- Create a pair of dlls named `dll_createwith_mysocks_32/64.dll`, their function is hooked `CreateProcess` to create any new process with it.
- Create a 32bit exe(named exe_socks) use dll_createwith_mysocks_32.dll by PE import table. So it starts any process will with dll_createwith_mysocks_32/64.dll.

- Now it starts a 32bit exe (named exe_vs), but exe_vs will load a dll (named dll_createwith_myluainject_32/64.dll) that build with detours and their function is hooked `CreateProcess` to create any new process with it.
So if `exe_vs` starts a 64bit exe, `DetourCreateProcessXXX` API will only restore the first IAT which was modified by `dll_createwith_mysocks_32/64.dll`, and `dll_createwith_myluainject_32/64.dll` modified IAT will not restore. 

Because they create payload with the same GUID `DETOUR_EXE_RESTORE_GUID`, Detours will do restore with the first founded payload twice. To fix this we need to delete the payload after the associated task finishes, immediately. If we do this then the payload with GUID `DETOUR_EXE_RESTORE_GUID` can be used by the next dll that complied by Detours.

And for compatible with these dlls that compiled by old version Detours which we don`t have source code to recompile these. So we need change `DETOUR_EXE_RESTORE_GUID`'s value to a new value, so even these dlls can not delete the payload, because we only search the new `DETOUR_EXE_RESTORE_GUID`'s value's payload, the old playload things will not executed by us.
2021-04-13 15:41:01 -07:00
sonyps5201314 7b7977d964
Revert "Maintenance: Fix Compiler Warnings (#192)" (#193)
This reverts commit 04472fc59c.
2021-04-11 04:28:24 -07:00
R. Elliott Childre 04472fc59c
Maintenance: Fix Compiler Warnings (#192)
Closes #188 and #189
2021-04-06 12:00:34 -07:00
Brian Gianforcaro 6782fe6e6a
Maintenance: Fix incorrect use of NULL to initialize DWORD (#187)
Fixes #186, found by compiling with `-Wconversion-null`
2021-03-22 14:29:05 -07:00
Charles Milette 827b89608c
Maintenance: Remove stray tabs
Work towards #181
2021-03-18 12:51:45 -07:00
Charles Milette 5034cfacc4
Fix: Address print strings regression from PR #175
Fix print strings (#184)
2021-03-18 12:48:25 -07: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
David Tarditi 108ceef1a8
Fix potential integer overflow (#182)
When injecting a DLL into a process, it is possible that the process memory has been corrupted.  The values in the import table for the process could be incorrect, which could cause an integer overflow when calculating the size of the new import table.  Add code to protect against this to UPDATE_IMPORTS_XX.
2021-03-04 22:26:20 -08:00
Charles Milette ba2c4ec872
Backport DetourAttach overloads to C++11 (#180) 2021-03-03 02:13:03 -08:00
Brian Gianforcaro 58a61c7cc6
CI: Only run CodeQL for Debug matrix configuration (#179)
The new "Debug" build now compiles all code.
So there's no use in running static analysis on Release.
2021-03-02 12:45:19 -08:00
Charles Milette 784f155d91
Feature: Add safe DetoursAttach (and friends) overloads (#178)
Fixes #176

I've also added a sample (a copy of the `simple` sample, but without the `(PVOID&)` casts) to validate the functionality.
2021-03-02 09:34:30 +00:00
Charles Milette 259ad4173a
Maintenace + CI: Enable debug logging on 'Debug' build configs (#175)
This enables 'Debug' build configs to build the debug output and breakpoints,
and fixes all mistakes that slipped in printf format specifiers.
2021-03-01 14:36:49 -08:00
Rene Nyffenegger 7f33ae3507
Prevent conflict with MINGW32 defines (#173) 2021-02-24 14:28:21 -08:00
R. Elliott Childre 9116a26025
Maintenance: Revert boolean flip (#168)
Commit 99ac5f9162 ("Maintenance: Clean up some compiler warnings") flipped a boolean check. Revert.

Reported-by: @sonyps5201314
2021-01-27 22:22:33 +00:00
Reinier Torenbeek ce9abcfff0
Minor fixes in symtest example (#167)
Fixed invocations of `SymGetModuleInfo64` and `SymEnumSymbols`
Tested on x64 only.

Output snippets from `symtest.exe` before fix:

    SymGetModuleInfo64(FFFFFFFFFFFFFFFF, 000000006EBC0000) [64] failed: 87

and

    ===Enum===
    SymEnumSymbols() failed: 318

Output snippets from `symtest.exe` after fix:

    SymGetModuleInfo64(FFFFFFFFFFFFFFFF, 000000006EBC0000) [64] succeeded: 0
    NumSyms:         0
    SymType:         3
    ModuleName:      target64
    ImageName:       target64.dll
    LoadedImageName: target64.dll

and

    ===Enum===
      000000006EBD4A60: __newclmap
      000000006EBD4A60: __newclmap
      000000006EBD2238: __guard_xfg_dispatch_icall_fptr
      000000006EBDDA40: _fltused
      000000006EBD8AC0: __mask_mant
      000000006EBDD000: SelfHidden
      000000006EBC1000: Target
      000000006EBC1060: Hidden
2021-01-27 16:56:32 +00:00
R. Elliott Childre 99ac5f9162
Maintenance: Clean up some compiler warnings (#166)
Spotted with MinGW32 g++

* `uimports.cpp`: `IMAGE_DATA_DIRECTORY.VirtualAddress` is a `DWORD`
  type, not a pointer type, so compare against a scalar type.
* `creatwth.cpp`: `LoadNtHeaderFromProcess` returns a `BOOL`, so compare
  with falsey check.

```sh
i686-w64-mingw32-g++ -c -Wall -Wextra -Wpedantic ./creatwth.cpp

# In file included from ./creatwth.cpp:329:
# ./uimports.cpp: In function 'BOOL UpdateImports32(HANDLE, HMODULE, const CHAR**, DWORD)':
# ./uimports.cpp:109:48: warning: NULL used in arithmetic [-Wpointer-arith]
#   109 |     if (inh.IMPORT_DIRECTORY.VirtualAddress != NULL && inh.IMPORT_DIRECTORY.Size == 0) {
#       |                                                ^~~~
# ./creatwth.cpp: In function 'BOOL DetourUpdateProcessWithDllEx(HANDLE, HMODULE, BOOL, const CHAR**, DWORD)':
# ./creatwth.cpp:624:80: warning: NULL used in arithmetic [-Wpointer-arith]
#   624 |     if (hModule == NULL || LoadNtHeaderFromProcess(hProcess, hModule, &inh) == NULL) {
#       |                                                                                ^~~~
```
2021-01-27 02:35:07 +00:00
Brian Gianforcaro 8be832ee51 Maintenance: Reformat CREDITS.TXT -> CREDITS.md 2021-01-24 06:07:32 -08:00
Brian Gianforcaro 58cb9a0bfb
CI: Follow major version of ilammy/msvc-dev-cmd to get latest fixes (#165)
The @v1 tag is maintained with latest changes automatically. Use this
tag instead of having to manually update on every minor version.
2021-01-24 04:49:58 -08:00
Brian Gianforcaro 2ba03b38a4
CI: `git checkout HEAD^2` step is no longer necessary (#164)
The CI builds now report this warning:

```
1 issue was detected with this workflow: git checkout HEAD^2 is no longer necessary.
Please remove this step as Code Scanning recommends analyzing the merge commit for best results
```

This step was recommended, but is now unnecessary apparently.
2021-01-24 03:40:59 -08:00
sonyps5201314 57172d09c0
Fix createwith failure when run against some protected binaries (#140)
Fix can not use createwith api to start some unnormal exe, like chinese online, commercial, protected game dnf.exe https://dnf.qq.com/, but this exe can start run by explorer.
2021-01-24 03:33:25 -08:00
Dustin Spicuzza e64fe0f6b3
Allow compilation with MinGW to succeed (#108)
- Tested with 7.3-win32 20180312

Co-authored-by: Brian Gianforcaro <b.gianfo@gmail.com>
2021-01-24 02:44:06 -08:00
number201724 39aa864d29
Maintenance: Fix compiler error C2362 in creatwth.cpp
Compile error:

    error C2362: initialization of 'cchWrittenWideChar' is skipped by 'goto Cleanup'
2020-12-16 15:07:34 -08:00
Brian Gianforcaro 90f54c2ed7
Maintenance: Remove unused variables found static analysis (#156)
- CodeQL found these unused variables, remove them.
2020-12-13 22:43:59 -08:00
Brian Gianforcaro 092243d9e5
Maintenance: Add missing header include guards (#155) 2020-12-08 11:17:20 -08:00
Brian Gianforcaro 666cf50468
CI: Fix action workflow to use latests msvc cmd version (#153)
Detours CI was broken by a deprecation in the github actions API.
We need to bump to the latest version of msvc action to get the fix.
2020-12-02 00:24:53 -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
Yogesh B d8b8144c54
Fixed#116 via changing to signed for negative diff (#146)
Addressed : Issue #116 [syelogd] Negative timing difference between successive events with option /d (delta time)
2020-09-30 15:15:06 -07:00
Brian Gianforcaro a3bdeaf006
README.md link to License file 2020-09-07 00:27:30 +00:00
sonyps5201314 73e9a0a34c
add vs solution, it is safety because it only call nmake command, and it is friendly for edit, modify and debug code in Detours (#138) 2020-09-07 00:26:00 +00:00
Jay Krell 5c919c80d2
Remove opcode fields from COPYENTRY as it isn't used, except (#17)
These are only used for a self-check, and aren't needed.
2020-09-06 22:32:02 +00:00
sonyps5201314 a9e6186a88
Fix createwith exe with path containing special characters or unicode languages (#142)
Currently we can not use createwith API to start exes which path contain special characters or unicode languages like Chinese.
This change fixes that by formatting the string path correctly.
2020-09-06 18:04:40 +00:00