Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RenardDev authored Sep 19, 2024
1 parent e4013c8 commit 4070ea0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7668,11 +7668,11 @@ namespace Detours {
#endif
unsigned long long unDisp = 0;

if (pReadOperand->Info.Memory.HasBase && pReadOperand->Info.Memory.BaseSize) {
if (pReadOperand->Info.Memory.HasBase) {
unBase = GetRegisterValue(pCTX, pReadOperand->Info.Memory.Base, pReadOperand->Info.Memory.BaseSize);
}

if (pReadOperand->Info.Memory.HasIndex && pReadOperand->Info.Memory.IndexSize) {
if (pReadOperand->Info.Memory.HasIndex) {
unIndex = GetRegisterValue(pCTX, pReadOperand->Info.Memory.Index, pReadOperand->Info.Memory.IndexSize) * pReadOperand->Info.Memory.Scale;
}

Expand Down Expand Up @@ -7816,11 +7816,11 @@ namespace Detours {
#endif
unsigned long long unDisp = 0;

if (pWriteOperand->Info.Memory.HasBase && pWriteOperand->Info.Memory.BaseSize) {
if (pWriteOperand->Info.Memory.HasBase) {
unBase = GetRegisterValue(pCTX, pWriteOperand->Info.Memory.Base, pWriteOperand->Info.Memory.BaseSize);
}

if (pWriteOperand->Info.Memory.HasIndex && pWriteOperand->Info.Memory.IndexSize) {
if (pWriteOperand->Info.Memory.HasIndex) {
unIndex = GetRegisterValue(pCTX, pWriteOperand->Info.Memory.Index, pWriteOperand->Info.Memory.IndexSize) * pWriteOperand->Info.Memory.Scale;
}

Expand Down
10 changes: 5 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ TEST_SUITE("Detours::Hook") {
#ifndef DEBUG
// FIXME: MemoryHook don't support instructions with imm in write operand
// Like `mov dword ptr [1], 0xDEEDBEEF`
#pragma optimize("g", off)
#pragma optimize("", off)
#endif

TEST_CASE("MemoryHook 3") {
Expand All @@ -1914,9 +1914,9 @@ TEST_SUITE("Detours::Hook") {
pVirtualAddress[1] = 0xDEEDFACE;
pVirtualAddress[2] = 0xFACE;

printf("*(0x1) = 0x%X\n", pVirtualAddress[0]);
printf("*(0x1 + 4) = 0x%X\n", pVirtualAddress[1]);
printf("*(0x1 + 8) = 0x%X\n", pVirtualAddress[2]);
//printf("*(0x1) = 0x%X\n", pVirtualAddress[0]);
//printf("*(0x1 + 4) = 0x%X\n", pVirtualAddress[1]);
//printf("*(0x1 + 8) = 0x%X\n", pVirtualAddress[2]);

CHECK(pVirtualAddress[0] == 0xDEEDBEEF);
CHECK(pVirtualAddress[1] == 0xDEEDFACE);
Expand All @@ -1926,7 +1926,7 @@ TEST_SUITE("Detours::Hook") {
}

#ifndef DEBUG
#pragma optimize("g", on)
#pragma optimize("", on)
#endif

TEST_CASE("MemoryHook [benchmark]" * doctest::skip(false)) {
Expand Down

0 comments on commit 4070ea0

Please sign in to comment.